@cnc-tools/storm 0.0.0 → 0.5.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 (513) 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/run/cleanup.d.ts +135 -0
  15. package/dist/commands/run/cleanup.js +171 -0
  16. package/dist/commands/run/command.d.ts +327 -0
  17. package/dist/commands/run/command.js +620 -0
  18. package/dist/commands/run/job-summary.d.ts +6 -0
  19. package/dist/commands/run/job-summary.js +31 -0
  20. package/dist/commands/run/live-view.d.ts +22 -0
  21. package/dist/commands/run/live-view.js +395 -0
  22. package/dist/commands/run/metadata.d.ts +47 -0
  23. package/dist/commands/run/metadata.js +83 -0
  24. package/dist/commands/run/mint-failed.d.ts +11 -0
  25. package/dist/commands/run/mint-failed.js +33 -0
  26. package/dist/commands/run/outcomes.d.ts +307 -0
  27. package/dist/commands/run/outcomes.js +332 -0
  28. package/dist/commands/run/progress.d.ts +44 -0
  29. package/dist/commands/run/progress.js +277 -0
  30. package/dist/commands/run/redaction.d.ts +15 -0
  31. package/dist/commands/run/redaction.js +40 -0
  32. package/dist/commands/run/run-collector.d.ts +30 -0
  33. package/dist/commands/run/run-collector.js +73 -0
  34. package/dist/commands/run/run-record.d.ts +144 -0
  35. package/dist/commands/run/run-record.js +96 -0
  36. package/dist/commands/run/tests-summary.d.ts +34 -0
  37. package/dist/commands/run/tests-summary.js +141 -0
  38. package/dist/commands/run/text.d.ts +22 -0
  39. package/dist/commands/run/text.js +74 -0
  40. package/dist/commands/run/view.d.ts +35 -0
  41. package/dist/commands/run/view.js +163 -0
  42. package/dist/commands/run/waterfall.d.ts +25 -0
  43. package/dist/commands/run/waterfall.js +108 -0
  44. package/dist/commands/run/worker-chart.d.ts +79 -0
  45. package/dist/commands/run/worker-chart.js +313 -0
  46. package/dist/commands/runs/facts.d.ts +150 -0
  47. package/dist/commands/runs/facts.js +292 -0
  48. package/dist/commands/runs/list/command.d.ts +86 -0
  49. package/dist/commands/runs/list/command.js +36 -0
  50. package/dist/commands/runs/list/metadata.d.ts +22 -0
  51. package/dist/commands/runs/list/metadata.js +19 -0
  52. package/dist/commands/runs/list/outcomes.d.ts +74 -0
  53. package/dist/commands/runs/list/outcomes.js +89 -0
  54. package/dist/commands/runs/logs/command.d.ts +72 -0
  55. package/dist/commands/runs/logs/command.js +51 -0
  56. package/dist/commands/runs/logs/metadata.d.ts +22 -0
  57. package/dist/commands/runs/logs/metadata.js +22 -0
  58. package/dist/commands/runs/logs/outcomes.d.ts +55 -0
  59. package/dist/commands/runs/logs/outcomes.js +77 -0
  60. package/dist/commands/runs/metadata.d.ts +3 -0
  61. package/dist/commands/runs/metadata.js +3 -0
  62. package/dist/commands/runs/past-run.d.ts +72 -0
  63. package/dist/commands/runs/past-run.js +99 -0
  64. package/dist/commands/runs/show/command.d.ts +176 -0
  65. package/dist/commands/runs/show/command.js +76 -0
  66. package/dist/commands/runs/show/metadata.d.ts +25 -0
  67. package/dist/commands/runs/show/metadata.js +22 -0
  68. package/dist/commands/runs/show/outcomes.d.ts +164 -0
  69. package/dist/commands/runs/show/outcomes.js +317 -0
  70. package/dist/config/by-name.d.ts +24 -0
  71. package/dist/config/by-name.js +26 -0
  72. package/dist/config/errors.d.ts +58 -0
  73. package/dist/config/errors.js +101 -0
  74. package/dist/config/gateways.d.ts +32 -0
  75. package/dist/config/gateways.js +1 -0
  76. package/dist/config/index.d.ts +9 -0
  77. package/dist/config/index.js +12 -0
  78. package/dist/config/live/config-gateway.d.ts +6 -0
  79. package/dist/config/live/config-gateway.js +71 -0
  80. package/dist/config/load.d.ts +54 -0
  81. package/dist/config/load.js +175 -0
  82. package/dist/config/resolve.d.ts +49 -0
  83. package/dist/config/resolve.js +94 -0
  84. package/dist/config/resource-config.d.ts +132 -0
  85. package/dist/config/resource-config.js +19 -0
  86. package/dist/config/schema.d.ts +64 -0
  87. package/dist/config/schema.js +57 -0
  88. package/dist/config/set.d.ts +16 -0
  89. package/dist/config/set.js +55 -0
  90. package/dist/config/settings-file.d.ts +41 -0
  91. package/dist/config/settings-file.js +72 -0
  92. package/dist/config-file/define.d.ts +37 -0
  93. package/dist/config-file/define.js +9 -0
  94. package/dist/config-file/toolchain.d.ts +9 -0
  95. package/dist/config-file/toolchain.js +41 -0
  96. package/dist/context.d.ts +86 -0
  97. package/dist/context.js +43 -0
  98. package/dist/core/command-provider.d.ts +126 -0
  99. package/dist/core/command-provider.js +13 -0
  100. package/dist/core/command-slots.d.ts +67 -0
  101. package/dist/core/command-slots.js +136 -0
  102. package/dist/core/events.d.ts +128 -0
  103. package/dist/core/events.js +15 -0
  104. package/dist/core/gateways.d.ts +249 -0
  105. package/dist/core/gateways.js +1 -0
  106. package/dist/core/index.d.ts +20 -0
  107. package/dist/core/index.js +18 -0
  108. package/dist/core/keyed.d.ts +12 -0
  109. package/dist/core/keyed.js +24 -0
  110. package/dist/core/lane.d.ts +46 -0
  111. package/dist/core/lane.js +5 -0
  112. package/dist/core/limit.d.ts +9 -0
  113. package/dist/core/limit.js +29 -0
  114. package/dist/core/live/command-gateway.d.ts +11 -0
  115. package/dist/core/live/command-gateway.js +83 -0
  116. package/dist/core/live/job-summary-gateway.d.ts +5 -0
  117. package/dist/core/live/job-summary-gateway.js +20 -0
  118. package/dist/core/live/progress-terminal.d.ts +20 -0
  119. package/dist/core/live/progress-terminal.js +173 -0
  120. package/dist/core/live/run-directory-gateway.d.ts +24 -0
  121. package/dist/core/live/run-directory-gateway.js +437 -0
  122. package/dist/core/mint.d.ts +10 -0
  123. package/dist/core/mint.js +14 -0
  124. package/dist/core/payload.d.ts +26 -0
  125. package/dist/core/payload.js +33 -0
  126. package/dist/core/presentation.d.ts +87 -0
  127. package/dist/core/presentation.js +5 -0
  128. package/dist/core/presentations.d.ts +56 -0
  129. package/dist/core/presentations.js +66 -0
  130. package/dist/core/provider.d.ts +69 -0
  131. package/dist/core/provider.js +5 -0
  132. package/dist/core/resource.d.ts +262 -0
  133. package/dist/core/resource.js +6 -0
  134. package/dist/core/resources.d.ts +131 -0
  135. package/dist/core/resources.js +254 -0
  136. package/dist/core/run-directory.d.ts +69 -0
  137. package/dist/core/run-directory.js +94 -0
  138. package/dist/core/run-state.d.ts +152 -0
  139. package/dist/core/run-state.js +313 -0
  140. package/dist/core/run.d.ts +187 -0
  141. package/dist/core/run.js +321 -0
  142. package/dist/core/state-directory.d.ts +19 -0
  143. package/dist/core/state-directory.js +29 -0
  144. package/dist/core/timeline.d.ts +63 -0
  145. package/dist/core/timeline.js +97 -0
  146. package/dist/core/timing.d.ts +22 -0
  147. package/dist/core/timing.js +26 -0
  148. package/dist/credential/credential.d.ts +46 -0
  149. package/dist/credential/credential.js +80 -0
  150. package/dist/credential/diagnosis.d.ts +18 -0
  151. package/dist/credential/diagnosis.js +99 -0
  152. package/dist/credential/gateways.d.ts +109 -0
  153. package/dist/credential/gateways.js +1 -0
  154. package/dist/credential/index.d.ts +7 -0
  155. package/dist/credential/index.js +7 -0
  156. package/dist/credential/live/github-actions-token-gateway.d.ts +15 -0
  157. package/dist/credential/live/github-actions-token-gateway.js +43 -0
  158. package/dist/credential/live/github-actions-token-response.d.ts +19 -0
  159. package/dist/credential/live/github-actions-token-response.js +49 -0
  160. package/dist/credential/live/vercel-cli-gateway.d.ts +9 -0
  161. package/dist/credential/live/vercel-cli-gateway.js +64 -0
  162. package/dist/credential/live/vercel-output.d.ts +60 -0
  163. package/dist/credential/live/vercel-output.js +122 -0
  164. package/dist/credential/live/vercel-process.d.ts +14 -0
  165. package/dist/credential/live/vercel-process.js +3 -0
  166. package/dist/credential/settle.d.ts +31 -0
  167. package/dist/credential/settle.js +49 -0
  168. package/dist/credential/source.d.ts +110 -0
  169. package/dist/credential/source.js +114 -0
  170. package/dist/help-logo.d.ts +11 -0
  171. package/dist/help-logo.js +56 -0
  172. package/dist/presentation.d.ts +26 -0
  173. package/dist/presentation.js +21 -0
  174. package/dist/resources/github/cleanup.d.ts +23 -0
  175. package/dist/resources/github/cleanup.js +39 -0
  176. package/dist/resources/github/command.d.ts +74 -0
  177. package/dist/resources/github/command.js +117 -0
  178. package/dist/resources/github/config.d.ts +16 -0
  179. package/dist/resources/github/config.js +37 -0
  180. package/dist/resources/github/events.d.ts +26 -0
  181. package/dist/resources/github/events.js +2 -0
  182. package/dist/resources/github/fixture-repo.d.ts +69 -0
  183. package/dist/resources/github/fixture-repo.js +60 -0
  184. package/dist/resources/github/gateways.d.ts +62 -0
  185. package/dist/resources/github/gateways.js +1 -0
  186. package/dist/resources/github/index.d.ts +12 -0
  187. package/dist/resources/github/index.js +15 -0
  188. package/dist/resources/github/live/fixture-repo-gateway.d.ts +12 -0
  189. package/dist/resources/github/live/fixture-repo-gateway.js +92 -0
  190. package/dist/resources/github/live/gateways.d.ts +6 -0
  191. package/dist/resources/github/live/gateways.js +13 -0
  192. package/dist/resources/github/presentation.d.ts +13 -0
  193. package/dist/resources/github/presentation.js +43 -0
  194. package/dist/resources/github/provider.d.ts +66 -0
  195. package/dist/resources/github/provider.js +58 -0
  196. package/dist/resources/github/resource-provider.d.ts +6 -0
  197. package/dist/resources/github/resource-provider.js +20 -0
  198. package/dist/resources/github/resource.d.ts +33 -0
  199. package/dist/resources/github/resource.js +12 -0
  200. package/dist/resources/testserver/cleanup.d.ts +14 -0
  201. package/dist/resources/testserver/cleanup.js +22 -0
  202. package/dist/resources/testserver/command.d.ts +322 -0
  203. package/dist/resources/testserver/command.js +245 -0
  204. package/dist/resources/testserver/commands/app.d.ts +18 -0
  205. package/dist/resources/testserver/commands/app.js +3 -0
  206. package/dist/resources/testserver/commands/create/command.d.ts +136 -0
  207. package/dist/resources/testserver/commands/create/command.js +158 -0
  208. package/dist/resources/testserver/commands/create/metadata.d.ts +31 -0
  209. package/dist/resources/testserver/commands/create/metadata.js +45 -0
  210. package/dist/resources/testserver/commands/create/outcomes.d.ts +111 -0
  211. package/dist/resources/testserver/commands/create/outcomes.js +172 -0
  212. package/dist/resources/testserver/commands/list/command.d.ts +60 -0
  213. package/dist/resources/testserver/commands/list/command.js +56 -0
  214. package/dist/resources/testserver/commands/list/metadata.d.ts +9 -0
  215. package/dist/resources/testserver/commands/list/metadata.js +9 -0
  216. package/dist/resources/testserver/commands/list/outcomes.d.ts +54 -0
  217. package/dist/resources/testserver/commands/list/outcomes.js +152 -0
  218. package/dist/resources/testserver/config.d.ts +18 -0
  219. package/dist/resources/testserver/config.js +77 -0
  220. package/dist/resources/testserver/credential-facts.d.ts +80 -0
  221. package/dist/resources/testserver/credential-facts.js +83 -0
  222. package/dist/resources/testserver/events.d.ts +59 -0
  223. package/dist/resources/testserver/events.js +4 -0
  224. package/dist/resources/testserver/index.d.ts +16 -0
  225. package/dist/resources/testserver/index.js +24 -0
  226. package/dist/resources/testserver/lane.d.ts +28 -0
  227. package/dist/resources/testserver/lane.js +139 -0
  228. package/dist/resources/testserver/live/gateways.d.ts +6 -0
  229. package/dist/resources/testserver/live/gateways.js +26 -0
  230. package/dist/resources/testserver/options.d.ts +5 -0
  231. package/dist/resources/testserver/options.js +5 -0
  232. package/dist/resources/testserver/pool/channels.d.ts +80 -0
  233. package/dist/resources/testserver/pool/channels.js +48 -0
  234. package/dist/resources/testserver/pool/create.d.ts +48 -0
  235. package/dist/resources/testserver/pool/create.js +45 -0
  236. package/dist/resources/testserver/pool/directory.d.ts +4 -0
  237. package/dist/resources/testserver/pool/directory.js +5 -0
  238. package/dist/resources/testserver/pool/gateways.d.ts +190 -0
  239. package/dist/resources/testserver/pool/gateways.js +1 -0
  240. package/dist/resources/testserver/pool/host.d.ts +8 -0
  241. package/dist/resources/testserver/pool/host.js +21 -0
  242. package/dist/resources/testserver/pool/index.d.ts +9 -0
  243. package/dist/resources/testserver/pool/index.js +10 -0
  244. package/dist/resources/testserver/pool/inspect.d.ts +53 -0
  245. package/dist/resources/testserver/pool/inspect.js +45 -0
  246. package/dist/resources/testserver/pool/lease.d.ts +84 -0
  247. package/dist/resources/testserver/pool/lease.js +125 -0
  248. package/dist/resources/testserver/pool/live/pool-records.d.ts +17 -0
  249. package/dist/resources/testserver/pool/live/pool-records.js +70 -0
  250. package/dist/resources/testserver/pool/live/pool-store-gateway.d.ts +12 -0
  251. package/dist/resources/testserver/pool/live/pool-store-gateway.js +435 -0
  252. package/dist/resources/testserver/pool/staleness.d.ts +16 -0
  253. package/dist/resources/testserver/pool/staleness.js +27 -0
  254. package/dist/resources/testserver/presentation.d.ts +9 -0
  255. package/dist/resources/testserver/presentation.js +217 -0
  256. package/dist/resources/testserver/provider.d.ts +177 -0
  257. package/dist/resources/testserver/provider.js +254 -0
  258. package/dist/resources/testserver/ran.d.ts +87 -0
  259. package/dist/resources/testserver/ran.js +140 -0
  260. package/dist/resources/testserver/resource-provider.d.ts +12 -0
  261. package/dist/resources/testserver/resource-provider.js +38 -0
  262. package/dist/resources/testserver/resource.d.ts +32 -0
  263. package/dist/resources/testserver/resource.js +10 -0
  264. package/dist/resources/testserver/run-sandbox.d.ts +13 -0
  265. package/dist/resources/testserver/run-sandbox.js +6 -0
  266. package/dist/resources/testserver/sandbox/channels.d.ts +12 -0
  267. package/dist/resources/testserver/sandbox/channels.js +21 -0
  268. package/dist/resources/testserver/sandbox/create-failure.d.ts +35 -0
  269. package/dist/resources/testserver/sandbox/create-failure.js +65 -0
  270. package/dist/resources/testserver/sandbox/create.d.ts +29 -0
  271. package/dist/resources/testserver/sandbox/create.js +37 -0
  272. package/dist/resources/testserver/sandbox/gateways.d.ts +150 -0
  273. package/dist/resources/testserver/sandbox/gateways.js +1 -0
  274. package/dist/resources/testserver/sandbox/index.d.ts +6 -0
  275. package/dist/resources/testserver/sandbox/index.js +7 -0
  276. package/dist/resources/testserver/sandbox/live/builds-response.d.ts +9 -0
  277. package/dist/resources/testserver/sandbox/live/builds-response.js +27 -0
  278. package/dist/resources/testserver/sandbox/live/control-plane-gateway.d.ts +17 -0
  279. package/dist/resources/testserver/sandbox/live/control-plane-gateway.js +133 -0
  280. package/dist/resources/testserver/sandbox/live/create-response.d.ts +35 -0
  281. package/dist/resources/testserver/sandbox/live/create-response.js +78 -0
  282. package/dist/resources/testserver/sandbox/live/fetch-failure.d.ts +24 -0
  283. package/dist/resources/testserver/sandbox/live/fetch-failure.js +45 -0
  284. package/dist/resources/testserver/sandbox/live/health-check-gateway.d.ts +11 -0
  285. package/dist/resources/testserver/sandbox/live/health-check-gateway.js +36 -0
  286. package/dist/resources/testserver/sandbox/live/sse.d.ts +12 -0
  287. package/dist/resources/testserver/sandbox/live/sse.js +32 -0
  288. package/dist/resources.d.ts +452 -0
  289. package/dist/resources.js +88 -0
  290. package/dist/runner/base.d.ts +40 -0
  291. package/dist/runner/base.js +52 -0
  292. package/dist/runner/context.d.ts +13 -0
  293. package/dist/runner/context.js +9 -0
  294. package/dist/runner/events.d.ts +179 -0
  295. package/dist/runner/events.js +16 -0
  296. package/dist/runner/gateways.d.ts +351 -0
  297. package/dist/runner/gateways.js +3 -0
  298. package/dist/runner/index.d.ts +19 -0
  299. package/dist/runner/index.js +18 -0
  300. package/dist/runner/live/checkout-gateway.d.ts +3 -0
  301. package/dist/runner/live/checkout-gateway.js +206 -0
  302. package/dist/runner/live/git-output.d.ts +14 -0
  303. package/dist/runner/live/git-output.js +32 -0
  304. package/dist/runner/live/sandbox-errors.d.ts +7 -0
  305. package/dist/runner/live/sandbox-errors.js +21 -0
  306. package/dist/runner/live/sandbox-gateway.d.ts +7 -0
  307. package/dist/runner/live/sandbox-gateway.js +427 -0
  308. package/dist/runner/live/snapshot-cache-gateway.d.ts +12 -0
  309. package/dist/runner/live/snapshot-cache-gateway.js +104 -0
  310. package/dist/runner/live/snapshot-records.d.ts +11 -0
  311. package/dist/runner/live/snapshot-records.js +57 -0
  312. package/dist/runner/live/terminal.d.ts +16 -0
  313. package/dist/runner/live/terminal.js +37 -0
  314. package/dist/runner/live/user.d.ts +2 -0
  315. package/dist/runner/live/user.js +11 -0
  316. package/dist/runner/output.d.ts +23 -0
  317. package/dist/runner/output.js +58 -0
  318. package/dist/runner/prepare.d.ts +67 -0
  319. package/dist/runner/prepare.js +59 -0
  320. package/dist/runner/ready.d.ts +68 -0
  321. package/dist/runner/ready.js +159 -0
  322. package/dist/runner/recipe.d.ts +126 -0
  323. package/dist/runner/recipe.js +302 -0
  324. package/dist/runner/remote-command.d.ts +77 -0
  325. package/dist/runner/remote-command.js +127 -0
  326. package/dist/runner/scope.d.ts +58 -0
  327. package/dist/runner/scope.js +117 -0
  328. package/dist/runner/snapshot-build.d.ts +33 -0
  329. package/dist/runner/snapshot-build.js +112 -0
  330. package/dist/runner/snapshot-cache.d.ts +84 -0
  331. package/dist/runner/snapshot-cache.js +126 -0
  332. package/dist/runner/snapshot-key.d.ts +52 -0
  333. package/dist/runner/snapshot-key.js +91 -0
  334. package/dist/runner/steps.d.ts +41 -0
  335. package/dist/runner/steps.js +49 -0
  336. package/dist/sdk/container/api-request.d.ts +32 -0
  337. package/dist/sdk/container/api-request.js +46 -0
  338. package/dist/sdk/container/container.d.ts +144 -0
  339. package/dist/sdk/container/container.js +346 -0
  340. package/dist/sdk/container/feature-flags.d.ts +37 -0
  341. package/dist/sdk/container/feature-flags.js +118 -0
  342. package/dist/sdk/container/gateways.d.ts +108 -0
  343. package/dist/sdk/container/gateways.js +1 -0
  344. package/dist/sdk/container/index.d.ts +5 -0
  345. package/dist/sdk/container/index.js +5 -0
  346. package/dist/sdk/container/live/container-gateway.d.ts +17 -0
  347. package/dist/sdk/container/live/container-gateway.js +114 -0
  348. package/dist/sdk/factories/build.d.ts +66 -0
  349. package/dist/sdk/factories/build.js +98 -0
  350. package/dist/sdk/factories/definition.d.ts +28 -0
  351. package/dist/sdk/factories/definition.js +16 -0
  352. package/dist/sdk/factories/definitions.d.ts +166 -0
  353. package/dist/sdk/factories/definitions.js +235 -0
  354. package/dist/sdk/factories/gateways.d.ts +25 -0
  355. package/dist/sdk/factories/gateways.js +1 -0
  356. package/dist/sdk/factories/index.d.ts +5 -0
  357. package/dist/sdk/factories/index.js +5 -0
  358. package/dist/sdk/factories/live/factory-gateway.d.ts +10 -0
  359. package/dist/sdk/factories/live/factory-gateway.js +29 -0
  360. package/dist/sdk/index.d.ts +7 -0
  361. package/dist/sdk/index.js +15 -0
  362. package/dist/sdk/payload/index.d.ts +2 -0
  363. package/dist/sdk/payload/index.js +4 -0
  364. package/dist/sdk/payload/payload.d.ts +47 -0
  365. package/dist/sdk/payload/payload.js +74 -0
  366. package/dist/sdk/payload/test-events.d.ts +102 -0
  367. package/dist/sdk/payload/test-events.js +59 -0
  368. package/dist/sdk/proxy/exchange.d.ts +58 -0
  369. package/dist/sdk/proxy/exchange.js +173 -0
  370. package/dist/sdk/proxy/faulted-exchange.d.ts +10 -0
  371. package/dist/sdk/proxy/faulted-exchange.js +106 -0
  372. package/dist/sdk/proxy/faults.d.ts +133 -0
  373. package/dist/sdk/proxy/faults.js +147 -0
  374. package/dist/sdk/proxy/index.d.ts +3 -0
  375. package/dist/sdk/proxy/index.js +3 -0
  376. package/dist/sdk/proxy/proxy.d.ts +93 -0
  377. package/dist/sdk/proxy/proxy.js +99 -0
  378. package/dist/sdk/proxy/records.d.ts +56 -0
  379. package/dist/sdk/proxy/records.js +56 -0
  380. package/dist/sdk/records/body.d.ts +89 -0
  381. package/dist/sdk/records/body.js +236 -0
  382. package/dist/sdk/records/index.d.ts +2 -0
  383. package/dist/sdk/records/index.js +4 -0
  384. package/dist/sdk/records/records.d.ts +49 -0
  385. package/dist/sdk/records/records.js +16 -0
  386. package/dist/sdk/seed/index.d.ts +1 -0
  387. package/dist/sdk/seed/index.js +3 -0
  388. package/dist/sdk/seed/seed.d.ts +221 -0
  389. package/dist/sdk/seed/seed.js +171 -0
  390. package/dist/sdk/testserver/clock.d.ts +8 -0
  391. package/dist/sdk/testserver/clock.js +10 -0
  392. package/dist/sdk/testserver/failure.d.ts +73 -0
  393. package/dist/sdk/testserver/failure.js +61 -0
  394. package/dist/sdk/testserver/index.d.ts +5 -0
  395. package/dist/sdk/testserver/index.js +8 -0
  396. package/dist/sdk/testserver/live/connect-failure.d.ts +7 -0
  397. package/dist/sdk/testserver/live/connect-failure.js +30 -0
  398. package/dist/sdk/testserver/live/request.d.ts +69 -0
  399. package/dist/sdk/testserver/live/request.js +89 -0
  400. package/dist/sdk/testserver/service-ids.d.ts +19 -0
  401. package/dist/sdk/testserver/service-ids.js +77 -0
  402. package/dist/sdk/testserver/test-id.d.ts +15 -0
  403. package/dist/sdk/testserver/test-id.js +28 -0
  404. package/dist/story/align.d.ts +37 -0
  405. package/dist/story/align.js +39 -0
  406. package/dist/story/artifact.d.ts +60 -0
  407. package/dist/story/artifact.js +93 -0
  408. package/dist/story/definition.d.ts +52 -0
  409. package/dist/story/definition.js +9 -0
  410. package/dist/story/diff.d.ts +9 -0
  411. package/dist/story/diff.js +97 -0
  412. package/dist/story/errors.d.ts +14 -0
  413. package/dist/story/errors.js +21 -0
  414. package/dist/story/gateways.d.ts +74 -0
  415. package/dist/story/gateways.js +3 -0
  416. package/dist/story/host.d.ts +27 -0
  417. package/dist/story/host.js +97 -0
  418. package/dist/story/index.d.ts +7 -0
  419. package/dist/story/index.js +9 -0
  420. package/dist/story/json.d.ts +16 -0
  421. package/dist/story/json.js +59 -0
  422. package/dist/story/live/artifact-gateway.d.ts +2 -0
  423. package/dist/story/live/artifact-gateway.js +82 -0
  424. package/dist/story/mode.d.ts +17 -0
  425. package/dist/story/mode.js +21 -0
  426. package/dist/story/orphans.d.ts +17 -0
  427. package/dist/story/orphans.js +15 -0
  428. package/dist/story/report.d.ts +30 -0
  429. package/dist/story/report.js +118 -0
  430. package/dist/story/run.d.ts +49 -0
  431. package/dist/story/run.js +160 -0
  432. package/dist/story/sequence.d.ts +30 -0
  433. package/dist/story/sequence.js +74 -0
  434. package/dist/story/settle.d.ts +94 -0
  435. package/dist/story/settle.js +70 -0
  436. package/dist/time/duration.d.ts +19 -0
  437. package/dist/time/duration.js +37 -0
  438. package/dist/time/index.d.ts +2 -0
  439. package/dist/time/index.js +4 -0
  440. package/dist/time/time.d.ts +15 -0
  441. package/dist/time/time.js +23 -0
  442. package/dist/vercel-cli/ansi.d.ts +13 -0
  443. package/dist/vercel-cli/ansi.js +32 -0
  444. package/dist/vercel-cli/arguments.d.ts +25 -0
  445. package/dist/vercel-cli/arguments.js +78 -0
  446. package/dist/vercel-cli/auth-config.d.ts +43 -0
  447. package/dist/vercel-cli/auth-config.js +36 -0
  448. package/dist/vercel-cli/clock.d.ts +9 -0
  449. package/dist/vercel-cli/clock.js +10 -0
  450. package/dist/vercel-cli/config-files.d.ts +24 -0
  451. package/dist/vercel-cli/config-files.js +40 -0
  452. package/dist/vercel-cli/context.d.ts +12 -0
  453. package/dist/vercel-cli/context.js +12 -0
  454. package/dist/vercel-cli/driver.d.ts +218 -0
  455. package/dist/vercel-cli/driver.js +364 -0
  456. package/dist/vercel-cli/entry.d.ts +8 -0
  457. package/dist/vercel-cli/entry.js +13 -0
  458. package/dist/vercel-cli/environment.d.ts +33 -0
  459. package/dist/vercel-cli/environment.js +72 -0
  460. package/dist/vercel-cli/errors.d.ts +8 -0
  461. package/dist/vercel-cli/errors.js +8 -0
  462. package/dist/vercel-cli/gateways.d.ts +103 -0
  463. package/dist/vercel-cli/gateways.js +4 -0
  464. package/dist/vercel-cli/index.d.ts +10 -0
  465. package/dist/vercel-cli/index.js +15 -0
  466. package/dist/vercel-cli/invocation.d.ts +234 -0
  467. package/dist/vercel-cli/invocation.js +397 -0
  468. package/dist/vercel-cli/keys.d.ts +14 -0
  469. package/dist/vercel-cli/keys.js +12 -0
  470. package/dist/vercel-cli/live/config-files.d.ts +28 -0
  471. package/dist/vercel-cli/live/config-files.js +66 -0
  472. package/dist/vercel-cli/live/process-gateway.d.ts +14 -0
  473. package/dist/vercel-cli/live/process-gateway.js +178 -0
  474. package/dist/vercel-cli/redaction.d.ts +13 -0
  475. package/dist/vercel-cli/redaction.js +22 -0
  476. package/dist/vercel-cli/report.d.ts +22 -0
  477. package/dist/vercel-cli/report.js +110 -0
  478. package/dist/vercel-cli/verbose.d.ts +7 -0
  479. package/dist/vercel-cli/verbose.js +24 -0
  480. package/dist/version.d.ts +20 -0
  481. package/dist/version.js +57 -0
  482. package/dist/vitest/config.d.ts +51 -0
  483. package/dist/vitest/config.js +61 -0
  484. package/dist/vitest/container-scope.d.ts +108 -0
  485. package/dist/vitest/container-scope.js +234 -0
  486. package/dist/vitest/diagnostics.d.ts +146 -0
  487. package/dist/vitest/diagnostics.js +306 -0
  488. package/dist/vitest/fixtures.d.ts +64 -0
  489. package/dist/vitest/fixtures.js +172 -0
  490. package/dist/vitest/gateways.d.ts +47 -0
  491. package/dist/vitest/gateways.js +3 -0
  492. package/dist/vitest/index.d.ts +3 -0
  493. package/dist/vitest/index.js +9 -0
  494. package/dist/vitest/list-output.d.ts +3 -0
  495. package/dist/vitest/list-output.js +19 -0
  496. package/dist/vitest/live/list-gateway.d.ts +7 -0
  497. package/dist/vitest/live/list-gateway.js +60 -0
  498. package/dist/vitest/ownership.d.ts +29 -0
  499. package/dist/vitest/ownership.js +68 -0
  500. package/dist/vitest/plan.d.ts +33 -0
  501. package/dist/vitest/plan.js +73 -0
  502. package/dist/vitest/sandbox.d.ts +16 -0
  503. package/dist/vitest/sandbox.js +35 -0
  504. package/dist/vitest/test-events.d.ts +41 -0
  505. package/dist/vitest/test-events.js +92 -0
  506. package/dist/vitest/test-results.d.ts +84 -0
  507. package/dist/vitest/test-results.js +160 -0
  508. package/dist/vitest/types.d.ts +68 -0
  509. package/dist/vitest/types.js +4 -0
  510. package/package.json +119 -3
  511. package/skills/overview.md +32 -0
  512. package/skills/read-run-output.md +65 -0
  513. package/README.md +0 -3
@@ -0,0 +1,21 @@
1
+ // Pure helpers beneath the live Sandbox gateway: reading what a thrown `@vercel/sandbox` error says.
2
+ /** The HTTP status a Sandbox API error carries (`error.response.status`), if it carries one. */
3
+ export function apiStatus(error) {
4
+ if (typeof error !== "object" || error === null)
5
+ return undefined;
6
+ const response = error.response;
7
+ if (typeof response !== "object" || response === null)
8
+ return undefined;
9
+ const status = response.status;
10
+ return typeof status === "number" ? status : undefined;
11
+ }
12
+ /** Whether `error` is an abort: a DOM `AbortError`, as `fetch` and the SDK throw when a signal aborts. */
13
+ export function isAbortError(error) {
14
+ return typeof error === "object" && error !== null && error.name === "AbortError";
15
+ }
16
+ /** What a thrown Sandbox error means: an abort when `signal` aborted or the error is one, otherwise an API failure. */
17
+ export function sandboxFailure(error, signal) {
18
+ if (signal?.aborted === true || isAbortError(error))
19
+ return { kind: "aborted" };
20
+ return { kind: "api", status: apiStatus(error), message: error instanceof Error ? error.message : String(error) };
21
+ }
@@ -0,0 +1,7 @@
1
+ import type { RunnerSandboxGateway } from "../gateways.ts";
2
+ /** How long a process has to end after SIGTERM before it gets SIGKILL: 10 seconds. */
3
+ export declare const TERMINATE_GRACE_MS = 10000;
4
+ /** How long a process has to end after SIGKILL before keeping its sandbox fails: 5 seconds. */
5
+ export declare const KILL_GRACE_MS = 5000;
6
+ /** Vercel Sandbox through `@vercel/sandbox`. */
7
+ export declare function liveRunnerSandboxGateway(): RunnerSandboxGateway;
@@ -0,0 +1,427 @@
1
+ // The live Sandbox gateway: Vercel Sandbox through `@vercel/sandbox`, imported on first use, so a run with
2
+ // `--local` never loads it. Every create passes the region, `persistent: false`, the tags, the vCPUs and the
3
+ // timeout; every delete keeps the sandbox's snapshots. The credential's token is revealed here and only here, for
4
+ // the SDK's calls, and never reaches a sandbox's environment.
5
+ //
6
+ // Every detached process it starts in a sandbox, a script, the command or a follow, it tracks until it has seen the
7
+ // process end, since aborting a call stops only the gateway's wait. Keeping a sandbox running ends each one first.
8
+ import { REMOTE_ROOT } from "../snapshot-key.js";
9
+ import { apiStatus, sandboxFailure } from "./sandbox-errors.js";
10
+ /** How long a process has to end after SIGTERM before it gets SIGKILL: 10 seconds. */
11
+ export const TERMINATE_GRACE_MS = 10_000;
12
+ /** How long a process has to end after SIGKILL before keeping its sandbox fails: 5 seconds. */
13
+ export const KILL_GRACE_MS = 5_000;
14
+ /** The most stderr characters a failed test events read reports. */
15
+ const STDERR_MESSAGE_CHARS = 1000;
16
+ /** The Sandbox API's answer when a snapshot to start from has expired or been deleted. */
17
+ const SNAPSHOT_GONE_STATUS = 410;
18
+ /** Vercel Sandbox through `@vercel/sandbox`. */
19
+ export function liveRunnerSandboxGateway() {
20
+ let loading;
21
+ const sdk = () => (loading ??= import("@vercel/sandbox"));
22
+ const held = new WeakMap();
23
+ const holding = (sandbox) => {
24
+ const found = held.get(sandbox);
25
+ if (found === undefined)
26
+ throw new Error(`liveRunnerSandboxGateway: sandbox ${sandbox.name} isn't one it started`);
27
+ return found;
28
+ };
29
+ const adopt = (sandbox, role, timeoutMs) => {
30
+ const handle = Object.freeze({ name: sandbox.name, role, timeoutMs });
31
+ held.set(handle, { sandbox, staging: undefined, running: new Set(), starting: new Set(), keeping: false });
32
+ return handle;
33
+ };
34
+ return {
35
+ async startBuildSandbox(access, request, signal) {
36
+ try {
37
+ const { Sandbox } = await sdk();
38
+ const sandbox = await Sandbox.create({
39
+ ...credentials(access),
40
+ // oxlint-disable-next-line typescript/no-deprecated -- the recipe names a runtime; moving to `image` changes the recipe format.
41
+ runtime: request.runtime,
42
+ ...placement(request),
43
+ ...(signal === undefined ? {} : { signal }),
44
+ });
45
+ return { ok: true, value: adopt(sandbox, "snapshot-build", request.timeoutMs) };
46
+ }
47
+ catch (error) {
48
+ return { ok: false, failure: sandboxFailure(error, signal) };
49
+ }
50
+ },
51
+ async startRunnerSandbox(access, request, signal) {
52
+ try {
53
+ const { Sandbox } = await sdk();
54
+ const sandbox = await Sandbox.create({
55
+ ...credentials(access),
56
+ source: { type: "snapshot", snapshotId: request.snapshotId },
57
+ ...placement(request),
58
+ ...(signal === undefined ? {} : { signal }),
59
+ });
60
+ return { ok: true, value: adopt(sandbox, "runner", request.timeoutMs) };
61
+ }
62
+ catch (error) {
63
+ const failure = sandboxFailure(error, signal);
64
+ if (failure.kind === "api" && apiStatus(error) === SNAPSHOT_GONE_STATUS)
65
+ return { ok: false, failure: { kind: "snapshot-gone", message: failure.message } };
66
+ return { ok: false, failure };
67
+ }
68
+ },
69
+ async upload(sandbox, files, signal) {
70
+ const holder = holding(sandbox);
71
+ try {
72
+ const directory = await stagingDirectory(holder, signal);
73
+ if (typeof directory !== "string")
74
+ return { ok: false, failure: directory };
75
+ await holder.sandbox.writeFiles(writes(directory, files), signal === undefined ? undefined : { signal });
76
+ return { ok: true, value: { directory } };
77
+ }
78
+ catch (error) {
79
+ return { ok: false, failure: sandboxFailure(error, signal) };
80
+ }
81
+ },
82
+ async runScript(sandbox, request, onOutput, signal) {
83
+ const holder = holding(sandbox);
84
+ try {
85
+ const command = await startDetached(holder, {
86
+ cmd: "bash",
87
+ args: ["-lc", request.script],
88
+ cwd: REMOTE_ROOT,
89
+ env: { ...request.env },
90
+ ...(signal === undefined ? {} : { signal }),
91
+ });
92
+ if (command === undefined)
93
+ return { ok: false, failure: { kind: "aborted" } };
94
+ return { ok: true, value: await follow(holder, command, onOutput, signal) };
95
+ }
96
+ catch (error) {
97
+ return { ok: false, failure: sandboxFailure(error, signal) };
98
+ }
99
+ },
100
+ async loginPath(sandbox, signal) {
101
+ const holder = holding(sandbox);
102
+ try {
103
+ const finished = await holder.sandbox.runCommand({
104
+ cmd: "bash",
105
+ args: ["-lc", 'printf %s "$PATH"'],
106
+ ...(signal === undefined ? {} : { signal }),
107
+ });
108
+ if (finished.exitCode !== 0)
109
+ return {
110
+ ok: false,
111
+ failure: { kind: "api", status: undefined, message: `reading the login PATH exited ${finished.exitCode}` },
112
+ };
113
+ return { ok: true, value: await finished.stdout(signal === undefined ? undefined : { signal }) };
114
+ }
115
+ catch (error) {
116
+ return { ok: false, failure: sandboxFailure(error, signal) };
117
+ }
118
+ },
119
+ async runCommand(sandbox, request, onOutput, kill) {
120
+ const holder = holding(sandbox);
121
+ if (kill.aborted)
122
+ return { ok: false, failure: { kind: "aborted" } };
123
+ try {
124
+ const cmd = await resolveExecutable(holder, request);
125
+ if (kill.aborted)
126
+ return { ok: false, failure: { kind: "aborted" } };
127
+ const command = await startDetached(holder, {
128
+ cmd,
129
+ args: [...request.args],
130
+ cwd: request.cwd,
131
+ env: { ...request.env },
132
+ });
133
+ if (command === undefined)
134
+ return { ok: false, failure: { kind: "aborted" } };
135
+ const terminate = () => {
136
+ command.kill("SIGTERM").catch(() => { });
137
+ };
138
+ // A kill that came while the command was starting still reaches it.
139
+ if (kill.aborted)
140
+ terminate();
141
+ else
142
+ kill.addEventListener("abort", terminate, { once: true });
143
+ try {
144
+ return { ok: true, value: await follow(holder, command, onOutput, kill) };
145
+ }
146
+ finally {
147
+ kill.removeEventListener("abort", terminate);
148
+ }
149
+ }
150
+ catch (error) {
151
+ return { ok: false, failure: sandboxFailure(error, kill) };
152
+ }
153
+ },
154
+ async followTestEvents(sandbox, request, onOutput, stop) {
155
+ const holder = holding(sandbox);
156
+ if (stop.aborted)
157
+ return { ok: true };
158
+ try {
159
+ // `tail -F` waits for a file that doesn't exist yet, and follows it from its first line.
160
+ const command = await startDetached(holder, { cmd: "tail", args: ["-n", "+1", "-F", request.path] });
161
+ if (command === undefined)
162
+ return { ok: true };
163
+ const end = () => {
164
+ command.kill("SIGTERM").catch(() => { });
165
+ };
166
+ if (stop.aborted)
167
+ end();
168
+ else
169
+ stop.addEventListener("abort", end, { once: true });
170
+ try {
171
+ await follow(holder, command, (chunk) => {
172
+ if (chunk.stream === "stdout")
173
+ onOutput(chunk);
174
+ }, stop);
175
+ }
176
+ finally {
177
+ stop.removeEventListener("abort", end);
178
+ }
179
+ return { ok: true };
180
+ }
181
+ catch (error) {
182
+ const failure = sandboxFailure(error, stop);
183
+ return failure.kind === "aborted" ? { ok: true } : { ok: false, failure };
184
+ }
185
+ },
186
+ async readTestEvents(sandbox, request, onOutput, signal) {
187
+ const holder = holding(sandbox);
188
+ if (signal?.aborted === true)
189
+ return { ok: false, failure: { kind: "aborted" } };
190
+ try {
191
+ const command = await startDetached(holder, {
192
+ cmd: "bash",
193
+ args: [
194
+ "-c",
195
+ 'test -e "$1" || exit 0; exec tail -n +"$2" -- "$1"',
196
+ "_",
197
+ request.path,
198
+ String(request.fromLine),
199
+ ],
200
+ });
201
+ if (command === undefined)
202
+ return { ok: false, failure: { kind: "aborted" } };
203
+ const end = () => {
204
+ command.kill("SIGTERM").catch(() => { });
205
+ };
206
+ if (isAborted(signal))
207
+ end();
208
+ else
209
+ signal?.addEventListener("abort", end, { once: true });
210
+ let stderr = "";
211
+ try {
212
+ const exit = await follow(holder, command, (chunk) => {
213
+ if (chunk.stream === "stdout")
214
+ onOutput(chunk);
215
+ else if (stderr.length < STDERR_MESSAGE_CHARS)
216
+ stderr += chunk.data.slice(0, STDERR_MESSAGE_CHARS - stderr.length);
217
+ }, signal);
218
+ if (exit.exitCode === 0)
219
+ return { ok: true };
220
+ const reason = stderr.trim();
221
+ return {
222
+ ok: false,
223
+ failure: {
224
+ kind: "api",
225
+ status: undefined,
226
+ message: `reading the test events file exited ${exit.exitCode ?? "without a code"}${reason === "" ? "" : `: ${reason}`}`,
227
+ },
228
+ };
229
+ }
230
+ finally {
231
+ signal?.removeEventListener("abort", end);
232
+ }
233
+ }
234
+ catch (error) {
235
+ return { ok: false, failure: sandboxFailure(error, signal) };
236
+ }
237
+ },
238
+ async saveSnapshot(sandbox, request) {
239
+ const holder = holding(sandbox);
240
+ try {
241
+ const snapshot = await holder.sandbox.snapshot({ expiration: request.expirationMs });
242
+ if (snapshot.status !== "created")
243
+ return {
244
+ ok: false,
245
+ failure: {
246
+ kind: "api",
247
+ status: undefined,
248
+ message: `snapshot ${snapshot.snapshotId} is ${snapshot.status}`,
249
+ },
250
+ };
251
+ return {
252
+ ok: true,
253
+ value: {
254
+ snapshotId: snapshot.snapshotId,
255
+ expiresAt: snapshot.expiresAt?.toISOString(),
256
+ sizeBytes: snapshot.sizeBytes,
257
+ },
258
+ };
259
+ }
260
+ catch (error) {
261
+ return { ok: false, failure: sandboxFailure(error, undefined) };
262
+ }
263
+ },
264
+ async keepRunning(sandbox, request) {
265
+ const holder = holding(sandbox);
266
+ holder.keeping = true;
267
+ await Promise.allSettled(holder.starting);
268
+ const stillRunning = (await Promise.all([...holder.running].map((command) => endProcess(holder, command)))).filter((ended) => !ended).length;
269
+ if (stillRunning > 0)
270
+ return {
271
+ ok: false,
272
+ failure: {
273
+ kind: "processes-running",
274
+ message: `${stillRunning} ${stillRunning === 1 ? "process" : "processes"} the run started didn't end after SIGKILL`,
275
+ },
276
+ };
277
+ try {
278
+ // The SDK's `expiresAt` is the running session's start plus its timeout, as the last answer about it said.
279
+ const stopsAt = holder.sandbox.expiresAt;
280
+ const short = request.until.getTime() - (stopsAt?.getTime() ?? Date.now());
281
+ if (short <= 0 && stopsAt !== undefined)
282
+ return { ok: true, value: { stopsAt } };
283
+ await holder.sandbox.extendTimeout(short);
284
+ return { ok: true, value: { stopsAt: holder.sandbox.expiresAt ?? request.until } };
285
+ }
286
+ catch (error) {
287
+ return { ok: false, failure: sandboxFailure(error, undefined) };
288
+ }
289
+ },
290
+ async stop(sandbox) {
291
+ const holder = holding(sandbox);
292
+ try {
293
+ await holder.sandbox.stop();
294
+ return { ok: true };
295
+ }
296
+ catch (error) {
297
+ return { ok: false, failure: sandboxFailure(error, undefined) };
298
+ }
299
+ },
300
+ async delete(sandbox) {
301
+ const holder = holding(sandbox);
302
+ try {
303
+ await holder.sandbox.delete({ deleteOrphanSnapshots: false });
304
+ return { ok: true };
305
+ }
306
+ catch (error) {
307
+ return { ok: false, failure: sandboxFailure(error, undefined) };
308
+ }
309
+ },
310
+ };
311
+ }
312
+ function credentials(access) {
313
+ return { token: access.credential.reveal(), teamId: access.teamId, projectId: access.projectId };
314
+ }
315
+ function placement(request) {
316
+ return {
317
+ region: request.region,
318
+ resources: { vcpus: request.vcpus },
319
+ timeout: request.timeoutMs,
320
+ persistent: false,
321
+ tags: { ...request.tags },
322
+ };
323
+ }
324
+ function writes(directory, files) {
325
+ return files.map((file) => ({ path: `${directory}/${file.name}`, content: file.content }));
326
+ }
327
+ /** The sandbox's staging directory, made once with `mktemp -d`, so no fixed path is shared or reused. */
328
+ async function stagingDirectory(holder, signal) {
329
+ if (holder.staging !== undefined)
330
+ return holder.staging;
331
+ const made = await holder.sandbox.runCommand({
332
+ cmd: "mktemp",
333
+ args: ["-d", "-t", "storm-runner.XXXXXXXX"],
334
+ ...(signal === undefined ? {} : { signal }),
335
+ });
336
+ if (made.exitCode !== 0)
337
+ return { kind: "api", status: undefined, message: `mktemp exited ${made.exitCode} making a staging directory` };
338
+ const directory = (await made.stdout(signal === undefined ? undefined : { signal })).trim();
339
+ holder.staging = directory;
340
+ return directory;
341
+ }
342
+ /**
343
+ * The executable a command runs: a bare name looked up on the `PATH` in the command's `env`, as a shell would. The
344
+ * Sandbox API looks a bare `cmd` up on the sandbox's own `PATH` and ignores the one in `env`, so `vitest` in a
345
+ * `node_modules/.bin` would answer 400, "executable file not found in $PATH". A non-login `bash -c` keeps the `PATH`
346
+ * as given. A name with a `/`, or one the lookup doesn't find as a file, is passed as it is.
347
+ */
348
+ async function resolveExecutable(holder, request) {
349
+ if (request.cmd.includes("/"))
350
+ return request.cmd;
351
+ const found = await holder.sandbox.runCommand({
352
+ cmd: "bash",
353
+ args: ["-c", 'command -v -- "$1"', "_", request.cmd],
354
+ cwd: request.cwd,
355
+ env: { ...request.env },
356
+ });
357
+ if (found.exitCode !== 0)
358
+ return request.cmd;
359
+ const path = (await found.stdout()).trim();
360
+ return path.startsWith("/") ? path : request.cmd;
361
+ }
362
+ /**
363
+ * Starts a detached process in `holder`'s sandbox and tracks it until it is seen to end; undefined, starting nothing,
364
+ * once keeping the sandbox running began. `keepRunning` waits for a start in flight, so it ends what that started too.
365
+ */
366
+ async function startDetached(holder, params) {
367
+ if (holder.keeping)
368
+ return undefined;
369
+ const starting = holder.sandbox.runCommand({ ...params, detached: true });
370
+ holder.starting.add(starting);
371
+ try {
372
+ const command = await starting;
373
+ holder.running.add(command);
374
+ return command;
375
+ }
376
+ finally {
377
+ holder.starting.delete(starting);
378
+ }
379
+ }
380
+ /**
381
+ * Streams a detached command's output to `onOutput` until it ends, then answers its exit code; it is no longer
382
+ * running once it has. `signal` aborting stops the wait, not the command.
383
+ */
384
+ async function follow(holder, command, onOutput, signal) {
385
+ const options = signal === undefined ? undefined : { signal };
386
+ for await (const log of command.logs(options))
387
+ onOutput({ stream: log.stream, data: log.data });
388
+ const finished = await command.wait(options);
389
+ holder.running.delete(command);
390
+ return { exitCode: typeof finished.exitCode === "number" ? finished.exitCode : null };
391
+ }
392
+ /**
393
+ * Ends `command`: SIGTERM, then SIGKILL when it hasn't ended `TERMINATE_GRACE_MS` later; whether it is seen to end,
394
+ * `KILL_GRACE_MS` after SIGKILL at the latest. A kill that fails, as on a process already gone, is checked by the wait.
395
+ */
396
+ async function endProcess(holder, command) {
397
+ for (const [signal, graceMs] of [
398
+ ["SIGTERM", TERMINATE_GRACE_MS],
399
+ ["SIGKILL", KILL_GRACE_MS],
400
+ ]) {
401
+ await command.kill(signal).catch(() => undefined);
402
+ if (await endsWithin(command, graceMs)) {
403
+ holder.running.delete(command);
404
+ return true;
405
+ }
406
+ }
407
+ return false;
408
+ }
409
+ /** Whether `command` is seen to end within `ms`: a wait that fails or outlasts it isn't. */
410
+ async function endsWithin(command, ms) {
411
+ const timeout = new AbortController();
412
+ const timer = setTimeout(() => timeout.abort(), ms);
413
+ try {
414
+ await command.wait({ signal: timeout.signal });
415
+ return true;
416
+ }
417
+ catch {
418
+ return false;
419
+ }
420
+ finally {
421
+ clearTimeout(timer);
422
+ }
423
+ }
424
+ /** Whether `signal` has aborted now, read after an await so an earlier check doesn't narrow it. */
425
+ function isAborted(signal) {
426
+ return signal?.aborted === true;
427
+ }
@@ -0,0 +1,12 @@
1
+ import type { RunnerSnapshotCacheGateway } from "../gateways.ts";
2
+ export interface LiveRunnerSnapshotCacheOptions {
3
+ /** The cache directory, `$XDG_STATE_HOME/storm/runner/snapshots`. */
4
+ readonly directory: string;
5
+ }
6
+ /** The runner snapshot cache in `options.directory`. */
7
+ export declare function liveRunnerSnapshotCacheGateway(options: LiveRunnerSnapshotCacheOptions): RunnerSnapshotCacheGateway;
8
+ /**
9
+ * A cache that can't be found, because neither `XDG_STATE_HOME` nor `HOME` names a place for it. Every operation
10
+ * fails with `reason`, at `location`.
11
+ */
12
+ export declare function unavailableRunnerSnapshotCacheGateway(location: string, reason: string): RunnerSnapshotCacheGateway;
@@ -0,0 +1,104 @@
1
+ // The runner snapshot cache on disk: one `<identity>.json` file per runner snapshot in one directory, named after
2
+ // the entry's identity (`snapshotEntryIdentity`). An entry is written to a temp file in the same directory and
3
+ // renamed into place, so a write with the same identity replaces the file whole and the last write wins. Files are
4
+ // mode 0600 and directories 0700.
5
+ import { randomBytes } from "node:crypto";
6
+ import { mkdir, readdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
7
+ import { join } from "node:path";
8
+ import { snapshotEntryFileName } from "../snapshot-cache.js";
9
+ import { parseSnapshotEntry, snapshotEntryText } from "./snapshot-records.js";
10
+ const DIRECTORY_MODE = 0o700;
11
+ const FILE_MODE = 0o600;
12
+ /** A cache file's name: 32 hex characters and `.json`. Temp files start with a dot and never match. */
13
+ const ENTRY_FILE_NAME = /^[0-9a-f]{32}\.json$/;
14
+ /** The runner snapshot cache in `options.directory`. */
15
+ export function liveRunnerSnapshotCacheGateway(options) {
16
+ const { directory } = options;
17
+ return {
18
+ listEntries: () => listEntries(directory),
19
+ writeEntry: (entry) => writeEntry(directory, entry),
20
+ removeEntry: (entry) => removeEntry(directory, entry),
21
+ };
22
+ }
23
+ /**
24
+ * A cache that can't be found, because neither `XDG_STATE_HOME` nor `HOME` names a place for it. Every operation
25
+ * fails with `reason`, at `location`.
26
+ */
27
+ export function unavailableRunnerSnapshotCacheGateway(location, reason) {
28
+ const failure = { path: location, message: reason };
29
+ const fail = async () => ({ ok: false, failure });
30
+ return { listEntries: fail, writeEntry: fail, removeEntry: fail };
31
+ }
32
+ async function listEntries(directory) {
33
+ let names;
34
+ try {
35
+ names = await readdir(directory);
36
+ }
37
+ catch (error) {
38
+ if (errorCode(error) === "ENOENT")
39
+ return { ok: true, value: { directory, entries: [], unreadable: [] } };
40
+ return { ok: false, failure: failureAt(directory, error) };
41
+ }
42
+ const entries = [];
43
+ const unreadable = [];
44
+ for (const name of names.filter((name) => ENTRY_FILE_NAME.test(name)).toSorted()) {
45
+ const file = join(directory, name);
46
+ let text;
47
+ try {
48
+ text = await readFile(file, "utf8");
49
+ }
50
+ catch (error) {
51
+ if (errorCode(error) === "ENOENT")
52
+ continue; // Removed since the directory was read.
53
+ unreadable.push({ file, reason: error instanceof Error ? error.message : String(error) });
54
+ continue;
55
+ }
56
+ const parsed = parseSnapshotEntry(text);
57
+ if (!parsed.ok)
58
+ unreadable.push({ file, reason: parsed.reason });
59
+ else if (snapshotEntryFileName(parsed.value) !== name)
60
+ unreadable.push({ file, reason: "its name isn't its entry's identity" });
61
+ else
62
+ entries.push(parsed.value);
63
+ }
64
+ return { ok: true, value: { directory, entries, unreadable } };
65
+ }
66
+ async function writeEntry(directory, entry) {
67
+ try {
68
+ await mkdir(directory, { recursive: true, mode: DIRECTORY_MODE });
69
+ }
70
+ catch (error) {
71
+ return { ok: false, failure: failureAt(directory, error) };
72
+ }
73
+ const name = snapshotEntryFileName(entry);
74
+ const path = join(directory, name);
75
+ const temp = join(directory, `.${name}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
76
+ try {
77
+ await writeFile(temp, snapshotEntryText(entry), { mode: FILE_MODE, flag: "wx" });
78
+ await rename(temp, path);
79
+ return { ok: true };
80
+ }
81
+ catch (error) {
82
+ await unlink(temp).catch(() => { });
83
+ return { ok: false, failure: failureAt(path, error) };
84
+ }
85
+ }
86
+ async function removeEntry(directory, entry) {
87
+ const path = join(directory, snapshotEntryFileName(entry));
88
+ try {
89
+ await unlink(path);
90
+ return { ok: true };
91
+ }
92
+ catch (error) {
93
+ if (errorCode(error) === "ENOENT")
94
+ return { ok: true };
95
+ return { ok: false, failure: failureAt(path, error) };
96
+ }
97
+ }
98
+ function errorCode(error) {
99
+ const code = typeof error === "object" && error !== null ? error.code : undefined;
100
+ return typeof code === "string" ? code : undefined;
101
+ }
102
+ function failureAt(path, error) {
103
+ return { path, message: error instanceof Error ? error.message : String(error) };
104
+ }
@@ -0,0 +1,11 @@
1
+ import type { RunnerSnapshotEntry } from "../gateways.ts";
2
+ /** The entry a cache file holds, or why it holds none. */
3
+ export declare function parseSnapshotEntry(text: string): {
4
+ readonly ok: true;
5
+ readonly value: RunnerSnapshotEntry;
6
+ } | {
7
+ readonly ok: false;
8
+ readonly reason: string;
9
+ };
10
+ /** The text of the file that records `entry`. */
11
+ export declare function snapshotEntryText(entry: RunnerSnapshotEntry): string;
@@ -0,0 +1,57 @@
1
+ // The runner snapshot cache's file format: one JSON object per runner snapshot, carrying `version: 1`. A reader
2
+ // rejects a version it doesn't know.
3
+ import { z } from "zod";
4
+ const isoTime = z.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "not a time" });
5
+ const nonEmpty = z.string().min(1);
6
+ const entrySchema = z.object({
7
+ version: z.literal(1),
8
+ teamId: nonEmpty,
9
+ projectId: nonEmpty,
10
+ region: nonEmpty,
11
+ runtime: nonEmpty,
12
+ recipeName: nonEmpty,
13
+ snapshotKey: nonEmpty,
14
+ base: nonEmpty,
15
+ snapshotId: nonEmpty,
16
+ createdAt: isoTime,
17
+ expiresAt: isoTime,
18
+ });
19
+ /** The entry a cache file holds, or why it holds none. */
20
+ export function parseSnapshotEntry(text) {
21
+ let json;
22
+ try {
23
+ json = JSON.parse(text);
24
+ }
25
+ catch {
26
+ return { ok: false, reason: "not JSON" };
27
+ }
28
+ const version = typeof json === "object" && json !== null ? json.version : undefined;
29
+ if (version !== 1)
30
+ return { ok: false, reason: `unknown version ${JSON.stringify(version) ?? "(none)"}` };
31
+ const parsed = entrySchema.safeParse(json);
32
+ if (!parsed.success) {
33
+ const issue = parsed.error.issues[0];
34
+ const where = issue === undefined || issue.path.length === 0 ? "the record" : issue.path.join(".");
35
+ return { ok: false, reason: `${where}: ${issue?.message ?? "invalid"}` };
36
+ }
37
+ const { version: _version, ...entry } = parsed.data;
38
+ return { ok: true, value: entry };
39
+ }
40
+ /** The text of the file that records `entry`. */
41
+ export function snapshotEntryText(entry) {
42
+ const { teamId, projectId, region, runtime, recipeName, snapshotKey, base, snapshotId, createdAt, expiresAt } = entry;
43
+ const record = {
44
+ version: 1,
45
+ teamId,
46
+ projectId,
47
+ region,
48
+ runtime,
49
+ recipeName,
50
+ snapshotKey,
51
+ base,
52
+ snapshotId,
53
+ createdAt,
54
+ expiresAt,
55
+ };
56
+ return `${JSON.stringify(record, null, 2)}\n`;
57
+ }
@@ -0,0 +1,16 @@
1
+ import type { RunnerTerminal } from "../gateways.ts";
2
+ /** The part of a writable stream the terminal uses: `process.stdout` and `process.stderr` have it. */
3
+ export interface TerminalStream {
4
+ readonly isTTY?: boolean;
5
+ write(text: string): unknown;
6
+ on(event: "error", listener: (error: Error) => void): unknown;
7
+ }
8
+ /**
9
+ * A terminal over `stdout` and `stderr`, by default this process's. It shows color when stdout is a TTY and the
10
+ * host environment doesn't set `NO_COLOR`.
11
+ */
12
+ export declare function liveRunnerTerminal(options: {
13
+ readonly env: Readonly<Record<string, string | undefined>>;
14
+ readonly stdout?: TerminalStream;
15
+ readonly stderr?: TerminalStream;
16
+ }): RunnerTerminal;