Skip to content

Commit 717edda

Browse files
Aleksandr Slapoguzovslapoguzov
authored andcommitted
LLM-25226 extract common code
1 parent 7df94bc commit 717edda

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/CodexToolCallMapper.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
PatchApplyStatus,
1818
ThreadItem,
1919
} from "./app-server/v2";
20+
import type { JsonValue } from "./app-server/serde_json/JsonValue";
2021

2122
type CodexItemStatus = CommandExecutionStatus | PatchApplyStatus | McpToolCallStatus | DynamicToolCallStatus;
2223
type AcpToolCallStatus = "pending" | "in_progress" | "completed" | "failed";
@@ -83,27 +84,26 @@ export async function createCommandExecutionUpdate(
8384
export async function createMcpToolCallUpdate(
8485
item: ThreadItem & { type: "mcpToolCall" }
8586
): Promise<UpdateSessionEvent> {
86-
return {
87-
sessionUpdate: "tool_call",
88-
toolCallId: item.id,
89-
kind: "execute",
90-
title: `mcp.${item.server}.${item.tool}`,
91-
status: toAcpStatus(item.status),
92-
};
87+
return createExecuteToolCallUpdate(item, `mcp.${item.server}.${item.tool}`);
9388
}
94-
9589
export async function createDynamicToolCallUpdate(
9690
item: ThreadItem & { type: "dynamicToolCall" }
91+
): Promise<UpdateSessionEvent> {
92+
return createExecuteToolCallUpdate(item, item.tool, { arguments: item.arguments })
93+
}
94+
95+
export async function createExecuteToolCallUpdate(
96+
item: ThreadItem & ({ type: "mcpToolCall" } | { type: "dynamicToolCall" }),
97+
title: string,
98+
rawInput?: { arguments: JsonValue }
9799
): Promise<UpdateSessionEvent> {
98100
return {
99101
sessionUpdate: "tool_call",
100102
toolCallId: item.id,
101103
kind: "execute",
102-
title: item.tool,
104+
title: title,
103105
status: toAcpStatus(item.status),
104-
rawInput: {
105-
arguments: item.arguments,
106-
},
106+
rawInput: rawInput,
107107
};
108108
}
109109

0 commit comments

Comments
 (0)