@poe-platform/safe-js 0.1.721 → 0.1.722
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -6
- package/dist/config-mutations/types.d.ts +3 -1
- package/dist/safe-js/chunks/{chunk-B4M6QVUV.js → chunk-3QQYJ4RQ.js} +3 -2
- package/dist/safe-js/chunks/chunk-3QQYJ4RQ.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-BHYBD6SY.js → chunk-55RIIUGG.js} +23 -7
- package/dist/safe-js/chunks/chunk-55RIIUGG.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-A4L72WXV.js → chunk-7SBQ7WTV.js} +10 -11
- package/dist/safe-js/chunks/chunk-7SBQ7WTV.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-DNA7BMBY.js → chunk-BNIEPGDU.js} +8520 -7312
- package/dist/safe-js/chunks/{chunk-DNA7BMBY.js.map → chunk-BNIEPGDU.js.map} +4 -4
- package/dist/safe-js/chunks/{chunk-HYD4K4HN.js → chunk-D3GC5QPZ.js} +63 -1
- package/dist/safe-js/chunks/chunk-D3GC5QPZ.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-Q7B6JIMI.js → chunk-EH5A2EQI.js} +404 -117
- package/dist/safe-js/chunks/chunk-EH5A2EQI.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-4CX3HYRY.js → chunk-FA5CQO6V.js} +2 -2
- package/dist/safe-js/chunks/{chunk-LPBTSTDG.js → chunk-GCOLKRMY.js} +4 -4
- package/dist/safe-js/chunks/{chunk-GMPZBMPA.js → chunk-K3ZRBAG5.js} +3 -3
- package/dist/safe-js/chunks/{chunk-JNLY7IMV.js → chunk-QL2ALAE6.js} +4 -4
- package/dist/safe-js/chunks/{chunk-ILYJBA2D.js → chunk-RYVHEOHM.js} +1109 -100
- package/dist/safe-js/chunks/chunk-RYVHEOHM.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-BEXRQET4.js → chunk-S2GFVXSI.js} +3 -3
- package/dist/safe-js/chunks/{chunk-Y4LNCDCP.js → chunk-WF7HYDJ4.js} +4 -5
- package/dist/safe-js/chunks/{chunk-Y4LNCDCP.js.map → chunk-WF7HYDJ4.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-IS7YUCOF.js → chunk-XHSOM5CG.js} +2 -2
- package/dist/safe-js/chunks/{cli-runtime-YK2WE33M.js → cli-runtime-6QPGM3TX.js} +14 -14
- package/dist/safe-js/chunks/{dump-ATWBOZWV.js → dump-TU6SYRFD.js} +4 -4
- package/dist/safe-js/chunks/{fs-D72Y52I5.js → fs-HTZT32MQ.js} +4 -4
- package/dist/safe-js/chunks/harness-RYAMI444.js +10 -0
- package/dist/safe-js/chunks/mcp-DO2IRFGQ.js +11 -0
- package/dist/safe-js/chunks/migration-file-K7UH5ZG6.js +12 -0
- package/dist/safe-js/chunks/restore-7LRP4BM3.js +13 -0
- package/dist/safe-js/chunks/run-6SETM7SV.js +17 -0
- package/dist/safe-js/chunks/runtime-modules-MCQS2SHQ.js +10 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +7 -7
- package/dist/safe-js/index.js +14 -14
- package/dist/safe-js/interp/async.d.ts +4 -1
- package/dist/safe-js/interp/budget.d.ts +12 -6
- package/dist/safe-js/interp/collection-iterator.d.ts +1 -1
- package/dist/safe-js/interp/host-bridge.d.ts +1 -0
- package/dist/safe-js/interp/host-capabilities.d.ts +13 -4
- package/dist/safe-js/interp/interpreter.d.ts +5 -1
- package/dist/safe-js/interp/intl-numberformat.d.ts +2 -2
- package/dist/safe-js/interp/jobs.d.ts +8 -0
- package/dist/safe-js/interp/scope.d.ts +9 -2
- package/dist/safe-js/interp/typed-array.d.ts +2 -2
- package/dist/safe-js/interp/values.d.ts +1 -0
- package/dist/safe-js/modules/registry.d.ts +4 -1
- package/dist/safe-js/modules/source-graph.d.ts +19 -1
- package/dist/safe-js/parse/compact-spans.d.ts +18 -0
- package/dist/safe-js/parse/dynamic-source.d.ts +3 -1
- package/dist/safe-js/parse/function-source.d.ts +1 -1
- package/dist/safe-js/parse/parser.d.ts +8 -3
- package/dist/safe-js/parse/tokenizer.d.ts +4 -0
- package/dist/safe-js/realm.d.ts +16 -3
- package/dist/safe-js/restore.d.ts +1 -0
- package/dist/safe-js/run.d.ts +10 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-A4L72WXV.js.map +0 -7
- package/dist/safe-js/chunks/chunk-B4M6QVUV.js.map +0 -7
- package/dist/safe-js/chunks/chunk-BHYBD6SY.js.map +0 -7
- package/dist/safe-js/chunks/chunk-HYD4K4HN.js.map +0 -7
- package/dist/safe-js/chunks/chunk-ILYJBA2D.js.map +0 -7
- package/dist/safe-js/chunks/chunk-Q7B6JIMI.js.map +0 -7
- package/dist/safe-js/chunks/harness-LUYCGWHZ.js +0 -10
- package/dist/safe-js/chunks/mcp-IWKZB2R2.js +0 -11
- package/dist/safe-js/chunks/migration-file-IXO5MLP4.js +0 -12
- package/dist/safe-js/chunks/restore-SI7HOC6C.js +0 -13
- package/dist/safe-js/chunks/run-SHI2PYR6.js +0 -17
- package/dist/safe-js/chunks/runtime-modules-OO72HTVF.js +0 -10
- /package/dist/safe-js/chunks/{chunk-4CX3HYRY.js.map → chunk-FA5CQO6V.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-LPBTSTDG.js.map → chunk-GCOLKRMY.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-GMPZBMPA.js.map → chunk-K3ZRBAG5.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-JNLY7IMV.js.map → chunk-QL2ALAE6.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-BEXRQET4.js.map → chunk-S2GFVXSI.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-IS7YUCOF.js.map → chunk-XHSOM5CG.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-YK2WE33M.js.map → cli-runtime-6QPGM3TX.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-ATWBOZWV.js.map → dump-TU6SYRFD.js.map} +0 -0
- /package/dist/safe-js/chunks/{fs-D72Y52I5.js.map → fs-HTZT32MQ.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-LUYCGWHZ.js.map → harness-RYAMI444.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-IWKZB2R2.js.map → mcp-DO2IRFGQ.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-IXO5MLP4.js.map → migration-file-K7UH5ZG6.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-SI7HOC6C.js.map → restore-7LRP4BM3.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-SHI2PYR6.js.map → run-6SETM7SV.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-OO72HTVF.js.map → runtime-modules-MCQS2SHQ.js.map} +0 -0
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
// packages/tiny-mcp-client/src/http-json-budget.ts
|
|
2
|
+
function assertHttpJsonBudget(text) {
|
|
3
|
+
let nodes = 0;
|
|
4
|
+
let allocation = 0;
|
|
5
|
+
let decodedBytes = 0;
|
|
6
|
+
const stack = [];
|
|
7
|
+
const whitespace = (c) => c === " " || c === " " || c === "\r" || c === "\n";
|
|
8
|
+
const check = () => {
|
|
9
|
+
if (nodes > 1e5 || stack.length > 64 || allocation > 8 * 1024 * 1024 || decodedBytes > 4 * 1024 * 1024)
|
|
10
|
+
throw new Error("MCP HTTP JSON structural budget exceeded");
|
|
11
|
+
};
|
|
12
|
+
for (let i = 0; i < text.length; ) {
|
|
13
|
+
const c = text[i++];
|
|
14
|
+
if (whitespace(c) || c === "," || c === ":") continue;
|
|
15
|
+
if (c === "}" || c === "]") {
|
|
16
|
+
if (stack.pop() !== c) throw new SyntaxError("Malformed MCP HTTP JSON nesting");
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
nodes++;
|
|
20
|
+
allocation += 128;
|
|
21
|
+
if (c === "{" || c === "[") {
|
|
22
|
+
stack.push(c === "{" ? "}" : "]");
|
|
23
|
+
check();
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
check();
|
|
27
|
+
if (c === '"') {
|
|
28
|
+
let closed = false;
|
|
29
|
+
while (i < text.length) {
|
|
30
|
+
const character = text[i++];
|
|
31
|
+
if (character === '"') {
|
|
32
|
+
closed = true;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (character.charCodeAt(0) < 32) throw new SyntaxError("Malformed MCP HTTP JSON string");
|
|
36
|
+
if (character === "\\") {
|
|
37
|
+
const escape = text[i++];
|
|
38
|
+
if (escape === "u") {
|
|
39
|
+
for (let digit = 0; digit < 4; digit++) {
|
|
40
|
+
const hex = text[i++];
|
|
41
|
+
if (hex === void 0 || !"0123456789abcdefABCDEF".includes(hex))
|
|
42
|
+
throw new SyntaxError("Malformed MCP HTTP JSON escape");
|
|
43
|
+
}
|
|
44
|
+
} else if (escape === void 0 || !'"\\/bfnrt'.includes(escape)) {
|
|
45
|
+
throw new SyntaxError("Malformed MCP HTTP JSON escape");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
decodedBytes += 2;
|
|
49
|
+
allocation += 2;
|
|
50
|
+
check();
|
|
51
|
+
}
|
|
52
|
+
if (!closed) throw new SyntaxError("Unterminated MCP HTTP JSON string");
|
|
53
|
+
} else {
|
|
54
|
+
while (i < text.length && !whitespace(text[i]) && !'{}[],:"'.includes(text[i])) i++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (stack.length !== 0) throw new SyntaxError("Unterminated MCP HTTP JSON container");
|
|
58
|
+
}
|
|
59
|
+
|
|
1
60
|
// packages/tiny-mcp-client/src/internal.ts
|
|
2
61
|
import { spawn as spawn2 } from "node:child_process";
|
|
3
62
|
import { PassThrough } from "node:stream";
|
|
@@ -8144,6 +8203,7 @@ var HttpTransport = class {
|
|
|
8144
8203
|
signal
|
|
8145
8204
|
)).trim();
|
|
8146
8205
|
if (request !== void 0 && responseBody.length > 0) {
|
|
8206
|
+
assertHttpJsonBudget(responseBody);
|
|
8147
8207
|
let parsed = parseJsonRpcMessage(responseBody);
|
|
8148
8208
|
if (parsed.type === "invalid") {
|
|
8149
8209
|
try {
|
|
@@ -8297,6 +8357,7 @@ var HttpTransport = class {
|
|
|
8297
8357
|
if (context !== void 0) throw new Error("MCP HTTP response body is empty");
|
|
8298
8358
|
return;
|
|
8299
8359
|
}
|
|
8360
|
+
assertHttpJsonBudget(payload);
|
|
8300
8361
|
if (context !== void 0) {
|
|
8301
8362
|
this.writeReadableLine(context.validate(payload, false));
|
|
8302
8363
|
return;
|
|
@@ -8319,6 +8380,7 @@ var HttpTransport = class {
|
|
|
8319
8380
|
this.rejectLegacyEndpoint = void 0;
|
|
8320
8381
|
continue;
|
|
8321
8382
|
}
|
|
8383
|
+
assertHttpJsonBudget(message.data);
|
|
8322
8384
|
this.writeReadableLine(context?.validate(message.data, true) ?? message.data);
|
|
8323
8385
|
if (context?.completed) return;
|
|
8324
8386
|
}
|
|
@@ -9756,4 +9818,4 @@ CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for
|
|
|
9756
9818
|
the full license text.
|
|
9757
9819
|
|
|
9758
9820
|
*/
|
|
9759
|
-
//# sourceMappingURL=chunk-
|
|
9821
|
+
//# sourceMappingURL=chunk-D3GC5QPZ.js.map
|