import type { SessionEvent } from "@opengeni/contracts"; import type { Database } from "./database.js"; export type SessionCommandOutputInput = { accountId: string; workspaceId: string; sessionId: string; commandId: string; /** Stable identity of this consumed provider chunk, reused on persistence retry. */ chunkId: string; stream: "stdout" | "stderr"; streamFidelity?: "separate" | "merged"; chunk: string; }; /** Every output chunk of a command carries a client event id with this prefix. * Readers bound their scan by it (byte order), so it must never change. */ export declare function commandOutputClientEventIdPrefix(commandId: string): string; /** Frames stored per transaction by a connected capture: a statement-size * bound, so one transaction's parameters stay well within PostgreSQL's limit * while a replay of thousands of frames takes a few transactions, not one each. */ export declare const CONNECTED_COMMAND_OUTPUT_FRAMES_PER_TRANSACTION = 256; /** One provider-frame identity scheme for attached reads, push and reconciliation. */ export declare function createConnectedCommandOutputCapture(db: Database, ids: { accountId: string; workspaceId: string; sessionId: string; }, publish?: (events: SessionEvent[]) => Promise): (commandId: string, frames: Array<{ sequence: string; stream: "stdout" | "stderr"; chunk: string; }>) => Promise; /** Capture is independent of terminal observation and remains valid after the * launching attempt ends. Only an exact retained process/background command in * this session is eligible; this helper never creates command authority. */ export declare function appendSessionCommandOutput(db: Database, input: SessionCommandOutputInput): Promise; /** Store several chunks of ONE command, in order, in one transaction. Each * chunk keeps its own identity and is idempotent exactly as when stored * alone; storing a batch only saves the transaction and lock per chunk. */ export declare function appendSessionCommandOutputs(db: Database, inputs: readonly SessionCommandOutputInput[]): Promise;