@anuma/sdk 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4248,6 +4248,37 @@ declare function getConversationsByProjectLazyOp(ctx: StorageOperationsContext,
4248
4248
  declare function upsertMessageOp(ctx: StorageOperationsContext, opts: CreateMessageOptions & {
4249
4249
  uniqueId: string;
4250
4250
  }): Promise<StoredMessage>;
4251
+ /**
4252
+ * Decrypted, model-native chunk vectors for one message, cached across recall
4253
+ * calls so the chunk lane doesn't re-decrypt + re-JSON.parse every message's
4254
+ * embeddings on every query. Keyed by message id; `version` is the message's
4255
+ * `updated_at` at cache time, so a re-embed (which bumps `updated_at`) misses
4256
+ * and repopulates. Vectors are stored Float32 — model-native precision, half
4257
+ * the RAM of float64 `number[]` — mirroring the vault embedding cache (#705).
4258
+ * Content text is deliberately NOT cached (see searchChunksOp): it isn't
4259
+ * needed for scoring, and keeping decrypted content out of the cache preserves
4260
+ * the SDK's data-at-rest posture.
4261
+ */
4262
+ interface CachedChunkVectors {
4263
+ /** Message `updated_at` (ms) at cache time — the invalidation token. */
4264
+ version: number;
4265
+ /**
4266
+ * Per-chunk embedding vectors, index-aligned with the message's decrypted
4267
+ * `chunks` array (empty-vector chunks kept as zero-length placeholders so
4268
+ * indices stay aligned). Empty when the message has only a whole-message
4269
+ * `fallback` vector.
4270
+ */
4271
+ chunks: Float32Array[];
4272
+ /** Whole-message vector when the message was embedded without chunking. */
4273
+ fallback?: Float32Array;
4274
+ }
4275
+ /**
4276
+ * Cache consumed by {@link searchChunksOp}, keyed by message id. A plain `Map`
4277
+ * (satisfied by the LRU from `createChunkVectorCache`) — mirrors
4278
+ * `VaultEmbeddingCache` so consumers get the same `clear()`/`delete()`
4279
+ * ergonomics on an encryption-key reset.
4280
+ */
4281
+ type ChunkVectorCache = Map<string, CachedChunkVectors>;
4251
4282
 
4252
4283
  declare const chatStorageSchema: Readonly<{
4253
4284
  version: _nozbe_watermelondb_Schema.SchemaVersion;
@@ -5047,6 +5078,14 @@ interface RecallOptions {
5047
5078
  * resolves windows in 2026 and never overlaps stored event_time.
5048
5079
  */
5049
5080
  now?: number;
5081
+ /**
5082
+ * Best-effort observability hook. Called once per `recall()` with per-lane
5083
+ * timings, lane counts, and soft-degradation signals — the raw material for
5084
+ * tuning latency/quality and for wiring recall telemetry to PostHog. Invoked
5085
+ * synchronously just before `recall()` returns; a throwing callback is
5086
+ * swallowed (diagnostics must never break retrieval). Off unless provided.
5087
+ */
5088
+ onDiagnostics?: (diagnostics: RecallDiagnostics) => void;
5050
5089
  /** Number of candidates fed to the cross-encoder rerank stage. Default: 30. */
5051
5090
  rerankTopN?: number;
5052
5091
  /** Multiplicative cross-encoder blend weight. Default: 0.1. */
@@ -5077,6 +5116,12 @@ interface RecallContext {
5077
5116
  embeddingOptions: EmbeddingOptions;
5078
5117
  /** Vault embedding LRU cache. */
5079
5118
  vaultCache?: VaultEmbeddingCache;
5119
+ /**
5120
+ * Optional chunk-vector LRU cache. When provided, the chunk lane skips the
5121
+ * per-query decrypt + JSON.parse of every message's chunk vectors on warm
5122
+ * entries. Build via `createChunkVectorCache`. Omit for legacy behavior.
5123
+ */
5124
+ chunkCache?: ChunkVectorCache;
5080
5125
  /**
5081
5126
  * Optional — when provided, recall extracts entities from the query
5082
5127
  * and adds a graph lane to the RRF fusion (memories sharing entities
@@ -5096,6 +5141,48 @@ interface RecallResult {
5096
5141
  /** Diagnostic: total memories in the vault when fact lane was queried. */
5097
5142
  vaultSize?: number;
5098
5143
  }
5144
+ /** Soft-degradation signals surfaced via {@link RecallDiagnostics.degraded}. */
5145
+ type RecallDegradation =
5146
+ /** Rerank was requested (budget mid/high) but the cross-encoder didn't run
5147
+ * this call — unavailable (e.g. React Native) or a transient failure. */
5148
+ "rerank-unavailable"
5149
+ /** `budget: 'high'` requested but no `decomposeOptions`, so query
5150
+ * decomposition was skipped and the budget downgraded to mid. */
5151
+ | "decompose-unavailable";
5152
+ /**
5153
+ * Per-call recall observability payload (see {@link RecallOptions.onDiagnostics}).
5154
+ * All timings are wall-clock milliseconds. Lane counts are post-dedupe,
5155
+ * pre-fusion. Intended to be forwarded to a metrics sink (e.g. PostHog).
5156
+ */
5157
+ interface RecallDiagnostics {
5158
+ /** Budget actually executed (may have downgraded from the requested one). */
5159
+ usedBudget: Budget;
5160
+ /** Whether the cross-encoder actually reranked the fact lane this call. */
5161
+ reranked: boolean;
5162
+ /** Total candidates considered before truncation. */
5163
+ candidateCount: number;
5164
+ /** Total vault size when the fact lane ran (absent if it didn't). */
5165
+ vaultSize?: number;
5166
+ /** Facts the fact lane returned (post-dedupe, pre-fusion). */
5167
+ factCount: number;
5168
+ /** Chunks the chunk lane returned (post-dedupe, pre-fusion). */
5169
+ chunkCount: number;
5170
+ /** Wall-clock phase timings (ms). */
5171
+ timings: {
5172
+ /** Whole `recall()` call. */
5173
+ total: number;
5174
+ /** Parallel query-embed + graph/temporal side-lane build. */
5175
+ prep: number;
5176
+ /** Vault fact-lane search (`searchVaultMemoriesWithSize`). */
5177
+ factLane: number;
5178
+ /** Chunk-lane search (`searchChunksOp`). */
5179
+ chunkLane: number;
5180
+ /** Cross-lane RRF fusion + provenance dedup after both lanes. */
5181
+ fuse: number;
5182
+ };
5183
+ /** Soft-degradation signals that fired this call (empty when clean). */
5184
+ degraded: RecallDegradation[];
5185
+ }
5099
5186
  type RetainAction = "create" | "merge" | "update" | "skip" | "suppressed";
5100
5187
  type RetainSource = "manual" | "auto-extracted" | "capsule";
5101
5188
  /** Why the consolidator fell back to "create" instead of a real decision. */
@@ -5664,6 +5751,24 @@ interface AutoExtractor {
5664
5751
  */
5665
5752
  declare function createAutoExtractor(options: CreateAutoExtractorOptions): AutoExtractor;
5666
5753
 
5754
+ /**
5755
+ * Default entry cap for the chunk-vector cache. Entries are keyed by message
5756
+ * id, so this bounds how many messages' decrypted chunk vectors stay resident.
5757
+ * Matches the vault cache default (#705).
5758
+ */
5759
+ declare const DEFAULT_CHUNK_CACHE_SIZE = 5000;
5760
+ /**
5761
+ * Create a {@link ChunkVectorCache} backed by an LRU. Pass the returned cache
5762
+ * into `recall()` (via `RecallContext.chunkCache`) so the chunk lane skips the
5763
+ * per-query decrypt + JSON.parse of every message's chunk vectors on warm
5764
+ * entries. Stale entries self-invalidate on `updated_at` mismatch, so no
5765
+ * explicit invalidation is required beyond clearing it on an encryption-key
5766
+ * reset (wallet switch), mirroring the vault embedding cache.
5767
+ *
5768
+ * @public
5769
+ */
5770
+ declare function createChunkVectorCache(maxSize?: number): ChunkVectorCache;
5771
+
5667
5772
  /**
5668
5773
  * Unified Recall API — single retrieval surface above vault + engine.
5669
5774
  *
@@ -5816,6 +5921,46 @@ interface ReflectResult {
5816
5921
  */
5817
5922
  declare function reflect(query: string, ctx: RecallContext, options: ReflectOptions): Promise<ReflectResult>;
5818
5923
 
5924
+ /**
5925
+ * Cross-encoder reranker — local inference via @huggingface/transformers.
5926
+ *
5927
+ * Mirrors Hindsight's default reranker (`cross-encoder/ms-marco-MiniLM-L-6-v2`)
5928
+ * for parity with their reference pipeline. Runs fully on-device — no API
5929
+ * key, no network call, works offline. Model file ~25MB; lazy-loaded and
5930
+ * cached for the lifetime of the process.
5931
+ *
5932
+ * Implementation note: transformers.js v3 doesn't expose a "text-ranking"
5933
+ * pipeline, so we drive the cross-encoder directly via the tokenizer +
5934
+ * sequence-classification model. The model outputs a single relevance
5935
+ * logit per (query, doc) pair; we sigmoid it into [0, 1].
5936
+ */
5937
+ /**
5938
+ * Thrown when the cross-encoder cannot run because its optional peer
5939
+ * dependency (`@huggingface/transformers`) isn't installed — the expected
5940
+ * state on React Native, where the package isn't part of the bundle. Callers
5941
+ * treat this as "reranker unavailable, degrade to the fused ranking" rather
5942
+ * than a transient error worth warning about on every recall.
5943
+ *
5944
+ * @public
5945
+ */
5946
+ declare class RerankerUnavailableError extends Error {
5947
+ /** The underlying import failure, kept for debugging. */
5948
+ readonly reason: unknown;
5949
+ constructor(reason: unknown);
5950
+ }
5951
+ /**
5952
+ * Whether the cross-encoder reranker can run in this environment.
5953
+ *
5954
+ * - `true` — the model loaded successfully at least once.
5955
+ * - `false` — the optional `@huggingface/transformers` dependency is missing
5956
+ * (e.g. React Native); reranking is permanently degraded to the fused
5957
+ * ranking and no further load attempts are made.
5958
+ * - `undefined` — no rerank has been attempted yet, so availability is unknown.
5959
+ *
5960
+ * @public
5961
+ */
5962
+ declare function isRerankerAvailable(): boolean | undefined;
5963
+
5819
5964
  /**
5820
5965
  * Standalone topic (entity) extraction for EXISTING memories.
5821
5966
  *
@@ -7190,4 +7335,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
7190
7335
  */
7191
7336
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
7192
7337
 
7193
- export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
7338
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
@@ -4248,6 +4248,37 @@ declare function getConversationsByProjectLazyOp(ctx: StorageOperationsContext,
4248
4248
  declare function upsertMessageOp(ctx: StorageOperationsContext, opts: CreateMessageOptions & {
4249
4249
  uniqueId: string;
4250
4250
  }): Promise<StoredMessage>;
4251
+ /**
4252
+ * Decrypted, model-native chunk vectors for one message, cached across recall
4253
+ * calls so the chunk lane doesn't re-decrypt + re-JSON.parse every message's
4254
+ * embeddings on every query. Keyed by message id; `version` is the message's
4255
+ * `updated_at` at cache time, so a re-embed (which bumps `updated_at`) misses
4256
+ * and repopulates. Vectors are stored Float32 — model-native precision, half
4257
+ * the RAM of float64 `number[]` — mirroring the vault embedding cache (#705).
4258
+ * Content text is deliberately NOT cached (see searchChunksOp): it isn't
4259
+ * needed for scoring, and keeping decrypted content out of the cache preserves
4260
+ * the SDK's data-at-rest posture.
4261
+ */
4262
+ interface CachedChunkVectors {
4263
+ /** Message `updated_at` (ms) at cache time — the invalidation token. */
4264
+ version: number;
4265
+ /**
4266
+ * Per-chunk embedding vectors, index-aligned with the message's decrypted
4267
+ * `chunks` array (empty-vector chunks kept as zero-length placeholders so
4268
+ * indices stay aligned). Empty when the message has only a whole-message
4269
+ * `fallback` vector.
4270
+ */
4271
+ chunks: Float32Array[];
4272
+ /** Whole-message vector when the message was embedded without chunking. */
4273
+ fallback?: Float32Array;
4274
+ }
4275
+ /**
4276
+ * Cache consumed by {@link searchChunksOp}, keyed by message id. A plain `Map`
4277
+ * (satisfied by the LRU from `createChunkVectorCache`) — mirrors
4278
+ * `VaultEmbeddingCache` so consumers get the same `clear()`/`delete()`
4279
+ * ergonomics on an encryption-key reset.
4280
+ */
4281
+ type ChunkVectorCache = Map<string, CachedChunkVectors>;
4251
4282
 
4252
4283
  declare const chatStorageSchema: Readonly<{
4253
4284
  version: _nozbe_watermelondb_Schema.SchemaVersion;
@@ -5047,6 +5078,14 @@ interface RecallOptions {
5047
5078
  * resolves windows in 2026 and never overlaps stored event_time.
5048
5079
  */
5049
5080
  now?: number;
5081
+ /**
5082
+ * Best-effort observability hook. Called once per `recall()` with per-lane
5083
+ * timings, lane counts, and soft-degradation signals — the raw material for
5084
+ * tuning latency/quality and for wiring recall telemetry to PostHog. Invoked
5085
+ * synchronously just before `recall()` returns; a throwing callback is
5086
+ * swallowed (diagnostics must never break retrieval). Off unless provided.
5087
+ */
5088
+ onDiagnostics?: (diagnostics: RecallDiagnostics) => void;
5050
5089
  /** Number of candidates fed to the cross-encoder rerank stage. Default: 30. */
5051
5090
  rerankTopN?: number;
5052
5091
  /** Multiplicative cross-encoder blend weight. Default: 0.1. */
@@ -5077,6 +5116,12 @@ interface RecallContext {
5077
5116
  embeddingOptions: EmbeddingOptions;
5078
5117
  /** Vault embedding LRU cache. */
5079
5118
  vaultCache?: VaultEmbeddingCache;
5119
+ /**
5120
+ * Optional chunk-vector LRU cache. When provided, the chunk lane skips the
5121
+ * per-query decrypt + JSON.parse of every message's chunk vectors on warm
5122
+ * entries. Build via `createChunkVectorCache`. Omit for legacy behavior.
5123
+ */
5124
+ chunkCache?: ChunkVectorCache;
5080
5125
  /**
5081
5126
  * Optional — when provided, recall extracts entities from the query
5082
5127
  * and adds a graph lane to the RRF fusion (memories sharing entities
@@ -5096,6 +5141,48 @@ interface RecallResult {
5096
5141
  /** Diagnostic: total memories in the vault when fact lane was queried. */
5097
5142
  vaultSize?: number;
5098
5143
  }
5144
+ /** Soft-degradation signals surfaced via {@link RecallDiagnostics.degraded}. */
5145
+ type RecallDegradation =
5146
+ /** Rerank was requested (budget mid/high) but the cross-encoder didn't run
5147
+ * this call — unavailable (e.g. React Native) or a transient failure. */
5148
+ "rerank-unavailable"
5149
+ /** `budget: 'high'` requested but no `decomposeOptions`, so query
5150
+ * decomposition was skipped and the budget downgraded to mid. */
5151
+ | "decompose-unavailable";
5152
+ /**
5153
+ * Per-call recall observability payload (see {@link RecallOptions.onDiagnostics}).
5154
+ * All timings are wall-clock milliseconds. Lane counts are post-dedupe,
5155
+ * pre-fusion. Intended to be forwarded to a metrics sink (e.g. PostHog).
5156
+ */
5157
+ interface RecallDiagnostics {
5158
+ /** Budget actually executed (may have downgraded from the requested one). */
5159
+ usedBudget: Budget;
5160
+ /** Whether the cross-encoder actually reranked the fact lane this call. */
5161
+ reranked: boolean;
5162
+ /** Total candidates considered before truncation. */
5163
+ candidateCount: number;
5164
+ /** Total vault size when the fact lane ran (absent if it didn't). */
5165
+ vaultSize?: number;
5166
+ /** Facts the fact lane returned (post-dedupe, pre-fusion). */
5167
+ factCount: number;
5168
+ /** Chunks the chunk lane returned (post-dedupe, pre-fusion). */
5169
+ chunkCount: number;
5170
+ /** Wall-clock phase timings (ms). */
5171
+ timings: {
5172
+ /** Whole `recall()` call. */
5173
+ total: number;
5174
+ /** Parallel query-embed + graph/temporal side-lane build. */
5175
+ prep: number;
5176
+ /** Vault fact-lane search (`searchVaultMemoriesWithSize`). */
5177
+ factLane: number;
5178
+ /** Chunk-lane search (`searchChunksOp`). */
5179
+ chunkLane: number;
5180
+ /** Cross-lane RRF fusion + provenance dedup after both lanes. */
5181
+ fuse: number;
5182
+ };
5183
+ /** Soft-degradation signals that fired this call (empty when clean). */
5184
+ degraded: RecallDegradation[];
5185
+ }
5099
5186
  type RetainAction = "create" | "merge" | "update" | "skip" | "suppressed";
5100
5187
  type RetainSource = "manual" | "auto-extracted" | "capsule";
5101
5188
  /** Why the consolidator fell back to "create" instead of a real decision. */
@@ -5664,6 +5751,24 @@ interface AutoExtractor {
5664
5751
  */
5665
5752
  declare function createAutoExtractor(options: CreateAutoExtractorOptions): AutoExtractor;
5666
5753
 
5754
+ /**
5755
+ * Default entry cap for the chunk-vector cache. Entries are keyed by message
5756
+ * id, so this bounds how many messages' decrypted chunk vectors stay resident.
5757
+ * Matches the vault cache default (#705).
5758
+ */
5759
+ declare const DEFAULT_CHUNK_CACHE_SIZE = 5000;
5760
+ /**
5761
+ * Create a {@link ChunkVectorCache} backed by an LRU. Pass the returned cache
5762
+ * into `recall()` (via `RecallContext.chunkCache`) so the chunk lane skips the
5763
+ * per-query decrypt + JSON.parse of every message's chunk vectors on warm
5764
+ * entries. Stale entries self-invalidate on `updated_at` mismatch, so no
5765
+ * explicit invalidation is required beyond clearing it on an encryption-key
5766
+ * reset (wallet switch), mirroring the vault embedding cache.
5767
+ *
5768
+ * @public
5769
+ */
5770
+ declare function createChunkVectorCache(maxSize?: number): ChunkVectorCache;
5771
+
5667
5772
  /**
5668
5773
  * Unified Recall API — single retrieval surface above vault + engine.
5669
5774
  *
@@ -5816,6 +5921,46 @@ interface ReflectResult {
5816
5921
  */
5817
5922
  declare function reflect(query: string, ctx: RecallContext, options: ReflectOptions): Promise<ReflectResult>;
5818
5923
 
5924
+ /**
5925
+ * Cross-encoder reranker — local inference via @huggingface/transformers.
5926
+ *
5927
+ * Mirrors Hindsight's default reranker (`cross-encoder/ms-marco-MiniLM-L-6-v2`)
5928
+ * for parity with their reference pipeline. Runs fully on-device — no API
5929
+ * key, no network call, works offline. Model file ~25MB; lazy-loaded and
5930
+ * cached for the lifetime of the process.
5931
+ *
5932
+ * Implementation note: transformers.js v3 doesn't expose a "text-ranking"
5933
+ * pipeline, so we drive the cross-encoder directly via the tokenizer +
5934
+ * sequence-classification model. The model outputs a single relevance
5935
+ * logit per (query, doc) pair; we sigmoid it into [0, 1].
5936
+ */
5937
+ /**
5938
+ * Thrown when the cross-encoder cannot run because its optional peer
5939
+ * dependency (`@huggingface/transformers`) isn't installed — the expected
5940
+ * state on React Native, where the package isn't part of the bundle. Callers
5941
+ * treat this as "reranker unavailable, degrade to the fused ranking" rather
5942
+ * than a transient error worth warning about on every recall.
5943
+ *
5944
+ * @public
5945
+ */
5946
+ declare class RerankerUnavailableError extends Error {
5947
+ /** The underlying import failure, kept for debugging. */
5948
+ readonly reason: unknown;
5949
+ constructor(reason: unknown);
5950
+ }
5951
+ /**
5952
+ * Whether the cross-encoder reranker can run in this environment.
5953
+ *
5954
+ * - `true` — the model loaded successfully at least once.
5955
+ * - `false` — the optional `@huggingface/transformers` dependency is missing
5956
+ * (e.g. React Native); reranking is permanently degraded to the fused
5957
+ * ranking and no further load attempts are made.
5958
+ * - `undefined` — no rerank has been attempted yet, so availability is unknown.
5959
+ *
5960
+ * @public
5961
+ */
5962
+ declare function isRerankerAvailable(): boolean | undefined;
5963
+
5819
5964
  /**
5820
5965
  * Standalone topic (entity) extraction for EXISTING memories.
5821
5966
  *
@@ -7190,4 +7335,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
7190
7335
  */
7191
7336
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
7192
7337
 
7193
- export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
7338
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
@@ -6,6 +6,8 @@ import {
6
6
  DEFAULT_MIN_CONTENT_LENGTH,
7
7
  DEFAULT_VAULT_CACHE_SIZE,
8
8
  ENTITY_KINDS,
9
+ LRUCache,
10
+ RerankerUnavailableError,
9
11
  chunkAndEmbedAllMessages,
10
12
  chunkAndEmbedMessage,
11
13
  chunkText,
@@ -58,6 +60,7 @@ import {
58
60
  getVaultMemoryOp,
59
61
  hasEncryptionKey,
60
62
  isEncrypted,
63
+ isRerankerAvailable,
61
64
  linkMemoryEntitiesOp,
62
65
  makeSyntheticStoredConversation,
63
66
  makeSyntheticStoredMessage,
@@ -83,7 +86,7 @@ import {
83
86
  upsertMessageOp,
84
87
  useEncryption,
85
88
  vaultMemoryToStored
86
- } from "./chunk-SF5AYTXH.mjs";
89
+ } from "./chunk-UOUJUZM4.mjs";
87
90
  import {
88
91
  PII_PATTERNS,
89
92
  PiiRedactor,
@@ -6598,6 +6601,12 @@ function createAutoExtractor(options) {
6598
6601
  };
6599
6602
  }
6600
6603
 
6604
+ // src/lib/memory/chunkVectorCache.ts
6605
+ var DEFAULT_CHUNK_CACHE_SIZE = 5e3;
6606
+ function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
6607
+ return new LRUCache(maxSize);
6608
+ }
6609
+
6601
6610
  // src/lib/memory/recallTool.ts
6602
6611
  var RECALL_TOOL_NAME = "recall_memory";
6603
6612
  var RECALL_MAX_LIMIT = 50;
@@ -8209,6 +8218,13 @@ function useChatStorage(options) {
8209
8218
  [vaultCtx]
8210
8219
  );
8211
8220
  const vaultEmbeddingCacheRef = useRef4(createVaultEmbeddingCache());
8221
+ const chunkVectorCacheRef = useRef4(createChunkVectorCache());
8222
+ useEffect4(() => {
8223
+ return onClearAllEncryptionState(() => {
8224
+ vaultEmbeddingCacheRef.current.clear();
8225
+ chunkVectorCacheRef.current.clear();
8226
+ });
8227
+ }, []);
8212
8228
  const createRecallTool2 = useCallback4(
8213
8229
  (toolOptions, callbacks) => {
8214
8230
  if (!getToken) {
@@ -8225,7 +8241,8 @@ function useChatStorage(options) {
8225
8241
  model: embeddingModel,
8226
8242
  maskInput: maskEmbeddingInput
8227
8243
  },
8228
- vaultCache: vaultEmbeddingCacheRef.current
8244
+ vaultCache: vaultEmbeddingCacheRef.current,
8245
+ chunkCache: chunkVectorCacheRef.current
8229
8246
  // entityCtx is intentionally omitted on Expo for now — the
8230
8247
  // W5 graph lane is a no-op without it (recall falls through
8231
8248
  // to fact + chunk lanes). Wire it up when the Expo client
@@ -8267,7 +8284,8 @@ function useChatStorage(options) {
8267
8284
  model: embeddingModel,
8268
8285
  maskInput: maskEmbeddingInput
8269
8286
  },
8270
- vaultCache: vaultEmbeddingCacheRef.current
8287
+ vaultCache: vaultEmbeddingCacheRef.current,
8288
+ chunkCache: chunkVectorCacheRef.current
8271
8289
  },
8272
8290
  resolvedOptions
8273
8291
  );
@@ -11587,6 +11605,7 @@ export {
11587
11605
  Message as ChatMessage,
11588
11606
  ConversationMemory as ConversationMemoryModel,
11589
11607
  DEFAULT_CACHE_EXPIRATION_MS,
11608
+ DEFAULT_CHUNK_CACHE_SIZE,
11590
11609
  DEFAULT_CHUNK_OVERLAP,
11591
11610
  DEFAULT_CHUNK_SIZE,
11592
11611
  DEFAULT_MIN_CHUNK_SIZE,
@@ -11600,6 +11619,7 @@ export {
11600
11619
  QueueManager,
11601
11620
  RECALL_MAX_LIMIT,
11602
11621
  RECALL_TOOL_NAME,
11622
+ RerankerUnavailableError,
11603
11623
  SDK_SCHEMA_VERSION,
11604
11624
  STREAM_RESUMABLE_HEADER,
11605
11625
  VaultFolder as StoredVaultFolderModel,
@@ -11632,6 +11652,7 @@ export {
11632
11652
  conversationMemoryToStored,
11633
11653
  cosineInt8,
11634
11654
  createAutoExtractor,
11655
+ createChunkVectorCache,
11635
11656
  createCryptoPricePreProcessor,
11636
11657
  createMemoryEngineTool,
11637
11658
  createMemoryVaultSearchTool,
@@ -11681,6 +11702,7 @@ export {
11681
11702
  getVaultMemoryOp,
11682
11703
  hasEncryptionKey,
11683
11704
  isPiiRedactor,
11705
+ isRerankerAvailable,
11684
11706
  moveMemoriesToFolderOp,
11685
11707
  noopLogger,
11686
11708
  onKeyAvailable,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-SF5AYTXH.mjs";
3
+ } from "./chunk-UOUJUZM4.mjs";
4
4
  import "./chunk-DFVCS3QQ.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {