@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45

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 (388) hide show
  1. package/CHANGELOG.md +231 -0
  2. package/README.md +580 -320
  3. package/dist/acp-package.d.ts +28 -0
  4. package/dist/acp-package.js +23 -0
  5. package/dist/adapter-facts.d.ts +8 -1
  6. package/dist/adapter-facts.js +9 -1
  7. package/dist/adapters.d.ts +5 -0
  8. package/dist/adapters.js +36 -3
  9. package/dist/agent-delete.d.ts +50 -0
  10. package/dist/agent-delete.js +125 -0
  11. package/dist/agents-store.d.ts +9 -3
  12. package/dist/agents-store.js +22 -8
  13. package/dist/agents.d.ts +5 -1
  14. package/dist/agents.js +8 -4
  15. package/dist/api-only.d.ts +8 -3
  16. package/dist/api-only.js +10 -4
  17. package/dist/archil-routes.d.ts +5 -1
  18. package/dist/archil-routes.js +57 -2
  19. package/dist/browser-wait-ended.d.ts +2 -0
  20. package/dist/browser-wait-ended.js +2 -0
  21. package/dist/calendar/ics-faux.d.ts +3 -1
  22. package/dist/calendar/ics-faux.js +12 -2
  23. package/dist/calendar/tools.js +5 -2
  24. package/dist/chatgpt-plan.js +3 -1
  25. package/dist/claude-login.d.ts +135 -0
  26. package/dist/claude-login.js +244 -0
  27. package/dist/cli.js +92 -22
  28. package/dist/composio-preset.d.ts +4 -3
  29. package/dist/composio-preset.js +81 -11
  30. package/dist/composio-triggers.d.ts +34 -2
  31. package/dist/composio-triggers.js +261 -31
  32. package/dist/computer-attach.d.ts +40 -5
  33. package/dist/computer-attach.js +130 -15
  34. package/dist/computer-keys.d.ts +3 -0
  35. package/dist/computer-keys.js +7 -1
  36. package/dist/computer-live.js +3 -2
  37. package/dist/computer-lost.d.ts +11 -0
  38. package/dist/computer-lost.js +19 -0
  39. package/dist/computer-record.d.ts +10 -2
  40. package/dist/computer-record.js +50 -18
  41. package/dist/computer-setting.d.ts +1 -0
  42. package/dist/computer-setting.js +2 -2
  43. package/dist/computers.d.ts +21 -10
  44. package/dist/computers.js +39 -28
  45. package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
  46. package/dist/console/assets/index-DaFsZuzQ.css +1 -0
  47. package/dist/console/index.html +2 -2
  48. package/dist/decisions.d.ts +1 -1
  49. package/dist/dial-relay.d.ts +29 -0
  50. package/dist/dial-relay.js +94 -0
  51. package/dist/email/tools.js +10 -5
  52. package/dist/env-proxy.d.ts +2 -0
  53. package/dist/env-proxy.js +35 -0
  54. package/dist/errors.d.ts +4 -1
  55. package/dist/errors.js +10 -4
  56. package/dist/faux-computers.d.ts +8 -2
  57. package/dist/faux-computers.js +83 -6
  58. package/dist/harness-archive.d.ts +67 -0
  59. package/dist/harness-archive.js +177 -0
  60. package/dist/harness-goose.d.ts +34 -0
  61. package/dist/harness-goose.js +87 -0
  62. package/dist/harness-install.d.ts +21 -0
  63. package/dist/harness-install.js +24 -11
  64. package/dist/harness-opencode/adapter.js +1 -1
  65. package/dist/harness-table.d.ts +59 -3
  66. package/dist/harness-table.js +119 -14
  67. package/dist/harness.d.ts +17 -1
  68. package/dist/harness.js +22 -11
  69. package/dist/host.d.ts +12 -10
  70. package/dist/host.js +19 -16
  71. package/dist/import-worker.d.ts +3 -0
  72. package/dist/import-worker.js +7 -5
  73. package/dist/import.d.ts +22 -1
  74. package/dist/import.js +141 -28
  75. package/dist/key-check.js +3 -0
  76. package/dist/learn/audit.d.ts +6 -6
  77. package/dist/learn/audit.js +3 -7
  78. package/dist/learn/check.d.ts +26 -89
  79. package/dist/learn/check.js +58 -336
  80. package/dist/learn/commit.d.ts +63 -90
  81. package/dist/learn/commit.js +124 -316
  82. package/dist/learn/compile.d.ts +53 -50
  83. package/dist/learn/compile.js +88 -103
  84. package/dist/learn/corrections.d.ts +13 -0
  85. package/dist/learn/corrections.js +23 -0
  86. package/dist/learn/delete.d.ts +17 -0
  87. package/dist/learn/delete.js +42 -0
  88. package/dist/learn/folder.d.ts +35 -47
  89. package/dist/learn/folder.js +118 -134
  90. package/dist/learn/index.d.ts +3 -5
  91. package/dist/learn/index.js +6 -9
  92. package/dist/learn/learning.sh +45 -15
  93. package/dist/learn/promote.d.ts +20 -2
  94. package/dist/learn/promote.js +17 -4
  95. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
  96. package/dist/learn/{skills.js → workflow-draft.js} +65 -59
  97. package/dist/learn/workflow-nodes.d.ts +22 -1
  98. package/dist/learn/workflow-nodes.js +29 -10
  99. package/dist/learned-workflow.js +2 -2
  100. package/dist/learning-cost.d.ts +127 -13
  101. package/dist/learning-cost.js +142 -10
  102. package/dist/learning-routes.d.ts +99 -170
  103. package/dist/learning-routes.js +199 -420
  104. package/dist/learning-run.d.ts +19 -40
  105. package/dist/learning-run.js +23 -93
  106. package/dist/learning-setting.d.ts +4 -4
  107. package/dist/learning-setting.js +6 -6
  108. package/dist/learning-words.d.ts +28 -74
  109. package/dist/learning-words.js +64 -162
  110. package/dist/learning.d.ts +62 -393
  111. package/dist/learning.js +101 -651
  112. package/dist/listen-first.d.ts +30 -0
  113. package/dist/listen-first.js +115 -0
  114. package/dist/live-reach.d.ts +25 -2
  115. package/dist/live-reach.js +46 -4
  116. package/dist/llms.txt +2 -1
  117. package/dist/local-models.d.ts +3 -11
  118. package/dist/local-models.js +5 -6
  119. package/dist/mcp-servers-store.d.ts +16 -16
  120. package/dist/model-form.js +6 -5
  121. package/dist/model.d.ts +12 -4
  122. package/dist/model.js +41 -16
  123. package/dist/native/binding.js +1 -1
  124. package/dist/native/connection.js +1 -1
  125. package/dist/native/discovery.js +1 -1
  126. package/dist/native/instructions.d.ts +3 -0
  127. package/dist/native/instructions.js +5 -3
  128. package/dist/native/remote-worker-bridge.js +9 -43
  129. package/dist/native/remote.d.ts +8 -15
  130. package/dist/native/remote.js +3 -3
  131. package/dist/native/schema.js +1 -1
  132. package/dist/native/types.d.ts +2 -2
  133. package/dist/openapi.js +375 -347
  134. package/dist/owner.d.ts +8 -0
  135. package/dist/owner.js +11 -0
  136. package/dist/paid-calls.d.ts +14 -0
  137. package/dist/paid-calls.js +31 -1
  138. package/dist/particle-provider.d.ts +11 -0
  139. package/dist/particle-provider.js +135 -0
  140. package/dist/place.d.ts +8 -3
  141. package/dist/place.js +13 -9
  142. package/dist/port-models.d.ts +12 -4
  143. package/dist/port-models.js +28 -11
  144. package/dist/print.d.ts +27 -0
  145. package/dist/print.js +21 -0
  146. package/dist/provider.d.ts +7 -0
  147. package/dist/provider.js +30 -2
  148. package/dist/reflect-range.js +2 -3
  149. package/dist/run-launch.d.ts +14 -28
  150. package/dist/run-launch.js +9 -12
  151. package/dist/run-learning-served.d.ts +16 -90
  152. package/dist/run-listing.d.ts +34 -0
  153. package/dist/run-listing.js +128 -0
  154. package/dist/run-model-key.d.ts +64 -0
  155. package/dist/run-model-key.js +147 -0
  156. package/dist/run-timeline-served.js +5 -3
  157. package/dist/run-trace.d.ts +97 -0
  158. package/dist/run-trace.js +253 -0
  159. package/dist/run-view.d.ts +15 -0
  160. package/dist/run-view.js +9 -0
  161. package/dist/runnable.js +2 -1
  162. package/dist/runner/adapter-loop.d.ts +14 -6
  163. package/dist/runner/adapter-loop.js +25 -14
  164. package/dist/runner/adapter-run-spec.d.ts +22 -7
  165. package/dist/runner/adapter-run-spec.js +130 -77
  166. package/dist/runner/adapters/index.d.ts +4 -2
  167. package/dist/runner/adapters/index.js +35 -4
  168. package/dist/runner/adapters/pi.d.ts +4 -12
  169. package/dist/runner/adapters/pi.js +2 -2
  170. package/dist/runner/audit.d.ts +5 -1
  171. package/dist/runner/audit.js +31 -12
  172. package/dist/runner/beside.d.ts +7 -2
  173. package/dist/runner/beside.js +41 -9
  174. package/dist/runner/claim-secrets.d.ts +66 -1
  175. package/dist/runner/claim-secrets.js +136 -3
  176. package/dist/runner/cli-run-spec.d.ts +2 -1
  177. package/dist/runner/cli-run-spec.js +82 -59
  178. package/dist/runner/commands.d.ts +3 -6
  179. package/dist/runner/conformance/harness.d.ts +6 -0
  180. package/dist/runner/conformance/harness.js +16 -5
  181. package/dist/runner/dispatch.d.ts +2 -2
  182. package/dist/runner/end-of-run.d.ts +6 -14
  183. package/dist/runner/end-of-run.js +8 -33
  184. package/dist/runner/feedback-round.d.ts +5 -4
  185. package/dist/runner/feedback-round.js +14 -10
  186. package/dist/runner/github-app.js +3 -1
  187. package/dist/runner/harness-loops.d.ts +0 -8
  188. package/dist/runner/harness-loops.js +30 -56
  189. package/dist/runner/held.d.ts +170 -0
  190. package/dist/runner/held.js +57 -0
  191. package/dist/runner/journal-kinds.d.ts +7 -3
  192. package/dist/runner/journal-kinds.js +2 -3
  193. package/dist/runner/learned-first.d.ts +40 -0
  194. package/dist/runner/learned-first.js +32 -0
  195. package/dist/runner/learning-end.d.ts +77 -66
  196. package/dist/runner/learning-end.js +250 -299
  197. package/dist/runner/learning-seed.d.ts +15 -33
  198. package/dist/runner/learning-seed.js +24 -45
  199. package/dist/runner/loop-contract.d.ts +8 -3
  200. package/dist/runner/loop-contract.js +4 -0
  201. package/dist/runner/loop.js +6 -2
  202. package/dist/runner/main.d.ts +18 -9
  203. package/dist/runner/main.js +82 -22
  204. package/dist/runner/mcp-run.d.ts +11 -0
  205. package/dist/runner/mcp-run.js +67 -0
  206. package/dist/runner/memory-claim.d.ts +14 -6
  207. package/dist/runner/memory-claim.js +18 -9
  208. package/dist/runner/model-route.d.ts +7 -4
  209. package/dist/runner/model-route.js +22 -10
  210. package/dist/runner/native-loop.d.ts +0 -7
  211. package/dist/runner/native-loop.js +9 -101
  212. package/dist/runner/promotion.d.ts +13 -6
  213. package/dist/runner/promotion.js +63 -17
  214. package/dist/runner/reflect-hook.d.ts +64 -91
  215. package/dist/runner/reflect-hook.js +112 -206
  216. package/dist/runner/run-channel.d.ts +43 -0
  217. package/dist/runner/run-channel.js +467 -0
  218. package/dist/runner/run-child-host.d.ts +169 -0
  219. package/dist/runner/run-child-host.js +1222 -0
  220. package/dist/runner/run-child.d.ts +1 -0
  221. package/dist/runner/run-child.js +254 -0
  222. package/dist/runner/run-errors.d.ts +2 -0
  223. package/dist/runner/run-errors.js +20 -0
  224. package/dist/runner/runner.js +58 -9
  225. package/dist/runner/sdk-ask.d.ts +78 -0
  226. package/dist/runner/sdk-ask.js +158 -0
  227. package/dist/runner/sdk-loop.d.ts +2 -4
  228. package/dist/runner/sdk-loop.js +29 -49
  229. package/dist/runner/store-secrets.d.ts +5 -3
  230. package/dist/runner/store-secrets.js +14 -6
  231. package/dist/runner/workflow-first.d.ts +5 -0
  232. package/dist/runner/workflow-first.js +4 -0
  233. package/dist/runner/workflow-spec.js +17 -4
  234. package/dist/runs-over-store.d.ts +21 -32
  235. package/dist/runs-over-store.js +44 -41
  236. package/dist/sdk/runs.d.ts +6 -11
  237. package/dist/sdk/runs.js +20 -41
  238. package/dist/sdk/schema.js +3 -4
  239. package/dist/sdk/workflows.d.ts +1 -1
  240. package/dist/seal-key.d.ts +5 -0
  241. package/dist/seal-key.js +7 -0
  242. package/dist/secrets.d.ts +3 -0
  243. package/dist/secrets.js +16 -3
  244. package/dist/server.d.ts +119 -83
  245. package/dist/server.js +1121 -419
  246. package/dist/sign-ins-store.d.ts +8 -0
  247. package/dist/sign-ins-store.js +36 -1
  248. package/dist/skills.js +1 -1
  249. package/dist/store/index.d.ts +3 -3
  250. package/dist/store/index.js +2 -2
  251. package/dist/store/journal/storage.js +3 -0
  252. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  253. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  254. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  255. package/dist/store/schema.d.ts +53 -4
  256. package/dist/store/schema.js +137 -6
  257. package/dist/store/seal.d.ts +20 -2
  258. package/dist/store/seal.js +24 -8
  259. package/dist/store/sqlite/connection.d.ts +2 -0
  260. package/dist/store/sqlite/connection.js +3 -1
  261. package/dist/store/sqlite/run-launch.d.ts +4 -1
  262. package/dist/store/sqlite/run-launch.js +12 -0
  263. package/dist/store/sqlite/run-patch.d.ts +0 -17
  264. package/dist/store/sqlite/run-patch.js +4 -33
  265. package/dist/store/sqlite/store.d.ts +3 -2
  266. package/dist/store/sqlite/store.js +360 -75
  267. package/dist/store/sqlite/worker.js +25 -0
  268. package/dist/store/store.d.ts +231 -39
  269. package/dist/store/store.js +25 -3
  270. package/dist/store-reads/analytics.js +11 -1
  271. package/dist/store-reads/learning.d.ts +131 -194
  272. package/dist/store-reads/learning.js +292 -301
  273. package/dist/store-reads/loop.d.ts +0 -1
  274. package/dist/store-reads/loop.js +1 -1
  275. package/dist/store-reads/stats.js +13 -3
  276. package/dist/store-view.d.ts +34 -2
  277. package/dist/store-view.js +108 -41
  278. package/dist/telemetry.d.ts +59 -0
  279. package/dist/telemetry.js +153 -0
  280. package/dist/template-eval.d.ts +3 -6
  281. package/dist/template-eval.js +22 -36
  282. package/dist/templates.d.ts +2 -1
  283. package/dist/templates.js +6 -3
  284. package/dist/timeline/index.d.ts +1 -1
  285. package/dist/timeline/index.js +1 -1
  286. package/dist/timeline/timeline.d.ts +5 -1
  287. package/dist/timeline/timeline.js +16 -0
  288. package/dist/tool-gate.d.ts +0 -7
  289. package/dist/tool-gate.js +1 -15
  290. package/dist/tool-keys-store.d.ts +1 -1
  291. package/dist/tool-keys.d.ts +6 -4
  292. package/dist/tool-keys.js +12 -6
  293. package/dist/tool-plane.d.ts +12 -12
  294. package/dist/tools.d.ts +13 -13
  295. package/dist/tools.js +29 -9
  296. package/dist/trigger-adapter.d.ts +3 -0
  297. package/dist/trigger-adapters.d.ts +4 -0
  298. package/dist/trigger-adapters.js +13 -0
  299. package/dist/trigger-composio.d.ts +58 -1
  300. package/dist/trigger-composio.js +160 -6
  301. package/dist/triggers.d.ts +64 -5
  302. package/dist/triggers.js +141 -17
  303. package/dist/validate.d.ts +11 -7
  304. package/dist/validate.js +9 -8
  305. package/dist/webhooks.d.ts +4 -1
  306. package/dist/webhooks.js +11 -4
  307. package/dist/workspace/agent-computer.d.ts +2 -0
  308. package/dist/workspace/agent-computer.js +2 -0
  309. package/dist/workspace/archil-claim.d.ts +7 -0
  310. package/dist/workspace/archil-claim.js +29 -0
  311. package/dist/workspace/archil.d.ts +9 -1
  312. package/dist/workspace/archil.js +165 -3
  313. package/dist/workspace/attach.d.ts +3 -1
  314. package/dist/workspace/attach.js +2 -0
  315. package/dist/workspace/attached-computers.d.ts +16 -5
  316. package/dist/workspace/attached-computers.js +25 -9
  317. package/dist/workspace/computer-deps.js +1 -1
  318. package/dist/workspace/computer-for-claim.d.ts +22 -8
  319. package/dist/workspace/computer-for-claim.js +339 -46
  320. package/dist/workspace/computer-hold.js +2 -1
  321. package/dist/workspace/computer-kept.d.ts +11 -1
  322. package/dist/workspace/computer-kept.js +24 -3
  323. package/dist/workspace/resolve-computer.d.ts +41 -21
  324. package/dist/workspace/resolve-computer.js +172 -64
  325. package/dist/workspace/revision-skills.d.ts +1 -2
  326. package/dist/workspace/revision-skills.js +3 -4
  327. package/dist/workspace/run-workspace.d.ts +1 -1
  328. package/dist/workspace/run-workspace.js +5 -0
  329. package/dist/workspace/synced-folder.d.ts +85 -0
  330. package/dist/workspace/synced-folder.js +230 -0
  331. package/dist/workspace/workspace.d.ts +4 -0
  332. package/launcher/agentrun-serve +1 -1
  333. package/package.json +10 -9
  334. package/templates/README.md +7 -7
  335. package/templates/inbound-lead/agent.md +3 -3
  336. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  337. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  338. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  339. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  340. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  341. package/templates/inbound-lead/lead.schema.json +6 -5
  342. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  343. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  344. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  345. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  346. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  347. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  348. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  349. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  350. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  351. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  352. package/dist/console/assets/index-BrcDSBD8.css +0 -1
  353. package/dist/console/assets/index-Bz6IWncl.js +0 -711
  354. package/dist/learn/grade.d.ts +0 -138
  355. package/dist/learn/grade.js +0 -682
  356. package/dist/learn/notes.d.ts +0 -81
  357. package/dist/learn/notes.js +0 -178
  358. package/dist/learn/reflect.d.ts +0 -77
  359. package/dist/learn/reflect.js +0 -228
  360. package/dist/learn/relevance.d.ts +0 -24
  361. package/dist/learn/relevance.js +0 -91
  362. package/dist/learn/seed-check.d.ts +0 -74
  363. package/dist/learn/seed-check.js +0 -103
  364. package/dist/learning-batch.d.ts +0 -291
  365. package/dist/learning-batch.js +0 -600
  366. package/dist/learning-evals.d.ts +0 -33
  367. package/dist/learning-evals.js +0 -98
  368. package/dist/native/context.d.ts +0 -6
  369. package/dist/native/context.js +0 -22
  370. package/dist/propose.d.ts +0 -52
  371. package/dist/propose.js +0 -224
  372. package/dist/runner/learning-ask.d.ts +0 -47
  373. package/dist/runner/learning-ask.js +0 -128
  374. package/dist/runner/learning-dispatch.d.ts +0 -45
  375. package/dist/runner/learning-dispatch.js +0 -99
  376. package/dist/runner/learning-factory.d.ts +0 -16
  377. package/dist/runner/learning-factory.js +0 -50
  378. package/dist/runner/learning-loop.d.ts +0 -273
  379. package/dist/runner/learning-loop.js +0 -521
  380. package/dist/usage.d.ts +0 -11
  381. package/dist/usage.js +0 -11
  382. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  383. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  384. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  385. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  386. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  387. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  388. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
@@ -1,10 +1,24 @@
1
+ // The runner's pi spec (design 2.1: "the runner takes every run"). What app.ts built for a run it launched — the run's
2
+ // workspace, its computer, its tools, its model route, its spend cap and its end metrics — built here instead, from the
3
+ // run's launch record and its revision, and handed to the kernel's adapter loop (adapter-loop.ts) as one AdapterRunSpec.
4
+ // The dispatch switch (dispatch.ts resolve) runs a pi run on `createAdapterLoop((claim, run) =>
5
+ // adapterRunSpecFromLaunch(launch, run, deps, claim, runner))`, and so does a harness a module adds with no adapter facts
6
+ // of its own: the session's adapter is the run's runner's (RunnerHarness.adapter), pi's for a pi run.
7
+ //
8
+ // The one ledger (B2c): pi's model requests go through the session's proxy, booked by the runner's booking under the
9
+ // run's cap; the cap prices a request as main's calculateCost does (tiers included), on the hold and the booking. The
10
+ // tools are the kernel registry's hands on the run's Workspace (runTools), and — once built through the ToolHost below —
11
+ // tools.ts's full set (browser, web, MCP, decisions, monid) by their own names. The gate before a call's intent is the
12
+ // run's revision's tool settings, read through runGate (approvals "never" among them), the adapter loop asking it.
13
+ import { dirname, join } from "node:path";
14
+ import { stopRunWith } from "../paid-calls.js";
1
15
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
2
16
  import { defineExtension, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
3
17
  import { checkRaise, followUpOf, freeModelRequestsOf, parkOf, planCapModel } from "@parcha/agentrun-kernel/kernel/cap";
4
18
  import { inspectWorkflow } from "@parcha/agentrun-dsl";
5
19
  import { decisionProvidersIn } from "../decisions.js";
6
20
  import { dropLiveViewer, putLiveViewer } from "../browser-live.js";
7
- import { runnerLiveOf } from "../live-reach.js";
21
+ import { liveForRun, runnerLiveOf } from "../live-reach.js";
8
22
  import { llmTiers, nodeTiers, thinkingLevel, TIERS, tierModelOf, workflowNodes } from "../model.js";
9
23
  import { firstMessage, inputMessage, messageText } from "../run-manifest.js";
10
24
  import { learningStartOf, seedFailed } from "../run-launch.js";
@@ -29,28 +43,31 @@ import { PORT_PROVIDER, tieredModels, tierProvider } from "../port-models.js";
29
43
  import { promptOf, readsFiles } from "../skills.js";
30
44
  import { openRunWorkspace } from "../workspace/run-workspace.js";
31
45
  import { layOwnSkills } from "../workspace/revision-skills.js";
32
- import { COMPUTER_ROOT, recordingsFolder, runFolder } from "../workspace/paths.js";
46
+ import { COMPUTER_ROOT, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
33
47
  import { runTools, withKindTools } from "../workspace/run-tools.js";
34
48
  import { placeRunInputs } from "../uploads.js";
35
49
  import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
36
50
  import { UNREADABLE_SIGN_IN } from "../run-view.js";
37
51
  import { durableWait } from "../workflow/pi-versions.js";
38
- import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
39
- import { catalogSessionNames, mcpForClaim } from "./mcp-run.js";
52
+ import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
53
+ import { catalogSessionNames, mcpWhereHeld } from "./mcp-run.js";
54
+ import { held as runnerSeam, heldOrThrow, heldSignInReads } from "./held.js";
40
55
  import { hostLifecycle } from "./adapter-loop.js";
41
- import { piAdapter } from "./adapters/pi.js";
56
+ import { RUNNER_HARNESSES } from "./adapters/index.js";
57
+ import { DEFAULT_HARNESS } from "../harness.js";
42
58
  import { agentEntriesOf } from "./loop.js";
43
59
  import { SUBAGENT_TIERS, SUBAGENT_TOOL, subagentTool } from "./subagent.js";
44
60
  import { ClaimRefused } from "./loop-contract.js";
45
61
  import { bookedSpend, cliRunMetrics, endCostOf, runCostOf, runMetrics } from "./metrics.js";
46
62
  import { journalEntries } from "./journal-reader.js";
47
63
  import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
48
- import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid, toolFlowsFor } from "./promotion.js";
49
- import { pathMetrics, servedOf, workflowFirstOf } from "./workflow-first.js";
50
- import { AUDIT_PARKED, settleAudits, withAudit } from "./audit.js";
51
- import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
64
+ import { replayCallsOver } from "./promotion.js";
65
+ import { learnedFirstWhereHeld } from "./learned-first.js";
66
+ import { pathMetrics, servedOf } from "./workflow-first.js";
67
+ import { AUDIT_PARKED, withAudit } from "./audit.js";
68
+ import { runPathOverStore } from "../store-reads/learning.js";
52
69
  import { specBuilt } from "./spec-holds.js";
53
- import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
70
+ import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
54
71
  import { loadArchilSettings } from "../archil-settings.js";
55
72
  import { settingOfDefinition } from "../computer-setting.js";
56
73
  import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
@@ -96,6 +113,11 @@ export function capModelOf(route) {
96
113
  // The cap reads a request's provider overhead by the route's own wire (providerInputOverhead).
97
114
  return { id: route.model, api: route.provider.api, price, outputCeiling: route.outputCeiling ?? null };
98
115
  }
116
+ /** Particle requests are never automatically replayed after an uncertain failure. Retry is a harness-wide setting,
117
+ * so a claim with any Particle route disables it for all its conversations, including subagents on other tiers. */
118
+ export function modelRetryOf(routes) {
119
+ return [...routes].some((route) => route.like?.translatedChatCompletions) ? { retry: { enabled: false } } : {};
120
+ }
99
121
  /** The key of a subagent tier's route in a run's tier routes and proxies (a key of its own, never a learned workflow's
100
122
  * tier: those nodes keep their own route and fallback). */
101
123
  const SUBAGENT_ROUTE = "subagent-";
@@ -203,12 +225,14 @@ export async function storeSettings(store) {
203
225
  return { settings: {}, problems: ["the stored tool settings could not be read"], unreadable: true };
204
226
  }
205
227
  }
206
- /** pi's spec for a claimed run. What it makes for the run (its Archil mount credential, its Workspace, its computer, its
207
- * tools) is held until the spec's release; a build that throws part-way lets go what it made by then (spec-holds.ts). */
208
- export function adapterRunSpecFromLaunch(launch, run, deps, claim) {
209
- return specBuilt((holds) => adapterSpec(launch, run, deps, claim, holds));
228
+ /** pi's spec for a claimed run, on `runner`'s adapter (pi's when none is given; a harness module's runner for a harness it
229
+ * adds with no adapter facts), its visible record kept as that runner says (RunnerHarness.record). What it makes for the
230
+ * run (its Archil mount credential, its Workspace, its computer, its tools) is held until the spec's release; a build
231
+ * that throws part-way lets go what it made by then (spec-holds.ts). */
232
+ export function adapterRunSpecFromLaunch(launch, run, deps, claim, runner = RUNNER_HARNESSES[DEFAULT_HARNESS]) {
233
+ return specBuilt((holds) => adapterSpec(launch, run, deps, claim, holds, runner));
210
234
  }
211
- async function adapterSpec(launch, run, deps, claim, holds) {
235
+ async function adapterSpec(launch, run, deps, claim, holds, runner) {
212
236
  const context = BACKGROUND_CONTEXT;
213
237
  // What this claim may reach on loopback, read once for its MCP servers and its calendar_events alike (mcpReachOf).
214
238
  const reach = await mcpReachOf(deps);
@@ -223,7 +247,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
223
247
  throw new Error(`run ${claim.runId}: its row is gone from the store`);
224
248
  // A run handed a browser sign-in this runner can't read back (its seal does not open here, or nothing of it is kept):
225
249
  // what it said could repeat a pointer nothing can cut, so it ends failed at its claim, in main's words (runs.ts).
226
- if (!(await handedSignInReadsBack(deps.store, deps.sealKey, runRow)))
250
+ if (!(await (deps.sealKey ? handedSignInReadsBack(deps.store, deps.sealKey, runRow) : heldOrThrow("a handed sign-in's read-back").signInReadsBack())))
227
251
  throw new ClaimRefused(UNREADABLE_SIGN_IN);
228
252
  const revisionRow = await deps.store.agents.revision(runRow.revisionId);
229
253
  if (!revisionRow)
@@ -246,7 +270,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
246
270
  // with no computer makes no control-plane call. mountControl (a test's loopback control-plane fake) is spread into the
247
271
  // mount, so no test reaches the real control plane. MOUNT_TTL_MS is the credential's safety net (its computer's 24 h bound), not its lifetime.
248
272
  // The disk is the run's (run-disk.ts): its launch record's, else its agent's, made on its first run that needs one.
249
- : await archilClaim({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
273
+ : await archilWhereHeld({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
250
274
  // Each resource is held the moment it exists (spec-holds.ts): a throw after it lets it go.
251
275
  holds.hold({ archil });
252
276
  // The run's Workspace at the claim: Mode 1 the run's local folder (made here, the server's start made it before); Mode 2
@@ -257,8 +281,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
257
281
  holds.hold({ ws });
258
282
  // The run's uploaded files, copied into its work/inputs/ before the first turn, from what its start held for it, once
259
283
  // per run (uploads.ts copyRunFiles), and its opening message saved beside them as inputs/message.md (placeRunInputs);
260
- // a copy that fails ends the run failed, saying why.
261
- await placeRunInputs(deps.data, claim.runId, ws.workspace, launch.files ?? [], messageText(launch.input));
284
+ // a copy that fails ends the run failed, saying why. A run's own process copies nothing: its runner placed them before
285
+ // the process started (run-child-host.ts), as the server's held uploads are never the run's to read.
286
+ if (!(deps.sealKey === undefined && runnerSeam()))
287
+ await placeRunInputs(deps.data, claim.runId, ws.workspace, launch.files ?? [], messageText(launch.input));
262
288
  // The pull request's checkout, when the revision asks for one (pr-checkout.ts): the server's own fetch before the first
263
289
  // turn, with the GitHub App's read-only token for that one repository (or none); the run is told what it holds, or why
264
290
  // there is none. Held from the fetch's start, so the release (after the tools' end) removes it however the claim ends; a
@@ -274,26 +300,16 @@ async function adapterSpec(launch, run, deps, claim, holds) {
274
300
  const start = learningStartOf(launch);
275
301
  // The revision's own skills are laid in the run's .agents/skills/ before they are read (main's server start laid them;
276
302
  // on the one store the claim does), from the revision row's texts (the body keeps only each file's SHA-256): each
277
- // folder not there yet, never over a learned skill or an earlier claim's. A desktop or a phone (the revision's computer
303
+ // folder not there yet, never over an earlier claim's. A desktop or a phone (the revision's computer
278
304
  // setting, the one computerForClaim starts) brings its kind's skill, named in the prompt beside the revision's own.
279
305
  const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
280
- // A learning run's seed, read once from its learning folder where the run's place keeps it: its notes in .learning/
281
- // and its learned skills beside the revision's own (runner/learning-seed.ts), cut of the server's secrets, the learned
282
- // skills then in the skill list the prompt names, its learned workflows the ones its learned_workflow tool runs. Laid
283
- // before the run's tools are bound. A learning fault, or a seed that failed (seedFailed), lays nothing.
306
+ // A learning run's seed, read once from its learning folder where the run's place keeps it (runner/learning-seed.ts):
307
+ // its learned workflows, cut of the server's secrets, the ones its learned_workflow tool runs. Read before the run's
308
+ // tools are bound. A learning fault, or a seed that failed (seedFailed), gives none.
284
309
  const shown = async () => secretsShown(runnerSecrets(deps.env, await storeSecrets(deps.store, deps.sealKey, deps.data)), { local: true });
285
310
  const learningFolder = () => (archil === undefined ? learningFolderOf(deps.data, runRow.agentId) : learningWorkspace({ mode: "archil", agentId: runRow.agentId, archil }));
286
311
  const seedLaid = start && !seedFailed(start)
287
- ? await layLearningSeed({
288
- work: ws.workspace,
289
- seed: start.seed,
290
- folder: learningFolder,
291
- own: Object.keys(revisionRow.skills ?? {}),
292
- shown,
293
- log,
294
- ...(start.notesOnly ? { workflows: false } : {}),
295
- ...(start.notesLeftOut?.length ? { notesLeftOut: start.notesLeftOut } : {}),
296
- })
312
+ ? await layLearningSeed({ seed: start.seed, folder: learningFolder, shown, log, ...(start.noWorkflows ? { workflows: false } : {}) })
297
313
  : undefined;
298
314
  // The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
299
315
  // credentials opened under the server's seal key into this claim's memory, one gateway for the claim. First, before
@@ -301,7 +317,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
301
317
  // words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
302
318
  // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
303
319
  const hold = (values) => cut.hold(values);
304
- const mcp = await mcpForClaim({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => ws.workspace, 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 } : {}), ...reach });
320
+ const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => ws.workspace, 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 } : {}), ...reach });
305
321
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
306
322
  holds.hold({ passed: mcp });
307
323
  // The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
@@ -317,7 +333,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
317
333
  // claim's is a new one whatever ended the earlier claim (a lost runner, a server's stop, a park past its keep). The
318
334
  // computer a park kept, attached again, brings its mount credential with it (inheritMount): none is minted. A
319
335
  // recording of its screen (computer.record) goes in the run's recordings folder, beside its folder, said on its timeline.
320
- { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(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) } : {}) });
336
+ { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(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) } : {}) });
321
337
  // The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
322
338
  // (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
323
339
  // A desktop's or a phone's hold (the person's take-over) wraps its ports: a call made while the person holds it waits,
@@ -341,11 +357,20 @@ async function adapterSpec(launch, run, deps, claim, holds) {
341
357
  // tools unlock and its model needs, scoped to the run as the old per-run environment was, so one run's keys never reach
342
358
  // another's on this runner (claim-secrets.ts). MCP credentials are the other per-claim secret and come through mcp-claim.
343
359
  const toolEnv = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, revisionRow, launch);
360
+ // The run's own model key, when its caller handed one (model_key, sealed in its launch): opened at every claim, a reclaim
361
+ // after a crash among them, and held by the run's one redactor. Its model routes read it alone; its tools never do.
362
+ // A run that starts on the server's key holds the claim's key holder too: a message's first key reaches its next request.
363
+ const runKey = await claimModelKey({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, claim.runId);
364
+ const keyed = keyedAtClaim(runKey);
365
+ if (keyed)
366
+ withoutModelKeys(toolEnv);
367
+ if (runKey)
368
+ holdRunKey(cut, runKey);
344
369
  // The keys it opened join the run's one redactor before any tool or model request can echo one.
345
370
  holdClaimed(cut, toolEnv);
346
371
  // The route reads its model's key from the runner's environment, else the one the claim opened from the store: a key
347
- // saved in Settings → Model keys runs the next run with no restart (withModelKeys).
348
- const modelEnv = withModelKeys(deps.env, toolEnv);
372
+ // saved in Settings → Model keys runs the next run with no restart (withModelKeys). A run with its own key: that key.
373
+ const modelEnv = claimModelEnv(deps.env, toolEnv, runKey);
349
374
  const route = await deps.routeOf(modelAskOf(launch.model, body.model), modelEnv, "default", PI_WIRES, undefined, cut);
350
375
  await planBeforeRun(modelEnv, route.provider.plan ? { provider: PLAN_PROVIDER } : undefined);
351
376
  // The run's models of other tiers, for its learned workflows' nodes of a tier (learnedTierRoutes, filled once the seed's
@@ -374,9 +399,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
374
399
  // requests as that route books them.
375
400
  const tierWhy = new Map();
376
401
  if (revision.kind === "agentic" && granted.includes(SUBAGENT_TOOL)) {
377
- const savedKeys = await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env });
402
+ // A run with its own model key: its subagents' models carry that key too, and no saved key is read.
403
+ const savedKeys = keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env });
378
404
  holdClaimed(cut, savedKeys);
379
- const tierEnv = withModelKeys(deps.env, { ...savedKeys, ...toolEnv });
405
+ const tierEnv = claimModelEnv(deps.env, { ...savedKeys, ...toolEnv }, runKey);
380
406
  for (const tier of SUBAGENT_TIERS) {
381
407
  if (body.modelTiers?.[tier] === undefined && tierModelOf(tierEnv, tier) === undefined)
382
408
  continue;
@@ -388,17 +414,28 @@ async function adapterSpec(launch, run, deps, claim, holds) {
388
414
  }
389
415
  }
390
416
  }
391
- const adapter = piAdapter({
417
+ // The run's adapter is its runner's (runner/adapters/index.ts RunnerHarness: pi's, or the one a harness module's entry
418
+ // brings), made from the run's launch on its route. Its private files, where it keeps any, go in this claim's folder of
419
+ // the run's scratch (the CLI spec's layout), swept at the claim's end with the earlier claims' and any parent left empty.
420
+ // pi's own options (its extensions, tools, redactor, the model's catalog entry, hosted search, tiers, and the route's
421
+ // whole provider) are the harness's own options (`extra`), passed on as given.
422
+ const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
423
+ const harnesses = join(scratch, "harness");
424
+ holds.hold({ scratch: { sweep: async () => (await import("./cli-run-spec.js")).sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
425
+ const adapter = await runner.adapter({
392
426
  run,
427
+ model: route.model,
428
+ provider: route.provider,
429
+ ...(route.price ? { price: route.price } : {}),
430
+ sessionsDir: join(harnesses, String(claim.epoch)),
431
+ ...(route.fetch ? { fetch: route.fetch } : {}),
432
+ }, {
393
433
  // Read when the session opens (pi.ts), so the browser's extension pushed by bindNonHandTools below is in it.
394
434
  extensions: native,
395
435
  tools: piTools,
396
- model: route.model,
397
436
  provider: route.provider,
398
437
  redact: cut,
399
438
  ...(route.like ? { like: route.like } : {}),
400
- ...(route.price ? { price: route.price } : {}),
401
- ...(route.fetch ? { fetch: route.fetch } : {}),
402
439
  // The run's web_search is its provider's hosted search (the launch's plane, as its start resolved it): the session's
403
440
  // proxy admits that search's one request (it goes through the session's port: buildToolHost's `search`) and books it
404
441
  // with each search it ran.
@@ -430,8 +467,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
430
467
  const tierRoute = tierRoutes.get(by);
431
468
  return tierRoute && tierRoute.model === id ? capModelOf(tierRoute) : undefined;
432
469
  },
433
- // What its learning runs' grades and its audit's shadow took beside it, read by every gate with its own sessions
434
- // (none: it queues none).
470
+ // What its audit's shadow took beside it, read by every gate with its own sessions (none: it starts none).
435
471
  ...(besideOf ? { beside: besideOf } : {}),
436
472
  // The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS).
437
473
  freeRequests: freeModelRequestsOf(deps.env),
@@ -459,29 +495,26 @@ async function adapterSpec(launch, run, deps, claim, holds) {
459
495
  // chose them, scoped as the revision's own: each provider the run's gate does not deny, held by the run's one redactor,
460
496
  // onto the tools' environment alone. The model's route was built on the revision's keys above, so a decision key never
461
497
  // becomes its model's.
462
- // A replay run lays only the workflow it replays (runner/promotion.ts replayLaid).
463
- const laidFlows = replayLaid(launch, seedLaid?.workflows ?? []);
464
498
  // The learned workflow the run starts on, before its agent's first turn, when one fits its input (workflow-first.ts),
465
499
  // chosen before the learned_workflow tool is bound, so the tool runs the text that serves. Only a promoted digest
466
500
  // serves (runner/promotion.ts: replayed on the agent's graded inputs first, or promoted on its dry run with fewer than
467
501
  // five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
468
502
  // (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
469
503
  // The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
470
- const audits = { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey };
471
- if (launch.learning && !launch.replay && !launch.audit)
472
- await settleAudits(audits);
473
- const promotion = claimPromotion({
474
- store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
475
- });
476
- const firstChoice = learnsWorkflows(revision.kind, laidFlows) ? await workflowFirstOf(revision.kind, laidFlows, launch, log, () => pastRunsOverStore(deps.store, runRow.agentId), promotionGate(promotion), revision.body.outputSchema) : {};
477
- // A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
478
- await replayClaimed(deps.store, runRow.agentId, claim.runId, launch, firstChoice);
504
+ // Model spend beside the run that its caller's key does not pay for (claimSpendOff): a shadow audit and a replay check
505
+ // are skipped, in words, where the run brought its own key or the server holds none.
506
+ const spendOff = await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey);
507
+ const audits = { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey, spendOff };
508
+ // Each step writes the store or reads another run (runner/learned-first.ts): in a run's own process its runner takes
509
+ // them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself.
510
+ const learned = await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, folder: learningFolder, shown, spendOff }, seedLaid?.workflows ?? []);
511
+ const firstChoice = learned.choice;
479
512
  // A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
480
- // answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
481
- const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
513
+ // answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
514
+ const replay = learned.recorded ? await replayCallsOver(deps.store, claim.runId, new Map(learned.recorded)) : undefined;
482
515
  const { serve: workflowFirst, revise: workflowRevise } = firstChoice;
483
516
  // The tool runs what serves, never a revision not promoted (runner/promotion.ts toolFlowsFor).
484
- const workflows = await toolFlowsFor(promotion, launch, laidFlows, firstChoice);
517
+ const workflows = learned.workflows;
485
518
  // A tier a learned workflow's node names and the host has a model of: none can't be reached is left as `why`, and its
486
519
  // node fails in those words (learnedWorkflowHostTool), never on another model.
487
520
  const tierUnreachable = new Map();
@@ -489,9 +522,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
489
522
  // The keys those tiers' models need (tierModelKeys: a key saved in Settings too, which claimSecrets opened only for the
490
523
  // run's own model), held by the run's one redactor, on the tiers' route env alone (withModelKeys, never enumerable),
491
524
  // never on the tools' (toolEnv).
492
- const tierKeys = await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
525
+ // A run with its own model key: its learned nodes' tiers carry that key too, and no saved key is read.
526
+ const tierKeys = keyed ? {} : await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
493
527
  holdClaimed(cut, tierKeys);
494
- const tierEnv = withModelKeys(deps.env, { ...toolEnv, ...tierKeys });
528
+ const tierEnv = claimModelEnv(deps.env, { ...toolEnv, ...tierKeys }, runKey);
495
529
  for (const [tier, routed] of await learnedTierRoutes(workflows, tierEnv, (tier) => deps.routeOf(undefined, tierEnv, tier, PI_WIRES, undefined, cut))) {
496
530
  if ("why" in routed)
497
531
  tierUnreachable.set(tier, routed.why);
@@ -511,7 +545,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
511
545
  // An agent whose computer is a browser the claim started gets the browser tool on that one session (tools.ts).
512
546
  const claimBrowser = computer.computer?.kind === "browser" ? computer.computer.browser : undefined;
513
547
  const fakes = deps.evalFakes?.(runRow.agentId);
514
- const host = { ...buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: cut, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach }), ...(claimBrowser ? { browserComputer: claimBrowser } : {}) };
548
+ const liveAt = await claimLiveAt(deps, claim.runId);
549
+ const host = { ...buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: cut, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach, ...(liveAt ? { liveAt } : {}) }), ...(claimBrowser ? { browserComputer: claimBrowser } : {}) };
515
550
  gate.askedOn(host);
516
551
  // The run's tools. The hands (read/write/edit/bash and the background tools) are the kernel registry's over the run's
517
552
  // Workspace and computer (runTools.hostTools); the gate is the adapter loop's own (spec.gate), so they run as asked.
@@ -535,12 +570,14 @@ async function adapterSpec(launch, run, deps, claim, holds) {
535
570
  // outputContract, the CLI spec's too), then the effort guidance (the launch's effort, never this process's environment).
536
571
  // The one path for every harness.
537
572
  // A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
538
- const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
539
- const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills, ...(seedLaid?.skills ?? [])], ws.workspace, { onDemand: readsFiles(granted) });
573
+ const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
574
+ const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills], ws.workspace, { onDemand: readsFiles(granted) });
540
575
  const guidance = effortGuidance(launch.effort);
541
576
  // The run's clock: a template eval case's (EvalFakes.now), else the real one.
542
577
  const now = fakes?.now;
543
- const zone = await runZone(deps.store, launch.inputOrigin);
578
+ // A run's own process reads no trigger's row: its runner answers the zone (held.ts runZone).
579
+ const seam = deps.sealKey ? undefined : runnerSeam();
580
+ const zone = seam ? await seam.runZone() : await runZone(deps.store, launch.inputOrigin);
544
581
  const system = [environmentLine(now, zone), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line));
545
582
  // The subagent tool, one of the session's own tools (no extension of its own): a child's tools are a subset of the
546
583
  // revision's grants (each by its session name: an MCP tool's wire name, the browser's registrations), its model the
@@ -583,12 +620,12 @@ async function adapterSpec(launch, run, deps, claim, holds) {
583
620
  // A typed input's other fields follow its content as one json block (inputMessage).
584
621
  const input = await firstMessage(inputMessage(launch.input), ws.workspace);
585
622
  // The run's end-of-run step, when it learns (learningEndOfRun from the launch's learning start; none otherwise): the
586
- // reflect-and-propose turn over the run's store, asked in the end turn while the claim is held (adapter-loop.ts stepOf).
587
- // Its learning folder is where the run's place keeps it — Mode 1 the agent's folder under the data directory, Mode 2 the
588
- // agent's folder on THIS claim's Archil disk (the proposal is checked against the seed on the disk, never this machine's
623
+ // compile turn and the owner's correction over the run's store, asked in the end turn while the claim is held
624
+ // (adapter-loop.ts stepOf). Its learning folder is where the run's place keeps it — Mode 1 the agent's folder under the
625
+ // data directory, Mode 2 the agent's folder on THIS claim's Archil disk (the draft is checked against the seed on the disk, never this machine's
589
626
  // local path) — so the end-of-run step reads the run's own Workspace, the one the run worked in.
590
627
  // A replay run or an audit's shadow run asks nothing at its end: it is the promotion's, never the agent's to learn from.
591
- // A run the promoted workflow served first starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
628
+ // A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
592
629
  // withAudit): at its end, so the shadow's cap is what the run's own left.
593
630
  const endOfRun = launch.replay || launch.audit ? undefined : withAudit(learningEndOfRun(launch, {
594
631
  store: deps.store,
@@ -597,7 +634,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
597
634
  // What the run must never learn beside the runner's secrets: the keys its claim handed it, every secret the server
598
635
  // keeps sealed (storeSecrets: the run's redactor holds the same list), and its sign-in's pointers, read back from the
599
636
  // store's sign-ins under the seal key (learning-run.ts refused, on the runner).
600
- signIns: signInReads(deps.store, deps.sealKey),
637
+ signIns: deps.sealKey ? signInReads(deps.store, deps.sealKey) : heldSignInReads(),
601
638
  handed: runnerSecrets(toolEnv),
602
639
  stored: () => storeSecrets(deps.store, deps.sealKey, deps.data),
603
640
  log,
@@ -606,11 +643,14 @@ async function adapterSpec(launch, run, deps, claim, holds) {
606
643
  learningFolder: archil === undefined
607
644
  ? (agentId) => learningFolderOf(deps.data, agentId)
608
645
  : (agentId) => learningWorkspace({ mode: "archil", agentId, archil }),
609
- }), { ...audits, launch });
646
+ }), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
610
647
  return {
611
648
  adapter,
649
+ // Who keeps the run's visible record: its runner says (none: the adapter, as pi keeps its own).
650
+ ...(runner.record ? { record: runner.record } : {}),
612
651
  session,
613
652
  input,
653
+ ...modelRetryOf([route, ...tierRoutes.values()]),
614
654
  // A trigger's first input is its origin's, the launch's own owner flag kept (run-launch.ts keepInputOrigin).
615
655
  ...(launch.inputOrigin ? { inputOrigin: launch.inputOrigin } : {}),
616
656
  // The gate's answer with its words (adapterRunGate, RunGate.decide): a deny names where it was set and that nothing was
@@ -623,6 +663,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
623
663
  // The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
624
664
  // the catalog tools the session mounts; absent when none.
625
665
  ...(catalog ? { mcp: catalog } : {}),
666
+ // The run's own model key: a command row opens it again before the next model request (a message's new key).
667
+ ...(runKey ? { modelKey: runKey } : {}),
626
668
  // The run's end-of-run step, when it learns (the spec's, which the loop prefers over its deps': adapter-loop.ts stepOf).
627
669
  ...(endOfRun ? { endOfRun } : {}),
628
670
  ...(start ? { learningLaid: laidOf(seedLaid) } : {}),
@@ -814,9 +856,10 @@ export function liveViewersOf(store, sealKey, claim, cut) {
814
856
  return {
815
857
  put: (handover) => {
816
858
  cut.hold([handover.token]);
817
- return putLiveViewer(store, sealKey, claim, handover);
859
+ // A run's own process holds no seal key: its runner seals the hand-over under the claim (held.ts).
860
+ return sealKey ? putLiveViewer(store, sealKey, claim, handover) : heldOrThrow("a browser viewer's hand-over").liveViewerPut(handover);
818
861
  },
819
- drop: (tag) => dropLiveViewer(store, claim, tag),
862
+ drop: (tag) => (sealKey ? dropLiveViewer(store, claim, tag) : heldOrThrow("a browser viewer's drop").liveViewerDrop(tag)),
820
863
  };
821
864
  }
822
865
  /** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
@@ -849,8 +892,7 @@ export function answersCut(tool, cut) {
849
892
  * session's viewer over through (the store, never files), and the run's own Workspace (`workspace`: in Mode 2 its folder
850
893
  * on the run's disk), where a tool files what the run's read finds later. */
851
894
  export function buildToolHost(opts) {
852
- const liveAt = runnerLiveOf(opts.env, opts.sealKey);
853
- const { root, claim, run, life } = opts;
895
+ const { root, claim, run, life, liveAt } = opts;
854
896
  const { web, now, email } = opts.fakes ?? {};
855
897
  return {
856
898
  ...(web ? { web } : {}),
@@ -871,7 +913,7 @@ export function buildToolHost(opts) {
871
913
  ...(run.rowSummaryOn ? { rowSummaryOn: run.rowSummaryOn } : {}),
872
914
  store: opts.store,
873
915
  claim,
874
- sealKey: opts.sealKey,
916
+ ...(opts.sealKey ? { sealKey: opts.sealKey } : {}),
875
917
  // The run's one ledger, as the adapter loop made it over the run's sessions and handed it on the AdapterRun: the
876
918
  // browser holds and settles its calls here (host.ledger.paid), never on this process's own spend, and a refusal at the
877
919
  // cap parks the run (pause). browserListed reads it to fail closed.
@@ -892,6 +934,17 @@ export function buildToolHost(opts) {
892
934
  ...(opts.toolSettings !== undefined ? { toolSettings: opts.toolSettings } : {}),
893
935
  };
894
936
  }
937
+ /** Where the claim's viewers answer on a runner on another host than its server (live-reach.ts runnerLiveOf), under the
938
+ * claim's run's own proof key (liveForRun); none on the server's machine. In a run's own process its runner's
939
+ * (held.ts liveAt): the process holds its run's key, never the runners' shared one. */
940
+ export async function claimLiveAt(deps, runId) {
941
+ if (deps.sealKey) {
942
+ const live = runnerLiveOf(deps.env ?? {}, deps.sealKey);
943
+ return live && liveForRun(live, runId);
944
+ }
945
+ const given = await runnerSeam()?.liveAt();
946
+ return given && { host: given.host, bind: given.bind, key: Buffer.from(given.key) };
947
+ }
895
948
  /** The run's web host tools (tool-list.ts `host` rows: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
896
949
  * catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
897
950
  * CLI spec share. Each runs under the adapter loop's one gate (spec.gate) on the claim's keys (host.env), and books its
@@ -33,5 +33,7 @@ export interface RunnerHarness {
33
33
  }
34
34
  /** Every harness the runner runs, by name. */
35
35
  export declare const RUNNER_HARNESSES: Readonly<Record<string, RunnerHarness>>;
36
- /** The harness the launch names, or undefined when the runner runs none by that name. */
37
- export declare function resolveHarness(harness: string): RunnerHarness | undefined;
36
+ /** The harness the launch names, as `env`'s harness table has it (harness-table.ts harnessOf): a built-in one's runner is
37
+ * the runner's own (RUNNER_HARNESSES), one a harness module adds brings its own (HarnessEntry.runner). Undefined when
38
+ * the table has none by that name. `env`: the run's environment (this process's when not given). */
39
+ export declare function resolveHarness(harness: string, env?: NodeJS.ProcessEnv): RunnerHarness | undefined;
@@ -1,18 +1,24 @@
1
1
  import { facts as claudeFacts } from "@parcha/agentrun-harness-claude/facts";
2
2
  import { facts as codexFacts } from "@parcha/agentrun-harness-codex/facts";
3
3
  import { facts as openCodeFacts } from "../../harness-opencode/facts.js";
4
+ import { harnessOf } from "../../harness-table.js";
5
+ import { acpPackage } from "../../acp-package.js";
6
+ import { GOOSE_ID } from "../../harness-goose.js";
4
7
  import { piAdapter } from "./pi.js";
5
8
  const CLAUDE_PACKAGE = "@parcha/agentrun-harness-claude";
6
9
  const CODEX_PACKAGE = "@parcha/agentrun-harness-codex";
7
10
  /** Every harness the runner runs, by name. */
8
11
  export const RUNNER_HARNESSES = {
9
12
  pi: {
10
- adapter: async (launch) => piAdapter({
13
+ // `extra`: pi's own options (PiAdapterOptions), as the run's spec gives them (adapter-run-spec.ts): its extensions,
14
+ // tools, redactor, tiers, and the route's whole provider over the launch's.
15
+ adapter: async (launch, extra = {}) => piAdapter({
11
16
  run: launch.run,
12
17
  model: launch.model,
13
18
  provider: { api: launch.provider.api ?? "anthropic-messages", origin: launch.provider.origin, credential: launch.provider.credential, ...(launch.provider.headers ? { headers: launch.provider.headers } : {}), ...(launch.provider.auth ? { auth: launch.provider.auth } : {}) },
14
19
  ...(launch.price ? { price: launch.price } : {}),
15
20
  ...(launch.fetch ? { fetch: launch.fetch } : {}),
21
+ ...extra,
16
22
  }),
17
23
  },
18
24
  [claudeFacts.id]: {
@@ -69,8 +75,33 @@ export const RUNNER_HARNESSES = {
69
75
  });
70
76
  },
71
77
  },
78
+ // Goose, where its package is beside serve (acp-package.ts): on the binary `extra.binary` names, which its owner
79
+ // installed (harness-goose.ts); a run on serve's table builds its adapter from its entry (adapters.ts gooseOf).
80
+ [GOOSE_ID]: {
81
+ record: "loop",
82
+ adapter: async (launch, extra = {}) => {
83
+ const acp = acpPackage();
84
+ if (!acp)
85
+ throw new Error("Goose's adapter (@parcha/agentrun-harness-acp) is not installed beside this runner");
86
+ if (typeof extra.binary !== "string")
87
+ throw new Error("Goose's runner adapter needs the installed binary's path (extra.binary)");
88
+ return acp.gooseAdapter({
89
+ model: launch.model,
90
+ provider: { origin: launch.provider.origin, credential: launch.provider.credential, ...(launch.provider.headers ? { headers: launch.provider.headers } : {}), ...(launch.provider.auth ? { auth: launch.provider.auth } : {}) },
91
+ ...(launch.price ? { price: launch.price } : {}),
92
+ ...(launch.fetch ? { fetch: launch.fetch } : {}),
93
+ sessionsDir: launch.sessionsDir,
94
+ ...extra,
95
+ });
96
+ },
97
+ },
72
98
  };
73
- /** The harness the launch names, or undefined when the runner runs none by that name. */
74
- export function resolveHarness(harness) {
75
- return Object.prototype.hasOwnProperty.call(RUNNER_HARNESSES, harness) ? RUNNER_HARNESSES[harness] : undefined;
99
+ /** The harness the launch names, as `env`'s harness table has it (harness-table.ts harnessOf): a built-in one's runner is
100
+ * the runner's own (RUNNER_HARNESSES), one a harness module adds brings its own (HarnessEntry.runner). Undefined when
101
+ * the table has none by that name. `env`: the run's environment (this process's when not given). */
102
+ export function resolveHarness(harness, env = process.env) {
103
+ const entry = harnessOf(env, harness);
104
+ if (!entry)
105
+ return undefined;
106
+ return entry.runner ?? (Object.prototype.hasOwnProperty.call(RUNNER_HARNESSES, harness) ? RUNNER_HARNESSES[harness] : undefined);
76
107
  }
@@ -1,9 +1,9 @@
1
1
  import type { Context } from "@earendil-works/chord/context";
2
2
  import type { Models } from "@earendil-works/pi-ai";
3
3
  import { type Extension, type Harness, type Registry, type ToolRegistration } from "@earendil-works/pi-durable";
4
- import { type AgentAdapter, type SessionIO, type SessionPort, type Wire } from "@parcha/agentrun-kernel";
4
+ import { type AgentAdapter, type SessionIO, type Wire } from "@parcha/agentrun-kernel";
5
5
  import { type ModelProxy, type ProviderPolicy } from "@parcha/agentrun-kernel/host";
6
- import { type ThinkingLevelMap } from "../../port-models.js";
6
+ import { type SessionLike, type SessionModelPort } from "../../port-models.js";
7
7
  import { type CallStatus } from "../journal-kinds.js";
8
8
  import { CALL_REFUSED } from "../../timeline/index.js";
9
9
  import { type ComputerCallRecord } from "../../computer-calls.js";
@@ -64,15 +64,7 @@ export interface PiAdapterOptions {
64
64
  /** The model pi asks for. */
65
65
  readonly model: string;
66
66
  /** The catalog's entry for the model: whether it reasons, its window and its output ceiling, as pi-ai's model of it. */
67
- readonly like?: {
68
- readonly reasoning?: boolean;
69
- readonly contextWindow?: number;
70
- readonly maxTokens?: number;
71
- readonly input?: readonly string[];
72
- readonly inputLimits?: unknown;
73
- readonly developerRole?: boolean;
74
- readonly thinkingLevelMap?: ThinkingLevelMap;
75
- };
67
+ readonly like?: SessionLike;
76
68
  /** The price of a request's usage, for the proxy's booking. */
77
69
  readonly price?: (model: string, usage: never) => number | null;
78
70
  /** The proxy's upstream fetch (a test's scripted origin). */
@@ -113,7 +105,7 @@ export declare function piAdapter(options: PiAdapterOptions): AgentAdapter;
113
105
  export type TierModel = Pick<PiAdapterOptions, "provider" | "model" | "like" | "price" | "fetch">;
114
106
  /** The tier proxies a session holds (openTierProxies): each tier's port for a side request under `label`, and their close. */
115
107
  export interface TierProxies {
116
- port(label: string, tier: string): SessionPort | undefined;
108
+ port(label: string, tier: string): SessionModelPort | undefined;
117
109
  /** Each tier, its route and its proxy: a subagent's child on the tier is sent there on the proxy's own key. */
118
110
  readonly each: readonly (readonly [string, TierModel, ModelProxy])[];
119
111
  close(): Promise<void>;
@@ -120,7 +120,7 @@ export async function openTierProxies(tiers, hooks, redact, tools = []) {
120
120
  return {
121
121
  port: (label, tier) => {
122
122
  const at = open.get(tier);
123
- return at ? { url: at.proxy.url, key: at.proxy.sideKey(label), model: at.route.model, api: at.route.provider.api } : undefined;
123
+ return at ? { url: at.proxy.url, key: at.proxy.sideKey(label), model: at.route.model, api: at.route.provider.api, ...(at.route.like ? { like: at.route.like } : {}) } : undefined;
124
124
  },
125
125
  each: [...open].map(([tier, { proxy, route }]) => [tier, route, proxy]),
126
126
  close,
@@ -413,7 +413,7 @@ async function sessionOn(proxy, options, spec, io, context, tiers) {
413
413
  port: (label, tier) => {
414
414
  if (closed)
415
415
  return undefined;
416
- return tier === undefined ? { url: proxy.url, key: proxy.sideKey(label), model, api } : tiers.port(label, tier);
416
+ return tier === undefined ? { url: proxy.url, key: proxy.sideKey(label), model, api, ...(like ? { like } : {}) } : tiers.port(label, tier);
417
417
  },
418
418
  // A steer: pi places it in the turn in flight, at its next boundary. `id`: its request id (the command's), so the
419
419
  // commit that places it is the one that takes its row. `origin` (a trigger's message): its input is the host's user
@@ -20,6 +20,9 @@ export type AuditDeps = {
20
20
  readonly log: (line: string) => void;
21
21
  readonly sealKey?: Buffer;
22
22
  readonly now?: () => number;
23
+ /** Why model spend beside the claimed run is skipped (claim-secrets.ts claimSpendOff): a shadow is a run the runner
24
+ * starts with no caller's key. Absent: it runs. */
25
+ readonly spendOff?: (what: string) => string | undefined;
23
26
  };
24
27
  /** The words a second hold within stop_window leaves on its record: what the owner reads. */
25
28
  export declare const STOPPED_TWICE = "stopped: the workflow disagreed with the agent twice";
@@ -35,10 +38,11 @@ export declare const AUDIT_PARKED = "the audit ended where it would wait on a pe
35
38
  /** The served run's end-of-run step `step` (none for a run that only uses what its agent learned), its audit started
36
39
  * after it (startAudit) on an end the run reached on its own (a cut run starts none): the learned workflow that served
37
40
  * it, read from its journal whatever claim it served on (servedOf), and, for a capped run, what its cap leaves once this
38
- * end is counted (auditRoomOf: its job, its look-back, the grades beside it and the one this end queues). A run that
41
+ * end is counted (auditRoomOf: its job, its follow-ups, its compile turns). A run that
39
42
  * could never be audited (no learning start, or not auditableLaunch) keeps `step` as it is. */
40
43
  export declare function withAudit(step: EndOfRunTurn | undefined, deps: AuditDeps & {
41
44
  readonly launch: RunLaunch;
45
+ readonly redact?: (text: string) => string;
42
46
  }): EndOfRunTurn | undefined;
43
47
  /** Starts the shadow of run `runId`, at its end, when the learned workflow `serve` served it first and its id is drawn:
44
48
  * never for a replay or a shadow, a run that does not learn, one not auditable (auditableLaunch: a trigger started it,