@nodetool-ai/sandbox-runtime 0.0.0-stage → 0.8.9-beta.2

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 (218) hide show
  1. package/README.md +24 -2
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/host-access-gate.d.ts +24 -0
  4. package/dist/host-access-gate.d.ts.map +1 -0
  5. package/dist/host-access-gate.js +31 -0
  6. package/dist/host-access-gate.js.map +1 -0
  7. package/dist/index.d.ts +32 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +318 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/js-sandbox-worker/engine.d.ts +4 -0
  12. package/dist/js-sandbox-worker/engine.d.ts.map +1 -0
  13. package/dist/js-sandbox-worker/engine.js +82 -0
  14. package/dist/js-sandbox-worker/engine.js.map +1 -0
  15. package/dist/js-sandbox-worker/host.d.ts +136 -0
  16. package/dist/js-sandbox-worker/host.d.ts.map +1 -0
  17. package/dist/js-sandbox-worker/host.js +482 -0
  18. package/dist/js-sandbox-worker/host.js.map +1 -0
  19. package/dist/js-sandbox-worker/interpreter.d.ts +276 -0
  20. package/dist/js-sandbox-worker/interpreter.d.ts.map +1 -0
  21. package/dist/js-sandbox-worker/interpreter.js +1318 -0
  22. package/dist/js-sandbox-worker/interpreter.js.map +1 -0
  23. package/dist/js-sandbox-worker/protocol.d.ts +168 -0
  24. package/dist/js-sandbox-worker/protocol.d.ts.map +1 -0
  25. package/dist/js-sandbox-worker/protocol.js +217 -0
  26. package/dist/js-sandbox-worker/protocol.js.map +1 -0
  27. package/dist/js-sandbox-worker/worker-entry.d.ts +26 -0
  28. package/dist/js-sandbox-worker/worker-entry.d.ts.map +1 -0
  29. package/dist/js-sandbox-worker/worker-entry.js +308 -0
  30. package/dist/js-sandbox-worker/worker-entry.js.map +1 -0
  31. package/dist/limits.d.ts +77 -0
  32. package/dist/limits.d.ts.map +1 -0
  33. package/dist/limits.js +56 -0
  34. package/dist/limits.js.map +1 -0
  35. package/dist/sandbox-bootstrap-modules.d.ts +54 -0
  36. package/dist/sandbox-bootstrap-modules.d.ts.map +1 -0
  37. package/dist/sandbox-bootstrap-modules.js +104 -0
  38. package/dist/sandbox-bootstrap-modules.js.map +1 -0
  39. package/dist/sandbox-bytes.d.ts +43 -0
  40. package/dist/sandbox-bytes.d.ts.map +1 -0
  41. package/dist/sandbox-bytes.js +61 -0
  42. package/dist/sandbox-bytes.js.map +1 -0
  43. package/dist/sandbox-canvas-api.d.ts +30 -0
  44. package/dist/sandbox-canvas-api.d.ts.map +1 -0
  45. package/dist/sandbox-canvas-api.js +81 -0
  46. package/dist/sandbox-canvas-api.js.map +1 -0
  47. package/dist/sandbox-constants.d.ts +5 -0
  48. package/dist/sandbox-constants.d.ts.map +1 -0
  49. package/dist/sandbox-constants.js +13 -0
  50. package/dist/sandbox-constants.js.map +1 -0
  51. package/dist/sandbox-json-transport.d.ts +107 -0
  52. package/dist/sandbox-json-transport.d.ts.map +1 -0
  53. package/dist/sandbox-json-transport.js +324 -0
  54. package/dist/sandbox-json-transport.js.map +1 -0
  55. package/dist/timeline-capture.d.ts +21 -0
  56. package/dist/timeline-capture.d.ts.map +1 -0
  57. package/dist/timeline-capture.js +564 -0
  58. package/dist/timeline-capture.js.map +1 -0
  59. package/dist/utils/type-guards.d.ts +26 -0
  60. package/dist/utils/type-guards.d.ts.map +1 -0
  61. package/dist/utils/type-guards.js +44 -0
  62. package/dist/utils/type-guards.js.map +1 -0
  63. package/package.json +138 -4
  64. package/vendor/README.md +17 -0
  65. package/vendor/quickjs/LICENSE +21 -0
  66. package/vendor/quickjs/PROVENANCE.json +8 -0
  67. package/vendor/quickjs/adapter/fetch.d.ts +56 -0
  68. package/vendor/quickjs/adapter/fetch.js +140 -0
  69. package/vendor/quickjs/createTimeInterval.d.ts +9 -0
  70. package/vendor/quickjs/createTimeInterval.js +22 -0
  71. package/vendor/quickjs/createVirtualFileSystem.d.ts +13 -0
  72. package/vendor/quickjs/createVirtualFileSystem.js +191 -0
  73. package/vendor/quickjs/index.d.ts +77 -0
  74. package/vendor/quickjs/index.js +77 -0
  75. package/vendor/quickjs/loadAsyncQuickJs.d.ts +12 -0
  76. package/vendor/quickjs/loadAsyncQuickJs.js +66 -0
  77. package/vendor/quickjs/loadQuickJs.d.ts +12 -0
  78. package/vendor/quickjs/loadQuickJs.js +73 -0
  79. package/vendor/quickjs/modules/assert.d.ts +2 -0
  80. package/vendor/quickjs/modules/assert.js +47 -0
  81. package/vendor/quickjs/modules/buffer.d.ts +2 -0
  82. package/vendor/quickjs/modules/buffer.js +106 -0
  83. package/vendor/quickjs/modules/build/test-lib.js +2 -0
  84. package/vendor/quickjs/modules/events.d.ts +2 -0
  85. package/vendor/quickjs/modules/events.js +4 -0
  86. package/vendor/quickjs/modules/fs.d.ts +2 -0
  87. package/vendor/quickjs/modules/fs.js +76 -0
  88. package/vendor/quickjs/modules/fs_promises.d.ts +2 -0
  89. package/vendor/quickjs/modules/fs_promises.js +328 -0
  90. package/vendor/quickjs/modules/module.d.ts +2 -0
  91. package/vendor/quickjs/modules/module.js +33 -0
  92. package/vendor/quickjs/modules/nodeCompatibility/headers.d.ts +2 -0
  93. package/vendor/quickjs/modules/nodeCompatibility/headers.js +58 -0
  94. package/vendor/quickjs/modules/nodeCompatibility/request.d.ts +2 -0
  95. package/vendor/quickjs/modules/nodeCompatibility/request.js +5 -0
  96. package/vendor/quickjs/modules/nodeCompatibility/response.d.ts +2 -0
  97. package/vendor/quickjs/modules/nodeCompatibility/response.js +5 -0
  98. package/vendor/quickjs/modules/path.d.ts +2 -0
  99. package/vendor/quickjs/modules/path.js +504 -0
  100. package/vendor/quickjs/modules/process.d.ts +2 -0
  101. package/vendor/quickjs/modules/process.js +309 -0
  102. package/vendor/quickjs/modules/punycode.d.ts +2 -0
  103. package/vendor/quickjs/modules/punycode.js +443 -0
  104. package/vendor/quickjs/modules/querystring.d.ts +2 -0
  105. package/vendor/quickjs/modules/querystring.js +15 -0
  106. package/vendor/quickjs/modules/string_decoder.d.ts +2 -0
  107. package/vendor/quickjs/modules/string_decoder.js +223 -0
  108. package/vendor/quickjs/modules/timers.d.ts +2 -0
  109. package/vendor/quickjs/modules/timers.js +10 -0
  110. package/vendor/quickjs/modules/timers_promises.d.ts +2 -0
  111. package/vendor/quickjs/modules/timers_promises.js +40 -0
  112. package/vendor/quickjs/modules/url.d.ts +2 -0
  113. package/vendor/quickjs/modules/url.js +104 -0
  114. package/vendor/quickjs/modules/util.d.ts +2 -0
  115. package/vendor/quickjs/modules/util.js +233 -0
  116. package/vendor/quickjs/package.json +3 -0
  117. package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.d.ts +4 -0
  118. package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.js +76 -0
  119. package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.d.ts +3 -0
  120. package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.js +22 -0
  121. package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.d.ts +12 -0
  122. package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.js +9 -0
  123. package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.d.ts +4 -0
  124. package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.js +30 -0
  125. package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.d.ts +2 -0
  126. package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.js +12 -0
  127. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.d.ts +3 -0
  128. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.js +11 -0
  129. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.d.ts +4 -0
  130. package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.js +10 -0
  131. package/vendor/quickjs/sandbox/expose/expose.d.ts +3 -0
  132. package/vendor/quickjs/sandbox/expose/expose.js +155 -0
  133. package/vendor/quickjs/sandbox/expose/isES2015Class.d.ts +1 -0
  134. package/vendor/quickjs/sandbox/expose/isES2015Class.js +4 -0
  135. package/vendor/quickjs/sandbox/expose/isObject.d.ts +1 -0
  136. package/vendor/quickjs/sandbox/expose/isObject.js +4 -0
  137. package/vendor/quickjs/sandbox/expose/pendingHostPromises.d.ts +6 -0
  138. package/vendor/quickjs/sandbox/expose/pendingHostPromises.js +40 -0
  139. package/vendor/quickjs/sandbox/getMaxIntervalAmount.d.ts +8 -0
  140. package/vendor/quickjs/sandbox/getMaxIntervalAmount.js +12 -0
  141. package/vendor/quickjs/sandbox/getMaxTimeoutAmount.d.ts +8 -0
  142. package/vendor/quickjs/sandbox/getMaxTimeoutAmount.js +12 -0
  143. package/vendor/quickjs/sandbox/handleEvalError.d.ts +2 -0
  144. package/vendor/quickjs/sandbox/handleEvalError.js +21 -0
  145. package/vendor/quickjs/sandbox/handleToNative/handleToNative.d.ts +9 -0
  146. package/vendor/quickjs/sandbox/handleToNative/handleToNative.js +153 -0
  147. package/vendor/quickjs/sandbox/handleToNative/serializer/index.d.ts +10 -0
  148. package/vendor/quickjs/sandbox/handleToNative/serializer/index.js +36 -0
  149. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.d.ts +2 -0
  150. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.js +4 -0
  151. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.d.ts +2 -0
  152. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.js +16 -0
  153. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.d.ts +2 -0
  154. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.js +16 -0
  155. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.d.ts +2 -0
  156. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.js +18 -0
  157. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.d.ts +2 -0
  158. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.js +17 -0
  159. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.d.ts +2 -0
  160. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.js +18 -0
  161. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.d.ts +2 -0
  162. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.js +16 -0
  163. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.d.ts +2 -0
  164. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.js +17 -0
  165. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.d.ts +2 -0
  166. package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.js +17 -0
  167. package/vendor/quickjs/sandbox/helper.d.ts +2 -0
  168. package/vendor/quickjs/sandbox/helper.js +14 -0
  169. package/vendor/quickjs/sandbox/provide/provideConsole.d.ts +6 -0
  170. package/vendor/quickjs/sandbox/provide/provideConsole.js +53 -0
  171. package/vendor/quickjs/sandbox/provide/provideEnv.d.ts +3 -0
  172. package/vendor/quickjs/sandbox/provide/provideEnv.js +10 -0
  173. package/vendor/quickjs/sandbox/provide/provideFs.d.ts +4 -0
  174. package/vendor/quickjs/sandbox/provide/provideFs.js +159 -0
  175. package/vendor/quickjs/sandbox/provide/provideHttp.d.ts +9 -0
  176. package/vendor/quickjs/sandbox/provide/provideHttp.js +42 -0
  177. package/vendor/quickjs/sandbox/provide/provideTimingFunctions.d.ts +7 -0
  178. package/vendor/quickjs/sandbox/provide/provideTimingFunctions.js +119 -0
  179. package/vendor/quickjs/sandbox/setupFileSystem.d.ts +3 -0
  180. package/vendor/quickjs/sandbox/setupFileSystem.js +13 -0
  181. package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.d.ts +4 -0
  182. package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.js +76 -0
  183. package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.d.ts +3 -0
  184. package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.js +22 -0
  185. package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.d.ts +12 -0
  186. package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.js +9 -0
  187. package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.d.ts +4 -0
  188. package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.js +30 -0
  189. package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.d.ts +2 -0
  190. package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.js +12 -0
  191. package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.d.ts +3 -0
  192. package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.js +11 -0
  193. package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.d.ts +4 -0
  194. package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.js +10 -0
  195. package/vendor/quickjs/types/CodeFunctionInput.d.ts +12 -0
  196. package/vendor/quickjs/types/CodeFunctionInput.js +1 -0
  197. package/vendor/quickjs/types/ErrorResponse.d.ts +9 -0
  198. package/vendor/quickjs/types/ErrorResponse.js +1 -0
  199. package/vendor/quickjs/types/LoadQuickJsOptions.d.ts +3 -0
  200. package/vendor/quickjs/types/LoadQuickJsOptions.js +1 -0
  201. package/vendor/quickjs/types/OkResponse.d.ts +4 -0
  202. package/vendor/quickjs/types/OkResponse.js +1 -0
  203. package/vendor/quickjs/types/OkResponseCheck.d.ts +3 -0
  204. package/vendor/quickjs/types/OkResponseCheck.js +1 -0
  205. package/vendor/quickjs/types/Prettify.d.ts +3 -0
  206. package/vendor/quickjs/types/Prettify.js +1 -0
  207. package/vendor/quickjs/types/RuntimeOptions.d.ts +87 -0
  208. package/vendor/quickjs/types/RuntimeOptions.js +1 -0
  209. package/vendor/quickjs/types/SandboxEvalCode.d.ts +5 -0
  210. package/vendor/quickjs/types/SandboxEvalCode.js +1 -0
  211. package/vendor/quickjs/types/SandboxFunction.d.ts +16 -0
  212. package/vendor/quickjs/types/SandboxFunction.js +1 -0
  213. package/vendor/quickjs/types/SandboxOptions.d.ts +152 -0
  214. package/vendor/quickjs/types/SandboxOptions.js +1 -0
  215. package/vendor/quickjs/types/SandboxValidateCode.d.ts +9 -0
  216. package/vendor/quickjs/types/SandboxValidateCode.js +1 -0
  217. package/vendor/quickjs/types/Serializer.d.ts +2 -0
  218. package/vendor/quickjs/types/Serializer.js +1 -0
@@ -0,0 +1,324 @@
1
+ /**
2
+ * JSON transport for structured data across the QuickJS boundary.
3
+ *
4
+ * The wrapper marshals a value handle-by-handle: every object node costs four
5
+ * `evalCode` compilations inside the guest plus a `newFunction` allocation, and
6
+ * every property crosses as its own descriptor. Measured on this repo's engine
7
+ * that is ~150 µs per object node out of the guest and ~400 µs per object node
8
+ * into it — a Code node handed 5 000 rows spent 1.9 s reading them and another
9
+ * 0.8 s handing them back, before running a line of its own.
10
+ *
11
+ * Both directions carry JSON-shaped data, so the fast path is to move one
12
+ * string: the guest builds its answer with `JSON.stringify` and the host parses
13
+ * it, and the host encodes its globals here for the init prelude to parse.
14
+ * Measured on the same shapes, 20–25× either way.
15
+ *
16
+ * Two kinds of value would lose by that trade, and both ride *beside* the JSON
17
+ * in a sidecar the marshaler moves in one piece — a typed array (base64 inside
18
+ * the guest costs more than the marshal it replaces) and a string past
19
+ * {@link SIDECAR_STRING_THRESHOLD} (escaping a megabyte to unescape it again is
20
+ * two passes the primitive path never makes). A {@link JSON_SIDECAR_MARKER}
21
+ * holds its place by index.
22
+ *
23
+ * What JSON alone still cannot carry is carried by markers, so the round trip
24
+ * keeps the types the structured path preserved:
25
+ *
26
+ * - **dates** — an ISO string under {@link JSON_DATE_MARKER}, revived as a
27
+ * `Date`. A `state.lastRun` that survives a Code node's invocations stays a
28
+ * `Date` rather than degrading to a string on its first round trip.
29
+ * - **non-finite numbers** — `NaN` and the infinities under {@link
30
+ * JSON_NUMBER_MARKER}. `JSON.stringify` writes them as `null`.
31
+ * - **undefined** — {@link JSON_UNDEFINED_MARKER}, so a property whose value is
32
+ * `undefined` keeps its key. `JSON.stringify` drops it.
33
+ *
34
+ * Anything else — a function, a symbol, a bigint, a `Map`, a class instance —
35
+ * makes the encoder refuse that value, and its caller falls back to the
36
+ * wrapper's own marshaling, which is slow but total. The fast path never has to
37
+ * guess.
38
+ *
39
+ * A **cycle** is the one thing neither path carries: the wrapper's marshaler
40
+ * recurses until the runtime aborts with `list_empty(&rt->gc_obj_list)`, which
41
+ * kills the run with an assertion instead of an answer. So a cyclic global is
42
+ * refused by name, and a cyclic result becomes `String(value)` — the fallback
43
+ * `serializeResult` already documents for a value `JSON.stringify` rejects.
44
+ *
45
+ * Browser-safe: nothing here imports a Node builtin.
46
+ */
47
+ import { encodeBase64, SANDBOX_BYTES_MARKER, SANDBOX_SERIALIZE_MAX_DEPTH } from "./sandbox-bytes.js";
48
+ import { isObjectLike } from "./utils/type-guards.js";
49
+ /** Marker key carrying an ISO timestamp for a `Date`. */
50
+ export const JSON_DATE_MARKER = "__nodetool_sandbox_date__";
51
+ /** Marker key carrying `"NaN"`, `"Infinity"`, or `"-Infinity"`. */
52
+ export const JSON_NUMBER_MARKER = "__nodetool_sandbox_number__";
53
+ /** Marker key standing in for an `undefined` property value. */
54
+ export const JSON_UNDEFINED_MARKER = "__nodetool_sandbox_undefined__";
55
+ /** Marker key carrying an index into the payload's sidecar. */
56
+ export const JSON_SIDECAR_MARKER = "__nodetool_sandbox_side__";
57
+ /**
58
+ * Strings at least this long travel in the sidecar rather than inside the JSON.
59
+ * Below it the escape/unescape pass is noise next to the run's fixed cost; a
60
+ * megabyte of text is where it stops being.
61
+ */
62
+ export const SIDECAR_STRING_THRESHOLD = 8192;
63
+ /** The global the guest parks its encoder on. */
64
+ export const GUEST_MARSHAL_GLOBAL = "__nodetool_marshal__";
65
+ /** The global carrying the host's encoded globals for the prelude to read. */
66
+ export const GUEST_GLOBALS_JSON_BINDING = "__nodetool_globals_json__";
67
+ /** The global carrying the sidecar those encoded globals index into. */
68
+ export const GUEST_GLOBALS_SIDECAR_BINDING = "__nodetool_globals_side__";
69
+ // ---------------------------------------------------------------------------
70
+ // Host → guest
71
+ // ---------------------------------------------------------------------------
72
+ function isPlainObject(value) {
73
+ const prototype = Object.getPrototypeOf(value);
74
+ return prototype === Object.prototype || prototype === null;
75
+ }
76
+ /** Returned in place of a value that has no JSON representation. */
77
+ const UNREPRESENTABLE = Symbol("unrepresentable");
78
+ /**
79
+ * Returned in place of a value that refers back to itself. It is reported apart
80
+ * from {@link UNREPRESENTABLE} because the fallback does not cover it: the
81
+ * wrapper's own marshaler recurses until the runtime aborts, so a caller has to
82
+ * refuse a cycle rather than hand it over.
83
+ */
84
+ const CYCLIC = Symbol("cyclic");
85
+ function toJsonTree(value, sidecar, seen, depth) {
86
+ if (value === null)
87
+ return null;
88
+ if (value === undefined)
89
+ return { [JSON_UNDEFINED_MARKER]: true };
90
+ switch (typeof value) {
91
+ case "boolean":
92
+ return value;
93
+ case "string":
94
+ return value.length >= SIDECAR_STRING_THRESHOLD
95
+ ? { [JSON_SIDECAR_MARKER]: sidecar.push(value) - 1 }
96
+ : value;
97
+ case "number":
98
+ return Number.isFinite(value)
99
+ ? value
100
+ : { [JSON_NUMBER_MARKER]: String(value) };
101
+ case "function":
102
+ case "symbol":
103
+ case "bigint":
104
+ return UNREPRESENTABLE;
105
+ default:
106
+ break;
107
+ }
108
+ if (depth >= SANDBOX_SERIALIZE_MAX_DEPTH)
109
+ return UNREPRESENTABLE;
110
+ if (seen.has(value))
111
+ return CYCLIC;
112
+ if (value instanceof Date) {
113
+ return { [JSON_DATE_MARKER]: value.toISOString() };
114
+ }
115
+ if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
116
+ // Bytes cannot ride the sidecar into the guest: a host `Uint8Array` arrives
117
+ // there as a numeric-keyed object, which is the whole reason the base64
118
+ // marker exists.
119
+ const view = value;
120
+ return {
121
+ [SANDBOX_BYTES_MARKER]: encodeBase64(new Uint8Array(view.buffer, view.byteOffset, view.byteLength))
122
+ };
123
+ }
124
+ seen.add(value);
125
+ try {
126
+ if (Array.isArray(value)) {
127
+ const out = new Array(value.length);
128
+ for (let i = 0; i < value.length; i++) {
129
+ const encoded = toJsonTree(value[i], sidecar, seen, depth + 1);
130
+ if (encoded === UNREPRESENTABLE || encoded === CYCLIC)
131
+ return encoded;
132
+ out[i] = encoded;
133
+ }
134
+ return out;
135
+ }
136
+ if (!isPlainObject(value))
137
+ return UNREPRESENTABLE;
138
+ const out = {};
139
+ for (const [key, entry] of Object.entries(value)) {
140
+ const encoded = toJsonTree(entry, sidecar, seen, depth + 1);
141
+ if (encoded === UNREPRESENTABLE || encoded === CYCLIC)
142
+ return encoded;
143
+ out[key] = encoded;
144
+ }
145
+ return out;
146
+ }
147
+ finally {
148
+ seen.delete(value);
149
+ }
150
+ }
151
+ /**
152
+ * Encode a batch of named host values for the guest to `JSON.parse` and revive.
153
+ *
154
+ * One batch means one sidecar and one parse. An entry holding something JSON
155
+ * plus the markers cannot carry is reported in `skipped` instead of failing the
156
+ * batch, so one exotic global costs only itself; an entry that refers back to
157
+ * itself is reported in `cyclic`, which no path can carry.
158
+ */
159
+ export function encodeHostRecord(values) {
160
+ const sidecar = [];
161
+ const skipped = [];
162
+ const cyclic = [];
163
+ const tree = {};
164
+ for (const [name, value] of Object.entries(values)) {
165
+ const encoded = toJsonTree(value, sidecar, new Set(), 0);
166
+ if (encoded === CYCLIC) {
167
+ cyclic.push(name);
168
+ continue;
169
+ }
170
+ if (encoded === UNREPRESENTABLE) {
171
+ skipped.push(name);
172
+ continue;
173
+ }
174
+ tree[name] = encoded;
175
+ }
176
+ return { json: JSON.stringify(tree), sidecar, skipped, cyclic };
177
+ }
178
+ // ---------------------------------------------------------------------------
179
+ // Guest → host
180
+ // ---------------------------------------------------------------------------
181
+ function reviveHostTree(value, sidecar) {
182
+ if (Array.isArray(value)) {
183
+ for (let i = 0; i < value.length; i++) {
184
+ value[i] = reviveHostTree(value[i], sidecar);
185
+ }
186
+ return value;
187
+ }
188
+ if (!isObjectLike(value))
189
+ return value;
190
+ const sideIndex = value[JSON_SIDECAR_MARKER];
191
+ if (typeof sideIndex === "number")
192
+ return sidecar[sideIndex];
193
+ const iso = value[JSON_DATE_MARKER];
194
+ if (typeof iso === "string")
195
+ return new Date(iso);
196
+ const nonFinite = value[JSON_NUMBER_MARKER];
197
+ if (typeof nonFinite === "string")
198
+ return Number(nonFinite);
199
+ if (value[JSON_UNDEFINED_MARKER] === true)
200
+ return undefined;
201
+ for (const key of Object.keys(value)) {
202
+ value[key] = reviveHostTree(value[key], sidecar);
203
+ }
204
+ return value;
205
+ }
206
+ /**
207
+ * Decode what the guest's encoder produced: either a JSON string plus the
208
+ * sidecar its markers index, or a value the guest handed over as-is (a
209
+ * primitive, or something `JSON.stringify` refused) under `raw`.
210
+ *
211
+ * The guest owns this string, so a body that overwrites the encoder can hand
212
+ * back nonsense. That is not an escalation — the guest owned its own result
213
+ * either way — so a payload that will not parse decodes as `undefined` rather
214
+ * than failing the run.
215
+ */
216
+ export function decodeGuestPayload(payload) {
217
+ if (!isObjectLike(payload))
218
+ return payload;
219
+ const json = payload.j;
220
+ if (typeof json !== "string") {
221
+ return "raw" in payload ? payload.raw : undefined;
222
+ }
223
+ let parsed;
224
+ try {
225
+ parsed = JSON.parse(json);
226
+ }
227
+ catch {
228
+ return undefined;
229
+ }
230
+ const sidecar = Array.isArray(payload.b) ? payload.b : [];
231
+ if (!isObjectLike(parsed))
232
+ return undefined;
233
+ const revived = reviveHostTree(parsed, sidecar);
234
+ return isObjectLike(revived) ? revived.v : undefined;
235
+ }
236
+ // ---------------------------------------------------------------------------
237
+ // Guest-side sources
238
+ // ---------------------------------------------------------------------------
239
+ /**
240
+ * The guest half, spliced into the init prelude: the encoder the entry module
241
+ * and the sync extractor call, and the parse of whatever globals the host
242
+ * encoded.
243
+ *
244
+ * `__bytesMarker` and `fromBase64` are defined earlier in the prelude, so this
245
+ * source has to follow them.
246
+ */
247
+ export const GUEST_JSON_TRANSPORT_SOURCE = `
248
+ const __ntSide = [];
249
+ globalThis.${GUEST_MARSHAL_GLOBAL} = (value) => {
250
+ // A primitive already crosses as a primitive — stringifying a megabyte of
251
+ // text only to parse it back on the host is the one trade JSON loses.
252
+ if (value === null || (typeof value !== "object" && typeof value !== "string")) {
253
+ return { raw: value };
254
+ }
255
+ __ntSide.length = 0;
256
+ let json;
257
+ try {
258
+ json = JSON.stringify({ v: value }, function (key, encoded) {
259
+ const raw = this[key];
260
+ if (typeof raw === "string") {
261
+ return raw.length >= ${SIDECAR_STRING_THRESHOLD}
262
+ ? { ${JSON.stringify(JSON_SIDECAR_MARKER)}: __ntSide.push(raw) - 1 }
263
+ : raw;
264
+ }
265
+ if (typeof raw === "number" && !Number.isFinite(raw)) {
266
+ return { ${JSON.stringify(JSON_NUMBER_MARKER)}: String(raw) };
267
+ }
268
+ if (raw instanceof Date) {
269
+ return { ${JSON.stringify(JSON_DATE_MARKER)}: raw.toISOString() };
270
+ }
271
+ if (ArrayBuffer.isView(raw) && !(raw instanceof DataView)) {
272
+ return {
273
+ ${JSON.stringify(JSON_SIDECAR_MARKER)}: __ntSide.push(
274
+ raw instanceof Uint8Array
275
+ ? raw
276
+ : new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength)
277
+ ) - 1
278
+ };
279
+ }
280
+ if (raw === undefined && encoded === undefined) {
281
+ return { ${JSON.stringify(JSON_UNDEFINED_MARKER)}: true };
282
+ }
283
+ return encoded;
284
+ });
285
+ } catch (e) {
286
+ // A cycle (or a bigint) has no JSON form, and handing the value to the
287
+ // wrapper's marshaler instead recurses until the runtime aborts. String()
288
+ // is what serializeResult falls back to for the same values.
289
+ __ntSide.length = 0;
290
+ return { raw: String(value) };
291
+ }
292
+ // An empty sidecar is left off: an empty array still costs the wrapper a
293
+ // whole object node to marshal, which is most of a small payload's cost.
294
+ return __ntSide.length === 0 ? { j: json } : { j: json, b: __ntSide.slice() };
295
+ };
296
+ const __ntReviveHost = (value, side) => {
297
+ if (Array.isArray(value)) {
298
+ for (let i = 0; i < value.length; i++) value[i] = __ntReviveHost(value[i], side);
299
+ return value;
300
+ }
301
+ if (!value || typeof value !== "object") return value;
302
+ const index = value[${JSON.stringify(JSON_SIDECAR_MARKER)}];
303
+ if (typeof index === "number") return side[index];
304
+ const bytes = value[__bytesMarker];
305
+ if (typeof bytes === "string") return globalThis.fromBase64(bytes);
306
+ const iso = value[${JSON.stringify(JSON_DATE_MARKER)}];
307
+ if (typeof iso === "string") return new Date(iso);
308
+ const num = value[${JSON.stringify(JSON_NUMBER_MARKER)}];
309
+ if (typeof num === "string") return Number(num);
310
+ if (value[${JSON.stringify(JSON_UNDEFINED_MARKER)}] === true) return undefined;
311
+ for (const key of Object.keys(value)) value[key] = __ntReviveHost(value[key], side);
312
+ return value;
313
+ };
314
+ if (typeof globalThis.${GUEST_GLOBALS_JSON_BINDING} === "string") {
315
+ const __ntHostSide = globalThis.${GUEST_GLOBALS_SIDECAR_BINDING} || [];
316
+ const __ntGlobals = JSON.parse(globalThis.${GUEST_GLOBALS_JSON_BINDING});
317
+ delete globalThis.${GUEST_GLOBALS_JSON_BINDING};
318
+ delete globalThis.${GUEST_GLOBALS_SIDECAR_BINDING};
319
+ for (const __ntKey of Object.keys(__ntGlobals)) {
320
+ globalThis[__ntKey] = __ntReviveHost(__ntGlobals[__ntKey], __ntHostSide);
321
+ }
322
+ }
323
+ `;
324
+ //# sourceMappingURL=sandbox-json-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-json-transport.js","sourceRoot":"","sources":["../src/sandbox-json-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,oBAAoB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CAAC,CAAC,EAAE,CAAC;IACzE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;;aAE9B,oBAAoB;;;;;;;;;;;;+BAYF,wBAAwB;gBACvC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;;;;mBAIhC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;;;mBAGlC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;;;;YAIvC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;;;;;;;;mBAQ5B,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;wBAqBhC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;;;;sBAIrC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;;sBAEhC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC;;cAE1C,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC;;;;wBAI3B,0BAA0B;oCACd,6BAA6B;8CACnB,0BAA0B;sBAClD,0BAA0B;sBAC1B,6BAA6B;;;;;CAKlD,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The capture step of timeline code capture (docs/timeline-code-capture.md).
3
+ *
4
+ * Guest code that imports `@nodetool-ai/sandbox-timeline` passes through
5
+ * {@link captureTimelineScenes} before it runs. Each
6
+ * `<receiver>.scene(name, seconds, fn, extra?)` call gets one more argument,
7
+ * a capture record, which tells the pack what `fn` needs to be rebuilt
8
+ * without the rest of the script: the declarations to keep as source text,
9
+ * the pack imports, and the values to snapshot when the scene is built.
10
+ * `v.save()` prints the retained program from these records.
11
+ *
12
+ * The transform only appends text inside existing lines, so every line of
13
+ * the guest code keeps its number and stack positions stay correct.
14
+ */
15
+ /**
16
+ * Add a capture record to each `.scene()` call in `code`. Returns `code`
17
+ * unchanged when it does not import the timeline pack, cannot be parsed,
18
+ * or has no scene call to capture.
19
+ */
20
+ export declare function captureTimelineScenes(code: string): string;
21
+ //# sourceMappingURL=timeline-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline-capture.d.ts","sourceRoot":"","sources":["../src/timeline-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA6DH;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiC1D"}