@cnc-tools/storm 0.8.1 → 0.9.1

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 (108) hide show
  1. package/bin/storm.js +3 -14
  2. package/dist/application.d.ts +18 -10
  3. package/dist/application.js +10 -11
  4. package/dist/bin/storm.js +97 -41
  5. package/dist/build-info.js +1 -1
  6. package/dist/chunks/chunk-5CQCRX2L.js +5768 -0
  7. package/dist/chunks/chunk-5U5Q6VZR.js +556 -0
  8. package/dist/chunks/chunk-7O6UN63H.js +63 -0
  9. package/dist/chunks/chunk-I5GZLOLQ.js +38 -0
  10. package/dist/chunks/chunk-NX55IJ5S.js +1842 -0
  11. package/dist/chunks/chunk-OCZJE5XV.js +910 -0
  12. package/dist/chunks/chunk-RRQ2ZGSE.js +1512 -0
  13. package/dist/chunks/chunk-S5NAIZYS.js +13 -0
  14. package/dist/chunks/chunk-UHO5OCEX.js +360 -0
  15. package/dist/chunks/chunk-WBIHJM7D.js +188 -0
  16. package/dist/chunks/chunk-WV6WQFC6.js +436 -0
  17. package/dist/chunks/live-app-X3PW2W42.js +89 -0
  18. package/dist/chunks/version-X7RMSKZI.js +12 -0
  19. package/dist/commands/exec/command.d.ts +32 -0
  20. package/dist/commands/exec/command.js +35 -21
  21. package/dist/commands/exec/metadata.js +66 -58
  22. package/dist/commands/exec/outcomes.d.ts +67 -0
  23. package/dist/commands/exec/outcomes.js +50 -0
  24. package/dist/commands/exec/redaction.js +1 -1
  25. package/dist/commands/exec/run-collector.d.ts +1 -1
  26. package/dist/commands/exec/run-collector.js +1 -1
  27. package/dist/commands/exec/run-command.d.ts +17 -11
  28. package/dist/commands/exec/run-command.js +33 -16
  29. package/dist/commands/exec/run-record.d.ts +1 -1
  30. package/dist/commands/exec/tests-summary.d.ts +1 -1
  31. package/dist/commands/exec/worker-chart.d.ts +1 -1
  32. package/dist/commands/runs/list/command.js +136 -33
  33. package/dist/commands/runs/list/metadata.js +22 -18
  34. package/dist/commands/runs/logs/command.js +131 -48
  35. package/dist/commands/runs/logs/metadata.js +24 -20
  36. package/dist/commands/runs/metadata.js +6 -2
  37. package/dist/commands/runs/past-run.d.ts +1 -1
  38. package/dist/commands/runs/past-run.js +1 -1
  39. package/dist/commands/runs/show/command.js +396 -74
  40. package/dist/commands/runs/show/metadata.js +24 -20
  41. package/dist/commands/vitest/command.d.ts +32 -0
  42. package/dist/commands/vitest/command.js +195 -128
  43. package/dist/commands/vitest/metadata.js +45 -37
  44. package/dist/commands/vitest/outcomes.d.ts +16 -0
  45. package/dist/context.d.ts +1 -1
  46. package/dist/core/events.d.ts +1 -1
  47. package/dist/core/payload.d.ts +1 -1
  48. package/dist/core/payload.js +1 -1
  49. package/dist/core/provider.d.ts +12 -2
  50. package/dist/core/run.d.ts +6 -1
  51. package/dist/core/run.js +2 -2
  52. package/dist/live-app.d.ts +9 -0
  53. package/dist/live-app.js +21 -0
  54. package/dist/resource-commands.d.ts +13 -0
  55. package/dist/resource-commands.js +22 -0
  56. package/dist/resources/github/provider.d.ts +1 -1
  57. package/dist/resources/testserver/command-tree.d.ts +4 -0
  58. package/dist/resources/testserver/command-tree.js +12 -0
  59. package/dist/resources/testserver/commands/create/command.js +373 -194
  60. package/dist/resources/testserver/commands/create/metadata.js +52 -48
  61. package/dist/resources/testserver/commands/list/command.js +195 -50
  62. package/dist/resources/testserver/commands/list/metadata.js +12 -8
  63. package/dist/resources/testserver/provider.d.ts +1 -1
  64. package/dist/resources/testserver/resource-provider.js +2 -8
  65. package/dist/resources.d.ts +0 -3
  66. package/dist/resources.js +5 -10
  67. package/dist/runner/index.d.ts +2 -1
  68. package/dist/runner/index.js +1 -0
  69. package/dist/runner/prepare.d.ts +7 -6
  70. package/dist/runner/prepare.js +1 -1
  71. package/dist/runner/ready.d.ts +6 -0
  72. package/dist/runner/ready.js +33 -5
  73. package/dist/runner/recipe.d.ts +33 -6
  74. package/dist/runner/recipe.js +151 -23
  75. package/dist/runner/remote-command.js +1 -1
  76. package/dist/runner/secrets.d.ts +42 -0
  77. package/dist/runner/secrets.js +44 -0
  78. package/dist/runner/snapshot-build.d.ts +5 -2
  79. package/dist/runner/snapshot-build.js +12 -5
  80. package/dist/runner/snapshot-cache.d.ts +3 -3
  81. package/dist/runner/snapshot-cache.js +2 -2
  82. package/dist/runner/snapshot-key.d.ts +19 -12
  83. package/dist/runner/snapshot-key.js +25 -16
  84. package/dist/runner/snapshot-save.d.ts +5 -3
  85. package/dist/runner/snapshot-save.js +7 -5
  86. package/dist/runner/steps.d.ts +6 -1
  87. package/dist/runner/steps.js +5 -2
  88. package/dist/sdk/host.d.ts +2 -0
  89. package/dist/sdk/host.js +7 -0
  90. package/dist/version.d.ts +2 -2
  91. package/dist/version.js +10 -11
  92. package/dist/vitest/config.d.ts +4 -8
  93. package/dist/vitest/config.js +5 -9
  94. package/dist/vitest/container-scope.d.ts +12 -5
  95. package/dist/vitest/container-scope.js +27 -4
  96. package/dist/vitest/diagnostics.d.ts +8 -2
  97. package/dist/vitest/diagnostics.js +7 -4
  98. package/dist/vitest/fixtures.d.ts +4 -1
  99. package/dist/vitest/fixtures.js +17 -6
  100. package/dist/vitest/plan.d.ts +1 -1
  101. package/dist/vitest/plan.js +2 -2
  102. package/dist/vitest/sandbox.d.ts +6 -0
  103. package/dist/vitest/sandbox.js +6 -0
  104. package/package.json +4 -3
  105. package/skills/overview.md +1 -0
  106. package/bin/node-version.js +0 -24
  107. package/dist/closed-terminal.d.ts +0 -7
  108. package/dist/closed-terminal.js +0 -18
@@ -0,0 +1,436 @@
1
+ import {
2
+ RESOURCE_PRESENTATIONS,
3
+ median,
4
+ paint,
5
+ seconds,
6
+ shortFile,
7
+ truncate,
8
+ visibleLength
9
+ } from "./chunk-NX55IJ5S.js";
10
+
11
+ // src/commands/exec/tests-summary.ts
12
+ var SLOWEST_FILES = 3;
13
+ function testsSummaryLines(events, unreadable = 0, incomplete) {
14
+ const summary = testsSummary(events, unreadable, incomplete);
15
+ return [
16
+ summary.tests,
17
+ summary.containers === void 0 ? void 0 : ` ${summary.containers}`,
18
+ summary.slowest === void 0 ? void 0 : ` ${summary.slowest}`,
19
+ summary.unreadable,
20
+ summary.incomplete
21
+ ].filter((line) => line !== void 0);
22
+ }
23
+ function incompleteText(message) {
24
+ return `the test results may be incomplete: couldn't read the test events file once the command ended: ${message}`;
25
+ }
26
+ var NO_FINAL_RESULTS = "no final test results: add stormReporter() to vitest.config's reporters (@vercel/storm/vitest/config)";
27
+ function testsSummary(events, unreadable = 0, incomplete) {
28
+ const results = [];
29
+ const reported = [];
30
+ for (const event of events) {
31
+ if (event.kind === "test-result") results.push(event);
32
+ else reported.push(event);
33
+ }
34
+ let tests;
35
+ let containers;
36
+ let slowestText;
37
+ if (events.length > 0) {
38
+ const attempts = reported.flatMap((event) => event.kind === "test-attempt-finished" ? [event] : []);
39
+ const testMs = attempts.reduce((sum, event) => sum + event.ms, 0);
40
+ let workers = 0;
41
+ let first = Infinity;
42
+ let last = -Infinity;
43
+ for (const event of reported) {
44
+ workers = Math.max(workers, event.worker);
45
+ first = Math.min(first, event.at);
46
+ last = Math.max(last, event.at);
47
+ }
48
+ const wallMs = reported.length === 0 ? 0 : last - first;
49
+ const files = new Set(events.map((event) => event.file)).size;
50
+ const filesText = `${files} ${files === 1 ? "file" : "files"}`;
51
+ const outcome = results.length === 0 ? [
52
+ NO_FINAL_RESULTS,
53
+ ...attempts.length === 0 ? [] : [`${attempts.length} test ${attempts.length === 1 ? "attempt" : "attempts"}`],
54
+ filesText
55
+ ] : resultTotals(results, filesText);
56
+ const busy = wallMs > 0 && workers > 0 ? ` (${Math.round(testMs / (wallMs * workers) * 100)}% busy)` : "";
57
+ const timing = workers === 0 ? [] : [
58
+ `${seconds(testMs)} of attempts on ${workers} ${workers === 1 ? "worker" : "workers"} in ${seconds(wallMs)}${busy}`
59
+ ];
60
+ tests = ` tests ${[...outcome, ...timing].join(" \xB7 ")}`;
61
+ const starts = [];
62
+ const warmups = [];
63
+ for (const event of reported) {
64
+ if (event.kind !== "container-started" || !event.ok) continue;
65
+ starts.push(event.ms);
66
+ if (event.warmupMs !== void 0) warmups.push(event.warmupMs);
67
+ }
68
+ if (starts.length > 0) {
69
+ let startMs = 0;
70
+ let fastest = Infinity;
71
+ let slowest2 = -Infinity;
72
+ for (const ms of starts) {
73
+ startMs += ms;
74
+ fastest = Math.min(fastest, ms);
75
+ slowest2 = Math.max(slowest2, ms);
76
+ }
77
+ const share = testMs > 0 ? ` \xB7 ~${Math.round(startMs / testMs * 100)}% of attempt time` : "";
78
+ const warmup = warmups.length === 0 ? "" : ` \xB7 warmup median ${seconds(median(warmups) ?? 0)}`;
79
+ containers = `container starts ${starts.length} \xB7 ${seconds(fastest)}\u2013${seconds(slowest2)} \xB7 median ${seconds(median(starts) ?? 0)}${share}${warmup}`;
80
+ }
81
+ const slowest = slowestFiles(reported);
82
+ if (slowest.length > 0)
83
+ slowestText = `slowest: ${slowest.map(({ file, ms }) => `${shortFile(file)} ${seconds(ms)}`).join(", ")}`;
84
+ }
85
+ return {
86
+ tests,
87
+ containers,
88
+ slowest: slowestText,
89
+ unreadable: unreadable > 0 ? ` tests skipped ${unreadable} unreadable test event ${unreadable === 1 ? "line" : "lines"}` : void 0,
90
+ incomplete: incomplete === void 0 ? void 0 : ` tests ${incompleteText(incomplete)}`
91
+ };
92
+ }
93
+ function resultTotals(results, filesText) {
94
+ const count = (state) => results.filter((event) => event.state === state).length;
95
+ const failed = count("fail");
96
+ const skipped = count("skip");
97
+ return [
98
+ `${count("pass")} passed`,
99
+ ...failed === 0 ? [] : [`${failed} failed`],
100
+ ...skipped === 0 ? [] : [`${skipped} skipped`],
101
+ filesText
102
+ ];
103
+ }
104
+ function slowestFiles(events) {
105
+ const started = /* @__PURE__ */ new Map();
106
+ const durations = [];
107
+ for (const event of events) {
108
+ const key = `${event.worker}\0${event.file}`;
109
+ if (event.kind === "file-started") started.set(key, event.at);
110
+ if (event.kind === "file-finished") {
111
+ const at = started.get(key);
112
+ if (at !== void 0) durations.push({ file: event.file, ms: event.at - at });
113
+ }
114
+ }
115
+ return durations.toSorted((a, b) => b.ms - a.ms).slice(0, SLOWEST_FILES);
116
+ }
117
+
118
+ // src/commands/exec/worker-chart.ts
119
+ var MAX_WORKER_ROWS = 16;
120
+ var MAX_LABEL_SHARE = 0.3;
121
+ var MAX_LABEL_WIDTH = 32;
122
+ var INDENT = " ";
123
+ function testsChart(events, unreadable, clock, incomplete) {
124
+ const lanes = workerLanes(events, clock);
125
+ if (lanes.length === 0) return void 0;
126
+ const summary = testsSummary(events, unreadable, incomplete);
127
+ const failed = lanes.reduce((sum, lane) => sum + lane.starts.filter((start) => !start.ok).length, 0);
128
+ const notes = [
129
+ summary.tests,
130
+ summary.containers === void 0 ? void 0 : ` \u2591 ${summary.containers}`,
131
+ failed === 0 ? void 0 : ` \xD7 ${failed} container ${failed === 1 ? "start" : "starts"} failed`,
132
+ lanes.some((lane) => lane.files.length > 1) ? " \u2588\u2593 a worker's files, in turn" : void 0,
133
+ summary.unreadable,
134
+ summary.incomplete
135
+ ].filter((line) => line !== void 0);
136
+ return { lanes, notes };
137
+ }
138
+ function workerLanes(events, clock) {
139
+ const reported = events.filter((event) => event.kind !== "test-result");
140
+ const lanes = lanesOf(reported, clock.runStartedAt - clock.offsetMs);
141
+ if (lanes.length === 0) return [];
142
+ let first = Infinity;
143
+ let last = -Infinity;
144
+ for (const lane of lanes) {
145
+ first = Math.min(first, lane.startMs);
146
+ last = Math.max(last, lane.endMs);
147
+ }
148
+ const { startMs, endMs } = clock.tests;
149
+ const shift = first < startMs ? startMs - first : last > endMs ? Math.max(startMs - first, endMs - last) : 0;
150
+ const within = (ms) => Math.min(Math.max(ms + shift, startMs), endMs);
151
+ const moved = (span) => ({ ...span, startMs: within(span.startMs), endMs: within(span.endMs) });
152
+ const names = fileNames(lanes.flatMap((lane) => lane.files.map((run) => run.file)));
153
+ return lanes.map((lane) => ({
154
+ ...moved(lane),
155
+ files: lane.files.map((run) => ({ ...moved(run), name: names.get(run.file) ?? run.file })),
156
+ starts: lane.starts.map(moved)
157
+ }));
158
+ }
159
+ function fileNames(files) {
160
+ const distinct = [...new Set(files)];
161
+ const parts = new Map(distinct.map((file) => [file, file.split("/").filter((part) => part !== "")]));
162
+ const names = /* @__PURE__ */ new Map();
163
+ for (const file of distinct) {
164
+ const own = parts.get(file) ?? [file];
165
+ for (let depth = 1; depth <= own.length; depth += 1) {
166
+ const name = own.slice(-depth).join("/");
167
+ const shared = distinct.some(
168
+ (other) => other !== file && (parts.get(other) ?? []).slice(-depth).join("/") === name
169
+ );
170
+ if (!shared || depth === own.length) {
171
+ names.set(file, name);
172
+ break;
173
+ }
174
+ }
175
+ }
176
+ return names;
177
+ }
178
+ function workerLabelWidth(lanes, width) {
179
+ const digits = digitsOf(lanes);
180
+ const most = labelRoom(width);
181
+ let widest = 0;
182
+ for (const lane of shownLanes(lanes)) widest = Math.max(widest, labelText(lane, digits, most).length);
183
+ return widest + 1;
184
+ }
185
+ function labelRoom(width) {
186
+ return Math.min(MAX_LABEL_WIDTH, Math.floor(width * MAX_LABEL_SHARE));
187
+ }
188
+ function workerLaneLines(lanes, layout) {
189
+ const shown = shownLanes(lanes);
190
+ const digits = digitsOf(lanes);
191
+ let lastMs = -Infinity;
192
+ for (const lane of lanes) lastMs = Math.max(lastMs, lane.endMs);
193
+ const lines = shown.flatMap((lane) => laneLines(lane, digits, layout, lane.endMs === lastMs));
194
+ const hidden = lanes.filter((lane) => !shown.includes(lane));
195
+ if (hidden.length > 0) {
196
+ let doneMs = -Infinity;
197
+ for (const lane of hidden) doneMs = Math.max(doneMs, lane.endMs - lane.startMs);
198
+ lines.push(`${" ".repeat(layout.labelWidth)}+${hidden.length} more workers, each done within ${seconds(doneMs)}`);
199
+ }
200
+ return lines;
201
+ }
202
+ function lanesOf(events, origin) {
203
+ const byWorker = /* @__PURE__ */ new Map();
204
+ for (const event of events) {
205
+ const own = byWorker.get(event.worker);
206
+ if (own === void 0) byWorker.set(event.worker, [event]);
207
+ else own.push(event);
208
+ }
209
+ const lanes = [];
210
+ for (const [worker, own] of [...byWorker].toSorted(([a], [b]) => a - b)) {
211
+ const files = [];
212
+ const starts = [];
213
+ const tests = /* @__PURE__ */ new Set();
214
+ const openFiles = /* @__PURE__ */ new Map();
215
+ const startingContainers = /* @__PURE__ */ new Map();
216
+ let lastMs = -Infinity;
217
+ for (const event of own) {
218
+ const atMs = event.at - origin;
219
+ lastMs = Math.max(lastMs, atMs);
220
+ switch (event.kind) {
221
+ case "file-started":
222
+ openFiles.set(event.file, atMs);
223
+ break;
224
+ case "file-finished": {
225
+ const startMs2 = openFiles.get(event.file);
226
+ if (startMs2 !== void 0) files.push({ file: event.file, startMs: startMs2, endMs: atMs });
227
+ openFiles.delete(event.file);
228
+ break;
229
+ }
230
+ case "container-starting":
231
+ startingContainers.set(event.file, atMs);
232
+ break;
233
+ case "container-started":
234
+ starts.push({ startMs: atMs - event.ms - (event.warmupMs ?? 0), endMs: atMs, ok: event.ok });
235
+ startingContainers.delete(event.file);
236
+ break;
237
+ case "test-started":
238
+ tests.add(`${event.file}\0${event.test}`);
239
+ break;
240
+ case "test-attempt-finished":
241
+ break;
242
+ }
243
+ }
244
+ for (const [file, startMs2] of openFiles) files.push({ file, startMs: startMs2, endMs: lastMs });
245
+ for (const startMs2 of startingContainers.values()) starts.push({ startMs: startMs2, endMs: lastMs, ok: true });
246
+ if (files.length === 0) continue;
247
+ files.sort((a, b) => a.startMs - b.startMs);
248
+ let startMs = Infinity;
249
+ let endMs = -Infinity;
250
+ for (const run of files) {
251
+ startMs = Math.min(startMs, run.startMs);
252
+ endMs = Math.max(endMs, run.endMs);
253
+ }
254
+ lanes.push({
255
+ worker,
256
+ files: files.map((run) => ({ ...run, name: run.file })),
257
+ starts,
258
+ startMs,
259
+ endMs,
260
+ tests: tests.size
261
+ });
262
+ }
263
+ return lanes;
264
+ }
265
+ function shownLanes(lanes) {
266
+ if (lanes.length <= MAX_WORKER_ROWS) return lanes;
267
+ return [...lanes].toSorted((a, b) => b.endMs - a.endMs || a.worker - b.worker).slice(0, MAX_WORKER_ROWS).toSorted((a, b) => a.worker - b.worker);
268
+ }
269
+ function digitsOf(lanes) {
270
+ let worker = 1;
271
+ for (const lane of lanes) worker = Math.max(worker, lane.worker);
272
+ return String(worker).length;
273
+ }
274
+ function labelText(lane, digits, room) {
275
+ const [first] = lane.files;
276
+ const more = lane.files.length > 1 ? ` +${lane.files.length - 1}` : "";
277
+ const head = `${INDENT}w${String(lane.worker).padEnd(digits)} `;
278
+ const name = first?.name ?? "";
279
+ return `${head}${shortened(name, Math.max(1, room - head.length - more.length))}${more}`;
280
+ }
281
+ function shortened(name, room) {
282
+ if (name.length <= room) return name;
283
+ const extension = /(\.(test|spec))?\.[cm]?[jt]sx?$/.exec(name)?.[0] ?? "";
284
+ const stemRoom = room - extension.length - 1;
285
+ if (extension === "" || stemRoom < 1) return truncate(name, room);
286
+ return `${name.slice(0, stemRoom)}\u2026${extension}`;
287
+ }
288
+ function tailText(lane) {
289
+ const tests = lane.tests === 0 ? "" : ` \xB7 ${lane.tests} ${lane.tests === 1 ? "test" : "tests"}`;
290
+ return ` ${seconds(lane.endMs - lane.startMs)}${tests}`;
291
+ }
292
+ function workerTailWidth(lanes) {
293
+ let widest = 0;
294
+ for (const lane of shownLanes(lanes)) widest = Math.max(widest, tailText(lane).length);
295
+ return widest + 1;
296
+ }
297
+ var GLYPH = { file: "\u2588", "next-file": "\u2593", start: "\u2591", "failed-start": "\xD7" };
298
+ function laneLines(lane, digits, layout, waitedOn) {
299
+ const { labelWidth, column, width, paint: paint2 } = layout;
300
+ const startColumn = column(lane.startMs);
301
+ const endColumn = Math.max(startColumn, column(lane.endMs));
302
+ const cells = Array.from({ length: endColumn }, () => void 0);
303
+ const fill = (span, cell, atLeastOne = false) => {
304
+ const from = Math.min(Math.max(column(span.startMs), startColumn), endColumn);
305
+ const to = Math.min(Math.max(column(span.endMs), atLeastOne ? from + 1 : from), endColumn);
306
+ for (let index = from; index < to; index += 1) cells[index] = cell;
307
+ };
308
+ lane.files.forEach((run, index) => fill(run, index % 2 === 0 ? "file" : "next-file"));
309
+ for (const start of lane.starts) fill(start, start.ok ? "start" : "failed-start", !start.ok);
310
+ const label = labelText(lane, digits, Math.min(labelWidth - 1, labelRoom(width))).padEnd(labelWidth);
311
+ const text = tailText(lane);
312
+ const line = `${label}${paintedBar(cells, paint2, waitedOn)}\u258F${text}`;
313
+ if (lane.files.length < 2) return [line];
314
+ const plainWidth = label.length + cells.length + 1 + text.length;
315
+ const names = lane.files.map((run) => `${run.name} ${seconds(run.endMs - run.startMs)}`);
316
+ const sameLine = names.join(" \xB7 ");
317
+ if (plainWidth + 3 + visibleLength(sameLine) <= width) return [`${line} ${sameLine}`];
318
+ if (!waitedOn) return [line];
319
+ return [line, `${" ".repeat(labelWidth)}${fittingNames(names, width - labelWidth)}`];
320
+ }
321
+ function paintedBar(cells, paint2, waitedOn) {
322
+ let text = "";
323
+ let index = 0;
324
+ while (index < cells.length) {
325
+ const cell = cells[index];
326
+ let end = index + 1;
327
+ while (end < cells.length && cells[end] === cell) end += 1;
328
+ const run = cell === void 0 ? " ".repeat(end - index) : GLYPH[cell].repeat(end - index);
329
+ if (cell === "start") text += paint2.faint(run);
330
+ else if (cell === "failed-start") text += paint2.failed(run);
331
+ else if (cell !== void 0 && waitedOn) text += paint2.active(run);
332
+ else text += run;
333
+ index = end;
334
+ }
335
+ return text;
336
+ }
337
+ function fittingNames(names, room) {
338
+ for (let count = names.length; count > 0; count -= 1) {
339
+ const kept = [...names.slice(0, count), ...count < names.length ? [`+${names.length - count} more`] : []];
340
+ const text = kept.join(" \xB7 ");
341
+ if (visibleLength(text) <= room) return text;
342
+ }
343
+ return `+${names.length} more`;
344
+ }
345
+
346
+ // src/commands/exec/waterfall.ts
347
+ function laneLabel(name) {
348
+ if (name === "mint") return "credential";
349
+ if (name === "runner") return "runner-setup";
350
+ return RESOURCE_PRESENTATIONS.lanes.find(({ lane }) => lane === name)?.label ?? name;
351
+ }
352
+ function criticalPathStep(name, timeline) {
353
+ const snapshot = timeline.rows.find((candidate) => candidate.name === name)?.snapshot;
354
+ return snapshot === void 0 ? laneLabel(name) : `${laneLabel(name)} (snapshot ${snapshot})`;
355
+ }
356
+ var LABEL_WIDTH = Math.max(
357
+ ...[
358
+ "credential",
359
+ "runner-setup",
360
+ "tests",
361
+ "cleanup",
362
+ ...RESOURCE_PRESENTATIONS.lanes.map(({ label }) => label)
363
+ ].map((label) => label.length)
364
+ ) + 2;
365
+ var TAIL_WIDTH = 14;
366
+ var AXIS_STEPS = [1, 2, 5, 10, 15, 20, 30, 60, 120, 300, 600, 900, 1800, 3600, 7200];
367
+ function waterfallLines(timeline, extras) {
368
+ const style = extras.paint ?? paint(false);
369
+ const width = Math.max(60, extras.width);
370
+ const workers = extras.workers ?? [];
371
+ const labelWidth = Math.max(LABEL_WIDTH, workers.length === 0 ? 0 : workerLabelWidth(workers, width));
372
+ const tailWidth = Math.max(TAIL_WIDTH, workers.length === 0 ? 0 : workerTailWidth(workers));
373
+ const barWidth = width - labelWidth - tailWidth;
374
+ const total = Math.max(timeline.totalMs, 1);
375
+ const column = (ms) => Math.round(ms / total * barWidth);
376
+ const lines = [];
377
+ if (timeline.rows.length > 0) {
378
+ lines.push(style.faint(axis(total, labelWidth, barWidth, tailWidth, column)));
379
+ for (const row of timeline.rows) {
380
+ const critical = timeline.criticalPath.includes(row.name);
381
+ lines.push(...rowLines(row, { labelWidth, column, width, style }, critical));
382
+ if (row.name === "tests" && workers.length > 0)
383
+ lines.push(...workerLaneLines(workers, { labelWidth, column, width, paint: style }));
384
+ }
385
+ }
386
+ if (timeline.criticalPath.length > 0)
387
+ lines.push(` critical path: ${timeline.criticalPath.map((name) => criticalPathStep(name, timeline)).join(" \u2192 ")}`);
388
+ lines.push(...extras.details ?? []);
389
+ if (extras.logs !== void 0) lines.push(` logs ${extras.logs}`);
390
+ return lines;
391
+ }
392
+ function axis(total, labelWidth, barWidth, tailWidth, column) {
393
+ const stepSeconds = AXIS_STEPS.find((candidate) => candidate * 1e3 * barWidth / total >= 10) ?? AXIS_STEPS.at(-1) ?? 1;
394
+ const cells = Array.from({ length: barWidth + tailWidth }, () => " ");
395
+ for (let at = 0; at * 1e3 <= total; at += stepSeconds) {
396
+ const label = stepSeconds >= 60 ? `${at / 60}m` : `${at}s`;
397
+ const start = column(at * 1e3);
398
+ if (start + label.length > cells.length) break;
399
+ for (let index = 0; index < label.length; index += 1) cells[start + index] = label[index] ?? " ";
400
+ }
401
+ return `${" ".repeat(labelWidth)}${cells.join("").trimEnd()}`;
402
+ }
403
+ function rowLines(row, layout, critical) {
404
+ const { labelWidth, column, width, style } = layout;
405
+ const start = column(row.startMs);
406
+ const end = Math.max(start, column(row.endMs));
407
+ const idleEnd = Math.max(end, column(row.endMs + row.idleMs));
408
+ const bar = "\u2588".repeat(end - start);
409
+ const idle = "\u2591".repeat(idleEnd - end);
410
+ const outcome = row.outcome === "done" ? "" : ` ${row.outcome === "failed" ? style.failed(row.outcome) : style.stopped(row.outcome)}`;
411
+ const idleText = row.idleMs > 0 ? ` \xB7 idle ${seconds(row.idleMs)}` : "";
412
+ const head = `${` ${laneLabel(row.name)}`.padEnd(labelWidth)}${" ".repeat(start)}`;
413
+ const text = ` ${seconds(row.endMs - row.startMs)}${idleText}${outcome}`;
414
+ const line = `${head}${critical ? style.active(bar) : bar}${style.faint(idle)}\u258F${text}`;
415
+ const breakdown = breakdownText(row);
416
+ if (breakdown === "") return [line];
417
+ const plainWidth = head.length + bar.length + idle.length + 1 + visibleLength(text);
418
+ if (plainWidth + 3 + breakdown.length <= width) return [`${line} ${breakdown}`];
419
+ return [line, `${" ".repeat(labelWidth)}${breakdown}`];
420
+ }
421
+ function breakdownText(row) {
422
+ const steps = row.steps.map(
423
+ (step) => `${step.name} ${seconds(step.endMs - step.startMs)}${step.outcome === "done" ? "" : ` ${step.outcome}`}`
424
+ );
425
+ if (row.sandboxes === void 0) return steps.join(" \xB7 ");
426
+ const counts = `${row.sandboxes.reused} reused, ${row.sandboxes.created} created`;
427
+ return [counts, ...steps.length > 1 ? steps : []].join(" \xB7 ");
428
+ }
429
+
430
+ export {
431
+ testsSummaryLines,
432
+ testsChart,
433
+ laneLabel,
434
+ criticalPathStep,
435
+ waterfallLines
436
+ };
@@ -0,0 +1,89 @@
1
+ import {
2
+ liveVitestListGateway
3
+ } from "./chunk-WBIHJM7D.js";
4
+ import {
5
+ RESOURCE_CONFIGS,
6
+ liveResourceGateways
7
+ } from "./chunk-NX55IJ5S.js";
8
+ import {
9
+ liveConfigGateway
10
+ } from "./chunk-OCZJE5XV.js";
11
+ import {
12
+ RUNNER_SNAPSHOTS_SUBPATH,
13
+ RUNS_SUBPATH,
14
+ liveCheckoutGateway,
15
+ liveCommandGateway,
16
+ liveCredentialGateway,
17
+ liveGitHubActionsTokenGateway,
18
+ liveJobSummaryGateway,
19
+ liveProgressTerminal,
20
+ liveRunDirectoryGateway,
21
+ liveRunnerSandboxGateway,
22
+ liveRunnerSnapshotCacheGateway,
23
+ liveRunnerTerminal,
24
+ localUserName,
25
+ resolveStateDirectory,
26
+ stateDirectoryPattern,
27
+ systemClock,
28
+ systemTimer,
29
+ unavailableRunDirectoryGateway,
30
+ unavailableRunnerSnapshotCacheGateway
31
+ } from "./chunk-5CQCRX2L.js";
32
+ import "./chunk-S5NAIZYS.js";
33
+
34
+ // src/context.ts
35
+ function liveContext(options) {
36
+ const snapshots = resolveStateDirectory(options.env, RUNNER_SNAPSHOTS_SUBPATH);
37
+ const runs = resolveStateDirectory(options.env, RUNS_SUBPATH);
38
+ return {
39
+ ...liveResourceGateways({ env: options.env }),
40
+ credentials: liveCredentialGateway(),
41
+ githubActionsTokens: liveGitHubActionsTokenGateway({ env: options.env, timeoutMs: 1e4 }),
42
+ commands: liveCommandGateway(),
43
+ config: liveConfigGateway(),
44
+ checkout: liveCheckoutGateway(),
45
+ runnerSnapshots: snapshots.ok ? liveRunnerSnapshotCacheGateway({ directory: snapshots.directory }) : unavailableRunnerSnapshotCacheGateway(stateDirectoryPattern(RUNNER_SNAPSHOTS_SUBPATH), snapshots.reason),
46
+ runnerSandboxes: liveRunnerSandboxGateway(),
47
+ runnerTerminal: liveRunnerTerminal({ env: options.env }),
48
+ runDirectories: runs.ok ? liveRunDirectoryGateway({ directory: runs.directory }) : unavailableRunDirectoryGateway(stateDirectoryPattern(RUNS_SUBPATH), runs.reason),
49
+ progressTerminal: liveProgressTerminal(),
50
+ jobSummary: liveJobSummaryGateway({ path: options.env["GITHUB_STEP_SUMMARY"] }),
51
+ vitestList: liveVitestListGateway,
52
+ timer: systemTimer,
53
+ clock: systemClock
54
+ };
55
+ }
56
+
57
+ // src/presentation.ts
58
+ function resolvePresentation(host) {
59
+ const { env, stderr } = host;
60
+ const color = resolveColor(env, stderr.rich);
61
+ const columns = stderr.columns;
62
+ if (stderr.rich && !host.ci && host.agent === void 0 && env["VERCEL_ACCESSIBLE"] !== "1")
63
+ return { kind: "live", color, columns };
64
+ return { kind: "plain", github: env["GITHUB_ACTIONS"] === "true", color, columns };
65
+ }
66
+ function resolveColor(env, rich) {
67
+ if (env["NO_COLOR"] !== void 0) return false;
68
+ const forced = env["FORCE_COLOR"];
69
+ if (forced !== void 0 && forced !== "") return forced !== "0" && forced !== "false";
70
+ return rich;
71
+ }
72
+
73
+ // src/live-app.ts
74
+ function liveStormApp(host, build, exit) {
75
+ return {
76
+ context: liveContext({ env: host.env }),
77
+ resourceConfigs: RESOURCE_CONFIGS,
78
+ env: host.env,
79
+ cwd: host.cwd,
80
+ version: build.version,
81
+ commit: build.commit,
82
+ user: localUserName(),
83
+ presentation: resolvePresentation(host),
84
+ exit
85
+ };
86
+ }
87
+ export {
88
+ liveStormApp
89
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ buildCommit,
3
+ commitText,
4
+ readGitCommit,
5
+ versionText
6
+ } from "./chunk-I5GZLOLQ.js";
7
+ export {
8
+ buildCommit,
9
+ commitText,
10
+ readGitCommit,
11
+ versionText
12
+ };
@@ -301,6 +301,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
301
301
  };
302
302
  cleanup: import("./cleanup.ts").StormCleanupFacts;
303
303
  }]>;
304
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
305
+ variables: {
306
+ name: string;
307
+ problem: "missing" | "multiline" | "short";
308
+ }[];
309
+ minLength: number;
310
+ configFile: string | null;
311
+ }]>;
304
312
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
305
313
  snapshotId: string;
306
314
  base: string;
@@ -512,6 +520,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
512
520
  };
513
521
  cleanup: import("./cleanup.ts").StormCleanupFacts;
514
522
  }]>;
523
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
524
+ variables: {
525
+ name: string;
526
+ problem: "missing" | "multiline" | "short";
527
+ }[];
528
+ minLength: number;
529
+ configFile: string | null;
530
+ }]>;
515
531
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
516
532
  snapshotId: string;
517
533
  base: string;
@@ -821,6 +837,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
821
837
  };
822
838
  cleanup: import("./cleanup.ts").StormCleanupFacts;
823
839
  }]>;
840
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
841
+ variables: {
842
+ name: string;
843
+ problem: "missing" | "multiline" | "short";
844
+ }[];
845
+ minLength: number;
846
+ configFile: string | null;
847
+ }]>;
824
848
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
825
849
  snapshotId: string;
826
850
  base: string;
@@ -1032,6 +1056,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
1032
1056
  };
1033
1057
  cleanup: import("./cleanup.ts").StormCleanupFacts;
1034
1058
  }]>;
1059
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
1060
+ variables: {
1061
+ name: string;
1062
+ problem: "missing" | "multiline" | "short";
1063
+ }[];
1064
+ minLength: number;
1065
+ configFile: string | null;
1066
+ }]>;
1035
1067
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
1036
1068
  snapshotId: string;
1037
1069
  base: string;
@@ -1,23 +1,37 @@
1
+ import {
2
+ RUN_CLI_OPTIONS,
3
+ RUN_REQUEST_FIELDS,
4
+ runCommand,
5
+ runProblems
6
+ } from "../../chunks/chunk-RRQ2ZGSE.js";
7
+ import "../../chunks/chunk-I5GZLOLQ.js";
8
+ import "../../chunks/chunk-WV6WQFC6.js";
9
+ import {
10
+ outcomes
11
+ } from "../../chunks/chunk-5U5Q6VZR.js";
12
+ import "../../chunks/chunk-NX55IJ5S.js";
13
+ import "../../chunks/chunk-OCZJE5XV.js";
14
+ import "../../chunks/chunk-5CQCRX2L.js";
15
+ import "../../chunks/chunk-S5NAIZYS.js";
16
+
17
+ // src/commands/exec/command.ts
1
18
  import { z } from "zod";
2
- import { outcomes } from "./outcomes.js";
3
- import { RUN_CLI_OPTIONS, RUN_REQUEST_FIELDS, runCommand, runProblems } from "./run-command.js";
4
- /**
5
- * `storm exec`: runs any command, the argument list after `--`, as it is, in a run (`runCommand`). It counts no
6
- * tests and sizes nothing: `storm vitest` does both for vitest.
7
- */
8
- export function command(cmd) {
9
- return cmd.define({
10
- requestSchema: z.object({
11
- ...RUN_REQUEST_FIELDS,
12
- command: z.array(z.string()).min(1, { message: "Give the command to run after --" }),
13
- }),
14
- cli: { options: RUN_CLI_OPTIONS, positionals: ["command"] },
15
- response: outcomes,
16
- validate: runProblems,
17
- handler: async (context, request) => await runCommand(context, request, {
18
- name: "exec",
19
- prepare: async (settled) => ({ ok: true, argv: request.command, settled, plan: undefined }),
20
- ran: (facts) => outcomes.ran(facts),
21
- }),
22
- });
19
+ function command(cmd) {
20
+ return cmd.define({
21
+ requestSchema: z.object({
22
+ ...RUN_REQUEST_FIELDS,
23
+ command: z.array(z.string()).min(1, { message: "Give the command to run after --" })
24
+ }),
25
+ cli: { options: RUN_CLI_OPTIONS, positionals: ["command"] },
26
+ response: outcomes,
27
+ validate: runProblems,
28
+ handler: async (context, request) => await runCommand(context, request, {
29
+ name: "exec",
30
+ prepare: async (settled) => ({ ok: true, argv: request.command, settled, plan: void 0 }),
31
+ ran: (facts) => outcomes.ran(facts)
32
+ })
33
+ });
23
34
  }
35
+ export {
36
+ command
37
+ };