import type { AgentMessage } from '@earendil-works/pi-agent-core'; import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol'; import type { AgentSourceContext, SourceContextRefSummary } from '../../agent/source-context/types.js'; export type ReplaceLatestSessionTurnInput = { sessionKey: string; targetTurnId: string; clientMessageId: string; content: string; attachments?: unknown[]; contextRefs?: SourceContextRefSummary[]; contextSnapshots?: AgentSourceContext[]; thinking?: string; origin: TurnOrigin; }; export type ReplaceLatestSessionTurnResult = { ok: true; idempotent: boolean; inputId: string; removedMessages: AgentMessage[]; remainingMessages: AgentMessage[]; } | { ok: false; code: 'TARGET_NOT_FOUND' | 'NOT_LATEST' | 'SESSION_BUSY'; }; /** Validate before aborting a run; the transactional mutation validates again. */ export declare function validateLatestSessionTurnTarget(sessionKey: string, targetTurnId: string): { ok: true; } | { ok: false; code: 'TARGET_NOT_FOUND' | 'NOT_LATEST'; }; /** * Replace the latest persisted user turn with a durable queued input. * Transcript deletion and input insertion share one SQLite transaction so a * failed enqueue cannot leave the conversation without the original turn. */ export declare function replaceLatestSessionTurnAndQueueInput(input: ReplaceLatestSessionTurnInput): ReplaceLatestSessionTurnResult;