import type { DatabaseSync } from 'node:sqlite'; import type { OneShotDestination, OneShotTerminalReason } from '@xopcai/gateway-contract'; import type { AttentionThread, Outreach } from './attention-repository.js'; export interface SettleOneShotSqlOptions { status: 'completed' | 'expired'; terminalReason: OneShotTerminalReason; now: number; lastCheckedAt?: number; clearLastCheckError?: boolean; outreachMode?: 'cancelled' | 'stale' | 'none'; wakeupAction?: { kind: 'cancel_all'; } | { kind: 'single'; wakeupId: string; status: 'cancelled' | 'done'; } | { kind: 'none'; }; nextRevision?: number; } export declare function hasCoveringOneShotRecord(ownerId: string, taskId: string, waitId: string, db?: DatabaseSync): boolean; export declare function findLatestOutreachForThread(threadId: string, db?: DatabaseSync): Outreach | undefined; export declare function findProjectNameById(projectId: string, db?: DatabaseSync): string | undefined; export declare function findOneShotThreadByIdAndOwner(followUpId: string, ownerId: string, db?: DatabaseSync): AttentionThread | undefined; export declare function listTaskOneShotThreadIds(ownerId: string, taskId: string, db?: DatabaseSync): string[]; export declare function listUnreadWorkbenchOutreachRows(ownerId: string, db?: DatabaseSync): Array<{ follow_up_id: string; outreach_id: string; task_id: string; wait_id: string; subject: string; text: string | null; published_at: number; }>; export declare function findWorkbenchOutreachForAck(outreachId: string, ownerId: string, db?: DatabaseSync): { outreach_id: string; acknowledged_at: number | null; follow_up_id: string; task_id: string; } | undefined; export declare function markWorkbenchOutreachAcknowledged(outreachId: string, now: number, db?: DatabaseSync): void; export declare function findOneShotThreadIdBySessionInput(ownerId: string, sessionInputId: string, db?: DatabaseSync): string | undefined; export declare function findOneShotThreadIdBySourceEntry(entryId: string, ownerId: string, db?: DatabaseSync): string | undefined; export declare function findUserTranscriptEntryPayload(entryId: string, transcriptId: string | null, db?: DatabaseSync): { payload_json: string; created_at: number; } | undefined; export declare function findActiveOneShotThreadIdByContractKey(ownerId: string, contractKey: string, db?: DatabaseSync): string | undefined; export declare function insertAttentionSourceIgnore(input: { threadId: string; evidenceId: string; entryId: string; transcriptId: string | null; conversationId: string; }, db?: DatabaseSync): void; export declare function touchAttentionThreadMeaningfulAt(threadId: string, observedAt: number, now: number, db?: DatabaseSync): void; export declare function findActiveOneShotThreadForWait(ownerId: string, taskId: string, waitId: string, db?: DatabaseSync): { id: string; revision: number; } | undefined; export declare function insertOneShotThread(input: { id: string; ownerId: string; agentId: string; conversationId: string; subject: string; summary: string; taskId: string; projectId: string | null; checkAt: number; validUntil: number; observedAt: number; now: number; waitId: string; destination: OneShotDestination; timezone: string; contractKey: string; sessionInputId: string | null; }, db?: DatabaseSync): void; export declare function insertPendingOneShotWakeup(input: { id: string; threadId: string; dedupeKey: string; notBefore: number; expiresAt: number; createdAt: number; }, db?: DatabaseSync): void; export declare function findStrategyOperationByDedupeKey(ownerId: string, dedupeKey: string, db?: DatabaseSync): { thread_id: string; input_json: string; } | undefined; export declare function insertStopStrategyVersion(input: { id: string; ownerId: string; threadId: string; revision: number; beforeJson: string; afterJson: string; inputJson: string; sourceEntryId: string | null; dedupeKey: string; createdAt: number; }, db?: DatabaseSync): void; export declare function persistSettledOneShotThread(db: DatabaseSync, threadId: string, opts: SettleOneShotSqlOptions): void; export declare function listOverdueActiveOneShotThreads(db: DatabaseSync, now: number): AttentionThread[]; export declare function listActiveOneShotThreadsForTask(db: DatabaseSync, taskId: string): AttentionThread[]; export declare function listDueOneShotWakeups(db: DatabaseSync, now: number): Array<{ wakeup_id: string; thread_id: string; thread_revision: number; }>; export declare function findAttentionThreadById(db: DatabaseSync, threadId: string): AttentionThread | undefined; export declare function cancelOneShotWakeup(db: DatabaseSync, wakeupId: string): void; export declare function findOutreachIdByWakeupId(db: DatabaseSync, wakeupId: string): string | undefined; export declare function insertReadyOneShotOutreach(db: DatabaseSync, input: { outreachId: string; wakeupId: string; threadId: string; conversationId: string; originTranscriptId: string; threadRevision: number; contextRevision: number; policyRevision: number; reason: string; text: string; provenanceJson: string; validUntil: number; now: number; destination: OneShotDestination; }): void; export declare function markOneShotWakeupEvaluated(db: DatabaseSync, threadId: string, wakeupId: string, now: number): void; export declare function listPublishableOneShotOutreach(db?: DatabaseSync): Outreach[]; export declare function findOutreachById(db: DatabaseSync, outreachId: string): Outreach | undefined; export declare function clearOneShotOutreachWithState(db: DatabaseSync, outreachId: string, state: 'cancelled' | 'stale'): void; export declare function markOneShotOutreachPublished(db: DatabaseSync, outreachId: string, messageEntryId: string | null, now: number): void; export declare function markOneShotOutreachNotified(outreachId: string, now: number, db?: DatabaseSync): void;