/** * Session Persistence Helpers * * Non-blocking helpers that save conversation state through a `TalkerStore`. * Safe to call when no store is configured - the no-op store gracefully * skips every write. */ import type { Channel } from "../types"; import type { TalkerStore } from "./store"; /** * Persist the current conversation state through `store`. * * `store` defaults to whatever the legacy singleton client (`./client.ts`) * resolves to when omitted - route handlers pass `deps.store` explicitly; * callers outside a mount (or tests using `setDbClient`) get the historical * fallback behavior. Awaits the session row write (so a caller that also * calls `persistFinalSession` right after can order the two - see its * docstring), but message inserts stay fire-and-forget since they don't * share a mutable field two calls could race on. Logs errors but never throws. */ export declare function persistSession(phoneNumber: string, channel: Channel, store?: TalkerStore): Promise; /** * Persist the final session state when a call completes. * Sets the reason and optional transfer reason. * * Writes the same session row `persistSession` does (upsert by session id), * so a caller that reports both the ongoing state and the final outcome for * one interaction must `await persistSession(...)` before calling this - * otherwise `persistSession`'s hardcoded `reason: "ended"` can complete after * this call's real reason and silently overwrite it (both are async database * writes with no ordering guarantee unless the caller imposes one). `store` * defaults the same way `persistSession`'s does; pass the same one to both * calls in one interaction. */ export declare function persistFinalSession(phoneNumber: string, channel: Channel, reason: "ended" | "redirected", transferReason?: string, store?: TalkerStore): void;