@anuma/sdk 3.4.0 → 3.6.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/{chunk-C7PGRFBG.mjs → chunk-7TATXBC5.mjs} +45 -8
- package/dist/expo/index.cjs +158 -19
- package/dist/expo/index.d.mts +97 -4
- package/dist/expo/index.d.ts +97 -4
- package/dist/expo/index.mjs +104 -11
- package/dist/expo/{recall-7ZX6T2VD.mjs → recall-IO4KJ5W7.mjs} +1 -1
- package/dist/react/{chunk-CGC3UJHM.mjs → chunk-DDHTJGZN.mjs} +45 -8
- package/dist/react/index.cjs +158 -19
- package/dist/react/index.d.mts +97 -4
- package/dist/react/index.d.ts +97 -4
- package/dist/react/index.mjs +104 -11
- package/dist/react/{recall-OTUNGQHQ.mjs → recall-OPKHWKZX.mjs} +1 -1
- package/dist/server/{chunk-LUDHA4X4.mjs → chunk-V7SVKIXQ.mjs} +45 -8
- package/dist/server/index.cjs +158 -19
- package/dist/server/index.d.mts +97 -4
- package/dist/server/index.d.ts +97 -4
- package/dist/server/index.mjs +104 -11
- package/dist/server/{recall-GWRWPGE4.mjs → recall-IWY2MYHR.mjs} +1 -1
- package/package.json +1 -1
package/dist/expo/index.d.ts
CHANGED
|
@@ -4887,7 +4887,7 @@ interface VaultSearchResult {
|
|
|
4887
4887
|
updatedAt?: Date;
|
|
4888
4888
|
/** Times this fact has been re-observed — for C2 trend labels. */
|
|
4889
4889
|
proofCount?: number | null;
|
|
4890
|
-
/** C3 re-observation watermark (Unix ms) — for C2
|
|
4890
|
+
/** C3 re-observation watermark (Unix ms) — for C2 trends + C4 CE dates. */
|
|
4891
4891
|
lastObservedAt?: number | null;
|
|
4892
4892
|
/** W6 temporal-lane anchors carried through to downstream `RankedMemory`
|
|
4893
4893
|
* so the recall executor can surface dates to the answer model without
|
|
@@ -7001,6 +7001,66 @@ interface LlmNeighborRefinerOptions extends PortalLlmAuth {
|
|
|
7001
7001
|
*/
|
|
7002
7002
|
declare function createLlmNeighborRefiner(options: LlmNeighborRefinerOptions): NeighborRefiner;
|
|
7003
7003
|
|
|
7004
|
+
/**
|
|
7005
|
+
* Profile salience — profile-worthiness scoring for vault facts (#706).
|
|
7006
|
+
*
|
|
7007
|
+
* Distinct from query-time relevance (`recall` fusion). Answers: "is this
|
|
7008
|
+
* fact worth putting on a shareable profile?" using durable type, proof
|
|
7009
|
+
* density, and C2 observation trend. Pure + deterministic — no LLM, no DB.
|
|
7010
|
+
*
|
|
7011
|
+
* Used by:
|
|
7012
|
+
* - `synthesizeProfile` facet recall (default factTypeWeights)
|
|
7013
|
+
* - Publish-review UIs via {@link rankProfileCandidates} (nearby / client)
|
|
7014
|
+
*
|
|
7015
|
+
* Persisted `importance` is deferred until publish flow proves the need.
|
|
7016
|
+
*/
|
|
7017
|
+
|
|
7018
|
+
/** Proof-count curve weight inside {@link scoreProfileSalience}. */
|
|
7019
|
+
declare const DEFAULT_PROFILE_PROOF_ALPHA = 0.2;
|
|
7020
|
+
/**
|
|
7021
|
+
* Per-FactType multipliers for profile synthesis / salience.
|
|
7022
|
+
* Durable identity-class types (never age-archive in decay) rank higher;
|
|
7023
|
+
* ephemeral plan/ongoing_context rank lower. Untyped / `other` stay neutral.
|
|
7024
|
+
*/
|
|
7025
|
+
declare const DEFAULT_PROFILE_FACT_TYPE_WEIGHTS: Partial<Record<FactType, number>>;
|
|
7026
|
+
/** C2 trend multipliers for profile-worthiness. */
|
|
7027
|
+
declare const DEFAULT_PROFILE_TREND_MULTIPLIERS: Record<ObservationTrend, number>;
|
|
7028
|
+
interface ProfileSalienceInput extends ObservationTrendInput {
|
|
7029
|
+
/** Vault memory id — required for {@link rankProfileCandidates}. */
|
|
7030
|
+
id: string;
|
|
7031
|
+
/** Extractor FactType; null/undefined → neutral weight (1.0). */
|
|
7032
|
+
factType?: string | null;
|
|
7033
|
+
}
|
|
7034
|
+
interface RankedProfileCandidate {
|
|
7035
|
+
id: string;
|
|
7036
|
+
score: number;
|
|
7037
|
+
trend: ObservationTrend;
|
|
7038
|
+
factType?: string | null;
|
|
7039
|
+
proofCount: number;
|
|
7040
|
+
}
|
|
7041
|
+
interface ScoreProfileSalienceOptions {
|
|
7042
|
+
/** Override type weights (merged over {@link DEFAULT_PROFILE_FACT_TYPE_WEIGHTS}). */
|
|
7043
|
+
factTypeWeights?: Partial<Record<FactType, number>>;
|
|
7044
|
+
/** Override trend multipliers. */
|
|
7045
|
+
trendMultipliers?: Partial<Record<ObservationTrend, number>>;
|
|
7046
|
+
/** Proof-count α. Default: {@link DEFAULT_PROFILE_PROOF_ALPHA}. */
|
|
7047
|
+
proofCountAlpha?: number;
|
|
7048
|
+
}
|
|
7049
|
+
/**
|
|
7050
|
+
* Score a vault fact for profile-worthiness.
|
|
7051
|
+
*
|
|
7052
|
+
* `typeWeight * (1 + α·log(1+proofCount) − α·log(2)) * trendMultiplier`
|
|
7053
|
+
*
|
|
7054
|
+
* The proof term mirrors vault fusion's log curve (neutral at proofCount=1).
|
|
7055
|
+
* Pass `now` for deterministic evals.
|
|
7056
|
+
*/
|
|
7057
|
+
declare function scoreProfileSalience(input: ProfileSalienceInput, now?: number, options?: ScoreProfileSalienceOptions): number;
|
|
7058
|
+
/**
|
|
7059
|
+
* Rank vault facts by profile-worthiness (descending score).
|
|
7060
|
+
* Ties broken by higher proofCount, then id ascending for stability.
|
|
7061
|
+
*/
|
|
7062
|
+
declare function rankProfileCandidates(inputs: readonly ProfileSalienceInput[], now?: number, options?: ScoreProfileSalienceOptions): RankedProfileCandidate[];
|
|
7063
|
+
|
|
7004
7064
|
/**
|
|
7005
7065
|
* Unified Recall API — single retrieval surface above vault + engine.
|
|
7006
7066
|
*
|
|
@@ -7138,6 +7198,12 @@ interface ReflectOptions extends RecallOptions, PortalLlmAuth {
|
|
|
7138
7198
|
fetchFn?: typeof fetch;
|
|
7139
7199
|
/** Optional JSON Schema to coerce structured outputs. */
|
|
7140
7200
|
responseSchema?: Record<string, unknown>;
|
|
7201
|
+
/**
|
|
7202
|
+
* Skip Stage-1 {@link recall} and synthesize from these memories instead.
|
|
7203
|
+
* Used by `synthesizeProfile` after intersecting recall with a
|
|
7204
|
+
* `reviewedMemoryIds` gate so the LLM never sees unreviewed evidence.
|
|
7205
|
+
*/
|
|
7206
|
+
memories?: RankedMemory[];
|
|
7141
7207
|
}
|
|
7142
7208
|
interface ReflectResult {
|
|
7143
7209
|
/** The synthesized answer text. */
|
|
@@ -7261,8 +7327,9 @@ interface ProfileSection {
|
|
|
7261
7327
|
/** Fingerprint of the config that produced a {@link ProfileDoc}. Delta reuse
|
|
7262
7328
|
* (both the wholesale fast path and per-section reuse) is only valid when the
|
|
7263
7329
|
* current call's config matches — otherwise reused sections could carry the
|
|
7264
|
-
* wrong scope's evidence, un-redacted text under a now-present redactor,
|
|
7265
|
-
* old section shape
|
|
7330
|
+
* wrong scope's evidence, un-redacted text under a now-present redactor, an
|
|
7331
|
+
* old section shape, or text grounded in memory ids that are no longer in the
|
|
7332
|
+
* publish-review set. */
|
|
7266
7333
|
interface ProfileConfigFingerprint {
|
|
7267
7334
|
/** Facet keys present in the doc, sorted. */
|
|
7268
7335
|
facetKeys: ProfileFacetKey[];
|
|
@@ -7277,6 +7344,14 @@ interface ProfileConfigFingerprint {
|
|
|
7277
7344
|
/** Whether a PII redactor gated the section text. Reusing un-gated text under
|
|
7278
7345
|
* a now-present redactor would leak PII, so this flips the fingerprint. */
|
|
7279
7346
|
redacted: boolean;
|
|
7347
|
+
/**
|
|
7348
|
+
* Order-independent digest of {@link SynthesizeProfileOptions.reviewedMemoryIds}.
|
|
7349
|
+
* Empty string when the review gate is off (omit / empty array). Changing the
|
|
7350
|
+
* set must invalidate reuse — otherwise a narrowed review keeps text grounded
|
|
7351
|
+
* in unreviewed ids, and a widened review leaves previously-cleared sections
|
|
7352
|
+
* empty.
|
|
7353
|
+
*/
|
|
7354
|
+
reviewedMemoryIdsSignature: string;
|
|
7280
7355
|
}
|
|
7281
7356
|
/** A synthesized profile. Server-authoritative once published; the client
|
|
7282
7357
|
* caches it and passes it back as {@link SynthesizeProfileOptions.previous}. */
|
|
@@ -7322,6 +7397,24 @@ interface SynthesizeProfileOptions extends PortalLlmAuth {
|
|
|
7322
7397
|
* Omit only when the caller redacts downstream — `nearby` also moderates
|
|
7323
7398
|
* server-side, but the client should never publish un-gated text. */
|
|
7324
7399
|
redactor?: PiiRedactor;
|
|
7400
|
+
/**
|
|
7401
|
+
* Per-FactType score multipliers for facet recall. Default:
|
|
7402
|
+
* {@link DEFAULT_PROFILE_FACT_TYPE_WEIGHTS} (durable types boosted).
|
|
7403
|
+
* Does not change global chat `recall()` defaults.
|
|
7404
|
+
*/
|
|
7405
|
+
factTypeWeights?: Partial<Record<FactType, number>>;
|
|
7406
|
+
/**
|
|
7407
|
+
* Proof-count α for facet recall. Default: {@link DEFAULT_PROFILE_PROOF_ALPHA}
|
|
7408
|
+
* (0.2). Chat recall stays at 0.1.
|
|
7409
|
+
*/
|
|
7410
|
+
proofCountAlpha?: number;
|
|
7411
|
+
/**
|
|
7412
|
+
* When non-empty, intersect each facet's recalled evidence with this id set
|
|
7413
|
+
* before the LLM runs (publish-review gate). Empty intersection → empty
|
|
7414
|
+
* section (legitimate no-evidence), not a stale fallback. Omit / empty →
|
|
7415
|
+
* no gate.
|
|
7416
|
+
*/
|
|
7417
|
+
reviewedMemoryIds?: readonly string[];
|
|
7325
7418
|
}
|
|
7326
7419
|
/**
|
|
7327
7420
|
* Synthesize a shareable {@link ProfileDoc} from the user's vault, on-device.
|
|
@@ -8793,4 +8886,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
|
|
|
8793
8886
|
*/
|
|
8794
8887
|
declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
|
|
8795
8888
|
|
|
8796
|
-
export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScreenResult, type ScreenedCandidate, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type SynthesizeProfileOptions, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
|
|
8889
|
+
export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type SynthesizeProfileOptions, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
|
package/dist/expo/index.mjs
CHANGED
|
@@ -103,7 +103,7 @@ import {
|
|
|
103
103
|
upsertMessageOp,
|
|
104
104
|
useEncryption,
|
|
105
105
|
vaultMemoryToStored
|
|
106
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-7TATXBC5.mjs";
|
|
107
107
|
import {
|
|
108
108
|
PII_PATTERNS,
|
|
109
109
|
PiiRedactor,
|
|
@@ -8174,6 +8174,61 @@ function createDecaySweeper(options) {
|
|
|
8174
8174
|
};
|
|
8175
8175
|
}
|
|
8176
8176
|
|
|
8177
|
+
// src/lib/memory/profileSalience.ts
|
|
8178
|
+
var DEFAULT_PROFILE_PROOF_ALPHA = 0.2;
|
|
8179
|
+
var DEFAULT_PROFILE_FACT_TYPE_WEIGHTS = {
|
|
8180
|
+
identity: 1.5,
|
|
8181
|
+
preference: 1.5,
|
|
8182
|
+
relationship: 1.5,
|
|
8183
|
+
constraint: 1.5,
|
|
8184
|
+
other: 1,
|
|
8185
|
+
plan: 0.6,
|
|
8186
|
+
ongoing_context: 0.6
|
|
8187
|
+
};
|
|
8188
|
+
var DEFAULT_PROFILE_TREND_MULTIPLIERS = {
|
|
8189
|
+
strengthening: 1.25,
|
|
8190
|
+
new: 1.1,
|
|
8191
|
+
stable: 1,
|
|
8192
|
+
weakening: 0.75,
|
|
8193
|
+
stale: 0.5
|
|
8194
|
+
};
|
|
8195
|
+
function typeWeight(factType, weights) {
|
|
8196
|
+
if (!factType) return 1;
|
|
8197
|
+
const w = weights[factType];
|
|
8198
|
+
if (w !== void 0 && Number.isFinite(w) && w > 0) return w;
|
|
8199
|
+
return 1;
|
|
8200
|
+
}
|
|
8201
|
+
function scoreProfileSalience(input, now = Date.now(), options = {}) {
|
|
8202
|
+
const alpha = options.proofCountAlpha ?? DEFAULT_PROFILE_PROOF_ALPHA;
|
|
8203
|
+
const typeWeights = { ...DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, ...options.factTypeWeights };
|
|
8204
|
+
const trendMults = { ...DEFAULT_PROFILE_TREND_MULTIPLIERS, ...options.trendMultipliers };
|
|
8205
|
+
const proofs = Math.max(1, input.proofCount ?? 1);
|
|
8206
|
+
const proofBoost = 1 + alpha * Math.log(1 + proofs) - alpha * Math.log(2);
|
|
8207
|
+
const trend = classifyObservationTrend(input, now);
|
|
8208
|
+
const tw = typeWeight(input.factType, typeWeights);
|
|
8209
|
+
const tm = trendMults[trend] ?? 1;
|
|
8210
|
+
const score = tw * proofBoost * tm;
|
|
8211
|
+
return Number.isFinite(score) ? score : 0;
|
|
8212
|
+
}
|
|
8213
|
+
function rankProfileCandidates(inputs, now = Date.now(), options = {}) {
|
|
8214
|
+
const ranked = inputs.map((input) => {
|
|
8215
|
+
const proofs = Math.max(1, input.proofCount ?? 1);
|
|
8216
|
+
return {
|
|
8217
|
+
id: input.id,
|
|
8218
|
+
score: scoreProfileSalience(input, now, options),
|
|
8219
|
+
trend: classifyObservationTrend(input, now),
|
|
8220
|
+
factType: input.factType ?? null,
|
|
8221
|
+
proofCount: proofs
|
|
8222
|
+
};
|
|
8223
|
+
});
|
|
8224
|
+
ranked.sort((a, b) => {
|
|
8225
|
+
if (b.score !== a.score) return b.score - a.score;
|
|
8226
|
+
if (b.proofCount !== a.proofCount) return b.proofCount - a.proofCount;
|
|
8227
|
+
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
8228
|
+
});
|
|
8229
|
+
return ranked;
|
|
8230
|
+
}
|
|
8231
|
+
|
|
8177
8232
|
// src/lib/memory/recallConstants.ts
|
|
8178
8233
|
var RECALL_TOOL_NAME = "recall_memory";
|
|
8179
8234
|
var RECALL_MAX_LIMIT = 50;
|
|
@@ -8398,18 +8453,18 @@ async function reflect(query, ctx, options) {
|
|
|
8398
8453
|
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 }
|
|
8399
8454
|
};
|
|
8400
8455
|
if (trimmed.length === 0) return empty;
|
|
8401
|
-
const { maxTokens: _llmMaxTokens, ...recallOptions } = options;
|
|
8402
|
-
const
|
|
8403
|
-
const memoryIds =
|
|
8456
|
+
const { maxTokens: _llmMaxTokens, memories: providedMemories, ...recallOptions } = options;
|
|
8457
|
+
const recalledMemories = providedMemories !== void 0 ? providedMemories : (await recall(trimmed, ctx, recallOptions)).memories;
|
|
8458
|
+
const memoryIds = recalledMemories.map((m) => m.id);
|
|
8404
8459
|
const baseResult = {
|
|
8405
8460
|
text: "",
|
|
8406
8461
|
basedOn: { memoryIds },
|
|
8407
8462
|
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 }
|
|
8408
8463
|
};
|
|
8409
|
-
if (
|
|
8464
|
+
if (recalledMemories.length === 0) {
|
|
8410
8465
|
return baseResult;
|
|
8411
8466
|
}
|
|
8412
|
-
const evidence =
|
|
8467
|
+
const evidence = recalledMemories.map((m, i) => `[${i + 1}] (id: ${m.id}, kind: ${m.kind})
|
|
8413
8468
|
${m.content}`).join("\n\n");
|
|
8414
8469
|
const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
8415
8470
|
const model = options.llmModel ?? DEFAULT_MODEL3;
|
|
@@ -8595,7 +8650,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
8595
8650
|
facetKeys: facets.map((f) => f.key).sort(),
|
|
8596
8651
|
facetsSignature: facetsSignature(facets),
|
|
8597
8652
|
scopes: [...scopes].sort(),
|
|
8598
|
-
redacted: options.redactor !== void 0
|
|
8653
|
+
redacted: options.redactor !== void 0,
|
|
8654
|
+
reviewedMemoryIdsSignature: reviewedMemoryIdsSignature(options.reviewedMemoryIds)
|
|
8599
8655
|
};
|
|
8600
8656
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
8601
8657
|
const memories = await getAllVaultMemoriesOp(ctx.vaultCtx, {
|
|
@@ -8668,7 +8724,11 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
8668
8724
|
}
|
|
8669
8725
|
function configMatches(a, b) {
|
|
8670
8726
|
if (!a) return false;
|
|
8671
|
-
return a.redacted === b.redacted && a.facetsSignature === b.facetsSignature && a.scopes.length === b.scopes.length && a.scopes.every((s, i) => s === b.scopes[i]);
|
|
8727
|
+
return a.redacted === b.redacted && a.facetsSignature === b.facetsSignature && (a.reviewedMemoryIdsSignature ?? "") === b.reviewedMemoryIdsSignature && a.scopes.length === b.scopes.length && a.scopes.every((s, i) => s === b.scopes[i]);
|
|
8728
|
+
}
|
|
8729
|
+
function reviewedMemoryIdsSignature(ids) {
|
|
8730
|
+
if (ids === void 0 || ids.length === 0) return "";
|
|
8731
|
+
return [...new Set(ids)].sort().join("\n");
|
|
8672
8732
|
}
|
|
8673
8733
|
function facetsSignature(facets) {
|
|
8674
8734
|
return facets.map((f) => JSON.stringify([f.key, f.label, f.query, f.guidance])).sort().join("\n");
|
|
@@ -8772,18 +8832,46 @@ async function attributeFacts(ctx, candidates, facets) {
|
|
|
8772
8832
|
return keys;
|
|
8773
8833
|
}
|
|
8774
8834
|
async function synthesizeFacet(facet, ctx, options, prior) {
|
|
8835
|
+
const scopes = options.scopes ?? DEFAULT_SCOPES;
|
|
8836
|
+
const limit = options.limit ?? DEFAULT_FACET_RECALL_LIMIT;
|
|
8837
|
+
const factTypeWeights = { ...DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, ...options.factTypeWeights };
|
|
8838
|
+
const proofCountAlpha = options.proofCountAlpha ?? DEFAULT_PROFILE_PROOF_ALPHA;
|
|
8839
|
+
const reviewed = options.reviewedMemoryIds;
|
|
8840
|
+
const hasReviewGate = reviewed !== void 0 && reviewed.length > 0;
|
|
8841
|
+
const recalled = await recall(facet.query, ctx, {
|
|
8842
|
+
scopes,
|
|
8843
|
+
limit: hasReviewGate ? RECALL_MAX_LIMIT : limit,
|
|
8844
|
+
types: ["fact"],
|
|
8845
|
+
factTypeWeights,
|
|
8846
|
+
proofCountAlpha
|
|
8847
|
+
});
|
|
8848
|
+
let memories = recalled.memories;
|
|
8849
|
+
if (hasReviewGate) {
|
|
8850
|
+
const allowed = new Set(reviewed);
|
|
8851
|
+
memories = memories.filter((m) => allowed.has(m.id)).slice(0, limit);
|
|
8852
|
+
}
|
|
8853
|
+
if (memories.length === 0) {
|
|
8854
|
+
return {
|
|
8855
|
+
key: facet.key,
|
|
8856
|
+
label: facet.label,
|
|
8857
|
+
text: "",
|
|
8858
|
+
sourceMemoryIds: [],
|
|
8859
|
+
generatedAt: Date.now()
|
|
8860
|
+
};
|
|
8861
|
+
}
|
|
8775
8862
|
const result = await reflect(facet.query, ctx, {
|
|
8776
8863
|
apiKey: options.apiKey,
|
|
8777
8864
|
getToken: options.getToken,
|
|
8778
8865
|
llmModel: options.llmModel ?? DEFAULT_SYNTHESIS_MODEL,
|
|
8779
8866
|
baseUrl: options.baseUrl,
|
|
8780
8867
|
fetchFn: options.fetchFn,
|
|
8781
|
-
scopes
|
|
8782
|
-
limit
|
|
8868
|
+
scopes,
|
|
8869
|
+
limit,
|
|
8783
8870
|
types: ["fact"],
|
|
8784
8871
|
maxTokens: DEFAULT_FACET_MAX_TOKENS,
|
|
8785
8872
|
systemPrompt: buildFacetSystemPrompt(facet),
|
|
8786
|
-
responseSchema: FACET_RESPONSE_SCHEMA
|
|
8873
|
+
responseSchema: FACET_RESPONSE_SCHEMA,
|
|
8874
|
+
memories
|
|
8787
8875
|
});
|
|
8788
8876
|
const noEvidence = result.basedOn.memoryIds.length === 0;
|
|
8789
8877
|
const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
|
|
@@ -14368,6 +14456,9 @@ export {
|
|
|
14368
14456
|
DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP,
|
|
14369
14457
|
DEFAULT_MIN_CHUNK_SIZE,
|
|
14370
14458
|
DEFAULT_PROFILE_FACETS,
|
|
14459
|
+
DEFAULT_PROFILE_FACT_TYPE_WEIGHTS,
|
|
14460
|
+
DEFAULT_PROFILE_PROOF_ALPHA,
|
|
14461
|
+
DEFAULT_PROFILE_TREND_MULTIPLIERS,
|
|
14371
14462
|
DEFAULT_VAULT_CACHE_SIZE,
|
|
14372
14463
|
DatabaseManager,
|
|
14373
14464
|
ENTITY_FANOUT,
|
|
@@ -14493,6 +14584,7 @@ export {
|
|
|
14493
14584
|
preEmbedVaultMemories,
|
|
14494
14585
|
quantizeEmbedding,
|
|
14495
14586
|
queueManager,
|
|
14587
|
+
rankProfileCandidates,
|
|
14496
14588
|
recall,
|
|
14497
14589
|
reflect,
|
|
14498
14590
|
refreshNotionAccessToken,
|
|
@@ -14502,6 +14594,7 @@ export {
|
|
|
14502
14594
|
restoreVaultMemoryOp,
|
|
14503
14595
|
resumeStream,
|
|
14504
14596
|
retain,
|
|
14597
|
+
scoreProfileSalience,
|
|
14505
14598
|
screenCandidatesForInjection,
|
|
14506
14599
|
sdkMigrations,
|
|
14507
14600
|
sdkModelClasses,
|
|
@@ -3564,11 +3564,20 @@ async function getModel() {
|
|
|
3564
3564
|
function sigmoid(x) {
|
|
3565
3565
|
return 1 / (1 + Math.exp(-x));
|
|
3566
3566
|
}
|
|
3567
|
+
function formatRerankDoc(content, dateMs) {
|
|
3568
|
+
if (dateMs === null || dateMs === void 0 || !Number.isFinite(dateMs)) return content;
|
|
3569
|
+
const d = new Date(dateMs);
|
|
3570
|
+
if (!Number.isFinite(d.getTime())) return content;
|
|
3571
|
+
const yyyy = d.getFullYear();
|
|
3572
|
+
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
3573
|
+
const dd = String(d.getDate()).padStart(2, "0");
|
|
3574
|
+
return `[Date: ${yyyy}-${mm}-${dd}] ${content}`;
|
|
3575
|
+
}
|
|
3567
3576
|
async function rerankPairs(query, items) {
|
|
3568
3577
|
if (items.length === 0 || !query) return [];
|
|
3569
3578
|
const { tokenizer, model } = await getModel();
|
|
3570
3579
|
const queries = items.map(() => query);
|
|
3571
|
-
const docs = items.map((i) => i.content);
|
|
3580
|
+
const docs = items.map((i) => formatRerankDoc(i.content, i.dateMs));
|
|
3572
3581
|
const tokenize2 = tokenizer;
|
|
3573
3582
|
const inputs = tokenize2(queries, { text_pair: docs, padding: true, truncation: true });
|
|
3574
3583
|
const forward = model;
|
|
@@ -3917,6 +3926,23 @@ function createVaultEmbeddingCache(maxSize = DEFAULT_VAULT_CACHE_SIZE) {
|
|
|
3917
3926
|
function normalizeEventTimeKind(kind) {
|
|
3918
3927
|
return kind === "point" || kind === "range" || kind === "ongoing" ? kind : null;
|
|
3919
3928
|
}
|
|
3929
|
+
function rerankDateMs(item) {
|
|
3930
|
+
if (item.eventTimeStart !== null && item.eventTimeStart !== void 0 && Number.isFinite(item.eventTimeStart) && item.eventTimeStart > 0) {
|
|
3931
|
+
return item.eventTimeStart;
|
|
3932
|
+
}
|
|
3933
|
+
if (item.lastObservedAt !== null && item.lastObservedAt !== void 0 && Number.isFinite(item.lastObservedAt) && item.lastObservedAt > 0) {
|
|
3934
|
+
return item.lastObservedAt;
|
|
3935
|
+
}
|
|
3936
|
+
const updatedMs = item.updatedAt?.getTime();
|
|
3937
|
+
if (updatedMs !== null && updatedMs !== void 0 && Number.isFinite(updatedMs) && updatedMs > 0) {
|
|
3938
|
+
return updatedMs;
|
|
3939
|
+
}
|
|
3940
|
+
const createdMs = item.createdAt?.getTime();
|
|
3941
|
+
if (createdMs !== null && createdMs !== void 0 && Number.isFinite(createdMs) && createdMs > 0) {
|
|
3942
|
+
return createdMs;
|
|
3943
|
+
}
|
|
3944
|
+
return void 0;
|
|
3945
|
+
}
|
|
3920
3946
|
var SUPERSESSION_SIMILARITY_THRESHOLD = 0.7;
|
|
3921
3947
|
var SUPERSESSION_MIN_AGE_GAP_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3922
3948
|
var SUPERSESSION_BOOST_FACTOR = 0.8;
|
|
@@ -4123,6 +4149,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
4123
4149
|
}
|
|
4124
4150
|
let combined;
|
|
4125
4151
|
let tailSlice = [];
|
|
4152
|
+
const itemById = new Map(items.map((i) => [i.id, i]));
|
|
4126
4153
|
if (options?.rerank) {
|
|
4127
4154
|
const rerankTopN = options.rerankTopN ?? 30;
|
|
4128
4155
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
@@ -4130,7 +4157,12 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
4130
4157
|
try {
|
|
4131
4158
|
const reranked = await rerankPairs(
|
|
4132
4159
|
query,
|
|
4133
|
-
headSlice.map((r) => ({
|
|
4160
|
+
headSlice.map((r) => ({
|
|
4161
|
+
id: r.uniqueId,
|
|
4162
|
+
content: r.content,
|
|
4163
|
+
// C4: date-prefix the CE doc so temporal alignment influences rank.
|
|
4164
|
+
dateMs: rerankDateMs(itemById.get(r.uniqueId) ?? r)
|
|
4165
|
+
}))
|
|
4134
4166
|
);
|
|
4135
4167
|
tailSlice = v2Ranked.slice(rerankTopN);
|
|
4136
4168
|
const v2ScoreById = new Map(headSlice.map((r) => [r.uniqueId, r.similarity]));
|
|
@@ -4165,11 +4197,11 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
4165
4197
|
const fused = rrfFuse([headIds, headIds, ...sideLanesAsync], options?.rrfK);
|
|
4166
4198
|
const fusedHead = combined.map((r) => ({ ...r, similarity: fused.get(r.uniqueId) ?? r.similarity })).sort((a, b) => b.similarity - a.similarity);
|
|
4167
4199
|
const seen = new Set(combined.map((r) => r.uniqueId));
|
|
4168
|
-
const
|
|
4200
|
+
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
4169
4201
|
for (const lane of sideLanesAsync) {
|
|
4170
4202
|
for (const id of lane) {
|
|
4171
4203
|
if (seen.has(id)) continue;
|
|
4172
|
-
const it =
|
|
4204
|
+
const it = itemById2.get(id);
|
|
4173
4205
|
if (!it) continue;
|
|
4174
4206
|
fusedHead.push({
|
|
4175
4207
|
uniqueId: id,
|
|
@@ -4188,11 +4220,11 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
4188
4220
|
if (options?.mmr) {
|
|
4189
4221
|
const lambda = options.mmrLambda ?? 0.7;
|
|
4190
4222
|
const mmrTopN = options.mmrTopN ?? 20;
|
|
4191
|
-
const
|
|
4223
|
+
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
4192
4224
|
const mmrCandidates = combined.slice(0, mmrTopN).map((r) => ({
|
|
4193
4225
|
id: r.uniqueId,
|
|
4194
4226
|
score: r.similarity,
|
|
4195
|
-
embedding:
|
|
4227
|
+
embedding: itemById2.get(r.uniqueId)?.embedding ?? [],
|
|
4196
4228
|
content: r.content
|
|
4197
4229
|
}));
|
|
4198
4230
|
const picked = applyMMR(mmrCandidates, limit, lambda);
|
|
@@ -4314,7 +4346,12 @@ async function rankComposite(originalQuery, originalQueryEmbedding, subQueries,
|
|
|
4314
4346
|
try {
|
|
4315
4347
|
const reranked = await rerankPairs(
|
|
4316
4348
|
originalQuery,
|
|
4317
|
-
headSlice.map((r) => ({
|
|
4349
|
+
headSlice.map((r) => ({
|
|
4350
|
+
id: r.uniqueId,
|
|
4351
|
+
content: r.content,
|
|
4352
|
+
// C4: date-prefix the CE doc so temporal alignment influences rank.
|
|
4353
|
+
dateMs: rerankDateMs(itemById.get(r.uniqueId) ?? r)
|
|
4354
|
+
}))
|
|
4318
4355
|
);
|
|
4319
4356
|
const ceById = new Map(reranked.map((r) => [r.id, r.score]));
|
|
4320
4357
|
const head = headSlice.map((r) => ({
|
|
@@ -4732,7 +4769,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
4732
4769
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
4733
4770
|
);
|
|
4734
4771
|
}
|
|
4735
|
-
const { recall: recall2 } = await import("./recall-
|
|
4772
|
+
const { recall: recall2 } = await import("./recall-OPKHWKZX.mjs");
|
|
4736
4773
|
const result = await recall2(
|
|
4737
4774
|
query,
|
|
4738
4775
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|