import type { EventLoopSlicer } from "../../../event-loop-slicer.ts";
import type { ExtensionAPI, ToolInfo } from "../../types.ts";
import { type Bm25Result, type Bm25SearchOptions } from "./engine/bm25.ts";
import type { ToolSearchDocument } from "./engine/document.ts";
export interface ToolSearchFeederHooks {
    /** Activate every named match, including names already active as stubs. */
    activate(names: readonly string[]): void;
}
export interface ToolSearchRuntime {
    getAllTools(): ToolInfo[];
    getActiveTools(): string[];
    setActiveTools(names: readonly string[]): void;
}
type RuntimeApi = Pick<ExtensionAPI, "getActiveTools" | "getAllTools" | "setActiveTools">;
/** Redirect text for a tool the model may name but cannot call directly (eval-only bash, removed tools). */
export interface HiddenToolHint {
    readonly name: string;
    readonly hint: string;
}
/** Session-scoped owner of the live generalized tool-search catalog. */
export declare class ToolSearchService {
    #private;
    constructor(runtime: ToolSearchRuntime);
    get isDisposed(): boolean;
    /** Retire this service with its session or extension generation; every later use throws. */
    dispose(sessionId: string, reason: string): void;
    /** Record that a native-injected request was rejected; the session consumes it once. */
    noteNativeInjectionFailure(reason: string): void;
    /** Consume the pending native-injection failure, if any (one-shot). */
    takeNativeInjectionFailure(): string | null;
    bindRuntime(runtime: RuntimeApi): void;
    bindActivationRuntime(runtime: Pick<RuntimeApi, "getActiveTools" | "setActiveTools">): void;
    /** Register the resident search tool only after a searchable catalog exists. */
    bindToolRegistrar(register: () => void): void;
    /** Let the host expose its removed-tool hints so a search for a hidden tool answers with the redirect. */
    bindRemovedToolHints(provider: () => Readonly<Record<string, string>>): void;
    /** Hints for every hidden tool the query names, in query order. */
    hiddenToolHints(query: string): HiddenToolHint[];
    /** Parameter schema of a registered tool, active or not, so a search result can be called by name. */
    getToolParameters(name: string): unknown;
    beginSession(): void;
    /** Replace one source's catalog generation and activation hook. */
    feed(source: "mcp", docs: readonly ToolSearchDocument[], hooks: ToolSearchFeederHooks): void;
    getCatalog(): ToolSearchDocument[];
    search(query: string, limit?: number, options?: Bm25SearchOptions): Bm25Result[];
    /**
     * Rank the tools the session routes through eval only (senpi#6886). They are never catalog entries, so no feeder
     * can activate them; a model reaches them as `tool.<name>(...)` inside an eval cell.
     */
    searchEvalOnly(query: string, limit?: number, options?: Bm25SearchOptions): Bm25Result[];
    /** Route all matches through their owning feeder, even when already active. */
    activate(matches: readonly Bm25Result[]): string[];
    activateTool(name: string): boolean;
    /** Replay ownership-aware and legacy MCP history once per catalog generation. */
    maybeRehydrateFromHistory(messages: readonly unknown[]): string[];
    /**
     * `maybeRehydrateFromHistory` for a whole session's entries: the candidate scan yields to the
     * event loop, so a large transcript does not hold a shared host while it opens (senpi#3518).
     */
    maybeRehydrateFromHistoryInSlices(messages: readonly unknown[], slicer: EventLoopSlicer): Promise<string[]>;
}
/** Make a session-owned service visible to later builtins loaded in the same provider scope. */
export declare function installScopedToolSearchService(value: ToolSearchService): void;
/** Own `value` as the tool-search service of the extension load that created `pi`. */
export declare function registerToolSearchServiceForExtensionLoad(pi: ExtensionAPI, value: ToolSearchService): void;
/** The tool-search service owned by the extension load that created `pi`. */
export declare function getToolSearchServiceForExtension(pi: object): ToolSearchService | undefined;
/** A session takes the service its extension load (keyed by that load's runtime) created. */
export declare function adoptToolSearchServiceForSession(extensionLoad: object): ToolSearchService | undefined;
/**
 * Resolve a service for a caller that holds no session: the provider scope's service, else the
 * only live session's service. With several live sessions there is no right answer, so it throws.
 * With none, a standalone service serves session-free callers.
 */
export declare function getToolSearchService(runtime?: ToolSearchRuntime): ToolSearchService;
export declare function resetToolSearchServiceForTests(): void;
export {};
//# sourceMappingURL=service.d.ts.map