/** * Long-lived singleton that owns asynchronous embedding generation for memories. * Registered by the basic-capabilities bundle; it listens for * EMBEDDING_GENERATION_REQUESTED events and drains a priority `BatchQueue` on the * task scheduler, embedding each memory's text and writing the vector back via * `updateMemory`. When a TEXT_EMBEDDING_BATCH model is registered it collapses a * per-turn embed burst into one round-trip, falling back per-item on any batch * failure. Without a model it waits without a drain task, then activates when * an embedding handler registers, including handlers installed after boot. A * failed activation is withdrawn, so the next registration retries it. */ import type { IAgentRuntime } from "../types/runtime.js"; import { Service } from "../types/service.js"; export declare class EmbeddingGenerationService extends Service { static serviceType: string; capabilityDescription: string; private batchQueue; private readonly pending; private isDisabled; private stopped; private initialization; private readonly embeddingRequestHandler; private readonly messageSentHandler; private queueDeliveredReply; private readonly modelRegistrationHandler; private static readonly EMBEDDING_DRAIN_TASK; static start(runtime: IAgentRuntime): Promise; initialize(): Promise; private initializeQueue; private handleEmbeddingRequest; private generateEmbedding; /** * Persist a generated vector to its memory and emit the completion event. * Shared by the per-item ({@link generateEmbedding}) and batched * ({@link generateEmbeddingsBatch}) paths so write-back is identical. */ private persistEmbedding; /** * Batched drain path: embed every queued text in ONE TEXT_EMBEDDING_BATCH * round-trip, then write each vector back to its own memory id. * * Returns a {@link BatchItemOutcome} per item so the queue applies its normal * retry / `onExhausted` accounting. Items with no text or an already-present * vector are skipped (counted as success — nothing to do). If the single * batch model call throws, this throws too, which makes `BatchQueue.drain` * fall the WHOLE slice back to the per-item {@link generateEmbedding} path — * preserving the per-item fallback and per-id write-back guarantees. */ private generateEmbeddingsBatch; stop(): Promise; getQueueSize(): number; getQueueStats(): { high: number; normal: number; low: number; total: number; }; clearQueue(): void; } export default EmbeddingGenerationService;