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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/README.md +339 -179
  3. package/dist/adapters.d.ts +15 -2
  4. package/dist/adapters.js +34 -2
  5. package/dist/agent-rows.d.ts +3 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +25 -5
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +90 -8
  13. package/dist/archil-settings.js +150 -14
  14. package/dist/attach-images.d.ts +15 -0
  15. package/dist/attach-images.js +59 -0
  16. package/dist/background.d.ts +0 -6
  17. package/dist/background.js +0 -28
  18. package/dist/bash-read-only.d.ts +13 -0
  19. package/dist/bash-read-only.js +77 -0
  20. package/dist/box-image.d.ts +1 -97
  21. package/dist/box-image.js +4 -284
  22. package/dist/box-paths.d.ts +2 -7
  23. package/dist/box-paths.js +7 -13
  24. package/dist/box-settings.d.ts +0 -11
  25. package/dist/box-settings.js +4 -29
  26. package/dist/browser-commands.js +1 -1
  27. package/dist/browser-computer.d.ts +47 -3
  28. package/dist/browser-computer.js +286 -18
  29. package/dist/browser-cost.d.ts +2 -2
  30. package/dist/browser-cost.js +6 -4
  31. package/dist/browser-person.d.ts +19 -2
  32. package/dist/browser-person.js +55 -6
  33. package/dist/browser-wait-ended.d.ts +23 -0
  34. package/dist/browser-wait-ended.js +42 -0
  35. package/dist/cap.d.ts +19 -44
  36. package/dist/cap.js +31 -77
  37. package/dist/cli.js +36 -27
  38. package/dist/computer-keys.d.ts +20 -10
  39. package/dist/computer-keys.js +36 -57
  40. package/dist/computer-routes.d.ts +1 -4
  41. package/dist/computer-routes.js +3 -5
  42. package/dist/computer-setting.d.ts +8 -5
  43. package/dist/computer-setting.js +91 -26
  44. package/dist/computer-view.d.ts +11 -2
  45. package/dist/computer-view.js +2 -1
  46. package/dist/computers.d.ts +54 -8
  47. package/dist/computers.js +101 -22
  48. package/dist/console/assets/index-BI4Byidu.js +550 -0
  49. package/dist/console/assets/index-C19gUF2n.css +1 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/content-filter.d.ts +7 -0
  52. package/dist/content-filter.js +23 -0
  53. package/dist/decision-cap.d.ts +7 -29
  54. package/dist/decision-cap.js +3 -94
  55. package/dist/docker-daemon.d.ts +2 -2
  56. package/dist/docker-daemon.js +2 -2
  57. package/dist/errors.d.ts +1 -0
  58. package/dist/errors.js +8 -5
  59. package/dist/explain.js +3 -1
  60. package/dist/faux-computers.js +4 -0
  61. package/dist/files.d.ts +1 -9
  62. package/dist/files.js +1 -9
  63. package/dist/github-connection.js +25 -7
  64. package/dist/github-faux.d.ts +26 -0
  65. package/dist/github-faux.js +76 -0
  66. package/dist/github.d.ts +28 -4
  67. package/dist/github.js +46 -10
  68. package/dist/gpu-words.d.ts +14 -0
  69. package/dist/gpu-words.js +21 -0
  70. package/dist/graph-served.d.ts +5 -3
  71. package/dist/graph-served.js +14 -6
  72. package/dist/graph-view.d.ts +2 -0
  73. package/dist/graph-view.js +29 -2
  74. package/dist/handed-values.d.ts +1 -1
  75. package/dist/handed-values.js +1 -1
  76. package/dist/harness-install.d.ts +60 -3
  77. package/dist/harness-install.js +322 -34
  78. package/dist/harness-opencode/harness.js +0 -1
  79. package/dist/harness-opencode/host/policy.js +2 -2
  80. package/dist/harness.js +1 -1
  81. package/dist/host-tools.d.ts +8 -9
  82. package/dist/host-tools.js +7 -7
  83. package/dist/index.d.ts +2 -3
  84. package/dist/index.js +2 -2
  85. package/dist/key-refusal.d.ts +1 -1
  86. package/dist/key-refusal.js +2 -2
  87. package/dist/learn/check.d.ts +10 -2
  88. package/dist/learn/check.js +126 -8
  89. package/dist/learn/commit.d.ts +40 -6
  90. package/dist/learn/commit.js +164 -20
  91. package/dist/learn/folder.d.ts +11 -3
  92. package/dist/learn/folder.js +40 -16
  93. package/dist/learn/grade.d.ts +22 -2
  94. package/dist/learn/grade.js +127 -19
  95. package/dist/learn/index.d.ts +2 -2
  96. package/dist/learn/index.js +2 -2
  97. package/dist/learn/learning.sh +11 -13
  98. package/dist/learn/notes.d.ts +17 -3
  99. package/dist/learn/notes.js +19 -6
  100. package/dist/learn/reflect.d.ts +5 -2
  101. package/dist/learn/reflect.js +48 -32
  102. package/dist/learn/skills.d.ts +52 -5
  103. package/dist/learn/skills.js +104 -21
  104. package/dist/learned-nodes.d.ts +18 -0
  105. package/dist/learned-nodes.js +8 -0
  106. package/dist/learned-workflow.d.ts +27 -13
  107. package/dist/learned-workflow.js +110 -38
  108. package/dist/learning-cost.d.ts +79 -0
  109. package/dist/learning-cost.js +69 -0
  110. package/dist/learning-routes.d.ts +48 -2
  111. package/dist/learning-routes.js +99 -28
  112. package/dist/learning-run.d.ts +7 -5
  113. package/dist/learning-run.js +9 -6
  114. package/dist/learning-words.d.ts +3 -0
  115. package/dist/learning-words.js +6 -2
  116. package/dist/learning.d.ts +13 -28
  117. package/dist/learning.js +4 -18
  118. package/dist/llm.d.ts +4 -1
  119. package/dist/llm.js +4 -2
  120. package/dist/mcp-gateway.d.ts +6 -0
  121. package/dist/mcp-gateway.js +11 -1
  122. package/dist/mcp-probe.d.ts +8 -1
  123. package/dist/mcp-probe.js +62 -20
  124. package/dist/mcp-secret-writes.js +4 -0
  125. package/dist/mcp-servers-store.d.ts +12 -12
  126. package/dist/mcp-servers-store.js +8 -3
  127. package/dist/model.d.ts +8 -5
  128. package/dist/model.js +14 -6
  129. package/dist/openapi.d.ts +2 -0
  130. package/dist/openapi.js +236 -55
  131. package/dist/owner.d.ts +0 -1
  132. package/dist/owner.js +0 -2
  133. package/dist/pause.d.ts +2 -19
  134. package/dist/pause.js +5 -74
  135. package/dist/place-offers.d.ts +97 -0
  136. package/dist/place-offers.js +206 -0
  137. package/dist/place.d.ts +9 -13
  138. package/dist/place.js +22 -32
  139. package/dist/port-models.d.ts +12 -4
  140. package/dist/port-models.js +31 -9
  141. package/dist/print.d.ts +1 -8
  142. package/dist/print.js +1 -14
  143. package/dist/propose.d.ts +3 -0
  144. package/dist/propose.js +25 -19
  145. package/dist/run-cut.d.ts +5 -0
  146. package/dist/run-cut.js +19 -0
  147. package/dist/run-db.js +3 -3
  148. package/dist/run-launch.d.ts +18 -3
  149. package/dist/run-launch.js +11 -5
  150. package/dist/run-learning-served.d.ts +12 -1
  151. package/dist/run-manifest.d.ts +2 -2
  152. package/dist/run-manifest.js +2 -2
  153. package/dist/run-reads-over-store.d.ts +4 -2
  154. package/dist/run-reads-over-store.js +10 -8
  155. package/dist/run-secrets.js +3 -3
  156. package/dist/run-timeline-served.js +60 -38
  157. package/dist/run-view.d.ts +35 -16
  158. package/dist/run-view.js +64 -35
  159. package/dist/runnable.d.ts +6 -3
  160. package/dist/runnable.js +20 -4
  161. package/dist/runner/adapter-loop.d.ts +46 -5
  162. package/dist/runner/adapter-loop.js +381 -56
  163. package/dist/runner/adapter-run-spec.d.ts +46 -4
  164. package/dist/runner/adapter-run-spec.js +200 -45
  165. package/dist/runner/adapters/pi.d.ts +39 -3
  166. package/dist/runner/adapters/pi.js +124 -29
  167. package/dist/runner/beside.d.ts +8 -0
  168. package/dist/runner/beside.js +24 -2
  169. package/dist/runner/claim-secrets.d.ts +6 -0
  170. package/dist/runner/claim-secrets.js +15 -1
  171. package/dist/runner/cli-run-spec.d.ts +10 -0
  172. package/dist/runner/cli-run-spec.js +207 -64
  173. package/dist/runner/commands.d.ts +5 -1
  174. package/dist/runner/commands.js +3 -3
  175. package/dist/runner/conformance/harness.d.ts +1 -1
  176. package/dist/runner/conformance/harness.js +13 -10
  177. package/dist/runner/github-app.d.ts +7 -2
  178. package/dist/runner/github-app.js +46 -15
  179. package/dist/runner/harness-loops.d.ts +6 -1
  180. package/dist/runner/harness-loops.js +24 -1
  181. package/dist/runner/journal-kinds.d.ts +53 -7
  182. package/dist/runner/journal-kinds.js +29 -1
  183. package/dist/runner/learning-end.d.ts +15 -0
  184. package/dist/runner/learning-end.js +113 -20
  185. package/dist/runner/learning-factory.js +6 -2
  186. package/dist/runner/learning-loop.d.ts +75 -1
  187. package/dist/runner/learning-loop.js +215 -22
  188. package/dist/runner/learning-seed.d.ts +8 -0
  189. package/dist/runner/learning-seed.js +7 -1
  190. package/dist/runner/loop-contract.d.ts +12 -0
  191. package/dist/runner/loop-contract.js +6 -0
  192. package/dist/runner/loop.d.ts +5 -1
  193. package/dist/runner/loop.js +20 -0
  194. package/dist/runner/main.d.ts +9 -4
  195. package/dist/runner/main.js +38 -13
  196. package/dist/runner/mcp-claim.d.ts +7 -0
  197. package/dist/runner/mcp-claim.js +35 -2
  198. package/dist/runner/mcp-github.d.ts +15 -4
  199. package/dist/runner/mcp-github.js +55 -11
  200. package/dist/runner/mcp-run.d.ts +2 -0
  201. package/dist/runner/mcp-run.js +2 -0
  202. package/dist/runner/metrics.d.ts +18 -1
  203. package/dist/runner/metrics.js +81 -1
  204. package/dist/runner/model-route.d.ts +6 -0
  205. package/dist/runner/model-route.js +5 -2
  206. package/dist/runner/pr-checkout.d.ts +59 -0
  207. package/dist/runner/pr-checkout.js +176 -0
  208. package/dist/runner/reflect-hook.d.ts +1 -0
  209. package/dist/runner/reflect-hook.js +3 -3
  210. package/dist/runner/runner.js +136 -19
  211. package/dist/runner/spec-holds.d.ts +13 -3
  212. package/dist/runner/spec-holds.js +13 -10
  213. package/dist/runner/store-port.d.ts +4 -1
  214. package/dist/runner/store-secrets.js +17 -1
  215. package/dist/runner/subagent.d.ts +44 -0
  216. package/dist/runner/subagent.js +188 -0
  217. package/dist/runner/workflow-host.d.ts +25 -4
  218. package/dist/runner/workflow-host.js +26 -4
  219. package/dist/runner/workflow-loop.d.ts +9 -3
  220. package/dist/runner/workflow-loop.js +17 -10
  221. package/dist/runner/workflow-spec.d.ts +28 -13
  222. package/dist/runner/workflow-spec.js +247 -102
  223. package/dist/runs-over-store.d.ts +18 -7
  224. package/dist/runs-over-store.js +149 -31
  225. package/dist/seal-key.d.ts +0 -2
  226. package/dist/seal-key.js +0 -2
  227. package/dist/sealing.js +1 -2
  228. package/dist/secret-cut.d.ts +1 -1
  229. package/dist/secret-cut.js +1 -1
  230. package/dist/server-lock.js +4 -5
  231. package/dist/server.d.ts +49 -63
  232. package/dist/server.js +429 -230
  233. package/dist/stop-signals.d.ts +4 -2
  234. package/dist/stop-signals.js +5 -3
  235. package/dist/store/agent-body.d.ts +14 -3
  236. package/dist/store/agent-body.js +22 -8
  237. package/dist/store/deadline.d.ts +18 -0
  238. package/dist/store/deadline.js +49 -0
  239. package/dist/store/index.d.ts +3 -3
  240. package/dist/store/index.js +2 -2
  241. package/dist/store/journal/storage.js +2 -1
  242. package/dist/store/postgres/connection.d.ts +4 -0
  243. package/dist/store/postgres/connection.js +64 -13
  244. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  245. package/dist/store/schema.d.ts +2 -1
  246. package/dist/store/schema.js +11 -8
  247. package/dist/store/seal.d.ts +13 -0
  248. package/dist/store/seal.js +19 -0
  249. package/dist/store/sqlite/connection.d.ts +5 -0
  250. package/dist/store/sqlite/connection.js +88 -82
  251. package/dist/store/sqlite/run-patch.d.ts +18 -2
  252. package/dist/store/sqlite/run-patch.js +31 -2
  253. package/dist/store/sqlite/store.js +65 -11
  254. package/dist/store/store.d.ts +62 -12
  255. package/dist/store/store.js +22 -1
  256. package/dist/store-reads/analytics.js +3 -2
  257. package/dist/store-reads/cap.d.ts +1 -3
  258. package/dist/store-reads/cap.js +8 -6
  259. package/dist/store-reads/decisions.d.ts +2 -2
  260. package/dist/store-reads/decisions.js +3 -6
  261. package/dist/store-reads/journal.js +83 -15
  262. package/dist/store-reads/learning.d.ts +73 -3
  263. package/dist/store-reads/learning.js +232 -9
  264. package/dist/store-reads/runs.d.ts +6 -4
  265. package/dist/store-reads/runs.js +17 -10
  266. package/dist/store-reads/stats.js +5 -1
  267. package/dist/store-view.d.ts +15 -1
  268. package/dist/store-view.js +88 -29
  269. package/dist/template-eval.js +2 -1
  270. package/dist/templates.d.ts +73 -4
  271. package/dist/templates.js +113 -23
  272. package/dist/timeline/timeline.d.ts +11 -1
  273. package/dist/timeline/timeline.js +19 -4
  274. package/dist/tool-blurbs.js +1 -0
  275. package/dist/tool-budget.d.ts +26 -0
  276. package/dist/tool-budget.js +56 -0
  277. package/dist/tool-gate.d.ts +13 -3
  278. package/dist/tool-gate.js +15 -7
  279. package/dist/tool-plane.d.ts +42 -29
  280. package/dist/tool-plane.js +64 -27
  281. package/dist/tools.d.ts +53 -39
  282. package/dist/tools.js +174 -79
  283. package/dist/trigger-signatures.d.ts +1 -0
  284. package/dist/trigger-signatures.js +3 -1
  285. package/dist/triggers.d.ts +3 -3
  286. package/dist/triggers.js +2 -2
  287. package/dist/turn-end.d.ts +0 -3
  288. package/dist/turn-end.js +0 -3
  289. package/dist/uploads.d.ts +28 -5
  290. package/dist/uploads.js +82 -9
  291. package/dist/usage-lines.d.ts +1 -1
  292. package/dist/usage.d.ts +1 -47
  293. package/dist/usage.js +3 -82
  294. package/dist/validate.d.ts +8 -0
  295. package/dist/validate.js +40 -3
  296. package/dist/webhooks.d.ts +2 -1
  297. package/dist/webhooks.js +5 -2
  298. package/dist/workflow/decision-recovery.d.ts +23 -0
  299. package/dist/workflow/decision-recovery.js +80 -0
  300. package/dist/workflow/decisions.d.ts +134 -0
  301. package/dist/workflow/decisions.js +46 -0
  302. package/dist/workflow/host-session.d.ts +5 -0
  303. package/dist/workflow/host-session.js +85 -0
  304. package/dist/workflow/host-tools.d.ts +3 -0
  305. package/dist/workflow/host-tools.js +3 -0
  306. package/dist/workflow/node-runner.d.ts +112 -0
  307. package/dist/workflow/node-runner.js +270 -0
  308. package/dist/workflow/node.d.ts +88 -0
  309. package/dist/workflow/node.js +99 -0
  310. package/dist/workflow/operator-error.d.ts +4 -0
  311. package/dist/workflow/operator-error.js +4 -0
  312. package/dist/workflow/pi-versions.d.ts +9 -0
  313. package/dist/workflow/pi-versions.js +8 -0
  314. package/dist/workflow/readers.d.ts +36 -0
  315. package/dist/workflow/readers.js +145 -0
  316. package/dist/workflow/record-file.d.ts +10 -0
  317. package/dist/workflow/record-file.js +56 -0
  318. package/dist/workflow/record-tool.d.ts +76 -0
  319. package/dist/workflow/record-tool.js +126 -0
  320. package/dist/workflow/record.d.ts +151 -0
  321. package/dist/workflow/record.js +401 -0
  322. package/dist/workflow/run-error.d.ts +16 -0
  323. package/dist/workflow/run-error.js +26 -0
  324. package/dist/workflow/runner.d.ts +6 -0
  325. package/dist/workflow/runner.js +240 -0
  326. package/dist/workflow/store.d.ts +23 -0
  327. package/dist/workflow/store.js +242 -0
  328. package/dist/workflow/task.d.ts +133 -0
  329. package/dist/workflow/task.js +411 -0
  330. package/dist/workflow/thinking.d.ts +3 -0
  331. package/dist/workflow/thinking.js +7 -0
  332. package/dist/workflow/tool-context.d.ts +21 -0
  333. package/dist/workflow/tool-context.js +13 -0
  334. package/dist/workflow/types.d.ts +126 -0
  335. package/dist/workflow/types.js +1 -0
  336. package/dist/workflow/wal.d.ts +11 -0
  337. package/dist/workflow/wal.js +106 -0
  338. package/dist/workflow-run.d.ts +1 -1
  339. package/dist/workspace/agent-computer.d.ts +137 -0
  340. package/dist/workspace/agent-computer.js +292 -0
  341. package/dist/workspace/archil-claim.d.ts +13 -2
  342. package/dist/workspace/archil-claim.js +22 -13
  343. package/dist/workspace/archil-disk.d.ts +10 -1
  344. package/dist/workspace/archil-disk.js +4 -0
  345. package/dist/workspace/archil-disks.d.ts +49 -0
  346. package/dist/workspace/archil-disks.js +185 -0
  347. package/dist/workspace/archil-exec.d.ts +12 -2
  348. package/dist/workspace/archil-exec.js +18 -3
  349. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  350. package/dist/workspace/archil-mount-credential.js +13 -4
  351. package/dist/workspace/archil.d.ts +2 -2
  352. package/dist/workspace/archil.js +25 -5
  353. package/dist/workspace/attach.js +2 -0
  354. package/dist/workspace/computer-deps.d.ts +18 -11
  355. package/dist/workspace/computer-deps.js +64 -40
  356. package/dist/workspace/computer-for-claim.d.ts +47 -9
  357. package/dist/workspace/computer-for-claim.js +236 -24
  358. package/dist/workspace/computer-janitor.d.ts +3 -2
  359. package/dist/workspace/computer-janitor.js +43 -9
  360. package/dist/workspace/computer-ledger.d.ts +3 -8
  361. package/dist/workspace/computer-ledger.js +7 -3
  362. package/dist/workspace/computer-providers.d.ts +5 -3
  363. package/dist/workspace/computer-providers.js +11 -9
  364. package/dist/workspace/hands.d.ts +5 -2
  365. package/dist/workspace/hands.js +4 -3
  366. package/dist/workspace/index.d.ts +5 -4
  367. package/dist/workspace/index.js +2 -1
  368. package/dist/workspace/local.d.ts +3 -0
  369. package/dist/workspace/local.js +9 -0
  370. package/dist/workspace/paths.js +3 -2
  371. package/dist/workspace/pi-env.d.ts +4 -0
  372. package/dist/workspace/pi-env.js +3 -2
  373. package/dist/workspace/resolve-computer.d.ts +48 -12
  374. package/dist/workspace/resolve-computer.js +88 -19
  375. package/dist/workspace/run-disk.d.ts +34 -0
  376. package/dist/workspace/run-disk.js +91 -0
  377. package/dist/workspace/run-tools.d.ts +6 -4
  378. package/dist/workspace/run-tools.js +17 -9
  379. package/dist/workspace/server-run-workspace.d.ts +3 -2
  380. package/dist/workspace/server-run-workspace.js +17 -4
  381. package/dist/workspace/workspace.d.ts +5 -0
  382. package/dist/workspace.d.ts +0 -3
  383. package/dist/workspace.js +2 -15
  384. package/package.json +11 -16
  385. package/skills/agentrun-serve/SKILL.md +1 -1
  386. package/templates/README.md +11 -8
  387. package/templates/code-review/agent.md +27 -11
  388. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  389. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  390. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  391. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  392. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  393. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  394. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  395. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  396. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  397. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  398. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  399. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  400. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  401. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  402. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  403. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  404. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  405. package/templates/code-review/evals/re-review/prompt.md +1 -1
  406. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  407. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  408. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  409. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  410. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  411. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  412. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  413. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  414. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  415. package/templates/code-review/findings.schema.json +131 -27
  416. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  417. package/templates/code-review/skills/review/DEEP.md +130 -0
  418. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  419. package/templates/code-review/skills/review/SKILL.md +104 -154
  420. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  421. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  422. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  423. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  424. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  425. package/templates/release-notes/agent.md +11 -0
  426. package/dist/box/record.d.ts +0 -6
  427. package/dist/box/record.js +0 -41
  428. package/dist/box/sweep.d.ts +0 -53
  429. package/dist/box/sweep.js +0 -193
  430. package/dist/box-egress-vm.d.ts +0 -118
  431. package/dist/box-egress-vm.js +0 -354
  432. package/dist/box-egress.d.ts +0 -105
  433. package/dist/box-egress.js +0 -256
  434. package/dist/box-relay-vm.d.ts +0 -84
  435. package/dist/box-relay-vm.js +0 -437
  436. package/dist/box-relay.d.ts +0 -36
  437. package/dist/box-relay.js +0 -207
  438. package/dist/boxes.d.ts +0 -109
  439. package/dist/boxes.js +0 -249
  440. package/dist/budget.d.ts +0 -76
  441. package/dist/budget.js +0 -204
  442. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  443. package/dist/console/assets/index-opTN5Naq.css +0 -1
  444. package/dist/daytona-api.d.ts +0 -10
  445. package/dist/daytona-api.js +0 -20
  446. package/dist/egress-proxy.d.ts +0 -45
  447. package/dist/egress-proxy.js +0 -416
  448. package/dist/egress-table.d.ts +0 -24
  449. package/dist/egress-table.js +0 -165
  450. package/templates/code-review/rules/REVIEW.md +0 -41
@@ -12,8 +12,9 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
12
12
  import { COMMAND_KINDS, endedReason } from "./commands.js";
13
13
  import { KINDS, withdrawnAnswers } from "./journal-kinds.js";
14
14
  import { journalEntries } from "./journal-reader.js";
15
- import { endedBy } from "./loop-contract.js";
15
+ import { ClaimRefused, stopEnd } from "./loop-contract.js";
16
16
  import { isFenced } from "./store-port.js";
17
+ import { clearWaitEnded } from "../browser-wait-ended.js";
17
18
  import { heldRedactor, processSecretRedactor } from "./redact.js";
18
19
  import { withLiveTicker } from "./live-ticker.js";
19
20
  /** Most runs a runner holds at once, unless told (RunnerOptions.loops). */
@@ -30,6 +31,8 @@ export const runnerCloseBoundMs = (drainMs) => drainMs + RUNNER_LEASE_MS - RUNNE
30
31
  export const RUNNER_RENEW_EVERY_MS = 10_000;
31
32
  /** A runner's name when none is given: its host, its process and a part of a random id. */
32
33
  export const runnerName = () => `${hostname()}:${process.pid}:${randomUUID().slice(0, 8)}`;
34
+ /** A failed end's code when the claim was refused for good before any loop started (loop-contract's ClaimRefused). */
35
+ const CLAIM_REFUSED = "claim-refused";
33
36
  /** The untaken row a run ends on when no loop can: a cancel before a stop (it ends the run for good, in its words). */
34
37
  const endingRow = (untaken) => untaken.find((row) => row.kind === "cancel") ?? untaken.find((row) => row.kind === "stop");
35
38
  /** A commit by a loop whose claim this runner gave up: refused before it reaches the store. */
@@ -292,18 +295,23 @@ export function startRunner(options) {
292
295
  * the run row alone (runs.update, the same take in its one transaction), unless the end is a stop that may withdraw a
293
296
  * call (one waits, or the journal could not be read to say none does): that end is never written without its withdrawal,
294
297
  * so it throws EndNotWithdrawn and the run is left as it stands, not final, its stop untaken (endRefused retries it). A
295
- * lost claim (Fenced) writes neither.
298
+ * lost claim (Fenced) writes neither. A person's stop written on the row alone keeps no outcome 'stopped': with no end
299
+ * in its journal, a reopen would find no turn to follow (its next claim would read the run as never started), so it
300
+ * reads as a stop that is over (cancelled), as it read before a stop and a cancel were told apart.
296
301
  */
297
302
  const endRun = async (claim, given, take, withdrawnAs = "withdrawn") => {
298
303
  // Why the run ended, as its end and its row say it: cut of every secret the runner holds (an error's text may echo one).
299
304
  const data = { ...given, summary: redact(given.summary) };
300
305
  // Unknown means it may withdraw: false only once the journal was read and no call of it waits.
301
306
  let mayWithdraw = data.state === "stopped";
307
+ // A run whose journal holds no conversation never sent a request: its end carries a cost of $0, as a loop's end does.
308
+ let neverSent = false;
302
309
  try {
303
310
  const journal = store.journal(claim);
304
311
  const [root] = (await journal.scanConversations({}, 1, undefined, BACKGROUND_CONTEXT)).items;
305
312
  if (!root)
306
313
  mayWithdraw = false;
314
+ neverSent = !root;
307
315
  const writes = [];
308
316
  let conversationId = root?.id;
309
317
  if (conversationId === undefined) {
@@ -322,7 +330,7 @@ export function startRunner(options) {
322
330
  }
323
331
  const id = (await journal.mintId());
324
332
  writes.push({ type: "entry", value: { id, conversationId, kind: KINDS.end, data: data } });
325
- journal.stage({ run: { state: data.state, summary: data.summary }, effect: id, ...(take.length ? { take: take.map((command) => ({ command, effect: id })) } : {}) });
333
+ journal.stage({ run: { state: data.state, summary: data.summary, ...(data.outcome ? { outcome: data.outcome } : {}), ...(neverSent ? { costUsd: 0 } : {}) }, effect: id, ...(take.length ? { take: take.map((command) => ({ command, effect: id })) } : {}) });
326
334
  const result = await journal.commit([writes], () => { }, BACKGROUND_CONTEXT);
327
335
  if (result.stored !== 1)
328
336
  throw result.refused ?? new Error("the run's end was not stored");
@@ -332,14 +340,22 @@ export function startRunner(options) {
332
340
  throw error;
333
341
  if (mayWithdraw)
334
342
  throw new EndNotWithdrawn(claim.runId, error);
335
- await store.runs.update(claim, { state: data.state, summary: data.summary }, take.length ? { take } : undefined);
343
+ await store.runs.update(claim, { state: data.state, summary: data.summary, ...(data.outcome === "cancelled" ? { outcome: data.outcome } : {}) }, take.length ? { take } : undefined);
336
344
  }
345
+ // An ended run's Screen has no ended-while-waiting state to keep (browser-wait-ended.ts): its row goes with the end.
346
+ if (store.settings)
347
+ await clearWaitEnded(store.settings, claim.runId, claim.epoch).catch(() => undefined);
337
348
  };
338
349
  /** Ends the run under `claim` stopped on its untaken `stop` (or cancel) row (endRun). False when that end may withdraw a
339
350
  * call and the journal would not take it or could not be read: the refusal is then the run's (endRefused). */
340
351
  const endStopped = async (claim, stop) => {
341
352
  try {
342
- await endRun(claim, { state: "stopped", summary: endedBy(stop.kind === "cancel") }, [stop.id], stop.kind === "cancel" ? "canceled" : "withdrawn");
353
+ // A learning run is never reopened (reopenableWhere), so its person's stop keeps no outcome 'stopped' (which would
354
+ // read it waiting on a message for good): it reads stopped, as the learning loop's own stop end leaves it.
355
+ const end = stopEnd(stop.kind === "cancel");
356
+ const launch = end.outcome === "stopped" ? await store.runs.launch?.(claim.runId).catch(() => undefined) : undefined;
357
+ const learning = launch?.body?.harness === "learning";
358
+ await endRun(claim, learning ? { state: end.state, summary: end.summary } : end, [stop.id], stop.kind === "cancel" ? "canceled" : "withdrawn");
343
359
  return true;
344
360
  }
345
361
  catch (error) {
@@ -376,7 +392,9 @@ export function startRunner(options) {
376
392
  const why = message(refused.cause);
377
393
  if (tries >= endRetryCapFrom + endRetryAtCap) {
378
394
  emit({ type: "error", runId: claim.runId, step: "end", message: `run ${claim.runId} ended without withdrawing: journal unreadable or refusing (after ${tries} tries; the last: ${why})` });
379
- await store.runs.update(claim, { state: "stopped", summary: redact(endedBy(stop.kind === "cancel")) }, { take: [stop.id] });
395
+ // On its row alone, so no outcome 'stopped' (endRun): a run whose journal never took its end is never reopened.
396
+ const end = stopEnd(stop.kind === "cancel");
397
+ await store.runs.update(claim, { state: end.state, summary: redact(end.summary), ...(end.outcome === "cancelled" ? { outcome: end.outcome } : {}) }, { take: [stop.id] });
380
398
  await releaseStopped(claim, stop);
381
399
  return;
382
400
  }
@@ -386,6 +404,16 @@ export function startRunner(options) {
386
404
  await store.release(claim, { backoffUntil: now() + wait });
387
405
  emit({ type: "released", runId: claim.runId, epoch: claim.epoch, end: "interrupted" });
388
406
  };
407
+ /** Whether the run under `claim` never started: its journal has no conversation yet, so no input of it went out. A
408
+ * journal that cannot be read says no (the claim's loop applies the stop as it would). */
409
+ const neverStarted = async (claim) => {
410
+ try {
411
+ return (await store.journal(claim).scanConversations({}, 1, undefined, BACKGROUND_CONTEXT)).items.length === 0;
412
+ }
413
+ catch {
414
+ return false;
415
+ }
416
+ };
389
417
  /** A claim of a run whose stopped end was refused (its untaken stop row has tries): it only ends the run, with no loop,
390
418
  * so no turn, model request or tool runs on a run that is stopping. */
391
419
  const endRetried = async (claim, stop) => {
@@ -425,7 +453,8 @@ export function startRunner(options) {
425
453
  // with why, and a person can raise again or stop it (#1944-5). A claim its spec refuses (ClaimRefused: a handed
426
454
  // sign-in that won't read back, an MCP pin refused) never comes here: the loop writes that end itself, final, the run
427
455
  // failed in the refusal's words.
428
- if (threw && end.state === "failed" && claim.from === "parked")
456
+ // A claim refused for good (CLAIM_REFUSED) is no resume to try again: it fails the run below, parked or not.
457
+ if (threw && end.state === "failed" && claim.from === "parked" && end.error.code !== CLAIM_REFUSED)
429
458
  return await resumeFailed(held, end.error.message);
430
459
  if (threw && end.state === "failed") {
431
460
  // A loop that failed with no end written: a person's stop waiting now is the run's end (stopped, its row taken),
@@ -448,6 +477,9 @@ export function startRunner(options) {
448
477
  if (row.refused === reason)
449
478
  emit({ type: "refused", runId: claim.runId, commandId: row.id, reason });
450
479
  }
480
+ // The run's end (a normal completion among them) leaves no browser-released message behind for a follow-up (browser-wait-ended.ts).
481
+ if (store.settings)
482
+ await clearWaitEnded(store.settings, claim.runId, claim.epoch).catch(() => undefined);
451
483
  }
452
484
  await store.flush();
453
485
  // A loop that ended interrupted with no stop asked of it (its Session closed itself) is released with a backoff that
@@ -515,14 +547,24 @@ export function startRunner(options) {
515
547
  const delivered = new Promise((resolve) => (firstDelivered = resolve));
516
548
  // Set below, once held is made: the loop's end commit lands only after start(), well after.
517
549
  let ending = () => { };
550
+ // Set below, once held is made: the loop asks deliverNow only once its first turn has ended, well after.
551
+ let heldNow;
518
552
  const loop = loopsOf({
519
553
  journal: (forClaim) => fenced(store.journal(forClaim), fence, forClaim.runId, () => ending()),
520
554
  flush: () => store.flush(),
521
555
  signal: abort.signal,
522
556
  delivered,
557
+ // A delivery under way first (its rows are the loop's already), then one more read of the run's new rows.
558
+ deliverNow: async () => {
559
+ if (!heldNow)
560
+ return;
561
+ await heldNow.inFlight?.catch(() => undefined);
562
+ await deliver(heldNow);
563
+ },
523
564
  redact,
524
565
  });
525
566
  const held = { claim, loop, fence, abort, cursor: 0, stopping: false, ending: false, sealed: false, renewing: false, delivering: false, mib };
567
+ heldNow = held;
526
568
  // The loop's own end landed: the run is ending from here, its teardown included (no renew, no lost claim).
527
569
  ending = () => {
528
570
  held.ending = true;
@@ -539,7 +581,9 @@ export function startRunner(options) {
539
581
  }
540
582
  catch (error) {
541
583
  threw = true;
542
- end = { state: "failed", error: { code: "loop-threw", message: message(error) } };
584
+ // A claim refused before any loop could start (the dispatch's ClaimRefused: a harness this host never holds) is
585
+ // for good: the run fails in its words, whatever woke it.
586
+ end = { state: "failed", error: { code: error instanceof ClaimRefused ? CLAIM_REFUSED : "loop-threw", message: message(error) } };
543
587
  }
544
588
  await finish(held, end, threw);
545
589
  })();
@@ -560,14 +604,20 @@ export function startRunner(options) {
560
604
  const sentAt = clock.now();
561
605
  const weights = new Map();
562
606
  const claims = memory ? await claimByMemory(memory, free, weights) : await store.runs.claimMany(name, free, { leaseMs });
563
- // A run whose untaken stop row has tries failed to apply that stop before: its claim only ends it (endRetried). Either
564
- // source of tries counts: a refused stopped end (endRefused, released running) or a failed resume (resumeFailed's
565
- // store.retry, released parked). One read of those claims' rows, made only when the batch has a released run.
566
- const released = claims.filter((claim) => claim.from === "running" || claim.from === "parked");
567
- const rows = released.length ? await store.commandsOf(released.map((claim) => ({ runId: claim.runId, after: 0 }))) : new Map();
607
+ // A claim whose run must only end, with no loop (endRetried), so no turn, model request or tool runs on it:
608
+ // - a run stopped or cancelled while it had not started: claimed from queued, or claimed from running when an earlier
609
+ // claim was lost before the run's journal had anything (its runner gone before it wrote a word). Nothing of it
610
+ // starts now, not even its first input: a loop started first would send that input before the stop reached it;
611
+ // - a run whose untaken stop row has tries, which failed to apply that stop before. Either source of tries counts: a
612
+ // refused stopped end (endRefused, released running) or a failed resume (resumeFailed's store.retry, released
613
+ // parked).
614
+ // One read of those claims' rows, made only when the batch has a queued or a released run.
615
+ const reread = claims.filter((claim) => claim.from === "queued" || claim.from === "running" || claim.from === "parked");
616
+ const rows = reread.length ? await store.commandsOf(reread.map((claim) => ({ runId: claim.runId, after: 0 }))) : new Map();
568
617
  for (const claim of claims) {
569
618
  const stop = endingRow((rows.get(claim.runId) ?? []).filter((row) => row.takenAt === null));
570
- if (stop && stop.tries > 0 && !closed && !killed && !runs.has(claim.runId)) {
619
+ const endsOnly = stop !== undefined && (claim.from === "queued" || stop.tries > 0 || (claim.from === "running" && (await neverStarted(claim))));
620
+ if (stop && endsOnly && !closed && !killed && !runs.has(claim.runId)) {
571
621
  const ending = endRetried(claim, stop);
572
622
  endings.add(ending);
573
623
  void ending.finally(() => endings.delete(ending));
@@ -658,6 +708,52 @@ export function startRunner(options) {
658
708
  };
659
709
  poll();
660
710
  commandTimer = setTimeout(deliverAll, commandPollMs);
711
+ /** The untaken stop or cancel row each of `going` ends on (endingRow: a cancel before a stop), past its cursor, by run id:
712
+ * the close's one read of their rows (store.commandsOf), after the deliveries in flight. The whole of it is bounded by
713
+ * the stop margin, so a store that stalls never holds the shutdown: a read that fails or runs past it is said, and those
714
+ * runs are released for a shutdown as before, their rows untaken for the next claim. */
715
+ const closingEnds = async (going) => {
716
+ const ends = new Map();
717
+ if (going.length === 0)
718
+ return ends;
719
+ const read = async () => {
720
+ // A delivery in flight finishes first: it may be handing on that same row.
721
+ await Promise.all(going.map((held) => held.inFlight?.catch(() => undefined)));
722
+ const still = going.filter((held) => !held.stopping && !held.ending && !held.fence.lost);
723
+ if (still.length === 0)
724
+ return ends;
725
+ const rows = await store.commandsOf(still.map((held) => ({ runId: held.claim.runId, after: held.cursor })));
726
+ const found = new Map();
727
+ for (const held of still) {
728
+ const end = endingRow((rows.get(held.claim.runId) ?? []).filter((row) => row.takenAt === null));
729
+ if (end)
730
+ found.set(held.claim.runId, end);
731
+ }
732
+ return found;
733
+ };
734
+ let bound;
735
+ // Within the close's stop window (the lease less its margin), whatever the margin.
736
+ const boundMs = Math.min(stopMarginMs, leaseMs - stopMarginMs);
737
+ const late = new Promise((resolve) => (bound = setTimeout(() => resolve("late"), boundMs)));
738
+ // A read that fails after the bound is never an unhandled rejection: the close has moved on without it.
739
+ const reading = read();
740
+ reading.catch(() => undefined);
741
+ try {
742
+ const found = await Promise.race([reading, late]);
743
+ if (found !== "late")
744
+ return found;
745
+ for (const held of going)
746
+ emit({ type: "error", runId: held.claim.runId, step: "commands", message: `the close's read of its stop rows took longer than ${boundMs} ms: released for the next claim` });
747
+ }
748
+ catch (error) {
749
+ for (const held of going)
750
+ emit({ type: "error", runId: held.claim.runId, step: "commands", message: message(error) });
751
+ }
752
+ finally {
753
+ clearTimeout(bound);
754
+ }
755
+ return ends;
756
+ };
661
757
  const stopTimers = () => {
662
758
  clearTimeout(pollTimer);
663
759
  clearTimeout(commandTimer);
@@ -689,17 +785,38 @@ export function startRunner(options) {
689
785
  draining = false;
690
786
  clearTimeout(commandTimer);
691
787
  const live = [...runs.values()].filter((held) => !held.fence.lost);
788
+ // One window for the stop after the drain, the one runnerCloseBoundMs counts (the lease less its margin): the read
789
+ // below and the loops' stop share it, so the close is never longer than a deployment's stop grace allows for.
790
+ const stopBy = Date.now() + leaseMs - stopMarginMs;
791
+ // A stop or cancel a person sent before the close is the run's end, never a resume: one no delivery has handed on
792
+ // yet (the command poll's tick had not come) is read here, once, for every run still going, and stops its loop as
793
+ // its delivery would. Its end is in the store when the close is done, and the next start never resumes the turn.
794
+ const ends = await closingEnds(live.filter((held) => !held.ending && !held.stopping));
692
795
  for (const held of live) {
693
- if (!held.ending) {
694
- stopLoop(held, { kind: "shutdown" });
695
- held.abort.abort(new Error("the runner is closing"));
796
+ if (held.ending)
797
+ continue;
798
+ const end = ends.get(held.claim.runId);
799
+ if (end && !held.stopping) {
800
+ held.cursor = Math.max(held.cursor, end.id);
801
+ stopLoop(held, { kind: "command", commandId: end.id, ...(end.kind === "cancel" ? { cancel: true } : {}) });
696
802
  }
803
+ // A loop a stop or cancel already stops writes that end: it is never cut for the close.
804
+ if (held.stopping)
805
+ continue;
806
+ stopLoop(held, { kind: "shutdown" });
807
+ held.abort.abort(new Error("the runner is closing"));
697
808
  }
698
- // Claims are renewed while the loops stop; a loop that never stops is given up when its claim would run out.
809
+ // Claims are renewed while the loops stop; a loop that never stops is given up when its claim would run out (the end
810
+ // of the window the read above began).
699
811
  let timeout;
700
- const late = new Promise((resolve) => (timeout = setTimeout(resolve, leaseMs - stopMarginMs)));
812
+ const late = new Promise((resolve) => (timeout = setTimeout(resolve, Math.max(0, stopBy - Date.now()))));
701
813
  await Promise.race([Promise.all([...live.map((held) => held.done), ...endings]), late]);
702
814
  clearTimeout(timeout);
815
+ // A loop still going at the window's end (one a stop row stops, whose signal was kept whole for its end) has its
816
+ // signal aborted before its claim is given up: no request of it outlives the close.
817
+ for (const held of live)
818
+ if (!held.ending && !held.abort.signal.aborted)
819
+ held.abort.abort(new Error("the runner is closing"));
703
820
  for (const held of runs.values())
704
821
  held.fence.lost = true;
705
822
  stopTimers();
@@ -3,6 +3,10 @@ type Held = {
3
3
  readonly tools?: {
4
4
  end(): Promise<void>;
5
5
  };
6
+ /** The run's checkout of its pull request (pr-checkout.ts), removed from its folder while the Workspace still answers. */
7
+ readonly checkout?: {
8
+ end(): Promise<void>;
9
+ } | undefined;
6
10
  readonly computer?: {
7
11
  release(): Promise<void>;
8
12
  };
@@ -16,6 +20,11 @@ type Held = {
16
20
  readonly keys?: {
17
21
  release(): void;
18
22
  } | undefined;
23
+ /** The CLI's files on this machine for this claim (its private folder in the run's scratch), swept once the rest is let
24
+ * go: every claim lays its own again, the harness's state coming back from the run's journal. */
25
+ readonly scratch?: {
26
+ sweep(): Promise<void>;
27
+ } | undefined;
19
28
  /** What the spec hands the loop, which lets it go itself (the claim's MCP): let go here only when the build throws. */
20
29
  readonly passed?: {
21
30
  release(): void;
@@ -28,9 +37,10 @@ export declare class SpecHolds {
28
37
  logTo(log: (line: string) => void): void;
29
38
  /** `parts`, held from now until the release. */
30
39
  hold(parts: Held): void;
31
- /** Everything held let go, once: the tools' end (background processes ended, scratch swept), the computer, the Archil
32
- * mount credential (idempotent: the computer's release revokes it too), the Workspace's end, then the claim's keys
33
- * where they are held. A second call waits for the first and does nothing more. */
40
+ /** Everything held let go, once: the tools' end (background processes ended, scratch swept), the pull request's
41
+ * checkout removed, the computer, the Archil mount credential (idempotent: the computer's release revokes it too), the
42
+ * Workspace's end, the CLI's scratch, then the claim's keys where they are held. A second call waits for the first and
43
+ * does nothing more. */
34
44
  release(): Promise<void>;
35
45
  /** What the spec would have handed the loop, let go: only a build that throws calls it. */
36
46
  releasePassed(): void;
@@ -1,9 +1,9 @@
1
- // What a run's spec holds from its claim until its release: the run's tools, its computer, its Archil mount credential
2
- // and its Workspace, each kept here as the spec builder makes it (adapter-run-spec.ts and cli-run-spec.ts). The spec's
3
- // release lets them go, in that order, each step's failure logged and the next still taken. A builder that throws
4
- // part-way never hands the loop a spec to release, so specBuilt lets go what was made by then, the same way, and throws
5
- // the builder's own error unchanged: a credential minted for the run is revoked and a computer made for it let go, never
6
- // left to the credential's 24 h ttl or the computer's lifetime. Each is let go at most once.
1
+ // What a run's spec holds from its claim until its release: the run's tools, its pull request's checkout, its computer,
2
+ // its Archil mount credential and its Workspace, each kept here as the spec builder makes it (adapter-run-spec.ts and
3
+ // cli-run-spec.ts). The spec's release lets them go, in that order, each step's failure logged and the next still taken.
4
+ // A builder that throws part-way never hands the loop a spec to release, so specBuilt lets go what was made by then, the
5
+ // same way, and throws the builder's own error unchanged: a credential minted for the run is revoked and a computer made
6
+ // for it let go, never left to the credential's 24 h ttl or the computer's lifetime. Each is let go at most once.
7
7
  const words = (error) => error?.message ?? String(error);
8
8
  /** The parts a run's spec holds, and their one release. */
9
9
  export class SpecHolds {
@@ -18,19 +18,22 @@ export class SpecHolds {
18
18
  hold(parts) {
19
19
  this.#held = { ...this.#held, ...parts };
20
20
  }
21
- /** Everything held let go, once: the tools' end (background processes ended, scratch swept), the computer, the Archil
22
- * mount credential (idempotent: the computer's release revokes it too), the Workspace's end, then the claim's keys
23
- * where they are held. A second call waits for the first and does nothing more. */
21
+ /** Everything held let go, once: the tools' end (background processes ended, scratch swept), the pull request's
22
+ * checkout removed, the computer, the Archil mount credential (idempotent: the computer's release revokes it too), the
23
+ * Workspace's end, the CLI's scratch, then the claim's keys where they are held. A second call waits for the first and
24
+ * does nothing more. */
24
25
  release() {
25
26
  return (this.#released ??= this.#releaseAll());
26
27
  }
27
28
  async #releaseAll() {
28
- const { tools, computer, archil, ws, keys } = this.#held;
29
+ const { tools, checkout, computer, archil, ws, scratch, keys } = this.#held;
29
30
  const log = this.#log;
30
31
  await tools?.end().catch((error) => log(`the run's tools' end failed: ${words(error)}`));
32
+ await checkout?.end().catch((error) => log(words(error)));
31
33
  await computer?.release().catch((error) => log(`the run's computer could not be let go: ${words(error)}`));
32
34
  await archil?.revoke().catch((error) => log(`the run's Archil mount credential could not be revoked: ${words(error)}`));
33
35
  await ws?.end().catch((error) => log(`the run's workspace end failed: ${words(error)}`));
36
+ await scratch?.sweep().catch((error) => log(`the run's scratch folder could not be swept: ${words(error)}`));
34
37
  keys?.release();
35
38
  }
36
39
  /** What the spec would have handed the loop, let go: only a build that throws calls it. */
@@ -1,9 +1,12 @@
1
1
  import { type Store } from "../store/store.js";
2
2
  export type RunnerStore = Pick<Store, "claim" | "renew" | "renewMany" | "release" | "journal" | "flush" | "commands" | "commandsOf" | "take" | "retry"> & {
3
- readonly runs: Pick<Store["runs"], "claimMany" | "claimable" | "update">;
3
+ readonly runs: Pick<Store["runs"], "claimMany" | "claimable" | "update"> & Partial<Pick<Store["runs"], "launch">>;
4
4
  /** The runs' live view (run_live): the runner's live ticker writes each run's held state there. A store without it (a
5
5
  * test's) has no live view. */
6
6
  readonly live?: Store["live"];
7
+ /** The server's settings, for the one the runner removes at a run's end (browser-wait-ended.ts). A store without it (a
8
+ * test's) keeps none. */
9
+ readonly settings?: Store["settings"];
7
10
  };
8
11
  /** The store's fence: a write under an epoch that moved. */
9
12
  export declare function isFenced(error: unknown): boolean;
@@ -50,6 +50,22 @@ function jsonSecrets(text) {
50
50
  walk(value);
51
51
  return out;
52
52
  }
53
+ /** A launch's sealed JSON: its own listed values (jsonSecrets), and each handed MCP credential's headers (store/seal.ts
54
+ * sealRunMcpAuth: `{"mcp": {"<server>": {"headers": {...}}}}`), as a saved server's are listed. */
55
+ function launchSecrets(text) {
56
+ const out = jsonSecrets(text);
57
+ let mcp;
58
+ try {
59
+ mcp = JSON.parse(text)?.mcp;
60
+ }
61
+ catch {
62
+ return out;
63
+ }
64
+ if (mcp && typeof mcp === "object")
65
+ for (const entry of Object.values(mcp))
66
+ out.push(...jsonSecrets(JSON.stringify(entry)));
67
+ return out;
68
+ }
53
69
  /** A PEM key whole, and each of its base64 lines (the short last one too), as the server lists one (sealed-settings-store.ts). */
54
70
  const pemForms = (value) => [value, ...value.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("-----"))];
55
71
  /** What of one opened sealed value is a secret to hold, by its plane: `listed` with the server list's floor and spellings,
@@ -66,7 +82,7 @@ function secretsOf(row, plain, adapters) {
66
82
  case "mcp_oauth_pending":
67
83
  return { listed: jsonSecrets(plain), whole: [] };
68
84
  case "run_launch":
69
- return { listed: plain.trimStart().startsWith("{") ? jsonSecrets(plain) : [plain], whole: [] };
85
+ return { listed: plain.trimStart().startsWith("{") ? launchSecrets(plain) : [plain], whole: [] };
70
86
  default:
71
87
  return { listed: [plain], whole: [] };
72
88
  }
@@ -0,0 +1,44 @@
1
+ import { type ModelRef, type ToolRegistration } from "@earendil-works/pi-durable";
2
+ export declare const SUBAGENT_TOOL = "subagent";
3
+ /** The tiers a call may name for its child (its definition's model_tiers, else this server's tier); a call that names
4
+ * none runs its child on the agent's own model. */
5
+ export declare const SUBAGENT_TIERS: readonly ["fast", "strong"];
6
+ export type SubagentTier = (typeof SUBAGENT_TIERS)[number];
7
+ /** How many of a run's children work at once; a call past it waits for a slot. */
8
+ export declare const SUBAGENT_PARALLEL = 4;
9
+ /** A child's instructions: the call's prompt is its whole task. Nothing of the parent's prompt is carried over. */
10
+ export declare const SUBAGENT_INSTRUCTIONS = "You are a subagent. The message you are given is your whole task: do it with the tools you have, then answer. Your last message is returned, as it is, to the agent that called you.";
11
+ /** The thinking levels a call may give its child (`effort`); absent, the child thinks at the agent's own level. */
12
+ export declare const SUBAGENT_EFFORTS: readonly ["low", "medium", "high"];
13
+ /** A tier's model in this run: its ref in the run's models (adapters/pi.ts tierProvider), or why the tier has none here. */
14
+ export type TierModel = {
15
+ readonly ref: ModelRef;
16
+ } | {
17
+ readonly why: string;
18
+ };
19
+ export type SubagentOptions = {
20
+ /** The tools the agent was granted, by catalog name (`read`, `mcp:github/get_file_contents`): a call's subset of them. */
21
+ readonly granted: readonly string[];
22
+ /** A granted tool's names in the run's session (catalog.ts wireName; the browser's registrations for `browser`). */
23
+ readonly sessionNames: (catalog: string) => readonly string[];
24
+ /** The tier's model, resolved at the claim. */
25
+ readonly tier: (tier: SubagentTier) => TierModel;
26
+ /** Words before a child's own instructions (the environment line), when the host has any. */
27
+ readonly preamble?: string;
28
+ /** The agent's tool-call budget (definition.max_tool_calls, tool-budget.ts), per conversation: a call's own narrows it
29
+ * for its child, never widens it. */
30
+ readonly toolCalls?: number;
31
+ };
32
+ /** `text` within the host's bound on a tool result (HOST_RESULT_MAX_CHARS), saying where it was cut. */
33
+ export declare function boundedAnswer(text: string): string;
34
+ /** The catalog names of `asked` (each a catalog or session name of a granted tool) and the session names the child gets,
35
+ * or what is wrong with them. A catalog name gives every session name of its tool (`browser`: each browser tool); a
36
+ * session name gives that one alone (`browser_read`: never the rest of the browser's). */
37
+ export declare function chosenTools(asked: readonly string[], options: Pick<SubagentOptions, "granted" | "sessionNames">): {
38
+ catalog: string[];
39
+ names: string[];
40
+ } | {
41
+ refused: string;
42
+ };
43
+ /** The subagent tool: one of the session's own tools (adapters/pi.ts `tools`), so it needs no extension of its own. */
44
+ export declare function subagentTool(options: SubagentOptions): ToolRegistration;