import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol'; import type { SessionInput } from '../../storage/sqlite/session-input-repository.js'; import type { UserTurnAttachment } from '../user-turn-input.js'; import { type AgentSourceContext, type TurnContextRef } from '../../agent/source-context/types.js'; import { type SessionInputDelivery, type SessionInputState } from '../../storage/sqlite/index.js'; export type SubmitSessionInput = { expectedSessionId?: string; sessionKey: string; clientMessageId: string; delivery: SessionInputDelivery; content: string; attachments?: UserTurnAttachment[]; contextRefs?: TurnContextRef[]; thinking?: string; origin: TurnOrigin; }; export type ReplaceLatestTurnInput = SubmitSessionInput & { targetTurnId: string; }; export declare class SessionInputCoordinator { private readonly deps; private readonly draining; private readonly submissionTails; constructor(deps: { beforeExecute?: (input: SessionInput) => Promise; sessionExists: (sessionKey: string) => Promise; execute: (input: { runId: string; taskRunId?: string; sessionKey: string; content: string; attachments?: UserTurnAttachment[]; sourceContexts?: AgentSourceContext[]; thinking?: string; origin: TurnOrigin; }) => Promise<{ status: string; summary: string; }>; prepareAttachments: (sessionKey: string, attachments?: UserTurnAttachment[]) => Promise; prepareContexts: (contextRefs?: TurnContextRef[]) => Promise; steer: (sessionKey: string, content: string) => Promise; emit: (type: string, payload: unknown) => void; }); snapshot(sessionKey: string): SessionInputState; private publish; private runSubmissionExclusive; submit(input: SubmitSessionInput): Promise<{ ok: true; effectiveDelivery: SessionInputDelivery; state: SessionInputState; } | { ok: false; code: 'BAD_REQUEST' | 'QUEUE_FULL' | 'CONTEXT_UNAVAILABLE' | 'SESSION_CHANGED'; }>; replaceLatestTurn(input: ReplaceLatestTurnInput, beforeReplace: () => Promise): Promise<{ ok: true; effectiveDelivery: 'next'; state: SessionInputState; } | { ok: false; code: 'BAD_REQUEST' | 'TARGET_NOT_FOUND' | 'NOT_LATEST' | 'SESSION_BUSY' | 'CONTEXT_UNAVAILABLE'; }>; private submitLocked; drain(sessionKey: string): Promise; update(sessionKey: string, id: string, body: { version: number; content?: string; attachments?: UserTurnAttachment[]; contextRefs?: TurnContextRef[]; thinking?: string; position?: number; }): Promise<{ ok: boolean; state: SessionInputState; contextUnavailable?: boolean; }>; remove(sessionKey: string, id: string, version: number): { ok: boolean; state: SessionInputState; }; waitForCompletion(sessionKey: string, clientMessageId: string): Promise; recover(): void; }