import { type SQL } from "drizzle-orm"; import type { SessionMessageSearchRequest, SessionMessageSearchResponse } from "@opengeni/contracts"; import type { Database } from "./database.js"; /** Eligible messages one search statement reads, in key order. Small enough * that a cold window stays far below the request's statement timeout. */ export declare const SESSION_MESSAGE_SEARCH_WINDOW = 2000; export declare class SessionMessageSearchCursorError extends Error { constructor(); } /** ECMAScript Unicode simple case folding, not locale-sensitive lowercasing. * Escaping every regexp metacharacter makes %, _, backslash, etc. literal too. * RegExp indices refer to original UTF-16 text (no lowercased-offset drift). */ export declare function sessionMessageLiteralPattern(query: string): RegExp; /** Every code point that `sessionMessageLiteralPattern` treats as the same * character, keyed by each member. Characters absent from the map only match * themselves. Built once from the runtime's own case mappings and verified * against its `iu` matching, so the database filter agrees with the exact * JavaScript matcher (including K/k/U+212A, s/S/U+017F and the Greek sigmas). */ export declare function sessionMessageCaseClasses(): ReadonlyMap; /** A PostgreSQL advanced regular expression matching exactly the strings that * contain `query` under `sessionMessageLiteralPattern`. Every character is a * \u/\U escape, so no character is special and the database collation plays * no part. Null when the query holds a character PostgreSQL text cannot store * (NUL or a lone surrogate): only losslessly encoded text can contain it. */ export declare function sessionMessagePostgresPattern(query: string): string | null; /** Database tests over stored message text: `matched` is exact for ordinary * text; `encoded` marks losslessly encoded strings, which only the decoding * reader can inspect and so always remain candidates. */ export declare function sessionMessageTextMatchSql(query: string, text: SQL): { matched: SQL; encoded: SQL; }; export declare function sessionMessageSearchSnippet(text: string, start: number, length: number): { text: string; matchStart: number; matchEnd: number; }; /** Internal executor: caller holds subject RLS, session-tenancy and membership * fences and supplies the ordinary session list filters. Never call as auth. * Work/transfer is bounded by 32 scalar windows per request. No history cutoff: * an unfinished scan ALWAYS returns an advancing cursor, even with zero hits. */ export declare function scanSessionMessages(db: Database, workspaceId: string, request: SessionMessageSearchRequest, filters: SQL[], authorityIdentity: unknown, signal?: AbortSignal): Promise;