@agentclientprotocol/claude-agent-acp 0.107.4-preview.1 → 0.107.4-preview.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.
@@ -51,4 +51,94 @@ export declare class BackgroundOutputTail {
51
51
  private read;
52
52
  private send;
53
53
  }
54
+ /** What Claude Code's `get_task_output` returns: the end of a shell task's output. */
55
+ export interface TaskOutput {
56
+ /** At most the last 8 KiB of the output, decoded as UTF-8. */
57
+ output: string;
58
+ /** The size of the whole output in bytes. */
59
+ total_bytes: number;
60
+ /** Whether `output` holds only the end of the output. */
61
+ truncated: boolean;
62
+ }
63
+ /**
64
+ * Follows the output of a command that runs in the foreground, read with
65
+ * `read` (Claude Code's `get_task_output`), and hands each piece of new text
66
+ * to `publish`, in order. Claude Code streams no output of a foreground Bash
67
+ * command either: the output arrives in the tool result. Claude Code writes
68
+ * the output to the command's task before then, and `get_task_output` reads
69
+ * it, though the task's `task_started` names no output file.
70
+ *
71
+ * The new text is the output past the bytes already sent. When `output` does
72
+ * not hold all of it, or its bytes may not match the command's (not UTF-8),
73
+ * the whole `output` replaces the terminal's output, as a snapshot. A read
74
+ * that ends in U+FFFD may have cut a character that the command is still
75
+ * writing, so it is sent only at the next read.
76
+ *
77
+ * Once the command ends, Claude Code drops its output: the task then reads as
78
+ * empty (`total_bytes: 0`, CLI 2.1.325), up to the tool result that carries
79
+ * the whole output. A read that holds less than was sent is that end, so it
80
+ * stops the poll and publishes nothing: an empty snapshot would clear the
81
+ * terminal.
82
+ *
83
+ * One read runs at a time: a poll that comes during a read is skipped, so a
84
+ * read that Claude Code never answers queues nothing behind it. A read that
85
+ * fails is tried again at the next poll. `publish` must not reject.
86
+ */
87
+ export declare class TaskOutputPoll {
88
+ private readonly read;
89
+ private readonly publish;
90
+ private sentBytes;
91
+ private sent;
92
+ private stopped;
93
+ /** A read is in progress, or the publish of its text. */
94
+ private busy;
95
+ /** The publish in progress, or the last one. */
96
+ private publishing;
97
+ private readonly timer;
98
+ constructor(read: () => Promise<TaskOutput>, publish: (output: BackgroundOutput) => Promise<void>);
99
+ /**
100
+ * Stops, once a publish in progress is out. Returns whether any text was
101
+ * published: the tool result then replaces it with the whole output.
102
+ *
103
+ * A read in progress is not waited for. It publishes nothing after this,
104
+ * and Claude Code may never answer it.
105
+ */
106
+ finish(): Promise<boolean>;
107
+ /**
108
+ * Stops now and returns whether any text was published, for a caller whose
109
+ * `publish` sends in the same synchronous step (v2), so none is in progress.
110
+ */
111
+ end(): boolean;
112
+ /** Stops without waiting: the command's task, the query or the session ended. */
113
+ stop(): void;
114
+ private poll;
115
+ /**
116
+ * The text that `read` adds to what was sent, or undefined when it adds none
117
+ * yet. `read` holds at least the bytes that were sent.
118
+ */
119
+ private newText;
120
+ }
121
+ /**
122
+ * The id of the tool call whose command the task `started` runs in the
123
+ * foreground, or undefined for any other task. Claude Code starts the task of
124
+ * a foreground command once the command has run for a few seconds (3.1 s with
125
+ * CLI 2.1.325). A faster command gets no task, and its output comes with its
126
+ * tool result, as before.
127
+ */
128
+ export declare function foregroundCommandToolCall(started: {
129
+ task_type?: string;
130
+ is_backgrounded?: boolean;
131
+ tool_use_id?: string;
132
+ }): string | undefined;
133
+ /** Whether a call of the tool `name` runs a command that a terminal shows. */
134
+ export declare function isCommandTool(name: string | undefined): boolean;
135
+ /**
136
+ * Claude Code's `get_task_output` on the SDK's query. Like `mcpAuthenticate`,
137
+ * it is on the query object but not in the public `Query` declaration yet,
138
+ * though the SDK types its control request (`SDKControlGetTaskOutputRequest`).
139
+ */
140
+ export type TaskOutputQuery = {
141
+ getTaskOutput(taskId: string): Promise<TaskOutput>;
142
+ };
143
+ export declare function supportsTaskOutput<T extends object>(query: T): query is T & TaskOutputQuery;
54
144
  //# sourceMappingURL=background-output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"background-output.d.ts","sourceRoot":"","sources":["../src/background-output.ts"],"names":[],"mappings":"AAcA,yDAAyD;AACzD,eAAO,MAAM,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;;OAMG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAMhC;;;OAGG;IACH,GAAG,IAAI,OAAO;IAKd,iFAAiF;IACjF,IAAI,IAAI,IAAI;YAKE,IAAI;IAuBlB;;;OAGG;IACH,OAAO,CAAC,OAAO;CAchB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,GAAG,SAAS,CAIrB;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE/D;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAAE,CAAC;AAErF,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,eAAe,CAE3F"}
@@ -120,3 +120,141 @@ export class BackgroundOutputTail {
120
120
  await this.publish({ text, replaces });
121
121
  }
122
122
  }
123
+ /**
124
+ * The most bytes at the start of a truncated `output` that may not match the
125
+ * command's bytes: a character that the 8 KiB cut split decodes as U+FFFD.
126
+ */
127
+ const CUT_CHARACTER_BYTES = 4;
128
+ /**
129
+ * Follows the output of a command that runs in the foreground, read with
130
+ * `read` (Claude Code's `get_task_output`), and hands each piece of new text
131
+ * to `publish`, in order. Claude Code streams no output of a foreground Bash
132
+ * command either: the output arrives in the tool result. Claude Code writes
133
+ * the output to the command's task before then, and `get_task_output` reads
134
+ * it, though the task's `task_started` names no output file.
135
+ *
136
+ * The new text is the output past the bytes already sent. When `output` does
137
+ * not hold all of it, or its bytes may not match the command's (not UTF-8),
138
+ * the whole `output` replaces the terminal's output, as a snapshot. A read
139
+ * that ends in U+FFFD may have cut a character that the command is still
140
+ * writing, so it is sent only at the next read.
141
+ *
142
+ * Once the command ends, Claude Code drops its output: the task then reads as
143
+ * empty (`total_bytes: 0`, CLI 2.1.325), up to the tool result that carries
144
+ * the whole output. A read that holds less than was sent is that end, so it
145
+ * stops the poll and publishes nothing: an empty snapshot would clear the
146
+ * terminal.
147
+ *
148
+ * One read runs at a time: a poll that comes during a read is skipped, so a
149
+ * read that Claude Code never answers queues nothing behind it. A read that
150
+ * fails is tried again at the next poll. `publish` must not reject.
151
+ */
152
+ export class TaskOutputPoll {
153
+ read;
154
+ publish;
155
+ sentBytes = 0;
156
+ sent = false;
157
+ stopped = false;
158
+ /** A read is in progress, or the publish of its text. */
159
+ busy = false;
160
+ /** The publish in progress, or the last one. */
161
+ publishing = Promise.resolve();
162
+ timer;
163
+ constructor(read, publish) {
164
+ this.read = read;
165
+ this.publish = publish;
166
+ this.timer = setInterval(() => void this.poll(), BACKGROUND_OUTPUT_POLL_MS);
167
+ // A command that runs on must not keep the agent process alive.
168
+ this.timer.unref();
169
+ }
170
+ /**
171
+ * Stops, once a publish in progress is out. Returns whether any text was
172
+ * published: the tool result then replaces it with the whole output.
173
+ *
174
+ * A read in progress is not waited for. It publishes nothing after this,
175
+ * and Claude Code may never answer it.
176
+ */
177
+ async finish() {
178
+ this.stop();
179
+ await this.publishing;
180
+ return this.sent;
181
+ }
182
+ /**
183
+ * Stops now and returns whether any text was published, for a caller whose
184
+ * `publish` sends in the same synchronous step (v2), so none is in progress.
185
+ */
186
+ end() {
187
+ this.stop();
188
+ return this.sent;
189
+ }
190
+ /** Stops without waiting: the command's task, the query or the session ended. */
191
+ stop() {
192
+ clearInterval(this.timer);
193
+ this.stopped = true;
194
+ }
195
+ async poll() {
196
+ if (this.stopped || this.busy)
197
+ return;
198
+ this.busy = true;
199
+ try {
200
+ const read = await this.read();
201
+ if (this.stopped)
202
+ return;
203
+ if (read.total_bytes < this.sentBytes) {
204
+ this.stop();
205
+ return;
206
+ }
207
+ const output = this.newText(read);
208
+ if (output === undefined)
209
+ return;
210
+ this.sentBytes = read.total_bytes;
211
+ this.sent = true;
212
+ this.publishing = this.publish(output);
213
+ await this.publishing;
214
+ }
215
+ catch {
216
+ // The read failed: try again at the next poll.
217
+ }
218
+ finally {
219
+ this.busy = false;
220
+ }
221
+ }
222
+ /**
223
+ * The text that `read` adds to what was sent, or undefined when it adds none
224
+ * yet. `read` holds at least the bytes that were sent.
225
+ */
226
+ newText({ output, total_bytes, truncated }) {
227
+ if (total_bytes === this.sentBytes || output.endsWith("\uFFFD"))
228
+ return undefined;
229
+ const bytes = Buffer.from(output, "utf8");
230
+ const added = total_bytes - this.sentBytes;
231
+ const exact = truncated
232
+ ? added <= bytes.length - CUT_CHARACTER_BYTES
233
+ : bytes.length === total_bytes;
234
+ // `sentBytes` ends a read that ended in a whole character, so the cut is
235
+ // at a character boundary.
236
+ if (exact) {
237
+ return { text: bytes.subarray(bytes.length - added).toString("utf8"), replaces: false };
238
+ }
239
+ return { text: output, replaces: true };
240
+ }
241
+ }
242
+ /**
243
+ * The id of the tool call whose command the task `started` runs in the
244
+ * foreground, or undefined for any other task. Claude Code starts the task of
245
+ * a foreground command once the command has run for a few seconds (3.1 s with
246
+ * CLI 2.1.325). A faster command gets no task, and its output comes with its
247
+ * tool result, as before.
248
+ */
249
+ export function foregroundCommandToolCall(started) {
250
+ return started.task_type === "local_bash" && started.is_backgrounded === false
251
+ ? started.tool_use_id
252
+ : undefined;
253
+ }
254
+ /** Whether a call of the tool `name` runs a command that a terminal shows. */
255
+ export function isCommandTool(name) {
256
+ return name === "Bash" || name === "PowerShell";
257
+ }
258
+ export function supportsTaskOutput(query) {
259
+ return typeof query.getTaskOutput === "function";
260
+ }
@@ -29,6 +29,38 @@ export declare function backgroundedBashToolCall(notification: SessionNotificati
29
29
  * the exit when the command's task ends (see `Session.backgroundTerminals`).
30
30
  */
31
31
  export declare function withRunningTerminal(notification: SessionNotification, toolCallId: string | undefined): SessionNotification;
32
+ /**
33
+ * How the tool result of each command whose terminal got output as the command
34
+ * ran reaches that terminal, by tool call id (see `withStreamedTerminal`).
35
+ */
36
+ export type StreamedTerminals = ReadonlyMap<string, "replace" | "append">;
37
+ /**
38
+ * How the tool results of the commands `shown`, whose terminals got output as
39
+ * they ran, reach those terminals. A result that carries the command's whole
40
+ * output replaces what the terminal showed. Two results carry a text of Claude
41
+ * Code instead, so that text is appended to what the terminal showed:
42
+ * - the result of `backgrounded`, the command that went to the background:
43
+ * "Command running in background";
44
+ * - a result that `toolResultMeta` (the `tool_result_meta` of the result's
45
+ * message) stamps as not executed. CLI 2.1.325 stamps the command that a
46
+ * `session/cancel` stopped `user-rejected`, and its result is the notice
47
+ * "The user doesn't want to proceed with this tool use".
48
+ */
49
+ export declare function streamedTerminals(shown: readonly string[], backgrounded: string | undefined, toolResultMeta: unknown): StreamedTerminals;
50
+ /**
51
+ * Makes the output of the tool result update of a command in `streamed` reach
52
+ * its terminal as `streamed` says. The terminal showed the command's output as
53
+ * it ran (see `SessionBackgroundWork.followForeground`):
54
+ * - `replace`: the output goes as `terminal_output`. The result carries the
55
+ * whole output again, also the end that the last read missed.
56
+ * - `append`: the output goes as `terminal_output_delta`, after what the
57
+ * terminal showed.
58
+ *
59
+ * Without this, the client's kind decides: the result of a client that appends
60
+ * chunks would repeat the output, and the result of any other client, such as
61
+ * a v2 client, would replace it also with a notice.
62
+ */
63
+ export declare function withStreamedTerminal(notification: SessionNotification, streamed: StreamedTerminals): SessionNotification;
32
64
  /**
33
65
  * Keeps the tool call of a task that went on in the background running: the
34
66
  * tool result update of a tool call in `toolCallIds` reports `in_progress`
@@ -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,mCAAmC,CAAC;AAG7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,C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ACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,mBAAmB,EACjC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GAC/B,mBAAmB,CAUrB"}
@@ -1,4 +1,5 @@
1
1
  import { AIR_ASYNC_TASKS_CAPABILITY, withAirMeta } from "../air-extension.js";
2
+ import { parseToolResultMeta } from "../tool-result-meta.js";
2
3
  /**
3
4
  * Marks the Bash `tool_call_update` whose command detached into the background.
4
5
  *
@@ -59,6 +60,58 @@ export function withRunningTerminal(notification, toolCallId) {
59
60
  delete next._meta;
60
61
  return { ...notification, update: next };
61
62
  }
63
+ /**
64
+ * How the tool results of the commands `shown`, whose terminals got output as
65
+ * they ran, reach those terminals. A result that carries the command's whole
66
+ * output replaces what the terminal showed. Two results carry a text of Claude
67
+ * Code instead, so that text is appended to what the terminal showed:
68
+ * - the result of `backgrounded`, the command that went to the background:
69
+ * "Command running in background";
70
+ * - a result that `toolResultMeta` (the `tool_result_meta` of the result's
71
+ * message) stamps as not executed. CLI 2.1.325 stamps the command that a
72
+ * `session/cancel` stopped `user-rejected`, and its result is the notice
73
+ * "The user doesn't want to proceed with this tool use".
74
+ */
75
+ export function streamedTerminals(shown, backgrounded, toolResultMeta) {
76
+ const notExecuted = parseToolResultMeta(toolResultMeta);
77
+ return new Map(shown.map((toolCallId) => [
78
+ toolCallId,
79
+ toolCallId === backgrounded || notExecuted?.has(toolCallId) ? "append" : "replace",
80
+ ]));
81
+ }
82
+ /**
83
+ * Makes the output of the tool result update of a command in `streamed` reach
84
+ * its terminal as `streamed` says. The terminal showed the command's output as
85
+ * it ran (see `SessionBackgroundWork.followForeground`):
86
+ * - `replace`: the output goes as `terminal_output`. The result carries the
87
+ * whole output again, also the end that the last read missed.
88
+ * - `append`: the output goes as `terminal_output_delta`, after what the
89
+ * terminal showed.
90
+ *
91
+ * Without this, the client's kind decides: the result of a client that appends
92
+ * chunks would repeat the output, and the result of any other client, such as
93
+ * a v2 client, would replace it also with a notice.
94
+ */
95
+ export function withStreamedTerminal(notification, streamed) {
96
+ const update = notification.update;
97
+ const how = update.sessionUpdate === "tool_call_update" && streamed.get(update.toolCallId);
98
+ if (update.sessionUpdate !== "tool_call_update" || !how || !update._meta)
99
+ return notification;
100
+ const { terminal_output_delta: delta, terminal_output: whole, ...meta } = update._meta;
101
+ const output = delta ?? whole;
102
+ if (output === undefined)
103
+ return notification;
104
+ return {
105
+ ...notification,
106
+ update: {
107
+ ...update,
108
+ _meta: {
109
+ ...meta,
110
+ ...(how === "replace" ? { terminal_output: output } : { terminal_output_delta: output }),
111
+ },
112
+ },
113
+ };
114
+ }
62
115
  /**
63
116
  * Keeps the tool call of a task that went on in the background running: the
64
117
  * tool result update of a tool call in `toolCallIds` reports `in_progress`
@@ -6,6 +6,15 @@ import { BetaBashCodeExecutionResultBlock, BetaBashCodeExecutionToolResultBlockP
6
6
  * These are transformed to valid ACP ContentBlock types by toValidAcpContent().
7
7
  */
8
8
  export type ToolResultContent = TextBlockParam | DocumentBlockParam | ImageBlockParam | BetaImageBlockParam | BetaToolReferenceBlock | BetaToolSearchToolSearchResultBlock | BetaToolSearchToolResultError | WebSearchResultBlock | WebSearchToolResultError | BetaWebFetchBlock | BetaWebFetchToolResultErrorBlock | BetaCodeExecutionResultBlock | BetaCodeExecutionToolResultError | BetaBashCodeExecutionResultBlock | BetaBashCodeExecutionToolResultError | BetaTextEditorCodeExecutionViewResultBlock | BetaTextEditorCodeExecutionCreateResultBlock | BetaTextEditorCodeExecutionStrReplaceResultBlock | BetaTextEditorCodeExecutionToolResultError;
9
+ /**
10
+ * The field `key` of a tool's input when it holds a non-empty string.
11
+ *
12
+ * The input is what the model wrote. Claude Code validates it when it runs the
13
+ * tool, after the adapter reported the tool use, so a field can hold any type:
14
+ * `Read {"file_path": 12345}`. A reporter must not pass such a value on as a
15
+ * path or a title.
16
+ */
17
+ export declare function inputString(input: unknown, key: string): string | undefined;
9
18
  /**
10
19
  * Convert an absolute file path to a project-relative path for display.
11
20
  * Returns the original path if it's outside the project directory or if no cwd is provided.
@@ -1 +1 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/tool-calls/content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gCAAgC,EAChC,yCAAyC,EACzC,oCAAoC,EACpC,4BAA4B,EAC5B,qCAAqC,EACrC,gCAAgC,EAChC,mBAAmB,EACnB,kCAAkC,EAClC,4CAA4C,EAC5C,gDAAgD,EAChD,+CAA+C,EAC/C,0CAA0C,EAC1C,0CAA0C,EAC1C,sBAAsB,EACtB,wBAAwB,EACxB,kCAAkC,EAClC,6BAA6B,EAC7B,mCAAmC,EACnC,iBAAiB,EACjB,gCAAgC,EAChC,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,sCAAsC,CAAC;AAG9C;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,cAAc,GACd,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,sBAAsB,GACtB,mCAAmC,GACnC,6BAA6B,GAC7B,oBAAoB,GACpB,wBAAwB,GACxB,iBAAiB,GACjB,gCAAgC,GAChC,4BAA4B,GAC5B,gCAAgC,GAChC,gCAAgC,GAChC,oCAAoC,GACpC,0CAA0C,GAC1C,4CAA4C,GAC5C,gDAAgD,GAChD,0CAA0C,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAQpE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS,CAMxF;AAED;;iCAEi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AAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE9E;AAUD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,GAAG,EACZ,OAAO,GAAE,OAAe,GACvB;IAAE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAA;CAAE,CA+BjC;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,GAAG,YAAY,CA6F5F;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED,6DAA6D;AAC7D,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,wBAAwB,GACxB,iCAAiC,GACjC,gCAAgC,GAChC,6BAA6B,GAC7B,qCAAqC,GACrC,yCAAyC,GACzC,+CAA+C,GAC/C,kCAAkC,GAClC,kCAAkC,CAAC;AAEvC,8BAA8B;AAC9B,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAEzD;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,GAAG;IACpF,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B,CAEA;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,OAAO,GACpB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAUpD"}
@@ -1,4 +1,18 @@
1
1
  import path from "node:path";
2
+ /**
3
+ * The field `key` of a tool's input when it holds a non-empty string.
4
+ *
5
+ * The input is what the model wrote. Claude Code validates it when it runs the
6
+ * tool, after the adapter reported the tool use, so a field can hold any type:
7
+ * `Read {"file_path": 12345}`. A reporter must not pass such a value on as a
8
+ * path or a title.
9
+ */
10
+ export function inputString(input, key) {
11
+ if (!input || typeof input !== "object")
12
+ return undefined;
13
+ const value = input[key];
14
+ return typeof value === "string" && value !== "" ? value : undefined;
15
+ }
2
16
  /**
3
17
  * Convert an absolute file path to a project-relative path for display.
4
18
  * Returns the original path if it's outside the project directory or if no cwd is provided.
@@ -1 +1 @@
1
- {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKnE;AAED,gFAAgF;AAChF,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;IAWrC,iFAAiF;IACjF,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,SAAS;IAIpE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,eAAe;CAsFvE"}
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKnE;AAED,gFAAgF;AAChF,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;IAUrC,iFAAiF;IACjF,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,SAAS;IAIpE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,eAAe;CAsFvE"}
@@ -1,4 +1,4 @@
1
- import { structuredResult, textContent, toAcpContentUpdate } from "../content.js";
1
+ import { inputString, structuredResult, textContent, toAcpContentUpdate } from "../content.js";
2
2
  /**
3
3
  * Reads a Bash or PowerShell input's description the way the CLI validates it.
4
4
  * Since CLI 2.1.295 the CLI accepts `command_description` for `description`.
@@ -16,10 +16,9 @@ export function shellDescription(input) {
16
16
  /** Bash and PowerShell: a command whose output goes to the terminal channel. */
17
17
  export class BashReporter {
18
18
  toolUse(input) {
19
- const bash = input;
20
19
  const description = shellDescription(input);
21
20
  return {
22
- title: bash?.command ? bash.command : "Terminal",
21
+ title: inputString(input, "command") ?? "Terminal",
23
22
  kind: "execute",
24
23
  command: true,
25
24
  ...(description ? { display: [textContent(description)] } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"file-edit.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/file-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EAEf,MAAM,6CAA6C,CAAC;AAQrD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACb,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,YAAY;IAoCpF,UAAU,IAAI,eAAe;IAI7B,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAGrF;AAED,yFAAyF;AACzF,KAAK,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAI9E;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAYpF;AAED,qDAAqD;AACrD,qB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a,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,cAAc,GAAG,YAAY;IA2B5E,UAAU,IAAI,eAAe;IAI7B,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAGrF;AAyCD;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,cAAc,GAAG,YAAY;IAqB5E;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe;CAMxD"}
@@ -1,5 +1,5 @@
1
1
  import { patchUpdateFromDiffToolResponse, toolUpdateFromDiffToolResponse, v2UpdateFromDiffToolResponse, } from "../../diff.js";
2
- import { markdownEscape, resultText, textContent, toDisplayPath } from "../content.js";
2
+ import { inputString, markdownEscape, resultText, textContent, toDisplayPath } from "../content.js";
3
3
  /**
4
4
  * Write: the diff holds the file text. The PostToolUse hook sends the final
5
5
  * diff, so the result text is only a confirmation.
@@ -73,21 +73,22 @@ export function normalizeWriteInput(input) {
73
73
  export class EditReporter {
74
74
  toolUse(input, { cwd, capabilities }) {
75
75
  const edit = input;
76
- const displayPath = edit?.file_path ? toDisplayPath(edit.file_path, cwd) : undefined;
76
+ const filePath = inputString(input, "file_path");
77
+ const displayPath = filePath ? toDisplayPath(filePath, cwd) : undefined;
77
78
  const facts = {
78
79
  title: displayPath ? `Edit ${displayPath}` : "Edit",
79
80
  kind: "edit",
80
- locations: edit?.file_path ? [{ path: edit.file_path }] : [],
81
+ locations: filePath ? [{ path: filePath }] : [],
81
82
  };
82
83
  // The standard diff, also for a client that negotiated patches: the input
83
84
  // holds a snippet, not the file, so a patch would need line numbers that
84
85
  // the adapter does not know here. A v2 diff cannot hold a snippet, so a v2
85
86
  // client gets the patch from the PostToolUse hook alone.
86
- if (edit?.file_path && (edit.old_string || edit.new_string) && !capabilities.v2) {
87
+ if (filePath && (edit?.old_string || edit?.new_string) && !capabilities.v2) {
87
88
  facts.change = [
88
89
  {
89
90
  type: "diff",
90
- path: edit.file_path,
91
+ path: filePath,
91
92
  oldText: edit.old_string || null,
92
93
  newText: edit.new_string ?? "",
93
94
  },
@@ -151,9 +152,8 @@ export class NotebookEditReporter {
151
152
  if (!capabilities.air.client)
152
153
  return { title: "NotebookEdit", kind: "other" };
153
154
  const notebook = input;
154
- const displayPath = notebook?.notebook_path
155
- ? toDisplayPath(notebook.notebook_path, cwd)
156
- : undefined;
155
+ const notebookPath = inputString(input, "notebook_path");
156
+ const displayPath = notebookPath ? toDisplayPath(notebookPath, cwd) : undefined;
157
157
  const cell = notebook?.cell_id ? ` ${notebook.cell_id}` : "";
158
158
  const verb = notebook?.edit_mode === "insert"
159
159
  ? "Insert"
@@ -164,7 +164,7 @@ export class NotebookEditReporter {
164
164
  return {
165
165
  title: displayPath ? `${verb} cell${cell} in ${displayPath}` : "Edit notebook",
166
166
  kind: "edit",
167
- locations: notebook?.notebook_path ? [{ path: notebook.notebook_path }] : [],
167
+ locations: notebookPath ? [{ path: notebookPath }] : [],
168
168
  ...(source ? { display: source } : {}),
169
169
  };
170
170
  }
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/read.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,iDAAiD;AACjD,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,cAAc,GAAG,YAAY;IAoB9D,UAAU,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,eAAe;CAiDhF"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/read.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,iDAAiD;AACjD,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,cAAc,GAAG,YAAY;IAmB9D,UAAU,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,eAAe;CAiDhF"}
@@ -1,8 +1,9 @@
1
- import { markdownEscape, structuredResult, textContent, toAcpContentBlock, toDisplayPath, } from "../content.js";
1
+ import { inputString, markdownEscape, structuredResult, textContent, toAcpContentBlock, toDisplayPath, } from "../content.js";
2
2
  /** Read: the file text is the result to show. */
3
3
  export class ReadReporter {
4
4
  toolUse(input, { cwd }) {
5
5
  const read = input;
6
+ const filePath = inputString(input, "file_path");
6
7
  let limit = "";
7
8
  if (read?.limit && read.limit > 0) {
8
9
  limit = " (" + (read.offset ?? 1) + " - " + ((read.offset ?? 1) + read.limit - 1) + ")";
@@ -10,15 +11,13 @@ export class ReadReporter {
10
11
  else if (read?.offset) {
11
12
  limit = " (from line " + read.offset + ")";
12
13
  }
13
- const displayPath = read?.file_path ? toDisplayPath(read.file_path, cwd) : "File";
14
+ const displayPath = filePath ? toDisplayPath(filePath, cwd) : "File";
14
15
  return {
15
16
  title: "Read " + displayPath + limit,
16
17
  kind: "read",
17
18
  // Read offsets are 1-based. ACP lines are too, so `offset: 0` (read from
18
19
  // the start) becomes line 1.
19
- locations: read?.file_path
20
- ? [{ path: read.file_path, line: Math.max(read.offset ?? 1, 1) }]
21
- : [],
20
+ locations: filePath ? [{ path: filePath, line: Math.max(read?.offset ?? 1, 1) }] : [],
22
21
  };
23
22
  }
24
23
  toolResult({ toolUse, result, structured }) {
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,iDAAiD;AACjD,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;CAWtC;AAED,2DAA2D;AAC3D,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;CAoBtC;AAgBD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAK3D"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/search.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,iDAAiD;AACjD,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;CAYtC;AAED,2DAA2D;AAC3D,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;CAoBtC;AAgBD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAK3D"}
@@ -1,16 +1,18 @@
1
+ import { inputString } from "../content.js";
1
2
  /** Glob: the file list is the result to show. */
2
3
  export class GlobReporter {
3
4
  toolUse(input) {
4
5
  const glob = input;
6
+ const searchPath = inputString(input, "path");
5
7
  let label = "Find";
6
- if (glob?.path)
7
- label += ` \`${glob.path}\``;
8
+ if (searchPath)
9
+ label += ` \`${searchPath}\``;
8
10
  if (glob?.pattern)
9
11
  label += ` \`${glob.pattern}\``;
10
12
  return {
11
13
  title: label,
12
14
  kind: "search",
13
- locations: glob?.path ? [{ path: glob.path }] : [],
15
+ locations: searchPath ? [{ path: searchPath }] : [],
14
16
  };
15
17
  }
16
18
  }