export type RunStateStatus = 'pending' | 'running' | 'waiting_user_input' | 'completed' | 'failed' | 'cancelled';
export type NodeStatus = 'idle' | 'active' | 'completed' | 'failed' | 'skipped' | 'waiting_user_input';
export interface NodeRunState {
    label?: string;
    type: 'user_input' | 'llm' | 'if';
    status: NodeStatus;
    iter: number;
    lastActiveAt?: number;
    lastCompletedAt?: number;
    done?: boolean;
    failed?: boolean;
    reason?: string | null;
}
export interface RunStateFile {
    version: 1;
    runId: string;
    basename: string;
    startedAt: number;
    finishedAt?: number | null;
    status: RunStateStatus;
    currentNodeId: string | null;
    nodes: Record<string, NodeRunState>;
    error?: {
        nodeId?: string;
        message: string;
    } | null;
}
export declare function writeRunState(projectFolder: string, basename: string, state: RunStateFile): boolean;
/** 读取 run-state.json。文件不存在 / parse 失败返 null。 */
export declare function readRunState(projectFolder: string, basename: string): RunStateFile | null;
/** statSync mtime — dispatcher polling 用。 */
export declare function getRunStateMtime(projectFolder: string, basename: string): number;
/** 返回 sidecar 文件**相对项目根**的路径，用于 prompt 系统指令告知 LLM。 */
export declare function runStateRelativePath(basename: string): string;
export declare function initialRunState(runId: string, basename: string, nodes: {
    id: string;
    type: NodeRunState['type'];
    label?: string;
}[]): RunStateFile;
/** Mutate-and-write helper：runtime 在每个状态切换点调一次，承担 read-modify-write 与
 *  原子写。文件可能并发被 LLM 改写（done flag），所以必须 read 最新值再 merge。 */
export declare function patchRunState(projectFolder: string, basename: string, patcher: (cur: RunStateFile) => RunStateFile): RunStateFile | null;
//# sourceMappingURL=run-state-file.d.ts.map