@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 37 lines 1.34 KB
Raw
1 import * as workflowexecutions from "@distilled.cloud/gcp/workflowexecutions_v1";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as GCPBindings from "../GCPBindings.ts";
5 import { CreateExecution, type CreateExecutionRequest } from "./CreateExecution.ts";
6 import type { Workflow } from "./Workflow.ts";
7
8 /**
9 * HTTP implementation of {@link CreateExecution}.
10 *
11 * @layer
12 * @provides GCP.Workflows.CreateExecution
13 */
14 export const CreateExecutionHttp = Layer.effect(
15 CreateExecution,
16 Effect.gen(function* () {
17 const bind = yield* GCPBindings.Bind;
18 const createExecution = yield* GCPBindings.withCredentials(
19 workflowexecutions.createProjectsLocationsWorkflowsExecutions,
20 );
21 return Effect.fn(function* (workflow: Workflow) {
22 if (!globalThis.__ALCHEMY_RUNTIME__) {
23 yield* bind`GCP.Workflows.CreateExecution(${workflow})`({
24 // Workflows has no resource-level IAM; invoker is granted on the project.
25 iam: [{ role: "roles/workflows.invoker" }],
26 });
27 }
28 const name = yield* workflow.name;
29 return Effect.fn(`GCP.Workflows.CreateExecution(${workflow.LogicalId})`)(function* (
30 request?: CreateExecutionRequest,
31 ) {
32 const parent = yield* name;
33 return yield* createExecution({ ...request, parent });
34 });
35 });
36 }),
37 );