/**
 * Run History Store — durable per-workflow run records (闭环 "察" 半场).
 *
 * The checkpoint store (run-checkpoint-store.ts) is an execution cache that is
 * DELETED when a run completes — it cannot answer "what did the last run do?".
 * This store keeps a bounded, append-style history per workflow so the canvas
 * can show past runs and per-node outputs:
 *
 *   `<project>/.qlogicagent/workflows/<workflowId>/runs/history.json`
 *
 * Recording happens in WorkflowController.run() — the single choke point every
 * trigger path goes through (manual RPC, cron scheduler, IM, webhook) — so
 * scheduled runs are captured identically to manual ones.
 *
 * Node outputs are stored as TRUNCATED JSON previews (default-port items'
 * `json`), not full PortMaps: history is for inspection, the checkpoint cache
 * remains the execution-fidelity layer. Bounded to the most recent
 * MAX_RUN_HISTORY entries; corrupt/missing history degrades to empty (history
 * must never block a run).
 */
import type { RunResult } from "./workflow-runtime.js";
import { type WorkflowError } from "./workflow-error.js";
export declare const MAX_RUN_HISTORY = 20;
export type RunHistoryStatus = "running" | "completed" | "failed" | "paused" | "skipped" | "canceled";
export interface RunNodeRecord {
    /** Whether the node's executor actually ran (false = checkpoint cache hit). */
    executed: boolean;
    /** Truncated JSON preview of the node's output items (port → items[].json). */
    preview: string;
    seq?: number;
    startedAt?: string;
    durationMs?: number;
    attempts?: number;
    cacheHit?: boolean;
    /** Per-node disposition; "failed" with a surviving run = onError errorPort/continue (D32). */
    nodeStatus?: "completed" | "failed";
}
export interface RunHistoryEntry {
    runId: string;
    status: RunHistoryStatus;
    triggerType: string;
    startedAt: string;
    finishedAt?: string;
    durationMs?: number;
    error?: string;
    /** AI-5 (D49): classified, human-readable form of `error` (人话 + class + 0-死端 next-step actions). */
    errorInfo?: WorkflowError;
    /** AI-5: node that caused a "failed" run — precise canvas attribution. Hard-stop failures reject
     *  without node records, so the runtime tags the failing node onto the thrown error. */
    failedNodeId?: string;
    /** nodeId → output record. Present once the run settles (not while running). */
    nodes?: Record<string, RunNodeRecord>;
}
/** Summary row for list views — full node outputs stay behind get(). */
export type RunHistorySummary = Omit<RunHistoryEntry, "nodes">;
/** Build per-node output previews (+ D33 trace stats) from a settled RunResult. */
export declare function buildNodeRecords(result: RunResult): Record<string, RunNodeRecord>;
export declare class WorkflowRunHistoryStore {
    private readonly cwd;
    constructor(cwd: string);
    /** Record a run start. Prepends a "running" entry and prunes to the bound. */
    begin(workflowId: string, entry: Pick<RunHistoryEntry, "runId" | "triggerType" | "startedAt">): Promise<void>;
    /** Settle a run entry (status/outputs/error). Unknown runId is a no-op (pruned entry). */
    finish(workflowId: string, runId: string, patch: Partial<Pick<RunHistoryEntry, "status" | "finishedAt" | "durationMs" | "error" | "failedNodeId" | "nodes">>): Promise<void>;
    /** Most-recent-first run summaries (no node outputs — those stay behind get()). */
    list(workflowId: string): Promise<RunHistorySummary[]>;
    /** Full entry incl. per-node output previews. */
    get(workflowId: string, runId: string): Promise<RunHistoryEntry | undefined>;
    private read;
    private write;
}
