@levalicious/server-memory 0.0.18 → 0.0.19
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/server.js +1 -1
- package/dist/src/kb_load.js +10 -4
- package/dist/tests/memory-server.test.js +9 -6
- package/package.json +1 -1
package/dist/server.js
CHANGED
package/dist/src/kb_load.js
CHANGED
|
@@ -350,6 +350,9 @@ export function loadDocument(text, title, st, topK = 15) {
|
|
|
350
350
|
observations: [idx.phrase],
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
|
+
// Index hub — empty structural node linking Document to index entries
|
|
354
|
+
const indexHubId = `${title}__index`;
|
|
355
|
+
entities.push({ name: indexHubId, entityType: 'DocumentIndex', observations: [] });
|
|
353
356
|
// ─── Assemble relations ─────────────────────────────────────────
|
|
354
357
|
// Document → chain endpoints
|
|
355
358
|
if (chunks.length > 0) {
|
|
@@ -365,12 +368,15 @@ export function loadDocument(text, title, st, topK = 15) {
|
|
|
365
368
|
relations.push({ from: chunks[i].id, to: chunks[i + 1].id, relationType: 'follows' });
|
|
366
369
|
relations.push({ from: chunks[i + 1].id, to: chunks[i].id, relationType: 'preceded_by' });
|
|
367
370
|
}
|
|
368
|
-
// Document → index
|
|
371
|
+
// Document → index hub
|
|
372
|
+
relations.push({ from: title, to: indexHubId, relationType: 'has_index' });
|
|
373
|
+
relations.push({ from: indexHubId, to: title, relationType: 'indexes' });
|
|
374
|
+
// Index hub → index entries
|
|
369
375
|
for (const idx of indexEntities) {
|
|
370
|
-
relations.push({ from:
|
|
371
|
-
relations.push({ from: idx.id, to:
|
|
376
|
+
relations.push({ from: indexHubId, to: idx.id, relationType: 'contains' });
|
|
377
|
+
relations.push({ from: idx.id, to: indexHubId, relationType: 'contained_in' });
|
|
372
378
|
}
|
|
373
|
-
// Index → highlighted chunks
|
|
379
|
+
// Index entries → highlighted chunks
|
|
374
380
|
for (const idx of indexEntities) {
|
|
375
381
|
relations.push({ from: idx.id, to: idx.chunk.id, relationType: 'highlights' });
|
|
376
382
|
relations.push({ from: idx.chunk.id, to: idx.id, relationType: 'highlighted_by' });
|
|
@@ -1068,13 +1068,16 @@ describe('MCP Memory Server E2E Tests', () => {
|
|
|
1068
1068
|
const docResult = await callTool(client, 'open_nodes', { names: ['test-doc'] });
|
|
1069
1069
|
expect(docResult.entities.items).toHaveLength(1);
|
|
1070
1070
|
expect(docResult.entities.items[0].entityType).toBe('Document');
|
|
1071
|
-
// Check index entities
|
|
1071
|
+
// Check index entities — one hub (0 observations) + entries (1 observation each)
|
|
1072
1072
|
const indexEntities = await callTool(client, 'get_entities_by_type', { entityType: 'DocumentIndex' });
|
|
1073
|
-
expect(indexEntities.items.length).toBeGreaterThan(
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1073
|
+
expect(indexEntities.items.length).toBeGreaterThan(1);
|
|
1074
|
+
const hub = indexEntities.items.filter(e => e.observations.length === 0);
|
|
1075
|
+
const entries = indexEntities.items.filter(e => e.observations.length > 0);
|
|
1076
|
+
expect(hub).toHaveLength(1);
|
|
1077
|
+
expect(entries.length).toBeGreaterThan(0);
|
|
1078
|
+
for (const entry of entries) {
|
|
1079
|
+
expect(entry.observations.length).toBe(1);
|
|
1080
|
+
expect(entry.observations[0].length).toBeLessThanOrEqual(140);
|
|
1078
1081
|
}
|
|
1079
1082
|
// Check TextChunk entities exist via type query
|
|
1080
1083
|
const chunks = await callTool(client, 'get_entities_by_type', { entityType: 'TextChunk' });
|