Signature
tsSignature
export async function run<I, O, E, C extends object = {}>( behavior: Behavior<I, O, E, C>, input: I, context: C & { signal?: AbortSignal } = {} as C & { signal?: AbortSignal },): Promise<Result<O, E | RuntimeError>>;Imports
tsImport
import { run } from "@/lib/flow/core/runtime";import { run } from "@/lib/flow";Type Parameters
IInput type.
OOutput type.
EExpected domain error type.
CCustom context type.
Parameters
inputI
Input passed to the behavior.
contextC & { signal?: AbortSignal }
Optional custom context and optional `AbortSignal`.
Returns
A result containing behavior output, domain error, or runtime error.
Return type
Promise<Result<O, E | RuntimeError>>Details
If no signal is provided, Flow creates a fresh non-aborted signal. Expected failures remain in
the returned `Result`; thrown exceptions are converted to `Thrown`.
Examples
tsExample
const result = await run(loadUser, "user_1");Related Symbols
Behavior
Executable Flow workflow unit.
type
input
Creates an identity behavior for starting typed pipelines.
function
Result
Explicit success-or-failure outcome used throughout Flow.
type
RuntimeError
Runtime-level failure union added around every behavior's domain error type.
type
thrown
Re-exports core result helpers used by advanced record internals.
re-export
Source
tsflow/core/runtime.ts:192-203
export async function run<I, O, E, C extends object = {}>( behavior: Behavior<I, O, E, C>, input: I, context: C & { signal?: AbortSignal } = {} as C & { signal?: AbortSignal },): Promise<Result<O, E | RuntimeError>> { const { signal = new AbortController().signal, ...rest } = context;
return runBehavior(behavior, input, { ...(rest as C), signal, });}