import type { WorkerToDaemon } from '../types.js'; import type { Session } from '../types.js'; import { type SkillFeedbackStore, type TurnCompletionEventPayload } from './skill-feedback-store.js'; export declare function persistTurnTerminal(input: { dataDir: string; botAppId: string; session: Pick; terminal: Pick, 'turnId' | 'dispatchAttempt' | 'status'>; store?: SkillFeedbackStore; }): Promise; export interface EnqueueTurnTerminalInput { dataDir: string; botAppId: string; sessionId: string; terminal: Pick, 'turnId' | 'dispatchAttempt' | 'status'>; onError?: (error: unknown) => void; /** Test/tuning knobs. */ retryBaseMs?: number; maxRetryMs?: number; maxAttempts?: number; } /** * Enqueue a turn terminal for nonblocking persistence. Returns a promise that * settles when the terminal is durably recorded (or permanently gives up after * maxAttempts). Re-enqueuing the same (bot,session,turn,attempt) while one is * in flight returns the existing promise — the write is idempotent, so a repeat * signal need not queue twice. But if the repeat carries a DIFFERENT terminal * status for the same key, that is a real conflict (the store would throw * turn_terminal_status_conflict on commit); surface it immediately via onError * instead of silently letting the first-arrived status win. * Never rejects: terminal failures are surfaced via onError and the promise * resolves so a caller awaiting drain cannot hang. After shutdown drain closes * admission, new enqueues are refused (surfaced via onError) — the daemon is * stopping and the durable outbox / next boot reconcile; accepting here would * race the drain and could be silently dropped. */ export declare function enqueueTurnTerminal(input: EnqueueTurnTerminalInput): Promise; /** * Close admission and await all in-flight turn-terminal persistence, bounded by * timeoutMs. Called during graceful shutdown so the last turns are not lost. * Closing admission FIRST removes the race where a terminal enqueued after the * snapshot is skipped. Loops until the queue is truly empty (not a static * snapshot) so items rescheduled onto a backoff timer are also awaited. Returns * the count still pending when the bound elapsed (0 = fully drained). * Best-effort: a nonzero return is logged by the caller, not fatal — the * durable outbox and next-boot reconciliation cover anything not flushed. */ export declare function drainTurnTerminalQueue(timeoutMs?: number): Promise; /** Test-only: current in-flight count. */ export declare function __testOnly_pendingTurnTerminalCount(): number; /** Test-only: reopen admission (drain closes it for the process otherwise). */ export declare function __testOnly_reopenTurnTerminalAdmission(): void; //# sourceMappingURL=turn-completion-events.d.ts.map