@anuma/sdk 4.2.0 → 5.0.0

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.
@@ -3506,6 +3506,15 @@ interface StoredMessage {
3506
3506
  feedback?: MessageFeedback;
3507
3507
  /** Tool call events from the backend response (for reconstructing tool call history) */
3508
3508
  toolCallEvents?: LlmapiToolCallEvent[];
3509
+ /**
3510
+ * Set when `content` could not be decrypted on read (#561).
3511
+ * The `content` field still holds the original ciphertext — never a
3512
+ * `[Decryption Failed]` placeholder — so a later unlock can recover.
3513
+ * - `key_missing`: no key for this field's `enc:vN:` version in the store
3514
+ * - `auth_mismatch`: a key was present but AES-GCM auth failed (wrong key)
3515
+ * - `invalid_payload`: malformed ciphertext envelope
3516
+ */
3517
+ decryptionStatus?: "key_missing" | "auth_mismatch" | "invalid_payload";
3509
3518
  }
3510
3519
  interface ActivityPhase {
3511
3520
  id: string;
@@ -4141,6 +4150,35 @@ declare class Conversation extends Model {
4141
4150
  pinnedAt?: Date | null;
4142
4151
  }
4143
4152
 
4153
+ /**
4154
+ * Encryption key version type.
4155
+ * - "v2": Legacy SHA-256 derived key (for reading enc:v2: data)
4156
+ * - "v3": HKDF derived key with domain separation (for new encryption)
4157
+ */
4158
+ type EncryptionKeyVersion = "v2" | "v3";
4159
+ /**
4160
+ * Thrown by {@link getEncryptionKey} when the requested version is absent.
4161
+ * Distinct from AES-GCM auth-tag failures so decrypt callers can tell
4162
+ * "need to derive/hydrate this version" from "wrong key for intact ciphertext".
4163
+ */
4164
+ declare class EncryptionKeyMissingError extends Error {
4165
+ readonly address: string;
4166
+ readonly version: EncryptionKeyVersion;
4167
+ constructor(address: string, version: EncryptionKeyVersion);
4168
+ }
4169
+ /**
4170
+ * Options for {@link requestEncryptionKey}.
4171
+ */
4172
+ interface RequestEncryptionKeyOptions {
4173
+ /**
4174
+ * When true, re-derive and replace any existing in-memory keys for this
4175
+ * address. Default false preserves the historical "if present, return"
4176
+ * short-circuit. Prefer {@link refreshEncryptionKeyIfMatches} when the
4177
+ * caller has ciphertext that must keep working — force-replace can pin a
4178
+ * newly derived wrong key over a still-valid one.
4179
+ */
4180
+ force?: boolean;
4181
+ }
4144
4182
  /**
4145
4183
  * Register a callback that fires when an encryption key becomes available for an address.
4146
4184
  * If the key is already available, the callback fires immediately.
@@ -4186,9 +4224,30 @@ declare function clearAllEncryptionState(): void;
4186
4224
  */
4187
4225
  declare function clearAllEncryptionKeys(): void;
4188
4226
  /**
4189
- * Checks if an encryption key exists in memory for the given wallet address
4227
+ * Checks if an encryption key exists in memory for the given wallet address.
4228
+ *
4229
+ * @param address - Wallet address
4230
+ * @param version - When omitted, checks the **v3** (`current`) key — the key
4231
+ * write/OPFS/encrypt paths need. Callers that only need to read legacy
4232
+ * `enc:v2:` data should pass `"v2"` explicitly. (#561 / PR #828)
4233
+ */
4234
+ declare function hasEncryptionKey(address: string, version?: EncryptionKeyVersion): boolean;
4235
+ /**
4236
+ * Seed (or merge) raw key hex into the in-memory store without signing.
4237
+ *
4238
+ * Used by platform polyfills that hydrate from SecureStore / keychain where
4239
+ * one version may be missing — callers must not require both versions to
4240
+ * exist before the other becomes usable (#561).
4241
+ *
4242
+ * Existing versions are preserved when the corresponding argument is omitted.
4243
+ * Pass an explicit empty merge is not supported; omit the field to leave it.
4244
+ *
4245
+ * Each provided key must be 64 hex characters (32-byte AES key).
4190
4246
  */
4191
- declare function hasEncryptionKey(address: string): boolean;
4247
+ declare function seedEncryptionKeys(address: string, keys: {
4248
+ legacy?: string;
4249
+ current?: string;
4250
+ }): void;
4192
4251
  /**
4193
4252
  * Options for signing messages.
4194
4253
  */
@@ -4209,24 +4268,50 @@ type SignMessageFn = (message: string, options?: SignMessageOptions) => Promise<
4209
4268
  type EmbeddedWalletSignerFn = (message: string, options?: SignMessageOptions) => Promise<string>;
4210
4269
  /**
4211
4270
  * Requests the user to sign a message to generate an encryption key.
4212
- * If a key already exists in memory for the given wallet, resolves immediately.
4271
+ * If a key already exists in memory for the given wallet, resolves immediately
4272
+ * unless {@link RequestEncryptionKeyOptions.force} is set.
4213
4273
  *
4214
4274
  * Note: Keys are stored in memory only and do not persist across page reloads.
4215
4275
  * This is a security feature - users must sign once per session to derive their key.
4216
4276
  *
4277
+ * When a seeded/pinned store already has keys and the fresh derive does not
4278
+ * match any of them, the store is left unchanged and this resolves to `false`
4279
+ * (without firing {@link onKeyAvailable}). Callers that need write readiness
4280
+ * should check the return value or {@link hasEncryptionKey} before encrypting
4281
+ * so they can surface a re-unlock UI instead of failing downstream (#828).
4282
+ *
4217
4283
  * @param walletAddress - The wallet address to generate the key for
4218
4284
  * @param signMessage - Function to sign a message (returns signature hex string)
4219
4285
  * @param embeddedWalletSigner - Optional function for silent signing with embedded wallets
4220
- * @returns Promise that resolves when the key is available
4286
+ * @param options - Optional flags (e.g. force re-derive)
4287
+ * @returns `true` when keys are available after the call; `false` when a
4288
+ * divergent derive left the store unchanged (or the session was torn down
4289
+ * mid-flight).
4290
+ */
4291
+ declare function requestEncryptionKey(walletAddress: string, signMessage: SignMessageFn, embeddedWalletSigner?: EmbeddedWalletSignerFn, options?: RequestEncryptionKeyOptions): Promise<boolean>;
4292
+ /**
4293
+ * Re-derive encryption keys from a fresh signature and commit them **only if**
4294
+ * they successfully decrypt `probeCiphertext` (a prefixed `enc:v2:` / `enc:v3:`
4295
+ * value). If they do not, the existing in-memory keys are left untouched.
4296
+ *
4297
+ * Concurrent calls for the same wallet share one sign+derive. Each caller then
4298
+ * probes **its own** ciphertext against those candidates, so mixed-era messages
4299
+ * in one `Promise.all` batch can still recover when only the leader's probe
4300
+ * misses (#828 review). Failed candidates are memoized for the session so
4301
+ * pagination does not re-prompt on every page when the wallet has changed.
4302
+ *
4303
+ * @returns true when keys were refreshed (probe decrypted); false when the
4304
+ * probe failed under the candidate keys (store unchanged) or the probe was
4305
+ * not encrypted.
4221
4306
  */
4222
- declare function requestEncryptionKey(walletAddress: string, signMessage: SignMessageFn, embeddedWalletSigner?: EmbeddedWalletSignerFn): Promise<void>;
4307
+ declare function refreshEncryptionKeyIfMatches(walletAddress: string, probeCiphertext: string, signMessage: SignMessageFn, embeddedWalletSigner?: EmbeddedWalletSignerFn): Promise<boolean>;
4223
4308
  /**
4224
4309
  * Result returned by the useEncryption hook.
4225
4310
  * @category Hooks
4226
4311
  */
4227
4312
  interface UseEncryptionResult {
4228
4313
  /** Request and generate an encryption key for a wallet address */
4229
- requestEncryptionKey: (walletAddress: string) => Promise<void>;
4314
+ requestEncryptionKey: (walletAddress: string) => Promise<boolean>;
4230
4315
  /** Request and generate an ECDH key pair for a wallet address */
4231
4316
  requestKeyPair: (walletAddress: string) => Promise<void>;
4232
4317
  /** Export the public key for a wallet address as base64-encoded SPKI */
@@ -4924,15 +5009,26 @@ interface MemoryVaultSearchOptions {
4924
5009
  /** RRF smoothing constant for lane fusion. Default 60. */
4925
5010
  rrfK?: number;
4926
5011
  /**
4927
- * LLM-based query decomposition for composite/abstract queries. When set,
4928
- * each query is classified + (if composite) decomposed into 3–5 facet
4929
- * sub-queries via gpt-5-mini, then ranked via {@link rankComposite}.
4930
- * Requires `decomposeOptions` (auth) when set to "llm".
5012
+ * Pre-decomposed facet queries for the composite ranker (719/B4). When
5013
+ * ≥2 are supplied (and embeddings are available), runs {@link rankComposite}
5014
+ * over them — no LLM call inside the search path. Callers that want LLM
5015
+ * rewrite (e.g. `createRecallTool`) call `decomposeQuery` first and pass
5016
+ * the facets here.
5017
+ */
5018
+ subQueries?: string[];
5019
+ /**
5020
+ * @deprecated 719/B4 — ignored by {@link searchVaultMemories} /
5021
+ * {@link searchVaultMemoriesWithSize}. Pass {@link MemoryVaultSearchOptions.subQueries}
5022
+ * (or use `createRecallTool`). The legacy {@link createMemoryVaultSearchTool}
5023
+ * executor still honors `decompose: "llm"` + `decomposeOptions` for eval
5024
+ * parity, then forwards facets into the LLM-free search path.
4931
5025
  */
4932
5026
  decompose?: "off" | "llm";
4933
- /** Auth + endpoint for the decomposition LLM call. Required when
4934
- * decompose="llm". Auth is the dual pattern — one of `apiKey` /
4935
- * `getToken`; see {@link PortalLlmAuth}. */
5027
+ /**
5028
+ * @deprecated 719/B4 — see `decompose`. Ignored on the programmatic search
5029
+ * path; tool-layer rewrite still reads this from the search-tool options.
5030
+ * Prefer `RecallToolOptions.decomposeOptions` with `createRecallTool`.
5031
+ */
4936
5032
  decomposeOptions?: PortalLlmAuth & {
4937
5033
  baseUrl?: string;
4938
5034
  model?: string;
@@ -5097,9 +5193,11 @@ type MemoryKind = "fact" | "chunk";
5097
5193
  * Budget controls retrieval depth/cost. Higher budgets enable more
5098
5194
  * candidate sources and the cross-encoder reranker.
5099
5195
  *
5100
- * - `low`: cosine + BM25 fusion only. No reranker. Mobile default.
5101
- * - `mid`: + recency boost. Demo default.
5102
- * - `high`: + cross-encoder rerank stage. Demo `budget: high` path.
5196
+ * - `low`: cosine + BM25 + recency. No reranker. Mobile default.
5197
+ * - `mid`: + cross-encoder rerank.
5198
+ * - `high`: + multi-hop graph traversal. LLM-free — query decomposition
5199
+ * (when wanted) lives in the tool/agent layer ({@link createRecallTool}),
5200
+ * not inside `recall()` itself (719/B4).
5103
5201
  */
5104
5202
  type Budget = "low" | "mid" | "high";
5105
5203
  interface ScoreBreakdown {
@@ -5199,10 +5297,28 @@ interface RecallOptions {
5199
5297
  /** Drop results below this score. Default: 0.1 for facts, 0.5 for chunks (mirrors today's defaults). */
5200
5298
  minScore?: number;
5201
5299
  /**
5202
- * Auth + endpoint for the LLM-based query decomposition pass. Without
5203
- * these, decompose is skipped even at `budget: 'high'`. Mirrors the
5204
- * shape used by `searchVaultMemories`. Auth is the dual pattern — one
5205
- * of `apiKey` / `getToken` is required; see {@link PortalLlmAuth}.
5300
+ * Pre-decomposed facet queries for the composite ranker. When ≥2 are
5301
+ * supplied, the vault lane runs `rankComposite` over them (no LLM call
5302
+ * inside `recall()` — 719/B4). Callers that still want LLM rewrite
5303
+ * (e.g. {@link createRecallTool} at `budget: 'high'`) call
5304
+ * `decomposeQuery` themselves and pass the result here. A single entry
5305
+ * (or omitting this) keeps the single-query path.
5306
+ */
5307
+ subQueries?: string[];
5308
+ /**
5309
+ * Auth + endpoint for optional LLM helpers that reuse portal auth —
5310
+ * currently {@link RecallOptions.graphRefine} neighbor selection.
5311
+ * Query decomposition is **not** driven by this field inside `recall()`
5312
+ * (719/B4); {@link createRecallTool} reads the same shape from
5313
+ * `RecallToolOptions.decomposeOptions` for tool-layer rewrite.
5314
+ *
5315
+ * Callers that still pass `{ budget: 'high', decomposeOptions }` without
5316
+ * {@link RecallOptions.subQueries} keep compiling but no longer rewrite —
5317
+ * `recall()` emits `decompose-moved` on {@link RecallDiagnostics.degraded}
5318
+ * so upgrades without a changelog read still leave a telemetry breadcrumb.
5319
+ *
5320
+ * Auth is the dual pattern — one of `apiKey` / `getToken` is required;
5321
+ * see {@link PortalLlmAuth}.
5206
5322
  */
5207
5323
  decomposeOptions?: PortalLlmAuth & {
5208
5324
  baseUrl?: string;
@@ -5306,9 +5422,22 @@ type RecallDegradation =
5306
5422
  /** Rerank was requested (budget mid/high) but the cross-encoder didn't run
5307
5423
  * this call — unavailable (e.g. React Native) or a transient failure. */
5308
5424
  "rerank-unavailable"
5309
- /** `budget: 'high'` requested but no `decomposeOptions`, so query
5310
- * decomposition was skipped and the budget downgraded to mid. */
5425
+ /**
5426
+ * @deprecated 719/B4 moved query decomposition out of `recall()`. Budget
5427
+ * `high` no longer requires `decomposeOptions` and this signal is never
5428
+ * emitted. Prefer `"decompose-moved"` for the upgrade breadcrumb. Kept in
5429
+ * the union so existing telemetry consumers stay typed.
5430
+ */
5311
5431
  | "decompose-unavailable"
5432
+ /**
5433
+ * `budget: 'high'` with `decomposeOptions` set but no usable
5434
+ * {@link RecallOptions.subQueries}. Pre-B4 this call shape triggered LLM
5435
+ * rewrite inside `recall()`; post-B4 it stays on the single-query high
5436
+ * path (rerank + graph) and callers must pass facets (or use
5437
+ * {@link createRecallTool}). Surfaced so silent quality regressions show
5438
+ * up in diagnostics instead of looking healthier than before.
5439
+ */
5440
+ | "decompose-moved"
5312
5441
  /** There was no usable cosine lane, so results were ranked on BM25 (lexical)
5313
5442
  * alone: either the query embedding failed (or came back empty), or no
5314
5443
  * candidate had a vector to score against it because the row (re)embed failed.
@@ -7378,9 +7507,14 @@ declare function rankProfileCandidates(inputs: readonly ProfileSalienceInput[],
7378
7507
  * Unified Recall API — single retrieval surface above vault + engine.
7379
7508
  *
7380
7509
  * Budget maps to pipeline depth (mirrors Hindsight's tiered defaults):
7381
- * - `low` → V2 cosine + BM25 + recency (no rerank, no decompose)
7510
+ * - `low` → V2 cosine + BM25 + recency (no rerank)
7382
7511
  * - `mid` → V2 + cross-encoder rerank
7383
- * - `high` → V2 + rerank + LLM query decomposition for composite queries
7512
+ * - `high` → V2 + rerank + multi-hop graph traversal
7513
+ *
7514
+ * LLM-free by design (719/B4): query decomposition for composite asks
7515
+ * lives in the tool/agent layer (`createRecallTool`), which may pass
7516
+ * pre-built `subQueries` into this API. `recall()` itself never pays an
7517
+ * LLM RTT.
7384
7518
  *
7385
7519
  * Fact + chunk lanes are fused with RRF (k=60). The previous naive
7386
7520
  * "sort the union by raw score" path is gone — score scales differ
@@ -7435,7 +7569,8 @@ interface RecallToolOptions {
7435
7569
  folderId?: string | null;
7436
7570
  /** Exclude one conversation from chunk results (typically the active one). */
7437
7571
  excludeConversationId?: string;
7438
- /** LLM-decompose options; only used at budget="high". Auth follows the
7572
+ /** LLM-decompose options; only used at budget="high". Runs in THIS tool
7573
+ * executor (719/B4) — `recall()` itself is LLM-free. Auth follows the
7439
7574
  * dual pattern: apiKey (server/CLI) or getToken (browser identity
7440
7575
  * tokens) — at least one required. */
7441
7576
  decomposeOptions?: PortalLlmAuth & {
@@ -9253,4 +9388,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
9253
9388
  */
9254
9389
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
9255
9390
 
9256
- 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 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, 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 MemoryVaultSearchOptions, type MemoryVaultToolOptions, 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 PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, 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, 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, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, 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, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, 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, 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, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
9391
+ 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 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 MemoryVaultSearchOptions, type MemoryVaultToolOptions, 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 PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, 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, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, 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, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, 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, 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, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, 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, xhrTransport };
@@ -3506,6 +3506,15 @@ interface StoredMessage {
3506
3506
  feedback?: MessageFeedback;
3507
3507
  /** Tool call events from the backend response (for reconstructing tool call history) */
3508
3508
  toolCallEvents?: LlmapiToolCallEvent[];
3509
+ /**
3510
+ * Set when `content` could not be decrypted on read (#561).
3511
+ * The `content` field still holds the original ciphertext — never a
3512
+ * `[Decryption Failed]` placeholder — so a later unlock can recover.
3513
+ * - `key_missing`: no key for this field's `enc:vN:` version in the store
3514
+ * - `auth_mismatch`: a key was present but AES-GCM auth failed (wrong key)
3515
+ * - `invalid_payload`: malformed ciphertext envelope
3516
+ */
3517
+ decryptionStatus?: "key_missing" | "auth_mismatch" | "invalid_payload";
3509
3518
  }
3510
3519
  interface ActivityPhase {
3511
3520
  id: string;
@@ -4141,6 +4150,35 @@ declare class Conversation extends Model {
4141
4150
  pinnedAt?: Date | null;
4142
4151
  }
4143
4152
 
4153
+ /**
4154
+ * Encryption key version type.
4155
+ * - "v2": Legacy SHA-256 derived key (for reading enc:v2: data)
4156
+ * - "v3": HKDF derived key with domain separation (for new encryption)
4157
+ */
4158
+ type EncryptionKeyVersion = "v2" | "v3";
4159
+ /**
4160
+ * Thrown by {@link getEncryptionKey} when the requested version is absent.
4161
+ * Distinct from AES-GCM auth-tag failures so decrypt callers can tell
4162
+ * "need to derive/hydrate this version" from "wrong key for intact ciphertext".
4163
+ */
4164
+ declare class EncryptionKeyMissingError extends Error {
4165
+ readonly address: string;
4166
+ readonly version: EncryptionKeyVersion;
4167
+ constructor(address: string, version: EncryptionKeyVersion);
4168
+ }
4169
+ /**
4170
+ * Options for {@link requestEncryptionKey}.
4171
+ */
4172
+ interface RequestEncryptionKeyOptions {
4173
+ /**
4174
+ * When true, re-derive and replace any existing in-memory keys for this
4175
+ * address. Default false preserves the historical "if present, return"
4176
+ * short-circuit. Prefer {@link refreshEncryptionKeyIfMatches} when the
4177
+ * caller has ciphertext that must keep working — force-replace can pin a
4178
+ * newly derived wrong key over a still-valid one.
4179
+ */
4180
+ force?: boolean;
4181
+ }
4144
4182
  /**
4145
4183
  * Register a callback that fires when an encryption key becomes available for an address.
4146
4184
  * If the key is already available, the callback fires immediately.
@@ -4186,9 +4224,30 @@ declare function clearAllEncryptionState(): void;
4186
4224
  */
4187
4225
  declare function clearAllEncryptionKeys(): void;
4188
4226
  /**
4189
- * Checks if an encryption key exists in memory for the given wallet address
4227
+ * Checks if an encryption key exists in memory for the given wallet address.
4228
+ *
4229
+ * @param address - Wallet address
4230
+ * @param version - When omitted, checks the **v3** (`current`) key — the key
4231
+ * write/OPFS/encrypt paths need. Callers that only need to read legacy
4232
+ * `enc:v2:` data should pass `"v2"` explicitly. (#561 / PR #828)
4233
+ */
4234
+ declare function hasEncryptionKey(address: string, version?: EncryptionKeyVersion): boolean;
4235
+ /**
4236
+ * Seed (or merge) raw key hex into the in-memory store without signing.
4237
+ *
4238
+ * Used by platform polyfills that hydrate from SecureStore / keychain where
4239
+ * one version may be missing — callers must not require both versions to
4240
+ * exist before the other becomes usable (#561).
4241
+ *
4242
+ * Existing versions are preserved when the corresponding argument is omitted.
4243
+ * Pass an explicit empty merge is not supported; omit the field to leave it.
4244
+ *
4245
+ * Each provided key must be 64 hex characters (32-byte AES key).
4190
4246
  */
4191
- declare function hasEncryptionKey(address: string): boolean;
4247
+ declare function seedEncryptionKeys(address: string, keys: {
4248
+ legacy?: string;
4249
+ current?: string;
4250
+ }): void;
4192
4251
  /**
4193
4252
  * Options for signing messages.
4194
4253
  */
@@ -4209,24 +4268,50 @@ type SignMessageFn = (message: string, options?: SignMessageOptions) => Promise<
4209
4268
  type EmbeddedWalletSignerFn = (message: string, options?: SignMessageOptions) => Promise<string>;
4210
4269
  /**
4211
4270
  * Requests the user to sign a message to generate an encryption key.
4212
- * If a key already exists in memory for the given wallet, resolves immediately.
4271
+ * If a key already exists in memory for the given wallet, resolves immediately
4272
+ * unless {@link RequestEncryptionKeyOptions.force} is set.
4213
4273
  *
4214
4274
  * Note: Keys are stored in memory only and do not persist across page reloads.
4215
4275
  * This is a security feature - users must sign once per session to derive their key.
4216
4276
  *
4277
+ * When a seeded/pinned store already has keys and the fresh derive does not
4278
+ * match any of them, the store is left unchanged and this resolves to `false`
4279
+ * (without firing {@link onKeyAvailable}). Callers that need write readiness
4280
+ * should check the return value or {@link hasEncryptionKey} before encrypting
4281
+ * so they can surface a re-unlock UI instead of failing downstream (#828).
4282
+ *
4217
4283
  * @param walletAddress - The wallet address to generate the key for
4218
4284
  * @param signMessage - Function to sign a message (returns signature hex string)
4219
4285
  * @param embeddedWalletSigner - Optional function for silent signing with embedded wallets
4220
- * @returns Promise that resolves when the key is available
4286
+ * @param options - Optional flags (e.g. force re-derive)
4287
+ * @returns `true` when keys are available after the call; `false` when a
4288
+ * divergent derive left the store unchanged (or the session was torn down
4289
+ * mid-flight).
4290
+ */
4291
+ declare function requestEncryptionKey(walletAddress: string, signMessage: SignMessageFn, embeddedWalletSigner?: EmbeddedWalletSignerFn, options?: RequestEncryptionKeyOptions): Promise<boolean>;
4292
+ /**
4293
+ * Re-derive encryption keys from a fresh signature and commit them **only if**
4294
+ * they successfully decrypt `probeCiphertext` (a prefixed `enc:v2:` / `enc:v3:`
4295
+ * value). If they do not, the existing in-memory keys are left untouched.
4296
+ *
4297
+ * Concurrent calls for the same wallet share one sign+derive. Each caller then
4298
+ * probes **its own** ciphertext against those candidates, so mixed-era messages
4299
+ * in one `Promise.all` batch can still recover when only the leader's probe
4300
+ * misses (#828 review). Failed candidates are memoized for the session so
4301
+ * pagination does not re-prompt on every page when the wallet has changed.
4302
+ *
4303
+ * @returns true when keys were refreshed (probe decrypted); false when the
4304
+ * probe failed under the candidate keys (store unchanged) or the probe was
4305
+ * not encrypted.
4221
4306
  */
4222
- declare function requestEncryptionKey(walletAddress: string, signMessage: SignMessageFn, embeddedWalletSigner?: EmbeddedWalletSignerFn): Promise<void>;
4307
+ declare function refreshEncryptionKeyIfMatches(walletAddress: string, probeCiphertext: string, signMessage: SignMessageFn, embeddedWalletSigner?: EmbeddedWalletSignerFn): Promise<boolean>;
4223
4308
  /**
4224
4309
  * Result returned by the useEncryption hook.
4225
4310
  * @category Hooks
4226
4311
  */
4227
4312
  interface UseEncryptionResult {
4228
4313
  /** Request and generate an encryption key for a wallet address */
4229
- requestEncryptionKey: (walletAddress: string) => Promise<void>;
4314
+ requestEncryptionKey: (walletAddress: string) => Promise<boolean>;
4230
4315
  /** Request and generate an ECDH key pair for a wallet address */
4231
4316
  requestKeyPair: (walletAddress: string) => Promise<void>;
4232
4317
  /** Export the public key for a wallet address as base64-encoded SPKI */
@@ -4924,15 +5009,26 @@ interface MemoryVaultSearchOptions {
4924
5009
  /** RRF smoothing constant for lane fusion. Default 60. */
4925
5010
  rrfK?: number;
4926
5011
  /**
4927
- * LLM-based query decomposition for composite/abstract queries. When set,
4928
- * each query is classified + (if composite) decomposed into 3–5 facet
4929
- * sub-queries via gpt-5-mini, then ranked via {@link rankComposite}.
4930
- * Requires `decomposeOptions` (auth) when set to "llm".
5012
+ * Pre-decomposed facet queries for the composite ranker (719/B4). When
5013
+ * ≥2 are supplied (and embeddings are available), runs {@link rankComposite}
5014
+ * over them — no LLM call inside the search path. Callers that want LLM
5015
+ * rewrite (e.g. `createRecallTool`) call `decomposeQuery` first and pass
5016
+ * the facets here.
5017
+ */
5018
+ subQueries?: string[];
5019
+ /**
5020
+ * @deprecated 719/B4 — ignored by {@link searchVaultMemories} /
5021
+ * {@link searchVaultMemoriesWithSize}. Pass {@link MemoryVaultSearchOptions.subQueries}
5022
+ * (or use `createRecallTool`). The legacy {@link createMemoryVaultSearchTool}
5023
+ * executor still honors `decompose: "llm"` + `decomposeOptions` for eval
5024
+ * parity, then forwards facets into the LLM-free search path.
4931
5025
  */
4932
5026
  decompose?: "off" | "llm";
4933
- /** Auth + endpoint for the decomposition LLM call. Required when
4934
- * decompose="llm". Auth is the dual pattern — one of `apiKey` /
4935
- * `getToken`; see {@link PortalLlmAuth}. */
5027
+ /**
5028
+ * @deprecated 719/B4 — see `decompose`. Ignored on the programmatic search
5029
+ * path; tool-layer rewrite still reads this from the search-tool options.
5030
+ * Prefer `RecallToolOptions.decomposeOptions` with `createRecallTool`.
5031
+ */
4936
5032
  decomposeOptions?: PortalLlmAuth & {
4937
5033
  baseUrl?: string;
4938
5034
  model?: string;
@@ -5097,9 +5193,11 @@ type MemoryKind = "fact" | "chunk";
5097
5193
  * Budget controls retrieval depth/cost. Higher budgets enable more
5098
5194
  * candidate sources and the cross-encoder reranker.
5099
5195
  *
5100
- * - `low`: cosine + BM25 fusion only. No reranker. Mobile default.
5101
- * - `mid`: + recency boost. Demo default.
5102
- * - `high`: + cross-encoder rerank stage. Demo `budget: high` path.
5196
+ * - `low`: cosine + BM25 + recency. No reranker. Mobile default.
5197
+ * - `mid`: + cross-encoder rerank.
5198
+ * - `high`: + multi-hop graph traversal. LLM-free — query decomposition
5199
+ * (when wanted) lives in the tool/agent layer ({@link createRecallTool}),
5200
+ * not inside `recall()` itself (719/B4).
5103
5201
  */
5104
5202
  type Budget = "low" | "mid" | "high";
5105
5203
  interface ScoreBreakdown {
@@ -5199,10 +5297,28 @@ interface RecallOptions {
5199
5297
  /** Drop results below this score. Default: 0.1 for facts, 0.5 for chunks (mirrors today's defaults). */
5200
5298
  minScore?: number;
5201
5299
  /**
5202
- * Auth + endpoint for the LLM-based query decomposition pass. Without
5203
- * these, decompose is skipped even at `budget: 'high'`. Mirrors the
5204
- * shape used by `searchVaultMemories`. Auth is the dual pattern — one
5205
- * of `apiKey` / `getToken` is required; see {@link PortalLlmAuth}.
5300
+ * Pre-decomposed facet queries for the composite ranker. When ≥2 are
5301
+ * supplied, the vault lane runs `rankComposite` over them (no LLM call
5302
+ * inside `recall()` — 719/B4). Callers that still want LLM rewrite
5303
+ * (e.g. {@link createRecallTool} at `budget: 'high'`) call
5304
+ * `decomposeQuery` themselves and pass the result here. A single entry
5305
+ * (or omitting this) keeps the single-query path.
5306
+ */
5307
+ subQueries?: string[];
5308
+ /**
5309
+ * Auth + endpoint for optional LLM helpers that reuse portal auth —
5310
+ * currently {@link RecallOptions.graphRefine} neighbor selection.
5311
+ * Query decomposition is **not** driven by this field inside `recall()`
5312
+ * (719/B4); {@link createRecallTool} reads the same shape from
5313
+ * `RecallToolOptions.decomposeOptions` for tool-layer rewrite.
5314
+ *
5315
+ * Callers that still pass `{ budget: 'high', decomposeOptions }` without
5316
+ * {@link RecallOptions.subQueries} keep compiling but no longer rewrite —
5317
+ * `recall()` emits `decompose-moved` on {@link RecallDiagnostics.degraded}
5318
+ * so upgrades without a changelog read still leave a telemetry breadcrumb.
5319
+ *
5320
+ * Auth is the dual pattern — one of `apiKey` / `getToken` is required;
5321
+ * see {@link PortalLlmAuth}.
5206
5322
  */
5207
5323
  decomposeOptions?: PortalLlmAuth & {
5208
5324
  baseUrl?: string;
@@ -5306,9 +5422,22 @@ type RecallDegradation =
5306
5422
  /** Rerank was requested (budget mid/high) but the cross-encoder didn't run
5307
5423
  * this call — unavailable (e.g. React Native) or a transient failure. */
5308
5424
  "rerank-unavailable"
5309
- /** `budget: 'high'` requested but no `decomposeOptions`, so query
5310
- * decomposition was skipped and the budget downgraded to mid. */
5425
+ /**
5426
+ * @deprecated 719/B4 moved query decomposition out of `recall()`. Budget
5427
+ * `high` no longer requires `decomposeOptions` and this signal is never
5428
+ * emitted. Prefer `"decompose-moved"` for the upgrade breadcrumb. Kept in
5429
+ * the union so existing telemetry consumers stay typed.
5430
+ */
5311
5431
  | "decompose-unavailable"
5432
+ /**
5433
+ * `budget: 'high'` with `decomposeOptions` set but no usable
5434
+ * {@link RecallOptions.subQueries}. Pre-B4 this call shape triggered LLM
5435
+ * rewrite inside `recall()`; post-B4 it stays on the single-query high
5436
+ * path (rerank + graph) and callers must pass facets (or use
5437
+ * {@link createRecallTool}). Surfaced so silent quality regressions show
5438
+ * up in diagnostics instead of looking healthier than before.
5439
+ */
5440
+ | "decompose-moved"
5312
5441
  /** There was no usable cosine lane, so results were ranked on BM25 (lexical)
5313
5442
  * alone: either the query embedding failed (or came back empty), or no
5314
5443
  * candidate had a vector to score against it because the row (re)embed failed.
@@ -7378,9 +7507,14 @@ declare function rankProfileCandidates(inputs: readonly ProfileSalienceInput[],
7378
7507
  * Unified Recall API — single retrieval surface above vault + engine.
7379
7508
  *
7380
7509
  * Budget maps to pipeline depth (mirrors Hindsight's tiered defaults):
7381
- * - `low` → V2 cosine + BM25 + recency (no rerank, no decompose)
7510
+ * - `low` → V2 cosine + BM25 + recency (no rerank)
7382
7511
  * - `mid` → V2 + cross-encoder rerank
7383
- * - `high` → V2 + rerank + LLM query decomposition for composite queries
7512
+ * - `high` → V2 + rerank + multi-hop graph traversal
7513
+ *
7514
+ * LLM-free by design (719/B4): query decomposition for composite asks
7515
+ * lives in the tool/agent layer (`createRecallTool`), which may pass
7516
+ * pre-built `subQueries` into this API. `recall()` itself never pays an
7517
+ * LLM RTT.
7384
7518
  *
7385
7519
  * Fact + chunk lanes are fused with RRF (k=60). The previous naive
7386
7520
  * "sort the union by raw score" path is gone — score scales differ
@@ -7435,7 +7569,8 @@ interface RecallToolOptions {
7435
7569
  folderId?: string | null;
7436
7570
  /** Exclude one conversation from chunk results (typically the active one). */
7437
7571
  excludeConversationId?: string;
7438
- /** LLM-decompose options; only used at budget="high". Auth follows the
7572
+ /** LLM-decompose options; only used at budget="high". Runs in THIS tool
7573
+ * executor (719/B4) — `recall()` itself is LLM-free. Auth follows the
7439
7574
  * dual pattern: apiKey (server/CLI) or getToken (browser identity
7440
7575
  * tokens) — at least one required. */
7441
7576
  decomposeOptions?: PortalLlmAuth & {
@@ -9253,4 +9388,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
9253
9388
  */
9254
9389
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
9255
9390
 
9256
- 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 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, 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 MemoryVaultSearchOptions, type MemoryVaultToolOptions, 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 PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, 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, 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, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, 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, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, 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, 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, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
9391
+ 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 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 MemoryVaultSearchOptions, type MemoryVaultToolOptions, 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 PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, 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, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, 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, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, 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, 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, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, 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, xhrTransport };