/** Extract the cliSessionId encoded in a rollout filename. Codex's session
 *  id is UUID-shaped (8-4-4-4-12 hex), which lets us anchor the regex on
 *  the UUID alone — the `<ts>` segment between "rollout-" and the sid
 *  contains its own dashes that would otherwise let a greedy match swallow
 *  parts of the sid. Returns undefined for paths that don't match. */
export declare function codexSessionIdFromRolloutPath(path: string): string | undefined;
/** Find the rollout file an externally-running Codex process has open. The
 *  Codex process keeps fd open on its current rollout for the entire
 *  lifetime of the session, so this is the authoritative way to bind a
 *  Codex pid to its sessionId — far more reliable than scanning
 *  `~/.codex/sessions` by mtime (which would race with sibling Codex panes
 *  in the same project).
 *
 *  Linux: `/proc/<pid>/fd/*` fast path.
 *  macOS / BSD: `lsof -p <pid> -Fn` 兜底（同 session-discovery 里的 readCwd）。
 *  两种平台都用 `codexSessionIdFromRolloutPath` 提取 sid。 */
export declare function findCodexRolloutByPid(pid: number): {
    path: string;
    cliSessionId: string;
} | undefined;
export interface CodexBridgeEvent {
    /** Synthetic uuid for dedup: `<absPath>:<byteOffset>` of the line start.
     *  Stable across re-drains because rollout files are append-only. */
    uuid: string;
    /** Wall-clock ms parsed from the event's `timestamp` field. Falls back
     *  to Date.now() if missing/unparseable so the gate's window math still
     *  has something to compare against. */
    timestampMs: number;
    /** Discriminator for the queue layer:
     *   - 'user' starts a pending Lark turn (fingerprint-matched)
     *   - 'assistant_final' closes the currently-collecting turn */
    kind: 'user' | 'assistant_final';
    /** Concatenated text from the message's content blocks (input_text for
     *  user, output_text for assistant). */
    text: string;
    sourceSessionId?: string;
}
/** Extract the last completed user/assistant turn from a Codex / CoCo bridge
 *  event sequence. Used by /adopt to surface the previous turn as a
 *  preamble card in the Lark thread — gives the user context to continue
 *  from. CoCo events share the same shape (uuid/timestampMs/kind/text),
 *  so this works for both bridges.
 *
 *  Algorithm: scan tail-first for the most recent `assistant_final`, then
 *  pair it with the most recent `user` event that precedes it. Returns
 *  undefined when either side is missing — typically a fresh session whose
 *  user typed something but the model hasn't replied yet. */
export declare function extractLastCodexTurn(events: readonly {
    kind: 'user' | 'assistant_final';
    text: string;
}[]): {
    userText: string;
    assistantText: string;
} | undefined;
/** Split a drained event list into "history" (older than the live cutoff)
 *  and "live" (cutoff or newer). The Codex adopt bridge uses this when
 *  it discovers the rollout file LATE (after the user already typed in
 *  iTerm or sent a Lark message): drain-from-0 produces a mix of pre-
 *  adopt history and post-adopt live events. The worker then `absorb()`s
 *  the history (so it isn't replayed) and `ingest()`s the live partition
 *  (so the local-turn synthesis / fingerprint match still works). Pure
 *  function — no I/O, easy to test against fixed timestamps. */
export declare function splitCodexEventsByCutoff(events: readonly CodexBridgeEvent[], liveSinceMs: number): {
    history: CodexBridgeEvent[];
    live: CodexBridgeEvent[];
};
export interface CodexDrainResult {
    events: CodexBridgeEvent[];
    /** Byte offset of the last fully-parsed line + its trailing \n. The next
     *  drain should pass this back as fromOffset. */
    newOffset: number;
    /** A line that was written without its terminating \n yet. Currently
     *  informational — only complete lines produce events. */
    pendingTail: string;
}
/** Locate the rollout file for a given Codex sessionId. Codex names files
 *  `rollout-<ts>-<sid>.jsonl`, so a suffix match is unambiguous. The
 *  directory tree is small (year/month/day) — a one-shot recursive scan
 *  is cheap enough that we don't bother caching. */
export declare function findCodexRolloutBySessionId(cliSessionId: string): string | undefined;
/** Find the newest Codex session whose history entry includes a botmux
 *  session id. Fresh dashboard rows often only know botmux's UUID; Codex's
 *  rollout filename uses its own UUID, and history.jsonl is the durable bridge
 *  between the two. Only the trailing `maxTailBytes` of the file is scanned. */
export declare function findCodexSessionIdByBotmuxSessionId(botmuxSessionId: string, opts?: {
    maxTailBytes?: number;
}): string | undefined;
/** Increment-read the rollout from `fromOffset`. Mirrors the byte-offset
 *  contract of claude-transcript.drainTranscript so callers can swap them
 *  out and reuse the existing fs.watch / poll wakeup machinery. */
export declare function drainCodexRollout(path: string, fromOffset: number): CodexDrainResult;
//# sourceMappingURL=codex-transcript.d.ts.map