@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
@@ -27,14 +27,14 @@ import { openAccount } from "../email/account.js";
27
27
  import { harnessOf, planRecipeOf, recipeHarness } from "../harness-table.js";
28
28
  import { openHarnessKeys } from "../harness-keys.js";
29
29
  import { installDirOf, installForClaim, shareInstall } from "../harness-install.js";
30
- import { loadArchilSettings } from "../archil-settings.js";
30
+ import { loadArchilSettings, noExecRegionOf } from "../archil-settings.js";
31
31
  import { planOf } from "../chatgpt-plan.js";
32
32
  import { forgottenSignIns, handedSignInReadsBack, peekSignIn, runSignIn, signInReads, verifyRunSignIn } from "../sign-ins-store.js";
33
33
  import { vendorsOver } from "../sign-ins.js";
34
34
  import { decisionProvidersIn, fauxFetch } from "../decisions.js";
35
35
  import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
36
36
  import { learningEndOfRun } from "./learning-end.js";
37
- import { cutDeep, runnerSecrets } from "./redact.js";
37
+ import { cutDeep, mustHold, runnerSecrets } from "./redact.js";
38
38
  import { storeSecrets } from "./store-secrets.js";
39
39
  import { FAUX_ENV, GATEWAY_KEY_ENV } from "../model.js";
40
40
  import { SAVED_GATEWAY_ENV, savedGatewayIn } from "../model-gateway.js";
@@ -66,7 +66,7 @@ import { workflowsAt } from "./learning-seed.js";
66
66
  import { claimMetering, heldMcpOf, mcpForClaim } from "./mcp-run.js";
67
67
  import { learnedTiers, learnsWorkflows, mcpReachOf } from "./adapter-run-spec.js";
68
68
  import { createDispatchLoop } from "./dispatch.js";
69
- import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
69
+ import { refuseRecipeTriggerRun, resolveRunnerLoop, underServerCeilings, withSavedGatewayDeps } from "./harness-loops.js";
70
70
  import { isWorkflowRevision } from "./workflow-loop.js";
71
71
  import { loginForRun } from "../claude-login.js";
72
72
  import { harnessOfBody } from "../harness.js";
@@ -622,7 +622,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
622
622
  const projectStop = new AbortController();
623
623
  const projectSignal = reads.signal ? AbortSignal.any([reads.signal, projectStop.signal]) : projectStop.signal;
624
624
  let projectIO, projectCapture;
625
- let projectComputer, projectWorkspace, projectMode = 1;
625
+ let projectComputer, projectWorkspace, projectMode = 1, projectNoExec;
626
626
  let projectFailed = false, projectReleased = false, projectClosing = false, projectCaptureDone = false;
627
627
  let projectRelease;
628
628
  let projectCleanup;
@@ -660,7 +660,9 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
660
660
  return pending;
661
661
  };
662
662
  const fromGitHub = launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github";
663
- const github = () => githubAppAccess(store, sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
663
+ // Each credential the claim opens, refreshes or mints here (its MCP's, its GitHub App tokens) joins the runner's redactor.
664
+ const hold = (values) => cut.hold(values);
665
+ const github = () => githubAppAccess(store, sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
664
666
  /** The run's folder as the computer this claim made mounts it (Mode 2), where the claim's MCP files once it is made. */
665
667
  let mountedFolder;
666
668
  /** Mode 2's Archil claim, made once for the claim on the runner, its folder the run's. */
@@ -724,7 +726,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
724
726
  checkpoint = runProjectCheckpoint({ store, agentId: run.agentId, claim, launch, computer: projectComputer, ioHeld: true,
725
727
  tools: { get workspace() { if (!tools)
726
728
  throw new ClaimRefused("Project settlement has not opened its workspace."); return tools.workspace; },
727
- settleProject: async () => { tools = await runTools(projectWorkspace, projectComputer.computer, { mode: projectMode, context: BACKGROUND_CONTEXT }); return tools.settleProject(); } },
729
+ settleProject: async () => { tools = await runTools(projectWorkspace, projectComputer.computer, { mode: projectMode, noExec: projectNoExec, context: BACKGROUND_CONTEXT }); return tools.settleProject(); } },
728
730
  workspace: { data: deps.data, sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } },
729
731
  secrets: async () => runnerSecrets(deps.env, [...runnerSecrets(claimed), ...await storeSecrets(store, sealKey, deps.data)]), });
730
732
  result = await checkpoint.capture(signal);
@@ -757,24 +759,24 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
757
759
  return { state: plan.state, models: [...plan.models], token: () => plan.token(), refused: (sent) => plan.refused(sent), watch: (listener) => plan.watch(listener) };
758
760
  },
759
761
  // The claim's own login, as this runner reads the claim (its harness, its place, no model key of its own), whatever
760
- // the process names: its access token alone, read again at each ask and renewed here when it must be (near its end,
761
- // or refused); never its folder or its refresh token. Each token is carried into the runner's redactor for this run
762
- // (redact.ts carry) before it is handed, a renewed one too: model text that repeats it is cut from the run's journal
763
- // as the runner writes it (runner.ts fenced), from what it stages and from its rows, as the run's own tool keys are.
764
- // This answer is the one decision whether the run goes on the login: none, it does not. Its claim read the setting
765
- // (staysInRunner); a claim that read it off is never put on it, whatever the setting says now. A claim that read it on
766
- // has it read again here, at the start, with the claim's settings, data folder, harness and place. Its environment is
767
- // the claim's (the process's, when the runner was given none) with a saved gateway laid over it (withSavedGatewayDeps),
768
- // not always the very one the claim read with; that
769
- // difference can only refuse the start, never hand another folder, since the login is handed only when both reads name
770
- // the same folder: a turn-off, or a move to another folder,
771
- // between the claim and the start refuses the start in LOGIN_CHANGED_SINCE_CLAIM's fixed words (no folder in them),
772
- // never a start on a login the setting no longer names nor a fall to a model key the run was not claimed on. Nothing
773
- // else of the claim is read again. A run with a model key of its own, and a login other than AgentRun's own folder,
774
- // were each decided at the claim (staysInRunner: no login read for the one, LOGIN_MACHINE_NEEDS_SERVER_USER for the
775
- // other), so neither reaches here on a login. The process reads no setting or machine id.
776
- // None for a run that sends no model key (keyless: a held run, any run on a --faux runner, a faux-pinned one), whatever
777
- // its claim read: the login is a model credential like any key.
762
+ // the process names: its access token alone, read again at each ask and renewed here when it must be (near its end, or
763
+ // refused); never its folder or its refresh token. Each token is carried into the runner's redactor for this run
764
+ // (redact.ts carry) before it is handed, a renewed one too: model text that repeats it is cut from the run's journal as
765
+ // the runner writes it (runner.ts fenced), from what it stages and from its rows, as the run's own tool keys are.
766
+ // This answer is the one decision whether the run goes on the login: none, it does not. A run that sends no model key
767
+ // (keyless: a held run, any run on a --faux runner, a faux-pinned one) gets none, whatever its claim read, and no read
768
+ // of the claim's login or the setting for it: the login is a model credential like any key. Any other claim read the
769
+ // setting (staysInRunner): one that read it off is never put on it, whatever the setting says now; one that read it on
770
+ // has it read again here, at the start, with the claim's
771
+ // settings, data folder, harness and place. That read's environment is the claim's (the process's, when the runner was
772
+ // given none) with a saved gateway laid over it (withSavedGatewayDeps), not always the very one the claim read with;
773
+ // the difference can only refuse the start, never hand another folder, since the login is handed only when both reads
774
+ // name the same folder. A turn-off, or a move to another folder, between the claim and the start refuses the start in
775
+ // LOGIN_CHANGED_SINCE_CLAIM's fixed words (no folder in them), never a start on a login the setting no longer names nor
776
+ // a fall to a model key the run was not claimed on. Nothing else of the claim is read again. A keyless run, a run with
777
+ // a model key of its own and a login other than AgentRun's own folder were each decided at the claim (staysInRunner:
778
+ // no login read for the first two, LOGIN_MACHINE_NEEDS_SERVER_USER for the last), so none reaches here on a login. The
779
+ // process reads no setting or machine id.
778
780
  claudeLogin: async () => {
779
781
  if (keyless)
780
782
  return undefined;
@@ -825,7 +827,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
825
827
  const overTheDisk = disk === undefined ? undefined : openedAtUse(() => openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: disk, sweep: false, log }));
826
828
  if (overTheDisk)
827
829
  releases.push(() => overTheDisk.end());
828
- const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, toolSettings: revision.body.toolSettings, work: () => (overTheDisk === undefined ? runFolder(deps.data, run.agentId, claim.runId) : mountedFolder ?? overTheDisk.workspace()), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, undefined, launch) });
830
+ const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, toolSettings: revision.body.toolSettings, work: () => (overTheDisk === undefined ? runFolder(deps.data, run.agentId, claim.runId) : mountedFolder ?? overTheDisk.workspace()), launchInput: launch.input, hold, redact: cut, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, undefined, launch) });
829
831
  if (!made)
830
832
  return undefined;
831
833
  releases.push(() => made.release());
@@ -939,12 +941,13 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
939
941
  computer: (ask) => projectCall(async () => {
940
942
  const made = await archilOf();
941
943
  const mode = made === undefined ? 1 : 2;
944
+ const noExec = noExecRegionOf(made);
942
945
  const ws = made === undefined
943
946
  ? await openRunWorkspace({ mode: 1, agentId: run.agentId, runId: claim.runId, data: deps.data, log })
944
947
  : await openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: made, log });
945
948
  const say = typeof ask.say === "function" ? ask.say : undefined;
946
949
  const got = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, claim, agentId: run.agentId, revisionId: run.revisionId, place: launch.place, ...(reads.incarnation ? { holder: { runner: claim.runner, incarnation: reads.incarnation } } : {}) }, store, {
947
- ...deps.computerDeps, mode, workspace: ws.workspace, sealKey,
950
+ ...deps.computerDeps, mode, noExec, workspace: ws.workspace, sealKey,
948
951
  recordings: { folder: recordingsFolder(deps.data, run.agentId, claim.runId), say: (words) => say?.(cut(words)) },
949
952
  hadComputer: async () => (await ask.hadComputer()) === true,
950
953
  ...(typeof ask.turnedOff === "string" ? { turnedOff: ask.turnedOff } : {}),
@@ -973,6 +976,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
973
976
  projectComputer = got;
974
977
  projectWorkspace = ws.workspace;
975
978
  projectMode = mode;
979
+ projectNoExec = noExec;
976
980
  const { syncProject: _sync, ...exposed } = got;
977
981
  return { ...exposed, ...(exposed.computer ? { computer: projectGate.capability(exposed.computer) } : {}),
978
982
  release: (...args) => cleanProject(() => exposed.release(...args)),
@@ -1141,6 +1145,11 @@ export async function staysInRunner(deps, harness, launch, runId, isolation) {
1141
1145
  if (revision && isWorkflowRevision(revision))
1142
1146
  return STAYS;
1143
1147
  }
1148
+ // A run that sends no model key (claim-secrets.ts sendsNoModelKey) is handed no login (heldFor claudeLogin), so its claim
1149
+ // reads none: it is never refused for a login it would never be handed. A held run its model kept from running holds its
1150
+ // computer so, whatever login this machine has on.
1151
+ if (sendsNoModelKey(launch, deps.env ?? {}))
1152
+ return OFF_LOGIN;
1144
1153
  const login = await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, harness, launch.place);
1145
1154
  if (login === undefined)
1146
1155
  return OFF_LOGIN;
@@ -1206,9 +1215,9 @@ export function runChannel(socket, onClose, gate = SERVER_SLOTS, more = {}) {
1206
1215
  return channel;
1207
1216
  }
1208
1217
  /** `login`: the Claude login this run's claim read (staysInRunner), the one its runner hands the run (ClaimReads). */
1209
- function childLoop(options, slots, loopDeps, login) {
1218
+ export function childLoop(options, slots, loopDeps, login) {
1219
+ const cut = mustHold(loopDeps.redact, "A run's own process's loop");
1210
1220
  const { deps, isolation } = options;
1211
- const cut = loopDeps.redact;
1212
1221
  const log = (line) => options.log(cut(line));
1213
1222
  let channel;
1214
1223
  let child;
@@ -1291,7 +1300,10 @@ function childLoop(options, slots, loopDeps, login) {
1291
1300
  // host's default's now, where its revision names no model and a key saved since moved that default. On a --faux
1292
1301
  // runner, or pinned to the faux model, a run sends no model key (claim-secrets.ts sendsNoModelKey): its process is
1293
1302
  // handed none, not even its revision's model's.
1294
- const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, launch, claim.runId);
1303
+ // Its keys are its capped plane's (harness-loops.ts underServerCeilings), as the run's own loop reads that plane: a
1304
+ // run kept on Parallel and claimed after the server set kernel or native is handed no Parallel key.
1305
+ const capped = await underServerCeilings(claimDeps, launch, revisionRow);
1306
+ const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact }, revisionRow, capped, claim.runId);
1295
1307
  // A run that holds a model key of its own (model_key, its launch's) spends that key alone: its process is handed
1296
1308
  // none of the server's model keys, as its spec drops them from its tools' (claim-secrets.ts withoutModelKeys).
1297
1309
  // Copies: the runner's own reads (heldFor's `claimed`: what the run's learning must never keep) stay whole.
@@ -1413,6 +1425,9 @@ function childLoop(options, slots, loopDeps, login) {
1413
1425
  const reach = await mcpReachOf(deps);
1414
1426
  const init = {
1415
1427
  claim, data: deps.data, signal: loopDeps.signal, where: deps.store.where, ...(traced ? { traced: true } : {}),
1428
+ // The plane its keys were chosen by (`capped`): the process runs its tools on it, never on a later read of the
1429
+ // server's settings, which may have moved since.
1430
+ ...(capped.plane ? { plane: capped.plane } : {}),
1416
1431
  ...(reach.loopback ? { mcpLoopback: true, mcpOwn: reach.own ?? [] } : {}),
1417
1432
  ...(deps.githubApi ? { githubApi: deps.githubApi } : {}),
1418
1433
  ...(deps.githubWeb ? { githubWeb: deps.githubWeb } : {}),
@@ -189,6 +189,7 @@ function childDeps(init, store, journal, held) {
189
189
  installForClaim: heldInstall,
190
190
  // web_save's download slots are the runner's, shared by all its runs (save-slots.ts).
191
191
  saveSlots: remoteSaveSlots(channel),
192
+ ...(init.plane ? { claimedPlane: init.plane } : {}),
192
193
  ...(init.githubApi ? { githubApi: init.githubApi } : {}),
193
194
  ...(init.githubWeb ? { githubWeb: init.githubWeb } : {}),
194
195
  ...(init.githubMcpOrigin ? { githubMcpOrigin: init.githubMcpOrigin } : {}),
@@ -744,6 +744,8 @@ export function startRunner(options) {
744
744
  // loop ended interrupted on its own and the run is tried again. The next claim works its turn again.
745
745
  const cut = end.state !== "interrupted" ? undefined : closedItself ? "retry" : held.stoppedFor === "shutdown" ? "drain" : undefined;
746
746
  await release(claim, {
747
+ // Parked again with nothing written (LoopEnd `again`): the release parks the row, its words left as they stood.
748
+ ...(end.state === "parked" && end.again ? { state: "parked" } : {}),
747
749
  ...(end.state === "parked" && end.wakeAt !== undefined ? { wakeAt: end.wakeAt }
748
750
  : inARow > 0 ? { backoffUntil: now() + interruptBackoffMs * 2 ** Math.min(inARow - 1, 6) }
749
751
  : {}),
@@ -6,7 +6,8 @@ import type { EntryLike } from "../timeline/index.js";
6
6
  * platform's call ends as the run's WORKFLOW_FIRST entry says (its answer shaped, or taken back to the agent); one a
7
7
  * crash cut before its record was kept is that entry's alone, its cost unknown. A call its record says was refused
8
8
  * before any node ran (`refused`) is `refused`, whoever called it, and booked $0, while nothing was booked under its
9
- * call id (bookedUnder); one an earlier attempt spent under (a crash cut it, and its rerun was refused: at its gate, at
10
- * runLearned's check of its call nodes' tools, or the platform's at serveFirst) is `failed`, at what it booked. A
11
- * record that names no digest or caller is left out. */
9
+ * call id (bookedUnder) and every attempt of it its gate let go was closed by a refusal (openAttempts); one an attempt
10
+ * ran or spent under (a crash cut it, and its rerun was refused: at its gate, at runLearned's check of its call nodes'
11
+ * tools, or the platform's at serveFirst) is `failed`, at what it booked (callUsdOf: null on a shared or unpriced
12
+ * window, and null for an attempt cut past its record). A record that names no digest or caller is left out. */
12
13
  export declare function workflowCallsOf(entries: readonly EntryLike[]): WorkflowCall[];
@@ -5,7 +5,7 @@
5
5
  // read: a run the platform served first counts on that workflow's served side alone, one only the agent called on the
6
6
  // side of each workflow it ran (workflow-first.ts costLineOf), and a call refused before any node ran on none.
7
7
  import { WORKFLOW_CALLERS } from "../learning-cost.js";
8
- import { learnedCallEntries } from "../learned-nodes.js";
8
+ import { LEARNED_ALLOWED, LEARNED_NODES, learnedCallEntries } from "../learned-nodes.js";
9
9
  import { KINDS } from "./journal-kinds.js";
10
10
  import { callCostOf, callTurnsOf } from "./metrics.js";
11
11
  import { WORKFLOW_FIRST, WORKFLOW_FIRST_CALL } from "./workflow-first.js";
@@ -128,11 +128,35 @@ function callUsdOf(entries, callId, recordAt) {
128
128
  const window = callWindowOf(entries, callId, recordAt);
129
129
  return window ? callCostOf(entries, callId, window.from, window.to) : null;
130
130
  }
131
- /** Whether anything was booked under call `callId` (runner/metrics.ts callTurnsOf): a request named under it, or one of
132
- * host work in its window while that window is its alone. */
131
+ /** Whether anything was booked under call `callId` (runner/metrics.ts callTurnsOf, as proof): a request named under it,
132
+ * or one of host work in its window while that window is its alone, never the harness's own side request there. */
133
133
  function bookedUnder(entries, callId, recordAt) {
134
134
  const window = callWindowOf(entries, callId, recordAt);
135
- return callTurnsOf(entries, callId, window?.from ?? -1, window?.to ?? -1).size > 0;
135
+ return callTurnsOf(entries, callId, window?.from ?? -1, window?.to ?? -1, true).size > 0;
136
+ }
137
+ /** The attempts of an agent's learned_workflow call `callId` its gate let go (each allow mark, LEARNED_ALLOWED) that no
138
+ * refused record of it closed. A mark is closed by the call's next record before its next mark when that record is
139
+ * `refused` (refused at runLearned's check: it ran nothing); a record that says it ran, a next mark first (a crash cut
140
+ * the attempt before it kept a record) or none at all leaves it open: that attempt may have run and spent. `open`:
141
+ * any is. `cut`: the newest is open with no record after it, so what it spent lies past every record's window. The
142
+ * marks need no window, so this holds where a sibling call shares the call's window and its model nodes' spend, booked
143
+ * under a host label and no call id, can't be told for its own. */
144
+ function openAttempts(entries, callId) {
145
+ let open = false;
146
+ let pending = false;
147
+ for (const entry of entries) {
148
+ if (dataOf(entry).call !== callId)
149
+ continue;
150
+ if (entry.kind === LEARNED_ALLOWED) {
151
+ open ||= pending;
152
+ pending = true;
153
+ }
154
+ else if (entry.kind === LEARNED_NODES && pending) {
155
+ open ||= dataOf(entry).refused !== true;
156
+ pending = false;
157
+ }
158
+ }
159
+ return { open: open || pending, cut: pending };
136
160
  }
137
161
  /** Each learned workflow call run `entries` show (every conversation's, in log order: store-reads/journal.ts runEntries),
138
162
  * in the order the calls first kept a record, from the record that counts for each (a call run again after a park or a
@@ -140,9 +164,10 @@ function bookedUnder(entries, callId, recordAt) {
140
164
  * platform's call ends as the run's WORKFLOW_FIRST entry says (its answer shaped, or taken back to the agent); one a
141
165
  * crash cut before its record was kept is that entry's alone, its cost unknown. A call its record says was refused
142
166
  * before any node ran (`refused`) is `refused`, whoever called it, and booked $0, while nothing was booked under its
143
- * call id (bookedUnder); one an earlier attempt spent under (a crash cut it, and its rerun was refused: at its gate, at
144
- * runLearned's check of its call nodes' tools, or the platform's at serveFirst) is `failed`, at what it booked. A
145
- * record that names no digest or caller is left out. */
167
+ * call id (bookedUnder) and every attempt of it its gate let go was closed by a refusal (openAttempts); one an attempt
168
+ * ran or spent under (a crash cut it, and its rerun was refused: at its gate, at runLearned's check of its call nodes'
169
+ * tools, or the platform's at serveFirst) is `failed`, at what it booked (callUsdOf: null on a shared or unpriced
170
+ * window, and null for an attempt cut past its record). A record that names no digest or caller is left out. */
146
171
  export function workflowCallsOf(entries) {
147
172
  // The record that counts for each call (learned-nodes.ts learnedCallEntries): a rerun refused before any node ran leaves
148
173
  // the attempt that ran standing, as the call's timeline row does.
@@ -153,12 +178,16 @@ export function workflowCallsOf(entries) {
153
178
  const served = entries.findLast((entry) => entry.kind === WORKFLOW_FIRST && ["answered", "handed_back"].includes(String(entry.data?.outcome)))?.data;
154
179
  const calls = [...newest].map(([call, at]) => {
155
180
  const data = dataOf(entries[at]);
156
- // Refused before any node ran (its record's `refused`) with nothing booked under its id: it ran nothing, whatever the
157
- // run did after. Refused with something booked: an earlier attempt ran and spent, so it failed.
158
- const refused = data.refused === true && !bookedUnder(entries, call, at);
181
+ // Refused before any node ran (its record's `refused`) with nothing booked under its id and every attempt its gate let
182
+ // go closed by a refusal: it ran nothing, whatever the run did after. Refused with something booked, or with an
183
+ // attempt left open (openAttempts): that attempt ran and may have spent, so it failed.
184
+ const attempts = data.refused === true ? openAttempts(entries, call) : { open: false, cut: false };
185
+ const refused = data.refused === true && !bookedUnder(entries, call, at) && !attempts.open;
159
186
  const outcome = refused ? "refused" : data.refused === true ? "failed" : call === WORKFLOW_FIRST_CALL && served ? served.outcome : outcomeOf(data.ended);
160
- // A refused call ran nothing: its $ is 0, never a shared window's unknown (two denied calls in one pi answer).
161
- return { workflow: data.workflow, digest: data.digest, caller: data.caller, outcome, usd: refused ? 0 : callUsdOf(entries, call, at) };
187
+ // A refused call ran nothing: its $ is 0, never a shared window's unknown (two denied calls in one pi answer). One an
188
+ // attempt cut past its record failed at a cost its record's window can't hold: unknown.
189
+ const usd = refused ? 0 : attempts.cut ? null : callUsdOf(entries, call, at);
190
+ return { workflow: data.workflow, digest: data.digest, caller: data.caller, outcome, usd };
162
191
  });
163
192
  if (served && !newest.has(WORKFLOW_FIRST_CALL) && typeof served.workflow === "string" && typeof served.digest === "string") {
164
193
  calls.unshift({ workflow: served.workflow, digest: served.digest, caller: "platform", outcome: served.outcome, usd: null });
@@ -280,7 +280,7 @@ export function workflowSpecOf(deps) {
280
280
  const nodeTools = new Map();
281
281
  for (const [name, binding] of nodeBindings) {
282
282
  const booked = bookedNodeTools(binding, () => paidTools, parkAt);
283
- const tools = run?.redact ? booked.tools.map((tool) => answersCutInside(tool, run.redact)) : booked.tools;
283
+ const tools = booked.tools.map((tool) => answersCutInside(tool, redact));
284
284
  nodeTools.set(name, { tools, extensions: [defineExtension({ name: `node-tool-${name}`, tools: tools })] });
285
285
  }
286
286
  const nodePolicy = callPolicyOf(deps.store, claim.runId, claimed);
@@ -143,7 +143,6 @@ export declare const envFilePath: (path: string) => boolean;
143
143
  /** A path under a .ssh folder. */
144
144
  export declare const sshFilePath: (path: string) => boolean;
145
145
  export declare const credentialFilePath: (path: string) => boolean;
146
- export declare const commandPaths: (command: string | undefined) => string[];
147
146
  export declare const SCRUB_RULES: readonly ScrubRule[];
148
147
  /** Every module-level pattern the rules read, by name: secret-scrub.test.mjs walks each (redact/match.ts SECRET_SHAPES are scanners, linear by construction)
149
148
  * and fails on an unbounded quantifier outside its allowlist, and fails on a module-level pattern missing here. */
@@ -2313,7 +2313,7 @@ const DOCKER_AUTHS_BEFORE = 65_536;
2313
2313
  /** Each `"auths"` in the text and whether the call read a config.json are found once a text (ruling LXXIII), never
2314
2314
  * once a match: a text of many `"auth"` keys is read in linear time. */
2315
2315
  const dockerAuth = (text, ctx) => {
2316
- const read = [ctx.path, ...commandPaths(ctx.command)].some((path) => path !== undefined && DOCKER_CONFIG.test(path));
2316
+ const read = (ctx.path !== undefined && dockerConfigPath(ctx.path)) || commandNames(ctx.command, dockerConfigPath);
2317
2317
  const auths = [];
2318
2318
  if (!read)
2319
2319
  for (let at = text.indexOf(DOCKER_AUTHS); at >= 0; at = text.indexOf(DOCKER_AUTHS, at + 1))
@@ -2598,7 +2598,15 @@ const READ_TOOL = /^\s{0,8}(?:⏺\s{0,2})?Read\(([^()\s]{1,512})\)\s{0,8}$/;
2598
2598
  const readPath = (body) => READ_COMMAND.exec(body)?.[2] ?? READ_TOOL.exec(body)?.[1];
2599
2599
  /** The file a command prints whole, when it is one read alone (`cat ~/.pgpass`): its output is that file's content
2600
2600
  * (ruling LVI). */
2601
- export const commandReadPath = (command) => (command === undefined ? undefined : readPath(command));
2601
+ export const commandReadPath = (command) => (command === undefined ? undefined : factsOf(command).readPath);
2602
+ let lastCommand;
2603
+ function factsOf(command) {
2604
+ if (lastCommand?.command === command)
2605
+ return lastCommand.facts;
2606
+ const facts = { readPath: readPath(command), paths: pathWords(command), dumps: command.trim() !== "" && printsEnvironment(command), names: new Map() };
2607
+ lastCommand = { command, facts };
2608
+ return facts;
2609
+ }
2602
2610
  /** Quote and escape characters, dropped before a command line is read: a quoted script's words are the line's own
2603
2611
  * words however deep its shells nest (`bash -c "bash -c 'env'"`), and a word spelled across quotes or behind a
2604
2612
  * backslash (`e"n"v`, `\env`) reads whole. No depth is followed, so none can run out. */
@@ -2709,7 +2717,7 @@ function wholeDump(text) {
2709
2717
  /** A command's output, given apart from its command (ruling LVI): all of it is a dump when the command prints the
2710
2718
  * environment or a variable's value, alone on its line or among others. An approval outcome's head line is cut with
2711
2719
  * it (ruled so: never split on run-view's words). */
2712
- const commandDumps = (text, given) => (given !== undefined && given.trim() !== "" && printsEnvironment(given) ? wholeDump(text) : []);
2720
+ const commandDumps = (text, given) => (given !== undefined && factsOf(given).dumps ? wholeDump(text) : []);
2713
2721
  const PATH_SEPARATOR = /[\\/]/;
2714
2722
  const ENV_FILE_NAME = /^(?:\.env(?:rc)?|\.env\.[A-Za-z0-9_.-]{1,64}|[A-Za-z0-9_.-]{1,64}\.env)$/;
2715
2723
  const ENV_TEMPLATE = /\.(?:example|sample|template|tmpl|dist|defaults?|schema)$/i;
@@ -2755,12 +2763,24 @@ const COMMAND_WORD_SPLIT = /[\s|;&<>()]{1,64}/;
2755
2763
  const OPTION_NAME = /^-{1,2}[A-Za-z0-9-]{1,64}=/;
2756
2764
  const WORD_QUOTES = /["']/g;
2757
2765
  const COMMAND_MAX = 65_536;
2758
- export const commandPaths = (command) => command === undefined ? [] : command.slice(0, COMMAND_MAX).split(COMMAND_WORD_SPLIT).map((word) => word.replace(OPTION_NAME, "").replace(WORD_QUOTES, "")).filter(Boolean);
2766
+ /** Whether a command names, anywhere in its words, a path `fits` takes: asked once a command and predicate (factsOf),
2767
+ * so a call's output read string by string never walks its command's words again. `fits` is a module-level function. */
2768
+ function commandNames(command, fits) {
2769
+ if (command === undefined)
2770
+ return false;
2771
+ const { paths, names } = factsOf(command);
2772
+ let named = names.get(fits);
2773
+ if (named === undefined)
2774
+ names.set(fits, (named = paths.some(fits)));
2775
+ return named;
2776
+ }
2777
+ const dockerConfigPath = (path) => DOCKER_CONFIG.test(path);
2778
+ const pathWords = (command) => command.slice(0, COMMAND_MAX).split(COMMAND_WORD_SPLIT).map((word) => word.replace(OPTION_NAME, "").replace(WORD_QUOTES, "")).filter(Boolean);
2759
2779
  /** The text whole, its trailing blanks left out, when the caller says it is the content of a file `fits` names: the call
2760
2780
  * read that file (`ctx.path`), or its command names one anywhere (ruling LXII d: `grep app ~/.pgpass`, `jq . ~/.docker/
2761
2781
  * config.json`, `grep -v ^# .env`; an over-cut, `ls ~/.ssh/known_hosts`'s, fails closed). */
2762
2782
  const wholeText = (text, ctx, fits) => {
2763
- if (!((ctx.path !== undefined && fits(ctx.path)) || commandPaths(ctx.command).some(fits)) || DUMP_MARKER_LINE.test(text))
2783
+ if (!((ctx.path !== undefined && fits(ctx.path)) || commandNames(ctx.command, fits)) || DUMP_MARKER_LINE.test(text))
2764
2784
  return [];
2765
2785
  const end = text.trimEnd().length;
2766
2786
  return end > 0 ? [{ start: 0, end }] : [];
package/dist/server.d.ts CHANGED
@@ -99,6 +99,11 @@ export type ServeOptions = {
99
99
  * (the console, sign-in, setup, settings, MCP, triggers, hooks, ...) with a 404 before anything reads the request.
100
100
  * It has no owner: accounts and open setup are off, there being no page to sign in to. */
101
101
  apiOnly?: boolean;
102
+ /** The share host (`--share-host`, AGENTRUN_SHARE_HOST=1, share-host.ts): serve shares under /r/ alone (a share's page,
103
+ * its stored bundle, the page's assets, /r/v2/shares and /r/v2/health) and refuse every other address with a 404
104
+ * before anything reads the request. No runner beside it, no owner (accounts and open setup are off), and its share
105
+ * URLs on `publicUrl` (AGENTRUN_PUBLIC_URL): a start on an address other than loopback without one is refused. */
106
+ shareHost?: boolean;
102
107
  /** AGENTRUN_API_ONLY_MCP_ORIGINS, read as the environment's is (the serve README's API-only section); only with apiOnly. */
103
108
  apiOnlyMcpOrigins?: readonly string[];
104
109
  /** The launch hook (AGENTRUN_LAUNCH_HOOK_URL and _SECRET, trigger-launch-hook.ts): each trigger firing that would start
@@ -197,6 +202,9 @@ export type ServeOptions = {
197
202
  console?: string;
198
203
  /** How long a run's process may finish its turn after SIGTERM (default 30s): `8s`, `500ms`, `1m`. */
199
204
  drainTimeout?: string;
205
+ /** How long a cut read of a run's file waits for its cut (cut-pool.ts) before it is refused 503 (default CUT_MS). For
206
+ * tests. */
207
+ cutMs?: number;
200
208
  /** How often the runs' listings' builder looks again when it found nothing to build (run-listing.ts; default
201
209
  * LISTER_IDLE_MS). `Infinity`: it builds only when Serve.listingSettled asks, so a test reads what a list builds alone. */
202
210
  listerIdleMs?: number;
@@ -261,7 +269,8 @@ export type ServeOptions = {
261
269
  * command row is written, with the run's id and the message's text, so a test can hold a message at the run's door while
262
270
  * the run's state changes under it (runs-over-store.ts message). */
263
271
  beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
264
- /** A test's seam: the scrubber GET /runs/{id}/export cuts with (run-export.ts), in place of secret-cut.ts scrub. */
272
+ /** A test's seam: the scrubber GET /runs/{id}/export cuts with (run-export.ts), and a share host scrubs an upload with
273
+ * (share-host.ts), in place of secret-cut.ts scrub. */
265
274
  shareScrub?: CutScrub;
266
275
  /** A test's seam: step 2 of DELETE /agents/{id} (agent-delete.ts) in place of the learning module's deleteLearning over
267
276
  * the agent's learning (learn/delete.ts), the server's own. */