@agentclientprotocol/claude-agent-acp 0.93.1-preview.5 → 0.93.1-preview.6
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.
|
@@ -64,4 +64,19 @@ export declare function subagentLaunchIds(content: unknown): string[];
|
|
|
64
64
|
export declare function readSubagentMessages(sessionId: string, agentId: string, history: SubagentHistory, logger: {
|
|
65
65
|
error(...args: unknown[]): void;
|
|
66
66
|
}): Promise<SessionMessage[]>;
|
|
67
|
+
/**
|
|
68
|
+
* The transcript of a `subagent_type: "fork"` child without the context it
|
|
69
|
+
* inherited. A fork transcript starts with a copy of the parent's launching
|
|
70
|
+
* assistant message (its text, thinking and every tool_use, including the
|
|
71
|
+
* Agent call itself), then a user message with a "Fork started — processing
|
|
72
|
+
* in background" tool_result for each of those tool_uses and the text
|
|
73
|
+
* `<fork-boilerplate>…</fork-boilerplate>\nYour directive: <prompt>`. A fork
|
|
74
|
+
* launched from inside a subagent also gets a copy of that subagent's history
|
|
75
|
+
* before them. None of it is the child's own work: replayed as is, the
|
|
76
|
+
* parent's text and tool calls would show again in the child.
|
|
77
|
+
*
|
|
78
|
+
* This drops every record before the directive message, and reduces that
|
|
79
|
+
* message to the prompt. Other transcripts are returned unchanged.
|
|
80
|
+
*/
|
|
81
|
+
export declare function stripForkPrefix(messages: SessionMessage[]): SessionMessage[];
|
|
67
82
|
//# sourceMappingURL=subagent-history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-history.d.ts","sourceRoot":"","sources":["../src/subagent-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAA+B,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7F,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,IAAI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,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAkB5E"}
|
package/dist/subagent-history.js
CHANGED
|
@@ -154,7 +154,8 @@ async function readLaunchIdsFromTranscript(file, owner, logger) {
|
|
|
154
154
|
const stream = createReadStream(file, { encoding: "utf8" });
|
|
155
155
|
try {
|
|
156
156
|
for await (const line of readline.createInterface({ input: stream, crlfDelay: Infinity })) {
|
|
157
|
-
|
|
157
|
+
const forkDirective = owner !== null && line.includes(FORK_BOILERPLATE_OPEN);
|
|
158
|
+
if (!line.includes('"tool_use"') && !forkDirective)
|
|
158
159
|
continue;
|
|
159
160
|
let record;
|
|
160
161
|
try {
|
|
@@ -163,6 +164,13 @@ async function readLaunchIdsFromTranscript(file, owner, logger) {
|
|
|
163
164
|
catch {
|
|
164
165
|
continue;
|
|
165
166
|
}
|
|
167
|
+
// Every record of a fork child's transcript before its directive message
|
|
168
|
+
// is inherited context: a copy of the launching message, whose launch
|
|
169
|
+
// calls are the parent's, not the fork's.
|
|
170
|
+
if (forkDirective && record !== null && isForkDirectiveMessage(record)) {
|
|
171
|
+
launches.clear();
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
166
174
|
if (record?.type !== "assistant")
|
|
167
175
|
continue;
|
|
168
176
|
if (owner === null
|
|
@@ -194,12 +202,67 @@ export async function readSubagentMessages(sessionId, agentId, history, logger)
|
|
|
194
202
|
if (history.dir) {
|
|
195
203
|
const messages = await getSubagentMessages(sessionId, agentId, { dir: history.dir });
|
|
196
204
|
if (messages.length > 0)
|
|
197
|
-
return messages;
|
|
205
|
+
return stripForkPrefix(messages);
|
|
198
206
|
}
|
|
199
|
-
return await getSubagentMessages(sessionId, agentId);
|
|
207
|
+
return stripForkPrefix(await getSubagentMessages(sessionId, agentId));
|
|
200
208
|
}
|
|
201
209
|
catch (error) {
|
|
202
210
|
logger.error(`Failed to read the history of subagent ${agentId}:`, error);
|
|
203
211
|
return [];
|
|
204
212
|
}
|
|
205
213
|
}
|
|
214
|
+
/** How Claude Code opens the directive message of a `subagent_type: "fork"` child. */
|
|
215
|
+
const FORK_BOILERPLATE_OPEN = "<fork-boilerplate>";
|
|
216
|
+
/** What follows the boilerplate, right before the prompt of the Agent call. */
|
|
217
|
+
const FORK_DIRECTIVE_MARKER = "</fork-boilerplate>\nYour directive: ";
|
|
218
|
+
/** Whether `block` is the text block of a fork child's directive message. */
|
|
219
|
+
function isForkDirectiveText(block) {
|
|
220
|
+
return (typeof block === "object" &&
|
|
221
|
+
block !== null &&
|
|
222
|
+
block.type === "text" &&
|
|
223
|
+
typeof block.text === "string" &&
|
|
224
|
+
block.text.startsWith(FORK_BOILERPLATE_OPEN));
|
|
225
|
+
}
|
|
226
|
+
/** Whether the transcript record `message` is the directive message of a fork child. */
|
|
227
|
+
function isForkDirectiveMessage(message) {
|
|
228
|
+
if (message.type !== "user")
|
|
229
|
+
return false;
|
|
230
|
+
const content = message.message?.content;
|
|
231
|
+
return Array.isArray(content) && content.some(isForkDirectiveText);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The transcript of a `subagent_type: "fork"` child without the context it
|
|
235
|
+
* inherited. A fork transcript starts with a copy of the parent's launching
|
|
236
|
+
* assistant message (its text, thinking and every tool_use, including the
|
|
237
|
+
* Agent call itself), then a user message with a "Fork started — processing
|
|
238
|
+
* in background" tool_result for each of those tool_uses and the text
|
|
239
|
+
* `<fork-boilerplate>…</fork-boilerplate>\nYour directive: <prompt>`. A fork
|
|
240
|
+
* launched from inside a subagent also gets a copy of that subagent's history
|
|
241
|
+
* before them. None of it is the child's own work: replayed as is, the
|
|
242
|
+
* parent's text and tool calls would show again in the child.
|
|
243
|
+
*
|
|
244
|
+
* This drops every record before the directive message, and reduces that
|
|
245
|
+
* message to the prompt. Other transcripts are returned unchanged.
|
|
246
|
+
*/
|
|
247
|
+
export function stripForkPrefix(messages) {
|
|
248
|
+
const index = messages.findIndex(isForkDirectiveMessage);
|
|
249
|
+
if (index === -1)
|
|
250
|
+
return messages;
|
|
251
|
+
const directive = messages[index];
|
|
252
|
+
const content = directive.message.content;
|
|
253
|
+
const prompt = content.flatMap((block) => {
|
|
254
|
+
if (!isForkDirectiveText(block))
|
|
255
|
+
return [];
|
|
256
|
+
const start = block.text.indexOf(FORK_DIRECTIVE_MARKER);
|
|
257
|
+
return start === -1
|
|
258
|
+
? []
|
|
259
|
+
: [{ type: "text", text: block.text.slice(start + FORK_DIRECTIVE_MARKER.length) }];
|
|
260
|
+
});
|
|
261
|
+
const rest = messages.slice(index + 1);
|
|
262
|
+
if (prompt.length === 0)
|
|
263
|
+
return rest;
|
|
264
|
+
return [
|
|
265
|
+
{ ...directive, message: { ...directive.message, content: prompt } },
|
|
266
|
+
...rest,
|
|
267
|
+
];
|
|
268
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/agent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElG,2EAA2E;AAC3E,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/agent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElG,2EAA2E;AAC3E,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;IAarC,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,eAAe;CA2BvE"}
|
|
@@ -3,8 +3,9 @@ import { structuredResult, textContent, toAcpContentUpdate } from "../content.js
|
|
|
3
3
|
export class AgentReporter {
|
|
4
4
|
toolUse(input) {
|
|
5
5
|
const agent = input;
|
|
6
|
-
// `effort` is set only when the user asked for one (CLI 2.1.292+).
|
|
7
|
-
|
|
6
|
+
// `effort` is set only when the user asked for one (CLI 2.1.292+). A
|
|
7
|
+
// `subagent_type: "fork"` child ignores it and runs at the parent's effort.
|
|
8
|
+
const effort = agent?.effort && agent.subagent_type !== "fork" ? ` (${agent.effort} effort)` : "";
|
|
8
9
|
return {
|
|
9
10
|
title: (agent?.description ? agent.description : "Task") + effort,
|
|
10
11
|
kind: "think",
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.93.1-preview.
|
|
6
|
+
"version": "0.93.1-preview.6",
|
|
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",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@agentclientprotocol/sdk": "2.0.0",
|
|
69
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
69
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.303",
|
|
70
70
|
"diff": "9.0.0",
|
|
71
71
|
"zod": "4.6.7"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@anthropic-ai/sdk": "0.
|
|
74
|
+
"@anthropic-ai/sdk": "0.135.0",
|
|
75
75
|
"@eslint/js": "10.0.1",
|
|
76
76
|
"@tsconfig/node22": "22.0.6",
|
|
77
77
|
"@types/node": "26.6.5",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"@typescript-eslint/parser": "8.71.2",
|
|
80
80
|
"ajv": "8.20.0",
|
|
81
81
|
"ajv-formats": "3.0.1",
|
|
82
|
-
"eslint": "10.
|
|
82
|
+
"eslint": "10.13.0",
|
|
83
83
|
"eslint-config-prettier": "10.1.8",
|
|
84
84
|
"globals": "17.13.0",
|
|
85
85
|
"prettier": "3.9.10",
|
|
86
86
|
"ts-node": "10.9.2",
|
|
87
87
|
"typescript": "6.0.3",
|
|
88
|
-
"vitest": "5.0.
|
|
88
|
+
"vitest": "5.0.5"
|
|
89
89
|
}
|
|
90
90
|
}
|