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

main
ts 39 lines 1.29 KB
Raw
1 import * as cloudrun from "@distilled.cloud/gcp/run_v2";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as GCPBindings from "../GCPBindings.ts";
5 import { grantFor } from "../HttpBinding.ts";
6 import { GetWorkerPool, type GetWorkerPoolRequest } from "./GetWorkerPool.ts";
7 import type { WorkerPool } from "./WorkerPool.ts";
8
9 /**
10 * HTTP implementation of {@link GetWorkerPool}.
11 *
12 * @layer
13 * @provides GCP.Run.GetWorkerPool
14 */
15 export const GetWorkerPoolHttp = Layer.effect(
16 GetWorkerPool,
17 Effect.gen(function* () {
18 const bind = yield* GCPBindings.Bind;
19 const getProjectsLocationsWorkerPools = yield* GCPBindings.withCredentials(
20 cloudrun.getProjectsLocationsWorkerPools,
21 );
22 return Effect.fn(function* <T extends WorkerPool>(pool: T) {
23 if (!globalThis.__ALCHEMY_RUNTIME__) {
24 yield* bind`GCP.Run.GetWorkerPool(${pool})`({
25 iam: [grantFor({ role: "roles/run.viewer", on: "run.workerPool" }, pool.name)],
26 });
27 }
28 const name = yield* pool.name;
29 return Effect.fn(`GCP.Run.GetWorkerPool(${pool.LogicalId})`)(function* (
30 request?: GetWorkerPoolRequest,
31 ) {
32 return yield* getProjectsLocationsWorkerPools({
33 ...request,
34 name: yield* name,
35 });
36 });
37 });
38 }),
39 );