import type { EntityWithProvenance } from "../../services/entity_queries.js";
interface QueryEntitiesParams {
    userId: string;
    entityType?: string;
    includeMerged?: boolean;
    includeSnapshots?: boolean;
    sortBy?: "entity_id" | "canonical_name" | "observation_count" | "last_observation_at" | "submitted_at";
    sortOrder?: "asc" | "desc";
    published?: boolean;
    publishedAfter?: string;
    publishedBefore?: string;
    search?: string;
    similarityThreshold?: number;
    limit?: number;
    offset?: number;
    updatedSince?: string;
    createdSince?: string;
    /** R3: filter entities by the identity_basis carried on their observations. */
    identityBasis?: "schema_rule" | "schema_lookup" | "heuristic_name" | "heuristic_fallback" | "target_id";
    /**
     * When true, omit chat bookkeeping types (`conversation`, `conversation_message`,
     * etc.) from results. Default false — bookkeeping is included unless the caller
     * opts in. Has no effect when `entityType` already filters to a bookkeeping type.
     */
    excludeBookkeeping?: boolean;
}
/** Extra lexical/semantic rank when a query token equals the row's entity_type (e.g. "plan" → plan). */
export declare const ENTITY_TYPE_KEYWORD_BOOST = 280;
export declare function shouldExcludeBookkeepingFromSearch(entityType?: string): boolean;
export declare function normalizeSearchText(text: string): string;
export declare function matchesSearchTokens(searchableText: string, searchTokens: string[]): boolean;
/** True when a token matches entity_type exactly or as a conventional plural (plans → plan). */
export declare function searchTokenMatchesEntityType(token: string, entityType: string): boolean;
export declare function entityTypeKeywordBoost(entityType: string, searchTokens: string[]): number;
export declare function buildEntityTypeFilterTokens(searchTokens: string[], knownEntityTypes: Set<string>): Set<string>;
/** When the query names an entity type, that token filters by type instead of snapshot text. */
export declare function textTokensForEntityMatch(searchTokens: string[], entityType: string, typeFilterTokens: Set<string>): string[];
/** Canonical lexical haystack: canonical_name + snapshot + optional raw_fragments text. */
export declare function buildEntityLexicalSearchText(canonicalName: string, snapshot: unknown, rawFragmentText?: string): string;
export declare function queryEntitiesWithCount(params: QueryEntitiesParams): Promise<{
    entities: EntityWithProvenance[];
    total: number;
    excluded_merged: boolean;
}>;
export declare function filterEntitiesBySearch<T extends {
    canonical_name: string;
}>(entities: T[], search?: string): T[];
export {};
//# sourceMappingURL=entity_handlers.d.ts.map