@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 51 lines 1.65 KB
Raw
1 /**
2 * Process bootstrap for `Docker.Service` (a bun process serving the
3 * bundled program). The generated entry imports this module and the user's
4 * `main`, nothing else — see `alchemy/Runtime/Bootstrap` for why.
5 */
6 import { BunServices } from "@effect/platform-bun";
7 import { BunHttpServer } from "alchemy/Http";
8 import { reifyBoundConfigProvider } from "alchemy/Runtime";
9 import {
10 entrypointLayer,
11 resolveProgram,
12 runProcess,
13 stackFromEnv,
14 } from "alchemy/Runtime/Bootstrap";
15 import * as ConfigProvider from "effect/ConfigProvider";
16 import * as Effect from "effect/Effect";
17 import * as FetchHttpClient from "effect/http/FetchHttpClient";
18 import * as Layer from "effect/Layer";
19 import * as Logger from "effect/Logger";
20
21 /**
22 * Resolve the bundled program (the runners registered via `host.run` /
23 * serve) and run it with a Bun HTTP server bound to `PORT`, so the returned
24 * `{ fetch }` handler is actually served and `host.run` loops stay alive.
25 */
26 export const bootstrap = (entrypoint: unknown): Promise<void> => {
27 const platform = Layer.mergeAll(
28 BunServices.layer,
29 FetchHttpClient.layer,
30 Logger.layer([Logger.consolePretty()]),
31 );
32
33 const program = resolveProgram("program").pipe(
34 Effect.provide(
35 entrypointLayer(entrypoint).pipe(
36 Layer.provideMerge(stackFromEnv),
37 Layer.provideMerge(BunHttpServer()),
38 Layer.provideMerge(platform),
39 Layer.provideMerge(
40 Layer.succeed(
41 ConfigProvider.ConfigProvider,
42 reifyBoundConfigProvider(ConfigProvider.fromEnv(), process.env),
43 ),
44 ),
45 ),
46 ),
47 Effect.scoped,
48 );
49
50 return runProcess("Docker service", program);
51 };