import { type ServeOptions, type ServerHandle } from "../api/index.js"; import { type DocumentOptions, type ResolvedConfig } from "../config.js"; import { type AnswerResult, type PromptOptions } from "../llm/index.js"; import { type SearchToolOptions } from "../tools/search-tool.js"; import type { LLMProviderConfig, SearchResult } from "../types.js"; import { Document, type IndexOptions, type SearchOptions } from "./document.js"; export interface CollectionBuildResult { totalDocuments: number; totalChunks: number; cachedDocuments: number; newDocuments: number; errors: { source: string; error: string; }[]; } export interface CollectionAskOptions extends SearchOptions, PromptOptions { llm?: LLMProviderConfig; /** Cancels the LLM request. */ signal?: AbortSignal; } /** * Manages semantic indexing, multi-document retrieval, and question-answering across * multiple files, directories, glob patterns, and URLs. */ export declare class DocumentCollection { private readonly sources; private readonly options; private readonly config; private readonly logger; private readonly documents; private ready; constructor(sources?: string | string[], options?: DocumentOptions); /** * Add a file path, directory path, glob pattern, or web URL to the collection. */ addSource(source: string): void; /** * Build (or reuse) semantic indexes for all documents in the collection. */ build(options?: IndexOptions): Promise; /** * Search across all documents in the collection. `mode` picks vector * (default), keyword or hybrid retrieval. */ search(query: string, options?: SearchOptions): Promise; /** Merged retrieval over every document, without reranking. */ private retrieve; /** * Runs `fn` on every document. One broken document should not hide results * from the others, but if every document failed the caller needs the * error, not an empty list. */ private settle; /** * Ask a question across the entire collection. */ ask(question: string, options?: CollectionAskOptions): Promise; /** * Stream LLM response over retrieved collection context. */ askStream(question: string, options?: CollectionAskOptions): AsyncGenerator; /** * An AI SDK tool that searches every document in the collection, for `generateText({ tools })` and agents. * * ```ts * await generateText({ model, tools: { searchDocs: collection.asTool() }, prompt }); * ``` */ asTool(options?: SearchToolOptions): ({ title?: string; providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions; metadata?: import("@ai-sdk/provider").JSONObject; inputSchema: import("ai").FlexibleSchema<{ query: string; }>; contextSchema?: import("ai").FlexibleSchema | undefined; needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{ query: string; }, NoInfer> | undefined; onInputStart?: ((options: import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputDelta?: ((options: { inputTextDelta: string; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputAvailable?: ((options: { input: { query: string; }; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; toModelOutput?: ((options: { toolCallId: string; input: { query: string; }; output: NoInfer; }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike) | undefined; } & { outputSchema?: import("ai").FlexibleSchema | undefined; execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; } & { description?: string | ((options: { context: NoInfer; experimental_sandbox?: import("ai").Experimental_SandboxSession; }) => string) | undefined; strict?: boolean; inputExamples?: { input: NoInfer<{ query: string; }>; }[] | undefined; id?: never; isProviderExecuted?: never; args?: never; supportsDeferredResults?: never; } & { type?: undefined | "function"; } & { execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; }) | ({ title?: string; providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions; metadata?: import("@ai-sdk/provider").JSONObject; inputSchema: import("ai").FlexibleSchema<{ query: string; }>; contextSchema?: import("ai").FlexibleSchema | undefined; needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{ query: string; }, NoInfer> | undefined; onInputStart?: ((options: import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputDelta?: ((options: { inputTextDelta: string; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputAvailable?: ((options: { input: { query: string; }; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; toModelOutput?: ((options: { toolCallId: string; input: { query: string; }; output: NoInfer; }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike) | undefined; } & { outputSchema?: import("ai").FlexibleSchema | undefined; execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; } & { description?: string | ((options: { context: NoInfer; experimental_sandbox?: import("ai").Experimental_SandboxSession; }) => string) | undefined; strict?: boolean; inputExamples?: { input: NoInfer<{ query: string; }>; }[] | undefined; id?: never; isProviderExecuted?: never; args?: never; supportsDeferredResults?: never; } & { type: "dynamic"; } & { execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; }) | ({ title?: string; providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions; metadata?: import("@ai-sdk/provider").JSONObject; inputSchema: import("ai").FlexibleSchema<{ query: string; }>; contextSchema?: import("ai").FlexibleSchema | undefined; needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{ query: string; }, NoInfer> | undefined; onInputStart?: ((options: import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputDelta?: ((options: { inputTextDelta: string; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputAvailable?: ((options: { input: { query: string; }; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; toModelOutput?: ((options: { toolCallId: string; input: { query: string; }; output: NoInfer; }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike) | undefined; } & { outputSchema?: import("ai").FlexibleSchema | undefined; execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; } & { type: "provider"; id: `${string}.${string}`; args: Record; description?: never; strict?: never; inputExamples?: never; } & { isProviderExecuted: false; supportsDeferredResults?: never; } & { execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; }) | ({ title?: string; providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions; metadata?: import("@ai-sdk/provider").JSONObject; inputSchema: import("ai").FlexibleSchema<{ query: string; }>; contextSchema?: import("ai").FlexibleSchema | undefined; needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{ query: string; }, NoInfer> | undefined; onInputStart?: ((options: import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputDelta?: ((options: { inputTextDelta: string; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; onInputAvailable?: ((options: { input: { query: string; }; } & import("ai").ToolExecutionOptions>) => void | PromiseLike) | undefined; toModelOutput?: ((options: { toolCallId: string; input: { query: string; }; output: NoInfer; }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike) | undefined; } & { outputSchema?: import("ai").FlexibleSchema | undefined; execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; } & { type: "provider"; id: `${string}.${string}`; args: Record; description?: never; strict?: never; inputExamples?: never; } & { isProviderExecuted: true; supportsDeferredResults?: boolean; } & { execute: import("ai").ToolExecuteFunction<{ query: string; }, import("../tools/search-tool.js").Passage[], NoInfer>; }); /** * Serve a REST API server over the document collection. */ serve(options?: ServeOptions): Promise; /** * Access underlying Document instances. */ getDocuments(): Document[]; /** Number of total chunks across all documents in the collection. */ get chunkCount(): number; /** Underlying resolved configuration (readonly view). */ get resolvedConfig(): Readonly; private ensureReady; }