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

main
ts 33 lines 1.15 KB
Raw
1 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
2 import * as Effect from "effect/Effect";
3 import { MinimumLogLevel } from "effect/References";
4 import * as Schedule from "effect/Schedule";
5
6 export const logLevel = Effect.provideService(
7 MinimumLogLevel,
8 process.env.DEBUG ? "Debug" : "Info",
9 );
10
11 // Pub/Sub Lite is turned down for new projects (creates answer 403
12 // PubSubLiteTurnedDown); only a project still allow-listed can run lifecycles.
13 export const runLifecycle = !process.env.FAST && process.env.GCP_TEST_PUBSUBLITE === "1";
14
15 export const currentProject = GcpEnvironment.current.pipe(Effect.map((env) => env.project));
16 export const region = "us-central1";
17 export const zone = "us-central1-a";
18
19 export const waitUntilGone = <E extends { readonly _tag: string }, R>(
20 get: Effect.Effect<unknown, E, R>,
21 ) =>
22 get.pipe(
23 Effect.as("found" as const),
24 Effect.catchIf(
25 (error): error is E & { readonly _tag: "NotFound" } => error._tag === "NotFound",
26 () => Effect.succeed("gone" as const),
27 ),
28 Effect.repeat({
29 schedule: Schedule.spaced("1 second"),
30 until: (status) => status === "gone",
31 times: 10,
32 }),
33 );