@alchemy.run/modal 0.0.0 → 2.0.0-beta.86

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 (499) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +96 -4
  3. package/lib/App.d.ts +143 -0
  4. package/lib/App.d.ts.map +1 -0
  5. package/lib/App.js +198 -0
  6. package/lib/App.js.map +1 -0
  7. package/lib/AuthProvider.d.ts +53 -0
  8. package/lib/AuthProvider.d.ts.map +1 -0
  9. package/lib/AuthProvider.js +209 -0
  10. package/lib/AuthProvider.js.map +1 -0
  11. package/lib/BindingHttp.d.ts +56 -0
  12. package/lib/BindingHttp.d.ts.map +1 -0
  13. package/lib/BindingHttp.js +50 -0
  14. package/lib/BindingHttp.js.map +1 -0
  15. package/lib/Blob.d.ts +34 -0
  16. package/lib/Blob.d.ts.map +1 -0
  17. package/lib/Blob.js +59 -0
  18. package/lib/Blob.js.map +1 -0
  19. package/lib/Bootstrap.d.ts +8 -0
  20. package/lib/Bootstrap.d.ts.map +1 -0
  21. package/lib/Bootstrap.js +26 -0
  22. package/lib/Bootstrap.js.map +1 -0
  23. package/lib/Cbor.d.ts +10 -0
  24. package/lib/Cbor.d.ts.map +1 -0
  25. package/lib/Cbor.js +177 -0
  26. package/lib/Cbor.js.map +1 -0
  27. package/lib/ConnectSandbox.d.ts +64 -0
  28. package/lib/ConnectSandbox.d.ts.map +1 -0
  29. package/lib/ConnectSandbox.js +33 -0
  30. package/lib/ConnectSandbox.js.map +1 -0
  31. package/lib/Container.d.ts +124 -0
  32. package/lib/Container.d.ts.map +1 -0
  33. package/lib/Container.js +1 -0
  34. package/lib/Container.js.map +1 -0
  35. package/lib/Contributions.d.ts +7 -0
  36. package/lib/Contributions.d.ts.map +1 -0
  37. package/lib/Contributions.js +6 -0
  38. package/lib/Contributions.js.map +1 -0
  39. package/lib/CreateDict.d.ts +83 -0
  40. package/lib/CreateDict.d.ts.map +1 -0
  41. package/lib/CreateDict.js +3 -0
  42. package/lib/CreateDict.js.map +1 -0
  43. package/lib/CreateDictHttp.d.ts +33 -0
  44. package/lib/CreateDictHttp.d.ts.map +1 -0
  45. package/lib/CreateDictHttp.js +67 -0
  46. package/lib/CreateDictHttp.js.map +1 -0
  47. package/lib/CreateImage.d.ts +98 -0
  48. package/lib/CreateImage.d.ts.map +1 -0
  49. package/lib/CreateImage.js +3 -0
  50. package/lib/CreateImage.js.map +1 -0
  51. package/lib/CreateImageHttp.d.ts +51 -0
  52. package/lib/CreateImageHttp.d.ts.map +1 -0
  53. package/lib/CreateImageHttp.js +87 -0
  54. package/lib/CreateImageHttp.js.map +1 -0
  55. package/lib/CreateQueue.d.ts +83 -0
  56. package/lib/CreateQueue.d.ts.map +1 -0
  57. package/lib/CreateQueue.js +3 -0
  58. package/lib/CreateQueue.js.map +1 -0
  59. package/lib/CreateQueueHttp.d.ts +31 -0
  60. package/lib/CreateQueueHttp.d.ts.map +1 -0
  61. package/lib/CreateQueueHttp.js +67 -0
  62. package/lib/CreateQueueHttp.js.map +1 -0
  63. package/lib/CreateSandbox.d.ts +186 -0
  64. package/lib/CreateSandbox.d.ts.map +1 -0
  65. package/lib/CreateSandbox.js +3 -0
  66. package/lib/CreateSandbox.js.map +1 -0
  67. package/lib/CreateSandboxHttp.d.ts +17 -0
  68. package/lib/CreateSandboxHttp.d.ts.map +1 -0
  69. package/lib/CreateSandboxHttp.js +117 -0
  70. package/lib/CreateSandboxHttp.js.map +1 -0
  71. package/lib/CreateSecret.d.ts +95 -0
  72. package/lib/CreateSecret.d.ts.map +1 -0
  73. package/lib/CreateSecret.js +3 -0
  74. package/lib/CreateSecret.js.map +1 -0
  75. package/lib/CreateSecretHttp.d.ts +24 -0
  76. package/lib/CreateSecretHttp.d.ts.map +1 -0
  77. package/lib/CreateSecretHttp.js +60 -0
  78. package/lib/CreateSecretHttp.js.map +1 -0
  79. package/lib/CreateVolume.d.ts +84 -0
  80. package/lib/CreateVolume.d.ts.map +1 -0
  81. package/lib/CreateVolume.js +3 -0
  82. package/lib/CreateVolume.js.map +1 -0
  83. package/lib/CreateVolumeHttp.d.ts +32 -0
  84. package/lib/CreateVolumeHttp.d.ts.map +1 -0
  85. package/lib/CreateVolumeHttp.js +69 -0
  86. package/lib/CreateVolumeHttp.js.map +1 -0
  87. package/lib/Credentials.d.ts +32 -0
  88. package/lib/Credentials.d.ts.map +1 -0
  89. package/lib/Credentials.js +44 -0
  90. package/lib/Credentials.js.map +1 -0
  91. package/lib/Dict.d.ts +147 -0
  92. package/lib/Dict.d.ts.map +1 -0
  93. package/lib/Dict.js +175 -0
  94. package/lib/Dict.js.map +1 -0
  95. package/lib/DictClient.d.ts +55 -0
  96. package/lib/DictClient.d.ts.map +1 -0
  97. package/lib/DictClient.js +89 -0
  98. package/lib/DictClient.js.map +1 -0
  99. package/lib/Domain.d.ts +86 -0
  100. package/lib/Domain.d.ts.map +1 -0
  101. package/lib/Domain.js +113 -0
  102. package/lib/Domain.js.map +1 -0
  103. package/lib/Endpoint.d.ts +181 -0
  104. package/lib/Endpoint.d.ts.map +1 -0
  105. package/lib/Endpoint.js +283 -0
  106. package/lib/Endpoint.js.map +1 -0
  107. package/lib/Environment.d.ts +174 -0
  108. package/lib/Environment.d.ts.map +1 -0
  109. package/lib/Environment.js +244 -0
  110. package/lib/Environment.js.map +1 -0
  111. package/lib/FetchServer.d.ts +105 -0
  112. package/lib/FetchServer.d.ts.map +1 -0
  113. package/lib/FetchServer.js +3 -0
  114. package/lib/FetchServer.js.map +1 -0
  115. package/lib/FetchServerHttp.d.ts +21 -0
  116. package/lib/FetchServerHttp.d.ts.map +1 -0
  117. package/lib/FetchServerHttp.js +84 -0
  118. package/lib/FetchServerHttp.js.map +1 -0
  119. package/lib/Function.d.ts +236 -0
  120. package/lib/Function.d.ts.map +1 -0
  121. package/lib/Function.js +273 -0
  122. package/lib/Function.js.map +1 -0
  123. package/lib/FunctionAutoscaler.d.ts +99 -0
  124. package/lib/FunctionAutoscaler.d.ts.map +1 -0
  125. package/lib/FunctionAutoscaler.js +136 -0
  126. package/lib/FunctionAutoscaler.js.map +1 -0
  127. package/lib/FunctionTarget.d.ts +61 -0
  128. package/lib/FunctionTarget.d.ts.map +1 -0
  129. package/lib/FunctionTarget.js +136 -0
  130. package/lib/FunctionTarget.js.map +1 -0
  131. package/lib/Image.d.ts +159 -0
  132. package/lib/Image.d.ts.map +1 -0
  133. package/lib/Image.js +203 -0
  134. package/lib/Image.js.map +1 -0
  135. package/lib/ImageBuild.d.ts +108 -0
  136. package/lib/ImageBuild.d.ts.map +1 -0
  137. package/lib/ImageBuild.js +157 -0
  138. package/lib/ImageBuild.js.map +1 -0
  139. package/lib/ImagePlan.d.ts +31 -0
  140. package/lib/ImagePlan.d.ts.map +1 -0
  141. package/lib/ImagePlan.js +70 -0
  142. package/lib/ImagePlan.js.map +1 -0
  143. package/lib/InferEnv.d.ts +26 -0
  144. package/lib/InferEnv.d.ts.map +1 -0
  145. package/lib/InferEnv.js +1 -0
  146. package/lib/InferEnv.js.map +1 -0
  147. package/lib/InvokeFunction.d.ts +186 -0
  148. package/lib/InvokeFunction.d.ts.map +1 -0
  149. package/lib/InvokeFunction.js +10 -0
  150. package/lib/InvokeFunction.js.map +1 -0
  151. package/lib/InvokeFunctionHttp.d.ts +39 -0
  152. package/lib/InvokeFunctionHttp.d.ts.map +1 -0
  153. package/lib/InvokeFunctionHttp.js +210 -0
  154. package/lib/InvokeFunctionHttp.js.map +1 -0
  155. package/lib/ModalBindings.d.ts +138 -0
  156. package/lib/ModalBindings.d.ts.map +1 -0
  157. package/lib/ModalBindings.js +223 -0
  158. package/lib/ModalBindings.js.map +1 -0
  159. package/lib/MountBucket.d.ts +80 -0
  160. package/lib/MountBucket.d.ts.map +1 -0
  161. package/lib/MountBucket.js +44 -0
  162. package/lib/MountBucket.js.map +1 -0
  163. package/lib/MountVolume.d.ts +77 -0
  164. package/lib/MountVolume.d.ts.map +1 -0
  165. package/lib/MountVolume.js +41 -0
  166. package/lib/MountVolume.js.map +1 -0
  167. package/lib/Mounts.d.ts +134 -0
  168. package/lib/Mounts.d.ts.map +1 -0
  169. package/lib/Mounts.js +87 -0
  170. package/lib/Mounts.js.map +1 -0
  171. package/lib/PersistentSandbox.d.ts +75 -0
  172. package/lib/PersistentSandbox.d.ts.map +1 -0
  173. package/lib/PersistentSandbox.js +93 -0
  174. package/lib/PersistentSandbox.js.map +1 -0
  175. package/lib/Providers.d.ts +23 -0
  176. package/lib/Providers.d.ts.map +1 -0
  177. package/lib/Providers.js +64 -0
  178. package/lib/Providers.js.map +1 -0
  179. package/lib/Proxy.d.ts +94 -0
  180. package/lib/Proxy.d.ts.map +1 -0
  181. package/lib/Proxy.js +132 -0
  182. package/lib/Proxy.js.map +1 -0
  183. package/lib/Queue.d.ts +147 -0
  184. package/lib/Queue.d.ts.map +1 -0
  185. package/lib/Queue.js +177 -0
  186. package/lib/Queue.js.map +1 -0
  187. package/lib/QueueClient.d.ts +64 -0
  188. package/lib/QueueClient.d.ts.map +1 -0
  189. package/lib/QueueClient.js +73 -0
  190. package/lib/QueueClient.js.map +1 -0
  191. package/lib/ReadApp.d.ts +85 -0
  192. package/lib/ReadApp.d.ts.map +1 -0
  193. package/lib/ReadApp.js +3 -0
  194. package/lib/ReadApp.js.map +1 -0
  195. package/lib/ReadAppHttp.d.ts +26 -0
  196. package/lib/ReadAppHttp.d.ts.map +1 -0
  197. package/lib/ReadAppHttp.js +106 -0
  198. package/lib/ReadAppHttp.js.map +1 -0
  199. package/lib/ReadDict.d.ts +39 -0
  200. package/lib/ReadDict.d.ts.map +1 -0
  201. package/lib/ReadDict.js +3 -0
  202. package/lib/ReadDict.js.map +1 -0
  203. package/lib/ReadDictHttp.d.ts +12 -0
  204. package/lib/ReadDictHttp.d.ts.map +1 -0
  205. package/lib/ReadDictHttp.js +23 -0
  206. package/lib/ReadDictHttp.js.map +1 -0
  207. package/lib/ReadFunction.d.ts +73 -0
  208. package/lib/ReadFunction.d.ts.map +1 -0
  209. package/lib/ReadFunction.js +3 -0
  210. package/lib/ReadFunction.js.map +1 -0
  211. package/lib/ReadFunctionHttp.d.ts +25 -0
  212. package/lib/ReadFunctionHttp.d.ts.map +1 -0
  213. package/lib/ReadFunctionHttp.js +63 -0
  214. package/lib/ReadFunctionHttp.js.map +1 -0
  215. package/lib/ReadQueue.d.ts +39 -0
  216. package/lib/ReadQueue.d.ts.map +1 -0
  217. package/lib/ReadQueue.js +3 -0
  218. package/lib/ReadQueue.js.map +1 -0
  219. package/lib/ReadQueueHttp.d.ts +12 -0
  220. package/lib/ReadQueueHttp.d.ts.map +1 -0
  221. package/lib/ReadQueueHttp.js +23 -0
  222. package/lib/ReadQueueHttp.js.map +1 -0
  223. package/lib/ReadServer.d.ts +72 -0
  224. package/lib/ReadServer.d.ts.map +1 -0
  225. package/lib/ReadServer.js +3 -0
  226. package/lib/ReadServer.js.map +1 -0
  227. package/lib/ReadServerHttp.d.ts +25 -0
  228. package/lib/ReadServerHttp.d.ts.map +1 -0
  229. package/lib/ReadServerHttp.js +70 -0
  230. package/lib/ReadServerHttp.js.map +1 -0
  231. package/lib/ReadVolume.d.ts +40 -0
  232. package/lib/ReadVolume.d.ts.map +1 -0
  233. package/lib/ReadVolume.js +3 -0
  234. package/lib/ReadVolume.js.map +1 -0
  235. package/lib/ReadVolumeHttp.d.ts +12 -0
  236. package/lib/ReadVolumeHttp.d.ts.map +1 -0
  237. package/lib/ReadVolumeHttp.js +24 -0
  238. package/lib/ReadVolumeHttp.js.map +1 -0
  239. package/lib/ReadWriteDict.d.ts +39 -0
  240. package/lib/ReadWriteDict.d.ts.map +1 -0
  241. package/lib/ReadWriteDict.js +3 -0
  242. package/lib/ReadWriteDict.js.map +1 -0
  243. package/lib/ReadWriteDictHttp.d.ts +12 -0
  244. package/lib/ReadWriteDictHttp.d.ts.map +1 -0
  245. package/lib/ReadWriteDictHttp.js +23 -0
  246. package/lib/ReadWriteDictHttp.js.map +1 -0
  247. package/lib/ReadWriteQueue.d.ts +40 -0
  248. package/lib/ReadWriteQueue.d.ts.map +1 -0
  249. package/lib/ReadWriteQueue.js +3 -0
  250. package/lib/ReadWriteQueue.js.map +1 -0
  251. package/lib/ReadWriteQueueHttp.d.ts +12 -0
  252. package/lib/ReadWriteQueueHttp.d.ts.map +1 -0
  253. package/lib/ReadWriteQueueHttp.js +23 -0
  254. package/lib/ReadWriteQueueHttp.js.map +1 -0
  255. package/lib/ReadWriteVolume.d.ts +40 -0
  256. package/lib/ReadWriteVolume.d.ts.map +1 -0
  257. package/lib/ReadWriteVolume.js +3 -0
  258. package/lib/ReadWriteVolume.js.map +1 -0
  259. package/lib/ReadWriteVolumeHttp.d.ts +12 -0
  260. package/lib/ReadWriteVolumeHttp.d.ts.map +1 -0
  261. package/lib/ReadWriteVolumeHttp.js +24 -0
  262. package/lib/ReadWriteVolumeHttp.js.map +1 -0
  263. package/lib/RuntimeOwner.d.ts +39 -0
  264. package/lib/RuntimeOwner.d.ts.map +1 -0
  265. package/lib/RuntimeOwner.js +85 -0
  266. package/lib/RuntimeOwner.js.map +1 -0
  267. package/lib/Sandbox.d.ts +215 -0
  268. package/lib/Sandbox.d.ts.map +1 -0
  269. package/lib/Sandbox.js +278 -0
  270. package/lib/Sandbox.js.map +1 -0
  271. package/lib/SandboxClient.d.ts +748 -0
  272. package/lib/SandboxClient.d.ts.map +1 -0
  273. package/lib/SandboxClient.js +710 -0
  274. package/lib/SandboxClient.js.map +1 -0
  275. package/lib/ScaleFunction.d.ts +54 -0
  276. package/lib/ScaleFunction.d.ts.map +1 -0
  277. package/lib/ScaleFunction.js +3 -0
  278. package/lib/ScaleFunction.js.map +1 -0
  279. package/lib/ScaleFunctionHttp.d.ts +21 -0
  280. package/lib/ScaleFunctionHttp.d.ts.map +1 -0
  281. package/lib/ScaleFunctionHttp.js +39 -0
  282. package/lib/ScaleFunctionHttp.js.map +1 -0
  283. package/lib/Secret.d.ts +170 -0
  284. package/lib/Secret.d.ts.map +1 -0
  285. package/lib/Secret.js +196 -0
  286. package/lib/Secret.js.map +1 -0
  287. package/lib/Server.d.ts +155 -0
  288. package/lib/Server.d.ts.map +1 -0
  289. package/lib/Server.js +184 -0
  290. package/lib/Server.js.map +1 -0
  291. package/lib/ServiceUser.d.ts +139 -0
  292. package/lib/ServiceUser.d.ts.map +1 -0
  293. package/lib/ServiceUser.js +210 -0
  294. package/lib/ServiceUser.js.map +1 -0
  295. package/lib/Volume.d.ts +170 -0
  296. package/lib/Volume.d.ts.map +1 -0
  297. package/lib/Volume.js +220 -0
  298. package/lib/Volume.js.map +1 -0
  299. package/lib/VolumeClient.d.ts +53 -0
  300. package/lib/VolumeClient.d.ts.map +1 -0
  301. package/lib/VolumeClient.js +22 -0
  302. package/lib/VolumeClient.js.map +1 -0
  303. package/lib/VolumeFiles.d.ts +94 -0
  304. package/lib/VolumeFiles.d.ts.map +1 -0
  305. package/lib/VolumeFiles.js +139 -0
  306. package/lib/VolumeFiles.js.map +1 -0
  307. package/lib/WebhookToken.d.ts +102 -0
  308. package/lib/WebhookToken.d.ts.map +1 -0
  309. package/lib/WebhookToken.js +176 -0
  310. package/lib/WebhookToken.js.map +1 -0
  311. package/lib/WorkspaceSettings.d.ts +70 -0
  312. package/lib/WorkspaceSettings.d.ts.map +1 -0
  313. package/lib/WorkspaceSettings.js +105 -0
  314. package/lib/WorkspaceSettings.js.map +1 -0
  315. package/lib/WriteApp.d.ts +38 -0
  316. package/lib/WriteApp.d.ts.map +1 -0
  317. package/lib/WriteApp.js +3 -0
  318. package/lib/WriteApp.js.map +1 -0
  319. package/lib/WriteAppHttp.d.ts +23 -0
  320. package/lib/WriteAppHttp.d.ts.map +1 -0
  321. package/lib/WriteAppHttp.js +36 -0
  322. package/lib/WriteAppHttp.js.map +1 -0
  323. package/lib/WriteDict.d.ts +39 -0
  324. package/lib/WriteDict.d.ts.map +1 -0
  325. package/lib/WriteDict.js +3 -0
  326. package/lib/WriteDict.js.map +1 -0
  327. package/lib/WriteDictHttp.d.ts +12 -0
  328. package/lib/WriteDictHttp.d.ts.map +1 -0
  329. package/lib/WriteDictHttp.js +23 -0
  330. package/lib/WriteDictHttp.js.map +1 -0
  331. package/lib/WriteQueue.d.ts +39 -0
  332. package/lib/WriteQueue.d.ts.map +1 -0
  333. package/lib/WriteQueue.js +3 -0
  334. package/lib/WriteQueue.js.map +1 -0
  335. package/lib/WriteQueueHttp.d.ts +12 -0
  336. package/lib/WriteQueueHttp.d.ts.map +1 -0
  337. package/lib/WriteQueueHttp.js +23 -0
  338. package/lib/WriteQueueHttp.js.map +1 -0
  339. package/lib/WriteSecret.d.ts +53 -0
  340. package/lib/WriteSecret.d.ts.map +1 -0
  341. package/lib/WriteSecret.js +3 -0
  342. package/lib/WriteSecret.js.map +1 -0
  343. package/lib/WriteSecretHttp.d.ts +23 -0
  344. package/lib/WriteSecretHttp.d.ts.map +1 -0
  345. package/lib/WriteSecretHttp.js +44 -0
  346. package/lib/WriteSecretHttp.js.map +1 -0
  347. package/lib/WriteVolume.d.ts +39 -0
  348. package/lib/WriteVolume.d.ts.map +1 -0
  349. package/lib/WriteVolume.js +3 -0
  350. package/lib/WriteVolume.js.map +1 -0
  351. package/lib/WriteVolumeHttp.d.ts +12 -0
  352. package/lib/WriteVolumeHttp.d.ts.map +1 -0
  353. package/lib/WriteVolumeHttp.js +24 -0
  354. package/lib/WriteVolumeHttp.js.map +1 -0
  355. package/lib/index.d.ts +80 -0
  356. package/lib/index.d.ts.map +1 -0
  357. package/lib/index.js +78 -0
  358. package/lib/index.js.map +1 -0
  359. package/lib/internal/Declared.d.ts +29 -0
  360. package/lib/internal/Declared.d.ts.map +1 -0
  361. package/lib/internal/Declared.js +31 -0
  362. package/lib/internal/Declared.js.map +1 -0
  363. package/lib/internal/Deploy.d.ts +110 -0
  364. package/lib/internal/Deploy.d.ts.map +1 -0
  365. package/lib/internal/Deploy.js +230 -0
  366. package/lib/internal/Deploy.js.map +1 -0
  367. package/lib/internal/Entrypoint.d.ts +52 -0
  368. package/lib/internal/Entrypoint.d.ts.map +1 -0
  369. package/lib/internal/Entrypoint.js +193 -0
  370. package/lib/internal/Entrypoint.js.map +1 -0
  371. package/lib/internal/Rpc.d.ts +17 -0
  372. package/lib/internal/Rpc.d.ts.map +1 -0
  373. package/lib/internal/Rpc.js +49 -0
  374. package/lib/internal/Rpc.js.map +1 -0
  375. package/lib/internal/RpcAuth.d.ts +41 -0
  376. package/lib/internal/RpcAuth.d.ts.map +1 -0
  377. package/lib/internal/RpcAuth.js +100 -0
  378. package/lib/internal/RpcAuth.js.map +1 -0
  379. package/lib/internal/Runtime.d.ts +127 -0
  380. package/lib/internal/Runtime.d.ts.map +1 -0
  381. package/lib/internal/Runtime.js +246 -0
  382. package/lib/internal/Runtime.js.map +1 -0
  383. package/lib/internal/Tags.d.ts +19 -0
  384. package/lib/internal/Tags.d.ts.map +1 -0
  385. package/lib/internal/Tags.js +33 -0
  386. package/lib/internal/Tags.js.map +1 -0
  387. package/lib/internal/TcpConnect.d.ts +12 -0
  388. package/lib/internal/TcpConnect.d.ts.map +1 -0
  389. package/lib/internal/TcpConnect.js +46 -0
  390. package/lib/internal/TcpConnect.js.map +1 -0
  391. package/lib/internal/Transport.d.ts +13 -0
  392. package/lib/internal/Transport.d.ts.map +1 -0
  393. package/lib/internal/Transport.js +16 -0
  394. package/lib/internal/Transport.js.map +1 -0
  395. package/lib/internal.d.ts +71 -0
  396. package/lib/internal.d.ts.map +1 -0
  397. package/lib/internal.js +102 -0
  398. package/lib/internal.js.map +1 -0
  399. package/package.json +59 -3
  400. package/src/App.ts +262 -0
  401. package/src/AuthProvider.ts +295 -0
  402. package/src/BindingHttp.ts +112 -0
  403. package/src/Blob.ts +71 -0
  404. package/src/Bootstrap.ts +52 -0
  405. package/src/Cbor.ts +158 -0
  406. package/src/ConnectSandbox.ts +99 -0
  407. package/src/Container.ts +121 -0
  408. package/src/Contributions.ts +9 -0
  409. package/src/CreateDict.ts +95 -0
  410. package/src/CreateDictHttp.ts +91 -0
  411. package/src/CreateImage.ts +105 -0
  412. package/src/CreateImageHttp.ts +117 -0
  413. package/src/CreateQueue.ts +95 -0
  414. package/src/CreateQueueHttp.ts +91 -0
  415. package/src/CreateSandbox.ts +228 -0
  416. package/src/CreateSandboxHttp.ts +160 -0
  417. package/src/CreateSecret.ts +109 -0
  418. package/src/CreateSecretHttp.ts +83 -0
  419. package/src/CreateVolume.ts +96 -0
  420. package/src/CreateVolumeHttp.ts +93 -0
  421. package/src/Credentials.ts +74 -0
  422. package/src/Dict.ts +245 -0
  423. package/src/DictClient.ts +166 -0
  424. package/src/Domain.ts +147 -0
  425. package/src/Endpoint.ts +406 -0
  426. package/src/Environment.ts +373 -0
  427. package/src/FetchServer.ts +126 -0
  428. package/src/FetchServerHttp.ts +110 -0
  429. package/src/Function.ts +397 -0
  430. package/src/FunctionAutoscaler.ts +210 -0
  431. package/src/FunctionTarget.ts +181 -0
  432. package/src/Image.ts +281 -0
  433. package/src/ImageBuild.ts +228 -0
  434. package/src/ImagePlan.ts +78 -0
  435. package/src/InferEnv.ts +27 -0
  436. package/src/InvokeFunction.ts +211 -0
  437. package/src/InvokeFunctionHttp.ts +316 -0
  438. package/src/ModalBindings.ts +310 -0
  439. package/src/MountBucket.ts +137 -0
  440. package/src/MountVolume.ts +113 -0
  441. package/src/Mounts.ts +230 -0
  442. package/src/PersistentSandbox.ts +142 -0
  443. package/src/Providers.ts +100 -0
  444. package/src/Proxy.ts +191 -0
  445. package/src/Queue.ts +258 -0
  446. package/src/QueueClient.ts +149 -0
  447. package/src/ReadApp.ts +101 -0
  448. package/src/ReadAppHttp.ts +142 -0
  449. package/src/ReadDict.ts +44 -0
  450. package/src/ReadDictHttp.ts +27 -0
  451. package/src/ReadFunction.ts +107 -0
  452. package/src/ReadFunctionHttp.ts +91 -0
  453. package/src/ReadQueue.ts +44 -0
  454. package/src/ReadQueueHttp.ts +27 -0
  455. package/src/ReadServer.ts +98 -0
  456. package/src/ReadServerHttp.ts +101 -0
  457. package/src/ReadVolume.ts +45 -0
  458. package/src/ReadVolumeHttp.ts +28 -0
  459. package/src/ReadWriteDict.ts +44 -0
  460. package/src/ReadWriteDictHttp.ts +27 -0
  461. package/src/ReadWriteQueue.ts +45 -0
  462. package/src/ReadWriteQueueHttp.ts +27 -0
  463. package/src/ReadWriteVolume.ts +45 -0
  464. package/src/ReadWriteVolumeHttp.ts +28 -0
  465. package/src/RuntimeOwner.ts +111 -0
  466. package/src/Sandbox.ts +402 -0
  467. package/src/SandboxClient.ts +1404 -0
  468. package/src/ScaleFunction.ts +70 -0
  469. package/src/ScaleFunctionHttp.ts +54 -0
  470. package/src/Secret.ts +296 -0
  471. package/src/Server.ts +285 -0
  472. package/src/ServiceUser.ts +295 -0
  473. package/src/Volume.ts +320 -0
  474. package/src/VolumeClient.ts +108 -0
  475. package/src/VolumeFiles.ts +194 -0
  476. package/src/WebhookToken.ts +230 -0
  477. package/src/WorkspaceSettings.ts +160 -0
  478. package/src/WriteApp.ts +43 -0
  479. package/src/WriteAppHttp.ts +51 -0
  480. package/src/WriteDict.ts +44 -0
  481. package/src/WriteDictHttp.ts +27 -0
  482. package/src/WriteQueue.ts +44 -0
  483. package/src/WriteQueueHttp.ts +27 -0
  484. package/src/WriteSecret.ts +60 -0
  485. package/src/WriteSecretHttp.ts +56 -0
  486. package/src/WriteVolume.ts +44 -0
  487. package/src/WriteVolumeHttp.ts +28 -0
  488. package/src/globals.d.ts +2 -0
  489. package/src/index.ts +85 -0
  490. package/src/internal/Declared.ts +80 -0
  491. package/src/internal/Deploy.ts +309 -0
  492. package/src/internal/Entrypoint.ts +198 -0
  493. package/src/internal/Rpc.ts +59 -0
  494. package/src/internal/RpcAuth.ts +132 -0
  495. package/src/internal/Runtime.ts +386 -0
  496. package/src/internal/Tags.ts +44 -0
  497. package/src/internal/TcpConnect.ts +78 -0
  498. package/src/internal/Transport.ts +25 -0
  499. package/src/internal.ts +147 -0
@@ -0,0 +1,223 @@
1
+ import { GrpcTransport } from "@distilled.cloud/core/grpc-transport";
2
+ import { withAuthToken } from "@distilled.cloud/modal/AuthToken";
3
+ import { containerSocket, Credentials, CredentialsFromEnv, credentials, fromContainer, streamTaskCommandRouter, withTaskCommandRouter, } from "@distilled.cloud/modal/Credentials";
4
+ import { orDieCredentialsUnavailable } from "alchemy/Auth/Resolve";
5
+ import * as Binding from "alchemy/Binding";
6
+ import * as Output from "alchemy/Output";
7
+ import { CurrentRuntimeContext } from "alchemy/RuntimeContext";
8
+ import * as Context from "effect/Context";
9
+ import * as Effect from "effect/Effect";
10
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
11
+ import * as HttpClient from "effect/http/HttpClient";
12
+ import * as Layer from "effect/Layer";
13
+ import * as Option from "effect/Option";
14
+ import * as Redacted from "effect/Redacted";
15
+ import { withAuthTokens } from "./Credentials.js";
16
+ import { ModalTransport } from "./internal/Transport.js";
17
+ import { ServiceUser } from "./ServiceUser.js";
18
+ /**
19
+ * How a Modal binding reaches Modal from its host.
20
+ *
21
+ * Modal grants access per environment, as a `viewer` or a `contributor`. So:
22
+ *
23
+ * - a Modal Function or Server: nothing is bound. It calls Modal as its own
24
+ * container, over the API socket Modal gives every container
25
+ * (`fromContainer`), the way Modal's Python client does there. No
26
+ * credential is stored. A host with `restrictModalAccess` has no such
27
+ * access, so it gets a service user like any other host;
28
+ * - any other host (a Cloudflare Worker, a Lambda, a Modal Sandbox):
29
+ * {@link Bind} creates a scoped `Modal.ServiceUser` for the
30
+ * host (`<host>ModalIdentity`), grants it the role each binding asks for
31
+ * on the bound resource's environment, and binds its token pair into the
32
+ * host's env (`MODAL_TOKEN_ID`, and `MODAL_TOKEN_SECRET` kept `Redacted`);
33
+ * - no host (a script or a deploy-time Action): nothing is bound, and calls
34
+ * use the deployer's credentials.
35
+ *
36
+ * Modal's Starter plan has no service users. There, provide
37
+ * {@link DeployerHostIdentity} to bind the deployer's own token pair into
38
+ * each host instead: hosts then act with the deployer's workspace-wide
39
+ * access, not the roles their bindings ask for.
40
+ *
41
+ * Import it as a namespace. A binding resolves its operations with
42
+ * {@link withCredentials} and gets its `bind` from {@link Bind} when its layer
43
+ * is built, then binds behind its own `__ALCHEMY_RUNTIME__` guard:
44
+ *
45
+ * ```ts
46
+ * Effect.gen(function* () {
47
+ * const put = yield* ModalBindings.withCredentials(modalQueue.putQueue);
48
+ * const bind = yield* ModalBindings.Bind;
49
+ * return Effect.fn(function* (queue: Queue) {
50
+ * if (!globalThis.__ALCHEMY_RUNTIME__) {
51
+ * yield* bind`Modal.WriteQueue(${queue})`({
52
+ * roles: [{ environment: queue.environment, role: "contributor" }],
53
+ * });
54
+ * }
55
+ * const queueId = yield* queue.queueId;
56
+ * return (value) => put({ queueId: yield* queueId, values: [...] });
57
+ * });
58
+ * })
59
+ * ```
60
+ */
61
+ export const TOKEN_ENV = {
62
+ id: "MODAL_TOKEN_ID",
63
+ secret: "MODAL_TOKEN_SECRET",
64
+ // Not MODAL_SERVER_URL: inside a Modal container, Modal sets that to the
65
+ // container's own socket (`unix:/run/modal.sock`), shadowing ours.
66
+ serverUrl: "ALCHEMY_MODAL_SERVER_URL",
67
+ };
68
+ /**
69
+ * The identity {@link Bind} gives a binding's host:
70
+ *
71
+ * - `"service-user"`: a scoped `Modal.ServiceUser` per host with only the
72
+ * roles its bindings ask for (needs Modal's Team or Enterprise plan);
73
+ * - `"deployer"`: the deployer's own token pair, with its workspace-wide
74
+ * access (for the Starter plan, which has no service users).
75
+ *
76
+ * Set it with {@link DeployerHostIdentity}.
77
+ */
78
+ export const HostIdentity = Context.Reference("Modal/HostIdentity", {
79
+ defaultValue: () => "service-user",
80
+ });
81
+ /**
82
+ * Bind the deployer's own Modal token into binding hosts instead of a
83
+ * scoped service user per host. Use it on Modal's Starter plan, which has
84
+ * no service users; hosts then have the deployer's workspace-wide access.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * export default Alchemy.Stack(
89
+ * "App",
90
+ * { providers: Layer.mergeAll(Cloudflare.providers(), Modal.providers(), Modal.DeployerHostIdentity) },
91
+ * Effect.gen(function* () { ... }),
92
+ * );
93
+ * ```
94
+ */
95
+ export const DeployerHostIdentity = Layer.succeed(HostIdentity, "deployer");
96
+ const labelled = (verb, label) => {
97
+ const strings = [`${verb}(`, `, ${label[0]}`, ...label.slice(1)];
98
+ strings[strings.length - 1] += ")";
99
+ return Object.assign(strings, { raw: strings });
100
+ };
101
+ /**
102
+ * The `bind` for a binding's layer: yield it while the layer is built, then
103
+ * call it from the returned function behind a literal
104
+ * `if (!globalThis.__ALCHEMY_RUNTIME__)` so the bundler drops it. On a host it
105
+ * grants `data.roles` to the host's service user and binds that user's token
106
+ * pair (and `data.env`) into the host's env; with no host it does nothing.
107
+ */
108
+ export const Bind = Effect.gen(function* () {
109
+ // Bindings only bind at deploy, so a host bundle captures nothing here
110
+ // and drops the identity resource.
111
+ if (globalThis.__ALCHEMY_RUNTIME__)
112
+ return () => () => Effect.void;
113
+ const Identity = yield* ServiceUser;
114
+ const identity = yield* HostIdentity;
115
+ const ambient = yield* Effect.serviceOption(Credentials);
116
+ return (label, ...args) => Effect.fn(function* (data = {}) {
117
+ const host = yield* Binding.Host;
118
+ if (host === undefined)
119
+ return;
120
+ const runtime = yield* CurrentRuntimeContext;
121
+ if (runtime === undefined)
122
+ return;
123
+ // A binding that calls no Modal API (only `env`) needs no identity, and
124
+ // a Modal Function or Server calls as its own container.
125
+ if (data.roles !== undefined && data.roles.length > 0 && !callsAsContainer(host)) {
126
+ // The host talks to the deployer's Modal control plane.
127
+ const resolve = Option.isSome(ambient)
128
+ ? ambient.value
129
+ : yield* Credentials.pipe(Effect.provide(CredentialsFromEnv));
130
+ // Binding initialization can't fail; the engine reports this defect as
131
+ // `CredentialsRequired`.
132
+ const creds = yield* resolve.pipe(orDieCredentialsUnavailable("Modal"));
133
+ if (identity === "deployer") {
134
+ yield* runtime.set(TOKEN_ENV.id, creds.tokenId.pipe(Redacted.value, Output.literal));
135
+ yield* runtime.set(TOKEN_ENV.secret, Output.literal(creds.tokenSecret));
136
+ }
137
+ else {
138
+ const user = yield* Identity(`${host.LogicalId}ModalIdentity`, { scoped: true });
139
+ yield* user.bind(labelled("Allow", label), host, ...args)({ environments: data.roles });
140
+ yield* runtime.set(TOKEN_ENV.id, user.tokenId);
141
+ yield* runtime.set(TOKEN_ENV.secret, user.tokenSecret);
142
+ }
143
+ yield* runtime.set(TOKEN_ENV.serverUrl, Output.literal(creds.apiBaseUrl));
144
+ }
145
+ for (const [name, value] of Object.entries(data.env ?? {})) {
146
+ yield* runtime.set(name, Output.isOutput(value) ? value : Output.literal(value));
147
+ }
148
+ });
149
+ });
150
+ /** Host types whose containers call Modal over their own API socket. */
151
+ const CONTAINER_HOSTS = new Set(["Modal.Function", "Modal.Server"]);
152
+ /** Whether `host` calls Modal as its container instead of with a bound token. */
153
+ const callsAsContainer = (host) => CONTAINER_HOSTS.has(host.Type ?? "") &&
154
+ !host.Props?.restrictModalAccess;
155
+ /**
156
+ * The credentials, HTTP client and gRPC transport distilled operations run
157
+ * with on this host. A resolved operation keeps them as a fallback under its
158
+ * caller's context, so a Worker's own `HttpClient` doesn't displace the
159
+ * transport.
160
+ */
161
+ const operationContext = Effect.gen(function* () {
162
+ const runtime = yield* CurrentRuntimeContext;
163
+ if (globalThis.__ALCHEMY_RUNTIME__ && runtime !== undefined) {
164
+ const tokenId = yield* runtime.get(TOKEN_ENV.id);
165
+ const tokenSecret = yield* runtime.get(TOKEN_ENV.secret);
166
+ if (tokenId !== undefined && tokenSecret !== undefined) {
167
+ const serverUrl = yield* runtime.get(TOKEN_ENV.serverUrl);
168
+ return yield* Layer.build(Layer.mergeAll(withAuthTokens(credentials({
169
+ tokenId: Redacted.make(tokenId),
170
+ tokenSecret: Redacted.isRedacted(tokenSecret)
171
+ ? tokenSecret
172
+ : Redacted.make(tokenSecret),
173
+ apiBaseUrl: serverUrl,
174
+ })), ModalTransport)).pipe(Effect.scoped);
175
+ }
176
+ // A Modal Function or Server: call as the container (see `Bind`).
177
+ const socket = yield* containerSocket;
178
+ if (socket !== undefined) {
179
+ return yield* Layer.build(Layer.mergeAll(withAuthToken.pipe(Layer.provide(Layer.mergeAll(fromContainer, FetchHttpClient.layer))), fromContainer, FetchHttpClient.layer)).pipe(Effect.orDie, Effect.scoped);
180
+ }
181
+ }
182
+ // No bound identity (deploy, scripts, Actions): the ambient Modal
183
+ // credentials, falling back to `MODAL_TOKEN_ID` / `MODAL_TOKEN_SECRET`.
184
+ const ambientCredentials = yield* Effect.serviceOption(Credentials);
185
+ const ambientHttp = yield* Effect.serviceOption(HttpClient.HttpClient);
186
+ const transport = yield* Effect.provide(Effect.service(GrpcTransport), ModalTransport);
187
+ return Context.make(Credentials, Option.isSome(ambientCredentials)
188
+ ? ambientCredentials.value
189
+ : yield* Credentials.pipe(Effect.provide(withAuthTokens(CredentialsFromEnv)))).pipe(Context.add(HttpClient.HttpClient, Option.isSome(ambientHttp)
190
+ ? ambientHttp.value
191
+ : yield* HttpClient.HttpClient.pipe(Effect.provide(ModalTransport))), Context.add(GrpcTransport, transport));
192
+ });
193
+ /**
194
+ * Resolve a distilled operation (or several, with `Effect.all`) once when
195
+ * the binding's layer is built: with the token pair {@link Bind} bound into
196
+ * the host, or the deployer's credentials when there is none.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * const ops = yield* ModalBindings.withCredentials(
201
+ * operations({ getFile: volume.volumeGetFile2, putFiles: volume.volumePutFiles2 }),
202
+ * );
203
+ * ```
204
+ */
205
+ export const withCredentials = Effect.fn(function* (operation) {
206
+ const context = yield* operationContext;
207
+ return yield* operation.pipe(Effect.provide(context));
208
+ });
209
+ /**
210
+ * Resolve a task command router operation for one sandbox: the router runs
211
+ * per task, at a URL with its own JWT (from `sandboxGetCommandRouterAccess`).
212
+ * The router credentials are applied on every call, because a resolved
213
+ * operation runs with its caller's `Credentials` (the control plane's) over
214
+ * the ones it captured. `withTaskCommandRouter` also supplies the HTTP/2
215
+ * client the router requires.
216
+ */
217
+ export const withRouter = (operation) => (access) => Effect.succeed((input) => operation(input).pipe(withTaskCommandRouter(access)));
218
+ /**
219
+ * {@link withRouter} for a server-streaming router operation: its `.stream`,
220
+ * which emits each message as the router sends it.
221
+ */
222
+ export const streamRouter = (operation) => (access) => Effect.succeed((input) => operation.stream(input).pipe(streamTaskCommandRouter(access)));
223
+ //# sourceMappingURL=ModalBindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalBindings.js","sources":["../src/ModalBindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EACL,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,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AC,CACtC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAEH,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC1C,SAAsD;IAEtD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,gBAAgB,CAAC;IACxC,OAAO,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,CAAU,SAA+D,EAAE,EAAE,CAC7E,CAAC,MAAoB,EAAoD,EAAE,CACzE,MAAM,CAAC,OAAO,CAAC,CAAC,KAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEvF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GACvB,CAAU,SAAoF,EAAE,EAAE,CAClG,CAAC,MAAoB,EAAoD,EAAE,CACzE,MAAM,CAAC,OAAO,CAAC,CAAC,KAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,80 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import type * as Output from "alchemy/Output";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
5
+ import { type BucketMount, type BucketMountOptions, type MountedBucket } from "./Mounts.ts";
6
+ import type { Secret } from "./Secret.ts";
7
+ /**
8
+ * A bucket resource of another provider: an AWS S3 Bucket, a Cloudflare R2
9
+ * Bucket, a GCS bucket. Its name (and, for R2, its account endpoint) is
10
+ * read from its attributes.
11
+ */
12
+ export interface BucketResource {
13
+ readonly Type: string;
14
+ readonly bucketName: Output.Output<string, never>;
15
+ }
16
+ /** Options for `Modal.MountBucket`: Modal's cloud bucket mount fields, plus the keys' secret. */
17
+ export interface MountBucketOptions extends BucketMountOptions {
18
+ /**
19
+ * A `Modal.Secret` holding the bucket's keys (`AWS_ACCESS_KEY_ID` /
20
+ * `AWS_SECRET_ACCESS_KEY`, or GCS HMAC keys). Omit it with `oidcAuthRoleArn`.
21
+ */
22
+ readonly secret?: Secret;
23
+ }
24
+ /** What `Modal.MountBucket` returns: a mount entry, ready for `mounts`. */
25
+ export type BucketMountRef = BucketMount<string | MountedBucket, {
26
+ readonly secretId: Effect.Effect<string>;
27
+ }>;
28
+ /**
29
+ * Mount a cloud bucket at `path` with Modal's cloud bucket mounts: a bucket
30
+ * name, or a bucket resource of another provider (an AWS S3 Bucket, a
31
+ * Cloudflare R2 Bucket, whose account endpoint is filled in).
32
+ *
33
+ * - In a `Modal.Function`, `Modal.Server` or `Modal.Sandbox` program, the
34
+ * bucket is mounted into every container the program runs in.
35
+ * - In any other runtime, the binding returns the entry to pass to
36
+ * `sandboxes.create({ mounts })`.
37
+ *
38
+ * Modal reads the bucket with the keys in `secret`, or by assuming
39
+ * `oidcAuthRoleArn` with its OIDC identity.
40
+ *
41
+ * ### Mount an R2 bucket
42
+ * **Example:** A sandbox program reading uploads from Cloudflare R2
43
+ * ```typescript
44
+ * import * as Modal from "@alchemy.run/modal";
45
+ * import * as Effect from "effect/Effect";
46
+ * import * as FileSystem from "effect/FileSystem";
47
+ * import * as HttpServerResponse from "effect/http/HttpServerResponse";
48
+ * import { Coder, R2Keys, Uploads } from "./Storage.ts";
49
+ *
50
+ * export default class Agent extends Modal.Sandbox<Agent>()(
51
+ * "Agent",
52
+ * { main: import.meta.url, app: Coder },
53
+ * Effect.gen(function* () {
54
+ * const uploads = yield* Modal.MountBucket(Uploads, { path: "/uploads", secret: R2Keys });
55
+ * const fs = yield* FileSystem.FileSystem;
56
+ * return {
57
+ * fetch: Effect.gen(function* () {
58
+ * return yield* HttpServerResponse.json(yield* fs.readDirectory(uploads.path));
59
+ * }).pipe(Effect.orDie),
60
+ * };
61
+ * }).pipe(Effect.provide(Modal.MountBucketLive)),
62
+ * ) {}
63
+ * ```
64
+ *
65
+ * @binding
66
+ * @product Volume
67
+ */
68
+ export interface MountBucket extends Binding.Service<MountBucket, "Modal.MountBucket", (bucket: string | BucketResource, options: MountBucketOptions) => Effect.Effect<BucketMountRef>> {
69
+ }
70
+ export declare const MountBucket: MountBucket;
71
+ /**
72
+ * {@link MountBucket}: binds the entry into a Modal runtime's `mounts`, or
73
+ * resolves it for `sandboxes.create` in any other runtime.
74
+ *
75
+ * @layer
76
+ * @product Volume
77
+ * @provides Modal.MountBucket
78
+ */
79
+ export declare const MountBucketLive: Layer.Layer<MountBucket, never, never>;
80
+ //# sourceMappingURL=MountBucket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountBucket.d.ts","sources":["../src/MountBucket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAEnB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACnD;AAED,iGAAiG;AACjG,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG,WAAW,CACtC,MAAM,GAAG,aAAa,EACtB;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;CAAE,CAC7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO,CAClD,WAAW,EACX,mBAAmB,EACnB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,OAAO,EAAE,kBAAkB,KAAK,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAChG;CAAG;AAEJ,eAAO,MAAM,WAAW,aAAoD,CAAC;AAI7E;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,wCAwC3B,CAAC"}
@@ -0,0 +1,44 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import { r2Endpoint, } from "./Mounts.js";
5
+ import { MODAL_RUNTIMES } from "./MountVolume.js";
6
+ export const MountBucket = Binding.Service("Modal.MountBucket");
7
+ const R2_BUCKET = "Cloudflare.R2.Bucket";
8
+ /**
9
+ * {@link MountBucket}: binds the entry into a Modal runtime's `mounts`, or
10
+ * resolves it for `sandboxes.create` in any other runtime.
11
+ *
12
+ * @layer
13
+ * @product Volume
14
+ * @provides Modal.MountBucket
15
+ */
16
+ export const MountBucketLive = Layer.effect(MountBucket, Effect.succeed(Effect.fn("Modal.MountBucket")(function* (bucket, options) {
17
+ const { secret, ...rest } = options;
18
+ if (!globalThis.__ALCHEMY_RUNTIME__) {
19
+ const host = yield* Binding.Host;
20
+ if (host !== undefined && MODAL_RUNTIMES.has(host.Type)) {
21
+ yield* host.bind `Modal.MountBucket(${bucket})`({
22
+ mounts: [{ ...rest, bucket, secret }],
23
+ });
24
+ }
25
+ }
26
+ const secretRef = secret === undefined ? undefined : { secretId: yield* secret.secretId };
27
+ if (typeof bucket === "string") {
28
+ return { ...rest, bucket, secret: secretRef };
29
+ }
30
+ const bucketName = yield* bucket.bucketName;
31
+ if (bucket.Type === R2_BUCKET) {
32
+ const r2 = bucket;
33
+ const accountId = yield* r2.accountId;
34
+ const jurisdiction = yield* r2.jurisdiction;
35
+ const endpointUrl = Effect.map(Effect.all([accountId, jurisdiction]), ([account, j]) => r2Endpoint(account, j));
36
+ return {
37
+ ...rest,
38
+ bucket: { bucketName, endpointUrl, type: "r2" },
39
+ secret: secretRef,
40
+ };
41
+ }
42
+ return { ...rest, bucket: { bucketName }, secret: secretRef };
43
+ })));
44
+ //# sourceMappingURL=MountBucket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountBucket.js","sources":["../src/MountBucket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAIL,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AA0ElE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAc,mBAAmB,CAAC,CAAC;AAE7E,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CACzC,WAAW,EACX,MAAM,CAAC,OAAO,CACZ,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,EACtC,MAA+B,EAC/B,OAA2B;IAE3B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACpC,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,C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IAC7B,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,SAAS,EAA2B,CAAC;AACzF,CAAC,CAAC,CACH,CACF,CAAC"}
@@ -0,0 +1,77 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import type { MountedVolume, VolumeMount, VolumeMountOptions } from "./Mounts.ts";
5
+ import type { Volume } from "./Volume.ts";
6
+ /** What `Modal.MountVolume` returns: a mount entry, ready for `mounts`. */
7
+ export type VolumeMountRef = VolumeMount<MountedVolume>;
8
+ /**
9
+ * Mount a `Modal.Volume` at `path`.
10
+ *
11
+ * - In a `Modal.Function`, `Modal.Server` or `Modal.Sandbox` program, the
12
+ * volume is mounted into every container the program runs in: read it at
13
+ * `path` with the filesystem.
14
+ * - In any other runtime (a Worker, a Lambda), the binding grants the
15
+ * runtime's Modal identity access to the volume's environment and returns
16
+ * the entry to pass to `sandboxes.create({ mounts })`.
17
+ *
18
+ * The returned reference holds the same fields as a plain entry
19
+ * (`{ volume, path, readOnly?, subPath? }`).
20
+ *
21
+ * ### Mount into a program
22
+ * **Example:** A Function reading model weights from a volume
23
+ * ```typescript
24
+ * import * as Modal from "@alchemy.run/modal";
25
+ * import * as Effect from "effect/Effect";
26
+ * import * as FileSystem from "effect/FileSystem";
27
+ * import * as HttpServerResponse from "effect/http/HttpServerResponse";
28
+ * import { Backend, Weights } from "./Backend.ts";
29
+ *
30
+ * export default class Embed extends Modal.Function<Embed>()(
31
+ * "Embed",
32
+ * { main: import.meta.url, app: Backend, gpu: "L4" },
33
+ * Effect.gen(function* () {
34
+ * const weights = yield* Modal.MountVolume(Weights, { path: "/weights", readOnly: true });
35
+ * const fs = yield* FileSystem.FileSystem;
36
+ * return {
37
+ * fetch: Effect.gen(function* () {
38
+ * return yield* HttpServerResponse.json(yield* fs.readDirectory(weights.path));
39
+ * }).pipe(Effect.orDie),
40
+ * };
41
+ * }).pipe(Effect.provide(Modal.MountVolumeLive)),
42
+ * ) {}
43
+ * ```
44
+ *
45
+ * ### Mount into a sandbox you create
46
+ * **Example:** From a Cloudflare Worker
47
+ * ```typescript
48
+ * const data = yield* Modal.MountVolume(Data, { path: "/data" });
49
+ * const sandboxes = yield* Modal.CreateSandbox(Coder);
50
+ * // per request
51
+ * const sandbox = yield* sandboxes.create({ mounts: [data] });
52
+ * ```
53
+ *
54
+ * @binding
55
+ * @product Volume
56
+ */
57
+ export interface MountVolume extends Binding.Service<MountVolume, "Modal.MountVolume", (volume: Volume, options: VolumeMountOptions) => Effect.Effect<VolumeMountRef>> {
58
+ }
59
+ export declare const MountVolume: MountVolume;
60
+ /** Runtimes that mount volumes into their own containers. */
61
+ export declare const MODAL_RUNTIMES: Set<string>;
62
+ /** A Modal runtime's `bind`, typed for the `mounts` slice of its binding contract. */
63
+ export type MountHost = {
64
+ bind: (label: TemplateStringsArray, ...args: unknown[]) => (data: {
65
+ readonly mounts: ReadonlyArray<unknown>;
66
+ }) => Effect.Effect<void>;
67
+ };
68
+ /**
69
+ * {@link MountVolume}: binds the entry into a Modal runtime's `mounts`, or
70
+ * grants another runtime's identity access to the volume's environment.
71
+ *
72
+ * @layer
73
+ * @product Volume
74
+ * @provides Modal.MountVolume
75
+ */
76
+ export declare const MountVolumeLive: Layer.Layer<MountVolume, never, never>;
77
+ //# sourceMappingURL=MountVolume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountVolume.d.ts","sources":["../src/MountVolume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO,CAClD,WAAW,EACX,mBAAmB,EACnB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,KAAK,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAC/E;CAAG;AAEJ,eAAO,MAAM,WAAW,aAAoD,CAAC;AAE7E,6DAA6D;AAC7D,eAAO,MAAM,cAAc,aAA+D,CAAC;AAE3F,sFAAsF;AACtF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,CACJ,KAAK,EAAE,oBAAoB,EAC3B,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;KAAE,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACjF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,wCA0B3B,CAAC"}
@@ -0,0 +1,41 @@
1
+ import * as Binding from "alchemy/Binding";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as ModalBindings from "./ModalBindings.js";
5
+ export const MountVolume = Binding.Service("Modal.MountVolume");
6
+ /** Runtimes that mount volumes into their own containers. */
7
+ export const MODAL_RUNTIMES = new Set(["Modal.Function", "Modal.Server", "Modal.Sandbox"]);
8
+ /**
9
+ * {@link MountVolume}: binds the entry into a Modal runtime's `mounts`, or
10
+ * grants another runtime's identity access to the volume's environment.
11
+ *
12
+ * @layer
13
+ * @product Volume
14
+ * @provides Modal.MountVolume
15
+ */
16
+ export const MountVolumeLive = Layer.effect(MountVolume, Effect.gen(function* () {
17
+ const bind = yield* ModalBindings.Bind;
18
+ return Effect.fn("Modal.MountVolume")(function* (volume, options) {
19
+ if (!globalThis.__ALCHEMY_RUNTIME__) {
20
+ const host = yield* Binding.Host;
21
+ if (host !== undefined && MODAL_RUNTIMES.has(host.Type)) {
22
+ yield* host.bind `Modal.MountVolume(${volume})`({
23
+ mounts: [{ volume, ...options }],
24
+ });
25
+ }
26
+ else {
27
+ yield* bind `Modal.MountVolume(${volume})`({
28
+ roles: [
29
+ {
30
+ environment: volume.environment,
31
+ role: options.readOnly ? "viewer" : "contributor",
32
+ },
33
+ ],
34
+ });
35
+ }
36
+ }
37
+ const volumeId = yield* volume.volumeId;
38
+ return { ...options, volume: { volumeId } };
39
+ });
40
+ }));
41
+ //# sourceMappingURL=MountVolume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountVolume.js","sources":["../src/MountVolume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AA8DpD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAc,mBAAmB,CAAC,CAAC;AAE7E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC;AAU3F;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CACzC,WAAW,EACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;IACvC,OAAO,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc,EAAE,OAA2B;QAC1F,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;YACjC,IAAI,IAAI,KAAK,SAAS,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxD,KAAK,CAAC,CAAE,IAA6B,CAAC,IAAI,CAAA,qBAAqB,MAAM,GAAG,CAAC;oBACvE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;iBACjC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,CAAC,IAAI,CAAA,qBAAqB,MAAM,GAAG,CAAC;oBACxC,KAAK,EAAE;wBACL;4BACE,WAAW,EAAE,MAAM,CAAC,WAAW;4BAC/B,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa;yBAClD;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QACxC,OAAO,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAA2B,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CACH,CAAC"}
@@ -0,0 +1,134 @@
1
+ import type * as sandbox from "@distilled.cloud/modal/sandbox";
2
+ import { type MountCapability } from "alchemy/Mount";
3
+ import * as Effect from "effect/Effect";
4
+ import type { Ref } from "./Container.ts";
5
+ /** A value known at deploy, or an Effect that reads it at runtime. */
6
+ type Lazy<T> = T | Effect.Effect<T>;
7
+ /** A volume entry's options besides the volume: Modal's own volume mount fields. */
8
+ export interface VolumeMountOptions {
9
+ /** Absolute path the volume is mounted at. */
10
+ readonly path: string;
11
+ /** Mount read-only. */
12
+ readonly readOnly?: boolean;
13
+ /** Mount this directory of the volume instead of its root. */
14
+ readonly subPath?: string;
15
+ }
16
+ /** A bucket entry's options besides the bucket: Modal's own cloud bucket mount fields. */
17
+ export interface BucketMountOptions {
18
+ /** Absolute path the bucket is mounted at. */
19
+ readonly path: string;
20
+ /**
21
+ * The bucket's storage API.
22
+ * @default "r2" for a Cloudflare R2 bucket, "s3" otherwise
23
+ */
24
+ readonly type?: "s3" | "r2" | "gcp";
25
+ /**
26
+ * S3-compatible endpoint.
27
+ * @default the account endpoint, for a Cloudflare R2 bucket
28
+ */
29
+ readonly endpointUrl?: string;
30
+ /** Mount only keys under this prefix. */
31
+ readonly keyPrefix?: string;
32
+ /** Mount read-only. */
33
+ readonly readOnly?: boolean;
34
+ /** Assume this AWS role with Modal's OIDC identity instead of a secret. */
35
+ readonly oidcAuthRoleArn?: string;
36
+ }
37
+ /** The fields of a bucket resource a mount reads: AWS S3, Cloudflare R2, GCS. */
38
+ export interface BucketLike {
39
+ readonly bucketName: string;
40
+ /** Cloudflare R2: the account the bucket's endpoint is under. */
41
+ readonly accountId?: string;
42
+ /** Cloudflare R2: `"eu"` or `"fedramp"` buckets have their own endpoint. */
43
+ readonly jurisdiction?: string;
44
+ }
45
+ /**
46
+ * A `Modal.Volume` mounted at `path`. In Stack props the volume is the
47
+ * declared `Modal.Volume`; at runtime it's a handle (`CreateVolume`) or
48
+ * the reference `Modal.MountVolume` returns.
49
+ */
50
+ export interface VolumeMount<V = Ref<{
51
+ readonly volumeId: string;
52
+ }>> extends VolumeMountOptions {
53
+ readonly volume: V;
54
+ }
55
+ /**
56
+ * A cloud bucket mounted at `path` with Modal's cloud bucket mounts: a
57
+ * bucket name, or a bucket resource of another provider (an AWS S3 Bucket,
58
+ * a Cloudflare R2 Bucket). Without `oidcAuthRoleArn`, `secret` holds the
59
+ * bucket's keys (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`, or GCS HMAC
60
+ * keys).
61
+ */
62
+ export interface BucketMount<B = string | Ref<BucketLike>, S = Ref<{
63
+ readonly secretId: string;
64
+ }>> extends BucketMountOptions {
65
+ readonly bucket: B;
66
+ readonly secret?: S;
67
+ }
68
+ /** A mount in Stack props (`Modal.Function`, `Server`, `Sandbox`, `PersistentSandbox`). */
69
+ export type Mount = VolumeMount | BucketMount;
70
+ /** The volume of a runtime mount entry: a volume handle, or a `MountVolume` reference. */
71
+ export interface MountedVolume {
72
+ readonly volumeId: Lazy<string>;
73
+ }
74
+ /** The bucket of a runtime mount entry, as `MountBucket` resolves it. */
75
+ export interface MountedBucket {
76
+ readonly bucketName: Lazy<string>;
77
+ readonly endpointUrl?: Lazy<string | undefined>;
78
+ readonly type?: "s3" | "r2" | "gcp";
79
+ }
80
+ /** A mount for `sandboxes.create`: a plain entry over handles, or a `Mount<Noun>` reference. */
81
+ export type SandboxMount = VolumeMount<MountedVolume> | BucketMount<string | MountedBucket, {
82
+ readonly secretId: Lazy<string>;
83
+ }>;
84
+ declare const MountNotBound_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
85
+ readonly _tag: "Modal.MountNotBound";
86
+ } & Readonly<A>;
87
+ /** A mount entry referenced a resource that isn't bound into this runtime. */
88
+ export declare class MountNotBound extends MountNotBound_base<{
89
+ readonly path: string;
90
+ readonly message: string;
91
+ }> {
92
+ }
93
+ /** Modal's mount fields for a set of entries. */
94
+ export interface ModalMounts {
95
+ readonly volumeMounts: sandbox.VolumeMount[];
96
+ readonly cloudBucketMounts: sandbox.CloudBucketMount[];
97
+ }
98
+ /** Cloudflare R2's S3 endpoint for an account (and jurisdiction). */
99
+ export declare const r2Endpoint: (accountId: string, jurisdiction?: string) => string;
100
+ /**
101
+ * Modal's `volumeMounts` and `cloudBucketMounts` for mount entries whose
102
+ * resources are resolved: attributes at reconcile, handles or `Mount<Noun>`
103
+ * references at runtime.
104
+ */
105
+ export declare const modalMountsOf: (mounts: ReadonlyArray<Mount | SandboxMount> | undefined) => Effect.Effect<ModalMounts, MountNotBound>;
106
+ /**
107
+ * What a Modal runtime's `mounts` binding contract holds: volume and bucket
108
+ * entries (`Modal.MountVolume`, `Modal.MountBucket`), and the install lines
109
+ * of other providers' mount clients (`alchemy/Mount`).
110
+ */
111
+ export type MountContract = ReadonlyArray<Mount | MountCapability>;
112
+ /** A host's binding data, for its `mounts` slice. */
113
+ export type MountBindings = ReadonlyArray<{
114
+ readonly data: {
115
+ readonly mounts?: MountContract;
116
+ };
117
+ }>;
118
+ /** The volume and bucket entries a host's bindings contributed, in binding order. */
119
+ export declare const boundMounts: (bindings: MountBindings) => ReadonlyArray<Mount>;
120
+ /** The mount clients other providers' bindings asked the host's image to install. */
121
+ export declare const boundCapabilities: (bindings: MountBindings) => ReadonlyArray<MountCapability>;
122
+ /**
123
+ * What a Modal container provides to mount clients. Modal runs containers
124
+ * under gVisor without `CAP_SYS_ADMIN`: `/dev/fuse` exists, but `mount`
125
+ * fails with permission denied, for FUSE and NFS alike.
126
+ */
127
+ export declare const MODAL_MOUNT_SUPPORT: {
128
+ readonly fuse: false;
129
+ readonly nfs: false;
130
+ };
131
+ /** Fail when a mount client needs what a Modal container can't provide. */
132
+ export declare const checkModalMounts: (host: string, capabilities: ReadonlyArray<MountCapability>) => Effect.Effect<void, never, never> | Effect.Effect<never, import("alchemy/Mount").MountUnsupported, never>;
133
+ export {};
134
+ //# sourceMappingURL=Mounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mounts.d.ts","sources":["../src/Mounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAA+C,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAGlG,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE1C,sEAAsE;AACtE,KAAK,IAAI,CAAC,CAAC,IAAI,C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