@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
@@ -32,14 +32,89 @@
32
32
  * those would change what a command line means after the rules read it, so
33
33
  * they are removed from the environment of the spawned bash.
34
34
  * `NAMZU_BASH_SHELL=/bin/sh` restores the old shell exactly.
35
+ *
36
+ * ## Windows
37
+ *
38
+ * `cmd.exe` is a dialect the permission lexer cannot read: every command
39
+ * line comes back opaque, so every call needs a person in every mode, and a
40
+ * model writes POSIX syntax that cmd cannot run. So on Windows the same rule
41
+ * applies as everywhere else: run bash where it exists, and read the line as
42
+ * bash. The bash that exists on a Windows machine is Git for Windows'
43
+ * (`findGitBash`). Without it the tool falls back to cmd, as before, and
44
+ * {@link windowsShellNotice} says so once. `NAMZU_BASH_SHELL=cmd` keeps cmd
45
+ * on a machine that has Git Bash.
35
46
  */
36
- import { spawn as nodeSpawn } from 'node:child_process';
47
+ import { execFileSync, spawn as nodeSpawn, } from 'node:child_process';
48
+ import { randomUUID } from 'node:crypto';
37
49
  import { constants, accessSync, existsSync } from 'node:fs';
38
- import { delimiter, isAbsolute, join } from 'node:path';
50
+ import { delimiter, isAbsolute, join, win32 } from 'node:path';
51
+ import { MSYS_TAG_VARIABLE, registerMsysShell } from '../process/kill-tree.js';
39
52
  const WELL_KNOWN_BASH = ['/bin/bash', '/usr/bin/bash'];
40
53
  const WELL_KNOWN_SH = ['/bin/sh', '/usr/bin/sh'];
41
54
  /** Environment variables that change what a bash command line means. */
42
55
  const BASH_STARTUP_VARIABLES = new Set(['BASH_ENV', 'ENV', 'SHELLOPTS', 'BASHOPTS']);
56
+ /** A variable of a Windows environment, whose names are not case-sensitive. */
57
+ function windowsEnv(env, name) {
58
+ const key = Object.keys(env).find((k) => k.toLowerCase() === name.toLowerCase());
59
+ return key === undefined ? undefined : env[key];
60
+ }
61
+ /** Is `path` the working directory or inside it? Windows paths compare without case. */
62
+ function insideDirectory(path, directory) {
63
+ const relative = win32.relative(directory, path);
64
+ return relative === '' || (!relative.startsWith('..') && !win32.isAbsolute(relative));
65
+ }
66
+ /**
67
+ * Git for Windows' bash.exe, found in this order:
68
+ *
69
+ * 1. `%ProgramFiles%\Git\bin\bash.exe`, then `%ProgramFiles(x86)%\Git\bin\bash.exe`;
70
+ * 2. `%LOCALAPPDATA%\\Programs\\Git\\bin\\bash.exe`, a per-user install;
71
+ * 3. the install that holds the first `git` that `where.exe git` lists: its
72
+ * `bin\bash.exe`, one or two directories up from the `git.exe` it printed.
73
+ * A hit inside the working directory is skipped, because a repository can
74
+ * carry a `git.exe` of its own and the search must not run it.
75
+ *
76
+ * There is no registry lookup, and `where bash` is never asked: on a machine
77
+ * with WSL, `System32\bash.exe` is the launcher of another system.
78
+ */
79
+ export function findGitBash(probe) {
80
+ const programFiles = windowsEnv(probe.env, 'ProgramFiles') ?? 'C:\\Program Files';
81
+ const programFilesX86 = windowsEnv(probe.env, 'ProgramFiles(x86)') ?? 'C:\\Program Files (x86)';
82
+ for (const root of [programFiles, programFilesX86]) {
83
+ const candidate = win32.join(root, 'Git', 'bin', 'bash.exe');
84
+ if (probe.isExecutable(candidate))
85
+ return candidate;
86
+ }
87
+ // A per-user install (the installer's "just me" choice) lives under LOCALAPPDATA.
88
+ const localAppData = windowsEnv(probe.env, 'LOCALAPPDATA');
89
+ if (localAppData !== undefined && localAppData !== '') {
90
+ const candidate = win32.join(localAppData, 'Programs', 'Git', 'bin', 'bash.exe');
91
+ if (probe.isExecutable(candidate))
92
+ return candidate;
93
+ }
94
+ let listed = [];
95
+ try {
96
+ listed = probe.whereGit?.() ?? [];
97
+ }
98
+ catch {
99
+ return undefined;
100
+ }
101
+ const cwd = probe.cwd ?? process.cwd();
102
+ for (const line of listed) {
103
+ const git = line.trim();
104
+ if (!win32.isAbsolute(git) || insideDirectory(git, cwd))
105
+ continue;
106
+ const directory = win32.dirname(git);
107
+ // <Git>\cmd\git.exe and <Git>\bin\git.exe, then <Git>\mingw64\bin\git.exe.
108
+ for (const candidate of [
109
+ win32.join(directory, '..', 'bin', 'bash.exe'),
110
+ win32.join(directory, '..', '..', 'bin', 'bash.exe'),
111
+ ]) {
112
+ if (probe.isExecutable(candidate))
113
+ return candidate;
114
+ }
115
+ }
116
+ return undefined;
117
+ }
43
118
  export function findCommandShell(probe) {
44
119
  const override = probe.env.NAMZU_BASH_SHELL;
45
120
  if (override !== undefined && override !== '') {
@@ -52,12 +127,27 @@ export function findCommandShell(probe) {
52
127
  ?.toLowerCase()
53
128
  .replace(/\.exe$/, '')
54
129
  : override.slice(override.lastIndexOf('/') + 1);
55
- return { path: override, dialect: name === 'bash' ? 'bash' : 'sh', source: 'override' };
130
+ // cmd is not a POSIX shell and takes no `-c`: naming it keeps Node's
131
+ // own cmd path, which is how a Windows machine with Git Bash runs the
132
+ // tool as it did before bash was preferred.
133
+ if (probe.platform === 'win32' && name === 'cmd')
134
+ return { path: undefined, dialect: 'cmd', source: 'override' };
135
+ return {
136
+ path: override,
137
+ dialect: name === 'bash' ? 'bash' : 'sh',
138
+ source: 'override',
139
+ ...(probe.platform === 'win32' ? { windows: true } : {}),
140
+ };
141
+ }
142
+ // Looking `bash` up on the Windows PATH can find WSL's launcher, which
143
+ // runs the command in another system, so only Git for Windows' own
144
+ // install is used. Without it Node's platform shell (cmd) runs the line.
145
+ if (probe.platform === 'win32') {
146
+ const gitBash = findGitBash(probe);
147
+ return gitBash === undefined
148
+ ? { path: undefined, dialect: 'cmd', source: 'platform' }
149
+ : { path: gitBash, dialect: 'bash', source: 'bash', windows: true };
56
150
  }
57
- // Windows keeps Node's platform shell. Looking `bash` up on its PATH can
58
- // find WSL's launcher, which runs the command in another system.
59
- if (probe.platform === 'win32')
60
- return { path: undefined, dialect: 'cmd', source: 'platform' };
61
151
  for (const directory of (probe.env.PATH ?? '').split(delimiter)) {
62
152
  if (directory === '' || !directory.startsWith('/'))
63
153
  continue;
@@ -71,6 +161,48 @@ export function findCommandShell(probe) {
71
161
  }
72
162
  return { path: '/bin/sh', dialect: 'sh', source: 'sh' };
73
163
  }
164
+ /**
165
+ * Said once, in the session, when a Windows machine has no Git Bash and the
166
+ * `bash` tool runs cmd.exe. Undefined everywhere else.
167
+ */
168
+ export const WINDOWS_CMD_FALLBACK_NOTICE = 'Git for Windows not found — shell commands run in cmd.exe and each one asks for approval. Install Git for Windows for full support.';
169
+ export function windowsShellNotice(shell = hostCommandShell()) {
170
+ return shell.source === 'platform' && shell.path === undefined && shell.dialect === 'cmd'
171
+ ? WINDOWS_CMD_FALLBACK_NOTICE
172
+ : undefined;
173
+ }
174
+ /**
175
+ * Is the host `bash` tool Git Bash on Windows? The model is then told so, and
176
+ * the Windows-only spawn details apply.
177
+ */
178
+ export function isWindowsBash(shell = hostCommandShell()) {
179
+ return shell.windows === true && shell.dialect === 'bash';
180
+ }
181
+ /** What a model needs to know when the `bash` tool is Git Bash on Windows, appended to the tool's description. */
182
+ export const WINDOWS_BASH_GUIDANCE = 'This tool runs Git Bash (POSIX sh), not cmd.exe or PowerShell. Use Unix shell syntax: `/dev/null` not `NUL`, forward slashes, `$VAR` not `%VAR%` or `$env:VAR`. To run PowerShell, call `powershell -NoProfile -Command "…"`.';
183
+ /**
184
+ * Rewrite a redirect to Windows' `NUL` device (`>nul`, `2>NUL`, `&>nul`) to
185
+ * `/dev/null`. In bash `nul` is an ordinary file name, so the line would
186
+ * create a file called `nul` that Windows then cannot delete. A line with
187
+ * `<`, `$` or a backtick is left alone: it may be a heredoc or a string that
188
+ * only mentions the text.
189
+ */
190
+ export function rewriteWindowsNullRedirect(command) {
191
+ if (/[<$`]/.test(command))
192
+ return command;
193
+ return command.replace(/(\d?&?>+[ \t]*)nul(?=\s|$|[|&;)\n])/gi, '$1/dev/null');
194
+ }
195
+ /** `where.exe git`, run from the system directory by its absolute path, so PATH cannot stand in for it. */
196
+ function whereGit() {
197
+ const root = process.env.SystemRoot ?? process.env.windir ?? 'C:\\Windows';
198
+ const output = execFileSync(win32.join(root, 'System32', 'where.exe'), ['git'], {
199
+ encoding: 'utf8',
200
+ windowsHide: true,
201
+ stdio: ['ignore', 'pipe', 'ignore'],
202
+ timeout: 5000,
203
+ });
204
+ return output.split(/\r?\n/);
205
+ }
74
206
  /**
75
207
  * An explicitly requested interpreter for a host script. Unlike the live
76
208
  * `bash` tool's automatic choice, this never substitutes bash for sh (or sh
@@ -122,7 +254,12 @@ let resolved;
122
254
  */
123
255
  export function hostCommandShell() {
124
256
  if (resolved === undefined) {
125
- resolved = findCommandShell({ env: process.env, platform: process.platform, isExecutable });
257
+ resolved = findCommandShell({
258
+ env: process.env,
259
+ platform: process.platform,
260
+ isExecutable,
261
+ whereGit,
262
+ });
126
263
  }
127
264
  return resolved;
128
265
  }
@@ -147,7 +284,17 @@ export function hostShellSpawn(command, env, shell = hostCommandShell()) {
147
284
  return { file: undefined, args: [command], env };
148
285
  if (shell.dialect !== 'bash')
149
286
  return { file: shell.path, args: ['-c', command], env };
150
- return { file: shell.path, args: ['-c', command], env: withoutBashStartup(env) };
287
+ const clean = withoutBashStartup(env);
288
+ // Git for Windows: the line is read as bash, so `>nul` must already have
289
+ // become `/dev/null` (the tool's input does that before the rules read it;
290
+ // this covers a caller that did not), and git must never open an editor.
291
+ if (shell.windows === true)
292
+ return {
293
+ file: shell.path,
294
+ args: ['-c', rewriteWindowsNullRedirect(command)],
295
+ env: { ...clean, GIT_EDITOR: 'true' },
296
+ };
297
+ return { file: shell.path, args: ['-c', command], env: clean };
151
298
  }
152
299
  /** Why a command could not be started, in the words a model or operator reads. */
153
300
  export function describeSpawnFailure(error, cwd) {
@@ -222,16 +369,30 @@ function windowsCmdSpawn(command, env) {
222
369
  */
223
370
  export function spawnHostShell(command, options) {
224
371
  const spawnFn = options.spawnImpl ?? nodeSpawn;
225
- const resolved = hostShellSpawn(command, options.env, options.shell);
372
+ const shell = options.shell ?? hostCommandShell();
373
+ const spawned = hostShellSpawn(command, options.env, shell);
374
+ // Git Bash: tag the shell so a kill can find what a forked command left.
375
+ const tag = shell.windows === true && shell.path !== undefined ? randomUUID() : undefined;
376
+ const resolved = tag === undefined ? spawned : { ...spawned, env: { ...spawned.env, [MSYS_TAG_VARIABLE]: tag } };
226
377
  const common = {
227
378
  cwd: options.cwd,
228
379
  env: resolved.env,
229
380
  detached: options.detached ?? (options.platform ?? process.platform) !== 'win32',
230
381
  windowsHide: true,
231
- ...(options.stdio === undefined ? {} : { stdio: options.stdio }),
382
+ // Git Bash reads no terminal: a command that asks for input gets
383
+ // end-of-file (the null device) instead of waiting for a timeout.
384
+ ...(options.stdio === undefined
385
+ ? resolved.file !== undefined && shell.windows === true
386
+ ? { stdio: ['ignore', 'pipe', 'pipe'] }
387
+ : {}
388
+ : { stdio: options.stdio }),
232
389
  };
233
- if (resolved.file !== undefined)
234
- return spawnFn(resolved.file, [...resolved.args], common);
390
+ if (resolved.file !== undefined) {
391
+ const child = spawnFn(resolved.file, [...resolved.args], common);
392
+ if (tag !== undefined && child !== null && typeof child === 'object')
393
+ registerMsysShell(child, { bash: resolved.file, tag });
394
+ return child;
395
+ }
235
396
  const windows = windowsCmdSpawn(command, resolved.env);
236
397
  return spawnFn(windows.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zu/sdk",
3
- "version": "50.0.0",
3
+ "version": "51.0.0",
4
4
  "description": "Open-source AI agent SDK with a built-in runtime. Nothing between you and your agents.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "engines": {
@@ -40,52 +40,140 @@ list of agent kinds.
40
40
  declared, not inferred.
41
41
  - **`runAgent.ts`** — the entry a host calls.
42
42
 
43
- ## The decided position: control flow is authored by a developer
44
-
45
- A model may choose *what* to do — which tool, which delegate, in what order
46
- within a turn. It does not author the *program* that runs those choices.
47
-
48
- The proposal this rules on is a model-emitted orchestration SCRIPT —
49
- `agent()`, `parallel()`, `pipeline()` as globals — executed in an isolate, so
50
- that logic between steps costs no model turns. It is refused, and the reason
51
- is the trust boundary rather than the feature's value.
52
-
53
- **The argument.** `bash` from a model is mediated by `packages/sandbox`
54
- because code from a model is untrusted input. A model-authored script is the
55
- same input through a different door, and a strictly more powerful one: it can
56
- call back into the agent surface, spawn delegates and spend budget, which a
57
- shell command reaching only the filesystem cannot. Running it in-process would
58
- leave the kernel's one clearly-drawn confinement boundary covering the weaker
59
- case and not the stronger. So an isolate is mandatory rather than an
60
- optimisation — and once it is mandatory, the capability costs a **second
61
- mediated execution surface** to secure, audit, version and keep in step with
62
- the first.
63
-
64
- **What it would buy, measured honestly.** Model turns spent on orchestration
65
- between steps. That is real, and most of it is already available: `PipelineAgent`
66
- spends none, and `SupervisorAgent`'s concurrent `create_task` fan-out spends
67
- one turn for N children. The remaining gap is orchestration a developer did
68
- not anticipate and a model invents at runtime — which is also the case where a
69
- wrong program is hardest to review before it runs.
70
-
71
- ## The bar a reopen has to clear
72
-
73
- Not "someone wants it". Specifically:
74
-
75
- 1. **A decided trust model**, in writing, before any code: mediated by
76
- `packages/sandbox` like `bash`, or not at all. "Decide later" is the
77
- answer this refusal rejects.
78
- 2. **A second execution surface worth its own maintenance** — its own
79
- confinement, its own audit records, its own version story. If the answer
80
- is "reuse the sandbox", show how a script that calls `agent()` is confined
81
- by a boundary designed for a subprocess.
82
- 3. **A measured gap**, against `PipelineAgent` and concurrent `create_task`
83
- rather than against a single sequential agent. The comparison the original
84
- proposal made was to the wrong baseline.
85
-
86
- Recorded in `ses_020`'s decision log as D5. If the owner reverses it, replace
87
- this section rather than adding to it — two stances in one file is how the
88
- first one got lost.
43
+ ## The decided position: a model may author a workflow script, confined
44
+
45
+ Decided by the owner on **2026-10-18**, reversing the earlier refusal (D5,
46
+ which kept control flow developer-authored). The earlier text named the bar a
47
+ reopen had to clear: a written trust model before any code, a second
48
+ execution surface worth its own maintenance, a measured gap. This section is
49
+ the first; the second is the code under `execution/workflow/`; the third is
50
+ the table below, measured on 2026-10-18 and not met (see its reading).
51
+
52
+ A model may choose *what* to do, and it may also author a **workflow script**:
53
+ a program run once in the background that decides how many subagents run, with
54
+ which prompts, in which order and under which phase titles. The runtime
55
+ (`WorkflowRuntime`, `docs/sdk/workflows.md`) schedules them. A workflow's
56
+ agents are not subagent rows and not separate notifications; the `Agent` tool
57
+ stays the way a model starts one subagent.
58
+
59
+ ### Trust model
60
+
61
+ 1. **The script is untrusted model input**, exactly like a `bash` command
62
+ line. It is never evaluated in the host's Node process.
63
+ 2. **Confinement is the `run_code` interpreter**, not a new one. The script
64
+ runs in a fresh QuickJS WASM interpreter in a worker thread
65
+ (`execution/code-runtime`, `WorkerCodeRuntime`): no filesystem, network,
66
+ process, module loading or host timers; JSON-only crossings; a memory
67
+ ceiling; source and value size limits; a CPU interrupt on synchronous
68
+ loops. A workflow is a second *bridge* on that surface, not a second
69
+ interpreter. The workflow bridge differs in one respect: it bounds
70
+ interpreter CPU time (per synchronous stretch and in total) instead of the
71
+ run's wall clock while the script awaits its agents, because agents take
72
+ minutes.
73
+ 3. **One capability: `agent()`.** The bridge admits exactly one host call,
74
+ `agent`. It starts a subagent through the host's own delegation path (the
75
+ same permission mode and rules, sandbox, tool sets, accounting and
76
+ cancellation as the `Agent` tool), so a script cannot widen a grant, pick a
77
+ tool set the `Agent` tool could not, run a command or read a file. Prompts
78
+ are data. `parallel`, `pipeline`, `phase`, `log`, `args` and `budget` live
79
+ inside the interpreter. The host re-validates every call; the in-interpreter
80
+ prelude is convenience, never enforcement.
81
+ 4. **Review before it runs.** The host (WF2, the CLI tool) shows the script's
82
+ `meta`, the agent cap and the script text, and the operator approves once,
83
+ unless the session is in bypass. Headless sessions with no reviewer refuse
84
+ it unless in bypass.
85
+ 5. **Opt-in offering.** The tool is offered only when the operator asked for
86
+ orchestration (hypermode, the word "workflow", or a slash command or skill).
87
+ 6. **Limits.** Concurrent agents `min(8, cpus - 2)` (at most 16); agents per
88
+ run 200 (at most 1000); script source 256 KiB; interpreter memory 64 MiB;
89
+ one bridge value 1 MiB; an optional token budget that stops new agents;
90
+ all with plain errors.
91
+ 7. **Audit.** Every run is journaled: the script and its sha256, `meta`,
92
+ `args`, one record per `agent()` request and outcome, phase announcements,
93
+ `log()` lines and the final result. Each agent keeps its own transcript.
94
+
95
+ Not in v1, each a later and separate decision: nested `workflow()`, worktree
96
+ isolation, resume from a journal, saved or named workflows.
97
+
98
+ ### The measured gap (WF3, 2026-10-18)
99
+
100
+ Same two tasks three ways on small fixture repos (a fresh git repo per run, a
101
+ checker script for correctness): **2 phases x 3 agents** (scan three packages
102
+ for a seeded defect, then fix each; the checker runs the three self-tests and
103
+ requires that nothing but the three `index.js` files changed) and a **10-item
104
+ pipeline** (extract, then write a derived file per item; the checker verifies
105
+ all ten JSON files). Ways: (a) one CLI parent fanning out with labelled `Agent`
106
+ calls (the prompt never says "workflow"), (b) concurrent `create_task` through
107
+ `SupervisorAgent` and `AgentManager` from the SDK, (c) the `workflow` tool
108
+ (`namzu exec --permission-mode auto`, prompt says "use a workflow").
109
+
110
+ **Real model**, `space-bunny-free` on the keyless Zen free route (every request
111
+ went to `opencode.ai/inference/v1/chat/completions` from an `env -i` process
112
+ with no credential, and none returned a non-200 in the rows below). Frozen
113
+ build `d8a7e2f23`. Median (min-max) over the reps that finished:
114
+
115
+ | Task | Way | Reps | Parent requests | Parent tokens | Child requests | Child tokens | Wall time | Correct |
116
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- |
117
+ | 2 phases x 3 agents | (a) `Agent` fan-out | 2 | 7 (7-7) | 117,761 (116,263-119,259) | 23 (23-23) | 181,040 (174,347-187,732) | 60 s (57-62) | 2/2 |
118
+ | 2 phases x 3 agents | (b) `create_task` | 2 | 6 (5-6) | 34,428 (28,171-40,685) | 31 (29-32) | 153,850 (142,475-165,224) | 46 s (43-49) | 2/2 |
119
+ | 2 phases x 3 agents | (c) workflow | 2 | 9 (7-11) | 150,984 (111,614-190,354) | 20 (19-21) | 152,263 (147,307-157,219) | 51 s (45-56) | 2/2 |
120
+ | 10-item pipeline | (a) `Agent` fan-out | 2 | 9 (7-11) | 188,078 (150,833-225,323) | 56 (46-65) | 426,912 (352,653-501,170) | 62 s (56-67) | 2/2 |
121
+ | 10-item pipeline | (b) `create_task` | 2 | 8 (7-9) | 69,678 (62,780-76,575) | 76 (70-82) | 356,317 (322,126-390,507) | 83 s (77-88) | 2/2 |
122
+ | 10-item pipeline | (c) workflow | 1 | 26 | 604,756 | 291 | 2,348,135 | 213 s | 1/1 |
123
+
124
+ Not measured: a second (c) rep of the 10-item pipeline. It was rate limited
125
+ mid-run (Zen answered 429 with "retry delay at least 20 hours" for every free
126
+ model, so no further real-model run was possible that day) and is excluded, not
127
+ counted as a failure.
128
+
129
+ **Scripted model**, same rows, deterministic (the model emits every call of a
130
+ stage in one response; tokens are request bytes / 4, so compare ways, not
131
+ absolutes): the parent takes **3 requests in every way** for both tasks, and
132
+ the fan-out is the same (6 children, 15 child requests; 20 children, 40 child
133
+ requests). `Agent` and `create_task` parents spend 41.8k and 44.7k estimated
134
+ tokens (CLI parent: a 27-tool prefix of about 12k tokens per request); the workflow
135
+ parent 43.7k and 43.9k; the `SupervisorAgent` harness parent 9.1k and 14.7k
136
+ because it carries no CLI system prompt or builtin tools, which is a property of
137
+ the harness and not of `create_task`.
138
+
139
+ Sources: parent and child request counts and tokens are summed from the
140
+ `message_completed` records of the root session JSONL and of
141
+ `<session>/subagents/*.jsonl` (cross-checked against a fetch-recording
142
+ `--require` hook: parent + child requests equalled the hook's count of chat
143
+ requests in every CLI run); for (b) from the `SupervisorAgent` result and the
144
+ same hook (parent = requests offering `create_task`). Wall time is the process's
145
+ own, start to exit.
146
+
147
+ **Reading.** There is no measured gap in the workflow's favour, and on this
148
+ model it lost the larger task.
149
+
150
+ - The two-phase task is a tie. Parent requests (7, 6, 9) and wall time (60, 46,
151
+ 51 s) are within each other's range, every run was correct, and the workflow
152
+ parent spent as many or more tokens than the `Agent` parent. The parent's cost
153
+ is the request prefix times the number of requests, and a model offered
154
+ `workflow` still explored first, kept a task list and verified afterwards, as
155
+ the `Agent` parent did.
156
+ - With a model that batches the calls of a stage into one response, a fan-out
157
+ needs no more parent requests than a workflow (3 and 3), so the workflow does
158
+ not save requests on a fixed two-stage shape. What a workflow could still
159
+ buy is not exercised here: children returned one line each, so the parent
160
+ context never grew, and there was no failure to repair mid-run. Concurrency
161
+ does not separate them either: the `Agent` parent also ran at most 8 children
162
+ at once (measured from the child sessions' timestamps).
163
+ - The 10-item pipeline run took 5 workflow runs. The model's script misused
164
+ `pipeline` (first argument not an array, though the tool description gives the
165
+ signature), asked children for schema-validated JSON that 4 of 10 did not
166
+ produce, and passed `args.ids` as numbers while believing they were strings, so
167
+ its padded file names came out wrong. Each repair re-ran the work, which is why
168
+ child requests and tokens are 5x and 6x the `Agent` way. Whether a stronger
169
+ model scripts it in one run is not measured.
170
+ - Caveat on (b): the harness parent has no CLI prompt, so its parent-token
171
+ column is not comparable to (a) and (c).
172
+ - Caveat on scale: two reps, one model, two fixtures. The ranges overlap for
173
+ every comparison except the pipeline's workflow row.
174
+
175
+ If a later change reverses this again, replace this section rather than
176
+ adding to it: two stances in one file is how the first one got lost.
89
177
 
90
178
  ## Working here
91
179
 
@@ -83,11 +83,47 @@ export interface RunCodeOptions {
83
83
  */
84
84
  readonly maxOutputBytes: number
85
85
  readonly signal?: AbortSignal
86
+ /**
87
+ * Replace the single wall-clock interrupt with a CPU budget.
88
+ *
89
+ * By default `timeoutMs` bounds synchronous interpreter execution as well
90
+ * as the whole run, so a program waiting on slow host calls is stopped at
91
+ * the same deadline as one spinning in a loop. A host that legitimately
92
+ * awaits long host operations (a workflow awaiting subagents) sets this:
93
+ * the interpreter is then interrupted when ONE synchronous slice (the time
94
+ * between entering the interpreter and handing control back) exceeds
95
+ * `sliceMs`, or all slices together exceed `totalMs`. Time spent awaiting
96
+ * the host is not counted. `timeoutMs` still bounds the run's wall clock.
97
+ */
98
+ readonly cpuLimits?: { readonly sliceMs: number; readonly totalMs: number }
99
+ /**
100
+ * Called with each line the program prints, in order, as it is printed and
101
+ * within `maxOutputBytes`. A line is data, not a capability: the callback
102
+ * must treat it as untrusted text.
103
+ */
104
+ readonly onOutput?: (line: string) => void
105
+ }
106
+
107
+ export interface CodeFrame {
108
+ readonly line: number
109
+ readonly column: number
86
110
  }
87
111
 
88
112
  export type CodeRunOutcome =
89
113
  | { readonly status: 'completed'; readonly result: unknown }
90
- | { readonly status: 'failed'; readonly error: string }
114
+ | {
115
+ readonly status: 'failed'
116
+ readonly error: string
117
+ /** The thrown value's `name`, when it was an error object. */
118
+ readonly errorName?: string
119
+ /**
120
+ * Where the interpreter says the program failed: innermost first, line and
121
+ * column counted in the submitted `source` (1-based). Absent when the
122
+ * interpreter gave no location (a non-error was thrown, or the failure was
123
+ * not in the program).
124
+ */
125
+ readonly frames?: readonly CodeFrame[]
126
+ }
91
127
  | { readonly status: 'timed-out' }
92
128
  | { readonly status: 'cancelled' }
93
129