import type { CodexBridgeEvent } from './codex-transcript.js';
export interface CodexPendingTurn {
    turnId: string;
    started: boolean;
    contentFingerprint?: string;
    /** Wall-clock millis when mark() was called. The emit gate uses this as
     *  the lower bound of the "did `botmux send` happen for this turn?"
     *  window. Optional only for legacy / test-injected turns. */
    markTimeMs?: number;
    /** Set once an assistant_final event closes this turn. */
    finalText?: string;
    /** Set when this turn was synthesised from a user_message that didn't
     *  match any pending Lark fingerprint. Adopt-only. The worker emit path
     *  formats these with both userText and finalText under a "终端本地对话"
     *  header — same rationale as Claude's BridgeTurnQueue local turns. */
    isLocal?: boolean;
    /** For local turns: the user's typed text, surfaced alongside the
     *  assistant reply so the Lark thread sees both sides of the exchange. */
    userText?: string;
    sourceSessionId?: string;
}
export declare class CodexBridgeQueue {
    private seen;
    private queue;
    private collecting;
    private localTurnsEnabled;
    private bufferedUnmatched;
    /** Lower bound (ms) for synthesising local turns — protects against a
     *  fresh-empty attach replaying historical iTerm conversation as
     *  "live" local input. Typically set to the moment adopt was wired up. */
    private localLowerBoundMs;
    /** Register events as historical without producing pending-turn side
     *  effects. Used at attach time when resume mode wants to swallow prior
     *  conversation as already-processed. */
    absorb(events: CodexBridgeEvent[]): void;
    /** Toggle adopt-mode local-turn synthesis. `lowerBoundMs` (typically
     *  Date.now() at adopt-time) protects against a fresh-empty attach
     *  feeding historical user_messages back as "live" local turns. */
    setLocalTurns(enabled: boolean, lowerBoundMs?: number): void;
    /** Push a pending Lark turn anchored to the message text. The fingerprint
     *  derived from `message` is what the upcoming `user` event must contain
     *  to start this turn. Pre-path-known marking is allowed: the worker can
     *  call this before late-attach has located the rollout file, and the
     *  ingest call after attach will still match correctly. */
    mark(turnId: string, message: string, markTimeMs?: number): void;
    /** Drop all pending turns. Used when the worker decides it can't reliably
     *  attribute future events (e.g. a teardown). */
    clearPending(): CodexPendingTurn[];
    /** Process newly-appended events. Idempotent on uuid: events with seen
     *  uuids are skipped, so callers can replay safely. */
    ingest(events: CodexBridgeEvent[]): void;
    private replayBufferedUnmatched;
    private rememberUnmatched;
    private ingestOne;
    /** Pop FIFO any leading turn that is started AND has finalText. */
    drainEmittable(): CodexPendingTurn[];
    size(): number;
    /** Test helper — peek the queue without mutating. */
    peek(): readonly CodexPendingTurn[];
}
//# sourceMappingURL=codex-bridge-queue.d.ts.map