@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, 06:00 UTC

main
ts 38 lines 1.29 KB
Raw
1 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
2 import type { GcpOpError } from "@distilled.cloud/gcp/datastream_v1";
3 import { NotFound } from "@distilled.cloud/gcp/datastream_v1";
4 import * as Effect from "effect/Effect";
5 import { MinimumLogLevel } from "effect/References";
6 import * as Schedule from "effect/Schedule";
7
8 export const logLevel = Effect.provideService(
9 MinimumLogLevel,
10 process.env.DEBUG ? "Debug" : "Info",
11 );
12
13 // Connection profiles and streams take 2-5 minutes end to end.
14 export const runLifecycle = !process.env.FAST;
15
16 // Private connections peer a dedicated VPC and take 5-10 minutes to create
17 // and delete.
18 export const runSlowLifecycle = !!process.env.GCP_TEST_SLOW && !process.env.FAST;
19
20 export const currentProject = GcpEnvironment.current.pipe(Effect.map((env) => env.project));
21
22 export const LOCATION = "us-central1";
23
24 export const waitUntilGone = <A, E extends { readonly _tag: string }, R>(
25 get: Effect.Effect<A, E | NotFound | GcpOpError, R>,
26 ) =>
27 get.pipe(
28 Effect.as("found" as const),
29 Effect.catchIf(
30 (error): error is NotFound => error._tag === "NotFound",
31 () => Effect.succeed("gone" as const),
32 ),
33 Effect.repeat({
34 schedule: Schedule.spaced("2 seconds"),
35 until: (status) => status === "gone",
36 times: 10,
37 }),
38 );