@parcha/agentrun-serve 0.1.0-beta.61 → 0.1.0-beta.63

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 (228) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +128 -20
  3. package/dist/adapters.js +4 -2
  4. package/dist/agent-delete.d.ts +3 -3
  5. package/dist/agent-delete.js +50 -4
  6. package/dist/api-only.d.ts +4 -0
  7. package/dist/api-only.js +5 -1
  8. package/dist/archil-settings.d.ts +9 -0
  9. package/dist/archil-settings.js +8 -1
  10. package/dist/bash-read-only.d.ts +3 -0
  11. package/dist/bash-read-only.js +6 -3
  12. package/dist/chatgpt-plan.d.ts +33 -8
  13. package/dist/chatgpt-plan.js +141 -24
  14. package/dist/claude-login.d.ts +12 -5
  15. package/dist/claude-login.js +28 -3
  16. package/dist/cli.js +19 -8
  17. package/dist/composio-triggers.d.ts +9 -3
  18. package/dist/computers.d.ts +3 -0
  19. package/dist/computers.js +2 -1
  20. package/dist/console/assets/{backend-C9ffXUR5.js → backend-BxQ2G1M0.js} +2 -2
  21. package/dist/console/assets/index-C8Y5Zl8x.js +639 -0
  22. package/dist/console/assets/share-CjBJ_rxP.js +6 -0
  23. package/dist/console/assets/{styles-fjQBFfMv.css → styles-D0SufbzK.css} +1 -1
  24. package/dist/console/index.html +3 -3
  25. package/dist/console/share.html +3 -3
  26. package/dist/cut-pool.d.ts +14 -0
  27. package/dist/cut-pool.js +98 -0
  28. package/dist/cut-worker.d.ts +14 -0
  29. package/dist/cut-worker.js +16 -0
  30. package/dist/decisions.d.ts +4 -0
  31. package/dist/decisions.js +9 -1
  32. package/dist/env-switch.d.ts +3 -0
  33. package/dist/env-switch.js +3 -0
  34. package/dist/harness-opencode/adapter.d.ts +3 -1
  35. package/dist/harness-opencode/adapter.js +6 -2
  36. package/dist/harness-opencode/harness.d.ts +4 -0
  37. package/dist/harness-opencode/harness.js +6 -1
  38. package/dist/harness-table.d.ts +7 -0
  39. package/dist/harness-table.js +6 -3
  40. package/dist/host-tools.d.ts +18 -3
  41. package/dist/host-tools.js +27 -4
  42. package/dist/import.d.ts +8 -1
  43. package/dist/import.js +36 -5
  44. package/dist/key-check.js +22 -8
  45. package/dist/learn/ledger.d.ts +37 -16
  46. package/dist/learn/ledger.js +56 -24
  47. package/dist/learn/promote.d.ts +4 -1
  48. package/dist/learned-nodes.d.ts +2 -1
  49. package/dist/learned-nodes.js +2 -1
  50. package/dist/learning-cost.d.ts +5 -3
  51. package/dist/learning-model.js +7 -5
  52. package/dist/learning-work.d.ts +69 -0
  53. package/dist/learning-work.js +148 -0
  54. package/dist/mcp-gateway.d.ts +24 -0
  55. package/dist/mcp-gateway.js +97 -8
  56. package/dist/mcp-servers-store.d.ts +7 -10
  57. package/dist/mcp-servers-store.js +15 -9
  58. package/dist/native/cli.js +5 -1
  59. package/dist/ollama-provider.d.ts +10 -3
  60. package/dist/ollama-provider.js +17 -7
  61. package/dist/openapi.js +51 -20
  62. package/dist/otel/tracer.d.ts +6 -3
  63. package/dist/otel/tracer.js +24 -6
  64. package/dist/page.d.ts +7 -0
  65. package/dist/page.js +17 -4
  66. package/dist/place.d.ts +25 -9
  67. package/dist/place.js +37 -11
  68. package/dist/print.d.ts +3 -2
  69. package/dist/print.js +8 -6
  70. package/dist/run-export.js +7 -4
  71. package/dist/run-launch.d.ts +6 -1
  72. package/dist/run-launch.js +26 -6
  73. package/dist/run-model-key.d.ts +2 -1
  74. package/dist/run-model-key.js +2 -1
  75. package/dist/run-reads-over-store.d.ts +7 -0
  76. package/dist/run-reads-over-store.js +32 -4
  77. package/dist/run-view.js +9 -3
  78. package/dist/runnable.d.ts +6 -3
  79. package/dist/runnable.js +21 -11
  80. package/dist/runner/adapter-loop.js +95 -28
  81. package/dist/runner/adapter-run-spec.d.ts +20 -4
  82. package/dist/runner/adapter-run-spec.js +64 -30
  83. package/dist/runner/adapters/index.d.ts +6 -0
  84. package/dist/runner/adapters/index.js +5 -1
  85. package/dist/runner/adapters/pi.d.ts +42 -3
  86. package/dist/runner/adapters/pi.js +114 -13
  87. package/dist/runner/audit.d.ts +8 -2
  88. package/dist/runner/audit.js +34 -18
  89. package/dist/runner/book-cut.d.ts +6 -0
  90. package/dist/runner/book-cut.js +38 -0
  91. package/dist/runner/claim-secrets.d.ts +12 -5
  92. package/dist/runner/claim-secrets.js +28 -12
  93. package/dist/runner/cli-run-spec.d.ts +0 -2
  94. package/dist/runner/cli-run-spec.js +54 -25
  95. package/dist/runner/dispatch.js +2 -0
  96. package/dist/runner/harness-loops.d.ts +5 -0
  97. package/dist/runner/harness-loops.js +4 -1
  98. package/dist/runner/held.d.ts +6 -3
  99. package/dist/runner/learned-first.d.ts +5 -0
  100. package/dist/runner/learned-first.js +1 -1
  101. package/dist/runner/learning-end.d.ts +15 -8
  102. package/dist/runner/learning-end.js +23 -7
  103. package/dist/runner/live-ticker.js +3 -1
  104. package/dist/runner/loop-contract.d.ts +8 -1
  105. package/dist/runner/main.js +2 -0
  106. package/dist/runner/mcp-run.d.ts +5 -0
  107. package/dist/runner/mcp-run.js +18 -0
  108. package/dist/runner/meta-tools.js +4 -4
  109. package/dist/runner/metrics.d.ts +4 -2
  110. package/dist/runner/metrics.js +5 -3
  111. package/dist/runner/model-route.d.ts +4 -0
  112. package/dist/runner/model-route.js +1 -1
  113. package/dist/runner/native-loop.js +2 -2
  114. package/dist/runner/pr-checkout.d.ts +12 -0
  115. package/dist/runner/pr-checkout.js +21 -2
  116. package/dist/runner/promotion.d.ts +9 -2
  117. package/dist/runner/promotion.js +79 -28
  118. package/dist/runner/reflect-hook.d.ts +7 -0
  119. package/dist/runner/reflect-hook.js +2 -1
  120. package/dist/runner/run-child-host.d.ts +10 -6
  121. package/dist/runner/run-child-host.js +65 -41
  122. package/dist/runner/run-child.js +2 -0
  123. package/dist/runner/runner.d.ts +9 -0
  124. package/dist/runner/runner.js +158 -25
  125. package/dist/runner/store-port.d.ts +4 -1
  126. package/dist/runner/workflow-calls.d.ts +4 -3
  127. package/dist/runner/workflow-calls.js +41 -12
  128. package/dist/runner/workflow-first.js +4 -3
  129. package/dist/runner/workflow-loop.js +13 -1
  130. package/dist/runner/workflow-spec.js +1 -1
  131. package/dist/secret-cut.d.ts +4 -0
  132. package/dist/secret-cut.js +1 -1
  133. package/dist/secret-rules.d.ts +2 -1
  134. package/dist/secret-rules.js +88 -24
  135. package/dist/server.d.ts +10 -1
  136. package/dist/server.js +131 -44
  137. package/dist/share-host.d.ts +111 -0
  138. package/dist/share-host.js +669 -0
  139. package/dist/store/schema.d.ts +4 -3
  140. package/dist/store/schema.js +4 -3
  141. package/dist/store/seal.d.ts +8 -2
  142. package/dist/store/seal.js +13 -2
  143. package/dist/store/sqlite/learning-rows.js +2 -1
  144. package/dist/store/sqlite/run-patch.js +4 -4
  145. package/dist/store/sqlite/store.js +28 -4
  146. package/dist/store/store.d.ts +5 -0
  147. package/dist/store-reads/analytics.d.ts +15 -0
  148. package/dist/store-reads/analytics.js +17 -0
  149. package/dist/store-reads/journal.d.ts +2 -0
  150. package/dist/store-reads/journal.js +1 -1
  151. package/dist/store-reads/learning.d.ts +4 -3
  152. package/dist/store-reads/learning.js +62 -18
  153. package/dist/store-view.d.ts +3 -0
  154. package/dist/store-view.js +18 -1
  155. package/dist/suggestions.js +32 -3
  156. package/dist/templates.d.ts +3 -1
  157. package/dist/templates.js +7 -3
  158. package/dist/tool-gate.d.ts +25 -9
  159. package/dist/tool-gate.js +58 -19
  160. package/dist/tool-list.d.ts +4 -0
  161. package/dist/tool-list.js +4 -0
  162. package/dist/tool-plane.d.ts +1 -0
  163. package/dist/tool-plane.js +6 -2
  164. package/dist/tools.js +2 -2
  165. package/dist/trigger-composio.js +1 -1
  166. package/dist/webhooks.d.ts +3 -0
  167. package/dist/webhooks.js +5 -0
  168. package/dist/workspace/archil-claim.d.ts +7 -3
  169. package/dist/workspace/archil-claim.js +13 -5
  170. package/dist/workspace/archil-mount-credential.d.ts +6 -0
  171. package/dist/workspace/archil-mount-credential.js +11 -0
  172. package/dist/workspace/attach.js +22 -5
  173. package/dist/workspace/computer-deps.d.ts +5 -3
  174. package/dist/workspace/computer-deps.js +11 -9
  175. package/dist/workspace/computer-for-claim.d.ts +6 -2
  176. package/dist/workspace/computer-for-claim.js +43 -12
  177. package/dist/workspace/computer-janitor.d.ts +7 -4
  178. package/dist/workspace/computer-janitor.js +7 -4
  179. package/dist/workspace/computer-kept.d.ts +7 -1
  180. package/dist/workspace/computer-kept.js +7 -1
  181. package/dist/workspace/kind-skills/desktop/SKILL.md +17 -4
  182. package/dist/workspace/mount-revoke-left.d.ts +16 -4
  183. package/dist/workspace/mount-revoke-left.js +42 -22
  184. package/dist/workspace/resolve-computer.d.ts +11 -5
  185. package/dist/workspace/resolve-computer.js +22 -13
  186. package/dist/workspace/run-end-computers.js +1 -1
  187. package/dist/workspace/run-tools.d.ts +10 -3
  188. package/dist/workspace/run-tools.js +5 -4
  189. package/dist/wrapped.d.ts +29 -2
  190. package/dist/wrapped.js +20 -3
  191. package/launcher/agentrun-serve +1 -1
  192. package/package.json +12 -12
  193. package/templates/kyb/agent.md +7 -1
  194. package/templates/kyb/evals/list-file-fuzzy-alias/case.yaml +10 -0
  195. package/templates/kyb/evals/list-file-fuzzy-alias/fixtures/web.json +58 -0
  196. package/templates/kyb/evals/list-file-fuzzy-alias/graders/finds-the-transliteration.md +17 -0
  197. package/templates/kyb/evals/list-file-fuzzy-alias/graders/greps-the-files.md +11 -0
  198. package/templates/kyb/evals/list-file-fuzzy-alias/graders/saves-the-uk-file.md +8 -0
  199. package/templates/kyb/evals/list-file-fuzzy-alias/prompt.md +7 -0
  200. package/templates/kyb/evals/list-file-hit/case.yaml +10 -0
  201. package/templates/kyb/evals/list-file-hit/fixtures/web.json +58 -0
  202. package/templates/kyb/evals/list-file-hit/graders/greps-the-files.md +11 -0
  203. package/templates/kyb/evals/list-file-hit/graders/hits-by-company-number.md +18 -0
  204. package/templates/kyb/evals/list-file-hit/graders/saves-the-uk-file.md +8 -0
  205. package/templates/kyb/evals/list-file-hit/prompt.md +7 -0
  206. package/templates/kyb/evals/list-file-no-hit/case.yaml +10 -0
  207. package/templates/kyb/evals/list-file-no-hit/fixtures/web.json +58 -0
  208. package/templates/kyb/evals/list-file-no-hit/graders/greps-the-files.md +11 -0
  209. package/templates/kyb/evals/list-file-no-hit/graders/no-hit-by-whole-file.md +12 -0
  210. package/templates/kyb/evals/list-file-no-hit/graders/saves-the-uk-file.md +8 -0
  211. package/templates/kyb/evals/list-file-no-hit/prompt.md +7 -0
  212. package/templates/kyb/evals/list-file-short-name/case.yaml +9 -0
  213. package/templates/kyb/evals/list-file-short-name/fixtures/web.json +58 -0
  214. package/templates/kyb/evals/list-file-short-name/graders/finds-the-short-name.md +19 -0
  215. package/templates/kyb/evals/list-file-short-name/graders/greps-the-files.md +11 -0
  216. package/templates/kyb/evals/list-file-short-name/graders/saves-the-uk-file.md +8 -0
  217. package/templates/kyb/evals/list-file-short-name/prompt.md +7 -0
  218. package/templates/kyb/evals/list-file-split-name/case.yaml +11 -0
  219. package/templates/kyb/evals/list-file-split-name/fixtures/web.json +58 -0
  220. package/templates/kyb/evals/list-file-split-name/graders/finds-the-director.md +18 -0
  221. package/templates/kyb/evals/list-file-split-name/graders/greps-the-files.md +11 -0
  222. package/templates/kyb/evals/list-file-split-name/graders/saves-the-uk-file.md +8 -0
  223. package/templates/kyb/evals/list-file-split-name/prompt.md +7 -0
  224. package/templates/kyb/kyb.schema.json +2 -2
  225. package/templates/kyb/rules/SANCTIONS.md +82 -13
  226. package/dist/console/assets/index-BnZV3lvW.js +0 -639
  227. package/dist/console/assets/share-B1o5mJ56.js +0 -6
  228. /package/dist/console/assets/{styles-D_znYrHR.js → styles-BGZxYkky.js} +0 -0
@@ -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
  }
@@ -62,6 +62,10 @@ export interface ModelRoute {
62
62
  readonly thinkingLevelMap?: ThinkingLevelMap;
63
63
  readonly translatedChatCompletions?: boolean;
64
64
  };
65
+ /** The model's context window in tokens, from the catalog entry (an Ollama model's, its num_ctx), on every wire: the
66
+ * session's window (SessionSpec.contextWindow), which each tool result is held to its share of. Absent when the
67
+ * catalog names none. */
68
+ readonly contextWindow?: number;
65
69
  /** A request's price from its usage (the proxy's booking reads it): pi-ai's calculateCost, tiers included. */
66
70
  readonly price?: (model: string, usage: RouteUsage) => number | null;
67
71
  /** The upstream fetch: the route's own, for a model that does not speak Messages. Absent: the network. */
@@ -50,7 +50,7 @@ export async function routeOf(model, env = process.env, tier = "default", wires
50
50
  // The settings serve registered for a gateway model, carried on either wire, so pi's session reads the same model whether
51
51
  // it speaks Messages or Responses to the gateway.
52
52
  const settings = { ...sees, ...(target.reasoning !== undefined ? { reasoning: target.reasoning } : {}), ...(target.contextWindow ? { contextWindow: target.contextWindow } : {}), ...(target.maxTokens ? { maxTokens: target.maxTokens } : {}), ...(target.thinkingLevelMap ? { thinkingLevelMap: target.thinkingLevelMap } : {}) };
53
- const route = { model: chosen.model.modelId, named: `${chosen.model.provider}/${chosen.model.modelId}`, price, cost: target.cost, ...(unpriced.has(chosen.model.modelId) ? { unpriced: true } : {}), outputCeiling: target.maxTokens ?? null, like: sees };
53
+ const route = { model: chosen.model.modelId, named: `${chosen.model.provider}/${chosen.model.modelId}`, price, cost: target.cost, ...(unpriced.has(chosen.model.modelId) ? { unpriced: true } : {}), outputCeiling: target.maxTokens ?? null, ...(target.contextWindow ? { contextWindow: target.contextWindow } : {}), like: sees };
54
54
  // An Anthropic model speaks Messages itself: the network, at its catalog origin, its key read by name per request.
55
55
  // Its requests name the claim's run, turn and attempt only where that origin is serve's own gateway (gatewayHeadersAt).
56
56
  if (chosen.model.provider === "anthropic") {
@@ -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;
@@ -61,6 +61,18 @@ export declare function prCheckoutForClaim(deps: Pick<AdapterSpecDeps, "store" |
61
61
  }, signal?: AbortSignal, held?: (part: {
62
62
  end(): Promise<void>;
63
63
  }) => void, kind?: Checkout): Promise<PrCheckout>;
64
+ /** A claim's checkout on a Mode 2 server whose Archil region `region` has no serverless exec (archil-settings.ts
65
+ * noExecRegionOf), where the disk runs no command (its every exec answers "Exec is not enabled"): made as
66
+ * prCheckoutForClaim makes it, the same script and the token on its stdin, in the run's computer through its own exec,
67
+ * once it has mounted the run's folder (`mounted`: the run's Workspace attached to it, run-tools.ts RunTools.workspace
68
+ * where the run's shell is the computer's). The mount holds the disk's write delegation, and the fetch writes through
69
+ * it. With no computer that mounts the folder, none is made: the run is told why, and `say` puts the fix (a sandbox
70
+ * computer) on its timeline. */
71
+ export declare function checkoutWhereNoExec(deps: Parameters<typeof prCheckoutForClaim>[0], mounted: Workspace | undefined, region: string, launch: Parameters<typeof prCheckoutForClaim>[2], redact: {
72
+ hold(values: readonly string[]): void;
73
+ }, signal: AbortSignal | undefined, held: (part: {
74
+ end(): Promise<void>;
75
+ }) => void, kind: Checkout, say?: (words: string) => void): Promise<PrCheckout>;
64
76
  /** The file in the checkout's .git that lists its files, one path a line (git ls-tree), so an agent with `read` and no
65
77
  * shell can still find what to open. */
66
78
  export declare const FILE_LIST = "agentrun-files";
@@ -2,14 +2,17 @@
2
2
  // definition says `checkout: pull_request` (a template's manifest sets it). The agent then starts with the repository at
3
3
  // the pull request's head in `repo/` of its folder, its base and their merge base fetched beside it, and never holds a
4
4
  // GitHub token: the fetch is the server's own, one exec on the run's Workspace (Mode 1 a process on this machine, Mode 2
5
- // Archil's serverless exec over the run's folder), never a command of the agent's.
5
+ // Archil's serverless exec over the run's folder), never a command of the agent's. On an Archil region with no serverless
6
+ // exec (archil-settings.ts noExecRegionOf) the disk runs no command: the fetch runs in the run's computer, through its
7
+ // own exec, once it has mounted the run's folder (checkoutWhereNoExec), and a run with no such computer has none.
6
8
  //
7
9
  // What it reads of the run: its first message's payload tag alone (github.ts githubPullOf), which the server wrote from a
8
10
  // signed GitHub delivery: the repository, the pull request's number, its head and its base. Nothing else names a
9
11
  // repository to fetch.
10
12
  //
11
13
  // The credential: an installation token of the server's GitHub App, minted for that one repository with
12
- // {contents: "read"} alone, handed to the exec on its stdin (Archil's: a spill file deleted on every path), turned there
14
+ // {contents: "read"} alone, handed to the exec on its stdin (Archil's: a spill file deleted on every path; a computer's:
15
+ // process.write to the process's stdin), turned there
13
16
  // into an Authorization header in git's environment (GIT_CONFIG_COUNT), scoped to GitHub's site. It is never in argv,
14
17
  // .git/config, the remote's URL, the run's folder, an env the agent's commands get, or the log (it joins the run's
15
18
  // redactor). No App, or one not installed on the repository: the fetch is anonymous, which a public repository answers.
@@ -22,6 +25,7 @@
22
25
  // tools can read the change instead. The checkout is removed when the claim lets go (spec-holds.ts), and made again by
23
26
  // the next claim of the same run.
24
27
  import { randomUUID } from "node:crypto";
28
+ import { noExecWords } from "../archil-settings.js";
25
29
  import { GITHUB_WEB, githubPullOf, githubTargetOf } from "../github.js";
26
30
  import { isObject } from "../validate.js";
27
31
  import { COMMAND_MAX_MS } from "../workspace/archil-exec.js";
@@ -178,6 +182,21 @@ export async function prCheckoutForClaim(deps, workspace, launch, redact, signal
178
182
  return repoCheckout({ ...common, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
179
183
  return prCheckout(common);
180
184
  }
185
+ /** A claim's checkout on a Mode 2 server whose Archil region `region` has no serverless exec (archil-settings.ts
186
+ * noExecRegionOf), where the disk runs no command (its every exec answers "Exec is not enabled"): made as
187
+ * prCheckoutForClaim makes it, the same script and the token on its stdin, in the run's computer through its own exec,
188
+ * once it has mounted the run's folder (`mounted`: the run's Workspace attached to it, run-tools.ts RunTools.workspace
189
+ * where the run's shell is the computer's). The mount holds the disk's write delegation, and the fetch writes through
190
+ * it. With no computer that mounts the folder, none is made: the run is told why, and `say` puts the fix (a sandbox
191
+ * computer) on its timeline. */
192
+ export async function checkoutWhereNoExec(deps, mounted, region, launch, redact, signal, held, kind, say) {
193
+ if (mounted)
194
+ return prCheckoutForClaim(deps, mounted, launch, redact, signal, held, kind);
195
+ const why = `${noExecWords(region)}, so the server checks a repository out only in a computer that mounts the run's folder`;
196
+ say?.(`No checkout in repo/: ${why}, and this run has none. Give the agent a sandbox computer (a box) to get its checkout.`);
197
+ const instead = kind === "pull_request" ? "Read the change through the GitHub tools if you have them." : "Read it through the GitHub tools if you have them, else say that you could not read it.";
198
+ return noCheckout(`No checkout was made, so there is no ${CHECKOUT_DIR}/ folder: ${why}, and this run has none. ${instead}`);
199
+ }
181
200
  /** The file in the checkout's .git that lists its files, one path a line (git ls-tree), so an agent with `read` and no
182
201
  * shell can still find what to open. */
183
202
  export const FILE_LIST = "agentrun-files";
@@ -3,6 +3,7 @@ import type { Context } from "@earendil-works/chord/context";
3
3
  import type { LearnedWorkflow } from "../learning.js";
4
4
  import { type RunLaunch } from "../run-launch.js";
5
5
  import { type Store } from "../store/store.js";
6
+ import { type AtRunEnd } from "../learning-work.js";
6
7
  import { type Recorded, type ReplayCalls, type Skipped } from "../learn/replay-calls.js";
7
8
  import { type Json } from "../validate.js";
8
9
  import { type CheckBar, type CheckRecord, type CheckTurns, type Compared, type PromotionRecord, recordPromotion, type ReplayOutcomes, type ReplayScore } from "../learn/promote.js";
@@ -17,9 +18,15 @@ export declare const REPLAY_LAUNCH_GRACE_MS: number;
17
18
  export interface PromotionDeps {
18
19
  readonly store: Store;
19
20
  readonly admitAuxiliary?: AuxiliaryAdmitter;
20
- /** Why model spend beside the claimed run is skipped (claim-secrets.ts claimSpendOff): a replay check starts runs with
21
- * no caller's key. Absent: it runs. */
21
+ /** Why model spend beside the claimed run is skipped (claim-secrets.ts claimSpendOff). Absent: it runs. */
22
22
  readonly spendOff?: (what: string) => string | undefined;
23
+ /** Whether the claim holds its run's own model key now (claim-secrets.ts keyedNow): its check's replay runs then spend
24
+ * on that key, started at the run's end (`atEnd`) out of what its cap leaves. Absent: never. */
25
+ readonly keyed?: () => boolean;
26
+ /** Where the claim queues what starts at its run's end (learning-work.ts atRunEnd). */
27
+ readonly atEnd?: AtRunEnd;
28
+ /** Set on a check started from `atEnd`: it is not queued again. */
29
+ readonly ending?: true;
23
30
  readonly agentId: string;
24
31
  /** The run being claimed: never one of its own check's inputs. Absent: no run is claimed (a person's replay, and its
25
32
  * read): no run served first to keep, none whose per_run MCP credentials a replay is handed. */
@@ -50,7 +50,9 @@ import { LEARNED_WORKFLOW_TOOL } from "../learned-workflow.js";
50
50
  import { launchBody, readLaunchBody } from "../run-launch.js";
51
51
  import { uuidv7 } from "../ids.js";
52
52
  import { FINAL_STATES, RunFinal, RunPurged, StoreConstraint } from "../store/store.js";
53
- import { openRunMcpAuth, sealRunMcpAuth } from "../store/seal.js";
53
+ import { openRunLaunch, sealHandedLaunch } from "../store/seal.js";
54
+ import { LEARNING_CHILD_MS, learningChildrenOf, noteLearningChild, RUN_CAP_MIN_USD } from "../learning-work.js";
55
+ import { roomAtEndOf } from "./learning-end.js";
54
56
  import { isCliRecord, piShaped, runEntries, runTimeline } from "../store-reads/journal.js";
55
57
  import { pinAnnotations, recordedCalls, replayCalls, SKIPPED_WRITE, toolClassOf, toolWord, unmarkedWords } from "../learn/replay-calls.js";
56
58
  import { listed } from "../learning-words.js";
@@ -344,12 +346,13 @@ const checkable = (deps, row) => row.id !== deps.runId && agentRun(row) && row.a
344
346
  * never push them out of the read. And `audited`: an audit hold's disagreeing shadow runs (auditInputsOf), each ended.
345
347
  * Of those, the ones whose input `workflow` takes (fits), each with its launch read back; one with an uploaded file is
346
348
  * never an input. With how many of the agent's runs it looked at (`looked`) and why each it looked at is no input
347
- * (`unfit`, `files`). Every one of them a run on no named disk (one on a named disk learns nothing, learn/learning-of.ts)
348
- * since the agent's learning's reset (sinceReset), the named and audited ones included. */
349
+ * (`unfit`, `files`). Every one of them a run of the agent's own (the named and audited ones are read by bare id, so a
350
+ * record naming another agent's run never makes it an input) on no named disk (one on a named disk learns nothing,
351
+ * learn/learning-of.ts) since the agent's learning's reset (sinceReset). */
349
352
  async function checkInputs(deps, workflow, pick, audited = []) {
350
353
  const { resolveSchemaForWorkflow } = await import("@parcha/agentrun-dsl");
351
354
  const since = await sinceReset(deps.store, deps.agentId);
352
- const learns = (row) => (row.disk ?? null) === null && since(row);
355
+ const learns = (row) => row.agentId === deps.agentId && (row.disk ?? null) === null && since(row);
353
356
  const named = (await Promise.all(pick.of.map((id) => deps.store.runs.get(id)))).filter((row) => row !== undefined && checkable(deps, row) && learns(row));
354
357
  const last = pick.n ? await lastOwnRuns(deps.store, deps.agentId, pick.n + pick.of.length, deps.runId) : [];
355
358
  const own = [...named, ...last.filter((row) => !pick.of.includes(row.id)).slice(0, pick.n)];
@@ -382,11 +385,20 @@ async function startCheck(deps, workflow, digest) {
382
385
  log(`workflow-first: ${PROJECT_REPLAY_REFUSED}`);
383
386
  return;
384
387
  }
385
- // Its replay runs are runs the runner starts, on no caller's key: skipped where the claimed run brought its own key or
386
- // the server holds none (claimSpendOff).
388
+ // Its replay runs are runs the runner starts: on the claimed run's own key while its claim holds it, else on the
389
+ // server's; skipped where the run's key was erased, or the server holds none (claimSpendOff).
387
390
  const off = deps.spendOff?.("A learned workflow's replay check");
388
391
  if (off)
389
392
  return void log(`workflow-first: ${off} ${workflow.name} at ${digest} is not checked and does not serve this run`);
393
+ // On the run's own key it starts at the run's end, out of what the run's cap leaves then (keyedCapOf): never beside
394
+ // the run's own turn, which it would leave no room. Only where the runner can seal the key for its runs.
395
+ const keyed = deps.keyed?.() === true;
396
+ if (keyed && !deps.ending) {
397
+ if (!deps.atEnd || !deps.sealKey || !deps.runId)
398
+ return void log(`workflow-first: ${workflow.name} at ${digest} is not checked on this claim: its runs would spend on this run's own key, which this claim cannot hand them; it does not serve this run`);
399
+ deps.atEnd.later(() => startCheck({ ...deps, ending: true }, workflow, digest));
400
+ return void log(`workflow-first: ${workflow.name} at ${digest} is new: it is checked at this run's end, on this run's own key, out of what its cap leaves then; it does not serve this run`);
401
+ }
390
402
  // Only the agent's newest revision is checked: a run pinned to an older save lays an older text.
391
403
  const newest = deps.newest ? await deps.newest(workflow.name) : undefined;
392
404
  if (newest !== undefined && newest !== digest) {
@@ -416,8 +428,15 @@ async function startCheck(deps, workflow, digest) {
416
428
  await stopUnchecked(deps, workflow.name, digest, bar, why, (was) => was === undefined);
417
429
  return;
418
430
  }
431
+ // Each keyed replay's share of what the run's cap leaves; too little for each, it drops (`no_budget`), named as the
432
+ // run's learning work so its learning_work reads ended, and nothing is reserved: a later claim checks it.
433
+ const capUsd = keyed ? await keyedCapOf(deps, inputs.length) : undefined;
434
+ if (capUsd === null) {
435
+ await noteLearningChild(store.settings, deps.runId, { run: null, kind: "replay", at: (deps.now ?? Date.now)(), keyed: true, dropped: "no_budget" });
436
+ return void log(`workflow-first: ${workflow.name} at ${digest} is not checked: what this run's cap leaves is too little for ${plural(inputs.length, "replay run")} on its own key, or not known (no_budget); it does not serve this run`);
437
+ }
419
438
  const said = `checking it on ${plural(inputs.length, "input")} of the agent's last ${plural(bar.compile_after, "completed run")} against its own answers`;
420
- const reserved = await reserve(deps, workflow, digest, inputs, said, (was) => was === undefined, bar);
439
+ const reserved = await reserve(deps, workflow, digest, inputs, said, (was) => was === undefined, bar, keyed ? { capUsd } : undefined);
421
440
  if (!reserved.won) {
422
441
  log(`workflow-first: ${workflow.name} at ${digest}: another claim's decision on it came first; it does not serve this run`);
423
442
  return;
@@ -685,16 +704,30 @@ export async function decideCheck(deps, name, digest, bar, read, still, extra) {
685
704
  * now and no other revision of the workflow replays, in the one guarded write. Only the writer that kept it starts them:
686
705
  * a claim of the same digest, or of another revision, or a person's ask, at once, starts none. A claim's (startCheck) and
687
706
  * a person's (askReplay) are this one reservation. */
688
- async function reserve(deps, workflow, digest, inputs, reason, still, check) {
707
+ async function reserve(deps, workflow, digest, inputs, reason, still, check, keyed) {
689
708
  const now = deps.now ?? Date.now;
690
709
  const ids = inputs.map(() => uuidv7());
691
- const launch = replayLaunchOf(deps);
710
+ const launch = replayLaunchOf(deps, keyed);
692
711
  const reserved = await recordPromotion(deps.store.learning, deps.agentId, { workflow: workflow.name, digest, at: iso(now()), decided: "replaying", reason, runs: ids, inputs: inputs.map((one) => one.run), replay_id: uuidv7(), launch, ...seedOf(deps), check }, (was, items) => still(was) && replayingOf(items, workflow.name, digest).length === 0);
693
712
  if (reserved.won)
694
713
  for (const [i, one] of inputs.entries())
695
- await startReplay(deps, workflow, digest, one.run, one.launch, ids[i], launch);
714
+ await startReplay(deps, workflow, digest, one.run, one.launch, ids[i], launch, deps.runId);
696
715
  return reserved;
697
716
  }
717
+ /** The cap of each of `n` replay runs of a check on the claimed run's own key, at that run's end: what its cap leaves
718
+ * then (learning-end.ts roomAtEndOf: its turns, its compile turn, and the learning work it started already), shared
719
+ * among them to a millionth. Undefined for a run with no cap (its replays have none either). Null where that share is
720
+ * under a run's smallest cap, or what it spent is not known: the check drops (`no_budget`). */
721
+ async function keyedCapOf(deps, n) {
722
+ const capUsd = deps.launch.maxCostUsd;
723
+ if (capUsd === undefined || !deps.runId)
724
+ return undefined;
725
+ const room = await roomAtEndOf(deps.store, deps.runId, capUsd);
726
+ if (room === null)
727
+ return null;
728
+ const each = Math.floor((room / n) * 1e6 + 1e-6) / 1e6;
729
+ return each < RUN_CAP_MIN_USD ? null : each;
730
+ }
698
731
  /** How many of a connected agent's reserved native turns its check gives back in a row (failed, a learned workflow or
699
732
  * nested call in it, redacted evidence, no shadow report, or a shadow that did not answer; never a cancel, and a turn
700
733
  * that lands starts the count again) before it holds the draft, never promoted and never stopped for good, for the
@@ -866,9 +899,10 @@ async function setAside(deps, pending) {
866
899
  /** The launch a replay's runs all run with (PromotionRecord.launch), chosen once by the claim or person reserving it:
867
900
  * `deps.launch` as a replay run takes it (a claim's claimed run's; a person's ask makes one now), the revision it runs,
868
901
  * and the claimed run as the one whose per_run MCP credentials its runs are handed, when the server can seal them. A
869
- * person's ask claims no run, so an owner's replay runs are handed none. */
870
- function replayLaunchOf(deps) {
871
- const { launch } = deps;
902
+ * person's ask claims no run, so an owner's replay runs are handed none. `keyed`: its runs spend on the claimed run's own
903
+ * model key, each capped at `capUsd` (keyedCapOf; none for a run with no cap), never at the claimed run's whole cap. */
904
+ function replayLaunchOf(deps, keyed) {
905
+ const launch = keyed ? { ...deps.launch, maxCostUsd: keyed.capUsd } : deps.launch;
872
906
  const base = {
873
907
  input: null,
874
908
  title: "",
@@ -885,7 +919,7 @@ function replayLaunchOf(deps) {
885
919
  ...(launch.learning ? { learning: launch.learning } : {}),
886
920
  ...(launch.archilDisk ? { archilDisk: launch.archilDisk } : {}),
887
921
  };
888
- return { revision: deps.revisionId, body: launchBody(base), ...((deps.sealKey || held()) && deps.runId ? { handed_from: deps.runId } : {}) };
922
+ return { revision: deps.revisionId, body: launchBody(base), ...((deps.sealKey || held()) && deps.runId ? { handed_from: deps.runId } : {}), ...(keyed ? { keyed: true } : {}) };
889
923
  }
890
924
  /** Whether `was`, a digest's newest record now, is still the replay `record` reserved: replaying, under the same replay
891
925
  * id. A replay settled meanwhile, and a newer replay of the same revision its owner started since (a held revision may
@@ -918,20 +952,23 @@ async function cancelUnended(deps, record) {
918
952
  return cancelled;
919
953
  }
920
954
  /** The per_run MCP credentials run `launch.handed_from` was handed (its launch's sealed column, opened under the seal
921
- * key), sealed for the replay run `id` alone, as the server's start seals a run's mcp_auth (store/seal.ts
922
- * sealRunMcpAuth): the replay's claim reads them where any run's claim does (runner/mcp-claim.ts). None when the replay
923
- * names no such run (an owner's), that run was handed none, or they do not open. Never written anywhere else, never
924
- * logged. */
955
+ * key), and its own model key for a `keyed` replay, sealed for the replay run `id` alone (store/seal.ts
956
+ * sealHandedLaunch): the replay's claim reads them where any run's claim does (runner/mcp-claim.ts, claim-secrets.ts
957
+ * claimModelKey), and its end erases them as any run's. None when the replay names no such run (an owner's), that run
958
+ * was handed none, or they do not open. A keyed replay whose run holds no key now is never started (throws): it would
959
+ * spend on the server's key. Never written anywhere else, never logged. */
925
960
  async function handedTo(deps, launch, id) {
926
961
  const from = launch.handed_from;
927
962
  if (!from)
928
963
  return undefined;
964
+ const keyed = launch.keyed === true;
929
965
  // A run's own process holds no seal key: its runner seals them again, from its own run alone (held.ts handOn).
930
- if (!deps.sealKey)
931
- return held()?.handOn(from, id);
932
- const sealed = await deps.store.runs.launch(from).then((one) => one.sealed ?? null, () => null);
933
- const handed = sealed === null ? undefined : openRunMcpAuth(deps.sealKey, from, sealed);
934
- return handed && Object.keys(handed).length ? sealRunMcpAuth(deps.sealKey, id, handed) : undefined;
966
+ const sealed = deps.sealKey
967
+ ? await deps.store.runs.launch(from).then((one) => (one.sealed === null ? undefined : sealHandedLaunch(deps.sealKey, from, one.sealed, id, keyed)), () => undefined)
968
+ : await held()?.handOn(from, id, keyed);
969
+ if (keyed && (!deps.sealKey || !sealed || !openRunLaunch(deps.sealKey, id, sealed)?.model))
970
+ throw new Error(`the replay ${id} is not started: the run whose own model key it would spend on holds none now`);
971
+ return sealed;
935
972
  }
936
973
  /** Starts the replay of `workflow` at `digest` on agent run `of` (its launch `from`) as run `id` (the id its reserved
937
974
  * record names), with the replay's chosen `launch` (replayLaunchOf: its run launch, revision and handed credentials,
@@ -939,7 +976,7 @@ async function handedTo(deps, launch, id) {
939
976
  * relaunch and the reserving claim at once), and it is left to that one; false too when run `of` was purged since its
940
977
  * launch was read (the store refuses it, RunPurged, nothing written): the replay never starts, counted so past its
941
978
  * deadline. */
942
- async function startReplay(deps, workflow, digest, of, from, id, launch) {
979
+ async function startReplay(deps, workflow, digest, of, from, id, launch, parent) {
943
980
  const { store, agentId } = deps;
944
981
  const base = readLaunchBody(launch.body);
945
982
  if (!base)
@@ -947,8 +984,17 @@ async function startReplay(deps, workflow, digest, of, from, id, launch) {
947
984
  const source = sourceSyncOf((await store.agents.revision(launch.revision))?.body);
948
985
  if (base.sourceProject || source && !deps.admitAuxiliary)
949
986
  throw new ReplayRefused("conflict", PROJECT_REPLAY_REFUSED);
950
- const replay = { ...base, input: from.input, title: `Replay of ${workflow.name}: ${from.title}`.slice(0, 200), replay: { of, workflow: workflow.name, digest } };
987
+ // A keyed replay names the run whose own key it spends on: its cost is that run's learning, never its revision's
988
+ // (learn/ledger.ts record).
989
+ const paidBy = launch.keyed && launch.handed_from ? { paidBy: launch.handed_from } : {};
990
+ // Its start, and its deadline from it (learning-work.ts LEARNING_CHILD_MS): its runner cancels it there.
991
+ const at = (deps.now ?? Date.now)();
992
+ const replay = { ...base, input: from.input, title: `Replay of ${workflow.name}: ${from.title}`.slice(0, 200), replay: { of, workflow: workflow.name, digest, ...paidBy, deadlineAt: at + LEARNING_CHILD_MS } };
951
993
  const sealed = await handedTo(deps, launch, id);
994
+ // The reserving claim's run names it as its learning work before it exists (learning-work.ts), so no replay runs that
995
+ // its run's learning_work does not list; the same write moves that run's learning deadline to this one's.
996
+ if (parent)
997
+ await noteLearningChild(store.settings, parent, { run: id, kind: "replay", at, ...(launch.keyed ? { keyed: true } : {}) });
952
998
  try {
953
999
  if (source)
954
1000
  return (await deps.admitAuxiliary({ runId: id, agentId, revisionId: launch.revision, launch: replay, ...(sealed ? { sealed } : {}) })).created;
@@ -973,16 +1019,21 @@ async function startReplay(deps, workflow, digest, of, from, id, launch) {
973
1019
  * this claim created. */
974
1020
  async function relaunch(deps, workflow, digest, record) {
975
1021
  const { store } = deps;
976
- if (deps.spendOff?.("A replay"))
1022
+ // Its runs spend on the server's key: a claim on its run's own key starts none of them, and a check on another run's
1023
+ // key (`keyed`) is never created again, that key being erased with its run's claim.
1024
+ if (deps.spendOff?.("A replay") || deps.keyed?.())
977
1025
  return 0;
978
1026
  const since = (deps.now ?? Date.now)() - Date.parse(record.at);
979
1027
  const launch = record.launch;
980
- if (!launch || since <= REPLAY_LAUNCH_GRACE_MS || since > REPLAY_DEADLINE_MS)
1028
+ if (!launch || launch.keyed || since <= REPLAY_LAUNCH_GRACE_MS || since > REPLAY_DEADLINE_MS)
981
1029
  return 0;
1030
+ // A run the reserving claim named as its learning work and did not create (it crashed between the two) stays missing,
1031
+ // counted as never started: that run's learning_work read it ended, and never reads it running again.
1032
+ const named = launch.handed_from ? new Set((await learningChildrenOf(store.settings, launch.handed_from)).map((one) => one.run)) : new Set();
982
1033
  let made = 0;
983
1034
  for (const [i, id] of (record.runs ?? []).entries()) {
984
1035
  const of = record.inputs?.[i];
985
- if (!of || (await store.runs.get(id)))
1036
+ if (!of || named.has(id) || (await store.runs.get(id)))
986
1037
  continue;
987
1038
  const from = await store.runs.launch(of).then((one) => readLaunchBody(one.body), () => undefined);
988
1039
  if (from && (await startReplay(deps, workflow, digest, of, from, id, launch)))
@@ -76,6 +76,13 @@ export interface ReflectDeps {
76
76
  }) => Promise<void>;
77
77
  /** The compile turn's deadline, every attempt in it. Default learn/compile.ts COMPILE_TIMEOUT_MS. */
78
78
  readonly compileDeadlineMs?: number;
79
+ /** Keeps the run's learning deadline at least `until` (its compile turn's start + that deadline), before the turn asks a
80
+ * model (learning-work.ts noteLearningDeadline). A write that fails fails the step: no compile turn without its bound.
81
+ * Absent: none kept. */
82
+ readonly compileStarts?: (input: {
83
+ runId: string;
84
+ until: number;
85
+ }) => Promise<void>;
79
86
  /** One compile draft through the checks (learning-end.ts checkDraftOf): its errors, else what is committed and its
80
87
  * digest. `revised`: a revision's workflow and the commit of main it was read at, its conflict base. */
81
88
  readonly checkDraft: (input: {
@@ -12,7 +12,7 @@
12
12
  // nothing.
13
13
  import { cutStrings } from "../key-refusal.js";
14
14
  import { redactSecrets } from "../learn/index.js";
15
- import { compileTurn } from "../learn/compile.js";
15
+ import { COMPILE_TIMEOUT_MS, compileTurn } from "../learn/compile.js";
16
16
  import { correctionsCapOf, said, STOPPED } from "../learning-words.js";
17
17
  /** A turn the spend cap refused (the cap's refusal words, cap.ts CAP_REFUSAL_PREFIX). */
18
18
  export const CAP_REFUSAL = /^spend_cap_reached(?: \([^)]*\))?: /;
@@ -92,6 +92,7 @@ export function createReflectHook(deps) {
92
92
  // since), and it is the revised workflow's conflict base in every check of the turn.
93
93
  let revised = compile.mode === "revise" && compile.base ? { workflow: compile.workflow, base: compile.base } : undefined;
94
94
  let capped = false;
95
+ await deps.compileStarts?.({ runId: input.runId, until: now() + (deps.compileDeadlineMs ?? COMPILE_TIMEOUT_MS) });
95
96
  const result = await compileTurn({
96
97
  ask: async (prompt, attempt, left) => {
97
98
  asked = true;
@@ -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;