@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,35 @@
1
+ import type { CreateFailure } from "./gateways.ts";
2
+ /**
3
+ * Whether a Testserver sandbox may exist after `failure`, one nothing can delete, until its TTL runs out.
4
+ *
5
+ * - `connect-failed`: no. The request never reached the Testserver control plane.
6
+ * - `rejected` and `http-error`: no. The control plane's create handler answers 200 and opens its stream before
7
+ * it does any work, so any other status comes from in front of it, before a Testserver sandbox exists.
8
+ * - `stream-error`: yes. The control plane reports through the stream any failure after it created the
9
+ * Testserver sandbox's VMs, and stops nothing. Some errors, such as a missing or expired snapshot, come before
10
+ * any VM exists, but they look the same, and telling them apart by their text would be brittle.
11
+ * - `stream-ended`, `dropped`, `timeout` and `malformed`: yes. The request reached the control plane, and it may
12
+ * have created the Testserver sandbox.
13
+ *
14
+ * Checked against `vercel/api` at `1b73b91b807`: `testserver/create-server/src/app.ts` (`/create-testserver`) and
15
+ * `start-from-snapshot.ts`.
16
+ */
17
+ export declare function mayLeaveSandbox(failure: CreateFailure): boolean;
18
+ /**
19
+ * A failed create described: its `kind`; its `detail`, what the Testserver control plane or the connection said
20
+ * about it, if anything; and its `text`, the two in a few words (`createFailureText`). `kind` keeps the failure's
21
+ * own narrower kind, such as a `FailedCreate`'s.
22
+ */
23
+ export declare function describeCreateFailure<Failure extends CreateFailure>(failure: Failure): {
24
+ readonly kind: Failure["kind"];
25
+ readonly detail: string | null;
26
+ readonly text: string;
27
+ };
28
+ /**
29
+ * A failed create, in a few words: its kind, and its detail (`describeCreateFailure`), if any. For a failed create's
30
+ * facts, as an outcome holds them, when the `CreateFailure` itself is gone.
31
+ */
32
+ export declare function createFailureText(facts: {
33
+ readonly kind: string;
34
+ readonly detail: string | null;
35
+ }): string;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Whether a Testserver sandbox may exist after `failure`, one nothing can delete, until its TTL runs out.
3
+ *
4
+ * - `connect-failed`: no. The request never reached the Testserver control plane.
5
+ * - `rejected` and `http-error`: no. The control plane's create handler answers 200 and opens its stream before
6
+ * it does any work, so any other status comes from in front of it, before a Testserver sandbox exists.
7
+ * - `stream-error`: yes. The control plane reports through the stream any failure after it created the
8
+ * Testserver sandbox's VMs, and stops nothing. Some errors, such as a missing or expired snapshot, come before
9
+ * any VM exists, but they look the same, and telling them apart by their text would be brittle.
10
+ * - `stream-ended`, `dropped`, `timeout` and `malformed`: yes. The request reached the control plane, and it may
11
+ * have created the Testserver sandbox.
12
+ *
13
+ * Checked against `vercel/api` at `1b73b91b807`: `testserver/create-server/src/app.ts` (`/create-testserver`) and
14
+ * `start-from-snapshot.ts`.
15
+ */
16
+ export function mayLeaveSandbox(failure) {
17
+ switch (failure.kind) {
18
+ case "connect-failed":
19
+ case "rejected":
20
+ case "http-error":
21
+ return false;
22
+ case "stream-error":
23
+ case "stream-ended":
24
+ case "dropped":
25
+ case "timeout":
26
+ case "malformed":
27
+ return true;
28
+ }
29
+ }
30
+ /**
31
+ * A failed create described: its `kind`; its `detail`, what the Testserver control plane or the connection said
32
+ * about it, if anything; and its `text`, the two in a few words (`createFailureText`). `kind` keeps the failure's
33
+ * own narrower kind, such as a `FailedCreate`'s.
34
+ */
35
+ export function describeCreateFailure(failure) {
36
+ const detail = detailOf(failure);
37
+ return { kind: failure.kind, detail, text: createFailureText({ kind: failure.kind, detail }) };
38
+ }
39
+ function detailOf(failure) {
40
+ switch (failure.kind) {
41
+ case "connect-failed":
42
+ return failure.code;
43
+ case "rejected":
44
+ return `HTTP ${failure.status}`;
45
+ case "http-error":
46
+ return `HTTP ${failure.status}: ${failure.body}`;
47
+ case "stream-error":
48
+ return failure.error;
49
+ case "stream-ended":
50
+ return null;
51
+ case "dropped":
52
+ return failure.message;
53
+ case "timeout":
54
+ return `after ${failure.seconds}s`;
55
+ case "malformed":
56
+ return failure.detail;
57
+ }
58
+ }
59
+ /**
60
+ * A failed create, in a few words: its kind, and its detail (`describeCreateFailure`), if any. For a failed create's
61
+ * facts, as an outcome holds them, when the `CreateFailure` itself is gone.
62
+ */
63
+ export function createFailureText(facts) {
64
+ return facts.detail === null ? facts.kind : `${facts.kind}: ${facts.detail}`;
65
+ }
@@ -0,0 +1,29 @@
1
+ import type { Credential } from "../../../credential/index.ts";
2
+ import type { ControlPlaneGateway, CreateOutcome, CreateProgress } from "./gateways.ts";
3
+ import type { Timer } from "../../../time/index.ts";
4
+ /**
5
+ * The TTL a Testserver sandbox gets unless the `ttl` setting (`resources.testserverPool.ttl`, `run --testserver-ttl`,
6
+ * or `pool create --ttl`) says otherwise: 5 hours.
7
+ */
8
+ export declare const DEFAULT_TTL_MINUTES = 300;
9
+ /** A TTL as a person reads it: `5 hours`, `1 hour`, `30 minutes`, `90 minutes`. */
10
+ export declare function describeTtl(minutes: number): string;
11
+ /** What `pool create` says about a `--ttl` that `parseTtl` refuses. */
12
+ export declare function invalidTtlMessage(ttl: string): string;
13
+ /** How many creates `createSandbox` attempts when none reaches the Testserver control plane. */
14
+ export declare const CREATE_ATTEMPTS = 3;
15
+ /**
16
+ * Creates one Testserver sandbox on `build` living `ttlMinutes`. It retries only a create that never reached
17
+ * the Testserver control plane (`connect-failed`), up to 3 attempts in all, waiting 1s and then 2s. Any other
18
+ * failure is final: most can leave a Testserver sandbox (see `mayLeaveSandbox`), and a retry would orphan it.
19
+ * A final `connect-failed` means all 3 attempts failed to connect. `progress` hears the
20
+ * Testserver control plane's progress messages from every attempt.
21
+ */
22
+ export declare function createSandbox(context: {
23
+ readonly controlPlane: ControlPlaneGateway;
24
+ readonly timer: Timer;
25
+ }, request: {
26
+ readonly credential: Credential;
27
+ readonly build: string;
28
+ readonly ttlMinutes: number;
29
+ }, progress?: CreateProgress): Promise<CreateOutcome>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The TTL a Testserver sandbox gets unless the `ttl` setting (`resources.testserverPool.ttl`, `run --testserver-ttl`,
3
+ * or `pool create --ttl`) says otherwise: 5 hours.
4
+ */
5
+ export const DEFAULT_TTL_MINUTES = 300;
6
+ /** A TTL as a person reads it: `5 hours`, `1 hour`, `30 minutes`, `90 minutes`. */
7
+ export function describeTtl(minutes) {
8
+ if (minutes % 60 === 0)
9
+ return minutes === 60 ? "1 hour" : `${minutes / 60} hours`;
10
+ return minutes === 1 ? "1 minute" : `${minutes} minutes`;
11
+ }
12
+ /** What `pool create` says about a `--ttl` that `parseTtl` refuses. */
13
+ export function invalidTtlMessage(ttl) {
14
+ return `Expected a whole number of minutes or hours from 10m to 5h, such as 30m or 2h, not ${ttl}.`;
15
+ }
16
+ /** How many creates `createSandbox` attempts when none reaches the Testserver control plane. */
17
+ export const CREATE_ATTEMPTS = 3;
18
+ /** The wait before each retry: 1s before the second attempt, 2s before the third. */
19
+ const RETRY_WAITS_MS = [1000, 2000];
20
+ /**
21
+ * Creates one Testserver sandbox on `build` living `ttlMinutes`. It retries only a create that never reached
22
+ * the Testserver control plane (`connect-failed`), up to 3 attempts in all, waiting 1s and then 2s. Any other
23
+ * failure is final: most can leave a Testserver sandbox (see `mayLeaveSandbox`), and a retry would orphan it.
24
+ * A final `connect-failed` means all 3 attempts failed to connect. `progress` hears the
25
+ * Testserver control plane's progress messages from every attempt.
26
+ */
27
+ export async function createSandbox(context, request, progress = {}) {
28
+ const create = { credential: request.credential, build: request.build, ttlMinutes: request.ttlMinutes };
29
+ let outcome = await context.controlPlane.create(create, progress);
30
+ for (const wait of RETRY_WAITS_MS) {
31
+ if (outcome.ok || outcome.failure.kind !== "connect-failed")
32
+ return outcome;
33
+ await context.timer.sleep(wait);
34
+ outcome = await context.controlPlane.create(create, progress);
35
+ }
36
+ return outcome;
37
+ }
@@ -0,0 +1,150 @@
1
+ import type { Credential } from "../../../credential/index.ts";
2
+ /** One build of Testserver, as `GET /builds` lists it. `name` is its bundle name, `<timestamp>__<commit>`. */
3
+ export interface Build {
4
+ readonly name: string;
5
+ readonly commitSha?: string;
6
+ readonly createdAt?: string;
7
+ }
8
+ /** What `GET /builds` says each build channel points to: `stable`, if any, and `main`, newest first. */
9
+ export interface Builds {
10
+ readonly stable?: Build;
11
+ readonly main: readonly Build[];
12
+ }
13
+ /** A Testserver sandbox the Testserver control plane created. */
14
+ export interface CreatedSandbox {
15
+ /** The Testserver URL, with no trailing slash. */
16
+ readonly testserverUrl: string;
17
+ /** The log viewer URL, with no trailing slash. */
18
+ readonly logViewerUrl: string;
19
+ /** The build the Testserver sandbox runs: the last segment of the create response's `blobPath`. */
20
+ readonly resolvedBuild: string;
21
+ }
22
+ /**
23
+ * Why a create failed.
24
+ *
25
+ * - `connect-failed`: the request never reached the Testserver control plane (`code` is the network error's
26
+ * code, such as `ECONNREFUSED`). Only this failure is safe to retry: no Testserver sandbox can exist.
27
+ * - `rejected`: Vercel Authentication refused the credential (a 3xx redirect to SSO, a 401 or a 403).
28
+ * - `http-error`: any other non-ok status; `body` is the first 200 characters of the response. It comes from in
29
+ * front of the control plane's create stream, so no Testserver sandbox exists.
30
+ * - `stream-error`: the create stream reported a failure; `error` is its text. It may come after the control
31
+ * plane created the Testserver sandbox's VMs.
32
+ * - `stream-ended`: the stream ended without a sandbox config.
33
+ * - `dropped`: the connection failed after the request reached the control plane.
34
+ * - `timeout`: the whole create took longer than its timeout.
35
+ * - `malformed`: the sandbox config lacked a Testserver URL, log viewer URL or resolved build.
36
+ *
37
+ * `mayLeaveSandbox` says which failures may leave a Testserver sandbox running until its TTL runs out.
38
+ */
39
+ export type CreateFailure = {
40
+ readonly kind: "connect-failed";
41
+ readonly code: string;
42
+ } | {
43
+ readonly kind: "rejected";
44
+ readonly status: number;
45
+ readonly vercelId?: string;
46
+ } | {
47
+ readonly kind: "http-error";
48
+ readonly status: number;
49
+ readonly body: string;
50
+ } | {
51
+ readonly kind: "stream-error";
52
+ readonly error: string;
53
+ } | {
54
+ readonly kind: "stream-ended";
55
+ } | {
56
+ readonly kind: "dropped";
57
+ readonly message: string;
58
+ } | {
59
+ readonly kind: "timeout";
60
+ readonly seconds: number;
61
+ } | {
62
+ readonly kind: "malformed";
63
+ readonly detail: string;
64
+ };
65
+ export type CreateOutcome = {
66
+ readonly ok: true;
67
+ readonly sandbox: CreatedSandbox;
68
+ } | {
69
+ readonly ok: false;
70
+ readonly failure: CreateFailure;
71
+ };
72
+ /** Why `GET /builds` failed. The kinds mean what they mean for a create. */
73
+ export type BuildsFailure = {
74
+ readonly kind: "connect-failed";
75
+ readonly code: string;
76
+ } | {
77
+ readonly kind: "rejected";
78
+ readonly status: number;
79
+ readonly vercelId?: string;
80
+ } | {
81
+ readonly kind: "http-error";
82
+ readonly status: number;
83
+ readonly body: string;
84
+ } | {
85
+ readonly kind: "dropped";
86
+ readonly message: string;
87
+ } | {
88
+ readonly kind: "timeout";
89
+ readonly seconds: number;
90
+ } | {
91
+ readonly kind: "malformed";
92
+ readonly detail: string;
93
+ };
94
+ export type BuildsOutcome = {
95
+ readonly ok: true;
96
+ readonly value: Builds;
97
+ } | {
98
+ readonly ok: false;
99
+ readonly failure: BuildsFailure;
100
+ };
101
+ /** One create: on `build` (a build or build channel), living `ttlMinutes`. */
102
+ export interface CreateRequest {
103
+ readonly credential: Credential;
104
+ readonly build: string;
105
+ readonly ttlMinutes: number;
106
+ }
107
+ /** What a caller hears while a create runs. */
108
+ export interface CreateProgress {
109
+ /** Each progress message the Testserver control plane sends, such as `Restoring snapshot`, in order. */
110
+ readonly onProgress?: (message: string) => Promise<void>;
111
+ }
112
+ /**
113
+ * The Testserver control plane. Each call is one attempt, and no method rejects: every failure is in the
114
+ * outcome. Whether to retry is the caller's decision (see `createSandbox`).
115
+ */
116
+ export interface ControlPlaneGateway {
117
+ /** Creates one Testserver sandbox, passing on the control plane's progress messages as they arrive. */
118
+ create(request: CreateRequest, progress?: CreateProgress): Promise<CreateOutcome>;
119
+ /** Lists what each build channel points to. */
120
+ builds(request: {
121
+ readonly credential: Credential;
122
+ }): Promise<BuildsOutcome>;
123
+ }
124
+ /**
125
+ * What one health check showed.
126
+ *
127
+ * - `answers`: the Testserver sandbox answered with a 2xx `status`.
128
+ * - `expired`: it answered 410 or 502, which a Testserver sandbox past its TTL answers.
129
+ * - `failed`: anything else: a 3xx (never followed), another status, a timeout, a refused or dropped
130
+ * connection. `detail` is the status (`HTTP 500`) or a short reason.
131
+ */
132
+ export type HealthCheckOutcome = {
133
+ readonly kind: "answers";
134
+ readonly status: number;
135
+ } | {
136
+ readonly kind: "expired";
137
+ readonly status: number;
138
+ } | {
139
+ readonly kind: "failed";
140
+ readonly detail: string;
141
+ };
142
+ /**
143
+ * Health-checks Testserver sandboxes: one `GET` of the Testserver URL itself, not of the Testserver control
144
+ * plane, and with no credential. It never rejects: every failure is a `failed` outcome.
145
+ */
146
+ export interface HealthCheckGateway {
147
+ check(request: {
148
+ readonly testserverUrl: string;
149
+ }): Promise<HealthCheckOutcome>;
150
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export { BUILD_CHANNELS, type BuildChannel, isBuildChannel, resolveChannel } from "./channels.ts";
2
+ export { CREATE_ATTEMPTS, createSandbox, DEFAULT_TTL_MINUTES, describeTtl, invalidTtlMessage } from "./create.ts";
3
+ export { createFailureText, describeCreateFailure, mayLeaveSandbox } from "./create-failure.ts";
4
+ export type { Build, Builds, BuildsFailure, BuildsOutcome, ControlPlaneGateway, CreatedSandbox, CreateFailure, CreateOutcome, CreateProgress, CreateRequest, HealthCheckGateway, HealthCheckOutcome, } from "./gateways.ts";
5
+ export { liveControlPlaneGateway, type LiveControlPlaneOptions } from "./live/control-plane-gateway.ts";
6
+ export { liveHealthCheckGateway, type LiveHealthCheckOptions } from "./live/health-check-gateway.ts";
@@ -0,0 +1,7 @@
1
+ // The Testserver folder's `sandbox/` barrel, for the other files in `resources/testserver/`. Code outside that folder
2
+ // imports `resources/testserver/index.ts` instead.
3
+ export { BUILD_CHANNELS, isBuildChannel, resolveChannel } from "./channels.js";
4
+ export { CREATE_ATTEMPTS, createSandbox, DEFAULT_TTL_MINUTES, describeTtl, invalidTtlMessage } from "./create.js";
5
+ export { createFailureText, describeCreateFailure, mayLeaveSandbox } from "./create-failure.js";
6
+ export { liveControlPlaneGateway } from "./live/control-plane-gateway.js";
7
+ export { liveHealthCheckGateway } from "./live/health-check-gateway.js";
@@ -0,0 +1,9 @@
1
+ import type { Builds } from "../gateways.ts";
2
+ /** The builds a `GET /builds` body lists, or why it isn't a builds document. */
3
+ export declare function parseBuilds(json: unknown): {
4
+ readonly ok: true;
5
+ readonly value: Builds;
6
+ } | {
7
+ readonly ok: false;
8
+ readonly detail: string;
9
+ };
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ // `GET /builds` answers `{ stable: SnapshotInfo | null, main: SnapshotInfo[] }`, `main` newest first. Only
3
+ // the fields storm uses are read; the rest are ignored.
4
+ const wireBuildSchema = z.object({
5
+ bundleName: z.string().min(1),
6
+ commitSha: z.string().optional(),
7
+ createdAt: z.string().optional(),
8
+ });
9
+ const buildsSchema = z.object({ stable: wireBuildSchema.nullable(), main: z.array(wireBuildSchema) });
10
+ /** The builds a `GET /builds` body lists, or why it isn't a builds document. */
11
+ export function parseBuilds(json) {
12
+ const parsed = buildsSchema.safeParse(json);
13
+ if (!parsed.success) {
14
+ const issue = parsed.error.issues[0];
15
+ const where = issue === undefined || issue.path.length === 0 ? "the body" : issue.path.join(".");
16
+ return { ok: false, detail: `${where}: ${issue?.message ?? "not a builds document"}` };
17
+ }
18
+ const { stable, main } = parsed.data;
19
+ return { ok: true, value: { ...(stable === null ? {} : { stable: toBuild(stable) }), main: main.map(toBuild) } };
20
+ }
21
+ function toBuild(wire) {
22
+ return {
23
+ name: wire.bundleName,
24
+ ...(wire.commitSha === undefined ? {} : { commitSha: wire.commitSha }),
25
+ ...(wire.createdAt === undefined ? {} : { createdAt: wire.createdAt }),
26
+ };
27
+ }
@@ -0,0 +1,17 @@
1
+ import type { ControlPlaneGateway } from "../gateways.ts";
2
+ /** The header the Testserver control plane reads the credential from. */
3
+ export declare const CREDENTIAL_HEADER = "x-vercel-trusted-oidc-idp-token";
4
+ export interface LiveControlPlaneOptions {
5
+ /** The control plane's origin, such as `https://testserver.vercel.sh`, with no trailing slash. */
6
+ readonly origin: string;
7
+ /** How long one whole create, stream included, may take. */
8
+ readonly streamTimeoutMs: number;
9
+ /** How long one `GET /builds` may take. */
10
+ readonly buildsTimeoutMs: number;
11
+ }
12
+ /**
13
+ * The Testserver control plane over `fetch`. Each request carries the credential in its header, follows no
14
+ * redirect (Vercel Authentication answers a refused credential with a redirect to SSO), and has a timeout
15
+ * for the whole exchange. No method rejects.
16
+ */
17
+ export declare function liveControlPlaneGateway(options: LiveControlPlaneOptions): ControlPlaneGateway;
@@ -0,0 +1,133 @@
1
+ import { parseBuilds } from "./builds-response.js";
2
+ import { classifyCreateEvent, parseEventData, readSandboxConfig } from "./create-response.js";
3
+ import { errorMessage, fetchFailure } from "./fetch-failure.js";
4
+ import { SseDataReader } from "./sse.js";
5
+ /** The header the Testserver control plane reads the credential from. */
6
+ export const CREDENTIAL_HEADER = "x-vercel-trusted-oidc-idp-token";
7
+ /** How much of a failed response's body a failure quotes. */
8
+ const BODY_LIMIT = 200;
9
+ /**
10
+ * The Testserver control plane over `fetch`. Each request carries the credential in its header, follows no
11
+ * redirect (Vercel Authentication answers a refused credential with a redirect to SSO), and has a timeout
12
+ * for the whole exchange. No method rejects.
13
+ */
14
+ export function liveControlPlaneGateway(options) {
15
+ return {
16
+ create: (request, progress) => create(options, request, progress),
17
+ builds: (request) => builds(options, request.credential),
18
+ };
19
+ }
20
+ async function create(options, request, progress = {}) {
21
+ const url = new URL("/create-testserver", options.origin);
22
+ url.searchParams.set("build", request.build);
23
+ url.searchParams.set("timeout", String(request.ttlMinutes));
24
+ const signal = AbortSignal.timeout(options.streamTimeoutMs);
25
+ const seconds = options.streamTimeoutMs / 1000;
26
+ let response;
27
+ try {
28
+ response = await fetch(url, { headers: credentialHeaders(request.credential), redirect: "manual", signal });
29
+ }
30
+ catch (error) {
31
+ return { ok: false, failure: fetchFailure(error, signal, seconds) };
32
+ }
33
+ const refused = await refusal(response);
34
+ if (refused !== undefined)
35
+ return { ok: false, failure: refused };
36
+ try {
37
+ return await readCreateStream(response, progress);
38
+ }
39
+ catch (error) {
40
+ // Not `fetchFailure`: the request reached the control plane, so this failure must never read as
41
+ // `connect-failed`, which `createSandbox` retries. A retry now could orphan a Testserver sandbox.
42
+ if (signal.aborted)
43
+ return { ok: false, failure: { kind: "timeout", seconds } };
44
+ return { ok: false, failure: { kind: "dropped", message: errorMessage(error) } };
45
+ }
46
+ }
47
+ /**
48
+ * Reads the create stream until the sandbox config or a failure arrives, and returns at once: the server
49
+ * may hold the stream open after the config. Passes each progress message on as it arrives. Cancels the
50
+ * body however it ends.
51
+ */
52
+ async function readCreateStream(response, progress) {
53
+ if (response.body === null)
54
+ return { ok: false, failure: { kind: "stream-ended" } };
55
+ const reader = response.body.getReader();
56
+ const decoder = new TextDecoder();
57
+ const sse = new SseDataReader();
58
+ try {
59
+ for (;;) {
60
+ const read = await reader.read();
61
+ const payloads = read.done
62
+ ? [...sse.push(decoder.decode()), ...sse.end()]
63
+ : sse.push(decoder.decode(bytesOf(read.value), { stream: true }));
64
+ for (const payload of payloads) {
65
+ const event = classifyCreateEvent(parseEventData(payload));
66
+ if (event.kind === "error")
67
+ return { ok: false, failure: { kind: "stream-error", error: event.error } };
68
+ if (event.kind === "config")
69
+ return readSandboxConfig(event.config);
70
+ if (event.kind === "progress")
71
+ await progress.onProgress?.(event.message);
72
+ }
73
+ if (read.done)
74
+ return { ok: false, failure: { kind: "stream-ended" } };
75
+ }
76
+ }
77
+ finally {
78
+ reader.cancel().catch(() => { });
79
+ }
80
+ }
81
+ /** A body chunk, which a fetch body yields as bytes; anything else is what `TextDecoder` would refuse. */
82
+ function bytesOf(chunk) {
83
+ if (!(chunk instanceof Uint8Array))
84
+ throw new TypeError("The create stream yielded a chunk that isn't bytes");
85
+ return chunk;
86
+ }
87
+ async function builds(options, credential) {
88
+ const signal = AbortSignal.timeout(options.buildsTimeoutMs);
89
+ const seconds = options.buildsTimeoutMs / 1000;
90
+ try {
91
+ const response = await fetch(new URL("/builds", options.origin), {
92
+ headers: credentialHeaders(credential),
93
+ redirect: "manual",
94
+ signal,
95
+ });
96
+ const refused = await refusal(response);
97
+ if (refused !== undefined)
98
+ return { ok: false, failure: refused };
99
+ const text = await response.text();
100
+ let json;
101
+ try {
102
+ json = JSON.parse(text);
103
+ }
104
+ catch {
105
+ return { ok: false, failure: { kind: "malformed", detail: `the body isn't JSON: ${text.slice(0, BODY_LIMIT)}` } };
106
+ }
107
+ const parsed = parseBuilds(json);
108
+ return parsed.ok ? parsed : { ok: false, failure: { kind: "malformed", detail: parsed.detail } };
109
+ }
110
+ catch (error) {
111
+ return { ok: false, failure: fetchFailure(error, signal, seconds) };
112
+ }
113
+ }
114
+ /**
115
+ * The failure a non-ok response means: `rejected` for a 3xx, 401 or 403, which is Vercel Authentication
116
+ * refusing the credential, and `http-error` with the start of the body for any other non-ok status.
117
+ * `undefined` for an ok response.
118
+ */
119
+ async function refusal(response) {
120
+ const { status } = response;
121
+ if ((status >= 300 && status < 400) || status === 401 || status === 403) {
122
+ await response.body?.cancel().catch(() => { });
123
+ const vercelId = response.headers.get("x-vercel-id");
124
+ return { kind: "rejected", status, ...(vercelId === null ? {} : { vercelId }) };
125
+ }
126
+ if (response.ok)
127
+ return undefined;
128
+ const body = await response.text().catch(() => "");
129
+ return { kind: "http-error", status, body: body.slice(0, BODY_LIMIT) };
130
+ }
131
+ function credentialHeaders(credential) {
132
+ return { [CREDENTIAL_HEADER]: credential.reveal() };
133
+ }
@@ -0,0 +1,35 @@
1
+ import type { CreatedSandbox, CreateFailure } from "../gateways.ts";
2
+ /** What one create stream payload means. */
3
+ export type CreateEvent = {
4
+ readonly kind: "config";
5
+ readonly config: Readonly<Record<string, unknown>>;
6
+ } | {
7
+ readonly kind: "error";
8
+ readonly error: string;
9
+ } | {
10
+ readonly kind: "progress";
11
+ readonly message: string;
12
+ } | {
13
+ readonly kind: "ignored";
14
+ };
15
+ /** A `data:` payload parsed as JSON, or `undefined` when it isn't JSON. */
16
+ export declare function parseEventData(payload: string): unknown;
17
+ /**
18
+ * Classifies a parsed payload: an object with `error` is the create's failure (a non-string error is quoted
19
+ * as JSON), one with a string `testserverUrl` is the sandbox config, one with a nonblank string `message` is
20
+ * progress (warnings too, which arrive under `event: error`), and anything else is ignored. A progress
21
+ * message is cut to its first line, without control characters.
22
+ */
23
+ export declare function classifyCreateEvent(json: unknown): CreateEvent;
24
+ /**
25
+ * The created Testserver sandbox a sandbox config describes: its Testserver URL and log viewer URL (`logsUrl`),
26
+ * each without trailing slashes, and the resolved build, the last path segment of `blobPath`
27
+ * (`builds/main/<build>`). A missing or empty field is `malformed`.
28
+ */
29
+ export declare function readSandboxConfig(config: Readonly<Record<string, unknown>>): {
30
+ readonly ok: true;
31
+ readonly sandbox: CreatedSandbox;
32
+ } | {
33
+ readonly ok: false;
34
+ readonly failure: CreateFailure;
35
+ };
@@ -0,0 +1,78 @@
1
+ // What the create stream's `data:` payloads mean. The Testserver control plane sends `{ message }` frames
2
+ // for progress (under `event: log`) and for warnings (under `event: error`), `{ error }` for a failure, and
3
+ // the sandbox config, with `testserverUrl`, on success. As vercel-internal's `create-testserver.mjs` does,
4
+ // each payload is classified by its fields and the `event:` name is ignored.
5
+ /** A `data:` payload parsed as JSON, or `undefined` when it isn't JSON. */
6
+ export function parseEventData(payload) {
7
+ try {
8
+ return JSON.parse(payload);
9
+ }
10
+ catch {
11
+ return undefined;
12
+ }
13
+ }
14
+ /**
15
+ * Classifies a parsed payload: an object with `error` is the create's failure (a non-string error is quoted
16
+ * as JSON), one with a string `testserverUrl` is the sandbox config, one with a nonblank string `message` is
17
+ * progress (warnings too, which arrive under `event: error`), and anything else is ignored. A progress
18
+ * message is cut to its first line, without control characters.
19
+ */
20
+ export function classifyCreateEvent(json) {
21
+ if (typeof json !== "object" || json === null || Array.isArray(json))
22
+ return { kind: "ignored" };
23
+ const event = json;
24
+ const error = event["error"];
25
+ if (error !== undefined)
26
+ return { kind: "error", error: typeof error === "string" ? error : JSON.stringify(error) };
27
+ if (typeof event["testserverUrl"] === "string")
28
+ return { kind: "config", config: event };
29
+ const message = event["message"];
30
+ if (typeof message === "string") {
31
+ const line = progressLine(message);
32
+ if (line !== "")
33
+ return { kind: "progress", message: line };
34
+ }
35
+ return { kind: "ignored" };
36
+ }
37
+ /**
38
+ * The created Testserver sandbox a sandbox config describes: its Testserver URL and log viewer URL (`logsUrl`),
39
+ * each without trailing slashes, and the resolved build, the last path segment of `blobPath`
40
+ * (`builds/main/<build>`). A missing or empty field is `malformed`.
41
+ */
42
+ export function readSandboxConfig(config) {
43
+ const testserverUrl = nonEmpty(config["testserverUrl"]);
44
+ if (testserverUrl === undefined)
45
+ return malformed("the sandbox config has no testserverUrl");
46
+ const logViewerUrl = nonEmpty(config["logsUrl"]);
47
+ if (logViewerUrl === undefined)
48
+ return malformed("the sandbox config has no logsUrl");
49
+ const blobPath = config["blobPath"];
50
+ if (typeof blobPath !== "string")
51
+ return malformed("the sandbox config has no blobPath");
52
+ const resolvedBuild = blobPath.split("/").at(-1) ?? "";
53
+ if (resolvedBuild === "")
54
+ return malformed(`the sandbox config's blobPath names no build: ${blobPath}`);
55
+ return {
56
+ ok: true,
57
+ sandbox: {
58
+ testserverUrl: stripTrailingSlashes(testserverUrl),
59
+ logViewerUrl: stripTrailingSlashes(logViewerUrl),
60
+ resolvedBuild,
61
+ },
62
+ };
63
+ }
64
+ /** The first nonblank line of `message`, trimmed, with control characters removed. */
65
+ function progressLine(message) {
66
+ const line = message.split(/\r?\n/).find((candidate) => candidate.trim() !== "") ?? "";
67
+ // oxlint-disable-next-line no-control-regex -- removing control characters is the point.
68
+ return line.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").trim();
69
+ }
70
+ function nonEmpty(value) {
71
+ return typeof value === "string" && stripTrailingSlashes(value) !== "" ? value : undefined;
72
+ }
73
+ function stripTrailingSlashes(url) {
74
+ return url.replace(/\/+$/, "");
75
+ }
76
+ function malformed(detail) {
77
+ return { ok: false, failure: { kind: "malformed", detail } };
78
+ }