@cnc-tools/storm 0.10.0 → 0.12.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 (461) hide show
  1. package/dist/bin/storm.js +12 -9
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-YF3ICDBY.js → chunk-43MWZLJR.js} +1 -1
  4. package/dist/chunks/chunk-4XT5RC5T.js +98 -0
  5. package/dist/chunks/chunk-7D6LC5JY.js +340 -0
  6. package/dist/chunks/{chunk-WF4KJ7YG.js → chunk-BW2ADH7U.js} +1 -1
  7. package/dist/chunks/chunk-FK4RLDEK.js +40 -0
  8. package/dist/chunks/chunk-FSP3SJ35.js +1429 -0
  9. package/dist/chunks/{chunk-J6ZNYUDV.js → chunk-GQIL3AHY.js} +2 -3
  10. package/dist/chunks/chunk-GSC6SRTW.js +27 -0
  11. package/dist/chunks/chunk-ISGQJIQM.js +852 -0
  12. package/dist/chunks/chunk-IYM44FUX.js +1461 -0
  13. package/dist/chunks/{chunk-XHJGHJBW.js → chunk-LQKNI3EG.js} +38 -279
  14. package/dist/chunks/chunk-NMVODY3P.js +19 -0
  15. package/dist/chunks/{chunk-VJQLMGOH.js → chunk-ODQHQJLE.js} +2761 -3699
  16. package/dist/chunks/chunk-RYRJNHL7.js +55 -0
  17. package/dist/chunks/chunk-SXW6XN4R.js +161 -0
  18. package/dist/chunks/{chunk-OVXD7GES.js → chunk-T6AZIDZD.js} +43 -396
  19. package/dist/chunks/chunk-TEEZL3GA.js +851 -0
  20. package/dist/chunks/chunk-TMQQYHUX.js +80 -0
  21. package/dist/chunks/{chunk-AKKNF3WZ.js → chunk-U7M3ZB3Z.js} +565 -595
  22. package/dist/chunks/{chunk-JQ2HK4RN.js → chunk-Y3BUNNRG.js} +234 -57
  23. package/dist/chunks/{chunk-ZJ2USLAT.js → chunk-YM6TZV4L.js} +394 -416
  24. package/dist/chunks/chunk-YT5OROR7.js +271 -0
  25. package/dist/chunks/{live-app-RIJM3QFD.js → live-app-AZ5N5HBD.js} +36 -12
  26. package/dist/command-tree.d.ts +4 -1
  27. package/dist/command-tree.js +4 -1
  28. package/dist/commands/exec/cleanup.d.ts +3 -3
  29. package/dist/commands/exec/cleanup.js +6 -2
  30. package/dist/commands/exec/command.d.ts +56 -17
  31. package/dist/commands/exec/command.js +51 -39
  32. package/dist/commands/exec/define-run-command.d.ts +752 -0
  33. package/dist/commands/exec/define-run-command.js +58 -0
  34. package/dist/commands/exec/driver-plan.d.ts +30 -0
  35. package/dist/commands/exec/driver-plan.js +44 -0
  36. package/dist/commands/exec/driver-refusals.d.ts +89 -0
  37. package/dist/commands/exec/driver-refusals.js +65 -0
  38. package/dist/commands/exec/exec-words.d.ts +5 -0
  39. package/dist/commands/exec/exec-words.js +31 -0
  40. package/dist/commands/exec/job-summary.d.ts +1 -1
  41. package/dist/commands/exec/job-summary.js +1 -1
  42. package/dist/commands/exec/live-view.js +58 -28
  43. package/dist/commands/exec/mint-failed.js +5 -5
  44. package/dist/commands/exec/outcomes.d.ts +72 -10
  45. package/dist/commands/exec/outcomes.js +38 -10
  46. package/dist/commands/exec/plan-run.d.ts +3 -5
  47. package/dist/commands/exec/plan-run.js +3 -3
  48. package/dist/commands/exec/progress.d.ts +35 -15
  49. package/dist/commands/exec/progress.js +82 -57
  50. package/dist/commands/exec/resource-flags.d.ts +10 -3
  51. package/dist/commands/exec/resource-flags.js +25 -14
  52. package/dist/commands/exec/resource-refusals.d.ts +2 -2
  53. package/dist/commands/exec/resource-refusals.js +10 -10
  54. package/dist/commands/exec/run-bin.d.ts +35 -0
  55. package/dist/commands/exec/run-bin.js +32 -0
  56. package/dist/commands/exec/run-command.d.ts +85 -20
  57. package/dist/commands/exec/run-command.js +142 -238
  58. package/dist/commands/exec/run-metadata.d.ts +29 -17
  59. package/dist/commands/exec/run-metadata.js +38 -16
  60. package/dist/commands/exec/snapshot-text.d.ts +40 -0
  61. package/dist/commands/exec/snapshot-text.js +112 -0
  62. package/dist/commands/exec/test-plan.d.ts +3 -37
  63. package/dist/commands/exec/test-plan.js +11 -28
  64. package/dist/commands/exec/tests-summary.d.ts +21 -12
  65. package/dist/commands/exec/tests-summary.js +67 -39
  66. package/dist/commands/exec/text.d.ts +5 -0
  67. package/dist/commands/exec/text.js +7 -0
  68. package/dist/commands/exec/view.js +22 -13
  69. package/dist/commands/exec/waterfall.d.ts +3 -1
  70. package/dist/commands/exec/waterfall.js +20 -3
  71. package/dist/commands/exec/worker-chart.d.ts +19 -11
  72. package/dist/commands/exec/worker-chart.js +66 -36
  73. package/dist/commands/playwright/command.d.ts +746 -0
  74. package/dist/commands/playwright/command.js +31 -0
  75. package/dist/commands/playwright/metadata.d.ts +4 -0
  76. package/dist/commands/playwright/metadata.js +8 -0
  77. package/dist/commands/runs/facts.d.ts +22 -8
  78. package/dist/commands/runs/facts.js +19 -9
  79. package/dist/commands/runs/list/command.d.ts +34 -8
  80. package/dist/commands/runs/list/command.js +18 -13
  81. package/dist/commands/runs/list/outcomes.d.ts +17 -4
  82. package/dist/commands/runs/logs/command.js +20 -14
  83. package/dist/commands/runs/logs/outcomes.js +1 -1
  84. package/dist/commands/runs/past-run.d.ts +3 -27
  85. package/dist/commands/runs/past-run.js +3 -37
  86. package/dist/commands/runs/show/command.d.ts +36 -8
  87. package/dist/commands/runs/show/command.js +53 -33
  88. package/dist/commands/runs/show/metadata.js +1 -1
  89. package/dist/commands/runs/show/outcomes.d.ts +18 -4
  90. package/dist/commands/runs/show/outcomes.js +37 -16
  91. package/dist/commands/snapshots/build/command.d.ts +898 -0
  92. package/dist/commands/snapshots/build/command.js +511 -0
  93. package/dist/commands/snapshots/build/metadata.d.ts +28 -0
  94. package/dist/commands/snapshots/build/metadata.js +34 -0
  95. package/dist/commands/snapshots/build/outcomes.d.ts +484 -0
  96. package/dist/commands/snapshots/build/outcomes.js +322 -0
  97. package/dist/commands/snapshots/list/command.d.ts +272 -0
  98. package/dist/commands/snapshots/list/command.js +305 -0
  99. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  100. package/dist/commands/snapshots/list/metadata.js +24 -0
  101. package/dist/commands/snapshots/list/outcomes.d.ts +183 -0
  102. package/dist/commands/snapshots/list/outcomes.js +257 -0
  103. package/dist/commands/snapshots/metadata.d.ts +3 -0
  104. package/dist/commands/snapshots/metadata.js +7 -0
  105. package/dist/commands/vitest/command.d.ts +267 -298
  106. package/dist/commands/vitest/command.js +23 -174
  107. package/dist/commands/vitest/metadata.js +1 -1
  108. package/dist/config/credential-resolver.d.ts +6 -3
  109. package/dist/config/credential-resolver.js +6 -5
  110. package/dist/config-file/define.d.ts +1 -1
  111. package/dist/context.d.ts +44 -24
  112. package/dist/context.js +20 -13
  113. package/dist/core/before-run.d.ts +7 -6
  114. package/dist/core/before-run.js +9 -9
  115. package/dist/core/definition-lookup.d.ts +22 -0
  116. package/dist/core/definition-lookup.js +35 -0
  117. package/dist/core/drivers-of.d.ts +23 -0
  118. package/dist/core/drivers-of.js +13 -0
  119. package/dist/core/events.d.ts +6 -22
  120. package/dist/core/gateways.d.ts +38 -170
  121. package/dist/core/index.d.ts +13 -12
  122. package/dist/core/index.js +12 -11
  123. package/dist/core/launcher-context.d.ts +11 -0
  124. package/dist/core/launcher-context.js +31 -0
  125. package/dist/core/live/package-bin-gateway.d.ts +6 -0
  126. package/dist/core/live/package-bin-gateway.js +24 -0
  127. package/dist/core/package-bin.d.ts +7 -0
  128. package/dist/core/package-bin.js +30 -0
  129. package/dist/core/presentations.d.ts +5 -4
  130. package/dist/core/presentations.js +9 -9
  131. package/dist/core/resource-definition-set.d.ts +39 -0
  132. package/dist/core/resource-definition-set.js +31 -0
  133. package/dist/core/resource-reports.d.ts +38 -5
  134. package/dist/core/resource-reports.js +47 -17
  135. package/dist/core/resource.d.ts +4 -4
  136. package/dist/core/resources.d.ts +8 -7
  137. package/dist/core/resources.js +11 -13
  138. package/dist/core/run-state.d.ts +27 -16
  139. package/dist/core/run-state.js +50 -18
  140. package/dist/core/run.d.ts +42 -54
  141. package/dist/core/run.js +72 -122
  142. package/dist/core/setup-phases.d.ts +14 -0
  143. package/dist/core/setup-phases.js +24 -0
  144. package/dist/core/state-directory.d.ts +2 -2
  145. package/dist/core/state-directory.js +3 -3
  146. package/dist/core/timeline.d.ts +4 -2
  147. package/dist/core/timeline.js +11 -4
  148. package/dist/credential/events.d.ts +20 -0
  149. package/dist/credential/events.js +4 -0
  150. package/dist/credential/index.d.ts +2 -1
  151. package/dist/credential/index.js +6 -5
  152. package/dist/credential/source.d.ts +38 -26
  153. package/dist/credential/source.js +25 -34
  154. package/dist/extension-commands.d.ts +12 -6
  155. package/dist/extension-commands.js +16 -13
  156. package/dist/extensions/github/{world.d.ts → context.d.ts} +1 -1
  157. package/dist/extensions/github/context.js +3 -0
  158. package/dist/extensions/github/definition.d.ts +1 -1
  159. package/dist/extensions/github/definition.js +3 -3
  160. package/dist/extensions/github/extension.d.ts +1 -1
  161. package/dist/extensions/github/index.d.ts +2 -2
  162. package/dist/extensions/github/index.js +4 -4
  163. package/dist/extensions/github/lifecycle.d.ts +3 -3
  164. package/dist/extensions/github/lifecycle.js +14 -14
  165. package/dist/extensions/github/live/context.d.ts +6 -0
  166. package/dist/extensions/github/live/context.js +16 -0
  167. package/dist/extensions/github/resource.d.ts +1 -1
  168. package/dist/extensions/playwright/driver.d.ts +8 -0
  169. package/dist/extensions/playwright/driver.js +60 -0
  170. package/dist/extensions/playwright/extension.d.ts +2 -0
  171. package/dist/extensions/playwright/extension.js +12 -0
  172. package/dist/extensions/playwright/plan/gateways.d.ts +62 -0
  173. package/dist/extensions/playwright/plan/gateways.js +4 -0
  174. package/dist/extensions/playwright/plan/list-output.d.ts +26 -0
  175. package/dist/extensions/playwright/plan/list-output.js +101 -0
  176. package/dist/extensions/playwright/plan/live/list-gateway.d.ts +15 -0
  177. package/dist/extensions/playwright/plan/live/list-gateway.js +100 -0
  178. package/dist/extensions/playwright/plan/plan.d.ts +44 -0
  179. package/dist/extensions/playwright/plan/plan.js +53 -0
  180. package/dist/extensions/testserver/command-tree.d.ts +2 -2
  181. package/dist/extensions/testserver/command-tree.js +2 -3
  182. package/dist/extensions/testserver/commands/app.d.ts +7 -7
  183. package/dist/extensions/testserver/commands/pool/create/command.d.ts +5 -5
  184. package/dist/extensions/testserver/commands/pool/create/command.js +17 -12
  185. package/dist/extensions/testserver/commands/pool/list/command.js +8 -5
  186. package/dist/extensions/testserver/{world.d.ts → context.d.ts} +1 -1
  187. package/dist/extensions/testserver/context.js +4 -0
  188. package/dist/extensions/testserver/definition.d.ts +2 -2
  189. package/dist/extensions/testserver/definition.js +8 -7
  190. package/dist/extensions/testserver/events.d.ts +1 -1
  191. package/dist/extensions/testserver/extension.d.ts +4 -3
  192. package/dist/extensions/testserver/extension.js +33 -20
  193. package/dist/extensions/testserver/index.d.ts +2 -2
  194. package/dist/extensions/testserver/index.js +2 -2
  195. package/dist/extensions/testserver/lifecycle.d.ts +6 -5
  196. package/dist/extensions/testserver/lifecycle.js +9 -8
  197. package/dist/extensions/testserver/live/context.d.ts +8 -0
  198. package/dist/extensions/testserver/live/{world.js → context.js} +6 -7
  199. package/dist/extensions/testserver/options/rules.d.ts +3 -3
  200. package/dist/extensions/testserver/options/rules.js +5 -4
  201. package/dist/extensions/testserver/options/sandboxes.d.ts +3 -2
  202. package/dist/extensions/testserver/options/sandboxes.js +3 -2
  203. package/dist/extensions/testserver/playwright/index.d.ts +33 -0
  204. package/dist/extensions/testserver/playwright/index.js +43 -0
  205. package/dist/extensions/testserver/presentation.d.ts +4 -4
  206. package/dist/extensions/testserver/presentation.js +7 -7
  207. package/dist/extensions/testserver/progress.d.ts +3 -3
  208. package/dist/extensions/testserver/progress.js +3 -3
  209. package/dist/extensions/testserver/provision.d.ts +2 -2
  210. package/dist/extensions/testserver/provision.js +10 -10
  211. package/dist/extensions/testserver/resource.d.ts +2 -2
  212. package/dist/extensions/testserver/result.d.ts +2 -2
  213. package/dist/extensions/testserver/result.js +1 -1
  214. package/dist/extensions/testserver/run/connection.d.ts +1 -1
  215. package/dist/extensions/testserver/run/connection.js +3 -3
  216. package/dist/extensions/testserver/run/sandbox.d.ts +31 -0
  217. package/dist/extensions/testserver/run/sandbox.js +58 -0
  218. package/dist/extensions/testserver/run-sandbox.d.ts +2 -2
  219. package/dist/extensions/testserver/run-sandbox.js +3 -3
  220. package/dist/extensions/testserver/vercel-cli/arguments.d.ts +2 -2
  221. package/dist/extensions/testserver/vercel-cli/arguments.js +6 -6
  222. package/dist/extensions/testserver/vercel-cli/auth-config.d.ts +7 -7
  223. package/dist/extensions/testserver/vercel-cli/auth-config.js +4 -4
  224. package/dist/extensions/testserver/vercel-cli/clock.js +1 -1
  225. package/dist/extensions/testserver/vercel-cli/config-files.js +1 -1
  226. package/dist/extensions/testserver/vercel-cli/context.d.ts +1 -1
  227. package/dist/extensions/testserver/vercel-cli/context.js +2 -2
  228. package/dist/extensions/testserver/vercel-cli/entry.d.ts +1 -1
  229. package/dist/extensions/testserver/vercel-cli/entry.js +1 -1
  230. package/dist/extensions/testserver/vercel-cli/environment.d.ts +5 -5
  231. package/dist/extensions/testserver/vercel-cli/environment.js +6 -6
  232. package/dist/extensions/testserver/vercel-cli/gateways.d.ts +1 -1
  233. package/dist/extensions/testserver/vercel-cli/gateways.js +3 -3
  234. package/dist/extensions/testserver/vercel-cli/index.d.ts +1 -1
  235. package/dist/extensions/testserver/vercel-cli/index.js +8 -9
  236. package/dist/extensions/testserver/vercel-cli/invocation.d.ts +13 -12
  237. package/dist/extensions/testserver/vercel-cli/invocation.js +1 -1
  238. package/dist/extensions/testserver/vercel-cli/{driver.d.ts → invoker.d.ts} +18 -17
  239. package/dist/extensions/testserver/vercel-cli/{driver.js → invoker.js} +8 -8
  240. package/dist/extensions/testserver/vercel-cli/live/config-files.d.ts +2 -2
  241. package/dist/extensions/testserver/vercel-cli/live/config-files.js +2 -2
  242. package/dist/extensions/testserver/vercel-cli/live/process-gateway.js +1 -1
  243. package/dist/extensions/testserver/vercel-cli/report.js +2 -2
  244. package/dist/extensions/testserver/vercel-cli/verbose.js +1 -1
  245. package/dist/extensions/testserver/vitest/config.d.ts +8 -6
  246. package/dist/extensions/testserver/vitest/config.js +10 -16
  247. package/dist/extensions/testserver/vitest/container-scope.d.ts +11 -11
  248. package/dist/extensions/testserver/vitest/container-scope.js +9 -9
  249. package/dist/extensions/testserver/vitest/container-start.d.ts +6 -6
  250. package/dist/extensions/testserver/vitest/container-start.js +14 -11
  251. package/dist/extensions/testserver/vitest/diagnostics.d.ts +1 -1
  252. package/dist/extensions/testserver/vitest/fixtures.d.ts +12 -10
  253. package/dist/extensions/testserver/vitest/fixtures.js +44 -22
  254. package/dist/extensions/testserver/vitest/index.d.ts +1 -1
  255. package/dist/extensions/testserver/vitest/index.js +4 -4
  256. package/dist/extensions/testserver/vitest/types.d.ts +16 -18
  257. package/dist/extensions/testserver/vitest/types.js +2 -2
  258. package/dist/extensions/testserver/vitest/worker-sandbox.d.ts +8 -0
  259. package/dist/extensions/testserver/vitest/worker-sandbox.js +17 -0
  260. package/dist/extensions/vitest/driver.d.ts +8 -0
  261. package/dist/extensions/vitest/driver.js +62 -0
  262. package/dist/extensions/vitest/extension.d.ts +2 -0
  263. package/dist/extensions/vitest/extension.js +8 -0
  264. package/dist/{vitest → extensions/vitest/plan}/gateways.d.ts +1 -26
  265. package/dist/extensions/vitest/plan/gateways.js +3 -0
  266. package/dist/{vitest → extensions/vitest/plan}/live/list-gateway.d.ts +1 -2
  267. package/dist/{vitest → extensions/vitest/plan}/live/list-gateway.js +1 -20
  268. package/dist/extensions/vitest/plan/plan-over.d.ts +38 -0
  269. package/dist/extensions/vitest/plan/plan-over.js +31 -0
  270. package/dist/extensions/vitest/plan/plan.d.ts +24 -0
  271. package/dist/{vitest → extensions/vitest/plan}/plan.js +11 -26
  272. package/dist/extensions.d.ts +43 -30
  273. package/dist/extensions.js +50 -35
  274. package/dist/forward-sigterm.d.ts +8 -0
  275. package/dist/forward-sigterm.js +18 -0
  276. package/dist/launcher-resolvers/index.d.ts +1 -0
  277. package/dist/launcher-resolvers/index.js +2 -1
  278. package/dist/launcher-resolvers/local-services.d.ts +22 -0
  279. package/dist/launcher-resolvers/local-services.js +6 -0
  280. package/dist/live-app.js +9 -7
  281. package/dist/local-services.d.ts +11 -0
  282. package/dist/local-services.js +16 -0
  283. package/dist/playwright/index.d.ts +1 -0
  284. package/dist/playwright/index.js +4 -0
  285. package/dist/playwright/reporter.d.ts +96 -0
  286. package/dist/playwright/reporter.js +162 -0
  287. package/dist/playwright/worker-index.d.ts +7 -0
  288. package/dist/playwright/worker-index.js +20 -0
  289. package/dist/run-directory/gateways.d.ts +167 -0
  290. package/dist/run-directory/gateways.js +2 -0
  291. package/dist/run-directory/index.d.ts +8 -0
  292. package/dist/run-directory/index.js +13 -0
  293. package/dist/run-directory/plan.d.ts +35 -0
  294. package/dist/run-directory/plan.js +24 -0
  295. package/dist/run-directory/reader.d.ts +70 -0
  296. package/dist/run-directory/reader.js +51 -0
  297. package/dist/run-directory/recording.d.ts +95 -0
  298. package/dist/run-directory/recording.js +85 -0
  299. package/dist/{commands/exec → run-directory}/run-collector.d.ts +9 -8
  300. package/dist/{commands/exec → run-directory}/run-collector.js +8 -10
  301. package/dist/{core → run-directory}/run-directory.d.ts +3 -3
  302. package/dist/{core → run-directory}/run-directory.js +2 -2
  303. package/dist/{commands/exec → run-directory}/run-record.d.ts +94 -27
  304. package/dist/run-directory/run-record.js +229 -0
  305. package/dist/{commands/exec → run-directory}/timeline-facts.d.ts +5 -8
  306. package/dist/{commands/exec → run-directory}/timeline-facts.js +11 -25
  307. package/dist/runner/build-snapshots.d.ts +179 -0
  308. package/dist/runner/build-snapshots.js +235 -0
  309. package/dist/runner/context.js +2 -1
  310. package/dist/runner/events.d.ts +73 -33
  311. package/dist/runner/gateways.d.ts +30 -10
  312. package/dist/runner/index.d.ts +15 -17
  313. package/dist/runner/index.js +12 -14
  314. package/dist/runner/live/checkout-gateway.js +15 -7
  315. package/dist/runner/live/snapshot-records.js +8 -7
  316. package/dist/runner/prepare.d.ts +26 -26
  317. package/dist/runner/prepare.js +27 -14
  318. package/dist/runner/ready.d.ts +43 -10
  319. package/dist/runner/ready.js +51 -34
  320. package/dist/runner/recipe.d.ts +48 -4
  321. package/dist/runner/recipe.js +42 -1
  322. package/dist/runner/scope.d.ts +13 -13
  323. package/dist/runner/scope.js +9 -11
  324. package/dist/runner/secrets.d.ts +6 -0
  325. package/dist/runner/secrets.js +10 -0
  326. package/dist/runner/session.d.ts +128 -0
  327. package/dist/runner/session.js +138 -0
  328. package/dist/runner/snapshot-build.d.ts +21 -11
  329. package/dist/runner/snapshot-build.js +11 -16
  330. package/dist/runner/snapshot-cache.d.ts +140 -62
  331. package/dist/runner/snapshot-cache.js +145 -102
  332. package/dist/runner/snapshot-inspect.d.ts +89 -0
  333. package/dist/runner/snapshot-inspect.js +173 -0
  334. package/dist/runner/snapshot-key.d.ts +5 -2
  335. package/dist/runner/snapshot-key.js +1 -1
  336. package/dist/runner/snapshot-save.d.ts +35 -20
  337. package/dist/runner/snapshot-save.js +47 -37
  338. package/dist/runner/snapshot-start.d.ts +25 -0
  339. package/dist/runner/snapshot-start.js +16 -0
  340. package/dist/sdk/extension/ci.d.ts +2 -0
  341. package/dist/sdk/extension/ci.js +6 -0
  342. package/dist/sdk/extension/commands.d.ts +44 -28
  343. package/dist/sdk/extension/commands.js +15 -13
  344. package/dist/sdk/extension/driver.d.ts +143 -0
  345. package/dist/sdk/extension/driver.js +28 -0
  346. package/dist/sdk/extension/index.d.ts +3 -1
  347. package/dist/sdk/extension/index.js +16 -9
  348. package/dist/sdk/extension/{launcher-supplies.d.ts → launcher-context.d.ts} +3 -3
  349. package/dist/sdk/extension/launcher-context.js +5 -0
  350. package/dist/sdk/extension/lifecycle.d.ts +10 -8
  351. package/dist/sdk/extension/lifecycle.js +2 -2
  352. package/dist/sdk/extension/progress.js +2 -2
  353. package/dist/sdk/extension/resource-definition.d.ts +13 -13
  354. package/dist/sdk/extension/resource-definition.js +2 -2
  355. package/dist/sdk/extension/resource.d.ts +13 -13
  356. package/dist/sdk/extension/resource.js +11 -11
  357. package/dist/sdk/extension/time.js +2 -2
  358. package/dist/sdk/index.d.ts +2 -0
  359. package/dist/sdk/index.js +3 -1
  360. package/dist/sdk/run/launcher.d.ts +1 -1
  361. package/dist/sdk/run/launcher.js +4 -3
  362. package/dist/sdk/run/payload.js +1 -1
  363. package/dist/sdk/run/test-events.d.ts +24 -18
  364. package/dist/sdk/run/test-events.js +5 -4
  365. package/dist/sdk/run/test-result-writer.d.ts +77 -0
  366. package/dist/sdk/run/test-result-writer.js +143 -0
  367. package/dist/sdk/run/worker-test-event-writer.d.ts +13 -0
  368. package/dist/sdk/run/worker-test-event-writer.js +31 -0
  369. package/dist/vendor/testserver-sdk/container/container.d.ts +12 -12
  370. package/dist/vendor/testserver-sdk/container/container.js +39 -21
  371. package/dist/vendor/testserver-sdk/factories/build.d.ts +12 -40
  372. package/dist/vendor/testserver-sdk/factories/build.js +15 -66
  373. package/dist/vendor/testserver-sdk/factories/gateways.d.ts +1 -2
  374. package/dist/vendor/testserver-sdk/factories/index.d.ts +1 -3
  375. package/dist/vendor/testserver-sdk/factories/index.js +3 -5
  376. package/dist/vendor/testserver-sdk/index.d.ts +1 -2
  377. package/dist/vendor/testserver-sdk/index.js +5 -6
  378. package/dist/vendor/testserver-sdk/records/body.d.ts +1 -1
  379. package/dist/vendor/testserver-sdk/records/body.js +1 -1
  380. package/dist/vendor/testserver-sdk/testserver/failure.d.ts +4 -3
  381. package/dist/vendor/testserver-sdk/testserver/failure.js +4 -3
  382. package/dist/vitest/index.d.ts +2 -1
  383. package/dist/vitest/index.js +6 -4
  384. package/dist/vitest/test-events.d.ts +6 -16
  385. package/dist/vitest/test-events.js +15 -40
  386. package/dist/vitest/test-results.d.ts +9 -31
  387. package/dist/vitest/test-results.js +34 -105
  388. package/dist/vitest/worker-index.d.ts +6 -0
  389. package/dist/vitest/worker-index.js +17 -0
  390. package/package.json +23 -9
  391. package/skills/overview.md +6 -5
  392. package/skills/read-run-output.md +22 -7
  393. package/dist/chunks/chunk-AGWW3HDT.js +0 -2559
  394. package/dist/chunks/chunk-H2VCSNVU.js +0 -351
  395. package/dist/commands/exec/run-record.js +0 -135
  396. package/dist/commands/vitest/outcomes.d.ts +0 -379
  397. package/dist/commands/vitest/outcomes.js +0 -70
  398. package/dist/core/launcher-supplies.d.ts +0 -11
  399. package/dist/core/launcher-supplies.js +0 -28
  400. package/dist/core/mint.d.ts +0 -10
  401. package/dist/core/mint.js +0 -14
  402. package/dist/core/resource-registry.d.ts +0 -54
  403. package/dist/core/resource-registry.js +0 -57
  404. package/dist/extensions/github/live/world.d.ts +0 -6
  405. package/dist/extensions/github/live/world.js +0 -16
  406. package/dist/extensions/github/world.js +0 -3
  407. package/dist/extensions/testserver/live/world.d.ts +0 -8
  408. package/dist/extensions/testserver/vitest/sandbox.d.ts +0 -25
  409. package/dist/extensions/testserver/vitest/sandbox.js +0 -43
  410. package/dist/extensions/testserver/world.js +0 -4
  411. package/dist/sdk/extension/launcher-supplies.js +0 -3
  412. package/dist/story/align.d.ts +0 -37
  413. package/dist/story/align.js +0 -39
  414. package/dist/story/command-line.d.ts +0 -34
  415. package/dist/story/command-line.js +0 -100
  416. package/dist/story/definition.d.ts +0 -59
  417. package/dist/story/definition.js +0 -9
  418. package/dist/story/diff.d.ts +0 -9
  419. package/dist/story/diff.js +0 -97
  420. package/dist/story/errors.d.ts +0 -14
  421. package/dist/story/errors.js +0 -21
  422. package/dist/story/gateways.d.ts +0 -94
  423. package/dist/story/gateways.js +0 -3
  424. package/dist/story/host.d.ts +0 -30
  425. package/dist/story/host.js +0 -97
  426. package/dist/story/index.d.ts +0 -8
  427. package/dist/story/index.js +0 -10
  428. package/dist/story/json.d.ts +0 -16
  429. package/dist/story/json.js +0 -59
  430. package/dist/story/live/recording-gateway.d.ts +0 -2
  431. package/dist/story/live/recording-gateway.js +0 -103
  432. package/dist/story/mode.d.ts +0 -17
  433. package/dist/story/mode.js +0 -21
  434. package/dist/story/orphans.d.ts +0 -35
  435. package/dist/story/orphans.js +0 -51
  436. package/dist/story/recording.d.ts +0 -62
  437. package/dist/story/recording.js +0 -97
  438. package/dist/story/report.d.ts +0 -42
  439. package/dist/story/report.js +0 -130
  440. package/dist/story/sequence.d.ts +0 -30
  441. package/dist/story/sequence.js +0 -74
  442. package/dist/story/settle.d.ts +0 -96
  443. package/dist/story/settle.js +0 -71
  444. package/dist/story/start.d.ts +0 -50
  445. package/dist/story/start.js +0 -183
  446. package/dist/vendor/testserver-sdk/factories/definition.d.ts +0 -39
  447. package/dist/vendor/testserver-sdk/factories/definition.js +0 -16
  448. package/dist/vendor/testserver-sdk/factories/definitions.d.ts +0 -169
  449. package/dist/vendor/testserver-sdk/factories/definitions.js +0 -245
  450. package/dist/vendor/testserver-sdk/seed/index.d.ts +0 -1
  451. package/dist/vendor/testserver-sdk/seed/index.js +0 -3
  452. package/dist/vendor/testserver-sdk/seed/seed.d.ts +0 -221
  453. package/dist/vendor/testserver-sdk/seed/seed.js +0 -171
  454. package/dist/vitest/find-vitest.d.ts +0 -7
  455. package/dist/vitest/find-vitest.js +0 -28
  456. package/dist/vitest/gateways.js +0 -4
  457. package/dist/vitest/plan.d.ts +0 -51
  458. /package/dist/{vitest → extensions/vitest/plan}/list-output.d.ts +0 -0
  459. /package/dist/{vitest → extensions/vitest/plan}/list-output.js +0 -0
  460. /package/dist/{core → run-directory}/live/run-directory-gateway.d.ts +0 -0
  461. /package/dist/{core → run-directory}/live/run-directory-gateway.js +0 -0
@@ -1,97 +0,0 @@
1
- // `story()` on Vitest: the one file in `src/story/` that imports vitest. Each story is a Vitest test whose recording
2
- // sits beside its file, and runs over the live recording gateway.
3
- import { basename } from "node:path";
4
- import { test } from "vitest";
5
- import { recordingPath } from "./recording.js";
6
- import { liveStoryRecordingGateway } from "./live/recording-gateway.js";
7
- import { resolveStoryRecordLevel } from "./mode.js";
8
- import { findOrphans, looksForOrphans } from "./orphans.js";
9
- import { startStory } from "./start.js";
10
- /**
11
- * The `story` function for `harness`. A story's name is its full test name, its `describe` names first; its recording
12
- * is `recordingPath(<story file>, <name>)`. When the story ends, each call becomes a Vitest annotation of type `story`
13
- * (`storyEventLines`), and what a passing story changed, naming each call it rewrote (`storyChangeReport`), goes to
14
- * stderr and becomes an annotation too. A story whose body threw prints its report on stderr, when there is one, and
15
- * fails with its body's error; one that diverged or went stale fails with the report as the error. A story Vitest
16
- * stops (a timeout, or a canceled Vitest run) ends then, without waiting for its body, and counts as one whose body
17
- * threw: its session closes, and it writes nothing and removes no orphan recording, even when its body returns later
18
- * or the stop comes while its end is changing the recording. When every story in the file runs (no test name filter,
19
- * `.only` or `.skip` left one out), the last story the file declares also finds the orphan recordings when it ends
20
- * (`looksForOrphans`, `findOrphans`): the file's own, and those in the recording directory of each story file that is
21
- * gone.
22
- */
23
- export function createStory(harness, options = {}) {
24
- return (name, body) => {
25
- test(name, { meta: { story: true }, ...(options.timeout === undefined ? {} : { timeout: options.timeout }) }, async (context) => {
26
- const file = context.task.file.filepath;
27
- const story = { file: basename(file), name: context.task.fullTestName };
28
- const level = resolveStoryRecordLevel(options.env ?? process.env);
29
- const started = startStory(harness, { story, path: recordingPath(file, story.name), level, signal: context.signal }, liveStoryRecordingGateway);
30
- const bodyEnded = await bodyEnd(() => body(started.handles), context.signal);
31
- const orphans = await fileOrphans(context);
32
- const end = await started.end({
33
- bodyPassed: bodyEnded.passed,
34
- orphans: orphans.kind === "found" ? orphans.paths : [],
35
- });
36
- const annotations = end.events.map((line) => context.annotate(line, "story"));
37
- if (end.changeReport !== undefined) {
38
- console.error(end.changeReport);
39
- annotations.push(context.annotate(end.changeReport, "story"));
40
- }
41
- await Promise.all(annotations);
42
- if (!bodyEnded.passed) {
43
- if (end.report !== undefined)
44
- console.error(end.report);
45
- if (end.error !== undefined)
46
- console.error(end.error.message);
47
- throw bodyEnded.error;
48
- }
49
- if (end.error !== undefined)
50
- throw end.error;
51
- if (orphans.kind === "failed") {
52
- throw new Error(`story: couldn't look for orphan recordings: ${orphans.message}`);
53
- }
54
- });
55
- };
56
- }
57
- /**
58
- * Runs `body` until it settles or `signal` aborts, whichever comes first. Vitest aborts the signal when it times the
59
- * story out or cancels its Vitest run, and has already failed the test by then, so a stopped body has not passed,
60
- * even if it returns later. A body still running then keeps running: nothing can stop it, but the story ends without
61
- * it, so its session closes, and any tool it calls after that throws.
62
- */
63
- function bodyEnd(body, signal) {
64
- const stopped = () => ({
65
- passed: false,
66
- error: signal.reason ?? new Error("story: Vitest stopped the story before its body returned"),
67
- });
68
- if (signal.aborted)
69
- return Promise.resolve(stopped());
70
- return new Promise((resolve) => {
71
- const onAbort = () => resolve(stopped());
72
- signal.addEventListener("abort", onAbort, { once: true });
73
- const settle = (end) => {
74
- signal.removeEventListener("abort", onAbort);
75
- resolve(signal.aborted ? stopped() : end);
76
- };
77
- Promise.resolve()
78
- .then(body)
79
- .then(() => settle({ passed: true }), (error) => settle({ passed: false, error }));
80
- });
81
- }
82
- /**
83
- * The orphan recordings the running story's end finds (`findOrphans`): found only by the last story its file declares,
84
- * and only when every story in the file runs (`looksForOrphans`); none otherwise.
85
- */
86
- async function fileOrphans(context) {
87
- const file = context.task.file;
88
- const stories = storyTests(file.tasks);
89
- const declared = stories.map((each) => ({ id: each.id, runs: each.mode === "run" }));
90
- if (!looksForOrphans(declared, context.task.id))
91
- return { kind: "found", paths: [] };
92
- return findOrphans({ storyFile: file.filepath, expected: stories.map((each) => recordingPath(file.filepath, each.fullTestName)) }, liveStoryRecordingGateway);
93
- }
94
- /** Every test `story()` declared among `tasks`, in suites too. */
95
- function storyTests(tasks) {
96
- return tasks.flatMap((task) => task.type === "suite" ? storyTests(task.tasks) : task.meta.story === true ? [task] : []);
97
- }
@@ -1,8 +0,0 @@
1
- export { recordingDirectory, recordingPath, parseRecording, type ParsedStoryRecording, STORY_RECORDING_SCHEMA_VERSION, type StoryRecording, type StoryCall, type StoryIdentity, } from "./recording.ts";
2
- export { type AnyStoryTool, type StoryAgent, type StoryAgents, type StoryHandles, type StoryHarness, type StorySession, type StoryTool, type StoryToolCall, storyTool, } from "./definition.ts";
3
- export { InvalidCommandLine, splitCommandLine, type StoryExecutable, type StoryExecutableOptions, storyExecutable, } from "./command-line.ts";
4
- export { StoryDivergenceError, StoryStaleError } from "./errors.ts";
5
- export { createStory, type StoryFunction, type StoryHostOptions } from "./host.ts";
6
- export type { StoryJson } from "./json.ts";
7
- export { STORY_RECORD_VARIABLE, type StoryRecordLevel } from "./mode.ts";
8
- export type { StoryDivergence, StoryStaleEntry } from "./settle.ts";
@@ -1,10 +0,0 @@
1
- // Story core, exported as `@vercel/storm/story`: stories whose agents call tools, each call's observation kept in
2
- // a recording beside the story file and compared on every later Vitest run. `README.md` beside this file is its design
3
- // and authoring guide. It depends only on Node builtins, `zod`, and `vitest` (an optional peer dependency of
4
- // `@vercel/storm`), and on nothing else in storm; `.oxlintrc.json` checks the boundary.
5
- export { recordingDirectory, recordingPath, parseRecording, STORY_RECORDING_SCHEMA_VERSION, } from "./recording.js";
6
- export { storyTool, } from "./definition.js";
7
- export { InvalidCommandLine, splitCommandLine, storyExecutable, } from "./command-line.js";
8
- export { StoryDivergenceError, StoryStaleError } from "./errors.js";
9
- export { createStory } from "./host.js";
10
- export { STORY_RECORD_VARIABLE } from "./mode.js";
@@ -1,16 +0,0 @@
1
- /** A JSON value, as a story recording holds it. */
2
- export type StoryJson = null | boolean | number | string | readonly StoryJson[] | {
3
- readonly [key: string]: StoryJson;
4
- };
5
- /**
6
- * `value` as `StoryJson`, a copy, or a `TypeError` that says `what` and why `value` isn't JSON: a function, a
7
- * `bigint`, a symbol, `undefined` (in an array, or as the whole value), a number that isn't finite, an object that
8
- * isn't plain, or a cycle. An object's `undefined` fields are dropped, as `JSON.stringify` drops them.
9
- */
10
- export declare function toStoryJson(value: unknown, what: string): StoryJson;
11
- /** `value` as compact JSON with every object's keys sorted: the same text for the same value. */
12
- export declare function canonicalJson(value: StoryJson): string;
13
- /** Whether two JSON values are equal, whatever their objects' key order. */
14
- export declare function sameJson(left: StoryJson, right: StoryJson): boolean;
15
- /** `value` with every object's keys sorted, so `JSON.stringify` writes it the same way each time. */
16
- export declare function sortKeys(value: StoryJson): StoryJson;
@@ -1,59 +0,0 @@
1
- // The JSON a story recording holds: tool inputs and observations. Pure.
2
- /**
3
- * `value` as `StoryJson`, a copy, or a `TypeError` that says `what` and why `value` isn't JSON: a function, a
4
- * `bigint`, a symbol, `undefined` (in an array, or as the whole value), a number that isn't finite, an object that
5
- * isn't plain, or a cycle. An object's `undefined` fields are dropped, as `JSON.stringify` drops them.
6
- */
7
- export function toStoryJson(value, what) {
8
- const problem = jsonProblem(value, new Set());
9
- if (problem !== undefined)
10
- throw new TypeError(`story: ${what}, but ${problem}`);
11
- return JSON.parse(JSON.stringify(value));
12
- }
13
- /** `value` as compact JSON with every object's keys sorted: the same text for the same value. */
14
- export function canonicalJson(value) {
15
- return JSON.stringify(sortKeys(value));
16
- }
17
- /** Whether two JSON values are equal, whatever their objects' key order. */
18
- export function sameJson(left, right) {
19
- return canonicalJson(left) === canonicalJson(right);
20
- }
21
- /** `value` with every object's keys sorted, so `JSON.stringify` writes it the same way each time. */
22
- export function sortKeys(value) {
23
- if (Array.isArray(value))
24
- return value.map(sortKeys);
25
- if (typeof value === "object" && value !== null) {
26
- return Object.fromEntries(Object.keys(value)
27
- .toSorted()
28
- .map((key) => [key, sortKeys(value[key] ?? null)]));
29
- }
30
- return value;
31
- }
32
- /** Why `value` isn't JSON a story recording can hold, or `undefined` when it is. */
33
- function jsonProblem(value, seen) {
34
- if (value === null || typeof value === "string" || typeof value === "boolean")
35
- return undefined;
36
- if (typeof value === "number")
37
- return Number.isFinite(value) ? undefined : `${value} isn't JSON`;
38
- if (value === undefined)
39
- return "undefined isn't JSON";
40
- if (typeof value !== "object")
41
- return `a ${typeof value} isn't JSON`;
42
- if (seen.has(value))
43
- return "a cycle isn't JSON";
44
- const prototype = Object.getPrototypeOf(value);
45
- if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) {
46
- return "an object that isn't plain isn't JSON";
47
- }
48
- seen.add(value);
49
- const children = Array.isArray(value) ? value : Object.values(value);
50
- for (const child of children) {
51
- if (child === undefined && !Array.isArray(value))
52
- continue;
53
- const problem = jsonProblem(child, seen);
54
- if (problem !== undefined)
55
- return problem;
56
- }
57
- seen.delete(value);
58
- return undefined;
59
- }
@@ -1,2 +0,0 @@
1
- import type { StoryRecordingGateway } from "../gateways.ts";
2
- export declare const liveStoryRecordingGateway: StoryRecordingGateway;
@@ -1,103 +0,0 @@
1
- // The live recording gateway: one JSON file per story on disk. A write goes to a temporary file beside the recording
2
- // and is renamed into place, so a reader never sees half a recording. A write or removal checks its signal before it
3
- // starts and again just before the rename or `rm` that makes the change.
4
- import { randomBytes } from "node:crypto";
5
- import { mkdir, readdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
6
- import { dirname, join } from "node:path";
7
- import { parseRecording, serializeRecording } from "../recording.js";
8
- export const liveStoryRecordingGateway = {
9
- async readRecording({ path }) {
10
- let text;
11
- try {
12
- text = await readFile(path, "utf8");
13
- }
14
- catch (error) {
15
- return codeOf(error) === "ENOENT" ? { kind: "missing" } : { kind: "failed", message: messageOf(error) };
16
- }
17
- const parsed = parseRecording(text);
18
- return parsed.ok ? { kind: "found", recording: parsed.recording } : { kind: "unreadable", problem: parsed.problem };
19
- },
20
- async writeRecording({ path, recording, signal }) {
21
- if (aborted(signal))
22
- return { kind: "canceled" };
23
- const text = serializeRecording(recording);
24
- try {
25
- if ((await readFile(path, "utf8")) === text)
26
- return { kind: "unchanged" };
27
- }
28
- catch (error) {
29
- if (codeOf(error) !== "ENOENT")
30
- return { kind: "failed", message: messageOf(error) };
31
- }
32
- const temporary = `${path}.${randomBytes(4).toString("hex")}.tmp`;
33
- try {
34
- await mkdir(dirname(path), { recursive: true });
35
- await writeFile(temporary, text, "utf8");
36
- if (aborted(signal)) {
37
- await rm(temporary, { force: true });
38
- return { kind: "canceled" };
39
- }
40
- await rename(temporary, path);
41
- return { kind: "written" };
42
- }
43
- catch (error) {
44
- await rm(temporary, { force: true });
45
- return { kind: "failed", message: messageOf(error) };
46
- }
47
- },
48
- async removeRecording({ path, signal }) {
49
- if (aborted(signal))
50
- return { kind: "canceled" };
51
- try {
52
- await rm(path);
53
- return { kind: "removed" };
54
- }
55
- catch (error) {
56
- return codeOf(error) === "ENOENT" ? { kind: "missing" } : { kind: "failed", message: messageOf(error) };
57
- }
58
- },
59
- async listRecordings({ directory }) {
60
- try {
61
- const entries = await readdir(directory, { withFileTypes: true });
62
- const paths = entries
63
- .filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
64
- .map((entry) => join(directory, entry.name))
65
- .toSorted();
66
- return { kind: "listed", paths };
67
- }
68
- catch (error) {
69
- return codeOf(error) === "ENOENT" ? { kind: "listed", paths: [] } : { kind: "failed", message: messageOf(error) };
70
- }
71
- },
72
- async listRecordingDirectories({ root }) {
73
- try {
74
- const entries = await readdir(root, { withFileTypes: true });
75
- const paths = entries
76
- .filter((entry) => entry.isDirectory())
77
- .map((entry) => join(root, entry.name))
78
- .toSorted();
79
- return { kind: "listed", paths };
80
- }
81
- catch (error) {
82
- return codeOf(error) === "ENOENT" ? { kind: "listed", paths: [] } : { kind: "failed", message: messageOf(error) };
83
- }
84
- },
85
- async findStoryFile({ path }) {
86
- try {
87
- return (await stat(path)).isFile() ? { kind: "found" } : { kind: "missing" };
88
- }
89
- catch (error) {
90
- return codeOf(error) === "ENOENT" ? { kind: "missing" } : { kind: "failed", message: messageOf(error) };
91
- }
92
- },
93
- };
94
- /** Whether `signal` has aborted, read afresh at each check: a signal aborts while a method awaits. */
95
- function aborted(signal) {
96
- return signal?.aborted === true;
97
- }
98
- function codeOf(error) {
99
- return typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
100
- }
101
- function messageOf(error) {
102
- return error instanceof Error ? error.message : String(error);
103
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * How much a story may change its recording:
3
- *
4
- * - `none` compares and writes nothing. A divergence or a stale entry fails the story.
5
- * - `stale` rewrites the recording so it fits the story again, when the only problems are stale entries. A divergence
6
- * still fails the story, and then nothing is written.
7
- * - `all` also accepts divergences, recording the new observations.
8
- */
9
- export type StoryRecordLevel = "none" | "stale" | "all";
10
- /** The variable that sets the level. */
11
- export declare const STORY_RECORD_VARIABLE = "STORY_RECORD";
12
- /**
13
- * The level `env` sets: `STORY_RECORD` when it is set and non-empty; otherwise `none` when `CI` is set and non-empty,
14
- * since CI must not change a recording, and `stale` elsewhere. Any other value of `STORY_RECORD` is a `TypeError`
15
- * naming it.
16
- */
17
- export declare function resolveStoryRecordLevel(env: Readonly<Record<string, string | undefined>>): StoryRecordLevel;
@@ -1,21 +0,0 @@
1
- // How much a story may change its recording, from `STORY_RECORD`. Pure.
2
- /** The variable that sets the level. */
3
- export const STORY_RECORD_VARIABLE = "STORY_RECORD";
4
- const LEVELS = ["none", "stale", "all"];
5
- /**
6
- * The level `env` sets: `STORY_RECORD` when it is set and non-empty; otherwise `none` when `CI` is set and non-empty,
7
- * since CI must not change a recording, and `stale` elsewhere. Any other value of `STORY_RECORD` is a `TypeError`
8
- * naming it.
9
- */
10
- export function resolveStoryRecordLevel(env) {
11
- const value = env[STORY_RECORD_VARIABLE];
12
- if (value === undefined || value === "") {
13
- const ci = env["CI"];
14
- return ci !== undefined && ci !== "" ? "none" : "stale";
15
- }
16
- const level = LEVELS.find((each) => each === value);
17
- if (level === undefined) {
18
- throw new TypeError(`story: ${STORY_RECORD_VARIABLE} must be none, stale or all, or unset, not ${JSON.stringify(value)}`);
19
- }
20
- return level;
21
- }
@@ -1,35 +0,0 @@
1
- import type { StoryRecordingGateway } from "./gateways.ts";
2
- /** A story as its story file declares it: its id, and whether this Vitest run runs it. */
3
- export interface DeclaredStory {
4
- readonly id: string;
5
- readonly runs: boolean;
6
- }
7
- /**
8
- * Whether the story `id` looks for its file's orphan recordings, given the stories its file declares, in order: only
9
- * the last of them, and only when every one of them runs (no test name filter, `.only` or `.skip` left one out). The
10
- * search works from the stories' recording paths and lists only recordings, never a recording being written, so it
11
- * needs none of the file's other stories to have ended.
12
- */
13
- export declare function looksForOrphans(declared: readonly DeclaredStory[], id: string): boolean;
14
- export type StoryOrphans = {
15
- readonly kind: "found";
16
- readonly paths: readonly string[];
17
- } | {
18
- readonly kind: "failed";
19
- readonly message: string;
20
- };
21
- /**
22
- * The orphan recordings `storyFile`'s end finds, when its stories' recordings are at `expected`, those in its own
23
- * recording directory first, then each other directory's, each part sorted:
24
- *
25
- * - every recording in its own recording directory but those. The directory is the file's alone
26
- * (`recordingDirectory`), so a recording there that no story expects is an orphan whatever it holds, an unreadable
27
- * one too.
28
- * - every recording in each other recording directory beside it, under the same `__story__/`, whose story file is
29
- * gone. Such a directory belongs to no story file. One whose story file is there is another story file's, and
30
- * nothing in it is listed or read.
31
- */
32
- export declare function findOrphans(request: {
33
- readonly storyFile: string;
34
- readonly expected: readonly string[];
35
- }, gateway: StoryRecordingGateway): Promise<StoryOrphans>;
@@ -1,51 +0,0 @@
1
- // Finding a story file's orphan recordings: those in its recording directory that belong to none of its stories, and
2
- // those in the recording directory of a story file that is gone, and which of the file's stories looks for them.
3
- // Domain logic over the recording gateway.
4
- import { dirname } from "node:path";
5
- import { recordingDirectory, storyFileOf } from "./recording.js";
6
- /**
7
- * Whether the story `id` looks for its file's orphan recordings, given the stories its file declares, in order: only
8
- * the last of them, and only when every one of them runs (no test name filter, `.only` or `.skip` left one out). The
9
- * search works from the stories' recording paths and lists only recordings, never a recording being written, so it
10
- * needs none of the file's other stories to have ended.
11
- */
12
- export function looksForOrphans(declared, id) {
13
- return declared.every((story) => story.runs) && declared.at(-1)?.id === id;
14
- }
15
- /**
16
- * The orphan recordings `storyFile`'s end finds, when its stories' recordings are at `expected`, those in its own
17
- * recording directory first, then each other directory's, each part sorted:
18
- *
19
- * - every recording in its own recording directory but those. The directory is the file's alone
20
- * (`recordingDirectory`), so a recording there that no story expects is an orphan whatever it holds, an unreadable
21
- * one too.
22
- * - every recording in each other recording directory beside it, under the same `__story__/`, whose story file is
23
- * gone. Such a directory belongs to no story file. One whose story file is there is another story file's, and
24
- * nothing in it is listed or read.
25
- */
26
- export async function findOrphans(request, gateway) {
27
- const own = recordingDirectory(request.storyFile);
28
- const listed = await gateway.listRecordings({ directory: own });
29
- if (listed.kind === "failed")
30
- return listed;
31
- const expected = new Set(request.expected);
32
- const recordings = listed.paths.filter((path) => !expected.has(path));
33
- const others = await gateway.listRecordingDirectories({ root: dirname(own) });
34
- if (others.kind === "failed")
35
- return others;
36
- const gone = [];
37
- for (const directory of others.paths) {
38
- if (directory === own)
39
- continue;
40
- const storyFile = await gateway.findStoryFile({ path: storyFileOf(directory) });
41
- if (storyFile.kind === "failed")
42
- return storyFile;
43
- if (storyFile.kind === "found")
44
- continue;
45
- const held = await gateway.listRecordings({ directory });
46
- if (held.kind === "failed")
47
- return held;
48
- gone.push(...held.paths);
49
- }
50
- return { kind: "found", paths: [...recordings, ...gone] };
51
- }
@@ -1,62 +0,0 @@
1
- import { type StoryJson } from "./json.ts";
2
- /** The recording format this version of story core writes and reads. */
3
- export declare const STORY_RECORDING_SCHEMA_VERSION = 1;
4
- /** Which story a recording belongs to: the story file's name (no directory) and the story's full test name. */
5
- export interface StoryIdentity {
6
- readonly file: string;
7
- readonly name: string;
8
- }
9
- /**
10
- * One tool call: the agent, the tool, the input the tool ran with (after its schema parsed it), and what its
11
- * `observe` returned. (agent, tool, input) is the call's key.
12
- */
13
- export interface StoryCall {
14
- readonly agent: string;
15
- readonly tool: string;
16
- readonly input: StoryJson;
17
- readonly observation: StoryJson;
18
- }
19
- /** One story's recording. */
20
- export interface StoryRecording {
21
- readonly schemaVersion: typeof STORY_RECORDING_SCHEMA_VERSION;
22
- readonly story: StoryIdentity;
23
- readonly calls: readonly StoryCall[];
24
- }
25
- /** A recording's text, read back: the recording, or why it can't be one. */
26
- export type ParsedStoryRecording = {
27
- readonly ok: true;
28
- readonly recording: StoryRecording;
29
- } | {
30
- readonly ok: false;
31
- readonly problem: string;
32
- };
33
- /**
34
- * The directory that holds a story file's recordings: `<story file dir>/__story__/<story file name>`
35
- * (`__story__/slot-surface.story.test.ts`). Each story file has a directory of its own, so the path alone says which
36
- * file owns a recording, whatever the recording holds.
37
- */
38
- export declare function recordingDirectory(storyFile: string): string;
39
- /** The story file whose recording directory is `directory`: the inverse of `recordingDirectory`. */
40
- export declare function storyFileOf(directory: string): string;
41
- /**
42
- * Where a story's recording lives: `<recordingDirectory>/<slug>-<id8>.json`. The slug is the story's name for people,
43
- * cut to 80 characters; `id8`, the first 8 hex characters of the SHA-256 of the canonical JSON of
44
- * `{ file, story }` (the file's name and the story's full name), keeps two stories whose names slug alike apart.
45
- */
46
- export declare function recordingPath(storyFile: string, story: string): string;
47
- /**
48
- * `text` lowercased, each run of characters other than ASCII letters and digits replaced by one `-`, with no `-` at
49
- * either end, cut to `max` characters; `story` when nothing is left.
50
- */
51
- export declare function slugify(text: string, max: number): string;
52
- /**
53
- * The recording's text: its fields in a fixed order (`schemaVersion`, `story`, `calls`, and each call's `agent`,
54
- * `tool`, `input`, `observation`), each input and observation's keys sorted, indented by 2 spaces, with a trailing
55
- * newline. The same recording always gives the same bytes.
56
- */
57
- export declare function serializeRecording(recording: StoryRecording): string;
58
- /**
59
- * `text` as a recording, or the problem: it isn't JSON, its `schemaVersion` isn't 1, or its fields don't have the
60
- * recording's shape (unknown fields included).
61
- */
62
- export declare function parseRecording(text: string): ParsedStoryRecording;
@@ -1,97 +0,0 @@
1
- // A story's recording: the tool calls one story made, each with its observation, in story order. Where it lives,
2
- // how it is written and how it is read back. Pure, but for hashing with `node:crypto`.
3
- import { createHash } from "node:crypto";
4
- import { basename, dirname, join } from "node:path";
5
- import { z } from "zod";
6
- import { canonicalJson, sortKeys } from "./json.js";
7
- /** The recording format this version of story core writes and reads. */
8
- export const STORY_RECORDING_SCHEMA_VERSION = 1;
9
- /** How much of the story's name its recording's file name keeps. */
10
- const STORY_SLUG_CHARS = 80;
11
- const recordingSchema = z.strictObject({
12
- schemaVersion: z.literal(STORY_RECORDING_SCHEMA_VERSION),
13
- story: z.strictObject({ file: z.string(), name: z.string() }),
14
- calls: z.array(z.strictObject({ agent: z.string(), tool: z.string(), input: z.json(), observation: z.json() })),
15
- });
16
- /**
17
- * The directory that holds a story file's recordings: `<story file dir>/__story__/<story file name>`
18
- * (`__story__/slot-surface.story.test.ts`). Each story file has a directory of its own, so the path alone says which
19
- * file owns a recording, whatever the recording holds.
20
- */
21
- export function recordingDirectory(storyFile) {
22
- return join(dirname(storyFile), "__story__", basename(storyFile));
23
- }
24
- /** The story file whose recording directory is `directory`: the inverse of `recordingDirectory`. */
25
- export function storyFileOf(directory) {
26
- return join(dirname(dirname(directory)), basename(directory));
27
- }
28
- /**
29
- * Where a story's recording lives: `<recordingDirectory>/<slug>-<id8>.json`. The slug is the story's name for people,
30
- * cut to 80 characters; `id8`, the first 8 hex characters of the SHA-256 of the canonical JSON of
31
- * `{ file, story }` (the file's name and the story's full name), keeps two stories whose names slug alike apart.
32
- */
33
- export function recordingPath(storyFile, story) {
34
- const id = createHash("sha256")
35
- .update(canonicalJson({ file: basename(storyFile), story }))
36
- .digest("hex")
37
- .slice(0, 8);
38
- return join(recordingDirectory(storyFile), `${slugify(story, STORY_SLUG_CHARS)}-${id}.json`);
39
- }
40
- /**
41
- * `text` lowercased, each run of characters other than ASCII letters and digits replaced by one `-`, with no `-` at
42
- * either end, cut to `max` characters; `story` when nothing is left.
43
- */
44
- export function slugify(text, max) {
45
- const slug = text
46
- .toLowerCase()
47
- .replaceAll(/[^a-z0-9]+/g, "-")
48
- .replaceAll(/^-+|-+$/g, "")
49
- .slice(0, max)
50
- .replace(/-+$/, "");
51
- return slug === "" ? "story" : slug;
52
- }
53
- /**
54
- * The recording's text: its fields in a fixed order (`schemaVersion`, `story`, `calls`, and each call's `agent`,
55
- * `tool`, `input`, `observation`), each input and observation's keys sorted, indented by 2 spaces, with a trailing
56
- * newline. The same recording always gives the same bytes.
57
- */
58
- export function serializeRecording(recording) {
59
- const ordered = {
60
- schemaVersion: recording.schemaVersion,
61
- story: { file: recording.story.file, name: recording.story.name },
62
- calls: recording.calls.map((call) => ({
63
- agent: call.agent,
64
- tool: call.tool,
65
- input: sortKeys(call.input),
66
- observation: sortKeys(call.observation),
67
- })),
68
- };
69
- return `${JSON.stringify(ordered, null, 2)}\n`;
70
- }
71
- /**
72
- * `text` as a recording, or the problem: it isn't JSON, its `schemaVersion` isn't 1, or its fields don't have the
73
- * recording's shape (unknown fields included).
74
- */
75
- export function parseRecording(text) {
76
- let value;
77
- try {
78
- value = JSON.parse(text);
79
- }
80
- catch (error) {
81
- return { ok: false, problem: `not JSON: ${error.message}` };
82
- }
83
- const version = typeof value === "object" && value !== null ? value.schemaVersion : undefined;
84
- if (version !== STORY_RECORDING_SCHEMA_VERSION) {
85
- return {
86
- ok: false,
87
- problem: `schemaVersion is ${JSON.stringify(version) ?? "missing"}, and this story core reads ${STORY_RECORDING_SCHEMA_VERSION}`,
88
- };
89
- }
90
- const parsed = recordingSchema.safeParse(value);
91
- if (!parsed.success) {
92
- const issue = parsed.error.issues[0];
93
- const where = issue === undefined || issue.path.length === 0 ? "the recording" : issue.path.join(".");
94
- return { ok: false, problem: `${where}: ${issue?.message ?? "not a recording"}` };
95
- }
96
- return { ok: true, recording: parsed.data };
97
- }
@@ -1,42 +0,0 @@
1
- import type { StoryCall, StoryIdentity } from "./recording.ts";
2
- import { type StoryRecordLevel } from "./mode.ts";
3
- import type { StorySettlement } from "./settle.ts";
4
- /** `user calls slot {"command":"list --json"}`, the input as compact JSON cut to 100 characters. */
5
- export declare function describeCall(call: Pick<StoryCall, "agent" | "tool" | "input">): string;
6
- /**
7
- * What a story's end changed: whether it wrote or removed the story's own recording, and the orphan recordings it
8
- * removed, or found already gone. An end that fails partway keeps what it changed before the failure.
9
- */
10
- export interface StoryApplied {
11
- readonly recording: boolean;
12
- readonly orphans: readonly string[];
13
- }
14
- /**
15
- * One line per aligned call, then one per unreadable recording and orphan, each with its status in brackets:
16
- * `matched`, `divergence`, `unrecorded` or `unmade`, `orphan` or `unreadable`. When the story's end `applied` the
17
- * change to its recording, an unrecorded call reads `recorded`, an accepted divergence `divergence accepted`, an
18
- * unmade call `unmade removed` and an unreadable recording `unreadable rewritten`; each orphan it removed reads
19
- * `orphan removed`.
20
- */
21
- export declare function storyEventLines(settlement: StorySettlement, applied: StoryApplied): readonly string[];
22
- export interface StoryReportInput {
23
- readonly story: StoryIdentity;
24
- readonly level: StoryRecordLevel;
25
- readonly settlement: StorySettlement;
26
- /** Whether the story's body threw, so nothing was written. */
27
- readonly bodyFailed: boolean;
28
- }
29
- /**
30
- * The report of a story that failed: a heading naming the story and the level, each divergence with its
31
- * observation's diff, each stale entry by kind, a line for the recorded calls a story that threw never reached, and a
32
- * summary line saying what to do.
33
- */
34
- export declare function storyReport(input: StoryReportInput): string;
35
- /**
36
- * What a passing story's end `applied`, or `undefined` when it changed nothing. Its first line counts what it did: the
37
- * calls it recorded, the divergences it accepted, the unmade calls it removed, an unreadable recording it rewrote and
38
- * the orphans it removed. One line follows for each call it rewrote and each recording it rewrote or removed, as
39
- * `storyEventLines` gives it, so a call whose input changed with its answer shows as the unmade call removed and the
40
- * new call recorded.
41
- */
42
- export declare function storyChangeReport(story: StoryIdentity, path: string, settlement: StorySettlement, applied: StoryApplied): string | undefined;