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

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 (381) hide show
  1. package/CHANGELOG.md +233 -0
  2. package/README.md +266 -201
  3. package/dist/adapters.d.ts +0 -4
  4. package/dist/adapters.js +11 -15
  5. package/dist/agent-rows.d.ts +98 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +60 -25
  9. package/dist/agents.d.ts +9 -125
  10. package/dist/agents.js +15 -305
  11. package/dist/answer-json.d.ts +23 -0
  12. package/dist/answer-json.js +58 -0
  13. package/dist/api-only.d.ts +1 -1
  14. package/dist/api-only.js +2 -2
  15. package/dist/bash-read-only.d.ts +22 -0
  16. package/dist/bash-read-only.js +701 -0
  17. package/dist/box-settings.d.ts +3 -23
  18. package/dist/box-settings.js +7 -51
  19. package/dist/boxes.d.ts +17 -0
  20. package/dist/boxes.js +27 -20
  21. package/dist/browser-commands.d.ts +5 -2
  22. package/dist/browser-commands.js +4 -4
  23. package/dist/browser-computer.d.ts +5 -0
  24. package/dist/browser-computer.js +21 -0
  25. package/dist/browser-cost.d.ts +9 -6
  26. package/dist/browser-cost.js +92 -50
  27. package/dist/browser-live.d.ts +7 -20
  28. package/dist/browser-live.js +15 -93
  29. package/dist/browser-person.d.ts +18 -51
  30. package/dist/browser-person.js +94 -277
  31. package/dist/cap.d.ts +8 -5
  32. package/dist/cap.js +12 -5
  33. package/dist/cli.js +39 -13
  34. package/dist/closed-pipes.d.ts +2 -0
  35. package/dist/closed-pipes.js +13 -0
  36. package/dist/computer-commands.d.ts +2 -0
  37. package/dist/computer-commands.js +2 -0
  38. package/dist/computer-keys.js +5 -2
  39. package/dist/computer-setting.d.ts +20 -4
  40. package/dist/computer-setting.js +25 -5
  41. package/dist/computers.d.ts +30 -2
  42. package/dist/computers.js +70 -11
  43. package/dist/confine.d.ts +120 -0
  44. package/dist/confine.js +436 -0
  45. package/dist/console/assets/index-RPHGlXmM.js +540 -0
  46. package/dist/console/assets/index-opTN5Naq.css +1 -0
  47. package/dist/console/index.html +2 -2
  48. package/dist/decision-rows.d.ts +1 -1
  49. package/dist/decision-rows.js +1 -1
  50. package/dist/docker-daemon.d.ts +31 -0
  51. package/dist/docker-daemon.js +56 -0
  52. package/dist/effort-guidance.js +4 -3
  53. package/dist/environment.d.ts +0 -3
  54. package/dist/environment.js +3 -5
  55. package/dist/errors.d.ts +0 -2
  56. package/dist/errors.js +6 -9
  57. package/dist/filed-answer.d.ts +32 -0
  58. package/dist/filed-answer.js +160 -0
  59. package/dist/files.d.ts +1 -3
  60. package/dist/files.js +2 -4
  61. package/dist/github-connection.d.ts +1 -1
  62. package/dist/graph-view.d.ts +3 -5
  63. package/dist/graph-view.js +4 -14
  64. package/dist/handed-values.d.ts +9 -0
  65. package/dist/handed-values.js +26 -0
  66. package/dist/harness-install.d.ts +1 -7
  67. package/dist/harness-install.js +1 -18
  68. package/dist/harness-opencode/adapter.d.ts +7 -0
  69. package/dist/harness-opencode/adapter.js +23 -6
  70. package/dist/harness-opencode/index.d.ts +1 -1
  71. package/dist/harness-opencode/index.js +1 -1
  72. package/dist/harness-opencode/verify.d.ts +17 -0
  73. package/dist/harness-opencode/verify.js +30 -10
  74. package/dist/harness-table.js +6 -1
  75. package/dist/heard.js +1 -1
  76. package/dist/held-fd.d.ts +5 -0
  77. package/dist/held-fd.js +14 -0
  78. package/dist/host-calls.d.ts +20 -0
  79. package/dist/host-calls.js +12 -0
  80. package/dist/host-tools.d.ts +4 -21
  81. package/dist/host-tools.js +4 -61
  82. package/dist/host.d.ts +2 -4
  83. package/dist/host.js +2 -7
  84. package/dist/import-summary.d.ts +1 -5
  85. package/dist/import-summary.js +0 -21
  86. package/dist/import.d.ts +6 -6
  87. package/dist/import.js +14 -15
  88. package/dist/key-refusal.d.ts +5 -1
  89. package/dist/key-refusal.js +19 -4
  90. package/dist/learn/check.d.ts +6 -2
  91. package/dist/learn/check.js +83 -29
  92. package/dist/learn/folder.d.ts +5 -1
  93. package/dist/learn/folder.js +10 -3
  94. package/dist/learn/grade.d.ts +14 -0
  95. package/dist/learn/grade.js +68 -12
  96. package/dist/learn/index.d.ts +4 -4
  97. package/dist/learn/index.js +4 -4
  98. package/dist/learn/reflect.d.ts +31 -2
  99. package/dist/learn/reflect.js +79 -4
  100. package/dist/learn/relevance.d.ts +24 -0
  101. package/dist/learn/relevance.js +91 -0
  102. package/dist/learn/secrets.d.ts +7 -1
  103. package/dist/learn/secrets.js +86 -19
  104. package/dist/learn/skills.d.ts +112 -14
  105. package/dist/learn/skills.js +556 -52
  106. package/dist/learned-workflow.d.ts +32 -1
  107. package/dist/learned-workflow.js +100 -9
  108. package/dist/learning-routes.d.ts +8 -4
  109. package/dist/learning-routes.js +23 -9
  110. package/dist/learning-run.d.ts +9 -26
  111. package/dist/learning-run.js +22 -32
  112. package/dist/learning-words.d.ts +12 -5
  113. package/dist/learning-words.js +18 -9
  114. package/dist/learning.d.ts +93 -77
  115. package/dist/learning.js +176 -304
  116. package/dist/live/stream.js +1 -1
  117. package/dist/live/translate.js +12 -2
  118. package/dist/local-models.d.ts +11 -5
  119. package/dist/local-models.js +13 -8
  120. package/dist/mcp-gateway.d.ts +11 -49
  121. package/dist/mcp-gateway.js +44 -135
  122. package/dist/mcp-oauth.d.ts +10 -14
  123. package/dist/mcp-oauth.js +14 -32
  124. package/dist/mcp-probe.d.ts +0 -7
  125. package/dist/mcp-probe.js +4 -10
  126. package/dist/mcp-servers-store.d.ts +6 -6
  127. package/dist/mcp-servers-store.js +12 -14
  128. package/dist/mcp-store.js +3 -4
  129. package/dist/mcp.js +4 -3
  130. package/dist/model.d.ts +6 -7
  131. package/dist/model.js +43 -27
  132. package/dist/monid.d.ts +0 -2
  133. package/dist/monid.js +3 -6
  134. package/dist/openapi.d.ts +8 -1
  135. package/dist/openapi.js +121 -47
  136. package/dist/page.d.ts +1 -3
  137. package/dist/page.js +6 -18
  138. package/dist/paid-calls.d.ts +21 -27
  139. package/dist/paid-calls.js +25 -60
  140. package/dist/propose.js +83 -39
  141. package/dist/push-handler.d.ts +1 -1
  142. package/dist/reflect-range.d.ts +25 -0
  143. package/dist/reflect-range.js +30 -0
  144. package/dist/refusal-words.d.ts +5 -1
  145. package/dist/refusal-words.js +5 -1
  146. package/dist/rows.d.ts +1 -1
  147. package/dist/run-cut.d.ts +0 -6
  148. package/dist/run-cut.js +0 -6
  149. package/dist/run-db.d.ts +2 -11
  150. package/dist/run-db.js +2 -37
  151. package/dist/run-launch.d.ts +19 -2
  152. package/dist/run-launch.js +13 -5
  153. package/dist/run-learning-served.d.ts +10 -4
  154. package/dist/run-learning-served.js +23 -13
  155. package/dist/run-reads-over-store.d.ts +1 -1
  156. package/dist/run-reads-over-store.js +15 -6
  157. package/dist/run-secrets.d.ts +1 -1
  158. package/dist/run-timeline-served.d.ts +5 -1
  159. package/dist/run-timeline-served.js +15 -4
  160. package/dist/run-view.d.ts +7 -8
  161. package/dist/run-view.js +26 -7
  162. package/dist/runnable.d.ts +18 -10
  163. package/dist/runnable.js +21 -10
  164. package/dist/runner/adapter-loop.d.ts +6 -1
  165. package/dist/runner/adapter-loop.js +423 -53
  166. package/dist/runner/adapter-run-spec.d.ts +21 -8
  167. package/dist/runner/adapter-run-spec.js +90 -32
  168. package/dist/runner/adapters/index.js +11 -1
  169. package/dist/runner/adapters/pi.d.ts +12 -2
  170. package/dist/runner/adapters/pi.js +16 -5
  171. package/dist/runner/beside.d.ts +30 -3
  172. package/dist/runner/beside.js +36 -5
  173. package/dist/runner/claim-secrets.d.ts +10 -1
  174. package/dist/runner/claim-secrets.js +48 -14
  175. package/dist/runner/cli-run-spec.d.ts +2 -0
  176. package/dist/runner/cli-run-spec.js +45 -16
  177. package/dist/runner/commands.js +1 -1
  178. package/dist/runner/computer-journal.d.ts +15 -2
  179. package/dist/runner/computer-journal.js +41 -5
  180. package/dist/runner/conformance/harness.js +118 -8
  181. package/dist/runner/conformance/subject.d.ts +4 -1
  182. package/dist/runner/dispatch.d.ts +8 -1
  183. package/dist/runner/dispatch.js +81 -7
  184. package/dist/runner/end-of-run.d.ts +8 -2
  185. package/dist/runner/end-of-run.js +10 -4
  186. package/dist/runner/github-app.js +1 -1
  187. package/dist/runner/harness-loops.d.ts +9 -1
  188. package/dist/runner/harness-loops.js +15 -2
  189. package/dist/runner/journal-kinds.d.ts +24 -6
  190. package/dist/runner/journal-kinds.js +20 -5
  191. package/dist/runner/journal-reader.d.ts +1 -1
  192. package/dist/runner/journal-reader.js +2 -2
  193. package/dist/runner/learning-ask.d.ts +4 -0
  194. package/dist/runner/learning-ask.js +15 -1
  195. package/dist/runner/learning-end.d.ts +18 -3
  196. package/dist/runner/learning-end.js +113 -11
  197. package/dist/runner/learning-loop.d.ts +5 -0
  198. package/dist/runner/learning-loop.js +26 -6
  199. package/dist/runner/main.d.ts +56 -9
  200. package/dist/runner/main.js +127 -18
  201. package/dist/runner/mcp-claim.js +1 -2
  202. package/dist/runner/mcp-run.d.ts +2 -0
  203. package/dist/runner/mcp-run.js +15 -5
  204. package/dist/runner/memory-claim.d.ts +9 -0
  205. package/dist/runner/memory-claim.js +25 -0
  206. package/dist/runner/metrics.d.ts +33 -1
  207. package/dist/runner/metrics.js +85 -1
  208. package/dist/runner/model-route.d.ts +13 -0
  209. package/dist/runner/model-route.js +133 -9
  210. package/dist/runner/reflect-hook.d.ts +12 -1
  211. package/dist/runner/reflect-hook.js +33 -3
  212. package/dist/runner/runner.d.ts +20 -0
  213. package/dist/runner/runner.js +56 -10
  214. package/dist/runner/store-port.d.ts +1 -1
  215. package/dist/runner/store-secrets.d.ts +3 -3
  216. package/dist/runner/store-secrets.js +8 -12
  217. package/dist/runner/text-tools.d.ts +44 -0
  218. package/dist/runner/text-tools.js +237 -0
  219. package/dist/runner/workflow-loop.d.ts +6 -0
  220. package/dist/runner/workflow-loop.js +6 -4
  221. package/dist/runner/workflow-spec.d.ts +18 -0
  222. package/dist/runner/workflow-spec.js +63 -17
  223. package/dist/runs-over-store.d.ts +7 -2
  224. package/dist/runs-over-store.js +60 -14
  225. package/dist/seal-key.js +5 -43
  226. package/dist/sealed-settings-store.d.ts +19 -4
  227. package/dist/sealed-settings-store.js +9 -9
  228. package/dist/sealing.d.ts +4 -0
  229. package/dist/sealing.js +20 -0
  230. package/dist/secret-cut.d.ts +1 -1
  231. package/dist/secret-cut.js +1 -1
  232. package/dist/secret-name.d.ts +9 -0
  233. package/dist/secret-name.js +15 -0
  234. package/dist/secret-writes.d.ts +0 -1
  235. package/dist/secret-writes.js +0 -1
  236. package/dist/server-fs.d.ts +4 -0
  237. package/dist/server-fs.js +8 -2
  238. package/dist/server-lock.d.ts +0 -24
  239. package/dist/server-lock.js +1 -80
  240. package/dist/server-secrets-store.d.ts +4 -4
  241. package/dist/server-secrets-store.js +9 -31
  242. package/dist/server-secrets.d.ts +4 -9
  243. package/dist/server-secrets.js +12 -36
  244. package/dist/server.d.ts +16 -38
  245. package/dist/server.js +145 -106
  246. package/dist/sign-ins-store.d.ts +34 -36
  247. package/dist/sign-ins-store.js +27 -38
  248. package/dist/sign-ins.d.ts +2 -119
  249. package/dist/sign-ins.js +5 -311
  250. package/dist/standard-webhooks.d.ts +1 -1
  251. package/dist/standard-webhooks.js +1 -1
  252. package/dist/stats.d.ts +3 -2
  253. package/dist/stats.js +1 -1
  254. package/dist/store/agent-body.d.ts +8 -2
  255. package/dist/store/agent-body.js +16 -4
  256. package/dist/store/index.d.ts +2 -2
  257. package/dist/store/index.js +2 -2
  258. package/dist/store/open.d.ts +6 -3
  259. package/dist/store/open.js +2 -2
  260. package/dist/store/postgres/connection.d.ts +18 -2
  261. package/dist/store/postgres/connection.js +156 -32
  262. package/dist/store/postgres/migrate.d.ts +4 -0
  263. package/dist/store/postgres/migrate.js +9 -2
  264. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  265. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  266. package/dist/store/postgres/store.d.ts +9 -2
  267. package/dist/store/postgres/store.js +9 -0
  268. package/dist/store/schema.js +1 -1
  269. package/dist/store/seal.js +2 -2
  270. package/dist/store/sqlite/connection.js +49 -5
  271. package/dist/store/sqlite/run-patch.d.ts +3 -0
  272. package/dist/store/sqlite/run-patch.js +3 -0
  273. package/dist/store/sqlite/store.js +41 -12
  274. package/dist/store/store.d.ts +35 -6
  275. package/dist/store/store.js +12 -2
  276. package/dist/store-reads/cap.d.ts +1 -1
  277. package/dist/store-reads/cap.js +22 -4
  278. package/dist/store-reads/journal.d.ts +9 -6
  279. package/dist/store-reads/journal.js +93 -17
  280. package/dist/store-reads/learning.d.ts +26 -8
  281. package/dist/store-reads/learning.js +12 -4
  282. package/dist/store-reads/workflow.d.ts +1 -1
  283. package/dist/store-reads/workflow.js +1 -1
  284. package/dist/store-view.d.ts +5 -1
  285. package/dist/store-view.js +53 -18
  286. package/dist/template-eval.d.ts +60 -4
  287. package/dist/template-eval.js +120 -54
  288. package/dist/templates.d.ts +24 -10
  289. package/dist/templates.js +69 -38
  290. package/dist/timeline/group.d.ts +33 -0
  291. package/dist/timeline/group.js +77 -0
  292. package/dist/timeline/index.d.ts +7 -0
  293. package/dist/timeline/index.js +7 -0
  294. package/dist/timeline/labels.d.ts +79 -0
  295. package/dist/timeline/labels.js +150 -0
  296. package/dist/timeline/origin.d.ts +56 -0
  297. package/dist/timeline/origin.js +92 -0
  298. package/dist/timeline/render-text.d.ts +11 -0
  299. package/dist/timeline/render-text.js +62 -0
  300. package/dist/timeline/timeline.d.ts +274 -0
  301. package/dist/timeline/timeline.js +1308 -0
  302. package/dist/timeline/util.d.ts +17 -0
  303. package/dist/timeline/util.js +49 -0
  304. package/dist/tool-gate.d.ts +41 -216
  305. package/dist/tool-gate.js +79 -540
  306. package/dist/tool-keys-store.d.ts +11 -12
  307. package/dist/tool-keys-store.js +24 -31
  308. package/dist/tool-keys.d.ts +5 -101
  309. package/dist/tool-keys.js +8 -267
  310. package/dist/tool-plane.d.ts +14 -42
  311. package/dist/tool-plane.js +23 -81
  312. package/dist/tool-settings-store.d.ts +1 -2
  313. package/dist/tool-settings-store.js +5 -8
  314. package/dist/tools.d.ts +30 -18
  315. package/dist/tools.js +97 -107
  316. package/dist/trigger-adapter.d.ts +2 -2
  317. package/dist/trigger-targets.d.ts +13 -1
  318. package/dist/trigger-targets.js +31 -1
  319. package/dist/triggers.d.ts +2 -2
  320. package/dist/triggers.js +3 -3
  321. package/dist/turn-end.d.ts +1 -1
  322. package/dist/turn-end.js +1 -1
  323. package/dist/turns.d.ts +0 -6
  324. package/dist/turns.js +0 -19
  325. package/dist/uploads.js +1 -1
  326. package/dist/usage.d.ts +0 -2
  327. package/dist/usage.js +0 -2
  328. package/dist/validate.d.ts +2 -0
  329. package/dist/validate.js +23 -14
  330. package/dist/webhooks.d.ts +102 -76
  331. package/dist/webhooks.js +266 -233
  332. package/dist/workflow-run.d.ts +114 -0
  333. package/dist/workflow-run.js +144 -0
  334. package/dist/workspace/beneath.d.ts +19 -0
  335. package/dist/workspace/beneath.js +106 -0
  336. package/dist/workspace/computer-deps.d.ts +24 -6
  337. package/dist/workspace/computer-deps.js +108 -20
  338. package/dist/workspace/computer-for-claim.d.ts +12 -11
  339. package/dist/workspace/computer-for-claim.js +76 -15
  340. package/dist/workspace/computer-hold.d.ts +6 -1
  341. package/dist/workspace/computer-hold.js +6 -1
  342. package/dist/workspace/computer-janitor.d.ts +47 -0
  343. package/dist/workspace/computer-janitor.js +182 -0
  344. package/dist/workspace/grep-worker.d.ts +5 -0
  345. package/dist/workspace/grep-worker.js +9 -6
  346. package/dist/workspace/index.d.ts +3 -2
  347. package/dist/workspace/index.js +3 -3
  348. package/dist/workspace/local.d.ts +11 -2
  349. package/dist/workspace/local.js +161 -43
  350. package/dist/workspace/resolve-computer.d.ts +50 -10
  351. package/dist/workspace/resolve-computer.js +46 -11
  352. package/dist/workspace/run-tools.d.ts +13 -31
  353. package/dist/workspace/run-tools.js +10 -27
  354. package/dist/workspace-paths.d.ts +0 -17
  355. package/dist/workspace-paths.js +1 -41
  356. package/dist/workspace.d.ts +0 -14
  357. package/dist/workspace.js +3 -96
  358. package/package.json +13 -13
  359. package/templates/README.md +9 -3
  360. package/templates/market-monitor/agent.md +2 -2
  361. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  362. package/dist/bound-files.d.ts +0 -4
  363. package/dist/bound-files.js +0 -164
  364. package/dist/coding-tools.d.ts +0 -47
  365. package/dist/coding-tools.js +0 -189
  366. package/dist/computer-adb.d.ts +0 -12
  367. package/dist/computer-adb.js +0 -14
  368. package/dist/console/assets/index-Dn0ngwG9.js +0 -535
  369. package/dist/console/assets/index-DvW6Aled.css +0 -1
  370. package/dist/grade.d.ts +0 -63
  371. package/dist/grade.js +0 -150
  372. package/dist/mcp-servers.d.ts +0 -269
  373. package/dist/mcp-servers.js +0 -456
  374. package/dist/packs.d.ts +0 -71
  375. package/dist/packs.js +0 -180
  376. package/dist/sealed-settings.d.ts +0 -60
  377. package/dist/sealed-settings.js +0 -171
  378. package/dist/sessions.d.ts +0 -6
  379. package/dist/sessions.js +0 -109
  380. package/dist/workspace/computer-serves.d.ts +0 -12
  381. package/dist/workspace/computer-serves.js +0 -15
package/README.md CHANGED
@@ -65,12 +65,12 @@ An edit is a new revision: `PUT $AGENTRUN_BASE_URL/agents/calc/definition` with
65
65
  | `--faux MODULE` | none | Answer every model request from the module's default export (below). |
66
66
  | `--faux-browser MODULE` | none | With `--faux` only: the `browser` tool's provider and driver from the module's default export, a fake browser with no vendor and no key ([below](#the-faux-model)). The console's real-browser tests run on it. |
67
67
  | `--allow-host NAME` | none | Another `Host` name to accept on a loopback address, on any port. Repeat it. |
68
- | `--max-runs N` | `AGENTRUN_MAX_RUNS`, else as many pi runs as fit | The most runs at once, beside the memory each run's harness reserves ([capacity](#capacity-and-health)). Over either, a new run is `429 rate_limited`. |
68
+ | `--max-runs N` | `AGENTRUN_MAX_RUNS`, else as many pi runs as fit | The most runs the runner beside the server holds at once ([capacity](#capacity-and-health)); a run past that waits `queued` until one ends. Capabilities report the same number (`limits.max_concurrent_runs`), capped by each harness's memory. |
69
69
  | `--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
70
  | `--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
71
  | `--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
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. |
73
- | `--drain-timeout D` | `30s` (the image: `6s`) | How long a busy run may finish its turn when the server stops (`8s`, `500ms`, `1m`). A turn cut off resumes at the next start; its model request is sent again. The server keeps its data directory until its runs' processes have exited (up to this and a second), and says so as it stops; a server started on the same `--data` meanwhile waits for it, saying so, then starts. |
73
+ | `--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
74
 
75
75
  `AGENTRUN_TOKEN`, when set, is the token (32 characters or more), and the server prints `$AGENTRUN_TOKEN` in its
76
76
  place: a token from the environment stays out of the logs. `DIR/.token`'s token is printed only by the start that made
@@ -210,16 +210,12 @@ let a service with a disk change that.
210
210
  ## The disk, and earlier data directories
211
211
 
212
212
  The data directory has two parts. Its own files, the control plane, hold the agent store (`DIR/store.sqlite`, where
213
- each run's row keeps its claim: an epoch and its holder), the token and the server's settings; only the server opens
214
- them. Everything the agents make is on the disk, `DIR/disk/`: one folder per agent, `DIR/disk/agents/<agent>/` (its id
213
+ each run's row keeps its claim: an epoch and its holder), the token and the server's settings; only the server and its
214
+ runners open them. Everything the agents make is on the disk, `DIR/disk/`: one folder per agent, `DIR/disk/agents/<agent>/` (its id
215
215
  in lower case, a dash and 16 hex digits of its SHA-256), with its learning folder (`learning/`) and its runs
216
- (`runs/<id>/`, each with `store/run.sqlite`, its log, and `work/`, where its tools work). Nothing is copied in or out of
217
- a run's folder: where it works, it works in that folder.
218
-
219
- A run's own process writes its `run.sqlite` in WAL, under an exclusive lock, with no automatic checkpoint, and ends
220
- with its WAL in place. The server reads it with a fresh read-only open per read, never shows a read older than one
221
- before, and never opens it for writing while the run's process holds it. Once that process is gone the server takes
222
- the run back (its epoch bumped, the server its holder) and checkpoints its WAL into the database file.
216
+ (`runs/<id>/`, each with `work/`, where its tools work). Nothing is copied in or out of a run's folder: where it
217
+ works, it works in that folder. A run's record is not in its folder: its row, its claim and its journal (what the run
218
+ did, in order) are rows of the store.
223
219
 
224
220
  A data directory an earlier version wrote, with its runs under `DIR/runs/` (or a store of store version 1), is refused
225
221
  at start, saying so: this version neither reads nor moves it. Keep it with that version, or start this one on a new data
@@ -244,9 +240,11 @@ through `POST /v2/agents`. Their earlier runs stay readable where you moved them
244
240
 
245
241
  ## Capacity and health
246
242
 
247
- Each run is a process of its own, and how much memory it takes depends on its harness. The server admits runs by
248
- memory: each run that holds a live process (working, or waiting for an answer) reserves its harness's size out of the
249
- container's limit when it has one (cgroup), else the machine's, less the server's own 128 MiB.
243
+ A run is held by a runner, and how much memory it takes depends on its harness. Capabilities size what a host holds by
244
+ memory: each run reserves its harness's size out of the container's limit when it has one (cgroup), else the machine's,
245
+ less the server's own 128 MiB. The server does not refuse a start for memory: a start inserts a `queued` run, and a
246
+ runner claims it when it has a free loop (300 at once by default; `agentrun-serve runner --loops N` sets it for a
247
+ runner you start yourself).
250
248
 
251
249
  | Harness | Reserved per run | Measured per run |
252
250
  | --- | --- | --- |
@@ -258,21 +256,22 @@ container's limit when it has one (cgroup), else the machine's, less the server'
258
256
  The measure is a short task (write a file, read it back, answer) on a real server in a container of its own; the table
259
257
  in `src/harness.ts` says how it was taken. So a 512 MB instance holds 3 pi runs, 2 codex runs or 1 claude-agent run at
260
258
  once (or 1 codex and 1 pi), 1 GB holds 7, 4 or 3, and 8 GB 63, 42 or 28; an opencode run, OpenCode's own process with
261
- it, needs a 1 GB instance for one and 2 GB for two. A start that does not fit in what is left is
262
- `429 rate_limited` with `retry-after`, its message naming the harness and the memory, and nothing starts: there is no
263
- queue, so the client tries again once a run ends. A harness whose one run needs more than all the memory for runs (claude-agent
264
- on a host under 416 MB, opencode under 832 MB) is unavailable: capabilities say why in its `harnesses` entry, and
265
- its runs are `409 agent_not_runnable` with that reason. pi always has one place, however small the host.
266
-
267
- `--max-runs N` or `AGENTRUN_MAX_RUNS` caps the count as well (by default, as many as pi runs fit), and both limits
268
- apply. Capabilities report pi's count in `limits.max_concurrent_runs`, and each harness's own in its `harnesses` entry
269
- (`max_concurrent_runs`, beside `run_memory_mib`). A message to a run already going is never refused for a place, nor is
270
- the relaunch of one whose process went, and a run's process the next server adopts after a restart holds its harness's
271
- memory there. A run whose harness can never fit (the server restarted on a smaller host) is not started again: it fails
272
- with why if it was working, and a message to it is `409 agent_not_runnable`.
273
-
274
- A data directory serves one AgentRun Server at a time: two servers on a shared disk are not supported (each
275
- counts only its own runs, and a run could be relaunched twice).
259
+ it, needs a 1 GB instance for one and 2 GB for two. A runner holds runs by this memory and by `--max-runs` (below): it
260
+ claims a waiting run only while the runs it holds and that run's size fit the host's memory less the server's 128 MB,
261
+ oldest first, so a run that does not fit yet waits `queued`, the runs behind it too, until one ends. A run is never
262
+ refused for a place. A 2 GB host's default count is 15, as many pi runs as fit, but it holds 6 claude-agent runs at
263
+ once, not 15. A harness whose one run
264
+ needs more than all the memory for runs (claude-agent on a host under 416 MB, opencode under 832 MB) is unavailable:
265
+ capabilities say why in its `harnesses` entry. pi always has one place, however small the host.
266
+
267
+ `--max-runs N` or `AGENTRUN_MAX_RUNS` sets that count (by default, as many as pi runs fit): the runner beside the
268
+ server claims at most that many runs at once, of any harness, and the rest wait queued. A runner of its own
269
+ (`agentrun-serve runner`) holds `--loops N`, else the same default. Capabilities report it: pi's in
270
+ `limits.max_concurrent_runs`, and each harness's own, the lower of that and what its memory holds, in its `harnesses`
271
+ entry (`max_concurrent_runs`, beside `run_memory_mib`).
272
+
273
+ A data directory serves one AgentRun Server at a time: a second server on the same data root is refused at start
274
+ (`server.lock`).
276
275
 
277
276
  `GET /v2/health`, with no credential like capabilities, answers `200 {status: "ok", checks: {store: "ok", disk: "ok"}}`
278
277
  when the agent store opens for a read and the data directory's disk has at least 64 MiB free (`AGENTRUN_MIN_FREE_MB`),
@@ -281,12 +280,12 @@ and `503` with `status: "failing"` and which check failed (`store: "does_not_ope
281
280
  It names no path, size or version. One route serves as both liveness and readiness: any answer says the server is up,
282
281
  and a 200 says it can work, and the platforms here take one path.
283
282
 
284
- A run whose end the agent store cannot take (a full disk) still ends: a cancel makes it `cancelled`, with its cost from
285
- its rows, and the server writes the end to the store again every 30 s until it lands; a restart before then reads the
286
- run as the store last had it. A run whose process was killed is opened again on its next message at once: the run's row
287
- names its process (its pid, that process's start and this boot), and a process that is gone holds nothing. One server
288
- serves a data root, and the agent disk under it (`<data>/disk`): a second server on the same root is refused at start
289
- (`server.lock`), so the row's claim never has two servers claiming it at once.
283
+ A run's runner renews its claim on the run every 10 s, for a claim of 30 s. A runner that stops, or cannot renew in
284
+ time, writes nothing more to the run, and the store refuses any write under a claim the run has moved past. Once the
285
+ claim lapses another runner claims the run and resumes it from its journal. `agentrun-serve runner --check --data DIR --name N`
286
+ (or `AGENTRUN_RUNNER_NAME=N` in place of `--name`) says whether the runner named `N` has a fresh heartbeat: it exits 0
287
+ when it does and 1 when it does not, and 2 when no name is given. Name a runner you start yourself with
288
+ `agentrun-serve runner --data DIR --name N`.
290
289
 
291
290
  ## Sandbox
292
291
 
@@ -339,9 +338,11 @@ and `GET /v2/runs/{id}` shows it as `place`. A harness's own tools in the box, w
339
338
  `sandbox` (such as `native_tools: true`), never a third mode.
340
339
 
341
340
  `bash` may be named only by an agentic definition whose place is a sandbox (`422` on a runner, named or by default, with
342
- the sandbox place as its `fix`), and a workflow's place is `runner` or none (`422` on a sandbox, with the runner place as
343
- its `fix`). In `capabilities.tools`, `bash` is `available: false` with a `reason` (`no box is set up on this server: …`,
344
- each box's own reason) when no box this server has can run it.
341
+ the sandbox place as its `fix`), or, in Mode 2, by one on the runner, where `bash` runs on Archil's serverless exec
342
+ ([where `bash` runs](#computers)); the background tools run in a box alone, in either mode. A workflow's place is `runner`
343
+ or none (`422` on a sandbox, with the runner place as its `fix`). In `capabilities.tools`, `bash` is `available: false`
344
+ 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
+ the server is in Mode 1.
345
346
 
346
347
  `GET /v2/capabilities` lists `places`: the modes, the default, a new agent's place, and each box with `available`, its `state` (`ready`,
347
348
  `preparing` while the server builds or pulls its image, or `unavailable`) and, when it is not ready, the `reason`.
@@ -454,9 +455,9 @@ go through `work/` by path.
454
455
  `LANG=C.UTF-8` and `HOME=/tmp` and the image's own: never this server's, so no key or token is in it. It runs as this
455
456
  server's uid:gid, so what it writes in `work/` stays this server's. It starts from [the box's image](#the-boxs-image).
456
457
  It may use 2 CPUs' time, 4 GiB of memory, swap included, and 1,024 processes and threads (`--cpu-period 100000
457
- --cpu-quota 200000 --memory 4g --memory-swap 4g --pids-limit 1024`), so a runaway build or a fork bomb stops in the
458
- box. `AGENTRUN_BOX_CPUS` (at least `0.01`), `AGENTRUN_BOX_MEMORY` (with its unit, such as `8g`, and at least `6m`) and
459
- `AGENTRUN_BOX_PIDS` (at most 4,194,304) change them; any other value refuses the start. `AGENTRUN_BOX_CPUS` caps CPU
458
+ --cpu-quota 200000 --memory 4096m --memory-swap 4096m --pids-limit 1024`), so a runaway build or a fork bomb stops in
459
+ the box. `AGENTRUN_BOX_CPUS`, `AGENTRUN_BOX_MEMORY` and `AGENTRUN_BOX_PIDS` change them, for Docker computers only
460
+ ([a Docker computer's size](#computers)). `AGENTRUN_BOX_CPUS` caps CPU
460
461
  time, as a CFS quota (the cap `--cpus` sets), so it holds whatever CPU count Docker's VM has, and where the kernel
461
462
  gives Docker no CPU controller (a rootless Docker without one delegated), Docker ignores it with a warning.
462
463
  - `bash` takes pi's `{command, timeout?}`, `timeout` in seconds, 300 when the call names none; a timeout kills the
@@ -626,10 +627,8 @@ is Modal's default sandbox runtime (gVisor), not a virtual machine: the server d
626
627
  show the box's `network` as `none`, with `network_reason`, unless the setting is `none`.
627
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
628
629
  with the run's `work/`. The call that met the gone box fails, saying so.
629
- - Each Modal sandbox reserves 2 CPUs and 4 GiB of memory by default, which the provider bills for while the box lives:
630
- the Docker box's defaults, asked of the provider as the sandbox's CPU and memory. `AGENTRUN_BOX_CPUS` and
631
- `AGENTRUN_BOX_MEMORY` change both boxes alike (such as `AGENTRUN_BOX_CPUS=1 AGENTRUN_BOX_MEMORY=1g`). The provider has
632
- no process limit, so `AGENTRUN_BOX_PIDS` does not apply. Its lifetime is 24 hours, as every box's is.
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.
633
632
  - A start copies back, then ends, the sandbox of every run that has ended or is archived.
634
633
 
635
634
  ### The box's image
@@ -721,7 +720,12 @@ Settings → Computers. The kind says what the agent is given, and the provider
721
720
  | `browser` | A hosted browser (the browser tools) | `browserbase`, `kernel` |
722
721
 
723
722
  A kind with no provider, a provider that does not serve the kind, or a provider whose required keys are not saved is
724
- refused before anything starts, in words that name the fix in Settings → Computers. `GET /v2/computers` lists each kind,
723
+ refused before anything starts, in words that name the fix in Settings → Computers. A Docker computer needs a Docker
724
+ daemon on this server: where none answers `docker version` (Render and most hosted services run none), Docker is not
725
+ ready and says to use a vendor's computer. The server asks again every 30 s, so a daemon that stops is seen. A daemon
726
+ started after the server is taken at the next restart, since the start's checks of Docker (its host, this server's
727
+ paths and addresses) ran without it.
728
+ `GET /v2/computers` lists each kind,
725
729
  whether this server offers it now, the tools it brings, and each provider with its key names and whether each is saved
726
730
  (never a value). `PUT /v2/computers/{provider}/keys` saves a provider's keys, sealed under the server's seal key, from
727
731
  the owner's signed-in session only (the API token is 403), and `POST /v2/computers/{provider}/test` makes one read at
@@ -732,6 +736,30 @@ the provider with them and starts nothing. A key set in the server's environment
732
736
  computer time. The older [`place`](#place) is this setting's v2 view: `{"mode": "runner"}` is kind `none`, and
733
737
  `{"mode": "sandbox", "box": X}` is a sandbox on provider X. Writing either sets both.
734
738
 
739
+ **A Docker computer's size.** A Docker computer, a sandbox or a desktop, may use 2 CPUs' time, 4 GiB of memory with swap
740
+ included, and 1,024 processes and threads, unless the server's environment says otherwise: `AGENTRUN_BOX_CPUS` (at least
741
+ `0.01`, such as `1.5`), `AGENTRUN_BOX_MEMORY` (a size with its unit, `b`, `k`, `m` or `g`, such as `8g`: at least `6m`,
742
+ a fraction of a MiB dropped) and `AGENTRUN_BOX_PIDS` (from 1 to 4,194,304). The claim puts them on the computer's spec,
743
+ and the Docker provider runs the container with them (`--cpu-quota`, `--memory` and `--memory-swap`, `--pids-limit`).
744
+ They apply to Docker computers only: a vendor's computer (Daytona, Modal, E2B, Orgo, a phone, a hosted browser) is the
745
+ size its provider makes it, and is never given them. A value the Docker provider refuses stops the server's start, in
746
+ the provider's words.
747
+
748
+ **GPUs.** A sandbox may ask for GPUs: `computer: {"kind": "sandbox", "provider": "daytona", "gpu": {"type": "H100",
749
+ "count": 1}}`. `GET /v2/computers` shows each sandbox provider's `gpu`: the types it gives, by the vendor's own names, the
750
+ most one computer gets, and where a GPU computer differs from its others. A provider whose GPU computers cannot hold
751
+ this server's run folder says why there. The save checks the shape, and only a sandbox takes one. The run's start (409)
752
+ and the claim refuse a type or a count the provider does not give, in the computer package's `checkGpu` words, and the
753
+ computer is made with the GPUs asked.
754
+
755
+ - **Daytona** gives `H100`, `H200`, `RTX-PRO-6000`, `RTX-4090`, `RTX-5090` and `MI355X`, up to 8. A GPU sandbox runs
756
+ in region `earth`. Stopping it deletes it: it has no pause and no snapshot, so nothing on it outlives the run. Each GPU
757
+ comes with 16 vCPU, 192 GiB of memory and 512 GiB of disk. A Daytona GPU may be preempted, so a run on one can be
758
+ cut short. The Daytona org needs GPU credits. A Daytona GPU sandbox with the run's folder mounted from Archil, and
759
+ its network allowlist, are not yet proven live.
760
+ - **Modal** declares its GPUs, but a Modal GPU sandbox runs on gVisor, and the Archil mount the run's folder needs is not
761
+ proven there. So this server refuses a Modal sandbox with a `gpu` for now. A Modal GPU is also preemptible.
762
+
735
763
  **Where the run's folder lives.** A server keeps its runs' folders in one of two modes:
736
764
 
737
765
  - **Mode 1** (the default): on this server's own disk. Only a provider that binds a folder of this machine can hold
@@ -774,8 +802,10 @@ no computer.
774
802
  registries and GitHub) through its egress proxy, and nothing else; `AGENTRUN_BOX_ALLOW=none` gives it no network. From a
775
803
  server in a container the proxy also refuses the Docker host's own addresses, which the server reads through the socket
776
804
  ([in the published image](#in-the-published-image)). A
777
- Daytona, Modal or E2B sandbox has no network of its own (loopback only). A phone and a browser are on their vendor's
778
- own network, whatever the list says.
805
+ Daytona, Modal or E2B sandbox has no network of its own (loopback only). A phone and a hosted browser are on their
806
+ vendor's own network, whatever the list says. Local Chrome is open unless this server sets `AGENTRUN_BOX_ALLOW`; then
807
+ only those hosts (the default list, a sandbox's package registries, is no browsing policy). Under
808
+ `AGENTRUN_BOX_ALLOW=none`, each of these is refused at the run's start, in words that name the setting.
779
809
 
780
810
  **Docker.** A Docker computer runs where this server's Docker answers. With `AGENTRUN_BOXES` not set at all (a plain
781
811
  `npx @parcha/agentrun`), the server probes `docker` at its start (within 5 s) and offers it when Docker answers
@@ -847,7 +877,7 @@ A definition is checked for what keeps it from running here when it is saved, wi
847
877
  it starts:
848
878
 
849
879
  - What no setting of this host fixes refuses the save, `422 input_invalid` by field, and nothing is written: a tool
850
- this host does not bind (`definition.tools[i]`), `bash` on an agent whose place is not a sandbox, a model pi-ai does
880
+ this host does not bind (`definition.tools[i]`), `bash` on an agent whose place is not a sandbox (in Mode 1), a model pi-ai does
851
881
  not know when no gateway is set (`definition.model`, saying why), empty instructions (`definition.instructions`), and a workflow that needs a tool
852
882
  call this host does not run, code, or a node tool other than `read`, `write` and `edit` (`definition.workflow`, one
853
883
  field per need).
@@ -860,11 +890,13 @@ it starts:
860
890
  A run is refused before it starts, `409 agent_not_runnable`, saying which, for any of these: a warning the host has not
861
891
  fixed yet, or a revision saved before these checks. A run needs only the tiers it uses: an agentic one its model or the default, a workflow the tiers its nodes name, so a
862
892
  workflow of fast nodes runs with `AGENT_MODEL_FAST` and no `AGENT_MODEL`. A run thinks at its `effort` (`low`, `medium`,
863
- `high`), else at its agentic revision's `thinking` (`low` to `max`), else at the host's `AGENT_THINKING`, else at medium;
864
- it is never off, and a model node that names its own thinking level keeps it. An agentic run started with an `effort` also
865
- gets a short note on how to work, right after its instructions, on every harness (`src/effort-guidance.ts`): `low`
866
- answers directly, `medium` plans briefly and checks once, `high` plans each part, fills the gaps and reviews. A run
867
- started with none gets no note.
893
+ `high`), else at its agentic revision's `thinking` (`low` to `max`), else at the host's `AGENT_THINKING` (one of those
894
+ levels exactly), else at its harness's own default; it is never off, and a model node that names its own thinking level
895
+ keeps it. The level is fixed in the run's launch when it starts, and its metrics name the level its harness ran at: one
896
+ above the harness's highest runs at that highest (Codex and OpenCode stop at `xhigh`). An agentic run whose level is
897
+ `low`, `medium` or `high` also gets a short note on how to work, right after its instructions, on every harness
898
+ (`src/effort-guidance.ts`): `low` answers directly, `medium` plans briefly and checks once, `high` plans each part, fills
899
+ the gaps and reviews. A run with no level, or one above `high`, gets no note.
868
900
 
869
901
  ## Tools
870
902
 
@@ -881,7 +913,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
881
913
  | `read` | Read a file in the run's `work/`; in a box, also an image (png, jpg, gif, webp, by its bytes) at any absolute path in the box, such as one rendered to `/tmp`, read through the box and never from the host | nothing | yes, no |
882
914
  | `write` | Write a file in the run's `work/` | nothing | yes, no |
883
915
  | `edit` | Edit a file in the run's `work/` | nothing | yes, no |
884
- | `bash` | Run a shell command in the run's box, from its `work/`: pi's `{command, timeout?}`, 120 s when the call names no timeout and at most 600 s (a longer one runs at 600 s and says so; longer work is `bash_background`) | an agentic definition whose place is a sandbox ([Sandbox](#sandbox)) | no, no |
916
+ | `bash` | Run a shell command in the run's box, from its `work/`: pi's `{command, timeout?}`, 120 s when the call names no timeout and at most 600 s (a longer one runs at 600 s and says so; longer work is `bash_background`) | an agentic definition whose place is a sandbox ([Sandbox](#sandbox)), or one on the runner in Mode 2 (Archil's serverless exec, at most 295 s) | no, no |
885
917
  | `bash_background` | Start a shell command in the background in the run's box, from its `work/`, and answer its id at once: `{command, tty?}` in, `tty: true` for a terminal. Its stdout and stderr go to `work/background/<id>/output.log`, the first 16 MiB; at most 8 run at once ([background processes](#background-processes)) | an agentic definition whose place is a sandbox | no, no |
886
918
  | `bash_output` | Read a background process's output from a byte offset: `{id, offset?, max_bytes?}` in (at most 48 KiB a call), its state, exit code, the log's size and the next offset out | an agentic definition whose place is a sandbox | no, no |
887
919
  | `bash_input` | Write to a running background process's stdin: `{id, text, close?}` (at most 64 KiB a call) | an agentic definition whose place is a sandbox | no, no |
@@ -1178,9 +1210,8 @@ picks which one a run gets, never the model.
1178
1210
  (`agentrun-` and 24 hex digits: Kernel's names are its account's, so a name derived from the agent would be any
1179
1211
  server's that shares the key). This
1180
1212
  server keeps only a pointer per agent and vendor, sealed under the seal key (`AGENTRUN_SEAL_KEY`) and bound to its
1181
- agent, in `<data>/homes/<key>/sign-ins/sign-ins.json`. With no seal key nothing is kept and runs start signed out;
1182
- capabilities say `sign_ins: true` only with a seal key and a browser vendor here. A local Chrome keeps none: its
1183
- cookies would sit on this server's disk.
1213
+ agent and vendor, in its store. Capabilities say `sign_ins: true` with a browser vendor here. A local Chrome keeps
1214
+ none: its cookies would sit on this server's disk.
1184
1215
  - **How a run gets it.** Before a run with the `browser` tool is launched, the server makes the agent's context at
1185
1216
  Browserbase (`POST /v1/contexts`, which opens no session; Browserbase bills sessions, not contexts) or its profile at
1186
1217
  Kernel (`POST /profiles`, which starts no browser) if it has none,
@@ -1319,8 +1350,8 @@ another server's by then. Under `--faux` a key is checked only against the fake
1319
1350
  with is checked under `--faux` only against a check's own fake (`fauxBrowserbase`, `fauxMonidCheck`, `fauxKernel`), so the fakes the runs use see the
1320
1351
  runs' calls alone; with none, its `check` stays null.
1321
1352
 
1322
- A saved key is kept only as ciphertext: AES-256-GCM in `DIR/tool-keys.json` (0600), each value bound to its field's
1323
- name, under the seal key `AGENTRUN_SEAL_KEY`, which only the server opens it with. A run's process never gets the seal
1353
+ A saved key is kept only as ciphertext: AES-256-GCM in the server's store, each value bound to its field's name, under
1354
+ the seal key `AGENTRUN_SEAL_KEY`, which only the server opens it with. A run's process never gets the seal
1324
1355
  key. With `AGENTRUN_SEAL_KEY` not set, the server keeps it in `seal/seal.key` in its data directory, beside the store,
1325
1356
  making it at the first start: 32 random bytes in base64, 0600 in a 0700 directory, and one another user can read is
1326
1357
  refused, not changed. It lives and dies with the data (a disk, a volume): back it up with the data directory, and keep
@@ -1385,22 +1416,20 @@ naming the limit and how many tools were read.
1385
1416
 
1386
1417
  `PUT /v2/settings/mcp-servers/{name}` previews the same way, then keeps the server: its URL, the tools it listed (the
1387
1418
  snapshot an agent will be shown) and its credential. A name is lowercase letters, digits and dashes, starting with a
1388
- letter, at most 32, with no underscores, so `mcp__<server>__<tool>` splits one way. Each credential header's value is
1389
- sealed like a [tool key](#tool-keys): AES-256-GCM under `AGENTRUN_SEAL_KEY`, bound to the server's name and the header,
1390
- in `DIR/mcp-servers.json` (0600, written whole, synced and renamed), which holds no value in the clear. With no seal key,
1391
- a server that takes a credential is `409 no_sealing_key`, before anything is contacted; one with `auth.type` none is
1392
- kept. A `PUT` that sends no `token` (or no `headers`) keeps the sealed credential, as long as the auth type and the URL's
1393
- origin stay the same: a saved credential never goes to another origin unless you send it again.
1394
-
1395
- `GET /v2/settings/mcp-servers` and `GET .../{name}` show each server with `credential`: `sealed`, `seal_key_missing`
1396
- (no seal key now) or `unreadable` (sealed under another key, or damaged: a `PUT` with the credential seals it again),
1397
- null for `auth.type` none. No read, log line or error shows a credential; a server's error text is cut of the values
1398
- sent before it is shown. `POST .../{name}/refresh` lists the tools again with the saved URL and credential, keeps them,
1399
- and answers `{added, removed, changed, server}`: `changed` names a tool whose title, description, schemas or
1400
- annotations differ. `DELETE .../{name}` forgets the server and its credential. A saved-servers file that does not read (damaged, or
1401
- another format) is never written over: the list answers `servers: []` with `file_unreadable: true`, and every other
1402
- route is `409 store_unreadable` until the file is restored or removed. Capabilities' `features.mcp_client`
1403
- says `transports: ["streamable-http"]`, the `auth` types and `at_rest` (`sealed`, or `unavailable` with no seal key).
1419
+ letter, at most 32, with no underscores, so `mcp__<server>__<tool>` splits one way. The credential is sealed like a
1420
+ [tool key](#tool-keys): AES-256-GCM under `AGENTRUN_SEAL_KEY`, bound to the server's name and its URL's origin, in the
1421
+ data directory's store, which holds no value in the clear. The server does not start without its seal key. A `PUT` that
1422
+ sends no `token` (or no `headers`) keeps the sealed credential, as long as the auth type and the URL's origin stay the
1423
+ same: a saved credential never goes to another origin unless you send it again.
1424
+
1425
+ `GET /v2/settings/mcp-servers` and `GET .../{name}` show each server with `credential`: `sealed`, `unreadable` (sealed
1426
+ under another key, or damaged: a `PUT` with the credential seals it again) or `expired` (an OAuth sign-in whose refresh
1427
+ its authorization server refused: sign in again), null for `auth.type` none. No read, log line or error shows a
1428
+ credential; a server's error text is cut of the values sent before it is shown. `POST .../{name}/refresh` lists the
1429
+ tools again with the saved URL and credential, keeps them, and answers `{added, removed, changed, server}`: `changed`
1430
+ names a tool whose title, description, schemas or annotations differ. `DELETE .../{name}` forgets the server and its
1431
+ credential. Capabilities' `features.mcp_client` says `transports: ["streamable-http"]`, the `auth` types and `at_rest:
1432
+ "sealed"`.
1404
1433
 
1405
1434
  ### Signing in with OAuth
1406
1435
 
@@ -1500,8 +1529,13 @@ asked by default.
1500
1529
  - **A call** goes to the pinned URL alone, the 2026-07-28 revision first and a 2025-era server through its
1501
1530
  `initialize`; on 2026-07-28 each `x-mcp-header` parameter of the pinned tool is sent as its `Mcp-Param-*` header. No
1502
1531
  redirect is followed, at most 4 MiB is read, and it may take 120 s. The
1503
- model reads the text blocks joined; past 60,000 characters, or with blocks that are not text, the whole answer is
1504
- filed under the run's `evidence/mcp/<server>/` and the text says where. A tool's own error (`isError`) reaches the
1532
+ model reads the text blocks and embedded text resources joined (GitHub's `get_file_contents` answers a file as one);
1533
+ past 60,000 characters it reads the answer's first lines, whole, and the rest is filed under the run's
1534
+ `evidence/mcp/<server>/` as lines (JSON laid out a value a line, its indent capped at 32 levels, and filed as
1535
+ written when the layout would pass twice its size and 64 KiB; a line past 10,000 characters broken), the text
1536
+ naming the file and the `read` offset that goes on, so a run with `read` and no shell pages through it. With blocks
1537
+ that are neither (an image, a blob), the whole answer is filed there as JSON and the text says where. On pi, every
1538
+ host tool's answer reaches the model whole within the host's result bound, as each CLI harness is told. A tool's own error (`isError`) reaches the
1505
1539
  model as its error. A refused credential (401, 403) reads "the MCP server <name> refused its credential (its sign-in
1506
1540
  expired or was revoked, or its key changed): sign in again in Settings → MCP servers, or update its credential
1507
1541
  there"; another failure names the server and the HTTP status, never a header. A stop, or a
@@ -1552,19 +1586,19 @@ or `https` address, with no user or password in it. Loopback and private-network
1552
1586
  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
1553
1587
  need its person (`input_required`: a question, a call held for approval, a pause at its cap, an ask for its person in
1554
1588
  its browser, desktop or phone, or a stopped turn) and `run.ended` when it ends
1555
- (completed, failed or cancelled, once carried back). A [schedule](#schedules) whose firing fails sends a third,
1589
+ (completed, failed or cancelled, once the run's end is written). A [schedule](#schedules) whose firing fails sends a third,
1556
1590
  `trigger.failed`; a server with no triggers never sends one.
1557
1591
 
1558
1592
  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
1559
1593
  store, so the row's `ended_at` and the message's `webhook-id` name one time. `run.ended` is queued only once the agent
1560
1594
  store has the end, so a receiver that reads the run back on its message (`GET /v2/runs/{id}`) reads it ended; while the
1561
1595
  store refuses the end (a full disk, a busy store), nothing is sent, until a later try of the write or the next server
1562
- stores it. The outbox (`DIR/webhook-outbox.json`) keeps, in the same write as each message, which end and which wait of
1596
+ stores it. The outbox, in the store with the runs, keeps, in the same write as each message, which end and which wait of
1563
1597
  each run it queued. A server that starts queues any end of the last day that the agent store holds and the outbox does
1564
1598
  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
1565
1599
  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
1566
1600
  `webhook-id`. An end before the webhook was set is never sent. A run is continued only once its end's
1567
- `run.ended` is in the outbox on disk (`503` meanwhile), so a continued run's next end is its own, under its own id.
1601
+ `run.ended` is in the outbox (`503` meanwhile), so a continued run's next end is its own, under its own id.
1568
1602
 
1569
1603
  ```json
1570
1604
  { "type": "run.needs_input", "timestamp": "2026-11-01T12:00:00.000Z",
@@ -1587,15 +1621,15 @@ with any of its libraries: `webhook-id` (the same on every try of a message, so
1587
1621
  the secret's bytes. A receiver checks the signature against the raw body and refuses a timestamp more than 5 minutes
1588
1622
  from its clock, so a replay does not pass. The first `PUT` makes the secret, `whsec_` and 32 random bytes in base64,
1589
1623
  and answers `201` with it, once; `GET /v2/settings/webhook` never shows it. It is kept like a [tool key](#tool-keys):
1590
- sealed under `AGENTRUN_SEAL_KEY` in `DIR/webhook.json` (0600), so with no seal key no webhook is set
1591
- (`409 no_sealing_key`). A new secret is a `DELETE` and a `PUT`.
1624
+ sealed under `AGENTRUN_SEAL_KEY`, in the store (SQLite or Postgres) with the webhook itself. A new secret is a `DELETE` and a
1625
+ `PUT`; a secret that no longer opens under the server's key (sealed under another) is replaced, and shown once, by the next `PUT`.
1592
1626
 
1593
1627
  A try that is not answered 2xx within 15 s fails; a redirect is not followed. A failed message is tried again on the
1594
1628
  spec's schedule, with jitter: after about 5 s, 5 min, 30 min, 2 h, 5 h and 10 h, then logged as failed
1595
1629
  (`event=webhook condition=delivery_failed`). Each message goes on its own tries, so two queued close together can
1596
1630
  arrive in either order: a receiver orders them by `webhook-timestamp`, or reads the run (`GET /v2/runs/{id}`). A
1597
- `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 `DIR/webhook-outbox.json`, so the next server goes on with
1598
- them after a restart; a message can then come twice, under the same `webhook-id`. An outbox file of another version
1631
+ `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
1632
+ them after a restart; a message can then come twice, under the same `webhook-id`. An outbox of another version
1599
1633
  is not read: the server starts with none, and the log says so (`condition=outbox_not_read`). `GET /v2/settings/webhook/deliveries`
1600
1634
  lists the last 50 attempts (`webhook_id`, type, status code, latency, error, when, and the next try's time), and
1601
1635
  `POST /v2/settings/webhook/deliveries/{webhook_id}/redeliver` sends one of those messages again, once, under the same
@@ -1631,7 +1665,7 @@ a restart drives again finds its run. A firing's key stays bound to that run: wh
1631
1665
  run up, the firing reads `failed` ("The server stopped while setting up the run.") with that run's id, it never fires
1632
1666
  again, the next firing goes ahead, and `POST /v2/triggers/{id}/fire` is how a person tries it again. While the trigger's last run is active (working, or waiting on a person), a firing
1633
1667
  is `skipped`, with why (a webhook trigger with `accept` or `max_active_runs` is the exception: [each event it
1634
- takes](#webhook-triggers) starts its own run); a full server (`429`) keeps it due and tries again. Times missed while the server was down are
1668
+ takes](#webhook-triggers) starts its own run); a firing over the run limit starts its run `queued`, and one the server can't take now (busy or unavailable) stays due and is tried again. Times missed while the server was down are
1635
1669
  one `missed` firing with their count, and the schedule goes on from now; the latest of them still fires, once, when it is
1636
1670
  no older than the trigger's `catchup_window_s` (default an hour; 0, never), marked `catch_up`. A
1637
1671
  firing while the last run is active (working, or parked waiting on a person) is skipped with why, never queued,
@@ -1663,8 +1697,7 @@ anything else. A bad signature, a stale timestamp, an unknown trigger, one that
1663
1697
  answer the same `401`, so no trigger id can be found by asking; a body past 256 KiB is `413`.
1664
1698
 
1665
1699
  The secret, `whsec_` and 32 random bytes in base64, is made with the trigger and shown in the `201` once; no `GET`
1666
- shows it. It is kept sealed under `AGENTRUN_SEAL_KEY` in `DIR/trigger-settings-webhook.json` (each trigger source's
1667
- sealed settings have a file of their own), so with no seal key no webhook trigger is made (`409 no_sealing_key`).
1700
+ shows it. It is kept sealed under `AGENTRUN_SEAL_KEY` in the server's store, with each trigger source's other sealed settings.
1668
1701
  `POST /v2/triggers/{id}/secret` makes a new one, shown once, and the old one signs nothing from then on. Like every
1669
1702
  secret this server keeps (its tokens, its outbound webhook's secret), it is cut from what a run shows, from what an
1670
1703
  import keeps and from every learning text. A secret replaced by a rotation, or whose trigger is deleted, is kept too,
@@ -1672,8 +1705,7 @@ sealed in a retired row of its own (scope `retired:<trigger>:<n>`), never a sett
1672
1705
  before is still cut on every later server. Retired rows are kept for good for now; dropping one once no run older than
1673
1706
  it is left is still to come. A secret that does not open under the seal key the server starts with is
1674
1707
  said in its log (`condition=trigger_setting_unopened`, naming the trigger), and its trigger is refused until a new
1675
- secret is made. A `trigger-settings-webhook.json` that does not read is never written over: until it is fixed or moved
1676
- away, no webhook trigger is made or rotated (`409 store_unreadable`) and none fires.
1708
+ secret is made.
1677
1709
 
1678
1710
  The request's `webhook-id`, which its signature covers, is its firing's key: the first answers `202` once the firing is
1679
1711
  recorded, and its run starts after; the same `webhook-id` again, for a day after, answers `200` with that firing and
@@ -1729,15 +1761,15 @@ conditions holding. A verified delivery no rule takes (GitHub's `ping` among the
1729
1761
  `accept`, every verified request fires, as before. A trigger holds at most 20 rules, each at most 20 conditions and 20
1730
1762
  actions; an `in` lists at most 20 values of at most 1024 characters of JSON each, a pointer is at most 512 characters,
1731
1763
  and an event, an action or a prefix at most 200. A trigger with `accept` starts a run for each event it takes, its last
1732
- run active or not, since the events it takes are each their own work (a review per pull request); the server's run
1733
- limit still holds: a start it refuses (`429`) keeps the firing due and tries it again, and past 20 firings due a new
1734
- delivery answers `429`. This holds for every firing of such a trigger, a run now (`POST /v2/triggers/{id}/fire`)
1735
- included. Runs start in the order their events came while the server has room; while one firing waits to be tried
1736
- again after a `429`, a later one can start first.
1737
-
1738
- Such a trigger can take every run this server has room for, starving other triggers and the runs people start. Give it
1739
- `max_active_runs` (1 to 100; `null` clears it): past that many of its runs active, a firing waits due and is tried
1740
- again, as at a full server, and is never skipped. It counts the runs this trigger started while they work, kept apart
1764
+ run active or not, since the events it takes are each their own work (a review per pull request); the run limit still
1765
+ holds on the runner: a run past it waits `queued`. A start the server can't take now keeps the firing due and tries it
1766
+ again, and past 20 firings due a new delivery answers `429`. This holds for every firing of such a trigger, a run now
1767
+ (`POST /v2/triggers/{id}/fire`) included. Runs start in the order their events came; while one firing waits to be
1768
+ tried again, a later one can start first.
1769
+
1770
+ Such a trigger can fill the runner's places and the queue behind them, starving other triggers and the runs people
1771
+ start. Give it `max_active_runs` (1 to 100; `null` clears it): past that many of its runs active, a firing waits due and
1772
+ is tried again, and is never skipped. It counts the runs this trigger started while they work, kept apart
1741
1773
  from its history (so a long run counts however many firings follow it) and read again at each check; a run a person
1742
1774
  opens again after it ended is that person's follow-up, not counted. Any `start_run` trigger of a pushed source (a
1743
1775
  webhook) takes it, with or without `accept`: set, each event starts its own run, never skipped behind the last, up to the
@@ -1881,7 +1913,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
1881
1913
  | `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
1882
1914
  | `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. |
1883
1915
  | `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. |
1884
- | `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)). A field the store does not keep (`input_schema`, `output_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)). |
1916
+ | `POST /agents`, `GET /agents`, `GET /agents/{id}` | `POST` takes `{definition, skills?, note?}` and makes the agent with its first revision, current. A definition has `instructions` (an agentic revision) or `workflow` (a workflow revision, checked by the DSL first), and `name`, `description`, `model` and `thinking` (agentic only), `harness` ([harnesses](#harnesses)), `place` ([place](#place)), `tools`, `tool_settings` ([search and fetch](#search-and-fetch)), `skills` (names; each `<name>/SKILL.md` is in `skills`) and `version`, which is the number the revision gets, and `max_cost_usd`, the agent's default cap (an agentic agent's or a workflow's), kept by an edit that leaves it out and cleared only by 0, and `cap_mode`, how such a cap prices a request, `expected` or `strict` ([spend cap](#spend-cap)), and `output_schema` (agentic only, at most 64 KiB): the JSON Schema the final answer's last fenced json block meets, which a completed run's `result.output` then holds (null when the answer doesn't meet it), kept by an edit that leaves it out. A template's answer schema is set here at apply, and a run a trigger starts is handed that trigger's last completed `result.output` after its message. A field the store does not keep (`input_schema`) is `422 input_invalid` by name, and so is a definition that can never run here; one this host cannot run yet saves with `warnings` ([models](#models)). The ETag (`home_etag`) is the current revision's id. `GET /agents/{id}` adds `tools`, the tools its current revision grants with each one's provider ([search and fetch](#search-and-fetch)). |
1885
1917
  | `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. |
1886
1918
  | `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
1887
1919
  | `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
@@ -1891,7 +1923,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
1891
1923
  | `GET /runs` | Every agent's runs, newest first, a page of at most 100; `agent`, `revision` and `status` narrow it, and `archived=true` lists only archived ones. A failed run's summary carries its `error`, and a waiting run's its `pending`. |
1892
1924
  | `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what a waiting run waits on, by `kind`: `{kind: "question", question, asked_at}` for a question it asked a person; `approval` for a tool call held for a person's approval, with the tool, its arguments and its price; `budget` for a run paused at its cap ([a run paused at its cap](#a-run-paused-at-its-cap)); `{kind: "browser", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner in its browser; or `{kind: "computer", computer: "desktop" | "phone", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner on its desktop or phone; else null, a stopped turn's included) and cost (`basis: estimate`; $0 before its first model request, a cancelled run's included). |
1893
1925
  | `GET /runs/{id}/timeline` | JSON pages with the change-number cursor (`after`, `next_after`, `reset`, `drop`, `has_more`, `final`, `wait_ms` long poll, and this server's own `limit`, 1 to 500 rows a page, default 500), or server-sent events with `Accept: text/event-stream` (`id` is the cursor, `Last-Event-ID` resumes). Rows sort by `seq`; the usage row (`Cost so far`), the run's running total, is always the last row, and moves to the end when a row comes after it. |
1894
- | `POST /runs/{id}/messages` | To an agentic run: `steer` while the agent works, `answer` when it asked the person, `follow_up` after a stop or after it completed: a completed run opens again, the same run on its own session and store, takes a place under `--max-runs` (`429` when none is free), and completes again. A failed or cancelled run, an archived run and a run of an archived agent are `409 not_continuable`; a workflow run takes none (`501`). |
1926
+ | `POST /runs/{id}/messages` | To an agentic run: `steer` while the agent works, `answer` when it asked the person, `follow_up` after a stop or after it completed: a completed run opens again, the same run on its own session and store, takes a place under `--max-runs` (it waits for one when none is free), and completes again. A failed or cancelled run, an archived run and a run of an archived agent are `409 not_continuable`; a workflow run takes none (`501`). |
1895
1927
  | `POST /runs/{id}/stop`, `POST /runs/{id}/cancel` | Stop ends an agentic run's turn and leaves the run `input_required` and idle. Cancel ends a run `cancelled` once its process has exited. |
1896
1928
  | `POST /runs/{id}/archive`, `POST /runs/{id}/unarchive` | [Archiving](#archiving) one run. Answers the run, with `archived_at`. |
1897
1929
  | `GET /runs/{id}/files`, `GET /runs/{id}/files/{path}` | The files under the run's `work/`, raw. |
@@ -1913,8 +1945,9 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
1913
1945
  | `POST /mcp` | This server's own route (`x-agentrun-serve: "mcp/1"`): the [MCP endpoint](#for-coding-agents), Streamable HTTP with one JSON-RPC message per POST (`initialize`, `ping`, `tools/list`, `tools/call`), answered as JSON, stateless. Its ten tools call these routes in process with the caller's token. The Bearer token only, never the page's cookie; a browser `Origin` other than this server's own is `403`; any other method is `405`. |
1914
1946
  | `GET /usage` | The runs' cost estimates, by meter, agent, key, day or region (`key` and `region` are one line, `local`). A run of unknown cost adds what it is known to have spent so far (its `so_far_usd`: each priced charge, browser time and paid tools included) and is counted in `unpriced_runs` (in the total and in each line it is unknown on), so no sum is ever null, it never passes as $0, and a total is never below a line of its own: with `unpriced_runs` above 0 the total is a lower bound. |
1915
1947
 
1916
- Home export and import, quotes and `POST /runs/{id}/kill` answer `501 unsupported_here` naming the feature, and
1917
- capabilities declare each one false. No run waits out `input_wait_s` here (`null`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
1948
+ Quotes answer `501 unsupported_here` naming the feature. Home export and import (`GET` and `PUT /agents/{id}/home`) and
1949
+ `POST /runs/{id}/kill` are not served here: they answer `404`, and the served document leaves them out (its
1950
+ `info.x-agentrun-serve.not_served` lists them). Capabilities declare each of the four false. No run waits out `input_wait_s` here (`null`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
1918
1951
  above $0 is taken; it does not mean caps are unsupported ([spend cap](#spend-cap)).
1919
1952
 
1920
1953
  ### API only
@@ -1928,7 +1961,7 @@ serves these routes alone:
1928
1961
  - `GET /capabilities`, `GET /health` and `GET /usage`.
1929
1962
 
1930
1963
  Every other address is `404 not_found`, answered before the request is read further: the console at `/` and its
1931
- assets, the store page's `/api/*`, sign-in and setup, every `/settings` route, `POST /mcp`, triggers and their
1964
+ assets, sign-in and setup, every `/settings` route, `POST /mcp`, triggers and their
1932
1965
  `POST /hooks/{id}`, agents, templates, `/openapi.json`, `/llms.txt` and the live views. It has no accounts: there is no
1933
1966
  page to sign in to, so no setup code is printed. The token works as it does on every route served. Unset, `0` or
1934
1967
  `false` serve the whole server, as before; any value other than these and `1` or `true` stops the start, in words.
@@ -2007,7 +2040,7 @@ device and inode), so a disk that takes another spelling for one name is refused
2007
2040
  segments: each its own NFC form, with no default-ignorable code point, or it is `400 invalid_file_path`. An archived agent's home is read and written as
2008
2041
  its definition is. A write is held to its directory through `/proc/self/fd`; where there is none (macOS),
2009
2042
  `capabilities.home.writes` is `false` and `PUT` and `DELETE` are `501 unsupported_here`, as Node has no `openat` to
2010
- write safely by path, while the list and reads still work. `GET` and `PUT /agents/{id}/home`, the contract's packed home, stay `501`.
2043
+ write safely by path, while the list and reads still work. `GET` and `PUT /agents/{id}/home`, the contract's packed home, are not served (`404`).
2011
2044
 
2012
2045
  ## For coding agents
2013
2046
 
@@ -2069,9 +2102,7 @@ into place and made read-only. `node scripts/harness-locks.mjs` makes the locks
2069
2102
  checks them). Every run that needs one waits for that one install, its ready time counted from the install's end, and
2070
2103
  shows a `phase` row, `Installing Claude Code (first use)…` or `Installing Codex (first use)…`, while it does. Each run
2071
2104
  then loads the harness from its own packages inside its install and nowhere else, never from a `node_modules` above it;
2072
- a tree that is not whole is installed again. Claude Code as an earlier build installed it, at the top of `<data>/harnesses`
2073
- itself, is removed before the first install (the server logs `harness_install_removed`), and it installs again; a
2074
- `harnesses` directory that holds anything else is left as it is. Until it is installed, capabilities list the harness with `installs:
2105
+ a tree that is not whole is installed again. Until it is installed, capabilities list the harness with `installs:
2075
2106
  "on_first_use"`. When npm fails, the run fails and its error names the command that installs it by hand, the same locked
2076
2107
  install: the shipped `package.json` and `package-lock.json` copied into a fresh `<data>/harnesses/<harness>.new`, `npm ci
2077
2108
  --ignore-scripts --include=optional` there, then that directory put in place of `<data>/harnesses/<harness>` (made
@@ -2192,10 +2223,7 @@ An agent or a run is archived, never deleted: `DELETE` stays `405`. These routes
2192
2223
  spend happened.
2193
2224
  - A new run of an archived agent is `409 agent_not_runnable`, saying it is archived (`details.archived_at`); a run
2194
2225
  already going when its agent is archived keeps going.
2195
- - The store keeps each change as one row of `archive_changes` in `store.sqlite`, written once
2196
- ([the store](../pi-durable-agent/README.md#agents-in-a-folder-the-agent-store)). A data directory an earlier version
2197
- wrote opens as it is, with nothing archived. Going back to an earlier version keeps every row, but that version does
2198
- not read them: archived agents and runs show as not archived there, and an archived agent's runs start again.
2226
+ - The store keeps an archive as `archived_at` on the agent's or the run's row, null when it is not archived.
2199
2227
 
2200
2228
  ## The console
2201
2229
 
@@ -2218,15 +2246,13 @@ server's own origin, under a CSP that allows that origin only, but for the provi
2218
2246
  agent's Tools step lists each saved server's tools; a box ticked grants `mcp:<server>/<tool>`.
2219
2247
 
2220
2248
  Its files (`index.html`, and Vite's hashed files under `/assets/`) are public and hold no data: everything it shows
2221
- comes through `/v2`. The store's read-only JSON stays under `/api/*` (`/api/store`, `/api/agents/{id}`, `/api/runs` and
2222
- the rest of [`@parcha/pi-durable-agent`](../pi-durable-agent/README.md#looking-at-a-store)'s store page's data), for a
2223
- script with the token or a browser with its cookie. With accounts on (the default) the console asks for the owner's password
2249
+ comes through `/v2`. With accounts on (the default) the console asks for the owner's password
2224
2250
  ([your password](#your-password)) and the browser holds the owner's session cookie; a `?token=` link sets no cookie: the
2225
2251
  token is for scripts and the CLI. With `AGENTRUN_ACCOUNTS=0`, the printed link (`/?token=`) sets a cookie (`HttpOnly`,
2226
2252
  `SameSite=Strict`, `Path=/`, and `Secure` when `X-Forwarded-Proto` says https) and sends the browser to the same address
2227
2253
  without the token. The cookie's value is derived from the token, never the token itself, and it lasts until the browser
2228
2254
  closes. Without it, the console says to open the link. Either cookie takes the place of `Authorization: Bearer` on
2229
- `/api/*` and `/v2`: for a `GET`, and for any other method only when the request's `Origin` is the server's own origin
2255
+ `/v2`: for a `GET`, and for any other method only when the request's `Origin` is the server's own origin
2230
2256
  and its body is `application/json`, or, on a `PUT` or `POST` to a route that takes bytes (`PUT /v2/files/{id}`,
2231
2257
  `POST /v2/files`), of any content type. A request that sends an `Authorization` header is checked on that header alone.
2232
2258
 
@@ -2298,18 +2324,22 @@ left out: 2 sessions still being written: they come in next time
2298
2324
 
2299
2325
  ## A run's life
2300
2326
 
2301
- 1. `POST /agents/{id}/runs` starts the run in the store (`startRun`, which pins the revision and seeds
2302
- `DIR/disk/agents/<agent>/runs/<id>/`), then its process: `pi-durable-disk run --dir DIR/disk/agents/<agent>/runs/<id> --app <this package's app> --serve 0` on
2303
- loopback, behind a token of its own (`DIR/.door-token`), with its stderr in `runs/<id>/process.log`. The run's input
2304
- is in `runs/<id>/serve.json`.
2305
- 2. The app reads the run's revision from the store.
2327
+ 1. `POST /agents/{id}/runs` starts the run in the store (`startRun`): one transaction writes a `queued` run, pinned to the
2328
+ agent's revision, with its launch record (the request, checked and resolved once, its model included). No process
2329
+ starts for it.
2330
+ 2. A runner (by default the one beside the server) claims the `queued` run for 30 s and renews the claim every 10 s. At
2331
+ the claim it opens the run's folder (`DIR/disk/agents/<agent>/runs/<id>/work`), reads the launch record and picks
2332
+ the run's loop: a workflow revision runs on the workflow loop, a learning run on the learning loop, and every
2333
+ other harness (pi, claude-agent, codex, opencode) on the adapter loop. Each loop writes the run's journal in the
2334
+ store, behind the claim's fence: a write under a claim the run has moved past is refused. A message, stop, cancel,
2335
+ raise or approval is a command row in the store, which the run's runner reads and applies.
2306
2336
  - An agentic revision runs as the root agent: its instructions and skills, its model, and the tools it names of the
2307
2337
  workspace's `read`, `write` and `edit`, and `ask_person`, which ends the turn; the timeline then shows a `waiting`
2308
- row, and the run is `input_required` and `waiting` until a message answers it. `bash` is bound only where the run
2309
- has a shell ([computers](#computers)): in a computer that mounts the run's folder, or on Archil's serverless exec
2310
- in Mode 2; in Mode 1 a run with no such computer has the file tools alone. The run is `queued` until its first message shows; while the process runs, the
2311
- timeline comes from its door's events through `@parcha/pi-durable-agent/timeline`. Once the run is idle and its
2312
- newest row is the agent's answer, the server sends the process SIGTERM. A model error ends it `failed`
2338
+ row, and the run is `input_required` and `waiting`, with no runner holding it, until a message answers it. `bash`
2339
+ is bound only where the run has a shell ([computers](#computers)): in a computer that mounts the run's folder, or
2340
+ on Archil's serverless exec in Mode 2; in Mode 1 a run with no such computer has the file tools alone. The run is
2341
+ `queued` until its first message shows. The timeline is read from the run's journal. When the turn ends on the
2342
+ agent's answer, the loop writes the run's end and the runner releases the claim. A model error ends it `failed`
2313
2343
  (`run_failed`). A run whose `max_cost_usd` cannot buy its next request is paused, `input_required` and `waiting`
2314
2344
  with `pending.kind` `budget`; one its cap refuses for a reason no cap fixes ends `failed` (`spend_cap_reached`,
2315
2345
  [below](#spend-cap)). A
@@ -2324,28 +2354,23 @@ left out: 2 sessions still being written: they come in next time
2324
2354
  A stopped run can be continued: a follow-up starts a fresh turn on the whole history, and the turn the stop cut is
2325
2355
  not replayed. A cancelled run cannot: a message to it is `409 not_continuable`, and its `next_action` is to start a
2326
2356
  new run of the agent.
2327
- - A workflow revision runs on agentrun-pi's durable workflow task, started by `startWorkflowRevision` of
2328
- `@parcha/pi-durable-agent/workflow` (keyed by the run's id): its model nodes (`agent`, `decide`, `extract`,
2329
- `report`) on the run's model, with the file tools each node names, and its typed questions on Jev or Parallel
2330
- ([decision workflows](#decision-workflows)). A workflow that needs code or a tool call this host does not run is
2331
- not saved here (`422`). The run is `queued` until its process serves, then `working`; when the workflow
2332
- ends, the app writes the run's final status with the outcome and releases it. Nothing is carried back from inside
2333
- the process, which holds the run's store until it exits.
2334
- 3. When the process has exited, the run's rows are read from its released store (an agentic run's conversation, a
2335
- workflow run's model nodes), and the server carries the run back, every run of both kinds: `carryBack` records its
2336
- state, cost and a summary in the store (an agentic run's answer; a workflow run's `workflowCarry`, its completed
2337
- nodes, then where it failed or escalated). Its last
2338
- page says `final`. v2's `cancelled` is the store's `stopped`; a workflow that escalated ends `completed`, its work
2339
- done and waiting for a person's review: `error` is null and `review` is `{kind, node, reason, at}`, in the run and in the
2340
- lists. In this release `kind` and `node` are always null: the store keeps only the escalation's summary (`reason`)
2341
- and the run's end (`at`). Every other run's
2342
- `review` is null. `GET /v2/stats` counts it in `needs_review`, never in `failed`.
2343
- 4. When the server starts, it reads every run the store says is running. A run process an earlier server started and
2344
- that still serves the run is supervised again, by the holder its row names (its pid, its start, its door); a run
2345
- that already ended is carried
2346
- back; a run whose process is gone before it ended is opened again on its directory and resumes from its store (an
2347
- agentic run waiting for an answer waits without one, until a message). A carry back that finds the store held by
2348
- another writer is tried again with backoff, and at the next start.
2357
+ - A workflow revision runs on the workflow loop, which drives the DSL's durable workflow task on the run's journal
2358
+ (keyed by the run's id): its model nodes (`agent`, `decide`, `extract`, `report`) on the run's model, with the file
2359
+ tools each node names, and its typed questions on Jev or Parallel ([decision workflows](#decision-workflows)). A
2360
+ workflow that needs code or a tool call this host does not run is not saved here (`422`). The run is `queued`
2361
+ until a runner claims it, then `working`. When the workflow ends, the loop writes the run's end from its outcome:
2362
+ a complete run ends `ended`, an escalated one `ended` with the outcome `escalated`, a refused or failed one
2363
+ `failed`, a cancelled one `stopped`.
2364
+ 3. The run's end is one commit: the run's state, its cost and a summary (an agentic run's answer; a workflow run's
2365
+ completed nodes, then where it failed or escalated) are written with the journal's end entry, so there is nothing to
2366
+ carry back afterwards. Its last page says `final`. v2's `cancelled` is the store's `stopped`; a workflow that
2367
+ escalated ends `completed`, its work done and waiting for a person's review: `error` is null and `review` is
2368
+ `{kind, node, reason, at}`, in the run and in the lists. In this release `kind` and `node` are always null: the
2369
+ store keeps only the escalation's summary (`reason`) and the run's end (`at`). Every other run's `review` is null.
2370
+ `GET /v2/stats` counts it in `needs_review`, never in `failed`.
2371
+ 4. A server that starts again adopts nothing: runs are claimed, not supervised. A run whose runner stopped or lost its
2372
+ claim writes nothing more; once the claim lapses another runner claims the run and resumes it from its journal,
2373
+ and a model request the stop cut is sent again. A run waiting for an answer has no claim and waits until a message.
2349
2374
 
2350
2375
  An `Idempotency-Key` answer is kept in `DATA/.idempotency.json` for `limits.idempotency_ttl_s` (a day), saved once the
2351
2376
  work is done and before the answer is sent, so a retry after a restart gets the first answer; a server that goes down
@@ -2387,9 +2412,13 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
2387
2412
  not counted toward the budget. Each active note is there whole (its
2388
2413
  `## name (file.md)`, its description, then its text), the one changed last on `main` first (a merge or a person's
2389
2414
  edit; then by name), while they all fit the server's learning budget (`--learning-budget`, 8000 bytes by default).
2390
- Past it, the run reads the first 200 lines of `MEMORY.md` (and no more than 25 KB, as Claude Code loads its own),
2391
- then the notes changed last, whole, while they fit what is left; the rest are named only in the index, and an agent
2392
- with the `read` tool is told they are in `.learning/`, to open one when it applies (one without is not). A line
2415
+ Past it, the run reads the notes that bear on it: each active note is scored against the run's first message by a
2416
+ lexical match (BM25 over its name, description and text; a code review's changed paths weigh three times its prose; no
2417
+ model call), and the run reads the best ones whole while they fit, then one line for each of the rest
2418
+ (`- <name> (<file>): <description>`, at most 200 lines and 25 KB), in place of the index. A first message that shares
2419
+ no word with any note reads the index's first 200 lines, then the notes changed last, whole, while they fit. An agent
2420
+ with the `read` tool is told the notes not given whole are in `.learning/`, to open one when it applies (one without
2421
+ is not). A line
2393
2422
  before them says to follow a note when it applies. `# Learned` opens, for every run that learns, notes or none, with
2394
2423
  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
2395
2424
  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
@@ -2406,6 +2435,10 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
2406
2435
  revision's (pi and codex read each `SKILL.md` in their prompt, claude-agent loads the ones its adapter takes through
2407
2436
  its Skill tool). A skill named like one of the revision's is the revision's, and only an active skill is served: one
2408
2437
  whose `SKILL.md` front matter says `status: pending` (held for its owner's OK), or any status but `active`, is not.
2438
+ One front-matter reader decides a skill's and a workflow's status everywhere (the checks, the console, the routes and
2439
+ a run's start): front matter that does not read one way (not closed, a key indented under another, a key set twice, a
2440
+ status over more than one line) reads as retired, so no run is given it. A learned skill is served with its `name` and
2441
+ `description` quoted, so a harness reads them as text.
2409
2442
  The learned ones get 256 KiB, every file of each together, and never more than the revision's skills leave of the 1
2410
2443
  MiB an adapter takes of a run's skills in all, so they never push the revision's back into the prompt: the one
2411
2444
  changed last on `main` first, each whole while it fits. One that does not fit, or holds one of the server's secrets,
@@ -2437,6 +2470,10 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
2437
2470
  offered the workflows its pin names. A call a crash cut off is answered interrupted, never run again. The tool gate holds
2438
2471
  `learned_workflow` like any tool: its settings key is `learned_workflow`, allowed by default (the agent's own graded
2439
2472
  workflow, each node checked), and tool settings may set it to ask (the run parks until an owner answers) or deny.
2473
+ When a run's learned workflows name decision providers (Jev, Parallel, OpenRouter), the runner opens those providers'
2474
+ keys as it opens the run's own, from the server's environment first and then its saved keys, for the run's tools alone:
2475
+ never for its model or a CLI harness's own environment. A provider the run's tool gate denies gets no key. Learned
2476
+ workflows can use them once decision nodes land (see Coming).
2440
2477
 
2441
2478
  The server reads the commit with git plumbing, never the working tree. What it holds that is not a regular UTF-8 file of
2442
2479
  1 MiB or less, or a note out of shape, is not read, and the server's stderr names it. A learning fault never blocks a
@@ -2454,27 +2491,41 @@ with each note to keep as one ` ```note <file>.md ` block in the note format, an
2454
2491
  needed, and nothing the run wrote in `work/.learning/`, during the task or the turn, counts. It also says that a memory
2455
2492
  is replaced by a new note with `supersedes: [old.md]` and never by reusing a name, how many index lines are left (200
2456
2493
  less the active notes), that `No notes.` is a fine answer, and what not to keep. The turn runs under the run's own cap,
2457
- with no reserve, and within 5 minutes; its rows are labelled `learning`, and the run's answer stays the job's.
2458
-
2459
- As the run settles, before it reads ended and before a follow-up can open it again, the server keeps what the turn
2460
- answered, the whole text of each of its messages, and what the user said in the run, in `runs/<id>/learning-turn.json`.
2461
- Once the run has ended, in the agent's queue, the server reads the notes from that answer alone (`parseReflection`, in
2494
+ with no reserve, and within 5 minutes; its rows are labelled `learning`, and the run's answer stays the job's. While it
2495
+ runs, the run reads `reflecting` on every harness. A run whose only tool work was its learned workflows, each answering,
2496
+ with nothing said after its first message, is not asked: no request is sent, and its learning ends `dropped` (`empty`),
2497
+ "Nothing new: the run only ran a learned workflow."
2498
+
2499
+ The same turn may give one skill (only when the job completed) and one workflow draft, when the work repeats. Once a
2500
+ learned skill the run was given has been given to 3 earlier runs of its agent, with no learned workflow of that name,
2501
+ the turn also asks for that skill's job as a workflow draft under the skill's name, and says what each tool a draft's
2502
+ call node may run takes and gives. A draft the checks pass is dry-run before it is kept: the workflow language runs it on
2503
+ the run's own input (its block's `example:` line) or one made from its input schema, with every model and tool answer
2504
+ made up from the node's output schema, so nothing is sent, paid or run. One whose wiring breaks is left out, and the
2505
+ turn is asked once more to fix it. [`src/learn/SPEC.md`](src/learn/SPEC.md) has the rules.
2506
+
2507
+ The runner reads the notes from that answer alone (`parseReflection`, in
2462
2508
  `src/learn/reflect.ts`): an answer with no note is `empty`, and one that gives notes out of format (a note outside a
2463
2509
  block, a block with no file name, or one name given twice with other words) is `unparsed`, nothing kept. A block opens
2464
2510
  with the fence asked for (```` ```note ```` or four backticks for a note, four for a skill or a draft) and runs to the
2465
2511
  next line that is that fence; a shorter fence is text, a longer one an example, and an opening never closed is left out
2466
2512
  alone. `checkProposal`
2467
- (`src/learn/check.ts`) then refuses, before anything is written anywhere, a note that reuses an existing note's name, a
2513
+ (`src/learn/check.ts`) then leaves out, before anything is written anywhere, each item that breaks a rule, and the rest
2514
+ goes on: a note that reuses an existing note's name, a
2468
2515
  path that is not a `.md` file at the top, a bad name, front matter out of shape or setting `status`, a `supersedes`
2469
2516
  naming a note that is not active, more than 8 notes superseded, more than 8 new notes or a note over 4068 bytes (4096,
2470
2517
  less the 28 the server's own `origin` and `status` lines may take once it merges the note), an
2471
2518
  index past 200 lines, hidden characters, and text shaped like a secret or holding one of the server's own secrets (the
2472
2519
  launcher's, the keys and tokens in its environment, its API and door tokens, each webhook trigger's signing secret as it
2473
- is now), in a note or its name. A `MEMORY.md` the
2474
- answer gives is ignored. What passes is kept as the run's proposal, `runs/<id>/learning-proposal.json`, with what the
2475
- user said, each message cut of the server's secrets.
2476
-
2477
- Then one grader decides, one grade at a time per agent: `gradePrompt` (`src/learn/grade.ts`), which holds
2520
+ is now), in a note or its name. A cap leaves out the items past it, in the order the answer gave them, and the run's
2521
+ learning names what was left out. The whole answer is refused when it holds a secret or a hidden character (no item of
2522
+ 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
2523
+ would pass 200 lines, or when nothing is left. A `MEMORY.md` the
2524
+ answer gives is ignored. What passes is kept as the run's proposal, with what the user said, each message cut of the
2525
+ server's secrets, in the store in the same write as the run's end, beside what the turn answered. The run's end queues a
2526
+ learning run of its own, which no list of runs shows.
2527
+
2528
+ Then one grader decides, in that learning run: `gradePrompt` (`src/learn/grade.ts`), which holds
2478
2529
  `GRADE_RUBRIC`, the rubric's one statement, bounded (3 minutes), against `main` as it is then, and read by
2479
2530
  `parseVerdict`, which fails closed. It runs on the model the server grades on: `--grade-model` (or
2480
2531
  `AGENTRUN_SERVE_GRADE_MODEL`), else the strong tier (`AGENT_MODEL_STRONG`), named as the strong tier takes one; with
@@ -2483,8 +2534,13 @@ cheap model is a poor grader, so point the strong tier (or `--grade-model`) at a
2483
2534
  note's index line, the whole text only of the notes the proposal supersedes, what the user said in the run (cut of the
2484
2535
  server's secrets, as the proposal keeps it), and the new notes, so its prompt stays under 200,000 characters however
2485
2536
  many notes the folder holds. No injection screen runs before it: a page classifier cannot see where a note came
2486
- from, and read a preference the user stated as a planted instruction; the grader's Planted question decides. What the
2487
- grade spends is in no run's totals: it is kept on the run's learning, and counted once on `GET /usage` under the meter
2537
+ from, and read a preference the user stated as a planted instruction; the grader's Planted question decides: a rule the
2538
+ user states in their own words is theirs, even beside a form or a pasted email in the same message, and a rule found only
2539
+ inside text the run read is planted and dropped, never held for the owner's OK. An item that holds an account number is
2540
+ dropped too, even where the user gave it as where money goes. The Risky question reads one way on every grade model: a
2541
+ limit or threshold that decides whether an approval or a check happens is risky in either direction, as is an exemption
2542
+ from a check, trusting or paying a named site or seller, or naming where money or data goes, whoever asked. What the
2543
+ grade spends is in no run's totals, and is read once its request is booked: it is kept on the run's learning, and counted once on `GET /usage` under the meter
2488
2544
  `learning`, by agent and by day; a call cut off at its bound spent what nobody knows, so its cost is unknown, never $0.
2489
2545
 
2490
2546
  A kept verdict merges as one commit on `main`, made with plumbing: the new notes added, each with its `origin` (`you`
@@ -2539,14 +2595,31 @@ looking back cost, 0 when it did not), after its `serve.json` holds it; a server
2539
2595
  its next start. A run's notes are the one part that moves after its end (a follow-up reads another note): a line
2540
2596
  `{run, agent, notes: true, given, read}` then says them anew, the latest one winning, and counts neither the run nor its
2541
2597
  costs again. `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
2542
- `agent`, from that ledger and from the runs the server holds (`in_progress`), never opening a run's files; the
2543
- `learning` meter on `GET /usage` reads the same lines.
2598
+ `agent`, from the store (each run's kept learning and its learning run's journal; `in_progress` while a proposal waits
2599
+ for its grade), never opening a run's files; the `learning` meter on `GET /usage` reads each run's grade from the same.
2544
2600
 
2545
2601
  An eval set of 20 runs and what each proposed, labelled keep or drop (`test/fixtures/learn-eval.json`: lessons the
2546
2602
  agent worked out, user preferences and a "remember" during the task, one-shop facts, secrets, a tool's failure and four
2547
2603
  injections), runs in CI through the parser, the checks and the grader's prompt on a faux grader that answers by label
2548
2604
  (`test/learn-eval.test.mjs`). `scripts/learn-eval.mjs` runs the same set on real models, the grade and the end-of-run
2549
- turn both, and prints keep-precision, keep-recall and the injection-drop rate per model; it spends.
2605
+ turn both, and prints keep-precision, keep-recall and the injection-drop rate per model; it spends. It grades on several
2606
+ models at once (`--grade-models A,B,C`, with how often they agree, note by note), reads the held-out set with
2607
+ `--set heldout`, and lists its plan without calling a model with `--dry`.
2608
+
2609
+ The learning bench, `node scripts/learn-bench.mjs`, runs repeated jobs with learning off and on, on pi and
2610
+ claude-agent, and reports the follow rate on repeat steps, the work cost per run and its trend, how often workflows are
2611
+ proposed and reused, staleness after a rule changes, and wrong keeps after a planted request. Six jobs ship with it, in
2612
+ [`learn-bench/`](learn-bench/README.md); it calls real models and spends, so it runs on demand or nightly.
2613
+
2614
+ ### Coming
2615
+
2616
+ - One copy of each rule: a note that repeats an active note's rule is a duplicate, and a skill re-filed as a note retires the old skill (#2256).
2617
+ - A learned workflow may hold decision nodes (judge, pick, sift), answered by the run's decision provider under the run's cap (#2363).
2618
+ - Consolidation: related notes merged into one, and a skill and its workflow brought back in step (#2335).
2619
+ - A learned workflow's node of a tier runs on the server's model of that tier, at its own price (#2408).
2620
+ - A learned workflow's call node runs an MCP tool through the run's own MCP, under its gate, and the grader holds one that writes for the owner's OK (#2424).
2621
+ - A learned workflow keeps the output format its skill asks for (#2412).
2622
+ - A grade that contradicts itself is asked once more (#2425).
2550
2623
 
2551
2624
  ### What a person sees and controls
2552
2625
 
@@ -2706,6 +2779,9 @@ session (spent before any process could hold it). A session whose release is nev
2706
2779
  (what it ran and its minimum) when the run gives up on it. When the run is let go, its sessions are released and their
2707
2780
  last charges booked before its process exits.
2708
2781
 
2782
+ A computer's minutes (a sandbox's, a desktop's or a phone's) are billed by its provider to your own account there, and
2783
+ AgentRun does not count them yet: they are in no run's cost and are not held against its cap.
2784
+
2709
2785
  Under a cap, whatever cannot be priced is refused, never passed as $0, and the run ends `failed` with
2710
2786
  `spend_cap_reached`, since no cap would send it:
2711
2787
 
@@ -2792,11 +2868,8 @@ follows it. The refusal's words (`said`) keep its own figures. Its timeline show
2792
2868
  ending `:note`, so it is no message) marked `paused` (never an `error` row; it stays once the cap is raised, as the
2793
2869
  run's history), then a waiting row: "Waiting for you to raise the
2794
2870
  cap", and no more: the words are `pending.said`'s, which a client shows once. The
2795
- webhook's `run.needs_input` says `pending.kind: "budget"`. Its process is let go while it waits (SIGTERM: it drains and
2796
- releases the run), so a paused run holds no place; a server started again reads it paused from its store. A paused
2797
- process that does not let go within the drain timeout (`--drain-timeout`, 30 s by default) is killed, and the run ends
2798
- `failed`, as any run whose process is killed does, unless its cap was raised meanwhile: it held nothing, so the raise's
2799
- follow-up goes (below). A message to a
2871
+ webhook's `run.needs_input` says `pending.kind: "budget"`. The run is parked while it waits: no runner holds it,
2872
+ so a paused run holds no place, and a server started again reads it paused from its store. A message to a
2800
2873
  paused run is `409 budget_reached`; a stop does nothing more, and a cancel ends it `cancelled`. Only a refusal for room
2801
2874
  pauses a run: one no cap fixes (above) ends it `failed`, as does a cost found past the cap after a response.
2802
2875
 
@@ -2812,20 +2885,11 @@ still ends the run `failed`.
2812
2885
  `PATCH /runs/{run_id}` with `{max_cost_usd}` raises the cap, and only raises it: the new cap is above the run's current
2813
2886
  cap, its last raise included, by more than a float's tail (1e-9; `422` otherwise, and for a run with no cap;
2814
2887
  `409 not_continuable` for an ended run). A workflow run's raise is [below](#a-workflow-run-under-its-cap). The same raise sent again (a retry), within that tail, changes nothing and
2815
- answers as the first did. The run's serve.json keeps the raise before any answer, with each raise in `cap_raised`, so its
2816
- next process opens under it, as does a server started again; a raise it could not keep is not taken (an error answers it),
2817
- and the same raise again is taken anew. A run paused at its cap goes on: the answer is `{run_id, max_cost_usd, resumed: true,
2818
- message_id, status, state}` at once, and the pause gets one follow-up turn, "The cap was raised to $2; continue the
2819
- task.", under that `message_id`, which the server sends once the process being let go is gone, and which runs under the
2820
- new cap. From the moment the raise is taken, the run reads `queued` (state `working`), in the answer's `status` and in
2821
- every read after it, until the follow-up's turn runs: nothing waits on a person, so it is never `input_required` with no
2822
- `pending` meanwhile. A second raise before it goes raises the cap it names and answers the same `message_id`. It is sent once: a
2823
- server stopped before it went, or between starting its process and sending it, sends it when it starts again. One that
2824
- cannot be sent is tried again (after 1 s, then 3 s); after 3 tries the run ends `failed`, saying the cap was raised but
2825
- the run could not be sent on. The follow-up shows in the run's timeline as the server's, "AgentRun: The cap was raised…", never as the
2826
- person's message (its submit names the server as its origin, `cap_raised`). A working run's
2827
- live process keeps the cap it was opened with until its next one, and the answer's `note` says so. The raise is keyed to
2828
- the refusal's own start mark, so a row shown after the refusal never reads the run paused again.
2888
+ answers as the first did. The raise is a command row in the store, which the run's runner reads. A run paused at its cap goes on: the answer is
2889
+ `{run_id, max_cost_usd, resumed: true, status, state}` at once, and a runner claims the run again and resumes it from its
2890
+ journal under the new cap. A raise for a run a runner holds now takes effect from the run's next step: a step already
2891
+ under way keeps the cap it was admitted at, and the answer's `note` says so. A run a person stopped takes no raise
2892
+ (`409 not_continuable`): send it a message to go on, then raise its cap.
2829
2893
 
2830
2894
  A request carrying a native web search tool reads pages into its input that its body does not hold (the provider bills
2831
2895
  them as input): under a cap its input bound is its body's plus an allowance. Claude's own search, an explicit `native`
@@ -2950,18 +3014,19 @@ carries no cost at all, as from a provider that does not price the model. The te
2950
3014
  no cookie of this server's and nothing of yours; Google sees the browser's address and which providers the page
2951
3015
  lists. Offline, or with those hosts blocked, the page shows a key icon instead. The CSP's `img-src` allows those
2952
3016
  five hosts; everything else is this origin only.
2953
- - Each run's door listens on loopback and takes only that run's own door token (`DIR/disk/agents/<agent>/runs/<id>/door-token`, 0600, made
2954
- at its first launch); a run's process an older server started keeps the server-wide one (`DIR/.door-token`).
2955
- - A run's process gets the server's environment (the `AGENT_MODEL` variables among it) without the server's token or any
2956
- key: no `AGENTRUN_TOKEN`, no `AGENTRUN_API_KEY`, no variable whose value is the token, and no variable named like a key
3017
+ - A run has no door of its own. The server and a run's runner meet in the store: a message, stop or approval is a
3018
+ command row the runner reads, so no port a run listens on takes a token.
3019
+ - A run's tools run under the runner's environment (the `AGENT_MODEL` variables among it) without the server's token or
3020
+ any key: no `AGENTRUN_TOKEN`, no `AGENTRUN_API_KEY`, no variable whose value is the token, and no variable named like a key
2957
3021
  (one of its `_`-separated segments, in any case, is `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `PASSWD`, `PASS`, `PAT`,
2958
3022
  `CREDENTIAL`, `CREDENTIALS` or `DSN`, or its last is `PWD` after another: `SERVICE_KEY`, `GITHUB_TOKEN_RO`, `DB_PASS`,
2959
3023
  `SENTRY_DSN`, `DB_PWD`; never `PWD` or `OLDPWD`), whether the launcher's list names it or not. The rule is
2960
- pi-durable-disk's (`@parcha/pi-durable-disk/secret-name`), which an import's cut and a harness's log take too. The keys it
2961
- needs come over its pipe. It gets none of the boxes' keys ([Boxes](#boxes)). A tool key reaches it only when its
3024
+ `keyShaped` (`src/secret-cut.ts`), which an import's cut and a harness's log take too. The keys a
3025
+ run needs are read from the store at its claim, opened with the seal key, and are put on that run's environment alone.
3026
+ It gets none of the boxes' keys ([Boxes](#boxes)). A tool key reaches it only when its
2962
3027
  revision names a tool the key unlocks (`MONID_API_KEY` a monid tool, `BROWSERBASE_API_KEY` and `KERNEL_API_KEY` `browser`; a workflow's
2963
3028
  tools are those its model and call nodes name), and a model key only when its model needs it ([Models](#models)), read
2964
- from the revision at each launch, a relaunch or a resume after a restart included.
3029
+ from the revision at each claim, a resume after a restart included.
2965
3030
  - A variable named like a key that is not on the launcher's list (`capabilities.secrets.names`) is left out of every
2966
3031
  run's environment, but the launcher does not take it out of the server's: it stays in the server's own environment
2967
3032
  (`/proc/<pid>/environ`), which any process of the same user can read. Set only the keys the server needs where it
@@ -2974,15 +3039,15 @@ carries no cost at all, as from a provider that does not price the model. The te
2974
3039
  keys or bearer token (held, and handed to a run on Bedrock), an `AWS_PROFILE`, `GOOGLE_CLOUD_API_KEY` or the default
2975
3040
  application credentials file work. A credential file a provider reads by path (`AWS_PROFILE`'s `~/.aws` files, the
2976
3041
  default application credentials) is the host's: a run's process reads it for its model, and its file tools cannot.
2977
- - `TYPESAFE_API_KEY` is a decision key, handed to a workflow run's decision providers on a pipe of their own and never
2978
- with a run's other secrets, so a pi run on a `typesafe/` model does not get it: its process finds no key for that
2979
- model, and the run fails.
3042
+ - `TYPESAFE_API_KEY` is a decision key, given to a workflow run's decision providers alone and never
3043
+ with a run's other secrets, so a pi run on a `typesafe/` model does not get it: it finds no key for that model, and
3044
+ the run fails.
2980
3045
  - A run's file tools (`read`, `write`, `edit`) reach its own `work/`, and two places of its own beside it: `read` also
2981
3046
  reaches the run's `tmp/` (next to `work/`, where a command's spilled output would go), and a write may also land in a
2982
3047
  temporary directory the run's environment made for a tool (`createTempDir`). Every other path, a link inside `work/`
2983
- included, is resolved and refused (`outside the workspace`), so a run reads neither the server's token, the door
2984
- token, `store.sqlite`, another run's files (its `work/` or its `tmp/`) nor `/proc`, and writes nowhere else. This is
2985
- pi-durable-disk's confinement inside the run's process, not an operating-system boundary: the run and the server
3048
+ included, is resolved and refused (`outside the workspace`), so a run reads neither the server's token,
3049
+ `store.sqlite`, another run's files (its `work/` or its `tmp/`) nor `/proc`, and writes nowhere else. This is the
3050
+ Workspace's confinement inside the runner's process, not an operating-system boundary: the runner and the server
2986
3051
  share a user (one uid in the container), so the confinement holds only because the run has no shell on this machine.
2987
3052
  - No path offers a shell on this machine. On the runner `bash` is not bound: a definition that names it is not saved
2988
3053
  here (`422`), one saved before that check is not runnable (`409`), and a model that calls it anyway, as an agent or as
@@ -3018,8 +3083,8 @@ carries no cost at all, as from a provider that does not price the model. The te
3018
3083
  ## Test
3019
3084
 
3020
3085
  ```sh
3021
- npm run build -w @parcha/agentrun-dsl -w @parcha/agentrun-pi -w @parcha/pi-durable-disk -w @parcha/pi-durable-agent -w @parcha/agentrun-serve
3086
+ npm run build -w @parcha/agentrun-dsl -w @parcha/agentrun-pi -w @parcha/pi-durable-agent -w @parcha/agentrun-serve
3022
3087
  npm test -w @parcha/agentrun-serve
3023
3088
  ```
3024
3089
 
3025
- The tests start real run processes on the faux model, both kinds: no key, no network.
3090
+ The tests start a real runner on the faux model, both kinds of run: no key, no network.