leduo-patrol 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/server/__tests__/acp-session.test.js +92 -0
- package/dist/server/__tests__/activity-monitor.test.js +13 -1
- package/dist/server/__tests__/session-manager.test.js +215 -1
- package/dist/server/acp-session.js +476 -0
- package/dist/server/activity-monitor.js +22 -7
- package/dist/server/index.js +54 -1
- package/dist/server/session-manager.js +1117 -121
- package/dist/web/assets/index-B-YXVUoQ.css +1 -0
- package/dist/web/assets/index-Bu0K7QgY.js +21 -0
- package/dist/web/index.html +2 -2
- package/package.json +3 -1
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/LICENSE +191 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/README.md +53 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.d.ts +823 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.js +965 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.test.d.ts +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.test.js +839 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/acp.test.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/agent.d.ts +2 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/agent.js +225 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/agent.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/client.d.ts +2 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/client.js +130 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/examples/client.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.d.ts +35 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js +5 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/index.d.ts +27 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/index.js +28 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/index.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.d.ts +2870 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.js +3 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.d.ts +5333 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js +1554 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/stream.d.ts +24 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/stream.js +64 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/package.json +66 -0
- package/vendor/claude-code-acp/node_modules/@agentclientprotocol/sdk/schema/schema.json +4125 -0
- package/vendor/claude-code-acp/node_modules/@types/node/LICENSE +21 -0
- package/vendor/claude-code-acp/node_modules/@types/node/README.md +15 -0
- package/vendor/claude-code-acp/node_modules/@types/node/assert/strict.d.ts +105 -0
- package/vendor/claude-code-acp/node_modules/@types/node/assert.d.ts +955 -0
- package/vendor/claude-code-acp/node_modules/@types/node/async_hooks.d.ts +623 -0
- package/vendor/claude-code-acp/node_modules/@types/node/buffer.buffer.d.ts +466 -0
- package/vendor/claude-code-acp/node_modules/@types/node/buffer.d.ts +1810 -0
- package/vendor/claude-code-acp/node_modules/@types/node/child_process.d.ts +1428 -0
- package/vendor/claude-code-acp/node_modules/@types/node/cluster.d.ts +486 -0
- package/vendor/claude-code-acp/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/vendor/claude-code-acp/node_modules/@types/node/console.d.ts +151 -0
- package/vendor/claude-code-acp/node_modules/@types/node/constants.d.ts +20 -0
- package/vendor/claude-code-acp/node_modules/@types/node/crypto.d.ts +4065 -0
- package/vendor/claude-code-acp/node_modules/@types/node/dgram.d.ts +564 -0
- package/vendor/claude-code-acp/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
- package/vendor/claude-code-acp/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/vendor/claude-code-acp/node_modules/@types/node/dns.d.ts +922 -0
- package/vendor/claude-code-acp/node_modules/@types/node/domain.d.ts +166 -0
- package/vendor/claude-code-acp/node_modules/@types/node/events.d.ts +1054 -0
- package/vendor/claude-code-acp/node_modules/@types/node/fs/promises.d.ts +1329 -0
- package/vendor/claude-code-acp/node_modules/@types/node/fs.d.ts +4676 -0
- package/vendor/claude-code-acp/node_modules/@types/node/globals.d.ts +150 -0
- package/vendor/claude-code-acp/node_modules/@types/node/globals.typedarray.d.ts +101 -0
- package/vendor/claude-code-acp/node_modules/@types/node/http.d.ts +2167 -0
- package/vendor/claude-code-acp/node_modules/@types/node/http2.d.ts +2480 -0
- package/vendor/claude-code-acp/node_modules/@types/node/https.d.ts +405 -0
- package/vendor/claude-code-acp/node_modules/@types/node/index.d.ts +115 -0
- package/vendor/claude-code-acp/node_modules/@types/node/inspector/promises.d.ts +41 -0
- package/vendor/claude-code-acp/node_modules/@types/node/inspector.d.ts +224 -0
- package/vendor/claude-code-acp/node_modules/@types/node/inspector.generated.d.ts +4226 -0
- package/vendor/claude-code-acp/node_modules/@types/node/module.d.ts +819 -0
- package/vendor/claude-code-acp/node_modules/@types/node/net.d.ts +933 -0
- package/vendor/claude-code-acp/node_modules/@types/node/os.d.ts +507 -0
- package/vendor/claude-code-acp/node_modules/@types/node/package.json +155 -0
- package/vendor/claude-code-acp/node_modules/@types/node/path/posix.d.ts +8 -0
- package/vendor/claude-code-acp/node_modules/@types/node/path/win32.d.ts +8 -0
- package/vendor/claude-code-acp/node_modules/@types/node/path.d.ts +187 -0
- package/vendor/claude-code-acp/node_modules/@types/node/perf_hooks.d.ts +643 -0
- package/vendor/claude-code-acp/node_modules/@types/node/process.d.ts +2161 -0
- package/vendor/claude-code-acp/node_modules/@types/node/punycode.d.ts +117 -0
- package/vendor/claude-code-acp/node_modules/@types/node/querystring.d.ts +152 -0
- package/vendor/claude-code-acp/node_modules/@types/node/quic.d.ts +910 -0
- package/vendor/claude-code-acp/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/vendor/claude-code-acp/node_modules/@types/node/readline.d.ts +541 -0
- package/vendor/claude-code-acp/node_modules/@types/node/repl.d.ts +415 -0
- package/vendor/claude-code-acp/node_modules/@types/node/sea.d.ts +162 -0
- package/vendor/claude-code-acp/node_modules/@types/node/sqlite.d.ts +955 -0
- package/vendor/claude-code-acp/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/vendor/claude-code-acp/node_modules/@types/node/stream/promises.d.ts +211 -0
- package/vendor/claude-code-acp/node_modules/@types/node/stream/web.d.ts +296 -0
- package/vendor/claude-code-acp/node_modules/@types/node/stream.d.ts +1760 -0
- package/vendor/claude-code-acp/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/vendor/claude-code-acp/node_modules/@types/node/test/reporters.d.ts +96 -0
- package/vendor/claude-code-acp/node_modules/@types/node/test.d.ts +2240 -0
- package/vendor/claude-code-acp/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/vendor/claude-code-acp/node_modules/@types/node/timers.d.ts +159 -0
- package/vendor/claude-code-acp/node_modules/@types/node/tls.d.ts +1198 -0
- package/vendor/claude-code-acp/node_modules/@types/node/trace_events.d.ts +197 -0
- package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
- package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/vendor/claude-code-acp/node_modules/@types/node/ts5.6/index.d.ts +117 -0
- package/vendor/claude-code-acp/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/vendor/claude-code-acp/node_modules/@types/node/ts5.7/index.d.ts +117 -0
- package/vendor/claude-code-acp/node_modules/@types/node/tty.d.ts +250 -0
- package/vendor/claude-code-acp/node_modules/@types/node/url.d.ts +519 -0
- package/vendor/claude-code-acp/node_modules/@types/node/util/types.d.ts +558 -0
- package/vendor/claude-code-acp/node_modules/@types/node/util.d.ts +1662 -0
- package/vendor/claude-code-acp/node_modules/@types/node/v8.d.ts +983 -0
- package/vendor/claude-code-acp/node_modules/@types/node/vm.d.ts +1208 -0
- package/vendor/claude-code-acp/node_modules/@types/node/wasi.d.ts +202 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/events.d.ts +106 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/streams.d.ts +115 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/vendor/claude-code-acp/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/vendor/claude-code-acp/node_modules/@types/node/worker_threads.d.ts +717 -0
- package/vendor/claude-code-acp/node_modules/@types/node/zlib.d.ts +618 -0
- package/vendor/claude-code-acp/node_modules/undici-types/LICENSE +21 -0
- package/vendor/claude-code-acp/node_modules/undici-types/README.md +6 -0
- package/vendor/claude-code-acp/node_modules/undici-types/agent.d.ts +32 -0
- package/vendor/claude-code-acp/node_modules/undici-types/api.d.ts +43 -0
- package/vendor/claude-code-acp/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/vendor/claude-code-acp/node_modules/undici-types/cache-interceptor.d.ts +172 -0
- package/vendor/claude-code-acp/node_modules/undici-types/cache.d.ts +36 -0
- package/vendor/claude-code-acp/node_modules/undici-types/client-stats.d.ts +15 -0
- package/vendor/claude-code-acp/node_modules/undici-types/client.d.ts +108 -0
- package/vendor/claude-code-acp/node_modules/undici-types/connector.d.ts +34 -0
- package/vendor/claude-code-acp/node_modules/undici-types/content-type.d.ts +21 -0
- package/vendor/claude-code-acp/node_modules/undici-types/cookies.d.ts +30 -0
- package/vendor/claude-code-acp/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/vendor/claude-code-acp/node_modules/undici-types/dispatcher.d.ts +276 -0
- package/vendor/claude-code-acp/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/vendor/claude-code-acp/node_modules/undici-types/errors.d.ts +161 -0
- package/vendor/claude-code-acp/node_modules/undici-types/eventsource.d.ts +66 -0
- package/vendor/claude-code-acp/node_modules/undici-types/fetch.d.ts +211 -0
- package/vendor/claude-code-acp/node_modules/undici-types/formdata.d.ts +108 -0
- package/vendor/claude-code-acp/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/vendor/claude-code-acp/node_modules/undici-types/global-origin.d.ts +7 -0
- package/vendor/claude-code-acp/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/vendor/claude-code-acp/node_modules/undici-types/handlers.d.ts +15 -0
- package/vendor/claude-code-acp/node_modules/undici-types/header.d.ts +160 -0
- package/vendor/claude-code-acp/node_modules/undici-types/index.d.ts +80 -0
- package/vendor/claude-code-acp/node_modules/undici-types/interceptors.d.ts +39 -0
- package/vendor/claude-code-acp/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/vendor/claude-code-acp/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/vendor/claude-code-acp/node_modules/undici-types/mock-client.d.ts +27 -0
- package/vendor/claude-code-acp/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/vendor/claude-code-acp/node_modules/undici-types/mock-interceptor.d.ts +94 -0
- package/vendor/claude-code-acp/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/vendor/claude-code-acp/node_modules/undici-types/package.json +55 -0
- package/vendor/claude-code-acp/node_modules/undici-types/patch.d.ts +29 -0
- package/vendor/claude-code-acp/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/vendor/claude-code-acp/node_modules/undici-types/pool.d.ts +41 -0
- package/vendor/claude-code-acp/node_modules/undici-types/proxy-agent.d.ts +29 -0
- package/vendor/claude-code-acp/node_modules/undici-types/readable.d.ts +68 -0
- package/vendor/claude-code-acp/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/vendor/claude-code-acp/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/vendor/claude-code-acp/node_modules/undici-types/snapshot-agent.d.ts +109 -0
- package/vendor/claude-code-acp/node_modules/undici-types/util.d.ts +18 -0
- package/vendor/claude-code-acp/node_modules/undici-types/utility.d.ts +7 -0
- package/vendor/claude-code-acp/node_modules/undici-types/webidl.d.ts +341 -0
- package/vendor/claude-code-acp/node_modules/undici-types/websocket.d.ts +186 -0
- package/dist/web/assets/index-B5Dh2E8j.css +0 -1
- package/dist/web/assets/index-xPPPaEde.js +0 -13
|
@@ -0,0 +1,823 @@
|
|
|
1
|
+
import * as schema from "./schema/index.js";
|
|
2
|
+
export type * from "./schema/types.gen.js";
|
|
3
|
+
export * from "./schema/index.js";
|
|
4
|
+
export * from "./stream.js";
|
|
5
|
+
import type { Stream } from "./stream.js";
|
|
6
|
+
import type { Result, ErrorResponse, RequestHandler, NotificationHandler } from "./jsonrpc.js";
|
|
7
|
+
/**
|
|
8
|
+
* An agent-side connection to a client.
|
|
9
|
+
*
|
|
10
|
+
* This class provides the agent's view of an ACP connection, allowing
|
|
11
|
+
* agents to communicate with clients. It implements the {@link Client} interface
|
|
12
|
+
* to provide methods for requesting permissions, accessing the file system,
|
|
13
|
+
* and sending session updates.
|
|
14
|
+
*
|
|
15
|
+
* See protocol docs: [Agent](https://agentclientprotocol.com/protocol/overview#agent)
|
|
16
|
+
*/
|
|
17
|
+
export declare class AgentSideConnection {
|
|
18
|
+
#private;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new agent-side connection to a client.
|
|
21
|
+
*
|
|
22
|
+
* This establishes the communication channel from the agent's perspective
|
|
23
|
+
* following the ACP specification.
|
|
24
|
+
*
|
|
25
|
+
* @param toAgent - A function that creates an Agent handler to process incoming client requests
|
|
26
|
+
* @param stream - The bidirectional message stream for communication. Typically created using
|
|
27
|
+
* {@link ndJsonStream} for stdio-based connections.
|
|
28
|
+
*
|
|
29
|
+
* See protocol docs: [Communication Model](https://agentclientprotocol.com/protocol/overview#communication-model)
|
|
30
|
+
*/
|
|
31
|
+
constructor(toAgent: (conn: AgentSideConnection) => Agent, stream: Stream);
|
|
32
|
+
/**
|
|
33
|
+
* Handles session update notifications from the agent.
|
|
34
|
+
*
|
|
35
|
+
* This is a notification endpoint (no response expected) that sends
|
|
36
|
+
* real-time updates about session progress, including message chunks,
|
|
37
|
+
* tool calls, and execution plans.
|
|
38
|
+
*
|
|
39
|
+
* Note: Clients SHOULD continue accepting tool call updates even after
|
|
40
|
+
* sending a `session/cancel` notification, as the agent may send final
|
|
41
|
+
* updates before responding with the cancelled stop reason.
|
|
42
|
+
*
|
|
43
|
+
* See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
|
|
44
|
+
*/
|
|
45
|
+
sessionUpdate(params: schema.SessionNotification): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Requests permission from the user for a tool call operation.
|
|
48
|
+
*
|
|
49
|
+
* Called by the agent when it needs user authorization before executing
|
|
50
|
+
* a potentially sensitive operation. The client should present the options
|
|
51
|
+
* to the user and return their decision.
|
|
52
|
+
*
|
|
53
|
+
* If the client cancels the prompt turn via `session/cancel`, it MUST
|
|
54
|
+
* respond to this request with `RequestPermissionOutcome::Cancelled`.
|
|
55
|
+
*
|
|
56
|
+
* See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
|
|
57
|
+
*/
|
|
58
|
+
requestPermission(params: schema.RequestPermissionRequest): Promise<schema.RequestPermissionResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Reads content from a text file in the client's file system.
|
|
61
|
+
*
|
|
62
|
+
* Only available if the client advertises the `fs.readTextFile` capability.
|
|
63
|
+
* Allows the agent to access file contents within the client's environment.
|
|
64
|
+
*
|
|
65
|
+
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
|
|
66
|
+
*/
|
|
67
|
+
readTextFile(params: schema.ReadTextFileRequest): Promise<schema.ReadTextFileResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Writes content to a text file in the client's file system.
|
|
70
|
+
*
|
|
71
|
+
* Only available if the client advertises the `fs.writeTextFile` capability.
|
|
72
|
+
* Allows the agent to create or modify files within the client's environment.
|
|
73
|
+
*
|
|
74
|
+
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
|
|
75
|
+
*/
|
|
76
|
+
writeTextFile(params: schema.WriteTextFileRequest): Promise<schema.WriteTextFileResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Executes a command in a new terminal.
|
|
79
|
+
*
|
|
80
|
+
* Returns a `TerminalHandle` that can be used to get output, wait for exit,
|
|
81
|
+
* kill the command, or release the terminal.
|
|
82
|
+
*
|
|
83
|
+
* The terminal can also be embedded in tool calls by using its ID in
|
|
84
|
+
* `ToolCallContent` with type "terminal".
|
|
85
|
+
*
|
|
86
|
+
* @param params - The terminal creation parameters
|
|
87
|
+
* @returns A handle to control and monitor the terminal
|
|
88
|
+
*/
|
|
89
|
+
createTerminal(params: schema.CreateTerminalRequest): Promise<TerminalHandle>;
|
|
90
|
+
/**
|
|
91
|
+
* Extension method
|
|
92
|
+
*
|
|
93
|
+
* Allows the Agent to send an arbitrary request that is not part of the ACP spec.
|
|
94
|
+
*/
|
|
95
|
+
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
96
|
+
/**
|
|
97
|
+
* Extension notification
|
|
98
|
+
*
|
|
99
|
+
* Allows the Agent to send an arbitrary notification that is not part of the ACP spec.
|
|
100
|
+
*/
|
|
101
|
+
extNotification(method: string, params: Record<string, unknown>): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* AbortSignal that aborts when the connection closes.
|
|
104
|
+
*
|
|
105
|
+
* This signal can be used to:
|
|
106
|
+
* - Listen for connection closure: `connection.signal.addEventListener('abort', () => {...})`
|
|
107
|
+
* - Check connection status synchronously: `if (connection.signal.aborted) {...}`
|
|
108
|
+
* - Pass to other APIs (fetch, setTimeout) for automatic cancellation
|
|
109
|
+
*
|
|
110
|
+
* The connection closes when the underlying stream ends, either normally or due to an error.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const connection = new AgentSideConnection(agent, stream);
|
|
115
|
+
*
|
|
116
|
+
* // Listen for closure
|
|
117
|
+
* connection.signal.addEventListener('abort', () => {
|
|
118
|
+
* console.log('Connection closed - performing cleanup');
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* // Check status
|
|
122
|
+
* if (connection.signal.aborted) {
|
|
123
|
+
* console.log('Connection is already closed');
|
|
124
|
+
* }
|
|
125
|
+
*
|
|
126
|
+
* // Pass to other APIs
|
|
127
|
+
* fetch(url, { signal: connection.signal });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
get signal(): AbortSignal;
|
|
131
|
+
/**
|
|
132
|
+
* Promise that resolves when the connection closes.
|
|
133
|
+
*
|
|
134
|
+
* The connection closes when the underlying stream ends, either normally or due to an error.
|
|
135
|
+
* Once closed, the connection cannot send or receive any more messages.
|
|
136
|
+
*
|
|
137
|
+
* This is useful for async/await style cleanup:
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const connection = new AgentSideConnection(agent, stream);
|
|
142
|
+
* await connection.closed;
|
|
143
|
+
* console.log('Connection closed - performing cleanup');
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
get closed(): Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Handle for controlling and monitoring a terminal created via `createTerminal`.
|
|
150
|
+
*
|
|
151
|
+
* Provides methods to:
|
|
152
|
+
* - Get current output without waiting
|
|
153
|
+
* - Wait for command completion
|
|
154
|
+
* - Kill the running command
|
|
155
|
+
* - Release terminal resources
|
|
156
|
+
*
|
|
157
|
+
* **Important:** Always call `release()` when done with the terminal to free resources.
|
|
158
|
+
|
|
159
|
+
* The terminal supports async disposal via `Symbol.asyncDispose` for automatic cleanup.
|
|
160
|
+
|
|
161
|
+
* You can use `await using` to ensure the terminal is automatically released when it
|
|
162
|
+
* goes out of scope.
|
|
163
|
+
*/
|
|
164
|
+
export declare class TerminalHandle {
|
|
165
|
+
#private;
|
|
166
|
+
id: string;
|
|
167
|
+
constructor(id: string, sessionId: string, conn: Connection);
|
|
168
|
+
/**
|
|
169
|
+
* Gets the current terminal output without waiting for the command to exit.
|
|
170
|
+
*/
|
|
171
|
+
currentOutput(): Promise<schema.TerminalOutputResponse>;
|
|
172
|
+
/**
|
|
173
|
+
* Waits for the terminal command to complete and returns its exit status.
|
|
174
|
+
*/
|
|
175
|
+
waitForExit(): Promise<schema.WaitForTerminalExitResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Kills the terminal command without releasing the terminal.
|
|
178
|
+
*
|
|
179
|
+
* The terminal remains valid after killing, allowing you to:
|
|
180
|
+
* - Get the final output with `currentOutput()`
|
|
181
|
+
* - Check the exit status
|
|
182
|
+
* - Release the terminal when done
|
|
183
|
+
*
|
|
184
|
+
* Useful for implementing timeouts or cancellation.
|
|
185
|
+
*/
|
|
186
|
+
kill(): Promise<schema.KillTerminalCommandResponse>;
|
|
187
|
+
/**
|
|
188
|
+
* Releases the terminal and frees all associated resources.
|
|
189
|
+
*
|
|
190
|
+
* If the command is still running, it will be killed.
|
|
191
|
+
* After release, the terminal ID becomes invalid and cannot be used
|
|
192
|
+
* with other terminal methods.
|
|
193
|
+
*
|
|
194
|
+
* Tool calls that already reference this terminal will continue to
|
|
195
|
+
* display its output.
|
|
196
|
+
*
|
|
197
|
+
* **Important:** Always call this method when done with the terminal.
|
|
198
|
+
*/
|
|
199
|
+
release(): Promise<schema.ReleaseTerminalResponse | void>;
|
|
200
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A client-side connection to an agent.
|
|
204
|
+
*
|
|
205
|
+
* This class provides the client's view of an ACP connection, allowing
|
|
206
|
+
* clients (such as code editors) to communicate with agents. It implements
|
|
207
|
+
* the {@link Agent} interface to provide methods for initializing sessions, sending
|
|
208
|
+
* prompts, and managing the agent lifecycle.
|
|
209
|
+
*
|
|
210
|
+
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
|
|
211
|
+
*/
|
|
212
|
+
export declare class ClientSideConnection implements Agent {
|
|
213
|
+
#private;
|
|
214
|
+
/**
|
|
215
|
+
* Creates a new client-side connection to an agent.
|
|
216
|
+
*
|
|
217
|
+
* This establishes the communication channel between a client and agent
|
|
218
|
+
* following the ACP specification.
|
|
219
|
+
*
|
|
220
|
+
* @param toClient - A function that creates a Client handler to process incoming agent requests
|
|
221
|
+
* @param stream - The bidirectional message stream for communication. Typically created using
|
|
222
|
+
* {@link ndJsonStream} for stdio-based connections.
|
|
223
|
+
*
|
|
224
|
+
* See protocol docs: [Communication Model](https://agentclientprotocol.com/protocol/overview#communication-model)
|
|
225
|
+
*/
|
|
226
|
+
constructor(toClient: (agent: Agent) => Client, stream: Stream);
|
|
227
|
+
/**
|
|
228
|
+
* Establishes the connection with a client and negotiates protocol capabilities.
|
|
229
|
+
*
|
|
230
|
+
* This method is called once at the beginning of the connection to:
|
|
231
|
+
* - Negotiate the protocol version to use
|
|
232
|
+
* - Exchange capability information between client and agent
|
|
233
|
+
* - Determine available authentication methods
|
|
234
|
+
*
|
|
235
|
+
* The agent should respond with its supported protocol version and capabilities.
|
|
236
|
+
*
|
|
237
|
+
* See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
|
|
238
|
+
*/
|
|
239
|
+
initialize(params: schema.InitializeRequest): Promise<schema.InitializeResponse>;
|
|
240
|
+
/**
|
|
241
|
+
* Creates a new conversation session with the agent.
|
|
242
|
+
*
|
|
243
|
+
* Sessions represent independent conversation contexts with their own history and state.
|
|
244
|
+
*
|
|
245
|
+
* The agent should:
|
|
246
|
+
* - Create a new session context
|
|
247
|
+
* - Connect to any specified MCP servers
|
|
248
|
+
* - Return a unique session ID for future requests
|
|
249
|
+
*
|
|
250
|
+
* May return an `auth_required` error if the agent requires authentication.
|
|
251
|
+
*
|
|
252
|
+
* See protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)
|
|
253
|
+
*/
|
|
254
|
+
newSession(params: schema.NewSessionRequest): Promise<schema.NewSessionResponse>;
|
|
255
|
+
/**
|
|
256
|
+
* Loads an existing session to resume a previous conversation.
|
|
257
|
+
*
|
|
258
|
+
* This method is only available if the agent advertises the `loadSession` capability.
|
|
259
|
+
*
|
|
260
|
+
* The agent should:
|
|
261
|
+
* - Restore the session context and conversation history
|
|
262
|
+
* - Connect to the specified MCP servers
|
|
263
|
+
* - Stream the entire conversation history back to the client via notifications
|
|
264
|
+
*
|
|
265
|
+
* See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)
|
|
266
|
+
*/
|
|
267
|
+
loadSession(params: schema.LoadSessionRequest): Promise<schema.LoadSessionResponse>;
|
|
268
|
+
/**
|
|
269
|
+
* **UNSTABLE**
|
|
270
|
+
*
|
|
271
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
272
|
+
*
|
|
273
|
+
* Forks an existing session to create a new independent session.
|
|
274
|
+
*
|
|
275
|
+
* Creates a new session based on the context of an existing one, allowing
|
|
276
|
+
* operations like generating summaries without affecting the original session's history.
|
|
277
|
+
*
|
|
278
|
+
* This method is only available if the agent advertises the `session.fork` capability.
|
|
279
|
+
*
|
|
280
|
+
* @experimental
|
|
281
|
+
*/
|
|
282
|
+
unstable_forkSession(params: schema.ForkSessionRequest): Promise<schema.ForkSessionResponse>;
|
|
283
|
+
/**
|
|
284
|
+
* **UNSTABLE**
|
|
285
|
+
*
|
|
286
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
287
|
+
*
|
|
288
|
+
* Lists existing sessions from the agent.
|
|
289
|
+
*
|
|
290
|
+
* This method is only available if the agent advertises the `listSessions` capability.
|
|
291
|
+
*
|
|
292
|
+
* Returns a list of sessions with metadata like session ID, working directory,
|
|
293
|
+
* title, and last update time. Supports filtering by working directory and
|
|
294
|
+
* cursor-based pagination.
|
|
295
|
+
*
|
|
296
|
+
* @experimental
|
|
297
|
+
*/
|
|
298
|
+
unstable_listSessions(params: schema.ListSessionsRequest): Promise<schema.ListSessionsResponse>;
|
|
299
|
+
/**
|
|
300
|
+
* **UNSTABLE**
|
|
301
|
+
*
|
|
302
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
303
|
+
*
|
|
304
|
+
* Resumes an existing session without returning previous messages.
|
|
305
|
+
*
|
|
306
|
+
* This method is only available if the agent advertises the `session.resume` capability.
|
|
307
|
+
*
|
|
308
|
+
* The agent should resume the session context, allowing the conversation to continue
|
|
309
|
+
* without replaying the message history (unlike `session/load`).
|
|
310
|
+
*
|
|
311
|
+
* @experimental
|
|
312
|
+
*/
|
|
313
|
+
unstable_resumeSession(params: schema.ResumeSessionRequest): Promise<schema.ResumeSessionResponse>;
|
|
314
|
+
/**
|
|
315
|
+
* Sets the operational mode for a session.
|
|
316
|
+
*
|
|
317
|
+
* Allows switching between different agent modes (e.g., "ask", "architect", "code")
|
|
318
|
+
* that affect system prompts, tool availability, and permission behaviors.
|
|
319
|
+
*
|
|
320
|
+
* The mode must be one of the modes advertised in `availableModes` during session
|
|
321
|
+
* creation or loading. Agents may also change modes autonomously and notify the
|
|
322
|
+
* client via `current_mode_update` notifications.
|
|
323
|
+
*
|
|
324
|
+
* This method can be called at any time during a session, whether the Agent is
|
|
325
|
+
* idle or actively generating a turn.
|
|
326
|
+
*
|
|
327
|
+
* See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
|
|
328
|
+
*/
|
|
329
|
+
setSessionMode(params: schema.SetSessionModeRequest): Promise<schema.SetSessionModeResponse>;
|
|
330
|
+
/**
|
|
331
|
+
* **UNSTABLE**
|
|
332
|
+
*
|
|
333
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
334
|
+
*
|
|
335
|
+
* Select a model for a given session.
|
|
336
|
+
*
|
|
337
|
+
* @experimental
|
|
338
|
+
*/
|
|
339
|
+
unstable_setSessionModel(params: schema.SetSessionModelRequest): Promise<schema.SetSessionModelResponse>;
|
|
340
|
+
/**
|
|
341
|
+
* Set a configuration option for a given session.
|
|
342
|
+
*
|
|
343
|
+
* The response contains the full set of configuration options and their current values,
|
|
344
|
+
* as changing one option may affect the available values or state of other options.
|
|
345
|
+
*/
|
|
346
|
+
setSessionConfigOption(params: schema.SetSessionConfigOptionRequest): Promise<schema.SetSessionConfigOptionResponse>;
|
|
347
|
+
/**
|
|
348
|
+
* Authenticates the client using the specified authentication method.
|
|
349
|
+
*
|
|
350
|
+
* Called when the agent requires authentication before allowing session creation.
|
|
351
|
+
* The client provides the authentication method ID that was advertised during initialization.
|
|
352
|
+
*
|
|
353
|
+
* After successful authentication, the client can proceed to create sessions with
|
|
354
|
+
* `newSession` without receiving an `auth_required` error.
|
|
355
|
+
*
|
|
356
|
+
* See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
|
|
357
|
+
*/
|
|
358
|
+
authenticate(params: schema.AuthenticateRequest): Promise<schema.AuthenticateResponse>;
|
|
359
|
+
/**
|
|
360
|
+
* Processes a user prompt within a session.
|
|
361
|
+
*
|
|
362
|
+
* This method handles the whole lifecycle of a prompt:
|
|
363
|
+
* - Receives user messages with optional context (files, images, etc.)
|
|
364
|
+
* - Processes the prompt using language models
|
|
365
|
+
* - Reports language model content and tool calls to the Clients
|
|
366
|
+
* - Requests permission to run tools
|
|
367
|
+
* - Executes any requested tool calls
|
|
368
|
+
* - Returns when the turn is complete with a stop reason
|
|
369
|
+
*
|
|
370
|
+
* See protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)
|
|
371
|
+
*/
|
|
372
|
+
prompt(params: schema.PromptRequest): Promise<schema.PromptResponse>;
|
|
373
|
+
/**
|
|
374
|
+
* Cancels ongoing operations for a session.
|
|
375
|
+
*
|
|
376
|
+
* This is a notification sent by the client to cancel an ongoing prompt turn.
|
|
377
|
+
*
|
|
378
|
+
* Upon receiving this notification, the Agent SHOULD:
|
|
379
|
+
* - Stop all language model requests as soon as possible
|
|
380
|
+
* - Abort all tool call invocations in progress
|
|
381
|
+
* - Send any pending `session/update` notifications
|
|
382
|
+
* - Respond to the original `session/prompt` request with `StopReason::Cancelled`
|
|
383
|
+
*
|
|
384
|
+
* See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
|
|
385
|
+
*/
|
|
386
|
+
cancel(params: schema.CancelNotification): Promise<void>;
|
|
387
|
+
/**
|
|
388
|
+
* Extension method
|
|
389
|
+
*
|
|
390
|
+
* Allows the Client to send an arbitrary request that is not part of the ACP spec.
|
|
391
|
+
*/
|
|
392
|
+
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
393
|
+
/**
|
|
394
|
+
* Extension notification
|
|
395
|
+
*
|
|
396
|
+
* Allows the Client to send an arbitrary notification that is not part of the ACP spec.
|
|
397
|
+
*/
|
|
398
|
+
extNotification(method: string, params: Record<string, unknown>): Promise<void>;
|
|
399
|
+
/**
|
|
400
|
+
* AbortSignal that aborts when the connection closes.
|
|
401
|
+
*
|
|
402
|
+
* This signal can be used to:
|
|
403
|
+
* - Listen for connection closure: `connection.signal.addEventListener('abort', () => {...})`
|
|
404
|
+
* - Check connection status synchronously: `if (connection.signal.aborted) {...}`
|
|
405
|
+
* - Pass to other APIs (fetch, setTimeout) for automatic cancellation
|
|
406
|
+
*
|
|
407
|
+
* The connection closes when the underlying stream ends, either normally or due to an error.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```typescript
|
|
411
|
+
* const connection = new ClientSideConnection(client, stream);
|
|
412
|
+
*
|
|
413
|
+
* // Listen for closure
|
|
414
|
+
* connection.signal.addEventListener('abort', () => {
|
|
415
|
+
* console.log('Connection closed - performing cleanup');
|
|
416
|
+
* });
|
|
417
|
+
*
|
|
418
|
+
* // Check status
|
|
419
|
+
* if (connection.signal.aborted) {
|
|
420
|
+
* console.log('Connection is already closed');
|
|
421
|
+
* }
|
|
422
|
+
*
|
|
423
|
+
* // Pass to other APIs
|
|
424
|
+
* fetch(url, { signal: connection.signal });
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
get signal(): AbortSignal;
|
|
428
|
+
/**
|
|
429
|
+
* Promise that resolves when the connection closes.
|
|
430
|
+
*
|
|
431
|
+
* The connection closes when the underlying stream ends, either normally or due to an error.
|
|
432
|
+
* Once closed, the connection cannot send or receive any more messages.
|
|
433
|
+
*
|
|
434
|
+
* This is useful for async/await style cleanup:
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* const connection = new ClientSideConnection(client, stream);
|
|
439
|
+
* await connection.closed;
|
|
440
|
+
* console.log('Connection closed - performing cleanup');
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
get closed(): Promise<void>;
|
|
444
|
+
}
|
|
445
|
+
export type { AnyMessage } from "./jsonrpc.js";
|
|
446
|
+
declare class Connection {
|
|
447
|
+
#private;
|
|
448
|
+
constructor(requestHandler: RequestHandler, notificationHandler: NotificationHandler, stream: Stream);
|
|
449
|
+
/**
|
|
450
|
+
* AbortSignal that aborts when the connection closes.
|
|
451
|
+
*
|
|
452
|
+
* This signal can be used to:
|
|
453
|
+
* - Listen for connection closure via event listeners
|
|
454
|
+
* - Check connection status synchronously with `signal.aborted`
|
|
455
|
+
* - Pass to other APIs (fetch, setTimeout) for automatic cancellation
|
|
456
|
+
*/
|
|
457
|
+
get signal(): AbortSignal;
|
|
458
|
+
/**
|
|
459
|
+
* Promise that resolves when the connection closes.
|
|
460
|
+
*
|
|
461
|
+
* The connection closes when the underlying stream ends, either normally
|
|
462
|
+
* or due to an error. Once closed, the connection cannot send or receive
|
|
463
|
+
* any more messages.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const connection = new ClientSideConnection(client, stream);
|
|
468
|
+
* await connection.closed;
|
|
469
|
+
* console.log('Connection closed - performing cleanup');
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
get closed(): Promise<void>;
|
|
473
|
+
sendRequest<Req, Resp>(method: string, params?: Req): Promise<Resp>;
|
|
474
|
+
sendNotification<N>(method: string, params?: N): Promise<void>;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* JSON-RPC error object.
|
|
478
|
+
*
|
|
479
|
+
* Represents an error that occurred during method execution, following the
|
|
480
|
+
* JSON-RPC 2.0 error object specification with optional additional data.
|
|
481
|
+
*
|
|
482
|
+
* See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)
|
|
483
|
+
*/
|
|
484
|
+
export declare class RequestError extends Error {
|
|
485
|
+
code: number;
|
|
486
|
+
data?: unknown;
|
|
487
|
+
constructor(code: number, message: string, data?: unknown);
|
|
488
|
+
/**
|
|
489
|
+
* Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
|
|
490
|
+
*/
|
|
491
|
+
static parseError(data?: unknown, additionalMessage?: string): RequestError;
|
|
492
|
+
/**
|
|
493
|
+
* The JSON sent is not a valid Request object.
|
|
494
|
+
*/
|
|
495
|
+
static invalidRequest(data?: unknown, additionalMessage?: string): RequestError;
|
|
496
|
+
/**
|
|
497
|
+
* The method does not exist / is not available.
|
|
498
|
+
*/
|
|
499
|
+
static methodNotFound(method: string): RequestError;
|
|
500
|
+
/**
|
|
501
|
+
* Invalid method parameter(s).
|
|
502
|
+
*/
|
|
503
|
+
static invalidParams(data?: unknown, additionalMessage?: string): RequestError;
|
|
504
|
+
/**
|
|
505
|
+
* Internal JSON-RPC error.
|
|
506
|
+
*/
|
|
507
|
+
static internalError(data?: unknown, additionalMessage?: string): RequestError;
|
|
508
|
+
/**
|
|
509
|
+
* Authentication required.
|
|
510
|
+
*/
|
|
511
|
+
static authRequired(data?: unknown, additionalMessage?: string): RequestError;
|
|
512
|
+
/**
|
|
513
|
+
* Resource, such as a file, was not found
|
|
514
|
+
*/
|
|
515
|
+
static resourceNotFound(uri?: string): RequestError;
|
|
516
|
+
toResult<T>(): Result<T>;
|
|
517
|
+
toErrorResponse(): ErrorResponse;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* The Client interface defines the interface that ACP-compliant clients must implement.
|
|
521
|
+
*
|
|
522
|
+
* Clients are typically code editors (IDEs, text editors) that provide the interface
|
|
523
|
+
* between users and AI agents. They manage the environment, handle user interactions,
|
|
524
|
+
* and control access to resources.
|
|
525
|
+
*/
|
|
526
|
+
export interface Client {
|
|
527
|
+
/**
|
|
528
|
+
* Requests permission from the user for a tool call operation.
|
|
529
|
+
*
|
|
530
|
+
* Called by the agent when it needs user authorization before executing
|
|
531
|
+
* a potentially sensitive operation. The client should present the options
|
|
532
|
+
* to the user and return their decision.
|
|
533
|
+
*
|
|
534
|
+
* If the client cancels the prompt turn via `session/cancel`, it MUST
|
|
535
|
+
* respond to this request with `RequestPermissionOutcome::Cancelled`.
|
|
536
|
+
*
|
|
537
|
+
* See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
|
|
538
|
+
*/
|
|
539
|
+
requestPermission(params: schema.RequestPermissionRequest): Promise<schema.RequestPermissionResponse>;
|
|
540
|
+
/**
|
|
541
|
+
* Handles session update notifications from the agent.
|
|
542
|
+
*
|
|
543
|
+
* This is a notification endpoint (no response expected) that receives
|
|
544
|
+
* real-time updates about session progress, including message chunks,
|
|
545
|
+
* tool calls, and execution plans.
|
|
546
|
+
*
|
|
547
|
+
* Note: Clients SHOULD continue accepting tool call updates even after
|
|
548
|
+
* sending a `session/cancel` notification, as the agent may send final
|
|
549
|
+
* updates before responding with the cancelled stop reason.
|
|
550
|
+
*
|
|
551
|
+
* See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
|
|
552
|
+
*/
|
|
553
|
+
sessionUpdate(params: schema.SessionNotification): Promise<void>;
|
|
554
|
+
/**
|
|
555
|
+
* Writes content to a text file in the client's file system.
|
|
556
|
+
*
|
|
557
|
+
* Only available if the client advertises the `fs.writeTextFile` capability.
|
|
558
|
+
* Allows the agent to create or modify files within the client's environment.
|
|
559
|
+
*
|
|
560
|
+
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
|
|
561
|
+
*/
|
|
562
|
+
writeTextFile?(params: schema.WriteTextFileRequest): Promise<schema.WriteTextFileResponse>;
|
|
563
|
+
/**
|
|
564
|
+
* Reads content from a text file in the client's file system.
|
|
565
|
+
*
|
|
566
|
+
* Only available if the client advertises the `fs.readTextFile` capability.
|
|
567
|
+
* Allows the agent to access file contents within the client's environment.
|
|
568
|
+
*
|
|
569
|
+
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
|
|
570
|
+
*/
|
|
571
|
+
readTextFile?(params: schema.ReadTextFileRequest): Promise<schema.ReadTextFileResponse>;
|
|
572
|
+
/**
|
|
573
|
+
* Creates a new terminal to execute a command.
|
|
574
|
+
*
|
|
575
|
+
* Only available if the `terminal` capability is set to `true`.
|
|
576
|
+
*
|
|
577
|
+
* The Agent must call `releaseTerminal` when done with the terminal
|
|
578
|
+
* to free resources.
|
|
579
|
+
|
|
580
|
+
* @see {@link https://agentclientprotocol.com/protocol/terminals | Terminal Documentation}
|
|
581
|
+
*/
|
|
582
|
+
createTerminal?(params: schema.CreateTerminalRequest): Promise<schema.CreateTerminalResponse>;
|
|
583
|
+
/**
|
|
584
|
+
* Gets the current output and exit status of a terminal.
|
|
585
|
+
*
|
|
586
|
+
* Returns immediately without waiting for the command to complete.
|
|
587
|
+
* If the command has already exited, the exit status is included.
|
|
588
|
+
*
|
|
589
|
+
* @see {@link https://agentclientprotocol.com/protocol/terminals#getting-output | Getting Terminal Output}
|
|
590
|
+
*/
|
|
591
|
+
terminalOutput?(params: schema.TerminalOutputRequest): Promise<schema.TerminalOutputResponse>;
|
|
592
|
+
/**
|
|
593
|
+
* Releases a terminal and frees all associated resources.
|
|
594
|
+
*
|
|
595
|
+
* The command is killed if it hasn't exited yet. After release,
|
|
596
|
+
* the terminal ID becomes invalid for all other terminal methods.
|
|
597
|
+
*
|
|
598
|
+
* Tool calls that already contain the terminal ID continue to
|
|
599
|
+
* display its output.
|
|
600
|
+
*
|
|
601
|
+
* @see {@link https://agentclientprotocol.com/protocol/terminals#releasing-terminals | Releasing Terminals}
|
|
602
|
+
*/
|
|
603
|
+
releaseTerminal?(params: schema.ReleaseTerminalRequest): Promise<schema.ReleaseTerminalResponse | void>;
|
|
604
|
+
/**
|
|
605
|
+
* Waits for a terminal command to exit and returns its exit status.
|
|
606
|
+
*
|
|
607
|
+
* This method returns once the command completes, providing the
|
|
608
|
+
* exit code and/or signal that terminated the process.
|
|
609
|
+
*
|
|
610
|
+
* @see {@link https://agentclientprotocol.com/protocol/terminals#waiting-for-exit | Waiting for Exit}
|
|
611
|
+
*/
|
|
612
|
+
waitForTerminalExit?(params: schema.WaitForTerminalExitRequest): Promise<schema.WaitForTerminalExitResponse>;
|
|
613
|
+
/**
|
|
614
|
+
* Kills a terminal command without releasing the terminal.
|
|
615
|
+
*
|
|
616
|
+
* While `releaseTerminal` also kills the command, this method keeps
|
|
617
|
+
* the terminal ID valid so it can be used with other methods.
|
|
618
|
+
*
|
|
619
|
+
* Useful for implementing command timeouts that terminate the command
|
|
620
|
+
* and then retrieve the final output.
|
|
621
|
+
*
|
|
622
|
+
* Note: Call `releaseTerminal` when the terminal is no longer needed.
|
|
623
|
+
*
|
|
624
|
+
* @see {@link https://agentclientprotocol.com/protocol/terminals#killing-commands | Killing Commands}
|
|
625
|
+
*/
|
|
626
|
+
killTerminal?(params: schema.KillTerminalCommandRequest): Promise<schema.KillTerminalCommandResponse | void>;
|
|
627
|
+
/**
|
|
628
|
+
* Extension method
|
|
629
|
+
*
|
|
630
|
+
* Allows the Agent to send an arbitrary request that is not part of the ACP spec.
|
|
631
|
+
*
|
|
632
|
+
* To help avoid conflicts, it's a good practice to prefix extension
|
|
633
|
+
* methods with a unique identifier such as domain name.
|
|
634
|
+
*/
|
|
635
|
+
extMethod?(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
636
|
+
/**
|
|
637
|
+
* Extension notification
|
|
638
|
+
*
|
|
639
|
+
* Allows the Agent to send an arbitrary notification that is not part of the ACP spec.
|
|
640
|
+
*/
|
|
641
|
+
extNotification?(method: string, params: Record<string, unknown>): Promise<void>;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* The Agent interface defines the interface that all ACP-compliant agents must implement.
|
|
645
|
+
*
|
|
646
|
+
* Agents are programs that use generative AI to autonomously modify code. They handle
|
|
647
|
+
* requests from clients and execute tasks using language models and tools.
|
|
648
|
+
*/
|
|
649
|
+
export interface Agent {
|
|
650
|
+
/**
|
|
651
|
+
* Establishes the connection with a client and negotiates protocol capabilities.
|
|
652
|
+
*
|
|
653
|
+
* This method is called once at the beginning of the connection to:
|
|
654
|
+
* - Negotiate the protocol version to use
|
|
655
|
+
* - Exchange capability information between client and agent
|
|
656
|
+
* - Determine available authentication methods
|
|
657
|
+
*
|
|
658
|
+
* The agent should respond with its supported protocol version and capabilities.
|
|
659
|
+
*
|
|
660
|
+
* See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
|
|
661
|
+
*/
|
|
662
|
+
initialize(params: schema.InitializeRequest): Promise<schema.InitializeResponse>;
|
|
663
|
+
/**
|
|
664
|
+
* Creates a new conversation session with the agent.
|
|
665
|
+
*
|
|
666
|
+
* Sessions represent independent conversation contexts with their own history and state.
|
|
667
|
+
*
|
|
668
|
+
* The agent should:
|
|
669
|
+
* - Create a new session context
|
|
670
|
+
* - Connect to any specified MCP servers
|
|
671
|
+
* - Return a unique session ID for future requests
|
|
672
|
+
*
|
|
673
|
+
* May return an `auth_required` error if the agent requires authentication.
|
|
674
|
+
*
|
|
675
|
+
* See protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)
|
|
676
|
+
*/
|
|
677
|
+
newSession(params: schema.NewSessionRequest): Promise<schema.NewSessionResponse>;
|
|
678
|
+
/**
|
|
679
|
+
* Loads an existing session to resume a previous conversation.
|
|
680
|
+
*
|
|
681
|
+
* This method is only available if the agent advertises the `loadSession` capability.
|
|
682
|
+
*
|
|
683
|
+
* The agent should:
|
|
684
|
+
* - Restore the session context and conversation history
|
|
685
|
+
* - Connect to the specified MCP servers
|
|
686
|
+
* - Stream the entire conversation history back to the client via notifications
|
|
687
|
+
*
|
|
688
|
+
* See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)
|
|
689
|
+
*/
|
|
690
|
+
loadSession?(params: schema.LoadSessionRequest): Promise<schema.LoadSessionResponse>;
|
|
691
|
+
/**
|
|
692
|
+
* **UNSTABLE**
|
|
693
|
+
*
|
|
694
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
695
|
+
*
|
|
696
|
+
* Forks an existing session to create a new independent session.
|
|
697
|
+
*
|
|
698
|
+
* Creates a new session based on the context of an existing one, allowing
|
|
699
|
+
* operations like generating summaries without affecting the original session's history.
|
|
700
|
+
*
|
|
701
|
+
* This method is only available if the agent advertises the `session.fork` capability.
|
|
702
|
+
*
|
|
703
|
+
* @experimental
|
|
704
|
+
*/
|
|
705
|
+
unstable_forkSession?(params: schema.ForkSessionRequest): Promise<schema.ForkSessionResponse>;
|
|
706
|
+
/**
|
|
707
|
+
* **UNSTABLE**
|
|
708
|
+
*
|
|
709
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
710
|
+
*
|
|
711
|
+
* Lists existing sessions from the agent.
|
|
712
|
+
*
|
|
713
|
+
* This method is only available if the agent advertises the `listSessions` capability.
|
|
714
|
+
*
|
|
715
|
+
* Returns a list of sessions with metadata like session ID, working directory,
|
|
716
|
+
* title, and last update time. Supports filtering by working directory and
|
|
717
|
+
* cursor-based pagination.
|
|
718
|
+
*/
|
|
719
|
+
unstable_listSessions?(params: schema.ListSessionsRequest): Promise<schema.ListSessionsResponse>;
|
|
720
|
+
/**
|
|
721
|
+
* **UNSTABLE**
|
|
722
|
+
*
|
|
723
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
724
|
+
*
|
|
725
|
+
* Resumes an existing session without returning previous messages.
|
|
726
|
+
*
|
|
727
|
+
* This method is only available if the agent advertises the `session.resume` capability.
|
|
728
|
+
*
|
|
729
|
+
* The agent should resume the session context, allowing the conversation to continue
|
|
730
|
+
* without replaying the message history (unlike `session/load`).
|
|
731
|
+
*
|
|
732
|
+
* @experimental
|
|
733
|
+
*/
|
|
734
|
+
unstable_resumeSession?(params: schema.ResumeSessionRequest): Promise<schema.ResumeSessionResponse>;
|
|
735
|
+
/**
|
|
736
|
+
* Sets the operational mode for a session.
|
|
737
|
+
*
|
|
738
|
+
* Allows switching between different agent modes (e.g., "ask", "architect", "code")
|
|
739
|
+
* that affect system prompts, tool availability, and permission behaviors.
|
|
740
|
+
*
|
|
741
|
+
* The mode must be one of the modes advertised in `availableModes` during session
|
|
742
|
+
* creation or loading. Agents may also change modes autonomously and notify the
|
|
743
|
+
* client via `current_mode_update` notifications.
|
|
744
|
+
*
|
|
745
|
+
* This method can be called at any time during a session, whether the Agent is
|
|
746
|
+
* idle or actively generating a turn.
|
|
747
|
+
*
|
|
748
|
+
* See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
|
|
749
|
+
*/
|
|
750
|
+
setSessionMode?(params: schema.SetSessionModeRequest): Promise<schema.SetSessionModeResponse | void>;
|
|
751
|
+
/**
|
|
752
|
+
* **UNSTABLE**
|
|
753
|
+
*
|
|
754
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
755
|
+
*
|
|
756
|
+
* Select a model for a given session.
|
|
757
|
+
*
|
|
758
|
+
* @experimental
|
|
759
|
+
*/
|
|
760
|
+
unstable_setSessionModel?(params: schema.SetSessionModelRequest): Promise<schema.SetSessionModelResponse | void>;
|
|
761
|
+
/**
|
|
762
|
+
* Set a configuration option for a given session.
|
|
763
|
+
*
|
|
764
|
+
* The response contains the full set of configuration options and their current values,
|
|
765
|
+
* as changing one option may affect the available values or state of other options.
|
|
766
|
+
*/
|
|
767
|
+
setSessionConfigOption?(params: schema.SetSessionConfigOptionRequest): Promise<schema.SetSessionConfigOptionResponse>;
|
|
768
|
+
/**
|
|
769
|
+
* Authenticates the client using the specified authentication method.
|
|
770
|
+
*
|
|
771
|
+
* Called when the agent requires authentication before allowing session creation.
|
|
772
|
+
* The client provides the authentication method ID that was advertised during initialization.
|
|
773
|
+
*
|
|
774
|
+
* After successful authentication, the client can proceed to create sessions with
|
|
775
|
+
* `newSession` without receiving an `auth_required` error.
|
|
776
|
+
*
|
|
777
|
+
* See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
|
|
778
|
+
*/
|
|
779
|
+
authenticate(params: schema.AuthenticateRequest): Promise<schema.AuthenticateResponse | void>;
|
|
780
|
+
/**
|
|
781
|
+
* Processes a user prompt within a session.
|
|
782
|
+
*
|
|
783
|
+
* This method handles the whole lifecycle of a prompt:
|
|
784
|
+
* - Receives user messages with optional context (files, images, etc.)
|
|
785
|
+
* - Processes the prompt using language models
|
|
786
|
+
* - Reports language model content and tool calls to the Clients
|
|
787
|
+
* - Requests permission to run tools
|
|
788
|
+
* - Executes any requested tool calls
|
|
789
|
+
* - Returns when the turn is complete with a stop reason
|
|
790
|
+
*
|
|
791
|
+
* See protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)
|
|
792
|
+
*/
|
|
793
|
+
prompt(params: schema.PromptRequest): Promise<schema.PromptResponse>;
|
|
794
|
+
/**
|
|
795
|
+
* Cancels ongoing operations for a session.
|
|
796
|
+
*
|
|
797
|
+
* This is a notification sent by the client to cancel an ongoing prompt turn.
|
|
798
|
+
*
|
|
799
|
+
* Upon receiving this notification, the Agent SHOULD:
|
|
800
|
+
* - Stop all language model requests as soon as possible
|
|
801
|
+
* - Abort all tool call invocations in progress
|
|
802
|
+
* - Send any pending `session/update` notifications
|
|
803
|
+
* - Respond to the original `session/prompt` request with `StopReason::Cancelled`
|
|
804
|
+
*
|
|
805
|
+
* See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
|
|
806
|
+
*/
|
|
807
|
+
cancel(params: schema.CancelNotification): Promise<void>;
|
|
808
|
+
/**
|
|
809
|
+
* Extension method
|
|
810
|
+
*
|
|
811
|
+
* Allows the Client to send an arbitrary request that is not part of the ACP spec.
|
|
812
|
+
*
|
|
813
|
+
* To help avoid conflicts, it's a good practice to prefix extension
|
|
814
|
+
* methods with a unique identifier such as domain name.
|
|
815
|
+
*/
|
|
816
|
+
extMethod?(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
817
|
+
/**
|
|
818
|
+
* Extension notification
|
|
819
|
+
*
|
|
820
|
+
* Allows the Client to send an arbitrary notification that is not part of the ACP spec.
|
|
821
|
+
*/
|
|
822
|
+
extNotification?(method: string, params: Record<string, unknown>): Promise<void>;
|
|
823
|
+
}
|