Skip to content
Français

WorkflowResult

import type { WorkflowResult } from "@elie-laloum/outpost/workflows";
  • observationIdOptional
    string | undefined
    Tracking ID when started with createObservation(); equal to the retained result.runId. Selected by options.runId, otherwise checkpoint.runId or a generated ID. Independent of executionId and checkpoint ownership. Available without persistence, but reading requires a transport. Absent without an automatic tracking session.
  • runIdOptional
    string | undefined
    Observation ID of this workflow when started with createObservation(). Independent of executionId and available without persistence; reading requires a configured transport. Retained for compatibility; prefer observationId when reading or watching tracking state.
  • terminationCodeOptional
    TerminationCode | undefined
    Reason for an unsuccessful terminal outcome: rejected for a gate refusal, aborted for external cancellation, timeout for a task or workflow deadline, limit for an exhausted workflow budget, usage-unavailable for incomplete budget accounting, the first technical failure’s OutpostError code (including wrapped causes), or failed for an unclassified error. Absent for done, paused and waiting-input; recomputed from restored gate records on resume.
  • inputRequestsRequired
    readonly WorkflowInputRequest[]
    Immutable pending questions from tasks in waiting-input; empty when no human input is pending.
  • executionIdRequired
    string
    Identity of the workflow execution, preserved across checkpoint resumption.
  • nameRequired
    string
    Name of the workflow definition, included in its execution reports.
  • statusRequired
    "failed" | "done" | "cancelled" | "rejected" | "waiting-input" | "paused"
    Run outcome: done, failed, cancelled, rejected, paused (gate or quota), or waiting-input. External cancellation or the workflow deadline takes precedence, then technical failure, rejection, waiting-input and pause. A workflow deadline gives failed with terminationCode timeout.
  • tasksRequired
    readonly Readonly<TaskRecord>[]
    One frozen record per task, in list order, with status, attempts, timestamps and error.
  • errorsRequired
    readonly unknown[]
    Task failures, gate rejections, budget errors and the external abort or timeout reason. Gate rejection uses OutpostError code rejected and retains the task key, actor and reason in details; rejected runs keep this audit trail after checkpoint resumption.
  • observerErrorsRequired
    readonly unknown[]
    Exceptions thrown by telemetry and observe callbacks, collected independently without changing workflow status or task errors.
  • usageRequired
    WorkflowUsage
    Cumulative admitted attempts and observed token usage, including restored accounting.
  • valueRequired
    <T>(task: Task<T>) => T
    Return a task’s output from this run or its restored checkpoint; throws when the task has no done value.
  • unwrapRequired
    () => void
    Return when status is done; otherwise throw WorkflowFailure.
export interface WorkflowResult {
  readonly observationId?: string;
  readonly runId?: string;
  readonly terminationCode?: WorkflowTerminationCode;
  readonly inputRequests: readonly WorkflowInputRequest[];
  readonly executionId: string;
  readonly name: string;
  readonly status:
    "done" | "failed" | "cancelled" | "paused" | "waiting-input" | "rejected";
  readonly tasks: readonly Readonly<TaskRecord>[];
  readonly errors: readonly unknown[];
  readonly observerErrors: readonly unknown[];
  readonly usage: WorkflowUsage;
  value<T>(task: Task<T>): T;
  unwrap(): void;
}