@nodetool-ai/agents 0.7.0-rc.11

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 (281) hide show
  1. package/dist/agent-executor.d.ts +62 -0
  2. package/dist/agent-executor.d.ts.map +1 -0
  3. package/dist/agent-executor.js +324 -0
  4. package/dist/agent-executor.js.map +1 -0
  5. package/dist/agent-step-executor.d.ts +28 -0
  6. package/dist/agent-step-executor.d.ts.map +1 -0
  7. package/dist/agent-step-executor.js +99 -0
  8. package/dist/agent-step-executor.js.map +1 -0
  9. package/dist/agent-workflow-runner.d.ts +31 -0
  10. package/dist/agent-workflow-runner.d.ts.map +1 -0
  11. package/dist/agent-workflow-runner.js +124 -0
  12. package/dist/agent-workflow-runner.js.map +1 -0
  13. package/dist/agent.d.ts +115 -0
  14. package/dist/agent.d.ts.map +1 -0
  15. package/dist/agent.js +587 -0
  16. package/dist/agent.js.map +1 -0
  17. package/dist/base-agent.d.ts +42 -0
  18. package/dist/base-agent.d.ts.map +1 -0
  19. package/dist/base-agent.js +29 -0
  20. package/dist/base-agent.js.map +1 -0
  21. package/dist/constants.d.ts +8 -0
  22. package/dist/constants.d.ts.map +1 -0
  23. package/dist/constants.js +8 -0
  24. package/dist/constants.js.map +1 -0
  25. package/dist/graph-builder.d.ts +49 -0
  26. package/dist/graph-builder.d.ts.map +1 -0
  27. package/dist/graph-builder.js +206 -0
  28. package/dist/graph-builder.js.map +1 -0
  29. package/dist/graph-planner.d.ts +56 -0
  30. package/dist/graph-planner.d.ts.map +1 -0
  31. package/dist/graph-planner.js +311 -0
  32. package/dist/graph-planner.js.map +1 -0
  33. package/dist/index.d.ts +79 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +81 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/js-sandbox.d.ts +84 -0
  38. package/dist/js-sandbox.d.ts.map +1 -0
  39. package/dist/js-sandbox.js +654 -0
  40. package/dist/js-sandbox.js.map +1 -0
  41. package/dist/multi-mode-agent.d.ts +86 -0
  42. package/dist/multi-mode-agent.d.ts.map +1 -0
  43. package/dist/multi-mode-agent.js +476 -0
  44. package/dist/multi-mode-agent.js.map +1 -0
  45. package/dist/output-format.d.ts +10 -0
  46. package/dist/output-format.d.ts.map +1 -0
  47. package/dist/output-format.js +17 -0
  48. package/dist/output-format.js.map +1 -0
  49. package/dist/parallel-task-executor.d.ts +87 -0
  50. package/dist/parallel-task-executor.d.ts.map +1 -0
  51. package/dist/parallel-task-executor.js +332 -0
  52. package/dist/parallel-task-executor.js.map +1 -0
  53. package/dist/prompts/graph-planner-prompt.d.ts +48 -0
  54. package/dist/prompts/graph-planner-prompt.d.ts.map +1 -0
  55. package/dist/prompts/graph-planner-prompt.js +180 -0
  56. package/dist/prompts/graph-planner-prompt.js.map +1 -0
  57. package/dist/reject-agentic-provider.d.ts +21 -0
  58. package/dist/reject-agentic-provider.d.ts.map +1 -0
  59. package/dist/reject-agentic-provider.js +32 -0
  60. package/dist/reject-agentic-provider.js.map +1 -0
  61. package/dist/simple-agent.d.ts +29 -0
  62. package/dist/simple-agent.d.ts.map +1 -0
  63. package/dist/simple-agent.js +54 -0
  64. package/dist/simple-agent.js.map +1 -0
  65. package/dist/step-executor.d.ts +162 -0
  66. package/dist/step-executor.d.ts.map +1 -0
  67. package/dist/step-executor.js +1114 -0
  68. package/dist/step-executor.js.map +1 -0
  69. package/dist/sub-agent-planner.d.ts +33 -0
  70. package/dist/sub-agent-planner.d.ts.map +1 -0
  71. package/dist/sub-agent-planner.js +203 -0
  72. package/dist/sub-agent-planner.js.map +1 -0
  73. package/dist/task-executor.d.ts +89 -0
  74. package/dist/task-executor.d.ts.map +1 -0
  75. package/dist/task-executor.js +359 -0
  76. package/dist/task-executor.js.map +1 -0
  77. package/dist/task-planner.d.ts +44 -0
  78. package/dist/task-planner.d.ts.map +1 -0
  79. package/dist/task-planner.js +532 -0
  80. package/dist/task-planner.js.map +1 -0
  81. package/dist/team/db-task-board.d.ts +54 -0
  82. package/dist/team/db-task-board.d.ts.map +1 -0
  83. package/dist/team/db-task-board.js +361 -0
  84. package/dist/team/db-task-board.js.map +1 -0
  85. package/dist/team/edge-message-bus.d.ts +51 -0
  86. package/dist/team/edge-message-bus.d.ts.map +1 -0
  87. package/dist/team/edge-message-bus.js +169 -0
  88. package/dist/team/edge-message-bus.js.map +1 -0
  89. package/dist/team/edge-task-board.d.ts +77 -0
  90. package/dist/team/edge-task-board.d.ts.map +1 -0
  91. package/dist/team/edge-task-board.js +140 -0
  92. package/dist/team/edge-task-board.js.map +1 -0
  93. package/dist/team/index.d.ts +16 -0
  94. package/dist/team/index.d.ts.map +1 -0
  95. package/dist/team/index.js +17 -0
  96. package/dist/team/index.js.map +1 -0
  97. package/dist/team/message-bus.d.ts +58 -0
  98. package/dist/team/message-bus.d.ts.map +1 -0
  99. package/dist/team/message-bus.js +151 -0
  100. package/dist/team/message-bus.js.map +1 -0
  101. package/dist/team/task-board.d.ts +106 -0
  102. package/dist/team/task-board.d.ts.map +1 -0
  103. package/dist/team/task-board.js +370 -0
  104. package/dist/team/task-board.js.map +1 -0
  105. package/dist/team/team-executor.d.ts +72 -0
  106. package/dist/team/team-executor.d.ts.map +1 -0
  107. package/dist/team/team-executor.js +466 -0
  108. package/dist/team/team-executor.js.map +1 -0
  109. package/dist/team/team-tools.d.ts +252 -0
  110. package/dist/team/team-tools.d.ts.map +1 -0
  111. package/dist/team/team-tools.js +412 -0
  112. package/dist/team/team-tools.js.map +1 -0
  113. package/dist/team/types.d.ts +198 -0
  114. package/dist/team/types.d.ts.map +1 -0
  115. package/dist/team/types.js +8 -0
  116. package/dist/team/types.js.map +1 -0
  117. package/dist/tools/add-edge-tool.d.ts +18 -0
  118. package/dist/tools/add-edge-tool.d.ts.map +1 -0
  119. package/dist/tools/add-edge-tool.js +92 -0
  120. package/dist/tools/add-edge-tool.js.map +1 -0
  121. package/dist/tools/add-node-tool.d.ts +22 -0
  122. package/dist/tools/add-node-tool.d.ts.map +1 -0
  123. package/dist/tools/add-node-tool.js +128 -0
  124. package/dist/tools/add-node-tool.js.map +1 -0
  125. package/dist/tools/asset-tools.d.ts +58 -0
  126. package/dist/tools/asset-tools.d.ts.map +1 -0
  127. package/dist/tools/asset-tools.js +191 -0
  128. package/dist/tools/asset-tools.js.map +1 -0
  129. package/dist/tools/base-tool.d.ts +25 -0
  130. package/dist/tools/base-tool.d.ts.map +1 -0
  131. package/dist/tools/base-tool.js +24 -0
  132. package/dist/tools/base-tool.js.map +1 -0
  133. package/dist/tools/browser-tools.d.ts +32 -0
  134. package/dist/tools/browser-tools.d.ts.map +1 -0
  135. package/dist/tools/browser-tools.js +208 -0
  136. package/dist/tools/browser-tools.js.map +1 -0
  137. package/dist/tools/calculator-tool.d.ts +24 -0
  138. package/dist/tools/calculator-tool.d.ts.map +1 -0
  139. package/dist/tools/calculator-tool.js +64 -0
  140. package/dist/tools/calculator-tool.js.map +1 -0
  141. package/dist/tools/claude-code-tools.d.ts +96 -0
  142. package/dist/tools/claude-code-tools.d.ts.map +1 -0
  143. package/dist/tools/claude-code-tools.js +463 -0
  144. package/dist/tools/claude-code-tools.js.map +1 -0
  145. package/dist/tools/code-tools.d.ts +26 -0
  146. package/dist/tools/code-tools.d.ts.map +1 -0
  147. package/dist/tools/code-tools.js +82 -0
  148. package/dist/tools/code-tools.js.map +1 -0
  149. package/dist/tools/control-tool.d.ts +47 -0
  150. package/dist/tools/control-tool.d.ts.map +1 -0
  151. package/dist/tools/control-tool.js +101 -0
  152. package/dist/tools/control-tool.js.map +1 -0
  153. package/dist/tools/create-plan-tool.d.ts +29 -0
  154. package/dist/tools/create-plan-tool.d.ts.map +1 -0
  155. package/dist/tools/create-plan-tool.js +355 -0
  156. package/dist/tools/create-plan-tool.js.map +1 -0
  157. package/dist/tools/create-task-tool.d.ts +28 -0
  158. package/dist/tools/create-task-tool.d.ts.map +1 -0
  159. package/dist/tools/create-task-tool.js +254 -0
  160. package/dist/tools/create-task-tool.js.map +1 -0
  161. package/dist/tools/dataseo-tools.d.ts +38 -0
  162. package/dist/tools/dataseo-tools.d.ts.map +1 -0
  163. package/dist/tools/dataseo-tools.js +329 -0
  164. package/dist/tools/dataseo-tools.js.map +1 -0
  165. package/dist/tools/email-tools.d.ts +76 -0
  166. package/dist/tools/email-tools.d.ts.map +1 -0
  167. package/dist/tools/email-tools.js +259 -0
  168. package/dist/tools/email-tools.js.map +1 -0
  169. package/dist/tools/filesystem-tools.d.ts +77 -0
  170. package/dist/tools/filesystem-tools.d.ts.map +1 -0
  171. package/dist/tools/filesystem-tools.js +334 -0
  172. package/dist/tools/filesystem-tools.js.map +1 -0
  173. package/dist/tools/find-model-tool.d.ts +25 -0
  174. package/dist/tools/find-model-tool.d.ts.map +1 -0
  175. package/dist/tools/find-model-tool.js +236 -0
  176. package/dist/tools/find-model-tool.js.map +1 -0
  177. package/dist/tools/finish-graph-tool.d.ts +23 -0
  178. package/dist/tools/finish-graph-tool.d.ts.map +1 -0
  179. package/dist/tools/finish-graph-tool.js +46 -0
  180. package/dist/tools/finish-graph-tool.js.map +1 -0
  181. package/dist/tools/finish-step-tool.d.ts +16 -0
  182. package/dist/tools/finish-step-tool.d.ts.map +1 -0
  183. package/dist/tools/finish-step-tool.js +68 -0
  184. package/dist/tools/finish-step-tool.js.map +1 -0
  185. package/dist/tools/google-tools.d.ts +44 -0
  186. package/dist/tools/google-tools.d.ts.map +1 -0
  187. package/dist/tools/google-tools.js +176 -0
  188. package/dist/tools/google-tools.js.map +1 -0
  189. package/dist/tools/http-tools.d.ts +56 -0
  190. package/dist/tools/http-tools.d.ts.map +1 -0
  191. package/dist/tools/http-tools.js +180 -0
  192. package/dist/tools/http-tools.js.map +1 -0
  193. package/dist/tools/js-code-tool.d.ts +30 -0
  194. package/dist/tools/js-code-tool.d.ts.map +1 -0
  195. package/dist/tools/js-code-tool.js +98 -0
  196. package/dist/tools/js-code-tool.js.map +1 -0
  197. package/dist/tools/local-get-node-info-tool.d.ts +19 -0
  198. package/dist/tools/local-get-node-info-tool.d.ts.map +1 -0
  199. package/dist/tools/local-get-node-info-tool.js +75 -0
  200. package/dist/tools/local-get-node-info-tool.js.map +1 -0
  201. package/dist/tools/local-list-nodes-tool.d.ts +19 -0
  202. package/dist/tools/local-list-nodes-tool.d.ts.map +1 -0
  203. package/dist/tools/local-list-nodes-tool.js +69 -0
  204. package/dist/tools/local-list-nodes-tool.js.map +1 -0
  205. package/dist/tools/local-search-nodes-tool.d.ts +21 -0
  206. package/dist/tools/local-search-nodes-tool.d.ts.map +1 -0
  207. package/dist/tools/local-search-nodes-tool.js +111 -0
  208. package/dist/tools/local-search-nodes-tool.js.map +1 -0
  209. package/dist/tools/math-tools.d.ts +156 -0
  210. package/dist/tools/math-tools.d.ts.map +1 -0
  211. package/dist/tools/math-tools.js +422 -0
  212. package/dist/tools/math-tools.js.map +1 -0
  213. package/dist/tools/mcp-tools.d.ts +413 -0
  214. package/dist/tools/mcp-tools.d.ts.map +1 -0
  215. package/dist/tools/mcp-tools.js +618 -0
  216. package/dist/tools/mcp-tools.js.map +1 -0
  217. package/dist/tools/media-tools.d.ts +277 -0
  218. package/dist/tools/media-tools.d.ts.map +1 -0
  219. package/dist/tools/media-tools.js +682 -0
  220. package/dist/tools/media-tools.js.map +1 -0
  221. package/dist/tools/model-tools.d.ts +25 -0
  222. package/dist/tools/model-tools.d.ts.map +1 -0
  223. package/dist/tools/model-tools.js +48 -0
  224. package/dist/tools/model-tools.js.map +1 -0
  225. package/dist/tools/openai-tools.d.ts +73 -0
  226. package/dist/tools/openai-tools.d.ts.map +1 -0
  227. package/dist/tools/openai-tools.js +193 -0
  228. package/dist/tools/openai-tools.js.map +1 -0
  229. package/dist/tools/pdf-tools.d.ts +152 -0
  230. package/dist/tools/pdf-tools.d.ts.map +1 -0
  231. package/dist/tools/pdf-tools.js +339 -0
  232. package/dist/tools/pdf-tools.js.map +1 -0
  233. package/dist/tools/plan-builder-tools.d.ts +72 -0
  234. package/dist/tools/plan-builder-tools.d.ts.map +1 -0
  235. package/dist/tools/plan-builder-tools.js +438 -0
  236. package/dist/tools/plan-builder-tools.js.map +1 -0
  237. package/dist/tools/search-tools.d.ts +39 -0
  238. package/dist/tools/search-tools.d.ts.map +1 -0
  239. package/dist/tools/search-tools.js +218 -0
  240. package/dist/tools/search-tools.js.map +1 -0
  241. package/dist/tools/serp-providers/dataforseo-provider.d.ts +14 -0
  242. package/dist/tools/serp-providers/dataforseo-provider.d.ts.map +1 -0
  243. package/dist/tools/serp-providers/dataforseo-provider.js +114 -0
  244. package/dist/tools/serp-providers/dataforseo-provider.js.map +1 -0
  245. package/dist/tools/serp-providers/index.d.ts +35 -0
  246. package/dist/tools/serp-providers/index.d.ts.map +1 -0
  247. package/dist/tools/serp-providers/index.js +14 -0
  248. package/dist/tools/serp-providers/index.js.map +1 -0
  249. package/dist/tools/serp-providers/serpapi-provider.d.ts +18 -0
  250. package/dist/tools/serp-providers/serpapi-provider.d.ts.map +1 -0
  251. package/dist/tools/serp-providers/serpapi-provider.js +66 -0
  252. package/dist/tools/serp-providers/serpapi-provider.js.map +1 -0
  253. package/dist/tools/tool-registry.d.ts +9 -0
  254. package/dist/tools/tool-registry.d.ts.map +1 -0
  255. package/dist/tools/tool-registry.js +17 -0
  256. package/dist/tools/tool-registry.js.map +1 -0
  257. package/dist/tools/vector-tools.d.ts +224 -0
  258. package/dist/tools/vector-tools.d.ts.map +1 -0
  259. package/dist/tools/vector-tools.js +582 -0
  260. package/dist/tools/vector-tools.js.map +1 -0
  261. package/dist/tools/workspace-tools.d.ts +58 -0
  262. package/dist/tools/workspace-tools.d.ts.map +1 -0
  263. package/dist/tools/workspace-tools.js +152 -0
  264. package/dist/tools/workspace-tools.js.map +1 -0
  265. package/dist/types.d.ts +65 -0
  266. package/dist/types.d.ts.map +1 -0
  267. package/dist/types.js +5 -0
  268. package/dist/types.js.map +1 -0
  269. package/dist/utils/json-parser.d.ts +15 -0
  270. package/dist/utils/json-parser.d.ts.map +1 -0
  271. package/dist/utils/json-parser.js +78 -0
  272. package/dist/utils/json-parser.js.map +1 -0
  273. package/dist/utils/remove-base64-images.d.ts +12 -0
  274. package/dist/utils/remove-base64-images.d.ts.map +1 -0
  275. package/dist/utils/remove-base64-images.js +20 -0
  276. package/dist/utils/remove-base64-images.js.map +1 -0
  277. package/dist/utils/wrap-generators-parallel.d.ts +11 -0
  278. package/dist/utils/wrap-generators-parallel.d.ts.map +1 -0
  279. package/dist/utils/wrap-generators-parallel.js +38 -0
  280. package/dist/utils/wrap-generators-parallel.js.map +1 -0
  281. package/package.json +65 -0
@@ -0,0 +1,654 @@
1
+ /**
2
+ * Shared sandboxed JavaScript execution engine.
3
+ *
4
+ * Used by both the MiniJSAgentTool (agent tool) and the CodeNode (workflow node).
5
+ * Runs user code in an isolated QuickJS WebAssembly context — the guest has its
6
+ * own heap inside the WASM instance, so there is a real memory/CPU boundary
7
+ * between host and guest (unlike Node's `node:vm`, which shares the V8 heap).
8
+ *
9
+ * The exposed surface is a small curated one: vanilla JavaScript plus a handful
10
+ * of bridge functions (`fetch`, `workspace`, `getSecret`, `uuid`, `sleep`,
11
+ * `assetToSandbox`, `sandboxToAsset`, `console`). Library-powered helpers
12
+ * (lodash, dayjs, cheerio, csv-parse,
13
+ * validator) are intentionally NOT exposed here — use the dedicated workflow
14
+ * nodes instead (lib.datetime.*, lib.html.*, lib.data.ParseCSV,
15
+ * lib.validate.*, etc.). Keeping the sandbox lib-free makes snippet behaviour
16
+ * identical between dev and packaged Electron, and avoids shipping those
17
+ * packages into the user-code surface.
18
+ */
19
+ import { addSerializer, expose, loadQuickJs } from "@sebastianwessel/quickjs";
20
+ // The variant package uses a `default` export. With `esModuleInterop` this
21
+ // typechecks as a namespace, so reach through `.default` explicitly.
22
+ import * as quickJsVariantModule from "@jitl/quickjs-ng-wasmfile-release-sync";
23
+ const quickJsVariant = quickJsVariantModule.default;
24
+ import { Scope } from "quickjs-emscripten-core";
25
+ // ---------------------------------------------------------------------------
26
+ // Constants
27
+ // ---------------------------------------------------------------------------
28
+ export const DEFAULT_TIMEOUT_MS = 30_000;
29
+ export const MAX_OUTPUT_SIZE = 100_000;
30
+ export const MAX_LOOP_ITERATIONS = 10_000;
31
+ export const MAX_FETCH_CALLS = 20;
32
+ export const MAX_RESPONSE_BODY_SIZE = 1_000_000;
33
+ /** Guest heap cap. QuickJS aborts if the guest tries to allocate beyond this. */
34
+ export const GUEST_MEMORY_LIMIT = 64 * 1024 * 1024;
35
+ /** Guest stack cap — protects against deeply recursive code. */
36
+ export const GUEST_STACK_LIMIT = 512 * 1024;
37
+ // ---------------------------------------------------------------------------
38
+ // Engine bootstrap — one WASM module shared by every invocation.
39
+ // ---------------------------------------------------------------------------
40
+ let enginePromise = null;
41
+ let serializersRegistered = false;
42
+ function registerTypedArraySerializers() {
43
+ if (serializersRegistered)
44
+ return;
45
+ serializersRegistered = true;
46
+ // Map every typed-array class to a native Uint8Array on the host side.
47
+ // The guest returns `new Uint8Array([...])` (or friends); without this,
48
+ // the library's generic object serializer produces a plain object with
49
+ // numeric keys, which downstream code (CodeNode's normalizeOutput) would
50
+ // miss when detecting binary values.
51
+ const typedArrayNames = [
52
+ "Uint8Array",
53
+ "Int8Array",
54
+ "Uint8ClampedArray",
55
+ "Int16Array",
56
+ "Uint16Array",
57
+ "Int32Array",
58
+ "Uint32Array",
59
+ "Float32Array",
60
+ "Float64Array"
61
+ ];
62
+ for (const name of typedArrayNames) {
63
+ addSerializer(name, (ctx, handle) => {
64
+ const bufferHandle = ctx.getProp(handle, "buffer");
65
+ try {
66
+ const ab = ctx.getArrayBuffer(bufferHandle);
67
+ return Uint8Array.from(ab.value);
68
+ }
69
+ finally {
70
+ bufferHandle.dispose();
71
+ }
72
+ });
73
+ }
74
+ }
75
+ function getEngine() {
76
+ registerTypedArraySerializers();
77
+ if (!enginePromise) {
78
+ enginePromise = loadQuickJs(quickJsVariant);
79
+ }
80
+ return enginePromise;
81
+ }
82
+ /**
83
+ * Marker key placed on an object to signal a sandboxed error. A host async
84
+ * function that would normally `throw` instead resolves with one of these
85
+ * objects; a prelude inside the guest rewraps them as real guest-side errors.
86
+ *
87
+ * This indirection exists because the current `@sebastianwessel/quickjs`
88
+ * runtime leaks handles whenever a host-backed guest Promise is *rejected*,
89
+ * tripping an internal assertion (`list_empty(&rt->gc_obj_list)`) in
90
+ * quickjs-ng when the runtime is freed. Routing failures through a resolved
91
+ * tagged value sidesteps the leak while preserving the guest-visible
92
+ * behaviour (the user still gets a thrown Error with name + message).
93
+ */
94
+ const SANDBOX_ERROR_MARKER = "__nodetool_sandbox_error__";
95
+ function neverReject(fn) {
96
+ return async (...args) => {
97
+ try {
98
+ return await fn(...args);
99
+ }
100
+ catch (e) {
101
+ return {
102
+ [SANDBOX_ERROR_MARKER]: true,
103
+ name: e instanceof Error ? e.name : "Error",
104
+ message: e instanceof Error ? e.message : String(e)
105
+ };
106
+ }
107
+ };
108
+ }
109
+ // ---------------------------------------------------------------------------
110
+ // Helpers
111
+ // ---------------------------------------------------------------------------
112
+ export function truncate(text, max) {
113
+ if (text.length <= max)
114
+ return text;
115
+ return text.slice(0, max) + "\n...[truncated]";
116
+ }
117
+ function formatArg(arg) {
118
+ if (arg === null)
119
+ return "null";
120
+ if (arg === undefined)
121
+ return "undefined";
122
+ if (typeof arg === "string")
123
+ return arg;
124
+ try {
125
+ return JSON.stringify(arg, null, 2);
126
+ }
127
+ catch {
128
+ return String(arg);
129
+ }
130
+ }
131
+ function isTypedArray(value) {
132
+ if (!value || typeof value !== "object")
133
+ return false;
134
+ const name = value.constructor?.name;
135
+ return name === "Uint8Array" || name === "Buffer" ||
136
+ name === "Int8Array" || name === "Uint8ClampedArray" ||
137
+ name === "Int16Array" || name === "Uint16Array" ||
138
+ name === "Int32Array" || name === "Uint32Array" ||
139
+ name === "Float32Array" || name === "Float64Array" ||
140
+ name === "ArrayBuffer";
141
+ }
142
+ function toNativeUint8Array(value) {
143
+ const v = value;
144
+ const len = v.length ?? v.byteLength ?? 0;
145
+ const arr = new Uint8Array(len);
146
+ for (let i = 0; i < len; i++)
147
+ arr[i] = v[i] ?? 0;
148
+ return arr;
149
+ }
150
+ /**
151
+ * Recursively serialize a value returned from the sandbox, converting typed
152
+ * arrays to native Uint8Array and enforcing output size limits.
153
+ */
154
+ export function serializeResult(result) {
155
+ if (result === undefined)
156
+ return null;
157
+ if (result === null)
158
+ return null;
159
+ if (typeof result === "string" ||
160
+ typeof result === "number" ||
161
+ typeof result === "boolean") {
162
+ if (typeof result === "string" && result.length > MAX_OUTPUT_SIZE) {
163
+ return truncate(result, MAX_OUTPUT_SIZE);
164
+ }
165
+ return result;
166
+ }
167
+ if (isTypedArray(result)) {
168
+ return toNativeUint8Array(result);
169
+ }
170
+ if (typeof result === "object") {
171
+ let hasBinary = false;
172
+ if (Array.isArray(result)) {
173
+ hasBinary = result.some(isTypedArray);
174
+ }
175
+ else {
176
+ for (const v of Object.values(result)) {
177
+ if (isTypedArray(v)) {
178
+ hasBinary = true;
179
+ break;
180
+ }
181
+ }
182
+ }
183
+ if (hasBinary) {
184
+ if (Array.isArray(result)) {
185
+ return result.map(v => isTypedArray(v) ? toNativeUint8Array(v) : v);
186
+ }
187
+ const obj = result;
188
+ const out = {};
189
+ for (const [k, v] of Object.entries(obj)) {
190
+ out[k] = isTypedArray(v) ? toNativeUint8Array(v) : v;
191
+ }
192
+ return out;
193
+ }
194
+ try {
195
+ const json = JSON.stringify(result);
196
+ if (json.length > MAX_OUTPUT_SIZE) {
197
+ return truncate(json, MAX_OUTPUT_SIZE);
198
+ }
199
+ return JSON.parse(json);
200
+ }
201
+ catch {
202
+ return String(result);
203
+ }
204
+ }
205
+ return String(result);
206
+ }
207
+ /**
208
+ * Trim engine/library frames from a stack trace so the user sees only their
209
+ * own code. Keeps QuickJS frames (`user-code`, `<evalScript>`, `<anonymous>`)
210
+ * and legacy Node frames (`evalmachine`, `agent-js`).
211
+ */
212
+ export function cleanStack(stack) {
213
+ return stack
214
+ .split("\n")
215
+ .filter((line) => {
216
+ if (line.includes("user-code") ||
217
+ line.includes("<evalScript>") ||
218
+ line.includes("agent-js") ||
219
+ line.includes("evalmachine")) {
220
+ return true;
221
+ }
222
+ if (line.includes("node:") || line.includes("node_modules"))
223
+ return false;
224
+ return true;
225
+ })
226
+ .slice(0, 5)
227
+ .join("\n");
228
+ }
229
+ /**
230
+ * Build a sandbox descriptor: a record of host-side bindings plus a `getLogs`
231
+ * closure that retrieves captured console output. `runInSandbox` feeds this
232
+ * record into a QuickJS context via `expose()`.
233
+ *
234
+ * @param context Optional ProcessingContext — when provided, enables
235
+ * `workspace.*` and `getSecret()` APIs.
236
+ */
237
+ export function buildSandbox(context) {
238
+ const logs = [];
239
+ let fetchCount = 0;
240
+ const console = {
241
+ log: (...args) => {
242
+ logs.push(args.map(formatArg).join(" "));
243
+ },
244
+ warn: (...args) => {
245
+ logs.push("[warn] " + args.map(formatArg).join(" "));
246
+ },
247
+ error: (...args) => {
248
+ logs.push("[error] " + args.map(formatArg).join(" "));
249
+ },
250
+ info: (...args) => {
251
+ logs.push("[info] " + args.map(formatArg).join(" "));
252
+ }
253
+ };
254
+ const sandboxedFetch = async (url, options) => {
255
+ fetchCount++;
256
+ if (fetchCount > MAX_FETCH_CALLS) {
257
+ throw new Error(`Fetch limit exceeded (max ${MAX_FETCH_CALLS} requests per execution)`);
258
+ }
259
+ if (typeof url !== "string" || !url) {
260
+ throw new Error("fetch: url must be a non-empty string");
261
+ }
262
+ const controller = new AbortController();
263
+ const timer = setTimeout(() => controller.abort(), 15_000);
264
+ try {
265
+ const fetchOptions = {
266
+ method: options?.method ?? "GET",
267
+ signal: controller.signal
268
+ };
269
+ if (options?.headers && typeof options.headers === "object") {
270
+ fetchOptions.headers = options.headers;
271
+ }
272
+ if (options?.body !== undefined) {
273
+ fetchOptions.body =
274
+ typeof options.body === "string"
275
+ ? options.body
276
+ : JSON.stringify(options.body);
277
+ }
278
+ const response = await fetch(url, fetchOptions);
279
+ const rawBytes = new Uint8Array(await response.arrayBuffer());
280
+ const ok = response.ok;
281
+ const status = response.status;
282
+ const statusText = response.statusText;
283
+ const headers = Object.fromEntries(response.headers.entries());
284
+ let cachedText = null;
285
+ const getText = () => {
286
+ if (cachedText === null) {
287
+ const decoded = new TextDecoder().decode(rawBytes);
288
+ cachedText =
289
+ decoded.length > MAX_RESPONSE_BODY_SIZE
290
+ ? decoded.slice(0, MAX_RESPONSE_BODY_SIZE) + "...[truncated]"
291
+ : decoded;
292
+ }
293
+ return cachedText;
294
+ };
295
+ let parsedJson;
296
+ try {
297
+ parsedJson = JSON.parse(getText());
298
+ }
299
+ catch {
300
+ parsedJson = undefined;
301
+ }
302
+ return {
303
+ ok,
304
+ status,
305
+ statusText,
306
+ headers,
307
+ body: getText(),
308
+ json: parsedJson,
309
+ text: async () => getText(),
310
+ arrayBuffer: async () => rawBytes.buffer.slice(rawBytes.byteOffset, rawBytes.byteOffset + rawBytes.byteLength),
311
+ bytes: async () => rawBytes
312
+ };
313
+ }
314
+ finally {
315
+ clearTimeout(timer);
316
+ }
317
+ };
318
+ const uuid = () => crypto.randomUUID();
319
+ const getSecret = context
320
+ ? async (name) => {
321
+ return (await context.getSecret(name)) ?? undefined;
322
+ }
323
+ : async (_name) => {
324
+ return undefined;
325
+ };
326
+ const workspace = context
327
+ ? {
328
+ read: async (path) => {
329
+ const fullPath = context.resolveWorkspacePath(path);
330
+ const { readFile } = await import("node:fs/promises");
331
+ return readFile(fullPath, "utf-8");
332
+ },
333
+ write: async (path, content) => {
334
+ const fullPath = context.resolveWorkspacePath(path);
335
+ const { writeFile, mkdir } = await import("node:fs/promises");
336
+ const { dirname } = await import("node:path");
337
+ await mkdir(dirname(fullPath), { recursive: true });
338
+ await writeFile(fullPath, content, "utf-8");
339
+ },
340
+ list: async (path) => {
341
+ const fullPath = context.resolveWorkspacePath(path);
342
+ const { readdir } = await import("node:fs/promises");
343
+ return readdir(fullPath);
344
+ }
345
+ }
346
+ : {
347
+ read: async (_path) => {
348
+ throw new Error("workspace.read is not available without a context");
349
+ },
350
+ write: async (_path, _content) => {
351
+ throw new Error("workspace.write is not available without a context");
352
+ },
353
+ list: async (_path) => {
354
+ throw new Error("workspace.list is not available without a context");
355
+ }
356
+ };
357
+ const sleep = (ms) => {
358
+ const capped = Math.min(ms, 5000);
359
+ return new Promise((resolve) => setTimeout(resolve, capped));
360
+ };
361
+ const assetToSandbox = context
362
+ ? async (assetId, path) => {
363
+ return context.assetToSandbox(assetId, path);
364
+ }
365
+ : async (_assetId, _path) => {
366
+ throw new Error("assetToSandbox is not available without a context");
367
+ };
368
+ const sandboxToAsset = context
369
+ ? async (path) => {
370
+ return context.sandboxToAsset(path);
371
+ }
372
+ : async (_path) => {
373
+ throw new Error("sandboxToAsset is not available without a context");
374
+ };
375
+ const sandbox = {
376
+ // Core JS globals are native in QuickJS; we still reflect them in the
377
+ // descriptor so callers that inspect `sandbox.JSON` / `sandbox.Math`
378
+ // (tests, debug tooling) see the expected references.
379
+ console,
380
+ JSON,
381
+ Math,
382
+ Date,
383
+ RegExp,
384
+ Array,
385
+ Object,
386
+ String,
387
+ Number,
388
+ Boolean,
389
+ Map,
390
+ Set,
391
+ WeakMap,
392
+ WeakSet,
393
+ Symbol,
394
+ Promise,
395
+ Error,
396
+ TypeError,
397
+ RangeError,
398
+ URIError,
399
+ SyntaxError,
400
+ parseInt,
401
+ parseFloat,
402
+ isNaN,
403
+ isFinite,
404
+ encodeURIComponent,
405
+ decodeURIComponent,
406
+ encodeURI,
407
+ decodeURI,
408
+ btoa: globalThis.btoa,
409
+ atob: globalThis.atob,
410
+ structuredClone: globalThis.structuredClone,
411
+ TextEncoder: globalThis.TextEncoder,
412
+ TextDecoder: globalThis.TextDecoder,
413
+ URL: globalThis.URL,
414
+ URLSearchParams: globalThis.URLSearchParams,
415
+ // Async primitives blocked — use sleep() instead.
416
+ setTimeout: undefined,
417
+ setInterval: undefined,
418
+ // Bridge functions — the only non-native surface the sandbox exposes.
419
+ fetch: sandboxedFetch,
420
+ uuid,
421
+ sleep,
422
+ getSecret,
423
+ workspace,
424
+ assetToSandbox,
425
+ sandboxToAsset,
426
+ __maxIter: MAX_LOOP_ITERATIONS
427
+ };
428
+ return { sandbox, getLogs: () => logs };
429
+ }
430
+ // ---------------------------------------------------------------------------
431
+ // Code execution
432
+ // ---------------------------------------------------------------------------
433
+ /**
434
+ * Wrap user code as the default export of an ES module with a top-level-awaited
435
+ * async IIFE body, so `return <value>` inside the snippet becomes the module's
436
+ * default export and `await` at the top level works.
437
+ */
438
+ export function wrapCode(code) {
439
+ return `export default await (async () => {
440
+ ${code}
441
+ })();`;
442
+ }
443
+ const IDENTIFIER_RE = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
444
+ /** Overwrite the contents of `target` with the contents of `source` in place. */
445
+ function replaceInPlace(target, source) {
446
+ if (Array.isArray(target)) {
447
+ target.length = 0;
448
+ if (Array.isArray(source)) {
449
+ for (let i = 0; i < source.length; i++)
450
+ target[i] = source[i];
451
+ }
452
+ return;
453
+ }
454
+ if (target && typeof target === "object") {
455
+ const t = target;
456
+ for (const key of Object.keys(t))
457
+ delete t[key];
458
+ if (source && typeof source === "object" && !Array.isArray(source)) {
459
+ const s = source;
460
+ for (const [k, v] of Object.entries(s))
461
+ t[k] = v;
462
+ }
463
+ }
464
+ }
465
+ /** Names that should never be reassigned via `globals` — core sandbox APIs. */
466
+ const RESERVED_SANDBOX_NAMES = new Set([
467
+ "console",
468
+ "fetch",
469
+ "uuid",
470
+ "sleep",
471
+ "getSecret",
472
+ "workspace",
473
+ "assetToSandbox",
474
+ "sandboxToAsset",
475
+ "__maxIter"
476
+ ]);
477
+ /**
478
+ * Names injected as bridge bindings into the QuickJS guest. The rest of the
479
+ * `buildSandbox` record (JSON, Math, Date, URL, etc.) is deliberately NOT
480
+ * marshaled — QuickJS already provides native implementations, and re-exposing
481
+ * host versions creates thousands of handles that slow execution and leak on
482
+ * teardown.
483
+ */
484
+ const EXPOSED_BRIDGE_NAMES = [
485
+ "console",
486
+ "fetch",
487
+ "uuid",
488
+ "sleep",
489
+ "getSecret",
490
+ "workspace",
491
+ "assetToSandbox",
492
+ "sandboxToAsset",
493
+ "__maxIter"
494
+ ];
495
+ /**
496
+ * Execute JavaScript code inside a QuickJS WebAssembly sandbox.
497
+ *
498
+ * The runtime enforces hard memory and CPU limits via QuickJS's own interrupt
499
+ * handler / memory limiter, so runaway user code can't exhaust host resources.
500
+ */
501
+ export async function runInSandbox(options) {
502
+ const { code, context, timeoutMs = DEFAULT_TIMEOUT_MS, globals } = options;
503
+ if (!code.trim()) {
504
+ return { success: false, error: "No code provided", logs: [] };
505
+ }
506
+ const { sandbox, getLogs } = buildSandbox(context);
507
+ // User-supplied globals (dynamic inputs from CodeNode etc.) layer on top of
508
+ // the core surface, but must not clobber the bridge functions themselves.
509
+ const userGlobals = {};
510
+ if (globals) {
511
+ for (const [key, value] of Object.entries(globals)) {
512
+ if (RESERVED_SANDBOX_NAMES.has(key))
513
+ continue;
514
+ if (!IDENTIFIER_RE.test(key))
515
+ continue;
516
+ userGlobals[key] = value;
517
+ }
518
+ }
519
+ // Identify object-typed globals whose contents should be synced back to the
520
+ // host after the guest runs. Primitives are passed by value and need no sync.
521
+ const syncTargetNames = Object.entries(userGlobals)
522
+ .filter(([, v]) => v !== null && typeof v === "object")
523
+ .map(([k]) => k);
524
+ try {
525
+ const { runSandboxed } = await getEngine();
526
+ const evalResponse = await runSandboxed(async ({ ctx, evalCode }) => {
527
+ const bridges = {};
528
+ for (const name of EXPOSED_BRIDGE_NAMES) {
529
+ bridges[name] = sandbox[name];
530
+ }
531
+ // Wrap every async bridge in a never-reject adapter (see
532
+ // SANDBOX_ERROR_MARKER above). The guest prelude rewraps them back into
533
+ // throwing functions before user code runs.
534
+ bridges.fetch = neverReject(bridges.fetch);
535
+ bridges.sleep = neverReject(bridges.sleep);
536
+ bridges.getSecret = neverReject(bridges.getSecret);
537
+ bridges.assetToSandbox = neverReject(bridges.assetToSandbox);
538
+ bridges.sandboxToAsset = neverReject(bridges.sandboxToAsset);
539
+ const ws = bridges.workspace;
540
+ bridges.workspace = {
541
+ read: neverReject(ws.read),
542
+ write: neverReject(ws.write),
543
+ list: neverReject(ws.list)
544
+ };
545
+ Object.assign(bridges, userGlobals);
546
+ // `expose` manages its own internal Scope; the second arg is unused.
547
+ const disposable = new Scope();
548
+ try {
549
+ expose(ctx, disposable, bridges);
550
+ }
551
+ finally {
552
+ disposable.dispose();
553
+ }
554
+ // Block dynamic code generation and re-wrap the never-reject bridges as
555
+ // throwing guest-side functions. Direct eval in QuickJS can't be neutered
556
+ // by overwriting `globalThis.eval` (QuickJS still resolves the builtin),
557
+ // but a plain `delete` removes the binding entirely so any reference
558
+ // throws ReferenceError — same for `Function`.
559
+ await evalCode(`const __marker = "${SANDBOX_ERROR_MARKER}";
560
+ const __wrap = (fn) => async (...args) => {
561
+ const r = await fn(...args);
562
+ if (r && r[__marker]) {
563
+ const e = new Error(r.message);
564
+ e.name = r.name;
565
+ throw e;
566
+ }
567
+ return r;
568
+ };
569
+ globalThis.fetch = __wrap(globalThis.fetch);
570
+ globalThis.sleep = __wrap(globalThis.sleep);
571
+ globalThis.getSecret = __wrap(globalThis.getSecret);
572
+ globalThis.assetToSandbox = __wrap(globalThis.assetToSandbox);
573
+ globalThis.sandboxToAsset = __wrap(globalThis.sandboxToAsset);
574
+ const __ws = globalThis.workspace;
575
+ globalThis.workspace = {
576
+ read: __wrap(__ws.read),
577
+ write: __wrap(__ws.write),
578
+ list: __wrap(__ws.list)
579
+ };
580
+ delete globalThis.eval;
581
+ delete globalThis.Function;
582
+ export default true;`, "sandbox-init");
583
+ const userResult = await evalCode(wrapCode(code), "user-code");
584
+ // Sync mutable globals back to the host. node:vm shared the host heap,
585
+ // so `state.counter++` in user code mutated the caller's object directly.
586
+ // With QuickJS the guest heap is isolated, so after user code runs we
587
+ // extract the current values of the object-typed user globals and
588
+ // replace the contents of the host-side objects in place. CodeNode
589
+ // relies on this to make its `state` object persist across invocations.
590
+ if (userResult.ok && syncTargetNames.length > 0) {
591
+ const extractor = `export default {${syncTargetNames
592
+ .map((n) => `${n}: (typeof ${n} !== 'undefined' && ${n} !== null) ? ${n} : null`)
593
+ .join(", ")}};`;
594
+ const syncResp = await evalCode(extractor, "sandbox-sync");
595
+ if (syncResp.ok && syncResp.data && typeof syncResp.data === "object") {
596
+ const extracted = syncResp.data;
597
+ for (const name of syncTargetNames) {
598
+ const hostValue = userGlobals[name];
599
+ const guestValue = extracted[name];
600
+ if (hostValue !== null &&
601
+ typeof hostValue === "object" &&
602
+ guestValue !== null &&
603
+ typeof guestValue === "object") {
604
+ replaceInPlace(hostValue, guestValue);
605
+ }
606
+ }
607
+ }
608
+ }
609
+ return userResult;
610
+ }, {
611
+ executionTimeout: timeoutMs,
612
+ memoryLimit: GUEST_MEMORY_LIMIT,
613
+ maxStackSize: GUEST_STACK_LIMIT
614
+ });
615
+ const logs = getLogs();
616
+ if (!evalResponse.ok) {
617
+ // Include the error name alongside the message when the name carries
618
+ // useful signal (e.g. `ExecutionTimeout` for the library's wall-clock
619
+ // abort). `Error` is redundant, so omit it.
620
+ const name = evalResponse.error.name;
621
+ const message = evalResponse.error.message;
622
+ const combined = name && name !== "Error" && !message.toLowerCase().includes(name.toLowerCase())
623
+ ? `${name}: ${message}`
624
+ : message || name;
625
+ return {
626
+ success: false,
627
+ error: combined,
628
+ stack: evalResponse.error.stack
629
+ ? cleanStack(evalResponse.error.stack)
630
+ : undefined,
631
+ logs: logs.length > 0 ? logs : undefined
632
+ };
633
+ }
634
+ return {
635
+ success: true,
636
+ result: serializeResult(evalResponse.data),
637
+ logs: logs.length > 0 ? logs : undefined
638
+ };
639
+ }
640
+ catch (e) {
641
+ // Host-side failures (engine load error, marshaling bug, etc.). Guest-side
642
+ // errors go through evalResponse.ok=false above.
643
+ const logs = getLogs();
644
+ const errorMessage = e instanceof Error ? e.message : String(e);
645
+ const errorStack = e instanceof Error ? cleanStack(e.stack ?? "") : undefined;
646
+ return {
647
+ success: false,
648
+ error: errorMessage,
649
+ stack: errorStack,
650
+ logs: logs.length > 0 ? logs : undefined
651
+ };
652
+ }
653
+ }
654
+ //# sourceMappingURL=js-sandbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js-sandbox.js","sourceRoot":"","sources":["../src/js-sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,aAAa,EACb,MAAM,EACN,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,2EAA2E;AAC3E,qEAAqE;AACrE,OAAO,KAAK,oBAAoB,MAAM,wCAAwC,CAAC;AAC/E,MAAM,cAAc,GAAI,oBAEtB,CAAC,OAAO,CAAC;AACX,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGhD,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAChD,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,CAAC;AAE5C,8EAA8E;AAC9E,iEAAiE;AACjE,8EAA8E;AAE9E,IAAI,aAAa,GAA0C,IAAI,CAAC;AAChE,IAAI,qBAAqB,GAAG,KAAK,CAAC;AAElC,SAAS,6BAA6B;IACpC,IAAI,qBAAqB;QAAE,OAAO;IAClC,qBAAqB,GAAG,IAAI,CAAC;IAE7B,uEAAuE;IACvE,wEAAwE;IACxE,uEAAuE;IACvE,yEAAyE;IACzE,qCAAqC;IACrC,MAAM,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