import type { AgentHarnessRequest, AgentHarnessResponse } from "./types.js"; /** * Serializes turns per conversation while letting different conversations run * concurrently. A second message for a conversation whose turn is in flight is * *queued* and answered after the current turn finishes (queue-after-turn), * rather than rejected or run in parallel. * * The queue is deliberately decoupled from provider-session lifetime: it owns * only turn ordering. Whether a turn resumes a warm provider session or replays * history is decided by the runner (`MonoAgentHarness.run`) on each turn, so a * session that dies/evicts mid-queue simply demotes the next turn to a fresh * run — queued follow-ups are never silently dropped. */ export interface LiveSessionManager { /** Enqueue a turn; resolves when *this* turn completes (after any ahead of it). */ enqueue(conversationId: string, request: AgentHarnessRequest): Promise; /** Abort an uncommitted in-flight turn and reject every queued turn for the conversation. */ cancel(conversationId: string, reason?: unknown): void; /** Number of turns queued behind the active one. */ pendingCount(conversationId: string): number; /** * Abort uncommitted work, refuse further turns, and wait for any turn that * already crossed its durable commit boundary to finish publishing. */ dispose(): Promise; } export interface LiveSessionManagerOptions { /** Executes a single turn — typically `MonoAgentHarness.run`. */ readonly run: (request: AgentHarnessRequest, lifecycle: LiveSessionRunLifecycle) => Promise; /** * Max turns queued behind the active one per conversation. Beyond this, new * enqueues are rejected (cancelled) so a stuck active turn cannot retain * unbounded follow-ups. Default 100. */ readonly maxPendingPerConversation?: number; } /** Internal commit handshake between the serialized queue and the harness. */ export interface LiveSessionRunLifecycle { /** Cancellation is too late once durable conversation state starts committing. */ markCommitted(): void; } export declare function createLiveSessionManager(options: LiveSessionManagerOptions): LiveSessionManager; //# sourceMappingURL=live-session.d.ts.map