@namzu/sdk 50.0.0 → 51.0.0

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 (133) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/execution/code-runtime/types.d.ts +35 -0
  3. package/dist/execution/code-runtime/types.d.ts.map +1 -1
  4. package/dist/execution/code-runtime/types.js.map +1 -1
  5. package/dist/execution/code-runtime/worker-program.d.ts +1 -1
  6. package/dist/execution/code-runtime/worker-program.d.ts.map +1 -1
  7. package/dist/execution/code-runtime/worker-program.js +72 -13
  8. package/dist/execution/code-runtime/worker-program.js.map +1 -1
  9. package/dist/execution/code-runtime/worker.d.ts.map +1 -1
  10. package/dist/execution/code-runtime/worker.js +35 -1
  11. package/dist/execution/code-runtime/worker.js.map +1 -1
  12. package/dist/execution/workflow/errors.d.ts +5 -0
  13. package/dist/execution/workflow/errors.d.ts.map +1 -0
  14. package/dist/execution/workflow/errors.js +8 -0
  15. package/dist/execution/workflow/errors.js.map +1 -0
  16. package/dist/execution/workflow/index.d.ts +9 -0
  17. package/dist/execution/workflow/index.d.ts.map +1 -0
  18. package/dist/execution/workflow/index.js +6 -0
  19. package/dist/execution/workflow/index.js.map +1 -0
  20. package/dist/execution/workflow/journal.d.ts +18 -0
  21. package/dist/execution/workflow/journal.d.ts.map +1 -0
  22. package/dist/execution/workflow/journal.js +43 -0
  23. package/dist/execution/workflow/journal.js.map +1 -0
  24. package/dist/execution/workflow/meta.d.ts +14 -0
  25. package/dist/execution/workflow/meta.d.ts.map +1 -0
  26. package/dist/execution/workflow/meta.js +314 -0
  27. package/dist/execution/workflow/meta.js.map +1 -0
  28. package/dist/execution/workflow/phases.d.ts +32 -0
  29. package/dist/execution/workflow/phases.d.ts.map +1 -0
  30. package/dist/execution/workflow/phases.js +57 -0
  31. package/dist/execution/workflow/phases.js.map +1 -0
  32. package/dist/execution/workflow/prelude.d.ts +15 -0
  33. package/dist/execution/workflow/prelude.d.ts.map +1 -0
  34. package/dist/execution/workflow/prelude.js +128 -0
  35. package/dist/execution/workflow/prelude.js.map +1 -0
  36. package/dist/execution/workflow/runtime.d.ts +31 -0
  37. package/dist/execution/workflow/runtime.d.ts.map +1 -0
  38. package/dist/execution/workflow/runtime.js +682 -0
  39. package/dist/execution/workflow/runtime.js.map +1 -0
  40. package/dist/execution/workflow/schema.d.ts +10 -0
  41. package/dist/execution/workflow/schema.d.ts.map +1 -0
  42. package/dist/execution/workflow/schema.js +145 -0
  43. package/dist/execution/workflow/schema.js.map +1 -0
  44. package/dist/execution/workflow/types.d.ts +267 -0
  45. package/dist/execution/workflow/types.d.ts.map +1 -0
  46. package/dist/execution/workflow/types.js +7 -0
  47. package/dist/execution/workflow/types.js.map +1 -0
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1 -0
  51. package/dist/index.js.map +1 -1
  52. package/dist/plugin/shell-hook.d.ts.map +1 -1
  53. package/dist/plugin/shell-hook.js +2 -1
  54. package/dist/plugin/shell-hook.js.map +1 -1
  55. package/dist/process/kill-tree.d.ts +7 -0
  56. package/dist/process/kill-tree.d.ts.map +1 -1
  57. package/dist/process/kill-tree.js +41 -0
  58. package/dist/process/kill-tree.js.map +1 -1
  59. package/dist/provider/strict-schema.d.ts +28 -0
  60. package/dist/provider/strict-schema.d.ts.map +1 -1
  61. package/dist/provider/strict-schema.js +86 -0
  62. package/dist/provider/strict-schema.js.map +1 -1
  63. package/dist/provider/token-budget.d.ts.map +1 -1
  64. package/dist/provider/token-budget.js +31 -2
  65. package/dist/provider/token-budget.js.map +1 -1
  66. package/dist/public-runtime.d.ts +2 -1
  67. package/dist/public-runtime.d.ts.map +1 -1
  68. package/dist/public-runtime.js +4 -1
  69. package/dist/public-runtime.js.map +1 -1
  70. package/dist/public-tools.d.ts +1 -1
  71. package/dist/public-tools.d.ts.map +1 -1
  72. package/dist/public-tools.js +1 -1
  73. package/dist/public-tools.js.map +1 -1
  74. package/dist/public-types.d.ts +3 -0
  75. package/dist/public-types.d.ts.map +1 -1
  76. package/dist/runtime/jobs/job-id.d.ts +21 -0
  77. package/dist/runtime/jobs/job-id.d.ts.map +1 -0
  78. package/dist/runtime/jobs/job-id.js +66 -0
  79. package/dist/runtime/jobs/job-id.js.map +1 -0
  80. package/dist/runtime/jobs/registry.d.ts +0 -1
  81. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  82. package/dist/runtime/jobs/registry.js +2 -3
  83. package/dist/runtime/jobs/registry.js.map +1 -1
  84. package/dist/runtime/query/prompt.d.ts.map +1 -1
  85. package/dist/runtime/query/prompt.js +5 -1
  86. package/dist/runtime/query/prompt.js.map +1 -1
  87. package/dist/tools/builtins/bash.d.ts +8 -1
  88. package/dist/tools/builtins/bash.d.ts.map +1 -1
  89. package/dist/tools/builtins/bash.js +20 -3
  90. package/dist/tools/builtins/bash.js.map +1 -1
  91. package/dist/tools/builtins/edit.d.ts.map +1 -1
  92. package/dist/tools/builtins/edit.js +12 -1
  93. package/dist/tools/builtins/edit.js.map +1 -1
  94. package/dist/tools/builtins/job.d.ts.map +1 -1
  95. package/dist/tools/builtins/job.js +4 -0
  96. package/dist/tools/builtins/job.js.map +1 -1
  97. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  98. package/dist/tools/builtins/wait-for-job.js +4 -0
  99. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  100. package/dist/tools/command-shell.d.ts +55 -0
  101. package/dist/tools/command-shell.d.ts.map +1 -1
  102. package/dist/tools/command-shell.js +174 -13
  103. package/dist/tools/command-shell.js.map +1 -1
  104. package/package.json +1 -1
  105. package/src/agents/AGENTS.md +134 -46
  106. package/src/execution/code-runtime/types.ts +37 -1
  107. package/src/execution/code-runtime/worker-program.ts +72 -13
  108. package/src/execution/code-runtime/worker.ts +40 -1
  109. package/src/execution/workflow/errors.ts +7 -0
  110. package/src/execution/workflow/index.ts +8 -0
  111. package/src/execution/workflow/journal.ts +46 -0
  112. package/src/execution/workflow/meta.ts +316 -0
  113. package/src/execution/workflow/phases.ts +91 -0
  114. package/src/execution/workflow/prelude.ts +135 -0
  115. package/src/execution/workflow/runtime.ts +786 -0
  116. package/src/execution/workflow/schema.ts +137 -0
  117. package/src/execution/workflow/types.ts +300 -0
  118. package/src/index.ts +4 -0
  119. package/src/plugin/shell-hook.ts +2 -1
  120. package/src/process/kill-tree.ts +43 -0
  121. package/src/provider/strict-schema.ts +90 -0
  122. package/src/provider/token-budget.ts +31 -1
  123. package/src/public-runtime.ts +12 -0
  124. package/src/public-tools.ts +6 -0
  125. package/src/public-types.ts +3 -0
  126. package/src/runtime/jobs/job-id.ts +66 -0
  127. package/src/runtime/jobs/registry.ts +2 -3
  128. package/src/runtime/query/prompt.ts +5 -1
  129. package/src/tools/builtins/bash.ts +33 -3
  130. package/src/tools/builtins/edit.ts +12 -1
  131. package/src/tools/builtins/job.ts +4 -0
  132. package/src/tools/builtins/wait-for-job.ts +4 -0
  133. package/src/tools/command-shell.ts +194 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## 51.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 28eaee1: On Windows the `bash` tool, background jobs started with `run_in_background`, and plugin shell hooks now run in Git for Windows' bash instead of cmd.exe whenever Git for Windows is installed, and `hostCommandShell()` and `BashTool.commandDialect()` answer `bash` there instead of `cmd`. Before, every command a model wrote was refused or needed a person to approve it each time, because the permission rules cannot read cmd.exe lines. Git Bash is looked up as `NAMZU_BASH_SHELL`, then `%ProgramFiles%\Git\bin\bash.exe`, then `%ProgramFiles(x86)%\Git\bin\bash.exe`, then `%LOCALAPPDATA%\Programs\Git\bin\bash.exe`, then the install holding the first `git` that `where.exe git` lists outside the working directory. Commands now need Unix syntax (`/dev/null`, forward slashes, `$VAR`); the model is told so, and `>nul` is rewritten to `/dev/null`. A host that depends on cmd.exe syntax in the `bash` tool, or on `hostCommandShell().dialect === 'cmd'` on a machine with Git for Windows, sets `NAMZU_BASH_SHELL=cmd` (a path to `cmd.exe`, such as `%ComSpec%`, works too) to keep the old behaviour. Without Git for Windows nothing changes except that `windowsShellNotice()` returns a sentence saying commands run in cmd.exe and each asks for approval; the CLI shows it once at session start. New exports: `findGitBash`, `isWindowsBash`, `windowsShellNotice`, `rewriteWindowsNullRedirect`, `WINDOWS_BASH_GUIDANCE`, `WINDOWS_CMD_FALLBACK_NOTICE`, and an optional `windows` flag on `CommandShell`. Stopping a command or job on Windows now also ends processes that Git Bash forked, which `taskkill /T` alone missed.
8
+
9
+ ### Minor Changes
10
+
11
+ - 437dd6d: The built-in background job registry now mints ids as `b` plus eight random characters from `0-9a-z` (for example `b1k3x9q2z`) instead of `job_1`, `job_2`, … counted per registry. The counter restarted in every session and after every resume, so a resumed conversation that still said `job_1` about a dead job could be answered by a different, newer `job_1`. The new ids are never reused within a registry.
12
+
13
+ Ids are opaque: a host must not parse them or rely on their shape (nothing in the types ever promised `job_<n>`). `createBackgroundJobId()` mints one for a host that supplies its own registry, and `isBackgroundJobId(id)` answers whether an id looks like one this SDK minted; neither is required. The `job` and `wait_for_job` tools do not check shape: they refuse only input that cannot be an id (empty, over 128 characters, or containing whitespace or control characters) and pass every other id to the registry, whose existing "No background job <id>." covers an unknown one. Hosts with their own registry and ids keep working unchanged.
14
+
15
+ - 437dd6d: Add `WorkflowRuntime`, which runs a model-authored workflow script: a JavaScript program, written once, that decides how many subagents run and in which order (`agent()`, `parallel()`, `pipeline()`, `phase()`, `log()`, `args`, `budget`). The script runs in the same QuickJS interpreter as `run_code`, and `agent()` is its only capability; your `spawnAgent` callback decides what starting an agent means, so it can go through the same policy and accounting as your own delegation. New exports: `WorkflowRuntime`, `parseWorkflowMeta`, `resolveWorkflowLimits`, `summarizeWorkflowPhases`, `FileWorkflowJournal`, `WorkflowScriptError` and the `Workflow*` types (events, limits, journal records, results). Nothing existing changes behaviour. `RunCodeOptions` gains two optional fields, `cpuLimits` (bound synchronous interpreter time per stretch and in total instead of the whole run's wall clock) and `onOutput` (each printed line as it is printed); a custom `CodeRuntime` may ignore both. A script that throws or does not parse fails with `error` set to the error name and message, the script line and column, that line's text, and how far the run got (agents started, finished and failed, last phase); `parallel`, `pipeline` and `agent` reject wrong argument shapes with a message naming the signature. The `failed` `CodeRunOutcome` gains optional `errorName` and `frames` (line and column in the submitted source) for a host that wants to build its own message.
16
+
17
+ ### Patch Changes
18
+
19
+ - 437dd6d: A model request that the operator cancelled on purpose (a cancel with the `user` cause, such as stopping a child or skipping a workflow agent), before the provider reported any usage, is now closed on an estimate (the prompt plus the text that had streamed) instead of being left as unknown spend. Before, stopping or skipping one delegated child under a finite token budget marked the whole budget unusable, and every sibling and every later child was refused with "0 tokens remaining". A request that fails for any other reason, or whose tree was torn down by a parent or a closing runtime, keeps its unknown-spend marker. The estimate can undercount what the provider billed for the part it never reported.
20
+
21
+ ## 50.1.0
22
+
23
+ ### Minor Changes
24
+
25
+ - 4a6ec17: Refuse to claim strict tool input generation where the wire would refuse the request.
26
+
27
+ `edit` and `write` set `enforceModelInput`, and the Zen driver answered that with
28
+ `strict: true` for both on the chat-class wires. The Zen free-tier gateway
29
+ enforces the strict subset's structural rule itself — every object that declares
30
+ `properties` must list all of them in `required` — and refuses the WHOLE request
31
+ when one tool fails, so `edit`'s optional fields (a find-and-replace OR an
32
+ insertion) took every other tool in the call down with it. `cat-jam-free` is the
33
+ model that enforces; the symptom was `Invalid schema for function 'edit'`.
34
+
35
+ - `@namzu/sdk` gains `acceptsStrictSchema(schema)`, the wider question a driver
36
+ asks before claiming `strict: true` on one request: the keyword deny-list that
37
+ `findStrictSchemaViolations` already runs, plus the structural rules, plus a
38
+ guard for a tool that declared no schema at all (the deny-list walks nothing in
39
+ `undefined` and finds nothing). It is additive; `findStrictSchemaViolations`
40
+ and `assertStrictSchema` keep the registration-time job they had.
41
+ - `@namzu/zen` now sends `strict: acceptsStrictSchema(...)` for a tool named in
42
+ `enforceToolInputSchema`, so `write` keeps the guarantee and `edit` sends
43
+ `strict: false`. Responses still sends `strict: false` for every tool, as it
44
+ did. Nothing about a schema changes, and Namzu validates tool inputs before
45
+ execution either way.
46
+ - `edit`'s `insertLine` union branch `{ const: 'end' }` states no `type`, which
47
+ the strict dialect has no spelling for; it is now `{ type: 'string', const:
48
+ 'end' }`. The validator reports any union branch that never states a type.
49
+
50
+ **What breaks.** A caller that relied on Zen sending `strict: true` for `edit`
51
+ loses constrained decoding for that one tool on the chat-class wires. To keep it,
52
+ the schema would have to require every field and make the optional ones nullable,
53
+ which changes what `edit` accepts on every provider.
54
+
3
55
  ## 50.0.0
4
56
 
5
57
  ### Major Changes
@@ -75,6 +75,32 @@ export interface RunCodeOptions {
75
75
  */
76
76
  readonly maxOutputBytes: number;
77
77
  readonly signal?: AbortSignal;
78
+ /**
79
+ * Replace the single wall-clock interrupt with a CPU budget.
80
+ *
81
+ * By default `timeoutMs` bounds synchronous interpreter execution as well
82
+ * as the whole run, so a program waiting on slow host calls is stopped at
83
+ * the same deadline as one spinning in a loop. A host that legitimately
84
+ * awaits long host operations (a workflow awaiting subagents) sets this:
85
+ * the interpreter is then interrupted when ONE synchronous slice (the time
86
+ * between entering the interpreter and handing control back) exceeds
87
+ * `sliceMs`, or all slices together exceed `totalMs`. Time spent awaiting
88
+ * the host is not counted. `timeoutMs` still bounds the run's wall clock.
89
+ */
90
+ readonly cpuLimits?: {
91
+ readonly sliceMs: number;
92
+ readonly totalMs: number;
93
+ };
94
+ /**
95
+ * Called with each line the program prints, in order, as it is printed and
96
+ * within `maxOutputBytes`. A line is data, not a capability: the callback
97
+ * must treat it as untrusted text.
98
+ */
99
+ readonly onOutput?: (line: string) => void;
100
+ }
101
+ export interface CodeFrame {
102
+ readonly line: number;
103
+ readonly column: number;
78
104
  }
79
105
  export type CodeRunOutcome = {
80
106
  readonly status: 'completed';
@@ -82,6 +108,15 @@ export type CodeRunOutcome = {
82
108
  } | {
83
109
  readonly status: 'failed';
84
110
  readonly error: string;
111
+ /** The thrown value's `name`, when it was an error object. */
112
+ readonly errorName?: string;
113
+ /**
114
+ * Where the interpreter says the program failed: innermost first, line and
115
+ * column counted in the submitted `source` (1-based). Absent when the
116
+ * interpreter gave no location (a non-error was thrown, or the failure was
117
+ * not in the program).
118
+ */
119
+ readonly frames?: readonly CodeFrame[];
85
120
  } | {
86
121
  readonly status: 'timed-out';
87
122
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/execution/code-runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC/B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,CAC7B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,eAAe,KACpB,OAAO,CAAC,cAAc,CAAC,CAAA;AAE5B,MAAM,WAAW,cAAc;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAA;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CA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AAED,gEAAgE;AAChE,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAA;gBAElD,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE;CAOjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/execution/code-runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAyFH,gEAAgE;AAChE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACpC,OAAO,CAA8C;IAE9D,YAAY,OAAqD;QAChE,KAAK,CACJ,uBAAuB,OAAO,CAAC,IAAI,2CAA2C,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAClJ,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,CAAC;CACD"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/execution/code-runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA6HH,gEAAgE;AAChE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACpC,OAAO,CAA8C;IAE9D,YAAY,OAAqD;QAChE,KAAK,CACJ,uBAAuB,OAAO,CAAC,IAAI,2CAA2C,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAClJ,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,CAAC;CACD"}
@@ -4,5 +4,5 @@
4
4
  * No Node object or callback is injected into QuickJS: its native functions
5
5
  * exchange bounded strings and interpreter-owned promise handles.
6
6
  */
7
- export declare const QUICKJS_WORKER_SOURCE = "\nconst { parentPort, workerData } = require('node:worker_threads')\nconst { newQuickJSWASMModuleFromVariant, newVariant } = require(workerData.corePath)\nconst variantModule = require(workerData.variantPath)\nconst variant = variantModule.default || variantModule\n\nasync function main() {\n\tconst limits = workerData.limits\n\tconst pages = Math.floor(limits.memoryLimitBytes / 65536)\n\tconst wasmMemory = new WebAssembly.Memory({ initial: Math.min(256, pages), maximum: pages })\n\tconst module = await newQuickJSWASMModuleFromVariant(newVariant(variant, { wasmMemory }))\n\tconst runtime = module.newRuntime()\n\truntime.setMemoryLimit(limits.memoryLimitBytes)\n\truntime.setMaxStackSize(512 * 1024)\n\truntime.setInterruptHandler(() => Date.now() >= workerData.deadline)\n\tconst vm = runtime.newContext()\n\tconst pending = new Map()\n\tlet nextId = 0\n\tlet printBytes = 0\n\tlet printCount = 0\n\tlet truncated = false\n\tlet ended = false\n\tlet pumping = false\n\tlet scheduled = false\n\tlet program\n\tconst owned = []\n\n\tfunction keep(result) {\n\t\tconst handle = vm.unwrapResult(result)\n\t\towned.push(handle)\n\t\treturn handle\n\t}\n\t// Capture intrinsics before the program may replace its own globals.\n\tconst encode = keep(vm.evalCode('(' + function () {\n\t\tconst stringify = JSON.stringify\n\t\tconst finite = Number.isFinite\n\t\tconst prototype = Object.getPrototypeOf\n\t\tconst plain = Object.prototype\n\t\tconst isArray = Array.isArray\n\t\tconst keys = Object.keys\n\t\tconst descriptor = Object.getOwnPropertyDescriptor\n\t\treturn function (value) {\n\t\t\tif (value === undefined) return undefined\n\t\t\tconst parents = new Set()\n\t\t\tfunction check(item, depth) {\n\t\t\t\tconst kind = typeof item\n\t\t\t\tif (item === null || kind === 'string' || kind === 'boolean' || (kind === 'number' && finite(item))) return\n\t\t\t\tif (kind !== 'object' || depth > 64 || parents.has(item)) throw new Error('Code runtime values must be JSON-safe.')\n\t\t\t\tif (!isArray(item) && prototype(item) !== plain && prototype(item) !== null) throw new Error('Code runtime values must use plain objects and arrays.')\n\t\t\t\tparents.add(item)\n\t\t\t\tfor (const key of keys(item)) {\n\t\t\t\t\tconst property = descriptor(item, key)\n\t\t\t\t\tif (!property || !('value' in property)) throw new Error('Code runtime values must not contain accessors.')\n\t\t\t\t\tcheck(property.value, depth + 1)\n\t\t\t\t}\n\t\t\t\tparents.delete(item)\n\t\t\t}\n\t\t\tcheck(value, 0)\n\t\t\treturn stringify(value)\n\t\t}\n\t}.toString() + ')()'))\n\tconst decode = keep(vm.evalCode('(function () { const parse = JSON.parse; return function(value) { return parse(value); }; })()'))\n\tconst errorText = keep(vm.evalCode('(function () { const string = String; return function(error) { try { return typeof error.message === \"string\" ? error.message : string(error); } catch { return \"The program failed.\"; } }; })()'))\n\n\tfunction textValue(handle, maximum) {\n\t\tconst length = vm.getProp(handle, 'length')\n\t\ttry {\n\t\t\tif (vm.getNumber(length) > maximum) throw new Error('Code runtime value exceeds ' + maximum + ' bytes.')\n\t\t} finally { length.dispose() }\n\t\tconst text = vm.getString(handle)\n\t\tif (Buffer.byteLength(text) > maximum) throw new Error('Code runtime value exceeds ' + maximum + ' bytes.')\n\t\treturn text\n\t}\n\tfunction serialize(handle, maximum) {\n\t\tif (vm.typeof(handle) === 'undefined') return undefined\n\t\tconst encoded = vm.callFunction(encode, vm.undefined, handle)\n\t\tif (encoded.error) {\n\t\t\tencoded.error.dispose()\n\t\t\tthrow new Error('Code runtime values must be JSON-safe and serializable.')\n\t\t}\n\t\ttry { return textValue(encoded.value, maximum) }\n\t\tfinally { encoded.value.dispose() }\n\t}\n\tfunction failureText(handle) {\n\t\tconst result = vm.callFunction(errorText, vm.undefined, handle)\n\t\tif (result.error) { result.error.dispose(); return 'The program failed.' }\n\t\t// Diagnostics have their own fixed bound. A deliberately tiny data\n\t\t// allowance must not erase the reason or the no-replay guidance for an\n\t\t// effect that completed but whose return value could not be delivered.\n\t\ttry { return textValue(result.value, 4096) }\n\t\tcatch { return 'The program failed with an oversized error.' }\n\t\tfinally { result.value.dispose() }\n\t}\n\tfunction dispose() {\n\t\tfor (const deferred of pending.values()) deferred.dispose()\n\t\tpending.clear()\n\t\tif (program && program.alive) program.dispose()\n\t\tfor (const handle of owned) if (handle.alive) handle.dispose()\n\t\tvm.dispose()\n\t\truntime.dispose()\n\t}\n\tfunction finish(message) {\n\t\tif (ended) return\n\t\tended = true\n\t\t// A guest OOM can make QuickJS teardown throw. The worker still owns\n\t\t// the whole WASM module and is terminated by its parent on settlement.\n\t\ttry { dispose() } catch {}\n\t\tparentPort.postMessage(message)\n\t}\n\tfunction fail(error) {\n\t\tfinish(Date.now() >= workerData.deadline\n\t\t\t? { kind: 'timed-out' }\n\t\t\t: { kind: 'error', error: String(error && error.message || error).slice(0, 4096) })\n\t}\n\tfunction schedule() {\n\t\tif (ended || scheduled) return\n\t\tscheduled = true\n\t\tsetImmediate(() => { scheduled = false; pump() })\n\t}\n\tfunction pump() {\n\t\tif (ended || pumping) return\n\t\tpumping = true\n\t\ttry {\n\t\t\tconst jobs = runtime.executePendingJobs(32)\n\t\t\tif (jobs.error) {\n\t\t\t\tconst error = failureText(jobs.error)\n\t\t\t\tjobs.error.dispose()\n\t\t\t\tthrow new Error(error)\n\t\t\t}\n\t\t\tconst state = vm.getPromiseState(program)\n\t\t\tif (state.type === 'fulfilled') {\n\t\t\t\tlet json\n\t\t\t\ttry { json = serialize(state.value, limits.maxValueBytes) }\n\t\t\t\tfinally { state.value.dispose() }\n\t\t\t\tfinish({ kind: 'done', json })\n\t\t\t} else if (state.type === 'rejected') {\n\t\t\t\tlet error\n\t\t\t\ttry { error = failureText(state.error) }\n\t\t\t\tfinally { state.error.dispose() }\n\t\t\t\tfail(new Error(error))\n\t\t\t} else if (runtime.hasPendingJob()) schedule()\n\t\t} catch (error) { fail(error) }\n\t\tfinally { pumping = false }\n\t}\n\tfunction rejected(message) {\n\t\tconst deferred = vm.newPromise()\n\t\tconst error = vm.newError(message)\n\t\tdeferred.reject(error)\n\t\terror.dispose()\n\t\treturn deferred.handle\n\t}\n\tconst call = vm.newFunction('call', (name, input = vm.undefined) => {\n\t\ttry {\n\t\t\tif (nextId >= limits.maxHostCalls) return rejected('Code runtime host-call limit reached.')\n\t\t\tif (pending.size >= limits.maxPendingHostCalls) return rejected('Code runtime pending host-call limit reached.')\n\t\t\tif (vm.typeof(name) !== 'string') return rejected('A host call requires a tool name string.')\n\t\t\tconst tool = textValue(name, Math.min(limits.maxValueBytes, 1024))\n\t\t\tconst json = serialize(input, limits.maxValueBytes)\n\t\t\tconst id = ++nextId\n\t\t\tconst deferred = vm.newPromise()\n\t\t\tpending.set(id, deferred)\n\t\t\tparentPort.postMessage({ kind: 'call', id, name: tool, json })\n\t\t\treturn deferred.handle\n\t\t} catch (error) { return rejected(String(error.message || error)) }\n\t})\n\tvm.setProp(vm.global, 'call', call)\n\tcall.dispose()\n\tconst print = vm.newFunction('print', (...values) => {\n\t\tif (truncated) return vm.undefined\n\t\ttry {\n\t\t\tconst parts = []\n\t\t\tlet remaining = workerData.maxOutputBytes - printBytes - (printCount > 0 ? 1 : 0)\n\t\t\tfor (const value of values) {\n\t\t\t\tif (parts.length) remaining--\n\t\t\t\tif (remaining < 0) throw new Error('output limit')\n\t\t\t\tconst text = vm.typeof(value) === 'string' ? textValue(value, remaining) : serialize(value, remaining)\n\t\t\t\tconst part = text === undefined ? '' : text\n\t\t\t\tremaining -= Buffer.byteLength(part)\n\t\t\t\tparts.push(part)\n\t\t\t}\n\t\t\tconst line = parts.join(' ')\n\t\t\tconst size = Buffer.byteLength(line) + (printCount > 0 ? 1 : 0)\n\t\t\tif (printBytes + size > workerData.maxOutputBytes) throw new Error('output limit')\n\t\t\t// Empty prints consume a newline after the first, so the byte\n\t\t\t// budget also bounds the number of worker messages.\n\t\t\tprintBytes += size\n\t\t\tprintCount++\n\t\t\tparentPort.postMessage({ kind: 'print', line })\n\t\t} catch {\n\t\t\ttruncated = true\n\t\t\tparentPort.postMessage({ kind: 'truncated' })\n\t\t}\n\t\treturn vm.undefined\n\t})\n\tvm.setProp(vm.global, 'print', print)\n\tprint.dispose()\n\n\tparentPort.on('message', (message) => {\n\t\tif (ended || message.kind !== 'call-result') return\n\t\tconst deferred = pending.get(message.id)\n\t\tif (!deferred) return\n\t\tpending.delete(message.id)\n\t\ttry {\n\t\t\tif (message.ok) {\n\t\t\t\tlet value = vm.undefined\n\t\t\t\tif (message.json !== undefined) {\n\t\t\t\t\tif (typeof message.json !== 'string' || Buffer.byteLength(message.json) > limits.maxValueBytes) throw new Error('Host result exceeds the value limit.')\n\t\t\t\t\tconst input = vm.newString(message.json)\n\t\t\t\t\ttry { value = vm.unwrapResult(vm.callFunction(decode, vm.undefined, input)) }\n\t\t\t\t\tfinally { input.dispose() }\n\t\t\t\t}\n\t\t\t\tdeferred.resolve(value)\n\t\t\t\tif (value !== vm.undefined) value.dispose()\n\t\t\t} else {\n\t\t\t\tconst error = vm.newError(String(message.error).slice(0, 4096))\n\t\t\t\tdeferred.reject(error)\n\t\t\t\terror.dispose()\n\t\t\t}\n\t\t\tdeferred.dispose()\n\t\t\tschedule()\n\t\t} catch (error) { deferred.dispose(); fail(error) }\n\t})\n\ttry {\n\t\tconst result = vm.evalCode('(async () => {\\n' + workerData.source + '\\n})()', 'model-program.js')\n\t\tif (result.error) {\n\t\t\tconst error = failureText(result.error)\n\t\t\tresult.error.dispose()\n\t\t\tfail(new Error(error))\n\t\t} else { program = result.value; pump() }\n\t} catch (error) { fail(error) }\n}\nmain().catch((error) => parentPort.postMessage({ kind: 'error', error: String(error && error.message || error).slice(0, 4096) }))\n";
7
+ export declare const QUICKJS_WORKER_SOURCE = "\nconst { parentPort, workerData } = require('node:worker_threads')\nconst { newQuickJSWASMModuleFromVariant, newVariant } = require(workerData.corePath)\nconst variantModule = require(workerData.variantPath)\nconst variant = variantModule.default || variantModule\n\nasync function main() {\n\tconst limits = workerData.limits\n\tconst pages = Math.floor(limits.memoryLimitBytes / 65536)\n\tconst wasmMemory = new WebAssembly.Memory({ initial: Math.min(256, pages), maximum: pages })\n\tconst module = await newQuickJSWASMModuleFromVariant(newVariant(variant, { wasmMemory }))\n\tconst runtime = module.newRuntime()\n\truntime.setMemoryLimit(limits.memoryLimitBytes)\n\truntime.setMaxStackSize(512 * 1024)\n\t// Two ways to bound a program's synchronous execution. Default: one wall\n\t// deadline for the whole run. With `cpu`: a budget per synchronous slice\n\t// (each entry into the interpreter) and a total across slices, so a program\n\t// that spends hours AWAITING the host is not stopped, but a busy loop is.\n\tconst cpu = workerData.cpu\n\tlet sliceDepth = 0\n\tlet sliceStart = 0\n\tlet cpuUsed = 0\n\tlet interrupted = false\n\tfunction inSlice(fn) {\n\t\tif (!cpu) return fn()\n\t\tif (sliceDepth === 0) sliceStart = Date.now()\n\t\tsliceDepth++\n\t\ttry { return fn() }\n\t\tfinally {\n\t\t\tsliceDepth--\n\t\t\tif (sliceDepth === 0) cpuUsed += Date.now() - sliceStart\n\t\t}\n\t}\n\truntime.setInterruptHandler(() => {\n\t\tconst now = Date.now()\n\t\tconst stop = cpu\n\t\t\t? sliceDepth > 0 && (now - sliceStart >= cpu.sliceMs || cpuUsed + (now - sliceStart) >= cpu.totalMs)\n\t\t\t: now >= workerData.deadline\n\t\tif (stop) interrupted = true\n\t\treturn stop\n\t})\n\tconst vm = runtime.newContext()\n\tconst pending = new Map()\n\tlet nextId = 0\n\tlet printBytes = 0\n\tlet printCount = 0\n\tlet truncated = false\n\tlet ended = false\n\tlet pumping = false\n\tlet scheduled = false\n\tlet program\n\tconst owned = []\n\n\tfunction keep(result) {\n\t\tconst handle = vm.unwrapResult(result)\n\t\towned.push(handle)\n\t\treturn handle\n\t}\n\t// Capture intrinsics before the program may replace its own globals.\n\tconst encode = keep(vm.evalCode('(' + function () {\n\t\tconst stringify = JSON.stringify\n\t\tconst finite = Number.isFinite\n\t\tconst prototype = Object.getPrototypeOf\n\t\tconst plain = Object.prototype\n\t\tconst isArray = Array.isArray\n\t\tconst keys = Object.keys\n\t\tconst descriptor = Object.getOwnPropertyDescriptor\n\t\treturn function (value) {\n\t\t\tif (value === undefined) return undefined\n\t\t\tconst parents = new Set()\n\t\t\tfunction check(item, depth) {\n\t\t\t\tconst kind = typeof item\n\t\t\t\tif (item === null || kind === 'string' || kind === 'boolean' || (kind === 'number' && finite(item))) return\n\t\t\t\tif (kind !== 'object' || depth > 64 || parents.has(item)) throw new Error('Code runtime values must be JSON-safe.')\n\t\t\t\tif (!isArray(item) && prototype(item) !== plain && prototype(item) !== null) throw new Error('Code runtime values must use plain objects and arrays.')\n\t\t\t\tparents.add(item)\n\t\t\t\tfor (const key of keys(item)) {\n\t\t\t\t\tconst property = descriptor(item, key)\n\t\t\t\t\tif (!property || !('value' in property)) throw new Error('Code runtime values must not contain accessors.')\n\t\t\t\t\tcheck(property.value, depth + 1)\n\t\t\t\t}\n\t\t\t\tparents.delete(item)\n\t\t\t}\n\t\t\tcheck(value, 0)\n\t\t\treturn stringify(value)\n\t\t}\n\t}.toString() + ')()'))\n\tconst decode = keep(vm.evalCode('(function () { const parse = JSON.parse; return function(value) { return parse(value); }; })()'))\n\tconst errorText = keep(vm.evalCode('(function () { const string = String; return function(error) { try { return typeof error.message === \"string\" ? error.message : string(error); } catch { return \"The program failed.\"; } }; })()'))\n\n\tconst errorMeta = keep(vm.evalCode('(function () { const string = String; const stringify = JSON.stringify; return function(error) { try { return stringify({ name: typeof error.name === \"string\" ? error.name : \"\", stack: typeof error.stack === \"string\" ? error.stack : \"\" }); } catch { return \"{}\"; } }; })()'))\n\n\tfunction textValue(handle, maximum) {\n\t\tconst length = vm.getProp(handle, 'length')\n\t\ttry {\n\t\t\tif (vm.getNumber(length) > maximum) throw new Error('Code runtime value exceeds ' + maximum + ' bytes.')\n\t\t} finally { length.dispose() }\n\t\tconst text = vm.getString(handle)\n\t\tif (Buffer.byteLength(text) > maximum) throw new Error('Code runtime value exceeds ' + maximum + ' bytes.')\n\t\treturn text\n\t}\n\tfunction serialize(handle, maximum) {\n\t\tif (vm.typeof(handle) === 'undefined') return undefined\n\t\tconst encoded = vm.callFunction(encode, vm.undefined, handle)\n\t\tif (encoded.error) {\n\t\t\tencoded.error.dispose()\n\t\t\tthrow new Error('Code runtime values must be JSON-safe and serializable.')\n\t\t}\n\t\ttry { return textValue(encoded.value, maximum) }\n\t\tfinally { encoded.value.dispose() }\n\t}\n\tfunction failureText(handle) {\n\t\tconst result = vm.callFunction(errorText, vm.undefined, handle)\n\t\tif (result.error) { result.error.dispose(); return 'The program failed.' }\n\t\t// Diagnostics have their own fixed bound. A deliberately tiny data\n\t\t// allowance must not erase the reason or the no-replay guidance for an\n\t\t// effect that completed but whose return value could not be delivered.\n\t\ttry { return textValue(result.value, 4096) }\n\t\tcatch { return 'The program failed with an oversized error.' }\n\t\tfinally { result.value.dispose() }\n\t}\n\t// The guest error's message plus its name and stack, so the host can say\n\t// where in the program it failed. Stack text is untrusted and only parsed\n\t// for line and column numbers.\n\tfunction failureError(handle) {\n\t\tconst error = new Error(failureText(handle))\n\t\ttry {\n\t\t\tconst result = vm.callFunction(errorMeta, vm.undefined, handle)\n\t\t\tif (result.error) result.error.dispose()\n\t\t\telse {\n\t\t\t\ttry {\n\t\t\t\t\tconst meta = JSON.parse(textValue(result.value, 4096))\n\t\t\t\t\terror.guestName = String(meta.name || '').slice(0, 64)\n\t\t\t\t\terror.guestStack = String(meta.stack || '').slice(0, 3072)\n\t\t\t\t} finally { result.value.dispose() }\n\t\t\t}\n\t\t} catch {}\n\t\treturn error\n\t}\n\tfunction dispose() {\n\t\tfor (const deferred of pending.values()) deferred.dispose()\n\t\tpending.clear()\n\t\tif (program && program.alive) program.dispose()\n\t\tfor (const handle of owned) if (handle.alive) handle.dispose()\n\t\tvm.dispose()\n\t\truntime.dispose()\n\t}\n\tfunction finish(message) {\n\t\tif (ended) return\n\t\tended = true\n\t\t// A guest OOM can make QuickJS teardown throw. The worker still owns\n\t\t// the whole WASM module and is terminated by its parent on settlement.\n\t\ttry { dispose() } catch {}\n\t\tparentPort.postMessage(message)\n\t}\n\tfunction fail(error) {\n\t\tfinish(interrupted || Date.now() >= workerData.deadline\n\t\t\t? { kind: 'timed-out' }\n\t\t\t: { kind: 'error', error: String(error && error.message || error).slice(0, 4096), name: error && error.guestName, stack: error && error.guestStack })\n\t}\n\tfunction schedule() {\n\t\tif (ended || scheduled) return\n\t\tscheduled = true\n\t\tsetImmediate(() => { scheduled = false; pump() })\n\t}\n\tfunction pump() {\n\t\tif (ended || pumping) return\n\t\tinSlice(pumpOnce)\n\t}\n\tfunction pumpOnce() {\n\t\tpumping = true\n\t\ttry {\n\t\t\t// A program that never lets one slice run long (a loop of awaited\n\t\t\t// microtasks) is still bounded by the total CPU budget.\n\t\t\tif (cpu && cpuUsed >= cpu.totalMs) {\n\t\t\t\tinterrupted = true\n\t\t\t\tthrow new Error('The program used its CPU budget.')\n\t\t\t}\n\t\t\tconst jobs = runtime.executePendingJobs(32)\n\t\t\tif (jobs.error) {\n\t\t\t\tconst error = failureError(jobs.error)\n\t\t\t\tjobs.error.dispose()\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tconst state = vm.getPromiseState(program)\n\t\t\tif (state.type === 'fulfilled') {\n\t\t\t\tlet json\n\t\t\t\ttry { json = serialize(state.value, limits.maxValueBytes) }\n\t\t\t\tfinally { state.value.dispose() }\n\t\t\t\tfinish({ kind: 'done', json })\n\t\t\t} else if (state.type === 'rejected') {\n\t\t\t\tlet error\n\t\t\t\ttry { error = failureError(state.error) }\n\t\t\t\tfinally { state.error.dispose() }\n\t\t\t\tfail(error)\n\t\t\t} else if (runtime.hasPendingJob()) schedule()\n\t\t} catch (error) { fail(error) }\n\t\tfinally { pumping = false }\n\t}\n\tfunction rejected(message) {\n\t\tconst deferred = vm.newPromise()\n\t\tconst error = vm.newError(message)\n\t\tdeferred.reject(error)\n\t\terror.dispose()\n\t\treturn deferred.handle\n\t}\n\tconst call = vm.newFunction('call', (name, input = vm.undefined) => {\n\t\ttry {\n\t\t\tif (nextId >= limits.maxHostCalls) return rejected('Code runtime host-call limit reached.')\n\t\t\tif (pending.size >= limits.maxPendingHostCalls) return rejected('Code runtime pending host-call limit reached.')\n\t\t\tif (vm.typeof(name) !== 'string') return rejected('A host call requires a tool name string.')\n\t\t\tconst tool = textValue(name, Math.min(limits.maxValueBytes, 1024))\n\t\t\tconst json = serialize(input, limits.maxValueBytes)\n\t\t\tconst id = ++nextId\n\t\t\tconst deferred = vm.newPromise()\n\t\t\tpending.set(id, deferred)\n\t\t\tparentPort.postMessage({ kind: 'call', id, name: tool, json })\n\t\t\treturn deferred.handle\n\t\t} catch (error) { return rejected(String(error.message || error)) }\n\t})\n\tvm.setProp(vm.global, 'call', call)\n\tcall.dispose()\n\tconst print = vm.newFunction('print', (...values) => {\n\t\tif (truncated) return vm.undefined\n\t\ttry {\n\t\t\tconst parts = []\n\t\t\tlet remaining = workerData.maxOutputBytes - printBytes - (printCount > 0 ? 1 : 0)\n\t\t\tfor (const value of values) {\n\t\t\t\tif (parts.length) remaining--\n\t\t\t\tif (remaining < 0) throw new Error('output limit')\n\t\t\t\tconst text = vm.typeof(value) === 'string' ? textValue(value, remaining) : serialize(value, remaining)\n\t\t\t\tconst part = text === undefined ? '' : text\n\t\t\t\tremaining -= Buffer.byteLength(part)\n\t\t\t\tparts.push(part)\n\t\t\t}\n\t\t\tconst line = parts.join(' ')\n\t\t\tconst size = Buffer.byteLength(line) + (printCount > 0 ? 1 : 0)\n\t\t\tif (printBytes + size > workerData.maxOutputBytes) throw new Error('output limit')\n\t\t\t// Empty prints consume a newline after the first, so the byte\n\t\t\t// budget also bounds the number of worker messages.\n\t\t\tprintBytes += size\n\t\t\tprintCount++\n\t\t\tparentPort.postMessage({ kind: 'print', line })\n\t\t} catch {\n\t\t\ttruncated = true\n\t\t\tparentPort.postMessage({ kind: 'truncated' })\n\t\t}\n\t\treturn vm.undefined\n\t})\n\tvm.setProp(vm.global, 'print', print)\n\tprint.dispose()\n\n\tparentPort.on('message', (message) => {\n\t\tif (ended || message.kind !== 'call-result') return\n\t\tconst deferred = pending.get(message.id)\n\t\tif (!deferred) return\n\t\tpending.delete(message.id)\n\t\ttry {\n\t\t\tinSlice(() => {\n\t\t\tif (message.ok) {\n\t\t\t\tlet value = vm.undefined\n\t\t\t\tif (message.json !== undefined) {\n\t\t\t\t\tif (typeof message.json !== 'string' || Buffer.byteLength(message.json) > limits.maxValueBytes) throw new Error('Host result exceeds the value limit.')\n\t\t\t\t\tconst input = vm.newString(message.json)\n\t\t\t\t\ttry { value = vm.unwrapResult(vm.callFunction(decode, vm.undefined, input)) }\n\t\t\t\t\tfinally { input.dispose() }\n\t\t\t\t}\n\t\t\t\tdeferred.resolve(value)\n\t\t\t\tif (value !== vm.undefined) value.dispose()\n\t\t\t} else {\n\t\t\t\tconst error = vm.newError(String(message.error).slice(0, 4096))\n\t\t\t\tdeferred.reject(error)\n\t\t\t\terror.dispose()\n\t\t\t}\n\t\t\tdeferred.dispose()\n\t\t\t})\n\t\t\tschedule()\n\t\t} catch (error) { deferred.dispose(); fail(error) }\n\t})\n\ttry {\n\t\tinSlice(() => {\n\t\t\tconst result = vm.evalCode('(async () => {\\n' + workerData.source + '\\n})()', 'model-program.js')\n\t\t\tif (result.error) {\n\t\t\t\tconst error = failureError(result.error)\n\t\t\t\tresult.error.dispose()\n\t\t\t\tfail(error)\n\t\t\t} else { program = result.value; pump() }\n\t\t})\n\t} catch (error) { fail(error) }\n}\nmain().catch((error) => parentPort.postMessage({ kind: 'error', error: String(error && error.message || error).slice(0, 4096) }))\n";
8
8
  //# sourceMappingURL=worker-program.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-program.d.ts","sourceRoot":"","sources":["../../../src/execution/code-runtime/worker-program.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,8qTAwOjC,CAAA"}
1
+ {"version":3,"file":"worker-program.d.ts","sourceRoot":"","sources":["../../../src/execution/code-runtime/worker-program.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,qiYAmSjC,CAAA"}
@@ -18,7 +18,33 @@ async function main() {
18
18
  const runtime = module.newRuntime()
19
19
  runtime.setMemoryLimit(limits.memoryLimitBytes)
20
20
  runtime.setMaxStackSize(512 * 1024)
21
- runtime.setInterruptHandler(() => Date.now() >= workerData.deadline)
21
+ // Two ways to bound a program's synchronous execution. Default: one wall
22
+ // deadline for the whole run. With \`cpu\`: a budget per synchronous slice
23
+ // (each entry into the interpreter) and a total across slices, so a program
24
+ // that spends hours AWAITING the host is not stopped, but a busy loop is.
25
+ const cpu = workerData.cpu
26
+ let sliceDepth = 0
27
+ let sliceStart = 0
28
+ let cpuUsed = 0
29
+ let interrupted = false
30
+ function inSlice(fn) {
31
+ if (!cpu) return fn()
32
+ if (sliceDepth === 0) sliceStart = Date.now()
33
+ sliceDepth++
34
+ try { return fn() }
35
+ finally {
36
+ sliceDepth--
37
+ if (sliceDepth === 0) cpuUsed += Date.now() - sliceStart
38
+ }
39
+ }
40
+ runtime.setInterruptHandler(() => {
41
+ const now = Date.now()
42
+ const stop = cpu
43
+ ? sliceDepth > 0 && (now - sliceStart >= cpu.sliceMs || cpuUsed + (now - sliceStart) >= cpu.totalMs)
44
+ : now >= workerData.deadline
45
+ if (stop) interrupted = true
46
+ return stop
47
+ })
22
48
  const vm = runtime.newContext()
23
49
  const pending = new Map()
24
50
  let nextId = 0
@@ -68,6 +94,8 @@ async function main() {
68
94
  const decode = keep(vm.evalCode('(function () { const parse = JSON.parse; return function(value) { return parse(value); }; })()'))
69
95
  const errorText = keep(vm.evalCode('(function () { const string = String; return function(error) { try { return typeof error.message === "string" ? error.message : string(error); } catch { return "The program failed."; } }; })()'))
70
96
 
97
+ const errorMeta = keep(vm.evalCode('(function () { const string = String; const stringify = JSON.stringify; return function(error) { try { return stringify({ name: typeof error.name === "string" ? error.name : "", stack: typeof error.stack === "string" ? error.stack : "" }); } catch { return "{}"; } }; })()'))
98
+
71
99
  function textValue(handle, maximum) {
72
100
  const length = vm.getProp(handle, 'length')
73
101
  try {
@@ -97,6 +125,24 @@ async function main() {
97
125
  catch { return 'The program failed with an oversized error.' }
98
126
  finally { result.value.dispose() }
99
127
  }
128
+ // The guest error's message plus its name and stack, so the host can say
129
+ // where in the program it failed. Stack text is untrusted and only parsed
130
+ // for line and column numbers.
131
+ function failureError(handle) {
132
+ const error = new Error(failureText(handle))
133
+ try {
134
+ const result = vm.callFunction(errorMeta, vm.undefined, handle)
135
+ if (result.error) result.error.dispose()
136
+ else {
137
+ try {
138
+ const meta = JSON.parse(textValue(result.value, 4096))
139
+ error.guestName = String(meta.name || '').slice(0, 64)
140
+ error.guestStack = String(meta.stack || '').slice(0, 3072)
141
+ } finally { result.value.dispose() }
142
+ }
143
+ } catch {}
144
+ return error
145
+ }
100
146
  function dispose() {
101
147
  for (const deferred of pending.values()) deferred.dispose()
102
148
  pending.clear()
@@ -114,9 +160,9 @@ async function main() {
114
160
  parentPort.postMessage(message)
115
161
  }
116
162
  function fail(error) {
117
- finish(Date.now() >= workerData.deadline
163
+ finish(interrupted || Date.now() >= workerData.deadline
118
164
  ? { kind: 'timed-out' }
119
- : { kind: 'error', error: String(error && error.message || error).slice(0, 4096) })
165
+ : { kind: 'error', error: String(error && error.message || error).slice(0, 4096), name: error && error.guestName, stack: error && error.guestStack })
120
166
  }
121
167
  function schedule() {
122
168
  if (ended || scheduled) return
@@ -125,13 +171,22 @@ async function main() {
125
171
  }
126
172
  function pump() {
127
173
  if (ended || pumping) return
174
+ inSlice(pumpOnce)
175
+ }
176
+ function pumpOnce() {
128
177
  pumping = true
129
178
  try {
179
+ // A program that never lets one slice run long (a loop of awaited
180
+ // microtasks) is still bounded by the total CPU budget.
181
+ if (cpu && cpuUsed >= cpu.totalMs) {
182
+ interrupted = true
183
+ throw new Error('The program used its CPU budget.')
184
+ }
130
185
  const jobs = runtime.executePendingJobs(32)
131
186
  if (jobs.error) {
132
- const error = failureText(jobs.error)
187
+ const error = failureError(jobs.error)
133
188
  jobs.error.dispose()
134
- throw new Error(error)
189
+ throw error
135
190
  }
136
191
  const state = vm.getPromiseState(program)
137
192
  if (state.type === 'fulfilled') {
@@ -141,9 +196,9 @@ async function main() {
141
196
  finish({ kind: 'done', json })
142
197
  } else if (state.type === 'rejected') {
143
198
  let error
144
- try { error = failureText(state.error) }
199
+ try { error = failureError(state.error) }
145
200
  finally { state.error.dispose() }
146
- fail(new Error(error))
201
+ fail(error)
147
202
  } else if (runtime.hasPendingJob()) schedule()
148
203
  } catch (error) { fail(error) }
149
204
  finally { pumping = false }
@@ -207,6 +262,7 @@ async function main() {
207
262
  if (!deferred) return
208
263
  pending.delete(message.id)
209
264
  try {
265
+ inSlice(() => {
210
266
  if (message.ok) {
211
267
  let value = vm.undefined
212
268
  if (message.json !== undefined) {
@@ -223,16 +279,19 @@ async function main() {
223
279
  error.dispose()
224
280
  }
225
281
  deferred.dispose()
282
+ })
226
283
  schedule()
227
284
  } catch (error) { deferred.dispose(); fail(error) }
228
285
  })
229
286
  try {
230
- const result = vm.evalCode('(async () => {\\n' + workerData.source + '\\n})()', 'model-program.js')
231
- if (result.error) {
232
- const error = failureText(result.error)
233
- result.error.dispose()
234
- fail(new Error(error))
235
- } else { program = result.value; pump() }
287
+ inSlice(() => {
288
+ const result = vm.evalCode('(async () => {\\n' + workerData.source + '\\n})()', 'model-program.js')
289
+ if (result.error) {
290
+ const error = failureError(result.error)
291
+ result.error.dispose()
292
+ fail(error)
293
+ } else { program = result.value; pump() }
294
+ })
236
295
  } catch (error) { fail(error) }
237
296
  }
238
297
  main().catch((error) => parentPort.postMessage({ kind: 'error', error: String(error && error.message || error).slice(0, 4096) }))
@@ -1 +1 @@
1
- {"version":3,"file":"worker-program.js","sourceRoot":"","sources":["../../../src/execution/code-runtime/worker-program.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwOpC,CAAA"}
1
+ {"version":3,"file":"worker-program.js","sourceRoot":"","sources":["../../../src/execution/code-runtime/worker-program.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmSpC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/execution/code-runtime/worker.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,MAAM,YAAY,CAAA;AAKnB,8DAA8D;AAC9D,MAAM,WAAW,wBAAwB;IACxC,+HAA+H;IAC/H,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC,2DAA2D;IAC3D,QAAQ,C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OAAO,CAAC,aAAa,CAAC;CAkU1D"}
@@ -3,6 +3,25 @@ import { Worker } from 'node:worker_threads';
3
3
  import { encodeCodeValue } from './json-value.js';
4
4
  import { HostCallDeniedError, } from './types.js';
5
5
  import { QUICKJS_WORKER_SOURCE } from './worker-program.js';
6
+ /** The worker wraps the program in `(async () => {` plus a newline: one line. */
7
+ const WRAPPER_LINES = 1;
8
+ const FRAME_PATTERN = /model-program\.js:(\d+):(\d+)/g;
9
+ function failureLocation(name, stack, sourceLines) {
10
+ const frames = [];
11
+ if (typeof stack === 'string') {
12
+ for (const match of stack.matchAll(FRAME_PATTERN)) {
13
+ const line = Number(match[1]) - WRAPPER_LINES;
14
+ // The wrapper's own lines (its opening, and the closing after the source)
15
+ // are not in what the caller submitted.
16
+ if (line >= 1 && line <= sourceLines)
17
+ frames.push({ line, column: Number(match[2]) });
18
+ }
19
+ }
20
+ return {
21
+ ...(typeof name === 'string' && name !== '' ? { errorName: name } : {}),
22
+ ...(frames.length > 0 ? { frames } : {}),
23
+ };
24
+ }
6
25
  const requireFromSdk = createRequire(import.meta.url);
7
26
  function validateInteger(name, value, minimum, maximum) {
8
27
  if (!Number.isSafeInteger(value) || value < minimum || value > maximum) {
@@ -48,6 +67,10 @@ export class WorkerCodeRuntime {
48
67
  async run(options) {
49
68
  validateInteger('timeoutMs', options.timeoutMs, 1, 2_147_483_647);
50
69
  validateInteger('maxOutputBytes', options.maxOutputBytes, 0, 16 * 1024 * 1024);
70
+ if (options.cpuLimits) {
71
+ validateInteger('cpuLimits.sliceMs', options.cpuLimits.sliceMs, 1, 2_147_483_647);
72
+ validateInteger('cpuLimits.totalMs', options.cpuLimits.totalMs, 1, 2_147_483_647);
73
+ }
51
74
  const allowed = new Set(options.allowedCalls);
52
75
  const calls = [];
53
76
  let output = '';
@@ -90,6 +113,12 @@ export class WorkerCodeRuntime {
90
113
  }
91
114
  output = next;
92
115
  printCount++;
116
+ try {
117
+ options.onOutput?.(line);
118
+ }
119
+ catch {
120
+ // A listener bug must not decide the program's outcome.
121
+ }
93
122
  }
94
123
  };
95
124
  const worker = new Worker(QUICKJS_WORKER_SOURCE, {
@@ -100,6 +129,7 @@ export class WorkerCodeRuntime {
100
129
  variantPath: requireFromSdk.resolve('@jitl/quickjs-wasmfile-release-sync'),
101
130
  limits: this.limits,
102
131
  maxOutputBytes: options.maxOutputBytes,
132
+ cpu: options.cpuLimits,
103
133
  deadline: Date.now() + options.timeoutMs,
104
134
  },
105
135
  // Trusted bootstrap requires Node; guest code runs only inside QuickJS.
@@ -306,7 +336,11 @@ export class WorkerCodeRuntime {
306
336
  }
307
337
  if (message.kind === 'error') {
308
338
  finish({
309
- outcome: { status: 'failed', error: String(message.error) },
339
+ outcome: {
340
+ status: 'failed',
341
+ error: String(message.error),
342
+ ...failureLocation(message.name, message.stack, options.source.split('\n').length),
343
+ },
310
344
  output,
311
345
  outputTruncated: truncated,
312
346
  calls,
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/execution/code-runtime/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAGN,mBAAmB,GAEnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAgBrD,SAAS,eAAe,CAAC,IAAY,EAAE,KAAa,EAAE,OAAe,EAAE,OAAe;IACrF,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,OAAO,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;QACxE,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,+BAA+B,OAA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BAC9C;oBACD,MAAM;oBACN,eAAe,EAAE,SAAS;oBAC1B,KAAK;iBACL,CAAC,CAAA;YACH,CAAC,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC;CACD"}
@@ -0,0 +1,5 @@
1
+ /** A script that cannot run: bad `meta`, too large, bad `args`. Nothing started. */
2
+ export declare class WorkflowScriptError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/errors.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,qBAAa,mBAAoB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI3B"}
@@ -0,0 +1,8 @@
1
+ /** A script that cannot run: bad `meta`, too large, bad `args`. Nothing started. */
2
+ export class WorkflowScriptError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = 'WorkflowScriptError';
6
+ }
7
+ }
8
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/execution/workflow/errors.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IAClC,CAAC;CACD"}
@@ -0,0 +1,9 @@
1
+ export { WorkflowScriptError } from './errors.js';
2
+ export { FileWorkflowJournal } from './journal.js';
3
+ export { parseWorkflowMeta } from './meta.js';
4
+ export { summarizeWorkflowPhases } from './phases.js';
5
+ export type { PhaseAgentView, PhaseRecord } from './phases.js';
6
+ export { resolveWorkflowLimits, WORKFLOW_HOST_CALL, WorkflowRuntime } from './runtime.js';
7
+ export type { WorkflowRuntimeOptions } from './runtime.js';
8
+ export type * from './types.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACzF,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC1D,mBAAmB,YAAY,CAAA"}
@@ -0,0 +1,6 @@
1
+ export { WorkflowScriptError } from './errors.js';
2
+ export { FileWorkflowJournal } from './journal.js';
3
+ export { parseWorkflowMeta } from './meta.js';
4
+ export { summarizeWorkflowPhases } from './phases.js';
5
+ export { resolveWorkflowLimits, WORKFLOW_HOST_CALL, WorkflowRuntime } from './runtime.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/execution/workflow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,18 @@
1
+ import type { WorkflowJournal, WorkflowJournalRecord } from './types.js';
2
+ export declare function sha256(text: string): string;
3
+ /** The first `max` UTF-16 units of `text`, never ending inside a surrogate pair. */
4
+ export declare function preview(text: string, max?: number): string;
5
+ /**
6
+ * A journal in a directory: `script.js` (the exact script text, mode 0600)
7
+ * and `journal.jsonl` (one JSON record per line, append-only). The caller
8
+ * chooses the directory, normally `<session>/runs/<runId>/workflow/`.
9
+ */
10
+ export declare class FileWorkflowJournal implements WorkflowJournal {
11
+ private readonly dir;
12
+ private ready;
13
+ constructor(dir: string);
14
+ private ensure;
15
+ writeScript(source: string): Promise<void>;
16
+ append(record: WorkflowJournalRecord): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/journal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAExE,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,oFAAoF;AACpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAM,GAAG,MAAM,CAMvD;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAG9C,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFhC,OAAO,CAAC,KAAK,CAA2B;gBAEX,GAAG,EAAE,MAAM;IAExC,OAAO,CAAC,MAAM;IAKR,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CAM1D"}
@@ -0,0 +1,43 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { appendFile, mkdir, writeFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ export function sha256(text) {
5
+ return createHash('sha256').update(text).digest('hex');
6
+ }
7
+ /** The first `max` UTF-16 units of `text`, never ending inside a surrogate pair. */
8
+ export function preview(text, max = 500) {
9
+ if (text.length <= max)
10
+ return text;
11
+ let end = max;
12
+ const last = text.charCodeAt(end - 1);
13
+ if (last >= 0xd800 && last <= 0xdbff)
14
+ end--;
15
+ return `${text.slice(0, end)}…`;
16
+ }
17
+ /**
18
+ * A journal in a directory: `script.js` (the exact script text, mode 0600)
19
+ * and `journal.jsonl` (one JSON record per line, append-only). The caller
20
+ * chooses the directory, normally `<session>/runs/<runId>/workflow/`.
21
+ */
22
+ export class FileWorkflowJournal {
23
+ dir;
24
+ ready;
25
+ constructor(dir) {
26
+ this.dir = dir;
27
+ }
28
+ ensure() {
29
+ this.ready ??= mkdir(this.dir, { recursive: true, mode: 0o700 }).then(() => undefined);
30
+ return this.ready;
31
+ }
32
+ async writeScript(source) {
33
+ await this.ensure();
34
+ await writeFile(join(this.dir, 'script.js'), source, { mode: 0o600 });
35
+ }
36
+ async append(record) {
37
+ await this.ensure();
38
+ await appendFile(join(this.dir, 'journal.jsonl'), `${JSON.stringify(record)}\n`, {
39
+ mode: 0o600,
40
+ });
41
+ }
42
+ }
43
+ //# sourceMappingURL=journal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.js","sourceRoot":"","sources":["../../../src/execution/workflow/journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,MAAM,UAAU,MAAM,CAAC,IAAY;IAClC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACvD,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,GAAG,GAAG,GAAG;IAC9C,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,CAAA;IACnC,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;IACrC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;QAAE,GAAG,EAAE,CAAA;IAC3C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAGF;IAFrB,KAAK,CAA2B;IAExC,YAA6B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEpC,MAAM;QACb,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QACtF,OAAO,IAAI,CAAC,KAAK,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAc;QAC/B,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;QACnB,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAA6B;QACzC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;QACnB,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE;YAChF,IAAI,EAAE,KAAK;SACX,CAAC,CAAA;IACH,CAAC;CACD"}
@@ -0,0 +1,14 @@
1
+ import type { WorkflowMeta } from './types.js';
2
+ export declare function normalizePhaseTitle(value: string): string;
3
+ /**
4
+ * Split a script into its `meta` and its body. The body keeps the script's
5
+ * line breaks (the meta statement is blanked, not removed) so an error line
6
+ * still points at the author's text.
7
+ */
8
+ export declare function splitWorkflowScript(source: string): {
9
+ meta: WorkflowMeta;
10
+ body: string;
11
+ };
12
+ /** Parse `meta` from a script without executing it. Throws {@link WorkflowScriptError}. */
13
+ export declare function parseWorkflowMeta(source: string): WorkflowMeta;
14
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/meta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAA;AA0OjE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AA6CD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAuBxF;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAE9D"}