/** * Fixed child extension for ACP sessions. * * The ACP adapter always passes this module with `--extension` next to the MCP bootstrap * extension. It owns the plan/build mode that ACP's `session/set_mode` selects: * * - `build` keeps the tools the session started with. * - `plan` declares only plan-allowed tools: the built-in readers, `todo_write` (which changes * only the session plan), and MCP tools whose server marks them read-only * (`annotations.readOnlyHint === true`). Its `tool_call` handler blocks every tool that is not * plan-allowed, including `write`, `edit`, `bash`, `powershell`, unproven MCP tools and custom * or extension tools prepared before the switch. This also covers calls nested in codemode * scripts. * * The mode is deliberately not persisted in the transcript: every ACP child starts in `build`, * and the adapter sends `set_mode build` once the child is ready. `session/new` and * `session/resume` therefore both report `build`; T3 re-applies plan mode from its own * interaction mode after activation. */ import type { SessionMode, SessionModeState } from "@agentclientprotocol/sdk"; import type { ExtensionAPI } from "../../core/extensions/types.ts"; export declare const ACP_BUILD_MODE_ID = "build"; export declare const ACP_PLAN_MODE_ID = "plan"; /** Set by the adapter for its owned RPC child; plain RPC, print and TUI never set it. */ export declare const ACP_SESSION_ENV = "SELESAI_ACP_SESSION"; /** The permission options offered for a tool approval; `reject_always` is never offered. */ export declare const ACP_TOOL_PERMISSION_OPTIONS: readonly [{ readonly optionId: "allow_once"; readonly name: "Allow once"; readonly kind: "allow_once"; }, { readonly optionId: "allow_always"; readonly name: "Always allow this session"; readonly kind: "allow_always"; }, { readonly optionId: "reject_once"; readonly name: "Reject"; readonly kind: "reject_once"; }]; export type AcpPermissionOptionId = (typeof ACP_TOOL_PERMISSION_OPTIONS)[number]["optionId"]; export declare function isAcpPermissionOptionId(value: unknown): value is AcpPermissionOptionId; /** Only an explicit allow runs the tool; every other answer, including a rejection, denies it. */ export declare function isAcpPermissionAllowOptionId(value: unknown): boolean; export declare const ACP_SESSION_MODES: readonly SessionMode[]; export type AcpSessionModeId = typeof ACP_BUILD_MODE_ID | typeof ACP_PLAN_MODE_ID; /** Built-in tools that only read the workspace and stay declared in plan mode. */ export declare const PLAN_MODE_READ_TOOLS: readonly string[]; /** The plan tool changes only the session todo list, which is how plan mode records its plan. */ export declare const PLAN_MODE_PLANNING_TOOL = "todo_write"; /** The tool fields the mode policy needs; `ToolInfo` satisfies this shape. */ export interface AcpModeToolInfo { name: string; annotations?: { readOnlyHint?: boolean; }; } /** Private session EventBus channel; only the fixed child extension answers it. */ export declare const ACP_SESSION_MODE_EVENT = "acp:session-mode:v1"; export interface AcpSessionModeResult { mode: AcpSessionModeId; activeTools: string[]; } /** Host-to-child request. `respond` is called synchronously by the fixed child extension. */ export interface AcpSessionModeRequest { version: 1; mode: AcpSessionModeId; respond(result: AcpSessionModeResult): void; } export declare function isAcpSessionModeId(value: unknown): value is AcpSessionModeId; export declare function isAcpSessionModeRequest(value: unknown): value is AcpSessionModeRequest; /** The mode state advertised by `session/new`, `session/resume` and T19's `session/load`. */ export declare function createAcpSessionModeState(mode: AcpSessionModeId): SessionModeState; /** * Whether plan mode allows a tool: exactly the built-in readers, `todo_write`, and MCP tools the * server marks read-only. Every other tool, including unknown custom tools, is not allowed. */ export declare function planModeAllowsTool(tool: AcpModeToolInfo): boolean; /** The plan-allowed subset of `tools` that plan mode declares to the model. */ export declare function planModeActiveTools(tools: readonly AcpModeToolInfo[]): string[]; /** Absolute path of this fixed extension for `--extension`; `.ts` while running from source. */ export declare function childExtensionPath(): string; export default function acpChildExtension(pi: ExtensionAPI): void;