@anuma/sdk 2.1.0 → 2.2.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.
@@ -49,8 +49,12 @@ import { ResultCallback } from '@nozbe/watermelondb/utils/fp/Result';
49
49
  * rows, grandfathered as compatible with the current model)
50
50
  * - v35: Added conversation_memory table recording which vault memories a
51
51
  * conversation drew on, so the conversation-level Memories panel survives reload
52
+ * - v36: Added topics_extracted_at column to memory_vault — watermark of the last
53
+ * LLM topic-extraction pass, so the background topic worker re-extracts only
54
+ * memories edited since (updated_at > topics_extracted_at) instead of
55
+ * re-running the whole vault
52
56
  */
53
- declare const SDK_SCHEMA_VERSION = 35;
57
+ declare const SDK_SCHEMA_VERSION = 36;
54
58
  /**
55
59
  * Combined WatermelonDB schema for all SDK storage modules.
56
60
  *
@@ -129,6 +133,7 @@ declare const sdkSchema: Readonly<{
129
133
  * - v31 → v32: Added `pinned_at` column to conversations for pinning chats
130
134
  * - v32 → v33: Added `embedding_model` column to memory_vault (null grandfathered as current-model-compatible)
131
135
  * - v34 → v35: Added `conversation_memory` table (conversation ↔ recalled memory ids)
136
+ * - v35 → v36: Added `topics_extracted_at` column to memory_vault (watermark for the background topic-extraction worker; null + existing links grandfathered as extracted)
132
137
  */
133
138
  declare const sdkMigrations: Readonly<{
134
139
  validated: true;
@@ -4096,6 +4101,9 @@ declare class VaultMemory extends Model$1 {
4096
4101
  /** When true, the user has manually set this memory's topics; auto-extraction
4097
4102
  * leaves its entity links alone. Null on legacy rows (treated as false). */
4098
4103
  topicsUserManaged: boolean | null;
4104
+ /** Unix ms of the last LLM topic-extraction pass. Null = never extracted
4105
+ * standalone (linked legacy rows are grandfathered as extracted). */
4106
+ topicsExtractedAt: number | null;
4099
4107
  createdAt: Date;
4100
4108
  updatedAt: Date;
4101
4109
  isDeleted: boolean;
@@ -4199,6 +4207,10 @@ interface StoredVaultMemory {
4199
4207
  /** When true, the user has manually set this memory's topics (entity links);
4200
4208
  * auto-extraction leaves them alone. False on legacy/auto rows. */
4201
4209
  topicsUserManaged: boolean;
4210
+ /** Unix ms of the last LLM topic-extraction pass over this memory's content.
4211
+ * Null = never extracted standalone; rows that already carry entity links
4212
+ * are grandfathered as extracted (see getMemoriesNeedingTopicExtractionOp). */
4213
+ topicsExtractedAt: number | null;
4202
4214
  createdAt: Date;
4203
4215
  updatedAt: Date;
4204
4216
  isDeleted: boolean;
@@ -4317,6 +4329,62 @@ declare function deleteVaultMemoryOp(ctx: VaultMemoryOperationsContext, id: stri
4317
4329
  * Get all non-deleted, unfiled vault memories (folder_id is null).
4318
4330
  */
4319
4331
  declare function getUnfiledVaultMemoriesOp(ctx: VaultMemoryOperationsContext): Promise<StoredVaultMemory[]>;
4332
+ /**
4333
+ * Result of {@link getMemoriesNeedingTopicExtractionOp}: which memories the
4334
+ * background topic worker should run LLM entity extraction on, and which it
4335
+ * should merely stamp as already-extracted.
4336
+ */
4337
+ interface MemoriesNeedingTopicExtraction {
4338
+ /**
4339
+ * Memories to run LLM topic extraction on (decrypted): never-extracted rows
4340
+ * with no entity links, plus stamped rows edited since their last pass
4341
+ * (`updated_at` > `topics_extracted_at`). Edited rows come first (they get
4342
+ * priority under `limit`), each group newest-created first.
4343
+ */
4344
+ pending: StoredVaultMemory[];
4345
+ /**
4346
+ * IDs of rows that already have entity links but no watermark — legacy rows
4347
+ * extracted by the conversation pipeline before v36. Grandfather these with
4348
+ * {@link stampTopicsExtractedAtOp} (no LLM call) so a later content edit
4349
+ * makes them re-extractable instead of invisible forever. Bounded by the
4350
+ * same `limit` as {@link pending} — stamping loads a Model per row, so the
4351
+ * grandfather backlog is drained across sweeps rather than in one spike.
4352
+ */
4353
+ linkedUnstamped: string[];
4354
+ }
4355
+ /**
4356
+ * Sweep query for the background topic-extraction worker: partition the
4357
+ * user's non-deleted, non-user-managed memories by what the worker should do
4358
+ * with them (see {@link MemoriesNeedingTopicExtraction}). User-managed rows
4359
+ * are never returned — the user owns their topics, including an intentionally
4360
+ * empty set. Requires `ctx.entityCtx` for the entity-links check.
4361
+ */
4362
+ declare function getMemoriesNeedingTopicExtractionOp(ctx: VaultMemoryOperationsContext, options?: {
4363
+ limit?: number;
4364
+ }): Promise<MemoriesNeedingTopicExtraction>;
4365
+ /**
4366
+ * Stamp `topics_extracted_at` on the given memories — the topic worker calls
4367
+ * this after a successful extraction pass (including zero-entity results, so
4368
+ * quiet memories aren't re-asked every sweep) and to grandfather
4369
+ * `linkedUnstamped` rows without an LLM call. Preserves `updated_at` so a
4370
+ * stamp never inflates the recency multiplier — and never masks a concurrent
4371
+ * content edit from the next sweep. Skips deleted, foreign-user, and
4372
+ * user-managed rows. Returns the IDs actually stamped.
4373
+ *
4374
+ * ALL eligibility AND `updated_at` are read from the LIVE Model inside the
4375
+ * serialized writer — never a pre-writer snapshot. Writers are serialized, so
4376
+ * a content edit or topic-override that commits before this writer runs is
4377
+ * observed here: its fresh `updated_at` is preserved (so the next sweep's
4378
+ * `updated_at > stamp` check still fires) and a mid-pass user-managed flip
4379
+ * skips the row. Reading `updated_at` from a raw pre-fetch instead would write
4380
+ * a stale value back, pushing `updated_at < topics_extracted_at` and hiding
4381
+ * the edited memory from every future sweep.
4382
+ *
4383
+ * Callers bound the input via `getMemoriesNeedingTopicExtractionOp`'s `limit`
4384
+ * (both `pending` and `linkedUnstamped` are capped), so the per-row Model load
4385
+ * needed to `prepareUpdate` stays bounded and never spikes the RecordCache.
4386
+ */
4387
+ declare function stampTopicsExtractedAtOp(ctx: VaultMemoryOperationsContext, memoryIds: readonly string[], extractedAt: number): Promise<string[]>;
4320
4388
  declare function deleteAllVaultMemoriesForUserOp(ctx: VaultMemoryOperationsContext, userId: string): Promise<number>;
4321
4389
  declare function updateVaultMemoryEmbeddingOp(ctx: VaultMemoryOperationsContext, id: string, embedding: string, embeddingModel: string): Promise<boolean>;
4322
4390
 
@@ -6341,6 +6409,112 @@ interface ReflectResult {
6341
6409
  */
6342
6410
  declare function reflect(query: string, ctx: RecallContext, options: ReflectOptions): Promise<ReflectResult>;
6343
6411
 
6412
+ /**
6413
+ * Standalone topic (entity) extraction for EXISTING memories.
6414
+ *
6415
+ * The conversation pipeline (autoExtract.ts) assigns entities only to facts it
6416
+ * extracts from a live transcript — manually created, imported, and edited
6417
+ * memories never get LLM topics and used to fall back to a client-side regex.
6418
+ * This module is the LLM half of "continuously LLM-managed topics": a batched
6419
+ * pass that takes memories already in the vault, asks the extraction model for
6420
+ * their named entities, REPLACES their auto-managed links (guarded — a manual
6421
+ * edit or delete always wins), and stamps `topics_extracted_at` so the sweep
6422
+ * query (`getMemoriesNeedingTopicExtractionOp`) only revisits edited memories.
6423
+ *
6424
+ * Batching: memories are classified ~10 per LLM call (mirroring the folder
6425
+ * Auto-Sort harness) with per-memory content truncation, so a whole-vault
6426
+ * backfill or a bulk import costs ceil(n/10) requests, not n.
6427
+ */
6428
+
6429
+ /** Memories per LLM call. Mirrors the folder Auto-Sort batch size — the cost
6430
+ * lever that makes a whole-vault backfill viable. */
6431
+ declare const TOPIC_EXTRACTION_BATCH_SIZE = 10;
6432
+ /** One memory to extract topics for. `content` must be the DECRYPTED text. */
6433
+ interface TopicExtractionInput {
6434
+ id: string;
6435
+ content: string;
6436
+ }
6437
+ /**
6438
+ * Options for the topic-extraction LLM call. Auth follows the portal dual
6439
+ * pattern — one of `apiKey` / `getToken` is required (see {@link PortalLlmAuth}).
6440
+ */
6441
+ interface TopicExtractOptions extends PortalLlmAuth {
6442
+ baseUrl?: string;
6443
+ /** Defaults to {@link DEFAULT_EXTRACTION_MODEL} — the sanctioned extraction
6444
+ * model. Don't point this at a second model without an eval. */
6445
+ model?: string;
6446
+ /** Override the global fetch implementation (useful for tests). */
6447
+ fetchFn?: typeof fetch;
6448
+ maxAttempts?: number;
6449
+ timeoutMs?: number;
6450
+ totalTimeoutMs?: number;
6451
+ backoffMs?: (attempt: number) => number;
6452
+ /**
6453
+ * The user's existing entity vocabulary (canonical names). Included in the
6454
+ * prompt so independent batches reuse canonical names instead of fragmenting
6455
+ * ("ZetaChain" / "Zetachain" / "zeta chain" as three graph nodes). Truncated
6456
+ * to the first {@link MAX_VOCABULARY_NAMES} names — pass the most-linked
6457
+ * names first.
6458
+ */
6459
+ existingEntityNames?: readonly string[];
6460
+ /**
6461
+ * When set, PII in memory contents is replaced with tagged placeholders
6462
+ * before the LLM call and returned entity names are de-anonymized (entities
6463
+ * whose placeholders can't be restored are dropped) — mirrors
6464
+ * `ExtractFactsOptions.piiRedaction`. Vault contents hold REAL values, so
6465
+ * callers that redact the conversation pipeline must redact this pass too.
6466
+ */
6467
+ piiRedaction?: boolean | PiiRedactor;
6468
+ }
6469
+ /**
6470
+ * Ask the extraction LLM for the named entities of each memory, in batches of
6471
+ * {@link TOPIC_EXTRACTION_BATCH_SIZE}. Pure LLM step — no persistence.
6472
+ *
6473
+ * Returns memoryId → entities. A memory PRESENT with an empty array is a
6474
+ * successful, explicit "no named entities" answer; a memory ABSENT from the
6475
+ * map is UNANSWERED — its batch failed after retries, returned an unusable
6476
+ * shape, or the model omitted its id. Callers must retry absent ids in a
6477
+ * later sweep, never stamp them.
6478
+ */
6479
+ declare function extractEntitiesForMemories(memories: readonly TopicExtractionInput[], options: TopicExtractOptions): Promise<Map<string, ExtractedEntity[]>>;
6480
+ /** Outcome of one {@link extractAndLinkEntitiesForMemoriesOp} run. */
6481
+ interface TopicExtractionRunResult {
6482
+ /** memoryId → entities the LLM returned (post-validation, post-linking). */
6483
+ entitiesByMemory: Map<string, ExtractedEntity[]>;
6484
+ /** Memories stamped `topics_extracted_at` this run — includes zero-entity
6485
+ * results so quiet memories aren't re-asked every sweep. */
6486
+ stampedIds: string[];
6487
+ /** Memories NOT processed: missing/deleted/foreign rows, user-managed rows
6488
+ * (including ones that became user-managed mid-run), and members of failed
6489
+ * LLM batches. Skipped ids are not stamped, so failed batches are retried
6490
+ * by a later sweep — callers should apply their own attempt caps. */
6491
+ skippedIds: string[];
6492
+ }
6493
+ /**
6494
+ * Run LLM topic extraction over existing vault memories and persist the
6495
+ * results: REPLACE each memory's auto-managed entity links with the extracted
6496
+ * set (via {@link replaceMemoryEntitiesGuardedOp} — an edited memory drops the
6497
+ * entities its previous content mentioned) and stamp `topics_extracted_at`.
6498
+ *
6499
+ * User intent is enforced twice: rows already user-managed are skipped up
6500
+ * front, and the replace write re-checks the vault row INSIDE its writer
6501
+ * (user-managed / deleted / absent ⇒ null, and the memory is neither linked
6502
+ * nor stamped) so a manual topic edit or delete landing during the LLM
6503
+ * round-trip wins — a manual edit's own replace semantics also erase anything
6504
+ * this pass linked just before it. The watermark is captured BEFORE contents
6505
+ * are read: an edit landing mid-run keeps `updated_at` > stamp, so the next
6506
+ * sweep re-extracts it rather than trusting this run's stale read.
6507
+ *
6508
+ * Requires `ctx.entityCtx`. Contents are decrypted via the ctx's wallet
6509
+ * fields, exactly like the vault read ops; a memory whose decryption fails is
6510
+ * skipped (retried next sweep), not fatal to the run.
6511
+ */
6512
+ declare function extractAndLinkEntitiesForMemoriesOp(ctx: VaultMemoryOperationsContext, memoryIds: readonly string[], options: TopicExtractOptions & {
6513
+ /** Watermark timestamp (Unix ms) recorded as `topics_extracted_at`.
6514
+ * Defaults to now; tests pass a fixed value. */
6515
+ now?: number;
6516
+ }): Promise<TopicExtractionRunResult>;
6517
+
6344
6518
  /**
6345
6519
  * Queue Types
6346
6520
  *
@@ -7335,4 +7509,4 @@ declare function sanitizeQuotes(s: string): string;
7335
7509
  declare function renderTemplate(value: string | null | undefined, template: string): string | null;
7336
7510
  declare function buildSystemPrompt(ctx: PromptContext, options?: BuildPromptOptions): BuildPromptResult;
7337
7511
 
7338
- export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndRetain, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, streamCancelPath, streamReplayPath, summaryToSystemMessage, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };
7512
+ export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summaryToSystemMessage, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };
@@ -49,8 +49,12 @@ import { ResultCallback } from '@nozbe/watermelondb/utils/fp/Result';
49
49
  * rows, grandfathered as compatible with the current model)
50
50
  * - v35: Added conversation_memory table recording which vault memories a
51
51
  * conversation drew on, so the conversation-level Memories panel survives reload
52
+ * - v36: Added topics_extracted_at column to memory_vault — watermark of the last
53
+ * LLM topic-extraction pass, so the background topic worker re-extracts only
54
+ * memories edited since (updated_at > topics_extracted_at) instead of
55
+ * re-running the whole vault
52
56
  */
53
- declare const SDK_SCHEMA_VERSION = 35;
57
+ declare const SDK_SCHEMA_VERSION = 36;
54
58
  /**
55
59
  * Combined WatermelonDB schema for all SDK storage modules.
56
60
  *
@@ -129,6 +133,7 @@ declare const sdkSchema: Readonly<{
129
133
  * - v31 → v32: Added `pinned_at` column to conversations for pinning chats
130
134
  * - v32 → v33: Added `embedding_model` column to memory_vault (null grandfathered as current-model-compatible)
131
135
  * - v34 → v35: Added `conversation_memory` table (conversation ↔ recalled memory ids)
136
+ * - v35 → v36: Added `topics_extracted_at` column to memory_vault (watermark for the background topic-extraction worker; null + existing links grandfathered as extracted)
132
137
  */
133
138
  declare const sdkMigrations: Readonly<{
134
139
  validated: true;
@@ -4096,6 +4101,9 @@ declare class VaultMemory extends Model$1 {
4096
4101
  /** When true, the user has manually set this memory's topics; auto-extraction
4097
4102
  * leaves its entity links alone. Null on legacy rows (treated as false). */
4098
4103
  topicsUserManaged: boolean | null;
4104
+ /** Unix ms of the last LLM topic-extraction pass. Null = never extracted
4105
+ * standalone (linked legacy rows are grandfathered as extracted). */
4106
+ topicsExtractedAt: number | null;
4099
4107
  createdAt: Date;
4100
4108
  updatedAt: Date;
4101
4109
  isDeleted: boolean;
@@ -4199,6 +4207,10 @@ interface StoredVaultMemory {
4199
4207
  /** When true, the user has manually set this memory's topics (entity links);
4200
4208
  * auto-extraction leaves them alone. False on legacy/auto rows. */
4201
4209
  topicsUserManaged: boolean;
4210
+ /** Unix ms of the last LLM topic-extraction pass over this memory's content.
4211
+ * Null = never extracted standalone; rows that already carry entity links
4212
+ * are grandfathered as extracted (see getMemoriesNeedingTopicExtractionOp). */
4213
+ topicsExtractedAt: number | null;
4202
4214
  createdAt: Date;
4203
4215
  updatedAt: Date;
4204
4216
  isDeleted: boolean;
@@ -4317,6 +4329,62 @@ declare function deleteVaultMemoryOp(ctx: VaultMemoryOperationsContext, id: stri
4317
4329
  * Get all non-deleted, unfiled vault memories (folder_id is null).
4318
4330
  */
4319
4331
  declare function getUnfiledVaultMemoriesOp(ctx: VaultMemoryOperationsContext): Promise<StoredVaultMemory[]>;
4332
+ /**
4333
+ * Result of {@link getMemoriesNeedingTopicExtractionOp}: which memories the
4334
+ * background topic worker should run LLM entity extraction on, and which it
4335
+ * should merely stamp as already-extracted.
4336
+ */
4337
+ interface MemoriesNeedingTopicExtraction {
4338
+ /**
4339
+ * Memories to run LLM topic extraction on (decrypted): never-extracted rows
4340
+ * with no entity links, plus stamped rows edited since their last pass
4341
+ * (`updated_at` > `topics_extracted_at`). Edited rows come first (they get
4342
+ * priority under `limit`), each group newest-created first.
4343
+ */
4344
+ pending: StoredVaultMemory[];
4345
+ /**
4346
+ * IDs of rows that already have entity links but no watermark — legacy rows
4347
+ * extracted by the conversation pipeline before v36. Grandfather these with
4348
+ * {@link stampTopicsExtractedAtOp} (no LLM call) so a later content edit
4349
+ * makes them re-extractable instead of invisible forever. Bounded by the
4350
+ * same `limit` as {@link pending} — stamping loads a Model per row, so the
4351
+ * grandfather backlog is drained across sweeps rather than in one spike.
4352
+ */
4353
+ linkedUnstamped: string[];
4354
+ }
4355
+ /**
4356
+ * Sweep query for the background topic-extraction worker: partition the
4357
+ * user's non-deleted, non-user-managed memories by what the worker should do
4358
+ * with them (see {@link MemoriesNeedingTopicExtraction}). User-managed rows
4359
+ * are never returned — the user owns their topics, including an intentionally
4360
+ * empty set. Requires `ctx.entityCtx` for the entity-links check.
4361
+ */
4362
+ declare function getMemoriesNeedingTopicExtractionOp(ctx: VaultMemoryOperationsContext, options?: {
4363
+ limit?: number;
4364
+ }): Promise<MemoriesNeedingTopicExtraction>;
4365
+ /**
4366
+ * Stamp `topics_extracted_at` on the given memories — the topic worker calls
4367
+ * this after a successful extraction pass (including zero-entity results, so
4368
+ * quiet memories aren't re-asked every sweep) and to grandfather
4369
+ * `linkedUnstamped` rows without an LLM call. Preserves `updated_at` so a
4370
+ * stamp never inflates the recency multiplier — and never masks a concurrent
4371
+ * content edit from the next sweep. Skips deleted, foreign-user, and
4372
+ * user-managed rows. Returns the IDs actually stamped.
4373
+ *
4374
+ * ALL eligibility AND `updated_at` are read from the LIVE Model inside the
4375
+ * serialized writer — never a pre-writer snapshot. Writers are serialized, so
4376
+ * a content edit or topic-override that commits before this writer runs is
4377
+ * observed here: its fresh `updated_at` is preserved (so the next sweep's
4378
+ * `updated_at > stamp` check still fires) and a mid-pass user-managed flip
4379
+ * skips the row. Reading `updated_at` from a raw pre-fetch instead would write
4380
+ * a stale value back, pushing `updated_at < topics_extracted_at` and hiding
4381
+ * the edited memory from every future sweep.
4382
+ *
4383
+ * Callers bound the input via `getMemoriesNeedingTopicExtractionOp`'s `limit`
4384
+ * (both `pending` and `linkedUnstamped` are capped), so the per-row Model load
4385
+ * needed to `prepareUpdate` stays bounded and never spikes the RecordCache.
4386
+ */
4387
+ declare function stampTopicsExtractedAtOp(ctx: VaultMemoryOperationsContext, memoryIds: readonly string[], extractedAt: number): Promise<string[]>;
4320
4388
  declare function deleteAllVaultMemoriesForUserOp(ctx: VaultMemoryOperationsContext, userId: string): Promise<number>;
4321
4389
  declare function updateVaultMemoryEmbeddingOp(ctx: VaultMemoryOperationsContext, id: string, embedding: string, embeddingModel: string): Promise<boolean>;
4322
4390
 
@@ -6341,6 +6409,112 @@ interface ReflectResult {
6341
6409
  */
6342
6410
  declare function reflect(query: string, ctx: RecallContext, options: ReflectOptions): Promise<ReflectResult>;
6343
6411
 
6412
+ /**
6413
+ * Standalone topic (entity) extraction for EXISTING memories.
6414
+ *
6415
+ * The conversation pipeline (autoExtract.ts) assigns entities only to facts it
6416
+ * extracts from a live transcript — manually created, imported, and edited
6417
+ * memories never get LLM topics and used to fall back to a client-side regex.
6418
+ * This module is the LLM half of "continuously LLM-managed topics": a batched
6419
+ * pass that takes memories already in the vault, asks the extraction model for
6420
+ * their named entities, REPLACES their auto-managed links (guarded — a manual
6421
+ * edit or delete always wins), and stamps `topics_extracted_at` so the sweep
6422
+ * query (`getMemoriesNeedingTopicExtractionOp`) only revisits edited memories.
6423
+ *
6424
+ * Batching: memories are classified ~10 per LLM call (mirroring the folder
6425
+ * Auto-Sort harness) with per-memory content truncation, so a whole-vault
6426
+ * backfill or a bulk import costs ceil(n/10) requests, not n.
6427
+ */
6428
+
6429
+ /** Memories per LLM call. Mirrors the folder Auto-Sort batch size — the cost
6430
+ * lever that makes a whole-vault backfill viable. */
6431
+ declare const TOPIC_EXTRACTION_BATCH_SIZE = 10;
6432
+ /** One memory to extract topics for. `content` must be the DECRYPTED text. */
6433
+ interface TopicExtractionInput {
6434
+ id: string;
6435
+ content: string;
6436
+ }
6437
+ /**
6438
+ * Options for the topic-extraction LLM call. Auth follows the portal dual
6439
+ * pattern — one of `apiKey` / `getToken` is required (see {@link PortalLlmAuth}).
6440
+ */
6441
+ interface TopicExtractOptions extends PortalLlmAuth {
6442
+ baseUrl?: string;
6443
+ /** Defaults to {@link DEFAULT_EXTRACTION_MODEL} — the sanctioned extraction
6444
+ * model. Don't point this at a second model without an eval. */
6445
+ model?: string;
6446
+ /** Override the global fetch implementation (useful for tests). */
6447
+ fetchFn?: typeof fetch;
6448
+ maxAttempts?: number;
6449
+ timeoutMs?: number;
6450
+ totalTimeoutMs?: number;
6451
+ backoffMs?: (attempt: number) => number;
6452
+ /**
6453
+ * The user's existing entity vocabulary (canonical names). Included in the
6454
+ * prompt so independent batches reuse canonical names instead of fragmenting
6455
+ * ("ZetaChain" / "Zetachain" / "zeta chain" as three graph nodes). Truncated
6456
+ * to the first {@link MAX_VOCABULARY_NAMES} names — pass the most-linked
6457
+ * names first.
6458
+ */
6459
+ existingEntityNames?: readonly string[];
6460
+ /**
6461
+ * When set, PII in memory contents is replaced with tagged placeholders
6462
+ * before the LLM call and returned entity names are de-anonymized (entities
6463
+ * whose placeholders can't be restored are dropped) — mirrors
6464
+ * `ExtractFactsOptions.piiRedaction`. Vault contents hold REAL values, so
6465
+ * callers that redact the conversation pipeline must redact this pass too.
6466
+ */
6467
+ piiRedaction?: boolean | PiiRedactor;
6468
+ }
6469
+ /**
6470
+ * Ask the extraction LLM for the named entities of each memory, in batches of
6471
+ * {@link TOPIC_EXTRACTION_BATCH_SIZE}. Pure LLM step — no persistence.
6472
+ *
6473
+ * Returns memoryId → entities. A memory PRESENT with an empty array is a
6474
+ * successful, explicit "no named entities" answer; a memory ABSENT from the
6475
+ * map is UNANSWERED — its batch failed after retries, returned an unusable
6476
+ * shape, or the model omitted its id. Callers must retry absent ids in a
6477
+ * later sweep, never stamp them.
6478
+ */
6479
+ declare function extractEntitiesForMemories(memories: readonly TopicExtractionInput[], options: TopicExtractOptions): Promise<Map<string, ExtractedEntity[]>>;
6480
+ /** Outcome of one {@link extractAndLinkEntitiesForMemoriesOp} run. */
6481
+ interface TopicExtractionRunResult {
6482
+ /** memoryId → entities the LLM returned (post-validation, post-linking). */
6483
+ entitiesByMemory: Map<string, ExtractedEntity[]>;
6484
+ /** Memories stamped `topics_extracted_at` this run — includes zero-entity
6485
+ * results so quiet memories aren't re-asked every sweep. */
6486
+ stampedIds: string[];
6487
+ /** Memories NOT processed: missing/deleted/foreign rows, user-managed rows
6488
+ * (including ones that became user-managed mid-run), and members of failed
6489
+ * LLM batches. Skipped ids are not stamped, so failed batches are retried
6490
+ * by a later sweep — callers should apply their own attempt caps. */
6491
+ skippedIds: string[];
6492
+ }
6493
+ /**
6494
+ * Run LLM topic extraction over existing vault memories and persist the
6495
+ * results: REPLACE each memory's auto-managed entity links with the extracted
6496
+ * set (via {@link replaceMemoryEntitiesGuardedOp} — an edited memory drops the
6497
+ * entities its previous content mentioned) and stamp `topics_extracted_at`.
6498
+ *
6499
+ * User intent is enforced twice: rows already user-managed are skipped up
6500
+ * front, and the replace write re-checks the vault row INSIDE its writer
6501
+ * (user-managed / deleted / absent ⇒ null, and the memory is neither linked
6502
+ * nor stamped) so a manual topic edit or delete landing during the LLM
6503
+ * round-trip wins — a manual edit's own replace semantics also erase anything
6504
+ * this pass linked just before it. The watermark is captured BEFORE contents
6505
+ * are read: an edit landing mid-run keeps `updated_at` > stamp, so the next
6506
+ * sweep re-extracts it rather than trusting this run's stale read.
6507
+ *
6508
+ * Requires `ctx.entityCtx`. Contents are decrypted via the ctx's wallet
6509
+ * fields, exactly like the vault read ops; a memory whose decryption fails is
6510
+ * skipped (retried next sweep), not fatal to the run.
6511
+ */
6512
+ declare function extractAndLinkEntitiesForMemoriesOp(ctx: VaultMemoryOperationsContext, memoryIds: readonly string[], options: TopicExtractOptions & {
6513
+ /** Watermark timestamp (Unix ms) recorded as `topics_extracted_at`.
6514
+ * Defaults to now; tests pass a fixed value. */
6515
+ now?: number;
6516
+ }): Promise<TopicExtractionRunResult>;
6517
+
6344
6518
  /**
6345
6519
  * Queue Types
6346
6520
  *
@@ -7335,4 +7509,4 @@ declare function sanitizeQuotes(s: string): string;
7335
7509
  declare function renderTemplate(value: string | null | undefined, template: string): string | null;
7336
7510
  declare function buildSystemPrompt(ctx: PromptContext, options?: BuildPromptOptions): BuildPromptResult;
7337
7511
 
7338
- export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndRetain, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, streamCancelPath, streamReplayPath, summaryToSystemMessage, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };
7512
+ export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summaryToSystemMessage, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };