import { splitCodexEventsByCutoff, extractLastCodexTurn, type CodexBridgeEvent, type CodexDrainResult } from './codex-transcript.js'; export { splitCodexEventsByCutoff as splitTraexEventsByCutoff }; export { extractLastCodexTurn as extractLastTraexTurn }; export type { CodexBridgeEvent as TraexBridgeEvent }; export interface TraexDrainResult extends CodexDrainResult { /** Latest executor-reported model observed in the drained complete records. */ latestModel?: string; /** Latest executor-reported reasoning effort observed in complete records. */ latestReasoningEffort?: string; } export interface TraexDrainOptions { /** Adopt mode: the adopted CLI is botmux-unaware, so the drainer must NOT * synthesise a bare nothing-to-send sentinel for an empty final — the emit * layer posts transcript text verbatim in adopt mode and the literal token * would leak into Lark. Default false (synthesise, matching the non-adopt * genuine-silence contract). */ adoptMode?: boolean; /** Read-only probe: skip the per-turn agent_message cache mutations. Used by * submit-confirmation probes that re-drain the same live rollout at a * different offset and must not disturb the production drainer's pending * turn state. */ probe?: boolean; } export interface TraexRuntimeSnapshot { model?: string; reasoningEffort?: string; } /** Incrementally drain complete TRAE rollout lines. * * `task_complete` is intentionally emitted even when last_agent_message is * missing/empty: a silent successful turn still has to release a durable * delivery. A non-newline-terminated tail is never parsed, so a process crash * halfway through the terminal JSON object cannot manufacture completion. * * Terminal refinement on an empty `last_agent_message`: * - a non-null `error` payload maps the event to `failed` (same shape as the * Codex drainer) — traecli writes task_complete with * last_agent_message=null AND error when the model endpoint fails, so the * failure must not be read as a silent success; * - otherwise the turn's agent_message records (tracked across drain calls) * recover a dropped final_answer or recognise a trailing * nothing-to-send sentinel as deliberate silence. The sentinel synthesis * runs only in non-adopt mode: adopt posts transcript text verbatim, so a * synthesised bare token would leak into Lark. */ export declare function drainTraexRollout(path: string, fromOffset: number, opts?: TraexDrainOptions): TraexDrainResult; /** Read the current TRAE runtime from complete rollout records without * retaining the full transcript in memory. Each field is latest-wins because * `/model` and `/effort` can change independently in a long-lived session. * * Scans BACKWARD in fixed-size chunks and stops as soon as both fields are * resolved — the newest `turn_context` is near the tail, so a live session * touches only the last chunk. A hard byte cap bounds the pathological case * where a field never appears (same guard rationale as #740's * MAX_USAGE_TRANSCRIPT_BYTES): runtime identity is advisory and must never * synchronously parse a multi-GB rollout on attach. A non-newline-terminated * trailing partial is excluded via baselineJsonlCursor, so a crash mid-write * cannot surface a half-written model — matching drainTraexRollout. */ export declare function readLatestTraexRuntime(path: string): TraexRuntimeSnapshot; /** Submit-confirmation probe: only a complete event_msg/user_message record * appended after `fromOffset` can match. Read-only — drains with `probe` so * it never mutates the per-turn agent_message cache the production drainer * relies on (a re-drain of the same live rollout at a different offset must * not clear pending turn state). Not currently wired into the production * submit-confirmation path; kept as a tested probe. */ export declare function traexRolloutHasUserInputSince(path: string, fromOffset: number, expectedText: string): boolean; export interface TraexHistoryMatch { found: boolean; cliSessionId?: string; } /** Optional ownership filter for a shared-history match: accept a same-text * line only when its session id is one the owning pid actually holds open. * Re-evaluated on every call so a lazily-opened owned rollout fd that appears * AFTER its history line can still be accepted on a later poll. */ export type TraexHistorySidFilter = (cliSessionId: string | undefined) => boolean; /** Scan the byte delta appended to history.jsonl since `fromByte` for a line * whose decoded `text` exactly matches `expectedText` (newline-normalised). * Never parses a non-newline-terminated tail, so a half-written line can't * manufacture a false match — a later poll sees the completed entry. */ export declare function traexHistoryMatchDelta(path: string, fromByte: number, expectedText: string, acceptSid?: TraexHistorySidFilter): TraexHistoryMatch; /** Current byte size of history.jsonl (0 when absent), captured before a paste * so the confirmation scan only considers lines this submit appends. */ export declare function traexHistorySize(path: string): number; /** Find the visible top-level rollout an externally-running TRAE process owns. * TRAE can keep the parent rollout and internal guardian/subagent rollouts open * in the same process. Internal rollouts are never adoptable. When a current * top-level session is supplied it remains preferred unless a newer top-level * user rollout proves a real in-process `/new` rotation. */ export declare function findTraexRolloutByPid(pid: number, preferredSessionId?: string): { path: string; cliSessionId: string; } | undefined; /** Lowercased set of TRAE session ids whose rollout the pid holds open. The * ownership gate for a shared-history.jsonl submit match: only a sid this pid * actually owns is safe to accept, so a concurrent sibling pane's identical * text can't hand back a foreign session id. Empty Set = pid holds no TRAE * rollout; undefined = fd enumeration unavailable (callers must treat undefined * as "cannot prove ownership" — fail closed, do not bind). Mirrors * findCodexRolloutSetByPid. */ export declare function findTraexRolloutSetByPid(pid: number): Set | undefined; /** Pure ownership decision: is `cliSessionId` one of the rollouts the observed * pid holds open? `ownedRollouts` is the lowercased sid set from * findTraexRolloutSetByPid (undefined when fd enumeration was unavailable). * FAIL CLOSED — a missing set or a non-member id returns false so the caller * never binds the bridge (or persists a resume id) it can't prove the pid owns. * Extracted so the exact predicate the worker's persist/attach gates use is * unit-testable without a live pid. Mirrors codexHistorySidIsOwned. */ export declare function traexHistorySidIsOwned(cliSessionId: string, ownedRollouts: Set | undefined): boolean; /** Locate the rollout file for a given TRAE session UUID. Filename shape is * identical to Codex: `rollout--.jsonl`, so a suffix match over the * TRAE sessions tree is unambiguous. */ export declare function findTraexRolloutBySessionId(cliSessionId: string): string | undefined; //# sourceMappingURL=traex-transcript.d.ts.map