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 | /** |
| 2 | * Process bootstrap for `AWS.Batch.JobDefinition` containers. The generated |
| 3 | * entry imports this module and the user's `main`, nothing else — see |
| 4 | * `alchemy/Runtime/Bootstrap` for why. |
| 5 | */ |
| 6 | import * as Credentials from "@distilled.cloud/aws/Credentials"; |
| 7 | import * as Region from "@distilled.cloud/aws/Region"; |
| 8 | import { BunServices } from "@effect/platform-bun"; |
| 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 | * Run the bundled job to completion: no HTTP server, and the process exits 0 |
| 23 | * explicitly once the program finishes (Batch waits on the container). |
| 24 | */ |
| 25 | export const bootstrap = (entrypoint: unknown): Promise<void> => { |
| 26 | const platform = Layer.mergeAll( |
| 27 | BunServices.layer, |
| 28 | FetchHttpClient.layer, |
| 29 | Logger.layer([Logger.consolePretty()]), |
| 30 | ); |
| 31 | |
| 32 | const program = resolveProgram("program").pipe( |
| 33 | Effect.provide( |
| 34 | entrypointLayer(entrypoint).pipe( |
| 35 | Layer.provideMerge(stackFromEnv), |
| 36 | // The role's credentials come from the container credentials endpoint, |
| 37 | // not `AWS_ACCESS_KEY_ID`. |
| 38 | Layer.provideMerge(Credentials.fromContainerMetadata()), |
| 39 | Layer.provideMerge(Region.fromEnv()), |
| 40 | Layer.provideMerge(platform), |
| 41 | Layer.provideMerge(Layer.succeed(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv())), |
| 42 | ), |
| 43 | ), |
| 44 | Effect.scoped, |
| 45 | ); |
| 46 | |
| 47 | return runProcess("Batch job", program, { exitOnComplete: true }); |
| 48 | }; |