import { type IndexedToolCall } from './tool-calls.js';
import type { SessionMeta } from './types.js';
export declare const BACKFILL_MAX_STREAM_SOURCE_BYTES: number;
export declare const TOOL_SEARCH_SCHEMA_VERSION = 1;
export declare const TOOL_PROGRAM_COUNT_SCHEMA_VERSION = 1;
export declare const TOOL_QUERY_MAX_CLAUSES = 32;
export declare const TOOL_QUERY_MAX_CLAUSE_BYTES = 4096;
export declare const TOOL_QUERY_MAX_CALL_ROWS = 50000;
export declare const TOOL_QUERY_MAX_RESULT_BYTES: number;
export declare const TOOL_QUERY_MAX_RESULT_SESSIONS = 1000;
export declare const TOOL_QUERY_MAX_SERIALIZED_BYTES: number;
export declare const TOOL_QUERY_MERGE_OVERHEAD_BYTES: number;
export interface ToolIndexCoverage {
    indexedFiles: number;
    indexedCalls: number;
    skippedFiles: number;
    limitedFiles: number;
    remainingFiles: number;
    complete: boolean;
}
export interface ToolCallEvidence extends IndexedToolCall {
    id: string;
}
export interface ToolSessionEvidence {
    id: string;
    shortId: string;
    agent: string;
    machine?: string;
    timestamp: string;
    project?: string;
    cwd?: string;
    topic?: string;
    label?: string;
    filePath?: string;
    calls: ToolCallEvidence[];
}
export interface ToolSearchEnvelope {
    schemaVersion: typeof TOOL_SEARCH_SCHEMA_VERSION;
    generatedAt: string;
    query: {
        clauses: string[];
    };
    coverage: ToolIndexCoverage;
    sessions: ToolSessionEvidence[];
}
export interface ToolProgramCountTotals {
    occurrences: number;
    toolCalls: number;
    sessions: number;
}
export interface ToolProgramCountEnvelope {
    schemaVersion: typeof TOOL_PROGRAM_COUNT_SCHEMA_VERSION;
    kind: 'tool-program-count';
    generatedAt: string;
    query: {
        program: string;
        semantics: 'static-program-occurrences-v1';
    };
    coverage: ToolIndexCoverage;
    totals: ToolProgramCountTotals;
    machines: Array<{
        machine: string;
        coverage: ToolIndexCoverage;
        totals: ToolProgramCountTotals;
    }>;
}
/** Serialize once and enforce headroom below the fleet transport's 16 MiB cap. */
export declare function serializeToolSearchEnvelope(envelope: ToolSearchEnvelope): string;
/** Exact UTF-8 size of the public pretty-JSON envelope. */
export declare function serializedToolSearchEnvelopeBytes(envelope: ToolSearchEnvelope): number;
/**
 * Reserve the exact local JSON plus coordinator headroom before retaining peer
 * stdout. Peer envelopes repeat metadata that disappears during merge, so
 * charging their full wire bytes against the remainder is conservative.
 */
export declare function toolSearchRemoteReceiveBudget(envelope: ToolSearchEnvelope): number;
/** Read index completeness from SQLite only; never stat or parse transcripts. */
export declare function readToolIndexCoverage(sessions: SessionMeta[]): ToolIndexCoverage;
/**
 * Fill one bounded chunk of the independent tool index. A warm call performs
 * only stat + ledger checks; it never opens or parses unchanged transcripts.
 */
export declare function ensureToolIndex(sessions: SessionMeta[], limits?: {
    maxFiles?: number;
    maxBytes?: number;
    verifySourceStamps?: boolean;
}): Promise<ToolIndexCoverage>;
interface QueryTerm {
    field?: 'tool' | 'program' | 'input' | 'output' | 'status' | 'exit' | 'error';
    value: string;
}
/** Parse one same-call clause. Unprefixed terms search every evidence field. */
export declare function parseToolQueryClause(source: string): QueryTerm[];
/** A count has one unambiguous subject: one exact `program:<name>` term. */
export declare function parseToolProgramCountClause(source: string): string;
/** Count exact, pre-indexed static program sites without reading transcripts. */
export declare function countToolProgramOccurrences(sessions: SessionMeta[], program: string, coverage: ToolIndexCoverage, machine: string): ToolProgramCountEnvelope;
/** Query cached evidence; every repeated clause must select a distinct call. */
export declare function searchToolCalls(sessions: SessionMeta[], clauseSources: string[], coverage: ToolIndexCoverage, resultLimit?: number): ToolSearchEnvelope;
export {};
