/** * Embeddings public API. * * The rest of AiDex talks to this module ONLY through `getEmbeddings()`. * No deep imports — that's how we keep the system encapsulated. * * The default instance is a stub: it costs nothing, loads nothing, and * answers `isEnabled()` with false. The real implementation (model loading, * sqlite-vec, HTTP downloads) is loaded lazily on the first `enable()` call. */ export type SourceKind = 'code' | 'docs' | 'workspace'; export type SourceType = 'method' | 'type' | 'doc-section' | 'task' | 'note' | 'note-history' | 'task-log'; export type SearchScope = 'current' | 'all' | 'linked'; export type SearchMode = 'semantic' | 'hybrid' | 'exact'; export interface EnableOptions { /** Model id from the registry (default: jina-code). */ model?: string; /** Mark this project's embeddings as private. Reserved for future team-sync. */ isPrivate?: boolean; } export interface IndexOptions { /** Limit indexing to a specific source kind. Default: all. */ sourceKinds?: SourceKind[]; /** Re-embed everything, ignoring content hashes. */ force?: boolean; } export interface IndexResult { embedded: number; skipped: number; removed: number; durationMs: number; } export type LlmStrategy = 'auto' | 'off' | 'translate' | 'rerank' | 'expand+rerank'; export interface SearchOptions { query: string; scope?: SearchScope; /** Required when scope is 'current' or 'linked'. */ path?: string; projectFilter?: string[]; sourceKinds?: SourceKind[]; sourceTypes?: SourceType[]; mode?: SearchMode; k?: number; /** * LLM-layer strategy. * - 'auto' : translate + rerank if a backend is available, else off * - 'off' : pure embeddings, no LLM at all (default if no key) * - 'translate' : just rewrite the query * - 'rerank' : embedding search, then rerank top-N * - 'expand+rerank' : split query into 2-4 subqueries, merge, then rerank */ llm?: LlmStrategy; } export interface SearchHit { projectPath: string; projectName: string; sourceType: SourceType; sourceKind: SourceKind; sourcePath: string | null; sourceLine: number | null; sourceAnchor: string | null; sourceName: string | null; sourceText: string; distance: number; rank: number; } /** * Side-channel info about which LLM stages ran during a search and whether * they succeeded. Useful for the user/AI to know if translate/rerank actually * fired or silently fell back to embeddings-only. */ export interface SearchTelemetry { translateRan: boolean; translateFailed: boolean; expandRan: boolean; expandFailed: boolean; rerankRan: boolean; rerankFailed: boolean; queriesUsed: string[]; /** Optional human-readable error from the last LLM failure. */ lastError?: string; } export interface SearchResultWithTelemetry { hits: SearchHit[]; telemetry: SearchTelemetry; } export interface EmbeddingStatus { moduleLoaded: boolean; modelId: string | null; enabledProjects: number; totalEmbeddings: number; storageBytes: number; } export interface MigrateOptions { fromModel: string; toModel: string; /** If true: actually perform migration. Default: dry-run. */ apply?: boolean; } export interface MigrationResult { applied: boolean; projectsAffected: number; embeddingsAffected: number; } export interface EmbeddingsModule { /** Whether embeddings are enabled for this project. Cheap; safe to call often. */ isEnabled(projectPath: string): boolean; /** Enable embeddings for a project. Triggers lazy-load of the real module + model. */ enable(projectPath: string, opts?: EnableOptions): Promise; /** (Re-)index a whole project. Skips items whose content hash hasn't changed. */ indexProject(projectPath: string, opts?: IndexOptions): Promise; /** Update embeddings for a single source file (hash-diffed). */ updateFile(projectPath: string, filePath: string): Promise; /** Drop embeddings for a single source file. */ removeFile(projectPath: string, filePath: string): Promise; /** Hook called after a task changes (create/update/log). */ onTaskChanged(projectPath: string, taskId: number): Promise; /** Hook called after a session note changes (write/append/clear/archive). */ onNoteChanged(projectPath: string, noteId?: string): Promise; /** Search embeddings. */ search(opts: SearchOptions): Promise; /** Search and return telemetry about which LLM stages fired. */ searchWithTelemetry(opts: SearchOptions): Promise; /** Status overview. */ status(projectPath?: string): Promise; /** Migrate embeddings between models. */ migrate(opts: MigrateOptions): Promise; } /** * Returns a stable handle to the embeddings module. * * The handle delegates every call to the current internal instance, so * after `enable()` swaps the stub for the real module, callers that cached * the handle automatically see the upgrade — no need to re-fetch. */ export declare function getEmbeddings(): EmbeddingsModule; /** Test helper: reset the singleton. Not part of the stable API. */ export declare function _resetEmbeddings(): void; export { DEFAULT_MODEL_ID, MODEL_REGISTRY, listModels } from './model-registry.js'; //# sourceMappingURL=index.d.ts.map