@shadowforge0/aquifer-memory 0.3.0 → 0.3.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/core/aquifer.js +18 -1
- package/package.json +1 -1
package/core/aquifer.js
CHANGED
|
@@ -94,6 +94,14 @@ function createAquifer(config) {
|
|
|
94
94
|
|
|
95
95
|
// Track if migrate was called
|
|
96
96
|
let migrated = false;
|
|
97
|
+
let migratePromise = null;
|
|
98
|
+
|
|
99
|
+
async function ensureMigrated() {
|
|
100
|
+
if (migrated) return;
|
|
101
|
+
if (migratePromise) return migratePromise;
|
|
102
|
+
migratePromise = aquifer.migrate().finally(() => { migratePromise = null; });
|
|
103
|
+
return migratePromise;
|
|
104
|
+
}
|
|
97
105
|
|
|
98
106
|
// --- Helper: embed search on summaries ---
|
|
99
107
|
async function embeddingSearchSummaries(queryVec, opts) {
|
|
@@ -196,6 +204,7 @@ function createAquifer(config) {
|
|
|
196
204
|
async commit(sessionId, messages, opts = {}) {
|
|
197
205
|
if (!sessionId) throw new Error('sessionId is required');
|
|
198
206
|
if (!messages || !Array.isArray(messages)) throw new Error('messages must be an array');
|
|
207
|
+
await ensureMigrated();
|
|
199
208
|
|
|
200
209
|
const agentId = opts.agentId || 'agent';
|
|
201
210
|
const source = opts.source || 'api';
|
|
@@ -240,6 +249,7 @@ function createAquifer(config) {
|
|
|
240
249
|
// --- enrichment ---
|
|
241
250
|
|
|
242
251
|
async enrich(sessionId, opts = {}) {
|
|
252
|
+
await ensureMigrated();
|
|
243
253
|
const agentId = opts.agentId || 'agent';
|
|
244
254
|
const skipSummary = opts.skipSummary || false;
|
|
245
255
|
const skipTurnEmbed = opts.skipTurnEmbed || false;
|
|
@@ -470,6 +480,13 @@ function createAquifer(config) {
|
|
|
470
480
|
entityMode = 'any',
|
|
471
481
|
} = opts;
|
|
472
482
|
|
|
483
|
+
// Validate before touching DB
|
|
484
|
+
if (explicitEntities && explicitEntities.length > 0 && !entitiesEnabled) {
|
|
485
|
+
throw new Error('Entities are not enabled');
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
await ensureMigrated();
|
|
489
|
+
|
|
473
490
|
const fetchLimit = limit * 4;
|
|
474
491
|
|
|
475
492
|
// 1. Embed query
|
|
@@ -482,7 +499,6 @@ function createAquifer(config) {
|
|
|
482
499
|
let entityScoreBySession = new Map();
|
|
483
500
|
|
|
484
501
|
if (explicitEntities && explicitEntities.length > 0) {
|
|
485
|
-
if (!entitiesEnabled) throw new Error('Entities are not enabled');
|
|
486
502
|
|
|
487
503
|
const resolved = await entity.resolveEntities(pool, {
|
|
488
504
|
schema, tenantId, names: explicitEntities, agentId,
|
|
@@ -671,6 +687,7 @@ function createAquifer(config) {
|
|
|
671
687
|
const agentId = opts.agentId || 'agent';
|
|
672
688
|
const verdict = opts.verdict;
|
|
673
689
|
if (!verdict) throw new Error('opts.verdict is required ("helpful" or "unhelpful")');
|
|
690
|
+
await ensureMigrated();
|
|
674
691
|
|
|
675
692
|
const session = await storage.getSession(pool, sessionId, agentId, {}, { schema, tenantId });
|
|
676
693
|
if (!session) throw new Error(`Session not found: ${sessionId} (agentId=${agentId})`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shadowforge0/aquifer-memory",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "PG-native long-term memory for AI agents. Turn-level embedding, hybrid RRF ranking, optional knowledge graph. Includes CLI, MCP server, and OpenClaw plugin.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|