/** * The editor an ACP session runs in, as tools an agent can use: the editor's files and terminal, * through the ACP connection, and the MCP servers the editor offers for the session. * * ```ts * const editor = acpEditor(); * const agent = createAgent({ client: ai, toolSource: editor.toolSource, interruptOn: { editor_write_file: true } }); * serveAcp(agent, { input: process.stdin, output: process.stdout }, { editor }); * ``` * * A tool is offered only when the editor said it can do that thing, in `initialize`. Each declares * what it touches, as `filesystem:read:`, `filesystem:write:`, or `shell:`, so a * permission policy decides it like any other tool, and an approval asks the person in the editor. An * MCP server's tools, over stdio, HTTP, or SSE, declare what their server says they do. */ import type { ToolSourceContext } from '../agent/create-agent.js'; import { type McpToolDescriptor } from '../mcp/client.js'; import type { ToolDefinition } from '../types/messages.js'; import type { AcpEditorBridge } from './acp.js'; /** Options for `acpEditor()`. */ export interface AcpEditorOptions { /** Offers the editor's files, when the editor can read or write them. Defaults to true. */ files?: boolean; /** Offers the editor's terminal, when the editor has one. Defaults to true. */ terminal?: boolean; /** Connects the MCP servers the editor offers for a session, and offers their tools. Defaults to true. */ mcp?: boolean; /** How long a request to an MCP server may take, in milliseconds. Defaults to 30 seconds. */ mcpTimeoutMs?: number; /** Replaces `fetch` for MCP servers reached over HTTP or SSE: a proxy, or a test. */ mcpFetch?: typeof globalThis.fetch; /** * What an MCP server's tools declare they do, for a permission policy. `true`, the default, reads * it from the server's annotations, with `mcpToolCapabilities()`: `mcp.read`, `mcp.write`, or * `mcp.destructive` under the server's name, and `network` for a tool that reaches beyond it. A * function decides per tool, and `false` declares nothing, as before 2.17. */ mcpToolCapabilities?: boolean | ((tool: McpToolDescriptor, server: string) => readonly string[] | undefined); /** The most terminal output a command returns, in bytes. Defaults to 64 KB. */ maxOutputBytes?: number; /** Receives an MCP server that failed to start, whose tools are then not offered. */ onError?: (error: unknown, server: string) => void; } /** The editor, as tools for an agent. */ export interface AcpEditor extends AcpEditorBridge { /** The MCP transports it connects, which the agent tells the editor in `initialize`. */ readonly mcpCapabilities: { http: boolean; sse: boolean; }; /** The tools of one session, for `CreateAgentOptions.toolSource`: the session is the run's thread. */ toolSource(context: ToolSourceContext): Promise; /** Closes every MCP server it connected. */ close(): Promise; } /** The editor's files, terminal, and MCP servers, as tools an agent's `toolSource` supplies per session. */ export declare function acpEditor(options?: AcpEditorOptions): AcpEditor;