@agentclientprotocol/claude-agent-acp 0.59.0 → 0.61.0
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/dist/acp-agent.d.ts +125 -5
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +594 -98
- package/dist/tools.d.ts +1 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +34 -9
- package/package.json +7 -7
package/dist/tools.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { HookCallback } from "@anthropic-ai/claude-agent-sdk";
|
|
|
3
3
|
import { TaskCreateInput, TaskCreateOutput, TaskUpdateInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
4
4
|
import { ToolResultBlockParam, WebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources";
|
|
5
5
|
import { BetaBashCodeExecutionToolResultBlockParam, BetaCodeExecutionToolResultBlockParam, BetaRequestMCPToolResultBlockParam, BetaTextEditorCodeExecutionToolResultBlockParam, BetaToolResultBlockParam, BetaToolSearchToolResultBlockParam, BetaWebFetchToolResultBlockParam, BetaWebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
6
|
-
import { Logger } from "./acp-agent.js";
|
|
7
6
|
interface ToolInfo {
|
|
8
7
|
title: string;
|
|
9
8
|
kind: ToolKind;
|
|
@@ -82,7 +81,7 @@ export declare function toolUpdateFromDiffToolResponse(toolResponse: unknown): {
|
|
|
82
81
|
export declare const registerHookCallback: (toolUseID: string, { onPostToolUseHook, }: {
|
|
83
82
|
onPostToolUseHook?: (toolUseID: string, toolInput: unknown, toolResponse: unknown) => Promise<void>;
|
|
84
83
|
}) => void;
|
|
85
|
-
export declare const createPostToolUseHook: (
|
|
84
|
+
export declare const createPostToolUseHook: (options?: {
|
|
86
85
|
onEnterPlanMode?: () => Promise<void>;
|
|
87
86
|
}) => HookCallback;
|
|
88
87
|
/**
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAaL,eAAe,EACf,gBAAgB,EAChB,eAAe,EAKhB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,yCAAyC,EAGzC,qCAAqC,EAGrC,kCAAkC,EAGlC,+CAA+C,EAI/C,wBAAwB,EACxB,kCAAkC,EAIlC,gCAAgC,EAEhC,iCAAiC,EAClC,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAaL,eAAe,EACf,gBAAgB,EAChB,eAAe,EAKhB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,yCAAyC,EAGzC,qCAAqC,EAGrC,kCAAkC,EAGlC,+CAA+C,EAI/C,wBAAwB,EACxB,kCAAkC,EAIlC,gCAAgC,EAEhC,iCAAiC,EAClC,MAAM,sCAAsC,CAAC;AA2B9C,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC;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,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAiBtD,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACxB,SAAS;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAsBpE,CAAC"}
|
package/dist/tools.js
CHANGED
|
@@ -362,9 +362,38 @@ function structuredResult(toolUseResult) {
|
|
|
362
362
|
* matching rather than mangle the report.
|
|
363
363
|
*/
|
|
364
364
|
function stripAgentTrailer(text) {
|
|
365
|
-
return text
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
return stripAgentIdLine(stripUsageBlock(text));
|
|
366
|
+
}
|
|
367
|
+
const USAGE_OPEN = "<usage>";
|
|
368
|
+
const USAGE_CLOSE = "</usage>";
|
|
369
|
+
/** Remove a trailing `<usage>…</usage>` block, plus trailing whitespace and
|
|
370
|
+
* one preceding newline. Matches from the *last* `<usage>` so a report that
|
|
371
|
+
* merely mentions the marker earlier isn't truncated at the mention. */
|
|
372
|
+
function stripUsageBlock(text) {
|
|
373
|
+
const body = text.trimEnd();
|
|
374
|
+
if (!body.endsWith(USAGE_CLOSE)) {
|
|
375
|
+
return text;
|
|
376
|
+
}
|
|
377
|
+
const open = body.lastIndexOf(USAGE_OPEN, body.length - USAGE_CLOSE.length - USAGE_OPEN.length);
|
|
378
|
+
if (open === -1) {
|
|
379
|
+
return text;
|
|
380
|
+
}
|
|
381
|
+
return body.slice(0, open > 0 && body[open - 1] === "\n" ? open - 1 : open);
|
|
382
|
+
}
|
|
383
|
+
/** The continuation line, anchored to a whole line so the regex has a single
|
|
384
|
+
* start position and no ambiguous repetition (`[\w-]+` can't consume the
|
|
385
|
+
* following space, `[^)]*` can't consume the closing paren) — it runs in
|
|
386
|
+
* linear time on any input. */
|
|
387
|
+
const AGENT_ID_LINE = /^agentId: [\w-]+ \([^)]*\)$/;
|
|
388
|
+
/** Remove a final `agentId: <id> (…)` line, plus trailing whitespace and the
|
|
389
|
+
* newline that preceded the line. */
|
|
390
|
+
function stripAgentIdLine(text) {
|
|
391
|
+
const body = text.trimEnd();
|
|
392
|
+
const lineStart = body.lastIndexOf("\n") + 1;
|
|
393
|
+
if (!AGENT_ID_LINE.test(body.slice(lineStart))) {
|
|
394
|
+
return text;
|
|
395
|
+
}
|
|
396
|
+
return body.slice(0, Math.max(lineStart - 1, 0));
|
|
368
397
|
}
|
|
369
398
|
/** Apply {@link stripAgentTrailer} across a raw tool_result `content` (plain
|
|
370
399
|
* string or block array), leaving non-text blocks untouched. */
|
|
@@ -898,7 +927,7 @@ export const registerHookCallback = (toolUseID, { onPostToolUseHook, }) => {
|
|
|
898
927
|
};
|
|
899
928
|
};
|
|
900
929
|
/* A callback for Claude Code that is called when receiving a PostToolUse hook */
|
|
901
|
-
export const createPostToolUseHook = (
|
|
930
|
+
export const createPostToolUseHook = (options) => async (input, toolUseID) => {
|
|
902
931
|
if (input.hook_event_name === "PostToolUse") {
|
|
903
932
|
// Handle EnterPlanMode tool - notify client of mode change after successful execution
|
|
904
933
|
if (input.tool_name === "EnterPlanMode" && options?.onEnterPlanMode) {
|
|
@@ -908,12 +937,8 @@ export const createPostToolUseHook = (logger = console, options) => async (input
|
|
|
908
937
|
const onPostToolUseHook = toolUseCallbacks[toolUseID]?.onPostToolUseHook;
|
|
909
938
|
if (onPostToolUseHook) {
|
|
910
939
|
await onPostToolUseHook(toolUseID, input.tool_input, input.tool_response);
|
|
911
|
-
delete toolUseCallbacks[toolUseID]; // Cleanup after execution
|
|
912
|
-
}
|
|
913
|
-
else {
|
|
914
|
-
logger.error(`No onPostToolUseHook found for tool use ID: ${toolUseID}`);
|
|
915
|
-
delete toolUseCallbacks[toolUseID];
|
|
916
940
|
}
|
|
941
|
+
delete toolUseCallbacks[toolUseID]; // Cleanup after execution
|
|
917
942
|
}
|
|
918
943
|
}
|
|
919
944
|
return { continue: true };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.61.0",
|
|
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",
|
|
@@ -63,21 +63,21 @@
|
|
|
63
63
|
"node": ">=22"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@agentclientprotocol/sdk": "1.
|
|
67
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
66
|
+
"@agentclientprotocol/sdk": "1.3.0",
|
|
67
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.217",
|
|
68
68
|
"zod": "^3.25.0 || ^4.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@anthropic-ai/sdk": "0.
|
|
71
|
+
"@anthropic-ai/sdk": "0.112.5",
|
|
72
72
|
"@eslint/js": "10.0.1",
|
|
73
73
|
"@tsconfig/node22": "22.0.5",
|
|
74
74
|
"@types/node": "26.1.1",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
76
|
-
"@typescript-eslint/parser": "8.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "8.65.0",
|
|
76
|
+
"@typescript-eslint/parser": "8.65.0",
|
|
77
77
|
"eslint": "10.7.0",
|
|
78
78
|
"eslint-config-prettier": "10.1.8",
|
|
79
79
|
"globals": "17.7.0",
|
|
80
|
-
"prettier": "3.9.
|
|
80
|
+
"prettier": "3.9.6",
|
|
81
81
|
"ts-node": "10.9.2",
|
|
82
82
|
"typescript": "6.0.3",
|
|
83
83
|
"vitest": "4.1.10"
|