@cnc-tools/storm 0.16.0 → 0.18.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 (290) hide show
  1. package/dist/bin/storm.js +54 -40
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
  4. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
  5. package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
  6. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
  7. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  8. package/dist/chunks/chunk-AS37D43E.js +2173 -0
  9. package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
  10. package/dist/chunks/chunk-DZLU7BYK.js +340 -0
  11. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  12. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
  13. package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
  14. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
  15. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
  16. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
  17. package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
  18. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
  19. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
  20. package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
  21. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
  22. package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
  23. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
  24. package/dist/chunks/chunk-SZMYIIG2.js +88 -0
  25. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
  26. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
  27. package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
  28. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  29. package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
  30. package/dist/cli.d.ts +28 -0
  31. package/dist/cli.js +64 -0
  32. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
  33. package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
  34. package/dist/commands/exec/before-run.d.ts +123 -0
  35. package/dist/commands/exec/before-run.js +105 -0
  36. package/dist/commands/exec/command.d.ts +67 -14
  37. package/dist/commands/exec/command.js +31 -95
  38. package/dist/commands/exec/driver-plan.d.ts +9 -4
  39. package/dist/commands/exec/driver-plan.js +8 -8
  40. package/dist/commands/exec/exec-words.js +1 -1
  41. package/dist/commands/exec/execute-run.d.ts +39 -0
  42. package/dist/commands/exec/execute-run.js +325 -0
  43. package/dist/commands/exec/live-view.d.ts +3 -3
  44. package/dist/commands/exec/live-view.js +16 -15
  45. package/dist/commands/exec/metadata.js +1 -1
  46. package/dist/commands/exec/mint-failed.d.ts +38 -0
  47. package/dist/commands/exec/mint-failed.js +27 -4
  48. package/dist/commands/exec/outcomes.d.ts +104 -22
  49. package/dist/commands/exec/outcomes.js +73 -26
  50. package/dist/commands/exec/plan-run.d.ts +58 -150
  51. package/dist/commands/exec/plan-run.js +239 -90
  52. package/dist/commands/exec/progress.d.ts +10 -6
  53. package/dist/commands/exec/progress.js +38 -25
  54. package/dist/commands/exec/run-bin.d.ts +11 -11
  55. package/dist/commands/exec/run-bin.js +9 -9
  56. package/dist/commands/exec/run-flags.d.ts +69 -0
  57. package/dist/commands/exec/run-flags.js +58 -0
  58. package/dist/commands/exec/run-metadata.js +4 -4
  59. package/dist/commands/exec/run-summary.d.ts +58 -0
  60. package/dist/commands/exec/run-summary.js +205 -0
  61. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  62. package/dist/commands/exec/runner-refusals.js +71 -0
  63. package/dist/commands/exec/sandbox-progress.js +3 -0
  64. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  65. package/dist/commands/exec/stopped-outcome.js +77 -0
  66. package/dist/commands/exec/view.d.ts +20 -11
  67. package/dist/commands/exec/view.js +103 -47
  68. package/dist/commands/runs/facts.d.ts +8 -4
  69. package/dist/commands/runs/facts.js +19 -10
  70. package/dist/commands/runs/list/command.d.ts +16 -8
  71. package/dist/commands/runs/list/command.js +10 -10
  72. package/dist/commands/runs/list/outcomes.d.ts +8 -4
  73. package/dist/commands/runs/logs/command.js +10 -10
  74. package/dist/commands/runs/show/command.d.ts +16 -8
  75. package/dist/commands/runs/show/command.js +31 -29
  76. package/dist/commands/runs/show/metadata.js +1 -1
  77. package/dist/commands/runs/show/outcomes.d.ts +8 -4
  78. package/dist/commands/runs/show/outcomes.js +8 -6
  79. package/dist/commands/snapshots/access.d.ts +111 -0
  80. package/dist/commands/snapshots/access.js +96 -0
  81. package/dist/commands/snapshots/build/command.d.ts +376 -101
  82. package/dist/commands/snapshots/build/command.js +447 -149
  83. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  84. package/dist/commands/snapshots/build/metadata.js +31 -11
  85. package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
  86. package/dist/commands/snapshots/build/outcomes.js +200 -36
  87. package/dist/commands/snapshots/list/command.d.ts +368 -27
  88. package/dist/commands/snapshots/list/command.js +298 -68
  89. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  90. package/dist/commands/snapshots/list/metadata.js +29 -6
  91. package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
  92. package/dist/commands/snapshots/list/outcomes.js +223 -52
  93. package/dist/commands/snapshots/metadata.js +1 -1
  94. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  95. package/dist/commands/snapshots/prune/command.js +161 -0
  96. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  97. package/dist/commands/snapshots/prune/metadata.js +39 -0
  98. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  99. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  100. package/dist/commands/suites/list/command.js +17 -17
  101. package/dist/commands/suites/list/outcomes.js +2 -2
  102. package/dist/commands/test/command.d.ts +67 -14
  103. package/dist/commands/test/command.js +49 -252
  104. package/dist/commands/test/outcomes.d.ts +33 -7
  105. package/dist/config/check-runner.d.ts +3 -3
  106. package/dist/config/check-runner.js +8 -7
  107. package/dist/config/credential-resolver.d.ts +50 -5
  108. package/dist/config/credential-resolver.js +51 -19
  109. package/dist/config/credential-settle.d.ts +6 -2
  110. package/dist/config/credential-settle.js +11 -5
  111. package/dist/config/index.d.ts +2 -2
  112. package/dist/config/index.js +1 -1
  113. package/dist/config/runner.d.ts +5 -5
  114. package/dist/config/runner.js +1 -1
  115. package/dist/config/schema.d.ts +2 -2
  116. package/dist/config/schema.js +1 -1
  117. package/dist/config-file/define.d.ts +1 -1
  118. package/dist/config-file/define.js +1 -1
  119. package/dist/config-file/runner.d.ts +5 -5
  120. package/dist/config-file/toolchain.d.ts +14 -4
  121. package/dist/config-file/toolchain.js +43 -7
  122. package/dist/context.d.ts +10 -6
  123. package/dist/context.js +8 -6
  124. package/dist/core/across-sandboxes.d.ts +7 -6
  125. package/dist/core/across-sandboxes.js +123 -152
  126. package/dist/core/coordinator.d.ts +166 -0
  127. package/dist/core/coordinator.js +233 -0
  128. package/dist/core/events.d.ts +2 -2
  129. package/dist/core/index.d.ts +4 -2
  130. package/dist/core/index.js +1 -1
  131. package/dist/core/outcomes.d.ts +148 -0
  132. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  133. package/dist/core/resources.d.ts +31 -53
  134. package/dist/core/resources.js +32 -70
  135. package/dist/core/run-state.d.ts +7 -1
  136. package/dist/core/run-state.js +2 -0
  137. package/dist/core/run.d.ts +32 -236
  138. package/dist/core/run.js +107 -267
  139. package/dist/core/state-directory.d.ts +1 -1
  140. package/dist/core/state-directory.js +2 -2
  141. package/dist/credential/gateways.d.ts +15 -1
  142. package/dist/credential/index.d.ts +4 -3
  143. package/dist/credential/index.js +3 -2
  144. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  145. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  146. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  147. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  148. package/dist/credential/source.d.ts +73 -6
  149. package/dist/credential/source.js +55 -2
  150. package/dist/extension-commands.d.ts +1 -1
  151. package/dist/extension-commands.js +2 -2
  152. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  153. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  154. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  155. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  156. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  157. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  158. package/dist/extensions/testserver/credential-facts.js +29 -11
  159. package/dist/extensions/testserver/lifecycle.js +7 -1
  160. package/dist/extensions/testserver/limit.d.ts +3 -0
  161. package/dist/extensions/testserver/limit.js +3 -0
  162. package/dist/extensions/testserver/provision.d.ts +8 -1
  163. package/dist/extensions/testserver/provision.js +8 -3
  164. package/dist/extensions/testserver/refusals.d.ts +6 -1
  165. package/dist/extensions/testserver/refusals.js +16 -1
  166. package/dist/extensions/testserver/resource.d.ts +1 -1
  167. package/dist/extensions/testserver/resource.js +1 -1
  168. package/dist/extensions/testserver/result.d.ts +1 -1
  169. package/dist/extensions/testserver/result.js +9 -4
  170. package/dist/planning/driver-file-lists.d.ts +0 -15
  171. package/dist/planning/driver-file-lists.js +2 -21
  172. package/dist/planning/plan-only.d.ts +3 -14
  173. package/dist/planning/plan-only.js +11 -20
  174. package/dist/planning/run-kind-flags.js +2 -2
  175. package/dist/planning/run-plan.d.ts +45 -12
  176. package/dist/planning/run-plan.js +4 -3
  177. package/dist/planning/suites.d.ts +1 -1
  178. package/dist/planning/suites.js +2 -2
  179. package/dist/planning/test-plan.d.ts +9 -0
  180. package/dist/planning/test-plan.js +9 -0
  181. package/dist/run-directory/recording.js +3 -3
  182. package/dist/run-directory/run-record.d.ts +26 -11
  183. package/dist/run-directory/run-record.js +16 -13
  184. package/dist/runner/base.js +1 -1
  185. package/dist/runner/build-snapshots.d.ts +60 -29
  186. package/dist/runner/build-snapshots.js +136 -29
  187. package/dist/runner/context.d.ts +15 -7
  188. package/dist/runner/context.js +19 -6
  189. package/dist/runner/events.d.ts +16 -10
  190. package/dist/runner/gateways.d.ts +122 -23
  191. package/dist/runner/gateways.js +1 -1
  192. package/dist/runner/gh.d.ts +42 -0
  193. package/dist/runner/gh.js +58 -0
  194. package/dist/runner/index.d.ts +13 -8
  195. package/dist/runner/index.js +12 -6
  196. package/dist/runner/live/checkout-gateway.js +7 -0
  197. package/dist/runner/live/gh-output.d.ts +17 -0
  198. package/dist/runner/live/gh-output.js +37 -0
  199. package/dist/runner/live/gh-token-gateway.d.ts +13 -0
  200. package/dist/runner/live/gh-token-gateway.js +51 -0
  201. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  202. package/dist/runner/live/sandbox-errors.js +4 -0
  203. package/dist/runner/live/sandbox-gateway.js +140 -4
  204. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  205. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  206. package/dist/runner/live/snapshot-records.js +12 -12
  207. package/dist/runner/local-snapshot-index.d.ts +205 -0
  208. package/dist/runner/local-snapshot-index.js +210 -0
  209. package/dist/runner/network-policy.d.ts +6 -6
  210. package/dist/runner/network-policy.js +7 -7
  211. package/dist/runner/policy-writes.d.ts +1 -1
  212. package/dist/runner/policy-writes.js +1 -1
  213. package/dist/runner/prepare.d.ts +14 -14
  214. package/dist/runner/prepare.js +20 -11
  215. package/dist/runner/ready.d.ts +19 -11
  216. package/dist/runner/ready.js +104 -33
  217. package/dist/runner/sandboxed-command.d.ts +3 -3
  218. package/dist/runner/sandboxed-command.js +3 -3
  219. package/dist/runner/scope.d.ts +15 -8
  220. package/dist/runner/scope.js +16 -5
  221. package/dist/runner/secrets.d.ts +41 -18
  222. package/dist/runner/secrets.js +226 -30
  223. package/dist/runner/session.d.ts +8 -8
  224. package/dist/runner/session.js +6 -3
  225. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  226. package/dist/runner/shared-snapshot-entry.js +168 -0
  227. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  228. package/dist/runner/shared-snapshot-list.js +155 -0
  229. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  230. package/dist/runner/shared-snapshot-lookup.js +118 -0
  231. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  232. package/dist/runner/shared-snapshot-prune.js +133 -0
  233. package/dist/runner/snapshot-build.d.ts +42 -14
  234. package/dist/runner/snapshot-build.js +79 -47
  235. package/dist/runner/snapshot-choice.js +2 -1
  236. package/dist/runner/snapshot-inspect.d.ts +39 -40
  237. package/dist/runner/snapshot-inspect.js +52 -35
  238. package/dist/runner/snapshot-key.d.ts +32 -17
  239. package/dist/runner/snapshot-key.js +43 -18
  240. package/dist/runner/snapshot-source.d.ts +31 -0
  241. package/dist/runner/snapshot-source.js +122 -0
  242. package/dist/runner/steps.d.ts +1 -1
  243. package/dist/runner/steps.js +1 -1
  244. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
  245. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
  246. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
  247. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
  248. package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
  249. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
  250. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  251. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  252. package/dist/sdk/extension/credential-source.d.ts +20 -3
  253. package/dist/sdk/extension/credential-source.js +4 -4
  254. package/dist/sdk/extension/index.d.ts +3 -2
  255. package/dist/sdk/extension/index.js +2 -1
  256. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  257. package/dist/sdk/extension/secret-source.d.ts +1 -1
  258. package/dist/sdk/extension/secret-source.js +1 -1
  259. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  260. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  261. package/dist/shared/cleanup.d.ts +3 -3
  262. package/dist/shared/cleanup.js +15 -5
  263. package/dist/shared/snapshot-text.d.ts +4 -4
  264. package/dist/shared/snapshot-text.js +11 -11
  265. package/dist/time/duration.js +1 -1
  266. package/package.json +5 -3
  267. package/skills/overview.md +4 -4
  268. package/skills/plan-runs.md +1 -1
  269. package/skills/read-run-output.md +6 -6
  270. package/dist/application.d.ts +0 -21
  271. package/dist/application.js +0 -30
  272. package/dist/chunks/chunk-7EENF73W.js +0 -782
  273. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  274. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  275. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  276. package/dist/commands/exec/plan-only.d.ts +0 -10
  277. package/dist/commands/exec/plan-only.js +0 -45
  278. package/dist/commands/exec/run-command.d.ts +0 -475
  279. package/dist/commands/exec/run-command.js +0 -603
  280. package/dist/commands/exec/run-planned.d.ts +0 -20
  281. package/dist/commands/exec/run-planned.js +0 -22
  282. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  283. package/dist/commands/exec/sandbox-view.js +0 -72
  284. package/dist/commands/test/plan.d.ts +0 -92
  285. package/dist/commands/test/plan.js +0 -125
  286. package/dist/core/sandbox-end.d.ts +0 -64
  287. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  288. package/dist/runner/recipe-secrets.d.ts +0 -67
  289. package/dist/runner/snapshot-cache.d.ts +0 -148
  290. package/dist/runner/snapshot-cache.js +0 -126
package/dist/core/run.js CHANGED
@@ -1,174 +1,52 @@
1
- // A run, from its start to its outcome. A run is sandboxed or unsandboxed (`GLOSSARY.md`): a sandboxed run's request
2
- // holds `runner`, and its command runs in a runner sandbox readied beside the resources (`runSandboxed`), through the
3
- // run's runner session (`openRunnerSession`), which keeps the order of the runner's stages and their cleanup; an
4
- // unsandboxed run's request holds none, and its command runs on the launch machine (`runUnsandboxed`). Either way the
5
- // core keeps the mint, acquiring the resources (with the runner lane beside them in a sandboxed run), saying each
6
- // acquired, the run payload, the `command-started` and `command-ended` events, the test events and releasing the
7
- // resources. This file is the one core module that tells the kinds apart. The rest of the core sees the runner, the
8
- // runner lane and the runner's events, or nothing.
1
+ // A single run, from its start to its outcome (`executeRun`). Dispatches the peer runner (`launch-machine` or
2
+ // `vercel-sandbox`) directly in `executeRun` and delegates opening, credential obtainment, concurrent setup, sandbox
3
+ // command execution, and cleanup framing to `core/coordinator.ts`.
9
4
  import { posix } from "node:path";
10
- import { credentialSourceFor, } from "../credential/index.js";
5
+ import { credentialSourceFor } from "../credential/index.js";
11
6
  import { lineSplitter, openRunnerSession, SANDBOX_TEST_EVENTS_PATH, } from "../runner/index.js";
12
- import { parseTestEvent } from "../sdk/run/launcher.js";
7
+ import { coordinateSetup, emitLanesStarted, emitRunOpening, obtainRunnerCredential, runCommandInSandbox, withResourceCleanup, } from "./coordinator.js";
8
+ import { canceledStop, runnerLaneOutcome, runnerStopped, } from "./outcomes.js";
13
9
  import { colorEnvironment, commandEnvironment, runPayload } from "./payload.js";
14
10
  import { LOOKUP } from "./resource-definition-set.js";
15
- import { acquireResources, announceAcquired, canceledStop, runInstances, releaseResources, resourceWarnings, releasedResources, resourceInstances, resourcesCredentials, resourcesPayload, resourcesRan, } from "./resources.js";
11
+ import { acquireResources, announceAcquired, resourceInstances, resourcesCredentials, resourcesPayload, resourcesRan, resourceWarnings, startResourceLanes, } from "./resources.js";
16
12
  /**
17
- * Shared opening events emitted at the start of every run (across runner sandboxes or not): `started`, skips, and
18
- * `runner-prepared`.
13
+ * Runs `request.argv` with the resources it asks for, through `definitionSet`'s resource definitions, in definition
14
+ * order. Releases every resource instance in reverse order however the run ends, and reports cleanup completion.
19
15
  */
20
- export async function emitRunOpening(progress, request, instances) {
21
- await progress.emit({
22
- kind: "started",
16
+ export async function executeRun(definitionSet, context, resourceContexts, request, control, progress) {
17
+ const instances = resourceInstances(definitionSet[LOOKUP], resourceContexts, request.resources);
18
+ await emitRunOpening(progress, {
23
19
  version: request.version,
24
20
  commit: request.commit,
25
21
  configFile: request.configFile,
26
- resources: runInstances(instances),
27
- });
28
- for (const skip of request.skipped ?? [])
29
- await progress.emit({ kind: "resource-skipped", ...skip });
30
- if (request.runner !== undefined) {
31
- const { prepared } = request.runner;
32
- await progress.emit({
33
- kind: "runner-prepared",
34
- base: prepared.base,
35
- baseRef: prepared.baseRef,
36
- nestedRepositories: prepared.upload.nestedRepositories,
37
- notes: prepared.notes,
38
- });
39
- }
40
- }
41
- /**
42
- * Mints a Vercel OIDC credential for `target`, checks its team and project claims, and honors `signal`. Every run
43
- * shares it, across runner sandboxes or not.
44
- */
45
- export async function mintCredential(context, target, signal, progress) {
46
- const canceled = () => ({ ...canceledStop(), commandStopped: false });
47
- if (signal.aborted)
48
- return { ok: false, outcome: canceled() };
49
- const mint = credentialSourceFor({ source: "mint", target }, context, progress);
50
- const minted = await mint.obtain();
51
- if (!minted.ok)
52
- return { ok: false, outcome: { kind: "mint_failed", failure: minted.failure.failure, target, runner: true } };
53
- const project = minted.credential.vercelProject();
54
- if (project === undefined)
55
- return {
56
- ok: false,
57
- outcome: { kind: "runner_failed", failure: { kind: "credential-claims-missing", target } },
58
- };
59
- if (signal.aborted)
60
- return { ok: false, outcome: canceled() };
61
- return { ok: true, mint, access: { credential: minted.credential, ...project } };
62
- }
63
- /**
64
- * Runs `request.argv` in `session` with `request.runPayload`, pumping test events in arrival order and mapping sandbox
65
- * exit/kill/failure outcomes into `RanCommand` or `RunStopped`. Every run shares it, across runner sandboxes or not.
66
- */
67
- export async function runCommandInSandbox(session, request, signal, progress, onStarted) {
68
- await progress.emit({ kind: "command-started", argv: request.argv });
69
- if (signal.aborted)
70
- return { ok: false, outcome: { ...canceledStop(), commandStopped: false } };
71
- onStarted?.();
72
- // Test events arrive from a callback that can't wait, so they are emitted in order through a chain.
73
- let testEvents = Promise.resolve();
74
- const sandboxed = await session.runCommand({
75
- argv: request.argv,
76
- runPayload: request.runPayload,
77
- ...(request.credentials === undefined ? {} : { credentials: request.credentials }),
78
- testEvents: {
79
- onLine: (line) => {
80
- const event = parseTestEvent(line);
81
- testEvents = testEvents.then(() => progress.emit(event === undefined ? { kind: "test-event-unreadable" } : { kind: "test", event }));
82
- },
83
- onIncomplete: (message) => {
84
- testEvents = testEvents.then(() => progress.emit({ kind: "test-events-incomplete", message }));
85
- },
86
- },
87
- });
88
- await testEvents;
89
- // Closing on a signal can stop the runner sandbox under the command, so a failed call then is the stop too.
90
- if (sandboxed.kind === "killed" || (sandboxed.kind === "failed" && signal.aborted))
91
- return { ok: false, outcome: { ...canceledStop(), commandStopped: true } };
92
- if (sandboxed.kind === "failed")
93
- return { ok: false, outcome: { kind: "runner_failed", failure: sandboxed.failure } };
94
- const command = sandboxed.exitCode === null ? { kind: "no-exit-code" } : { kind: "exited", code: sandboxed.exitCode };
95
- await progress.emit({
96
- kind: "command-ended",
97
- command: posix.basename(request.argv[0] ?? ""),
98
- outcome: command,
99
- ms: sandboxed.ms,
100
- });
101
- return { ok: true, command };
102
- }
103
- /**
104
- * Runs `body` with idempotent `startCleanup` / `release` hooks, guarantees every acquired resource instance is
105
- * released in `finally`, and returns both `body`'s result and the collected `resourceCleanup`.
106
- */
107
- export async function withResourceCleanup(instances, keepMs, progress, body) {
108
- let cleanupStarted = false;
109
- // Said once, before the runner's sandboxes are fenced in a sandboxed run, else before the resources are released,
110
- // with how long cleanup keeps the runner sandbox running, if the run has one (`keepMs`, null for a run with no runner).
111
- const startCleanup = async () => {
112
- if (cleanupStarted)
113
- return;
114
- cleanupStarted = true;
115
- await progress.emit({ kind: "cleanup-started", keepMs, resources: releasedResources(instances) });
116
- };
117
- let resourceCleanup = {};
118
- let releasing;
119
- // Once: reporting cleanup's start can fail, and releasing what the acquires took must not depend on it. The first
120
- // call's `runner` is the one every release gets: whether the launcher fenced the run's runner sandbox.
121
- const release = (runner) => (releasing ??= (async () => {
122
- try {
123
- await startCleanup();
124
- }
125
- finally {
126
- resourceCleanup = await releaseResources(instances, progress, runner);
22
+ ...(request.skipped === undefined ? {} : { skipped: request.skipped }),
23
+ ...(request.runner.kind === "vercel-sandbox" ? { runner: request.runner.session } : {}),
24
+ }, instances);
25
+ const keepMs = request.runner.kind === "vercel-sandbox" ? request.runner.session.keepMs : null;
26
+ const { value: { ended, runnerCleanup }, resourceCleanup, } = await withResourceCleanup(instances, keepMs, progress, async (cleanup) => {
27
+ switch (request.runner.kind) {
28
+ case "launch-machine":
29
+ return {
30
+ ended: await runOnLaunchMachine(context, request.runner, {
31
+ argv: request.argv,
32
+ verbose: request.verbose,
33
+ instances,
34
+ control,
35
+ progress,
36
+ }),
37
+ runnerCleanup: null,
38
+ };
39
+ case "vercel-sandbox":
40
+ return await runInVercelSandboxSession(context, request.runner, {
41
+ argv: request.argv,
42
+ verbose: request.verbose,
43
+ instances,
44
+ control,
45
+ progress,
46
+ cleanup,
47
+ });
127
48
  }
128
- })());
129
- let value;
130
- try {
131
- value = await body({ startCleanup, release });
132
- }
133
- finally {
134
- // A run with no runner (`keepMs` null) has nothing to fence, so the release hears true. With a runner this is a
135
- // no-op: its runner session released the resources once it fenced its sandboxes, saying whether it fenced the runner
136
- // sandbox. Should a session ever end without releasing, nothing has confirmed the fence, so the release hears false.
137
- await release({ runnerSandboxFenced: keepMs === null });
138
- }
139
- return { value, resourceCleanup };
140
- }
141
- /**
142
- * Runs `request.argv` with the resources it asks for, through `definitionSet`'s resource definitions, in definition
143
- * order. Each resource's `beforeRun` has run already, before the run started: the request holds what it answered. It
144
- * says each resource `beforeRun` skipped right after it starts (`resource-skipped`), acquires the other resource
145
- * instances all at once through their `acquireForRun` (`acquireResources`), says each acquired (`resource-acquired`),
146
- * runs the command with the run payload in `STORM_RUN`, waits for it, and hands each instance what its acquire took to
147
- * its `releaseAfterRun`. It reports each step to `progress`. What acquiring and releasing do is each resource
148
- * definition's own: see its lifecycle. A run that asks for no resource goes straight to its command. It calls each
149
- * definition's lifecycle with its own Context from `resourceContexts`, and hands `context` to none.
150
- *
151
- * In a sandboxed run (`request.runner`), the command runs in a runner sandbox, readied beside the resources (see
152
- * `runSandboxed`).
153
- *
154
- * Release happens however the run ended, a throw included: once the command has stopped and, in a sandboxed run, the
155
- * runner session has fenced the run's sandboxes, each resource instance is released in reverse order, even when the
156
- * `cleanup-started` event can't be reported. An unsandboxed run releases them in `finally`; a sandboxed run's runner
157
- * session does, as it finishes or closes, between the fence and the scope's close: the fence stops every sandbox the
158
- * run doesn't keep and leaves the runner sandbox it keeps with no network access; the close then deletes the stopped
159
- * sandboxes and keeps the kept one running. Each release hears whether the launcher fenced the run's runner sandbox
160
- * (`ReleaseAfterRunInput.runnerSandboxFenced`): what the runner session says once the fence answered, and true in an
161
- * unsandboxed run, which has nothing to fence.
162
- */
163
- export async function executeRun(definitionSet, context, resourceContexts, request, control, progress) {
164
- const instances = resourceInstances(definitionSet[LOOKUP], resourceContexts, request.resources);
165
- await emitRunOpening(progress, request, instances);
166
- // Each instance keeps what its acquire took, as `acquireForRun` hands it over: the run releases all of it however
167
- // it ends.
168
- const keepMs = request.runner === undefined ? null : request.runner.keepMs;
169
- const { value: { ended, runnerCleanup }, resourceCleanup, } = await withResourceCleanup(instances, keepMs, progress, async (cleanup) => request.runner === undefined
170
- ? { ended: await runUnsandboxed(context, request, instances, control, progress), runnerCleanup: null }
171
- : await runSandboxed(context, request, instances, control, progress, cleanup));
49
+ });
172
50
  await progress.emit({
173
51
  kind: "cleanup-finished",
174
52
  resourceWarnings: resourceWarnings(resourceCleanup),
@@ -185,42 +63,31 @@ export async function executeRun(definitionSet, context, resourceContexts, reque
185
63
  resourceCleanup,
186
64
  };
187
65
  }
188
- /**
189
- * Everything between the run's start and releasing its resources, in an unsandboxed run: it acquires every resource
190
- * instance (`acquireResources`), each keeping what its acquire took, then says each acquired and runs the command once
191
- * all are. The credential source its request names is built once (`credentialSourceFor`), reporting each mint and token
192
- * request as the run's own event, and handed to every instance; the mint is lazy, so a run mints only when a resource
193
- * asks for a credential.
194
- * The command's stdout and stderr reach `runnerTerminal` a line at a time per stream, and its environment says whether
195
- * to color them (`colorEnvironment`), since the command writes to pipes. A run with no runner has no firewall, so a
196
- * resource that answered sandbox credentials throws: the launcher refuses such a run before it starts.
197
- */
198
- async function runUnsandboxed(context, request, instances, control, progress) {
66
+ async function runOnLaunchMachine(context, runner, input) {
67
+ const { argv, verbose, instances, control, progress } = input;
68
+ await startResourceLanes(instances, progress);
199
69
  const acquisition = await acquireResources(instances, {
200
- credential: request.credential === undefined ? undefined : credentialSourceFor(request.credential, context, progress),
201
- signal: control.signal,
70
+ credential: runner.credential === undefined ? undefined : credentialSourceFor(runner.credential, context, progress),
71
+ cancelSignal: control.signal,
202
72
  progress,
203
73
  });
204
74
  if (acquisition.kind === "stopped")
205
75
  return acquisition.outcome;
206
- // Only a runner sandbox's firewall can add a credential: the launcher refuses a run with no runner whose resources
207
- // need a runner sandbox before it starts, so a resource that answers credentials here is a programmer error.
76
+ if (acquisition.kind !== "acquired")
77
+ return canceledStop();
208
78
  const crediting = resourcesCredentials(instances);
209
79
  if (crediting.length > 0)
210
80
  throw new Error(`resource ${crediting[0]?.resource ?? ""} answered sandbox credentials in a run with no runner sandbox; its beforeRun must say it needs one`);
211
81
  await announceAcquired(instances, progress);
212
82
  const terminal = context.runnerTerminal;
213
- const env = commandEnvironment(colorEnvironment(request.env, terminal.color), runPayload(resourcesPayload(instances), {
214
- ...(request.testEvents === undefined ? {} : { testEvents: request.testEvents }),
215
- ...(request.verbose === undefined ? {} : { verbose: request.verbose }),
83
+ const env = commandEnvironment(colorEnvironment(runner.env, terminal.color), runPayload(resourcesPayload(instances), {
84
+ ...(runner.testEvents === undefined ? {} : { testEvents: runner.testEvents }),
85
+ ...(verbose === undefined ? {} : { verbose }),
216
86
  }));
217
- await progress.emit({ kind: "command-started", argv: request.argv });
218
- // A signal during either progress write must still keep the command from starting.
87
+ await progress.emit({ kind: "command-started", argv });
219
88
  if (control.signal.aborted)
220
89
  return canceledStop();
221
90
  const commandStartedAt = context.clock.now();
222
- // The command's output reaches the terminal a line at a time per stream, as a sandboxed run's does, the rest once it
223
- // ends.
224
91
  const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
225
92
  const write = (stream, text) => {
226
93
  if (text === "")
@@ -231,7 +98,7 @@ async function runUnsandboxed(context, request, instances, control, progress) {
231
98
  terminal.writeStderr(text);
232
99
  };
233
100
  const command = await context.commands.run({
234
- argv: request.argv,
101
+ argv,
235
102
  env,
236
103
  terminate: control.terminate,
237
104
  onOutput: ({ stream, data }) => write(stream, splitters[stream].push(data)),
@@ -240,43 +107,21 @@ async function runUnsandboxed(context, request, instances, control, progress) {
240
107
  write("stdout", splitters.stdout.flush());
241
108
  write("stderr", splitters.stderr.flush());
242
109
  if (command.kind === "spawn-failed")
243
- return { kind: "spawn_failed", executable: request.argv[0] ?? "", message: command.message };
110
+ return { kind: "spawn_failed", executable: argv[0] ?? "", message: command.message };
244
111
  await progress.emit({
245
112
  kind: "command-ended",
246
- command: posix.basename(request.argv[0] ?? ""),
113
+ command: posix.basename(argv[0] ?? ""),
247
114
  outcome: command,
248
115
  ms: commandEndedAt.getTime() - commandStartedAt.getTime(),
249
116
  });
250
117
  return { kind: "command-ended", resources: resourcesRan(instances), command, runner: undefined };
251
118
  }
252
- /** How the runner lane ended, by how readying did: stopped when aborted, failed when it failed or its snapshot was
253
- * gone. */
254
- function runnerLaneOutcome(outcome) {
255
- if (outcome.kind === "ready")
256
- return "ready";
257
- return outcome.kind === "aborted" ? "stopped" : "failed";
258
- }
259
- /** The outcome a runner that couldn't get ready ends the run with; undefined when it is ready or was stopped. */
260
- function runnerStopped(outcome) {
261
- if (outcome.kind === "failed")
262
- return { kind: "runner_failed", failure: outcome.failure };
263
- if (outcome.kind === "snapshot-gone")
264
- return { kind: "snapshot_gone", entry: outcome.entry, removal: outcome.removal };
265
- return undefined;
266
- }
267
- /**
268
- * In a sandboxed run, everything between the run's start and releasing its resources. It opens the run's runner session
269
- * (`openRunnerSession`) before the mint, which owns the runner's sandbox scope and the order its stages run in, runs
270
- * `runInSandbox` in it, and cleans up the session, which fences the run's sandboxes, releases the resources, saying
271
- * whether it fenced the runner sandbox, and closes the scope. A run that throws cleans up the session in `finally`,
272
- * which does the same. A sandboxed run always mints, whatever its resources are, so its request names no credential
273
- * source: the command layer refuses `--credential github-actions` with it.
274
- */
275
- async function runSandboxed(context, request, instances, control, progress, cleanup) {
119
+ async function runInVercelSandboxSession(context, runner, input) {
120
+ const { argv, verbose, instances, control, progress, cleanup } = input;
276
121
  const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
277
- const session = openRunnerSession(context, request.runner, { signal: control.signal, cleanup }, runnerProgress);
122
+ const session = openRunnerSession(context, runner.session, { signal: control.signal, cleanup }, runnerProgress);
278
123
  try {
279
- const ended = await runInSandbox(context, request, instances, session, control, progress);
124
+ const ended = await runInVercelSandbox(context, runner, { argv, verbose, instances, session, control, progress });
280
125
  return { ended, runnerCleanup: await session.cleanUp() };
281
126
  }
282
127
  finally {
@@ -284,57 +129,71 @@ async function runSandboxed(context, request, instances, control, progress, clea
284
129
  await session.cleanUp();
285
130
  }
286
131
  }
287
- /**
288
- * The body of `runSandboxed`, in its runner session. It mints first, whatever the resources are, since the
289
- * runner sandbox needs the run's credential: it builds the mint's source (`credentialSourceFor`) and obtains from it
290
- * once, and hands the same source to the resources, so one that asks for a credential gets the one mint's outcome and
291
- * the run reports no other mint. Then it acquires the resources and readies the runner sandbox at once (`readyBoth`),
292
- * and runs the command in the runner sandbox once all are ready, saying each resource acquired first. The sandbox
293
- * credentials the acquired resources answered (`Acquired.credentials`) go to the runner session, which has the firewall
294
- * add each to the requests to its domain for the length of the command, beside the run's own; two credentials, of two
295
- * resources or of a resource and the run's config (`runner.credentials`), for the same domain and header, or for one
296
- * domain with different `requests`, throw before the command starts (`resourcesCredentials`).
297
- */
298
- async function runInSandbox(context, request, instances, session, control, progress) {
299
- const { runner } = request;
300
- // Canceled before a command started in the runner sandbox.
301
- const canceled = () => ({ ...canceledStop(), commandStopped: false });
302
- const credential = await mintCredential(context, runner.target, control.signal, progress);
132
+ async function runInVercelSandbox(context, runner, input) {
133
+ const { argv, verbose, instances, session, control, progress } = input;
134
+ const credential = await obtainRunnerCredential(context, runner.credential, control.signal, progress);
303
135
  if (!credential.ok)
304
136
  return credential.outcome;
305
- const acquisition = await readyBoth({
306
- instances,
307
- credential: credential.mint,
308
- ready: (signal) => session.ready(credential.access, signal),
309
- }, control, progress);
310
- if (acquisition.kind === "stopped") {
311
- const { outcome } = acquisition;
137
+ await emitLanesStarted(instances, progress);
138
+ const setup = await coordinateSetup({
139
+ cancelSignal: control.signal,
140
+ runResources: async (stopSignal) => {
141
+ const acquired = await acquireResources(instances, {
142
+ credential: credential.mint,
143
+ cancelSignal: control.signal,
144
+ stopSignal,
145
+ progress,
146
+ });
147
+ if (acquired.kind === "acquired")
148
+ return { kind: "ready", value: undefined };
149
+ return acquired;
150
+ },
151
+ runRunner: async (stopSignal) => {
152
+ let readied;
153
+ let laneOutcome;
154
+ try {
155
+ readied = await session.ready(credential.access, AbortSignal.any([control.signal, stopSignal]));
156
+ laneOutcome = runnerLaneOutcome(readied);
157
+ await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: laneOutcome });
158
+ }
159
+ catch (error) {
160
+ if (laneOutcome === undefined)
161
+ await progress
162
+ .emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: "failed" })
163
+ .catch(() => undefined);
164
+ throw error;
165
+ }
166
+ if (readied.kind === "ready")
167
+ return { kind: "ready", value: readied.runner };
168
+ const stopped = runnerStopped(readied);
169
+ if (stopped !== undefined)
170
+ return { kind: "stopped", outcome: stopped };
171
+ return control.signal.aborted ? { kind: "canceled" } : { kind: "internal-stopped" };
172
+ },
173
+ });
174
+ if (setup.kind === "threw")
175
+ throw setup.error;
176
+ if (setup.kind === "stopped") {
177
+ const { outcome } = setup;
312
178
  return outcome.kind === "canceled" ? { ...outcome, commandStopped: false } : outcome;
313
179
  }
314
- const { beside: readied } = acquisition;
315
- // No resource refused and no signal arrived, so the runner wasn't stopped.
316
- if (readied?.kind !== "ready")
317
- return canceled();
318
- const ready = readied.runner;
319
- // Each sandbox credential a resource gives the command, which the runner session puts on the requests to its domain
320
- // while the command runs; a clash with another resource's or the config's throws here, before the command starts.
321
- const credentials = resourcesCredentials(instances, runner.credentials).map(({ credential }) => credential);
180
+ const ready = setup.runner;
181
+ const credentials = resourcesCredentials(instances, runner.session.credentials).map(({ credential: c }) => c);
322
182
  await announceAcquired(instances, progress);
323
183
  const ran = await runCommandInSandbox(session, {
324
- argv: request.argv,
184
+ argv,
325
185
  runPayload: JSON.stringify(runPayload(resourcesPayload(instances), {
326
186
  testEvents: SANDBOX_TEST_EVENTS_PATH,
327
- ...(request.verbose === undefined ? {} : { verbose: request.verbose }),
187
+ ...(verbose === undefined ? {} : { verbose }),
328
188
  })),
329
189
  credentials,
330
190
  }, control.signal, progress);
331
191
  if (!ran.ok)
332
192
  return ran.outcome;
333
- const { command } = ran;
334
193
  return {
335
194
  kind: "command-ended",
336
195
  resources: resourcesRan(instances),
337
- command,
196
+ command: ran.command,
338
197
  runner: {
339
198
  snapshotId: ready.snapshotId,
340
199
  base: ready.base,
@@ -343,27 +202,8 @@ async function runInSandbox(context, request, instances, session, control, progr
343
202
  uploadBytes: ready.uploadBytes,
344
203
  vcpus: ready.vcpus,
345
204
  region: ready.region,
346
- runtime: ready.runtime,
205
+ image: ready.image,
347
206
  buildMs: ready.buildMs,
348
207
  },
349
208
  };
350
209
  }
351
- /**
352
- * Acquires the resources and readies the runner sandbox at once, through `acquireResources` with the runner lane
353
- * beside the resources (`ready`, the runner session's): a resource's refusal or throw stops readying the runner, and
354
- * the runner's failure stops acquiring the resources. Without any resource, the runner lane runs alone.
355
- */
356
- async function readyBoth(request, control, progress) {
357
- await progress.emit({ kind: "lanes-started" });
358
- return await acquireResources(request.instances, {
359
- credential: request.credential,
360
- signal: control.signal,
361
- progress,
362
- beside: {
363
- lane: { lane: "runner", resource: null },
364
- start: request.ready,
365
- outcomeOf: runnerLaneOutcome,
366
- stopped: runnerStopped,
367
- },
368
- });
369
- }
@@ -6,7 +6,7 @@ export declare function stateDirectoryPattern(subpath: readonly string[]): strin
6
6
  /**
7
7
  * Where one kind of state storm keeps lives: `subpath` under `$XDG_STATE_HOME/storm` when
8
8
  * `XDG_STATE_HOME` is absolute, else under `$HOME/.local/state/storm`, which needs an absolute `HOME`. Each
9
- * kind gets its own subdirectory: the run directories `["runs"]`, the runner snapshot cache `["runner", "snapshots"]`.
9
+ * kind gets its own subdirectory: the run directories `["runs"]`, the local snapshot index `["runner", "snapshots"]`.
10
10
  * A relative `XDG_STATE_HOME` is ignored, as the XDG spec says. Without either, the directory can't be found, and
11
11
  * `reason` says why.
12
12
  */
@@ -1,5 +1,5 @@
1
1
  // Where storm keeps its state: one directory under XDG's state home, with a subdirectory for each kind of state, such
2
- // as the run directories (`runs`), the runner snapshot cache (`runner/snapshots`) and each resource's own, named for
2
+ // as the run directories (`runs`), the local snapshot index (`runner/snapshots`) and each resource's own, named for
3
3
  // the resource (`launcherContext`, `launcher-context.ts`). It names no resource; each kind names its own
4
4
  // subpath.
5
5
  import { isAbsolute, join } from "node:path";
@@ -13,7 +13,7 @@ export function stateDirectoryPattern(subpath) {
13
13
  /**
14
14
  * Where one kind of state storm keeps lives: `subpath` under `$XDG_STATE_HOME/storm` when
15
15
  * `XDG_STATE_HOME` is absolute, else under `$HOME/.local/state/storm`, which needs an absolute `HOME`. Each
16
- * kind gets its own subdirectory: the run directories `["runs"]`, the runner snapshot cache `["runner", "snapshots"]`.
16
+ * kind gets its own subdirectory: the run directories `["runs"]`, the local snapshot index `["runner", "snapshots"]`.
17
17
  * A relative `XDG_STATE_HOME` is ignored, as the XDG spec says. Without either, the directory can't be found, and
18
18
  * `reason` says why.
19
19
  */
@@ -1,4 +1,4 @@
1
- import type { Credential, MintFailure, MintTarget, TokenAttemptFailure } from "../sdk/extension/index.ts";
1
+ import type { Credential, MintFailure, MintTarget, TokenAttemptFailure, VercelOidcTokenFailure } from "../sdk/extension/index.ts";
2
2
  export type MintOutcome = {
3
3
  readonly ok: true;
4
4
  readonly credential: Credential;
@@ -28,3 +28,17 @@ export type TokenAttemptOutcome = {
28
28
  export interface GitHubActionsTokenGateway {
29
29
  request(): Promise<TokenAttemptOutcome>;
30
30
  }
31
+ export type VercelOidcTokenOutcome = {
32
+ readonly ok: true;
33
+ readonly credential: Credential;
34
+ } | {
35
+ readonly ok: false;
36
+ readonly failure: VercelOidcTokenFailure;
37
+ };
38
+ /**
39
+ * Reads a pre-minted Vercel project OIDC token from `VERCEL_OIDC_TOKEN`. Never rejects: every failure is a
40
+ * `VercelOidcTokenFailure`. Domain logic validates the JWT claims (`vercelOidcSource`).
41
+ */
42
+ export interface VercelOidcTokenGateway {
43
+ read(): Promise<VercelOidcTokenOutcome>;
44
+ }
@@ -1,7 +1,8 @@
1
- export { Credential, type CredentialDiagnosis, type CredentialFailure, type CredentialOrigin, type CredentialOutcome, type CredentialSource, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, type GitHubActionsClaims, type MintFailure, type MintStep, type MintTarget, type TokenAttemptFailure, type TokenRequestFailure, tokenRequestFailureFacts, tokenRequestFailureShape, type TokenRequestVariable, type VercelProject, } from "../sdk/extension/index.ts";
2
- export type { CredentialGateway, GitHubActionsTokenGateway, MintOutcome, TokenAttemptOutcome } from "./gateways.ts";
1
+ export { Credential, type CredentialDiagnosis, type CredentialFailure, type CredentialOrigin, type CredentialOutcome, type CredentialSource, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, describeVercelOidcTokenFailure, type GitHubActionsClaims, type MintFailure, type MintStep, type MintTarget, type TokenAttemptFailure, type TokenRequestFailure, tokenRequestFailureFacts, tokenRequestFailureShape, type TokenRequestVariable, type VercelOidcTokenFailure, vercelOidcTokenFailureFacts, vercelOidcTokenFailureShape, type VercelProject, } from "../sdk/extension/index.ts";
2
+ export type { CredentialGateway, GitHubActionsTokenGateway, MintOutcome, TokenAttemptOutcome, VercelOidcTokenGateway, VercelOidcTokenOutcome, } from "./gateways.ts";
3
3
  export { liveGitHubActionsTokenGateway } from "./live/github-actions-token-gateway.ts";
4
4
  export { liveCredentialGateway } from "./live/vercel-cli-gateway.ts";
5
+ export { liveVercelOidcTokenGateway } from "./live/vercel-oidc-token-gateway.ts";
5
6
  export type { CredentialEvent, CredentialProgress } from "./events.ts";
6
- export { type CredentialContext, type CredentialSourceChoice, credentialSourceFor, type MintSource, REQUESTING_TOKEN_LINE, } from "./source.ts";
7
+ export { type CredentialContext, type CredentialSourceChoice, credentialSourceFor, type MintSource, REQUESTING_TOKEN_LINE, type VercelOidcFailed, type VercelOidcSource, type VercelProjectOutcome, type VercelProjectSource, vercelProjectSource, } from "./source.ts";
7
8
  export { mintTargetText } from "./target.ts";
@@ -4,8 +4,9 @@
4
4
  // their failures and how those are worded, which this surface re-exports for the launcher. It loads no Clinkr, at run
5
5
  // time or in its declarations: the credential launcher resolver and the errors a command refuses with live in `config`
6
6
  // (`credential-resolver.ts`, `credential-settle.ts`).
7
- export { Credential, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, tokenRequestFailureFacts, tokenRequestFailureShape, } from "../sdk/extension/index.js";
7
+ export { Credential, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, describeVercelOidcTokenFailure, tokenRequestFailureFacts, tokenRequestFailureShape, vercelOidcTokenFailureFacts, vercelOidcTokenFailureShape, } from "../sdk/extension/index.js";
8
8
  export { liveGitHubActionsTokenGateway } from "./live/github-actions-token-gateway.js";
9
9
  export { liveCredentialGateway } from "./live/vercel-cli-gateway.js";
10
- export { credentialSourceFor, REQUESTING_TOKEN_LINE, } from "./source.js";
10
+ export { liveVercelOidcTokenGateway } from "./live/vercel-oidc-token-gateway.js";
11
+ export { credentialSourceFor, REQUESTING_TOKEN_LINE, vercelProjectSource, } from "./source.js";
11
12
  export { mintTargetText } from "./target.js";
@@ -11,7 +11,7 @@ export declare function liveCredentialGateway(): CredentialGateway;
11
11
  /**
12
12
  * The environment of a `vercel` invocation: `host` without `VERCEL_TOKEN`, with color and the update notifier off.
13
13
  * `vercel` reads `VERCEL_TOKEN` when there's no `--token`, and then ignores its saved login. An inherited token, such
14
- * as a test account's token that `vtest teams run` hands its command, would make `vercel` mint the credential as that
14
+ * as a test account's token that `vctest teams run` hands its command, would make `vercel` mint the credential as that
15
15
  * identity, and not as the person or CI job that runs storm.
16
16
  */
17
17
  export declare function vercelEnvironment(host: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
@@ -57,7 +57,7 @@ function runVercel(args) {
57
57
  /**
58
58
  * The environment of a `vercel` invocation: `host` without `VERCEL_TOKEN`, with color and the update notifier off.
59
59
  * `vercel` reads `VERCEL_TOKEN` when there's no `--token`, and then ignores its saved login. An inherited token, such
60
- * as a test account's token that `vtest teams run` hands its command, would make `vercel` mint the credential as that
60
+ * as a test account's token that `vctest teams run` hands its command, would make `vercel` mint the credential as that
61
61
  * identity, and not as the person or CI job that runs storm.
62
62
  */
63
63
  export function vercelEnvironment(host) {
@@ -0,0 +1,11 @@
1
+ import type { VercelOidcTokenGateway } from "../gateways.ts";
2
+ export interface LiveVercelOidcTokenOptions {
3
+ /** The environment `VERCEL_OIDC_TOKEN` is read from when `read()` is called. */
4
+ readonly env: Readonly<Record<string, string | undefined>>;
5
+ }
6
+ /**
7
+ * Reads a pre-minted Vercel project OIDC token from `VERCEL_OIDC_TOKEN` in `options.env`, wrapping it in a
8
+ * `Credential` immediately so the raw token never leaves the credential. Never auto-detected without
9
+ * `--credential vercel-oidc`. Never rejects.
10
+ */
11
+ export declare function liveVercelOidcTokenGateway(options: LiveVercelOidcTokenOptions): VercelOidcTokenGateway;
@@ -0,0 +1,16 @@
1
+ import { Credential } from "../../sdk/extension/index.js";
2
+ /**
3
+ * Reads a pre-minted Vercel project OIDC token from `VERCEL_OIDC_TOKEN` in `options.env`, wrapping it in a
4
+ * `Credential` immediately so the raw token never leaves the credential. Never auto-detected without
5
+ * `--credential vercel-oidc`. Never rejects.
6
+ */
7
+ export function liveVercelOidcTokenGateway(options) {
8
+ return {
9
+ async read() {
10
+ const token = Object.hasOwn(options.env, "VERCEL_OIDC_TOKEN") ? options.env["VERCEL_OIDC_TOKEN"] : undefined;
11
+ if (token === undefined || token === "")
12
+ return { ok: false, failure: { kind: "missing-token" } };
13
+ return { ok: true, credential: new Credential(token) };
14
+ },
15
+ };
16
+ }