@mnemoai/core 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.d.ts +128 -0
- package/dist/index.d.ts.map +1 -0
- package/{index.ts → dist/index.js} +526 -1333
- package/dist/index.js.map +7 -0
- package/dist/src/access-tracker.d.ts +97 -0
- package/dist/src/access-tracker.d.ts.map +1 -0
- package/dist/src/access-tracker.js +184 -0
- package/dist/src/access-tracker.js.map +7 -0
- package/dist/src/adapters/chroma.d.ts +31 -0
- package/dist/src/adapters/chroma.d.ts.map +1 -0
- package/{src/adapters/chroma.ts → dist/src/adapters/chroma.js} +45 -107
- package/dist/src/adapters/chroma.js.map +7 -0
- package/dist/src/adapters/lancedb.d.ts +29 -0
- package/dist/src/adapters/lancedb.d.ts.map +1 -0
- package/{src/adapters/lancedb.ts → dist/src/adapters/lancedb.js} +41 -109
- package/dist/src/adapters/lancedb.js.map +7 -0
- package/dist/src/adapters/pgvector.d.ts +33 -0
- package/dist/src/adapters/pgvector.d.ts.map +1 -0
- package/{src/adapters/pgvector.ts → dist/src/adapters/pgvector.js} +42 -104
- package/dist/src/adapters/pgvector.js.map +7 -0
- package/dist/src/adapters/qdrant.d.ts +34 -0
- package/dist/src/adapters/qdrant.d.ts.map +1 -0
- package/dist/src/adapters/qdrant.js +132 -0
- package/dist/src/adapters/qdrant.js.map +7 -0
- package/dist/src/adaptive-retrieval.d.ts +14 -0
- package/dist/src/adaptive-retrieval.d.ts.map +1 -0
- package/dist/src/adaptive-retrieval.js +52 -0
- package/dist/src/adaptive-retrieval.js.map +7 -0
- package/dist/src/audit-log.d.ts +56 -0
- package/dist/src/audit-log.d.ts.map +1 -0
- package/dist/src/audit-log.js +139 -0
- package/dist/src/audit-log.js.map +7 -0
- package/dist/src/chunker.d.ts +45 -0
- package/dist/src/chunker.d.ts.map +1 -0
- package/dist/src/chunker.js +157 -0
- package/dist/src/chunker.js.map +7 -0
- package/dist/src/config.d.ts +70 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +142 -0
- package/dist/src/config.js.map +7 -0
- package/dist/src/decay-engine.d.ts +73 -0
- package/dist/src/decay-engine.d.ts.map +1 -0
- package/dist/src/decay-engine.js +119 -0
- package/dist/src/decay-engine.js.map +7 -0
- package/dist/src/embedder.d.ts +94 -0
- package/dist/src/embedder.d.ts.map +1 -0
- package/{src/embedder.ts → dist/src/embedder.js} +119 -317
- package/dist/src/embedder.js.map +7 -0
- package/dist/src/extraction-prompts.d.ts +12 -0
- package/dist/src/extraction-prompts.d.ts.map +1 -0
- package/dist/src/extraction-prompts.js +311 -0
- package/dist/src/extraction-prompts.js.map +7 -0
- package/dist/src/license.d.ts +29 -0
- package/dist/src/license.d.ts.map +1 -0
- package/{src/license.ts → dist/src/license.js} +42 -113
- package/dist/src/license.js.map +7 -0
- package/dist/src/llm-client.d.ts +23 -0
- package/dist/src/llm-client.d.ts.map +1 -0
- package/{src/llm-client.ts → dist/src/llm-client.js} +22 -55
- package/dist/src/llm-client.js.map +7 -0
- package/dist/src/logger.d.ts +33 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +35 -0
- package/dist/src/logger.js.map +7 -0
- package/dist/src/mcp-server.d.ts +16 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/{src/mcp-server.ts → dist/src/mcp-server.js} +81 -181
- package/dist/src/mcp-server.js.map +7 -0
- package/dist/src/memory-categories.d.ts +40 -0
- package/dist/src/memory-categories.d.ts.map +1 -0
- package/dist/src/memory-categories.js +33 -0
- package/dist/src/memory-categories.js.map +7 -0
- package/dist/src/memory-upgrader.d.ts +71 -0
- package/dist/src/memory-upgrader.d.ts.map +1 -0
- package/dist/src/memory-upgrader.js +238 -0
- package/dist/src/memory-upgrader.js.map +7 -0
- package/dist/src/migrate.d.ts +47 -0
- package/dist/src/migrate.d.ts.map +1 -0
- package/{src/migrate.ts → dist/src/migrate.js} +57 -165
- package/dist/src/migrate.js.map +7 -0
- package/dist/src/mnemo.d.ts +67 -0
- package/dist/src/mnemo.d.ts.map +1 -0
- package/dist/src/mnemo.js +66 -0
- package/dist/src/mnemo.js.map +7 -0
- package/dist/src/noise-filter.d.ts +23 -0
- package/dist/src/noise-filter.d.ts.map +1 -0
- package/dist/src/noise-filter.js +62 -0
- package/dist/src/noise-filter.js.map +7 -0
- package/dist/src/noise-prototypes.d.ts +40 -0
- package/dist/src/noise-prototypes.d.ts.map +1 -0
- package/dist/src/noise-prototypes.js +116 -0
- package/dist/src/noise-prototypes.js.map +7 -0
- package/dist/src/observability.d.ts +16 -0
- package/dist/src/observability.d.ts.map +1 -0
- package/dist/src/observability.js +53 -0
- package/dist/src/observability.js.map +7 -0
- package/dist/src/query-tracker.d.ts +27 -0
- package/dist/src/query-tracker.d.ts.map +1 -0
- package/dist/src/query-tracker.js +32 -0
- package/dist/src/query-tracker.js.map +7 -0
- package/dist/src/reflection-event-store.d.ts +44 -0
- package/dist/src/reflection-event-store.d.ts.map +1 -0
- package/dist/src/reflection-event-store.js +50 -0
- package/dist/src/reflection-event-store.js.map +7 -0
- package/dist/src/reflection-item-store.d.ts +58 -0
- package/dist/src/reflection-item-store.d.ts.map +1 -0
- package/dist/src/reflection-item-store.js +69 -0
- package/dist/src/reflection-item-store.js.map +7 -0
- package/dist/src/reflection-mapped-metadata.d.ts +47 -0
- package/dist/src/reflection-mapped-metadata.d.ts.map +1 -0
- package/dist/src/reflection-mapped-metadata.js +40 -0
- package/dist/src/reflection-mapped-metadata.js.map +7 -0
- package/dist/src/reflection-metadata.d.ts +11 -0
- package/dist/src/reflection-metadata.d.ts.map +1 -0
- package/dist/src/reflection-metadata.js +24 -0
- package/dist/src/reflection-metadata.js.map +7 -0
- package/dist/src/reflection-ranking.d.ts +13 -0
- package/dist/src/reflection-ranking.d.ts.map +1 -0
- package/{src/reflection-ranking.ts → dist/src/reflection-ranking.js} +12 -21
- package/dist/src/reflection-ranking.js.map +7 -0
- package/dist/src/reflection-retry.d.ts +30 -0
- package/dist/src/reflection-retry.d.ts.map +1 -0
- package/{src/reflection-retry.ts → dist/src/reflection-retry.js} +24 -64
- package/dist/src/reflection-retry.js.map +7 -0
- package/dist/src/reflection-slices.d.ts +42 -0
- package/dist/src/reflection-slices.d.ts.map +1 -0
- package/{src/reflection-slices.ts → dist/src/reflection-slices.js} +60 -136
- package/dist/src/reflection-slices.js.map +7 -0
- package/dist/src/reflection-store.d.ts +85 -0
- package/dist/src/reflection-store.d.ts.map +1 -0
- package/dist/src/reflection-store.js +407 -0
- package/dist/src/reflection-store.js.map +7 -0
- package/dist/src/resonance-state.d.ts +19 -0
- package/dist/src/resonance-state.d.ts.map +1 -0
- package/{src/resonance-state.ts → dist/src/resonance-state.js} +13 -42
- package/dist/src/resonance-state.js.map +7 -0
- package/dist/src/retriever.d.ts +228 -0
- package/dist/src/retriever.d.ts.map +1 -0
- package/dist/src/retriever.js +1006 -0
- package/dist/src/retriever.js.map +7 -0
- package/dist/src/scopes.d.ts +58 -0
- package/dist/src/scopes.d.ts.map +1 -0
- package/dist/src/scopes.js +252 -0
- package/dist/src/scopes.js.map +7 -0
- package/dist/src/self-improvement-files.d.ts +20 -0
- package/dist/src/self-improvement-files.d.ts.map +1 -0
- package/{src/self-improvement-files.ts → dist/src/self-improvement-files.js} +24 -49
- package/dist/src/self-improvement-files.js.map +7 -0
- package/dist/src/semantic-gate.d.ts +24 -0
- package/dist/src/semantic-gate.d.ts.map +1 -0
- package/dist/src/semantic-gate.js +86 -0
- package/dist/src/semantic-gate.js.map +7 -0
- package/dist/src/session-recovery.d.ts +9 -0
- package/dist/src/session-recovery.d.ts.map +1 -0
- package/{src/session-recovery.ts → dist/src/session-recovery.js} +40 -57
- package/dist/src/session-recovery.js.map +7 -0
- package/dist/src/smart-extractor.d.ts +107 -0
- package/dist/src/smart-extractor.d.ts.map +1 -0
- package/{src/smart-extractor.ts → dist/src/smart-extractor.js} +130 -383
- package/dist/src/smart-extractor.js.map +7 -0
- package/dist/src/smart-metadata.d.ts +103 -0
- package/dist/src/smart-metadata.d.ts.map +1 -0
- package/dist/src/smart-metadata.js +361 -0
- package/dist/src/smart-metadata.js.map +7 -0
- package/dist/src/storage-adapter.d.ts +102 -0
- package/dist/src/storage-adapter.d.ts.map +1 -0
- package/dist/src/storage-adapter.js +22 -0
- package/dist/src/storage-adapter.js.map +7 -0
- package/dist/src/store.d.ts +108 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +939 -0
- package/dist/src/store.js.map +7 -0
- package/dist/src/tier-manager.d.ts +57 -0
- package/dist/src/tier-manager.d.ts.map +1 -0
- package/dist/src/tier-manager.js +80 -0
- package/dist/src/tier-manager.js.map +7 -0
- package/dist/src/tools.d.ts +43 -0
- package/dist/src/tools.d.ts.map +1 -0
- package/dist/src/tools.js +1075 -0
- package/dist/src/tools.js.map +7 -0
- package/dist/src/wal-recovery.d.ts +30 -0
- package/dist/src/wal-recovery.d.ts.map +1 -0
- package/{src/wal-recovery.ts → dist/src/wal-recovery.js} +26 -79
- package/dist/src/wal-recovery.js.map +7 -0
- package/package.json +21 -2
- package/openclaw.plugin.json +0 -815
- package/src/access-tracker.ts +0 -341
- package/src/adapters/README.md +0 -78
- package/src/adapters/qdrant.ts +0 -191
- package/src/adaptive-retrieval.ts +0 -90
- package/src/audit-log.ts +0 -238
- package/src/chunker.ts +0 -254
- package/src/config.ts +0 -271
- package/src/decay-engine.ts +0 -238
- package/src/extraction-prompts.ts +0 -339
- package/src/memory-categories.ts +0 -71
- package/src/memory-upgrader.ts +0 -388
- package/src/mnemo.ts +0 -142
- package/src/noise-filter.ts +0 -97
- package/src/noise-prototypes.ts +0 -164
- package/src/observability.ts +0 -81
- package/src/query-tracker.ts +0 -57
- package/src/reflection-event-store.ts +0 -98
- package/src/reflection-item-store.ts +0 -112
- package/src/reflection-mapped-metadata.ts +0 -84
- package/src/reflection-metadata.ts +0 -23
- package/src/reflection-store.ts +0 -602
- package/src/retriever.ts +0 -1510
- package/src/scopes.ts +0 -375
- package/src/semantic-gate.ts +0 -121
- package/src/smart-metadata.ts +0 -561
- package/src/storage-adapter.ts +0 -153
- package/src/store.ts +0 -1330
- package/src/tier-manager.ts +0 -189
- package/src/tools.ts +0 -1292
- package/test/core.test.mjs +0 -301
package/src/tier-manager.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
/**
|
|
3
|
-
* Tier Manager — Three-tier memory promotion/demotion system
|
|
4
|
-
*
|
|
5
|
-
* Tiers:
|
|
6
|
-
* - Core (decay floor 0.9): Identity-level facts, almost never forgotten
|
|
7
|
-
* - Working (decay floor 0.7): Active context, ages out without reinforcement
|
|
8
|
-
* - Peripheral (decay floor 0.5): Low-priority or aging memories
|
|
9
|
-
*
|
|
10
|
-
* Promotion: Peripheral → Working → Core (based on access, composite score, importance)
|
|
11
|
-
* Demotion: Core → Working → Peripheral (based on decay, age)
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type { MemoryTier } from "./memory-categories.js";
|
|
15
|
-
import type { DecayScore } from "./decay-engine.js";
|
|
16
|
-
|
|
17
|
-
// ============================================================================
|
|
18
|
-
// Types
|
|
19
|
-
// ============================================================================
|
|
20
|
-
|
|
21
|
-
export interface TierConfig {
|
|
22
|
-
/** Minimum access count for Core promotion (default: 10) */
|
|
23
|
-
coreAccessThreshold: number;
|
|
24
|
-
/** Minimum composite decay score for Core promotion (default: 0.7) */
|
|
25
|
-
coreCompositeThreshold: number;
|
|
26
|
-
/** Minimum importance for Core promotion (default: 0.8) */
|
|
27
|
-
coreImportanceThreshold: number;
|
|
28
|
-
/** Composite threshold below which to demote to Peripheral (default: 0.15) */
|
|
29
|
-
peripheralCompositeThreshold: number;
|
|
30
|
-
/** Age in days after which infrequent memories demote to Peripheral (default: 60) */
|
|
31
|
-
peripheralAgeDays: number;
|
|
32
|
-
/** Minimum access count for Working promotion from Peripheral (default: 3) */
|
|
33
|
-
workingAccessThreshold: number;
|
|
34
|
-
/** Minimum composite for Working promotion from Peripheral (default: 0.4) */
|
|
35
|
-
workingCompositeThreshold: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const DEFAULT_TIER_CONFIG: TierConfig = {
|
|
39
|
-
coreAccessThreshold: 10,
|
|
40
|
-
coreCompositeThreshold: 0.7,
|
|
41
|
-
coreImportanceThreshold: 0.8,
|
|
42
|
-
peripheralCompositeThreshold: 0.15,
|
|
43
|
-
peripheralAgeDays: 60,
|
|
44
|
-
workingAccessThreshold: 3,
|
|
45
|
-
workingCompositeThreshold: 0.4,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export interface TierTransition {
|
|
49
|
-
memoryId: string;
|
|
50
|
-
fromTier: MemoryTier;
|
|
51
|
-
toTier: MemoryTier;
|
|
52
|
-
reason: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Minimal memory fields needed for tier evaluation. */
|
|
56
|
-
export interface TierableMemory {
|
|
57
|
-
id: string;
|
|
58
|
-
tier: MemoryTier;
|
|
59
|
-
importance: number;
|
|
60
|
-
accessCount: number;
|
|
61
|
-
createdAt: number;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface TierManager {
|
|
65
|
-
/**
|
|
66
|
-
* Evaluate whether a memory should change tiers.
|
|
67
|
-
* Returns the transition if a change is needed, null otherwise.
|
|
68
|
-
*/
|
|
69
|
-
evaluate(
|
|
70
|
-
memory: TierableMemory,
|
|
71
|
-
decayScore: DecayScore,
|
|
72
|
-
now?: number,
|
|
73
|
-
): TierTransition | null;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Evaluate multiple memories and return all transitions.
|
|
77
|
-
*/
|
|
78
|
-
evaluateAll(
|
|
79
|
-
memories: TierableMemory[],
|
|
80
|
-
decayScores: DecayScore[],
|
|
81
|
-
now?: number,
|
|
82
|
-
): TierTransition[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ============================================================================
|
|
86
|
-
// Factory
|
|
87
|
-
// ============================================================================
|
|
88
|
-
|
|
89
|
-
const MS_PER_DAY = 86_400_000;
|
|
90
|
-
|
|
91
|
-
export function createTierManager(
|
|
92
|
-
config: TierConfig = DEFAULT_TIER_CONFIG,
|
|
93
|
-
): TierManager {
|
|
94
|
-
function evaluate(
|
|
95
|
-
memory: TierableMemory,
|
|
96
|
-
decayScore: DecayScore,
|
|
97
|
-
now: number = Date.now(),
|
|
98
|
-
): TierTransition | null {
|
|
99
|
-
const ageDays = (now - memory.createdAt) / MS_PER_DAY;
|
|
100
|
-
|
|
101
|
-
switch (memory.tier) {
|
|
102
|
-
case "peripheral": {
|
|
103
|
-
// Promote to Working?
|
|
104
|
-
if (
|
|
105
|
-
memory.accessCount >= config.workingAccessThreshold &&
|
|
106
|
-
decayScore.composite >= config.workingCompositeThreshold
|
|
107
|
-
) {
|
|
108
|
-
return {
|
|
109
|
-
memoryId: memory.id,
|
|
110
|
-
fromTier: "peripheral",
|
|
111
|
-
toTier: "working",
|
|
112
|
-
reason: `Access count (${memory.accessCount}) >= ${config.workingAccessThreshold} and composite (${decayScore.composite.toFixed(2)}) >= ${config.workingCompositeThreshold}`,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
case "working": {
|
|
119
|
-
// Promote to Core?
|
|
120
|
-
if (
|
|
121
|
-
memory.accessCount >= config.coreAccessThreshold &&
|
|
122
|
-
decayScore.composite >= config.coreCompositeThreshold &&
|
|
123
|
-
memory.importance >= config.coreImportanceThreshold
|
|
124
|
-
) {
|
|
125
|
-
return {
|
|
126
|
-
memoryId: memory.id,
|
|
127
|
-
fromTier: "working",
|
|
128
|
-
toTier: "core",
|
|
129
|
-
reason: `High access (${memory.accessCount}), composite (${decayScore.composite.toFixed(2)}), importance (${memory.importance})`,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Demote to Peripheral?
|
|
134
|
-
if (
|
|
135
|
-
decayScore.composite < config.peripheralCompositeThreshold ||
|
|
136
|
-
(ageDays > config.peripheralAgeDays &&
|
|
137
|
-
memory.accessCount < config.workingAccessThreshold)
|
|
138
|
-
) {
|
|
139
|
-
return {
|
|
140
|
-
memoryId: memory.id,
|
|
141
|
-
fromTier: "working",
|
|
142
|
-
toTier: "peripheral",
|
|
143
|
-
reason: `Low composite (${decayScore.composite.toFixed(2)}) or aged ${ageDays.toFixed(0)} days with low access (${memory.accessCount})`,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
case "core": {
|
|
150
|
-
// Demote to Working? (Core rarely demotes, but it can)
|
|
151
|
-
if (
|
|
152
|
-
decayScore.composite < config.peripheralCompositeThreshold &&
|
|
153
|
-
memory.accessCount < config.workingAccessThreshold
|
|
154
|
-
) {
|
|
155
|
-
return {
|
|
156
|
-
memoryId: memory.id,
|
|
157
|
-
fromTier: "core",
|
|
158
|
-
toTier: "working",
|
|
159
|
-
reason: `Severely low composite (${decayScore.composite.toFixed(2)}) and access (${memory.accessCount})`,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
evaluate,
|
|
171
|
-
|
|
172
|
-
evaluateAll(memories, decayScores, now = Date.now()) {
|
|
173
|
-
const scoreMap = new Map(decayScores.map((s) => [s.memoryId, s]));
|
|
174
|
-
const transitions: TierTransition[] = [];
|
|
175
|
-
|
|
176
|
-
for (const memory of memories) {
|
|
177
|
-
const score = scoreMap.get(memory.id);
|
|
178
|
-
if (!score) continue;
|
|
179
|
-
|
|
180
|
-
const transition = evaluate(memory, score, now);
|
|
181
|
-
if (transition) {
|
|
182
|
-
transitions.push(transition);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return transitions;
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
}
|