/** * Type definitions for OpenCode SDK integration */ import type { AskUserQuestionHandler } from '../../core/workflow/types.js'; import type { Language, OpenCodeGuardOptions, PermissionMode } from '../../core/models/index.js'; import type { ProviderActivityCallback, StreamCallback } from '../../shared/types/provider.js'; /** OpenCode permission reply values */ export type OpenCodePermissionReply = 'once' | 'always' | 'reject'; export type OpenCodePermissionAction = 'ask' | 'allow' | 'deny'; export type OpenCodePermissionRule = { permission: string; pattern: string; action: OpenCodePermissionAction; }; /** Map TAKT PermissionMode to OpenCode permission reply */ export declare function mapToOpenCodePermissionReply(mode: PermissionMode): OpenCodePermissionReply; export declare function resolveOpenCodePermissionReply(mode: PermissionMode | undefined, permission?: string, allowedToolsRuleset?: readonly OpenCodePermissionRule[]): OpenCodePermissionReply; declare const OPEN_CODE_PERMISSION_KEYS: readonly ["read", "glob", "grep", "edit", "write", "bash", "task", "todowrite", "websearch", "webfetch", "question"]; export type OpenCodePermissionKey = typeof OPEN_CODE_PERMISSION_KEYS[number]; export type OpenCodePermissionMap = Record; export declare function buildOpenCodePermissionRuleset(mode?: PermissionMode, networkAccess?: boolean, allowedTools?: OpenCodeAllowedTools, allowedMcpTools?: readonly string[]): OpenCodePermissionRule[]; export type OpenCodeAllowedTools = readonly string[]; /** * Build the permission ruleset used at session creation. * * A session-scoped `deny` can never be escalated later (verified against a * live OpenCode server: neither agent-level `allow` nor a new ruleset can * override it), while TAKT reuses one session across step phases and the * report phase needs file writes on read-only steps. Therefore `edit`/`write` * denies are lifted to `allow` at session scope (`ask` rules stay: the * permission auto-reply already approves them per phase) and the per-phase * restriction is enforced by the explicit per-prompt tools map instead * (see buildOpenCodePromptTools). * * `external_directory` is denied explicitly. Note that this session-scoped * rule only holds until the first prompt: a prompt-level tools map is * materialized into `session.permission` by OpenCode and replaces this * ruleset. The authoritative deny lives in the server config passed to * `createOpencode` (see client.ts), which the rewrite does not touch; the * rule here covers the window before the first prompt. */ export declare function buildOpenCodeSessionPermission(mode?: PermissionMode, networkAccess?: boolean, allowedTools?: OpenCodeAllowedTools, allowedMcpTools?: readonly string[]): OpenCodePermissionRule[]; /** * ワイヤ(per-prompt tools マップ)でのみ送る ID。現行 opencode(1.17.18 の * `/experimental/tool/ids` で実測: invalid, question, bash, read, glob, grep, * edit, write, task, webfetch, todowrite, websearch, skill, apply_patch)の * registry に存在せず、モデルからは呼べない。旧バージョン互換の制御のため * だけに送り続けるが、モデル向けの有効ツール一覧には決して載せない * (v3-r4: recovery 前置文が 'list' を「利用可能」と誤誘導し、fresh session * 後も同名再発 → 確定失敗した死因の再発防止)。 * * 'list' の扱い: TAKT の list 互換シム(plugins/list-tool.ts)が登録された * サーバでは 'list' は実ツールになり、写像 read → list:true がそのまま可視性 * 制御として機能する(read 無効フェーズでは非表示)。シムの登録は起動時の * registry プローブで upstream 衝突を排除した場合のみ(client.ts の * shouldRegisterListToolShim)。シム無効時もワイヤ送信は継続する(無害・ * 旧バージョン互換)。 */ export declare const OPEN_CODE_WIRE_ONLY_TOOL_IDS: readonly string[]; /** 全プロンプトで明示するツール ID の完全集合(固着リーク防止の契約) */ export declare const OPEN_CODE_MANAGED_TOOL_IDS: readonly string[]; /** * Build the explicit per-prompt tools map that enforces the current phase's * tool restriction on a shared session. * * The map is sent with every prompt and always covers the full managed tool * set: OpenCode persists the last explicit map on the session, so omitting a * key would silently leak the previous phase's restriction into the next one * (verified against a live OpenCode server). */ export declare function buildOpenCodePromptTools(mode?: PermissionMode, networkAccess?: boolean, allowedTools?: OpenCodeAllowedTools, allowedMcpTools?: readonly string[]): Record; export declare function resolveOpenCodeAllowedPermissions(mode: PermissionMode | undefined, networkAccess: boolean | undefined, allowedTools: OpenCodeAllowedTools, allowedMcpTools?: readonly string[]): string[]; /** Options for calling OpenCode */ export interface OpenCodeCallOptions { cwd: string; abortSignal?: AbortSignal; sessionId?: string; model: string; systemPrompt?: string; /** Resolved OpenCode tool allowlist from provider_options.opencode.allowed_tools. */ allowedTools?: OpenCodeAllowedTools; /** Trusted task-state MCP tools in OpenCode's normalized permission names. */ allowedMcpTools?: readonly string[]; permissionMode?: PermissionMode; networkAccess?: boolean; variant?: string; /** Guard feature switches from provider_options.opencode.guards. */ guards?: OpenCodeGuardOptions; onStream?: StreamCallback; onActivity?: ProviderActivityCallback; onAskUserQuestion?: AskUserQuestionHandler; opencodeApiKey?: string; interactionTimeoutMs?: number; childProcessEnv?: Readonly>; /** JSON schema for native structured output (OpenCode format: json_schema). */ outputSchema?: Record; language?: Language; /** Provider-prepared MCP material (issue #1137). */ preparedMcp?: import('../providers/mcp/types.js').PreparedProviderMcp; } export interface OpenCodeCompactSessionOptions { cwd: string; sessionId: string; model: string; abortSignal?: AbortSignal; opencodeApiKey?: string; childProcessEnv?: Readonly>; } export {}; //# sourceMappingURL=types.d.ts.map