MCPcopy Create free account
hub / github.com/agegr/pi-web / normalizeToolCallBlock

Function normalizeToolCallBlock

lib/normalize.ts:7–19  ·  view source on GitHub ↗
(block: unknown)

Source from the content-addressed store, hash-verified

5}
6
7function normalizeToolCallBlock(block: unknown): ToolCallContent | null {
8 if (!isObject(block) || block.type !== "toolCall") return null;
9 return {
10 type: "toolCall",
11 toolCallId: typeof block.toolCallId === "string" ? block.toolCallId : (typeof block.id === "string" ? block.id : ""),
12 toolName: typeof block.toolName === "string" ? block.toolName : (typeof block.name === "string" ? block.name : ""),
13 input: typeof block.input === "object" && block.input !== null && !Array.isArray(block.input)
14 ? block.input as Record<string, unknown>
15 : (typeof block.arguments === "object" && block.arguments !== null && !Array.isArray(block.arguments)
16 ? block.arguments as Record<string, unknown>
17 : {}),
18 };
19}
20
21export function normalizeToolCalls(msg: AgentMessage): AgentMessage {
22 // Non-assistant roles (user, toolResult, bashExecution, custom) are returned

Callers 1

normalizeToolCallsFunction · 0.85

Calls 1

isObjectFunction · 0.85

Tested by

no test coverage detected