@anuma/sdk 7.3.3 → 7.4.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.
@@ -18739,9 +18739,51 @@ function isBorderline(input) {
18739
18739
  }
18740
18740
  return false;
18741
18741
  }
18742
+ function vaultDecayBackend(vaultCtx) {
18743
+ return {
18744
+ candidates: () => getDecayCandidatesRawOp(vaultCtx),
18745
+ archive: async (rows, now) => {
18746
+ const archived = /* @__PURE__ */ new Set();
18747
+ for (const c of rows) {
18748
+ const ok = await archiveVaultMemoryOp(vaultCtx, c.uniqueId, {
18749
+ now,
18750
+ expectedUpdatedAt: c.updatedAt,
18751
+ expectedLastObservedAt: c.lastObservedAt ?? null
18752
+ });
18753
+ if (ok) archived.add(c.uniqueId);
18754
+ }
18755
+ return archived;
18756
+ },
18757
+ hardDelete: async (rows, deleteOptions) => {
18758
+ const deleted = /* @__PURE__ */ new Set();
18759
+ for (const c of rows) {
18760
+ if (await hardDeleteDecayedOp(vaultCtx, c.uniqueId, deleteOptions)) deleted.add(c.uniqueId);
18761
+ }
18762
+ return deleted;
18763
+ }
18764
+ };
18765
+ }
18742
18766
  function createDecaySweeper(options) {
18743
- const { vaultCtx, policy, classifier, onSwept, onError } = options;
18767
+ const { vaultCtx, ...sweepOptions } = options;
18744
18768
  assertVaultScopeForSweep(vaultCtx);
18769
+ return createDecaySweeperOver(vaultDecayBackend(vaultCtx), sweepOptions);
18770
+ }
18771
+ function ruleBasedDecayOptions(options = {}) {
18772
+ if (options.classifier !== void 0)
18773
+ throw new Error(
18774
+ "MemoryStore.decay sweeps by rule only; a decay classifier needs decrypted content"
18775
+ );
18776
+ const { now, policy, onSwept, onError } = options;
18777
+ return {
18778
+ ...now !== void 0 && { now },
18779
+ ...policy && { policy },
18780
+ ...onSwept && { onSwept },
18781
+ ...onError && { onError }
18782
+ };
18783
+ }
18784
+ function createDecaySweeperOver(backend, options) {
18785
+ const { policy, classifier, onSwept, onError } = options;
18786
+ const maxTransitions = options.maxTransitionsPerSweep ?? Number.POSITIVE_INFINITY;
18745
18787
  const hardDeleteWindowMs = policy?.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs;
18746
18788
  const maxClassifierCalls = options.maxClassifierCallsPerSweep ?? DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP;
18747
18789
  const classifierCache = /* @__PURE__ */ new Map();
@@ -18783,7 +18825,7 @@ function createDecaySweeper(options) {
18783
18825
  const now = resolveNow(options.now);
18784
18826
  let candidates;
18785
18827
  try {
18786
- candidates = await getDecayCandidatesRawOp(vaultCtx);
18828
+ candidates = await backend.candidates();
18787
18829
  } catch (err) {
18788
18830
  onError?.(err instanceof Error ? err : new Error(String(err)));
18789
18831
  return emptyResult();
@@ -18806,25 +18848,37 @@ function createDecaySweeper(options) {
18806
18848
  result.scanned = candidates.length;
18807
18849
  result.classifierCalls = sweep.classifierCalls;
18808
18850
  result.classifierCapHits = sweep.classifierCapHits;
18851
+ let landed = 0;
18852
+ const apply = async (queue, run, count2) => {
18853
+ let next = 0;
18854
+ while (next < queue.length && landed < maxTransitions) {
18855
+ const batch = queue.slice(next, next + (maxTransitions - landed));
18856
+ next += batch.length;
18857
+ const done = await run(batch.map(({ candidate }) => candidate));
18858
+ for (const { candidate, source } of batch) {
18859
+ if (!done.has(candidate.uniqueId)) continue;
18860
+ landed++;
18861
+ count2(source);
18862
+ }
18863
+ }
18864
+ };
18809
18865
  try {
18810
- for (const { candidate: c, source } of toArchive) {
18811
- const ok = await archiveVaultMemoryOp(vaultCtx, c.uniqueId, {
18812
- now,
18813
- expectedUpdatedAt: c.updatedAt,
18814
- expectedLastObservedAt: c.lastObservedAt ?? null
18815
- });
18816
- if (ok) {
18866
+ await apply(
18867
+ toArchive,
18868
+ (rows) => backend.archive(rows, now),
18869
+ (source) => {
18817
18870
  result.archived++;
18818
18871
  result[source].archived++;
18819
18872
  }
18820
- }
18821
- for (const { candidate: c, source } of toDelete) {
18822
- const ok = await hardDeleteDecayedOp(vaultCtx, c.uniqueId, { hardDeleteWindowMs, now });
18823
- if (ok) {
18873
+ );
18874
+ await apply(
18875
+ toDelete,
18876
+ (rows) => backend.hardDelete(rows, { hardDeleteWindowMs, now }),
18877
+ (source) => {
18824
18878
  result.deleted++;
18825
18879
  result[source].deleted++;
18826
18880
  }
18827
- }
18881
+ );
18828
18882
  } catch (err) {
18829
18883
  onError?.(err instanceof Error ? err : new Error(String(err)));
18830
18884
  }
@@ -20883,7 +20937,10 @@ function createLocalMemoryStore(options) {
20883
20937
  return () => subscriptions.forEach((s) => s.unsubscribe());
20884
20938
  },
20885
20939
  maintenance,
20886
- topicMaintenance: maintenance
20940
+ topicMaintenance: maintenance,
20941
+ decay: {
20942
+ createDecaySweeper: (sweeperOptions) => createDecaySweeper({ ...ruleBasedDecayOptions(sweeperOptions), vaultCtx })
20943
+ }
20887
20944
  };
20888
20945
  }
20889
20946
 
@@ -22279,6 +22336,7 @@ var MAX_QUERY_TOPICS = 100;
22279
22336
  var MAX_QUERY_FILTER = 20;
22280
22337
  var GRAPH_LANE_ROWS = 256;
22281
22338
  var TEMPORAL_LANE_ROWS = 256;
22339
+ var DECAY_TRANSITIONS_PER_SWEEP = 200;
22282
22340
  var RemoteMemoryPartialCreateError = class extends Error {
22283
22341
  constructor(created, cause) {
22284
22342
  super(`createMany stored ${created.length} memories before a batch failed`);
@@ -22465,7 +22523,7 @@ function createRemoteMemoryStore(options) {
22465
22523
  )).flat();
22466
22524
  const listFilters = (listOptions) => ({
22467
22525
  ...stateFilters(listOptions),
22468
- include_embeddings: true,
22526
+ include_embeddings: listOptions.withEmbeddings !== false,
22469
22527
  order: listOptions.since ? "updated" : "created",
22470
22528
  ...listOptions.scopes?.length && { scopes: listOptions.scopes },
22471
22529
  ...listOptions.factTypes?.length && { fact_types: listOptions.factTypes },
@@ -22792,6 +22850,42 @@ function createRemoteMemoryStore(options) {
22792
22850
  relinkTopics: () => Promise.resolve([]),
22793
22851
  backfillTopics: () => Promise.resolve([])
22794
22852
  };
22853
+ const decayRow = (memory) => ({
22854
+ uniqueId: memory.memory_id,
22855
+ factType: memory.fact_type ?? null,
22856
+ eventTimeEnd: memory.event_time_end ?? null,
22857
+ eventTimeKind: memory.event_time_kind ?? null,
22858
+ updatedAt: memory.updated_at,
22859
+ lastObservedAt: memory.last_observed_at ?? null,
22860
+ archivedAt: memory.archived_at ?? null,
22861
+ source: memory.source ?? null,
22862
+ trustTier: memory.trust_tier ?? null
22863
+ });
22864
+ const decayWrite = async (rows, change, edit) => {
22865
+ if (rows.length === 0) return /* @__PURE__ */ new Set();
22866
+ const seen2 = new Map(rows.map((row) => [row.uniqueId, row]));
22867
+ const { saved, failed } = await mutateMany(
22868
+ [...seen2.keys()],
22869
+ () => change,
22870
+ (memory) => edit(memory, seen2.get(memory.memory_id))
22871
+ );
22872
+ if (failed.size)
22873
+ getLogger().warn("[memory/remote-store] Decay skipped memories:", [...failed.values()]);
22874
+ return new Set(saved.keys());
22875
+ };
22876
+ const decayBackend = {
22877
+ candidates: async () => (await pages(metadata2, { include_archived: true, include_quarantined: true })).filter(({ memory }) => memory.kind === void 0 || memory.kind === null).map(({ memory }) => decayRow(memory)),
22878
+ archive: (rows, now) => decayWrite(
22879
+ rows,
22880
+ "edit",
22881
+ (memory, seen2) => (memory.archived_at ?? null) === null && memory.updated_at === seen2.updatedAt && (memory.last_observed_at ?? null) === (seen2.lastObservedAt ?? null) ? { ...memory, archived_at: now } : null
22882
+ ),
22883
+ hardDelete: (rows, { hardDeleteWindowMs, now }) => decayWrite(
22884
+ rows,
22885
+ "membership",
22886
+ (memory) => memory.archived_at !== void 0 && memory.archived_at !== null && now - memory.archived_at > hardDeleteWindowMs ? { ...memory, is_deleted: true } : null
22887
+ )
22888
+ };
22795
22889
  const everyState = {
22796
22890
  include_deleted: true,
22797
22891
  include_archived: true,
@@ -23069,6 +23163,12 @@ function createRemoteMemoryStore(options) {
23069
23163
  else if (result.action === "update" || result.action === "merge") notify("edit");
23070
23164
  return result;
23071
23165
  },
23166
+ decay: {
23167
+ createDecaySweeper: (sweeperOptions) => createDecaySweeperOver(decayBackend, {
23168
+ ...ruleBasedDecayOptions(sweeperOptions),
23169
+ maxTransitionsPerSweep: DECAY_TRANSITIONS_PER_SWEEP
23170
+ })
23171
+ },
23072
23172
  subscribe: (onChange, subscribeOptions = {}) => {
23073
23173
  const subscriber = { onChange, options: subscribeOptions };
23074
23174
  subscribers.add(subscriber);
@@ -6511,6 +6511,8 @@ interface MemoryListOptions {
6511
6511
  includeQuarantined?: boolean;
6512
6512
  /** Memory history — rows carry `supersededBy`. */
6513
6513
  includeSuperseded?: boolean;
6514
+ /** `false` lets a remote store skip downloading vectors; its rows then carry a null `embedding`. */
6515
+ withEmbeddings?: boolean;
6514
6516
  }
6515
6517
  /**
6516
6518
  * A manual memory save. Creation uses private visibility, manual provenance
@@ -6595,6 +6597,16 @@ interface MemorySubscribeOptions {
6595
6597
  */
6596
6598
  embeddings?: boolean;
6597
6599
  }
6600
+ /** @public */
6601
+ type MemoryDecaySweeperOptions = Pick<CreateDecaySweeperOptions, "now" | "policy" | "onSwept" | "onError">;
6602
+ /**
6603
+ * Rule-based memory decay over a store's metadata, on any backend.
6604
+ * @public
6605
+ */
6606
+ interface MemoryDecay {
6607
+ /** A rule-based decay sweeper over this store's memories. */
6608
+ createDecaySweeper(options?: MemoryDecaySweeperOptions): DecaySweeper;
6609
+ }
6598
6610
  /**
6599
6611
  * Background jobs that keep a LOCAL store healthy.
6600
6612
  *
@@ -6717,6 +6729,8 @@ interface MemoryStore {
6717
6729
  subscribe(onChange: () => void, options?: MemorySubscribeOptions): () => void;
6718
6730
  /** TRANSITIONAL — see {@link MemoryMaintenance}. Absent on a remote backend. */
6719
6731
  maintenance?: MemoryMaintenance;
6732
+ /** Rule-based decay, available without the local-only {@link MemoryMaintenance}. */
6733
+ readonly decay?: MemoryDecay;
6720
6734
  /** Topic-extraction upkeep, available on every backend. */
6721
6735
  readonly topicMaintenance: MemoryTopicMaintenance;
6722
6736
  }
@@ -11462,4 +11476,4 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
11462
11476
  */
11463
11477
  declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
11464
11478
 
11465
- export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkSearchStats, 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 MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, 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 RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, 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 TopicExtractionBatchDiagnostics, 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, type WriteFailureReason, 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, encryptToolCallEventsOp, 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, migrateMemoriesToRemote, 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 };
11479
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkSearchStats, 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 MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, 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 RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, 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 TopicExtractionBatchDiagnostics, 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, type WriteFailureReason, 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, encryptToolCallEventsOp, 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, migrateMemoriesToRemote, 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 };
@@ -6511,6 +6511,8 @@ interface MemoryListOptions {
6511
6511
  includeQuarantined?: boolean;
6512
6512
  /** Memory history — rows carry `supersededBy`. */
6513
6513
  includeSuperseded?: boolean;
6514
+ /** `false` lets a remote store skip downloading vectors; its rows then carry a null `embedding`. */
6515
+ withEmbeddings?: boolean;
6514
6516
  }
6515
6517
  /**
6516
6518
  * A manual memory save. Creation uses private visibility, manual provenance
@@ -6595,6 +6597,16 @@ interface MemorySubscribeOptions {
6595
6597
  */
6596
6598
  embeddings?: boolean;
6597
6599
  }
6600
+ /** @public */
6601
+ type MemoryDecaySweeperOptions = Pick<CreateDecaySweeperOptions, "now" | "policy" | "onSwept" | "onError">;
6602
+ /**
6603
+ * Rule-based memory decay over a store's metadata, on any backend.
6604
+ * @public
6605
+ */
6606
+ interface MemoryDecay {
6607
+ /** A rule-based decay sweeper over this store's memories. */
6608
+ createDecaySweeper(options?: MemoryDecaySweeperOptions): DecaySweeper;
6609
+ }
6598
6610
  /**
6599
6611
  * Background jobs that keep a LOCAL store healthy.
6600
6612
  *
@@ -6717,6 +6729,8 @@ interface MemoryStore {
6717
6729
  subscribe(onChange: () => void, options?: MemorySubscribeOptions): () => void;
6718
6730
  /** TRANSITIONAL — see {@link MemoryMaintenance}. Absent on a remote backend. */
6719
6731
  maintenance?: MemoryMaintenance;
6732
+ /** Rule-based decay, available without the local-only {@link MemoryMaintenance}. */
6733
+ readonly decay?: MemoryDecay;
6720
6734
  /** Topic-extraction upkeep, available on every backend. */
6721
6735
  readonly topicMaintenance: MemoryTopicMaintenance;
6722
6736
  }
@@ -11462,4 +11476,4 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
11462
11476
  */
11463
11477
  declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
11464
11478
 
11465
- export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkSearchStats, 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 MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, 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 RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, 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 TopicExtractionBatchDiagnostics, 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, type WriteFailureReason, 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, encryptToolCallEventsOp, 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, migrateMemoriesToRemote, 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 };
11479
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkSearchStats, 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 MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, 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 RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, 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 TopicExtractionBatchDiagnostics, 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, type WriteFailureReason, 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, encryptToolCallEventsOp, 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, migrateMemoriesToRemote, 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 };
@@ -17095,9 +17095,51 @@ function isBorderline(input) {
17095
17095
  }
17096
17096
  return false;
17097
17097
  }
17098
+ function vaultDecayBackend(vaultCtx) {
17099
+ return {
17100
+ candidates: () => getDecayCandidatesRawOp(vaultCtx),
17101
+ archive: async (rows, now) => {
17102
+ const archived = /* @__PURE__ */ new Set();
17103
+ for (const c of rows) {
17104
+ const ok = await archiveVaultMemoryOp(vaultCtx, c.uniqueId, {
17105
+ now,
17106
+ expectedUpdatedAt: c.updatedAt,
17107
+ expectedLastObservedAt: c.lastObservedAt ?? null
17108
+ });
17109
+ if (ok) archived.add(c.uniqueId);
17110
+ }
17111
+ return archived;
17112
+ },
17113
+ hardDelete: async (rows, deleteOptions) => {
17114
+ const deleted = /* @__PURE__ */ new Set();
17115
+ for (const c of rows) {
17116
+ if (await hardDeleteDecayedOp(vaultCtx, c.uniqueId, deleteOptions)) deleted.add(c.uniqueId);
17117
+ }
17118
+ return deleted;
17119
+ }
17120
+ };
17121
+ }
17098
17122
  function createDecaySweeper(options) {
17099
- const { vaultCtx, policy, classifier, onSwept, onError } = options;
17123
+ const { vaultCtx, ...sweepOptions } = options;
17100
17124
  assertVaultScopeForSweep(vaultCtx);
17125
+ return createDecaySweeperOver(vaultDecayBackend(vaultCtx), sweepOptions);
17126
+ }
17127
+ function ruleBasedDecayOptions(options = {}) {
17128
+ if (options.classifier !== void 0)
17129
+ throw new Error(
17130
+ "MemoryStore.decay sweeps by rule only; a decay classifier needs decrypted content"
17131
+ );
17132
+ const { now, policy, onSwept, onError } = options;
17133
+ return {
17134
+ ...now !== void 0 && { now },
17135
+ ...policy && { policy },
17136
+ ...onSwept && { onSwept },
17137
+ ...onError && { onError }
17138
+ };
17139
+ }
17140
+ function createDecaySweeperOver(backend, options) {
17141
+ const { policy, classifier, onSwept, onError } = options;
17142
+ const maxTransitions = options.maxTransitionsPerSweep ?? Number.POSITIVE_INFINITY;
17101
17143
  const hardDeleteWindowMs = policy?.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs;
17102
17144
  const maxClassifierCalls = options.maxClassifierCallsPerSweep ?? DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP;
17103
17145
  const classifierCache = /* @__PURE__ */ new Map();
@@ -17139,7 +17181,7 @@ function createDecaySweeper(options) {
17139
17181
  const now = resolveNow(options.now);
17140
17182
  let candidates;
17141
17183
  try {
17142
- candidates = await getDecayCandidatesRawOp(vaultCtx);
17184
+ candidates = await backend.candidates();
17143
17185
  } catch (err) {
17144
17186
  onError?.(err instanceof Error ? err : new Error(String(err)));
17145
17187
  return emptyResult();
@@ -17162,25 +17204,37 @@ function createDecaySweeper(options) {
17162
17204
  result.scanned = candidates.length;
17163
17205
  result.classifierCalls = sweep.classifierCalls;
17164
17206
  result.classifierCapHits = sweep.classifierCapHits;
17207
+ let landed = 0;
17208
+ const apply = async (queue, run, count2) => {
17209
+ let next = 0;
17210
+ while (next < queue.length && landed < maxTransitions) {
17211
+ const batch = queue.slice(next, next + (maxTransitions - landed));
17212
+ next += batch.length;
17213
+ const done = await run(batch.map(({ candidate }) => candidate));
17214
+ for (const { candidate, source } of batch) {
17215
+ if (!done.has(candidate.uniqueId)) continue;
17216
+ landed++;
17217
+ count2(source);
17218
+ }
17219
+ }
17220
+ };
17165
17221
  try {
17166
- for (const { candidate: c, source } of toArchive) {
17167
- const ok = await archiveVaultMemoryOp(vaultCtx, c.uniqueId, {
17168
- now,
17169
- expectedUpdatedAt: c.updatedAt,
17170
- expectedLastObservedAt: c.lastObservedAt ?? null
17171
- });
17172
- if (ok) {
17222
+ await apply(
17223
+ toArchive,
17224
+ (rows) => backend.archive(rows, now),
17225
+ (source) => {
17173
17226
  result.archived++;
17174
17227
  result[source].archived++;
17175
17228
  }
17176
- }
17177
- for (const { candidate: c, source } of toDelete) {
17178
- const ok = await hardDeleteDecayedOp(vaultCtx, c.uniqueId, { hardDeleteWindowMs, now });
17179
- if (ok) {
17229
+ );
17230
+ await apply(
17231
+ toDelete,
17232
+ (rows) => backend.hardDelete(rows, { hardDeleteWindowMs, now }),
17233
+ (source) => {
17180
17234
  result.deleted++;
17181
17235
  result[source].deleted++;
17182
17236
  }
17183
- }
17237
+ );
17184
17238
  } catch (err) {
17185
17239
  onError?.(err instanceof Error ? err : new Error(String(err)));
17186
17240
  }
@@ -19224,7 +19278,10 @@ function createLocalMemoryStore(options) {
19224
19278
  return () => subscriptions.forEach((s) => s.unsubscribe());
19225
19279
  },
19226
19280
  maintenance,
19227
- topicMaintenance: maintenance
19281
+ topicMaintenance: maintenance,
19282
+ decay: {
19283
+ createDecaySweeper: (sweeperOptions) => createDecaySweeper({ ...ruleBasedDecayOptions(sweeperOptions), vaultCtx })
19284
+ }
19228
19285
  };
19229
19286
  }
19230
19287
 
@@ -20614,6 +20671,7 @@ var MAX_QUERY_TOPICS = 100;
20614
20671
  var MAX_QUERY_FILTER = 20;
20615
20672
  var GRAPH_LANE_ROWS = 256;
20616
20673
  var TEMPORAL_LANE_ROWS = 256;
20674
+ var DECAY_TRANSITIONS_PER_SWEEP = 200;
20617
20675
  var RemoteMemoryPartialCreateError = class extends Error {
20618
20676
  constructor(created, cause) {
20619
20677
  super(`createMany stored ${created.length} memories before a batch failed`);
@@ -20800,7 +20858,7 @@ function createRemoteMemoryStore(options) {
20800
20858
  )).flat();
20801
20859
  const listFilters = (listOptions) => ({
20802
20860
  ...stateFilters(listOptions),
20803
- include_embeddings: true,
20861
+ include_embeddings: listOptions.withEmbeddings !== false,
20804
20862
  order: listOptions.since ? "updated" : "created",
20805
20863
  ...listOptions.scopes?.length && { scopes: listOptions.scopes },
20806
20864
  ...listOptions.factTypes?.length && { fact_types: listOptions.factTypes },
@@ -21127,6 +21185,42 @@ function createRemoteMemoryStore(options) {
21127
21185
  relinkTopics: () => Promise.resolve([]),
21128
21186
  backfillTopics: () => Promise.resolve([])
21129
21187
  };
21188
+ const decayRow = (memory) => ({
21189
+ uniqueId: memory.memory_id,
21190
+ factType: memory.fact_type ?? null,
21191
+ eventTimeEnd: memory.event_time_end ?? null,
21192
+ eventTimeKind: memory.event_time_kind ?? null,
21193
+ updatedAt: memory.updated_at,
21194
+ lastObservedAt: memory.last_observed_at ?? null,
21195
+ archivedAt: memory.archived_at ?? null,
21196
+ source: memory.source ?? null,
21197
+ trustTier: memory.trust_tier ?? null
21198
+ });
21199
+ const decayWrite = async (rows, change, edit) => {
21200
+ if (rows.length === 0) return /* @__PURE__ */ new Set();
21201
+ const seen2 = new Map(rows.map((row) => [row.uniqueId, row]));
21202
+ const { saved, failed } = await mutateMany(
21203
+ [...seen2.keys()],
21204
+ () => change,
21205
+ (memory) => edit(memory, seen2.get(memory.memory_id))
21206
+ );
21207
+ if (failed.size)
21208
+ getLogger().warn("[memory/remote-store] Decay skipped memories:", [...failed.values()]);
21209
+ return new Set(saved.keys());
21210
+ };
21211
+ const decayBackend = {
21212
+ candidates: async () => (await pages(metadata2, { include_archived: true, include_quarantined: true })).filter(({ memory }) => memory.kind === void 0 || memory.kind === null).map(({ memory }) => decayRow(memory)),
21213
+ archive: (rows, now) => decayWrite(
21214
+ rows,
21215
+ "edit",
21216
+ (memory, seen2) => (memory.archived_at ?? null) === null && memory.updated_at === seen2.updatedAt && (memory.last_observed_at ?? null) === (seen2.lastObservedAt ?? null) ? { ...memory, archived_at: now } : null
21217
+ ),
21218
+ hardDelete: (rows, { hardDeleteWindowMs, now }) => decayWrite(
21219
+ rows,
21220
+ "membership",
21221
+ (memory) => memory.archived_at !== void 0 && memory.archived_at !== null && now - memory.archived_at > hardDeleteWindowMs ? { ...memory, is_deleted: true } : null
21222
+ )
21223
+ };
21130
21224
  const everyState = {
21131
21225
  include_deleted: true,
21132
21226
  include_archived: true,
@@ -21404,6 +21498,12 @@ function createRemoteMemoryStore(options) {
21404
21498
  else if (result.action === "update" || result.action === "merge") notify("edit");
21405
21499
  return result;
21406
21500
  },
21501
+ decay: {
21502
+ createDecaySweeper: (sweeperOptions) => createDecaySweeperOver(decayBackend, {
21503
+ ...ruleBasedDecayOptions(sweeperOptions),
21504
+ maxTransitionsPerSweep: DECAY_TRANSITIONS_PER_SWEEP
21505
+ })
21506
+ },
21407
21507
  subscribe: (onChange, subscribeOptions = {}) => {
21408
21508
  const subscriber = { onChange, options: subscribeOptions };
21409
21509
  subscribers.add(subscriber);