@poe-platform/safe-js 0.1.720 → 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.
Files changed (88) hide show
  1. package/README.md +50 -7
  2. package/dist/config-mutations/types.d.ts +3 -1
  3. package/dist/safe-js/chunks/{chunk-B2SQLK4O.js → chunk-3QQYJ4RQ.js} +3 -2
  4. package/dist/safe-js/chunks/chunk-3QQYJ4RQ.js.map +7 -0
  5. package/dist/safe-js/chunks/{chunk-OP3H3ZDN.js → chunk-55RIIUGG.js} +23 -7
  6. package/dist/safe-js/chunks/chunk-55RIIUGG.js.map +7 -0
  7. package/dist/safe-js/chunks/{chunk-NJM2Q74Z.js → chunk-7SBQ7WTV.js} +10 -11
  8. package/dist/safe-js/chunks/chunk-7SBQ7WTV.js.map +7 -0
  9. package/dist/safe-js/chunks/{chunk-KP6I45ET.js → chunk-BNIEPGDU.js} +9885 -8523
  10. package/dist/safe-js/chunks/{chunk-KP6I45ET.js.map → chunk-BNIEPGDU.js.map} +4 -4
  11. package/dist/safe-js/chunks/{chunk-HYD4K4HN.js → chunk-D3GC5QPZ.js} +63 -1
  12. package/dist/safe-js/chunks/chunk-D3GC5QPZ.js.map +7 -0
  13. package/dist/safe-js/chunks/{chunk-KK5NCR5R.js → chunk-EH5A2EQI.js} +501 -150
  14. package/dist/safe-js/chunks/chunk-EH5A2EQI.js.map +7 -0
  15. package/dist/safe-js/chunks/{chunk-APKV5Y6T.js → chunk-FA5CQO6V.js} +2 -2
  16. package/dist/safe-js/chunks/{chunk-RML35GIF.js → chunk-GCOLKRMY.js} +4 -4
  17. package/dist/safe-js/chunks/{chunk-U6KZ2DQ2.js → chunk-K3ZRBAG5.js} +3 -3
  18. package/dist/safe-js/chunks/{chunk-BGJXQN4A.js → chunk-QL2ALAE6.js} +4 -4
  19. package/dist/safe-js/chunks/{chunk-IDQ67DY2.js → chunk-RYVHEOHM.js} +1131 -101
  20. package/dist/safe-js/chunks/chunk-RYVHEOHM.js.map +7 -0
  21. package/dist/safe-js/chunks/{chunk-A7CADQAD.js → chunk-S2GFVXSI.js} +3 -3
  22. package/dist/safe-js/chunks/{chunk-XMA6FOJU.js → chunk-WF7HYDJ4.js} +4 -5
  23. package/dist/safe-js/chunks/{chunk-XMA6FOJU.js.map → chunk-WF7HYDJ4.js.map} +2 -2
  24. package/dist/safe-js/chunks/{chunk-NEJ44T4Y.js → chunk-XHSOM5CG.js} +2 -2
  25. package/dist/safe-js/chunks/{cli-runtime-PO6DQDHP.js → cli-runtime-6QPGM3TX.js} +14 -14
  26. package/dist/safe-js/chunks/{dump-TRGFSCJ7.js → dump-TU6SYRFD.js} +4 -4
  27. package/dist/safe-js/chunks/{fs-4T5MZW5J.js → fs-HTZT32MQ.js} +4 -4
  28. package/dist/safe-js/chunks/harness-RYAMI444.js +10 -0
  29. package/dist/safe-js/chunks/mcp-DO2IRFGQ.js +11 -0
  30. package/dist/safe-js/chunks/migration-file-K7UH5ZG6.js +12 -0
  31. package/dist/safe-js/chunks/restore-7LRP4BM3.js +13 -0
  32. package/dist/safe-js/chunks/run-6SETM7SV.js +17 -0
  33. package/dist/safe-js/chunks/runtime-modules-MCQS2SHQ.js +10 -0
  34. package/dist/safe-js/cli.js +2 -2
  35. package/dist/safe-js/core.js +7 -7
  36. package/dist/safe-js/extensions.d.ts +3 -1
  37. package/dist/safe-js/index.js +14 -14
  38. package/dist/safe-js/interp/async.d.ts +4 -1
  39. package/dist/safe-js/interp/budget.d.ts +15 -6
  40. package/dist/safe-js/interp/collection-iterator.d.ts +1 -1
  41. package/dist/safe-js/interp/host-bridge.d.ts +1 -0
  42. package/dist/safe-js/interp/host-capabilities.d.ts +13 -4
  43. package/dist/safe-js/interp/interpreter.d.ts +5 -1
  44. package/dist/safe-js/interp/intl-numberformat.d.ts +2 -2
  45. package/dist/safe-js/interp/jobs.d.ts +8 -0
  46. package/dist/safe-js/interp/scope.d.ts +13 -3
  47. package/dist/safe-js/interp/typed-array.d.ts +5 -2
  48. package/dist/safe-js/interp/values.d.ts +1 -0
  49. package/dist/safe-js/modules/registry.d.ts +4 -1
  50. package/dist/safe-js/modules/source-graph.d.ts +19 -1
  51. package/dist/safe-js/parse/compact-spans.d.ts +18 -0
  52. package/dist/safe-js/parse/dynamic-source.d.ts +3 -1
  53. package/dist/safe-js/parse/function-source.d.ts +1 -1
  54. package/dist/safe-js/parse/parser.d.ts +8 -3
  55. package/dist/safe-js/parse/tokenizer.d.ts +4 -0
  56. package/dist/safe-js/realm.d.ts +17 -3
  57. package/dist/safe-js/restore.d.ts +1 -0
  58. package/dist/safe-js/run.d.ts +10 -0
  59. package/dist/safe-js/snapshot/guest-heap.d.ts +1 -0
  60. package/dist/toolcraft-design/prompts/primitives/note.d.ts +1 -1
  61. package/package.json +2 -2
  62. package/dist/safe-js/chunks/chunk-B2SQLK4O.js.map +0 -7
  63. package/dist/safe-js/chunks/chunk-HYD4K4HN.js.map +0 -7
  64. package/dist/safe-js/chunks/chunk-IDQ67DY2.js.map +0 -7
  65. package/dist/safe-js/chunks/chunk-KK5NCR5R.js.map +0 -7
  66. package/dist/safe-js/chunks/chunk-NJM2Q74Z.js.map +0 -7
  67. package/dist/safe-js/chunks/chunk-OP3H3ZDN.js.map +0 -7
  68. package/dist/safe-js/chunks/harness-DLEQ2Z3O.js +0 -10
  69. package/dist/safe-js/chunks/mcp-TNVEFJ6K.js +0 -11
  70. package/dist/safe-js/chunks/migration-file-IDIUFLKY.js +0 -12
  71. package/dist/safe-js/chunks/restore-P27AUZR2.js +0 -13
  72. package/dist/safe-js/chunks/run-KGAEHYMV.js +0 -17
  73. package/dist/safe-js/chunks/runtime-modules-KICK45EE.js +0 -10
  74. /package/dist/safe-js/chunks/{chunk-APKV5Y6T.js.map → chunk-FA5CQO6V.js.map} +0 -0
  75. /package/dist/safe-js/chunks/{chunk-RML35GIF.js.map → chunk-GCOLKRMY.js.map} +0 -0
  76. /package/dist/safe-js/chunks/{chunk-U6KZ2DQ2.js.map → chunk-K3ZRBAG5.js.map} +0 -0
  77. /package/dist/safe-js/chunks/{chunk-BGJXQN4A.js.map → chunk-QL2ALAE6.js.map} +0 -0
  78. /package/dist/safe-js/chunks/{chunk-A7CADQAD.js.map → chunk-S2GFVXSI.js.map} +0 -0
  79. /package/dist/safe-js/chunks/{chunk-NEJ44T4Y.js.map → chunk-XHSOM5CG.js.map} +0 -0
  80. /package/dist/safe-js/chunks/{cli-runtime-PO6DQDHP.js.map → cli-runtime-6QPGM3TX.js.map} +0 -0
  81. /package/dist/safe-js/chunks/{dump-TRGFSCJ7.js.map → dump-TU6SYRFD.js.map} +0 -0
  82. /package/dist/safe-js/chunks/{fs-4T5MZW5J.js.map → fs-HTZT32MQ.js.map} +0 -0
  83. /package/dist/safe-js/chunks/{harness-DLEQ2Z3O.js.map → harness-RYAMI444.js.map} +0 -0
  84. /package/dist/safe-js/chunks/{mcp-TNVEFJ6K.js.map → mcp-DO2IRFGQ.js.map} +0 -0
  85. /package/dist/safe-js/chunks/{migration-file-IDIUFLKY.js.map → migration-file-K7UH5ZG6.js.map} +0 -0
  86. /package/dist/safe-js/chunks/{restore-P27AUZR2.js.map → restore-7LRP4BM3.js.map} +0 -0
  87. /package/dist/safe-js/chunks/{run-KGAEHYMV.js.map → run-6SETM7SV.js.map} +0 -0
  88. /package/dist/safe-js/chunks/{runtime-modules-KICK45EE.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-HYD4K4HN.js.map
9821
+ //# sourceMappingURL=chunk-D3GC5QPZ.js.map