@finityno/claude-code-acp 0.13.5 → 0.13.7
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 +3 -1
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +29 -15
- package/dist/lib.d.ts +1 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +1 -1
- package/dist/tools.d.ts +10 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +115 -67
- package/package.json +1 -1
package/dist/acp-agent.d.ts
CHANGED
|
@@ -99,7 +99,9 @@ export declare function promptToClaude(prompt: PromptRequest): SDKUserMessage;
|
|
|
99
99
|
* Convert an SDKAssistantMessage (Claude) to a SessionNotification (ACP).
|
|
100
100
|
* Only handles text, image, and thinking chunks for now.
|
|
101
101
|
*/
|
|
102
|
-
export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger, subagentTracker?: SubagentTracker
|
|
102
|
+
export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger, subagentTracker?: SubagentTracker,
|
|
103
|
+
/** The parent tool use ID from the SDK message - indicates which subagent context this is from */
|
|
104
|
+
sdkParentToolUseId?: string | null): SessionNotification[];
|
|
103
105
|
export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger, subagentTracker?: SubagentTracker): SessionNotification[];
|
|
104
106
|
export declare function runAcp(): void;
|
|
105
107
|
export {};
|
package/dist/acp-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.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O,CAAC,oBAAoB,CAAC;IAKxE,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKjF,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;YAgI3B,aAAa;CA8P5B;AAwED,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc,CA6EpE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,gBAAgB,EAAE,GAAG,wBAAwB,EAAE,EACvF,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,eAAe;AACjC,kGAAkG;AAClG,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GACjC,mBAAmB,EAAE,CAiRvB;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,eAAe,GAChC,mBAAmB,EAAE,CAuCvB;AAED,wBAAgB,MAAM,SAMrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -205,7 +205,9 @@ export class ClaudeAcpAgent {
|
|
|
205
205
|
? // Handled by stream events above
|
|
206
206
|
message.message.content.filter((item) => !["text", "thinking"].includes(item.type))
|
|
207
207
|
: message.message.content;
|
|
208
|
-
|
|
208
|
+
// Pass through the SDK-provided parent_tool_use_id which identifies the subagent context
|
|
209
|
+
const sdkParentToolUseId = message.parent_tool_use_id;
|
|
210
|
+
for (const notification of toAcpNotifications(content, message.message.role, params.sessionId, this.toolUseCache, this.client, this.logger, this.subagentTracker, sdkParentToolUseId)) {
|
|
209
211
|
await this.client.sessionUpdate(notification);
|
|
210
212
|
}
|
|
211
213
|
break;
|
|
@@ -746,7 +748,9 @@ export function promptToClaude(prompt) {
|
|
|
746
748
|
* Convert an SDKAssistantMessage (Claude) to a SessionNotification (ACP).
|
|
747
749
|
* Only handles text, image, and thinking chunks for now.
|
|
748
750
|
*/
|
|
749
|
-
export function toAcpNotifications(content, role, sessionId, toolUseCache, client, logger, subagentTracker
|
|
751
|
+
export function toAcpNotifications(content, role, sessionId, toolUseCache, client, logger, subagentTracker,
|
|
752
|
+
/** The parent tool use ID from the SDK message - indicates which subagent context this is from */
|
|
753
|
+
sdkParentToolUseId) {
|
|
750
754
|
if (typeof content === "string") {
|
|
751
755
|
return [
|
|
752
756
|
{
|
|
@@ -812,8 +816,10 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
812
816
|
}
|
|
813
817
|
else if (chunk.name === "Task" && subagentTracker && isTaskToolInput(chunk.input)) {
|
|
814
818
|
// Track Task tool as subagent
|
|
819
|
+
// Pass the SDK-provided parent_tool_use_id for proper nesting of subagents
|
|
815
820
|
const input = chunk.input;
|
|
816
|
-
|
|
821
|
+
const parentSubagentId = sdkParentToolUseId ?? undefined;
|
|
822
|
+
subagentTracker.trackSubagent(chunk.id, sessionId, input, parentSubagentId);
|
|
817
823
|
// Register hook callback for subagent completion
|
|
818
824
|
registerHookCallback(chunk.id, {
|
|
819
825
|
onPostToolUseHook: async (toolUseId, toolInput, toolResponse) => {
|
|
@@ -866,10 +872,13 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
866
872
|
// ignore if we can't turn it to JSON
|
|
867
873
|
}
|
|
868
874
|
// Send tool_call notification with subagent metadata
|
|
875
|
+
// Include parentToolUseId for nested subagents (Task called from within another Task)
|
|
869
876
|
update = {
|
|
870
877
|
_meta: {
|
|
871
878
|
claudeCode: {
|
|
872
879
|
toolName: chunk.name,
|
|
880
|
+
// For nested subagents, include parent reference
|
|
881
|
+
...(parentSubagentId && { parentToolUseId: parentSubagentId }),
|
|
873
882
|
subagent: {
|
|
874
883
|
id: chunk.id,
|
|
875
884
|
eventType: "subagent_started",
|
|
@@ -877,6 +886,8 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
877
886
|
description: input.description,
|
|
878
887
|
status: "running",
|
|
879
888
|
parentSessionId: sessionId,
|
|
889
|
+
// Include parent for nested subagents
|
|
890
|
+
...(parentSubagentId && { parentToolUseId: parentSubagentId }),
|
|
880
891
|
model: input.model,
|
|
881
892
|
runInBackground: input.run_in_background ?? false,
|
|
882
893
|
},
|
|
@@ -890,9 +901,11 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
890
901
|
};
|
|
891
902
|
}
|
|
892
903
|
else {
|
|
893
|
-
//
|
|
894
|
-
|
|
895
|
-
|
|
904
|
+
// Use the SDK-provided parent tool use ID which correctly identifies
|
|
905
|
+
// which subagent context this tool call is from.
|
|
906
|
+
// Task tools are subagents themselves, not children of other subagents.
|
|
907
|
+
const isTaskTool = chunk.name === "Task";
|
|
908
|
+
const parentToolUseId = isTaskTool ? undefined : (sdkParentToolUseId ?? undefined);
|
|
896
909
|
// Register hook callback to receive the structured output from the hook
|
|
897
910
|
registerHookCallback(chunk.id, {
|
|
898
911
|
onPostToolUseHook: async (toolUseId, toolInput, toolResponse) => {
|
|
@@ -903,7 +916,7 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
903
916
|
claudeCode: {
|
|
904
917
|
toolResponse,
|
|
905
918
|
toolName: toolUse.name,
|
|
906
|
-
...(
|
|
919
|
+
...(parentToolUseId && { parentToolUseId }),
|
|
907
920
|
},
|
|
908
921
|
},
|
|
909
922
|
toolCallId: toolUseId,
|
|
@@ -926,9 +939,6 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
926
939
|
catch {
|
|
927
940
|
// ignore if we can't turn it to JSON
|
|
928
941
|
}
|
|
929
|
-
// Check if there's an active subagent that owns this tool call
|
|
930
|
-
const activeSubagent = subagentTracker?.getActiveSubagent(sessionId);
|
|
931
|
-
const parentToolUseId = activeSubagent?.id;
|
|
932
942
|
update = {
|
|
933
943
|
_meta: {
|
|
934
944
|
claudeCode: {
|
|
@@ -959,9 +969,11 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
959
969
|
break;
|
|
960
970
|
}
|
|
961
971
|
if (toolUse.name !== "TodoWrite") {
|
|
962
|
-
//
|
|
963
|
-
|
|
964
|
-
|
|
972
|
+
// Use the SDK-provided parent tool use ID which correctly identifies
|
|
973
|
+
// which subagent context this tool result is from.
|
|
974
|
+
// Task tools are subagents themselves, not children of other subagents.
|
|
975
|
+
const isTaskTool = toolUse.name === "Task";
|
|
976
|
+
const parentToolUseId = isTaskTool ? undefined : (sdkParentToolUseId ?? undefined);
|
|
965
977
|
update = {
|
|
966
978
|
_meta: {
|
|
967
979
|
claudeCode: {
|
|
@@ -997,11 +1009,13 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
997
1009
|
}
|
|
998
1010
|
export function streamEventToAcpNotifications(message, sessionId, toolUseCache, client, logger, subagentTracker) {
|
|
999
1011
|
const event = message.event;
|
|
1012
|
+
// Pass through the SDK-provided parent_tool_use_id which identifies the subagent context
|
|
1013
|
+
const sdkParentToolUseId = message.parent_tool_use_id;
|
|
1000
1014
|
switch (event.type) {
|
|
1001
1015
|
case "content_block_start":
|
|
1002
|
-
return toAcpNotifications([event.content_block], "assistant", sessionId, toolUseCache, client, logger, subagentTracker);
|
|
1016
|
+
return toAcpNotifications([event.content_block], "assistant", sessionId, toolUseCache, client, logger, subagentTracker, sdkParentToolUseId);
|
|
1003
1017
|
case "content_block_delta":
|
|
1004
|
-
return toAcpNotifications([event.delta], "assistant", sessionId, toolUseCache, client, logger, subagentTracker);
|
|
1018
|
+
return toAcpNotifications([event.delta], "assistant", sessionId, toolUseCache, client, logger, subagentTracker, sdkParentToolUseId);
|
|
1005
1019
|
// No content
|
|
1006
1020
|
case "message_start":
|
|
1007
1021
|
case "message_delta":
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, type ToolUpdateMeta, type NewSessionMeta, } from "./acp-agent.js";
|
|
2
2
|
export { loadManagedSettings, applyEnvironmentSettings, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js";
|
|
3
3
|
export { createMcpServer } from "./mcp-server.js";
|
|
4
|
-
export { toolInfoFromToolUse, planEntries, toolUpdateFromToolResult, createPreToolUseHook, acpToolNames as toolNames, } from "./tools.js";
|
|
4
|
+
export { toolInfoFromToolUse, planEntries, toolUpdateFromToolResult, createPreToolUseHook, acpToolNames as toolNames, normalizeToolName, getCanonicalToolName, } from "./tools.js";
|
|
5
5
|
export { SettingsManager, type ClaudeCodeSettings, type PermissionSettings, type PermissionDecision, type PermissionCheckResult, type SettingsManagerOptions, } from "./settings.js";
|
|
6
6
|
export { SubagentTracker, isTaskToolInput, extractSubagentMeta, type TrackedSubagent, type SubagentStatus, type SubagentType, type SubagentEventType, type SubagentUpdateMeta, type SubagentEventListener, type SubagentStats, type TaskToolInput, } from "./subagent-tracker.js";
|
|
7
7
|
export type { ClaudePlanEntry } from "./tools.js";
|
package/dist/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,IAAI,SAAS,EACzB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/lib.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, } from "./acp-agent.js";
|
|
3
3
|
export { loadManagedSettings, applyEnvironmentSettings, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js";
|
|
4
4
|
export { createMcpServer } from "./mcp-server.js";
|
|
5
|
-
export { toolInfoFromToolUse, planEntries, toolUpdateFromToolResult, createPreToolUseHook, acpToolNames as toolNames, } from "./tools.js";
|
|
5
|
+
export { toolInfoFromToolUse, planEntries, toolUpdateFromToolResult, createPreToolUseHook, acpToolNames as toolNames, normalizeToolName, getCanonicalToolName, } from "./tools.js";
|
|
6
6
|
export { SettingsManager, } from "./settings.js";
|
|
7
7
|
// Export subagent tracking
|
|
8
8
|
export { SubagentTracker, isTaskToolInput, extractSubagentMeta, } from "./subagent-tracker.js";
|
package/dist/tools.d.ts
CHANGED
|
@@ -25,6 +25,16 @@ interface ToolUpdate {
|
|
|
25
25
|
content?: ToolCallContent[];
|
|
26
26
|
locations?: ToolCallLocation[];
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Normalize a tool name by stripping MCP prefixes.
|
|
30
|
+
* e.g., "mcp__acp__Read" -> "Read", "mcp__context7__query-docs" -> "query-docs"
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeToolName(name: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the canonical tool name for categorization purposes.
|
|
35
|
+
* This maps tool names to their canonical form for icon/kind matching.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCanonicalToolName(name: string): string;
|
|
28
38
|
export declare function toolInfoFromToolUse(toolUse: any): ToolInfo;
|
|
29
39
|
export declare function toolUpdateFromToolResult(toolResult: ToolResultBlockParam | BetaWebSearchToolResultBlockParam | BetaWebFetchToolResultBlockParam | WebSearchToolResultBlockParam | BetaCodeExecutionToolResultBlockParam | BetaBashCodeExecutionToolResultBlockParam | BetaTextEditorCodeExecutionToolResultBlockParam | BetaRequestMCPToolResultBlockParam | BetaToolSearchToolResultBlockParam, toolUse: any | undefined): ToolUpdate;
|
|
30
40
|
export type ClaudePlanEntry = {
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","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AAS,GAAG,aAAa,GAAG,WAAW,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,eAAe,EAAE,CAAA;CAAE,GAAG,SAAS,EAAE,CAM5E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAcD,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,EACjB,wBAEG;IACD,iBAAiB,CAAC,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,SAKF,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAC/B,SAAQ,MAAgB,KAAG,YAa3B,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC9B,iBAAiB,eAAe,EAAE,SAAQ,MAAgB,KAAG,YA2C7D,CAAC"}
|
package/dist/tools.js
CHANGED
|
@@ -18,9 +18,59 @@ export const acpToolNames = {
|
|
|
18
18
|
bashOutput: ACP_TOOL_NAME_PREFIX + acpUnqualifiedToolNames.bashOutput,
|
|
19
19
|
};
|
|
20
20
|
export const EDIT_TOOL_NAMES = [acpToolNames.edit, acpToolNames.write];
|
|
21
|
+
/**
|
|
22
|
+
* Normalize a tool name by stripping MCP prefixes.
|
|
23
|
+
* e.g., "mcp__acp__Read" -> "Read", "mcp__context7__query-docs" -> "query-docs"
|
|
24
|
+
*/
|
|
25
|
+
export function normalizeToolName(name) {
|
|
26
|
+
// Strip mcp__<server>__ prefix
|
|
27
|
+
const mcpMatch = name.match(/^mcp__[^_]+__(.+)$/);
|
|
28
|
+
if (mcpMatch) {
|
|
29
|
+
return mcpMatch[1];
|
|
30
|
+
}
|
|
31
|
+
return name;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the canonical tool name for categorization purposes.
|
|
35
|
+
* This maps tool names to their canonical form for icon/kind matching.
|
|
36
|
+
*/
|
|
37
|
+
export function getCanonicalToolName(name) {
|
|
38
|
+
const normalized = normalizeToolName(name);
|
|
39
|
+
// Map common variations to canonical names
|
|
40
|
+
const canonicalMap = {
|
|
41
|
+
// ACP tools
|
|
42
|
+
"Read": "Read",
|
|
43
|
+
"Edit": "Edit",
|
|
44
|
+
"Write": "Write",
|
|
45
|
+
"Bash": "Bash",
|
|
46
|
+
"BashOutput": "BashOutput",
|
|
47
|
+
"KillShell": "KillShell",
|
|
48
|
+
"TaskOutput": "TaskOutput",
|
|
49
|
+
// Search tools
|
|
50
|
+
"Glob": "Glob",
|
|
51
|
+
"Grep": "Grep",
|
|
52
|
+
"LS": "LS",
|
|
53
|
+
// Web tools
|
|
54
|
+
"WebFetch": "WebFetch",
|
|
55
|
+
"WebSearch": "WebSearch",
|
|
56
|
+
// Agent/planning tools
|
|
57
|
+
"Task": "Task",
|
|
58
|
+
"TodoWrite": "TodoWrite",
|
|
59
|
+
"ExitPlanMode": "ExitPlanMode",
|
|
60
|
+
"EnterPlanMode": "EnterPlanMode",
|
|
61
|
+
"AskUserQuestion": "AskUserQuestion",
|
|
62
|
+
"Skill": "Skill",
|
|
63
|
+
// Notebook tools
|
|
64
|
+
"NotebookRead": "NotebookRead",
|
|
65
|
+
"NotebookEdit": "NotebookEdit",
|
|
66
|
+
};
|
|
67
|
+
return canonicalMap[normalized] ?? normalized;
|
|
68
|
+
}
|
|
21
69
|
export function toolInfoFromToolUse(toolUse) {
|
|
22
|
-
const
|
|
70
|
+
const rawName = toolUse.name;
|
|
23
71
|
const input = toolUse.input;
|
|
72
|
+
// Get canonical name for matching
|
|
73
|
+
const name = getCanonicalToolName(rawName);
|
|
24
74
|
switch (name) {
|
|
25
75
|
case "Task":
|
|
26
76
|
return {
|
|
@@ -57,7 +107,6 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
57
107
|
locations: input?.notebook_path ? [{ path: input.notebook_path }] : [],
|
|
58
108
|
};
|
|
59
109
|
case "Bash":
|
|
60
|
-
case acpToolNames.bash:
|
|
61
110
|
return {
|
|
62
111
|
title: input?.command ? "`" + input.command.replaceAll("`", "\\`") + "`" : "Terminal",
|
|
63
112
|
kind: "execute",
|
|
@@ -71,32 +120,36 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
71
120
|
: [],
|
|
72
121
|
};
|
|
73
122
|
case "BashOutput":
|
|
74
|
-
case acpToolNames.bashOutput:
|
|
75
123
|
return {
|
|
76
124
|
title: "Tail Logs",
|
|
77
125
|
kind: "execute",
|
|
78
126
|
content: [],
|
|
79
127
|
};
|
|
80
128
|
case "KillShell":
|
|
81
|
-
case acpToolNames.killShell:
|
|
82
129
|
return {
|
|
83
130
|
title: "Kill Process",
|
|
84
131
|
kind: "execute",
|
|
85
132
|
content: [],
|
|
86
133
|
};
|
|
87
|
-
case
|
|
134
|
+
case "TaskOutput":
|
|
135
|
+
return {
|
|
136
|
+
title: input?.task_id ? `Task Output (${input.task_id})` : "Task Output",
|
|
137
|
+
kind: "read",
|
|
138
|
+
content: [],
|
|
139
|
+
};
|
|
140
|
+
case "Read": {
|
|
88
141
|
let limit = "";
|
|
89
|
-
if (input
|
|
142
|
+
if (input?.limit) {
|
|
90
143
|
limit =
|
|
91
144
|
" (" + ((input.offset ?? 0) + 1) + " - " + ((input.offset ?? 0) + input.limit) + ")";
|
|
92
145
|
}
|
|
93
|
-
else if (input
|
|
146
|
+
else if (input?.offset) {
|
|
94
147
|
limit = " (from line " + (input.offset + 1) + ")";
|
|
95
148
|
}
|
|
96
149
|
return {
|
|
97
|
-
title: "Read " + (input
|
|
150
|
+
title: "Read " + (input?.file_path ?? "File") + limit,
|
|
98
151
|
kind: "read",
|
|
99
|
-
locations: input
|
|
152
|
+
locations: input?.file_path
|
|
100
153
|
? [
|
|
101
154
|
{
|
|
102
155
|
path: input.file_path,
|
|
@@ -107,20 +160,6 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
107
160
|
content: [],
|
|
108
161
|
};
|
|
109
162
|
}
|
|
110
|
-
case "Read":
|
|
111
|
-
return {
|
|
112
|
-
title: "Read File",
|
|
113
|
-
kind: "read",
|
|
114
|
-
content: [],
|
|
115
|
-
locations: input.file_path
|
|
116
|
-
? [
|
|
117
|
-
{
|
|
118
|
-
path: input.file_path,
|
|
119
|
-
line: input.offset ?? 0,
|
|
120
|
-
},
|
|
121
|
-
]
|
|
122
|
-
: [],
|
|
123
|
-
};
|
|
124
163
|
case "LS":
|
|
125
164
|
return {
|
|
126
165
|
title: `List the ${input?.path ? "`" + input.path + "`" : "current"} directory's contents`,
|
|
@@ -128,9 +167,8 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
128
167
|
content: [],
|
|
129
168
|
locations: [],
|
|
130
169
|
};
|
|
131
|
-
case acpToolNames.edit:
|
|
132
170
|
case "Edit": {
|
|
133
|
-
const path = input?.file_path
|
|
171
|
+
const path = input?.file_path;
|
|
134
172
|
return {
|
|
135
173
|
title: path ? `Edit \`${path}\`` : "Edit",
|
|
136
174
|
kind: "edit",
|
|
@@ -147,7 +185,7 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
147
185
|
locations: path ? [{ path }] : undefined,
|
|
148
186
|
};
|
|
149
187
|
}
|
|
150
|
-
case
|
|
188
|
+
case "Write": {
|
|
151
189
|
let content = [];
|
|
152
190
|
if (input && input.file_path) {
|
|
153
191
|
content = [
|
|
@@ -174,22 +212,6 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
174
212
|
locations: input?.file_path ? [{ path: input.file_path }] : [],
|
|
175
213
|
};
|
|
176
214
|
}
|
|
177
|
-
case "Write":
|
|
178
|
-
return {
|
|
179
|
-
title: input?.file_path ? `Write ${input.file_path}` : "Write",
|
|
180
|
-
kind: "edit",
|
|
181
|
-
content: input && input.file_path
|
|
182
|
-
? [
|
|
183
|
-
{
|
|
184
|
-
type: "diff",
|
|
185
|
-
path: input.file_path,
|
|
186
|
-
oldText: null,
|
|
187
|
-
newText: input.content,
|
|
188
|
-
},
|
|
189
|
-
]
|
|
190
|
-
: [],
|
|
191
|
-
locations: input?.file_path ? [{ path: input.file_path }] : [],
|
|
192
|
-
};
|
|
193
215
|
case "Glob": {
|
|
194
216
|
let label = "Find";
|
|
195
217
|
if (input.path) {
|
|
@@ -302,6 +324,36 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
302
324
|
? [{ type: "content", content: { type: "text", text: input.plan } }]
|
|
303
325
|
: [],
|
|
304
326
|
};
|
|
327
|
+
case "AskUserQuestion":
|
|
328
|
+
return {
|
|
329
|
+
title: "Question",
|
|
330
|
+
kind: "think",
|
|
331
|
+
content: input?.questions
|
|
332
|
+
? [
|
|
333
|
+
{
|
|
334
|
+
type: "content",
|
|
335
|
+
content: {
|
|
336
|
+
type: "text",
|
|
337
|
+
text: Array.isArray(input.questions)
|
|
338
|
+
? input.questions.map((q) => q.question).join("\n")
|
|
339
|
+
: String(input.questions),
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
]
|
|
343
|
+
: [],
|
|
344
|
+
};
|
|
345
|
+
case "EnterPlanMode":
|
|
346
|
+
return {
|
|
347
|
+
title: "Enter Plan Mode",
|
|
348
|
+
kind: "switch_mode",
|
|
349
|
+
content: [],
|
|
350
|
+
};
|
|
351
|
+
case "Skill":
|
|
352
|
+
return {
|
|
353
|
+
title: input?.skill ? `/${input.skill}` : "Skill",
|
|
354
|
+
kind: "execute",
|
|
355
|
+
content: [],
|
|
356
|
+
};
|
|
305
357
|
case "Other": {
|
|
306
358
|
let output;
|
|
307
359
|
try {
|
|
@@ -311,7 +363,7 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
311
363
|
output = typeof input === "string" ? input : "{}";
|
|
312
364
|
}
|
|
313
365
|
return {
|
|
314
|
-
title:
|
|
366
|
+
title: rawName || "Unknown Tool",
|
|
315
367
|
kind: "other",
|
|
316
368
|
content: [
|
|
317
369
|
{
|
|
@@ -324,12 +376,23 @@ export function toolInfoFromToolUse(toolUse) {
|
|
|
324
376
|
],
|
|
325
377
|
};
|
|
326
378
|
}
|
|
327
|
-
default:
|
|
379
|
+
default: {
|
|
380
|
+
// For MCP tools from other servers, try to provide a reasonable title
|
|
381
|
+
const isMcpTool = rawName.startsWith("mcp__");
|
|
382
|
+
let title = rawName;
|
|
383
|
+
if (isMcpTool) {
|
|
384
|
+
// Extract server and tool name: mcp__server__toolName -> server: toolName
|
|
385
|
+
const parts = rawName.match(/^mcp__([^_]+)__(.+)$/);
|
|
386
|
+
if (parts) {
|
|
387
|
+
title = `${parts[1]}: ${parts[2]}`;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
328
390
|
return {
|
|
329
|
-
title:
|
|
330
|
-
kind: "other",
|
|
391
|
+
title: title || "Unknown Tool",
|
|
392
|
+
kind: isMcpTool ? "other" : "other",
|
|
331
393
|
content: [],
|
|
332
394
|
};
|
|
395
|
+
}
|
|
333
396
|
}
|
|
334
397
|
}
|
|
335
398
|
export function toolUpdateFromToolResult(toolResult, toolUse) {
|
|
@@ -340,9 +403,10 @@ export function toolUpdateFromToolResult(toolResult, toolUse) {
|
|
|
340
403
|
// Only return errors
|
|
341
404
|
return toAcpContentUpdate(toolResult.content, true);
|
|
342
405
|
}
|
|
343
|
-
|
|
406
|
+
// Use canonical name for matching
|
|
407
|
+
const canonicalName = toolUse?.name ? getCanonicalToolName(toolUse.name) : undefined;
|
|
408
|
+
switch (canonicalName) {
|
|
344
409
|
case "Read":
|
|
345
|
-
case acpToolNames.read:
|
|
346
410
|
if (Array.isArray(toolResult.content) && toolResult.content.length > 0) {
|
|
347
411
|
return {
|
|
348
412
|
content: toolResult.content.map((content) => ({
|
|
@@ -370,7 +434,7 @@ export function toolUpdateFromToolResult(toolResult, toolUse) {
|
|
|
370
434
|
};
|
|
371
435
|
}
|
|
372
436
|
return {};
|
|
373
|
-
case
|
|
437
|
+
case "Edit": {
|
|
374
438
|
const content = [];
|
|
375
439
|
const locations = [];
|
|
376
440
|
if (Array.isArray(toolResult.content) &&
|
|
@@ -416,30 +480,14 @@ export function toolUpdateFromToolResult(toolResult, toolUse) {
|
|
|
416
480
|
}
|
|
417
481
|
return result;
|
|
418
482
|
}
|
|
419
|
-
case
|
|
420
|
-
case "edit":
|
|
421
|
-
case "Edit":
|
|
422
|
-
case acpToolNames.write:
|
|
483
|
+
case "Bash":
|
|
423
484
|
case "Write": {
|
|
424
485
|
return {};
|
|
425
486
|
}
|
|
426
487
|
case "ExitPlanMode": {
|
|
427
488
|
return { title: "Exited Plan Mode" };
|
|
428
489
|
}
|
|
429
|
-
|
|
430
|
-
case "NotebookEdit":
|
|
431
|
-
case "NotebookRead":
|
|
432
|
-
case "TodoWrite":
|
|
433
|
-
case "exit_plan_mode":
|
|
434
|
-
case "Bash":
|
|
435
|
-
case "BashOutput":
|
|
436
|
-
case "KillBash":
|
|
437
|
-
case "LS":
|
|
438
|
-
case "Glob":
|
|
439
|
-
case "Grep":
|
|
440
|
-
case "WebFetch":
|
|
441
|
-
case "WebSearch":
|
|
442
|
-
case "Other":
|
|
490
|
+
// All other tools: return content as-is
|
|
443
491
|
default: {
|
|
444
492
|
return toAcpContentUpdate(toolResult.content, "is_error" in toolResult ? toolResult.is_error : false);
|
|
445
493
|
}
|
package/package.json
CHANGED