import type { WorkflowExecution } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/enum_pb";
/**
 * A flattened, UI-ready row derived from a {@link WorkflowExecution}.
 *
 * All computed fields (duration, failed task, retry count) are derived
 * from the execution's status data — no additional API calls needed.
 * This type is the contract between the derivation layer and the table
 * component; it intentionally avoids protobuf types so the table can
 * be tested and rendered without proto dependencies.
 */
export interface ExecutionRow {
    readonly id: string;
    readonly name: string;
    readonly phase: ExecutionPhase;
    readonly startedAt: Date | null;
    readonly completedAt: Date | null;
    /** Milliseconds between started_at and completed_at. `null` when not yet completed or timestamps missing. */
    readonly durationMs: number | null;
    readonly costMicros: bigint;
    readonly inputTokens: bigint;
    readonly outputTokens: bigint;
    readonly totalTokens: bigint;
    readonly taskCount: number;
    readonly completedTaskCount: number;
    /** Name of the first task in FAILED status, or `null` if none. */
    readonly failedTaskName: string | null;
    /** Name of the first task in IN_PROGRESS status, or `null` if none. */
    readonly currentTaskName: string | null;
    /** Number of retry attempts across all tasks (derived from task metadata). */
    readonly retryCount: number;
    /** `true` when any task is in WAITING_APPROVAL status. */
    readonly hasHumanWait: boolean;
    readonly error: string | null;
    /** Reference to the original execution for downstream consumers that need the full object. */
    readonly _source: WorkflowExecution;
}
/**
 * Derives a UI-ready {@link ExecutionRow} from a raw {@link WorkflowExecution}.
 *
 * Pure function with zero side effects. Computes duration, identifies
 * the failed/current task, counts retries, and normalizes bigint fields.
 */
export declare function deriveExecutionRow(exec: WorkflowExecution): ExecutionRow;
/**
 * Batch-derives execution rows from a list of raw executions.
 * Preserves input order.
 */
export declare function deriveExecutionRows(executions: readonly WorkflowExecution[]): ExecutionRow[];
export type ExecutionSortField = "name" | "phase" | "startedAt" | "duration" | "cost" | "tokens" | "tasks";
export type SortDirection = "asc" | "desc";
/**
 * Sorts execution rows by a given field and direction.
 * Returns a new array (does not mutate the input).
 */
export declare function sortExecutionRows(rows: readonly ExecutionRow[], field: ExecutionSortField, direction: SortDirection): ExecutionRow[];
export interface ExecutionClientFilters {
    readonly phases?: readonly ExecutionPhase[];
    readonly minDurationMs?: number;
    readonly maxDurationMs?: number;
    readonly minCostMicros?: bigint;
    readonly maxCostMicros?: bigint;
    readonly failedTaskName?: string;
    readonly hasRetries?: boolean;
}
/**
 * Applies client-side filters to execution rows.
 * Returns a new array containing only rows that match all criteria.
 */
export declare function filterExecutionRows(rows: readonly ExecutionRow[], filters: ExecutionClientFilters): ExecutionRow[];
//# sourceMappingURL=derive-execution-row.d.ts.map