@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,48 @@
1
+ import { isBuildChannel, resolveChannel, } from "../sandbox/index.js";
2
+ /** How long a channel resolution is trusted without asking the Testserver control plane again. */
3
+ export const CHANNEL_RESOLUTION_TRUST_MINUTES = 60;
4
+ /**
5
+ * Resolves `build`. A build named directly resolves to itself. A build channel uses its channel resolution
6
+ * when that is less than an hour old; otherwise it gets a credential from `credential` and asks the Testserver
7
+ * control plane, and records what it learns. A failed record write is ignored: it costs only a later lookup.
8
+ * Reading the channel resolutions failing counts as having none.
9
+ *
10
+ * With no `credential`, it never mints or requests a token: it uses the channel resolution at any age, and with none
11
+ * matches on the channel as written (`not-recorded`).
12
+ */
13
+ export async function resolveBuild(context, request) {
14
+ const { build } = request;
15
+ if (!isBuildChannel(build))
16
+ return { kind: "named", build };
17
+ const now = context.clock.now();
18
+ const recorded = await context.pool.readChannelResolutions();
19
+ const known = recorded.ok ? recorded.value[build] : undefined;
20
+ if (known !== undefined && isFresh(known.learnedAt, now))
21
+ return { kind: "channel-resolution", channel: build, build: known.build, learnedAt: known.learnedAt };
22
+ if (request.credential === undefined)
23
+ return known === undefined
24
+ ? { kind: "as-written", channel: build, reason: { kind: "not-recorded" } }
25
+ : { kind: "old-channel-resolution", channel: build, build: known.build, learnedAt: known.learnedAt };
26
+ const got = await request.credential.get();
27
+ if (!got.ok)
28
+ return { kind: "as-written", channel: build, reason: { kind: "credential-failed", failure: got.failure } };
29
+ const listed = await context.controlPlane.builds({ credential: got.credential });
30
+ if (!listed.ok)
31
+ return { kind: "as-written", channel: build, reason: { kind: "builds-failed", failure: listed.failure } };
32
+ const resolved = resolveChannel(listed.value, build);
33
+ if (resolved === undefined)
34
+ return { kind: "as-written", channel: build, reason: { kind: "no-build" } };
35
+ await context.pool.writeChannelResolution(build, { build: resolved, learnedAt: now.toISOString() });
36
+ return { kind: "control-plane", channel: build, build: resolved };
37
+ }
38
+ /** The pool entries a resolution lets a run lease. */
39
+ export function buildMatch(resolution) {
40
+ return resolution.kind === "as-written"
41
+ ? { requestedBuild: resolution.channel }
42
+ : { resolvedBuild: resolution.build };
43
+ }
44
+ /** Whether a resolution learned at `learnedAt` is under an hour old. One from the future isn't trusted. */
45
+ function isFresh(learnedAt, now) {
46
+ const age = now.getTime() - new Date(learnedAt).getTime();
47
+ return age >= 0 && age < CHANNEL_RESOLUTION_TRUST_MINUTES * 60_000;
48
+ }
@@ -0,0 +1,48 @@
1
+ import type { Credential } from "../../../credential/index.ts";
2
+ import { type ControlPlaneGateway, type CreateFailure, type CreateProgress } from "../sandbox/index.ts";
3
+ import type { Clock, Timer } from "../../../time/index.ts";
4
+ import type { PoolEntry, PoolStoreFailure, PoolStoreGateway } from "./gateways.ts";
5
+ /**
6
+ * How `createPooledSandbox` ended:
7
+ *
8
+ * - `pooled`: the Testserver sandbox exists and its pool entry is written, leased to this process if asked.
9
+ * - `create-failed`: the create failed, as `createSandbox` reports it, or its Testserver URL has no host a
10
+ * pool entry can be named after (`malformed`).
11
+ * - `pool-write-failed`: the Testserver sandbox exists, but its pool entry couldn't be written. `entry` is
12
+ * what the entry would have held, so the caller can still report it.
13
+ */
14
+ export type PooledCreateOutcome = {
15
+ readonly kind: "pooled";
16
+ readonly host: string;
17
+ readonly entry: PoolEntry;
18
+ } | {
19
+ readonly kind: "create-failed";
20
+ readonly failure: CreateFailure;
21
+ } | {
22
+ readonly kind: "pool-write-failed";
23
+ readonly entry: PoolEntry;
24
+ readonly failure: PoolStoreFailure;
25
+ };
26
+ /**
27
+ * Creates one Testserver sandbox on `build` living `ttlMinutes` (see `createSandbox`) and adds it to the pool, its
28
+ * entry recording the TTL: free, or, with
29
+ * `lease`, leased to this process, the lease written before the entry so no other run sees it free. Its
30
+ * `createdAt` is the clock when the create started, which underestimates the time it has left. The entry is
31
+ * written first, as soon as the Testserver sandbox exists; then, on a build channel, the channel resolution
32
+ * the create showed is recorded. A failed channel record is ignored: it costs only a later lookup.
33
+ * `progress` hears the Testserver control plane's progress messages.
34
+ *
35
+ * Callers call `pool.prepare()` first, before minting, so a pool that can't be used stops the run before a
36
+ * Testserver sandbox exists that nothing can delete.
37
+ */
38
+ export declare function createPooledSandbox(context: {
39
+ readonly pool: PoolStoreGateway;
40
+ readonly controlPlane: ControlPlaneGateway;
41
+ readonly timer: Timer;
42
+ readonly clock: Clock;
43
+ }, request: {
44
+ readonly credential: Credential;
45
+ readonly build: string;
46
+ readonly ttlMinutes: number;
47
+ readonly lease: boolean;
48
+ }, progress?: CreateProgress): Promise<PooledCreateOutcome>;
@@ -0,0 +1,45 @@
1
+ import { createSandbox, isBuildChannel, } from "../sandbox/index.js";
2
+ import { sandboxHost } from "./host.js";
3
+ /**
4
+ * Creates one Testserver sandbox on `build` living `ttlMinutes` (see `createSandbox`) and adds it to the pool, its
5
+ * entry recording the TTL: free, or, with
6
+ * `lease`, leased to this process, the lease written before the entry so no other run sees it free. Its
7
+ * `createdAt` is the clock when the create started, which underestimates the time it has left. The entry is
8
+ * written first, as soon as the Testserver sandbox exists; then, on a build channel, the channel resolution
9
+ * the create showed is recorded. A failed channel record is ignored: it costs only a later lookup.
10
+ * `progress` hears the Testserver control plane's progress messages.
11
+ *
12
+ * Callers call `pool.prepare()` first, before minting, so a pool that can't be used stops the run before a
13
+ * Testserver sandbox exists that nothing can delete.
14
+ */
15
+ export async function createPooledSandbox(context, request, progress = {}) {
16
+ const startedAt = context.clock.now();
17
+ const { credential, build, ttlMinutes } = request;
18
+ const created = await createSandbox(context, { credential, build, ttlMinutes }, progress);
19
+ if (!created.ok)
20
+ return { kind: "create-failed", failure: created.failure };
21
+ const { testserverUrl, logViewerUrl, resolvedBuild } = created.sandbox;
22
+ const host = sandboxHost(testserverUrl);
23
+ if (host === undefined) {
24
+ const detail = `the Testserver URL ${testserverUrl} has no host a pool entry can be named after`;
25
+ return { kind: "create-failed", failure: { kind: "malformed", detail } };
26
+ }
27
+ const entry = {
28
+ testserverUrl,
29
+ logViewerUrl,
30
+ createdAt: startedAt.toISOString(),
31
+ ttlMinutes,
32
+ requestedBuild: request.build,
33
+ resolvedBuild,
34
+ };
35
+ const leaseOptions = request.lease ? { lease: { startedAt: context.clock.now().toISOString() } } : {};
36
+ const added = await context.pool.addEntry(entry, leaseOptions);
37
+ if (!added.ok)
38
+ return { kind: "pool-write-failed", entry, failure: added.failure };
39
+ if (isBuildChannel(request.build))
40
+ await context.pool.writeChannelResolution(request.build, {
41
+ build: resolvedBuild,
42
+ learnedAt: context.clock.now().toISOString(),
43
+ });
44
+ return { kind: "pooled", host, entry };
45
+ }
@@ -0,0 +1,4 @@
1
+ /** The subpath of storm's state directory that holds the pool. */
2
+ export declare const POOL_SUBPATH: readonly string[];
3
+ /** How `resolveStateDirectory` names the pool's location when it can't resolve it. */
4
+ export declare const POOL_DIRECTORY_PATTERN: string;
@@ -0,0 +1,5 @@
1
+ import { stateDirectoryPattern } from "../../../core/index.js";
2
+ /** The subpath of storm's state directory that holds the pool. */
3
+ export const POOL_SUBPATH = ["pool"];
4
+ /** How `resolveStateDirectory` names the pool's location when it can't resolve it. */
5
+ export const POOL_DIRECTORY_PATTERN = stateDirectoryPattern(POOL_SUBPATH);
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The pool's record of one Testserver sandbox. It is keyed by its host, the Testserver URL's hostname
3
+ * (see `sandboxHost`).
4
+ */
5
+ export interface PoolEntry {
6
+ /** The Testserver URL, with no trailing slash. */
7
+ readonly testserverUrl: string;
8
+ /** The log viewer URL, with no trailing slash. */
9
+ readonly logViewerUrl: string;
10
+ /** When the create that made it started, by the client clock, as an ISO string. */
11
+ readonly createdAt: string;
12
+ readonly ttlMinutes: number;
13
+ readonly requestedBuild: string;
14
+ readonly resolvedBuild: string;
15
+ }
16
+ /** A lease as its file records it: the process holding it, on which host, since when. */
17
+ export interface LeaseRecord {
18
+ readonly pid: number;
19
+ readonly hostname: string;
20
+ /** When the lease was taken, as an ISO string. */
21
+ readonly startedAt: string;
22
+ }
23
+ /** Who holds a lease, as its file names them, and whether that process still runs. */
24
+ export interface LeaseHolder {
25
+ readonly pid: number;
26
+ readonly hostname: string;
27
+ /** `undefined` when the holder is on another host, where storm can't tell. */
28
+ readonly alive: boolean | undefined;
29
+ }
30
+ /**
31
+ * A lease as observed. `holder` is `undefined` when the lease file can't be read; its `startedAt` is then the
32
+ * file's modification time, so the lease is judged by age alone.
33
+ */
34
+ export interface ObservedLease {
35
+ readonly holder: LeaseHolder | undefined;
36
+ /** When the lease was taken, as an ISO string (or the file's mtime when the file can't be read). */
37
+ readonly startedAt: string;
38
+ }
39
+ /** One readable pool entry with its lease, if any. */
40
+ export interface ListedEntry {
41
+ readonly host: string;
42
+ readonly entry: PoolEntry;
43
+ readonly lease: ObservedLease | undefined;
44
+ /** Whether a lease guard is present on disk for its lease. No run takes a lease guard over. */
45
+ readonly leaseGuard: boolean;
46
+ }
47
+ /** A pool entry file storm can't read: corrupt, of an unknown version, or naming another host. */
48
+ export interface UnreadableEntry {
49
+ readonly file: string;
50
+ readonly reason: string;
51
+ }
52
+ /** What `listEntries` found. */
53
+ export interface PoolListing {
54
+ /** Where the pool lives. */
55
+ readonly directory: string;
56
+ readonly entries: readonly ListedEntry[];
57
+ readonly unreadable: readonly UnreadableEntry[];
58
+ }
59
+ /** What a build channel last resolved to, and when that was learned (an ISO string). */
60
+ export interface ChannelResolution {
61
+ readonly build: string;
62
+ readonly learnedAt: string;
63
+ }
64
+ /** Why a pool operation failed: the path it failed on and what the OS said. */
65
+ export interface PoolStoreFailure {
66
+ readonly path: string;
67
+ readonly message: string;
68
+ }
69
+ export type PoolStoreResult<T> = {
70
+ readonly ok: true;
71
+ readonly value: T;
72
+ } | {
73
+ readonly ok: false;
74
+ readonly failure: PoolStoreFailure;
75
+ };
76
+ export type PoolStoreOperation = {
77
+ readonly ok: true;
78
+ } | {
79
+ readonly ok: false;
80
+ readonly failure: PoolStoreFailure;
81
+ };
82
+ /**
83
+ * What a lease attempt did: `leased` to this process; `held` when another holder has the lease, having won the
84
+ * race; `gone` when the entry left the pool first (no lease is left behind).
85
+ */
86
+ export type LeaseOutcome = {
87
+ readonly kind: "leased";
88
+ } | {
89
+ readonly kind: "held";
90
+ } | {
91
+ readonly kind: "gone";
92
+ } | {
93
+ readonly kind: "failed";
94
+ readonly failure: PoolStoreFailure;
95
+ };
96
+ /**
97
+ * What a release did: `released` this process's lease, found none of its own (`not-held`), or found another run
98
+ * holding the lease guard (`guarded`, at path `guard`), so the lease stays.
99
+ */
100
+ export type ReleaseOutcome = {
101
+ readonly kind: "released";
102
+ } | {
103
+ readonly kind: "not-held";
104
+ } | {
105
+ readonly kind: "guarded";
106
+ readonly guard: string;
107
+ } | {
108
+ readonly kind: "failed";
109
+ readonly failure: PoolStoreFailure;
110
+ };
111
+ /**
112
+ * What a reclaim did.
113
+ *
114
+ * - `reclaimed`: the lease was stale and is gone, so its Testserver sandbox is free.
115
+ * - `not-stale`: the lease read under the lease guard isn't stale; it stays.
116
+ * - `guarded`: another run holds the lease guard; nothing changed.
117
+ * - `gone`: there was no lease by the time the lease guard was taken.
118
+ */
119
+ export type ReclaimOutcome = {
120
+ readonly kind: "reclaimed";
121
+ } | {
122
+ readonly kind: "not-stale";
123
+ } | {
124
+ readonly kind: "guarded";
125
+ } | {
126
+ readonly kind: "gone";
127
+ } | {
128
+ readonly kind: "failed";
129
+ readonly failure: PoolStoreFailure;
130
+ };
131
+ /**
132
+ * What a drop did.
133
+ *
134
+ * - `dropped`: the entry was free, and it is gone from the pool.
135
+ * - `held`: another holder has the entry's lease; it stays.
136
+ * - `gone`: the entry wasn't in the pool.
137
+ * - `guarded`: another run holds the lease guard; nothing changed.
138
+ */
139
+ export type DropOutcome = {
140
+ readonly kind: "dropped";
141
+ } | {
142
+ readonly kind: "held";
143
+ } | {
144
+ readonly kind: "gone";
145
+ } | {
146
+ readonly kind: "guarded";
147
+ } | {
148
+ readonly kind: "failed";
149
+ readonly failure: PoolStoreFailure;
150
+ };
151
+ /**
152
+ * The pool and the channel resolutions kept beside it. Every method returns its expected failures and never
153
+ * rejects. The store owns the mechanism (files, links, lease guards, whether a holder's pid still runs, this
154
+ * process's own pid and hostname); the policy that decides staleness is the caller's (`isStaleLease`).
155
+ *
156
+ * Taking a lease needs no lease guard: it only ever creates a lease where none is, and never replaces one.
157
+ * Removing a lease does: only the holder of a host's lease guard removes its lease, so a release, a reclaim
158
+ * or a drop never removes a lease another run took meanwhile. A lease guard is never taken over; a method
159
+ * that finds one held returns `guarded` at once. The one exception is a lease attempt or a leased add that
160
+ * undoes the lease it has just created, which no other run can have judged stale.
161
+ */
162
+ export interface PoolStoreGateway {
163
+ /** Makes the pool's directories, so a run learns the pool is unusable before it creates anything. */
164
+ prepare(): Promise<PoolStoreOperation>;
165
+ /** Every pool entry, each with its lease, and the entry files it can't read. A pool never written is empty. */
166
+ listEntries(): Promise<PoolStoreResult<PoolListing>>;
167
+ /** Adds `entry`, free, or leased to this process from `lease.startedAt`, writing the lease first. */
168
+ addEntry(entry: PoolEntry, options: {
169
+ readonly lease?: {
170
+ readonly startedAt: string;
171
+ };
172
+ }): Promise<PoolStoreOperation>;
173
+ /** Leases the entry for `host` to this process, unless another holder already has it. */
174
+ lease(host: string, options: {
175
+ readonly startedAt: string;
176
+ }): Promise<LeaseOutcome>;
177
+ /** Under the lease guard: removes the lease on `host` only if this process holds it (same pid and hostname). */
178
+ release(host: string): Promise<ReleaseOutcome>;
179
+ /** Under the lease guard: removes the lease on `host` if `isStale` says the lease read there is stale. */
180
+ reclaim(host: string, isStale: (lease: ObservedLease) => boolean): Promise<ReclaimOutcome>;
181
+ /**
182
+ * Under the lease guard: leases the free entry for `host` to this process, then removes the entry and that
183
+ * lease. An entry another holder leases is left alone.
184
+ */
185
+ dropEntry(host: string): Promise<DropOutcome>;
186
+ /** Every channel resolution, by build channel. None recorded, or a record storm can't read, is none. */
187
+ readChannelResolutions(): Promise<PoolStoreResult<Readonly<Record<string, ChannelResolution>>>>;
188
+ /** Records what `channel` resolved to, replacing any earlier resolution. */
189
+ writeChannelResolution(channel: string, resolution: ChannelResolution): Promise<PoolStoreOperation>;
190
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The host a Testserver sandbox's pool entry is keyed by: its Testserver URL's hostname, such as
3
+ * `sb-4eb2wi4db1he.vercel.run`. `undefined` when the URL doesn't parse or its hostname isn't safe as a file
4
+ * name.
5
+ */
6
+ export declare function sandboxHost(testserverUrl: string): string | undefined;
7
+ /** Whether `host` is safe as a pool file name. */
8
+ export declare function isSafeHost(host: string): boolean;
@@ -0,0 +1,21 @@
1
+ /** A host storm may name a pool entry file after: letters, digits, `.` and `-`, and not `.` or `..`. */
2
+ const SAFE_HOST = /^[A-Za-z0-9.-]+$/;
3
+ /**
4
+ * The host a Testserver sandbox's pool entry is keyed by: its Testserver URL's hostname, such as
5
+ * `sb-4eb2wi4db1he.vercel.run`. `undefined` when the URL doesn't parse or its hostname isn't safe as a file
6
+ * name.
7
+ */
8
+ export function sandboxHost(testserverUrl) {
9
+ let hostname;
10
+ try {
11
+ hostname = new URL(testserverUrl).hostname;
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ return isSafeHost(hostname) ? hostname : undefined;
17
+ }
18
+ /** Whether `host` is safe as a pool file name. */
19
+ export function isSafeHost(host) {
20
+ return SAFE_HOST.test(host) && host !== "." && host !== "..";
21
+ }
@@ -0,0 +1,9 @@
1
+ export { type BuildMatch, buildMatch, type BuildResolution, resolveBuild, type UnresolvedChannelReason, } from "./channels.ts";
2
+ export { createPooledSandbox, type PooledCreateOutcome } from "./create.ts";
3
+ export { POOL_DIRECTORY_PATTERN, POOL_SUBPATH } from "./directory.ts";
4
+ export type { ChannelResolution, DropOutcome, LeaseHolder, LeaseOutcome, LeaseRecord, ListedEntry, ObservedLease, PoolEntry, PoolListing, PoolStoreFailure, PoolStoreGateway, PoolStoreOperation, PoolStoreResult, ReclaimOutcome, ReleaseOutcome, UnreadableEntry, } from "./gateways.ts";
5
+ export { sandboxHost } from "./host.ts";
6
+ export { type InspectedChannelResolution, type InspectedEntry, type InspectedLease, inspectPool, type PoolInspection, } from "./inspect.ts";
7
+ export { type LeasedEntry, type LeaseReport, leaseUsable, releaseLeases, type CheckedEntry, type EntryVerdict, } from "./lease.ts";
8
+ export { livePoolStoreGateway, type LivePoolStoreOptions, unavailablePoolStoreGateway, } from "./live/pool-store-gateway.ts";
9
+ export { minutesSince } from "./staleness.ts";
@@ -0,0 +1,10 @@
1
+ // The Testserver folder's `pool/` barrel, for the other files in `resources/testserver/`. Code outside that folder
2
+ // imports `resources/testserver/index.ts` instead.
3
+ export { buildMatch, resolveBuild, } from "./channels.js";
4
+ export { createPooledSandbox } from "./create.js";
5
+ export { POOL_DIRECTORY_PATTERN, POOL_SUBPATH } from "./directory.js";
6
+ export { sandboxHost } from "./host.js";
7
+ export { inspectPool, } from "./inspect.js";
8
+ export { leaseUsable, releaseLeases, } from "./lease.js";
9
+ export { livePoolStoreGateway, unavailablePoolStoreGateway, } from "./live/pool-store-gateway.js";
10
+ export { minutesSince } from "./staleness.js";
@@ -0,0 +1,53 @@
1
+ import type { HealthCheckGateway, HealthCheckOutcome } from "../sandbox/index.ts";
2
+ import type { Clock } from "../../../time/index.ts";
3
+ import type { ObservedLease, PoolEntry, PoolStoreFailure, PoolStoreGateway, UnreadableEntry } from "./gateways.ts";
4
+ /** A pool entry's lease, as `inspectPool` reports it. */
5
+ export type InspectedLease = {
6
+ readonly state: "free";
7
+ } | ({
8
+ readonly state: "leased" | "stale";
9
+ } & ObservedLease);
10
+ export interface InspectedEntry {
11
+ readonly host: string;
12
+ readonly entry: PoolEntry;
13
+ /** Whole minutes left by its TTL; negative once past it. */
14
+ readonly minutesLeft: number;
15
+ readonly lease: InspectedLease;
16
+ readonly health: HealthCheckOutcome;
17
+ /**
18
+ * Whether a lease guard directory is present beside its lease: held by a running storm run, or left behind
19
+ * by one that died. A guard left behind stops every run from releasing, reclaiming, or dropping that lease
20
+ * until it is removed by hand.
21
+ */
22
+ readonly leaseGuard: boolean;
23
+ }
24
+ export interface InspectedChannelResolution {
25
+ readonly channel: string;
26
+ readonly build: string;
27
+ readonly learnedAt: string;
28
+ /** Whole minutes since it was learned. */
29
+ readonly ageMinutes: number;
30
+ }
31
+ export interface PoolInspection {
32
+ readonly directory: string;
33
+ readonly entries: readonly InspectedEntry[];
34
+ readonly unreadable: readonly UnreadableEntry[];
35
+ /** By build channel name. */
36
+ readonly channels: readonly InspectedChannelResolution[];
37
+ }
38
+ /**
39
+ * The pool as it stands: every pool entry, health-checked in parallel whether leased or not, with its lease
40
+ * state and time left; the entry files that can't be read; and the channel resolutions with their age. It
41
+ * changes nothing: it drops no expired entry and reclaims no stale lease.
42
+ */
43
+ export declare function inspectPool(context: {
44
+ readonly pool: PoolStoreGateway;
45
+ readonly healthChecks: HealthCheckGateway;
46
+ readonly clock: Clock;
47
+ }): Promise<{
48
+ readonly ok: true;
49
+ readonly value: PoolInspection;
50
+ } | {
51
+ readonly ok: false;
52
+ readonly failure: PoolStoreFailure;
53
+ }>;
@@ -0,0 +1,45 @@
1
+ import { leaseState, minutesLeft, minutesSince } from "./staleness.js";
2
+ /**
3
+ * The pool as it stands: every pool entry, health-checked in parallel whether leased or not, with its lease
4
+ * state and time left; the entry files that can't be read; and the channel resolutions with their age. It
5
+ * changes nothing: it drops no expired entry and reclaims no stale lease.
6
+ */
7
+ export async function inspectPool(context) {
8
+ const listed = await context.pool.listEntries();
9
+ if (!listed.ok)
10
+ return listed;
11
+ const channels = await context.pool.readChannelResolutions();
12
+ if (!channels.ok)
13
+ return channels;
14
+ const now = context.clock.now();
15
+ const checked = await Promise.all(listed.value.entries.map(async (listedEntry) => ({
16
+ listedEntry,
17
+ health: await context.healthChecks.check({ testserverUrl: listedEntry.entry.testserverUrl }),
18
+ })));
19
+ const entries = checked.map(({ listedEntry, health }) => ({
20
+ host: listedEntry.host,
21
+ entry: listedEntry.entry,
22
+ minutesLeft: minutesLeft(listedEntry.entry, now),
23
+ lease: inspectLease(listedEntry.lease, listedEntry.entry.ttlMinutes, now),
24
+ health,
25
+ leaseGuard: listedEntry.leaseGuard,
26
+ }));
27
+ const resolutions = Object.entries(channels.value)
28
+ .toSorted(([a], [b]) => a.localeCompare(b))
29
+ .map(([channel, resolution]) => ({
30
+ channel,
31
+ build: resolution.build,
32
+ learnedAt: resolution.learnedAt,
33
+ ageMinutes: minutesSince(resolution.learnedAt, now),
34
+ }));
35
+ return {
36
+ ok: true,
37
+ value: { directory: listed.value.directory, entries, unreadable: listed.value.unreadable, channels: resolutions },
38
+ };
39
+ }
40
+ function inspectLease(lease, ttlMinutes, now) {
41
+ const state = leaseState(lease, ttlMinutes, now);
42
+ if (state === "free" || lease === undefined)
43
+ return { state: "free" };
44
+ return { state, ...lease };
45
+ }
@@ -0,0 +1,84 @@
1
+ import type { HealthCheckGateway, HealthCheckOutcome } from "../sandbox/index.ts";
2
+ import type { Clock } from "../../../time/index.ts";
3
+ import type { BuildMatch } from "./channels.ts";
4
+ import type { PoolEntry, PoolStoreFailure, PoolStoreGateway, UnreadableEntry } from "./gateways.ts";
5
+ /**
6
+ * What a run makes of one free pool entry on its build, from its health check and its time left once the
7
+ * health checks are done:
8
+ *
9
+ * - `usable`: answers and has at least the minimum time left. Usable entries are leased freshest first.
10
+ * - `expired`: answered 410 or 502; the run drops it from the pool.
11
+ * - `kept`: failed its health check but has the minimum time left; it stays in the pool, unused by this run.
12
+ * - `drop-due`: failed its health check without the minimum time left; the run tries to drop it from the pool.
13
+ * - `kept-unused`: answers but has less than the minimum time left; it isn't expired, so it stays.
14
+ *
15
+ * A drop leaves an entry another run leases first, or whose lease guard another run holds.
16
+ */
17
+ export type EntryVerdict = "usable" | "expired" | "kept" | "drop-due" | "kept-unused";
18
+ export interface CheckedEntry {
19
+ readonly host: string;
20
+ readonly entry: PoolEntry;
21
+ readonly minutesLeft: number;
22
+ readonly health: HealthCheckOutcome;
23
+ readonly verdict: EntryVerdict;
24
+ }
25
+ /** A pool entry this run now leases. */
26
+ export interface LeasedEntry {
27
+ readonly host: string;
28
+ readonly entry: PoolEntry;
29
+ }
30
+ /** What `leaseUsable` did, for the run to report. */
31
+ export interface LeaseReport {
32
+ /** The pool entries leased, freshest first: at most the count asked for. */
33
+ readonly leased: readonly LeasedEntry[];
34
+ /** Every free pool entry on the run's build, with its verdict, in pool order. */
35
+ readonly checked: readonly CheckedEntry[];
36
+ /** The hosts whose stale leases were reclaimed. */
37
+ readonly reclaimed: readonly string[];
38
+ /**
39
+ * The hosts dropped from the pool. An entry judged `expired` or `drop-due` that another run leases first, or
40
+ * whose lease guard another run holds, stays and isn't listed.
41
+ */
42
+ readonly dropped: readonly string[];
43
+ /** Lease attempts that found the usable pool entry already leased by another run. */
44
+ readonly lostRaces: number;
45
+ /**
46
+ * The hosts of usable pool entries that had fallen below the minimum time left by the time their lease was
47
+ * attempted. They stay in the pool, unleased.
48
+ */
49
+ readonly belowMinimumAtLease: readonly string[];
50
+ readonly unreadable: readonly UnreadableEntry[];
51
+ /** Pool operations that failed along the way without stopping the run: a drop, a reclaim, or a lease. */
52
+ readonly storeFailures: readonly PoolStoreFailure[];
53
+ }
54
+ /**
55
+ * Leases up to `count` usable pool entries matching `match`. It lists the pool, reclaims stale leases,
56
+ * health-checks every free matching entry in parallel, then reads the clock again to judge each entry's time
57
+ * left. It drops the expired entries and the failed ones without `minTimeLeftMinutes` left, and leases usable
58
+ * ones freshest first. Before each lease attempt it reads the clock again: an entry that has fallen below
59
+ * `minTimeLeftMinutes` is skipped and kept, and each lease starts at its attempt's clock read. An entry
60
+ * another run leases or drops first is skipped for the next. Only a pool that can't be listed stops it.
61
+ */
62
+ export declare function leaseUsable(context: {
63
+ readonly pool: PoolStoreGateway;
64
+ readonly healthChecks: HealthCheckGateway;
65
+ readonly clock: Clock;
66
+ }, request: {
67
+ readonly match: BuildMatch;
68
+ readonly count: number;
69
+ readonly minTimeLeftMinutes: number;
70
+ }): Promise<{
71
+ readonly ok: true;
72
+ readonly report: LeaseReport;
73
+ } | {
74
+ readonly ok: false;
75
+ readonly failure: PoolStoreFailure;
76
+ }>;
77
+ /**
78
+ * Releases this process's leases on `hosts`, in parallel, and returns the releases that failed. A release
79
+ * that finds another run holding the lease guard fails at the guard: its lease stays until this process
80
+ * exits, after which a reclaim frees it.
81
+ */
82
+ export declare function releaseLeases(context: {
83
+ readonly pool: PoolStoreGateway;
84
+ }, hosts: readonly string[]): Promise<readonly PoolStoreFailure[]>;