Skip to content
Français

WorkflowEvent

import type { WorkflowEvent } from "@elie-laloum/outpost/workflows";
  • tasksOptional
    readonly Readonly<TaskRecord>[] | undefined
    Declared task record snapshot on start and finish, including waiting and restored checkpoint tasks.
  • accountingOptional
    WorkflowUsage | undefined
    Authoritative cumulative budget snapshot at this event, including restored tokens, attempts and optional cost.
  • terminationCodeOptional
    TerminationCode | undefined
    Termination reason on a workflow finish event, matching WorkflowResult.terminationCode when a result is returned. Also classifies errors thrown during scheduling or checkpoint persistence; absent on successful or suspended finishes and other event types.
  • executionIdRequired
    string
    Identity of the workflow execution, preserved across checkpoint resumption.
  • workflowRequired
    string
    Name of the workflow that emitted this event.
  • timestampRequired
    string
    ISO timestamp when the workflow event was emitted.
  • typeRequired
    "start" | "resume" | "decision" | "usage" | "quota" | "cache" | "input-request" | "input-answer" | "loop" | "task" | "attempt" | "retry" | "finish" | "gate" | "checkpoint" | "budget-exceeded"
    Event kind: start, resume, task, attempt, retry, usage, checkpoint, finish, budget-exceeded, gate, decision, loop, input-request, input-answer, quota or cache.
  • cacheOptional
    TaskCacheOutcome | undefined
    Task cache outcome on cache events: hit, miss (absent, expired or refresh mode), stored, or failed when the store or an entry was unusable.
  • errorOptional
    string | undefined
    Observed task failure, workflow termination details, quota message or cache-store error according to the event type. Cache failures continue without the cache.
  • resetAtOptional
    string | undefined
    Reported quota reset time on quota events, when the provider supplied one.
  • roundOptional
    number | undefined
    Logical round number on loop phase events.
  • phaseOptional
    "complete" | "attempt" | "check" | undefined
    Saved phase on loop events: attempt, check or complete.
  • feedbackOptional
    string | undefined
    Feedback of a rejected round on its complete loop event, masked by the workflow redact patterns, then limited to its first and last 1,000 characters.
  • keyOptional
    string | undefined
    Stable task key identifying the node within its workflow graph.
  • statusOptional
    TaskStatus | undefined
    Task status on task, quota and input events, or the run status on finish. On quota events, waiting means the task runs again in this start() call and paused means it stays paused.
  • attemptOptional
    number | undefined
    One-based task attempt number.
  • usageOptional
    Usage | undefined
    Reported usage counters; not a currency estimate.
  • durationMsOptional
    number | undefined
    Elapsed execution time in milliseconds.
  • delayMsOptional
    number | undefined
    Selected wait before the next task attempt, present on retry events and on quota events that wait for a reset in process; includes backoff, jitter and any valid server minimum for retries.
export interface WorkflowEvent {
  readonly tasks?: readonly Readonly<TaskRecord>[];
  readonly accounting?: WorkflowUsage;
  readonly terminationCode?: WorkflowTerminationCode;
  readonly executionId: string;
  readonly workflow: string;
  readonly timestamp: string;
  readonly type:
    | "cache"
    | "quota"
    | "input-request"
    | "input-answer"
    | "loop"
    | "start"
    | "task"
    | "attempt"
    | "retry"
    | "usage"
    | "finish"
    | "gate"
    | "decision"
    | "checkpoint"
    | "resume"
    | "budget-exceeded";
  readonly cache?: TaskCacheOutcome;
  readonly error?: string;
  readonly resetAt?: string;
  readonly round?: number;
  readonly phase?: "attempt" | "check" | "complete";
  /** Bounded feedback of a rejected loop round, on its `complete` event. */
  readonly feedback?: string;
  readonly key?: string;
  readonly status?: TaskStatus;
  readonly attempt?: number;
  readonly usage?: Usage;
  readonly durationMs?: number;
  readonly delayMs?: number;
}