import type { DepotApi } from '../depot/api.js'; import { type JobNode, type RunTree } from './ci-tree.js'; import { type WorkflowDetail, type WorkflowExecution } from './ci-write-detail.js'; export declare function isTerminalState(state: string | undefined): boolean; /** A job is done when its status is terminal or Depot has recorded a conclusion for it. */ export declare function isJobTerminal(job: JobNode): boolean; /** Accepts the job key, its display name, or its id, since agents quote whichever they saw last. */ export declare function findJob(tree: RunTree, key: string): JobNode | undefined; export type NodeKind = 'run' | 'workflow' | 'execution' | 'job' | 'attempt'; export interface NodeChange { readonly kind: NodeKind; readonly id: string; readonly name: string | undefined; /** Undefined when the node was not in the first snapshot. */ readonly from: string | undefined; /** Undefined when the node is no longer in the last snapshot. */ readonly to: string | undefined; } /** Every node whose state differs between two snapshots, in tree order of the later one. */ export declare function diffTrees(first: RunTree, last: RunTree): NodeChange[]; export type WaitOutcome = 'run_terminal' | 'workflow_terminal' | 'job_terminal' | 'timed_out'; export interface PollResult { readonly outcome: WaitOutcome; readonly first: TSnapshot; readonly last: TSnapshot; readonly polls: number; readonly elapsedMs: number; readonly changes: NodeChange[]; } interface WaitTiming { readonly sleep: (ms: number) => Promise; readonly now: () => number; readonly timeoutMs: number; readonly pollMs: number; readonly untilJobKey?: string | undefined; } export interface WaitOptions extends WaitTiming { readonly api: Pick; readonly runId: string; } export interface WaitResult extends PollResult { readonly job: JobNode | undefined; } /** Polls `GetRunStatus` until the run (or one named job) reaches a terminal state. */ export declare function waitForRun(options: WaitOptions): Promise; export interface WorkflowSnapshot { readonly workflowId: string | undefined; readonly name: string | undefined; readonly runId: string | undefined; /** The workflow's own status as Depot reports it. */ readonly status: string | undefined; readonly executions: WorkflowExecution[]; /** The execution with the highest number; after a rerun, the one that is actually running. */ readonly latest: WorkflowExecution | undefined; /** The workflow as a one-workflow run tree, so job lookup, counting and diffing are shared. */ readonly tree: RunTree; } export declare function snapshotWorkflow(detail: WorkflowDetail): WorkflowSnapshot; /** * After a rerun the workflow-level status can lag the new execution, so the latest execution * decides when one exists and carries a status; the workflow's own status is the fallback. */ export declare function isWorkflowTerminal(snapshot: WorkflowSnapshot): boolean; export declare function diffWorkflowSnapshots(first: WorkflowSnapshot, last: WorkflowSnapshot): NodeChange[]; export interface WaitForWorkflowOptions extends WaitTiming { readonly api: Pick; readonly workflowId: string; /** When given, the workflow must belong to this run; a mismatch ends the wait on the first poll. */ readonly expectedRunId?: string | undefined; } export interface WorkflowWaitResult extends PollResult { readonly job: JobNode | undefined; } /** * Polls `GetWorkflow` until the latest execution (or one named job) reaches a terminal state. * This is what to watch after `RerunWorkflow` or `RetryFailedJobs`: they create a new execution * of the same workflow, not a new run. */ export declare function waitForWorkflow(options: WaitForWorkflowOptions): Promise; export {}; //# sourceMappingURL=ci-wait.d.ts.map