@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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
formatMemoryStatsInterface,
|
|
5
|
+
formatPendingRowsInterface,
|
|
6
|
+
formatPendingWorkInterface,
|
|
7
|
+
} = require('../../core/interface');
|
|
8
|
+
const { MCP_TOOL_MANIFEST } = require('../../core/mcp-manifest');
|
|
9
|
+
|
|
10
|
+
function manifestToolDescription(name, fallback) {
|
|
11
|
+
return MCP_TOOL_MANIFEST.find(tool => tool.name === name)?.description || fallback;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function clampLimit(value, fallback = 20, max = 200) {
|
|
15
|
+
const parsed = parseInt(value ?? fallback, 10);
|
|
16
|
+
if (!Number.isFinite(parsed)) return fallback;
|
|
17
|
+
return Math.max(1, Math.min(max, parsed));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function pendingSessionOpts(params = {}) {
|
|
21
|
+
return {
|
|
22
|
+
limit: clampLimit(params.limit, 20, 200),
|
|
23
|
+
source: params.source || undefined,
|
|
24
|
+
agentId: params.agentId || params.agent_id || undefined,
|
|
25
|
+
status: params.status || undefined,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function normalizeSkipTools(value) {
|
|
30
|
+
if (!value) return new Set();
|
|
31
|
+
if (value instanceof Set) return value;
|
|
32
|
+
if (Array.isArray(value)) return new Set(value);
|
|
33
|
+
return new Set();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function registerOpenClawProductStatusTools(api, aquifer, opts = {}) {
|
|
37
|
+
if (!api || typeof api.registerTool !== 'function') {
|
|
38
|
+
throw new Error('OpenClaw-compatible api.registerTool is required');
|
|
39
|
+
}
|
|
40
|
+
if (!aquifer) {
|
|
41
|
+
throw new Error('aquifer instance is required');
|
|
42
|
+
}
|
|
43
|
+
const skipTools = normalizeSkipTools(opts.skipTools);
|
|
44
|
+
|
|
45
|
+
if (!skipTools.has('memory_stats')) {
|
|
46
|
+
api.registerTool((ctx) => {
|
|
47
|
+
if ((ctx?.sessionKey || '').includes('subagent')) return null;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
name: 'memory_stats',
|
|
51
|
+
description: manifestToolDescription('memory_stats', 'Return Aquifer product status.'),
|
|
52
|
+
parameters: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
diagnostics: { type: 'boolean', description: 'Include raw storage counters and serving diagnostics. Default false.' },
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
async execute(_toolCallId, params = {}) {
|
|
59
|
+
try {
|
|
60
|
+
const stats = await aquifer.getStats();
|
|
61
|
+
const text = formatMemoryStatsInterface(stats, { diagnostics: params.diagnostics === true });
|
|
62
|
+
return { content: [{ type: 'text', text }] };
|
|
63
|
+
} catch (err) {
|
|
64
|
+
return {
|
|
65
|
+
content: [{ type: 'text', text: `memory_stats error: ${err.message}` }],
|
|
66
|
+
isError: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}, { name: 'memory_stats' });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!skipTools.has('memory_pending')) {
|
|
75
|
+
api.registerTool((ctx) => {
|
|
76
|
+
if ((ctx?.sessionKey || '').includes('subagent')) return null;
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
name: 'memory_pending',
|
|
80
|
+
description: manifestToolDescription('memory_pending', 'Return saved-content preparation status.'),
|
|
81
|
+
parameters: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
limit: { type: 'number', description: 'Max results (default 20)' },
|
|
85
|
+
source: { type: 'string', description: 'Filter by source' },
|
|
86
|
+
agentId: { type: 'string', description: 'Filter by agent ID' },
|
|
87
|
+
agent_id: { type: 'string', description: 'Filter by agent ID' },
|
|
88
|
+
status: { type: 'string', enum: ['pending', 'failed'], description: 'Filter by processing status' },
|
|
89
|
+
diagnostics: { type: 'boolean', description: 'Include source/agent/status buckets, guidance, and samples. Default false.' },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
async execute(_toolCallId, params = {}) {
|
|
93
|
+
try {
|
|
94
|
+
const opts = pendingSessionOpts(params);
|
|
95
|
+
const report = typeof aquifer.getPendingWork === 'function'
|
|
96
|
+
? await aquifer.getPendingWork(opts)
|
|
97
|
+
: null;
|
|
98
|
+
const text = report
|
|
99
|
+
? formatPendingWorkInterface(report, {
|
|
100
|
+
diagnostics: params.diagnostics === true,
|
|
101
|
+
includePlan: false,
|
|
102
|
+
})
|
|
103
|
+
: formatPendingRowsInterface(
|
|
104
|
+
typeof aquifer.getPendingSessions === 'function'
|
|
105
|
+
? await aquifer.getPendingSessions(opts)
|
|
106
|
+
: [],
|
|
107
|
+
{ diagnostics: params.diagnostics === true }
|
|
108
|
+
);
|
|
109
|
+
return { content: [{ type: 'text', text }] };
|
|
110
|
+
} catch (err) {
|
|
111
|
+
return {
|
|
112
|
+
content: [{ type: 'text', text: `memory_pending error: ${err.message}` }],
|
|
113
|
+
isError: true,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}, { name: 'memory_pending' });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return { aquifer, productStatusToolsRegistered: true };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = {
|
|
125
|
+
clampLimit,
|
|
126
|
+
manifestToolDescription,
|
|
127
|
+
normalizeSkipTools,
|
|
128
|
+
pendingSessionOpts,
|
|
129
|
+
registerOpenClawProductStatusTools,
|
|
130
|
+
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
4
|
// Shared recall formatter — turns aquifer.recall() rows into human-readable
|
|
5
|
-
// text. The default is English and markdown-ish;
|
|
6
|
-
//
|
|
5
|
+
// text. The default is English and markdown-ish; persona adapters can override
|
|
6
|
+
// individual renderers.
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
|
|
9
9
|
function truncate(s, n) {
|