alchemy 2.0.0-beta.43 → 2.0.0-beta.45

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 (561) hide show
  1. package/bin/cli.js +18 -5
  2. package/bin/exec.js +381 -240
  3. package/bin/exec.js.map +1 -1
  4. package/lib/AWS/Lambda/Function.d.ts +17 -0
  5. package/lib/AWS/Lambda/Function.d.ts.map +1 -1
  6. package/lib/AWS/Lambda/Function.js +61 -16
  7. package/lib/AWS/Lambda/Function.js.map +1 -1
  8. package/lib/AWS/Providers.d.ts +2 -1
  9. package/lib/AWS/Providers.d.ts.map +1 -1
  10. package/lib/AWS/Providers.js +3 -1
  11. package/lib/AWS/Providers.js.map +1 -1
  12. package/lib/Apply.js +17 -1
  13. package/lib/Apply.js.map +1 -1
  14. package/lib/Auth/AuthProvider.d.ts.map +1 -1
  15. package/lib/Auth/AuthProvider.js +24 -6
  16. package/lib/Auth/AuthProvider.js.map +1 -1
  17. package/lib/Auth/Credentials.d.ts.map +1 -1
  18. package/lib/Auth/Credentials.js +3 -3
  19. package/lib/Auth/Credentials.js.map +1 -1
  20. package/lib/Auth/Lock.js +2 -2
  21. package/lib/Auth/Lock.js.map +1 -1
  22. package/lib/Bundle/Bundle.d.ts +11 -0
  23. package/lib/Bundle/Bundle.d.ts.map +1 -1
  24. package/lib/Bundle/Bundle.js +19 -12
  25. package/lib/Bundle/Bundle.js.map +1 -1
  26. package/lib/Bundle/BundleAnalyzerPlugin.d.ts +25 -0
  27. package/lib/Bundle/BundleAnalyzerPlugin.d.ts.map +1 -0
  28. package/lib/Bundle/BundleAnalyzerPlugin.js +16 -0
  29. package/lib/Bundle/BundleAnalyzerPlugin.js.map +1 -0
  30. package/lib/Bundle/RawPlugin.d.ts +36 -0
  31. package/lib/Bundle/RawPlugin.d.ts.map +1 -0
  32. package/lib/Bundle/RawPlugin.js +80 -0
  33. package/lib/Bundle/RawPlugin.js.map +1 -0
  34. package/lib/Bundle/index.d.ts +2 -0
  35. package/lib/Bundle/index.d.ts.map +1 -1
  36. package/lib/Bundle/index.js +2 -0
  37. package/lib/Bundle/index.js.map +1 -1
  38. package/lib/Cli/commands/_shared.d.ts +13 -1
  39. package/lib/Cli/commands/_shared.d.ts.map +1 -1
  40. package/lib/Cli/commands/_shared.js +33 -2
  41. package/lib/Cli/commands/_shared.js.map +1 -1
  42. package/lib/Cli/commands/dev.d.ts +3 -2
  43. package/lib/Cli/commands/dev.d.ts.map +1 -1
  44. package/lib/Cli/commands/dev.js +19 -2
  45. package/lib/Cli/commands/dev.js.map +1 -1
  46. package/lib/Cli/commands/login.d.ts.map +1 -1
  47. package/lib/Cli/commands/login.js +19 -5
  48. package/lib/Cli/commands/login.js.map +1 -1
  49. package/lib/Cli/commands/profile.d.ts.map +1 -1
  50. package/lib/Cli/commands/profile.js +7 -27
  51. package/lib/Cli/commands/profile.js.map +1 -1
  52. package/lib/Cli/exec.d.ts.map +1 -1
  53. package/lib/Cli/exec.js +2 -1
  54. package/lib/Cli/exec.js.map +1 -1
  55. package/lib/Cli/main.d.ts.map +1 -1
  56. package/lib/Cli/main.js +0 -2
  57. package/lib/Cli/main.js.map +1 -1
  58. package/lib/Cloudflare/AiGateway/AiGateway.d.ts +0 -2
  59. package/lib/Cloudflare/AiGateway/AiGateway.d.ts.map +1 -1
  60. package/lib/Cloudflare/AiGateway/AiGateway.js +2 -4
  61. package/lib/Cloudflare/AiGateway/AiGateway.js.map +1 -1
  62. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts +116 -0
  63. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts.map +1 -0
  64. package/lib/Cloudflare/BrowserRendering/BrowserRendering.js +92 -0
  65. package/lib/Cloudflare/BrowserRendering/BrowserRendering.js.map +1 -0
  66. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts +55 -0
  67. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts.map +1 -0
  68. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js +55 -0
  69. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js.map +1 -0
  70. package/lib/Cloudflare/BrowserRendering/index.d.ts +3 -0
  71. package/lib/Cloudflare/BrowserRendering/index.d.ts.map +1 -0
  72. package/lib/Cloudflare/BrowserRendering/index.js +3 -0
  73. package/lib/Cloudflare/BrowserRendering/index.js.map +1 -0
  74. package/lib/Cloudflare/Container/Container.d.ts +3 -3
  75. package/lib/Cloudflare/Container/Container.js +3 -3
  76. package/lib/Cloudflare/Container/StartContainer.d.ts.map +1 -1
  77. package/lib/Cloudflare/Container/StartContainer.js.map +1 -1
  78. package/lib/Cloudflare/D1/D1Database.d.ts +1 -0
  79. package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
  80. package/lib/Cloudflare/D1/D1Database.js +2 -1
  81. package/lib/Cloudflare/D1/D1Database.js.map +1 -1
  82. package/lib/Cloudflare/D1/D1DatabaseBinding.js +1 -1
  83. package/lib/Cloudflare/D1/D1DatabaseBinding.js.map +1 -1
  84. package/lib/Cloudflare/Fetcher.d.ts.map +1 -1
  85. package/lib/Cloudflare/Fetcher.js +0 -2
  86. package/lib/Cloudflare/Fetcher.js.map +1 -1
  87. package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts +1 -0
  88. package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts.map +1 -1
  89. package/lib/Cloudflare/Hyperdrive/Hyperdrive.js +3 -0
  90. package/lib/Cloudflare/Hyperdrive/Hyperdrive.js.map +1 -1
  91. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts +3 -2
  92. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts.map +1 -1
  93. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js +32 -33
  94. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js.map +1 -1
  95. package/lib/Cloudflare/KV/KVNamespace.d.ts +1 -0
  96. package/lib/Cloudflare/KV/KVNamespace.d.ts.map +1 -1
  97. package/lib/Cloudflare/KV/KVNamespace.js +2 -0
  98. package/lib/Cloudflare/KV/KVNamespace.js.map +1 -1
  99. package/lib/Cloudflare/Local.d.ts +2 -0
  100. package/lib/Cloudflare/Local.d.ts.map +1 -0
  101. package/lib/Cloudflare/Local.js +9 -0
  102. package/lib/Cloudflare/Local.js.map +1 -0
  103. package/lib/Cloudflare/Providers.d.ts +2 -1
  104. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  105. package/lib/Cloudflare/Providers.js +23 -17
  106. package/lib/Cloudflare/Providers.js.map +1 -1
  107. package/lib/Cloudflare/Queue/Queue.d.ts +1 -0
  108. package/lib/Cloudflare/Queue/Queue.d.ts.map +1 -1
  109. package/lib/Cloudflare/Queue/Queue.js +1 -0
  110. package/lib/Cloudflare/Queue/Queue.js.map +1 -1
  111. package/lib/Cloudflare/Queue/QueueConsumer.d.ts +2 -1
  112. package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -1
  113. package/lib/Cloudflare/Queue/QueueConsumer.js +11 -3
  114. package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -1
  115. package/lib/Cloudflare/Queue/QueueEventSource.d.ts +30 -4
  116. package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -1
  117. package/lib/Cloudflare/Queue/QueueEventSource.js +22 -1
  118. package/lib/Cloudflare/Queue/QueueEventSource.js.map +1 -1
  119. package/lib/Cloudflare/R2/R2Bucket.d.ts +1 -0
  120. package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
  121. package/lib/Cloudflare/R2/R2Bucket.js +18 -0
  122. package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
  123. package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -1
  124. package/lib/Cloudflare/SecretsStore/Secret.js +13 -34
  125. package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -1
  126. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts +3 -2
  127. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts.map +1 -1
  128. package/lib/Cloudflare/SecretsStore/SecretBinding.js +3 -2
  129. package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -1
  130. package/lib/Cloudflare/StateStore/Api.d.ts +5 -13
  131. package/lib/Cloudflare/StateStore/Api.d.ts.map +1 -1
  132. package/lib/Cloudflare/StateStore/Api.js +14 -8
  133. package/lib/Cloudflare/StateStore/Api.js.map +1 -1
  134. package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
  135. package/lib/Cloudflare/StateStore/State.js +45 -9
  136. package/lib/Cloudflare/StateStore/State.js.map +1 -1
  137. package/lib/Cloudflare/StateStore/Store.d.ts.map +1 -1
  138. package/lib/Cloudflare/StateStore/Store.js +5 -2
  139. package/lib/Cloudflare/StateStore/Store.js.map +1 -1
  140. package/lib/Cloudflare/VpcService/VpcService.d.ts +2 -2
  141. package/lib/Cloudflare/VpcService/VpcService.d.ts.map +1 -1
  142. package/lib/Cloudflare/Website/StaticSite.d.ts +5 -5
  143. package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
  144. package/lib/Cloudflare/Website/StaticSite.js +3 -0
  145. package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
  146. package/lib/Cloudflare/Website/Vite.d.ts +5 -5
  147. package/lib/Cloudflare/Website/Vite.d.ts.map +1 -1
  148. package/lib/Cloudflare/Website/Vite.js.map +1 -1
  149. package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
  150. package/lib/Cloudflare/Workers/Assets.js +1 -1
  151. package/lib/Cloudflare/Workers/Assets.js.map +1 -1
  152. package/lib/Cloudflare/Workers/DurableObjectBridge.d.ts.map +1 -1
  153. package/lib/Cloudflare/Workers/DurableObjectBridge.js +4 -3
  154. package/lib/Cloudflare/Workers/DurableObjectBridge.js.map +1 -1
  155. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +183 -6
  156. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
  157. package/lib/Cloudflare/Workers/DurableObjectNamespace.js +279 -76
  158. package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
  159. package/lib/Cloudflare/Workers/HttpServer.d.ts +6 -4
  160. package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
  161. package/lib/Cloudflare/Workers/HttpServer.js +20 -15
  162. package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
  163. package/lib/Cloudflare/Workers/InferEnv.d.ts +3 -2
  164. package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
  165. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts +19 -3
  166. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  167. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +458 -21
  168. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  169. package/lib/Cloudflare/Workers/Rpc.d.ts +16 -0
  170. package/lib/Cloudflare/Workers/Rpc.d.ts.map +1 -1
  171. package/lib/Cloudflare/Workers/Rpc.js +22 -0
  172. package/lib/Cloudflare/Workers/Rpc.js.map +1 -1
  173. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts +285 -0
  174. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts.map +1 -0
  175. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js +288 -0
  176. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js.map +1 -0
  177. package/lib/Cloudflare/Workers/RpcWorker.d.ts +305 -0
  178. package/lib/Cloudflare/Workers/RpcWorker.d.ts.map +1 -0
  179. package/lib/Cloudflare/Workers/RpcWorker.js +350 -0
  180. package/lib/Cloudflare/Workers/RpcWorker.js.map +1 -0
  181. package/lib/Cloudflare/Workers/Vite.d.ts +1 -1
  182. package/lib/Cloudflare/Workers/Vite.d.ts.map +1 -1
  183. package/lib/Cloudflare/Workers/Vite.js +2 -1
  184. package/lib/Cloudflare/Workers/Vite.js.map +1 -1
  185. package/lib/Cloudflare/Workers/Worker.d.ts +69 -37
  186. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  187. package/lib/Cloudflare/Workers/Worker.js +171 -51
  188. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  189. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts +1 -1
  190. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
  191. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +158 -97
  192. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
  193. package/lib/Cloudflare/Workers/WorkerBinding.d.ts +11 -23
  194. package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
  195. package/lib/Cloudflare/Workers/WorkerBinding.js +3 -0
  196. package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
  197. package/lib/Cloudflare/Workers/WorkerBridge.d.ts.map +1 -1
  198. package/lib/Cloudflare/Workers/WorkerBridge.js +8 -7
  199. package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
  200. package/lib/Cloudflare/Workers/WorkerBundle.d.ts +1 -2
  201. package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
  202. package/lib/Cloudflare/Workers/WorkerBundle.js +7 -7
  203. package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
  204. package/lib/Cloudflare/Workers/WorkerRuntimeContext.d.ts.map +1 -1
  205. package/lib/Cloudflare/Workers/WorkerRuntimeContext.js +9 -10
  206. package/lib/Cloudflare/Workers/WorkerRuntimeContext.js.map +1 -1
  207. package/lib/Cloudflare/Workers/Workflow.d.ts +5 -3
  208. package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
  209. package/lib/Cloudflare/Workers/Workflow.js +19 -1
  210. package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
  211. package/lib/Cloudflare/Workers/index.d.ts +2 -0
  212. package/lib/Cloudflare/Workers/index.d.ts.map +1 -1
  213. package/lib/Cloudflare/Workers/index.js +2 -0
  214. package/lib/Cloudflare/Workers/index.js.map +1 -1
  215. package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts +184 -0
  216. package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts.map +1 -0
  217. package/lib/Cloudflare/Zaraz/ZarazConfig.js +216 -0
  218. package/lib/Cloudflare/Zaraz/ZarazConfig.js.map +1 -0
  219. package/lib/Cloudflare/Zaraz/ZarazEventTypes.d.ts +188 -0
  220. package/lib/Cloudflare/Zaraz/ZarazEventTypes.d.ts.map +1 -0
  221. package/lib/Cloudflare/Zaraz/ZarazEventTypes.js +4 -0
  222. package/lib/Cloudflare/Zaraz/ZarazEventTypes.js.map +1 -0
  223. package/lib/Cloudflare/Zaraz/index.d.ts +3 -0
  224. package/lib/Cloudflare/Zaraz/index.d.ts.map +1 -0
  225. package/lib/Cloudflare/Zaraz/index.js +2 -0
  226. package/lib/Cloudflare/Zaraz/index.js.map +1 -0
  227. package/lib/Cloudflare/index.d.ts +2 -0
  228. package/lib/Cloudflare/index.d.ts.map +1 -1
  229. package/lib/Cloudflare/index.js +2 -0
  230. package/lib/Cloudflare/index.js.map +1 -1
  231. package/lib/Dependencies.d.ts +10 -0
  232. package/lib/Dependencies.d.ts.map +1 -0
  233. package/lib/Dependencies.js +1 -0
  234. package/lib/Dependencies.js.map +1 -0
  235. package/lib/Deploy.d.ts +2 -1
  236. package/lib/Deploy.d.ts.map +1 -1
  237. package/lib/Deploy.js +2 -2
  238. package/lib/Deploy.js.map +1 -1
  239. package/lib/Diff.d.ts +11 -0
  240. package/lib/Diff.d.ts.map +1 -1
  241. package/lib/Diff.js +11 -0
  242. package/lib/Diff.js.map +1 -1
  243. package/lib/Input.d.ts +2 -1
  244. package/lib/Input.d.ts.map +1 -1
  245. package/lib/KeyPair.d.ts +77 -0
  246. package/lib/KeyPair.d.ts.map +1 -0
  247. package/lib/KeyPair.js +102 -0
  248. package/lib/KeyPair.js.map +1 -0
  249. package/lib/Local/RpcProvider.d.ts +56 -0
  250. package/lib/Local/RpcProvider.d.ts.map +1 -0
  251. package/lib/Local/RpcProvider.js +83 -0
  252. package/lib/Local/RpcProvider.js.map +1 -0
  253. package/lib/Local/RpcProviderProxy.d.ts +19 -0
  254. package/lib/Local/RpcProviderProxy.d.ts.map +1 -0
  255. package/lib/Local/RpcProviderProxy.js +48 -0
  256. package/lib/Local/RpcProviderProxy.js.map +1 -0
  257. package/lib/Local/RpcSerialization.d.ts +34 -0
  258. package/lib/Local/RpcSerialization.d.ts.map +1 -0
  259. package/lib/Local/RpcSerialization.js +120 -0
  260. package/lib/Local/RpcSerialization.js.map +1 -0
  261. package/lib/Local/RpcServer.d.ts +63 -0
  262. package/lib/Local/RpcServer.d.ts.map +1 -0
  263. package/lib/Local/RpcServer.js +72 -0
  264. package/lib/Local/RpcServer.js.map +1 -0
  265. package/lib/Local/RpcServerBun.d.ts +3 -0
  266. package/lib/Local/RpcServerBun.d.ts.map +1 -0
  267. package/lib/Local/RpcServerBun.js +47 -0
  268. package/lib/Local/RpcServerBun.js.map +1 -0
  269. package/lib/Local/RpcServerEnvironment.d.ts +20 -0
  270. package/lib/Local/RpcServerEnvironment.d.ts.map +1 -0
  271. package/lib/Local/RpcServerEnvironment.js +22 -0
  272. package/lib/Local/RpcServerEnvironment.js.map +1 -0
  273. package/lib/Local/RpcServerNode.d.ts +3 -0
  274. package/lib/Local/RpcServerNode.d.ts.map +1 -0
  275. package/lib/Local/RpcServerNode.js +43 -0
  276. package/lib/Local/RpcServerNode.js.map +1 -0
  277. package/lib/Local/RpcServerSession.d.ts +27 -0
  278. package/lib/Local/RpcServerSession.d.ts.map +1 -0
  279. package/lib/Local/RpcServerSession.js +68 -0
  280. package/lib/Local/RpcServerSession.js.map +1 -0
  281. package/lib/Local/RpcSpawner.d.ts +21 -0
  282. package/lib/Local/RpcSpawner.d.ts.map +1 -0
  283. package/lib/Local/RpcSpawner.js +132 -0
  284. package/lib/Local/RpcSpawner.js.map +1 -0
  285. package/lib/Neon/Project.d.ts.map +1 -1
  286. package/lib/Neon/Project.js +14 -3
  287. package/lib/Neon/Project.js.map +1 -1
  288. package/lib/Output.d.ts.map +1 -1
  289. package/lib/Output.js +9 -2
  290. package/lib/Output.js.map +1 -1
  291. package/lib/Phase.d.ts +2 -1
  292. package/lib/Phase.d.ts.map +1 -1
  293. package/lib/Phase.js +6 -1
  294. package/lib/Phase.js.map +1 -1
  295. package/lib/Plan.d.ts.map +1 -1
  296. package/lib/Plan.js +14 -3
  297. package/lib/Plan.js.map +1 -1
  298. package/lib/Platform.d.ts +8 -6
  299. package/lib/Platform.d.ts.map +1 -1
  300. package/lib/Platform.js +33 -3
  301. package/lib/Platform.js.map +1 -1
  302. package/lib/Random.d.ts.map +1 -1
  303. package/lib/Random.js +9 -14
  304. package/lib/Random.js.map +1 -1
  305. package/lib/RuntimeContext.d.ts +21 -1
  306. package/lib/RuntimeContext.d.ts.map +1 -1
  307. package/lib/RuntimeContext.js +12 -0
  308. package/lib/RuntimeContext.js.map +1 -1
  309. package/lib/Stack.d.ts +3 -3
  310. package/lib/Stack.d.ts.map +1 -1
  311. package/lib/Stack.js.map +1 -1
  312. package/lib/State/HttpStateApi.d.ts +2 -2
  313. package/lib/State/StateEncoding.d.ts +8 -0
  314. package/lib/State/StateEncoding.d.ts.map +1 -1
  315. package/lib/State/StateEncoding.js +55 -5
  316. package/lib/State/StateEncoding.js.map +1 -1
  317. package/lib/Test/Bun.d.ts.map +1 -1
  318. package/lib/Test/Bun.js +0 -2
  319. package/lib/Test/Bun.js.map +1 -1
  320. package/lib/Test/Vitest.d.ts.map +1 -1
  321. package/lib/Test/Vitest.js +0 -2
  322. package/lib/Test/Vitest.js.map +1 -1
  323. package/lib/Util/Duration.d.ts +14 -0
  324. package/lib/Util/Duration.d.ts.map +1 -0
  325. package/lib/Util/Duration.js +18 -0
  326. package/lib/Util/Duration.js.map +1 -0
  327. package/lib/Util/PlatformServices.d.ts +7 -0
  328. package/lib/Util/PlatformServices.d.ts.map +1 -1
  329. package/lib/Util/PlatformServices.js +22 -11
  330. package/lib/Util/PlatformServices.js.map +1 -1
  331. package/lib/Util/camel.d.ts.map +1 -1
  332. package/lib/Util/camel.js +2 -3
  333. package/lib/Util/camel.js.map +1 -1
  334. package/lib/Util/data.d.ts +5 -0
  335. package/lib/Util/data.d.ts.map +1 -1
  336. package/lib/Util/data.js +29 -0
  337. package/lib/Util/data.js.map +1 -1
  338. package/lib/Util/index.d.ts +0 -6
  339. package/lib/Util/index.d.ts.map +1 -1
  340. package/lib/Util/index.js +0 -6
  341. package/lib/Util/index.js.map +1 -1
  342. package/lib/Util/stable.d.ts.map +1 -1
  343. package/lib/Util/stable.js +3 -6
  344. package/lib/Util/stable.js.map +1 -1
  345. package/lib/Util/types.d.ts +3 -1
  346. package/lib/Util/types.d.ts.map +1 -1
  347. package/lib/Util/types.js +5 -1
  348. package/lib/Util/types.js.map +1 -1
  349. package/lib/index.d.ts +2 -3
  350. package/lib/index.d.ts.map +1 -1
  351. package/lib/index.js +1 -3
  352. package/lib/index.js.map +1 -1
  353. package/lib/tsconfig.test.tsbuildinfo +1 -1
  354. package/package.json +22 -23
  355. package/src/AWS/Lambda/Function.ts +87 -34
  356. package/src/AWS/Providers.ts +3 -0
  357. package/src/Apply.ts +18 -1
  358. package/src/Auth/AuthProvider.ts +25 -5
  359. package/src/Auth/Credentials.ts +8 -7
  360. package/src/Auth/Lock.ts +2 -2
  361. package/src/Bundle/Bundle.ts +35 -13
  362. package/src/Bundle/BundleAnalyzerPlugin.ts +33 -0
  363. package/src/Bundle/RawPlugin.ts +82 -0
  364. package/src/Bundle/index.ts +2 -0
  365. package/src/Cli/commands/_shared.ts +47 -4
  366. package/src/Cli/commands/dev.ts +63 -37
  367. package/src/Cli/commands/login.ts +20 -4
  368. package/src/Cli/commands/profile.ts +24 -34
  369. package/src/Cli/exec.ts +12 -7
  370. package/src/Cli/main.ts +0 -3
  371. package/src/Cloudflare/AiGateway/AiGateway.ts +2 -6
  372. package/src/Cloudflare/BrowserRendering/BrowserRendering.ts +132 -0
  373. package/src/Cloudflare/BrowserRendering/BrowserRenderingBinding.ts +137 -0
  374. package/src/Cloudflare/BrowserRendering/index.ts +11 -0
  375. package/src/Cloudflare/Container/Container.ts +3 -3
  376. package/src/Cloudflare/Container/StartContainer.ts +1 -2
  377. package/src/Cloudflare/D1/D1Database.ts +4 -1
  378. package/src/Cloudflare/D1/D1DatabaseBinding.ts +1 -1
  379. package/src/Cloudflare/Fetcher.ts +0 -2
  380. package/src/Cloudflare/Hyperdrive/Hyperdrive.ts +5 -0
  381. package/src/Cloudflare/Hyperdrive/HyperdriveBinding.ts +41 -43
  382. package/src/Cloudflare/KV/KVNamespace.ts +4 -0
  383. package/src/Cloudflare/Local.ts +23 -0
  384. package/src/Cloudflare/Providers.ts +28 -16
  385. package/src/Cloudflare/Queue/Queue.ts +3 -0
  386. package/src/Cloudflare/Queue/QueueConsumer.ts +23 -8
  387. package/src/Cloudflare/Queue/QueueEventSource.ts +33 -5
  388. package/src/Cloudflare/R2/R2Bucket.ts +26 -0
  389. package/src/Cloudflare/SecretsStore/Secret.ts +14 -41
  390. package/src/Cloudflare/SecretsStore/SecretBinding.ts +11 -11
  391. package/src/Cloudflare/StateStore/Api.ts +15 -15
  392. package/src/Cloudflare/StateStore/State.ts +68 -6
  393. package/src/Cloudflare/StateStore/Store.ts +5 -2
  394. package/src/Cloudflare/VpcService/VpcService.ts +2 -2
  395. package/src/Cloudflare/Website/StaticSite.ts +8 -10
  396. package/src/Cloudflare/Website/Vite.ts +4 -7
  397. package/src/Cloudflare/Workers/Assets.ts +1 -1
  398. package/src/Cloudflare/Workers/DurableObjectBridge.ts +7 -5
  399. package/src/Cloudflare/Workers/DurableObjectNamespace.ts +380 -121
  400. package/src/Cloudflare/Workers/HttpServer.ts +31 -25
  401. package/src/Cloudflare/Workers/InferEnv.ts +15 -8
  402. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +609 -22
  403. package/src/Cloudflare/Workers/Rpc.ts +50 -0
  404. package/src/Cloudflare/Workers/RpcDurableObjectNamespace.ts +502 -0
  405. package/src/Cloudflare/Workers/RpcWorker.ts +562 -0
  406. package/src/Cloudflare/Workers/Vite.ts +2 -0
  407. package/src/Cloudflare/Workers/Worker.ts +280 -110
  408. package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +158 -103
  409. package/src/Cloudflare/Workers/WorkerBinding.ts +10 -0
  410. package/src/Cloudflare/Workers/WorkerBridge.ts +10 -9
  411. package/src/Cloudflare/Workers/WorkerBundle.ts +8 -9
  412. package/src/Cloudflare/Workers/WorkerRuntimeContext.ts +8 -15
  413. package/src/Cloudflare/Workers/Workflow.ts +22 -3
  414. package/src/Cloudflare/Workers/index.ts +2 -0
  415. package/src/Cloudflare/Zaraz/ZarazConfig.ts +403 -0
  416. package/src/Cloudflare/Zaraz/ZarazEventTypes.ts +257 -0
  417. package/src/Cloudflare/Zaraz/index.ts +25 -0
  418. package/src/Cloudflare/index.ts +2 -0
  419. package/src/Dependencies.ts +10 -0
  420. package/src/Deploy.ts +3 -1
  421. package/src/Diff.ts +13 -0
  422. package/src/Input.ts +2 -0
  423. package/src/KeyPair.ts +146 -0
  424. package/src/Local/RpcProvider.ts +146 -0
  425. package/src/Local/RpcProviderProxy.ts +86 -0
  426. package/src/Local/RpcSerialization.ts +225 -0
  427. package/src/Local/RpcServer.ts +138 -0
  428. package/src/Local/RpcServerBun.ts +59 -0
  429. package/src/Local/RpcServerEnvironment.ts +55 -0
  430. package/src/Local/RpcServerNode.ts +58 -0
  431. package/src/Local/RpcServerSession.ts +87 -0
  432. package/src/Local/RpcSpawner.ts +196 -0
  433. package/src/Neon/Project.ts +16 -3
  434. package/src/Output.ts +8 -2
  435. package/src/Phase.ts +8 -0
  436. package/src/Plan.ts +16 -3
  437. package/src/Platform.ts +74 -27
  438. package/src/Random.ts +22 -27
  439. package/src/RuntimeContext.ts +23 -1
  440. package/src/Stack.ts +3 -3
  441. package/src/State/StateEncoding.ts +58 -7
  442. package/src/Test/Bun.ts +0 -3
  443. package/src/Test/Vitest.ts +0 -3
  444. package/src/Util/Duration.ts +21 -0
  445. package/src/Util/PlatformServices.ts +41 -27
  446. package/src/Util/camel.ts +3 -5
  447. package/src/Util/data.ts +38 -0
  448. package/src/Util/index.ts +0 -6
  449. package/src/Util/stable.ts +4 -10
  450. package/src/Util/types.ts +9 -2
  451. package/src/index.ts +2 -3
  452. package/lib/Cloudflare/Local/Sidecar.d.ts +0 -63
  453. package/lib/Cloudflare/Local/Sidecar.d.ts.map +0 -1
  454. package/lib/Cloudflare/Local/Sidecar.js +0 -50
  455. package/lib/Cloudflare/Local/Sidecar.js.map +0 -1
  456. package/lib/Cloudflare/Local/SidecarHandlers.d.ts +0 -8
  457. package/lib/Cloudflare/Local/SidecarHandlers.d.ts.map +0 -1
  458. package/lib/Cloudflare/Local/SidecarHandlers.js +0 -381
  459. package/lib/Cloudflare/Local/SidecarHandlers.js.map +0 -1
  460. package/lib/Cloudflare/Local/SidecarServer.d.ts +0 -2
  461. package/lib/Cloudflare/Local/SidecarServer.d.ts.map +0 -1
  462. package/lib/Cloudflare/Local/SidecarServer.js +0 -34
  463. package/lib/Cloudflare/Local/SidecarServer.js.map +0 -1
  464. package/lib/Secret.d.ts +0 -50
  465. package/lib/Secret.d.ts.map +0 -1
  466. package/lib/Secret.js +0 -23
  467. package/lib/Secret.js.map +0 -1
  468. package/lib/Sidecar/Lock.d.ts +0 -23
  469. package/lib/Sidecar/Lock.d.ts.map +0 -1
  470. package/lib/Sidecar/Lock.js +0 -39
  471. package/lib/Sidecar/Lock.js.map +0 -1
  472. package/lib/Sidecar/RpcClient.d.ts +0 -15
  473. package/lib/Sidecar/RpcClient.d.ts.map +0 -1
  474. package/lib/Sidecar/RpcClient.js +0 -78
  475. package/lib/Sidecar/RpcClient.js.map +0 -1
  476. package/lib/Sidecar/RpcHandler.d.ts +0 -51
  477. package/lib/Sidecar/RpcHandler.d.ts.map +0 -1
  478. package/lib/Sidecar/RpcHandler.js +0 -87
  479. package/lib/Sidecar/RpcHandler.js.map +0 -1
  480. package/lib/Sidecar/RpcPaths.d.ts +0 -19
  481. package/lib/Sidecar/RpcPaths.d.ts.map +0 -1
  482. package/lib/Sidecar/RpcPaths.js +0 -31
  483. package/lib/Sidecar/RpcPaths.js.map +0 -1
  484. package/lib/Sidecar/RpcServer.d.ts +0 -30
  485. package/lib/Sidecar/RpcServer.d.ts.map +0 -1
  486. package/lib/Sidecar/RpcServer.js +0 -105
  487. package/lib/Sidecar/RpcServer.js.map +0 -1
  488. package/lib/Sidecar/RpcServerBun.d.ts +0 -4
  489. package/lib/Sidecar/RpcServerBun.d.ts.map +0 -1
  490. package/lib/Sidecar/RpcServerBun.js +0 -28
  491. package/lib/Sidecar/RpcServerBun.js.map +0 -1
  492. package/lib/Sidecar/RpcServerNode.d.ts +0 -4
  493. package/lib/Sidecar/RpcServerNode.d.ts.map +0 -1
  494. package/lib/Sidecar/RpcServerNode.js +0 -39
  495. package/lib/Sidecar/RpcServerNode.js.map +0 -1
  496. package/lib/Sidecar/RpcServices.d.ts +0 -6
  497. package/lib/Sidecar/RpcServices.d.ts.map +0 -1
  498. package/lib/Sidecar/RpcServices.js +0 -29
  499. package/lib/Sidecar/RpcServices.js.map +0 -1
  500. package/lib/Trait.d.ts +0 -43
  501. package/lib/Trait.d.ts.map +0 -1
  502. package/lib/Trait.js +0 -17
  503. package/lib/Trait.js.map +0 -1
  504. package/lib/Util/LocalhostDns.d.ts +0 -23
  505. package/lib/Util/LocalhostDns.d.ts.map +0 -1
  506. package/lib/Util/LocalhostDns.js +0 -46
  507. package/lib/Util/LocalhostDns.js.map +0 -1
  508. package/lib/Util/assert-never.d.ts +0 -12
  509. package/lib/Util/assert-never.d.ts.map +0 -1
  510. package/lib/Util/assert-never.js +0 -11
  511. package/lib/Util/assert-never.js.map +0 -1
  512. package/lib/Util/class.d.ts +0 -3
  513. package/lib/Util/class.d.ts.map +0 -1
  514. package/lib/Util/class.js +0 -1
  515. package/lib/Util/class.js.map +0 -1
  516. package/lib/Util/ignore.d.ts +0 -40
  517. package/lib/Util/ignore.d.ts.map +0 -1
  518. package/lib/Util/ignore.js +0 -591
  519. package/lib/Util/ignore.js.map +0 -1
  520. package/lib/Util/instance.d.ts +0 -4
  521. package/lib/Util/instance.d.ts.map +0 -1
  522. package/lib/Util/instance.js +0 -1
  523. package/lib/Util/instance.js.map +0 -1
  524. package/lib/Util/pointer.d.ts +0 -5
  525. package/lib/Util/pointer.d.ts.map +0 -1
  526. package/lib/Util/pointer.js +0 -1
  527. package/lib/Util/pointer.js.map +0 -1
  528. package/lib/Util/schema-to-type.d.ts +0 -42
  529. package/lib/Util/schema-to-type.d.ts.map +0 -1
  530. package/lib/Util/schema-to-type.js +0 -364
  531. package/lib/Util/schema-to-type.js.map +0 -1
  532. package/lib/Util/todo.d.ts +0 -3
  533. package/lib/Util/todo.d.ts.map +0 -1
  534. package/lib/Util/todo.js +0 -3
  535. package/lib/Util/todo.js.map +0 -1
  536. package/lib/Variable.d.ts +0 -29
  537. package/lib/Variable.d.ts.map +0 -1
  538. package/lib/Variable.js +0 -9
  539. package/lib/Variable.js.map +0 -1
  540. package/src/Cloudflare/Local/Sidecar.ts +0 -81
  541. package/src/Cloudflare/Local/SidecarHandlers.ts +0 -491
  542. package/src/Cloudflare/Local/SidecarServer.ts +0 -70
  543. package/src/Secret.ts +0 -87
  544. package/src/Sidecar/Lock.ts +0 -66
  545. package/src/Sidecar/RpcClient.ts +0 -142
  546. package/src/Sidecar/RpcHandler.ts +0 -205
  547. package/src/Sidecar/RpcPaths.ts +0 -39
  548. package/src/Sidecar/RpcServer.ts +0 -153
  549. package/src/Sidecar/RpcServerBun.ts +0 -41
  550. package/src/Sidecar/RpcServerNode.ts +0 -51
  551. package/src/Sidecar/RpcServices.ts +0 -48
  552. package/src/Trait.ts +0 -105
  553. package/src/Util/LocalhostDns.ts +0 -52
  554. package/src/Util/assert-never.ts +0 -18
  555. package/src/Util/class.ts +0 -7
  556. package/src/Util/ignore.ts +0 -815
  557. package/src/Util/instance.ts +0 -9
  558. package/src/Util/pointer.ts +0 -5
  559. package/src/Util/schema-to-type.ts +0 -456
  560. package/src/Util/todo.ts +0 -4
  561. package/src/Variable.ts +0 -44
package/bin/exec.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as ConfigProvider from "effect/ConfigProvider";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
- import * as S from "effect/Schema";
4
+ import * as Schema from "effect/Schema";
5
5
  import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
6
6
  import * as EffectContext from "effect/Context";
7
7
  import * as FileSystem from "effect/FileSystem";
@@ -11,20 +11,29 @@ import * as Redacted from "effect/Redacted";
11
11
  import path from "pathe";
12
12
  import * as Config from "effect/Config";
13
13
  import os from "node:os";
14
- import * as Console from "effect/Console";
14
+ import { newWebSocketRpcSession } from "capnweb";
15
+ import * as Cache from "effect/Cache";
16
+ import * as HttpBody from "effect/unstable/http/HttpBody";
17
+ import * as HttpClient from "effect/unstable/http/HttpClient";
15
18
  import * as Logger from "effect/Logger";
16
19
  import * as Option from "effect/Option";
17
- import * as Command from "effect/unstable/cli/Command";
18
- import * as Flag from "effect/unstable/cli/Flag";
19
- import * as Data from "effect/Data";
20
- import * as Cause from "effect/Cause";
20
+ import "effect/Scope";
21
21
  import * as Deferred from "effect/Deferred";
22
- import { pipe } from "effect/Function";
22
+ import * as Semaphore from "effect/Semaphore";
23
+ import * as Data from "effect/Data";
24
+ import * as Duration from "effect/Duration";
25
+ import { flow, pipe } from "effect/Function";
23
26
  import { SingleShotGen } from "effect/Utils";
24
27
  import { pipeArguments } from "effect/Pipeable";
25
- import "effect/Scope";
26
- import * as Duration from "effect/Duration";
28
+ import "effect/Predicate";
29
+ import "effect/Record";
30
+ import * as Cause from "effect/Cause";
27
31
  import * as Exit from "effect/Exit";
32
+ import * as Stream from "effect/Stream";
33
+ import * as NodeUtil from "node:util";
34
+ import * as Console from "effect/Console";
35
+ import * as Command from "effect/unstable/cli/Command";
36
+ import * as Flag from "effect/unstable/cli/Flag";
28
37
  import * as Metric from "effect/Metric";
29
38
  import { createHash } from "node:crypto";
30
39
  import * as Argument from "effect/unstable/cli/Argument";
@@ -134,7 +143,9 @@ const CredentialsStoreLive = Layer.effect(CredentialsStore, Effect.gen(function*
134
143
  }));
135
144
  const write = (profile$1, provider, credentials) => {
136
145
  const filePath = credentialsFilePath(profile$1, provider);
137
- return fs.makeDirectory(path.dirname(filePath), { recursive: true }).pipe(Effect.flatMap(() => fs.writeFileString(filePath, JSON.stringify(credentials, null, 2))));
146
+ return fs.makeDirectory(path.dirname(filePath), { recursive: true }).pipe(Effect.flatMap(() => {
147
+ return fs.writeFileString(filePath, JSON.stringify(credentials, null, 2));
148
+ }));
138
149
  };
139
150
  const remove_ = (profile$1, provider) => fs.remove(credentialsFilePath(profile$1, provider)).pipe(Effect.catch(() => Effect.void));
140
151
  const deleteProfile = (profile$1) => fs.remove(profileCredentialsDirPath(profile$1), { recursive: true }).pipe(Effect.catch(() => Effect.void));
@@ -146,125 +157,6 @@ const CredentialsStoreLive = Layer.effect(CredentialsStore, Effect.gen(function*
146
157
  };
147
158
  }));
148
159
 
149
- //#endregion
150
- //#region lib/Util/PlatformServices.js
151
- const isBun = typeof Bun !== "undefined";
152
- const PlatformServices = Effect.promise(async () => {
153
- if (isBun) {
154
- const [BunServices, BunSocket] = await Promise.all([import("@effect/platform-bun/BunServices"), import("@effect/platform-bun/BunSocket")]);
155
- return Layer.merge(BunServices.layer, BunSocket.layerWebSocketConstructor);
156
- } else {
157
- const [NodeServices, NodeSocket] = await Promise.all([import("@effect/platform-node/NodeServices"), import("@effect/platform-node/NodeSocket")]);
158
- return Layer.merge(NodeServices.layer, NodeSocket.layerWebSocketConstructor);
159
- }
160
- }).pipe(Layer.unwrap);
161
- const runMain = (effect, options) => {
162
- if (isBun) import("@effect/platform-bun/BunRuntime").then((BunRuntime) => BunRuntime.runMain(effect, options));
163
- else import("@effect/platform-node/NodeRuntime").then((NodeRuntime) => NodeRuntime.runMain(effect, options));
164
- };
165
-
166
- //#endregion
167
- //#region lib/AdoptPolicy.js
168
- /**
169
- * AdoptPolicy controls whether the engine should "adopt" pre-existing cloud
170
- * resources that conflict with this stack instead of failing.
171
- *
172
- * The engine always calls a provider's `read` lifecycle operation when there
173
- * is no prior state and `read` is implemented. The provider's job is to
174
- * report two things:
175
- *
176
- * 1. Whether the resource exists (returns attributes vs. `undefined`).
177
- * 2. Whether *we* own it (plain attributes vs. {@link Unowned}-branded).
178
- *
179
- * The engine then routes:
180
- *
181
- * | `read` outcome | `adopt: false` | `adopt: true` |
182
- * | ------------------- | -------------- | ----------------- |
183
- * | undefined | create | create |
184
- * | owned (plain attrs) | silent adopt | silent adopt |
185
- * | {@link Unowned} | fail | takeover (adopt) |
186
- *
187
- * "Owned" means a provider has affirmatively determined the resource was
188
- * created by this stack/stage/logical-id (typically by inspecting tags or
189
- * naming conventions). Resources without ownership semantics simply always
190
- * return plain attrs — they are treated as owned by default, so silent
191
- * adoption is the norm and `--adopt` is unnecessary.
192
- *
193
- * The policy can be overridden per-effect via {@link adopt} — most commonly
194
- * applied at the resource or stack scope.
195
- */
196
- var AdoptPolicy = class extends EffectContext.Service()("AdoptPolicy") {};
197
- /**
198
- * Engine-raised failure produced when `read` reports an existing resource
199
- * marked as {@link Unowned} and `adopt` is `false`. Surface this to the user
200
- * to indicate they should either re-tag the cloud resource, pick a different
201
- * physical name, or re-run with `--adopt` (or `adopt(true)`) to force a
202
- * takeover.
203
- */
204
- var OwnedBySomeoneElse = class extends Data.TaggedError("OwnedBySomeoneElse") {};
205
- /**
206
- * Private symbol used to brand attribute objects returned by `read` as
207
- * "exists in cloud, but not owned by this stack/stage/logical-id".
208
- *
209
- * Deliberately *not* registered via `Symbol.for` — the brand is an
210
- * engine-internal routing hint and must not be observable or
211
- * forgeable from outside this module. The engine strips it before any
212
- * state persistence (see {@link stripUnowned}) so it never leaks into
213
- * the state store, JSON serialization, or downstream `Output`s.
214
- */
215
- const UnownedTag = Symbol("alchemy/Unowned");
216
- /**
217
- * Brand a `read` return value as belonging to a different owner.
218
- *
219
- * Use this in a provider's `read` implementation when the resource exists in
220
- * the cloud but a positive ownership check (e.g. tag inspection) shows it
221
- * was *not* created by this stack/stage/logical-id:
222
- *
223
- * ```ts
224
- * read: Effect.fnUntraced(function* ({ id, output, olds }) {
225
- * const settings = yield* getScriptSettings({ ... }).pipe(
226
- * Effect.catchTag("WorkerNotFound", () => Effect.succeed(undefined)),
227
- * );
228
- * if (!settings) return undefined;
229
- *
230
- * const attrs = { workerName, ...buildAttrs(settings) };
231
- * return hasAlchemyWorkerTags(id, settings.tags) ? attrs : Unowned(attrs);
232
- * }),
233
- * ```
234
- *
235
- * The returned value is structurally still `T` — there is no wrapper to
236
- * unwrap. The brand is a non-enumerable symbol that the engine inspects
237
- * during planning to decide whether to take over (`adopt: true`) or fail
238
- * loudly (`adopt: false`).
239
- *
240
- * Resources without ownership semantics should simply return plain attrs —
241
- * the engine treats them as owned and silent adoption is the default.
242
- */
243
- const Unowned = Object.assign((attrs) => {
244
- const cloned = { ...attrs };
245
- Object.defineProperty(cloned, UnownedTag, {
246
- value: true,
247
- enumerable: false,
248
- writable: false,
249
- configurable: false
250
- });
251
- return cloned;
252
- }, { is: (value) => typeof value === "object" && value !== null && value[UnownedTag] === true });
253
- /**
254
- * Strip the {@link Unowned} brand from an attributes object before persisting
255
- * it — state should not carry per-deploy ownership-routing metadata.
256
- *
257
- * The brand is intentionally non-enumerable, so a plain spread already
258
- * drops it; the additional `delete` is defense-in-depth in case a future
259
- * change makes the descriptor enumerable. Always returns a fresh object
260
- * (never mutates the input).
261
- */
262
- const stripUnowned = (attrs) => {
263
- const out = { ...attrs };
264
- if (UnownedTag in out) delete out[UnownedTag];
265
- return out;
266
- };
267
-
268
160
  //#endregion
269
161
  //#region lib/Artifacts.js
270
162
  /**
@@ -325,6 +217,11 @@ const makeScopedArtifacts = (store, fqn) => {
325
217
  */
326
218
  const ensureArtifactStore = (effect) => Effect.serviceOption(ArtifactStore).pipe(Effect.map(Option.getOrUndefined), Effect.flatMap((existing) => effect.pipe(Effect.provideService(ArtifactStore, existing ?? createArtifactStore()))));
327
219
 
220
+ //#endregion
221
+ //#region lib/Auth/AuthProvider.js
222
+ const interactiveMutex = Semaphore.makeUnsafe(1);
223
+ var AuthProviders = class extends EffectContext.Service()("AuthProviders") {};
224
+
328
225
  //#endregion
329
226
  //#region lib/Cli/Cli.js
330
227
  var Cli = class extends EffectContext.Service()("CLI") {};
@@ -415,97 +312,6 @@ const tryFindProviderByType = Effect.fnUntraced(function* (resourceType) {
415
312
  return Option.none();
416
313
  });
417
314
 
418
- //#endregion
419
- //#region lib/Auth/AuthProvider.js
420
- var AuthProviders = class extends EffectContext.Service()("AuthProviders") {};
421
-
422
- //#endregion
423
- //#region lib/Stage.js
424
- var Stage = class extends EffectContext.Service()("Stage") {};
425
-
426
- //#endregion
427
- //#region lib/Util/ConfigProvider.js
428
- const loadConfigProvider = (envFile$1) => {
429
- if (Option.isSome(envFile$1)) return ConfigProvider.fromDotEnv({ path: envFile$1.value }).pipe(Effect.map((dotEnv) => ConfigProvider.orElse(dotEnv, ConfigProvider.fromEnv())));
430
- return Effect.gen(function* () {
431
- if (!(yield* (yield* FileSystem.FileSystem).exists(".env"))) return ConfigProvider.fromEnv();
432
- return ConfigProvider.orElse(yield* ConfigProvider.fromDotEnv({ path: ".env" }), ConfigProvider.fromEnv());
433
- });
434
- };
435
-
436
- //#endregion
437
- //#region lib/Util/effect.js
438
- const effectClass = ((impl) => impl === void 0 ? (innerImpl) => effectClass(innerImpl) : Object.assign(class {
439
- static asEffect() {
440
- return impl;
441
- }
442
- static [Symbol.iterator]() {
443
- return new SingleShotGen(this.asEffect());
444
- }
445
- static pipe(...fns) {
446
- return pipeArguments(this, fns);
447
- }
448
- }, impl));
449
- const taggedFunction = (tag$1, fn) => {
450
- const overrides = {
451
- asEffect: () => tag$1,
452
- [Symbol.iterator]: () => tag$1[Symbol.iterator](),
453
- pipe: (...fns) => pipeArguments(tag$1, fns),
454
- toString: () => `${tag$1.toString()}.${fn.name}`
455
- };
456
- return new Proxy(fn, {
457
- get: (target, prop, receiver) => Reflect.has(overrides, prop) ? Reflect.get(overrides, prop, receiver) : Reflect.has(target, prop) ? Reflect.get(target, prop, receiver) : Reflect.get(tag$1, prop, tag$1),
458
- has: (target, prop) => Reflect.has(overrides, prop) || Reflect.has(target, prop) || Reflect.has(tag$1, prop)
459
- });
460
- };
461
-
462
- //#endregion
463
- //#region lib/Util/FileLogger.js
464
- const fileLogger = Effect.fnUntraced(function* (...segments) {
465
- const { dotAlchemy } = yield* AlchemyContext;
466
- const fs = yield* FileSystem.FileSystem;
467
- const path$1 = yield* Path;
468
- const logFile = path$1.join(dotAlchemy, "log", ...segments);
469
- yield* fs.makeDirectory(path$1.dirname(logFile), { recursive: true });
470
- return yield* Logger.formatLogFmt.pipe(Logger.toFile(logFile, { flag: "a" }));
471
- });
472
-
473
- //#endregion
474
- //#region lib/Stack.js
475
- const Stack = Object.assign(taggedFunction(EffectContext.Service()("Stack"), (stackName, options, eff) => {
476
- if (!stackName) return (stackName$1) => Object.assign(stackRef(stackName$1).pipe(effectClass), {
477
- stage: createStageProxy(stackName$1),
478
- make: (options$1, eff$1) => Stack(stackName$1, options$1, eff$1)
479
- });
480
- return eff.pipe(make$1({
481
- name: stackName,
482
- ...options
483
- }), (eff$1) => Object.assign(eff$1, { stage: createStageProxy(stackName) }));
484
- }));
485
- const createStageProxy = (stackName) => new Proxy({}, { get: (_, stage$1) => stackRef(stackName, { stage: stage$1 }) });
486
- const StackName = Stack.use((stack) => Effect.succeed(stack.name));
487
- const make$1 = (options) => (effect) => Effect.scope.pipe(Effect.flatMap((scope) => {
488
- if (options.state == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a state store. Add a \`state\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(),\n state: Cloudflare.state(), // <-- required\n }, ...)\nSee https://v2.alchemy.run/concepts/state-store for available state stores.`));
489
- if (options.providers == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a providers layer. Add a \`providers\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(), // <-- required\n state: Cloudflare.state(),\n }, ...)`));
490
- return options.providers.pipe(Layer.provideMerge(options.state), Layer.provideMerge(Layer.effect(Stack, Stage.pipe(Effect.map((stage$1) => options.stack ?? {
491
- name: options.name,
492
- stage: stage$1,
493
- resources: {},
494
- bindings: {},
495
- actions: {}
496
- })))), Layer.buildWithScope(scope));
497
- }), Effect.flatMap((context) => Effect.all([
498
- effect,
499
- Stack,
500
- Effect.context()
501
- ]).pipe(Effect.map(([output, stack, services$1]) => ({
502
- ...stack,
503
- output,
504
- services: EffectContext.merge(services$1, context)
505
- })), Effect.provideContext(context))));
506
- const CurrentStack = Effect.serviceOption(Stack).pipe(Effect.map(Option.getOrUndefined));
507
- const platform = Layer.mergeAll(PlatformServices, FetchHttpClient.layer, Logger.layer([fileLogger("out")], { mergeWithExisting: true }), Layer.provide(ProfileLive, PlatformServices), Layer.provide(CredentialsStoreLive, PlatformServices));
508
-
509
315
  //#endregion
510
316
  //#region lib/Resource.js
511
317
  const isResource = (value) => {
@@ -515,6 +321,18 @@ const isResource = (value) => {
515
321
  //#endregion
516
322
  //#region lib/RuntimeContext.js
517
323
  /**
324
+ * Canonicalize a logical key into a key that is safe to use as the name of an
325
+ * environment variable / binding (`[a-zA-Z][a-zA-Z0-9_]*`).
326
+ *
327
+ * `RuntimeContext.set`/`get` are dumb key/value stores: they read and write the
328
+ * key **verbatim**. It is the *caller's* responsibility to hand them a
329
+ * canonical key, since the caller is the one that knows the logical key may
330
+ * contain `.`/`-` (e.g. a dotted config name from `Platform`, or an
331
+ * `Output.toString()` like `"QueueSinkQueue.queueUrl"`). Callers run the key
332
+ * through this before calling `set`/`get` so both sides agree.
333
+ */
334
+ const sanitizeKey = (key) => key.replaceAll(/[^a-zA-Z0-9]/g, "_");
335
+ /**
518
336
  * Context of the runtime environment.
519
337
  *
520
338
  * E.g. the context of a running Worker, Task, Process, Function
@@ -522,6 +340,10 @@ const isResource = (value) => {
522
340
  var RuntimeContext = class extends EffectContext.Service()("RuntimeContext") {};
523
341
  const CurrentRuntimeContext = Effect.serviceOption(RuntimeContext).pipe(Effect.map(Option.getOrUndefined));
524
342
 
343
+ //#endregion
344
+ //#region lib/Stage.js
345
+ var Stage = class extends EffectContext.Service()("Stage") {};
346
+
525
347
  //#endregion
526
348
  //#region lib/State/State.js
527
349
  const isActionState = (s) => !!s && s.kind === "action";
@@ -556,7 +378,8 @@ var BaseExpr = class {
556
378
  return this.bind(this.toString());
557
379
  }
558
380
  bind(id) {
559
- return RuntimeContext.pipe(Effect.flatMap((ctx) => Effect.map(ctx.set(id, this), (key) => ctx.get(key))));
381
+ const key = sanitizeKey(id);
382
+ return RuntimeContext.pipe(Effect.flatMap((ctx) => Effect.map(ctx.set(key, this), (k) => ctx.get(k))));
560
383
  }
561
384
  pipe(...fns) {
562
385
  return pipe(this, ...fns);
@@ -805,6 +628,7 @@ const evaluate = (expr, upstream$1) => Effect.gen(function* () {
805
628
  }
806
629
  if (Array.isArray(expr)) return yield* Effect.all(expr.map((item) => evaluate(item, upstream$1)));
807
630
  else if (Redacted.isRedacted(expr)) return expr;
631
+ else if (Duration.isDuration(expr)) return expr;
808
632
  else if (typeof expr === "object" && expr !== null) return Object.fromEntries(yield* Effect.all(Object.entries(expr).map(([key, value]) => evaluate(value, upstream$1).pipe(Effect.map((value$1) => [key, value$1])))));
809
633
  return expr;
810
634
  });
@@ -839,6 +663,282 @@ const toObject = (acc, v) => ({
839
663
  ...v
840
664
  });
841
665
 
666
+ //#endregion
667
+ //#region lib/Util/ConfigProvider.js
668
+ const loadConfigProvider = (envFile$1) => {
669
+ if (Option.isSome(envFile$1)) return ConfigProvider.fromDotEnv({ path: envFile$1.value }).pipe(Effect.map((dotEnv) => ConfigProvider.orElse(dotEnv, ConfigProvider.fromEnv())));
670
+ return Effect.gen(function* () {
671
+ if (!(yield* (yield* FileSystem.FileSystem).exists(".env"))) return ConfigProvider.fromEnv();
672
+ return ConfigProvider.orElse(yield* ConfigProvider.fromDotEnv({ path: ".env" }), ConfigProvider.fromEnv());
673
+ });
674
+ };
675
+
676
+ //#endregion
677
+ //#region lib/Util/effect.js
678
+ const effectClass = ((impl) => impl === void 0 ? (innerImpl) => effectClass(innerImpl) : Object.assign(class {
679
+ static asEffect() {
680
+ return impl;
681
+ }
682
+ static [Symbol.iterator]() {
683
+ return new SingleShotGen(this.asEffect());
684
+ }
685
+ static pipe(...fns) {
686
+ return pipeArguments(this, fns);
687
+ }
688
+ }, impl));
689
+ const taggedFunction = (tag$1, fn) => {
690
+ const overrides = {
691
+ asEffect: () => tag$1,
692
+ [Symbol.iterator]: () => tag$1[Symbol.iterator](),
693
+ pipe: (...fns) => pipeArguments(tag$1, fns),
694
+ toString: () => `${tag$1.toString()}.${fn.name}`
695
+ };
696
+ return new Proxy(fn, {
697
+ get: (target, prop, receiver) => Reflect.has(overrides, prop) ? Reflect.get(overrides, prop, receiver) : Reflect.has(target, prop) ? Reflect.get(target, prop, receiver) : Reflect.get(tag$1, prop, tag$1),
698
+ has: (target, prop) => Reflect.has(overrides, prop) || Reflect.has(target, prop) || Reflect.has(tag$1, prop)
699
+ });
700
+ };
701
+
702
+ //#endregion
703
+ //#region lib/Util/FileLogger.js
704
+ const fileLogger = Effect.fnUntraced(function* (...segments) {
705
+ const { dotAlchemy } = yield* AlchemyContext;
706
+ const fs = yield* FileSystem.FileSystem;
707
+ const path$1 = yield* Path;
708
+ const logFile = path$1.join(dotAlchemy, "log", ...segments);
709
+ yield* fs.makeDirectory(path$1.dirname(logFile), { recursive: true });
710
+ return yield* Logger.formatLogFmt.pipe(Logger.toFile(logFile, { flag: "a" }));
711
+ });
712
+
713
+ //#endregion
714
+ //#region lib/Util/PlatformServices.js
715
+ const isBun = typeof Bun !== "undefined";
716
+ /**
717
+ * Constructs a layer with different implementations for Bun and Node.
718
+ */
719
+ const platformLayer = (constructors) => Layer.unwrap(Effect.promise(async () => {
720
+ if (isBun) return await constructors.bun();
721
+ else return await constructors.node();
722
+ }));
723
+ const PlatformServices = platformLayer({
724
+ bun: async () => {
725
+ const [BunServices, BunSocket] = await Promise.all([import("@effect/platform-bun/BunServices"), import("@effect/platform-bun/BunSocket")]);
726
+ return Layer.merge(BunServices.layer, BunSocket.layerWebSocketConstructor);
727
+ },
728
+ node: async () => {
729
+ const [NodeServices, NodeSocket] = await Promise.all([import("@effect/platform-node/NodeServices"), import("@effect/platform-node/NodeSocket")]);
730
+ return Layer.merge(NodeServices.layer, NodeSocket.layerWebSocketConstructor);
731
+ }
732
+ });
733
+ const runMain = (effect, options) => {
734
+ if (isBun) import("@effect/platform-bun/BunRuntime").then((BunRuntime) => BunRuntime.runMain(effect, options));
735
+ else import("@effect/platform-node/NodeRuntime").then((NodeRuntime) => NodeRuntime.runMain(effect, options));
736
+ };
737
+
738
+ //#endregion
739
+ //#region lib/Stack.js
740
+ const Stack = Object.assign(taggedFunction(EffectContext.Service()("Stack"), (stackName, options, eff) => {
741
+ if (!stackName) return (stackName$1) => Object.assign(stackRef(stackName$1).pipe(effectClass), {
742
+ stage: createStageProxy(stackName$1),
743
+ make: (options$1, eff$1) => Stack(stackName$1, options$1, eff$1)
744
+ });
745
+ return eff.pipe(make$2({
746
+ name: stackName,
747
+ ...options
748
+ }), (eff$1) => Object.assign(eff$1, { stage: createStageProxy(stackName) }));
749
+ }));
750
+ const createStageProxy = (stackName) => new Proxy({}, { get: (_, stage$1) => stackRef(stackName, { stage: stage$1 }) });
751
+ const StackName = Stack.use((stack) => Effect.succeed(stack.name));
752
+ const make$2 = (options) => (effect) => Effect.scope.pipe(Effect.flatMap((scope) => {
753
+ if (options.state == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a state store. Add a \`state\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(),\n state: Cloudflare.state(), // <-- required\n }, ...)\nSee https://v2.alchemy.run/concepts/state-store for available state stores.`));
754
+ if (options.providers == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options.name}" is missing a providers layer. Add a \`providers\` layer to the stack options, e.g.:\n Alchemy.Stack("${options.name}", {\n providers: Cloudflare.providers(), // <-- required\n state: Cloudflare.state(),\n }, ...)`));
755
+ return options.providers.pipe(Layer.provideMerge(options.state), Layer.provideMerge(Layer.effect(Stack, Stage.pipe(Effect.map((stage$1) => options.stack ?? {
756
+ name: options.name,
757
+ stage: stage$1,
758
+ resources: {},
759
+ bindings: {},
760
+ actions: {}
761
+ })))), Layer.buildWithScope(scope));
762
+ }), Effect.flatMap((context) => Effect.all([
763
+ effect,
764
+ Stack,
765
+ Effect.context()
766
+ ]).pipe(Effect.map(([output, stack, services$1]) => ({
767
+ ...stack,
768
+ output,
769
+ services: EffectContext.merge(services$1, context)
770
+ })), Effect.provideContext(context))));
771
+ const CurrentStack = Effect.serviceOption(Stack).pipe(Effect.map(Option.getOrUndefined));
772
+ const platform = Layer.mergeAll(PlatformServices, FetchHttpClient.layer, Logger.layer([fileLogger("out")], { mergeWithExisting: true }), Layer.provide(ProfileLive, PlatformServices), Layer.provide(CredentialsStoreLive, PlatformServices));
773
+
774
+ //#endregion
775
+ //#region lib/Local/RpcSerialization.js
776
+ const unwrapRpcHandlers = (handlers, streamKeys) => {
777
+ return Object.fromEntries(Object.entries(handlers).map(([key, value]) => [key, typeof value === "function" ? streamKeys?.includes(key) ? unwrapRpcStreamHandler(value) : unwrapRpcEffectHandler(value) : typeof value === "object" && value !== null ? unwrapRpcHandlers(value) : value]));
778
+ };
779
+ const serializeError = Schema.encodeSync(Schema.Defect);
780
+ const unwrapRpcEffectHandler = (handler) => flow((...args) => serializeRpcArgs(args), (args) => Effect.promise(() => handler(args)), Effect.flatMap((exit) => {
781
+ if (exit._tag === "Success") return Exit.succeed(exit.value);
782
+ return Exit.failCause(Cause.fromReasons(exit.cause.map((reason) => {
783
+ switch (reason._tag) {
784
+ case "Fail": return Cause.makeFailReason(reason.error);
785
+ case "Die": return Cause.makeDieReason(reason.defect);
786
+ case "Interrupt": return Cause.makeInterruptReason(reason.fiberId);
787
+ }
788
+ })));
789
+ }));
790
+ const unwrapRpcStreamHandler = (handler) => flow((...args) => serializeRpcArgs(args), (args) => handler(args), (stream) => Stream.fromReadableStream({
791
+ evaluate: () => stream,
792
+ onError: (error) => error
793
+ }));
794
+ const serializeRpcArgs = (value) => {
795
+ if (Redacted.isRedacted(value)) return {
796
+ _tag: "Redacted",
797
+ value: Redacted.value(value)
798
+ };
799
+ if (isOutput(value)) return {
800
+ _tag: "Output",
801
+ description: NodeUtil.inspect(value)
802
+ };
803
+ if (typeof value === "function") return null;
804
+ if (Array.isArray(value)) return value.map(serializeRpcArgs);
805
+ if (value && typeof value === "object" && !("toJSON" in value)) return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, serializeRpcArgs(child)]));
806
+ return value;
807
+ };
808
+
809
+ //#endregion
810
+ //#region lib/Local/RpcProviderProxy.js
811
+ var RpcProviderProxy = class extends EffectContext.Service()("alchemy/Local/RpcProviderProxy") {};
812
+ const SPAWNER_URL_ENV_KEY = "ALCHEMY_RPC_SPAWNER_URL";
813
+ const make$1 = Effect.fnUntraced(function* (spawnerUrl) {
814
+ const client = yield* HttpClient.HttpClient;
815
+ const getSession = Effect.fnUntraced(function* (serverEntryUrl) {
816
+ const alchemyContext = yield* AlchemyContext;
817
+ const stack = yield* Stack;
818
+ const payload = {
819
+ serverEntryUrl,
820
+ alchemyContext,
821
+ stack: {
822
+ name: stack.name,
823
+ stage: stack.stage
824
+ }
825
+ };
826
+ return newWebSocketRpcSession(yield* (yield* client.post(spawnerUrl, { body: yield* HttpBody.json(payload) })).text);
827
+ }, (effect, serverEntryUrl) => Effect.catch(effect, (error) => Effect.die(new Error(`Failed to create provider RPC session for "${serverEntryUrl}"`, { cause: error }))));
828
+ const cache = yield* Cache.make({
829
+ lookup: getSession,
830
+ capacity: Infinity,
831
+ requireServicesAt: "lookup"
832
+ });
833
+ return RpcProviderProxy.of({ get: Effect.fnUntraced(function* (mainUrl, providerName) {
834
+ const session = yield* cache.lookup(mainUrl);
835
+ return unwrapRpcHandlers(yield* Effect.promise(() => session.getProvider(providerName)), ["tail"]);
836
+ }) });
837
+ });
838
+ const fromEnv = () => Layer.effect(RpcProviderProxy, Config.string(SPAWNER_URL_ENV_KEY).pipe(Effect.flatMap(make$1)));
839
+
840
+ //#endregion
841
+ //#region lib/AdoptPolicy.js
842
+ /**
843
+ * AdoptPolicy controls whether the engine should "adopt" pre-existing cloud
844
+ * resources that conflict with this stack instead of failing.
845
+ *
846
+ * The engine always calls a provider's `read` lifecycle operation when there
847
+ * is no prior state and `read` is implemented. The provider's job is to
848
+ * report two things:
849
+ *
850
+ * 1. Whether the resource exists (returns attributes vs. `undefined`).
851
+ * 2. Whether *we* own it (plain attributes vs. {@link Unowned}-branded).
852
+ *
853
+ * The engine then routes:
854
+ *
855
+ * | `read` outcome | `adopt: false` | `adopt: true` |
856
+ * | ------------------- | -------------- | ----------------- |
857
+ * | undefined | create | create |
858
+ * | owned (plain attrs) | silent adopt | silent adopt |
859
+ * | {@link Unowned} | fail | takeover (adopt) |
860
+ *
861
+ * "Owned" means a provider has affirmatively determined the resource was
862
+ * created by this stack/stage/logical-id (typically by inspecting tags or
863
+ * naming conventions). Resources without ownership semantics simply always
864
+ * return plain attrs — they are treated as owned by default, so silent
865
+ * adoption is the norm and `--adopt` is unnecessary.
866
+ *
867
+ * The policy can be overridden per-effect via {@link adopt} — most commonly
868
+ * applied at the resource or stack scope.
869
+ */
870
+ var AdoptPolicy = class extends EffectContext.Service()("AdoptPolicy") {};
871
+ /**
872
+ * Engine-raised failure produced when `read` reports an existing resource
873
+ * marked as {@link Unowned} and `adopt` is `false`. Surface this to the user
874
+ * to indicate they should either re-tag the cloud resource, pick a different
875
+ * physical name, or re-run with `--adopt` (or `adopt(true)`) to force a
876
+ * takeover.
877
+ */
878
+ var OwnedBySomeoneElse = class extends Data.TaggedError("OwnedBySomeoneElse") {};
879
+ /**
880
+ * Private symbol used to brand attribute objects returned by `read` as
881
+ * "exists in cloud, but not owned by this stack/stage/logical-id".
882
+ *
883
+ * Deliberately *not* registered via `Symbol.for` — the brand is an
884
+ * engine-internal routing hint and must not be observable or
885
+ * forgeable from outside this module. The engine strips it before any
886
+ * state persistence (see {@link stripUnowned}) so it never leaks into
887
+ * the state store, JSON serialization, or downstream `Output`s.
888
+ */
889
+ const UnownedTag = Symbol("alchemy/Unowned");
890
+ /**
891
+ * Brand a `read` return value as belonging to a different owner.
892
+ *
893
+ * Use this in a provider's `read` implementation when the resource exists in
894
+ * the cloud but a positive ownership check (e.g. tag inspection) shows it
895
+ * was *not* created by this stack/stage/logical-id:
896
+ *
897
+ * ```ts
898
+ * read: Effect.fnUntraced(function* ({ id, output, olds }) {
899
+ * const settings = yield* getScriptSettings({ ... }).pipe(
900
+ * Effect.catchTag("WorkerNotFound", () => Effect.succeed(undefined)),
901
+ * );
902
+ * if (!settings) return undefined;
903
+ *
904
+ * const attrs = { workerName, ...buildAttrs(settings) };
905
+ * return hasAlchemyWorkerTags(id, settings.tags) ? attrs : Unowned(attrs);
906
+ * }),
907
+ * ```
908
+ *
909
+ * The returned value is structurally still `T` — there is no wrapper to
910
+ * unwrap. The brand is a non-enumerable symbol that the engine inspects
911
+ * during planning to decide whether to take over (`adopt: true`) or fail
912
+ * loudly (`adopt: false`).
913
+ *
914
+ * Resources without ownership semantics should simply return plain attrs —
915
+ * the engine treats them as owned and silent adoption is the default.
916
+ */
917
+ const Unowned = Object.assign((attrs) => {
918
+ const cloned = { ...attrs };
919
+ Object.defineProperty(cloned, UnownedTag, {
920
+ value: true,
921
+ enumerable: false,
922
+ writable: false,
923
+ configurable: false
924
+ });
925
+ return cloned;
926
+ }, { is: (value) => typeof value === "object" && value !== null && value[UnownedTag] === true });
927
+ /**
928
+ * Strip the {@link Unowned} brand from an attributes object before persisting
929
+ * it — state should not carry per-deploy ownership-routing metadata.
930
+ *
931
+ * The brand is intentionally non-enumerable, so a plain spread already
932
+ * drops it; the additional `delete` is defense-in-depth in case a future
933
+ * change makes the descriptor enumerable. Always returns a fresh object
934
+ * (never mutates the input).
935
+ */
936
+ const stripUnowned = (attrs) => {
937
+ const out = { ...attrs };
938
+ if (UnownedTag in out) delete out[UnownedTag];
939
+ return out;
940
+ };
941
+
842
942
  //#endregion
843
943
  //#region lib/Diff.js
844
944
  const isResolved = (value) => !_hasUnresolved(value);
@@ -856,6 +956,17 @@ const canonicalize = (value, stripNullish) => {
856
956
  if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).filter(([, nested]) => !stripNullish || nested != null).sort(([a], [b]) => a.localeCompare(b)).map(([key, nested]) => [key, canonicalize(nested, stripNullish)]));
857
957
  return value;
858
958
  };
959
+ /**
960
+ * Collapse bindings that share the same `sid`, keeping the last occurrence.
961
+ *
962
+ * The same binding can be recorded more than once on a target resource — e.g.
963
+ * a KV namespace bound to both a Worker and a Workflow ends up pushed twice to
964
+ * `stack.bindings[fqn]`. `diffBindings` already collapses these implicitly via
965
+ * its `Map` keyed by `sid`, so the `reconcile` path never observes duplicates.
966
+ * Use this helper to give a provider's `diff` handler the same de-duplicated
967
+ * binding set, keeping plan-time hashing consistent with deploy-time.
968
+ */
969
+ const dedupeBindings = (bindings) => Array.from(new Map(bindings.map((b) => [b.sid, b])).values());
859
970
  const diffBindings = (oldBindings, newBindings) => {
860
971
  const oldMap = new Map(oldBindings.map((b) => [b.sid, b]));
861
972
  const newMap = new Map(newBindings.map((b) => [b.sid, b]));
@@ -888,7 +999,7 @@ const generateInstanceId = () => Effect.sync(() => {
888
999
 
889
1000
  //#endregion
890
1001
  //#region lib/Util/types.js
891
- const asEffect = (effect) => Effect.isEffect(effect) ? effect : Effect.succeed(effect);
1002
+ const asEffect = (effect) => typeof effect?.asEffect === "function" ? effect.asEffect() : Effect.isEffect(effect) ? effect : Effect.succeed(effect);
892
1003
 
893
1004
  //#endregion
894
1005
  //#region lib/Telemetry/Metrics.js
@@ -1096,7 +1207,7 @@ const make = (stack, options = {}) => Effect.gen(function* () {
1096
1207
  if (!oldState || oldState.status === "creating") return resourceExpr;
1097
1208
  const oldProps = oldState.status === "updating" ? oldState.old.props : oldState.props;
1098
1209
  const oldBindings = oldState.bindings ?? [];
1099
- const newBindings = stack.bindings[resource.FQN] ?? [];
1210
+ const newBindings = dedupeBindings(stack.bindings[resource.FQN] ?? []);
1100
1211
  const diff = yield* provider.diff ? provider.diff({
1101
1212
  id: resource.LogicalId,
1102
1213
  olds: oldProps,
@@ -1120,6 +1231,7 @@ const make = (stack, options = {}) => Effect.gen(function* () {
1120
1231
  if (!input) return input;
1121
1232
  else if (isExpr(input)) return yield* resolveOutput(input);
1122
1233
  else if (Redacted.isRedacted(input)) return input;
1234
+ else if (Duration.isDuration(input)) return input;
1123
1235
  else if (Array.isArray(input)) return yield* Effect.all(input.map(resolveInput), { concurrency: "unbounded" });
1124
1236
  else if (isResource(input)) return yield* resolveInput(yield* resolveOutput(of(input)));
1125
1237
  else if (typeof input === "object") return Object.fromEntries(yield* Effect.all(Object.entries(input).map(([key, value]) => resolveInput(value).pipe(Effect.map((value$1) => [key, value$1]))), { concurrency: "unbounded" }));
@@ -1212,7 +1324,7 @@ const make = (stack, options = {}) => Effect.gen(function* () {
1212
1324
  const fqn = resource.FQN;
1213
1325
  const news = yield* resolveInput(resource.Props);
1214
1326
  const downstream = newDownstreamDependencies[fqn] ?? [];
1215
- const newBindings = yield* resolveInput(stack.bindings[fqn] ?? []);
1327
+ const newBindings = dedupeBindings(yield* resolveInput(stack.bindings[fqn] ?? []));
1216
1328
  const persisted = yield* state.get({
1217
1329
  stack: stackName,
1218
1330
  stage: stage$1,
@@ -1621,7 +1733,7 @@ const executePlan = Effect.fnUntraced(function* (plan, tracker, terminalStatuses
1621
1733
  const ready = Object.fromEntries(yield* Effect.all(Object.keys(allNodes).map((fqn) => Effect.map(Deferred.make(), (d) => [fqn, d]))));
1622
1734
  const readyStable = Object.fromEntries(yield* Effect.all(Object.keys(allNodes).map((fqn) => Effect.map(Deferred.make(), (d) => [fqn, d]))));
1623
1735
  const getOutputs = () => Object.fromEntries(Object.entries(tracker).map(([fqn, t]) => [fqn, t.output]));
1624
- const waitForDeps = (fqns) => Effect.all(fqns.filter((fqn) => fqn in ready).map((fqn) => Deferred.await(ready[fqn])), { concurrency: "unbounded" });
1736
+ const waitForDeps = (fqns) => Effect.all(fqns.filter((fqn) => fqn in ready).map((fqn) => plan.cycleMembers.has(fqn) ? Deferred.await(ready[fqn]) : Deferred.await(readyStable[fqn])), { concurrency: "unbounded" });
1625
1737
  const waitForStableDeps = (fqns) => Effect.all(fqns.filter((fqn) => fqn in readyStable).map((fqn) => Deferred.await(readyStable[fqn])), { concurrency: "unbounded" });
1626
1738
  const failures = [];
1627
1739
  yield* Effect.all(Object.entries(allNodes).map(([fqn, node]) => node.kind === "action" ? executeActionNode(fqn, node, tracker, ready, readyStable, terminalStatuses, session, state, stackName, stage$1, getOutputs, waitForStableDeps, failures) : executeNode(fqn, node, tracker, ready, readyStable, terminalStatuses, session, state, stackName, stage$1, getOutputs, waitForDeps, failures, plan.cycleMembers.has(fqn))), { concurrency: "unbounded" });
@@ -2420,7 +2532,7 @@ var __rewriteRelativeImportExtension = void 0 && (void 0).__rewriteRelativeImpor
2420
2532
  };
2421
2533
  const USER = Config.string("USER").pipe(Config.orElse(() => Config.string("USERNAME")), Config.withDefault("unknown"));
2422
2534
  const STAGE = Config.string("stage").pipe(Config.option, (a) => a, Effect.map(Option.getOrUndefined));
2423
- const stage = Flag.string("stage").pipe(Flag.withSchema(S.String.check(S.isPattern(/^[a-z0-9]+([-_a-z0-9]+)*$/gi))), Flag.withDescription("Stage to deploy to, defaults to dev_${USER}"), Flag.optional, Flag.map(Option.getOrUndefined), Flag.mapEffect(Effect.fn(function* (stage$1) {
2535
+ const stage = Flag.string("stage").pipe(Flag.withSchema(Schema.String.check(Schema.isPattern(/^[a-z0-9]+([-_a-z0-9]+)*$/gi))), Flag.withDescription("Stage to deploy to, defaults to dev_${USER}"), Flag.optional, Flag.map(Option.getOrUndefined), Flag.mapEffect(Effect.fn(function* (stage$1) {
2424
2536
  if (stage$1) return stage$1;
2425
2537
  return yield* STAGE.pipe(Effect.catch(() => Effect.fail(new CliError.MissingOption({ option: "stage" }))), Effect.flatMap((s) => s === void 0 ? USER.pipe(Effect.map((user) => `dev_${user}`), Effect.catch(() => Effect.succeed("unknown"))) : Effect.succeed(s)));
2426
2538
  })));
@@ -2451,26 +2563,55 @@ const resourceFilter = Flag.string("filter").pipe(Flag.withDescription("Comma-se
2451
2563
  * ```
2452
2564
  */
2453
2565
  const instrumentCommand = (command, attrs) => (handler) => (args) => handler(args).pipe(Effect.withSpan(`cli.${command}`, { attributes: attrs ? attrs(args) : {} }), recordCli(command));
2566
+ /**
2567
+ * Render a profile's stored credential entries the same way across
2568
+ * `alchemy login` and `alchemy profile show`: one `── Provider ──`
2569
+ * header per entry, then either the provider's own `prettyPrint` block
2570
+ * (preferred) or a JSON-style fallback when the provider isn't
2571
+ * registered in the supplied {@link AuthProviders} registry.
2572
+ */
2573
+ const printProfile = Effect.fn(function* (profile$1, stored, registry) {
2574
+ yield* Console.log(`Profile: ${profile$1}`);
2575
+ const names = Object.keys(stored).sort();
2576
+ if (names.length === 0) {
2577
+ yield* Console.log("(no providers configured)");
2578
+ return;
2579
+ }
2580
+ for (const name of names) {
2581
+ const cfg = stored[name];
2582
+ yield* Console.log("");
2583
+ yield* Console.log(`── ${name} ──`);
2584
+ const provider = registry[name];
2585
+ if (provider == null) {
2586
+ yield* Console.log(` method: ${cfg.method}`);
2587
+ const { method: _method,...rest } = cfg;
2588
+ for (const [k, v] of Object.entries(rest)) yield* Console.log(` ${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`);
2589
+ continue;
2590
+ }
2591
+ yield* provider.prettyPrint(profile$1, cfg);
2592
+ }
2593
+ });
2454
2594
  const importStack = Effect.fn(function* (main) {
2455
2595
  const path$1 = yield* Path$1.Path;
2456
- const stackEffect = (yield* Effect.promise(() => import(__rewriteRelativeImportExtension(path$1.resolve(process.cwd(), main))))).default;
2596
+ const url = import.meta.resolve(path$1.resolve(main));
2597
+ const stackEffect = (yield* Effect.promise(() => import(__rewriteRelativeImportExtension(url)))).default;
2457
2598
  if (!Effect.isEffect(stackEffect)) return yield* Effect.die(/* @__PURE__ */ new Error(`Main file '${main}' must export a default stack definition (export default Alchemy.Stack({...}))`));
2458
2599
  return stackEffect;
2459
2600
  });
2460
2601
 
2461
2602
  //#endregion
2462
2603
  //#region lib/Cli/commands/deploy.js
2463
- const ExecStackOptions = S.Struct({
2464
- main: S.String,
2465
- stage: S.String,
2466
- envFile: S.OptionFromOptional(S.String),
2467
- profile: S.optional(S.String),
2468
- dryRun: S.optional(S.Boolean),
2469
- force: S.optional(S.Boolean),
2470
- yes: S.optional(S.Boolean),
2471
- destroy: S.optional(S.Boolean),
2472
- dev: S.optional(S.Boolean),
2473
- adopt: S.optional(S.Boolean)
2604
+ const ExecStackOptions = Schema.Struct({
2605
+ main: Schema.String,
2606
+ stage: Schema.String,
2607
+ envFile: Schema.OptionFromOptional(Schema.String),
2608
+ profile: Schema.optional(Schema.String),
2609
+ dryRun: Schema.optional(Schema.Boolean),
2610
+ force: Schema.optional(Schema.Boolean),
2611
+ yes: Schema.optional(Schema.Boolean),
2612
+ destroy: Schema.optional(Schema.Boolean),
2613
+ dev: Schema.optional(Schema.Boolean),
2614
+ adopt: Schema.optional(Schema.Boolean)
2474
2615
  });
2475
2616
  const stackSpanAttrs = (args) => ({
2476
2617
  "alchemy.stage": args.stage,
@@ -3341,8 +3482,8 @@ const selectCli = () => isNonInteractive() ? LoggingCli : inkCLI();
3341
3482
 
3342
3483
  //#endregion
3343
3484
  //#region lib/Cli/exec.js
3344
- const services = Layer.mergeAll(Layer.provideMerge(AlchemyContextLive, PlatformServices), Layer.provide(ProfileLive, PlatformServices), Layer.provide(CredentialsStoreLive, PlatformServices), FetchHttpClient.layer, ConfigProvider.layer(ConfigProvider.fromEnv()), selectCli());
3345
- const exec = () => execStack(S.decodeSync(ExecStackOptions)(JSON.parse(process.env.ALCHEMY_EXEC_OPTIONS))).pipe(Effect.provide(services), Effect.scoped);
3485
+ const services = Layer.merge(selectCli(), fromEnv()).pipe(Layer.provideMerge(Layer.mergeAll(AlchemyContextLive, ProfileLive, CredentialsStoreLive)), Layer.provideMerge(Layer.mergeAll(PlatformServices, FetchHttpClient.layer, ConfigProvider.layer(ConfigProvider.fromEnv()))));
3486
+ const exec = () => execStack(Schema.decodeSync(ExecStackOptions)(JSON.parse(process.env.ALCHEMY_EXEC_OPTIONS))).pipe(Effect.provide(services), Effect.scoped);
3346
3487
 
3347
3488
  //#endregion
3348
3489
  //#region bin/exec.ts