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, 06:00 UTC
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { HttpServerRequest } from "effect/http/HttpServerRequest"; |
| 4 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 5 | |
| 6 | /** A Node MicroVM program that reaches the AWS package through `import * as AWS`. */ |
| 7 | export class CanaryMicrovm extends AWS.Lambda.MicrovmImage<CanaryMicrovm>()("CanaryMicrovm") {} |
| 8 | |
| 9 | /** Throws so `/trace` can show how a stack trace reads from the minified bundle. */ |
| 10 | function canaryThrows(): never { |
| 11 | throw new Error("canary"); |
| 12 | } |
| 13 | |
| 14 | export default CanaryMicrovm.make( |
| 15 | { |
| 16 | main: import.meta.filename, |
| 17 | resources: [{ minimumMemoryInMiB: 512 }], |
| 18 | cpuConfigurations: [{ architecture: "ARM_64" }], |
| 19 | }, |
| 20 | Effect.gen(function* () { |
| 21 | return { |
| 22 | fetch: Effect.gen(function* () { |
| 23 | const request = yield* HttpServerRequest; |
| 24 | const url = new URL(request.url, "http://microvm"); |
| 25 | if (url.pathname === "/trace") { |
| 26 | const stack = yield* Effect.try({ |
| 27 | try: canaryThrows, |
| 28 | catch: (error) => String((error as { stack?: unknown }).stack), |
| 29 | }).pipe(Effect.flip); |
| 30 | return yield* HttpServerResponse.json({ stack }); |
| 31 | } |
| 32 | return yield* HttpServerResponse.json({ path: url.pathname }); |
| 33 | }), |
| 34 | }; |
| 35 | }), |
| 36 | ); |