@shadowforge0/aquifer-memory 1.8.1 → 1.9.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/.env.example +1 -0
- package/README.md +82 -26
- package/README_CN.md +33 -23
- package/README_TW.md +25 -24
- package/aquifer.config.example.json +2 -1
- package/consumers/cli.js +587 -33
- package/consumers/codex-active-checkpoint.js +3 -1
- package/consumers/codex-current-memory.js +10 -6
- package/consumers/codex.js +6 -3
- package/consumers/default/daily-entries.js +2 -2
- package/consumers/default/index.js +40 -30
- package/consumers/default/prompts/summary.js +2 -2
- package/consumers/mcp.js +56 -46
- package/consumers/openclaw-ext/index.js +65 -7
- package/consumers/openclaw-ext/openclaw.plugin.json +1 -1
- package/consumers/openclaw-ext/package.json +1 -1
- package/consumers/openclaw-install.js +326 -0
- package/consumers/openclaw-plugin.js +105 -24
- package/consumers/shared/compat-recall.js +101 -0
- package/consumers/shared/config.js +2 -0
- package/consumers/shared/openclaw-product-tools.js +130 -0
- package/consumers/shared/recall-format.js +2 -2
- package/core/aquifer.js +553 -41
- package/core/backends/local.js +169 -1
- package/core/doctor.js +924 -0
- package/core/finalization-inspector.js +164 -0
- package/core/finalization-review.js +88 -42
- package/core/interface.js +629 -0
- package/core/mcp-manifest.js +11 -3
- package/core/memory-bootstrap.js +25 -27
- package/core/memory-consolidation.js +564 -42
- package/core/memory-explain.js +593 -0
- package/core/memory-promotion.js +392 -55
- package/core/memory-recall.js +75 -71
- package/core/memory-records.js +107 -108
- package/core/memory-review.js +891 -0
- package/core/memory-serving.js +61 -4
- package/core/memory-type-policy.js +298 -0
- package/core/operator-observability.js +249 -0
- package/core/postgres-migrations.js +22 -0
- package/core/session-checkpoint-producer.js +3 -1
- package/core/session-checkpoints.js +1 -1
- package/core/session-finalization.js +78 -3
- package/core/storage.js +124 -8
- package/docs/getting-started.md +50 -4
- package/docs/setup.md +163 -24
- package/package.json +5 -4
- package/schema/004-completion.sql +4 -4
- package/schema/010-v1-finalization-review.sql +72 -0
- package/schema/019-v1-memory-review-resolutions.sql +53 -0
- package/schema/020-v1-assistant-shaping-memory.sql +30 -0
- package/scripts/backfill-canonical-key.js +1 -1
- package/scripts/codex-checkpoint-commands.js +28 -0
- package/scripts/codex-checkpoint-runtime.js +109 -0
- package/scripts/codex-recovery.js +16 -4
- package/scripts/diagnose-fts-zh.js +1 -1
- package/scripts/extract-insights-from-recent-sessions.js +4 -4
package/core/memory-bootstrap.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
fact: 5,
|
|
10
|
-
conclusion: 6,
|
|
11
|
-
entity_note: 7,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const AUTHORITY_PRIORITY = {
|
|
15
|
-
user_explicit: 0,
|
|
16
|
-
executable_evidence: 1,
|
|
17
|
-
manual: 2,
|
|
18
|
-
system: 3,
|
|
19
|
-
verified_summary: 4,
|
|
20
|
-
llm_inference: 5,
|
|
21
|
-
raw_transcript: 6,
|
|
22
|
-
};
|
|
3
|
+
const {
|
|
4
|
+
authoritySortPriority,
|
|
5
|
+
formatRuntimeMemoryLine,
|
|
6
|
+
memoryTypeBootstrapPriority,
|
|
7
|
+
memoryTypeRuntimeContract,
|
|
8
|
+
} = require('./memory-type-policy');
|
|
23
9
|
|
|
24
10
|
function recordId(record) {
|
|
25
11
|
return String(record.memoryId || record.memory_id || record.id || record.canonicalKey || record.canonical_key);
|
|
@@ -42,6 +28,11 @@ function parseTime(value) {
|
|
|
42
28
|
return Number.isFinite(t) ? t : null;
|
|
43
29
|
}
|
|
44
30
|
|
|
31
|
+
function numericValue(value) {
|
|
32
|
+
const parsed = Number(value);
|
|
33
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
45
36
|
function isWithinTime(record, asOf) {
|
|
46
37
|
if (!asOf) return true;
|
|
47
38
|
const at = Date.parse(asOf);
|
|
@@ -97,20 +88,28 @@ function resolveApplicableRecords(records = [], opts = {}) {
|
|
|
97
88
|
}
|
|
98
89
|
|
|
99
90
|
function sortForBootstrap(a, b, opts = {}) {
|
|
91
|
+
const aRuntimeContract = memoryTypeRuntimeContract(a.memoryType || a.memory_type);
|
|
92
|
+
const bRuntimeContract = memoryTypeRuntimeContract(b.memoryType || b.memory_type);
|
|
93
|
+
if (aRuntimeContract !== bRuntimeContract) return aRuntimeContract ? -1 : 1;
|
|
94
|
+
|
|
100
95
|
const activeScopePath = opts.activeScopePath || (opts.activeScopeKey ? [opts.activeScopeKey] : ['global']);
|
|
101
96
|
const position = new Map(activeScopePath.map((key, idx) => [key, idx]));
|
|
102
97
|
const aScope = position.get(scopeKey(a)) ?? -1;
|
|
103
98
|
const bScope = position.get(scopeKey(b)) ?? -1;
|
|
104
99
|
if (bScope !== aScope) return bScope - aScope;
|
|
105
100
|
|
|
106
|
-
const aType =
|
|
107
|
-
const bType =
|
|
101
|
+
const aType = memoryTypeBootstrapPriority(a.memoryType || a.memory_type);
|
|
102
|
+
const bType = memoryTypeBootstrapPriority(b.memoryType || b.memory_type);
|
|
108
103
|
if (aType !== bType) return aType - bType;
|
|
109
104
|
|
|
110
|
-
const aAuth =
|
|
111
|
-
const bAuth =
|
|
105
|
+
const aAuth = authoritySortPriority(a.authority);
|
|
106
|
+
const bAuth = authoritySortPriority(b.authority);
|
|
112
107
|
if (aAuth !== bAuth) return aAuth - bAuth;
|
|
113
108
|
|
|
109
|
+
const aFeedback = numericValue(a.feedbackScore ?? a.feedback_score);
|
|
110
|
+
const bFeedback = numericValue(b.feedbackScore ?? b.feedback_score);
|
|
111
|
+
if (aFeedback !== bFeedback) return bFeedback - aFeedback;
|
|
112
|
+
|
|
114
113
|
const aAccepted = Date.parse(a.acceptedAt || a.accepted_at || '') || 0;
|
|
115
114
|
const bAccepted = Date.parse(b.acceptedAt || b.accepted_at || '') || 0;
|
|
116
115
|
if (aAccepted !== bAccepted) return bAccepted - aAccepted;
|
|
@@ -119,9 +118,7 @@ function sortForBootstrap(a, b, opts = {}) {
|
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
function lineFor(record) {
|
|
122
|
-
|
|
123
|
-
const text = record.summary || record.title || '';
|
|
124
|
-
return `- ${type}: ${String(text).trim()}`;
|
|
121
|
+
return formatRuntimeMemoryLine(record);
|
|
125
122
|
}
|
|
126
123
|
|
|
127
124
|
function buildText(records, meta) {
|
|
@@ -184,6 +181,7 @@ function createMemoryBootstrap({ records }) {
|
|
|
184
181
|
scopeId: opts.scopeId,
|
|
185
182
|
scopeKeys: opts.activeScopePath || (opts.activeScopeKey ? [opts.activeScopeKey] : undefined),
|
|
186
183
|
visibleInBootstrap: true,
|
|
184
|
+
includeFeedbackScore: true,
|
|
187
185
|
asOf: opts.asOf,
|
|
188
186
|
limit: Math.max(50, Math.min(200, requestedLimit * 4)),
|
|
189
187
|
});
|