@cnc-tools/storm 0.16.0 → 0.17.0

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 (281) hide show
  1. package/dist/application.d.ts +22 -13
  2. package/dist/application.js +21 -10
  3. package/dist/bin/run.d.ts +18 -0
  4. package/dist/bin/run.js +31 -0
  5. package/dist/bin/storm.js +42 -26
  6. package/dist/build-info.js +1 -1
  7. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
  8. package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
  9. package/dist/chunks/{chunk-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
  10. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
  11. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
  12. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  13. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
  14. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
  15. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
  16. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
  17. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
  18. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  19. package/dist/chunks/chunk-F4MOYHRY.js +198 -0
  20. package/dist/chunks/{chunk-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
  21. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
  22. package/dist/chunks/chunk-HP3CURSZ.js +88 -0
  23. package/dist/chunks/{chunk-DWEAHX4T.js → chunk-HWIQ2S7K.js} +5 -5
  24. package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
  25. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
  26. package/dist/chunks/{chunk-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
  27. package/dist/chunks/chunk-MR77L2GK.js +340 -0
  28. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
  29. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
  30. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
  31. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  32. package/dist/chunks/{chunk-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
  33. package/dist/chunks/{live-app-WECQOQ4C.js → live-app-R76JQXZL.js} +15 -13
  34. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
  35. package/dist/commands/exec/across-sandboxes-outcomes.js +2 -2
  36. package/dist/commands/exec/before-run.d.ts +123 -0
  37. package/dist/commands/exec/before-run.js +105 -0
  38. package/dist/commands/exec/command.d.ts +31 -2
  39. package/dist/commands/exec/command.js +31 -95
  40. package/dist/commands/exec/driver-plan.d.ts +9 -4
  41. package/dist/commands/exec/driver-plan.js +8 -8
  42. package/dist/commands/exec/exec-words.js +1 -1
  43. package/dist/commands/exec/execute-run.d.ts +39 -0
  44. package/dist/commands/exec/execute-run.js +325 -0
  45. package/dist/commands/exec/live-view.d.ts +3 -3
  46. package/dist/commands/exec/live-view.js +16 -15
  47. package/dist/commands/exec/metadata.js +1 -1
  48. package/dist/commands/exec/mint-failed.d.ts +38 -0
  49. package/dist/commands/exec/mint-failed.js +27 -4
  50. package/dist/commands/exec/outcomes.d.ts +34 -8
  51. package/dist/commands/exec/outcomes.js +30 -23
  52. package/dist/commands/exec/plan-run.d.ts +58 -150
  53. package/dist/commands/exec/plan-run.js +232 -88
  54. package/dist/commands/exec/progress.d.ts +10 -6
  55. package/dist/commands/exec/progress.js +38 -25
  56. package/dist/commands/exec/run-bin.d.ts +11 -11
  57. package/dist/commands/exec/run-bin.js +9 -9
  58. package/dist/commands/exec/run-flags.d.ts +69 -0
  59. package/dist/commands/exec/run-flags.js +58 -0
  60. package/dist/commands/exec/run-metadata.js +4 -4
  61. package/dist/commands/exec/run-summary.d.ts +58 -0
  62. package/dist/commands/exec/run-summary.js +205 -0
  63. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  64. package/dist/commands/exec/runner-refusals.js +71 -0
  65. package/dist/commands/exec/sandbox-progress.js +3 -0
  66. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  67. package/dist/commands/exec/stopped-outcome.js +77 -0
  68. package/dist/commands/exec/view.d.ts +20 -11
  69. package/dist/commands/exec/view.js +103 -47
  70. package/dist/commands/runs/facts.d.ts +7 -3
  71. package/dist/commands/runs/facts.js +17 -8
  72. package/dist/commands/runs/list/command.d.ts +14 -6
  73. package/dist/commands/runs/list/command.js +10 -10
  74. package/dist/commands/runs/list/outcomes.d.ts +7 -3
  75. package/dist/commands/runs/logs/command.js +10 -10
  76. package/dist/commands/runs/show/command.d.ts +14 -6
  77. package/dist/commands/runs/show/command.js +30 -28
  78. package/dist/commands/runs/show/outcomes.d.ts +7 -3
  79. package/dist/commands/runs/show/outcomes.js +7 -5
  80. package/dist/commands/snapshots/access.d.ts +111 -0
  81. package/dist/commands/snapshots/access.js +96 -0
  82. package/dist/commands/snapshots/build/command.d.ts +360 -93
  83. package/dist/commands/snapshots/build/command.js +446 -150
  84. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  85. package/dist/commands/snapshots/build/metadata.js +31 -11
  86. package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
  87. package/dist/commands/snapshots/build/outcomes.js +200 -36
  88. package/dist/commands/snapshots/list/command.d.ts +366 -25
  89. package/dist/commands/snapshots/list/command.js +296 -66
  90. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  91. package/dist/commands/snapshots/list/metadata.js +29 -6
  92. package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
  93. package/dist/commands/snapshots/list/outcomes.js +221 -50
  94. package/dist/commands/snapshots/metadata.js +1 -1
  95. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  96. package/dist/commands/snapshots/prune/command.js +161 -0
  97. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  98. package/dist/commands/snapshots/prune/metadata.js +39 -0
  99. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  100. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  101. package/dist/commands/suites/list/command.js +17 -17
  102. package/dist/commands/suites/list/outcomes.js +2 -2
  103. package/dist/commands/test/command.d.ts +31 -2
  104. package/dist/commands/test/command.js +49 -252
  105. package/dist/commands/test/outcomes.d.ts +15 -1
  106. package/dist/config/check-runner.d.ts +3 -3
  107. package/dist/config/check-runner.js +8 -7
  108. package/dist/config/credential-resolver.d.ts +50 -5
  109. package/dist/config/credential-resolver.js +51 -19
  110. package/dist/config/credential-settle.d.ts +6 -2
  111. package/dist/config/credential-settle.js +11 -5
  112. package/dist/config/index.d.ts +2 -2
  113. package/dist/config/index.js +1 -1
  114. package/dist/config/runner.d.ts +5 -5
  115. package/dist/config/runner.js +1 -1
  116. package/dist/config/schema.d.ts +2 -2
  117. package/dist/config/schema.js +1 -1
  118. package/dist/config-file/define.d.ts +1 -1
  119. package/dist/config-file/define.js +1 -1
  120. package/dist/config-file/runner.d.ts +5 -5
  121. package/dist/config-file/toolchain.d.ts +1 -1
  122. package/dist/config-file/toolchain.js +2 -2
  123. package/dist/context.d.ts +8 -6
  124. package/dist/context.js +7 -6
  125. package/dist/core/across-sandboxes.d.ts +7 -6
  126. package/dist/core/across-sandboxes.js +123 -152
  127. package/dist/core/coordinator.d.ts +166 -0
  128. package/dist/core/coordinator.js +233 -0
  129. package/dist/core/events.d.ts +2 -2
  130. package/dist/core/index.d.ts +4 -2
  131. package/dist/core/index.js +1 -1
  132. package/dist/core/outcomes.d.ts +148 -0
  133. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  134. package/dist/core/resources.d.ts +31 -53
  135. package/dist/core/resources.js +32 -70
  136. package/dist/core/run-state.d.ts +7 -1
  137. package/dist/core/run-state.js +2 -0
  138. package/dist/core/run.d.ts +32 -236
  139. package/dist/core/run.js +106 -266
  140. package/dist/core/state-directory.d.ts +1 -1
  141. package/dist/core/state-directory.js +2 -2
  142. package/dist/credential/gateways.d.ts +15 -1
  143. package/dist/credential/index.d.ts +4 -3
  144. package/dist/credential/index.js +3 -2
  145. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  146. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  147. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  148. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  149. package/dist/credential/source.d.ts +73 -6
  150. package/dist/credential/source.js +55 -2
  151. package/dist/extension-commands.d.ts +6 -1
  152. package/dist/extension-commands.js +15 -1
  153. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  154. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  155. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  156. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  157. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  158. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  159. package/dist/extensions/testserver/credential-facts.js +29 -11
  160. package/dist/extensions/testserver/lifecycle.js +7 -1
  161. package/dist/extensions/testserver/limit.d.ts +3 -0
  162. package/dist/extensions/testserver/limit.js +3 -0
  163. package/dist/extensions/testserver/provision.d.ts +8 -1
  164. package/dist/extensions/testserver/provision.js +8 -3
  165. package/dist/extensions/testserver/refusals.d.ts +6 -1
  166. package/dist/extensions/testserver/refusals.js +16 -1
  167. package/dist/extensions/testserver/resource.d.ts +1 -1
  168. package/dist/extensions/testserver/resource.js +1 -1
  169. package/dist/extensions/testserver/result.d.ts +1 -1
  170. package/dist/extensions/testserver/result.js +9 -4
  171. package/dist/planning/driver-file-lists.d.ts +0 -15
  172. package/dist/planning/driver-file-lists.js +2 -21
  173. package/dist/planning/plan-only.d.ts +3 -14
  174. package/dist/planning/plan-only.js +11 -20
  175. package/dist/planning/run-kind-flags.js +2 -2
  176. package/dist/planning/run-plan.d.ts +45 -12
  177. package/dist/planning/run-plan.js +4 -3
  178. package/dist/planning/suites.d.ts +1 -1
  179. package/dist/planning/suites.js +2 -2
  180. package/dist/planning/test-plan.d.ts +9 -0
  181. package/dist/planning/test-plan.js +9 -0
  182. package/dist/run-directory/recording.js +2 -2
  183. package/dist/run-directory/run-record.d.ts +21 -6
  184. package/dist/run-directory/run-record.js +12 -9
  185. package/dist/runner/base.js +1 -1
  186. package/dist/runner/build-snapshots.d.ts +55 -29
  187. package/dist/runner/build-snapshots.js +130 -29
  188. package/dist/runner/context.d.ts +15 -7
  189. package/dist/runner/context.js +19 -6
  190. package/dist/runner/events.d.ts +16 -10
  191. package/dist/runner/gateways.d.ts +87 -21
  192. package/dist/runner/gateways.js +1 -1
  193. package/dist/runner/index.d.ts +11 -7
  194. package/dist/runner/index.js +9 -4
  195. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  196. package/dist/runner/live/sandbox-errors.js +4 -0
  197. package/dist/runner/live/sandbox-gateway.js +129 -3
  198. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  199. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  200. package/dist/runner/live/snapshot-records.js +6 -7
  201. package/dist/runner/local-snapshot-index.d.ts +199 -0
  202. package/dist/runner/local-snapshot-index.js +211 -0
  203. package/dist/runner/network-policy.d.ts +6 -6
  204. package/dist/runner/network-policy.js +7 -7
  205. package/dist/runner/policy-writes.d.ts +1 -1
  206. package/dist/runner/policy-writes.js +1 -1
  207. package/dist/runner/prepare.d.ts +14 -14
  208. package/dist/runner/prepare.js +20 -11
  209. package/dist/runner/ready.d.ts +18 -10
  210. package/dist/runner/ready.js +104 -33
  211. package/dist/runner/sandboxed-command.d.ts +3 -3
  212. package/dist/runner/sandboxed-command.js +3 -3
  213. package/dist/runner/scope.d.ts +10 -6
  214. package/dist/runner/scope.js +10 -3
  215. package/dist/runner/secrets.d.ts +13 -13
  216. package/dist/runner/secrets.js +18 -15
  217. package/dist/runner/session.d.ts +8 -8
  218. package/dist/runner/session.js +3 -3
  219. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  220. package/dist/runner/shared-snapshot-entry.js +168 -0
  221. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  222. package/dist/runner/shared-snapshot-list.js +155 -0
  223. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  224. package/dist/runner/shared-snapshot-lookup.js +118 -0
  225. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  226. package/dist/runner/shared-snapshot-prune.js +133 -0
  227. package/dist/runner/snapshot-build.d.ts +42 -14
  228. package/dist/runner/snapshot-build.js +32 -29
  229. package/dist/runner/snapshot-choice.js +1 -1
  230. package/dist/runner/snapshot-inspect.d.ts +39 -40
  231. package/dist/runner/snapshot-inspect.js +55 -35
  232. package/dist/runner/snapshot-key.d.ts +13 -12
  233. package/dist/runner/snapshot-key.js +13 -12
  234. package/dist/runner/steps.d.ts +1 -1
  235. package/dist/runner/steps.js +1 -1
  236. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
  237. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
  238. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
  239. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
  240. package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
  241. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
  242. package/dist/sdk/extension/commands.d.ts +8 -3
  243. package/dist/sdk/extension/commands.js +3 -1
  244. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  245. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  246. package/dist/sdk/extension/credential-source.d.ts +20 -3
  247. package/dist/sdk/extension/credential-source.js +4 -4
  248. package/dist/sdk/extension/index.d.ts +3 -2
  249. package/dist/sdk/extension/index.js +2 -1
  250. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  251. package/dist/sdk/extension/secret-source.d.ts +1 -1
  252. package/dist/sdk/extension/secret-source.js +1 -1
  253. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  254. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  255. package/dist/shared/cleanup.d.ts +3 -3
  256. package/dist/shared/cleanup.js +15 -5
  257. package/dist/shared/snapshot-text.d.ts +4 -4
  258. package/dist/shared/snapshot-text.js +11 -11
  259. package/dist/time/duration.js +1 -1
  260. package/package.json +3 -2
  261. package/skills/overview.md +4 -4
  262. package/skills/plan-runs.md +1 -1
  263. package/skills/read-run-output.md +6 -6
  264. package/dist/chunks/chunk-7EENF73W.js +0 -782
  265. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  266. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  267. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  268. package/dist/commands/exec/plan-only.d.ts +0 -10
  269. package/dist/commands/exec/plan-only.js +0 -45
  270. package/dist/commands/exec/run-command.d.ts +0 -475
  271. package/dist/commands/exec/run-command.js +0 -603
  272. package/dist/commands/exec/run-planned.d.ts +0 -20
  273. package/dist/commands/exec/run-planned.js +0 -22
  274. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  275. package/dist/commands/exec/sandbox-view.js +0 -72
  276. package/dist/commands/test/plan.d.ts +0 -92
  277. package/dist/commands/test/plan.js +0 -125
  278. package/dist/core/sandbox-end.d.ts +0 -64
  279. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  280. package/dist/runner/snapshot-cache.d.ts +0 -148
  281. package/dist/runner/snapshot-cache.js +0 -126
@@ -1,180 +0,0 @@
1
- import { type CommandError, type ExecutionContext } from "@vercel/clinkr";
2
- import type { z } from "zod";
3
- import type { StormApp } from "../../context.ts";
4
- import { type ResourceLifecycles } from "../../core/index.ts";
5
- import type { PlannedSandboxesRun, PlannedWhere } from "../../planning/run-plan.ts";
6
- import type { DriverHints, RunTestPlan } from "../../sdk/extension/index.ts";
7
- import type { PlanCommand, PlannedCommand, PlannedSettings, RunPlan } from "./plan-run.ts";
8
- import { type RunCommandRequest, type RunPlanRequest } from "./run-command.ts";
9
- import { sandboxesErrors, type sandboxesRanSchema } from "./across-sandboxes-outcomes.ts";
10
- export declare const SANDBOXES_MAX_KEY = "runner.sandboxes.max";
11
- export declare const SANDBOXES_DEFAULT_KEY = "runner.sandboxes.default";
12
- type SandboxesMaxRefusal = ReturnType<typeof sandboxesErrors.missingSandboxesMax> | ReturnType<typeof sandboxesErrors.sandboxesOverMax>;
13
- /** The runner sandboxes a run asks for: how many, and the flag that asked. */
14
- export interface SandboxesAsk {
15
- readonly count: number;
16
- readonly flag: "--sandboxes" | "--file-lists";
17
- }
18
- export type AcrossSandboxesWhere = Extract<PlannedWhere, {
19
- readonly kind: "runner";
20
- }>;
21
- /**
22
- * Where a run across runner sandboxes runs: `where`, a runner sandbox. Every run across runner sandboxes uses the Vercel
23
- * Sandbox runner: `planRun` refuses `--sandboxes` and `--file-lists` for the launch machine runner
24
- * (`conflicting_options`), and `runner.sandboxes.default` lives in `vercelSandbox({ … })`. So any other `where` is a
25
- * mistake in storm, and throws.
26
- */
27
- export declare function acrossSandboxesWhere(where: PlannedWhere): AcrossSandboxesWhere;
28
- /**
29
- * A command's part of planning a run across runner sandboxes, once storm knows the run's runner and its max (`max`):
30
- * the command's part of planning (`PlannedCommand`), with each runner sandbox's command and file list.
31
- */
32
- export type PlanSandboxesRun<TTestPlan extends RunTestPlan, TRefusal> = (plan: {
33
- readonly where: AcrossSandboxesWhere;
34
- readonly max: number;
35
- readonly settings: PlannedSettings;
36
- }, signal: AbortSignal) => Promise<(PlannedCommand<TTestPlan> & {
37
- readonly sandboxes: PlannedSandboxesRun;
38
- }) | {
39
- readonly ok: false;
40
- readonly refusal: TRefusal;
41
- }>;
42
- /**
43
- * How one command runs a planned run across runner sandboxes: its name, the driver and suite of a `storm test` run, its
44
- * words, and its `sandboxes_ran` outcome, from what every such run reports and whether it saved no final test result.
45
- */
46
- export interface AcrossSandboxesSpec<TRan> {
47
- readonly name: string;
48
- /** The driver and suite (`null` for the project's tests) of a `storm test` run; absent for `storm exec`. Recorded in `run.json`. */
49
- readonly test?: {
50
- readonly driver: string;
51
- readonly suite: string | null;
52
- } | undefined;
53
- readonly hints: Pick<DriverHints, "noFinalResults">;
54
- readonly extraMismatchHint?: string;
55
- sandboxesRan(facts: z.input<typeof sandboxesRanSchema>, noFinalTestResults: boolean): TRan;
56
- }
57
- /** A planned run across runner sandboxes: its runner sandboxes, and the runner that each runner sandbox starts from. */
58
- export type AcrossSandboxesPlan = RunPlan & {
59
- readonly where: AcrossSandboxesWhere;
60
- readonly sandboxes: PlannedSandboxesRun;
61
- };
62
- /** Keep time of each runner sandbox, in milliseconds: `--keep-sandbox`, else 0. */
63
- export declare function sandboxKeepMs(flag: string | undefined): number;
64
- /**
65
- * Plans a run that asks for runner sandboxes (`asked`: `--sandboxes` or `--file-lists`), before it mints. It refuses a
66
- * config file with no `runner.sandboxes` (`missing_sandboxes_max`) and more runner sandboxes than its max
67
- * (`sandboxes_over_max`).
68
- */
69
- export declare function planAskedSandboxesRun<TTestPlan extends RunTestPlan, TRefusal extends CommandError = never>(app: StormApp, request: RunPlanRequest, asked: SandboxesAsk, planSandboxes: PlanSandboxesRun<TTestPlan, TRefusal>, signal: AbortSignal): Promise<{
70
- readonly ok: false;
71
- readonly refusal: CommandError<"invalid_resource_options">;
72
- } | {
73
- readonly ok: false;
74
- readonly refusal: CommandError<"missing_target">;
75
- } | {
76
- readonly ok: false;
77
- readonly refusal: import("@vercel/clinkr").ClinkrError<"canceled">;
78
- } | {
79
- readonly ok: false;
80
- readonly refusal: CommandError<"conflicting_options">;
81
- } | {
82
- readonly ok: false;
83
- readonly refusal: CommandError<"credentials_invalid">;
84
- } | {
85
- readonly ok: false;
86
- readonly refusal: CommandError<"keep_sandbox_unsafe_secret_env_vars">;
87
- } | {
88
- readonly ok: false;
89
- readonly refusal: CommandError<"missing_runner">;
90
- } | {
91
- readonly ok: false;
92
- readonly refusal: CommandError<"unsafe_secret_env_vars_invalid">;
93
- } | {
94
- readonly ok: false;
95
- readonly refusal: TRefusal | SandboxesMaxRefusal;
96
- } | {
97
- readonly ok: true;
98
- readonly planned: {
99
- readonly ok: true;
100
- readonly configFile: string | null;
101
- readonly settings: import("../../config/resolve.ts").ResolvedSettings;
102
- readonly where: PlannedWhere;
103
- readonly argv: readonly string[];
104
- readonly testPlan: TTestPlan;
105
- readonly testFiles: readonly string[] | undefined;
106
- readonly sandboxes: PlannedSandboxesRun | undefined;
107
- readonly resources: {
108
- readonly [key: string]: import("../../config/resolve.ts").ResolvedResourceRecord;
109
- };
110
- readonly planOptions: Readonly<{
111
- path: string;
112
- value: string | number | boolean;
113
- from: "default" | "file" | "flag";
114
- }>[];
115
- };
116
- readonly lifecycles: ResourceLifecycles;
117
- }>;
118
- /**
119
- * Plans a run of a command that takes its runner sandboxes from `runner.sandboxes.default`: a run across runner
120
- * sandboxes when the run has a runner whose recipe sets the default, and else a run that is not across runner
121
- * sandboxes, planned by `planCommand`. A run that the default gives runner sandboxes refuses `--show-output`
122
- * (`sandboxes_default_refused`).
123
- */
124
- export declare function planDefaultSandboxesRun<TTestPlan extends RunTestPlan, TRefusal extends CommandError = never>(app: StormApp, request: RunPlanRequest, planCommand: PlanCommand<TTestPlan, TRefusal>, planSandboxes: PlanSandboxesRun<TTestPlan, TRefusal>, signal: AbortSignal): Promise<{
125
- readonly ok: false;
126
- readonly refusal: CommandError<"invalid_resource_options">;
127
- } | {
128
- readonly ok: false;
129
- readonly refusal: CommandError<"missing_target">;
130
- } | {
131
- readonly ok: false;
132
- readonly refusal: TRefusal;
133
- } | {
134
- readonly ok: false;
135
- readonly refusal: import("@vercel/clinkr").ClinkrError<"canceled">;
136
- } | {
137
- readonly ok: false;
138
- readonly refusal: CommandError<"conflicting_options">;
139
- } | {
140
- readonly ok: false;
141
- readonly refusal: CommandError<"credentials_invalid">;
142
- } | {
143
- readonly ok: false;
144
- readonly refusal: CommandError<"keep_sandbox_unsafe_secret_env_vars">;
145
- } | {
146
- readonly ok: false;
147
- readonly refusal: CommandError<"missing_runner">;
148
- } | {
149
- readonly ok: false;
150
- readonly refusal: CommandError<"sandboxes_default_refused">;
151
- } | {
152
- readonly ok: false;
153
- readonly refusal: CommandError<"unsafe_secret_env_vars_invalid">;
154
- } | {
155
- readonly ok: true;
156
- readonly planned: {
157
- readonly ok: true;
158
- readonly configFile: string | null;
159
- readonly settings: import("../../config/resolve.ts").ResolvedSettings;
160
- readonly where: PlannedWhere;
161
- readonly argv: readonly string[];
162
- readonly testPlan: TTestPlan;
163
- readonly testFiles: readonly string[] | undefined;
164
- readonly sandboxes: PlannedSandboxesRun | undefined;
165
- readonly resources: {
166
- readonly [key: string]: import("../../config/resolve.ts").ResolvedResourceRecord;
167
- };
168
- readonly planOptions: Readonly<{
169
- path: string;
170
- value: string | number | boolean;
171
- from: "default" | "file" | "flag";
172
- }>[];
173
- };
174
- readonly lifecycles: ResourceLifecycles;
175
- }>;
176
- /**
177
- * Runs a planned run across runner sandboxes through the unified session, lifecycle, redaction, and outcome pipeline.
178
- */
179
- export declare function runPlannedAcrossSandboxes<TRan>(context: ExecutionContext<StormApp>, request: RunCommandRequest, spec: AcrossSandboxesSpec<TRan>, planned: AcrossSandboxesPlan, lifecycles: ResourceLifecycles): Promise<TRan | import("@vercel/clinkr").ClinkrError<"canceled"> | CommandError<"credential_unused"> | CommandError<"invalid_config"> | CommandError<"mint_failed"> | CommandError<"missing_target"> | CommandError<"no_base_ref"> | CommandError<"resource_needs_runner_sandbox"> | CommandError<"resource_refused"> | CommandError<"resource_refused_before_run"> | CommandError<"runner_failed"> | CommandError<"snapshot_gone"> | CommandError<"spawn_failed"> | CommandError<"submodules_refused">>;
180
- export {};
@@ -1,339 +0,0 @@
1
- // A run across runner sandboxes, in two parts. Planning: `planAskedSandboxesRun` plans a run that asks for runner
2
- // sandboxes (`--sandboxes` or `--file-lists`), and `planDefaultSandboxesRun` a run that takes them from
3
- // `runner.sandboxes.default` when the recipe has one; both plan through `planCommandRun` (`run-command.ts`), as a run
4
- // that is not across runner sandboxes does. Running: `runPlannedAcrossSandboxes` reuses `beforeRunStarts`,
5
- // `runnerRequestFor`, `runLifecycle`, and `mapStoppedOutcome` from `run-command.ts`, routes runner
6
- // sandbox headers and events through the shared `redactor`, tags test events with `sandbox` before calling
7
- // `testsSummaryLines`, and shows the run through its view (`sandbox-view.ts`).
8
- import { refused } from "@vercel/clinkr";
9
- import { executeAcrossSandboxes, acrossSandboxesExitStatus, timedProgress, } from "../../core/index.js";
10
- import { DEFINITION_SET } from "../../extensions.js";
11
- import { lacksFinalResults } from "../../planning/final-results.js";
12
- import { redactingObserver, redactingTerminal, redactor, redactStrings } from "../../planning/redaction.js";
13
- import { fileListMismatches } from "../../planning/file-lists.js";
14
- import { recordedPlan } from "../../planning/test-plan.js";
15
- import { recordAcrossSandboxes, } from "../../run-directory/index.js";
16
- import { RUN_CLEANUP } from "../../shared/cleanup.js";
17
- import { sandboxConnectPage } from "../../shared/dashboard.js";
18
- import { acrossSandboxesJobSummaryMarkdown } from "../../shared/job-summary.js";
19
- import { testsSummaryLines } from "../../shared/tests-summary.js";
20
- import { isoSecondsText, paint } from "../../shared/text.js";
21
- import { waterfallLines } from "../../shared/waterfall.js";
22
- import { testsChart } from "../../shared/worker-chart.js";
23
- import { parseKeepTime } from "../../time/index.js";
24
- import { beforeRunStarts, checkoutGit, displayPath, logsText, mapStoppedOutcome, planCommandRun, runLifecycle, runnerRequestFor, } from "./run-command.js";
25
- import { acrossSandboxesEndLines, acrossSandboxesHeaderLines, showsFailed, } from "./sandbox-lines.js";
26
- import { sandboxesDefaultErrors, sandboxesErrors } from "./across-sandboxes-outcomes.js";
27
- import { sandboxProgress } from "./sandbox-progress.js";
28
- import { sandboxView } from "./sandbox-view.js";
29
- export const SANDBOXES_MAX_KEY = "runner.sandboxes.max";
30
- export const SANDBOXES_DEFAULT_KEY = "runner.sandboxes.default";
31
- const SHOW_OUTPUT_ACROSS_SANDBOXES = "a run across runner sandboxes prints status lines and no step output, and each runner sandbox entry of its run directory keeps its step logs; drop --show-output.";
32
- /**
33
- * Where a run across runner sandboxes runs: `where`, a runner sandbox. Every run across runner sandboxes uses the Vercel
34
- * Sandbox runner: `planRun` refuses `--sandboxes` and `--file-lists` for the launch machine runner
35
- * (`conflicting_options`), and `runner.sandboxes.default` lives in `vercelSandbox({ … })`. So any other `where` is a
36
- * mistake in storm, and throws.
37
- */
38
- export function acrossSandboxesWhere(where) {
39
- if (where.kind !== "runner")
40
- throw new Error("a run across runner sandboxes has a runner");
41
- return where;
42
- }
43
- /** Keep time of each runner sandbox, in milliseconds: `--keep-sandbox`, else 0. */
44
- export function sandboxKeepMs(flag) {
45
- const minutes = flag === undefined ? 0 : (parseKeepTime(flag) ?? 0);
46
- return minutes * 60_000;
47
- }
48
- /**
49
- * Plans a run that asks for runner sandboxes (`asked`: `--sandboxes` or `--file-lists`), before it mints. It refuses a
50
- * config file with no `runner.sandboxes` (`missing_sandboxes_max`) and more runner sandboxes than its max
51
- * (`sandboxes_over_max`).
52
- */
53
- export async function planAskedSandboxesRun(app, request, asked, planSandboxes, signal) {
54
- return await planCommandRun(app, request, async (planned, planSignal, settings) => {
55
- const where = acrossSandboxesWhere(planned);
56
- const { configFile } = settings;
57
- const policy = where.recipe.sandboxes;
58
- if (policy === undefined)
59
- return refused(sandboxesErrors.missingSandboxesMax({ flag: asked.flag, key: SANDBOXES_MAX_KEY, configFile }));
60
- if (asked.count > policy.max)
61
- return refused(sandboxesErrors.sandboxesOverMax({
62
- flag: asked.flag,
63
- sandboxes: asked.count,
64
- key: SANDBOXES_MAX_KEY,
65
- max: policy.max,
66
- configFile,
67
- }));
68
- return await planSandboxes({ where, max: policy.max, settings }, planSignal);
69
- }, signal);
70
- }
71
- /**
72
- * Plans a run of a command that takes its runner sandboxes from `runner.sandboxes.default`: a run across runner
73
- * sandboxes when the run has a runner whose recipe sets the default, and else a run that is not across runner
74
- * sandboxes, planned by `planCommand`. A run that the default gives runner sandboxes refuses `--show-output`
75
- * (`sandboxes_default_refused`).
76
- */
77
- export async function planDefaultSandboxesRun(app, request, planCommand, planSandboxes, signal) {
78
- const plan = await planCommandRun(app, request, async (where, planSignal, settings) => {
79
- const policy = where.kind === "runner" ? where.recipe.sandboxes : undefined;
80
- if (where.kind !== "runner" || policy?.default === undefined)
81
- return await planCommand(where, planSignal, settings);
82
- return await planSandboxes({ where, max: policy.max, settings }, planSignal);
83
- }, signal);
84
- if (!plan.ok || plan.planned.sandboxes === undefined)
85
- return plan;
86
- if (request.showOutput)
87
- return refused(sandboxesDefaultErrors.sandboxesDefaultRefused({
88
- key: SANDBOXES_DEFAULT_KEY,
89
- sandboxes: plan.planned.sandboxes.sandboxes.length,
90
- field: "showOutput",
91
- problem: SHOW_OUTPUT_ACROSS_SANDBOXES,
92
- configFile: plan.planned.configFile,
93
- }));
94
- return plan;
95
- }
96
- /**
97
- * Runs a planned run across runner sandboxes through the unified session, lifecycle, redaction, and outcome pipeline.
98
- */
99
- export async function runPlannedAcrossSandboxes(context, request, spec, planned, lifecycles) {
100
- const { app, ui, signal } = context;
101
- const { configFile, argv, where } = planned;
102
- const sandboxes = planned.sandboxes.sandboxes;
103
- const count = sandboxes.length;
104
- // A run across runner sandboxes always has a test plan: its number of runner sandboxes, beside what it counted.
105
- const plan = {
106
- ...(recordedPlan(planned.testPlan, planned.planOptions) ?? { options: [] }),
107
- sandboxes: planned.sandboxes.count,
108
- };
109
- const before = await beforeRunStarts(context, lifecycles, planned, request, plan);
110
- if (!before.ok)
111
- return before.refusal;
112
- const { used } = before;
113
- const requested = await runnerRequestFor(app, where, used, {
114
- configFile,
115
- sandboxes: count,
116
- keepMs: sandboxKeepMs(request.keepSandbox),
117
- });
118
- if (!requested.ok)
119
- return requested.refusal;
120
- const { runner } = requested;
121
- // The resources' secrets, the credentials' values, and any unsafe secret environment variables' values.
122
- const secrets = [...used.secrets, ...where.secrets];
123
- const redact = redactor(secrets);
124
- const git = await checkoutGit(app.context.checkout, app.cwd);
125
- const recording = await recordAcrossSandboxes(app.context.runDirectories, {
126
- definitionSet: DEFINITION_SET,
127
- clock: app.context.clock,
128
- cwd: app.cwd,
129
- configFile,
130
- argv,
131
- ...(spec.test === undefined ? {} : { test: spec.test }),
132
- plan,
133
- runner,
134
- sandboxes,
135
- git,
136
- redact: (value) => redactStrings(value, redact),
137
- });
138
- const runDirectory = recording.opened.ok
139
- ? `${displayPath(recording.opened.path, app.env)}/`
140
- : `none: couldn't make ${recording.opened.failure.path}: ${recording.opened.failure.message}`;
141
- // Redact raw argv elements before shell-quoting so secrets containing apostrophes cannot bypass literal masking,
142
- // and keep final header redaction for other fields such as runDirectory.
143
- const view = sandboxView(app, ui.progress, sandboxProgress({
144
- count,
145
- listed: sandboxes.map(({ files }) => (files === null ? null : files.length)),
146
- header: acrossSandboxesHeaderLines({
147
- version: app.version,
148
- commit: app.commit,
149
- argv: argv.map(redact),
150
- count,
151
- runDirectory,
152
- }).map(redact),
153
- }));
154
- const observer = recording.observer(view.observer);
155
- const outcome = await runLifecycle({
156
- execute: async () => await executeAcrossSandboxes(DEFINITION_SET, {
157
- ...app.context,
158
- sandboxTerminal: (sandbox) => {
159
- const terminal = recording.terminal(sandbox, app.context.runnerTerminal);
160
- return secrets.length === 0 ? terminal : redactingTerminal(terminal, redact);
161
- },
162
- }, app.resourceContexts, {
163
- version: app.version,
164
- commit: app.commit,
165
- configFile,
166
- verbose: request.verbose,
167
- runner,
168
- sandboxes: sandboxes.map((sandbox) => ({
169
- argv: sandbox.argv,
170
- ...(sandbox.files === null ? {} : { files: sandbox.files }),
171
- })),
172
- resources: used.requests,
173
- skipped: used.skipped,
174
- }, { signal }, timedProgress(app.context.clock, secrets.length === 0 ? observer : redactingObserver(observer, redact))),
175
- redact,
176
- hasSecrets: secrets.length > 0,
177
- finishView: async () => view.finish(),
178
- abandonRecording: async () => await recording.abandon(),
179
- });
180
- view.finish();
181
- const recorded = await recording.end(outcome);
182
- const mismatches = outcome.kind === "sandboxes_ran" ? listMismatches(recorded) : [];
183
- await summarizeAcrossSandboxes(app, ui.progress, {
184
- command: spec.name,
185
- hints: spec.hints,
186
- ...(spec.extraMismatchHint === undefined ? {} : { extraMismatchHint: spec.extraMismatchHint }),
187
- recording,
188
- recorded,
189
- outcome,
190
- mismatches,
191
- });
192
- if (outcome.kind === "sandboxes_ran") {
193
- app.exit.status = acrossSandboxesExitStatus(outcome.sandboxes);
194
- const facts = sandboxesRanFacts(app, { outcome, recorded, recording, plan, runner, configFile, mismatches });
195
- const everyExited0 = outcome.sandboxes.every(({ state, exitCode }) => state === "passed" && exitCode === 0);
196
- const noFinalTestResults = lacksFinalResults(everyExited0 ? 0 : null, {
197
- finalResults: recorded.tests.events.filter((event) => event.kind === "test-result").length,
198
- partial: recorded.tests.unreadable > 0 || recorded.tests.incomplete !== undefined,
199
- collected: true,
200
- });
201
- return spec.sandboxesRan(secrets.length === 0 ? facts : redactStrings(facts, redact), noFinalTestResults);
202
- }
203
- // Reuse the shared stopped-outcome mapper (including resource cancellation lines for canceled runs!).
204
- const keptLines = recorded.sandboxes.flatMap(({ record }) => record.name === null || record.keptUntil === null
205
- ? []
206
- : [`Kept runner sandbox ${record.sandbox}, ${record.name}, running until ${isoSecondsText(record.keptUntil)}.`]);
207
- return mapStoppedOutcome(outcome, {
208
- commandLine: outcome.kind === "canceled" && outcome.commandStopped === true
209
- ? "Each command that was running was stopped in its runner sandbox."
210
- : "The command didn't run.",
211
- keptLines,
212
- });
213
- }
214
- function listMismatches(recorded) {
215
- return fileListMismatches(recorded.sandboxes.map(({ record, tests }) => ({
216
- sandbox: record.sandbox,
217
- files: record.files,
218
- exitCode: record.exitCode,
219
- reported: tests.events.map((event) => event.file),
220
- whole: tests.unreadable === 0 && tests.incomplete === undefined,
221
- })));
222
- }
223
- async function summarizeAcrossSandboxes(app, progress, run) {
224
- const { recording, recorded, hints } = run;
225
- const { presentation } = app;
226
- const width = Math.min(Math.max(presentation.columns ?? 80, 60), 120);
227
- const style = paint(presentation.colorDepth !== "none");
228
- // Tag each event with its runner sandbox so multi-sandbox worker counts aggregate per runner sandbox without
229
- // colliding worker 0.
230
- const events = recorded.sandboxes.flatMap((sandbox) => sandbox.tests.events.map((event) => ({ ...event, sandbox: sandbox.record.sandbox })));
231
- const testsLines = testsSummaryLines(events, hints, recorded.tests.unreadable, recorded.tests.incomplete);
232
- const failed = events.some((event) => event.kind === "test-result" && event.state === "fail");
233
- const opened = recording.opened;
234
- const summarized = await app.context.jobSummary.appendJobSummary(acrossSandboxesJobSummaryMarkdown(recorded.sandboxes.map(({ record }) => record), { command: run.command, logs: opened.ok ? opened.path : undefined, details: testsLines }));
235
- if (progress === undefined)
236
- return;
237
- const ranSandboxes = run.outcome.kind === "sandboxes_ran" || run.outcome.kind === "canceled";
238
- const sandboxes = recorded.sandboxes.map((sandbox) => {
239
- const tests = sandbox.timeline.rows.find((row) => row.name === "command");
240
- const charted = tests === undefined
241
- ? undefined
242
- : testsChart(sandbox.tests.events, hints, sandbox.tests.unreadable, { runStartedAt: Date.parse(sandbox.timeline.startedAt), offsetMs: sandbox.workerOffsetMs, tests }, sandbox.tests.incomplete);
243
- return {
244
- sandbox: sandbox.record.sandbox,
245
- waterfall: waterfallLines(sandbox.timeline, {
246
- width,
247
- colorDepth: presentation.colorDepth,
248
- logs: undefined,
249
- ...(charted === undefined ? {} : { workers: charted.lanes, details: charted.notes }),
250
- }),
251
- };
252
- });
253
- const [first] = sandboxes;
254
- const runId = opened.ok ? opened.id : undefined;
255
- const records = recorded.sandboxes.map(({ record }) => record);
256
- const lines = acrossSandboxesEndLines({
257
- sandboxes: ranSandboxes ? sandboxes : [],
258
- records,
259
- tests: testsLines,
260
- runId,
261
- logs: logsText(recording, recorded.writeFailure, app.env, failed && !showsFailed(records, runId), false),
262
- mismatches: run.mismatches,
263
- ...(run.extraMismatchHint === undefined ? {} : { extraMismatchHint: run.extraMismatchHint }),
264
- paint: style,
265
- });
266
- const once = ranSandboxes || first === undefined ? [] : first.waterfall;
267
- const summaryFailure = summarized.kind === "failed"
268
- ? [` couldn't append to the job summary at ${summarized.failure.path}: ${summarized.failure.message}`]
269
- : [];
270
- for (const line of [...once, ...lines, ...summaryFailure])
271
- try {
272
- await progress(line);
273
- }
274
- catch {
275
- return;
276
- }
277
- }
278
- function sandboxesRanFacts(app, run) {
279
- const { outcome, recorded, recording, plan, runner } = run;
280
- const records = recorded.sandboxes.map(({ record }) => record);
281
- const count = (state) => records.filter((record) => record.state === state).length;
282
- const totals = records.flatMap(({ tests }) => (tests === null ? [] : [tests]));
283
- const snapshotState = recorded.state.runner?.snapshot;
284
- const { entry } = outcome.snapshot;
285
- return {
286
- version: app.version,
287
- commit: app.commit,
288
- configFile: run.configFile,
289
- runId: recording.opened.ok ? recording.opened.id : null,
290
- runDirectory: recording.opened.ok ? recording.opened.path : null,
291
- sandboxes: records,
292
- states: {
293
- passed: count("passed"),
294
- failed: count("failed"),
295
- "not-started": count("not-started"),
296
- canceled: count("canceled"),
297
- },
298
- tests: totals.length === 0
299
- ? null
300
- : {
301
- passed: totals.reduce((sum, { passed }) => sum + passed, 0),
302
- failed: totals.reduce((sum, { failed }) => sum + failed, 0),
303
- skipped: totals.reduce((sum, { skipped }) => sum + skipped, 0),
304
- },
305
- plan: {
306
- ...plan,
307
- options: plan.options.map((option) => ({ ...option })),
308
- ...(plan.sandboxes === undefined ? {} : { sandboxes: { ...plan.sandboxes } }),
309
- },
310
- resources: DEFINITION_SET.reports.ranFacts(outcome.resources),
311
- wallMs: recorded.wallMs,
312
- runner: {
313
- snapshotId: entry.snapshotId,
314
- base: entry.base,
315
- builtBehind: snapshotState !== undefined && snapshotState.kind !== "building" ? snapshotState.builtBehind : null,
316
- built: outcome.snapshot.built,
317
- vcpus: runner.prepared.vcpus,
318
- region: entry.region,
319
- runtime: entry.runtime,
320
- uploadBytes: recorded.uploadBytes,
321
- },
322
- cleanup: RUN_CLEANUP.facts(outcome),
323
- kept: outcome.sandboxes.flatMap(({ sandbox, runnerCleanup }) => {
324
- const kept = runnerCleanup?.kept ?? null;
325
- return kept === null
326
- ? []
327
- : [{ sandbox, name: kept.name, stopsAt: kept.stopsAt, url: sandboxConnectPage(runner.target, kept.name) }];
328
- }),
329
- notKept: outcome.sandboxes.flatMap(({ sandbox, runnerCleanup }) => {
330
- const notKept = runnerCleanup?.notKept ?? null;
331
- return notKept === null ? [] : [{ sandbox, name: notKept.name, message: notKept.message }];
332
- }),
333
- fileListMismatches: run.mismatches.map(({ sandbox, missing, extra }) => ({
334
- sandbox,
335
- missing: [...missing],
336
- extra: [...extra],
337
- })),
338
- };
339
- }
@@ -1,10 +0,0 @@
1
- import type { StormApp } from "../../context.ts";
2
- import type { ResourceLifecycles } from "../../core/index.ts";
3
- import { type PlannedFacts } from "../../planning/plan-only.ts";
4
- import type { RunPlan } from "./plan-run.ts";
5
- /**
6
- * The `planned` outcome of planned run `plan`, which starts nothing: the planned run, with each runner sandbox's
7
- * command and file list when it is across runner sandboxes, and the vCPUs of each runner sandbox. The runner's local
8
- * checks run for it (`prepareRunner`), so a refusal a run gets from them, `--plan-only` gets too.
9
- */
10
- export declare function plannedRun<TPlanned>(app: StormApp, plan: RunPlan, lifecycles: ResourceLifecycles, planned: (facts: PlannedFacts) => TPlanned): Promise<TPlanned | import("@vercel/clinkr").CommandError<"invalid_config"> | import("@vercel/clinkr").CommandError<"no_base_ref"> | import("@vercel/clinkr").CommandError<"runner_failed"> | import("@vercel/clinkr").CommandError<"submodules_refused">>;
@@ -1,45 +0,0 @@
1
- // Thin CLI wiring for `--plan-only`: resolves `vcpus` via `prepareRunner` for a planned run, across runner sandboxes or
2
- // not, builds redacted `PlannedFacts` through `src/planning/plan-only.ts`, and returns the `planned` outcome.
3
- import { buildPlannedFacts, plannedSecrets } from "../../planning/plan-only.js";
4
- import { redactor, redactStrings } from "../../planning/redaction.js";
5
- import { prepareRunner } from "../../runner/index.js";
6
- import { prepareRefusal, recipeResources } from "./run-command.js";
7
- /**
8
- * The `planned` outcome of planned run `plan`, which starts nothing: the planned run, with each runner sandbox's
9
- * command and file list when it is across runner sandboxes, and the vCPUs of each runner sandbox. The runner's local
10
- * checks run for it (`prepareRunner`), so a refusal a run gets from them, `--plan-only` gets too.
11
- */
12
- export async function plannedRun(app, plan, lifecycles, planned) {
13
- const vcpus = await plannedVcpus(app, lifecycles, plan);
14
- if (!vcpus.ok)
15
- return vcpus.refusal;
16
- return planned(buildPlannedFacts({
17
- version: app.version,
18
- commit: app.commit,
19
- configFile: plan.configFile,
20
- argv: plan.argv,
21
- where: plan.where,
22
- testPlan: plan.testPlan,
23
- planOptions: plan.planOptions,
24
- testFiles: plan.testFiles,
25
- sandboxes: plan.sandboxes,
26
- resources: plan.resources,
27
- lifecycles,
28
- vcpus: vcpus.vcpus,
29
- }));
30
- }
31
- /** The vCPUs of each runner sandbox of the planned run; null for a run with no runner. */
32
- async function plannedVcpus(app, lifecycles, { where, configFile, resources, sandboxes }) {
33
- if (where.kind !== "runner")
34
- return { ok: true, vcpus: null };
35
- const prepared = await prepareRunner(app.context, {
36
- cwd: app.cwd,
37
- recipe: where.recipe,
38
- vcpuRun: { resources: recipeResources(resources), sandboxes: sandboxes?.sandboxes.length ?? 1 },
39
- });
40
- if (prepared.kind === "ok")
41
- return { ok: true, vcpus: prepared.prepared.vcpus };
42
- const refusal = prepareRefusal(prepared, configFile);
43
- const secrets = plannedSecrets(lifecycles, where, resources);
44
- return { ok: false, refusal: secrets.length === 0 ? refusal : redactStrings(refusal, redactor(secrets)) };
45
- }