import { requireNodeSqlite } from "../memory/sqlite.js";
import type { PluginHookMessageContext } from "../plugins/hooks.js";
/**
 * Message Ledger — SQLite inbound/outbound message logging.
 *
 * Persists every message flowing through the gateway to a local SQLite database,
 * regardless of whether the message reaches an agent (filtered by mention gating,
 * allowFrom, group policy, etc.).
 *
 * Opt-in feature — enable via:
 *   - Config:   gateway.messageLedger.enabled: true
 *   - Env var:  MINION_MESSAGE_LEDGER=1
 *
 * Database path defaults to {workspaceDir}/message-ledger.db but can be overridden:
 *   - Config:   gateway.messageLedger.dbPath
 *   - Env var:  MINION_MESSAGE_LEDGER_PATH
 */
import type { PluginHookMessageInboundEvent, PluginHookMessageSentEvent } from "../plugins/types.js";
type DatabaseSync = InstanceType<ReturnType<typeof requireNodeSqlite>["DatabaseSync"]>;
export declare function openMessageLedger(dbPath: string): void;
export declare function closeMessageLedger(): void;
export declare function recordInboundMessage(event: PluginHookMessageInboundEvent): void;
export declare function recordOutboundMessage(event: PluginHookMessageSentEvent, ctx: PluginHookMessageContext): void;
/**
 * Update the most recent inbound row for a chat with the resolved session key
 * and agent ID. Called from the `message_received` hook which fires post-routing.
 *
 * Note: message_inbound stores channel-native chat IDs (e.g. WhatsApp JID)
 * while message_received uses normalised identifiers (e.g. E.164). We match
 * on channel + account_id + recency instead of chat_id to avoid mismatches.
 */
export declare function updateInboundSessionInfo(ctx: PluginHookMessageContext): void;
/** Expose the active database for testing. */
export declare function getMessageLedgerDb(): DatabaseSync | null;
/** Reset module state (testing only). */
export declare function resetMessageLedgerForTest(): void;
export {};
