Signature
tsSignature
export async function runBehavior<I, O, E, C extends object>( behavior: Behavior<I, O, E, C>, input: I, context: RuntimeContext<C>,): Promise<Result<O, E | RuntimeError>>;Imports
tsImport
import { runBehavior } from "@/lib/flow/core/runtime";import { runBehavior } from "@/lib/flow";Type Parameters
IInput type.
OOutput type.
EExpected domain error type.
CCustom context type.
Parameters
inputI
Input passed to the behavior.
contextRuntime context containing an `AbortSignal`.
Returns
The behavior result, cancellation result, or thrown runtime result.
Return type
Promise<Result<O, E | RuntimeError>>Details
The runner checks cancellation before and after behavior execution and converts thrown
exceptions into `Thrown` results.
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
RuntimeContext
Execution context passed to every behavior.
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:107-131
export async function runBehavior<I, O, E, C extends object>( behavior: Behavior<I, O, E, C>, input: I, context: RuntimeContext<C>,): Promise<Result<O, E | RuntimeError>> { if (context.signal.aborted) { return resultFromSignal(context.signal); }
try { const result = await behavior(input, context);
if (context.signal.aborted) { return resultFromSignal(context.signal); }
return result; } catch (error) { if (context.signal.aborted) { return resultFromSignal(context.signal); }
return thrown(error); }}