import type { IDatabaseAdapter } from "../types/database.js"; import type { Memory } from "../types/memory.js"; import { type ModelTypeName } from "../types/model.js"; import type { UUID } from "../types/primitives.js"; import type { IAgentRuntime } from "../types/runtime.js"; import { type ResolvedModelRegistration } from "./model-policy.js"; /** One failed TEXT_EMBEDDING dimension-probe attempt, kept for diagnostics. */ export interface EmbeddingProbeAttempt { provider: string; modelKey: string; error: string; } /** Providers that satisfy the app's explicit on-device embedding contract. */ export declare const LOCAL_EMBEDDING_PROVIDERS: Set; /** Pins the embedder identity for each agent. Equal vector dimensions do not imply compatible spaces; changing models requires an explicitly acknowledged fresh index. */ export declare const EMBEDDING_STORE_IDENTITY_CACHE_KEY = "embedding:store-identity"; export declare const EMBEDDING_STORE_ACCEPT_MODEL_SETTING = "ELIZA_EMBEDDING_STORE_ACCEPT_MODEL"; export interface EmbeddingStoreIdentity { provider: string; modelLabel: string | null; dimension: number; recordedAt: string; } /** Carries every failed provider probe so initialization can expose disabled embeddings without dropping memory writes. */ export declare class EmbeddingDimensionProbeError extends Error { readonly attempts: readonly EmbeddingProbeAttempt[]; constructor(attempts: readonly EmbeddingProbeAttempt[]); } export declare class RuntimeEmbeddings { private readonly runtime; private readonly host; /** Resolve provider-owned model identity without reading another provider's settings. */ private embeddingModelLabelForRegistration; /** Resolve and validate identity before changing the active adapter width. */ private prepareEmbeddingStoreIdentity; constructor(runtime: IAgentRuntime, host: { resolveModelRegistrations(modelType: ModelTypeName | string, provider?: string): ResolvedModelRegistration[]; }); private pinnedEmbeddingSpace; private pinnedEmbeddingDimension; validateProviderOutput(modelType: string, params: unknown, embeddingProviderOutput: unknown, result: unknown, provider: string, signal?: AbortSignal): Promise; getPinnedProvider(): string | undefined; /** * Provider that answered the boot-time TEXT_EMBEDDING dimension probe. The * SQL adapter's vector column is sized from that provider's output, so all * later embedding calls without an explicit provider are pinned to it — * letting a different registration serve an embedding call can emit a * different-width vector that the adapter silently drops on dimension * mismatch. Re-set on every successful `ensureEmbeddingDimension`. */ private pinnedEmbeddingProvider; /** * Non-null while embedding generation is disabled because every registered * TEXT_EMBEDDING provider failed the dimension probe. While set, memory * writes skip vector generation entirely (see `addEmbeddingToMemory` / * `queueEmbeddingGeneration`) instead of producing vectors the SQL adapter * would silently drop against a default-sized column. Cleared by the next * successful `ensureEmbeddingDimension` (e.g. the deferred boot re-probe). */ private embeddingGenerationDisabledReason; /** Once a width or identity change starts, only confirmed initialization can publish vectors again. */ private embeddingStoreTransition; /** Once-latch so the embedding-skip warning fires once, not per write. */ private embeddingSkipWarned; /** * True when probing disabled generation or a store transition is unconfirmed. * While true, memory * writes persist without vectors (recall over new memories is degraded) * rather than emitting vectors the SQL adapter would silently drop against * a default-sized column. Cleared by the next successful * {@link ensureEmbeddingDimension} (e.g. the deferred boot re-probe). */ isEmbeddingGenerationDisabled(): boolean; disableEmbeddingGeneration(reason: string): void; enableEmbeddingGeneration(): void; /** * Once-latch warn for skipped embedding generation: the first skipped write * logs a structured warning, subsequent skips stay quiet until the flag is * cleared and re-set (a fresh degradation event warns again). */ warnEmbeddingGenerationSkipped(): void; private embeddingInitialization; ensureEmbeddingDimension(): Promise; private initializeEmbeddingDimension; addEmbeddingToMemory(memory: Memory): Promise; /** * Re-embed the given memories at the active embedding dimension after their * stale-dimension vectors were reclaimed. Runs detached from boot and drains * through the embedding queue at `low` priority so live traffic is never * starved. Fetched in chunks so a large migration never loads every memory at * once; a chunk failure is reported and the rest still proceed. */ reembedMemoriesByIds(memoryIds: UUID[]): Promise; /** * Queue embedding work through the registered event handlers without blocking * the memory write that requested it. */ queueEmbeddingGeneration(memory: Memory, priority?: "high" | "normal" | "low"): Promise; clearEmbeddingsOutsideActiveDimension(): Promise; getCachedEmbeddings(params: Parameters[0]): ReturnType; }