@parcha/agentrun-serve 0.1.0-beta.60 → 0.1.0-beta.62

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 (179) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +139 -22
  3. package/dist/acp-package.d.ts +4 -0
  4. package/dist/api-only.d.ts +23 -1
  5. package/dist/api-only.js +43 -4
  6. package/dist/archil-settings.d.ts +9 -0
  7. package/dist/archil-settings.js +8 -1
  8. package/dist/bash-read-only.d.ts +3 -0
  9. package/dist/bash-read-only.js +6 -3
  10. package/dist/browser-person.d.ts +1 -1
  11. package/dist/browser-person.js +1 -1
  12. package/dist/calendar/tools.js +1 -1
  13. package/dist/chatgpt-plan.d.ts +26 -8
  14. package/dist/chatgpt-plan.js +89 -21
  15. package/dist/claude-login.d.ts +12 -5
  16. package/dist/claude-login.js +28 -3
  17. package/dist/cli.js +61 -18
  18. package/dist/composio-triggers.d.ts +9 -3
  19. package/dist/computers.d.ts +3 -0
  20. package/dist/computers.js +2 -1
  21. package/dist/console/assets/{backend-QnwGVBeU.js → backend-DEgVn5lC.js} +1 -1
  22. package/dist/console/assets/index-CG5tELph.js +639 -0
  23. package/dist/console/assets/share-CIeFK2Oe.js +6 -0
  24. package/dist/console/assets/{styles-CcceGcu2.js → styles-BGZxYkky.js} +2 -2
  25. package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
  26. package/dist/console/index.html +3 -3
  27. package/dist/console/share.html +3 -3
  28. package/dist/cut-pool.d.ts +14 -0
  29. package/dist/cut-pool.js +98 -0
  30. package/dist/cut-worker.d.ts +14 -0
  31. package/dist/cut-worker.js +16 -0
  32. package/dist/decisions.d.ts +4 -0
  33. package/dist/decisions.js +9 -1
  34. package/dist/env-switch.d.ts +3 -0
  35. package/dist/env-switch.js +3 -0
  36. package/dist/errors.d.ts +1 -0
  37. package/dist/errors.js +2 -0
  38. package/dist/harness-check.js +2 -1
  39. package/dist/harness-recipe.d.ts +13 -2
  40. package/dist/harness-recipe.js +30 -7
  41. package/dist/harness-sign-in.js +2 -1
  42. package/dist/harness-table.d.ts +12 -3
  43. package/dist/harness-table.js +13 -8
  44. package/dist/import.d.ts +8 -1
  45. package/dist/import.js +36 -5
  46. package/dist/key-check.js +22 -8
  47. package/dist/key-refusal.js +6 -4
  48. package/dist/learn/secrets.d.ts +2 -1
  49. package/dist/learn/secrets.js +2 -2
  50. package/dist/learned-nodes.d.ts +37 -0
  51. package/dist/learned-nodes.js +24 -0
  52. package/dist/local-model.d.ts +144 -0
  53. package/dist/local-model.js +214 -0
  54. package/dist/mcp-gateway.d.ts +24 -0
  55. package/dist/mcp-gateway.js +97 -8
  56. package/dist/mcp-probe.d.ts +7 -0
  57. package/dist/mcp-probe.js +7 -0
  58. package/dist/mcp-servers-store.d.ts +7 -10
  59. package/dist/mcp-servers-store.js +15 -9
  60. package/dist/native/cli.js +5 -1
  61. package/dist/ollama-provider.d.ts +42 -0
  62. package/dist/ollama-provider.js +118 -2
  63. package/dist/openapi.js +85 -16
  64. package/dist/otel/tracer.d.ts +6 -3
  65. package/dist/otel/tracer.js +24 -6
  66. package/dist/page.d.ts +7 -0
  67. package/dist/page.js +17 -4
  68. package/dist/place.d.ts +28 -11
  69. package/dist/place.js +43 -14
  70. package/dist/print.d.ts +3 -2
  71. package/dist/print.js +8 -6
  72. package/dist/redact/match.d.ts +17 -4
  73. package/dist/redact/match.js +57 -15
  74. package/dist/run-export.js +4 -2
  75. package/dist/run-launch.js +16 -3
  76. package/dist/run-model-key.d.ts +2 -1
  77. package/dist/run-model-key.js +2 -1
  78. package/dist/run-reads-over-store.d.ts +7 -0
  79. package/dist/run-reads-over-store.js +32 -4
  80. package/dist/run-usage.js +3 -2
  81. package/dist/runnable.d.ts +6 -3
  82. package/dist/runnable.js +16 -6
  83. package/dist/runner/adapter-loop.d.ts +8 -1
  84. package/dist/runner/adapter-loop.js +148 -29
  85. package/dist/runner/adapter-run-spec.d.ts +9 -6
  86. package/dist/runner/adapter-run-spec.js +38 -52
  87. package/dist/runner/adapters/index.d.ts +4 -0
  88. package/dist/runner/adapters/index.js +2 -1
  89. package/dist/runner/adapters/pi.d.ts +3 -2
  90. package/dist/runner/adapters/pi.js +3 -1
  91. package/dist/runner/audit.d.ts +1 -1
  92. package/dist/runner/claim-secrets.d.ts +3 -1
  93. package/dist/runner/claim-secrets.js +18 -7
  94. package/dist/runner/cli-run-spec.js +24 -17
  95. package/dist/runner/compare-end.d.ts +1 -1
  96. package/dist/runner/dispatch.js +4 -2
  97. package/dist/runner/harness-loops.d.ts +14 -0
  98. package/dist/runner/harness-loops.js +51 -5
  99. package/dist/runner/held.d.ts +4 -1
  100. package/dist/runner/live-ticker.js +5 -4
  101. package/dist/runner/loop-contract.d.ts +4 -1
  102. package/dist/runner/mcp-claim.js +3 -2
  103. package/dist/runner/mcp-run.d.ts +24 -4
  104. package/dist/runner/mcp-run.js +47 -2
  105. package/dist/runner/meta-tools.js +4 -4
  106. package/dist/runner/metrics.d.ts +6 -0
  107. package/dist/runner/metrics.js +12 -4
  108. package/dist/runner/monid-run.js +3 -1
  109. package/dist/runner/native-loop.js +3 -3
  110. package/dist/runner/redact.d.ts +3 -0
  111. package/dist/runner/redact.js +7 -0
  112. package/dist/runner/run-child-host.d.ts +10 -6
  113. package/dist/runner/run-child-host.js +44 -29
  114. package/dist/runner/run-child.js +1 -0
  115. package/dist/runner/runner.js +2 -0
  116. package/dist/runner/sdk-loop.js +5 -3
  117. package/dist/runner/workflow-calls.d.ts +5 -1
  118. package/dist/runner/workflow-calls.js +65 -19
  119. package/dist/runner/workflow-loop.d.ts +1 -1
  120. package/dist/runner/workflow-loop.js +3 -1
  121. package/dist/runner/workflow-spec.d.ts +4 -0
  122. package/dist/runner/workflow-spec.js +18 -13
  123. package/dist/runs-over-store.d.ts +2 -2
  124. package/dist/runs-over-store.js +1 -1
  125. package/dist/secret-cut.js +7 -4
  126. package/dist/secret-rules.d.ts +0 -1
  127. package/dist/secret-rules.js +122 -88
  128. package/dist/server.d.ts +17 -1
  129. package/dist/server.js +208 -69
  130. package/dist/share-host.d.ts +111 -0
  131. package/dist/share-host.js +666 -0
  132. package/dist/slack.js +2 -1
  133. package/dist/store/postgres/migrate.js +3 -1
  134. package/dist/store-reads/analytics.d.ts +15 -0
  135. package/dist/store-reads/analytics.js +17 -0
  136. package/dist/store-reads/learning.d.ts +5 -4
  137. package/dist/store-reads/learning.js +7 -4
  138. package/dist/suggestions.js +32 -3
  139. package/dist/templates.d.ts +3 -1
  140. package/dist/templates.js +7 -3
  141. package/dist/tool-gate.d.ts +25 -9
  142. package/dist/tool-gate.js +58 -19
  143. package/dist/tool-plane.d.ts +24 -1
  144. package/dist/tool-plane.js +75 -3
  145. package/dist/tools.d.ts +12 -2
  146. package/dist/tools.js +42 -7
  147. package/dist/trigger-composio.js +1 -1
  148. package/dist/trigger-launch-hook.d.ts +2 -2
  149. package/dist/trigger-launch-hook.js +1 -1
  150. package/dist/triggers.d.ts +7 -4
  151. package/dist/triggers.js +4 -4
  152. package/dist/webhooks.d.ts +3 -0
  153. package/dist/webhooks.js +5 -0
  154. package/dist/workspace/archil-claim.d.ts +7 -3
  155. package/dist/workspace/archil-claim.js +13 -5
  156. package/dist/workspace/archil-mount-credential.d.ts +6 -0
  157. package/dist/workspace/archil-mount-credential.js +11 -0
  158. package/dist/workspace/computer-deps.d.ts +5 -3
  159. package/dist/workspace/computer-deps.js +11 -9
  160. package/dist/workspace/computer-for-claim.d.ts +6 -2
  161. package/dist/workspace/computer-for-claim.js +43 -12
  162. package/dist/workspace/computer-janitor.d.ts +7 -4
  163. package/dist/workspace/computer-janitor.js +7 -4
  164. package/dist/workspace/computer-kept.d.ts +7 -1
  165. package/dist/workspace/computer-kept.js +7 -1
  166. package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
  167. package/dist/workspace/mount-revoke-left.d.ts +16 -4
  168. package/dist/workspace/mount-revoke-left.js +42 -22
  169. package/dist/workspace/resolve-computer.d.ts +11 -5
  170. package/dist/workspace/resolve-computer.js +22 -13
  171. package/dist/workspace/run-end-computers.js +1 -1
  172. package/dist/workspace/run-tools.d.ts +10 -3
  173. package/dist/workspace/run-tools.js +5 -4
  174. package/dist/wrapped.d.ts +29 -2
  175. package/dist/wrapped.js +20 -3
  176. package/launcher/agentrun-serve +1 -1
  177. package/package.json +12 -12
  178. package/dist/console/assets/index-DZi-muIj.js +0 -629
  179. package/dist/console/assets/share-pz61zIn9.js +0 -6
@@ -28,11 +28,9 @@ import { isWebHostTool } from "../tool-list.js";
28
28
  import { deniedText, noApproverText, runGate } from "../tool-gate.js";
29
29
  import { DECISION_PROVIDER_KEYS, loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
30
30
  import { readApprovers } from "../server-approvers.js";
31
- import { ASK_TOOL, askPerson, toolOf } from "../tools.js";
31
+ import { ASK_TOOL, askPerson, toolOf, webAnswerCut } from "../tools.js";
32
32
  import { hostToolOf } from "../host-tools.js";
33
33
  import { WEB_SEARCH_TOOL } from "../web-search.js";
34
- import { webCut } from "../timeline/web-calls.js";
35
- import { withheldWhole } from "../key-refusal.js";
36
34
  import { environmentLine, runZone } from "../environment.js";
37
35
  import { effortGuidance } from "../effort-guidance.js";
38
36
  import { outputContract } from "../answer-json.js";
@@ -67,16 +65,16 @@ import { journalEntries } from "./journal-reader.js";
67
65
  import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
68
66
  import { replayCallsOver } from "./promotion.js";
69
67
  import { learnedFirstWhereHeld } from "./learned-first.js";
70
- import { servedOf } from "./workflow-first.js";
68
+ import { servedOf, workflowDigest } from "./workflow-first.js";
71
69
  import { AUDIT_PARKED, withAudit } from "./audit.js";
72
70
  import { runPathMetricsOverStore } from "../store-reads/learning.js";
73
71
  import { specBuilt } from "./spec-holds.js";
74
72
  import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
75
- import { loadArchilSettings } from "../archil-settings.js";
73
+ import { loadArchilSettings, noExecRegionOf } from "../archil-settings.js";
76
74
  import { settingOfDefinition } from "../computer-setting.js";
77
75
  import { computerFilesNote, computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
78
76
  import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
79
- import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
77
+ import { holdClaimed, mustHold, runnerSecrets } from "./redact.js";
80
78
  import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
81
79
  import { heldSpecOf } from "./held-run.js";
82
80
  import { loopComputerOf } from "./computer-channel.js";
@@ -333,11 +331,18 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
333
331
  return refused(noApproverText(asks[0].tool, "no"));
334
332
  return asks.length ? { ask: learnedAskShown(asks) } : decision;
335
333
  };
334
+ /** The learned workflow of the run's a learned_workflow call's arguments name, if any. */
335
+ const flowOf = (args) => learned.find((one) => one.name === args?.name);
336
336
  /** The MCP actions the learned workflow a learned_workflow call names can call; none for another call or workflow. */
337
337
  const mcpOf = async (args) => {
338
- const flow = learned.find((one) => one.name === args?.name);
338
+ const flow = flowOf(args);
339
339
  return flow ? learnedMcpCalls(flow.workflow) : [];
340
340
  };
341
+ /** That workflow's name and digest (SpecGate.learnedOf): what the record of a call of it the gate refuses names. */
342
+ const learnedOf = (args) => {
343
+ const flow = flowOf(args);
344
+ return flow ? { workflow: flow.name, digest: workflowDigest(flow) } : undefined;
345
+ };
341
346
  // An ask is named as main's pending approval is (RunGate.askedAs: its settings key), beside the decision, which is
342
347
  // unchanged. The permissions are the learned workflow's (main's toolGate.policy and denyFrom), over the same settings.
343
348
  const permissions = { policy: (tool) => gate.policy(tool), denyFrom: (tool) => gate.denyFrom(tool), refresh: async () => { current = await storeSettings(store); } };
@@ -348,7 +353,7 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
348
353
  current = await storeSettings(store);
349
354
  return current.unreadable ? "deny" : gate.policy(tool);
350
355
  };
351
- return Object.assign(decide, { askedAs: (tool, args) => gate.askedAs(tool, args), permissions, permission, learn: (flows) => void (learned = flows), askedOn: (made) => void (host = made), computerOff: () => gate.computerOff !== undefined, writes: () => gate.writeBar() === undefined });
356
+ return Object.assign(decide, { askedAs: (tool, args) => gate.askedAs(tool, args), permissions, permission, learnedOf, learn: (flows) => void (learned = flows), askedOn: (made) => void (host = made), computerOff: () => gate.computerOff !== undefined, writes: () => gate.writeBar() === undefined, opsRefused: () => gate.opsRefused() });
352
357
  }
353
358
  /** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
354
359
  * and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
@@ -368,13 +373,14 @@ export function adapterRunSpecFromLaunch(launch, run, deps, claim, runner = RUNN
368
373
  return specBuilt((holds) => adapterSpec(launch, run, deps, claim, holds, runner));
369
374
  }
370
375
  async function adapterSpec(launch, run, deps, claim, holds, runner) {
376
+ mustHold(run.redact, "A pi run's spec");
371
377
  const context = BACKGROUND_CONTEXT;
372
378
  // What this claim may reach on loopback, read once for its MCP servers and its calendar_events alike (mcpReachOf).
373
379
  const reach = await mcpReachOf(deps);
374
380
  // The runner's one redactor (the loop's, LoopDeps.redact), for every text a secret could reach: the spec's log lines
375
- // (a release, a workspace's end), the model route's translation and the session's model proxy. A spec built with no
376
- // runner around it cuts every secret the runner's env holds. It holds the keys the claim opens (below), too.
377
- const cut = heldRedactor(run.redact ?? secretRedactor(runnerSecrets(deps.env)));
381
+ // (a release, a workspace's end), the model route's translation and the session's model proxy. It holds the keys the
382
+ // claim opens (below), too.
383
+ const cut = run.redact;
378
384
  const log = (line) => (deps.log ?? (() => { }))(cut(line));
379
385
  holds.logTo(log);
380
386
  const runRow = await deps.store.runs.get(claim.runId);
@@ -396,6 +402,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
396
402
  // claim's memory only); else Mode 1, the run's local folder. The same for the pi and the CLI spec.
397
403
  const archilSettings = await loadArchilSettings(deps.store, deps.env);
398
404
  const mode = archilSettings === undefined ? 1 : 2;
405
+ // Its region with no serverless exec, where it has none: a run with no computer that mounts its folder has no shell.
406
+ const noExec = noExecRegionOf(archilSettings);
399
407
  const archil = archilSettings === undefined
400
408
  ? undefined
401
409
  // The run's mount credential is minted per run the first time a computer's mount asks (archil-mount-credential.ts), on
@@ -455,7 +463,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
455
463
  // credentials opened under the server's seal key into this claim's memory, one gateway for the claim. First, before
456
464
  // anything the spec would have to let go: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its
457
465
  // words before the session opens. The seal key is the runner's own (deps.sealKey), not re-read from the environment.
458
- // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor.
466
+ // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactor. A
467
+ // per_run server the run was handed no credential for is left out of its tools, and its timeline says so.
459
468
  // A held run its model kept from running at its create (hold.refused) opens none: nothing can call one.
460
469
  const heldRefusal = launch.hold?.refused?.message;
461
470
  // What its gateway files (a long answer, a server's results) goes in the run's own files. In Mode 1 that is the run's
@@ -466,7 +475,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
466
475
  // and a call reaches it only through the session this spec returns, after `tools` is made.
467
476
  let filedIn;
468
477
  const hold = (values) => cut.hold(values);
469
- const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, fakes?.web, launch) });
478
+ const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), launchInput: launch.input, hold, redact: cut, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, say: (words) => run.phase?.(words), ...claimMetering(deps, fakes?.web, launch) });
470
479
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
471
480
  holds.hold({ passed: mcp });
472
481
  // The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
@@ -490,7 +499,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
490
499
  // row names the disk that credential is on (mountDisk), asked only at the park: a run's own process hands its claim to
491
500
  // its runner, whose computerForClaim asks its own Archil claim. A recording of its screen (computer.record) goes in
492
501
  // the run's recordings folder, beside its folder, said on its timeline.
493
- { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, ...(offAlready ? { turnedOff: offAlready } : {}), recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit(), mountDisk: () => archil.disk.id } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
502
+ { ...deps.computerDeps, mode, noExec, workspace: ws.workspace, sealKey: deps.sealKey, ...(offAlready ? { turnedOff: offAlready } : {}), recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit(), mountDisk: () => archil.disk.id } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
494
503
  // The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
495
504
  // (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
496
505
  // A desktop's or a phone's hold (the person's take-over) wraps its ports: a call made while the person holds it waits,
@@ -503,7 +512,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
503
512
  // The computer's tools are the run's own host tools, as on every harness: the host's codemode (meta-tools.ts) calls them
504
513
  // as `tools.<name>`, each a nested call, gated and recorded as the model's own call is. A computer that replaced an
505
514
  // earlier claim's holds its acts to what it showed.
506
- const tools = await runTools(ws.workspace, computer.computer, { mode, context, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
515
+ const tools = await runTools(ws.workspace, computer.computer, { mode, noExec, context, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
507
516
  filedIn = tools.workspace;
508
517
  let remoteProjectCapture = false;
509
518
  holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
@@ -573,8 +582,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
573
582
  // The run's adapter is its runner's (runner/adapters/index.ts RunnerHarness: pi's, or the one a harness module's entry
574
583
  // brings), made from the run's launch on its route. Its private files, where it keeps any, go in this claim's folder of
575
584
  // the run's scratch (the CLI spec's layout), swept at the claim's end with the earlier claims' and any parent left empty.
576
- // pi's own options (its extensions, tools, redactor, the model's catalog entry, hosted search, tiers, and the route's
577
- // whole provider) are the harness's own options (`extra`), passed on as given.
585
+ // The run's one redactor is the launch's (HarnessLaunch.redact). pi's own options (its extensions, tools, the model's
586
+ // catalog entry, hosted search, tiers, and the route's whole provider) are the harness's own (`extra`), passed on as given.
578
587
  const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
579
588
  const harnesses = join(scratch, "harness");
580
589
  holds.hold({ scratch: { sweep: async () => (await import("./cli-run-spec.js")).sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
@@ -585,12 +594,12 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
585
594
  ...(route.price ? { price: route.price } : {}),
586
595
  sessionsDir: join(harnesses, String(claim.epoch)),
587
596
  ...(route.fetch ? { fetch: route.fetch } : {}),
597
+ redact: cut,
588
598
  }, {
589
599
  // Read when the session opens (pi.ts), so the browser's extension pushed by bindNonHandTools below is in it.
590
600
  extensions: native,
591
601
  tools: piTools,
592
602
  provider: route.provider,
593
- redact: cut,
594
603
  ...(route.like ? { like: route.like } : {}),
595
604
  // The run's web_search is its provider's hosted search (the launch's plane, as its start resolved it): the session's
596
605
  // proxy admits that search's one request (it goes through the session's port: buildToolHost's `search`) and books it
@@ -725,7 +734,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
725
734
  // The run's tools. The hands (read/write/edit/bash and the background tools) are the kernel registry's over the run's
726
735
  // Workspace and computer (runTools.hostTools); the gate is the adapter loop's own (spec.gate), so they run as asked.
727
736
  const results = new Map();
728
- const handTools = tools.hostTools(withKindTools(granted, tools), { results, writes: gate.writes() });
737
+ const handTools = tools.hostTools(withKindTools(granted, tools), { results, writes: gate.writes(), opsRefused: gate.opsRefused() });
729
738
  // The non-hand tools run on the claim's keys (host.env), so a vendor's error may echo one: each answer, and a throw's
730
739
  // words, pass the run's one redactor before the harness, the model or the record has them.
731
740
  const tiers = new Map([...[...tierRoutes].filter(([tier]) => !isSubagentRoute(tier) && tier !== GRADER).map(([tier, { model }]) => [tier, { model }]), ...[...tierUnreachable].map(([tier, why]) => [tier, { why }])]);
@@ -803,7 +812,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
803
812
  // A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
804
813
  // withAudit): at its end, so the shadow's cap is what the run's own left.
805
814
  // A held run (no audits) takes none, and its runner refuses one too (run-child-host.ts heldFor).
806
- const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, ...(run.redact ? { redact: run.redact } : {}) }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
815
+ const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, redact: run.redact }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
807
816
  store: deps.store,
808
817
  data: deps.data,
809
818
  ...(deps.env ? { env: deps.env } : {}),
@@ -816,7 +825,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
816
825
  log,
817
826
  // A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
818
827
  decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
819
- }), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
828
+ }), { ...audits, launch, redact: run.redact });
820
829
  return {
821
830
  adapter,
822
831
  facts,
@@ -860,8 +869,9 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
860
869
  // The run's computer as the claim made it, with the person's hold on a desktop or phone: the loop shows the hold up,
861
870
  // applies a take-over and a hand-back to it, and answers the computer call channel's rows on it.
862
871
  ...(loopComputer ? { computer: loopComputer } : {}),
863
- // A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools.
864
- ...(tools.computer ? { scriptComputer: tools.computer } : {}),
872
+ // A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools, its
873
+ // declarations without the ops the gate refuses whatever their arguments.
874
+ ...(tools.computer ? { scriptComputer: { ...tools.computer, opsRefused: gate.opsRefused() } } : {}),
865
875
  // A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
866
876
  ...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
867
877
  // A desktop or a phone that holds none of the run's files: the model is told once in the run where they are, or, where
@@ -884,7 +894,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
884
894
  // The path it took, the learned revision it ran on, its learned workflow calls and why its first choice served or
885
895
  // did not, for a run that learns (workflow-first.ts pathMetrics), by the one writer every harness's end calls
886
896
  // (runPathMetricsOverStore).
887
- const path = await runPathMetricsOverStore(deps.store, claim.runId, launch, { ...(run.redact ? { redact: run.redact } : {}), choice: firstChoice.reason });
897
+ const path = await runPathMetricsOverStore(deps.store, claim.runId, launch, { redact: run.redact, choice: firstChoice.reason });
888
898
  // A run its learned workflow served first: that call is on the loop's record (no pi answer carries its tokens), so its
889
899
  // metrics are its booking's, as a CLI harness's run reads them: the workflow's nodes and the agent's own after a handback.
890
900
  // An MCP tool called by a hashed wire name is counted under its catalog name, as its timeline names it.
@@ -1058,29 +1068,16 @@ export function liveViewersOf(store, sealKey, claim, cut) {
1058
1068
  };
1059
1069
  }
1060
1070
  /** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
1061
- * string by string inside its JSON (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
1062
- * its links whole for a grader's link check; one whose strings, read joined, hold a held value no cut in place takes (a
1063
- * value split across two of them) is "[redacted]" (webHeld). The join is read against the values `cut` holds
1064
- * (key-refusal.ts withheldWhole), or through `cut` itself when it does not know them (joinCut). Each string is cut once
1065
- * in a call, for the join's read and the answer both. */
1071
+ * string by string inside its JSON (tools.ts webAnswerCut), so what the harness stores still parses and keeps its links
1072
+ * whole for a grader's link check; one whose strings, read joined, hold a held value split across two of them is
1073
+ * "[redacted]". */
1066
1074
  export function answersCut(tool, cut) {
1067
1075
  return {
1068
1076
  ...tool,
1069
1077
  call: async (args, context) => {
1070
1078
  try {
1071
1079
  const answer = await tool.call(args, context);
1072
- const seen = new Map();
1073
- const once = (text) => {
1074
- let out = seen.get(text);
1075
- if (out === undefined)
1076
- seen.set(text, (out = cut(text)));
1077
- return out;
1078
- };
1079
- const holds = (joined, parts) => {
1080
- const values = cut.heldValues?.();
1081
- return values ? withheldWhole(joined, values) : joinCut(joined, parts, once);
1082
- };
1083
- return { ...answer, text: webCut(tool.name, answer.text, once, holds) ?? cut(answer.text) };
1080
+ return { ...answer, text: webAnswerCut(cut)(tool.name, answer.text) ?? cut(answer.text) };
1084
1081
  }
1085
1082
  catch (error) {
1086
1083
  if (error instanceof Error) {
@@ -1094,17 +1091,6 @@ export function answersCut(tool, cut) {
1094
1091
  },
1095
1092
  };
1096
1093
  }
1097
- /** Whether `cut`, a redactor that does not know its values, takes from `joined` (`parts` joined by line breaks) what it
1098
- * does not take from the parts each read alone: a held value split across two parts. Its cut of the join whole being
1099
- * "[redacted]" is not enough: it reads a text longer than a piece in pieces of 8,192 characters (key-refusal.ts
1100
- * redactedAnswer), and a value split inside one piece withholds only that piece, the rest of the join served. It misses
1101
- * nothing: no value split across parts is in a part to cut, so the join's cut and the parts' differ wherever the join
1102
- * holds one; where nothing spans two parts they are the same, as every piece ends at whitespace or inside a run longer
1103
- * than a piece, and a line break ends each part. */
1104
- function joinCut(joined, parts, cut) {
1105
- const whole = cut(joined);
1106
- return whole === "[redacted]" || whole !== parts.map(cut).join("\n");
1107
- }
1108
1094
  /** The ToolHost a run's non-hand tools bind through, the one both the pi spec and the CLI spec build: the run's folder and
1109
1095
  * the claim's environment (claim-secrets.ts: the run's keys from the store, its plane set), the run's registry for an
1110
1096
  * extension a binding installs, the install lifecycle (`life`, run by the adapter loop from the spec's `lifecycle`), the
@@ -1,5 +1,6 @@
1
1
  import type { AgentAdapter, Wire } from "@parcha/agentrun-kernel";
2
2
  import type { AdapterRun } from "../adapter-loop.js";
3
+ import type { HeldRedact } from "../redact.js";
3
4
  /** What every adapter is given for one claim, from the run's launch. */
4
5
  export interface HarnessLaunch {
5
6
  /** The claim's run: its Harness on the run's journal (pi adds its turns to it). */
@@ -22,6 +23,9 @@ export interface HarnessLaunch {
22
23
  readonly sessionsDir: string;
23
24
  /** The proxy's upstream fetch (a test's scripted origin). */
24
25
  readonly fetch?: typeof fetch;
26
+ /** The runner's one redactor (LoopDeps.redact), holding the keys the claim opens: pi's session proxy cuts a provider's
27
+ * error with it before pi has it. */
28
+ readonly redact: HeldRedact;
25
29
  }
26
30
  /** A harness the runner runs. */
27
31
  export interface RunnerHarness {
@@ -9,7 +9,7 @@ const CODEX_PACKAGE = "@parcha/agentrun-harness-codex";
9
9
  export const RUNNER_HARNESSES = {
10
10
  pi: {
11
11
  // `extra`: pi's own options (PiAdapterOptions), as the run's spec gives them (adapter-run-spec.ts): its extensions,
12
- // tools, redactor, tiers, and the route's whole provider over the launch's.
12
+ // tools, tiers, and the route's whole provider over the launch's. Its redactor is the launch's, typed.
13
13
  adapter: async (launch, extra = {}) => piAdapter({
14
14
  run: launch.run,
15
15
  model: launch.model,
@@ -17,6 +17,7 @@ export const RUNNER_HARNESSES = {
17
17
  ...(launch.price ? { price: launch.price } : {}),
18
18
  ...(launch.fetch ? { fetch: launch.fetch } : {}),
19
19
  ...extra,
20
+ redact: launch.redact,
20
21
  }),
21
22
  },
22
23
  [claudeFacts.id]: {
@@ -7,6 +7,7 @@ import { type SessionLike, type SessionModelPort } from "../../port-models.js";
7
7
  import { type CallStatus } from "../journal-kinds.js";
8
8
  import { CALL_REFUSED } from "../../timeline/index.js";
9
9
  import { type ComputerCallRecord } from "../../computer-calls.js";
10
+ import { type HeldRedact } from "../redact.js";
10
11
  /** What the adapter loop lends pi for one claim: the run's Harness, its registry, and where pi's models go. */
11
12
  export interface PiRun {
12
13
  readonly harness: Harness;
@@ -74,7 +75,7 @@ export interface PiAdapterOptions {
74
75
  readonly fetch?: typeof fetch;
75
76
  /** The runner's one redactor, which a provider's error passes through in the session's proxy before pi has it
76
77
  * (ModelProxyOptions.redact; the proxy's own cut of the credential comes first). */
77
- readonly redact?: (text: string) => string;
78
+ readonly redact: HeldRedact;
78
79
  /** pi-native extensions the run's root agent carries beside the session's own (the browser's durable extension, as a
79
80
  * pi DurableRun on main installs it): installed in the claim's registry, so their tools run as pi's own tool tasks (a
80
81
  * taskId, a memo, conversations they own) and their own task kinds (a browser.release) under pi's recovery, all in the
@@ -119,7 +120,7 @@ export interface TierProxies {
119
120
  * keys, AdapterSession.port's `tier`), sent by pi-ai's client of the tier model's own wire (port-models.ts), so a tier
120
121
  * proxy speaks its model's route (model-route.ts routeOf, its translation fetch for a model of neither wire), never the
121
122
  * harness's. One that fails to start closes those started. */
122
- export declare function openTierProxies(tiers: ReadonlyMap<string, TierModel>, hooks: SessionIO["models"], redact?: (text: string) => string, tools?: readonly string[]): Promise<TierProxies>;
123
+ export declare function openTierProxies(tiers: ReadonlyMap<string, TierModel>, hooks: SessionIO["models"], redact: (text: string) => string, tools?: readonly string[]): Promise<TierProxies>;
123
124
  /** The session proxy's policy on Messages: claude-agent's (no fork), with pi's tools, the host's own names (`tools`), as
124
125
  * the names its client offers by themselves (its builtins). The CLI's own `mcp__hands__` prefix is not pi's: under it
125
126
  * every one of pi's tool definitions would be dropped and the model offered none. Every other tool definition is
@@ -13,6 +13,7 @@ import { sessionProvider, tierProvider } from "../../port-models.js";
13
13
  import { KINDS } from "../journal-kinds.js";
14
14
  import { CALL_REFUSED } from "../../timeline/index.js";
15
15
  import { recordingCalls } from "../../computer-calls.js";
16
+ import { mustHold } from "../redact.js";
16
17
  /** `extension` with each of its tools run inside recordingCalls, its calls kept by `keep` under the call's id. A call pi
17
18
  * runs again after a restart keeps what that attempt makes: a code mode script's replay hands back the results of the
18
19
  * calls its earlier attempt made, never making them again, so none is kept twice. The earlier attempt's own record goes
@@ -64,6 +65,7 @@ const HOST_VALUE = "agentrun.value";
64
65
  const INPUT_REQUEST = "agentrun:input";
65
66
  /** pi as an AgentAdapter for one claim's run. */
66
67
  export function piAdapter(options) {
68
+ mustHold(options.redact, "A pi adapter");
67
69
  return {
68
70
  // pi is the default harness: its id is the harness table's, never a literal of its own.
69
71
  id: DEFAULT_HARNESS,
@@ -116,7 +118,7 @@ async function routeProxy(route, hooks, tools, redact, tier, webSearch = false)
116
118
  ...(price ? { price: price } : {}),
117
119
  ...(route.provider.headers ? { headers: route.provider.headers } : {}),
118
120
  ...(route.fetch ? { fetch: route.fetch } : {}),
119
- ...(redact ? { redact } : {}),
121
+ redact,
120
122
  }, randomBytes(32).toString("base64url"));
121
123
  }
122
124
  /** A run's models of other tiers than its own (a learned workflow's node of a tier: AGENT_MODEL_FAST, AGENT_MODEL_STRONG),
@@ -49,7 +49,7 @@ export declare const AUDIT_PARKED = "the audit ended where it would wait on a pe
49
49
  * could never be audited (no learning start, or not auditableLaunch) keeps `step` as it is. */
50
50
  export declare function withAudit(step: EndOfRunTurn | undefined, deps: AuditDeps & {
51
51
  readonly launch: RunLaunch;
52
- readonly redact?: (text: string) => string;
52
+ readonly redact: (text: string) => string;
53
53
  }): EndOfRunTurn | undefined;
54
54
  /** Starts the shadow of run `runId`, at its end, when the learned workflow `serve` served it first and its id is drawn:
55
55
  * never for a replay or a shadow, a run that does not learn, one not auditable (auditableLaunch: a trigger started it,
@@ -36,7 +36,9 @@ type RunLaunchReader = {
36
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
37
37
  * written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws. A run whose
38
38
  * model sends no key (sendsNoModelKey: a held run its model kept from running, any run on a --faux runner, a faux-pinned
39
- * one) is laid no model key and no plan sign-in. Its tools' keys, its decision keys and its own tool keys are laid as any run's. The one tool key row that names
39
+ * one) is laid no model key and no plan sign-in. A held run its model kept from running at its create (hold.refused) is
40
+ * laid no built-in harness's own key either (harness-table.ts BUILTIN_OWN_KEYS: Cursor's): its agent never starts. Its
41
+ * tools' keys, its decision keys and its own tool keys are laid as any run's. The one tool key row that names
40
42
  * a model key's name, TypeSafe's (key-words.ts; model.ts PROVIDER_KEYS typesafe), is a decision key (secrets.ts
41
43
  * DECISION_KEYS): keysFor never names one, so the model key filter below never sees it, and decisionKeysFor lays it
42
44
  * apart, as it lays OpenRouter's for a decision node that runs on it. */
@@ -6,9 +6,10 @@
6
6
  // providers they name, read once the claim's seed lay chose them (learnedDecisionKeys). So a run that names no monid never gets the monid key, and two runs on
7
7
  // one runner never see each other's keys: each claim reads its own, into its own environment. (MCP credentials are the
8
8
  // other per-claim secret; they come through mcp-claim.ts, which already opens them from the store under the claim.)
9
- import { decisionKeysFor, JEV_KEY_ENV, JEV_OPENROUTER_KEY_ENV, PARALLEL_KEY_ENV, providersNamed } from "../decisions.js";
9
+ import { decisionKeysFor, JEV_GATEWAY_KEY_ENV, JEV_KEY_ENV, JEV_OPENROUTER_KEY_ENV, PARALLEL_KEY_ENV, providersNamed } from "../decisions.js";
10
10
  import { FAUX_ENV, FAUX_PROVIDER, GATEWAY_KEY_ENV, hostModel, modelKeys, PROVIDER_KEYS, tierModelOf, TIERS, workflowNodes } from "../model.js";
11
11
  import { keysFor, needsOf, RUN_SECRETS } from "../run-secrets.js";
12
+ import { BUILTIN_OWN_KEYS } from "../harness-table.js";
12
13
  import { DECISION_KEYS, withoutSecrets } from "../secrets.js";
13
14
  import { getSealedKey } from "../server-keys.js";
14
15
  import { PLAN_PROVIDER, planOf, planReaderOf, withPlan } from "../chatgpt-plan.js";
@@ -32,23 +33,29 @@ const CANDIDATES = [...new Set([...RUN_SECRETS, ...DECISION_KEYS])];
32
33
  * 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
33
34
  * written (no one holds them after the turn); a plain JS caller that passes none lays no run key, and throws. A run whose
34
35
  * model sends no key (sendsNoModelKey: a held run its model kept from running, any run on a --faux runner, a faux-pinned
35
- * one) is laid no model key and no plan sign-in. 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
+ * one) is laid no model key and no plan sign-in. A held run its model kept from running at its create (hold.refused) is
37
+ * laid no built-in harness's own key either (harness-table.ts BUILTIN_OWN_KEYS: Cursor's): its agent never starts. Its
38
+ * tools' keys, its decision keys and its own tool keys are laid as any run's. The one tool key row that names
36
39
  * a model key's name, TypeSafe's (key-words.ts; model.ts PROVIDER_KEYS typesafe), is a decision key (secrets.ts
37
40
  * DECISION_KEYS): keysFor never names one, so the model key filter below never sees it, and decisionKeysFor lays it
38
41
  * apart, as it lays OpenRouter's for a decision node that runs on it. */
39
42
  export async function claimSecrets(deps, revision, launch, runId) {
40
43
  const base = withoutSecrets(deps.env ?? {});
41
44
  const needs = await needsOf(revision);
45
+ const keyless = sendsNoModelKey(launch, deps.env ?? {});
42
46
  const modelRefused = launch.hold?.refused !== undefined;
43
- // A held run its model kept from running lays no model key, so its claim opens none: a key it never lays is never
44
- // decrypted. OpenRouter's is read still for a run whose decision nodes may run on it (decisionKeysFor), as a decision key.
45
- const unread = modelRefused ? MODEL_KEY_NAMES.filter((name) => !(name === JEV_OPENROUTER_KEY_ENV && needs.decisionProviders.length > 0)) : [];
47
+ // A run that sends no model key (sendsNoModelKey) lays none, so its claim opens none: a key it never lays is never
48
+ // decrypted. A run with decision nodes still reads each name its decision keys come from (DECISION_KEY_SOURCES: Jev's
49
+ // TypeSafe key, OpenRouter's, an OpenRouter gateway's), which decisionKeysFor lays as decision keys alone; the model key
50
+ // filter below lays none of them as a model key. Parallel's is no model key's name, so it is never left unread. A held
51
+ // run its model kept from running (hold.refused) lays no built-in harness's own key either (its agent never starts), so
52
+ // it opens none of those.
53
+ const unread = [...(keyless ? MODEL_KEY_NAMES.filter((name) => !(needs.decisionProviders.length > 0 && DECISION_KEY_SOURCES.has(name))) : []), ...(modelRefused ? BUILTIN_OWN_KEYS : [])];
46
54
  const working = await workingEnv(deps, unread);
47
55
  // An agentic run's model keys are its PINNED model's (the launch's, chosen at its start), the one its route sends, never
48
56
  // the host's default now: a key saved since the run started (another provider's, now first) would otherwise be opened
49
57
  // in its place, and the run would hold a key its model never sends and lack the one it does.
50
58
  const scoped = launch.model && !needs.tiers ? { ...needs, model: `${launch.model.provider}/${launch.model.modelId}` } : needs;
51
- const keyless = sendsNoModelKey(launch, deps.env ?? {});
52
59
  const env = { ...base };
53
60
  // The key of a gateway saved in the console (model-gateway.ts) stays on the run environment its model routes read, never
54
61
  // on the tools': it is read there by name alone (claimModelEnv), as a run's own model key is.
@@ -56,7 +63,7 @@ export async function claimSecrets(deps, revision, launch, runId) {
56
63
  // A model key is never enumerable, as withModelKeys lays a route's, but unlike a route's it stays writable and deletable
57
64
  // (withoutModelKeys drops it); a tool key is a plain value, which its tools read and hand on.
58
65
  for (const name of keysFor(scoped, working))
59
- if (working[name] !== undefined && !(savedGateway && name === GATEWAY_KEY_ENV) && !(keyless && MODEL_KEY_NAMES.includes(name)))
66
+ if (working[name] !== undefined && !(savedGateway && name === GATEWAY_KEY_ENV) && !(keyless && MODEL_KEY_NAMES.includes(name)) && !(modelRefused && BUILTIN_OWN_KEYS.includes(name)))
60
67
  Object.defineProperty(env, name, { value: working[name], enumerable: !MODEL_KEY_NAMES.includes(name), writable: true, configurable: true });
61
68
  // TypeSafe's key is a model key: a run whose model sends none (keyless) is not handed it for Jev's web ranking either,
62
69
  // and its web tools answer unranked.
@@ -378,6 +385,10 @@ export function claimModelEnv(env, opened, runKey, claim) {
378
385
  /** The decision providers' own keys (decisions.ts: Jev's TypeSafe key, OpenRouter's, Parallel's): some are also pi-ai
379
386
  * provider names, but a run's model key never replaces them, so withoutModelKeys keeps them. */
380
387
  const DECISION_KEY_NAMES = new Set([JEV_KEY_ENV, JEV_OPENROUTER_KEY_ENV, PARALLEL_KEY_ENV]);
388
+ /** Every name a decision key is read from (decisions.ts decisionKeysOf): the decision keys' own names, and an OpenRouter
389
+ * gateway's key (JEV_GATEWAY_KEY_ENV), which Jev and OpenRouter's Decisions models run on when no key of their own is
390
+ * set. A claim that opens no model key still opens these for a run with decision nodes (claimSecrets). */
391
+ const DECISION_KEY_SOURCES = new Set([...DECISION_KEY_NAMES, JEV_GATEWAY_KEY_ENV]);
381
392
  /** `toolEnv` with no model key in it, for a run that holds its own: a tool's environment never carries a model key the
382
393
  * run's model routes do not send. The decision providers' keys stay (DECISION_KEY_NAMES): a keyed workflow's judge,
383
394
  * pick, sift, route and ask nodes run on them as any run's do. */
@@ -46,7 +46,7 @@ import { withoutKindSkill } from "../workspace/kind-skills.js";
46
46
  import { layOwnSkills } from "../workspace/revision-skills.js";
47
47
  import { runTools, withKindTools } from "../workspace/run-tools.js";
48
48
  import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
49
- import { loadArchilSettings } from "../archil-settings.js";
49
+ import { loadArchilSettings, noExecRegionOf } from "../archil-settings.js";
50
50
  import { settingOfDefinition } from "../computer-setting.js";
51
51
  import { computerFilesNote, computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
52
52
  import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
@@ -75,7 +75,7 @@ import { AUDIT_PARKED, withAudit } from "./audit.js";
75
75
  import { compareEndOfRun, GRADER, withGrader } from "./compare-end.js";
76
76
  import { runPathMetricsOverStore } from "../store-reads/learning.js";
77
77
  import { specBuilt } from "./spec-holds.js";
78
- import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
78
+ import { heldRedactor, holdClaimed, mustHold, runnerSecrets, secretRedactor } from "./redact.js";
79
79
  import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
80
80
  import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginByToken, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
81
81
  import { heldTokenLogin } from "../claude-login-token.js";
@@ -288,6 +288,7 @@ export function cliRunSpecFromLaunch(launch, run, deps, claim) {
288
288
  return specBuilt((holds) => cliSpec(launch, run, deps, claim, holds));
289
289
  }
290
290
  async function cliSpec(launch, run, deps, claim, holds) {
291
+ mustHold(run.redact, "A CLI run's spec");
291
292
  const context = BACKGROUND_CONTEXT;
292
293
  // What this claim may reach on loopback, read once for its MCP servers and its calendar_events alike (mcpReachOf).
293
294
  const reach = await mcpReachOf(deps);
@@ -319,7 +320,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
319
320
  holds.hold({ scratch: { sweep: () => sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
320
321
  // Every secret the server keeps sealed (store-secrets.ts) held by the runner's one redactor (the loop's) and this spec's
321
322
  // log cut, before any of the run's text is written: a run's text may quote one it was never handed.
322
- for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
323
+ for (const redact of [run.redact, cut])
323
324
  await holdStored(redact, deps.store, deps.sealKey, deps.data);
324
325
  const revisionRow = await deps.store.agents.revision(runRow.revisionId);
325
326
  if (!revisionRow)
@@ -379,6 +380,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
379
380
  // this claim's memory only, dropped at the release); else Mode 1, the run's local folder.
380
381
  const archilSettings = await loadArchilSettings(deps.store, deps.env);
381
382
  const mode = archilSettings === undefined ? 1 : 2;
383
+ // Its region with no serverless exec, where it has none: a run with no computer that mounts its folder has no shell.
384
+ const noExec = noExecRegionOf(archilSettings);
382
385
  const archil = archilSettings === undefined
383
386
  ? undefined
384
387
  // The run's mount credential, minted per run (account key from the server's environment first, then the sealed row),
@@ -400,7 +403,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
400
403
  // The run's MCP for this claim (mcp-run.ts mcpForClaim): its pin, the one its revision's save made, read, its
401
404
  // credentials opened under the runner's seal key (deps.sealKey) into this claim's memory, one gateway for the claim.
402
405
  // Before the session opens: a refusal (a granted tool its pin does not hold, a pinned meta tool) ends the run in its words.
403
- // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
406
+ // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors. A
407
+ // per_run server the run was handed no credential for is left out of its tools, and its timeline says so; not on a
408
+ // harness whose tools are fixed at its thread's start (AdapterFacts.toolsFixedAtStart), where it would never come back.
404
409
  // A held run its model kept from running at its create (hold.refused) opens none: nothing can call one.
405
410
  const heldRefusal = launch.hold?.refused?.message;
406
411
  // What its gateway files (a long answer, a server's results) goes in the run's own files. In Mode 1 that is the run's
@@ -411,9 +416,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
411
416
  // and a call reaches it only through the session this spec returns, after `tools` is made. After the run's Workspace,
412
417
  // as the pi spec makes it: a refusal lets the Workspace and the Archil claim go (holds above).
413
418
  let filedIn;
414
- const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
419
+ const hold = (values) => { for (const redact of [run.redact, cut])
415
420
  redact.hold(values); };
416
- const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, web, launch) });
421
+ const mcp = heldRefusal !== undefined ? undefined : await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, toolSettings: body.toolSettings, work: () => (mode === 2 ? filedIn ?? ws.workspace : ws.workspace), launchInput: launch.input, hold, redact: run.redact, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, say: (words) => run.phase?.(words), ...(facts.toolsFixedAtStart ? { toolsFixedAtStart: true } : {}), ...claimMetering(deps, web, launch) });
417
422
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
418
423
  holds.hold({ passed: mcp });
419
424
  // The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
@@ -457,7 +462,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
457
462
  // spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount); a park's
458
463
  // row names the disk that credential is on (mountDisk). Its screen's recording (computer.record) goes in the run's
459
464
  // recordings folder, as the pi spec's does.
460
- { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(offAlready ? { turnedOff: offAlready } : {}), recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit(), mountDisk: () => archil.disk.id } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
465
+ { ...deps.computerDeps, mode, noExec, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(offAlready ? { turnedOff: offAlready } : {}), recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit(), mountDisk: () => archil.disk.id } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
461
466
  holds.hold({ computer });
462
467
  const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
463
468
  const heldComputer = heldSpecOf(launch, loopComputer);
@@ -482,7 +487,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
482
487
  // Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv), as the pi spec does.
483
488
  const bashPolicy = bashPolicyOf(body.toolSettings);
484
489
  // A computer that replaced an earlier claim's holds its acts to what it showed, as the pi spec's does.
485
- const tools = await runTools(ws.workspace, computer.computer, { mode, context, aliases: [scratch], ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
490
+ const tools = await runTools(ws.workspace, computer.computer, { mode, noExec, context, aliases: [scratch], ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
486
491
  filedIn = tools.workspace;
487
492
  let remoteProjectCapture = false;
488
493
  holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
@@ -514,12 +519,13 @@ async function cliSpec(launch, run, deps, claim, holds) {
514
519
  const keyed = keyedAtClaim(runKey);
515
520
  if (keyed)
516
521
  withoutModelKeys(claimed);
517
- for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut]) {
522
+ for (const redact of [run.redact, cut]) {
518
523
  holdClaimed(redact, claimed);
519
524
  if (runKey)
520
525
  holdRunKey(redact, runKey);
521
526
  }
522
- const login = await runLoginOf(deps, keyed, name, launch.place, hold);
527
+ // A held run its model kept from running asks for no login, here or of its runner: its agent never starts.
528
+ const login = heldRefusal !== undefined ? undefined : await runLoginOf(deps, keyed, name, launch.place, hold);
523
529
  const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey, claim), login);
524
530
  // A plan-billed recipe's keys saved for its harness alone (harness-keys.ts), opened at each claim for this run's harness
525
531
  // and no other (a run's own process asks its runner, which opens its claim's own: held.ts harnessKeys), held by the
@@ -681,7 +687,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
681
687
  const ctx = hostToolCtxOf(run, context, results, root);
682
688
  // The runner's one redactor (the loop's), else this spec's log cut: the claim's keys join it, and the answers of the tools
683
689
  // that run on them pass it.
684
- const held = run.redact ? heldRedactor(run.redact) : cut;
690
+ const held = run.redact;
685
691
  // The run's monid endpoints (monid-run.ts), one host tool each from its revision's pin, on the claim's keys and beside
686
692
  // its MCP tools in the loop's one catalog seam; their answers pass the redactors as the web tools' do.
687
693
  const monid = monidForClaim(revisionRow.monidPin ?? undefined, { ...claimed }, () => ws.workspace, claim.runId, () => launch.maxCostUsd !== undefined, fakes?.monid);
@@ -792,7 +798,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
792
798
  system: [environmentLine(now, zone), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line)),
793
799
  // The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
794
800
  // redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
795
- tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), { results, writes: gate.writes() }), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
801
+ tools: inGrantOrder([...tools.hostTools(withKindTools(granted, tools), { results, writes: gate.writes(), opsRefused: gate.opsRefused() }), ...[...webTools, ...(askTool ? [askTool] : []), ...(learnedTool ? [learnedTool] : [])].map((tool) => answersCut(tool, held))], granted),
796
802
  context: "fresh",
797
803
  ...(thinking ? { thinking } : {}),
798
804
  };
@@ -805,7 +811,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
805
811
  // A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
806
812
  // withAudit): at its end, so the shadow's cap is what the run's own left.
807
813
  // A held run (no audits) takes none, as on pi.
808
- const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, ...(run.redact ? { redact: run.redact } : {}) }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
814
+ const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, log, redact: run.redact }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
809
815
  store: deps.store,
810
816
  data: deps.data,
811
817
  ...(deps.env ? { env: deps.env } : {}),
@@ -818,7 +824,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
818
824
  log,
819
825
  // A workflow draft's decision nodes are checked against the host's decision providers, on its keys (LS-07).
820
826
  decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, DECISION_PROVIDER_KEYS)) }),
821
- }), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
827
+ }), { ...audits, launch, redact: run.redact });
822
828
  return {
823
829
  adapter,
824
830
  facts: factsOn(ownerFacts, chosen.model),
@@ -854,8 +860,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
854
860
  ...(personOnly ? { personOnly } : {}),
855
861
  // The run's computer and the person's hold on a desktop or phone, as the claim made them (as the pi spec gives them).
856
862
  ...(loopComputer ? { computer: loopComputer } : {}),
857
- // A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools.
858
- ...(tools.computer ? { scriptComputer: tools.computer } : {}),
863
+ // A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools, its
864
+ // declarations without the ops the gate refuses whatever their arguments.
865
+ ...(tools.computer ? { scriptComputer: { ...tools.computer, opsRefused: gate.opsRefused() } } : {}),
859
866
  // A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
860
867
  ...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
861
868
  // A desktop or a phone that holds none of the run's files: the model is told once in the run where they are, or, where
@@ -888,7 +895,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
888
895
  const metrics = cliRunMetrics(piShaped(entries), booked, { ...(thinking ? { effort: thinking } : {}), model: `${chosen.model.provider}/${chosen.model.modelId}`, catalog: await hashedMcpOf(deps.store, claim.runId) });
889
896
  // Its cost is endCost's, read apart (an unknown one written as null, never left out: a follow-up's end clears the
890
897
  // cost an earlier end stored).
891
- return { metrics: { ...metrics, ...(await runPathMetricsOverStore(deps.store, claim.runId, launch, { ...(run.redact ? { redact: run.redact } : {}), choice: firstChoice.reason })), costBasis: costBasisOf(booked) } };
898
+ return { metrics: { ...metrics, ...(await runPathMetricsOverStore(deps.store, claim.runId, launch, { redact: run.redact, choice: firstChoice.reason })), costBasis: costBasisOf(booked) } };
892
899
  },
893
900
  // A run started with hold: true holds its computer for its owner (computer-held.ts), as the pi spec's.
894
901
  ...(heldComputer ? { held: heldComputer } : {}),