@parcha/agentrun-serve 0.1.0-beta.61 → 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 (131) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +102 -13
  3. package/dist/api-only.d.ts +4 -0
  4. package/dist/api-only.js +5 -1
  5. package/dist/archil-settings.d.ts +9 -0
  6. package/dist/archil-settings.js +8 -1
  7. package/dist/bash-read-only.d.ts +3 -0
  8. package/dist/bash-read-only.js +6 -3
  9. package/dist/chatgpt-plan.d.ts +26 -8
  10. package/dist/chatgpt-plan.js +89 -21
  11. package/dist/claude-login.d.ts +12 -5
  12. package/dist/claude-login.js +28 -3
  13. package/dist/cli.js +19 -8
  14. package/dist/composio-triggers.d.ts +9 -3
  15. package/dist/computers.d.ts +3 -0
  16. package/dist/computers.js +2 -1
  17. package/dist/console/assets/{backend-C9ffXUR5.js → backend-DEgVn5lC.js} +1 -1
  18. package/dist/console/assets/index-CG5tELph.js +639 -0
  19. package/dist/console/assets/share-CIeFK2Oe.js +6 -0
  20. package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
  21. package/dist/console/index.html +3 -3
  22. package/dist/console/share.html +3 -3
  23. package/dist/cut-pool.d.ts +14 -0
  24. package/dist/cut-pool.js +98 -0
  25. package/dist/cut-worker.d.ts +14 -0
  26. package/dist/cut-worker.js +16 -0
  27. package/dist/decisions.d.ts +4 -0
  28. package/dist/decisions.js +9 -1
  29. package/dist/env-switch.d.ts +3 -0
  30. package/dist/env-switch.js +3 -0
  31. package/dist/harness-table.d.ts +7 -0
  32. package/dist/harness-table.js +6 -3
  33. package/dist/import.d.ts +8 -1
  34. package/dist/import.js +36 -5
  35. package/dist/key-check.js +22 -8
  36. package/dist/learned-nodes.d.ts +2 -1
  37. package/dist/learned-nodes.js +2 -1
  38. package/dist/mcp-gateway.d.ts +24 -0
  39. package/dist/mcp-gateway.js +97 -8
  40. package/dist/mcp-servers-store.d.ts +7 -10
  41. package/dist/mcp-servers-store.js +15 -9
  42. package/dist/native/cli.js +5 -1
  43. package/dist/ollama-provider.d.ts +10 -3
  44. package/dist/ollama-provider.js +17 -7
  45. package/dist/openapi.js +29 -12
  46. package/dist/otel/tracer.d.ts +6 -3
  47. package/dist/otel/tracer.js +24 -6
  48. package/dist/page.d.ts +7 -0
  49. package/dist/page.js +17 -4
  50. package/dist/place.d.ts +25 -9
  51. package/dist/place.js +37 -11
  52. package/dist/print.d.ts +3 -2
  53. package/dist/print.js +8 -6
  54. package/dist/run-launch.js +16 -3
  55. package/dist/run-model-key.d.ts +2 -1
  56. package/dist/run-model-key.js +2 -1
  57. package/dist/run-reads-over-store.d.ts +7 -0
  58. package/dist/run-reads-over-store.js +32 -4
  59. package/dist/runnable.d.ts +6 -3
  60. package/dist/runnable.js +16 -6
  61. package/dist/runner/adapter-loop.js +64 -25
  62. package/dist/runner/adapter-run-spec.d.ts +6 -1
  63. package/dist/runner/adapter-run-spec.js +14 -11
  64. package/dist/runner/adapters/index.d.ts +4 -0
  65. package/dist/runner/adapters/index.js +2 -1
  66. package/dist/runner/claim-secrets.d.ts +3 -1
  67. package/dist/runner/claim-secrets.js +18 -7
  68. package/dist/runner/cli-run-spec.js +12 -8
  69. package/dist/runner/dispatch.js +2 -0
  70. package/dist/runner/harness-loops.d.ts +5 -0
  71. package/dist/runner/harness-loops.js +4 -1
  72. package/dist/runner/live-ticker.js +3 -1
  73. package/dist/runner/loop-contract.d.ts +4 -1
  74. package/dist/runner/mcp-run.d.ts +5 -0
  75. package/dist/runner/mcp-run.js +18 -0
  76. package/dist/runner/meta-tools.js +4 -4
  77. package/dist/runner/metrics.d.ts +4 -2
  78. package/dist/runner/metrics.js +5 -3
  79. package/dist/runner/native-loop.js +2 -2
  80. package/dist/runner/run-child-host.d.ts +10 -6
  81. package/dist/runner/run-child-host.js +44 -29
  82. package/dist/runner/run-child.js +1 -0
  83. package/dist/runner/runner.js +2 -0
  84. package/dist/runner/workflow-calls.d.ts +4 -3
  85. package/dist/runner/workflow-calls.js +41 -12
  86. package/dist/runner/workflow-spec.js +1 -1
  87. package/dist/secret-rules.d.ts +0 -1
  88. package/dist/secret-rules.js +25 -5
  89. package/dist/server.d.ts +10 -1
  90. package/dist/server.js +114 -38
  91. package/dist/share-host.d.ts +111 -0
  92. package/dist/share-host.js +666 -0
  93. package/dist/store-reads/analytics.d.ts +15 -0
  94. package/dist/store-reads/analytics.js +17 -0
  95. package/dist/suggestions.js +32 -3
  96. package/dist/templates.d.ts +3 -1
  97. package/dist/templates.js +7 -3
  98. package/dist/tool-gate.d.ts +25 -9
  99. package/dist/tool-gate.js +58 -19
  100. package/dist/tool-plane.d.ts +1 -0
  101. package/dist/tool-plane.js +6 -2
  102. package/dist/trigger-composio.js +1 -1
  103. package/dist/webhooks.d.ts +3 -0
  104. package/dist/webhooks.js +5 -0
  105. package/dist/workspace/archil-claim.d.ts +7 -3
  106. package/dist/workspace/archil-claim.js +13 -5
  107. package/dist/workspace/archil-mount-credential.d.ts +6 -0
  108. package/dist/workspace/archil-mount-credential.js +11 -0
  109. package/dist/workspace/computer-deps.d.ts +5 -3
  110. package/dist/workspace/computer-deps.js +11 -9
  111. package/dist/workspace/computer-for-claim.d.ts +6 -2
  112. package/dist/workspace/computer-for-claim.js +43 -12
  113. package/dist/workspace/computer-janitor.d.ts +7 -4
  114. package/dist/workspace/computer-janitor.js +7 -4
  115. package/dist/workspace/computer-kept.d.ts +7 -1
  116. package/dist/workspace/computer-kept.js +7 -1
  117. package/dist/workspace/kind-skills/desktop/SKILL.md +12 -3
  118. package/dist/workspace/mount-revoke-left.d.ts +16 -4
  119. package/dist/workspace/mount-revoke-left.js +42 -22
  120. package/dist/workspace/resolve-computer.d.ts +11 -5
  121. package/dist/workspace/resolve-computer.js +22 -13
  122. package/dist/workspace/run-end-computers.js +1 -1
  123. package/dist/workspace/run-tools.d.ts +10 -3
  124. package/dist/workspace/run-tools.js +5 -4
  125. package/dist/wrapped.d.ts +29 -2
  126. package/dist/wrapped.js +20 -3
  127. package/launcher/agentrun-serve +1 -1
  128. package/package.json +12 -12
  129. package/dist/console/assets/index-BnZV3lvW.js +0 -639
  130. package/dist/console/assets/share-B1o5mJ56.js +0 -6
  131. /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
@@ -70,7 +70,7 @@ import { AUDIT_PARKED, withAudit } from "./audit.js";
70
70
  import { runPathMetricsOverStore } from "../store-reads/learning.js";
71
71
  import { specBuilt } from "./spec-holds.js";
72
72
  import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
73
- import { loadArchilSettings } from "../archil-settings.js";
73
+ import { loadArchilSettings, noExecRegionOf } from "../archil-settings.js";
74
74
  import { settingOfDefinition } from "../computer-setting.js";
75
75
  import { computerFilesNote, computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
76
76
  import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
@@ -353,7 +353,7 @@ export async function adapterRunGate(store, claim, revision, root, shell, option
353
353
  current = await storeSettings(store);
354
354
  return current.unreadable ? "deny" : gate.policy(tool);
355
355
  };
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 });
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() });
357
357
  }
358
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
359
359
  * and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
@@ -402,6 +402,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
402
402
  // claim's memory only); else Mode 1, the run's local folder. The same for the pi and the CLI spec.
403
403
  const archilSettings = await loadArchilSettings(deps.store, deps.env);
404
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);
405
407
  const archil = archilSettings === undefined
406
408
  ? undefined
407
409
  // The run's mount credential is minted per run the first time a computer's mount asks (archil-mount-credential.ts), on
@@ -473,7 +475,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
473
475
  // and a call reaches it only through the session this spec returns, after `tools` is made.
474
476
  let filedIn;
475
477
  const hold = (values) => cut.hold(values);
476
- 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, say: (words) => run.phase?.(words), ...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) });
477
479
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
478
480
  holds.hold({ passed: mcp });
479
481
  // The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
@@ -497,7 +499,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
497
499
  // row names the disk that credential is on (mountDisk), asked only at the park: a run's own process hands its claim to
498
500
  // its runner, whose computerForClaim asks its own Archil claim. A recording of its screen (computer.record) goes in
499
501
  // the run's recordings folder, beside its folder, said on its timeline.
500
- { ...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) } : {}) });
501
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
502
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).
503
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,
@@ -510,7 +512,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
510
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
511
513
  // as `tools.<name>`, each a nested call, gated and recorded as the model's own call is. A computer that replaced an
512
514
  // earlier claim's holds its acts to what it showed.
513
- 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 } : {}) });
514
516
  filedIn = tools.workspace;
515
517
  let remoteProjectCapture = false;
516
518
  holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
@@ -580,8 +582,8 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
580
582
  // The run's adapter is its runner's (runner/adapters/index.ts RunnerHarness: pi's, or the one a harness module's entry
581
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
582
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.
583
- // pi's own options (its extensions, tools, redactor, the model's catalog entry, hosted search, tiers, and the route's
584
- // 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.
585
587
  const scratch = scratchFolder(deps.data, runRow.agentId, claim.runId);
586
588
  const harnesses = join(scratch, "harness");
587
589
  holds.hold({ scratch: { sweep: async () => (await import("./cli-run-spec.js")).sweepScratch(harnesses, claim.epoch, [harnesses, scratch, dirname(scratch)]) } });
@@ -592,12 +594,12 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
592
594
  ...(route.price ? { price: route.price } : {}),
593
595
  sessionsDir: join(harnesses, String(claim.epoch)),
594
596
  ...(route.fetch ? { fetch: route.fetch } : {}),
597
+ redact: cut,
595
598
  }, {
596
599
  // Read when the session opens (pi.ts), so the browser's extension pushed by bindNonHandTools below is in it.
597
600
  extensions: native,
598
601
  tools: piTools,
599
602
  provider: route.provider,
600
- redact: cut,
601
603
  ...(route.like ? { like: route.like } : {}),
602
604
  // The run's web_search is its provider's hosted search (the launch's plane, as its start resolved it): the session's
603
605
  // proxy admits that search's one request (it goes through the session's port: buildToolHost's `search`) and books it
@@ -732,7 +734,7 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
732
734
  // The run's tools. The hands (read/write/edit/bash and the background tools) are the kernel registry's over the run's
733
735
  // Workspace and computer (runTools.hostTools); the gate is the adapter loop's own (spec.gate), so they run as asked.
734
736
  const results = new Map();
735
- 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() });
736
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
737
739
  // words, pass the run's one redactor before the harness, the model or the record has them.
738
740
  const tiers = new Map([...[...tierRoutes].filter(([tier]) => !isSubagentRoute(tier) && tier !== GRADER).map(([tier, { model }]) => [tier, { model }]), ...[...tierUnreachable].map(([tier, why]) => [tier, { why }])]);
@@ -867,8 +869,9 @@ async function adapterSpec(launch, run, deps, claim, holds, runner) {
867
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,
868
870
  // applies a take-over and a hand-back to it, and answers the computer call channel's rows on it.
869
871
  ...(loopComputer ? { computer: loopComputer } : {}),
870
- // A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools.
871
- ...(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() } } : {}),
872
875
  // A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
873
876
  ...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
874
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
@@ -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]: {
@@ -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";
@@ -380,6 +380,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
380
380
  // this claim's memory only, dropped at the release); else Mode 1, the run's local folder.
381
381
  const archilSettings = await loadArchilSettings(deps.store, deps.env);
382
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);
383
385
  const archil = archilSettings === undefined
384
386
  ? undefined
385
387
  // The run's mount credential, minted per run (account key from the server's environment first, then the sealed row),
@@ -416,7 +418,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
416
418
  let filedIn;
417
419
  const hold = (values) => { for (const redact of [run.redact, cut])
418
420
  redact.hold(values); };
419
- 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, say: (words) => run.phase?.(words), ...(facts.toolsFixedAtStart ? { toolsFixedAtStart: true } : {}), ...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) });
420
422
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
421
423
  holds.hold({ passed: mcp });
422
424
  // The pull request's checkout, when the revision asks for one, as the pi spec makes it (pr-checkout.ts).
@@ -460,7 +462,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
460
462
  // spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount); a park's
461
463
  // row names the disk that credential is on (mountDisk). Its screen's recording (computer.record) goes in the run's
462
464
  // recordings folder, as the pi spec's does.
463
- { ...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) } : {}) });
464
466
  holds.hold({ computer });
465
467
  const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
466
468
  const heldComputer = heldSpecOf(launch, loopComputer);
@@ -485,7 +487,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
485
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.
486
488
  const bashPolicy = bashPolicyOf(body.toolSettings);
487
489
  // A computer that replaced an earlier claim's holds its acts to what it showed, as the pi spec's does.
488
- 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 } : {}) });
489
491
  filedIn = tools.workspace;
490
492
  let remoteProjectCapture = false;
491
493
  holds.hold({ tools: { end: () => remoteProjectCapture ? Promise.resolve() : tools.end() } });
@@ -522,7 +524,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
522
524
  if (runKey)
523
525
  holdRunKey(redact, runKey);
524
526
  }
525
- 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);
526
529
  const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey, claim), login);
527
530
  // A plan-billed recipe's keys saved for its harness alone (harness-keys.ts), opened at each claim for this run's harness
528
531
  // and no other (a run's own process asks its runner, which opens its claim's own: held.ts harnessKeys), held by the
@@ -795,7 +798,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
795
798
  system: [environmentLine(now, zone), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line)),
796
799
  // The web tools and the learned workflow's call nodes run on the claim's keys: their answers pass the runner's one
797
800
  // redactor, as pi's do. Listed in the order the agent grants them, as main lists a CLI run's tools.
798
- 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),
799
802
  context: "fresh",
800
803
  ...(thinking ? { thinking } : {}),
801
804
  };
@@ -857,8 +860,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
857
860
  ...(personOnly ? { personOnly } : {}),
858
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).
859
862
  ...(loopComputer ? { computer: loopComputer } : {}),
860
- // A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools.
861
- ...(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() } } : {}),
862
866
  // A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
863
867
  ...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
864
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
@@ -9,6 +9,7 @@
9
9
  // be read, fails the run in words (the dispatch's start() throws, which the runner records as the run failing).
10
10
  import { harnessOfBody } from "../harness.js";
11
11
  import { launchOnItsDisk, readLaunchBody } from "../run-launch.js";
12
+ import { mustHold } from "./redact.js";
12
13
  /** A launch naming a harness this runner does not run. */
13
14
  export class UnknownHarness extends Error {
14
15
  harness;
@@ -39,6 +40,7 @@ export function createDispatchLoop(deps) {
39
40
  return (loopDeps) => dispatchLoop(deps, loopDeps);
40
41
  }
41
42
  function dispatchLoop(deps, loopDeps) {
43
+ mustHold(loopDeps.redact, "A dispatch loop");
42
44
  /** The harness's loop, once the launch read has chosen it. */
43
45
  let inner;
44
46
  /** Commands handed over before the inner loop was chosen: replayed through it once it is. */
@@ -30,6 +30,11 @@ export declare function refuseRecipeTriggerRun(deps: {
30
30
  export declare function resolveRunnerLoop(given: AdapterSpecDeps, options?: {
31
31
  readonly keysCounted?: boolean;
32
32
  }): (harness: string, launch: RunLaunch, runId: string) => Promise<LoopFactory | undefined>;
33
+ /** `made` with the saved gateway's key, as this claim read it, held by the run's one redactor before the loop starts: the
34
+ * key stays off the claim's tool keys (claimSecrets), and a later scan of the store (holdStored) would find only a key
35
+ * saved since, so a gateway reply that echoes this one is cut in the run's records and logs all the same. `made` itself
36
+ * where the gateway is not the saved one. */
37
+ export declare function holdingGatewayKey(made: LoopFactory, env: NodeJS.ProcessEnv | undefined): LoopFactory;
33
38
  /** `launch` as this claim runs it: its plane, resolved at the run's start, under the server's tool settings now
34
39
  * (tool-plane.ts claimPlane), so a resume, a follow-up or a reclaim after the server set web_fetch to kernel, or
35
40
  * web_search to native or off, sends nothing past that setting, whatever its agent picked. Settings that could not be
@@ -73,7 +73,7 @@ export function resolveRunnerLoop(given, options = {}) {
73
73
  * key stays off the claim's tool keys (claimSecrets), and a later scan of the store (holdStored) would find only a key
74
74
  * saved since, so a gateway reply that echoes this one is cut in the run's records and logs all the same. `made` itself
75
75
  * where the gateway is not the saved one. */
76
- function holdingGatewayKey(made, env) {
76
+ export function holdingGatewayKey(made, env) {
77
77
  const key = env && savedGatewayIn(env) ? env[GATEWAY_KEY_ENV] : undefined;
78
78
  if (!key)
79
79
  return made;
@@ -92,6 +92,9 @@ function holdingGatewayKey(made, env) {
92
92
  export async function underServerCeilings(deps, launch, revision) {
93
93
  if (!launch.plane)
94
94
  return launch;
95
+ // A run's own process takes the plane its runner capped, the one its keys were chosen by (AdapterSpecDeps.claimedPlane).
96
+ if (deps.claimedPlane)
97
+ return { ...launch, plane: deps.claimedPlane };
95
98
  const { settings, unreadable } = await storeSettings(deps.store);
96
99
  const unread = unreadable === true;
97
100
  const tooling = await toolingOf(revision);
@@ -1,4 +1,5 @@
1
1
  import { redactedAnswer, redactedLive, redactedOutputWhole } from "../key-refusal.js";
2
+ import { mustHold } from "./redact.js";
2
3
  /** A run's held state as the live view keeps it, under `values`, every secret value the run's one redactor holds. A
3
4
  * running tool's id and name are cut whole (redactedAnswer). Its args by a workflow output's rule (redactedOutputWhole):
4
5
  * read whole first, so a held value split across two of its fields withholds them as "[redacted]", as a call's arguments
@@ -54,6 +55,7 @@ export function withLiveTicker(store, createLoop, options = {}) {
54
55
  timer.unref?.();
55
56
  return {
56
57
  createLoop: (deps) => {
58
+ const redact = mustHold(deps.redact, "A loop the live ticker wraps");
57
59
  let claim;
58
60
  // The claim's signal aborts when its claim is lost (or the runner shuts down past its drain): from then the loop's
59
61
  // held state is neither taken nor written, though the loop still reports while it stops. The store fences a write
@@ -67,7 +69,7 @@ export function withLiveTicker(store, createLoop, options = {}) {
67
69
  // The run's one redactor: a running tool's args and output and a partial answer can quote a secret the runner holds
68
70
  // (a key its claim opened), and the live view is read by people and consoles. A loop whose redactor does not know its
69
71
  // values has no live view: a value still streaming, a number or an object's names cannot be cut by text alone.
70
- const values = deps.redact.heldValues;
72
+ const values = redact.heldValues;
71
73
  const loop = createLoop({
72
74
  ...deps,
73
75
  live: (read) => {
@@ -96,10 +96,13 @@ export type LoopEnd = {
96
96
  };
97
97
  }
98
98
  /** Parked on a person (an approval, a raise): the runner flushes and releases; a command row (or `wakeAt`, ms since
99
- * the epoch) makes the run claimable again, and the next claim's start() resumes it from the journal. */
99
+ * the epoch) makes the run claimable again, and the next claim's start() resumes it from the journal. `again`: parked
100
+ * where it stood with nothing written (a run woken at its cap by raises that were all refused), so the release itself
101
+ * parks the row again; else the loop's last commit parked it. */
100
102
  | {
101
103
  readonly state: "parked";
102
104
  readonly wakeAt?: number;
105
+ readonly again?: true;
103
106
  };
104
107
  export type StopReason =
105
108
  /** A stop or cancel row: the loop stages that row's take in the commit that ends the run as stopped (`cancel`: a cancel
@@ -1,3 +1,4 @@
1
+ import { type HeldRedact } from "./redact.js";
1
2
  import type { HostTool } from "@parcha/agentrun-kernel";
2
3
  import type { Harness } from "@earendil-works/pi-durable";
3
4
  import { type McpGatewayOptions } from "../mcp-gateway.js";
@@ -73,6 +74,10 @@ export interface McpForClaimOptions {
73
74
  };
74
75
  /** Each credential value the claim opens, refreshes or mints, for the run's redactors (mcp-claim.ts `hold`). */
75
76
  readonly hold?: (values: string[]) => void;
77
+ /** The run's redactor, after each call's own scrub on every text its gateway answers or files (mcp-gateway.ts
78
+ * McpGatewayOptions.redact). Required, and one that holds keys (heldRedactor): a claim's MCP given none throws before
79
+ * it opens or mints anything, and never answers past the run's redactor. */
80
+ readonly redact: HeldRedact;
76
81
  /** The run's revision's own tool settings (body.toolSettings), where a tool's file setting is read (filed-tool.ts
77
82
  * filedBy): each answer of such a tool is filed whole in the run's files and the tool's result is its summary. A run's
78
83
  * own process passes none: its runner reads them from the revision it reads itself (run-child-host.ts). */
@@ -1,3 +1,19 @@
1
+ // A claimed run's remote MCP servers on the runner (tl-mcp's note, sections 4 to 6). A spec builder calls mcpForClaim once
2
+ // per claim, inside the adapter loop's spec step: after the loop's Gate and Harness are open, before its session. It runs
3
+ // the claim step (mcp-claim.ts: the pin its revision's save made, read and checked against the meta tools known now, the
4
+ // pinned servers' credentials opened into this claim's memory) and builds ONE gateway (mcp-gateway.ts) for the
5
+ // claim, never shared with another, reading those credentials live. The builder puts what it returns in its spec
6
+ // (AdapterRunSpec.mcp); the loop does the rest:
7
+ // - one host tool per pinned tool (`tools`), under its wire name with the pinned description and schema, for every
8
+ // harness: the loop hands them to the session as it hands every host tool (pi's registry, the CLIs' own channel for
9
+ // host tools), on its path for every host tool: the gate before the intent (allow, ask and park, deny), the flush, the
10
+ // record, the run's one ledger for a priced call.
11
+ // - a command row handed to the running loop makes the credentials fresh again (`fresh`, on the same pin) before its
12
+ // next model request; the loop calls `release` when its pass ends, the claim is lost or its signal aborts.
13
+ // The gateway holds no gate here (the loop's is the run's one gate) and keeps the rest as it is: the meta refusal, the
14
+ // unopened refusal, the URL check per call, the scrub of each call's credentials held only while that call is out, prices
15
+ // on the run's one ledger and the not-metered booking on the run's root.
16
+ import { mustHold } from "./redact.js";
1
17
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
2
18
  import { wireName } from "../catalog.js";
3
19
  import { mcpGateway } from "../mcp-gateway.js";
@@ -31,6 +47,7 @@ export function catalogSessionNames(catalog, grant) {
31
47
  * claim lost while a refresh was awaited: the loop ends interrupted). A builder calls it before it takes anything it
32
48
  * would have to let go, since a throw here leaves its spec unbuilt and its release uncalled. */
33
49
  export async function mcpForClaim(options) {
50
+ const redact = mustHold(options.redact, "A claim's MCP");
34
51
  // The step's own signal: aborted by release(), which the loop calls when its pass ends, the claim is lost or its
35
52
  // signal aborts.
36
53
  const held = new AbortController();
@@ -90,6 +107,7 @@ export async function mcpForClaim(options) {
90
107
  ...(options.callBounds ? { bounds: options.callBounds } : {}),
91
108
  capped: options.capped !== false,
92
109
  ...(options.toolSettings !== undefined ? { filed: filedBy(options.toolSettings) } : {}),
110
+ redact,
93
111
  ...(media ? { media: publicMedia(async () => (media.web ? fakeSaveOptions(media.web) : fetchOptions(media.env, FAUX_ENV)), media.slots) } : {}),
94
112
  });
95
113
  const catalog = new Map();
@@ -20,7 +20,7 @@
20
20
  import { randomBytes } from "node:crypto";
21
21
  import { CodemodeSandbox, toCodemodeIdentifier } from "@earendil-works/pi-codemode";
22
22
  import { computerOver, withoutImageData } from "@parcha/agentrun-computer/surface";
23
- import { COMPUTER_OP_TOOL, computerDeclarations, STEP_TOOL_OPS } from "@parcha/agentrun-kernel/kernel";
23
+ import { COMPUTER_OP_TOOL, computerDeclarations, GUI_REACH, STEP_TOOL_OPS } from "@parcha/agentrun-kernel/kernel";
24
24
  import { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH } from "../meta-tool-names.js";
25
25
  import { NO_PROGRAMS_WORDS } from "../workspace/computer-ports.js";
26
26
  export { CODEMODE, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH };
@@ -83,11 +83,11 @@ function scriptComputer(computer, tools) {
83
83
  return `new Proxy(${bound}, { get(target, key, receiver) { if (key === "shell" || key === "processes") throw new Error(${JSON.stringify(NO_PROGRAMS_WORDS)}); return Reflect.get(target, key, receiver); } })`;
84
84
  }
85
85
  /** What codemode's description adds for a run with a computer: the script's `computer`, and the declarations of what its
86
- * card offers. */
86
+ * card offers, less the ops the run's gate refuses whatever their arguments (opsRefused). */
87
87
  function computerWords(computer) {
88
88
  return [
89
- `The script has this run's computer as \`computer\`, typed by the declarations below. Each of its calls is a call of the run's own computer tools, asked about and recorded as that tool's: a command it runs is held to bash's setting, a file it writes to write's, a file it reads, lists or stats to read's.`,
90
- computerDeclarations(computer.card.groups),
89
+ `The script has this run's computer as \`computer\`, typed by the declarations below. Each of its calls is a call of the run's own computer tools, asked about and recorded as that tool's: a command it runs is held to bash's setting; a file it writes needs write among this agent's tools, and a file it reads, lists or stats needs read among this agent's tools, each then held to that tool's setting. ${GUI_REACH}`,
90
+ computerDeclarations(computer.card.groups, computer.opsRefused),
91
91
  ].join("\n");
92
92
  }
93
93
  /** The three tools for a session: each `nests` (but the search, which calls nothing). */
@@ -83,8 +83,10 @@ export declare function bookedDecisionsOf(entries: readonly EntryLike[], ids: Re
83
83
  export declare function callCostOf(entries: readonly EntryLike[], callId: string, from: number, to: number): number | null;
84
84
  /** The turns of the requests call `callId` booked, by callCostOf's rule: each request whose record names it or one nested
85
85
  * in it, and each of host work admitted in its window (`from` < at <= `to`; -1 for both: no window, those named alone).
86
- * None: nothing was booked under the call. */
87
- export declare function callTurnsOf(entries: readonly EntryLike[], callId: string, from: number, to: number): Set<unknown>;
86
+ * None: nothing was booked under the call. `proof`: the turns that prove the call spent (workflow-calls.ts bookedUnder),
87
+ * not its price: a harness's own side request (`side` with no host label: a CLI's request on another model, its title or
88
+ * summary helper, proxy.ts) is left out, as it is never the call's. */
89
+ export declare function callTurnsOf(entries: readonly EntryLike[], callId: string, from: number, to: number, proof?: boolean): Set<unknown>;
88
90
  /** A cost of charges as a usage row or a run's cost block says it (costsofar/1, cutathold/1), by the kernel's one rule
89
91
  * (costOfParts) over `parts`, its float noise rounded off (floatNoiseOff): `usd` their sum, `upper_bound` when it counts
90
92
  * a cut request at its hold, with `so_far_usd` the charges' own figures alone and `unpriced` how many it counts at their
@@ -182,15 +182,17 @@ export function callCostOf(entries, callId, from, to) {
182
182
  }
183
183
  /** The turns of the requests call `callId` booked, by callCostOf's rule: each request whose record names it or one nested
184
184
  * in it, and each of host work admitted in its window (`from` < at <= `to`; -1 for both: no window, those named alone).
185
- * None: nothing was booked under the call. */
186
- export function callTurnsOf(entries, callId, from, to) {
185
+ * None: nothing was booked under the call. `proof`: the turns that prove the call spent (workflow-calls.ts bookedUnder),
186
+ * not its price: a harness's own side request (`side` with no host label: a CLI's request on another model, its title or
187
+ * summary helper, proxy.ts) is left out, as it is never the call's. */
188
+ export function callTurnsOf(entries, callId, from, to, proof = false) {
187
189
  const keyed = sessionConversations(entries);
188
190
  const hosted = new Set([keyed.get(TOOL_SESSION), keyed.get(DECISION_SESSION)].filter((one) => one !== undefined));
189
191
  const ours = (e, at) => {
190
192
  const d = (e.data ?? {});
191
193
  if (typeof d.call === "string" && (d.call === callId || d.call.startsWith(`${callId}/`)))
192
194
  return true;
193
- return at > from && at <= to && (typeof d.host === "string" || d.side === true || hosted.has(Number(e.conversationId)));
195
+ return at > from && at <= to && (typeof d.host === "string" || (d.side === true && !proof) || hosted.has(Number(e.conversationId)));
194
196
  };
195
197
  return new Set(entries.flatMap((e, at) => (e.kind === RUNNER_RECORDS.request && ours(e, at) ? [turnOf(e)] : [])));
196
198
  }
@@ -24,7 +24,7 @@ import { bookedSpend, cliRunMetrics } from './metrics.js';
24
24
  import { stopEnd } from './loop-contract.js';
25
25
  import { END_PATCH_MS, END_PATCH_UNKNOWN, REAL_TIMER } from './loop.js';
26
26
  import { storeSecrets } from './store-secrets.js';
27
- import { runnerSecrets, heldRedactor, processSecretRedactor } from './redact.js';
27
+ import { runnerSecrets, mustHold } from './redact.js';
28
28
  import { secretRedactor } from './redact.js';
29
29
  const ROOT = ROOT_CONVERSATION_ID;
30
30
  const MARK = 'agentrun.native';
@@ -64,7 +64,7 @@ async function lockProject(data, target, runId) {
64
64
  }
65
65
  export function createNativeLoop(launch, host) {
66
66
  return deps => {
67
- const held = heldRedactor(deps.redact ?? processSecretRedactor());
67
+ const held = mustHold(deps.redact, 'A native loop');
68
68
  let stopped;
69
69
  const abort = new AbortController();
70
70
  let session;
@@ -1,10 +1,10 @@
1
1
  import type { Duplex } from "node:stream";
2
2
  import { type GenAiTracing } from "../otel/tracer.js";
3
- import { type HeldRedact, type Redact } from "./redact.js";
3
+ import { type HeldRedact } from "./redact.js";
4
4
  import { type AdapterSpecDeps } from "./adapter-run-spec.js";
5
5
  import type { ClaudeAgentLogin } from "@parcha/agentrun-harness-claude";
6
6
  import type { Held } from "./held.js";
7
- import { type Claim, type LoopFactory } from "./loop-contract.js";
7
+ import { type Claim, type Loop, type LoopDeps, type LoopFactory } from "./loop-contract.js";
8
8
  import { Channel } from "./run-channel.js";
9
9
  import { type RunBigWrites } from "./big-writes.js";
10
10
  import { type SaveSlots } from "../web-save.js";
@@ -126,9 +126,10 @@ interface ClaimReads {
126
126
  * run's start (claudeLogin), handing it only when both reads name the same folder. */
127
127
  readonly login: ClaudeAgentLogin | undefined;
128
128
  }
129
- /** The runner's redactor as the host side of a run's process holds it (LoopDeps.redact): its cut, and the carry of a
130
- * value into what it cuts from the run's journal, which a token the runner hands the run needs (claudeLogin). */
131
- export type RunnerCut = Redact & Partial<Pick<HeldRedact, "carry">>;
129
+ /** The runner's redactor as the host side of a run's process holds it (LoopDeps.redact): its cut, the carry of a value
130
+ * into what it cuts from the run's journal, which a token the runner hands the run needs (claudeLogin), and the hold of
131
+ * each credential the claim opens, refreshes or mints for the run, which its MCP will not start without (mustHold). */
132
+ export type RunnerCut = HeldRedact;
132
133
  /** Held (held.ts) for one claim, on the runner: each answer the claim's own, read with the runner's seal key from the
133
134
  * runner's own reads of the claim; every argument from the run's process is checked or ignored. `bigs`: the run's pieced
134
135
  * writes (big-writes.ts), let go at the claim's release and, by the caller, when the run's channel ends. */
@@ -185,7 +186,8 @@ export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
185
186
  * own like any other. A run that is a process of its own is handed the login this claim read (`login`, ClaimReads): a
186
187
  * claim that read it off is never put on it, so a turn-on landing after it never puts the run on a login whose refusals
187
188
  * here it was never checked against; a claim that read it on has its runner read the setting again at the start
188
- * (heldFor claudeLogin), and is refused there, in fixed words, when that read names none or another folder. */
189
+ * (heldFor claudeLogin), and is refused there, in fixed words, when that read names none or another folder. A run that
190
+ * sends no model key (sendsNoModelKey) reads no login at its claim: it is never handed one, so never refused for one. */
189
191
  export type ClaimPlace = {
190
192
  readonly stays: true;
191
193
  } | {
@@ -204,3 +206,5 @@ export declare function runChannel(socket: Duplex, onClose: (why: Error) => void
204
206
  readonly bigs?: RunBigWrites;
205
207
  readonly maxFrame?: number;
206
208
  }): Channel;
209
+ /** `login`: the Claude login this run's claim read (staysInRunner), the one its runner hands the run (ClaimReads). */
210
+ export declare function childLoop(options: ChildLoopsOptions, slots: Slots | undefined, loopDeps: LoopDeps, login: ClaudeAgentLogin | undefined): Loop;