@smyslenny/agent-memory 5.0.1 → 5.1.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/index.d.ts CHANGED
@@ -72,6 +72,46 @@ declare function createMemory(db: Database.Database, input: CreateMemoryInput):
72
72
  declare function getMemory(db: Database.Database, id: string): Memory | null;
73
73
  declare function updateMemory(db: Database.Database, id: string, input: UpdateMemoryInput): Memory | null;
74
74
  declare function deleteMemory(db: Database.Database, id: string): boolean;
75
+ interface ArchivedMemory {
76
+ id: string;
77
+ content: string;
78
+ type: string;
79
+ priority: number;
80
+ emotion_val: number;
81
+ vitality: number;
82
+ stability: number;
83
+ access_count: number;
84
+ last_accessed: string | null;
85
+ created_at: string;
86
+ updated_at: string;
87
+ archived_at: string;
88
+ archive_reason: string;
89
+ source: string | null;
90
+ agent_id: string;
91
+ hash: string | null;
92
+ emotion_tag: string | null;
93
+ source_session: string | null;
94
+ source_context: string | null;
95
+ observed_at: string | null;
96
+ }
97
+ /**
98
+ * Archive a memory to memory_archive, then delete from memories.
99
+ * If minVitality is set (default 0.1), memories below that threshold
100
+ * are directly deleted without archiving — they're decayed noise.
101
+ * Returns "archived" if actually archived, "deleted" if skipped to direct delete,
102
+ * or false if memory not found.
103
+ */
104
+ declare function archiveMemory(db: Database.Database, id: string, reason?: string, opts?: {
105
+ minVitality?: number;
106
+ }): "archived" | "deleted" | false;
107
+ declare function restoreMemory(db: Database.Database, id: string): Memory | null;
108
+ declare function listArchivedMemories(db: Database.Database, opts?: {
109
+ agent_id?: string;
110
+ limit?: number;
111
+ }): ArchivedMemory[];
112
+ declare function purgeArchive(db: Database.Database, opts?: {
113
+ agent_id?: string;
114
+ }): number;
75
115
  declare function listMemories(db: Database.Database, opts?: {
76
116
  agent_id?: string;
77
117
  type?: MemoryType;
@@ -330,6 +370,16 @@ declare function fusionScore(input: {
330
370
  recency_boost?: number;
331
371
  }): number;
332
372
  declare function fuseHybridResults(lexical: SearchResult[], vector: VectorSearchResult[], limit: number, recency_boost?: number): HybridRecallResult[];
373
+ interface RelatedLink {
374
+ memory: Memory;
375
+ sourceId: string;
376
+ weight: number;
377
+ }
378
+ /**
379
+ * Fetch related memories from the links table for a set of source memory IDs.
380
+ * Shared by both recall and surface expansion paths.
381
+ */
382
+ declare function fetchRelatedLinks(db: Database.Database, sourceIds: string[], agentId: string, excludeIds: Set<string>, maxPerSource?: number): RelatedLink[];
333
383
  declare function recallMemories(db: Database.Database, query: string, opts?: RecallOptions): Promise<HybridRecallResponse>;
334
384
  declare function reindexEmbeddings(db: Database.Database, opts?: ReindexOptions): Promise<ReindexEmbeddingsResult>;
335
385
  declare function reindexMemorySearch(db: Database.Database, opts?: ReindexOptions): Promise<ReindexSearchResult>;
@@ -410,6 +460,8 @@ interface SurfaceResult {
410
460
  lexical_rank?: number;
411
461
  semantic_rank?: number;
412
462
  semantic_similarity?: number;
463
+ related_source_id?: string;
464
+ match_type?: "direct" | "related";
413
465
  }
414
466
  interface SurfaceResponse {
415
467
  count: number;
@@ -505,6 +557,10 @@ interface ReflectInput {
505
557
  }
506
558
  declare function reflectMemories(db: Database.Database, input: ReflectInput): Promise<ReflectRunResult>;
507
559
 
560
+ interface CapacityInfo {
561
+ count: number;
562
+ limit: number | null;
563
+ }
508
564
  interface StatusResult {
509
565
  total: number;
510
566
  by_type: Record<string, number>;
@@ -513,6 +569,7 @@ interface StatusResult {
513
569
  low_vitality: number;
514
570
  feedback_events: number;
515
571
  agent_id: string;
572
+ capacity: Record<string, CapacityInfo>;
516
573
  }
517
574
  declare function getMemoryStatus(db: Database.Database, input?: {
518
575
  agent_id?: string;
@@ -752,6 +809,8 @@ interface GovernResult {
752
809
  orphanPaths: number;
753
810
  emptyMemories: number;
754
811
  evicted: number;
812
+ archived: number;
813
+ evictedByType: Record<string, number>;
755
814
  }
756
815
  interface EvictionCandidate {
757
816
  memory: Memory;
@@ -771,13 +830,28 @@ declare function computeEvictionScore(input: {
771
830
  declare function rankEvictionCandidates(db: Database.Database, opts?: {
772
831
  agent_id?: string;
773
832
  }): EvictionCandidate[];
833
+ interface TieredCapacity {
834
+ identity: number | null;
835
+ emotion: number | null;
836
+ knowledge: number | null;
837
+ event: number | null;
838
+ total: number;
839
+ }
840
+ declare function getTieredCapacity(opts?: {
841
+ maxMemories?: number;
842
+ }): TieredCapacity;
774
843
  /**
775
844
  * Run governance checks and cleanup:
776
845
  * 1. Remove orphan paths (no parent memory)
777
846
  * 2. Remove empty memories (blank content)
778
- * 3. Evict low-value memories when over capacity using eviction_score
847
+ * 3. Evict low-value memories when over capacity using tiered + global eviction
848
+ *
849
+ * Tiered capacity can be set via env vars:
850
+ * AGENT_MEMORY_MAX_IDENTITY, AGENT_MEMORY_MAX_EMOTION,
851
+ * AGENT_MEMORY_MAX_KNOWLEDGE, AGENT_MEMORY_MAX_EVENT,
852
+ * AGENT_MEMORY_MAX_MEMORIES (global cap, default 350)
779
853
  *
780
- * maxMemories can be set via AGENT_MEMORY_MAX_MEMORIES env var (default: 200).
854
+ * Evicted memories are archived to memory_archive before deletion.
781
855
  */
782
856
  declare function runGovern(db: Database.Database, opts?: {
783
857
  agent_id?: string;
@@ -831,4 +905,4 @@ declare function formatNarrativeBoot(layers: {
831
905
  */
832
906
  declare function boot(db: Database.Database, opts?: WarmBootOptions): WarmBootResult;
833
907
 
834
- export { type AgentMemoryHttpServer, type ReflectInput as AppReflectInput, type ReflectProgressEvent as AppReflectProgressEvent, type AutoIngestWatcher, type AutoIngestWatcherOptions, type BootResult, type ConflictInfo, type ConflictType, type CreateMemoryInput, type DedupScoreBreakdown, type EmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderKind, type EmbeddingProviderOptions, type EmbeddingStatus, type EvictionCandidate, type ExportResult, type FeedbackEventInput, type FeedbackEventRecord, type FeedbackSource, type FeedbackSummary, type GovernResult, type GuardAction, type GuardInput, type GuardResult, type HttpJobStatus, type HttpServerOptions, type HybridRecallResponse, type HybridRecallResult, type IngestExtractedItem, type IngestResult, type IngestRunOptions, type MaintenanceJob, type MaintenancePhase, type MaintenanceStatus, type Memory, type MemoryType, type MergeContext, type MergePlan, type Path, type PendingEmbeddingRecord, type Priority, type RecallInput, type ReflectCheckpoint, type ReflectOptions, type ReflectProgressEvent$1 as ReflectProgressEvent, type ReflectRunResult, type ReflectRunners, type ReflectStats, type ReflectStep, type ReindexEmbeddingsResult, type ReindexInput, type ReindexProgressEvent, type ReindexSearchResult, type RememberInput, type SearchResult, type StatusResult, type StoredEmbedding, type SurfaceInput, type SurfaceIntent, type SurfaceResponse, type SurfaceResult, type SyncInput, type SyncResult, type TidyResult, type UpdateMemoryInput, type VectorSearchResult, type WarmBootOptions, type WarmBootResult, boot, buildFtsQuery, buildMergePlan, calculateVitality, classifyIngestType, completeMaintenanceJob, computeEvictionScore, contentHash, cosineSimilarity, countMemories, createEmbeddingProvider, createHttpServer, createInitialCheckpoint, createLocalHttpEmbeddingProvider, createMaintenanceJob, createMemory, createOpenAICompatibleEmbeddingProvider, createPath, decodeVector, deleteMemory, deletePath, encodeVector, exportMemories, extractIngestItems, failMaintenanceJob, findResumableMaintenanceJob, formatNarrativeBoot, formatRelativeDate, fuseHybridResults, fusionScore, getConfiguredEmbeddingProviderId, getDecayedMemories, getEmbedding, getEmbeddingProvider, getEmbeddingProviderConfigFromEnv, getEmbeddingProviderFromEnv, getFeedbackScore, getFeedbackSummary, getMaintenanceJob, getMemory, getMemoryStatus, getPath, getPathByUri, getPathsByDomain, getPathsByMemory, getPathsByPrefix, guard, healthcheckEmbeddingProvider, ingestText, isStaleContent, listMemories, listPendingEmbeddings, loadWarmBootLayers, markAllEmbeddingsPending, markEmbeddingFailed, markMemoryEmbeddingPending, parseUri, priorityPrior, rankEvictionCandidates, rebuildBm25Index, recallMemories, recallMemory, recordAccess, recordFeedbackEvent, recordPassiveFeedback, reflectMemories, reindexEmbeddings, reindexMemories, reindexMemorySearch, rememberMemory, runAutoIngestWatcher, runDecay, runGovern, runReflectOrchestrator, runTidy, searchBM25, searchByVector, slugify, splitIngestBlocks, startHttpServer, surfaceMemories, syncBatch, syncOne, tokenize, updateMaintenanceCheckpoint, updateMemory, upsertReadyEmbedding };
908
+ export { type AgentMemoryHttpServer, type ReflectInput as AppReflectInput, type ReflectProgressEvent as AppReflectProgressEvent, type ArchivedMemory, type AutoIngestWatcher, type AutoIngestWatcherOptions, type BootResult, type CapacityInfo, type ConflictInfo, type ConflictType, type CreateMemoryInput, type DedupScoreBreakdown, type EmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderKind, type EmbeddingProviderOptions, type EmbeddingStatus, type EvictionCandidate, type ExportResult, type FeedbackEventInput, type FeedbackEventRecord, type FeedbackSource, type FeedbackSummary, type GovernResult, type GuardAction, type GuardInput, type GuardResult, type HttpJobStatus, type HttpServerOptions, type HybridRecallResponse, type HybridRecallResult, type IngestExtractedItem, type IngestResult, type IngestRunOptions, type MaintenanceJob, type MaintenancePhase, type MaintenanceStatus, type Memory, type MemoryType, type MergeContext, type MergePlan, type Path, type PendingEmbeddingRecord, type Priority, type RecallInput, type ReflectCheckpoint, type ReflectOptions, type ReflectProgressEvent$1 as ReflectProgressEvent, type ReflectRunResult, type ReflectRunners, type ReflectStats, type ReflectStep, type ReindexEmbeddingsResult, type ReindexInput, type ReindexProgressEvent, type ReindexSearchResult, type RelatedLink, type RememberInput, type SearchResult, type StatusResult, type StoredEmbedding, type SurfaceInput, type SurfaceIntent, type SurfaceResponse, type SurfaceResult, type SyncInput, type SyncResult, type TidyResult, type TieredCapacity, type UpdateMemoryInput, type VectorSearchResult, type WarmBootOptions, type WarmBootResult, archiveMemory, boot, buildFtsQuery, buildMergePlan, calculateVitality, classifyIngestType, completeMaintenanceJob, computeEvictionScore, contentHash, cosineSimilarity, countMemories, createEmbeddingProvider, createHttpServer, createInitialCheckpoint, createLocalHttpEmbeddingProvider, createMaintenanceJob, createMemory, createOpenAICompatibleEmbeddingProvider, createPath, decodeVector, deleteMemory, deletePath, encodeVector, exportMemories, extractIngestItems, failMaintenanceJob, fetchRelatedLinks, findResumableMaintenanceJob, formatNarrativeBoot, formatRelativeDate, fuseHybridResults, fusionScore, getConfiguredEmbeddingProviderId, getDecayedMemories, getEmbedding, getEmbeddingProvider, getEmbeddingProviderConfigFromEnv, getEmbeddingProviderFromEnv, getFeedbackScore, getFeedbackSummary, getMaintenanceJob, getMemory, getMemoryStatus, getPath, getPathByUri, getPathsByDomain, getPathsByMemory, getPathsByPrefix, getTieredCapacity, guard, healthcheckEmbeddingProvider, ingestText, isStaleContent, listArchivedMemories, listMemories, listPendingEmbeddings, loadWarmBootLayers, markAllEmbeddingsPending, markEmbeddingFailed, markMemoryEmbeddingPending, parseUri, priorityPrior, purgeArchive, rankEvictionCandidates, rebuildBm25Index, recallMemories, recallMemory, recordAccess, recordFeedbackEvent, recordPassiveFeedback, reflectMemories, reindexEmbeddings, reindexMemories, reindexMemorySearch, rememberMemory, restoreMemory, runAutoIngestWatcher, runDecay, runGovern, runReflectOrchestrator, runTidy, searchBM25, searchByVector, slugify, splitIngestBlocks, startHttpServer, surfaceMemories, syncBatch, syncOne, tokenize, updateMaintenanceCheckpoint, updateMemory, upsertReadyEmbedding };