Download src/node-host/invoke-mcp-result.test.ts from SaylorTwift/openclaw: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/node-host/invoke-mcp-result.test.ts
- Command line
-
hf download hf://SaylorTwift/openclaw/src/node-host/invoke-mcp-result.test.ts
-
curl -L -o invoke-mcp-result.test.ts https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/node-host/invoke-mcp-result.test.ts
1.16 kB
| import { execFile } from "node:child_process"; | |
| import { promisify } from "node:util"; | |
| import { describe, expect, it } from "vitest"; | |
| const execFileAsync = promisify(execFile); | |
| describe("boundMcpToolResultPayload", () => { | |
| it("bounds a resident 64 MiB audio result without full serialization", async () => { | |
| const source = String.raw` | |
| import { boundMcpToolResultPayload } from ${JSON.stringify(new URL("./invoke-mcp-result.ts", import.meta.url).href)}; | |
| const payload = boundMcpToolResultPayload({ | |
| content: [{ type: "audio", data: "A".repeat(64 * 1024 * 1024), mimeType: "audio/wav" }], | |
| }); | |
| process.stdout.write(JSON.stringify(payload)); | |
| `; | |
| const { stdout } = await execFileAsync( | |
| process.execPath, | |
| ["--max-old-space-size=192", "--import", "tsx", "--input-type=module", "-e", source], | |
| { cwd: process.cwd(), encoding: "utf8", maxBuffer: 1024 * 1024 }, | |
| ); | |
| const payload = JSON.parse(stdout) as { | |
| content: Array<{ type: string; text?: string }>; | |
| }; | |
| expect(payload.content).toEqual([ | |
| { type: "text", text: "[truncated: MCP result exceeded 20 MB]" }, | |
| ]); | |
| }); | |
| }); | |