@parcha/agentrun-serve 0.1.0-beta.51 → 0.1.0-beta.53

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 (322) hide show
  1. package/CHANGELOG.md +160 -1
  2. package/README.md +306 -36
  3. package/dist/adapters.js +1 -1
  4. package/dist/agent-delete.d.ts +14 -4
  5. package/dist/agent-delete.js +30 -58
  6. package/dist/agent-package.d.ts +71 -0
  7. package/dist/agent-package.js +345 -0
  8. package/dist/agents-store.d.ts +28 -18
  9. package/dist/agents-store.js +48 -34
  10. package/dist/api-only.d.ts +30 -8
  11. package/dist/api-only.js +40 -16
  12. package/dist/archil-routes.d.ts +1 -0
  13. package/dist/archil-routes.js +28 -2
  14. package/dist/claude-login.d.ts +1 -0
  15. package/dist/claude-login.js +1 -1
  16. package/dist/cli-learning/cli.d.ts +3 -0
  17. package/dist/cli-learning/cli.js +17 -3
  18. package/dist/cli-learning/connections.js +3 -2
  19. package/dist/cli-learning/schema.js +2 -1
  20. package/dist/cli.js +70 -7
  21. package/dist/composio-preset.d.ts +2 -1
  22. package/dist/composio-preset.js +4 -3
  23. package/dist/composio-triggers.d.ts +4 -0
  24. package/dist/composio-triggers.js +4 -1
  25. package/dist/computer-needs.d.ts +32 -0
  26. package/dist/computer-needs.js +80 -0
  27. package/dist/computer-setting.d.ts +9 -0
  28. package/dist/computer-setting.js +19 -1
  29. package/dist/computers.d.ts +6 -2
  30. package/dist/computers.js +2 -2
  31. package/dist/console/assets/index-BFgyZzF_.js +734 -0
  32. package/dist/console/assets/index-DbilxljH.css +1 -0
  33. package/dist/console/index.html +2 -2
  34. package/dist/console-links.d.ts +1 -0
  35. package/dist/console-links.js +2 -0
  36. package/dist/env-switch.d.ts +14 -0
  37. package/dist/env-switch.js +23 -0
  38. package/dist/errors.d.ts +1 -0
  39. package/dist/errors.js +3 -0
  40. package/dist/eval-previous.js +4 -3
  41. package/dist/fal-price.d.ts +76 -0
  42. package/dist/fal-price.js +365 -0
  43. package/dist/handed-secret.d.ts +4 -0
  44. package/dist/handed-secret.js +10 -0
  45. package/dist/harness-archive.d.ts +15 -5
  46. package/dist/harness-archive.js +71 -34
  47. package/dist/harness-check.d.ts +2 -1
  48. package/dist/harness-check.js +36 -95
  49. package/dist/harness-egress.d.ts +23 -0
  50. package/dist/harness-egress.js +69 -0
  51. package/dist/harness-recipe-entry.d.ts +71 -0
  52. package/dist/harness-recipe-entry.js +184 -0
  53. package/dist/harness-recipe.d.ts +73 -6
  54. package/dist/harness-recipe.js +185 -31
  55. package/dist/harness-sign-in.d.ts +29 -0
  56. package/dist/harness-sign-in.js +122 -0
  57. package/dist/harness-table.d.ts +21 -0
  58. package/dist/harness-table.js +58 -3
  59. package/dist/harness-zip.d.ts +6 -0
  60. package/dist/harness-zip.js +203 -0
  61. package/dist/ids.d.ts +11 -0
  62. package/dist/ids.js +36 -0
  63. package/dist/learn/commit.d.ts +19 -1
  64. package/dist/learn/commit.js +160 -2
  65. package/dist/learn/compile.d.ts +13 -5
  66. package/dist/learn/compile.js +46 -15
  67. package/dist/learn/delete.d.ts +12 -6
  68. package/dist/learn/delete.js +17 -11
  69. package/dist/learn/folder.d.ts +16 -0
  70. package/dist/learn/folder.js +30 -4
  71. package/dist/learn/learning-of.d.ts +8 -0
  72. package/dist/learn/learning-of.js +8 -0
  73. package/dist/learn/learning.sh +29 -4
  74. package/dist/learn/promote.d.ts +51 -7
  75. package/dist/learn/promote.js +51 -8
  76. package/dist/learn/secrets.js +30 -7
  77. package/dist/learning-reset.d.ts +18 -0
  78. package/dist/learning-reset.js +115 -0
  79. package/dist/learning-routes.d.ts +23 -11
  80. package/dist/learning-routes.js +110 -20
  81. package/dist/learning-words.d.ts +5 -0
  82. package/dist/learning-words.js +5 -0
  83. package/dist/learning.d.ts +15 -10
  84. package/dist/learning.js +14 -8
  85. package/dist/llms.txt +1 -0
  86. package/dist/mcp-gateway.d.ts +39 -2
  87. package/dist/mcp-gateway.js +56 -12
  88. package/dist/mcp-pin-first.js +1 -1
  89. package/dist/mcp-probe.d.ts +3 -0
  90. package/dist/mcp-probe.js +7 -2
  91. package/dist/mcp-resources.d.ts +44 -0
  92. package/dist/mcp-resources.js +100 -0
  93. package/dist/mcp-servers-store.d.ts +17 -12
  94. package/dist/mcp-servers-store.js +2 -1
  95. package/dist/media-duration.d.ts +2 -0
  96. package/dist/media-duration.js +136 -0
  97. package/dist/model.d.ts +4 -4
  98. package/dist/model.js +6 -6
  99. package/dist/native/cli.js +9 -2
  100. package/dist/native/connection.d.ts +2 -2
  101. package/dist/native/connection.js +5 -2
  102. package/dist/native/discovery.d.ts +2 -0
  103. package/dist/native/discovery.js +10 -6
  104. package/dist/native/remote-worker-bridge.js +36 -4
  105. package/dist/native/remote.d.ts +18 -1
  106. package/dist/native/remote.js +126 -37
  107. package/dist/native/schema.d.ts +6 -0
  108. package/dist/native/schema.js +31 -6
  109. package/dist/native/source-account.d.ts +13 -0
  110. package/dist/native/source-account.js +114 -0
  111. package/dist/native/source-capture-hooks.d.ts +5 -0
  112. package/dist/native/source-capture-hooks.js +102 -0
  113. package/dist/native/source-mcp-selection.d.ts +13 -0
  114. package/dist/native/source-mcp-selection.js +72 -0
  115. package/dist/native/source-runtime-tools.d.ts +19 -0
  116. package/dist/native/source-runtime-tools.js +103 -0
  117. package/dist/native/source-snapshot-types.d.ts +138 -0
  118. package/dist/native/source-snapshot-types.js +12 -0
  119. package/dist/native/source-snapshot.d.ts +8 -0
  120. package/dist/native/source-snapshot.js +1201 -0
  121. package/dist/observation/learning.js +3 -2
  122. package/dist/openapi.js +211 -47
  123. package/dist/print.js +1 -1
  124. package/dist/provider.d.ts +8 -0
  125. package/dist/provider.js +14 -2
  126. package/dist/purged-workflow.d.ts +12 -0
  127. package/dist/purged-workflow.js +43 -0
  128. package/dist/refusal-words.d.ts +0 -3
  129. package/dist/refusal-words.js +0 -3
  130. package/dist/request-metadata.d.ts +20 -0
  131. package/dist/request-metadata.js +24 -0
  132. package/dist/run-keys.d.ts +46 -0
  133. package/dist/run-keys.js +109 -0
  134. package/dist/run-launch.d.ts +29 -5
  135. package/dist/run-launch.js +44 -4
  136. package/dist/run-learning-served.d.ts +2 -2
  137. package/dist/run-model-key.d.ts +2 -2
  138. package/dist/run-model-key.js +5 -5
  139. package/dist/run-secrets.d.ts +2 -0
  140. package/dist/run-secrets.js +7 -4
  141. package/dist/run-usage.d.ts +48 -4
  142. package/dist/run-usage.js +156 -39
  143. package/dist/run-view.d.ts +18 -1
  144. package/dist/run-view.js +28 -8
  145. package/dist/runner/adapter-loop.d.ts +14 -4
  146. package/dist/runner/adapter-loop.js +150 -31
  147. package/dist/runner/adapter-run-spec.d.ts +1 -1
  148. package/dist/runner/adapter-run-spec.js +35 -22
  149. package/dist/runner/audit.d.ts +10 -3
  150. package/dist/runner/audit.js +30 -7
  151. package/dist/runner/beside.js +2 -1
  152. package/dist/runner/claim-secrets.d.ts +31 -4
  153. package/dist/runner/claim-secrets.js +43 -7
  154. package/dist/runner/cli-run-spec.d.ts +1 -1
  155. package/dist/runner/cli-run-spec.js +32 -20
  156. package/dist/runner/conformance/harness.js +4 -2
  157. package/dist/runner/dispatch.js +4 -2
  158. package/dist/runner/harness-loops.d.ts +6 -0
  159. package/dist/runner/harness-loops.js +16 -3
  160. package/dist/runner/held.d.ts +4 -0
  161. package/dist/runner/journal-kinds.d.ts +5 -0
  162. package/dist/runner/learned-first.d.ts +2 -0
  163. package/dist/runner/learned-first.js +1 -1
  164. package/dist/runner/learning-end.d.ts +9 -3
  165. package/dist/runner/learning-end.js +66 -29
  166. package/dist/runner/learning-seed.d.ts +9 -3
  167. package/dist/runner/learning-seed.js +2 -2
  168. package/dist/runner/main.d.ts +1 -0
  169. package/dist/runner/main.js +20 -13
  170. package/dist/runner/mcp-claim.js +7 -2
  171. package/dist/runner/mcp-run.d.ts +12 -0
  172. package/dist/runner/mcp-run.js +14 -1
  173. package/dist/runner/model-route.js +7 -4
  174. package/dist/runner/monid-run.js +9 -11
  175. package/dist/runner/project-checkpoint.d.ts +35 -0
  176. package/dist/runner/project-checkpoint.js +116 -0
  177. package/dist/runner/project-drain.d.ts +8 -0
  178. package/dist/runner/project-drain.js +25 -0
  179. package/dist/runner/project-host.d.ts +10 -0
  180. package/dist/runner/project-host.js +52 -0
  181. package/dist/runner/promotion.d.ts +51 -24
  182. package/dist/runner/promotion.js +206 -78
  183. package/dist/runner/redact.d.ts +13 -0
  184. package/dist/runner/redact.js +67 -1
  185. package/dist/runner/run-channel.d.ts +9 -0
  186. package/dist/runner/run-channel.js +15 -2
  187. package/dist/runner/run-child-host.d.ts +8 -4
  188. package/dist/runner/run-child-host.js +174 -42
  189. package/dist/runner/run-errors.js +2 -2
  190. package/dist/runner/runner-check.js +5 -2
  191. package/dist/runner/runner.js +41 -12
  192. package/dist/runner/sdk-loop.d.ts +2 -2
  193. package/dist/runner/sdk-loop.js +3 -3
  194. package/dist/runner/store-port.d.ts +3 -0
  195. package/dist/runner/store-secrets.js +7 -3
  196. package/dist/runner/workflow-first.d.ts +4 -0
  197. package/dist/runner/workflow-first.js +13 -0
  198. package/dist/runner/workflow-loop.d.ts +2 -1
  199. package/dist/runner/workflow-loop.js +2 -1
  200. package/dist/runner/workflow-spec.js +4 -4
  201. package/dist/runs-over-store.d.ts +39 -8
  202. package/dist/runs-over-store.js +147 -32
  203. package/dist/sdk/check.d.ts +6 -5
  204. package/dist/sdk/check.js +17 -16
  205. package/dist/sdk/runs.d.ts +11 -1
  206. package/dist/sdk/runs.js +185 -78
  207. package/dist/sdk/schema.js +12 -2
  208. package/dist/sdk/workflows.d.ts +1 -1
  209. package/dist/server.d.ts +68 -32
  210. package/dist/server.js +678 -124
  211. package/dist/skills/agentrun-serve/SKILL.md +2 -1
  212. package/dist/source-sync/adoption.d.ts +15 -0
  213. package/dist/source-sync/adoption.js +36 -0
  214. package/dist/source-sync/auxiliary.d.ts +23 -0
  215. package/dist/source-sync/auxiliary.js +64 -0
  216. package/dist/source-sync/capture-git.d.ts +5 -0
  217. package/dist/source-sync/capture-git.js +272 -0
  218. package/dist/source-sync/capture-project.d.ts +53 -0
  219. package/dist/source-sync/capture-project.js +206 -0
  220. package/dist/source-sync/capture-refusal.d.ts +7 -0
  221. package/dist/source-sync/capture-refusal.js +16 -0
  222. package/dist/source-sync/capture.d.ts +11 -0
  223. package/dist/source-sync/capture.js +22 -0
  224. package/dist/source-sync/checkpoint-gate.d.ts +21 -0
  225. package/dist/source-sync/checkpoint-gate.js +52 -0
  226. package/dist/source-sync/checkpoints.d.ts +66 -0
  227. package/dist/source-sync/checkpoints.js +168 -0
  228. package/dist/source-sync/claim.d.ts +11 -0
  229. package/dist/source-sync/claim.js +48 -0
  230. package/dist/source-sync/destination.d.ts +47 -0
  231. package/dist/source-sync/destination.js +239 -0
  232. package/dist/source-sync/io.d.ts +15 -0
  233. package/dist/source-sync/io.js +52 -0
  234. package/dist/source-sync/local.d.ts +43 -0
  235. package/dist/source-sync/local.js +229 -0
  236. package/dist/source-sync/prepare.d.ts +59 -0
  237. package/dist/source-sync/prepare.js +93 -0
  238. package/dist/source-sync/projects.d.ts +61 -0
  239. package/dist/source-sync/projects.js +130 -0
  240. package/dist/source-sync/registry.d.ts +95 -0
  241. package/dist/source-sync/registry.js +226 -0
  242. package/dist/source-sync/service.d.ts +33 -0
  243. package/dist/source-sync/service.js +118 -0
  244. package/dist/source-sync/skill-edits.d.ts +12 -0
  245. package/dist/source-sync/skill-edits.js +122 -0
  246. package/dist/source-sync/snapshots.d.ts +48 -0
  247. package/dist/source-sync/snapshots.js +448 -0
  248. package/dist/source-sync/types.d.ts +9 -0
  249. package/dist/source-sync/types.js +14 -0
  250. package/dist/source-sync/workspace.d.ts +66 -0
  251. package/dist/source-sync/workspace.js +273 -0
  252. package/dist/store/agent-body.d.ts +8 -0
  253. package/dist/store/agent-body.js +20 -6
  254. package/dist/store/index.d.ts +2 -2
  255. package/dist/store/index.js +1 -1
  256. package/dist/store/journal/storage.d.ts +2 -0
  257. package/dist/store/journal/storage.js +2 -1
  258. package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
  259. package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
  260. package/dist/store/schema.d.ts +15 -1
  261. package/dist/store/schema.js +43 -4
  262. package/dist/store/seal.d.ts +5 -1
  263. package/dist/store/seal.js +12 -3
  264. package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
  265. package/dist/store/sqlite/project-checkpoints.js +70 -0
  266. package/dist/store/sqlite/run-launch.d.ts +14 -0
  267. package/dist/store/sqlite/run-launch.js +58 -7
  268. package/dist/store/sqlite/run-patch.d.ts +2 -1
  269. package/dist/store/sqlite/run-patch.js +4 -3
  270. package/dist/store/sqlite/store.js +319 -153
  271. package/dist/store/store-schema.js +2 -2
  272. package/dist/store/store.d.ts +173 -33
  273. package/dist/store/store.js +14 -1
  274. package/dist/store-reads/learning.d.ts +12 -8
  275. package/dist/store-reads/learning.js +33 -24
  276. package/dist/store-reads/loop.d.ts +4 -3
  277. package/dist/store-reads/loop.js +7 -5
  278. package/dist/store-view.d.ts +3 -1
  279. package/dist/store-view.js +17 -5
  280. package/dist/template-eval.js +4 -4
  281. package/dist/template-import.d.ts +10 -2
  282. package/dist/template-import.js +116 -13
  283. package/dist/templates.d.ts +29 -5
  284. package/dist/templates.js +68 -14
  285. package/dist/timeline/index.d.ts +1 -1
  286. package/dist/timeline/index.js +1 -1
  287. package/dist/timeline/labels.js +1 -1
  288. package/dist/timeline/timeline.d.ts +5 -0
  289. package/dist/timeline/timeline.js +8 -0
  290. package/dist/tool-plane.d.ts +12 -12
  291. package/dist/tools.d.ts +8 -8
  292. package/dist/tools.js +1 -1
  293. package/dist/trigger-launch-hook.d.ts +47 -0
  294. package/dist/trigger-launch-hook.js +90 -0
  295. package/dist/trigger-targets.d.ts +14 -1
  296. package/dist/trigger-targets.js +20 -0
  297. package/dist/triggers.d.ts +54 -5
  298. package/dist/triggers.js +143 -8
  299. package/dist/uploads-archil.js +2 -1
  300. package/dist/uploads.d.ts +0 -3
  301. package/dist/uploads.js +2 -11
  302. package/dist/validate.js +4 -1
  303. package/dist/web-save.d.ts +3 -0
  304. package/dist/web-save.js +17 -2
  305. package/dist/workspace/archil-exec.js +1 -1
  306. package/dist/workspace/archil.js +1 -1
  307. package/dist/workspace/computer-for-claim.d.ts +2 -0
  308. package/dist/workspace/computer-for-claim.js +43 -0
  309. package/dist/workspace/paths.d.ts +6 -0
  310. package/dist/workspace/paths.js +6 -0
  311. package/dist/workspace/resolve-computer.d.ts +1 -0
  312. package/dist/workspace/revision-skills.js +24 -11
  313. package/dist/workspace/run-tools.d.ts +2 -0
  314. package/dist/workspace/run-tools.js +8 -0
  315. package/dist/workspace/synced-folder.d.ts +3 -3
  316. package/dist/workspace/synced-folder.js +7 -6
  317. package/launcher/agentrun-serve +1 -1
  318. package/package.json +10 -10
  319. package/skills/agentrun-serve/SKILL.md +2 -1
  320. package/templates/README.md +5 -2
  321. package/dist/console/assets/index-Bt1B51b7.js +0 -733
  322. package/dist/console/assets/index-sVftE9Ht.css +0 -1
@@ -24,6 +24,19 @@ export class ChannelClosed extends Error {
24
24
  export class ChannelRefused extends Error {
25
25
  name = "ChannelRefused";
26
26
  }
27
+ /** A call or an answer past the channel's cap: it fails alone, and the channel goes on. Its bytes and the cap cross with
28
+ * it (registered on both sides), so a runner can tell a run whose records no longer fit from one that may go on. */
29
+ export class FrameTooLarge extends RangeError {
30
+ name = "FrameTooLarge";
31
+ bytes;
32
+ limit;
33
+ /** `what`: "an answer", or "a call of <method>". */
34
+ constructor(what, bytes, limit) {
35
+ super(what === "an answer" ? `an answer of ${bytes} bytes is past the channel's ${limit}` : `${what} is ${bytes} bytes, past the channel's ${limit}`);
36
+ this.bytes = bytes;
37
+ this.limit = limit;
38
+ }
39
+ }
27
40
  /** The error classes made again by name on the receiving side, so instanceof holds across the channel. Each side
28
41
  * registers the ones it may receive (registerErrors). */
29
42
  const ERRORS = new Map();
@@ -189,11 +202,11 @@ export class Channel {
189
202
  if (message.t === "call") {
190
203
  const pending = this.#pending.get(message.id);
191
204
  this.#pending.delete(message.id);
192
- pending?.reject(new RangeError(`a call of ${message.m} is ${body.length} bytes, past the channel's ${this.#maxFrame}`));
205
+ pending?.reject(new FrameTooLarge(`a call of ${String(message.m)}`, body.length, this.#maxFrame));
193
206
  return;
194
207
  }
195
208
  if (message.t === "ok")
196
- return this.#send({ t: "err", id: message.id, e: this.#encode(new RangeError(`an answer of ${body.length} bytes is past the channel's ${this.#maxFrame}`)) });
209
+ return this.#send({ t: "err", id: message.id, e: this.#encode(new FrameTooLarge("an answer", body.length, this.#maxFrame)) });
197
210
  return;
198
211
  }
199
212
  const head = Buffer.alloc(4);
@@ -32,6 +32,9 @@ export declare const runIsolationName: (isolation: RunIsolation) => "uid" | "pro
32
32
  export declare class RunIsolationRefused extends Error {
33
33
  name: string;
34
34
  }
35
+ /** Whether runIsolationOf gives `env` on this host `process` (every run as the runner's own user), told before it is
36
+ * asked: `same`, or no helper and not `slot`. A helper that is there but cannot switch refuses the runner instead. */
37
+ export declare const runsAsOwnUser: (env: NodeJS.ProcessEnv, helper?: string) => boolean;
35
38
  /** This host's isolation for `loops` runs at once, by `env` and the helper: the helper's own check that it can switch
36
39
  * (its effective set holds what it needs) decides `uid`; none installed (a local install), `process`; `same`, `process`
37
40
  * said in the log. A helper that cannot switch is refused in words naming the setting, never a quiet fall back. `loops`
@@ -89,9 +92,6 @@ export declare function reapSlot(isolation: Extract<RunIsolation, {
89
92
  /** `value` as data: every function, symbol and class's method left out, so nothing the runner holds is handed by
90
93
  * reference to the run's process unless a target hands it on purpose. */
91
94
  export declare function dataOnly(value: unknown, seen?: Set<object>): unknown;
92
- /** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
93
- * loop of its own (rule three: no secret the runner holds is written). */
94
- export declare function cutDeep<T>(value: T, cut: (text: string) => string): T;
95
95
  /** What the store target knows of the claim: its run and the run's agent and revision. */
96
96
  export interface Bound {
97
97
  readonly claim: Claim;
@@ -116,6 +116,7 @@ interface ClaimReads {
116
116
  readonly body: Record<string, unknown>;
117
117
  };
118
118
  readonly claimed: NodeJS.ProcessEnv;
119
+ readonly signal?: AbortSignal;
119
120
  }
120
121
  /** Held (held.ts) for one claim, on the runner: each answer the claim's own, read with the runner's seal key from the
121
122
  * runner's own reads of the claim; every argument from the run's process is checked or ignored. `bigs`: the run's pieced
@@ -126,6 +127,7 @@ export declare function heldFor(deps: AdapterSpecDeps & {
126
127
  held: Held;
127
128
  inputs(): Promise<void>;
128
129
  release(): Promise<void>;
130
+ projectEnd?(): Promise<void>;
129
131
  };
130
132
  /** A call of the learning folder a run's process asks (Held.learning), on the runner's own Workspace of the claim's
131
133
  * agent's folder: reads pass, and the learning script runs its reads, with the script's own environment (the script
@@ -156,6 +158,9 @@ export declare const childArgv: () => string[];
156
158
  export declare const runsInRunner: (harness: string, launch: Pick<RunLaunch, "sdk" | "native" | "cli_learning">) => boolean;
157
159
  /** The words a run on Claude Code's login on this machine is refused in where each run is a user of its own. */
158
160
  export declare const LOGIN_NEEDS_SERVER_USER = "A run on Claude Code's login on this machine needs runs under the server's own user, and this runner runs each run as a user of its own: set AGENTRUN_RUN_USER=same, or give the run a model_key.";
161
+ /** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
162
+ export declare const RECIPE_NEEDS_SERVER_USER = "A run on a harness recipe needs runs under the server's own user, since its install, its check and its owner's sign-in are that user's alone, and this runner runs each run as a user of its own: set AGENTRUN_RUN_USER=same on this runner.";
163
+ export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
159
164
  /** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
160
165
  * directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
161
166
  * user holds and no slot's user is given; its nodes run the server's own tools alone, no agent's code. A run on Claude
@@ -176,4 +181,3 @@ export declare function runChannel(socket: Duplex, onClose: (why: Error) => void
176
181
  readonly bigs?: RunBigWrites;
177
182
  readonly maxFrame?: number;
178
183
  }): Channel;
179
- export {};
@@ -22,7 +22,7 @@ import { putLiveViewer, dropLiveViewer } from "../browser-live.js";
22
22
  import { CALENDAR_EVENTS } from "../calendar/names.js";
23
23
  import { openCalendar } from "../calendar/address.js";
24
24
  import { openAccount } from "../email/account.js";
25
- import { harnessOf } from "../harness-table.js";
25
+ import { harnessOf, recipeHarness } from "../harness-table.js";
26
26
  import { installDirOf, installForClaim, shareInstall } from "../harness-install.js";
27
27
  import { loadArchilSettings } from "../archil-settings.js";
28
28
  import { planOf } from "../chatgpt-plan.js";
@@ -31,7 +31,7 @@ import { vendorsOver } from "../sign-ins.js";
31
31
  import { decisionProvidersIn, fauxFetch } from "../decisions.js";
32
32
  import { DECISION_PROVIDER_KEYS } from "../tool-plane.js";
33
33
  import { learningEndOfRun } from "./learning-end.js";
34
- import { runnerSecrets } from "./redact.js";
34
+ import { cutDeep, heldRedactor, runnerSecrets } from "./redact.js";
35
35
  import { storeSecrets } from "./store-secrets.js";
36
36
  import { FAUX_ENV, GATEWAY_KEY_ENV } from "../model.js";
37
37
  import { SAVED_GATEWAY_ENV, savedGatewayIn } from "../model-gateway.js";
@@ -61,7 +61,7 @@ import { workflowsAt } from "./learning-seed.js";
61
61
  import { heldMcpOf, mcpForClaim } from "./mcp-run.js";
62
62
  import { learnedTiers, learnsWorkflows, mcpReachOf } from "./adapter-run-spec.js";
63
63
  import { createDispatchLoop } from "./dispatch.js";
64
- import { resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
64
+ import { refuseRecipeTriggerRun, resolveRunnerLoop, withSavedGatewayDeps } from "./harness-loops.js";
65
65
  import { isWorkflowRevision } from "./workflow-loop.js";
66
66
  import { loginForRun } from "../claude-login.js";
67
67
  import { heardComputerHold } from "./computer-journal.js";
@@ -71,8 +71,14 @@ import { registerRunErrors } from "./run-errors.js";
71
71
  import { exposeSaveSlots } from "./save-slots.js";
72
72
  import { runBigWrites } from "./big-writes.js";
73
73
  import { SERVER_SLOTS } from "../web-save.js";
74
- import { readLaunchBody } from "../run-launch.js";
74
+ import { launchOnItsDisk, readLaunchBody } from "../run-launch.js";
75
75
  import { SUBAGENT_TOOL } from "./subagent.js";
76
+ import { sourceSyncOf } from "../source-sync/types.js";
77
+ import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
78
+ import { beginSourceIO } from "../source-sync/io.js";
79
+ import { runTools } from "../workspace/run-tools.js";
80
+ import { ProjectHostGate } from "./project-host.js";
81
+ import { runProjectCheckpoint } from "./project-checkpoint.js";
76
82
  /** The image's helper that starts a run's process as its slot's uid (packages/serve/runas). */
77
83
  export const RUNAS_HELPER = "/usr/local/bin/agentrun-runas";
78
84
  /** `same`: every run runs as the runner's own user, the helper unused, said in the runner's log. */
@@ -106,6 +112,9 @@ const execText = (file, args, timeoutMs) => new Promise((resolve) => {
106
112
  resolve({ code: -1, stdout: "", stderr: error?.message ?? String(error) });
107
113
  }
108
114
  });
115
+ /** Whether runIsolationOf gives `env` on this host `process` (every run as the runner's own user), told before it is
116
+ * asked: `same`, or no helper and not `slot`. A helper that is there but cannot switch refuses the runner instead. */
117
+ export const runsAsOwnUser = (env, helper = RUNAS_HELPER) => env[RUN_USER_ENV] === "same" || (!existsSync(helper) && env[RUN_USER_ENV] !== "slot");
109
118
  /** This host's isolation for `loops` runs at once, by `env` and the helper: the helper's own check that it can switch
110
119
  * (its effective set holds what it needs) decides `uid`; none installed (a local install), `process`; `same`, `process`
111
120
  * said in the log. A helper that cannot switch is refused in words naming the setting, never a quiet fall back. `loops`
@@ -363,24 +372,6 @@ export function dataOnly(value, seen = new Set()) {
363
372
  seen.delete(value);
364
373
  }
365
374
  }
366
- /** Every string inside `value` cut by `cut`: what the run's process writes, as the runner's redactor would cut it in a
367
- * loop of its own (rule three: no secret the runner holds is written). */
368
- export function cutDeep(value, cut) {
369
- if (typeof value === "string")
370
- return cut(value);
371
- if (value === null || typeof value !== "object")
372
- return value;
373
- if (ArrayBuffer.isView(value) || value instanceof Date || value instanceof RegExp || value instanceof ArrayBuffer)
374
- return value;
375
- if (Array.isArray(value))
376
- return value.map((item) => cutDeep(item, cut));
377
- if (value instanceof Map)
378
- return new Map([...value].map(([k, v]) => [k, cutDeep(v, cut)]));
379
- const out = {};
380
- for (const key of Object.keys(value))
381
- Object.defineProperty(out, key, { value: cutDeep(value[key], cut), enumerable: true, writable: true, configurable: true });
382
- return out;
383
- }
384
375
  const ownRun = (args, bound) => args[0] === bound.claim.runId;
385
376
  /** The claim's run, or its own audit's shadow run, whose spend its cap gates read beside it (learning-end.ts besideOf). */
386
377
  const ownRunOrShadow = (args, bound) => args[0] === bound.claim.runId || args[0] === shadowRunId(bound.claim.runId);
@@ -569,8 +560,52 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
569
560
  const sealKey = deps.sealKey;
570
561
  const store = deps.store;
571
562
  const granted = revision.body.tools ?? [];
563
+ const admitAuxiliary = sourceAuxiliaryAdmitter(store, { data: deps.data, sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
572
564
  const keys = { store, sealKey, env: deps.env };
573
565
  const releases = [() => bigs.close()];
566
+ const source = sourceSyncOf(revision.body), placed = launch.sourceProject;
567
+ const moved = !!source && !!placed && source.id === placed.sourceId && source.project === placed.digest && placed.baselineRevision === run.revisionId;
568
+ const projectGate = moved ? new ProjectHostGate() : undefined;
569
+ const projectStop = new AbortController();
570
+ const projectSignal = reads.signal ? AbortSignal.any([reads.signal, projectStop.signal]) : projectStop.signal;
571
+ let projectIO, projectCapture;
572
+ let projectComputer, projectWorkspace, projectMode = 1;
573
+ let projectFailed = false, projectReleased = false, projectClosing = false, projectCaptureDone = false;
574
+ let projectRelease;
575
+ let projectCleanup;
576
+ const projectOwns = async (settlingAudit = false) => {
577
+ projectSignal.throwIfAborted();
578
+ const row = await store.runs.get(claim.runId);
579
+ // A never-waiting audit journals its Ask/cap as parked before terminalizing under this same claim. Only its
580
+ // checkpoint may finish from that state; ordinary held calls still require running, and claim identity is exact.
581
+ const settlingParkedAudit = settlingAudit && launch.audit !== undefined && row?.state === "parked";
582
+ if (!row || row.agentId !== run.agentId || row.revisionId !== run.revisionId || row.epoch !== claim.epoch || row.runner !== claim.runner || row.state !== "running" && !settlingParkedAudit)
583
+ throw new ClaimRefused("This project checkpoint no longer holds its original run claim.");
584
+ };
585
+ const ownProject = async (settlingAudit = false) => {
586
+ if (!projectGate)
587
+ return;
588
+ await projectOwns(settlingAudit);
589
+ await (projectIO ??= beginSourceIO(store, run.agentId, "snapshot"));
590
+ };
591
+ const projectCall = (work) => projectGate ? projectGate.run(async () => { await ownProject(); return work(); }) : work();
592
+ const projectWorkSettled = async () => { await projectCapture; await projectGate?.drain(); };
593
+ const projectSettled = async () => { await projectWorkSettled(); await projectCleanup?.catch(() => undefined); };
594
+ /** Cleanup closes capture admission synchronously. A capture already admitted finishes first; one arriving later
595
+ * cannot use resources being relinquished. Cleanup itself remains owned and is awaited by the host's release. */
596
+ const cleanProject = (work) => {
597
+ if (!projectGate)
598
+ return work();
599
+ if (projectReleased)
600
+ return Promise.reject(new ClaimRefused("This claim's project resources have already been released."));
601
+ projectClosing = true;
602
+ projectGate.close();
603
+ const previous = projectCleanup;
604
+ const pending = (async () => { await previous?.catch(() => undefined); await projectWorkSettled(); return work(); })();
605
+ projectCleanup = pending;
606
+ void pending.catch(() => { projectFailed = true; });
607
+ return pending;
608
+ };
574
609
  const fromGitHub = launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github";
575
610
  const github = () => githubAppAccess(store, sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
576
611
  /** Mode 2's Archil claim, made once for the claim on the runner, its folder the run's. */
@@ -603,6 +638,62 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
603
638
  /** The claim's one learned first choice: its promotion's writes are made once, however often the process asks. */
604
639
  let chosen;
605
640
  const held = {
641
+ projectCheckpoint: (...args) => {
642
+ if (args.length > 1 || args[0] !== undefined && !(args[0] instanceof AbortSignal))
643
+ throw new ClaimRefused("A project checkpoint accepts only its cancellation signal.");
644
+ if (!projectGate || !placed || !source)
645
+ throw new ClaimRefused("This claim has no matching placed source project.");
646
+ if (projectReleased)
647
+ throw new ClaimRefused("This claim's project resources have already been released.");
648
+ if (projectCapture)
649
+ return projectCapture;
650
+ if (projectClosing)
651
+ throw new ClaimRefused("This claim's project resources are closing for cleanup.");
652
+ projectGate.close();
653
+ const signal = args[0] ? AbortSignal.any([projectSignal, args[0], AbortSignal.timeout(60_000)]) : AbortSignal.any([projectSignal, AbortSignal.timeout(60_000)]);
654
+ const uncertain = () => ({ version: 1, status: "uncertain", sourceId: source.id, runId: claim.runId, epoch: claim.epoch, reason: "project_not_settled", stage: "drain" });
655
+ projectCapture = (async () => {
656
+ let checkpoint;
657
+ let tools;
658
+ let result;
659
+ try {
660
+ await projectGate.drain();
661
+ await ownProject(true);
662
+ signal.throwIfAborted();
663
+ await projectOwns(true);
664
+ if (projectGate.uncertain)
665
+ throw new ClaimRefused("An earlier project operation has an unresolved outcome.");
666
+ if (!projectComputer || !projectWorkspace)
667
+ throw new ClaimRefused("The project's held execution resources are unavailable.");
668
+ checkpoint = runProjectCheckpoint({ store, agentId: run.agentId, claim, launch, computer: projectComputer, ioHeld: true,
669
+ tools: { get workspace() { if (!tools)
670
+ throw new ClaimRefused("Project settlement has not opened its workspace."); return tools.workspace; },
671
+ settleProject: async () => { tools = await runTools(projectWorkspace, projectComputer.computer, { mode: projectMode, context: BACKGROUND_CONTEXT }); return tools.settleProject(); } },
672
+ workspace: { data: deps.data, sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } },
673
+ secrets: async () => runnerSecrets(deps.env, [...runnerSecrets(claimed), ...await storeSecrets(store, sealKey, deps.data)]), });
674
+ result = await checkpoint.capture(signal);
675
+ signal.throwIfAborted();
676
+ await projectOwns(true);
677
+ if (result.status !== "candidate" && result.status !== "discarded" && !checkpoint.refusalSettled())
678
+ projectFailed = true;
679
+ }
680
+ catch {
681
+ projectFailed = true;
682
+ result = checkpoint?.uncertain() ?? uncertain();
683
+ }
684
+ finally {
685
+ try {
686
+ await tools?.end();
687
+ }
688
+ catch {
689
+ projectFailed = true;
690
+ result = { ...uncertain(), reason: "project_capture_failed", stage: "cleanup" };
691
+ }
692
+ }
693
+ return result;
694
+ })().finally(() => { projectCaptureDone = true; });
695
+ return projectCapture;
696
+ },
606
697
  plan: async () => {
607
698
  const plan = planOf(claimed);
608
699
  if (!plan)
@@ -615,15 +706,16 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
615
706
  return runSignIn(store, sealKey, claim, String(resolution), { vendors: vendorsOver(() => claimed, vendorFetch), log });
616
707
  },
617
708
  verifySignIn: (kept, at) => verifyRunSignIn(store, sealKey, claim, kept, Number(at)),
618
- mcp: async (ask) => {
709
+ mcp: (ask) => projectCall(async () => {
619
710
  const reach = await mcpReachOf(deps);
620
711
  const harness = { commit: (change) => change({ appendEntry: async (_conversation, entry) => void (await ask.appendRoot(dataOnly(entry))) }) };
621
- const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...reach });
712
+ const made = await mcpForClaim({ claim, store, sealKey, grants: granted, harness: harness, work: () => runFolder(deps.data, run.agentId, claim.runId), launchInput: launch.input, githubAppAccess: () => github(), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...reach, capped: launch.maxCostUsd !== undefined, media: { env: deps.env, web: deps.evalFakes?.(run.agentId)?.web, slots: deps.saveSlots } });
622
713
  if (!made)
623
714
  return undefined;
624
715
  releases.push(() => made.release());
625
- return heldMcpOf(made, cut);
626
- },
716
+ const exposed = heldMcpOf(made, cut);
717
+ return projectGate ? projectGate.capability(exposed) : exposed;
718
+ }),
627
719
  githubAppAccess: async () => {
628
720
  // A run's process mints for one thing alone: its revision's pull-request checkout (pr-checkout.ts), of the pull
629
721
  // request its launch's payload names, contents read. Its MCP mints on the runner (mcp above). So the mint handed
@@ -702,7 +794,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
702
794
  // install from before installs were shared too.
703
795
  await shareInstall(installDirOf(deps.data, harness));
704
796
  },
705
- computer: async (ask) => {
797
+ computer: (ask) => projectCall(async () => {
706
798
  const made = await archilOf();
707
799
  const mode = made === undefined ? 1 : 2;
708
800
  const ws = made === undefined
@@ -726,17 +818,27 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
726
818
  const claimed = got;
727
819
  if (typeof claimed?.release === "function")
728
820
  releases.push(() => claimed.release("ended"));
821
+ if (projectGate) {
822
+ projectComputer = got;
823
+ projectWorkspace = ws.workspace;
824
+ projectMode = mode;
825
+ const { syncProject: _sync, ...exposed } = got;
826
+ return { ...exposed, ...(exposed.computer ? { computer: projectGate.capability(exposed.computer) } : {}),
827
+ release: (...args) => cleanProject(() => exposed.release(...args)),
828
+ ...(exposed.park ? { park: (...args) => cleanProject(() => exposed.park(...args)) } : {}) };
829
+ }
729
830
  return got;
730
- },
731
- archil: async () => {
831
+ }),
832
+ archil: () => projectCall(async () => {
732
833
  const made = await archilOf();
733
834
  if (made === undefined)
734
835
  return undefined;
735
836
  const ws = await openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: made, log });
736
837
  releases.push(() => ws.end());
737
838
  // A write bigger than the channel's frame is pulled in pieces and written here, on this Workspace (big-writes.ts).
738
- return { workspace: ws.workspace, pieces: bigs.pieces(ws.workspace), revoke: () => made.revoke(), inherit: async () => made.inherit(), release: async () => { } };
739
- },
839
+ return { workspace: projectGate ? projectGate.capability(ws.workspace) : ws.workspace, pieces: projectGate ? projectGate.capability(bigs.pieces(ws.workspace)) : bigs.pieces(ws.workspace),
840
+ revoke: () => cleanProject(() => made.revoke()), inherit: () => projectCall(async () => made.inherit()), release: async () => { } };
841
+ }),
740
842
  endOfRun: async (input) => {
741
843
  // The step as the run's spec builds it in a runner (adapter-run-spec.ts), over the runner's reads of the claim: what
742
844
  // the run must never learn is every secret this runner holds, the keys its claim handed it, every secret the server
@@ -767,7 +869,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
767
869
  log,
768
870
  decisionProviders: async () => decisionProvidersIn({ ...(deps.env ?? {}), ...(await hostDecisionKeys(keys, DECISION_PROVIDER_KEYS)) }),
769
871
  learningFolder: made === undefined ? (agentId) => learningFolderOf(deps.data, agentId) : (agentId) => learningWorkspace({ mode: "archil", agentId, archil: made }),
770
- }), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, folder: await folderNow(), shown, log, sealKey, spendOff, launch, redact: cut });
872
+ }), { store, agentId: run.agentId, revisionId: run.revisionId, context: BACKGROUND_CONTEXT, folder: await folderNow(), shown, log, sealKey, spendOff, launch, redact: cut, admitAuxiliary });
771
873
  if (!step)
772
874
  return undefined;
773
875
  // keptOf is the run's process's, asked over the channel: read once, for the round learningEndOfRun reads (the
@@ -795,10 +897,10 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
795
897
  // workflows).
796
898
  const start = learningStartOf(launch);
797
899
  const folder = await folderNow();
798
- const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ folder, shown }, start.seed).catch(() => []) : [];
900
+ const laid = ask?.laid === true && start && !seedFailed(start) && !start.noWorkflows ? await workflowsAt({ folder, store, shown }, start.seed).catch(() => []) : [];
799
901
  const spendOff = await claimSpendOff(keys, await claimModelKey(keys, claim.runId));
800
902
  const outputSchema = revision.body.outputSchema;
801
- const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log, folder, shown, spendOff }, laid);
903
+ const got = await learnedFirst({ store, sealKey, agentId: run.agentId, runId: claim.runId, revisionId: run.revisionId, kind: revision.kind, ...(outputSchema !== undefined ? { outputSchema } : {}), launch, context: BACKGROUND_CONTEXT, log, folder, shown, spendOff, admitAuxiliary }, laid);
802
904
  learnedFlows = got.workflows;
803
905
  return cutDeep(dataOnly(got), cut);
804
906
  })()),
@@ -812,7 +914,7 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
812
914
  };
813
915
  return {
814
916
  held,
815
- inputs: async () => {
917
+ inputs: () => projectCall(async () => {
816
918
  // The run's uploads and its opening message (uploads.ts placeRunInputs), placed by this runner before the run's
817
919
  // process starts: their hold is the server's alone.
818
920
  const made = await archilOf();
@@ -825,11 +927,24 @@ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
825
927
  finally {
826
928
  await ws.end();
827
929
  }
828
- },
829
- release: async () => {
930
+ }),
931
+ release: () => projectRelease ??= (async () => {
932
+ projectReleased = true;
933
+ projectGate?.close();
934
+ await projectSettled();
935
+ let failed = false;
830
936
  for (const release of releases.reverse())
831
- await Promise.resolve(release()).catch((error) => log(`run ${claim.runId}: a release on its runner failed: ${error?.message ?? error}`));
832
- },
937
+ await Promise.resolve(release()).catch((error) => { failed = true; log(`run ${claim.runId}: a release on its runner failed: ${error?.message ?? error}`); });
938
+ if (projectIO && !failed && !projectFailed && !projectGate?.uncertain && !projectSignal.aborted)
939
+ await (await projectIO).settled();
940
+ })(),
941
+ ...(projectGate ? { projectEnd: async () => {
942
+ if (projectCapture && !projectCaptureDone)
943
+ projectStop.abort(new Error("The project host is ending."));
944
+ projectReleased = true;
945
+ projectGate.close();
946
+ await projectSettled();
947
+ } } : {}),
833
948
  };
834
949
  }
835
950
  /** `env`'s string values. */
@@ -889,6 +1004,9 @@ export const childArgv = () => [process.execPath, "--import", new URL("../secret
889
1004
  export const runsInRunner = (harness, launch) => harness === "learning" || Boolean(launch.sdk) || Boolean(launch.native) || Boolean(launch.cli_learning);
890
1005
  /** The words a run on Claude Code's login on this machine is refused in where each run is a user of its own. */
891
1006
  export const LOGIN_NEEDS_SERVER_USER = `A run on Claude Code's login on this machine needs runs under the server's own user, and this runner runs each run as a user of its own: set ${RUN_USER_ENV}=same, or give the run a model_key.`;
1007
+ /** The words a run on a harness recipe is refused in where each run is a user of its own (harness-table.ts recipeHarness). */
1008
+ export const RECIPE_NEEDS_SERVER_USER = `A run on a harness recipe needs runs under the server's own user, since its install, its check and its owner's sign-in are that user's alone, and this runner runs each run as a user of its own: set ${RUN_USER_ENV}=same on this runner.`;
1009
+ export { RECIPE_SIGN_IN_PERSON_ONLY } from "./harness-loops.js";
892
1010
  /** Whether run `runId` stays in its runner's process: runsInRunner's, and a workflow run on a server with a documents
893
1011
  * directory (launch.documents), whose reads and writes (a pdf_pages call's pages) are rooted in a folder the server's
894
1012
  * user holds and no slot's user is given; its nodes run the server's own tools alone, no agent's code. A run on Claude
@@ -898,6 +1016,12 @@ export const LOGIN_NEEDS_SERVER_USER = `A run on Claude Code's login on this mac
898
1016
  * the server's user. A run its caller handed a model key (model_key) runs on that key and never on the login
899
1017
  * (cli-run-spec.ts), so it is a process of its own like any other. */
900
1018
  export async function staysInRunner(deps, harness, launch, runId, isolation) {
1019
+ // A recipe's harness reads its install, its check's note and its owner's sign-in, each the server user's alone: never
1020
+ // opened to a slot's user (the sign-in least of all), so where each run is a user of its own it is refused here. And a
1021
+ // plan-billed one's run that no person started (a schedule's, a trigger's) never runs on its owner's sign-in.
1022
+ if (isolation.kind === "uid" && recipeHarness(deps.env ?? {}, harness))
1023
+ throw new ClaimRefused(RECIPE_NEEDS_SERVER_USER);
1024
+ refuseRecipeTriggerRun(deps.env ?? {}, harness, launch);
901
1025
  if (runsInRunner(harness, launch))
902
1026
  return true;
903
1027
  if (launch.documents !== undefined) {
@@ -1018,7 +1142,9 @@ function childLoop(options, slots, loopDeps) {
1018
1142
  const runRow = await deps.store.runs.get(claim.runId);
1019
1143
  if (!runRow)
1020
1144
  throw new Error(`run ${claim.runId}: its row is gone from the store`);
1021
- const launch = readLaunchBody((await deps.store.runs.launch(claim.runId)).body);
1145
+ // The launch as this run runs it: on a named disk, with nothing learned on another disk (launchOnItsDisk).
1146
+ const read = readLaunchBody((await deps.store.runs.launch(claim.runId)).body);
1147
+ const launch = read && launchOnItsDisk(read);
1022
1148
  if (!launch)
1023
1149
  throw new Error(`run ${claim.runId}: its launch record could not be read as a launch`);
1024
1150
  const revisionRow = await deps.store.agents.revision(runRow.revisionId);
@@ -1029,9 +1155,14 @@ function childLoop(options, slots, loopDeps) {
1029
1155
  // in this process has it laid (harness-loops.ts): the run's process reads no store row of it and holds no seal key.
1030
1156
  const claimDeps = await withSavedGatewayDeps(deps);
1031
1157
  const claimEnv = claimDeps.env ?? {};
1158
+ // Refuse before taking a slot: even a slot's final reap normalizes modes in its run folders.
1159
+ if (launch.sourceProject && isolation.kind === "uid" && !await loadArchilSettings(deps.store, claimEnv)) {
1160
+ ready();
1161
+ throw new ClaimRefused("project_mode_fidelity: This runner rewrites local project file permissions for per-user isolation. A moved project needs a destination that preserves its original permissions.");
1162
+ }
1032
1163
  const savedGateway = savedGatewayIn(claimEnv);
1033
1164
  // The run's own keys: those its claim opens (claim-secrets.ts), the one list its loop in this process read.
1034
- const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }, revisionRow, launch);
1165
+ const claimed = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv, redact: loopDeps.redact ? heldRedactor(loopDeps.redact) : undefined }, revisionRow, launch, claim.runId);
1035
1166
  // With them, its revision's own model's (a launch pinned at its start to another model, a --faux start's, is still
1036
1167
  // handed its agent's model's key, as a run's own process was handed it before: run-secrets.ts secretsFor).
1037
1168
  const ofRevision = await claimSecrets({ store: deps.store, sealKey: deps.sealKey, env: claimEnv }, revisionRow, { ...(launch.plane ? { plane: launch.plane } : {}) });
@@ -1070,7 +1201,7 @@ function childLoop(options, slots, loopDeps) {
1070
1201
  const tops = runTops(deps.data, runRow.agentId, claim.runId);
1071
1202
  // The run's pieced writes (big-writes.ts): let go when its channel ends, or at the claim's release.
1072
1203
  const bigs = runBigWrites();
1073
- const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed }, cut, log, bigs);
1204
+ const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed, signal: loopDeps.signal }, cut, log, bigs);
1074
1205
  try {
1075
1206
  let extra = {};
1076
1207
  let argv = [...(options.argv ?? childArgv())];
@@ -1165,6 +1296,7 @@ function childLoop(options, slots, loopDeps) {
1165
1296
  }
1166
1297
  finally {
1167
1298
  ready();
1299
+ await heldSide.projectEnd?.();
1168
1300
  const reaped = await end(slot, tops).catch((error) => {
1169
1301
  log(`run ${claim.runId}: its process's end failed: ${error?.message ?? error}`);
1170
1302
  return false;
@@ -9,7 +9,7 @@ import { LaunchUnreadable, UnknownHarness } from "./dispatch.js";
9
9
  import { NeverFits } from "./harness-loops.js";
10
10
  import { ClaimRefused } from "./loop-contract.js";
11
11
  import { McpClaimRefused } from "./mcp-claim.js";
12
- import { registerErrors } from "./run-channel.js";
12
+ import { FrameTooLarge, registerErrors } from "./run-channel.js";
13
13
  import { ClaimLost } from "./runner.js";
14
14
  /** Registers every error class a run's process and its runner hand each other (run-channel.ts registerErrors). */
15
15
  export function registerRunErrors() {
@@ -17,6 +17,6 @@ export function registerRunErrors() {
17
17
  ClaimRefused, NeverFits, McpClaimRefused, ClaimLost, UnknownHarness, LaunchUnreadable,
18
18
  Fenced, CommandTaken, RunFinal, SignInHandedTo, SignInMissing, StoreBusy, StoreClosed, StoreConstraint, StoreDeadline, StoreLaunchMissing, StoreWorkerLost, Unanswered,
19
19
  ConversationBusy, ConversationIdle, ReadAfterWrite, ReadOnlySession, SessionFailed, StorageRequestError,
20
- WorkspaceError,
20
+ WorkspaceError, FrameTooLarge,
21
21
  });
22
22
  }
@@ -21,20 +21,21 @@ import { ARCHIL_SETTINGS_ENV } from "../archil-settings.js";
21
21
  import { BOX_ALLOW_ENV } from "../box-settings.js";
22
22
  import { TOOL_KEY_ROWS } from "../key-words.js";
23
23
  import { PRIVATE_HOSTS_ENV } from "../mcp-private-hosts.js";
24
- import { HARNESS_MODULES_SETTING } from "../harness-table.js";
24
+ import { HARNESS_MODULES_SETTING, HARNESS_RECIPES_SETTING } from "../harness-table.js";
25
25
  import { GATEWAY_IDS_ENV } from "../model-gateway.js";
26
26
  import { BOX_CPUS_ENV, BOX_MEMORY_ENV, BOX_PIDS_ENV, MCP_ALLOW_LOOPBACK_ENV } from "../start-switches.js";
27
27
  import { DOCKER_IMAGE_ENV } from "../box-image.js";
28
28
  import { bootSealKey } from "../seal-key.js";
29
29
  import { SECRET_NAMES } from "../secrets.js";
30
30
  import { SEAL_KEY_ENV } from "../tool-keys.js";
31
+ import { LAUNCH_HOOK_SECRET_ENV } from "../trigger-launch-hook.js";
31
32
  /** The store.settings key a server keeps the names of its run-facing environment under at each start: `{ v: 1, names }`. */
32
33
  export const RUN_ENV_KEY = "server.run_env";
33
34
  export const STORE_URL_ENV = "AGENTRUN_STORE_URL";
34
35
  /** The most connections a Postgres store holds at once; its start refuses a value that is no size (store/open.ts). */
35
36
  const POOL_SIZE_ENV = "AGENTRUN_STORE_POOL_SIZE";
36
37
  /** The server's own secrets: never a runner's (runner/main.ts RUNNER_ONLY keeps them from its runs, too). */
37
- const SERVER_ONLY = ["AGENTRUN_TOKEN", "AGENTRUN_TOKENS", "AGENTRUN_API_KEY"];
38
+ const SERVER_ONLY = ["AGENTRUN_TOKEN", "AGENTRUN_TOKENS", "AGENTRUN_API_KEY", LAUNCH_HOOK_SECRET_ENV];
38
39
  /** Names that are neither the server's run-facing environment nor the runner's: its own store and key (checked on their
39
40
  * own), the server's secrets, and a client's address of the server. */
40
41
  const NOT_RUN_FACING = new Set([...SERVER_ONLY, STORE_URL_ENV, SEAL_KEY_ENV, "AGENTRUN_BASE_URL"]);
@@ -61,6 +62,8 @@ const FIXED = new Set([
61
62
  // The harness modules a server loads (harness-table.ts): a runner without them claims their runs and has no harness to
62
63
  // run them on.
63
64
  HARNESS_MODULES_SETTING,
65
+ // And the harness recipes it runs (harness-table.ts), for the same reason.
66
+ HARNESS_RECIPES_SETTING,
64
67
  // A Docker computer's image and size (box-image.ts, workspace/computer-deps.ts dockerLimitsOf): read where the run's
65
68
  // computer starts, the runner.
66
69
  DOCKER_IMAGE_ENV,