Skip to main content

createFlowRunner

@retinue/monorepo


@retinue/monorepo / backend/src / createFlowRunner

Function: createFlowRunner()

createFlowRunner(deps): object

Defined in: backend/src/flows/runner.ts:127

Parameters​

deps​

FlowRunnerDeps

Returns​

deliverSignal()​

deliverSignal(context, signal, value?): Promise<readonly RunResult[]>

Everything parked on a signal, so delivering one can wake what was waiting.

Parameters​

context​

ExecutionContext

signal​

string

value?​

unknown

Returns​

Promise<readonly RunResult[]>

notifyRunFinished()​

notifyRunFinished(context, runId): Promise<RunResult | null>

A child run settled — #202.

The fast path. Correctness does not depend on it: drive polls the child's state on every resume, so a lost notification costs latency rather than a stuck flow. Returns null when no execution was waiting for this run, which is the common case in a deployment where most runs are chat turns.

Parameters​

context​

ExecutionContext

runId​

RunId

Returns​

Promise<RunResult | null>

resume()​

resume(context, executionId): Promise<RunResult>

Continue a stored execution — after a restart, or after a slice ran out.

Parameters​

context​

ExecutionContext

executionId​

string

Returns​

Promise<RunResult>

resumeWith()​

resumeWith(context, executionId, value): Promise<RunResult>

Deliver an answer or a signal to a parked execution.

The value goes through the interpreter as a resumed outcome, so the parked step's assignTo receives it exactly as any other step's result would. A separate "apply an answer" path would be a second way to write state, and the two would eventually disagree about where an answer lands.

Parameters​

context​

ExecutionContext

executionId​

string

value​

unknown

Returns​

Promise<RunResult>

start()​

start(context, input): Promise<RunResult>

Start a flow at its latest version, pinning that version for this execution's whole life.

Parameters​

context​

ExecutionContext

input​
depth?​

number

flowId​

string

runId​

RunId

state?​

Readonly<Record<string, unknown>>

Returns​

Promise<RunResult>