@cnc-tools/storm 0.0.0 → 0.6.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 (527) hide show
  1. package/bin/node-version.js +24 -0
  2. package/bin/storm.js +16 -0
  3. package/dist/application.d.ts +13 -0
  4. package/dist/application.js +23 -0
  5. package/dist/bin/storm.d.ts +1 -0
  6. package/dist/bin/storm.js +45 -0
  7. package/dist/build-info.js +3 -0
  8. package/dist/closed-terminal.d.ts +7 -0
  9. package/dist/closed-terminal.js +18 -0
  10. package/dist/combine-errors.d.ts +11 -0
  11. package/dist/combine-errors.js +19 -0
  12. package/dist/commands/dashboard.d.ts +11 -0
  13. package/dist/commands/dashboard.js +18 -0
  14. package/dist/commands/exec/cleanup.d.ts +135 -0
  15. package/dist/commands/exec/cleanup.js +171 -0
  16. package/dist/commands/exec/command.d.ts +272 -0
  17. package/dist/commands/exec/command.js +23 -0
  18. package/dist/commands/exec/job-summary.d.ts +10 -0
  19. package/dist/commands/exec/job-summary.js +34 -0
  20. package/dist/commands/exec/live-view.d.ts +22 -0
  21. package/dist/commands/exec/live-view.js +395 -0
  22. package/dist/commands/exec/metadata.d.ts +66 -0
  23. package/dist/commands/exec/metadata.js +55 -0
  24. package/dist/commands/exec/mint-failed.d.ts +11 -0
  25. package/dist/commands/exec/mint-failed.js +33 -0
  26. package/dist/commands/exec/outcomes.d.ts +614 -0
  27. package/dist/commands/exec/outcomes.js +338 -0
  28. package/dist/commands/exec/progress.d.ts +44 -0
  29. package/dist/commands/exec/progress.js +277 -0
  30. package/dist/commands/exec/redaction.d.ts +15 -0
  31. package/dist/commands/exec/redaction.js +40 -0
  32. package/dist/commands/exec/run-collector.d.ts +30 -0
  33. package/dist/commands/exec/run-collector.js +73 -0
  34. package/dist/commands/exec/run-command.d.ts +221 -0
  35. package/dist/commands/exec/run-command.js +663 -0
  36. package/dist/commands/exec/run-metadata.d.ts +56 -0
  37. package/dist/commands/exec/run-metadata.js +58 -0
  38. package/dist/commands/exec/run-record.d.ts +170 -0
  39. package/dist/commands/exec/run-record.js +104 -0
  40. package/dist/commands/exec/tests-summary.d.ts +34 -0
  41. package/dist/commands/exec/tests-summary.js +141 -0
  42. package/dist/commands/exec/testserver-flags.d.ts +48 -0
  43. package/dist/commands/exec/testserver-flags.js +80 -0
  44. package/dist/commands/exec/text.d.ts +22 -0
  45. package/dist/commands/exec/text.js +74 -0
  46. package/dist/commands/exec/view.d.ts +35 -0
  47. package/dist/commands/exec/view.js +163 -0
  48. package/dist/commands/exec/waterfall.d.ts +25 -0
  49. package/dist/commands/exec/waterfall.js +108 -0
  50. package/dist/commands/exec/worker-chart.d.ts +79 -0
  51. package/dist/commands/exec/worker-chart.js +313 -0
  52. package/dist/commands/runs/facts.d.ts +150 -0
  53. package/dist/commands/runs/facts.js +292 -0
  54. package/dist/commands/runs/list/command.d.ts +86 -0
  55. package/dist/commands/runs/list/command.js +36 -0
  56. package/dist/commands/runs/list/metadata.d.ts +22 -0
  57. package/dist/commands/runs/list/metadata.js +19 -0
  58. package/dist/commands/runs/list/outcomes.d.ts +74 -0
  59. package/dist/commands/runs/list/outcomes.js +89 -0
  60. package/dist/commands/runs/logs/command.d.ts +72 -0
  61. package/dist/commands/runs/logs/command.js +51 -0
  62. package/dist/commands/runs/logs/metadata.d.ts +22 -0
  63. package/dist/commands/runs/logs/metadata.js +22 -0
  64. package/dist/commands/runs/logs/outcomes.d.ts +55 -0
  65. package/dist/commands/runs/logs/outcomes.js +80 -0
  66. package/dist/commands/runs/metadata.d.ts +3 -0
  67. package/dist/commands/runs/metadata.js +3 -0
  68. package/dist/commands/runs/past-run.d.ts +72 -0
  69. package/dist/commands/runs/past-run.js +99 -0
  70. package/dist/commands/runs/show/command.d.ts +176 -0
  71. package/dist/commands/runs/show/command.js +76 -0
  72. package/dist/commands/runs/show/metadata.d.ts +25 -0
  73. package/dist/commands/runs/show/metadata.js +22 -0
  74. package/dist/commands/runs/show/outcomes.d.ts +164 -0
  75. package/dist/commands/runs/show/outcomes.js +320 -0
  76. package/dist/commands/vitest/command.d.ts +299 -0
  77. package/dist/commands/vitest/command.js +138 -0
  78. package/dist/commands/vitest/metadata.d.ts +66 -0
  79. package/dist/commands/vitest/metadata.js +35 -0
  80. package/dist/commands/vitest/outcomes.d.ts +273 -0
  81. package/dist/commands/vitest/outcomes.js +77 -0
  82. package/dist/config/by-name.d.ts +24 -0
  83. package/dist/config/by-name.js +26 -0
  84. package/dist/config/errors.d.ts +58 -0
  85. package/dist/config/errors.js +101 -0
  86. package/dist/config/gateways.d.ts +32 -0
  87. package/dist/config/gateways.js +1 -0
  88. package/dist/config/index.d.ts +10 -0
  89. package/dist/config/index.js +13 -0
  90. package/dist/config/live/config-gateway.d.ts +6 -0
  91. package/dist/config/live/config-gateway.js +71 -0
  92. package/dist/config/load.d.ts +54 -0
  93. package/dist/config/load.js +175 -0
  94. package/dist/config/resolve.d.ts +49 -0
  95. package/dist/config/resolve.js +94 -0
  96. package/dist/config/resource-config.d.ts +132 -0
  97. package/dist/config/resource-config.js +19 -0
  98. package/dist/config/schema.d.ts +64 -0
  99. package/dist/config/schema.js +57 -0
  100. package/dist/config/set.d.ts +27 -0
  101. package/dist/config/set.js +71 -0
  102. package/dist/config/settings-file.d.ts +41 -0
  103. package/dist/config/settings-file.js +72 -0
  104. package/dist/config-file/define.d.ts +39 -0
  105. package/dist/config-file/define.js +9 -0
  106. package/dist/config-file/toolchain.d.ts +9 -0
  107. package/dist/config-file/toolchain.js +41 -0
  108. package/dist/context.d.ts +89 -0
  109. package/dist/context.js +45 -0
  110. package/dist/core/command-provider.d.ts +126 -0
  111. package/dist/core/command-provider.js +13 -0
  112. package/dist/core/command-slots.d.ts +67 -0
  113. package/dist/core/command-slots.js +136 -0
  114. package/dist/core/events.d.ts +128 -0
  115. package/dist/core/events.js +15 -0
  116. package/dist/core/gateways.d.ts +249 -0
  117. package/dist/core/gateways.js +1 -0
  118. package/dist/core/index.d.ts +20 -0
  119. package/dist/core/index.js +18 -0
  120. package/dist/core/keyed.d.ts +12 -0
  121. package/dist/core/keyed.js +24 -0
  122. package/dist/core/lane.d.ts +46 -0
  123. package/dist/core/lane.js +5 -0
  124. package/dist/core/limit.d.ts +9 -0
  125. package/dist/core/limit.js +29 -0
  126. package/dist/core/live/command-gateway.d.ts +11 -0
  127. package/dist/core/live/command-gateway.js +83 -0
  128. package/dist/core/live/job-summary-gateway.d.ts +5 -0
  129. package/dist/core/live/job-summary-gateway.js +20 -0
  130. package/dist/core/live/progress-terminal.d.ts +20 -0
  131. package/dist/core/live/progress-terminal.js +173 -0
  132. package/dist/core/live/run-directory-gateway.d.ts +24 -0
  133. package/dist/core/live/run-directory-gateway.js +437 -0
  134. package/dist/core/mint.d.ts +10 -0
  135. package/dist/core/mint.js +14 -0
  136. package/dist/core/payload.d.ts +26 -0
  137. package/dist/core/payload.js +33 -0
  138. package/dist/core/presentation.d.ts +87 -0
  139. package/dist/core/presentation.js +5 -0
  140. package/dist/core/presentations.d.ts +56 -0
  141. package/dist/core/presentations.js +66 -0
  142. package/dist/core/provider.d.ts +69 -0
  143. package/dist/core/provider.js +5 -0
  144. package/dist/core/resource.d.ts +262 -0
  145. package/dist/core/resource.js +6 -0
  146. package/dist/core/resources.d.ts +131 -0
  147. package/dist/core/resources.js +254 -0
  148. package/dist/core/run-directory.d.ts +69 -0
  149. package/dist/core/run-directory.js +94 -0
  150. package/dist/core/run-state.d.ts +152 -0
  151. package/dist/core/run-state.js +313 -0
  152. package/dist/core/run.d.ts +187 -0
  153. package/dist/core/run.js +321 -0
  154. package/dist/core/state-directory.d.ts +19 -0
  155. package/dist/core/state-directory.js +29 -0
  156. package/dist/core/timeline.d.ts +63 -0
  157. package/dist/core/timeline.js +97 -0
  158. package/dist/core/timing.d.ts +22 -0
  159. package/dist/core/timing.js +26 -0
  160. package/dist/credential/credential.d.ts +46 -0
  161. package/dist/credential/credential.js +80 -0
  162. package/dist/credential/diagnosis.d.ts +18 -0
  163. package/dist/credential/diagnosis.js +99 -0
  164. package/dist/credential/gateways.d.ts +109 -0
  165. package/dist/credential/gateways.js +1 -0
  166. package/dist/credential/index.d.ts +7 -0
  167. package/dist/credential/index.js +7 -0
  168. package/dist/credential/live/github-actions-token-gateway.d.ts +15 -0
  169. package/dist/credential/live/github-actions-token-gateway.js +43 -0
  170. package/dist/credential/live/github-actions-token-response.d.ts +19 -0
  171. package/dist/credential/live/github-actions-token-response.js +49 -0
  172. package/dist/credential/live/vercel-cli-gateway.d.ts +9 -0
  173. package/dist/credential/live/vercel-cli-gateway.js +64 -0
  174. package/dist/credential/live/vercel-output.d.ts +60 -0
  175. package/dist/credential/live/vercel-output.js +122 -0
  176. package/dist/credential/live/vercel-process.d.ts +14 -0
  177. package/dist/credential/live/vercel-process.js +3 -0
  178. package/dist/credential/settle.d.ts +31 -0
  179. package/dist/credential/settle.js +49 -0
  180. package/dist/credential/source.d.ts +110 -0
  181. package/dist/credential/source.js +114 -0
  182. package/dist/help-logo.d.ts +11 -0
  183. package/dist/help-logo.js +56 -0
  184. package/dist/presentation.d.ts +26 -0
  185. package/dist/presentation.js +21 -0
  186. package/dist/resources/github/cleanup.d.ts +23 -0
  187. package/dist/resources/github/cleanup.js +39 -0
  188. package/dist/resources/github/command.d.ts +74 -0
  189. package/dist/resources/github/command.js +117 -0
  190. package/dist/resources/github/config.d.ts +16 -0
  191. package/dist/resources/github/config.js +37 -0
  192. package/dist/resources/github/events.d.ts +26 -0
  193. package/dist/resources/github/events.js +2 -0
  194. package/dist/resources/github/fixture-repo.d.ts +69 -0
  195. package/dist/resources/github/fixture-repo.js +60 -0
  196. package/dist/resources/github/gateways.d.ts +62 -0
  197. package/dist/resources/github/gateways.js +1 -0
  198. package/dist/resources/github/index.d.ts +12 -0
  199. package/dist/resources/github/index.js +15 -0
  200. package/dist/resources/github/live/fixture-repo-gateway.d.ts +12 -0
  201. package/dist/resources/github/live/fixture-repo-gateway.js +92 -0
  202. package/dist/resources/github/live/gateways.d.ts +6 -0
  203. package/dist/resources/github/live/gateways.js +13 -0
  204. package/dist/resources/github/presentation.d.ts +13 -0
  205. package/dist/resources/github/presentation.js +43 -0
  206. package/dist/resources/github/provider.d.ts +66 -0
  207. package/dist/resources/github/provider.js +58 -0
  208. package/dist/resources/github/resource-provider.d.ts +6 -0
  209. package/dist/resources/github/resource-provider.js +20 -0
  210. package/dist/resources/github/resource.d.ts +33 -0
  211. package/dist/resources/github/resource.js +12 -0
  212. package/dist/resources/testserver/cleanup.d.ts +14 -0
  213. package/dist/resources/testserver/cleanup.js +22 -0
  214. package/dist/resources/testserver/command.d.ts +322 -0
  215. package/dist/resources/testserver/command.js +245 -0
  216. package/dist/resources/testserver/commands/app.d.ts +18 -0
  217. package/dist/resources/testserver/commands/app.js +3 -0
  218. package/dist/resources/testserver/commands/create/command.d.ts +136 -0
  219. package/dist/resources/testserver/commands/create/command.js +158 -0
  220. package/dist/resources/testserver/commands/create/metadata.d.ts +31 -0
  221. package/dist/resources/testserver/commands/create/metadata.js +45 -0
  222. package/dist/resources/testserver/commands/create/outcomes.d.ts +111 -0
  223. package/dist/resources/testserver/commands/create/outcomes.js +172 -0
  224. package/dist/resources/testserver/commands/list/command.d.ts +60 -0
  225. package/dist/resources/testserver/commands/list/command.js +56 -0
  226. package/dist/resources/testserver/commands/list/metadata.d.ts +9 -0
  227. package/dist/resources/testserver/commands/list/metadata.js +9 -0
  228. package/dist/resources/testserver/commands/list/outcomes.d.ts +54 -0
  229. package/dist/resources/testserver/commands/list/outcomes.js +152 -0
  230. package/dist/resources/testserver/config.d.ts +18 -0
  231. package/dist/resources/testserver/config.js +78 -0
  232. package/dist/resources/testserver/credential-facts.d.ts +80 -0
  233. package/dist/resources/testserver/credential-facts.js +83 -0
  234. package/dist/resources/testserver/events.d.ts +59 -0
  235. package/dist/resources/testserver/events.js +4 -0
  236. package/dist/resources/testserver/index.d.ts +16 -0
  237. package/dist/resources/testserver/index.js +24 -0
  238. package/dist/resources/testserver/lane.d.ts +28 -0
  239. package/dist/resources/testserver/lane.js +139 -0
  240. package/dist/resources/testserver/live/gateways.d.ts +6 -0
  241. package/dist/resources/testserver/live/gateways.js +26 -0
  242. package/dist/resources/testserver/options.d.ts +5 -0
  243. package/dist/resources/testserver/options.js +5 -0
  244. package/dist/resources/testserver/pool/channels.d.ts +80 -0
  245. package/dist/resources/testserver/pool/channels.js +48 -0
  246. package/dist/resources/testserver/pool/create.d.ts +48 -0
  247. package/dist/resources/testserver/pool/create.js +45 -0
  248. package/dist/resources/testserver/pool/directory.d.ts +4 -0
  249. package/dist/resources/testserver/pool/directory.js +5 -0
  250. package/dist/resources/testserver/pool/gateways.d.ts +190 -0
  251. package/dist/resources/testserver/pool/gateways.js +1 -0
  252. package/dist/resources/testserver/pool/host.d.ts +8 -0
  253. package/dist/resources/testserver/pool/host.js +21 -0
  254. package/dist/resources/testserver/pool/index.d.ts +9 -0
  255. package/dist/resources/testserver/pool/index.js +10 -0
  256. package/dist/resources/testserver/pool/inspect.d.ts +53 -0
  257. package/dist/resources/testserver/pool/inspect.js +45 -0
  258. package/dist/resources/testserver/pool/lease.d.ts +84 -0
  259. package/dist/resources/testserver/pool/lease.js +125 -0
  260. package/dist/resources/testserver/pool/live/pool-records.d.ts +17 -0
  261. package/dist/resources/testserver/pool/live/pool-records.js +70 -0
  262. package/dist/resources/testserver/pool/live/pool-store-gateway.d.ts +12 -0
  263. package/dist/resources/testserver/pool/live/pool-store-gateway.js +435 -0
  264. package/dist/resources/testserver/pool/staleness.d.ts +16 -0
  265. package/dist/resources/testserver/pool/staleness.js +27 -0
  266. package/dist/resources/testserver/presentation.d.ts +9 -0
  267. package/dist/resources/testserver/presentation.js +217 -0
  268. package/dist/resources/testserver/provider.d.ts +177 -0
  269. package/dist/resources/testserver/provider.js +254 -0
  270. package/dist/resources/testserver/ran.d.ts +87 -0
  271. package/dist/resources/testserver/ran.js +140 -0
  272. package/dist/resources/testserver/resource-provider.d.ts +12 -0
  273. package/dist/resources/testserver/resource-provider.js +38 -0
  274. package/dist/resources/testserver/resource.d.ts +32 -0
  275. package/dist/resources/testserver/resource.js +10 -0
  276. package/dist/resources/testserver/run-sandbox.d.ts +13 -0
  277. package/dist/resources/testserver/run-sandbox.js +6 -0
  278. package/dist/resources/testserver/sandbox/channels.d.ts +12 -0
  279. package/dist/resources/testserver/sandbox/channels.js +21 -0
  280. package/dist/resources/testserver/sandbox/create-failure.d.ts +35 -0
  281. package/dist/resources/testserver/sandbox/create-failure.js +65 -0
  282. package/dist/resources/testserver/sandbox/create.d.ts +29 -0
  283. package/dist/resources/testserver/sandbox/create.js +37 -0
  284. package/dist/resources/testserver/sandbox/gateways.d.ts +150 -0
  285. package/dist/resources/testserver/sandbox/gateways.js +1 -0
  286. package/dist/resources/testserver/sandbox/index.d.ts +6 -0
  287. package/dist/resources/testserver/sandbox/index.js +7 -0
  288. package/dist/resources/testserver/sandbox/live/builds-response.d.ts +9 -0
  289. package/dist/resources/testserver/sandbox/live/builds-response.js +27 -0
  290. package/dist/resources/testserver/sandbox/live/control-plane-gateway.d.ts +17 -0
  291. package/dist/resources/testserver/sandbox/live/control-plane-gateway.js +133 -0
  292. package/dist/resources/testserver/sandbox/live/create-response.d.ts +35 -0
  293. package/dist/resources/testserver/sandbox/live/create-response.js +78 -0
  294. package/dist/resources/testserver/sandbox/live/fetch-failure.d.ts +24 -0
  295. package/dist/resources/testserver/sandbox/live/fetch-failure.js +45 -0
  296. package/dist/resources/testserver/sandbox/live/health-check-gateway.d.ts +11 -0
  297. package/dist/resources/testserver/sandbox/live/health-check-gateway.js +36 -0
  298. package/dist/resources/testserver/sandbox/live/sse.d.ts +12 -0
  299. package/dist/resources/testserver/sandbox/live/sse.js +32 -0
  300. package/dist/resources.d.ts +455 -0
  301. package/dist/resources.js +88 -0
  302. package/dist/runner/base.d.ts +40 -0
  303. package/dist/runner/base.js +52 -0
  304. package/dist/runner/context.d.ts +13 -0
  305. package/dist/runner/context.js +9 -0
  306. package/dist/runner/events.d.ts +179 -0
  307. package/dist/runner/events.js +16 -0
  308. package/dist/runner/gateways.d.ts +351 -0
  309. package/dist/runner/gateways.js +3 -0
  310. package/dist/runner/index.d.ts +19 -0
  311. package/dist/runner/index.js +18 -0
  312. package/dist/runner/live/checkout-gateway.d.ts +3 -0
  313. package/dist/runner/live/checkout-gateway.js +206 -0
  314. package/dist/runner/live/git-output.d.ts +14 -0
  315. package/dist/runner/live/git-output.js +32 -0
  316. package/dist/runner/live/sandbox-errors.d.ts +7 -0
  317. package/dist/runner/live/sandbox-errors.js +21 -0
  318. package/dist/runner/live/sandbox-gateway.d.ts +7 -0
  319. package/dist/runner/live/sandbox-gateway.js +427 -0
  320. package/dist/runner/live/snapshot-cache-gateway.d.ts +12 -0
  321. package/dist/runner/live/snapshot-cache-gateway.js +104 -0
  322. package/dist/runner/live/snapshot-records.d.ts +11 -0
  323. package/dist/runner/live/snapshot-records.js +57 -0
  324. package/dist/runner/live/terminal.d.ts +16 -0
  325. package/dist/runner/live/terminal.js +37 -0
  326. package/dist/runner/live/user.d.ts +2 -0
  327. package/dist/runner/live/user.js +11 -0
  328. package/dist/runner/output.d.ts +23 -0
  329. package/dist/runner/output.js +58 -0
  330. package/dist/runner/prepare.d.ts +67 -0
  331. package/dist/runner/prepare.js +59 -0
  332. package/dist/runner/ready.d.ts +68 -0
  333. package/dist/runner/ready.js +159 -0
  334. package/dist/runner/recipe.d.ts +126 -0
  335. package/dist/runner/recipe.js +302 -0
  336. package/dist/runner/remote-command.d.ts +77 -0
  337. package/dist/runner/remote-command.js +127 -0
  338. package/dist/runner/scope.d.ts +58 -0
  339. package/dist/runner/scope.js +117 -0
  340. package/dist/runner/snapshot-build.d.ts +33 -0
  341. package/dist/runner/snapshot-build.js +112 -0
  342. package/dist/runner/snapshot-cache.d.ts +84 -0
  343. package/dist/runner/snapshot-cache.js +126 -0
  344. package/dist/runner/snapshot-key.d.ts +52 -0
  345. package/dist/runner/snapshot-key.js +91 -0
  346. package/dist/runner/steps.d.ts +41 -0
  347. package/dist/runner/steps.js +49 -0
  348. package/dist/sdk/container/api-request.d.ts +32 -0
  349. package/dist/sdk/container/api-request.js +46 -0
  350. package/dist/sdk/container/container.d.ts +144 -0
  351. package/dist/sdk/container/container.js +346 -0
  352. package/dist/sdk/container/feature-flags.d.ts +37 -0
  353. package/dist/sdk/container/feature-flags.js +118 -0
  354. package/dist/sdk/container/gateways.d.ts +108 -0
  355. package/dist/sdk/container/gateways.js +1 -0
  356. package/dist/sdk/container/index.d.ts +5 -0
  357. package/dist/sdk/container/index.js +5 -0
  358. package/dist/sdk/container/live/container-gateway.d.ts +17 -0
  359. package/dist/sdk/container/live/container-gateway.js +114 -0
  360. package/dist/sdk/factories/build.d.ts +66 -0
  361. package/dist/sdk/factories/build.js +98 -0
  362. package/dist/sdk/factories/definition.d.ts +28 -0
  363. package/dist/sdk/factories/definition.js +16 -0
  364. package/dist/sdk/factories/definitions.d.ts +166 -0
  365. package/dist/sdk/factories/definitions.js +235 -0
  366. package/dist/sdk/factories/gateways.d.ts +25 -0
  367. package/dist/sdk/factories/gateways.js +1 -0
  368. package/dist/sdk/factories/index.d.ts +5 -0
  369. package/dist/sdk/factories/index.js +5 -0
  370. package/dist/sdk/factories/live/factory-gateway.d.ts +10 -0
  371. package/dist/sdk/factories/live/factory-gateway.js +29 -0
  372. package/dist/sdk/index.d.ts +7 -0
  373. package/dist/sdk/index.js +15 -0
  374. package/dist/sdk/payload/index.d.ts +2 -0
  375. package/dist/sdk/payload/index.js +4 -0
  376. package/dist/sdk/payload/payload.d.ts +47 -0
  377. package/dist/sdk/payload/payload.js +74 -0
  378. package/dist/sdk/payload/test-events.d.ts +102 -0
  379. package/dist/sdk/payload/test-events.js +59 -0
  380. package/dist/sdk/proxy/exchange.d.ts +58 -0
  381. package/dist/sdk/proxy/exchange.js +173 -0
  382. package/dist/sdk/proxy/faulted-exchange.d.ts +10 -0
  383. package/dist/sdk/proxy/faulted-exchange.js +106 -0
  384. package/dist/sdk/proxy/faults.d.ts +133 -0
  385. package/dist/sdk/proxy/faults.js +147 -0
  386. package/dist/sdk/proxy/index.d.ts +3 -0
  387. package/dist/sdk/proxy/index.js +3 -0
  388. package/dist/sdk/proxy/proxy.d.ts +93 -0
  389. package/dist/sdk/proxy/proxy.js +99 -0
  390. package/dist/sdk/proxy/records.d.ts +56 -0
  391. package/dist/sdk/proxy/records.js +56 -0
  392. package/dist/sdk/records/body.d.ts +89 -0
  393. package/dist/sdk/records/body.js +236 -0
  394. package/dist/sdk/records/index.d.ts +2 -0
  395. package/dist/sdk/records/index.js +4 -0
  396. package/dist/sdk/records/records.d.ts +49 -0
  397. package/dist/sdk/records/records.js +16 -0
  398. package/dist/sdk/seed/index.d.ts +1 -0
  399. package/dist/sdk/seed/index.js +3 -0
  400. package/dist/sdk/seed/seed.d.ts +221 -0
  401. package/dist/sdk/seed/seed.js +171 -0
  402. package/dist/sdk/testserver/clock.d.ts +8 -0
  403. package/dist/sdk/testserver/clock.js +10 -0
  404. package/dist/sdk/testserver/failure.d.ts +73 -0
  405. package/dist/sdk/testserver/failure.js +61 -0
  406. package/dist/sdk/testserver/index.d.ts +5 -0
  407. package/dist/sdk/testserver/index.js +8 -0
  408. package/dist/sdk/testserver/live/connect-failure.d.ts +7 -0
  409. package/dist/sdk/testserver/live/connect-failure.js +30 -0
  410. package/dist/sdk/testserver/live/request.d.ts +69 -0
  411. package/dist/sdk/testserver/live/request.js +89 -0
  412. package/dist/sdk/testserver/service-ids.d.ts +19 -0
  413. package/dist/sdk/testserver/service-ids.js +77 -0
  414. package/dist/sdk/testserver/test-id.d.ts +15 -0
  415. package/dist/sdk/testserver/test-id.js +28 -0
  416. package/dist/story/align.d.ts +37 -0
  417. package/dist/story/align.js +39 -0
  418. package/dist/story/artifact.d.ts +60 -0
  419. package/dist/story/artifact.js +93 -0
  420. package/dist/story/definition.d.ts +52 -0
  421. package/dist/story/definition.js +9 -0
  422. package/dist/story/diff.d.ts +9 -0
  423. package/dist/story/diff.js +97 -0
  424. package/dist/story/errors.d.ts +14 -0
  425. package/dist/story/errors.js +21 -0
  426. package/dist/story/gateways.d.ts +74 -0
  427. package/dist/story/gateways.js +3 -0
  428. package/dist/story/host.d.ts +27 -0
  429. package/dist/story/host.js +97 -0
  430. package/dist/story/index.d.ts +7 -0
  431. package/dist/story/index.js +9 -0
  432. package/dist/story/json.d.ts +16 -0
  433. package/dist/story/json.js +59 -0
  434. package/dist/story/live/artifact-gateway.d.ts +2 -0
  435. package/dist/story/live/artifact-gateway.js +82 -0
  436. package/dist/story/mode.d.ts +17 -0
  437. package/dist/story/mode.js +21 -0
  438. package/dist/story/orphans.d.ts +17 -0
  439. package/dist/story/orphans.js +15 -0
  440. package/dist/story/report.d.ts +30 -0
  441. package/dist/story/report.js +118 -0
  442. package/dist/story/run.d.ts +49 -0
  443. package/dist/story/run.js +160 -0
  444. package/dist/story/sequence.d.ts +30 -0
  445. package/dist/story/sequence.js +74 -0
  446. package/dist/story/settle.d.ts +94 -0
  447. package/dist/story/settle.js +70 -0
  448. package/dist/time/duration.d.ts +19 -0
  449. package/dist/time/duration.js +37 -0
  450. package/dist/time/index.d.ts +2 -0
  451. package/dist/time/index.js +4 -0
  452. package/dist/time/time.d.ts +15 -0
  453. package/dist/time/time.js +23 -0
  454. package/dist/vercel-cli/ansi.d.ts +13 -0
  455. package/dist/vercel-cli/ansi.js +32 -0
  456. package/dist/vercel-cli/arguments.d.ts +25 -0
  457. package/dist/vercel-cli/arguments.js +78 -0
  458. package/dist/vercel-cli/auth-config.d.ts +43 -0
  459. package/dist/vercel-cli/auth-config.js +36 -0
  460. package/dist/vercel-cli/clock.d.ts +9 -0
  461. package/dist/vercel-cli/clock.js +10 -0
  462. package/dist/vercel-cli/config-files.d.ts +24 -0
  463. package/dist/vercel-cli/config-files.js +40 -0
  464. package/dist/vercel-cli/context.d.ts +12 -0
  465. package/dist/vercel-cli/context.js +12 -0
  466. package/dist/vercel-cli/driver.d.ts +218 -0
  467. package/dist/vercel-cli/driver.js +364 -0
  468. package/dist/vercel-cli/entry.d.ts +8 -0
  469. package/dist/vercel-cli/entry.js +13 -0
  470. package/dist/vercel-cli/environment.d.ts +33 -0
  471. package/dist/vercel-cli/environment.js +72 -0
  472. package/dist/vercel-cli/errors.d.ts +8 -0
  473. package/dist/vercel-cli/errors.js +8 -0
  474. package/dist/vercel-cli/gateways.d.ts +103 -0
  475. package/dist/vercel-cli/gateways.js +4 -0
  476. package/dist/vercel-cli/index.d.ts +10 -0
  477. package/dist/vercel-cli/index.js +15 -0
  478. package/dist/vercel-cli/invocation.d.ts +234 -0
  479. package/dist/vercel-cli/invocation.js +397 -0
  480. package/dist/vercel-cli/keys.d.ts +14 -0
  481. package/dist/vercel-cli/keys.js +12 -0
  482. package/dist/vercel-cli/live/config-files.d.ts +28 -0
  483. package/dist/vercel-cli/live/config-files.js +66 -0
  484. package/dist/vercel-cli/live/process-gateway.d.ts +14 -0
  485. package/dist/vercel-cli/live/process-gateway.js +178 -0
  486. package/dist/vercel-cli/redaction.d.ts +13 -0
  487. package/dist/vercel-cli/redaction.js +22 -0
  488. package/dist/vercel-cli/report.d.ts +22 -0
  489. package/dist/vercel-cli/report.js +110 -0
  490. package/dist/vercel-cli/verbose.d.ts +7 -0
  491. package/dist/vercel-cli/verbose.js +24 -0
  492. package/dist/version.d.ts +20 -0
  493. package/dist/version.js +57 -0
  494. package/dist/vitest/config.d.ts +51 -0
  495. package/dist/vitest/config.js +61 -0
  496. package/dist/vitest/container-scope.d.ts +108 -0
  497. package/dist/vitest/container-scope.js +234 -0
  498. package/dist/vitest/diagnostics.d.ts +146 -0
  499. package/dist/vitest/diagnostics.js +306 -0
  500. package/dist/vitest/find-vitest.d.ts +7 -0
  501. package/dist/vitest/find-vitest.js +28 -0
  502. package/dist/vitest/fixtures.d.ts +64 -0
  503. package/dist/vitest/fixtures.js +172 -0
  504. package/dist/vitest/gateways.d.ts +78 -0
  505. package/dist/vitest/gateways.js +4 -0
  506. package/dist/vitest/index.d.ts +3 -0
  507. package/dist/vitest/index.js +9 -0
  508. package/dist/vitest/list-output.d.ts +3 -0
  509. package/dist/vitest/list-output.js +19 -0
  510. package/dist/vitest/live/list-gateway.d.ts +11 -0
  511. package/dist/vitest/live/list-gateway.js +107 -0
  512. package/dist/vitest/ownership.d.ts +29 -0
  513. package/dist/vitest/ownership.js +68 -0
  514. package/dist/vitest/plan.d.ts +66 -0
  515. package/dist/vitest/plan.js +104 -0
  516. package/dist/vitest/sandbox.d.ts +16 -0
  517. package/dist/vitest/sandbox.js +35 -0
  518. package/dist/vitest/test-events.d.ts +41 -0
  519. package/dist/vitest/test-events.js +92 -0
  520. package/dist/vitest/test-results.d.ts +84 -0
  521. package/dist/vitest/test-results.js +160 -0
  522. package/dist/vitest/types.d.ts +68 -0
  523. package/dist/vitest/types.js +4 -0
  524. package/package.json +119 -3
  525. package/skills/overview.md +33 -0
  526. package/skills/read-run-output.md +65 -0
  527. package/README.md +0 -3
@@ -0,0 +1,4 @@
1
+ // The Vitest adapter's gateway: finding `vitest` in `node_modules/.bin`, and listing the tests a `vitest run` would
2
+ // run, before any Testserver sandbox is leased. The live gateway is `live/list-gateway.ts`; the fake is
3
+ // `test/fakes/vitest/list-gateway.ts`.
4
+ export {};
@@ -0,0 +1,3 @@
1
+ export { CONTAINER_SCOPE, type ContainerScope } from "./container-scope.ts";
2
+ export { test } from "./fixtures.ts";
3
+ export type { StormContext, StormScopes, StormTest, StormTestFixtures, StormWorkerFixtures } from "./types.ts";
@@ -0,0 +1,9 @@
1
+ // storm's Vitest adapter, exported as `@cnc-tools/storm/vitest`: vitest's `test` extended with fixtures for
2
+ // the worker's Testserver sandbox, a container (shared by a test file's tests unless `containerScope` is `'test'`),
3
+ // its seeder and its proxy. A `vitest.config.ts` can't import it, since extending vitest's `test` throws there;
4
+ // `testserverWorkers` is in `./config.ts` (`@cnc-tools/storm/vitest/config`) for that reason, and isn't re-exported
5
+ // here. It imports the SDK only through `src/sdk/index.ts`, and the SDK never imports it. Besides Node builtins and
6
+ // the SDK, it depends only on `vitest`, an optional peer dependency of `@cnc-tools/storm`; `.oxlintrc.json` checks
7
+ // the boundary.
8
+ export { CONTAINER_SCOPE } from "./container-scope.js";
9
+ export { test } from "./fixtures.js";
@@ -0,0 +1,3 @@
1
+ import type { ListedTest } from "./gateways.ts";
2
+ /** The tests `stdout` names. Throws an `Error` when it isn't JSON, or isn't a list of tests. */
3
+ export declare function readVitestList(stdout: string): readonly ListedTest[];
@@ -0,0 +1,19 @@
1
+ // Reading `vitest list --json`'s output: a JSON array with one `{ name, file }` object per test. Pure, so the live
2
+ // gateway and `parseVitestList` (`plan.ts`) share it.
3
+ import { z } from "zod";
4
+ /** `vitest list --json`'s output; other fields, such as `projectName`, pass through unchecked. */
5
+ const VITEST_LIST = z.array(z.looseObject({ name: z.string(), file: z.string() }));
6
+ /** The tests `stdout` names. Throws an `Error` when it isn't JSON, or isn't a list of tests. */
7
+ export function readVitestList(stdout) {
8
+ let document;
9
+ try {
10
+ document = JSON.parse(stdout);
11
+ }
12
+ catch {
13
+ throw new Error("`vitest list --json` did not print JSON");
14
+ }
15
+ const parsed = VITEST_LIST.safeParse(document);
16
+ if (!parsed.success)
17
+ throw new Error("`vitest list --json` did not print a list of tests");
18
+ return parsed.data.map(({ name, file }) => ({ name, file }));
19
+ }
@@ -0,0 +1,11 @@
1
+ import type { VitestListGateway } from "../gateways.ts";
2
+ /**
3
+ * The live list gateway. `listTests` spawns `vitest list <args> --json` (`listArgv`), the request's `executable` or
4
+ * `vitest` from `PATH`, no shell, in `cwd`, with stdin ignored. It sends SIGTERM after `timeoutMs`
5
+ * (`AbortSignal.timeout`), or once the request's `signal` aborts, then waits for the process to exit and answers
6
+ * `timed-out` or `canceled`, `canceled` when the request's `signal` aborted. It waits for the exit, not for the pipes
7
+ * to close, since a process `vitest` left behind could hold them open. Any other `error` is a start failure, answered
8
+ * at once, since no process started. `findVitest` answers the first `node_modules/.bin/vitest` this process may
9
+ * execute, in `vitestSearchDirectories` order.
10
+ */
11
+ export declare const liveVitestListGateway: VitestListGateway;
@@ -0,0 +1,107 @@
1
+ import { spawn } from "node:child_process";
2
+ import { constants } from "node:fs";
3
+ import { access } from "node:fs/promises";
4
+ import { join } from "node:path";
5
+ import { VITEST_BIN, vitestSearchDirectories } from "../find-vitest.js";
6
+ import { readVitestList } from "../list-output.js";
7
+ /**
8
+ * The live list gateway. `listTests` spawns `vitest list <args> --json` (`listArgv`), the request's `executable` or
9
+ * `vitest` from `PATH`, no shell, in `cwd`, with stdin ignored. It sends SIGTERM after `timeoutMs`
10
+ * (`AbortSignal.timeout`), or once the request's `signal` aborts, then waits for the process to exit and answers
11
+ * `timed-out` or `canceled`, `canceled` when the request's `signal` aborted. It waits for the exit, not for the pipes
12
+ * to close, since a process `vitest` left behind could hold them open. Any other `error` is a start failure, answered
13
+ * at once, since no process started. `findVitest` answers the first `node_modules/.bin/vitest` this process may
14
+ * execute, in `vitestSearchDirectories` order.
15
+ */
16
+ export const liveVitestListGateway = {
17
+ async findVitest({ from, root }) {
18
+ const searched = vitestSearchDirectories(from, root);
19
+ for (const directory of searched) {
20
+ const path = join(directory, VITEST_BIN);
21
+ try {
22
+ await access(path, constants.X_OK);
23
+ return { ok: true, path };
24
+ }
25
+ catch {
26
+ // Not there, or not executable: look further up.
27
+ }
28
+ }
29
+ return { ok: false, searched };
30
+ },
31
+ listTests(request) {
32
+ return new Promise((resolve) => {
33
+ let settled = false;
34
+ const settle = (result) => {
35
+ if (settled)
36
+ return;
37
+ settled = true;
38
+ resolve(result);
39
+ };
40
+ const timeout = AbortSignal.timeout(request.timeoutMs);
41
+ const child = spawn(request.executable ?? "vitest", listArgv(request.args), {
42
+ ...(request.cwd === undefined ? {} : { cwd: request.cwd }),
43
+ stdio: ["ignore", "pipe", "pipe"],
44
+ signal: request.signal === undefined ? timeout : AbortSignal.any([timeout, request.signal]),
45
+ });
46
+ // Why the listing was stopped, once the abort killed the process: answered when it has exited.
47
+ let stopped;
48
+ let stdout = "";
49
+ let stderr = "";
50
+ child.stdout.setEncoding("utf8").on("data", (chunk) => {
51
+ stdout += chunk;
52
+ });
53
+ child.stderr.setEncoding("utf8").on("data", (chunk) => {
54
+ stderr += chunk;
55
+ });
56
+ child.on("error", (error) => {
57
+ if (error.name !== "AbortError") {
58
+ settle({ ok: false, failure: { kind: "start-failed", message: error.message } });
59
+ return;
60
+ }
61
+ stopped =
62
+ request.signal?.aborted === true ? { kind: "canceled" } : { kind: "timed-out", timeoutMs: request.timeoutMs };
63
+ if (child.exitCode !== null || child.signalCode !== null)
64
+ settle({ ok: false, failure: stopped });
65
+ });
66
+ child.on("exit", () => {
67
+ if (stopped !== undefined)
68
+ settle({ ok: false, failure: stopped });
69
+ });
70
+ child.on("close", (exitCode, signal) => {
71
+ if (stopped !== undefined) {
72
+ settle({ ok: false, failure: stopped });
73
+ return;
74
+ }
75
+ if (exitCode !== 0) {
76
+ settle({ ok: false, failure: { kind: "exited", exitCode, signal, lastStderrLine: lastLine(stderr) } });
77
+ return;
78
+ }
79
+ try {
80
+ settle({ ok: true, tests: readVitestList(stdout) });
81
+ }
82
+ catch (error) {
83
+ settle({ ok: false, failure: { kind: "unreadable-output", message: error.message } });
84
+ }
85
+ });
86
+ });
87
+ },
88
+ };
89
+ /**
90
+ * The last line of `text` that is neither blank nor a stack frame (`at …`), trimmed, so an error's stack leaves its
91
+ * message; empty when there is none.
92
+ */
93
+ function lastLine(text) {
94
+ return (text
95
+ .split(/\r?\n/)
96
+ .map((line) => line.trim())
97
+ .findLast((line) => line !== "" && !/^at\s/.test(line)) ?? "");
98
+ }
99
+ /**
100
+ * `vitest list`'s arguments: `args`, with `--json` after them but before a `--` among them. vitest's `--json` takes an
101
+ * optional path, so `vitest list --json test/a.test.ts` would write the list over `test/a.test.ts`; after the
102
+ * arguments, it takes none, and the list goes to stdout.
103
+ */
104
+ function listArgv(args) {
105
+ const end = args.indexOf("--");
106
+ return end === -1 ? ["list", ...args, "--json"] : ["list", ...args.slice(0, end), "--json", ...args.slice(end)];
107
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Acquires a resource for a fixture and makes sure it is disposed even when the test ends first.
3
+ *
4
+ * Vitest can time a test out and drain its fixture cleanups while an acquisition is still in flight, so a
5
+ * resource that arrives after that would never be disposed. Here, once `acquire` settles: if `signal` has aborted,
6
+ * the resource is disposed at once and never handed out, and this rejects with `signal.reason`; otherwise its
7
+ * disposal is registered with `onCleanup` and the resource returned. The check and the registration run with no
8
+ * await between them, so a cleanup drain can't slip in. When the late disposal fails too, this throws an
9
+ * `AggregateError` holding both, the abort reason first and as its `cause`.
10
+ */
11
+ export declare function acquireOwned<T>(signal: AbortSignal, onCleanup: (cleanup: () => Promise<void>) => void, acquire: () => Promise<T>, dispose: (resource: T) => Promise<void>): Promise<T>;
12
+ /**
13
+ * The acquisitions a test file has in flight. Vitest ends a file's worker once its tests and cleanups are done, so
14
+ * a resource still starting when its test timed out would be left behind with the worker. A file-scoped fixture
15
+ * calls `settle` in its cleanup, which Vitest awaits before the file finishes.
16
+ */
17
+ export declare class Acquisitions {
18
+ #private;
19
+ /**
20
+ * Tracks `acquisition`, an `acquireOwned` for the test whose signal is `signal`, and returns it unchanged. If it
21
+ * rejects after the test aborted with anything but the abort reason, `settle` throws that.
22
+ */
23
+ track<T>(signal: AbortSignal, acquisition: Promise<T>): Promise<T>;
24
+ /**
25
+ * Waits for every tracked acquisition to settle, then throws what any rejected with after its test aborted (one
26
+ * error as is, several in an `AggregateError`), since that may have left a resource behind.
27
+ */
28
+ settle(): Promise<void>;
29
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Acquires a resource for a fixture and makes sure it is disposed even when the test ends first.
3
+ *
4
+ * Vitest can time a test out and drain its fixture cleanups while an acquisition is still in flight, so a
5
+ * resource that arrives after that would never be disposed. Here, once `acquire` settles: if `signal` has aborted,
6
+ * the resource is disposed at once and never handed out, and this rejects with `signal.reason`; otherwise its
7
+ * disposal is registered with `onCleanup` and the resource returned. The check and the registration run with no
8
+ * await between them, so a cleanup drain can't slip in. When the late disposal fails too, this throws an
9
+ * `AggregateError` holding both, the abort reason first and as its `cause`.
10
+ */
11
+ export async function acquireOwned(signal, onCleanup, acquire, dispose) {
12
+ const resource = await acquire();
13
+ if (signal.aborted) {
14
+ const reason = signal.reason;
15
+ try {
16
+ await dispose(resource);
17
+ }
18
+ catch (disposeError) {
19
+ // oxlint-disable-next-line eslint/preserve-caught-error -- the abort reason is the documented `cause`; `disposeError` is in `errors`.
20
+ throw new AggregateError([reason, disposeError], `${messageOf(reason)}; disposing what the fixture acquired late also failed: ${messageOf(disposeError)}`, { cause: reason });
21
+ }
22
+ throw reason;
23
+ }
24
+ onCleanup(() => dispose(resource));
25
+ return resource;
26
+ }
27
+ /**
28
+ * The acquisitions a test file has in flight. Vitest ends a file's worker once its tests and cleanups are done, so
29
+ * a resource still starting when its test timed out would be left behind with the worker. A file-scoped fixture
30
+ * calls `settle` in its cleanup, which Vitest awaits before the file finishes.
31
+ */
32
+ export class Acquisitions {
33
+ #inFlight = new Set();
34
+ #lateFailures = [];
35
+ /**
36
+ * Tracks `acquisition`, an `acquireOwned` for the test whose signal is `signal`, and returns it unchanged. If it
37
+ * rejects after the test aborted with anything but the abort reason, `settle` throws that.
38
+ */
39
+ track(signal, acquisition) {
40
+ const settled = acquisition
41
+ .then(() => { }, (error) => {
42
+ if (signal.aborted && error !== signal.reason)
43
+ this.#lateFailures.push(error);
44
+ })
45
+ .finally(() => {
46
+ this.#inFlight.delete(settled);
47
+ });
48
+ this.#inFlight.add(settled);
49
+ return acquisition;
50
+ }
51
+ /**
52
+ * Waits for every tracked acquisition to settle, then throws what any rejected with after its test aborted (one
53
+ * error as is, several in an `AggregateError`), since that may have left a resource behind.
54
+ */
55
+ async settle() {
56
+ while (this.#inFlight.size > 0)
57
+ await Promise.all(this.#inFlight);
58
+ const failures = this.#lateFailures.splice(0);
59
+ if (failures.length === 1)
60
+ throw failures[0];
61
+ if (failures.length > 1) {
62
+ throw new AggregateError(failures, `${failures.length} fixtures failed after their tests ended: ${failures.map(messageOf).join("; ")}`);
63
+ }
64
+ }
65
+ }
66
+ function messageOf(error) {
67
+ return error instanceof Error ? error.message : String(error);
68
+ }
@@ -0,0 +1,66 @@
1
+ import type { VitestListFailure, VitestListGateway } from "./gateways.ts";
2
+ export { VITEST_BIN, vitestSearchDirectories } from "./find-vitest.ts";
3
+ export type { FindVitestRequest, FindVitestResult, ListedTest, VitestListFailure, VitestListGateway, VitestListRequest, VitestListResult, } from "./gateways.ts";
4
+ export { liveVitestListGateway } from "./live/list-gateway.ts";
5
+ export { WORKERS_PER_SANDBOX } from "./config.ts";
6
+ /** How long `listVitestTests` lets `vitest list` run by default. */
7
+ export declare const LIST_TIMEOUT_MS = 60000;
8
+ /** How many tests a Vitest run would run, and in how many files. */
9
+ export interface TestPlan {
10
+ readonly tests: number;
11
+ readonly files: number;
12
+ }
13
+ export interface ListVitestTestsOptions {
14
+ /** Passed to `vitest list --json`, as `vitest run` takes them, such as `["--project", "testserver"]`. */
15
+ readonly args: readonly string[];
16
+ /** Where vitest runs; default the current directory. */
17
+ readonly cwd?: string;
18
+ /** The `vitest` to start, such as the path `findVitest` found; default `vitest` from `PATH`. */
19
+ readonly executable?: string;
20
+ /** How long `vitest list` may take; default `LIST_TIMEOUT_MS`, 60s. */
21
+ readonly timeoutMs?: number;
22
+ /** Stops `vitest list` when it aborts: the plan's failure is then `canceled`. */
23
+ readonly signal?: AbortSignal;
24
+ }
25
+ /** A Vitest run's test plan, or why its tests couldn't be listed. */
26
+ export type VitestPlanResult = {
27
+ readonly ok: true;
28
+ readonly plan: TestPlan;
29
+ } | {
30
+ readonly ok: false;
31
+ readonly failure: VitestListFailure;
32
+ };
33
+ /**
34
+ * Lists the tests `vitest run <args>` would run, with `vitest list <args> --json` (`executable`, else `vitest` from
35
+ * `PATH`), and counts them; or says why it couldn't: `vitest` failed to start, didn't finish within `timeoutMs`, exited
36
+ * other than 0 (with the last line of its stderr that isn't a stack frame), printed something other than a list of
37
+ * tests, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive number.
38
+ */
39
+ export declare function planVitestRun(options: ListVitestTestsOptions, gateway?: VitestListGateway): Promise<VitestPlanResult>;
40
+ /**
41
+ * `planVitestRun`'s plan, rejecting with an `Error` that says why the tests couldn't be listed
42
+ * (`describeVitestListFailure`).
43
+ */
44
+ export declare function listVitestTests(options: ListVitestTestsOptions, gateway?: VitestListGateway): Promise<TestPlan>;
45
+ /** The argv that runs `args` with `executable`, a `vitest`: `<executable> run <args...>`. */
46
+ export declare function vitestRunArgv(executable: string, args: readonly string[]): readonly string[];
47
+ /** The plan `vitest list --json` printed: its tests, and their distinct files. Throws when it isn't a list of tests. */
48
+ export declare function parseVitestList(stdout: string): TestPlan;
49
+ /** A plan as a phrase, such as `65 tests in 19 files` or `1 test in 1 file`. */
50
+ export declare function formatPlan(plan: TestPlan): string;
51
+ /** The most Testserver sandboxes `autoSandboxes` sizes a run for: past it, a run passes `--testserver-sandboxes`. */
52
+ export declare const AUTO_SANDBOXES_MAX = 8;
53
+ /**
54
+ * The Testserver sandboxes `storm vitest` asks for when neither `--testserver-sandboxes` nor the config file says:
55
+ * one per `WORKERS_PER_SANDBOX` (4) files, at least 1 and at most `AUTO_SANDBOXES_MAX` (8) (`sandboxesFor`).
56
+ */
57
+ export declare function autoSandboxes(files: number): number;
58
+ /**
59
+ * The Testserver sandboxes to ask `storm exec --testserver-sandboxes <n>` for: one per `workersPerSandbox` files
60
+ * (default `WORKERS_PER_SANDBOX`, 4, as `testserverWorkers` sizes `maxWorkers`), at least 1 and at most `max`. A file's
61
+ * tests run in one worker, so more sandboxes than that would sit idle. Throws a `TypeError` unless `files` is a
62
+ * non-negative integer and `max` and `workersPerSandbox` are positive integers.
63
+ */
64
+ export declare function sandboxesFor(files: number, max: number, workersPerSandbox?: number): number;
65
+ /** Why the tests couldn't be listed, as a sentence. */
66
+ export declare function describeVitestListFailure(failure: VitestListFailure): string;
@@ -0,0 +1,104 @@
1
+ // Planning a Vitest run before any Testserver sandbox is leased, exported as `@cnc-tools/storm/vitest/plan`: finding
2
+ // `vitest` in `node_modules/.bin`, counting the tests `vitest run <args>` would run, sizing the Testserver sandboxes
3
+ // for them, and the `vitest run` argv. It is the adapter's one entry point for the CLI: `storm vitest` imports it
4
+ // and nothing else of the adapter. Like `config.ts`, it imports neither `./fixtures.ts` nor vitest: the CLI and a
5
+ // launcher script run outside a Vitest run, where the adapter's `test` throws.
6
+ import { WORKERS_PER_SANDBOX } from "./config.js";
7
+ import { readVitestList } from "./list-output.js";
8
+ import { liveVitestListGateway } from "./live/list-gateway.js";
9
+ export { VITEST_BIN, vitestSearchDirectories } from "./find-vitest.js";
10
+ export { liveVitestListGateway } from "./live/list-gateway.js";
11
+ export { WORKERS_PER_SANDBOX } from "./config.js";
12
+ /** How long `listVitestTests` lets `vitest list` run by default. */
13
+ export const LIST_TIMEOUT_MS = 60_000;
14
+ /**
15
+ * Lists the tests `vitest run <args>` would run, with `vitest list <args> --json` (`executable`, else `vitest` from
16
+ * `PATH`), and counts them; or says why it couldn't: `vitest` failed to start, didn't finish within `timeoutMs`, exited
17
+ * other than 0 (with the last line of its stderr that isn't a stack frame), printed something other than a list of
18
+ * tests, or was stopped by `signal` (`canceled`). Throws a `TypeError` unless `timeoutMs` is a positive number.
19
+ */
20
+ export async function planVitestRun(options, gateway = liveVitestListGateway) {
21
+ const timeoutMs = options.timeoutMs ?? LIST_TIMEOUT_MS;
22
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
23
+ throw new TypeError(`planVitestRun: timeoutMs is ${String(timeoutMs)}, not a positive number`);
24
+ }
25
+ const listed = await gateway.listTests({
26
+ args: options.args,
27
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
28
+ ...(options.executable === undefined ? {} : { executable: options.executable }),
29
+ timeoutMs,
30
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
31
+ });
32
+ return listed.ok ? { ok: true, plan: planOf(listed.tests) } : { ok: false, failure: listed.failure };
33
+ }
34
+ /**
35
+ * `planVitestRun`'s plan, rejecting with an `Error` that says why the tests couldn't be listed
36
+ * (`describeVitestListFailure`).
37
+ */
38
+ export async function listVitestTests(options, gateway = liveVitestListGateway) {
39
+ const planned = await planVitestRun(options, gateway);
40
+ if (!planned.ok)
41
+ throw new Error(describeVitestListFailure(planned.failure));
42
+ return planned.plan;
43
+ }
44
+ /** The argv that runs `args` with `executable`, a `vitest`: `<executable> run <args...>`. */
45
+ export function vitestRunArgv(executable, args) {
46
+ return [executable, "run", ...args];
47
+ }
48
+ /** The plan `vitest list --json` printed: its tests, and their distinct files. Throws when it isn't a list of tests. */
49
+ export function parseVitestList(stdout) {
50
+ return planOf(readVitestList(stdout));
51
+ }
52
+ /** A plan as a phrase, such as `65 tests in 19 files` or `1 test in 1 file`. */
53
+ export function formatPlan(plan) {
54
+ return `${plan.tests} ${plan.tests === 1 ? "test" : "tests"} in ${plan.files} ${plan.files === 1 ? "file" : "files"}`;
55
+ }
56
+ /** The most Testserver sandboxes `autoSandboxes` sizes a run for: past it, a run passes `--testserver-sandboxes`. */
57
+ export const AUTO_SANDBOXES_MAX = 8;
58
+ /**
59
+ * The Testserver sandboxes `storm vitest` asks for when neither `--testserver-sandboxes` nor the config file says:
60
+ * one per `WORKERS_PER_SANDBOX` (4) files, at least 1 and at most `AUTO_SANDBOXES_MAX` (8) (`sandboxesFor`).
61
+ */
62
+ export function autoSandboxes(files) {
63
+ return sandboxesFor(files, AUTO_SANDBOXES_MAX);
64
+ }
65
+ /**
66
+ * The Testserver sandboxes to ask `storm exec --testserver-sandboxes <n>` for: one per `workersPerSandbox` files
67
+ * (default `WORKERS_PER_SANDBOX`, 4, as `testserverWorkers` sizes `maxWorkers`), at least 1 and at most `max`. A file's
68
+ * tests run in one worker, so more sandboxes than that would sit idle. Throws a `TypeError` unless `files` is a
69
+ * non-negative integer and `max` and `workersPerSandbox` are positive integers.
70
+ */
71
+ export function sandboxesFor(files, max, workersPerSandbox = WORKERS_PER_SANDBOX) {
72
+ if (!Number.isInteger(files) || files < 0) {
73
+ throw new TypeError(`sandboxesFor: files is ${String(files)}, not a non-negative integer`);
74
+ }
75
+ for (const [name, value] of [
76
+ ["max", max],
77
+ ["workersPerSandbox", workersPerSandbox],
78
+ ]) {
79
+ if (!Number.isInteger(value) || value < 1) {
80
+ throw new TypeError(`sandboxesFor: ${name} is ${String(value)}, not a positive integer`);
81
+ }
82
+ }
83
+ return Math.min(max, Math.max(1, Math.ceil(files / workersPerSandbox)));
84
+ }
85
+ function planOf(tests) {
86
+ return { tests: tests.length, files: new Set(tests.map((test) => test.file)).size };
87
+ }
88
+ /** Why the tests couldn't be listed, as a sentence. */
89
+ export function describeVitestListFailure(failure) {
90
+ switch (failure.kind) {
91
+ case "start-failed":
92
+ return `\`vitest list\` failed to start: ${failure.message}`;
93
+ case "timed-out":
94
+ return `\`vitest list\` did not finish in ${failure.timeoutMs / 1000}s`;
95
+ case "exited": {
96
+ const how = failure.exitCode === null ? `was ended by ${failure.signal ?? "a signal"}` : `exited ${failure.exitCode}`;
97
+ return `\`vitest list\` ${how}${failure.lastStderrLine === "" ? "" : `: ${failure.lastStderrLine}`}`;
98
+ }
99
+ case "unreadable-output":
100
+ return failure.message;
101
+ case "canceled":
102
+ return "`vitest list` was canceled";
103
+ }
104
+ }
@@ -0,0 +1,16 @@
1
+ import type { RunPayload } from "../sdk/index.ts";
2
+ /** What a test that needs a Testserver sandbox fails with in a run that holds none. */
3
+ export declare const NO_TESTSERVER_MESSAGE = "this run has no Testserver; add resources.testserverPool to storm.config.ts or pass --testserver-sandboxes <n>";
4
+ /**
5
+ * The Testserver URL of the Testserver sandbox the vitest worker numbered `poolId` uses:
6
+ * `sandboxes[(poolId - 1) % N]` of the run payload's `resources.testserverPool`. `poolId` is the worker's
7
+ * `VITEST_POOL_ID`, which vitest sets to a number from 1 to `maxWorkers`. Throws when `poolId` is missing or not a
8
+ * positive integer, or when the run payload lists no Testserver sandbox (`NO_TESTSERVER_MESSAGE`), as in a run
9
+ * without a Testserver side, which has no `testserverPool`.
10
+ */
11
+ export declare function sandboxForWorker(payload: RunPayload, poolId: string | undefined): string;
12
+ /**
13
+ * How many Testserver sandboxes `payload` counts for sizing workers: at least one, so a config always loads, a run
14
+ * without a Testserver side's included; its tests that need a Testserver sandbox fail with `NO_TESTSERVER_MESSAGE`.
15
+ */
16
+ export declare function sandboxCount(payload: RunPayload): number;
@@ -0,0 +1,35 @@
1
+ // Which Testserver sandbox a vitest worker uses, and how many Testserver sandboxes a run counts for sizing workers.
2
+ // Pure: no vitest import, so `config.ts`, which a `vitest.config.ts` loads, can use it.
3
+ /** What a test that needs a Testserver sandbox fails with in a run that holds none. */
4
+ export const NO_TESTSERVER_MESSAGE = "this run has no Testserver; add resources.testserverPool to storm.config.ts or pass --testserver-sandboxes <n>";
5
+ /**
6
+ * The Testserver URL of the Testserver sandbox the vitest worker numbered `poolId` uses:
7
+ * `sandboxes[(poolId - 1) % N]` of the run payload's `resources.testserverPool`. `poolId` is the worker's
8
+ * `VITEST_POOL_ID`, which vitest sets to a number from 1 to `maxWorkers`. Throws when `poolId` is missing or not a
9
+ * positive integer, or when the run payload lists no Testserver sandbox (`NO_TESTSERVER_MESSAGE`), as in a run
10
+ * without a Testserver side, which has no `testserverPool`.
11
+ */
12
+ export function sandboxForWorker(payload, poolId) {
13
+ if (poolId === undefined || !/^[1-9][0-9]*$/.test(poolId)) {
14
+ throw new Error(`VITEST_POOL_ID is ${poolId === undefined ? "not set" : JSON.stringify(poolId)}, not a positive integer: ` +
15
+ "the storm Vitest adapter must run inside a vitest worker");
16
+ }
17
+ const sandboxes = payloadSandboxes(payload);
18
+ if (sandboxes.length === 0)
19
+ throw new Error(NO_TESTSERVER_MESSAGE);
20
+ const sandbox = sandboxes[(Number(poolId) - 1) % sandboxes.length];
21
+ if (sandbox === undefined)
22
+ throw new Error(NO_TESTSERVER_MESSAGE);
23
+ return sandbox.url;
24
+ }
25
+ /**
26
+ * How many Testserver sandboxes `payload` counts for sizing workers: at least one, so a config always loads, a run
27
+ * without a Testserver side's included; its tests that need a Testserver sandbox fail with `NO_TESTSERVER_MESSAGE`.
28
+ */
29
+ export function sandboxCount(payload) {
30
+ return Math.max(1, payloadSandboxes(payload).length);
31
+ }
32
+ /** The Testserver sandboxes the run payload's `resources.testserverPool` lists; none without it. */
33
+ function payloadSandboxes(payload) {
34
+ return payload.resources.testserverPool?.sandboxes ?? [];
35
+ }
@@ -0,0 +1,41 @@
1
+ import { type ServiceWarmup, type WorkerTestEvent } from "../sdk/index.ts";
2
+ /** What a worker's test event reports beside what its reporter knows: the worker and the time. */
3
+ export type ReportedTestEvent = WorkerTestEvent extends infer E ? E extends WorkerTestEvent ? Omit<E, "worker" | "at"> : never : never;
4
+ /** Reports this worker's test events. */
5
+ export type TestEventReporter = (event: ReportedTestEvent) => void;
6
+ /** A reporter that reports nothing. */
7
+ export declare const silentTestEvents: TestEventReporter;
8
+ /**
9
+ * The reporter for this worker: appends each event, with the worker's `VITEST_POOL_ID` and the time, to the run
10
+ * payload's `testEvents` file. Outside a storm run, when the run payload names no such file, or outside a vitest
11
+ * worker, it reports nothing; and once an append fails it drops every later event: reporting never fails a test.
12
+ */
13
+ export declare function testEventReporter(env?: Readonly<Record<string, string | undefined>>, append?: (path: string, text: string) => void, now?: () => number): TestEventReporter;
14
+ /**
15
+ * The test events file the run payload in `env` names; undefined outside a storm run, when the run payload
16
+ * names none, or when it can't be read.
17
+ */
18
+ export declare function testEventsFile(env: Readonly<Record<string, string | undefined>>): string | undefined;
19
+ /** The tests in a vitest file or suite, counted through its suites. */
20
+ export declare function countTests(task: {
21
+ readonly tasks?: readonly unknown[];
22
+ }): number;
23
+ /** A finished test attempt's state as a test event reports it: passed, failed, or anything else as skipped. */
24
+ export declare function testEventState(state: string | undefined): "pass" | "fail" | "skip";
25
+ /** A container start `reportedStart` reported: what `start` returned, how long it took, and any warmup after it. */
26
+ export interface ReportedStart<T> {
27
+ readonly value: T;
28
+ readonly startMs: number;
29
+ /** The warmup, and how long it took by `reportedStart`'s clock; absent when nothing was warmed. */
30
+ readonly warmup?: {
31
+ readonly ms: number;
32
+ readonly warmup: ServiceWarmup;
33
+ };
34
+ }
35
+ /**
36
+ * `start`, then `warm` on what it returned when given, reporting to `report`, for `file`: `container-starting`,
37
+ * then, once both have ended, `container-started` with the start's `ms` and, when `warm` ran, `warmupMs` and how
38
+ * many services failed (`warmupFailed`). A start that throws reports `ok: false` without warmup fields, and so does a
39
+ * `warm` that throws, which leaves ending the container to `warm`.
40
+ */
41
+ export declare function reportedStart<T>(report: TestEventReporter, file: string, start: () => Promise<T>, warm?: (value: T) => Promise<ServiceWarmup>, now?: () => number): Promise<ReportedStart<T>>;
@@ -0,0 +1,92 @@
1
+ // The test events a vitest worker appends to the run payload's `testEvents` file, so the run can show which
2
+ // worker runs which file, how long each container start and test attempt takes, and how busy the workers are. A
3
+ // test's final result comes from vitest's main process instead (`test-results.ts`). Pure but for the append, which a
4
+ // reporter does with one write a line: a short `O_APPEND` write lands whole beside other workers'.
5
+ import { appendFileSync } from "node:fs";
6
+ import { readRunPayload, RUN_PAYLOAD_VARIABLE, testEventLine, } from "../sdk/index.js";
7
+ /** A reporter that reports nothing. */
8
+ export const silentTestEvents = () => { };
9
+ /**
10
+ * The reporter for this worker: appends each event, with the worker's `VITEST_POOL_ID` and the time, to the run
11
+ * payload's `testEvents` file. Outside a storm run, when the run payload names no such file, or outside a vitest
12
+ * worker, it reports nothing; and once an append fails it drops every later event: reporting never fails a test.
13
+ */
14
+ export function testEventReporter(env = process.env, append = (path, text) => appendFileSync(path, text), now = Date.now) {
15
+ const path = testEventsFile(env);
16
+ const poolId = env["VITEST_POOL_ID"];
17
+ if (path === undefined || poolId === undefined || !/^[1-9][0-9]*$/.test(poolId))
18
+ return silentTestEvents;
19
+ const file = path;
20
+ const worker = Number(poolId);
21
+ let failed = false;
22
+ return (event) => {
23
+ if (failed)
24
+ return;
25
+ try {
26
+ append(file, `${testEventLine({ ...event, worker, at: now() })}\n`);
27
+ }
28
+ catch {
29
+ failed = true;
30
+ }
31
+ };
32
+ }
33
+ /**
34
+ * The test events file the run payload in `env` names; undefined outside a storm run, when the run payload
35
+ * names none, or when it can't be read.
36
+ */
37
+ export function testEventsFile(env) {
38
+ const raw = env[RUN_PAYLOAD_VARIABLE];
39
+ if (raw === undefined || raw === "")
40
+ return undefined;
41
+ try {
42
+ return readRunPayload(env).testEvents;
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
48
+ /** The tests in a vitest file or suite, counted through its suites. */
49
+ export function countTests(task) {
50
+ let count = 0;
51
+ for (const child of task.tasks ?? []) {
52
+ const node = child;
53
+ if (node.type === "test")
54
+ count += 1;
55
+ else if (node.type === "suite")
56
+ count += countTests(node);
57
+ }
58
+ return count;
59
+ }
60
+ /** A finished test attempt's state as a test event reports it: passed, failed, or anything else as skipped. */
61
+ export function testEventState(state) {
62
+ return state === "pass" ? "pass" : state === "fail" ? "fail" : "skip";
63
+ }
64
+ /**
65
+ * `start`, then `warm` on what it returned when given, reporting to `report`, for `file`: `container-starting`,
66
+ * then, once both have ended, `container-started` with the start's `ms` and, when `warm` ran, `warmupMs` and how
67
+ * many services failed (`warmupFailed`). A start that throws reports `ok: false` without warmup fields, and so does a
68
+ * `warm` that throws, which leaves ending the container to `warm`.
69
+ */
70
+ export async function reportedStart(report, file, start, warm, now = Date.now) {
71
+ const startedAt = now();
72
+ report({ kind: "container-starting", file });
73
+ let startMs;
74
+ try {
75
+ const value = await start();
76
+ startMs = now() - startedAt;
77
+ if (warm === undefined) {
78
+ report({ kind: "container-started", file, ms: startMs, ok: true });
79
+ return { value, startMs };
80
+ }
81
+ const warmStartedAt = now();
82
+ const warmup = await warm(value);
83
+ const warmupMs = now() - warmStartedAt;
84
+ const warmupFailed = warmup.services.filter((service) => !service.ok).length;
85
+ report({ kind: "container-started", file, ms: startMs, ok: true, warmupMs, warmupFailed });
86
+ return { value, startMs, warmup: { ms: warmupMs, warmup } };
87
+ }
88
+ catch (error) {
89
+ report({ kind: "container-started", file, ms: startMs ?? now() - startedAt, ok: false });
90
+ throw error;
91
+ }
92
+ }