MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / buildToolCallFrames

Function buildToolCallFrames

apps/vscode-e2e/src/bedrock-mock-server.ts:62–89  ·  view source on GitHub ↗
(toolName: string, toolUseId: string, argsJson: string)

Source from the content-addressed store, hash-verified

60}
61
62function buildToolCallFrames(toolName: string, toolUseId: string, argsJson: string): Buffer[] {
63 const frames: Buffer[] = []
64 frames.push(encodeFrame("messageStart", { role: "assistant" }))
65 frames.push(
66 encodeFrame("contentBlockStart", {
67 contentBlockIndex: 0,
68 start: { toolUse: { name: toolName, toolUseId } },
69 }),
70 )
71 const CHUNK = 20
72 for (let i = 0; i < argsJson.length; i += CHUNK) {
73 frames.push(
74 encodeFrame("contentBlockDelta", {
75 contentBlockIndex: 0,
76 delta: { toolUse: { input: argsJson.slice(i, i + CHUNK) } },
77 }),
78 )
79 }
80 frames.push(encodeFrame("contentBlockStop", { contentBlockIndex: 0 }))
81 frames.push(encodeFrame("messageStop", { stopReason: "tool_use" }))
82 frames.push(
83 encodeFrame("metadata", {
84 metrics: { latencyMs: 1 },
85 usage: { inputTokens: 100, outputTokens: 10, totalTokens: 110, serverToolUsage: {} },
86 }),
87 )
88 return frames
89}
90
91export async function startBedrockMockServer(): Promise<BedrockMockServer> {
92 // HTTP/2 cleartext (h2c) — matches what @aws-sdk/client-bedrock-runtime uses by default.

Callers 1

startBedrockMockServerFunction · 0.85

Calls 1

encodeFrameFunction · 0.85

Tested by

no test coverage detected