@anuma/sdk 6.40.0 → 6.42.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.
- package/dist/expo/index.cjs +169 -83
- package/dist/expo/index.d.mts +38 -1
- package/dist/expo/index.d.ts +38 -1
- package/dist/expo/index.mjs +166 -83
- package/dist/memory/context.d.mts +2 -0
- package/dist/memory/context.d.ts +2 -0
- package/dist/react/index.cjs +131 -43
- package/dist/react/index.d.mts +38 -1
- package/dist/react/index.d.ts +38 -1
- package/dist/react/index.mjs +128 -43
- package/dist/server/index.cjs +108 -40
- package/dist/server/index.d.mts +16 -0
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.mjs +108 -40
- package/package.json +1 -1
package/dist/expo/index.d.ts
CHANGED
|
@@ -3201,7 +3201,30 @@ interface StoredTopic {
|
|
|
3201
3201
|
name: string;
|
|
3202
3202
|
kind?: string;
|
|
3203
3203
|
source: TopicSource;
|
|
3204
|
+
/** How central the topic is to the memory, in (0, 1]; read it with {@link topicWeight}. */
|
|
3205
|
+
weight?: number;
|
|
3204
3206
|
}
|
|
3207
|
+
/**
|
|
3208
|
+
* Fixed weight per salience level the topic extractor assigns.
|
|
3209
|
+
* @public
|
|
3210
|
+
*/
|
|
3211
|
+
declare const TOPIC_SALIENCE_WEIGHTS: {
|
|
3212
|
+
readonly primary: 1;
|
|
3213
|
+
readonly secondary: 0.6;
|
|
3214
|
+
readonly mention: 0.3;
|
|
3215
|
+
};
|
|
3216
|
+
/** @public */
|
|
3217
|
+
type TopicSalience = keyof typeof TOPIC_SALIENCE_WEIGHTS;
|
|
3218
|
+
/**
|
|
3219
|
+
* A topic's weight: 1 when it is user-set or carries no weight.
|
|
3220
|
+
* @public
|
|
3221
|
+
*/
|
|
3222
|
+
declare function topicWeight(topic: StoredTopic): number;
|
|
3223
|
+
/**
|
|
3224
|
+
* The first topic with the highest weight, or null when there are none.
|
|
3225
|
+
* @public
|
|
3226
|
+
*/
|
|
3227
|
+
declare function primaryTopic(topics: readonly StoredTopic[] | null | undefined): StoredTopic | null;
|
|
3205
3228
|
|
|
3206
3229
|
/**
|
|
3207
3230
|
* Accepted entity shape for {@link linkMemoryEntitiesOp}. A bare string is
|
|
@@ -3212,6 +3235,7 @@ interface StoredTopic {
|
|
|
3212
3235
|
type EntityInput = string | {
|
|
3213
3236
|
name: string;
|
|
3214
3237
|
kind?: EntityKind | (string & {});
|
|
3238
|
+
weight?: number;
|
|
3215
3239
|
};
|
|
3216
3240
|
interface EntityOperationsContext {
|
|
3217
3241
|
database: Database;
|
|
@@ -4920,6 +4944,7 @@ interface AutoExtractMessage {
|
|
|
4920
4944
|
interface ExtractedEntity {
|
|
4921
4945
|
name: string;
|
|
4922
4946
|
kind?: EntityKind;
|
|
4947
|
+
weight?: number;
|
|
4923
4948
|
}
|
|
4924
4949
|
interface ExtractedCandidate {
|
|
4925
4950
|
content: string;
|
|
@@ -9796,6 +9821,12 @@ interface ProfileDoc {
|
|
|
9796
9821
|
* without another LLM pass. Recomputed every synthesis (not delta-cached).
|
|
9797
9822
|
*/
|
|
9798
9823
|
observationTrends: Record<ObservationTrend, number>;
|
|
9824
|
+
/**
|
|
9825
|
+
* Sorted ids the store listed but could not decrypt at synthesis time.
|
|
9826
|
+
* Absent when every memory was readable. A later call regenerates only when
|
|
9827
|
+
* this set changes, and attributes a memory once it becomes readable.
|
|
9828
|
+
*/
|
|
9829
|
+
unreadableMemoryIds?: string[];
|
|
9799
9830
|
/** Unix ms this doc was produced. */
|
|
9800
9831
|
generatedAt: number;
|
|
9801
9832
|
}
|
|
@@ -9849,6 +9880,12 @@ interface SynthesizeProfileOptions extends PortalLlmAuth {
|
|
|
9849
9880
|
* never accidentally disable the gate by finding it empty.
|
|
9850
9881
|
*/
|
|
9851
9882
|
reviewedMemoryIds?: readonly string[];
|
|
9883
|
+
/**
|
|
9884
|
+
* Read facts and recall through this store instead of `ctx.vaultCtx` and
|
|
9885
|
+
* `ctx.vaultCache`, so a remote store works. Only `ctx.embeddingOptions` is
|
|
9886
|
+
* then read from `ctx`.
|
|
9887
|
+
*/
|
|
9888
|
+
store?: Pick<MemoryStore, "list" | "listProjections" | "factSource">;
|
|
9852
9889
|
}
|
|
9853
9890
|
/**
|
|
9854
9891
|
* Synthesize a shareable {@link ProfileDoc} from the user's vault, on-device.
|
|
@@ -11298,4 +11335,4 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
11298
11335
|
*/
|
|
11299
11336
|
declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
|
|
11300
11337
|
|
|
11301
|
-
export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, 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, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, 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 LocalMemoryStoreOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCreate, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, 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 StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearModelsCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, memoryCipher, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
|
|
11338
|
+
export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, 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, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, 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 LocalMemoryStoreOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCreate, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, 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 StoredTopic, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TOPIC_SALIENCE_WEIGHTS, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSalience, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearModelsCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, memoryCipher, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, primaryTopic, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, topicWeight, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
|
package/dist/expo/index.mjs
CHANGED
|
@@ -9333,6 +9333,62 @@ async function clearConversationMemoriesOp(ctx, conversationId) {
|
|
|
9333
9333
|
});
|
|
9334
9334
|
}
|
|
9335
9335
|
|
|
9336
|
+
// src/lib/db/entities/types.ts
|
|
9337
|
+
var ENTITY_KINDS = [
|
|
9338
|
+
"person",
|
|
9339
|
+
"organization",
|
|
9340
|
+
"place",
|
|
9341
|
+
"event",
|
|
9342
|
+
"product",
|
|
9343
|
+
"thing",
|
|
9344
|
+
"concept",
|
|
9345
|
+
"other"
|
|
9346
|
+
];
|
|
9347
|
+
function normalizeEntityName(name) {
|
|
9348
|
+
return name.trim().toLowerCase();
|
|
9349
|
+
}
|
|
9350
|
+
var TOPIC_SALIENCE_WEIGHTS = { primary: 1, secondary: 0.6, mention: 0.3 };
|
|
9351
|
+
function topicWeight(topic) {
|
|
9352
|
+
return topic.source === "user" ? 1 : topic.weight ?? 1;
|
|
9353
|
+
}
|
|
9354
|
+
function primaryTopic(topics) {
|
|
9355
|
+
let best = null;
|
|
9356
|
+
for (const topic of topics ?? []) {
|
|
9357
|
+
if (best === null || topicWeight(topic) > topicWeight(best)) best = topic;
|
|
9358
|
+
}
|
|
9359
|
+
return best;
|
|
9360
|
+
}
|
|
9361
|
+
function parseTopicWeight(value) {
|
|
9362
|
+
return typeof value === "number" && value > 0 && value <= 1 ? value : void 0;
|
|
9363
|
+
}
|
|
9364
|
+
function serializeTopics(topics) {
|
|
9365
|
+
return JSON.stringify(topics);
|
|
9366
|
+
}
|
|
9367
|
+
function parseTopics(value) {
|
|
9368
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
9369
|
+
let parsed;
|
|
9370
|
+
try {
|
|
9371
|
+
parsed = JSON.parse(value);
|
|
9372
|
+
} catch {
|
|
9373
|
+
return null;
|
|
9374
|
+
}
|
|
9375
|
+
if (!Array.isArray(parsed)) return null;
|
|
9376
|
+
const out = [];
|
|
9377
|
+
for (const raw of parsed) {
|
|
9378
|
+
if (typeof raw !== "object" || raw === null) continue;
|
|
9379
|
+
const { name, kind, source, weight } = raw;
|
|
9380
|
+
if (typeof name !== "string" || name.trim().length === 0) continue;
|
|
9381
|
+
const parsedWeight = parseTopicWeight(weight);
|
|
9382
|
+
out.push({
|
|
9383
|
+
name,
|
|
9384
|
+
...typeof kind === "string" && kind.length > 0 ? { kind } : {},
|
|
9385
|
+
source: source === "user" ? "user" : "auto",
|
|
9386
|
+
...parsedWeight !== void 0 ? { weight: parsedWeight } : {}
|
|
9387
|
+
});
|
|
9388
|
+
}
|
|
9389
|
+
return out;
|
|
9390
|
+
}
|
|
9391
|
+
|
|
9336
9392
|
// src/lib/db/manager.ts
|
|
9337
9393
|
import { Database } from "@nozbe/watermelondb";
|
|
9338
9394
|
|
|
@@ -10689,48 +10745,6 @@ import { Q as Q5 } from "@nozbe/watermelondb";
|
|
|
10689
10745
|
|
|
10690
10746
|
// src/lib/db/entities/operations.ts
|
|
10691
10747
|
import { Q as Q4 } from "@nozbe/watermelondb";
|
|
10692
|
-
|
|
10693
|
-
// src/lib/db/entities/types.ts
|
|
10694
|
-
var ENTITY_KINDS = [
|
|
10695
|
-
"person",
|
|
10696
|
-
"organization",
|
|
10697
|
-
"place",
|
|
10698
|
-
"event",
|
|
10699
|
-
"product",
|
|
10700
|
-
"thing",
|
|
10701
|
-
"concept",
|
|
10702
|
-
"other"
|
|
10703
|
-
];
|
|
10704
|
-
function normalizeEntityName(name) {
|
|
10705
|
-
return name.trim().toLowerCase();
|
|
10706
|
-
}
|
|
10707
|
-
function serializeTopics(topics) {
|
|
10708
|
-
return JSON.stringify(topics);
|
|
10709
|
-
}
|
|
10710
|
-
function parseTopics(value) {
|
|
10711
|
-
if (typeof value !== "string" || value.length === 0) return null;
|
|
10712
|
-
let parsed;
|
|
10713
|
-
try {
|
|
10714
|
-
parsed = JSON.parse(value);
|
|
10715
|
-
} catch {
|
|
10716
|
-
return null;
|
|
10717
|
-
}
|
|
10718
|
-
if (!Array.isArray(parsed)) return null;
|
|
10719
|
-
const out = [];
|
|
10720
|
-
for (const raw of parsed) {
|
|
10721
|
-
if (typeof raw !== "object" || raw === null) continue;
|
|
10722
|
-
const { name, kind, source } = raw;
|
|
10723
|
-
if (typeof name !== "string" || name.trim().length === 0) continue;
|
|
10724
|
-
out.push({
|
|
10725
|
-
name,
|
|
10726
|
-
...typeof kind === "string" && kind.length > 0 ? { kind } : {},
|
|
10727
|
-
source: source === "user" ? "user" : "auto"
|
|
10728
|
-
});
|
|
10729
|
-
}
|
|
10730
|
-
return out;
|
|
10731
|
-
}
|
|
10732
|
-
|
|
10733
|
-
// src/lib/db/entities/operations.ts
|
|
10734
10748
|
function entityToStored(e) {
|
|
10735
10749
|
return {
|
|
10736
10750
|
uniqueId: e.id,
|
|
@@ -10811,21 +10825,47 @@ function displayNamesOf(entities) {
|
|
|
10811
10825
|
}
|
|
10812
10826
|
function topicsEqual(stored2, computed) {
|
|
10813
10827
|
if (stored2 === null || stored2.length !== computed.length) return false;
|
|
10814
|
-
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source]);
|
|
10828
|
+
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source, t.weight ?? null]);
|
|
10815
10829
|
const storedKeys = stored2.map(key).sort();
|
|
10816
10830
|
const computedKeys = computed.map(key).sort();
|
|
10817
10831
|
return storedKeys.every((k, i) => k === computedKeys[i]);
|
|
10818
10832
|
}
|
|
10819
|
-
function resolveTopicsWrite(row, linked,
|
|
10833
|
+
function resolveTopicsWrite(row, linked, inputs, source, mode) {
|
|
10820
10834
|
if (row === null || source === null) return null;
|
|
10821
|
-
const
|
|
10822
|
-
|
|
10835
|
+
const stored2 = parseTopics(row.topics);
|
|
10836
|
+
const carried = mode === "merge" ? stored2 : null;
|
|
10837
|
+
const weights = source === "auto" ? weightsOf(carried, inputs) : null;
|
|
10838
|
+
const displayNames = displayNamesOf([...inputs, ...carried ?? []]);
|
|
10839
|
+
const topics = topicsForEntities(linked, displayNames, source, weights);
|
|
10840
|
+
if (topicsEqual(stored2, topics)) return null;
|
|
10823
10841
|
return { row, topics };
|
|
10824
10842
|
}
|
|
10825
|
-
function
|
|
10843
|
+
function weightsOf(stored2, inputs) {
|
|
10844
|
+
const out = /* @__PURE__ */ new Map();
|
|
10845
|
+
for (const topic of stored2 ?? []) out.set(normalizeEntityName(topic.name), topic.weight);
|
|
10846
|
+
for (const input of inputs) {
|
|
10847
|
+
const weight = parseTopicWeight(input.weight);
|
|
10848
|
+
if (weight === void 0) continue;
|
|
10849
|
+
const name = normalizeEntityName(input.name);
|
|
10850
|
+
if (!out.has(name)) {
|
|
10851
|
+
out.set(name, weight);
|
|
10852
|
+
continue;
|
|
10853
|
+
}
|
|
10854
|
+
const current = out.get(name);
|
|
10855
|
+
if (current !== void 0 && weight > current) out.set(name, weight);
|
|
10856
|
+
}
|
|
10857
|
+
return out;
|
|
10858
|
+
}
|
|
10859
|
+
function topicsForEntities(entities, displayNames, source, weights) {
|
|
10826
10860
|
return entities.map((e) => {
|
|
10827
10861
|
const name = displayNames.get(e.canonicalName) ?? e.canonicalName;
|
|
10828
|
-
|
|
10862
|
+
const weight = weights?.get(e.canonicalName);
|
|
10863
|
+
return {
|
|
10864
|
+
name,
|
|
10865
|
+
...e.kind ? { kind: e.kind } : {},
|
|
10866
|
+
source,
|
|
10867
|
+
...weight !== void 0 ? { weight } : {}
|
|
10868
|
+
};
|
|
10829
10869
|
});
|
|
10830
10870
|
}
|
|
10831
10871
|
function toEntityObjects(entityInputs) {
|
|
@@ -10833,7 +10873,7 @@ function toEntityObjects(entityInputs) {
|
|
|
10833
10873
|
}
|
|
10834
10874
|
async function resolveMemoryTopicsWrite(ctx, memoryId, linked, inputs, source) {
|
|
10835
10875
|
const row = await findVaultRowInWrite(ctx, memoryId);
|
|
10836
|
-
return resolveTopicsWrite(row, linked,
|
|
10876
|
+
return resolveTopicsWrite(row, linked, toEntityObjects(inputs), source, "replace");
|
|
10837
10877
|
}
|
|
10838
10878
|
function prepareMemoryTopicsUpdate(write) {
|
|
10839
10879
|
return prepareTopicsUpdate(write.row, write.topics, Date.now());
|
|
@@ -10871,8 +10911,9 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
|
|
|
10871
10911
|
const topicsWrite = resolveTopicsWrite(
|
|
10872
10912
|
vaultRow,
|
|
10873
10913
|
[...carriedOver, ...entities],
|
|
10874
|
-
|
|
10875
|
-
options?.topicsSource ?? "auto"
|
|
10914
|
+
normalized,
|
|
10915
|
+
options?.topicsSource ?? "auto",
|
|
10916
|
+
"merge"
|
|
10876
10917
|
);
|
|
10877
10918
|
if (entityOps.length === 0 && kindBackfills.length === 0 && toCreate.length === 0 && topicsWrite === null) {
|
|
10878
10919
|
return;
|
|
@@ -10938,8 +10979,9 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
|
|
|
10938
10979
|
const topicsWrite = resolveTopicsWrite(
|
|
10939
10980
|
vaultRow,
|
|
10940
10981
|
entities,
|
|
10941
|
-
|
|
10942
|
-
options.topicsSource
|
|
10982
|
+
normalized,
|
|
10983
|
+
options.topicsSource,
|
|
10984
|
+
"replace"
|
|
10943
10985
|
);
|
|
10944
10986
|
if (entityOps.length === 0 && kindBackfills.length === 0 && toCreate.length === 0 && toDestroy.length === 0 && topicsWrite === null) {
|
|
10945
10987
|
return;
|
|
@@ -15739,9 +15781,9 @@ For each durable fact, output:
|
|
|
15739
15781
|
- type: one of identity | preference | relationship | plan | ongoing_context | constraint | other
|
|
15740
15782
|
- confidence: 0.0-1.0; how sure you are this is durable AND true. Only include facts >= 0.7.
|
|
15741
15783
|
- sourceMessageIds: which message IDs from the conversation contained the evidence
|
|
15742
|
-
- entities: named entities mentioned, each as an object { "name": string, "kind": one of "person" | "organization" | "place" | "event" | "product" | "thing" | "concept" | "other" }. Optional \u2014 include only NAMED entities, skip generic/common nouns. ${ENTITY_KIND_GUIDELINES} Examples:
|
|
15743
|
-
- "started a new job at Hollowpoint Labs and I'm learning Haskell for it" \u2192 entities: [{ "name": "Hollowpoint Labs", "kind": "organization" }, { "name": "Haskell", "kind": "concept" }]
|
|
15744
|
-
- "running the Berlin Half in May and I track workouts in Whoop" \u2192 entities: [{ "name": "Berlin Half", "kind": "event" }, { "name": "Whoop", "kind": "product" }]
|
|
15784
|
+
- entities: named entities mentioned, each as an object { "name": string, "kind": one of "person" | "organization" | "place" | "event" | "product" | "thing" | "concept" | "other", "salience": one of "primary" | "secondary" | "mention" }. Optional \u2014 include only NAMED entities, skip generic/common nouns. ${ENTITY_KIND_GUIDELINES} Salience is how central the entity is to the fact: "primary" = the fact is ABOUT it (usually exactly one per fact), "secondary" = a meaningful part of it, "mention" = named in passing. Examples:
|
|
15785
|
+
- "started a new job at Hollowpoint Labs and I'm learning Haskell for it" \u2192 entities: [{ "name": "Hollowpoint Labs", "kind": "organization", "salience": "primary" }, { "name": "Haskell", "kind": "concept", "salience": "secondary" }]
|
|
15786
|
+
- "running the Berlin Half in May and I track workouts in Whoop" \u2192 entities: [{ "name": "Berlin Half", "kind": "event", "salience": "primary" }, { "name": "Whoop", "kind": "product", "salience": "mention" }]
|
|
15745
15787
|
- eventTime: when the event in this fact occurs/occurred. Resolve relative phrases ("yesterday", "next week") against the current date given in the user message. Output one of:
|
|
15746
15788
|
- { "kind": "point", "start": "YYYY-MM-DD" } for a single date ("met Sara on March 14, 2026")
|
|
15747
15789
|
- { "kind": "range", "start": "YYYY-MM-DD", "end": "YYYY-MM-DD" } for a span ("Japan trip May 4\u201315, 2026")
|
|
@@ -15822,9 +15864,10 @@ function restoreCandidates(candidates, redactor, ownNames) {
|
|
|
15822
15864
|
candidate: {
|
|
15823
15865
|
...c,
|
|
15824
15866
|
content: content.text,
|
|
15825
|
-
entities: c.entities.
|
|
15826
|
-
|
|
15827
|
-
|
|
15867
|
+
entities: c.entities.flatMap((e) => {
|
|
15868
|
+
const restored = redactor.restoreForStorage(e.name);
|
|
15869
|
+
return restored.unresolved ? [] : [{ ...e, name: restored.text }];
|
|
15870
|
+
})
|
|
15828
15871
|
},
|
|
15829
15872
|
unresolved: content.unresolved
|
|
15830
15873
|
};
|
|
@@ -16053,7 +16096,12 @@ function parseEntities(raw) {
|
|
|
16053
16096
|
const name = typeof obj.name === "string" ? obj.name.trim() : "";
|
|
16054
16097
|
if (name.length === 0 || isGenericEntityName(name)) continue;
|
|
16055
16098
|
const kind = typeof obj.kind === "string" && ENTITY_KINDS.includes(obj.kind) ? obj.kind : void 0;
|
|
16056
|
-
|
|
16099
|
+
const weight = typeof obj.salience === "string" && Object.keys(TOPIC_SALIENCE_WEIGHTS).includes(obj.salience) ? TOPIC_SALIENCE_WEIGHTS[obj.salience] : void 0;
|
|
16100
|
+
out.push({
|
|
16101
|
+
name,
|
|
16102
|
+
...kind !== void 0 ? { kind } : {},
|
|
16103
|
+
...weight !== void 0 ? { weight } : {}
|
|
16104
|
+
});
|
|
16057
16105
|
}
|
|
16058
16106
|
return out;
|
|
16059
16107
|
}
|
|
@@ -18012,7 +18060,13 @@ Include only NAMED entities, skip generic/common nouns. A topic must identify a
|
|
|
18012
18060
|
- Prefer 0 entities over a weak one. A memory whose only candidate is a generic noun has NO entities.
|
|
18013
18061
|
${ENTITY_KIND_GUIDELINES}
|
|
18014
18062
|
|
|
18015
|
-
|
|
18063
|
+
Give each entity a "salience" \u2014 how central it is to the memory:
|
|
18064
|
+
- "primary": the memory is ABOUT it. A memory with entities usually has exactly one primary; never more than two.
|
|
18065
|
+
- "secondary": a meaningful part of the memory, but not its subject.
|
|
18066
|
+
- "mention": named in passing; the memory would say much the same without it.
|
|
18067
|
+
Example: "Ran the Chicago Marathon with my sister Ana in 3:41" \u2192 Chicago Marathon primary, Ana secondary.
|
|
18068
|
+
|
|
18069
|
+
Each memory below is written as "<id>: <text>". Output strict JSON: {"memories": [{"id": string, "entities": [{"name": string, "kind": string, "salience": "primary" | "secondary" | "mention"}]}]}
|
|
18016
18070
|
- exactly one element per input memory; copy its id EXACTLY as written (the token before the first ": "), with no brackets, quotes, or extra characters
|
|
18017
18071
|
- "entities" may be empty when a memory mentions no named entities \u2014 most short memories have 0-3
|
|
18018
18072
|
No prose.`;
|
|
@@ -18083,9 +18137,10 @@ List each memory's named entities.`,
|
|
|
18083
18137
|
return out;
|
|
18084
18138
|
}
|
|
18085
18139
|
function restoreEntities(entities, redactor) {
|
|
18086
|
-
return entities.
|
|
18087
|
-
|
|
18088
|
-
|
|
18140
|
+
return entities.flatMap((e) => {
|
|
18141
|
+
const restored = redactor.restoreForStorage(e.name);
|
|
18142
|
+
return restored.unresolved ? [] : [{ ...e, name: restored.text }];
|
|
18143
|
+
});
|
|
18089
18144
|
}
|
|
18090
18145
|
function parseTopicResponse(parsed, validIds) {
|
|
18091
18146
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
@@ -19372,19 +19427,23 @@ function topicInputs(topics, source) {
|
|
|
19372
19427
|
return topics.flatMap((topic) => {
|
|
19373
19428
|
const name = (typeof topic === "string" ? topic : topic.name).trim();
|
|
19374
19429
|
const kind = typeof topic === "string" ? void 0 : topic.kind;
|
|
19375
|
-
|
|
19430
|
+
const weight = typeof topic === "string" || source === "user" ? void 0 : parseTopicWeight(topic.weight);
|
|
19431
|
+
return name ? [{ name, ...kind && { kind }, source, ...weight && { weight } }] : [];
|
|
19376
19432
|
});
|
|
19377
19433
|
}
|
|
19378
19434
|
function mergeTopics(existing, added) {
|
|
19379
19435
|
const byName = /* @__PURE__ */ new Map();
|
|
19380
19436
|
for (const topic of [...existing, ...added]) {
|
|
19381
19437
|
const key = normalizeEntityName(topic.name);
|
|
19382
|
-
|
|
19438
|
+
const kept = byName.get(key);
|
|
19439
|
+
if (!kept) byName.set(key, topic);
|
|
19440
|
+
else if (kept.weight !== void 0 && topic.weight !== void 0 && topic.weight > kept.weight)
|
|
19441
|
+
byName.set(key, { ...kept, weight: topic.weight });
|
|
19383
19442
|
}
|
|
19384
19443
|
return [...byName.values()];
|
|
19385
19444
|
}
|
|
19386
19445
|
function sameTopics(stored2, next) {
|
|
19387
|
-
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source]);
|
|
19446
|
+
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source, t.weight ?? null]);
|
|
19388
19447
|
if (stored2 === null || stored2.length !== next.length) return false;
|
|
19389
19448
|
const keys = new Set(stored2.map(key));
|
|
19390
19449
|
return next.every((t) => keys.has(key(t)));
|
|
@@ -20147,12 +20206,19 @@ var FACET_STRUCTURED_RESPONSE_HINT = {
|
|
|
20147
20206
|
interests: `, "interests": <the same interests as an array of at most ${NEARBY_MAX_INTERESTS} strings of at most ${NEARBY_MAX_INTEREST_CODEPOINTS} characters each, e.g. ["trail running", "film photography"], or []>`
|
|
20148
20207
|
};
|
|
20149
20208
|
async function synthesizeProfile(ctx, options = {}) {
|
|
20150
|
-
|
|
20151
|
-
|
|
20209
|
+
const { store } = options;
|
|
20210
|
+
const vaultCtx = ctx.vaultCtx;
|
|
20211
|
+
if (!store && !vaultCtx) {
|
|
20212
|
+
throw new Error(
|
|
20213
|
+
"synthesizeProfile requires options.store or ctx.vaultCtx (vault-backed facts)."
|
|
20214
|
+
);
|
|
20152
20215
|
}
|
|
20153
|
-
if (!ctx.vaultCache) {
|
|
20154
|
-
throw new Error(
|
|
20216
|
+
if (!store && !ctx.vaultCache) {
|
|
20217
|
+
throw new Error(
|
|
20218
|
+
"synthesizeProfile requires options.store or ctx.vaultCache (semantic fact recall)."
|
|
20219
|
+
);
|
|
20155
20220
|
}
|
|
20221
|
+
const recallCtx = store ? { embeddingOptions: ctx.embeddingOptions, factSource: store.factSource } : ctx;
|
|
20156
20222
|
const facets = options.facets ?? DEFAULT_PROFILE_FACETS;
|
|
20157
20223
|
const scopes = options.scopes ?? DEFAULT_SCOPES;
|
|
20158
20224
|
const config = {
|
|
@@ -20163,11 +20229,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
20163
20229
|
reviewedMemoryIdsSignature: reviewedMemoryIdsSignature(options.reviewedMemoryIds)
|
|
20164
20230
|
};
|
|
20165
20231
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
20166
|
-
const
|
|
20167
|
-
|
|
20168
|
-
includeDeleted: true,
|
|
20169
|
-
includeSuperseded: true
|
|
20170
|
-
});
|
|
20232
|
+
const listOptions = { scopes, includeDeleted: true, includeSuperseded: true };
|
|
20233
|
+
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await getAllVaultMemoriesOp(vaultCtx, listOptions), []];
|
|
20171
20234
|
const watermark = computeVaultWatermark(memories);
|
|
20172
20235
|
const observationTrends = summarizeObservationTrends(
|
|
20173
20236
|
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
@@ -20177,11 +20240,14 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
20177
20240
|
}))
|
|
20178
20241
|
);
|
|
20179
20242
|
const presentIds = new Set(memories.map((m) => m.uniqueId));
|
|
20243
|
+
const unreadableMemoryIds = projections.map((p) => p.uniqueId).filter((id) => !presentIds.has(id)).sort();
|
|
20244
|
+
const previousUnreadable = new Set(previous?.unreadableMemoryIds ?? []);
|
|
20245
|
+
const sameUnreadable = unreadableMemoryIds.length === previousUnreadable.size && unreadableMemoryIds.every((id) => previousUnreadable.has(id));
|
|
20180
20246
|
const hasStaleSections = previous?.sections.some((s) => s.stale);
|
|
20181
20247
|
const citesMissingFact = previous?.sections.some(
|
|
20182
20248
|
(s) => s.sourceMemoryIds.some((id) => !presentIds.has(id))
|
|
20183
20249
|
);
|
|
20184
|
-
if (previous && previous.vaultWatermark === watermark && !hasStaleSections && !citesMissingFact) {
|
|
20250
|
+
if (previous && previous.vaultWatermark === watermark && !hasStaleSections && !citesMissingFact && sameUnreadable) {
|
|
20185
20251
|
const sameOrder = previous.sections.length === facets.length && facets.every((f, i) => previous.sections[i]?.key === f.key);
|
|
20186
20252
|
if (sameOrder) {
|
|
20187
20253
|
if (trendsEqual(previous.observationTrends, observationTrends)) return previous;
|
|
@@ -20194,12 +20260,13 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
20194
20260
|
};
|
|
20195
20261
|
}
|
|
20196
20262
|
const staleKeys = await computeStaleFacetKeys(
|
|
20197
|
-
|
|
20263
|
+
recallCtx,
|
|
20198
20264
|
memories,
|
|
20199
20265
|
facets,
|
|
20200
20266
|
previous,
|
|
20201
20267
|
watermark,
|
|
20202
|
-
options.reviewedMemoryIds
|
|
20268
|
+
options.reviewedMemoryIds,
|
|
20269
|
+
previousUnreadable
|
|
20203
20270
|
);
|
|
20204
20271
|
const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
20205
20272
|
const fallbackPriors = /* @__PURE__ */ new Map();
|
|
@@ -20219,7 +20286,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
20219
20286
|
if (prior && !staleKeys.has(facet.key)) {
|
|
20220
20287
|
return prior;
|
|
20221
20288
|
}
|
|
20222
|
-
return synthesizeFacet(facet,
|
|
20289
|
+
return synthesizeFacet(facet, recallCtx, options, fallbackPriors.get(facet.key));
|
|
20223
20290
|
})
|
|
20224
20291
|
);
|
|
20225
20292
|
const sections = settled.map((r, i) => {
|
|
@@ -20234,12 +20301,18 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
20234
20301
|
);
|
|
20235
20302
|
return fallbackSection(facet, fallbackPriors.get(facet.key));
|
|
20236
20303
|
});
|
|
20304
|
+
if (!sameUnreadable && unreadableMemoryIds.length > 0) {
|
|
20305
|
+
getLogger().warn("[memory/synthesizeProfile] some memories could not be read", {
|
|
20306
|
+
unreadable: unreadableMemoryIds.length
|
|
20307
|
+
});
|
|
20308
|
+
}
|
|
20237
20309
|
return {
|
|
20238
20310
|
version: PROFILE_DOC_VERSION,
|
|
20239
20311
|
sections,
|
|
20240
20312
|
vaultWatermark: watermark,
|
|
20241
20313
|
config,
|
|
20242
20314
|
observationTrends,
|
|
20315
|
+
...unreadableMemoryIds.length > 0 && { unreadableMemoryIds },
|
|
20243
20316
|
generatedAt: Date.now()
|
|
20244
20317
|
};
|
|
20245
20318
|
}
|
|
@@ -20273,11 +20346,13 @@ function computeVaultWatermark(memories) {
|
|
|
20273
20346
|
}
|
|
20274
20347
|
return max;
|
|
20275
20348
|
}
|
|
20276
|
-
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds) {
|
|
20349
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable) {
|
|
20277
20350
|
const allKeys = new Set(facets.map((f) => f.key));
|
|
20278
20351
|
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
20279
20352
|
if (!previous) return allKeys;
|
|
20280
|
-
const changed = memories.filter(
|
|
20353
|
+
const changed = memories.filter(
|
|
20354
|
+
(m) => changeTime(m) > previous.vaultWatermark || previouslyUnreadable.has(m.uniqueId)
|
|
20355
|
+
);
|
|
20281
20356
|
const changedIds = new Set(changed.map((m) => m.uniqueId));
|
|
20282
20357
|
const presentIds = new Set(memories.map((m) => m.uniqueId));
|
|
20283
20358
|
const stale = /* @__PURE__ */ new Set();
|
|
@@ -20351,7 +20426,12 @@ async function attributeFacts(ctx, candidates, facets) {
|
|
|
20351
20426
|
for (const fv of factVectors) {
|
|
20352
20427
|
let matchedAny = false;
|
|
20353
20428
|
for (let i = 0; i < facets.length; i++) {
|
|
20354
|
-
|
|
20429
|
+
const query = queryVectors[i];
|
|
20430
|
+
const similarity = cosineSimilarity(
|
|
20431
|
+
fv,
|
|
20432
|
+
fv.length < query.length ? query.slice(0, fv.length) : query
|
|
20433
|
+
);
|
|
20434
|
+
if (similarity >= NEW_FACT_ATTRIBUTION_MIN_SCORE) {
|
|
20355
20435
|
keys.add(facets[i].key);
|
|
20356
20436
|
matchedAny = true;
|
|
20357
20437
|
}
|
|
@@ -26296,6 +26376,7 @@ export {
|
|
|
26296
26376
|
TOOL_RESULT_ORIGIN,
|
|
26297
26377
|
TOPICS_EXTRACTION_VERSION,
|
|
26298
26378
|
TOPIC_EXTRACTION_BATCH_SIZE,
|
|
26379
|
+
TOPIC_SALIENCE_WEIGHTS,
|
|
26299
26380
|
TREND_RECENT_WINDOW_DAYS,
|
|
26300
26381
|
TREND_STALE_WINDOW_DAYS,
|
|
26301
26382
|
VAULT_SIZE_HOP_CAP,
|
|
@@ -26420,6 +26501,7 @@ export {
|
|
|
26420
26501
|
onKeyAvailable,
|
|
26421
26502
|
parseMedia,
|
|
26422
26503
|
preEmbedVaultMemories,
|
|
26504
|
+
primaryTopic,
|
|
26423
26505
|
quantizeEmbedding,
|
|
26424
26506
|
queueManager,
|
|
26425
26507
|
rankProfileCandidates,
|
|
@@ -26453,6 +26535,7 @@ export {
|
|
|
26453
26535
|
summarizeObservationTrends,
|
|
26454
26536
|
supersedeVaultMemoryOp,
|
|
26455
26537
|
synthesizeProfile,
|
|
26538
|
+
topicWeight,
|
|
26456
26539
|
traverseGraphLane,
|
|
26457
26540
|
ttlForType,
|
|
26458
26541
|
updateVaultFolderContextOp,
|
|
@@ -157,6 +157,8 @@ interface StoredTopic {
|
|
|
157
157
|
name: string;
|
|
158
158
|
kind?: string;
|
|
159
159
|
source: TopicSource;
|
|
160
|
+
/** How central the topic is to the memory, in (0, 1]; read it with {@link topicWeight}. */
|
|
161
|
+
weight?: number;
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
interface EntityOperationsContext {
|
package/dist/memory/context.d.ts
CHANGED
|
@@ -157,6 +157,8 @@ interface StoredTopic {
|
|
|
157
157
|
name: string;
|
|
158
158
|
kind?: string;
|
|
159
159
|
source: TopicSource;
|
|
160
|
+
/** How central the topic is to the memory, in (0, 1]; read it with {@link topicWeight}. */
|
|
161
|
+
weight?: number;
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
interface EntityOperationsContext {
|