alchemy 2.0.0-beta.13 → 2.0.0-beta.14
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/bin/alchemy.js +8386 -8205
- package/bin/alchemy.js.map +1 -1
- package/bin/alchemy.ts +4 -2
- package/bin/cli.js +61 -0
- package/bin/commands/deploy.ts +6 -3
- package/bin/commands/login.ts +1 -1
- package/bin/commands/logs.ts +1 -1
- package/bin/commands/state.ts +230 -0
- package/bin/commands/tail.ts +1 -1
- package/lib/AWS/AutoScaling/LaunchTemplate.d.ts +1 -1
- package/lib/AWS/EC2/Instance.d.ts +1 -1
- package/lib/AWS/EC2/hosted.d.ts +2 -2
- package/lib/AWS/ECS/Task.d.ts +4 -4
- package/lib/AWS/ECS/Task.d.ts.map +1 -1
- package/lib/AWS/ECS/Task.js +2 -2
- package/lib/AWS/ECS/Task.js.map +1 -1
- package/lib/AWS/Environment.d.ts +2 -2
- package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.d.ts +2 -2
- package/lib/AWS/Lambda/Function.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.js +1 -2
- package/lib/AWS/Lambda/Function.js.map +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
- package/lib/AWS/SQS/QueueSink.d.ts.map +1 -1
- package/lib/AWS/SQS/QueueSink.js +1 -2
- package/lib/AWS/SQS/QueueSink.js.map +1 -1
- package/lib/Agent/coding/bash.d.ts +2 -6
- package/lib/Agent/coding/bash.d.ts.map +1 -1
- package/lib/Agent/coding/bash.js +2 -3
- package/lib/Agent/coding/bash.js.map +1 -1
- package/lib/Agent/coding/edit.d.ts +1 -1
- package/lib/Agent/coding/glob.d.ts +2 -4
- package/lib/Agent/coding/glob.d.ts.map +1 -1
- package/lib/Agent/coding/glob.js +1 -2
- package/lib/Agent/coding/glob.js.map +1 -1
- package/lib/Agent/coding/grep.d.ts +2 -4
- package/lib/Agent/coding/grep.d.ts.map +1 -1
- package/lib/Agent/coding/grep.js +1 -2
- package/lib/Agent/coding/grep.js.map +1 -1
- package/lib/Agent/coding/read.d.ts +1 -1
- package/lib/Agent/coding/write.d.ts +1 -1
- package/lib/Agent/util/ripgrep.d.ts +2 -2
- package/lib/AlchemyContext.d.ts +13 -0
- package/lib/AlchemyContext.d.ts.map +1 -0
- package/lib/AlchemyContext.js +18 -0
- package/lib/AlchemyContext.js.map +1 -0
- package/lib/Auth/AuthProvider.js +1 -1
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/Profile.d.ts +1 -1
- package/lib/Auth/index.d.ts +3 -1
- package/lib/Auth/index.d.ts.map +1 -1
- package/lib/Auth/index.js +3 -0
- package/lib/Auth/index.js.map +1 -1
- package/lib/Build/Command.d.ts +1 -1
- package/lib/Build/Memo.d.ts +1 -1
- package/lib/Bundle/Docker.d.ts +3 -3
- package/lib/Bundle/TempRoot.d.ts +3 -3
- package/lib/Cli/InkCLI.d.ts +1 -0
- package/lib/Cli/InkCLI.d.ts.map +1 -1
- package/lib/Cli/InkCLI.js +5 -0
- package/lib/Cli/InkCLI.js.map +1 -1
- package/lib/Cli/LoggingCli.d.ts +4 -0
- package/lib/Cli/LoggingCli.d.ts.map +1 -0
- package/lib/{Test/TestCli.js → Cli/LoggingCli.js} +3 -3
- package/lib/Cli/LoggingCli.js.map +1 -0
- package/lib/Cloudflare/CloudflareEnvironment.d.ts +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.d.ts +2 -2
- package/lib/Cloudflare/Container/ContainerApplication.d.ts.map +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.js +7 -2
- package/lib/Cloudflare/Container/ContainerApplication.js.map +1 -1
- package/lib/Cloudflare/EdgeSession.d.ts +53 -0
- package/lib/Cloudflare/EdgeSession.d.ts.map +1 -0
- package/lib/Cloudflare/EdgeSession.js +78 -0
- package/lib/Cloudflare/EdgeSession.js.map +1 -0
- package/lib/Cloudflare/Providers.d.ts +1 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/StateStore/Api.d.ts +62 -0
- package/lib/Cloudflare/StateStore/Api.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/Api.js +101 -0
- package/lib/Cloudflare/StateStore/Api.js.map +1 -0
- package/lib/Cloudflare/StateStore/State.d.ts +39 -0
- package/lib/Cloudflare/StateStore/State.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/State.js +217 -0
- package/lib/Cloudflare/StateStore/State.js.map +1 -0
- package/lib/Cloudflare/StateStore/Store.d.ts +82 -0
- package/lib/Cloudflare/StateStore/Store.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/Store.js +189 -0
- package/lib/Cloudflare/StateStore/Store.js.map +1 -0
- package/lib/Cloudflare/StateStore/Token.d.ts +41 -0
- package/lib/Cloudflare/StateStore/Token.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/Token.js +57 -0
- package/lib/Cloudflare/StateStore/Token.js.map +1 -0
- package/lib/Cloudflare/StateStore/index.d.ts +2 -0
- package/lib/Cloudflare/StateStore/index.d.ts.map +1 -0
- package/lib/Cloudflare/StateStore/index.js +2 -0
- package/lib/Cloudflare/StateStore/index.js.map +1 -0
- package/lib/Cloudflare/Workers/Assets.d.ts +2 -2
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +2 -2
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js +0 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.d.ts +1 -1
- package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +5 -5
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +0 -1
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/index.d.ts +3 -1
- package/lib/Cloudflare/index.d.ts.map +1 -1
- package/lib/Cloudflare/index.js +3 -1
- package/lib/Cloudflare/index.js.map +1 -1
- package/lib/Deploy.d.ts +10 -0
- package/lib/Deploy.d.ts.map +1 -0
- package/lib/Deploy.js +12 -0
- package/lib/Deploy.js.map +1 -0
- package/lib/Destroy.d.ts +8 -3
- package/lib/Destroy.d.ts.map +1 -1
- package/lib/Destroy.js +8 -8
- package/lib/Destroy.js.map +1 -1
- package/lib/Http.d.ts +1 -1
- package/lib/Http.d.ts.map +1 -1
- package/lib/Http.js +7 -3
- package/lib/Http.js.map +1 -1
- package/lib/Kubernetes/client.d.ts +10 -10
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js.map +1 -1
- package/lib/Platform.d.ts +2 -2
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js.map +1 -1
- package/lib/Provider.d.ts.map +1 -1
- package/lib/Provider.js +0 -1
- package/lib/Provider.js.map +1 -1
- package/lib/Stack.d.ts +23 -12
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +32 -14
- package/lib/Stack.js.map +1 -1
- package/lib/State/HttpStateApi.d.ts +96 -0
- package/lib/State/HttpStateApi.d.ts.map +1 -0
- package/lib/State/HttpStateApi.js +96 -0
- package/lib/State/HttpStateApi.js.map +1 -0
- package/lib/State/HttpStateStore.d.ts +10 -0
- package/lib/State/HttpStateStore.d.ts.map +1 -0
- package/lib/State/HttpStateStore.js +102 -0
- package/lib/State/HttpStateStore.js.map +1 -0
- package/lib/State/InMemoryState.d.ts +2 -30
- package/lib/State/InMemoryState.d.ts.map +1 -1
- package/lib/State/InMemoryState.js +23 -18
- package/lib/State/InMemoryState.js.map +1 -1
- package/lib/State/LocalState.d.ts +4 -2
- package/lib/State/LocalState.d.ts.map +1 -1
- package/lib/State/LocalState.js +9 -41
- package/lib/State/LocalState.js.map +1 -1
- package/lib/State/State.d.ts +11 -4
- package/lib/State/State.d.ts.map +1 -1
- package/lib/State/State.js +1 -1
- package/lib/State/State.js.map +1 -1
- package/lib/State/StateEncoding.d.ts +31 -0
- package/lib/State/StateEncoding.d.ts.map +1 -0
- package/lib/State/StateEncoding.js +82 -0
- package/lib/State/StateEncoding.js.map +1 -0
- package/lib/State/Sync.d.ts +23 -0
- package/lib/State/Sync.d.ts.map +1 -0
- package/lib/State/Sync.js +49 -0
- package/lib/State/Sync.js.map +1 -0
- package/lib/State/index.d.ts +4 -0
- package/lib/State/index.d.ts.map +1 -1
- package/lib/State/index.js +4 -0
- package/lib/State/index.js.map +1 -1
- package/lib/Test/Bun.d.ts +13 -17
- package/lib/Test/Bun.d.ts.map +1 -1
- package/lib/Test/Bun.js +16 -33
- package/lib/Test/Bun.js.map +1 -1
- package/lib/Test/TestState.d.ts +1 -2
- package/lib/Test/TestState.d.ts.map +1 -1
- package/lib/Test/TestState.js +5 -9
- package/lib/Test/TestState.js.map +1 -1
- package/lib/Test/Vitest.d.ts +3 -2
- package/lib/Test/Vitest.d.ts.map +1 -1
- package/lib/Test/Vitest.js +20 -15
- package/lib/Test/Vitest.js.map +1 -1
- package/lib/Test/index.d.ts +0 -1
- package/lib/Test/index.d.ts.map +1 -1
- package/lib/Test/index.js +0 -1
- package/lib/Test/index.js.map +1 -1
- package/lib/Util/FileLogger.d.ts +2 -2
- package/lib/Util/FileLogger.d.ts.map +1 -1
- package/lib/Util/FileLogger.js +2 -2
- package/lib/Util/FileLogger.js.map +1 -1
- package/lib/cli/index.d.ts +10 -1
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +9 -4
- package/lib/cli/index.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/package.json +26 -11
- package/src/AWS/ECS/Task.ts +4 -4
- package/src/AWS/Lambda/Function.ts +2 -3
- package/src/AWS/SQS/QueueSink.ts +1 -2
- package/src/Agent/coding/bash.ts +2 -3
- package/src/Agent/coding/glob.ts +1 -2
- package/src/Agent/coding/grep.ts +1 -2
- package/src/AlchemyContext.ts +27 -0
- package/src/Auth/AuthProvider.ts +1 -1
- package/src/Auth/index.ts +3 -1
- package/src/Cli/InkCLI.tsx +10 -0
- package/src/{Test/TestCli.ts → Cli/LoggingCli.ts} +2 -2
- package/src/Cloudflare/Container/ContainerApplication.ts +8 -2
- package/src/Cloudflare/EdgeSession.ts +144 -0
- package/src/Cloudflare/StateStore/Api.ts +157 -0
- package/src/Cloudflare/StateStore/State.ts +318 -0
- package/src/Cloudflare/StateStore/Store.ts +288 -0
- package/src/Cloudflare/StateStore/Token.ts +62 -0
- package/src/Cloudflare/StateStore/index.ts +1 -0
- package/src/Cloudflare/Workers/DurableObjectNamespace.ts +1 -6
- package/src/Cloudflare/Workers/HttpServer.ts +1 -1
- package/src/Cloudflare/Workers/Worker.ts +7 -7
- package/src/Cloudflare/index.ts +3 -1
- package/src/Deploy.ts +25 -0
- package/src/Destroy.ts +25 -13
- package/src/Http.ts +31 -16
- package/src/Output.ts +0 -2
- package/src/Platform.ts +8 -2
- package/src/Provider.ts +0 -2
- package/src/Stack.ts +122 -47
- package/src/State/HttpStateApi.ts +155 -0
- package/src/State/HttpStateStore.ts +155 -0
- package/src/State/InMemoryState.ts +15 -17
- package/src/State/LocalState.ts +13 -45
- package/src/State/State.ts +13 -4
- package/src/State/StateEncoding.ts +83 -0
- package/src/State/Sync.ts +89 -0
- package/src/State/index.ts +4 -0
- package/src/Test/Bun.ts +29 -87
- package/src/Test/TestState.ts +6 -8
- package/src/Test/Vitest.ts +32 -23
- package/src/Test/index.ts +0 -1
- package/src/Util/FileLogger.ts +2 -2
- package/src/index.ts +2 -1
- package/lib/Config.d.ts +0 -20
- package/lib/Config.d.ts.map +0 -1
- package/lib/Config.js +0 -22
- package/lib/Config.js.map +0 -1
- package/lib/Observability.d.ts +0 -2
- package/lib/Observability.d.ts.map +0 -1
- package/lib/Observability.js +0 -1
- package/lib/Observability.js.map +0 -1
- package/lib/Test/TestCli.d.ts +0 -4
- package/lib/Test/TestCli.d.ts.map +0 -1
- package/lib/Test/TestCli.js.map +0 -1
- package/src/Config.ts +0 -31
- package/src/Observability.ts +0 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * as AdoptPolicy from "./AdoptPolicy.ts";
|
|
2
|
+
export * from "./AlchemyContext.ts";
|
|
2
3
|
export * from "./Apply.ts";
|
|
3
4
|
export { Service as BindingService, Policy, type ServiceLike as BindingServiceLike, type ServiceShape as BindingServiceShape, type PolicyLike, type PolicyShape, } from "./Binding.ts";
|
|
4
|
-
export * from "./Config.ts";
|
|
5
5
|
export * from "./Destroy.ts";
|
|
6
6
|
export * from "./Diff.ts";
|
|
7
7
|
export * from "./Input.ts";
|
|
@@ -20,6 +20,7 @@ export * as Server from "./Server/index.ts";
|
|
|
20
20
|
export * as Serverless from "./Serverless/index.ts";
|
|
21
21
|
export { Stack } from "./Stack.ts";
|
|
22
22
|
export * from "./Stage.ts";
|
|
23
|
+
export { inMemoryState, localState } from "./State/index.ts";
|
|
23
24
|
export * from "./Trait.ts";
|
|
24
25
|
export * as Construct from "./Construct.ts";
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,MAAM,EACN,KAAK,WAAW,IAAI,kBAAkB,EACtC,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,MAAM,EACN,KAAK,WAAW,IAAI,kBAAkB,EACtC,KAAK,YAAY,IAAI,mBAAmB,EACxC,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7D,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * as AdoptPolicy from "./AdoptPolicy.js";
|
|
2
|
+
export * from "./AlchemyContext.js";
|
|
2
3
|
export * from "./Apply.js";
|
|
3
4
|
export { Service as BindingService, Policy, } from "./Binding.js";
|
|
4
|
-
export * from "./Config.js";
|
|
5
5
|
export * from "./Destroy.js";
|
|
6
6
|
export * from "./Diff.js";
|
|
7
7
|
export * from "./Input.js";
|
|
@@ -19,6 +19,7 @@ export * as Server from "./Server/index.js";
|
|
|
19
19
|
export * as Serverless from "./Serverless/index.js";
|
|
20
20
|
export { Stack } from "./Stack.js";
|
|
21
21
|
export * from "./Stage.js";
|
|
22
|
+
export { inMemoryState, localState } from "./State/index.js";
|
|
22
23
|
export * from "./Trait.js";
|
|
23
24
|
export * as Construct from "./Construct.js";
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,MAAM,GAKP,MAAM,cAAc,CAAC;AACtB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,MAAM,GAKP,MAAM,cAAc,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7D,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,cAAc,eAAe,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemy",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.14",
|
|
4
4
|
"homepage": "https://alchemy.run",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Sam Goodwin <sam@alchemy.run>",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"url": "git+https://github.com/alchemy-run/alchemy-effect.git",
|
|
10
10
|
"directory": "package/alchemy"
|
|
11
11
|
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"alchemy": "./bin/cli.js"
|
|
14
|
+
},
|
|
12
15
|
"files": [
|
|
13
16
|
"bin",
|
|
14
17
|
"lib",
|
|
@@ -43,6 +46,12 @@
|
|
|
43
46
|
"worker": "./src/Agent/index.ts",
|
|
44
47
|
"import": "./lib/Agent/index.js"
|
|
45
48
|
},
|
|
49
|
+
"./Auth": {
|
|
50
|
+
"types": "./src/Auth/index.ts",
|
|
51
|
+
"bun": "./src/Auth/index.ts",
|
|
52
|
+
"worker": "./src/Auth/index.ts",
|
|
53
|
+
"import": "./lib/Auth/index.js"
|
|
54
|
+
},
|
|
46
55
|
"./AWS": {
|
|
47
56
|
"types": "./src/AWS/index.ts",
|
|
48
57
|
"bun": "./src/AWS/index.ts",
|
|
@@ -187,6 +196,12 @@
|
|
|
187
196
|
"worker": "./src/State/index.ts",
|
|
188
197
|
"import": "./lib/State/index.js"
|
|
189
198
|
},
|
|
199
|
+
"./State/*": {
|
|
200
|
+
"types": "./src/State/*.ts",
|
|
201
|
+
"bun": "./src/State/*.ts",
|
|
202
|
+
"worker": "./src/State/*.ts",
|
|
203
|
+
"import": "./lib/State/*.js"
|
|
204
|
+
},
|
|
190
205
|
"./Test/Bun": {
|
|
191
206
|
"types": "./src/Test/Bun.ts",
|
|
192
207
|
"bun": "./src/Test/Bun.ts",
|
|
@@ -199,15 +214,17 @@
|
|
|
199
214
|
"worker": "./src/Util/index.ts",
|
|
200
215
|
"import": "./lib/Util/index.js"
|
|
201
216
|
},
|
|
217
|
+
"./Util/Clank": {
|
|
218
|
+
"types": "./src/Util/Clank.ts",
|
|
219
|
+
"bun": "./src/Util/Clank.ts",
|
|
220
|
+
"worker": "./src/Util/Clank.ts",
|
|
221
|
+
"import": "./lib/Util/Clank.js"
|
|
222
|
+
},
|
|
202
223
|
"./bin/alchemy.js": "./bin/alchemy.js"
|
|
203
224
|
},
|
|
204
225
|
"publishConfig": {
|
|
205
226
|
"access": "public"
|
|
206
227
|
},
|
|
207
|
-
"optionalDependencies": {
|
|
208
|
-
"@alchemy.run/cli-posix": "2.0.0-beta.13",
|
|
209
|
-
"@alchemy.run/cli-win32": "2.0.0-beta.13"
|
|
210
|
-
},
|
|
211
228
|
"dependencies": {
|
|
212
229
|
"@ai-sdk/anthropic": "^3.0.31",
|
|
213
230
|
"@ai-sdk/openai": "^3.0.23",
|
|
@@ -233,6 +250,7 @@
|
|
|
233
250
|
"cloudflare": "^5.2.0",
|
|
234
251
|
"fast-glob": "^3.3.2",
|
|
235
252
|
"fast-xml-parser": "^5.3.4",
|
|
253
|
+
"foreground-child": "^4.0.3",
|
|
236
254
|
"ignore": "^7.0.5",
|
|
237
255
|
"jszip": "^3.10.1",
|
|
238
256
|
"libsodium-wrappers": "^0.8.3",
|
|
@@ -265,9 +283,9 @@
|
|
|
265
283
|
"typescript": "^5.9.3"
|
|
266
284
|
},
|
|
267
285
|
"peerDependencies": {
|
|
268
|
-
"@effect/platform-bun": "
|
|
269
|
-
"@effect/platform-node": "
|
|
270
|
-
"effect": "
|
|
286
|
+
"@effect/platform-bun": "4.0.0-beta.48",
|
|
287
|
+
"@effect/platform-node": "4.0.0-beta.48",
|
|
288
|
+
"effect": "4.0.0-beta.48",
|
|
271
289
|
"vite": "^8.0.7"
|
|
272
290
|
},
|
|
273
291
|
"peerDependenciesMeta": {
|
|
@@ -277,9 +295,6 @@
|
|
|
277
295
|
"@effect/platform-bun": {
|
|
278
296
|
"optional": true
|
|
279
297
|
},
|
|
280
|
-
"effect": {
|
|
281
|
-
"optional": true
|
|
282
|
-
},
|
|
283
298
|
"vite": {
|
|
284
299
|
"optional": true
|
|
285
300
|
}
|
package/src/AWS/ECS/Task.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as Context from "effect/Context";
|
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as FileSystem from "effect/FileSystem";
|
|
10
10
|
import type * as rolldown from "rolldown";
|
|
11
|
+
import { AlchemyContext } from "../../AlchemyContext.ts";
|
|
11
12
|
import * as Bundle from "../../Bundle/Bundle.ts";
|
|
12
13
|
import {
|
|
13
14
|
dockerBuild,
|
|
@@ -19,20 +20,19 @@ import {
|
|
|
19
20
|
findCwdForBundle,
|
|
20
21
|
getStableContextDir,
|
|
21
22
|
} from "../../Bundle/TempRoot.ts";
|
|
22
|
-
import { DotAlchemy } from "../../Config.ts";
|
|
23
23
|
import { isResolved } from "../../Diff.ts";
|
|
24
24
|
import * as Output from "../../Output.ts";
|
|
25
25
|
import { createPhysicalName } from "../../PhysicalName.ts";
|
|
26
26
|
import { Platform, type Main, type PlatformProps } from "../../Platform.ts";
|
|
27
27
|
import * as Provider from "../../Provider.ts";
|
|
28
28
|
import { Resource, type ResourceBinding } from "../../Resource.ts";
|
|
29
|
-
import type { Providers } from "../Providers.ts";
|
|
30
29
|
import type { ProcessContext, ServerHost } from "../../Server/Process.ts";
|
|
31
30
|
import { Stack } from "../../Stack.ts";
|
|
32
31
|
import { createInternalTags, createTagsList, hasTags } from "../../Tags.ts";
|
|
33
|
-
import { AWSEnvironment } from "../Environment.ts";
|
|
34
32
|
import type { Credentials } from "../Credentials.ts";
|
|
33
|
+
import { AWSEnvironment } from "../Environment.ts";
|
|
35
34
|
import type { PolicyStatement } from "../IAM/Policy.ts";
|
|
35
|
+
import type { Providers } from "../Providers.ts";
|
|
36
36
|
|
|
37
37
|
export const isTask = (value: any): value is Task => {
|
|
38
38
|
return (
|
|
@@ -225,7 +225,7 @@ export const TaskProvider = () =>
|
|
|
225
225
|
const stack = yield* Stack;
|
|
226
226
|
const { accountId } = yield* AWSEnvironment;
|
|
227
227
|
const region = yield* Region;
|
|
228
|
-
const dotAlchemy = yield*
|
|
228
|
+
const { dotAlchemy } = yield* AlchemyContext;
|
|
229
229
|
const fs = yield* FileSystem.FileSystem;
|
|
230
230
|
const virtualEntryPlugin = yield* Bundle.virtualEntryPlugin;
|
|
231
231
|
|
|
@@ -23,16 +23,16 @@ import { Platform, type Main, type PlatformProps } from "../../Platform.ts";
|
|
|
23
23
|
import type { LogLine, LogsInput } from "../../Provider.ts";
|
|
24
24
|
import * as Provider from "../../Provider.ts";
|
|
25
25
|
import { Resource, type ResourceBinding } from "../../Resource.ts";
|
|
26
|
-
import type { Providers } from "../Providers.ts";
|
|
27
26
|
import * as Serverless from "../../Serverless/index.ts";
|
|
28
27
|
import { Stack } from "../../Stack.ts";
|
|
29
28
|
import { createInternalTags, createTagsList, hasTags } from "../../Tags.ts";
|
|
30
29
|
import { sha256 } from "../../Util/sha256.ts";
|
|
31
30
|
import { zipCode } from "../../Util/zip.ts";
|
|
32
|
-
import { AWSEnvironment } from "../Environment.ts";
|
|
33
31
|
import { Assets } from "../Assets.ts";
|
|
32
|
+
import { AWSEnvironment } from "../Environment.ts";
|
|
34
33
|
import * as IAM from "../IAM/index.ts";
|
|
35
34
|
import type { PolicyStatement } from "../IAM/Policy.ts";
|
|
35
|
+
import type { Providers } from "../Providers.ts";
|
|
36
36
|
import { makeFunctionHttpHandler } from "./HttpServer.ts";
|
|
37
37
|
|
|
38
38
|
export const FunctionTypeId = "AWS.Lambda.Function" as const;
|
|
@@ -403,7 +403,6 @@ export const Function: Platform<
|
|
|
403
403
|
}),
|
|
404
404
|
(handlers) =>
|
|
405
405
|
async (event: any, context: lambda.Context): Promise<any> => {
|
|
406
|
-
console.log({ event, handlers });
|
|
407
406
|
for (const handler of handlers) {
|
|
408
407
|
const eff = handler(event);
|
|
409
408
|
if (Effect.isEffect(eff)) {
|
package/src/AWS/SQS/QueueSink.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Console from "effect/Console";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
3
2
|
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Sink from "effect/Sink";
|
|
@@ -30,7 +29,7 @@ export const QueueSinkLive = Layer.effect(
|
|
|
30
29
|
Id: `${i}`,
|
|
31
30
|
MessageBody: message,
|
|
32
31
|
})),
|
|
33
|
-
}).pipe(Effect.
|
|
32
|
+
}).pipe(Effect.orDie, Effect.asVoid),
|
|
34
33
|
);
|
|
35
34
|
});
|
|
36
35
|
}),
|
package/src/Agent/coding/bash.ts
CHANGED
|
@@ -2,7 +2,6 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import * as Option from "effect/Option";
|
|
3
3
|
import * as S from "effect/Schema";
|
|
4
4
|
import { ChildProcess } from "effect/unstable/process";
|
|
5
|
-
import { cwd } from "../../Config.ts";
|
|
6
5
|
import { AspectConfig } from "../Aspect.ts";
|
|
7
6
|
import { Tool } from "../tool/tool.ts";
|
|
8
7
|
import { CommandValidator } from "../util/command-validator.ts";
|
|
@@ -18,7 +17,7 @@ export class timeout extends Tool.input(
|
|
|
18
17
|
export class workdir extends Tool.input(
|
|
19
18
|
"workdir",
|
|
20
19
|
S.optional(S.String),
|
|
21
|
-
)`The working directory to run the command in. Defaults to
|
|
20
|
+
)`The working directory to run the command in. Defaults to cwd. Use this instead of 'cd' commands.` {}
|
|
22
21
|
|
|
23
22
|
export class description extends Tool.input(
|
|
24
23
|
"description",
|
|
@@ -51,7 +50,7 @@ export class bash extends Tool("bash", {
|
|
|
51
50
|
Returns the ${exitCode} and ${stdout} containing both stdout and stderr.
|
|
52
51
|
If the command is invalid, an error message will be returned as a ${S.String}.
|
|
53
52
|
|
|
54
|
-
All commands run in
|
|
53
|
+
All commands run in cwd by default. Use the ${workdir} parameter if you need to run a command in a different directory. AVOID using \`cd <directory> && <command>\` patterns - use \`workdir\` instead.
|
|
55
54
|
|
|
56
55
|
IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.
|
|
57
56
|
|
package/src/Agent/coding/glob.ts
CHANGED
|
@@ -3,7 +3,6 @@ import * as FileSystem from "effect/FileSystem";
|
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
4
|
import * as Path from "effect/Path";
|
|
5
5
|
import * as S from "effect/Schema";
|
|
6
|
-
import { cwd } from "../../Config.ts";
|
|
7
6
|
import { AspectConfig } from "../Aspect.ts";
|
|
8
7
|
import { Tool } from "../tool/tool.ts";
|
|
9
8
|
import * as Ripgrep from "../util/ripgrep.ts";
|
|
@@ -21,7 +20,7 @@ Examples:
|
|
|
21
20
|
export class path extends Tool.input(
|
|
22
21
|
"path",
|
|
23
22
|
S.optional(S.String),
|
|
24
|
-
)`The directory to search in. Defaults to
|
|
23
|
+
)`The directory to search in. Defaults to cwd if not specified.` {}
|
|
25
24
|
|
|
26
25
|
export class files extends Tool.output(
|
|
27
26
|
"files",
|
package/src/Agent/coding/grep.ts
CHANGED
|
@@ -3,7 +3,6 @@ import * as FileSystem from "effect/FileSystem";
|
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
4
|
import * as S from "effect/Schema";
|
|
5
5
|
import { ChildProcess } from "effect/unstable/process";
|
|
6
|
-
import { cwd } from "../../Config.ts";
|
|
7
6
|
import { AspectConfig } from "../Aspect.ts";
|
|
8
7
|
import { Tool } from "../tool/tool.ts";
|
|
9
8
|
import { exec } from "../util/exec.ts";
|
|
@@ -18,7 +17,7 @@ Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+", etc.)` {}
|
|
|
18
17
|
class path extends Tool.input(
|
|
19
18
|
"path",
|
|
20
19
|
S.optional(S.String),
|
|
21
|
-
)`The directory to search in. Defaults to
|
|
20
|
+
)`The directory to search in. Defaults to cwd if not specified.` {}
|
|
22
21
|
|
|
23
22
|
class include extends Tool.input(
|
|
24
23
|
"include",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as EffectContext from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as FileSystem from "effect/FileSystem";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Path from "effect/Path";
|
|
6
|
+
|
|
7
|
+
export class AlchemyContext extends EffectContext.Service<
|
|
8
|
+
AlchemyContext,
|
|
9
|
+
{
|
|
10
|
+
dotAlchemy: string;
|
|
11
|
+
updateStateStore: boolean;
|
|
12
|
+
}
|
|
13
|
+
>()("alchemy/Context") {}
|
|
14
|
+
|
|
15
|
+
export const AlchemyContextLive = Layer.effect(
|
|
16
|
+
AlchemyContext,
|
|
17
|
+
Effect.gen(function* () {
|
|
18
|
+
const fs = yield* FileSystem.FileSystem;
|
|
19
|
+
const path = yield* Path.Path;
|
|
20
|
+
const dir = path.join(process.cwd(), ".alchemy");
|
|
21
|
+
yield* fs.makeDirectory(dir, { recursive: true });
|
|
22
|
+
return {
|
|
23
|
+
dotAlchemy: dir,
|
|
24
|
+
updateStateStore: false,
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
);
|
package/src/Auth/AuthProvider.ts
CHANGED
|
@@ -206,7 +206,7 @@ export const getAuthProvider = <
|
|
|
206
206
|
registry[name] == null
|
|
207
207
|
? Effect.fail(
|
|
208
208
|
new AuthError({
|
|
209
|
-
message: `AuthProvider '${name}' is not registered. Make sure its layer has been
|
|
209
|
+
message: `AuthProvider '${name}' is not registered. Make sure its layer has been provided.`,
|
|
210
210
|
}),
|
|
211
211
|
)
|
|
212
212
|
: Effect.succeed(registry[name] as AuthProvider<Config, Credentials>),
|
package/src/Auth/index.ts
CHANGED
package/src/Cli/InkCLI.tsx
CHANGED
|
@@ -19,6 +19,16 @@ export const inkCLI = () =>
|
|
|
19
19
|
}),
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
+
export const inkCLIAutoApprove = () =>
|
|
23
|
+
Layer.succeed(
|
|
24
|
+
Cli,
|
|
25
|
+
Cli.of({
|
|
26
|
+
approvePlan: () => Effect.succeed(true),
|
|
27
|
+
displayPlan,
|
|
28
|
+
startApplySession,
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
22
32
|
const approvePlan = Effect.fn(function* <P extends Plan>(plan: P) {
|
|
23
33
|
let approved = false;
|
|
24
34
|
const { waitUntilExit } = render(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import { Cli } from "
|
|
3
|
+
import { Cli } from "./Cli.ts";
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const LoggingCli = Layer.succeed(
|
|
6
6
|
Cli,
|
|
7
7
|
Cli.of({
|
|
8
8
|
approvePlan: () => Effect.succeed(true),
|
|
@@ -5,6 +5,7 @@ import * as Option from "effect/Option";
|
|
|
5
5
|
import * as Schedule from "effect/Schedule";
|
|
6
6
|
import type * as rolldown from "rolldown";
|
|
7
7
|
import { AdoptPolicy } from "../../AdoptPolicy.ts";
|
|
8
|
+
import { AlchemyContext } from "../../AlchemyContext.ts";
|
|
8
9
|
import * as Bundle from "../../Bundle/Bundle.ts";
|
|
9
10
|
import {
|
|
10
11
|
dockerBuild,
|
|
@@ -16,7 +17,6 @@ import {
|
|
|
16
17
|
findCwdForBundle,
|
|
17
18
|
getStableContextDir,
|
|
18
19
|
} from "../../Bundle/TempRoot.ts";
|
|
19
|
-
import { DotAlchemy } from "../../Config.ts";
|
|
20
20
|
import { deepEqual, isResolved } from "../../Diff.ts";
|
|
21
21
|
import { createPhysicalName } from "../../PhysicalName.ts";
|
|
22
22
|
import {
|
|
@@ -359,7 +359,7 @@ export const ContainerProvider = () =>
|
|
|
359
359
|
const adoptPolicy = yield* Effect.serviceOption(AdoptPolicy).pipe(
|
|
360
360
|
Effect.map(Option.getOrElse(() => false)),
|
|
361
361
|
);
|
|
362
|
-
const dotAlchemy = yield*
|
|
362
|
+
const { dotAlchemy } = yield* AlchemyContext;
|
|
363
363
|
const fs = yield* FileSystem.FileSystem;
|
|
364
364
|
const virtualEntryPlugin = yield* Bundle.virtualEntryPlugin;
|
|
365
365
|
const createContainerApplication =
|
|
@@ -498,6 +498,12 @@ export const ContainerProvider = () =>
|
|
|
498
498
|
...external,
|
|
499
499
|
],
|
|
500
500
|
platform: "node",
|
|
501
|
+
resolve: {
|
|
502
|
+
conditionNames:
|
|
503
|
+
runtime === "bun"
|
|
504
|
+
? ["bun", "import", "module", "default"]
|
|
505
|
+
: ["node", "import", "module", "default"],
|
|
506
|
+
},
|
|
501
507
|
plugins,
|
|
502
508
|
treeshake: true,
|
|
503
509
|
},
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Credentials } from "@distilled.cloud/cloudflare/Credentials";
|
|
2
|
+
import * as workers from "@distilled.cloud/cloudflare/workers";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
6
|
+
import { CloudflareEnvironment } from "./CloudflareEnvironment.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A "remote binding" as understood by the Cloudflare Workers
|
|
10
|
+
* edge-preview API. We reuse the distilled request schema so the
|
|
11
|
+
* shape tracks Cloudflare's surface.
|
|
12
|
+
*/
|
|
13
|
+
type EdgeMetadata = NonNullable<
|
|
14
|
+
NonNullable<workers.CreateScriptEdgePreviewRequest["metadata"]>
|
|
15
|
+
>;
|
|
16
|
+
export type EdgeBinding = NonNullable<
|
|
17
|
+
NonNullable<EdgeMetadata["bindings"]>
|
|
18
|
+
>[number];
|
|
19
|
+
|
|
20
|
+
export class EdgeSessionError extends Data.TaggedError("EdgeSessionError")<{
|
|
21
|
+
readonly message: string;
|
|
22
|
+
readonly cause?: unknown;
|
|
23
|
+
}> {}
|
|
24
|
+
|
|
25
|
+
export interface EdgeSessionOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Name used as the preview script identifier on Cloudflare's side.
|
|
28
|
+
* Shows up as the hostname: `{scriptName}.{subdomain}.workers.dev`.
|
|
29
|
+
*/
|
|
30
|
+
readonly scriptName: string;
|
|
31
|
+
/** ES-module worker script(s). The first file is the entrypoint. */
|
|
32
|
+
readonly files: ReadonlyArray<File>;
|
|
33
|
+
/** Remote bindings attached to the preview worker. */
|
|
34
|
+
readonly bindings: ReadonlyArray<EdgeBinding>;
|
|
35
|
+
/** @default "2025-04-28" */
|
|
36
|
+
readonly compatibilityDate?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Information needed to call a running edge-preview worker. Attach
|
|
41
|
+
* `headers` (including the `cf-workers-preview-token`) and fetch
|
|
42
|
+
* `url` or a path under it.
|
|
43
|
+
*/
|
|
44
|
+
export interface EdgeSessionHandle {
|
|
45
|
+
readonly url: string;
|
|
46
|
+
readonly headers: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const DEFAULT_COMPATIBILITY_DATE = "2025-04-28";
|
|
50
|
+
|
|
51
|
+
const wrap = <A, E, R>(effect: Effect.Effect<A, E, R>, message: string) =>
|
|
52
|
+
effect.pipe(
|
|
53
|
+
Effect.mapError((cause) => new EdgeSessionError({ message, cause })),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Ask Cloudflare for a preview upload token. Some accounts return an
|
|
58
|
+
* `exchangeUrl` that must be GET'd to swap the session token for a
|
|
59
|
+
* short-lived upload token; when present we do the swap, falling back
|
|
60
|
+
* to the original if the exchange fails.
|
|
61
|
+
*/
|
|
62
|
+
const createUploadToken = Effect.gen(function* () {
|
|
63
|
+
const env = yield* CloudflareEnvironment;
|
|
64
|
+
const http = yield* HttpClient.HttpClient;
|
|
65
|
+
const createSubdomainEdgePreviewSession =
|
|
66
|
+
yield* workers.createSubdomainEdgePreviewSession;
|
|
67
|
+
const { token, exchangeUrl } = yield* createSubdomainEdgePreviewSession({
|
|
68
|
+
accountId: env.accountId,
|
|
69
|
+
});
|
|
70
|
+
if (!exchangeUrl) return token;
|
|
71
|
+
const json = yield* http.get(exchangeUrl).pipe(
|
|
72
|
+
Effect.flatMap((r) => r.json),
|
|
73
|
+
Effect.timeout(30_000),
|
|
74
|
+
Effect.catch(() => Effect.succeed(null as unknown)),
|
|
75
|
+
);
|
|
76
|
+
if (
|
|
77
|
+
typeof json === "object" &&
|
|
78
|
+
json !== null &&
|
|
79
|
+
"token" in json &&
|
|
80
|
+
typeof (json as Record<string, unknown>).token === "string"
|
|
81
|
+
) {
|
|
82
|
+
return (json as { token: string }).token;
|
|
83
|
+
}
|
|
84
|
+
return token;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const uploadScript = (options: EdgeSessionOptions, uploadToken: string) =>
|
|
88
|
+
Effect.gen(function* () {
|
|
89
|
+
const env = yield* CloudflareEnvironment;
|
|
90
|
+
const createScriptEdgePreview = yield* workers.createScriptEdgePreview;
|
|
91
|
+
return yield* createScriptEdgePreview({
|
|
92
|
+
accountId: env.accountId,
|
|
93
|
+
scriptName: options.scriptName,
|
|
94
|
+
cfPreviewUploadConfigToken: uploadToken,
|
|
95
|
+
wranglerSessionConfig: { workersDev: true, minimalMode: true },
|
|
96
|
+
metadata: {
|
|
97
|
+
compatibilityDate:
|
|
98
|
+
options.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,
|
|
99
|
+
bindings: options.bindings as EdgeMetadata["bindings"],
|
|
100
|
+
mainModule: options.files[0]!.name,
|
|
101
|
+
},
|
|
102
|
+
// Distilled's generated schema expects a mutable array; our
|
|
103
|
+
// public surface keeps `readonly` so callers can pass a frozen
|
|
104
|
+
// tuple without a cast on their side.
|
|
105
|
+
files: options.files.slice(),
|
|
106
|
+
}).pipe(Effect.timeout(30_000));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const workerHost = (scriptName: string) =>
|
|
110
|
+
Effect.gen(function* () {
|
|
111
|
+
const env = yield* CloudflareEnvironment;
|
|
112
|
+
const getSubdomain = yield* workers.getSubdomain;
|
|
113
|
+
const { subdomain } = yield* getSubdomain({ accountId: env.accountId });
|
|
114
|
+
return `${scriptName}.${subdomain}.workers.dev`;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Upload a short-lived preview worker to Cloudflare's edge and
|
|
119
|
+
* return its URL plus the headers needed to reach it.
|
|
120
|
+
*
|
|
121
|
+
* Preview workers are ephemeral: they live only while a client keeps
|
|
122
|
+
* sending requests with the returned preview token and expire soon
|
|
123
|
+
* after. Nothing is deployed or billed.
|
|
124
|
+
*/
|
|
125
|
+
export const createEdgeSession = (
|
|
126
|
+
options: EdgeSessionOptions,
|
|
127
|
+
): Effect.Effect<
|
|
128
|
+
EdgeSessionHandle,
|
|
129
|
+
EdgeSessionError,
|
|
130
|
+
CloudflareEnvironment | HttpClient.HttpClient | Credentials
|
|
131
|
+
> =>
|
|
132
|
+
Effect.gen(function* () {
|
|
133
|
+
const [{ previewToken }, host] = yield* Effect.all(
|
|
134
|
+
[
|
|
135
|
+
createUploadToken.pipe(Effect.flatMap((t) => uploadScript(options, t))),
|
|
136
|
+
workerHost(options.scriptName),
|
|
137
|
+
],
|
|
138
|
+
{ concurrency: "unbounded" },
|
|
139
|
+
);
|
|
140
|
+
return {
|
|
141
|
+
url: `https://${host}`,
|
|
142
|
+
headers: { "cf-workers-preview-token": previewToken },
|
|
143
|
+
} satisfies EdgeSessionHandle;
|
|
144
|
+
}).pipe((e) => wrap(e, "Failed to create edge preview session"));
|