import type { WorkflowActivityObserver, WorkflowActivitySubscription, WorkflowRunStatus, WorkflowStageStatus } from "./workflow-events.js"; export type WorkflowRunJsonValue = string | number | boolean | null | readonly WorkflowRunJsonValue[] | WorkflowRunJsonObject; export interface WorkflowRunJsonObject { readonly [key: string]: WorkflowRunJsonValue | undefined; } export type WorkflowRunFilterStatus = WorkflowRunStatus | WorkflowStageStatus | "awaiting_input"; export interface WorkflowRunListFilter { /** Run statuses match directly; `awaiting_input` selects runs with an unanswered prompt. */ readonly status?: WorkflowRunFilterStatus; /** Include project durable/completed history in addition to this session's runs. */ readonly includeDurable?: boolean; } export interface WorkflowStageListFilter { readonly status?: WorkflowStageStatus; } export interface WorkflowRunActiveStage { readonly stageId: string; readonly name: string; readonly status: WorkflowStageStatus; } export interface WorkflowRunAwaitingInput { readonly stageId?: string; readonly stageName?: string; readonly promptId?: string; readonly promptKind?: string; readonly message?: string; } /** Stored generated description and the run identity used by resume clients. */ export interface WorkflowRunSummaryMetadata { readonly label?: string; readonly identity?: string; readonly summary?: string; /** Unix milliseconds through which the summary describes the run. */ readonly summarizedThrough?: number; } /** The concise per-run data that the `workflow` tool's `status` action lists. */ export interface WorkflowRunSummary extends WorkflowRunSummaryMetadata { readonly runId: string; readonly name: string; readonly status: WorkflowRunStatus; readonly startedAt: number; readonly endedAt?: number; readonly elapsedMs: number; readonly activeStages: readonly WorkflowRunActiveStage[]; readonly awaitingInputCount: number; readonly awaitingInput: readonly WorkflowRunAwaitingInput[]; readonly exitReason?: string; readonly error?: string; } export interface WorkflowRunStageSummary { readonly id: string; readonly name: string; readonly status: WorkflowStageStatus; readonly sessionId?: string; readonly error?: string; readonly skippedReason?: string; readonly awaitingInputSince?: number; } /** The per-run detail that the `workflow` tool's `status` action returns for one run id. */ export interface WorkflowRunDetail extends WorkflowRunSummaryMetadata { readonly runId: string; readonly rootRunId?: string; readonly name: string; readonly status: WorkflowRunStatus | "crashed"; readonly startedAt: number; readonly endedAt?: number; readonly durationMs?: number; readonly inputs: WorkflowRunJsonObject; readonly stages: readonly WorkflowRunStageSummary[]; readonly result?: WorkflowRunJsonObject; readonly error?: string; readonly exitReason?: string; readonly resumable?: boolean; readonly resumeGuidance?: string; readonly ownerActiveElsewhere?: boolean; } export interface WorkflowRunAllTarget { readonly all: true; } export interface WorkflowRunPauseOptions { /** Pause one stage instead of the whole run. */ readonly stageId?: string; } export interface WorkflowRunResumeOptions { /** Resume one paused stage instead of the whole run. */ readonly stageId?: string; /** Message delivered to each resumed stage. */ readonly message?: string; readonly legacyRecovery?: { readonly olderWorkersStopped: true; }; } export type WorkflowRunControlStatus = "ok" | "running" | "paused" | "partial" | "noop" | "cancelled"; /** A run that a batch pause or quit could not stop; it may still be active. */ export interface WorkflowRunControlFailedRun { readonly runId: string; /** Machine-readable refusal, such as `not_found`, `no_active_stages` or `pause_failed`. */ readonly reason: string; readonly message?: string; } /** * The acknowledged result of a pause, quit or resume request, as the `workflow` * tool reports it. `runId` is `--all` for a batch request. `noop` means the request was * understood and found nothing to change; `partial` means only part of the * request took effect. For a batch pause or quit, `failedRuns` names every run that * could not be stopped, so a `partial` outcome is never a complete stop. */ export interface WorkflowRunControlOutcome { readonly action: "pause" | "quit" | "resume"; readonly runId: string; readonly status: WorkflowRunControlStatus; readonly message: string; readonly stageId?: string; readonly workflowStatus?: WorkflowRunStatus; readonly abandoned?: boolean; readonly failedRuns?: readonly WorkflowRunControlFailedRun[]; } /** Typed run management for the workflow runs owned by one session, as registered by the workflows extension. */ export interface WorkflowRunControl { listRuns(filter?: WorkflowRunListFilter): Promise; getRun(runId: string): Promise; getStages(runId: string, filter?: WorkflowStageListFilter): Promise; pause(runId: string, options?: WorkflowRunPauseOptions): Promise; pause(target: WorkflowRunAllTarget): Promise; quit(target: string | WorkflowRunAllTarget): Promise; resume(runId: string, options?: WorkflowRunResumeOptions): Promise; /** * Resolves once this session has finished executing the run, which includes recording its ending in the * workflow journal and releasing its lease. A run reports `completed`, `failed` or `killed` before this * point, so wait here before treating the journal as final. Resolves at once when this session is not * executing the run. Rejects with `WorkflowRunStorageError` when the journal could not record the ending. * It never times out; race it against your own deadline. */ waitForSettled(runId: string): Promise; } /** `session.workflows`: run management plus observation of the workflow runs owned by one session. */ export interface SessionWorkflows extends WorkflowRunControl { /** * Follow root activity and graph changes. Delivers a snapshot frame first, then FIFO * `changed` and `removed` frames; the subscription follows extension reloads. */ observe(observer: WorkflowActivityObserver): WorkflowActivitySubscription; } export interface WorkflowRunControlRegistration { dispose(): void; } export type WorkflowRunControlErrorCode = "WORKFLOW_RUN_NOT_FOUND" | "WORKFLOW_RUN_OWNED_ELSEWHERE" | "WORKFLOW_RUN_NOT_RESUMABLE" | "WORKFLOW_STAGE_NOT_FOUND" | "WORKFLOW_STAGE_AMBIGUOUS" | "WORKFLOW_STAGE_RESUME_UNSUPPORTED" | "WORKFLOW_RUN_STORAGE" | "WORKFLOW_RUN_CONTROL_FAILED" | "WORKFLOW_RUN_CONTROL_UNAVAILABLE"; export interface WorkflowRunControlErrorOptions extends ErrorOptions { readonly runId?: string; readonly failedRuns?: readonly WorkflowRunControlFailedRun[]; } /** Base class for every failure reported by {@link SessionWorkflows}; branch on `code`. */ export declare class WorkflowRunControlError extends Error { readonly code: WorkflowRunControlErrorCode; readonly runId?: string; /** Runs a batch pause or quit could not stop, when the whole batch was refused. */ readonly failedRuns?: readonly WorkflowRunControlFailedRun[]; constructor(code: WorkflowRunControlErrorCode, message: string, options?: WorkflowRunControlErrorOptions); } /** The run id is unknown, malformed, or an ambiguous prefix. */ export declare class WorkflowRunNotFoundError extends WorkflowRunControlError { constructor(message: string, options?: WorkflowRunControlErrorOptions); } /** The run belongs to another session or is executing in another live Atomic process. */ export declare class WorkflowRunOwnershipError extends WorkflowRunControlError { constructor(message: string, options?: WorkflowRunControlErrorOptions); } /** The run has no continuation to resume: it completed, was killed, or has no durable progress. */ export declare class WorkflowRunNotResumableError extends WorkflowRunControlError { constructor(message: string, options?: WorkflowRunControlErrorOptions); } /** The stage identifier matches no stage or tool node of the run. */ export declare class WorkflowStageNotFoundError extends WorkflowRunControlError { constructor(message: string, options?: WorkflowRunControlErrorOptions); } /** The stage identifier matches more than one stage or tool node; pass a more specific identifier. */ export declare class WorkflowStageAmbiguousError extends WorkflowRunControlError { constructor(message: string, options?: WorkflowRunControlErrorOptions); } /** A durable run can only be resumed whole; resume it without a stage identifier. */ export declare class WorkflowStageResumeUnsupportedError extends WorkflowRunControlError { constructor(message: string, options?: WorkflowRunControlErrorOptions); } /** Workflow storage is unavailable, closed, or failed. */ export declare class WorkflowRunStorageError extends WorkflowRunControlError { constructor(message: string, options?: WorkflowRunControlErrorOptions); } /** The workflows extension is not loaded for this session, or the session was disposed. */ export declare class WorkflowRunControlUnavailableError extends WorkflowRunControlError { constructor(message?: string, options?: WorkflowRunControlErrorOptions); } //# sourceMappingURL=workflow-run-control.d.ts.map