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

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 (275) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/README.md +201 -52
  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 +17 -5
  11. package/dist/api-only.js +34 -8
  12. package/dist/browser-hold.d.ts +23 -0
  13. package/dist/browser-hold.js +48 -0
  14. package/dist/browser-person.d.ts +3 -0
  15. package/dist/browser-person.js +4 -1
  16. package/dist/chatgpt-plan.d.ts +18 -8
  17. package/dist/chatgpt-plan.js +91 -34
  18. package/dist/claude-login.d.ts +74 -16
  19. package/dist/claude-login.js +215 -56
  20. package/dist/claude-sign-in.d.ts +17 -6
  21. package/dist/claude-sign-in.js +42 -39
  22. package/dist/cli.js +63 -6
  23. package/dist/composio-made.d.ts +4 -0
  24. package/dist/composio-made.js +4 -0
  25. package/dist/composio-preset.d.ts +43 -2
  26. package/dist/composio-preset.js +92 -4
  27. package/dist/computer-held-routes.d.ts +5 -4
  28. package/dist/computer-held-routes.js +29 -8
  29. package/dist/computer-held.d.ts +6 -1
  30. package/dist/computer-held.js +14 -0
  31. package/dist/computer-record.js +4 -2
  32. package/dist/computer-viewer.js +4 -1
  33. package/dist/console/assets/{backend-Boh7tC4i.js → backend-DVhHzJX2.js} +19 -19
  34. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  35. package/dist/console/assets/index-okP-y8PK.js +747 -0
  36. package/dist/console/index.html +2 -2
  37. package/dist/decisions.d.ts +1 -1
  38. package/dist/decisions.js +1 -1
  39. package/dist/docker-host-addresses.d.ts +22 -11
  40. package/dist/docker-host-addresses.js +38 -26
  41. package/dist/env-switch.d.ts +10 -0
  42. package/dist/env-switch.js +33 -2
  43. package/dist/errors.d.ts +1 -0
  44. package/dist/errors.js +2 -0
  45. package/dist/fal-price.d.ts +58 -20
  46. package/dist/fal-price.js +341 -82
  47. package/dist/handed-values.d.ts +43 -1
  48. package/dist/handed-values.js +119 -2
  49. package/dist/harness-archive.d.ts +13 -10
  50. package/dist/harness-archive.js +60 -34
  51. package/dist/harness-check.d.ts +3 -1
  52. package/dist/harness-check.js +25 -46
  53. package/dist/harness-keys.d.ts +73 -27
  54. package/dist/harness-keys.js +194 -61
  55. package/dist/harness-recipe-entry.d.ts +8 -7
  56. package/dist/harness-recipe-entry.js +21 -32
  57. package/dist/harness-recipe.d.ts +38 -25
  58. package/dist/harness-recipe.js +49 -36
  59. package/dist/harness-sign-in.js +12 -23
  60. package/dist/harness-table.d.ts +10 -3
  61. package/dist/harness-table.js +26 -21
  62. package/dist/harness.d.ts +1 -0
  63. package/dist/harness.js +17 -5
  64. package/dist/hosted-search.d.ts +1 -1
  65. package/dist/hosted-search.js +1 -2
  66. package/dist/import-worker.d.ts +4 -2
  67. package/dist/import-worker.js +9 -2
  68. package/dist/in-flight.d.ts +26 -0
  69. package/dist/in-flight.js +52 -0
  70. package/dist/key-refusal.d.ts +9 -4
  71. package/dist/key-refusal.js +107 -25
  72. package/dist/learn/secrets.d.ts +13 -3
  73. package/dist/learn/secrets.js +118 -17
  74. package/dist/learning-cost.d.ts +6 -3
  75. package/dist/learning-cost.js +4 -2
  76. package/dist/link-check.js +1 -1
  77. package/dist/llms.txt +1 -1
  78. package/dist/marketplace.d.ts +77 -0
  79. package/dist/marketplace.js +224 -0
  80. package/dist/mcp-api-only-origins.d.ts +30 -0
  81. package/dist/mcp-api-only-origins.js +57 -0
  82. package/dist/mcp-gateway.d.ts +7 -5
  83. package/dist/mcp-gateway.js +9 -12
  84. package/dist/mcp-secret-writes.js +5 -3
  85. package/dist/mcp-servers-store.d.ts +28 -6
  86. package/dist/mcp-servers-store.js +53 -4
  87. package/dist/media-duration.d.ts +3 -0
  88. package/dist/media-duration.js +90 -9
  89. package/dist/model-form.d.ts +5 -4
  90. package/dist/model-form.js +11 -7
  91. package/dist/model.d.ts +5 -2
  92. package/dist/model.js +9 -5
  93. package/dist/ollama-provider.d.ts +7 -1
  94. package/dist/ollama-provider.js +14 -2
  95. package/dist/openapi.js +178 -27
  96. package/dist/otel/genai.d.ts +65 -0
  97. package/dist/otel/genai.js +116 -0
  98. package/dist/otel/tracer.d.ts +55 -0
  99. package/dist/otel/tracer.js +308 -0
  100. package/dist/page.d.ts +2 -0
  101. package/dist/page.js +3 -1
  102. package/dist/paid-calls.d.ts +1 -32
  103. package/dist/paid-calls.js +4 -39
  104. package/dist/provider.d.ts +9 -0
  105. package/dist/provider.js +50 -3
  106. package/dist/redact/match.d.ts +30 -3
  107. package/dist/redact/match.js +422 -41
  108. package/dist/refusal-words.d.ts +11 -0
  109. package/dist/refusal-words.js +11 -0
  110. package/dist/run-census.d.ts +67 -0
  111. package/dist/run-census.js +240 -0
  112. package/dist/run-computer.d.ts +6 -3
  113. package/dist/run-computer.js +4 -1
  114. package/dist/run-cut.d.ts +15 -6
  115. package/dist/run-cut.js +30 -9
  116. package/dist/run-files.d.ts +3 -0
  117. package/dist/run-files.js +3 -0
  118. package/dist/run-launch.d.ts +12 -1
  119. package/dist/run-launch.js +9 -10
  120. package/dist/run-learning-served.d.ts +2 -0
  121. package/dist/run-model-key.d.ts +8 -0
  122. package/dist/run-model-key.js +31 -1
  123. package/dist/run-reads-over-store.d.ts +24 -6
  124. package/dist/run-reads-over-store.js +67 -23
  125. package/dist/run-recordings.d.ts +5 -1
  126. package/dist/run-recordings.js +39 -14
  127. package/dist/run-timeline-served.d.ts +2 -0
  128. package/dist/run-timeline-served.js +2 -2
  129. package/dist/run-usage.d.ts +1 -0
  130. package/dist/runnable.d.ts +10 -1
  131. package/dist/runnable.js +20 -8
  132. package/dist/runner/adapter-loop.d.ts +11 -0
  133. package/dist/runner/adapter-loop.js +55 -10
  134. package/dist/runner/adapter-run-spec.d.ts +45 -8
  135. package/dist/runner/adapter-run-spec.js +150 -28
  136. package/dist/runner/adapters/pi.js +25 -3
  137. package/dist/runner/beside.js +4 -3
  138. package/dist/runner/big-writes.js +1 -10
  139. package/dist/runner/claim-secrets.d.ts +18 -3
  140. package/dist/runner/claim-secrets.js +35 -6
  141. package/dist/runner/cli-run-spec.d.ts +6 -0
  142. package/dist/runner/cli-run-spec.js +82 -35
  143. package/dist/runner/computer-journal.d.ts +9 -1
  144. package/dist/runner/computer-journal.js +26 -0
  145. package/dist/runner/conformance/harness.js +1 -1
  146. package/dist/runner/feedback-round.js +3 -0
  147. package/dist/runner/harness-loops.d.ts +6 -5
  148. package/dist/runner/harness-loops.js +7 -7
  149. package/dist/runner/held.d.ts +11 -5
  150. package/dist/runner/journal-kinds.d.ts +5 -0
  151. package/dist/runner/journal-kinds.js +5 -0
  152. package/dist/runner/main.js +7 -2
  153. package/dist/runner/mcp-claim.js +30 -3
  154. package/dist/runner/mcp-run.d.ts +12 -0
  155. package/dist/runner/mcp-run.js +12 -5
  156. package/dist/runner/model-route.d.ts +17 -0
  157. package/dist/runner/model-route.js +120 -2
  158. package/dist/runner/run-child-host.d.ts +3 -0
  159. package/dist/runner/run-child-host.js +69 -28
  160. package/dist/runner/run-child.js +5 -2
  161. package/dist/runner/runner.d.ts +14 -3
  162. package/dist/runner/runner.js +129 -33
  163. package/dist/runner/store-port.d.ts +1 -1
  164. package/dist/runner/store-secrets.d.ts +6 -0
  165. package/dist/runner/store-secrets.js +49 -7
  166. package/dist/runner/subagent.js +4 -40
  167. package/dist/runner/workflow-first.d.ts +11 -4
  168. package/dist/runner/workflow-first.js +14 -8
  169. package/dist/runner/workflow-spec.js +3 -2
  170. package/dist/runs-over-store.d.ts +15 -6
  171. package/dist/runs-over-store.js +33 -21
  172. package/dist/scrub-command.d.ts +73 -0
  173. package/dist/scrub-command.js +307 -0
  174. package/dist/secret-cut.d.ts +73 -0
  175. package/dist/secret-cut.js +291 -4
  176. package/dist/secret-rules.d.ts +143 -0
  177. package/dist/secret-rules.js +2564 -0
  178. package/dist/secrets.d.ts +7 -0
  179. package/dist/secrets.js +20 -0
  180. package/dist/server-keys.d.ts +20 -0
  181. package/dist/server-keys.js +25 -6
  182. package/dist/server.d.ts +52 -11
  183. package/dist/server.js +345 -118
  184. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  185. package/dist/store/index.d.ts +1 -1
  186. package/dist/store/index.js +1 -1
  187. package/dist/store/journal/storage.js +1 -1
  188. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  189. package/dist/store/schema.d.ts +6 -0
  190. package/dist/store/schema.js +11 -1
  191. package/dist/store/seal.d.ts +6 -1
  192. package/dist/store/seal.js +5 -3
  193. package/dist/store/sqlite/run-launch.d.ts +9 -1
  194. package/dist/store/sqlite/run-launch.js +24 -13
  195. package/dist/store/sqlite/run-patch.d.ts +1 -1
  196. package/dist/store/sqlite/run-patch.js +13 -4
  197. package/dist/store/sqlite/store.js +34 -4
  198. package/dist/store/store.d.ts +43 -2
  199. package/dist/store/store.js +20 -0
  200. package/dist/store-reads/learning.d.ts +6 -3
  201. package/dist/store-reads/learning.js +22 -7
  202. package/dist/store-view.d.ts +3 -0
  203. package/dist/store-view.js +3 -3
  204. package/dist/suggestions.js +3 -2
  205. package/dist/template-eval.d.ts +20 -9
  206. package/dist/template-eval.js +115 -33
  207. package/dist/template-import.d.ts +10 -0
  208. package/dist/template-import.js +16 -7
  209. package/dist/templates.d.ts +10 -2
  210. package/dist/templates.js +28 -8
  211. package/dist/timeline/labels.d.ts +6 -4
  212. package/dist/timeline/labels.js +18 -6
  213. package/dist/timeline/timeline.d.ts +5 -0
  214. package/dist/timeline/timeline.js +14 -8
  215. package/dist/timeline/util.js +1 -1
  216. package/dist/timeline/web-calls.d.ts +26 -9
  217. package/dist/timeline/web-calls.js +124 -37
  218. package/dist/tool-gate.d.ts +42 -3
  219. package/dist/tool-gate.js +66 -5
  220. package/dist/tool-keys-store.d.ts +2 -4
  221. package/dist/tool-keys-store.js +5 -21
  222. package/dist/tool-keys.d.ts +2 -2
  223. package/dist/tool-keys.js +2 -2
  224. package/dist/tool-list.js +1 -1
  225. package/dist/tool-plane.d.ts +2 -2
  226. package/dist/tool-plane.js +35 -33
  227. package/dist/tools.js +13 -7
  228. package/dist/trigger-targets.d.ts +4 -0
  229. package/dist/trigger-targets.js +9 -2
  230. package/dist/triggers.d.ts +67 -4
  231. package/dist/triggers.js +171 -22
  232. package/dist/until.d.ts +3 -0
  233. package/dist/until.js +11 -0
  234. package/dist/web-fake.d.ts +1 -3
  235. package/dist/web-fake.js +7 -18
  236. package/dist/web-fetch.d.ts +6 -72
  237. package/dist/web-fetch.js +11 -265
  238. package/dist/web-run.d.ts +31 -0
  239. package/dist/web-run.js +90 -0
  240. package/dist/web-save.d.ts +6 -4
  241. package/dist/web-save.js +9 -12
  242. package/dist/web-search.d.ts +9 -127
  243. package/dist/web-search.js +23 -259
  244. package/dist/wires.d.ts +13 -0
  245. package/dist/wires.js +11 -0
  246. package/dist/workflow-run.d.ts +5 -4
  247. package/dist/workflow-run.js +5 -4
  248. package/dist/workspace/computer-deps.d.ts +2 -1
  249. package/dist/workspace/computer-deps.js +9 -2
  250. package/dist/workspace/computer-for-claim.d.ts +12 -1
  251. package/dist/workspace/computer-for-claim.js +77 -8
  252. package/dist/workspace/computer-kept.d.ts +3 -0
  253. package/dist/workspace/computer-kept.js +11 -2
  254. package/dist/workspace/index.d.ts +1 -1
  255. package/dist/workspace/index.js +1 -1
  256. package/dist/workspace/kind-skills.d.ts +4 -0
  257. package/dist/workspace/kind-skills.js +9 -0
  258. package/dist/workspace/synced-folder.js +3 -4
  259. package/dist/wrapped.d.ts +13 -5
  260. package/dist/wrapped.js +52 -26
  261. package/package.json +17 -11
  262. package/skills/agentrun-serve/SKILL.md +4 -0
  263. package/templates/README.md +30 -8
  264. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  265. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  266. package/dist/exa-keyless.d.ts +0 -34
  267. package/dist/exa-keyless.js +0 -118
  268. package/dist/firecrawl-keyless.d.ts +0 -41
  269. package/dist/firecrawl-keyless.js +0 -152
  270. package/dist/keyless-mcp.d.ts +0 -36
  271. package/dist/keyless-mcp.js +0 -127
  272. package/dist/text-urls.d.ts +0 -38
  273. package/dist/text-urls.js +0 -170
  274. package/dist/web-fetch-direct.d.ts +0 -119
  275. package/dist/web-fetch-direct.js +0 -190
@@ -17,12 +17,13 @@ import { existsSync } from "node:fs";
17
17
  import { chmod, mkdir, rm } from "node:fs/promises";
18
18
  import { dirname, join } from "node:path";
19
19
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
20
- import { encode, SECRET_NAMES, SECRETS_FD_ENV, SECRETS_LEN_ENV, withoutSecrets } from "../secrets.js";
20
+ import { encode, OTEL_PAIR, SECRET_NAMES, SECRETS_FD_ENV, SECRETS_LEN_ENV, withoutSecrets } from "../secrets.js";
21
+ import { otelSettings } from "../otel/tracer.js";
21
22
  import { putLiveViewer, dropLiveViewer } from "../browser-live.js";
22
23
  import { CALENDAR_EVENTS } from "../calendar/names.js";
23
24
  import { openCalendar } from "../calendar/address.js";
24
25
  import { openAccount } from "../email/account.js";
25
- import { harnessOf, recipeHarness, recipeKeysOf } from "../harness-table.js";
26
+ import { harnessOf, planRecipeOf, recipeHarness } from "../harness-table.js";
26
27
  import { openHarnessKeys } from "../harness-keys.js";
27
28
  import { installDirOf, installForClaim, shareInstall } from "../harness-install.js";
28
29
  import { loadArchilSettings } from "../archil-settings.js";
@@ -34,7 +35,7 @@ import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
34
35
  import { learningEndOfRun } from "./learning-end.js";
35
36
  import { cutDeep, runnerSecrets } from "./redact.js";
36
37
  import { storeSecrets } from "./store-secrets.js";
37
- import { FAUX_ENV, GATEWAY_KEY_ENV } from "../model.js";
38
+ import { FAUX_ENV, FAUX_PROVIDER, GATEWAY_KEY_ENV } from "../model.js";
38
39
  import { SAVED_GATEWAY_ENV, savedGatewayIn } from "../model-gateway.js";
39
40
  import { FAUX_VENDOR_API_ENV } from "../tools.js";
40
41
  import { withinCarried } from "../paid-calls.js";
@@ -46,7 +47,7 @@ import { openRunWorkspace } from "../workspace/run-workspace.js";
46
47
  import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
47
48
  import { agentDirName, recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
48
49
  import { keptKeyOf } from "../workspace/computer-kept.js";
49
- import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, savedModelKeys, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
50
+ import { claimModelKey, claimSecrets, claimSpendOff, hostDecisionKeys, learnedDecisionKeys, openRunModelKey, routeModelKeys, savedModelKeys, serverKeyless, tierModelKeys, withoutModelKeys } from "./claim-secrets.js";
50
51
  import { githubAppAccess } from "./github-app.js";
51
52
  import { githubPullOf, githubTargetOf } from "../github.js";
52
53
  import { isObject } from "../validate.js";
@@ -59,8 +60,8 @@ import { withAudit } from "./audit.js";
59
60
  import { compareEndOfRun } from "./compare-end.js";
60
61
  import { learnedFirst } from "./learned-first.js";
61
62
  import { workflowsAt } from "./learning-seed.js";
62
- import { heldMcpOf, mcpForClaim } from "./mcp-run.js";
63
- import { learnedTiers, learnsWorkflows, mcpReachOf } from "./adapter-run-spec.js";
63
+ import { claimMetering, heldMcpOf, mcpForClaim } from "./mcp-run.js";
64
+ import { graderModelOf, learnedTiers, learnsWorkflows, mcpReachOf } from "./adapter-run-spec.js";
64
65
  import { createDispatchLoop } from "./dispatch.js";
65
66
  import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
66
67
  import { isWorkflowRevision } from "./workflow-loop.js";
@@ -622,6 +623,11 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
622
623
  /** Whether the claim's run holds a model key of its own now (its launch, as this runner opens it): its process is then
623
624
  * handed none of the server's (claim-secrets.ts keyedAtClaim, held here for the runner's answers). */
624
625
  const runKeyed = async () => (await openRunModelKey(keys, claim.runId)) !== undefined;
626
+ /** Whether the claim's run is held, its model kept from running at its create (hold.refused): it routes no model, so
627
+ * whatever its process asks, the runner hands it no model key, answers it keyless and refuses it a learning step (its
628
+ * learned workflows and its end-of-run step), as its spec asks for none of them (adapter-run-spec.ts, cli-run-spec.ts). */
629
+ const modelRefused = launch.hold?.refused !== undefined;
630
+ const refusedSpend = () => new ClaimRefused("a held run its model kept from running asks its runner for no model spend: it routes no model and takes no learning step");
625
631
  const learningFolder = async () => {
626
632
  const made = await archilOf();
627
633
  return made === undefined ? learningFolderOf(deps.data, run.agentId) : learningWorkspace({ mode: "archil", agentId: run.agentId, archil: made });
@@ -710,7 +716,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
710
716
  mcp: (ask) => projectCall(async () => {
711
717
  const reach = await mcpReachOf(deps);
712
718
  const harness = { commit: (change) => change({ appendEntry: async (_conversation, entry) => void (await ask.appendRoot(dataOnly(entry))) }) };
713
- const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, capped: launch.maxCostUsd !== undefined, media: { env: deps.env, web: deps.evalFakes?.(run.agentId)?.web, slots: deps.saveSlots } });
719
+ const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, run.agentId, launch) });
714
720
  if (!made)
715
721
  return undefined;
716
722
  releases.push(() => made.release());
@@ -745,16 +751,26 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
745
751
  savedModelKeys: async () => {
746
752
  // Only a run whose routes have no revision to scope their keys by: a subagent's tiers, a learning run's grade, an SDK
747
753
  // run's grade. And never for a run that holds a key of its own (its launch's, read now): the server's keys are not
748
- // its to spend, whatever its process asks.
749
- const reads = granted.includes(SUBAGENT_TOOL) || launch.harness === "learning" || launch.sdk !== undefined;
754
+ // its to spend, whatever its process asks; nor for a held run its model kept from running, which routes no model.
755
+ const reads = !modelRefused && (granted.includes(SUBAGENT_TOOL) || launch.harness === "learning" || launch.sdk !== undefined);
756
+ // A replay's or an audit's grade (adapter-run-spec.ts graderRouteOf): its fast model may be another provider's than
757
+ // its agent's, its key saved alone, which the claim's own keys never hold. Least privilege: the agent's tools run in
758
+ // this process tree, so only that one provider's saved keys (a gateway route's: the gateway's key alone) cross the
759
+ // pipe, filtered here, never the rest; none when the revision has no fast model, and none for a held run its model
760
+ // kept from running, which grades nothing.
761
+ const grades = !modelRefused && (launch.replay !== undefined || launch.audit !== undefined);
750
762
  const keyed = await runKeyed();
751
- return reads ? stringsOf(keyed ? {} : await savedModelKeys(keys)) : {};
763
+ if (!reads && !grades)
764
+ return {};
765
+ const saved = stringsOf(keyed ? {} : await savedModelKeys(keys));
766
+ return reads ? saved : stringsOf(routeModelKeys(saved, keys.env ?? {}, graderModelOf(revision.body, keys.env ?? {})));
752
767
  },
753
768
  tierModelKeys: async (tiers) => {
754
769
  // The tiers the claim's learned workflows name (learnedTiers), as this runner chose them (learnedFirst below): a
755
- // tier the process names beyond them gets no key, and none before the choice.
770
+ // tier the process names beyond them gets no key, and none before the choice (a held run its model kept from running
771
+ // makes none: its learnedFirst is refused).
756
772
  const asked = new Set(tiers.filter((tier) => typeof tier === "string"));
757
- const named = learnsWorkflows(revision.kind, learnedFlows) ? learnedTiers(learnedFlows).filter((tier) => asked.has(tier)) : [];
773
+ const named = !modelRefused && learnsWorkflows(revision.kind, learnedFlows) ? learnedTiers(learnedFlows).filter((tier) => asked.has(tier)) : [];
758
774
  const keyed = await runKeyed();
759
775
  const got = keyed ? {} : await tierModelKeys(keys, named);
760
776
  const plan = planOf(got);
@@ -768,15 +784,18 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
768
784
  },
769
785
  // The claim's own run's key alone (its launch, as the runner reads it), whatever run the process would name.
770
786
  runModelKey: () => openRunModelKey(keys, claim.runId),
771
- serverKeyless: () => serverKeyless(keys),
787
+ // A held run its model kept from running is answered keyless, no saved key read: none of its spend is the server's.
788
+ serverKeyless: async () => modelRefused || serverKeyless(keys),
772
789
  // The zone alone, from the claim's own launch's trigger: the process never reads a trigger's row.
773
790
  runZone: () => runZone(store, launch.inputOrigin),
774
791
  // The keys saved for the claim's own harness alone (harness-keys.ts), whatever the process names: none unless that
775
- // harness is a plan-billed recipe on this runner's table, and never another harness's.
776
- harnessKeys: async () => {
792
+ // harness is a plan-billed recipe on this runner's table, and never another harness's. Opened for the recipe file
793
+ // the process loaded (`digest`), never the one this runner's table read at its start: a file swapped for another
794
+ // vendor's under the same id since then runs its own binary, and a key bound to the first file never opens for it.
795
+ harnessKeys: async (digest) => {
777
796
  const harness = launch.harness ?? revision.body.harness;
778
- const names = harness === undefined ? undefined : recipeKeysOf(deps.env, harness);
779
- return harness !== undefined && names?.length ? openHarnessKeys(store, sealKey, harness, names) : {};
797
+ const recipe = harness === undefined ? undefined : planRecipeOf(deps.env, harness);
798
+ return recipe?.keys.length && typeof digest === "string" ? openHarnessKeys(store, sealKey, { ...recipe, digest }) : {};
780
799
  },
781
800
  liveViewerPut: (handover) => putLiveViewer(store, sealKey, claim, handover),
782
801
  liveViewerDrop: (tag) => dropLiveViewer(store, claim, tag),
@@ -816,6 +835,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
816
835
  ...deps.computerDeps, mode, workspace: ws.workspace, sealKey,
817
836
  recordings: { folder: recordingsFolder(deps.data, run.agentId, claim.runId), say: (words) => say?.(cut(words)) },
818
837
  hadComputer: async () => (await ask.hadComputer()) === true,
838
+ ...(typeof ask.turnedOff === "string" ? { turnedOff: ask.turnedOff } : {}),
819
839
  ...(ask.signal instanceof AbortSignal ? { signal: ask.signal } : {}),
820
840
  ...(made ? { revokeMount: () => made.revoke(), inheritMount: () => made.inherit() } : {}),
821
841
  ...(typeof ask.onImageWait === "function" ? { onImageWait: ask.onImageWait } : {}),
@@ -851,6 +871,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
851
871
  revoke: () => cleanProject(() => made.revoke()), inherit: () => projectCall(async () => made.inherit()), release: async () => { } };
852
872
  }),
853
873
  endOfRun: async (input) => {
874
+ // None for a held run its model kept from running: its spec builds no end-of-run step, and its runner reads no saved
875
+ // key and starts no audit for one, whatever its process asks.
876
+ if (modelRefused)
877
+ throw refusedSpend();
854
878
  // The step as the run's spec builds it in a runner (adapter-run-spec.ts), over the runner's reads of the claim: what
855
879
  // the run must never learn is every secret this runner holds, the keys its claim handed it, every secret the server
856
880
  // keeps sealed and its sign-in's pointers, none of which the run's process is given.
@@ -902,7 +926,8 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
902
926
  });
903
927
  return rows === undefined ? undefined : { also: dataOnly(rows.also ?? []) };
904
928
  },
905
- learnedFirst: (ask) => (chosen ??= (async () => {
929
+ // None for a held run its model kept from running: it settles no audit, starts no replay run and serves no workflow.
930
+ learnedFirst: (ask) => (modelRefused ? Promise.reject(refusedSpend()) : chosen ??= (async () => {
906
931
  // The workflows the claim's seed lays, read by this runner at the launch's seed (learning-seed.ts workflowsAt), as
907
932
  // the process's lay chose them: none where its lay laid none (`laid` false: a read that failed, a seed with no
908
933
  // workflows).
@@ -1071,6 +1096,12 @@ function withGatewayKey(claimed, key) {
1071
1096
  Object.defineProperty(out, GATEWAY_KEY_ENV, { value: key, enumerable: false, writable: false, configurable: false });
1072
1097
  return out;
1073
1098
  }
1099
+ /** The pair a run's process is handed this runner's OpenTelemetry settings in (secrets.ts OTEL_PAIR): none when it has
1100
+ * none. */
1101
+ export const otelPair = (env = process.env) => {
1102
+ const settings = otelSettings(env);
1103
+ return Object.keys(settings).length ? [[OTEL_PAIR, JSON.stringify(settings)]] : [];
1104
+ };
1074
1105
  /** The environment a run's process starts with: the runner's run environment's plain values (runEnv: its secrets are
1075
1106
  * not enumerable, so none is here), no key-shaped name, and where its keys come from. */
1076
1107
  function childEnv(base, keys, extra) {
@@ -1173,11 +1204,15 @@ function childLoop(options, slots, loopDeps) {
1173
1204
  throw new ClaimRefused("project_mode_fidelity: This runner rewrites local project file permissions for per-user isolation. A moved project needs a destination that preserves its original permissions.");
1174
1205
  }
1175
1206
  const savedGateway = savedGatewayIn(claimEnv);
1176
- // The run's own keys: those its claim opens (claim-secrets.ts), the one list its loop in this process read.
1207
+ // The run's own keys: those its claim opens (claim-secrets.ts), the one list its loop in this process read. Its model
1208
+ // keys are its pinned model's (claimSecrets scopes them by the launch's model), the one its route sends: never the
1209
+ // host's default's now, where its revision names no model and a key saved since moved that default.
1177
1210
  const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, launch, claim.runId);
1178
- // With them, its revision's own model's (a launch pinned at its start to another model, a --faux start's, is still
1179
- // handed its agent's model's key, as a run's own process was handed it before: run-secrets.ts secretsFor).
1180
- const ofRevision = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}) });
1211
+ // A --faux start alone is pinned to the faux model (model.ts chooseModel), which stands in for its revision's and
1212
+ // sends no key: its process is handed its revision's model's key with them, as a run of that model is handed it. A
1213
+ // held run its model kept from running at its create (hold.refused) is laid no model key here either: its model runs
1214
+ // nowhere.
1215
+ const ofRevision = launch.model?.provider === FAUX_PROVIDER ? await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}), ...(launch.hold ? { hold: launch.hold } : {}) }) : {};
1181
1216
  // A run that holds a model key of its own (model_key, its launch's) spends that key alone: its process is handed
1182
1217
  // none of the server's model keys, as its spec drops them from its tools' (claim-secrets.ts withoutModelKeys).
1183
1218
  // Copies: the runner's own reads (heldFor's `claimed`: what the run's learning must never keep) stay whole.
@@ -1185,13 +1220,19 @@ function childLoop(options, slots, loopDeps) {
1185
1220
  const toProcess = keyed ? [withoutModelKeys({ ...claimed }), withoutModelKeys({ ...ofRevision })] : [claimed, ofRevision];
1186
1221
  // The saved gateway's key, kept off the claim's tool keys (claimSecrets), is handed for the run's model routes alone,
1187
1222
  // read as the server's model keys are (savedModelKeys, over the claim's environment the gateway was laid over), as a
1188
- // run in this process reads it from its environment by name; none to a run that brings its own key.
1189
- const gatewayKey = savedGateway ? (keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }))[GATEWAY_KEY_ENV] || undefined : undefined;
1223
+ // run in this process reads it from its environment by name; none to a run that brings its own key, and none to a
1224
+ // held run its model kept from running, which routes no model.
1225
+ const gatewayKey = savedGateway && !launch.hold?.refused ? (keyed ? {} : await savedModelKeys({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }))[GATEWAY_KEY_ENV] || undefined : undefined;
1190
1226
  const handed = (name) => (name === GATEWAY_KEY_ENV && savedGateway ? gatewayKey : toProcess.map((from) => from[name]).find((value) => typeof value === "string" && value !== ""));
1191
- const keys = encode(SECRET_NAMES.flatMap((name) => {
1192
- const value = handed(name);
1193
- return value === undefined ? [] : [[name, value]];
1194
- }));
1227
+ const keys = encode([
1228
+ ...SECRET_NAMES.flatMap((name) => {
1229
+ const value = handed(name);
1230
+ return value === undefined ? [] : [[name, value]];
1231
+ }),
1232
+ // The runner's OpenTelemetry settings, so the run's process exports its trace as this one would: on the pipe,
1233
+ // since no run's environment has them (runEnv), never in the process's environment.
1234
+ ...otelPair(),
1235
+ ]);
1195
1236
  const slot = await slots?.take();
1196
1237
  if (slots && slot === undefined) {
1197
1238
  // Every free slot of this runner is held by another runner on the data directory (ranges that overlap): the run
@@ -20,14 +20,16 @@ import { remoteSaveSlots } from "./save-slots.js";
20
20
  import { runEnv } from "./main.js";
21
21
  import { carriedLedger } from "../paid-calls.js";
22
22
  import { heldHands } from "../workspace/computer-hold.js";
23
+ import { flushTraces } from "../otel/tracer.js";
23
24
  /** How often the run's process reads its loop's held state (LoopDeps.live) and posts it to its runner when it moved: the
24
25
  * runner's live ticker reads the newest it was posted. */
25
26
  const LIVE_POLL_MS = 200;
26
27
  registerRunErrors();
27
28
  const socket = new Socket({ fd: 4, readable: true, writable: true });
28
29
  const channel = new Channel(socket, {
29
- // The runner closed the channel (the loop's end answered) or is gone: nothing of the run's goes on.
30
- onClose: () => void setImmediate(() => process.exit(0)),
30
+ // The runner closed the channel (the loop's end answered) or is gone: nothing of the run's goes on, but its trace's last
31
+ // spans are sent first (flushTraces: at most FLUSH_MS, at once when tracing is off).
32
+ onClose: () => void setImmediate(() => void flushTraces().finally(() => process.exit(0))),
31
33
  // Each call carries the ledger of the tool call it is made in: what the runner does for it (an MCP tool's call, a
32
34
  // computer's) books on the run's one ledger, as it would in the run's own process.
33
35
  context: carriedLedger,
@@ -160,6 +162,7 @@ function childDeps(init, store, journal, held) {
160
162
  const recordings = given.recordings;
161
163
  const ask = {
162
164
  hadComputer: given.hadComputer,
165
+ ...(typeof given.turnedOff === "string" ? { turnedOff: given.turnedOff } : {}),
163
166
  ...(given.signal instanceof AbortSignal ? { signal: given.signal } : {}),
164
167
  ...(recordings?.say ? { say: recordings.say } : {}),
165
168
  ...(typeof given.onImageWait === "function" ? { onImageWait: given.onImageWait } : {}),
@@ -1,6 +1,6 @@
1
1
  import { type Claim, type LoopEnd, type LoopFactory } from "./loop-contract.js";
2
2
  import { type RunnerStore } from "./store-port.js";
3
- import { type RunState } from "../store/store.js";
3
+ import { type RunPatch, type RunState } from "../store/store.js";
4
4
  import { type Redact } from "./redact.js";
5
5
  import { type LiveTickerOptions } from "./live-ticker.js";
6
6
  import { type Presence } from "./presence.js";
@@ -34,6 +34,9 @@ export declare const END_RETRY_BACKOFF_MS = 5000;
34
34
  export declare const END_RETRY_CAP_MS = 300000;
35
35
  /** The tries at that cap before the run ends stopped on its row alone (about an hour of retries in all; endRefused). */
36
36
  export declare const END_RETRY_AT_CAP = 11;
37
+ /** The most a run's end waits for its census (RunnerOptions.census): 60 s, for up to CENSUS_BYTES_MAX (64 MiB) read
38
+ * over the run's Workspace (an Archil disk's included). Past it the end goes on without one. */
39
+ export declare const CENSUS_MS = 60000;
37
40
  export interface RunnerOptions {
38
41
  store: RunnerStore;
39
42
  createLoop: LoopFactory;
@@ -82,6 +85,14 @@ export interface RunnerOptions {
82
85
  * runs behind it wait too and a heavy run is never passed over for ever by light ones. A run heavier than the whole
83
86
  * budget is claimed when the runner holds nothing, so it never waits for ever. Absent: by count alone (`loops`). */
84
87
  memory?: RunnerMemory;
88
+ /** The census a run's end writes in the place of the secrets its caller handed it, which that end erases
89
+ * (run-census.ts; RunPatch.census): made just before each final patch this runner writes, while the run's launch
90
+ * still holds them, and undefined for a run that holds none. One not made within censusMs, or that fails, is left
91
+ * out, said as an error event (step "census", the run's id and why): the end then writes the marker "unscanned", and
92
+ * the run's files are withheld from a cut read after it. Absent: no census (every such end writes the marker). */
93
+ census?: (runId: string) => Promise<RunPatch["census"] | undefined>;
94
+ /** The most a run's end waits for its census. Default CENSUS_MS. */
95
+ censusMs?: number;
85
96
  /** A refused stopped end that withdraws a call (endRefused): the first wait, its cap, and the tries at the cap before
86
97
  * the run ends on its row alone. Defaults END_RETRY_BACKOFF_MS, END_RETRY_CAP_MS, END_RETRY_AT_CAP. */
87
98
  endRetryBackoffMs?: number;
@@ -92,8 +103,8 @@ export interface RunnerOptions {
92
103
  * it: what the run's earlier claims left is let go (workspace/run-end-computers.ts, their computers). A throw is said
93
104
  * as an error; the run's end stands. Absent: nothing. */
94
105
  runEnded?: (claim: Claim) => Promise<void>;
95
- /** The runner's clock (epoch ms) for what it writes itself: a withdrawn answer's time in an end it writes. Default
96
- * Date.now. */
106
+ /** The runner's clock (epoch ms) for what it writes itself: a withdrawn answer's time in an end it writes, and every
107
+ * backoff it releases a run with (the store reads them on its own clock, the same one). Default Date.now. */
97
108
  now?: () => number;
98
109
  /** The one redactor (redact.ts secretRedactor over the secrets the runner holds): every error text this runner writes
99
110
  * to a run's row or end, or emits, passes through it, and each loop gets it (LoopDeps.redact). Default: the one over every secret this process's environment holds (runnerSecrets), so a runner