import type { WakeRail } from "../types.js";
/** Bounded so an always-on peer cannot grow this without limit. Oldest are dropped. */
export declare const WAKE_LOG_MAX_RECORDS = 500;
/**
 * `injected`: an inject-only or broadcast-awareness resume (no reply relayed). Those are recorded
 * ONLY when their codex sandbox restore failed (COG-87) — see auto-relay.ts _recordInjectRestoreError.
 */
export type WakeOutcome = "replied" | "failed" | "refused" | "threw" | "injected" | "late-replied" | "late-none";
/** COG-95: what the asker was told at the end of this wake. */
export type WakeNotice = "processing" | "failure" | "queued-live" | "none";
/**
 * COG-95: how the answer reached the asker. A timed-out app-server wake that handed its turn to a
 * late wait is recorded as `pending-late`; the late wait appends a SECOND row with the same
 * messageId/traceId (outcome `late-replied` | `late-none`) — the collector joins on messageId.
 */
export type WakeDelivery = "in-time" | "late-by-bridge" | "none" | "pending-late";
export interface WakeRecord {
    /** ISO timestamp, stamped on append. */
    ts: string;
    traceId: string;
    /** The relay message id that triggered this wake — the join key the report asked for. */
    messageId: string;
    fromPeerId: string;
    toPeerId: string;
    cwd: string;
    sessionId: string;
    platform: string;
    outcome: WakeOutcome;
    exitCode: number | null;
    durationMs: number;
    /** Paths changed during the wake window; "HEAD" if it committed. null = not a git repo. */
    filesChanged: string[] | null;
    messagePreview: string;
    /**
     * COG-87: a codex app-server wake could not put the thread owner's own sandbox back, so the
     * human's next turns may run under the wake's policy. The full warning; absent when it did not
     * fail. Recorded here so it is visible in cogent_wake_log, not only in the bridge's stderr.
     */
    sandboxRestoreError?: string;
    /**
     * COG-105: a codex wake fell back to exec-resume — why the app-server rail could not be used
     * (CliExecResult.appServerError). `APP_SERVER_SOCKET_GONE: …` = the daemon runs but its socket
     * was deleted; the text names the restart command. Absent when the rail was not in play.
     */
    appServerError?: string;
    /** The rail that actually ran (not the configured one). */
    rail?: WakeRail;
    /** Effective codex sandbox of the wake; null for non-codex agents. */
    sandbox?: string | null;
    /** Experiment phase from ~/.cogent/wake-experiment.json at wake time; null outside a phase. */
    phase?: string | null;
    /** Whether option A (late answer) was switched on for this wake. */
    lateAnswer?: boolean;
    bridgeVersion?: string;
    /** The wake timeout in force (COGENT_TIMEOUT_MS). */
    timeoutMs?: number | null;
    codexVersion?: string;
    /** Cogent's codex Stop hook at wake time; null = not listed by hooks/list. */
    stopHook?: {
        enabled: boolean;
        trust: string;
    } | null;
    /** ISO time the bridge stopped waiting for the turn (app-server timeout). */
    gaveUpAt?: string;
    notice?: WakeNotice;
    delivery?: WakeDelivery;
    /** Late rows: ISO time the codex turn ended (as seen by the bridge). */
    turnEndedAt?: string;
    /** ISO time the answer was posted to the relay. */
    deliveredAt?: string;
    /** Late rows that delivered nothing: why ("window" | "closed" | "error" | …); also "no-turn-id". */
    lateReason?: string;
    /**
     * COG-93: extra time a Claude wake got at its timeout because it was changing files; durationMs is
     * then its real length (killed at the new limit = still unknown how long it needed).
     */
    timeoutExtendedMs?: number;
}
/**
 * `~/.cogent/wake-log/<sha256(cwd)[..16]>.jsonl`
 *
 * Homedir-based, NOT COGENT_STATE_PATH — same reasoning as wake-inflight note 1. The whole
 * point is that a process which is NOT this bridge (the operator's shell, the interactive
 * session) can find it. An .mcp.json env var reaches only the bridge, so keying on
 * COGENT_STATE_PATH would hide the log from precisely the readers it exists for.
 */
export declare function wakeLogPath(cwd: string): string;
/** A git snapshot: HEAD plus every dirty path. null when cwd is not a git worktree. */
export interface TreeState {
    head: string;
    entries: Record<string, string>;
}
/**
 * Snapshot the worktree. Returns null (never throws, never guesses) when cwd is not a git
 * repo or git is unavailable — "I cannot tell" is a legitimate answer and is recorded as one.
 */
export declare function captureTreeState(cwd: string): TreeState | null;
/**
 * Paths that differ between two snapshots, plus "HEAD" when the wake committed.
 * null when either side could not be captured.
 */
export declare function diffTreeState(before: TreeState | null, after: TreeState | null): string[] | null;
/**
 * Append one record. Never throws: a read-only home, a full disk or a race must cost the
 * log entry, never the wake.
 */
export declare function appendWakeRecord(record: Omit<WakeRecord, "ts">, cwd: string): void;
/**
 * Read the log back, oldest first. A corrupt line is SKIPPED, not fatal: a forensic log
 * that throws on one bad byte is useless exactly when it is needed.
 */
export declare function readWakeLog(cwd: string, limit?: number): WakeRecord[];
//# sourceMappingURL=wake-log.d.ts.map