@agentclientprotocol/claude-agent-acp 0.89.2-preview.1 → 0.89.2-preview.10

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.
@@ -188,7 +188,10 @@ export declare class AsyncTaskRuntime {
188
188
  export declare function backgroundBashTaskFromToolResult(content: unknown, toolUseResult: unknown, toolUses: Record<string, {
189
189
  name: string;
190
190
  input: unknown;
191
- }>): AsyncTaskStarted | undefined;
191
+ }>): (AsyncTaskStarted & {
192
+ taskId: string;
193
+ toolCallId: string;
194
+ }) | undefined;
192
195
  /**
193
196
  * The Bash tool calls in `content` whose command went to the background. Only
194
197
  * structured data counts: the task from the structured tool result, a task
@@ -1 +1 @@
1
- {"version":3,"file":"async-tasks.d.ts","sourceRoot":"","sources":["../src/async-tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIjF,KAAK,OAAO,GAAG,CAAC,YAAY,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACvE,qEAAqE;AACrE,KAAK,KAAK,GAAG,CAAC,YAAY,EAAE,sBAAsB,KAAK,sBAAsB,GAAG,IAAI,CAAC;AAoCrF,KAAK,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAI5D,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,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,4 +20,13 @@ import type { SessionNotification } from "@agentclientprotocol/sdk";
20
20
  * promise a card state it has no way to ever resolve.
21
21
  */
22
22
  export declare function backgroundedBashToolCall(notification: SessionNotification, backgroundedToolCallIds: ReadonlySet<string>, asyncTasksSupported: boolean): SessionNotification;
23
+ /**
24
+ * Keeps the display terminal of a command that went to the background running:
25
+ * drops `terminal_exit` from the tool result update of `toolCallId`.
26
+ *
27
+ * The Bash call returns as soon as the command detaches, so that exit would
28
+ * mark the terminal as ended while the command still runs. The consumer sends
29
+ * the exit when the command's task ends (see `Session.backgroundTerminals`).
30
+ */
31
+ export declare function withRunningTerminal(notification: SessionNotification, toolCallId: string | undefined): SessionNotification;
23
32
  //# sourceMappingURL=background.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../src/tool-calls/background.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,mBAAmB,EACjC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5C,mBAAmB,EAAE,OAAO,GAC3B,mBAAmB,CAgBrB"}
1
+ {"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../src/tool-calls/background.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,mBAAmB,EACjC,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5C,mBAAmB,EAAE,OAAO,GAC3B,mBAAmB,CAgBrB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,mBAAmB,EACjC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,mBAAmB,CAiBrB"}
@@ -34,3 +34,28 @@ export function backgroundedBashToolCall(notification, backgroundedToolCallIds,
34
34
  },
35
35
  };
36
36
  }
37
+ /**
38
+ * Keeps the display terminal of a command that went to the background running:
39
+ * drops `terminal_exit` from the tool result update of `toolCallId`.
40
+ *
41
+ * The Bash call returns as soon as the command detaches, so that exit would
42
+ * mark the terminal as ended while the command still runs. The consumer sends
43
+ * the exit when the command's task ends (see `Session.backgroundTerminals`).
44
+ */
45
+ export function withRunningTerminal(notification, toolCallId) {
46
+ const update = notification.update;
47
+ if (toolCallId === undefined ||
48
+ update.sessionUpdate !== "tool_call_update" ||
49
+ update.toolCallId !== toolCallId ||
50
+ !update._meta ||
51
+ !("terminal_exit" in update._meta)) {
52
+ return notification;
53
+ }
54
+ const meta = { ...update._meta };
55
+ delete meta.terminal_exit;
56
+ const next = { ...update, _meta: meta };
57
+ // An empty `_meta` would clear what a v2 client stores for the tool call.
58
+ if (Object.keys(meta).length === 0)
59
+ delete next._meta;
60
+ return { ...notification, update: next };
61
+ }
@@ -85,12 +85,15 @@ export declare class AcpToolCallRenderer {
85
85
  replay?: boolean);
86
86
  static for(capabilities: AcpClientCapabilities | null | undefined, replay?: boolean): AcpToolCallRenderer;
87
87
  /**
88
- * The status of a tool result. `nonExecution` is why Claude Code stamped an
89
- * error result instead of the tool's output. A run that was aborted is
90
- * `cancelled` for a v2 client, which has that status; every other client
91
- * gets `failed`, with the kind in `_meta.claudeCode.nonExecutionKind`.
88
+ * The status of a tool result. Claude Code reports a run that it aborted in
89
+ * one of two ways: an error result whose `nonExecution` kind says so (a
90
+ * cancelled turn), or a command result that says `interrupted` (for example,
91
+ * a steering message landed just before the command started). Such a run is
92
+ * `cancelled` for a v2 client, which has that status. Every other client gets
93
+ * `failed` for the error, with the kind in `_meta.claudeCode.nonExecutionKind`,
94
+ * and `completed` for the command.
92
95
  */
93
- resultStatus(isError: boolean, nonExecution: ToolResultMeta | undefined): ToolCallStatus;
96
+ resultStatus(isError: boolean, nonExecution: ToolResultMeta | undefined, interrupted?: boolean): ToolCallStatus;
94
97
  /** The facts of a tool use. */
95
98
  facts(toolUse: Pick<ToolUse, "name" | "input">, cwd?: string): ToolUseFacts;
96
99
  /** The standard fields of a tool use: the title, the kind, the content, and the locations. */
@@ -146,6 +149,7 @@ export declare class AcpToolCallRenderer {
146
149
  resultFacts(toolUse: ToolUse, result: ResultBlock, structured?: unknown): ToolResultFacts;
147
150
  /** The result fields of a tool result, before the status and the tool name. */
148
151
  resultFields(toolUse: ToolUse, result: ResultBlock, structured?: unknown): RenderedResult;
152
+ private fieldsOfResult;
149
153
  /**
150
154
  * The reports of a tool result. A command sends its output as a separate
151
155
  * report first, like codex-acp: the output, then the exit and the status.
@@ -193,6 +197,18 @@ export declare class AcpToolCallRenderer {
193
197
  decisionReason?: string;
194
198
  message?: string;
195
199
  }): ToolCallUpdate;
200
+ /**
201
+ * The report that closes a tool call when the turn ends without its result.
202
+ * If Claude dropped it before it ran (`ran` is false: its tool_use never
203
+ * reached a complete assistant message, for example because Claude switched
204
+ * to a steering message), a v2 client gets `cancelled` and every other
205
+ * client `failed`, since v1 has no `cancelled`. If Claude Code ran it but
206
+ * returned no result, it failed.
207
+ */
208
+ unfinished(call: {
209
+ toolCallId: string;
210
+ ran: boolean;
211
+ }): ToolCallUpdate;
196
212
  /**
197
213
  * The report of a tool progress beat. The field tracker sends the
198
214
  * `in_progress` status once, so a later beat carries only the progress.
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/tool-calls/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,IAAI,qBAAqB,EAC3C,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,E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,GAAG,CAAC,EAAE,MAAM,GAAG,cAAc;CA0BtF"}
@@ -41,15 +41,19 @@ export class AcpToolCallRenderer {
41
41
  return new AcpToolCallRenderer(ClientCapabilities.from(capabilities), replay);
42
42
  }
43
43
  /**
44
- * The status of a tool result. `nonExecution` is why Claude Code stamped an
45
- * error result instead of the tool's output. A run that was aborted is
46
- * `cancelled` for a v2 client, which has that status; every other client
47
- * gets `failed`, with the kind in `_meta.claudeCode.nonExecutionKind`.
44
+ * The status of a tool result. Claude Code reports a run that it aborted in
45
+ * one of two ways: an error result whose `nonExecution` kind says so (a
46
+ * cancelled turn), or a command result that says `interrupted` (for example,
47
+ * a steering message landed just before the command started). Such a run is
48
+ * `cancelled` for a v2 client, which has that status. Every other client gets
49
+ * `failed` for the error, with the kind in `_meta.claudeCode.nonExecutionKind`,
50
+ * and `completed` for the command.
48
51
  */
49
- resultStatus(isError, nonExecution) {
50
- if (!isError)
51
- return "completed";
52
- return this.capabilities.v2 && isAbortedToolResult(nonExecution) ? V2_CANCELLED : "failed";
52
+ resultStatus(isError, nonExecution, interrupted = false) {
53
+ const aborted = interrupted || (isError && isAbortedToolResult(nonExecution));
54
+ if (this.capabilities.v2 && aborted)
55
+ return V2_CANCELLED;
56
+ return isError ? "failed" : "completed";
53
57
  }
54
58
  /** The facts of a tool use. */
55
59
  facts(toolUse, cwd) {
@@ -191,7 +195,9 @@ export class AcpToolCallRenderer {
191
195
  }
192
196
  /** The result fields of a tool result, before the status and the tool name. */
193
197
  resultFields(toolUse, result, structured) {
194
- const facts = this.resultFacts(toolUse, result, structured);
198
+ return this.fieldsOfResult(toolUse, result, this.resultFacts(toolUse, result, structured));
199
+ }
200
+ fieldsOfResult(toolUse, result, facts) {
195
201
  const { command, ...fields } = facts;
196
202
  if (!command)
197
203
  return fields;
@@ -252,7 +258,8 @@ export class AcpToolCallRenderer {
252
258
  * when no other field carries the result.
253
259
  */
254
260
  result(toolUse, result, options = {}) {
255
- const { _meta: resultMeta, ...fields } = this.resultFields(toolUse, result, options.structured);
261
+ const facts = this.resultFacts(toolUse, result, options.structured);
262
+ const { _meta: resultMeta, ...fields } = this.fieldsOfResult(toolUse, result, facts);
256
263
  // AIR shows a read or a search that names a path as the list of viewed
257
264
  // files. That view does not show the text of the result, so it stays out.
258
265
  const viewedFiles = this.capabilities.air.client && result.is_error !== true && this.namesViewedFile(toolUse);
@@ -299,7 +306,7 @@ export class AcpToolCallRenderer {
299
306
  },
300
307
  toolCallId: toolUse.id,
301
308
  sessionUpdate: "tool_call_update",
302
- status: this.resultStatus(result.is_error === true, options.nonExecution),
309
+ status: this.resultStatus(result.is_error === true, options.nonExecution, facts.command?.interrupted === true),
303
310
  ...(rawOutput !== undefined ? { rawOutput } : {}),
304
311
  ...(planFilePath ? { rawInput: planFileInput(toolUse.input, planFilePath) } : {}),
305
312
  ...fields,
@@ -425,6 +432,26 @@ export class AcpToolCallRenderer {
425
432
  },
426
433
  };
427
434
  }
435
+ /**
436
+ * The report that closes a tool call when the turn ends without its result.
437
+ * If Claude dropped it before it ran (`ran` is false: its tool_use never
438
+ * reached a complete assistant message, for example because Claude switched
439
+ * to a steering message), a v2 client gets `cancelled` and every other
440
+ * client `failed`, since v1 has no `cancelled`. If Claude Code ran it but
441
+ * returned no result, it failed.
442
+ */
443
+ unfinished(call) {
444
+ return {
445
+ sessionUpdate: "tool_call_update",
446
+ toolCallId: call.toolCallId,
447
+ status: !call.ran && this.capabilities.v2 ? V2_CANCELLED : "failed",
448
+ content: [
449
+ textContent(call.ran
450
+ ? "Claude ended the turn without returning a result for this tool."
451
+ : "Claude stopped this tool call before it ran."),
452
+ ],
453
+ };
454
+ }
428
455
  /**
429
456
  * The report of a tool progress beat. The field tracker sends the
430
457
  * `in_progress` status once, so a later beat carries only the progress.
@@ -1,10 +1,11 @@
1
1
  /**
2
- * A prompt turn as the adapter understands it, independent of the ACP version.
2
+ * A prompt turn and the foreground work of a session, as the adapter
3
+ * understands them, independent of the ACP version.
3
4
  *
4
- * The agent reports each turn through {@link TurnEvents}, and each ACP version
5
- * maps the events to its own messages. ACP v1 answers `session/prompt` when the
6
- * turn ends or fails. ACP v2 answers it when the prompt is inserted, and
7
- * reports the rest as session state.
5
+ * The agent reports how each prompt is answered through {@link TurnEvents}:
6
+ * ACP v1 answers `session/prompt` when the turn ends or fails, and ACP v2 when
7
+ * the prompt is inserted. ACP v2 also reports the session's work as state,
8
+ * which the agent reports through {@link ForegroundEvents}.
8
9
  *
9
10
  * The agent calls these synchronously while it updates its own state, so a
10
11
  * handler must not throw, nor call back into the agent before it returns.
@@ -23,18 +24,6 @@ export interface TurnEvents {
23
24
  * `/compact`), it is the command's result, after any output it streamed.
24
25
  */
25
26
  inserted(messageId: string): void;
26
- /**
27
- * The turn waits for the user: a permission request or a question is open in
28
- * the session. Requests do not say which prompt they are for, so this
29
- * includes one opened before the turn was inserted. Only reported after
30
- * {@link inserted}.
31
- */
32
- awaitingUser(): void;
33
- /**
34
- * The turn works again: no request is open any more. A turn that ends or
35
- * fails while it waits reports that instead.
36
- */
37
- resumed(): void;
38
27
  /**
39
28
  * The turn ended. A queued turn that is cancelled before it is inserted
40
29
  * ends too, without {@link inserted}; Claude Code may still run its prompt.
@@ -47,6 +36,39 @@ export interface TurnEvents {
47
36
  */
48
37
  failed(error: unknown): void;
49
38
  }
39
+ /**
40
+ * The foreground work of a session: what a client would wait for before it
41
+ * sends the next prompt. One piece of work runs at a time, and the next starts
42
+ * with {@link running}. The work is either:
43
+ *
44
+ * - A prompt's turn, from {@link TurnEvents.inserted} until its result, or
45
+ * until it fails or is cancelled. A turn that v1 holds open for the
46
+ * background subagents it spawned (`Turn.deferredSettle`) ends its work at
47
+ * its result all the same: the hold only delays v1's answer.
48
+ * - A model cycle that Claude Code starts on its own while no work runs: for
49
+ * example, its follow-up after a background command or subagent finished,
50
+ * or its answer to a message from another session. It runs until its result.
51
+ *
52
+ * A prompt that Claude Code takes in while a cycle runs takes the cycle over:
53
+ * the cycle reports nothing more, and the turn reports from there.
54
+ */
55
+ export interface ForegroundEvents {
56
+ /** The work started, or works again after it waited for the user. */
57
+ running(): void;
58
+ /**
59
+ * The work waits for the user: a permission request or a question is open in
60
+ * the session. Requests do not say which work they are for, so this includes
61
+ * one opened before the work started.
62
+ */
63
+ awaitingUser(): void;
64
+ /** The work ended. */
65
+ ended(outcome: TurnOutcome): void;
66
+ /**
67
+ * The work failed with `error`, the JSON-RPC error that v1 answers the
68
+ * prompt with.
69
+ */
70
+ failed(error: unknown): void;
71
+ }
50
72
  /** Why a turn ended. Every ACP version has these reasons. */
51
73
  export type StopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
52
74
  /** How a turn ended. */
@@ -1 +1 @@
1
- {"version":3,"file":"turn-events.d.ts","sourceRoot":"","sources":["../src/turn-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;;OAKG;IACH,YAAY,IAAI,IAAI,CAAC;IACrB;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9B;AAED,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,mBAAmB,GAAG,SAAS,GAAG,WAAW,CAAC;AAEnG,wBAAwB;AACxB,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW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W,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAkB,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAmB9E;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GACvC,EAAE,CAAC,QAAQ,CAoEb"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAkB,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAmB9E;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GACvC,EAAE,CAAC,QAAQ,CA0Eb"}
package/dist/v2/agent.js CHANGED
@@ -2,7 +2,7 @@ import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
2
2
  import { ClaudeAcpAgent } from "../acp-agent.js";
3
3
  import { v1InitializeRequest, v2InitializeResponse } from "./initialize.js";
4
4
  import { v1PermissionResponse, v2PermissionRequest } from "./permission.js";
5
- import { v2Prompt } from "./prompt.js";
5
+ import { v2Foreground, v2Prompt } from "./prompt.js";
6
6
  import { v1ForkSessionRequests, v1NewSessionRequest, v1RestoreSessionRequest, v1SetSessionConfigOptionRequest, v2AvailableCommands, v2ConfigOptions, v2NewSessionResponse, v2ResumeSessionResponse, } from "./session.js";
7
7
  import { v2SessionUpdate } from "./session-update.js";
8
8
  import { V2Terminals } from "./terminal.js";
@@ -22,7 +22,12 @@ export function v2AgentApp(logger, onAgent) {
22
22
  .agent({ name: "claude-code-acp" })
23
23
  .onConnect((connection) => {
24
24
  client = new V2ClientConnection(connection.client, logger ?? console);
25
- agent = new ClaudeAcpAgent(client, logger, { v2: true });
25
+ agent = new ClaudeAcpAgent(client, logger, {
26
+ v2: true,
27
+ foreground: (sessionId) => v2Foreground((update) => {
28
+ void client.send({ sessionId, update });
29
+ }),
30
+ });
26
31
  onAgent(agent);
27
32
  })
28
33
  .onRequest(v2.methods.agent.initialize, async ({ params }) => v2InitializeResponse(await agent.initialize(v1InitializeRequest(params))))
@@ -7,31 +7,42 @@
7
7
  import { type PromptRequest } from "@agentclientprotocol/sdk";
8
8
  import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
9
9
  import type { ClaudeAcpAgent } from "../acp-agent.js";
10
+ import type { ForegroundEvents } from "../turn-events.js";
10
11
  /**
11
12
  * Starts a turn for `params`, and answers when Claude Code takes the prompt
12
- * in. `send` delivers a session update of the prompt's session; it must not
13
- * throw, and must deliver updates in the order it is called, also relative to
14
- * the agent's own updates.
13
+ * in, with the id of the user message it became. `send` delivers a session
14
+ * update of the prompt's session; it must not throw, and must deliver updates
15
+ * in the order it is called, also relative to the agent's own updates.
15
16
  *
16
- * - Taken in: the prompt's `user_message`, then `running`, then the answer.
17
- * - Waiting on a permission request or a question: `requires_action`, and
18
- * `running` once none is open.
19
- * - Ended: `idle` with the stop reason, usage, and `_meta` of the turn.
20
- * - Failed after it was taken in: `idle` with the `error` stop reason and the
21
- * JSON-RPC error that v1 answers the prompt with, so a client can show its
22
- * message and handle its code as for an error response (for example,
23
- * `-32000` starts the client's sign-in).
17
+ * - Taken in: the prompt's `user_message`, then the answer. From then on, the
18
+ * turn is the session's foreground work, which reports its states (see
19
+ * {@link v2Foreground}).
24
20
  * - Ended or failed before it was taken in: the answer is a JSON-RPC error,
25
21
  * `-32800` for a prompt that a cancel ended in the queue.
26
- *
27
- * Deferred decision: a turn whose background subagents still run ends only
28
- * when they finish (`Turn.deferredSettle`), so `idle` waits for them too. The
29
- * hold exists for v1, whose clients stop listening at the prompt response.
30
- * v2 allows background updates while idle, so it could report `idle` at the
31
- * turn's result instead, with a turn event for the hold. To be decided with
32
- * async tasks (step 6 in `docs/acp-v2.md`).
33
22
  */
34
23
  export declare function v2Prompt(agent: ClaudeAcpAgent, params: v2.PromptRequest, send: (update: v2.SessionUpdate) => void): Promise<v2.PromptResponse>;
24
+ /**
25
+ * Reports the foreground work of a session (see {@link ForegroundEvents}) as
26
+ * its `state_update`s. `send` delivers a session update of that session, as
27
+ * for {@link v2Prompt}.
28
+ *
29
+ * - Started: `running`. For a prompt's turn, right after its `user_message`.
30
+ * - Waiting on a permission request or a question: `requires_action`, and
31
+ * `running` once none is open.
32
+ * - Ended: `idle` with the stop reason, usage, and `_meta` of the work.
33
+ * - Failed: `idle` with the `error` stop reason and the JSON-RPC error that v1
34
+ * answers the prompt with, so a client can show its message and handle its
35
+ * code as for an error response (for example, `-32000` starts the client's
36
+ * sign-in).
37
+ *
38
+ * The work is a prompt's turn or a model cycle that Claude Code started on its
39
+ * own, such as its follow-up after a background subagent finished. A turn's
40
+ * work ends at its result, also when v1 holds the turn's answer for the
41
+ * background subagents it spawned (`Turn.deferredSettle`): v2 allows
42
+ * background updates while idle, so the subagents' output and requests arrive
43
+ * after `idle`, and their follow-up is a cycle of its own.
44
+ */
45
+ export declare function v2Foreground(send: (update: v2.SessionUpdate) => void): ForegroundEvents;
35
46
  /**
36
47
  * A v2 prompt may hold content blocks that v1 cannot express: a custom one,
37
48
  * or one from a newer ACP version. Clients send only the kinds the agent
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/v2/prompt.ts"],"names":[],"mappings":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AACH,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,aAAa,GAAG,aAAa,CAEvF"}
package/dist/v2/prompt.js CHANGED
@@ -8,27 +8,15 @@ import { RequestError, } from "@agentclientprotocol/sdk";
8
8
  import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
9
9
  /**
10
10
  * Starts a turn for `params`, and answers when Claude Code takes the prompt
11
- * in. `send` delivers a session update of the prompt's session; it must not
12
- * throw, and must deliver updates in the order it is called, also relative to
13
- * the agent's own updates.
11
+ * in, with the id of the user message it became. `send` delivers a session
12
+ * update of the prompt's session; it must not throw, and must deliver updates
13
+ * in the order it is called, also relative to the agent's own updates.
14
14
  *
15
- * - Taken in: the prompt's `user_message`, then `running`, then the answer.
16
- * - Waiting on a permission request or a question: `requires_action`, and
17
- * `running` once none is open.
18
- * - Ended: `idle` with the stop reason, usage, and `_meta` of the turn.
19
- * - Failed after it was taken in: `idle` with the `error` stop reason and the
20
- * JSON-RPC error that v1 answers the prompt with, so a client can show its
21
- * message and handle its code as for an error response (for example,
22
- * `-32000` starts the client's sign-in).
15
+ * - Taken in: the prompt's `user_message`, then the answer. From then on, the
16
+ * turn is the session's foreground work, which reports its states (see
17
+ * {@link v2Foreground}).
23
18
  * - Ended or failed before it was taken in: the answer is a JSON-RPC error,
24
19
  * `-32800` for a prompt that a cancel ended in the queue.
25
- *
26
- * Deferred decision: a turn whose background subagents still run ends only
27
- * when they finish (`Turn.deferredSettle`), so `idle` waits for them too. The
28
- * hold exists for v1, whose clients stop listening at the prompt response.
29
- * v2 allows background updates while idle, so it could report `idle` at the
30
- * turn's result instead, with a turn event for the hold. To be decided with
31
- * async tasks (step 6 in `docs/acp-v2.md`).
32
20
  */
33
21
  export function v2Prompt(agent, params, send) {
34
22
  return new Promise((resolve, reject) => {
@@ -37,37 +25,18 @@ export function v2Prompt(agent, params, send) {
37
25
  inserted(messageId) {
38
26
  inserted = true;
39
27
  send({ sessionUpdate: "user_message", messageId, content: params.prompt });
40
- send({ sessionUpdate: "state_update", state: "running" });
41
28
  resolve({ messageId });
42
29
  },
43
- awaitingUser() {
44
- send({ sessionUpdate: "state_update", state: "requires_action" });
45
- },
46
- resumed() {
47
- send({ sessionUpdate: "state_update", state: "running" });
48
- },
49
30
  ended(outcome) {
50
- if (inserted) {
51
- send(idle(outcome));
52
- }
53
- else if (outcome.stopReason === "cancelled") {
54
- reject(RequestError.requestCancelled());
55
- }
56
- else {
57
- reject(RequestError.internalError({ stopReason: outcome.stopReason }, "The turn ended before Claude Code took the prompt in"));
58
- }
31
+ if (inserted)
32
+ return;
33
+ reject(outcome.stopReason === "cancelled"
34
+ ? RequestError.requestCancelled()
35
+ : RequestError.internalError({ stopReason: outcome.stopReason }, "The turn ended before Claude Code took the prompt in"));
59
36
  },
60
37
  failed(error) {
61
- if (!inserted) {
38
+ if (!inserted)
62
39
  reject(error);
63
- return;
64
- }
65
- send({
66
- sessionUpdate: "state_update",
67
- state: "idle",
68
- stopReason: "error",
69
- error: jsonRpcError(error),
70
- });
71
40
  },
72
41
  };
73
42
  let request;
@@ -81,6 +50,48 @@ export function v2Prompt(agent, params, send) {
81
50
  agent.startTurn(request, events).catch(reject);
82
51
  });
83
52
  }
53
+ /**
54
+ * Reports the foreground work of a session (see {@link ForegroundEvents}) as
55
+ * its `state_update`s. `send` delivers a session update of that session, as
56
+ * for {@link v2Prompt}.
57
+ *
58
+ * - Started: `running`. For a prompt's turn, right after its `user_message`.
59
+ * - Waiting on a permission request or a question: `requires_action`, and
60
+ * `running` once none is open.
61
+ * - Ended: `idle` with the stop reason, usage, and `_meta` of the work.
62
+ * - Failed: `idle` with the `error` stop reason and the JSON-RPC error that v1
63
+ * answers the prompt with, so a client can show its message and handle its
64
+ * code as for an error response (for example, `-32000` starts the client's
65
+ * sign-in).
66
+ *
67
+ * The work is a prompt's turn or a model cycle that Claude Code started on its
68
+ * own, such as its follow-up after a background subagent finished. A turn's
69
+ * work ends at its result, also when v1 holds the turn's answer for the
70
+ * background subagents it spawned (`Turn.deferredSettle`): v2 allows
71
+ * background updates while idle, so the subagents' output and requests arrive
72
+ * after `idle`, and their follow-up is a cycle of its own.
73
+ */
74
+ export function v2Foreground(send) {
75
+ return {
76
+ running() {
77
+ send({ sessionUpdate: "state_update", state: "running" });
78
+ },
79
+ awaitingUser() {
80
+ send({ sessionUpdate: "state_update", state: "requires_action" });
81
+ },
82
+ ended(outcome) {
83
+ send(idle(outcome));
84
+ },
85
+ failed(error) {
86
+ send({
87
+ sessionUpdate: "state_update",
88
+ state: "idle",
89
+ stopReason: "error",
90
+ error: jsonRpcError(error),
91
+ });
92
+ },
93
+ };
94
+ }
84
95
  /** The JSON-RPC error that v1 answers a failed prompt with. */
85
96
  function jsonRpcError(error) {
86
97
  if (error instanceof RequestError) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.89.2-preview.1",
6
+ "version": "0.89.2-preview.10",
7
7
  "description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",