@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37

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 (522) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/README.md +417 -219
  3. package/dist/adapters.d.ts +12 -2
  4. package/dist/adapters.js +27 -2
  5. package/dist/agent-rows.d.ts +2 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +9 -4
  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 +79 -7
  13. package/dist/archil-settings.js +140 -14
  14. package/dist/attach-conformance-cli.d.ts +1 -0
  15. package/dist/attach-conformance-cli.js +18 -0
  16. package/dist/attach-conformance.d.ts +25 -0
  17. package/dist/attach-conformance.js +343 -0
  18. package/dist/attach-images.d.ts +15 -0
  19. package/dist/attach-images.js +59 -0
  20. package/dist/background.d.ts +0 -6
  21. package/dist/background.js +0 -28
  22. package/dist/box-image.d.ts +1 -97
  23. package/dist/box-image.js +4 -284
  24. package/dist/box-paths.d.ts +2 -7
  25. package/dist/box-paths.js +7 -13
  26. package/dist/box-settings.d.ts +0 -11
  27. package/dist/box-settings.js +4 -29
  28. package/dist/browser-commands.js +1 -1
  29. package/dist/browser-computer.d.ts +47 -3
  30. package/dist/browser-computer.js +286 -18
  31. package/dist/browser-cost.d.ts +1 -1
  32. package/dist/browser-live.d.ts +20 -8
  33. package/dist/browser-live.js +50 -27
  34. package/dist/browser-person.d.ts +19 -2
  35. package/dist/browser-person.js +55 -6
  36. package/dist/browser-wait-ended.d.ts +23 -0
  37. package/dist/browser-wait-ended.js +42 -0
  38. package/dist/cap.d.ts +12 -57
  39. package/dist/cap.js +20 -160
  40. package/dist/catalog.d.ts +1 -12
  41. package/dist/catalog.js +3 -33
  42. package/dist/cli.js +17 -26
  43. package/dist/composio-preset.d.ts +36 -0
  44. package/dist/composio-preset.js +179 -0
  45. package/dist/computer-attach.d.ts +125 -0
  46. package/dist/computer-attach.js +330 -0
  47. package/dist/computer-calls.d.ts +48 -0
  48. package/dist/computer-calls.js +126 -0
  49. package/dist/computer-channel.d.ts +57 -0
  50. package/dist/computer-channel.js +115 -0
  51. package/dist/computer-commands.d.ts +1 -1
  52. package/dist/computer-held-routes.d.ts +35 -0
  53. package/dist/computer-held-routes.js +106 -0
  54. package/dist/computer-held.d.ts +48 -0
  55. package/dist/computer-held.js +87 -0
  56. package/dist/computer-keys.d.ts +21 -1
  57. package/dist/computer-keys.js +53 -11
  58. package/dist/computer-live.d.ts +160 -0
  59. package/dist/computer-live.js +643 -0
  60. package/dist/computer-routes.d.ts +1 -4
  61. package/dist/computer-routes.js +3 -5
  62. package/dist/computer-setting.d.ts +2 -0
  63. package/dist/computer-setting.js +38 -1
  64. package/dist/computer-view.d.ts +24 -2
  65. package/dist/computer-view.js +51 -3
  66. package/dist/computer-viewer.d.ts +6 -0
  67. package/dist/computer-viewer.js +297 -0
  68. package/dist/computers.d.ts +79 -12
  69. package/dist/computers.js +147 -28
  70. package/dist/console/assets/index-Cn6JX1uH.js +563 -0
  71. package/dist/console/assets/index-DRN62V5v.css +1 -0
  72. package/dist/console/index.html +2 -2
  73. package/dist/docker-daemon.d.ts +2 -2
  74. package/dist/docker-daemon.js +2 -2
  75. package/dist/errors.js +5 -5
  76. package/dist/faux-computers.d.ts +9 -20
  77. package/dist/faux-computers.js +56 -24
  78. package/dist/files.d.ts +1 -9
  79. package/dist/files.js +1 -9
  80. package/dist/github-connection.d.ts +10 -2
  81. package/dist/github-connection.js +65 -2
  82. package/dist/github-faux.js +1 -1
  83. package/dist/github.d.ts +22 -2
  84. package/dist/github.js +42 -8
  85. package/dist/gpu-words.d.ts +14 -0
  86. package/dist/gpu-words.js +21 -0
  87. package/dist/graph-view.d.ts +3 -1
  88. package/dist/graph-view.js +25 -1
  89. package/dist/handed-values.d.ts +1 -1
  90. package/dist/handed-values.js +1 -1
  91. package/dist/harness-install.d.ts +60 -3
  92. package/dist/harness-install.js +322 -34
  93. package/dist/harness.d.ts +1 -0
  94. package/dist/harness.js +36 -2
  95. package/dist/host-tools.d.ts +9 -10
  96. package/dist/host-tools.js +7 -7
  97. package/dist/hosted-search.d.ts +5 -4
  98. package/dist/hosted-search.js +2 -7
  99. package/dist/import-sources.d.ts +10 -0
  100. package/dist/import-sources.js +44 -2
  101. package/dist/import.d.ts +3 -3
  102. package/dist/import.js +37 -6
  103. package/dist/index.d.ts +1 -3
  104. package/dist/index.js +1 -2
  105. package/dist/key-refusal.d.ts +1 -1
  106. package/dist/key-refusal.js +2 -2
  107. package/dist/learn/check.d.ts +11 -2
  108. package/dist/learn/check.js +124 -6
  109. package/dist/learn/commit.d.ts +43 -7
  110. package/dist/learn/commit.js +166 -22
  111. package/dist/learn/folder.d.ts +11 -0
  112. package/dist/learn/folder.js +37 -1
  113. package/dist/learn/general.d.ts +66 -0
  114. package/dist/learn/general.js +73 -0
  115. package/dist/learn/grade.d.ts +22 -1
  116. package/dist/learn/grade.js +107 -16
  117. package/dist/learn/index.d.ts +1 -1
  118. package/dist/learn/index.js +1 -1
  119. package/dist/learn/learning.sh +12 -1
  120. package/dist/learn/notes.d.ts +3 -0
  121. package/dist/learn/notes.js +3 -0
  122. package/dist/learn/reflect.d.ts +14 -2
  123. package/dist/learn/reflect.js +54 -30
  124. package/dist/learn/skills.d.ts +37 -5
  125. package/dist/learn/skills.js +60 -7
  126. package/dist/learned-nodes.d.ts +6 -2
  127. package/dist/learned-workflow.d.ts +43 -9
  128. package/dist/learned-workflow.js +128 -37
  129. package/dist/learning-batch.d.ts +283 -0
  130. package/dist/learning-batch.js +574 -0
  131. package/dist/learning-cost.d.ts +79 -0
  132. package/dist/learning-cost.js +69 -0
  133. package/dist/learning-evals.d.ts +33 -0
  134. package/dist/learning-evals.js +98 -0
  135. package/dist/learning-routes.d.ts +32 -4
  136. package/dist/learning-routes.js +48 -12
  137. package/dist/learning-words.d.ts +9 -0
  138. package/dist/learning-words.js +12 -2
  139. package/dist/learning.d.ts +39 -19
  140. package/dist/learning.js +88 -46
  141. package/dist/live/stream.js +6 -3
  142. package/dist/live/translate.d.ts +4 -3
  143. package/dist/live/translate.js +8 -4
  144. package/dist/live-reach.d.ts +37 -0
  145. package/dist/live-reach.js +62 -0
  146. package/dist/mcp-gateway.d.ts +9 -0
  147. package/dist/mcp-gateway.js +60 -11
  148. package/dist/mcp-oauth.d.ts +57 -7
  149. package/dist/mcp-oauth.js +133 -18
  150. package/dist/mcp-private-hosts.d.ts +4 -4
  151. package/dist/mcp-private-hosts.js +20 -12
  152. package/dist/mcp-probe.d.ts +27 -3
  153. package/dist/mcp-probe.js +106 -29
  154. package/dist/mcp-secret-writes.js +8 -0
  155. package/dist/mcp-servers-store.d.ts +38 -15
  156. package/dist/mcp-servers-store.js +120 -23
  157. package/dist/mcp-store.d.ts +10 -4
  158. package/dist/mcp-store.js +17 -6
  159. package/dist/model-form.d.ts +26 -0
  160. package/dist/model-form.js +80 -0
  161. package/dist/model.d.ts +5 -5
  162. package/dist/model.js +29 -16
  163. package/dist/openapi.d.ts +2 -0
  164. package/dist/openapi.js +586 -64
  165. package/dist/owner.d.ts +0 -1
  166. package/dist/owner.js +0 -2
  167. package/dist/page.d.ts +18 -0
  168. package/dist/page.js +48 -20
  169. package/dist/paid-calls.d.ts +1 -1
  170. package/dist/paid-calls.js +1 -1
  171. package/dist/place-offers.d.ts +96 -0
  172. package/dist/place-offers.js +202 -0
  173. package/dist/place.d.ts +9 -13
  174. package/dist/place.js +21 -32
  175. package/dist/port-models.d.ts +2 -1
  176. package/dist/port-models.js +5 -3
  177. package/dist/print.d.ts +16 -9
  178. package/dist/print.js +15 -17
  179. package/dist/propose.d.ts +4 -0
  180. package/dist/propose.js +34 -11
  181. package/dist/provider.js +3 -2
  182. package/dist/reflect-range.d.ts +8 -1
  183. package/dist/reflect-range.js +1 -1
  184. package/dist/run-cut.d.ts +5 -0
  185. package/dist/run-cut.js +19 -0
  186. package/dist/run-launch.d.ts +28 -3
  187. package/dist/run-launch.js +14 -4
  188. package/dist/run-learning-served.d.ts +2 -2
  189. package/dist/run-manifest.d.ts +2 -2
  190. package/dist/run-manifest.js +2 -2
  191. package/dist/run-reads-over-store.d.ts +1 -1
  192. package/dist/run-repo.d.ts +20 -0
  193. package/dist/run-repo.js +63 -0
  194. package/dist/run-secrets.js +3 -3
  195. package/dist/run-timeline-served.d.ts +1 -1
  196. package/dist/run-timeline-served.js +56 -44
  197. package/dist/run-view.d.ts +8 -5
  198. package/dist/run-view.js +18 -10
  199. package/dist/runnable.d.ts +2 -2
  200. package/dist/runnable.js +6 -2
  201. package/dist/runner/adapter-loop.d.ts +39 -8
  202. package/dist/runner/adapter-loop.js +770 -83
  203. package/dist/runner/adapter-run-spec.d.ts +36 -7
  204. package/dist/runner/adapter-run-spec.js +171 -37
  205. package/dist/runner/adapters/pi-computer.d.ts +7 -0
  206. package/dist/runner/adapters/pi-computer.js +43 -0
  207. package/dist/runner/adapters/pi.d.ts +20 -7
  208. package/dist/runner/adapters/pi.js +111 -26
  209. package/dist/runner/beside.d.ts +7 -3
  210. package/dist/runner/beside.js +26 -12
  211. package/dist/runner/claim-secrets.d.ts +4 -0
  212. package/dist/runner/claim-secrets.js +6 -1
  213. package/dist/runner/cli-run-spec.d.ts +27 -3
  214. package/dist/runner/cli-run-spec.js +198 -74
  215. package/dist/runner/commands.d.ts +8 -2
  216. package/dist/runner/commands.js +31 -6
  217. package/dist/runner/computer-channel.d.ts +34 -0
  218. package/dist/runner/computer-channel.js +61 -0
  219. package/dist/runner/conformance/harness.d.ts +0 -1
  220. package/dist/runner/conformance/harness.js +87 -18
  221. package/dist/runner/conformance/subject.d.ts +1 -1
  222. package/dist/runner/dispatch.js +3 -0
  223. package/dist/runner/end-of-run.d.ts +22 -12
  224. package/dist/runner/end-of-run.js +38 -16
  225. package/dist/runner/github-app.d.ts +2 -1
  226. package/dist/runner/github-app.js +6 -4
  227. package/dist/runner/harness-loops.js +16 -2
  228. package/dist/runner/held-run.d.ts +65 -0
  229. package/dist/runner/held-run.js +158 -0
  230. package/dist/runner/journal-kinds.d.ts +35 -6
  231. package/dist/runner/journal-kinds.js +20 -1
  232. package/dist/runner/journal-reader.d.ts +5 -4
  233. package/dist/runner/journal-reader.js +12 -10
  234. package/dist/runner/learning-ask.d.ts +7 -1
  235. package/dist/runner/learning-ask.js +21 -6
  236. package/dist/runner/learning-dispatch.d.ts +22 -0
  237. package/dist/runner/learning-dispatch.js +77 -10
  238. package/dist/runner/learning-end.d.ts +37 -1
  239. package/dist/runner/learning-end.js +115 -14
  240. package/dist/runner/learning-factory.d.ts +1 -1
  241. package/dist/runner/learning-factory.js +15 -5
  242. package/dist/runner/learning-loop.d.ts +139 -7
  243. package/dist/runner/learning-loop.js +369 -32
  244. package/dist/runner/learning-seed.d.ts +9 -0
  245. package/dist/runner/learning-seed.js +14 -1
  246. package/dist/runner/live-ticker.js +1 -0
  247. package/dist/runner/loop-contract.d.ts +16 -1
  248. package/dist/runner/loop-contract.js +6 -0
  249. package/dist/runner/loop.d.ts +10 -2
  250. package/dist/runner/loop.js +22 -1
  251. package/dist/runner/main.d.ts +13 -1
  252. package/dist/runner/main.js +38 -6
  253. package/dist/runner/mcp-claim.d.ts +11 -4
  254. package/dist/runner/mcp-claim.js +140 -23
  255. package/dist/runner/mcp-github.d.ts +4 -2
  256. package/dist/runner/mcp-github.js +1 -8
  257. package/dist/runner/mcp-run.d.ts +6 -4
  258. package/dist/runner/mcp-run.js +16 -3
  259. package/dist/runner/metrics.d.ts +15 -2
  260. package/dist/runner/metrics.js +21 -2
  261. package/dist/runner/model-route.d.ts +3 -0
  262. package/dist/runner/model-route.js +5 -2
  263. package/dist/runner/pr-checkout.d.ts +60 -0
  264. package/dist/runner/pr-checkout.js +176 -0
  265. package/dist/runner/reflect-hook.d.ts +19 -0
  266. package/dist/runner/reflect-hook.js +20 -8
  267. package/dist/runner/runner.d.ts +26 -0
  268. package/dist/runner/runner.js +231 -27
  269. package/dist/runner/scratch-sweep.d.ts +13 -0
  270. package/dist/runner/scratch-sweep.js +62 -0
  271. package/dist/runner/sessions.d.ts +1 -1
  272. package/dist/runner/spec-holds.d.ts +8 -3
  273. package/dist/runner/spec-holds.js +12 -10
  274. package/dist/runner/store-port.d.ts +7 -2
  275. package/dist/runner/store-secrets.js +21 -4
  276. package/dist/runner/subagent.d.ts +44 -0
  277. package/dist/runner/subagent.js +190 -0
  278. package/dist/runner/workflow-host.d.ts +24 -3
  279. package/dist/runner/workflow-host.js +24 -4
  280. package/dist/runner/workflow-loop.d.ts +6 -3
  281. package/dist/runner/workflow-loop.js +9 -8
  282. package/dist/runner/workflow-spec.d.ts +39 -15
  283. package/dist/runner/workflow-spec.js +143 -40
  284. package/dist/runs-over-store.d.ts +16 -6
  285. package/dist/runs-over-store.js +145 -29
  286. package/dist/seal-key.js +3 -3
  287. package/dist/sealed-settings-store.d.ts +5 -2
  288. package/dist/sealed-settings-store.js +10 -4
  289. package/dist/sealing.js +1 -2
  290. package/dist/secret-cut.d.ts +1 -1
  291. package/dist/secret-cut.js +1 -1
  292. package/dist/secret-writes.d.ts +5 -4
  293. package/dist/secret-writes.js +5 -4
  294. package/dist/server-secrets-store.d.ts +4 -3
  295. package/dist/server-secrets-store.js +15 -9
  296. package/dist/server-secrets.js +3 -2
  297. package/dist/server.d.ts +75 -63
  298. package/dist/server.js +712 -316
  299. package/dist/settings-wake.d.ts +21 -0
  300. package/dist/settings-wake.js +59 -0
  301. package/dist/standard-webhooks.d.ts +4 -1
  302. package/dist/standard-webhooks.js +8 -4
  303. package/dist/store/agent-body.d.ts +9 -2
  304. package/dist/store/agent-body.js +16 -8
  305. package/dist/store/command-wake.d.ts +12 -0
  306. package/dist/store/command-wake.js +37 -0
  307. package/dist/store/deadline.js +9 -5
  308. package/dist/store/dialect.d.ts +6 -0
  309. package/dist/store/dialect.js +5 -0
  310. package/dist/store/index.d.ts +4 -4
  311. package/dist/store/index.js +2 -2
  312. package/dist/store/journal/storage.d.ts +3 -2
  313. package/dist/store/journal/storage.js +15 -6
  314. package/dist/store/postgres/connection.js +9 -4
  315. package/dist/store/postgres/dialect.js +4 -0
  316. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  317. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  318. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  319. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  320. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  321. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  322. package/dist/store/schema.d.ts +2 -1
  323. package/dist/store/schema.js +85 -13
  324. package/dist/store/seal.d.ts +13 -0
  325. package/dist/store/seal.js +19 -0
  326. package/dist/store/sqlite/connection.d.ts +5 -0
  327. package/dist/store/sqlite/connection.js +88 -47
  328. package/dist/store/sqlite/run-patch.d.ts +25 -7
  329. package/dist/store/sqlite/run-patch.js +58 -14
  330. package/dist/store/sqlite/store.js +331 -59
  331. package/dist/store/store.d.ts +330 -21
  332. package/dist/store/store.js +34 -2
  333. package/dist/store-reads/analytics.js +3 -2
  334. package/dist/store-reads/cap.d.ts +2 -4
  335. package/dist/store-reads/cap.js +16 -7
  336. package/dist/store-reads/decisions.d.ts +3 -3
  337. package/dist/store-reads/decisions.js +3 -6
  338. package/dist/store-reads/import-summary.d.ts +1 -1
  339. package/dist/store-reads/journal.d.ts +5 -4
  340. package/dist/store-reads/journal.js +118 -27
  341. package/dist/store-reads/learning.d.ts +34 -4
  342. package/dist/store-reads/learning.js +137 -23
  343. package/dist/store-reads/runs.d.ts +7 -5
  344. package/dist/store-reads/runs.js +17 -10
  345. package/dist/store-reads/stats.js +5 -1
  346. package/dist/store-reads/workflow.d.ts +1 -1
  347. package/dist/store-view.d.ts +5 -0
  348. package/dist/store-view.js +70 -29
  349. package/dist/template-eval.js +8 -5
  350. package/dist/template-github-permissions.d.ts +22 -8
  351. package/dist/template-github-permissions.js +35 -15
  352. package/dist/templates.d.ts +64 -0
  353. package/dist/templates.js +101 -16
  354. package/dist/timeline/timeline.d.ts +30 -1
  355. package/dist/timeline/timeline.js +29 -13
  356. package/dist/timeline/util.d.ts +4 -0
  357. package/dist/timeline/util.js +14 -0
  358. package/dist/tool-blurbs.js +1 -0
  359. package/dist/tool-budget.d.ts +27 -7
  360. package/dist/tool-budget.js +21 -9
  361. package/dist/tool-gate.d.ts +23 -10
  362. package/dist/tool-gate.js +60 -44
  363. package/dist/tool-plane.d.ts +46 -28
  364. package/dist/tool-plane.js +73 -31
  365. package/dist/tools.d.ts +31 -38
  366. package/dist/tools.js +117 -74
  367. package/dist/trigger-adapter.d.ts +4 -0
  368. package/dist/trigger-secrets-shown.d.ts +2 -2
  369. package/dist/trigger-secrets-shown.js +1 -1
  370. package/dist/trigger-signatures.d.ts +26 -6
  371. package/dist/trigger-signatures.js +44 -8
  372. package/dist/trigger-targets.d.ts +2 -0
  373. package/dist/trigger-targets.js +1 -0
  374. package/dist/trigger-webhook.js +5 -2
  375. package/dist/triggers.d.ts +10 -6
  376. package/dist/triggers.js +37 -7
  377. package/dist/turn-end.d.ts +0 -3
  378. package/dist/turn-end.js +0 -3
  379. package/dist/turns.js +16 -1
  380. package/dist/usage-lines.d.ts +1 -1
  381. package/dist/validate.d.ts +6 -0
  382. package/dist/validate.js +41 -4
  383. package/dist/web-fetch.d.ts +1 -1
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +147 -103
  387. package/dist/webhooks.js +564 -324
  388. package/dist/workflow/decision-recovery.d.ts +23 -0
  389. package/dist/workflow/decision-recovery.js +80 -0
  390. package/dist/workflow/decisions.d.ts +134 -0
  391. package/dist/workflow/decisions.js +46 -0
  392. package/dist/workflow/host-session.d.ts +5 -0
  393. package/dist/workflow/host-session.js +85 -0
  394. package/dist/workflow/host-tools.d.ts +3 -0
  395. package/dist/workflow/host-tools.js +3 -0
  396. package/dist/workflow/node-runner.d.ts +113 -0
  397. package/dist/workflow/node-runner.js +270 -0
  398. package/dist/workflow/node.d.ts +89 -0
  399. package/dist/workflow/node.js +101 -0
  400. package/dist/workflow/operator-error.d.ts +4 -0
  401. package/dist/workflow/operator-error.js +4 -0
  402. package/dist/workflow/pi-versions.d.ts +32 -0
  403. package/dist/workflow/pi-versions.js +65 -0
  404. package/dist/workflow/record-file.d.ts +10 -0
  405. package/dist/workflow/record-file.js +56 -0
  406. package/dist/workflow/record-tool.d.ts +77 -0
  407. package/dist/workflow/record-tool.js +126 -0
  408. package/dist/workflow/record.d.ts +151 -0
  409. package/dist/workflow/record.js +401 -0
  410. package/dist/workflow/run-error.d.ts +16 -0
  411. package/dist/workflow/run-error.js +26 -0
  412. package/dist/workflow/runner.d.ts +6 -0
  413. package/dist/workflow/runner.js +240 -0
  414. package/dist/workflow/store.d.ts +23 -0
  415. package/dist/workflow/store.js +242 -0
  416. package/dist/workflow/task.d.ts +133 -0
  417. package/dist/workflow/task.js +412 -0
  418. package/dist/workflow/thinking.d.ts +3 -0
  419. package/dist/workflow/thinking.js +7 -0
  420. package/dist/workflow/tool-context.d.ts +21 -0
  421. package/dist/workflow/tool-context.js +13 -0
  422. package/dist/workflow/types.d.ts +126 -0
  423. package/dist/workflow/types.js +1 -0
  424. package/dist/workflow-run.d.ts +2 -2
  425. package/dist/workspace/agent-computer.d.ts +137 -0
  426. package/dist/workspace/agent-computer.js +292 -0
  427. package/dist/workspace/archil-claim.d.ts +11 -0
  428. package/dist/workspace/archil-claim.js +18 -10
  429. package/dist/workspace/archil-disks.d.ts +49 -0
  430. package/dist/workspace/archil-disks.js +185 -0
  431. package/dist/workspace/archil-exec.js +2 -3
  432. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  433. package/dist/workspace/archil-mount-credential.js +13 -4
  434. package/dist/workspace/attached-computers.d.ts +41 -0
  435. package/dist/workspace/attached-computers.js +114 -0
  436. package/dist/workspace/computer-deps.d.ts +32 -17
  437. package/dist/workspace/computer-deps.js +37 -14
  438. package/dist/workspace/computer-for-claim.d.ts +58 -13
  439. package/dist/workspace/computer-for-claim.js +267 -26
  440. package/dist/workspace/computer-hold.d.ts +11 -27
  441. package/dist/workspace/computer-hold.js +36 -56
  442. package/dist/workspace/computer-janitor.d.ts +3 -2
  443. package/dist/workspace/computer-janitor.js +43 -9
  444. package/dist/workspace/computer-ledger.d.ts +5 -1
  445. package/dist/workspace/computer-ledger.js +11 -0
  446. package/dist/workspace/computer-mcp.d.ts +25 -0
  447. package/dist/workspace/computer-mcp.js +41 -0
  448. package/dist/workspace/computer-ports.d.ts +4 -13
  449. package/dist/workspace/computer-ports.js +4 -107
  450. package/dist/workspace/computer-script.d.ts +37 -0
  451. package/dist/workspace/computer-script.js +138 -0
  452. package/dist/workspace/executors.d.ts +1 -1
  453. package/dist/workspace/index.d.ts +7 -4
  454. package/dist/workspace/index.js +4 -1
  455. package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
  456. package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
  457. package/dist/workspace/resolve-computer.d.ts +45 -11
  458. package/dist/workspace/resolve-computer.js +72 -14
  459. package/dist/workspace/run-disk.d.ts +34 -0
  460. package/dist/workspace/run-disk.js +91 -0
  461. package/dist/workspace/run-tools.d.ts +35 -18
  462. package/dist/workspace/run-tools.js +24 -29
  463. package/dist/workspace/server-run-workspace.d.ts +3 -2
  464. package/dist/workspace/server-run-workspace.js +17 -4
  465. package/dist/workspace.js +1 -1
  466. package/package.json +19 -21
  467. package/templates/README.md +9 -6
  468. package/templates/code-review/agent.md +27 -11
  469. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  470. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  471. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  472. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  473. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  474. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  475. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  476. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  477. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  478. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  479. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  480. package/templates/code-review/evals/re-review/prompt.md +1 -1
  481. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  482. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  483. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  484. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  485. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  486. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  487. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  488. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  489. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  490. package/templates/code-review/findings.schema.json +131 -27
  491. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  492. package/templates/code-review/skills/review/DEEP.md +130 -0
  493. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  494. package/templates/code-review/skills/review/SKILL.md +104 -154
  495. package/templates/market-monitor/agent.md +1 -1
  496. package/dist/box/record.d.ts +0 -6
  497. package/dist/box/record.js +0 -41
  498. package/dist/box/sweep.d.ts +0 -53
  499. package/dist/box/sweep.js +0 -193
  500. package/dist/box-egress-vm.d.ts +0 -118
  501. package/dist/box-egress-vm.js +0 -354
  502. package/dist/box-egress.d.ts +0 -105
  503. package/dist/box-egress.js +0 -256
  504. package/dist/box-relay-vm.d.ts +0 -84
  505. package/dist/box-relay-vm.js +0 -437
  506. package/dist/box-relay.d.ts +0 -36
  507. package/dist/box-relay.js +0 -207
  508. package/dist/boxes.d.ts +0 -109
  509. package/dist/boxes.js +0 -249
  510. package/dist/budget.d.ts +0 -71
  511. package/dist/budget.js +0 -199
  512. package/dist/console/assets/index-B7NKTU8E.css +0 -1
  513. package/dist/console/assets/index-CXZMgJE7.js +0 -550
  514. package/dist/daytona-api.d.ts +0 -10
  515. package/dist/daytona-api.js +0 -20
  516. package/dist/egress-proxy.d.ts +0 -45
  517. package/dist/egress-proxy.js +0 -416
  518. package/dist/egress-table.d.ts +0 -24
  519. package/dist/egress-table.js +0 -165
  520. package/dist/run-db.d.ts +0 -53
  521. package/dist/run-db.js +0 -116
  522. package/templates/code-review/rules/REVIEW.md +0 -41
package/README.md CHANGED
@@ -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
 
@@ -69,14 +67,13 @@ An edit is a new revision: `PUT $AGENTRUN_BASE_URL/agents/calc/definition` with
69
67
  | `--documents DIR` | `AGENTRUN_SERVE_DOCUMENTS` | A read-only directory of documents a workflow's `pdf_pages` calls read by file name, confined to it. |
70
68
  | `--allow-code-nodes` | off (`AGENTRUN_SERVE_CODE_NODES=1` turns it on) | Run workflows' `code` nodes. They run in the run's process through the DSL's `new Function` transform, which is no sandbox, so only turn it on for workflows you wrote. Off, a workflow with a code node saves with a `not_set_up_here` warning and its runs are `409 agent_not_runnable` with `details.code: true`. A call `via: "shell"` or `"executor"` is refused either way. |
71
69
  | `--learning on\|off` | on (`AGENTRUN_SERVE_LEARNING`) | Whether runs [learn](#learning). On, a run of an agent whose definition says `learning: true` starts from what that agent learned and adds to it; off, no run does, whatever its agent says. Any other value refuses the start. Capabilities report it as `features.learning`. |
72
- | `--learning-budget BYTES` | `8000` (`AGENTRUN_SERVE_LEARNING_BUDGET`) | How much of what an agent learned its runs' instructions hold under `# Learned`, in UTF-8 bytes: every note whole while they fit, else the index and the notes changed last, whole, while they fit ([learning](#learning)). `0` gives the index alone. A value that is not a whole number of bytes refuses the start. |
70
+ | `--learning-budget BYTES` | `8000` (`AGENTRUN_SERVE_LEARNING_BUDGET`) | How much of what an agent learned its runs' instructions hold under `# Learned`, in UTF-8 bytes: every note whole while they fit, else the notes that bear most on the run whole while they fit, then one line each for more of them; the rest are left out, and the run's log names them ([learning](#learning)). `0` gives no notes. A value that is not a whole number of bytes refuses the start. |
73
71
  | `--drain-timeout D` | `30s` (the image: `6s`) | How long the runner beside the server lets each busy run finish its turn when the server stops (`8s`, `500ms`, `1m`): a turn that ends within it keeps its outcome, and its model request is never sent again. A run still busy at the bound is stopped where it can resume, and the next claim carries on from its journal (that turn's model request sent again). The stop says how long it waits and for how many runs. A runner of its own (`agentrun-serve runner`) takes `--drain-timeout` too, default `AGENTRUN_DRAIN_TIMEOUT`, else `6s`. |
74
72
 
75
73
  `AGENTRUN_TOKEN`, when set, is the token (32 characters or more), and the server prints `$AGENTRUN_TOKEN` in its
76
74
  place: a token from the environment stays out of the logs. `DIR/.token`'s token is printed only by the start that made
77
75
  it; a later start prints `AGENTRUN_API_KEY=<in DIR/.token>`, to read it there. With `AGENTRUN_ACCOUNTS=0` the `Open`
78
- link carries the token (`?token=<in DIR/.token>` on a later start); it encodes the token, and the server also takes one
79
- whose `+` arrived as a space. `AGENTRUN_PUBLIC_URL`, when set, is the
76
+ link carries a launch code this start made at random (`?launch=<code>`), never the token. `AGENTRUN_PUBLIC_URL`, when set, is the
80
77
  address people open (a container's published port, or a proxy's URL): the printed `Open` link and `AGENTRUN_BASE_URL`
81
78
  use it.
82
79
 
@@ -93,11 +90,9 @@ node packages/serve/dist/cli.js
93
90
  Its log says `event=boxes available=docker`, and its banner's last line `Boxes: docker (on by default; set
94
91
  AGENTRUN_BOXES to change). docker boxes reach only pypi.org, files.pythonhosted.org, registry.npmjs.org, registry.yarnpkg.com,
95
92
  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
93
+ network: [Sandbox](#sandbox)). The first sandbox run builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
94
+ 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
95
+ it built. In a second shell, export the two `AGENTRUN_` lines it printed (a later start prints
101
96
  where the key is: `export AGENTRUN_API_KEY=$(cat ~/.local/share/agentrun/agents/.token)`). Then make a sandbox agent,
102
97
  run it, watch it, and read the file it wrote:
103
98
 
@@ -140,11 +135,9 @@ at=2026-10-25T21:04:09.010Z event=auth_failed route=/v2/runs reason=wrong_token
140
135
  ```
141
136
 
142
137
  A request's path has no query. `auth_failed` names the route and why (`no_credential`, `wrong_token`,
143
- `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
138
+ `wrong_launch_code`, `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
139
  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.
140
+ One line at start, `event=boxes`, says which boxes this server has ([Boxes](#boxes)); quiet keeps it too.
148
141
  `event=harness_offers why=start ms=<n>` says how long the server took to check what each harness offers (each CLI's
149
142
  package and pins; [harnesses](#harnesses)), the bulk of its start; quiet keeps it too. It is made at the start only: a
150
143
  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 +173,13 @@ docker compose logs agentrun | grep Open
180
173
  The `.env` beside `compose.yaml` keeps the socket's group (`DOCKER_GID`) for every later `docker compose` command, in any
181
174
  shell: compose reads it each time, and `compose.yaml` needs it to be read at all.
182
175
 
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.
176
+ This `compose.yaml` passes `AGENTRUN_SEAL_KEY` from the `.env` to the server and refuses to start without it, so the key that
177
+ seals every saved key, MCP credential and sign-in is kept outside the container and the data volume. Keep that `.env`
178
+ line. A store whose secrets were sealed with another key refuses to start, and the server never makes a new key over
179
+ sealed secrets, so a lost key is not replaced: recreating the container with the same key opens the store as before.
186
180
 
187
181
  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
182
+ `packages/serve/docker/Dockerfile` builds that image: the server and the open packages it runs, on Node 24.22.3 and Debian 13
189
183
  (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
184
  the runs and the token.
191
185
 
@@ -289,15 +283,16 @@ when it does and 1 when it does not, and 2 when no name is given. Name a runner
289
283
 
290
284
  ## Sandbox
291
285
 
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
286
+ 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
287
+ with no setup: a Docker container made for each run, which binds the run's `work/` and nothing else. A Daytona or Modal box
288
+ runs on a computer from that provider, offered once `AGENTRUN_BOXES` lists it and the keys its computer provider needs are
289
+ set (the environment, or Settings → Computers). No box holds a key. A Docker box on Linux reaches the package registries
290
+ 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
291
+ 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
292
  holds directory handles (Docker on Linux), else in the box. The agent's loop, its log, its model calls and every key stay
297
293
  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
294
+ box](#a-run-in-a-docker-box) is what the container gets; [the box's image](#the-boxs-image) is what it starts from.
295
+ [Sandbox in 60 seconds](#sandbox-in-60-seconds) is all of it
301
296
  end to end. The [published image](#in-the-published-image) hosts Docker boxes through the host's Docker socket.
302
297
 
303
298
  ### Place
@@ -313,8 +308,7 @@ remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox"
313
308
  place keeps it, `runner` included. An edit that names no place keeps the agent's.
314
309
 
315
310
  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
311
+ (`{"mode": "sandbox", "box": "docker"}`) wherever this server has docker. The place is written on the agent's first revision, so its answers
318
312
  show it. If that definition names no `tools` either, it gets `["bash", "bash_background", "bash_output", "bash_input",
319
313
  "bash_signal", "bash_list"]`, so the agent has a shell and can run a command in the background
320
314
  ([background processes](#background-processes)). A definition that
@@ -344,8 +338,8 @@ or none (`422` on a sandbox, with the runner place as its `fix`). In `capabiliti
344
338
  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
339
  the server is in Mode 1.
346
340
 
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`.
341
+ `GET /v2/capabilities` lists `places`: the modes, the default, a new agent's place, and each box with `available`, its `state` (`ready` or
342
+ `unavailable`) and, when it is unavailable, the `reason`.
349
343
  A definition naming a box this server does not have saves with a warning on `definition.place`, and a run of it is
350
344
  `409 agent_not_runnable` with `details.box`. `GET /v2/openapi.json` marks `definition.place`, the run's `place` and
351
345
  `capabilities.places` `x-agentrun-serve: "place/1"`, `default_reason` `"place/3"`, and `default_place` `"place/4"`
@@ -409,7 +403,7 @@ go through `work/` by path.
409
403
  connect, over a minute old); a live run's, of any server of this user's, stays.
410
404
  - 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
405
  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
406
+ 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
407
  `<data>/egress/`, the list as its one variable, a read-only root, no capability, the server's uid:gid, 256 MiB and
414
408
  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
409
  box mounts that volume read-only at `/run/agentrun/egress/`. The box keeps `--network none`, its `socat` and its
@@ -547,111 +541,21 @@ where `bash`'s setting came from:
547
541
  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
542
  `background_ended` with how many. A follow-up's box starts with none running, and its ids go on from the last.
549
543
 
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
544
  ### The box's image
635
545
 
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.
546
+ A Docker box's computer starts from the computer package's own image by default: python 3.12 (`python:3.12-slim`,
547
+ pinned by its digest) with git, curl, node and npm, rg and `socat` (the relay to the computer's egress proxy), about
548
+ 360 MB. Its recipe is `DOCKER_RECIPE` in `packages/computer/src/docker/image.ts`. The Docker provider builds it on the
549
+ first run that needs it, tags it with the recipe's hash (`agentrun-computer:<12 hex>`) and labels it with the whole hash
550
+ (`agentrun.computer.recipe`), and builds again only when the recipe changes; the run waiting on the build shows it on its
551
+ timeline. Nothing is built or pulled at the server's start. Images of older recipes stay until you remove them:
552
+ `docker image ls --filter label=agentrun.computer.recipe` lists them. An `agentrun-box:*` image an earlier server built
553
+ is used by nothing: `docker image rm` it.
554
+
555
+ A box reaches its package registries, so `pip install` and `npm install` work in it, but not `apt-get`: the box runs as
556
+ this server's user, with no root. For other tools, name another image in `AGENTRUN_DOCKER_IMAGE`: the provider then pulls
557
+ it on the first run that needs it, and builds nothing. This image is the Docker box's alone: a box on another provider
558
+ starts from that provider's own.
655
559
 
656
560
  ```sh
657
561
  AGENTRUN_DOCKER_IMAGE=python:3.12-bookworm AGENTRUN_BOXES=docker node packages/serve/dist/cli.js
@@ -715,10 +619,22 @@ Settings → Computers. The kind says what the agent is given, and the provider
715
619
  |---|---|---|
716
620
  | `none` | The run's folder alone: no computer, and no provider (`{"kind": "none"}`) | |
717
621
  | `sandbox` | A Linux shell, with files and processes | `docker`, `daytona`, `modal`, `e2b` |
718
- | `desktop` | A screen, a pointer and keys (`desktop_screen`, `desktop_input`), and a shell where its provider mounts the run's folder | `docker` (with an image that has an X server), `e2b`, `orgo` |
719
- | `phone` | A rented Android: its screen, touch and apps (the `phone_*` tools) | `phone-harness` |
622
+ | `desktop` | The computer's tools (`computer_observe`, `computer_act`, `computer_screenshot`, `computer_script`), and a shell where its provider mounts the run's folder | `docker` (with an image that has an X server), `e2b`, `orgo`, or [a paired computer](#a-persons-own-computer) by its id |
623
+ | `phone` | A rented Android, through the same computer tools | `phone-harness` |
720
624
  | `browser` | A hosted browser (the browser tools) | `browserbase`, `kernel` |
721
625
 
626
+ A desktop's and a phone's tools are one set over the computer's groups. With the `ui` group, `computer_observe` returns
627
+ the app window's elements as compact lines (`@e12 button "Save"`), and `computer_act` runs steps on them by ref (press,
628
+ set, click, type, key, scroll, drag, nav), each step saying its route and whether a readback verified it, and the answer
629
+ ending with the window's new state. Without it, observe is a screenshot and act's steps are raw input at its pixels.
630
+ `computer_script` runs JavaScript in an isolate in this server, with a typed `computer` object as its only binding (no
631
+ network, no keys): a known sequence of steps is one script, and it returns only what the next decision needs. Its
632
+ declarations are `spec/computer/computer.d.ts`, generated from `packages/computer/src/surface/api.ts`. On pi, a run
633
+ with a desktop or a phone also has pi's code mode (`codemode`), whose scripts call the run's tools and have the same
634
+ `computer` bound; the call is held to the kind's setting. In Codex's code mode, a script's call of a computer tool
635
+ answers the tool's value as JSON. `computerMcp` (`src/workspace/computer-mcp.ts`) serves the same tools to an MCP
636
+ client, each answer with its value as `structuredContent`.
637
+
722
638
  A kind with no provider, a provider that does not serve the kind, or a provider whose required keys are not saved is
723
639
  refused before anything starts, in words that name the fix in Settings → Computers. A Docker computer needs a Docker
724
640
  daemon on this server: where none answers `docker version` (Render and most hosted services run none), Docker is not
@@ -763,17 +679,138 @@ computer is made with the GPUs asked.
763
679
  - **Modal** declares its GPUs, but a Modal GPU sandbox runs on gVisor, and the Archil mount the run's folder needs is not
764
680
  proven there. So this server refuses a Modal sandbox with a `gpu` for now. A Modal GPU is also preemptible.
765
681
 
682
+ **An agent's own computer.** `computer: {"kind": "desktop", "provider": "orgo", "persistent": true}` gives the agent
683
+ one computer that it keeps between runs, instead of a fresh one for each run:
684
+
685
+ - Its first run makes it. Each run's end detaches it rather than deleting it (an Orgo Linux desktop is suspended, with
686
+ its memory and disk). The agent's next run attaches it again, with what was on it.
687
+ - The run's timeline says which happened. If the computer was deleted outside this server, the next run makes a new
688
+ one and says so.
689
+ - One run at a time. A run that finds the computer held by another run that is still going is refused at its start,
690
+ naming that run.
691
+ - Only where the provider keeps one for the kind and image (`GET /v2/computers`: the provider's `persistent`); anything
692
+ else is 422. A computer that mounts the run's folder can't be kept, so a persistent computer never mounts it.
693
+ - `GET /v2/agents/{agent_id}` shows it as `own_computer`: its provider, id and name, and whether a run holds it, it is
694
+ detached, or it is being deleted.
695
+ - Archiving the agent, turning `persistent` off, or moving the setting to another provider or image deletes it.
696
+ - The computer is owned by this server's id (kept in its store) and the agent's id, so two servers on one vendor
697
+ account never take each other's. The janitor deletes an agent's computer only once its agent no longer wants it.
698
+
699
+ #### A person's own computer
700
+
701
+ A computer of your own (a laptop, a desktop, a phone) can be an agent's computer. A driver on it dials this server and
702
+ holds the connection open, so the computer needs no open port and this server needs no address of its
703
+ ([spec/computer/attach.md](../../spec/computer/attach.md)). This server knows no OS: a paired computer is what its
704
+ driver's hello says it is (its kind, os, device, screen, capability groups and features), and a driver on any OS that
705
+ passes the binding's conformance cases (below) needs no change here.
706
+
707
+ - **Pair it.** Settings → Computers → Pair a computer shows a code, such as `K7PD-W3QX` (`POST /v2/computers/pairings`),
708
+ and this server's address. The code pairs one computer, once, within 10 minutes. Type both into the driver: it trades
709
+ the code for its own token (`POST /v2/computers/pair`, which takes no token of this server's) and keeps that token in
710
+ the OS's keychain. This server keeps only the token's SHA-256. A wrong, used or expired code is a 404, and each source
711
+ address gets 10 tries a minute.
712
+ - **It attaches.** The driver dials `GET /v2/computers/attach`, a WebSocket with its token and the subprotocol
713
+ `agentrun.computer.0.2`, and dials again when the connection drops. `GET /v2/computers` lists it under `paired` as its
714
+ hello says, online or offline, with the run that holds it and the time that hold ends by, and as a provider, named by
715
+ its name and os, of each kind its hello serves (`desktop`, `phone`), ready while it is online.
716
+ - **An agent uses it.** `computer: {"kind": "desktop", "provider": "cmp-8f2k3jq7m4xw9tnb"}` names it by its id. A run
717
+ claims it at its start (one run at a time: another is refused while one holds it) and releases it at its end, or at
718
+ its lifetime, released or not; it is never made, stopped or deleted. A run of an agent whose computer is offline is
719
+ refused at its start, saying to open its driver. A run uses what the hello's groups and features allow.
720
+ - **Remove it.** Remove on its row (`DELETE /v2/computers/{computer_id}`) ends its token and closes its connection; a
721
+ run holding it loses it. Pairing it again gives it a new id.
722
+ - **One process.** A computer's connection lands on one server process, and only a run in that process can use it:
723
+ run `agentrun-serve start` with its runner beside the server (the default). A runner started apart
724
+ (`agentrun-serve runner`, beside a server started with `--no-runner`) refuses a paired computer at the claim, saying
725
+ so. A second server on one store is already refused by the store's owner lock, on SQLite and Postgres alike.
726
+ - **Conformance.** `node dist/attach-conformance-cli.js [--port 7392] [--listen 127.0.0.1]` runs the binding's cases
727
+ against whatever driver pairs with the code it prints: pair, a wrong or used code, ping, a quiet minute, a redial
728
+ after each close it must redial after (4408, 1000, 1001, 4409) and after a drop, a binary frame (1003), a frame over
729
+ 1 MiB (1009), a second socket with the same token (4409 to the older), and revoke (4401, no redial). It runs a store
730
+ of its own in a scratch directory, prints PASS or FAIL for each case, and exits 0 when all pass; it takes about five
731
+ minutes. The revoke case leaves the driver unpaired. Serve's tests run the same cases against a test driver.
732
+
766
733
  **Where the run's folder lives.** A server keeps its runs' folders in one of two modes:
767
734
 
768
735
  - **Mode 1** (the default): on this server's own disk. Only a provider that binds a folder of this machine can hold
769
- it, so a sandbox runs on Docker only; a Daytona, Modal or E2B sandbox is refused ("Mode 1 runs a sandbox only on
736
+ it, so a sandbox runs on Docker only; a Daytona, Modal, E2B or Agent37 sandbox is refused ("Mode 1 runs a sandbox only on
770
737
  Docker").
771
- - **Mode 2**: on your own Archil disk. `PUT /v2/workspace/archil` turns it on with the disk's id, its region, its S3 URL
772
- (and an exec image pinned by digest, if you want one other than serve's default), and the account key,
773
- `ARCHIL_API_KEY`; `DELETE` turns it off. The default exec image is Docker's `buildpack-deps:trixie-scm` pinned by
774
- digest (git 2.47), because Archil's own has git 2.34 and a read-only bash policy runs git only at 2.43 or later. An
775
- image you name needs git 2.43 for that too, and GNU coreutils and perl, as Debian-family images have. A Daytona, Modal or E2B sandbox mounts the run's folder from the disk with a
776
- mount credential minted for that run alone; Docker's sandbox is refused, since it cannot mount the disk.
738
+ - **Mode 2**: on Archil disks. `PUT /v2/workspace/archil` turns it on with the account key, `ARCHIL_API_KEY`, its
739
+ region and that region's S3 URL (and an exec image pinned by digest, if you want one other than serve's default);
740
+ `DELETE` turns it off. The default exec image is Docker's `buildpack-deps:trixie-scm` pinned by digest (git 2.47),
741
+ 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
742
+ git 2.43 for that too, and GNU coreutils and perl, as Debian-family images have. A Daytona, Modal, E2B or Agent37 sandbox mounts
743
+ the run's folder from its disk with a mount credential minted for that run alone; Docker's sandbox is refused, since
744
+ it cannot mount the disk.
745
+
746
+ 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
747
+ `AGENTRUN_ACCOUNTS=0` reached beyond loopback) is set where it is started instead: `AGENTRUN_ARCHIL_REGION` and
748
+ `AGENTRUN_ARCHIL_S3_URL` together, and `AGENTRUN_ARCHIL_IMAGE` for a pinned exec image, with the account key in
749
+ `ARCHIL_API_KEY`. Each agent's disk is then made on its first run, as with saved settings:
750
+
751
+ ```sh
752
+ AGENTRUN_ARCHIL_REGION=aws-us-east-1 AGENTRUN_ARCHIL_S3_URL=https://s3.example.com \
753
+ ARCHIL_API_KEY=... node packages/serve/dist/cli.js
754
+ ```
755
+
756
+ 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,
757
+ stops the start, in words naming each variable. Set, they win over saved settings, as `ARCHIL_API_KEY` wins over a
758
+ saved key, and nothing is written to the store: `GET /v2/workspace/archil` says `source: "env"` (saved ones say
759
+ `"console"`), and `PUT` and `DELETE` are `409 key_set_by_server`, since they are changed where the server is started.
760
+ Unset, the saved settings, if any, hold again. A runner started on its own (`agentrun-serve runner`) reads them from its
761
+ own environment, as it reads `ARCHIL_API_KEY`, so give it the same values.
762
+
763
+ **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
764
+ it, never when the agent is made, in the account key's region, named `agentrun-<server id>-i-<agent id>` (an id with
765
+ characters Archil doesn't take, or past 46 of them, is `h-` with its first 21 safe characters and 24 hex digits of its
766
+ SHA-256, so no agent's disk name is another's); making it is
767
+ idempotent by that name, and `GET /v2/agents/{agent_id}/archil` says which disk it is. A run's mount credential is minted
768
+ 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
769
+ files. This is the default, and it is enough for one owner: this server has no roles, and everything on it is its
770
+ owner's.
771
+
772
+ - **Isolating tenants.** A run's start may name another disk: `"archil_disk": {"disk_id": "dsk-…"}` on
773
+ `POST /v2/agents/{agent_id}/runs` or `POST /v2/runs` (an agent given inline). The run then keeps its folder there, and
774
+ its token is minted there, so a system that runs one agent for many customers (one expert, say) names a disk per
775
+ customer. That disk is the caller's: agentrun never makes, renames or removes it. It takes the id Archil returned when
776
+ the disk was made (`dsk-…`; Archil's API addresses disks by id, not owner/name), never a key or a region. The server
777
+ 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,
778
+ 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
779
+ launch keeps the disk it used, and whether it was the launch's or the agent's, so every claim, revoke and reclaim of
780
+ that run acts on that one disk, after a restart too. Any disk in the key's region may be named, by design: this
781
+ server has one owner, and a backend that launches runs for its customers is a trusted caller. Isolation comes from a
782
+ disk per boundary.
783
+ - **The plan's disk limit.** Archil's free plan allows 5 disks per region. When Archil refuses to make an agent's disk
784
+ for its plan's limit, the run fails in words ("your Archil plan allows 5 disks; upgrade or delete an agent"); no run
785
+ falls back to a shared disk.
786
+ - **Removing an agent's disk.** This server archives agents and never deletes one, and an archive keeps everything,
787
+ its disk included. `DELETE /v2/agents/{agent_id}/archil` deletes the agent's own disk at Archil (its runs' folders,
788
+ 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
789
+ another agent may name it in `archil_disk`). The agent must be archived, unless its source manages it: an inline
790
+ run's agent is never archived here, and its caller decides when it is done. The disk is marked as being removed
791
+ before the live runs are counted: from then a new run of the agent on it is `409 agent_not_runnable`, and a run
792
+ launched just before is refused at its claim, so no run starts on a disk being deleted. A refusal leaves the disk the
793
+ agent's. It never touches a disk a run's launch named.
794
+ - **Before you upgrade.** In Archil mode, an agent's files from before this release stay on the old server disk at
795
+ Archil; the agent starts on a new disk of its own. `diskId` is no longer a setting: there is no server-wide disk, and
796
+ no agent falls back to one.
797
+ - **Later, narrower tokens.** Archil's tokens reach a whole disk; nothing narrower exists today. If Archil ships
798
+ path-scoped tokens, a run's token narrows from its disk to its own folder with no other change.
799
+
800
+ **A Daytona computer's snapshot.** The mount runs as root through the image's root helper and its pinned archil client,
801
+ so a Daytona computer that mounts the run's folder must start from a snapshot of the computer package's
802
+ `box/Dockerfile`; Daytona's default snapshot, whose user is not root, is refused before anything mounts. Build one in
803
+ the organization of `DAYTONA_API_KEY` with Daytona's Python SDK (`pip install daytona`), which prints its name, a hash
804
+ of the recipe:
805
+
806
+ ```sh
807
+ DAYTONA_API_KEY=... python3 packages/computer/box/build-daytona.py # prints snapshot=agentrun-archil-<12 hex>
808
+ ```
809
+
810
+ and name it in the server's environment, `AGENTRUN_DAYTONA_SNAPSHOT=agentrun-archil-<12 hex>` (the id or name of any
811
+ Daytona snapshot), as `AGENTRUN_DOCKER_IMAGE` names Docker's image. Every Daytona computer is then made from it. Unset,
812
+ it is Daytona's default snapshot, as before. A changed recipe is a new name, so build again after an upgrade that
813
+ changes `box/`. The [Daytona box](#a-run-in-a-daytona-box) never reads it.
777
814
 
778
815
  A desktop, a phone and a browser run in either mode. The run's folder is at `/workspace` in every computer that mounts
779
816
  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
@@ -807,14 +844,14 @@ no computer.
807
844
  registries and GitHub) through its egress proxy, and nothing else; `AGENTRUN_BOX_ALLOW=none` gives it no network. From a
808
845
  server in a container the proxy also refuses the Docker host's own addresses, which the server reads through the socket
809
846
  ([in the published image](#in-the-published-image)). A
810
- Daytona, Modal or E2B sandbox has no network of its own (loopback only). A phone and a hosted browser are on their
847
+ Daytona, Modal, E2B or Agent37 sandbox has no network of its own (loopback only). A phone and a hosted browser are on their
811
848
  vendor's own network, whatever the list says. Local Chrome is open unless this server sets `AGENTRUN_BOX_ALLOW`; then
812
849
  only those hosts (the default list, a sandbox's package registries, is no browsing policy). Under
813
850
  `AGENTRUN_BOX_ALLOW=none`, each of these is refused at the run's start, in words that name the setting.
814
851
 
815
852
  **Docker.** A Docker computer runs where this server's Docker answers. With `AGENTRUN_BOXES` not set at all (a plain
816
853
  `npx @parcha/agentrun`), the server probes `docker` at its start (within 5 s) and offers it when Docker answers
817
- (`ready`, or `preparing` while its image is built or pulled, as [the box's image](#the-boxs-image) says); `AGENTRUN_BOXES`,
854
+ (`ready`); `AGENTRUN_BOXES`,
818
855
  when set, lists what it probes, and `AGENTRUN_BOXES=none` probes nothing. One log line says what it found:
819
856
 
820
857
  event=boxes available=<ids or none> unavailable=<ids> <id>="<why>" ...
@@ -856,7 +893,7 @@ model with no price set that the catalog does not list in any form; null while `
856
893
  in USD per million tokens, so a run's cost estimate has a price; `AGENT_MODEL_FAST_PRICE` and `AGENT_MODEL_STRONG_PRICE`
857
894
  price their tier's model, and default to it. With no price set, a model id pi-ai's catalog knows (`gpt-6-luna`, say)
858
895
  takes the catalog's list price; one it lists only with its version's separators written the other way (a gateway's
859
- `gpt-5-4-mini` for the catalog's `gpt-5.4-mini`, `claude-haiku-4.5` for `claude-haiku-4-5`) takes that entry's price,
896
+ `gpt-6-1-terra` for the catalog's `gpt-6.1-terra`, `claude-haiku-5.5` for `claude-haiku-5-5`) takes that entry's price,
860
897
  only when every entry of that form lists one price (else none), and the id sent to the gateway stays as named; any
861
898
  other has no price: its answers' cost is unknown, so the run's `cost.usd` is
862
899
  `null`, never $0. A model the catalog lists at $0, or one `AGENT_MODEL_PRICE=0,0` prices, is a known $0. A revision's `provider/model-id` takes that provider's
@@ -933,6 +970,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
933
970
  | `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 |
934
971
  | `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 |
935
972
  | `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 |
973
+ | `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 |
936
974
 
937
975
  `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
938
976
  sandbox place `read`, `write` and `edit` run in the box too.
@@ -975,6 +1013,54 @@ to read it, which a run's confinement refuses, Codex keeps only the ends of a re
975
1013
  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
976
1014
  `web_search` answer past 100,000 characters leaves out its least relevant results, `omitted` counting them.
977
1015
 
1016
+ ### Subagents
1017
+
1018
+ `subagent` is one primitive: a prompt, a fresh context and a subset of the agent's own tools, on the agent's own model
1019
+ unless the call names a tier. A child keeps the run's gate, so the agent's permissions and bash policy (`read-only`)
1020
+ 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
1021
+ given `subagent` or `ask_person`), and at most 4 children of a run work at once; more wait. The run's timeline nests each
1022
+ child under its call, and the run's cost counts every child's requests. How to split work and merge answers is the
1023
+ agent's own instructions, never the engine's.
1024
+
1025
+ A call may set its child's `max_tool_calls` and `effort`. `max_tool_calls` narrows the agent's own budget (its definition's
1026
+ `max_tool_calls`, which holds each conversation) for that child and never widens it; with no budget of the agent's, the
1027
+ call's holds. `effort` (`low`, `medium` or `high`) is the child's thinking level; absent, the child thinks as the agent
1028
+ does. So one template can run wide reviewers at `medium` with 30 calls and deep ones at `high` with 90.
1029
+
1030
+ A child is a conversation in the run's own journal, owned by its call, so it lives and ends with the run:
1031
+
1032
+ - **A restart or a moved claim** resumes it. The next claim finds the same child, which answers its call once. A request
1033
+ 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
1034
+ meantime (the server's `AGENT_MODEL_STRONG`, say) resumes on the tier's model now.
1035
+ - **A cancel** stops every child with the run: their requests are aborted, and nothing more is asked.
1036
+ - **The cap.** When the run's cap refuses a child's request, the child stops and its call fails in the cap's words
1037
+ (`subagent: it stopped before it answered: ... spend_cap_reached`). The run's next request is refused the same way, so
1038
+ the run parks at its cap (`input_required`, a `budget` pending) and sends nothing more. A raise resumes the run, not
1039
+ the child: the agent reads the failed call on its next turn and may call `subagent` again, which starts a fresh child.
1040
+ On a capped run, a call on a tier whose model has no known price is refused before any child starts.
1041
+
1042
+ #### Patterns
1043
+
1044
+ **Sample K, merge, verify.** One pass misses what a second finds, and states things neither would confirm. A template's
1045
+ skill can ask for K passes and check their union, with no engine support beyond the tool:
1046
+
1047
+ 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).
1048
+ Each starts from a fresh context, so the answers vary the way independent samples do.
1049
+ 2. Merge the K answers: dedupe the items that say the same thing about the same place, and keep how many children found
1050
+ each.
1051
+ 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
1052
+ confirm it says what the item claims. Drop what does not hold. Agreement between children orders the checks; it is
1053
+ never the check.
1054
+
1055
+ It fits any agent whose answer is a list:
1056
+
1057
+ - Research: children answer with `web_search` and `web_fetch`; the parent re-fetches each cited source before it writes.
1058
+ - QA: children run one test plan with `browser`; the parent reproduces each finding before it files it.
1059
+ - Extraction: children pull a document's fields with `read`; the parent reads the page again for any value they differ on.
1060
+ - Code review: children read a diff with read-only `bash`; the parent re-reads each finding's lines before it posts.
1061
+
1062
+ Each child books on the run's cap, so size the cap for K passes, not one.
1063
+
978
1064
  ### Search and fetch
979
1065
 
980
1066
  `web_search` and `web_fetch` work on every harness with only a model key. Each resolves, for a run, in one order: (1) the
@@ -1191,6 +1277,19 @@ and the ask expires, the agent told the cap's words. When the
1191
1277
  browser comes back, what was held up front goes, and the time the person had stays held, at the provider's price, until
1192
1278
  the session's next charge books it: take-overs given back with no browser call between them still meet the cap.
1193
1279
 
1280
+ **The run waits for you, its browser kept.** When the agent asks the person a question (`ask_person`) with its browser open,
1281
+ the run waits for the answer with that browser kept open for them: its page, the live view and Take over stay there. The
1282
+ 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
1283
+ window, `AGENTRUN_BROWSER_PERSON_WAIT_MIN` (whole minutes, 1 to 360; 15 by default), the same setting that bounds a
1284
+ take-over with no input and an agent's hand-over ask (above, 15 minutes each by default), so the three never drift apart.
1285
+ 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
1286
+ waits, its cost grows by the browser's session time only, never by model time, and with no room under the cap the run
1287
+ 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
1288
+ the browser is released ("The browser was released after 15 min waiting for you" on the timeline, and the Screen tab says
1289
+ so, with when, until a browser opens again), so its billing stops there. An answer after that goes on with a new
1290
+ browser, opened at the agent's next browser call. A browser its provider ends before the answer says so too ("The browser
1291
+ session ended while the run waited for you"). A provider's own session timeout still applies: keep the window under it.
1292
+
1194
1293
  **The agent asks.** The agent may ask the owner to do something in its browser (`browser_request_handoff`: an instruction
1195
1294
  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
1196
1295
  made, and the tool's result says why. The run then reads `input_required`/`waiting` with
@@ -1405,6 +1504,21 @@ Streamable HTTP with the official MCP SDK client (`@modelcontextprotocol/client`
1405
1504
  value}}` (up to 8). An `oauth` server is signed in to first ([below](#signing-in-with-oauth)), then previewed by name.
1406
1505
  `url` is `https`, or `http` on loopback.
1407
1506
 
1507
+ ### Composio
1508
+
1509
+ Composio is an MCP server like any other, so it needs no adapter of its own. Settings → MCP servers has a Composio
1510
+ preset: you give your Composio API key, a toolkit (`github`, `slack`...), the actions to grant (picked from the
1511
+ toolkit's list) and a server name, and the server has Composio make a managed MCP server for them, then saves it as an
1512
+ ordinary MCP server with the key sealed as an `x-api-key` header. `POST /v2/settings/mcp-servers/composio/tools`
1513
+ `{api_key, toolkit}` lists the actions; `PUT /v2/settings/mcp-servers/{name}/composio` `{api_key, toolkit, tools,
1514
+ user_id?}` makes and saves the server. When the toolkit needs your account and `user_id` (default `agentrun`) has none
1515
+ active, the answer's `connect_url` is Composio's page to connect it; nothing here signs in. Composio's server can leave
1516
+ out an action it was allowed (it did for `HACKERNEWS_GET_FRONTPAGE`), so the answer's `not_served` names any chosen
1517
+ action the saved server doesn't list. Both routes are the owner's
1518
+ session alone, and a saved Composio server is gated, approved and shown on the Timeline as any MCP server's tools are,
1519
+ "not metered" until you price them. Composio's own meta tools stay refused, and the helper actions that connect an
1520
+ account are left off the server's address.
1521
+
1408
1522
  What can go wrong, told apart:
1409
1523
 
1410
1524
  - `422 auth_required`: the server answered 401 or 403. `details.auth` is `oauth` when it names protected-resource
@@ -1436,6 +1550,35 @@ names a tool whose title, description, schemas or annotations differ. `DELETE ..
1436
1550
  credential. Capabilities' `features.mcp_client` says `transports: ["streamable-http"]`, the `auth` types and `at_rest:
1437
1551
  "sealed"`.
1438
1552
 
1553
+ ### A credential handed with each run
1554
+
1555
+ Some servers take a credential made for one run (a token scoped to that run's job and its person) that no saved
1556
+ server could hold. Save such a server with `auth: {type: "per_run", headers?}`: it keeps no credential, and `headers`,
1557
+ when sent, are used only to list its tools now. Then hand each run its own as `mcp_auth` on the run's start
1558
+ (`POST /v2/runs`, `POST /v2/agents/{agent_id}/runs`), one entry for each per_run server it calls:
1559
+
1560
+ ```sh
1561
+ curl -X PUT "$BASE/v2/settings/mcp-servers/gateway" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
1562
+ -d '{"url": "https://gateway.example.com/mcp", "auth": {"type": "per_run", "headers": {"authorization": "Bearer <a token to list with>"}}}'
1563
+ curl -X POST "$BASE/v2/agents/$AGENT/runs" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
1564
+ -d '{"input": {"content": "..."}, "mcp_auth": {"gateway": {"headers": {"authorization": "Bearer <this run'"'"'s token>"}}}}'
1565
+ ```
1566
+
1567
+ A per_run save keeps no secret, so the API token may make it, as it may preview a server with a credential: the
1568
+ credentials such a server receives are the ones each run's own caller hands it. The run's calls of that server carry
1569
+ those headers, and only to the origin the server had when the run was started. The
1570
+ credential is sealed into the run's launch record under `AGENTRUN_SEAL_KEY` (bound to the run's id), read at each claim, so
1571
+ 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
1572
+ saved body, its timeline, its view, a log line or an `Idempotency-Key`'s fingerprint (a retry with a new credential
1573
+ answers the first request's run), and its values are cut from whatever the run shows. `POST /v2/runs/{run_id}/messages`
1574
+ takes `mcp_auth` too: it replaces the run's credentials in the message's own write, so the turn the message starts (a
1575
+ steer into a working run from its next model request, or a follow-up that opens an ended run again) calls with them. A
1576
+ name that is not a saved per_run server is `422` at `mcp_auth.<server>`, and no run starts. A run handed no credential
1577
+ for a per_run server it calls has those calls answered, unsent, that it was handed none. `POST .../{name}/refresh` lists
1578
+ a per_run server's tools with no credential: save it again with `headers` for a server that lists only to a caller it
1579
+ knows. The tools are those it listed at its save, so a server whose tool list varies by caller shows each run the saved
1580
+ list.
1581
+
1439
1582
  ### Signing in with OAuth
1440
1583
 
1441
1584
  A server whose preview answers `details.auth: "oauth"` is signed in to by this server, which keeps the tokens: the
@@ -1460,7 +1603,12 @@ proxy on a public https address, set `AGENTRUN_PUBLIC_URL` to that address and h
1460
1603
  and `X-Forwarded-Proto: https`: without them a start reads as another address (or plain http) than the callback's,
1461
1604
  and every start answers `409 wrong_origin`. For an MCP server whose URL is not loopback, every endpoint its authorization server names (and
1462
1605
  every request to one) must be `https` and resolve to no private, loopback or link-local address, or the sign-in or
1463
- refresh is refused with words and nothing is sent. A loopback MCP server is a development-only exception: its
1606
+ refresh is refused with words and nothing is sent. A loopback MCP server (a `127.0.0.1` or `localhost` URL) is taken only
1607
+ by a server started with `AGENTRUN_MCP_ALLOW_LOOPBACK=1`, which says this is a local install: set it only on a machine you
1608
+ alone use, since loopback is this machine's other services too. Without it such a URL is refused at the save, the preview
1609
+ and the sign-in, in words naming the variable, and a runner never reaches one; only the runner beside such a server does.
1610
+ An MCP server's URL is shown on every read as its origin and `/…`: its path and query are held as a secret, sent only to
1611
+ the server itself, and sending the shown URL back for a saved server keeps the saved one. A loopback MCP server is a development-only exception: its
1464
1612
  authorization server may name endpoints on the MCP server's own loopback host, exactly as its URL writes it (never
1465
1613
  another loopback address, the IPv6 loopback, or a name for this machine in its place), on any port but this server's own; any other
1466
1614
  loopback endpoint is refused the same way. The host is pinned, not the port, as a local authorization server listens on
@@ -1587,23 +1735,25 @@ asked by default.
1587
1735
  ## Webhooks
1588
1736
 
1589
1737
  One URL hears of your runs without anyone watching the page. `PUT /v2/settings/webhook` with `{url}` sets it: an `http`
1590
- or `https` address, with no user or password in it. Loopback and private-network addresses are allowed, so a receiver
1591
- on your own machine or network works. Two kinds of message are POSTed to it about runs: `run.needs_input` when a run comes to
1738
+ or `https` address, with no user or password in it, on a public host: a loopback or private-network address is refused
1739
+ unless the operator allows it (`AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1`, below). Two kinds of message are POSTed to it about runs: `run.needs_input` when a run comes to
1592
1740
  need its person (`input_required`: a question, a call held for approval, a pause at its cap, an ask for its person in
1593
1741
  its browser, desktop or phone, or a stopped turn) and `run.ended` when it ends
1594
1742
  (completed, failed or cancelled, once the run's end is written). A [schedule](#schedules) whose firing fails sends a third,
1595
1743
  `trigger.failed`; a server with no triggers never sends one.
1596
1744
 
1597
- A run's end and its `run.ended` are one durable step. The server chooses the end's time once and gives it to the agent
1598
- store, so the row's `ended_at` and the message's `webhook-id` name one time. `run.ended` is queued only once the agent
1599
- store has the end, so a receiver that reads the run back on its message (`GET /v2/runs/{id}`) reads it ended; while the
1600
- store refuses the end (a full disk, a busy store), nothing is sent, until a later try of the write or the next server
1601
- stores it. The outbox, in the store with the runs, keeps, in the same write as each message, which end and which wait of
1602
- each run it queued. A server that starts queues any end of the last day that the agent store holds and the outbox does
1603
- not, under the same `webhook-id` (one lost to a kill, or to a crash of the machine), and a server that takes over a run
1604
- queues a wait it stands at that the outbox does not name (one the run came to while no server was up), under its one
1605
- `webhook-id`. An end before the webhook was set is never sent. A run is continued only once its end's
1606
- `run.ended` is in the outbox (`503` meanwhile), so a continued run's next end is its own, under its own id.
1745
+ The server follows the store's run-change feed: each run that reaches its end, or that its runner lets go waiting on a
1746
+ person, is told once, in order, whichever runner wrote it, so a receiver that reads the run back on its message
1747
+ (`GET /v2/runs/{id}`) reads it as the message says. The end's time is the store's, so the row's `ended_at` and the
1748
+ message's `webhook-id` name one time. A wait's `webhook-id` comes from its ask (a question's, an approval's call, a
1749
+ pause at the cap, a hand-over), so one ask sends one `run.needs_input`, however often the run is read and after its
1750
+ answer too. Everything the webhook keeps is in the store: its messages, their tries, and which
1751
+ end and which wait of each run it queued, written with each message in one transaction. While the store refuses that
1752
+ write (a full disk, a busy store), nothing is sent and the log says so (`condition=outbox_unwritable`); the server tells
1753
+ the notice again on its next read. A server that starts queues any end of the last day that the store holds and the
1754
+ webhook has not, under the same `webhook-id` (one lost to a kill, or to a crash of the machine), and any wait a run
1755
+ stands at that it has not told (one the run came to while no server was up), under its one `webhook-id`. An end before
1756
+ the webhook was set is never sent.
1607
1757
 
1608
1758
  ```json
1609
1759
  { "type": "run.needs_input", "timestamp": "2026-11-01T12:00:00.000Z",
@@ -1626,16 +1776,23 @@ with any of its libraries: `webhook-id` (the same on every try of a message, so
1626
1776
  the secret's bytes. A receiver checks the signature against the raw body and refuses a timestamp more than 5 minutes
1627
1777
  from its clock, so a replay does not pass. The first `PUT` makes the secret, `whsec_` and 32 random bytes in base64,
1628
1778
  and answers `201` with it, once; `GET /v2/settings/webhook` never shows it. It is kept like a [tool key](#tool-keys):
1629
- sealed under `AGENTRUN_SEAL_KEY`, in the store (SQLite or Postgres) with the webhook itself. A new secret is a `DELETE` and a
1630
- `PUT`; a secret that no longer opens under the server's key (sealed under another) is replaced, and shown once, by the next `PUT`.
1779
+ sealed under the server's seal key in the store, and a replaced or removed one is kept sealed too, so a run that echoes
1780
+ it is still cut. A `PUT` that changes the URL makes a new secret and shows it once, as the first does; one that keeps the
1781
+ URL keeps it. `GET` and the log show the URL's origin and its last four characters, never the whole URL (a chat
1782
+ service's incoming-hook URL is a credential itself). The URL is refused when it is on a private network or this machine,
1783
+ by address or by any address its name resolves to, and each try resolves the name again and dials the address it
1784
+ checked; an operator who sends to an internal receiver sets `AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1` where the server starts. A `DIR/webhook.json` an earlier build left is not read: the
1785
+ server says so at its start (`condition=webhook_left_over`), and a `PUT` sets the webhook again. A new secret for the
1786
+ same URL is a `DELETE` and a `PUT`; a secret that no longer opens under the server's key (sealed under another) is
1787
+ replaced, and shown once, by the next `PUT`. The URL and its secret go live together: a `PUT` whose write the store
1788
+ refuses leaves the webhook as it was, and the secret it made is never used.
1631
1789
 
1632
1790
  A try that is not answered 2xx within 15 s fails; a redirect is not followed. A failed message is tried again on the
1633
1791
  spec's schedule, with jitter: after about 5 s, 5 min, 30 min, 2 h, 5 h and 10 h, then logged as failed
1634
1792
  (`event=webhook condition=delivery_failed`). Each message goes on its own tries, so two queued close together can
1635
1793
  arrive in either order: a receiver orders them by `webhook-timestamp`, or reads the run (`GET /v2/runs/{id}`). A
1636
- `410 Gone` turns the webhook off (`disabled` in `GET`, and the log says why) until a `PUT` sets it again. Pending messages are kept in the store's outbox, so the next server goes on with
1637
- them after a restart; a message can then come twice, under the same `webhook-id`. An outbox of another version
1638
- is not read: the server starts with none, and the log says so (`condition=outbox_not_read`). `GET /v2/settings/webhook/deliveries`
1794
+ `410 Gone` turns the webhook off (`disabled` in `GET`, and the log says why) until a `PUT` sets it again. Pending messages are kept in the store, so the next server goes on with them after a
1795
+ restart; a message can then come twice, under the same `webhook-id`. `GET /v2/settings/webhook/deliveries`
1639
1796
  lists the last 50 attempts (`webhook_id`, type, status code, latency, error, when, and the next try's time), and
1640
1797
  `POST /v2/settings/webhook/deliveries/{webhook_id}/redeliver` sends one of those messages again, once, under the same
1641
1798
  `webhook-id`. `POST /v2/settings/webhook/test` sends a `webhook.test` message once and answers how it went. A webhook a
@@ -1721,8 +1878,8 @@ then the body, cut at 16 KiB, inside `<trigger-payload source="webhook" scheme="
1721
1878
  whatever the sender wrote is data, not an instruction. The tag names the signature scheme, the event as that scheme
1722
1879
  reads it (`event="..."`), the JSON body's top-level `action` (`action="..."`) and an unsigned delivery id
1723
1880
  (`delivery="..."`, GitHub's `X-GitHub-Delivery`) and, for a GitHub delivery, its pull request or issue's `number="..."`
1724
- (`pull_request.number`, else `issue.number`) and a pull request's `head_sha="..."` (40 hex; a comment event has none, so
1725
- 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
1881
+ (`pull_request.number`, else `issue.number`) and a pull request's `head_sha="..."` and `base_sha="..."` (40 hex each; a
1882
+ 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
1726
1883
  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
1727
1884
  the body, in any case, is defused.
1728
1885
 
@@ -1740,6 +1897,21 @@ delivery on the payload's tag, for tracing. A request that carries no scheme's s
1740
1897
  one, or is signed under a scheme other than its trigger's, is the same `401` as a bad signature, and the headers are
1741
1898
  checked before the body is read.
1742
1899
 
1900
+ `composio` takes [Composio](https://composio.dev) trigger events. Register the trigger's `hook_url` as Composio's webhook
1901
+ subscription (`POST /api/v3.1/webhook_subscriptions` with `enabled_events: ["composio.trigger.message"]`); Composio
1902
+ answers with a `secret` it makes, which you give here, whole and as Composio shows it, with `POST /v2/triggers/{id}/secret`
1903
+ and the body `{"secret": "..."}` (the same call replaces it when you rotate it in Composio). A composio trigger is made with no
1904
+ secret (the URL carries its id, so Composio can only make the secret after); until one is set every request is refused. It is sealed as a minted one is and never shown again; this server never
1905
+ makes one for a composio trigger. Composio signs as Standard Webhooks does (`webhook-id`, `webhook-timestamp`, `webhook-signature`) but keyed by the
1906
+ UTF-8 bytes of that secret string, not a decoded `whsec_` key, which is why a `standard` trigger cannot take it. The
1907
+ firing's key is `webhook-id`, the event is the body's `metadata.trigger_slug`, so `accept: [{"event":
1908
+ "GITHUB_ISSUE_ADDED_EVENT"}]` takes one Composio trigger's events, and a rule's `where` pointers read the payload under
1909
+ `/data`. The subscription also delivers account events (`composio.connected_account.expired`,
1910
+ `composio.connected_account.activated`, `composio.trigger.disabled`), signed the same way, with no slug: their event is the
1911
+ body's top-level `type`, so `accept` can take them too. A Composio project's subscription posts every event to the one URL it names, so it fires that one composio
1912
+ trigger and its agent: other triggers never see those deliveries, whatever their `accept`. The tag also names
1913
+ `trigger_id` and `user_id`.
1914
+
1743
1915
  `accept` makes a trigger take only the events it names, from the delivery alone:
1744
1916
 
1745
1917
  ```json
@@ -1886,6 +2058,22 @@ expires, so a long run's calls never carry an expired token. When that mint fail
1886
2058
  it expires; then the run's calls of that server are answered, unsent, that its GitHub App token expired and a new one
1887
2059
  could not be made, with GitHub's reason, and the next launch (a resume) mints a fresh one.
1888
2060
 
2061
+ An agent whose definition says `checkout: pull_request` starts each run a GitHub event about a pull request started in a
2062
+ checkout of it, made by the server at each claim before the first turn ([runner/pr-checkout.ts](src/runner/pr-checkout.ts)).
2063
+ It reads the repository, number, head and base from the server's own payload tag, only on a run a github trigger started
2064
+ (its launch's input origin) and never from anyone's words, and runs one
2065
+ 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
2066
+ the base 50 commits deep, deepened until their merge base is in (about 3,200 commits at most), then a detached checkout
2067
+ of the head, with refs `pr/head`, `pr/base` and `pr/merge-base`. The fetch takes an installation token minted for that
2068
+ one repository with `permissions: {contents: "read"}` alone, handed to the command on its stdin and turned there into an
2069
+ `Authorization` header in git's environment, scoped to GitHub's site; it is never in argv, `.git/config`, the remote's
2070
+ URL (`https://github.com/<owner>/<repo>.git`), the run's folder, the agent's environment or a log line, and it is revoked
2071
+ once the fetch is done. Git there reads no system or global config and fetches no tags or submodules. With no App, or one
2072
+ not installed on the repository, the fetch is anonymous, which a public repository answers. The run's system prompt
2073
+ carries one line: the checkout's facts, or why there is none (no pull request named, a fetch that failed, with git's
2074
+ last words), so its instructions can read the change through the GitHub MCP instead. The checkout is removed when the
2075
+ claim ends, and the next claim of the run makes it again.
2076
+
1889
2077
  ## Templates
1890
2078
 
1891
2079
  A template package makes a working agent in one call: its definition, its skills and rules, and its triggers, from a
@@ -1918,7 +2106,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
1918
2106
  | `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
1919
2107
  | `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. |
1920
2108
  | `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. |
1921
- | `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. 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)). |
2109
+ | `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)). |
1922
2110
  | `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. |
1923
2111
  | `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
1924
2112
  | `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
@@ -1934,7 +2122,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
1934
2122
  | `GET /runs/{id}/files`, `GET /runs/{id}/files/{path}` | The files under the run's `work/`, raw. |
1935
2123
  | `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. |
1936
2124
  | `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"`). |
1937
- | `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. |
2125
+ | `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. |
1938
2126
  | `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`). |
1939
2127
  | `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`. |
1940
2128
  | `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`. |
@@ -1963,6 +2151,7 @@ serves these routes alone:
1963
2151
  - a run's launch (`POST /agents/{id}/runs`, `POST /runs`), read (`GET /runs/{id}`), lists (`GET /agents/{id}/runs`,
1964
2152
  `GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above) and cap raise (`PATCH /runs/{id}`);
1965
2153
  - its files (`GET /runs/{id}/files`, `GET /runs/{id}/files/{path}`) and [uploads](#uploads) (`/files`);
2154
+ - an agent's Archil disk (`GET` and `DELETE /agents/{id}/archil`);
1966
2155
  - `GET /capabilities`, `GET /health` and `GET /usage`.
1967
2156
 
1968
2157
  Every other address is `404 not_found`, answered before the request is read further: the console at `/` and its
@@ -2132,9 +2321,9 @@ alone: a model of any other provider runs as it does without it. `codex` and `op
2132
2321
  to serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
2133
2322
  `OPENROUTER_API_KEY` is set, runs through OpenRouter (`https://openrouter.ai/api`, the key as a bearer token):
2134
2323
  claude-agent on its Messages endpoint, with Anthropic's own id on the wire (OpenRouter takes it: its Claude Code guide
2135
- 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
2136
- `openrouter/openai/gpt-6-sol` for pi (pi-ai's OpenRouter provider, on the bearer route), `anthropic/claude-sonnet-5.5` for
2137
- 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
2324
+ 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
2325
+ `openrouter/openai/gpt-6.1-sol` for pi (pi-ai's OpenRouter provider, on the bearer route), `anthropic/claude-sonnet-5.5` for
2326
+ 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
2138
2327
  set. A model named `openrouter/<vendor>/<model>` (pi's name for it) goes through OpenRouter on every harness. An endpoint
2139
2328
  the host names never gets OpenRouter's key: `ANTHROPIC_BASE_URL` without `ANTHROPIC_API_KEY` is refused. A model with more
2140
2329
  than one segment after its provider (`anthropic/anthropic/claude-sonnet-5.5`) is refused, naming the form to use. A provider
@@ -2253,10 +2442,13 @@ server's own origin, under a CSP that allows that origin only, but for the provi
2253
2442
  Its files (`index.html`, and Vite's hashed files under `/assets/`) are public and hold no data: everything it shows
2254
2443
  comes through `/v2`. With accounts on (the default) the console asks for the owner's password
2255
2444
  ([your password](#your-password)) and the browser holds the owner's session cookie; a `?token=` link sets no cookie: the
2256
- token is for scripts and the CLI. With `AGENTRUN_ACCOUNTS=0`, the printed link (`/?token=`) sets a cookie (`HttpOnly`,
2257
- `SameSite=Strict`, `Path=/`, and `Secure` when `X-Forwarded-Proto` says https) and sends the browser to the same address
2258
- without the token. The cookie's value is derived from the token, never the token itself, and it lasts until the browser
2259
- closes. Without it, the console says to open the link. Either cookie takes the place of `Authorization: Bearer` on
2445
+ token is for scripts and the CLI. With `AGENTRUN_ACCOUNTS=0`, the printed link (`/?launch=<code>`, a code each start
2446
+ makes at random) gives the browser a console session: a cookie (`HttpOnly`, `SameSite=Strict`, `Path=/`, and `Secure`
2447
+ when `X-Forwarded-Proto` says https) whose value is an id made at random and kept by the server, and sends the browser
2448
+ to the same address without the code. Nothing about it is derived from the API token, and a `?token=` link sets no
2449
+ cookie there either, so the token alone never holds a console session (and so never writes a secret, below). The
2450
+ session lasts until the browser closes or the server stops; the next start prints its own link. Without it, the console
2451
+ says to open the link. Either cookie takes the place of `Authorization: Bearer` on
2260
2452
  `/v2`: for a `GET`, and for any other method only when the request's `Origin` is the server's own origin
2261
2453
  and its body is `application/json`, or, on a `PUT` or `POST` to a route that takes bytes (`PUT /v2/files/{id}`,
2262
2454
  `POST /v2/files`), of any content type. A request that sends an `Authorization` header is checked on that header alone.
@@ -2359,7 +2551,7 @@ left out: 2 sessions still being written: they come in next time
2359
2551
  A stopped run can be continued: a follow-up starts a fresh turn on the whole history, and the turn the stop cut is
2360
2552
  not replayed. A cancelled run cannot: a message to it is `409 not_continuable`, and its `next_action` is to start a
2361
2553
  new run of the agent.
2362
- - A workflow revision runs on the workflow loop, which drives the DSL's durable workflow task on the run's journal
2554
+ - 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
2363
2555
  (keyed by the run's id): its model nodes (`agent`, `decide`, `extract`, `report`) on the run's model, with the file
2364
2556
  tools each node names, and its typed questions on Jev or Parallel ([decision workflows](#decision-workflows)). A
2365
2557
  workflow that needs code or a tool call this host does not run is not saved here (`422`). The run is `queued`
@@ -2419,11 +2611,14 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
2419
2611
  edit; then by name), while they all fit the server's learning budget (`--learning-budget`, 8000 bytes by default).
2420
2612
  Past it, the run reads the notes that bear on it: each active note is scored against the run's first message by a
2421
2613
  lexical match (BM25 over its name, description and text; a code review's changed paths weigh three times its prose; no
2422
- model call), and the run reads the best ones whole while they fit, then one line for each of the rest
2423
- (`- <name> (<file>): <description>`, at most 200 lines and 25 KB), in place of the index. A first message that shares
2424
- no word with any note reads the index's first 200 lines, then the notes changed last, whole, while they fit. An agent
2425
- with the `read` tool is told the notes not given whole are in `.learning/`, to open one when it applies (one without
2426
- is not). A line
2614
+ model call), and the run reads the best ones whole while they fit the budget, then one line each
2615
+ (`- <name> (<file>): <description>`, at most 200 lines and 25 KB) for the next ones while they fit what is left, in
2616
+ place of the index. A note that shares no word with the first message is a line at most. A first message that shares
2617
+ no word with any note reads the notes changed last, whole while they fit, then their lines. Whole notes take the
2618
+ budget before lines do, so an agent with hundreds of notes still reads the ones that bear on the run whole; the notes
2619
+ given neither way are left out, and the run's log names them ("starts without N of the notes its agent learned").
2620
+ An agent with the `read` tool is told the notes not given whole are in `.learning/`, to open one when it applies
2621
+ (one without is not). A line
2427
2622
  before them says to follow a note when it applies. `# Learned` opens, for every run that learns, notes or none, with
2428
2623
  what the run is told of learning: that only what it answers when it is asked at the end is kept, never a file it
2429
2624
  writes, so it tells the person it will keep what they ask it to remember, and that a secret is never kept. A run with
@@ -2525,7 +2720,7 @@ path that is not a `.md` file at the top, a bad name, front matter out of shape
2525
2720
  naming a note that is not active, more than 8 notes superseded, more than 8 new notes or a note over 4068 bytes (4096,
2526
2721
  less the 28 the server's own `origin` and `status` lines may take once it merges the note), an
2527
2722
  index past 200 lines, hidden characters, and text shaped like a secret or holding one of the server's own secrets (the
2528
- launcher's, the keys and tokens in its environment, its API and door tokens, each webhook trigger's signing secret as it
2723
+ launcher's, the keys and tokens in its environment, its API token, each webhook trigger's signing secret as it
2529
2724
  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
2530
2725
  learning names what was left out. The whole answer is refused when it holds a secret or a hidden character (no item of
2531
2726
  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
@@ -2542,7 +2737,15 @@ neither, on the agent's own model. `GET /capabilities` names it as `learning.gra
2542
2737
  cheap model is a poor grader, so point the strong tier (or `--grade-model`) at a strong one. The grader reads each active
2543
2738
  note's index line, the whole text only of the notes the proposal supersedes, what the user said in the run (cut of the
2544
2739
  server's secrets, as the proposal keeps it), and the new notes, so its prompt stays under 200,000 characters however
2545
- many notes the folder holds. No injection screen runs before it: a page classifier cannot see where a note came
2740
+ many notes the folder holds. A note must hold beyond the one input it came from: before the grader, one Jev question
2741
+ per new note (the Jev model and keys decision nodes use) asks whether it states a method, a source, a fact or a
2742
+ preference that holds for this job's other inputs, and a note rated below 0.5
2743
+ (`AGENTRUN_SERVE_LEARNING_GENERAL_THRESHOLD`, from 0 to 1) is dropped there, its reason on the verdict; its cost is
2744
+ the grade's. When Jev cannot run, the grader reads every note: the runner's log says why, the run's learning says the
2745
+ check could not run, and the grade's cost is unknown, never the grader's alone (a Jev request that failed may still
2746
+ have been charged). The grader answers General
2747
+ for every item, and one it says is not general is never kept, whatever else it decides. No injection screen runs
2748
+ before it: a page classifier cannot see where a note came
2546
2749
  from, and read a preference the user stated as a planted instruction; the grader's Planted question decides: a rule the
2547
2750
  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
2548
2751
  inside text the run read is planted and dropped, never held for the owner's OK. An item that holds an account number is
@@ -2572,7 +2775,7 @@ characters and no time) says how it went: `seeded`, then
2572
2775
  `reflecting` during the turn and until what it answered is checked, `proposed` while it is graded, and `merged`, or
2573
2776
  `dropped` with a reason from a closed list (`seed_failed`, `no_budget`, `unknown_cost`, `cancelled`, `crashed`,
2574
2777
  `reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`; a run
2575
- record or ledger line with any other reason is not counted). It is `null` for a
2778
+ record with any other reason is not counted). It is `null` for a
2576
2779
  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
2577
2780
  workflow's or an imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2
2578
2781
  notes.", "Looking back on this run…", "Checking 1 new note…", "Learned: Check units (replaces 1 older note)", "Learned:
@@ -2596,17 +2799,9 @@ notes its merge added, once `merged`; and `pending`, `[{file, name}]`, the notes
2596
2799
  `merged`, never among `learned`. A name and a file are cut of the server's secrets as they are now, a file holding one
2597
2800
  `[redacted]`. Whether a run applied a note is not measured: `given` and `read` say what it had and what it opened. Each
2598
2801
  note on the agent's learning view and notes page counts its runs of each, `runs: {given, read}`, over the runs the server
2599
- knows (held ones from memory, ended ones from the learning ledger).
2600
-
2601
- Each run's learning end is written once to the learning ledger, `DATA/learning-usage.jsonl`, one line `{run, agent,
2602
- state, reason, at, cost, tokens, seed_notes, given, read, answered_at, job_cost_usd, look_back_usd}` (`cost` and
2603
- `tokens` the grade's, null when unknown, 0 when nothing was graded; `seed_notes` how many notes the run started from;
2604
- `given` and `read` the files of the notes it was given and read, each absent when there are none; once it looked back,
2605
- `answered_at` and `job_cost_usd`, when its job's answer was final and what it had cost then; `look_back_usd` what
2606
- looking back cost, 0 when it did not), after its `serve.json` holds it; a server that went between the two writes it at
2607
- its next start. A run's notes are the one part that moves after its end (a follow-up reads another note): a line
2608
- `{run, agent, notes: true, given, read}` then says them anew, the latest one winning, and counts neither the run nor its
2609
- costs again. `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
2802
+ knows, read from the store.
2803
+
2804
+ `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
2610
2805
  `agent`, from the store (each run's kept learning and its learning run's journal; `in_progress` while a proposal waits
2611
2806
  for its grade), never opening a run's files; the `learning` meter on `GET /usage` reads each run's grade from the same.
2612
2807
 
@@ -2640,13 +2835,12 @@ with the token, an archived agent's too:
2640
2835
  - `GET /agents/{agent_id}/learning`: `main`'s head, `MEMORY.md` as `index`, the first 50 notes (active first, then
2641
2836
  newest first) and the first 20 changes on `main` (newest first, each `by: {run}` from its `Run-Id` trailer or
2642
2837
  `{user: true}`, with its commit, time, reason and files), and how the agent's runs that tried to learn fared
2643
- (`merged`, `dropped` by reason, `in_progress`), counted as `GET /stats` counts them: from the learning ledger and the
2644
- runs the server holds, never a run's files; and `impact` (`learning/2`), what learning changed: the agent's completed
2838
+ (`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
2645
2839
  runs that started from at least one active note against those that started before its first note (the earlier of its
2646
2840
  first merge and the start of its first run that started from a note, so a person's first note counts), each side's
2647
2841
  `runs`; `median_duration_s`, the time to the answer (the run's start to its job's end, before it looks back);
2648
2842
  `median_cost_usd`, the job's own cost without its look-back, over the `cost_runs` whose cost is known; and
2649
- `median_learning_usd`, what learning itself cost a run (its look-back and its grade). From the same rows and ledger;
2843
+ `median_learning_usd`, what learning itself cost a run (its look-back and its grade). From the same rows;
2650
2844
  null unless both sides count 2 runs. An agent with no folder answers `main: null`, empty pages and `impact: null`.
2651
2845
  `GET .../learning/notes?cursor=&limit=&status=` and `GET .../learning/log?cursor=&limit=` page on, up to 200 at a
2652
2846
  time; a cursor reads the same commit its first page did.
@@ -2713,8 +2907,8 @@ Who can approve: the owner, signed in with their password. No token approves, th
2713
2907
 
2714
2908
  `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
2715
2909
  a JSON body as every page write is. Any token is 403: the server's own (what scripts and the MCP endpoint's tools
2716
- carry), a run's door token, and a token sent beside the session. So is every request on a server with accounts off
2717
- (`AGENTRUN_ACCOUNTS=0`), whose page cookie any token holder can mint. With no credential it is 401, as every route.
2910
+ carry) and a token sent beside the session. So is every request on a server with accounts off
2911
+ (`AGENTRUN_ACCOUNTS=0`), which has no password session: its console session comes from the launch code, never the token. With no credential it is 401, as every route.
2718
2912
  `capabilities.learning.approve` is true only for the owner's session; every other caller reads `approve: false` with
2719
2913
  `approve_needs: "password"`. A note that is not pending is 400; a stale ETag is 412, none 428. The approval is one host
2720
2914
  commit, `learning: approved by a person: <file>`, with the trailers `Changed-By: user` and `Approved-Via: console`; the
@@ -2762,11 +2956,14 @@ cap, due at the run's first request), the words say the budget instead, on every
2762
2956
  $X, enough for little work: answer as soon as you can." On pi the words go into that one request's context;
2763
2957
  on claude-agent, codex and opencode the model proxy adds them to the body (after everything the CLI sent, so its cached
2764
2958
  prefix is unchanged). Neither CLI nor pi keeps them in its transcript, and no message is queued, so nothing runs after
2765
- the model's answer. Once per cap, across restarts; a raise re-arms it.
2766
-
2767
- A capped run also stops calling tools before its cap stops it. Once what it has spent, plus what its requests and paid
2768
- steps still out are held at (their worst case, as the cap counts them, a browser session's open reserve included),
2769
- reaches 75% of its cap, the run's tool gate
2959
+ the model's answer. Once per cap, across restarts; a raise re-arms it. The note also comes due, if it has not already,
2960
+ on the request whose tool call would be refused now (the wrap-up below: what is left no longer covers what the run keeps
2961
+ back to answer), so the note tells the model what is left no later than its tools stop.
2962
+
2963
+ A capped run also stops calling tools before its cap stops it. It keeps back enough to answer: one typical step (its own
2964
+ answers' typical cost) and one final answer at its least, as the cap prices the main model's next request. Once what it
2965
+ has spent, plus what its requests and paid steps still out are held at (their worst case, as the cap counts them, a
2966
+ browser session's open reserve included), leaves less than that, the run's tool gate
2770
2967
  refuses every call a model makes, in every conversation of the run, on every harness, before any setting or approval
2771
2968
  is read, with one fixed text: "Budget nearly spent: stop calling tools and answer now from what you have." A call that
2772
2969
  would open a child conversation is refused the same way, so no new one starts. Nothing in flight is cut: a child still
@@ -2775,7 +2972,10 @@ model requests are judged by the cap as before, so the run's final answer still
2775
2972
  request that does not fit what is left is refused as above. The figure is read from the run's booking records at each
2776
2973
  call, never kept in memory, so a restart or a claim moved to another runner holds the same line, and a raise moves it.
2777
2974
  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
2778
- with no answer at all; the quarter left above the line is the room for each of them, and the parent, to answer.
2975
+ with no answer at all: their holds count as taken, so the run stops calling tools while each of them, and the parent,
2976
+ still has room to answer. A simple run, with nothing else out, uses its cap up to its last step and answer. The run is
2977
+ told what is left (its wrap-up note, above) no later than its first refused call. Its one known miss: a request that
2978
+ writes to its max output can still leave no room for the answer; then the run pauses for a raise rather than overspend.
2779
2979
 
2780
2980
  Under a cap each request is limited to the
2781
2981
  output tokens what is left of the cap can buy, thinking included, never more than it asks for or than the model's
@@ -2802,16 +3002,13 @@ screenshots, then the answer), spending about $0.04 in all:
2802
3002
 
2803
3003
  | Cap mode | Route | First request needs | Five-step run needs | Each further step |
2804
3004
  | --- | --- | --- | --- | --- |
2805
- | `strict` | Through a gateway (OpenRouter): the byte bound | $0.05 | $0.11 | about $0.013 |
3005
+ | `strict` | Through a gateway (OpenRouter): the byte bound | $0.06 | $0.12 | about $0.013 |
2806
3006
  | `strict` | Straight to Anthropic: Anthropic's count | $0.03 | $0.09 | about $0.012 |
2807
- | `expected` (the default) | Either | as `strict` | as `strict` until #2504 lands | as `strict` until #2504 lands |
3007
+ | `expected` (the default) | Either | as `strict` | $0.06 | about $0.007 |
2808
3008
 
2809
- In `strict` mode every step's whole input is priced at the cache-write price. The `expected` row is today's: the runner
2810
- does not yet price a step from what the previous request read from the cache, as `expected` is described above, so it
2811
- prices like `strict` until #2504 lands. Once it does, a five-step run in `expected` mode needs about $0.06 by either route,
2812
- and about $0.007 a further step. A claude-agent run's first request is of the same size (the pinned
3009
+ In `strict` mode every step's whole input is priced at the cache-write price. In `expected` mode a step after the first is priced from what the session's previous request read from the cache, so a five-step run needs about $0.06 by either route, and about $0.007 a further step; the first request is priced as in `strict`, so its figure is the same. A claude-agent run's first request is of the same size (the pinned
2813
3010
  CLI's measured 6,926 bytes with five tools: $0.04 for its first request through a gateway). A cap below these pauses at
2814
- once with `Not sent: ... the next step needs at least $X`, and a raise to that figure sends it on.
3011
+ once with `Not sent: ... the next step needs at least $X`, and a raise to that figure sends it on. (In `strict` mode through a gateway, a run a cent under the five-step figure is not parked before its last step: the cap's wrap-up refuses its last screenshot, and the run answers from what it has.)
2815
3012
  `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
2816
3013
  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
2817
3014
  survives a restart, plus each response since, and with them each charge a paid tool booked (`monid.run`, which is itself
@@ -2901,7 +3098,8 @@ no cap fixes, its error), as a person who has never seen a model request reads t
2901
3098
  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:
2902
3099
  "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
2903
3100
  $0.48 to continue." What was spent, and what steps still running hold (named when it is a cent or more), read to the
2904
- nearest cent ($0.0237416 reads $0.02); the exact amounts are `pending.spent_usd`. The cap to raise to is what was
3101
+ nearest cent ($0.0237416 reads $0.02); a spend above $0 that rounds to $0 reads "less than a cent" ("this run has spent
3102
+ 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
2905
3103
  spent, what steps still running hold, and the next step's least, rounded up to the cent so that it is enough. The words
2906
3104
  name no model. The refusal's timeline row is an `error` row with
2907
3105
  `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
@@ -3035,13 +3233,13 @@ carries no cost at all, as from a provider that does not price the model. The te
3035
3233
 
3036
3234
  - An import (`agentrun-serve import`, and setup's import) cuts secrets out of everything it writes: the values of the
3037
3235
  environment's key-shaped variables and the keys saved on this server, the secrets this server made and keeps (its API
3038
- token, its door token, its sign-in secret, and its webhook's signing secret when the seal key opens it; when it does
3236
+ token, its sign-in secret, and its webhook's signing secret when the seal key opens it; when it does
3039
3237
  not, the CLI's import says so once, on stderr, and goes on), and the keys [secretlint](https://github.com/secretlint/secretlint)'s
3040
3238
  recommended rules find in what it reads (Anthropic, OpenAI, GitHub, Slack and Stripe keys, AWS secret keys beside their
3041
3239
  name, private keys, database URLs with a password, and more). Each becomes `[redacted]`, and the import says how many
3042
3240
  distinct values it removed. Known key formats are removed. Other secrets in your session history, like passwords in
3043
- config files, are imported as they are. So are a key-shaped value this server did not make (a `whsec_` secret from
3044
- another service) and a run's own door token.
3241
+ config files, are imported as they are. So is a key-shaped value this server did not make (a `whsec_` secret from
3242
+ another service).
3045
3243
  - The decision keys (`TYPESAFE_API_KEY`, `PARALLEL_API_KEY`, `OPENROUTER_API_KEY` as Jev's or OpenRouter's) are never in
3046
3244
  a run's environment or files: a run's process gets on a pipe of their own only those it needs, for its decision
3047
3245
  providers ([decision workflows](#decision-workflows)) and its web tools: Jev's (by its route) for a node that names Jev
@@ -3151,7 +3349,7 @@ carries no cost at all, as from a provider that does not price the model. The te
3151
3349
  ## Test
3152
3350
 
3153
3351
  ```sh
3154
- npm run build -w @parcha/agentrun-dsl -w @parcha/agentrun-pi -w @parcha/pi-durable-agent -w @parcha/agentrun-serve
3352
+ npm run build
3155
3353
  npm test -w @parcha/agentrun-serve
3156
3354
  ```
3157
3355