/** * Workflow routing for a Task: which task runs first, and which runs next. * * Port of `praisonaiagents/process/process.py::workflow()`. The precedence it * applies, in order: * * 1. A `decision`/`loop` task consults its `condition` (alias `routing`) table * with the decision the model returned; an empty target, or the literal * `"exit"`, ends the workflow. * 2. Otherwise the unified `when` / `thenTask` / `elseTask` routing wins over * `nextTasks` when configured (`_resolve_when_routing`). * 3. Otherwise `nextTasks[0]`. * * `isStart` picks the entry point and `nextTasks` defines the edges that * become each task's `previousTasks`. */ import type { Task } from '../types'; /** Sentinel returned when routing says the workflow is finished. */ export declare const EXIT: "exit"; /** Where a task sends control next. */ export type RouteDecision = { kind: 'task'; name: string; } | { kind: 'exit'; } | { kind: 'none'; }; /** Variables a `when` expression and a decision table are evaluated against. */ export interface RoutingContext extends Record { /** Raw text the task produced. */ previous_output?: string; /** Structured `decision` field, for `decision`/`loop` task types. */ decision?: string; } /** True when the task uses the unified when/then/else routing (`_has_when_routing`). */ export declare function hasWhenRouting(task: Task): boolean; /** Evaluate the task's `when` expression; a task without one always passes. */ export declare function evaluateTaskWhen(task: Task, context?: RoutingContext): boolean; /** * Look a decision up in the task's `condition`/`routing` table. * Returns `exit` for a missing, empty or literally-"exit" target. */ export declare function decisionRoute(task: Task, decision: string): RouteDecision; /** * The task control moves to after this one finished with `context`. * * `context.decision` (or, failing that, the raw output) drives the decision * table for `decision`/`loop` tasks; `when`/`thenTask`/`elseTask` and finally * `nextTasks[0]` are consulted after it. */ export declare function resolveNextTask(task: Task, context?: RoutingContext): RouteDecision; /** * The task a workflow starts at: the one flagged `isStart`, else the first * task with no incoming `nextTasks` edge, else the first task * (Python `process.workflow()`'s start-task selection). */ export declare function startTaskOf(tasks: readonly Task[]): Task | undefined; /** * Fill each task's `previousTasks` from the `nextTasks` edges of the others * (Python does this at the top of `process.workflow()`). Returns the map it * wrote, keyed by task name. */ export declare function linkPreviousTasks(tasks: readonly Task[]): Map;