The best way to control Claude Code, Codex and more from any computer or phone

main
ts 32 lines 1.26 KB
Raw
1 import * as Lambda from "@alchemy.run/aws/Lambda";
2 import * as SQS from "@alchemy.run/aws/SQS";
3 import { ServerHost } from "alchemy/Runtime/Process";
4 // Web Functions only receive HTTP. These declarations must fail to type
5 // check and fail at plan rather than deploy something that never runs.
6 import * as Effect from "effect/Effect";
7
8 export class EventSourceWeb extends Lambda.WebFunction<Lambda.WebFunction>()("EventSourceWeb") {}
9
10 export const EventSourceWebLive = EventSourceWeb.make(
11 { main: import.meta.url, authType: "ApplicationManaged" },
12 // @ts-expect-error — Lambda event sources need an AWS.Lambda.Function host
13 Effect.gen(function* () {
14 const queue = yield* SQS.Queue("WebEventSourceQueue");
15 yield* SQS.consumeQueueMessages(queue, () => Effect.void);
16 return {};
17 }).pipe(Effect.provide(Lambda.QueueEventSource)),
18 );
19
20 export class BackgroundLoopWeb extends Lambda.WebFunction<Lambda.WebFunction>()(
21 "BackgroundLoopWeb",
22 ) {}
23
24 export const BackgroundLoopWebLive = BackgroundLoopWeb.make(
25 { main: import.meta.url, authType: "ApplicationManaged" },
26 // @ts-expect-error — a Web Function provides no ServerHost for background loops
27 Effect.gen(function* () {
28 const host = yield* ServerHost;
29 yield* host.run(Effect.never);
30 return {};
31 }),
32 );