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

main
ts 41 lines 1.64 KB
Raw
1 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
2 import type { GcpOpError } from "@distilled.cloud/gcp/vmmigration_v1";
3 import { Forbidden, NotFound } from "@distilled.cloud/gcp/vmmigration_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 // An AWS source only finishes creating once Migrate to VMs can reach AWS with
14 // the credentials: with placeholder keys the create operation never completes
15 // (the source stays in state PENDING). Set GCP_TEST_VMMIGRATION_AWS_ACCESS_KEY_ID
16 // and GCP_TEST_VMMIGRATION_AWS_SECRET_ACCESS_KEY to run the source lifecycles.
17 const awsAccessKeyId = process.env.GCP_TEST_VMMIGRATION_AWS_ACCESS_KEY_ID;
18 const awsSecretAccessKey = process.env.GCP_TEST_VMMIGRATION_AWS_SECRET_ACCESS_KEY;
19
20 export const runSourceLifecycle = !!awsAccessKeyId && !!awsSecretAccessKey;
21
22 export const currentProject = GcpEnvironment.current.pipe(Effect.map((env) => env.project));
23
24 export const dummyAws = {
25 awsRegion: "us-east-1",
26 accessKeyCreds: {
27 accessKeyId: awsAccessKeyId ?? "AKIATESTALCHEMY0000",
28 secretAccessKey: awsSecretAccessKey ?? "alchemy-test-secret",
29 },
30 } as const;
31
32 export const waitUntilGone = <A, R>(get: Effect.Effect<A, NotFound | Forbidden | GcpOpError, R>) =>
33 get.pipe(
34 Effect.as("found" as const),
35 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
36 Effect.repeat({
37 schedule: Schedule.spaced("2 seconds"),
38 until: (status) => status === "gone",
39 times: 10,
40 }),
41 );