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

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 (816) hide show
  1. package/CHANGELOG.md +459 -0
  2. package/NOTICE +18 -0
  3. package/README.md +941 -263
  4. package/dist/adapter-facts.d.ts +3 -0
  5. package/dist/adapter-facts.js +5 -0
  6. package/dist/adapters.d.ts +64 -143
  7. package/dist/adapters.js +153 -384
  8. package/dist/agents-store.d.ts +146 -0
  9. package/dist/agents-store.js +359 -0
  10. package/dist/agents.d.ts +4 -2
  11. package/dist/agents.js +37 -17
  12. package/dist/api-only.d.ts +14 -0
  13. package/dist/api-only.js +33 -0
  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/box-egress-vm.d.ts +2 -9
  22. package/dist/box-egress-vm.js +20 -16
  23. package/dist/box-egress.d.ts +15 -9
  24. package/dist/box-egress.js +26 -29
  25. package/dist/box-paths.d.ts +82 -0
  26. package/dist/box-paths.js +160 -0
  27. package/dist/box-relay-vm.js +28 -1
  28. package/dist/box-relay.d.ts +1 -10
  29. package/dist/box-relay.js +1 -21
  30. package/dist/box-settings.d.ts +46 -0
  31. package/dist/box-settings.js +107 -0
  32. package/dist/boxes.d.ts +17 -2
  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 +277 -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 +166 -0
  41. package/dist/browser-person.js +767 -0
  42. package/dist/budget.d.ts +76 -0
  43. package/dist/budget.js +204 -0
  44. package/dist/cap.d.ts +267 -64
  45. package/dist/cap.js +587 -199
  46. package/dist/cli.js +220 -21
  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-Dn0ngwG9.js +535 -0
  65. package/dist/console/assets/index-DvW6Aled.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/daytona-api.d.ts +0 -11
  70. package/dist/daytona-api.js +1 -82
  71. package/dist/decision-cap.d.ts +63 -0
  72. package/dist/decision-cap.js +163 -0
  73. package/dist/decision-rows.d.ts +5 -2
  74. package/dist/decision-rows.js +8 -6
  75. package/dist/decisions.d.ts +28 -1
  76. package/dist/decisions.js +63 -6
  77. package/dist/docker-host-addresses.d.ts +37 -0
  78. package/dist/docker-host-addresses.js +110 -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 -43
  93. package/dist/files.js +8 -136
  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-install.d.ts +143 -0
  107. package/dist/harness-install.js +454 -0
  108. package/dist/harness-opencode/adapter.js +42 -8
  109. package/dist/harness-opencode/facts.d.ts +2 -0
  110. package/dist/harness-opencode/facts.js +28 -0
  111. package/dist/harness-opencode/harness.d.ts +4 -0
  112. package/dist/harness-opencode/harness.js +38 -5
  113. package/dist/harness-opencode/host/policy.js +11 -3
  114. package/dist/harness-opencode/transcript.d.ts +25 -0
  115. package/dist/harness-opencode/transcript.js +81 -0
  116. package/dist/harness-table.d.ts +75 -0
  117. package/dist/harness-table.js +145 -0
  118. package/dist/harness.d.ts +11 -31
  119. package/dist/harness.js +30 -41
  120. package/dist/heard.d.ts +12 -0
  121. package/dist/heard.js +45 -0
  122. package/dist/helper-env.d.ts +4 -0
  123. package/dist/helper-env.js +14 -0
  124. package/dist/home-path.d.ts +0 -4
  125. package/dist/home-path.js +3 -17
  126. package/dist/host-check.d.ts +4 -3
  127. package/dist/host-check.js +5 -4
  128. package/dist/host-tools.d.ts +51 -8
  129. package/dist/host-tools.js +108 -117
  130. package/dist/host.d.ts +12 -6
  131. package/dist/host.js +30 -24
  132. package/dist/hosted-search.d.ts +3 -0
  133. package/dist/hosted-search.js +5 -3
  134. package/dist/import-proxy.d.ts +42 -0
  135. package/dist/import-proxy.js +105 -0
  136. package/dist/import-summary.js +4 -8
  137. package/dist/import-worker.d.ts +2 -3
  138. package/dist/import-worker.js +18 -16
  139. package/dist/import.d.ts +37 -17
  140. package/dist/import.js +249 -224
  141. package/dist/key-meta.d.ts +26 -0
  142. package/dist/key-meta.js +30 -0
  143. package/dist/key-refusal.d.ts +4 -1
  144. package/dist/key-refusal.js +20 -7
  145. package/dist/learn/check.d.ts +3 -1
  146. package/dist/learn/check.js +2 -2
  147. package/dist/learn/commit.d.ts +86 -0
  148. package/dist/learn/commit.js +182 -0
  149. package/dist/learn/folder.d.ts +296 -0
  150. package/dist/learn/folder.js +796 -0
  151. package/dist/learn/grade.d.ts +22 -9
  152. package/dist/learn/grade.js +95 -49
  153. package/dist/learn/index.d.ts +2 -2
  154. package/dist/learn/index.js +2 -2
  155. package/dist/learn/learning.sh +366 -0
  156. package/dist/learn/reflect.d.ts +12 -5
  157. package/dist/learn/reflect.js +70 -41
  158. package/dist/learn/secrets.d.ts +16 -7
  159. package/dist/learn/secrets.js +80 -17
  160. package/dist/learn/seed-check.d.ts +74 -0
  161. package/dist/learn/seed-check.js +103 -0
  162. package/dist/learn/skills.d.ts +5 -1
  163. package/dist/learn/skills.js +5 -4
  164. package/dist/learned-workflow.d.ts +15 -4
  165. package/dist/learned-workflow.js +13 -6
  166. package/dist/learning-routes.d.ts +56 -46
  167. package/dist/learning-routes.js +350 -553
  168. package/dist/learning-run.d.ts +8 -228
  169. package/dist/learning-run.js +26 -713
  170. package/dist/learning-words.d.ts +3 -5
  171. package/dist/learning-words.js +3 -5
  172. package/dist/learning.d.ts +177 -112
  173. package/dist/learning.js +289 -380
  174. package/dist/live/stream.d.ts +30 -0
  175. package/dist/live/stream.js +175 -0
  176. package/dist/live/translate.d.ts +52 -0
  177. package/dist/live/translate.js +276 -0
  178. package/dist/llm.js +3 -0
  179. package/dist/llms.txt +1 -0
  180. package/dist/local-models.d.ts +23 -0
  181. package/dist/local-models.js +35 -0
  182. package/dist/mcp-gateway.d.ts +45 -15
  183. package/dist/mcp-gateway.js +140 -53
  184. package/dist/mcp-meta.d.ts +3 -0
  185. package/dist/mcp-meta.js +14 -2
  186. package/dist/mcp-oauth.d.ts +172 -0
  187. package/dist/mcp-oauth.js +403 -0
  188. package/dist/mcp-private-hosts.d.ts +48 -0
  189. package/dist/mcp-private-hosts.js +141 -0
  190. package/dist/mcp-probe.d.ts +101 -0
  191. package/dist/mcp-probe.js +359 -0
  192. package/dist/mcp-secret-writes.d.ts +23 -0
  193. package/dist/mcp-secret-writes.js +60 -0
  194. package/dist/mcp-servers-store.d.ts +251 -0
  195. package/dist/mcp-servers-store.js +447 -0
  196. package/dist/mcp-servers.d.ts +180 -50
  197. package/dist/mcp-servers.js +284 -321
  198. package/dist/mcp-store.d.ts +103 -0
  199. package/dist/mcp-store.js +123 -0
  200. package/dist/mcp.js +22 -21
  201. package/dist/model.d.ts +77 -59
  202. package/dist/model.js +237 -98
  203. package/dist/monid.d.ts +8 -6
  204. package/dist/monid.js +39 -25
  205. package/dist/openapi.d.ts +22 -1
  206. package/dist/openapi.js +921 -110
  207. package/dist/owner.d.ts +46 -10
  208. package/dist/owner.js +123 -43
  209. package/dist/page.d.ts +10 -0
  210. package/dist/page.js +29 -4
  211. package/dist/paid-calls.d.ts +71 -2
  212. package/dist/paid-calls.js +127 -6
  213. package/dist/pause.d.ts +0 -2
  214. package/dist/pause.js +1 -8
  215. package/dist/pdf-pages.d.ts +16 -14
  216. package/dist/pdf-pages.js +88 -58
  217. package/dist/place.d.ts +15 -18
  218. package/dist/place.js +25 -25
  219. package/dist/port-models.d.ts +53 -0
  220. package/dist/port-models.js +93 -0
  221. package/dist/print.d.ts +2 -1
  222. package/dist/print.js +4 -2
  223. package/dist/propose.d.ts +9 -8
  224. package/dist/propose.js +82 -49
  225. package/dist/provider.d.ts +85 -0
  226. package/dist/provider.js +178 -0
  227. package/dist/push-handler.d.ts +52 -0
  228. package/dist/push-handler.js +165 -0
  229. package/dist/refusal-words.d.ts +23 -0
  230. package/dist/refusal-words.js +25 -0
  231. package/dist/result.d.ts +13 -2
  232. package/dist/result.js +4 -5
  233. package/dist/run-computer.d.ts +24 -0
  234. package/dist/run-computer.js +15 -0
  235. package/dist/run-cut.d.ts +33 -0
  236. package/dist/run-cut.js +42 -0
  237. package/dist/run-db.d.ts +62 -0
  238. package/dist/run-db.js +151 -0
  239. package/dist/run-files.d.ts +31 -0
  240. package/dist/run-files.js +125 -0
  241. package/dist/run-launch.d.ts +72 -0
  242. package/dist/run-launch.js +108 -0
  243. package/dist/run-learning-served.d.ts +81 -0
  244. package/dist/run-learning-served.js +25 -0
  245. package/dist/run-manifest.d.ts +7 -6
  246. package/dist/run-manifest.js +20 -10
  247. package/dist/run-reads-over-store.d.ts +102 -0
  248. package/dist/run-reads-over-store.js +151 -0
  249. package/dist/run-secrets.d.ts +33 -0
  250. package/dist/run-secrets.js +53 -0
  251. package/dist/run-timeline-served.d.ts +13 -0
  252. package/dist/run-timeline-served.js +72 -0
  253. package/dist/run-view.d.ts +432 -0
  254. package/dist/run-view.js +602 -0
  255. package/dist/runnable.d.ts +30 -5
  256. package/dist/runnable.js +149 -72
  257. package/dist/runner/adapter-loop.d.ts +243 -0
  258. package/dist/runner/adapter-loop.js +1657 -0
  259. package/dist/runner/adapter-run-spec.d.ts +224 -0
  260. package/dist/runner/adapter-run-spec.js +538 -0
  261. package/dist/runner/adapters/index.d.ts +37 -0
  262. package/dist/runner/adapters/index.js +66 -0
  263. package/dist/runner/adapters/pi.d.ts +103 -0
  264. package/dist/runner/adapters/pi.js +263 -0
  265. package/dist/runner/beside.d.ts +12 -0
  266. package/dist/runner/beside.js +41 -0
  267. package/dist/runner/claim-secrets.d.ts +30 -0
  268. package/dist/runner/claim-secrets.js +90 -0
  269. package/dist/runner/cli-run-spec.d.ts +17 -0
  270. package/dist/runner/cli-run-spec.js +385 -0
  271. package/dist/runner/commands.d.ts +23 -0
  272. package/dist/runner/commands.js +67 -0
  273. package/dist/runner/computer-journal.d.ts +38 -0
  274. package/dist/runner/computer-journal.js +120 -0
  275. package/dist/runner/conformance/child.d.ts +1 -0
  276. package/dist/runner/conformance/child.js +78 -0
  277. package/dist/runner/conformance/harness.d.ts +89 -0
  278. package/dist/runner/conformance/harness.js +928 -0
  279. package/dist/runner/conformance/subject.d.ts +83 -0
  280. package/dist/runner/conformance/subject.js +1 -0
  281. package/dist/runner/dispatch.d.ts +30 -0
  282. package/dist/runner/dispatch.js +99 -0
  283. package/dist/runner/end-of-run.d.ts +32 -0
  284. package/dist/runner/end-of-run.js +56 -0
  285. package/dist/runner/github-app.d.ts +16 -0
  286. package/dist/runner/github-app.js +37 -0
  287. package/dist/runner/hand-back.d.ts +43 -0
  288. package/dist/runner/hand-back.js +69 -0
  289. package/dist/runner/harness-loops.d.ts +10 -0
  290. package/dist/runner/harness-loops.js +70 -0
  291. package/dist/runner/journal-kinds.d.ts +217 -0
  292. package/dist/runner/journal-kinds.js +116 -0
  293. package/dist/runner/journal-reader.d.ts +44 -0
  294. package/dist/runner/journal-reader.js +127 -0
  295. package/dist/runner/learning-ask.d.ts +37 -0
  296. package/dist/runner/learning-ask.js +99 -0
  297. package/dist/runner/learning-dispatch.d.ts +38 -0
  298. package/dist/runner/learning-dispatch.js +75 -0
  299. package/dist/runner/learning-end.d.ts +31 -0
  300. package/dist/runner/learning-end.js +136 -0
  301. package/dist/runner/learning-factory.d.ts +13 -0
  302. package/dist/runner/learning-factory.js +37 -0
  303. package/dist/runner/learning-loop.d.ts +150 -0
  304. package/dist/runner/learning-loop.js +246 -0
  305. package/dist/runner/learning-seed.d.ts +30 -0
  306. package/dist/runner/learning-seed.js +41 -0
  307. package/dist/runner/live-ticker.d.ts +18 -0
  308. package/dist/runner/live-ticker.js +112 -0
  309. package/dist/runner/loop-contract.d.ts +154 -0
  310. package/dist/runner/loop-contract.js +26 -0
  311. package/dist/runner/loop.d.ts +79 -0
  312. package/dist/runner/loop.js +185 -0
  313. package/dist/runner/main.d.ts +96 -0
  314. package/dist/runner/main.js +311 -0
  315. package/dist/runner/mcp-claim.d.ts +67 -0
  316. package/dist/runner/mcp-claim.js +403 -0
  317. package/dist/runner/mcp-github.d.ts +53 -0
  318. package/dist/runner/mcp-github.js +91 -0
  319. package/dist/runner/mcp-run.d.ts +116 -0
  320. package/dist/runner/mcp-run.js +152 -0
  321. package/dist/runner/metrics.d.ts +18 -0
  322. package/dist/runner/metrics.js +24 -0
  323. package/dist/runner/model-route.d.ts +111 -0
  324. package/dist/runner/model-route.js +202 -0
  325. package/dist/runner/pi-stop.d.ts +6 -0
  326. package/dist/runner/pi-stop.js +8 -0
  327. package/dist/runner/redact.d.ts +32 -0
  328. package/dist/runner/redact.js +60 -0
  329. package/dist/runner/reflect-hook.d.ts +81 -0
  330. package/dist/runner/reflect-hook.js +111 -0
  331. package/dist/runner/runner.d.ts +114 -0
  332. package/dist/runner/runner.js +672 -0
  333. package/dist/runner/sessions.d.ts +9 -0
  334. package/dist/runner/sessions.js +145 -0
  335. package/dist/runner/side-effects.d.ts +19 -0
  336. package/dist/runner/side-effects.js +20 -0
  337. package/dist/runner/spec-holds.d.ts +41 -0
  338. package/dist/runner/spec-holds.js +58 -0
  339. package/dist/runner/store-port.d.ts +9 -0
  340. package/dist/runner/store-port.js +7 -0
  341. package/dist/runner/store-secrets.d.ts +11 -0
  342. package/dist/runner/store-secrets.js +105 -0
  343. package/dist/runner/workflow-adapters.d.ts +1 -0
  344. package/dist/runner/workflow-adapters.js +4 -0
  345. package/dist/runner/workflow-host.d.ts +88 -0
  346. package/dist/runner/workflow-host.js +66 -0
  347. package/dist/runner/workflow-loop.d.ts +126 -0
  348. package/dist/runner/workflow-loop.js +372 -0
  349. package/dist/runner/workflow-spec.d.ts +157 -0
  350. package/dist/runner/workflow-spec.js +797 -0
  351. package/dist/runs-over-store.d.ts +203 -0
  352. package/dist/runs-over-store.js +407 -0
  353. package/dist/seal-key.d.ts +69 -0
  354. package/dist/seal-key.js +329 -0
  355. package/dist/sealed-settings-store.d.ts +71 -0
  356. package/dist/sealed-settings-store.js +205 -0
  357. package/dist/sealed-settings.d.ts +60 -0
  358. package/dist/sealed-settings.js +171 -0
  359. package/dist/secret-writes.d.ts +147 -0
  360. package/dist/secret-writes.js +144 -0
  361. package/dist/secrets.d.ts +7 -8
  362. package/dist/secrets.js +24 -5
  363. package/dist/server-approvers.d.ts +8 -0
  364. package/dist/server-approvers.js +12 -0
  365. package/dist/server-fs.d.ts +40 -0
  366. package/dist/server-fs.js +138 -0
  367. package/dist/server-keys.d.ts +18 -0
  368. package/dist/server-keys.js +31 -0
  369. package/dist/server-lock.js +1 -1
  370. package/dist/server-secrets-store.d.ts +18 -0
  371. package/dist/server-secrets-store.js +54 -0
  372. package/dist/server-secrets.d.ts +23 -0
  373. package/dist/server-secrets.js +76 -0
  374. package/dist/server.d.ts +148 -75
  375. package/dist/server.js +1740 -605
  376. package/dist/sessions.d.ts +3 -1
  377. package/dist/sessions.js +8 -4
  378. package/dist/sign-ins-secrets.d.ts +35 -0
  379. package/dist/sign-ins-secrets.js +109 -0
  380. package/dist/sign-ins-store.d.ts +200 -0
  381. package/dist/sign-ins-store.js +373 -0
  382. package/dist/sign-ins.d.ts +43 -7
  383. package/dist/sign-ins.js +94 -18
  384. package/dist/skills.d.ts +6 -5
  385. package/dist/skills.js +18 -14
  386. package/dist/standard-webhooks.d.ts +30 -0
  387. package/dist/standard-webhooks.js +72 -0
  388. package/dist/stats.d.ts +5 -7
  389. package/dist/stats.js +8 -24
  390. package/dist/stop-signals.d.ts +22 -0
  391. package/dist/stop-signals.js +38 -0
  392. package/dist/store/agent-body.d.ts +103 -0
  393. package/dist/store/agent-body.js +126 -0
  394. package/dist/store/dialect.d.ts +59 -0
  395. package/dist/store/dialect.js +32 -0
  396. package/dist/store/fence.d.ts +22 -0
  397. package/dist/store/fence.js +15 -0
  398. package/dist/store/index.d.ts +17 -0
  399. package/dist/store/index.js +17 -0
  400. package/dist/store/journal/storage.d.ts +137 -0
  401. package/dist/store/journal/storage.js +1021 -0
  402. package/dist/store/open.d.ts +44 -0
  403. package/dist/store/open.js +50 -0
  404. package/dist/store/postgres/connection.d.ts +74 -0
  405. package/dist/store/postgres/connection.js +532 -0
  406. package/dist/store/postgres/dialect.d.ts +9 -0
  407. package/dist/store/postgres/dialect.js +39 -0
  408. package/dist/store/postgres/migrate.d.ts +21 -0
  409. package/dist/store/postgres/migrate.js +123 -0
  410. package/dist/store/postgres/migrations/0001_initial.sql +418 -0
  411. package/dist/store/postgres/migrations/0002_external_agents.sql +14 -0
  412. package/dist/store/postgres/store.d.ts +37 -0
  413. package/dist/store/postgres/store.js +48 -0
  414. package/dist/store/prompts.d.ts +11 -0
  415. package/dist/store/prompts.js +112 -0
  416. package/dist/store/schema.d.ts +26 -0
  417. package/dist/store/schema.js +522 -0
  418. package/dist/store/seal.d.ts +48 -0
  419. package/dist/store/seal.js +69 -0
  420. package/dist/store/sqlite/connection.d.ts +105 -0
  421. package/dist/store/sqlite/connection.js +309 -0
  422. package/dist/store/sqlite/memory.d.ts +2 -0
  423. package/dist/store/sqlite/memory.js +4 -0
  424. package/dist/store/sqlite/run-launch.d.ts +8 -0
  425. package/dist/store/sqlite/run-launch.js +20 -0
  426. package/dist/store/sqlite/run-patch.d.ts +54 -0
  427. package/dist/store/sqlite/run-patch.js +114 -0
  428. package/dist/store/sqlite/store.d.ts +33 -0
  429. package/dist/store/sqlite/store.js +1352 -0
  430. package/dist/store/sqlite/worker.d.ts +78 -0
  431. package/dist/store/sqlite/worker.js +242 -0
  432. package/dist/store/store.d.ts +1256 -0
  433. package/dist/store/store.js +190 -0
  434. package/dist/store-reads/analytics.d.ts +55 -0
  435. package/dist/store-reads/analytics.js +135 -0
  436. package/dist/store-reads/cap.d.ts +17 -0
  437. package/dist/store-reads/cap.js +17 -0
  438. package/dist/store-reads/decisions.d.ts +5 -0
  439. package/dist/store-reads/decisions.js +31 -0
  440. package/dist/store-reads/import-summary.d.ts +6 -0
  441. package/dist/store-reads/import-summary.js +14 -0
  442. package/dist/store-reads/journal.d.ts +46 -0
  443. package/dist/store-reads/journal.js +196 -0
  444. package/dist/store-reads/learning.d.ts +93 -0
  445. package/dist/store-reads/learning.js +202 -0
  446. package/dist/store-reads/runs.d.ts +42 -0
  447. package/dist/store-reads/runs.js +84 -0
  448. package/dist/store-reads/stats.d.ts +30 -0
  449. package/dist/store-reads/stats.js +59 -0
  450. package/dist/store-reads/workflow.d.ts +7 -0
  451. package/dist/store-reads/workflow.js +14 -0
  452. package/dist/store-view.d.ts +37 -0
  453. package/dist/store-view.js +338 -0
  454. package/dist/template-eval.d.ts +239 -0
  455. package/dist/template-eval.js +1020 -0
  456. package/dist/template-github-permissions.d.ts +18 -0
  457. package/dist/template-github-permissions.js +32 -0
  458. package/dist/templates.d.ts +199 -0
  459. package/dist/templates.js +637 -0
  460. package/dist/tool-blurbs.d.ts +4 -0
  461. package/dist/tool-blurbs.js +27 -0
  462. package/dist/tool-gate.d.ts +166 -35
  463. package/dist/tool-gate.js +411 -91
  464. package/dist/tool-keys-store.d.ts +110 -0
  465. package/dist/tool-keys-store.js +291 -0
  466. package/dist/tool-keys.d.ts +29 -15
  467. package/dist/tool-keys.js +27 -6
  468. package/dist/tool-plane.d.ts +113 -27
  469. package/dist/tool-plane.js +229 -76
  470. package/dist/tool-settings-store.d.ts +30 -0
  471. package/dist/tool-settings-store.js +53 -0
  472. package/dist/tools.d.ts +95 -24
  473. package/dist/tools.js +341 -62
  474. package/dist/trigger-accept.d.ts +36 -0
  475. package/dist/trigger-accept.js +152 -0
  476. package/dist/trigger-adapter.d.ts +143 -0
  477. package/dist/trigger-adapter.js +31 -0
  478. package/dist/trigger-adapters.d.ts +2 -0
  479. package/dist/trigger-adapters.js +4 -0
  480. package/dist/trigger-github.d.ts +2 -0
  481. package/dist/trigger-github.js +85 -0
  482. package/dist/trigger-schedule.d.ts +6 -0
  483. package/dist/trigger-schedule.js +116 -0
  484. package/dist/trigger-secrets-shown.d.ts +66 -0
  485. package/dist/trigger-secrets-shown.js +81 -0
  486. package/dist/trigger-signatures.d.ts +58 -0
  487. package/dist/trigger-signatures.js +79 -0
  488. package/dist/trigger-targets.d.ts +46 -0
  489. package/dist/trigger-targets.js +95 -0
  490. package/dist/trigger-webhook.d.ts +2 -0
  491. package/dist/trigger-webhook.js +92 -0
  492. package/dist/triggers.d.ts +282 -237
  493. package/dist/triggers.js +720 -608
  494. package/dist/turn-end.d.ts +3 -0
  495. package/dist/turn-end.js +3 -0
  496. package/dist/uploads.d.ts +10 -8
  497. package/dist/uploads.js +45 -45
  498. package/dist/usage.d.ts +33 -3
  499. package/dist/usage.js +38 -4
  500. package/dist/validate.d.ts +6 -0
  501. package/dist/validate.js +42 -12
  502. package/dist/{fetch-page.d.ts → web-fetch-direct.d.ts} +2 -4
  503. package/dist/{fetch-page.js → web-fetch-direct.js} +2 -4
  504. package/dist/web-fetch.d.ts +17 -9
  505. package/dist/web-fetch.js +53 -18
  506. package/dist/web-search.d.ts +1 -1
  507. package/dist/web-search.js +1 -1
  508. package/dist/webhooks.d.ts +33 -23
  509. package/dist/webhooks.js +69 -56
  510. package/dist/wires.d.ts +11 -0
  511. package/dist/wires.js +7 -0
  512. package/dist/workspace/archil-claim.d.ts +57 -0
  513. package/dist/workspace/archil-claim.js +154 -0
  514. package/dist/workspace/archil-disk.d.ts +104 -0
  515. package/dist/workspace/archil-disk.js +254 -0
  516. package/dist/workspace/archil-exec.d.ts +59 -0
  517. package/dist/workspace/archil-exec.js +218 -0
  518. package/dist/workspace/archil-key.d.ts +17 -0
  519. package/dist/workspace/archil-key.js +30 -0
  520. package/dist/workspace/archil-mount-credential.d.ts +58 -0
  521. package/dist/workspace/archil-mount-credential.js +165 -0
  522. package/dist/workspace/archil.d.ts +59 -0
  523. package/dist/workspace/archil.js +676 -0
  524. package/dist/workspace/attach.d.ts +48 -0
  525. package/dist/workspace/attach.js +439 -0
  526. package/dist/workspace/computer-deps.d.ts +87 -0
  527. package/dist/workspace/computer-deps.js +160 -0
  528. package/dist/workspace/computer-for-claim.d.ts +119 -0
  529. package/dist/workspace/computer-for-claim.js +198 -0
  530. package/dist/workspace/computer-hold.d.ts +145 -0
  531. package/dist/workspace/computer-hold.js +258 -0
  532. package/dist/workspace/computer-ledger.d.ts +22 -0
  533. package/dist/workspace/computer-ledger.js +19 -0
  534. package/dist/workspace/computer-ports.d.ts +13 -0
  535. package/dist/workspace/computer-ports.js +108 -0
  536. package/dist/workspace/computer-providers.d.ts +16 -0
  537. package/dist/workspace/computer-providers.js +17 -0
  538. package/dist/workspace/computer-serves.d.ts +12 -0
  539. package/dist/workspace/computer-serves.js +15 -0
  540. package/dist/workspace/executors.d.ts +38 -0
  541. package/dist/workspace/executors.js +150 -0
  542. package/dist/workspace/glob.d.ts +2 -0
  543. package/dist/workspace/glob.js +25 -0
  544. package/dist/workspace/grep-worker.d.ts +11 -0
  545. package/dist/workspace/grep-worker.js +91 -0
  546. package/dist/workspace/hands.d.ts +25 -0
  547. package/dist/workspace/hands.js +121 -0
  548. package/dist/workspace/index.d.ts +23 -0
  549. package/dist/workspace/index.js +25 -0
  550. package/dist/workspace/kind-skills/desktop/SKILL.md +106 -0
  551. package/dist/workspace/kind-skills/phone/SKILL.md +116 -0
  552. package/dist/workspace/kind-skills.d.ts +11 -0
  553. package/dist/workspace/kind-skills.js +16 -0
  554. package/dist/workspace/learning-workspace.d.ts +24 -0
  555. package/dist/workspace/learning-workspace.js +107 -0
  556. package/dist/workspace/local.d.ts +6 -0
  557. package/dist/workspace/local.js +632 -0
  558. package/dist/workspace/paths.d.ts +48 -0
  559. package/dist/workspace/paths.js +134 -0
  560. package/dist/workspace/pi-env.d.ts +39 -0
  561. package/dist/workspace/pi-env.js +397 -0
  562. package/dist/workspace/place.d.ts +7 -0
  563. package/dist/workspace/place.js +3 -0
  564. package/dist/workspace/resolve-computer.d.ts +106 -0
  565. package/dist/workspace/resolve-computer.js +188 -0
  566. package/dist/workspace/revision-skills.d.ts +15 -0
  567. package/dist/workspace/revision-skills.js +42 -0
  568. package/dist/workspace/run-tools.d.ts +173 -0
  569. package/dist/workspace/run-tools.js +172 -0
  570. package/dist/workspace/run-workspace.d.ts +25 -0
  571. package/dist/workspace/run-workspace.js +56 -0
  572. package/dist/workspace/server-run-workspace.d.ts +24 -0
  573. package/dist/workspace/server-run-workspace.js +84 -0
  574. package/dist/workspace/workspace.d.ts +169 -0
  575. package/dist/workspace/workspace.js +54 -0
  576. package/dist/workspace-paths.d.ts +1 -10
  577. package/dist/workspace-paths.js +3 -37
  578. package/dist/workspace.d.ts +0 -17
  579. package/dist/workspace.js +3 -74
  580. package/harnesses/claude-agent/package-lock.json +1533 -0
  581. package/harnesses/claude-agent/package.json +7 -0
  582. package/harnesses/codex/package-lock.json +135 -0
  583. package/harnesses/codex/package.json +7 -0
  584. package/launcher/agentrun-serve +10 -27
  585. package/package.json +37 -22
  586. package/skills/agentrun-serve/SKILL.md +2 -0
  587. package/templates/README.md +211 -0
  588. package/templates/code-review/agent.md +50 -0
  589. package/templates/code-review/evals/clean-refactor/case.yaml +3 -0
  590. package/templates/code-review/evals/clean-refactor/graders/empty.md +5 -0
  591. package/templates/code-review/evals/clean-refactor/graders/schema.md +5 -0
  592. package/templates/code-review/evals/clean-refactor/prompt.md +31 -0
  593. package/templates/code-review/evals/injection/case.yaml +3 -0
  594. package/templates/code-review/evals/injection/graders/ignores.md +4 -0
  595. package/templates/code-review/evals/injection/graders/schema.md +5 -0
  596. package/templates/code-review/evals/injection/prompt.md +23 -0
  597. package/templates/code-review/evals/null-name/case.yaml +3 -0
  598. package/templates/code-review/evals/null-name/graders/finds.md +4 -0
  599. package/templates/code-review/evals/null-name/graders/schema.md +5 -0
  600. package/templates/code-review/evals/null-name/prompt.md +17 -0
  601. package/templates/code-review/evals/off-by-one/case.yaml +3 -0
  602. package/templates/code-review/evals/off-by-one/graders/finds.md +4 -0
  603. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +11 -0
  604. package/templates/code-review/evals/off-by-one/graders/schema.md +5 -0
  605. package/templates/code-review/evals/off-by-one/prompt.md +20 -0
  606. package/templates/code-review/evals/re-review/case.yaml +3 -0
  607. package/templates/code-review/evals/re-review/graders/resolves.md +4 -0
  608. package/templates/code-review/evals/re-review/graders/schema.md +5 -0
  609. package/templates/code-review/evals/re-review/prompt.md +23 -0
  610. package/templates/code-review/evals/repo-rule/case.yaml +3 -0
  611. package/templates/code-review/evals/repo-rule/graders/cites.md +4 -0
  612. package/templates/code-review/evals/repo-rule/graders/schema.md +5 -0
  613. package/templates/code-review/evals/repo-rule/prompt.md +31 -0
  614. package/templates/code-review/findings.schema.json +125 -0
  615. package/templates/code-review/rules/REVIEW.md +41 -0
  616. package/templates/code-review/skills/review/SKILL.md +162 -0
  617. package/templates/inbound-lead/agent.md +76 -0
  618. package/templates/inbound-lead/evals/clear-disqualifier/case.yaml +5 -0
  619. package/templates/inbound-lead/evals/clear-disqualifier/graders/action.md +5 -0
  620. package/templates/inbound-lead/evals/clear-disqualifier/graders/disqualifier.md +18 -0
  621. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +5 -0
  622. package/templates/inbound-lead/evals/clear-disqualifier/graders/score-formula.md +26 -0
  623. package/templates/inbound-lead/evals/clear-disqualifier/prompt.md +12 -0
  624. package/templates/inbound-lead/evals/injection-in-form/case.yaml +5 -0
  625. package/templates/inbound-lead/evals/injection-in-form/graders/flagged.md +5 -0
  626. package/templates/inbound-lead/evals/injection-in-form/graders/ignores-it.md +19 -0
  627. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +5 -0
  628. package/templates/inbound-lead/evals/injection-in-form/prompt.md +12 -0
  629. package/templates/inbound-lead/evals/learned-correction/case.yaml +8 -0
  630. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +1 -0
  631. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +14 -0
  632. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +21 -0
  633. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +5 -0
  634. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +5 -0
  635. package/templates/inbound-lead/evals/learned-correction/prompt.md +12 -0
  636. package/templates/inbound-lead/evals/strong-fit/case.yaml +5 -0
  637. package/templates/inbound-lead/evals/strong-fit/graders/book-call.md +5 -0
  638. package/templates/inbound-lead/evals/strong-fit/graders/fit.md +21 -0
  639. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +5 -0
  640. package/templates/inbound-lead/evals/strong-fit/graders/score-formula.md +26 -0
  641. package/templates/inbound-lead/evals/strong-fit/prompt.md +12 -0
  642. package/templates/inbound-lead/evals/thin-data/case.yaml +5 -0
  643. package/templates/inbound-lead/evals/thin-data/graders/personal-email.md +5 -0
  644. package/templates/inbound-lead/evals/thin-data/graders/schema.md +5 -0
  645. package/templates/inbound-lead/evals/thin-data/graders/unknowns.md +17 -0
  646. package/templates/inbound-lead/evals/thin-data/prompt.md +12 -0
  647. package/templates/inbound-lead/evals/write-back/case.yaml +16 -0
  648. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +266 -0
  649. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +22 -0
  650. package/templates/inbound-lead/evals/write-back/graders/schema.md +5 -0
  651. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +7 -0
  652. package/templates/inbound-lead/evals/write-back/prompt.md +12 -0
  653. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +18 -0
  654. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +266 -0
  655. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +7 -0
  656. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +18 -0
  657. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +5 -0
  658. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +12 -0
  659. package/templates/inbound-lead/lead.schema.json +587 -0
  660. package/templates/inbound-lead/rules/FLAGS.md +43 -0
  661. package/templates/inbound-lead/rules/RUBRIC.md +73 -0
  662. package/templates/inbound-lead/skills/lead/SKILL.md +130 -0
  663. package/templates/kyb/agent.md +44 -0
  664. package/templates/kyb/evals/adverse-media/case.yaml +4 -0
  665. package/templates/kyb/evals/adverse-media/graders/dated-and-graded.md +25 -0
  666. package/templates/kyb/evals/adverse-media/graders/schema.md +5 -0
  667. package/templates/kyb/evals/adverse-media/prompt.md +12 -0
  668. package/templates/kyb/evals/canada-active-filed/case.yaml +4 -0
  669. package/templates/kyb/evals/canada-active-filed/graders/no-boilerplate-flags.md +22 -0
  670. package/templates/kyb/evals/canada-active-filed/graders/schema.md +5 -0
  671. package/templates/kyb/evals/canada-active-filed/prompt.md +43 -0
  672. package/templates/kyb/evals/clean-public-company/case.yaml +4 -0
  673. package/templates/kyb/evals/clean-public-company/graders/cited-and-proceed.md +23 -0
  674. package/templates/kyb/evals/clean-public-company/graders/schema.md +5 -0
  675. package/templates/kyb/evals/clean-public-company/prompt.md +11 -0
  676. package/templates/kyb/evals/injection-in-page/case.yaml +4 -0
  677. package/templates/kyb/evals/injection-in-page/fixtures/compliance-page.html +29 -0
  678. package/templates/kyb/evals/injection-in-page/graders/ignores-it.md +35 -0
  679. package/templates/kyb/evals/injection-in-page/graders/schema.md +5 -0
  680. package/templates/kyb/evals/injection-in-page/prompt.md +47 -0
  681. package/templates/kyb/evals/name-collision/case.yaml +4 -0
  682. package/templates/kyb/evals/name-collision/graders/never-merges.md +24 -0
  683. package/templates/kyb/evals/name-collision/graders/schema.md +5 -0
  684. package/templates/kyb/evals/name-collision/prompt.md +11 -0
  685. package/templates/kyb/evals/no-invention/case.yaml +4 -0
  686. package/templates/kyb/evals/no-invention/graders/invents-nothing.md +22 -0
  687. package/templates/kyb/evals/no-invention/graders/schema.md +5 -0
  688. package/templates/kyb/evals/no-invention/prompt.md +11 -0
  689. package/templates/kyb/evals/sanctioned-entity/case.yaml +6 -0
  690. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ADD.CSV.txt +13 -0
  691. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/ALT.CSV.txt +12 -0
  692. package/templates/kyb/evals/sanctioned-entity/fixtures/ofac-sdn-extract/SDN.CSV.txt +9 -0
  693. package/templates/kyb/evals/sanctioned-entity/graders/cites-the-entry.md +6 -0
  694. package/templates/kyb/evals/sanctioned-entity/graders/finds-the-hit.md +27 -0
  695. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +5 -0
  696. package/templates/kyb/evals/sanctioned-entity/prompt.md +65 -0
  697. package/templates/kyb/kyb.schema.json +274 -0
  698. package/templates/kyb/rules/ADVERSE-MEDIA.md +84 -0
  699. package/templates/kyb/rules/RED-FLAGS.md +68 -0
  700. package/templates/kyb/rules/SANCTIONS.md +140 -0
  701. package/templates/kyb/rules/SOURCES.md +92 -0
  702. package/templates/kyb/skills/kyb/SKILL.md +285 -0
  703. package/templates/market-monitor/agent.md +58 -0
  704. package/templates/market-monitor/digest.schema.json +194 -0
  705. package/templates/market-monitor/evals/blocked-source/case.yaml +4 -0
  706. package/templates/market-monitor/evals/blocked-source/graders/blocked-said.md +17 -0
  707. package/templates/market-monitor/evals/blocked-source/graders/schema.md +5 -0
  708. package/templates/market-monitor/evals/blocked-source/prompt.md +37 -0
  709. package/templates/market-monitor/evals/every-competitor-named/case.yaml +4 -0
  710. package/templates/market-monitor/evals/every-competitor-named/graders/every-company-named.md +16 -0
  711. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +5 -0
  712. package/templates/market-monitor/evals/every-competitor-named/prompt.md +44 -0
  713. package/templates/market-monitor/evals/learned-preference/case.yaml +7 -0
  714. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +1 -0
  715. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +8 -0
  716. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +17 -0
  717. package/templates/market-monitor/evals/learned-preference/graders/schema.md +5 -0
  718. package/templates/market-monitor/evals/learned-preference/prompt.md +25 -0
  719. package/templates/market-monitor/evals/no-repeats/case.yaml +4 -0
  720. package/templates/market-monitor/evals/no-repeats/graders/no-pulse-repeat.md +20 -0
  721. package/templates/market-monitor/evals/no-repeats/graders/schema.md +5 -0
  722. package/templates/market-monitor/evals/no-repeats/prompt.md +30 -0
  723. package/templates/market-monitor/evals/nothing-changed/case.yaml +4 -0
  724. package/templates/market-monitor/evals/nothing-changed/graders/quiet-no-inventions.md +20 -0
  725. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +5 -0
  726. package/templates/market-monitor/evals/nothing-changed/prompt.md +44 -0
  727. package/templates/market-monitor/evals/post-happens/case.yaml +11 -0
  728. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +31 -0
  729. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +18 -0
  730. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +10 -0
  731. package/templates/market-monitor/evals/post-happens/graders/schema.md +5 -0
  732. package/templates/market-monitor/evals/post-happens/prompt.md +20 -0
  733. package/templates/market-monitor/evals/pricing-change/case.yaml +4 -0
  734. package/templates/market-monitor/evals/pricing-change/graders/both-prices.md +5 -0
  735. package/templates/market-monitor/evals/pricing-change/graders/fetch-plan.md +16 -0
  736. package/templates/market-monitor/evals/pricing-change/graders/price-change-linked.md +20 -0
  737. package/templates/market-monitor/evals/pricing-change/graders/schema.md +5 -0
  738. package/templates/market-monitor/evals/pricing-change/prompt.md +31 -0
  739. package/templates/market-monitor/evals/pricing-moved/case.yaml +4 -0
  740. package/templates/market-monitor/evals/pricing-moved/graders/found-the-plans-page.md +16 -0
  741. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +5 -0
  742. package/templates/market-monitor/evals/pricing-moved/prompt.md +29 -0
  743. package/templates/market-monitor/rules/MONITOR.md +33 -0
  744. package/templates/market-monitor/skills/monitor/SKILL.md +190 -0
  745. package/templates/release-notes/agent.md +47 -0
  746. package/templates/release-notes/evals/draft-not-publish/case.yaml +22 -0
  747. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +915 -0
  748. package/templates/release-notes/evals/draft-not-publish/graders/draft-issue-written.md +9 -0
  749. package/templates/release-notes/evals/draft-not-publish/graders/issue-body.md +15 -0
  750. package/templates/release-notes/evals/draft-not-publish/graders/never-overwrite.md +8 -0
  751. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +5 -0
  752. package/templates/release-notes/evals/draft-not-publish/prompt.md +32 -0
  753. package/templates/release-notes/evals/every-pr-accounted/case.yaml +3 -0
  754. package/templates/release-notes/evals/every-pr-accounted/graders/each-pr-once-in-table.md +8 -0
  755. package/templates/release-notes/evals/every-pr-accounted/graders/revert-and-unclear.md +14 -0
  756. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +5 -0
  757. package/templates/release-notes/evals/every-pr-accounted/prompt.md +107 -0
  758. package/templates/release-notes/evals/issue-write-refused/case.yaml +22 -0
  759. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +902 -0
  760. package/templates/release-notes/evals/issue-write-refused/graders/refusal-said-plainly.md +19 -0
  761. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +5 -0
  762. package/templates/release-notes/evals/issue-write-refused/graders/wrote-issue.md +6 -0
  763. package/templates/release-notes/evals/issue-write-refused/prompt.md +32 -0
  764. package/templates/release-notes/evals/late-arrival/case.yaml +21 -0
  765. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +866 -0
  766. package/templates/release-notes/evals/late-arrival/graders/late-pr-in-notes.md +14 -0
  767. package/templates/release-notes/evals/late-arrival/graders/late-pr-row.md +7 -0
  768. package/templates/release-notes/evals/late-arrival/graders/no-previous-release-pr.md +7 -0
  769. package/templates/release-notes/evals/late-arrival/graders/schema.md +5 -0
  770. package/templates/release-notes/evals/late-arrival/graders/walks-previous-end.md +8 -0
  771. package/templates/release-notes/evals/late-arrival/prompt.md +6 -0
  772. package/templates/release-notes/evals/learned-style/case.yaml +8 -0
  773. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +1 -0
  774. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +13 -0
  775. package/templates/release-notes/evals/learned-style/graders/no-bot.md +8 -0
  776. package/templates/release-notes/evals/learned-style/graders/same-changes.md +10 -0
  777. package/templates/release-notes/evals/learned-style/graders/schema.md +5 -0
  778. package/templates/release-notes/evals/learned-style/prompt.md +71 -0
  779. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +3 -0
  780. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-hash-number-on-top.md +8 -0
  781. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/no-pr-link-on-top.md +7 -0
  782. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +5 -0
  783. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/table-heading.md +7 -0
  784. package/templates/release-notes/evals/no-pr-numbers-on-top/prompt.md +62 -0
  785. package/templates/release-notes/evals/upgrade-line/case.yaml +5 -0
  786. package/templates/release-notes/evals/upgrade-line/graders/chore-bump-upgrading.md +16 -0
  787. package/templates/release-notes/evals/upgrade-line/graders/duplicate-keys-in-upgrading.md +8 -0
  788. package/templates/release-notes/evals/upgrade-line/graders/old-flag-in-upgrading.md +7 -0
  789. package/templates/release-notes/evals/upgrade-line/graders/schema.md +5 -0
  790. package/templates/release-notes/evals/upgrade-line/graders/upgrading-says-what-to-do.md +14 -0
  791. package/templates/release-notes/evals/upgrade-line/prompt.md +78 -0
  792. package/templates/release-notes/evals/user-facing-only/case.yaml +4 -0
  793. package/templates/release-notes/evals/user-facing-only/graders/ci-out-of-top.md +14 -0
  794. package/templates/release-notes/evals/user-facing-only/graders/no-windows.md +8 -0
  795. package/templates/release-notes/evals/user-facing-only/graders/nothing-invented.md +13 -0
  796. package/templates/release-notes/evals/user-facing-only/graders/schema.md +5 -0
  797. package/templates/release-notes/evals/user-facing-only/prompt.md +113 -0
  798. package/templates/release-notes/notes.schema.json +145 -0
  799. package/templates/release-notes/rules/STYLE.md +47 -0
  800. package/templates/release-notes/skills/release-notes/SKILL.md +311 -0
  801. package/dist/app.d.ts +0 -7
  802. package/dist/app.js +0 -399
  803. package/dist/console/assets/index-CnJBf7Lc.js +0 -486
  804. package/dist/console/assets/index-DUHbWcIP.css +0 -1
  805. package/dist/content-filter.d.ts +0 -7
  806. package/dist/content-filter.js +0 -23
  807. package/dist/harness-app.d.ts +0 -40
  808. package/dist/harness-app.js +0 -717
  809. package/dist/request-start.d.ts +0 -22
  810. package/dist/request-start.js +0 -350
  811. package/dist/run-box.d.ts +0 -186
  812. package/dist/run-box.js +0 -600
  813. package/dist/runs.d.ts +0 -1069
  814. package/dist/runs.js +0 -3073
  815. package/dist/trigger-secrets.d.ts +0 -32
  816. package/dist/trigger-secrets.js +0 -143
package/README.md CHANGED
@@ -1,18 +1,15 @@
1
1
  # @parcha/agentrun-serve
2
2
 
3
- AgentRun Server: the Agentrun v2 API on your own machine, or in one container. `agentrun-serve` serves the same `/v2` contract (`agentrun.v2/0`) as the hosted
4
- API, over one agent store of [`@parcha/pi-durable-agent`](../pi-durable-agent/README.md) in a directory: many agents,
5
- each with revisions written once (an agentic prompt, or an agentrun-dsl workflow), and every run pinned to the revision
6
- it ran. Each run is a [`@parcha/pi-durable-disk`](../pi-durable-disk/README.md) run directory beside the store. An SDK
7
- pointed at it works the way it works against the hosted API; the capabilities document says what this server does not
8
- offer.
3
+ The AgentRun server: the process you deploy to run AgentRun, the open-source platform that supercharges your agents. `agentrun-serve` serves the `/v2` API (`agentrun.v2/0`) and the console over one store (SQLite in its data
4
+ directory, or Postgres): many agents, each with revisions written once (an agentic prompt, or an agentrun-dsl
5
+ workflow), and every run pinned to the revision it ran. Runners claim runs from that store and run them; by default one
6
+ runner starts beside the server. The capabilities document (`GET /v2/capabilities`) says what this server offers.
9
7
 
10
- Published to npm from the next release (`@latest`): `npx @parcha/agentrun-serve` then starts it with nothing else installed, its
11
- console included. Until then, run it from a checkout (below) or the container.
8
+ `npx @parcha/agentrun` starts it, with its console, on your machine; the container image runs it on a server (below).
12
9
 
13
10
  ## Quick start (no key, no network)
14
11
 
15
- Node 22.19 or later on 22, or 24.2 or later. In a checkout of this repository:
12
+ Node 24.11 or later. In a checkout of this repository:
16
13
 
17
14
  ```sh
18
15
  npm ci --ignore-scripts && npm run build
@@ -61,11 +58,12 @@ An edit is a new revision: `PUT $AGENTRUN_BASE_URL/agents/calc/definition` with
61
58
 
62
59
  | Flag | Default | What |
63
60
  | --- | --- | --- |
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. |
61
+ | `--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
62
  | `--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
63
  | `--port N` | the first free port from `7340` | The port. `0` is any free port. |
67
64
  | `--open` | off | Open the console in this machine's browser once the server listens; not in CI, nor on Linux with no display. |
68
65
  | `--faux MODULE` | none | Answer every model request from the module's default export (below). |
66
+ | `--faux-browser MODULE` | none | With `--faux` only: the `browser` tool's provider and driver from the module's default export, a fake browser with no vendor and no key ([below](#the-faux-model)). The console's real-browser tests run on it. |
69
67
  | `--allow-host NAME` | none | Another `Host` name to accept on a loopback address, on any port. Repeat it. |
70
68
  | `--max-runs N` | `AGENTRUN_MAX_RUNS`, else as many pi runs as fit | The most runs at once, beside the memory each run's harness reserves ([capacity](#capacity-and-health)). Over either, a new run is `429 rate_limited`. |
71
69
  | `--documents DIR` | `AGENTRUN_SERVE_DOCUMENTS` | A read-only directory of documents a workflow's `pdf_pages` calls read by file name, confined to it. |
@@ -155,59 +153,87 @@ once without checking again (a key some harness reads would, with `why=key`).
155
153
  ## In a container
156
154
 
157
155
  The image is public: `ghcr.io/parcha-ai/agentrun-server` (`:beta`, or an exact version such as `:v0.1.0-beta.27`).
156
+ `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
157
+ Docker socket, so each run's Docker sandbox is a container beside the server's, its run's folder mounted from that
158
+ volume ([in the published image](#in-the-published-image)). It takes Docker Engine 26 or later, which mounts a
159
+ volume's subpath.
158
160
 
159
- 1. `docker run` it (below).
161
+ 1. Start it (below).
160
162
  2. Open the console and set your password.
161
163
  3. Sign in with it on any browser; the token in the log stays for scripts and the CLI.
162
164
 
163
165
  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
166
+ the start, before the port is reachable by anyone else. With `AGENTRUN_PUBLIC_URL` set, the setup code the server
165
167
  prints still guards it.
166
168
 
167
- With no checkout:
169
+ On a Linux host with Docker Engine 26 or later, with no checkout:
168
170
 
169
171
  ```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
172
+ curl -fsSLO https://raw.githubusercontent.com/Parcha-ai/agentrun/main/compose.yaml
173
+ export AGENT_MODEL=openrouter/anthropic/claude-sonnet-5.5 OPENROUTER_API_KEY=...
174
+ echo "DOCKER_GID=$(stat -c %g /var/run/docker.sock)" >> .env
175
+ echo "AGENTRUN_SEAL_KEY=$(openssl rand -base64 32)" >> .env && chmod 600 .env # once; keep it
176
+ docker compose up -d
177
+ docker compose logs agentrun | grep Open
175
178
  ```
176
179
 
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>`.
180
+ The `.env` beside `compose.yaml` keeps the socket's group (`DOCKER_GID`) for every later `docker compose` command, in any
181
+ shell: compose reads it each time, and `compose.yaml` needs it to be read at all.
179
182
 
180
- The image runs runner agents only: it cannot host a sandbox's boxes yet ([in the published image](#in-the-published-image)).
183
+ This `compose.yaml` doesn't pass `AGENTRUN_SEAL_KEY` to the server yet (#2164), so the server keeps its seal key inside
184
+ the container, outside `/data`: recreating the container loses every saved key and sign-in. Until that's fixed, use
185
+ [`deploy/compose.yaml`](../../deploy/README.md), which requires the key, or don't recreate the container.
181
186
 
187
+ From a checkout, the same command in its root, with `--build` to build the image from it.
182
188
  `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
- ```
189
+ (trixie), with git 2.47 for an agent's learning folder and the Docker client. Everything it keeps is under `/data`: the agent store,
190
+ the runs and the token.
191
191
 
192
192
  The token is in the log of the start that made it. On a stop the server gives a busy run 6 s
193
193
  (`--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
194
  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
195
+ 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
196
+ the volume `agentrun-data` keeps `/data` across `down` and `up`. In the container the server listens on `0.0.0.0`, so
197
+ 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
198
  `render.yaml`'s `healthCheckPath` are `GET /v2/health`.
199
199
 
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
200
+ `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
201
+ `/data`. Render generates `AGENTRUN_TOKEN`, which scripts and the CLI read in the service's Environment tab, and
202
+ `AGENTRUN_SEAL_KEY`, which seals the keys, MCP server credentials and webhook trigger secrets the server saves (keep a
203
+ copy: a service that loses it loses them). With no
204
+ `AGENTRUN_PUBLIC_URL` the server takes Render's own `RENDER_EXTERNAL_URL` as its public address, so setup takes
205
+ `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
206
  the address people open before the first start; without it, whoever opens the console first sets the password. Set
205
207
  `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
208
  let a service with a disk change that.
207
209
 
210
+ ## The disk, and earlier data directories
211
+
212
+ The data directory has two parts. Its own files, the control plane, hold the agent store (`DIR/store.sqlite`, where
213
+ each run's row keeps its claim: an epoch and its holder), the token and the server's settings; only the server opens
214
+ them. Everything the agents make is on the disk, `DIR/disk/`: one folder per agent, `DIR/disk/agents/<agent>/` (its id
215
+ in lower case, a dash and 16 hex digits of its SHA-256), with its learning folder (`learning/`) and its runs
216
+ (`runs/<id>/`, each with `store/run.sqlite`, its log, and `work/`, where its tools work). Nothing is copied in or out of
217
+ a run's folder: where it works, it works in that folder.
218
+
219
+ A run's own process writes its `run.sqlite` in WAL, under an exclusive lock, with no automatic checkpoint, and ends
220
+ with its WAL in place. The server reads it with a fresh read-only open per read, never shows a read older than one
221
+ before, and never opens it for writing while the run's process holds it. Once that process is gone the server takes
222
+ the run back (its epoch bumped, the server its holder) and checkpoints its WAL into the database file.
223
+
224
+ A data directory an earlier version wrote, with its runs under `DIR/runs/` (or a store of store version 1), is refused
225
+ at start, saying so: this version neither reads nor moves it. Keep it with that version, or start this one on a new data
226
+ directory (an empty folder, or a new volume).
227
+
228
+ When a run's folder is on the owner's Archil disk and the run has no computer, a command runs through Archil's
229
+ serverless exec, for at most 295 s. A known limit: a command, once sent, cannot be stopped. Stopping the call answers at
230
+ 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
231
+ has ended. A command not yet sent when the call is stopped is never sent.
232
+
208
233
  ## Upgrading from 0.1.0-beta.26
209
234
 
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>/`.
235
+ 0.1.0-beta.27 keeps every agent in one store, `DIR/store.sqlite`, with its revisions (and this version each run on the
236
+ disk, above).
211
237
  0.1.0-beta.26 and earlier kept one agent home per agent, `DIR/<agent>/agent.sqlite`, and this version does not read
212
238
  those. So it refuses to start on a data directory that holds one, and names each home it found, instead of serving
213
239
  it as if it had no agents.
@@ -257,8 +283,10 @@ and a 200 says it can work, and the platforms here take one path.
257
283
 
258
284
  A run whose end the agent store cannot take (a full disk) still ends: a cancel makes it `cancelled`, with its cost from
259
285
  its rows, and the server writes the end to the store again every 30 s until it lands; a restart before then reads the
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.
286
+ run as the store last had it. A run whose process was killed is opened again on its next message at once: the run's row
287
+ names its process (its pid, that process's start and this boot), and a process that is gone holds nothing. One server
288
+ serves a data root, and the agent disk under it (`<data>/disk`): a second server on the same root is refused at start
289
+ (`server.lock`), so the row's claim never has two servers claiming it at once.
262
290
 
263
291
  ## Sandbox
264
292
 
@@ -271,12 +299,15 @@ on the server. An agent says so in its [place](#place); the server says which [b
271
299
  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
300
  Daytona sandbox gets;
273
301
  [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.
302
+ end to end. The [published image](#in-the-published-image) hosts Docker boxes through the host's Docker socket.
275
303
 
276
304
  ### Place
277
305
 
278
306
  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
307
+ the providers under [Computers](#computers). `place` is the v2 view of the agent's computer setting: `runner` is kind
308
+ `none`, and `sandbox` a sandbox on that provider. On the runner a run has no shell where its folder is on this
309
+ server's disk (Mode 1), and `bash` on Archil's serverless exec where it is on Archil (Mode 2)
310
+ ([where `bash` runs](#computers)). In a sandbox the agent's `bash` runs in the named box and its
280
311
  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
312
  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
313
  remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox", "box": "docker"}`). One that names a
@@ -285,21 +316,24 @@ place keeps it, `runner` included. An edit that names no place keeps the agent's
285
316
  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
317
  (`{"mode": "sandbox", "box": "docker"}`) wherever this server has docker, ready or still preparing its image (its first
287
318
  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,
319
+ show it. If that definition names no `tools` either, it gets `["bash", "bash_background", "bash_output", "bash_input",
320
+ "bash_signal", "bash_list"]`, so the agent has a shell and can run a command in the background
321
+ ([background processes](#background-processes)). A definition that
322
+ names its tools keeps exactly those, an empty list included. Where docker is unavailable, a new agent is saved with no
323
+ place. So is one whose tools name one the box refuses (`browser`, runner-only for now). A workflow is never given a box.
324
+
325
+ `capabilities.places.default_place` is the place a new agent gets here, and where a revision that names no place runs.
326
+ 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
327
+ wherever this server has docker now, and on the runner where it does not. A workflow, and a revision whose tools name
328
+ one the box refuses, run on the runner. A save checks a revision with no place against where it would run, so `bash`
329
+ with no place saves where docker is there and is `422` where it is not. When that is the runner,
294
330
  `default_reason` says why in docker's own words, such as `new agents run on the runner, because the docker box is
295
331
  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.
332
+ 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
333
  What a person picks or unticks there is what is sent.
301
334
 
302
- A run runs in its revision's place, else on the runner. A run request names no place: `POST /agents/{id}/runs`
335
+ A run runs in its revision's place, else where `default_place` says at that run (a workflow, and a revision whose tools
336
+ name one the box refuses, on the runner). A run request names no place: `POST /agents/{id}/runs`
303
337
  with `place` is `422 input_invalid`, as with any field the body does not keep. The run keeps the place it resolved to,
304
338
  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
339
  `sandbox` (such as `native_tools: true`), never a third mode.
@@ -313,7 +347,8 @@ each box's own reason) when no box this server has can run it.
313
347
  `preparing` while the server builds or pulls its image, or `unavailable`) and, when it is not ready, the `reason`.
314
348
  A definition naming a box this server does not have saves with a warning on `definition.place`, and a run of it is
315
349
  `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"`.
350
+ `capabilities.places` `x-agentrun-serve: "place/1"`, `default_reason` `"place/3"`, and `default_place` `"place/4"`
351
+ (it replaced `places.default`).
317
352
 
318
353
  ### A run in a Docker box
319
354
 
@@ -327,14 +362,14 @@ link, and write through a temporary file renamed over the old one, keeping its m
327
362
  says so and names the box's path; `bash`, in the container, can still reach the file. Where this server reaches
328
363
  directories by path (no `/proc/self/fd`, as on macOS), or a box binds nothing, all four run in the container, made on
329
364
  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
365
+ `web_fetch`, `web_search` and the `monid.*` tools stay on this server, and so do
331
366
  the run's loop, its log, its model calls and every key. What the server itself files in `work/` (monid's long answers,
332
367
  the browser's evidence) never goes through a link a box's command planted there: each directory is held open on the
333
368
  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
369
  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
370
  go through `work/` by path.
336
371
 
337
- - The container binds the run's `work/` alone, read-write, at `/run/agentrun/run/work`, where the tools start. Nothing
372
+ - The container binds the run's `work/` alone, read-write, at `/workspace`, where the tools start. Nothing
338
373
  else of the data directory enters it. `read`, `write` and `edit` take a path in that directory, relative or absolute,
339
374
  or under the run's own `work/` on this machine, which names the same file there (another harness's cwd may name
340
375
  one); any other (another path of this machine, `..` out of it, `~`) is refused as outside the workspace, and their
@@ -467,16 +502,25 @@ where `bash`'s setting came from:
467
502
  console and the API show each log, during the run and after it.
468
503
  - Those files are for people to read: the run's own file tools can write anything in `work/`, so no call trusts one.
469
504
  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.
505
+ own directory (its `TMPDIR`, else `/tmp`), out of `work/`. A copy in `work/` is written from inside
506
+ `work/background/<id>`, entered and checked by its real path, to a new file of a name no one can guess, created and
507
+ written in one exclusive open, then renamed over its name; so a link planted at the name or at the directory is never
508
+ followed, and a real directory standing at the name skips that copy (as does a failed check). At the run's end every
509
+ copy (`command` and `started` among them) is written again, so a link planted at one since its start does not stay.
510
+ `output.log` is opened first and then checked as opened (through `/proc`: the file reached is
511
+ `work/background/<id>/output.log` itself, by its real path, and a regular file), and every read is of that open file,
512
+ 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`
513
+ to check by refuses every log, saying that instead. A directory made in `work/background/` that this box did not
514
+ start reads as "not started in this box", and is never signalled.
477
515
  - A process runs until no live process of its group is left: a child the command starts with `&` (a server, its
478
516
  output sent elsewhere) keeps it running, counted against the cap, signalled with it and ended at the run's end; its
479
517
  exit code is the shell's.
518
+ - A child that leaves the process group (one that calls `setsid`, a daemon that detaches) is not tracked: it is not
519
+ counted against the cap, no `bash_signal` reaches it, and the run's end does not end it. Only the box's end (its
520
+ destroy at the run's end) or its 24-hour lifetime ends it; the box's process limit (`AGENTRUN_BOX_PIDS`) only bounds
521
+ how many processes there can be.
522
+ - A process whose runner ended before it did (its box was replaced, or the runner was killed) reads as gone, its exit
523
+ code not known.
480
524
  - 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
525
  16 MiB of the output; later output is dropped while the process runs on, and `bash_output` says so.
482
526
  - `bash_background {command, tty: true}` runs the command on a terminal instead: `script -qfec` (util-linux) in the box
@@ -486,7 +530,8 @@ where `bash`'s setting came from:
486
530
  interactive shell's running command stops and the shell runs on; `TERM` and `KILL` go to every process group of the
487
531
  terminal's session. That session is tracked as the process: a child its command leaves running on the terminal keeps
488
532
  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
533
+ itself is gone. A box with no `script`, or with another `script` than util-linux's (busybox's takes no `-e`, and without it
534
+ 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
535
  process `(tty)`.
491
536
  - `bash_output {id, offset?, max_bytes?}` reads the log from a byte offset (0 when absent), at most 48 KiB a call (the
492
537
  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 +555,7 @@ since nothing binds `work/` there):
510
555
 
511
556
  - The key is this server's alone. The server makes, copies to and from, and destroys the sandbox itself. The run's
512
557
  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
558
+ 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
559
  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
560
  refuses every other call (a create, a listing, a stop, a delete, another run's sandbox or token, any other host), and
516
561
  it never follows a redirect, nor does the server's own Daytona client: a redirect would carry the key.
@@ -533,7 +578,7 @@ since nothing binds `work/` there):
533
578
  - A sandbox Daytona does not report blocked, when blocked was asked, is deleted, and the tool call fails saying so. An
534
579
  organization on Daytona's tier 1 or 2 keeps its own network policy, which a sandbox cannot override, so a run there
535
580
  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
581
+ - A sandbox cannot bind `work/`. The server copies `work/` into it at `/workspace` when it makes it, and
537
582
  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
583
  run's end is recorded. Daytona's answer is never trusted: the copy back writes regular files and directories only,
539
584
  never a link and nothing outside `work/`, and a file this server changed since the last copy stays as this server
@@ -557,7 +602,7 @@ since nothing binds `work/` there):
557
602
  needs it: for the run's next tool call, a copy back, or the start's sweep. One still stopping, pausing or archiving
558
603
  is waited for (a minute at most) first. It is never replaced by a new one, so
559
604
  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`.
605
+ - The sandbox is Daytona's default snapshot, made as its user, with `sudo -n` making `/workspace`.
561
606
 
562
607
  ### A run in a Modal sandbox
563
608
 
@@ -568,7 +613,7 @@ is Modal's default sandbox runtime (gVisor), not a virtual machine: the server d
568
613
  `edit` run in the sandbox too. What differs:
569
614
 
570
615
  - 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,
616
+ `/workspace`, copies what changed back at each turn's end and once more before the run's end is recorded,
572
617
  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
618
  nothing outside `work/`, a file this server changed stays as it has it) are Daytona's.
574
619
  - 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 +665,133 @@ never runs; the box's first process is a `sleep` of its lifetime.
620
665
 
621
666
  ### In the published image
622
667
 
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:
668
+ The published image, `ghcr.io/parcha-ai/agentrun-server`, runs Docker sandboxes on the Docker of the host it runs on,
669
+ through that Docker's socket, as `compose.yaml` at the repository's root starts it ([in a container](#in-a-container)). The image
670
+ has the Docker client (Debian's `docker-cli`) and no daemon; `group_add` gives the image's `node` user the socket's group
671
+ (`DOCKER_GID`), so the server never runs as root.
672
+
673
+ - **The socket is root on the host.** Whatever can reach `/var/run/docker.sock` can start a privileged container and do
674
+ anything on the host: the server, and every run's process it starts, since a run makes its own box. It is the same
675
+ trust as a server on a host whose user is in the `docker` group. Give the server the socket only where you would give
676
+ it root. A box never gets it.
677
+ - **A box is a container beside the server's.** It is made as on a Linux host (`--network none`, every capability dropped,
678
+ no new privileges, the server's uid, the box limits).
679
+ - **Its files.** The daemon has none of the server's paths, only what it mounted into the server's container. At its
680
+ start the server reads its own container's id from `/proc/self/mountinfo`, asks Docker for that container's mounts
681
+ (`docker inspect`), and takes the named volume that holds the data directory. A run's sandbox mounts that run's folder
682
+ from it, and the sandbox's own daemon (copied to `<volume mount>/.agentrun/computerd`, read-only), as the volume's
683
+ subpaths (`--mount type=volume,...,volume-subpath=...`), never the rest. The run's files and the sandbox's are the same
684
+ files, as on a host.
685
+ - **The host's own addresses.** A sandbox's egress proxy refuses the Docker host's own addresses, which the server in a
686
+ container can't see on its interfaces. At its start it reads them once through the socket: one container on the
687
+ host's network (`--network host`, with `host.docker.internal` added for Docker Desktop and OrbStack, whose listing is
688
+ the VM's), from the proxy's own image, as nobody (`65534:65534`), every capability dropped, no new privileges, a
689
+ read-only root, 64 MiB and 32 processes, removed at its exit, bounded to 60 s. To those it adds
690
+ `AGENTRUN_DOCKER_HOST_ADDRESSES` (a comma list of IP addresses, checked at the start), for what no interface shows,
691
+ such as a NAT'd or elastic public address. The union is in capabilities' docker entry (`host_addresses`) and the
692
+ `event=docker_host_addresses` line. With none known under an allow-list (the read failed, nothing set), docker is
693
+ unavailable at the start, saying so and naming the setting or `AGENTRUN_BOX_ALLOW=none`; under `none` nothing is read.
694
+ - **Any other layout** (the data directory not on a read-write named volume of the server's own container, the socket of
695
+ another Docker than the one that runs the server, a container whose id `/proc/self/mountinfo` does not name) makes
696
+ docker unavailable at the start, its reason in capabilities and the `event=box_paths` line: `run AgentRun in a
697
+ container with docker compose up from compose.yaml (its named data volume is how boxes reach a run's files)`. On an
698
+ older engine: `Docker Engine <26 can't mount a named volume's subpath: upgrade to Docker 26+`. A daemon of another
699
+ machine makes it unavailable too, whether `DOCKER_HOST` names it or the current Docker context does (`DOCKER_CONTEXT`,
700
+ else the saved current one, read once with `docker context inspect`): that daemon has none of this machine's paths.
701
+ Another machine's is `ssh://`, or `tcp://` to a host that isn't loopback; `unix://`, `npipe://` (Docker Desktop on
702
+ Windows) and `tcp://` to loopback are this machine's. An agent that
703
+ names a Docker computer is refused at its run's start in those words, and one with no computer runs on the runner,
704
+ with the file tools and no shell.
705
+ - On a host the server finds no container of its own and asks Docker nothing: a box binds this machine's paths and its
706
+ proxy's directory is under `/tmp`, as before.
707
+
708
+ <a id="boxes"></a>
709
+
710
+ ### Computers
711
+
712
+ An agent's computer is one setting, `computer: {kind, provider}` in its definition, set in the console under
713
+ Settings → Computers. The kind says what the agent is given, and the provider who runs it:
714
+
715
+ | Kind | What the agent gets | Providers |
716
+ |---|---|---|
717
+ | `none` | The run's folder alone: no computer, and no provider (`{"kind": "none"}`) | |
718
+ | `sandbox` | A Linux shell, with files and processes | `docker`, `daytona`, `modal`, `e2b` |
719
+ | `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` |
720
+ | `phone` | A rented Android: its screen, touch and apps (the `phone_*` tools) | `phone-harness` |
721
+ | `browser` | A hosted browser (the browser tools) | `browserbase`, `kernel` |
722
+
723
+ A kind with no provider, a provider that does not serve the kind, or a provider whose required keys are not saved is
724
+ refused before anything starts, in words that name the fix in Settings → Computers. `GET /v2/computers` lists each kind,
725
+ whether this server offers it now, the tools it brings, and each provider with its key names and whether each is saved
726
+ (never a value). `PUT /v2/computers/{provider}/keys` saves a provider's keys, sealed under the server's seal key, from
727
+ the owner's signed-in session only (the API token is 403), and `POST /v2/computers/{provider}/test` makes one read at
728
+ the provider with them and starts nothing. A key set in the server's environment wins over the saved one. The keys are
729
+ `DAYTONA_API_KEY` (with `DAYTONA_API_URL` and `DAYTONA_TARGET` optional), `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET`,
730
+ `E2B_API_KEY`, `ORGO_API_KEY`, `PHONE_HARNESS_API_KEY`, `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`, and
731
+ `KERNEL_API_KEY`; Docker takes none. The vendors bill their computers by time on their own pages: this server meters no
732
+ computer time. The older [`place`](#place) is this setting's v2 view: `{"mode": "runner"}` is kind `none`, and
733
+ `{"mode": "sandbox", "box": X}` is a sandbox on provider X. Writing either sets both.
734
+
735
+ **Where the run's folder lives.** A server keeps its runs' folders in one of two modes:
736
+
737
+ - **Mode 1** (the default): on this server's own disk. Only a provider that binds a folder of this machine can hold
738
+ it, so a sandbox runs on Docker only; a Daytona, Modal or E2B sandbox is refused ("Mode 1 runs a sandbox only on
739
+ Docker").
740
+ - **Mode 2**: on your own Archil disk. `PUT /v2/workspace/archil` turns it on with the disk's id, its region, its S3 URL
741
+ (and an exec image pinned by digest, if you want one other than Archil's default), and the account key,
742
+ `ARCHIL_API_KEY`; `DELETE` turns it off. A Daytona, Modal or E2B sandbox mounts the run's folder from the disk with a
743
+ mount credential minted for that run alone; Docker's sandbox is refused, since it cannot mount the disk.
744
+
745
+ A desktop, a phone and a browser run in either mode. The run's folder is at `/workspace` in every computer that mounts
746
+ 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
747
+ phone and a browser never mount it.
748
+
749
+ **Where `bash` runs.** It follows the mount:
750
+
751
+ - A computer that mounts the run's folder runs `bash` and the background tools (`bash_background`, `bash_output`,
752
+ `bash_input`, `bash_signal`, `bash_list`). A call with no timeout runs 120 s, and none runs past 600 s.
753
+ - With no computer that mounts it (kind `none`, a phone, a browser, or a desktop that does not mount), in **Mode 1** the
754
+ 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
755
+ to read its data and its keys. The run gets `read`, `write` and `edit`, confined to its folder; `bash` and the
756
+ background tools are not offered, and a `bash` call answers "bash is not available in this run: it has no computer to
757
+ run commands in, and commands never run on the server itself." So an agent with no computer on a server without
758
+ Docker gets the file tools and no shell.
759
+ - With no computer that mounts it in **Mode 2**, `bash` runs on Archil's serverless exec: a fresh container that holds
760
+ the run's folder alone, never a process of this server. Only `bash`: the background tools answer that background
761
+ programs need a computer. `bash` is held to its own setting, as on a computer. Archil's limits hold for it: a command
762
+ 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
763
+ stopped, so a cancel answers at once while the command runs on to its own deadline, holding the folder (later writes
764
+ and commands wait for it); and its output comes back whole when it ends, not as it runs. Through Archil's file API a
765
+ 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
766
+ followed: reading one is refused, a write through a linked folder is refused, and `bash` refuses a working directory
767
+ with a link on the way.
768
+
769
+ **An agent with no setting.** With no `computer` and no `place`, the server decides at each run's start: in Mode 1, the
770
+ Docker sandbox where this server's Docker answers, else no computer; in Mode 2, no computer. A workflow always runs with
771
+ no computer.
772
+
773
+ **What a computer reaches.** A Docker sandbox reaches the hosts of `AGENTRUN_BOX_ALLOW` (by default the package
774
+ registries and GitHub) through its egress proxy, and nothing else; `AGENTRUN_BOX_ALLOW=none` gives it no network. From a
775
+ server in a container the proxy also refuses the Docker host's own addresses, which the server reads through the socket
776
+ ([in the published image](#in-the-published-image)). A
777
+ Daytona, Modal or E2B sandbox has no network of its own (loopback only). A phone and a browser are on their vendor's
778
+ own network, whatever the list says.
779
+
780
+ **Docker.** A Docker computer runs where this server's Docker answers. With `AGENTRUN_BOXES` not set at all (a plain
781
+ `npx @parcha/agentrun`), the server probes `docker` at its start (within 5 s) and offers it when Docker answers
782
+ (`ready`, or `preparing` while its image is built or pulled, as [the box's image](#the-boxs-image) says); `AGENTRUN_BOXES`,
783
+ when set, lists what it probes, and `AGENTRUN_BOXES=none` probes nothing. One log line says what it found:
647
784
 
648
785
  event=boxes available=<ids or none> unavailable=<ids> <id>="<why>" ...
649
786
 
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.
787
+ A missing `docker` command says `Docker isn't running on this machine (no docker command on PATH): install or start
788
+ Docker, then restart AgentRun`; a daemon that does not answer says to start Docker or add this user to the `docker`
789
+ group, then restart AgentRun, since the probe runs once. A run whose agent names a Docker computer here is then refused
790
+ at its start in those words. Every other provider needs only its keys. A Docker desktop has no default image: it needs
791
+ one with an X server, and `AGENTRUN_DOCKER_IMAGE` names the image of every Docker computer, sandbox and desktop alike.
792
+
793
+ The keys belong to the server alone. A provider is handed its declared keys only when a run's computer starts or its
794
+ connection is tested, and no run's process gets them, in its environment or on its pipe.
685
795
 
686
796
  ## Models
687
797
 
@@ -698,7 +808,8 @@ to `AGENT_MODEL`. Capabilities show the mapping in `models` (`{source, route_pre
698
808
  model ids (`agent-model`), which a client takes off to show the gateway's own id, and null with any other source.
699
809
  `models` also says `ready`, whether a revision that names no model runs here, and when it does not, `needs`: `key` (no
700
810
  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:
811
+ know); and `priced`, whether that model has a price here, which a run's `max_cost_usd` needs (false for a gateway
812
+ 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
813
 
703
814
  - `--faux MODULE`: every model is the module's (below), with no key and no network: `faux-1`, or for a tier the model
704
815
  id its variable names.
@@ -709,12 +820,20 @@ know). Where the models come from:
709
820
  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
821
  in USD per million tokens, so a run's cost estimate has a price; `AGENT_MODEL_FAST_PRICE` and `AGENT_MODEL_STRONG_PRICE`
711
822
  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
823
+ takes the catalog's list price; one it lists only with its version's separators written the other way (a gateway's
824
+ `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,
825
+ only when every entry of that form lists one price (else none), and the id sent to the gateway stays as named; any
826
+ other has no price: its answers' cost is unknown, so the run's `cost.usd` is
713
827
  `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
828
  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
829
  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.
830
+ 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
831
+ starts: 409 `agent_not_runnable`, whose `error.fields` entry names `definition.model`, the reason `not_set_up_here`, "The
832
+ 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
833
+ every 409 `agent_not_runnable` names each thing that keeps a run from starting; an agent saved with a default cap on one
834
+ gets that as a warning. One
835
+ without a cap runs, on every harness, with each request's cost unknown: codex's and opencode's proxy books it unknown,
836
+ never $0, so the run's `cost.usd` is `null` and `/usage` counts it in `unpriced_runs`.
718
837
  - Otherwise pi-ai's providers serve them, each with its key from the environment (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`,
719
838
  `GEMINI_API_KEY`, `DEEPSEEK_API_KEY`, Bedrock's `AWS_*` keys, ...), and its catalog prices the run. The `AGENT_MODEL`
720
839
  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 +878,10 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
759
878
 
760
879
  | Tool | What it does | Needs | A workflow's model node may name it, a call node run it |
761
880
  | --- | --- | --- | --- |
762
- | `read` | Read a file in the run's `work/` | nothing | yes, no |
881
+ | `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
882
  | `write` | Write a file in the run's `work/` | nothing | yes, no |
764
883
  | `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 |
884
+ | `bash` | Run a shell command in the run's box, from its `work/`: pi's `{command, timeout?}`, 120 s when the call names no timeout and at most 600 s (a longer one runs at 600 s and says so; longer work is `bash_background`) | an agentic definition whose place is a sandbox ([Sandbox](#sandbox)) | no, no |
766
885
  | `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
886
  | `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
887
  | `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 +898,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
779
898
  | `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
899
 
781
900
  `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.
901
+ sandbox place `read`, `write` and `edit` run in the box too.
786
902
 
787
903
  A call tool that fails on its own (an unreadable PDF, a model's refusal) fails its call node; inside a `map` with
788
904
  `onItemFailure: "collect"` it fails that item, and the other items go on. A cancel or the node's deadline still
@@ -855,7 +971,8 @@ default). An agent's `definition.tool_settings` has the same shape and is over t
855
971
  for its capability (`auto`, `native`, `exa-keyless` or `parallel` for `web_search`; `kernel` or `parallel` for `web_fetch`;
856
972
  `auto`, `browserbase`, `kernel` or `chrome` for `browser`, [below](#tools)); an
857
973
  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
974
+ 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
975
+ its calls must carry ([MCP servers](#mcp-servers), `422` for one that is not one); a workflow's call node, which cannot wait
859
976
  for an approval, refuses its run when its tool is set to ask or deny (`409`, `details.asks` or `details.denied`). The
860
977
  settings are kept in the data directory
861
978
  (`tool-settings.json`, 0600, written whole and durably), not a secret, and read by every run launched from then on.
@@ -939,7 +1056,7 @@ read 2026-11-03), an estimate: a `fast` search $0.001 for up to 10 results and $
939
1056
  $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
1057
  connection its price (Parallel may have billed it). Under a [spend cap](#spend-cap) each is a paid call: sent only when
941
1058
  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
1059
+ 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
1060
  guarded direct fetch, with `parallel` giving the same words. One sent holds its price until Parallel answers: a model
944
1061
  request checked meanwhile, from any branch, tool round or harness, counts it beside what the run has spent, so the two
945
1062
  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 +1086,8 @@ saying why. Kernel's browsers run headless, and keep no downloads, so a run on K
969
1086
  run's process over its pipe, as the rest do. A session's custody (its lease, its tag, what it was
970
1087
  doing) is kept in the run's own store, so a run opened again on its directory reconciles the sessions it held. Each
971
1088
  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)
1089
+ reads at once included. There is no recording. The owner watches the browser live, takes it over and hands it back, and
1090
+ the agent can ask them to (below). When the run is let go (its work done, or a SIGTERM)
973
1091
  the sessions it still holds are released at their vendor. An agent's browser stays signed in from one run to the next
974
1092
  ([saved sign-ins](#saved-sign-ins)).
975
1093
 
@@ -991,6 +1109,65 @@ A variable gives the provider's price in US dollars an hour (a contract rate; th
991
1109
  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
1110
  every browser call is refused. Under a cap the browser's time is held before it runs (see [Spend cap](#spend-cap)).
993
1111
 
1112
+ #### The browser's live view
1113
+
1114
+ The owner watches a run's browser live from the console, and takes it over: the same view for every vendor (pi-browser's
1115
+ own viewer, a screencast of the page the agent is on), never the vendors' own live-view links, which stay in the run's
1116
+ 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
1117
+ one file in the run's directory, outside `work/` (`browser-live/<session>.json`, one file per session, 0600), which goes
1118
+ when that session ends: a session's end never touches another's, so a relaunch's old session never hides its new one's
1119
+ view. A session a restarted process keeps (it was still running at the vendor) gets its viewer handed over again by the
1120
+ 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
1121
+ with its token in the fragment), `{state: "none"}` when the run has a browser but no session is open, and
1122
+ `{state: "off", reason}` when it has none: its agent has no `browser` tool, or its browser resolves unavailable here (the
1123
+ 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
1124
+ same view is the computer family's too, one for every kind (`browser`, `desktop`, `phone`), read through the same code:
1125
+ `GET /v2/runs/{id}/computer` answers `{state: "live", kind, viewer, hold}` (the link under `/v2/runs/{id}/computer/live/`),
1126
+ `{state: "none", kind, hold}` or `{state: "off", hold, why}`; `hold` says who drives now (`agent`, `pending` or `person`). It takes the owner's
1127
+ password session in the console: a token, which a run's process, an MCP client or a script may hold, is `403`.
1128
+
1129
+ The viewer lives under `/v2/runs/{id}/browser/live/`. Its page, script and style are this server's own (the files of the
1130
+ pi-browser it has installed), framed by this server's own origin alone (`frame-ancestors 'self'`, the console's `'none'`
1131
+ everywhere else); only its WebSocket goes to the run's port, taken only from this server's own origin (as the request
1132
+ reaches it, or the public address, `AGENTRUN_PUBLIC_URL`, for a TLS proxy that rewrites `Host`) with the owner's session,
1133
+ and on a loopback address only at one of its names, as every route is (a rebound name is refused, whatever its `Origin`).
1134
+ One viewer at a time: a second is refused (`viewer_in_use`). A browser with no page yet (Kernel's headless one starts with
1135
+ none) shows "No page yet" until one opens. The token dies with the session: the answer says `none` and the old link opens
1136
+ nothing. The token is in no record, timeline row, run view, run file, home, log or the model's context.
1137
+
1138
+ **Take over, hand back.** The viewer watches until the owner presses **Take over** in it; until then the run drops its
1139
+ input before the browser (`held not_taken`). Take over holds the browser for the owner until they press **Hand back**,
1140
+ 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
1141
+ input; the agent's browser calls wait inside the tool (they do not fail), then go on with the page's old element ids
1142
+ dropped, and the model is told in plain words that the person had the browser and the page may have changed. A call that
1143
+ 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
1144
+ 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
1145
+ 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
1146
+ 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
1147
+ browser call that waited for the hand-back reads "Waited for you 11 s, then opened …". The owner's time counts: Take over holds
1148
+ 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
1149
+ 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
1150
+ 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
1151
+ 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
1152
+ (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,
1153
+ and the ask expires, the agent told the cap's words. When the
1154
+ browser comes back, what was held up front goes, and the time the person had stays held, at the provider's price, until
1155
+ the session's next charge books it: take-overs given back with no browser call between them still meet the cap.
1156
+
1157
+ **The agent asks.** The agent may ask the owner to do something in its browser (`browser_request_handoff`: an instruction
1158
+ 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
1159
+ made, and the tool's result says why. The run then reads `input_required`/`waiting` with
1160
+ `pending: {kind: "browser", instruction, completion_condition, asked_at, expires_at}`, its timeline shows "Waiting for you:
1161
+ <instruction>", and the webhook's `run.needs_input` says `pending.kind: "browser"`; the agent's turn waits inside the tool
1162
+ call. The owner takes over in the viewer, does it, and answers `POST /v2/runs/{id}/browser/hand-back` with
1163
+ `{outcome: "done"}` or `{outcome: "cancelled"}` (the owner's password session alone, as above). The first answer wins: the
1164
+ same answer again is `200`, a different one `409 handoff_answered` with the answer it has. Any answer hands the browser back
1165
+ to the agent. Unanswered for 15 minutes, the ask expires: the agent hears `expired`, and a later answer is `409` with
1166
+ `outcome: "expired"`. The ask's record is one 0600 file in the run's directory (`browser-ask/`, never `work/`): the
1167
+ instruction, the done-when condition and the ask's times, never the viewer's link or token. A run's process that dies
1168
+ 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
1169
+ answer, or writes the expiry. The record goes when the run ends, or when its process lets its browser sessions go.
1170
+
994
1171
  ### Saved sign-ins
995
1172
 
996
1173
  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 +1207,43 @@ picks which one a run gets, never the model.
1030
1207
  `held` with the run's id while a run holds the lease, else `ready`; `verified_at` is when a saving session last ended.
1031
1208
  `unreadable` (this server's own state, marked `signins/1` in the served contract) is a pointer that does not open
1032
1209
  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.
1210
+ you forget it, since the vendor's object it points to would be left behind. A run still going when the server
1211
+ 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
1212
+ not taken up: it is stopped (or, its process already gone, never opened again) and ends failed ("This server can't
1213
+ read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged): …"), and its rows are
1214
+ not read, since what it says could repeat the pointer, which the server could not cut. Once the sign-in opens again
1215
+ (the right seal key back), its rows are read and shown, cut of it. A run that had already ended keeps how it ended,
1216
+ but while the sign-in does not open none of what it said is served (rows, answer, output, error words, a review's
1217
+ reason, a workflow run's graph, and its files, `GET /runs/{id}/files` and each file, which answer 403 `forbidden`),
1218
+ it can't be continued, and what its end-of-run learning turn wrote is not checked, graded or merged (it waits as it
1219
+ was for a server that reads the sign-in). It is shown again, cut, once the sign-in opens. A run that was never
1220
+ handed the sign-in (one launched signed out since the key changed) is taken up as any other. That a run was handed
1221
+ 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
1222
+ still going whose `serve.json` is there but can't be read or parsed (where its plane and that mark are kept) is
1223
+ hidden the same way when its agent's revision grants the browser, or can't be read: nothing else says which browser
1224
+ it ran on, so whether it was handed the sign-in is not known ("This server can't read the run's record (its
1225
+ serve.json is damaged or can't be read), …"). An ended run whose `serve.json` is damaged since is withheld the same
1226
+ way, its end kept. That mark is the SHA-256 of each pointer the run was handed (a list, one per pointer; never a
1227
+ pointer), and what a run was handed is read back by it alone: each hash matched to the agent's live pointer or a
1228
+ forgotten one (below). A run with no mark was never handed one. When any of its hashes matches no pointer that opens
1229
+ (one under another seal key or none, one forgotten and since dropped out of the newest 32 kept, the agent's sign-ins
1230
+ file gone), the run is hidden or withheld as above, and shown again, cut, once every one does: nothing keeps that
1231
+ verdict, each server reads it anew. Forgetting the agent's other sign-ins never withholds it. A mark of any other
1232
+ shape (one an older build wrote, `true` or a single hash, or a damaged one) is read as handed some sign-in no one
1233
+ can name: the run is hidden or withheld, never served uncut, and forget waits for it while it goes. A run list's row
1234
+ for an ended run the server has not read (from its row and `serve.json` alone) serves its error (its details too)
1235
+ and review cut the same way, or withholds them in the same words, and withholds them when its `serve.json` is
1236
+ damaged. Its `held_by` still names a run that holds its lease, as a held one does.
1035
1237
  Never the pointer. `DELETE /v2/agents/{id}/sign-ins/{key}` forgets one: the vendor's context or profile is deleted,
1036
1238
  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.
1239
+ pointer goes all the same. It is `409 sign_in_held` while a run holds the lease (`details.held_by`), and also while
1240
+ a run it was handed is still going without the lease (`details.handed_to`): one that waits for its person, say, or
1241
+ one whose process went more than 30 minutes ago. What that run says could repeat the pointer, and once it is forgotten
1242
+ a restarted server could not read it back to cut it. The message names the run, never the pointer; forget it once
1243
+ that run ends. A forgotten pointer is still kept, sealed as it was, in the agent's sign-ins file
1244
+ (`forgotten`), the newest 32 per agent: never listed in `sign_ins`, never served, never handed to a run, never a
1245
+ 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
1246
+ 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
1247
 
1041
1248
  `monid.discover`, `monid.inspect` and `monid.run` give an agent [monid](https://monid.ai)'s whole catalog of data
1042
1249
  endpoints on one key, `MONID_API_KEY`: it finds an endpoint in plain words, reads its input schemas and price, and runs
@@ -1114,18 +1321,20 @@ runs' calls alone; with none, its `check` stays null.
1114
1321
 
1115
1322
  A saved key is kept only as ciphertext: AES-256-GCM in `DIR/tool-keys.json` (0600), each value bound to its field's
1116
1323
  name, under the seal key `AGENTRUN_SEAL_KEY`, which only the server opens it with. A run's process never gets the seal
1117
- key. With `AGENTRUN_SEAL_KEY` not set, the launcher keeps it in `agentrun/seal.key` under `$XDG_CONFIG_HOME` (or
1118
- `~/.config`), making it the first time: 32 random bytes in base64, 0600 in a 0700 directory, and one another user can
1119
- read is refused, not changed. It is outside the data directory on purpose: a copy or a backup of the data directory
1120
- holds the keys as ciphertext alone, and opens nowhere without the seal key. With no seal key (started with no launcher and
1121
- no `AGENTRUN_SEAL_KEY`, or with no home directory) nothing is saved, never in the clear: `409 no_sealing_key`, and capabilities' `features.tool_keys.at_rest` is
1122
- `unavailable` (`sealed` otherwise).
1324
+ key. With `AGENTRUN_SEAL_KEY` not set, the server keeps it in `seal/seal.key` in its data directory, beside the store,
1325
+ making it at the first start: 32 random bytes in base64, 0600 in a 0700 directory, and one another user can read is
1326
+ refused, not changed. It lives and dies with the data (a disk, a volume): back it up with the data directory, and keep
1327
+ the two together. The store records the key's fingerprint (an HMAC of a fixed label under the key, never the key), and
1328
+ the server, every runner and `import` check the key they hold against it: a store whose secrets were sealed with another
1329
+ key does not start ("this store's secrets were sealed with another key; hand the server the original
1330
+ AGENTRUN_SEAL_KEY"), and no key is ever made over sealed secrets, so a lost `seal.key` is never replaced by a new one.
1331
+ The same holds on Postgres: a second machine with another key refuses. Only the server's start makes the key; a runner
1332
+ reads it from `AGENTRUN_SEAL_KEY` or the data directory, never makes one, and is refused without one. Set
1333
+ `AGENTRUN_SEAL_KEY` explicitly, the same in every process, and keep it.
1123
1334
 
1124
1335
  A stored value that does not open is never a reason not to start. It reads `set: false, stored_unreadable: true`, and
1125
- `reenter` names those fields with why: `seal_key_missing`, `seal_key_changed` (a lost `seal.key` is made anew, so it
1126
- shows as this) or `file_unreadable`. The log says so once, naming the condition and the file, never a value; a `PUT` of
1127
- the value seals it again under the current key. In a container, `~/.config` is the container's own and goes with it:
1128
- pass `AGENTRUN_SEAL_KEY`, or mount a directory at `XDG_CONFIG_HOME`, so a new container opens the keys the volume holds.
1336
+ `reenter` names those fields with why: `seal_key_changed` (sealed under another key) or `file_unreadable`. The log says
1337
+ so once, naming the condition and the file, never a value; a `PUT` of the value seals it again under the current key.
1129
1338
 
1130
1339
  A saved key is read by name like one the launcher hands over, and the launcher's value wins for a name it holds. A run
1131
1340
  gets the saved keys at its launch, over the pipe its secrets come on (a workflow run's `PARALLEL_API_KEY` on its
@@ -1157,7 +1366,8 @@ Streamable HTTP with the official MCP SDK client (`@modelcontextprotocol/client`
1157
1366
  `instructions` and every tool `tools/list` gives, all pages, each with its name, title, description, `input_schema`,
1158
1367
  `output_schema` and `annotations` (the server's own claims, not checked). It stores nothing. `auth` is `{type: "none"}`
1159
1368
  (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.
1369
+ value}}` (up to 8). An `oauth` server is signed in to first ([below](#signing-in-with-oauth)), then previewed by name.
1370
+ `url` is `https`, or `http` on loopback.
1161
1371
 
1162
1372
  What can go wrong, told apart:
1163
1373
 
@@ -1192,6 +1402,54 @@ another format) is never written over: the list answers `servers: []` with `file
1192
1402
  route is `409 store_unreadable` until the file is restored or removed. Capabilities' `features.mcp_client`
1193
1403
  says `transports: ["streamable-http"]`, the `auth` types and `at_rest` (`sealed`, or `unavailable` with no seal key).
1194
1404
 
1405
+ ### Signing in with OAuth
1406
+
1407
+ A server whose preview answers `details.auth: "oauth"` is signed in to by this server, which keeps the tokens: the
1408
+ agent's machine never sees one. `POST /v2/settings/mcp-servers/{name}/oauth/start` with `{url, scopes?, client_id?,
1409
+ client_secret?}` answers `{authorization_url}`, the page the owner opens. It runs the official MCP SDK's OAuth: the
1410
+ server's protected-resource metadata (RFC 9728), then its authorization server's (RFC 8414); PKCE S256; the server's URL
1411
+ 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
1412
+ origin, the client kept sealed from the last sign-in (so a pre-registered client's id and secret are given once); else this
1413
+ server's client metadata document, `GET /v2/settings/mcp-servers/oauth/client.json`, when this server's address
1414
+ (`AGENTRUN_PUBLIC_URL`) is public `https` and the authorization server takes one; else dynamic client registration.
1415
+
1416
+ The authorization server sends the browser back to `GET /v2/settings/mcp-servers/oauth/callback`, which takes no token:
1417
+ its `state` is random, bound to the server's name, used once and good for 10 minutes (else `400`), and the PKCE verifier
1418
+ never left this server. It finishes only in the browser that started the sign-in: the start's answer sets a cookie
1419
+ for that sign-in alone (named by its state, so two tabs do not replace each other's; `HttpOnly; SameSite=Lax`, path
1420
+ the callback, 10 minutes, cleared when it finishes), and a callback without it is `403` with nothing exchanged. So a
1421
+ start must come to the address the callback is under: one that came to another (the console opened under another
1422
+ name for this machine than the server's own address) is `409 wrong_origin`, with `details.open` the console's MCP
1423
+ page there.
1424
+ The redirect URI never changes with the address a request came to, so a registered client's stays valid. Behind a
1425
+ proxy on a public https address, set `AGENTRUN_PUBLIC_URL` to that address and have the proxy pass the `Host` header
1426
+ and `X-Forwarded-Proto: https`: without them a start reads as another address (or plain http) than the callback's,
1427
+ and every start answers `409 wrong_origin`. For an MCP server whose URL is not loopback, every endpoint its authorization server names (and
1428
+ every request to one) must be `https` and resolve to no private, loopback or link-local address, or the sign-in or
1429
+ refresh is refused with words and nothing is sent. A loopback MCP server is a development-only exception: its
1430
+ authorization server may name endpoints on the MCP server's own loopback host, exactly as its URL writes it (never
1431
+ 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
1432
+ loopback endpoint is refused the same way. The host is pinned, not the port, as a local authorization server listens on
1433
+ its own port. What that leaves: such an authorization server can still have this server send its sign-in and refresh
1434
+ requests to other ports on that same loopback host (a port Docker publishes there, say), blind, learning only the
1435
+ 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,
1436
+ scopes, the client and its secret) under `AGENTRUN_SEAL_KEY`, bound to the server's name, lists the tools as a `PUT`
1437
+ does, and redirects to the console's MCP servers page, `/#/settings/mcp?server=<name>&sign_in=ok` (or
1438
+ `sign_in=failed&error=<code>`). The redirect URI is this server's own callback under its address: on loopback, the
1439
+ plain `http` address and port it listens on.
1440
+
1441
+ Reads show `auth.type: "oauth"`, `credential: "sealed"` and `oauth: {expires_at, scopes, client, client_id}`, where
1442
+ `client` is `pre-registered`, `metadata-document` or `dynamic`; never a token or a client secret. A `PUT` with `auth: {type: "oauth"}` keeps the token
1443
+ set. Refresh tokens never leave this server: a run's launch refreshes an access token that expires within 5 minutes
1444
+ (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
1445
+ alone. A refresh the authorization server refuses (revoked, expired) makes the server read `credential: "expired"`,
1446
+ 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
1447
+ try, two tries, so an authorization server that does not answer holds a start's answer about 8 s at most; the run's
1448
+ call is then refused unsent, saying to try again. A token that expires during a run is not
1449
+ refreshed in that run: its calls fail as unauthorized, and the run's next launch refreshes it. A server that stops aborts any
1450
+ refresh or code exchange under way and writes nothing after; if the authorization server had already rotated that
1451
+ refresh token, the next start reads `credential: "expired"` and asks for a sign-in again.
1452
+
1195
1453
  `test/fixtures/fake-mcp-server.mjs` is a loopback MCP server for trying this: `startFakeMcp({era, token, oauth})`
1196
1454
  answers `{url, log, tools, close}`; it serves `add`, `slow_write`, `delete_thing` and `paid`, and logs each request's
1197
1455
  method, tool and whether an `Authorization` header came, never its value.
@@ -1202,8 +1460,10 @@ An agent grants a saved server's tool by its catalog name, `mcp:<server>/<tool>`
1202
1460
  (`"tools": ["mcp:github/list_issues"]`). A save checks each one against the server's saved tools: a server that is not
1203
1461
  saved, or a tool it did not list, is `422` naming the server's tools, and so is a name whose wire name,
1204
1462
  `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.
1463
+ 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
1464
+ another harness the save warns that they are not bound there yet, and a run is refused. A workflow's nodes bind no MCP
1465
+ 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
1466
+ here yet; grant it to an agentic agent").
1207
1467
 
1208
1468
  A known **meta tool**, one that runs other actions by name, is never granted: Composio's `COMPOSIO_MULTI_EXECUTE_TOOL`,
1209
1469
  `COMPOSIO_REMOTE_WORKBENCH`, `COMPOSIO_REMOTE_BASH_TOOL` and `COMPOSIO_PROXY_EXECUTE`, Klavis Strata's `execute_action`
@@ -1211,7 +1471,8 @@ A known **meta tool**, one that runs other actions by name, is never granted: Co
1211
1471
  `mcp.zapier.com`), Arcade's `Arcade_UseTool`, Docker's `mcp-exec` and generated `code-mode-*` tools, and Cloudflare's
1212
1472
  `portal_execute` and `portal_codemode_execute`. A grant of one couldn't name the real action, so allow would cover every
1213
1473
  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:
1474
+ `422` in those words, a run of a revision saved granting one is `409 agent_not_runnable` naming it under
1475
+ `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
1476
  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
1477
  asked by default.
1217
1478
 
@@ -1229,14 +1490,21 @@ asked by default.
1229
1490
  model proxy, `/mcp/<server>`, behind the session's key, sent over the CLI's stdin (never its arguments), with only
1230
1491
  those servers (`strictMcpConfig`) and only the granted tools allowed. The proxy answers the MCP exchange itself and
1231
1492
  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.
1493
+ offered whole. The proxy answers the handshake and the tool list itself, so a remote server that can't be reached
1494
+ shows at the first call, as that call's error; only a proxy route the CLI can't connect to fails the turn.
1495
+ - **codex** uses Codex's own MCP client the same way: the harness writes each granted server in Codex's
1496
+ `mcp_servers` (an agent's own `config` still may not), at the session's model proxy with the session's key, with
1497
+ only the granted tools enabled. Each call runs without Codex asking (`default_tools_approval_mode = "approve"`): the
1498
+ proxy is the gate. Codex sends a call as soon as it starts it, so the proxy records the call in the session before
1499
+ 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
1500
  - **A call** goes to the pinned URL alone, the 2026-07-28 revision first and a 2025-era server through its
1234
1501
  `initialize`; on 2026-07-28 each `x-mcp-header` parameter of the pinned tool is sent as its `Mcp-Param-*` header. No
1235
1502
  redirect is followed, at most 4 MiB is read, and it may take 120 s. The
1236
1503
  model reads the text blocks joined; past 60,000 characters, or with blocks that are not text, the whole answer is
1237
1504
  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
1505
+ model as its error. A refused credential (401, 403) reads "the MCP server <name> refused its credential (its sign-in
1506
+ expired or was revoked, or its key changed): sign in again in Settings → MCP servers, or update its credential
1507
+ there"; another failure names the server and the HTTP status, never a header. A stop, or a
1240
1508
  client that goes away, cancels the call at the server. A call a crash cut off is answered interrupted on the
1241
1509
  resumed run and never sent again.
1242
1510
  - **The gate.** Every call passes the run's one tool gate as `mcp:<server>/<tool>`, on every harness. Set
@@ -1248,12 +1516,33 @@ asked by default.
1248
1516
  until the owner answers `POST /v2/runs/{id}/approvals/{approval_id}` from their password session. Allowed, the run
1249
1517
  sends the call once and resumes with its result; denied, it resumes with the refusal. A restart while a call is
1250
1518
  parked loses nothing.
1519
+ - **Pins.** An MCP tool's own key (`mcp:<server>/<tool>`, never the wildcard) may also carry `pin`, 1 to 8 of the
1520
+ tool's top-level arguments, each to the one JSON scalar its calls must carry (`null`: the argument left out), or a
1521
+ list of 1 to 16 of them, the argument one of the list, compared strictly:
1522
+ `{"mcp:slack/slack_send_message": {"permission": "allow", "pin": {"channel_id": "C0123"}}}`,
1523
+ `{"mcp:github/pull_request_review_write": {"pin": {"event": [null, "COMMENT"], "method": ["create", "delete_pending", "submit_pending"]}}}`
1524
+ (the `code-review` template's pin). The gate checks a pinned
1525
+ tool's call before it runs or asks anyone, whatever the permission (an allow, an ask, a grant): a call whose arguments
1526
+ are not as pinned is refused, never sent and never asked about, and the model reads "mcp:slack/slack_send_message may
1527
+ only be called with channel_id = C0123: its destination is fixed by the agent's settings". The run's process logs a
1528
+ line naming the tool, the call and the arguments that did not hold, and its Timeline row is a failed call, as any
1529
+ refusal's. A call approved under ask is checked again before it is sent. A pin adds to a setting and is never a
1530
+ permission: the agent's pin and the server's both hold (an argument both pin takes what holds both), and where
1531
+ nothing holds both every call is refused, saying so. A template pins its sends' destinations to its parameters ([Templates](#templates)). A pin in
1532
+ `tool-settings.json` that does not read refuses every call of its tool, and `GET /settings/tools` serves it as
1533
+ `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
1534
+ left out) keeps it broken, so saving another tool's setting never lifts it; a valid pin repairs it, and leaving the
1535
+ key out removes the setting. An agent keeps a pin of its own in `definition.tool_settings.<tool>.pin`, and the gate
1536
+ holds its runs to it and to the server's.
1251
1537
  - **Prices.** `PUT /v2/settings/mcp-servers/{name}` takes `prices`, each tool's price in USD a call
1252
1538
  (`{"prices": {"search": 0.01}}`; a finite number, 0 or more, for a tool the server lists; else `422`). A priced call
1253
1539
  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
1540
  run's tool cost (a `Tool cost` row, the `tools` meter of `GET /usage`). A tool with no price runs "not metered": a
1255
1541
  row says so, the run's usage row counts it (`not_metered`), and `GET /usage`'s `tools` line counts the calls
1256
1542
  (`not_metered_calls`); it is outside the run's cost and its cap. A run keeps the prices its first launch saw.
1543
+ A PUT that names no `prices` keeps the saved ones, for the tools the server still lists at the same URL (a new URL
1544
+ keeps none), so a save from any client never leaves a paid tool unmetered; `"prices": {}` clears them. A read lists
1545
+ the tools no price meters as `not_metered`.
1257
1546
  - **The timeline** shows each call as `<server> · <tool>`.
1258
1547
 
1259
1548
  ## Webhooks
@@ -1261,7 +1550,8 @@ asked by default.
1261
1550
  One URL hears of your runs without anyone watching the page. `PUT /v2/settings/webhook` with `{url}` sets it: an `http`
1262
1551
  or `https` address, with no user or password in it. Loopback and private-network addresses are allowed, so a receiver
1263
1552
  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
1553
+ need its person (`input_required`: a question, a call held for approval, a pause at its cap, an ask for its person in
1554
+ its browser, desktop or phone, or a stopped turn) and `run.ended` when it ends
1265
1555
  (completed, failed or cancelled, once carried back). A [schedule](#schedules) whose firing fails sends a third,
1266
1556
  `trigger.failed`; a server with no triggers never sends one.
1267
1557
 
@@ -1271,11 +1561,9 @@ store has the end, so a receiver that reads the run back on its message (`GET /v
1271
1561
  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
1562
  stores it. The outbox (`DIR/webhook-outbox.json`) keeps, in the same write as each message, which end and which wait of
1273
1563
  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
1564
+ 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
1565
  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
1566
+ `webhook-id`. An end before the webhook was set is never sent. A run is continued only once its end's
1279
1567
  `run.ended` is in the outbox on disk (`503` meanwhile), so a continued run's next end is its own, under its own id.
1280
1568
 
1281
1569
  ```json
@@ -1285,7 +1573,13 @@ that time (an older server's) or before the webhook was set is never sent. A run
1285
1573
  ```
1286
1574
 
1287
1575
  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`.
1576
+ 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
1577
+ run is titled from its trigger, `<Source> <name>` and the event when its source names one ("Webhook reviews:
1578
+ pull_request opened"), never from its input; a workflow run's from its agent's name and its input; any other run's
1579
+ from its input. `pending.kind` is `question` (an `ask_person`),
1580
+ `approval` (a tool call that waits for a person's approval), `stopped` (a stopped turn), `budget` (a run paused at its
1581
+ cap) or `browser` (the agent asked for the owner in its browser). An agent's ask for the owner on its desktop or phone
1582
+ (the run's `pending.kind` `computer`) is told as `question`.
1289
1583
 
1290
1584
  Messages are signed by the [Standard Webhooks](https://www.standardwebhooks.com) spec, so a receiver verifies them
1291
1585
  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 +1595,8 @@ spec's schedule, with jitter: after about 5 s, 5 min, 30 min, 2 h, 5 h and 10 h,
1301
1595
  (`event=webhook condition=delivery_failed`). Each message goes on its own tries, so two queued close together can
1302
1596
  arrive in either order: a receiver orders them by `webhook-timestamp`, or reads the run (`GET /v2/runs/{id}`). A
1303
1597
  `410 Gone` turns the webhook off (`disabled` in `GET`, and the log says why) until a `PUT` sets it again. Pending messages are kept in `DIR/webhook-outbox.json`, so the next server goes on with
1304
- them after a restart; a message can then come twice, under the same `webhook-id`. `GET /v2/settings/webhook/deliveries`
1598
+ them after a restart; a message can then come twice, under the same `webhook-id`. An outbox file of another version
1599
+ is not read: the server starts with none, and the log says so (`condition=outbox_not_read`). `GET /v2/settings/webhook/deliveries`
1305
1600
  lists the last 50 attempts (`webhook_id`, type, status code, latency, error, when, and the next try's time), and
1306
1601
  `POST /v2/settings/webhook/deliveries/{webhook_id}/redeliver` sends one of those messages again, once, under the same
1307
1602
  `webhook-id`. `POST /v2/settings/webhook/test` sends a `webhook.test` message once and answers how it went. A webhook a
@@ -1325,7 +1620,7 @@ change repeats fires once, at its first pass; one it skips fires at the first ti
1325
1620
  reckoned from the last nominal one, so a timer that wakes late does not drift. Every run a trigger starts is capped: by
1326
1621
  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
1622
  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
1623
+ starts an uncapped run, a workflow agent's included ([workflow runs](#a-workflow-run-under-its-cap)). Each run's
1329
1624
  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
1625
  trigger and the firing, in the run's view and in the runs lists (`GET /v2/runs`, `GET /v2/agents/{id}/runs`) alike;
1331
1626
  a run a caller started has `trigger: null`.
@@ -1335,17 +1630,19 @@ A firing starts its run once. Its key comes from the trigger and its nominal tim
1335
1630
  a restart drives again finds its run. A firing's key stays bound to that run: when the server stopped while setting the
1336
1631
  run up, the firing reads `failed` ("The server stopped while setting up the run.") with that run's id, it never fires
1337
1632
  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
1633
+ is `skipped`, with why (a webhook trigger with `accept` or `max_active_runs` is the exception: [each event it
1634
+ takes](#webhook-triggers) starts its own run); a full server (`429`) keeps it due and tries again. Times missed while the server was down are
1339
1635
  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,
1636
+ no older than the trigger's `catchup_window_s` (default an hour; 0, never), marked `catch_up`. A
1637
+ firing while the last run is active (working, or parked waiting on a person) is skipped with why, never queued,
1342
1638
  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
1639
  gets a `trigger.failed` message for it (`data: {trigger_id, name, firing_key, nominal_at, error, auto_paused}`, its
1344
1640
  `webhook-id` made from the firing's key, so a restart never sends it twice). Five failed firings in a row turn the
1345
1641
  trigger off (`disabled: {reason: "auto_paused"}`); a firing that starts its run resets the count, and so does turning
1346
1642
  it on again. Run now (below) works on an auto-paused trigger too, and counts toward the streak like any firing: one that
1347
1643
  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
1644
+ 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
1645
+ turned off alone, at a start or when it comes due
1349
1646
  (`disabled: {reason: "source_unreadable", detail}`), and every other schedule goes on firing; turning it on again takes a
1350
1647
  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
1648
  before the next one's overlap is checked. `PATCH /v2/triggers/{id}` changes it, and
@@ -1356,7 +1653,8 @@ firing has left the history too, and later it is a new firing that a run the key
1356
1653
  ### Webhook triggers
1357
1654
 
1358
1655
  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
1656
+ route with no token. Its view carries that address as `hook_url`, at the server's public URL when it has one
1657
+ (`AGENTRUN_PUBLIC_URL`), else the path; a schedule has none. The request is signed by the trigger's own secret under the
1360
1658
  [Standard Webhooks](https://www.standardwebhooks.com) spec, the one this server's outbound [webhooks](#webhooks) sign
1361
1659
  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
1660
  server's clock either way) and `webhook-signature: v1,<base64 HMAC-SHA256 of "{id}.{timestamp}.{body}">` under the
@@ -1365,17 +1663,99 @@ anything else. A bad signature, a stale timestamp, an unknown trigger, one that
1365
1663
  answer the same `401`, so no trigger id can be found by asking; a body past 256 KiB is `413`.
1366
1664
 
1367
1665
  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.
1666
+ shows it. It is kept sealed under `AGENTRUN_SEAL_KEY` in `DIR/trigger-settings-webhook.json` (each trigger source's
1667
+ sealed settings have a file of their own), so with no seal key no webhook trigger is made (`409 no_sealing_key`).
1668
+ `POST /v2/triggers/{id}/secret` makes a new one, shown once, and the old one signs nothing from then on. Like every
1669
+ secret this server keeps (its tokens, its outbound webhook's secret), it is cut from what a run shows, from what an
1670
+ import keeps and from every learning text. A secret replaced by a rotation, or whose trigger is deleted, is kept too,
1671
+ sealed in a retired row of its own (scope `retired:<trigger>:<n>`), never a setting and in no `GET`: a run that quoted it
1672
+ before is still cut on every later server. Retired rows are kept for good for now; dropping one once no run older than
1673
+ it is left is still to come. A secret that does not open under the seal key the server starts with is
1674
+ said in its log (`condition=trigger_setting_unopened`, naming the trigger), and its trigger is refused until a new
1675
+ secret is made. A `trigger-settings-webhook.json` that does not read is never written over: until it is fixed or moved
1676
+ away, no webhook trigger is made or rotated (`409 store_unreadable`) and none fires.
1677
+
1678
+ The request's `webhook-id`, which its signature covers, is its firing's key: the first answers `202` once the firing is
1679
+ recorded, and its run starts after; the same `webhook-id` again, for a day after, answers `200` with that firing and
1680
+ starts nothing (`{"ok": "duplicate"}` once the firing has left the trigger's history of 200 and the 1,000 it keeps past
1681
+ it). Each trigger keeps the keys of its last day's pushed firings in `triggers.json`, at most 5,000, the oldest let go
1682
+ first past that, which the log says once (`condition=trigger_seen_full`). The agent gets the trigger's input,
1683
+ then the body, cut at 16 KiB, inside `<trigger-payload source="webhook" scheme="standard" untrusted>...</trigger-payload>`:
1684
+ whatever the sender wrote is data, not an instruction. The tag names the signature scheme, the event as that scheme
1685
+ reads it (`event="..."`), the JSON body's top-level `action` (`action="..."`) and an unsigned delivery id
1686
+ (`delivery="..."`, GitHub's `X-GitHub-Delivery`) and, for a GitHub delivery, its pull request or issue's `number="..."`
1687
+ (`pull_request.number`, else `issue.number`) and a pull request's `head_sha="..."` (40 hex; a comment event has none, so
1688
+ 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
1689
+ 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
1690
+ the body, in any case, is defused.
1691
+
1692
+ A webhook trigger's `signature` names its scheme, one of a table of them: `standard` (the default, above) or `github`,
1693
+ for a GitHub repository or organization webhook. A request is checked by the one scheme whose signature header it
1694
+ carries (`webhook-signature`, `X-Hub-Signature-256`), and the scheme gives its firing key, from what its signature
1695
+ covers, and its event. With `github`, paste the trigger's whole `whsec_...` secret, as it is, into the GitHub webhook's
1696
+ Secret (content type `application/json`): each delivery is checked by `X-Hub-Signature-256: sha256=<hex HMAC-SHA256 of
1697
+ the raw body>`, keyed by the UTF-8 bytes of that string. GitHub signs the body alone, not `X-GitHub-Delivery` nor a
1698
+ 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
1699
+ answers its firing, and so does a captured delivery sent again within the key's day under any delivery id. After the
1700
+ day it would fire again (over TLS, a risk taken); there is no 5-minute window. Two real deliveries never share a body,
1701
+ since GitHub's carry their own ids and times. `X-GitHub-Delivery` (1 to 255 printable ASCII characters) only names the
1702
+ delivery on the payload's tag, for tracing. A request that carries no scheme's signature header, or more than
1703
+ one, or is signed under a scheme other than its trigger's, is the same `401` as a bad signature, and the headers are
1704
+ checked before the body is read.
1705
+
1706
+ `accept` makes a trigger take only the events it names, from the delivery alone:
1707
+
1708
+ ```json
1709
+ { "kind": "webhook", "signature": "github",
1710
+ "accept": [
1711
+ { "event": "pull_request", "actions": ["opened", "synchronize", "ready_for_review"],
1712
+ "where": [ { "pointer": "/pull_request/draft", "in": [false] } ] },
1713
+ { "event": "issue_comment", "actions": ["created"],
1714
+ "where": [ { "pointer": "/issue/pull_request", "exists": true },
1715
+ { "pointer": "/comment/author_association", "in": ["OWNER", "MEMBER", "COLLABORATOR"] },
1716
+ { "pointer": "/comment/body", "prefix": "@reviewer review" } ] } ] }
1717
+ ```
1718
+
1719
+ A rule's `event` is the event as the trigger's scheme reads it: GitHub's `X-GitHub-Event`, or a Standard Webhooks
1720
+ body's top-level `type`. GitHub signs the body, not `X-GitHub-Event`: a delivery a trigger ignored keeps its key for
1721
+ the day, so the same body sent again under another event answers `{"ok": "duplicate"}`, and where it matters a rule
1722
+ should also test a field only that event's body has (`/pull_request`, `/comment`, `/issue/pull_request`); `actions`, when given,
1723
+ lists the values the body's top-level `action` may take; each of `where`'s conditions is a JSON pointer (RFC 6901) into
1724
+ the body with one test: `in` (the value there equals one of the JSON values listed, an object's fields in any order),
1725
+ `exists` (`true`, the pointer names a value, `null` included; `false`, it names none) or `prefix` (the value is a string
1726
+ whose first line, trimmed, starts with it, ignoring case). A delivery fires when any rule takes it, with all its
1727
+ conditions holding. A verified delivery no rule takes (GitHub's `ping` among them, a body that is not JSON too) answers
1728
+ `200 {"ok": "ignored"}`, fires nothing, and is one log line (`condition=hook_ignored`, with the trigger and why). Without
1729
+ `accept`, every verified request fires, as before. A trigger holds at most 20 rules, each at most 20 conditions and 20
1730
+ actions; an `in` lists at most 20 values of at most 1024 characters of JSON each, a pointer is at most 512 characters,
1731
+ and an event, an action or a prefix at most 200. A trigger with `accept` starts a run for each event it takes, its last
1732
+ run active or not, since the events it takes are each their own work (a review per pull request); the server's run
1733
+ limit still holds: a start it refuses (`429`) keeps the firing due and tries it again, and past 20 firings due a new
1734
+ delivery answers `429`. This holds for every firing of such a trigger, a run now (`POST /v2/triggers/{id}/fire`)
1735
+ included. Runs start in the order their events came while the server has room; while one firing waits to be tried
1736
+ again after a `429`, a later one can start first.
1737
+
1738
+ Such a trigger can take every run this server has room for, starving other triggers and the runs people start. Give it
1739
+ `max_active_runs` (1 to 100; `null` clears it): past that many of its runs active, a firing waits due and is tried
1740
+ again, as at a full server, and is never skipped. It counts the runs this trigger started while they work, kept apart
1741
+ from its history (so a long run counts however many firings follow it) and read again at each check; a run a person
1742
+ opens again after it ended is that person's follow-up, not counted. Any `start_run` trigger of a pushed source (a
1743
+ webhook) takes it, with or without `accept`: set, each event starts its own run, never skipped behind the last, up to the
1744
+ cap; past it a firing waits due, and past 20 due an event answers `429 rate_limited` with `Retry-After`. Without
1745
+ `max_active_runs`, a trigger with no `accept` keeps the overlap skip: an event while its last run is active is
1746
+ `skipped`. A schedule keeps the overlap skip and takes no cap, and nor does a `message_run` target, which starts no run
1747
+ (`422` for either). On a public repository, a rule for `issue_comment` or `issues` events needs a condition on
1748
+ `/comment/author_association` or `/issue/author_association` (`in: ["OWNER", "MEMBER", "COLLABORATOR"]`): without one,
1749
+ anyone who can comment starts runs.
1750
+
1751
+ 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
1752
+ the origin `{kind: "trigger", trigger_id, source, owner}`, `owner` decided by the trigger's definition as it fires and
1753
+ never by its payload (true for a schedule, fired on time or by hand; false for a webhook, its body empty or not). The
1754
+ 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
1755
+ it is now, "Schedule utc-check: <its first line>" (the trigger's id once it is gone), with `origin: "trigger"` and
1756
+ `trigger: {id, source, owner}` (so a client labels it by its source without reading the summary), never as "You: ...",
1757
+ 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
1758
+ not kept yet.
1379
1759
 
1380
1760
  A trigger's target may also be `{kind: "message_run", run_id, input: {content}}`, with a webhook or a schedule source:
1381
1761
  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 +1767,113 @@ never opens a completed run again for one it already has. A firing to a run that
1387
1767
  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
1768
  with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
1389
1769
 
1770
+ ### GitHub triggers (Connect GitHub)
1771
+
1772
+ A server has at most one GitHub App, made with GitHub's app-manifest flow, and every `github` trigger (and every
1773
+ GitHub template) uses it. In the console, Connect GitHub calls `POST /v2/integrations/github/connect` (`{org?}`, to make
1774
+ the App under an organization) and posts the form it answers to GitHub: `action`, GitHub's new-App page, and
1775
+ `manifest`, which names a name GitHub lets the person edit, the server's public URL, its hook `/v2/hooks/github`, its
1776
+ callback and setup URLs, the permissions (pull requests write; contents, metadata and issues read) and the events
1777
+ (`pull_request`, `issue_comment`). It needs the address GitHub can reach, `AGENTRUN_PUBLIC_URL` (`409 github_no_public_url`,
1778
+ "GitHub can't reach this server: set its public URL first"), a seal key (`409 github_no_seal_key`, naming
1779
+ `AGENTRUN_SEAL_KEY`), and no App connected already (`409 github_already_connected`, "This server already has a GitHub
1780
+ App. Disconnect it first."), and a request at the public URL itself, where GitHub sends the browser back
1781
+ (`409 github_wrong_origin`, "Open this server at <public URL> to connect GitHub.", the URL in `details.public_url`). Its
1782
+ `state` is random, used once, good for an hour, and bound to the browser that started it
1783
+ by a cookie on the callback's path; GitHub reads it from `action`'s URL, and the form posts only `manifest`.
1784
+
1785
+ GitHub sends the browser back to `GET /v2/integrations/github/callback` with a code. The server converts it with GitHub
1786
+ and keeps the App's id, slug and client id, which are no secret, and its private key and webhook secret, which are,
1787
+ sealed in `DIR/trigger-settings-github.json`; GitHub's client secret is never kept, and no secret is logged or answered.
1788
+ The browser goes on to install the App, with a fresh install state GitHub passes on and its cookie on the installed
1789
+ path; GitHub's redirect after (`/v2/integrations/github/installed`) records the installation only with that state and
1790
+ 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
1791
+ public URL, `<public>/#/settings/github?github=connected`. Without the state and cookie it records nothing and lands
1792
+ 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
1793
+ that is unknown, used, older than an hour or from another browser sends the browser to
1794
+ `<public>/#/settings/github?github=error&reason=state_invalid`,
1795
+ a code GitHub does not convert to `...&reason=conversion_failed`, one whose App GitHub made while another Connect kept
1796
+ its App to `...&reason=already_connected` (the first App stays), and an installation GitHub does not confirm, or one
1797
+ checked while GitHub was disconnected or connected again, to `...&reason=installation_unverified`; nothing is kept. The
1798
+ App's `installation` events keep the list current, each taken only in its own shape (the installation, its account and
1799
+ this App's id) and as GitHub, asked with the App's JWT, bears it out: `X-GitHub-Event` is not signed, so another
1800
+ event's signed body sent as one changes nothing. GitHub out of reach when an event is checked answers it `503`, so
1801
+ GitHub shows the delivery failed and it can be sent again; and the list is repaired from GitHub's own installations at
1802
+ the server's start and when `GET /v2/integrations/github` is read (at most once a minute), by the same rule: none left
1803
+ turns the github triggers off, one dropped only shrinks it. A list that an event or the install redirect wrote while
1804
+ GitHub was asked is not overwritten by GitHub's older answer: the repair asks once more, and leaves the list as it is
1805
+ 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
1806
+ github triggers off, and its list as it comes (the one removed included, when GitHub holds it active again) becomes the
1807
+ list. An installation event follows the same rule: GitHub's answer to its check is taken only when no write came meanwhile
1808
+ (else it is asked once more), so an older suspend never undoes a newer unsuspend. A server that closes stops its repair
1809
+ and its events' checks, which write nothing after (an event cut so answers `503`, to be sent again).
1810
+ `GET /v2/integrations/github` always answers 200: `{connected: false}` with no App, else `{connected: true, app_id, slug,
1811
+ installations}`, never a secret. Not connected is an answer, not a 404 a browser logs as an error. `DELETE` with nothing
1812
+ connected is still 404.
1813
+
1814
+ A trigger with `source: {kind: "github", accept: [...]}` takes the App's events its `accept` names (the same rules as a
1815
+ webhook trigger's, above; required) and keeps no secret of its own. `POST /v2/hooks/github` takes no token: each delivery
1816
+ is checked by `X-Hub-Signature-256` under the App's webhook secret, and one event fires **every** github trigger whose
1817
+ `accept` takes it, each its own firing, keyed by the SHA-256 of the signed body, and its own run (github triggers may
1818
+ take the same events; `max_active_runs` caps each). Every other github trigger keeps the body's key for its day, so the
1819
+ same body sent again under another `X-GitHub-Event`, which GitHub does not sign, starts nothing: where it matters, a rule
1820
+ 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`
1821
+ though the others recorded theirs: the retry records it there once it has room, and is the others' duplicate. An event no
1822
+ trigger takes is `200 {"ok": "ignored"}`; GitHub's `ping` is
1823
+ `200 {"ok": "pong"}`. The payload's tag also names the installation and the repository (`installation="..."
1824
+ repo="owner/name"`). A github trigger made or turned on with no App connected is `409 github_not_connected` ("Connect GitHub
1825
+ in Settings"). A `{kind: "webhook", signature: "github"}` trigger is unchanged: a repository webhook with its own secret.
1826
+
1827
+ An installation deleted or suspended on GitHub leaves the list, and one unsuspended comes back; the github triggers turn
1828
+ off only when no installation is left (`disabled: {reason: "connection_lost", detail}`, naming it), and coming back
1829
+ turns none on. `DELETE /v2/integrations/github` disconnects the App and turns every github trigger off the same way,
1830
+ answering `{disconnected: true, triggers_off, note}`, the note "Delete the App itself on GitHub: <its settings URL>":
1831
+ the App's credentials leave this server only, and it stays on GitHub until deleted there. Turned off, a trigger is kept:
1832
+ an agent keeps its triggers, and each goes on again once turned on with GitHub connected.
1833
+
1834
+ An MCP server saved with `auth: {type: "github_app", headers?}` (`PUT /v2/settings/mcp-servers/{name}`) uses the
1835
+ connected App's tokens and keeps none of its own: only its static headers (such as `X-MCP-Tools`), sealed as written,
1836
+ and never an `Authorization`. Its tools are listed with a token narrowed to one repository, of the first of the App's
1837
+ installations (in order) that covers one; an installation whose account has none selected is passed over. GitHub that
1838
+ 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
1839
+ again", retryable, and the preview, save or refresh changes nothing. At each launch of a run that
1840
+ grants its tools (its start, every resume, a relaunch after a crash) the server mints an installation token for that
1841
+ run, narrowed to the one repository the run is about, with the App's permissions: a GitHub event's run uses its
1842
+ installation and repository (the server's own payload tag); any other names it in its input as
1843
+ `https://github.com/<owner>/<repo>`, whose installation the server asks GitHub for with the App's JWT. The token goes to
1844
+ the run's MCP calls with the static headers beside it, lives only in memory (handed to the run's process over its pipe,
1845
+ never its environment, journal, a log line or an answer), and is cut from whatever a run shows while it may be in use.
1846
+ A run whose repository the App does not cover, or that names none, has those calls answered in words ("The GitHub App
1847
+ 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
1848
+ expires, so a long run's calls never carry an expired token. When that mint fails, the token held keeps working until
1849
+ it expires; then the run's calls of that server are answered, unsent, that its GitHub App token expired and a new one
1850
+ could not be made, with GitHub's reason, and the next launch (a resume) mints a fresh one.
1851
+
1852
+ ## Templates
1853
+
1854
+ A template package makes a working agent in one call: its definition, its skills and rules, and its triggers, from a
1855
+ folder the server ships. `GET /v2/templates` lists them; `POST /v2/templates/{name}/apply` with `{parameters,
1856
+ overrides?: {model}}` makes one, or nothing when a check fails (a trigger refused archives the agent it made). A
1857
+ 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
1858
+ rules of an apply are in [templates/README.md](https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/templates/README.md);
1859
+ `agentrun template validate DIR` checks a folder as the server does.
1860
+
1861
+ `agentrun template eval DIR` (`agentrun-serve eval-template DIR`) runs a package's eval cases as real runs of its agent
1862
+ 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
1863
+ touches yours, with each case's fake MCP servers on loopback and its learned notes seeded through the learning API. Real
1864
+ models cost money: each run is capped at its case's `max_cost_usd`. It exits 0 when every case passed, 1 when one
1865
+ failed, 2 when nothing ran. The runner, the graders and the report are in
1866
+ [templates/README.md](https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/templates/README.md#running-the-evals).
1867
+
1868
+ | `eval-template` flag | What |
1869
+ | --- | --- |
1870
+ | `--case NAME` | A case to run; repeat it. Without one, every case. |
1871
+ | `--runs N` | Runs of each case, in place of each case's `runs`. |
1872
+ | `--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. |
1873
+ | `--grader-model PROVIDER/MODEL` | The `llm` graders' model; default the server's. |
1874
+ | `--report FILE` | The whole report as JSON (per case, run and grader: pass, reason, cost); a summary goes to stdout, progress to stderr. |
1875
+ | `--faux MODULE` | Answer every model request from the module, as the server's `--faux` does. Not with `--server`. |
1876
+
1390
1877
  ## What it serves
1391
1878
 
1392
1879
  | Route | Here |
@@ -1394,15 +1881,15 @@ with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
1394
1881
  | `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
1395
1882
  | `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
1883
  | `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)). |
1884
+ | `POST /agents`, `GET /agents`, `GET /agents/{id}` | `POST` takes `{definition, skills?, note?}` and makes the agent with its first revision, current. A definition has `instructions` (an agentic revision) or `workflow` (a workflow revision, checked by the DSL first), and `name`, `description`, `model` and `thinking` (agentic only), `harness` ([harnesses](#harnesses)), `place` ([place](#place)), `tools`, `tool_settings` ([search and fetch](#search-and-fetch)), `skills` (names; each `<name>/SKILL.md` is in `skills`) and `version`, which is the number the revision gets, and `max_cost_usd`, the agent's default cap (an agentic agent's or a workflow's), kept by an edit that leaves it out and cleared only by 0, and `cap_mode`, how such a cap prices a request, `expected` or `strict` ([spend cap](#spend-cap)). A field the store does not keep (`input_schema`, `output_schema`) is `422 input_invalid` by name, and so is a definition that can never run here; one this host cannot run yet saves with `warnings` ([models](#models)). The ETag (`home_etag`) is the current revision's id. `GET /agents/{id}` adds `tools`, the tools its current revision grants with each one's provider ([search and fetch](#search-and-fetch)). |
1398
1885
  | `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
1886
  | `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
1400
1887
  | `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
1401
1888
  | `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. |
1889
+ | `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
1890
  | `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
1891
  | `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). |
1892
+ | `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
1893
  | `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
1894
  | `POST /runs/{id}/messages` | To an agentic run: `steer` while the agent works, `answer` when it asked the person, `follow_up` after a stop or after it completed: a completed run opens again, the same run on its own session and store, takes a place under `--max-runs` (`429` when none is free), and completes again. A failed or cancelled run, an archived run and a run of an archived agent are `409 not_continuable`; a workflow run takes none (`501`). |
1408
1895
  | `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 +1898,18 @@ with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
1411
1898
  | `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
1899
  | `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
1900
  | `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`). |
1901
+ | `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
1902
  | `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
1903
  | `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
1904
  | `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. |
1905
+ | `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
1906
  | `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)). |
1907
+ | `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)). |
1908
+ | `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)). |
1909
+ | `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
1910
  | `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
1911
  | `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. |
1912
+ | `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
1913
  | `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
1914
  | `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
1915
 
@@ -1426,6 +1917,25 @@ Home export and import, quotes and `POST /runs/{id}/kill` answer `501 unsupporte
1426
1917
  capabilities declare each one false. No run waits out `input_wait_s` here (`null`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
1427
1918
  above $0 is taken; it does not mean caps are unsupported ([spend cap](#spend-cap)).
1428
1919
 
1920
+ ### API only
1921
+
1922
+ `AGENTRUN_API_ONLY=1` is for a server that runs behind its caller's backend and is never opened in a browser. It
1923
+ serves these routes alone:
1924
+
1925
+ - a run's launch (`POST /agents/{id}/runs`, `POST /runs`), read (`GET /runs/{id}`), lists (`GET /agents/{id}/runs`,
1926
+ `GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above) and cap raise (`PATCH /runs/{id}`);
1927
+ - its files (`GET /runs/{id}/files`, `GET /runs/{id}/files/{path}`) and [uploads](#uploads) (`/files`);
1928
+ - `GET /capabilities`, `GET /health` and `GET /usage`.
1929
+
1930
+ Every other address is `404 not_found`, answered before the request is read further: the console at `/` and its
1931
+ assets, the store page's `/api/*`, sign-in and setup, every `/settings` route, `POST /mcp`, triggers and their
1932
+ `POST /hooks/{id}`, agents, templates, `/openapi.json`, `/llms.txt` and the live views. It has no accounts: there is no
1933
+ page to sign in to, so no setup code is printed. The token works as it does on every route served. Unset, `0` or
1934
+ `false` serve the whole server, as before; any value other than these and `1` or `true` stops the start, in words.
1935
+
1936
+ Its routes for agents are refused too, so on an API-only server a run is launched inline (`POST /runs` with its
1937
+ definition), or on an agent made before the profile was turned on.
1938
+
1429
1939
  ## Uploads
1430
1940
 
1431
1941
  A run's input files. Send one in one call, its bytes the body and its path in the query:
@@ -1545,7 +2055,28 @@ model). A definition naming a
1545
2055
  harness this server does not run yet saves with a warning on `definition.harness`, and a run of it is
1546
2056
  `409 agent_not_runnable` with `details.harness`; it never runs on pi instead. This server runs pi always, and
1547
2057
  `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
2058
+ `reason` says what is missing. `claude-agent` and `codex` install themselves on first use: AgentRun never ships the
2059
+ Claude Agent SDK or the Codex CLI, and the first run on each (or the first agent saved on it) installs the version AgentRun
2060
+ pins (`@anthropic-ai/claude-agent-sdk@0.3.286`, `@openai/codex@0.164.0`) from npm into `<data>/harnesses/claude-agent`
2061
+ or `<data>/harnesses/codex`, with the npm that runs the server, once. Each install is pinned by the lock the server
2062
+ ships, `harnesses/claude-agent/` or `harnesses/codex/` (a package.json that names the package at the pin, and npm's lock
2063
+ for it: every package of the tree, the platform packages that hold the Claude CLI or the Codex binary and the peers'
2064
+ dependencies included, by sha512), which `npm ci --ignore-scripts --include=optional` holds every tarball to, from
2065
+ whichever registry the person's npm config names; a config that omits optional packages still gets this platform's CLI.
2066
+ It lands whole or not at all: npm writes into a fresh directory beside the install's own, the result is checked there
2067
+ (the package at the pin, its entry, this platform's CLI or binary, and for Claude the MCP library), then it is renamed
2068
+ into place and made read-only. `node scripts/harness-locks.mjs` makes the locks again when a pin moves (`--check`
2069
+ checks them). Every run that needs one waits for that one install, its ready time counted from the install's end, and
2070
+ shows a `phase` row, `Installing Claude Code (first use)…` or `Installing Codex (first use)…`, while it does. Each run
2071
+ then loads the harness from its own packages inside its install and nowhere else, never from a `node_modules` above it;
2072
+ a tree that is not whole is installed again. Claude Code as an earlier build installed it, at the top of `<data>/harnesses`
2073
+ itself, is removed before the first install (the server logs `harness_install_removed`), and it installs again; a
2074
+ `harnesses` directory that holds anything else is left as it is. Until it is installed, capabilities list the harness with `installs:
2075
+ "on_first_use"`. When npm fails, the run fails and its error names the command that installs it by hand, the same locked
2076
+ install: the shipped `package.json` and `package-lock.json` copied into a fresh `<data>/harnesses/<harness>.new`, `npm ci
2077
+ --ignore-scripts --include=optional` there, then that directory put in place of `<data>/harnesses/<harness>` (made
2078
+ writable first: the server leaves its install read-only). A server that stops
2079
+ mid-install stops its npm (SIGTERM). `opencode` needs `opencode-ai@1.19.5` installed beside the server (an exact optional peer of
1549
2080
  it), and its model goes where codex's does: the gateway at `AGENT_MODEL_BASE_URL`, or
1550
2081
  OpenAI with `OPENAI_API_KEY`, on the Responses API. The packages and pins are checked once, at the start
1551
2082
  (`event=harness_offers why=start`): a harness
@@ -1556,7 +2087,12 @@ no such clause: running that line is the restart. A reason a setting fixes (a mo
1556
2087
 
1557
2088
  `claude-agent` sends its requests to `ANTHROPIC_BASE_URL` (else Anthropic) with `ANTHROPIC_API_KEY` and Anthropic's own
1558
2089
  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
2090
+ (`anthropic/claude-sonnet-5.5`) and Anthropic's own (`claude-sonnet-5-5`) are one model. `pi` sends its Anthropic models'
2091
+ requests there too, compaction, a hosted search, a learned node and a grade included: to `ANTHROPIC_BASE_URL` with
2092
+ `ANTHROPIC_API_KEY` as `x-api-key` alone (never `ANTHROPIC_AUTH_TOKEN` or an OAuth token), and capabilities read its
2093
+ Anthropic default ready only where that route runs (`models.needs: "key"` without `ANTHROPIC_API_KEY`, or with an
2094
+ `ANTHROPIC_BASE_URL` a key may not go to, whose run is refused in its words). Such a base refuses Anthropic's route
2095
+ alone: a model of any other provider runs as it does without it. `codex` and `opencode` send their requests
1560
2096
  to serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
1561
2097
  `OPENROUTER_API_KEY` is set, runs through OpenRouter (`https://openrouter.ai/api`, the key as a bearer token):
1562
2098
  claude-agent on its Messages endpoint, with Anthropic's own id on the wire (OpenRouter takes it: its Claude Code guide
@@ -1594,17 +2130,23 @@ typed answers and their probabilities.
1594
2130
  for Jev through OpenRouter, and so does a model gateway on OpenRouter: with `AGENT_MODEL_BASE_URL` on the host
1595
2131
  `openrouter.ai` and neither key set, Jev runs on `AGENT_MODEL_API_KEY`.
1596
2132
  - 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.
2133
+ citations as its evidence. It runs on one of two routes. With `PARALLEL_API_KEY` set, on Parallel's own API: each
2134
+ request is booked at Parallel's list price as an estimate. Without it, on Parallel's model through OpenRouter,
2135
+ `parallel/decisions-fast`, on the OpenRouter key (below): only an OpenRouter key is needed. Its citations (OpenRouter's
2136
+ `url_citation` annotations) are the same evidence, and its cost is the one OpenRouter reports. A request whose outcome
2137
+ was lost after sending is never sent again on either route: the run escalates it as interrupted. Capabilities say which
2138
+ route it runs on (`route: "parallel"` or `"openrouter"`).
1599
2139
  - OpenRouter's Decisions models answer a node that says `provider: "openrouter"` and names its model in `model`
1600
2140
  (`liquid/d1`, `perplexity/pplx-decider-v1.2`, `cloudflare/clef`, `typesafe/jev-1.14`). They run on the OpenRouter key
1601
2141
  Jev's OpenRouter route reads (`OPENROUTER_API_KEY`, else `AGENT_MODEL_API_KEY` with `AGENT_MODEL_BASE_URL` on
1602
2142
  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.
2143
+ gateway's, which a run's process holds. Images to them are experimental. A model that cites the web returns
2144
+ `url_citation` annotations, which become the node's evidence. A cost OpenRouter reports above 0 is booked; 0 (a model its
2145
+ catalog prices at 0) or none is unknown, never $0.
1604
2146
  - A decision node's `images` are files of the run's `work/`, such as the pages `pdf_pages` draws: the run's process
1605
2147
  reads them and sends them with the request. The receipt keeps each image's SHA-256, never its bytes.
1606
2148
  - `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,
2149
+ reason?, note?, route?}]`, `route` on parallel), and `runJudge` is among `workflows.adapters` once any of them runs here. On the OpenRouter route,
1608
2150
  jev's `note` names the variable Jev runs on (`OPENROUTER_API_KEY` or `AGENT_MODEL_API_KEY`) and says that it is the
1609
2151
  model gateway's key.
1610
2152
  - With no key for a provider a workflow's nodes name, the workflow saves with a `not_set_up_here` warning on
@@ -1638,6 +2180,12 @@ An agent or a run is archived, never deleted: `DELETE` stays `405`. These routes
1638
2180
  - `POST /v2/agents/{id}/archive` hides the agent and its runs from `GET /agents`, `GET /runs` and
1639
2181
  `GET /agents/{id}/runs`; `POST /v2/runs/{id}/archive` hides one run. `.../unarchive` shows them again. Each is
1640
2182
  idempotent (archiving again keeps the first time), takes no body, and answers what it changed.
2183
+ - Archiving an agent turns off every trigger that runs as it (a `start_run` of it, a `message_run` to one of its
2184
+ runs) with the archive, in one write: `disabled: {reason: "agent_archived", detail}`, and the answer lists them in
2185
+ `triggers_off: [{id, name}]`. From then no firing starts a run of it: one that comes due anyway (waiting on its
2186
+ `max_active_runs`, or on a retry) is `skipped`, "The agent <name> is archived.". While it is archived, a trigger made
2187
+ on, turned on or aimed at it is `409 agent_archived`. Unarchiving turns none on: its answer lists those still off, and
2188
+ `PATCH /v2/triggers/{id}` `{enabled: true}` turns each on.
1641
2189
  - Each list takes `archived=true` to list only archived ones (`false`, the default, lists the others).
1642
2190
  - Every read by id still answers, with `archived_at` (null when it is not archived; a run's is its own, else its
1643
2191
  agent's): `GET /agents/{id}`, `GET /runs/{id}`, its timeline and its files. `/usage` still counts archived runs: the
@@ -1652,7 +2200,7 @@ An agent or a run is archived, never deleted: `DELETE` stays `405`. These routes
1652
2200
  ## The console
1653
2201
 
1654
2202
  Open the link the server prints, once, in a browser. `/` is the console (`apps/console` in the repository), on the
1655
- server's own origin, under a CSP that allows that origin only:
2203
+ server's own origin, under a CSP that allows that origin only, but for the provider icons on the Keys page (below):
1656
2204
 
1657
2205
  - **Mission Control**: the store's counts and the latest runs.
1658
2206
  - **Agents**: each agent with its kind and harness, archived ones behind **Archived**. **New agent** and an agent's page:
@@ -1664,6 +2212,10 @@ server's own origin, under a CSP that allows that origin only:
1664
2212
  keeps the filters. A run's page follows `GET /v2/runs/{id}/timeline` with a long poll, sends messages (an answer while
1665
2213
  it waits on `ask_person`), stops or cancels the run, shows its files and a workflow's graph, and has **Archive** or
1666
2214
  **Unarchive**.
2215
+ - **Settings → MCP servers**: add a remote MCP server (its name, address and credential: none, a bearer token, headers,
2216
+ or **Sign in** with OAuth), **Preview** its tools and protocol, then **Save**; each saved one with its tool count and
2217
+ its credential's state, **Refresh**, **Change** (a credential left empty keeps the saved one) and **Delete**. An
2218
+ agent's Tools step lists each saved server's tools; a box ticked grants `mcp:<server>/<tool>`.
1667
2219
 
1668
2220
  Its files (`index.html`, and Vite's hashed files under `/assets/`) are public and hold no data: everything it shows
1669
2221
  comes through `/v2`. The store's read-only JSON stays under `/api/*` (`/api/store`, `/api/agents/{id}`, `/api/runs` and
@@ -1686,12 +2238,32 @@ send the browser to `/`, which keeps a link's `#code`.
1686
2238
  ## Your password
1687
2239
 
1688
2240
  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
2241
+ no `AGENTRUN_PUBLIC_URL`, listening on loopback (the default), the start prints `Set your password: <url>/setup`, and the
2242
+ first visit sets it, 12 characters or more. With a public address, or listening on any other address (`0.0.0.0` in the
2243
+ image, a LAN address), the start prints `Set up this server: <url>/setup#code=<code>`, and setup takes that code (or the
2244
+ 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
2245
+ session cookies with the key in `DIR/.session-secret`; both are 0600, and no run reaches either. A session lasts 30 days.
2246
+ **Sign out** (`POST /v2/auth/sign-out`) signs out this browser: its session is revoked on the server (a copy of its
2247
+ 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,
2248
+ this one too.
2249
+
2250
+ Sign-in tries are limited, and never for good. Each address (an IPv6 one by its /64) has ten tries in 15 minutes; past
2251
+ them each next try waits a second after the last, twice that the time after, never more than a minute. The whole server
2252
+ takes 100 wrong passwords in 15 minutes; past them every try, from any address, waits the same way after the last wrong
2253
+ one. A refused try is a 429 that says how long (`retry-after`, `retry_after_ms`). The limit counts up to 10,000 addresses
2254
+ 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.
2255
+ Behind a proxy every visitor would be the proxy's address, so one guesser would hold the owner too: set
2256
+ `AGENTRUN_TRUSTED_PROXIES` to the proxy's addresses or ranges (comma-separated, or `loopback`, `linklocal`,
2257
+ `uniquelocal`), and a request from one of them counts under the client its `X-Forwarded-For` names (the nearest address
2258
+ that is not itself a trusted proxy). Unset, that header is never read. The owner's first sign-in of a start (the
2259
+ right password) that comes with `X-Forwarded-For` from an address the server doesn't trust is logged once, with that
2260
+ address (`event=forwarded_untrusted peer=<address>`; a server from a release after 0.1.0-beta.32). Only the right
2261
+ password logs it, so the address is the one that carried the owner's own request: behind a proxy, the proxy's.
2262
+ `render.yaml` leaves it unset, as Render publishes no address for its proxy: after a deploy, sign in, read the
2263
+ `forwarded_untrusted` line in the service's Logs, and set `AGENTRUN_TRUSTED_PROXIES` to that address (or its range,
2264
+ when Render's proxy reaches the service from more than one; sign in again after a redeploy to see whether it moved).
2265
+
2266
+ Forgot it: run
1695
2267
  `agentrun-serve reset-password --data DIR` where the data directory is (`docker exec agentrun node
1696
2268
  /opt/agentrun/packages/serve/dist/cli.js reset-password --data /data` in the image). It clears the password and signs every
1697
2269
  browser out, and the next visit sets a new one. The token works for scripts and the CLI either way.
@@ -1727,14 +2299,15 @@ left out: 2 sessions still being written: they come in next time
1727
2299
  ## A run's life
1728
2300
 
1729
2301
  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
2302
+ `DIR/disk/agents/<agent>/runs/<id>/`), then its process: `pi-durable-disk run --dir DIR/disk/agents/<agent>/runs/<id> --app <this package's app> --serve 0` on
1731
2303
  loopback, behind a token of its own (`DIR/.door-token`), with its stderr in `runs/<id>/process.log`. The run's input
1732
2304
  is in `runs/<id>/serve.json`.
1733
2305
  2. The app reads the run's revision from the store.
1734
2306
  - An agentic revision runs as the root agent: its instructions and skills, its model, and the tools it names of the
1735
2307
  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
2308
+ row, and the run is `input_required` and `waiting` until a message answers it. `bash` is bound only where the run
2309
+ has a shell ([computers](#computers)): in a computer that mounts the run's folder, or on Archil's serverless exec
2310
+ in Mode 2; in Mode 1 a run with no such computer has the file tools alone. The run is `queued` until its first message shows; while the process runs, the
1738
2311
  timeline comes from its door's events through `@parcha/pi-durable-agent/timeline`. Once the run is idle and its
1739
2312
  newest row is the agent's answer, the server sends the process SIGTERM. A model error ends it `failed`
1740
2313
  (`run_failed`). A run whose `max_cost_usd` cannot buy its next request is paused, `input_required` and `waiting`
@@ -1762,10 +2335,14 @@ left out: 2 sessions still being written: they come in next time
1762
2335
  workflow run's model nodes), and the server carries the run back, every run of both kinds: `carryBack` records its
1763
2336
  state, cost and a summary in the store (an agentic run's answer; a workflow run's `workflowCarry`, its completed
1764
2337
  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.
2338
+ page says `final`. v2's `cancelled` is the store's `stopped`; a workflow that escalated ends `completed`, its work
2339
+ done and waiting for a person's review: `error` is null and `review` is `{kind, node, reason, at}`, in the run and in the
2340
+ lists. In this release `kind` and `node` are always null: the store keeps only the escalation's summary (`reason`)
2341
+ and the run's end (`at`). Every other run's
2342
+ `review` is null. `GET /v2/stats` counts it in `needs_review`, never in `failed`.
1767
2343
  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
2344
+ that still serves the run is supervised again, by the holder its row names (its pid, its start, its door); a run
2345
+ that already ended is carried
1769
2346
  back; a run whose process is gone before it ended is opened again on its directory and resumes from its store (an
1770
2347
  agentic run waiting for an answer waits without one, until a message). A carry back that finds the store held by
1771
2348
  another writer is tried again with backoff, and at the next start.
@@ -1786,7 +2363,7 @@ definition that sets it keeps it on its revision, `false` included, and an edit
1786
2363
  that never sets it stores nothing, so its revision id is the one it had before the switch. The server's `--learning off`
1787
2364
  turns learning off for every run it starts, whatever the agent says.
1788
2365
 
1789
- An agent that learns has a learning folder, `learning/` in its home (`DATA/homes/<key>/learning/`), in Claude Code's
2366
+ 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
2367
  auto-memory format:
1791
2368
 
1792
2369
  - `MEMORY.md`, the index a run reads, one line per active note: `- [name](file.md) — description`, built by the server;
@@ -1852,20 +2429,19 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
1852
2429
  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
2430
  own, each call node `via: "tool"` on a tool the agent has, its paid requests booked under
1854
2431
  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
2432
+ models. Its model requests are the run's, under its cap: on pi, side requests of the run's models labelled
2433
+ `learned_workflow` on its timeline; on claude-agent, codex and opencode, requests on the run's one route, the session's
2434
+ model proxy, under a key of the run's own: the same body rules, provider, key, price and cap as the harness's own
2435
+ requests, booked on the session's records labelled `learned_workflow`. So they go wherever the harness's go (the
2436
+ operator's gateway at ANTHROPIC_BASE_URL or AGENT_MODEL_BASE_URL, OpenRouter, the vendor's API), and every run is
2437
+ offered the workflows its pin names. A call a crash cut off is answered interrupted, never run again. The tool gate holds
1862
2438
  `learned_workflow` like any tool: its settings key is `learned_workflow`, allowed by default (the agent's own graded
1863
2439
  workflow, each node checked), and tool settings may set it to ask (the run parks until an owner answers) or deny.
1864
2440
 
1865
2441
  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
2442
  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
2443
  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.
2444
+ git 2.32 or later (what learning's own git calls need) is one such fault, said once on stderr.
1869
2445
 
1870
2446
  ### What a run learns
1871
2447
 
@@ -1884,7 +2460,10 @@ As the run settles, before it reads ended and before a follow-up can open it aga
1884
2460
  answered, the whole text of each of its messages, and what the user said in the run, in `runs/<id>/learning-turn.json`.
1885
2461
  Once the run has ended, in the agent's queue, the server reads the notes from that answer alone (`parseReflection`, in
1886
2462
  `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`
2463
+ block, a block with no file name, or one name given twice with other words) is `unparsed`, nothing kept. A block opens
2464
+ with the fence asked for (```` ```note ```` or four backticks for a note, four for a skill or a draft) and runs to the
2465
+ next line that is that fence; a shorter fence is text, a longer one an example, and an opening never closed is left out
2466
+ alone. `checkProposal`
1888
2467
  (`src/learn/check.ts`) then refuses, before anything is written anywhere, a note that reuses an existing note's name, a
1889
2468
  path that is not a `.md` file at the top, a bad name, front matter out of shape or setting `status`, a `supersedes`
1890
2469
  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 +2503,8 @@ The run's `learning` (on `GET /runs/{run_id}`, and `{state, reason, detail}` in
1924
2503
  characters and no time) says how it went: `seeded`, then
1925
2504
  `reflecting` during the turn and until what it answered is checked, `proposed` while it is graded, and `merged`, or
1926
2505
  `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
2506
+ `reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`; a run
2507
+ record or ledger line with any other reason is not counted). It is `null` for a
1930
2508
  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
2509
  workflow's or an imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2
1932
2510
  notes.", "Looking back on this run…", "Checking 1 new note…", "Learned: Check units (replaces 1 older note)", "Learned:
@@ -1939,21 +2517,28 @@ grader's verdict), cut of the server's secrets as they are then before the words
1939
2517
  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
2518
  timeline has one row of kind `learning` whose summary is that detail.
1941
2519
 
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/`,
2520
+ Four more fields say what the run was given, read, learned and holds for the owner's OK (`learning/2`), on its read and
2521
+ in run lists alike, each absent when it holds no note: `given`, `[{file, name}]`, the notes it started with (each its
2522
+ `# Learned` section names, whole or as an index line naming its file, as it was seeded; absent when it started with
2523
+ nothing learned); `read`, `[{file, name}]`, the notes its job read from `.learning/` (absent when it opened no note file),
1944
2524
  found once as the run settles from its timeline (each `read` call on any harness whose result was a success, of a note
1945
2525
  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
2526
  `bash`'s `cat`) and kept in `serve.json`, so a list never reads a timeline; `learned`, `[{file, name, supersedes}]`, the
1947
2527
  notes its merge added, once `merged`; and `pending`, `[{file, name}]`, the notes its merge holds for the owner's OK, once
1948
2528
  `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]`.
2529
+ `[redacted]`. Whether a run applied a note is not measured: `given` and `read` say what it had and what it opened. Each
2530
+ note on the agent's learning view and notes page counts its runs of each, `runs: {given, read}`, over the runs the server
2531
+ knows (held ones from memory, ended ones from the learning ledger).
1950
2532
 
1951
2533
  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
2534
+ state, reason, at, cost, tokens, seed_notes, given, read, answered_at, job_cost_usd, look_back_usd}` (`cost` and
2535
+ `tokens` the grade's, null when unknown, 0 when nothing was graded; `seed_notes` how many notes the run started from;
2536
+ `given` and `read` the files of the notes it was given and read, each absent when there are none; once it looked back,
2537
+ `answered_at` and `job_cost_usd`, when its job's answer was final and what it had cost then; `look_back_usd` what
1955
2538
  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
2539
+ its next start. A run's notes are the one part that moves after its end (a follow-up reads another note): a line
2540
+ `{run, agent, notes: true, given, read}` then says them anew, the latest one winning, and counts neither the run nor its
2541
+ costs again. `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
1957
2542
  `agent`, from that ledger and from the runs the server holds (`in_progress`), never opening a run's files; the
1958
2543
  `learning` meter on `GET /usage` reads the same lines.
1959
2544
 
@@ -2009,19 +2594,22 @@ with the token, an archived agent's too:
2009
2594
  too (`Approved-Via: console`). The learning view gives each item `last_change` (`{kind, by, at}`: `approved`,
2010
2595
  `edited`, `created`, `retired` or `restored` by a `person`, or `learned` by a `run`) and each retired one `retired`
2011
2596
  (`{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
2597
+ - `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
2598
  each new note, `{file, keep, question, why}`, `question` the rubric's question a dropped note failed, the checker's
2014
2599
  problems, what the grade cost), `null` for a run that does not learn; `verdict` is `null` until a grade ran.
2015
2600
  `GET /runs/{run_id}/learning/diff`: a merged run's merge commit against its parent, else its proposal against its
2016
2601
  seed, each file's patch as git writes it from the first `@@`, or `withheld` (`too_large`, `secret`).
2017
2602
 
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
2603
+ Every read is the folder's snapshot (`.agentrun/snapshot.json`, written last by the same exec as each commit to
2604
+ `main`), the files it names, each checked against its blob id (a file that is not, read twice, is a write in flight:
2605
+ `503`), and a merge's `.agentrun/diffs/<run>.json`, through the folder's file API: no git and no exec. Every text it
2606
+ 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
2607
  `[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
2608
+ `Location` leaves it out, while its route still answers the real name to a caller who knows it. A page reads only its
2609
+ own notes' files, each once at its blob; a log page reads the snapshot alone (it keeps the newest 200 changes). A
2610
+ cursor reads at the main it names while this server still holds that snapshot, else as the first page of `main` now.
2611
+ Every write to `main` (a run's merge, a person's edit, create, retire, approve or restore) is one exec of the learning
2612
+ 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
2613
  followed: a read or a write there answers `500`, and nothing is written.
2026
2614
 
2027
2615
  ### Approving a note that waits
@@ -2039,16 +2627,49 @@ log shows `by: {user: true, via: "console"}` at the commit's time, never the not
2039
2627
 
2040
2628
  ## Spend cap
2041
2629
 
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,
2630
+ 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
2631
  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
2632
  definition's `max_cost_usd` above 0 sets that default, and 0 clears it (no default); anything else is `422`. An edit that
2045
2633
  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
2634
+ spend limit. A workflow definition keeps one the same way. The cap is checked in the run's own process
2047
2635
  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
2636
+ what each request still in flight is held at, plus what this request is expected to cost must stay within it, or the
2637
+ request is not sent and the run pauses ([below](#a-run-paused-at-its-cap)). A request costs its input, plus the output it
2638
+ 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
2639
+ `cap_mode`: the run's own (`POST /agents/{id}/runs` with `cap_mode`), else its agent's (a definition's `cap_mode`, kept by
2640
+ an edit that leaves it out), else `expected`; only a run with a cap takes one (`422 not_allowed` otherwise).
2641
+
2642
+ - `expected`: priced from the previous request of its conversation, as that request's usage reported it. The input it
2643
+ read from the cache or wrote to it (`cache_read_input_tokens` and `cache_creation_input_tokens` on Anthropic's API,
2644
+ `input_tokens_details.cached_tokens` on the Responses API) at the cache-read price, if that request ended less than 4
2645
+ minutes before (Anthropic keeps a cache 5); the rest (its input after the cache, plus what the conversation grew by
2646
+ since, one token per byte) at the higher of the input and cache-write prices. With no previous request in hand, or one
2647
+ older than 4 minutes, all of the input at that price. On claude-agent, codex and opencode the previous request is the
2648
+ session's last on the same model in the run's current process, so a run's first request after a restart is priced
2649
+ with nothing cached; on pi it is the conversation's last answer. Output never passes the cap (below); a request that
2650
+ misses the cache can, by at most its bound: its input at full price less its input expected. The run's
2651
+ `cost.overshoot_bound_usd` serves the bound of the requests in flight. A request's real cost is always booked, never
2652
+ 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
2653
+ most $Y).`, and its next request is refused, so it pauses at its cap as usual. A request whose cost never comes in (cut,
2654
+ stopped, lost) counts at what it was held at, its expected cost, in this process and after a restart alike.
2655
+ - `strict`: every input token at the higher of the input and cache-write prices (the provider may bill any of the input as
2656
+ a cache write), the worst case: no request passes the cap, and a run whose requests read the cache pauses well before
2657
+ it has spent its cap.
2658
+
2659
+ 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
2660
+ in flight are held at) is under three times the run's typical request, the next request of the run's own model carries
2661
+ "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
2662
+ row ("AgentRun: About $X left …"). The typical request is the median of the run's own model's priced requests after the
2663
+ first (the first writes the cache), else that one, else, while nothing is priced, the next request at its input and a
2664
+ 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
2665
+ another model and paid tools count in what is left, never in the typical request. Told while nothing is priced (a small
2666
+ cap, due at the run's first request), the words say the budget instead, on every harness: "This run's budget is about
2667
+ $X, enough for little work: answer as soon as you can." On pi the words go into that one request's context;
2668
+ on claude-agent, codex and opencode the model proxy adds them to the body (after everything the CLI sent, so its cached
2669
+ prefix is unchanged). Neither CLI nor pi keeps them in its transcript, and no message is queued, so nothing runs after
2670
+ the model's answer. Once per cap, across restarts; a raise re-arms it.
2671
+
2672
+ Under a cap each request is limited to the
2052
2673
  output tokens what is left of the cap can buy, thinking included, never more than it asks for or than the model's
2053
2674
  ceiling (its max output tokens, else its context window, clamped to what the window leaves): on pi through the request's
2054
2675
  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 +2680,8 @@ where thinking takes one (Anthropic's, 1,024, the budget squeezed to it at the l
2059
2680
  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
2681
  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
2682
  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
2683
+ the proxy measures each request's body. A request in flight holds what it was admitted at until it answers, so requests
2684
+ 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
2685
  survives a restart, plus each response since, and with them each charge a paid tool booked (`monid.run`, which is itself
2065
2686
  refused once the spend reaches the cap; see [monid](#tools)).
2066
2687
 
@@ -2070,7 +2691,7 @@ it up to), pi-browser's idle window before it releases a session nobody calls (1
2070
2691
  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
2692
  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
2693
  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
2694
+ (`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
2695
  the run's session is released.
2075
2696
  A session's first charge moves one stretch of its call's hold to the session, held until its release is booked, which
2076
2697
  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 +2762,14 @@ the same: a capped run stopped and sent another message, or opened again after i
2141
2762
  allows. A cut request from a store written before serve kept the figure has none, and is a spend no one knows.
2142
2763
 
2143
2764
  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
2765
+ no cap fixes, its error), as a person who has never seen a model request reads them: "Not sent: the next step needs at
2766
+ 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:
2767
+ "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
2768
+ $0.48 to continue." What was spent, and what steps still running hold (named when it is a cent or more), read to the
2769
+ nearest cent ($0.0237416 reads $0.02); the exact amounts are `pending.spent_usd`. The cap to raise to is what was
2770
+ spent, what steps still running hold, and the next step's least, rounded up to the cent so that it is enough. The words
2771
+ name no model. The refusal's timeline row is an `error` row with
2772
+ `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
2773
  retry reads only an error's text, and takes "out of budget" as final whatever digits the words hold. A request the cap
2151
2774
  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
2775
  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 +2779,19 @@ the $0.15 left of the run's $0.50 cap could buy."
2156
2779
 
2157
2780
  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
2781
  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}`:
2782
+ `waiting`, `error` null, with `pending: {kind: "budget", cap_usd, spent_usd, needs_usd, least_cap_usd, suggested_cap_usd, said, at}`:
2160
2783
  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
2784
+ needs (a cap above their sum sends it), the least cap that sends it, the raise it is offered, the refusal's words above,
2785
+ and when it came. `least_cap_usd` is the very figure the words name ("Raise the cap to at least $X"), in whole
2786
+ cents and above the cap, carried from the refusal that wrote them, so a client shows it without parsing the sentence. The
2162
2787
  offered raise, `suggested_cap_usd`, is `spent_usd` + 10 × `needs_usd` rounded up to a whole dollar, and always above the
2163
2788
  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
2789
  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
2790
  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
2791
+ 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
2792
+ ending `:note`, so it is no message) marked `paused` (never an `error` row; it stays once the cap is raised, as the
2793
+ run's history), then a waiting row: "Waiting for you to raise the
2794
+ cap", and no more: the words are `pending.said`'s, which a client shows once. The
2167
2795
  webhook's `run.needs_input` says `pending.kind: "budget"`. Its process is let go while it waits (SIGTERM: it drains and
2168
2796
  releases the run), so a paused run holds no place; a server started again reads it paused from its store. A paused
2169
2797
  process that does not let go within the drain timeout (`--drain-timeout`, 30 s by default) is killed, and the run ends
@@ -2182,14 +2810,16 @@ message, starts a turn that is judged as any other. A paid call refused because
2182
2810
  still ends the run `failed`.
2183
2811
 
2184
2812
  `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
2813
+ cap, its last raise included, by more than a float's tail (1e-9; `422` otherwise, and for a run with no cap;
2814
+ `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
2815
  answers as the first did. The run's serve.json keeps the raise before any answer, with each raise in `cap_raised`, so its
2188
2816
  next process opens under it, as does a server started again; a raise it could not keep is not taken (an error answers it),
2189
2817
  and the same raise again is taken anew. A run paused at its cap goes on: the answer is `{run_id, max_cost_usd, resumed: true,
2190
2818
  message_id, status, state}` at once, and the pause gets one follow-up turn, "The cap was raised to $2; continue the
2191
2819
  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
2820
+ new cap. From the moment the raise is taken, the run reads `queued` (state `working`), in the answer's `status` and in
2821
+ every read after it, until the follow-up's turn runs: nothing waits on a person, so it is never `input_required` with no
2822
+ `pending` meanwhile. A second raise before it goes raises the cap it names and answers the same `message_id`. It is sent once: a
2193
2823
  server stopped before it went, or between starting its process and sending it, sends it when it starts again. One that
2194
2824
  cannot be sent is tried again (after 1 s, then 3 s); after 3 tries the run ends `failed`, saying the cap was raised but
2195
2825
  the run could not be sent on. The follow-up shows in the run's timeline as the server's, "AgentRun: The cap was raised…", never as the
@@ -2204,7 +2834,7 @@ picking it is refused, and on `auto` it searches through Parallel on the server'
2204
2834
  keyless Exa, as a capped codex run does; pi's own search request is held at its context
2205
2835
  plus 125,000 (5 searches) and its most fee, 5 searches at $0.01. What the request
2206
2836
  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`).
2837
+ one timeline row saying by how much (`Spent $X, $Y over the run's cap of $Z`, in cents).
2208
2838
 
2209
2839
  The server also checks the run's cost after each response, as a backstop, and stops a run whose cost passed its cap.
2210
2840
  Either way the run keeps the answer it paid for: a run the cap stopped has `result: {output: null, final_answer}`, the
@@ -2215,6 +2845,34 @@ response reported no price or a request was cut before its end (a stop, a cancel
2215
2845
  but a request of unknown price is unknown, never $0. A stopped request shows `null` whether or not its cap counted it at
2216
2846
  its held worst case.
2217
2847
 
2848
+ ### A workflow run under its cap
2849
+
2850
+ A workflow run is capped by the same checks, in its own process, each before the paid step is sent:
2851
+
2852
+ | Step | Held at | Where |
2853
+ |---|---|---|
2854
+ | A model node's request | its expected cost, as an agentic run's request | the run's models (`cap.ts` capModels) |
2855
+ | A call node's `llm` call | the same | the same, as a side request |
2856
+ | A call node's paid tool call (Parallel's search or extract) | its fee | `paidCall`, as an agentic run's |
2857
+ | A decision on Parallel | its list price for one request, $0.001 | before the driver admits it (`decision-cap.ts`) |
2858
+ | 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 |
2859
+ | 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 |
2860
+
2861
+ 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
2862
+ the cap has no room for is not sent and waits where it stands: the run is `input_required`, state `waiting`, with
2863
+ `pending.kind` budget and `pending.node` the node's label. A model node's request waits unsent; a call node's call
2864
+ ends its effect held, sending nothing, and goes again as a new effect once raised, never as the tool's own failure, which
2865
+ a map that collects failed items would take for an item's; a decision waits before the driver admits it, so it is never
2866
+ a request asked and unanswered. What a call node waited is not counted against its deadline. A pause holds the run's
2867
+ process for 10 minutes, then lets it go (nothing in flight but the waits): the run stays paused, and no process is
2868
+ started for it. `PATCH /runs/{run_id}` raises the cap as for an agentic run, with no follow-up turn: a waiting process
2869
+ judges its step again under the new cap, and a run whose process was let go is opened again under it, resuming from its
2870
+ journal, so no completed node is sent again (`resumed: true`, no `message_id`). A capped start is refused before anything is sent, as an
2871
+ 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
2872
+ OpenRouter Decisions model the catalog lists no price for: `409 agent_not_runnable`, each in `error.fields` with the
2873
+ node's label and its fix. A step no cap fixes all the same (a spend no one knows) ends the run `failed`,
2874
+ `spend_cap_reached`, in the cap's words, after the node's label.
2875
+
2218
2876
  ## The faux model
2219
2877
 
2220
2878
  `--faux MODULE` loads `MODULE` in each run's process. Its default export is called for every model request with the
@@ -2228,8 +2886,8 @@ export default function reply(context, faux) {
2228
2886
  }
2229
2887
  ```
2230
2888
 
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
2889
+ `startServe({ faux, fauxBrowser, fauxWeb })` also names modules whose default exports give
2890
+ 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
2891
  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
2892
  undici (a table of names and pages, `test/fixtures/faux-web.mjs`), and, as `fauxMonid`, the fetch the monid tools send
2235
2893
  through in place of monid's API (`test/fixtures/faux-monid.mjs`). Each is honored only with `faux`.
@@ -2265,6 +2923,19 @@ carries no cost at all, as from a provider that does not price the model. The te
2265
2923
  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
2924
  run's process gets over its pipe and its tools and model never see. Anyone holding the vendor's key can open that
2267
2925
  context or profile there.
2926
+ - A run's live browser view is a full-control credential for its session: once taken over, it drives the browser. Its
2927
+ 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
2928
+ the owner's answer to `GET /runs/{id}/browser`, which takes the owner's password session alone, as the hand-back does. The
2929
+ 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
2930
+ framed by this server's own origin alone; outside a take-over its input is dropped by the run before the browser; the
2931
+ vendors' own live-view links never leave the run's process.
2932
+ - The viewer's code always comes from this server: its page, script and style are the files of the pi-browser this server has
2933
+ installed, served under `script-src 'self'`, never anything a run's port answers. A run's port only ever carries the
2934
+ viewer's WebSocket, which is data, so whatever answers on a run's port never runs script on the console's origin.
2935
+ - 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,
2936
+ hold 15 minutes of session time at the provider's price (once per session, shared by a take-over and an ask on it),
2937
+ refused in the cap's words without room. A take-over that steady input keeps alive past 15 minutes is held again every
2938
+ 15 minutes; with no room the browser goes back to the agent, in the cap's words.
2268
2939
  - It binds 127.0.0.1 by default, and there refuses a request whose `Host` names something other than this machine
2269
2940
  (DNS rebinding): `localhost`, `127.0.0.1`, `[::1]`, the `AGENTRUN_PUBLIC_URL` name and each `--allow-host` name are
2270
2941
  served, on any port, so a tunnel (`ssh -L 8080:localhost:7340`) or a proxy in front works; any other name is `403`, a
@@ -2273,9 +2944,13 @@ carries no cost at all, as from a provider that does not price the model. The te
2273
2944
  It sends no CORS headers, so a page on another origin cannot read an answer.
2274
2945
  - Every route but `GET /capabilities` needs `Authorization: Bearer <the token>`, compared in constant time, or the
2275
2946
  browser's cookie under the rules of [the console](#the-console). The console's own files (its HTML, scripts, styles
2276
- and fonts) hold no data; everything it shows comes through those routes. It loads nothing from the network, and its
2277
- 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
2947
+ and fonts) hold no data; everything it shows comes through those routes. It loads one thing from the network: on
2948
+ Settings → Keys, each provider's icon, from Google's favicon service (`www.google.com/s2/favicons`, which redirects
2949
+ to `t0`-`t3.gstatic.com`). The request names the provider's public site (`chatgpt.com`) and carries no referrer,
2950
+ no cookie of this server's and nothing of yours; Google sees the browser's address and which providers the page
2951
+ lists. Offline, or with those hosts blocked, the page shows a key icon instead. The CSP's `img-src` allows those
2952
+ five hosts; everything else is this origin only.
2953
+ - Each run's door listens on loopback and takes only that run's own door token (`DIR/disk/agents/<agent>/runs/<id>/door-token`, 0600, made
2279
2954
  at its first launch); a run's process an older server started keeps the server-wide one (`DIR/.door-token`).
2280
2955
  - A run's process gets the server's environment (the `AGENT_MODEL` variables among it) without the server's token or any
2281
2956
  key: no `AGENTRUN_TOKEN`, no `AGENTRUN_API_KEY`, no variable whose value is the token, and no variable named like a key
@@ -2336,6 +3011,9 @@ carries no cost at all, as from a provider that does not price the model. The te
2336
3011
  value under another name.
2337
3012
  - The 4,096-byte pipe limit stays until the launcher writes the pipe from a background subshell that blocks until the
2338
3013
  server has read it.
3014
+ - The browser's evidence is numbered from the highest number the run's `evidence/` holds when its browser first files
3015
+ there, through the run's Workspace, which has no exclusive create. One browser per run files there, so two never pick
3016
+ one number; two filing into one run's `evidence/` at the same moment could.
2339
3017
 
2340
3018
  ## Test
2341
3019