The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import * as Alchemy from "alchemy"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as pathe from "pathe"; |
| 5 | import ArtifactsEffectWorker from "./effect-worker.ts"; |
| 6 | import ArtifactsReadWorker from "./read-worker.ts"; |
| 7 | import { Repos } from "./shared.ts"; |
| 8 | |
| 9 | /** |
| 10 | * Async-style Worker that declares the shared Artifacts namespace on its `env`. |
| 11 | * `InferEnv` resolves `REPOS` to the native `cf.Artifacts` runtime binding. |
| 12 | */ |
| 13 | export const AsyncWorker = Cloudflare.Worker("ArtifactsAsyncWorker", { |
| 14 | main: pathe.resolve(import.meta.dirname, "async-worker.ts"), |
| 15 | env: { |
| 16 | REPOS: Repos, |
| 17 | }, |
| 18 | }); |
| 19 | |
| 20 | export type AsyncWorkerEnv = Cloudflare.InferEnv<typeof AsyncWorker>; |
| 21 | |
| 22 | /** |
| 23 | * Deploys both invocation styles — the Effect-native worker |
| 24 | * (`Cloudflare.Artifacts.ReadWriteNamespace(Repos)` + `ReadWriteNamespaceBinding`) and the async |
| 25 | * worker (`env: { REPOS }`) — plus a read-only worker |
| 26 | * (`Cloudflare.Artifacts.ReadNamespace(Repos)`) against one shared Artifacts |
| 27 | * namespace, so the driver test can exercise the namespace surface over both |
| 28 | * styles and the repo read surface through the read-only binding. |
| 29 | */ |
| 30 | export default Alchemy.Stack( |
| 31 | "ArtifactsBindingStack", |
| 32 | { providers: Cloudflare.providers(), state: Cloudflare.state() }, |
| 33 | Effect.gen(function* () { |
| 34 | const asyncWorker = yield* AsyncWorker; |
| 35 | const effectWorker = yield* ArtifactsEffectWorker; |
| 36 | const readWorker = yield* ArtifactsReadWorker; |
| 37 | return { |
| 38 | readWorkerUrl: readWorker.url.as<string>(), |
| 39 | asyncWorkerUrl: asyncWorker.url.as<string>(), |
| 40 | effectWorkerUrl: effectWorker.url.as<string>(), |
| 41 | }; |
| 42 | }), |
| 43 | ); |