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

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 (568) hide show
  1. package/CHANGELOG.md +452 -0
  2. package/README.md +311 -142
  3. package/dist/agent-rows.d.ts +1 -1
  4. package/dist/agents-store.d.ts +35 -3
  5. package/dist/agents-store.js +39 -14
  6. package/dist/answer-json.d.ts +34 -1
  7. package/dist/answer-json.js +91 -9
  8. package/dist/api-only.d.ts +1 -1
  9. package/dist/api-only.js +2 -2
  10. package/dist/attach-conformance-cli.d.ts +1 -0
  11. package/dist/attach-conformance-cli.js +18 -0
  12. package/dist/attach-conformance.d.ts +25 -0
  13. package/dist/attach-conformance.js +343 -0
  14. package/dist/browser-cost.d.ts +1 -1
  15. package/dist/browser-cost.js +52 -93
  16. package/dist/browser-live.d.ts +20 -8
  17. package/dist/browser-live.js +50 -27
  18. package/dist/cap.d.ts +0 -407
  19. package/dist/cap.js +4 -1028
  20. package/dist/catalog.d.ts +1 -12
  21. package/dist/catalog.js +4 -34
  22. package/dist/cli.js +13 -4
  23. package/dist/composio-preset.d.ts +53 -0
  24. package/dist/composio-preset.js +221 -0
  25. package/dist/computer-attach.d.ts +125 -0
  26. package/dist/computer-attach.js +330 -0
  27. package/dist/computer-calls.d.ts +60 -0
  28. package/dist/computer-calls.js +209 -0
  29. package/dist/computer-channel.d.ts +57 -0
  30. package/dist/computer-channel.js +115 -0
  31. package/dist/computer-commands.d.ts +1 -1
  32. package/dist/computer-held-routes.d.ts +35 -0
  33. package/dist/computer-held-routes.js +106 -0
  34. package/dist/computer-held.d.ts +48 -0
  35. package/dist/computer-held.js +87 -0
  36. package/dist/computer-keys.d.ts +21 -1
  37. package/dist/computer-keys.js +53 -11
  38. package/dist/computer-live.d.ts +165 -0
  39. package/dist/computer-live.js +655 -0
  40. package/dist/computer-setting.d.ts +15 -2
  41. package/dist/computer-setting.js +20 -4
  42. package/dist/computer-view.d.ts +14 -0
  43. package/dist/computer-view.js +51 -3
  44. package/dist/computer-viewer.d.ts +6 -0
  45. package/dist/computer-viewer.js +311 -0
  46. package/dist/computers.d.ts +37 -8
  47. package/dist/computers.js +62 -14
  48. package/dist/console/assets/index-CjqQirbo.css +1 -0
  49. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/console-links.d.ts +2 -0
  52. package/dist/console-links.js +3 -0
  53. package/dist/decisions.js +4 -0
  54. package/dist/faux-computers.d.ts +9 -20
  55. package/dist/faux-computers.js +56 -26
  56. package/dist/github-connection.d.ts +10 -2
  57. package/dist/github-connection.js +65 -2
  58. package/dist/github-faux.js +1 -1
  59. package/dist/graph-view.d.ts +1 -1
  60. package/dist/harness-opencode/adapter.js +7 -3
  61. package/dist/harness-opencode/facts.js +0 -2
  62. package/dist/harness-opencode/host/policy.d.ts +2 -5
  63. package/dist/harness-opencode/host/policy.js +8 -32
  64. package/dist/harness-table.d.ts +0 -2
  65. package/dist/harness-table.js +0 -2
  66. package/dist/harness.d.ts +1 -0
  67. package/dist/harness.js +35 -1
  68. package/dist/host-tools.d.ts +2 -6
  69. package/dist/host-tools.js +7 -10
  70. package/dist/hosted-search.d.ts +5 -6
  71. package/dist/hosted-search.js +2 -28
  72. package/dist/import-sources.d.ts +10 -0
  73. package/dist/import-sources.js +44 -2
  74. package/dist/import.d.ts +3 -3
  75. package/dist/import.js +37 -6
  76. package/dist/key-words.d.ts +3 -2
  77. package/dist/key-words.js +4 -2
  78. package/dist/learn/check.d.ts +10 -2
  79. package/dist/learn/check.js +13 -5
  80. package/dist/learn/commit.d.ts +14 -2
  81. package/dist/learn/commit.js +23 -9
  82. package/dist/learn/compile.d.ts +243 -0
  83. package/dist/learn/compile.js +471 -0
  84. package/dist/learn/folder.d.ts +6 -0
  85. package/dist/learn/folder.js +4 -1
  86. package/dist/learn/general.d.ts +69 -0
  87. package/dist/learn/general.js +75 -0
  88. package/dist/learn/grade.d.ts +5 -1
  89. package/dist/learn/grade.js +29 -7
  90. package/dist/learn/notes.d.ts +8 -0
  91. package/dist/learn/notes.js +18 -0
  92. package/dist/learn/promote.d.ts +253 -0
  93. package/dist/learn/promote.js +428 -0
  94. package/dist/learn/refit.d.ts +39 -0
  95. package/dist/learn/refit.js +236 -0
  96. package/dist/learn/reflect.d.ts +9 -20
  97. package/dist/learn/reflect.js +18 -125
  98. package/dist/learn/replay-calls.d.ts +63 -0
  99. package/dist/learn/replay-calls.js +158 -0
  100. package/dist/learn/skills.d.ts +50 -14
  101. package/dist/learn/skills.js +183 -47
  102. package/dist/learn/workflow-nodes.d.ts +15 -0
  103. package/dist/learn/workflow-nodes.js +44 -0
  104. package/dist/learned-nodes.d.ts +50 -2
  105. package/dist/learned-nodes.js +41 -2
  106. package/dist/learned-workflow.d.ts +43 -3
  107. package/dist/learned-workflow.js +170 -28
  108. package/dist/learning-batch.d.ts +283 -0
  109. package/dist/learning-batch.js +574 -0
  110. package/dist/learning-cost.d.ts +18 -6
  111. package/dist/learning-cost.js +15 -7
  112. package/dist/learning-evals.d.ts +33 -0
  113. package/dist/learning-evals.js +98 -0
  114. package/dist/learning-routes.d.ts +37 -2
  115. package/dist/learning-routes.js +52 -8
  116. package/dist/learning-words.d.ts +13 -0
  117. package/dist/learning-words.js +13 -0
  118. package/dist/learning.d.ts +55 -17
  119. package/dist/learning.js +91 -48
  120. package/dist/live/stream.js +6 -3
  121. package/dist/live/translate.d.ts +4 -3
  122. package/dist/live/translate.js +8 -4
  123. package/dist/live-reach.d.ts +37 -0
  124. package/dist/live-reach.js +62 -0
  125. package/dist/llm.js +0 -3
  126. package/dist/mcp-gateway.d.ts +21 -20
  127. package/dist/mcp-gateway.js +76 -55
  128. package/dist/mcp-oauth.d.ts +62 -7
  129. package/dist/mcp-oauth.js +134 -19
  130. package/dist/mcp-pin-first.d.ts +37 -0
  131. package/dist/mcp-pin-first.js +107 -0
  132. package/dist/mcp-private-hosts.d.ts +4 -4
  133. package/dist/mcp-private-hosts.js +20 -12
  134. package/dist/mcp-probe.d.ts +27 -11
  135. package/dist/mcp-probe.js +60 -42
  136. package/dist/mcp-secret-writes.js +4 -0
  137. package/dist/mcp-servers-store.d.ts +115 -25
  138. package/dist/mcp-servers-store.js +241 -43
  139. package/dist/mcp-sources.d.ts +39 -0
  140. package/dist/mcp-sources.js +74 -0
  141. package/dist/mcp-store.d.ts +21 -4
  142. package/dist/mcp-store.js +33 -8
  143. package/dist/mcp-wire.d.ts +22 -0
  144. package/dist/mcp-wire.js +36 -0
  145. package/dist/mcp.js +3 -3
  146. package/dist/meta-tool-names.d.ts +1 -0
  147. package/dist/meta-tool-names.js +3 -0
  148. package/dist/model-form.d.ts +26 -0
  149. package/dist/model-form.js +80 -0
  150. package/dist/model.d.ts +13 -0
  151. package/dist/model.js +69 -25
  152. package/dist/monid.d.ts +51 -25
  153. package/dist/monid.js +226 -140
  154. package/dist/openapi.js +694 -59
  155. package/dist/page.d.ts +18 -0
  156. package/dist/page.js +48 -20
  157. package/dist/paid-calls.d.ts +26 -29
  158. package/dist/paid-calls.js +46 -102
  159. package/dist/place-offers.d.ts +2 -3
  160. package/dist/place-offers.js +3 -7
  161. package/dist/place.js +1 -2
  162. package/dist/print.d.ts +15 -1
  163. package/dist/print.js +14 -3
  164. package/dist/propose.d.ts +10 -1
  165. package/dist/propose.js +30 -10
  166. package/dist/provider.js +12 -4
  167. package/dist/reflect-range.d.ts +8 -1
  168. package/dist/reflect-range.js +3 -2
  169. package/dist/rows.d.ts +5 -3
  170. package/dist/rows.js +15 -4
  171. package/dist/run-launch.d.ts +27 -2
  172. package/dist/run-launch.js +15 -4
  173. package/dist/run-learning-served.d.ts +13 -2
  174. package/dist/run-manifest.d.ts +5 -0
  175. package/dist/run-manifest.js +20 -0
  176. package/dist/run-reads-over-store.d.ts +1 -1
  177. package/dist/run-repo.d.ts +20 -0
  178. package/dist/run-repo.js +63 -0
  179. package/dist/run-secrets.js +2 -3
  180. package/dist/run-timeline-served.d.ts +1 -1
  181. package/dist/run-timeline-served.js +5 -2
  182. package/dist/run-view.d.ts +19 -8
  183. package/dist/run-view.js +62 -26
  184. package/dist/runnable.d.ts +0 -3
  185. package/dist/runnable.js +37 -29
  186. package/dist/runner/adapter-loop.d.ts +47 -17
  187. package/dist/runner/adapter-loop.js +1427 -303
  188. package/dist/runner/adapter-run-spec.d.ts +23 -9
  189. package/dist/runner/adapter-run-spec.js +162 -56
  190. package/dist/runner/adapters/pi-computer.d.ts +9 -0
  191. package/dist/runner/adapters/pi-computer.js +51 -0
  192. package/dist/runner/adapters/pi.d.ts +25 -11
  193. package/dist/runner/adapters/pi.js +168 -45
  194. package/dist/runner/beside.d.ts +7 -3
  195. package/dist/runner/beside.js +21 -11
  196. package/dist/runner/claim-secrets.d.ts +4 -0
  197. package/dist/runner/claim-secrets.js +6 -1
  198. package/dist/runner/cli-run-spec.d.ts +20 -3
  199. package/dist/runner/cli-run-spec.js +174 -64
  200. package/dist/runner/commands.d.ts +3 -1
  201. package/dist/runner/commands.js +28 -3
  202. package/dist/runner/computer-channel.d.ts +34 -0
  203. package/dist/runner/computer-channel.js +62 -0
  204. package/dist/runner/conformance/harness.d.ts +3 -0
  205. package/dist/runner/conformance/harness.js +224 -17
  206. package/dist/runner/conformance/subject.d.ts +12 -5
  207. package/dist/runner/dispatch.js +3 -0
  208. package/dist/runner/end-of-run.d.ts +23 -12
  209. package/dist/runner/end-of-run.js +41 -16
  210. package/dist/runner/feedback-round.d.ts +52 -0
  211. package/dist/runner/feedback-round.js +79 -0
  212. package/dist/runner/github-app.d.ts +2 -1
  213. package/dist/runner/github-app.js +4 -2
  214. package/dist/runner/harness-loops.js +15 -1
  215. package/dist/runner/held-run.d.ts +65 -0
  216. package/dist/runner/held-run.js +158 -0
  217. package/dist/runner/journal-kinds.d.ts +44 -7
  218. package/dist/runner/journal-kinds.js +29 -0
  219. package/dist/runner/journal-reader.d.ts +5 -4
  220. package/dist/runner/journal-reader.js +12 -10
  221. package/dist/runner/learning-ask.d.ts +7 -1
  222. package/dist/runner/learning-ask.js +21 -6
  223. package/dist/runner/learning-dispatch.d.ts +22 -0
  224. package/dist/runner/learning-dispatch.js +77 -10
  225. package/dist/runner/learning-end.d.ts +69 -13
  226. package/dist/runner/learning-end.js +340 -87
  227. package/dist/runner/learning-factory.d.ts +1 -1
  228. package/dist/runner/learning-factory.js +11 -5
  229. package/dist/runner/learning-loop.d.ts +86 -8
  230. package/dist/runner/learning-loop.js +178 -23
  231. package/dist/runner/learning-seed.d.ts +11 -0
  232. package/dist/runner/learning-seed.js +27 -0
  233. package/dist/runner/live-ticker.js +1 -0
  234. package/dist/runner/loop-contract.d.ts +26 -3
  235. package/dist/runner/loop.d.ts +21 -2
  236. package/dist/runner/loop.js +23 -2
  237. package/dist/runner/main.d.ts +13 -1
  238. package/dist/runner/main.js +27 -5
  239. package/dist/runner/mcp-claim.d.ts +15 -8
  240. package/dist/runner/mcp-claim.js +176 -71
  241. package/dist/runner/mcp-github.js +1 -1
  242. package/dist/runner/mcp-run.d.ts +21 -57
  243. package/dist/runner/mcp-run.js +25 -85
  244. package/dist/runner/meta-tools.d.ts +37 -0
  245. package/dist/runner/meta-tools.js +268 -0
  246. package/dist/runner/metrics.d.ts +11 -2
  247. package/dist/runner/metrics.js +26 -5
  248. package/dist/runner/model-route.js +12 -3
  249. package/dist/runner/monid-run.d.ts +16 -0
  250. package/dist/runner/monid-run.js +96 -0
  251. package/dist/runner/pr-checkout.d.ts +1 -0
  252. package/dist/runner/pr-checkout.js +1 -1
  253. package/dist/runner/promotion.d.ts +80 -0
  254. package/dist/runner/promotion.js +562 -0
  255. package/dist/runner/reflect-hook.d.ts +46 -13
  256. package/dist/runner/reflect-hook.js +149 -48
  257. package/dist/runner/runner.d.ts +26 -0
  258. package/dist/runner/runner.js +208 -17
  259. package/dist/runner/scratch-sweep.d.ts +13 -0
  260. package/dist/runner/scratch-sweep.js +62 -0
  261. package/dist/runner/sessions.d.ts +9 -4
  262. package/dist/runner/sessions.js +5 -1
  263. package/dist/runner/step-guard.d.ts +62 -0
  264. package/dist/runner/step-guard.js +93 -0
  265. package/dist/runner/store-port.d.ts +4 -2
  266. package/dist/runner/store-secrets.js +4 -3
  267. package/dist/runner/subagent.d.ts +0 -3
  268. package/dist/runner/subagent.js +10 -13
  269. package/dist/runner/workflow-first.d.ts +216 -0
  270. package/dist/runner/workflow-first.js +303 -0
  271. package/dist/runner/workflow-host.d.ts +6 -1
  272. package/dist/runner/workflow-host.js +1 -1
  273. package/dist/runner/workflow-loop.d.ts +1 -1
  274. package/dist/runner/workflow-loop.js +17 -10
  275. package/dist/runner/workflow-spec.d.ts +15 -2
  276. package/dist/runner/workflow-spec.js +63 -23
  277. package/dist/runs-over-store.d.ts +17 -3
  278. package/dist/runs-over-store.js +59 -20
  279. package/dist/seal-key.js +3 -3
  280. package/dist/sealed-settings-store.d.ts +5 -2
  281. package/dist/sealed-settings-store.js +10 -4
  282. package/dist/secret-writes.d.ts +5 -4
  283. package/dist/secret-writes.js +5 -4
  284. package/dist/server-secrets-store.d.ts +4 -3
  285. package/dist/server-secrets-store.js +15 -9
  286. package/dist/server-secrets.js +3 -2
  287. package/dist/server.d.ts +119 -18
  288. package/dist/server.js +841 -202
  289. package/dist/settings-wake.d.ts +23 -0
  290. package/dist/settings-wake.js +65 -0
  291. package/dist/standard-webhooks.d.ts +4 -1
  292. package/dist/standard-webhooks.js +8 -4
  293. package/dist/store/agent-body.d.ts +14 -3
  294. package/dist/store/agent-body.js +14 -10
  295. package/dist/store/command-wake.d.ts +13 -0
  296. package/dist/store/command-wake.js +37 -0
  297. package/dist/store/dialect.d.ts +6 -0
  298. package/dist/store/dialect.js +5 -0
  299. package/dist/store/index.d.ts +1 -1
  300. package/dist/store/journal/storage.d.ts +3 -2
  301. package/dist/store/journal/storage.js +13 -5
  302. package/dist/store/postgres/connection.js +3 -1
  303. package/dist/store/postgres/dialect.js +4 -0
  304. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  305. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  306. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  307. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  308. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  309. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  310. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  311. package/dist/store/schema.d.ts +10 -1
  312. package/dist/store/schema.js +104 -15
  313. package/dist/store/sqlite/connection.d.ts +2 -2
  314. package/dist/store/sqlite/connection.js +2 -2
  315. package/dist/store/sqlite/run-patch.d.ts +7 -5
  316. package/dist/store/sqlite/run-patch.js +45 -18
  317. package/dist/store/sqlite/store.js +331 -72
  318. package/dist/store/store.d.ts +312 -21
  319. package/dist/store/store.js +12 -1
  320. package/dist/store-reads/cap.d.ts +1 -1
  321. package/dist/store-reads/cap.js +8 -1
  322. package/dist/store-reads/decisions.d.ts +2 -2
  323. package/dist/store-reads/decisions.js +1 -1
  324. package/dist/store-reads/import-summary.d.ts +1 -1
  325. package/dist/store-reads/journal.d.ts +30 -5
  326. package/dist/store-reads/journal.js +128 -56
  327. package/dist/store-reads/learning.d.ts +114 -12
  328. package/dist/store-reads/learning.js +238 -48
  329. package/dist/store-reads/loop.d.ts +61 -0
  330. package/dist/store-reads/loop.js +111 -0
  331. package/dist/store-reads/runs.d.ts +1 -1
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-view.d.ts +6 -0
  334. package/dist/store-view.js +59 -26
  335. package/dist/template-eval.d.ts +18 -9
  336. package/dist/template-eval.js +95 -68
  337. package/dist/template-github-permissions.d.ts +24 -10
  338. package/dist/template-github-permissions.js +36 -15
  339. package/dist/template-import.d.ts +31 -0
  340. package/dist/template-import.js +121 -0
  341. package/dist/template-source.d.ts +51 -0
  342. package/dist/template-source.js +371 -0
  343. package/dist/templates.d.ts +218 -46
  344. package/dist/templates.js +493 -181
  345. package/dist/timeline/computer.d.ts +48 -0
  346. package/dist/timeline/computer.js +169 -0
  347. package/dist/timeline/index.d.ts +4 -3
  348. package/dist/timeline/index.js +4 -3
  349. package/dist/timeline/labels.d.ts +6 -2
  350. package/dist/timeline/labels.js +93 -2
  351. package/dist/timeline/origin.d.ts +19 -5
  352. package/dist/timeline/origin.js +11 -4
  353. package/dist/timeline/timeline.d.ts +22 -1
  354. package/dist/timeline/timeline.js +34 -18
  355. package/dist/timeline/util.d.ts +4 -0
  356. package/dist/timeline/util.js +14 -0
  357. package/dist/tool-gate.d.ts +84 -50
  358. package/dist/tool-gate.js +179 -101
  359. package/dist/tool-keys.d.ts +4 -1
  360. package/dist/tool-keys.js +8 -3
  361. package/dist/tool-list.d.ts +26 -0
  362. package/dist/tool-list.js +43 -0
  363. package/dist/tool-names.d.ts +71 -0
  364. package/dist/tool-names.js +99 -0
  365. package/dist/tool-plane.d.ts +33 -27
  366. package/dist/tool-plane.js +72 -39
  367. package/dist/tools.d.ts +32 -7
  368. package/dist/tools.js +37 -24
  369. package/dist/trigger-adapter.d.ts +4 -0
  370. package/dist/trigger-secrets-shown.d.ts +2 -2
  371. package/dist/trigger-secrets-shown.js +1 -1
  372. package/dist/trigger-signatures.d.ts +25 -6
  373. package/dist/trigger-signatures.js +41 -7
  374. package/dist/trigger-targets.d.ts +2 -0
  375. package/dist/trigger-targets.js +1 -0
  376. package/dist/trigger-webhook.js +5 -2
  377. package/dist/triggers.d.ts +7 -3
  378. package/dist/triggers.js +35 -5
  379. package/dist/turns.js +16 -1
  380. package/dist/validate.d.ts +15 -7
  381. package/dist/validate.js +102 -45
  382. package/dist/web-fetch.d.ts +2 -8
  383. package/dist/web-fetch.js +2 -22
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +145 -102
  387. package/dist/webhooks.js +559 -322
  388. package/dist/workflow/decisions.d.ts +1 -1
  389. package/dist/workflow/node-runner.d.ts +2 -1
  390. package/dist/workflow/node.d.ts +2 -1
  391. package/dist/workflow/node.js +3 -1
  392. package/dist/workflow/pi-versions.d.ts +23 -0
  393. package/dist/workflow/pi-versions.js +57 -0
  394. package/dist/workflow/record-tool.d.ts +2 -1
  395. package/dist/workflow/store.d.ts +1 -1
  396. package/dist/workflow/task.js +3 -2
  397. package/dist/workflow-run.d.ts +1 -1
  398. package/dist/workspace/attached-computers.d.ts +41 -0
  399. package/dist/workspace/attached-computers.js +114 -0
  400. package/dist/workspace/computer-deps.d.ts +19 -9
  401. package/dist/workspace/computer-deps.js +24 -9
  402. package/dist/workspace/computer-for-claim.d.ts +23 -8
  403. package/dist/workspace/computer-for-claim.js +92 -33
  404. package/dist/workspace/computer-hold.d.ts +11 -27
  405. package/dist/workspace/computer-hold.js +41 -55
  406. package/dist/workspace/computer-ledger.d.ts +3 -1
  407. package/dist/workspace/computer-ledger.js +4 -0
  408. package/dist/workspace/computer-mcp.d.ts +25 -0
  409. package/dist/workspace/computer-mcp.js +41 -0
  410. package/dist/workspace/computer-ports.d.ts +4 -13
  411. package/dist/workspace/computer-ports.js +4 -107
  412. package/dist/workspace/computer-script.d.ts +53 -0
  413. package/dist/workspace/computer-script.js +172 -0
  414. package/dist/workspace/executors.d.ts +1 -1
  415. package/dist/workspace/index.d.ts +4 -2
  416. package/dist/workspace/index.js +3 -1
  417. package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
  418. package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
  419. package/dist/workspace/local.js +2 -2
  420. package/dist/workspace/resolve-computer.d.ts +24 -1
  421. package/dist/workspace/resolve-computer.js +40 -16
  422. package/dist/workspace/run-tools.d.ts +56 -21
  423. package/dist/workspace/run-tools.js +55 -34
  424. package/dist/wrap-up.d.ts +21 -0
  425. package/dist/wrap-up.js +21 -0
  426. package/launcher/agentrun-serve +4 -2
  427. package/package.json +19 -16
  428. package/templates/README.md +111 -45
  429. package/templates/code-review/agent.md +30 -14
  430. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  431. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  432. package/templates/code-review/evals/injection/case.yaml +2 -1
  433. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  434. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  435. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  436. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  437. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  438. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  439. package/templates/code-review/evals/null-name/case.yaml +2 -1
  440. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  441. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  442. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  443. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  444. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  445. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  446. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  447. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  448. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  449. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  450. package/templates/code-review/evals/re-review/case.yaml +2 -1
  451. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  452. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  453. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  454. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  455. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  456. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  457. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  458. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  459. package/templates/code-review/skills/review/DEEP.md +3 -2
  460. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  461. package/templates/code-review/skills/review/SKILL.md +4 -3
  462. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  463. package/templates/inbound-lead/agent.md +26 -16
  464. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  465. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  466. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  467. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  468. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  469. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  470. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  471. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  472. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  473. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  474. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  475. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  476. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  477. package/templates/kyb/agent.md +15 -5
  478. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  479. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  480. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  481. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  482. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  483. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  484. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  485. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  486. package/templates/kyb/kyb.schema.json +8 -7
  487. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  488. package/templates/market-monitor/agent.md +19 -12
  489. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  490. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  491. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  492. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  493. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  494. package/templates/release-notes/agent.md +32 -10
  495. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  496. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  497. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  498. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  499. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  500. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  501. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  502. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  503. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  504. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  505. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  506. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  507. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  508. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  509. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  510. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  511. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  512. package/templates/release-notes/notes.schema.json +1 -1
  513. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  514. package/dist/console/assets/index-BI4Byidu.js +0 -550
  515. package/dist/console/assets/index-C19gUF2n.css +0 -1
  516. package/dist/run-db.d.ts +0 -53
  517. package/dist/run-db.js +0 -116
  518. package/dist/tool-blurbs.d.ts +0 -4
  519. package/dist/tool-blurbs.js +0 -28
  520. package/dist/tool-budget.d.ts +0 -26
  521. package/dist/tool-budget.js +0 -56
  522. package/dist/workflow/readers.d.ts +0 -36
  523. package/dist/workflow/readers.js +0 -145
  524. package/dist/workflow/wal.d.ts +0 -11
  525. package/dist/workflow/wal.js +0 -106
  526. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  527. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  528. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  529. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  530. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  531. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  532. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  533. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  534. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  535. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  536. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  537. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  538. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  539. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  540. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  541. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  542. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  543. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  544. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  545. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  546. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  547. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  548. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  549. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  550. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  551. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  552. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  553. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  554. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  555. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  556. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  557. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  558. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  559. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  560. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  561. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  562. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  563. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  564. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  565. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  566. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  567. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  568. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
@@ -73,7 +73,12 @@ export async function learnedDecisionKeys(deps, workflows, allowed) {
73
73
  for (const id of providersNamed(nodes))
74
74
  named.add(id);
75
75
  }
76
- const providers = [...named].filter((id) => allowed(id));
76
+ return hostDecisionKeys(deps, [...named].filter((id) => allowed(id)));
77
+ }
78
+ /** The host's keys of the decision providers `providers` (bare ids), read as claimSecrets reads its keys and scoped by
79
+ * decisionKeysFor; none for none. learnedDecisionKeys hands them to a run; a learning end (LS-07) builds its check's
80
+ * providers on them, host-side, never handed to the run. A fresh object per call. */
81
+ export async function hostDecisionKeys(deps, providers) {
77
82
  if (!providers.length)
78
83
  return {};
79
84
  return decisionKeysFor(await workingEnv(deps), { providers, parallelWeb: false });
@@ -9,6 +9,18 @@ export type { ClaimComputer, ClaimDeps, ClaimLaunch, ComputerForClaim } from "./
9
9
  export type CliSpecDeps = AdapterSpecDeps;
10
10
  /** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
11
11
  export declare const cliRefusesKind: (kind: string) => string | undefined;
12
+ /** A CLI run's environment: the runner's run environment (`env`, runner/main.ts runEnv), built from it itself and never
13
+ * a spread of it, with the model keys the claim opened (`claimed`, withModelKeys) and the server's data directory named
14
+ * (DATA_ENV). The run environment's secrets, and the keys added, are readable by name and never enumerable: the
15
+ * harness's model route finds the key its requests carry (model.ts, `env[row.field]`) while a program spawned with this
16
+ * environment carries none. A spread would drop every secret the launcher handed the runner, and the route would send no
17
+ * key. The data directory is a plain variable, which a spawn carries. So is the run's resolved tool plane (`plane`,
18
+ * TOOL_PLANE_ENV, not a secret), as main hands its per-run process: the adapter reads web_search's there (adapters.ts
19
+ * nativeOptions: claude-agent's WebSearch, codex's live search, admitted by its proxy's policy and priced with it), so a
20
+ * run whose plane resolves it to native gets the harness's own search (#2458), this run's alone; whatever the runner's
21
+ * own environment says of a plane is never the run's. Whether each search runs is the tool's setting at that search
22
+ * (SessionIO.permission, the gate), never this plane, which is frozen when the run is made. */
23
+ export declare function cliRunEnv(env: NodeJS.ProcessEnv | undefined, data: string, claimed?: NodeJS.ProcessEnv, plane?: RunLaunch["plane"]): NodeJS.ProcessEnv;
12
24
  /** `tools` in the order the agent grants them (`granted`, catalog names; a tool is listed by its catalog name's wire
13
25
  * name), as main listed a CLI run's tools to its harness: each granted tool where its grant is, and a tool the grant
14
26
  * does not name (one a granted tool or the run's computer brings beside it) right after the tool listed before it. Ties
@@ -16,9 +28,14 @@ export declare const cliRefusesKind: (kind: string) => string | undefined;
16
28
  export declare function inGrantOrder<T extends {
17
29
  readonly name: string;
18
30
  }>(tools: readonly T[], granted: readonly string[]): T[];
19
- /** A claim's private folder removed, then each of `parents` in order while it is empty: one another claim of the run has
20
- * laid things in since (a follow-up's) stays, with what is in it. */
21
- export declare function sweepScratch(dir: string, parents: readonly string[]): Promise<void>;
31
+ /** Every earlier claim's private folder of the run (`<harnesses>/<n>`, n below `epoch`) removed: what a claim whose runner
32
+ * died left (its release never ran), or a sweep of its own cut off partway. A claim at `epoch` or later (a live one, or a
33
+ * next claim's while this one lets go late) is never touched. Each removal is whole or is finished by the next sweep. */
34
+ export declare function sweepEarlier(harnesses: string, epoch: number): Promise<void>;
35
+ /** A claim's end: every earlier claim's folder of the run (sweepEarlier) and the claim's own (`<harnesses>/<epoch>`)
36
+ * removed, then each of `parents` in order while it is empty: one another claim of the run has laid things in since (a
37
+ * follow-up's) stays, with what is in it. Run again over what a cut-off sweep left, it finishes it. */
38
+ export declare function sweepScratch(harnesses: string, epoch: number, parents: readonly string[]): Promise<void>;
22
39
  /**
23
40
  * One claimed CLI run's AdapterRunSpec, built from its launch record and its revision.
24
41
  *
@@ -13,8 +13,8 @@
13
13
  // Shared with the pi spec: the run's Workspace and its uploaded files, a sandbox run's computer, the kernel registry's
14
14
  // hands on them (runTools), the gate from the store's tool settings, the system prompt (environment line, instructions
15
15
  // with what the agent learned and its skills, effort guidance), the first message, the end's metrics and the release.
16
- import { mkdir, rm, rmdir } from "node:fs/promises";
17
- import { join } from "node:path";
16
+ import { mkdir, readdir, rm, rmdir } from "node:fs/promises";
17
+ import { dirname, join } from "node:path";
18
18
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
19
19
  import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
20
20
  import { checkRaise, followUpOf, parkOf } from "@parcha/agentrun-kernel/kernel/cap";
@@ -22,45 +22,55 @@ import { confineOf, noNewPrivsPrefix, standsIn, thinkingFor } from "../adapters.
22
22
  import { claimSettled, installDirOf, installForClaim, installingWords } from "../harness-install.js";
23
23
  import { HarnessUnavailable } from "../provider.js";
24
24
  import { effortGuidance } from "../effort-guidance.js";
25
+ import { outputContract } from "../answer-json.js";
25
26
  import { wireName } from "../catalog.js";
26
27
  import { environmentLine } from "../environment.js";
27
28
  import { harnessOf } from "../harness-table.js";
28
29
  import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
29
30
  import { laidOf, layLearningSeed } from "./learning-seed.js";
30
31
  import { learningWorkspace } from "../learn/folder.js";
31
- import { learningEndOfRun } from "./learning-end.js";
32
+ import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
32
33
  import { providerModels, runModels } from "../model.js";
33
- import { firstMessage } from "../run-manifest.js";
34
+ import { firstMessage, inputMessage } from "../run-manifest.js";
34
35
  import { learningStartOf, seedFailed } from "../run-launch.js";
35
36
  import { readsFiles, systemOf } from "../skills.js";
36
37
  import { DATA_ENV } from "../server-fs.js";
37
38
  import { copyRunFiles } from "../uploads.js";
38
- import { isObject } from "../validate.js";
39
39
  import { runFolder, scratchFolder } from "../workspace/paths.js";
40
40
  import { openRunWorkspace } from "../workspace/run-workspace.js";
41
41
  import { layOwnSkills } from "../workspace/revision-skills.js";
42
42
  import { runTools, withKindTools } from "../workspace/run-tools.js";
43
43
  import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
44
44
  import { loadArchilSettings } from "../archil-settings.js";
45
- import { computerReadyWords, imageWaitWords } from "../workspace/computer-deps.js";
45
+ import { computerReadyWords, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
46
46
  import { hostLifecycle } from "./adapter-loop.js";
47
- import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, PI_WIRES, webHostTools, webToolNames } from "./adapter-run-spec.js";
47
+ import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
48
48
  import { openTierProxies } from "./adapters/pi.js";
49
49
  import { signInReads } from "../sign-ins-store.js";
50
50
  import { mcpServersOf } from "../tool-gate.js";
51
- import { claimSecrets, learnedDecisionKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
51
+ import { isWebHostTool } from "../tool-list.js";
52
+ import { hostToolOf } from "../host-tools.js";
53
+ import { ASK_TOOL, askPerson } from "../tools.js";
54
+ import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
52
55
  import { mcpForClaim } from "./mcp-run.js";
53
- import { TOOL_PLANE_ENV } from "../tool-plane.js";
56
+ import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
57
+ import { decisionProvidersIn } from "../decisions.js";
54
58
  import { resolveHarness } from "./adapters/index.js";
55
59
  import { entriesOf } from "./loop.js";
56
- import { bookedSpend, cliModelWorked, cliRunMetrics } from "./metrics.js";
60
+ import { bookedSpend, cliModelWorked, cliRunMetrics, runEndCost } from "./metrics.js";
57
61
  import { journalEntries } from "./journal-reader.js";
62
+ import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid } from "./promotion.js";
63
+ import { laidFor, pathMetrics, workflowFirstOf } from "./workflow-first.js";
64
+ import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
58
65
  import { specBuilt } from "./spec-holds.js";
59
66
  import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
67
+ import { heldSpecOf } from "./held-run.js";
68
+ import { loopComputerOf } from "./computer-channel.js";
60
69
  import { githubAppAccess } from "./github-app.js";
61
70
  import { prCheckoutForClaim } from "./pr-checkout.js";
62
71
  import { holdStored, storeSecrets } from "./store-secrets.js";
63
72
  import { bashPolicyOf } from "../bash-read-only.js";
73
+ import { monidForClaim, withMonid } from "./monid-run.js";
64
74
  /** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
65
75
  export const cliRefusesKind = (kind) => kind === "browser" ? "This agent's computer is a browser, which only the pi harness drives here: pick pi for this agent, or another kind of computer in Settings → Computers." : undefined;
66
76
  /** The run's model and the catalog that prices it, as main chooses a CLI run's (app.ts wireModels and runModels): on the
@@ -101,10 +111,18 @@ function capModelOf(id, wire, listed, unpriced) {
101
111
  * (DATA_ENV). The run environment's secrets, and the keys added, are readable by name and never enumerable: the
102
112
  * harness's model route finds the key its requests carry (model.ts, `env[row.field]`) while a program spawned with this
103
113
  * environment carries none. A spread would drop every secret the launcher handed the runner, and the route would send no
104
- * key. The data directory is a plain variable, which a spawn carries. */
105
- function cliRunEnv(env, data, claimed = {}) {
114
+ * key. The data directory is a plain variable, which a spawn carries. So is the run's resolved tool plane (`plane`,
115
+ * TOOL_PLANE_ENV, not a secret), as main hands its per-run process: the adapter reads web_search's there (adapters.ts
116
+ * nativeOptions: claude-agent's WebSearch, codex's live search, admitted by its proxy's policy and priced with it), so a
117
+ * run whose plane resolves it to native gets the harness's own search (#2458), this run's alone; whatever the runner's
118
+ * own environment says of a plane is never the run's. Whether each search runs is the tool's setting at that search
119
+ * (SessionIO.permission, the gate), never this plane, which is frozen when the run is made. */
120
+ export function cliRunEnv(env, data, claimed = {}, plane) {
106
121
  const out = withModelKeys(env ?? {}, claimed);
107
122
  Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
123
+ delete out[TOOL_PLANE_ENV];
124
+ if (plane && Object.keys(plane).length)
125
+ Object.defineProperty(out, TOOL_PLANE_ENV, { value: JSON.stringify(plane), enumerable: true, writable: true, configurable: true });
108
126
  return out;
109
127
  }
110
128
  /** `tools` in the order the agent grants them (`granted`, catalog names; a tool is listed by its catalog name's wire
@@ -122,19 +140,54 @@ export function inGrantOrder(tools, granted) {
122
140
  });
123
141
  return keyed.sort((a, b) => a.key - b.key || a.given - b.given).map(({ tool }) => tool);
124
142
  }
125
- /** A claim's private folder removed, then each of `parents` in order while it is empty: one another claim of the run has
126
- * laid things in since (a follow-up's) stays, with what is in it. */
127
- export async function sweepScratch(dir, parents) {
128
- await rm(dir, { recursive: true, force: true });
143
+ /** Every earlier claim's private folder of the run (`<harnesses>/<n>`, n below `epoch`) removed: what a claim whose runner
144
+ * died left (its release never ran), or a sweep of its own cut off partway. A claim at `epoch` or later (a live one, or a
145
+ * next claim's while this one lets go late) is never touched. Each removal is whole or is finished by the next sweep. */
146
+ export async function sweepEarlier(harnesses, epoch) {
147
+ let names;
148
+ try {
149
+ names = await readdir(harnesses);
150
+ }
151
+ catch (error) {
152
+ if (error.code === "ENOENT")
153
+ return;
154
+ throw error;
155
+ }
156
+ for (const name of names) {
157
+ if (/^\d+$/.test(name) && Number(name) < epoch)
158
+ await rm(join(harnesses, name), { recursive: true, force: true });
159
+ }
160
+ }
161
+ /** A claim's end: every earlier claim's folder of the run (sweepEarlier) and the claim's own (`<harnesses>/<epoch>`)
162
+ * removed, then each of `parents` in order while it is empty: one another claim of the run has laid things in since (a
163
+ * follow-up's) stays, with what is in it. Run again over what a cut-off sweep left, it finishes it. */
164
+ export async function sweepScratch(harnesses, epoch, parents) {
165
+ // An earlier folder that cannot be swept never keeps this claim's own folder: its removal is attempted anyway, and the
166
+ // earlier failure is thrown after it (with this one's, when both fail).
167
+ const failures = [];
168
+ await sweepEarlier(harnesses, epoch).catch((error) => { failures.push(error); });
169
+ await rm(join(harnesses, String(epoch)), { recursive: true, force: true }).catch((error) => { failures.push(error); });
170
+ if (failures.length === 0)
171
+ await rmEmptyParents(parents);
172
+ else
173
+ await rmEmptyParents(parents).catch((error) => { failures.push(error); });
174
+ if (failures.length === 1)
175
+ throw failures[0];
176
+ if (failures.length > 1)
177
+ throw new AggregateError(failures, failures.map((error) => error?.message ?? String(error)).join("; "));
178
+ }
179
+ async function rmEmptyParents(parents) {
129
180
  for (const parent of parents) {
130
181
  try {
131
182
  await rmdir(parent);
132
183
  }
133
184
  catch (error) {
134
185
  const code = error.code;
135
- if (code === "ENOTEMPTY" || code === "EEXIST" || code === "ENOENT")
186
+ if (code === "ENOTEMPTY" || code === "EEXIST")
136
187
  return;
137
- throw error;
188
+ // Already gone (a sweep cut off after it, or never made): the folder above it may still be left empty.
189
+ if (code !== "ENOENT")
190
+ throw error;
138
191
  }
139
192
  }
140
193
  }
@@ -160,6 +213,18 @@ async function cliSpec(launch, run, deps, claim, holds) {
160
213
  const runRow = await deps.store.runs.get(claim.runId);
161
214
  if (!runRow)
162
215
  throw new Error(`run ${claim.runId}: its row is gone from the store`);
216
+ // The claim's private folder is swept at the spec's release, the claim's end, then the scratch folder if nothing else is
217
+ // in it, then the agent's: the next claim, here or on another runner, lays its own, its harness's session coming back from
218
+ // the run's journal. Its own per claim (by the claim's epoch), so a run reopened while this claim still lets go (its
219
+ // release follows the run's end commit) never has the next claim's folder swept from under it. A claim whose runner died
220
+ // never ran its release: every claim sweeps the earlier claims' folders of its run at its start and again at its end, so
221
+ // a killed CLI's home and session state never outlive the run. Held here, before any step that can fail (the install, the
222
+ // MCP claim, the computer): a claim that fails in its setup still sweeps what the earlier claims left, as specBuilt lets
223
+ // go what was held when the build throws.
224
+ const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
225
+ const harnesses = join(scratch, "harness");
226
+ const dir = join(harnesses, String(claim.epoch));
227
+ holds.hold({ scratch: { sweep: () => sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
163
228
  // Every secret the server keeps sealed (store-secrets.ts) held by the runner's one redactor (the loop's) and this spec's
164
229
  // log cut, before any of the run's text is written: a run's text may quote one it was never handed.
165
230
  for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
@@ -216,13 +281,13 @@ async function cliSpec(launch, run, deps, claim, holds) {
216
281
  });
217
282
  }
218
283
  }
219
- // The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin made at the first claim or read as written, its
284
+ // The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
220
285
  // credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
221
- // Before the session opens: a refusal (a pin that cannot be made, a pinned meta tool) ends the run in its words.
222
- // A credential the claim opens mid-run (a GitHub App token, a per_run server's handed one) joins the run's redactors.
286
+ // Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
287
+ // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
223
288
  const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
224
289
  redact.hold(values); };
225
- const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}) });
290
+ const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.mcpLoopback ? { loopback: true } : {}) });
226
291
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
227
292
  holds.hold({ passed: mcp });
228
293
  // The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
@@ -253,32 +318,32 @@ async function cliSpec(launch, run, deps, claim, holds) {
253
318
  await copyRunFiles(deps.data, claim.runId, ws.workspace, launch.files);
254
319
  // The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
255
320
  // It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
256
- const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
321
+ const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, claim, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
257
322
  // revokeMount removes the run's Archil mount credential at the computer's release (and if a start fails after a mint); the
258
323
  // run's end revokes it too, so it goes on every outcome even with no computer. Idempotent. As the pi spec does, with
259
324
  // what became of the agent's own computer said on the run's timeline.
260
325
  // A browser computer is driven by the browser tool, which runs on pi's native route alone: a CLI's run of an agent
261
326
  // whose computer is a browser is refused in words at its claim, before anything is made.
262
- { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
327
+ { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
263
328
  holds.hold({ computer });
329
+ const loopComputer = loopComputerOf(computer.computer, computer.held);
330
+ const heldComputer = heldSpecOf(launch, loopComputer);
264
331
  // The CLI works in the run's scratch folder on this machine (its working directory), its own files (home, state, the
265
332
  // skills laid for it) in this claim's private folder inside it, never on the run's disk. The scratch is an alias of the
266
333
  // run's folder for the run's file tools: a path the CLI builds from its working directory lands in the run's folder, and
267
334
  // any other absolute path is refused (workspace/paths.ts portPath).
268
- // The private folder is swept at the spec's release, the claim's end, then the scratch folder if nothing else is in it:
269
- // the next claim, here or on another runner, lays its own, its harness's session coming back from the run's journal.
270
- // Its own per claim (by the claim's epoch), so a run reopened while this claim still lets go (its release follows the
271
- // run's end commit) never has the next claim's folder swept from under it.
272
- const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
273
- const harnesses = join(scratch, "harness");
274
- const dir = join(harnesses, String(claim.epoch));
275
- holds.hold({ scratch: { sweep: () => sweepScratch(dir, [harnesses, scratch]) } });
276
- // Made again once if a parent went as it was made (the last claim's sweep removing the then empty scratch folder).
277
- await mkdir(dir, { recursive: true, mode: 0o700 }).catch(async (error) => {
278
- if (error.code !== "ENOENT")
279
- throw error;
280
- await mkdir(dir, { recursive: true, mode: 0o700 });
281
- });
335
+ // Made again if a parent went as it was made (another claim's sweep removing the then empty scratch or agent folder).
336
+ for (let tries = 1;; tries += 1) {
337
+ try {
338
+ await mkdir(dir, { recursive: true, mode: 0o700 });
339
+ break;
340
+ }
341
+ catch (error) {
342
+ if (error.code !== "ENOENT" || tries === 3)
343
+ throw error;
344
+ }
345
+ }
346
+ await sweepEarlier(harnesses, claim.epoch).catch((error) => log(`an earlier claim's scratch folder could not be swept: ${error?.message ?? String(error)}`));
282
347
  // The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
283
348
  // (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
284
349
  // Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv), as the pi spec does.
@@ -289,24 +354,28 @@ async function cliSpec(launch, run, deps, claim, holds) {
289
354
  // The system prompt, as main's harness branch builds it: the environment line, the instructions with what the agent
290
355
  // learned laid in (learning.ts laidLearned, from the launch's learning start, so the runner reads no learning folder), its
291
356
  // own skills through systemOf with the harness's own check (a harness that loads skills itself keeps in the prompt only
292
- // those it would refuse, and is handed the rest), then the effort guidance.
357
+ // those it would refuse, and is handed the rest), the output schema it answers in (answer-json.ts outputContract, as the
358
+ // pi spec gives it), then the effort guidance.
293
359
  const start = learningStartOf(launch);
294
360
  // A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
295
- const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
361
+ const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
296
362
  const check = await entry.skillCheck?.();
297
363
  // The revision's own skills laid before they are read, as the pi spec lays them (adapter-run-spec.ts).
298
364
  await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: launch.computer?.kind });
299
365
  // A learning run's seed laid as the pi spec lays it (runner/learning-seed.ts), its learned skills then in the skill list
300
366
  // the harness is handed (its native skills, or the prompt's), its learned workflows the ones learned_workflow runs.
367
+ const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
368
+ const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
301
369
  const seedLaid = start && !seedFailed(start)
302
370
  ? await layLearningSeed({
303
371
  work: ws.workspace,
304
372
  seed: start.seed,
305
- folder: () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil })),
373
+ folder: learningFolder,
306
374
  own: Object.keys(revisionRow.skills ?? {}),
307
- shown: async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true }),
375
+ shown,
308
376
  log,
309
377
  ...(start.notesOnly ? { workflows: false } : {}),
378
+ ...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
310
379
  })
311
380
  : undefined;
312
381
  const { system: instructions, native } = await systemOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, check, { onDemand: readsFiles(granted) });
@@ -321,7 +390,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
321
390
  const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, revisionRow, launch);
322
391
  for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
323
392
  holdClaimed(redact, claimed);
324
- const env = cliRunEnv(deps.env, deps.data, claimed);
393
+ const env = cliRunEnv(deps.env, deps.data, claimed, launch.plane);
325
394
  const chosen = await modelsOf(entry, env, modelAskOf(launch.model, body.model));
326
395
  // The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
327
396
  // (adapters.ts' noNewPrivsPrefix): on Linux, setpriv --no-new-privs, so a setuid program or file capability it
@@ -378,6 +447,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
378
447
  // The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
379
448
  // uncapped), the model that bills this CLI run priced WITH tiers, strict where the launch says. The loop builds the
380
449
  // kernel runCap from these over the run's own sessions; the spec carries no beforeRequest of its own.
450
+ const besideOf = spentBesideOf(launch, deps.store, claim.runId);
381
451
  const runCap = {
382
452
  capUsd: () => launch.maxCostUsd,
383
453
  // One model per CLI session: every request it sends is the run's model, whatever id its provider names it by. A
@@ -390,6 +460,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
390
460
  return tierRoute && tierRoute.model === id ? capModelOfRoute(tierRoute) : undefined;
391
461
  },
392
462
  ...(launch.capMode === "strict" ? { mode: "strict" } : {}),
463
+ // What its learning runs' grades took beside it, read by every gate with its own sessions (none: it queues none).
464
+ ...(besideOf ? { beside: besideOf } : {}),
393
465
  };
394
466
  const cap = capUsd === undefined
395
467
  ? undefined
@@ -404,7 +476,11 @@ async function cliSpec(launch, run, deps, claim, holds) {
404
476
  // store at each decide — adapterRunGate (RunGate.decide: deny with its words, a pin, allow, ask). The end-of-run turn's
405
477
  // refusal of writes under .learning/ is the adapter loop's own (it knows the turn), never a file's. The run's MCP servers
406
478
  // (mcpServersOf its grants) hold a harness's own name for an MCP tool to that tool's settings.
407
- const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted));
479
+ // A pinned MCP tool is held to the arguments its listing in the run's pin declares (mcp.argumentsOf).
480
+ const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted), mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {});
481
+ // What a script's shell and files are held to: this gate's settings, decided as on the run's computer (gate.script), so a
482
+ // denied bash or write holds inside computer_script too.
483
+ tools.computer?.guard.install(gate.script);
408
484
  // The run's tools: the kernel registry's hands on its Workspace (and computer); the web host tools it is granted
409
485
  // (web_fetch, web_search, monid), bound by the binding the pi spec uses (webHostTools) on the ToolHost the pi spec builds
410
486
  // (buildToolHost); and the learned_workflow tool when the run has it (learnsWorkflows: its revision is agentic and the
@@ -419,14 +495,34 @@ async function cliSpec(launch, run, deps, claim, holds) {
419
495
  // The runner's one redactor (the loop's), else this spec's log cut: the claim's keys join it, and the answers of the tools
420
496
  // that run on them pass it.
421
497
  const held = run.redact ? heldRedactor(run.redact) : cut;
422
- const webNames = webToolNames(granted);
498
+ // The run's monid endpoints (monid-run.ts), one host tool each from its revision's pin, on the claim's keys and beside
499
+ // its MCP tools in the loop's one catalog seam; their answers pass the redactors as the web tools' do.
500
+ const monid = monidForClaim(body.monidPin, { ...claimed }, () => ws.workspace, claim.runId);
501
+ const catalog = withMonid(mcp, monid && { ...monid, tools: monid.tools.map((tool) => answersCut(tool, held)) });
502
+ const webNames = granted.filter(isWebHostTool);
423
503
  let learnedTool;
424
504
  let webTools = [];
425
505
  let life;
426
506
  // The keys the claim hands the run (its web tools and its learned workflow's call nodes run on them): never learned
427
507
  // (learningEndOfRun).
428
508
  let handedKeys = [];
429
- const workflows = seedLaid?.workflows ?? [];
509
+ // A replay run lays the workflow it replays record-only (runner/promotion.ts replayLaid).
510
+ const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
511
+ // The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
512
+ // chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
513
+ // serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
514
+ // five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
515
+ // (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the run asks for its revision.
516
+ const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(claimPromotion({
517
+ store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
518
+ })), revision.body.outputSchema) : {};
519
+ // A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
520
+ await replayClaimed(deps.store, runRow.agentId, launch, firstChoice);
521
+ // A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
522
+ // answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
523
+ const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
524
+ const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
525
+ const workflows = laidFor(laidFlows, firstChoice);
430
526
  const learns = learnsWorkflows(revision.kind, workflows);
431
527
  if (webNames.length || learns) {
432
528
  // The claim's keys (above, already held by the redactors), a copy of its own for the tools' plane below.
@@ -471,25 +567,30 @@ async function cliSpec(launch, run, deps, claim, holds) {
471
567
  // The gate asks a learned_workflow call about its workflow's MCP nodes (adapterRunGate); they run through the run's
472
568
  // own MCP as the loop wraps it. Its model nodes run on the session's one model: what each node's trace says it ran on.
473
569
  gate.learn(workflows);
474
- learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, tiers, ...(mcp ? { mcp } : {}), modelName: () => chosen.model.modelId });
570
+ learnedTool = await learnedWorkflowHostTool({ run, kind: revision.kind, granted, plane: launch.plane, env: toolEnv, work: root, workflows, permissions: gate.permissions, ctx, tiers, ...(catalog ? { mcp: catalog } : {}), workspace: ws.workspace, modelName: () => chosen.model.modelId, ...(replay ? { replay } : {}) });
475
571
  }
476
572
  }
573
+ // ask_person, when granted: pi's own tool (tools.ts askPerson), bound as a host tool the way the web tools are. Its call
574
+ // answers what pi's does; the loop then cuts the CLI's turn at the question (adapter-loop.ts, turn-ending host tools),
575
+ // so the run parks on the person or waits for them in its claim exactly as a pi run does.
576
+ const askTool = granted.includes(ASK_TOOL) ? hostToolOf(ASK_TOOL, askPerson, ctx) : undefined;
477
577
  const session = {
478
578
  key: `run:${claim.runId}`,
479
579
  label: runRow.agentId,
480
- system: [environmentLine(), checkout?.note, instructions, guidance].filter((line) => Boolean(line)),
580
+ system: [environmentLine(), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line)),
481
581
  // The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
482
582
  // redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
483
- tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
583
+ tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), results), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
484
584
  context: "fresh",
485
585
  ...(thinking ? { thinking } : {}),
486
586
  };
487
- const content = isObject(launch.input) && typeof launch.input.content === "string" ? launch.input.content : "";
488
- const input = await firstMessage(content, ws.workspace);
587
+ // A typed input's other fields follow its content as one json block (inputMessage).
588
+ const input = await firstMessage(inputMessage(launch.input), ws.workspace);
489
589
  // The run's end-of-run step, when it learns, the same as the pi spec's: the reflect-and-propose turn over the run's
490
590
  // store, its learning folder where the run's place keeps it — Mode 1 under the data directory, Mode 2 on this claim's
491
591
  // Archil disk — so the proposal is checked against the seed in the run's own Workspace, never this machine's local path.
492
- const endOfRun = learningEndOfRun(launch, {
592
+ // A replay run asks nothing at its end: it is the promotion's, never the agent's to learn from.
593
+ const endOfRun = launch.replay ? undefined : learningEndOfRun(launch, {
493
594
  store: deps.store,
494
595
  data: deps.data,
495
596
  ...(deps.env ? { env: deps.env } : {}),
@@ -499,6 +600,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
499
600
  signIns: signInReads(deps.store, deps.sealKey),
500
601
  handed: handedKeys,
501
602
  stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
603
+ log,
604
+ // A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
605
+ decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
502
606
  learningFolder: archil === undefined
503
607
  ? (agentId) => learningFolderOf(deps.data, agentId)
504
608
  : (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
@@ -512,17 +616,22 @@ async function cliSpec(launch, run, deps, claim, holds) {
512
616
  ...(runner.record ? { record: runner.record } : {}),
513
617
  gate,
514
618
  runCap,
619
+ // The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry), as on pi.
620
+ ...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
515
621
  ...(cap ? { cap } : {}),
516
- // The run's MCP for a harness with its own client (mcp-run.ts), the session the adapter mounts; absent when none.
517
- ...(mcp ? { mcp } : {}),
622
+ // The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
623
+ // the catalog tools the session mounts; absent when none.
624
+ ...(catalog ? { mcp: catalog } : {}),
518
625
  // The run's end-of-run step, when it learns (the spec's, preferred over the loop's deps': adapter-loop.ts stepOf).
519
626
  ...(endOfRun ? { endOfRun } : {}),
520
627
  ...(start ? { learningLaid: laidOf(seedLaid) } : {}),
628
+ ...(workflowFirst ? { workflowFirst } : {}),
629
+ ...(workflowRevise ? { workflowRevise } : {}),
521
630
  // The web tools' install lifecycle, run by the adapter loop, as the pi spec's (they register none today).
522
631
  ...(life ? { lifecycle: life } : {}),
523
632
  agentId: runRow.agentId,
524
- // The run's desktop or phone and the person's hold on it, as the claim made them (as the pi spec gives them).
525
- ...(computer.held ? { computer: computer.held } : {}),
633
+ // The run's computer and the person's hold on a desktop or phone, as the claim made them (as the pi spec gives them).
634
+ ...(loopComputer ? { computer: loopComputer } : {}),
526
635
  workRoot: root,
527
636
  // Where the CLI works (its working directory, the run's folder to its file tools): what its absolute paths are read
528
637
  // against on the run's rows.
@@ -533,23 +642,24 @@ async function cliSpec(launch, run, deps, claim, holds) {
533
642
  // session of its journal), as a pi run's are at its answers' costs and tokens.
534
643
  endPatch: async () => {
535
644
  const entries = await entriesOf(deps.journal(claim), ROOT_CONVERSATION_ID, context);
536
- // Its tokens and model requests, and its model requests' cost, from one read of its booking (cliRunMetrics); its
537
- // decisions (a learned workflow's) at what they were booked at too.
645
+ // Its tokens and model requests, and its model requests' cost, from one read of its booking (cliRunMetrics). Its
646
+ // model requests and its decisions (a learned workflow's, LS-07) at what they were booked at (bookedSpend), and its
647
+ // paid tool calls (a Parallel extract or search, a monid call), booked on the run's one ledger in their own session,
648
+ // are the run's cost (runEndCost: unknown when any part is), as the pi spec's.
538
649
  const all = (await journalEntries(deps.journal(claim), context));
539
650
  const booked = bookedSpend(all, "model");
540
651
  const metrics = cliRunMetrics(entries, booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}` });
541
652
  // A run whose model answered or called a tool with no request booked (its requests went past its model proxy) spent
542
653
  // what no booking read: unknown, never the $0 an empty booking sums to.
543
654
  const model = booked.requests === 0 && cliModelWorked(entries) ? null : booked.usd;
544
- const decisions = bookedSpend(all, "decisions").usd;
545
- const costUsd = model === null || decisions === null ? null : model + decisions;
546
655
  // Its paid tool calls (a Parallel extract or search, a monid call), booked on the run's one ledger in their own
547
- // session, are the run's cost too, as the pi spec's.
548
- const paid = run.ledger?.paid ? run.ledger.paid.spentUsd() : 0;
549
- const total = costUsd === null || paid === null ? null : costUsd + paid;
656
+ // session, and its decisions (a learned workflow's decision nodes) are the run's cost too, as the pi spec's.
657
+ const total = runEndCost({ model, paid: run.ledger?.paid ? run.ledger.paid.spentUsd() : 0, decisions: bookedSpend(all, "decisions").usd });
550
658
  // An unknown cost is written as null, never left out: a follow-up's end clears the cost an earlier end stored.
551
- return { costUsd: total, metrics };
659
+ return { costUsd: total, metrics: { ...metrics, ...pathMetrics(launch, launch.learning ? await runPathOverStore(deps.store, claim.runId, launch.learning, run.redact) : undefined, entries) } };
552
660
  },
661
+ // A run started with hold: true holds its computer for its owner (computer-held.ts), as the pi spec's.
662
+ ...(heldComputer ? { held: heldComputer } : {}),
553
663
  // The run's Archil mount credential is revoked at its end on every outcome, even with no computer (idempotent with
554
664
  // the computer's release). A run that minted none revokes nothing.
555
665
  release: () => holds.release(),
@@ -2,7 +2,9 @@ import type { Command } from "./loop-contract.js";
2
2
  /** stop and cancel both end the run, stopped: a cancel's end says it was cancelled, as main's cancel ends a run for good.
3
3
  * browser_hand_back is a person's answer to the agent's browser hand-over (runner/hand-back.ts). computer_take_over and
4
4
  * computer_hand_back are a person's turn with the run's desktop or phone (computer-commands.ts, runner/computer-journal.ts).
5
- * pause and resume are a workflow run's (runs.ts pause). */
5
+ * computer_call is the computer call channel's: one protocol call on the run's computer (computer-channel.ts,
6
+ * runner/computer-channel.ts). computer_start and computer_release are the owner's, for a computer the run holds
7
+ * (computer-held.ts, runner/held-run.ts). pause and resume are a workflow run's (runs.ts pause). */
6
8
  export declare const COMMAND_KINDS: ReadonlySet<string>;
7
9
  export interface CommandInput {
8
10
  readonly kind: string;
@@ -5,9 +5,23 @@ import { originOf } from "../timeline/index.js";
5
5
  /** stop and cancel both end the run, stopped: a cancel's end says it was cancelled, as main's cancel ends a run for good.
6
6
  * browser_hand_back is a person's answer to the agent's browser hand-over (runner/hand-back.ts). computer_take_over and
7
7
  * computer_hand_back are a person's turn with the run's desktop or phone (computer-commands.ts, runner/computer-journal.ts).
8
- * pause and resume are a workflow run's (runs.ts pause). */
9
- export const COMMAND_KINDS = new Set(["stop", "cancel", "steer", "approve", "deny", "raise", "browser_hand_back", "computer_take_over", "computer_hand_back", "pause", "resume"]);
8
+ * computer_call is the computer call channel's: one protocol call on the run's computer (computer-channel.ts,
9
+ * runner/computer-channel.ts). computer_start and computer_release are the owner's, for a computer the run holds
10
+ * (computer-held.ts, runner/held-run.ts). pause and resume are a workflow run's (runs.ts pause). */
11
+ export const COMMAND_KINDS = new Set(["stop", "cancel", "steer", "approve", "deny", "raise", "browser_hand_back", "computer_take_over", "computer_hand_back", "computer_start", "computer_call", "computer_release", "pause", "resume"]);
10
12
  const text = (value) => typeof value === "string" && value.trim() !== "";
13
+ /** Whether `value` is the JSON text of an object (not an array, not null). */
14
+ const objectText = (value) => {
15
+ if (typeof value !== "string")
16
+ return false;
17
+ try {
18
+ const parsed = JSON.parse(value);
19
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed);
20
+ }
21
+ catch {
22
+ return false;
23
+ }
24
+ };
11
25
  /** Why a command's body is wrong for its kind, or undefined when it is right. */
12
26
  function bodyProblem(kind, body) {
13
27
  switch (kind) {
@@ -42,9 +56,20 @@ function bodyProblem(kind, body) {
42
56
  if (!text(body.ask))
43
57
  return "a computer hand-back names the take it ends (take) or the ask it answers (ask)";
44
58
  return body.outcome === "done" || body.outcome === "cancelled" ? undefined : "a computer hand-back's outcome is done or cancelled";
59
+ case "computer_call":
60
+ if (!text(body.method))
61
+ return "a computer call names its protocol method";
62
+ // A call answers no park (answers: false), so a row written as its run parks never wakes it.
63
+ if (body.answers !== false)
64
+ return "a computer call answers no park (answers: false)";
65
+ // Its params as one JSON text (computer-channel.ts callComputer), so a settle's jsonb never decodes what was typed.
66
+ return body.params === undefined || objectText(body.params) ? undefined : "a computer call's params are a JSON object's text";
67
+ case "computer_start":
68
+ case "computer_release":
45
69
  case "pause":
46
70
  case "resume":
47
- // A workflow run's pause or resume (POST /runs/{id}/pause, /resume): the run's runner takes it; it carries nothing.
71
+ // A held run's start or release (POST /runs/{id}/start, /computer/release), or a workflow run's pause or resume
72
+ // (POST /runs/{id}/pause, /resume): the run's runner takes it; it carries nothing.
48
73
  return Object.keys(body).length === 0 ? undefined : `a ${kind} carries nothing`;
49
74
  default:
50
75
  return undefined;