@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.58

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 (312) hide show
  1. package/CHANGELOG.md +281 -0
  2. package/README.md +246 -66
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +15 -3
  5. package/dist/adapters.js +17 -6
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/api-keys.d.ts +76 -0
  9. package/dist/api-keys.js +217 -0
  10. package/dist/api-only.d.ts +15 -5
  11. package/dist/api-only.js +32 -8
  12. package/dist/box-paths.d.ts +4 -3
  13. package/dist/box-paths.js +7 -4
  14. package/dist/browser-hold.d.ts +23 -0
  15. package/dist/browser-hold.js +48 -0
  16. package/dist/browser-person.d.ts +3 -0
  17. package/dist/browser-person.js +4 -1
  18. package/dist/chatgpt-plan.d.ts +18 -8
  19. package/dist/chatgpt-plan.js +91 -34
  20. package/dist/claude-login-token.d.ts +117 -0
  21. package/dist/claude-login-token.js +737 -0
  22. package/dist/claude-login.d.ts +120 -22
  23. package/dist/claude-login.js +347 -63
  24. package/dist/claude-sign-in.d.ts +17 -6
  25. package/dist/claude-sign-in.js +42 -39
  26. package/dist/cli.js +33 -10
  27. package/dist/composio-made.d.ts +4 -0
  28. package/dist/composio-made.js +4 -0
  29. package/dist/composio-preset.d.ts +43 -2
  30. package/dist/composio-preset.js +92 -4
  31. package/dist/computer-attach.d.ts +35 -17
  32. package/dist/computer-attach.js +301 -49
  33. package/dist/computer-held-routes.d.ts +5 -4
  34. package/dist/computer-held-routes.js +29 -8
  35. package/dist/computer-held.d.ts +6 -1
  36. package/dist/computer-held.js +14 -0
  37. package/dist/computer-record.js +4 -2
  38. package/dist/computer-viewer.js +4 -1
  39. package/dist/computers.d.ts +10 -10
  40. package/dist/computers.js +5 -5
  41. package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
  42. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  43. package/dist/console/assets/index-DPh29cyz.js +747 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/decisions.d.ts +1 -1
  46. package/dist/decisions.js +1 -1
  47. package/dist/dial-relay.d.ts +25 -4
  48. package/dist/dial-relay.js +129 -1
  49. package/dist/docker-host-addresses.d.ts +22 -11
  50. package/dist/docker-host-addresses.js +38 -26
  51. package/dist/env-switch.d.ts +8 -0
  52. package/dist/env-switch.js +31 -2
  53. package/dist/errors.d.ts +1 -0
  54. package/dist/errors.js +2 -0
  55. package/dist/fal-price.d.ts +56 -20
  56. package/dist/fal-price.js +400 -90
  57. package/dist/handed-values.d.ts +43 -1
  58. package/dist/handed-values.js +119 -2
  59. package/dist/harness-archive.d.ts +13 -10
  60. package/dist/harness-archive.js +60 -34
  61. package/dist/harness-check.d.ts +3 -1
  62. package/dist/harness-check.js +25 -46
  63. package/dist/harness-keys.d.ts +73 -27
  64. package/dist/harness-keys.js +194 -61
  65. package/dist/harness-recipe-entry.d.ts +8 -7
  66. package/dist/harness-recipe-entry.js +21 -32
  67. package/dist/harness-recipe.d.ts +38 -25
  68. package/dist/harness-recipe.js +49 -36
  69. package/dist/harness-sign-in.js +12 -23
  70. package/dist/harness-table.d.ts +10 -3
  71. package/dist/harness-table.js +26 -21
  72. package/dist/harness.d.ts +1 -0
  73. package/dist/harness.js +17 -5
  74. package/dist/hosted-search.d.ts +1 -1
  75. package/dist/hosted-search.js +1 -2
  76. package/dist/import-worker.d.ts +4 -2
  77. package/dist/import-worker.js +9 -2
  78. package/dist/in-flight.d.ts +26 -0
  79. package/dist/in-flight.js +52 -0
  80. package/dist/key-refusal.d.ts +9 -4
  81. package/dist/key-refusal.js +107 -25
  82. package/dist/learn/ledger.d.ts +170 -0
  83. package/dist/learn/ledger.js +218 -0
  84. package/dist/learn/promote.d.ts +3 -3
  85. package/dist/learn/promote.js +1 -1
  86. package/dist/learn/secrets.d.ts +13 -3
  87. package/dist/learn/secrets.js +118 -17
  88. package/dist/learning-cost.d.ts +28 -23
  89. package/dist/learning-cost.js +19 -23
  90. package/dist/link-check.js +1 -1
  91. package/dist/live-reach.d.ts +2 -0
  92. package/dist/live-reach.js +2 -0
  93. package/dist/llms.txt +1 -1
  94. package/dist/marketplace.d.ts +77 -0
  95. package/dist/marketplace.js +224 -0
  96. package/dist/mcp-api-only-origins.d.ts +35 -0
  97. package/dist/mcp-api-only-origins.js +57 -0
  98. package/dist/mcp-gateway.d.ts +7 -5
  99. package/dist/mcp-gateway.js +9 -12
  100. package/dist/mcp-secret-writes.js +5 -3
  101. package/dist/mcp-servers-store.d.ts +28 -6
  102. package/dist/mcp-servers-store.js +53 -4
  103. package/dist/media-duration.d.ts +3 -0
  104. package/dist/media-duration.js +90 -9
  105. package/dist/micro.d.ts +2 -0
  106. package/dist/micro.js +2 -0
  107. package/dist/model-form.d.ts +5 -4
  108. package/dist/model-form.js +11 -7
  109. package/dist/model.d.ts +10 -6
  110. package/dist/model.js +16 -11
  111. package/dist/monid.d.ts +14 -1
  112. package/dist/monid.js +103 -26
  113. package/dist/ollama-provider.d.ts +7 -1
  114. package/dist/ollama-provider.js +14 -2
  115. package/dist/openapi.js +210 -37
  116. package/dist/otel/genai.d.ts +65 -0
  117. package/dist/otel/genai.js +116 -0
  118. package/dist/otel/tracer.d.ts +55 -0
  119. package/dist/otel/tracer.js +308 -0
  120. package/dist/page.d.ts +2 -0
  121. package/dist/page.js +3 -1
  122. package/dist/paid-calls.d.ts +1 -32
  123. package/dist/paid-calls.js +4 -39
  124. package/dist/place-offers.d.ts +4 -0
  125. package/dist/place-offers.js +7 -4
  126. package/dist/provider.d.ts +11 -2
  127. package/dist/provider.js +59 -8
  128. package/dist/redact/match.d.ts +30 -3
  129. package/dist/redact/match.js +422 -41
  130. package/dist/refusal-words.d.ts +11 -0
  131. package/dist/refusal-words.js +11 -0
  132. package/dist/run-census.d.ts +67 -0
  133. package/dist/run-census.js +240 -0
  134. package/dist/run-computer.d.ts +6 -3
  135. package/dist/run-computer.js +4 -1
  136. package/dist/run-cut.d.ts +15 -6
  137. package/dist/run-cut.js +30 -9
  138. package/dist/run-files.d.ts +3 -0
  139. package/dist/run-files.js +3 -0
  140. package/dist/run-launch.d.ts +12 -1
  141. package/dist/run-launch.js +9 -10
  142. package/dist/run-learning-served.d.ts +4 -2
  143. package/dist/run-model-key.d.ts +8 -0
  144. package/dist/run-model-key.js +31 -1
  145. package/dist/run-reads-over-store.d.ts +24 -6
  146. package/dist/run-reads-over-store.js +67 -23
  147. package/dist/run-recordings.d.ts +5 -1
  148. package/dist/run-recordings.js +39 -14
  149. package/dist/run-timeline-served.d.ts +2 -0
  150. package/dist/run-timeline-served.js +2 -2
  151. package/dist/run-usage.d.ts +1 -0
  152. package/dist/run-view.d.ts +1 -2
  153. package/dist/run-view.js +2 -1
  154. package/dist/runnable.d.ts +10 -1
  155. package/dist/runnable.js +20 -8
  156. package/dist/runner/adapter-loop.d.ts +11 -0
  157. package/dist/runner/adapter-loop.js +58 -26
  158. package/dist/runner/adapter-run-spec.d.ts +55 -11
  159. package/dist/runner/adapter-run-spec.js +183 -52
  160. package/dist/runner/adapters/pi.js +25 -3
  161. package/dist/runner/beside.d.ts +9 -2
  162. package/dist/runner/beside.js +27 -9
  163. package/dist/runner/big-writes.js +1 -10
  164. package/dist/runner/claim-secrets.d.ts +27 -10
  165. package/dist/runner/claim-secrets.js +49 -22
  166. package/dist/runner/cli-run-spec.d.ts +6 -0
  167. package/dist/runner/cli-run-spec.js +97 -38
  168. package/dist/runner/computer-journal.d.ts +9 -1
  169. package/dist/runner/computer-journal.js +26 -0
  170. package/dist/runner/conformance/harness.js +1 -1
  171. package/dist/runner/feedback-round.js +3 -0
  172. package/dist/runner/harness-loops.d.ts +6 -5
  173. package/dist/runner/harness-loops.js +7 -7
  174. package/dist/runner/held.d.ts +24 -6
  175. package/dist/runner/journal-kinds.d.ts +5 -0
  176. package/dist/runner/journal-kinds.js +5 -0
  177. package/dist/runner/main.d.ts +11 -6
  178. package/dist/runner/main.js +19 -9
  179. package/dist/runner/mcp-claim.js +31 -3
  180. package/dist/runner/mcp-run.d.ts +9 -0
  181. package/dist/runner/mcp-run.js +11 -5
  182. package/dist/runner/model-route.d.ts +17 -0
  183. package/dist/runner/model-route.js +120 -2
  184. package/dist/runner/presence.d.ts +11 -1
  185. package/dist/runner/presence.js +7 -0
  186. package/dist/runner/reflect-hook.js +1 -1
  187. package/dist/runner/run-child-host.d.ts +22 -8
  188. package/dist/runner/run-child-host.js +128 -41
  189. package/dist/runner/run-child.js +5 -2
  190. package/dist/runner/runner.d.ts +17 -3
  191. package/dist/runner/runner.js +130 -34
  192. package/dist/runner/save-slots.js +2 -1
  193. package/dist/runner/store-port.d.ts +1 -1
  194. package/dist/runner/store-secrets.d.ts +6 -0
  195. package/dist/runner/store-secrets.js +49 -7
  196. package/dist/runner/subagent.d.ts +11 -0
  197. package/dist/runner/subagent.js +16 -38
  198. package/dist/runner/workflow-first.d.ts +35 -15
  199. package/dist/runner/workflow-first.js +38 -25
  200. package/dist/runner/workflow-spec.js +4 -3
  201. package/dist/runs-over-store.d.ts +15 -6
  202. package/dist/runs-over-store.js +33 -21
  203. package/dist/scrub-command.d.ts +73 -0
  204. package/dist/scrub-command.js +307 -0
  205. package/dist/secret-cut.d.ts +73 -0
  206. package/dist/secret-cut.js +291 -4
  207. package/dist/secret-rules.d.ts +143 -0
  208. package/dist/secret-rules.js +2564 -0
  209. package/dist/secrets.d.ts +7 -0
  210. package/dist/secrets.js +20 -0
  211. package/dist/server-keys.d.ts +20 -0
  212. package/dist/server-keys.js +25 -6
  213. package/dist/server.d.ts +65 -13
  214. package/dist/server.js +470 -157
  215. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  216. package/dist/slots.d.ts +9 -0
  217. package/dist/slots.js +45 -0
  218. package/dist/store/index.d.ts +1 -1
  219. package/dist/store/index.js +1 -1
  220. package/dist/store/journal/storage.js +1 -1
  221. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  222. package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
  223. package/dist/store/schema.d.ts +23 -0
  224. package/dist/store/schema.js +58 -2
  225. package/dist/store/seal.d.ts +6 -1
  226. package/dist/store/seal.js +5 -3
  227. package/dist/store/sqlite/run-launch.d.ts +9 -1
  228. package/dist/store/sqlite/run-launch.js +24 -13
  229. package/dist/store/sqlite/run-patch.d.ts +12 -2
  230. package/dist/store/sqlite/run-patch.js +42 -5
  231. package/dist/store/sqlite/store.js +105 -12
  232. package/dist/store/store.d.ts +57 -2
  233. package/dist/store/store.js +20 -0
  234. package/dist/store-reads/learning.d.ts +84 -124
  235. package/dist/store-reads/learning.js +210 -274
  236. package/dist/store-view.d.ts +3 -0
  237. package/dist/store-view.js +3 -3
  238. package/dist/suggestions.js +3 -2
  239. package/dist/template-eval.d.ts +39 -9
  240. package/dist/template-eval.js +191 -60
  241. package/dist/template-import.js +6 -2
  242. package/dist/templates.d.ts +10 -2
  243. package/dist/templates.js +28 -8
  244. package/dist/timeline/labels.d.ts +6 -4
  245. package/dist/timeline/labels.js +18 -6
  246. package/dist/timeline/timeline.d.ts +5 -0
  247. package/dist/timeline/timeline.js +14 -8
  248. package/dist/timeline/util.js +1 -1
  249. package/dist/timeline/web-calls.d.ts +22 -7
  250. package/dist/timeline/web-calls.js +106 -35
  251. package/dist/tool-gate.d.ts +42 -3
  252. package/dist/tool-gate.js +66 -5
  253. package/dist/tool-keys-store.d.ts +2 -4
  254. package/dist/tool-keys-store.js +5 -21
  255. package/dist/tool-keys.d.ts +2 -2
  256. package/dist/tool-keys.js +2 -2
  257. package/dist/tool-list.js +1 -1
  258. package/dist/tool-plane.d.ts +2 -2
  259. package/dist/tool-plane.js +35 -33
  260. package/dist/tools.js +13 -7
  261. package/dist/trigger-targets.d.ts +4 -0
  262. package/dist/trigger-targets.js +9 -2
  263. package/dist/triggers.d.ts +67 -4
  264. package/dist/triggers.js +171 -22
  265. package/dist/until.d.ts +3 -0
  266. package/dist/until.js +11 -0
  267. package/dist/web-fake.d.ts +1 -3
  268. package/dist/web-fake.js +7 -18
  269. package/dist/web-fetch.d.ts +6 -72
  270. package/dist/web-fetch.js +11 -265
  271. package/dist/web-run.d.ts +31 -0
  272. package/dist/web-run.js +90 -0
  273. package/dist/web-save.d.ts +10 -13
  274. package/dist/web-save.js +13 -55
  275. package/dist/web-search.d.ts +9 -127
  276. package/dist/web-search.js +23 -259
  277. package/dist/wires.d.ts +13 -0
  278. package/dist/wires.js +11 -0
  279. package/dist/workflow-run.d.ts +5 -4
  280. package/dist/workflow-run.js +5 -4
  281. package/dist/workspace/attached-computers.d.ts +32 -9
  282. package/dist/workspace/attached-computers.js +77 -13
  283. package/dist/workspace/computer-deps.d.ts +8 -2
  284. package/dist/workspace/computer-deps.js +10 -3
  285. package/dist/workspace/computer-for-claim.d.ts +12 -1
  286. package/dist/workspace/computer-for-claim.js +83 -11
  287. package/dist/workspace/computer-kept.d.ts +3 -0
  288. package/dist/workspace/computer-kept.js +11 -2
  289. package/dist/workspace/index.d.ts +1 -1
  290. package/dist/workspace/index.js +1 -1
  291. package/dist/workspace/kind-skills.d.ts +4 -0
  292. package/dist/workspace/kind-skills.js +9 -0
  293. package/dist/workspace/paired-route.d.ts +91 -0
  294. package/dist/workspace/paired-route.js +153 -0
  295. package/dist/workspace/synced-folder.js +3 -4
  296. package/dist/wrapped.d.ts +20 -6
  297. package/dist/wrapped.js +66 -25
  298. package/package.json +17 -11
  299. package/skills/agentrun-serve/SKILL.md +4 -0
  300. package/templates/README.md +32 -10
  301. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  302. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  303. package/dist/exa-keyless.d.ts +0 -34
  304. package/dist/exa-keyless.js +0 -118
  305. package/dist/firecrawl-keyless.d.ts +0 -41
  306. package/dist/firecrawl-keyless.js +0 -152
  307. package/dist/keyless-mcp.d.ts +0 -36
  308. package/dist/keyless-mcp.js +0 -127
  309. package/dist/text-urls.d.ts +0 -38
  310. package/dist/text-urls.js +0 -170
  311. package/dist/web-fetch-direct.d.ts +0 -119
  312. package/dist/web-fetch-direct.js +0 -190
@@ -29,11 +29,18 @@ export function besideStopping(server, held, drainMs) {
29
29
  * caller hands its own: the template eval's in-process server, its faux's). `loops` and `drainMs`: the runner's
30
30
  * (RunnerOptions), the CLI start's from the server's flags (besideRunnerOptions). `janitor`: run the computer janitor
31
31
  * too (workspace/computer-janitor.ts), as the CLI's start asks. `hub`: the server's AttachHub (Serve.attachHub), which
32
- * holds each paired computer's socket in this process, so a run here takes one. `dial`: the server's (Serve.dial), which
32
+ * holds each paired computer's socket in this process, so a run here takes one; with it `beside`, the name and
33
+ * incarnation the server gave this runner (Serve.beside), which it runs under and its run's route of a paired box names
34
+ * (dial-relay.ts pairedRelayOn over the server's hub), so a runner apart's take for another run is refused while the
35
+ * hold lasts and the server keeps the box in its hub. `dial`: the server's (Serve.dial), which
33
36
  * a remote provider's create takes, so a machine that dials the server lands in this process's hub. Returns the runner
34
37
  * and a close() that stops both and closes its store. `loopsTold`: `loops` was given (besideRunnerOptions), so on uid
35
38
  * isolation a number past the helper's slots is refused rather than cut. */
36
- export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, janitor, ownProcesses, hub, dial, mcpLoopback, mcpOwn, ollamaHost, evalFakes, harnessInstall, onLine, onRunEnded } = {}) {
39
+ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, janitor, ownProcesses, hub, beside, dial, mcpLoopback, mcpOwn, ollamaHost, evalFakes, harnessInstall, onLine, onRunEnded } = {}) {
40
+ // A paired box in the server's hub is held under a route naming this runner, which the server must know: never one
41
+ // without the other.
42
+ if (hub !== undefined && beside === undefined)
43
+ throw new Error("a runner beside a server takes the server's hub with the name and incarnation the server gave it (Serve.beside)");
37
44
  const { runnerName, startRunner } = await import("./runner.js");
38
45
  const { dispatchRunner } = await import("./harness-loops.js");
39
46
  const { routeOf } = await import("./model-route.js");
@@ -67,12 +74,17 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
67
74
  const { hostAddressesOnce } = await import("../docker-host-addresses.js");
68
75
  const { PROVIDERS } = await import("@parcha/agentrun-computer");
69
76
  const { hostCommandRefusals } = await import("../computers.js");
70
- const computers = runnerComputers(store, runs, seal.key, { dockerPaths: () => dockerPathsForRuns(runs, dataDir), hostAddresses: () => hostAddressesOnce(runs), hostWhy: hostCommandRefusals(PROVIDERS, process.env.PATH), ...(hub ? { hub } : {}), ...(dial ? { dial } : {}) });
77
+ // A paired box is brought and let go over the server's hub as a runner apart's is over its own (dial-relay.ts
78
+ // pairedRelayOn): its run's claim takes the box's route under this runner's name and incarnation, a cancel mid-bring
79
+ // or the run's release (its loop's finally, a cancel or a throw included) drops it, and a sweep drops one whose hold
80
+ // ended without either.
81
+ const paired = hub && beside ? (await import("../dial-relay.js")).pairedRelayOn({ store, hub, runner: beside.runner, incarnation: beside.incarnation, log: (line) => console.error(`agentrun-serve runner: ${line}`) }) : undefined;
82
+ const computers = runnerComputers(store, runs, seal.key, { dockerPaths: () => dockerPathsForRuns(runs, dataDir), hostAddresses: () => hostAddressesOnce(runs), hostWhy: hostCommandRefusals(PROVIDERS, process.env.PATH), ...(paired ? { pairedRelay: paired.paired } : {}), ...(dial ? { dial } : {}) });
71
83
  // `mcpLoopback`: the server beside it is a local install (Serve.localInstall), so its runs may reach an MCP server on
72
84
  // loopback; a runner in its own process does only as its own environment says (main.ts runnerLoopback). `mcpOwn`: that server's own addresses (Serve.own), whose ports a run's
73
85
  // loopback read never goes to. A run's log lines (a sweep that failed) go to
74
- // stderr with the runner's other lines. `evalFakes`: the template eval's fakes (EvalFakes: a case's web, now, monid and
75
- // email), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
86
+ // stderr with the runner's other lines. `evalFakes`: the template eval's fakes (EvalFakes: a case's web, now, monid,
87
+ // email and files), by the agent each of its runs is of; only the eval, in its own process, hands them. `harnessInstall`: what a
76
88
  // claim's first-use install installs with (the eval's sharedInstaller, which the server beside it takes too).
77
89
  const { installForClaim } = await import("../harness-install.js");
78
90
  const deps = { env: runs, data: dataDir, journal: (claim) => store.journal(claim), store, sealKey: seal.key, routeOf, computerForClaim: computers.computerForClaim, computerDeps: computers.computerDeps, ...(mcpLoopback ? { mcpLoopback: true } : {}), ...(mcpOwn ? { mcpOwn } : {}), ...(evalFakes ? { evalFakes } : {}), ...(harnessInstall ? { installForClaim: ((entry, dir, pins, given) => installForClaim(entry, dir, pins, { ...given, install: harnessInstall })) } : {}), log: (line) => console.error(`agentrun-serve runner: ${line}`) };
@@ -87,6 +99,7 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
87
99
  isolation = await runIsolationOf(process.env, loopsTold ? loops : undefined, deps.log);
88
100
  }
89
101
  catch (error) {
102
+ paired?.stop();
90
103
  await store.close();
91
104
  seal.release();
92
105
  throw error;
@@ -112,7 +125,11 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
112
125
  // stderr), so a lapse of its claims shows its cause.
113
126
  const { runLine } = await import("../print.js");
114
127
  const { metricLine, startRunnerGauge } = await import("./runner-metrics.js");
115
- const name = runnerName();
128
+ const name = beside?.runner ?? runnerName();
129
+ // Said on the data folder before it claims: whether its runs on Claude Code's login stay in this process, its CLI on
130
+ // the login's folder (claude-login-token.ts sayLoginRunner), for a runner whose runs are users of their own to read.
131
+ const { sayLoginRunner } = await import("../claude-login-token.js");
132
+ sayLoginRunner(dataDir, name, isolation?.kind === "uid" ? "uid" : "process");
116
133
  const said = (event) => {
117
134
  for (const { line, error } of besideLines(name, event, { metricLine, troubleLine, runLine }))
118
135
  (onLine ?? (error ? console.error : console.log))(line);
@@ -124,9 +141,10 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
124
141
  // the runner beside it (read at each end, once it has started): a computer kept pinned to another runner is that one's.
125
142
  const { runEndComputers } = await import("../workspace/run-end-computers.js");
126
143
  const { projectRunEnded } = await import("../source-sync/checkpoints.js");
144
+ const { runCensus } = await import("../run-census.js");
127
145
  const self = () => (runner.incarnation ? { runner: name, incarnation: runner.incarnation } : undefined);
128
146
  const runEnded = projectRunEnded(store, runEndComputers({ store, computers: computers.computerDeps, log: (line) => console.error(`agentrun-serve runner: ${line}`), self }));
129
- const runner = startRunner({ store, name, createLoop, memory: runnerMemory(store, undefined, runs, isolation ? RUN_PROCESS_MIB : 0), onEvent: said, runEnded, ...(held !== undefined ? { loops: held } : {}), ...(drainMs !== undefined ? { drainMs } : {}) });
147
+ const runner = startRunner({ store, name, ...(beside ? { incarnation: beside.incarnation } : {}), createLoop, census: runCensus(store, { data: dataDir, sealKey: seal.key, env: runs }), memory: runnerMemory(store, undefined, runs, isolation ? RUN_PROCESS_MIB : 0), onEvent: said, runEnded, ...(held !== undefined ? { loops: held } : {}), ...(drainMs !== undefined ? { drainMs } : {}) });
130
148
  // The computer janitor over the same computers, when the start asks for it: never under --faux. Its lines are the
131
149
  // runner's, on stderr (a stderr whose reader closed loses them, never the process: cli.ts).
132
150
  const { startJanitor } = await import("../workspace/computer-janitor.js");
@@ -139,7 +157,7 @@ export async function runnerBeside(dataDir, { loops, loopsTold, drainMs, env, ja
139
157
  // Its gauge (runner-metrics.ts): the runs it holds of its loops, and the process's memory (the server's with it), every
140
158
  // minute until its close.
141
159
  const gauge = startRunnerGauge({ runner: name, held: () => runner.held().length, slots: held ?? RUNNER_LOOPS, write: (line) => (onLine ?? console.log)(line) });
142
- return { runner, close: async () => { gauge.stop(); await Promise.all([swept?.close(), runner.close()]); await claimInstallsStopped(); await store.close(); seal.release(); } };
160
+ return { runner, close: async () => { gauge.stop(); await Promise.all([swept?.close(), runner.close()]); paired?.stop(); await claimInstallsStopped(); await store.close(); seal.release(); } };
143
161
  }
144
162
  /** The lines runner `name` beside a server says for `event`, in order, each with whether it goes to stderr (`error`): its
145
163
  * metric line (runner-metrics.ts metricLine: a claim, a hand-back by cause, a lost claim, the drain), then its trouble
@@ -171,7 +189,7 @@ export async function serveWithRunner(options) {
171
189
  const serve = await startServe(options);
172
190
  // Each run a process of its own, as a user of its own where the image's helper can switch, as the CLI's start runs
173
191
  // them (cli.ts): the isolation the server's capabilities say (runIsolationOf over the same helper) is the runner's.
174
- const beside = await runnerBeside(options.data, { loops, loopsTold, drainMs, env: besideRunEnv(process.env, fauxEnvOf(options)), ownProcesses: true, hub: serve.attachHub, dial: serve.dial, mcpLoopback: serve.localInstall, mcpOwn: serve.own, ollamaHost: serve.ollamaHost, ...(options.log ? { onLine: options.log } : {}) }).catch(async (error) => {
192
+ const beside = await runnerBeside(options.data, { loops, loopsTold, drainMs, env: besideRunEnv(process.env, fauxEnvOf(options)), ownProcesses: true, hub: serve.attachHub, beside: serve.beside, dial: serve.dial, mcpLoopback: serve.localInstall, mcpOwn: serve.own, ollamaHost: serve.ollamaHost, ...(options.log ? { onLine: options.log } : {}) }).catch(async (error) => {
175
193
  await serve.close();
176
194
  throw error;
177
195
  });
@@ -14,6 +14,7 @@
14
14
  // runner only copies bytes and calls the Workspace: it reads nothing of them and dials nothing.
15
15
  import { ClaimRefused } from "./loop-contract.js";
16
16
  import { ChannelClosed } from "./run-channel.js";
17
+ import { until } from "../until.js";
17
18
  import { saveSlots, SAVE_MAX_BYTES } from "../web-save.js";
18
19
  import { WorkspaceError } from "../workspace/workspace.js";
19
20
  export { piecedWorkspace } from "../workspace/pieced.js";
@@ -31,16 +32,6 @@ export const BIG_WRITES = 4;
31
32
  export const BIG_WRITES_PER_RUN = 8;
32
33
  /** The runner's one gate for pieced writes. */
33
34
  export const BIG_WRITE_SLOTS = saveSlots(BIG_WRITES);
34
- /** `work`'s answer, or `signal`'s reason as soon as it aborts. */
35
- function until(work, signal) {
36
- if (signal.aborted)
37
- return Promise.reject(signal.reason);
38
- return new Promise((resolve, reject) => {
39
- const abort = () => reject(signal.reason);
40
- signal.addEventListener("abort", abort, { once: true });
41
- work.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
42
- });
43
- }
44
35
  export function runBigWrites(options = {}) {
45
36
  const gate = options.gate ?? BIG_WRITE_SLOTS;
46
37
  const piece = options.piece ?? PIECE_BYTES;
@@ -30,12 +30,19 @@ type RunLaunchReader = {
30
30
  /** The environment a claimed run's tools run under: the runner's base (its secrets stripped), with the keys the run's
31
31
  * revision needs read from the store on top — the tool keys its tools unlock, the model keys its model needs, and its
32
32
  * decision provider keys — and, for claim `runId`, the run's own tool keys its revision declares (run-keys.ts) over the
33
- * server's by the same name. A fresh object per claim, so no run's keys reach another's. `redact`: the runner's one
33
+ * server's by the same name. Its model keys are readable by name and never enumerable (MODEL_KEY_NAMES): its model
34
+ * routes read them by name (claimModelEnv), and a spread or a spawn of the tools' environment carries none. A fresh
35
+ * object per claim, so no run's keys reach another's. `redact`: the runner's one
34
36
  * redactor, which the run's own tool keys are carried into before they are laid, so its journal is cut of them as it is
35
- * written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws. */
37
+ * written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws. A held run
38
+ * its model kept from running at its create (hold.refused) is laid no model key and no plan sign-in: its model runs
39
+ * nowhere. Its tools' keys, its decision keys and its own tool keys are laid as any run's. The one tool key row that names
40
+ * a model key's name, TypeSafe's (key-words.ts; model.ts PROVIDER_KEYS typesafe), is a decision key (secrets.ts
41
+ * DECISION_KEYS): keysFor never names one, so the model key filter below never sees it, and decisionKeysFor lays it
42
+ * apart, as it lays OpenRouter's for a decision node that runs on it. */
36
43
  export declare function claimSecrets(deps: ClaimSecretsDeps & {
37
44
  readonly redact: HeldRedact;
38
- }, revision: Revision, launch: Pick<RunLaunch, "plane" | "model">, runId?: string): Promise<NodeJS.ProcessEnv>;
45
+ }, revision: Revision, launch: Pick<RunLaunch, "plane" | "model" | "hold">, runId?: string): Promise<NodeJS.ProcessEnv>;
39
46
  /** `keys` (learnedDecisionKeys') laid onto `env`, a claim's environment, where it holds no value of that name: what the
40
47
  * claim laid stays, a run's own tool key over the server's above all. A name both read holds the same server key. */
41
48
  export declare function underClaimed(env: NodeJS.ProcessEnv, keys: Readonly<Record<string, string>>): void;
@@ -54,8 +61,12 @@ export declare function hostDecisionKeys(deps: ClaimSecretsDeps, providers: read
54
61
  /** The model keys the host's models of `tiers` need (model.ts modelKeys: each one's provider's, or the gateway's), read as
55
62
  * claimSecrets reads a run's (the runner's environment first, then the key saved in Settings → Model keys), for a run's
56
63
  * learned workflow nodes of those tiers (adapter-run-spec.ts learnedTierRoutes): claimSecrets opens only the run's own
57
- * model's. For the tiers' routes alone, through withModelKeys (never enumerable), never onto a tool's environment. */
58
- export declare function tierModelKeys(deps: ClaimSecretsDeps, tiers: readonly Tier[]): Promise<NodeJS.ProcessEnv>;
64
+ * model's. For the tiers' routes alone, through withModelKeys (never enumerable), never onto a tool's environment.
65
+ * `refs`: a model named for a tier in place of the host's (an agentic revision's modelTiers, for its subagent tiers:
66
+ * subagentTierKeys), read on the runner alone; a run's process names none. It scopes the key names alone: the ChatGPT
67
+ * sign-in is given for the host's models of `tiers`, as before (a revision's own model on the plan reaches the sign-in
68
+ * through its claim: claimSecrets reachesPlan). */
69
+ export declare function tierModelKeys(deps: ClaimSecretsDeps, tiers: readonly Tier[], refs?: Readonly<Partial<Record<Tier, string>>>): Promise<NodeJS.ProcessEnv>;
59
70
  /** Every model key a model route reads by name: each of pi-ai's providers' (model.ts PROVIDER_KEYS) and the gateway's. */
60
71
  export declare const MODEL_KEY_NAMES: readonly string[];
61
72
  /** `env` for a model route (model-route.ts routeOf, a CLI's providerFor): the runner's own environment, its secrets kept
@@ -63,9 +74,15 @@ export declare const MODEL_KEY_NAMES: readonly string[];
63
74
  * a claim opened from the store (claimSecrets, scoped to the run's model), or every one the server holds
64
75
  * (savedModelKeys). So a model key saved in Settings → Model keys reaches the next run's model requests with no
65
76
  * restart, as a tool key reaches its tools; a key set where AgentRun starts still wins (claimSecrets reads it first),
66
- * and a provider the runner holds any key of gets none of its saved ones.
77
+ * and a provider the runner holds any key of gets none of its saved ones. Each name is read from the first of `opened`
78
+ * that holds it, by name, as a run's process is handed its keys (run-child-host.ts handed): a claim's model keys, never
79
+ * enumerable, count as any other.
67
80
  * The keys added are never enumerable either: a spread of the result, or a spawn given it, carries none of them. */
68
- export declare function withModelKeys(env: NodeJS.ProcessEnv, opened: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
81
+ export declare function withModelKeys(env: NodeJS.ProcessEnv, ...opened: readonly NodeJS.ProcessEnv[]): NodeJS.ProcessEnv;
82
+ /** The saved model keys of the models of a run's subagent tiers (`tiers`, `refs` as subagent.ts routedSubagentTiers
83
+ * gives them; the revision's model of a tier over the host's): each model's provider's key, or the gateway's. None for
84
+ * no tier. */
85
+ export declare function subagentTierKeys(deps: ClaimSecretsDeps, tiers: readonly Tier[], refs: Readonly<Partial<Record<Tier, string>>>): Promise<NodeJS.ProcessEnv>;
69
86
  /** Every model key the server holds, for a model route with no revision to scope it by (an SDK run's compile turn): each
70
87
  * by its name from `deps.env` first, then the store's sealed value, as claimSecrets reads them. */
71
88
  export declare function savedModelKeys(deps: ClaimSecretsDeps): Promise<NodeJS.ProcessEnv>;
@@ -130,9 +147,9 @@ export declare function serverKeyless(deps: ClaimSecretsDeps): Promise<boolean>;
130
147
  * Settings → Model keys) has none to spend (noServerKeyWords). Undefined where it runs. */
131
148
  export declare function claimSpendOff(deps: ClaimSecretsDeps, runKey: ClaimModelKey | undefined): Promise<(what: string) => string | undefined>;
132
149
  /** The env a claimed run's model routes read: the run's own key alone where the claim opened one (withRunModelKey); else
133
- * the runner's environment with the keys `opened` for it (withModelKeys), whose gateway variables read the run's key
134
- * once a message hands it one (withRunModelKeyLater). */
135
- export declare function claimModelEnv(env: NodeJS.ProcessEnv, opened: NodeJS.ProcessEnv, runKey: ClaimModelKey | undefined, claim?: Pick<Claim, "runId" | "turn" | "attempt">): NodeJS.ProcessEnv;
150
+ * the runner's environment with the keys `opened` for it, each name from the first source that holds it (withModelKeys),
151
+ * whose gateway variables read the run's key once a message hands it one (withRunModelKeyLater). */
152
+ export declare function claimModelEnv(env: NodeJS.ProcessEnv, opened: readonly NodeJS.ProcessEnv[], runKey: ClaimModelKey | undefined, claim?: Pick<Claim, "runId" | "turn" | "attempt">): NodeJS.ProcessEnv;
136
153
  /** `toolEnv` with no model key in it, for a run that holds its own: a tool's environment never carries a model key the
137
154
  * run's model routes do not send. The decision providers' keys stay (DECISION_KEY_NAMES): a keyed workflow's judge,
138
155
  * pick, sift, route and ask nodes run on them as any run's do. */
@@ -26,9 +26,16 @@ const CANDIDATES = [...new Set([...RUN_SECRETS, ...DECISION_KEYS])];
26
26
  /** The environment a claimed run's tools run under: the runner's base (its secrets stripped), with the keys the run's
27
27
  * revision needs read from the store on top — the tool keys its tools unlock, the model keys its model needs, and its
28
28
  * decision provider keys — and, for claim `runId`, the run's own tool keys its revision declares (run-keys.ts) over the
29
- * server's by the same name. A fresh object per claim, so no run's keys reach another's. `redact`: the runner's one
29
+ * server's by the same name. Its model keys are readable by name and never enumerable (MODEL_KEY_NAMES): its model
30
+ * routes read them by name (claimModelEnv), and a spread or a spawn of the tools' environment carries none. A fresh
31
+ * object per claim, so no run's keys reach another's. `redact`: the runner's one
30
32
  * redactor, which the run's own tool keys are carried into before they are laid, so its journal is cut of them as it is
31
- * written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws. */
33
+ * written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws. A held run
34
+ * its model kept from running at its create (hold.refused) is laid no model key and no plan sign-in: its model runs
35
+ * nowhere. Its tools' keys, its decision keys and its own tool keys are laid as any run's. The one tool key row that names
36
+ * a model key's name, TypeSafe's (key-words.ts; model.ts PROVIDER_KEYS typesafe), is a decision key (secrets.ts
37
+ * DECISION_KEYS): keysFor never names one, so the model key filter below never sees it, and decisionKeysFor lays it
38
+ * apart, as it lays OpenRouter's for a decision node that runs on it. */
32
39
  export async function claimSecrets(deps, revision, launch, runId) {
33
40
  const base = withoutSecrets(deps.env ?? {});
34
41
  const working = await workingEnv(deps);
@@ -37,16 +44,20 @@ export async function claimSecrets(deps, revision, launch, runId) {
37
44
  // the host's default now: a key saved since the run started (another provider's, now first) would otherwise be opened
38
45
  // in its place, and the run would hold a key its model never sends and lack the one it does.
39
46
  const scoped = launch.model && !needs.tiers ? { ...needs, model: `${launch.model.provider}/${launch.model.modelId}` } : needs;
47
+ const modelRefused = launch.hold?.refused !== undefined;
40
48
  const env = { ...base };
41
49
  // The key of a gateway saved in the console (model-gateway.ts) stays on the run environment its model routes read, never
42
50
  // on the tools': it is read there by name alone (claimModelEnv), as a run's own model key is.
43
51
  const savedGateway = savedGatewayIn(deps.env ?? {});
52
+ // A model key is never enumerable, as withModelKeys lays a route's, but unlike a route's it stays writable and deletable
53
+ // (withoutModelKeys drops it); a tool key is a plain value, which its tools read and hand on.
44
54
  for (const name of keysFor(scoped, working))
45
- if (working[name] !== undefined && !(savedGateway && name === GATEWAY_KEY_ENV))
46
- env[name] = working[name];
55
+ if (working[name] !== undefined && !(savedGateway && name === GATEWAY_KEY_ENV) && !(modelRefused && MODEL_KEY_NAMES.includes(name)))
56
+ Object.defineProperty(env, name, { value: working[name], enumerable: !MODEL_KEY_NAMES.includes(name), writable: true, configurable: true });
47
57
  const decision = decisionKeysFor(working, { providers: needs.decisionProviders, parallelWeb: launch.plane ? handsParallel(launch.plane) : false });
58
+ // A decision key is a plain value, as before, under a model key's name too (OpenRouter's, which Jev's nodes use).
48
59
  for (const [name, value] of Object.entries(decision))
49
- env[name] = value;
60
+ Object.defineProperty(env, name, { value, enumerable: true, writable: true, configurable: true });
50
61
  // The run's own tool keys, sealed with its launch: each one its revision declares, over the server's by the same name.
51
62
  // Opened by a runner, which holds the seal key; a run's own process is handed them with the rest of its claim's keys.
52
63
  if (runId !== undefined && deps.sealKey && deps.store.runs) {
@@ -65,7 +76,7 @@ export async function claimSecrets(deps, revision, launch, runId) {
65
76
  // proxy sends (chatgpt-plan.ts), never put on the environment its tools run under (a symbol no spawn copies). Only for
66
77
  // a run that can reach a plan model: one pinned to a key's model (and its tiers on keys) never holds the sign-in, which
67
78
  // renews and spends the person's plan for any process that holds it.
68
- const plan = await planReaderOf(deps.store, deps.sealKey);
79
+ const plan = modelRefused ? undefined : await planReaderOf(deps.store, deps.sealKey);
69
80
  return plan && reachesPlan(withPlan({ ...working }, plan), scoped, revision) ? withPlan(env, plan) : env;
70
81
  }
71
82
  const onPlan = (model) => model?.startsWith(`${PLAN_PROVIDER}/`) === true;
@@ -143,8 +154,12 @@ export async function hostDecisionKeys(deps, providers) {
143
154
  /** The model keys the host's models of `tiers` need (model.ts modelKeys: each one's provider's, or the gateway's), read as
144
155
  * claimSecrets reads a run's (the runner's environment first, then the key saved in Settings → Model keys), for a run's
145
156
  * learned workflow nodes of those tiers (adapter-run-spec.ts learnedTierRoutes): claimSecrets opens only the run's own
146
- * model's. For the tiers' routes alone, through withModelKeys (never enumerable), never onto a tool's environment. */
147
- export async function tierModelKeys(deps, tiers) {
157
+ * model's. For the tiers' routes alone, through withModelKeys (never enumerable), never onto a tool's environment.
158
+ * `refs`: a model named for a tier in place of the host's (an agentic revision's modelTiers, for its subagent tiers:
159
+ * subagentTierKeys), read on the runner alone; a run's process names none. It scopes the key names alone: the ChatGPT
160
+ * sign-in is given for the host's models of `tiers`, as before (a revision's own model on the plan reaches the sign-in
161
+ * through its claim: claimSecrets reachesPlan). */
162
+ export async function tierModelKeys(deps, tiers, refs = {}) {
148
163
  if (!tiers.length)
149
164
  return {};
150
165
  // A run's own process holds no seal key: its runner reads them, the plan's reader with them (held.ts).
@@ -155,7 +170,7 @@ export async function tierModelKeys(deps, tiers) {
155
170
  }
156
171
  const working = await workingEnv(deps);
157
172
  const out = {};
158
- for (const name of modelKeys(working, undefined, tiers))
173
+ for (const name of modelKeys(working, undefined, tiers, refs))
159
174
  if (working[name] !== undefined)
160
175
  out[name] = working[name];
161
176
  // The ChatGPT sign-in, when a host model of those tiers is on the plan (claimSecrets gives it only to a run whose own
@@ -171,9 +186,11 @@ export const MODEL_KEY_NAMES = [...new Set([...Object.values(PROVIDER_KEYS).flat
171
186
  * a claim opened from the store (claimSecrets, scoped to the run's model), or every one the server holds
172
187
  * (savedModelKeys). So a model key saved in Settings → Model keys reaches the next run's model requests with no
173
188
  * restart, as a tool key reaches its tools; a key set where AgentRun starts still wins (claimSecrets reads it first),
174
- * and a provider the runner holds any key of gets none of its saved ones.
189
+ * and a provider the runner holds any key of gets none of its saved ones. Each name is read from the first of `opened`
190
+ * that holds it, by name, as a run's process is handed its keys (run-child-host.ts handed): a claim's model keys, never
191
+ * enumerable, count as any other.
175
192
  * The keys added are never enumerable either: a spread of the result, or a spawn given it, carries none of them. */
176
- export function withModelKeys(env, opened) {
193
+ export function withModelKeys(env, ...opened) {
177
194
  // A provider's keys are filled together or not at all: only when the runner holds none of them. A credential handed where
178
195
  // AgentRun started (ANTHROPIC_AUTH_TOKEN, an AWS key id) is never mixed with a saved key of the same provider, which its
179
196
  // route would send first (ANTHROPIC_API_KEY before the token) or pair with it (another AWS name). A key held empty
@@ -182,9 +199,11 @@ export function withModelKeys(env, opened) {
182
199
  for (const names of [...Object.values(PROVIDER_KEYS), [GATEWAY_KEY_ENV]]) {
183
200
  if (names.some((name) => env[name]))
184
201
  continue;
185
- for (const name of names)
186
- if (opened[name])
187
- fill.set(name, opened[name]);
202
+ for (const name of names) {
203
+ const value = opened.map((from) => from[name]).find((held) => held);
204
+ if (value)
205
+ fill.set(name, value);
206
+ }
188
207
  }
189
208
  // Every property of `env` as it is (enumerable or not, as runEnv made it), but a name the fill replaces, so a fixed empty
190
209
  // property is never copied in its way.
@@ -196,14 +215,22 @@ export function withModelKeys(env, opened) {
196
215
  for (const [name, value] of fill)
197
216
  Object.defineProperty(out, name, { value, enumerable: false, writable: false, configurable: false });
198
217
  // The claim's ChatGPT sign-in (claimSecrets), else the runner's own.
199
- return withPlan(out, planOf(opened) ?? planOf(env));
218
+ return withPlan(out, opened.map(planOf).find((plan) => plan) ?? planOf(env));
219
+ }
220
+ /** The saved model keys of the models of a run's subagent tiers (`tiers`, `refs` as subagent.ts routedSubagentTiers
221
+ * gives them; the revision's model of a tier over the host's): each model's provider's key, or the gateway's. None for
222
+ * no tier. */
223
+ export async function subagentTierKeys(deps, tiers, refs) {
224
+ if (!tiers.length)
225
+ return {};
226
+ // A run's own process holds no seal key: its runner reads them for the claim's tiers (held.ts).
227
+ const at = deps.sealKey ? undefined : held();
228
+ return at ? { ...(await at.subagentTierKeys()) } : tierModelKeys(deps, tiers, refs);
200
229
  }
201
230
  /** Every model key the server holds, for a model route with no revision to scope it by (an SDK run's compile turn): each
202
231
  * by its name from `deps.env` first, then the store's sealed value, as claimSecrets reads them. */
203
232
  export async function savedModelKeys(deps) {
204
- // A run's own process holds no seal key: what its runner hands a claim whose routes read them (held.ts savedModelKeys).
205
- const at = deps.sealKey ? undefined : held();
206
- const out = at ? { ...(await at.savedModelKeys()) } : {};
233
+ const out = {};
207
234
  for (const name of MODEL_KEY_NAMES) {
208
235
  const value = deps.env?.[name] || (deps.sealKey ? await getSealedKey(deps.store, deps.sealKey, name) : undefined);
209
236
  if (value !== undefined)
@@ -324,13 +351,13 @@ export async function claimSpendOff(deps, runKey) {
324
351
  return (what) => (runKey?.everHeld() ? runKeyEndedFor(what) : keyless ? noServerKeyWords(what) : undefined);
325
352
  }
326
353
  /** The env a claimed run's model routes read: the run's own key alone where the claim opened one (withRunModelKey); else
327
- * the runner's environment with the keys `opened` for it (withModelKeys), whose gateway variables read the run's key
328
- * once a message hands it one (withRunModelKeyLater). */
354
+ * the runner's environment with the keys `opened` for it, each name from the first source that holds it (withModelKeys),
355
+ * whose gateway variables read the run's key once a message hands it one (withRunModelKeyLater). */
329
356
  export function claimModelEnv(env, opened, runKey, claim) {
330
357
  // The claim's run, turn and attempt, which each request on serve's gateway names (request-metadata.ts).
331
358
  if (!runKey)
332
- return withRequestMetadata(withModelKeys(env, opened), claim);
333
- return withRequestMetadata(keyedAtClaim(runKey) ? withRunModelKey(env, runKey) : withRunModelKeyLater(withModelKeys(env, opened), runKey), claim);
359
+ return withRequestMetadata(withModelKeys(env, ...opened), claim);
360
+ return withRequestMetadata(keyedAtClaim(runKey) ? withRunModelKey(env, runKey) : withRunModelKeyLater(withModelKeys(env, ...opened), runKey), claim);
334
361
  }
335
362
  /** The decision providers' own keys (decisions.ts: Jev's TypeSafe key, OpenRouter's, Parallel's): some are also pi-ai
336
363
  * provider names, but a run's model key never replaces them, so withoutModelKeys keeps them. */
@@ -1,6 +1,7 @@
1
1
  import { type CapModel } from "@parcha/agentrun-kernel/kernel/cap";
2
2
  import { type AdapterFacts } from "@parcha/agentrun-kernel";
3
3
  import { type HarnessEntry } from "../harness-table.js";
4
+ import { type ModelRef } from "../model.js";
4
5
  import { type RunLaunch } from "../run-launch.js";
5
6
  import { type AdapterRun, type AdapterRunSpec } from "./adapter-loop.js";
6
7
  import { type AdapterSpecDeps } from "./adapter-run-spec.js";
@@ -13,6 +14,11 @@ export type { ClaimComputer, ClaimDeps, ClaimLaunch, ComputerForClaim } from "./
13
14
  export type CliSpecDeps = AdapterSpecDeps;
14
15
  /** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
15
16
  export declare const cliRefusesKind: (kind: string) => string | undefined;
17
+ /** A harness's facts for a run on `model`: on a model the route translates onto its wire (an Ollama model), its own tool
18
+ * search is not its (AdapterFacts.ownToolSearch dropped): what it sends (deferred tools, a tool search's references) is
19
+ * the provider's to read, and the translation's model has none. The host's own tools_search and tools_call are offered
20
+ * in its place, as to a harness with none of its own. */
21
+ export declare const factsOn: <T extends AdapterFacts | undefined>(facts: T, model: ModelRef) => T;
16
22
  /** The model a CLI run is capped at: the catalog entry that bills it (its entry's priceModel), its cost WITH TIERS (the
17
23
  * money rule: a request past a tier is held and booked at it, as main's calculateCost does), on the harness's wire. A
18
24
  * model the catalog does not price is held at no price: its requests are unknown, never $0. A ChatGPT plan's model