@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36

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 (450) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/README.md +339 -179
  3. package/dist/adapters.d.ts +15 -2
  4. package/dist/adapters.js +34 -2
  5. package/dist/agent-rows.d.ts +3 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +25 -5
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +90 -8
  13. package/dist/archil-settings.js +150 -14
  14. package/dist/attach-images.d.ts +15 -0
  15. package/dist/attach-images.js +59 -0
  16. package/dist/background.d.ts +0 -6
  17. package/dist/background.js +0 -28
  18. package/dist/bash-read-only.d.ts +13 -0
  19. package/dist/bash-read-only.js +77 -0
  20. package/dist/box-image.d.ts +1 -97
  21. package/dist/box-image.js +4 -284
  22. package/dist/box-paths.d.ts +2 -7
  23. package/dist/box-paths.js +7 -13
  24. package/dist/box-settings.d.ts +0 -11
  25. package/dist/box-settings.js +4 -29
  26. package/dist/browser-commands.js +1 -1
  27. package/dist/browser-computer.d.ts +47 -3
  28. package/dist/browser-computer.js +286 -18
  29. package/dist/browser-cost.d.ts +2 -2
  30. package/dist/browser-cost.js +6 -4
  31. package/dist/browser-person.d.ts +19 -2
  32. package/dist/browser-person.js +55 -6
  33. package/dist/browser-wait-ended.d.ts +23 -0
  34. package/dist/browser-wait-ended.js +42 -0
  35. package/dist/cap.d.ts +19 -44
  36. package/dist/cap.js +31 -77
  37. package/dist/cli.js +36 -27
  38. package/dist/computer-keys.d.ts +20 -10
  39. package/dist/computer-keys.js +36 -57
  40. package/dist/computer-routes.d.ts +1 -4
  41. package/dist/computer-routes.js +3 -5
  42. package/dist/computer-setting.d.ts +8 -5
  43. package/dist/computer-setting.js +91 -26
  44. package/dist/computer-view.d.ts +11 -2
  45. package/dist/computer-view.js +2 -1
  46. package/dist/computers.d.ts +54 -8
  47. package/dist/computers.js +101 -22
  48. package/dist/console/assets/index-BI4Byidu.js +550 -0
  49. package/dist/console/assets/index-C19gUF2n.css +1 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/content-filter.d.ts +7 -0
  52. package/dist/content-filter.js +23 -0
  53. package/dist/decision-cap.d.ts +7 -29
  54. package/dist/decision-cap.js +3 -94
  55. package/dist/docker-daemon.d.ts +2 -2
  56. package/dist/docker-daemon.js +2 -2
  57. package/dist/errors.d.ts +1 -0
  58. package/dist/errors.js +8 -5
  59. package/dist/explain.js +3 -1
  60. package/dist/faux-computers.js +4 -0
  61. package/dist/files.d.ts +1 -9
  62. package/dist/files.js +1 -9
  63. package/dist/github-connection.js +25 -7
  64. package/dist/github-faux.d.ts +26 -0
  65. package/dist/github-faux.js +76 -0
  66. package/dist/github.d.ts +28 -4
  67. package/dist/github.js +46 -10
  68. package/dist/gpu-words.d.ts +14 -0
  69. package/dist/gpu-words.js +21 -0
  70. package/dist/graph-served.d.ts +5 -3
  71. package/dist/graph-served.js +14 -6
  72. package/dist/graph-view.d.ts +2 -0
  73. package/dist/graph-view.js +29 -2
  74. package/dist/handed-values.d.ts +1 -1
  75. package/dist/handed-values.js +1 -1
  76. package/dist/harness-install.d.ts +60 -3
  77. package/dist/harness-install.js +322 -34
  78. package/dist/harness-opencode/harness.js +0 -1
  79. package/dist/harness-opencode/host/policy.js +2 -2
  80. package/dist/harness.js +1 -1
  81. package/dist/host-tools.d.ts +8 -9
  82. package/dist/host-tools.js +7 -7
  83. package/dist/index.d.ts +2 -3
  84. package/dist/index.js +2 -2
  85. package/dist/key-refusal.d.ts +1 -1
  86. package/dist/key-refusal.js +2 -2
  87. package/dist/learn/check.d.ts +10 -2
  88. package/dist/learn/check.js +126 -8
  89. package/dist/learn/commit.d.ts +40 -6
  90. package/dist/learn/commit.js +164 -20
  91. package/dist/learn/folder.d.ts +11 -3
  92. package/dist/learn/folder.js +40 -16
  93. package/dist/learn/grade.d.ts +22 -2
  94. package/dist/learn/grade.js +127 -19
  95. package/dist/learn/index.d.ts +2 -2
  96. package/dist/learn/index.js +2 -2
  97. package/dist/learn/learning.sh +11 -13
  98. package/dist/learn/notes.d.ts +17 -3
  99. package/dist/learn/notes.js +19 -6
  100. package/dist/learn/reflect.d.ts +5 -2
  101. package/dist/learn/reflect.js +48 -32
  102. package/dist/learn/skills.d.ts +52 -5
  103. package/dist/learn/skills.js +104 -21
  104. package/dist/learned-nodes.d.ts +18 -0
  105. package/dist/learned-nodes.js +8 -0
  106. package/dist/learned-workflow.d.ts +27 -13
  107. package/dist/learned-workflow.js +110 -38
  108. package/dist/learning-cost.d.ts +79 -0
  109. package/dist/learning-cost.js +69 -0
  110. package/dist/learning-routes.d.ts +48 -2
  111. package/dist/learning-routes.js +99 -28
  112. package/dist/learning-run.d.ts +7 -5
  113. package/dist/learning-run.js +9 -6
  114. package/dist/learning-words.d.ts +3 -0
  115. package/dist/learning-words.js +6 -2
  116. package/dist/learning.d.ts +13 -28
  117. package/dist/learning.js +4 -18
  118. package/dist/llm.d.ts +4 -1
  119. package/dist/llm.js +4 -2
  120. package/dist/mcp-gateway.d.ts +6 -0
  121. package/dist/mcp-gateway.js +11 -1
  122. package/dist/mcp-probe.d.ts +8 -1
  123. package/dist/mcp-probe.js +62 -20
  124. package/dist/mcp-secret-writes.js +4 -0
  125. package/dist/mcp-servers-store.d.ts +12 -12
  126. package/dist/mcp-servers-store.js +8 -3
  127. package/dist/model.d.ts +8 -5
  128. package/dist/model.js +14 -6
  129. package/dist/openapi.d.ts +2 -0
  130. package/dist/openapi.js +236 -55
  131. package/dist/owner.d.ts +0 -1
  132. package/dist/owner.js +0 -2
  133. package/dist/pause.d.ts +2 -19
  134. package/dist/pause.js +5 -74
  135. package/dist/place-offers.d.ts +97 -0
  136. package/dist/place-offers.js +206 -0
  137. package/dist/place.d.ts +9 -13
  138. package/dist/place.js +22 -32
  139. package/dist/port-models.d.ts +12 -4
  140. package/dist/port-models.js +31 -9
  141. package/dist/print.d.ts +1 -8
  142. package/dist/print.js +1 -14
  143. package/dist/propose.d.ts +3 -0
  144. package/dist/propose.js +25 -19
  145. package/dist/run-cut.d.ts +5 -0
  146. package/dist/run-cut.js +19 -0
  147. package/dist/run-db.js +3 -3
  148. package/dist/run-launch.d.ts +18 -3
  149. package/dist/run-launch.js +11 -5
  150. package/dist/run-learning-served.d.ts +12 -1
  151. package/dist/run-manifest.d.ts +2 -2
  152. package/dist/run-manifest.js +2 -2
  153. package/dist/run-reads-over-store.d.ts +4 -2
  154. package/dist/run-reads-over-store.js +10 -8
  155. package/dist/run-secrets.js +3 -3
  156. package/dist/run-timeline-served.js +60 -38
  157. package/dist/run-view.d.ts +35 -16
  158. package/dist/run-view.js +64 -35
  159. package/dist/runnable.d.ts +6 -3
  160. package/dist/runnable.js +20 -4
  161. package/dist/runner/adapter-loop.d.ts +46 -5
  162. package/dist/runner/adapter-loop.js +381 -56
  163. package/dist/runner/adapter-run-spec.d.ts +46 -4
  164. package/dist/runner/adapter-run-spec.js +200 -45
  165. package/dist/runner/adapters/pi.d.ts +39 -3
  166. package/dist/runner/adapters/pi.js +124 -29
  167. package/dist/runner/beside.d.ts +8 -0
  168. package/dist/runner/beside.js +24 -2
  169. package/dist/runner/claim-secrets.d.ts +6 -0
  170. package/dist/runner/claim-secrets.js +15 -1
  171. package/dist/runner/cli-run-spec.d.ts +10 -0
  172. package/dist/runner/cli-run-spec.js +207 -64
  173. package/dist/runner/commands.d.ts +5 -1
  174. package/dist/runner/commands.js +3 -3
  175. package/dist/runner/conformance/harness.d.ts +1 -1
  176. package/dist/runner/conformance/harness.js +13 -10
  177. package/dist/runner/github-app.d.ts +7 -2
  178. package/dist/runner/github-app.js +46 -15
  179. package/dist/runner/harness-loops.d.ts +6 -1
  180. package/dist/runner/harness-loops.js +24 -1
  181. package/dist/runner/journal-kinds.d.ts +53 -7
  182. package/dist/runner/journal-kinds.js +29 -1
  183. package/dist/runner/learning-end.d.ts +15 -0
  184. package/dist/runner/learning-end.js +113 -20
  185. package/dist/runner/learning-factory.js +6 -2
  186. package/dist/runner/learning-loop.d.ts +75 -1
  187. package/dist/runner/learning-loop.js +215 -22
  188. package/dist/runner/learning-seed.d.ts +8 -0
  189. package/dist/runner/learning-seed.js +7 -1
  190. package/dist/runner/loop-contract.d.ts +12 -0
  191. package/dist/runner/loop-contract.js +6 -0
  192. package/dist/runner/loop.d.ts +5 -1
  193. package/dist/runner/loop.js +20 -0
  194. package/dist/runner/main.d.ts +9 -4
  195. package/dist/runner/main.js +38 -13
  196. package/dist/runner/mcp-claim.d.ts +7 -0
  197. package/dist/runner/mcp-claim.js +35 -2
  198. package/dist/runner/mcp-github.d.ts +15 -4
  199. package/dist/runner/mcp-github.js +55 -11
  200. package/dist/runner/mcp-run.d.ts +2 -0
  201. package/dist/runner/mcp-run.js +2 -0
  202. package/dist/runner/metrics.d.ts +18 -1
  203. package/dist/runner/metrics.js +81 -1
  204. package/dist/runner/model-route.d.ts +6 -0
  205. package/dist/runner/model-route.js +5 -2
  206. package/dist/runner/pr-checkout.d.ts +59 -0
  207. package/dist/runner/pr-checkout.js +176 -0
  208. package/dist/runner/reflect-hook.d.ts +1 -0
  209. package/dist/runner/reflect-hook.js +3 -3
  210. package/dist/runner/runner.js +136 -19
  211. package/dist/runner/spec-holds.d.ts +13 -3
  212. package/dist/runner/spec-holds.js +13 -10
  213. package/dist/runner/store-port.d.ts +4 -1
  214. package/dist/runner/store-secrets.js +17 -1
  215. package/dist/runner/subagent.d.ts +44 -0
  216. package/dist/runner/subagent.js +188 -0
  217. package/dist/runner/workflow-host.d.ts +25 -4
  218. package/dist/runner/workflow-host.js +26 -4
  219. package/dist/runner/workflow-loop.d.ts +9 -3
  220. package/dist/runner/workflow-loop.js +17 -10
  221. package/dist/runner/workflow-spec.d.ts +28 -13
  222. package/dist/runner/workflow-spec.js +247 -102
  223. package/dist/runs-over-store.d.ts +18 -7
  224. package/dist/runs-over-store.js +149 -31
  225. package/dist/seal-key.d.ts +0 -2
  226. package/dist/seal-key.js +0 -2
  227. package/dist/sealing.js +1 -2
  228. package/dist/secret-cut.d.ts +1 -1
  229. package/dist/secret-cut.js +1 -1
  230. package/dist/server-lock.js +4 -5
  231. package/dist/server.d.ts +49 -63
  232. package/dist/server.js +429 -230
  233. package/dist/stop-signals.d.ts +4 -2
  234. package/dist/stop-signals.js +5 -3
  235. package/dist/store/agent-body.d.ts +14 -3
  236. package/dist/store/agent-body.js +22 -8
  237. package/dist/store/deadline.d.ts +18 -0
  238. package/dist/store/deadline.js +49 -0
  239. package/dist/store/index.d.ts +3 -3
  240. package/dist/store/index.js +2 -2
  241. package/dist/store/journal/storage.js +2 -1
  242. package/dist/store/postgres/connection.d.ts +4 -0
  243. package/dist/store/postgres/connection.js +64 -13
  244. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  245. package/dist/store/schema.d.ts +2 -1
  246. package/dist/store/schema.js +11 -8
  247. package/dist/store/seal.d.ts +13 -0
  248. package/dist/store/seal.js +19 -0
  249. package/dist/store/sqlite/connection.d.ts +5 -0
  250. package/dist/store/sqlite/connection.js +88 -82
  251. package/dist/store/sqlite/run-patch.d.ts +18 -2
  252. package/dist/store/sqlite/run-patch.js +31 -2
  253. package/dist/store/sqlite/store.js +65 -11
  254. package/dist/store/store.d.ts +62 -12
  255. package/dist/store/store.js +22 -1
  256. package/dist/store-reads/analytics.js +3 -2
  257. package/dist/store-reads/cap.d.ts +1 -3
  258. package/dist/store-reads/cap.js +8 -6
  259. package/dist/store-reads/decisions.d.ts +2 -2
  260. package/dist/store-reads/decisions.js +3 -6
  261. package/dist/store-reads/journal.js +83 -15
  262. package/dist/store-reads/learning.d.ts +73 -3
  263. package/dist/store-reads/learning.js +232 -9
  264. package/dist/store-reads/runs.d.ts +6 -4
  265. package/dist/store-reads/runs.js +17 -10
  266. package/dist/store-reads/stats.js +5 -1
  267. package/dist/store-view.d.ts +15 -1
  268. package/dist/store-view.js +88 -29
  269. package/dist/template-eval.js +2 -1
  270. package/dist/templates.d.ts +73 -4
  271. package/dist/templates.js +113 -23
  272. package/dist/timeline/timeline.d.ts +11 -1
  273. package/dist/timeline/timeline.js +19 -4
  274. package/dist/tool-blurbs.js +1 -0
  275. package/dist/tool-budget.d.ts +26 -0
  276. package/dist/tool-budget.js +56 -0
  277. package/dist/tool-gate.d.ts +13 -3
  278. package/dist/tool-gate.js +15 -7
  279. package/dist/tool-plane.d.ts +42 -29
  280. package/dist/tool-plane.js +64 -27
  281. package/dist/tools.d.ts +53 -39
  282. package/dist/tools.js +174 -79
  283. package/dist/trigger-signatures.d.ts +1 -0
  284. package/dist/trigger-signatures.js +3 -1
  285. package/dist/triggers.d.ts +3 -3
  286. package/dist/triggers.js +2 -2
  287. package/dist/turn-end.d.ts +0 -3
  288. package/dist/turn-end.js +0 -3
  289. package/dist/uploads.d.ts +28 -5
  290. package/dist/uploads.js +82 -9
  291. package/dist/usage-lines.d.ts +1 -1
  292. package/dist/usage.d.ts +1 -47
  293. package/dist/usage.js +3 -82
  294. package/dist/validate.d.ts +8 -0
  295. package/dist/validate.js +40 -3
  296. package/dist/webhooks.d.ts +2 -1
  297. package/dist/webhooks.js +5 -2
  298. package/dist/workflow/decision-recovery.d.ts +23 -0
  299. package/dist/workflow/decision-recovery.js +80 -0
  300. package/dist/workflow/decisions.d.ts +134 -0
  301. package/dist/workflow/decisions.js +46 -0
  302. package/dist/workflow/host-session.d.ts +5 -0
  303. package/dist/workflow/host-session.js +85 -0
  304. package/dist/workflow/host-tools.d.ts +3 -0
  305. package/dist/workflow/host-tools.js +3 -0
  306. package/dist/workflow/node-runner.d.ts +112 -0
  307. package/dist/workflow/node-runner.js +270 -0
  308. package/dist/workflow/node.d.ts +88 -0
  309. package/dist/workflow/node.js +99 -0
  310. package/dist/workflow/operator-error.d.ts +4 -0
  311. package/dist/workflow/operator-error.js +4 -0
  312. package/dist/workflow/pi-versions.d.ts +9 -0
  313. package/dist/workflow/pi-versions.js +8 -0
  314. package/dist/workflow/readers.d.ts +36 -0
  315. package/dist/workflow/readers.js +145 -0
  316. package/dist/workflow/record-file.d.ts +10 -0
  317. package/dist/workflow/record-file.js +56 -0
  318. package/dist/workflow/record-tool.d.ts +76 -0
  319. package/dist/workflow/record-tool.js +126 -0
  320. package/dist/workflow/record.d.ts +151 -0
  321. package/dist/workflow/record.js +401 -0
  322. package/dist/workflow/run-error.d.ts +16 -0
  323. package/dist/workflow/run-error.js +26 -0
  324. package/dist/workflow/runner.d.ts +6 -0
  325. package/dist/workflow/runner.js +240 -0
  326. package/dist/workflow/store.d.ts +23 -0
  327. package/dist/workflow/store.js +242 -0
  328. package/dist/workflow/task.d.ts +133 -0
  329. package/dist/workflow/task.js +411 -0
  330. package/dist/workflow/thinking.d.ts +3 -0
  331. package/dist/workflow/thinking.js +7 -0
  332. package/dist/workflow/tool-context.d.ts +21 -0
  333. package/dist/workflow/tool-context.js +13 -0
  334. package/dist/workflow/types.d.ts +126 -0
  335. package/dist/workflow/types.js +1 -0
  336. package/dist/workflow/wal.d.ts +11 -0
  337. package/dist/workflow/wal.js +106 -0
  338. package/dist/workflow-run.d.ts +1 -1
  339. package/dist/workspace/agent-computer.d.ts +137 -0
  340. package/dist/workspace/agent-computer.js +292 -0
  341. package/dist/workspace/archil-claim.d.ts +13 -2
  342. package/dist/workspace/archil-claim.js +22 -13
  343. package/dist/workspace/archil-disk.d.ts +10 -1
  344. package/dist/workspace/archil-disk.js +4 -0
  345. package/dist/workspace/archil-disks.d.ts +49 -0
  346. package/dist/workspace/archil-disks.js +185 -0
  347. package/dist/workspace/archil-exec.d.ts +12 -2
  348. package/dist/workspace/archil-exec.js +18 -3
  349. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  350. package/dist/workspace/archil-mount-credential.js +13 -4
  351. package/dist/workspace/archil.d.ts +2 -2
  352. package/dist/workspace/archil.js +25 -5
  353. package/dist/workspace/attach.js +2 -0
  354. package/dist/workspace/computer-deps.d.ts +18 -11
  355. package/dist/workspace/computer-deps.js +64 -40
  356. package/dist/workspace/computer-for-claim.d.ts +47 -9
  357. package/dist/workspace/computer-for-claim.js +236 -24
  358. package/dist/workspace/computer-janitor.d.ts +3 -2
  359. package/dist/workspace/computer-janitor.js +43 -9
  360. package/dist/workspace/computer-ledger.d.ts +3 -8
  361. package/dist/workspace/computer-ledger.js +7 -3
  362. package/dist/workspace/computer-providers.d.ts +5 -3
  363. package/dist/workspace/computer-providers.js +11 -9
  364. package/dist/workspace/hands.d.ts +5 -2
  365. package/dist/workspace/hands.js +4 -3
  366. package/dist/workspace/index.d.ts +5 -4
  367. package/dist/workspace/index.js +2 -1
  368. package/dist/workspace/local.d.ts +3 -0
  369. package/dist/workspace/local.js +9 -0
  370. package/dist/workspace/paths.js +3 -2
  371. package/dist/workspace/pi-env.d.ts +4 -0
  372. package/dist/workspace/pi-env.js +3 -2
  373. package/dist/workspace/resolve-computer.d.ts +48 -12
  374. package/dist/workspace/resolve-computer.js +88 -19
  375. package/dist/workspace/run-disk.d.ts +34 -0
  376. package/dist/workspace/run-disk.js +91 -0
  377. package/dist/workspace/run-tools.d.ts +6 -4
  378. package/dist/workspace/run-tools.js +17 -9
  379. package/dist/workspace/server-run-workspace.d.ts +3 -2
  380. package/dist/workspace/server-run-workspace.js +17 -4
  381. package/dist/workspace/workspace.d.ts +5 -0
  382. package/dist/workspace.d.ts +0 -3
  383. package/dist/workspace.js +2 -15
  384. package/package.json +11 -16
  385. package/skills/agentrun-serve/SKILL.md +1 -1
  386. package/templates/README.md +11 -8
  387. package/templates/code-review/agent.md +27 -11
  388. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  389. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  390. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  391. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  392. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  393. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  394. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  395. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  396. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  397. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  398. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  399. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  400. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  401. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  402. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  403. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  404. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  405. package/templates/code-review/evals/re-review/prompt.md +1 -1
  406. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  407. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  408. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  409. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  410. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  411. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  412. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  413. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  414. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  415. package/templates/code-review/findings.schema.json +131 -27
  416. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  417. package/templates/code-review/skills/review/DEEP.md +130 -0
  418. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  419. package/templates/code-review/skills/review/SKILL.md +104 -154
  420. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  421. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  422. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  423. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  424. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  425. package/templates/release-notes/agent.md +11 -0
  426. package/dist/box/record.d.ts +0 -6
  427. package/dist/box/record.js +0 -41
  428. package/dist/box/sweep.d.ts +0 -53
  429. package/dist/box/sweep.js +0 -193
  430. package/dist/box-egress-vm.d.ts +0 -118
  431. package/dist/box-egress-vm.js +0 -354
  432. package/dist/box-egress.d.ts +0 -105
  433. package/dist/box-egress.js +0 -256
  434. package/dist/box-relay-vm.d.ts +0 -84
  435. package/dist/box-relay-vm.js +0 -437
  436. package/dist/box-relay.d.ts +0 -36
  437. package/dist/box-relay.js +0 -207
  438. package/dist/boxes.d.ts +0 -109
  439. package/dist/boxes.js +0 -249
  440. package/dist/budget.d.ts +0 -76
  441. package/dist/budget.js +0 -204
  442. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  443. package/dist/console/assets/index-opTN5Naq.css +0 -1
  444. package/dist/daytona-api.d.ts +0 -10
  445. package/dist/daytona-api.js +0 -20
  446. package/dist/egress-proxy.d.ts +0 -45
  447. package/dist/egress-proxy.js +0 -416
  448. package/dist/egress-table.d.ts +0 -24
  449. package/dist/egress-table.js +0 -165
  450. package/templates/code-review/rules/REVIEW.md +0 -41
package/README.md CHANGED
@@ -9,7 +9,7 @@ runner starts beside the server. The capabilities document (`GET /v2/capabilitie
9
9
 
10
10
  ## Quick start (no key, no network)
11
11
 
12
- Node 24.11 or later. In a checkout of this repository:
12
+ Node 24.22.3 or later. In a checkout of this repository:
13
13
 
14
14
  ```sh
15
15
  npm ci --ignore-scripts && npm run build
@@ -32,10 +32,8 @@ Boxes: docker (on by default; set AGENTRUN_BOXES to change).
32
32
  Set your password: http://127.0.0.1:7340/setup (the first visit sets it)
33
33
  ```
34
34
 
35
- When the box image is not built yet, a line after the banner says its first build is under way (`Preparing the Docker
36
- box image (first start only, a few minutes); agents can be made now, and their first run waits for it.`), and another
37
- when it ends (`The Docker box image is ready.`, or why it failed). `npx @parcha/agentrun` prints the `Boxes:` line and
38
- these two on stderr, after its own line on stdout. On a machine where Docker is not running, the `Boxes:` line says so instead (`Boxes: none, so new agents run on the
35
+ A Docker box's image is built on its first run, which shows that on its timeline. `npx @parcha/agentrun` prints the
36
+ `Boxes:` line on stderr, after its own line on stdout. On a machine where Docker is not running, the `Boxes:` line says so instead (`Boxes: none, so new agents run on the
39
37
  runner. Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart
40
38
  AgentRun.`); see [Boxes](#boxes).
41
39
 
@@ -93,11 +91,9 @@ node packages/serve/dist/cli.js
93
91
  Its log says `event=boxes available=docker`, and its banner's last line `Boxes: docker (on by default; set
94
92
  AGENTRUN_BOXES to change). docker boxes reach only pypi.org, files.pythonhosted.org, registry.npmjs.org, registry.yarnpkg.com,
95
93
  github.com, and codeload.github.com.` (on Linux; elsewhere it says why the box has no
96
- network: [Sandbox](#sandbox)). The first start builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
97
- about 300 MB, a minute or two, the build alone on the network): its banner then says `Boxes: docker is preparing
98
- (building the box image (python, git, curl, node, npm, rg)).`, and the log `event=box_image ... state=preparing`, then
99
- `state=ready` with how long it took; a later start finds it built. A run that needs its box sooner waits for it, with a
100
- row on its timeline saying so. In a second shell, export the two `AGENTRUN_` lines it printed (a later start prints
94
+ network: [Sandbox](#sandbox)). The first sandbox run builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
95
+ about 300 MB, a minute or two, the build alone on the network), with a row on its timeline saying so; a later run finds
96
+ it built. In a second shell, export the two `AGENTRUN_` lines it printed (a later start prints
101
97
  where the key is: `export AGENTRUN_API_KEY=$(cat ~/.local/share/agentrun/agents/.token)`). Then make a sandbox agent,
102
98
  run it, watch it, and read the file it wrote:
103
99
 
@@ -142,9 +138,7 @@ at=2026-10-25T21:04:09.010Z event=auth_failed route=/v2/runs reason=wrong_token
142
138
  A request's path has no query. `auth_failed` names the route and why (`no_credential`, `wrong_token`,
143
139
  `wrong_link_token`, `wrong_password`, `sign_in_table_full`), never the token given nor any part of it. `AGENTRUN_LOG=quiet` leaves out the request lines; the
144
140
  run and `auth_failed` lines stay. A run whose process failed at its start says why in its `error.message`, in words.
145
- One line at start, `event=boxes`, says which boxes this server has ([Boxes](#boxes)), and with a Docker box,
146
- `event=box_image` says whether its image is `ready`, `preparing` (being built or pulled) or `unavailable` and why, again
147
- when that ends; quiet keeps them too.
141
+ One line at start, `event=boxes`, says which boxes this server has ([Boxes](#boxes)); quiet keeps it too.
148
142
  `event=harness_offers why=start ms=<n>` says how long the server took to check what each harness offers (each CLI's
149
143
  package and pins; [harnesses](#harnesses)), the bulk of its start; quiet keeps it too. It is made at the start only: a
150
144
  PUT of `/settings/tools` and a save or delete of a tool key change no harness's offer, so they remake capabilities at
@@ -180,12 +174,13 @@ docker compose logs agentrun | grep Open
180
174
  The `.env` beside `compose.yaml` keeps the socket's group (`DOCKER_GID`) for every later `docker compose` command, in any
181
175
  shell: compose reads it each time, and `compose.yaml` needs it to be read at all.
182
176
 
183
- This `compose.yaml` doesn't pass `AGENTRUN_SEAL_KEY` to the server yet (#2164), so the server keeps its seal key inside
184
- the container, outside `/data`: recreating the container loses every saved key and sign-in. Until that's fixed, use
185
- [`deploy/compose.yaml`](../../deploy/README.md), which requires the key, or don't recreate the container.
177
+ This `compose.yaml` passes `AGENTRUN_SEAL_KEY` from the `.env` to the server and refuses to start without it, so the key that
178
+ seals every saved key, MCP credential and sign-in is kept outside the container and the data volume. Keep that `.env`
179
+ line. A store whose secrets were sealed with another key refuses to start, and the server never makes a new key over
180
+ sealed secrets, so a lost key is not replaced: recreating the container with the same key opens the store as before.
186
181
 
187
182
  From a checkout, the same command in its root, with `--build` to build the image from it.
188
- `packages/serve/docker/Dockerfile` builds that image: the server and the open packages it runs, on Node 22 and Debian 13
183
+ `packages/serve/docker/Dockerfile` builds that image: the server and the open packages it runs, on Node 24.22.3 and Debian 13
189
184
  (trixie), with git 2.47 for an agent's learning folder and the Docker client. Everything it keeps is under `/data`: the agent store,
190
185
  the runs and the token.
191
186
 
@@ -289,15 +284,16 @@ when it does and 1 when it does not, and 2 when no name is given. Name a runner
289
284
 
290
285
  ## Sandbox
291
286
 
292
- A sandbox agent's `bash` runs in a box, a machine apart from this server: today a Docker container made for each run,
293
- which binds the run's `work/` and nothing else, or a Daytona sandbox, which gets a copy of it. Neither holds a key. A
294
- Docker box on Linux reaches the package registries and GitHub through a proxy, and nothing else; a Daytona box reaches
295
- them through Daytona's domain list. Its `read`, `write` and `edit` work on that same `work/`: on this server, where the box binds it and this server
287
+ A sandbox agent's `bash` runs in a box, a machine apart from this server. Docker is the default box and the only one offered
288
+ with no setup: a Docker container made for each run, which binds the run's `work/` and nothing else. A Daytona or Modal box
289
+ runs on a computer from that provider, offered once `AGENTRUN_BOXES` lists it and the keys its computer provider needs are
290
+ set (the environment, or Settings → Computers). No box holds a key. A Docker box on Linux reaches the package registries
291
+ and GitHub through a proxy, and nothing else; a Daytona or Modal box is made with no network when a host list is set, and
292
+ capabilities say so in its `places.boxes` entry. Its `read`, `write` and `edit` work on that same `work/`: on this server, where the box binds it and this server
296
293
  holds directory handles (Docker on Linux), else in the box. The agent's loop, its log, its model calls and every key stay
297
294
  on the server. An agent says so in its [place](#place); the server says which [boxes](#boxes) it has; [a run in a Docker
298
- box](#a-run-in-a-docker-box) is what the container gets, and [a run in a Daytona box](#a-run-in-a-daytona-box) what a
299
- Daytona sandbox gets;
300
- [the box's image](#the-boxs-image) is what it starts from. [Sandbox in 60 seconds](#sandbox-in-60-seconds) is all of it
295
+ box](#a-run-in-a-docker-box) is what the container gets; [the box's image](#the-boxs-image) is what it starts from.
296
+ [Sandbox in 60 seconds](#sandbox-in-60-seconds) is all of it
301
297
  end to end. The [published image](#in-the-published-image) hosts Docker boxes through the host's Docker socket.
302
298
 
303
299
  ### Place
@@ -313,8 +309,7 @@ remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox"
313
309
  place keeps it, `runner` included. An edit that names no place keeps the agent's.
314
310
 
315
311
  The box is a new agent's default machine. A new agentic agent whose definition names no place is saved in the Docker box
316
- (`{"mode": "sandbox", "box": "docker"}`) wherever this server has docker, ready or still preparing its image (its first
317
- run then waits for the image, with one timeline row). The place is written on the agent's first revision, so its answers
312
+ (`{"mode": "sandbox", "box": "docker"}`) wherever this server has docker. The place is written on the agent's first revision, so its answers
318
313
  show it. If that definition names no `tools` either, it gets `["bash", "bash_background", "bash_output", "bash_input",
319
314
  "bash_signal", "bash_list"]`, so the agent has a shell and can run a command in the background
320
315
  ([background processes](#background-processes)). A definition that
@@ -344,8 +339,8 @@ or none (`422` on a sandbox, with the runner place as its `fix`). In `capabiliti
344
339
  with a `reason` (`no box is set up on this server: …`, each box's own reason) when no box this server has can run it and
345
340
  the server is in Mode 1.
346
341
 
347
- `GET /v2/capabilities` lists `places`: the modes, the default, a new agent's place, and each box with `available`, its `state` (`ready`,
348
- `preparing` while the server builds or pulls its image, or `unavailable`) and, when it is not ready, the `reason`.
342
+ `GET /v2/capabilities` lists `places`: the modes, the default, a new agent's place, and each box with `available`, its `state` (`ready` or
343
+ `unavailable`) and, when it is unavailable, the `reason`.
349
344
  A definition naming a box this server does not have saves with a warning on `definition.place`, and a run of it is
350
345
  `409 agent_not_runnable` with `details.box`. `GET /v2/openapi.json` marks `definition.place`, the run's `place` and
351
346
  `capabilities.places` `x-agentrun-serve: "place/1"`, `default_reason` `"place/3"`, and `default_place` `"place/4"`
@@ -409,7 +404,7 @@ go through `work/` by path.
409
404
  connect, over a minute old); a live run's, of any server of this user's, stays.
410
405
  - On a Mac, where Docker runs in a VM, a socket bound in from the Mac does not connect, so the proxy runs inside the
411
406
  VM instead: one container per server, `agentrun-egress-<12 hex of the data root>`, labelled `agentrun.egress`. It
412
- is `node:22-bookworm-slim` pinned by digest, with the kernel's two proxy files and a short entry bound read-only from
407
+ is `node:22.23.5-trixie-slim` pinned by digest, with the kernel's two proxy files and a short entry bound read-only from
413
408
  `<data>/egress/`, the list as its one variable, a read-only root, no capability, the server's uid:gid, 256 MiB and
414
409
  256 processes. It listens on a Unix socket in a tmpfs volume of the same name, owned by the server's uid, and the
415
410
  box mounts that volume read-only at `/run/agentrun/egress/`. The box keeps `--network none`, its `socat` and its
@@ -547,111 +542,21 @@ where `bash`'s setting came from:
547
542
  then `KILL` after 3 s, and marks each with `ended` beside its log, which stays in the run's files; the server's log says
548
543
  `background_ended` with how many. A follow-up's box starts with none running, and its ids go on from the last.
549
544
 
550
- ### A run in a Daytona box
551
-
552
- With `AGENTRUN_BOXES=daytona` and `DAYTONA_API_KEY`, a run whose place is `{"mode": "sandbox", "box": "daytona"}` gets one
553
- Daytona sandbox, made on its first `read`, `write`, `edit` or `bash` call, with the same tools, path rules, environment,
554
- `bash` and labels as a Docker box. What differs (its `read`, `write` and `edit` run in the sandbox, as its `bash` does,
555
- since nothing binds `work/` there):
556
-
557
- - The key is this server's alone. The server makes, copies to and from, and destroys the sandbox itself. The run's
558
- process holds no key: it reaches its sandbox only through the server's box relay, on loopback, which takes a call for
559
- a run only with that run's own door token (`DIR/disk/agents/<agent>/runs/<id>/door-token`, handed to that run's process alone) and adds
560
- the key to the calls a run's tools make of their own sandbox (a read of it, and its toolbox's programs and files). It
561
- refuses every other call (a create, a listing, a stop, a delete, another run's sandbox or token, any other host), and
562
- it never follows a redirect, nor does the server's own Daytona client: a redirect would carry the key.
563
- - It reaches the hosts `AGENTRUN_BOX_ALLOW` names, and no other: Daytona's domain list (`domainAllowList`), which
564
- Daytona's egress proxy enforces. Unset or empty, the list is the package registries and GitHub: `pypi.org`,
565
- `files.pythonhosted.org`, `registry.npmjs.org`, `registry.yarnpkg.com`, `github.com` and `codeload.github.com`. A
566
- comma list of hosts (a `*.` wildcard allowed, at most 100) replaces it, so to add one, copy this list and extend it.
567
- `AGENTRUN_BOX_ALLOW=none` blocks its network (`networkBlockAll`), as before the list. `*`, an IP address, a CIDR, a
568
- port or a URL refuses the start. Capabilities show the hosts in `places.allow`, and the box's `network` (`allowlist` or
569
- `none`) in its `places.boxes` entry. Daytona's proxy re-signs each TLS connection with Daytona's own CA, which the
570
- sandbox's environment names to pip, npm, git and curl (`REQUESTS_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`, `GIT_SSL_CAINFO`,
571
- `CURL_CA_BUNDLE`, `SSL_CERT_FILE`).
572
- - A sandbox whose own read does not carry the list it was asked for is deleted. Daytona takes a domain list on its tier 3
573
- and 4 only: where it keeps none, or refuses it, the server makes the run's box again with its network blocked, never
574
- open, and makes every later Daytona box that way until it starts again. The log says so once, with Daytona's own
575
- words (`event=box_network box=daytona network=none refused=<code> message="…"`), and capabilities show the box's
576
- `network` as `none` with its `network_reason`. A box the server finds is kept when it has no network, or the list the
577
- setting names now (the same hosts, in any order, as Daytona reads them back); any other (a wider or narrower list, a
578
- list when the setting is `none`) is destroyed and made again, so a changed list holds for a run's box after a restart.
579
- - A sandbox Daytona does not report blocked, when blocked was asked, is deleted, and the tool call fails saying so. An
580
- organization on Daytona's tier 1 or 2 keeps its own network policy, which a sandbox cannot override, so a run there
581
- gets no Daytona box unless that policy blocks it.
582
- - A sandbox cannot bind `work/`. The server copies `work/` into it at `/workspace` when it makes it, and
583
- copies what changed back at each turn's end (a read of the run's files waits for that copy) and once more before the
584
- run's end is recorded. Daytona's answer is never trusted: the copy back writes regular files and directories only,
585
- never a link and nothing outside `work/`, and a file this server changed since the last copy stays as this server
586
- has it. A file the box removed is removed here too. What the server files in `work/` during the run (monid's long
587
- answers) is copied into the sandbox as well. The copy's mark is `box-sync.json` beside the run, which the server alone
588
- writes; the run's process notes each file it copied in, in `box-mirrored.jsonl` beside it, and a copy back counts
589
- those as held by both sides, so an edit the box makes to one comes back.
590
- - The sandbox is destroyed after the last copy back, and only once that copy is whole: when the run ends, and when it
591
- is archived (a copy that fails at an archive keeps the sandbox for the run's end). A copy that fails at the run's end
592
- is tried again, and the end waits for it. One that stops for good (an archive the server cannot read, or a limit a copy
593
- that brought nothing reached) keeps the sandbox, says so in the log (`event=box_kept` with its id), and lets the run
594
- end with what did come back. A start pulls a run it finds waiting for the person, and copies back, then destroys, the
595
- sandbox of every run that has ended or is archived. One whose copy fails is kept for the next start.
596
- - A kept sandbox has Daytona's auto-delete turned off (a sandbox is made with auto-delete at 0, which deletes it as it
597
- stops) and is set to stop after 15 minutes without activity, so once stopped it costs its disk alone (3 GiB on
598
- Daytona's default snapshot, at Daytona's storage price) and no compute; its files stay. The next start wakes it, copies
599
- back again, and destroys it once that copy is whole; else its 24-hour lifetime ends it. To remove one sooner, delete
600
- the sandbox in Daytona's dashboard or API: it carries the labels `agentrun.box=run` and `agentrun.run=<run id>`.
601
- - A run's sandbox that Daytona stopped, paused (a sandbox class that pauses when idle, while the run waits for its
602
- person) or archived (a stopped one it moved away) is started again, an archived one restored, when the server next
603
- needs it: for the run's next tool call, a copy back, or the start's sweep. One still stopping, pausing or archiving
604
- is waited for (a minute at most) first. It is never replaced by a new one, so
605
- what only it holds stays.
606
- - The sandbox is Daytona's default snapshot, made as its user, with `sudo -n` making `/workspace`.
607
-
608
- ### A run in a Modal sandbox
609
-
610
- With `modal` listed in `AGENTRUN_BOXES`, its token set and its SDK installed, a run whose place is
611
- `{"mode": "sandbox", "box": "modal"}` gets one Modal sandbox, made on its first `read`, `write`, `edit` or `bash` call. It
612
- is Modal's default sandbox runtime (gVisor), not a virtual machine: the server does not ask Modal for its VM runtime. It works like a
613
- [Daytona box](#a-run-in-a-daytona-box): the same tools, path rules, environment and labels, and its `read`, `write` and
614
- `edit` run in the sandbox too. What differs:
615
-
616
- - The token and the SDK's client are this server's alone. The server makes the sandbox, copies `work/` into it at
617
- `/workspace`, copies what changed back at each turn's end and once more before the run's end is recorded,
618
- and ends it after that last copy, at the run's end, a cancel included, and at an archive. The copy rules (no link,
619
- nothing outside `work/`, a file this server changed stays as it has it) are Daytona's.
620
- - The run's process holds no token. Its calls to its sandbox go through the server's box relay, on loopback, with that
621
- run's own door token. The relay makes only the calls a run's tools make of their own sandbox, with the server's
622
- client: finding it, reading its state and tags, and starting a program in it with that program's input, output and
623
- exit. It refuses everything else: a create, a listing, an end, a tag change, or another run's sandbox or program.
624
- - It has no network, whatever `AGENTRUN_BOX_ALLOW` names. The provider takes a domain list when a sandbox is made, but
625
- its SDK cannot read a sandbox's list back, so this server cannot check that a box holds the list it asked for (as it
626
- does for Daytona). Each box is made with its network blocked, never with the provider's open default. Capabilities
627
- show the box's `network` as `none`, with `network_reason`, unless the setting is `none`.
628
- - A sandbox that is gone (it ended, or its lifetime ran out) is made again on the run's next tool call and seeded
629
- with the run's `work/`. The call that met the gone box fails, saying so.
630
- - A Modal sandbox is the size Modal makes it, which the provider bills for while the box lives: `AGENTRUN_BOX_CPUS`,
631
- `AGENTRUN_BOX_MEMORY` and `AGENTRUN_BOX_PIDS` size Docker computers only. Its lifetime is 24 hours, as every box's is.
632
- - A start copies back, then ends, the sandbox of every run that has ended or is archived.
633
-
634
545
  ### The box's image
635
546
 
636
- A Docker box starts from this server's own image by default: `agentrun-box`, python 3.12 (`python:3.12-slim`, pinned by
637
- its digest) with git, curl, node and npm (Debian's `nodejs` and `npm`), rg (`ripgrep`), `socat` (the relay to the box's
638
- network proxy, when it has one) and their certificates, about 360 MB. Its
639
- recipe is `BOX_RECIPE` in `src/box-image.ts`, its base `BOX_BASE` there. The server builds it on first use
640
- (`docker build`, at most 10 minutes, its context a private directory under `TMPDIR` holding the recipe alone as its
641
- `Dockerfile`, removed after), tags it with the recipe's hash (`agentrun-box:<12 hex>`) and labels it with the whole hash
642
- (`agentrun.box-image`), and builds again only when the recipe changes: a start that finds the image with this recipe's
643
- hash uses it. To move the base, read the tag's index digest again from Docker Hub (the comment beside `BOX_BASE` says
644
- how) and put it there: the recipe's hash changes, and so does the image's tag, so the next start builds it. The build
645
- reaches the network, for the base image and apt; a box made from it never does through Docker's (`--network none`). A build that fails
646
- leaves the box unavailable with the reason ([Boxes](#boxes)). Images of older recipes stay until you remove them:
647
- `docker image ls --filter label=agentrun.box-image` lists them all, and `docker image rm agentrun-box:<12 hex>` removes
648
- one.
649
-
650
- A box reaches its package registries (on Linux), so `pip install` and `npm install` work in it, but not `apt-get`: the
651
- box runs as this server's user, with no root. For other tools, name another image
652
- in `AGENTRUN_DOCKER_IMAGE`: the server then pulls it when Docker has none (at most 10 minutes) and builds nothing.
653
- This image, its build and the wait for it are the Docker box's alone: a Daytona box is made by the server from
654
- Daytona's own image, and a Daytona run never waits on this one.
547
+ A Docker box's computer starts from the computer package's own image by default: python 3.12 (`python:3.12-slim`,
548
+ pinned by its digest) with git, curl, node and npm, rg and `socat` (the relay to the computer's egress proxy), about
549
+ 360 MB. Its recipe is `DOCKER_RECIPE` in `packages/computer/src/docker/image.ts`. The Docker provider builds it on the
550
+ first run that needs it, tags it with the recipe's hash (`agentrun-computer:<12 hex>`) and labels it with the whole hash
551
+ (`agentrun.computer.recipe`), and builds again only when the recipe changes; the run waiting on the build shows it on its
552
+ timeline. Nothing is built or pulled at the server's start. Images of older recipes stay until you remove them:
553
+ `docker image ls --filter label=agentrun.computer.recipe` lists them. An `agentrun-box:*` image an earlier server built
554
+ is used by nothing: `docker image rm` it.
555
+
556
+ A box reaches its package registries, so `pip install` and `npm install` work in it, but not `apt-get`: the box runs as
557
+ this server's user, with no root. For other tools, name another image in `AGENTRUN_DOCKER_IMAGE`: the provider then pulls
558
+ it on the first run that needs it, and builds nothing. This image is the Docker box's alone: a box on another provider
559
+ starts from that provider's own.
655
560
 
656
561
  ```sh
657
562
  AGENTRUN_DOCKER_IMAGE=python:3.12-bookworm AGENTRUN_BOXES=docker node packages/serve/dist/cli.js
@@ -752,23 +657,115 @@ this server's run folder says why there. The save checks the shape, and only a s
752
657
  and the claim refuse a type or a count the provider does not give, in the computer package's `checkGpu` words, and the
753
658
  computer is made with the GPUs asked.
754
659
 
755
- - **Daytona** gives `H100`, `H200`, `RTX-PRO-6000`, `RTX-4090`, `RTX-5090` and `MI355X`, up to 8. A GPU sandbox runs
756
- in region `earth`. Stopping it deletes it: it has no pause and no snapshot, so nothing on it outlives the run. Each GPU
757
- comes with 16 vCPU, 192 GiB of memory and 512 GiB of disk. A Daytona GPU may be preempted, so a run on one can be
758
- cut short. The Daytona org needs GPU credits. A Daytona GPU sandbox with the run's folder mounted from Archil, and
759
- its network allowlist, are not yet proven live.
660
+ - **Daytona** gives one `H100`, the GPU of its GPU snapshot `daytona-gpu` (the computer package's `DAYTONA_GPU`:
661
+ `types: ["H100"]`, `max: 1`); another type or count needs a snapshot of its own, so it is refused. A GPU sandbox is
662
+ made from that snapshot, with its 16 vCPUs, 100 GiB of memory and 400 GiB of disk, in region `earth`. Stopping it
663
+ deletes it: it has no pause and no snapshot, so nothing on it outlives the run. A Daytona GPU may be preempted, so a
664
+ run on one can be cut short. The Daytona org needs GPU credits. It takes no mount (`mounts: []`: the snapshot's user
665
+ is not root and has no Archil client), so it can't hold the run's folder from Archil: in Mode 2 this server refuses a
666
+ Daytona sandbox with a `gpu`, and `GET /v2/computers` says why in Daytona's `gpu.why`. In Mode 1 a sandbox runs on
667
+ Docker only, so a Daytona GPU sandbox runs on neither mode's server today.
760
668
  - **Modal** declares its GPUs, but a Modal GPU sandbox runs on gVisor, and the Archil mount the run's folder needs is not
761
669
  proven there. So this server refuses a Modal sandbox with a `gpu` for now. A Modal GPU is also preemptible.
762
670
 
671
+ **An agent's own computer.** `computer: {"kind": "desktop", "provider": "orgo", "persistent": true}` gives the agent
672
+ one computer that it keeps between runs, instead of a fresh one for each run:
673
+
674
+ - Its first run makes it. Each run's end detaches it rather than deleting it (an Orgo Linux desktop is suspended, with
675
+ its memory and disk). The agent's next run attaches it again, with what was on it.
676
+ - The run's timeline says which happened. If the computer was deleted outside this server, the next run makes a new
677
+ one and says so.
678
+ - One run at a time. A run that finds the computer held by another run that is still going is refused at its start,
679
+ naming that run.
680
+ - Only where the provider keeps one for the kind and image (`GET /v2/computers`: the provider's `persistent`); anything
681
+ else is 422. A computer that mounts the run's folder can't be kept, so a persistent computer never mounts it.
682
+ - `GET /v2/agents/{agent_id}` shows it as `own_computer`: its provider, id and name, and whether a run holds it, it is
683
+ detached, or it is being deleted.
684
+ - Archiving the agent, turning `persistent` off, or moving the setting to another provider or image deletes it.
685
+ - The computer is owned by this server's id (kept in its store) and the agent's id, so two servers on one vendor
686
+ account never take each other's. The janitor deletes an agent's computer only once its agent no longer wants it.
687
+
763
688
  **Where the run's folder lives.** A server keeps its runs' folders in one of two modes:
764
689
 
765
690
  - **Mode 1** (the default): on this server's own disk. Only a provider that binds a folder of this machine can hold
766
691
  it, so a sandbox runs on Docker only; a Daytona, Modal or E2B sandbox is refused ("Mode 1 runs a sandbox only on
767
692
  Docker").
768
- - **Mode 2**: on your own Archil disk. `PUT /v2/workspace/archil` turns it on with the disk's id, its region, its S3 URL
769
- (and an exec image pinned by digest, if you want one other than Archil's default), and the account key,
770
- `ARCHIL_API_KEY`; `DELETE` turns it off. A Daytona, Modal or E2B sandbox mounts the run's folder from the disk with a
771
- mount credential minted for that run alone; Docker's sandbox is refused, since it cannot mount the disk.
693
+ - **Mode 2**: on Archil disks. `PUT /v2/workspace/archil` turns it on with the account key, `ARCHIL_API_KEY`, its
694
+ region and that region's S3 URL (and an exec image pinned by digest, if you want one other than serve's default);
695
+ `DELETE` turns it off. The default exec image is Docker's `buildpack-deps:trixie-scm` pinned by digest (git 2.47),
696
+ because Archil's own has git 2.34 and a read-only bash policy runs git only at 2.43 or later. An image you name needs
697
+ git 2.43 for that too, and GNU coreutils and perl, as Debian-family images have. A Daytona, Modal or E2B sandbox mounts
698
+ the run's folder from its disk with a mount credential minted for that run alone; Docker's sandbox is refused, since
699
+ it cannot mount the disk.
700
+
701
+ The PUT is a secret write, so it takes the owner's signed-in session. A server with none to give it (API only, or
702
+ `AGENTRUN_ACCOUNTS=0` reached beyond loopback) is set where it is started instead: `AGENTRUN_ARCHIL_REGION` and
703
+ `AGENTRUN_ARCHIL_S3_URL` together, and `AGENTRUN_ARCHIL_IMAGE` for a pinned exec image, with the account key in
704
+ `ARCHIL_API_KEY`. Each agent's disk is then made on its first run, as with saved settings:
705
+
706
+ ```sh
707
+ AGENTRUN_ARCHIL_REGION=aws-us-east-1 AGENTRUN_ARCHIL_S3_URL=https://s3.example.com \
708
+ ARCHIL_API_KEY=... node packages/serve/dist/cli.js
709
+ ```
710
+
711
+ Each value is checked as the PUT checks it. One of the region and S3 URL without the other, or a value the PUT would refuse,
712
+ stops the start, in words naming each variable. Set, they win over saved settings, as `ARCHIL_API_KEY` wins over a
713
+ saved key, and nothing is written to the store: `GET /v2/workspace/archil` says `source: "env"` (saved ones say
714
+ `"console"`), and `PUT` and `DELETE` are `409 key_set_by_server`, since they are changed where the server is started.
715
+ Unset, the saved settings, if any, hold again. A runner started on its own (`agentrun-serve runner`) reads them from its
716
+ own environment, as it reads `ARCHIL_API_KEY`, so give it the same values.
717
+
718
+ **Archil disks: one per agent.** In Mode 2 every agent has its own disk. It is made on the agent's first run that uses
719
+ it, never when the agent is made, in the account key's region, named `agentrun-<server id>-i-<agent id>` (an id with
720
+ characters Archil doesn't take, or past 46 of them, is `h-` with its first 21 safe characters and 24 hex digits of its
721
+ SHA-256, so no agent's disk name is another's); making it is
722
+ idempotent by that name, and `GET /v2/agents/{agent_id}/archil` says which disk it is. A run's mount credential is minted
723
+ on its run's disk, so Archil refuses that token on every other disk: a run of one agent can't mount another agent's
724
+ files. This is the default, and it is enough for one owner: this server has no roles, and everything on it is its
725
+ owner's.
726
+
727
+ - **Isolating tenants.** A run's start may name another disk: `"archil_disk": {"disk_id": "dsk-…"}` on
728
+ `POST /v2/agents/{agent_id}/runs` or `POST /v2/runs` (an agent given inline). The run then keeps its folder there, and
729
+ its token is minted there, so a system that runs one agent for many customers (one expert, say) names a disk per
730
+ customer. That disk is the caller's: agentrun never makes, renames or removes it. It takes the id Archil returned when
731
+ the disk was made (`dsk-…`; Archil's API addresses disks by id, not owner/name), never a key or a region. The server
732
+ reads the disk at Archil before the run is made: a disk in another region than the account key's, or none of that id,
733
+ is a 422 naming the region, and no run is made; the claim reads it again, for a disk removed in between. The run's
734
+ launch keeps the disk it used, and whether it was the launch's or the agent's, so every claim, revoke and reclaim of
735
+ that run acts on that one disk, after a restart too. Any disk in the key's region may be named, by design: this
736
+ server has one owner, and a backend that launches runs for its customers is a trusted caller. Isolation comes from a
737
+ disk per boundary.
738
+ - **The plan's disk limit.** Archil's free plan allows 5 disks per region. When Archil refuses to make an agent's disk
739
+ for its plan's limit, the run fails in words ("your Archil plan allows 5 disks; upgrade or delete an agent"); no run
740
+ falls back to a shared disk.
741
+ - **Removing an agent's disk.** This server archives agents and never deletes one, and an archive keeps everything,
742
+ its disk included. `DELETE /v2/agents/{agent_id}/archil` deletes the agent's own disk at Archil (its runs' folders,
743
+ its home and its learning with it) and frees a disk of the plan, once no live run of any agent is on it (a run of
744
+ another agent may name it in `archil_disk`). The agent must be archived, unless its source manages it: an inline
745
+ run's agent is never archived here, and its caller decides when it is done. The disk is marked as being removed
746
+ before the live runs are counted: from then a new run of the agent on it is `409 agent_not_runnable`, and a run
747
+ launched just before is refused at its claim, so no run starts on a disk being deleted. A refusal leaves the disk the
748
+ agent's. It never touches a disk a run's launch named.
749
+ - **Before you upgrade.** In Archil mode, an agent's files from before this release stay on the old server disk at
750
+ Archil; the agent starts on a new disk of its own. `diskId` is no longer a setting: there is no server-wide disk, and
751
+ no agent falls back to one.
752
+ - **Later, narrower tokens.** Archil's tokens reach a whole disk; nothing narrower exists today. If Archil ships
753
+ path-scoped tokens, a run's token narrows from its disk to its own folder with no other change.
754
+
755
+ **A Daytona computer's snapshot.** The mount runs as root through the image's root helper and its pinned archil client,
756
+ so a Daytona computer that mounts the run's folder must start from a snapshot of the computer package's
757
+ `box/Dockerfile`; Daytona's default snapshot, whose user is not root, is refused before anything mounts. Build one in
758
+ the organization of `DAYTONA_API_KEY` with Daytona's Python SDK (`pip install daytona`), which prints its name, a hash
759
+ of the recipe:
760
+
761
+ ```sh
762
+ DAYTONA_API_KEY=... python3 packages/computer/box/build-daytona.py # prints snapshot=agentrun-archil-<12 hex>
763
+ ```
764
+
765
+ and name it in the server's environment, `AGENTRUN_DAYTONA_SNAPSHOT=agentrun-archil-<12 hex>` (the id or name of any
766
+ Daytona snapshot), as `AGENTRUN_DOCKER_IMAGE` names Docker's image. Every Daytona computer is then made from it. Unset,
767
+ it is Daytona's default snapshot, as before. A changed recipe is a new name, so build again after an upgrade that
768
+ changes `box/`. The [Daytona box](#a-run-in-a-daytona-box) never reads it.
772
769
 
773
770
  A desktop, a phone and a browser run in either mode. The run's folder is at `/workspace` in every computer that mounts
774
771
  it: a sandbox always, and a desktop whose provider mounts the mode's folder (Docker's in Mode 1, E2B's in Mode 2). A
@@ -809,7 +806,7 @@ only those hosts (the default list, a sandbox's package registries, is no browsi
809
806
 
810
807
  **Docker.** A Docker computer runs where this server's Docker answers. With `AGENTRUN_BOXES` not set at all (a plain
811
808
  `npx @parcha/agentrun`), the server probes `docker` at its start (within 5 s) and offers it when Docker answers
812
- (`ready`, or `preparing` while its image is built or pulled, as [the box's image](#the-boxs-image) says); `AGENTRUN_BOXES`,
809
+ (`ready`); `AGENTRUN_BOXES`,
813
810
  when set, lists what it probes, and `AGENTRUN_BOXES=none` probes nothing. One log line says what it found:
814
811
 
815
812
  event=boxes available=<ids or none> unavailable=<ids> <id>="<why>" ...
@@ -928,6 +925,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
928
925
  | `monid.run` | Run one monid endpoint, paid per call from the monid wallet: `{provider, endpoint, input}` in, the run's `output`, `price` and `cost` out | `MONID_API_KEY` | no, no |
929
926
  | `pdf_pages` | A workflow call only: `{path, maxPages?, dpi?}` in, `{name, pageCount, dpi, pages: [{page, image}], text}` out. Draws a document's first pages (3 by default, at 110 dpi) as PNGs under the run's `work/pages/<stem>/<dpi>/` (`<stem>`: the document's path below its directory made one name, with a short hash, so two documents of one file name never share pages), the dpi lowered so a page's long side is at most 1568 px, with its text (`pdftotext`, cut at 20,000 characters). A PNG or JPEG passes through as one page, scaled down to 1568 px. `path` is under `--documents` or the run's `work/`, never outside | `pdftoppm`, `pdftotext` | no, yes |
930
927
  | `llm` | A workflow call only: `{prompt, system?, maxTokens?, tier?}` in, `{text, model, usage, cost_usd}` out. One completion on the run's model of the tier (`default`; a tier the state fills in, such as `"{requestedTier}"`, may be any of the three, and a tier with no model fails the call), no tools and no loop; `cost_usd` is null when the model has no price, never 0 | a model | no, yes |
928
+ | `subagent` | pi only: `{prompt, tools?, model?, max_tool_calls?, effort?}` in, the child's last text out, bounded like a host tool's result. Runs a fresh conversation whose whole task is `prompt`, with `tools` a subset of the agent's own (by catalog or session name, MCP tools and `bash` included; absent, none), on the agent's own model or the tier `model` names (`fast` or `strong`: the definition's `model_tiers`, else `AGENT_MODEL_FAST` / `AGENT_MODEL_STRONG`, else the agent's own model) ([subagents](#subagents)) | a pi run | no, no |
931
929
 
932
930
  `bash` and the background tools run only in a box: a runner agent, and a workflow, get no shell on this machine (see [Safety](#safety)). In a
933
931
  sandbox place `read`, `write` and `edit` run in the box too.
@@ -970,6 +968,54 @@ to read it, which a run's confinement refuses, Codex keeps only the ends of a re
970
968
  would cut one past 2,000 lines or 51,200 bytes and save the rest to a file the session has no tool to read. A
971
969
  `web_search` answer past 100,000 characters leaves out its least relevant results, `omitted` counting them.
972
970
 
971
+ ### Subagents
972
+
973
+ `subagent` is one primitive: a prompt, a fresh context and a subset of the agent's own tools, on the agent's own model
974
+ unless the call names a tier. A child keeps the run's gate, so the agent's permissions and bash policy (`read-only`)
975
+ hold its tool calls too, and every request it makes books on the run's one cap. It goes one level deep (a child is never
976
+ given `subagent` or `ask_person`), and at most 4 children of a run work at once; more wait. The run's timeline nests each
977
+ child under its call, and the run's cost counts every child's requests. How to split work and merge answers is the
978
+ agent's own instructions, never the engine's.
979
+
980
+ A call may set its child's `max_tool_calls` and `effort`. `max_tool_calls` narrows the agent's own budget (its definition's
981
+ `max_tool_calls`, which holds each conversation) for that child and never widens it; with no budget of the agent's, the
982
+ call's holds. `effort` (`low`, `medium` or `high`) is the child's thinking level; absent, the child thinks as the agent
983
+ does. So one template can run wide reviewers at `medium` with 30 calls and deep ones at `high` with 90.
984
+
985
+ A child is a conversation in the run's own journal, owned by its call, so it lives and ends with the run:
986
+
987
+ - **A restart or a moved claim** resumes it. The next claim finds the same child, which answers its call once. A request
988
+ it had finished is never sent again, and one the stop cut is sent again. A child on a tier whose model changed in the
989
+ meantime (the server's `AGENT_MODEL_STRONG`, say) resumes on the tier's model now.
990
+ - **A cancel** stops every child with the run: their requests are aborted, and nothing more is asked.
991
+ - **The cap.** When the run's cap refuses a child's request, the child stops and its call fails in the cap's words
992
+ (`subagent: it stopped before it answered: ... spend_cap_reached`). The run's next request is refused the same way, so
993
+ the run parks at its cap (`input_required`, a `budget` pending) and sends nothing more. A raise resumes the run, not
994
+ the child: the agent reads the failed call on its next turn and may call `subagent` again, which starts a fresh child.
995
+ On a capped run, a call on a tier whose model has no known price is refused before any child starts.
996
+
997
+ #### Patterns
998
+
999
+ **Sample K, merge, verify.** One pass misses what a second finds, and states things neither would confirm. A template's
1000
+ skill can ask for K passes and check their union, with no engine support beyond the tool:
1001
+
1002
+ 1. In one turn, make K `subagent` calls with the same prompt and tools (K of 3 or 4 run at once; more wait their turn).
1003
+ Each starts from a fresh context, so the answers vary the way independent samples do.
1004
+ 2. Merge the K answers: dedupe the items that say the same thing about the same place, and keep how many children found
1005
+ each.
1006
+ 3. Before acting on a kept item, re-check it with the parent's own tools: open the file, page or record it cites and
1007
+ confirm it says what the item claims. Drop what does not hold. Agreement between children orders the checks; it is
1008
+ never the check.
1009
+
1010
+ It fits any agent whose answer is a list:
1011
+
1012
+ - Research: children answer with `web_search` and `web_fetch`; the parent re-fetches each cited source before it writes.
1013
+ - QA: children run one test plan with `browser`; the parent reproduces each finding before it files it.
1014
+ - Extraction: children pull a document's fields with `read`; the parent reads the page again for any value they differ on.
1015
+ - Code review: children read a diff with read-only `bash`; the parent re-reads each finding's lines before it posts.
1016
+
1017
+ Each child books on the run's cap, so size the cap for K passes, not one.
1018
+
973
1019
  ### Search and fetch
974
1020
 
975
1021
  `web_search` and `web_fetch` work on every harness with only a model key. Each resolves, for a run, in one order: (1) the
@@ -1186,6 +1232,19 @@ and the ask expires, the agent told the cap's words. When the
1186
1232
  browser comes back, what was held up front goes, and the time the person had stays held, at the provider's price, until
1187
1233
  the session's next charge books it: take-overs given back with no browser call between them still meet the cap.
1188
1234
 
1235
+ **The run waits for you, its browser kept.** When the agent asks the person a question (`ask_person`) with its browser open,
1236
+ the run waits for the answer with that browser kept open for them: its page, the live view and Take over stay there. The
1237
+ browser's own idle release (a few minutes with no browser call) doesn't apply while it waits. It is kept for the person's
1238
+ window, `AGENTRUN_BROWSER_PERSON_WAIT_MIN` (whole minutes, 1 to 360; 15 by default), the same setting that bounds a
1239
+ take-over with no input and an agent's hand-over ask (above, 15 minutes each by default), so the three never drift apart.
1240
+ The window's session time is held under the run's cap first, at the provider's price, like a take-over's: while the run
1241
+ waits, its cost grows by the browser's session time only, never by model time, and with no room under the cap the run
1242
+ parks at once. An answer inside the window goes back to the agent on the same page. At the window's end the run parks and
1243
+ the browser is released ("The browser was released after 15 min waiting for you" on the timeline, and the Screen tab says
1244
+ so, with when, until a browser opens again), so its billing stops there. An answer after that goes on with a new
1245
+ browser, opened at the agent's next browser call. A browser its provider ends before the answer says so too ("The browser
1246
+ session ended while the run waited for you"). A provider's own session timeout still applies: keep the window under it.
1247
+
1189
1248
  **The agent asks.** The agent may ask the owner to do something in its browser (`browser_request_handoff`: an instruction
1190
1249
  and how it will know it is done, such as signing in). Its person's time is held the same way first; with no room no ask is
1191
1250
  made, and the tool's result says why. The run then reads `input_required`/`waiting` with
@@ -1431,6 +1490,35 @@ names a tool whose title, description, schemas or annotations differ. `DELETE ..
1431
1490
  credential. Capabilities' `features.mcp_client` says `transports: ["streamable-http"]`, the `auth` types and `at_rest:
1432
1491
  "sealed"`.
1433
1492
 
1493
+ ### A credential handed with each run
1494
+
1495
+ Some servers take a credential made for one run (a token scoped to that run's job and its person) that no saved
1496
+ server could hold. Save such a server with `auth: {type: "per_run", headers?}`: it keeps no credential, and `headers`,
1497
+ when sent, are used only to list its tools now. Then hand each run its own as `mcp_auth` on the run's start
1498
+ (`POST /v2/runs`, `POST /v2/agents/{agent_id}/runs`), one entry for each per_run server it calls:
1499
+
1500
+ ```sh
1501
+ curl -X PUT "$BASE/v2/settings/mcp-servers/gateway" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
1502
+ -d '{"url": "https://gateway.example.com/mcp", "auth": {"type": "per_run", "headers": {"authorization": "Bearer <a token to list with>"}}}'
1503
+ curl -X POST "$BASE/v2/agents/$AGENT/runs" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
1504
+ -d '{"input": {"content": "..."}, "mcp_auth": {"gateway": {"headers": {"authorization": "Bearer <this run'"'"'s token>"}}}}'
1505
+ ```
1506
+
1507
+ A per_run save keeps no secret, so the API token may make it, as it may preview a server with a credential: the
1508
+ credentials such a server receives are the ones each run's own caller hands it. The run's calls of that server carry
1509
+ those headers, and only to the origin the server had when the run was started. The
1510
+ credential is sealed into the run's launch record under `AGENTRUN_SEAL_KEY` (bound to the run's id), read at each claim, so
1511
+ a resume, a restart or a lost lease uses it again, and erased by the write that ends the run. It is never in the run's
1512
+ saved body, its timeline, its view, a log line or an `Idempotency-Key`'s fingerprint (a retry with a new credential
1513
+ answers the first request's run), and its values are cut from whatever the run shows. `POST /v2/runs/{run_id}/messages`
1514
+ takes `mcp_auth` too: it replaces the run's credentials in the message's own write, so the turn the message starts (a
1515
+ steer into a working run from its next model request, or a follow-up that opens an ended run again) calls with them. A
1516
+ name that is not a saved per_run server is `422` at `mcp_auth.<server>`, and no run starts. A run handed no credential
1517
+ for a per_run server it calls has those calls answered, unsent, that it was handed none. `POST .../{name}/refresh` lists
1518
+ a per_run server's tools with no credential: save it again with `headers` for a server that lists only to a caller it
1519
+ knows. The tools are those it listed at its save, so a server whose tool list varies by caller shows each run the saved
1520
+ list.
1521
+
1434
1522
  ### Signing in with OAuth
1435
1523
 
1436
1524
  A server whose preview answers `details.auth: "oauth"` is signed in to by this server, which keeps the tokens: the
@@ -1716,8 +1804,8 @@ then the body, cut at 16 KiB, inside `<trigger-payload source="webhook" scheme="
1716
1804
  whatever the sender wrote is data, not an instruction. The tag names the signature scheme, the event as that scheme
1717
1805
  reads it (`event="..."`), the JSON body's top-level `action` (`action="..."`) and an unsigned delivery id
1718
1806
  (`delivery="..."`, GitHub's `X-GitHub-Delivery`) and, for a GitHub delivery, its pull request or issue's `number="..."`
1719
- (`pull_request.number`, else `issue.number`) and a pull request's `head_sha="..."` (40 hex; a comment event has none, so
1720
- no `head_sha` at all), read from the signed body so the payload's cut never loses them, each when there is one, so an
1807
+ (`pull_request.number`, else `issue.number`) and a pull request's `head_sha="..."` and `base_sha="..."` (40 hex each; a
1808
+ comment event has neither, so no `head_sha` or `base_sha` at all), read from the signed body so the payload's cut never loses them, each when there is one, so an
1721
1809
  agent's instructions can read what it was given; a sender's words there are cut to 200 characters, their quotes and brackets escaped, and a closing tag in
1722
1810
  the body, in any case, is defused.
1723
1811
 
@@ -1806,7 +1894,7 @@ GitHub template) uses it. In the console, Connect GitHub calls `POST /v2/integra
1806
1894
  the App under an organization) and posts the form it answers to GitHub: `action`, GitHub's new-App page, and
1807
1895
  `manifest`, which names a name GitHub lets the person edit, the server's public URL, its hook `/v2/hooks/github`, its
1808
1896
  callback and setup URLs, the permissions (pull requests write; contents, metadata and issues read) and the events
1809
- (`pull_request`, `issue_comment`). It needs the address GitHub can reach, `AGENTRUN_PUBLIC_URL` (`409 github_no_public_url`,
1897
+ (`pull_request`, `issue_comment`, `release`). It needs the address GitHub can reach, `AGENTRUN_PUBLIC_URL` (`409 github_no_public_url`,
1810
1898
  "GitHub can't reach this server: set its public URL first"), a seal key (`409 github_no_seal_key`, naming
1811
1899
  `AGENTRUN_SEAL_KEY`), and no App connected already (`409 github_already_connected`, "This server already has a GitHub
1812
1900
  App. Disconnect it first."), and a request at the public URL itself, where GitHub sends the browser back
@@ -1881,6 +1969,22 @@ expires, so a long run's calls never carry an expired token. When that mint fail
1881
1969
  it expires; then the run's calls of that server are answered, unsent, that its GitHub App token expired and a new one
1882
1970
  could not be made, with GitHub's reason, and the next launch (a resume) mints a fresh one.
1883
1971
 
1972
+ An agent whose definition says `checkout: pull_request` starts each run a GitHub event about a pull request started in a
1973
+ checkout of it, made by the server at each claim before the first turn ([runner/pr-checkout.ts](src/runner/pr-checkout.ts)).
1974
+ It reads the repository, number, head and base from the server's own payload tag, only on a run a github trigger started
1975
+ (its launch's input origin) and never from anyone's words, and runs one
1976
+ command on the run's folder (a process here in Mode 1, Archil's exec in Mode 2): `git init repo`, a fetch of the head and
1977
+ the base 50 commits deep, deepened until their merge base is in (about 3,200 commits at most), then a detached checkout
1978
+ of the head, with refs `pr/head`, `pr/base` and `pr/merge-base`. The fetch takes an installation token minted for that
1979
+ one repository with `permissions: {contents: "read"}` alone, handed to the command on its stdin and turned there into an
1980
+ `Authorization` header in git's environment, scoped to GitHub's site; it is never in argv, `.git/config`, the remote's
1981
+ URL (`https://github.com/<owner>/<repo>.git`), the run's folder, the agent's environment or a log line, and it is revoked
1982
+ once the fetch is done. Git there reads no system or global config and fetches no tags or submodules. With no App, or one
1983
+ not installed on the repository, the fetch is anonymous, which a public repository answers. The run's system prompt
1984
+ carries one line: the checkout's facts, or why there is none (no pull request named, a fetch that failed, with git's
1985
+ last words), so its instructions can read the change through the GitHub MCP instead. The checkout is removed when the
1986
+ claim ends, and the next claim of the run makes it again.
1987
+
1884
1988
  ## Templates
1885
1989
 
1886
1990
  A template package makes a working agent in one call: its definition, its skills and rules, and its triggers, from a
@@ -1913,7 +2017,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
1913
2017
  | `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
1914
2018
  | `GET /openapi.json` | Without a credential: this API as an OpenAPI 3.1 document, the `agentrun.v2/0` contract (vendored in `src/openapi/`, its source in `info`) with this server's own routes marked `x-agentrun-serve` the operations it answers `501` marked `x-agentrun-serve-unsupported`, and a contract operation that takes more than the contract gives marked `x-agentrun-serve-changed` with each change named; `links.openapi` in capabilities points at it. |
1915
2019
  | `GET /capabilities` | Without a credential. `backend: local`, every feature flag present and true only when it works; `tools`, the tools an agentic revision may name; `workflows`, what a workflow revision's model nodes get and, in `workflows.decisions.providers`, the decision providers its typed questions run on; `models`, where models come from and the model of each tier. |
1916
- | `POST /agents`, `GET /agents`, `GET /agents/{id}` | `POST` takes `{definition, skills?, note?}` and makes the agent with its first revision, current. A definition has `instructions` (an agentic revision) or `workflow` (a workflow revision, checked by the DSL first), and `name`, `description`, `model` and `thinking` (agentic only), `harness` ([harnesses](#harnesses)), `place` ([place](#place)), `tools`, `tool_settings` ([search and fetch](#search-and-fetch)), `skills` (names; each `<name>/SKILL.md` is in `skills`) and `version`, which is the number the revision gets, and `max_cost_usd`, the agent's default cap (an agentic agent's or a workflow's), kept by an edit that leaves it out and cleared only by 0, and `cap_mode`, how such a cap prices a request, `expected` or `strict` ([spend cap](#spend-cap)), and `output_schema` (agentic only, at most 64 KiB): the JSON Schema the final answer's last fenced json block meets, which a completed run's `result.output` then holds (null when the answer doesn't meet it), kept by an edit that leaves it out. A template's answer schema is set here at apply, and a run a trigger starts is handed that trigger's last completed `result.output` after its message. A field the store does not keep (`input_schema`) is `422 input_invalid` by name, and so is a definition that can never run here; one this host cannot run yet saves with `warnings` ([models](#models)). The ETag (`home_etag`) is the current revision's id. `GET /agents/{id}` adds `tools`, the tools its current revision grants with each one's provider ([search and fetch](#search-and-fetch)). |
2020
+ | `POST /agents`, `GET /agents`, `GET /agents/{id}` | `POST` takes `{definition, skills?, note?}` and makes the agent with its first revision, current. A definition has `instructions` (an agentic revision) or `workflow` (a workflow revision, checked by the DSL first), and `name`, `description`, `model` and `thinking` (agentic only), `harness` ([harnesses](#harnesses)), `place` ([place](#place)), `tools`, `tool_settings` ([search and fetch](#search-and-fetch)), `skills` (names; each `<name>/SKILL.md` is in `skills`) and `version`, which is the number the revision gets, and `max_cost_usd`, the agent's default cap (an agentic agent's or a workflow's), kept by an edit that leaves it out and cleared only by 0, and `cap_mode`, how such a cap prices a request, `expected` or `strict` ([spend cap](#spend-cap)), `max_tool_calls` (agentic only, on pi): the tool calls each conversation of a run may make ([tool-call budget](#tool-call-budget)), and `output_schema` (agentic only, at most 64 KiB): the JSON Schema the final answer's last fenced json block meets, which a completed run's `result.output` then holds (null when the answer doesn't meet it), kept by an edit that leaves it out. A template's answer schema is set here at apply, and a run a trigger starts is handed that trigger's last completed `result.output` after its message. `checkout` (agentic only): `pull_request` has the server check out, before each run's first turn, the pull request the run's GitHub event names, in `repo/` at its head with its base and merge base, using a read-only token of its GitHub App that the agent never holds ([GitHub triggers](#github-triggers-connect-github)); `none` clears it, and an edit that leaves it out keeps it. A field the store does not keep (`input_schema`) is `422 input_invalid` by name, and so is a definition that can never run here; one this host cannot run yet saves with `warnings` ([models](#models)). The ETag (`home_etag`) is the current revision's id. `GET /agents/{id}` adds `tools`, the tools its current revision grants with each one's provider ([search and fetch](#search-and-fetch)). |
1917
2021
  | `PUT /agents/{id}/definition` | The same body, checked [the same way](#models): a new revision, its parent the current one, made current. Without `skills` the current revision's skill files carry over. A definition that is the current revision already writes nothing, so a PUT sent twice makes one revision. An agent's id, name and description stay those it was made with. `If-Match` that is not the current ETag is `412 precondition_failed`; the store compares it again inside the commit, so of two edits that read the same revision exactly one lands. The contract's body is taken too: the definition itself, with `If-Match` required (`412` without it) and `definition.version` greater than the current one (`422`). Any such version is taken, and always makes a new revision, the same definition included; the revision is numbered as this server numbers them, the next, and the answer says which; the route reads a body holding `definition` as this one, any other as the contract's. |
1918
2022
  | `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
1919
2023
  | `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
@@ -1929,7 +2033,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
1929
2033
  | `GET /runs/{id}/files`, `GET /runs/{id}/files/{path}` | The files under the run's `work/`, raw. |
1930
2034
  | `POST /files`, `PUT /files/{id}`, `GET /files`, `GET` and `DELETE /files/{id}` | [Uploads](#uploads): a file sent in one call (`POST /v2/files?path=...`, its bytes the body), or reserved and then sent (`PUT /v2/files/{id}`); the server's uploads listed, read and deleted. |
1931
2035
  | `GET /agents/{id}/home/files`, and `GET`, `PUT`, `DELETE` on a file's path below it | The files in the agent's home, listed, read, written and deleted ([agent home](#agent-home)). This server's own routes (`x-agentrun-serve: "home/1"`). |
1932
- | `GET /stats` | This server's own route, outside the contract (`x-agentrun-serve: "stats/1"`): the agents, the runs (`total`, `active`, `needs_input`, `failed`, `needs_review`, `status_unknown`), each agent's run count, the cost and what is archived, read from the agent store's aggregates alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` `estimate`, or null beside a null `usd`; `unknown_runs` counts the rest. `analytics` (`stats/2`) sums the runs' metrics over the runs not archived that `from` and `to` (RFC 3339 date-times to the millisecond, an impossible one or a finer fraction refused; runs started in [`from`, `to`)) and `agent` pick, each optional, 400 when malformed: `filter` echoes them; `totals` (runs, completed, an escalated run included, `needs_review` (`stats/3`), failed, never an escalated run, `runs_with_metrics`, tokens and each token kind, requests, unmetered, `cost_usd` and `unknown_cost_runs`), `time` (`wall_ms` over the ended runs, `active_ms` where metrics have it), `by_harness_effort`, `by_day` (UTC), `by_source` (`live` or the import source) and the top 20 `tools`. A run with no metrics counts in `runs` and in no token sum. `learning` (`learning/1`) counts the runs that tried to learn over the same filters, from the learning ledger and the runs this server holds ([Learning](#learning)). The query bounds `analytics` and `learning` alone. |
2036
+ | `GET /stats` | This server's own route, outside the contract (`x-agentrun-serve: "stats/1"`): the agents, the runs (`total`, `active`, `needs_input`, `failed`, `needs_review`, `status_unknown`), each agent's run count, the cost and what is archived, read from the agent store's aggregates alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` `estimate`, or null beside a null `usd`; `unknown_runs` counts the rest. `analytics` (`stats/2`) sums the runs' metrics over the runs not archived that `from` and `to` (RFC 3339 date-times to the millisecond, an impossible one or a finer fraction refused; runs started in [`from`, `to`)) and `agent` pick, each optional, 400 when malformed: `filter` echoes them; `totals` (runs, completed, an escalated run included, `needs_review` (`stats/3`), failed, never an escalated run, `runs_with_metrics`, tokens and each token kind, requests, unmetered, `cost_usd` and `unknown_cost_runs`), `time` (`wall_ms` over the ended runs, `active_ms` where metrics have it), `by_harness_effort`, `by_day` (UTC), `by_source` (`live` or the import source) and the top 20 `tools`. A run with no metrics counts in `runs` and in no token sum. `learning` (`learning/1`) counts the runs that tried to learn over the same filters, from the store ([Learning](#learning)). The query bounds `analytics` and `learning` alone. |
1933
2037
  | `GET /runs/{id}/graph` | A workflow run drawn, live: its workflow, the DSL's `workflowGraph`, each node's state (a map's items with their labels and the branch each route took for them, a route's branch), every decision with its receipt (answers, evidence, the state the judge saw, image links), every call with its input and output, and the totals (cost, null when any part is unknown). While the run goes it reads the run process's `live.json`, rewritten every 300 ms, never the run's store, which the process holds; once it ended, its store is read lock-free, so a poll never waits on it and never answers `home_busy`. An agentic run has none (`404`). |
1934
2038
  | `POST /runs/{id}/pause`, `POST /runs/{id}/resume` | A workflow run: what is in flight finishes, and no node, model call or decision starts until it is resumed. Its status reads `paused`, and stays so across a server restart. An agentic run is `501`, an ended one `409`. |
1935
2039
  | `POST /workflows/validate` | `{workflow, tools?}`: every issue a save would refuse (`[{path, code, message}]`, the DSL's validation with code not run) and what this host lacks as `warnings`. Writes nothing. A refused save's `422` carries each issue as a field under `definition.workflow`, with its `code`. |
@@ -1958,6 +2062,7 @@ serves these routes alone:
1958
2062
  - a run's launch (`POST /agents/{id}/runs`, `POST /runs`), read (`GET /runs/{id}`), lists (`GET /agents/{id}/runs`,
1959
2063
  `GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above) and cap raise (`PATCH /runs/{id}`);
1960
2064
  - its files (`GET /runs/{id}/files`, `GET /runs/{id}/files/{path}`) and [uploads](#uploads) (`/files`);
2065
+ - an agent's Archil disk (`GET` and `DELETE /agents/{id}/archil`);
1961
2066
  - `GET /capabilities`, `GET /health` and `GET /usage`.
1962
2067
 
1963
2068
  Every other address is `404 not_found`, answered before the request is read further: the console at `/` and its
@@ -2127,9 +2232,9 @@ alone: a model of any other provider runs as it does without it. `codex` and `op
2127
2232
  to serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
2128
2233
  `OPENROUTER_API_KEY` is set, runs through OpenRouter (`https://openrouter.ai/api`, the key as a bearer token):
2129
2234
  claude-agent on its Messages endpoint, with Anthropic's own id on the wire (OpenRouter takes it: its Claude Code guide
2130
- says its "Anthropic Skin … handles model mapping") and the run priced by OpenRouter's catalog entry; codex and opencode on its Responses API, with the model's whole id (`openai/gpt-6-sol`). On that key alone the defaults are
2131
- `openrouter/openai/gpt-6-sol` for pi (pi-ai's OpenRouter provider, on the bearer route), `anthropic/claude-sonnet-5.5` for
2132
- claude-agent and `openai/gpt-6-sol` for codex and opencode; a direct provider's key gives the default for its harnesses where it is
2235
+ says its "Anthropic Skin … handles model mapping") and the run priced by OpenRouter's catalog entry; codex and opencode on its Responses API, with the model's whole id (`openai/gpt-6.1-sol`). On that key alone the defaults are
2236
+ `openrouter/openai/gpt-6.1-sol` for pi (pi-ai's OpenRouter provider, on the bearer route), `anthropic/claude-sonnet-5.5` for
2237
+ claude-agent and `openai/gpt-6.1-sol` for codex and opencode; a direct provider's key gives the default for its harnesses where it is
2133
2238
  set. A model named `openrouter/<vendor>/<model>` (pi's name for it) goes through OpenRouter on every harness. An endpoint
2134
2239
  the host names never gets OpenRouter's key: `ANTHROPIC_BASE_URL` without `ANTHROPIC_API_KEY` is refused. A model with more
2135
2240
  than one segment after its provider (`anthropic/anthropic/claude-sonnet-5.5`) is refused, naming the form to use. A provider
@@ -2354,7 +2459,7 @@ left out: 2 sessions still being written: they come in next time
2354
2459
  A stopped run can be continued: a follow-up starts a fresh turn on the whole history, and the turn the stop cut is
2355
2460
  not replayed. A cancelled run cannot: a message to it is `409 not_continuable`, and its `next_action` is to start a
2356
2461
  new run of the agent.
2357
- - A workflow revision runs on the workflow loop, which drives the DSL's durable workflow task on the run's journal
2462
+ - A workflow revision runs on the workflow loop, which drives the server's durable workflow task (src/workflow/task.ts) on the run's journal
2358
2463
  (keyed by the run's id): its model nodes (`agent`, `decide`, `extract`, `report`) on the run's model, with the file
2359
2464
  tools each node names, and its typed questions on Jev or Parallel ([decision workflows](#decision-workflows)). A
2360
2465
  workflow that needs code or a tool call this host does not run is not saved here (`422`). The run is `queued`
@@ -2474,6 +2579,10 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
2474
2579
  keys as it opens the run's own, from the server's environment first and then its saved keys, for the run's tools alone:
2475
2580
  never for its model or a CLI harness's own environment. A provider the run's tool gate denies gets no key. Learned
2476
2581
  workflows can use them once decision nodes land (see Coming).
2582
+ A learned workflow's call node can run an MCP tool the agent grants (`mcp:<server>/<tool>`) through the run's own MCP,
2583
+ under the run's tool gate: allowed, it runs at the run's tool cost; denied, the workflow is refused before any node
2584
+ runs; set to ask, the `learned_workflow` call asks once, naming every such tool, and the run parks. A run's own draft
2585
+ can't call one yet: the checks admitting it are coming.
2477
2586
 
2478
2587
  The server reads the commit with git plumbing, never the working tree. What it holds that is not a regular UTF-8 file of
2479
2588
  1 MiB or less, or a note out of shape, is not read, and the server's stderr names it. A learning fault never blocks a
@@ -2516,7 +2625,7 @@ path that is not a `.md` file at the top, a bad name, front matter out of shape
2516
2625
  naming a note that is not active, more than 8 notes superseded, more than 8 new notes or a note over 4068 bytes (4096,
2517
2626
  less the 28 the server's own `origin` and `status` lines may take once it merges the note), an
2518
2627
  index past 200 lines, hidden characters, and text shaped like a secret or holding one of the server's own secrets (the
2519
- launcher's, the keys and tokens in its environment, its API and door tokens, each webhook trigger's signing secret as it
2628
+ launcher's, the keys and tokens in its environment, its API token, each webhook trigger's signing secret as it
2520
2629
  is now), in a note or its name. A cap leaves out the items past it, in the order the answer gave them, and the run's
2521
2630
  learning names what was left out. The whole answer is refused when it holds a secret or a hidden character (no item of
2522
2631
  it is trusted), when it writes a path outside the folder or deletes a file, when a text is not UTF-8, when the index
@@ -2537,11 +2646,14 @@ many notes the folder holds. No injection screen runs before it: a page classifi
2537
2646
  from, and read a preference the user stated as a planted instruction; the grader's Planted question decides: a rule the
2538
2647
  user states in their own words is theirs, even beside a form or a pasted email in the same message, and a rule found only
2539
2648
  inside text the run read is planted and dropped, never held for the owner's OK. An item that holds an account number is
2540
- dropped too, even where the user gave it as where money goes. The Risky question reads one way on every grade model: a
2649
+ dropped too, even where the user gave it as where money goes; one with a bank account, IBAN, routing or sort-code number
2650
+ beside its word never reaches the grader, since the checks refuse it as they refuse a secret. The Risky question reads one way on every grade model: a
2541
2651
  limit or threshold that decides whether an approval or a check happens is risky in either direction, as is an exemption
2542
2652
  from a check, trusting or paying a named site or seller, or naming where money or data goes, whoever asked. What the
2543
2653
  grade spends is in no run's totals, and is read once its request is booked: it is kept on the run's learning, and counted once on `GET /usage` under the meter
2544
2654
  `learning`, by agent and by day; a call cut off at its bound spent what nobody knows, so its cost is unknown, never $0.
2655
+ A grade that contradicts itself (it keeps every item yet says not to merge) is asked once more, the contradiction named;
2656
+ a second contradiction drops the proposal, saying the review contradicted itself.
2545
2657
 
2546
2658
  A kept verdict merges as one commit on `main`, made with plumbing: the new notes added, each with its `origin` (`you`
2547
2659
  for what the user asked in their own words, `run` for what the run worked out), each note they supersede marked
@@ -2560,7 +2672,7 @@ characters and no time) says how it went: `seeded`, then
2560
2672
  `reflecting` during the turn and until what it answered is checked, `proposed` while it is graded, and `merged`, or
2561
2673
  `dropped` with a reason from a closed list (`seed_failed`, `no_budget`, `unknown_cost`, `cancelled`, `crashed`,
2562
2674
  `reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`; a run
2563
- record or ledger line with any other reason is not counted). It is `null` for a
2675
+ record with any other reason is not counted). It is `null` for a
2564
2676
  run that does not learn (its agent's `learning` is not true, the server's switch was off when it started, or it is a
2565
2677
  workflow's or an imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2
2566
2678
  notes.", "Looking back on this run…", "Checking 1 new note…", "Learned: Check units (replaces 1 older note)", "Learned:
@@ -2584,17 +2696,9 @@ notes its merge added, once `merged`; and `pending`, `[{file, name}]`, the notes
2584
2696
  `merged`, never among `learned`. A name and a file are cut of the server's secrets as they are now, a file holding one
2585
2697
  `[redacted]`. Whether a run applied a note is not measured: `given` and `read` say what it had and what it opened. Each
2586
2698
  note on the agent's learning view and notes page counts its runs of each, `runs: {given, read}`, over the runs the server
2587
- knows (held ones from memory, ended ones from the learning ledger).
2588
-
2589
- Each run's learning end is written once to the learning ledger, `DATA/learning-usage.jsonl`, one line `{run, agent,
2590
- state, reason, at, cost, tokens, seed_notes, given, read, answered_at, job_cost_usd, look_back_usd}` (`cost` and
2591
- `tokens` the grade's, null when unknown, 0 when nothing was graded; `seed_notes` how many notes the run started from;
2592
- `given` and `read` the files of the notes it was given and read, each absent when there are none; once it looked back,
2593
- `answered_at` and `job_cost_usd`, when its job's answer was final and what it had cost then; `look_back_usd` what
2594
- looking back cost, 0 when it did not), after its `serve.json` holds it; a server that went between the two writes it at
2595
- its next start. A run's notes are the one part that moves after its end (a follow-up reads another note): a line
2596
- `{run, agent, notes: true, given, read}` then says them anew, the latest one winning, and counts neither the run nor its
2597
- costs again. `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
2699
+ knows, read from the store.
2700
+
2701
+ `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
2598
2702
  `agent`, from the store (each run's kept learning and its learning run's journal; `in_progress` while a proposal waits
2599
2703
  for its grade), never opening a run's files; the `learning` meter on `GET /usage` reads each run's grade from the same.
2600
2704
 
@@ -2617,9 +2721,8 @@ proposed and reused, staleness after a rule changes, and wrong keeps after a pla
2617
2721
  - A learned workflow may hold decision nodes (judge, pick, sift), answered by the run's decision provider under the run's cap (#2363).
2618
2722
  - Consolidation: related notes merged into one, and a skill and its workflow brought back in step (#2335).
2619
2723
  - A learned workflow's node of a tier runs on the server's model of that tier, at its own price (#2408).
2620
- - A learned workflow's call node runs an MCP tool through the run's own MCP, under its gate, and the grader holds one that writes for the owner's OK (#2424).
2724
+ - A run's workflow draft may call a granted MCP tool: the checks admit it, and the grader holds one that writes for the owner's OK.
2621
2725
  - A learned workflow keeps the output format its skill asks for (#2412).
2622
- - A grade that contradicts itself is asked once more (#2425).
2623
2726
 
2624
2727
  ### What a person sees and controls
2625
2728
 
@@ -2629,13 +2732,12 @@ with the token, an archived agent's too:
2629
2732
  - `GET /agents/{agent_id}/learning`: `main`'s head, `MEMORY.md` as `index`, the first 50 notes (active first, then
2630
2733
  newest first) and the first 20 changes on `main` (newest first, each `by: {run}` from its `Run-Id` trailer or
2631
2734
  `{user: true}`, with its commit, time, reason and files), and how the agent's runs that tried to learn fared
2632
- (`merged`, `dropped` by reason, `in_progress`), counted as `GET /stats` counts them: from the learning ledger and the
2633
- runs the server holds, never a run's files; and `impact` (`learning/2`), what learning changed: the agent's completed
2735
+ (`merged`, `dropped` by reason, `in_progress`), counted as `GET /stats` counts them: from the store, never a run's files; and `impact` (`learning/2`), what learning changed: the agent's completed
2634
2736
  runs that started from at least one active note against those that started before its first note (the earlier of its
2635
2737
  first merge and the start of its first run that started from a note, so a person's first note counts), each side's
2636
2738
  `runs`; `median_duration_s`, the time to the answer (the run's start to its job's end, before it looks back);
2637
2739
  `median_cost_usd`, the job's own cost without its look-back, over the `cost_runs` whose cost is known; and
2638
- `median_learning_usd`, what learning itself cost a run (its look-back and its grade). From the same rows and ledger;
2740
+ `median_learning_usd`, what learning itself cost a run (its look-back and its grade). From the same rows;
2639
2741
  null unless both sides count 2 runs. An agent with no folder answers `main: null`, empty pages and `impact: null`.
2640
2742
  `GET .../learning/notes?cursor=&limit=&status=` and `GET .../learning/log?cursor=&limit=` page on, up to 200 at a
2641
2743
  time; a cursor reads the same commit its first page did.
@@ -2667,6 +2769,17 @@ with the token, an archived agent's too:
2667
2769
  too (`Approved-Via: console`). The learning view gives each item `last_change` (`{kind, by, at}`: `approved`,
2668
2770
  `edited`, `created`, `retired` or `restored` by a `person`, or `learned` by a `run`) and each retired one `retired`
2669
2771
  (`{at, by}`, the time of its retire, which an edit since moves not).
2772
+ - `POST .../learning/workflows/{name}/promote` (`{name?}`) makes an active learned workflow an agent of its own: a new
2773
+ agent, as `POST /agents` makes one, whose revision is a workflow revision of the workflow's `workflow.json`, so its
2774
+ runs run the workflow's nodes with no agent loop, answer the workflow's output, and can be started by a trigger or a
2775
+ pipeline like any agent's. Only an active one: a workflow that waits for its owner's OK, or was retired, is 409
2776
+ `learned_not_active`. Its files are checked again as a restore checks them, and its workflow as the learning checker
2777
+ checks a run's draft against the agent's tools and gate (400 with `problems`), then as any workflow revision's save
2778
+ (422, or 409 `agent_not_runnable`). The new agent's `tools` are the ones its call nodes call, and it keeps the source
2779
+ agent's policy as it is now (its `tool_settings`, `approvals`, `max_cost_usd` and `cap_mode`), never more. Its id is the
2780
+ workflow's name, with `-2`, `-3` and on past an agent's id or name already here, and its name `name` or the same. It
2781
+ answers 201 with the agent; the learned workflow stays in the folder, unchanged. It takes the owner's password session
2782
+ alone, as an approval does.
2670
2783
  - `GET /runs/{run_id}/learning`: the run's learning whole (its `given`, `read` and `learned` as on its read, its seed, its merge, the grader's verdict with its item for
2671
2784
  each new note, `{file, keep, question, why}`, `question` the rubric's question a dropped note failed, the checker's
2672
2785
  problems, what the grade cost), `null` for a run that does not learn; `verdict` is `null` until a grade ran.
@@ -2691,7 +2804,7 @@ Who can approve: the owner, signed in with their password. No token approves, th
2691
2804
 
2692
2805
  `POST .../learning/files/{file}/approve` (and `.../restore`, which puts a retired item back into every run) takes the console's password session, sent from this server's own origin with
2693
2806
  a JSON body as every page write is. Any token is 403: the server's own (what scripts and the MCP endpoint's tools
2694
- carry), a run's door token, and a token sent beside the session. So is every request on a server with accounts off
2807
+ carry) and a token sent beside the session. So is every request on a server with accounts off
2695
2808
  (`AGENTRUN_ACCOUNTS=0`), whose page cookie any token holder can mint. With no credential it is 401, as every route.
2696
2809
  `capabilities.learning.approve` is true only for the owner's session; every other caller reads `approve: false` with
2697
2810
  `approve_needs: "password"`. A note that is not pending is 400; a stale ETag is 412, none 428. The approval is one host
@@ -2742,6 +2855,19 @@ on claude-agent, codex and opencode the model proxy adds them to the body (after
2742
2855
  prefix is unchanged). Neither CLI nor pi keeps them in its transcript, and no message is queued, so nothing runs after
2743
2856
  the model's answer. Once per cap, across restarts; a raise re-arms it.
2744
2857
 
2858
+ A capped run also stops calling tools before its cap stops it. Once what it has spent, plus what its requests and paid
2859
+ steps still out are held at (their worst case, as the cap counts them, a browser session's open reserve included),
2860
+ reaches 75% of its cap, the run's tool gate
2861
+ refuses every call a model makes, in every conversation of the run, on every harness, before any setting or approval
2862
+ is read, with one fixed text: "Budget nearly spent: stop calling tools and answer now from what you have." A call that
2863
+ would open a child conversation is refused the same way, so no new one starts. Nothing in flight is cut: a child still
2864
+ working gets the same refusal on its next call and answers, a call a running tool makes is that tool's and runs, and
2865
+ model requests are judged by the cap as before, so the run's final answer still lands. The cap stays the last line: a
2866
+ request that does not fit what is left is refused as above. The figure is read from the run's booking records at each
2867
+ call, never kept in memory, so a restart or a claim moved to another runner holds the same line, and a raise moves it.
2868
+ Several requests out at once hold far more than they cost, which is why a fan-out of children used to end a small cap
2869
+ with no answer at all; the quarter left above the line is the room for each of them, and the parent, to answer.
2870
+
2745
2871
  Under a cap each request is limited to the
2746
2872
  output tokens what is left of the cap can buy, thinking included, never more than it asks for or than the model's
2747
2873
  ceiling (its max output tokens, else its context window, clamped to what the window leaves): on pi through the request's
@@ -2751,9 +2877,33 @@ so the cap stays exact. A request is refused only when what is left cannot buy i
2751
2877
  tokens for its answer (what it asks for, when that is fewer), and when it thinks, the provider's least thinking budget
2752
2878
  where thinking takes one (Anthropic's, 1,024, the budget squeezed to it at the least) or else its thinking level's
2753
2879
  budget, since its reasoning then shares the limit (minimal 1,024, low 2,048, medium 8,192, high 16,384). The input bound is one token per UTF-8 byte of what is sent (a byte-level tokenizer never makes
2754
- a token of less than one byte, and an image's base64 is far more bytes than its tokens), plus what the provider adds
2755
- server-side (a tool-use prompt, each image), from the same table the model proxy of claude-agent, codex and opencode uses; there
2756
- the proxy measures each request's body. A request in flight holds what it was admitted at until it answers, so requests
2880
+ a token of less than one byte), each image counted at what its model's provider bills it by its size in place of its
2881
+ base64's bytes, plus what the provider adds server-side (a tool-use prompt), from the same table the model proxy of
2882
+ claude-agent, codex and opencode uses; there the proxy measures each request's body. On a route straight to Anthropic
2883
+ (`https://api.anthropic.com`, on pi and claude-agent), each answer request is also counted by Anthropic's own free
2884
+ token count (`POST /v1/messages/count_tokens`, with only the credential and version headers, and never through a
2885
+ gateway or any other base), and its bound is that count plus the tool-use prompt when that is below its bytes. A count
2886
+ that fails or takes over 3 seconds leaves the byte bound; the request is never held up or refused for it.
2887
+
2888
+ **The smallest cap that works.** The byte bound reads text as about two to three times the tokens it is billed as, and a
2889
+ step is sent only when the run's spend plus that step's least (its input bound, priced by the cap mode, and a 1,024-token
2890
+ answer) fits. So a small cap pauses a run well before it has spent it. Measured on a pi desktop run on Sonnet ($3 / $15,
2891
+ cache write $3.75, cache read $0.30 a million) through the dispatch's own system prompt and tools, five requests (four
2892
+ screenshots, then the answer), spending about $0.04 in all:
2893
+
2894
+ | Cap mode | Route | First request needs | Five-step run needs | Each further step |
2895
+ | --- | --- | --- | --- | --- |
2896
+ | `strict` | Through a gateway (OpenRouter): the byte bound | $0.05 | $0.11 | about $0.013 |
2897
+ | `strict` | Straight to Anthropic: Anthropic's count | $0.03 | $0.09 | about $0.012 |
2898
+ | `expected` (the default) | Either | as `strict` | as `strict` until #2504 lands | as `strict` until #2504 lands |
2899
+
2900
+ In `strict` mode every step's whole input is priced at the cache-write price. The `expected` row is today's: the runner
2901
+ does not yet price a step from what the previous request read from the cache, as `expected` is described above, so it
2902
+ prices like `strict` until #2504 lands. Once it does, a five-step run in `expected` mode needs about $0.06 by either route,
2903
+ and about $0.007 a further step. A claude-agent run's first request is of the same size (the pinned
2904
+ CLI's measured 6,926 bytes with five tools: $0.04 for its first request through a gateway). A cap below these pauses at
2905
+ once with `Not sent: ... the next step needs at least $X`, and a raise to that figure sends it on.
2906
+ `packages/serve/test/cap-minimum.test.mjs` holds these figures to what the cap does. A request in flight holds what it was admitted at until it answers, so requests
2757
2907
  sent side by side cannot pass the cap together. Spent so far is read from the run's store each time its process starts, so it
2758
2908
  survives a restart, plus each response since, and with them each charge a paid tool booked (`monid.run`, which is itself
2759
2909
  refused once the spend reaches the cap; see [monid](#tools)).
@@ -2842,7 +2992,8 @@ no cap fixes, its error), as a person who has never seen a model request reads t
2842
2992
  least $0.03, and this run's cap is $0.01. Raise the cap to at least $0.03 to continue.", and once a run has spent:
2843
2993
  "Not sent: this run has spent $0.45 of its $0.50 cap, and the next step needs at least $0.03. Raise the cap to at least
2844
2994
  $0.48 to continue." What was spent, and what steps still running hold (named when it is a cent or more), read to the
2845
- nearest cent ($0.0237416 reads $0.02); the exact amounts are `pending.spent_usd`. The cap to raise to is what was
2995
+ nearest cent ($0.0237416 reads $0.02); a spend above $0 that rounds to $0 reads "less than a cent" ("this run has spent
2996
+ less than a cent of its $0.105 cap"), never "$0"; the exact amounts are `pending.spent_usd`. The cap to raise to is what was
2846
2997
  spent, what steps still running hold, and the next step's least, rounded up to the cent so that it is enough. The words
2847
2998
  name no model. The refusal's timeline row is an `error` row with
2848
2999
  `paused: true`: the request was not sent and the run waits on a raise, so it reads as a pause, never as a failure. The error's code is `spend_cap_reached (out of budget): ` before those words: pi-ai's
@@ -2937,6 +3088,15 @@ OpenRouter Decisions model the catalog lists no price for: `409 agent_not_runnab
2937
3088
  node's label and its fix. A step no cap fixes all the same (a spend no one knows) ends the run `failed`,
2938
3089
  `spend_cap_reached`, in the cap's words, after the node's label.
2939
3090
 
3091
+ ## Tool-call budget
3092
+
3093
+ An agentic definition's `max_tool_calls: N` gives each conversation of its runs on pi N tool calls: the run's own, and
3094
+ each conversation a tool opens, counted apart. Past N the run's tool gate refuses every call before it runs, before
3095
+ any setting or approval is read, with one fixed text: the budget is spent, don't call another tool, answer now from
3096
+ what you have. That refusal is not counted and never ends the run, so the model's next answer is the turn's. The count
3097
+ is read from the conversation's committed journal, so a restart or a claim moved to another runner keeps it. Above 0
3098
+ sets the budget, 0 clears it, an edit that leaves it out keeps it; a workflow's, or one on another harness, is `422`.
3099
+
2940
3100
  ## The faux model
2941
3101
 
2942
3102
  `--faux MODULE` loads `MODULE` in each run's process. Its default export is called for every model request with the
@@ -2967,13 +3127,13 @@ carries no cost at all, as from a provider that does not price the model. The te
2967
3127
 
2968
3128
  - An import (`agentrun-serve import`, and setup's import) cuts secrets out of everything it writes: the values of the
2969
3129
  environment's key-shaped variables and the keys saved on this server, the secrets this server made and keeps (its API
2970
- token, its door token, its sign-in secret, and its webhook's signing secret when the seal key opens it; when it does
3130
+ token, its sign-in secret, and its webhook's signing secret when the seal key opens it; when it does
2971
3131
  not, the CLI's import says so once, on stderr, and goes on), and the keys [secretlint](https://github.com/secretlint/secretlint)'s
2972
3132
  recommended rules find in what it reads (Anthropic, OpenAI, GitHub, Slack and Stripe keys, AWS secret keys beside their
2973
3133
  name, private keys, database URLs with a password, and more). Each becomes `[redacted]`, and the import says how many
2974
3134
  distinct values it removed. Known key formats are removed. Other secrets in your session history, like passwords in
2975
- config files, are imported as they are. So are a key-shaped value this server did not make (a `whsec_` secret from
2976
- another service) and a run's own door token.
3135
+ config files, are imported as they are. So is a key-shaped value this server did not make (a `whsec_` secret from
3136
+ another service).
2977
3137
  - The decision keys (`TYPESAFE_API_KEY`, `PARALLEL_API_KEY`, `OPENROUTER_API_KEY` as Jev's or OpenRouter's) are never in
2978
3138
  a run's environment or files: a run's process gets on a pipe of their own only those it needs, for its decision
2979
3139
  providers ([decision workflows](#decision-workflows)) and its web tools: Jev's (by its route) for a node that names Jev
@@ -3083,7 +3243,7 @@ carries no cost at all, as from a provider that does not price the model. The te
3083
3243
  ## Test
3084
3244
 
3085
3245
  ```sh
3086
- npm run build -w @parcha/agentrun-dsl -w @parcha/agentrun-pi -w @parcha/pi-durable-agent -w @parcha/agentrun-serve
3246
+ npm run build
3087
3247
  npm test -w @parcha/agentrun-serve
3088
3248
  ```
3089
3249