@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
@@ -14,8 +14,8 @@ import type { ScriptComputer } from "../workspace/run-tools.js";
14
14
  import { type RunCapOptions, type RunDecisions, type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
15
15
  import { type PortModels } from "../port-models.js";
16
16
  /** The run's cap's config, as its spec gives it: the kernel runCap's options but its sessions (the loop's own), and
17
- * `beside`, what was spent beside the run's sessions on its behalf (Store.learning.spentBeside: its learning runs'
18
- * grades), which every gate of the run reads with its sessions' spend (runBooking's sessions.beside, overCap, the
17
+ * `beside`, what was spent beside the run's sessions on its behalf (learning-end.ts shadowBesideOf: its audit's shadow
18
+ * run), which every gate of the run reads with its sessions' spend (runBooking's sessions.beside, overCap, the
19
19
  * wrap-ups). None: nothing is. */
20
20
  export type RunCapConfig = Omit<RunCapOptions, "sessions"> & {
21
21
  beside?(): Promise<number | null>;
@@ -98,6 +98,9 @@ export interface AdapterRunSpec {
98
98
  * run, its model requests, its paid tool calls and its decisions, is admitted and booked through it. An uncapped run
99
99
  * gives capUsd: () => undefined. */
100
100
  readonly runCap: RunCapConfig;
101
+ /** This claim's model-request retry policy over the loop's defaults. A provider whose failed request may already be
102
+ * billed can disable automatic retries for every conversation in the claim, including its subagents. */
103
+ readonly retry?: Partial<ConversationRetryPolicy>;
101
104
  /** The run's cap, when it has one (filled from the run's launch): its figure, and what a refusal does to the run (the
102
105
  * kernel cap's parkOf: parked with a pending budget for a refusal a raise could fix, else failed in its words), at the
103
106
  * cap the run is held to when it parks (`capUsd`: the newest raise's, else the launch's), which its pending budget
@@ -144,11 +147,10 @@ export interface AdapterRunSpec {
144
147
  * them): it wins over LoopDeps.endOfRun and is asked where that one is, in the end turn while the claim is held, before
145
148
  * a tool host's beforeRelease and the run's release, its rows in the end's commit. */
146
149
  readonly endOfRun?: EndOfRunTurn;
147
- /** What the claim laid of the run's learning seed (runner/learning-seed.ts): the learned skills and workflows it was
148
- * given, by name. The loop writes it on the root (KINDS.learningLaid) as this claim opens. Absent for a run that does
149
- * not learn. */
150
+ /** What the claim laid of the run's learning seed (runner/learning-seed.ts): the learned workflows it was given, by
151
+ * name. The loop writes it on the root (KINDS.learningLaid) as this claim opens. Absent for a run that does not
152
+ * learn. */
150
153
  readonly learningLaid?: {
151
- readonly skills: readonly string[];
152
154
  readonly workflows: readonly string[];
153
155
  };
154
156
  /** The run's work folder, as its file tools resolve a path: what the end-of-run turn's refusal under work/.learning/
@@ -220,6 +222,12 @@ export interface AdapterRunSpec {
220
222
  * the session through the loop's gate, a command row makes them fresh again, and the pass's end lets them go. Absent:
221
223
  * the run grants no MCP tool. */
222
224
  readonly mcp?: ClaimMcp;
225
+ /** The run's model key holder (claim-secrets.ts claimModelKey), which its model routes read at each request: a command
226
+ * row opens it from the run's launch again before the command reaches the session, so a message's key (a replacement,
227
+ * or a run's first) is the one its next request carries. Absent: no gateway here, and the routes read the server's keys. */
228
+ readonly modelKey?: {
229
+ fresh(): Promise<void>;
230
+ };
223
231
  /** The JSON Schema the run's final answer's last json block meets (its revision's definition.output_schema). An answer
224
232
  * that misses it is asked again once, in the same session under the same cap (the output contract's retry); absent:
225
233
  * the run's answer is never checked here. */
@@ -29,7 +29,7 @@ const outputRetried = (entries) => {
29
29
  import { ClaimRefused, deniedText, noteOf, stopEnd } from "./loop-contract.js";
30
30
  import { ASKED_BECAUSE, deniedText as setToDenyText, ENDED_WHILE_WAITING, refusedText, STOPPED_WHILE_WAITING } from "../refusal-words.js";
31
31
  import { ADAPTER_API } from "../turn-end.js";
32
- import { answerText, REFLECT_NOTE_ONLY, REFLECT_PREFIX, reflectRequestId, underLearning, WRITES } from "./end-of-run.js";
32
+ import { answerText, REFLECT_PREFIX, reflectRequestId } from "./end-of-run.js";
33
33
  import { agentEntriesOf, approvalOf, BOOKING_WRITE_MS, CLOSE_MS, CUT_STEP_MS, END_PATCH_MS, END_PATCH_UNKNOWN, PARK_SIBLINGS_MS, readAgain, STOP_SETTLE_MS, commandRequest, cutLast, DEFAULT_RESTART_LIMIT, entriesOf, findData, Gate, heldReporter, INPUT_REQUEST, Interrupted, KernelFault, lastAnswerText, Parked, quiet, restartLimited, writesEntry, writesSubmission } from "./loop.js";
34
34
  import { outputMiss, outputRetryWords } from "../answer-json.js";
35
35
  import { answerOnce, HAND_BACK, handBackOf } from "./hand-back.js";
@@ -53,6 +53,7 @@ import { Fenced } from "../store/index.js";
53
53
  import { answerAsServed } from "../answer-json.js";
54
54
  import { reserveFor, stepAndAnswerFor, wrappingUp, wrapUpText } from "../wrap-up.js";
55
55
  import { LEARNED_CARD_FIELDS, LEARNED_CLIP, LEARNED_WORKFLOW_TOOL, learnedApprovedTools } from "../learned-workflow.js";
56
+ import { warnHoldShort } from "../print.js";
56
57
  import { feedbackAsk, feedbackOf, pendingFeedbackOf } from "./feedback-round.js";
57
58
  import { handbackText, servedAnswerOf, servedAnswerText, WORKFLOW_FIRST, WORKFLOW_FIRST_CALL } from "./workflow-first.js";
58
59
  /** The end of a harness's own call (Claude Code's WebSearch) the gate held and then let run: the host ran nothing of it,
@@ -350,7 +351,7 @@ async function openCliRecord(harness, journal, context, now, cwd, endsItsCalls =
350
351
  flushedAtRequest = atRequest;
351
352
  if (joined)
352
353
  return;
353
- const length = cut?.stopReason === "length" ? { stopReason: "length", ...(cut.outputTokens === undefined ? {} : { outputTokens: cut.outputTokens }) } : {};
354
+ const length = cut?.stopReason === "length" ? { stopReason: "length", ...(cut.outputTokens === undefined ? {} : { outputTokens: cut.outputTokens }), ...(cut.capCut === undefined ? {} : { capCut: { capUsd: cut.capCut.capUsd, raiseToUsd: cut.capCut.raiseToUsd } }) } : {};
354
355
  await append(KINDS.message, { role: "model", text: said, ...length });
355
356
  });
356
357
  };
@@ -634,8 +635,7 @@ function adapterLoop(specOf, options, deps) {
634
635
  /** The current pass ended in a park that keeps its computer (keepAtPark), for this cause, until its release reads it. */
635
636
  let parkedNow;
636
637
  /** From the end-of-run step's start (or a claim that found its turn open: lookingBackOpen, from its session's open)
637
- * until the claim ends: a steer is left for the end, writes and edits under work/.learning/ are refused
638
- * (REFLECT_NOTE_ONLY), and every request is learning's, never the job's: the cap's wrap-up note is never told to it,
638
+ * until the claim ends: a steer is left for the end, and every request is learning's, never the job's: the cap's wrap-up note is never told to it,
639
639
  * and a refusal of one never parks the run (learningRefused). Held between the step's asks too: a turn a takeover
640
640
  * resumed may send its next request while the step still reads an earlier answer. */
641
641
  let reflecting = false;
@@ -1321,7 +1321,7 @@ function adapterLoop(specOf, options, deps) {
1321
1321
  /** The root a phase is making, awaited before the owed writes are read. */
1322
1322
  let rootMaking;
1323
1323
  harness = await Harness.open(gate.journal, {
1324
- models: () => models, registry, settings: { restartLimit, retry, stream }, onReport: () => { },
1324
+ models: () => models, registry, settings: () => ({ restartLimit, retry: { ...retry, ...specNow?.retry }, stream }), onReport: () => { },
1325
1325
  // A tool host's onConversation, in each agent conversation's creating commit (the spec's, once it is known: the
1326
1326
  // root is created when the session opens, after the spec).
1327
1327
  conversationCreated: async (tx, record) => {
@@ -1659,7 +1659,7 @@ function adapterLoop(specOf, options, deps) {
1659
1659
  // earlier session's, a grade's), summed as overCap sums them; null while any is unknown. Read at the claim and again
1660
1660
  // after each request is admitted (the note is placed before its own request's admission, so it reads the last).
1661
1661
  const restOf = async () => {
1662
- // And what was spent beside the run on its behalf (its learning runs' grades).
1662
+ // And what was spent beside the run on its behalf (its audit's shadow run).
1663
1663
  const beside = await besideNow();
1664
1664
  if (beside === null)
1665
1665
  return null;
@@ -1849,6 +1849,9 @@ function adapterLoop(specOf, options, deps) {
1849
1849
  // at their hold or cut, comes before `capNote.live` and is never one.)
1850
1850
  if (capNote.live && event.type === "request_end" && event.host === undefined && !notOwn.has(event.turn) && typeof event.usage.usd === "number" && event.usage.usd > 0 && !event.usage.cut && !event.usage.givenBack)
1851
1851
  capNote.costs.push(event.usage.usd);
1852
+ // A request that billed more input than the bound its hold was priced on (the booking's holdShort): one warn
1853
+ // line, ids and figures only (print.ts warnHoldShort). Its booking, the hold and the cap are as they were.
1854
+ warnHoldShort(claim.runId, spec.adapter.id, event);
1852
1855
  if (event.type === "request_start") {
1853
1856
  // A new request means the model's last message is over: what it said so far is on the record before the request,
1854
1857
  // so an answer shows while the turn goes on (a CLI that answers, then makes another request).
@@ -2317,15 +2320,19 @@ function adapterLoop(specOf, options, deps) {
2317
2320
  // (a new claim's, or a restart's after a fault: closeSession let the last one go) is not the one an open hold held,
2318
2321
  // nor has what the owner set up on it: the run ends in those words.
2319
2322
  heldNow = undefined;
2323
+ // This pass's hold began waiting for the start: an owner's row may move it on (start, release) as soon as the pass
2324
+ // opens, before the wait below begins, so a release there still ends the run before its agent runs.
2325
+ let heldBeforeStart = false;
2320
2326
  if (spec.held) {
2321
2327
  const [journalOf, rootOf] = [harness, root];
2322
2328
  heldNow = journalHeld(spec.held, (entries) => journalOf.commit(async (tx) => {
2323
2329
  for (const entry of entries)
2324
2330
  await tx.appendEntry(rootOf.id, { kind: entry.kind, data: entry.data });
2325
2331
  }, context), now);
2326
- if ((await heldNow.up(await entriesOf(gate.journal, root.id, context))) === "lost") {
2332
+ const up = await heldNow.up(await entriesOf(gate.journal, root.id, context));
2333
+ if (up === "lost")
2327
2334
  return await writeEnd(harness, root, gate, { state: "failed", summary: heldWords.lost }, []);
2328
- }
2335
+ heldBeforeStart = up === "held";
2329
2336
  }
2330
2337
  // The cap a raise left the run at, before any request of this claim, through the one reader the run view and its
2331
2338
  // budget card read too (capNowOf: the newest raise entry, else the launch's cap): a claim that takes over a raised
@@ -2350,7 +2357,7 @@ function adapterLoop(specOf, options, deps) {
2350
2357
  // What this claim laid of the run's learning seed, once per claim: the newest is what the run was given.
2351
2358
  if (restarts === 0 && spec.learningLaid) {
2352
2359
  const [journalOf, rootOf, laid] = [harness, root, spec.learningLaid];
2353
- await journalOf.commit((tx) => tx.appendEntry(rootOf.id, { kind: KINDS.learningLaid, data: { skills: [...laid.skills], workflows: [...laid.workflows] } }), context);
2360
+ await journalOf.commit((tx) => tx.appendEntry(rootOf.id, { kind: KINDS.learningLaid, data: { workflows: [...laid.workflows] } }), context);
2354
2361
  }
2355
2362
  // Reopened by a person's follow-up (runs.reopen, or the end's own reopen): a fresh reopen is a claim whose journal's
2356
2363
  // root ends on an end entry, with no input of the root in flight. Then any turn its session still reads open is one
@@ -2402,7 +2409,7 @@ function adapterLoop(specOf, options, deps) {
2402
2409
  // A held computer waits for its owner's start before the agent's first input; the owner's calls set the task up
2403
2410
  // meanwhile. A release, or no call for the hold's minutes, ends the run before its agent ever ran. A stop ends it
2404
2411
  // stopped, and a lost claim leaves it for the next claim.
2405
- if (heldNow?.state() === "waiting") {
2412
+ if (heldNow && (heldNow.state() === "waiting" || (heldBeforeStart && heldNow.state() === "released"))) {
2406
2413
  const aborted = new Promise((resolve) => (deps.signal.aborted ? resolve() : deps.signal.addEventListener("abort", () => resolve(), { once: true })));
2407
2414
  const waited = await heldNow.untilStarted(Promise.race([stopping, aborted, harness.closed]));
2408
2415
  // Set by stop() during the wait: read past the narrowing TypeScript did before it.
@@ -2992,9 +2999,6 @@ function adapterLoop(specOf, options, deps) {
2992
2999
  // An MCP tool is asked about by its catalog name (`mcp:<server>/<tool>`), as its settings and its card name it.
2993
3000
  const tool = mcp?.catalogOf(call.tool) ?? call.tool;
2994
3001
  const kernelCall = { callId: call.callId, tool: tool, args: call.args };
2995
- // The end-of-run turn's notes are kept only from its answer: a write there is refused before its intent.
2996
- if (reflecting && WRITES.has(call.tool) && underLearning(spec.workRoot, call.args))
2997
- return { deny: REFLECT_NOTE_ONLY };
2998
3002
  await hooks.beforeIntent(kernelCall);
2999
3003
  // The cap's wrap-up, the same way: once the run has taken its share of the cap, every call the model makes is refused
3000
3004
  // in its fixed words, and the model answers from what it has. A call a running tool makes is that tool's, let through.
@@ -3948,8 +3952,15 @@ function adapterLoop(specOf, options, deps) {
3948
3952
  async command(command) {
3949
3953
  // A command row resumes a loop that may have sat past a token's life: its MCP credentials are made fresh again
3950
3954
  // before its next model request.
3951
- if (command.kind === "steer" || command.kind === "approve" || command.kind === "deny" || command.kind === "raise")
3955
+ if (command.kind === "steer" || command.kind === "approve" || command.kind === "deny" || command.kind === "raise") {
3952
3956
  mcpStale = true;
3957
+ // The run's own model key, read again from its launch before the command reaches the session: the message's key
3958
+ // was written with its command row, so the next request's credential (which the model proxy reads before its
3959
+ // beforeRequest hook) is the message's, a first key or a replacement. Fail-closed: a read that keeps failing
3960
+ // throws here, before the command is taken, so the runner delivers it again at its next poll and the session
3961
+ // never runs the message on the key held before it.
3962
+ await specNow?.modelKey?.fresh();
3963
+ }
3953
3964
  if (command.kind === "steer")
3954
3965
  return steer(command);
3955
3966
  if (command.kind === "approve" || command.kind === "deny") {
@@ -4,6 +4,7 @@ import type { HostTool, Wire } from "@parcha/agentrun-kernel";
4
4
  import type { Approvals } from "../approvals.js";
5
5
  import type { installForClaim, installSettled } from "../harness-install.js";
6
6
  import type { LiveHandover, LiveViewerStore } from "../browser-live.js";
7
+ import { type RunnerLive } from "../live-reach.js";
7
8
  import { type PinnedModel, type Tier } from "../model.js";
8
9
  import { type RunLaunch } from "../run-launch.js";
9
10
  import type { Store } from "../store/store.js";
@@ -16,6 +17,7 @@ import { type LearnedWorkflow } from "../learning.js";
16
17
  import { type ToolResults } from "../workspace/run-tools.js";
17
18
  import { type ClaimMcp } from "./mcp-run.js";
18
19
  import { type AdapterLoopOptions, type AdapterRun, type AdapterRunSpec, hostLifecycle } from "./adapter-loop.js";
20
+ import { type RunnerHarness } from "./adapters/index.js";
19
21
  import { type Claim, type Journal } from "./loop-contract.js";
20
22
  import type { ReplayCalls } from "../learn/replay-calls.js";
21
23
  import type { ModelRoute } from "./model-route.js";
@@ -87,8 +89,9 @@ export interface AdapterSpecDeps {
87
89
  readonly journal: (claim: Claim) => Journal;
88
90
  /** The one store: `runs` and `agents` for the run's revision, and the live-viewer seam for the browser tool. */
89
91
  readonly store: Store & LiveViewerStore;
90
- /** The key the store's live-viewer tokens are sealed under (store/seal.ts). */
91
- readonly sealKey: Buffer;
92
+ /** The key the store's sealed values are opened under (store/seal.ts): the runner's. Undefined in a run's own process
93
+ * (run-child.ts), which never holds it: what a claim opens with it is asked of the runner there (held.ts). */
94
+ readonly sealKey: Buffer | undefined;
92
95
  /** The run's model route (model-route.ts routeOf), the one route the pi adapter and the cap read, on a wire of `wires`
93
96
  * (the caller's; pi speaks both of main's, PI_WIRES). */
94
97
  readonly routeOf: (model: string | PinnedModel | undefined, env: NodeJS.ProcessEnv, tier?: Tier, wires?: readonly Wire[], upstream?: typeof fetch, redact?: (text: string) => string) => Promise<ModelRoute>;
@@ -166,6 +169,9 @@ export type EvalFakes = {
166
169
  * model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
167
170
  * overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
168
171
  export declare function capModelOf(route: ModelRoute): CapModel;
172
+ /** Particle requests are never automatically replayed after an uncertain failure. Retry is a harness-wide setting,
173
+ * so a claim with any Particle route disables it for all its conversations, including subagents on other tiers. */
174
+ export declare function modelRetryOf(routes: Iterable<Pick<ModelRoute, "like">>): Pick<AdapterRunSpec, "retry">;
169
175
  /** What the runner routes a claimed run on: the launch's model as its start pinned it, sent as pinned, with the
170
176
  * revision's own ref beside it (main prices a gateway's id by the provider that ref names); the revision's ref alone
171
177
  * when the start pinned none. Never the pin's provider and id joined into a ref: a gateway refuses the joined id, and
@@ -221,9 +227,11 @@ export declare function adapterRunGate(store: Pick<Store, "settings">, claim: Pi
221
227
  /** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
222
228
  * and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
223
229
  export declare function storeSettings(store: Pick<Store, "settings">): Promise<Awaited<ReturnType<typeof loadToolSettings>>>;
224
- /** pi's spec for a claimed run. What it makes for the run (its Archil mount credential, its Workspace, its computer, its
225
- * tools) is held until the spec's release; a build that throws part-way lets go what it made by then (spec-holds.ts). */
226
- export declare function adapterRunSpecFromLaunch(launch: RunLaunch, run: AdapterRun, deps: AdapterSpecDeps, claim: Claim): Promise<AdapterRunSpec>;
230
+ /** 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
231
+ * adds with no adapter facts), its visible record kept as that runner says (RunnerHarness.record). What it makes for the
232
+ * run (its Archil mount credential, its Workspace, its computer, its tools) is held until the spec's release; a build
233
+ * that throws part-way lets go what it made by then (spec-holds.ts). */
234
+ export declare function adapterRunSpecFromLaunch(launch: RunLaunch, run: AdapterRun, deps: AdapterSpecDeps, claim: Claim, runner?: RunnerHarness): Promise<AdapterRunSpec>;
227
235
  /** The host-tool ctx a non-hand tool is wrapped with (host-tools.ts hostToolOf): the run's own Harness (its commit,
228
236
  * snapshot and task reads), the results map, and the run's folder as the api env's cwd (a tool reads no
229
237
  * file environment, so an error names a path relative to it). Shared by the pi spec's bindNonHandTools and the CLI spec's
@@ -290,7 +298,7 @@ export declare function learnedWorkflowHostTool(opts: {
290
298
  * each a named todo, added as their seams land. */
291
299
  /** The run's live-viewer writers over the store (browser-live.ts): a session's hand-over written sealed, and gone. Its
292
300
  * viewer token, minted in the run, is held by `cut`, the run's one redactor, as it is handed over, before it is written. */
293
- export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer, claim: Claim, cut: HeldRedact): {
301
+ export declare function liveViewersOf(store: LiveViewerStore, sealKey: Buffer | undefined, claim: Claim, cut: HeldRedact): {
294
302
  put(handover: LiveHandover): Promise<boolean>;
295
303
  drop(tag?: string): Promise<void>;
296
304
  };
@@ -311,7 +319,8 @@ export declare function buildToolHost(opts: {
311
319
  readonly env: NodeJS.ProcessEnv;
312
320
  readonly run: AdapterRun;
313
321
  readonly store: Store & LiveViewerStore;
314
- readonly sealKey: Buffer;
322
+ /** The runner's seal key; none in a run's own process, whose sealed reads its runner makes (held.ts). */
323
+ readonly sealKey: Buffer | undefined;
315
324
  readonly life: ReturnType<typeof hostLifecycle>;
316
325
  readonly redact: HeldRedact;
317
326
  /** The run's launch (its trigger and origin) and its agent's own tool settings, as the email tools read them. */
@@ -323,7 +332,13 @@ export declare function buildToolHost(opts: {
323
332
  readonly loopback?: boolean;
324
333
  /** That server's own addresses (AdapterSpecDeps.mcpOwn): never the ports calendar_events reads on loopback. */
325
334
  readonly own?: readonly string[];
335
+ /** A runner on another host than its server: where the run's viewers answer, under its run's key (claimLiveAt). */
336
+ readonly liveAt?: RunnerLive;
326
337
  }): ToolHost;
338
+ /** Where the claim's viewers answer on a runner on another host than its server (live-reach.ts runnerLiveOf), under the
339
+ * claim's run's own proof key (liveForRun); none on the server's machine. In a run's own process its runner's
340
+ * (held.ts liveAt): the process holds its run's key, never the runners' shared one. */
341
+ export declare function claimLiveAt(deps: Pick<AdapterSpecDeps, "env" | "sealKey">, runId: string): Promise<RunnerLive | undefined>;
327
342
  /** The run's web host tools (tool-list.ts `host` rows: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
328
343
  * catalog name and wrapped as the hands are (host-tools.ts hostToolOf, with `ctx`), the one binding the pi spec and the
329
344
  * CLI spec share. Each runs under the adapter loop's one gate (spec.gate) on the claim's keys (host.env), and books its