@mysten-incubation/devstack 0.0.1 → 0.1.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 (838) hide show
  1. package/README.md +7 -3
  2. package/dashboard-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  3. package/dashboard-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  4. package/dashboard-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  5. package/dashboard-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  6. package/dashboard-ui/assets/geist-mono-cyrillic-ext-wght-normal-I4S5GZfc.woff2 +0 -0
  7. package/dashboard-ui/assets/geist-mono-cyrillic-wght-normal-BmXc_FBt.woff2 +0 -0
  8. package/dashboard-ui/assets/geist-mono-latin-ext-wght-normal-DrnZ1wKl.woff2 +0 -0
  9. package/dashboard-ui/assets/geist-mono-latin-wght-normal-B_7UjwxQ.woff2 +0 -0
  10. package/dashboard-ui/assets/geist-mono-symbols2-wght-normal-GZpp1pK2.woff2 +0 -0
  11. package/dashboard-ui/assets/geist-mono-vietnamese-wght-normal-D8KDMBhC.woff2 +0 -0
  12. package/dashboard-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  13. package/dashboard-ui/assets/index-Bmi1UtAg.js +1356 -0
  14. package/dashboard-ui/assets/index-D5EShVt4.js +3 -0
  15. package/dashboard-ui/assets/index-Deml9drg.css +1 -0
  16. package/dashboard-ui/index.html +13 -0
  17. package/dist/api/define-capabilities.d.mts +14 -3
  18. package/dist/api/define-capabilities.mjs +18 -1
  19. package/dist/api/define-capabilities.mjs.map +1 -1
  20. package/dist/api/define-devstack.d.mts +1 -1
  21. package/dist/api/define-devstack.mjs +6 -26
  22. package/dist/api/define-devstack.mjs.map +1 -1
  23. package/dist/api/define-plugin.d.mts +1 -0
  24. package/dist/api/define-plugin.mjs +2 -0
  25. package/dist/api/inference-network.d.mts +132 -0
  26. package/dist/api/inference-network.mjs +105 -16
  27. package/dist/api/inference-network.mjs.map +1 -1
  28. package/dist/api/plugin-errors.d.mts +7 -0
  29. package/dist/api/run-stack.d.mts +20 -9
  30. package/dist/api/run-stack.mjs +56 -29
  31. package/dist/api/run-stack.mjs.map +1 -1
  32. package/dist/build-integrations/playwright/config.d.mts +6 -4
  33. package/dist/build-integrations/playwright/config.mjs +5 -3
  34. package/dist/build-integrations/playwright/config.mjs.map +1 -1
  35. package/dist/build-integrations/playwright/errors.d.mts +1 -1
  36. package/dist/build-integrations/playwright/global-setup.d.mts +43 -17
  37. package/dist/build-integrations/playwright/global-setup.mjs +250 -13
  38. package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
  39. package/dist/build-integrations/playwright/index.d.mts +5 -3
  40. package/dist/build-integrations/playwright/index.mjs +4 -2
  41. package/dist/build-integrations/playwright/stack-context.d.mts +0 -1
  42. package/dist/build-integrations/playwright/stack-context.mjs +24 -63
  43. package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
  44. package/dist/build-integrations/playwright/wallet-context.d.mts +7 -10
  45. package/dist/build-integrations/playwright/wallet-context.mjs +8 -13
  46. package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
  47. package/dist/build-integrations/runtime/cold-start-url.d.mts +5 -0
  48. package/dist/build-integrations/runtime/cold-start-url.mjs +4 -3
  49. package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
  50. package/dist/build-integrations/runtime/conventional-routes.d.mts +51 -0
  51. package/dist/build-integrations/runtime/conventional-routes.mjs +92 -0
  52. package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -0
  53. package/dist/build-integrations/runtime/discover.d.mts +38 -30
  54. package/dist/build-integrations/runtime/discover.mjs +73 -70
  55. package/dist/build-integrations/runtime/discover.mjs.map +1 -1
  56. package/dist/build-integrations/runtime/endpoint-registry.d.mts +3 -1
  57. package/dist/build-integrations/runtime/endpoint-registry.mjs +3 -1
  58. package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
  59. package/dist/build-integrations/runtime/index.d.mts +7 -2
  60. package/dist/build-integrations/runtime/index.mjs +9 -2
  61. package/dist/build-integrations/runtime/manifest-types.d.mts +2 -0
  62. package/dist/build-integrations/runtime/manifest-types.mjs +3 -0
  63. package/dist/build-integrations/runtime/playwright-stack-context-slot.d.mts +29 -0
  64. package/dist/build-integrations/runtime/playwright-stack-context-slot.mjs +10 -0
  65. package/dist/build-integrations/runtime/playwright-stack-context-slot.mjs.map +1 -0
  66. package/dist/build-integrations/runtime/read-stack-context.d.mts +1 -1
  67. package/dist/build-integrations/runtime/read-stack-context.mjs +10 -4
  68. package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
  69. package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +48 -0
  70. package/dist/build-integrations/runtime/resolve-discovery-env.mjs +42 -0
  71. package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -0
  72. package/dist/build-integrations/runtime/stack-context.d.mts +1 -1
  73. package/dist/build-integrations/runtime/wallet-paths.mjs +2 -0
  74. package/dist/build-integrations/vite/index.d.mts +51 -0
  75. package/dist/build-integrations/vite/index.mjs +73 -0
  76. package/dist/build-integrations/vite/index.mjs.map +1 -0
  77. package/dist/build-integrations/vitest/env.d.mts +4 -3
  78. package/dist/build-integrations/vitest/env.mjs +6 -4
  79. package/dist/build-integrations/vitest/env.mjs.map +1 -1
  80. package/dist/build-integrations/vitest/errors.d.mts +25 -4
  81. package/dist/build-integrations/vitest/errors.mjs +15 -2
  82. package/dist/build-integrations/vitest/errors.mjs.map +1 -1
  83. package/dist/build-integrations/vitest/index.d.mts +2 -2
  84. package/dist/build-integrations/vitest/index.mjs +3 -3
  85. package/dist/build-integrations/vitest/setup.d.mts +4 -2
  86. package/dist/build-integrations/vitest/setup.mjs +2 -2
  87. package/dist/build-integrations/vitest/setup.mjs.map +1 -1
  88. package/dist/build-integrations/vitest/stack-context.d.mts +0 -1
  89. package/dist/build-integrations/vitest/stack-context.mjs +33 -13
  90. package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
  91. package/dist/cli/bail.mjs +23 -0
  92. package/dist/cli/bail.mjs.map +1 -0
  93. package/dist/{surfaces/cli/commands → cli}/doctor-probes.mjs +26 -16
  94. package/dist/cli/doctor-probes.mjs.map +1 -0
  95. package/dist/cli/main.d.mts +15 -1
  96. package/dist/cli/main.mjs +166 -482
  97. package/dist/cli/main.mjs.map +1 -1
  98. package/dist/cli/prune-direct.mjs +31 -201
  99. package/dist/cli/prune-direct.mjs.map +1 -1
  100. package/dist/cli/snapshot-reader.mjs +14 -11
  101. package/dist/cli/snapshot-reader.mjs.map +1 -1
  102. package/dist/cli/up-lifecycle.mjs +4 -1
  103. package/dist/cli/up-lifecycle.mjs.map +1 -1
  104. package/dist/cli/wirings/apply.mjs +95 -0
  105. package/dist/cli/wirings/apply.mjs.map +1 -0
  106. package/dist/cli/wirings/build-verb-layers.mjs +42 -0
  107. package/dist/cli/wirings/build-verb-layers.mjs.map +1 -0
  108. package/dist/cli/wirings/config-loader.mjs +69 -0
  109. package/dist/cli/wirings/config-loader.mjs.map +1 -0
  110. package/dist/cli/wirings/engine-command.mjs +30 -0
  111. package/dist/cli/wirings/engine-command.mjs.map +1 -0
  112. package/dist/cli/wirings/identity.mjs +72 -0
  113. package/dist/cli/wirings/identity.mjs.map +1 -0
  114. package/dist/cli/wirings/provide-file-system.mjs +7 -0
  115. package/dist/cli/wirings/provide-file-system.mjs.map +1 -0
  116. package/dist/cli/wirings/snapshot.mjs +177 -0
  117. package/dist/cli/wirings/snapshot.mjs.map +1 -0
  118. package/dist/cli/wirings/up.mjs +287 -0
  119. package/dist/cli/wirings/up.mjs.map +1 -0
  120. package/dist/cli/wirings/wipe.mjs +40 -0
  121. package/dist/cli/wirings/wipe.mjs.map +1 -0
  122. package/dist/contracts/capability-decl.d.mts +0 -2
  123. package/dist/contracts/codegenable.d.mts +43 -0
  124. package/dist/contracts/container-runtime.d.mts +26 -1
  125. package/dist/contracts/faucet-strategy.d.mts +25 -0
  126. package/dist/contracts/funding-strategy.d.mts +42 -0
  127. package/dist/contracts/plugin-expander.mjs +60 -0
  128. package/dist/contracts/plugin-expander.mjs.map +1 -0
  129. package/dist/contracts/projection.d.mts +5 -3
  130. package/dist/contracts/renderer.d.mts +23 -0
  131. package/dist/contracts/routable.d.mts +14 -1
  132. package/dist/contracts/snapshotable.d.mts +25 -3
  133. package/dist/contracts/wallet-protocol.d.mts +52 -0
  134. package/dist/contracts/wallet-protocol.mjs +52 -0
  135. package/dist/contracts/wallet-protocol.mjs.map +1 -0
  136. package/dist/index.d.mts +26 -25
  137. package/dist/index.mjs +20 -13
  138. package/dist/{runtime → orchestrators}/built-in-plugin-layers.mjs +10 -5
  139. package/dist/orchestrators/built-in-plugin-layers.mjs.map +1 -0
  140. package/dist/orchestrators/codegen/bindings.d.mts +1 -2
  141. package/dist/orchestrators/codegen/bindings.mjs +52 -186
  142. package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
  143. package/dist/orchestrators/codegen/emit.mjs +19 -1
  144. package/dist/orchestrators/codegen/emit.mjs.map +1 -1
  145. package/dist/orchestrators/codegen/errors.mjs +8 -3
  146. package/dist/orchestrators/codegen/errors.mjs.map +1 -1
  147. package/dist/orchestrators/codegen/format.mjs +47 -39
  148. package/dist/orchestrators/codegen/format.mjs.map +1 -1
  149. package/dist/orchestrators/codegen/gitignore.mjs +3 -1
  150. package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
  151. package/dist/orchestrators/codegen/output-location.mjs +40 -0
  152. package/dist/orchestrators/codegen/output-location.mjs.map +1 -0
  153. package/dist/orchestrators/codegen/paths.d.mts +1 -1
  154. package/dist/orchestrators/codegen/paths.mjs +40 -14
  155. package/dist/orchestrators/codegen/paths.mjs.map +1 -1
  156. package/dist/orchestrators/codegen/permissions.mjs +3 -1
  157. package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
  158. package/dist/orchestrators/codegen/service.mjs +157 -105
  159. package/dist/orchestrators/codegen/service.mjs.map +1 -1
  160. package/dist/orchestrators/lifecycle-prune/errors.mjs +31 -0
  161. package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -0
  162. package/dist/orchestrators/lifecycle-prune/index.mjs +350 -0
  163. package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -0
  164. package/dist/orchestrators/router/cleanup.mjs +26 -27
  165. package/dist/orchestrators/router/cleanup.mjs.map +1 -1
  166. package/dist/orchestrators/router/entrypoints.mjs +2 -2
  167. package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
  168. package/dist/orchestrators/router/file-provider.mjs +14 -5
  169. package/dist/orchestrators/router/file-provider.mjs.map +1 -1
  170. package/dist/orchestrators/router/hostname.mjs +19 -55
  171. package/dist/orchestrators/router/hostname.mjs.map +1 -1
  172. package/dist/orchestrators/router/index.mjs +11 -0
  173. package/dist/orchestrators/router/profile.mjs +2 -2
  174. package/dist/orchestrators/router/sentinels.mjs +26 -0
  175. package/dist/orchestrators/router/sentinels.mjs.map +1 -0
  176. package/dist/orchestrators/router/service.mjs +40 -37
  177. package/dist/orchestrators/router/service.mjs.map +1 -1
  178. package/dist/orchestrators/router/traefik-container.mjs +27 -16
  179. package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
  180. package/dist/{substrate/runtime → orchestrators}/run.mjs +26 -21
  181. package/dist/orchestrators/run.mjs.map +1 -0
  182. package/dist/orchestrators/runtime-composition.d.mts +1 -1
  183. package/dist/orchestrators/runtime-composition.mjs +123 -39
  184. package/dist/orchestrators/runtime-composition.mjs.map +1 -1
  185. package/dist/orchestrators/snapshot/capture-command.d.mts +1 -0
  186. package/dist/orchestrators/snapshot/capture-command.mjs +25 -0
  187. package/dist/orchestrators/snapshot/capture-command.mjs.map +1 -0
  188. package/dist/orchestrators/snapshot/capture.mjs +42 -28
  189. package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
  190. package/dist/orchestrators/snapshot/descriptor.mjs +35 -10
  191. package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
  192. package/dist/orchestrators/snapshot/identity-guard.mjs +1 -1
  193. package/dist/orchestrators/snapshot/index.mjs +13 -0
  194. package/dist/orchestrators/snapshot/integrity.d.mts +1 -1
  195. package/dist/orchestrators/snapshot/integrity.mjs +73 -17
  196. package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
  197. package/dist/orchestrators/snapshot/pending-marker.d.mts +1 -0
  198. package/dist/orchestrators/snapshot/pending-marker.mjs +99 -0
  199. package/dist/orchestrators/snapshot/pending-marker.mjs.map +1 -0
  200. package/dist/orchestrators/snapshot/phase-error.mjs +23 -0
  201. package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -0
  202. package/dist/orchestrators/snapshot/prune.mjs +20 -55
  203. package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
  204. package/dist/orchestrators/snapshot/recover-pending.d.mts +1 -0
  205. package/dist/orchestrators/snapshot/recover-pending.mjs +223 -0
  206. package/dist/orchestrators/snapshot/recover-pending.mjs.map +1 -0
  207. package/dist/orchestrators/snapshot/restore.mjs +118 -84
  208. package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
  209. package/dist/orchestrators/snapshot/service.mjs +53 -56
  210. package/dist/orchestrators/snapshot/service.mjs.map +1 -1
  211. package/dist/orchestrators/snapshot/state-document.d.mts +1 -0
  212. package/dist/orchestrators/snapshot/state-document.mjs +47 -7
  213. package/dist/orchestrators/snapshot/state-document.mjs.map +1 -1
  214. package/dist/orchestrators/snapshot/wipe.mjs +67 -10
  215. package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
  216. package/dist/plugins/account/codegen.mjs +9 -8
  217. package/dist/plugins/account/codegen.mjs.map +1 -1
  218. package/dist/plugins/account/errors.d.mts +33 -6
  219. package/dist/plugins/account/errors.mjs.map +1 -1
  220. package/dist/plugins/account/funding.d.mts +29 -19
  221. package/dist/plugins/account/funding.mjs +84 -66
  222. package/dist/plugins/account/funding.mjs.map +1 -1
  223. package/dist/plugins/account/index.d.mts +2 -4
  224. package/dist/plugins/account/index.mjs +64 -31
  225. package/dist/plugins/account/index.mjs.map +1 -1
  226. package/dist/plugins/account/keypair.mjs +6 -9
  227. package/dist/plugins/account/keypair.mjs.map +1 -1
  228. package/dist/plugins/account/lease.mjs +1 -0
  229. package/dist/plugins/account/lease.mjs.map +1 -1
  230. package/dist/plugins/account/registry.d.mts +14 -1
  231. package/dist/plugins/account/registry.mjs +18 -18
  232. package/dist/plugins/account/registry.mjs.map +1 -1
  233. package/dist/plugins/account/service.d.mts +23 -4
  234. package/dist/plugins/account/service.mjs +83 -45
  235. package/dist/plugins/account/service.mjs.map +1 -1
  236. package/dist/plugins/account/snapshot.mjs +2 -5
  237. package/dist/plugins/account/snapshot.mjs.map +1 -1
  238. package/dist/plugins/account/spans.mjs +16 -0
  239. package/dist/plugins/account/spans.mjs.map +1 -0
  240. package/dist/plugins/account/variants/keystore.mjs +6 -8
  241. package/dist/plugins/account/variants/keystore.mjs.map +1 -1
  242. package/dist/plugins/action/build-context.d.mts +3 -2
  243. package/dist/plugins/action/errors.d.mts +16 -12
  244. package/dist/plugins/action/errors.mjs.map +1 -1
  245. package/dist/plugins/action/execute.mjs +65 -103
  246. package/dist/plugins/action/execute.mjs.map +1 -1
  247. package/dist/plugins/action/index.d.mts +0 -2
  248. package/dist/plugins/action/index.mjs +17 -13
  249. package/dist/plugins/action/index.mjs.map +1 -1
  250. package/dist/plugins/action/service.mjs +38 -35
  251. package/dist/plugins/action/service.mjs.map +1 -1
  252. package/dist/plugins/action/spans.mjs +11 -0
  253. package/dist/plugins/action/spans.mjs.map +1 -0
  254. package/dist/plugins/coin/codegen.mjs +9 -8
  255. package/dist/plugins/coin/codegen.mjs.map +1 -1
  256. package/dist/plugins/coin/discovery.mjs +8 -4
  257. package/dist/plugins/coin/discovery.mjs.map +1 -1
  258. package/dist/plugins/coin/index.d.mts +11 -29
  259. package/dist/plugins/coin/index.mjs +56 -27
  260. package/dist/plugins/coin/index.mjs.map +1 -1
  261. package/dist/plugins/coin/metadata.mjs +8 -15
  262. package/dist/plugins/coin/metadata.mjs.map +1 -1
  263. package/dist/plugins/coin/mint.d.mts +30 -11
  264. package/dist/plugins/coin/mint.mjs +78 -74
  265. package/dist/plugins/coin/mint.mjs.map +1 -1
  266. package/dist/plugins/coin/registry.mjs +4 -7
  267. package/dist/plugins/coin/registry.mjs.map +1 -1
  268. package/dist/plugins/coin/service.d.mts +39 -1
  269. package/dist/plugins/coin/service.mjs +11 -4
  270. package/dist/plugins/coin/service.mjs.map +1 -1
  271. package/dist/plugins/coin/spans.mjs +20 -0
  272. package/dist/plugins/coin/spans.mjs.map +1 -0
  273. package/dist/plugins/dashboard/domain.mjs +402 -0
  274. package/dist/plugins/dashboard/domain.mjs.map +1 -0
  275. package/dist/plugins/dashboard/index.d.mts +29 -0
  276. package/dist/plugins/dashboard/index.mjs +91 -0
  277. package/dist/plugins/dashboard/index.mjs.map +1 -0
  278. package/dist/plugins/dashboard/origin-policy.mjs +36 -0
  279. package/dist/plugins/dashboard/origin-policy.mjs.map +1 -0
  280. package/dist/plugins/dashboard/routable.mjs +27 -0
  281. package/dist/plugins/dashboard/routable.mjs.map +1 -0
  282. package/dist/plugins/dashboard/schema/builder.mjs +21 -0
  283. package/dist/plugins/dashboard/schema/builder.mjs.map +1 -0
  284. package/dist/plugins/dashboard/schema/enums.mjs +72 -0
  285. package/dist/plugins/dashboard/schema/enums.mjs.map +1 -0
  286. package/dist/plugins/dashboard/schema/root.mjs +351 -0
  287. package/dist/plugins/dashboard/schema/root.mjs.map +1 -0
  288. package/dist/plugins/dashboard/schema/types.mjs +508 -0
  289. package/dist/plugins/dashboard/schema/types.mjs.map +1 -0
  290. package/dist/plugins/dashboard/schema.mjs +11 -0
  291. package/dist/plugins/dashboard/schema.mjs.map +1 -0
  292. package/dist/plugins/dashboard/server.mjs +166 -0
  293. package/dist/plugins/dashboard/server.mjs.map +1 -0
  294. package/dist/plugins/deepbook/deploy.mjs +53 -115
  295. package/dist/plugins/deepbook/deploy.mjs.map +1 -1
  296. package/dist/plugins/deepbook/errors.mjs +1 -0
  297. package/dist/plugins/deepbook/errors.mjs.map +1 -1
  298. package/dist/plugins/deepbook/faucet-strategy.mjs +47 -34
  299. package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
  300. package/dist/plugins/deepbook/hash.mjs +9 -0
  301. package/dist/plugins/deepbook/hash.mjs.map +1 -0
  302. package/dist/plugins/deepbook/index.d.mts +1 -10
  303. package/dist/plugins/deepbook/index.mjs +25 -22
  304. package/dist/plugins/deepbook/index.mjs.map +1 -1
  305. package/dist/plugins/deepbook/pyth/index.mjs +26 -55
  306. package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
  307. package/dist/plugins/deepbook/snapshot.mjs +17 -29
  308. package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
  309. package/dist/plugins/deepbook/spans.mjs +18 -0
  310. package/dist/plugins/deepbook/spans.mjs.map +1 -0
  311. package/dist/plugins/deepbook/type-strings.mjs +65 -0
  312. package/dist/plugins/deepbook/type-strings.mjs.map +1 -0
  313. package/dist/plugins/deepbook/types.d.mts +2 -3
  314. package/dist/plugins/deepbook/types.mjs.map +1 -1
  315. package/dist/plugins/faucet/dispatcher.d.mts +21 -2
  316. package/dist/plugins/faucet/dispatcher.mjs +1 -2
  317. package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
  318. package/dist/plugins/faucet/errors.d.mts +11 -24
  319. package/dist/plugins/faucet/errors.mjs.map +1 -1
  320. package/dist/plugins/faucet/http.mjs +33 -14
  321. package/dist/plugins/faucet/http.mjs.map +1 -1
  322. package/dist/plugins/faucet/index.d.mts +15 -5
  323. package/dist/plugins/faucet/index.mjs +3 -0
  324. package/dist/plugins/faucet/index.mjs.map +1 -1
  325. package/dist/plugins/faucet/spans.mjs +12 -0
  326. package/dist/plugins/faucet/spans.mjs.map +1 -0
  327. package/dist/plugins/host-service/errors.d.mts +1 -1
  328. package/dist/plugins/host-service/index.mjs +34 -8
  329. package/dist/plugins/host-service/index.mjs.map +1 -1
  330. package/dist/plugins/host-service/routable.mjs +2 -1
  331. package/dist/plugins/host-service/routable.mjs.map +1 -1
  332. package/dist/plugins/host-service/service.d.mts +21 -0
  333. package/dist/plugins/host-service/service.mjs +136 -81
  334. package/dist/plugins/host-service/service.mjs.map +1 -1
  335. package/dist/plugins/internal/acquire-on-chain-artifact.mjs +23 -0
  336. package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -0
  337. package/dist/plugins/internal/codegen-helpers.mjs +18 -0
  338. package/dist/plugins/internal/codegen-helpers.mjs.map +1 -0
  339. package/dist/plugins/internal/funding-failure-error.mjs +32 -0
  340. package/dist/plugins/internal/funding-failure-error.mjs.map +1 -0
  341. package/dist/plugins/package/build.mjs +1 -1
  342. package/dist/plugins/package/build.mjs.map +1 -1
  343. package/dist/plugins/package/codegen.mjs +26 -0
  344. package/dist/plugins/package/codegen.mjs.map +1 -1
  345. package/dist/plugins/package/errors.d.mts +16 -6
  346. package/dist/plugins/package/errors.mjs.map +1 -1
  347. package/dist/plugins/package/index.d.mts +0 -4
  348. package/dist/plugins/package/index.mjs +27 -21
  349. package/dist/plugins/package/index.mjs.map +1 -1
  350. package/dist/plugins/package/mode-known.mjs +26 -12
  351. package/dist/plugins/package/mode-known.mjs.map +1 -1
  352. package/dist/plugins/package/mode-local.mjs +47 -41
  353. package/dist/plugins/package/mode-local.mjs.map +1 -1
  354. package/dist/plugins/package/publish-executor.mjs +55 -114
  355. package/dist/plugins/package/publish-executor.mjs.map +1 -1
  356. package/dist/plugins/package/registry.mjs +2 -1
  357. package/dist/plugins/package/registry.mjs.map +1 -1
  358. package/dist/plugins/package/service.mjs.map +1 -1
  359. package/dist/plugins/package/spans.mjs +14 -0
  360. package/dist/plugins/package/spans.mjs.map +1 -0
  361. package/dist/plugins/postgres/db-ensure.mjs +19 -12
  362. package/dist/plugins/postgres/db-ensure.mjs.map +1 -1
  363. package/dist/plugins/postgres/errors.d.mts +5 -0
  364. package/dist/plugins/postgres/errors.mjs.map +1 -1
  365. package/dist/plugins/postgres/index.mjs +10 -17
  366. package/dist/plugins/postgres/index.mjs.map +1 -1
  367. package/dist/plugins/postgres/service.mjs +58 -24
  368. package/dist/plugins/postgres/service.mjs.map +1 -1
  369. package/dist/plugins/postgres/snapshot.mjs.map +1 -1
  370. package/dist/plugins/postgres/spans.mjs +11 -0
  371. package/dist/plugins/postgres/spans.mjs.map +1 -0
  372. package/dist/plugins/router-entrypoints.mjs +4 -4
  373. package/dist/plugins/router-entrypoints.mjs.map +1 -1
  374. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +15 -13
  375. package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
  376. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +15 -19
  377. package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
  378. package/dist/plugins/seal/codegen.d.mts +2 -3
  379. package/dist/plugins/seal/codegen.mjs.map +1 -1
  380. package/dist/plugins/seal/config-render.mjs +35 -8
  381. package/dist/plugins/seal/config-render.mjs.map +1 -1
  382. package/dist/plugins/seal/deploy.mjs +31 -39
  383. package/dist/plugins/seal/deploy.mjs.map +1 -1
  384. package/dist/plugins/seal/errors.d.mts +1 -3
  385. package/dist/plugins/seal/errors.mjs +7 -1
  386. package/dist/plugins/seal/errors.mjs.map +1 -1
  387. package/dist/plugins/seal/index.d.mts +1 -6
  388. package/dist/plugins/seal/index.mjs +40 -14
  389. package/dist/plugins/seal/index.mjs.map +1 -1
  390. package/dist/plugins/seal/key-manager.d.mts +1 -9
  391. package/dist/plugins/seal/key-manager.mjs +2 -18
  392. package/dist/plugins/seal/key-manager.mjs.map +1 -1
  393. package/dist/plugins/seal/key-server.mjs +37 -36
  394. package/dist/plugins/seal/key-server.mjs.map +1 -1
  395. package/dist/plugins/seal/keygen.mjs +16 -17
  396. package/dist/plugins/seal/keygen.mjs.map +1 -1
  397. package/dist/plugins/seal/mode/fork-known.mjs +36 -14
  398. package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
  399. package/dist/plugins/seal/mode/live.d.mts +6 -4
  400. package/dist/plugins/seal/mode/live.mjs +14 -21
  401. package/dist/plugins/seal/mode/live.mjs.map +1 -1
  402. package/dist/plugins/seal/mode/local-keygen.mjs +57 -21
  403. package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
  404. package/dist/plugins/seal/registry-publish.mjs +1 -0
  405. package/dist/plugins/seal/registry-publish.mjs.map +1 -1
  406. package/dist/plugins/seal/routable.mjs.map +1 -1
  407. package/dist/plugins/seal/service.mjs.map +1 -1
  408. package/dist/plugins/seal/spans.mjs +18 -0
  409. package/dist/plugins/seal/spans.mjs.map +1 -0
  410. package/dist/plugins/sui/auto-tick.mjs +17 -23
  411. package/dist/plugins/sui/auto-tick.mjs.map +1 -1
  412. package/dist/plugins/sui/chain-build-container.mjs +18 -0
  413. package/dist/plugins/sui/chain-build-container.mjs.map +1 -0
  414. package/dist/plugins/sui/chain-probe.d.mts +5 -5
  415. package/dist/plugins/sui/chain-probe.mjs +28 -58
  416. package/dist/plugins/sui/chain-probe.mjs.map +1 -1
  417. package/dist/plugins/sui/codegen.mjs +26 -0
  418. package/dist/plugins/sui/codegen.mjs.map +1 -1
  419. package/dist/plugins/sui/errors.d.mts +2 -29
  420. package/dist/plugins/sui/errors.mjs +1 -3
  421. package/dist/plugins/sui/errors.mjs.map +1 -1
  422. package/dist/plugins/sui/fork-faucet-strategy.d.mts +1 -0
  423. package/dist/plugins/sui/fork-faucet-strategy.mjs +55 -0
  424. package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -0
  425. package/dist/plugins/sui/fork-orchestration.d.mts +1 -0
  426. package/dist/plugins/sui/fork-orchestration.mjs +170 -2
  427. package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
  428. package/dist/plugins/sui/fork-transaction.d.mts +2 -0
  429. package/dist/plugins/sui/fork-transaction.mjs +92 -28
  430. package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
  431. package/dist/plugins/sui/index.d.mts +33 -70
  432. package/dist/plugins/sui/index.mjs +58 -35
  433. package/dist/plugins/sui/index.mjs.map +1 -1
  434. package/dist/plugins/{faucet/strategies/sui-local.mjs → sui/local-faucet-strategy.mjs} +10 -7
  435. package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -0
  436. package/dist/plugins/sui/mode/external.mjs +7 -13
  437. package/dist/plugins/sui/mode/external.mjs.map +1 -1
  438. package/dist/plugins/sui/mode/fork.mjs +136 -59
  439. package/dist/plugins/sui/mode/fork.mjs.map +1 -1
  440. package/dist/plugins/sui/mode/live.mjs +10 -16
  441. package/dist/plugins/sui/mode/live.mjs.map +1 -1
  442. package/dist/plugins/sui/mode/local.mjs +37 -36
  443. package/dist/plugins/sui/mode/local.mjs.map +1 -1
  444. package/dist/plugins/sui/mode/shared-boot.mjs +38 -115
  445. package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
  446. package/dist/plugins/sui/mode/shared.d.mts +1 -5
  447. package/dist/plugins/sui/mode/shared.mjs.map +1 -1
  448. package/dist/plugins/sui/mode/spec.d.mts +18 -0
  449. package/dist/plugins/sui/move-summary-runner.mjs +207 -0
  450. package/dist/plugins/sui/move-summary-runner.mjs.map +1 -0
  451. package/dist/plugins/sui/network-resolver.d.mts +4 -3
  452. package/dist/plugins/sui/service.mjs.map +1 -1
  453. package/dist/plugins/sui/snapshot.mjs +3 -0
  454. package/dist/plugins/sui/snapshot.mjs.map +1 -1
  455. package/dist/plugins/sui/spans.mjs +17 -0
  456. package/dist/plugins/sui/spans.mjs.map +1 -0
  457. package/dist/plugins/wallet/codegen.d.mts +0 -1
  458. package/dist/plugins/wallet/codegen.mjs +8 -9
  459. package/dist/plugins/wallet/codegen.mjs.map +1 -1
  460. package/dist/plugins/wallet/index.d.mts +6 -8
  461. package/dist/plugins/wallet/index.mjs +46 -35
  462. package/dist/plugins/wallet/index.mjs.map +1 -1
  463. package/dist/plugins/wallet/origin-policy.mjs +12 -28
  464. package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
  465. package/dist/plugins/wallet/pairing.mjs +6 -4
  466. package/dist/plugins/wallet/pairing.mjs.map +1 -1
  467. package/dist/plugins/wallet/protocol.d.mts +1 -0
  468. package/dist/plugins/wallet/protocol.mjs +5 -44
  469. package/dist/plugins/wallet/protocol.mjs.map +1 -1
  470. package/dist/plugins/wallet/routable.mjs +2 -8
  471. package/dist/plugins/wallet/routable.mjs.map +1 -1
  472. package/dist/plugins/wallet/server.mjs +36 -44
  473. package/dist/plugins/wallet/server.mjs.map +1 -1
  474. package/dist/plugins/wallet/service.d.mts +1 -5
  475. package/dist/plugins/wallet/service.mjs +22 -18
  476. package/dist/plugins/wallet/service.mjs.map +1 -1
  477. package/dist/plugins/wallet/spans.mjs +22 -0
  478. package/dist/plugins/wallet/spans.mjs.map +1 -0
  479. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +33 -8
  480. package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
  481. package/dist/plugins/walrus/codegen.d.mts +3 -3
  482. package/dist/plugins/walrus/codegen.mjs.map +1 -1
  483. package/dist/plugins/walrus/deploy-paths.mjs +21 -5
  484. package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
  485. package/dist/plugins/walrus/deploy.mjs +67 -69
  486. package/dist/plugins/walrus/deploy.mjs.map +1 -1
  487. package/dist/plugins/walrus/errors.mjs +1 -0
  488. package/dist/plugins/walrus/errors.mjs.map +1 -1
  489. package/dist/plugins/walrus/faucet-strategy.mjs +12 -7
  490. package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
  491. package/dist/plugins/walrus/index.d.mts +2 -13
  492. package/dist/plugins/walrus/index.mjs +18 -23
  493. package/dist/plugins/walrus/index.mjs.map +1 -1
  494. package/dist/plugins/walrus/mode/known-deploy.mjs +7 -5
  495. package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
  496. package/dist/plugins/walrus/mode/local-cluster.mjs +26 -7
  497. package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
  498. package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
  499. package/dist/plugins/walrus/routable.mjs +7 -23
  500. package/dist/plugins/walrus/routable.mjs.map +1 -1
  501. package/dist/plugins/walrus/service.mjs.map +1 -1
  502. package/dist/plugins/walrus/spans.mjs +18 -0
  503. package/dist/plugins/walrus/spans.mjs.map +1 -0
  504. package/dist/plugins/walrus/storage-nodes.d.mts +6 -2
  505. package/dist/plugins/walrus/storage-nodes.mjs +15 -8
  506. package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
  507. package/dist/plugins/walrus/wal-swap.mjs +58 -15
  508. package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
  509. package/dist/primitives/artifact-publisher.d.mts +1 -1
  510. package/dist/primitives/artifact-publisher.mjs +15 -0
  511. package/dist/primitives/artifact-publisher.mjs.map +1 -0
  512. package/dist/runtime/docker/client.mjs +17 -4
  513. package/dist/runtime/docker/client.mjs.map +1 -1
  514. package/dist/runtime/docker/container.mjs +219 -132
  515. package/dist/runtime/docker/container.mjs.map +1 -1
  516. package/dist/runtime/docker/errors.mjs +0 -6
  517. package/dist/runtime/docker/errors.mjs.map +1 -1
  518. package/dist/runtime/docker/exec.mjs +21 -18
  519. package/dist/runtime/docker/exec.mjs.map +1 -1
  520. package/dist/runtime/docker/image.mjs +36 -13
  521. package/dist/runtime/docker/image.mjs.map +1 -1
  522. package/dist/runtime/docker/index.mjs +14 -0
  523. package/dist/runtime/docker/inspect-and-decode.mjs +51 -0
  524. package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -0
  525. package/dist/runtime/docker/inventory.mjs +14 -11
  526. package/dist/runtime/docker/inventory.mjs.map +1 -1
  527. package/dist/runtime/docker/labels.mjs +38 -5
  528. package/dist/runtime/docker/labels.mjs.map +1 -1
  529. package/dist/runtime/docker/logs.d.mts +1 -1
  530. package/dist/runtime/docker/logs.mjs.map +1 -1
  531. package/dist/runtime/docker/network.mjs +83 -47
  532. package/dist/runtime/docker/network.mjs.map +1 -1
  533. package/dist/runtime/docker/render-run-args.mjs +82 -0
  534. package/dist/runtime/docker/render-run-args.mjs.map +1 -0
  535. package/dist/runtime/docker/service.d.mts +1 -1
  536. package/dist/runtime/docker/service.mjs +12 -7
  537. package/dist/runtime/docker/service.mjs.map +1 -1
  538. package/dist/runtime/docker/sweep.mjs +118 -43
  539. package/dist/runtime/docker/sweep.mjs.map +1 -1
  540. package/dist/runtime/docker/volume.mjs +2 -0
  541. package/dist/runtime/docker/volume.mjs.map +1 -1
  542. package/dist/runtime/docker/wrap.mjs +30 -1
  543. package/dist/runtime/docker/wrap.mjs.map +1 -1
  544. package/dist/substrate/cross-process.mjs +14 -8
  545. package/dist/substrate/cross-process.mjs.map +1 -1
  546. package/dist/substrate/event-time.mjs +33 -0
  547. package/dist/substrate/event-time.mjs.map +1 -0
  548. package/dist/substrate/events.d.mts +28 -8
  549. package/dist/substrate/identity.d.mts +2 -1
  550. package/dist/substrate/manifest.d.mts +68 -5
  551. package/dist/substrate/manifest.mjs +34 -5
  552. package/dist/substrate/manifest.mjs.map +1 -1
  553. package/dist/substrate/network.d.mts +3 -5
  554. package/dist/substrate/options.d.mts +0 -2
  555. package/dist/substrate/plugin.d.mts +13 -0
  556. package/dist/substrate/plugin.mjs +4 -2
  557. package/dist/substrate/plugin.mjs.map +1 -1
  558. package/dist/substrate/projection.d.mts +35 -3
  559. package/dist/substrate/runtime/artifact-publisher/index.mjs +19 -9
  560. package/dist/substrate/runtime/artifact-publisher/index.mjs.map +1 -1
  561. package/dist/substrate/runtime/atomic-write.mjs +97 -32
  562. package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
  563. package/dist/substrate/runtime/cache/index.mjs +3 -0
  564. package/dist/substrate/runtime/cache/schema.mjs +2 -2
  565. package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
  566. package/dist/substrate/runtime/cache/service.mjs +9 -7
  567. package/dist/substrate/runtime/cache/service.mjs.map +1 -1
  568. package/dist/substrate/runtime/capability-sinks/index.d.mts +1 -1
  569. package/dist/substrate/runtime/capability-sinks/index.mjs +3 -0
  570. package/dist/substrate/runtime/capability-sinks/layer.mjs +1 -1
  571. package/dist/substrate/runtime/capability-sinks/service.d.mts +61 -2
  572. package/dist/substrate/runtime/capability-sinks/service.mjs +21 -26
  573. package/dist/substrate/runtime/capability-sinks/service.mjs.map +1 -1
  574. package/dist/substrate/runtime/config-validation.d.mts +1 -13
  575. package/dist/substrate/runtime/config-validation.mjs +2 -91
  576. package/dist/substrate/runtime/config-validation.mjs.map +1 -1
  577. package/dist/substrate/runtime/container-runtime.d.mts +1 -0
  578. package/dist/substrate/runtime/container-runtime.mjs +2 -0
  579. package/dist/substrate/runtime/control-plane/domain.mjs +101 -0
  580. package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -0
  581. package/dist/substrate/runtime/control-plane/service.mjs +7 -0
  582. package/dist/substrate/runtime/control-plane/service.mjs.map +1 -0
  583. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +46 -19
  584. package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
  585. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs +30 -12
  586. package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
  587. package/dist/substrate/runtime/cross-process/command-channel/index.mjs +5 -0
  588. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs +11 -2
  589. package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
  590. package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs +1 -1
  591. package/dist/substrate/runtime/cross-process/index.mjs +11 -0
  592. package/dist/substrate/runtime/cross-process/live-clock.mjs +34 -0
  593. package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -0
  594. package/dist/substrate/runtime/cross-process/liveness.mjs +52 -10
  595. package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
  596. package/dist/substrate/runtime/cross-process/lock.d.mts +1 -0
  597. package/dist/substrate/runtime/cross-process/lock.mjs +23 -0
  598. package/dist/substrate/runtime/cross-process/lock.mjs.map +1 -0
  599. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +64 -0
  600. package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -0
  601. package/dist/substrate/runtime/cross-process/roster.mjs +97 -83
  602. package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
  603. package/dist/substrate/runtime/cross-process/self-pid.mjs +8 -0
  604. package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -0
  605. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +24 -28
  606. package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +1 -1
  607. package/dist/substrate/runtime/cross-process/stack-lock.mjs +41 -20
  608. package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
  609. package/dist/substrate/runtime/current-plugin.mjs +2 -2
  610. package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
  611. package/dist/substrate/runtime/errors.mjs +12 -6
  612. package/dist/substrate/runtime/errors.mjs.map +1 -1
  613. package/dist/substrate/runtime/format-unknown-error.mjs +30 -0
  614. package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -0
  615. package/dist/substrate/runtime/host-bind-mount-owner.mjs +10 -0
  616. package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -0
  617. package/dist/substrate/runtime/host-gateway.mjs +20 -0
  618. package/dist/substrate/runtime/host-gateway.mjs.map +1 -0
  619. package/dist/substrate/runtime/host-tree-tar/index.mjs +61 -50
  620. package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
  621. package/dist/substrate/runtime/http-probe.d.mts +1 -1
  622. package/dist/substrate/runtime/index.mjs +14 -0
  623. package/dist/substrate/runtime/lease-broker/index.d.mts +1 -1
  624. package/dist/substrate/runtime/lease-broker/index.mjs +2 -0
  625. package/dist/substrate/runtime/lease-broker/service.d.mts +1 -64
  626. package/dist/substrate/runtime/lease-broker/service.mjs +1 -1
  627. package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
  628. package/dist/substrate/runtime/lifecycle/dep-graph.mjs +22 -3
  629. package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
  630. package/dist/substrate/runtime/lifecycle/index.mjs +9 -0
  631. package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +1 -1
  632. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +20 -3
  633. package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
  634. package/dist/substrate/runtime/lifecycle/selective-restart.mjs +1 -1
  635. package/dist/substrate/runtime/lifecycle/signals.mjs +5 -5
  636. package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
  637. package/dist/substrate/runtime/lifecycle/state-machine.mjs +1 -1
  638. package/dist/substrate/runtime/managed-container.d.mts +19 -1
  639. package/dist/substrate/runtime/managed-container.mjs +20 -1
  640. package/dist/substrate/runtime/managed-container.mjs.map +1 -1
  641. package/dist/substrate/runtime/manifest/index.mjs +3 -0
  642. package/dist/substrate/runtime/manifest/manifest.mjs +15 -11
  643. package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
  644. package/dist/substrate/runtime/mode-errors.mjs +20 -0
  645. package/dist/substrate/runtime/mode-errors.mjs.map +1 -0
  646. package/dist/substrate/runtime/observability/cascade-formatter.mjs +9 -13
  647. package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
  648. package/dist/substrate/runtime/observability/formatter-registry.mjs +19 -36
  649. package/dist/substrate/runtime/observability/formatter-registry.mjs.map +1 -1
  650. package/dist/substrate/runtime/observability/ignore-with-log.d.mts +1 -0
  651. package/dist/substrate/runtime/observability/ignore-with-log.mjs +17 -0
  652. package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -0
  653. package/dist/substrate/runtime/observability/index.d.mts +1 -1
  654. package/dist/substrate/runtime/observability/index.mjs +13 -0
  655. package/dist/substrate/runtime/observability/log-store.d.mts +1 -0
  656. package/dist/substrate/runtime/observability/log-store.mjs +175 -0
  657. package/dist/substrate/runtime/observability/log-store.mjs.map +1 -0
  658. package/dist/substrate/runtime/observability/logger.d.mts +2 -1
  659. package/dist/substrate/runtime/observability/logger.mjs +5 -9
  660. package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
  661. package/dist/substrate/runtime/observability/output-truncate.mjs +35 -0
  662. package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -0
  663. package/dist/substrate/runtime/observability/pretty-error.mjs +9 -12
  664. package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
  665. package/dist/substrate/runtime/observability/redaction.d.mts +2 -13
  666. package/dist/substrate/runtime/observability/redaction.mjs +8 -14
  667. package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
  668. package/dist/substrate/runtime/observability/span-store.d.mts +1 -0
  669. package/dist/substrate/runtime/observability/span-store.mjs +110 -0
  670. package/dist/substrate/runtime/observability/span-store.mjs.map +1 -0
  671. package/dist/substrate/runtime/observability/spans.mjs +14 -14
  672. package/dist/substrate/runtime/observability/spans.mjs.map +1 -1
  673. package/dist/substrate/runtime/observability/subprocess-capture.mjs +1 -1
  674. package/dist/substrate/runtime/passthrough-or-wrap.mjs +33 -0
  675. package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -0
  676. package/dist/substrate/runtime/paths.d.mts +1 -1
  677. package/dist/substrate/runtime/paths.mjs +4 -3
  678. package/dist/substrate/runtime/paths.mjs.map +1 -1
  679. package/dist/substrate/runtime/phase-preserving-produce.mjs +40 -0
  680. package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -0
  681. package/dist/substrate/runtime/port-broker/index.mjs +3 -0
  682. package/dist/substrate/runtime/port-broker/service.mjs +170 -126
  683. package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
  684. package/dist/substrate/runtime/post-acquire-tasks.mjs +1 -1
  685. package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
  686. package/dist/substrate/runtime/probes.d.mts +7 -5
  687. package/dist/substrate/runtime/probes.mjs +3 -1
  688. package/dist/substrate/runtime/probes.mjs.map +1 -1
  689. package/dist/substrate/runtime/projection/index.mjs +4 -0
  690. package/dist/substrate/runtime/projection/operational-endpoints.mjs +1 -2
  691. package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
  692. package/dist/substrate/runtime/projection/persisted.mjs +33 -15
  693. package/dist/substrate/runtime/projection/persisted.mjs.map +1 -1
  694. package/dist/substrate/runtime/projection/state-ref.mjs +26 -2
  695. package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
  696. package/dist/substrate/runtime/projection/update.mjs +88 -24
  697. package/dist/substrate/runtime/projection/update.mjs.map +1 -1
  698. package/dist/substrate/runtime/random-suffix.mjs +11 -0
  699. package/dist/substrate/runtime/random-suffix.mjs.map +1 -0
  700. package/dist/substrate/runtime/retry-policy.d.mts +59 -1
  701. package/dist/substrate/runtime/retry-policy.mjs +66 -1
  702. package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
  703. package/dist/substrate/runtime/routed-url.d.mts +1 -0
  704. package/dist/substrate/runtime/routed-url.mjs +79 -0
  705. package/dist/substrate/runtime/routed-url.mjs.map +1 -0
  706. package/dist/substrate/runtime/runtime-decode.d.mts +1 -1
  707. package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
  708. package/dist/substrate/runtime/scoped-http-server.mjs +2 -3
  709. package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
  710. package/dist/substrate/runtime/scoped-multimap/index.mjs +2 -0
  711. package/dist/substrate/runtime/scoped-multimap/service.mjs +52 -0
  712. package/dist/substrate/runtime/scoped-multimap/service.mjs.map +1 -0
  713. package/dist/substrate/runtime/scoped-ref-map/index.mjs +2 -0
  714. package/dist/substrate/runtime/scoped-ref-map/service.mjs +2 -2
  715. package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +1 -1
  716. package/dist/substrate/runtime/stage-and-swap/index.mjs +72 -4
  717. package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
  718. package/dist/substrate/runtime/state-store/index.d.mts +1 -0
  719. package/dist/substrate/runtime/state-store/index.mjs +3 -0
  720. package/dist/substrate/runtime/state-store/schema.d.mts +1 -0
  721. package/dist/substrate/runtime/state-store/schema.mjs +19 -14
  722. package/dist/substrate/runtime/state-store/schema.mjs.map +1 -1
  723. package/dist/substrate/runtime/state-store/service.d.mts +1 -0
  724. package/dist/substrate/runtime/state-store/service.mjs +145 -0
  725. package/dist/substrate/runtime/state-store/service.mjs.map +1 -0
  726. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.d.mts +1 -0
  727. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs +33 -0
  728. package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -0
  729. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs +1 -1
  730. package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
  731. package/dist/substrate/runtime/strategy-registry/index.mjs +4 -0
  732. package/dist/substrate/runtime/strategy-registry/service.mjs +19 -33
  733. package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
  734. package/dist/substrate/runtime/subnet-broker.mjs +60 -0
  735. package/dist/substrate/runtime/subnet-broker.mjs.map +1 -0
  736. package/dist/substrate/runtime/sui-execute/index.d.mts +21 -1
  737. package/dist/substrate/runtime/sui-execute/index.mjs +84 -20
  738. package/dist/substrate/runtime/sui-execute/index.mjs.map +1 -1
  739. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.d.mts +1 -0
  740. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs +32 -0
  741. package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +1 -0
  742. package/dist/substrate/runtime/sui-ledger/object-ref.mjs +32 -0
  743. package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +1 -0
  744. package/dist/substrate/runtime/sui-move-build/index.mjs +93 -19
  745. package/dist/substrate/runtime/sui-move-build/index.mjs.map +1 -1
  746. package/dist/substrate/runtime/supervisor/acquire-node.mjs +181 -0
  747. package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -0
  748. package/dist/substrate/runtime/supervisor/background-tasks.mjs +144 -0
  749. package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -0
  750. package/dist/substrate/runtime/supervisor/command-loop.mjs +68 -0
  751. package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -0
  752. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +151 -0
  753. package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +1 -0
  754. package/dist/substrate/runtime/supervisor/errors.d.mts +1 -0
  755. package/dist/substrate/runtime/supervisor/errors.mjs +9 -0
  756. package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -0
  757. package/dist/substrate/runtime/supervisor/index.d.mts +1 -0
  758. package/dist/substrate/runtime/supervisor/index.mjs +3 -0
  759. package/dist/substrate/runtime/supervisor/shutdown.mjs +51 -0
  760. package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -0
  761. package/dist/substrate/runtime/supervisor/start-supervisor.d.mts +1 -0
  762. package/dist/substrate/runtime/supervisor/start-supervisor.mjs +250 -0
  763. package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -0
  764. package/dist/substrate/runtime/supervisor/state.d.mts +1 -0
  765. package/dist/substrate/runtime/supervisor/state.mjs +22 -0
  766. package/dist/substrate/runtime/supervisor/state.mjs.map +1 -0
  767. package/dist/substrate/runtime/supervisor/teardown.mjs +57 -0
  768. package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -0
  769. package/dist/substrate/runtime/supervisor/types.d.mts +1 -0
  770. package/dist/substrate/runtime/supervisor/wiring.mjs +133 -0
  771. package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -0
  772. package/dist/substrate/runtime/typed-env.mjs +8 -0
  773. package/dist/substrate/runtime/typed-env.mjs.map +1 -0
  774. package/dist/substrate/state-store.d.mts +1 -0
  775. package/dist/substrate/versioned-doc-schema.mjs +17 -0
  776. package/dist/substrate/versioned-doc-schema.mjs.map +1 -0
  777. package/dist/substrate/versioned-doc-sync.mjs +94 -0
  778. package/dist/substrate/versioned-doc-sync.mjs.map +1 -0
  779. package/dist/surfaces/cli/command-tree.mjs.map +1 -1
  780. package/dist/surfaces/cli/commands/index.mjs +9 -0
  781. package/dist/surfaces/cli/commands/prune-picker-entry.mjs +13 -0
  782. package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -0
  783. package/dist/surfaces/cli/commands/prune-picker.mjs +3 -2
  784. package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
  785. package/dist/surfaces/cli/commands/prune.mjs +34 -17
  786. package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
  787. package/dist/surfaces/cli/commands/status.mjs +2 -2
  788. package/dist/surfaces/cli/commands/status.mjs.map +1 -1
  789. package/dist/surfaces/cli/commands/supervisor-presence.mjs +5 -3
  790. package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
  791. package/dist/surfaces/cli/commands/wipe.mjs +38 -4
  792. package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
  793. package/dist/surfaces/cli/errors.mjs +1 -1
  794. package/dist/surfaces/cli/errors.mjs.map +1 -1
  795. package/dist/surfaces/cli/flags.mjs +0 -1
  796. package/dist/surfaces/cli/flags.mjs.map +1 -1
  797. package/dist/surfaces/cli/index.mjs +98 -18
  798. package/dist/surfaces/cli/index.mjs.map +1 -1
  799. package/dist/surfaces/cli/output.mjs +1 -0
  800. package/dist/surfaces/cli/output.mjs.map +1 -1
  801. package/dist/surfaces/cli/sysexits.mjs +2 -1
  802. package/dist/surfaces/cli/sysexits.mjs.map +1 -1
  803. package/dist/surfaces/tui/app.mjs +25 -3
  804. package/dist/surfaces/tui/app.mjs.map +1 -1
  805. package/dist/surfaces/tui/display-derivation.mjs +23 -74
  806. package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
  807. package/dist/surfaces/tui/event-log.mjs +35 -23
  808. package/dist/surfaces/tui/event-log.mjs.map +1 -1
  809. package/dist/surfaces/tui/input.mjs +5 -1
  810. package/dist/surfaces/tui/input.mjs.map +1 -1
  811. package/dist/surfaces/tui/plain-renderer.mjs +70 -34
  812. package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
  813. package/package.json +24 -4
  814. package/dist/contracts/liveness-classifier.d.mts +0 -19
  815. package/dist/contracts/network-resolver.d.mts +0 -15
  816. package/dist/contracts/network-resolver.mjs +0 -7
  817. package/dist/contracts/network-resolver.mjs.map +0 -1
  818. package/dist/orchestrators/codegen/extras.mjs +0 -16
  819. package/dist/orchestrators/codegen/extras.mjs.map +0 -1
  820. package/dist/plugins/deepbook/routable.mjs +0 -21
  821. package/dist/plugins/deepbook/routable.mjs.map +0 -1
  822. package/dist/plugins/faucet/service.d.mts +0 -20
  823. package/dist/plugins/faucet/strategies/sui-local.d.mts +0 -23
  824. package/dist/plugins/faucet/strategies/sui-local.mjs.map +0 -1
  825. package/dist/plugins/sui/seed-objects.d.mts +0 -18
  826. package/dist/plugins/sui/seed-objects.mjs +0 -25
  827. package/dist/plugins/sui/seed-objects.mjs.map +0 -1
  828. package/dist/runtime/built-in-plugin-layers.mjs.map +0 -1
  829. package/dist/substrate/runtime/context-helpers.mjs +0 -32
  830. package/dist/substrate/runtime/context-helpers.mjs.map +0 -1
  831. package/dist/substrate/runtime/run.mjs.map +0 -1
  832. package/dist/substrate/runtime/strategy-registry/faucet-capability-for.mjs +0 -30
  833. package/dist/substrate/runtime/strategy-registry/faucet-capability-for.mjs.map +0 -1
  834. package/dist/substrate/runtime/supervisor.d.mts +0 -1
  835. package/dist/substrate/runtime/supervisor.mjs +0 -831
  836. package/dist/substrate/runtime/supervisor.mjs.map +0 -1
  837. package/dist/surfaces/cli/commands/doctor-probes.mjs.map +0 -1
  838. /package/dist/{substrate/runtime/strategy-registry/faucet-capability-for.d.mts → plugins/faucet/http.d.mts} +0 -0
@@ -1,17 +1,14 @@
1
- import { capture } from "../../substrate/runtime/observability/subprocess-capture.mjs";
2
- import { ContainerRuntimeService } from "../../runtime/docker/service.mjs";
3
- import { shellQuote, suiCliImageBuildContext } from "../../substrate/runtime/sui-move-build/index.mjs";
4
1
  import { CodegenBindingsFailed } from "./errors.mjs";
5
2
  import { emitOne } from "./emit.mjs";
3
+ import "./permissions.mjs";
6
4
  import { Context, Effect, Layer } from "effect";
7
- import { basename, dirname, join, relative, sep } from "node:path";
8
- import { homedir, tmpdir } from "node:os";
9
- import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
10
- import { copyFile, mkdir, mkdtemp, readFile, readdir, rm } from "node:fs/promises";
5
+ import { join, relative, sep } from "node:path";
6
+ import { tmpdir } from "node:os";
7
+ import { mkdtemp, readFile, readdir, rm } from "node:fs/promises";
11
8
  import { generateFromPackageSummary } from "@mysten/codegen";
12
9
  //#region src/orchestrators/codegen/bindings.ts
13
- var MoveSummaryRunnerService = class extends Context.Service()("@devstack-rewrite/orchestrator/MoveSummaryRunner") {};
14
- var MoveCodegenService = class extends Context.Service()("@devstack-rewrite/orchestrator/MoveCodegen") {};
10
+ var MoveSummaryRunnerService = class extends Context.Service()("@devstack/orchestrator/MoveSummaryRunner") {};
11
+ var MoveCodegenService = class extends Context.Service()("@devstack/orchestrator/MoveCodegen") {};
15
12
  /**
16
13
  * Walk the `PackageBindings` set, filter to LOCAL packages
17
14
  * (`sourcePath !== null`), run `sui move summary` + `@mysten/codegen`
@@ -77,7 +74,8 @@ const emitBindings = (input) => Effect.gen(function* () {
77
74
  if ((yield* emitOne({
78
75
  path: abs,
79
76
  content: stabilizeGeneratedBindingContent(f.content),
80
- mode: 420
77
+ mode: 420,
78
+ parentMode: 493
81
79
  }).pipe(Effect.mapError((cause) => new CodegenBindingsFailed({
82
80
  package: pkg.name,
83
81
  sourcePath: pkg.sourcePath,
@@ -93,184 +91,16 @@ const emitBindings = (input) => Effect.gen(function* () {
93
91
  filesWritten
94
92
  };
95
93
  }).pipe(Effect.withSpan("codegen.emitBindings", { attributes: { "codegen.bindingsDir": input.bindingsDir } }));
96
- const layerDockerMoveSummaryRunner = Layer.effect(MoveSummaryRunnerService, Effect.gen(function* () {
97
- const runtime = yield* ContainerRuntimeService;
98
- return MoveSummaryRunnerService.of({ runSummary: (input) => runSummaryViaDocker(runtime, input) });
99
- }));
100
- Layer.effect(MoveSummaryRunnerService, Effect.gen(function* () {
101
- const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
102
- return MoveSummaryRunnerService.of({ runSummary: ({ packageName, sourcePath }) => Effect.gen(function* () {
103
- const scratchDir = yield* Effect.tryPromise({
104
- try: () => mkdtemp(join(tmpdir(), "devstack-move-summary-")),
105
- catch: (cause) => new CodegenBindingsFailed({
106
- package: packageName,
107
- sourcePath,
108
- reason: "summary-failed",
109
- hint: "Unable to create a temporary directory for Move summary output.",
110
- cause
111
- })
112
- });
113
- const summaryPath = join(scratchDir, "package");
114
- const cleanupScratch = Effect.promise(() => rm(scratchDir, {
115
- recursive: true,
116
- force: true
117
- })).pipe(Effect.ignore);
118
- return {
119
- packageName,
120
- sourcePath,
121
- summaryPath,
122
- cleanupPath: scratchDir,
123
- summaryJson: parseSummaryStdout((yield* Effect.gen(function* () {
124
- yield* Effect.tryPromise({
125
- try: async () => {
126
- await mkdir(summaryPath, { recursive: true });
127
- await copyFile(join(sourcePath, "Move.toml"), join(summaryPath, "Move.toml"));
128
- },
129
- catch: (cause) => new CodegenBindingsFailed({
130
- package: packageName,
131
- sourcePath,
132
- reason: "summary-failed",
133
- hint: "Unable to prepare a temporary Move summary package directory.",
134
- cause
135
- })
136
- });
137
- return yield* capture(spawner, ChildProcess.make("sui", [
138
- "move",
139
- "summary",
140
- "--path",
141
- ".",
142
- "--install-dir",
143
- join(scratchDir, "install"),
144
- "--output-directory",
145
- join(summaryPath, "package_summaries")
146
- ], { cwd: sourcePath }), {
147
- op: `sui move summary (${sourcePath})`,
148
- nonZeroIsFailure: true,
149
- stdoutTruncate: Infinity,
150
- stderrTruncate: 4e3
151
- }).pipe(Effect.mapError((cause) => new CodegenBindingsFailed({
152
- package: packageName,
153
- sourcePath,
154
- reason: "summary-failed",
155
- hint: "Install the Sui CLI and ensure this Move package can run `sui move summary`.",
156
- cause
157
- })));
158
- }).pipe(Effect.tapError(() => cleanupScratch))).stdout)
159
- };
160
- }) });
161
- }));
162
- const runSummaryViaDocker = (runtime, input) => Effect.scoped(Effect.gen(function* () {
163
- const scratchDir = yield* makeSummaryScratch(input);
164
- const summaryPath = join(scratchDir, "package");
165
- const cleanupScratch = Effect.promise(() => rm(scratchDir, {
166
- recursive: true,
167
- force: true
168
- })).pipe(Effect.ignore);
169
- const result = yield* Effect.gen(function* () {
170
- yield* prepareSummaryPackage(summaryPath, input);
171
- const image = input.buildImage ?? (yield* resolveDefaultSummaryImage(runtime, input));
172
- const moveHome = join(homedir(), ".move");
173
- yield* ensureMoveHome(moveHome, input);
174
- const packageRoot = dirname(input.sourcePath);
175
- const packageDir = basename(input.sourcePath);
176
- const command = [
177
- "set -e",
178
- `cleanup_summary() { status=\$?; chmod -R a+rwX /summary 2>/dev/null || true; chown -R ${typeof process.getuid === "function" ? process.getuid() : 0}:${typeof process.getgid === "function" ? process.getgid() : 0} /summary 2>/dev/null || true; exit "\$status"; }`,
179
- "trap cleanup_summary EXIT",
180
- "mkdir -p /summary/package_summaries",
181
- `sui move summary --path /workspace/${shellQuote(packageDir)} --install-dir /tmp/devstack-move-summary-install --output-directory /summary/package_summaries`
182
- ].join("; ");
183
- const run = yield* runtime.runOneShot({
184
- image,
185
- entrypoint: "sh",
186
- argv: ["-c", command],
187
- mounts: [
188
- {
189
- source: packageRoot,
190
- target: "/workspace"
191
- },
192
- {
193
- source: summaryPath,
194
- target: "/summary"
195
- },
196
- {
197
- source: moveHome,
198
- target: "/root/.move"
199
- }
200
- ],
201
- timeoutMillis: 5 * 6e4
202
- }).pipe(Effect.mapError((cause) => new CodegenBindingsFailed({
203
- package: input.packageName,
204
- sourcePath: input.sourcePath,
205
- reason: "summary-failed",
206
- hint: "Docker runtime failed while running `sui move summary` for bindings codegen.",
207
- cause
208
- })));
209
- if (run.exitCode !== 0) return yield* Effect.fail(new CodegenBindingsFailed({
210
- package: input.packageName,
211
- sourcePath: input.sourcePath,
212
- reason: "summary-failed",
213
- hint: `sui move summary exited ${run.exitCode}. stderr: ${run.stderr || "(empty)"}; stdout tail: ${run.stdout.slice(-400) || "(empty)"}`
214
- }));
215
- return run;
216
- }).pipe(Effect.tapError(() => cleanupScratch));
217
- return {
218
- packageName: input.packageName,
219
- sourcePath: input.sourcePath,
220
- summaryPath,
221
- cleanupPath: scratchDir,
222
- summaryJson: parseSummaryStdout(result.stdout)
223
- };
224
- }));
225
- const makeSummaryScratch = (input) => Effect.tryPromise({
226
- try: () => mkdtemp(join(tmpdir(), "devstack-move-summary-")),
227
- catch: (cause) => new CodegenBindingsFailed({
228
- package: input.packageName,
229
- sourcePath: input.sourcePath,
230
- reason: "summary-failed",
231
- hint: "Unable to create a temporary directory for Move summary output.",
232
- cause
233
- })
234
- });
235
- const prepareSummaryPackage = (summaryPath, input) => Effect.tryPromise({
236
- try: async () => {
237
- await mkdir(summaryPath, { recursive: true });
238
- await copyFile(join(input.sourcePath, "Move.toml"), join(summaryPath, "Move.toml"));
239
- },
240
- catch: (cause) => new CodegenBindingsFailed({
241
- package: input.packageName,
242
- sourcePath: input.sourcePath,
243
- reason: "summary-failed",
244
- hint: "Unable to prepare a temporary Move summary package directory.",
245
- cause
246
- })
247
- });
248
- const resolveDefaultSummaryImage = (runtime, input) => runtime.ensureImage(suiCliImageBuildContext()).pipe(Effect.mapError((cause) => new CodegenBindingsFailed({
249
- package: input.packageName,
250
- sourcePath: input.sourcePath,
251
- reason: "summary-failed",
252
- hint: "Unable to resolve the Sui CLI container image for Move bindings codegen.",
253
- cause
254
- })));
255
- const ensureMoveHome = (moveHome, input) => Effect.tryPromise({
256
- try: () => mkdir(moveHome, { recursive: true }),
257
- catch: (cause) => new CodegenBindingsFailed({
258
- package: input.packageName,
259
- sourcePath: input.sourcePath,
260
- reason: "summary-failed",
261
- hint: `Unable to create Move cache mount source "${moveHome}".`,
262
- cause
263
- })
264
- }).pipe(Effect.asVoid);
265
94
  const layerMystenMoveCodegen = Layer.succeed(MoveCodegenService, MoveCodegenService.of({ generate: (input) => Effect.tryPromise({
266
95
  try: async () => {
267
96
  const tmp = await mkdtemp(join(tmpdir(), "devstack-move-codegen-"));
268
97
  try {
98
+ const packageName = await resolveSummaryDirName(input.sourcePath) ?? input.packageName;
269
99
  await generateFromPackageSummary({
270
100
  package: {
271
101
  path: input.summary.summaryPath ?? input.sourcePath,
272
102
  package: input.mvrPlaceholder,
273
- packageName: input.packageName
103
+ packageName
274
104
  },
275
105
  prune: true,
276
106
  outputDir: tmp,
@@ -296,14 +126,50 @@ const layerMystenMoveCodegen = Layer.succeed(MoveCodegenService, MoveCodegenServ
296
126
  })
297
127
  }) }));
298
128
  const joinPath = (...parts) => parts.map((p, i) => i === 0 ? p.replace(/\/+$/, "") : p.replace(/^\/+|\/+$/g, "")).join("/");
299
- const parseSummaryStdout = (stdout) => {
300
- const trimmed = stdout.trim();
301
- if (trimmed.length === 0) return null;
129
+ /**
130
+ * Determine the `package_summaries/<dir>` subdirectory name for a local
131
+ * Move package from its REAL source `Move.toml`. `sui move summary` keys
132
+ * these subdirs by the NAMED ADDRESS (e.g. MoveStdlib → "std"), not the
133
+ * `[package].name`, so when the two differ we must hand `@mysten/codegen`
134
+ * the address label rather than the symbolic package name.
135
+ *
136
+ * Returns the single `[addresses]` label when the table has exactly one
137
+ * entry (the overwhelmingly common case — and a no-op when name == address),
138
+ * and `null` otherwise (unreadable Move.toml, no `[addresses]` table, or an
139
+ * ambiguous multi-address table) so the caller can fall back to the package
140
+ * name and preserve `@mysten/codegen`'s own resolution.
141
+ *
142
+ * Hand-parse rather than pull in a TOML dependency: the sibling Move-build
143
+ * path already harvests `{ local = "../x" }` deps from Move.toml by regex
144
+ * (`sui-move-build/index.ts`), and we only need the `[addresses]` section's
145
+ * left-hand labels — never their values.
146
+ */
147
+ const resolveSummaryDirName = async (sourcePath) => {
148
+ let toml;
302
149
  try {
303
- return JSON.parse(trimmed);
150
+ toml = await readFile(join(sourcePath, "Move.toml"), "utf8");
304
151
  } catch {
305
- return trimmed;
152
+ return null;
153
+ }
154
+ const labels = parseAddressLabels(toml);
155
+ return labels.length === 1 ? labels[0] : null;
156
+ };
157
+ /** Left-hand labels of the `[addresses]` table in a Move.toml. Scans from
158
+ * the `[addresses]` header to the next `[section]` header (or EOF) and
159
+ * collects each `name = "..."` key, ignoring blank/comment lines. */
160
+ const parseAddressLabels = (toml) => {
161
+ const lines = toml.split(/\r?\n/);
162
+ const start = lines.findIndex((line) => /^\s*\[addresses\]\s*$/.test(line));
163
+ if (start === -1) return [];
164
+ const labels = [];
165
+ for (const line of lines.slice(start + 1)) {
166
+ if (/^\s*\[/.test(line)) break;
167
+ const stripped = line.replace(/#.*$/, "").trim();
168
+ if (stripped === "") continue;
169
+ const match = /^([A-Za-z_][\w-]*)\s*=/.exec(stripped);
170
+ if (match) labels.push(match[1]);
306
171
  }
172
+ return labels;
307
173
  };
308
174
  const generatedBcsFactoryPattern = /export function ([A-Za-z_$][\w$]*)<((?:[^<>]|<[^<>]*>)+)>\((\.\.\.typeParameters: \[[\s\S]*?\n\])\) \{\n(\s*)return new (MoveStruct|MoveEnum|MoveTuple)\(/g;
309
175
  const bcsFactoryReturnType = (constructorName) => {
@@ -335,6 +201,6 @@ const collectGeneratedFiles = async (root) => {
335
201
  return out;
336
202
  };
337
203
  //#endregion
338
- export { MoveCodegenService, MoveSummaryRunnerService, emitBindings, layerDockerMoveSummaryRunner, layerMystenMoveCodegen };
204
+ export { MoveCodegenService, MoveSummaryRunnerService, emitBindings, layerMystenMoveCodegen };
339
205
 
340
206
  //# sourceMappingURL=bindings.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindings.mjs","names":[],"sources":["../../../src/orchestrators/codegen/bindings.ts"],"sourcesContent":["// Move-package bindings emission.\n//\n// Distilled-doc § \"Move-to-TS bindings: per-published-package typed\n// client modules produced from each local Move package's summary.\"\n// Calls `@mysten/codegen`'s `generateFromPackageSummary` against the\n// `sui move summary` JSON for each LOCAL package.\n//\n// sourcePath-known-vs-unknown discipline:\n// - `Package` plugin's `Codegenable` emits a `PackageBindings`\n// shape with `sourcePath: string | null`.\n// - The bindings emitter filters to `sourcePath !== null` (i.e.\n// LOCAL packages); `KnownPackage` entries (`sourcePath: null`)\n// are skipped — their bindings come from the SDK or MVR.\n//\n// Architecture seam:\n// - The production layer runs `sui move summary` through the\n// container runtime's Sui CLI image. Tests and embedders can\n// replace `MoveSummaryRunnerService` through normal Layer\n// composition; no harness-only path exists.\n// - The call to `@mysten/codegen.generateFromPackageSummary` is\n// similarly behind a tagged service so unit tests can stub it\n// without pulling in the heavyweight `@mysten/codegen` graph.\n//\n// Distilled-doc § \"Silent no-op from a downstream tool is a\n// failure\": after summary + render, we probe the output dir.\n// If it's empty, that's a `CodegenBindingsFailed` with a hint about\n// the common `Move.toml` `[addresses]` cause.\n\nimport { copyFile, mkdir, mkdtemp, readdir, readFile, rm } from 'node:fs/promises';\nimport { homedir, tmpdir } from 'node:os';\nimport { basename, dirname, join, relative, sep } from 'node:path';\n\nimport { generateFromPackageSummary } from '@mysten/codegen';\nimport { Context, Effect, FileSystem, Layer } from 'effect';\nimport { ChildProcess, ChildProcessSpawner } from 'effect/unstable/process';\n\nimport type { ContainerRuntime, ImageRef } from '../../contracts/container-runtime.ts';\nimport { ContainerRuntimeService } from '../../runtime/docker/service.ts';\nimport { capture } from '../../substrate/runtime/observability/subprocess-capture.ts';\nimport {\n\tshellQuote,\n\tsuiCliImageBuildContext,\n} from '../../substrate/runtime/sui-move-build/index.ts';\n\nimport { emitOne } from './emit.ts';\nimport { CodegenBindingsFailed } from './errors.ts';\nimport { NON_SENSITIVE_FILE_MODE } from './permissions.ts';\n\n// -----------------------------------------------------------------------------\n// Service seam — Move summary + codegen invocation\n// -----------------------------------------------------------------------------\n\n/** Result of `sui move summary` — opaque JSON the codegen generator\n * consumes. We don't decode it here; `@mysten/codegen` owns the\n * schema. */\nexport interface MoveSummary {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly summaryPath?: string;\n\treadonly cleanupPath?: string;\n\treadonly summaryJson: unknown;\n}\n\nexport interface MoveSummaryInput {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly buildImage?: ImageRef | null;\n}\n\n/** Shape of the Move summary runner. Implementations:\n * - `dockerMoveSummary` — the `ContainerRuntime.runOneShot` path.\n * - `hostMoveSummary` — the fallback host-binary path.\n * - `stubMoveSummary` — used in tests (returns a fixture). */\nexport interface MoveSummaryRunner {\n\treadonly runSummary: (\n\t\tinput: MoveSummaryInput,\n\t) => Effect.Effect<MoveSummary, CodegenBindingsFailed>;\n}\n\nexport class MoveSummaryRunnerService extends Context.Service<\n\tMoveSummaryRunnerService,\n\tMoveSummaryRunner\n>()('@devstack-rewrite/orchestrator/MoveSummaryRunner') {}\n\n/** Shape of the `@mysten/codegen` invocation. Returns the rendered\n * TS files (path → content) for one package. */\nexport interface MoveCodegen {\n\treadonly generate: (input: {\n\t\treadonly packageName: string;\n\t\treadonly sourcePath: string;\n\t\treadonly summary: MoveSummary;\n\t\treadonly mvrPlaceholder: string;\n\t\treadonly importExtension: '.ts' | '.js' | '';\n\t}) => Effect.Effect<\n\t\tReadonlyArray<{ readonly relPath: string; readonly content: string }>,\n\t\tCodegenBindingsFailed\n\t>;\n}\n\nexport class MoveCodegenService extends Context.Service<MoveCodegenService, MoveCodegen>()(\n\t'@devstack-rewrite/orchestrator/MoveCodegen',\n) {}\n\n// -----------------------------------------------------------------------------\n// Public entry — emit bindings for the local packages in a set of\n// PackageBindings contributions.\n// -----------------------------------------------------------------------------\n\nexport interface PackageBindings {\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly mvrPlaceholder: string;\n\treadonly sourcePath: string | null;\n\treadonly excluded: boolean;\n}\n\nexport interface EmitBindingsInput {\n\treadonly bindingsDir: string;\n\treadonly packages: ReadonlyArray<PackageBindings>;\n\treadonly importExtension?: '.ts' | '.js' | '';\n}\n\nexport interface EmitBindingsResult {\n\treadonly packagesEmitted: ReadonlyArray<string>;\n\treadonly packagesSkipped: ReadonlyArray<string>;\n\treadonly filesWritten: ReadonlyArray<string>;\n}\n\n/**\n * Walk the `PackageBindings` set, filter to LOCAL packages\n * (`sourcePath !== null`), run `sui move summary` + `@mysten/codegen`\n * for each, and write the rendered files into `bindingsDir/<name>/`.\n *\n * Serial within a cycle (distilled-doc § \"Serial within a cycle\":\n * shared Move build cache races). Per-package parallelism is unsafe.\n */\nexport const emitBindings = (\n\tinput: EmitBindingsInput,\n): Effect.Effect<\n\tEmitBindingsResult,\n\tCodegenBindingsFailed,\n\tFileSystem.FileSystem | MoveSummaryRunnerService | MoveCodegenService\n> =>\n\tEffect.gen(function* () {\n\t\tconst runner = yield* MoveSummaryRunnerService;\n\t\tconst generator = yield* MoveCodegenService;\n\t\tconst importExtension = input.importExtension ?? '.ts';\n\n\t\t// Dedup by package name. First-wins; distilled-doc § \"Duplicate\n\t\t// package names\": warn + skip the duplicate to avoid the HMR\n\t\t// re-emit storm.\n\t\tconst seen = new Set<string>();\n\t\tconst targets: Array<PackageBindings> = [];\n\t\tconst skipped: Array<string> = [];\n\t\tfor (const pkg of input.packages) {\n\t\t\tif (pkg.sourcePath === null) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (pkg.excluded) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (seen.has(pkg.name)) {\n\t\t\t\tyield* Effect.logWarning(\n\t\t\t\t\t`codegen.bindings: duplicate package name '${pkg.name}' — keeping ` +\n\t\t\t\t\t\t`first and skipping duplicate to avoid HMR re-emit storm. ` +\n\t\t\t\t\t\t`Rename one of the packages.`,\n\t\t\t\t);\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseen.add(pkg.name);\n\t\t\ttargets.push(pkg);\n\t\t}\n\t\t// Deterministic order: lexicographic by package name.\n\t\ttargets.sort((a, b) => a.name.localeCompare(b.name));\n\n\t\tconst emitted: Array<string> = [];\n\t\tconst filesWritten: Array<string> = [];\n\t\tfor (const pkg of targets) {\n\t\t\t// sourcePath is non-null per the filter above. Narrow.\n\t\t\tif (pkg.sourcePath === null) continue;\n\t\t\tconst summary = yield* runner.runSummary({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t});\n\t\t\tconst files = yield* generator.generate({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\tsummary,\n\t\t\t\tmvrPlaceholder: pkg.mvrPlaceholder,\n\t\t\t\timportExtension,\n\t\t\t});\n\t\t\t// Post-emit probe — silent no-op detection.\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\treason: 'no-output',\n\t\t\t\t\t\thint:\n\t\t\t\t\t\t\t'The Move codegen generator produced no files. This is ' +\n\t\t\t\t\t\t\t'usually caused by a missing `[addresses]` block in the ' +\n\t\t\t\t\t\t\t\"package's Move.toml, or a non-published address mapping.\",\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const f of files) {\n\t\t\t\tif (f.relPath.includes('..') || f.relPath.startsWith('/')) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\tcause: new Error(`generated binding path escapes output dir: ${f.relPath}`),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst abs = joinPath(input.bindingsDir, f.relPath);\n\t\t\t\tconst outcome = yield* emitOne({\n\t\t\t\t\tpath: abs,\n\t\t\t\t\tcontent: stabilizeGeneratedBindingContent(f.content),\n\t\t\t\t\tmode: NON_SENSITIVE_FILE_MODE,\n\t\t\t\t}).pipe(\n\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\t\tsourcePath: pkg.sourcePath!,\n\t\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (outcome.outcome !== 'unchanged') {\n\t\t\t\t\tfilesWritten.push(abs);\n\t\t\t\t}\n\t\t\t}\n\t\t\temitted.push(pkg.name);\n\t\t}\n\n\t\treturn {\n\t\t\tpackagesEmitted: emitted,\n\t\t\tpackagesSkipped: skipped,\n\t\t\tfilesWritten,\n\t\t};\n\t}).pipe(\n\t\tEffect.withSpan('codegen.emitBindings', {\n\t\t\tattributes: { 'codegen.bindingsDir': input.bindingsDir },\n\t\t}),\n\t);\n\n// -----------------------------------------------------------------------------\n// Stub implementations for tests\n// -----------------------------------------------------------------------------\n\n/** Stub runner — returns a synthetic summary. Used in unit tests\n * to exercise the bindings pipeline without a real `sui` binary. */\nexport const stubMoveSummaryRunner = (\n\tsummaryFor: (sourcePath: string) => MoveSummary,\n): MoveSummaryRunner => ({\n\trunSummary: ({ sourcePath }) => Effect.succeed(summaryFor(sourcePath)),\n});\n\n/** Stub generator — returns a synthetic file set. Used in unit\n * tests to exercise the bindings pipeline without pulling in the\n * heavyweight `@mysten/codegen` graph. */\nexport const stubMoveCodegen = (\n\tfiles: (\n\t\tinput: Parameters<MoveCodegen['generate']>[0],\n\t) => ReadonlyArray<{ readonly relPath: string; readonly content: string }>,\n): MoveCodegen => ({\n\tgenerate: (input) => Effect.succeed(files(input)),\n});\n\n// -----------------------------------------------------------------------------\n// Production implementations\n// -----------------------------------------------------------------------------\n\nexport const layerDockerMoveSummaryRunner: Layer.Layer<\n\tMoveSummaryRunnerService,\n\tnever,\n\tContainerRuntimeService\n> = Layer.effect(\n\tMoveSummaryRunnerService,\n\tEffect.gen(function* () {\n\t\tconst runtime: ContainerRuntime = yield* ContainerRuntimeService;\n\t\treturn MoveSummaryRunnerService.of({\n\t\t\trunSummary: (input) => runSummaryViaDocker(runtime, input),\n\t\t});\n\t}),\n);\n\nexport const layerHostMoveSummaryRunner: Layer.Layer<\n\tMoveSummaryRunnerService,\n\tnever,\n\tChildProcessSpawner.ChildProcessSpawner\n> = Layer.effect(\n\tMoveSummaryRunnerService,\n\tEffect.gen(function* () {\n\t\tconst spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n\t\treturn MoveSummaryRunnerService.of({\n\t\t\trunSummary: ({ packageName, sourcePath }) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst scratchDir = yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: () => mkdtemp(join(tmpdir(), 'devstack-move-summary-')),\n\t\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\tpackage: packageName,\n\t\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\t\treason: 'summary-failed',\n\t\t\t\t\t\t\t\thint: 'Unable to create a temporary directory for Move summary output.',\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\tconst summaryPath = join(scratchDir, 'package');\n\t\t\t\t\tconst cleanupScratch = Effect.promise(() =>\n\t\t\t\t\t\trm(scratchDir, { recursive: true, force: true }),\n\t\t\t\t\t).pipe(Effect.ignore);\n\t\t\t\t\tconst result = yield* Effect.gen(function* () {\n\t\t\t\t\t\tyield* Effect.tryPromise({\n\t\t\t\t\t\t\ttry: async () => {\n\t\t\t\t\t\t\t\tawait mkdir(summaryPath, { recursive: true });\n\t\t\t\t\t\t\t\tawait copyFile(join(sourcePath, 'Move.toml'), join(summaryPath, 'Move.toml'));\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\t\tpackage: packageName,\n\t\t\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\t\t\treason: 'summary-failed',\n\t\t\t\t\t\t\t\t\thint: 'Unable to prepare a temporary Move summary package directory.',\n\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst cmd = ChildProcess.make(\n\t\t\t\t\t\t\t'sui',\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'move',\n\t\t\t\t\t\t\t\t'summary',\n\t\t\t\t\t\t\t\t'--path',\n\t\t\t\t\t\t\t\t'.',\n\t\t\t\t\t\t\t\t'--install-dir',\n\t\t\t\t\t\t\t\tjoin(scratchDir, 'install'),\n\t\t\t\t\t\t\t\t'--output-directory',\n\t\t\t\t\t\t\t\tjoin(summaryPath, 'package_summaries'),\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t{ cwd: sourcePath },\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn yield* capture(spawner, cmd, {\n\t\t\t\t\t\t\top: `sui move summary (${sourcePath})`,\n\t\t\t\t\t\t\tnonZeroIsFailure: true,\n\t\t\t\t\t\t\tstdoutTruncate: Infinity,\n\t\t\t\t\t\t\tstderrTruncate: 4_000,\n\t\t\t\t\t\t}).pipe(\n\t\t\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\t\t\tpackage: packageName,\n\t\t\t\t\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\t\t\t\t\treason: 'summary-failed',\n\t\t\t\t\t\t\t\t\t\thint: 'Install the Sui CLI and ensure this Move package can run `sui move summary`.',\n\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}).pipe(Effect.tapError(() => cleanupScratch));\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\tsourcePath,\n\t\t\t\t\t\tsummaryPath,\n\t\t\t\t\t\tcleanupPath: scratchDir,\n\t\t\t\t\t\tsummaryJson: parseSummaryStdout(result.stdout),\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t});\n\t}),\n);\n\nconst runSummaryViaDocker = (\n\truntime: ContainerRuntime,\n\tinput: MoveSummaryInput,\n): Effect.Effect<MoveSummary, CodegenBindingsFailed> =>\n\tEffect.scoped(\n\t\tEffect.gen(function* () {\n\t\t\tconst scratchDir = yield* makeSummaryScratch(input);\n\t\t\tconst summaryPath = join(scratchDir, 'package');\n\t\t\tconst cleanupScratch = Effect.promise(() =>\n\t\t\t\trm(scratchDir, { recursive: true, force: true }),\n\t\t\t).pipe(Effect.ignore);\n\t\t\tconst result = yield* Effect.gen(function* () {\n\t\t\t\tyield* prepareSummaryPackage(summaryPath, input);\n\t\t\t\tconst image = input.buildImage ?? (yield* resolveDefaultSummaryImage(runtime, input));\n\t\t\t\tconst moveHome = join(homedir(), '.move');\n\t\t\t\tyield* ensureMoveHome(moveHome, input);\n\t\t\t\tconst packageRoot = dirname(input.sourcePath);\n\t\t\t\tconst packageDir = basename(input.sourcePath);\n\t\t\t\tconst hostUid = typeof process.getuid === 'function' ? process.getuid() : 0;\n\t\t\t\tconst hostGid = typeof process.getgid === 'function' ? process.getgid() : 0;\n\t\t\t\tconst command = [\n\t\t\t\t\t'set -e',\n\t\t\t\t\t'cleanup_summary() { status=$?; ' +\n\t\t\t\t\t\t'chmod -R a+rwX /summary 2>/dev/null || true; ' +\n\t\t\t\t\t\t`chown -R ${hostUid}:${hostGid} /summary 2>/dev/null || true; ` +\n\t\t\t\t\t\t'exit \"$status\"; }',\n\t\t\t\t\t'trap cleanup_summary EXIT',\n\t\t\t\t\t'mkdir -p /summary/package_summaries',\n\t\t\t\t\t`sui move summary --path /workspace/${shellQuote(packageDir)} ` +\n\t\t\t\t\t\t'--install-dir /tmp/devstack-move-summary-install ' +\n\t\t\t\t\t\t'--output-directory /summary/package_summaries',\n\t\t\t\t].join('; ');\n\t\t\t\tconst run = yield* runtime\n\t\t\t\t\t.runOneShot({\n\t\t\t\t\t\timage,\n\t\t\t\t\t\tentrypoint: 'sh',\n\t\t\t\t\t\targv: ['-c', command],\n\t\t\t\t\t\tmounts: [\n\t\t\t\t\t\t\t{ source: packageRoot, target: '/workspace' },\n\t\t\t\t\t\t\t{ source: summaryPath, target: '/summary' },\n\t\t\t\t\t\t\t{ source: moveHome, target: '/root/.move' },\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttimeoutMillis: 5 * 60_000,\n\t\t\t\t\t})\n\t\t\t\t\t.pipe(\n\t\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\t\tpackage: input.packageName,\n\t\t\t\t\t\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\t\t\t\t\t\treason: 'summary-failed',\n\t\t\t\t\t\t\t\t\thint: 'Docker runtime failed while running `sui move summary` for bindings codegen.',\n\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\tif (run.exitCode !== 0) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\tpackage: input.packageName,\n\t\t\t\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\t\t\t\treason: 'summary-failed',\n\t\t\t\t\t\t\thint:\n\t\t\t\t\t\t\t\t`sui move summary exited ${run.exitCode}. ` +\n\t\t\t\t\t\t\t\t`stderr: ${run.stderr || '(empty)'}; stdout tail: ${\n\t\t\t\t\t\t\t\t\trun.stdout.slice(-400) || '(empty)'\n\t\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn run;\n\t\t\t}).pipe(Effect.tapError(() => cleanupScratch));\n\t\t\treturn {\n\t\t\t\tpackageName: input.packageName,\n\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\tsummaryPath,\n\t\t\t\tcleanupPath: scratchDir,\n\t\t\t\tsummaryJson: parseSummaryStdout(result.stdout),\n\t\t\t};\n\t\t}),\n\t);\n\nconst makeSummaryScratch = (\n\tinput: MoveSummaryInput,\n): Effect.Effect<string, CodegenBindingsFailed> =>\n\tEffect.tryPromise({\n\t\ttry: () => mkdtemp(join(tmpdir(), 'devstack-move-summary-')),\n\t\tcatch: (cause) =>\n\t\t\tnew CodegenBindingsFailed({\n\t\t\t\tpackage: input.packageName,\n\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\treason: 'summary-failed',\n\t\t\t\thint: 'Unable to create a temporary directory for Move summary output.',\n\t\t\t\tcause,\n\t\t\t}),\n\t});\n\nconst prepareSummaryPackage = (\n\tsummaryPath: string,\n\tinput: MoveSummaryInput,\n): Effect.Effect<void, CodegenBindingsFailed> =>\n\tEffect.tryPromise({\n\t\ttry: async () => {\n\t\t\tawait mkdir(summaryPath, { recursive: true });\n\t\t\tawait copyFile(join(input.sourcePath, 'Move.toml'), join(summaryPath, 'Move.toml'));\n\t\t},\n\t\tcatch: (cause) =>\n\t\t\tnew CodegenBindingsFailed({\n\t\t\t\tpackage: input.packageName,\n\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\treason: 'summary-failed',\n\t\t\t\thint: 'Unable to prepare a temporary Move summary package directory.',\n\t\t\t\tcause,\n\t\t\t}),\n\t});\n\nconst resolveDefaultSummaryImage = (\n\truntime: ContainerRuntime,\n\tinput: MoveSummaryInput,\n): Effect.Effect<ImageRef, CodegenBindingsFailed> =>\n\truntime.ensureImage(suiCliImageBuildContext()).pipe(\n\t\tEffect.mapError(\n\t\t\t(cause) =>\n\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\tpackage: input.packageName,\n\t\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\t\treason: 'summary-failed',\n\t\t\t\t\thint: 'Unable to resolve the Sui CLI container image for Move bindings codegen.',\n\t\t\t\t\tcause,\n\t\t\t\t}),\n\t\t),\n\t);\n\nconst ensureMoveHome = (\n\tmoveHome: string,\n\tinput: MoveSummaryInput,\n): Effect.Effect<void, CodegenBindingsFailed> =>\n\tEffect.tryPromise({\n\t\ttry: () => mkdir(moveHome, { recursive: true }),\n\t\tcatch: (cause) =>\n\t\t\tnew CodegenBindingsFailed({\n\t\t\t\tpackage: input.packageName,\n\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\treason: 'summary-failed',\n\t\t\t\thint: `Unable to create Move cache mount source \"${moveHome}\".`,\n\t\t\t\tcause,\n\t\t\t}),\n\t}).pipe(Effect.asVoid);\n\nexport const layerMystenMoveCodegen: Layer.Layer<MoveCodegenService> = Layer.succeed(\n\tMoveCodegenService,\n\tMoveCodegenService.of({\n\t\tgenerate: (input) =>\n\t\t\tEffect.tryPromise({\n\t\t\t\ttry: async () => {\n\t\t\t\t\tconst tmp = await mkdtemp(join(tmpdir(), 'devstack-move-codegen-'));\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait generateFromPackageSummary({\n\t\t\t\t\t\t\tpackage: {\n\t\t\t\t\t\t\t\tpath: input.summary.summaryPath ?? input.sourcePath,\n\t\t\t\t\t\t\t\tpackage: input.mvrPlaceholder,\n\t\t\t\t\t\t\t\tpackageName: input.packageName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tprune: true,\n\t\t\t\t\t\t\toutputDir: tmp,\n\t\t\t\t\t\t\timportExtension: input.importExtension,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn await collectGeneratedFiles(tmp);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait rm(tmp, { recursive: true, force: true });\n\t\t\t\t\t\tif (input.summary.cleanupPath !== undefined) {\n\t\t\t\t\t\t\tawait rm(input.summary.cleanupPath, { recursive: true, force: true });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcatch: (cause) =>\n\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\tpackage: input.packageName,\n\t\t\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\t\t\treason: 'render-failed',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t}),\n\t}),\n);\n\n// -----------------------------------------------------------------------------\n// Local helpers — keep the module dep-free of Path.Path so the\n// caller can compose without an extra service yield.\n// -----------------------------------------------------------------------------\n\nconst joinPath = (...parts: ReadonlyArray<string>): string =>\n\tparts.map((p, i) => (i === 0 ? p.replace(/\\/+$/, '') : p.replace(/^\\/+|\\/+$/g, ''))).join('/');\n\nconst parseSummaryStdout = (stdout: string): unknown => {\n\tconst trimmed = stdout.trim();\n\tif (trimmed.length === 0) return null;\n\ttry {\n\t\treturn JSON.parse(trimmed) as unknown;\n\t} catch {\n\t\treturn trimmed;\n\t}\n};\n\nconst generatedBcsFactoryPattern =\n\t/export function ([A-Za-z_$][\\w$]*)<((?:[^<>]|<[^<>]*>)+)>\\((\\.\\.\\.typeParameters: \\[[\\s\\S]*?\\n\\])\\) \\{\\n(\\s*)return new (MoveStruct|MoveEnum|MoveTuple)\\(/g;\n\nconst bcsFactoryReturnType = (constructorName: string): string => {\n\tif (constructorName === 'MoveEnum') {\n\t\treturn 'MoveEnum<any, string>';\n\t}\n\tif (constructorName === 'MoveTuple') {\n\t\treturn 'MoveTuple<any, string>';\n\t}\n\treturn 'MoveStruct<any, string>';\n};\n\nconst stabilizeGeneratedBindingContent = (content: string): string =>\n\tcontent.replace(\n\t\tgeneratedBcsFactoryPattern,\n\t\t(_match, name, generics, parameters, indent, constructorName: string) =>\n\t\t\t`export function ${name}<${generics}>(${parameters}): ${bcsFactoryReturnType(\n\t\t\t\tconstructorName,\n\t\t\t)} {\\n${indent}return new ${constructorName}(`,\n\t);\n\nconst collectGeneratedFiles = async (\n\troot: string,\n): Promise<ReadonlyArray<{ readonly relPath: string; readonly content: string }>> => {\n\tconst out: Array<{ readonly relPath: string; readonly content: string }> = [];\n\tconst walk = async (dir: string): Promise<void> => {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst abs = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(abs);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!entry.isFile()) continue;\n\t\t\tconst relPath = relative(root, abs).split(sep).join('/');\n\t\t\tout.push({ relPath, content: await readFile(abs, 'utf8') });\n\t\t}\n\t};\n\tawait walk(root);\n\tout.sort((a, b) => a.relPath.localeCompare(b.relPath));\n\treturn out;\n};\n"],"mappings":";;;;;;;;;;;;AA+EA,IAAa,2BAAb,cAA8C,QAAQ,SAGnD,CAAC,mDAAmD,CAAC;AAiBxD,IAAa,qBAAb,cAAwC,QAAQ,SAA0C,CACzF,6CACA,CAAC;;;;;;;;;AAmCF,MAAa,gBACZ,UAMA,OAAO,IAAI,aAAa;CACvB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,kBAAkB,MAAM,mBAAmB;CAKjD,MAAM,uBAAO,IAAI,KAAa;CAC9B,MAAM,UAAkC,EAAE;CAC1C,MAAM,UAAyB,EAAE;AACjC,MAAK,MAAM,OAAO,MAAM,UAAU;AACjC,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esContent":["// Move-package bindings emission.\n//\n// Distilled-doc § \"Move-to-TS bindings: per-published-package typed\n// client modules produced from each local Move package's summary.\"\n// Drives `@mysten/codegen`'s `generateFromPackageSummary` against\n// `MoveSummary` JSON contributed by a plugin-owned\n// `MoveSummaryRunnerService`.\n//\n// sourcePath-known-vs-unknown discipline:\n// - `Package` plugin's `Codegenable` emits a `PackageBindings`\n// shape with `sourcePath: string | null`.\n// - The bindings emitter filters to `sourcePath !== null` (i.e.\n// LOCAL packages); `KnownPackage` entries (`sourcePath: null`)\n// are skipped — their bindings come from the SDK or MVR.\n//\n// Architecture seam:\n// - `MoveSummaryRunnerService` is contributed by a plugin (the\n// sui plugin ships `layerSuiMoveSummaryRunnerDocker` /\n// `layerSuiMoveSummaryRunnerHost`). The codegen orchestrator\n// consumes only the abstract service — it never names the Sui\n// CLI binary or container image (architecture: \"Orchestrator\n// boundaries — never names a service\").\n// - The call to `@mysten/codegen.generateFromPackageSummary` is\n// similarly behind a tagged service so unit tests can stub it\n// without pulling in the heavyweight `@mysten/codegen` graph.\n//\n// Distilled-doc § \"Silent no-op from a downstream tool is a\n// failure\": after summary + render, we probe the output dir.\n// If it's empty, that's a `CodegenBindingsFailed` with a hint about\n// the common `Move.toml` `[addresses]` cause.\n\nimport { mkdtemp, readdir, readFile, rm } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join, relative, sep } from 'node:path';\n\nimport { generateFromPackageSummary } from '@mysten/codegen';\nimport { Context, Effect, FileSystem, Layer } from 'effect';\n\nimport type { ImageRef } from '../../contracts/container-runtime.ts';\n\nimport { emitOne } from './emit.ts';\nimport { CodegenBindingsFailed } from './errors.ts';\nimport { NON_SENSITIVE_DIR_MODE, NON_SENSITIVE_FILE_MODE } from './permissions.ts';\n\n// -----------------------------------------------------------------------------\n// Service seam — Move summary + codegen invocation\n// -----------------------------------------------------------------------------\n\n/** Result of `sui move summary` — opaque JSON the codegen generator\n * consumes. We don't decode it here; `@mysten/codegen` owns the\n * schema. */\nexport interface MoveSummary {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly summaryPath?: string;\n\treadonly cleanupPath?: string;\n\treadonly summaryJson: unknown;\n}\n\nexport interface MoveSummaryInput {\n\treadonly packageName: string;\n\treadonly sourcePath: string;\n\treadonly buildImage?: ImageRef | null;\n}\n\n/** Shape of the Move summary runner. Implementations live in\n * plugin packages (e.g. `plugins/sui/move-summary-runner.ts`\n * exports `layerSuiMoveSummaryRunnerDocker` and\n * `layerSuiMoveSummaryRunnerHost`); tests use `stubMoveSummaryRunner`\n * below. */\nexport interface MoveSummaryRunner {\n\treadonly runSummary: (\n\t\tinput: MoveSummaryInput,\n\t) => Effect.Effect<MoveSummary, CodegenBindingsFailed>;\n}\n\nexport class MoveSummaryRunnerService extends Context.Service<\n\tMoveSummaryRunnerService,\n\tMoveSummaryRunner\n>()('@devstack/orchestrator/MoveSummaryRunner') {}\n\n/** Shape of the `@mysten/codegen` invocation. Returns the rendered\n * TS files (path → content) for one package. */\nexport interface MoveCodegen {\n\treadonly generate: (input: {\n\t\treadonly packageName: string;\n\t\treadonly sourcePath: string;\n\t\treadonly summary: MoveSummary;\n\t\treadonly mvrPlaceholder: string;\n\t\treadonly importExtension: '.ts' | '.js' | '';\n\t}) => Effect.Effect<\n\t\tReadonlyArray<{ readonly relPath: string; readonly content: string }>,\n\t\tCodegenBindingsFailed\n\t>;\n}\n\nexport class MoveCodegenService extends Context.Service<MoveCodegenService, MoveCodegen>()(\n\t'@devstack/orchestrator/MoveCodegen',\n) {}\n\n// -----------------------------------------------------------------------------\n// Public entry — emit bindings for the local packages in a set of\n// PackageBindings contributions.\n// -----------------------------------------------------------------------------\n\nexport interface PackageBindings {\n\treadonly name: string;\n\treadonly packageId: string;\n\treadonly mvrPlaceholder: string;\n\treadonly sourcePath: string | null;\n\treadonly excluded: boolean;\n}\n\nexport interface EmitBindingsInput {\n\treadonly bindingsDir: string;\n\treadonly packages: ReadonlyArray<PackageBindings>;\n\treadonly importExtension?: '.ts' | '.js' | '';\n}\n\nexport interface EmitBindingsResult {\n\treadonly packagesEmitted: ReadonlyArray<string>;\n\treadonly packagesSkipped: ReadonlyArray<string>;\n\treadonly filesWritten: ReadonlyArray<string>;\n}\n\n/**\n * Walk the `PackageBindings` set, filter to LOCAL packages\n * (`sourcePath !== null`), run `sui move summary` + `@mysten/codegen`\n * for each, and write the rendered files into `bindingsDir/<name>/`.\n *\n * Serial within a cycle (distilled-doc § \"Serial within a cycle\":\n * shared Move build cache races). Per-package parallelism is unsafe.\n */\nexport const emitBindings = (\n\tinput: EmitBindingsInput,\n): Effect.Effect<\n\tEmitBindingsResult,\n\tCodegenBindingsFailed,\n\tFileSystem.FileSystem | MoveSummaryRunnerService | MoveCodegenService\n> =>\n\tEffect.gen(function* () {\n\t\tconst runner = yield* MoveSummaryRunnerService;\n\t\tconst generator = yield* MoveCodegenService;\n\t\tconst importExtension = input.importExtension ?? '.ts';\n\n\t\t// Dedup by package name. First-wins; distilled-doc § \"Duplicate\n\t\t// package names\": warn + skip the duplicate to avoid the HMR\n\t\t// re-emit storm.\n\t\tconst seen = new Set<string>();\n\t\tconst targets: Array<PackageBindings> = [];\n\t\tconst skipped: Array<string> = [];\n\t\tfor (const pkg of input.packages) {\n\t\t\tif (pkg.sourcePath === null) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (pkg.excluded) {\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (seen.has(pkg.name)) {\n\t\t\t\tyield* Effect.logWarning(\n\t\t\t\t\t`codegen.bindings: duplicate package name '${pkg.name}' — keeping ` +\n\t\t\t\t\t\t`first and skipping duplicate to avoid HMR re-emit storm. ` +\n\t\t\t\t\t\t`Rename one of the packages.`,\n\t\t\t\t);\n\t\t\t\tskipped.push(pkg.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseen.add(pkg.name);\n\t\t\ttargets.push(pkg);\n\t\t}\n\t\t// Deterministic order: lexicographic by package name.\n\t\ttargets.sort((a, b) => a.name.localeCompare(b.name));\n\n\t\tconst emitted: Array<string> = [];\n\t\tconst filesWritten: Array<string> = [];\n\t\tfor (const pkg of targets) {\n\t\t\t// sourcePath is non-null per the filter above. Narrow.\n\t\t\tif (pkg.sourcePath === null) continue;\n\t\t\tconst summary = yield* runner.runSummary({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t});\n\t\t\tconst files = yield* generator.generate({\n\t\t\t\tpackageName: pkg.name,\n\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\tsummary,\n\t\t\t\tmvrPlaceholder: pkg.mvrPlaceholder,\n\t\t\t\timportExtension,\n\t\t\t});\n\t\t\t// Post-emit probe — silent no-op detection.\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\treason: 'no-output',\n\t\t\t\t\t\thint:\n\t\t\t\t\t\t\t'The Move codegen generator produced no files. This is ' +\n\t\t\t\t\t\t\t'usually caused by a missing `[addresses]` block in the ' +\n\t\t\t\t\t\t\t\"package's Move.toml, or a non-published address mapping.\",\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const f of files) {\n\t\t\t\tif (f.relPath.includes('..') || f.relPath.startsWith('/')) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\tsourcePath: pkg.sourcePath,\n\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\tcause: new Error(`generated binding path escapes output dir: ${f.relPath}`),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst abs = joinPath(input.bindingsDir, f.relPath);\n\t\t\t\tconst outcome = yield* emitOne({\n\t\t\t\t\tpath: abs,\n\t\t\t\t\tcontent: stabilizeGeneratedBindingContent(f.content),\n\t\t\t\t\tmode: NON_SENSITIVE_FILE_MODE,\n\t\t\t\t\tparentMode: NON_SENSITIVE_DIR_MODE,\n\t\t\t\t}).pipe(\n\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\t\t\tpackage: pkg.name,\n\t\t\t\t\t\t\t\tsourcePath: pkg.sourcePath!,\n\t\t\t\t\t\t\t\treason: 'write-failed',\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tif (outcome.outcome !== 'unchanged') {\n\t\t\t\t\tfilesWritten.push(abs);\n\t\t\t\t}\n\t\t\t}\n\t\t\temitted.push(pkg.name);\n\t\t}\n\n\t\treturn {\n\t\t\tpackagesEmitted: emitted,\n\t\t\tpackagesSkipped: skipped,\n\t\t\tfilesWritten,\n\t\t};\n\t}).pipe(\n\t\tEffect.withSpan('codegen.emitBindings', {\n\t\t\tattributes: { 'codegen.bindingsDir': input.bindingsDir },\n\t\t}),\n\t);\n\n// -----------------------------------------------------------------------------\n// Stub implementations for tests\n// -----------------------------------------------------------------------------\n\n/** Stub runner — returns a synthetic summary. Used in unit tests\n * to exercise the bindings pipeline without a real `sui` binary. */\nexport const stubMoveSummaryRunner = (\n\tsummaryFor: (sourcePath: string) => MoveSummary,\n): MoveSummaryRunner => ({\n\trunSummary: ({ sourcePath }) => Effect.succeed(summaryFor(sourcePath)),\n});\n\n/** Stub generator — returns a synthetic file set. Used in unit\n * tests to exercise the bindings pipeline without pulling in the\n * heavyweight `@mysten/codegen` graph. */\nexport const stubMoveCodegen = (\n\tfiles: (\n\t\tinput: Parameters<MoveCodegen['generate']>[0],\n\t) => ReadonlyArray<{ readonly relPath: string; readonly content: string }>,\n): MoveCodegen => ({\n\tgenerate: (input) => Effect.succeed(files(input)),\n});\n\n// -----------------------------------------------------------------------------\n// Production implementations\n// -----------------------------------------------------------------------------\n//\n// Layer factories for `MoveSummaryRunnerService` are plugin-owned —\n// they live in `src/plugins/sui/move-summary-runner.ts`. The codegen\n// orchestrator does not name the Sui CLI binary or container image;\n// per \"Orchestrator boundaries — never names a service\", any plugin\n// that can produce `MoveSummary` JSON may contribute a runner Layer.\n\nexport const layerMystenMoveCodegen: Layer.Layer<MoveCodegenService> = Layer.succeed(\n\tMoveCodegenService,\n\tMoveCodegenService.of({\n\t\tgenerate: (input) =>\n\t\t\tEffect.tryPromise({\n\t\t\t\ttry: async () => {\n\t\t\t\t\tconst tmp = await mkdtemp(join(tmpdir(), 'devstack-move-codegen-'));\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// `sui move summary` keys each `package_summaries/<dir>`\n\t\t\t\t\t\t// subdirectory by the package's NAMED ADDRESS, not its\n\t\t\t\t\t\t// `[package].name`. These legitimately differ (the canonical\n\t\t\t\t\t\t// example is MoveStdlib, whose package name is \"MoveStdlib\"\n\t\t\t\t\t\t// but whose named address is \"std\"). `@mysten/codegen`'s\n\t\t\t\t\t\t// resolver matches the summary subdir by either (1) a single\n\t\t\t\t\t\t// `[addresses]` label or (2) the `packageName` — but it reads\n\t\t\t\t\t\t// the Move.toml at the path WE pass it (the summary scratch\n\t\t\t\t\t\t// dir), which has NO `[addresses]` table, so its label-based\n\t\t\t\t\t\t// path (1) is defeated and it falls back to (2). We pass the\n\t\t\t\t\t\t// symbolic localPackage() NAME as `packageName`, which is the\n\t\t\t\t\t\t// `[package].name`, NOT the named address — so codegen throws\n\t\t\t\t\t\t// \"Could not identify main package directory\" whenever the two\n\t\t\t\t\t\t// differ. Recover the correct subdir name here from the REAL\n\t\t\t\t\t\t// source Move.toml's `[addresses]` table (which devstack still\n\t\t\t\t\t\t// has at `input.sourcePath`), falling back to the name when the\n\t\t\t\t\t\t// source is unreadable or ambiguous (a no-op for the common\n\t\t\t\t\t\t// case where name == address).\n\t\t\t\t\t\tconst packageName =\n\t\t\t\t\t\t\t(await resolveSummaryDirName(input.sourcePath)) ?? input.packageName;\n\t\t\t\t\t\tawait generateFromPackageSummary({\n\t\t\t\t\t\t\tpackage: {\n\t\t\t\t\t\t\t\tpath: input.summary.summaryPath ?? input.sourcePath,\n\t\t\t\t\t\t\t\tpackage: input.mvrPlaceholder,\n\t\t\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tprune: true,\n\t\t\t\t\t\t\toutputDir: tmp,\n\t\t\t\t\t\t\timportExtension: input.importExtension,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn await collectGeneratedFiles(tmp);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tawait rm(tmp, { recursive: true, force: true });\n\t\t\t\t\t\tif (input.summary.cleanupPath !== undefined) {\n\t\t\t\t\t\t\tawait rm(input.summary.cleanupPath, { recursive: true, force: true });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcatch: (cause) =>\n\t\t\t\t\tnew CodegenBindingsFailed({\n\t\t\t\t\t\tpackage: input.packageName,\n\t\t\t\t\t\tsourcePath: input.sourcePath,\n\t\t\t\t\t\treason: 'render-failed',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t}),\n\t}),\n);\n\n// -----------------------------------------------------------------------------\n// Local helpers — keep the module dep-free of Path.Path so the\n// caller can compose without an extra service yield.\n// -----------------------------------------------------------------------------\n\nconst joinPath = (...parts: ReadonlyArray<string>): string =>\n\tparts.map((p, i) => (i === 0 ? p.replace(/\\/+$/, '') : p.replace(/^\\/+|\\/+$/g, ''))).join('/');\n\n/**\n * Determine the `package_summaries/<dir>` subdirectory name for a local\n * Move package from its REAL source `Move.toml`. `sui move summary` keys\n * these subdirs by the NAMED ADDRESS (e.g. MoveStdlib → \"std\"), not the\n * `[package].name`, so when the two differ we must hand `@mysten/codegen`\n * the address label rather than the symbolic package name.\n *\n * Returns the single `[addresses]` label when the table has exactly one\n * entry (the overwhelmingly common case — and a no-op when name == address),\n * and `null` otherwise (unreadable Move.toml, no `[addresses]` table, or an\n * ambiguous multi-address table) so the caller can fall back to the package\n * name and preserve `@mysten/codegen`'s own resolution.\n *\n * Hand-parse rather than pull in a TOML dependency: the sibling Move-build\n * path already harvests `{ local = \"../x\" }` deps from Move.toml by regex\n * (`sui-move-build/index.ts`), and we only need the `[addresses]` section's\n * left-hand labels — never their values.\n */\nconst resolveSummaryDirName = async (sourcePath: string): Promise<string | null> => {\n\tlet toml: string;\n\ttry {\n\t\ttoml = await readFile(join(sourcePath, 'Move.toml'), 'utf8');\n\t} catch {\n\t\treturn null;\n\t}\n\tconst labels = parseAddressLabels(toml);\n\treturn labels.length === 1 ? labels[0]! : null;\n};\n\n/** Left-hand labels of the `[addresses]` table in a Move.toml. Scans from\n * the `[addresses]` header to the next `[section]` header (or EOF) and\n * collects each `name = \"...\"` key, ignoring blank/comment lines. */\nconst parseAddressLabels = (toml: string): ReadonlyArray<string> => {\n\tconst lines = toml.split(/\\r?\\n/);\n\tconst start = lines.findIndex((line) => /^\\s*\\[addresses\\]\\s*$/.test(line));\n\tif (start === -1) return [];\n\tconst labels: Array<string> = [];\n\tfor (const line of lines.slice(start + 1)) {\n\t\t// Next table header ends the `[addresses]` section.\n\t\tif (/^\\s*\\[/.test(line)) break;\n\t\tconst stripped = line.replace(/#.*$/, '').trim();\n\t\tif (stripped === '') continue;\n\t\tconst match = /^([A-Za-z_][\\w-]*)\\s*=/.exec(stripped);\n\t\tif (match) labels.push(match[1]!);\n\t}\n\treturn labels;\n};\n\nconst generatedBcsFactoryPattern =\n\t/export function ([A-Za-z_$][\\w$]*)<((?:[^<>]|<[^<>]*>)+)>\\((\\.\\.\\.typeParameters: \\[[\\s\\S]*?\\n\\])\\) \\{\\n(\\s*)return new (MoveStruct|MoveEnum|MoveTuple)\\(/g;\n\nconst bcsFactoryReturnType = (constructorName: string): string => {\n\tif (constructorName === 'MoveEnum') {\n\t\treturn 'MoveEnum<any, string>';\n\t}\n\tif (constructorName === 'MoveTuple') {\n\t\treturn 'MoveTuple<any, string>';\n\t}\n\treturn 'MoveStruct<any, string>';\n};\n\nconst stabilizeGeneratedBindingContent = (content: string): string =>\n\tcontent.replace(\n\t\tgeneratedBcsFactoryPattern,\n\t\t(_match, name, generics, parameters, indent, constructorName: string) =>\n\t\t\t`export function ${name}<${generics}>(${parameters}): ${bcsFactoryReturnType(\n\t\t\t\tconstructorName,\n\t\t\t)} {\\n${indent}return new ${constructorName}(`,\n\t);\n\nconst collectGeneratedFiles = async (\n\troot: string,\n): Promise<ReadonlyArray<{ readonly relPath: string; readonly content: string }>> => {\n\tconst out: Array<{ readonly relPath: string; readonly content: string }> = [];\n\tconst walk = async (dir: string): Promise<void> => {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst abs = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(abs);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!entry.isFile()) continue;\n\t\t\tconst relPath = relative(root, abs).split(sep).join('/');\n\t\t\tout.push({ relPath, content: await readFile(abs, 'utf8') });\n\t\t}\n\t};\n\tawait walk(root);\n\tout.sort((a, b) => a.relPath.localeCompare(b.relPath));\n\treturn out;\n};\n"],"mappings":";;;;;;;;;AA4EA,IAAa,2BAAb,cAA8C,QAAQ,SAGnD,CAAC,2CAA2C,CAAC;AAiBhD,IAAa,qBAAb,cAAwC,QAAQ,SAA0C,CACzF,qCACA,CAAC;;;;;;;;;AAmCF,MAAa,gBACZ,UAMA,OAAO,IAAI,aAAa;CACvB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,kBAAkB,MAAM,mBAAmB;CAKjD,MAAM,uBAAO,IAAI,KAAa;CAC9B,MAAM,UAAkC,EAAE;CAC1C,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AC5B,MAAM,MAAM,KAAK,KAAK,MAAM,KAAK;AACjC,OAAI,MAAM,aAAa,EAAE;AACxB,UAAM,KAAK,IAAI;AACf;;AAED,OAAI,CAAC,MAAM,QAAQ,CAAE;GACrB,MAAM,UAAU,SAAS,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI;AACxD,OAAI,KAAK;IAAE;IAAS,SAAS,MAAM,SAAS,KAAK,OAAO;IAAE,CAAC;;;AAG7D,OAAM,KAAK,KAAK;AAChB,KAAI,MAAM,GAAG,MAAM,EAAE,QAAQ,cAAc,EAAE,QAAQ,CAAC;AACtD,QAAO"}
@@ -1,6 +1,7 @@
1
1
  import { atomicWriteFile } from "../../substrate/runtime/atomic-write.mjs";
2
2
  import { CodegenWriteFailed } from "./errors.mjs";
3
3
  import { Effect, FileSystem } from "effect";
4
+ import { dirname } from "node:path";
4
5
  //#region src/orchestrators/codegen/emit.ts
5
6
  /**
6
7
  * Emit one file with idempotency. The mode is re-applied even on
@@ -10,6 +11,7 @@ import { Effect, FileSystem } from "effect";
10
11
  const emitOne = (input) => Effect.gen(function* () {
11
12
  const fs = yield* FileSystem.FileSystem;
12
13
  const bytes = new TextEncoder().encode(input.content);
14
+ if (input.parentMode !== void 0) yield* ensureParentDirectory(input.path, input.parentMode);
13
15
  const existing = yield* fs.readFileString(input.path).pipe(Effect.match({
14
16
  onSuccess: (text) => text,
15
17
  onFailure: () => null
@@ -21,7 +23,10 @@ const emitOne = (input) => Effect.gen(function* () {
21
23
  outcome: drifted ? "chmod-only" : "unchanged"
22
24
  };
23
25
  }
24
- yield* atomicWriteFile(input.path, bytes, { mode: input.mode }).pipe(Effect.mapError((cause) => new CodegenWriteFailed({
26
+ yield* atomicWriteFile(input.path, bytes, {
27
+ mode: input.mode,
28
+ ...input.parentMode === void 0 ? {} : { parentMode: input.parentMode }
29
+ }).pipe(Effect.mapError((cause) => new CodegenWriteFailed({
25
30
  outputPath: input.path,
26
31
  stage: cause.stage === "mkdir-parent" ? "mkdir-parent" : "write",
27
32
  cause
@@ -50,6 +55,19 @@ const checkAndRestoreMode = (path, wantedMode) => Effect.gen(function* () {
50
55
  })));
51
56
  return true;
52
57
  });
58
+ const ensureParentDirectory = (path, parentMode) => Effect.gen(function* () {
59
+ const fs = yield* FileSystem.FileSystem;
60
+ const parent = dirname(path);
61
+ yield* fs.makeDirectory(parent, {
62
+ recursive: true,
63
+ mode: parentMode
64
+ }).pipe(Effect.mapError((cause) => new CodegenWriteFailed({
65
+ outputPath: parent,
66
+ stage: "mkdir-parent",
67
+ cause
68
+ })));
69
+ yield* checkAndRestoreMode(parent, parentMode).pipe(Effect.asVoid);
70
+ });
53
71
  //#endregion
54
72
  export { emitOne };
55
73
 
@@ -1 +1 @@
1
- {"version":3,"file":"emit.mjs","names":[],"sources":["../../../src/orchestrators/codegen/emit.ts"],"sourcesContent":["// File emission: per-file atomic write + idempotent no-touch.\n//\n// Distilled-doc § \"No-touch on no change\": when inputs are unchanged,\n// file mtimes do not move. This is load-bearing for dev-server HMR\n// quietness — Vite watchers fire on mtime, not content.\n//\n// Flow per file:\n// 1. Read existing file (best-effort). Decode as UTF-8 string.\n// 2. Compare to rendered content. If identical, restore mode bits\n// (defensive — distilled-doc §\"sensitive-file permission drift\")\n// and return WITHOUT touching the file.\n// 3. Otherwise atomic-write via the substrate's `atomicWriteFile`\n// primitive: tempfile + fsync + rename. Apply mode.\n//\n// There is no cycle-level staging directory today. Each generated\n// file is promoted independently through the substrate atomic-write\n// primitive.\n\nimport { Effect, FileSystem } from 'effect';\n\nimport { atomicWriteFile } from '../../substrate/runtime/atomic-write.ts';\n\nimport { CodegenWriteFailed } from './errors.ts';\n\nexport interface EmitOneInput {\n\treadonly path: string;\n\treadonly content: string;\n\treadonly mode: number;\n}\n\nexport interface EmitOneResult {\n\treadonly path: string;\n\t/** `wrote` — content was different and we atomically wrote.\n\t * `unchanged` — bytes matched, we skipped the write.\n\t * `chmod-only` — bytes matched but mode bits drifted; we\n\t * restored the mode but did not rewrite the file. */\n\treadonly outcome: 'wrote' | 'unchanged' | 'chmod-only';\n}\n\n/**\n * Emit one file with idempotency. The mode is re-applied even on\n * the no-write path to recover from manual chmods (distilled-doc\n * §\"sensitive-file permission drift\").\n */\nexport const emitOne = (\n\tinput: EmitOneInput,\n): Effect.Effect<EmitOneResult, CodegenWriteFailed, FileSystem.FileSystem> =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst bytes = new TextEncoder().encode(input.content);\n\n\t\t// 1. Best-effort read of existing content for the no-touch\n\t\t// short-circuit. A missing file collapses to \"no existing\n\t\t// bytes\" → write. Any other error also collapses to write\n\t\t// (atomic-write will report the real failure).\n\t\tconst existing = yield* fs.readFileString(input.path).pipe(\n\t\t\tEffect.match({\n\t\t\t\tonSuccess: (text) => text,\n\t\t\t\tonFailure: () => null,\n\t\t\t}),\n\t\t);\n\n\t\tif (existing !== null && existing === input.content) {\n\t\t\t// Content matches — re-apply mode to fix drift, but don't\n\t\t\t// touch the file's mtime. `chmod` updates the inode's\n\t\t\t// `ctime` only.\n\t\t\tconst drifted = yield* checkAndRestoreMode(input.path, input.mode);\n\t\t\treturn {\n\t\t\t\tpath: input.path,\n\t\t\t\toutcome: drifted ? ('chmod-only' as const) : ('unchanged' as const),\n\t\t\t};\n\t\t}\n\n\t\t// 2. Bytes differ (or file missing) — atomic write. The\n\t\t// substrate's `atomicWriteFile` owns mkdir-parent +\n\t\t// tempfile + fsync + rename. Mode is applied at create\n\t\t// time via the `mode` open flag.\n\t\tyield* atomicWriteFile(input.path, bytes, { mode: input.mode }).pipe(\n\t\t\tEffect.mapError(\n\t\t\t\t(cause) =>\n\t\t\t\t\tnew CodegenWriteFailed({\n\t\t\t\t\t\toutputPath: input.path,\n\t\t\t\t\t\tstage: cause.stage === 'mkdir-parent' ? 'mkdir-parent' : 'write',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t\treturn { path: input.path, outcome: 'wrote' as const };\n\t}).pipe(\n\t\tEffect.withSpan('codegen.emitOne', {\n\t\t\tattributes: { 'codegen.path': input.path },\n\t\t}),\n\t);\n\n/**\n * Check the file's current mode and restore it if drifted. Returns\n * true if a chmod was performed.\n */\nconst checkAndRestoreMode = (\n\tpath: string,\n\twantedMode: number,\n): Effect.Effect<boolean, CodegenWriteFailed, FileSystem.FileSystem> =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst stat = yield* fs.stat(path).pipe(\n\t\t\tEffect.match({\n\t\t\t\tonSuccess: (s) => s,\n\t\t\t\tonFailure: () => null,\n\t\t\t}),\n\t\t);\n\t\tif (stat === null) return false;\n\t\t// `stat.mode` is the full mode bits; mask to file-perm\n\t\t// bits (lowest 12 — incl. setuid/setgid/sticky).\n\t\tconst currentPermBits = stat.mode & 0o7777;\n\t\tif (currentPermBits === wantedMode) return false;\n\t\tyield* fs.chmod(path, wantedMode).pipe(\n\t\t\tEffect.mapError(\n\t\t\t\t(cause) =>\n\t\t\t\t\tnew CodegenWriteFailed({\n\t\t\t\t\t\toutputPath: path,\n\t\t\t\t\t\tstage: 'chmod',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t\treturn true;\n\t});\n"],"mappings":";;;;;;;;;AA4CA,MAAa,WACZ,UAEA,OAAO,IAAI,aAAa;CACvB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,MAAM,QAAQ;CAMrD,MAAM,WAAW,OAAO,GAAG,eAAe,MAAM,KAAK,CAAC,KACrD,OAAO,MAAM;EACZ,YAAY,SAAS;EACrB,iBAAiB;EACjB,CAAC,CACF;AAED,KAAI,aAAa,QAAQ,aAAa,MAAM,SAAS;EAIpD,MAAM,UAAU,OAAO,oBAAoB,MAAM,MAAM,MAAM,KAAK;AAClE,SAAO;GACN,MAAM,MAAM;GACZ,SAAS,UAAW,eAA0B;GAC9C;;AAOF,QAAO,gBAAgB,MAAM,MAAM,OAAO,EAAE,MAAM,MAAM,MAAM,CAAC,CAAC,KAC/D,OAAO,UACL,UACA,IAAI,mBAAmB;EACtB,YAAY,MAAM;EAClB,OAAO,MAAM,UAAU,iBAAiB,iBAAiB;EACzD;EACA,CAAC,CACH,CACD;AACD,QAAO;EAAE,MAAM,MAAM;EAAM,SAAS;EAAkB;EACrD,CAAC,KACF,OAAO,SAAS,mBAAmB,EAClC,YAAY,EAAE,gBAAgB,MAAM,MAAM,EAC1C,CAAC,CACF;;;;;AAMF,MAAM,uBACL,MACA,eAEA,OAAO,IAAI,aAAa;CACvB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,GAAG,KAAK,KAAK,CAAC,KACjC,OAAO,MAAM;EACZ,YAAY,MAAM;EAClB,iBAAiB;EACjB,CAAC,CACF;AACD,KAAI,SAAS,KAAM,QAAO;AAI1B,MADwB,KAAK,OAAO,UACZ,WAAY,QAAO;AAC3C,QAAO,GAAG,MAAM,MAAM,WAAW,CAAC,KACjC,OAAO,UACL,UACA,IAAI,mBAAmB;EACtB,YAAY;EACZ,OAAO;EACP;EACA,CAAC,CACH,CACD;AACD,QAAO;EACN"}
1
+ {"version":3,"file":"emit.mjs","names":[],"sources":["../../../src/orchestrators/codegen/emit.ts"],"sourcesContent":["// File emission: per-file atomic write + idempotent no-touch.\n//\n// Distilled-doc § \"No-touch on no change\": when inputs are unchanged,\n// file mtimes do not move. This is load-bearing for dev-server HMR\n// quietness — Vite watchers fire on mtime, not content.\n//\n// Flow per file:\n// 1. Read existing file (best-effort). Decode as UTF-8 string.\n// 2. Compare to rendered content. If identical, restore mode bits\n// (defensive — distilled-doc §\"sensitive-file permission drift\")\n// and return WITHOUT touching the file.\n// 3. Otherwise atomic-write via the substrate's `atomicWriteFile`\n// primitive: tempfile + fsync + rename. Apply mode.\n//\n// Cycle-level atomicity lives in `service.ts.runEmitCycle`, which\n// wraps the entire pipeline in substrate `stageAndSwap`. `emitOne`\n// remains per-file atomic so the inner staging-directory writes\n// stay crash-safe, but the user-visible output dir is replaced as\n// one rename — a half-cycle never reaches consumers.\n\nimport { Effect, FileSystem } from 'effect';\nimport { dirname } from 'node:path';\n\nimport { atomicWriteFile } from '../../substrate/runtime/atomic-write.ts';\n\nimport { CodegenWriteFailed } from './errors.ts';\n\nexport interface EmitOneInput {\n\treadonly path: string;\n\treadonly content: string;\n\treadonly mode: number;\n\treadonly parentMode?: number;\n}\n\nexport interface EmitOneResult {\n\treadonly path: string;\n\t/** `wrote` — content was different and we atomically wrote.\n\t * `unchanged` — bytes matched, we skipped the write.\n\t * `chmod-only` — bytes matched but mode bits drifted; we\n\t * restored the mode but did not rewrite the file. */\n\treadonly outcome: 'wrote' | 'unchanged' | 'chmod-only';\n}\n\n/**\n * Emit one file with idempotency. The mode is re-applied even on\n * the no-write path to recover from manual chmods (distilled-doc\n * §\"sensitive-file permission drift\").\n */\nexport const emitOne = (\n\tinput: EmitOneInput,\n): Effect.Effect<EmitOneResult, CodegenWriteFailed, FileSystem.FileSystem> =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst bytes = new TextEncoder().encode(input.content);\n\t\tif (input.parentMode !== undefined) {\n\t\t\tyield* ensureParentDirectory(input.path, input.parentMode);\n\t\t}\n\n\t\t// 1. Best-effort read of existing content for the no-touch\n\t\t// short-circuit. A missing file collapses to \"no existing\n\t\t// bytes\" → write. Any other error also collapses to write\n\t\t// (atomic-write will report the real failure).\n\t\tconst existing = yield* fs.readFileString(input.path).pipe(\n\t\t\tEffect.match({\n\t\t\t\tonSuccess: (text) => text,\n\t\t\t\tonFailure: () => null,\n\t\t\t}),\n\t\t);\n\n\t\tif (existing !== null && existing === input.content) {\n\t\t\t// Content matches — re-apply mode to fix drift, but don't\n\t\t\t// touch the file's mtime. `chmod` updates the inode's\n\t\t\t// `ctime` only.\n\t\t\tconst drifted = yield* checkAndRestoreMode(input.path, input.mode);\n\t\t\treturn {\n\t\t\t\tpath: input.path,\n\t\t\t\toutcome: drifted ? ('chmod-only' as const) : ('unchanged' as const),\n\t\t\t};\n\t\t}\n\n\t\t// 2. Bytes differ (or file missing) — atomic write. The\n\t\t// substrate's `atomicWriteFile` owns mkdir-parent +\n\t\t// tempfile + fsync + rename. Mode is applied at create\n\t\t// time via the `mode` open flag.\n\t\tyield* atomicWriteFile(input.path, bytes, {\n\t\t\tmode: input.mode,\n\t\t\t...(input.parentMode === undefined ? {} : { parentMode: input.parentMode }),\n\t\t}).pipe(\n\t\t\tEffect.mapError(\n\t\t\t\t(cause) =>\n\t\t\t\t\tnew CodegenWriteFailed({\n\t\t\t\t\t\toutputPath: input.path,\n\t\t\t\t\t\tstage: cause.stage === 'mkdir-parent' ? 'mkdir-parent' : 'write',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t\treturn { path: input.path, outcome: 'wrote' as const };\n\t}).pipe(\n\t\tEffect.withSpan('codegen.emitOne', {\n\t\t\tattributes: { 'codegen.path': input.path },\n\t\t}),\n\t);\n\n/**\n * Check the file's current mode and restore it if drifted. Returns\n * true if a chmod was performed.\n */\nconst checkAndRestoreMode = (\n\tpath: string,\n\twantedMode: number,\n): Effect.Effect<boolean, CodegenWriteFailed, FileSystem.FileSystem> =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst stat = yield* fs.stat(path).pipe(\n\t\t\tEffect.match({\n\t\t\t\tonSuccess: (s) => s,\n\t\t\t\tonFailure: () => null,\n\t\t\t}),\n\t\t);\n\t\tif (stat === null) return false;\n\t\t// `stat.mode` is the full mode bits; mask to file-perm\n\t\t// bits (lowest 12 — incl. setuid/setgid/sticky).\n\t\tconst currentPermBits = stat.mode & 0o7777;\n\t\tif (currentPermBits === wantedMode) return false;\n\t\tyield* fs.chmod(path, wantedMode).pipe(\n\t\t\tEffect.mapError(\n\t\t\t\t(cause) =>\n\t\t\t\t\tnew CodegenWriteFailed({\n\t\t\t\t\t\toutputPath: path,\n\t\t\t\t\t\tstage: 'chmod',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t\treturn true;\n\t});\n\nconst ensureParentDirectory = (\n\tpath: string,\n\tparentMode: number,\n): Effect.Effect<void, CodegenWriteFailed, FileSystem.FileSystem> =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst parent = dirname(path);\n\t\tyield* fs.makeDirectory(parent, { recursive: true, mode: parentMode }).pipe(\n\t\t\tEffect.mapError(\n\t\t\t\t(cause) =>\n\t\t\t\t\tnew CodegenWriteFailed({\n\t\t\t\t\t\toutputPath: parent,\n\t\t\t\t\t\tstage: 'mkdir-parent',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t\tyield* checkAndRestoreMode(parent, parentMode).pipe(Effect.asVoid);\n\t});\n"],"mappings":";;;;;;;;;;AAgDA,MAAa,WACZ,UAEA,OAAO,IAAI,aAAa;CACvB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,MAAM,QAAQ;AACrD,KAAI,MAAM,eAAe,KAAA,EACxB,QAAO,sBAAsB,MAAM,MAAM,MAAM,WAAW;CAO3D,MAAM,WAAW,OAAO,GAAG,eAAe,MAAM,KAAK,CAAC,KACrD,OAAO,MAAM;EACZ,YAAY,SAAS;EACrB,iBAAiB;EACjB,CAAC,CACF;AAED,KAAI,aAAa,QAAQ,aAAa,MAAM,SAAS;EAIpD,MAAM,UAAU,OAAO,oBAAoB,MAAM,MAAM,MAAM,KAAK;AAClE,SAAO;GACN,MAAM,MAAM;GACZ,SAAS,UAAW,eAA0B;GAC9C;;AAOF,QAAO,gBAAgB,MAAM,MAAM,OAAO;EACzC,MAAM,MAAM;EACZ,GAAI,MAAM,eAAe,KAAA,IAAY,EAAE,GAAG,EAAE,YAAY,MAAM,YAAY;EAC1E,CAAC,CAAC,KACF,OAAO,UACL,UACA,IAAI,mBAAmB;EACtB,YAAY,MAAM;EAClB,OAAO,MAAM,UAAU,iBAAiB,iBAAiB;EACzD;EACA,CAAC,CACH,CACD;AACD,QAAO;EAAE,MAAM,MAAM;EAAM,SAAS;EAAkB;EACrD,CAAC,KACF,OAAO,SAAS,mBAAmB,EAClC,YAAY,EAAE,gBAAgB,MAAM,MAAM,EAC1C,CAAC,CACF;;;;;AAMF,MAAM,uBACL,MACA,eAEA,OAAO,IAAI,aAAa;CACvB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,GAAG,KAAK,KAAK,CAAC,KACjC,OAAO,MAAM;EACZ,YAAY,MAAM;EAClB,iBAAiB;EACjB,CAAC,CACF;AACD,KAAI,SAAS,KAAM,QAAO;AAI1B,MADwB,KAAK,OAAO,UACZ,WAAY,QAAO;AAC3C,QAAO,GAAG,MAAM,MAAM,WAAW,CAAC,KACjC,OAAO,UACL,UACA,IAAI,mBAAmB;EACtB,YAAY;EACZ,OAAO;EACP;EACA,CAAC,CACH,CACD;AACD,QAAO;EACN;AAEH,MAAM,yBACL,MACA,eAEA,OAAO,IAAI,aAAa;CACvB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,SAAS,QAAQ,KAAK;AAC5B,QAAO,GAAG,cAAc,QAAQ;EAAE,WAAW;EAAM,MAAM;EAAY,CAAC,CAAC,KACtE,OAAO,UACL,UACA,IAAI,mBAAmB;EACtB,YAAY;EACZ,OAAO;EACP;EACA,CAAC,CACH,CACD;AACD,QAAO,oBAAoB,QAAQ,WAAW,CAAC,KAAK,OAAO,OAAO;EACjE"}
@@ -1,9 +1,14 @@
1
1
  import { Schema } from "effect";
2
2
  //#region src/orchestrators/codegen/errors.ts
3
- /** Two `Codegenable` contributions claim the same `outputPath`. Hard
4
- * failure detected BEFORE write so the user-visible output dir
5
- * never sees an ambiguous overwrite. */
3
+ /** Path-layer rejection from the codegen orchestrator.
4
+ * - `kind: 'duplicate'` two `Codegenable` contributions claim the
5
+ * same `outputPath`. Hard failure detected BEFORE write so the
6
+ * user-visible output dir never sees an ambiguous overwrite.
7
+ * - `kind: 'non-relative'` — a plugin-authored `outputPath` escapes
8
+ * the codegen root (contains `..` or is absolute). Defense-in-depth
9
+ * for the file-layout invariants. */
6
10
  var CodegenPathConflict = class extends Schema.TaggedErrorClass()("CodegenPathConflict", {
11
+ kind: Schema.Literals(["duplicate", "non-relative"]),
7
12
  outputPath: Schema.String,
8
13
  emitters: Schema.Array(Schema.String)
9
14
  }) {};
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../../../src/orchestrators/codegen/errors.ts"],"sourcesContent":["// Typed errors for the Codegen orchestrator.\n//\n// Architecture §6 (Codegenable) failure-mode taxonomy + distilled-doc\n// §\"Refine the `CodegenError` phase taxonomy\". Today's v3 collapsed\n// \"emitter-collision at acquire\", \"binary shell-out failure\", and\n// \"pure render failure\" into a single tag; the rewrite keeps them\n// separate so callers can `catchTag` on each.\n//\n// Phase tags inside each error name the lifecycle step that failed\n// (resolve → emit → render → write → bindings → finalize) so error\n// attribution stays accurate.\n\nimport { Schema } from 'effect';\n\n/** Two `Codegenable` contributions claim the same `outputPath`. Hard\n * failure detected BEFORE write so the user-visible output dir\n * never sees an ambiguous overwrite. */\nexport class CodegenPathConflict extends Schema.TaggedErrorClass<CodegenPathConflict>()(\n\t'CodegenPathConflict',\n\t{\n\t\toutputPath: Schema.String,\n\t\temitters: Schema.Array(Schema.String),\n\t},\n) {}\n\n/** Two `Codegenable` contributions share the SAME `emitterName`\n * literal but resolve to different `outputPath`s — programming\n * bug in plugin code (emitter name should be unique). Distinct\n * from `CodegenPathConflict` so attribution stays clean. */\nexport class CodegenEmitterCollision extends Schema.TaggedErrorClass<CodegenEmitterCollision>()(\n\t'CodegenEmitterCollision',\n\t{\n\t\temitterName: Schema.String,\n\t\toutputPaths: Schema.Array(Schema.String),\n\t},\n) {}\n\n/** A `Codegenable.emit()` wrote a value that the renderer cannot\n * serialise (a function, a symbol, a circular reference, etc.). */\nexport class CodegenRenderError extends Schema.TaggedErrorClass<CodegenRenderError>()(\n\t'CodegenRenderError',\n\t{\n\t\temitterName: Schema.String,\n\t\toutputPath: Schema.String,\n\t\tdetail: Schema.String,\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** `Codegenable.emit()` raised. Wraps the inner Effect failure\n * rather than propagating it raw so the orchestrator's error\n * channel stays closed. */\nexport class CodegenEmitFailed extends Schema.TaggedErrorClass<CodegenEmitFailed>()(\n\t'CodegenEmitFailed',\n\t{\n\t\temitterName: Schema.String,\n\t\toutputPath: Schema.String,\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** Disk write (atomic-write or permission-tighten) failed. */\nexport class CodegenWriteFailed extends Schema.TaggedErrorClass<CodegenWriteFailed>()(\n\t'CodegenWriteFailed',\n\t{\n\t\toutputPath: Schema.String,\n\t\tstage: Schema.Literals(['mkdir-parent', 'write', 'rename', 'chmod', 'gitignore']),\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** `@mysten/codegen` shell-out (Move-to-TS bindings) failed or\n * silently no-op'd. Distilled-doc § \"Silent no-op from a\n * downstream tool is a failure\" — we surface a hint about the\n * common `Move.toml` cause. */\nexport class CodegenBindingsFailed extends Schema.TaggedErrorClass<CodegenBindingsFailed>()(\n\t'CodegenBindingsFailed',\n\t{\n\t\tpackage: Schema.String,\n\t\tsourcePath: Schema.String,\n\t\treason: Schema.Literals(['summary-failed', 'no-output', 'render-failed', 'write-failed']),\n\t\thint: Schema.optional(Schema.String),\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** The reader of the manifest envelope detected drift between\n * what plugins contributed and what's on disk — e.g. a stale\n * envelope from a previous stack lifecycle. */\nexport class CodegenManifestDrift extends Schema.TaggedErrorClass<CodegenManifestDrift>()(\n\t'CodegenManifestDrift',\n\t{\n\t\tdetail: Schema.String,\n\t},\n) {}\n\nexport type CodegenError =\n\t| CodegenPathConflict\n\t| CodegenEmitterCollision\n\t| CodegenRenderError\n\t| CodegenEmitFailed\n\t| CodegenWriteFailed\n\t| CodegenBindingsFailed\n\t| CodegenManifestDrift;\n"],"mappings":";;;;;AAiBA,IAAa,sBAAb,cAAyC,OAAO,kBAAuC,CACtF,uBACA;CACC,YAAY,OAAO;CACnB,UAAU,OAAO,MAAM,OAAO,OAAO;CACrC,CACD,CAAC;;;;;AAMF,IAAa,0BAAb,cAA6C,OAAO,kBAA2C,CAC9F,2BACA;CACC,aAAa,OAAO;CACpB,aAAa,OAAO,MAAM,OAAO,OAAO;CACxC,CACD,CAAC;;;AAIF,IAAa,qBAAb,cAAwC,OAAO,kBAAsC,CACpF,sBACA;CACC,aAAa,OAAO;CACpB,YAAY,OAAO;CACnB,QAAQ,OAAO;CACf,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;;;;AAKF,IAAa,oBAAb,cAAuC,OAAO,kBAAqC,CAClF,qBACA;CACC,aAAa,OAAO;CACpB,YAAY,OAAO;CACnB,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;;AAGF,IAAa,qBAAb,cAAwC,OAAO,kBAAsC,CACpF,sBACA;CACC,YAAY,OAAO;CACnB,OAAO,OAAO,SAAS;EAAC;EAAgB;EAAS;EAAU;EAAS;EAAY,CAAC;CACjF,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;;;;;AAMF,IAAa,wBAAb,cAA2C,OAAO,kBAAyC,CAC1F,yBACA;CACC,SAAS,OAAO;CAChB,YAAY,OAAO;CACnB,QAAQ,OAAO,SAAS;EAAC;EAAkB;EAAa;EAAiB;EAAe,CAAC;CACzF,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;AAKwC,OAAO,kBAAwC,CACxF,wBACA,EACC,QAAQ,OAAO,QACf,CACD"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../../src/orchestrators/codegen/errors.ts"],"sourcesContent":["// Typed errors for the Codegen orchestrator.\n//\n// Architecture §6 (Codegenable) failure-mode taxonomy + distilled-doc\n// §\"Refine the `CodegenError` phase taxonomy\". Today's v3 collapsed\n// \"emitter-collision at acquire\", \"binary shell-out failure\", and\n// \"pure render failure\" into a single tag; the rewrite keeps them\n// separate so callers can `catchTag` on each.\n//\n// Phase tags inside each error name the lifecycle step that failed\n// (resolve → emit → render → write → bindings → finalize) so error\n// attribution stays accurate.\n\nimport { Schema } from 'effect';\n\n/** Path-layer rejection from the codegen orchestrator.\n * - `kind: 'duplicate'` — two `Codegenable` contributions claim the\n * same `outputPath`. Hard failure detected BEFORE write so the\n * user-visible output dir never sees an ambiguous overwrite.\n * - `kind: 'non-relative'` — a plugin-authored `outputPath` escapes\n * the codegen root (contains `..` or is absolute). Defense-in-depth\n * for the file-layout invariants. */\nexport class CodegenPathConflict extends Schema.TaggedErrorClass<CodegenPathConflict>()(\n\t'CodegenPathConflict',\n\t{\n\t\tkind: Schema.Literals(['duplicate', 'non-relative']),\n\t\toutputPath: Schema.String,\n\t\temitters: Schema.Array(Schema.String),\n\t},\n) {}\n\n/** Two `Codegenable` contributions share the SAME `emitterName`\n * literal but resolve to different `outputPath`s — programming\n * bug in plugin code (emitter name should be unique). Distinct\n * from `CodegenPathConflict` so attribution stays clean. */\nexport class CodegenEmitterCollision extends Schema.TaggedErrorClass<CodegenEmitterCollision>()(\n\t'CodegenEmitterCollision',\n\t{\n\t\temitterName: Schema.String,\n\t\toutputPaths: Schema.Array(Schema.String),\n\t},\n) {}\n\n/** A `Codegenable.emit()` wrote a value that the renderer cannot\n * serialise (a function, a symbol, a circular reference, etc.). */\nexport class CodegenRenderError extends Schema.TaggedErrorClass<CodegenRenderError>()(\n\t'CodegenRenderError',\n\t{\n\t\temitterName: Schema.String,\n\t\toutputPath: Schema.String,\n\t\tdetail: Schema.String,\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** `Codegenable.emit()` raised. Wraps the inner Effect failure\n * rather than propagating it raw so the orchestrator's error\n * channel stays closed. */\nexport class CodegenEmitFailed extends Schema.TaggedErrorClass<CodegenEmitFailed>()(\n\t'CodegenEmitFailed',\n\t{\n\t\temitterName: Schema.String,\n\t\toutputPath: Schema.String,\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** Disk write (atomic-write or permission-tighten) failed. */\nexport class CodegenWriteFailed extends Schema.TaggedErrorClass<CodegenWriteFailed>()(\n\t'CodegenWriteFailed',\n\t{\n\t\toutputPath: Schema.String,\n\t\tstage: Schema.Literals(['mkdir-parent', 'write', 'rename', 'chmod', 'gitignore']),\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** `@mysten/codegen` shell-out (Move-to-TS bindings) failed or\n * silently no-op'd. Distilled-doc § \"Silent no-op from a\n * downstream tool is a failure\" — we surface a hint about the\n * common `Move.toml` cause. */\nexport class CodegenBindingsFailed extends Schema.TaggedErrorClass<CodegenBindingsFailed>()(\n\t'CodegenBindingsFailed',\n\t{\n\t\tpackage: Schema.String,\n\t\tsourcePath: Schema.String,\n\t\treason: Schema.Literals(['summary-failed', 'no-output', 'render-failed', 'write-failed']),\n\t\thint: Schema.optional(Schema.String),\n\t\tcause: Schema.optional(Schema.Defect),\n\t},\n) {}\n\n/** The reader of the manifest envelope detected drift between\n * what plugins contributed and what's on disk — e.g. a stale\n * envelope from a previous stack lifecycle. */\nexport class CodegenManifestDrift extends Schema.TaggedErrorClass<CodegenManifestDrift>()(\n\t'CodegenManifestDrift',\n\t{\n\t\tdetail: Schema.String,\n\t},\n) {}\n\nexport type CodegenError =\n\t| CodegenPathConflict\n\t| CodegenEmitterCollision\n\t| CodegenRenderError\n\t| CodegenEmitFailed\n\t| CodegenWriteFailed\n\t| CodegenBindingsFailed\n\t| CodegenManifestDrift;\n"],"mappings":";;;;;;;;;AAqBA,IAAa,sBAAb,cAAyC,OAAO,kBAAuC,CACtF,uBACA;CACC,MAAM,OAAO,SAAS,CAAC,aAAa,eAAe,CAAC;CACpD,YAAY,OAAO;CACnB,UAAU,OAAO,MAAM,OAAO,OAAO;CACrC,CACD,CAAC;;;;;AAMF,IAAa,0BAAb,cAA6C,OAAO,kBAA2C,CAC9F,2BACA;CACC,aAAa,OAAO;CACpB,aAAa,OAAO,MAAM,OAAO,OAAO;CACxC,CACD,CAAC;;;AAIF,IAAa,qBAAb,cAAwC,OAAO,kBAAsC,CACpF,sBACA;CACC,aAAa,OAAO;CACpB,YAAY,OAAO;CACnB,QAAQ,OAAO;CACf,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;;;;AAKF,IAAa,oBAAb,cAAuC,OAAO,kBAAqC,CAClF,qBACA;CACC,aAAa,OAAO;CACpB,YAAY,OAAO;CACnB,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;;AAGF,IAAa,qBAAb,cAAwC,OAAO,kBAAsC,CACpF,sBACA;CACC,YAAY,OAAO;CACnB,OAAO,OAAO,SAAS;EAAC;EAAgB;EAAS;EAAU;EAAS;EAAY,CAAC;CACjF,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;;;;;AAMF,IAAa,wBAAb,cAA2C,OAAO,kBAAyC,CAC1F,yBACA;CACC,SAAS,OAAO;CAChB,YAAY,OAAO;CACnB,QAAQ,OAAO,SAAS;EAAC;EAAkB;EAAa;EAAiB;EAAe,CAAC;CACzF,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CACD,CAAC;AAKwC,OAAO,kBAAwC,CACxF,wBACA,EACC,QAAQ,OAAO,QACf,CACD"}