Graphorin API reference v0.7.0
Graphorin API reference / @graphorin/workflow / / Workflow
Interface: Workflow<TState, TInput>
Defined in: packages/workflow/src/types.ts:431
Top-level handle returned by createWorkflow.
Stable
Type Parameters
| Type Parameter | Default type |
|---|---|
TState extends object | Record<string, unknown> |
TInput | Partial<TState> |
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
name | readonly | string | packages/workflow/src/types.ts:435 |
nodeNames | readonly | readonly string[] | packages/workflow/src/types.ts:436 |
Methods
approve()
approve(
threadId,
name,
decision,
opts?): AsyncIterable<WorkflowEvent<TState>>;Defined in: packages/workflow/src/types.ts:478
Resolve a named persisted approval (D1) - sugar over resolveAwakeable for requestApproval(name) suspensions.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
name | string |
decision | unknown |
opts? | WorkflowResumeOptions |
Returns
AsyncIterable<WorkflowEvent<TState>>
deleteThread()
deleteThread(threadId): Promise<void>;Defined in: packages/workflow/src/types.ts:493
Delete every checkpoint and pending write of threadId across all namespaces (W-005) - the operator lever for per-thread hygiene and targeted erasure requests. Idempotent: deleting an unknown thread is a no-op. Deleting a merely-suspended thread (pending approval / timer / awakeable) destroys its resume state - the caller decides.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
Promise<void>
execute()
execute(input, opts?): AsyncIterable<WorkflowEvent<TState>>;Defined in: packages/workflow/src/types.ts:437
Parameters
| Parameter | Type |
|---|---|
input | TInput |
opts? | WorkflowExecuteOptions |
Returns
AsyncIterable<WorkflowEvent<TState>>
fork()
fork(threadId, fromCheckpointId): Promise<{
newThreadId: string;
}>;Defined in: packages/workflow/src/types.ts:494
Parameters
| Parameter | Type |
|---|---|
threadId | string |
fromCheckpointId | string |
Returns
Promise<{ newThreadId: string; }>
getState()
getState(threadId): Promise<WorkflowState<TState>>;Defined in: packages/workflow/src/types.ts:484
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
Promise<WorkflowState<TState>>
listCheckpoints()
listCheckpoints(threadId): Promise<readonly Checkpoint[]>;Defined in: packages/workflow/src/types.ts:485
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
Promise<readonly Checkpoint[]>
resolveAwakeable()
resolveAwakeable(
threadId,
name,
value?,
opts?): AsyncIterable<WorkflowEvent<TState>>;Defined in: packages/workflow/src/types.ts:468
Resolve a named awakeable (durable promise, D1): the suspended awaitExternal(name) call returns value and the thread resumes. Fails with pause-not-found when no pending pause carries the name.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
name | string |
value? | unknown |
opts? | WorkflowResumeOptions |
Returns
AsyncIterable<WorkflowEvent<TState>>
resume()
resume(
threadId,
directive?,
opts?): AsyncIterable<WorkflowEvent<TState>>;Defined in: packages/workflow/src/types.ts:438
Parameters
| Parameter | Type |
|---|---|
threadId | string |
directive? | Directive<Record<string, unknown>, unknown> |
opts? | WorkflowResumeOptions |
Returns
AsyncIterable<WorkflowEvent<TState>>
retry()
retry(threadId, opts?): AsyncIterable<WorkflowEvent<TState>>;Defined in: packages/workflow/src/types.ts:448
Restart a 'failed' thread from its last failure checkpoint (WF-3/WF-6): successful sibling tasks of the failed step replay from their persisted pending writes; only the failed work re-runs.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
opts? | WorkflowResumeOptions |
Returns
AsyncIterable<WorkflowEvent<TState>>
tick()
tick(threadId, opts?): Promise<{
fired: boolean;
nextWakeAt: number | null;
}>;Defined in: packages/workflow/src/types.ts:456
Fire due durable timers (D1). Scans the thread's pending pauses for sleepUntil records whose wakeAt has passed; when one is due the thread resumes (draining the resulting events internally). Returns whether a timer fired and the next earliest wake-at (epoch ms) still pending, so schedulers know when to call again.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
opts? | { now?: number; } |
opts.now? | number |
Returns
Promise<{ fired: boolean; nextWakeAt: number | null; }>