@sudocode-ai/claude-code-acp 0.13.6 → 0.13.8
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 +2 -2
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +46 -16
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +42 -3
- package/dist/tools.d.ts +2 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +68 -7
- package/package.json +11 -11
package/dist/acp-agent.d.ts
CHANGED
|
@@ -118,12 +118,12 @@ export type ToolUpdateMeta = {
|
|
|
118
118
|
toolResponse?: unknown;
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
|
-
type ToolUseCache = {
|
|
121
|
+
export type ToolUseCache = {
|
|
122
122
|
[key: string]: {
|
|
123
123
|
type: "tool_use" | "server_tool_use" | "mcp_tool_use";
|
|
124
124
|
id: string;
|
|
125
125
|
name: string;
|
|
126
|
-
input:
|
|
126
|
+
input: unknown;
|
|
127
127
|
};
|
|
128
128
|
};
|
|
129
129
|
export declare class ClaudeAcpAgent implements Agent {
|
package/dist/acp-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,oBAAoB,EACpB,qBAAqB,EAErB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,oB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/dist/acp-agent.js
CHANGED
|
@@ -10,6 +10,7 @@ import { EDIT_TOOL_NAMES, acpToolNames } from "./tools.js";
|
|
|
10
10
|
import { toolInfoFromToolUse, planEntries, toolUpdateFromToolResult, registerHookCallback, createPostToolUseHook, createPreToolUseHook, } from "./tools.js";
|
|
11
11
|
import packageJson from "../package.json" with { type: "json" };
|
|
12
12
|
import { randomUUID } from "node:crypto";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
13
14
|
export const CLAUDE_CONFIG_DIR = process.env.CLAUDE ?? path.join(os.homedir(), ".claude");
|
|
14
15
|
// Bypass Permissions doesn't work if we are a root/sudo user
|
|
15
16
|
const IS_ROOT = (process.geteuid?.() ?? process.getuid?.()) === 0;
|
|
@@ -31,16 +32,16 @@ export class ClaudeAcpAgent {
|
|
|
31
32
|
id: "claude-login",
|
|
32
33
|
};
|
|
33
34
|
// If client supports terminal-auth capability, use that instead.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
if (request.clientCapabilities?._meta?.["terminal-auth"] === true) {
|
|
36
|
+
const cliPath = fileURLToPath(import.meta.resolve("@anthropic-ai/claude-agent-sdk/cli.js"));
|
|
37
|
+
authMethod._meta = {
|
|
38
|
+
"terminal-auth": {
|
|
39
|
+
command: "node",
|
|
40
|
+
args: [cliPath, "/login"],
|
|
41
|
+
label: "Claude Code Login",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
44
45
|
return {
|
|
45
46
|
protocolVersion: 1,
|
|
46
47
|
agentCapabilities: {
|
|
@@ -99,6 +100,26 @@ export class ClaudeAcpAgent {
|
|
|
99
100
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
100
101
|
// Find the CLI-assigned session ID by looking for new session files
|
|
101
102
|
const cliSessionId = await this.discoverCliSessionId(sessionDir, beforeFiles, result.sessionId);
|
|
103
|
+
// If no new file was created, create one by copying the parent session file
|
|
104
|
+
if (cliSessionId === result.sessionId) {
|
|
105
|
+
// cliSessionId equals fallback, meaning no new file was found
|
|
106
|
+
const parentFilePath = path.join(sessionDir, `${params.sessionId}.jsonl`);
|
|
107
|
+
const forkFilePath = path.join(sessionDir, `${result.sessionId}.jsonl`);
|
|
108
|
+
if (fs.existsSync(parentFilePath) && !fs.existsSync(forkFilePath)) {
|
|
109
|
+
try {
|
|
110
|
+
// Copy parent session file to fork session file
|
|
111
|
+
fs.copyFileSync(parentFilePath, forkFilePath);
|
|
112
|
+
// Update the internal session ID in the copied file
|
|
113
|
+
this.updateSessionIdInFile(forkFilePath, result.sessionId);
|
|
114
|
+
// Promote to full session (not sidechain)
|
|
115
|
+
this.promoteToFullSession(forkFilePath);
|
|
116
|
+
this.logger.log(`[claude-code-acp] Fork: created fork file by copying parent: ${params.sessionId}.jsonl -> ${result.sessionId}.jsonl`);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
this.logger.error(`[claude-code-acp] Failed to create fork file from parent: ${err}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
102
123
|
if (cliSessionId && cliSessionId !== result.sessionId) {
|
|
103
124
|
// Check if the CLI assigned a non-UUID session ID (e.g., "agent-xxx")
|
|
104
125
|
// If so, we need to extract the internal sessionId from the file
|
|
@@ -396,6 +417,9 @@ export class ClaudeAcpAgent {
|
|
|
396
417
|
}
|
|
397
418
|
break;
|
|
398
419
|
}
|
|
420
|
+
case "hook_started":
|
|
421
|
+
case "task_notification":
|
|
422
|
+
case "hook_progress":
|
|
399
423
|
case "hook_response":
|
|
400
424
|
case "status":
|
|
401
425
|
// Todo: process via status api: https://docs.claude.com/en/docs/claude-code/hooks#hook-output
|
|
@@ -427,7 +451,7 @@ export class ClaudeAcpAgent {
|
|
|
427
451
|
throw RequestError.internalError(undefined, message.result);
|
|
428
452
|
}
|
|
429
453
|
// Check if auto-compaction should be triggered
|
|
430
|
-
if (session && await this.shouldTriggerCompaction(params.sessionId)) {
|
|
454
|
+
if (session && (await this.shouldTriggerCompaction(params.sessionId))) {
|
|
431
455
|
await this.triggerAutoCompaction(params.sessionId);
|
|
432
456
|
// Continue processing - the compaction will happen in the background
|
|
433
457
|
}
|
|
@@ -466,6 +490,14 @@ export class ClaudeAcpAgent {
|
|
|
466
490
|
// their own docs: https://docs.anthropic.com/en/docs/claude-code/sdk/sdk-slash-commands#%2Fcompact-compact-conversation-history
|
|
467
491
|
if (typeof message.message.content === "string" &&
|
|
468
492
|
message.message.content.includes("<local-command-stdout>")) {
|
|
493
|
+
// Handle /context by sending its reply as regular agent message.
|
|
494
|
+
if (message.message.content.includes("Context Usage")) {
|
|
495
|
+
for (const notification of toAcpNotifications(message.message.content
|
|
496
|
+
.replace("<local-command-stdout>", "")
|
|
497
|
+
.replace("</local-command-stdout>", ""), "assistant", params.sessionId, this.toolUseCache, this.client, this.logger)) {
|
|
498
|
+
await this.client.sessionUpdate(notification);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
469
501
|
this.logger.log(message.message.content);
|
|
470
502
|
break;
|
|
471
503
|
}
|
|
@@ -500,6 +532,7 @@ export class ClaudeAcpAgent {
|
|
|
500
532
|
break;
|
|
501
533
|
}
|
|
502
534
|
case "tool_progress":
|
|
535
|
+
case "tool_use_summary":
|
|
503
536
|
break;
|
|
504
537
|
case "auth_status":
|
|
505
538
|
break;
|
|
@@ -1062,10 +1095,7 @@ export class ClaudeAcpAgent {
|
|
|
1062
1095
|
// Start with user-provided tools lists, then add ACP-managed tools
|
|
1063
1096
|
const allowedTools = [...(userProvidedOptions?.allowedTools ?? [])];
|
|
1064
1097
|
// Disable AskUserQuestion for now, not a great way to expose this over ACP at the moment (in progress work so we can revisit)
|
|
1065
|
-
const disallowedTools = [
|
|
1066
|
-
"AskUserQuestion",
|
|
1067
|
-
...(userProvidedOptions?.disallowedTools ?? []),
|
|
1068
|
-
];
|
|
1098
|
+
const disallowedTools = ["AskUserQuestion", ...(userProvidedOptions?.disallowedTools ?? [])];
|
|
1069
1099
|
// Check if built-in tools should be disabled
|
|
1070
1100
|
const disableBuiltInTools = params._meta?.disableBuiltInTools === true;
|
|
1071
1101
|
if (!disableBuiltInTools) {
|
|
@@ -1192,7 +1222,6 @@ async function getAvailableModels(query) {
|
|
|
1192
1222
|
}
|
|
1193
1223
|
async function getAvailableSlashCommands(query) {
|
|
1194
1224
|
const UNSUPPORTED_COMMANDS = [
|
|
1195
|
-
"context",
|
|
1196
1225
|
"cost",
|
|
1197
1226
|
"login",
|
|
1198
1227
|
"logout",
|
|
@@ -1455,6 +1484,7 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
1455
1484
|
toolCallId: chunk.tool_use_id,
|
|
1456
1485
|
sessionUpdate: "tool_call_update",
|
|
1457
1486
|
status: "is_error" in chunk && chunk.is_error ? "failed" : "completed",
|
|
1487
|
+
rawOutput: chunk.content,
|
|
1458
1488
|
...toolUpdateFromToolResult(chunk, toolUseCache[chunk.tool_use_id]),
|
|
1459
1489
|
};
|
|
1460
1490
|
}
|
package/dist/mcp-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASpE,OAAO,EAAqB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAQlC,eAAO,MAAM,eAAe,iSAIT,CAAC;AA2BpB,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,GACjD,SAAS,
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASpE,OAAO,EAAqB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAQlC,eAAO,MAAM,eAAe,iSAIT,CAAC;AA2BpB,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,GACjD,SAAS,CA+qBX;AA+DD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC,GACD;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAyF/C"}
|
package/dist/mcp-server.js
CHANGED
|
@@ -535,15 +535,54 @@ Output: Create directory 'foo'`),
|
|
|
535
535
|
|
|
536
536
|
In sessions with ${acpToolNames.bashOutput} always use it for output from Bash commands instead of TaskOutput.`,
|
|
537
537
|
inputSchema: {
|
|
538
|
-
|
|
538
|
+
task_id: z
|
|
539
539
|
.string()
|
|
540
540
|
.describe(`The id of the background bash command as returned by \`${acpToolNames.bash}\``),
|
|
541
|
+
block: z.boolean().describe("Whether to wait for completion"),
|
|
542
|
+
timeout: z.number().describe("Max wait time in ms"),
|
|
541
543
|
},
|
|
542
544
|
}, async (input) => {
|
|
543
545
|
try {
|
|
544
|
-
const bgTerm = agent.backgroundTerminals[input.
|
|
546
|
+
const bgTerm = agent.backgroundTerminals[input.task_id];
|
|
545
547
|
if (!bgTerm) {
|
|
546
|
-
throw new Error(`Unknown shell ${input.
|
|
548
|
+
throw new Error(`Unknown shell ${input.task_id}`);
|
|
549
|
+
}
|
|
550
|
+
if (input.block && bgTerm.status === "started") {
|
|
551
|
+
const statusPromise = Promise.race([
|
|
552
|
+
bgTerm.handle
|
|
553
|
+
.waitForExit()
|
|
554
|
+
.then((exitStatus) => ({ status: "exited", exitStatus })),
|
|
555
|
+
sleep(input.timeout ?? 2 * 60 * 1000).then(async () => {
|
|
556
|
+
if (bgTerm.status === "started") {
|
|
557
|
+
await bgTerm.handle.kill();
|
|
558
|
+
}
|
|
559
|
+
return { status: "timedOut", exitStatus: null };
|
|
560
|
+
}),
|
|
561
|
+
]);
|
|
562
|
+
const { status, exitStatus } = await statusPromise;
|
|
563
|
+
const currentOutput = await bgTerm.handle.currentOutput();
|
|
564
|
+
const strippedOutput = stripCommonPrefix(bgTerm.lastOutput?.output ?? "", currentOutput.output);
|
|
565
|
+
agent.backgroundTerminals[input.task_id] = {
|
|
566
|
+
status,
|
|
567
|
+
pendingOutput: {
|
|
568
|
+
...currentOutput,
|
|
569
|
+
output: strippedOutput,
|
|
570
|
+
exitStatus: exitStatus ?? currentOutput.exitStatus,
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
await bgTerm.handle.release();
|
|
574
|
+
return {
|
|
575
|
+
content: [
|
|
576
|
+
{
|
|
577
|
+
type: "text",
|
|
578
|
+
text: toolCommandOutput(status, {
|
|
579
|
+
...currentOutput,
|
|
580
|
+
output: strippedOutput,
|
|
581
|
+
exitStatus: exitStatus ?? currentOutput.exitStatus,
|
|
582
|
+
}),
|
|
583
|
+
},
|
|
584
|
+
],
|
|
585
|
+
};
|
|
547
586
|
}
|
|
548
587
|
if (bgTerm.status === "started") {
|
|
549
588
|
const newOutput = await bgTerm.handle.currentOutput();
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PlanEntry, ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { ToolResultBlockParam, WebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources";
|
|
3
|
+
import { BetaBashCodeExecutionToolResultBlockParam, BetaCodeExecutionToolResultBlockParam, BetaRequestMCPToolResultBlockParam, BetaTextEditorCodeExecutionToolResultBlockParam, BetaToolResultBlockParam, BetaToolSearchToolResultBlockParam, BetaWebFetchToolResultBlockParam, BetaWebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
3
4
|
export declare const ACP_TOOL_NAME_PREFIX = "mcp__acp__";
|
|
4
5
|
export declare const acpToolNames: {
|
|
5
6
|
read: string;
|
|
@@ -10,7 +11,6 @@ export declare const acpToolNames: {
|
|
|
10
11
|
bashOutput: string;
|
|
11
12
|
};
|
|
12
13
|
export declare const EDIT_TOOL_NAMES: string[];
|
|
13
|
-
import { BetaBashCodeExecutionToolResultBlockParam, BetaCodeExecutionToolResultBlockParam, BetaRequestMCPToolResultBlockParam, BetaTextEditorCodeExecutionToolResultBlockParam, BetaToolSearchToolResultBlockParam, BetaWebFetchToolResultBlockParam, BetaWebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
14
14
|
import { HookCallback } from "@anthropic-ai/claude-agent-sdk";
|
|
15
15
|
import { Logger } from "./acp-agent.js";
|
|
16
16
|
import { SettingsManager } from "./settings.js";
|
|
@@ -26,7 +26,7 @@ interface ToolUpdate {
|
|
|
26
26
|
locations?: ToolCallLocation[];
|
|
27
27
|
}
|
|
28
28
|
export declare function toolInfoFromToolUse(toolUse: any): ToolInfo;
|
|
29
|
-
export declare function toolUpdateFromToolResult(toolResult: ToolResultBlockParam | BetaWebSearchToolResultBlockParam | BetaWebFetchToolResultBlockParam | WebSearchToolResultBlockParam | BetaCodeExecutionToolResultBlockParam | BetaBashCodeExecutionToolResultBlockParam | BetaTextEditorCodeExecutionToolResultBlockParam | BetaRequestMCPToolResultBlockParam | BetaToolSearchToolResultBlockParam, toolUse: any | undefined): ToolUpdate;
|
|
29
|
+
export declare function toolUpdateFromToolResult(toolResult: ToolResultBlockParam | BetaToolResultBlockParam | BetaWebSearchToolResultBlockParam | BetaWebFetchToolResultBlockParam | WebSearchToolResultBlockParam | BetaCodeExecutionToolResultBlockParam | BetaBashCodeExecutionToolResultBlockParam | BetaTextEditorCodeExecutionToolResultBlockParam | BetaRequestMCPToolResultBlockParam | BetaToolSearchToolResultBlockParam, toolUse: any | undefined): ToolUpdate;
|
|
30
30
|
export type ClaudePlanEntry = {
|
|
31
31
|
content: string;
|
|
32
32
|
status: "pending" | "in_progress" | "completed";
|
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,
|
|
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;AAGlC,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,yCAAyC,EAGzC,qCAAqC,EAGrC,kCAAkC,EAClC,+CAA+C,EAK/C,wBAAwB,EACxB,kCAAkC,EAIlC,gCAAgC,EAGhC,iCAAiC,EAElC,MAAM,sCAAsC,CAAC;AAW9C,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,YAAY;;;;;;;CAOxB,CAAC;AAEF,eAAO,MAAM,eAAe,UAA0C,CAAC;AAyBvE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,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;A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) {
|
|
|
448
448
|
function toAcpContentUpdate(content, isError = false) {
|
|
449
449
|
if (Array.isArray(content) && content.length > 0) {
|
|
450
450
|
return {
|
|
451
|
-
content: content.map((
|
|
451
|
+
content: content.map((c) => ({
|
|
452
452
|
type: "content",
|
|
453
|
-
content: isError
|
|
454
|
-
? {
|
|
455
|
-
...content,
|
|
456
|
-
text: `\`\`\`\n${content.text}\n\`\`\``,
|
|
457
|
-
}
|
|
458
|
-
: content,
|
|
453
|
+
content: toAcpContentBlock(c, isError),
|
|
459
454
|
})),
|
|
460
455
|
};
|
|
461
456
|
}
|
|
457
|
+
else if (typeof content === "object" && content !== null && "type" in content) {
|
|
458
|
+
return {
|
|
459
|
+
content: [
|
|
460
|
+
{
|
|
461
|
+
type: "content",
|
|
462
|
+
content: toAcpContentBlock(content, isError),
|
|
463
|
+
},
|
|
464
|
+
],
|
|
465
|
+
};
|
|
466
|
+
}
|
|
462
467
|
else if (typeof content === "string" && content.length > 0) {
|
|
463
468
|
return {
|
|
464
469
|
content: [
|
|
@@ -474,6 +479,62 @@ function toAcpContentUpdate(content, isError = false) {
|
|
|
474
479
|
}
|
|
475
480
|
return {};
|
|
476
481
|
}
|
|
482
|
+
function toAcpContentBlock(content, isError) {
|
|
483
|
+
const wrapText = (text) => ({
|
|
484
|
+
type: "text",
|
|
485
|
+
text: isError ? `\`\`\`\n${text}\n\`\`\`` : text,
|
|
486
|
+
});
|
|
487
|
+
switch (content.type) {
|
|
488
|
+
case "text":
|
|
489
|
+
return {
|
|
490
|
+
type: "text",
|
|
491
|
+
text: isError ? `\`\`\`\n${content.text}\n\`\`\`` : content.text,
|
|
492
|
+
};
|
|
493
|
+
case "image":
|
|
494
|
+
if (content.source.type === "base64") {
|
|
495
|
+
return {
|
|
496
|
+
type: "image",
|
|
497
|
+
data: content.source.data,
|
|
498
|
+
mimeType: content.source.media_type,
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
// URL and file-based images can't be converted to ACP format (requires data)
|
|
502
|
+
return wrapText(content.source.type === "url"
|
|
503
|
+
? `[image: ${content.source.url}]`
|
|
504
|
+
: "[image: file reference]");
|
|
505
|
+
case "tool_reference":
|
|
506
|
+
return wrapText(`Tool: ${content.tool_name}`);
|
|
507
|
+
case "tool_search_tool_search_result":
|
|
508
|
+
return wrapText(`Tools found: ${content.tool_references.map((r) => r.tool_name).join(", ") || "none"}`);
|
|
509
|
+
case "tool_search_tool_result_error":
|
|
510
|
+
return wrapText(`Error: ${content.error_code}${content.error_message ? ` - ${content.error_message}` : ""}`);
|
|
511
|
+
case "web_search_result":
|
|
512
|
+
return wrapText(`${content.title} (${content.url})`);
|
|
513
|
+
case "web_search_tool_result_error":
|
|
514
|
+
return wrapText(`Error: ${content.error_code}`);
|
|
515
|
+
case "web_fetch_result":
|
|
516
|
+
return wrapText(`Fetched: ${content.url}`);
|
|
517
|
+
case "web_fetch_tool_result_error":
|
|
518
|
+
return wrapText(`Error: ${content.error_code}`);
|
|
519
|
+
case "code_execution_result":
|
|
520
|
+
return wrapText(`Output: ${content.stdout || content.stderr || ""}`);
|
|
521
|
+
case "bash_code_execution_result":
|
|
522
|
+
return wrapText(`Output: ${content.stdout || content.stderr || ""}`);
|
|
523
|
+
case "code_execution_tool_result_error":
|
|
524
|
+
case "bash_code_execution_tool_result_error":
|
|
525
|
+
return wrapText(`Error: ${content.error_code}`);
|
|
526
|
+
case "text_editor_code_execution_view_result":
|
|
527
|
+
return wrapText(content.content);
|
|
528
|
+
case "text_editor_code_execution_create_result":
|
|
529
|
+
return wrapText(content.is_file_update ? "File updated" : "File created");
|
|
530
|
+
case "text_editor_code_execution_str_replace_result":
|
|
531
|
+
return wrapText(content.lines?.join("\n") || "");
|
|
532
|
+
case "text_editor_code_execution_tool_result_error":
|
|
533
|
+
return wrapText(`Error: ${content.error_code}${content.error_message ? ` - ${content.error_message}` : ""}`);
|
|
534
|
+
default:
|
|
535
|
+
return wrapText(JSON.stringify(content));
|
|
536
|
+
}
|
|
537
|
+
}
|
|
477
538
|
export function planEntries(input) {
|
|
478
539
|
return input.todos.map((input) => ({
|
|
479
540
|
content: input.content,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.13.
|
|
6
|
+
"version": "0.13.8",
|
|
7
7
|
"description": "An ACP-compatible coding agent powered by the Claude Code SDK (TypeScript)",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"format": "prettier --write .",
|
|
35
35
|
"format:check": "prettier --check .",
|
|
36
36
|
"check": "npm run lint && npm run format:check",
|
|
37
|
-
"sync-upstream": "git merge upstream/main",
|
|
37
|
+
"sync-upstream": "git fetch upstream && git merge upstream/main",
|
|
38
38
|
"test": "vitest",
|
|
39
39
|
"test:integration": "RUN_INTEGRATION_TESTS=true vitest run",
|
|
40
40
|
"test:run": "vitest run",
|
|
@@ -66,23 +66,23 @@
|
|
|
66
66
|
"author": "Sudocode AI",
|
|
67
67
|
"license": "Apache-2.0",
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@agentclientprotocol/sdk": "0.13.
|
|
70
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
71
|
-
"@modelcontextprotocol/sdk": "1.25.
|
|
69
|
+
"@agentclientprotocol/sdk": "0.13.1",
|
|
70
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.22",
|
|
71
|
+
"@modelcontextprotocol/sdk": "1.25.3",
|
|
72
72
|
"diff": "8.0.3",
|
|
73
73
|
"minimatch": "10.1.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@anthropic-ai/sdk": "0.71.2",
|
|
77
|
-
"@types/node": "25.0.
|
|
78
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
79
|
-
"@typescript-eslint/parser": "8.
|
|
77
|
+
"@types/node": "25.0.10",
|
|
78
|
+
"@typescript-eslint/eslint-plugin": "8.54.0",
|
|
79
|
+
"@typescript-eslint/parser": "8.54.0",
|
|
80
80
|
"eslint": "9.39.2",
|
|
81
81
|
"eslint-config-prettier": "10.1.8",
|
|
82
|
-
"globals": "17.
|
|
83
|
-
"prettier": "3.8.
|
|
82
|
+
"globals": "17.2.0",
|
|
83
|
+
"prettier": "3.8.1",
|
|
84
84
|
"ts-node": "10.9.2",
|
|
85
85
|
"typescript": "5.9.3",
|
|
86
|
-
"vitest": "4.0.
|
|
86
|
+
"vitest": "4.0.18"
|
|
87
87
|
}
|
|
88
88
|
}
|