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, 04:45 UTC
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 4 | import Agent from "./Agent.ts"; |
| 5 | |
| 6 | // A second Worker that binds the same `Agent` Durable Object as `Api`. Each |
| 7 | // `yield* Agent` runs the DO's outer init, which calls |
| 8 | // `Cloudflare.Container(Sandbox)` and pushes a binding onto the Sandbox |
| 9 | // ContainerApplication carrying the Agent namespace. With two Workers binding |
| 10 | // the same DO, the Sandbox ends up with two bindings that share a single |
| 11 | // `namespaceId` — the regression case for the dedupe fix in this PR. |
| 12 | export class SecondaryApi extends Cloudflare.Worker<SecondaryApi, {}>()("SecondaryApi") {} |
| 13 | |
| 14 | export default SecondaryApi.make( |
| 15 | { |
| 16 | main: import.meta.url, |
| 17 | observability: { enabled: true }, |
| 18 | }, |
| 19 | Effect.gen(function* () { |
| 20 | const agents = yield* Agent; |
| 21 | |
| 22 | return { |
| 23 | fetch: Effect.gen(function* () { |
| 24 | const body = yield* agents.getByName("sandbox-test").hello().pipe(Effect.orDie); |
| 25 | return HttpServerResponse.text(body); |
| 26 | }), |
| 27 | }; |
| 28 | }), |
| 29 | ); |