@anuma/sdk 6.16.0 → 6.17.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.
@@ -9749,6 +9749,7 @@ __export(index_exports, {
9749
9749
  isDegradedTopicSkip: () => isDegradedTopicSkip,
9750
9750
  isPiiRedactor: () => isPiiRedactor,
9751
9751
  isRerankerAvailable: () => isRerankerAvailable,
9752
+ maskScopedEmbeddingCache: () => maskScopedEmbeddingCache,
9752
9753
  moveMemoriesToFolderOp: () => moveMemoriesToFolderOp,
9753
9754
  noopLogger: () => noopLogger,
9754
9755
  onKeyAvailable: () => onKeyAvailable,
@@ -13485,6 +13486,28 @@ var xhrTransport = (options) => {
13485
13486
  return { stream: createStream() };
13486
13487
  };
13487
13488
 
13489
+ // src/lib/db/chat/embeddingCache.ts
13490
+ var MaskScopedEmbeddingCache = class extends Map {
13491
+ constructor(inner, masked) {
13492
+ super();
13493
+ this.inner = inner;
13494
+ this.masked = masked;
13495
+ }
13496
+ key(text12) {
13497
+ return `${this.masked ? "m" : "r"}:${text12}`;
13498
+ }
13499
+ get(text12) {
13500
+ return this.inner.get(this.key(text12));
13501
+ }
13502
+ set(text12, value) {
13503
+ this.inner.set(this.key(text12), value);
13504
+ return this;
13505
+ }
13506
+ };
13507
+ function maskScopedEmbeddingCache(cache, masked) {
13508
+ return new MaskScopedEmbeddingCache(cache, masked);
13509
+ }
13510
+
13488
13511
  // src/react/useCredits.ts
13489
13512
  var import_react = require("react");
13490
13513
  init_sdk_gen();
@@ -20182,12 +20205,14 @@ var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
20182
20205
  };
20183
20206
  var SERVER_TOOL_DEPENDENCY_SETS = [
20184
20207
  {
20185
- // search finds links; reading them is always the next step.
20186
- name: "jina-research",
20208
+ // search finds links; reading them is always the next step. The reader now
20209
+ // lives on the search server — Jina's read_url / parallel_read_url were
20210
+ // removed in favour of anuma_scrape_url, which takes a batch of URLs — so
20211
+ // this edge deliberately spans two MCP servers.
20212
+ name: "web-research",
20187
20213
  members: [
20188
20214
  "AnumaJinaMCP-search_web",
20189
- "AnumaJinaMCP-read_url",
20190
- "AnumaJinaMCP-parallel_read_url",
20215
+ "AnumaSearchMCP-anuma_scrape_url",
20191
20216
  "AnumaJinaMCP-parallel_search_web"
20192
20217
  ],
20193
20218
  anchors: ["AnumaJinaMCP-search_web"],
@@ -21091,6 +21116,7 @@ function useChatStorage(options) {
21091
21116
  summaryModel = DEFAULT_SUMMARY_MODEL,
21092
21117
  files,
21093
21118
  storedUserContent,
21119
+ embeddingCache,
21094
21120
  onData: perRequestOnData,
21095
21121
  onThinking: perRequestOnThinking,
21096
21122
  memoryContext,
@@ -21130,12 +21156,18 @@ function useChatStorage(options) {
21130
21156
  };
21131
21157
  pendingResumeRef.current = null;
21132
21158
  const effectiveAssistantUniqueId = assistantUniqueId ?? (resumable ? `msg_${(0, import_uuid5.v7)()}` : void 0);
21133
- const embedToolText = (text12, mask, token) => {
21134
- const opts = { getToken: token, baseUrl, model: embeddingModel };
21159
+ const embedToolText = (text12, mask, masked, token) => {
21160
+ const opts = {
21161
+ getToken: token,
21162
+ baseUrl,
21163
+ model: embeddingModel,
21164
+ maskInput: mask,
21165
+ cache: embeddingCache ? maskScopedEmbeddingCache(embeddingCache, masked) : void 0
21166
+ };
21135
21167
  return shouldChunkMessage(text12, DEFAULT_CHUNK_SIZE) ? generateEmbeddings(
21136
- chunkText(text12).map((c) => mask(c.text)),
21168
+ chunkText(text12).map((c) => c.text),
21137
21169
  opts
21138
- ) : generateEmbedding(mask(text12), opts);
21170
+ ) : generateEmbedding(text12, opts);
21139
21171
  };
21140
21172
  if (walletAddress && signMessage && !hasEncryptionKey(walletAddress)) {
21141
21173
  try {
@@ -21175,6 +21207,7 @@ function useChatStorage(options) {
21175
21207
  skipUserEmbedding = await embedToolText(
21176
21208
  messageContent,
21177
21209
  maskForCall2,
21210
+ Boolean(callPiiRedaction2),
21178
21211
  getTokenRef.current
21179
21212
  );
21180
21213
  const toolNames = serverToolsFilter(skipUserEmbedding, allServerTools);
@@ -21195,6 +21228,7 @@ function useChatStorage(options) {
21195
21228
  skipUserEmbedding = await embedToolText(
21196
21229
  messageContent,
21197
21230
  maskForCall2,
21231
+ Boolean(callPiiRedaction2),
21198
21232
  getTokenRef.current
21199
21233
  );
21200
21234
  } catch {
@@ -21343,7 +21377,14 @@ function useChatStorage(options) {
21343
21377
  };
21344
21378
  const embedForToolsSettled = async (token) => {
21345
21379
  try {
21346
- return { embedding: await embedToolText(contentForStorage, maskForCall, token) };
21380
+ return {
21381
+ embedding: await embedToolText(
21382
+ contentForStorage,
21383
+ maskForCall,
21384
+ Boolean(callPiiRedaction),
21385
+ token
21386
+ )
21387
+ };
21347
21388
  } catch (error) {
21348
21389
  return { error };
21349
21390
  }
@@ -24825,6 +24866,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
24825
24866
  isDegradedTopicSkip,
24826
24867
  isPiiRedactor,
24827
24868
  isRerankerAvailable,
24869
+ maskScopedEmbeddingCache,
24828
24870
  moveMemoriesToFolderOp,
24829
24871
  noopLogger,
24830
24872
  onKeyAvailable,
@@ -2755,6 +2755,38 @@ declare function resumeStream(options: ResumeStreamOptions): Promise<ResumeStrea
2755
2755
  */
2756
2756
  declare const xhrTransport: StreamingTransport;
2757
2757
 
2758
+ /**
2759
+ * Namespacing for a caller-shared embedding cache.
2760
+ *
2761
+ * Lives here, next to the `embeddingCache` send-arg it serves, rather than in either platform hook:
2762
+ * react and expo both thread the option through their own send paths, and a copy per platform is how
2763
+ * the two drift.
2764
+ */
2765
+ /**
2766
+ * Build the same namespaced view over `cache` that a send with this masking decision uses.
2767
+ *
2768
+ * REQUIRED FOR SHARING, and the reason this is exported at all. `embeddingCache`'s whole purpose is
2769
+ * that a caller who also needs the prompt vector passes one `Map` to both `sendMessage` and its own
2770
+ * `generateEmbedding` call, so the turn embeds once. But the send namespaces its entries by masking
2771
+ * decision (see {@link MaskScopedEmbeddingCache}) while `generateEmbedding` keys on the text alone —
2772
+ * so a caller handing the RAW `Map` to its own call writes `"hello"` where the send looks for
2773
+ * `"r:hello"`, and neither side ever hits. The dedupe silently does not happen.
2774
+ *
2775
+ * So: pass the plain `Map` as `embeddingCache`, and wrap it with this for your own call.
2776
+ *
2777
+ * ```ts
2778
+ * const shared = new Map<string, Float32Array>();
2779
+ * // your own ranking embed, same masking decision as the send:
2780
+ * await generateEmbedding(text, { getToken, cache: maskScopedEmbeddingCache(shared, masked) });
2781
+ * await sendMessage({ ..., embeddingCache: shared, piiRedaction: masked });
2782
+ * ```
2783
+ *
2784
+ * `masked` must match what the send resolves for the same turn — i.e. whether PII redaction is on.
2785
+ * Get it wrong and you simply miss the cache; you cannot be served the other decision's vector,
2786
+ * which is the property the namespacing exists to guarantee.
2787
+ */
2788
+ declare function maskScopedEmbeddingCache(cache: Map<string, Float32Array>, masked: boolean): Map<string, Float32Array>;
2789
+
2758
2790
  /**
2759
2791
  * @inline
2760
2792
  */
@@ -4071,6 +4103,37 @@ interface BaseSendMessageWithStorageArgs {
4071
4103
  * user content (matching a textless turn), NOT a request to fall back.
4072
4104
  */
4073
4105
  storedUserContent?: string;
4106
+ /**
4107
+ * Optional embedding cache, shared with the caller.
4108
+ *
4109
+ * Every send that needs tool selection embeds the user text once (see
4110
+ * `storedUserContent`). A caller that ALSO needs that vector — to rank tools itself, say, or to
4111
+ * hand a server a prompt-aware shortlist — otherwise pays for a second, identical embedding of
4112
+ * the same text in the same turn. Pass a `Map` here and into your own
4113
+ * `generateEmbedding`/`generateEmbeddings` call and whichever runs first fills it; the other is a
4114
+ * cache hit, so the turn embeds once.
4115
+ *
4116
+ * Keyed on the text **as passed in** (before `maskInput` is applied to the request body), prefixed
4117
+ * with a marker for this send's masking decision — `"r:"` raw, `"m:"` masked — so a mismatched
4118
+ * masking decision cannot silently serve the wrong vector: masked and unmasked occupy different
4119
+ * entries. `generateEmbedding`'s own contract is unchanged; it still keys on the text alone, and
4120
+ * the prefixing is a view this send wraps around the `Map` you hand it.
4121
+ *
4122
+ * WHICH MEANS SHARING TAKES ONE MORE STEP, and skipping it costs you the dedupe silently: pass
4123
+ * the plain `Map` here, and wrap it with `maskScopedEmbeddingCache(map, masked)` for your OWN
4124
+ * `generateEmbedding` call, so both sides look under the same key. Hand the raw `Map` to both and
4125
+ * your call writes `"hello"` while this one reads `"r:hello"` — no hit, and the second embedding
4126
+ * you were trying to avoid still happens.
4127
+ *
4128
+ * **Long messages are not deduped.** Past `DEFAULT_CHUNK_SIZE` (400 chars) the send embeds one
4129
+ * vector per chunk and keys each entry on its chunk text, so a caller that embedded the whole
4130
+ * prompt in one call finds nothing and both sides still pay. Making that hit would mean the caller
4131
+ * reproducing the SDK's chunking, which is a worse contract than admitting the gap: short prompts
4132
+ * — the overwhelming majority — dedupe, long ones do not.
4133
+ *
4134
+ * Omit it and nothing changes: every send embeds independently, exactly as before.
4135
+ */
4136
+ embeddingCache?: Map<string, Float32Array>;
4074
4137
  /**
4075
4138
  * Per-request callback invoked with each streamed response chunk.
4076
4139
  * Overrides the hook-level `onData` callback for this request only.
@@ -10591,4 +10654,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
10591
10654
  */
10592
10655
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
10593
10656
 
10594
- export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, 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 CreateDecaySweeperOptions, 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_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, 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, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
10657
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, 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 CreateDecaySweeperOptions, 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_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, 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, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
@@ -2755,6 +2755,38 @@ declare function resumeStream(options: ResumeStreamOptions): Promise<ResumeStrea
2755
2755
  */
2756
2756
  declare const xhrTransport: StreamingTransport;
2757
2757
 
2758
+ /**
2759
+ * Namespacing for a caller-shared embedding cache.
2760
+ *
2761
+ * Lives here, next to the `embeddingCache` send-arg it serves, rather than in either platform hook:
2762
+ * react and expo both thread the option through their own send paths, and a copy per platform is how
2763
+ * the two drift.
2764
+ */
2765
+ /**
2766
+ * Build the same namespaced view over `cache` that a send with this masking decision uses.
2767
+ *
2768
+ * REQUIRED FOR SHARING, and the reason this is exported at all. `embeddingCache`'s whole purpose is
2769
+ * that a caller who also needs the prompt vector passes one `Map` to both `sendMessage` and its own
2770
+ * `generateEmbedding` call, so the turn embeds once. But the send namespaces its entries by masking
2771
+ * decision (see {@link MaskScopedEmbeddingCache}) while `generateEmbedding` keys on the text alone —
2772
+ * so a caller handing the RAW `Map` to its own call writes `"hello"` where the send looks for
2773
+ * `"r:hello"`, and neither side ever hits. The dedupe silently does not happen.
2774
+ *
2775
+ * So: pass the plain `Map` as `embeddingCache`, and wrap it with this for your own call.
2776
+ *
2777
+ * ```ts
2778
+ * const shared = new Map<string, Float32Array>();
2779
+ * // your own ranking embed, same masking decision as the send:
2780
+ * await generateEmbedding(text, { getToken, cache: maskScopedEmbeddingCache(shared, masked) });
2781
+ * await sendMessage({ ..., embeddingCache: shared, piiRedaction: masked });
2782
+ * ```
2783
+ *
2784
+ * `masked` must match what the send resolves for the same turn — i.e. whether PII redaction is on.
2785
+ * Get it wrong and you simply miss the cache; you cannot be served the other decision's vector,
2786
+ * which is the property the namespacing exists to guarantee.
2787
+ */
2788
+ declare function maskScopedEmbeddingCache(cache: Map<string, Float32Array>, masked: boolean): Map<string, Float32Array>;
2789
+
2758
2790
  /**
2759
2791
  * @inline
2760
2792
  */
@@ -4071,6 +4103,37 @@ interface BaseSendMessageWithStorageArgs {
4071
4103
  * user content (matching a textless turn), NOT a request to fall back.
4072
4104
  */
4073
4105
  storedUserContent?: string;
4106
+ /**
4107
+ * Optional embedding cache, shared with the caller.
4108
+ *
4109
+ * Every send that needs tool selection embeds the user text once (see
4110
+ * `storedUserContent`). A caller that ALSO needs that vector — to rank tools itself, say, or to
4111
+ * hand a server a prompt-aware shortlist — otherwise pays for a second, identical embedding of
4112
+ * the same text in the same turn. Pass a `Map` here and into your own
4113
+ * `generateEmbedding`/`generateEmbeddings` call and whichever runs first fills it; the other is a
4114
+ * cache hit, so the turn embeds once.
4115
+ *
4116
+ * Keyed on the text **as passed in** (before `maskInput` is applied to the request body), prefixed
4117
+ * with a marker for this send's masking decision — `"r:"` raw, `"m:"` masked — so a mismatched
4118
+ * masking decision cannot silently serve the wrong vector: masked and unmasked occupy different
4119
+ * entries. `generateEmbedding`'s own contract is unchanged; it still keys on the text alone, and
4120
+ * the prefixing is a view this send wraps around the `Map` you hand it.
4121
+ *
4122
+ * WHICH MEANS SHARING TAKES ONE MORE STEP, and skipping it costs you the dedupe silently: pass
4123
+ * the plain `Map` here, and wrap it with `maskScopedEmbeddingCache(map, masked)` for your OWN
4124
+ * `generateEmbedding` call, so both sides look under the same key. Hand the raw `Map` to both and
4125
+ * your call writes `"hello"` while this one reads `"r:hello"` — no hit, and the second embedding
4126
+ * you were trying to avoid still happens.
4127
+ *
4128
+ * **Long messages are not deduped.** Past `DEFAULT_CHUNK_SIZE` (400 chars) the send embeds one
4129
+ * vector per chunk and keys each entry on its chunk text, so a caller that embedded the whole
4130
+ * prompt in one call finds nothing and both sides still pay. Making that hit would mean the caller
4131
+ * reproducing the SDK's chunking, which is a worse contract than admitting the gap: short prompts
4132
+ * — the overwhelming majority — dedupe, long ones do not.
4133
+ *
4134
+ * Omit it and nothing changes: every send embeds independently, exactly as before.
4135
+ */
4136
+ embeddingCache?: Map<string, Float32Array>;
4074
4137
  /**
4075
4138
  * Per-request callback invoked with each streamed response chunk.
4076
4139
  * Overrides the hook-level `onData` callback for this request only.
@@ -10591,4 +10654,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
10591
10654
  */
10592
10655
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
10593
10656
 
10594
- export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, 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 CreateDecaySweeperOptions, 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_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, 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, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
10657
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, 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 CreateDecaySweeperOptions, 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_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, 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, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
@@ -3818,6 +3818,28 @@ var xhrTransport = (options) => {
3818
3818
  return { stream: createStream() };
3819
3819
  };
3820
3820
 
3821
+ // src/lib/db/chat/embeddingCache.ts
3822
+ var MaskScopedEmbeddingCache = class extends Map {
3823
+ constructor(inner, masked) {
3824
+ super();
3825
+ this.inner = inner;
3826
+ this.masked = masked;
3827
+ }
3828
+ key(text12) {
3829
+ return `${this.masked ? "m" : "r"}:${text12}`;
3830
+ }
3831
+ get(text12) {
3832
+ return this.inner.get(this.key(text12));
3833
+ }
3834
+ set(text12, value) {
3835
+ this.inner.set(this.key(text12), value);
3836
+ return this;
3837
+ }
3838
+ };
3839
+ function maskScopedEmbeddingCache(cache, masked) {
3840
+ return new MaskScopedEmbeddingCache(cache, masked);
3841
+ }
3842
+
3821
3843
  // src/react/useCredits.ts
3822
3844
  import { useCallback, useEffect, useRef, useState } from "react";
3823
3845
  function useCredits(options = {}) {
@@ -10383,12 +10405,14 @@ var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
10383
10405
  };
10384
10406
  var SERVER_TOOL_DEPENDENCY_SETS = [
10385
10407
  {
10386
- // search finds links; reading them is always the next step.
10387
- name: "jina-research",
10408
+ // search finds links; reading them is always the next step. The reader now
10409
+ // lives on the search server — Jina's read_url / parallel_read_url were
10410
+ // removed in favour of anuma_scrape_url, which takes a batch of URLs — so
10411
+ // this edge deliberately spans two MCP servers.
10412
+ name: "web-research",
10388
10413
  members: [
10389
10414
  "AnumaJinaMCP-search_web",
10390
- "AnumaJinaMCP-read_url",
10391
- "AnumaJinaMCP-parallel_read_url",
10415
+ "AnumaSearchMCP-anuma_scrape_url",
10392
10416
  "AnumaJinaMCP-parallel_search_web"
10393
10417
  ],
10394
10418
  anchors: ["AnumaJinaMCP-search_web"],
@@ -11291,6 +11315,7 @@ function useChatStorage(options) {
11291
11315
  summaryModel = DEFAULT_SUMMARY_MODEL,
11292
11316
  files,
11293
11317
  storedUserContent,
11318
+ embeddingCache,
11294
11319
  onData: perRequestOnData,
11295
11320
  onThinking: perRequestOnThinking,
11296
11321
  memoryContext,
@@ -11330,12 +11355,18 @@ function useChatStorage(options) {
11330
11355
  };
11331
11356
  pendingResumeRef.current = null;
11332
11357
  const effectiveAssistantUniqueId = assistantUniqueId ?? (resumable ? `msg_${uuidv73()}` : void 0);
11333
- const embedToolText = (text12, mask, token) => {
11334
- const opts = { getToken: token, baseUrl, model: embeddingModel };
11358
+ const embedToolText = (text12, mask, masked, token) => {
11359
+ const opts = {
11360
+ getToken: token,
11361
+ baseUrl,
11362
+ model: embeddingModel,
11363
+ maskInput: mask,
11364
+ cache: embeddingCache ? maskScopedEmbeddingCache(embeddingCache, masked) : void 0
11365
+ };
11335
11366
  return shouldChunkMessage(text12, DEFAULT_CHUNK_SIZE) ? generateEmbeddings(
11336
- chunkText(text12).map((c) => mask(c.text)),
11367
+ chunkText(text12).map((c) => c.text),
11337
11368
  opts
11338
- ) : generateEmbedding(mask(text12), opts);
11369
+ ) : generateEmbedding(text12, opts);
11339
11370
  };
11340
11371
  if (walletAddress && signMessage && !hasEncryptionKey(walletAddress)) {
11341
11372
  try {
@@ -11375,6 +11406,7 @@ function useChatStorage(options) {
11375
11406
  skipUserEmbedding = await embedToolText(
11376
11407
  messageContent,
11377
11408
  maskForCall2,
11409
+ Boolean(callPiiRedaction2),
11378
11410
  getTokenRef.current
11379
11411
  );
11380
11412
  const toolNames = serverToolsFilter(skipUserEmbedding, allServerTools);
@@ -11395,6 +11427,7 @@ function useChatStorage(options) {
11395
11427
  skipUserEmbedding = await embedToolText(
11396
11428
  messageContent,
11397
11429
  maskForCall2,
11430
+ Boolean(callPiiRedaction2),
11398
11431
  getTokenRef.current
11399
11432
  );
11400
11433
  } catch {
@@ -11543,7 +11576,14 @@ function useChatStorage(options) {
11543
11576
  };
11544
11577
  const embedForToolsSettled = async (token) => {
11545
11578
  try {
11546
- return { embedding: await embedToolText(contentForStorage, maskForCall, token) };
11579
+ return {
11580
+ embedding: await embedToolText(
11581
+ contentForStorage,
11582
+ maskForCall,
11583
+ Boolean(callPiiRedaction),
11584
+ token
11585
+ )
11586
+ };
11547
11587
  } catch (error) {
11548
11588
  return { error };
11549
11589
  }
@@ -15017,6 +15057,7 @@ export {
15017
15057
  isDegradedTopicSkip,
15018
15058
  isPiiRedactor,
15019
15059
  isRerankerAvailable,
15060
+ maskScopedEmbeddingCache,
15020
15061
  moveMemoriesToFolderOp,
15021
15062
  noopLogger,
15022
15063
  onKeyAvailable,
package/dist/index.cjs CHANGED
@@ -2332,12 +2332,14 @@ var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
2332
2332
  };
2333
2333
  var SERVER_TOOL_DEPENDENCY_SETS = [
2334
2334
  {
2335
- // search finds links; reading them is always the next step.
2336
- name: "jina-research",
2335
+ // search finds links; reading them is always the next step. The reader now
2336
+ // lives on the search server — Jina's read_url / parallel_read_url were
2337
+ // removed in favour of anuma_scrape_url, which takes a batch of URLs — so
2338
+ // this edge deliberately spans two MCP servers.
2339
+ name: "web-research",
2337
2340
  members: [
2338
2341
  "AnumaJinaMCP-search_web",
2339
- "AnumaJinaMCP-read_url",
2340
- "AnumaJinaMCP-parallel_read_url",
2342
+ "AnumaSearchMCP-anuma_scrape_url",
2341
2343
  "AnumaJinaMCP-parallel_search_web"
2342
2344
  ],
2343
2345
  anchors: ["AnumaJinaMCP-search_web"],
package/dist/index.d.mts CHANGED
@@ -7808,7 +7808,7 @@ declare function applyToolSets(matchedNames: Set<string>, availableNames: Set<st
7808
7808
  * precision.
7809
7809
  *
7810
7810
  * Use this for server-side toolkit suites where the LLM needs the full
7811
- * call chain (e.g. search_web → read_url / parallel_read_url, or
7811
+ * call chain (e.g. search_web → anuma_scrape_url, or
7812
7812
  * geocoding before the OpenMeteo data tools). Differs from `applyToolSets`,
7813
7813
  * which replaces non-set matches when a set activates.
7814
7814
  *
@@ -7890,7 +7890,7 @@ interface CreateServerToolsFilterOptions {
7890
7890
  * toolSets: [
7891
7891
  * {
7892
7892
  * name: "research",
7893
- * members: ["AnumaJinaMCP-search_web", "AnumaJinaMCP-read_url", ...],
7893
+ * members: ["AnumaJinaMCP-search_web", "AnumaSearchMCP-anuma_scrape_url", ...],
7894
7894
  * anchors: ["AnumaJinaMCP-search_web"],
7895
7895
  * anchorMinSimilarity: 0.7,
7896
7896
  * },
package/dist/index.d.ts CHANGED
@@ -7808,7 +7808,7 @@ declare function applyToolSets(matchedNames: Set<string>, availableNames: Set<st
7808
7808
  * precision.
7809
7809
  *
7810
7810
  * Use this for server-side toolkit suites where the LLM needs the full
7811
- * call chain (e.g. search_web → read_url / parallel_read_url, or
7811
+ * call chain (e.g. search_web → anuma_scrape_url, or
7812
7812
  * geocoding before the OpenMeteo data tools). Differs from `applyToolSets`,
7813
7813
  * which replaces non-set matches when a set activates.
7814
7814
  *
@@ -7890,7 +7890,7 @@ interface CreateServerToolsFilterOptions {
7890
7890
  * toolSets: [
7891
7891
  * {
7892
7892
  * name: "research",
7893
- * members: ["AnumaJinaMCP-search_web", "AnumaJinaMCP-read_url", ...],
7893
+ * members: ["AnumaJinaMCP-search_web", "AnumaSearchMCP-anuma_scrape_url", ...],
7894
7894
  * anchors: ["AnumaJinaMCP-search_web"],
7895
7895
  * anchorMinSimilarity: 0.7,
7896
7896
  * },
package/dist/index.mjs CHANGED
@@ -2130,12 +2130,14 @@ var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
2130
2130
  };
2131
2131
  var SERVER_TOOL_DEPENDENCY_SETS = [
2132
2132
  {
2133
- // search finds links; reading them is always the next step.
2134
- name: "jina-research",
2133
+ // search finds links; reading them is always the next step. The reader now
2134
+ // lives on the search server — Jina's read_url / parallel_read_url were
2135
+ // removed in favour of anuma_scrape_url, which takes a batch of URLs — so
2136
+ // this edge deliberately spans two MCP servers.
2137
+ name: "web-research",
2135
2138
  members: [
2136
2139
  "AnumaJinaMCP-search_web",
2137
- "AnumaJinaMCP-read_url",
2138
- "AnumaJinaMCP-parallel_read_url",
2140
+ "AnumaSearchMCP-anuma_scrape_url",
2139
2141
  "AnumaJinaMCP-parallel_search_web"
2140
2142
  ],
2141
2143
  anchors: ["AnumaJinaMCP-search_web"],