@mysten-incubation/devstack 0.1.0 → 0.2.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 (858) hide show
  1. package/README.md +7 -4
  2. package/dashboard-ui/assets/grpc-a4usE3Nk.js +3 -0
  3. package/dashboard-ui/assets/index-B82Bh84P.css +1 -0
  4. package/dashboard-ui/assets/index-CRYJ4pru.js +1277 -0
  5. package/dashboard-ui/index.html +2 -2
  6. package/dist/api/define-capabilities.d.mts +1 -20
  7. package/dist/api/define-capabilities.mjs +15 -22
  8. package/dist/api/define-capabilities.mjs.map +1 -1
  9. package/dist/api/define-devstack-with.d.mts +7 -1
  10. package/dist/api/define-devstack-with.mjs.map +1 -1
  11. package/dist/api/define-devstack.mjs.map +1 -1
  12. package/dist/api/define-plugin.d.mts +2 -1
  13. package/dist/api/inference-network.d.mts +31 -17
  14. package/dist/api/inference-network.mjs +40 -43
  15. package/dist/api/inference-network.mjs.map +1 -1
  16. package/dist/api/load-config.mjs +88 -0
  17. package/dist/api/load-config.mjs.map +1 -0
  18. package/dist/api/mode-narrowed-factory.d.mts +1 -1
  19. package/dist/api/mode-narrowed-factory.mjs.map +1 -1
  20. package/dist/api/run-stack-internal.mjs +202 -0
  21. package/dist/api/run-stack-internal.mjs.map +1 -0
  22. package/dist/api/run-stack.d.mts +82 -31
  23. package/dist/api/run-stack.mjs +22 -141
  24. package/dist/api/run-stack.mjs.map +1 -1
  25. package/dist/build-integrations/dapp-kit/index.d.mts +61 -0
  26. package/dist/build-integrations/dapp-kit/index.mjs +58 -0
  27. package/dist/build-integrations/dapp-kit/index.mjs.map +1 -0
  28. package/dist/build-integrations/playwright/config.d.mts +1 -30
  29. package/dist/build-integrations/playwright/config.mjs +1 -27
  30. package/dist/build-integrations/playwright/config.mjs.map +1 -1
  31. package/dist/build-integrations/playwright/errors.d.mts +4 -7
  32. package/dist/build-integrations/playwright/errors.mjs.map +1 -1
  33. package/dist/build-integrations/playwright/global-setup.d.mts +42 -71
  34. package/dist/build-integrations/playwright/global-setup.mjs +142 -218
  35. package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
  36. package/dist/build-integrations/playwright/index.d.mts +2 -2
  37. package/dist/build-integrations/playwright/index.mjs +2 -2
  38. package/dist/build-integrations/playwright/stack-context.d.mts +3 -1
  39. package/dist/build-integrations/playwright/stack-context.mjs +4 -2
  40. package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
  41. package/dist/build-integrations/playwright/wallet-context.mjs +44 -19
  42. package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
  43. package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
  44. package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -1
  45. package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
  46. package/dist/build-integrations/runtime/discover.d.mts +6 -4
  47. package/dist/build-integrations/runtime/discover.mjs +15 -4
  48. package/dist/build-integrations/runtime/discover.mjs.map +1 -1
  49. package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
  50. package/dist/build-integrations/runtime/errors.mjs.map +1 -1
  51. package/dist/build-integrations/runtime/read-stack-context.mjs +3 -3
  52. package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
  53. package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +23 -7
  54. package/dist/build-integrations/runtime/resolve-discovery-env.mjs +25 -12
  55. package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -1
  56. package/dist/build-integrations/runtime/stack-context.d.mts +2 -2
  57. package/dist/build-integrations/vite/index.d.mts +84 -19
  58. package/dist/build-integrations/vite/index.mjs +203 -28
  59. package/dist/build-integrations/vite/index.mjs.map +1 -1
  60. package/dist/build-integrations/vitest/config.d.mts +20 -2
  61. package/dist/build-integrations/vitest/config.mjs +16 -4
  62. package/dist/build-integrations/vitest/config.mjs.map +1 -1
  63. package/dist/build-integrations/vitest/env.d.mts +18 -10
  64. package/dist/build-integrations/vitest/env.mjs +11 -10
  65. package/dist/build-integrations/vitest/env.mjs.map +1 -1
  66. package/dist/build-integrations/vitest/errors.d.mts +7 -11
  67. package/dist/build-integrations/vitest/errors.mjs +3 -4
  68. package/dist/build-integrations/vitest/errors.mjs.map +1 -1
  69. package/dist/build-integrations/vitest/global-setup.d.mts +35 -0
  70. package/dist/build-integrations/vitest/global-setup.mjs +156 -0
  71. package/dist/build-integrations/vitest/global-setup.mjs.map +1 -0
  72. package/dist/build-integrations/vitest/index.d.mts +3 -2
  73. package/dist/build-integrations/vitest/index.mjs +3 -2
  74. package/dist/build-integrations/vitest/setup.mjs +2 -2
  75. package/dist/build-integrations/vitest/setup.mjs.map +1 -1
  76. package/dist/build-integrations/vitest/stack-context.d.mts +5 -3
  77. package/dist/build-integrations/vitest/stack-context.mjs +3 -2
  78. package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
  79. package/dist/cli/bail.mjs.map +1 -1
  80. package/dist/cli/doctor-probes.mjs +1 -3
  81. package/dist/cli/doctor-probes.mjs.map +1 -1
  82. package/dist/cli/main.d.mts +23 -1
  83. package/dist/cli/main.mjs +63 -8
  84. package/dist/cli/main.mjs.map +1 -1
  85. package/dist/cli/prune-direct.mjs.map +1 -1
  86. package/dist/cli/snapshot-reader.mjs.map +1 -1
  87. package/dist/cli/up-lifecycle.mjs.map +1 -1
  88. package/dist/cli/wirings/apply.mjs +28 -21
  89. package/dist/cli/wirings/apply.mjs.map +1 -1
  90. package/dist/cli/wirings/codegen.mjs +108 -0
  91. package/dist/cli/wirings/codegen.mjs.map +1 -0
  92. package/dist/cli/wirings/config-loader.mjs +12 -62
  93. package/dist/cli/wirings/config-loader.mjs.map +1 -1
  94. package/dist/cli/wirings/dump-ids.mjs +86 -0
  95. package/dist/cli/wirings/dump-ids.mjs.map +1 -0
  96. package/dist/cli/wirings/engine-command.mjs +1 -1
  97. package/dist/cli/wirings/engine-command.mjs.map +1 -1
  98. package/dist/cli/wirings/identity.mjs +2 -2
  99. package/dist/cli/wirings/identity.mjs.map +1 -1
  100. package/dist/cli/wirings/provide-file-system.mjs.map +1 -1
  101. package/dist/cli/wirings/read-devstack-version.mjs +17 -0
  102. package/dist/cli/wirings/read-devstack-version.mjs.map +1 -0
  103. package/dist/cli/wirings/snapshot.mjs +27 -34
  104. package/dist/cli/wirings/snapshot.mjs.map +1 -1
  105. package/dist/cli/wirings/up-ipc.mjs +147 -0
  106. package/dist/cli/wirings/up-ipc.mjs.map +1 -0
  107. package/dist/cli/wirings/up.mjs +218 -198
  108. package/dist/cli/wirings/up.mjs.map +1 -1
  109. package/dist/cli/wirings/wipe.mjs +1 -1
  110. package/dist/cli/wirings/wipe.mjs.map +1 -1
  111. package/dist/contracts/chain-probe.d.mts +1 -1
  112. package/dist/contracts/chain-probe.mjs +1 -1
  113. package/dist/contracts/chain-probe.mjs.map +1 -1
  114. package/dist/contracts/codegenable.d.mts +60 -6
  115. package/dist/contracts/codegenable.mjs +28 -0
  116. package/dist/contracts/codegenable.mjs.map +1 -0
  117. package/dist/contracts/config-bindings.mjs +162 -0
  118. package/dist/contracts/config-bindings.mjs.map +1 -0
  119. package/dist/contracts/container-runtime.d.mts +23 -17
  120. package/dist/contracts/plugin-expander.mjs.map +1 -1
  121. package/dist/contracts/snapshotable.d.mts +5 -7
  122. package/dist/contracts/wallet-protocol.d.mts +2 -5
  123. package/dist/contracts/wallet-protocol.mjs +2 -5
  124. package/dist/contracts/wallet-protocol.mjs.map +1 -1
  125. package/dist/index.d.mts +21 -26
  126. package/dist/index.mjs +8 -9
  127. package/dist/orchestrators/boot.d.mts +28 -0
  128. package/dist/orchestrators/boot.mjs +440 -0
  129. package/dist/orchestrators/boot.mjs.map +1 -0
  130. package/dist/orchestrators/codegen/bindings.d.mts +13 -1
  131. package/dist/orchestrators/codegen/bindings.mjs +23 -9
  132. package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
  133. package/dist/orchestrators/codegen/config-runtime.mjs +208 -0
  134. package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -0
  135. package/dist/orchestrators/codegen/emit.mjs +1 -1
  136. package/dist/orchestrators/codegen/emit.mjs.map +1 -1
  137. package/dist/orchestrators/codegen/errors.mjs +21 -1
  138. package/dist/orchestrators/codegen/errors.mjs.map +1 -1
  139. package/dist/orchestrators/codegen/format.mjs +2 -0
  140. package/dist/orchestrators/codegen/format.mjs.map +1 -1
  141. package/dist/orchestrators/codegen/gitignore.mjs +30 -11
  142. package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
  143. package/dist/orchestrators/codegen/id-config.mjs +107 -0
  144. package/dist/orchestrators/codegen/id-config.mjs.map +1 -0
  145. package/dist/orchestrators/codegen/output-location.mjs +23 -31
  146. package/dist/orchestrators/codegen/output-location.mjs.map +1 -1
  147. package/dist/orchestrators/codegen/paths.mjs +8 -1
  148. package/dist/orchestrators/codegen/paths.mjs.map +1 -1
  149. package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
  150. package/dist/orchestrators/codegen/service.mjs +286 -58
  151. package/dist/orchestrators/codegen/service.mjs.map +1 -1
  152. package/dist/orchestrators/layers.mjs +31 -0
  153. package/dist/orchestrators/layers.mjs.map +1 -0
  154. package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -1
  155. package/dist/orchestrators/lifecycle-prune/index.mjs +8 -10
  156. package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -1
  157. package/dist/orchestrators/network-options.d.mts +52 -0
  158. package/dist/orchestrators/network-options.mjs +43 -0
  159. package/dist/orchestrators/network-options.mjs.map +1 -0
  160. package/dist/orchestrators/router/cleanup.mjs.map +1 -1
  161. package/dist/orchestrators/router/cors.mjs.map +1 -1
  162. package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
  163. package/dist/orchestrators/router/errors.mjs.map +1 -1
  164. package/dist/orchestrators/router/file-provider.mjs.map +1 -1
  165. package/dist/orchestrators/router/hostname.mjs.map +1 -1
  166. package/dist/orchestrators/router/profile.mjs +1 -1
  167. package/dist/orchestrators/router/profile.mjs.map +1 -1
  168. package/dist/orchestrators/router/service.d.mts +2 -2
  169. package/dist/orchestrators/router/service.mjs +12 -27
  170. package/dist/orchestrators/router/service.mjs.map +1 -1
  171. package/dist/orchestrators/router/traefik-container.mjs +1 -1
  172. package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
  173. package/dist/orchestrators/snapshot/capture.mjs +171 -195
  174. package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
  175. package/dist/orchestrators/snapshot/descriptor.d.mts +1 -1
  176. package/dist/orchestrators/snapshot/descriptor.mjs +53 -11
  177. package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
  178. package/dist/orchestrators/snapshot/identity-guard.mjs +3 -5
  179. package/dist/orchestrators/snapshot/identity-guard.mjs.map +1 -1
  180. package/dist/orchestrators/snapshot/image-bundle-tags.mjs +32 -101
  181. package/dist/orchestrators/snapshot/image-bundle-tags.mjs.map +1 -1
  182. package/dist/orchestrators/snapshot/index.mjs +1 -4
  183. package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
  184. package/dist/orchestrators/snapshot/interrupted-restore.mjs +116 -0
  185. package/dist/orchestrators/snapshot/interrupted-restore.mjs.map +1 -0
  186. package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -1
  187. package/dist/orchestrators/snapshot/prune.mjs +40 -31
  188. package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
  189. package/dist/orchestrators/snapshot/restore.mjs +221 -196
  190. package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
  191. package/dist/orchestrators/snapshot/service.mjs +72 -62
  192. package/dist/orchestrators/snapshot/service.mjs.map +1 -1
  193. package/dist/orchestrators/snapshot/wipe.mjs +67 -56
  194. package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
  195. package/dist/plugins/account/codegen.mjs +3 -0
  196. package/dist/plugins/account/codegen.mjs.map +1 -1
  197. package/dist/plugins/account/errors.d.mts +2 -2
  198. package/dist/plugins/account/errors.mjs +1 -4
  199. package/dist/plugins/account/errors.mjs.map +1 -1
  200. package/dist/plugins/account/funding.mjs +3 -27
  201. package/dist/plugins/account/funding.mjs.map +1 -1
  202. package/dist/plugins/account/index.d.mts +3 -8
  203. package/dist/plugins/account/index.mjs +71 -35
  204. package/dist/plugins/account/index.mjs.map +1 -1
  205. package/dist/plugins/account/keypair.d.mts +8 -7
  206. package/dist/plugins/account/keypair.mjs +5 -18
  207. package/dist/plugins/account/keypair.mjs.map +1 -1
  208. package/dist/plugins/account/lease.mjs.map +1 -1
  209. package/dist/plugins/account/registry.d.mts +1 -46
  210. package/dist/plugins/account/registry.mjs.map +1 -1
  211. package/dist/plugins/account/service.d.mts +43 -34
  212. package/dist/plugins/account/service.mjs +9 -54
  213. package/dist/plugins/account/service.mjs.map +1 -1
  214. package/dist/plugins/account/snapshot.mjs.map +1 -1
  215. package/dist/plugins/account/variants/ephemeral.mjs.map +1 -1
  216. package/dist/plugins/account/variants/impersonate.mjs.map +1 -1
  217. package/dist/plugins/account/variants/signer.mjs.map +1 -1
  218. package/dist/plugins/action/discriminator.mjs.map +1 -1
  219. package/dist/plugins/action/errors.mjs +1 -4
  220. package/dist/plugins/action/errors.mjs.map +1 -1
  221. package/dist/plugins/action/execute.mjs +3 -4
  222. package/dist/plugins/action/execute.mjs.map +1 -1
  223. package/dist/plugins/action/index.d.mts +2 -2
  224. package/dist/plugins/action/index.mjs +7 -11
  225. package/dist/plugins/action/index.mjs.map +1 -1
  226. package/dist/plugins/action/service.d.mts +5 -7
  227. package/dist/plugins/action/service.mjs +2 -16
  228. package/dist/plugins/action/service.mjs.map +1 -1
  229. package/dist/plugins/coin/address-resolution.mjs.map +1 -1
  230. package/dist/plugins/coin/codegen.mjs +97 -16
  231. package/dist/plugins/coin/codegen.mjs.map +1 -1
  232. package/dist/plugins/coin/discovery.mjs.map +1 -1
  233. package/dist/plugins/coin/errors.mjs +1 -4
  234. package/dist/plugins/coin/errors.mjs.map +1 -1
  235. package/dist/plugins/coin/index.d.mts +4 -34
  236. package/dist/plugins/coin/index.mjs +47 -28
  237. package/dist/plugins/coin/index.mjs.map +1 -1
  238. package/dist/plugins/coin/metadata.d.mts +1 -0
  239. package/dist/plugins/coin/metadata.mjs +8 -9
  240. package/dist/plugins/coin/metadata.mjs.map +1 -1
  241. package/dist/plugins/coin/mint.mjs +7 -21
  242. package/dist/plugins/coin/mint.mjs.map +1 -1
  243. package/dist/plugins/coin/registry.mjs +33 -20
  244. package/dist/plugins/coin/registry.mjs.map +1 -1
  245. package/dist/plugins/coin/service.d.mts +1 -1
  246. package/dist/plugins/coin/service.mjs +1 -8
  247. package/dist/plugins/coin/service.mjs.map +1 -1
  248. package/dist/plugins/coin/snapshot.mjs.map +1 -1
  249. package/dist/plugins/coin/type-strings.mjs.map +1 -1
  250. package/dist/plugins/dashboard/domain.mjs +106 -167
  251. package/dist/plugins/dashboard/domain.mjs.map +1 -1
  252. package/dist/plugins/dashboard/index.mjs +13 -13
  253. package/dist/plugins/dashboard/index.mjs.map +1 -1
  254. package/dist/plugins/dashboard/origin-policy.mjs +3 -3
  255. package/dist/plugins/dashboard/origin-policy.mjs.map +1 -1
  256. package/dist/plugins/dashboard/routable.mjs.map +1 -1
  257. package/dist/plugins/dashboard/schema/builder.mjs.map +1 -1
  258. package/dist/plugins/dashboard/schema/enums.mjs.map +1 -1
  259. package/dist/plugins/dashboard/schema/root.mjs +23 -44
  260. package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
  261. package/dist/plugins/dashboard/schema/types.mjs +37 -91
  262. package/dist/plugins/dashboard/schema/types.mjs.map +1 -1
  263. package/dist/plugins/dashboard/schema.mjs.map +1 -1
  264. package/dist/plugins/dashboard/server.mjs.map +1 -1
  265. package/dist/plugins/deepbook/codegen.d.mts +12 -11
  266. package/dist/plugins/deepbook/codegen.mjs +108 -11
  267. package/dist/plugins/deepbook/codegen.mjs.map +1 -1
  268. package/dist/plugins/deepbook/deploy.mjs +7 -14
  269. package/dist/plugins/deepbook/deploy.mjs.map +1 -1
  270. package/dist/plugins/deepbook/errors.mjs +4 -2
  271. package/dist/plugins/deepbook/errors.mjs.map +1 -1
  272. package/dist/plugins/deepbook/faucet-strategy.mjs +4 -10
  273. package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
  274. package/dist/plugins/deepbook/hash.mjs.map +1 -1
  275. package/dist/plugins/deepbook/index.d.mts +38 -34
  276. package/dist/plugins/deepbook/index.mjs +133 -64
  277. package/dist/plugins/deepbook/index.mjs.map +1 -1
  278. package/dist/plugins/deepbook/plugin-key.mjs.map +1 -1
  279. package/dist/plugins/deepbook/pyth/index.mjs +4 -8
  280. package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
  281. package/dist/plugins/deepbook/snapshot.mjs +0 -1
  282. package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
  283. package/dist/plugins/deepbook/type-strings.mjs.map +1 -1
  284. package/dist/plugins/deepbook/types.d.mts +2 -1
  285. package/dist/plugins/deepbook/types.mjs.map +1 -1
  286. package/dist/plugins/faucet/dispatcher.d.mts +3 -3
  287. package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
  288. package/dist/plugins/faucet/errors.mjs.map +1 -1
  289. package/dist/plugins/faucet/http.mjs +2 -10
  290. package/dist/plugins/faucet/http.mjs.map +1 -1
  291. package/dist/plugins/faucet/index.mjs +0 -1
  292. package/dist/plugins/faucet/index.mjs.map +1 -1
  293. package/dist/plugins/host-service/errors.d.mts +1 -3
  294. package/dist/plugins/host-service/errors.mjs +1 -2
  295. package/dist/plugins/host-service/errors.mjs.map +1 -1
  296. package/dist/plugins/host-service/index.d.mts +1 -2
  297. package/dist/plugins/host-service/index.mjs +11 -11
  298. package/dist/plugins/host-service/index.mjs.map +1 -1
  299. package/dist/plugins/host-service/routable.mjs.map +1 -1
  300. package/dist/plugins/host-service/service.mjs +13 -13
  301. package/dist/plugins/host-service/service.mjs.map +1 -1
  302. package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -1
  303. package/dist/plugins/internal/codegen-helpers.mjs +2 -0
  304. package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
  305. package/dist/plugins/internal/funding-failure-error.mjs.map +1 -1
  306. package/dist/plugins/{postgres → internal/postgres-sidecar}/connection.mjs +1 -1
  307. package/dist/plugins/internal/postgres-sidecar/connection.mjs.map +1 -0
  308. package/dist/plugins/{postgres → internal/postgres-sidecar}/db-ensure.mjs +30 -16
  309. package/dist/plugins/internal/postgres-sidecar/db-ensure.mjs.map +1 -0
  310. package/dist/plugins/internal/postgres-sidecar/errors.mjs +21 -0
  311. package/dist/plugins/internal/postgres-sidecar/errors.mjs.map +1 -0
  312. package/dist/{substrate/runtime/scoped-multimap → plugins/internal/postgres-sidecar}/index.mjs +1 -0
  313. package/dist/plugins/internal/postgres-sidecar/service.mjs +121 -0
  314. package/dist/plugins/internal/postgres-sidecar/service.mjs.map +1 -0
  315. package/dist/plugins/package/build.mjs +2 -2
  316. package/dist/plugins/package/build.mjs.map +1 -1
  317. package/dist/plugins/package/codegen.d.mts +7 -14
  318. package/dist/plugins/package/codegen.mjs +187 -59
  319. package/dist/plugins/package/codegen.mjs.map +1 -1
  320. package/dist/plugins/package/dep-resolution.mjs +51 -3
  321. package/dist/plugins/package/dep-resolution.mjs.map +1 -1
  322. package/dist/plugins/package/errors.mjs +1 -4
  323. package/dist/plugins/package/errors.mjs.map +1 -1
  324. package/dist/plugins/package/git-source.d.mts +18 -0
  325. package/dist/plugins/package/git-source.mjs +119 -0
  326. package/dist/plugins/package/git-source.mjs.map +1 -0
  327. package/dist/plugins/package/index.d.mts +28 -19
  328. package/dist/plugins/package/index.mjs +107 -32
  329. package/dist/plugins/package/index.mjs.map +1 -1
  330. package/dist/plugins/package/mode-known.mjs +2 -2
  331. package/dist/plugins/package/mode-known.mjs.map +1 -1
  332. package/dist/plugins/package/mode-local.mjs +18 -35
  333. package/dist/plugins/package/mode-local.mjs.map +1 -1
  334. package/dist/plugins/package/publish-executor.mjs +13 -8
  335. package/dist/plugins/package/publish-executor.mjs.map +1 -1
  336. package/dist/plugins/package/publish-output.d.mts +1 -11
  337. package/dist/plugins/package/publish-output.mjs +1 -9
  338. package/dist/plugins/package/publish-output.mjs.map +1 -1
  339. package/dist/plugins/package/registry.d.mts +1 -1
  340. package/dist/plugins/package/registry.mjs +26 -14
  341. package/dist/plugins/package/registry.mjs.map +1 -1
  342. package/dist/plugins/package/service.mjs.map +1 -1
  343. package/dist/plugins/package/snapshot.mjs.map +1 -1
  344. package/dist/plugins/router-entrypoints.mjs +1 -3
  345. package/dist/plugins/router-entrypoints.mjs.map +1 -1
  346. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +1 -2
  347. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
  348. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +1 -6
  349. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
  350. package/dist/plugins/seal/codegen.d.mts +1 -5
  351. package/dist/plugins/seal/codegen.mjs +83 -12
  352. package/dist/plugins/seal/codegen.mjs.map +1 -1
  353. package/dist/plugins/seal/config-render.mjs +2 -6
  354. package/dist/plugins/seal/config-render.mjs.map +1 -1
  355. package/dist/plugins/seal/deploy.mjs +18 -29
  356. package/dist/plugins/seal/deploy.mjs.map +1 -1
  357. package/dist/plugins/seal/errors.d.mts +4 -5
  358. package/dist/plugins/seal/errors.mjs +1 -8
  359. package/dist/plugins/seal/errors.mjs.map +1 -1
  360. package/dist/plugins/seal/index.d.mts +7 -28
  361. package/dist/plugins/seal/index.mjs +69 -47
  362. package/dist/plugins/seal/index.mjs.map +1 -1
  363. package/dist/plugins/seal/key-manager.mjs.map +1 -1
  364. package/dist/plugins/seal/key-server.mjs +1 -6
  365. package/dist/plugins/seal/key-server.mjs.map +1 -1
  366. package/dist/plugins/seal/keygen.mjs +2 -3
  367. package/dist/plugins/seal/keygen.mjs.map +1 -1
  368. package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
  369. package/dist/plugins/seal/mode/live.mjs +1 -1
  370. package/dist/plugins/seal/mode/live.mjs.map +1 -1
  371. package/dist/plugins/seal/mode/local-keygen.mjs +4 -10
  372. package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
  373. package/dist/plugins/seal/plugin-key.mjs.map +1 -1
  374. package/dist/plugins/seal/registry-publish.mjs.map +1 -1
  375. package/dist/plugins/seal/routable.mjs.map +1 -1
  376. package/dist/plugins/seal/service.mjs.map +1 -1
  377. package/dist/plugins/seal/snapshot.mjs +1 -2
  378. package/dist/plugins/seal/snapshot.mjs.map +1 -1
  379. package/dist/plugins/sui/auto-tick.mjs +5 -5
  380. package/dist/plugins/sui/auto-tick.mjs.map +1 -1
  381. package/dist/plugins/sui/chain-build-container.mjs +2 -2
  382. package/dist/plugins/sui/chain-build-container.mjs.map +1 -1
  383. package/dist/plugins/sui/chain-probe.mjs +4 -4
  384. package/dist/plugins/sui/chain-probe.mjs.map +1 -1
  385. package/dist/plugins/sui/codegen.d.mts +9 -7
  386. package/dist/plugins/sui/codegen.mjs +49 -46
  387. package/dist/plugins/sui/codegen.mjs.map +1 -1
  388. package/dist/plugins/sui/errors.d.mts +1 -1
  389. package/dist/plugins/sui/errors.mjs +1 -9
  390. package/dist/plugins/sui/errors.mjs.map +1 -1
  391. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.d.mts +1 -1
  392. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.mjs +3 -7
  393. package/dist/plugins/sui/exec/index.mjs.map +1 -0
  394. package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.mjs +1 -1
  395. package/dist/plugins/sui/exec/sign-and-dispatch.mjs.map +1 -0
  396. package/dist/plugins/sui/fork-faucet-strategy.mjs +2 -6
  397. package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -1
  398. package/dist/plugins/sui/fork-orchestration.mjs +13 -23
  399. package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
  400. package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
  401. package/dist/plugins/sui/index.d.mts +34 -83
  402. package/dist/plugins/sui/index.mjs +200 -68
  403. package/dist/plugins/sui/index.mjs.map +1 -1
  404. package/dist/{substrate/runtime/sui-ledger → plugins/sui/ledger}/object-ref.mjs +1 -1
  405. package/dist/plugins/sui/ledger/object-ref.mjs.map +1 -0
  406. package/dist/plugins/sui/local-faucet-strategy.mjs +1 -5
  407. package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -1
  408. package/dist/plugins/sui/log-attrs.mjs +11 -0
  409. package/dist/plugins/sui/log-attrs.mjs.map +1 -0
  410. package/dist/plugins/sui/mode/external.mjs +4 -12
  411. package/dist/plugins/sui/mode/external.mjs.map +1 -1
  412. package/dist/plugins/sui/mode/fork.mjs +19 -16
  413. package/dist/plugins/sui/mode/fork.mjs.map +1 -1
  414. package/dist/plugins/sui/mode/live.mjs +4 -17
  415. package/dist/plugins/sui/mode/live.mjs.map +1 -1
  416. package/dist/plugins/sui/mode/local.d.mts +1 -0
  417. package/dist/plugins/sui/mode/local.mjs +203 -61
  418. package/dist/plugins/sui/mode/local.mjs.map +1 -1
  419. package/dist/plugins/sui/mode/shared-boot.mjs +18 -23
  420. package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
  421. package/dist/plugins/sui/mode/shared.d.mts +6 -7
  422. package/dist/plugins/sui/mode/shared.mjs.map +1 -1
  423. package/dist/plugins/sui/mode/spec.d.mts +23 -6
  424. package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.mjs +28 -30
  425. package/dist/plugins/sui/move/index.mjs.map +1 -0
  426. package/dist/plugins/sui/move-summary-runner.mjs +8 -4
  427. package/dist/plugins/sui/move-summary-runner.mjs.map +1 -1
  428. package/dist/{substrate/network.d.mts → plugins/sui/network-config.d.mts} +11 -10
  429. package/dist/plugins/sui/network-resolver.d.mts +6 -6
  430. package/dist/plugins/sui/routable.mjs.map +1 -1
  431. package/dist/plugins/sui/service.mjs +10 -6
  432. package/dist/plugins/sui/service.mjs.map +1 -1
  433. package/dist/plugins/sui/snapshot.mjs +10 -5
  434. package/dist/plugins/sui/snapshot.mjs.map +1 -1
  435. package/dist/plugins/wallet/codegen.d.mts +8 -6
  436. package/dist/plugins/wallet/codegen.mjs +4 -10
  437. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  438. package/dist/plugins/wallet/errors.mjs +1 -4
  439. package/dist/plugins/wallet/errors.mjs.map +1 -1
  440. package/dist/plugins/wallet/index.d.mts +3 -6
  441. package/dist/plugins/wallet/index.mjs +16 -21
  442. package/dist/plugins/wallet/index.mjs.map +1 -1
  443. package/dist/plugins/wallet/origin-policy.mjs +3 -3
  444. package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
  445. package/dist/plugins/wallet/pairing.mjs +6 -24
  446. package/dist/plugins/wallet/pairing.mjs.map +1 -1
  447. package/dist/plugins/wallet/protocol.mjs.map +1 -1
  448. package/dist/plugins/wallet/routable.mjs.map +1 -1
  449. package/dist/plugins/wallet/server.mjs +17 -24
  450. package/dist/plugins/wallet/server.mjs.map +1 -1
  451. package/dist/plugins/wallet/service.d.mts +2 -2
  452. package/dist/plugins/wallet/service.mjs +4 -15
  453. package/dist/plugins/wallet/service.mjs.map +1 -1
  454. package/dist/plugins/wallet/snapshot.mjs.map +1 -1
  455. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +1 -5
  456. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
  457. package/dist/plugins/walrus/codegen.d.mts +2 -13
  458. package/dist/plugins/walrus/codegen.mjs +93 -28
  459. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  460. package/dist/plugins/walrus/deploy-paths.mjs +2 -3
  461. package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
  462. package/dist/plugins/walrus/deploy.mjs +26 -19
  463. package/dist/plugins/walrus/deploy.mjs.map +1 -1
  464. package/dist/plugins/walrus/errors.mjs +1 -8
  465. package/dist/plugins/walrus/errors.mjs.map +1 -1
  466. package/dist/plugins/walrus/faucet-strategy.mjs +15 -1
  467. package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
  468. package/dist/plugins/walrus/index.d.mts +13 -44
  469. package/dist/plugins/walrus/index.mjs +119 -122
  470. package/dist/plugins/walrus/index.mjs.map +1 -1
  471. package/dist/plugins/walrus/mode/known-deploy.mjs +6 -6
  472. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  473. package/dist/plugins/walrus/mode/local-cluster.d.mts +2 -2
  474. package/dist/plugins/walrus/mode/local-cluster.mjs +2 -10
  475. package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
  476. package/dist/plugins/walrus/plugin-key.mjs.map +1 -1
  477. package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
  478. package/dist/plugins/walrus/routable.mjs.map +1 -1
  479. package/dist/plugins/walrus/service.mjs.map +1 -1
  480. package/dist/plugins/walrus/snapshot.mjs +3 -3
  481. package/dist/plugins/walrus/snapshot.mjs.map +1 -1
  482. package/dist/plugins/walrus/storage-nodes.mjs +53 -14
  483. package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
  484. package/dist/plugins/walrus/wal-swap.mjs +4 -8
  485. package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
  486. package/dist/primitives/artifact-publisher.mjs.map +1 -1
  487. package/dist/primitives/cache.d.mts +1 -1
  488. package/dist/runtime/docker/client.mjs +47 -3
  489. package/dist/runtime/docker/client.mjs.map +1 -1
  490. package/dist/runtime/docker/container.mjs +37 -57
  491. package/dist/runtime/docker/container.mjs.map +1 -1
  492. package/dist/runtime/docker/errors.mjs.map +1 -1
  493. package/dist/runtime/docker/exec.mjs +2 -2
  494. package/dist/runtime/docker/exec.mjs.map +1 -1
  495. package/dist/runtime/docker/image.mjs +10 -11
  496. package/dist/runtime/docker/image.mjs.map +1 -1
  497. package/dist/runtime/docker/index.mjs +0 -1
  498. package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -1
  499. package/dist/runtime/docker/inventory.mjs +9 -9
  500. package/dist/runtime/docker/inventory.mjs.map +1 -1
  501. package/dist/runtime/docker/labels.mjs +12 -1
  502. package/dist/runtime/docker/labels.mjs.map +1 -1
  503. package/dist/runtime/docker/network.mjs +6 -6
  504. package/dist/runtime/docker/network.mjs.map +1 -1
  505. package/dist/runtime/docker/render-run-args.mjs.map +1 -1
  506. package/dist/runtime/docker/service.mjs +31 -45
  507. package/dist/runtime/docker/service.mjs.map +1 -1
  508. package/dist/runtime/docker/sweep.mjs +14 -64
  509. package/dist/runtime/docker/sweep.mjs.map +1 -1
  510. package/dist/runtime/docker/volume.mjs +1 -1
  511. package/dist/runtime/docker/volume.mjs.map +1 -1
  512. package/dist/runtime/docker/wrap.mjs +14 -2
  513. package/dist/runtime/docker/wrap.mjs.map +1 -1
  514. package/dist/substrate/brand.d.mts +2 -5
  515. package/dist/substrate/brand.mjs +3 -2
  516. package/dist/substrate/brand.mjs.map +1 -1
  517. package/dist/substrate/cross-process.mjs +2 -16
  518. package/dist/substrate/cross-process.mjs.map +1 -1
  519. package/dist/substrate/event-time.mjs +0 -2
  520. package/dist/substrate/event-time.mjs.map +1 -1
  521. package/dist/substrate/events.d.mts +46 -16
  522. package/dist/substrate/identity.d.mts +11 -5
  523. package/dist/substrate/manifest.d.mts +33 -26
  524. package/dist/substrate/manifest.mjs +8 -3
  525. package/dist/substrate/manifest.mjs.map +1 -1
  526. package/dist/substrate/options.d.mts +33 -4
  527. package/dist/substrate/plugin-ctx.d.mts +70 -0
  528. package/dist/substrate/plugin-ctx.mjs +66 -0
  529. package/dist/substrate/plugin-ctx.mjs.map +1 -0
  530. package/dist/substrate/plugin.d.mts +46 -38
  531. package/dist/substrate/plugin.mjs +13 -9
  532. package/dist/substrate/plugin.mjs.map +1 -1
  533. package/dist/substrate/projection.d.mts +1 -1
  534. package/dist/substrate/runtime/atomic-write.mjs +3 -4
  535. package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
  536. package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
  537. package/dist/substrate/runtime/cache/service.mjs +50 -20
  538. package/dist/substrate/runtime/cache/service.mjs.map +1 -1
  539. package/dist/substrate/runtime/config-validation.mjs.map +1 -1
  540. package/dist/substrate/runtime/control-plane/domain.mjs +34 -12
  541. package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -1
  542. package/dist/substrate/runtime/control-plane/service.mjs.map +1 -1
  543. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +14 -17
  544. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
  545. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
  546. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
  547. package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs.map +1 -1
  548. package/dist/substrate/runtime/cross-process/index.mjs +0 -2
  549. package/dist/substrate/runtime/cross-process/live-clock.mjs +1 -1
  550. package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -1
  551. package/dist/substrate/runtime/cross-process/liveness.mjs +11 -18
  552. package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
  553. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +2 -2
  554. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -1
  555. package/dist/substrate/runtime/cross-process/roster.mjs +17 -127
  556. package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
  557. package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -1
  558. package/dist/substrate/runtime/cross-process/stack-lock.mjs +29 -28
  559. package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
  560. package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
  561. package/dist/substrate/runtime/errors.mjs +1 -13
  562. package/dist/substrate/runtime/errors.mjs.map +1 -1
  563. package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -1
  564. package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -1
  565. package/dist/substrate/runtime/host-gateway.mjs.map +1 -1
  566. package/dist/substrate/runtime/host-tree-tar/index.mjs +15 -163
  567. package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
  568. package/dist/substrate/runtime/http-probe.d.mts +1 -3
  569. package/dist/substrate/runtime/http-probe.mjs.map +1 -1
  570. package/dist/substrate/runtime/index.mjs +1 -6
  571. package/dist/substrate/runtime/lease-broker/service.mjs +5 -23
  572. package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
  573. package/dist/substrate/runtime/lifecycle/dep-graph.mjs +3 -3
  574. package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
  575. package/dist/substrate/runtime/lifecycle/graph-input-id.d.mts +1 -0
  576. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs +133 -0
  577. package/dist/substrate/runtime/lifecycle/graph-input-id.mjs.map +1 -0
  578. package/dist/substrate/runtime/lifecycle/index.mjs +2 -2
  579. package/dist/substrate/runtime/lifecycle/plugin-registry.d.mts +1 -1
  580. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +22 -1
  581. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
  582. package/dist/substrate/runtime/lifecycle/ready-gate.mjs +2 -15
  583. package/dist/substrate/runtime/lifecycle/ready-gate.mjs.map +1 -1
  584. package/dist/substrate/runtime/lifecycle/selective-restart.mjs +29 -25
  585. package/dist/substrate/runtime/lifecycle/selective-restart.mjs.map +1 -1
  586. package/dist/substrate/runtime/lifecycle/signals.mjs +1 -1
  587. package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
  588. package/dist/substrate/runtime/lifecycle/state-machine.mjs.map +1 -1
  589. package/dist/substrate/runtime/lifecycle/watch-attribution.d.mts +1 -1
  590. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs +0 -1
  591. package/dist/substrate/runtime/lifecycle/watch-attribution.mjs.map +1 -1
  592. package/dist/substrate/runtime/managed-container.d.mts +5 -1
  593. package/dist/substrate/runtime/managed-container.mjs +8 -10
  594. package/dist/substrate/runtime/managed-container.mjs.map +1 -1
  595. package/dist/substrate/runtime/manifest/manifest.mjs +8 -30
  596. package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
  597. package/dist/substrate/runtime/mode-errors.d.mts +1 -2
  598. package/dist/substrate/runtime/mode-errors.mjs.map +1 -1
  599. package/dist/substrate/runtime/observability/cascade-formatter.mjs +1 -11
  600. package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
  601. package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -1
  602. package/dist/substrate/runtime/observability/index.d.mts +1 -1
  603. package/dist/substrate/runtime/observability/index.mjs +4 -6
  604. package/dist/substrate/runtime/observability/log-attrs.mjs +46 -0
  605. package/dist/substrate/runtime/observability/log-attrs.mjs.map +1 -0
  606. package/dist/substrate/runtime/observability/log-store.mjs.map +1 -1
  607. package/dist/substrate/runtime/observability/logger.mjs +3 -3
  608. package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
  609. package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -1
  610. package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
  611. package/dist/substrate/runtime/observability/process-lines.mjs.map +1 -1
  612. package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
  613. package/dist/substrate/runtime/observability/subprocess-capture.mjs +2 -2
  614. package/dist/substrate/runtime/observability/subprocess-capture.mjs.map +1 -1
  615. package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -1
  616. package/dist/substrate/runtime/paths.mjs +27 -9
  617. package/dist/substrate/runtime/paths.mjs.map +1 -1
  618. package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -1
  619. package/dist/substrate/runtime/port-broker/service.mjs +10 -27
  620. package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
  621. package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
  622. package/dist/substrate/runtime/probes.d.mts +2 -3
  623. package/dist/substrate/runtime/probes.mjs.map +1 -1
  624. package/dist/substrate/runtime/process-supervisor.mjs.map +1 -1
  625. package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
  626. package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
  627. package/dist/substrate/runtime/projection/update.mjs +87 -11
  628. package/dist/substrate/runtime/projection/update.mjs.map +1 -1
  629. package/dist/substrate/runtime/random-suffix.mjs.map +1 -1
  630. package/dist/substrate/runtime/reconcile/fs-plan.mjs +146 -0
  631. package/dist/substrate/runtime/reconcile/fs-plan.mjs.map +1 -0
  632. package/dist/substrate/runtime/reconcile/graph.mjs +19 -0
  633. package/dist/substrate/runtime/reconcile/graph.mjs.map +1 -0
  634. package/dist/substrate/runtime/reconcile/index.mjs +5 -0
  635. package/dist/substrate/runtime/reconcile/label.mjs +41 -0
  636. package/dist/substrate/runtime/reconcile/label.mjs.map +1 -0
  637. package/dist/substrate/runtime/reconcile/spec.mjs +15 -0
  638. package/dist/substrate/runtime/reconcile/spec.mjs.map +1 -0
  639. package/dist/substrate/runtime/retry-policy.d.mts +2 -3
  640. package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
  641. package/dist/substrate/runtime/routed-url.mjs.map +1 -1
  642. package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
  643. package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
  644. package/dist/substrate/runtime/stage-and-swap/index.mjs +49 -12
  645. package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
  646. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -1
  647. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
  648. package/dist/substrate/runtime/strategy-registry/service.mjs +29 -17
  649. package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
  650. package/dist/substrate/runtime/subnet-broker.mjs.map +1 -1
  651. package/dist/substrate/runtime/supervisor/acquire-node.mjs +188 -56
  652. package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -1
  653. package/dist/substrate/runtime/supervisor/background-tasks.mjs +79 -65
  654. package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -1
  655. package/dist/substrate/runtime/supervisor/command-loop.mjs +82 -23
  656. package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -1
  657. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs +16 -0
  658. package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs.map +1 -0
  659. package/dist/substrate/runtime/supervisor/errors.mjs +11 -2
  660. package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -1
  661. package/dist/substrate/runtime/supervisor/index.mjs +2 -0
  662. package/dist/substrate/runtime/supervisor/shutdown.mjs +6 -6
  663. package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -1
  664. package/dist/substrate/runtime/supervisor/start-supervisor.mjs +60 -70
  665. package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -1
  666. package/dist/substrate/runtime/supervisor/state.d.mts +1 -1
  667. package/dist/substrate/runtime/supervisor/state.mjs +1 -1
  668. package/dist/substrate/runtime/supervisor/state.mjs.map +1 -1
  669. package/dist/substrate/runtime/supervisor/teardown.mjs +10 -9
  670. package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -1
  671. package/dist/substrate/runtime/supervisor/wiring.mjs +6 -20
  672. package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -1
  673. package/dist/substrate/runtime/tar/reader.mjs +216 -0
  674. package/dist/substrate/runtime/tar/reader.mjs.map +1 -0
  675. package/dist/substrate/runtime/typed-env.mjs.map +1 -1
  676. package/dist/substrate/versioned-doc-schema.mjs.map +1 -1
  677. package/dist/substrate/versioned-doc-sync.mjs +5 -5
  678. package/dist/substrate/versioned-doc-sync.mjs.map +1 -1
  679. package/dist/surfaces/cli/command-tree.mjs +49 -7
  680. package/dist/surfaces/cli/command-tree.mjs.map +1 -1
  681. package/dist/surfaces/cli/commands/config.mjs +1 -1
  682. package/dist/surfaces/cli/commands/config.mjs.map +1 -1
  683. package/dist/surfaces/cli/commands/confirm-node.mjs.map +1 -1
  684. package/dist/surfaces/cli/commands/confirm.mjs.map +1 -1
  685. package/dist/surfaces/cli/commands/doctor.mjs +1 -1
  686. package/dist/surfaces/cli/commands/doctor.mjs.map +1 -1
  687. package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -1
  688. package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
  689. package/dist/surfaces/cli/commands/prune.mjs +1 -1
  690. package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
  691. package/dist/surfaces/cli/commands/snapshot.mjs +1 -1
  692. package/dist/surfaces/cli/commands/snapshot.mjs.map +1 -1
  693. package/dist/surfaces/cli/commands/status.mjs +1 -1
  694. package/dist/surfaces/cli/commands/status.mjs.map +1 -1
  695. package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
  696. package/dist/surfaces/cli/commands/wipe.mjs +3 -4
  697. package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
  698. package/dist/surfaces/cli/envelope.mjs.map +1 -1
  699. package/dist/surfaces/cli/errors.mjs.map +1 -1
  700. package/dist/surfaces/cli/flags.mjs.map +1 -1
  701. package/dist/surfaces/cli/index.mjs +45 -14
  702. package/dist/surfaces/cli/index.mjs.map +1 -1
  703. package/dist/surfaces/cli/output.mjs.map +1 -1
  704. package/dist/surfaces/cli/sysexits.mjs.map +1 -1
  705. package/dist/surfaces/tui/app.mjs +0 -21
  706. package/dist/surfaces/tui/app.mjs.map +1 -1
  707. package/dist/surfaces/tui/dashboard.mjs +0 -48
  708. package/dist/surfaces/tui/dashboard.mjs.map +1 -1
  709. package/dist/surfaces/tui/display-derivation.mjs +80 -16
  710. package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
  711. package/dist/surfaces/tui/errors.mjs.map +1 -1
  712. package/dist/surfaces/tui/event-log.mjs +0 -9
  713. package/dist/surfaces/tui/event-log.mjs.map +1 -1
  714. package/dist/surfaces/tui/heartbeat.mjs.map +1 -1
  715. package/dist/surfaces/tui/index.mjs +2 -2
  716. package/dist/surfaces/tui/index.mjs.map +1 -1
  717. package/dist/surfaces/tui/input.mjs.map +1 -1
  718. package/dist/surfaces/tui/mode-detect.mjs.map +1 -1
  719. package/dist/surfaces/tui/mount-ink.mjs.map +1 -1
  720. package/dist/surfaces/tui/plain-renderer.mjs +26 -19
  721. package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
  722. package/dist/surfaces/tui/resource-table.mjs +8 -10
  723. package/dist/surfaces/tui/resource-table.mjs.map +1 -1
  724. package/images/postgres/Dockerfile +0 -1
  725. package/images/sui/Dockerfile +27 -54
  726. package/images/sui/entrypoint.sh +17 -179
  727. package/package.json +23 -15
  728. package/dashboard-ui/assets/index-Bmi1UtAg.js +0 -1356
  729. package/dashboard-ui/assets/index-D5EShVt4.js +0 -3
  730. package/dashboard-ui/assets/index-Deml9drg.css +0 -1
  731. package/dist/api/plugin-errors.d.mts +0 -7
  732. package/dist/api/plugin-errors.mjs +0 -10
  733. package/dist/api/plugin-errors.mjs.map +0 -1
  734. package/dist/cli/wirings/build-verb-layers.mjs +0 -42
  735. package/dist/cli/wirings/build-verb-layers.mjs.map +0 -1
  736. package/dist/contracts/capability-decl.d.mts +0 -40
  737. package/dist/orchestrators/built-in-plugin-layers.mjs +0 -54
  738. package/dist/orchestrators/built-in-plugin-layers.mjs.map +0 -1
  739. package/dist/orchestrators/run.mjs +0 -91
  740. package/dist/orchestrators/run.mjs.map +0 -1
  741. package/dist/orchestrators/runtime-composition.d.mts +0 -10
  742. package/dist/orchestrators/runtime-composition.mjs +0 -252
  743. package/dist/orchestrators/runtime-composition.mjs.map +0 -1
  744. package/dist/orchestrators/snapshot/capture-command.d.mts +0 -1
  745. package/dist/orchestrators/snapshot/capture-command.mjs +0 -25
  746. package/dist/orchestrators/snapshot/capture-command.mjs.map +0 -1
  747. package/dist/orchestrators/snapshot/pending-marker.mjs +0 -99
  748. package/dist/orchestrators/snapshot/pending-marker.mjs.map +0 -1
  749. package/dist/orchestrators/snapshot/recover-pending.mjs +0 -223
  750. package/dist/orchestrators/snapshot/recover-pending.mjs.map +0 -1
  751. package/dist/orchestrators/snapshot/state-document.d.mts +0 -1
  752. package/dist/orchestrators/snapshot/state-document.mjs +0 -58
  753. package/dist/orchestrators/snapshot/state-document.mjs.map +0 -1
  754. package/dist/plugins/account/spans.mjs +0 -16
  755. package/dist/plugins/account/spans.mjs.map +0 -1
  756. package/dist/plugins/account/variants/env.mjs +0 -24
  757. package/dist/plugins/account/variants/env.mjs.map +0 -1
  758. package/dist/plugins/account/variants/inline.mjs +0 -13
  759. package/dist/plugins/account/variants/inline.mjs.map +0 -1
  760. package/dist/plugins/account/variants/keystore.mjs +0 -91
  761. package/dist/plugins/account/variants/keystore.mjs.map +0 -1
  762. package/dist/plugins/action/spans.mjs +0 -11
  763. package/dist/plugins/action/spans.mjs.map +0 -1
  764. package/dist/plugins/coin/spans.mjs +0 -20
  765. package/dist/plugins/coin/spans.mjs.map +0 -1
  766. package/dist/plugins/deepbook/spans.mjs +0 -18
  767. package/dist/plugins/deepbook/spans.mjs.map +0 -1
  768. package/dist/plugins/faucet/spans.mjs +0 -12
  769. package/dist/plugins/faucet/spans.mjs.map +0 -1
  770. package/dist/plugins/package/spans.mjs +0 -14
  771. package/dist/plugins/package/spans.mjs.map +0 -1
  772. package/dist/plugins/postgres/codegen.mjs +0 -42
  773. package/dist/plugins/postgres/codegen.mjs.map +0 -1
  774. package/dist/plugins/postgres/connection.d.mts +0 -33
  775. package/dist/plugins/postgres/connection.mjs.map +0 -1
  776. package/dist/plugins/postgres/db-ensure.mjs.map +0 -1
  777. package/dist/plugins/postgres/errors.d.mts +0 -60
  778. package/dist/plugins/postgres/errors.mjs +0 -29
  779. package/dist/plugins/postgres/errors.mjs.map +0 -1
  780. package/dist/plugins/postgres/index.d.mts +0 -37
  781. package/dist/plugins/postgres/index.mjs +0 -68
  782. package/dist/plugins/postgres/index.mjs.map +0 -1
  783. package/dist/plugins/postgres/routable.mjs +0 -33
  784. package/dist/plugins/postgres/routable.mjs.map +0 -1
  785. package/dist/plugins/postgres/service.d.mts +0 -50
  786. package/dist/plugins/postgres/service.mjs +0 -179
  787. package/dist/plugins/postgres/service.mjs.map +0 -1
  788. package/dist/plugins/postgres/snapshot.mjs +0 -32
  789. package/dist/plugins/postgres/snapshot.mjs.map +0 -1
  790. package/dist/plugins/postgres/spans.mjs +0 -11
  791. package/dist/plugins/postgres/spans.mjs.map +0 -1
  792. package/dist/plugins/seal/spans.mjs +0 -18
  793. package/dist/plugins/seal/spans.mjs.map +0 -1
  794. package/dist/plugins/sui/spans.mjs +0 -17
  795. package/dist/plugins/sui/spans.mjs.map +0 -1
  796. package/dist/plugins/wallet/spans.mjs +0 -22
  797. package/dist/plugins/wallet/spans.mjs.map +0 -1
  798. package/dist/plugins/walrus/registry-publish.d.mts +0 -24
  799. package/dist/plugins/walrus/spans.mjs +0 -18
  800. package/dist/plugins/walrus/spans.mjs.map +0 -1
  801. package/dist/runtime/docker/logs.d.mts +0 -1
  802. package/dist/runtime/docker/logs.mjs +0 -34
  803. package/dist/runtime/docker/logs.mjs.map +0 -1
  804. package/dist/substrate/runtime/artifact-publisher/index.mjs +0 -86
  805. package/dist/substrate/runtime/artifact-publisher/index.mjs.map +0 -1
  806. package/dist/substrate/runtime/capability-sinks/index.d.mts +0 -1
  807. package/dist/substrate/runtime/capability-sinks/index.mjs +0 -3
  808. package/dist/substrate/runtime/capability-sinks/layer.d.mts +0 -1
  809. package/dist/substrate/runtime/capability-sinks/layer.mjs +0 -31
  810. package/dist/substrate/runtime/capability-sinks/layer.mjs.map +0 -1
  811. package/dist/substrate/runtime/capability-sinks/service.d.mts +0 -95
  812. package/dist/substrate/runtime/capability-sinks/service.mjs +0 -69
  813. package/dist/substrate/runtime/capability-sinks/service.mjs.map +0 -1
  814. package/dist/substrate/runtime/cross-process/lock.d.mts +0 -1
  815. package/dist/substrate/runtime/cross-process/lock.mjs +0 -23
  816. package/dist/substrate/runtime/cross-process/lock.mjs.map +0 -1
  817. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +0 -113
  818. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +0 -1
  819. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs +0 -31
  820. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +0 -1
  821. package/dist/substrate/runtime/observability/formatter-registry.d.mts +0 -1
  822. package/dist/substrate/runtime/observability/formatter-registry.mjs +0 -48
  823. package/dist/substrate/runtime/observability/formatter-registry.mjs.map +0 -1
  824. package/dist/substrate/runtime/observability/span-store.d.mts +0 -1
  825. package/dist/substrate/runtime/observability/span-store.mjs +0 -110
  826. package/dist/substrate/runtime/observability/span-store.mjs.map +0 -1
  827. package/dist/substrate/runtime/observability/spans.d.mts +0 -1
  828. package/dist/substrate/runtime/observability/spans.mjs +0 -87
  829. package/dist/substrate/runtime/observability/spans.mjs.map +0 -1
  830. package/dist/substrate/runtime/projection/index.mjs +0 -4
  831. package/dist/substrate/runtime/projection/persisted.mjs +0 -213
  832. package/dist/substrate/runtime/projection/persisted.mjs.map +0 -1
  833. package/dist/substrate/runtime/scoped-multimap/service.mjs +0 -52
  834. package/dist/substrate/runtime/scoped-multimap/service.mjs.map +0 -1
  835. package/dist/substrate/runtime/scoped-ref-map/index.mjs +0 -2
  836. package/dist/substrate/runtime/scoped-ref-map/service.mjs +0 -83
  837. package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +0 -1
  838. package/dist/substrate/runtime/state-store/index.mjs +0 -3
  839. package/dist/substrate/runtime/state-store/schema.d.mts +0 -1
  840. package/dist/substrate/runtime/state-store/schema.mjs +0 -41
  841. package/dist/substrate/runtime/state-store/schema.mjs.map +0 -1
  842. package/dist/substrate/runtime/state-store/service.d.mts +0 -1
  843. package/dist/substrate/runtime/state-store/service.mjs +0 -145
  844. package/dist/substrate/runtime/state-store/service.mjs.map +0 -1
  845. package/dist/substrate/runtime/sui-execute/index.mjs.map +0 -1
  846. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +0 -1
  847. package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +0 -1
  848. package/dist/substrate/runtime/sui-move-build/index.mjs.map +0 -1
  849. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +0 -151
  850. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +0 -1
  851. package/dist/substrate/state-store.d.mts +0 -1
  852. /package/dist/orchestrators/{snapshot/pending-marker.d.mts → codegen/id-config.d.mts} +0 -0
  853. /package/dist/orchestrators/snapshot/{recover-pending.d.mts → interrupted-restore.d.mts} +0 -0
  854. /package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.d.mts +0 -0
  855. /package/dist/plugins/{postgres/snapshot.d.mts → sui/ledger/object-ref.d.mts} +0 -0
  856. /package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.d.mts +0 -0
  857. /package/dist/substrate/runtime/{state-store/index.d.mts → reconcile/graph.d.mts} +0 -0
  858. /package/dist/substrate/runtime/{cross-process/snapshot-reservation.d.mts → supervisor/contribution-dispatcher.d.mts} +0 -0
@@ -1,30 +1,51 @@
1
+ import { decodeIdConfig } from "../../orchestrators/codegen/id-config.mjs";
2
+ import { resolveNetworkOptions } from "../../orchestrators/network-options.mjs";
1
3
  import { resolveDiscoveryEnv } from "../runtime/resolve-discovery-env.mjs";
2
4
  import { discoverManifestPath } from "../runtime/discover.mjs";
3
5
  import "../runtime/index.mjs";
4
6
  import { existsSync, readFileSync } from "node:fs";
5
- import { resolve } from "node:path";
7
+ import { isAbsolute, resolve } from "node:path";
6
8
  //#region src/build-integrations/vite/index.ts
7
9
  /** Default import-alias prefix. Customizable via `options.alias` (some
8
10
  * apps prefer `@gen`, `~generated`, …). The app MUST use the SAME
9
11
  * prefix in three derivable places: this plugin option, the
10
12
  * `tsconfig` `paths` entry, and its import specifiers. */
11
13
  const DEFAULT_GENERATED_ALIAS = "@generated";
12
- /** Default home-stack output subpath, relative to the Vite root. The
13
- * cold-start fallback when no manifest / `codegen.generatedDir` is on
14
- * disk yet. Mirrors `output-location.ts`'s home rule. */
15
- const FALLBACK_GENERATED_SUBPATH = "src/generated";
16
- /** Best-effort, SYNC read of the manifest-recorded `codegen.generatedDir`
17
- * for the active stack. Returns the absolute dir, or `null` on any
18
- * miss (no manifest yet, no `codegen` field, unreadable/corrupt file).
19
- * Never throws the caller falls back to `src/generated/`. We read +
20
- * `JSON.parse` directly (rather than the schema-decoding
21
- * `readStackContext`, which (a) drops the `codegen` field in its
22
- * projection and (b) throws on a version mismatch) so an out-of-date
23
- * or partially-written manifest degrades to the cold-start fallback
24
- * instead of crashing the dev server. */
25
- const readGeneratedDirFromManifest = (env, cwd) => {
14
+ /** Default dev-extras import-alias prefix. Resolves the PRIMARY stack's
15
+ * `.devstack/stacks/<stack>/generated-extras` tree (dev-only / secret
16
+ * artifacts — `accounts.ts`, `dev-wallet.ts`). Mirror the `@generated`
17
+ * three-place discipline: this option, the `tsconfig` `paths` entry,
18
+ * and the import specifiers. */
19
+ const DEFAULT_DEV_EXTRAS_ALIAS = "@devstack-dev";
20
+ /** The committed generated-bindings subpath, relative to the Vite root.
21
+ * The single source of bindings written by `devstack codegen` that
22
+ * `@generated` always resolves to (absent the `options.generatedDir`
23
+ * escape hatch). */
24
+ const GENERATED_SUBPATH = "src/generated";
25
+ /** Virtual module id the dev-only HTML injection imports. Vite convention:
26
+ * a `virtual:` specifier resolved to a `\0`-prefixed id in `resolveId`. */
27
+ const VIRTUAL_DEV_WALLET_ID = "virtual:devstack-dev-wallet";
28
+ const RESOLVED_VIRTUAL_DEV_WALLET_ID = "\0virtual:devstack-dev-wallet";
29
+ /** The `/@id/` URL form Vite's middleware understands for a `\0`-prefixed
30
+ * virtual id: the NUL byte is encoded as the literal `__x00__` token (a
31
+ * raw `\0` in an HTML attribute is mangled to a space, which Vite then
32
+ * misroutes to the SPA fallback). Used for the injected `<script src>`. */
33
+ const VIRTUAL_DEV_WALLET_SCRIPT_SRC = `/@id/__x00__${VIRTUAL_DEV_WALLET_ID}`;
34
+ /** Best-effort, SYNC read of a string-valued field at `dottedPath` (e.g.
35
+ * `'codegen.idsFile'`, `'identity.network'`) from the active stack's
36
+ * manifest. Walks each path segment as a nested object, returning the leaf
37
+ * value, or `null` on ANY miss (absent / partially-written / version-
38
+ * mismatched manifest, a non-object hop, a missing or non-string/empty
39
+ * leaf). We read + `JSON.parse` directly (rather than the schema-decoding
40
+ * `readStackContext`, which drops the `codegen` field in its projection
41
+ * and throws on a version mismatch) so an out-of-date or partially-written
42
+ * manifest degrades gracefully instead of crashing the dev server. Never
43
+ * throws — the single discover→parse→guard→degrade-to-null reader every
44
+ * manifest field above (`codegen.idsFile`, `codegen.extrasDir`,
45
+ * `identity.network`) routes through. */
46
+ const readManifestField = (env, cwd, dottedPath) => {
26
47
  try {
27
- const { stack, stateDir } = resolveDiscoveryEnv(env);
48
+ const { stack, stateDir } = resolveDiscoveryEnv(env, { cwd });
28
49
  const manifestPath = discoverManifestPath({
29
50
  env,
30
51
  stack,
@@ -32,19 +53,52 @@ const readGeneratedDirFromManifest = (env, cwd) => {
32
53
  cwd
33
54
  });
34
55
  if (manifestPath === void 0 || !existsSync(manifestPath)) return null;
35
- const parsed = JSON.parse(readFileSync(manifestPath, "utf8"));
36
- if (typeof parsed !== "object" || parsed === null) return null;
37
- const codegen = parsed.codegen;
38
- if (typeof codegen !== "object" || codegen === null) return null;
39
- const generatedDir = codegen.generatedDir;
40
- return typeof generatedDir === "string" && generatedDir.length > 0 ? generatedDir : null;
56
+ let node = JSON.parse(readFileSync(manifestPath, "utf8"));
57
+ for (const segment of dottedPath.split(".")) {
58
+ if (typeof node !== "object" || node === null) return null;
59
+ node = node[segment];
60
+ }
61
+ return typeof node === "string" && node.length > 0 ? node : null;
41
62
  } catch {
42
63
  return null;
43
64
  }
44
65
  };
66
+ /** The gitignored `devstack-ids.json` path the boot wrote for the active
67
+ * stack (`codegen.idsFile`), or `null` on any miss. */
68
+ const readIdsFileFromManifest = (env, cwd) => readManifestField(env, cwd, "codegen.idsFile");
69
+ /** SYNC read + schema-decode of an id-config FILE. The MISSING-file case
70
+ * (absent path, no file on disk) collapses to `null` so the Vite config
71
+ * load degrades gracefully when no stack has booted / no committed file is
72
+ * wired. A PRESENT-but-malformed file is NOT swallowed: it flows through
73
+ * the shared {@link decodeIdConfig}, which THROWS on bad JSON or a shape
74
+ * that violates `IdConfigSchema` — surfacing a genuinely broken committed
75
+ * id-config at config-load instead of silently injecting `null`. */
76
+ const readIdConfigFile = (idsFile) => {
77
+ if (idsFile === null || !existsSync(idsFile)) return null;
78
+ return decodeIdConfig(readFileSync(idsFile, "utf8"));
79
+ };
80
+ /** Resolve the on-chain ids to inject as the `__DEVSTACK_IDS__` global —
81
+ * ALWAYS from an id-config FILE (same schema in dev and prod), never a
82
+ * JSON env blob. Dev (`serve`): the live `devstack-ids.json` (via the
83
+ * manifest `codegen.idsFile`). Prod (`build`): the committed known-
84
+ * deployment file — the plugin `ids` option, else the `DEVSTACK_IDS_FILE`
85
+ * env (a PATH pointer, not data). Neither ⇒ `null`, so the generated
86
+ * resolver throws loudly at id-access time. */
87
+ const resolveInjectedIds = (env, root, command, idsOption) => {
88
+ if (command === "build") {
89
+ const pointer = idsOption ?? env["DEVSTACK_IDS_FILE"];
90
+ if (pointer === void 0 || pointer.length === 0) return null;
91
+ return readIdConfigFile(isAbsolute(pointer) ? pointer : resolve(root, pointer));
92
+ }
93
+ return readIdConfigFile(readIdsFileFromManifest(env, root));
94
+ };
95
+ /** The manifest-recorded dev-extras tree (`codegen.extrasDir`) the
96
+ * `@devstack-dev` alias points at for the active stack, or `null` on any
97
+ * miss. */
98
+ const readExtrasDirFromManifest = (env, cwd) => readManifestField(env, cwd, "codegen.extrasDir");
45
99
  /**
46
100
  * Build the devstack Vite plugin that aliases `options.alias`
47
- * (default `@generated`) at the active stack's codegen output dir.
101
+ * (default `@generated`) at the committed `<root>/src/generated` tree.
48
102
  *
49
103
  * // vite.config.ts
50
104
  * import { devstackVitePlugin } from '@mysten-incubation/devstack/vite';
@@ -53,21 +107,142 @@ const readGeneratedDirFromManifest = (env, cwd) => {
53
107
  *
54
108
  * The plugin's `config` hook merges `resolve.alias[<prefix>] = <dir>`
55
109
  * into the user config (Vite deep-merges the returned partial). Sync;
56
- * reads `process.env` + the manifest once at config-load.
110
+ * reads `process.env` + the manifest (for `__DEVSTACK_IDS__` / the
111
+ * `@devstack-dev` extras dir) once at config-load.
57
112
  */
113
+ /** Derive the cold-start fallback dev-extras dir
114
+ * (`<root>/.devstack/stacks/<stack>/generated-extras`) for the active
115
+ * stack — used when no manifest / `codegen.extrasDir` is on disk yet.
116
+ * Mirrors `output-location.ts`'s `extrasDirFor`. Best-effort: a
117
+ * discovery failure collapses to the `default` stack name. */
118
+ const fallbackExtrasDir = (env, root) => {
119
+ let stack = "default";
120
+ try {
121
+ stack = resolveDiscoveryEnv(env, { cwd: root }).stack;
122
+ } catch {}
123
+ return resolve(root, ".devstack", "stacks", stack, "generated-extras");
124
+ };
125
+ /** Resolve the dev-extras dir for the active stack (shared by the alias
126
+ * config and the dev-wallet virtual module). Explicit option wins, else
127
+ * manifest `codegen.extrasDir`, else the derived cold-start path. */
128
+ const resolveExtrasDir = (options, root, env) => {
129
+ const explicitExtras = options.extrasDir;
130
+ return explicitExtras !== void 0 ? resolve(root, explicitExtras) : readExtrasDirFromManifest(env, root) ?? fallbackExtrasDir(env, root);
131
+ };
132
+ /** Read the `DEVSTACK_AUTO_APPROVE` env (`'1'`/`'true'`, case-insensitive). */
133
+ const autoApproveFromEnv = (env) => {
134
+ const raw = env["DEVSTACK_AUTO_APPROVE"];
135
+ return raw === "1" || raw?.toLowerCase() === "true";
136
+ };
137
+ /** Lit packages deduped to a single instance. The injected dev-wallet UI and
138
+ * the app's dapp-kit UI are both Lit-based; if Vite loads two Lit copies they
139
+ * register custom elements in separate realms, and the second realm's element
140
+ * classes are unknown to the global `customElements` registry — so re-rendering
141
+ * the dev-wallet UI (e.g. on disconnect/reconnect) throws `Illegal constructor`
142
+ * and leaves the app in an unusable connection state. */
143
+ const LIT_DEDUPE = [
144
+ "lit",
145
+ "lit-html",
146
+ "lit-element",
147
+ "@lit/reactive-element"
148
+ ];
149
+ /** The dev-wallet entry points the injected virtual module imports. They are
150
+ * reached only through the `<script>` this plugin adds in `transformIndexHtml`,
151
+ * so Vite's initial dep scan never sees them and re-optimizes mid-session the
152
+ * first time the page loads them — and that late, separate optimize pass pulls
153
+ * a SECOND Lit instance (see {@link LIT_DEDUPE}). Pre-bundling them up front via
154
+ * `optimizeDeps.include` keeps the whole dev-wallet UI graph in the initial pass,
155
+ * sharing one Lit. */
156
+ const DEV_WALLET_OPTIMIZE_ENTRIES = ["@mysten-incubation/dev-wallet/inject", "@mysten-incubation/dev-wallet/adapters"];
157
+ /** True when `@mysten-incubation/dev-wallet` is installed at the app root —
158
+ * i.e. the app actually depends on the dev wallet (the `app` template does;
159
+ * the headless `ts` template does not). Checked by package presence rather
160
+ * than `require.resolve('.../inject')`, whose `exports` entry declares only an
161
+ * `import` condition (the CJS resolver throws `ERR_PACKAGE_PATH_NOT_EXPORTED`).
162
+ * Best-effort: if it's absent we never hand Vite an `optimizeDeps.include` it
163
+ * can't resolve (which would fail the dep scan). */
164
+ const devWalletInstalled = (root) => existsSync(resolve(root, "node_modules", "@mysten-incubation", "dev-wallet", "package.json"));
58
165
  const devstackVitePlugin = (options = {}) => {
59
166
  const alias = options.alias ?? "@generated";
167
+ const devExtrasAlias = options.devExtrasAlias ?? "@devstack-dev";
168
+ const injectDevWallet = options.injectDevWallet ?? true;
169
+ let resolvedRoot = process.cwd();
170
+ let resolvedExtrasDir = null;
171
+ let isServe = false;
60
172
  return {
61
173
  name: "devstack:generated-alias",
62
- config: (config) => {
174
+ config: (config, configEnv) => {
63
175
  const root = config.root ?? process.cwd();
176
+ resolvedRoot = root;
177
+ const env = process.env;
178
+ const command = configEnv?.command ?? config.command ?? "build";
64
179
  const explicit = options.generatedDir;
65
- const generatedDir = explicit !== void 0 ? resolve(root, explicit) : readGeneratedDirFromManifest(process.env, root) ?? resolve(root, FALLBACK_GENERATED_SUBPATH);
66
- return { resolve: { alias: { [alias]: generatedDir } } };
180
+ const generatedDir = explicit !== void 0 ? resolve(root, explicit) : resolve(root, GENERATED_SUBPATH);
181
+ const extrasDir = resolveExtrasDir(options, root, env);
182
+ resolvedExtrasDir = extrasDir;
183
+ const includeDevWallet = injectDevWallet && devWalletInstalled(root);
184
+ const injectedIds = resolveInjectedIds(env, root, command, options.ids);
185
+ return {
186
+ resolve: {
187
+ alias: {
188
+ [alias]: generatedDir,
189
+ [devExtrasAlias]: extrasDir
190
+ },
191
+ dedupe: [...LIT_DEDUPE]
192
+ },
193
+ define: { __DEVSTACK_IDS__: JSON.stringify(injectedIds ?? null) },
194
+ ...includeDevWallet ? { optimizeDeps: { include: [...DEV_WALLET_OPTIMIZE_ENTRIES] } } : {}
195
+ };
196
+ },
197
+ configResolved: (config) => {
198
+ isServe = config.command !== "build";
199
+ },
200
+ resolveId: (id) => {
201
+ if (id === VIRTUAL_DEV_WALLET_ID) return RESOLVED_VIRTUAL_DEV_WALLET_ID;
202
+ },
203
+ load: (id) => {
204
+ if (id !== RESOLVED_VIRTUAL_DEV_WALLET_ID) return void 0;
205
+ const extrasDir = resolvedExtrasDir ?? resolveExtrasDir(options, resolvedRoot, process.env);
206
+ const devWalletFile = resolve(extrasDir, "dev-wallet.ts");
207
+ const accountsFile = resolve(extrasDir, "accounts.ts");
208
+ if (!injectDevWallet || !isServe || !existsSync(devWalletFile) || !existsSync(accountsFile)) return "export {};";
209
+ const env = process.env;
210
+ const netOpts = resolveNetworkOptions(readManifestField(env, resolvedRoot, "identity.network") ?? "mainnet", options.networkOptions);
211
+ const autoApprove = options.autoApprove ?? (autoApproveFromEnv(env) || netOpts.autoApproveSigning);
212
+ return [
213
+ `import { registerDevstackDevWallet } from '@mysten-incubation/dev-wallet/inject';`,
214
+ `import { parseDevstackToken } from '@mysten-incubation/dev-wallet/adapters';`,
215
+ `import { devWallet } from '${devExtrasAlias}/dev-wallet.js';`,
216
+ `import { accounts } from '${devExtrasAlias}/accounts.js';`,
217
+ `import { config as __devstackConfig } from '${alias}/config.js';`,
218
+ `registerDevstackDevWallet({`,
219
+ ` serverOrigin: devWallet.walletUrl,`,
220
+ ` token: parseDevstackToken(devWallet.pairUrl),`,
221
+ ` accounts,`,
222
+ ` rpcUrl: __devstackConfig.networks[__devstackConfig.network].rpc,`,
223
+ ` network: devWallet.network,`,
224
+ ` autoApprove: ${autoApprove ? "true" : "false"},`,
225
+ ` mountUI: true,`,
226
+ `}).catch((err) => console.error('[devstack] dev-wallet injection failed:', err));`
227
+ ].join("\n");
228
+ },
229
+ transformIndexHtml: (html) => {
230
+ if (!injectDevWallet || !isServe) return void 0;
231
+ return {
232
+ html,
233
+ tags: [{
234
+ tag: "script",
235
+ attrs: {
236
+ type: "module",
237
+ src: VIRTUAL_DEV_WALLET_SCRIPT_SRC
238
+ },
239
+ injectTo: "head"
240
+ }]
241
+ };
67
242
  }
68
243
  };
69
244
  };
70
245
  //#endregion
71
- export { DEFAULT_GENERATED_ALIAS, devstackVitePlugin };
246
+ export { DEFAULT_DEV_EXTRAS_ALIAS, DEFAULT_GENERATED_ALIAS, devstackVitePlugin };
72
247
 
73
248
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/build-integrations/vite/index.ts"],"sourcesContent":["// Vite build-integration — `@generated` alias plugin.\n//\n// notes/per-stack-codegen-design.md §\"Import mapping via a customizable\n// alias\": app source imports its Move codegen through a configurable\n// alias prefix (default `@generated`) instead of `./generated`. This\n// plugin points that alias at the ACTIVE stack's output dir — the EXACT\n// dir codegen wrote to for the current stack — so two stacks of the\n// same app (`pnpm dev` on the home stack + `pnpm test:e2e` on a\n// `--stack e2e` override) resolve `@generated/*` to different\n// directories and never read each other's clobbered package-id /\n// wallet-pair-token literals.\n//\n// The target is the manifest-recorded `codegen.generatedDir` (the\n// single source of truth — the supervisor wrote it at flush time; see\n// `orchestrators/codegen/output-location.ts` +\n// `runtime-composition.ts`). Resolution:\n// 1. `options.generatedDir` — explicit escape hatch, used verbatim.\n// 2. `resolveDiscoveryEnv(process.env)` → `{ stack, stateDir }`\n// (single source of truth; honors `DEVSTACK_STACK` +\n// `DEVSTACK_RUNTIME_ROOT`/`DEVSTACK_STATE_DIR`), then\n// `discoverManifestPath(...)` locates `<stateDir>/stacks/<stack>/manifest.json`,\n// and we read its `codegen.generatedDir`.\n// 3. Cold-start fallback — no manifest / no field yet → `<root>/src/generated`.\n// (In the supervised flow Vite starts AFTER post-acquire codegen,\n// so the field is present; the fallback is the pre-`up` window.)\n//\n// Because Playwright's `webServer` runs the app's OWN Vite as a child\n// inheriting `DEVSTACK_STACK`, the same plugin serves both `pnpm dev`\n// and the e2e dev server automatically. Vitest has its own Vite\n// pipeline, so apps add this plugin to `vitest.config.ts` too.\n//\n// SYNC + dependency-light, mirroring the playwright/vitest helpers: NO\n// heavy imports at module top-level, and `vite` is NOT imported (it is\n// an app-side dev dependency, not a devstack runtime dep). The return\n// value is a STRUCTURAL Vite `Plugin` — a `{ name, config }` object —\n// typed loosely so this module loads without `vite` installed. The\n// manifest read goes through the same `build-integrations/runtime`\n// machinery the playwright/vitest integrations use.\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nimport { discoverManifestPath, resolveDiscoveryEnv } from '../runtime/index.ts';\n\n/** Default import-alias prefix. Customizable via `options.alias` (some\n * apps prefer `@gen`, `~generated`, …). The app MUST use the SAME\n * prefix in three derivable places: this plugin option, the\n * `tsconfig` `paths` entry, and its import specifiers. */\nexport const DEFAULT_GENERATED_ALIAS = '@generated';\n\n/** Default home-stack output subpath, relative to the Vite root. The\n * cold-start fallback when no manifest / `codegen.generatedDir` is on\n * disk yet. Mirrors `output-location.ts`'s home rule. */\nconst FALLBACK_GENERATED_SUBPATH = 'src/generated';\n\nexport interface DevstackVitePluginOptions {\n\t/** Import-alias prefix. Default `'@generated'`. */\n\treadonly alias?: string;\n\t/** Explicit generated dir — bypasses manifest discovery entirely\n\t * (escape hatch for unusual layouts / tests). Relative paths\n\t * resolve against the Vite root. */\n\treadonly generatedDir?: string;\n}\n\n/** A `vite` `Plugin`'s `config` hook receives the partial user config.\n * We only ever read `config.root` and return a `resolve.alias` patch,\n * so a one-field structural subset is enough — this keeps the module\n * loadable without `vite` types (mirroring how the playwright/vitest\n * presets avoid importing their optional peer at module init). */\ninterface ViteUserConfigLike {\n\treadonly root?: string;\n}\n\n/** The structural `Plugin` shape we return — `name` + a `config` hook.\n * Typed as the loose object Vite accepts (Vite's `Plugin` is\n * structurally compatible) so callers spread it into `plugins: []`\n * without devstack depending on `vite`. */\nexport interface DevstackVitePlugin {\n\treadonly name: string;\n\treadonly config: (config: ViteUserConfigLike) => {\n\t\treadonly resolve: { readonly alias: Record<string, string> };\n\t};\n}\n\n/** Best-effort, SYNC read of the manifest-recorded `codegen.generatedDir`\n * for the active stack. Returns the absolute dir, or `null` on any\n * miss (no manifest yet, no `codegen` field, unreadable/corrupt file).\n * Never throws — the caller falls back to `src/generated/`. We read +\n * `JSON.parse` directly (rather than the schema-decoding\n * `readStackContext`, which (a) drops the `codegen` field in its\n * projection and (b) throws on a version mismatch) so an out-of-date\n * or partially-written manifest degrades to the cold-start fallback\n * instead of crashing the dev server. */\nconst readGeneratedDirFromManifest = (\n\tenv: Readonly<Record<string, string | undefined>>,\n\tcwd: string,\n): string | null => {\n\ttry {\n\t\tconst { stack, stateDir } = resolveDiscoveryEnv(env);\n\t\tconst manifestPath = discoverManifestPath({ env, stack, stateDir, cwd });\n\t\tif (manifestPath === undefined || !existsSync(manifestPath)) return null;\n\t\tconst parsed: unknown = JSON.parse(readFileSync(manifestPath, 'utf8'));\n\t\tif (typeof parsed !== 'object' || parsed === null) return null;\n\t\tconst codegen = (parsed as { readonly codegen?: unknown }).codegen;\n\t\tif (typeof codegen !== 'object' || codegen === null) return null;\n\t\tconst generatedDir = (codegen as { readonly generatedDir?: unknown }).generatedDir;\n\t\treturn typeof generatedDir === 'string' && generatedDir.length > 0 ? generatedDir : null;\n\t} catch {\n\t\t// Discovery / read / parse failure → cold-start fallback. A\n\t\t// best-effort alias resolver must never fail the Vite config load.\n\t\treturn null;\n\t}\n};\n\n/**\n * Build the devstack Vite plugin that aliases `options.alias`\n * (default `@generated`) at the active stack's codegen output dir.\n *\n * // vite.config.ts\n * import { devstackVitePlugin } from '@mysten-incubation/devstack/vite';\n * export default defineConfig({ plugins: [devstackVitePlugin()] });\n * // or devstackVitePlugin({ alias: '@gen' })\n *\n * The plugin's `config` hook merges `resolve.alias[<prefix>] = <dir>`\n * into the user config (Vite deep-merges the returned partial). Sync;\n * reads `process.env` + the manifest once at config-load.\n */\nexport const devstackVitePlugin = (options: DevstackVitePluginOptions = {}): DevstackVitePlugin => {\n\tconst alias = options.alias ?? DEFAULT_GENERATED_ALIAS;\n\treturn {\n\t\tname: 'devstack:generated-alias',\n\t\tconfig: (config: ViteUserConfigLike) => {\n\t\t\tconst root = config.root ?? process.cwd();\n\t\t\t// Explicit `generatedDir` wins (relative → resolved against the\n\t\t\t// Vite root). Otherwise consult the manifest-recorded dir, then\n\t\t\t// fall back to the home-stack `src/generated/` for the\n\t\t\t// pre-supervisor cold-start window.\n\t\t\tconst explicit = options.generatedDir;\n\t\t\tconst generatedDir =\n\t\t\t\texplicit !== undefined\n\t\t\t\t\t? resolve(root, explicit)\n\t\t\t\t\t: (readGeneratedDirFromManifest(\n\t\t\t\t\t\t\tprocess.env as Readonly<Record<string, string | undefined>>,\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t) ?? resolve(root, FALLBACK_GENERATED_SUBPATH));\n\t\t\t// Return a partial config; Vite merges `resolve.alias` into the\n\t\t\t// existing alias map. A bare-prefix alias (no trailing `/`)\n\t\t\t// matches both `@generated` and `@generated/foo.js` under Vite's\n\t\t\t// default string-alias resolution.\n\t\t\treturn { resolve: { alias: { [alias]: generatedDir } } };\n\t\t},\n\t};\n};\n"],"mappings":";;;;;;;;;;AAgDA,MAAa,0BAA0B;;;;AAKvC,MAAM,6BAA6B;;;;;;;;;;AAwCnC,MAAM,gCACL,KACA,QACmB;AACnB,KAAI;EACH,MAAM,EAAE,OAAO,aAAa,oBAAoB,IAAI;EACpD,MAAM,eAAe,qBAAqB;GAAE;GAAK;GAAO;GAAU;GAAK,CAAC;AACxE,MAAI,iBAAiB,KAAA,KAAa,CAAC,WAAW,aAAa,CAAE,QAAO;EACpE,MAAM,SAAkB,KAAK,MAAM,aAAa,cAAc,OAAO,CAAC;AACtE,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;EAC1D,MAAM,UAAW,OAA0C;AAC3D,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;EAC5D,MAAM,eAAgB,QAAgD;AACtE,SAAO,OAAO,iBAAiB,YAAY,aAAa,SAAS,IAAI,eAAe;SAC7E;AAGP,SAAO;;;;;;;;;;;;;;;;AAiBT,MAAa,sBAAsB,UAAqC,EAAE,KAAyB;CAClG,MAAM,QAAQ,QAAQ,SAAA;AACtB,QAAO;EACN,MAAM;EACN,SAAS,WAA+B;GACvC,MAAM,OAAO,OAAO,QAAQ,QAAQ,KAAK;GAKzC,MAAM,WAAW,QAAQ;GACzB,MAAM,eACL,aAAa,KAAA,IACV,QAAQ,MAAM,SAAS,GACtB,6BACD,QAAQ,KACR,KACA,IAAI,QAAQ,MAAM,2BAA2B;AAKjD,UAAO,EAAE,SAAS,EAAE,OAAO,GAAG,QAAQ,cAAc,EAAE,EAAE;;EAEzD"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/build-integrations/vite/index.ts"],"sourcesContent":["// Vite build-integration — `@generated` alias plugin.\n//\n// App source imports Move codegen through a configurable alias prefix\n// (default `@generated`) instead of `./generated`. This plugin points\n// that alias at the committed `<root>/src/generated` tree — the ONE\n// source of bindings, written only by the stack-free `devstack codegen`\n// verb. On-chain ids are NOT baked into that tree; they resolve at\n// runtime via the `__DEVSTACK_IDS__` global (see `resolveInjectedIds`),\n// so the same generated source serves every stack. Resolution:\n// 1. `options.generatedDir` — explicit escape hatch (relative → root).\n// 2. `<root>/src/generated` — the committed tree, always.\n//\n// Because Playwright's `webServer` runs the app's OWN Vite as a child,\n// the same plugin serves both `pnpm dev` and the e2e dev server\n// automatically. Vitest has its own Vite pipeline, so apps add this\n// plugin to `vitest.config.ts` too — and resolve `@generated` to the\n// same committed tree (the per-stack live tree no longer exists).\n//\n// SYNC + dependency-light, mirroring the playwright/vitest helpers: NO\n// heavy imports at module top-level, and `vite` is NOT imported (it is\n// an app-side dev dependency, not a devstack runtime dep). The return\n// value is a STRUCTURAL Vite `Plugin` — a `{ name, config }` object —\n// typed loosely so this module loads without `vite` installed. The\n// manifest read goes through the same `build-integrations/runtime`\n// machinery the playwright/vitest integrations use.\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { isAbsolute, resolve } from 'node:path';\n\nimport { discoverManifestPath, resolveDiscoveryEnv } from '../runtime/index.ts';\nimport { resolveNetworkOptions } from '../../orchestrators/network-options.ts';\nimport { decodeIdConfig } from '../../orchestrators/codegen/id-config.ts';\n\n/** Default import-alias prefix. Customizable via `options.alias` (some\n * apps prefer `@gen`, `~generated`, …). The app MUST use the SAME\n * prefix in three derivable places: this plugin option, the\n * `tsconfig` `paths` entry, and its import specifiers. */\nexport const DEFAULT_GENERATED_ALIAS = '@generated';\n\n/** Default dev-extras import-alias prefix. Resolves the PRIMARY stack's\n * `.devstack/stacks/<stack>/generated-extras` tree (dev-only / secret\n * artifacts — `accounts.ts`, `dev-wallet.ts`). Mirror the `@generated`\n * three-place discipline: this option, the `tsconfig` `paths` entry,\n * and the import specifiers. */\nexport const DEFAULT_DEV_EXTRAS_ALIAS = '@devstack-dev';\n\n/** The committed generated-bindings subpath, relative to the Vite root.\n * The single source of bindings — written by `devstack codegen` — that\n * `@generated` always resolves to (absent the `options.generatedDir`\n * escape hatch). */\nconst GENERATED_SUBPATH = 'src/generated';\n\nexport interface DevstackVitePluginOptions {\n\t/** Import-alias prefix. Default `'@generated'`. */\n\treadonly alias?: string;\n\t/** Dev-extras import-alias prefix. Default `'@devstack-dev'`. */\n\treadonly devExtrasAlias?: string;\n\t/** Explicit generated dir — bypasses manifest discovery entirely\n\t * (escape hatch for unusual layouts / tests). Relative paths\n\t * resolve against the Vite root. */\n\treadonly generatedDir?: string;\n\t/** Explicit dev-extras dir — bypasses manifest discovery. Relative\n\t * paths resolve against the Vite root. */\n\treadonly extrasDir?: string;\n\t/** Inject + register the devstack dev wallet on the page in DEV\n\t * (wallet-standard, so dApp Kit auto-discovers it). Defaults to\n\t * `true`. Production builds (`command === 'build'`) inject nothing\n\t * regardless. */\n\treadonly injectDevWallet?: boolean;\n\t/** Auto-approve all dev-wallet signing requests (headless Playwright /\n\t * in-app \"Open/Join as\" buttons). Defaults to the `DEVSTACK_AUTO_APPROVE`\n\t * env (`'1'`/`'true'`), then to the active network's `autoApproveSigning`\n\t * per-network policy (ON for every network except live `mainnet`). A\n\t * single switch, replacing per-app `VITE_*_AUTO_APPROVE`.\n\t *\n\t * HARD-CLAMP: on live `mainnet` the per-network policy forces\n\t * auto-approve OFF — a real-funds signature is NEVER granted without a\n\t * human in the loop. An explicit `autoApprove: true` here, or\n\t * `DEVSTACK_AUTO_APPROVE`, still take precedence (the author opted in\n\t * deliberately), but the policy default never silently auto-approves on\n\t * mainnet. */\n\treadonly autoApprove?: boolean;\n\t/** Per-network overrides for the dev-convenience policy (the same\n\t * `networkOptions` shape `defineDevstack` takes, forwarded verbatim).\n\t * Only the `autoApproveSigning` field is read here, to resolve the\n\t * auto-approve default for the active network. Omitted ⇒ the built-in\n\t * policy (ON except live `mainnet`) applies. The override RECORD is not\n\t * otherwise on disk, so an app that customizes per-network signing must\n\t * thread it here explicitly; the mainnet hard-clamp holds regardless. */\n\treadonly networkOptions?: Readonly<Record<string, unknown>>;\n\t/** Production id-config FILE — the known deployment's `devstack-ids.json`\n\t * (same schema the dev stack writes), committed at e.g.\n\t * `config/<network>.ids.json`. Used only for `command === 'build'` to\n\t * inject `__DEVSTACK_IDS__`. Relative paths resolve against the Vite\n\t * root. If omitted, the `DEVSTACK_IDS_FILE` env (a path pointer) is used.\n\t * Neither ⇒ no ids baked, and the generated resolver throws loudly at\n\t * id-access time. We deliberately take a FILE, not a JSON env blob: a\n\t * real deployment's ids are many + nested. */\n\treadonly ids?: string;\n}\n\n/** A `vite` `Plugin`'s `config` hook receives the partial user config.\n * We only ever read `config.root` and return a `resolve.alias` patch,\n * so a one-field structural subset is enough — this keeps the module\n * loadable without `vite` types (mirroring how the playwright/vitest\n * presets avoid importing their optional peer at module init). */\ninterface ViteUserConfigLike {\n\treadonly root?: string;\n\treadonly command?: 'build' | 'serve';\n}\n\n/** Virtual module id the dev-only HTML injection imports. Vite convention:\n * a `virtual:` specifier resolved to a `\\0`-prefixed id in `resolveId`. */\nconst VIRTUAL_DEV_WALLET_ID = 'virtual:devstack-dev-wallet';\nconst RESOLVED_VIRTUAL_DEV_WALLET_ID = '\\0virtual:devstack-dev-wallet';\n/** The `/@id/` URL form Vite's middleware understands for a `\\0`-prefixed\n * virtual id: the NUL byte is encoded as the literal `__x00__` token (a\n * raw `\\0` in an HTML attribute is mangled to a space, which Vite then\n * misroutes to the SPA fallback). Used for the injected `<script src>`. */\nconst VIRTUAL_DEV_WALLET_SCRIPT_SRC = `/@id/__x00__${VIRTUAL_DEV_WALLET_ID}`;\n\n/** The structural `Plugin` shape we return — `name`, a `config` hook, and\n * the DEV-only dev-wallet-injection hooks. Typed as the loose object Vite\n * accepts (Vite's `Plugin` is structurally compatible) so callers spread\n * it into `plugins: []` without devstack depending on `vite`. */\n/** Vite's `config` hook second arg — `{ command, mode }`. We read only\n * `command` to pick the dev vs prod id-injection source. */\ninterface ViteConfigEnvLike {\n\treadonly command?: 'build' | 'serve';\n}\n\nexport interface DevstackVitePlugin {\n\treadonly name: string;\n\treadonly config: (\n\t\tconfig: ViteUserConfigLike,\n\t\tenv?: ViteConfigEnvLike,\n\t) => {\n\t\treadonly resolve: {\n\t\t\treadonly alias: Record<string, string>;\n\t\t\t// Mutable `string[]` (NOT `readonly`): Vite's `ResolveOptions.dedupe`\n\t\t\t// and `DepOptimizationConfig.include` are both `string[] | undefined`,\n\t\t\t// and a `readonly string[]` return makes the whole `config` hook\n\t\t\t// unassignable to Vite's `Plugin` type in a consuming app's\n\t\t\t// `vite.config.ts`/`vitest.config.ts`. The values we return\n\t\t\t// (`[...LIT_DEDUPE]`, a freshly built array) are already mutable.\n\t\t\treadonly dedupe?: string[];\n\t\t};\n\t\treadonly optimizeDeps?: { readonly include: string[] };\n\t\t/** Build-time `define` injecting the on-chain ids as the\n\t\t * `__DEVSTACK_IDS__` global (the generated resolver reads it). */\n\t\treadonly define: Record<string, string>;\n\t};\n\t/** Capture the resolved command so injection is DEV-only. */\n\treadonly configResolved: (config: ViteUserConfigLike) => void;\n\t/** Resolve the dev-wallet virtual module. */\n\treadonly resolveId: (id: string) => string | undefined;\n\t/** Emit the dev-wallet register module (or a no-op when not applicable). */\n\treadonly load: (id: string) => string | undefined;\n\t/** Inject a `<script type=\"module\">` importing the virtual module into\n\t * the dev page's HTML. DEV-only. The return shape mirrors a structural\n\t * subset of Vite's `IndexHtmlTransformResult` (mutable `tags`,\n\t * `injectTo` as the literal `'head'`) so the plugin stays assignable to\n\t * Vite's `Plugin` without devstack importing `vite`. */\n\treadonly transformIndexHtml: (html: string) =>\n\t\t| {\n\t\t\t\thtml: string;\n\t\t\t\ttags: Array<{\n\t\t\t\t\ttag: string;\n\t\t\t\t\tattrs: Record<string, string | boolean>;\n\t\t\t\t\tinjectTo: 'head';\n\t\t\t\t}>;\n\t\t }\n\t\t| undefined;\n}\n\n/** Best-effort, SYNC read of a string-valued field at `dottedPath` (e.g.\n * `'codegen.idsFile'`, `'identity.network'`) from the active stack's\n * manifest. Walks each path segment as a nested object, returning the leaf\n * value, or `null` on ANY miss (absent / partially-written / version-\n * mismatched manifest, a non-object hop, a missing or non-string/empty\n * leaf). We read + `JSON.parse` directly (rather than the schema-decoding\n * `readStackContext`, which drops the `codegen` field in its projection\n * and throws on a version mismatch) so an out-of-date or partially-written\n * manifest degrades gracefully instead of crashing the dev server. Never\n * throws — the single discover→parse→guard→degrade-to-null reader every\n * manifest field above (`codegen.idsFile`, `codegen.extrasDir`,\n * `identity.network`) routes through. */\nconst readManifestField = (\n\tenv: Readonly<Record<string, string | undefined>>,\n\tcwd: string,\n\tdottedPath: string,\n): string | null => {\n\ttry {\n\t\tconst { stack, stateDir } = resolveDiscoveryEnv(env, { cwd });\n\t\tconst manifestPath = discoverManifestPath({ env, stack, stateDir, cwd });\n\t\tif (manifestPath === undefined || !existsSync(manifestPath)) return null;\n\t\tlet node: unknown = JSON.parse(readFileSync(manifestPath, 'utf8'));\n\t\tfor (const segment of dottedPath.split('.')) {\n\t\t\tif (typeof node !== 'object' || node === null) return null;\n\t\t\tnode = (node as Record<string, unknown>)[segment];\n\t\t}\n\t\treturn typeof node === 'string' && node.length > 0 ? node : null;\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n/** The gitignored `devstack-ids.json` path the boot wrote for the active\n * stack (`codegen.idsFile`), or `null` on any miss. */\nconst readIdsFileFromManifest = (\n\tenv: Readonly<Record<string, string | undefined>>,\n\tcwd: string,\n): string | null => readManifestField(env, cwd, 'codegen.idsFile');\n\n/** SYNC read + schema-decode of an id-config FILE. The MISSING-file case\n * (absent path, no file on disk) collapses to `null` so the Vite config\n * load degrades gracefully when no stack has booted / no committed file is\n * wired. A PRESENT-but-malformed file is NOT swallowed: it flows through\n * the shared {@link decodeIdConfig}, which THROWS on bad JSON or a shape\n * that violates `IdConfigSchema` — surfacing a genuinely broken committed\n * id-config at config-load instead of silently injecting `null`. */\nconst readIdConfigFile = (idsFile: string | null): unknown => {\n\tif (idsFile === null || !existsSync(idsFile)) return null;\n\treturn decodeIdConfig(readFileSync(idsFile, 'utf8'));\n};\n\n/** Resolve the on-chain ids to inject as the `__DEVSTACK_IDS__` global —\n * ALWAYS from an id-config FILE (same schema in dev and prod), never a\n * JSON env blob. Dev (`serve`): the live `devstack-ids.json` (via the\n * manifest `codegen.idsFile`). Prod (`build`): the committed known-\n * deployment file — the plugin `ids` option, else the `DEVSTACK_IDS_FILE`\n * env (a PATH pointer, not data). Neither ⇒ `null`, so the generated\n * resolver throws loudly at id-access time. */\nconst resolveInjectedIds = (\n\tenv: Readonly<Record<string, string | undefined>>,\n\troot: string,\n\tcommand: 'build' | 'serve' | undefined,\n\tidsOption: string | undefined,\n): unknown => {\n\t// Prod build: the known deployment's committed id-config file. Option\n\t// wins; else a `DEVSTACK_IDS_FILE` path pointer. Relative → Vite root.\n\tif (command === 'build') {\n\t\tconst pointer = idsOption ?? env['DEVSTACK_IDS_FILE'];\n\t\tif (pointer === undefined || pointer.length === 0) return null;\n\t\treturn readIdConfigFile(isAbsolute(pointer) ? pointer : resolve(root, pointer));\n\t}\n\t// Dev serve (and config-load default): the live id-config file.\n\treturn readIdConfigFile(readIdsFileFromManifest(env, root));\n};\n\n/** The manifest-recorded dev-extras tree (`codegen.extrasDir`) the\n * `@devstack-dev` alias points at for the active stack, or `null` on any\n * miss. */\nconst readExtrasDirFromManifest = (\n\tenv: Readonly<Record<string, string | undefined>>,\n\tcwd: string,\n): string | null => readManifestField(env, cwd, 'codegen.extrasDir');\n\n/**\n * Build the devstack Vite plugin that aliases `options.alias`\n * (default `@generated`) at the committed `<root>/src/generated` tree.\n *\n * // vite.config.ts\n * import { devstackVitePlugin } from '@mysten-incubation/devstack/vite';\n * export default defineConfig({ plugins: [devstackVitePlugin()] });\n * // or devstackVitePlugin({ alias: '@gen' })\n *\n * The plugin's `config` hook merges `resolve.alias[<prefix>] = <dir>`\n * into the user config (Vite deep-merges the returned partial). Sync;\n * reads `process.env` + the manifest (for `__DEVSTACK_IDS__` / the\n * `@devstack-dev` extras dir) once at config-load.\n */\n/** Derive the cold-start fallback dev-extras dir\n * (`<root>/.devstack/stacks/<stack>/generated-extras`) for the active\n * stack — used when no manifest / `codegen.extrasDir` is on disk yet.\n * Mirrors `output-location.ts`'s `extrasDirFor`. Best-effort: a\n * discovery failure collapses to the `default` stack name. */\nconst fallbackExtrasDir = (\n\tenv: Readonly<Record<string, string | undefined>>,\n\troot: string,\n): string => {\n\tlet stack = 'default';\n\ttry {\n\t\tstack = resolveDiscoveryEnv(env, { cwd: root }).stack;\n\t} catch {\n\t\t// keep the `default` fallback.\n\t}\n\treturn resolve(root, '.devstack', 'stacks', stack, 'generated-extras');\n};\n\n/** Resolve the dev-extras dir for the active stack (shared by the alias\n * config and the dev-wallet virtual module). Explicit option wins, else\n * manifest `codegen.extrasDir`, else the derived cold-start path. */\nconst resolveExtrasDir = (\n\toptions: DevstackVitePluginOptions,\n\troot: string,\n\tenv: Readonly<Record<string, string | undefined>>,\n): string => {\n\tconst explicitExtras = options.extrasDir;\n\treturn explicitExtras !== undefined\n\t\t? resolve(root, explicitExtras)\n\t\t: (readExtrasDirFromManifest(env, root) ?? fallbackExtrasDir(env, root));\n};\n\n/** Read the `DEVSTACK_AUTO_APPROVE` env (`'1'`/`'true'`, case-insensitive). */\nconst autoApproveFromEnv = (env: Readonly<Record<string, string | undefined>>): boolean => {\n\tconst raw = env['DEVSTACK_AUTO_APPROVE'];\n\treturn raw === '1' || raw?.toLowerCase() === 'true';\n};\n\n/** Lit packages deduped to a single instance. The injected dev-wallet UI and\n * the app's dapp-kit UI are both Lit-based; if Vite loads two Lit copies they\n * register custom elements in separate realms, and the second realm's element\n * classes are unknown to the global `customElements` registry — so re-rendering\n * the dev-wallet UI (e.g. on disconnect/reconnect) throws `Illegal constructor`\n * and leaves the app in an unusable connection state. */\nconst LIT_DEDUPE = ['lit', 'lit-html', 'lit-element', '@lit/reactive-element'] as const;\n\n/** The dev-wallet entry points the injected virtual module imports. They are\n * reached only through the `<script>` this plugin adds in `transformIndexHtml`,\n * so Vite's initial dep scan never sees them and re-optimizes mid-session the\n * first time the page loads them — and that late, separate optimize pass pulls\n * a SECOND Lit instance (see {@link LIT_DEDUPE}). Pre-bundling them up front via\n * `optimizeDeps.include` keeps the whole dev-wallet UI graph in the initial pass,\n * sharing one Lit. */\nconst DEV_WALLET_OPTIMIZE_ENTRIES = [\n\t'@mysten-incubation/dev-wallet/inject',\n\t'@mysten-incubation/dev-wallet/adapters',\n] as const;\n\n/** True when `@mysten-incubation/dev-wallet` is installed at the app root —\n * i.e. the app actually depends on the dev wallet (the `app` template does;\n * the headless `ts` template does not). Checked by package presence rather\n * than `require.resolve('.../inject')`, whose `exports` entry declares only an\n * `import` condition (the CJS resolver throws `ERR_PACKAGE_PATH_NOT_EXPORTED`).\n * Best-effort: if it's absent we never hand Vite an `optimizeDeps.include` it\n * can't resolve (which would fail the dep scan). */\nconst devWalletInstalled = (root: string): boolean =>\n\texistsSync(resolve(root, 'node_modules', '@mysten-incubation', 'dev-wallet', 'package.json'));\n\nexport const devstackVitePlugin = (options: DevstackVitePluginOptions = {}): DevstackVitePlugin => {\n\tconst alias = options.alias ?? DEFAULT_GENERATED_ALIAS;\n\tconst devExtrasAlias = options.devExtrasAlias ?? DEFAULT_DEV_EXTRAS_ALIAS;\n\tconst injectDevWallet = options.injectDevWallet ?? true;\n\n\t// Captured across hooks. `config` runs first (alias resolution),\n\t// `configResolved` records the command (DEV-gate), and `load` re-reads\n\t// the dev-wallet config off `extrasDir`.\n\tlet resolvedRoot = process.cwd();\n\tlet resolvedExtrasDir: string | null = null;\n\tlet isServe = false;\n\n\treturn {\n\t\tname: 'devstack:generated-alias',\n\t\tconfig: (config: ViteUserConfigLike, configEnv?: ViteConfigEnvLike) => {\n\t\t\tconst root = config.root ?? process.cwd();\n\t\t\tresolvedRoot = root;\n\t\t\tconst env = process.env as Readonly<Record<string, string | undefined>>;\n\t\t\t// `command` comes from the second hook arg (`{ command, mode }`);\n\t\t\t// fall back to `config.command` (some callers pass it on the\n\t\t\t// config). Default the UNKNOWN case to `build` (build-safe): only an\n\t\t\t// EXPLICIT `serve` takes the live local-stack id-injection path, so a\n\t\t\t// programmatic `vite.build()` that omits the env arg never bakes\n\t\t\t// dev-stack ids into a production bundle.\n\t\t\tconst command = configEnv?.command ?? config.command ?? 'build';\n\t\t\t// Explicit `generatedDir` wins (relative → resolved against the\n\t\t\t// Vite root). Otherwise always the committed `<root>/src/generated`\n\t\t\t// tree — the single source of bindings written by `devstack\n\t\t\t// codegen`; ids resolve at runtime via `__DEVSTACK_IDS__`, so the\n\t\t\t// same tree serves every stack.\n\t\t\tconst explicit = options.generatedDir;\n\t\t\tconst generatedDir =\n\t\t\t\texplicit !== undefined ? resolve(root, explicit) : resolve(root, GENERATED_SUBPATH);\n\t\t\t// `@devstack-dev` mirrors `@generated` exactly.\n\t\t\tconst extrasDir = resolveExtrasDir(options, root, env);\n\t\t\tresolvedExtrasDir = extrasDir;\n\t\t\t// Return a partial config; Vite deep-merges it. `resolve.dedupe`\n\t\t\t// pins a single Lit copy, and — when this app carries the dev\n\t\t\t// wallet — we pre-bundle the injected dev-wallet entries so Vite\n\t\t\t// never re-optimizes them mid-session into a second Lit realm\n\t\t\t// (see the constants above).\n\t\t\tconst includeDevWallet = injectDevWallet && devWalletInstalled(root);\n\t\t\t// Inject the on-chain ids as a build-time global. The generated\n\t\t\t// `config-runtime.ts` resolver reads `__DEVSTACK_IDS__`\n\t\t\t// synchronously and throws `DevstackConfigMissingError` when an id\n\t\t\t// is unresolved. `define` substitutes it identically in the dev\n\t\t\t// server and the prod build.\n\t\t\tconst injectedIds = resolveInjectedIds(env, root, command, options.ids);\n\t\t\treturn {\n\t\t\t\tresolve: {\n\t\t\t\t\t// A bare-prefix alias (no trailing `/`) matches both\n\t\t\t\t\t// `@generated` and `@generated/foo.js` under Vite's default\n\t\t\t\t\t// string-alias resolution.\n\t\t\t\t\talias: {\n\t\t\t\t\t\t[alias]: generatedDir,\n\t\t\t\t\t\t[devExtrasAlias]: extrasDir,\n\t\t\t\t\t},\n\t\t\t\t\tdedupe: [...LIT_DEDUPE],\n\t\t\t\t},\n\t\t\t\tdefine: {\n\t\t\t\t\t__DEVSTACK_IDS__: JSON.stringify(injectedIds ?? null),\n\t\t\t\t},\n\t\t\t\t...(includeDevWallet\n\t\t\t\t\t? { optimizeDeps: { include: [...DEV_WALLET_OPTIMIZE_ENTRIES] } }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t},\n\n\t\tconfigResolved: (config: ViteUserConfigLike) => {\n\t\t\t// DEV-gate: only a `serve` command injects the dev wallet. A\n\t\t\t// production `vite build` injects nothing.\n\t\t\tisServe = config.command !== 'build';\n\t\t},\n\n\t\tresolveId: (id: string) => {\n\t\t\tif (id === VIRTUAL_DEV_WALLET_ID) return RESOLVED_VIRTUAL_DEV_WALLET_ID;\n\t\t\treturn undefined;\n\t\t},\n\n\t\tload: (id: string): string | undefined => {\n\t\t\tif (id !== RESOLVED_VIRTUAL_DEV_WALLET_ID) return undefined;\n\t\t\t// Graceful no-op when injection is off, not a dev serve, or the\n\t\t\t// dev-extras config is absent (no `devstack apply` yet).\n\t\t\tconst extrasDir = resolvedExtrasDir ?? resolveExtrasDir(options, resolvedRoot, process.env);\n\t\t\tconst devWalletFile = resolve(extrasDir, 'dev-wallet.ts');\n\t\t\tconst accountsFile = resolve(extrasDir, 'accounts.ts');\n\t\t\tif (!injectDevWallet || !isServe || !existsSync(devWalletFile) || !existsSync(accountsFile)) {\n\t\t\t\treturn 'export {};';\n\t\t\t}\n\t\t\tconst env = process.env as Readonly<Record<string, string | undefined>>;\n\t\t\t// Auto-approve resolution (highest precedence first): explicit\n\t\t\t// `options.autoApprove`, then the `DEVSTACK_AUTO_APPROVE` env, then\n\t\t\t// the active network's `autoApproveSigning` per-network policy. The\n\t\t\t// policy is ON for every network EXCEPT live `mainnet`, so a stack\n\t\t\t// booted against real mainnet never silently auto-approves a\n\t\t\t// real-funds signature. The active network comes from the manifest\n\t\t\t// boot wrote (`identity.network`); absent that we conservatively\n\t\t\t// resolve as `mainnet` (auto-approve OFF) rather than assuming a\n\t\t\t// dev network. The override RECORD isn't on disk — `networkOptions`\n\t\t\t// is read from the plugin option when the app threads it.\n\t\t\tconst network = readManifestField(env, resolvedRoot, 'identity.network') ?? 'mainnet';\n\t\t\tconst netOpts = resolveNetworkOptions(network, options.networkOptions);\n\t\t\tconst autoApprove =\n\t\t\t\toptions.autoApprove ?? (autoApproveFromEnv(env) || netOpts.autoApproveSigning);\n\t\t\t// Re-export the generated config through the `@devstack-dev`\n\t\t\t// alias (already wired in `config`), parse the token, and\n\t\t\t// register the page wallet on load. Kept as source the dev\n\t\t\t// server transpiles — it imports `@mysten-incubation/dev-wallet`\n\t\t\t// + the generated extras, both resolvable in the app graph.\n\t\t\treturn [\n\t\t\t\t`import { registerDevstackDevWallet } from '@mysten-incubation/dev-wallet/inject';`,\n\t\t\t\t`import { parseDevstackToken } from '@mysten-incubation/dev-wallet/adapters';`,\n\t\t\t\t`import { devWallet } from '${devExtrasAlias}/dev-wallet.js';`,\n\t\t\t\t`import { accounts } from '${devExtrasAlias}/accounts.js';`,\n\t\t\t\t// The wallet EXECUTES (and simulates) against the same routed\n\t\t\t\t// RPC the app's dApp Kit client uses — a raw 127.0.0.1 RPC is\n\t\t\t\t// CORS-blocked from the routed page origin. Sourced from the\n\t\t\t\t// generated runtime config (active network's `rpc`).\n\t\t\t\t`import { config as __devstackConfig } from '${alias}/config.js';`,\n\t\t\t\t`registerDevstackDevWallet({`,\n\t\t\t\t` serverOrigin: devWallet.walletUrl,`,\n\t\t\t\t` token: parseDevstackToken(devWallet.pairUrl),`,\n\t\t\t\t` accounts,`,\n\t\t\t\t` rpcUrl: __devstackConfig.networks[__devstackConfig.network].rpc,`,\n\t\t\t\t` network: devWallet.network,`,\n\t\t\t\t` autoApprove: ${autoApprove ? 'true' : 'false'},`,\n\t\t\t\t` mountUI: true,`,\n\t\t\t\t`}).catch((err) => console.error('[devstack] dev-wallet injection failed:', err));`,\n\t\t\t].join('\\n');\n\t\t},\n\n\t\ttransformIndexHtml: (html: string) => {\n\t\t\tif (!injectDevWallet || !isServe) return undefined;\n\t\t\treturn {\n\t\t\t\thtml,\n\t\t\t\ttags: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttag: 'script',\n\t\t\t\t\t\tattrs: { type: 'module', src: VIRTUAL_DEV_WALLET_SCRIPT_SRC },\n\t\t\t\t\t\tinjectTo: 'head',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n};\n"],"mappings":";;;;;;;;;;;;AAqCA,MAAa,0BAA0B;;;;;;AAOvC,MAAa,2BAA2B;;;;;AAMxC,MAAM,oBAAoB;;;AA+D1B,MAAM,wBAAwB;AAC9B,MAAM,iCAAiC;;;;;AAKvC,MAAM,gCAAgC,eAAe;;;;;;;;;;;;;AAoErD,MAAM,qBACL,KACA,KACA,eACmB;CACnB,IAAI;EACH,MAAM,EAAE,OAAO,aAAa,oBAAoB,KAAK,EAAE,IAAI,CAAC;EAC5D,MAAM,eAAe,qBAAqB;GAAE;GAAK;GAAO;GAAU;EAAI,CAAC;EACvE,IAAI,iBAAiB,KAAA,KAAa,CAAC,WAAW,YAAY,GAAG,OAAO;EACpE,IAAI,OAAgB,KAAK,MAAM,aAAa,cAAc,MAAM,CAAC;EACjE,KAAK,MAAM,WAAW,WAAW,MAAM,GAAG,GAAG;GAC5C,IAAI,OAAO,SAAS,YAAY,SAAS,MAAM,OAAO;GACtD,OAAQ,KAAiC;EAC1C;EACA,OAAO,OAAO,SAAS,YAAY,KAAK,SAAS,IAAI,OAAO;CAC7D,QAAQ;EACP,OAAO;CACR;AACD;;;AAIA,MAAM,2BACL,KACA,QACmB,kBAAkB,KAAK,KAAK,iBAAiB;;;;;;;;AASjE,MAAM,oBAAoB,YAAoC;CAC7D,IAAI,YAAY,QAAQ,CAAC,WAAW,OAAO,GAAG,OAAO;CACrD,OAAO,eAAe,aAAa,SAAS,MAAM,CAAC;AACpD;;;;;;;;AASA,MAAM,sBACL,KACA,MACA,SACA,cACa;CAGb,IAAI,YAAY,SAAS;EACxB,MAAM,UAAU,aAAa,IAAI;EACjC,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,GAAG,OAAO;EAC1D,OAAO,iBAAiB,WAAW,OAAO,IAAI,UAAU,QAAQ,MAAM,OAAO,CAAC;CAC/E;CAEA,OAAO,iBAAiB,wBAAwB,KAAK,IAAI,CAAC;AAC3D;;;;AAKA,MAAM,6BACL,KACA,QACmB,kBAAkB,KAAK,KAAK,mBAAmB;;;;;;;;;;;;;;;;;;;;AAqBnE,MAAM,qBACL,KACA,SACY;CACZ,IAAI,QAAQ;CACZ,IAAI;EACH,QAAQ,oBAAoB,KAAK,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC;CACjD,QAAQ,CAER;CACA,OAAO,QAAQ,MAAM,aAAa,UAAU,OAAO,kBAAkB;AACtE;;;;AAKA,MAAM,oBACL,SACA,MACA,QACY;CACZ,MAAM,iBAAiB,QAAQ;CAC/B,OAAO,mBAAmB,KAAA,IACvB,QAAQ,MAAM,cAAc,IAC3B,0BAA0B,KAAK,IAAI,KAAK,kBAAkB,KAAK,IAAI;AACxE;;AAGA,MAAM,sBAAsB,QAA+D;CAC1F,MAAM,MAAM,IAAI;CAChB,OAAO,QAAQ,OAAO,KAAK,YAAY,MAAM;AAC9C;;;;;;;AAQA,MAAM,aAAa;CAAC;CAAO;CAAY;CAAe;AAAuB;;;;;;;;AAS7E,MAAM,8BAA8B,CACnC,wCACA,wCACD;;;;;;;;AASA,MAAM,sBAAsB,SAC3B,WAAW,QAAQ,MAAM,gBAAgB,sBAAsB,cAAc,cAAc,CAAC;AAE7F,MAAa,sBAAsB,UAAqC,CAAC,MAA0B;CAClG,MAAM,QAAQ,QAAQ,SAAA;CACtB,MAAM,iBAAiB,QAAQ,kBAAA;CAC/B,MAAM,kBAAkB,QAAQ,mBAAmB;CAKnD,IAAI,eAAe,QAAQ,IAAI;CAC/B,IAAI,oBAAmC;CACvC,IAAI,UAAU;CAEd,OAAO;EACN,MAAM;EACN,SAAS,QAA4B,cAAkC;GACtE,MAAM,OAAO,OAAO,QAAQ,QAAQ,IAAI;GACxC,eAAe;GACf,MAAM,MAAM,QAAQ;GAOpB,MAAM,UAAU,WAAW,WAAW,OAAO,WAAW;GAMxD,MAAM,WAAW,QAAQ;GACzB,MAAM,eACL,aAAa,KAAA,IAAY,QAAQ,MAAM,QAAQ,IAAI,QAAQ,MAAM,iBAAiB;GAEnF,MAAM,YAAY,iBAAiB,SAAS,MAAM,GAAG;GACrD,oBAAoB;GAMpB,MAAM,mBAAmB,mBAAmB,mBAAmB,IAAI;GAMnE,MAAM,cAAc,mBAAmB,KAAK,MAAM,SAAS,QAAQ,GAAG;GACtE,OAAO;IACN,SAAS;KAIR,OAAO;OACL,QAAQ;OACR,iBAAiB;KACnB;KACA,QAAQ,CAAC,GAAG,UAAU;IACvB;IACA,QAAQ,EACP,kBAAkB,KAAK,UAAU,eAAe,IAAI,EACrD;IACA,GAAI,mBACD,EAAE,cAAc,EAAE,SAAS,CAAC,GAAG,2BAA2B,EAAE,EAAE,IAC9D,CAAC;GACL;EACD;EAEA,iBAAiB,WAA+B;GAG/C,UAAU,OAAO,YAAY;EAC9B;EAEA,YAAY,OAAe;GAC1B,IAAI,OAAO,uBAAuB,OAAO;EAE1C;EAEA,OAAO,OAAmC;GACzC,IAAI,OAAO,gCAAgC,OAAO,KAAA;GAGlD,MAAM,YAAY,qBAAqB,iBAAiB,SAAS,cAAc,QAAQ,GAAG;GAC1F,MAAM,gBAAgB,QAAQ,WAAW,eAAe;GACxD,MAAM,eAAe,QAAQ,WAAW,aAAa;GACrD,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,WAAW,aAAa,KAAK,CAAC,WAAW,YAAY,GACzF,OAAO;GAER,MAAM,MAAM,QAAQ;GAYpB,MAAM,UAAU,sBADA,kBAAkB,KAAK,cAAc,kBAAkB,KAAK,WAC7B,QAAQ,cAAc;GACrE,MAAM,cACL,QAAQ,gBAAgB,mBAAmB,GAAG,KAAK,QAAQ;GAM5D,OAAO;IACN;IACA;IACA,8BAA8B,eAAe;IAC7C,6BAA6B,eAAe;IAK5C,+CAA+C,MAAM;IACrD;IACA;IACA;IACA;IACA;IACA;IACA,kBAAkB,cAAc,SAAS,QAAQ;IACjD;IACA;GACD,CAAC,CAAC,KAAK,IAAI;EACZ;EAEA,qBAAqB,SAAiB;GACrC,IAAI,CAAC,mBAAmB,CAAC,SAAS,OAAO,KAAA;GACzC,OAAO;IACN;IACA,MAAM,CACL;KACC,KAAK;KACL,OAAO;MAAE,MAAM;MAAU,KAAK;KAA8B;KAC5D,UAAU;IACX,CACD;GACD;EACD;CACD;AACD"}
@@ -11,6 +11,21 @@ interface DevstackVitestTestConfigOptions {
11
11
  * uses defaults; an options object configures the captured
12
12
  * fixture (e.g. `{ requireDevstack: true }`). Default: not wired. */
13
13
  readonly testSetup?: boolean | TestSetupOptions;
14
+ /** Marks this as the E2E (full-stack) config: boots a dedicated `test`
15
+ * stack for the run via vitest `globalSetup` (tearing it down on
16
+ * completion), AND scopes the run to `*.e2e.{test,spec}` files only. A
17
+ * plain `devstackVitestTestConfig()` is the UNIT config — it runs the
18
+ * other suites and excludes the `*.e2e` ones. So `pnpm test` (unit) never
19
+ * touches Docker, and `pnpm test:e2e` boots an isolated stack that runs
20
+ * in parallel to a developer's `pnpm dev` without contending.
21
+ * Default: not wired (unit config).
22
+ *
23
+ * The injected boot module reads its knobs from the environment
24
+ * (`DEVSTACK_STACK`, `DEVSTACK_RUNTIME_ROOT`, `DEVSTACK_TEST_REUSE`).
25
+ * For programmatic options (custom stack name, reuse, timeout), author a
26
+ * one-line `globalSetup` module calling `devstackVitestGlobalSetup(opts)`
27
+ * and pass its path via `test.globalSetup` instead. */
28
+ readonly autoBoot?: boolean;
14
29
  /** Enable vitest's typecheck pass. Default `false` — most apps
15
30
  * run `tsc` outside vitest. */
16
31
  readonly typecheck?: boolean;
@@ -39,8 +54,11 @@ interface DevstackVitestTestConfigOptions {
39
54
  *
40
55
  * For chain-mode integration tests against a real devstack, build a
41
56
  * devstack handle and pass `handle.layer` to `@effect/vitest`'s
42
- * `it.layer(...)` directly. This helper does not boot devstack the
43
- * test file owns its lifecycle.
57
+ * `it.layer(...)` directly here the test file owns its lifecycle.
58
+ * Alternatively, `autoBoot: true` wires the `global-setup.ts` boot seam
59
+ * that boots a dedicated stack for the `*.e2e` run and tears it down
60
+ * after (so `pnpm test:e2e` is self-contained); a plain call boots
61
+ * nothing and just builds the `test` block below.
44
62
  *
45
63
  * For suites that need a shared StackContext fixture (manifest read
46
64
  * once per file), opt into the setup file:
@@ -6,6 +6,11 @@
6
6
  * package's `./vitest/setup` subpath (added to package.json
7
7
  * `exports` alongside the integration). */
8
8
  const DEVSTACK_SETUP_MODULE = "@mysten-incubation/devstack/vitest/setup";
9
+ /** Path to the bundled devstack `globalSetup` module. Injected into
10
+ * `test.globalSetup` when `opts.autoBoot` is set — it boots a `test`
11
+ * stack before the run and tears it down after. Resolved like any npm
12
+ * package via the `./vitest/global-setup` subpath in package.json. */
13
+ const DEVSTACK_GLOBAL_SETUP_MODULE = "@mysten-incubation/devstack/vitest/global-setup";
9
14
  /** Runtime-root prefix the watcher MUST ignore — per architecture §
10
15
  * Invariants → "No-restart on harmless changes". The 500ms manifest
11
16
  * tick would otherwise re-trigger reloads. */
@@ -29,8 +34,11 @@ const WATCH_IGNORED_PATTERNS = [
29
34
  *
30
35
  * For chain-mode integration tests against a real devstack, build a
31
36
  * devstack handle and pass `handle.layer` to `@effect/vitest`'s
32
- * `it.layer(...)` directly. This helper does not boot devstack the
33
- * test file owns its lifecycle.
37
+ * `it.layer(...)` directly here the test file owns its lifecycle.
38
+ * Alternatively, `autoBoot: true` wires the `global-setup.ts` boot seam
39
+ * that boots a dedicated stack for the `*.e2e` run and tears it down
40
+ * after (so `pnpm test:e2e` is self-contained); a plain call boots
41
+ * nothing and just builds the `test` block below.
34
42
  *
35
43
  * For suites that need a shared StackContext fixture (manifest read
36
44
  * once per file), opt into the setup file:
@@ -54,19 +62,23 @@ const devstackVitestTestConfig = (options = {}) => {
54
62
  fileParallelism: true
55
63
  } : {};
56
64
  const typecheckOverride = options.typecheck === true ? { typecheck: { enabled: true } } : {};
65
+ const isE2e = Boolean(options.autoBoot);
66
+ const autoBootOverride = isE2e ? { globalSetup: [DEVSTACK_GLOBAL_SETUP_MODULE] } : {};
57
67
  return {
58
- include: ["src/**/*.{test,spec}.ts?(x)", "test/**/*.{test,spec}.ts?(x)"],
68
+ include: isE2e ? ["src/**/*.e2e.{test,spec}.ts?(x)", "test/**/*.e2e.{test,spec}.ts?(x)"] : ["src/**/*.{test,spec}.ts?(x)", "test/**/*.{test,spec}.ts?(x)"],
59
69
  exclude: [
60
70
  "e2e/**",
61
71
  "node_modules",
62
72
  "dist",
63
73
  ".turbo",
64
- "**/.devstack/**"
74
+ "**/.devstack/**",
75
+ ...isE2e ? [] : ["**/*.e2e.{test,spec}.ts?(x)"]
65
76
  ],
66
77
  passWithNoTests: true,
67
78
  ...setupFiles.length > 0 ? { setupFiles } : {},
68
79
  ...threadOverride,
69
80
  ...typecheckOverride,
81
+ ...autoBootOverride,
70
82
  ...options.test
71
83
  };
72
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../../../src/build-integrations/vitest/config.ts"],"sourcesContent":["// Vitest build-integration config helpers.\n//\n// Architecture (distilled/23-build-integrations.md § Per-integration\n// requirements → Vitest, § Outputs / capabilities, § Invariants):\n// - Canonical include/exclude: src globs in, e2e/dist/node_modules\n// out (`e2e/**` runs through the Playwright integration).\n// - `passWithNoTests: true` so codegen-derived stacks without unit\n// tests yet don't fail CI.\n// - `@effect/vitest` is declared as an optional peer — the preset\n// itself does not import it. Suites using `it.layer(stack.layer)`\n// bring it in directly.\n// - No-restart on harmless changes: watch ignores `<runtimeRoot>/**`\n// so the ~500ms manifest tick doesn't trigger a reload loop.\n//\n// Optional knobs:\n// - `testSetup: true | TestSetupOptions` wires the devstack\n// setup file (`./setup.ts`) automatically via `test.setupFiles`.\n// - `typecheck: true` opts INTO vitest's typecheck pass (off by\n// default — apps typically run `tsc` separately).\n// - `threads: 'single' | 'multi'` picks `pool: 'threads'` and toggles\n// `fileParallelism` (vitest 4: top-level `fileParallelism: false`\n// replaces the v3 `poolOptions.threads.singleThread`) for\n// stack-shared-state suites that can't safely parallelize.\n// - Caller-provided `test` fields win over the preset's defaults.\n//\n// No I/O happens at config-build time (per architecture § Lifecycle\n// states: vitest preset call is synchronous + side-effect free).\n\nimport type { ViteUserConfig } from 'vitest/config';\n\nimport type { TestSetupOptions } from './setup.ts';\n\n// -----------------------------------------------------------------------------\n// Public options\n// -----------------------------------------------------------------------------\n\nexport interface DevstackVitestTestConfigOptions {\n\t/** Extra `test` fields. Caller-provided keys win over the preset's\n\t * defaults; the preset's include/exclude/passWithNoTests are the\n\t * start, the caller's fields are merged shallowly. */\n\treadonly test?: NonNullable<ViteUserConfig['test']>;\n\t/** Wire the devstack `beforeAll` / `afterAll` setup file. `true`\n\t * uses defaults; an options object configures the captured\n\t * fixture (e.g. `{ requireDevstack: true }`). Default: not wired. */\n\treadonly testSetup?: boolean | TestSetupOptions;\n\t/** Enable vitest's typecheck pass. Default `false` — most apps\n\t * run `tsc` outside vitest. */\n\treadonly typecheck?: boolean;\n\t/** Threading mode. `'single'` forces a single thread (needed when\n\t * tests share devstack state); `'multi'` keeps vitest's default\n\t * worker pool. Default: vitest default (`undefined`). */\n\treadonly threads?: 'single' | 'multi';\n\t/** Absolute path to a user-authored setup file. When set, it is\n\t * appended to `test.setupFiles` AFTER the devstack setup file (so\n\t * the user file sees the captured StackContext via\n\t * `getStackContext()`). */\n\treadonly setupFile?: string;\n}\n\n// -----------------------------------------------------------------------------\n// Internals\n// -----------------------------------------------------------------------------\n\n/** Path to the bundled devstack setup file. The preset injects this\n * via `test.setupFiles` when `opts.testSetup` is truthy. The literal\n * string is the module's import specifier so vitest resolves it like\n * any other npm package; an apps-level resolver finds it via the\n * package's `./vitest/setup` subpath (added to package.json\n * `exports` alongside the integration). */\nconst DEVSTACK_SETUP_MODULE = '@mysten-incubation/devstack/vitest/setup';\n\n/** Runtime-root prefix the watcher MUST ignore — per architecture §\n * Invariants → \"No-restart on harmless changes\". The 500ms manifest\n * tick would otherwise re-trigger reloads. */\nconst WATCH_IGNORED_PATTERNS = ['**/.devstack/**', '**/node_modules/**', '**/dist/**'];\n\n// -----------------------------------------------------------------------------\n// Public surface\n// -----------------------------------------------------------------------------\n\n/**\n * Build the devstack-owned part of Vitest's `test` block. Apps keep a\n * normal `defineConfig(...)` call and compose this value into it:\n *\n * import { defineConfig } from 'vitest/config';\n * import { devstackVitestServerConfig, devstackVitestTestConfig }\n * from '@mysten-incubation/devstack/vitest';\n *\n * export default defineConfig({\n * server: devstackVitestServerConfig(),\n * test: devstackVitestTestConfig(),\n * });\n *\n * For chain-mode integration tests against a real devstack, build a\n * devstack handle and pass `handle.layer` to `@effect/vitest`'s\n * `it.layer(...)` directly. This helper does not boot devstack — the\n * test file owns its lifecycle.\n *\n * For suites that need a shared StackContext fixture (manifest read\n * once per file), opt into the setup file:\n *\n * test: devstackVitestTestConfig({\n * testSetup: { requireDevstack: true },\n * })\n *\n * The setup file's `beforeAll` populates a captured fixture readable\n * via `getStackContext()` from inside `it`/`test` bodies.\n */\nexport const devstackVitestTestConfig = (\n\toptions: DevstackVitestTestConfigOptions = {},\n): NonNullable<ViteUserConfig['test']> => {\n\tconst setupFiles: Array<string> = [];\n\tif (options.testSetup) {\n\t\tsetupFiles.push(DEVSTACK_SETUP_MODULE);\n\t}\n\tif (options.setupFile !== undefined) {\n\t\tsetupFiles.push(options.setupFile);\n\t}\n\n\t// Vitest 4 removed `poolOptions.threads.singleThread`. Top-level\n\t// `fileParallelism: false` is the replacement for single-threaded\n\t// runs (also pins `maxWorkers` to 1 per vitest's docs). Both\n\t// branches set `pool: 'threads'` explicitly so we don't depend on\n\t// vitest's default pool (which is `forks` in v4).\n\tconst threadOverride =\n\t\toptions.threads === 'single'\n\t\t\t? { pool: 'threads' as const, fileParallelism: false }\n\t\t\t: options.threads === 'multi'\n\t\t\t\t? { pool: 'threads' as const, fileParallelism: true }\n\t\t\t\t: {};\n\n\tconst typecheckOverride = options.typecheck === true ? { typecheck: { enabled: true } } : {};\n\n\treturn {\n\t\tinclude: ['src/**/*.{test,spec}.ts?(x)', 'test/**/*.{test,spec}.ts?(x)'],\n\t\texclude: ['e2e/**', 'node_modules', 'dist', '.turbo', '**/.devstack/**'],\n\t\tpassWithNoTests: true,\n\t\t...(setupFiles.length > 0 ? { setupFiles } : {}),\n\t\t...threadOverride,\n\t\t...typecheckOverride,\n\t\t// Caller overrides last. Shallow merge.\n\t\t...options.test,\n\t};\n};\n\n/** Build the devstack-owned part of Vitest's Vite server config.\n * Callers that need additional server options should merge them in\n * their own `defineConfig(...)` file. */\nexport const devstackVitestServerConfig = (): NonNullable<ViteUserConfig['server']> => ({\n\twatch: {\n\t\t// vite's chokidar watcher honors `ignored` even in test mode.\n\t\tignored: WATCH_IGNORED_PATTERNS,\n\t},\n});\n\n// -----------------------------------------------------------------------------\n// Test-visible internals (do not re-export from the integration barrel)\n// -----------------------------------------------------------------------------\n\n/** @internal — used by `test/build-integrations/vitest/config.test.ts`\n * to assert the watcher ignored set without depending on a built\n * config snapshot. */\nexport const _internal = {\n\tDEVSTACK_SETUP_MODULE,\n\tWATCH_IGNORED_PATTERNS,\n} as const;\n"],"mappings":";;;;;;;AAqEA,MAAM,wBAAwB;;;;AAK9B,MAAM,yBAAyB;CAAC;CAAmB;CAAsB;CAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCtF,MAAa,4BACZ,UAA2C,EAAE,KACJ;CACzC,MAAM,aAA4B,EAAE;AACpC,KAAI,QAAQ,UACX,YAAW,KAAK,sBAAsB;AAEvC,KAAI,QAAQ,cAAc,KAAA,EACzB,YAAW,KAAK,QAAQ,UAAU;CAQnC,MAAM,iBACL,QAAQ,YAAY,WACjB;EAAE,MAAM;EAAoB,iBAAiB;EAAO,GACpD,QAAQ,YAAY,UACnB;EAAE,MAAM;EAAoB,iBAAiB;EAAM,GACnD,EAAE;CAEP,MAAM,oBAAoB,QAAQ,cAAc,OAAO,EAAE,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,EAAE;AAE5F,QAAO;EACN,SAAS,CAAC,+BAA+B,+BAA+B;EACxE,SAAS;GAAC;GAAU;GAAgB;GAAQ;GAAU;GAAkB;EACxE,iBAAiB;EACjB,GAAI,WAAW,SAAS,IAAI,EAAE,YAAY,GAAG,EAAE;EAC/C,GAAG;EACH,GAAG;EAEH,GAAG,QAAQ;EACX;;;;;AAMF,MAAa,oCAA2E,EACvF,OAAO,EAEN,SAAS,wBACT,EACD"}
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../../../src/build-integrations/vitest/config.ts"],"sourcesContent":["// Vitest build-integration config helpers.\n//\n// Architecture (distilled/23-build-integrations.md § Per-integration\n// requirements → Vitest, § Outputs / capabilities, § Invariants):\n// - Canonical include/exclude: src globs in, e2e/dist/node_modules\n// out (`e2e/**` runs through the Playwright integration).\n// - `passWithNoTests: true` so codegen-derived stacks without unit\n// tests yet don't fail CI.\n// - `@effect/vitest` is declared as an optional peer — the preset\n// itself does not import it. Suites using `it.layer(stack.layer)`\n// bring it in directly.\n// - No-restart on harmless changes: watch ignores `<runtimeRoot>/**`\n// so the ~500ms manifest tick doesn't trigger a reload loop.\n//\n// Optional knobs:\n// - `testSetup: true | TestSetupOptions` wires the devstack\n// setup file (`./setup.ts`) automatically via `test.setupFiles`.\n// - `typecheck: true` opts INTO vitest's typecheck pass (off by\n// default — apps typically run `tsc` separately).\n// - `threads: 'single' | 'multi'` picks `pool: 'threads'` and toggles\n// `fileParallelism` (vitest 4 uses a top-level\n// `fileParallelism: false`) for stack-shared-state suites that\n// can't safely parallelize.\n// - Caller-provided `test` fields win over the preset's defaults.\n//\n// No I/O happens at config-build time (per architecture § Lifecycle\n// states: vitest preset call is synchronous + side-effect free).\n\nimport type { ViteUserConfig } from 'vitest/config';\n\nimport type { TestSetupOptions } from './setup.ts';\n\n// -----------------------------------------------------------------------------\n// Public options\n// -----------------------------------------------------------------------------\n\nexport interface DevstackVitestTestConfigOptions {\n\t/** Extra `test` fields. Caller-provided keys win over the preset's\n\t * defaults; the preset's include/exclude/passWithNoTests are the\n\t * start, the caller's fields are merged shallowly. */\n\treadonly test?: NonNullable<ViteUserConfig['test']>;\n\t/** Wire the devstack `beforeAll` / `afterAll` setup file. `true`\n\t * uses defaults; an options object configures the captured\n\t * fixture (e.g. `{ requireDevstack: true }`). Default: not wired. */\n\treadonly testSetup?: boolean | TestSetupOptions;\n\t/** Marks this as the E2E (full-stack) config: boots a dedicated `test`\n\t * stack for the run via vitest `globalSetup` (tearing it down on\n\t * completion), AND scopes the run to `*.e2e.{test,spec}` files only. A\n\t * plain `devstackVitestTestConfig()` is the UNIT config — it runs the\n\t * other suites and excludes the `*.e2e` ones. So `pnpm test` (unit) never\n\t * touches Docker, and `pnpm test:e2e` boots an isolated stack that runs\n\t * in parallel to a developer's `pnpm dev` without contending.\n\t * Default: not wired (unit config).\n\t *\n\t * The injected boot module reads its knobs from the environment\n\t * (`DEVSTACK_STACK`, `DEVSTACK_RUNTIME_ROOT`, `DEVSTACK_TEST_REUSE`).\n\t * For programmatic options (custom stack name, reuse, timeout), author a\n\t * one-line `globalSetup` module calling `devstackVitestGlobalSetup(opts)`\n\t * and pass its path via `test.globalSetup` instead. */\n\treadonly autoBoot?: boolean;\n\t/** Enable vitest's typecheck pass. Default `false` — most apps\n\t * run `tsc` outside vitest. */\n\treadonly typecheck?: boolean;\n\t/** Threading mode. `'single'` forces a single thread (needed when\n\t * tests share devstack state); `'multi'` keeps vitest's default\n\t * worker pool. Default: vitest default (`undefined`). */\n\treadonly threads?: 'single' | 'multi';\n\t/** Absolute path to a user-authored setup file. When set, it is\n\t * appended to `test.setupFiles` AFTER the devstack setup file (so\n\t * the user file sees the captured StackContext via\n\t * `getStackContext()`). */\n\treadonly setupFile?: string;\n}\n\n// -----------------------------------------------------------------------------\n// Internals\n// -----------------------------------------------------------------------------\n\n/** Path to the bundled devstack setup file. The preset injects this\n * via `test.setupFiles` when `opts.testSetup` is truthy. The literal\n * string is the module's import specifier so vitest resolves it like\n * any other npm package; an apps-level resolver finds it via the\n * package's `./vitest/setup` subpath (added to package.json\n * `exports` alongside the integration). */\nconst DEVSTACK_SETUP_MODULE = '@mysten-incubation/devstack/vitest/setup';\n\n/** Path to the bundled devstack `globalSetup` module. Injected into\n * `test.globalSetup` when `opts.autoBoot` is set — it boots a `test`\n * stack before the run and tears it down after. Resolved like any npm\n * package via the `./vitest/global-setup` subpath in package.json. */\nconst DEVSTACK_GLOBAL_SETUP_MODULE = '@mysten-incubation/devstack/vitest/global-setup';\n\n/** Runtime-root prefix the watcher MUST ignore — per architecture §\n * Invariants → \"No-restart on harmless changes\". The 500ms manifest\n * tick would otherwise re-trigger reloads. */\nconst WATCH_IGNORED_PATTERNS = ['**/.devstack/**', '**/node_modules/**', '**/dist/**'];\n\n// -----------------------------------------------------------------------------\n// Public surface\n// -----------------------------------------------------------------------------\n\n/**\n * Build the devstack-owned part of Vitest's `test` block. Apps keep a\n * normal `defineConfig(...)` call and compose this value into it:\n *\n * import { defineConfig } from 'vitest/config';\n * import { devstackVitestServerConfig, devstackVitestTestConfig }\n * from '@mysten-incubation/devstack/vitest';\n *\n * export default defineConfig({\n * server: devstackVitestServerConfig(),\n * test: devstackVitestTestConfig(),\n * });\n *\n * For chain-mode integration tests against a real devstack, build a\n * devstack handle and pass `handle.layer` to `@effect/vitest`'s\n * `it.layer(...)` directly — here the test file owns its lifecycle.\n * Alternatively, `autoBoot: true` wires the `global-setup.ts` boot seam\n * that boots a dedicated stack for the `*.e2e` run and tears it down\n * after (so `pnpm test:e2e` is self-contained); a plain call boots\n * nothing and just builds the `test` block below.\n *\n * For suites that need a shared StackContext fixture (manifest read\n * once per file), opt into the setup file:\n *\n * test: devstackVitestTestConfig({\n * testSetup: { requireDevstack: true },\n * })\n *\n * The setup file's `beforeAll` populates a captured fixture readable\n * via `getStackContext()` from inside `it`/`test` bodies.\n */\nexport const devstackVitestTestConfig = (\n\toptions: DevstackVitestTestConfigOptions = {},\n): NonNullable<ViteUserConfig['test']> => {\n\tconst setupFiles: Array<string> = [];\n\tif (options.testSetup) {\n\t\tsetupFiles.push(DEVSTACK_SETUP_MODULE);\n\t}\n\tif (options.setupFile !== undefined) {\n\t\tsetupFiles.push(options.setupFile);\n\t}\n\n\t// Vitest 4 removed `poolOptions.threads.singleThread`. Top-level\n\t// `fileParallelism: false` is the replacement for single-threaded\n\t// runs (also pins `maxWorkers` to 1 per vitest's docs). Both\n\t// branches set `pool: 'threads'` explicitly so we don't depend on\n\t// vitest's default pool (which is `forks` in v4).\n\tconst threadOverride =\n\t\toptions.threads === 'single'\n\t\t\t? { pool: 'threads' as const, fileParallelism: false }\n\t\t\t: options.threads === 'multi'\n\t\t\t\t? { pool: 'threads' as const, fileParallelism: true }\n\t\t\t\t: {};\n\n\tconst typecheckOverride = options.typecheck === true ? { typecheck: { enabled: true } } : {};\n\n\t// `autoBoot` marks the E2E (full-stack) config: it both wires the boot\n\t// `globalSetup` AND scopes the run to `*.e2e.{test,spec}` files. A plain\n\t// `devstackVitestTestConfig()` is the UNIT config — it runs the other\n\t// suites and EXCLUDES the `*.e2e` ones (which need a booted stack). So\n\t// `pnpm test` (unit) never boots Docker, and `pnpm test:e2e` runs only\n\t// the stack-requiring suites against a freshly-booted stack.\n\tconst isE2e = Boolean(options.autoBoot);\n\tconst autoBootOverride = isE2e ? { globalSetup: [DEVSTACK_GLOBAL_SETUP_MODULE] } : {};\n\n\tconst include = isE2e\n\t\t? ['src/**/*.e2e.{test,spec}.ts?(x)', 'test/**/*.e2e.{test,spec}.ts?(x)']\n\t\t: ['src/**/*.{test,spec}.ts?(x)', 'test/**/*.{test,spec}.ts?(x)'];\n\tconst exclude = [\n\t\t// `e2e/**` keeps Playwright's browser specs out of the vitest run.\n\t\t'e2e/**',\n\t\t'node_modules',\n\t\t'dist',\n\t\t'.turbo',\n\t\t'**/.devstack/**',\n\t\t// Unit runs skip the full-stack `*.e2e` vitest suites (they boot a\n\t\t// stack); the autoBoot config opts INTO them via `include` above.\n\t\t...(isE2e ? [] : ['**/*.e2e.{test,spec}.ts?(x)']),\n\t];\n\n\treturn {\n\t\tinclude,\n\t\texclude,\n\t\tpassWithNoTests: true,\n\t\t...(setupFiles.length > 0 ? { setupFiles } : {}),\n\t\t...threadOverride,\n\t\t...typecheckOverride,\n\t\t...autoBootOverride,\n\t\t// Caller overrides last. Shallow merge.\n\t\t...options.test,\n\t};\n};\n\n/** Build the devstack-owned part of Vitest's Vite server config.\n * Callers that need additional server options should merge them in\n * their own `defineConfig(...)` file. */\nexport const devstackVitestServerConfig = (): NonNullable<ViteUserConfig['server']> => ({\n\twatch: {\n\t\t// vite's chokidar watcher honors `ignored` even in test mode.\n\t\tignored: WATCH_IGNORED_PATTERNS,\n\t},\n});\n\n// -----------------------------------------------------------------------------\n// Test-visible internals (do not re-export from the integration barrel)\n// -----------------------------------------------------------------------------\n\n/** @internal — used by `test/build-integrations/vitest/config.test.ts`\n * to assert the watcher ignored set without depending on a built\n * config snapshot. */\nexport const _internal = {\n\tDEVSTACK_SETUP_MODULE,\n\tDEVSTACK_GLOBAL_SETUP_MODULE,\n\tWATCH_IGNORED_PATTERNS,\n} as const;\n"],"mappings":";;;;;;;AAoFA,MAAM,wBAAwB;;;;;AAM9B,MAAM,+BAA+B;;;;AAKrC,MAAM,yBAAyB;CAAC;CAAmB;CAAsB;AAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCrF,MAAa,4BACZ,UAA2C,CAAC,MACH;CACzC,MAAM,aAA4B,CAAC;CACnC,IAAI,QAAQ,WACX,WAAW,KAAK,qBAAqB;CAEtC,IAAI,QAAQ,cAAc,KAAA,GACzB,WAAW,KAAK,QAAQ,SAAS;CAQlC,MAAM,iBACL,QAAQ,YAAY,WACjB;EAAE,MAAM;EAAoB,iBAAiB;CAAM,IACnD,QAAQ,YAAY,UACnB;EAAE,MAAM;EAAoB,iBAAiB;CAAK,IAClD,CAAC;CAEN,MAAM,oBAAoB,QAAQ,cAAc,OAAO,EAAE,WAAW,EAAE,SAAS,KAAK,EAAE,IAAI,CAAC;CAQ3F,MAAM,QAAQ,QAAQ,QAAQ,QAAQ;CACtC,MAAM,mBAAmB,QAAQ,EAAE,aAAa,CAAC,4BAA4B,EAAE,IAAI,CAAC;CAiBpF,OAAO;EACN,SAhBe,QACb,CAAC,mCAAmC,kCAAkC,IACtE,CAAC,+BAA+B,8BAA8B;EAehE,SAAA;GAZA;GACA;GACA;GACA;GACA;GAGA,GAAI,QAAQ,CAAC,IAAI,CAAC,6BAA6B;EAKzC;EACN,iBAAiB;EACjB,GAAI,WAAW,SAAS,IAAI,EAAE,WAAW,IAAI,CAAC;EAC9C,GAAG;EACH,GAAG;EACH,GAAG;EAEH,GAAG,QAAQ;CACZ;AACD;;;;AAKA,MAAa,oCAA2E,EACvF,OAAO,EAEN,SAAS,uBACV,EACD"}
@@ -7,10 +7,7 @@ declare const VITEST_ENV_VARS: {
7
7
  readonly STACK: "DEVSTACK_STACK";
8
8
  /** Override for the runtime root that holds
9
9
  * `stacks/<stack>/manifest.json`. Defaults to `.devstack`. */
10
- readonly RUNTIME_ROOT: "DEVSTACK_RUNTIME_ROOT";
11
- /** Legacy alias for `RUNTIME_ROOT`. Accepted on read so the
12
- * rewrite can coexist with example apps that still set the
13
- * pre-rewrite name. New callers should use `RUNTIME_ROOT`. */
10
+ readonly RUNTIME_ROOT: "DEVSTACK_RUNTIME_ROOT"; /** Alias for `RUNTIME_ROOT`. New callers should use `RUNTIME_ROOT`. */
14
11
  readonly RUNTIME_ROOT_LEGACY: "DEVSTACK_STATE_DIR";
15
12
  /** Top-precedence absolute path to a specific manifest file. The
16
13
  * engine sets this when it spawns child processes; rarely set
@@ -23,8 +20,7 @@ type VitestEnvVarName = (typeof VITEST_ENV_VARS)[keyof typeof VITEST_ENV_VARS];
23
20
  * truth) — but tests should explicitly set `DEVSTACK_STACK=test`
24
21
  * rather than rely on this. */
25
22
  declare const DEFAULT_STACK_NAME = "main";
26
- /** Default runtime root when neither `DEVSTACK_RUNTIME_ROOT` nor the
27
- * legacy `DEVSTACK_STATE_DIR` is set. */
23
+ /** Default runtime root when no runtime-root override is set. */
28
24
  declare const DEFAULT_RUNTIME_ROOT = ".devstack";
29
25
  /** The recommended stack name for test runs — the value the
30
26
  * `test`-script env should set. Exported as a constant so example
@@ -40,10 +36,22 @@ interface ResolvedVitestEnv {
40
36
  * user runs `pnpm test` without the recommended wiring. */
41
37
  readonly stackWasExplicit: boolean;
42
38
  }
39
+ interface ResolveVitestEnvOptions {
40
+ /** Walk-up start for the package-name rung of the stack ladder,
41
+ * mirroring `resolveDiscoveryEnv` / the CLI's `resolveStackName`:
42
+ * when `DEVSTACK_STACK` is unset, the stack falls back to the
43
+ * nearest package.json `name` above `cwd` before `'main'`. Opt-in —
44
+ * omit it and the resolver stays fs-free with the bare
45
+ * env > `'main'` ladder. The setup hook threads it so the advisory
46
+ * names the stack `loadStackContext` will actually read. */
47
+ readonly cwd?: string;
48
+ }
43
49
  /** Resolve the vitest env contract from an arbitrary env bag.
44
- * Side-effect free — tests pass a fixture; production code passes
45
- * `process.env`. */
46
- declare const resolveVitestEnv: (env: Readonly<Record<string, string | undefined>>) => ResolvedVitestEnv;
50
+ * Side-effect free when `options.cwd` is omitted — tests pass a
51
+ * fixture; production code passes `process.env`. With `cwd`, the only
52
+ * fs access is the lazy package.json walk-up on the stack rung, and
53
+ * only when `DEVSTACK_STACK` is unset. */
54
+ declare const resolveVitestEnv: (env: Readonly<Record<string, string | undefined>>, options?: ResolveVitestEnvOptions) => ResolvedVitestEnv;
47
55
  //#endregion
48
- export { DEFAULT_RUNTIME_ROOT, DEFAULT_STACK_NAME, RECOMMENDED_TEST_STACK, ResolvedVitestEnv, VITEST_ENV_VARS, VitestEnvVarName, resolveVitestEnv };
56
+ export { DEFAULT_RUNTIME_ROOT, DEFAULT_STACK_NAME, RECOMMENDED_TEST_STACK, ResolveVitestEnvOptions, ResolvedVitestEnv, VITEST_ENV_VARS, VitestEnvVarName, resolveVitestEnv };
49
57
  //# sourceMappingURL=env.d.mts.map
@@ -1,3 +1,4 @@
1
+ import { inferPackageNameFromCwd } from "../../api/inference-network.mjs";
1
2
  import { DEFAULT_DISCOVERY_STACK } from "../runtime/resolve-discovery-env.mjs";
2
3
  //#region src/build-integrations/vitest/env.ts
3
4
  /** Env-var names the vitest integration consults. Centralized so
@@ -9,9 +10,7 @@ const VITEST_ENV_VARS = {
9
10
  /** Override for the runtime root that holds
10
11
  * `stacks/<stack>/manifest.json`. Defaults to `.devstack`. */
11
12
  RUNTIME_ROOT: "DEVSTACK_RUNTIME_ROOT",
12
- /** Legacy alias for `RUNTIME_ROOT`. Accepted on read so the
13
- * rewrite can coexist with example apps that still set the
14
- * pre-rewrite name. New callers should use `RUNTIME_ROOT`. */
13
+ /** Alias for `RUNTIME_ROOT`. New callers should use `RUNTIME_ROOT`. */
15
14
  RUNTIME_ROOT_LEGACY: "DEVSTACK_STATE_DIR",
16
15
  /** Top-precedence absolute path to a specific manifest file. The
17
16
  * engine sets this when it spawns child processes; rarely set
@@ -23,8 +22,7 @@ const VITEST_ENV_VARS = {
23
22
  * truth) — but tests should explicitly set `DEVSTACK_STACK=test`
24
23
  * rather than rely on this. */
25
24
  const DEFAULT_STACK_NAME = DEFAULT_DISCOVERY_STACK;
26
- /** Default runtime root when neither `DEVSTACK_RUNTIME_ROOT` nor the
27
- * legacy `DEVSTACK_STATE_DIR` is set. */
25
+ /** Default runtime root when no runtime-root override is set. */
28
26
  const DEFAULT_RUNTIME_ROOT = ".devstack";
29
27
  /** The recommended stack name for test runs — the value the
30
28
  * `test`-script env should set. Exported as a constant so example
@@ -32,18 +30,21 @@ const DEFAULT_RUNTIME_ROOT = ".devstack";
32
30
  * scaffolder lands. */
33
31
  const RECOMMENDED_TEST_STACK = "test";
34
32
  /** Resolve the vitest env contract from an arbitrary env bag.
35
- * Side-effect free — tests pass a fixture; production code passes
36
- * `process.env`. */
37
- const resolveVitestEnv = (env) => {
33
+ * Side-effect free when `options.cwd` is omitted — tests pass a
34
+ * fixture; production code passes `process.env`. With `cwd`, the only
35
+ * fs access is the lazy package.json walk-up on the stack rung, and
36
+ * only when `DEVSTACK_STACK` is unset. */
37
+ const resolveVitestEnv = (env, options = {}) => {
38
38
  const stackRaw = env[VITEST_ENV_VARS.STACK];
39
- const stack = stackRaw !== void 0 && stackRaw !== "" ? stackRaw : DEFAULT_STACK_NAME;
39
+ const stackWasExplicit = stackRaw !== void 0 && stackRaw !== "";
40
+ const stack = stackWasExplicit ? stackRaw : (options.cwd !== void 0 ? inferPackageNameFromCwd(options.cwd) : void 0) ?? DEFAULT_STACK_NAME;
40
41
  const runtimeRoot = env[VITEST_ENV_VARS.RUNTIME_ROOT] ?? env[VITEST_ENV_VARS.RUNTIME_ROOT_LEGACY] ?? ".devstack";
41
42
  const manifestPathOverride = env[VITEST_ENV_VARS.MANIFEST_PATH];
42
43
  return {
43
44
  stack,
44
45
  runtimeRoot: runtimeRoot === "" ? DEFAULT_RUNTIME_ROOT : runtimeRoot,
45
46
  manifestPathOverride: manifestPathOverride !== void 0 && manifestPathOverride !== "" ? manifestPathOverride : void 0,
46
- stackWasExplicit: stackRaw !== void 0 && stackRaw !== ""
47
+ stackWasExplicit
47
48
  };
48
49
  };
49
50
  //#endregion