import { type DB } from '../db/client.js'; import type { PendingReviewRow } from '../db/schema/pending_reviews.js'; export type ReviewStatus = 'pending' | 'approved' | 'sent' | 'rejected'; export type ReviewField = 'id' | 'whatsapp' | 'aiText' | 'editedText' | 'status' | 'wamid' | 'traceId' | 'tenantId' | 'threadId' | 'createdAt' | 'approvedAt' | 'approvedBy' | 'sentAt'; export declare const DEFAULT_REVIEW_COLUMNS: Readonly>; export interface AgentReviewQueueOptions { /** * D1 binding OR a pre-built Drizzle client (any schema). v0.7+: * normalized internally. */ db: D1Database | DB; /** Physical table name. Default `'pending_reviews'`. */ tableName?: string; columnMap?: Partial>; omitColumns?: ReadonlyArray; allowedExtraColumns?: ReadonlyArray; } export interface EnqueueReviewArgs { whatsapp?: string | null; aiText: string; wamid?: string | null; traceId?: string | null; tenantId?: string | null; threadId?: string | null; extraColumns?: Record; } export interface ApproveReviewArgs { approvedBy?: string | null; /** Override the original AI text. NULL means "send the original". */ editedText?: string | null; } export interface ListReviewsOptions { status?: ReviewStatus; tenantId?: string; whatsapp?: string; limit?: number; } export type ReviewRow = PendingReviewRow; export declare class AgentReviewQueue { readonly db: DB; readonly tableName: string; readonly columns: Readonly>; readonly omitColumns: ReadonlySet; readonly allowedExtraColumns: ReadonlySet; constructor({ db, tableName, columnMap, omitColumns, allowedExtraColumns, }: AgentReviewQueueOptions); /** * Insert a new pending review. Returns the generated id. The framework * calls this from `Agent.reply.ai()` when `mode === 'assisted'` + a * `reviewQueue` is configured. */ enqueue(args: EnqueueReviewArgs): Promise; byId(id: string): Promise; /** * Approve a pending review. Optional `editedText` overrides the AI's * answer on dispatch. Idempotent — re-approving an already-approved row * is a no-op. Returns true if the row transitioned from pending → approved. */ approve(id: string, args?: ApproveReviewArgs): Promise; /** Reject a pending review. Idempotent. */ reject(id: string, args?: { rejectedBy?: string | null; }): Promise; /** * Mark a row 'sent' after the WhatsApp dispatch succeeded. * `dispatchApprovedReviews` calls this after `client.sendText` returns. */ markSent(id: string): Promise; list({ status, tenantId, whatsapp, limit }?: ListReviewsOptions): Promise; /** Number of rows in a given status (default 'pending'), optionally per-tenant. */ countByStatus(status?: ReviewStatus, tenantId?: string): Promise; private selectList; } //# sourceMappingURL=review_queue.d.ts.map