import { getSqliteDatabase } from './transaction.js'; import { type TurnOrigin } from '@xopcai/endpoint-tools-protocol'; import type { AgentSourceContext, SourceContextRefSummary } from '../../agent/source-context/types.js'; export type SessionInputDelivery = 'next' | 'steer'; export type SessionInputStatus = 'queued' | 'running' | 'injecting' | 'completed' | 'cancelled' | 'failed' | 'interrupted' | 'suspended'; export type SessionInputPayload = { waitId: string; objectiveRevision: number; resolution: 'continued' | 'skipped'; } | { waitId: string; objectiveRevision: number; resolution: 'answered' | 'agent_decide' | 'cancelled'; }; export type SessionInput = { id: string; sessionKey: string; clientMessageId: string; expectedSessionId?: string; requestedDelivery: SessionInputDelivery; effectiveDelivery: SessionInputDelivery; status: SessionInputStatus; content: string; taskRunId?: string; kind: 'message' | 'connection_resume' | 'clarification_resume'; payload?: SessionInputPayload; attachments?: unknown[]; contextRefs?: SourceContextRefSummary[]; contextSnapshots?: AgentSourceContext[]; thinking?: string; origin: TurnOrigin; position: number; targetRunId?: string; runId?: string; version: number; error?: string; createdAtMs: number; updatedAtMs: number; }; export type SessionInputState = { sessionKey: string; revision: number; activeRunId?: string; activeInputId?: string; inputs: SessionInput[]; }; export declare function bumpSessionInputRevision(db: ReturnType, sessionKey: string): number; export declare function getSessionInputState(sessionKey: string): SessionInputState; /** Durable active webchat runs claimed by the session-input coordinator. */ export declare function listActiveSessionInputRuns(): Array<{ sessionKey: string; runId: string; }>; export declare function findSessionInput(sessionKey: string, clientMessageId: string): SessionInput | undefined; export declare function getSessionInputById(sessionKey: string, id: string): SessionInput | undefined; export declare class SessionInstanceChangedError extends Error { constructor(); } export declare function insertSessionInput(input: { id: string; sessionKey: string; clientMessageId: string; expectedSessionId?: string; requestedDelivery: SessionInputDelivery; effectiveDelivery: SessionInputDelivery; status: 'queued' | 'injecting'; content: string; attachments?: unknown[]; taskRunId?: string; kind?: SessionInput['kind']; payload?: SessionInput['payload']; contextRefs?: SourceContextRefSummary[]; contextSnapshots?: AgentSourceContext[]; thinking?: string; origin: TurnOrigin; targetRunId?: string; }): SessionInput; export declare function claimNextSessionInput(sessionKey: string, runId: string): SessionInput | undefined; export declare function finishSessionInputRun(sessionKey: string, runId: string, status: 'completed' | 'failed' | 'cancelled' | 'suspended', error?: string): boolean; export declare function setSessionInputStatus(id: string, status: SessionInputStatus, patch?: { effectiveDelivery?: SessionInputDelivery; targetRunId?: string | null; error?: string; }): boolean; export declare function mutateQueuedSessionInput(input: { sessionKey: string; id: string; version: number; content?: string; attachments?: unknown[]; contextRefs?: SourceContextRefSummary[]; contextSnapshots?: AgentSourceContext[]; thinking?: string; position?: number; }): boolean; export declare function cancelQueuedSessionInput(sessionKey: string, id: string, version: number): boolean; export declare function recoverSessionInputState(): string[];