import { AgentApp, AgentConnection, SessionUpdate, Stream } from '@agentclientprotocol/sdk/experimental/v2'; import { StreamChunk } from '@tanstack/ai'; import { AnyHarness, HarnessHost, HarnessUser } from '@tanstack/ai-harness'; export interface AcpAgentOptions { host: HarnessHost; harness: AnyHarness; /** * The user that the agent serves: an editor starts the agent for one * local user. Each session opens as this user, and `session/list` * shows the sessions of this user. Required when the host has * `access`. */ user?: U; /** Reported in `initialize`. Default `'0.0.0'`. */ version?: string; /** * The working directory that `session/list` reports for each session. * Default `process.cwd()`. */ cwd?: string; } /** * One AG-UI chunk as an ACP session update, or `undefined` to skip it. * `args` collects the argument deltas of each tool call: its full input goes * out as `rawInput` when the call's arguments end. */ export declare function toSessionUpdate(chunk: StreamChunk, args?: Map): SessionUpdate | undefined; /** * An ACP v2 agent backed by a harness. Each ACP session is one harness * session, and `session/list` reads the top-level sessions of the harness from * the session index of the host. The prompts of a session run one after * another, whatever the harness `busy` setting says. Each wait of a turn * goes to the editor by its kind: an approval becomes a * `session/request_permission` request (with `allow_always` for an approval * of `permissions()`), a question or a `human` wait a form elicitation, and * a sign-in a URL elicitation, when the editor declares them in * `initialize`. A wait that the editor cannot answer is cancelled. Cancel * cancels the running turn. Image, audio, and embedded resource blocks of a prompt go to the media * store of the session. A file the harness refuses (too big, or a type it * does not take) fails `session/prompt` with an invalid params error. * * Each session opens as `user`. On a host with `access`, the host * checks each action, and a session that the user may not read is not * found. Without `user`, a host with access throws at the start. * * The agent holds a handle on a session only while the session has work: a * new session, or prompts that run or wait in its queue. When the queue is * empty, the agent releases the handle, and the host closes the session when * it is idle. The next prompt opens it again. `session/close` and the close * of the connection release the handles too. `session/resume` only checks the * session index: the session opens at its first prompt. * * One app serves one connection: it keeps the session handles and prompt * queues of that connection, and a second connection to it throws. For more * connections, make one app for each, for example * `new AcpServer({ createAgent: () => createAcpAgent(options) })`. * * ACP v2 is a draft, so this API is experimental too. */ export declare function createAcpAgent(options: AcpAgentOptions): AgentApp; /** * Serve a harness as an ACP v2 agent over a stream. With no stream, it uses * stdin and stdout as newline-delimited JSON (for editors that start the * agent as a process). The sessions open as `user`, as in * `createAcpAgent`. * * @example * ```ts * serveAcp({ host, harness: assistant, user: { id: 'local-user' } }) * ``` */ export declare function serveAcp(options: AcpAgentOptions & { stream?: Stream; }): AgentConnection;