@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,302 @@
1
+ // The runner recipe, the `runner` key of `storm.config.ts`: what a repository's runner snapshot holds and what
2
+ // each run does on top of it. `checkRecipe` holds the recipe's static rules; `resolveSteps` and `resolveVcpus`
3
+ // evaluate the parts a recipe may give as functions, and check what they return.
4
+ import { parseKeepTime, parseTtl } from "../time/index.js";
5
+ import { RUN_PAYLOAD_VARIABLE } from "../sdk/index.js";
6
+ /** The defaults of a recipe's optional keys. */
7
+ export const RECIPE_DEFAULTS = {
8
+ cwd: ".",
9
+ timeout: "60m",
10
+ baseRefs: ["main", "origin/main"],
11
+ region: "iad1",
12
+ runtime: "node22",
13
+ };
14
+ const RECIPE_KEYS = new Set([
15
+ "name",
16
+ "snapshot",
17
+ "run",
18
+ "cwd",
19
+ "vcpus",
20
+ "env",
21
+ "timeout",
22
+ "keepSandbox",
23
+ "baseRefs",
24
+ "region",
25
+ "runtime",
26
+ ]);
27
+ const SNAPSHOT_KEYS = new Set(["vcpus", "summary", "toolchains", "warm"]);
28
+ const RUN_KEYS = new Set(["install", "build"]);
29
+ const STEP_KEYS = new Set(["label", "script"]);
30
+ const NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
31
+ /**
32
+ * Checks a recipe against its static rules: the keys it may hold and each value's shape. Functions are checked only
33
+ * for being functions; `resolveSteps` and `resolveVcpus` check what they return. Every problem is reported.
34
+ */
35
+ export function checkRecipe(value) {
36
+ const problems = [];
37
+ const report = (path, problem) => problems.push({ path, problem });
38
+ if (!isRecord(value)) {
39
+ report([], `must be an object, not ${describeRecipeValue(value)}`);
40
+ return { ok: false, problems };
41
+ }
42
+ reportUnknownKeys(value, RECIPE_KEYS, [], "a runner recipe key", report);
43
+ const name = value["name"];
44
+ if (typeof name !== "string" || !NAME_PATTERN.test(name))
45
+ report(["name"], `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${describeRecipeValue(name)}`);
46
+ const snapshot = checkSnapshot(value["snapshot"], report);
47
+ const run = checkRun(value["run"], report);
48
+ const cwd = orDefault(value["cwd"], RECIPE_DEFAULTS.cwd);
49
+ if (!isRelativePath(cwd))
50
+ report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeRecipeValue(cwd)}`);
51
+ const vcpus = value["vcpus"];
52
+ if (typeof vcpus !== "function" && !isPositiveInteger(vcpus))
53
+ report(["vcpus"], `must be a positive whole number, or a function of the run's resources, not ${describeRecipeValue(vcpus)}`);
54
+ const env = checkEnv(value["env"], report);
55
+ const timeout = orDefault(value["timeout"], RECIPE_DEFAULTS.timeout);
56
+ const timeoutMinutes = typeof timeout === "string" ? parseTtl(timeout) : undefined;
57
+ if (timeoutMinutes === undefined)
58
+ report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${describeRecipeValue(timeout)}`);
59
+ const keepSandbox = value["keepSandbox"];
60
+ const keepSandboxMinutes = typeof keepSandbox === "string" ? parseKeepTime(keepSandbox) : undefined;
61
+ if (keepSandbox !== undefined && keepSandboxMinutes === undefined)
62
+ report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${describeRecipeValue(keepSandbox)}`);
63
+ const baseRefs = checkBaseRefs(value["baseRefs"], report);
64
+ const region = orDefault(value["region"], RECIPE_DEFAULTS.region);
65
+ if (!isNonEmptyString(region))
66
+ report(["region"], `must be a non-empty string, not ${describeRecipeValue(region)}`);
67
+ const runtime = orDefault(value["runtime"], RECIPE_DEFAULTS.runtime);
68
+ if (!isNonEmptyString(runtime))
69
+ report(["runtime"], `must be a non-empty string, not ${describeRecipeValue(runtime)}`);
70
+ if (problems.length > 0 ||
71
+ snapshot === undefined ||
72
+ run === undefined ||
73
+ env === undefined ||
74
+ baseRefs === undefined ||
75
+ timeoutMinutes === undefined)
76
+ return { ok: false, problems };
77
+ return {
78
+ ok: true,
79
+ value: {
80
+ name: name,
81
+ snapshot,
82
+ run,
83
+ cwd: cwd,
84
+ vcpus: vcpus,
85
+ env,
86
+ timeout: timeout,
87
+ timeoutMinutes,
88
+ keepSandboxMinutes,
89
+ baseRefs,
90
+ region: region,
91
+ runtime: runtime,
92
+ },
93
+ };
94
+ }
95
+ function checkSnapshot(value, report) {
96
+ if (!isRecord(value)) {
97
+ report(["snapshot"], `must be an object of vcpus, toolchains, warm and an optional summary, not ${describeRecipeValue(value)}`);
98
+ return undefined;
99
+ }
100
+ let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a runner recipe snapshot key", report);
101
+ const vcpus = value["vcpus"];
102
+ if (!isPositiveInteger(vcpus)) {
103
+ report(["snapshot", "vcpus"], `must be a positive whole number, not ${describeRecipeValue(vcpus)}`);
104
+ ok = false;
105
+ }
106
+ const summary = value["summary"];
107
+ if (summary !== undefined && !isNonEmptyString(summary)) {
108
+ report(["snapshot", "summary"], `must be a non-empty string, not ${describeRecipeValue(summary)}`);
109
+ ok = false;
110
+ }
111
+ const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], report);
112
+ const warm = checkSteps(value["warm"], ["snapshot", "warm"], report);
113
+ if (!ok || toolchains === undefined || warm === undefined)
114
+ return undefined;
115
+ return {
116
+ vcpus: vcpus,
117
+ ...(summary === undefined ? {} : { summary: summary }),
118
+ toolchains,
119
+ warm,
120
+ };
121
+ }
122
+ function checkRun(value, report) {
123
+ if (!isRecord(value)) {
124
+ report(["run"], `must be an object of install and build steps, not ${describeRecipeValue(value)}`);
125
+ return undefined;
126
+ }
127
+ const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a runner recipe run key", report);
128
+ const install = checkStep(value["install"], ["run", "install"], report);
129
+ const build = checkStep(value["build"], ["run", "build"], report);
130
+ return ok && install !== undefined && build !== undefined ? { install, build } : undefined;
131
+ }
132
+ function checkSteps(value, path, report) {
133
+ if (typeof value === "function")
134
+ return value;
135
+ if (!Array.isArray(value)) {
136
+ report(path, `must be a list of steps, or a function that returns one, not ${describeRecipeValue(value)}`);
137
+ return undefined;
138
+ }
139
+ const steps = value.map((step, index) => checkStep(step, [...path, String(index)], report));
140
+ return steps.every((step) => step !== undefined) ? steps : undefined;
141
+ }
142
+ function checkStep(value, path, report) {
143
+ if (!isRecord(value)) {
144
+ report(path, `must be a step, { label, script }, not ${describeRecipeValue(value)}`);
145
+ return undefined;
146
+ }
147
+ let ok = reportUnknownKeys(value, STEP_KEYS, path, "a step key", report);
148
+ const label = value["label"];
149
+ const script = value["script"];
150
+ if (!isNonEmptyString(label)) {
151
+ report([...path, "label"], `must be a non-empty string, not ${describeRecipeValue(label)}`);
152
+ ok = false;
153
+ }
154
+ if (!isNonEmptyString(script)) {
155
+ report([...path, "script"], `must be a non-empty string, not ${describeRecipeValue(script)}`);
156
+ ok = false;
157
+ }
158
+ return ok ? { label: label, script: script } : undefined;
159
+ }
160
+ function checkEnv(value, report) {
161
+ if (value === undefined)
162
+ return {};
163
+ if (!isRecord(value)) {
164
+ report(["env"], `must be an object of strings, not ${describeRecipeValue(value)}`);
165
+ return undefined;
166
+ }
167
+ let ok = true;
168
+ const env = {};
169
+ for (const [key, variable] of Object.entries(value)) {
170
+ if (key === RUN_PAYLOAD_VARIABLE) {
171
+ report(["env", key], "can't be set: storm sets it for the command");
172
+ ok = false;
173
+ }
174
+ else if (typeof variable !== "string") {
175
+ report(["env", key], `must be a string, not ${describeRecipeValue(variable)}`);
176
+ ok = false;
177
+ }
178
+ else
179
+ env[key] = variable;
180
+ }
181
+ return ok ? env : undefined;
182
+ }
183
+ function checkBaseRefs(value, report) {
184
+ if (value === undefined)
185
+ return [...RECIPE_DEFAULTS.baseRefs];
186
+ if (!Array.isArray(value) || value.length === 0) {
187
+ report(["baseRefs"], `must be a non-empty list of refs, not ${describeRecipeValue(value)}`);
188
+ return undefined;
189
+ }
190
+ let ok = true;
191
+ value.forEach((ref, index) => {
192
+ if (!isNonEmptyString(ref)) {
193
+ report(["baseRefs", String(index)], `must be a non-empty string, not ${describeRecipeValue(ref)}`);
194
+ ok = false;
195
+ }
196
+ });
197
+ return ok ? [...value] : undefined;
198
+ }
199
+ /** Reports each key of `value` not in `known`; whether there were none. */
200
+ function reportUnknownKeys(value, known, path, what, report) {
201
+ let ok = true;
202
+ for (const key of Object.keys(value))
203
+ if (!known.has(key)) {
204
+ report([...path, key], `is not ${what}`);
205
+ ok = false;
206
+ }
207
+ return ok;
208
+ }
209
+ /**
210
+ * What a recipe's steps are at one base: the list as given, or what the function returns for `context`, checked.
211
+ * A function that throws or rejects, or returns anything but a list of steps, is a problem worded to follow the key.
212
+ */
213
+ export async function resolveSteps(steps, context) {
214
+ if (typeof steps !== "function")
215
+ return { ok: true, steps: steps.map(({ label, script }) => ({ label, script })) };
216
+ let returned;
217
+ try {
218
+ returned = await steps(context);
219
+ }
220
+ catch (error) {
221
+ return { ok: false, problem: `threw at base ${context.base.slice(0, 12)}: ${errorMessage(error)}` };
222
+ }
223
+ if (!Array.isArray(returned))
224
+ return { ok: false, problem: `must return a list of steps, not ${describeRecipeValue(returned)}` };
225
+ const problems = [];
226
+ const checked = returned.map((step, index) => checkStep(step, [String(index)], (path, problem) => problems.push({ path, problem })));
227
+ const first = problems[0];
228
+ if (first !== undefined)
229
+ return {
230
+ ok: false,
231
+ problem: `must return a list of { label, script } steps, but item ${first.path.join(".")} ${first.problem}`,
232
+ };
233
+ return { ok: true, steps: checked };
234
+ }
235
+ /**
236
+ * The runner sandbox's vCPUs for a run holding `resources`: the recipe's number, or what its function returns, which
237
+ * must be a positive whole number.
238
+ */
239
+ export function resolveVcpus(recipe, resources) {
240
+ if (typeof recipe.vcpus !== "function")
241
+ return { ok: true, vcpus: recipe.vcpus };
242
+ let returned;
243
+ try {
244
+ returned = recipe.vcpus(resources);
245
+ }
246
+ catch (error) {
247
+ return { ok: false, problem: `threw for ${describeResources(resources)}: ${errorMessage(error)}` };
248
+ }
249
+ return isPositiveInteger(returned)
250
+ ? { ok: true, vcpus: returned }
251
+ : {
252
+ ok: false,
253
+ problem: `must return a positive whole number, not ${describeRecipeValue(returned)} for ${describeResources(resources)}`,
254
+ };
255
+ }
256
+ /**
257
+ * The resources as a problem names them: `1 Testserver sandbox`, `2 Testserver sandboxes`, or `a run without a
258
+ * Testserver pool`.
259
+ */
260
+ function describeResources({ testserverPool }) {
261
+ if (testserverPool === undefined)
262
+ return "a run without a Testserver pool";
263
+ const count = testserverPool.sandboxes;
264
+ return `${count} Testserver ${count === 1 ? "sandbox" : "sandboxes"}`;
265
+ }
266
+ /** A value as a problem names it: a string or number as written, otherwise its kind. */
267
+ function describeRecipeValue(value) {
268
+ if (typeof value === "string")
269
+ return JSON.stringify(value);
270
+ if (typeof value === "number" || typeof value === "boolean")
271
+ return String(value);
272
+ if (value === null)
273
+ return "null";
274
+ if (value === undefined)
275
+ return "undefined";
276
+ if (typeof value === "function")
277
+ return "a function";
278
+ if (Array.isArray(value))
279
+ return value.length === 0 ? "an empty array" : "an array";
280
+ if (typeof value === "object")
281
+ return "an object";
282
+ return `a ${typeof value}`;
283
+ }
284
+ function errorMessage(error) {
285
+ return error instanceof Error ? error.message : String(error);
286
+ }
287
+ /** `value`, or `fallback` when the key is absent or set to `undefined`. A `null` stays, to be refused. */
288
+ function orDefault(value, fallback) {
289
+ return value === undefined ? fallback : value;
290
+ }
291
+ function isRecord(value) {
292
+ return typeof value === "object" && value !== null && !Array.isArray(value);
293
+ }
294
+ function isNonEmptyString(value) {
295
+ return typeof value === "string" && value.length > 0;
296
+ }
297
+ function isPositiveInteger(value) {
298
+ return typeof value === "number" && Number.isInteger(value) && value > 0;
299
+ }
300
+ function isRelativePath(value) {
301
+ return (typeof value === "string" && value.length > 0 && !value.startsWith("/") && !value.split(/[/\\]/).includes(".."));
302
+ }
@@ -0,0 +1,77 @@
1
+ import type { Clock } from "../time/index.ts";
2
+ import type { RunnerFailure, RunnerProgress } from "./events.ts";
3
+ import type { RunnerSandboxGateway, RunnerTerminal } from "./gateways.ts";
4
+ import type { ReadyRunner } from "./ready.ts";
5
+ /**
6
+ * The command as the runner sandbox runs it: each `<repoRoot>/` in its arguments, the executable's included, points
7
+ * at `/vercel/sandbox/`, and a relative executable with a `/` in it resolves against the remote `cwd`.
8
+ */
9
+ export declare function remoteCommand(request: {
10
+ readonly argv: readonly string[];
11
+ readonly repoRoot: string;
12
+ readonly cwd: string;
13
+ }): {
14
+ readonly cmd: string;
15
+ readonly args: readonly string[];
16
+ };
17
+ /**
18
+ * What the command's environment adds to the runner sandbox's own: `PATH` with the remote `cwd`'s and the
19
+ * repository's `node_modules/.bin` before the login shell's, no update checks, color when the local terminal shows
20
+ * it, the recipe's `env`, and `STORM_RUN` last, so nothing overrides it. Nothing comes from the local
21
+ * environment.
22
+ */
23
+ export declare function remoteEnvironment(request: {
24
+ readonly cwd: string;
25
+ readonly loginPath: string;
26
+ readonly color: boolean;
27
+ readonly env: Readonly<Record<string, string>>;
28
+ readonly runPayload: string;
29
+ }): Record<string, string>;
30
+ /** Where the command appends test events in the runner sandbox, which the run payload names. */
31
+ export declare const REMOTE_TEST_EVENTS_PATH = "/tmp/storm-test-events.jsonl";
32
+ /**
33
+ * What a run does with the test events a remote command appends: `onLine` hears each line once, in order;
34
+ * `onIncomplete` hears why the lines handed on may not be all of them, when the final read of the file failed.
35
+ */
36
+ export interface RemoteTestEvents {
37
+ readonly onLine: (line: string) => void;
38
+ readonly onIncomplete: (message: string) => void;
39
+ }
40
+ /**
41
+ * How the remote command ended.
42
+ *
43
+ * - `exited`: it ended with `exitCode`, or none (`null`), after `ms`.
44
+ * - `killed`: `kill` aborted, so it was sent SIGTERM and the run stopped waiting for it.
45
+ * - `failed`: the Sandbox call failed.
46
+ */
47
+ export type RemoteCommandOutcome = {
48
+ readonly kind: "exited";
49
+ readonly exitCode: number | null;
50
+ readonly ms: number;
51
+ } | {
52
+ readonly kind: "killed";
53
+ } | {
54
+ readonly kind: "failed";
55
+ readonly failure: RunnerFailure;
56
+ };
57
+ /**
58
+ * Runs `argv` in the ready runner sandbox with `runPayload` as `STORM_RUN`. Its stdout and stderr reach the
59
+ * terminal's, split into lines per stream with `/vercel/sandbox/` rewritten to the checkout's root, the rest flushed
60
+ * when it ends. Aborting `kill` kills it. With `testEvents`, it follows the test events file at `REMOTE_TEST_EVENTS_PATH`
61
+ * while the command runs, handing each line to `onLine` as it arrives, then, once the command ended on its own, streams
62
+ * the file from the first line not already handed on, which the Sandbox log stream hadn't yet delivered. A read that
63
+ * fails keeps the lines handed on and tells `onIncomplete` why. Following or reading that fails
64
+ * doesn't touch the command.
65
+ */
66
+ export declare function runRemote(context: {
67
+ readonly runnerSandboxes: RunnerSandboxGateway;
68
+ readonly runnerTerminal: RunnerTerminal;
69
+ readonly clock: Clock;
70
+ }, request: {
71
+ readonly runner: ReadyRunner;
72
+ readonly argv: readonly string[];
73
+ readonly runPayload: string;
74
+ readonly testEvents?: RemoteTestEvents;
75
+ }, control: {
76
+ readonly kill: AbortSignal;
77
+ }, progress: RunnerProgress): Promise<RemoteCommandOutcome>;
@@ -0,0 +1,127 @@
1
+ // Running the command in a ready runner sandbox: its argument list with local paths pointed at the sandbox's, its
2
+ // environment, and its output streamed to the terminal a line at a time with the sandbox's paths pointed back here.
3
+ import { posix } from "node:path";
4
+ import { RUN_PAYLOAD_VARIABLE } from "../sdk/index.js";
5
+ import { lineSplitter, rewritePaths, splitLines } from "./output.js";
6
+ import { REMOTE_ROOT } from "./snapshot-key.js";
7
+ import { sandboxApiFailure } from "./steps.js";
8
+ /**
9
+ * The command as the runner sandbox runs it: each `<repoRoot>/` in its arguments, the executable's included, points
10
+ * at `/vercel/sandbox/`, and a relative executable with a `/` in it resolves against the remote `cwd`.
11
+ */
12
+ export function remoteCommand(request) {
13
+ const [first = "", ...rest] = request.argv.map((argument) => rewritePaths(argument, request.repoRoot, REMOTE_ROOT));
14
+ const cmd = first.includes("/") && !first.startsWith("/") ? posix.join(request.cwd, first) : first;
15
+ return { cmd, args: rest };
16
+ }
17
+ /**
18
+ * What the command's environment adds to the runner sandbox's own: `PATH` with the remote `cwd`'s and the
19
+ * repository's `node_modules/.bin` before the login shell's, no update checks, color when the local terminal shows
20
+ * it, the recipe's `env`, and `STORM_RUN` last, so nothing overrides it. Nothing comes from the local
21
+ * environment.
22
+ */
23
+ export function remoteEnvironment(request) {
24
+ const bins = [
25
+ ...new Set([posix.join(request.cwd, "node_modules/.bin"), posix.join(REMOTE_ROOT, "node_modules/.bin")]),
26
+ ];
27
+ return {
28
+ PATH: [...bins, request.loginPath].filter((part) => part !== "").join(":"),
29
+ NO_UPDATE_NOTIFIER: "1",
30
+ ...(request.color ? { FORCE_COLOR: "1" } : { NO_COLOR: "1" }),
31
+ ...request.env,
32
+ [RUN_PAYLOAD_VARIABLE]: request.runPayload,
33
+ };
34
+ }
35
+ /** Where the command appends test events in the runner sandbox, which the run payload names. */
36
+ export const REMOTE_TEST_EVENTS_PATH = "/tmp/storm-test-events.jsonl";
37
+ /**
38
+ * Runs `argv` in the ready runner sandbox with `runPayload` as `STORM_RUN`. Its stdout and stderr reach the
39
+ * terminal's, split into lines per stream with `/vercel/sandbox/` rewritten to the checkout's root, the rest flushed
40
+ * when it ends. Aborting `kill` kills it. With `testEvents`, it follows the test events file at `REMOTE_TEST_EVENTS_PATH`
41
+ * while the command runs, handing each line to `onLine` as it arrives, then, once the command ended on its own, streams
42
+ * the file from the first line not already handed on, which the Sandbox log stream hadn't yet delivered. A read that
43
+ * fails keeps the lines handed on and tells `onIncomplete` why. Following or reading that fails
44
+ * doesn't touch the command.
45
+ */
46
+ export async function runRemote(context, request, control, progress) {
47
+ const { runner } = request;
48
+ const terminal = context.runnerTerminal;
49
+ const command = remoteCommand({ argv: request.argv, repoRoot: runner.repoRoot, cwd: runner.cwd });
50
+ const env = remoteEnvironment({
51
+ cwd: runner.cwd,
52
+ loginPath: runner.loginPath,
53
+ color: terminal.color,
54
+ env: runner.env,
55
+ runPayload: request.runPayload,
56
+ });
57
+ await progress.emit({ kind: "command-output-started", sandbox: runner.sandbox.name, region: runner.region });
58
+ const startedAt = context.clock.now().getTime();
59
+ const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
60
+ const write = (stream, text) => {
61
+ if (text === "")
62
+ return;
63
+ const local = rewritePaths(text, REMOTE_ROOT, runner.repoRoot);
64
+ if (stream === "stdout")
65
+ terminal.writeStdout(local);
66
+ else
67
+ terminal.writeStderr(local);
68
+ };
69
+ const following = followTestEvents(context, runner, request.testEvents, control.kill);
70
+ const ran = await context.runnerSandboxes.runCommand(runner.sandbox, { cmd: command.cmd, args: command.args, cwd: runner.cwd, env }, ({ stream, data }) => write(stream, splitters[stream].push(data)), control.kill);
71
+ // Timed before following the test events winds down and the final read, which outlast the command.
72
+ const ms = context.clock.now().getTime() - startedAt;
73
+ write("stdout", splitters.stdout.flush());
74
+ write("stderr", splitters.stderr.flush());
75
+ await following?.end(ran.ok && !control.kill.aborted);
76
+ if (!ran.ok) {
77
+ if (ran.failure.kind !== "aborted")
78
+ return { kind: "failed", failure: sandboxApiFailure("run-command", ran.failure) };
79
+ await progress.emit({ kind: "command-stopped", command: posix.basename(command.cmd) });
80
+ return { kind: "killed" };
81
+ }
82
+ return { kind: "exited", exitCode: ran.value.exitCode, ms };
83
+ }
84
+ /**
85
+ * Follows the test events file in `runner`'s sandbox, handing each whole line to `onLine`. `end` stops following; when
86
+ * the command ended on its own (`complete`), it then streams the file from the line after the count already handed on,
87
+ * since the file is only appended to. The last line may lack its newline. Without the read, as when the run was killed,
88
+ * it hands on what following left. A failed read hands on the last partial line it had; a failed read, not one `kill`
89
+ * aborted, also tells `onIncomplete` why.
90
+ */
91
+ function followTestEvents(context, runner, testEvents, kill) {
92
+ if (testEvents === undefined)
93
+ return undefined;
94
+ const stop = new AbortController();
95
+ const splitter = lineSplitter();
96
+ let handed = 0;
97
+ const hand = (lines) => {
98
+ for (const line of lines) {
99
+ handed += 1;
100
+ testEvents.onLine(line);
101
+ }
102
+ };
103
+ const followed = context.runnerSandboxes.followTestEvents(runner.sandbox, { path: REMOTE_TEST_EVENTS_PATH }, ({ data }) => hand(splitLines(splitter.push(data))), stop.signal);
104
+ return {
105
+ async end(complete) {
106
+ stop.abort();
107
+ await followed;
108
+ if (!complete) {
109
+ hand(splitLines(splitter.flush()));
110
+ return;
111
+ }
112
+ const reader = lineSplitter();
113
+ let read = false;
114
+ const result = await context.runnerSandboxes.readTestEvents(runner.sandbox, { path: REMOTE_TEST_EVENTS_PATH, fromLine: handed + 1 }, ({ data }) => {
115
+ if (!read) {
116
+ // What following left is the start of the next line, which the read holds whole.
117
+ splitter.flush();
118
+ read = true;
119
+ }
120
+ hand(splitLines(reader.push(data)));
121
+ }, kill);
122
+ hand(splitLines(read ? reader.flush() : splitter.flush()));
123
+ if (!result.ok && result.failure.kind === "api")
124
+ testEvents.onIncomplete(result.failure.message);
125
+ },
126
+ };
127
+ }
@@ -0,0 +1,58 @@
1
+ import type { Clock, Timer } from "../time/index.ts";
2
+ import type { KeptSandbox, NotDeletedSandbox, NotKeptSandbox, NotStoppedSandbox, RunnerProgress } from "./events.ts";
3
+ import type { RunnerSandbox, RunnerSandboxGateway, RunnerSandboxPlacement, RunnerSandboxResult, RunnerStartFailure, SandboxAccess, SavedSnapshot } from "./gateways.ts";
4
+ /** How long closing waits for a create in flight: 20 seconds. */
5
+ export declare const CREATE_SETTLE_MS = 20000;
6
+ /** How long closing waits for a runner snapshot still saving: 2 minutes. */
7
+ export declare const SNAPSHOT_SETTLE_MS: number;
8
+ /**
9
+ * What closing a scope left: the runner sandbox it kept running (`kept`), or couldn't keep running and so stopped and
10
+ * deleted (`notKept`), each null otherwise, and the sandboxes it couldn't stop or delete.
11
+ */
12
+ export interface RunnerScopeReport {
13
+ readonly kept: KeptSandbox | null;
14
+ readonly notKept: NotKeptSandbox | null;
15
+ readonly notStopped: readonly NotStoppedSandbox[];
16
+ readonly notDeleted: readonly NotDeletedSandbox[];
17
+ }
18
+ /**
19
+ * Starts sandboxes and saves runner snapshots on the scope's behalf, so `close` knows about every one. A start once
20
+ * closing has begun answers `aborted` and creates nothing. A start in flight is never aborted: an aborted create
21
+ * could still leave a sandbox the scope never hears of, so closing waits for it instead, and stops and deletes the
22
+ * sandbox it returns.
23
+ */
24
+ export interface RunnerSandboxScope {
25
+ /** Whether closing has begun. */
26
+ readonly closed: boolean;
27
+ startBuildSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
28
+ readonly runtime: string;
29
+ }): Promise<RunnerSandboxResult<RunnerSandbox>>;
30
+ startRunnerSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
31
+ readonly snapshotId: string;
32
+ }): Promise<RunnerSandboxResult<RunnerSandbox, RunnerStartFailure>>;
33
+ /** Saves a build sandbox as a runner snapshot, then deletes it at once; a failed save leaves it to `close`. */
34
+ saveSnapshot(sandbox: RunnerSandbox, request: {
35
+ readonly expirationMs: number;
36
+ }): Promise<RunnerSandboxResult<SavedSnapshot>>;
37
+ /**
38
+ * Waits up to `CREATE_SETTLE_MS` for creates in flight and up to `SNAPSHOT_SETTLE_MS` for a snapshot saving, then
39
+ * stops and deletes every sandbox the scope holds, but for the runner sandbox when the keep time is above 0: that one
40
+ * it keeps running at least the keep time from now, with nothing the run started still running in it, reporting
41
+ * `sandbox-kept`, or stops and deletes when it can't. A
42
+ * create that ends after closing began is stopped and deleted when it ends. Calling it again answers the first
43
+ * call's report.
44
+ */
45
+ close(): Promise<RunnerScopeReport>;
46
+ }
47
+ /**
48
+ * A scope over `context.runnerSandboxes`, waiting with `context.timer` and reporting to `progress`, which keeps the
49
+ * runner sandbox running `keepMs` past closing (`context.clock` says when that is), or stops and deletes it with the
50
+ * rest when `keepMs` is 0.
51
+ */
52
+ export declare function runnerSandboxScope(context: {
53
+ readonly runnerSandboxes: RunnerSandboxGateway;
54
+ readonly timer: Timer;
55
+ readonly clock: Clock;
56
+ }, progress: RunnerProgress, keep: {
57
+ readonly keepMs: number;
58
+ }): RunnerSandboxScope;
@@ -0,0 +1,117 @@
1
+ // The sandbox scope: owns every sandbox one run creates, so however the run ends, each one is stopped and deleted, but
2
+ // for the runner sandbox, which it keeps running for the run's keep time when that is above 0, so a person can connect
3
+ // to it. Closing waits briefly for work in flight first: a create, so the sandbox it returns doesn't outlive the run
4
+ // until its timeout, and a snapshot save, so the build isn't thrown away.
5
+ /** How long closing waits for a create in flight: 20 seconds. */
6
+ export const CREATE_SETTLE_MS = 20_000;
7
+ /** How long closing waits for a runner snapshot still saving: 2 minutes. */
8
+ export const SNAPSHOT_SETTLE_MS = 2 * 60_000;
9
+ /**
10
+ * A scope over `context.runnerSandboxes`, waiting with `context.timer` and reporting to `progress`, which keeps the
11
+ * runner sandbox running `keepMs` past closing (`context.clock` says when that is), or stops and deletes it with the
12
+ * rest when `keepMs` is 0.
13
+ */
14
+ export function runnerSandboxScope(context, progress, keep) {
15
+ const { runnerSandboxes: sandboxes, timer, clock } = context;
16
+ const live = new Set();
17
+ const creating = new Set();
18
+ const saving = new Set();
19
+ const notStopped = [];
20
+ const notDeleted = [];
21
+ let kept = null;
22
+ let notKept = null;
23
+ let closing;
24
+ const track = (set, task) => {
25
+ set.add(task);
26
+ const forget = () => set.delete(task);
27
+ void task.then(forget, forget);
28
+ return task;
29
+ };
30
+ const remove = async (sandbox) => {
31
+ const deleted = await sandboxes.delete(sandbox);
32
+ if (!deleted.ok)
33
+ notDeleted.push({ name: sandbox.name, role: sandbox.role, message: failureMessage(deleted.failure) });
34
+ };
35
+ const stopAndRemove = async (sandbox) => {
36
+ const stopped = await sandboxes.stop(sandbox);
37
+ if (!stopped.ok) {
38
+ notStopped.push({
39
+ name: sandbox.name,
40
+ role: sandbox.role,
41
+ timeoutMinutes: Math.round(sandbox.timeoutMs / 60_000),
42
+ message: failureMessage(stopped.failure),
43
+ });
44
+ return;
45
+ }
46
+ await remove(sandbox);
47
+ };
48
+ /**
49
+ * Keeps the runner sandbox running `keepMs` from now, once the gateway saw every process the run started in it end;
50
+ * when it can't, such as with a process that won't end, stops and deletes it as without a keep time.
51
+ */
52
+ const keepOrRemove = async (sandbox) => {
53
+ if (sandbox.role !== "runner" || keep.keepMs <= 0)
54
+ return await stopAndRemove(sandbox);
55
+ const keeping = await sandboxes.keepRunning(sandbox, { until: new Date(clock.now().getTime() + keep.keepMs) });
56
+ if (!keeping.ok) {
57
+ notKept = { name: sandbox.name, message: failureMessage(keeping.failure) };
58
+ return await stopAndRemove(sandbox);
59
+ }
60
+ kept = { name: sandbox.name, stopsAt: keeping.value.stopsAt.toISOString() };
61
+ await progress.emit({ kind: "sandbox-kept", ...kept });
62
+ };
63
+ const owned = (start) => {
64
+ if (closing !== undefined)
65
+ return Promise.resolve({ ok: false, failure: { kind: "aborted" } });
66
+ return track(creating, (async () => {
67
+ const started = await start();
68
+ if (!started.ok)
69
+ return started;
70
+ if (closing !== undefined) {
71
+ await stopAndRemove(started.value);
72
+ return { ok: false, failure: { kind: "aborted" } };
73
+ }
74
+ live.add(started.value);
75
+ return started;
76
+ })());
77
+ };
78
+ return {
79
+ get closed() {
80
+ return closing !== undefined;
81
+ },
82
+ startBuildSandbox: (access, request) => owned(() => sandboxes.startBuildSandbox(access, request)),
83
+ startRunnerSandbox: (access, request) => owned(() => sandboxes.startRunnerSandbox(access, request)),
84
+ saveSnapshot: (sandbox, request) => track(saving, (async () => {
85
+ const saved = await sandboxes.saveSnapshot(sandbox, request);
86
+ if (saved.ok && live.delete(sandbox))
87
+ await remove(sandbox);
88
+ return saved;
89
+ })()),
90
+ close() {
91
+ closing ??= (async () => {
92
+ if (saving.size > 0)
93
+ await progress.emit({ kind: "waiting-for-snapshot", settleMs: SNAPSHOT_SETTLE_MS });
94
+ await Promise.all([
95
+ settleWithin(timer, creating, CREATE_SETTLE_MS),
96
+ settleWithin(timer, saving, SNAPSHOT_SETTLE_MS),
97
+ ]);
98
+ const held = [...live];
99
+ live.clear();
100
+ await Promise.all(held.map(keepOrRemove));
101
+ return { kept, notKept, notStopped: [...notStopped], notDeleted: [...notDeleted] };
102
+ })();
103
+ return closing;
104
+ },
105
+ };
106
+ }
107
+ /** Waits until every task in `tasks` has settled, or `ms` has passed, whichever comes first. */
108
+ async function settleWithin(timer, tasks, ms) {
109
+ if (tasks.size === 0)
110
+ return;
111
+ const done = new AbortController();
112
+ await Promise.race([Promise.allSettled(tasks), timer.sleep(ms, done.signal)]);
113
+ done.abort();
114
+ }
115
+ function failureMessage(failure) {
116
+ return failure.message ?? failure.kind;
117
+ }