The best way to control Claude Code, Codex and more from any computer or phone

main
ts 31 lines 1.06 KB
Raw
1 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
2 import type { GcpOpError } from "@distilled.cloud/gcp/datamigration_v1";
3 import { NotFound } from "@distilled.cloud/gcp/datamigration_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 export const runSlowLifecycle = !!process.env.GCP_TEST_SLOW && !process.env.FAST;
14
15 export const currentProject = GcpEnvironment.current.pipe(Effect.map((env) => env.project));
16
17 export const waitUntilGone = <A, E extends { readonly _tag: string }, R>(
18 get: Effect.Effect<A, E | NotFound | GcpOpError, R>,
19 ) =>
20 get.pipe(
21 Effect.as("found" as const),
22 Effect.catchIf(
23 (error): error is NotFound => error._tag === "NotFound",
24 () => Effect.succeed("gone" as const),
25 ),
26 Effect.repeat({
27 schedule: Schedule.spaced("2 seconds"),
28 until: (status) => status === "gone",
29 times: 10,
30 }),
31 );