- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/test/small-frame-json.test.ts?format=json
21 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 163, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { smallFrameJson } from "../src/small-frame-json.ts";
5test("small frame decoding enforces a byte bound and streamed parser rules", () => {
6 assert.deepEqual(smallFrameJson(['{"type":"jo', 'in","agent":"alice"}']), { type: "join", agent: "alice" });
7 assert.deepEqual(smallFrameJson(['{"x":1,"x":2}']), { x: 2 });
8 assert.throws(() => smallFrameJson(['"' + "\u00e9".repeat(2048) + '"']), /exceeds bound/);
9 assert.throws(() => smallFrameJson(["[".repeat(130) + "0" + "]".repeat(130)]), /nesting/);
10 assert.throws(() => smallFrameJson(["1" + "0".repeat(256)]), /scalar/);
11 assert.throws(() => smallFrameJson(["{} trailing"]), /trailing/);
12});
13test("small frame byte accounting handles a split surrogate pair at the limit", () => {
14 const pair = String.fromCodePoint(0x1f600);
15 const body = "x".repeat(4090) + pair;
16 const json = JSON.stringify(body);
17 assert.equal(new TextEncoder().encode(json).byteLength, 4096);
18 const split = json.indexOf(pair) + 1;
19 assert.equal(smallFrameJson([json.slice(0, split), json.slice(split)]), body);
20 assert.throws(() => smallFrameJson([JSON.stringify(body + "x")]), /exceeds bound/);
21});