@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
@@ -1,5 +1,5 @@
1
- import type { CheckoutFailure, RunnerSandboxRole, RunnerSnapshotCacheFailure } from "./gateways.ts";
2
- import type { RejectedSnapshot } from "./snapshot-cache.ts";
1
+ import type { CheckoutFailure, RunnerSandboxRole, RunnerSnapshotIndexFailure } from "./gateways.ts";
2
+ import type { RejectedSnapshot } from "./local-snapshot-index.ts";
3
3
  /**
4
4
  * Where a step runs, which names its progress lines: `snapshot` (`[runner snapshot]`), `apply` (`[runner]`), `install`
5
5
  * (`[runner install]`) and `build` (`[runner build]`).
@@ -35,7 +35,7 @@ export interface NotKeptSandbox {
35
35
  }
36
36
  /**
37
37
  * Why a base snapshot is being built: no cached snapshot fits the run or the checkout (`no-snapshot`), with why each
38
- * cached snapshot of the recipe didn't (`rejected`); `storm snapshots build --full` asked for a new one whatever the
38
+ * cached snapshot of the runner didn't (`rejected`); `storm snapshots build --full` asked for a new one whatever the
39
39
  * cache holds (`full`); or `storm snapshots build --base <ref>` asked for one at a commit the cache has none of
40
40
  * (`base`).
41
41
  */
@@ -50,8 +50,9 @@ export type SnapshotBuildReason = {
50
50
  /**
51
51
  * What the runner reports, in order.
52
52
  *
53
- * - `snapshot-reused`: the run starts from cached runner snapshot `snapshotId`, built at `base`; `builtBehind` is how
54
- * many commits HEAD has that `base` lacks.
53
+ * - `snapshot-reused`: the run starts from runner snapshot `snapshotId`, built at `base`; `builtBehind` is how many
54
+ * commits HEAD has that `base` lacks, and `source` says whether it came from the local snapshot index (`local`) or the shared
55
+ * snapshot index (`shared`).
55
56
  * - `snapshot-build-started`: a base snapshot of `base` is being built, and `why` (`SnapshotBuildReason`); `summary`
56
57
  * says what the build does.
57
58
  * - `runner-sandbox-starting`: the runner sandbox is starting from runner snapshot `snapshotId`.
@@ -61,7 +62,8 @@ export type SnapshotBuildReason = {
61
62
  * - `snapshot-saving`: the build sandbox is being saved as a runner snapshot.
62
63
  * - `snapshot-built`: it was, in `ms` from the build's start; `builtBehind` is how many commits HEAD has that `base`
63
64
  * lacks, null for a `storm snapshots build --base` commit that isn't HEAD's merge-base.
64
- * - `snapshot-entry-not-written`: the cache couldn't record the new snapshot; the run goes on.
65
+ * - `snapshot-entry-not-written`: the cache couldn't record the snapshot; the run goes on.
66
+ * - `shared-snapshot-lookup-failed`: querying the shared snapshot index failed; the run continues without it.
65
67
  * - `uploading`: the run's changes are being uploaded to the runner sandbox.
66
68
  * - `uploaded`: the run's changes, `bytes` in all, reached the runner sandbox.
67
69
  * - `command-output-started`: the command started in runner sandbox `sandbox`, and its output follows on the
@@ -78,6 +80,7 @@ export type RunnerEvent = {
78
80
  readonly snapshotId: string;
79
81
  readonly base: string;
80
82
  readonly builtBehind: number;
83
+ readonly source: "local" | "shared";
81
84
  } | {
82
85
  readonly kind: "snapshot-build-started";
83
86
  readonly base: string;
@@ -127,7 +130,10 @@ export type RunnerEvent = {
127
130
  readonly builtBehind: number | null;
128
131
  } | {
129
132
  readonly kind: "snapshot-entry-not-written";
130
- readonly failure: RunnerSnapshotCacheFailure;
133
+ readonly failure: RunnerSnapshotIndexFailure;
134
+ } | {
135
+ readonly kind: "shared-snapshot-lookup-failed";
136
+ readonly message: string;
131
137
  } | {
132
138
  readonly kind: "uploading";
133
139
  } | {
@@ -156,9 +162,9 @@ export interface RunnerProgress {
156
162
  emit(event: RunnerEvent): Promise<void>;
157
163
  }
158
164
  /** What a Sandbox call was doing when it failed, as `sandbox-api-failed` names it. */
159
- export type RunnerSandboxCall = "start-build-sandbox" | "start-runner-sandbox" | "upload" | "run-script" | "login-path" | "run-command" | "save-snapshot";
165
+ export type RunnerSandboxCall = "start-build-sandbox" | "start-runner-sandbox" | "upload" | "run-script" | "login-path" | "run-command" | "save-snapshot" | "get-named-sandbox" | "get-snapshot" | "delete-named-sandbox";
160
166
  /**
161
- * Where a network policy write that puts credentials in place or removes them was: around the recipe's snapshot steps
167
+ * Where a network policy write that puts credentials in place or removes them was: around the runner's snapshot steps
162
168
  * (its toolchain and prebuild steps, in the build sandbox), around its run steps (its install and build steps, in the
163
169
  * runner sandbox), before a snapshot save, or around the command.
164
170
  */
@@ -171,7 +177,7 @@ export type NetworkPolicyPlace = "snapshot-steps" | "run-steps" | "snapshot-save
171
177
  * - `sandbox-api-failed`: a Sandbox call failed; `status` is the HTTP status when the API answered one.
172
178
  * - `checkout-failed`: git or tar failed on this machine, packing the base's files or the run's changes.
173
179
  * - `network-policy-failed`: a network policy write that puts credentials in place or removes them failed, `around`
174
- * one of four places: the recipe's snapshot steps (`snapshot-steps`) or its run steps (`run-steps`), whose
180
+ * one of four places: the runner's snapshot steps (`snapshot-steps`) or its run steps (`run-steps`), whose
175
181
  * credentials it puts in place before the first of them (`inject`; none of them ran); a snapshot save
176
182
  * (`snapshot-save`), before which the scope removes them (`remove`); or the command (`command`), whose resources'
177
183
  * credentials it puts in place before the command starts (`inject`; the command didn't run). `reason` is `api`, with
@@ -1,5 +1,6 @@
1
1
  import type { Credential } from "../credential/index.ts";
2
2
  import type { SandboxCredential } from "../sdk/extension/index.ts";
3
+ import type { ManagedCredential } from "./vercel-sandbox-secrets.ts";
3
4
  /** Why a checkout operation failed: what git or tar said, and the command that failed when there was one. */
4
5
  export interface CheckoutFailure {
5
6
  readonly message: string;
@@ -132,17 +133,22 @@ export interface CheckoutGateway {
132
133
  readonly repoRoot: string;
133
134
  readonly base: string;
134
135
  }): Promise<CheckoutResult<BaseArchive>>;
136
+ /** The URL configured for Git remote `remote` (`git remote get-url <remote>`). */
137
+ remoteUrl(request: {
138
+ readonly repoRoot: string;
139
+ readonly remote: string;
140
+ }): Promise<CheckoutResult<string>>;
135
141
  }
136
142
  /**
137
- * One runner snapshot the cache records: who it belongs to, what it was built from, and when it expires. Times
138
- * are ISO strings. Every entry records a base snapshot, built at its base, which may be any commit.
143
+ * One runner snapshot the local snapshot index records: who it belongs to, what it was built from, and when it expires.
144
+ * Times are ISO strings. Every entry records a runner snapshot built at its base commit.
139
145
  */
140
146
  export interface RunnerSnapshotEntry {
141
147
  readonly teamId: string;
142
148
  readonly projectId: string;
143
149
  readonly region: string;
144
- readonly runtime: string;
145
- readonly recipeName: string;
150
+ readonly image: string;
151
+ readonly runnerName: string;
146
152
  /** The snapshot key at `base` (`snapshotKey`). */
147
153
  readonly snapshotKey: string;
148
154
  /** The base commit's full SHA: the commit the snapshot was built at, whose tracked files its repository commits. */
@@ -151,49 +157,49 @@ export interface RunnerSnapshotEntry {
151
157
  readonly createdAt: string;
152
158
  readonly expiresAt: string;
153
159
  }
154
- /** A cache file storm can't read: not JSON, of an unknown version, invalid, or misnamed. */
160
+ /** A local snapshot index file storm can't read: not JSON, of an unknown version, invalid, or misnamed. */
155
161
  export interface UnreadableSnapshotEntry {
156
162
  readonly file: string;
157
163
  readonly reason: string;
158
164
  }
159
165
  /** What `listEntries` found. */
160
166
  export interface RunnerSnapshotListing {
161
- /** Where the cache lives. */
167
+ /** Where the local snapshot index lives. */
162
168
  readonly directory: string;
163
169
  readonly entries: readonly RunnerSnapshotEntry[];
164
170
  readonly unreadable: readonly UnreadableSnapshotEntry[];
165
171
  }
166
- /** Why a cache operation failed: the path it failed on and what the OS said. */
167
- export interface RunnerSnapshotCacheFailure {
172
+ /** Why a local snapshot index operation failed: the path it failed on and what the OS said. */
173
+ export interface RunnerSnapshotIndexFailure {
168
174
  readonly path: string;
169
175
  readonly message: string;
170
176
  }
171
- export type RunnerSnapshotCacheResult<T> = {
177
+ export type RunnerSnapshotIndexResult<T> = {
172
178
  readonly ok: true;
173
179
  readonly value: T;
174
180
  } | {
175
181
  readonly ok: false;
176
- readonly failure: RunnerSnapshotCacheFailure;
182
+ readonly failure: RunnerSnapshotIndexFailure;
177
183
  };
178
- export type RunnerSnapshotCacheOperation = {
184
+ export type RunnerSnapshotIndexOperation = {
179
185
  readonly ok: true;
180
186
  } | {
181
187
  readonly ok: false;
182
- readonly failure: RunnerSnapshotCacheFailure;
188
+ readonly failure: RunnerSnapshotIndexFailure;
183
189
  };
184
190
  /**
185
- * The per-machine runner snapshot cache: one record per runner snapshot, keyed by the entry's identity (team,
186
- * project, region, runtime, recipe name, snapshot key and base).
191
+ * The per-machine local snapshot index: one record per runner snapshot, keyed by the entry's identity (team, project,
192
+ * region, image, runner name, snapshot key, and base).
187
193
  * Every method returns its expected failures and never rejects. Which entries a run may use, and when one has
188
194
  * expired, is the caller's.
189
195
  */
190
- export interface RunnerSnapshotCacheGateway {
191
- /** Every readable entry, and the files it couldn't read. A cache never written is empty. */
192
- listEntries(): Promise<RunnerSnapshotCacheResult<RunnerSnapshotListing>>;
196
+ export interface RunnerSnapshotIndexGateway {
197
+ /** Every readable entry, and the files it couldn't read. An index never written is empty. */
198
+ listEntries(): Promise<RunnerSnapshotIndexResult<RunnerSnapshotListing>>;
193
199
  /** Records `entry`, replacing any entry with the same identity. */
194
- writeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotCacheOperation>;
200
+ writeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotIndexOperation>;
195
201
  /** Removes the entry with `entry`'s identity. Removing one that isn't there succeeds. */
196
- removeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotCacheOperation>;
202
+ removeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotIndexOperation>;
197
203
  }
198
204
  /** What every Sandbox call runs as: the run's credential, and the team and project its token names. */
199
205
  export interface SandboxAccess {
@@ -226,7 +232,7 @@ export interface RunnerSandbox {
226
232
  * with 403; for `all`, every request. Every other domain stays fully reachable.
227
233
  * - `custom`: only the allowed domains and the domain of each credential in place are reachable, and every other
228
234
  * domain doesn't resolve. An allowed domain is a hostname or a wildcard with one leading `*.`. Each credential's
229
- * domain gets the same rules as under `allow-all`. A recipe's `allowedDomains` gives the list.
235
+ * domain gets the same rules as under `allow-all`. A runner's `allowedDomains` gives the list.
230
236
  * - `deny-all`: no domain is reachable, and no credential is in place. A run writes it to the runner sandbox it keeps
231
237
  * before it releases its resources.
232
238
  *
@@ -251,6 +257,8 @@ export interface RunnerSandboxPlacement {
251
257
  /** At most 5: `purpose`, `user`, and `role`. */
252
258
  readonly tags: Readonly<Record<string, string>>;
253
259
  readonly networkPolicy: RunnerNetworkPolicy;
260
+ /** Vercel-managed sandbox credentials passed to `Sandbox.create({ credentials })`; omitted when empty. */
261
+ readonly managedCredentials?: readonly ManagedCredential[];
254
262
  }
255
263
  /**
256
264
  * Why a Sandbox call failed.
@@ -278,6 +286,49 @@ export type RunnerStartFailure = RunnerSandboxFailure | {
278
286
  readonly kind: "snapshot-gone";
279
287
  readonly message: string;
280
288
  };
289
+ /** Why starting a build sandbox failed: any Sandbox failure, or `name-taken` when `name` already exists. */
290
+ export type RunnerBuildStartFailure = RunnerSandboxFailure | {
291
+ readonly kind: "name-taken";
292
+ readonly name: string;
293
+ readonly message: string;
294
+ };
295
+ /** Status of a Vercel Sandbox as returned by the Sandbox API. */
296
+ export type NamedSandboxStatus = "pending" | "running" | "stopping" | "stopped" | "failed" | "aborted" | "snapshotting";
297
+ /** Metadata for a named sandbox in a Vercel project. */
298
+ export interface NamedSandboxInfo {
299
+ readonly name: string;
300
+ readonly status: NamedSandboxStatus;
301
+ readonly currentSnapshotId: string | undefined;
302
+ /** When the sandbox was created, as an ISO timestamp string. */
303
+ readonly createdAt: string;
304
+ readonly tags: Readonly<Record<string, string>>;
305
+ }
306
+ /** What `getNamedSandbox` found: the sandbox's metadata, or `not-found` when no sandbox by that name exists. */
307
+ export type NamedSandboxLookup = {
308
+ readonly kind: "found";
309
+ readonly sandbox: NamedSandboxInfo;
310
+ } | {
311
+ readonly kind: "not-found";
312
+ };
313
+ /** Status of a Vercel Sandbox snapshot as returned by the Sandbox API. */
314
+ export type SnapshotStatus = "failed" | "created" | "deleted";
315
+ /** Metadata for a snapshot in a Vercel project. */
316
+ export interface SnapshotInfo {
317
+ readonly snapshotId: string;
318
+ readonly status: SnapshotStatus;
319
+ /** When the snapshot was created, as an ISO timestamp string. */
320
+ readonly createdAt: string;
321
+ /** When the snapshot expires, as an ISO timestamp string, or `undefined` when it doesn't expire. */
322
+ readonly expiresAt: string | undefined;
323
+ readonly sizeBytes: number;
324
+ }
325
+ /** What `getSnapshot` found: the snapshot's metadata, or `not-found` when it is missing or has expired. */
326
+ export type SnapshotLookup = {
327
+ readonly kind: "found";
328
+ readonly snapshot: SnapshotInfo;
329
+ } | {
330
+ readonly kind: "not-found";
331
+ };
281
332
  export type RunnerSandboxResult<T, F = RunnerSandboxFailure> = {
282
333
  readonly ok: true;
283
334
  readonly value: T;
@@ -319,14 +370,37 @@ export interface SavedSnapshot {
319
370
  * outlive the call, and only `keepRunning` and `stop` end every one.
320
371
  */
321
372
  export interface RunnerSandboxGateway {
322
- /** Starts a fresh build sandbox on `runtime`, not persistent. */
373
+ /**
374
+ * Starts a fresh build sandbox from `image`, not persistent, optionally with an explicit `name`; answers
375
+ * `name-taken` when a sandbox with that `name` already exists in the project.
376
+ */
323
377
  startBuildSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
324
- readonly runtime: string;
325
- }, signal?: AbortSignal): Promise<RunnerSandboxResult<RunnerSandbox>>;
378
+ readonly image: string;
379
+ readonly name?: string;
380
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<RunnerSandbox, RunnerBuildStartFailure>>;
326
381
  /** Starts a runner sandbox from runner snapshot `snapshotId`, not persistent; `snapshot-gone` when it is gone. */
327
382
  startRunnerSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
328
383
  readonly snapshotId: string;
329
384
  }, signal?: AbortSignal): Promise<RunnerSandboxResult<RunnerSandbox, RunnerStartFailure>>;
385
+ /** Reads metadata for the named sandbox `name`, without resuming it; answers `not-found` on 404. */
386
+ getNamedSandbox(access: SandboxAccess, request: {
387
+ readonly name: string;
388
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<NamedSandboxLookup>>;
389
+ /** Lists every sandbox in the project whose name starts with `namePrefix`, across all pages, sorted by name. */
390
+ listNamedSandboxes(access: SandboxAccess, request: {
391
+ readonly namePrefix: string;
392
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<readonly NamedSandboxInfo[]>>;
393
+ /** Reads metadata for snapshot `snapshotId`; answers `not-found` on 404 or 410. */
394
+ getSnapshot(access: SandboxAccess, request: {
395
+ readonly snapshotId: string;
396
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<SnapshotLookup>>;
397
+ /**
398
+ * Deletes the named sandbox `name`, keeping any snapshots it saved (`deleteOrphanSnapshots: false`). Deleting a
399
+ * sandbox that doesn't exist succeeds.
400
+ */
401
+ deleteNamedSandbox(access: SandboxAccess, request: {
402
+ readonly name: string;
403
+ }, signal?: AbortSignal): Promise<RunnerSandboxOperation>;
330
404
  /** Writes `files` to the sandbox's own staging directory, made once per sandbox, and answers its path. */
331
405
  upload(sandbox: RunnerSandbox, files: readonly StagedFile[], signal?: AbortSignal): Promise<RunnerSandboxResult<{
332
406
  readonly directory: string;
@@ -418,3 +492,28 @@ export interface RunnerTerminal {
418
492
  writeStdout(text: string): void;
419
493
  writeStderr(text: string): void;
420
494
  }
495
+ /** Why reading a GitHub token through `gh auth token` failed. */
496
+ export type GhTokenFailureKind = "not-installed" | "not-authenticated" | "timed-out" | "failed";
497
+ /** A safe diagnostic for a failed `gh auth token --hostname <host>` call (never contains a token). */
498
+ export interface GhTokenFailure {
499
+ readonly kind: GhTokenFailureKind;
500
+ readonly host: string;
501
+ readonly message: string;
502
+ }
503
+ /** What reading a GitHub token through `GhTokenGateway` answered. */
504
+ export type GhTokenRead = {
505
+ readonly ok: true;
506
+ readonly token: string;
507
+ } | {
508
+ readonly ok: false;
509
+ readonly failure: GhTokenFailure;
510
+ };
511
+ /**
512
+ * Reads a GitHub token on the launch machine via `gh auth token --hostname <host>`. Every method returns its expected
513
+ * failures and never rejects.
514
+ */
515
+ export interface GhTokenGateway {
516
+ readToken(request: {
517
+ readonly host: string;
518
+ }): Promise<GhTokenRead>;
519
+ }
@@ -1,3 +1,3 @@
1
- // The runner's gateways: on this machine, the Git checkout a run uploads from and the runner snapshot cache; remotely,
1
+ // The runner's gateways: on this machine, the Git checkout a run uploads from and the local snapshot index; remotely,
2
2
  // Vercel Sandbox, where runner and build sandboxes run. And the terminal the command's output reaches.
3
3
  export {};
@@ -0,0 +1,42 @@
1
+ /** How a `{ kind: "gh" }` sandbox credential frames the raw token in the `authorization` header. */
2
+ export type GhTokenFormat = "basic" | "bearer";
3
+ /** Default GitHub hostname passed to `gh auth token --hostname <host>`. */
4
+ export declare const DEFAULT_GH_HOST = "github.com";
5
+ /** The result of validating and framing a raw GitHub token for a `{ kind: "gh" }` sandbox credential. */
6
+ export type GhTokenFraming = {
7
+ readonly ok: true;
8
+ readonly headerValue: string;
9
+ /** Every secret form (header value, base64 `x-access-token:<token>` when basic, raw token) to redact. */
10
+ readonly secrets: readonly string[];
11
+ } | {
12
+ readonly ok: false;
13
+ readonly problem: "multiline" | "short" | "gh-preframed";
14
+ };
15
+ /** Resolves the `gh auth token --hostname` target for a `{ kind: "gh" }` source (defaults to `"github.com"`). */
16
+ export declare function resolveGhHost(source: {
17
+ readonly host?: string;
18
+ }): string;
19
+ /**
20
+ * Resolves the `Authorization` framing for a `{ kind: "gh" }` source on `domain`:
21
+ * - Uses `source.format` when explicitly declared.
22
+ * - Defaults to `"basic"` (`Basic <base64(x-access-token:<token>)>`, for Git over HTTPS) when `domain` matches the
23
+ * source's GitHub host (such as `"github.com"` or a GitHub Enterprise host).
24
+ * - Defaults to `"bearer"` (`Bearer <token>`) for API and companion hosts (such as `"api.github.com"`).
25
+ */
26
+ export declare function resolveGhFormat(domain: string, source: {
27
+ readonly host?: string;
28
+ readonly format?: GhTokenFormat;
29
+ }): GhTokenFormat;
30
+ /** Base64 of `x-access-token:<token>`, the `Basic` credential value Git over HTTPS sends to GitHub. */
31
+ export declare function ghBasicCredential(token: string): string;
32
+ /**
33
+ * Validates a raw GitHub token (single-line, not pre-framed with `Bearer`/`Basic`, and at least `SECRET_MIN_LENGTH`
34
+ * characters), frames it as `Bearer <token>` or `Basic <base64(x-access-token:<token>)>`, and returns every secret
35
+ * form for `<token>` redaction.
36
+ */
37
+ export declare function frameGhToken(token: string, format: GhTokenFormat): GhTokenFraming;
38
+ /**
39
+ * Extracts unchecked redaction forms from a launcher environment variable configured as `env` on `{ kind: "gh", env }`
40
+ * for `declaredSecretValues` (redaction-only paths that never spawn `gh`).
41
+ */
42
+ export declare function ghEnvRedactionForms(raw: string): readonly string[];
@@ -0,0 +1,58 @@
1
+ // Pure GitHub token framing and defaults for `{ kind: "gh" }` sandbox credentials. Never spawns `gh`: the live
2
+ // `GhTokenGateway` invokes `gh auth token --hostname <host>` when no `env` override is set, and this module resolves
3
+ // defaults, validates raw tokens, frames `Basic` or `Bearer` `Authorization` headers, and produces every secret form
4
+ // to redact as `<token>`.
5
+ import { SECRET_MIN_LENGTH } from "../sdk/extension/index.js";
6
+ /** Default GitHub hostname passed to `gh auth token --hostname <host>`. */
7
+ export const DEFAULT_GH_HOST = "github.com";
8
+ /** Resolves the `gh auth token --hostname` target for a `{ kind: "gh" }` source (defaults to `"github.com"`). */
9
+ export function resolveGhHost(source) {
10
+ return source.host ?? DEFAULT_GH_HOST;
11
+ }
12
+ /**
13
+ * Resolves the `Authorization` framing for a `{ kind: "gh" }` source on `domain`:
14
+ * - Uses `source.format` when explicitly declared.
15
+ * - Defaults to `"basic"` (`Basic <base64(x-access-token:<token>)>`, for Git over HTTPS) when `domain` matches the
16
+ * source's GitHub host (such as `"github.com"` or a GitHub Enterprise host).
17
+ * - Defaults to `"bearer"` (`Bearer <token>`) for API and companion hosts (such as `"api.github.com"`).
18
+ */
19
+ export function resolveGhFormat(domain, source) {
20
+ if (source.format !== undefined)
21
+ return source.format;
22
+ return domain === resolveGhHost(source) ? "basic" : "bearer";
23
+ }
24
+ /** Base64 of `x-access-token:<token>`, the `Basic` credential value Git over HTTPS sends to GitHub. */
25
+ export function ghBasicCredential(token) {
26
+ return Buffer.from(`x-access-token:${token}`, "utf8").toString("base64");
27
+ }
28
+ /**
29
+ * Validates a raw GitHub token (single-line, not pre-framed with `Bearer`/`Basic`, and at least `SECRET_MIN_LENGTH`
30
+ * characters), frames it as `Bearer <token>` or `Basic <base64(x-access-token:<token>)>`, and returns every secret
31
+ * form for `<token>` redaction.
32
+ */
33
+ export function frameGhToken(token, format) {
34
+ if (/[\r\n]/.test(token))
35
+ return { ok: false, problem: "multiline" };
36
+ if (/^(?:bearer|basic)\s/i.test(token))
37
+ return { ok: false, problem: "gh-preframed" };
38
+ if (token.length < SECRET_MIN_LENGTH)
39
+ return { ok: false, problem: "short" };
40
+ if (format === "bearer") {
41
+ const headerValue = `Bearer ${token}`;
42
+ return { ok: true, headerValue, secrets: uniqueNonEmpty([headerValue, token]) };
43
+ }
44
+ const basic = ghBasicCredential(token);
45
+ const headerValue = `Basic ${basic}`;
46
+ return { ok: true, headerValue, secrets: uniqueNonEmpty([headerValue, basic, token]) };
47
+ }
48
+ /**
49
+ * Extracts unchecked redaction forms from a launcher environment variable configured as `env` on `{ kind: "gh", env }`
50
+ * for `declaredSecretValues` (redaction-only paths that never spawn `gh`).
51
+ */
52
+ export function ghEnvRedactionForms(raw) {
53
+ const basic = ghBasicCredential(raw);
54
+ return uniqueNonEmpty([`Basic ${basic}`, basic, `Bearer ${raw}`, raw]);
55
+ }
56
+ function uniqueNonEmpty(values) {
57
+ return [...new Set(values.filter((value) => value.length > 0))];
58
+ }
@@ -1,20 +1,25 @@
1
- export type { RunnerContext } from "./context.ts";
2
- export { buildSnapshots, prepareSnapshotBuild, type PrepareSnapshotBuildOutcome, type SnapshotBuildOutcome, } from "./build-snapshots.ts";
1
+ export { type RunnerContext, snapshotIndexTags } from "./context.ts";
2
+ export { buildSnapshots, prepareSnapshotBuild, type PreparedSnapshotBuild, type PrepareSnapshotBuildOutcome, sameSnapshotBuild, type SnapshotBuildOutcome, } from "./build-snapshots.ts";
3
3
  export { type KeptSandbox, type RunnerEvent, type RunnerFailure, type RunnerProgress, type RunnerStepPhase, type SnapshotBuildReason, } from "./events.ts";
4
- export type { CheckoutFailure, CheckoutGateway, RunnerSandboxGateway, SandboxAccess, RunnerSnapshotCacheFailure, RunnerSnapshotCacheGateway, RunnerSnapshotEntry, RunnerTerminal, RunnerTerminalColor, } from "./gateways.ts";
4
+ export type { CheckoutFailure, CheckoutGateway, GhTokenFailure, GhTokenFailureKind, GhTokenGateway, GhTokenRead, NamedSandboxInfo, NamedSandboxLookup, NamedSandboxStatus, RunnerBuildStartFailure, RunnerSandboxGateway, SandboxAccess, RunnerSnapshotIndexFailure, RunnerSnapshotIndexGateway, RunnerSnapshotEntry, RunnerTerminal, RunnerTerminalColor, SnapshotInfo, SnapshotLookup, SnapshotStatus, } from "./gateways.ts";
5
5
  export { liveCheckoutGateway } from "./live/checkout-gateway.ts";
6
+ export { liveGhTokenGateway } from "./live/gh-token-gateway.ts";
6
7
  export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.ts";
7
8
  export { liveRunnerTerminal } from "./live/terminal.ts";
8
9
  export { localUserName } from "./live/user.ts";
9
- export { liveRunnerSnapshotCacheGateway, unavailableRunnerSnapshotCacheGateway, } from "./live/snapshot-cache-gateway.ts";
10
+ export { liveRunnerSnapshotIndexGateway, unavailableRunnerSnapshotIndexGateway, } from "./live/snapshot-index-gateway.ts";
10
11
  export { lineSplitter } from "./output.ts";
11
12
  export { prepareRunner, type PrepareRunnerOutcome } from "./prepare.ts";
12
13
  export type { ChosenSnapshot, ReadyRunnerOutcome } from "./ready.ts";
13
- export { type CheckedRecipe, checkRecipe, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type RunnerVcpuCount, type RunnerVcpuRule, type SandboxCountDefault, type SandboxCountDefaultRule, type RunnerSandboxCount, type ToolchainStep, type VcpuRun, } from "./recipe.ts";
14
+ export { type CheckedVercelSandboxOptions, checkVercelSandboxOptions, type GhCredentialSource, type GhTokenFormat, type ManagedCredential, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type RunnerVcpuCount, type RunnerVcpuRule, type SandboxCountDefault, type SandboxCountDefaultRule, type SandboxCredentialSource, type RunnerSandboxCount, type SnapshotSource, type ToolchainStep, type VcpuRun, } from "./vercel-sandbox-options.ts";
14
15
  export { chooseSnapshotForRun, type SnapshotChoice, type SnapshotChoiceEnd } from "./snapshot-choice.ts";
15
16
  export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.ts";
16
17
  export type { RunnerFenceOutcome } from "./scope.ts";
17
- export { declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, type UnsafeSecretEnvVarMap, } from "./secrets.ts";
18
+ export { CREDENTIAL_PROBLEM_KINDS, type CredentialProblem, type CredentialProblemKind, type CredentialReadContext, declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, type UnsafeSecretEnvVarMap, } from "./secrets.ts";
18
19
  export { type RunnerCleanupFacts, openRunnerSession, type RunnerSession, type RunnerSessionCleanup, type RunnerSessionRequest, } from "./session.ts";
19
- export { type InspectedSnapshot, inspectSnapshotCache, type SnapshotCacheInspection, type UnpickedReason, } from "./snapshot-inspect.ts";
20
- export { type RejectedSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type SnapshotCacheNote, type SnapshotRejectionReason, } from "./snapshot-cache.ts";
20
+ export { type InspectedSnapshot, inspectLocalSnapshotIndex, type LocalSnapshotIndexInspection, type UnpickedReason, } from "./snapshot-inspect.ts";
21
+ export { type RejectedSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type SnapshotIndexNote, type SnapshotRejectionReason, } from "./local-snapshot-index.ts";
22
+ export { type ParsedSharedSnapshotName, parseSharedSnapshotSandboxName, SHARED_SNAPSHOT_SANDBOX_PREFIX, sharedSnapshotBucket, type SharedSnapshotBucketInput, sharedSnapshotSandboxName, sharedSnapshotSandboxPrefix, type SharedSnapshotStatus, } from "./shared-snapshot-entry.ts";
23
+ export { listSharedSnapshots, pickSnapshotAcrossIndexes, type SharedSnapshotIndexEntry, type SharedSnapshotListRequest, type SharedSnapshotListResult, type SharedSnapshotSelection, type SnapshotAcrossIndexesResult, } from "./shared-snapshot-list.ts";
24
+ export { lookupSharedSnapshot, type SharedSnapshotLookupContext, type SharedSnapshotLookupRequest, type SharedSnapshotLookupResult, } from "./shared-snapshot-lookup.ts";
25
+ export { type PrunedSharedSnapshot, pruneSharedSnapshots, type SharedSnapshotPruneFailure, type SharedSnapshotPruneReason, type SharedSnapshotPruneRequest, type SharedSnapshotPruneResult, type SharedSnapshotPruneSummary, } from "./shared-snapshot-prune.ts";
@@ -1,19 +1,25 @@
1
1
  // The `runner` module's public surface: running a command in a runner sandbox, through a run's runner session. Other
2
2
  // modules import only from here, and it holds only what another module under `src/` imports; the runner's own tests
3
3
  // import the files that declare the rest (`README.md`).
4
- export { buildSnapshots, prepareSnapshotBuild, } from "./build-snapshots.js";
4
+ export { snapshotIndexTags } from "./context.js";
5
+ export { buildSnapshots, prepareSnapshotBuild, sameSnapshotBuild, } from "./build-snapshots.js";
5
6
  export {} from "./events.js";
6
7
  export { liveCheckoutGateway } from "./live/checkout-gateway.js";
8
+ export { liveGhTokenGateway } from "./live/gh-token-gateway.js";
7
9
  export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.js";
8
10
  export { liveRunnerTerminal } from "./live/terminal.js";
9
11
  export { localUserName } from "./live/user.js";
10
- export { liveRunnerSnapshotCacheGateway, unavailableRunnerSnapshotCacheGateway, } from "./live/snapshot-cache-gateway.js";
12
+ export { liveRunnerSnapshotIndexGateway, unavailableRunnerSnapshotIndexGateway, } from "./live/snapshot-index-gateway.js";
11
13
  export { lineSplitter } from "./output.js";
12
14
  export { prepareRunner } from "./prepare.js";
13
- export { checkRecipe, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, } from "./recipe.js";
15
+ export { checkVercelSandboxOptions, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, } from "./vercel-sandbox-options.js";
14
16
  export { chooseSnapshotForRun } from "./snapshot-choice.js";
15
17
  export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.js";
16
- export { declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, } from "./secrets.js";
18
+ export { CREDENTIAL_PROBLEM_KINDS, declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, } from "./secrets.js";
17
19
  export { openRunnerSession, } from "./session.js";
18
- export { inspectSnapshotCache, } from "./snapshot-inspect.js";
19
- export { RUNNER_SNAPSHOTS_SUBPATH, } from "./snapshot-cache.js";
20
+ export { inspectLocalSnapshotIndex, } from "./snapshot-inspect.js";
21
+ export { RUNNER_SNAPSHOTS_SUBPATH, } from "./local-snapshot-index.js";
22
+ export { parseSharedSnapshotSandboxName, SHARED_SNAPSHOT_SANDBOX_PREFIX, sharedSnapshotBucket, sharedSnapshotSandboxName, sharedSnapshotSandboxPrefix, } from "./shared-snapshot-entry.js";
23
+ export { listSharedSnapshots, pickSnapshotAcrossIndexes, } from "./shared-snapshot-list.js";
24
+ export { lookupSharedSnapshot, } from "./shared-snapshot-lookup.js";
25
+ export { pruneSharedSnapshots, } from "./shared-snapshot-prune.js";
@@ -26,6 +26,7 @@ export function liveCheckoutGateway() {
26
26
  submodules: ({ repoRoot }) => submodules(repoRoot),
27
27
  assembleUpload: ({ repoRoot, base }) => assembleUpload(repoRoot, base),
28
28
  baseArchive: ({ repoRoot, base }) => baseArchive(repoRoot, base),
29
+ remoteUrl: ({ repoRoot, remote }) => remoteUrl(repoRoot, remote),
29
30
  };
30
31
  }
31
32
  async function repositoryRoot(cwd) {
@@ -147,6 +148,12 @@ async function baseArchive(repoRoot, base) {
147
148
  value: { tarball: tarball.stdout, fileList: fileList.stdout, files: splitNul(fileList.stdout).length },
148
149
  };
149
150
  }
151
+ async function remoteUrl(repoRoot, remote) {
152
+ const run = await git(repoRoot, ["remote", "get-url", "--", remote]);
153
+ // Strip only git's trailing line terminator so leading or trailing whitespace in the configured URL stays visible
154
+ // to validation rather than being silently dropped.
155
+ return run.ok ? { ok: true, value: run.stdout.toString("utf8").replace(/\r?\n$/, "") } : run;
156
+ }
150
157
  /** `git -C <repoRoot> <args>`: its stdout, or its exit code and what it said on stderr. */
151
158
  function git(repoRoot, args) {
152
159
  const argv = ["-C", repoRoot, ...args];
@@ -0,0 +1,17 @@
1
+ import type { GhTokenFailure } from "../gateways.ts";
2
+ /**
3
+ * Strips a single trailing `\n` or `\r\n` from `gh auth token` stdout without trimming leading/trailing spaces or inner
4
+ * line breaks, so unexpected multiline output is still caught as `multiline`.
5
+ */
6
+ export declare function stripSingleTrailingLineBreak(stdout: string): string;
7
+ /**
8
+ * Classifies a failed `gh auth token --hostname <host>` invocation into a safe `GhTokenFailure` without echoing raw
9
+ * stderr or stdout.
10
+ */
11
+ export declare function classifyGhTokenError(info: {
12
+ readonly host: string;
13
+ readonly code: string | number | undefined;
14
+ readonly killed: boolean;
15
+ readonly stderr: string;
16
+ readonly timeoutMs: number;
17
+ }): GhTokenFailure;
@@ -0,0 +1,37 @@
1
+ // Pure stdout/error helpers for the live `gh auth token` gateway (`gh-token-gateway.ts`). Never echoes stdout or raw
2
+ // stderr into error messages so a token can never leak through a diagnostic.
3
+ /**
4
+ * Strips a single trailing `\n` or `\r\n` from `gh auth token` stdout without trimming leading/trailing spaces or inner
5
+ * line breaks, so unexpected multiline output is still caught as `multiline`.
6
+ */
7
+ export function stripSingleTrailingLineBreak(stdout) {
8
+ if (stdout.endsWith("\r\n"))
9
+ return stdout.slice(0, -2);
10
+ if (stdout.endsWith("\n"))
11
+ return stdout.slice(0, -1);
12
+ return stdout;
13
+ }
14
+ /**
15
+ * Classifies a failed `gh auth token --hostname <host>` invocation into a safe `GhTokenFailure` without echoing raw
16
+ * stderr or stdout.
17
+ */
18
+ export function classifyGhTokenError(info) {
19
+ const { host, code, killed, stderr, timeoutMs } = info;
20
+ if (code === "ENOENT") {
21
+ return { kind: "not-installed", host, message: "gh CLI is not installed or not on PATH" };
22
+ }
23
+ if (killed || code === "ETIMEDOUT") {
24
+ return { kind: "timed-out", host, message: `gh auth token --hostname ${host} timed out after ${timeoutMs}ms` };
25
+ }
26
+ if (NOT_AUTHENTICATED_PATTERN.test(stderr)) {
27
+ return { kind: "not-authenticated", host, message: `gh is not authenticated for ${host}` };
28
+ }
29
+ return {
30
+ kind: "failed",
31
+ host,
32
+ message: typeof code === "number"
33
+ ? `gh auth token --hostname ${host} exited ${code}`
34
+ : `gh auth token --hostname ${host} failed`,
35
+ };
36
+ }
37
+ const NOT_AUTHENTICATED_PATTERN = /not logged in|no oauth token|no token|gh auth login|authentication failed|to get started with github cli/i;
@@ -0,0 +1,13 @@
1
+ import type { GhTokenGateway } from "../gateways.ts";
2
+ /** Default time limit for `gh auth token --hostname <host>`. */
3
+ export declare const GH_TOKEN_TIMEOUT_MS = 10000;
4
+ export interface LiveGhTokenGatewayOptions {
5
+ /** Executable name or path to invoke; defaults to `"gh"`. */
6
+ readonly command?: string;
7
+ /** Bounded timeout in milliseconds; defaults to `GH_TOKEN_TIMEOUT_MS` (10 seconds). */
8
+ readonly timeoutMs?: number;
9
+ /** Process environment for `gh`; defaults to `process.env`. */
10
+ readonly env?: Readonly<Record<string, string | undefined>>;
11
+ }
12
+ /** Live gateway reading a GitHub token from `gh auth token --hostname <host>`. */
13
+ export declare function liveGhTokenGateway(options?: LiveGhTokenGatewayOptions): GhTokenGateway;
@@ -0,0 +1,51 @@
1
+ // Live `GhTokenGateway`: invokes `gh auth token --hostname <host>` on the launch machine with a bounded timeout and
2
+ // classifies failures without ever echoing stdout or raw stderr containing tokens.
3
+ import { execFile } from "node:child_process";
4
+ import { classifyGhTokenError, stripSingleTrailingLineBreak } from "./gh-output.js";
5
+ /** Default time limit for `gh auth token --hostname <host>`. */
6
+ export const GH_TOKEN_TIMEOUT_MS = 10_000;
7
+ const GH_MAX_BUFFER = 64 * 1024;
8
+ /** Live gateway reading a GitHub token from `gh auth token --hostname <host>`. */
9
+ export function liveGhTokenGateway(options = {}) {
10
+ const command = options.command ?? "gh";
11
+ const timeoutMs = options.timeoutMs ?? GH_TOKEN_TIMEOUT_MS;
12
+ const env = options.env;
13
+ return {
14
+ readToken: ({ host }) => new Promise((resolve) => {
15
+ execFile(command, ["auth", "token", "--hostname", host], {
16
+ encoding: "utf8",
17
+ timeout: timeoutMs,
18
+ maxBuffer: GH_MAX_BUFFER,
19
+ ...(env === undefined ? {} : { env: { ...env } }),
20
+ }, (error, stdout, stderr) => {
21
+ if (error === null) {
22
+ const token = stripSingleTrailingLineBreak(stdout);
23
+ if (token.length === 0) {
24
+ resolve({
25
+ ok: false,
26
+ failure: {
27
+ kind: "not-authenticated",
28
+ host,
29
+ message: `gh is not authenticated for ${host}`,
30
+ },
31
+ });
32
+ return;
33
+ }
34
+ resolve({ ok: true, token });
35
+ return;
36
+ }
37
+ const err = error;
38
+ resolve({
39
+ ok: false,
40
+ failure: classifyGhTokenError({
41
+ host,
42
+ code: err.code,
43
+ killed: err.killed === true,
44
+ stderr: typeof stderr === "string" ? stderr : "",
45
+ timeoutMs,
46
+ }),
47
+ });
48
+ });
49
+ }),
50
+ };
51
+ }