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 type { SecurityGroupId } from "@alchemy.run/aws/EC2/SecurityGroup"; |
| 2 | import type { SubnetId } from "@alchemy.run/aws/EC2/Subnet"; |
| 3 | import type { VpcId } from "@alchemy.run/aws/EC2/Vpc"; |
| 4 | import * as Deferred from "effect/Deferred"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | |
| 7 | // Lightweight half of ProvisionedFixture.ts: the shared-network handle that |
| 8 | // Lambda fixtures read from their init effect. It must NOT import the test |
| 9 | // harness (`@alchemy.run/test/Core`) — anything imported here is bundled into the |
| 10 | // fixture Lambda, and the harness drags in the bundler and engine (a ~19 MB |
| 11 | // bundle that OOMs a 256 MB Lambda at cold start, surfacing as a 502). |
| 12 | |
| 13 | export interface ProvisionedNetwork { |
| 14 | vpcId: VpcId; |
| 15 | subnetIds: SubnetId[]; |
| 16 | securityGroupId: SecurityGroupId; |
| 17 | subnetGroupName: string; |
| 18 | } |
| 19 | |
| 20 | /** Process-wide state, mutated by ProvisionedFixture.ts in the test process. */ |
| 21 | export const networkState = { |
| 22 | ready: Deferred.makeUnsafe<ProvisionedNetwork, unknown>(), |
| 23 | started: false, |
| 24 | }; |
| 25 | |
| 26 | /** |
| 27 | * Resolved IDs of the process-wide provisioned-cache VPC. |
| 28 | * |
| 29 | * Inside a deployed Lambda fixture the init effect re-runs, but the shared |
| 30 | * network is test-process state that never exists there — and resource |
| 31 | * declarations ignore their props at runtime anyway. Hand back inert |
| 32 | * placeholders so the fixture's cold start does not die. |
| 33 | */ |
| 34 | export const getProvisionedNetwork = Effect.suspend(() => |
| 35 | globalThis.__ALCHEMY_RUNTIME__ |
| 36 | ? Effect.succeed({ |
| 37 | vpcId: "", |
| 38 | subnetIds: [], |
| 39 | securityGroupId: "", |
| 40 | subnetGroupName: "", |
| 41 | } as unknown as ProvisionedNetwork) |
| 42 | : networkState.started |
| 43 | ? Deferred.await(networkState.ready).pipe(Effect.orDie) |
| 44 | : Effect.die( |
| 45 | "provisioned network was not acquired; call shareProvisionedNetwork in the test file", |
| 46 | ), |
| 47 | ); |