@cnc-tools/storm 0.10.0 → 0.11.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 (198) hide show
  1. package/dist/bin/storm.js +17 -9
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-YF3ICDBY.js → chunk-3ZZVZPMG.js} +1 -1
  4. package/dist/chunks/{chunk-JQ2HK4RN.js → chunk-4EU4AH7E.js} +141 -6
  5. package/dist/chunks/{chunk-ZJ2USLAT.js → chunk-4PRAB24Y.js} +2 -22
  6. package/dist/chunks/chunk-AMTYHUYB.js +257 -0
  7. package/dist/chunks/{chunk-WF4KJ7YG.js → chunk-ETCZ6WP7.js} +1 -1
  8. package/dist/chunks/chunk-FVMQKYTT.js +10 -0
  9. package/dist/chunks/{chunk-XHJGHJBW.js → chunk-GRMD7G4J.js} +33 -275
  10. package/dist/chunks/chunk-ICB4BZJX.js +22 -0
  11. package/dist/chunks/{chunk-AGWW3HDT.js → chunk-KR7WIYLG.js} +1826 -2201
  12. package/dist/chunks/{chunk-OVXD7GES.js → chunk-L4ZPMSKQ.js} +4 -37
  13. package/dist/chunks/chunk-NPPJ57W7.js +569 -0
  14. package/dist/chunks/{chunk-VJQLMGOH.js → chunk-O4BUT7BE.js} +361 -1716
  15. package/dist/chunks/chunk-OJOKQRM6.js +1457 -0
  16. package/dist/chunks/chunk-SLNKW4ZM.js +40 -0
  17. package/dist/chunks/{chunk-AKKNF3WZ.js → chunk-TRFEAYNC.js} +277 -348
  18. package/dist/chunks/chunk-VZZTHCBW.js +93 -0
  19. package/dist/chunks/chunk-WNIQA5J6.js +19 -0
  20. package/dist/chunks/chunk-WSIF7SR6.js +10 -0
  21. package/dist/chunks/{live-app-RIJM3QFD.js → live-app-LOGYUBKB.js} +52 -7
  22. package/dist/commands/exec/cleanup.d.ts +3 -3
  23. package/dist/commands/exec/cleanup.js +6 -2
  24. package/dist/commands/exec/command.d.ts +3 -3
  25. package/dist/commands/exec/command.js +17 -10
  26. package/dist/commands/exec/job-summary.d.ts +1 -1
  27. package/dist/commands/exec/job-summary.js +1 -1
  28. package/dist/commands/exec/live-view.js +5 -5
  29. package/dist/commands/exec/mint-failed.js +1 -1
  30. package/dist/commands/exec/outcomes.d.ts +2 -2
  31. package/dist/commands/exec/outcomes.js +7 -8
  32. package/dist/commands/exec/plan-run.d.ts +3 -5
  33. package/dist/commands/exec/progress.d.ts +3 -3
  34. package/dist/commands/exec/progress.js +6 -6
  35. package/dist/commands/exec/resource-refusals.d.ts +1 -1
  36. package/dist/commands/exec/resource-refusals.js +1 -1
  37. package/dist/commands/exec/run-command.d.ts +14 -9
  38. package/dist/commands/exec/run-command.js +91 -202
  39. package/dist/commands/exec/run-metadata.d.ts +2 -2
  40. package/dist/commands/exec/run-metadata.js +3 -3
  41. package/dist/commands/exec/test-plan.d.ts +1 -35
  42. package/dist/commands/exec/test-plan.js +4 -24
  43. package/dist/commands/exec/view.js +3 -3
  44. package/dist/commands/exec/waterfall.d.ts +3 -1
  45. package/dist/commands/exec/waterfall.js +18 -1
  46. package/dist/commands/runs/facts.d.ts +2 -1
  47. package/dist/commands/runs/facts.js +1 -1
  48. package/dist/commands/runs/list/command.js +10 -9
  49. package/dist/commands/runs/logs/command.js +14 -12
  50. package/dist/commands/runs/past-run.d.ts +3 -27
  51. package/dist/commands/runs/past-run.js +3 -37
  52. package/dist/commands/runs/show/command.js +24 -21
  53. package/dist/commands/runs/show/outcomes.js +2 -2
  54. package/dist/commands/vitest/command.d.ts +3 -3
  55. package/dist/commands/vitest/command.js +24 -17
  56. package/dist/commands/vitest/outcomes.d.ts +1 -1
  57. package/dist/commands/vitest/outcomes.js +1 -1
  58. package/dist/config/credential-resolver.d.ts +6 -3
  59. package/dist/config/credential-resolver.js +6 -5
  60. package/dist/context.d.ts +27 -9
  61. package/dist/context.js +19 -8
  62. package/dist/core/before-run.d.ts +5 -4
  63. package/dist/core/before-run.js +6 -6
  64. package/dist/core/definition-lookup.d.ts +22 -0
  65. package/dist/core/definition-lookup.js +34 -0
  66. package/dist/core/events.d.ts +5 -19
  67. package/dist/core/gateways.d.ts +22 -162
  68. package/dist/core/index.d.ts +10 -11
  69. package/dist/core/index.js +9 -11
  70. package/dist/core/launcher-supplies.js +2 -2
  71. package/dist/core/live/terminal-command-gateway.d.ts +8 -0
  72. package/dist/core/live/terminal-command-gateway.js +49 -0
  73. package/dist/core/presentations.d.ts +4 -3
  74. package/dist/core/presentations.js +4 -5
  75. package/dist/core/resource-registry.d.ts +35 -51
  76. package/dist/core/resource-registry.js +27 -54
  77. package/dist/core/resource-reports.d.ts +37 -4
  78. package/dist/core/resource-reports.js +34 -5
  79. package/dist/core/resources.d.ts +4 -3
  80. package/dist/core/resources.js +2 -4
  81. package/dist/core/run-state.d.ts +1 -1
  82. package/dist/core/run-state.js +1 -1
  83. package/dist/core/run.d.ts +19 -37
  84. package/dist/core/run.js +59 -114
  85. package/dist/core/timeline.js +2 -1
  86. package/dist/credential/events.d.ts +20 -0
  87. package/dist/credential/events.js +4 -0
  88. package/dist/credential/index.d.ts +2 -1
  89. package/dist/credential/index.js +6 -5
  90. package/dist/credential/source.d.ts +38 -26
  91. package/dist/credential/source.js +25 -34
  92. package/dist/extension-commands.d.ts +12 -6
  93. package/dist/extension-commands.js +18 -11
  94. package/dist/extensions/story/command-tree.d.ts +6 -0
  95. package/dist/extensions/story/command-tree.js +21 -0
  96. package/dist/extensions/story/commands/app.d.ts +23 -0
  97. package/dist/extensions/story/commands/app.js +5 -0
  98. package/dist/extensions/story/commands/run/command.d.ts +211 -0
  99. package/dist/extensions/story/commands/run/command.js +259 -0
  100. package/dist/extensions/story/commands/run/metadata.d.ts +4 -0
  101. package/dist/extensions/story/commands/run/metadata.js +8 -0
  102. package/dist/extensions/story/commands/run/outcomes.d.ts +101 -0
  103. package/dist/extensions/story/commands/run/outcomes.js +73 -0
  104. package/dist/extensions/story/commands/tree.d.ts +2 -0
  105. package/dist/extensions/story/commands/tree.js +6 -0
  106. package/dist/extensions/story/extension.d.ts +2 -0
  107. package/dist/extensions/story/extension.js +8 -0
  108. package/dist/extensions/testserver/command-tree.d.ts +1 -1
  109. package/dist/extensions/testserver/command-tree.js +0 -1
  110. package/dist/extensions/testserver/commands/pool/create/command.js +14 -8
  111. package/dist/extensions/testserver/commands/pool/list/command.js +8 -4
  112. package/dist/extensions/testserver/vitest/config.d.ts +7 -5
  113. package/dist/extensions/testserver/vitest/config.js +7 -5
  114. package/dist/extensions/testserver/vitest/fixtures.d.ts +2 -0
  115. package/dist/extensions/testserver/vitest/fixtures.js +36 -5
  116. package/dist/extensions.d.ts +12 -21
  117. package/dist/extensions.js +22 -34
  118. package/dist/forward-sigterm.d.ts +8 -0
  119. package/dist/forward-sigterm.js +18 -0
  120. package/dist/launcher-resolvers/index.d.ts +1 -0
  121. package/dist/launcher-resolvers/index.js +2 -1
  122. package/dist/launcher-resolvers/local-services.d.ts +57 -0
  123. package/dist/launcher-resolvers/local-services.js +7 -0
  124. package/dist/live-app.js +2 -1
  125. package/dist/local-services.d.ts +19 -0
  126. package/dist/local-services.js +37 -0
  127. package/dist/run-directory/gateways.d.ts +167 -0
  128. package/dist/run-directory/gateways.js +2 -0
  129. package/dist/run-directory/index.d.ts +8 -0
  130. package/dist/run-directory/index.js +13 -0
  131. package/dist/run-directory/plan.d.ts +35 -0
  132. package/dist/run-directory/plan.js +24 -0
  133. package/dist/run-directory/reader.d.ts +70 -0
  134. package/dist/run-directory/reader.js +51 -0
  135. package/dist/run-directory/recording.d.ts +92 -0
  136. package/dist/run-directory/recording.js +85 -0
  137. package/dist/{commands/exec → run-directory}/run-collector.d.ts +9 -8
  138. package/dist/{commands/exec → run-directory}/run-collector.js +8 -10
  139. package/dist/{core → run-directory}/run-directory.d.ts +3 -3
  140. package/dist/{core → run-directory}/run-directory.js +2 -2
  141. package/dist/{commands/exec → run-directory}/run-record.d.ts +29 -7
  142. package/dist/{commands/exec → run-directory}/run-record.js +79 -5
  143. package/dist/{commands/exec → run-directory}/timeline-facts.d.ts +4 -8
  144. package/dist/{commands/exec → run-directory}/timeline-facts.js +8 -24
  145. package/dist/runner/events.d.ts +6 -5
  146. package/dist/runner/index.d.ts +13 -17
  147. package/dist/runner/index.js +10 -14
  148. package/dist/runner/prepare.d.ts +28 -6
  149. package/dist/runner/prepare.js +15 -9
  150. package/dist/runner/recipe.d.ts +14 -0
  151. package/dist/runner/recipe.js +12 -0
  152. package/dist/runner/scope.d.ts +18 -11
  153. package/dist/runner/scope.js +12 -10
  154. package/dist/runner/session.d.ts +100 -0
  155. package/dist/runner/session.js +109 -0
  156. package/dist/runner/snapshot-save.d.ts +3 -2
  157. package/dist/runner/snapshot-save.js +6 -5
  158. package/dist/sdk/extension/ci.d.ts +2 -0
  159. package/dist/sdk/extension/ci.js +6 -0
  160. package/dist/sdk/extension/commands.d.ts +11 -13
  161. package/dist/sdk/extension/commands.js +5 -5
  162. package/dist/sdk/extension/index.d.ts +1 -0
  163. package/dist/sdk/extension/index.js +1 -0
  164. package/dist/sdk/extension/lifecycle.d.ts +4 -3
  165. package/dist/sdk/extension/progress.js +2 -2
  166. package/dist/sdk/extension/resource.js +1 -1
  167. package/dist/story/align.d.ts +1 -1
  168. package/dist/story/align.js +1 -1
  169. package/dist/story/command-line.d.ts +6 -16
  170. package/dist/story/command-line.js +11 -23
  171. package/dist/story/errors.d.ts +1 -1
  172. package/dist/story/errors.js +1 -1
  173. package/dist/story/host.d.ts +1 -1
  174. package/dist/story/host.js +2 -2
  175. package/dist/story/index.d.ts +2 -2
  176. package/dist/story/index.js +4 -3
  177. package/dist/story/launch.d.ts +70 -0
  178. package/dist/story/launch.js +77 -0
  179. package/dist/story/report.d.ts +2 -2
  180. package/dist/story/report.js +3 -4
  181. package/dist/story/settle.d.ts +7 -7
  182. package/dist/story/settle.js +5 -5
  183. package/dist/story/start.d.ts +2 -2
  184. package/dist/vendor/testserver-sdk/container/container.d.ts +11 -6
  185. package/dist/vendor/testserver-sdk/container/container.js +38 -16
  186. package/dist/vendor/testserver-sdk/testserver/failure.d.ts +4 -3
  187. package/dist/vendor/testserver-sdk/testserver/failure.js +4 -3
  188. package/package.json +1 -1
  189. package/skills/overview.md +3 -0
  190. package/skills/read-run-output.md +2 -2
  191. package/dist/chunks/chunk-H2VCSNVU.js +0 -351
  192. package/dist/chunks/chunk-J6ZNYUDV.js +0 -21
  193. package/dist/core/mint.d.ts +0 -10
  194. package/dist/core/mint.js +0 -14
  195. package/dist/story/mode.d.ts +0 -17
  196. package/dist/story/mode.js +0 -21
  197. /package/dist/{core → run-directory}/live/run-directory-gateway.d.ts +0 -0
  198. /package/dist/{core → run-directory}/live/run-directory-gateway.js +0 -0
package/dist/core/run.js CHANGED
@@ -1,19 +1,22 @@
1
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`); an
3
- // unsandboxed run's request holds none, and its command runs on the launch machine (`runUnsandboxed`). This file is the
4
- // one core module that tells them apart. The rest of the core sees the runner, the runner lane and the runner's events,
5
- // or nothing.
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.
6
9
  import { posix } from "node:path";
7
- import { credentialSourceFor, obtainedSource, } from "../credential/index.js";
8
- import { readyRunner, runnerSandboxScope, SANDBOX_TEST_EVENTS_PATH, keptMs, lineSplitter, runCommandInSandbox, saveBranchSnapshot, } from "../runner/index.js";
10
+ import { credentialSourceFor, } from "../credential/index.js";
11
+ import { lineSplitter, openRunnerSession, SANDBOX_TEST_EVENTS_PATH, } from "../runner/index.js";
9
12
  import { parseTestEvent } from "../sdk/run/launcher.js";
10
- import { mintReported, mintSourceReported } from "./mint.js";
11
13
  import { colorEnvironment, commandEnvironment, runPayload } from "./payload.js";
14
+ import { LOOKUP } from "./resource-registry.js";
12
15
  import { acquireResources, announceAcquired, canceledStop, runInstances, releaseResources, resourceWarnings, releasedResources, resourceInstances, resourcesPayload, resourcesRan, } from "./resources.js";
13
16
  /**
14
- * Runs `request.argv` with the resources it asks for, through `resources`, the registry's resource definitions in
15
- * order. Each resource's `beforeRun` has run already, before the run started: the request holds what it answered. It
16
- * says each resource `beforeRun` skipped right after it starts (`resource-skipped`), acquires the other resource
17
+ * Runs `request.argv` with the resources it asks for, through `registry`'s resource definitions, in registry order.
18
+ * Each resource's `beforeRun` has run already, before the run started: the request holds what it answered. It says
19
+ * each resource `beforeRun` skipped right after it starts (`resource-skipped`), acquires the other resource
17
20
  * instances all at once through their `acquireForRun` (`acquireResources`), says each acquired (`resource-acquired`),
18
21
  * runs the command with the run payload in `STORM_RUN`, waits for it, and hands each instance what its acquire took to
19
22
  * its `releaseAfterRun`. It reports each step to `progress`. What acquiring and releasing do is each resource
@@ -23,13 +26,14 @@ import { acquireResources, announceAcquired, canceledStop, runInstances, release
23
26
  * In a sandboxed run (`request.runner`), the command runs in a runner sandbox, readied beside the resources (see
24
27
  * `runSandboxed`).
25
28
  *
26
- * Release happens in `finally`, however the run ended, a throw included: once the command has stopped and, in a
27
- * sandboxed run, the runner's sandboxes are closed, each resource instance is released in reverse order, even when the
29
+ * Release happens however the run ended, a throw included: once the command has stopped and, in a sandboxed run, the
30
+ * runner session has closed its sandbox scope, each resource instance is released in reverse order, even when the
28
31
  * `cleanup-started` event can't be reported. A sandboxed run that saves the runner sandbox as a branch snapshot
29
- * releases them while the save runs, since the command is done with them.
32
+ * releases them while the save runs, since the command is done with them. An unsandboxed run releases them in
33
+ * `finally`; a sandboxed run's runner session does, as it finishes or closes.
30
34
  */
31
- export async function executeRun(resources, context, worlds, request, control, progress) {
32
- const instances = resourceInstances(resources, worlds, request.resources);
35
+ export async function executeRun(registry, context, worlds, request, control, progress) {
36
+ const instances = resourceInstances(registry[LOOKUP], worlds, request.resources);
33
37
  await progress.emit({
34
38
  kind: "started",
35
39
  version: request.version,
@@ -73,8 +77,6 @@ export async function executeRun(resources, context, worlds, request, control, p
73
77
  resourceCleanup = await releaseResources(instances, progress);
74
78
  }
75
79
  })());
76
- // What cleanup does with the runner sandbox when no save runs: the plan's keep time, 0 for a save that didn't run.
77
- const unsaved = request.runner === undefined ? null : { kind: "keep", ms: keptMs(request.runner.sandbox) };
78
80
  let ended;
79
81
  let runnerCleanup = null;
80
82
  try {
@@ -84,7 +86,8 @@ export async function executeRun(resources, context, worlds, request, control, p
84
86
  : await runSandboxed(context, request, instances, control, progress, { startCleanup, release }));
85
87
  }
86
88
  finally {
87
- await release(unsaved);
89
+ // A no-op in a sandboxed run: its runner session released the resources once it closed its scope.
90
+ await release(null);
88
91
  }
89
92
  await progress.emit({
90
93
  kind: "cleanup-finished",
@@ -105,13 +108,15 @@ export async function executeRun(resources, context, worlds, request, control, p
105
108
  /**
106
109
  * Everything between the run's start and releasing its resources, in an unsandboxed run: it acquires every resource
107
110
  * instance (`acquireResources`), each keeping what its acquire took, then says each acquired and runs the command once
108
- * all are.
111
+ * all are. The credential source its request names is built once (`credentialSourceFor`), reporting each mint and token
112
+ * request as the run's own event, and handed to every instance; the mint is lazy, so a run mints only when a resource
113
+ * asks for a credential.
109
114
  * The command's stdout and stderr reach `runnerTerminal` a line at a time per stream, and its environment says whether
110
115
  * to color them (`colorEnvironment`), since the command writes to pipes.
111
116
  */
112
117
  async function runUnsandboxed(context, request, instances, control, progress) {
113
118
  const acquisition = await acquireResources(instances, {
114
- credential: request.credential === undefined ? undefined : unsandboxedSource(context, request.credential, progress),
119
+ credential: request.credential === undefined ? undefined : credentialSourceFor(request.credential, context, progress),
115
120
  signal: control.signal,
116
121
  progress,
117
122
  });
@@ -158,19 +163,6 @@ async function runUnsandboxed(context, request, instances, control, progress) {
158
163
  });
159
164
  return { kind: "command-ended", resources: resourcesRan(instances), command, runner: undefined };
160
165
  }
161
- /**
162
- * An unsandboxed run's credential source, which `choice` names: the mint reports its start and end, and a GitHub
163
- * Actions OIDC token request each request's start. The mint is lazy, so a run mints only when a resource asks for a
164
- * credential.
165
- */
166
- function unsandboxedSource(context, choice, progress) {
167
- if (choice.source === "mint")
168
- return mintSourceReported(context, choice.target, progress);
169
- return credentialSourceFor(choice, context, {
170
- onMint: (target) => progress.emit({ kind: "minting", target }),
171
- onRequest: () => progress.emit({ kind: "requesting-token" }),
172
- });
173
- }
174
166
  /** How the runner lane ended, by how readying did: stopped when aborted, failed when it failed or its snapshot was gone. */
175
167
  function runnerLaneOutcome(outcome) {
176
168
  if (outcome.kind === "ready")
@@ -186,99 +178,56 @@ function runnerStopped(outcome) {
186
178
  return undefined;
187
179
  }
188
180
  /**
189
- * In a sandboxed run, everything between the run's start and releasing its resources, and the one owner of the runner's
190
- * sandbox scope. It opens the scope before the mint, runs `runInSandbox` in it, and closes it before it returns, so the
191
- * runner's sandboxes are stopped and deleted before the resources are released, and every outcome carries the close's
192
- * report. The first signal says at once that the run is stopping, then starts closing the scope, so its waits for a
193
- * create in flight and a snapshot still saving run while readying winds down; the close the run awaits later gets that
194
- * close's report, or its error. A sandboxed run always mints, whatever its resources are, so its request names no
195
- * credential source: the command layer refuses `--credential github-actions` with it.
196
- *
197
- * The run's plan (`request.runner.sandbox`) gives the scope its keep time, which is 0 for a `save` plan: such a run
198
- * never keeps its runner sandbox, however it ends. Under a `save` plan, once the command ended on its own and no signal
199
- * arrived, it saves the runner sandbox as a branch snapshot (`saveBranchSnapshot`) while the resources are released,
200
- * and closes the scope once the save is done, even when releasing them threw.
181
+ * In a sandboxed run, everything between the run's start and releasing its resources. It opens the run's runner session
182
+ * (`openRunnerSession`) before the mint, which owns the runner's sandbox scope and the order its stages run in, runs
183
+ * `runInSandbox` in it, and finishes the session, which closes the scope and releases the resources, saving the runner
184
+ * sandbox as a branch snapshot beside the release when the run's plan says to. A run that throws closes the session in
185
+ * `finally`, which closes the scope, then releases the resources. A sandboxed run always mints, whatever its resources
186
+ * are, so its request names no credential source: the command layer refuses `--credential github-actions` with it.
201
187
  */
202
188
  async function runSandboxed(context, request, instances, control, progress, cleanup) {
203
189
  const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
204
- const plan = request.runner.sandbox;
205
- const keepMs = keptMs(plan);
206
- const scope = runnerSandboxScope(context, runnerProgress, { keepMs });
207
- let commandRunning = false;
208
- // Said before the close starts, so the stopping line comes before any line the close's waits print.
209
- const stop = () => {
210
- void progress.emit({ kind: "runner", event: { kind: "stopping", commandRunning, keepMs } }).catch(() => undefined);
211
- void scope.close().catch(() => undefined);
212
- };
213
- if (control.signal.aborted)
214
- stop();
215
- else
216
- control.signal.addEventListener("abort", stop, { once: true });
190
+ const session = openRunnerSession(context, request.runner, { signal: control.signal, cleanup }, runnerProgress);
217
191
  try {
218
- const ended = await runInSandbox(context, request, instances, {
219
- ...control,
220
- scope,
221
- commandStarted: () => {
222
- commandRunning = true;
223
- },
224
- }, progress, runnerProgress);
225
- commandRunning = false;
226
- const unsaved = { kind: "keep", ms: keepMs };
227
- if (ended.kind !== "command-ended") {
228
- await cleanup.startCleanup(unsaved);
229
- return { ended, runnerCleanup: { ...(await scope.close()), target: request.runner.target } };
230
- }
231
- const { ready, ...rest } = ended;
232
- const { prepared } = request.runner;
233
- let save = prepared.save?.kind === "skipped" ? prepared.save : null;
234
- const action = plan.kind === "save" && !control.signal.aborted ? plan : unsaved;
235
- if (action.kind === "save") {
236
- const saving = saveBranchSnapshot(context, { ready, branch: action.branch, head: prepared.head.commit }, { scope, signal: control.signal }, runnerProgress);
237
- // The save settles before the scope closes, even when releasing the resources threw.
238
- try {
239
- await cleanup.release(action);
240
- }
241
- finally {
242
- save = await saving;
243
- }
244
- }
245
- await cleanup.startCleanup(action);
246
- const runnerCleanup = { ...(await scope.close()), target: request.runner.target };
247
- return { ended: { ...rest, runner: { ...rest.runner, save } }, runnerCleanup };
192
+ const ended = await runInSandbox(context, request, instances, session, control, progress);
193
+ const finished = await session.finish();
194
+ return {
195
+ ended: ended.kind === "command-ended" ? { ...ended, runner: { ...ended.runner, save: finished.save } } : ended,
196
+ runnerCleanup: finished.cleanup,
197
+ };
248
198
  }
249
199
  finally {
250
- control.signal.removeEventListener("abort", stop);
251
- // Memoized: a no-op once the run closed it, and the cleanup when the run threw.
252
- await scope.close();
200
+ // Memoized: a no-op once the session finished, and the cleanup when the run threw.
201
+ await session.close();
253
202
  }
254
203
  }
255
204
  /**
256
- * The body of `runSandboxed`, in its sandbox scope. It mints first, whatever the resources are, since the
257
- * runner sandbox needs the run's credential; resources that create share that one mint, through a mint source that
258
- * hands out its outcome. Then it acquires the resources and readies the runner sandbox at once (`readyBoth`), and runs
259
- * the command in the runner sandbox once all are ready, saying each resource acquired and calling `commandStarted` as
260
- * it starts. Each instance keeps what its acquire took.
205
+ * The body of `runSandboxed`, in its runner session. It mints first, whatever the resources are, since the
206
+ * runner sandbox needs the run's credential: it builds the mint's source (`credentialSourceFor`) and obtains from it
207
+ * once, and hands the same source to the resources, so one that asks for a credential gets the one mint's outcome and
208
+ * the run reports no other mint. Then it acquires the resources and readies the runner sandbox at once (`readyBoth`),
209
+ * and runs the command in the runner sandbox once all are ready, saying each resource acquired first.
261
210
  */
262
- async function runInSandbox(context, request, instances, control, progress, runnerProgress) {
211
+ async function runInSandbox(context, request, instances, session, control, progress) {
263
212
  const { runner } = request;
264
213
  // Canceled before a command started in the runner sandbox.
265
214
  const canceled = () => ({ ...canceledStop(), commandStopped: false });
266
215
  if (control.signal.aborted)
267
216
  return canceled();
268
- const minted = await mintReported(context, runner.target, progress);
217
+ const mint = credentialSourceFor({ source: "mint", target: runner.target }, context, progress);
218
+ const minted = await mint.obtain();
269
219
  if (!minted.ok)
270
- return { kind: "mint-failed", failure: minted.failure, target: runner.target, runner: true };
220
+ return { kind: "mint-failed", failure: minted.failure.failure, target: runner.target, runner: true };
271
221
  const project = minted.credential.vercelProject();
272
222
  if (project === undefined)
273
223
  return { kind: "runner-failed", failure: { kind: "credential-claims-missing", target: runner.target } };
274
224
  if (control.signal.aborted)
275
225
  return canceled();
276
- const acquisition = await readyBoth(context, {
277
- request,
226
+ const acquisition = await readyBoth({
278
227
  instances,
279
- credential: obtainedSource(runner.target, minted.credential),
280
- access: { credential: minted.credential, ...project },
281
- }, control, progress, runnerProgress);
228
+ credential: mint,
229
+ ready: (signal) => session.ready({ credential: minted.credential, ...project }, signal),
230
+ }, control, progress);
282
231
  if (acquisition.kind === "stopped") {
283
232
  const { outcome } = acquisition;
284
233
  return outcome.kind === "canceled" ? { ...outcome, commandStopped: false } : outcome;
@@ -292,11 +241,9 @@ async function runInSandbox(context, request, instances, control, progress, runn
292
241
  await progress.emit({ kind: "command-started", argv: request.argv });
293
242
  if (control.signal.aborted)
294
243
  return canceled();
295
- control.commandStarted();
296
244
  // Test events arrive from a callback that can't wait, so they are emitted in order through a chain.
297
245
  let testEvents = Promise.resolve();
298
- const sandboxed = await runCommandInSandbox(context, {
299
- runner: ready,
246
+ const sandboxed = await session.runCommand({
300
247
  argv: request.argv,
301
248
  runPayload: JSON.stringify(runPayload(resourcesPayload(instances), {
302
249
  testEvents: SANDBOX_TEST_EVENTS_PATH,
@@ -311,7 +258,7 @@ async function runInSandbox(context, request, instances, control, progress, runn
311
258
  testEvents = testEvents.then(() => progress.emit({ kind: "test-events-incomplete", message }));
312
259
  },
313
260
  },
314
- }, { kill: control.signal }, runnerProgress);
261
+ });
315
262
  await testEvents;
316
263
  // Closing on a signal can stop the runner sandbox under the command, so a failed call then is the stop too.
317
264
  if (sandboxed.kind === "killed" || (sandboxed.kind === "failed" && control.signal.aborted))
@@ -341,16 +288,14 @@ async function runInSandbox(context, request, instances, control, progress, runn
341
288
  buildMs: ready.buildMs,
342
289
  save: null,
343
290
  },
344
- ready,
345
291
  };
346
292
  }
347
293
  /**
348
294
  * Acquires the resources and readies the runner sandbox at once, through `acquireResources` with the runner lane
349
- * beside the resources: a resource's refusal or throw stops readying the runner, and the runner's failure stops
350
- * acquiring the resources. Without any resource, the runner lane runs alone.
295
+ * beside the resources (`ready`, the runner session's): a resource's refusal or throw stops readying the runner, and
296
+ * the runner's failure stops acquiring the resources. Without any resource, the runner lane runs alone.
351
297
  */
352
- async function readyBoth(context, request, control, progress, runnerProgress) {
353
- const { runner } = request.request;
298
+ async function readyBoth(request, control, progress) {
354
299
  await progress.emit({ kind: "lanes-started" });
355
300
  return await acquireResources(request.instances, {
356
301
  credential: request.credential,
@@ -358,7 +303,7 @@ async function readyBoth(context, request, control, progress, runnerProgress) {
358
303
  progress,
359
304
  beside: {
360
305
  lane: { lane: "runner", resource: null },
361
- start: (signal) => readyRunner(context, { prepared: runner.prepared, access: request.access, user: runner.user, secrets: runner.secrets }, { scope: control.scope, signal }, runnerProgress),
306
+ start: request.ready,
362
307
  outcomeOf: runnerLaneOutcome,
363
308
  stopped: runnerStopped,
364
309
  },
@@ -1,6 +1,7 @@
1
1
  // A run's waterfall, projected from its final state: when each lane ran, what it did, how long a ready lane waited
2
2
  // for the last one, and the critical path to the command's end. Each resource's progress projects its own lane's row's
3
- // steps and counts (`ResourceProgress.row`); the core lays out every row.
3
+ // steps and counts (`ResourceProgress.row`); the core lays out every row. Callers project it through the registry
4
+ // (`timeline`, `resource-registry.ts`).
4
5
  /**
5
6
  * A run's waterfall, from its final state, with each resource lane's row from the progress of `resources`, the
6
7
  * registry's resource definitions. A span still running when the run ended is `unfinished`, ending at the run's last
@@ -0,0 +1,20 @@
1
+ import type { MintTarget } from "../sdk/extension/index.ts";
2
+ /**
3
+ * A credential source's events: `minting` before its one mint, for `target`; `minted` after it, with whether it gave a
4
+ * credential (`ok`); and `requesting-token` before each GitHub Actions OIDC token request, a refresh included, but not
5
+ * before a retry.
6
+ */
7
+ export type CredentialEvent = {
8
+ readonly kind: "minting";
9
+ readonly target: MintTarget;
10
+ } | {
11
+ readonly kind: "minted";
12
+ readonly target: MintTarget;
13
+ readonly ok: boolean;
14
+ } | {
15
+ readonly kind: "requesting-token";
16
+ };
17
+ /** Hears a credential source's events. */
18
+ export interface CredentialProgress {
19
+ emit(event: CredentialEvent): Promise<void>;
20
+ }
@@ -0,0 +1,4 @@
1
+ // What a credential source reports as it goes: before and after its mint, and before each GitHub Actions OIDC token
2
+ // request. A run emits them as its own events (`RunEvent` in `core/events.ts` holds them in its union), and the
3
+ // credential launcher resolver turns them into its progress lines (`config/credential-resolver.ts`).
4
+ export {};
@@ -2,5 +2,6 @@ export { Credential, type CredentialDiagnosis, type CredentialFailure, type Cred
2
2
  export type { CredentialGateway, GitHubActionsTokenGateway, MintOutcome, TokenAttemptOutcome } 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 { type CredentialSourceChoice, credentialSourceFor, githubActionsSource, mintSource, obtainedSource, REQUESTING_TOKEN_LINE, } from "./source.ts";
5
+ export type { CredentialEvent, CredentialProgress } from "./events.ts";
6
+ export { type CredentialContext, type CredentialSourceChoice, credentialSourceFor, type MintSource, REQUESTING_TOKEN_LINE, } from "./source.ts";
6
7
  export { mintTargetText } from "./target.ts";
@@ -1,10 +1,11 @@
1
- // The `credential` module's public surface. Other modules import only from here. It implements the credential sources
2
- // over its gateways; the extension API (`src/sdk/extension/`) declares the credential, the sources' shape, their
3
- // failures and how those are worded, which this surface re-exports for the launcher. It loads no Clinkr, at run time or
4
- // in its declarations: the credential launcher resolver and the errors a command refuses with live in `config`
1
+ // The `credential` module's public surface. Other modules import only from here. It builds every credential source with
2
+ // one factory (`credentialSourceFor`), over its gateways, which reports each mint and token request as a credential
3
+ // event (`CredentialEvent`); the extension API (`src/sdk/extension/`) declares the credential, the sources' shape,
4
+ // their failures and how those are worded, which this surface re-exports for the launcher. It loads no Clinkr, at run
5
+ // time or in its declarations: the credential launcher resolver and the errors a command refuses with live in `config`
5
6
  // (`credential-resolver.ts`, `credential-settle.ts`).
6
7
  export { Credential, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, tokenRequestFailureFacts, tokenRequestFailureShape, } from "../sdk/extension/index.js";
7
8
  export { liveGitHubActionsTokenGateway } from "./live/github-actions-token-gateway.js";
8
9
  export { liveCredentialGateway } from "./live/vercel-cli-gateway.js";
9
- export { credentialSourceFor, githubActionsSource, mintSource, obtainedSource, REQUESTING_TOKEN_LINE, } from "./source.js";
10
+ export { credentialSourceFor, REQUESTING_TOKEN_LINE, } from "./source.js";
10
11
  export { mintTargetText } from "./target.js";
@@ -1,4 +1,5 @@
1
- import type { Credential, CredentialSource, MintTarget } from "../sdk/extension/index.ts";
1
+ import type { Credential, CredentialSource, MintFailed, MintTarget } from "../sdk/extension/index.ts";
2
+ import type { CredentialProgress } from "./events.ts";
2
3
  import type { CredentialGateway, GitHubActionsTokenGateway, MintOutcome } from "./gateways.ts";
3
4
  /** The progress line a GitHub Actions OIDC token request prints as it starts. */
4
5
  export declare const REQUESTING_TOKEN_LINE = "Requesting a GitHub Actions OIDC token\u2026";
@@ -12,21 +13,6 @@ export type CredentialSourceChoice = {
12
13
  } | {
13
14
  readonly source: "github-actions";
14
15
  };
15
- /**
16
- * The mint as a credential source: it mints at most once. The first `obtain()` calls `mint`; every later call,
17
- * concurrent ones included, returns the same outcome. A failed mint is kept like a successful one and never retried
18
- * within the run. A minted credential lasts 12 hours, longer than any run.
19
- *
20
- * `mint` must not reject (`CredentialGateway.mint` never does). If it does anyway, `obtain()` still never throws: it
21
- * returns the rejected promise, and keeps returning it.
22
- */
23
- export declare function mintSource(target: MintTarget, mint: () => Promise<MintOutcome>): CredentialSource;
24
- /**
25
- * A credential the run already holds, as a credential source: `obtain()` hands it back and does nothing else. The
26
- * run mints `credential` for `target` and its runner sandbox before it acquires its resources, and shares it with them
27
- * through this.
28
- */
29
- export declare function obtainedSource(target: MintTarget, credential: Credential): CredentialSource;
30
16
  /** A clock as a credential source reads it; structural so this module needs no other module's time seams. */
31
17
  interface SourceClock {
32
18
  now(): Date;
@@ -36,23 +22,49 @@ interface SourceTimer {
36
22
  sleep(ms: number, signal?: AbortSignal): Promise<void>;
37
23
  }
38
24
  /**
39
- * The credential source `choice` names, over `context`'s gateways: the mint calls `report.onMint` before it mints,
40
- * and a GitHub Actions OIDC token request calls `report.onRequest` before each request.
25
+ * What a credential source reaches the world through: the mint, GitHub Actions' OIDC token issuer, the clock a token's
26
+ * age is read from and the timer a token request's retries wait on.
41
27
  */
42
- export declare function credentialSourceFor(choice: CredentialSourceChoice, context: {
28
+ export interface CredentialContext {
43
29
  readonly credentials: CredentialGateway;
44
30
  readonly githubActionsTokens: GitHubActionsTokenGateway;
45
31
  readonly clock: SourceClock;
46
32
  readonly timer: SourceTimer;
47
- }, report: {
48
- readonly onMint: (target: MintTarget) => Promise<void>;
49
- readonly onRequest: () => Promise<void>;
50
- }): CredentialSource;
33
+ }
34
+ /** The mint as a credential source: what it fails with is always the mint's failure, with its target. */
35
+ export interface MintSource extends CredentialSource {
36
+ obtain(): Promise<{
37
+ readonly ok: true;
38
+ readonly credential: Credential;
39
+ } | {
40
+ readonly ok: false;
41
+ readonly failure: MintFailed;
42
+ }>;
43
+ }
44
+ /**
45
+ * The credential source `choice` names, over `context`, reporting to `progress`: the mint emits `minting` before its
46
+ * one mint and `minted` after it, and a GitHub Actions OIDC token request emits `requesting-token` before each
47
+ * request, refreshes included, not before each retry. Nothing happens until the first `obtain()`. The mint's source
48
+ * mints once and hands every later `obtain()` the same outcome, emitting nothing more.
49
+ */
50
+ export declare function credentialSourceFor(choice: Extract<CredentialSourceChoice, {
51
+ readonly source: "mint";
52
+ }>, context: CredentialContext, progress: CredentialProgress): MintSource;
53
+ export declare function credentialSourceFor(choice: CredentialSourceChoice, context: CredentialContext, progress: CredentialProgress): CredentialSource;
54
+ /**
55
+ * The mint as a credential source: it mints at most once. The first `obtain()` calls `mint`; every later call,
56
+ * concurrent ones included, returns the same outcome. A failed mint is kept like a successful one and never retried
57
+ * within the run. A minted credential lasts 12 hours, longer than any run.
58
+ *
59
+ * `mint` must not reject (`CredentialGateway.mint` never does). If it does anyway, `obtain()` still never throws: it
60
+ * returns the rejected promise, and keeps returning it.
61
+ */
62
+ export declare function mintSource(target: MintTarget, mint: () => Promise<MintOutcome>): MintSource;
51
63
  /**
52
64
  * A GitHub Actions OIDC token request as a credential source. The first `obtain()` requests a token; later ones hand
53
65
  * back the same token while it is under 4 minutes old, counting from when its request was sent, and request a new
54
- * one after. Concurrent `obtain()` calls share one request in flight. `onRequest` is called before each request,
55
- * refreshes included, not before each retry.
66
+ * one after. Concurrent `obtain()` calls share one request in flight. It emits `requesting-token` to `progress` before
67
+ * each request, refreshes included, not before each retry.
56
68
  *
57
69
  * One request makes up to 3 attempts, retrying only a network failure, a timeout or HTTP 502, 503 or 504, after
58
70
  * waiting 1s, then 2s, on `timer`. A failure isn't kept: the next `obtain()` requests again. A failed refresh is a
@@ -62,6 +74,6 @@ export declare function githubActionsSource(context: {
62
74
  readonly gateway: GitHubActionsTokenGateway;
63
75
  readonly clock: SourceClock;
64
76
  readonly timer: SourceTimer;
65
- readonly onRequest?: () => Promise<void>;
77
+ readonly progress: CredentialProgress;
66
78
  }): CredentialSource;
67
79
  export {};
@@ -1,5 +1,24 @@
1
+ // The credential sources, built by one factory (`credentialSourceFor`) from the credential choice, over the
2
+ // credential gateways, a clock and a timer, reporting each mint and token request to a `CredentialProgress`. The mint
3
+ // source and the GitHub Actions source it builds are exported for this module's own tests only.
1
4
  /** The progress line a GitHub Actions OIDC token request prints as it starts. */
2
5
  export const REQUESTING_TOKEN_LINE = "Requesting a GitHub Actions OIDC token…";
6
+ export function credentialSourceFor(choice, context, progress) {
7
+ if (choice.source === "github-actions")
8
+ return githubActionsSource({
9
+ gateway: context.githubActionsTokens,
10
+ clock: context.clock,
11
+ timer: context.timer,
12
+ progress,
13
+ });
14
+ const { target } = choice;
15
+ return mintSource(target, async () => {
16
+ await progress.emit({ kind: "minting", target });
17
+ const minted = await context.credentials.mint(target);
18
+ await progress.emit({ kind: "minted", target, ok: minted.ok });
19
+ return minted;
20
+ });
21
+ }
3
22
  /**
4
23
  * The mint as a credential source: it mints at most once. The first `obtain()` calls `mint`; every later call,
5
24
  * concurrent ones included, returns the same outcome. A failed mint is kept like a successful one and never retried
@@ -15,7 +34,9 @@ export function mintSource(target, mint) {
15
34
  // The async wrapper turns a synchronous throw from `mint` into a rejection.
16
35
  outcome ??= (async () => {
17
36
  const minted = await mint();
18
- return minted.ok ? minted : { ok: false, failure: { source: "mint", failure: minted.failure, target } };
37
+ return minted.ok
38
+ ? minted
39
+ : { ok: false, failure: { source: "mint", failure: minted.failure, target } };
19
40
  })();
20
41
  return outcome;
21
42
  },
@@ -24,36 +45,6 @@ export function mintSource(target, mint) {
24
45
  },
25
46
  };
26
47
  }
27
- /**
28
- * A credential the run already holds, as a credential source: `obtain()` hands it back and does nothing else. The
29
- * run mints `credential` for `target` and its runner sandbox before it acquires its resources, and shares it with them
30
- * through this.
31
- */
32
- export function obtainedSource(target, credential) {
33
- const outcome = Promise.resolve({ ok: true, credential });
34
- return {
35
- obtain: () => outcome,
36
- origin: () => ({ source: "mint", target }),
37
- };
38
- }
39
- /**
40
- * The credential source `choice` names, over `context`'s gateways: the mint calls `report.onMint` before it mints,
41
- * and a GitHub Actions OIDC token request calls `report.onRequest` before each request.
42
- */
43
- export function credentialSourceFor(choice, context, report) {
44
- if (choice.source === "github-actions")
45
- return githubActionsSource({
46
- gateway: context.githubActionsTokens,
47
- clock: context.clock,
48
- timer: context.timer,
49
- onRequest: report.onRequest,
50
- });
51
- const { target } = choice;
52
- return mintSource(target, async () => {
53
- await report.onMint(target);
54
- return await context.credentials.mint(target);
55
- });
56
- }
57
48
  /** How long a GitHub Actions OIDC token is handed out after its request was sent: it expires after 5 minutes. */
58
49
  const TOKEN_REFRESH_MS = 4 * 60_000;
59
50
  /** The waits before each retry of a token request: one request makes one attempt more than there are waits. */
@@ -61,8 +52,8 @@ const RETRY_WAITS_MS = [1_000, 2_000];
61
52
  /**
62
53
  * A GitHub Actions OIDC token request as a credential source. The first `obtain()` requests a token; later ones hand
63
54
  * back the same token while it is under 4 minutes old, counting from when its request was sent, and request a new
64
- * one after. Concurrent `obtain()` calls share one request in flight. `onRequest` is called before each request,
65
- * refreshes included, not before each retry.
55
+ * one after. Concurrent `obtain()` calls share one request in flight. It emits `requesting-token` to `progress` before
56
+ * each request, refreshes included, not before each retry.
66
57
  *
67
58
  * One request makes up to 3 attempts, retrying only a network failure, a timeout or HTTP 502, 503 or 504, after
68
59
  * waiting 1s, then 2s, on `timer`. A failure isn't kept: the next `obtain()` requests again. A failed refresh is a
@@ -72,7 +63,7 @@ export function githubActionsSource(context) {
72
63
  let held;
73
64
  let inFlight;
74
65
  const request = async () => {
75
- await context.onRequest?.();
66
+ await context.progress.emit({ kind: "requesting-token" });
76
67
  for (let attempt = 1;; attempt += 1) {
77
68
  const sentAt = context.clock.now().getTime();
78
69
  const outcome = await context.gateway.request();
@@ -1,14 +1,20 @@
1
1
  import type { Mount } from "@vercel/clinkr";
2
2
  import type { StormApp } from "./context.ts";
3
3
  import type { ExtensionCommands } from "./sdk/extension/commands.ts";
4
+ /** One extension's command tree, and the command path storm mounts it at. */
5
+ export interface ExtensionCommandsEntry {
6
+ readonly commands: ExtensionCommands<StormApp>;
7
+ /** Where the tree's commands sit in `storm`, such as `["ext", "testserver"]`. */
8
+ readonly path: readonly string[];
9
+ }
4
10
  /**
5
- * Every extension's command tree, in extension order, checked against the app Clinkr hands their commands: a tree whose
6
- * commands take something `StormApp` lacks, or holds in another type, fails here.
11
+ * Every extension's command tree, in extension order, with its path, checked against the app Clinkr hands their
12
+ * commands: a tree whose commands take something `StormApp` lacks, or holds in another type, fails here.
7
13
  */
8
- export declare const EXTENSION_COMMANDS: readonly ExtensionCommands<string, StormApp>[];
14
+ export declare const EXTENSION_COMMANDS: readonly ExtensionCommandsEntry[];
9
15
  /**
10
- * Every extension's command tree, mounted at `storm ext <name>` with its directory under `root`, storm's code root
11
- * (`src/` or `dist/`), which `application.ts` mounts beside the launcher's own commands (the `ext` group is
12
- * `commands/ext/`).
16
+ * Every extension's command tree, mounted at its path with its directory under `root`, storm's code root (`src/` or
17
+ * `dist/`), which `application.ts` mounts beside the launcher's own commands (the `ext` group is `commands/ext/`).
18
+ * Clinkr refuses a path that collides with a command of storm's own or another mount.
13
19
  */
14
20
  export declare function extensionMounts(root: string): readonly Mount<StormApp>[];
@@ -1,20 +1,27 @@
1
- // The extensions' own command trees, which `application.ts` mounts under storm's `ext` group. It is the one file
2
- // besides the registry (`src/extensions.ts`) that names an extension, and it imports only each extension's
3
- // `command-tree.ts`, which loads no resource: help lists `ext testserver` without loading the registry, the resources,
4
- // the runner, or the SDK. `.oxlintrc.json` holds this file to `command-tree.ts`;
1
+ // The extensions' own command trees, each with the path `application.ts` mounts it at. It is the one file besides the
2
+ // registry (`src/extensions.ts`) that names an extension, and it imports only each extension's `command-tree.ts`,
3
+ // which loads no resource: help lists `ext testserver` and `story` without loading the registry, the resources, the
4
+ // runner, or the SDK. The registry places each tree, not its extension: a resource tool's tree goes under
5
+ // `ext <name>`, so its commands can't collide with storm's own, and the story extension's run command goes at the top
6
+ // level, as `storm story`, beside `storm vitest`. `.oxlintrc.json` holds this file to `command-tree.ts`;
5
7
  // `test/unit/extension-commands.test.ts` holds its list to the extensions' `commands`. `scripts/bundle.js` reads the
6
8
  // list from tsc's build to bundle each tree's commands.
9
+ import { storyExtensionCommands } from "./extensions/story/command-tree.js";
7
10
  import { testserverExtensionCommands } from "./extensions/testserver/command-tree.js";
8
11
  /**
9
- * Every extension's command tree, in extension order, checked against the app Clinkr hands their commands: a tree whose
10
- * commands take something `StormApp` lacks, or holds in another type, fails here.
12
+ * Every extension's command tree, in extension order, with its path, checked against the app Clinkr hands their
13
+ * commands: a tree whose commands take something `StormApp` lacks, or holds in another type, fails here.
11
14
  */
12
- export const EXTENSION_COMMANDS = [testserverExtensionCommands];
15
+ export const EXTENSION_COMMANDS = [
16
+ { commands: testserverExtensionCommands, path: ["ext", "testserver"] },
17
+ // A run command, beside `storm vitest`, not a resource tool: `storm story run`.
18
+ { commands: storyExtensionCommands, path: ["story"] },
19
+ ];
13
20
  /**
14
- * Every extension's command tree, mounted at `storm ext <name>` with its directory under `root`, storm's code root
15
- * (`src/` or `dist/`), which `application.ts` mounts beside the launcher's own commands (the `ext` group is
16
- * `commands/ext/`).
21
+ * Every extension's command tree, mounted at its path with its directory under `root`, storm's code root (`src/` or
22
+ * `dist/`), which `application.ts` mounts beside the launcher's own commands (the `ext` group is `commands/ext/`).
23
+ * Clinkr refuses a path that collides with a command of storm's own or another mount.
17
24
  */
18
25
  export function extensionMounts(root) {
19
- return EXTENSION_COMMANDS.map(({ extension, mount }) => mount({ path: ["ext", extension], root }));
26
+ return EXTENSION_COMMANDS.map(({ commands, path }) => commands.mount({ path, root }));
20
27
  }
@@ -0,0 +1,6 @@
1
+ import type { StoryCommandApp } from "./commands/app.ts";
2
+ /**
3
+ * The story extension's commands, which take `StoryCommandApp` (`commands/app.ts`), projected from the launcher's app:
4
+ * the vitest and terminal local services, the launcher's environment and directory, and where the exit status goes.
5
+ */
6
+ export declare const storyExtensionCommands: import("../../sdk/extension/commands.ts").ExtensionCommands<StoryCommandApp>;