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

main
ts 39 lines 1.31 KB
Raw
1 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
2 import { none as noGcpRetry } from "@distilled.cloud/gcp/Retry";
3 import * as Effect from "effect/Effect";
4 import { MinimumLogLevel } from "effect/References";
5 import * as Schedule from "effect/Schedule";
6
7 export const logLevel = Effect.provideService(
8 MinimumLogLevel,
9 process.env.DEBUG ? "Debug" : "Info",
10 );
11
12 export const currentProject = GcpEnvironment.current.pipe(Effect.map((env) => env.project));
13
14 /**
15 * Data Labeling is shut down. Live GETs hang ~20s then return HTTP 502
16 * (`BadGateway`). Opt in with `GCP_TEST_DATALABELING=1` if the API
17 * returns.
18 */
19 export const runLifecycle = !process.env.FAST && process.env.GCP_TEST_DATALABELING === "1";
20
21 export const probe = <A, E, R>(effect: Effect.Effect<A, E, R>) => effect.pipe(noGcpRetry);
22
23 export const waitUntilGone = <A, E extends { readonly _tag: string }, R>(
24 get: Effect.Effect<A, E, R>,
25 ) =>
26 get.pipe(
27 noGcpRetry,
28 Effect.as("found" as const),
29 Effect.catchIf(
30 (error): error is E & { readonly _tag: "NotFound" | "BadGateway" } =>
31 error._tag === "NotFound" || error._tag === "BadGateway",
32 () => Effect.succeed("gone" as const),
33 ),
34 Effect.repeat({
35 schedule: Schedule.spaced("1 second"),
36 until: (status) => status === "gone",
37 times: 10,
38 }),
39 );