@parcha/agentrun-serve 0.1.0-beta.31 → 0.1.0-beta.32

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 (810) hide show
  1. package/CHANGELOG.md +422 -0
  2. package/NOTICE +18 -0
  3. package/README.md +887 -241
  4. package/dist/adapter-facts.d.ts +3 -0
  5. package/dist/adapter-facts.js +5 -0
  6. package/dist/adapters.d.ts +64 -140
  7. package/dist/adapters.js +153 -377
  8. package/dist/agents-store.d.ts +146 -0
  9. package/dist/agents-store.js +359 -0
  10. package/dist/agents.d.ts +5 -3
  11. package/dist/agents.js +37 -17
  12. package/dist/app.d.ts +2 -4
  13. package/dist/app.js +207 -92
  14. package/dist/approvals.d.ts +4 -0
  15. package/dist/approvals.js +7 -0
  16. package/dist/archil-routes.d.ts +45 -0
  17. package/dist/archil-routes.js +150 -0
  18. package/dist/archil-settings.d.ts +30 -0
  19. package/dist/archil-settings.js +34 -0
  20. package/dist/background.js +28 -9
  21. package/dist/bounds.d.ts +26 -0
  22. package/dist/bounds.js +137 -0
  23. package/dist/box-egress-vm.d.ts +2 -1
  24. package/dist/box-egress-vm.js +20 -6
  25. package/dist/box-egress.d.ts +16 -6
  26. package/dist/box-egress.js +27 -15
  27. package/dist/box-paths.d.ts +59 -0
  28. package/dist/box-paths.js +92 -0
  29. package/dist/box-relay-vm.js +28 -1
  30. package/dist/box-relay.d.ts +2 -0
  31. package/dist/box-relay.js +2 -2
  32. package/dist/boxes.d.ts +13 -1
  33. package/dist/boxes.js +37 -3
  34. package/dist/browser-commands.d.ts +43 -0
  35. package/dist/browser-commands.js +154 -0
  36. package/dist/browser-cost.d.ts +30 -3
  37. package/dist/browser-cost.js +276 -21
  38. package/dist/browser-live.d.ts +124 -0
  39. package/dist/browser-live.js +324 -0
  40. package/dist/browser-person.d.ts +168 -0
  41. package/dist/browser-person.js +769 -0
  42. package/dist/budget.d.ts +80 -0
  43. package/dist/budget.js +211 -0
  44. package/dist/cap.d.ts +272 -62
  45. package/dist/cap.js +599 -189
  46. package/dist/cli.js +201 -17
  47. package/dist/coding-tools.d.ts +13 -1
  48. package/dist/coding-tools.js +107 -5
  49. package/dist/computer-adb.d.ts +12 -0
  50. package/dist/computer-adb.js +14 -0
  51. package/dist/computer-commands.d.ts +103 -0
  52. package/dist/computer-commands.js +256 -0
  53. package/dist/computer-keys.d.ts +68 -0
  54. package/dist/computer-keys.js +148 -0
  55. package/dist/computer-routes.d.ts +38 -0
  56. package/dist/computer-routes.js +56 -0
  57. package/dist/computer-setting.d.ts +37 -0
  58. package/dist/computer-setting.js +47 -0
  59. package/dist/computer-view.d.ts +38 -0
  60. package/dist/computer-view.js +14 -0
  61. package/dist/computers.d.ts +137 -0
  62. package/dist/computers.js +197 -0
  63. package/dist/console/THIRD-PARTY-NOTICES.txt +25 -0
  64. package/dist/console/assets/index-35-7aeIZ.js +519 -0
  65. package/dist/console/assets/index-Cejbov-Y.css +1 -0
  66. package/dist/console/index.html +2 -2
  67. package/dist/console-links.d.ts +2 -0
  68. package/dist/console-links.js +6 -0
  69. package/dist/decision-cap.d.ts +63 -0
  70. package/dist/decision-cap.js +163 -0
  71. package/dist/decision-rows.d.ts +5 -2
  72. package/dist/decision-rows.js +8 -6
  73. package/dist/decisions.d.ts +28 -1
  74. package/dist/decisions.js +63 -6
  75. package/dist/disk.d.ts +33 -0
  76. package/dist/disk.js +85 -0
  77. package/dist/door-line.d.ts +23 -0
  78. package/dist/door-line.js +83 -0
  79. package/dist/egress-proxy.d.ts +45 -0
  80. package/dist/egress-proxy.js +416 -0
  81. package/dist/egress-table.d.ts +24 -0
  82. package/dist/egress-table.js +165 -0
  83. package/dist/errors.d.ts +15 -0
  84. package/dist/errors.js +22 -2
  85. package/dist/exa-keyless.js +1 -1
  86. package/dist/explain.d.ts +22 -0
  87. package/dist/explain.js +207 -0
  88. package/dist/faux-computers.d.ts +35 -0
  89. package/dist/faux-computers.js +126 -0
  90. package/dist/file-types.d.ts +4 -0
  91. package/dist/file-types.js +11 -0
  92. package/dist/files.d.ts +3 -35
  93. package/dist/files.js +9 -120
  94. package/dist/github-connection.d.ts +207 -0
  95. package/dist/github-connection.js +595 -0
  96. package/dist/github.d.ts +64 -0
  97. package/dist/github.js +119 -0
  98. package/dist/grade.d.ts +9 -42
  99. package/dist/grade.js +42 -228
  100. package/dist/graph-served.d.ts +23 -2
  101. package/dist/graph-served.js +44 -3
  102. package/dist/graph-view.d.ts +7 -3
  103. package/dist/graph-view.js +26 -15
  104. package/dist/handed-values.d.ts +23 -0
  105. package/dist/handed-values.js +36 -0
  106. package/dist/harness-app.d.ts +33 -4
  107. package/dist/harness-app.js +530 -85
  108. package/dist/harness-install.d.ts +120 -0
  109. package/dist/harness-install.js +359 -0
  110. package/dist/harness-opencode/adapter.js +42 -8
  111. package/dist/harness-opencode/facts.d.ts +2 -0
  112. package/dist/harness-opencode/facts.js +28 -0
  113. package/dist/harness-opencode/harness.d.ts +4 -0
  114. package/dist/harness-opencode/harness.js +38 -5
  115. package/dist/harness-opencode/host/policy.js +11 -3
  116. package/dist/harness-opencode/transcript.d.ts +25 -0
  117. package/dist/harness-opencode/transcript.js +81 -0
  118. package/dist/harness-table.d.ts +75 -0
  119. package/dist/harness-table.js +145 -0
  120. package/dist/harness.d.ts +7 -28
  121. package/dist/harness.js +15 -41
  122. package/dist/heard.d.ts +12 -0
  123. package/dist/heard.js +45 -0
  124. package/dist/helper-env.d.ts +4 -0
  125. package/dist/helper-env.js +14 -0
  126. package/dist/home-path.d.ts +0 -4
  127. package/dist/home-path.js +3 -17
  128. package/dist/host-check.d.ts +4 -3
  129. package/dist/host-check.js +5 -4
  130. package/dist/host-tools.d.ts +51 -8
  131. package/dist/host-tools.js +108 -117
  132. package/dist/host.d.ts +12 -6
  133. package/dist/host.js +30 -24
  134. package/dist/hosted-search.d.ts +3 -0
  135. package/dist/hosted-search.js +5 -3
  136. package/dist/import-proxy.d.ts +42 -0
  137. package/dist/import-proxy.js +105 -0
  138. package/dist/import-summary.js +4 -8
  139. package/dist/import-worker.d.ts +2 -3
  140. package/dist/import-worker.js +18 -16
  141. package/dist/import.d.ts +37 -17
  142. package/dist/import.js +208 -222
  143. package/dist/key-meta.d.ts +26 -0
  144. package/dist/key-meta.js +30 -0
  145. package/dist/key-refusal.d.ts +4 -1
  146. package/dist/key-refusal.js +20 -7
  147. package/dist/learn/check.d.ts +3 -1
  148. package/dist/learn/check.js +2 -2
  149. package/dist/learn/commit.d.ts +86 -0
  150. package/dist/learn/commit.js +182 -0
  151. package/dist/learn/folder.d.ts +296 -0
  152. package/dist/learn/folder.js +796 -0
  153. package/dist/learn/grade.d.ts +22 -9
  154. package/dist/learn/grade.js +95 -49
  155. package/dist/learn/index.d.ts +2 -2
  156. package/dist/learn/index.js +2 -2
  157. package/dist/learn/learning.sh +366 -0
  158. package/dist/learn/reflect.d.ts +12 -5
  159. package/dist/learn/reflect.js +70 -41
  160. package/dist/learn/secrets.d.ts +15 -7
  161. package/dist/learn/secrets.js +66 -16
  162. package/dist/learn/seed-check.d.ts +74 -0
  163. package/dist/learn/seed-check.js +103 -0
  164. package/dist/learn/skills.d.ts +5 -1
  165. package/dist/learn/skills.js +5 -4
  166. package/dist/learned-workflow.d.ts +12 -2
  167. package/dist/learned-workflow.js +9 -5
  168. package/dist/learning-routes.d.ts +88 -41
  169. package/dist/learning-routes.js +340 -539
  170. package/dist/learning-run.d.ts +60 -53
  171. package/dist/learning-run.js +181 -224
  172. package/dist/learning-words.d.ts +3 -5
  173. package/dist/learning-words.js +3 -5
  174. package/dist/learning.d.ts +177 -112
  175. package/dist/learning.js +289 -380
  176. package/dist/live/stream.d.ts +30 -0
  177. package/dist/live/stream.js +175 -0
  178. package/dist/live/translate.d.ts +52 -0
  179. package/dist/live/translate.js +276 -0
  180. package/dist/llm.js +3 -0
  181. package/dist/llms.txt +1 -0
  182. package/dist/local-models.d.ts +23 -0
  183. package/dist/local-models.js +35 -0
  184. package/dist/mcp-gateway.d.ts +46 -13
  185. package/dist/mcp-gateway.js +145 -45
  186. package/dist/mcp-meta.d.ts +3 -0
  187. package/dist/mcp-meta.js +14 -2
  188. package/dist/mcp-oauth.d.ts +172 -0
  189. package/dist/mcp-oauth.js +403 -0
  190. package/dist/mcp-private-hosts.d.ts +48 -0
  191. package/dist/mcp-private-hosts.js +141 -0
  192. package/dist/mcp-probe.d.ts +101 -0
  193. package/dist/mcp-probe.js +359 -0
  194. package/dist/mcp-secret-writes.d.ts +23 -0
  195. package/dist/mcp-secret-writes.js +60 -0
  196. package/dist/mcp-servers-store.d.ts +251 -0
  197. package/dist/mcp-servers-store.js +447 -0
  198. package/dist/mcp-servers.d.ts +180 -50
  199. package/dist/mcp-servers.js +284 -321
  200. package/dist/mcp-store.d.ts +103 -0
  201. package/dist/mcp-store.js +123 -0
  202. package/dist/mcp.js +22 -21
  203. package/dist/model.d.ts +77 -59
  204. package/dist/model.js +237 -98
  205. package/dist/monid.d.ts +8 -6
  206. package/dist/monid.js +39 -25
  207. package/dist/openapi.d.ts +22 -1
  208. package/dist/openapi.js +919 -108
  209. package/dist/owner.d.ts +46 -10
  210. package/dist/owner.js +123 -43
  211. package/dist/page.d.ts +10 -0
  212. package/dist/page.js +27 -4
  213. package/dist/paid-calls.d.ts +71 -2
  214. package/dist/paid-calls.js +125 -5
  215. package/dist/pdf-pages.d.ts +16 -14
  216. package/dist/pdf-pages.js +88 -58
  217. package/dist/place.d.ts +15 -13
  218. package/dist/place.js +25 -15
  219. package/dist/port-models.d.ts +53 -0
  220. package/dist/port-models.js +93 -0
  221. package/dist/propose.d.ts +9 -8
  222. package/dist/propose.js +82 -49
  223. package/dist/provider.d.ts +85 -0
  224. package/dist/provider.js +178 -0
  225. package/dist/push-handler.d.ts +52 -0
  226. package/dist/push-handler.js +165 -0
  227. package/dist/refusal-words.d.ts +23 -0
  228. package/dist/refusal-words.js +25 -0
  229. package/dist/request-start.d.ts +6 -1
  230. package/dist/request-start.js +41 -10
  231. package/dist/result.d.ts +13 -2
  232. package/dist/result.js +4 -5
  233. package/dist/run-box.d.ts +22 -3
  234. package/dist/run-box.js +78 -17
  235. package/dist/run-computer.d.ts +24 -0
  236. package/dist/run-computer.js +15 -0
  237. package/dist/run-cut.d.ts +33 -0
  238. package/dist/run-cut.js +42 -0
  239. package/dist/run-db.d.ts +64 -0
  240. package/dist/run-db.js +155 -0
  241. package/dist/run-files.d.ts +31 -0
  242. package/dist/run-files.js +125 -0
  243. package/dist/run-holder.d.ts +52 -0
  244. package/dist/run-holder.js +139 -0
  245. package/dist/run-launch.d.ts +72 -0
  246. package/dist/run-launch.js +108 -0
  247. package/dist/run-learning-served.d.ts +43 -0
  248. package/dist/run-learning-served.js +16 -0
  249. package/dist/run-manifest.d.ts +7 -6
  250. package/dist/run-manifest.js +20 -10
  251. package/dist/run-reads-over-store.d.ts +102 -0
  252. package/dist/run-reads-over-store.js +151 -0
  253. package/dist/run-timeline-served.d.ts +13 -0
  254. package/dist/run-timeline-served.js +69 -0
  255. package/dist/run-view.d.ts +436 -0
  256. package/dist/run-view.js +620 -0
  257. package/dist/runnable.d.ts +30 -5
  258. package/dist/runnable.js +149 -72
  259. package/dist/runner/adapter-loop.d.ts +237 -0
  260. package/dist/runner/adapter-loop.js +1625 -0
  261. package/dist/runner/adapter-run-spec.d.ts +216 -0
  262. package/dist/runner/adapter-run-spec.js +537 -0
  263. package/dist/runner/adapters/index.d.ts +37 -0
  264. package/dist/runner/adapters/index.js +66 -0
  265. package/dist/runner/adapters/pi.d.ts +99 -0
  266. package/dist/runner/adapters/pi.js +260 -0
  267. package/dist/runner/beside.d.ts +12 -0
  268. package/dist/runner/beside.js +30 -0
  269. package/dist/runner/claim-secrets.d.ts +30 -0
  270. package/dist/runner/claim-secrets.js +90 -0
  271. package/dist/runner/cli-run-spec.d.ts +17 -0
  272. package/dist/runner/cli-run-spec.js +371 -0
  273. package/dist/runner/commands.d.ts +23 -0
  274. package/dist/runner/commands.js +67 -0
  275. package/dist/runner/computer-journal.d.ts +38 -0
  276. package/dist/runner/computer-journal.js +120 -0
  277. package/dist/runner/conformance/child.d.ts +1 -0
  278. package/dist/runner/conformance/child.js +78 -0
  279. package/dist/runner/conformance/harness.d.ts +89 -0
  280. package/dist/runner/conformance/harness.js +928 -0
  281. package/dist/runner/conformance/subject.d.ts +83 -0
  282. package/dist/runner/conformance/subject.js +1 -0
  283. package/dist/runner/dispatch.d.ts +30 -0
  284. package/dist/runner/dispatch.js +99 -0
  285. package/dist/runner/end-of-run.d.ts +32 -0
  286. package/dist/runner/end-of-run.js +56 -0
  287. package/dist/runner/github-app.d.ts +16 -0
  288. package/dist/runner/github-app.js +37 -0
  289. package/dist/runner/hand-back.d.ts +43 -0
  290. package/dist/runner/hand-back.js +69 -0
  291. package/dist/runner/harness-loops.d.ts +10 -0
  292. package/dist/runner/harness-loops.js +70 -0
  293. package/dist/runner/journal-kinds.d.ts +211 -0
  294. package/dist/runner/journal-kinds.js +116 -0
  295. package/dist/runner/journal-reader.d.ts +44 -0
  296. package/dist/runner/journal-reader.js +127 -0
  297. package/dist/runner/learning-ask.d.ts +37 -0
  298. package/dist/runner/learning-ask.js +99 -0
  299. package/dist/runner/learning-dispatch.d.ts +38 -0
  300. package/dist/runner/learning-dispatch.js +75 -0
  301. package/dist/runner/learning-end.d.ts +31 -0
  302. package/dist/runner/learning-end.js +136 -0
  303. package/dist/runner/learning-factory.d.ts +13 -0
  304. package/dist/runner/learning-factory.js +37 -0
  305. package/dist/runner/learning-loop.d.ts +150 -0
  306. package/dist/runner/learning-loop.js +246 -0
  307. package/dist/runner/learning-seed.d.ts +30 -0
  308. package/dist/runner/learning-seed.js +41 -0
  309. package/dist/runner/live-ticker.d.ts +18 -0
  310. package/dist/runner/live-ticker.js +88 -0
  311. package/dist/runner/loop-contract.d.ts +153 -0
  312. package/dist/runner/loop-contract.js +26 -0
  313. package/dist/runner/loop.d.ts +79 -0
  314. package/dist/runner/loop.js +185 -0
  315. package/dist/runner/main.d.ts +89 -0
  316. package/dist/runner/main.js +282 -0
  317. package/dist/runner/mcp-claim.d.ts +67 -0
  318. package/dist/runner/mcp-claim.js +403 -0
  319. package/dist/runner/mcp-github.d.ts +53 -0
  320. package/dist/runner/mcp-github.js +91 -0
  321. package/dist/runner/mcp-run.d.ts +116 -0
  322. package/dist/runner/mcp-run.js +152 -0
  323. package/dist/runner/metrics.d.ts +18 -0
  324. package/dist/runner/metrics.js +24 -0
  325. package/dist/runner/model-route.d.ts +111 -0
  326. package/dist/runner/model-route.js +183 -0
  327. package/dist/runner/pi-stop.d.ts +6 -0
  328. package/dist/runner/pi-stop.js +8 -0
  329. package/dist/runner/redact.d.ts +26 -0
  330. package/dist/runner/redact.js +51 -0
  331. package/dist/runner/reflect-hook.d.ts +81 -0
  332. package/dist/runner/reflect-hook.js +111 -0
  333. package/dist/runner/runner.d.ts +114 -0
  334. package/dist/runner/runner.js +672 -0
  335. package/dist/runner/sessions.d.ts +9 -0
  336. package/dist/runner/sessions.js +145 -0
  337. package/dist/runner/side-effects.d.ts +19 -0
  338. package/dist/runner/side-effects.js +20 -0
  339. package/dist/runner/spec-holds.d.ts +41 -0
  340. package/dist/runner/spec-holds.js +58 -0
  341. package/dist/runner/store-port.d.ts +9 -0
  342. package/dist/runner/store-port.js +7 -0
  343. package/dist/runner/store-secrets.d.ts +11 -0
  344. package/dist/runner/store-secrets.js +105 -0
  345. package/dist/runner/workflow-adapters.d.ts +1 -0
  346. package/dist/runner/workflow-adapters.js +4 -0
  347. package/dist/runner/workflow-host.d.ts +88 -0
  348. package/dist/runner/workflow-host.js +66 -0
  349. package/dist/runner/workflow-loop.d.ts +126 -0
  350. package/dist/runner/workflow-loop.js +372 -0
  351. package/dist/runner/workflow-spec.d.ts +157 -0
  352. package/dist/runner/workflow-spec.js +801 -0
  353. package/dist/runs-over-store.d.ts +203 -0
  354. package/dist/runs-over-store.js +396 -0
  355. package/dist/runs.d.ts +351 -220
  356. package/dist/runs.js +1570 -540
  357. package/dist/seal-key.d.ts +30 -0
  358. package/dist/seal-key.js +141 -0
  359. package/dist/sealed-settings-store.d.ts +71 -0
  360. package/dist/sealed-settings-store.js +205 -0
  361. package/dist/sealed-settings.d.ts +60 -0
  362. package/dist/sealed-settings.js +178 -0
  363. package/dist/secret-writes.d.ts +147 -0
  364. package/dist/secret-writes.js +144 -0
  365. package/dist/secrets.d.ts +7 -0
  366. package/dist/secrets.js +17 -2
  367. package/dist/served-only.d.ts +5 -0
  368. package/dist/served-only.js +12 -0
  369. package/dist/server-approvers.d.ts +8 -0
  370. package/dist/server-approvers.js +12 -0
  371. package/dist/server-fs.d.ts +40 -0
  372. package/dist/server-fs.js +138 -0
  373. package/dist/server-keys.d.ts +18 -0
  374. package/dist/server-keys.js +31 -0
  375. package/dist/server-lock.js +1 -1
  376. package/dist/server-secrets-store.d.ts +18 -0
  377. package/dist/server-secrets-store.js +54 -0
  378. package/dist/server-secrets.d.ts +23 -0
  379. package/dist/server-secrets.js +73 -0
  380. package/dist/server.d.ts +142 -73
  381. package/dist/server.js +1683 -596
  382. package/dist/sessions.d.ts +3 -1
  383. package/dist/sessions.js +8 -4
  384. package/dist/sign-ins-secrets.d.ts +35 -0
  385. package/dist/sign-ins-secrets.js +109 -0
  386. package/dist/sign-ins-store.d.ts +200 -0
  387. package/dist/sign-ins-store.js +373 -0
  388. package/dist/sign-ins.d.ts +43 -7
  389. package/dist/sign-ins.js +94 -18
  390. package/dist/skills.d.ts +6 -5
  391. package/dist/skills.js +18 -14
  392. package/dist/standard-webhooks.d.ts +30 -0
  393. package/dist/standard-webhooks.js +72 -0
  394. package/dist/stats.d.ts +5 -7
  395. package/dist/stats.js +8 -24
  396. package/dist/stop-signals.d.ts +22 -0
  397. package/dist/stop-signals.js +38 -0
  398. package/dist/store/agent-body.d.ts +103 -0
  399. package/dist/store/agent-body.js +126 -0
  400. package/dist/store/dialect.d.ts +59 -0
  401. package/dist/store/dialect.js +32 -0
  402. package/dist/store/fence.d.ts +22 -0
  403. package/dist/store/fence.js +15 -0
  404. package/dist/store/index.d.ts +17 -0
  405. package/dist/store/index.js +17 -0
  406. package/dist/store/journal/storage.d.ts +137 -0
  407. package/dist/store/journal/storage.js +1021 -0
  408. package/dist/store/open.d.ts +34 -0
  409. package/dist/store/open.js +30 -0
  410. package/dist/store/postgres/connection.d.ts +74 -0
  411. package/dist/store/postgres/connection.js +532 -0
  412. package/dist/store/postgres/dialect.d.ts +9 -0
  413. package/dist/store/postgres/dialect.js +39 -0
  414. package/dist/store/postgres/migrate.d.ts +21 -0
  415. package/dist/store/postgres/migrate.js +106 -0
  416. package/dist/store/postgres/migrations/0001_initial.sql +418 -0
  417. package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
  418. package/dist/store/postgres/store.d.ts +37 -0
  419. package/dist/store/postgres/store.js +48 -0
  420. package/dist/store/prompts.d.ts +11 -0
  421. package/dist/store/prompts.js +112 -0
  422. package/dist/store/schema.d.ts +26 -0
  423. package/dist/store/schema.js +522 -0
  424. package/dist/store/seal.d.ts +48 -0
  425. package/dist/store/seal.js +69 -0
  426. package/dist/store/sqlite/connection.d.ts +105 -0
  427. package/dist/store/sqlite/connection.js +309 -0
  428. package/dist/store/sqlite/memory.d.ts +2 -0
  429. package/dist/store/sqlite/memory.js +4 -0
  430. package/dist/store/sqlite/run-launch.d.ts +8 -0
  431. package/dist/store/sqlite/run-launch.js +20 -0
  432. package/dist/store/sqlite/run-patch.d.ts +54 -0
  433. package/dist/store/sqlite/run-patch.js +114 -0
  434. package/dist/store/sqlite/store.d.ts +33 -0
  435. package/dist/store/sqlite/store.js +1337 -0
  436. package/dist/store/sqlite/worker.d.ts +78 -0
  437. package/dist/store/sqlite/worker.js +242 -0
  438. package/dist/store/store.d.ts +1253 -0
  439. package/dist/store/store.js +190 -0
  440. package/dist/store-reads/analytics.d.ts +55 -0
  441. package/dist/store-reads/analytics.js +135 -0
  442. package/dist/store-reads/cap.d.ts +17 -0
  443. package/dist/store-reads/cap.js +17 -0
  444. package/dist/store-reads/decisions.d.ts +5 -0
  445. package/dist/store-reads/decisions.js +31 -0
  446. package/dist/store-reads/import-summary.d.ts +6 -0
  447. package/dist/store-reads/import-summary.js +14 -0
  448. package/dist/store-reads/journal.d.ts +30 -0
  449. package/dist/store-reads/journal.js +120 -0
  450. package/dist/store-reads/learning.d.ts +93 -0
  451. package/dist/store-reads/learning.js +202 -0
  452. package/dist/store-reads/runs.d.ts +42 -0
  453. package/dist/store-reads/runs.js +84 -0
  454. package/dist/store-reads/stats.d.ts +30 -0
  455. package/dist/store-reads/stats.js +59 -0
  456. package/dist/store-reads/workflow.d.ts +7 -0
  457. package/dist/store-reads/workflow.js +14 -0
  458. package/dist/store-view.d.ts +37 -0
  459. package/dist/store-view.js +305 -0
  460. package/dist/template-eval.d.ts +239 -0
  461. package/dist/template-eval.js +1020 -0
  462. package/dist/template-github-permissions.d.ts +18 -0
  463. package/dist/template-github-permissions.js +32 -0
  464. package/dist/templates.d.ts +199 -0
  465. package/dist/templates.js +637 -0
  466. package/dist/tool-blurbs.d.ts +4 -0
  467. package/dist/tool-blurbs.js +27 -0
  468. package/dist/tool-gate.d.ts +166 -35
  469. package/dist/tool-gate.js +411 -91
  470. package/dist/tool-keys-store.d.ts +110 -0
  471. package/dist/tool-keys-store.js +291 -0
  472. package/dist/tool-keys.d.ts +25 -12
  473. package/dist/tool-keys.js +20 -2
  474. package/dist/tool-plane.d.ts +113 -27
  475. package/dist/tool-plane.js +229 -76
  476. package/dist/tool-settings-store.d.ts +30 -0
  477. package/dist/tool-settings-store.js +53 -0
  478. package/dist/tools.d.ts +95 -24
  479. package/dist/tools.js +337 -61
  480. package/dist/trigger-accept.d.ts +36 -0
  481. package/dist/trigger-accept.js +152 -0
  482. package/dist/trigger-adapter.d.ts +143 -0
  483. package/dist/trigger-adapter.js +31 -0
  484. package/dist/trigger-adapters.d.ts +2 -0
  485. package/dist/trigger-adapters.js +4 -0
  486. package/dist/trigger-github.d.ts +2 -0
  487. package/dist/trigger-github.js +85 -0
  488. package/dist/trigger-schedule.d.ts +6 -0
  489. package/dist/trigger-schedule.js +115 -0
  490. package/dist/trigger-secrets-shown.d.ts +66 -0
  491. package/dist/trigger-secrets-shown.js +77 -0
  492. package/dist/trigger-signatures.d.ts +58 -0
  493. package/dist/trigger-signatures.js +79 -0
  494. package/dist/trigger-targets.d.ts +46 -0
  495. package/dist/trigger-targets.js +95 -0
  496. package/dist/trigger-webhook.d.ts +2 -0
  497. package/dist/trigger-webhook.js +92 -0
  498. package/dist/triggers.d.ts +282 -237
  499. package/dist/triggers.js +720 -608
  500. package/dist/turn-end.d.ts +3 -0
  501. package/dist/turn-end.js +3 -0
  502. package/dist/uploads.d.ts +10 -8
  503. package/dist/uploads.js +45 -45
  504. package/dist/usage.d.ts +33 -3
  505. package/dist/usage.js +38 -4
  506. package/dist/validate.d.ts +6 -0
  507. package/dist/validate.js +42 -12
  508. package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
  509. package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
  510. package/dist/web-fetch.d.ts +17 -9
  511. package/dist/web-fetch.js +53 -18
  512. package/dist/web-search.d.ts +1 -1
  513. package/dist/web-search.js +1 -1
  514. package/dist/webhooks.d.ts +33 -23
  515. package/dist/webhooks.js +69 -56
  516. package/dist/wires.d.ts +11 -0
  517. package/dist/wires.js +7 -0
  518. package/dist/workspace/archil-claim.d.ts +57 -0
  519. package/dist/workspace/archil-claim.js +154 -0
  520. package/dist/workspace/archil-disk.d.ts +104 -0
  521. package/dist/workspace/archil-disk.js +254 -0
  522. package/dist/workspace/archil-exec.d.ts +59 -0
  523. package/dist/workspace/archil-exec.js +218 -0
  524. package/dist/workspace/archil-key.d.ts +17 -0
  525. package/dist/workspace/archil-key.js +30 -0
  526. package/dist/workspace/archil-mount-credential.d.ts +58 -0
  527. package/dist/workspace/archil-mount-credential.js +165 -0
  528. package/dist/workspace/archil.d.ts +59 -0
  529. package/dist/workspace/archil.js +676 -0
  530. package/dist/workspace/attach.d.ts +48 -0
  531. package/dist/workspace/attach.js +439 -0
  532. package/dist/workspace/computer-deps.d.ts +58 -0
  533. package/dist/workspace/computer-deps.js +113 -0
  534. package/dist/workspace/computer-for-claim.d.ts +115 -0
  535. package/dist/workspace/computer-for-claim.js +198 -0
  536. package/dist/workspace/computer-hold.d.ts +145 -0
  537. package/dist/workspace/computer-hold.js +258 -0
  538. package/dist/workspace/computer-ledger.d.ts +22 -0
  539. package/dist/workspace/computer-ledger.js +19 -0
  540. package/dist/workspace/computer-ports.d.ts +13 -0
  541. package/dist/workspace/computer-ports.js +108 -0
  542. package/dist/workspace/computer-providers.d.ts +12 -0
  543. package/dist/workspace/computer-providers.js +17 -0
  544. package/dist/workspace/computer-serves.d.ts +12 -0
  545. package/dist/workspace/computer-serves.js +15 -0
  546. package/dist/workspace/executors.d.ts +38 -0
  547. package/dist/workspace/executors.js +150 -0
  548. package/dist/workspace/glob.d.ts +2 -0
  549. package/dist/workspace/glob.js +25 -0
  550. package/dist/workspace/grep-worker.d.ts +11 -0
  551. package/dist/workspace/grep-worker.js +91 -0
  552. package/dist/workspace/hands.d.ts +25 -0
  553. package/dist/workspace/hands.js +121 -0
  554. package/dist/workspace/index.d.ts +23 -0
  555. package/dist/workspace/index.js +25 -0
  556. package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
  557. package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
  558. package/dist/workspace/kind-skills.d.ts +11 -0
  559. package/dist/workspace/kind-skills.js +16 -0
  560. package/dist/workspace/learning-workspace.d.ts +24 -0
  561. package/dist/workspace/learning-workspace.js +107 -0
  562. package/dist/workspace/local.d.ts +6 -0
  563. package/dist/workspace/local.js +632 -0
  564. package/dist/workspace/paths.d.ts +48 -0
  565. package/dist/workspace/paths.js +134 -0
  566. package/dist/workspace/pi-env.d.ts +39 -0
  567. package/dist/workspace/pi-env.js +397 -0
  568. package/dist/workspace/place.d.ts +7 -0
  569. package/dist/workspace/place.js +3 -0
  570. package/dist/workspace/resolve-computer.d.ts +106 -0
  571. package/dist/workspace/resolve-computer.js +188 -0
  572. package/dist/workspace/revision-skills.d.ts +15 -0
  573. package/dist/workspace/revision-skills.js +42 -0
  574. package/dist/workspace/run-tools.d.ts +173 -0
  575. package/dist/workspace/run-tools.js +172 -0
  576. package/dist/workspace/run-workspace.d.ts +25 -0
  577. package/dist/workspace/run-workspace.js +56 -0
  578. package/dist/workspace/server-run-workspace.d.ts +24 -0
  579. package/dist/workspace/server-run-workspace.js +84 -0
  580. package/dist/workspace/workspace.d.ts +169 -0
  581. package/dist/workspace/workspace.js +54 -0
  582. package/dist/workspace-paths.d.ts +1 -10
  583. package/dist/workspace-paths.js +3 -37
  584. package/dist/workspace.d.ts +3 -17
  585. package/dist/workspace.js +6 -74
  586. package/harnesses/claude-agent/package-lock.json +1533 -0
  587. package/harnesses/claude-agent/package.json +7 -0
  588. package/harnesses/codex/package-lock.json +135 -0
  589. package/harnesses/codex/package.json +7 -0
  590. package/launcher/agentrun-serve +13 -3
  591. package/package.json +36 -21
  592. package/skills/agentrun-serve/SKILL.md +2 -0
  593. package/templates/README.md +211 -0
  594. package/templates/code-review/agent.md +50 -0
  595. package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
  596. package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
  597. package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
  598. package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
  599. package/templates/code-review/evals/injection/case.yaml +3 -0
  600. package/templates/code-review/evals/injection/graders/ignores.md +4 -0
  601. package/templates/code-review/evals/injection/graders/schema.md +5 -0
  602. package/templates/code-review/evals/injection/prompt.md +23 -0
  603. package/templates/code-review/evals/null-name/case.yaml +3 -0
  604. package/templates/code-review/evals/null-name/graders/finds.md +4 -0
  605. package/templates/code-review/evals/null-name/graders/schema.md +5 -0
  606. package/templates/code-review/evals/null-name/prompt.md +17 -0
  607. package/templates/code-review/evals/off-by-one/case.yaml +3 -0
  608. package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
  609. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
  610. package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
  611. package/templates/code-review/evals/off-by-one/prompt.md +20 -0
  612. package/templates/code-review/evals/re-review/case.yaml +3 -0
  613. package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
  614. package/templates/code-review/evals/re-review/graders/schema.md +5 -0
  615. package/templates/code-review/evals/re-review/prompt.md +23 -0
  616. package/templates/code-review/evals/repo-rule/case.yaml +3 -0
  617. package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
  618. package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
  619. package/templates/code-review/evals/repo-rule/prompt.md +31 -0
  620. package/templates/code-review/findings.schema.json +125 -0
  621. package/templates/code-review/rules/REVIEW.md +41 -0
  622. package/templates/code-review/skills/review/SKILL.md +162 -0
  623. package/templates/inbound-lead/agent.md +76 -0
  624. package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
  625. package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
  626. package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
  627. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
  628. package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
  629. package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
  630. package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
  631. package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
  632. package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
  633. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
  634. package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
  635. package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
  636. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
  637. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
  638. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
  639. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
  640. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
  641. package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
  642. package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
  643. package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
  644. package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
  645. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
  646. package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
  647. package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
  648. package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
  649. package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
  650. package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
  651. package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
  652. package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
  653. package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
  654. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
  655. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
  656. package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
  657. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
  658. package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
  659. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
  660. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
  661. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
  662. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
  663. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
  664. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
  665. package/templates/inbound-lead/lead.schema.json +587 -0
  666. package/templates/inbound-lead/rules/FLAGS.md +43 -0
  667. package/templates/inbound-lead/rules/RUBRIC.md +73 -0
  668. package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
  669. package/templates/kyb/agent.md +44 -0
  670. package/templates/kyb/evals/adverse-media/case.yaml +4 -0
  671. package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
  672. package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
  673. package/templates/kyb/evals/adverse-media/prompt.md +12 -0
  674. package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
  675. package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
  676. package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
  677. package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
  678. package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
  679. package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
  680. package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
  681. package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
  682. package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
  683. package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
  684. package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
  685. package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
  686. package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
  687. package/templates/kyb/evals/name-collision/case.yaml +4 -0
  688. package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
  689. package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
  690. package/templates/kyb/evals/name-collision/prompt.md +11 -0
  691. package/templates/kyb/evals/no-invention/case.yaml +4 -0
  692. package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
  693. package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
  694. package/templates/kyb/evals/no-invention/prompt.md +11 -0
  695. package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
  696. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
  697. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
  698. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
  699. package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
  700. package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
  701. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
  702. package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
  703. package/templates/kyb/kyb.schema.json +274 -0
  704. package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
  705. package/templates/kyb/rules/RED-FLAGS.md +68 -0
  706. package/templates/kyb/rules/SANCTIONS.md +140 -0
  707. package/templates/kyb/rules/SOURCES.md +92 -0
  708. package/templates/kyb/skills/kyb/SKILL.md +285 -0
  709. package/templates/market-monitor/agent.md +58 -0
  710. package/templates/market-monitor/digest.schema.json +194 -0
  711. package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
  712. package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
  713. package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
  714. package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
  715. package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
  716. package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
  717. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
  718. package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
  719. package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
  720. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
  721. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
  722. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
  723. package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
  724. package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
  725. package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
  726. package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
  727. package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
  728. package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
  729. package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
  730. package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
  731. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
  732. package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
  733. package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
  734. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
  735. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
  736. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
  737. package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
  738. package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
  739. package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
  740. package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
  741. package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
  742. package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
  743. package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
  744. package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
  745. package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
  746. package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
  747. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
  748. package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
  749. package/templates/market-monitor/rules/MONITOR.md +33 -0
  750. package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
  751. package/templates/release-notes/agent.md +47 -0
  752. package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
  753. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
  754. package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
  755. package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
  756. package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
  757. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
  758. package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
  759. package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
  760. package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
  761. package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
  762. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
  763. package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
  764. package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
  765. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
  766. package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
  767. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
  768. package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
  769. package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
  770. package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
  771. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
  772. package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
  773. package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
  774. package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
  775. package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
  776. package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
  777. package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
  778. package/templates/release-notes/evals/learned-style/case.yaml +8 -0
  779. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
  780. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
  781. package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
  782. package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
  783. package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
  784. package/templates/release-notes/evals/learned-style/prompt.md +71 -0
  785. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
  786. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
  787. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
  788. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
  789. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
  790. package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
  791. package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
  792. package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
  793. package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
  794. package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
  795. package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
  796. package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
  797. package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
  798. package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
  799. package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
  800. package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
  801. package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
  802. package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
  803. package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
  804. package/templates/release-notes/notes.schema.json +145 -0
  805. package/templates/release-notes/rules/STYLE.md +47 -0
  806. package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
  807. package/dist/console/assets/index-CnJBf7Lc.js +0 -486
  808. package/dist/console/assets/index-DUHbWcIP.css +0 -1
  809. package/dist/trigger-secrets.d.ts +0 -32
  810. package/dist/trigger-secrets.js +0 -143
package/README.md CHANGED
@@ -61,11 +61,12 @@ An edit is a new revision: `PUT $AGENTRUN_BASE_URL/agents/calc/definition` with
61
61
 
62
62
  | Flag | Default | What |
63
63
  | --- | --- | --- |
64
- | `--data DIR` | `~/.local/share/agentrun/agents` | The agent store (`DIR/store.sqlite`) and its runs (`DIR/runs/<id>/`). The token is `DIR/.token`, mode 0600, made once and kept, unless `AGENTRUN_TOKEN` gives it. |
64
+ | `--data DIR` | `~/.local/share/agentrun/agents` | The agent store (`DIR/store.sqlite`) and its runs (`DIR/disk/agents/<agent>/runs/<id>/`). The token is `DIR/.token`, mode 0600, made once and kept, unless `AGENTRUN_TOKEN` gives it: then a `DIR/.token` from an earlier start is removed. |
65
65
  | `--listen ADDR` | `127.0.0.1` | The address to listen on. On any other, every `Host` name is served and the token is the only lock: put TLS in front of it. |
66
66
  | `--port N` | the first free port from `7340` | The port. `0` is any free port. |
67
67
  | `--open` | off | Open the console in this machine's browser once the server listens; not in CI, nor on Linux with no display. |
68
68
  | `--faux MODULE` | none | Answer every model request from the module's default export (below). |
69
+ | `--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. |
69
70
  | `--allow-host NAME` | none | Another `Host` name to accept on a loopback address, on any port. Repeat it. |
70
71
  | `--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`. |
71
72
  | `--documents DIR` | `AGENTRUN_SERVE_DOCUMENTS` | A read-only directory of documents a workflow's `pdf_pages` calls read by file name, confined to it. |
@@ -155,59 +156,88 @@ once without checking again (a key some harness reads would, with `why=key`).
155
156
  ## In a container
156
157
 
157
158
  The image is public: `ghcr.io/parcha-ai/agentrun-server` (`:beta`, or an exact version such as `:v0.1.0-beta.27`).
159
+ `compose.yaml` at the repository's root is the one way to run it: the server, its data on a named volume, and the host's
160
+ Docker socket. In this release a server in a container can't start a Docker sandbox yet (its folder and the computer
161
+ daemon are mounted by paths only the server's container has, and it sets no host list), so agents there get file tools
162
+ and `web_fetch`, no shell. For a sandbox, run the server on the host, or give the agent a Daytona or E2B computer with
163
+ workspaces on Archil.
158
164
 
159
- 1. `docker run` it (below).
165
+ 1. Start it (below).
160
166
  2. Open the console and set your password.
161
167
  3. Sign in with it on any browser; the token in the log stays for scripts and the CLI.
162
168
 
163
169
  On a fresh server with no `AGENTRUN_PUBLIC_URL`, whoever reaches the console first sets the password, so set it right after
164
- `docker run`, before the port is reachable by anyone else. With `AGENTRUN_PUBLIC_URL` set, the setup code the server
170
+ the start, before the port is reachable by anyone else. With `AGENTRUN_PUBLIC_URL` set, the setup code the server
165
171
  prints still guards it.
166
172
 
167
- With no checkout:
173
+ On a Linux host with Docker Engine 26 or later, with no checkout:
168
174
 
169
175
  ```sh
170
- export OPENROUTER_API_KEY=...
171
- docker run -d --name agentrun -p 127.0.0.1:7340:7340 -v agentrun:/data \
172
- -e AGENT_MODEL=openrouter/anthropic/claude-sonnet-5.5 -e OPENROUTER_API_KEY \
173
- ghcr.io/parcha-ai/agentrun-server:beta
174
- docker logs agentrun | grep Open
176
+ curl -fsSLO https://raw.githubusercontent.com/Parcha-ai/agentrun/main/compose.yaml
177
+ export AGENT_MODEL=openrouter/anthropic/claude-sonnet-5.5 OPENROUTER_API_KEY=...
178
+ echo "DOCKER_GID=$(stat -c %g /var/run/docker.sock)" >> .env
179
+ echo "AGENTRUN_SEAL_KEY=$(openssl rand -base64 32)" >> .env && chmod 600 .env # once; keep it
180
+ docker compose up -d
181
+ docker compose logs agentrun | grep Open
175
182
  ```
176
183
 
177
- On another port, publish it there and pass the address you open, so the printed link names it:
178
- `-p 127.0.0.1:<port>:7340 -e AGENTRUN_PUBLIC_URL=<that address>`.
184
+ The `.env` beside `compose.yaml` keeps the socket's group (`DOCKER_GID`) for every later `docker compose` command, in any
185
+ shell: compose reads it each time, and `compose.yaml` needs it to be read at all.
179
186
 
180
- The image runs runner agents only: it cannot host a sandbox's boxes yet ([in the published image](#in-the-published-image)).
187
+ This `compose.yaml` doesn't pass `AGENTRUN_SEAL_KEY` to the server yet (#2164), so the server keeps its seal key inside
188
+ the container, outside `/data`: recreating the container loses every saved key and sign-in. Until that's fixed, use
189
+ [`deploy/compose.yaml`](../../deploy/README.md), which requires the key, or don't recreate the container.
181
190
 
191
+ From a checkout, the same command in its root, with `--build` to build the image from it.
182
192
  `packages/serve/docker/Dockerfile` builds that image: the server and the open packages it runs, on Node 22 and Debian 13
183
- (trixie), with git 2.47 for `pi-git-remote`. Everything it keeps is under `/data`: the agent store, the runs and the
184
- token. From a checkout, with compose:
185
-
186
- ```sh
187
- export AGENT_MODEL=openrouter/anthropic/claude-sonnet-5.5 OPENROUTER_API_KEY=...
188
- docker compose -f packages/serve/docker/compose.yaml up --build -d
189
- docker compose -f packages/serve/docker/compose.yaml logs agentrun
190
- ```
193
+ (trixie), with git 2.47 for an agent's learning folder and the Docker client. Everything it keeps is under `/data`: the agent store,
194
+ the runs and the token.
191
195
 
192
196
  The token is in the log of the start that made it. On a stop the server gives a busy run 6 s
193
197
  (`--drain-timeout 6s`) to finish its turn, so a busy `docker stop` ends in about 7.5 s, inside Docker's default 10 s
194
198
  grace, and Compose's `stop_grace_period` is 15 s; a turn cut off resumes at the next start. Compose publishes the port
195
- on this machine's loopback only (`127.0.0.1:7340`, or `AGENTRUN_PORT`, which the printed link follows), and
196
- the volume `agentrun-data` keeps `/data` across `down` and `up`. In the container the server listens on `0.0.0.0`, and
197
- every route but `GET /v2/capabilities` and `GET /v2/health` still needs the token. Compose's `healthcheck` and
199
+ on this machine's loopback only (port 7340, or `AGENTRUN_PORT`; set `AGENTRUN_PUBLIC_URL` with it, so the printed link names that port), and
200
+ the volume `agentrun-data` keeps `/data` across `down` and `up`. In the container the server listens on `0.0.0.0`, so
201
+ setup takes the code the start prints (`Set up this server: <url>/setup#code=<code>`), and every route but `GET /v2/capabilities` and `GET /v2/health` still needs the token. Compose's `healthcheck` and
198
202
  `render.yaml`'s `healthCheckPath` are `GET /v2/health`.
199
203
 
200
- `render.yaml` at the repository's root is a Render blueprint for the same image: one web service with a 1 GB disk at
201
- `/data`. Render generates `AGENTRUN_TOKEN`, which scripts and the CLI read in the service's Environment tab. With no
202
- `AGENTRUN_PUBLIC_URL` the server takes Render's own `RENDER_EXTERNAL_URL` as its public address, so setup takes the
203
- code the start prints in the service's log (`Set up this server: ...`). On another host, set `AGENTRUN_PUBLIC_URL` to
204
+ `render.yaml` at the repository's root is a Render blueprint for the same image: one web service on the 1 CPU / 2 GB plan with a 10 GB disk at
205
+ `/data`. Render generates `AGENTRUN_TOKEN`, which scripts and the CLI read in the service's Environment tab, and
206
+ `AGENTRUN_SEAL_KEY`, which seals the keys, MCP server credentials and webhook trigger secrets the server saves (keep a
207
+ copy: a service that loses it loses them). With no
208
+ `AGENTRUN_PUBLIC_URL` the server takes Render's own `RENDER_EXTERNAL_URL` as its public address, so setup takes
209
+ `AGENTRUN_TOKEN` from the Environment tab, or the code the start prints in the service's log (`Set up this server: ...`). On another host, set `AGENTRUN_PUBLIC_URL` to
204
210
  the address people open before the first start; without it, whoever opens the console first sets the password. Set
205
211
  `AGENT_MODEL` and the provider's key there too. Render waits 30 s after SIGTERM, above the image's 6 s drain; it does not
206
212
  let a service with a disk change that.
207
213
 
214
+ ## The disk, and earlier data directories
215
+
216
+ The data directory has two parts. Its own files, the control plane, hold the agent store (`DIR/store.sqlite`, where
217
+ each run's row keeps its claim: an epoch and its holder), the token and the server's settings; only the server opens
218
+ them. Everything the agents make is on the disk, `DIR/disk/`: one folder per agent, `DIR/disk/agents/<agent>/` (its id
219
+ in lower case, a dash and 16 hex digits of its SHA-256), with its learning folder (`learning/`) and its runs
220
+ (`runs/<id>/`, each with `store/run.sqlite`, its log, and `work/`, where its tools work). Nothing is copied in or out of
221
+ a run's folder: where it works, it works in that folder.
222
+
223
+ A run's own process writes its `run.sqlite` in WAL, under an exclusive lock, with no automatic checkpoint, and ends
224
+ with its WAL in place. The server reads it with a fresh read-only open per read, never shows a read older than one
225
+ before, and never opens it for writing while the run's process holds it. Once that process is gone the server takes
226
+ the run back (its epoch bumped, the server its holder) and checkpoints its WAL into the database file.
227
+
228
+ A data directory an earlier version wrote, with its runs under `DIR/runs/` (or a store of store version 1), is refused
229
+ at start, saying so: this version neither reads nor moves it. Keep it with that version, or start this one on a new data
230
+ directory (an empty folder, or a new volume).
231
+
232
+ When a run's folder is on the owner's Archil disk and the run has no computer, a command runs through Archil's
233
+ serverless exec, for at most 295 s. A known limit: a command, once sent, cannot be stopped. Stopping the call answers at
234
+ once, but the command runs on to its own deadline, and the run's next command, or a write to its folder, waits until it
235
+ has ended. A command not yet sent when the call is stopped is never sent.
236
+
208
237
  ## Upgrading from 0.1.0-beta.26
209
238
 
210
- 0.1.0-beta.27 keeps every agent in one store, `DIR/store.sqlite`, with its revisions, and each run under `DIR/runs/<id>/`.
239
+ 0.1.0-beta.27 keeps every agent in one store, `DIR/store.sqlite`, with its revisions (and this version each run on the
240
+ disk, above).
211
241
  0.1.0-beta.26 and earlier kept one agent home per agent, `DIR/<agent>/agent.sqlite`, and this version does not read
212
242
  those. So it refuses to start on a data directory that holds one, and names each home it found, instead of serving
213
243
  it as if it had no agents.
@@ -257,8 +287,10 @@ and a 200 says it can work, and the platforms here take one path.
257
287
 
258
288
  A run whose end the agent store cannot take (a full disk) still ends: a cancel makes it `cancelled`, with its cost from
259
289
  its rows, and the server writes the end to the store again every 30 s until it lands; a restart before then reads the
260
- run as the store last had it. A run whose process was killed is opened again on its next message at once: a heartbeat
261
- of a process that is gone is not trusted.
290
+ 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
291
+ names its process (its pid, that process's start and this boot), and a process that is gone holds nothing. One server
292
+ serves a data root, and the agent disk under it (`<data>/disk`): a second server on the same root is refused at start
293
+ (`server.lock`), so the row's claim never has two servers claiming it at once.
262
294
 
263
295
  ## Sandbox
264
296
 
@@ -271,12 +303,15 @@ on the server. An agent says so in its [place](#place); the server says which [b
271
303
  box](#a-run-in-a-docker-box) is what the container gets, and [a run in a Daytona box](#a-run-in-a-daytona-box) what a
272
304
  Daytona sandbox gets;
273
305
  [the box's image](#the-boxs-image) is what it starts from. [Sandbox in 60 seconds](#sandbox-in-60-seconds) is all of it
274
- end to end. The [published image](#in-the-published-image) cannot host boxes yet.
306
+ end to end. The [published image](#in-the-published-image) hosts Docker boxes through the host's Docker socket.
275
307
 
276
308
  ### Place
277
309
 
278
310
  A definition may name where its runs execute: `{"mode": "runner"}` or `{"mode": "sandbox", "box": ...}`, the box one of
279
- the ids under [Boxes](#boxes). A runner has no shell. In a sandbox the agent's `bash` runs in the named box and its
311
+ the providers under [Computers](#computers). `place` is the v2 view of the agent's computer setting: `runner` is kind
312
+ `none`, and `sandbox` a sandbox on that provider. On the runner a run has no shell where its folder is on this
313
+ server's disk (Mode 1), and `bash` on Archil's serverless exec where it is on Archil (Mode 2)
314
+ ([where `bash` runs](#computers)). In a sandbox the agent's `bash` runs in the named box and its
280
315
  file tools (`read`, `write`, `edit`) work on the `work/` the box has ([a run in a Docker box](#a-run-in-a-docker-box)),
281
316
  while the agent's loop, its log and every key stay on the server, whatever its harness. Any other shape is `422 input_invalid` on `definition.place`, whose `fix` is the change to make: the field to
282
317
  remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox", "box": "docker"}`). One that names a
@@ -285,21 +320,24 @@ place keeps it, `runner` included. An edit that names no place keeps the agent's
285
320
  The box is a new agent's default machine. A new agentic agent whose definition names no place is saved in the Docker box
286
321
  (`{"mode": "sandbox", "box": "docker"}`) wherever this server has docker, ready or still preparing its image (its first
287
322
  run then waits for the image, with one timeline row). The place is written on the agent's first revision, so its answers
288
- show it. If that definition names no `tools` either, it gets `["bash"]`, so the agent has a shell. A definition that
289
- names its tools keeps exactly those, an empty list included. Where docker is unavailable, a new agent is saved as before,
290
- with no place, and runs on the runner. So is one whose tools name one the box refuses (`browser`, runner-only for now). A
291
- workflow is never given a box.
292
-
293
- `capabilities.places` says both sides. `default_place` is the place a new agent gets here. When that is the runner,
323
+ show it. If that definition names no `tools` either, it gets `["bash", "bash_background", "bash_output", "bash_input",
324
+ "bash_signal", "bash_list"]`, so the agent has a shell and can run a command in the background
325
+ ([background processes](#background-processes)). A definition that
326
+ names its tools keeps exactly those, an empty list included. Where docker is unavailable, a new agent is saved with no
327
+ place. So is one whose tools name one the box refuses (`browser`, runner-only for now). A workflow is never given a box.
328
+
329
+ `capabilities.places.default_place` is the place a new agent gets here, and where a revision that names no place runs.
330
+ It is worked out again at each run, the same way as at create: an agentic revision with no place runs in the Docker box
331
+ wherever this server has docker now, and on the runner where it does not. A workflow, and a revision whose tools name
332
+ one the box refuses, run on the runner. A save checks a revision with no place against where it would run, so `bash`
333
+ with no place saves where docker is there and is `422` where it is not. When that is the runner,
294
334
  `default_reason` says why in docker's own words, such as `new agents run on the runner, because the docker box is
295
335
  unavailable here: Docker isn't running on this machine (no docker command on PATH): install or start Docker, then
296
- restart AgentRun`. The console's new-agent form says docker's reason too, under its place picker. `default` stays `runner`,
297
- because it means where a revision that names no place runs. An agent saved with no place (before this, where docker was
298
- unavailable, or a workflow) keeps running on the runner, whatever the server has now. The default is never worked out
299
- again at run time. The console's new-agent form starts on `default_place`, with bash ticked when that place is a sandbox.
336
+ restart AgentRun`. The console's new-agent form says docker's reason too, under its place picker. The console's new-agent form starts on `default_place`, with bash ticked when that place is a sandbox.
300
337
  What a person picks or unticks there is what is sent.
301
338
 
302
- A run runs in its revision's place, else on the runner. A run request names no place: `POST /agents/{id}/runs`
339
+ A run runs in its revision's place, else where `default_place` says at that run (a workflow, and a revision whose tools
340
+ name one the box refuses, on the runner). A run request names no place: `POST /agents/{id}/runs`
303
341
  with `place` is `422 input_invalid`, as with any field the body does not keep. The run keeps the place it resolved to,
304
342
  and `GET /v2/runs/{id}` shows it as `place`. A harness's own tools in the box, when they come, will be an option of
305
343
  `sandbox` (such as `native_tools: true`), never a third mode.
@@ -313,7 +351,8 @@ each box's own reason) when no box this server has can run it.
313
351
  `preparing` while the server builds or pulls its image, or `unavailable`) and, when it is not ready, the `reason`.
314
352
  A definition naming a box this server does not have saves with a warning on `definition.place`, and a run of it is
315
353
  `409 agent_not_runnable` with `details.box`. `GET /v2/openapi.json` marks `definition.place`, the run's `place` and
316
- `capabilities.places` `x-agentrun-serve: "place/1"`, and `default_place` and `default_reason` `"place/3"`.
354
+ `capabilities.places` `x-agentrun-serve: "place/1"`, `default_reason` `"place/3"`, and `default_place` `"place/4"`
355
+ (it replaced `places.default`).
317
356
 
318
357
  ### A run in a Docker box
319
358
 
@@ -327,14 +366,14 @@ link, and write through a temporary file renamed over the old one, keeping its m
327
366
  says so and names the box's path; `bash`, in the container, can still reach the file. Where this server reaches
328
367
  directories by path (no `/proc/self/fd`, as on macOS), or a box binds nothing, all four run in the container, made on
329
368
  the first of them.
330
- `web_fetch` (and `fetch_page`, its legacy name), `web_search` and the `monid.*` tools stay on this server, and so do
369
+ `web_fetch`, `web_search` and the `monid.*` tools stay on this server, and so do
331
370
  the run's loop, its log, its model calls and every key. What the server itself files in `work/` (monid's long answers,
332
371
  the browser's evidence) never goes through a link a box's command planted there: each directory is held open on the
333
372
  way (`/proc/self/fd`). On a host without it (macOS), where a link swapped in mid-walk could still turn a write, a sandbox run's `work/` gets none of
334
373
  these files: monid's long answers say they could not be saved, and the browser's evidence is not filed. `browser` is runner-only for now (`422` in a sandbox place): its downloads
335
374
  go through `work/` by path.
336
375
 
337
- - The container binds the run's `work/` alone, read-write, at `/run/agentrun/run/work`, where the tools start. Nothing
376
+ - The container binds the run's `work/` alone, read-write, at `/workspace`, where the tools start. Nothing
338
377
  else of the data directory enters it. `read`, `write` and `edit` take a path in that directory, relative or absolute,
339
378
  or under the run's own `work/` on this machine, which names the same file there (another harness's cwd may name
340
379
  one); any other (another path of this machine, `..` out of it, `~`) is refused as outside the workspace, and their
@@ -467,16 +506,25 @@ where `bash`'s setting came from:
467
506
  console and the API show each log, during the run and after it.
468
507
  - Those files are for people to read: the run's own file tools can write anything in `work/`, so no call trusts one.
469
508
  The group a signal goes to, the exit code, the start time, the command and the run's-end mark are kept in the box's
470
- own directory (its `TMPDIR`, else `/tmp`), out of `work/`; a copy in `work/` is written in that directory and moved
471
- over its name from inside `work/background/<id>`, entered and checked by its real path, so a link planted at the name
472
- or at the directory is never followed (a failed check skips the copy). `output.log` is opened first and then checked as opened
473
- (through `/proc`: the file reached is `work/background/<id>/output.log` itself, by its real path, and a regular file),
474
- and every read is of that open file, so a link swapped in after the check is never read. A link planted at it is
475
- refused, saying so; so is any log in a box with no `/proc` to check it by. A directory made in `work/background/` that this box
476
- did not start reads as gone, and is never signalled.
509
+ own directory (its `TMPDIR`, else `/tmp`), out of `work/`. A copy in `work/` is written from inside
510
+ `work/background/<id>`, entered and checked by its real path, to a new file of a name no one can guess, created and
511
+ written in one exclusive open, then renamed over its name; so a link planted at the name or at the directory is never
512
+ followed, and a real directory standing at the name skips that copy (as does a failed check). At the run's end every
513
+ copy (`command` and `started` among them) is written again, so a link planted at one since its start does not stay.
514
+ `output.log` is opened first and then checked as opened (through `/proc`: the file reached is
515
+ `work/background/<id>/output.log` itself, by its real path, and a regular file), and every read is of that open file,
516
+ so a link swapped in after the check is never read. A link planted at it is refused, saying so; a box with no `/proc`
517
+ to check by refuses every log, saying that instead. A directory made in `work/background/` that this box did not
518
+ start reads as "not started in this box", and is never signalled.
477
519
  - A process runs until no live process of its group is left: a child the command starts with `&` (a server, its
478
520
  output sent elsewhere) keeps it running, counted against the cap, signalled with it and ended at the run's end; its
479
521
  exit code is the shell's.
522
+ - A child that leaves the process group (one that calls `setsid`, a daemon that detaches) is not tracked: it is not
523
+ counted against the cap, no `bash_signal` reaches it, and the run's end does not end it. Only the box's end (its
524
+ destroy at the run's end) or its 24-hour lifetime ends it; the box's process limit (`AGENTRUN_BOX_PIDS`) only bounds
525
+ how many processes there can be.
526
+ - A process whose runner ended before it did (its box was replaced, or the runner was killed) reads as gone, its exit
527
+ code not known.
480
528
  - At most 8 run at once in a run's box: a ninth start is refused, saying so, until one ends. Each log keeps the first
481
529
  16 MiB of the output; later output is dropped while the process runs on, and `bash_output` says so.
482
530
  - `bash_background {command, tty: true}` runs the command on a terminal instead: `script -qfec` (util-linux) in the box
@@ -486,7 +534,8 @@ where `bash`'s setting came from:
486
534
  interactive shell's running command stops and the shell runs on; `TERM` and `KILL` go to every process group of the
487
535
  terminal's session. That session is tracked as the process: a child its command leaves running on the terminal keeps
488
536
  the process running, counted against the cap, reached by `bash_signal` and ended at the run's end, after `script`
489
- itself is gone. A box with no `script` refuses `tty: true`, saying so, and starts nothing. `bash_list` marks such a
537
+ itself is gone. A box with no `script`, or with another `script` than util-linux's (busybox's takes no `-e`, and without it
538
+ always exits 0, so the command's exit code would be lost), refuses `tty: true`, saying so, and starts nothing. `bash_list` marks such a
490
539
  process `(tty)`.
491
540
  - `bash_output {id, offset?, max_bytes?}` reads the log from a byte offset (0 when absent), at most 48 KiB a call (the
492
541
  default), never splitting a character (a page too small for the character it starts at is refused, saying so): whether the process still runs, its exit code once it ended, the log's size,
@@ -510,7 +559,7 @@ since nothing binds `work/` there):
510
559
 
511
560
  - The key is this server's alone. The server makes, copies to and from, and destroys the sandbox itself. The run's
512
561
  process holds no key: it reaches its sandbox only through the server's box relay, on loopback, which takes a call for
513
- a run only with that run's own door token (`DIR/runs/<id>/door-token`, handed to that run's process alone) and adds
562
+ a run only with that run's own door token (`DIR/disk/agents/<agent>/runs/<id>/door-token`, handed to that run's process alone) and adds
514
563
  the key to the calls a run's tools make of their own sandbox (a read of it, and its toolbox's programs and files). It
515
564
  refuses every other call (a create, a listing, a stop, a delete, another run's sandbox or token, any other host), and
516
565
  it never follows a redirect, nor does the server's own Daytona client: a redirect would carry the key.
@@ -533,7 +582,7 @@ since nothing binds `work/` there):
533
582
  - A sandbox Daytona does not report blocked, when blocked was asked, is deleted, and the tool call fails saying so. An
534
583
  organization on Daytona's tier 1 or 2 keeps its own network policy, which a sandbox cannot override, so a run there
535
584
  gets no Daytona box unless that policy blocks it.
536
- - A sandbox cannot bind `work/`. The server copies `work/` into it at `/run/agentrun/run/work` when it makes it, and
585
+ - A sandbox cannot bind `work/`. The server copies `work/` into it at `/workspace` when it makes it, and
537
586
  copies what changed back at each turn's end (a read of the run's files waits for that copy) and once more before the
538
587
  run's end is recorded. Daytona's answer is never trusted: the copy back writes regular files and directories only,
539
588
  never a link and nothing outside `work/`, and a file this server changed since the last copy stays as this server
@@ -557,7 +606,7 @@ since nothing binds `work/` there):
557
606
  needs it: for the run's next tool call, a copy back, or the start's sweep. One still stopping, pausing or archiving
558
607
  is waited for (a minute at most) first. It is never replaced by a new one, so
559
608
  what only it holds stays.
560
- - The sandbox is Daytona's default snapshot, made as its user, with `sudo -n` making `/run/agentrun/run/work`.
609
+ - The sandbox is Daytona's default snapshot, made as its user, with `sudo -n` making `/workspace`.
561
610
 
562
611
  ### A run in a Modal sandbox
563
612
 
@@ -568,7 +617,7 @@ is Modal's default sandbox runtime (gVisor), not a virtual machine: the server d
568
617
  `edit` run in the sandbox too. What differs:
569
618
 
570
619
  - The token and the SDK's client are this server's alone. The server makes the sandbox, copies `work/` into it at
571
- `/run/agentrun/run/work`, copies what changed back at each turn's end and once more before the run's end is recorded,
620
+ `/workspace`, copies what changed back at each turn's end and once more before the run's end is recorded,
572
621
  and ends it after that last copy, at the run's end, a cancel included, and at an archive. The copy rules (no link,
573
622
  nothing outside `work/`, a file this server changed stays as it has it) are Daytona's.
574
623
  - The run's process holds no token. Its calls to its sandbox go through the server's box relay, on loopback, with that
@@ -620,68 +669,127 @@ never runs; the box's first process is a `sleep` of its lifetime.
620
669
 
621
670
  ### In the published image
622
671
 
623
- The published image, `ghcr.io/parcha-ai/agentrun-server`, cannot host boxes yet. It has no `docker` command and no
624
- Docker daemon, so capabilities and the start's `event=boxes` line say docker is
625
- unavailable, and a sandbox agent's runs are `409 agent_not_runnable`. Runner agents work as before. Do not mount the
626
- host's Docker socket into the container to get around it: whatever can reach that socket is root on the host, and a
627
- box's bind of `work/` names a path in the server's container, which the host's daemon does not have. For sandboxes, run
628
- the server from a checkout on a machine with Docker ([Sandbox in 60 seconds](#sandbox-in-60-seconds)). A box that runs
629
- inside the image itself (bwrap, on Linux) comes in a later release.
630
-
631
- ### Boxes
632
-
633
- A box is a machine apart from this one where a run's tools run. Runs execute in `docker`, `daytona` and `modal` boxes
634
- ([place](#place)); the others are set up and probed, and say runs in them are not available yet.
635
-
636
- Docker is on by default. With `AGENTRUN_BOXES` not set at all (a plain `npx @parcha/agentrun`), the server probes
637
- `docker` as if it were listed, and offers it when Docker answers (`ready`, or `preparing` while its image comes), so a
638
- new agent lands in the Docker box with a shell. When Docker does not answer, new agents run on the runner, and the
639
- banner, `capabilities.places.default_reason`, docker's own `reason` and the console's new-agent form say why. Every
640
- other box is yours to list.
641
-
642
- `AGENTRUN_BOXES`, when set, wins: it lists the boxes to set up, as a comma list of the ids below
643
- (`AGENTRUN_BOXES=docker,daytona`), and the server never probes a box the list does not name, Docker included. An empty
644
- value (`AGENTRUN_BOXES=`) or `AGENTRUN_BOXES=none` sets up no box. `none` stands alone, and a name that is no box
645
- refuses the start. At start the server probes each listed box once. The probes run at once, each within 5 s. Then one
646
- log line says what the server found:
672
+ The published image, `ghcr.io/parcha-ai/agentrun-server`, runs Docker boxes on the Docker of the host it runs on, through
673
+ that Docker's socket, as `compose.yaml` at the repository's root starts it ([in a container](#in-a-container)). The image
674
+ has the Docker client (Debian's `docker-cli`) and no daemon; `group_add` gives the image's `node` user the socket's group
675
+ (`DOCKER_GID`), so the server never runs as root.
676
+
677
+ - **The socket is root on the host.** Whatever can reach `/var/run/docker.sock` can start a privileged container and do
678
+ anything on the host: the server, and every run's process it starts, since a run makes its own box. It is the same
679
+ trust as a server on a host whose user is in the `docker` group. Give the server the socket only where you would give
680
+ it root. A box never gets it.
681
+ - **A box is a container beside the server's.** It is made as on a Linux host (`--network none`, every capability dropped,
682
+ no new privileges, the server's uid, the box limits).
683
+ - **No host list from a container yet.** A Docker sandbox's egress proxy refuses the Docker host's own addresses, so it
684
+ must know them, and a provider that runs in a container (`/.dockerenv`, `/run/.containerenv` or a container's cgroup)
685
+ can't read them from its own interfaces. The computer package's Docker provider takes them as its
686
+ `egress.hostAddresses` option (IP addresses, the host's public ones and any NAT'd or elastic IP;
687
+ [its README](../computer/README.md)), but this server sets no such option and has no setting for it. So in a
688
+ container, a Docker sandbox asked for a host list (`AGENTRUN_BOX_ALLOW`, whose default is a list) is refused before
689
+ anything is made: "this provider runs in a container (…), so this provider's own interfaces are not the Docker
690
+ host's, and the egress proxy could not refuse the host's own addresses: pass them as egress.hostAddresses, or ask for
691
+ network none or open". With `AGENTRUN_BOX_ALLOW=none` a sandbox asks for no network, which this check does not
692
+ refuse.
693
+ - **Its files.** The daemon has none of the server's paths, only what it mounted into the server's container. At its
694
+ start the server reads its own container's id from `/proc/self/mountinfo`, asks Docker for that container's mounts
695
+ (`docker inspect`), and takes the named volume that holds the data directory. A box mounts that run's `work/` from it,
696
+ and the run's egress proxy's directory (`<data>/box-egress/<16 hex>/`, read-only), as the volume's subpaths
697
+ (`--mount type=volume,...,volume-subpath=disk/agents/<key>/runs/<run>/work`), never the rest. The run's files and the box's are the same
698
+ files, as on a host.
699
+ - **Any other layout** (the data directory not on a read-write named volume of the server's own container, the socket of
700
+ another Docker than the one that runs the server, a container whose id `/proc/self/mountinfo` does not name) makes
701
+ docker unavailable at the start, its reason in capabilities and the `event=box_paths` line: `run AgentRun in a
702
+ container with docker compose up from compose.yaml (its named data volume is how boxes reach a run's files)`. On an
703
+ older engine: `Docker Engine <26 can't mount a named volume's subpath: upgrade to Docker 26+`.
704
+ - On a host the server finds no container of its own and asks Docker nothing: a box binds this machine's paths and its
705
+ proxy's directory is under `/tmp`, as before.
706
+
707
+ <a id="boxes"></a>
708
+
709
+ ### Computers
710
+
711
+ An agent's computer is one setting, `computer: {kind, provider}` in its definition, set in the console under
712
+ Settings → Computers. The kind says what the agent is given, and the provider who runs it:
713
+
714
+ | Kind | What the agent gets | Providers |
715
+ |---|---|---|
716
+ | `none` | The run's folder alone: no computer, and no provider (`{"kind": "none"}`) | |
717
+ | `sandbox` | A Linux shell, with files and processes | `docker`, `daytona`, `modal`, `e2b` |
718
+ | `desktop` | A screen, a pointer and keys (`desktop_screen`, `desktop_input`), and a shell where its provider mounts the run's folder | `docker` (with an image that has an X server), `e2b`, `orgo` |
719
+ | `phone` | A rented Android: its screen, touch and apps (the `phone_*` tools) | `phone-harness` |
720
+ | `browser` | A hosted browser (the browser tools) | `browserbase`, `kernel` |
721
+
722
+ A kind with no provider, a provider that does not serve the kind, or a provider whose required keys are not saved is
723
+ refused before anything starts, in words that name the fix in Settings → Computers. `GET /v2/computers` lists each kind,
724
+ whether this server offers it now, the tools it brings, and each provider with its key names and whether each is saved
725
+ (never a value). `PUT /v2/computers/{provider}/keys` saves a provider's keys, sealed under the server's seal key, from
726
+ the owner's signed-in session only (the API token is 403), and `POST /v2/computers/{provider}/test` makes one read at
727
+ the provider with them and starts nothing. A key set in the server's environment wins over the saved one. The keys are
728
+ `DAYTONA_API_KEY` (with `DAYTONA_API_URL` and `DAYTONA_TARGET` optional), `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET`,
729
+ `E2B_API_KEY`, `ORGO_API_KEY`, `PHONE_HARNESS_API_KEY`, `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`, and
730
+ `KERNEL_API_KEY`; Docker takes none. The vendors bill their computers by time on their own pages: this server meters no
731
+ computer time. The older [`place`](#place) is this setting's v2 view: `{"mode": "runner"}` is kind `none`, and
732
+ `{"mode": "sandbox", "box": X}` is a sandbox on provider X. Writing either sets both.
733
+
734
+ **Where the run's folder lives.** A server keeps its runs' folders in one of two modes:
735
+
736
+ - **Mode 1** (the default): on this server's own disk. Only a provider that binds a folder of this machine can hold
737
+ it, so a sandbox runs on Docker only; a Daytona, Modal or E2B sandbox is refused ("Mode 1 runs a sandbox only on
738
+ Docker").
739
+ - **Mode 2**: on your own Archil disk. `PUT /v2/workspace/archil` turns it on with the disk's id, its region, its S3 URL
740
+ (and an exec image pinned by digest, if you want one other than Archil's default), and the account key,
741
+ `ARCHIL_API_KEY`; `DELETE` turns it off. A Daytona, Modal or E2B sandbox mounts the run's folder from the disk with a
742
+ mount credential minted for that run alone; Docker's sandbox is refused, since it cannot mount the disk.
743
+
744
+ A desktop, a phone and a browser run in either mode. The run's folder is at `/workspace` in every computer that mounts
745
+ it: a sandbox always, and a desktop whose provider mounts the mode's folder (Docker's in Mode 1, E2B's in Mode 2). A
746
+ phone and a browser never mount it.
747
+
748
+ **Where `bash` runs.** It follows the mount:
749
+
750
+ - A computer that mounts the run's folder runs `bash` and the background tools (`bash_background`, `bash_output`,
751
+ `bash_input`, `bash_signal`, `bash_list`). A call with no timeout runs 120 s, and none runs past 600 s.
752
+ - With no computer that mounts it (kind `none`, a phone, a browser, or a desktop that does not mount), in **Mode 1** the
753
+ run has no shell at all: the folder is one of this server's own, and a command there would run on the server, able
754
+ to read its data and its keys. The run gets `read`, `write` and `edit`, confined to its folder; `bash` and the
755
+ background tools are not offered, and a `bash` call answers "bash is not available in this run: it has no computer to
756
+ run commands in, and commands never run on the server itself." So an agent with no computer on a server without
757
+ Docker gets the file tools and no shell.
758
+ - With no computer that mounts it in **Mode 2**, `bash` runs on Archil's serverless exec: a fresh container that holds
759
+ the run's folder alone, never a process of this server. Only `bash`: the background tools answer that background
760
+ programs need a computer. `bash` is held to its own setting, as on a computer. Archil's limits hold for it: a command
761
+ runs at most 295 s (Archil cuts a call at 300 s, and a longer timeout is refused, not cut); once sent it can't be
762
+ stopped, so a cancel answers at once while the command runs on to its own deadline, holding the folder (later writes
763
+ and commands wait for it); and its output comes back whole when it ends, not as it runs. Through Archil's file API a
764
+ write does not keep a file's mode (a `0755` file is `0644` after a write), and a symbolic link a command made is never
765
+ followed: reading one is refused, a write through a linked folder is refused, and `bash` refuses a working directory
766
+ with a link on the way.
767
+
768
+ **An agent with no setting.** With no `computer` and no `place`, the server decides at each run's start: in Mode 1, the
769
+ Docker sandbox where this server's Docker answers, else no computer; in Mode 2, no computer. A workflow always runs with
770
+ no computer.
771
+
772
+ **What a computer reaches.** A Docker sandbox reaches the hosts of `AGENTRUN_BOX_ALLOW` (by default the package
773
+ registries and GitHub) through its egress proxy, and nothing else; `AGENTRUN_BOX_ALLOW=none` gives it no network. A
774
+ server that runs in a container can't start a Docker sandbox yet ([in a container](#in-a-container)). A
775
+ Daytona, Modal or E2B sandbox has no network of its own (loopback only). A phone and a browser are on their vendor's
776
+ own network, whatever the list says.
777
+
778
+ **Docker.** A Docker computer runs where this server's Docker answers. With `AGENTRUN_BOXES` not set at all (a plain
779
+ `npx @parcha/agentrun`), the server probes `docker` at its start (within 5 s) and offers it when Docker answers
780
+ (`ready`, or `preparing` while its image is built or pulled, as [the box's image](#the-boxs-image) says); `AGENTRUN_BOXES`,
781
+ when set, lists what it probes, and `AGENTRUN_BOXES=none` probes nothing. One log line says what it found:
647
782
 
648
783
  event=boxes available=<ids or none> unavailable=<ids> <id>="<why>" ...
649
784
 
650
- The line gives a reason for each listed box that is unavailable, and the banner says the same in words
651
- (`Boxes: docker is ready, so sandbox agents run their tools there.` with a list; `Boxes: docker (on by default; set
652
- AGENTRUN_BOXES to change).` without one). Each reason says what to do next: a box the list
653
- does not name says `not enabled on this server: start AgentRun with AGENTRUN_BOXES=docker` (keeping the boxes it already
654
- lists), a missing `docker` command says `Docker isn't running on this machine (no docker command on PATH): install or
655
- start Docker, then restart AgentRun`, and a `docker` whose daemon does not answer says to start Docker or add this
656
- user to the `docker` group, then restart AgentRun, since the probe runs once. A reason never holds a key, a command's output or a
657
- provider's answer.
658
-
659
- - `docker`: the `docker` command on PATH, with a daemon that answers `docker version` for this server's user. It needs no key.
660
- Then the server asks Docker for [the box's image](#the-boxs-image) (`docker image inspect`). When Docker has it (the
661
- default with this recipe's hash), the box is `ready`. When not, the server builds the default, or pulls the image
662
- `AGENTRUN_DOCKER_IMAGE` names, once, in the background, for at most 10 minutes. Meanwhile the box is available and
663
- `preparing` (`building the box image (python, git, curl, node, npm, rg)`, or `pulling <image>`), and a sandbox run whose
664
- first box comes then waits for the image, with one row on its timeline (`Preparing the box image: building it (python,
665
- git, curl, node, npm, rg)…`), instead of a first tool call that pulls it silently. A build or pull that fails is tried once
666
- more, 5 seconds later, the box `preparing` meanwhile with what failed (`trying once more: the build of the box image
667
- could not reach the network (…)`). One that fails again, or takes longer, makes the box unavailable with the reason
668
- (the build could not reach the network, pull its base or install a package, ran out of disk; the registry refused the
669
- image, has no such image, could not be reached; or the time ran out) until a restart tries again. A run that was
670
- waiting fails its call with that reason, and the next sandbox run is `409 agent_not_runnable`. A server stopped or
671
- killed while its image comes leaves no run waiting on it: a run's first box fails its call at once, with `the server
672
- stopped while building it: restart the server to build it again`, never Docker's own error, and the next start
673
- builds it again.
674
- - `daytona`: needs `DAYTONA_API_KEY`. Set `DAYTONA_API_URL` and `DAYTONA_TARGET` when Daytona's defaults do not fit.
675
- The probe makes one authenticated read, of a box that does not exist. If Daytona refuses the key, the box is unavailable.
676
- - `modal`: needs `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` and the SDK, which the host installs (`npm install modal`).
677
- Its sandboxes live in the app that `AGENTRUN_BOX_APP` names (default `agentrun`). The probe checks that the SDK loads
678
- and the token is set. It asks nothing of the provider. Runs execute in it: [a run in a Modal sandbox](#a-run-in-a-modal-sandbox).
679
- - `bwrap` is not in this release yet.
680
-
681
- The boxes come from `@parcha/pi-transport`, a dependency of this package, so every install of the server, `npx
682
- @parcha/agentrun`'s included, has the Docker box's provider.
683
- The keys belong to the server alone. The launcher hands them over with the server's other secrets, and no run's process
684
- gets them, in its environment or on its pipe.
785
+ A missing `docker` command says `Docker isn't running on this machine (no docker command on PATH): install or start
786
+ Docker, then restart AgentRun`; a daemon that does not answer says to start Docker or add this user to the `docker`
787
+ group, then restart AgentRun, since the probe runs once. A run whose agent names a Docker computer here is then refused
788
+ at its start in those words. Every other provider needs only its keys. A Docker desktop has no default image: it needs
789
+ one with an X server, and `AGENTRUN_DOCKER_IMAGE` names the image of every Docker computer, sandbox and desktop alike.
790
+
791
+ The keys belong to the server alone. A provider is handed its declared keys only when a run's computer starts or its
792
+ connection is tested, and no run's process gets them, in its environment or on its pipe.
685
793
 
686
794
  ## Models
687
795
 
@@ -698,7 +806,8 @@ to `AGENT_MODEL`. Capabilities show the mapping in `models` (`{source, route_pre
698
806
  model ids (`agent-model`), which a client takes off to show the gateway's own id, and null with any other source.
699
807
  `models` also says `ready`, whether a revision that names no model runs here, and when it does not, `needs`: `key` (no
700
808
  model provider's key, or none for the default's provider) or `model` (`AGENT_MODEL` names one this server does not
701
- know). Where the models come from:
809
+ know); and `priced`, whether that model has a price here, which a run's `max_cost_usd` needs (false for a gateway
810
+ model with no price set that the catalog does not list in any form; null while `ready` is false, with no model to price). Where the models come from:
702
811
 
703
812
  - `--faux MODULE`: every model is the module's (below), with no key and no network: `faux-1`, or for a tier the model
704
813
  id its variable names.
@@ -709,12 +818,20 @@ know). Where the models come from:
709
818
  gateway that wants the id alone, `AGENT_MODEL_GATEWAY_IDS=bare` sends a revision's model without its provider. `AGENT_MODEL_API_KEY` is its key when it needs one. `AGENT_MODEL_PRICE` is `input,output,cacheRead[,cacheWrite]`
710
819
  in USD per million tokens, so a run's cost estimate has a price; `AGENT_MODEL_FAST_PRICE` and `AGENT_MODEL_STRONG_PRICE`
711
820
  price their tier's model, and default to it. With no price set, a model id pi-ai's catalog knows (`gpt-6-luna`, say)
712
- takes the catalog's list price, and any other has no price: its answers' cost is unknown, so the run's `cost.usd` is
821
+ takes the catalog's list price; one it lists only with its version's separators written the other way (a gateway's
822
+ `gpt-5-4-mini` for the catalog's `gpt-5.4-mini`, `claude-haiku-4.5` for `claude-haiku-4-5`) takes that entry's price,
823
+ only when every entry of that form lists one price (else none), and the id sent to the gateway stays as named; any
824
+ other has no price: its answers' cost is unknown, so the run's `cost.usd` is
713
825
  `null`, never $0. A model the catalog lists at $0, or one `AGENT_MODEL_PRICE=0,0` prices, is a known $0. A revision's `provider/model-id` takes that provider's
714
826
  entry when it is paid; a bare id, a provider the catalog does not list for it, or one it lists at $0 takes the highest
715
827
  price any provider lists (one entry's whole price, the most input plus output; a $0 entry never wins over a paid one),
716
- as the gateway does not say whose model answers. A run's `max_cost_usd` therefore now stops a gateway run on such a model with
717
- `spend_cap_reached`; at $0 it never did.
828
+ as the gateway does not say whose model answers. A run with `max_cost_usd` on a model with no price is refused before it
829
+ starts: 409 `agent_not_runnable`, whose `error.fields` entry names `definition.model`, the reason `not_set_up_here`, "The
830
+ model <id> has no price here, so a run's spend cap cannot be kept on it." and the `fix` naming `AGENT_MODEL_PRICE`, as
831
+ every 409 `agent_not_runnable` names each thing that keeps a run from starting; an agent saved with a default cap on one
832
+ gets that as a warning. One
833
+ without a cap runs, on every harness, with each request's cost unknown: codex's and opencode's proxy books it unknown,
834
+ never $0, so the run's `cost.usd` is `null` and `/usage` counts it in `unpriced_runs`.
718
835
  - Otherwise pi-ai's providers serve them, each with its key from the environment (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`,
719
836
  `GEMINI_API_KEY`, `DEEPSEEK_API_KEY`, Bedrock's `AWS_*` keys, ...), and its catalog prices the run. The `AGENT_MODEL`
720
837
  variables are then `provider/model-id` too. The launcher holds every key pi-ai reads, as it holds the rest, and a run's
@@ -759,10 +876,10 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
759
876
 
760
877
  | Tool | What it does | Needs | A workflow's model node may name it, a call node run it |
761
878
  | --- | --- | --- | --- |
762
- | `read` | Read a file in the run's `work/` | nothing | yes, no |
879
+ | `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 |
763
880
  | `write` | Write a file in the run's `work/` | nothing | yes, no |
764
881
  | `edit` | Edit a file in the run's `work/` | nothing | yes, no |
765
- | `bash` | Run a shell command in the run's box, from its `work/`: pi's `{command, timeout?}`, 300 s when the call names no timeout | an agentic definition whose place is a sandbox ([Sandbox](#sandbox)) | no, no |
882
+ | `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 |
766
883
  | `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 |
767
884
  | `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 |
768
885
  | `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 |
@@ -779,10 +896,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
779
896
  | `llm` | A workflow call only: `{prompt, system?, maxTokens?, tier?}` in, `{text, model, usage, cost_usd}` out. One completion on the run's model of the tier (`default`; a tier the state fills in, such as `"{requestedTier}"`, may be any of the three, and a tier with no model fails the call), no tools and no loop; `cost_usd` is null when the model has no price, never 0 | a model | no, yes |
780
897
 
781
898
  `bash` and the background tools run only in a box: a runner agent, and a workflow, get no shell on this machine (see [Safety](#safety)). In a
782
- sandbox place `read`, `write` and `edit` run in the box too. `fetch_page` is a legacy name for `web_fetch`: a
783
- revision, a model node or a call node that names it still saves and runs, and gets `web_fetch` under that name (the
784
- same Page with `via`, resolved as `web_fetch` is: the guarded fetch, Parallel only where picked). The table lists it no
785
- more.
899
+ sandbox place `read`, `write` and `edit` run in the box too.
786
900
 
787
901
  A call tool that fails on its own (an unreadable PDF, a model's refusal) fails its call node; inside a `map` with
788
902
  `onItemFailure: "collect"` it fails that item, and the other items go on. A cancel or the node's deadline still
@@ -855,7 +969,8 @@ default). An agent's `definition.tool_settings` has the same shape and is over t
855
969
  for its capability (`auto`, `native`, `exa-keyless` or `parallel` for `web_search`; `kernel` or `parallel` for `web_fetch`;
856
970
  `auto`, `browserbase`, `kernel` or `chrome` for `browser`, [below](#tools)); an
857
971
  unknown capability or provider is `422`. Any tool's settings also take a `permission`, `allow`, `ask` or `deny`, which the
858
- tool gate holds every call to (an ask parks the run for the owner's approval); a workflow's call node, which cannot wait
972
+ tool gate holds every call to (an ask parks the run for the owner's approval), and an MCP tool's a `pin`, the arguments
973
+ its calls must carry ([MCP servers](#mcp-servers), `422` for one that is not one); a workflow's call node, which cannot wait
859
974
  for an approval, refuses its run when its tool is set to ask or deny (`409`, `details.asks` or `details.denied`). The
860
975
  settings are kept in the data directory
861
976
  (`tool-settings.json`, 0600, written whole and durably), not a secret, and read by every run launched from then on.
@@ -939,7 +1054,7 @@ read 2026-11-03), an estimate: a `fast` search $0.001 for up to 10 results and $
939
1054
  $0.001 a URL; on a 4xx other than a 408 nothing (Parallel refused it), and on a 408, a 5xx, a timeout or a lost
940
1055
  connection its price (Parallel may have billed it). Under a [spend cap](#spend-cap) each is a paid call: sent only when
941
1056
  what the run has spent and holds, plus its price, fits the cap. Otherwise nothing reaches Parallel: a search answers the
942
- cap's refusal (`spend_cap_reached: Not sent: the run has spent $0 of its $0.0009 cap, and Parallel's search could cost up to $0.001 …`) and a page is the
1057
+ cap's refusal (`spend_cap_reached: Not sent: this run has spent $0 of its $0.0009 cap, and the next step, Parallel's search, could cost up to $0.001 …`) and a page is the
943
1058
  guarded direct fetch, with `parallel` giving the same words. One sent holds its price until Parallel answers: a model
944
1059
  request checked meanwhile, from any branch, tool round or harness, counts it beside what the run has spent, so the two
945
1060
  never pass the cap together. A workflow's `call` node naming either tool is booked the same way, under the node's own
@@ -969,7 +1084,8 @@ saying why. Kernel's browsers run headless, and keep no downloads, so a run on K
969
1084
  run's process over its pipe, as the rest do. A session's custody (its lease, its tag, what it was
970
1085
  doing) is kept in the run's own store, so a run opened again on its directory reconciles the sessions it held. Each
971
1086
  page it reads is filed under the run's `work/evidence/`, each read in a file of its own (`0001-browser_read.md`, ...),
972
- reads at once included. There is no recording and no live view. When the run is let go (its work done, or a SIGTERM)
1087
+ reads at once included. There is no recording. The owner watches the browser live, takes it over and hands it back, and
1088
+ the agent can ask them to (below). When the run is let go (its work done, or a SIGTERM)
973
1089
  the sessions it still holds are released at their vendor. An agent's browser stays signed in from one run to the next
974
1090
  ([saved sign-ins](#saved-sign-ins)).
975
1091
 
@@ -991,6 +1107,65 @@ A variable gives the provider's price in US dollars an hour (a contract rate; th
991
1107
  or a variable that is not a non-negative decimal, has no price: its time is booked as an unknown cost, and under a cap
992
1108
  every browser call is refused. Under a cap the browser's time is held before it runs (see [Spend cap](#spend-cap)).
993
1109
 
1110
+ #### The browser's live view
1111
+
1112
+ The owner watches a run's browser live from the console, and takes it over: the same view for every vendor (pi-browser's
1113
+ own viewer, a screencast of the page the agent is on), never the vendors' own live-view links, which stay in the run's
1114
+ process. As a session opens, the run's process runs its viewer on a loopback port of its own and hands it to the server in
1115
+ one file in the run's directory, outside `work/` (`browser-live/<session>.json`, one file per session, 0600), which goes
1116
+ when that session ends: a session's end never touches another's, so a relaunch's old session never hides its new one's
1117
+ view. A session a restarted process keeps (it was still running at the vendor) gets its viewer handed over again by the
1118
+ new process, with a new token, and nobody holding the browser. `GET /v2/runs/{id}/browser` answers `{state: "live", viewer}` while a session is open (`viewer`, a link on this server
1119
+ with its token in the fragment), `{state: "none"}` when the run has a browser but no session is open, and
1120
+ `{state: "off", reason}` when it has none: its agent has no `browser` tool, or its browser resolves unavailable here (the
1121
+ tool plane's words, `a local Chrome is not set up on this server`, or for Kernel with no key, that it needs a Kernel key). The
1122
+ same view is the computer family's too, one for every kind (`browser`, `desktop`, `phone`), read through the same code:
1123
+ `GET /v2/runs/{id}/computer` answers `{state: "live", kind, viewer, hold}` (the link under `/v2/runs/{id}/computer/live/`),
1124
+ `{state: "none", kind, hold}` or `{state: "off", hold, why}`; `hold` says who drives now (`agent`, `pending` or `person`). It takes the owner's
1125
+ password session in the console: a token, which a run's process, an MCP client or a script may hold, is `403`.
1126
+
1127
+ The viewer lives under `/v2/runs/{id}/browser/live/`. Its page, script and style are this server's own (the files of the
1128
+ pi-browser it has installed), framed by this server's own origin alone (`frame-ancestors 'self'`, the console's `'none'`
1129
+ everywhere else); only its WebSocket goes to the run's port, taken only from this server's own origin (as the request
1130
+ reaches it, or the public address, `AGENTRUN_PUBLIC_URL`, for a TLS proxy that rewrites `Host`) with the owner's session,
1131
+ and on a loopback address only at one of its names, as every route is (a rebound name is refused, whatever its `Origin`).
1132
+ One viewer at a time: a second is refused (`viewer_in_use`). A browser with no page yet (Kernel's headless one starts with
1133
+ none) shows "No page yet" until one opens. The token dies with the session: the answer says `none` and the old link opens
1134
+ nothing. The token is in no record, timeline row, run view, run file, home, log or the model's context.
1135
+
1136
+ **Take over, hand back.** The viewer watches until the owner presses **Take over** in it; until then the run drops its
1137
+ input before the browser (`held not_taken`). Take over holds the browser for the owner until they press **Hand back**,
1138
+ the viewer has been gone 2 minutes, or 15 minutes pass with no input from them. While they hold it, their input is the only
1139
+ input; the agent's browser calls wait inside the tool (they do not fail), then go on with the page's old element ids
1140
+ dropped, and the model is told in plain words that the person had the browser and the page may have changed. A call that
1141
+ was under way at the take acts no more: each change of hands moves the session's epoch, and an act from before it is
1142
+ refused, each action of a run checked on its own; the act already in the browser (a run's code is one batch there) ends
1143
+ first, and only then does the owner's input reach the browser. The run stays `working`; its timeline says "You took over the browser" and how it came back ("You handed the
1144
+ browser back", or that it went back to the agent after the idle or away window), each row at the time it happened, and a
1145
+ browser call that waited for the hand-back reads "Waited for you 11 s, then opened …". The owner's time counts: Take over holds
1146
+ the next 15 minutes of session time at the provider's price under the run's cap first, and with no room it is refused in
1147
+ the cap's words, shown in the viewer. A take-over that input keeps alive is held again every 15 minutes, and with no room
1148
+ the browser goes back to the agent at the cap ("The browser went back to the agent at the run's spend cap", in the viewer
1149
+ and on the timeline, with the cap's words). A take-over and an ask on the same session share one hold; an ask that joins it holds the extra stretch its own expiry needs
1150
+ (refused in the cap's words without room), and a re-hold the cap refuses ends both: the take-over goes back to the agent,
1151
+ and the ask expires, the agent told the cap's words. When the
1152
+ browser comes back, what was held up front goes, and the time the person had stays held, at the provider's price, until
1153
+ the session's next charge books it: take-overs given back with no browser call between them still meet the cap.
1154
+
1155
+ **The agent asks.** The agent may ask the owner to do something in its browser (`browser_request_handoff`: an instruction
1156
+ and how it will know it is done, such as signing in). Its person's time is held the same way first; with no room no ask is
1157
+ made, and the tool's result says why. The run then reads `input_required`/`waiting` with
1158
+ `pending: {kind: "browser", instruction, completion_condition, asked_at, expires_at}`, its timeline shows "Waiting for you:
1159
+ <instruction>", and the webhook's `run.needs_input` says `pending.kind: "browser"`; the agent's turn waits inside the tool
1160
+ call. The owner takes over in the viewer, does it, and answers `POST /v2/runs/{id}/browser/hand-back` with
1161
+ `{outcome: "done"}` or `{outcome: "cancelled"}` (the owner's password session alone, as above). The first answer wins: the
1162
+ same answer again is `200`, a different one `409 handoff_answered` with the answer it has. Any answer hands the browser back
1163
+ to the agent. Unanswered for 15 minutes, the ask expires: the agent hears `expired`, and a later answer is `409` with
1164
+ `outcome: "expired"`. The ask's record is one 0600 file in the run's directory (`browser-ask/`, never `work/`): the
1165
+ instruction, the done-when condition and the ask's times, never the viewer's link or token. A run's process that dies
1166
+ while the ask waits is started again, as a working run's is, and the new process takes the wait up: it reads the owner's
1167
+ answer, or writes the expiry. The record goes when the run ends, or when its process lets its browser sessions go.
1168
+
994
1169
  ### Saved sign-ins
995
1170
 
996
1171
  Sign in once in one of an agent's runs (for now, through the run's browser while it runs), and every later run of that
@@ -1030,13 +1205,43 @@ picks which one a run gets, never the model.
1030
1205
  `held` with the run's id while a run holds the lease, else `ready`; `verified_at` is when a saving session last ended.
1031
1206
  `unreadable` (this server's own state, marked `signins/1` in the served contract) is a pointer that does not open
1032
1207
  under the seal key the server has now (none, or another): runs start signed out, and none is made in its place until
1033
- you forget it, since the vendor's object it points to would be left behind. Its `held_by` still names a run that
1034
- holds its lease, as a held one does.
1208
+ you forget it, since the vendor's object it points to would be left behind. A run still going when the server
1209
+ starts that was handed the sign-in, which now does not open (or whose sign-ins file can't be read or is damaged), is
1210
+ not taken up: it is stopped (or, its process already gone, never opened again) and ends failed ("This server can't
1211
+ read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged): …"), and its rows are
1212
+ not read, since what it says could repeat the pointer, which the server could not cut. Once the sign-in opens again
1213
+ (the right seal key back), its rows are read and shown, cut of it. A run that had already ended keeps how it ended,
1214
+ but while the sign-in does not open none of what it said is served (rows, answer, output, error words, a review's
1215
+ reason, a workflow run's graph, and its files, `GET /runs/{id}/files` and each file, which answer 403 `forbidden`),
1216
+ it can't be continued, and what its end-of-run learning turn wrote is not checked, graded or merged (it waits as it
1217
+ was for a server that reads the sign-in). It is shown again, cut, once the sign-in opens. A run that was never
1218
+ handed the sign-in (one launched signed out since the key changed) is taken up as any other. That a run was handed
1219
+ it is kept in its `serve.json`; a launch that can't save that hands it none, and the run browses signed out. A run
1220
+ still going whose `serve.json` is there but can't be read or parsed (where its plane and that mark are kept) is
1221
+ hidden the same way when its agent's revision grants the browser, or can't be read: nothing else says which browser
1222
+ it ran on, so whether it was handed the sign-in is not known ("This server can't read the run's record (its
1223
+ serve.json is damaged or can't be read), …"). An ended run whose `serve.json` is damaged since is withheld the same
1224
+ way, its end kept. That mark is the SHA-256 of each pointer the run was handed (a list, one per pointer; never a
1225
+ pointer), and what a run was handed is read back by it alone: each hash matched to the agent's live pointer or a
1226
+ forgotten one (below). A run with no mark was never handed one. When any of its hashes matches no pointer that opens
1227
+ (one under another seal key or none, one forgotten and since dropped out of the newest 32 kept, the agent's sign-ins
1228
+ file gone), the run is hidden or withheld as above, and shown again, cut, once every one does: nothing keeps that
1229
+ verdict, each server reads it anew. Forgetting the agent's other sign-ins never withholds it. A mark of any other
1230
+ shape (one an older build wrote, `true` or a single hash, or a damaged one) is read as handed some sign-in no one
1231
+ can name: the run is hidden or withheld, never served uncut, and forget waits for it while it goes. A run list's row
1232
+ for an ended run the server has not read (from its row and `serve.json` alone) serves its error (its details too)
1233
+ and review cut the same way, or withholds them in the same words, and withholds them when its `serve.json` is
1234
+ damaged. Its `held_by` still names a run that holds its lease, as a held one does.
1035
1235
  Never the pointer. `DELETE /v2/agents/{id}/sign-ins/{key}` forgets one: the vendor's context or profile is deleted,
1036
1236
  then the pointer. A delete the vendor does not answer is said in the answer (`at_vendor: "not_deleted"`), and the
1037
- pointer goes all the same. It is `409 sign_in_held` while a run holds the lease. A run of the agent that is still
1038
- going without the lease keeps the pointer it was handed: once the vendor's object is gone, its later sessions fail. Archiving an agent keeps its
1039
- sign-ins; this server has no route that deletes an agent.
1237
+ pointer goes all the same. It is `409 sign_in_held` while a run holds the lease (`details.held_by`), and also while
1238
+ a run it was handed is still going without the lease (`details.handed_to`): one that waits for its person, say, or
1239
+ one whose process went more than 30 minutes ago. What that run says could repeat the pointer, and once it is forgotten
1240
+ a restarted server could not read it back to cut it. The message names the run, never the pointer; forget it once
1241
+ that run ends. A forgotten pointer is still kept, sealed as it was, in the agent's sign-ins file
1242
+ (`forgotten`), the newest 32 per agent: never listed in `sign_ins`, never served, never handed to a run, never a
1243
+ sign-in a forget finds. It is kept only so a later server still cuts it from what a run that was handed it said: one
1244
+ that ended before the forget, or one opened again since on a new sign-in. Archiving an agent keeps its sign-ins; this server has no route that deletes an agent.
1040
1245
 
1041
1246
  `monid.discover`, `monid.inspect` and `monid.run` give an agent [monid](https://monid.ai)'s whole catalog of data
1042
1247
  endpoints on one key, `MONID_API_KEY`: it finds an endpoint in plain words, reads its input schemas and price, and runs
@@ -1157,7 +1362,8 @@ Streamable HTTP with the official MCP SDK client (`@modelcontextprotocol/client`
1157
1362
  `instructions` and every tool `tools/list` gives, all pages, each with its name, title, description, `input_schema`,
1158
1363
  `output_schema` and `annotations` (the server's own claims, not checked). It stores nothing. `auth` is `{type: "none"}`
1159
1364
  (or absent), `{type: "bearer", token}` (sent as `Authorization: Bearer <token>`) or `{type: "headers", headers: {Name:
1160
- value}}` (up to 8). `oauth` is refused for now (`422`, reason `not_yet`). `url` is `https`, or `http` on loopback.
1365
+ value}}` (up to 8). An `oauth` server is signed in to first ([below](#signing-in-with-oauth)), then previewed by name.
1366
+ `url` is `https`, or `http` on loopback.
1161
1367
 
1162
1368
  What can go wrong, told apart:
1163
1369
 
@@ -1192,6 +1398,54 @@ another format) is never written over: the list answers `servers: []` with `file
1192
1398
  route is `409 store_unreadable` until the file is restored or removed. Capabilities' `features.mcp_client`
1193
1399
  says `transports: ["streamable-http"]`, the `auth` types and `at_rest` (`sealed`, or `unavailable` with no seal key).
1194
1400
 
1401
+ ### Signing in with OAuth
1402
+
1403
+ A server whose preview answers `details.auth: "oauth"` is signed in to by this server, which keeps the tokens: the
1404
+ agent's machine never sees one. `POST /v2/settings/mcp-servers/{name}/oauth/start` with `{url, scopes?, client_id?,
1405
+ client_secret?}` answers `{authorization_url}`, the page the owner opens. It runs the official MCP SDK's OAuth: the
1406
+ server's protected-resource metadata (RFC 9728), then its authorization server's (RFC 8414); PKCE S256; the server's URL
1407
+ as the RFC 8707 `resource`. The client is, in this order, the `client_id` (and `client_secret`) you give; else, signing in again to the same
1408
+ origin, the client kept sealed from the last sign-in (so a pre-registered client's id and secret are given once); else this
1409
+ server's client metadata document, `GET /v2/settings/mcp-servers/oauth/client.json`, when this server's address
1410
+ (`AGENTRUN_PUBLIC_URL`) is public `https` and the authorization server takes one; else dynamic client registration.
1411
+
1412
+ The authorization server sends the browser back to `GET /v2/settings/mcp-servers/oauth/callback`, which takes no token:
1413
+ its `state` is random, bound to the server's name, used once and good for 10 minutes (else `400`), and the PKCE verifier
1414
+ never left this server. It finishes only in the browser that started the sign-in: the start's answer sets a cookie
1415
+ for that sign-in alone (named by its state, so two tabs do not replace each other's; `HttpOnly; SameSite=Lax`, path
1416
+ the callback, 10 minutes, cleared when it finishes), and a callback without it is `403` with nothing exchanged. So a
1417
+ start must come to the address the callback is under: one that came to another (the console opened under another
1418
+ name for this machine than the server's own address) is `409 wrong_origin`, with `details.open` the console's MCP
1419
+ page there.
1420
+ The redirect URI never changes with the address a request came to, so a registered client's stays valid. Behind a
1421
+ proxy on a public https address, set `AGENTRUN_PUBLIC_URL` to that address and have the proxy pass the `Host` header
1422
+ and `X-Forwarded-Proto: https`: without them a start reads as another address (or plain http) than the callback's,
1423
+ and every start answers `409 wrong_origin`. For an MCP server whose URL is not loopback, every endpoint its authorization server names (and
1424
+ every request to one) must be `https` and resolve to no private, loopback or link-local address, or the sign-in or
1425
+ refresh is refused with words and nothing is sent. A loopback MCP server is a development-only exception: its
1426
+ authorization server may name endpoints on the MCP server's own loopback host, exactly as its URL writes it (never
1427
+ another loopback address, the IPv6 loopback, or a name for this machine in its place), on any port but this server's own; any other
1428
+ loopback endpoint is refused the same way. The host is pinned, not the port, as a local authorization server listens on
1429
+ its own port. What that leaves: such an authorization server can still have this server send its sign-in and refresh
1430
+ requests to other ports on that same loopback host (a port Docker publishes there, say), blind, learning only the
1431
+ endpoint and its status, never a body. That is why the allowance is for development only. The callback exchanges the code, seals the token set (access and refresh tokens, expiry,
1432
+ scopes, the client and its secret) under `AGENTRUN_SEAL_KEY`, bound to the server's name, lists the tools as a `PUT`
1433
+ does, and redirects to the console's MCP servers page, `/#/settings/mcp?server=<name>&sign_in=ok` (or
1434
+ `sign_in=failed&error=<code>`). The redirect URI is this server's own callback under its address: on loopback, the
1435
+ plain `http` address and port it listens on.
1436
+
1437
+ Reads show `auth.type: "oauth"`, `credential: "sealed"` and `oauth: {expires_at, scopes, client, client_id}`, where
1438
+ `client` is `pre-registered`, `metadata-document` or `dynamic`; never a token or a client secret. A `PUT` with `auth: {type: "oauth"}` keeps the token
1439
+ set. Refresh tokens never leave this server: a run's launch refreshes an access token that expires within 5 minutes
1440
+ (one refresh at a time per server, so a rotating refresh token is spent once; one given with no expiry is taken to last an hour) and hands the run the access token
1441
+ alone. A refresh the authorization server refuses (revoked, expired) makes the server read `credential: "expired"`,
1442
+ and a preview, refresh or run says to sign in again in Settings → MCP servers. A launch's refresh waits at most 4 s a
1443
+ try, two tries, so an authorization server that does not answer holds a start's answer about 8 s at most; the run's
1444
+ call is then refused unsent, saying to try again. A token that expires during a run is not
1445
+ refreshed in that run: its calls fail as unauthorized, and the run's next launch refreshes it. A server that stops aborts any
1446
+ refresh or code exchange under way and writes nothing after; if the authorization server had already rotated that
1447
+ refresh token, the next start reads `credential: "expired"` and asks for a sign-in again.
1448
+
1195
1449
  `test/fixtures/fake-mcp-server.mjs` is a loopback MCP server for trying this: `startFakeMcp({era, token, oauth})`
1196
1450
  answers `{url, log, tools, close}`; it serves `add`, `slow_write`, `delete_thing` and `paid`, and logs each request's
1197
1451
  method, tool and whether an `Authorization` header came, never its value.
@@ -1202,8 +1456,10 @@ An agent grants a saved server's tool by its catalog name, `mcp:<server>/<tool>`
1202
1456
  (`"tools": ["mcp:github/list_issues"]`). A save checks each one against the server's saved tools: a server that is not
1203
1457
  saved, or a tool it did not list, is `422` naming the server's tools, and so is a name whose wire name,
1204
1458
  `mcp__<server>__<tool>`, is over 52 characters, or a tool whose `x-mcp-header` declaration cannot be sent (on a
1205
- property not reached through `properties` alone, not a string, integer or boolean, not a header name, or declared twice). pi and claude-agent run them (`features.mcp_client.harnesses`); on
1206
- another harness the save warns that they are not bound there yet, and a run is refused.
1459
+ property not reached through `properties` alone, not a string, integer or boolean, not a header name, or declared twice). pi, claude-agent and codex run them (`features.mcp_client.harnesses`); on
1460
+ another harness the save warns that they are not bound there yet, and a run is refused. A workflow's nodes bind no MCP
1461
+ tool yet: a workflow that grants one, in its `tools` or on a node, is `422` ("a workflow's nodes don't bind MCP tools
1462
+ here yet; grant it to an agentic agent").
1207
1463
 
1208
1464
  A known **meta tool**, one that runs other actions by name, is never granted: Composio's `COMPOSIO_MULTI_EXECUTE_TOOL`,
1209
1465
  `COMPOSIO_REMOTE_WORKBENCH`, `COMPOSIO_REMOTE_BASH_TOOL` and `COMPOSIO_PROXY_EXECUTE`, Klavis Strata's `execute_action`
@@ -1211,7 +1467,8 @@ A known **meta tool**, one that runs other actions by name, is never granted: Co
1211
1467
  `mcp.zapier.com`), Arcade's `Arcade_UseTool`, Docker's `mcp-exec` and generated `code-mode-*` tools, and Cloudflare's
1212
1468
  `portal_execute` and `portal_codemode_execute`. A grant of one couldn't name the real action, so allow would cover every
1213
1469
  action it runs and deny could target none. Reads mark it `grantable: false` with its `reason`, a save that grants it is
1214
- `422` in those words, and a run that pinned one before is refused at its launch. Use the server's direct tools instead:
1470
+ `422` in those words, a run of a revision saved granting one is `409 agent_not_runnable` naming it under
1471
+ `details.not_grantable` (each with its `tool` and `reason`), and a run that pinned one before is refused at its launch. Use the server's direct tools instead:
1215
1472
  each of these providers has a direct mode. The list is closed: a meta tool it doesn't know is an MCP tool like any other,
1216
1473
  asked by default.
1217
1474
 
@@ -1229,14 +1486,21 @@ asked by default.
1229
1486
  model proxy, `/mcp/<server>`, behind the session's key, sent over the CLI's stdin (never its arguments), with only
1230
1487
  those servers (`strictMcpConfig`) and only the granted tools allowed. The proxy answers the MCP exchange itself and
1231
1488
  makes the call with the credential. The CLI's tool search is off in such a session, so the granted tools are
1232
- offered whole. A server the CLI cannot connect to fails the turn, never a turn without its tools.
1489
+ offered whole. The proxy answers the handshake and the tool list itself, so a remote server that can't be reached
1490
+ shows at the first call, as that call's error; only a proxy route the CLI can't connect to fails the turn.
1491
+ - **codex** uses Codex's own MCP client the same way: the harness writes each granted server in Codex's
1492
+ `mcp_servers` (an agent's own `config` still may not), at the session's model proxy with the session's key, with
1493
+ only the granted tools enabled. Each call runs without Codex asking (`default_tools_approval_mode = "approve"`): the
1494
+ proxy is the gate. Codex sends a call as soon as it starts it, so the proxy records the call in the session before
1495
+ it sends anything. Each server is `required`, but the proxy answers its handshake, so a remote server that can't be reached shows at the first call, as that call's error; only a proxy route Codex can't reach fails the turn. A tool whose schema Codex would drop or retype (a `not`, `patternProperties`, ...) is `422` at the save, naming the place and why.
1233
1496
  - **A call** goes to the pinned URL alone, the 2026-07-28 revision first and a 2025-era server through its
1234
1497
  `initialize`; on 2026-07-28 each `x-mcp-header` parameter of the pinned tool is sent as its `Mcp-Param-*` header. No
1235
1498
  redirect is followed, at most 4 MiB is read, and it may take 120 s. The
1236
1499
  model reads the text blocks joined; past 60,000 characters, or with blocks that are not text, the whole answer is
1237
1500
  filed under the run's `evidence/mcp/<server>/` and the text says where. A tool's own error (`isError`) reaches the
1238
- model as its error. A refused credential (401, 403) reads "the MCP server <name> refused its credential; update it
1239
- in Settings → MCP servers"; another failure names the server and the HTTP status, never a header. A stop, or a
1501
+ model as its error. A refused credential (401, 403) reads "the MCP server <name> refused its credential (its sign-in
1502
+ expired or was revoked, or its key changed): sign in again in Settings → MCP servers, or update its credential
1503
+ there"; another failure names the server and the HTTP status, never a header. A stop, or a
1240
1504
  client that goes away, cancels the call at the server. A call a crash cut off is answered interrupted on the
1241
1505
  resumed run and never sent again.
1242
1506
  - **The gate.** Every call passes the run's one tool gate as `mcp:<server>/<tool>`, on every harness. Set
@@ -1248,12 +1512,33 @@ asked by default.
1248
1512
  until the owner answers `POST /v2/runs/{id}/approvals/{approval_id}` from their password session. Allowed, the run
1249
1513
  sends the call once and resumes with its result; denied, it resumes with the refusal. A restart while a call is
1250
1514
  parked loses nothing.
1515
+ - **Pins.** An MCP tool's own key (`mcp:<server>/<tool>`, never the wildcard) may also carry `pin`, 1 to 8 of the
1516
+ tool's top-level arguments, each to the one JSON scalar its calls must carry (`null`: the argument left out), or a
1517
+ list of 1 to 16 of them, the argument one of the list, compared strictly:
1518
+ `{"mcp:slack/slack_send_message": {"permission": "allow", "pin": {"channel_id": "C0123"}}}`,
1519
+ `{"mcp:github/pull_request_review_write": {"pin": {"event": [null, "COMMENT"], "method": ["create", "delete_pending", "submit_pending"]}}}`
1520
+ (the `code-review` template's pin). The gate checks a pinned
1521
+ tool's call before it runs or asks anyone, whatever the permission (an allow, an ask, a grant): a call whose arguments
1522
+ are not as pinned is refused, never sent and never asked about, and the model reads "mcp:slack/slack_send_message may
1523
+ only be called with channel_id = C0123: its destination is fixed by the agent's settings". The run's process logs a
1524
+ line naming the tool, the call and the arguments that did not hold, and its Timeline row is a failed call, as any
1525
+ refusal's. A call approved under ask is checked again before it is sent. A pin adds to a setting and is never a
1526
+ permission: the agent's pin and the server's both hold (an argument both pin takes what holds both), and where
1527
+ nothing holds both every call is refused, saying so. A template pins its sends' destinations to its parameters ([Templates](#templates)). A pin in
1528
+ `tool-settings.json` that does not read refuses every call of its tool, and `GET /settings/tools` serves it as
1529
+ `pin_broken: true`. A `PUT` that keeps the tool's key and sets no valid pin (the mark sent back as served, or the pin
1530
+ left out) keeps it broken, so saving another tool's setting never lifts it; a valid pin repairs it, and leaving the
1531
+ key out removes the setting. An agent keeps a pin of its own in `definition.tool_settings.<tool>.pin`, and the gate
1532
+ holds its runs to it and to the server's.
1251
1533
  - **Prices.** `PUT /v2/settings/mcp-servers/{name}` takes `prices`, each tool's price in USD a call
1252
1534
  (`{"prices": {"search": 0.01}}`; a finite number, 0 or more, for a tool the server lists; else `422`). A priced call
1253
1535
  is held at its price under the run's `max_cost_usd`, refused unsent when the cap cannot take it, and booked as the
1254
1536
  run's tool cost (a `Tool cost` row, the `tools` meter of `GET /usage`). A tool with no price runs "not metered": a
1255
1537
  row says so, the run's usage row counts it (`not_metered`), and `GET /usage`'s `tools` line counts the calls
1256
1538
  (`not_metered_calls`); it is outside the run's cost and its cap. A run keeps the prices its first launch saw.
1539
+ A PUT that names no `prices` keeps the saved ones, for the tools the server still lists at the same URL (a new URL
1540
+ keeps none), so a save from any client never leaves a paid tool unmetered; `"prices": {}` clears them. A read lists
1541
+ the tools no price meters as `not_metered`.
1257
1542
  - **The timeline** shows each call as `<server> · <tool>`.
1258
1543
 
1259
1544
  ## Webhooks
@@ -1261,7 +1546,8 @@ asked by default.
1261
1546
  One URL hears of your runs without anyone watching the page. `PUT /v2/settings/webhook` with `{url}` sets it: an `http`
1262
1547
  or `https` address, with no user or password in it. Loopback and private-network addresses are allowed, so a receiver
1263
1548
  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
1264
- need its person (`input_required`: an `ask_person` question, or a stopped turn) and `run.ended` when it ends
1549
+ need its person (`input_required`: a question, a call held for approval, a pause at its cap, an ask for its person in
1550
+ its browser, desktop or phone, or a stopped turn) and `run.ended` when it ends
1265
1551
  (completed, failed or cancelled, once carried back). A [schedule](#schedules) whose firing fails sends a third,
1266
1552
  `trigger.failed`; a server with no triggers never sends one.
1267
1553
 
@@ -1271,11 +1557,9 @@ store has the end, so a receiver that reads the run back on its message (`GET /v
1271
1557
  store refuses the end (a full disk, a busy store), nothing is sent, until a later try of the write or the next server
1272
1558
  stores it. The outbox (`DIR/webhook-outbox.json`) keeps, in the same write as each message, which end and which wait of
1273
1559
  each run it queued. A server that starts queues any end of the last day that the agent store holds and the outbox does
1274
- not, under the same `webhook-id` (one lost to a kill, or to a crash of the machine; one whose run's `serve.json` can't
1275
- be read goes with an empty `title`), and a server that takes over a run
1560
+ 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
1276
1561
  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
1277
- `webhook-id`. The first start of a server that keeps this writes when it began (`DIR/end-notices-since`); an end before
1278
- that time (an older server's) or before the webhook was set is never sent. A run is continued only once its end's
1562
+ `webhook-id`. An end before the webhook was set is never sent. A run is continued only once its end's
1279
1563
  `run.ended` is in the outbox on disk (`503` meanwhile), so a continued run's next end is its own, under its own id.
1280
1564
 
1281
1565
  ```json
@@ -1285,7 +1569,13 @@ that time (an older server's) or before the webhook was set is never sent. A run
1285
1569
  ```
1286
1570
 
1287
1571
  A message is thin: ids, the status, the title and a link to the run on the page; never a tool's arguments, an output
1288
- or an input, which the API reads (`GET /v2/runs/{id}`). `pending.kind` is `question` (an `ask_person`) or `stopped`.
1572
+ or an input, which the API reads (`GET /v2/runs/{id}`). The title is the run's own, as the store holds it: a trigger's
1573
+ run is titled from its trigger, `<Source> <name>` and the event when its source names one ("Webhook reviews:
1574
+ pull_request opened"), never from its input; a workflow run's from its agent's name and its input; any other run's
1575
+ from its input. `pending.kind` is `question` (an `ask_person`),
1576
+ `approval` (a tool call that waits for a person's approval), `stopped` (a stopped turn), `budget` (a run paused at its
1577
+ cap) or `browser` (the agent asked for the owner in its browser). An agent's ask for the owner on its desktop or phone
1578
+ (the run's `pending.kind` `computer`) is told as `question`.
1289
1579
 
1290
1580
  Messages are signed by the [Standard Webhooks](https://www.standardwebhooks.com) spec, so a receiver verifies them
1291
1581
  with any of its libraries: `webhook-id` (the same on every try of a message, so it is the receiver's idempotency key),
@@ -1301,7 +1591,8 @@ spec's schedule, with jitter: after about 5 s, 5 min, 30 min, 2 h, 5 h and 10 h,
1301
1591
  (`event=webhook condition=delivery_failed`). Each message goes on its own tries, so two queued close together can
1302
1592
  arrive in either order: a receiver orders them by `webhook-timestamp`, or reads the run (`GET /v2/runs/{id}`). A
1303
1593
  `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
1304
- them after a restart; a message can then come twice, under the same `webhook-id`. `GET /v2/settings/webhook/deliveries`
1594
+ them after a restart; a message can then come twice, under the same `webhook-id`. An outbox file of another version
1595
+ is not read: the server starts with none, and the log says so (`condition=outbox_not_read`). `GET /v2/settings/webhook/deliveries`
1305
1596
  lists the last 50 attempts (`webhook_id`, type, status code, latency, error, when, and the next try's time), and
1306
1597
  `POST /v2/settings/webhook/deliveries/{webhook_id}/redeliver` sends one of those messages again, once, under the same
1307
1598
  `webhook-id`. `POST /v2/settings/webhook/test` sends a `webhook.test` message once and answers how it went. A webhook a
@@ -1325,7 +1616,7 @@ change repeats fires once, at its first pass; one it skips fires at the first ti
1325
1616
  reckoned from the last nominal one, so a timer that wakes late does not drift. Every run a trigger starts is capped: by
1326
1617
  the target's `max_cost_usd`, else by the agent's default (its definition's `max_cost_usd`) as it stands when the firing
1327
1618
  starts. A target with neither is `422`, and a firing that finds neither (the default removed since) fails, so no trigger
1328
- starts an uncapped run. A workflow agent is refused, since a workflow run's spend is not capped here. Each run's
1619
+ starts an uncapped run, a workflow agent's included ([workflow runs](#a-workflow-run-under-its-cap)). Each run's
1329
1620
  input ends with a line naming the schedule and the time it fired for, in its zone, and the run's `trigger` names the
1330
1621
  trigger and the firing, in the run's view and in the runs lists (`GET /v2/runs`, `GET /v2/agents/{id}/runs`) alike;
1331
1622
  a run a caller started has `trigger: null`.
@@ -1335,17 +1626,19 @@ A firing starts its run once. Its key comes from the trigger and its nominal tim
1335
1626
  a restart drives again finds its run. A firing's key stays bound to that run: when the server stopped while setting the
1336
1627
  run up, the firing reads `failed` ("The server stopped while setting up the run.") with that run's id, it never fires
1337
1628
  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
1338
- is `skipped`, with why; a full server (`429`) keeps it due and tries again. Times missed while the server was down are
1629
+ is `skipped`, with why (a webhook trigger with `accept` or `max_active_runs` is the exception: [each event it
1630
+ 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
1339
1631
  one `missed` firing with their count, and the schedule goes on from now; the latest of them still fires, once, when it is
1340
- no older than the trigger's `catchup_window_s` (default an hour; 0, never), marked `catch_up`. Overlap is `skip` alone:
1341
- a firing while the last run is active (working, or parked waiting on a person) is skipped with why, never queued,
1632
+ no older than the trigger's `catchup_window_s` (default an hour; 0, never), marked `catch_up`. A
1633
+ firing while the last run is active (working, or parked waiting on a person) is skipped with why, never queued,
1342
1634
  because a firing queued behind a parked run would wait as long as the person does. A firing whose run is refused is `failed`, and a webhook set on this server
1343
1635
  gets a `trigger.failed` message for it (`data: {trigger_id, name, firing_key, nominal_at, error, auto_paused}`, its
1344
1636
  `webhook-id` made from the firing's key, so a restart never sends it twice). Five failed firings in a row turn the
1345
1637
  trigger off (`disabled: {reason: "auto_paused"}`); a firing that starts its run resets the count, and so does turning
1346
1638
  it on again. Run now (below) works on an auto-paused trigger too, and counts toward the streak like any firing: one that
1347
1639
  starts its run resets it, one that fails adds to it. A trigger whose cron line or zone no longer reads here (after an
1348
- upgrade of the cron library or of the time zone data) is turned off alone, at a start or when it comes due
1640
+ upgrade of the cron library or of the time zone data), or whose `every_s` a hand edit of its row put out of range, is
1641
+ turned off alone, at a start or when it comes due
1349
1642
  (`disabled: {reason: "source_unreadable", detail}`), and every other schedule goes on firing; turning it on again takes a
1350
1643
  new source. A trigger's firings are driven one at a time, in order, so a firing a crash left due settles to its run
1351
1644
  before the next one's overlap is checked. `PATCH /v2/triggers/{id}` changes it, and
@@ -1356,7 +1649,8 @@ firing has left the history too, and later it is a new firing that a run the key
1356
1649
  ### Webhook triggers
1357
1650
 
1358
1651
  A trigger with `source: {kind: "webhook"}` fires on each request to `POST /v2/hooks/{trigger_id}`: this server's one
1359
- route with no token. The request is signed by the trigger's own secret under the
1652
+ route with no token. Its view carries that address as `hook_url`, at the server's public URL when it has one
1653
+ (`AGENTRUN_PUBLIC_URL`), else the path; a schedule has none. The request is signed by the trigger's own secret under the
1360
1654
  [Standard Webhooks](https://www.standardwebhooks.com) spec, the one this server's outbound [webhooks](#webhooks) sign
1361
1655
  with, so a sender uses any of its libraries: `webhook-id` (1 to 255 printable ASCII characters, no space), `webhook-timestamp` (Unix seconds, within 5 minutes of this
1362
1656
  server's clock either way) and `webhook-signature: v1,<base64 HMAC-SHA256 of "{id}.{timestamp}.{body}">` under the
@@ -1365,17 +1659,99 @@ anything else. A bad signature, a stale timestamp, an unknown trigger, one that
1365
1659
  answer the same `401`, so no trigger id can be found by asking; a body past 256 KiB is `413`.
1366
1660
 
1367
1661
  The secret, `whsec_` and 32 random bytes in base64, is made with the trigger and shown in the `201` once; no `GET`
1368
- shows it. It is kept sealed under `AGENTRUN_SEAL_KEY` in `DIR/trigger-secrets.json`, so with no seal key no webhook
1369
- trigger is made (`409 no_sealing_key`). `POST /v2/triggers/{id}/secret` makes a new one, shown once, and the old one
1370
- signs nothing from then on. An import cuts these secrets out of what it keeps, and no learning text shows one. A
1371
- `trigger-secrets.json` that does not read is never written over: until it is fixed or moved away, no webhook trigger is
1372
- made or rotated (`409 store_unreadable`) and none fires.
1373
-
1374
- The request's `webhook-id` is its firing's key: the first answers `202` once the firing is recorded, and its run starts
1375
- after; the same `webhook-id` again, for a day after (even once the firing has left the history of 200), answers `200` with that
1376
- firing and starts nothing. The agent gets the trigger's input,
1377
- then the body, cut at 16 KiB, inside `<trigger-payload source="webhook" untrusted>...</trigger-payload>`: whatever the
1378
- sender wrote is data, not an instruction.
1662
+ shows it. It is kept sealed under `AGENTRUN_SEAL_KEY` in `DIR/trigger-settings-webhook.json` (each trigger source's
1663
+ sealed settings have a file of their own), so with no seal key no webhook trigger is made (`409 no_sealing_key`).
1664
+ `POST /v2/triggers/{id}/secret` makes a new one, shown once, and the old one signs nothing from then on. Like every
1665
+ secret this server keeps (its tokens, its outbound webhook's secret), it is cut from what a run shows, from what an
1666
+ import keeps and from every learning text. A secret replaced by a rotation, or whose trigger is deleted, is kept too,
1667
+ sealed in a retired row of its own (scope `retired:<trigger>:<n>`), never a setting and in no `GET`: a run that quoted it
1668
+ before is still cut on every later server. Retired rows are kept for good for now; dropping one once no run older than
1669
+ it is left is still to come. A secret that does not open under the seal key the server starts with is
1670
+ said in its log (`condition=trigger_setting_unopened`, naming the trigger), and its trigger is refused until a new
1671
+ secret is made. A `trigger-settings-webhook.json` that does not read is never written over: until it is fixed or moved
1672
+ away, no webhook trigger is made or rotated (`409 store_unreadable`) and none fires.
1673
+
1674
+ The request's `webhook-id`, which its signature covers, is its firing's key: the first answers `202` once the firing is
1675
+ recorded, and its run starts after; the same `webhook-id` again, for a day after, answers `200` with that firing and
1676
+ starts nothing (`{"ok": "duplicate"}` once the firing has left the trigger's history of 200 and the 1,000 it keeps past
1677
+ it). Each trigger keeps the keys of its last day's pushed firings in `triggers.json`, at most 5,000, the oldest let go
1678
+ first past that, which the log says once (`condition=trigger_seen_full`). The agent gets the trigger's input,
1679
+ then the body, cut at 16 KiB, inside `<trigger-payload source="webhook" scheme="standard" untrusted>...</trigger-payload>`:
1680
+ whatever the sender wrote is data, not an instruction. The tag names the signature scheme, the event as that scheme
1681
+ reads it (`event="..."`), the JSON body's top-level `action` (`action="..."`) and an unsigned delivery id
1682
+ (`delivery="..."`, GitHub's `X-GitHub-Delivery`) and, for a GitHub delivery, its pull request or issue's `number="..."`
1683
+ (`pull_request.number`, else `issue.number`) and a pull request's `head_sha="..."` (40 hex; a comment event has none, so
1684
+ no `head_sha` at all), read from the signed body so the payload's cut never loses them, each when there is one, so an
1685
+ agent's instructions can read what it was given; a sender's words there are cut to 200 characters, their quotes and brackets escaped, and a closing tag in
1686
+ the body, in any case, is defused.
1687
+
1688
+ A webhook trigger's `signature` names its scheme, one of a table of them: `standard` (the default, above) or `github`,
1689
+ for a GitHub repository or organization webhook. A request is checked by the one scheme whose signature header it
1690
+ carries (`webhook-signature`, `X-Hub-Signature-256`), and the scheme gives its firing key, from what its signature
1691
+ covers, and its event. With `github`, paste the trigger's whole `whsec_...` secret, as it is, into the GitHub webhook's
1692
+ Secret (content type `application/json`): each delivery is checked by `X-Hub-Signature-256: sha256=<hex HMAC-SHA256 of
1693
+ the raw body>`, keyed by the UTF-8 bytes of that string. GitHub signs the body alone, not `X-GitHub-Delivery` nor a
1694
+ time, so the firing's key is the SHA-256 of the raw body: a redelivery from GitHub's page sends the same body and
1695
+ answers its firing, and so does a captured delivery sent again within the key's day under any delivery id. After the
1696
+ day it would fire again (over TLS, a risk taken); there is no 5-minute window. Two real deliveries never share a body,
1697
+ since GitHub's carry their own ids and times. `X-GitHub-Delivery` (1 to 255 printable ASCII characters) only names the
1698
+ delivery on the payload's tag, for tracing. A request that carries no scheme's signature header, or more than
1699
+ one, or is signed under a scheme other than its trigger's, is the same `401` as a bad signature, and the headers are
1700
+ checked before the body is read.
1701
+
1702
+ `accept` makes a trigger take only the events it names, from the delivery alone:
1703
+
1704
+ ```json
1705
+ { "kind": "webhook", "signature": "github",
1706
+ "accept": [
1707
+ { "event": "pull_request", "actions": ["opened", "synchronize", "ready_for_review"],
1708
+ "where": [ { "pointer": "/pull_request/draft", "in": [false] } ] },
1709
+ { "event": "issue_comment", "actions": ["created"],
1710
+ "where": [ { "pointer": "/issue/pull_request", "exists": true },
1711
+ { "pointer": "/comment/author_association", "in": ["OWNER", "MEMBER", "COLLABORATOR"] },
1712
+ { "pointer": "/comment/body", "prefix": "@reviewer review" } ] } ] }
1713
+ ```
1714
+
1715
+ A rule's `event` is the event as the trigger's scheme reads it: GitHub's `X-GitHub-Event`, or a Standard Webhooks
1716
+ body's top-level `type`. GitHub signs the body, not `X-GitHub-Event`: a delivery a trigger ignored keeps its key for
1717
+ the day, so the same body sent again under another event answers `{"ok": "duplicate"}`, and where it matters a rule
1718
+ should also test a field only that event's body has (`/pull_request`, `/comment`, `/issue/pull_request`); `actions`, when given,
1719
+ lists the values the body's top-level `action` may take; each of `where`'s conditions is a JSON pointer (RFC 6901) into
1720
+ the body with one test: `in` (the value there equals one of the JSON values listed, an object's fields in any order),
1721
+ `exists` (`true`, the pointer names a value, `null` included; `false`, it names none) or `prefix` (the value is a string
1722
+ whose first line, trimmed, starts with it, ignoring case). A delivery fires when any rule takes it, with all its
1723
+ conditions holding. A verified delivery no rule takes (GitHub's `ping` among them, a body that is not JSON too) answers
1724
+ `200 {"ok": "ignored"}`, fires nothing, and is one log line (`condition=hook_ignored`, with the trigger and why). Without
1725
+ `accept`, every verified request fires, as before. A trigger holds at most 20 rules, each at most 20 conditions and 20
1726
+ actions; an `in` lists at most 20 values of at most 1024 characters of JSON each, a pointer is at most 512 characters,
1727
+ 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
1728
+ run active or not, since the events it takes are each their own work (a review per pull request); the server's run
1729
+ limit still holds: a start it refuses (`429`) keeps the firing due and tries it again, and past 20 firings due a new
1730
+ delivery answers `429`. This holds for every firing of such a trigger, a run now (`POST /v2/triggers/{id}/fire`)
1731
+ included. Runs start in the order their events came while the server has room; while one firing waits to be tried
1732
+ again after a `429`, a later one can start first.
1733
+
1734
+ Such a trigger can take every run this server has room for, starving other triggers and the runs people start. Give it
1735
+ `max_active_runs` (1 to 100; `null` clears it): past that many of its runs active, a firing waits due and is tried
1736
+ again, as at a full server, and is never skipped. It counts the runs this trigger started while they work, kept apart
1737
+ from its history (so a long run counts however many firings follow it) and read again at each check; a run a person
1738
+ opens again after it ended is that person's follow-up, not counted. Any `start_run` trigger of a pushed source (a
1739
+ webhook) takes it, with or without `accept`: set, each event starts its own run, never skipped behind the last, up to the
1740
+ cap; past it a firing waits due, and past 20 due an event answers `429 rate_limited` with `Retry-After`. Without
1741
+ `max_active_runs`, a trigger with no `accept` keeps the overlap skip: an event while its last run is active is
1742
+ `skipped`. A schedule keeps the overlap skip and takes no cap, and nor does a `message_run` target, which starts no run
1743
+ (`422` for either). On a public repository, a rule for `issue_comment` or `issues` events needs a condition on
1744
+ `/comment/author_association` or `/issue/author_association` (`in: ["OWNER", "MEMBER", "COLLABORATOR"]`): without one,
1745
+ anyone who can comment starts runs.
1746
+
1747
+ A trigger's input, a started run's first message or a firing's message, is the trigger's, never the person's: it carries
1748
+ the origin `{kind: "trigger", trigger_id, source, owner}`, `owner` decided by the trigger's definition as it fires and
1749
+ never by its payload (true for a schedule, fired on time or by hand; false for a webhook, its body empty or not). The
1750
+ model reads the very text it did; the run's timeline shows it as a `phase` row that names its source and its trigger as
1751
+ it is now, "Schedule utc-check: <its first line>" (the trigger's id once it is gone), with `origin: "trigger"` and
1752
+ `trigger: {id, source, owner}` (so a client labels it by its source without reading the summary), never as "You: ...",
1753
+ and what the run learns reads it as the trigger's. A trigger renamed renames the row; the name it had when it fired is
1754
+ not kept yet.
1379
1755
 
1380
1756
  A trigger's target may also be `{kind: "message_run", run_id, input: {content}}`, with a webhook or a schedule source:
1381
1757
  each firing sends its input to that run as `POST /v2/runs/{id}/messages` would (a steer, or a follow-up that opens a
@@ -1387,6 +1763,113 @@ never opens a completed run again for one it already has. A firing to a run that
1387
1763
  5 s), and a trigger holds at most 20 firings due: past them a webhook event and a run now answer `429 rate_limited`
1388
1764
  with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
1389
1765
 
1766
+ ### GitHub triggers (Connect GitHub)
1767
+
1768
+ A server has at most one GitHub App, made with GitHub's app-manifest flow, and every `github` trigger (and every
1769
+ GitHub template) uses it. In the console, Connect GitHub calls `POST /v2/integrations/github/connect` (`{org?}`, to make
1770
+ the App under an organization) and posts the form it answers to GitHub: `action`, GitHub's new-App page, and
1771
+ `manifest`, which names a name GitHub lets the person edit, the server's public URL, its hook `/v2/hooks/github`, its
1772
+ callback and setup URLs, the permissions (pull requests write; contents, metadata and issues read) and the events
1773
+ (`pull_request`, `issue_comment`). It needs the address GitHub can reach, `AGENTRUN_PUBLIC_URL` (`409 github_no_public_url`,
1774
+ "GitHub can't reach this server: set its public URL first"), a seal key (`409 github_no_seal_key`, naming
1775
+ `AGENTRUN_SEAL_KEY`), and no App connected already (`409 github_already_connected`, "This server already has a GitHub
1776
+ App. Disconnect it first."), and a request at the public URL itself, where GitHub sends the browser back
1777
+ (`409 github_wrong_origin`, "Open this server at <public URL> to connect GitHub.", the URL in `details.public_url`). Its
1778
+ `state` is random, used once, good for an hour, and bound to the browser that started it
1779
+ by a cookie on the callback's path; GitHub reads it from `action`'s URL, and the form posts only `manifest`.
1780
+
1781
+ GitHub sends the browser back to `GET /v2/integrations/github/callback` with a code. The server converts it with GitHub
1782
+ and keeps the App's id, slug and client id, which are no secret, and its private key and webhook secret, which are,
1783
+ sealed in `DIR/trigger-settings-github.json`; GitHub's client secret is never kept, and no secret is logged or answered.
1784
+ The browser goes on to install the App, with a fresh install state GitHub passes on and its cookie on the installed
1785
+ path; GitHub's redirect after (`/v2/integrations/github/installed`) records the installation only with that state and
1786
+ cookie, once GitHub, asked with the App's own JWT, says it is the App's, and sends the browser to the console at the
1787
+ public URL, `<public>/#/settings/github?github=connected`. Without the state and cookie it records nothing and lands
1788
+ there too: an installation made from GitHub's own pages arrives as the App's signed installation event. Neither leg ever answers an error body: a state
1789
+ that is unknown, used, older than an hour or from another browser sends the browser to
1790
+ `<public>/#/settings/github?github=error&reason=state_invalid`,
1791
+ a code GitHub does not convert to `...&reason=conversion_failed`, one whose App GitHub made while another Connect kept
1792
+ its App to `...&reason=already_connected` (the first App stays), and an installation GitHub does not confirm, or one
1793
+ checked while GitHub was disconnected or connected again, to `...&reason=installation_unverified`; nothing is kept. The
1794
+ App's `installation` events keep the list current, each taken only in its own shape (the installation, its account and
1795
+ this App's id) and as GitHub, asked with the App's JWT, bears it out: `X-GitHub-Event` is not signed, so another
1796
+ event's signed body sent as one changes nothing. GitHub out of reach when an event is checked answers it `503`, so
1797
+ GitHub shows the delivery failed and it can be sent again; and the list is repaired from GitHub's own installations at
1798
+ the server's start and when `GET /v2/integrations/github` is read (at most once a minute), by the same rule: none left
1799
+ turns the github triggers off, one dropped only shrinks it. A list that an event or the install redirect wrote while
1800
+ GitHub was asked is not overwritten by GitHub's older answer: the repair asks once more, and leaves the list as it is
1801
+ when it moved again. A deletion or suspension that would leave none is confirmed with GitHub's own list first: only none there turns the
1802
+ github triggers off, and its list as it comes (the one removed included, when GitHub holds it active again) becomes the
1803
+ list. An installation event follows the same rule: GitHub's answer to its check is taken only when no write came meanwhile
1804
+ (else it is asked once more), so an older suspend never undoes a newer unsuspend. A server that closes stops its repair
1805
+ and its events' checks, which write nothing after (an event cut so answers `503`, to be sent again).
1806
+ `GET /v2/integrations/github` always answers 200: `{connected: false}` with no App, else `{connected: true, app_id, slug,
1807
+ installations}`, never a secret. Not connected is an answer, not a 404 a browser logs as an error. `DELETE` with nothing
1808
+ connected is still 404.
1809
+
1810
+ A trigger with `source: {kind: "github", accept: [...]}` takes the App's events its `accept` names (the same rules as a
1811
+ webhook trigger's, above; required) and keeps no secret of its own. `POST /v2/hooks/github` takes no token: each delivery
1812
+ is checked by `X-Hub-Signature-256` under the App's webhook secret, and one event fires **every** github trigger whose
1813
+ `accept` takes it, each its own firing, keyed by the SHA-256 of the signed body, and its own run (github triggers may
1814
+ take the same events; `max_active_runs` caps each). Every other github trigger keeps the body's key for its day, so the
1815
+ same body sent again under another `X-GitHub-Event`, which GitHub does not sign, starts nothing: where it matters, a rule
1816
+ also tests a field only that event's body has. When a trigger that takes an event holds too many firings due, the delivery is refused `429` with `Retry-After`
1817
+ though the others recorded theirs: the retry records it there once it has room, and is the others' duplicate. An event no
1818
+ trigger takes is `200 {"ok": "ignored"}`; GitHub's `ping` is
1819
+ `200 {"ok": "pong"}`. The payload's tag also names the installation and the repository (`installation="..."
1820
+ repo="owner/name"`). A github trigger made or turned on with no App connected is `409 github_not_connected` ("Connect GitHub
1821
+ in Settings"). A `{kind: "webhook", signature: "github"}` trigger is unchanged: a repository webhook with its own secret.
1822
+
1823
+ An installation deleted or suspended on GitHub leaves the list, and one unsuspended comes back; the github triggers turn
1824
+ off only when no installation is left (`disabled: {reason: "connection_lost", detail}`, naming it), and coming back
1825
+ turns none on. `DELETE /v2/integrations/github` disconnects the App and turns every github trigger off the same way,
1826
+ answering `{disconnected: true, triggers_off, note}`, the note "Delete the App itself on GitHub: <its settings URL>":
1827
+ the App's credentials leave this server only, and it stays on GitHub until deleted there. Turned off, a trigger is kept:
1828
+ an agent keeps its triggers, and each goes on again once turned on with GitHub connected.
1829
+
1830
+ An MCP server saved with `auth: {type: "github_app", headers?}` (`PUT /v2/settings/mcp-servers/{name}`) uses the
1831
+ connected App's tokens and keeps none of its own: only its static headers (such as `X-MCP-Tools`), sealed as written,
1832
+ and never an `Authorization`. Its tools are listed with a token narrowed to one repository, of the first of the App's
1833
+ installations (in order) that covers one; an installation whose account has none selected is passed over. GitHub that
1834
+ does not answer while that token is minted (a 429, a 5xx, a rate limit's 403, no answer) is `502 github_failed`, "GitHub didn't answer: try
1835
+ again", retryable, and the preview, save or refresh changes nothing. At each launch of a run that
1836
+ grants its tools (its start, every resume, a relaunch after a crash) the server mints an installation token for that
1837
+ run, narrowed to the one repository the run is about, with the App's permissions: a GitHub event's run uses its
1838
+ installation and repository (the server's own payload tag); any other names it in its input as
1839
+ `https://github.com/<owner>/<repo>`, whose installation the server asks GitHub for with the App's JWT. The token goes to
1840
+ the run's MCP calls with the static headers beside it, lives only in memory (handed to the run's process over its pipe,
1841
+ never its environment, journal, a log line or an answer), and is cut from whatever a run shows while it may be in use.
1842
+ A run whose repository the App does not cover, or that names none, has those calls answered in words ("The GitHub App
1843
+ isn't installed on owner/repo"). A token lasts an hour, and the runner mints a new one for the run 5 minutes before it
1844
+ expires, so a long run's calls never carry an expired token. When that mint fails, the token held keeps working until
1845
+ it expires; then the run's calls of that server are answered, unsent, that its GitHub App token expired and a new one
1846
+ could not be made, with GitHub's reason, and the next launch (a resume) mints a fresh one.
1847
+
1848
+ ## Templates
1849
+
1850
+ A template package makes a working agent in one call: its definition, its skills and rules, and its triggers, from a
1851
+ folder the server ships. `GET /v2/templates` lists them; `POST /v2/templates/{name}/apply` with `{parameters,
1852
+ overrides?: {model}}` makes one, or nothing when a check fails (a trigger refused archives the agent it made). A
1853
+ package's `version` is SemVer and never `definition.version`, the agent's revision number. The first package is `code-review`, a code review agent for one GitHub repository. The format and the
1854
+ rules of an apply are in [templates/README.md](https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/templates/README.md);
1855
+ `agentrun template validate DIR` checks a folder as the server does.
1856
+
1857
+ `agentrun template eval DIR` (`agentrun-serve eval-template DIR`) runs a package's eval cases as real runs of its agent
1858
+ and grades each run with the case's graders: by default on a server of its own over a temp data directory, so it never
1859
+ touches yours, with each case's fake MCP servers on loopback and its learned notes seeded through the learning API. Real
1860
+ models cost money: each run is capped at its case's `max_cost_usd`. It exits 0 when every case passed, 1 when one
1861
+ failed, 2 when nothing ran. The runner, the graders and the report are in
1862
+ [templates/README.md](https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/templates/README.md#running-the-evals).
1863
+
1864
+ | `eval-template` flag | What |
1865
+ | --- | --- |
1866
+ | `--case NAME` | A case to run; repeat it. Without one, every case. |
1867
+ | `--runs N` | Runs of each case, in place of each case's `runs`. |
1868
+ | `--server URL` | Run on that server, its token in `AGENTRUN_API_KEY` (the launcher hands it over its pipe; never printed). The agents the eval makes are archived at the end. |
1869
+ | `--grader-model PROVIDER/MODEL` | The `llm` graders' model; default the server's. |
1870
+ | `--report FILE` | The whole report as JSON (per case, run and grader: pass, reason, cost); a summary goes to stdout, progress to stderr. |
1871
+ | `--faux MODULE` | Answer every model request from the module, as the server's `--faux` does. Not with `--server`. |
1872
+
1390
1873
  ## What it serves
1391
1874
 
1392
1875
  | Route | Here |
@@ -1394,15 +1877,15 @@ with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
1394
1877
  | `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
1395
1878
  | `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. |
1396
1879
  | `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. |
1397
- | `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` (agentic only), the agent's default cap, kept by an edit that leaves it out and cleared only by 0 ([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)). |
1880
+ | `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)). |
1398
1881
  | `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. |
1399
1882
  | `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
1400
1883
  | `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
1401
1884
  | `POST /agents/{id}/archive`, `POST /agents/{id}/unarchive` | [Archiving](#archiving): hides the agent and its runs from the lists, or shows them again. Answers the agent, with `archived_at`. |
1402
- | `DELETE /agents/{id}/sign-ins/{key}` | This server's own route (`x-agentrun-serve: "signins/1"`): forgets one of the agent's [saved sign-ins](#saved-sign-ins), at its vendor and here. `409 sign_in_held` while a run holds its save lease. |
1885
+ | `DELETE /agents/{id}/sign-ins/{key}` | This server's own route (`x-agentrun-serve: "signins/1"`): forgets one of the agent's [saved sign-ins](#saved-sign-ins), at its vendor and here. `409 sign_in_held` while a run holds its save lease, or while a run it was handed is still going. |
1403
1886
  | `POST /agents/{id}/runs`, `GET /agents/{id}/runs` | A run of the current revision, or of `revision`. An agentic run's input is `{content: string}`; a workflow run's is what its workflow's input schema takes. `file_ids` names [uploaded](#uploads) files, copied into the run's `work/inputs/` before it starts and named in its first message. The agent's runs, newest first. |
1404
1887
  | `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`. |
1405
- | `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what it waits on, by `kind`, such as `{kind: "question", question, asked_at}` for a question it asked a person; else null) and cost (`basis: estimate`; $0 before its first model request, a cancelled run's included). |
1888
+ | `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). |
1406
1889
  | `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. |
1407
1890
  | `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`). |
1408
1891
  | `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. |
@@ -1411,14 +1894,18 @@ with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
1411
1894
  | `POST /files`, `PUT /files/{id}`, `GET /files`, `GET` and `DELETE /files/{id}` | [Uploads](#uploads): a file sent in one call (`POST /v2/files?path=...`, its bytes the body), or reserved and then sent (`PUT /v2/files/{id}`); the server's uploads listed, read and deleted. |
1412
1895
  | `GET /agents/{id}/home/files`, and `GET`, `PUT`, `DELETE` on a file's path below it | The files in the agent's home, listed, read, written and deleted ([agent home](#agent-home)). This server's own routes (`x-agentrun-serve: "home/1"`). |
1413
1896
  | `GET /stats` | This server's own route, outside the contract (`x-agentrun-serve: "stats/1"`): the agents, the runs (`total`, `active`, `needs_input`, `failed`, `needs_review`, `status_unknown`), each agent's run count, the cost and what is archived, read from the agent store's aggregates alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` `estimate`, or null beside a null `usd`; `unknown_runs` counts the rest. `analytics` (`stats/2`) sums the runs' metrics over the runs not archived that `from` and `to` (RFC 3339 date-times to the millisecond, an impossible one or a finer fraction refused; runs started in [`from`, `to`)) and `agent` pick, each optional, 400 when malformed: `filter` echoes them; `totals` (runs, completed, an escalated run included, `needs_review` (`stats/3`), failed, never an escalated run, `runs_with_metrics`, tokens and each token kind, requests, unmetered, `cost_usd` and `unknown_cost_runs`), `time` (`wall_ms` over the ended runs, `active_ms` where metrics have it), `by_harness_effort`, `by_day` (UTC), `by_source` (`live` or the import source) and the top 20 `tools`. A run with no metrics counts in `runs` and in no token sum. `learning` (`learning/1`) counts the runs that tried to learn over the same filters, from the learning ledger and the runs this server holds ([Learning](#learning)). The query bounds `analytics` and `learning` alone. |
1414
- | `GET /runs/{id}/graph` | A workflow run drawn, live: its workflow, the DSL's `workflowGraph`, each node's state (a map's items with their labels and the branch each route took for them, a route's branch), every decision with its receipt (answers, evidence, the state the judge saw, image links), every call with its input and output, and the totals (cost, null when any part is unknown). While the run goes it reads the run process's `live.json`, rewritten every 300 ms, never the run's store, which the process holds; a poll never answers `home_busy` (`stale: true` marks a last whole view). An agentic run has none (`404`). |
1897
+ | `GET /runs/{id}/graph` | A workflow run drawn, live: its workflow, the DSL's `workflowGraph`, each node's state (a map's items with their labels and the branch each route took for them, a route's branch), every decision with its receipt (answers, evidence, the state the judge saw, image links), every call with its input and output, and the totals (cost, null when any part is unknown). While the run goes it reads the run process's `live.json`, rewritten every 300 ms, never the run's store, which the process holds; once it ended, its store is read lock-free, so a poll never waits on it and never answers `home_busy`. An agentic run has none (`404`). |
1415
1898
  | `POST /runs/{id}/pause`, `POST /runs/{id}/resume` | A workflow run: what is in flight finishes, and no node, model call or decision starts until it is resumed. Its status reads `paused`, and stays so across a server restart. An agentic run is `501`, an ended one `409`. |
1416
1899
  | `POST /workflows/validate` | `{workflow, tools?}`: every issue a save would refuse (`[{path, code, message}]`, the DSL's validation with code not run) and what this host lacks as `warnings`. Writes nothing. A refused save's `422` carries each issue as a field under `definition.workflow`, with its `code`. |
1417
1900
  | `GET /settings/tool-keys`, `PUT` and `DELETE /settings/tool-keys/{id}` | [Tool keys](#tool-keys), this server's own routes (`x-agentrun-serve: "toolkeys/1"`): each key's fields by name and where each is set, never a value; save one sealed, or forget it. |
1418
- | `GET /settings/mcp-servers`, `POST /settings/mcp-servers/preview`, `GET`, `PUT` and `DELETE /settings/mcp-servers/{name}`, `POST .../{name}/refresh` | [MCP servers](#mcp-servers), this server's own routes (`x-agentrun-serve: "mcpservers/1"`): preview a remote MCP server's tools, save it with its credential sealed, read it back without the credential, refresh its tools, or forget it. |
1901
+ | `GET /settings/mcp-servers`, `POST /settings/mcp-servers/preview`, `GET`, `PUT` and `DELETE /settings/mcp-servers/{name}`, `POST .../{name}/refresh`, `POST .../{name}/oauth/start`, `GET /settings/mcp-servers/oauth/callback` and `GET .../oauth/client.json` | [MCP servers](#mcp-servers), this server's own routes (`x-agentrun-serve: "mcpservers/1"`): preview a remote MCP server's tools, save it with its credential sealed, read it back without the credential, refresh its tools, forget it, or [sign in to it with OAuth](#signing-in-with-oauth) (the callback and the client document take no token). |
1419
1902
  | `GET /settings/tools`, `PUT /settings/tools` | This server's own: the providers of `web_search`, `web_fetch` and `browser` ([search and fetch](#search-and-fetch)). |
1903
+ | `GET /runs/{id}/browser` | This server's own (`x-agentrun-serve: "liveview/1"`): the run's live browser view for the owner, `{state: "off", reason}`, `{state: "none"}` or `{state: "live", viewer}` ([the live view](#the-browsers-live-view)). |
1904
+ | `POST /runs/{id}/browser/hand-back` | This server's own (`liveview/2`): the owner's answer to the agent's ask for them in its browser, `{outcome: "done" \| "cancelled"}`; the first answer wins, a different one is `409 handoff_answered` ([the live view](#the-browsers-live-view)). |
1905
+ | `GET /runs/{id}/computer` | This server's own (`computer/1`): the run's live computer view for the owner, one family for every kind, `{state: "off", hold, why?}`, `{state: "none", kind, hold}` or `{state: "live", kind, viewer, hold}`, its viewer under `/runs/{id}/computer/live/`; the browser is kind `browser` here, beside its own route ([the live view](#the-browsers-live-view)). |
1420
1906
  | `GET`, `PUT` and `DELETE /settings/webhook`, `POST /settings/webhook/test`, `GET /settings/webhook/deliveries` and `POST .../deliveries/{webhook_id}/redeliver` | [Webhooks](#webhooks), this server's own routes (`x-agentrun-serve: "webhook/1"`): the URL run notices are POSTed to, signed by the Standard Webhooks spec; never its secret but once. |
1421
1907
  | `GET` and `POST /triggers`, `GET`, `PATCH` and `DELETE /triggers/{id}`, `POST /triggers/{id}/fire`, `GET /triggers/{id}/firings`, `POST /triggers/{id}/secret`, `POST /hooks/{id}` (no token: [signed](#webhook-triggers)) | [Schedules](#schedules), this server's own routes (`x-agentrun-serve: "trigger/1"`): schedules that start an agent's capped runs, each firing once, and their history. |
1908
+ | `GET /templates`, `POST /templates/{name}/apply` | [Templates](#templates), this server's own routes (`x-agentrun-serve: "templates/1"`): the template packages it ships, and an apply that makes one's agent and triggers, all or nothing. |
1422
1909
  | `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`. |
1423
1910
  | `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. |
1424
1911
 
@@ -1545,7 +2032,28 @@ model). A definition naming a
1545
2032
  harness this server does not run yet saves with a warning on `definition.harness`, and a run of it is
1546
2033
  `409 agent_not_runnable` with `details.harness`; it never runs on pi instead. This server runs pi always, and
1547
2034
  `claude-agent`, `codex` and `opencode` when each adapter's package, pins and provider endpoint check out; the harness's
1548
- `reason` says what is missing. `opencode` needs `opencode-ai@1.19.5` installed beside the server (an exact optional peer of
2035
+ `reason` says what is missing. `claude-agent` and `codex` install themselves on first use: AgentRun never ships the
2036
+ Claude Agent SDK or the Codex CLI, and the first run on each (or the first agent saved on it) installs the version AgentRun
2037
+ pins (`@anthropic-ai/claude-agent-sdk@0.3.286`, `@openai/codex@0.164.0`) from npm into `<data>/harnesses/claude-agent`
2038
+ or `<data>/harnesses/codex`, with the npm that runs the server, once. Each install is pinned by the lock the server
2039
+ ships, `harnesses/claude-agent/` or `harnesses/codex/` (a package.json that names the package at the pin, and npm's lock
2040
+ for it: every package of the tree, the platform packages that hold the Claude CLI or the Codex binary and the peers'
2041
+ dependencies included, by sha512), which `npm ci --ignore-scripts --include=optional` holds every tarball to, from
2042
+ whichever registry the person's npm config names; a config that omits optional packages still gets this platform's CLI.
2043
+ It lands whole or not at all: npm writes into a fresh directory beside the install's own, the result is checked there
2044
+ (the package at the pin, its entry, this platform's CLI or binary, and for Claude the MCP library), then it is renamed
2045
+ into place and made read-only. `node scripts/harness-locks.mjs` makes the locks again when a pin moves (`--check`
2046
+ checks them). Every run that needs one waits for that one install, its ready time counted from the install's end, and
2047
+ shows a `phase` row, `Installing Claude Code (first use)…` or `Installing Codex (first use)…`, while it does. Each run
2048
+ then loads the harness from its own packages inside its install and nowhere else, never from a `node_modules` above it;
2049
+ a tree that is not whole is installed again. Claude Code as an earlier build installed it, at the top of `<data>/harnesses`
2050
+ itself, is removed before the first install (the server logs `harness_install_removed`), and it installs again; a
2051
+ `harnesses` directory that holds anything else is left as it is. Until it is installed, capabilities list the harness with `installs:
2052
+ "on_first_use"`. When npm fails, the run fails and its error names the command that installs it by hand, the same locked
2053
+ install: the shipped `package.json` and `package-lock.json` copied into a fresh `<data>/harnesses/<harness>.new`, `npm ci
2054
+ --ignore-scripts --include=optional` there, then that directory put in place of `<data>/harnesses/<harness>` (made
2055
+ writable first: the server leaves its install read-only). A server that stops
2056
+ mid-install stops its npm (SIGTERM). `opencode` needs `opencode-ai@1.19.5` installed beside the server (an exact optional peer of
1549
2057
  it), and its model goes where codex's does: the gateway at `AGENT_MODEL_BASE_URL`, or
1550
2058
  OpenAI with `OPENAI_API_KEY`, on the Responses API. The packages and pins are checked once, at the start
1551
2059
  (`event=harness_offers why=start`): a harness
@@ -1556,7 +2064,12 @@ no such clause: running that line is the restart. A reason a setting fixes (a mo
1556
2064
 
1557
2065
  `claude-agent` sends its requests to `ANTHROPIC_BASE_URL` (else Anthropic) with `ANTHROPIC_API_KEY` and Anthropic's own
1558
2066
  model id, and prices the run by it: a revision's `anthropic/<model-id>`, its dots as dashes, so OpenRouter's dotted name
1559
- (`anthropic/claude-sonnet-5.5`) and Anthropic's own (`claude-sonnet-5-5`) are one model. `codex` and `opencode` send their requests
2067
+ (`anthropic/claude-sonnet-5.5`) and Anthropic's own (`claude-sonnet-5-5`) are one model. `pi` sends its Anthropic models'
2068
+ requests there too, compaction, a hosted search, a learned node and a grade included: to `ANTHROPIC_BASE_URL` with
2069
+ `ANTHROPIC_API_KEY` as `x-api-key` alone (never `ANTHROPIC_AUTH_TOKEN` or an OAuth token), and capabilities read its
2070
+ Anthropic default ready only where that route runs (`models.needs: "key"` without `ANTHROPIC_API_KEY`, or with an
2071
+ `ANTHROPIC_BASE_URL` a key may not go to, whose run is refused in its words). Such a base refuses Anthropic's route
2072
+ alone: a model of any other provider runs as it does without it. `codex` and `opencode` send their requests
1560
2073
  to serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
1561
2074
  `OPENROUTER_API_KEY` is set, runs through OpenRouter (`https://openrouter.ai/api`, the key as a bearer token):
1562
2075
  claude-agent on its Messages endpoint, with Anthropic's own id on the wire (OpenRouter takes it: its Claude Code guide
@@ -1594,17 +2107,23 @@ typed answers and their probabilities.
1594
2107
  for Jev through OpenRouter, and so does a model gateway on OpenRouter: with `AGENT_MODEL_BASE_URL` on the host
1595
2108
  `openrouter.ai` and neither key set, Jev runs on `AGENT_MODEL_API_KEY`.
1596
2109
  - Parallel Decisions, through `@parcha/agentrun-decisions`, answers a node that says `provider: "parallel"`, with web
1597
- citations as its evidence. Set `PARALLEL_API_KEY`. Each request is booked at Parallel's list price as an estimate,
1598
- and one whose outcome was lost after sending is never sent again: the run escalates it as interrupted.
2110
+ citations as its evidence. It runs on one of two routes. With `PARALLEL_API_KEY` set, on Parallel's own API: each
2111
+ request is booked at Parallel's list price as an estimate. Without it, on Parallel's model through OpenRouter,
2112
+ `parallel/decisions-fast`, on the OpenRouter key (below): only an OpenRouter key is needed. Its citations (OpenRouter's
2113
+ `url_citation` annotations) are the same evidence, and its cost is the one OpenRouter reports. A request whose outcome
2114
+ was lost after sending is never sent again on either route: the run escalates it as interrupted. Capabilities say which
2115
+ route it runs on (`route: "parallel"` or `"openrouter"`).
1599
2116
  - OpenRouter's Decisions models answer a node that says `provider: "openrouter"` and names its model in `model`
1600
2117
  (`liquid/d1`, `perplexity/pplx-decider-v1.2`, `cloudflare/clef`, `typesafe/jev-1.14`). They run on the OpenRouter key
1601
2118
  Jev's OpenRouter route reads (`OPENROUTER_API_KEY`, else `AGENT_MODEL_API_KEY` with `AGENT_MODEL_BASE_URL` on
1602
2119
  openrouter.ai), handed to the run's process on the decision descriptor as Jev's is. That key is also the model
1603
- gateway's, which a run's process holds. Images to them are experimental.
2120
+ gateway's, which a run's process holds. Images to them are experimental. A model that cites the web returns
2121
+ `url_citation` annotations, which become the node's evidence. A cost OpenRouter reports above 0 is booked; 0 (a model its
2122
+ catalog prices at 0) or none is unknown, never $0.
1604
2123
  - A decision node's `images` are files of the run's `work/`, such as the pages `pdf_pages` draws: the run's process
1605
2124
  reads them and sends them with the request. The receipt keeps each image's SHA-256, never its bytes.
1606
2125
  - `GET /capabilities` lists the providers in `workflows.decisions.providers` (`[{id: "jev" | "parallel" | "openrouter", available,
1607
- reason?, note?}]`), and `runJudge` is among `workflows.adapters` once any of them runs here. On the OpenRouter route,
2126
+ reason?, note?, route?}]`, `route` on parallel), and `runJudge` is among `workflows.adapters` once any of them runs here. On the OpenRouter route,
1608
2127
  jev's `note` names the variable Jev runs on (`OPENROUTER_API_KEY` or `AGENT_MODEL_API_KEY`) and says that it is the
1609
2128
  model gateway's key.
1610
2129
  - With no key for a provider a workflow's nodes name, the workflow saves with a `not_set_up_here` warning on
@@ -1638,6 +2157,12 @@ An agent or a run is archived, never deleted: `DELETE` stays `405`. These routes
1638
2157
  - `POST /v2/agents/{id}/archive` hides the agent and its runs from `GET /agents`, `GET /runs` and
1639
2158
  `GET /agents/{id}/runs`; `POST /v2/runs/{id}/archive` hides one run. `.../unarchive` shows them again. Each is
1640
2159
  idempotent (archiving again keeps the first time), takes no body, and answers what it changed.
2160
+ - Archiving an agent turns off every trigger that runs as it (a `start_run` of it, a `message_run` to one of its
2161
+ runs) with the archive, in one write: `disabled: {reason: "agent_archived", detail}`, and the answer lists them in
2162
+ `triggers_off: [{id, name}]`. From then no firing starts a run of it: one that comes due anyway (waiting on its
2163
+ `max_active_runs`, or on a retry) is `skipped`, "The agent <name> is archived.". While it is archived, a trigger made
2164
+ on, turned on or aimed at it is `409 agent_archived`. Unarchiving turns none on: its answer lists those still off, and
2165
+ `PATCH /v2/triggers/{id}` `{enabled: true}` turns each on.
1641
2166
  - Each list takes `archived=true` to list only archived ones (`false`, the default, lists the others).
1642
2167
  - Every read by id still answers, with `archived_at` (null when it is not archived; a run's is its own, else its
1643
2168
  agent's): `GET /agents/{id}`, `GET /runs/{id}`, its timeline and its files. `/usage` still counts archived runs: the
@@ -1664,6 +2189,10 @@ server's own origin, under a CSP that allows that origin only:
1664
2189
  keeps the filters. A run's page follows `GET /v2/runs/{id}/timeline` with a long poll, sends messages (an answer while
1665
2190
  it waits on `ask_person`), stops or cancels the run, shows its files and a workflow's graph, and has **Archive** or
1666
2191
  **Unarchive**.
2192
+ - **Settings → MCP servers**: add a remote MCP server (its name, address and credential: none, a bearer token, headers,
2193
+ or **Sign in** with OAuth), **Preview** its tools and protocol, then **Save**; each saved one with its tool count and
2194
+ its credential's state, **Refresh**, **Change** (a credential left empty keeps the saved one) and **Delete**. An
2195
+ agent's Tools step lists each saved server's tools; a box ticked grants `mcp:<server>/<tool>`.
1667
2196
 
1668
2197
  Its files (`index.html`, and Vite's hashed files under `/assets/`) are public and hold no data: everything it shows
1669
2198
  comes through `/v2`. The store's read-only JSON stays under `/api/*` (`/api/store`, `/api/agents/{id}`, `/api/runs` and
@@ -1686,12 +2215,27 @@ send the browser to `/`, which keeps a link's `#code`.
1686
2215
  ## Your password
1687
2216
 
1688
2217
  AgentRun Server is for one person, who signs in to the console with a password (`AGENTRUN_ACCOUNTS=0` turns this off). With
1689
- no `AGENTRUN_PUBLIC_URL`, the start prints `Set your password: <url>/setup`, and the first visit sets it, 12 characters or
1690
- more. With it, the start prints `Set up this server: <url>/setup#code=<code>`, and setup takes that code (or the token as
1691
- the Bearer). The server keeps a scrypt hash of the password, never the password, in `DIR/owner.json`, and signs its
1692
- session cookies with the key in `DIR/.session-secret`; both are 0600, and no run reaches either. A session lasts 30 days;
1693
- **Sign out everywhere** ends every session on every browser. Sign-in tries are limited per address, ten in 15 minutes, and the limit keeps up to 10,000 addresses: past that a
1694
- new address gets a 429 until older ones expire, and an address already limited stays limited. Forgot it: run
2218
+ no `AGENTRUN_PUBLIC_URL`, listening on loopback (the default), the start prints `Set your password: <url>/setup`, and the
2219
+ first visit sets it, 12 characters or more. With a public address, or listening on any other address (`0.0.0.0` in the
2220
+ image, a LAN address), the start prints `Set up this server: <url>/setup#code=<code>`, and setup takes that code (or the
2221
+ token, in the code field or as the Bearer): anyone who reaches the port could otherwise set the password first. The server keeps a scrypt hash of the password, never the password, in `DIR/owner.json`, and signs its
2222
+ session cookies with the key in `DIR/.session-secret`; both are 0600, and no run reaches either. A session lasts 30 days.
2223
+ **Sign out** (`POST /v2/auth/sign-out`) signs out this browser: its session is revoked on the server (a copy of its
2224
+ cookie stops working too) and its cookie cleared, and every other browser stays signed in. **Sign out everywhere** (`POST /v2/auth/sign-out-everywhere`) ends every session on every browser and phone,
2225
+ this one too.
2226
+
2227
+ Sign-in tries are limited, and never for good. Each address (an IPv6 one by its /64) has ten tries in 15 minutes; past
2228
+ them each next try waits a second after the last, twice that the time after, never more than a minute. The whole server
2229
+ takes 100 wrong passwords in 15 minutes; past them every try, from any address, waits the same way after the last wrong
2230
+ one. A refused try is a 429 that says how long (`retry-after`, `retry_after_ms`). The limit counts up to 10,000 addresses
2231
+ at once; a new one past that is held by the server's budget only, and no address counted is ever dropped to make room.
2232
+ Behind a proxy every visitor would be the proxy's address, so one guesser would hold the owner too: set
2233
+ `AGENTRUN_TRUSTED_PROXIES` to the proxy's addresses or ranges (comma-separated, or `loopback`, `linklocal`,
2234
+ `uniquelocal`), and a request from one of them counts under the client its `X-Forwarded-For` names (the nearest address
2235
+ that is not itself a trusted proxy). Unset, that header is never read. `render.yaml` sets it to `uniquelocal`, the private
2236
+ ranges Render's proxy reaches a service from.
2237
+
2238
+ Forgot it: run
1695
2239
  `agentrun-serve reset-password --data DIR` where the data directory is (`docker exec agentrun node
1696
2240
  /opt/agentrun/packages/serve/dist/cli.js reset-password --data /data` in the image). It clears the password and signs every
1697
2241
  browser out, and the next visit sets a new one. The token works for scripts and the CLI either way.
@@ -1727,14 +2271,15 @@ left out: 2 sessions still being written: they come in next time
1727
2271
  ## A run's life
1728
2272
 
1729
2273
  1. `POST /agents/{id}/runs` starts the run in the store (`startRun`, which pins the revision and seeds
1730
- `DIR/runs/<id>/`), then its process: `pi-durable-disk run --dir DIR/runs/<id> --app <this package's app> --serve 0` on
2274
+ `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
1731
2275
  loopback, behind a token of its own (`DIR/.door-token`), with its stderr in `runs/<id>/process.log`. The run's input
1732
2276
  is in `runs/<id>/serve.json`.
1733
2277
  2. The app reads the run's revision from the store.
1734
2278
  - An agentic revision runs as the root agent: its instructions and skills, its model, and the tools it names of the
1735
2279
  workspace's `read`, `write` and `edit`, and `ask_person`, which ends the turn; the timeline then shows a `waiting`
1736
- row, and the run is `input_required` and `waiting` until a message answers it. `bash` is bound only in a
1737
- [sandbox](#sandbox), where it and the file tools run in the run's box. The run is `queued` until its first message shows; while the process runs, the
2280
+ row, and the run is `input_required` and `waiting` until a message answers it. `bash` is bound only where the run
2281
+ has a shell ([computers](#computers)): in a computer that mounts the run's folder, or on Archil's serverless exec
2282
+ 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
1738
2283
  timeline comes from its door's events through `@parcha/pi-durable-agent/timeline`. Once the run is idle and its
1739
2284
  newest row is the agent's answer, the server sends the process SIGTERM. A model error ends it `failed`
1740
2285
  (`run_failed`). A run whose `max_cost_usd` cannot buy its next request is paused, `input_required` and `waiting`
@@ -1762,10 +2307,14 @@ left out: 2 sessions still being written: they come in next time
1762
2307
  workflow run's model nodes), and the server carries the run back, every run of both kinds: `carryBack` records its
1763
2308
  state, cost and a summary in the store (an agentic run's answer; a workflow run's `workflowCarry`, its completed
1764
2309
  nodes, then where it failed or escalated). Its last
1765
- page says `final`. v2's `cancelled` is the store's `stopped`; a workflow that escalated ends `failed` with
1766
- `error: {code: "escalated", message: <its summary>}`, in the run and in the lists.
2310
+ page says `final`. v2's `cancelled` is the store's `stopped`; a workflow that escalated ends `completed`, its work
2311
+ done and waiting for a person's review: `error` is null and `review` is `{kind, node, reason, at}`, in the run and in the
2312
+ lists. In this release `kind` and `node` are always null: the store keeps only the escalation's summary (`reason`)
2313
+ and the run's end (`at`). Every other run's
2314
+ `review` is null. `GET /v2/stats` counts it in `needs_review`, never in `failed`.
1767
2315
  4. When the server starts, it reads every run the store says is running. A run process an earlier server started and
1768
- that still serves the run is supervised again, by its `run.json` and its pid; a run that already ended is carried
2316
+ that still serves the run is supervised again, by the holder its row names (its pid, its start, its door); a run
2317
+ that already ended is carried
1769
2318
  back; a run whose process is gone before it ended is opened again on its directory and resumes from its store (an
1770
2319
  agentic run waiting for an answer waits without one, until a message). A carry back that finds the store held by
1771
2320
  another writer is tried again with backoff, and at the next start.
@@ -1786,7 +2335,7 @@ definition that sets it keeps it on its revision, `false` included, and an edit
1786
2335
  that never sets it stores nothing, so its revision id is the one it had before the switch. The server's `--learning off`
1787
2336
  turns learning off for every run it starts, whatever the agent says.
1788
2337
 
1789
- An agent that learns has a learning folder, `learning/` in its home (`DATA/homes/<key>/learning/`), in Claude Code's
2338
+ An agent that learns has a learning folder, `learning/` in its folder on the disk (`DATA/disk/agents/<key>/learning/`), in Claude Code's
1790
2339
  auto-memory format:
1791
2340
 
1792
2341
  - `MEMORY.md`, the index a run reads, one line per active note: `- [name](file.md) — description`, built by the server;
@@ -1852,20 +2401,19 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
1852
2401
  and handed the key of; a tier the run has no model of runs there too), in a session of its own with no tool of its
1853
2402
  own, each call node `via: "tool"` on a tool the agent has, its paid requests booked under
1854
2403
  the `learned_workflow` call, and web_search on the provider's own search where it resolves native, through the run's
1855
- models. Its model requests are the run's, under its cap and on its timeline as side requests labelled
1856
- `learned_workflow`: on claude-agent and codex, the harness's requests and the workflow's count against one total, and
1857
- each holds its worst case in flight where the other's check sees it, and the workflow's go where the harness's go (on
1858
- OPENROUTER_API_KEY alone, through OpenRouter, by OpenRouter's name for the run's model; claude-agent through the
1859
- operator's own gateway at ANTHROPIC_BASE_URL, or any harness at an origin its requests could not follow, is offered
1860
- none, which its pin names in `workflows_off`; opencode takes codex's route). A call a crash cut off is answered interrupted,
1861
- never run again. The tool gate holds
2404
+ models. Its model requests are the run's, under its cap: on pi, side requests of the run's models labelled
2405
+ `learned_workflow` on its timeline; on claude-agent, codex and opencode, requests on the run's one route, the session's
2406
+ model proxy, under a key of the run's own: the same body rules, provider, key, price and cap as the harness's own
2407
+ requests, booked on the session's records labelled `learned_workflow`. So they go wherever the harness's go (the
2408
+ operator's gateway at ANTHROPIC_BASE_URL or AGENT_MODEL_BASE_URL, OpenRouter, the vendor's API), and every run is
2409
+ offered the workflows its pin names. A call a crash cut off is answered interrupted, never run again. The tool gate holds
1862
2410
  `learned_workflow` like any tool: its settings key is `learned_workflow`, allowed by default (the agent's own graded
1863
2411
  workflow, each node checked), and tool settings may set it to ask (the run parks until an owner answers) or deny.
1864
2412
 
1865
2413
  The server reads the commit with git plumbing, never the working tree. What it holds that is not a regular UTF-8 file of
1866
2414
  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
1867
2415
  run: when the folder cannot be made or read, or its notes copied, the run starts with nothing learned. A host without
1868
- git 2.40 or later is one such fault, said once on stderr.
2416
+ git 2.32 or later (what learning's own git calls need) is one such fault, said once on stderr.
1869
2417
 
1870
2418
  ### What a run learns
1871
2419
 
@@ -1884,7 +2432,10 @@ As the run settles, before it reads ended and before a follow-up can open it aga
1884
2432
  answered, the whole text of each of its messages, and what the user said in the run, in `runs/<id>/learning-turn.json`.
1885
2433
  Once the run has ended, in the agent's queue, the server reads the notes from that answer alone (`parseReflection`, in
1886
2434
  `src/learn/reflect.ts`): an answer with no note is `empty`, and one that gives notes out of format (a note outside a
1887
- block, a block not closed, with no file name, or a name given twice) is `unparsed`, nothing kept. `checkProposal`
2435
+ block, a block with no file name, or one name given twice with other words) is `unparsed`, nothing kept. A block opens
2436
+ with the fence asked for (```` ```note ```` or four backticks for a note, four for a skill or a draft) and runs to the
2437
+ next line that is that fence; a shorter fence is text, a longer one an example, and an opening never closed is left out
2438
+ alone. `checkProposal`
1888
2439
  (`src/learn/check.ts`) then refuses, before anything is written anywhere, a note that reuses an existing note's name, a
1889
2440
  path that is not a `.md` file at the top, a bad name, front matter out of shape or setting `status`, a `supersedes`
1890
2441
  naming a note that is not active, more than 8 notes superseded, more than 8 new notes or a note over 4068 bytes (4096,
@@ -1924,9 +2475,8 @@ The run's `learning` (on `GET /runs/{run_id}`, and `{state, reason, detail}` in
1924
2475
  characters and no time) says how it went: `seeded`, then
1925
2476
  `reflecting` during the turn and until what it answered is checked, `proposed` while it is graded, and `merged`, or
1926
2477
  `dropped` with a reason from a closed list (`seed_failed`, `no_budget`, `unknown_cost`, `cancelled`, `crashed`,
1927
- `reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`;
1928
- `no_write_tool`, `tool_denied`, `screen` and `screen_down` are an older server's, still read and counted, and no run
1929
- gets them now). It is `null` for a
2478
+ `reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`; a run
2479
+ record or ledger line with any other reason is not counted). It is `null` for a
1930
2480
  run that does not learn (its agent's `learning` is not true, the server's switch was off when it started, or it is a
1931
2481
  workflow's or an imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2
1932
2482
  notes.", "Looking back on this run…", "Checking 1 new note…", "Learned: Check units (replaces 1 older note)", "Learned:
@@ -1939,21 +2489,28 @@ grader's verdict), cut of the server's secrets as they are then before the words
1939
2489
  list), so a value that became a secret after the run is never shown in part. Once it is proposed, merged or dropped (`seed_failed` included), the run's
1940
2490
  timeline has one row of kind `learning` whose summary is that detail.
1941
2491
 
1942
- Three more fields say what the run used, learned and holds for the owner's OK (`learning/2`), on its read and in run
1943
- lists alike, each absent when it holds no note: `used`, `[{file, name}]`, the notes its job read from `.learning/`,
2492
+ Four more fields say what the run was given, read, learned and holds for the owner's OK (`learning/2`), on its read and
2493
+ in run lists alike, each absent when it holds no note: `given`, `[{file, name}]`, the notes it started with (each its
2494
+ `# Learned` section names, whole or as an index line naming its file, as it was seeded; absent when it started with
2495
+ nothing learned); `read`, `[{file, name}]`, the notes its job read from `.learning/` (absent when it opened no note file),
1944
2496
  found once as the run settles from its timeline (each `read` call on any harness whose result was a success, of a note
1945
2497
  the run started from: never `MEMORY.md`, nor a read its end-of-run turn made, nor a note read through a command such as
1946
2498
  `bash`'s `cat`) and kept in `serve.json`, so a list never reads a timeline; `learned`, `[{file, name, supersedes}]`, the
1947
2499
  notes its merge added, once `merged`; and `pending`, `[{file, name}]`, the notes its merge holds for the owner's OK, once
1948
2500
  `merged`, never among `learned`. A name and a file are cut of the server's secrets as they are now, a file holding one
1949
- `[redacted]`.
2501
+ `[redacted]`. Whether a run applied a note is not measured: `given` and `read` say what it had and what it opened. Each
2502
+ note on the agent's learning view and notes page counts its runs of each, `runs: {given, read}`, over the runs the server
2503
+ knows (held ones from memory, ended ones from the learning ledger).
1950
2504
 
1951
2505
  Each run's learning end is written once to the learning ledger, `DATA/learning-usage.jsonl`, one line `{run, agent,
1952
- state, reason, at, cost, tokens, seed_notes, answered_at, job_cost_usd, look_back_usd}` (`cost` and `tokens` the
1953
- grade's, null when unknown, 0 when nothing was graded; `seed_notes` how many notes the run started from; once it looked
1954
- back, `answered_at` and `job_cost_usd`, when its job's answer was final and what it had cost then; `look_back_usd` what
2506
+ state, reason, at, cost, tokens, seed_notes, given, read, answered_at, job_cost_usd, look_back_usd}` (`cost` and
2507
+ `tokens` the grade's, null when unknown, 0 when nothing was graded; `seed_notes` how many notes the run started from;
2508
+ `given` and `read` the files of the notes it was given and read, each absent when there are none; once it looked back,
2509
+ `answered_at` and `job_cost_usd`, when its job's answer was final and what it had cost then; `look_back_usd` what
1955
2510
  looking back cost, 0 when it did not), after its `serve.json` holds it; a server that went between the two writes it at
1956
- its next start. `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
2511
+ its next start. A run's notes are the one part that moves after its end (a follow-up reads another note): a line
2512
+ `{run, agent, notes: true, given, read}` then says them anew, the latest one winning, and counts neither the run nor its
2513
+ costs again. `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
1957
2514
  `agent`, from that ledger and from the runs the server holds (`in_progress`), never opening a run's files; the
1958
2515
  `learning` meter on `GET /usage` reads the same lines.
1959
2516
 
@@ -2009,19 +2566,22 @@ with the token, an archived agent's too:
2009
2566
  too (`Approved-Via: console`). The learning view gives each item `last_change` (`{kind, by, at}`: `approved`,
2010
2567
  `edited`, `created`, `retired` or `restored` by a `person`, or `learned` by a `run`) and each retired one `retired`
2011
2568
  (`{at, by}`, the time of its retire, which an edit since moves not).
2012
- - `GET /runs/{run_id}/learning`: the run's learning whole (its `used` and `learned` as on its read, its seed, its merge, the grader's verdict with its item for
2569
+ - `GET /runs/{run_id}/learning`: the run's learning whole (its `given`, `read` and `learned` as on its read, its seed, its merge, the grader's verdict with its item for
2013
2570
  each new note, `{file, keep, question, why}`, `question` the rubric's question a dropped note failed, the checker's
2014
2571
  problems, what the grade cost), `null` for a run that does not learn; `verdict` is `null` until a grade ran.
2015
2572
  `GET /runs/{run_id}/learning/diff`: a merged run's merge commit against its parent, else its proposal against its
2016
2573
  seed, each file's patch as git writes it from the first `@@`, or `withheld` (`too_large`, `secret`).
2017
2574
 
2018
- Every read is git plumbing at one commit, with no optional lock, and every text it answers is cut of the server's
2019
- secrets as they are then; a file name holding one (a note named after a value made secret since, say) reads
2575
+ Every read is the folder's snapshot (`.agentrun/snapshot.json`, written last by the same exec as each commit to
2576
+ `main`), the files it names, each checked against its blob id (a file that is not, read twice, is a write in flight:
2577
+ `503`), and a merge's `.agentrun/diffs/<run>.json`, through the folder's file API: no git and no exec. Every text it
2578
+ answers is cut of the server's secrets as they are then; a file name holding one (a note named after a value made secret since, say) reads
2020
2579
  `[redacted]` whole, in the notes (`file`, `superseded_by`), the log's `files` and a diff's `path`, and a write's
2021
- `Location` leaves it out, while its route still answers the real name to a caller who knows it. A commit's notes are
2022
- parsed once and kept, for the few commits last read, so the view and every page at that commit read no note again; a
2023
- log page reads only its own commits (`git log` from the cursor's offset, at most `limit`), and the log's `total` is
2024
- counted once a commit. A symbolic link at the agent's home, its learning folder or the folder's `.git` is never
2580
+ `Location` leaves it out, while its route still answers the real name to a caller who knows it. A page reads only its
2581
+ own notes' files, each once at its blob; a log page reads the snapshot alone (it keeps the newest 200 changes). A
2582
+ cursor reads at the main it names while this server still holds that snapshot, else as the first page of `main` now.
2583
+ Every write to `main` (a run's merge, a person's edit, create, retire, approve or restore) is one exec of the learning
2584
+ script, a compare and swap on `main`. A symbolic link at the agent's home, its learning folder or the folder's `.git` is never
2025
2585
  followed: a read or a write there answers `500`, and nothing is written.
2026
2586
 
2027
2587
  ### Approving a note that waits
@@ -2039,16 +2599,49 @@ log shows `by: {user: true, via: "console"}` at the commit's time, never the not
2039
2599
 
2040
2600
  ## Spend cap
2041
2601
 
2042
- An agentic run may name `max_cost_usd` (a workflow run may not: `422`). A run that names none takes its agent's default,
2602
+ A run may name `max_cost_usd`, an agentic run or a workflow run ([below](#a-workflow-run-under-its-cap)). A run that names none takes its agent's default,
2043
2603
  the `max_cost_usd` of the revision it runs, kept with the revision; a run's own cap wins, since its caller chose it. A
2044
2604
  definition's `max_cost_usd` above 0 sets that default, and 0 clears it (no default); anything else is `422`. An edit that
2045
2605
  leaves the field out keeps the agent's default, as it keeps its harness and place: leaving a field out never removes a
2046
- spend limit. A workflow definition keeps none: above 0 is `422 not_allowed`, and 0 changes nothing. The cap is checked in the run's own process
2606
+ spend limit. A workflow definition keeps one the same way. The cap is checked in the run's own process
2047
2607
  before each model request, the agent's and a compaction's alike, on every harness: what the run has spent so far, plus
2048
- the worst case of each request still in flight, plus this request's worst case must stay within it, or the request is
2049
- not sent and the run pauses ([below](#a-run-paused-at-its-cap)). A request's worst case is its input bound at the higher of
2050
- the model's input and cache-write prices (the provider may bill any of the input as a cache write), plus the output it is
2051
- sent with at the output price, plus any fee its tokens do not show (below). Under a cap each request is limited to the
2608
+ what each request still in flight is held at, plus what this request is expected to cost must stay within it, or the
2609
+ request is not sent and the run pauses ([below](#a-run-paused-at-its-cap)). A request costs its input, plus the output it
2610
+ is sent with at the output price, plus any fee its tokens do not show (below). How its input is priced is the run's
2611
+ `cap_mode`: the run's own (`POST /agents/{id}/runs` with `cap_mode`), else its agent's (a definition's `cap_mode`, kept by
2612
+ an edit that leaves it out), else `expected`; only a run with a cap takes one (`422 not_allowed` otherwise).
2613
+
2614
+ - `expected`: priced from the previous request of its conversation, as that request's usage reported it. The input it
2615
+ read from the cache or wrote to it (`cache_read_input_tokens` and `cache_creation_input_tokens` on Anthropic's API,
2616
+ `input_tokens_details.cached_tokens` on the Responses API) at the cache-read price, if that request ended less than 4
2617
+ minutes before (Anthropic keeps a cache 5); the rest (its input after the cache, plus what the conversation grew by
2618
+ since, one token per byte) at the higher of the input and cache-write prices. With no previous request in hand, or one
2619
+ older than 4 minutes, all of the input at that price. On claude-agent, codex and opencode the previous request is the
2620
+ session's last on the same model in the run's current process, so a run's first request after a restart is priced
2621
+ with nothing cached; on pi it is the conversation's last answer. Output never passes the cap (below); a request that
2622
+ misses the cache can, by at most its bound: its input at full price less its input expected. The run's
2623
+ `cost.overshoot_bound_usd` serves the bound of the requests in flight. A request's real cost is always booked, never
2624
+ clipped: a run that passed its cap so is not failed for it, its timeline says `Went $X over its cap on a cache miss (at
2625
+ most $Y).`, and its next request is refused, so it pauses at its cap as usual. A request whose cost never comes in (cut,
2626
+ stopped, lost) counts at what it was held at, its expected cost, in this process and after a restart alike.
2627
+ - `strict`: every input token at the higher of the input and cache-write prices (the provider may bill any of the input as
2628
+ a cache write), the worst case: no request passes the cap, and a run whose requests read the cache pauses well before
2629
+ it has spent its cap.
2630
+
2631
+ Near its cap, a run's model is told once to finish: when what is left (the cap less what was spent and what requests
2632
+ in flight are held at) is under three times the run's typical request, the next request of the run's own model carries
2633
+ "About $X left of this run's budget: finish now with your answer." at its end, and the Timeline shows it as the server's
2634
+ row ("AgentRun: About $X left …"). The typical request is the median of the run's own model's priced requests after the
2635
+ first (the first writes the cache), else that one, else, while nothing is priced, the next request at its input and a
2636
+ 4,096-token answer (never its whole output allowance: a $1 run on Sonnet 4.5 is not told at its start); side calls on
2637
+ another model and paid tools count in what is left, never in the typical request. Told while nothing is priced (a small
2638
+ cap, due at the run's first request), the words say the budget instead, on every harness: "This run's budget is about
2639
+ $X, enough for little work: answer as soon as you can." On pi the words go into that one request's context;
2640
+ on claude-agent, codex and opencode the model proxy adds them to the body (after everything the CLI sent, so its cached
2641
+ prefix is unchanged). Neither CLI nor pi keeps them in its transcript, and no message is queued, so nothing runs after
2642
+ the model's answer. Once per cap, across restarts; a raise re-arms it.
2643
+
2644
+ Under a cap each request is limited to the
2052
2645
  output tokens what is left of the cap can buy, thinking included, never more than it asks for or than the model's
2053
2646
  ceiling (its max output tokens, else its context window, clamped to what the window leaves): on pi through the request's
2054
2647
  own options (its max tokens, and on Anthropic's API its thinking budget), on claude-agent, codex and opencode written into its body
@@ -2059,8 +2652,8 @@ where thinking takes one (Anthropic's, 1,024, the budget squeezed to it at the l
2059
2652
  budget, since its reasoning then shares the limit (minimal 1,024, low 2,048, medium 8,192, high 16,384). The input bound is one token per UTF-8 byte of what is sent (a byte-level tokenizer never makes
2060
2653
  a token of less than one byte, and an image's base64 is far more bytes than its tokens), plus what the provider adds
2061
2654
  server-side (a tool-use prompt, each image), from the same table the model proxy of claude-agent, codex and opencode uses; there
2062
- the proxy measures each request's body. A request in flight holds its worst case until it answers, so requests sent side
2063
- by side cannot pass the cap together. Spent so far is read from the run's store each time its process starts, so it
2655
+ the proxy measures each request's body. A request in flight holds what it was admitted at until it answers, so requests
2656
+ sent side by side cannot pass the cap together. Spent so far is read from the run's store each time its process starts, so it
2064
2657
  survives a restart, plus each response since, and with them each charge a paid tool booked (`monid.run`, which is itself
2065
2658
  refused once the spend reaches the cap; see [monid](#tools)).
2066
2659
 
@@ -2070,7 +2663,7 @@ it up to), pi-browser's idle window before it releases a session nobody calls (1
2070
2663
  confirmed at the provider; at Browserbase's price, 270 s or $0.009. Before each browser call, the call is held at what its
2071
2664
  session ran since its last charge plus two stretches (one for the call's own time, one for a session it opens): spent, plus
2072
2665
  every hold, plus that must stay within the cap. Otherwise the call is not made: the model gets the cap's words
2073
- (`spend_cap_reached: Not sent: the run has spent $X of its $C cap, and this browser call could cost up to $0.018 ...`), and
2666
+ (`spend_cap_reached: Not sent: this run has spent $X of its $C cap, and the next step, this browser call, could cost up to $0.018 ...`), and
2074
2667
  the run's session is released.
2075
2668
  A session's first charge moves one stretch of its call's hold to the session, held until its release is booked, which
2076
2669
  covers its idle time, its top-up and its release; each call's charge comes out of the call's hold, which goes when the
@@ -2141,12 +2734,14 @@ the same: a capped run stopped and sent another message, or opened again after i
2141
2734
  allows. A cut request from a store written before serve kept the figure has none, and is a spend no one knows.
2142
2735
 
2143
2736
  A refusal says so in plain words, with the numbers, on its timeline row and on the run's `pending` (or, for a refusal
2144
- no cap fixes, its error): "Not sent: this run's
2145
- cap of $0.01 can't cover one Claude Sonnet 5.5 request (at least $0.03). Raise the cap to at least $0.03 to run it.", and
2146
- once a run has spent: "Not sent: the run has spent $0.45 of its $0.50 cap, and its next Claude Sonnet 5.5 request needs at
2147
- least $0.03. Raise the cap to at least $0.48 to run it." The cap that would run it is what was spent, what requests still
2148
- answering hold, and the request's least, rounded up to the cent so that it is enough; the model is named as its catalog
2149
- names it, without a vendor's prefix. The error's code is `spend_cap_reached (out of budget): ` before those words: pi-ai's
2737
+ no cap fixes, its error), as a person who has never seen a model request reads them: "Not sent: the next step needs at
2738
+ least $0.03, and this run's cap is $0.01. Raise the cap to at least $0.03 to continue.", and once a run has spent:
2739
+ "Not sent: this run has spent $0.45 of its $0.50 cap, and the next step needs at least $0.03. Raise the cap to at least
2740
+ $0.48 to continue." What was spent, and what steps still running hold (named when it is a cent or more), read to the
2741
+ nearest cent ($0.0237416 reads $0.02); the exact amounts are `pending.spent_usd`. The cap to raise to is what was
2742
+ spent, what steps still running hold, and the next step's least, rounded up to the cent so that it is enough. The words
2743
+ name no model. The refusal's timeline row is an `error` row with
2744
+ `paused: true`: the request was not sent and the run waits on a raise, so it reads as a pause, never as a failure. The error's code is `spend_cap_reached (out of budget): ` before those words: pi-ai's
2150
2745
  retry reads only an error's text, and takes "out of budget" as final whatever digits the words hold. A request the cap
2151
2746
  refused was never sent: the run's usage counts no request for it, and a run whose only request was refused says "no model
2152
2747
  request sent". A reply the limit cut short says so on the run's timeline: "The reply stopped at 1,500 tokens: all that
@@ -2156,14 +2751,19 @@ the $0.15 left of the run's $0.50 cap could buy."
2156
2751
 
2157
2752
  A refusal for room (what is left of the cap cannot buy the next request's least) pauses the run instead of ending it: the
2158
2753
  refused request was not sent, so the cap holds, and a higher cap would send it. The run is `input_required` and
2159
- `waiting`, `error` null, with `pending: {kind: "budget", cap_usd, spent_usd, needs_usd, suggested_cap_usd, said, at}`:
2754
+ `waiting`, `error` null, with `pending: {kind: "budget", cap_usd, spent_usd, needs_usd, least_cap_usd, suggested_cap_usd, said, at}`:
2160
2755
  its cap, what the cap counted as taken (spent, and held for requests still answering) and the least the refused request
2161
- needs (a cap above their sum sends it), the raise it is offered, the refusal's words above, and when it came. The
2756
+ needs (a cap above their sum sends it), the least cap that sends it, the raise it is offered, the refusal's words above,
2757
+ and when it came. `least_cap_usd` is the very figure the words name ("Raise the cap to at least $X"), in whole
2758
+ cents and above the cap, carried from the refusal that wrote them, so a client shows it without parsing the sentence. The
2162
2759
  offered raise, `suggested_cap_usd`, is `spent_usd` + 10 × `needs_usd` rounded up to a whole dollar, and always above the
2163
2760
  cap, so a `PATCH` with it (below) resumes the run; it is absent with the other figures. The figures come from the refusal's own start mark, so a
2164
2761
  server started again says them too, shown as `cost.usd` is (to a millionth of a dollar), except `spent_usd` once the paused process is gone: the refusal counted requests
2165
2762
  still answering at what it held for them, so then it is the store's spend, when that is lower, and `suggested_cap_usd`
2166
- follows it. The refusal's words (`said`) keep its own figures. Its timeline shows the refusal's row, then a waiting row: "Paused at the run's $0.05 cap: Not sent: …". The
2763
+ follows it. The refusal's words (`said`) keep its own figures. Its timeline shows the refusal's row, the server's `phase` row "Paused at the run's cap" (`origin` server, its id
2764
+ ending `:note`, so it is no message) marked `paused` (never an `error` row; it stays once the cap is raised, as the
2765
+ run's history), then a waiting row: "Waiting for you to raise the
2766
+ cap", and no more: the words are `pending.said`'s, which a client shows once. The
2167
2767
  webhook's `run.needs_input` says `pending.kind: "budget"`. Its process is let go while it waits (SIGTERM: it drains and
2168
2768
  releases the run), so a paused run holds no place; a server started again reads it paused from its store. A paused
2169
2769
  process that does not let go within the drain timeout (`--drain-timeout`, 30 s by default) is killed, and the run ends
@@ -2182,14 +2782,16 @@ message, starts a turn that is judged as any other. A paid call refused because
2182
2782
  still ends the run `failed`.
2183
2783
 
2184
2784
  `PATCH /runs/{run_id}` with `{max_cost_usd}` raises the cap, and only raises it: the new cap is above the run's current
2185
- cap, its last raise included, by more than a float's tail (1e-9; `422` otherwise, and for a run with no cap or a workflow
2186
- run; `409 not_continuable` for an ended run). The same raise sent again (a retry), within that tail, changes nothing and
2785
+ cap, its last raise included, by more than a float's tail (1e-9; `422` otherwise, and for a run with no cap;
2786
+ `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
2187
2787
  answers as the first did. The run's serve.json keeps the raise before any answer, with each raise in `cap_raised`, so its
2188
2788
  next process opens under it, as does a server started again; a raise it could not keep is not taken (an error answers it),
2189
2789
  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,
2190
2790
  message_id, status, state}` at once, and the pause gets one follow-up turn, "The cap was raised to $2; continue the
2191
2791
  task.", under that `message_id`, which the server sends once the process being let go is gone, and which runs under the
2192
- new cap. A second raise before it goes raises the cap it names and answers the same `message_id`. It is sent once: a
2792
+ new cap. From the moment the raise is taken, the run reads `queued` (state `working`), in the answer's `status` and in
2793
+ every read after it, until the follow-up's turn runs: nothing waits on a person, so it is never `input_required` with no
2794
+ `pending` meanwhile. A second raise before it goes raises the cap it names and answers the same `message_id`. It is sent once: a
2193
2795
  server stopped before it went, or between starting its process and sending it, sends it when it starts again. One that
2194
2796
  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
2195
2797
  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
@@ -2204,7 +2806,7 @@ picking it is refused, and on `auto` it searches through Parallel on the server'
2204
2806
  keyless Exa, as a capped codex run does; pi's own search request is held at its context
2205
2807
  plus 125,000 (5 searches) and its most fee, 5 searches at $0.01. What the request
2206
2808
  cost, booked once it answers, stops the next request through the cap, and a run whose booked spend passes its cap shows
2207
- one timeline row saying by how much (`Spent $X, $Y over the run's cap of $Z`).
2809
+ one timeline row saying by how much (`Spent $X, $Y over the run's cap of $Z`, in cents).
2208
2810
 
2209
2811
  The server also checks the run's cost after each response, as a backstop, and stops a run whose cost passed its cap.
2210
2812
  Either way the run keeps the answer it paid for: a run the cap stopped has `result: {output: null, final_answer}`, the
@@ -2215,6 +2817,34 @@ response reported no price or a request was cut before its end (a stop, a cancel
2215
2817
  but a request of unknown price is unknown, never $0. A stopped request shows `null` whether or not its cap counted it at
2216
2818
  its held worst case.
2217
2819
 
2820
+ ### A workflow run under its cap
2821
+
2822
+ A workflow run is capped by the same checks, in its own process, each before the paid step is sent:
2823
+
2824
+ | Step | Held at | Where |
2825
+ |---|---|---|
2826
+ | A model node's request | its expected cost, as an agentic run's request | the run's models (`cap.ts` capModels) |
2827
+ | A call node's `llm` call | the same | the same, as a side request |
2828
+ | A call node's paid tool call (Parallel's search or extract) | its fee | `paidCall`, as an agentic run's |
2829
+ | A decision on Parallel | its list price for one request, $0.001 | before the driver admits it (`decision-cap.ts`) |
2830
+ | A decision on Jev | TypeSafe's published price, $0.042 a million input tokens, one token a byte of its state and questions | the same |
2831
+ | A decision on an OpenRouter Decisions model | its catalog price: per request, per image, per input token, and per output token for 256 a question (`expected`) or the catalog's most (`strict`) | the same |
2832
+
2833
+ What a decision charged is booked in the run's store as the cap counted it, so a run opened again counts it once. A step
2834
+ the cap has no room for is not sent and waits where it stands: the run is `input_required`, state `waiting`, with
2835
+ `pending.kind` budget and `pending.node` the node's label. A model node's request waits unsent; a call node's call
2836
+ ends its effect held, sending nothing, and goes again as a new effect once raised, never as the tool's own failure, which
2837
+ a map that collects failed items would take for an item's; a decision waits before the driver admits it, so it is never
2838
+ a request asked and unanswered. What a call node waited is not counted against its deadline. A pause holds the run's
2839
+ process for 10 minutes, then lets it go (nothing in flight but the waits): the run stays paused, and no process is
2840
+ started for it. `PATCH /runs/{run_id}` raises the cap as for an agentic run, with no follow-up turn: a waiting process
2841
+ judges its step again under the new cap, and a run whose process was let go is opened again under it, resuming from its
2842
+ journal, so no completed node is sent again (`resumed: true`, no `message_id`). A capped start is refused before anything is sent, as an
2843
+ agentic run's is, when a model one of its nodes or `llm` calls runs on has no price here, or a decision pins an
2844
+ OpenRouter Decisions model the catalog lists no price for: `409 agent_not_runnable`, each in `error.fields` with the
2845
+ node's label and its fix. A step no cap fixes all the same (a spend no one knows) ends the run `failed`,
2846
+ `spend_cap_reached`, in the cap's words, after the node's label.
2847
+
2218
2848
  ## The faux model
2219
2849
 
2220
2850
  `--faux MODULE` loads `MODULE` in each run's process. Its default export is called for every model request with the
@@ -2228,8 +2858,8 @@ export default function reply(context, faux) {
2228
2858
  }
2229
2859
  ```
2230
2860
 
2231
- `startServe({ faux, fauxBrowser, fauxWeb })` (the tests', not the CLI's) also names modules whose default exports give
2232
- the `browser` tool's `{ provider, driver }` in place of Browserbase's or Kernel's (pi-browser's fake backend, told the
2861
+ `startServe({ faux, fauxBrowser, fauxWeb })` also names modules whose default exports give
2862
+ the `browser` tool's `{ provider, driver }` (`fauxBrowser`, which the CLI takes as `--faux-browser MODULE`; the others are the tests' alone) in place of Browserbase's or Kernel's (pi-browser's fake backend, told the
2233
2863
  vendor the run's plane names and the saved sign-in the run was handed: `test/fixtures/faux-browser.mjs`), `web_fetch`'s direct fetch's `{ lookup, fetchImpl }` in place of the system's resolver and
2234
2864
  undici (a table of names and pages, `test/fixtures/faux-web.mjs`), and, as `fauxMonid`, the fetch the monid tools send
2235
2865
  through in place of monid's API (`test/fixtures/faux-monid.mjs`). Each is honored only with `faux`.
@@ -2265,6 +2895,19 @@ carries no cost at all, as from a provider that does not price the model. The te
2265
2895
  in the run's `work/`. An agent's saved sign-in stays at the vendor; this server keeps a sealed pointer to it, which a
2266
2896
  run's process gets over its pipe and its tools and model never see. Anyone holding the vendor's key can open that
2267
2897
  context or profile there.
2898
+ - A run's live browser view is a full-control credential for its session: once taken over, it drives the browser. Its
2899
+ token lives in the run's process, in one 0600 file in the run's directory (never `work/`) while the session is open, and in
2900
+ the owner's answer to `GET /runs/{id}/browser`, which takes the owner's password session alone, as the hand-back does. The
2901
+ viewer's WebSocket is taken only under the run's path, from this server's own origin, with the owner's session; its page is
2902
+ framed by this server's own origin alone; outside a take-over its input is dropped by the run before the browser; the
2903
+ vendors' own live-view links never leave the run's process.
2904
+ - The viewer's code always comes from this server: its page, script and style are the files of the pi-browser this server has
2905
+ installed, served under `script-src 'self'`, never anything a run's port answers. A run's port only ever carries the
2906
+ viewer's WebSocket, which is data, so whatever answers on a run's port never runs script on the console's origin.
2907
+ - The owner's time in a run's browser counts toward its cap and is held before it starts: a take-over, and an agent's ask,
2908
+ hold 15 minutes of session time at the provider's price (once per session, shared by a take-over and an ask on it),
2909
+ refused in the cap's words without room. A take-over that steady input keeps alive past 15 minutes is held again every
2910
+ 15 minutes; with no room the browser goes back to the agent, in the cap's words.
2268
2911
  - It binds 127.0.0.1 by default, and there refuses a request whose `Host` names something other than this machine
2269
2912
  (DNS rebinding): `localhost`, `127.0.0.1`, `[::1]`, the `AGENTRUN_PUBLIC_URL` name and each `--allow-host` name are
2270
2913
  served, on any port, so a tunnel (`ssh -L 8080:localhost:7340`) or a proxy in front works; any other name is `403`, a
@@ -2275,7 +2918,7 @@ carries no cost at all, as from a provider that does not price the model. The te
2275
2918
  browser's cookie under the rules of [the console](#the-console). The console's own files (its HTML, scripts, styles
2276
2919
  and fonts) hold no data; everything it shows comes through those routes. It loads nothing from the network, and its
2277
2920
  CSP allows this origin only.
2278
- - Each run's door listens on loopback and takes only that run's own door token (`DIR/runs/<id>/door-token`, 0600, made
2921
+ - 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
2279
2922
  at its first launch); a run's process an older server started keeps the server-wide one (`DIR/.door-token`).
2280
2923
  - A run's process gets the server's environment (the `AGENT_MODEL` variables among it) without the server's token or any
2281
2924
  key: no `AGENTRUN_TOKEN`, no `AGENTRUN_API_KEY`, no variable whose value is the token, and no variable named like a key
@@ -2336,6 +2979,9 @@ carries no cost at all, as from a provider that does not price the model. The te
2336
2979
  value under another name.
2337
2980
  - The 4,096-byte pipe limit stays until the launcher writes the pipe from a background subshell that blocks until the
2338
2981
  server has read it.
2982
+ - The browser's evidence is numbered from the highest number the run's `evidence/` holds when its browser first files
2983
+ there, through the run's Workspace, which has no exclusive create. One browser per run files there, so two never pick
2984
+ one number; two filing into one run's `evidence/` at the same moment could.
2339
2985
 
2340
2986
  ## Test
2341
2987