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

Function encodeFrame

apps/vscode-e2e/src/bedrock-mock-server.ts:38–60  ·  view source on GitHub ↗
(eventType: string, payload: object)

Source from the content-addressed store, hash-verified

36}
37
38function encodeFrame(eventType: string, payload: object): Buffer {
39 const hdrs = encodeHeaders({
40 ":content-type": "application/json",
41 ":event-type": eventType,
42 ":message-type": "event",
43 })
44 const body = Buffer.from(JSON.stringify(payload), "utf8")
45 const total = 12 + hdrs.length + body.length + 4
46 const frame = Buffer.alloc(total)
47 let off = 0
48 frame.writeUInt32BE(total, off)
49 off += 4
50 frame.writeUInt32BE(hdrs.length, off)
51 off += 4
52 frame.writeUInt32BE(crc32(frame.subarray(0, 8)) >>> 0, off)
53 off += 4
54 hdrs.copy(frame, off)
55 off += hdrs.length
56 body.copy(frame, off)
57 off += body.length
58 frame.writeUInt32BE(crc32(frame.subarray(0, total - 4)) >>> 0, off)
59 return frame
60}
61
62function buildToolCallFrames(toolName: string, toolUseId: string, argsJson: string): Buffer[] {
63 const frames: Buffer[] = []

Callers 1

buildToolCallFramesFunction · 0.85

Calls 2

encodeHeadersFunction · 0.85
fromMethod · 0.80

Tested by

no test coverage detected