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

main
ts 55 lines 1.67 KB
Raw
1 import * as Context from "effect/Context";
2 import type * as Effect from "effect/Effect";
3 import type {
4 WorkflowCronSchedule,
5 WorkflowStepContextData,
6 WorkflowStepEvent,
7 WorkflowTaskOptions,
8 WorkflowWaitForEventOptions,
9 } from "./Workflow.ts";
10
11 /**
12 * Service that carries the current workflow event payload.
13 * `yield* WorkflowEvent` inside a workflow body to access it.
14 */
15 export class WorkflowEvent extends Context.Service<
16 WorkflowEvent,
17 {
18 payload: unknown;
19 timestamp: Date;
20 instanceId: string;
21 workflowName: string;
22 /**
23 * Present when Cloudflare created this instance from a native
24 * {@link WorkflowProps.schedules} cron expression. Absent for
25 * instances started with `create` / `createBatch`.
26 */
27 schedule?: WorkflowCronSchedule;
28 }
29 >()("Cloudflare.Workflows.WorkflowEvent") {}
30
31 /**
32 * Runtime information for the current `task` attempt.
33 */
34 export class WorkflowStepContext extends Context.Service<
35 WorkflowStepContext,
36 WorkflowStepContextData
37 >()("Cloudflare.WorkflowStepContext") {}
38
39 /**
40 * Internal service that wraps the Cloudflare `WorkflowStep` object.
41 * Not accessed directly by users -- use `task`, `sleep`, `sleepUntil`, and
42 * `waitForEvent` instead.
43 */
44 export class WorkflowStep extends Context.Service<
45 WorkflowStep,
46 {
47 do<T, E>(options: WorkflowTaskOptions<T, any, any, E>): Effect.Effect<T, E>;
48 sleep(name: string, duration: string | number): Effect.Effect<void>;
49 sleepUntil(name: string, timestamp: Date | number): Effect.Effect<void>;
50 waitForEvent<T>(
51 name: string,
52 options: WorkflowWaitForEventOptions,
53 ): Effect.Effect<WorkflowStepEvent<T>>;
54 }
55 >()("Cloudflare.Workflows.WorkflowStep") {}