@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.
- package/LICENSE +201 -0
- package/README.md +96 -4
- package/lib/App.d.ts +143 -0
- package/lib/App.d.ts.map +1 -0
- package/lib/App.js +198 -0
- package/lib/App.js.map +1 -0
- package/lib/AuthProvider.d.ts +53 -0
- package/lib/AuthProvider.d.ts.map +1 -0
- package/lib/AuthProvider.js +209 -0
- package/lib/AuthProvider.js.map +1 -0
- package/lib/BindingHttp.d.ts +56 -0
- package/lib/BindingHttp.d.ts.map +1 -0
- package/lib/BindingHttp.js +50 -0
- package/lib/BindingHttp.js.map +1 -0
- package/lib/Blob.d.ts +34 -0
- package/lib/Blob.d.ts.map +1 -0
- package/lib/Blob.js +59 -0
- package/lib/Blob.js.map +1 -0
- package/lib/Bootstrap.d.ts +8 -0
- package/lib/Bootstrap.d.ts.map +1 -0
- package/lib/Bootstrap.js +26 -0
- package/lib/Bootstrap.js.map +1 -0
- package/lib/Cbor.d.ts +10 -0
- package/lib/Cbor.d.ts.map +1 -0
- package/lib/Cbor.js +177 -0
- package/lib/Cbor.js.map +1 -0
- package/lib/ConnectSandbox.d.ts +64 -0
- package/lib/ConnectSandbox.d.ts.map +1 -0
- package/lib/ConnectSandbox.js +33 -0
- package/lib/ConnectSandbox.js.map +1 -0
- package/lib/Container.d.ts +124 -0
- package/lib/Container.d.ts.map +1 -0
- package/lib/Container.js +1 -0
- package/lib/Container.js.map +1 -0
- package/lib/Contributions.d.ts +7 -0
- package/lib/Contributions.d.ts.map +1 -0
- package/lib/Contributions.js +6 -0
- package/lib/Contributions.js.map +1 -0
- package/lib/CreateDict.d.ts +83 -0
- package/lib/CreateDict.d.ts.map +1 -0
- package/lib/CreateDict.js +3 -0
- package/lib/CreateDict.js.map +1 -0
- package/lib/CreateDictHttp.d.ts +33 -0
- package/lib/CreateDictHttp.d.ts.map +1 -0
- package/lib/CreateDictHttp.js +67 -0
- package/lib/CreateDictHttp.js.map +1 -0
- package/lib/CreateImage.d.ts +98 -0
- package/lib/CreateImage.d.ts.map +1 -0
- package/lib/CreateImage.js +3 -0
- package/lib/CreateImage.js.map +1 -0
- package/lib/CreateImageHttp.d.ts +51 -0
- package/lib/CreateImageHttp.d.ts.map +1 -0
- package/lib/CreateImageHttp.js +87 -0
- package/lib/CreateImageHttp.js.map +1 -0
- package/lib/CreateQueue.d.ts +83 -0
- package/lib/CreateQueue.d.ts.map +1 -0
- package/lib/CreateQueue.js +3 -0
- package/lib/CreateQueue.js.map +1 -0
- package/lib/CreateQueueHttp.d.ts +31 -0
- package/lib/CreateQueueHttp.d.ts.map +1 -0
- package/lib/CreateQueueHttp.js +67 -0
- package/lib/CreateQueueHttp.js.map +1 -0
- package/lib/CreateSandbox.d.ts +186 -0
- package/lib/CreateSandbox.d.ts.map +1 -0
- package/lib/CreateSandbox.js +3 -0
- package/lib/CreateSandbox.js.map +1 -0
- package/lib/CreateSandboxHttp.d.ts +17 -0
- package/lib/CreateSandboxHttp.d.ts.map +1 -0
- package/lib/CreateSandboxHttp.js +117 -0
- package/lib/CreateSandboxHttp.js.map +1 -0
- package/lib/CreateSecret.d.ts +95 -0
- package/lib/CreateSecret.d.ts.map +1 -0
- package/lib/CreateSecret.js +3 -0
- package/lib/CreateSecret.js.map +1 -0
- package/lib/CreateSecretHttp.d.ts +24 -0
- package/lib/CreateSecretHttp.d.ts.map +1 -0
- package/lib/CreateSecretHttp.js +60 -0
- package/lib/CreateSecretHttp.js.map +1 -0
- package/lib/CreateVolume.d.ts +84 -0
- package/lib/CreateVolume.d.ts.map +1 -0
- package/lib/CreateVolume.js +3 -0
- package/lib/CreateVolume.js.map +1 -0
- package/lib/CreateVolumeHttp.d.ts +32 -0
- package/lib/CreateVolumeHttp.d.ts.map +1 -0
- package/lib/CreateVolumeHttp.js +69 -0
- package/lib/CreateVolumeHttp.js.map +1 -0
- package/lib/Credentials.d.ts +32 -0
- package/lib/Credentials.d.ts.map +1 -0
- package/lib/Credentials.js +44 -0
- package/lib/Credentials.js.map +1 -0
- package/lib/Dict.d.ts +147 -0
- package/lib/Dict.d.ts.map +1 -0
- package/lib/Dict.js +175 -0
- package/lib/Dict.js.map +1 -0
- package/lib/DictClient.d.ts +55 -0
- package/lib/DictClient.d.ts.map +1 -0
- package/lib/DictClient.js +89 -0
- package/lib/DictClient.js.map +1 -0
- package/lib/Domain.d.ts +86 -0
- package/lib/Domain.d.ts.map +1 -0
- package/lib/Domain.js +113 -0
- package/lib/Domain.js.map +1 -0
- package/lib/Endpoint.d.ts +181 -0
- package/lib/Endpoint.d.ts.map +1 -0
- package/lib/Endpoint.js +283 -0
- package/lib/Endpoint.js.map +1 -0
- package/lib/Environment.d.ts +174 -0
- package/lib/Environment.d.ts.map +1 -0
- package/lib/Environment.js +244 -0
- package/lib/Environment.js.map +1 -0
- package/lib/FetchServer.d.ts +105 -0
- package/lib/FetchServer.d.ts.map +1 -0
- package/lib/FetchServer.js +3 -0
- package/lib/FetchServer.js.map +1 -0
- package/lib/FetchServerHttp.d.ts +21 -0
- package/lib/FetchServerHttp.d.ts.map +1 -0
- package/lib/FetchServerHttp.js +84 -0
- package/lib/FetchServerHttp.js.map +1 -0
- package/lib/Function.d.ts +236 -0
- package/lib/Function.d.ts.map +1 -0
- package/lib/Function.js +273 -0
- package/lib/Function.js.map +1 -0
- package/lib/FunctionAutoscaler.d.ts +99 -0
- package/lib/FunctionAutoscaler.d.ts.map +1 -0
- package/lib/FunctionAutoscaler.js +136 -0
- package/lib/FunctionAutoscaler.js.map +1 -0
- package/lib/FunctionTarget.d.ts +61 -0
- package/lib/FunctionTarget.d.ts.map +1 -0
- package/lib/FunctionTarget.js +136 -0
- package/lib/FunctionTarget.js.map +1 -0
- package/lib/Image.d.ts +159 -0
- package/lib/Image.d.ts.map +1 -0
- package/lib/Image.js +203 -0
- package/lib/Image.js.map +1 -0
- package/lib/ImageBuild.d.ts +108 -0
- package/lib/ImageBuild.d.ts.map +1 -0
- package/lib/ImageBuild.js +157 -0
- package/lib/ImageBuild.js.map +1 -0
- package/lib/ImagePlan.d.ts +31 -0
- package/lib/ImagePlan.d.ts.map +1 -0
- package/lib/ImagePlan.js +70 -0
- package/lib/ImagePlan.js.map +1 -0
- package/lib/InferEnv.d.ts +26 -0
- package/lib/InferEnv.d.ts.map +1 -0
- package/lib/InferEnv.js +1 -0
- package/lib/InferEnv.js.map +1 -0
- package/lib/InvokeFunction.d.ts +186 -0
- package/lib/InvokeFunction.d.ts.map +1 -0
- package/lib/InvokeFunction.js +10 -0
- package/lib/InvokeFunction.js.map +1 -0
- package/lib/InvokeFunctionHttp.d.ts +39 -0
- package/lib/InvokeFunctionHttp.d.ts.map +1 -0
- package/lib/InvokeFunctionHttp.js +210 -0
- package/lib/InvokeFunctionHttp.js.map +1 -0
- package/lib/ModalBindings.d.ts +138 -0
- package/lib/ModalBindings.d.ts.map +1 -0
- package/lib/ModalBindings.js +223 -0
- package/lib/ModalBindings.js.map +1 -0
- package/lib/MountBucket.d.ts +80 -0
- package/lib/MountBucket.d.ts.map +1 -0
- package/lib/MountBucket.js +44 -0
- package/lib/MountBucket.js.map +1 -0
- package/lib/MountVolume.d.ts +77 -0
- package/lib/MountVolume.d.ts.map +1 -0
- package/lib/MountVolume.js +41 -0
- package/lib/MountVolume.js.map +1 -0
- package/lib/Mounts.d.ts +134 -0
- package/lib/Mounts.d.ts.map +1 -0
- package/lib/Mounts.js +87 -0
- package/lib/Mounts.js.map +1 -0
- package/lib/PersistentSandbox.d.ts +75 -0
- package/lib/PersistentSandbox.d.ts.map +1 -0
- package/lib/PersistentSandbox.js +93 -0
- package/lib/PersistentSandbox.js.map +1 -0
- package/lib/Providers.d.ts +23 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +64 -0
- package/lib/Providers.js.map +1 -0
- package/lib/Proxy.d.ts +94 -0
- package/lib/Proxy.d.ts.map +1 -0
- package/lib/Proxy.js +132 -0
- package/lib/Proxy.js.map +1 -0
- package/lib/Queue.d.ts +147 -0
- package/lib/Queue.d.ts.map +1 -0
- package/lib/Queue.js +177 -0
- package/lib/Queue.js.map +1 -0
- package/lib/QueueClient.d.ts +64 -0
- package/lib/QueueClient.d.ts.map +1 -0
- package/lib/QueueClient.js +73 -0
- package/lib/QueueClient.js.map +1 -0
- package/lib/ReadApp.d.ts +85 -0
- package/lib/ReadApp.d.ts.map +1 -0
- package/lib/ReadApp.js +3 -0
- package/lib/ReadApp.js.map +1 -0
- package/lib/ReadAppHttp.d.ts +26 -0
- package/lib/ReadAppHttp.d.ts.map +1 -0
- package/lib/ReadAppHttp.js +106 -0
- package/lib/ReadAppHttp.js.map +1 -0
- package/lib/ReadDict.d.ts +39 -0
- package/lib/ReadDict.d.ts.map +1 -0
- package/lib/ReadDict.js +3 -0
- package/lib/ReadDict.js.map +1 -0
- package/lib/ReadDictHttp.d.ts +12 -0
- package/lib/ReadDictHttp.d.ts.map +1 -0
- package/lib/ReadDictHttp.js +23 -0
- package/lib/ReadDictHttp.js.map +1 -0
- package/lib/ReadFunction.d.ts +73 -0
- package/lib/ReadFunction.d.ts.map +1 -0
- package/lib/ReadFunction.js +3 -0
- package/lib/ReadFunction.js.map +1 -0
- package/lib/ReadFunctionHttp.d.ts +25 -0
- package/lib/ReadFunctionHttp.d.ts.map +1 -0
- package/lib/ReadFunctionHttp.js +63 -0
- package/lib/ReadFunctionHttp.js.map +1 -0
- package/lib/ReadQueue.d.ts +39 -0
- package/lib/ReadQueue.d.ts.map +1 -0
- package/lib/ReadQueue.js +3 -0
- package/lib/ReadQueue.js.map +1 -0
- package/lib/ReadQueueHttp.d.ts +12 -0
- package/lib/ReadQueueHttp.d.ts.map +1 -0
- package/lib/ReadQueueHttp.js +23 -0
- package/lib/ReadQueueHttp.js.map +1 -0
- package/lib/ReadServer.d.ts +72 -0
- package/lib/ReadServer.d.ts.map +1 -0
- package/lib/ReadServer.js +3 -0
- package/lib/ReadServer.js.map +1 -0
- package/lib/ReadServerHttp.d.ts +25 -0
- package/lib/ReadServerHttp.d.ts.map +1 -0
- package/lib/ReadServerHttp.js +70 -0
- package/lib/ReadServerHttp.js.map +1 -0
- package/lib/ReadVolume.d.ts +40 -0
- package/lib/ReadVolume.d.ts.map +1 -0
- package/lib/ReadVolume.js +3 -0
- package/lib/ReadVolume.js.map +1 -0
- package/lib/ReadVolumeHttp.d.ts +12 -0
- package/lib/ReadVolumeHttp.d.ts.map +1 -0
- package/lib/ReadVolumeHttp.js +24 -0
- package/lib/ReadVolumeHttp.js.map +1 -0
- package/lib/ReadWriteDict.d.ts +39 -0
- package/lib/ReadWriteDict.d.ts.map +1 -0
- package/lib/ReadWriteDict.js +3 -0
- package/lib/ReadWriteDict.js.map +1 -0
- package/lib/ReadWriteDictHttp.d.ts +12 -0
- package/lib/ReadWriteDictHttp.d.ts.map +1 -0
- package/lib/ReadWriteDictHttp.js +23 -0
- package/lib/ReadWriteDictHttp.js.map +1 -0
- package/lib/ReadWriteQueue.d.ts +40 -0
- package/lib/ReadWriteQueue.d.ts.map +1 -0
- package/lib/ReadWriteQueue.js +3 -0
- package/lib/ReadWriteQueue.js.map +1 -0
- package/lib/ReadWriteQueueHttp.d.ts +12 -0
- package/lib/ReadWriteQueueHttp.d.ts.map +1 -0
- package/lib/ReadWriteQueueHttp.js +23 -0
- package/lib/ReadWriteQueueHttp.js.map +1 -0
- package/lib/ReadWriteVolume.d.ts +40 -0
- package/lib/ReadWriteVolume.d.ts.map +1 -0
- package/lib/ReadWriteVolume.js +3 -0
- package/lib/ReadWriteVolume.js.map +1 -0
- package/lib/ReadWriteVolumeHttp.d.ts +12 -0
- package/lib/ReadWriteVolumeHttp.d.ts.map +1 -0
- package/lib/ReadWriteVolumeHttp.js +24 -0
- package/lib/ReadWriteVolumeHttp.js.map +1 -0
- package/lib/RuntimeOwner.d.ts +39 -0
- package/lib/RuntimeOwner.d.ts.map +1 -0
- package/lib/RuntimeOwner.js +85 -0
- package/lib/RuntimeOwner.js.map +1 -0
- package/lib/Sandbox.d.ts +215 -0
- package/lib/Sandbox.d.ts.map +1 -0
- package/lib/Sandbox.js +278 -0
- package/lib/Sandbox.js.map +1 -0
- package/lib/SandboxClient.d.ts +748 -0
- package/lib/SandboxClient.d.ts.map +1 -0
- package/lib/SandboxClient.js +710 -0
- package/lib/SandboxClient.js.map +1 -0
- package/lib/ScaleFunction.d.ts +54 -0
- package/lib/ScaleFunction.d.ts.map +1 -0
- package/lib/ScaleFunction.js +3 -0
- package/lib/ScaleFunction.js.map +1 -0
- package/lib/ScaleFunctionHttp.d.ts +21 -0
- package/lib/ScaleFunctionHttp.d.ts.map +1 -0
- package/lib/ScaleFunctionHttp.js +39 -0
- package/lib/ScaleFunctionHttp.js.map +1 -0
- package/lib/Secret.d.ts +170 -0
- package/lib/Secret.d.ts.map +1 -0
- package/lib/Secret.js +196 -0
- package/lib/Secret.js.map +1 -0
- package/lib/Server.d.ts +155 -0
- package/lib/Server.d.ts.map +1 -0
- package/lib/Server.js +184 -0
- package/lib/Server.js.map +1 -0
- package/lib/ServiceUser.d.ts +139 -0
- package/lib/ServiceUser.d.ts.map +1 -0
- package/lib/ServiceUser.js +210 -0
- package/lib/ServiceUser.js.map +1 -0
- package/lib/Volume.d.ts +170 -0
- package/lib/Volume.d.ts.map +1 -0
- package/lib/Volume.js +220 -0
- package/lib/Volume.js.map +1 -0
- package/lib/VolumeClient.d.ts +53 -0
- package/lib/VolumeClient.d.ts.map +1 -0
- package/lib/VolumeClient.js +22 -0
- package/lib/VolumeClient.js.map +1 -0
- package/lib/VolumeFiles.d.ts +94 -0
- package/lib/VolumeFiles.d.ts.map +1 -0
- package/lib/VolumeFiles.js +139 -0
- package/lib/VolumeFiles.js.map +1 -0
- package/lib/WebhookToken.d.ts +102 -0
- package/lib/WebhookToken.d.ts.map +1 -0
- package/lib/WebhookToken.js +176 -0
- package/lib/WebhookToken.js.map +1 -0
- package/lib/WorkspaceSettings.d.ts +70 -0
- package/lib/WorkspaceSettings.d.ts.map +1 -0
- package/lib/WorkspaceSettings.js +105 -0
- package/lib/WorkspaceSettings.js.map +1 -0
- package/lib/WriteApp.d.ts +38 -0
- package/lib/WriteApp.d.ts.map +1 -0
- package/lib/WriteApp.js +3 -0
- package/lib/WriteApp.js.map +1 -0
- package/lib/WriteAppHttp.d.ts +23 -0
- package/lib/WriteAppHttp.d.ts.map +1 -0
- package/lib/WriteAppHttp.js +36 -0
- package/lib/WriteAppHttp.js.map +1 -0
- package/lib/WriteDict.d.ts +39 -0
- package/lib/WriteDict.d.ts.map +1 -0
- package/lib/WriteDict.js +3 -0
- package/lib/WriteDict.js.map +1 -0
- package/lib/WriteDictHttp.d.ts +12 -0
- package/lib/WriteDictHttp.d.ts.map +1 -0
- package/lib/WriteDictHttp.js +23 -0
- package/lib/WriteDictHttp.js.map +1 -0
- package/lib/WriteQueue.d.ts +39 -0
- package/lib/WriteQueue.d.ts.map +1 -0
- package/lib/WriteQueue.js +3 -0
- package/lib/WriteQueue.js.map +1 -0
- package/lib/WriteQueueHttp.d.ts +12 -0
- package/lib/WriteQueueHttp.d.ts.map +1 -0
- package/lib/WriteQueueHttp.js +23 -0
- package/lib/WriteQueueHttp.js.map +1 -0
- package/lib/WriteSecret.d.ts +53 -0
- package/lib/WriteSecret.d.ts.map +1 -0
- package/lib/WriteSecret.js +3 -0
- package/lib/WriteSecret.js.map +1 -0
- package/lib/WriteSecretHttp.d.ts +23 -0
- package/lib/WriteSecretHttp.d.ts.map +1 -0
- package/lib/WriteSecretHttp.js +44 -0
- package/lib/WriteSecretHttp.js.map +1 -0
- package/lib/WriteVolume.d.ts +39 -0
- package/lib/WriteVolume.d.ts.map +1 -0
- package/lib/WriteVolume.js +3 -0
- package/lib/WriteVolume.js.map +1 -0
- package/lib/WriteVolumeHttp.d.ts +12 -0
- package/lib/WriteVolumeHttp.d.ts.map +1 -0
- package/lib/WriteVolumeHttp.js +24 -0
- package/lib/WriteVolumeHttp.js.map +1 -0
- package/lib/index.d.ts +80 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +78 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/Declared.d.ts +29 -0
- package/lib/internal/Declared.d.ts.map +1 -0
- package/lib/internal/Declared.js +31 -0
- package/lib/internal/Declared.js.map +1 -0
- package/lib/internal/Deploy.d.ts +110 -0
- package/lib/internal/Deploy.d.ts.map +1 -0
- package/lib/internal/Deploy.js +230 -0
- package/lib/internal/Deploy.js.map +1 -0
- package/lib/internal/Entrypoint.d.ts +52 -0
- package/lib/internal/Entrypoint.d.ts.map +1 -0
- package/lib/internal/Entrypoint.js +193 -0
- package/lib/internal/Entrypoint.js.map +1 -0
- package/lib/internal/Rpc.d.ts +17 -0
- package/lib/internal/Rpc.d.ts.map +1 -0
- package/lib/internal/Rpc.js +49 -0
- package/lib/internal/Rpc.js.map +1 -0
- package/lib/internal/RpcAuth.d.ts +41 -0
- package/lib/internal/RpcAuth.d.ts.map +1 -0
- package/lib/internal/RpcAuth.js +100 -0
- package/lib/internal/RpcAuth.js.map +1 -0
- package/lib/internal/Runtime.d.ts +127 -0
- package/lib/internal/Runtime.d.ts.map +1 -0
- package/lib/internal/Runtime.js +246 -0
- package/lib/internal/Runtime.js.map +1 -0
- package/lib/internal/Tags.d.ts +19 -0
- package/lib/internal/Tags.d.ts.map +1 -0
- package/lib/internal/Tags.js +33 -0
- package/lib/internal/Tags.js.map +1 -0
- package/lib/internal/TcpConnect.d.ts +12 -0
- package/lib/internal/TcpConnect.d.ts.map +1 -0
- package/lib/internal/TcpConnect.js +46 -0
- package/lib/internal/TcpConnect.js.map +1 -0
- package/lib/internal/Transport.d.ts +13 -0
- package/lib/internal/Transport.d.ts.map +1 -0
- package/lib/internal/Transport.js +16 -0
- package/lib/internal/Transport.js.map +1 -0
- package/lib/internal.d.ts +71 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +102 -0
- package/lib/internal.js.map +1 -0
- package/package.json +59 -3
- package/src/App.ts +262 -0
- package/src/AuthProvider.ts +295 -0
- package/src/BindingHttp.ts +112 -0
- package/src/Blob.ts +71 -0
- package/src/Bootstrap.ts +52 -0
- package/src/Cbor.ts +158 -0
- package/src/ConnectSandbox.ts +99 -0
- package/src/Container.ts +121 -0
- package/src/Contributions.ts +9 -0
- package/src/CreateDict.ts +95 -0
- package/src/CreateDictHttp.ts +91 -0
- package/src/CreateImage.ts +105 -0
- package/src/CreateImageHttp.ts +117 -0
- package/src/CreateQueue.ts +95 -0
- package/src/CreateQueueHttp.ts +91 -0
- package/src/CreateSandbox.ts +228 -0
- package/src/CreateSandboxHttp.ts +160 -0
- package/src/CreateSecret.ts +109 -0
- package/src/CreateSecretHttp.ts +83 -0
- package/src/CreateVolume.ts +96 -0
- package/src/CreateVolumeHttp.ts +93 -0
- package/src/Credentials.ts +74 -0
- package/src/Dict.ts +245 -0
- package/src/DictClient.ts +166 -0
- package/src/Domain.ts +147 -0
- package/src/Endpoint.ts +406 -0
- package/src/Environment.ts +373 -0
- package/src/FetchServer.ts +126 -0
- package/src/FetchServerHttp.ts +110 -0
- package/src/Function.ts +397 -0
- package/src/FunctionAutoscaler.ts +210 -0
- package/src/FunctionTarget.ts +181 -0
- package/src/Image.ts +281 -0
- package/src/ImageBuild.ts +228 -0
- package/src/ImagePlan.ts +78 -0
- package/src/InferEnv.ts +27 -0
- package/src/InvokeFunction.ts +211 -0
- package/src/InvokeFunctionHttp.ts +316 -0
- package/src/ModalBindings.ts +310 -0
- package/src/MountBucket.ts +137 -0
- package/src/MountVolume.ts +113 -0
- package/src/Mounts.ts +230 -0
- package/src/PersistentSandbox.ts +142 -0
- package/src/Providers.ts +100 -0
- package/src/Proxy.ts +191 -0
- package/src/Queue.ts +258 -0
- package/src/QueueClient.ts +149 -0
- package/src/ReadApp.ts +101 -0
- package/src/ReadAppHttp.ts +142 -0
- package/src/ReadDict.ts +44 -0
- package/src/ReadDictHttp.ts +27 -0
- package/src/ReadFunction.ts +107 -0
- package/src/ReadFunctionHttp.ts +91 -0
- package/src/ReadQueue.ts +44 -0
- package/src/ReadQueueHttp.ts +27 -0
- package/src/ReadServer.ts +98 -0
- package/src/ReadServerHttp.ts +101 -0
- package/src/ReadVolume.ts +45 -0
- package/src/ReadVolumeHttp.ts +28 -0
- package/src/ReadWriteDict.ts +44 -0
- package/src/ReadWriteDictHttp.ts +27 -0
- package/src/ReadWriteQueue.ts +45 -0
- package/src/ReadWriteQueueHttp.ts +27 -0
- package/src/ReadWriteVolume.ts +45 -0
- package/src/ReadWriteVolumeHttp.ts +28 -0
- package/src/RuntimeOwner.ts +111 -0
- package/src/Sandbox.ts +402 -0
- package/src/SandboxClient.ts +1404 -0
- package/src/ScaleFunction.ts +70 -0
- package/src/ScaleFunctionHttp.ts +54 -0
- package/src/Secret.ts +296 -0
- package/src/Server.ts +285 -0
- package/src/ServiceUser.ts +295 -0
- package/src/Volume.ts +320 -0
- package/src/VolumeClient.ts +108 -0
- package/src/VolumeFiles.ts +194 -0
- package/src/WebhookToken.ts +230 -0
- package/src/WorkspaceSettings.ts +160 -0
- package/src/WriteApp.ts +43 -0
- package/src/WriteAppHttp.ts +51 -0
- package/src/WriteDict.ts +44 -0
- package/src/WriteDictHttp.ts +27 -0
- package/src/WriteQueue.ts +44 -0
- package/src/WriteQueueHttp.ts +27 -0
- package/src/WriteSecret.ts +60 -0
- package/src/WriteSecretHttp.ts +56 -0
- package/src/WriteVolume.ts +44 -0
- package/src/WriteVolumeHttp.ts +28 -0
- package/src/globals.d.ts +2 -0
- package/src/index.ts +85 -0
- package/src/internal/Declared.ts +80 -0
- package/src/internal/Deploy.ts +309 -0
- package/src/internal/Entrypoint.ts +198 -0
- package/src/internal/Rpc.ts +59 -0
- package/src/internal/RpcAuth.ts +132 -0
- package/src/internal/Runtime.ts +386 -0
- package/src/internal/Tags.ts +44 -0
- package/src/internal/TcpConnect.ts +78 -0
- package/src/internal/Transport.ts +25 -0
- package/src/internal.ts +147 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type * as functions from "@distilled.cloud/modal/functions";
|
|
2
|
+
import { Platform, type Main, type MainRpc } from "alchemy/Platform";
|
|
3
|
+
import * as Provider from "alchemy/Provider";
|
|
4
|
+
import type { Resource } from "alchemy/Resource";
|
|
5
|
+
import type { HostRuntimeContext, ServerHost } from "alchemy/Runtime/Process";
|
|
6
|
+
import type { ContainerProps } from "./Container.ts";
|
|
7
|
+
import { type RuntimeAttributes } from "./internal/Runtime.ts";
|
|
8
|
+
import type { MountContract } from "./Mounts.ts";
|
|
9
|
+
import type { Providers } from "./Providers.ts";
|
|
10
|
+
import type { DurationInput } from "./SandboxClient.ts";
|
|
11
|
+
/** Serve the function on the web at a `*.modal.run` URL. */
|
|
12
|
+
export interface WebEndpointOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Label in the URL (`https://<workspace>--<label>.modal.run`).
|
|
15
|
+
* @default "<app>-<function>"
|
|
16
|
+
*/
|
|
17
|
+
label?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Require Modal's proxy auth headers (`Modal-Key` / `Modal-Secret`, from a
|
|
20
|
+
* `Modal.WebhookToken`) on every request.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
requiresProxyAuth?: boolean;
|
|
24
|
+
/** Custom domains (verified `Modal.Domain`s) that also serve the endpoint. */
|
|
25
|
+
customDomains?: string[];
|
|
26
|
+
}
|
|
27
|
+
/** Run the function on a schedule: a cron expression, or a fixed period. */
|
|
28
|
+
export type FunctionSchedule = {
|
|
29
|
+
/** Cron expression (`"0 9 * * 1-5"`). */
|
|
30
|
+
readonly cron: string;
|
|
31
|
+
/** IANA time zone the expression is read in. @default "UTC" */
|
|
32
|
+
readonly timezone?: string;
|
|
33
|
+
} | {
|
|
34
|
+
/** Time between runs (`"1 hour"`, or seconds). */
|
|
35
|
+
readonly period: DurationInput;
|
|
36
|
+
};
|
|
37
|
+
/** Retry failed calls. */
|
|
38
|
+
export interface FunctionRetries {
|
|
39
|
+
/** Retries after the first failure. */
|
|
40
|
+
readonly maxRetries: number;
|
|
41
|
+
/** Delay multiplier per retry; `1` is a fixed delay. @default 2 */
|
|
42
|
+
readonly backoffCoefficient?: number;
|
|
43
|
+
/** Delay before the first retry. @default 1 second */
|
|
44
|
+
readonly initialDelay?: DurationInput;
|
|
45
|
+
/** Longest delay between retries, at most 60 seconds. @default 60 seconds */
|
|
46
|
+
readonly maxDelay?: DurationInput;
|
|
47
|
+
}
|
|
48
|
+
export interface FunctionProps extends ContainerProps {
|
|
49
|
+
/**
|
|
50
|
+
* Serve the program's `fetch` handler on the web instead of taking calls.
|
|
51
|
+
* The URL is the `url` attribute.
|
|
52
|
+
*/
|
|
53
|
+
web?: boolean | WebEndpointOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Run on a schedule. Each tick arrives at the program's `fetch` handler
|
|
56
|
+
* as `POST /__modal/schedule`.
|
|
57
|
+
*/
|
|
58
|
+
schedule?: FunctionSchedule;
|
|
59
|
+
/** Retry failed calls: a count, or a backoff policy. Not for web functions. */
|
|
60
|
+
retries?: number | FunctionRetries;
|
|
61
|
+
/** Most inputs one container handles at once. @default 1 */
|
|
62
|
+
maxConcurrentInputs?: number;
|
|
63
|
+
/** Inputs per container the autoscaler aims for (at most `maxConcurrentInputs`). */
|
|
64
|
+
targetConcurrentInputs?: number;
|
|
65
|
+
/** Shut each container down after it handles one input. */
|
|
66
|
+
singleUseContainers?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface FunctionAttributes extends RuntimeAttributes {
|
|
69
|
+
/** The web endpoint's URL, for a function with `web`. */
|
|
70
|
+
url: string | undefined;
|
|
71
|
+
/** The program's RPC methods, which `Modal.InvokeFunction` calls. */
|
|
72
|
+
methods: string[];
|
|
73
|
+
}
|
|
74
|
+
declare const FunctionRpcConflict_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 & {
|
|
75
|
+
readonly _tag: "Modal.FunctionRpcConflict";
|
|
76
|
+
} & Readonly<A>;
|
|
77
|
+
/** A Function's program returns RPC methods and also asks for `web` or a `schedule`. */
|
|
78
|
+
export declare class FunctionRpcConflict extends FunctionRpcConflict_base<{
|
|
79
|
+
readonly message: string;
|
|
80
|
+
}> {
|
|
81
|
+
}
|
|
82
|
+
export type Function = Resource<"Modal.Function", FunctionProps, FunctionAttributes, {
|
|
83
|
+
env?: Record<string, any>;
|
|
84
|
+
mounts?: MountContract;
|
|
85
|
+
rpcCallers?: string[];
|
|
86
|
+
}, Providers>;
|
|
87
|
+
export type FunctionServices = ServerHost;
|
|
88
|
+
/**
|
|
89
|
+
* What the program returns: `fetch` for HTTP, and any other functions,
|
|
90
|
+
* its RPC methods.
|
|
91
|
+
*/
|
|
92
|
+
export type FunctionShape = Main<FunctionServices> | (Exclude<Main<FunctionServices>, void> & MainRpc<FunctionServices>);
|
|
93
|
+
export type FunctionRuntimeContext = HostRuntimeContext;
|
|
94
|
+
/**
|
|
95
|
+
* A Modal Function running your program: Modal scales its containers with
|
|
96
|
+
* demand (to zero when idle), and the function takes calls, runs on a
|
|
97
|
+
* schedule, or serves the web.
|
|
98
|
+
*
|
|
99
|
+
* Alchemy bundles `main`, builds it into an image on Modal's builder (no
|
|
100
|
+
* Docker), and deploys the function into its `Modal.App`. Modal starts each
|
|
101
|
+
* container with its Python entrypoint; Alchemy's entrypoint starts your
|
|
102
|
+
* program and hands it work:
|
|
103
|
+
*
|
|
104
|
+
* - the program's RPC methods (every function it returns besides `fetch`)
|
|
105
|
+
* become the function's methods: `Modal.InvokeFunction` calls them with
|
|
106
|
+
* typed arguments and results, and Modal queues, retries and autoscales
|
|
107
|
+
* the calls;
|
|
108
|
+
* - with `web`, Modal routes the function's `*.modal.run` URL to the
|
|
109
|
+
* program's `fetch` handler;
|
|
110
|
+
* - a `schedule` tick arrives at `fetch` as `POST /__modal/schedule`.
|
|
111
|
+
*
|
|
112
|
+
* A function serves one of these. To serve methods next to `fetch`, use a
|
|
113
|
+
* `Modal.Server`. The program's env, including the credentials its
|
|
114
|
+
* bindings need, goes into a Modal Secret, never into the image.
|
|
115
|
+
*
|
|
116
|
+
* ### Effect program
|
|
117
|
+
* **Example:** A function other runtimes call
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // src/Embed.ts
|
|
120
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
121
|
+
* import * as Effect from "effect/Effect";
|
|
122
|
+
* import { Inference } from "./Inference.ts";
|
|
123
|
+
*
|
|
124
|
+
* export default class Embed extends Modal.Function<Embed>()(
|
|
125
|
+
* "Embed",
|
|
126
|
+
* { main: import.meta.url, app: Inference },
|
|
127
|
+
* Effect.gen(function* () {
|
|
128
|
+
* return {
|
|
129
|
+
* embed: Effect.fn(function* (text: string) {
|
|
130
|
+
* return { tokens: text.split(/\s+/).length };
|
|
131
|
+
* }),
|
|
132
|
+
* };
|
|
133
|
+
* }),
|
|
134
|
+
* ) {}
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* **Example:** Call it from a Cloudflare Worker
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const embed = yield* Modal.InvokeFunction(Embed);
|
|
140
|
+
* const { tokens } = yield* embed.embed("hello modal");
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* ### Async program
|
|
144
|
+
* **Example:** A plain HTTP server, no Effect (it runs on Bun)
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // src/Embed.ts
|
|
147
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
148
|
+
* import { Inference } from "./Inference.ts";
|
|
149
|
+
*
|
|
150
|
+
* export const Embed = Modal.Function("Embed", {
|
|
151
|
+
* main: "./src/embed-server.ts",
|
|
152
|
+
* app: Inference,
|
|
153
|
+
* env: { MODEL: "small" },
|
|
154
|
+
* });
|
|
155
|
+
* export type EmbedEnv = Modal.InferEnv<typeof Embed>;
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* ```typescript
|
|
159
|
+
* // src/embed-server.ts
|
|
160
|
+
* import type { EmbedEnv } from "./Embed.ts";
|
|
161
|
+
*
|
|
162
|
+
* const env = process.env as unknown as EmbedEnv;
|
|
163
|
+
*
|
|
164
|
+
* Bun.serve({
|
|
165
|
+
* port: Number(process.env.PORT),
|
|
166
|
+
* async fetch(request) {
|
|
167
|
+
* const { args } = (await request.json()) as { args: [string] };
|
|
168
|
+
* return Response.json({ model: env.MODEL, tokens: args[0].split(/\s+/).length });
|
|
169
|
+
* },
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* ### Web endpoints
|
|
174
|
+
* **Example:** Serve `fetch` at a `*.modal.run` URL
|
|
175
|
+
* ```typescript
|
|
176
|
+
* export default class Api extends Modal.Function<Api>()(
|
|
177
|
+
* "Api",
|
|
178
|
+
* { main: import.meta.url, app: Inference, web: true },
|
|
179
|
+
* Effect.gen(function* () {
|
|
180
|
+
* return { fetch: Effect.succeed(HttpServerResponse.text("hello from Modal")) };
|
|
181
|
+
* }),
|
|
182
|
+
* ) {}
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* **Example:** Behind Modal's proxy auth
|
|
186
|
+
* ```typescript
|
|
187
|
+
* export default class Admin extends Modal.Function<Admin>()(
|
|
188
|
+
* "Admin",
|
|
189
|
+
* { main: import.meta.url, app: Inference, web: { requiresProxyAuth: true, label: "admin" } },
|
|
190
|
+
* program,
|
|
191
|
+
* ) {}
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* ### Schedules
|
|
195
|
+
* **Example:** Run every morning
|
|
196
|
+
* ```typescript
|
|
197
|
+
* export default class Digest extends Modal.Function<Digest>()(
|
|
198
|
+
* "Digest",
|
|
199
|
+
* { main: import.meta.url, app: Inference, schedule: { cron: "0 9 * * *", timezone: "Europe/London" } },
|
|
200
|
+
* Effect.gen(function* () {
|
|
201
|
+
* return {
|
|
202
|
+
* fetch: Effect.gen(function* () {
|
|
203
|
+
* yield* Effect.log("sending the digest");
|
|
204
|
+
* return yield* HttpServerResponse.json(null);
|
|
205
|
+
* }),
|
|
206
|
+
* };
|
|
207
|
+
* }),
|
|
208
|
+
* ) {}
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* ### GPUs, volumes and scaling
|
|
212
|
+
* **Example:** A warm GPU function reading weights from a volume
|
|
213
|
+
* ```typescript
|
|
214
|
+
* export default class Generate extends Modal.Function<Generate>()(
|
|
215
|
+
* "Generate",
|
|
216
|
+
* {
|
|
217
|
+
* main: import.meta.url,
|
|
218
|
+
* app: Inference,
|
|
219
|
+
* gpu: "L4",
|
|
220
|
+
* mounts: [{ volume: Weights, path: "/models" }],
|
|
221
|
+
* minContainers: 1,
|
|
222
|
+
* scaledownWindow: 300,
|
|
223
|
+
* maxConcurrentInputs: 8,
|
|
224
|
+
* timeout: "10 minutes",
|
|
225
|
+
* },
|
|
226
|
+
* program,
|
|
227
|
+
* ) {}
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @resource
|
|
231
|
+
* @product Function
|
|
232
|
+
*/
|
|
233
|
+
export declare const Function: Platform<Function, FunctionServices, FunctionShape, FunctionRuntimeContext>;
|
|
234
|
+
export declare const FunctionProvider: () => import("effect/Layer").Layer<Provider.Provider<Function>, never, import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("alchemy/Stack").Stack | import("alchemy/Stage").Stage | functions.ModalOpContext>;
|
|
235
|
+
export {};
|
|
236
|
+
//# sourceMappingURL=Function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Function.d.ts","sources":["../src/Function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,QAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0IG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,sBAAsB,CAI7F,CAAC;AAqGL,eAAO,MAAM,gBAAgB,wOAuC1B,CAAC"}
|
package/lib/Function.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { Platform } from "alchemy/Platform";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { seconds } from "./internal.js";
|
|
6
|
+
import { ENTRYPOINT, RPC_SERVE_ENV } from "./internal/Entrypoint.js";
|
|
7
|
+
import { createModalRuntimeContext, rpcMethodNamesOf } from "./internal/Rpc.js";
|
|
8
|
+
import { resolveContainerProps, runtimeLifecycle, } from "./internal/Runtime.js";
|
|
9
|
+
/** A Function's program returns RPC methods and also asks for `web` or a `schedule`. */
|
|
10
|
+
export class FunctionRpcConflict extends Data.TaggedError("Modal.FunctionRpcConflict") {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A Modal Function running your program: Modal scales its containers with
|
|
14
|
+
* demand (to zero when idle), and the function takes calls, runs on a
|
|
15
|
+
* schedule, or serves the web.
|
|
16
|
+
*
|
|
17
|
+
* Alchemy bundles `main`, builds it into an image on Modal's builder (no
|
|
18
|
+
* Docker), and deploys the function into its `Modal.App`. Modal starts each
|
|
19
|
+
* container with its Python entrypoint; Alchemy's entrypoint starts your
|
|
20
|
+
* program and hands it work:
|
|
21
|
+
*
|
|
22
|
+
* - the program's RPC methods (every function it returns besides `fetch`)
|
|
23
|
+
* become the function's methods: `Modal.InvokeFunction` calls them with
|
|
24
|
+
* typed arguments and results, and Modal queues, retries and autoscales
|
|
25
|
+
* the calls;
|
|
26
|
+
* - with `web`, Modal routes the function's `*.modal.run` URL to the
|
|
27
|
+
* program's `fetch` handler;
|
|
28
|
+
* - a `schedule` tick arrives at `fetch` as `POST /__modal/schedule`.
|
|
29
|
+
*
|
|
30
|
+
* A function serves one of these. To serve methods next to `fetch`, use a
|
|
31
|
+
* `Modal.Server`. The program's env, including the credentials its
|
|
32
|
+
* bindings need, goes into a Modal Secret, never into the image.
|
|
33
|
+
*
|
|
34
|
+
* ### Effect program
|
|
35
|
+
* **Example:** A function other runtimes call
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // src/Embed.ts
|
|
38
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
39
|
+
* import * as Effect from "effect/Effect";
|
|
40
|
+
* import { Inference } from "./Inference.ts";
|
|
41
|
+
*
|
|
42
|
+
* export default class Embed extends Modal.Function<Embed>()(
|
|
43
|
+
* "Embed",
|
|
44
|
+
* { main: import.meta.url, app: Inference },
|
|
45
|
+
* Effect.gen(function* () {
|
|
46
|
+
* return {
|
|
47
|
+
* embed: Effect.fn(function* (text: string) {
|
|
48
|
+
* return { tokens: text.split(/\s+/).length };
|
|
49
|
+
* }),
|
|
50
|
+
* };
|
|
51
|
+
* }),
|
|
52
|
+
* ) {}
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* **Example:** Call it from a Cloudflare Worker
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const embed = yield* Modal.InvokeFunction(Embed);
|
|
58
|
+
* const { tokens } = yield* embed.embed("hello modal");
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ### Async program
|
|
62
|
+
* **Example:** A plain HTTP server, no Effect (it runs on Bun)
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // src/Embed.ts
|
|
65
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
66
|
+
* import { Inference } from "./Inference.ts";
|
|
67
|
+
*
|
|
68
|
+
* export const Embed = Modal.Function("Embed", {
|
|
69
|
+
* main: "./src/embed-server.ts",
|
|
70
|
+
* app: Inference,
|
|
71
|
+
* env: { MODEL: "small" },
|
|
72
|
+
* });
|
|
73
|
+
* export type EmbedEnv = Modal.InferEnv<typeof Embed>;
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // src/embed-server.ts
|
|
78
|
+
* import type { EmbedEnv } from "./Embed.ts";
|
|
79
|
+
*
|
|
80
|
+
* const env = process.env as unknown as EmbedEnv;
|
|
81
|
+
*
|
|
82
|
+
* Bun.serve({
|
|
83
|
+
* port: Number(process.env.PORT),
|
|
84
|
+
* async fetch(request) {
|
|
85
|
+
* const { args } = (await request.json()) as { args: [string] };
|
|
86
|
+
* return Response.json({ model: env.MODEL, tokens: args[0].split(/\s+/).length });
|
|
87
|
+
* },
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* ### Web endpoints
|
|
92
|
+
* **Example:** Serve `fetch` at a `*.modal.run` URL
|
|
93
|
+
* ```typescript
|
|
94
|
+
* export default class Api extends Modal.Function<Api>()(
|
|
95
|
+
* "Api",
|
|
96
|
+
* { main: import.meta.url, app: Inference, web: true },
|
|
97
|
+
* Effect.gen(function* () {
|
|
98
|
+
* return { fetch: Effect.succeed(HttpServerResponse.text("hello from Modal")) };
|
|
99
|
+
* }),
|
|
100
|
+
* ) {}
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* **Example:** Behind Modal's proxy auth
|
|
104
|
+
* ```typescript
|
|
105
|
+
* export default class Admin extends Modal.Function<Admin>()(
|
|
106
|
+
* "Admin",
|
|
107
|
+
* { main: import.meta.url, app: Inference, web: { requiresProxyAuth: true, label: "admin" } },
|
|
108
|
+
* program,
|
|
109
|
+
* ) {}
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* ### Schedules
|
|
113
|
+
* **Example:** Run every morning
|
|
114
|
+
* ```typescript
|
|
115
|
+
* export default class Digest extends Modal.Function<Digest>()(
|
|
116
|
+
* "Digest",
|
|
117
|
+
* { main: import.meta.url, app: Inference, schedule: { cron: "0 9 * * *", timezone: "Europe/London" } },
|
|
118
|
+
* Effect.gen(function* () {
|
|
119
|
+
* return {
|
|
120
|
+
* fetch: Effect.gen(function* () {
|
|
121
|
+
* yield* Effect.log("sending the digest");
|
|
122
|
+
* return yield* HttpServerResponse.json(null);
|
|
123
|
+
* }),
|
|
124
|
+
* };
|
|
125
|
+
* }),
|
|
126
|
+
* ) {}
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* ### GPUs, volumes and scaling
|
|
130
|
+
* **Example:** A warm GPU function reading weights from a volume
|
|
131
|
+
* ```typescript
|
|
132
|
+
* export default class Generate extends Modal.Function<Generate>()(
|
|
133
|
+
* "Generate",
|
|
134
|
+
* {
|
|
135
|
+
* main: import.meta.url,
|
|
136
|
+
* app: Inference,
|
|
137
|
+
* gpu: "L4",
|
|
138
|
+
* mounts: [{ volume: Weights, path: "/models" }],
|
|
139
|
+
* minContainers: 1,
|
|
140
|
+
* scaledownWindow: 300,
|
|
141
|
+
* maxConcurrentInputs: 8,
|
|
142
|
+
* timeout: "10 minutes",
|
|
143
|
+
* },
|
|
144
|
+
* program,
|
|
145
|
+
* ) {}
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @resource
|
|
149
|
+
* @product Function
|
|
150
|
+
*/
|
|
151
|
+
export const Function = Platform("Modal.Function", {
|
|
152
|
+
createRuntimeContext: createModalRuntimeContext("Modal.Function"),
|
|
153
|
+
transformProps: resolveContainerProps,
|
|
154
|
+
});
|
|
155
|
+
const bootstrapEntry = (handler) => (importPath) => `
|
|
156
|
+
import { bootstrap } from "@alchemy.run/modal/Bootstrap";
|
|
157
|
+
import { ${handler} as entrypoint } from ${JSON.stringify(importPath)};
|
|
158
|
+
|
|
159
|
+
await bootstrap(entrypoint);
|
|
160
|
+
`;
|
|
161
|
+
const scheduleOf = (schedule) => schedule === undefined
|
|
162
|
+
? undefined
|
|
163
|
+
: "cron" in schedule
|
|
164
|
+
? { cron: { cronString: schedule.cron, timezone: schedule.timezone ?? "UTC" } }
|
|
165
|
+
: { period: { seconds: seconds(schedule.period) } };
|
|
166
|
+
const retriesOf = (retries) => retries === undefined
|
|
167
|
+
? undefined
|
|
168
|
+
: typeof retries === "number"
|
|
169
|
+
? { retries, backoffCoefficient: 1, initialDelayMs: 1000, maxDelayMs: 60_000 }
|
|
170
|
+
: {
|
|
171
|
+
retries: retries.maxRetries,
|
|
172
|
+
backoffCoefficient: retries.backoffCoefficient ?? 2,
|
|
173
|
+
initialDelayMs: Math.round((seconds(retries.initialDelay) ?? 1) * 1000),
|
|
174
|
+
maxDelayMs: Math.round((seconds(retries.maxDelay) ?? 60) * 1000),
|
|
175
|
+
};
|
|
176
|
+
/** How a Function differs from the other runtimes: a call, schedule or web function. */
|
|
177
|
+
const definitionOf = (props, context) => {
|
|
178
|
+
const methods = rpcMethodNamesOf(props.env);
|
|
179
|
+
if (methods.length > 0) {
|
|
180
|
+
// One method per RPC method: callers send its name as the input's
|
|
181
|
+
// `method_name`, and the entrypoint's `Rpc` class forwards it to the
|
|
182
|
+
// program's `/__rpc__/<method>`.
|
|
183
|
+
const formats = ["DATA_FORMAT_PICKLE", "DATA_FORMAT_CBOR"];
|
|
184
|
+
return {
|
|
185
|
+
implementationName: ENTRYPOINT.rpc,
|
|
186
|
+
isClass: true,
|
|
187
|
+
methodDefinitions: Object.fromEntries(methods.map((name) => [
|
|
188
|
+
name,
|
|
189
|
+
{
|
|
190
|
+
functionName: name,
|
|
191
|
+
functionType: "FUNCTION_TYPE_FUNCTION",
|
|
192
|
+
supportedInputFormats: formats,
|
|
193
|
+
supportedOutputFormats: formats,
|
|
194
|
+
},
|
|
195
|
+
])),
|
|
196
|
+
supportedInputFormats: formats,
|
|
197
|
+
supportedOutputFormats: formats,
|
|
198
|
+
retryPolicy: retriesOf(props.retries),
|
|
199
|
+
maxConcurrentInputs: props.maxConcurrentInputs ?? 0,
|
|
200
|
+
targetConcurrentInputs: props.targetConcurrentInputs ?? 0,
|
|
201
|
+
singleUseContainers: props.singleUseContainers,
|
|
202
|
+
maxInputs: props.singleUseContainers ? 1 : 0,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if (props.web) {
|
|
206
|
+
const web = props.web === true ? {} : props.web;
|
|
207
|
+
return {
|
|
208
|
+
implementationName: ENTRYPOINT.web,
|
|
209
|
+
webhookConfig: {
|
|
210
|
+
type: "WEBHOOK_TYPE_WEB_SERVER",
|
|
211
|
+
webServerPort: context.port,
|
|
212
|
+
webServerStartupTimeout: context.startupTimeout,
|
|
213
|
+
requestedSuffix: web.label,
|
|
214
|
+
requiresProxyAuth: web.requiresProxyAuth,
|
|
215
|
+
customDomains: web.customDomains?.map((name) => ({ name })),
|
|
216
|
+
},
|
|
217
|
+
supportedInputFormats: ["DATA_FORMAT_ASGI"],
|
|
218
|
+
supportedOutputFormats: ["DATA_FORMAT_ASGI", "DATA_FORMAT_GENERATOR_DONE"],
|
|
219
|
+
schedule: scheduleOf(props.schedule),
|
|
220
|
+
maxConcurrentInputs: props.maxConcurrentInputs ?? 0,
|
|
221
|
+
targetConcurrentInputs: props.targetConcurrentInputs ?? 0,
|
|
222
|
+
singleUseContainers: props.singleUseContainers,
|
|
223
|
+
maxInputs: props.singleUseContainers ? 1 : 0,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
implementationName: props.schedule ? ENTRYPOINT.schedule : ENTRYPOINT.call,
|
|
228
|
+
supportedInputFormats: ["DATA_FORMAT_PICKLE", "DATA_FORMAT_CBOR"],
|
|
229
|
+
supportedOutputFormats: ["DATA_FORMAT_PICKLE", "DATA_FORMAT_CBOR"],
|
|
230
|
+
schedule: scheduleOf(props.schedule),
|
|
231
|
+
retryPolicy: retriesOf(props.retries),
|
|
232
|
+
maxConcurrentInputs: props.maxConcurrentInputs ?? 0,
|
|
233
|
+
targetConcurrentInputs: props.targetConcurrentInputs ?? 0,
|
|
234
|
+
singleUseContainers: props.singleUseContainers,
|
|
235
|
+
maxInputs: props.singleUseContainers ? 1 : 0,
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
export const FunctionProvider = () => Provider.effect(Function, Effect.gen(function* () {
|
|
239
|
+
const lifecycle = yield* runtimeLifecycle({
|
|
240
|
+
type: "Modal.Function",
|
|
241
|
+
definition: definitionOf,
|
|
242
|
+
bootstrap: bootstrapEntry,
|
|
243
|
+
// Modal authenticates every call of a class function, so its
|
|
244
|
+
// program serves RPC (see `createModalRuntimeContext`).
|
|
245
|
+
env: (props) => rpcMethodNamesOf(props.env).length > 0 ? { [RPC_SERVE_ENV]: "1" } : {},
|
|
246
|
+
});
|
|
247
|
+
return {
|
|
248
|
+
stables: lifecycle.stables,
|
|
249
|
+
diff: lifecycle.diff,
|
|
250
|
+
read: Effect.fn(function* ({ output }) {
|
|
251
|
+
const found = yield* lifecycle.read({ output });
|
|
252
|
+
return found === undefined ? undefined : output;
|
|
253
|
+
}),
|
|
254
|
+
reconcile: Effect.fn(function* ({ id, news, output, session, bindings }) {
|
|
255
|
+
const methods = rpcMethodNamesOf(news.env);
|
|
256
|
+
if (methods.length > 0 && (news.web || news.schedule)) {
|
|
257
|
+
return yield* new FunctionRpcConflict({
|
|
258
|
+
message: `${id} returns RPC methods (${methods.join(", ")}) and sets ${news.web ? "web" : "schedule"}: a Modal.Function serves calls to its methods, a web endpoint or a schedule. Serve methods next to fetch with a Modal.Server.`,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
const { attributes, metadata } = yield* lifecycle.reconcile({
|
|
262
|
+
id,
|
|
263
|
+
news,
|
|
264
|
+
output,
|
|
265
|
+
session,
|
|
266
|
+
bindings,
|
|
267
|
+
});
|
|
268
|
+
return { ...attributes, url: news.web ? metadata?.webUrl : undefined, methods };
|
|
269
|
+
}),
|
|
270
|
+
delete: lifecycle.delete,
|
|
271
|
+
};
|
|
272
|
+
}));
|
|
273
|
+
//# sourceMappingURL=Function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Function.js","sources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ACJ,MAAM;gBACN,OAAO;gBACP,QAAQ;aACT,CAAC,CAAC;YACH,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;QAClF,CAAC,CAAC;QACF,MAAM,EAAE,SAAS,CAAC,MAAM;KACzB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as functions from "@distilled.cloud/modal/functions";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { type EnvironmentInput } from "./internal.ts";
|
|
6
|
+
import type { Providers } from "./Providers.ts";
|
|
7
|
+
declare const FunctionAutoscalerUnexpectedResponse_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 & {
|
|
8
|
+
readonly _tag: "Modal.FunctionAutoscalerUnexpectedResponse";
|
|
9
|
+
} & Readonly<A>;
|
|
10
|
+
export declare class FunctionAutoscalerUnexpectedResponse extends FunctionAutoscalerUnexpectedResponse_base<{
|
|
11
|
+
readonly message: string;
|
|
12
|
+
}> {
|
|
13
|
+
}
|
|
14
|
+
export interface FunctionAutoscalerProps {
|
|
15
|
+
/** Name of the deployed App that defines the function. */
|
|
16
|
+
app: string;
|
|
17
|
+
/**
|
|
18
|
+
* The function's name in the App (`"f"` for `@app.function() def f`, or
|
|
19
|
+
* `"Model.*"` for a class). Changing it, the app or the environment
|
|
20
|
+
* replaces this resource.
|
|
21
|
+
*/
|
|
22
|
+
function: string;
|
|
23
|
+
/**
|
|
24
|
+
* Environment the App is deployed in.
|
|
25
|
+
* @default the workspace's default environment
|
|
26
|
+
*/
|
|
27
|
+
environment?: EnvironmentInput;
|
|
28
|
+
/** Containers kept running even with no inputs (`min_containers`). */
|
|
29
|
+
minContainers?: number;
|
|
30
|
+
/** Most containers the function runs at once (`max_containers`). */
|
|
31
|
+
maxContainers?: number;
|
|
32
|
+
/** Extra idle containers kept ready while the function is busy (`buffer_containers`). */
|
|
33
|
+
bufferContainers?: number;
|
|
34
|
+
/** How long an idle container stays up before scaling down (`scaledown_window`). */
|
|
35
|
+
scaledownWindow?: number | string;
|
|
36
|
+
/** Sustained demand needed before scaling up (`scaleup_window`). */
|
|
37
|
+
scaleupWindow?: number | string;
|
|
38
|
+
/** Inputs each container handles at once before more are added. */
|
|
39
|
+
targetConcurrency?: number;
|
|
40
|
+
}
|
|
41
|
+
/** The autoscaler settings Modal stores for a function. */
|
|
42
|
+
export interface AutoscalerSettingsState {
|
|
43
|
+
minContainers?: number;
|
|
44
|
+
maxContainers?: number;
|
|
45
|
+
bufferContainers?: number;
|
|
46
|
+
scaledownWindow?: number;
|
|
47
|
+
scaleupWindow?: number;
|
|
48
|
+
targetConcurrency?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface FunctionAutoscalerAttributes {
|
|
51
|
+
/** Function ID (`fu-…`). */
|
|
52
|
+
functionId: string;
|
|
53
|
+
/** The settings in effect after the last deploy. */
|
|
54
|
+
settings: AutoscalerSettingsState;
|
|
55
|
+
/** The settings found before the first deploy, restored on destroy. */
|
|
56
|
+
original: AutoscalerSettingsState;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Autoscaling settings for a Modal Function deployed with Modal's Python
|
|
60
|
+
* client (`modal deploy`): warm containers, a container cap, buffer
|
|
61
|
+
* containers and scale-down timing, changed without redeploying the app.
|
|
62
|
+
*
|
|
63
|
+
* For a `Modal.Function` or `Modal.Server` of the Stack, set these on the
|
|
64
|
+
* resource itself. This resource adjusts a function deployed outside the
|
|
65
|
+
* Stack, and restores
|
|
66
|
+
* the settings it found when destroyed. Modal resets overrides like these
|
|
67
|
+
* when the app is redeployed, so redeploying the app and then this stack
|
|
68
|
+
* applies them again.
|
|
69
|
+
*
|
|
70
|
+
* ### Keeping containers warm
|
|
71
|
+
* **Example:** Two warm containers during business hours
|
|
72
|
+
* ```typescript
|
|
73
|
+
* import * as Modal from "@alchemy.run/modal";
|
|
74
|
+
*
|
|
75
|
+
* export const Warm = Modal.FunctionAutoscaler("Warm", {
|
|
76
|
+
* app: "inference",
|
|
77
|
+
* function: "Model.*",
|
|
78
|
+
* minContainers: 2,
|
|
79
|
+
* bufferContainers: 1,
|
|
80
|
+
* scaledownWindow: "5 minutes",
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @resource
|
|
85
|
+
* @product Function
|
|
86
|
+
*/
|
|
87
|
+
export declare const FunctionAutoscaler: import("alchemy/Resource").ResourceConstructor<FunctionAutoscaler, Providers> & Effect.Effect<import("alchemy/Resource").ResourceConstructor<FunctionAutoscaler, never>, never, never> & {
|
|
88
|
+
Self: import("alchemy/Self").Self<FunctionAutoscaler>;
|
|
89
|
+
Provider: Provider.Provider<FunctionAutoscaler>;
|
|
90
|
+
Aliases: readonly string[] | undefined;
|
|
91
|
+
ref(id: string, options?: {
|
|
92
|
+
stage?: string;
|
|
93
|
+
stack?: string;
|
|
94
|
+
}): Effect.Effect<FunctionAutoscaler, never, never>;
|
|
95
|
+
} & ((id: string, props: import("./internal/Declared.ts").DeclaredProps<FunctionAutoscalerProps>) => Effect.Effect<FunctionAutoscaler, never, Providers>);
|
|
96
|
+
export type FunctionAutoscaler = Resource<"Modal.FunctionAutoscaler", FunctionAutoscalerProps, FunctionAutoscalerAttributes, never, Providers>;
|
|
97
|
+
export declare const FunctionAutoscalerProvider: () => import("effect/Layer").Layer<Provider.Provider<FunctionAutoscaler>, never, functions.ModalOpContext>;
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=FunctionAutoscaler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Function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