vesper-memory 0.5.2 → 0.5.4
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/README.md +49 -14
- package/config/claude-rules/memory-discipline.md +39 -0
- package/config/claude-rules/vesper.md +218 -0
- package/dist/cli.js +59 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -2
- package/dist/cli 2.js +0 -583
- package/dist/cli.d 2.ts +0 -8
- package/dist/cli.d.ts 2.map +0 -1
- package/dist/cli.js 2.map +0 -1
- package/dist/config 2/rate-limits.d.ts +0 -76
- package/dist/config 2/rate-limits.d.ts.map +0 -1
- package/dist/config 2/rate-limits.js +0 -161
- package/dist/config 2/rate-limits.js.map +0 -1
- package/dist/consolidation 2/pipeline.d.ts +0 -52
- package/dist/consolidation 2/pipeline.d.ts.map +0 -1
- package/dist/consolidation 2/pipeline.js +0 -193
- package/dist/consolidation 2/pipeline.js.map +0 -1
- package/dist/embeddings 2/client.d.ts +0 -94
- package/dist/embeddings 2/client.d.ts.map +0 -1
- package/dist/embeddings 2/client.js +0 -144
- package/dist/embeddings 2/client.js.map +0 -1
- package/dist/memory-layers 2/semantic-memory.d.ts +0 -33
- package/dist/memory-layers 2/semantic-memory.d.ts.map +0 -1
- package/dist/memory-layers 2/semantic-memory.js +0 -114
- package/dist/memory-layers 2/semantic-memory.js.map +0 -1
- package/dist/memory-layers 2/skill-library.d.ts +0 -25
- package/dist/memory-layers 2/skill-library.d.ts.map +0 -1
- package/dist/memory-layers 2/skill-library.js +0 -54
- package/dist/memory-layers 2/skill-library.js.map +0 -1
- package/dist/memory-layers 2/working-memory.d.ts +0 -57
- package/dist/memory-layers 2/working-memory.d.ts.map +0 -1
- package/dist/memory-layers 2/working-memory.js +0 -153
- package/dist/memory-layers 2/working-memory.js.map +0 -1
- package/dist/middleware 2/auth.d.ts +0 -287
- package/dist/middleware 2/auth.d.ts.map +0 -1
- package/dist/middleware 2/auth.js +0 -610
- package/dist/middleware 2/auth.js.map +0 -1
- package/dist/monitoring 2/health.d.ts +0 -241
- package/dist/monitoring 2/health.d.ts.map +0 -1
- package/dist/monitoring 2/health.js +0 -649
- package/dist/monitoring 2/health.js.map +0 -1
- package/dist/monitoring 2/metrics.d.ts +0 -153
- package/dist/monitoring 2/metrics.d.ts.map +0 -1
- package/dist/monitoring 2/metrics.js +0 -349
- package/dist/monitoring 2/metrics.js.map +0 -1
- package/dist/retrieval 2/hybrid-search.d.ts +0 -186
- package/dist/retrieval 2/hybrid-search.d.ts.map +0 -1
- package/dist/retrieval 2/hybrid-search.js +0 -327
- package/dist/retrieval 2/hybrid-search.js.map +0 -1
- package/dist/router 2/smart-router.d.ts +0 -111
- package/dist/router 2/smart-router.d.ts.map +0 -1
- package/dist/router 2/smart-router.js +0 -383
- package/dist/router 2/smart-router.js.map +0 -1
- package/dist/security 2/rate-limit-middleware.d.ts +0 -119
- package/dist/security 2/rate-limit-middleware.d.ts.map +0 -1
- package/dist/security 2/rate-limit-middleware.js +0 -193
- package/dist/security 2/rate-limit-middleware.js.map +0 -1
- package/dist/server 2.js +0 -861
- package/dist/server-wrapper 2.js +0 -170
- package/dist/server-wrapper.d 2.ts +0 -12
- package/dist/server-wrapper.d.ts 2.map +0 -1
- package/dist/server-wrapper.js 2.map +0 -1
- package/dist/server.d 2.ts +0 -14
- package/dist/server.d.ts 2.map +0 -1
- package/dist/server.js 2.map +0 -1
- package/dist/synthesis 2/conflict-detector.d.ts +0 -43
- package/dist/synthesis 2/conflict-detector.d.ts.map +0 -1
- package/dist/synthesis 2/conflict-detector.js +0 -125
- package/dist/synthesis 2/conflict-detector.js.map +0 -1
- package/dist/utils 2/monitoring.d.ts +0 -25
- package/dist/utils 2/monitoring.d.ts.map +0 -1
- package/dist/utils 2/monitoring.js +0 -41
- package/dist/utils 2/monitoring.js.map +0 -1
- package/dist/utils 2/rate-limiter.d.ts +0 -97
- package/dist/utils 2/rate-limiter.d.ts.map +0 -1
- package/dist/utils 2/rate-limiter.js +0 -166
- package/dist/utils 2/rate-limiter.js.map +0 -1
- package/dist/utils 2/validation.d.ts +0 -139
- package/dist/utils 2/validation.d.ts.map +0 -1
- package/dist/utils 2/validation.js +0 -195
- package/dist/utils 2/validation.js.map +0 -1
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BGE-large Embedding Client
|
|
3
|
-
*
|
|
4
|
-
* TypeScript client for the BGE-large embedding service.
|
|
5
|
-
* Provides methods for generating 1024-dimensional dense embeddings.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* BGE-large Embedding Client
|
|
9
|
-
*
|
|
10
|
-
* Communicates with the Python embedding service to generate
|
|
11
|
-
* 1024-dimensional dense embeddings using BGE-large-en-v1.5.
|
|
12
|
-
*/
|
|
13
|
-
export class EmbeddingClient {
|
|
14
|
-
serviceUrl;
|
|
15
|
-
timeout;
|
|
16
|
-
maxRetries;
|
|
17
|
-
constructor(config = {}) {
|
|
18
|
-
this.serviceUrl = config.serviceUrl || process.env.EMBEDDING_SERVICE_URL || 'http://localhost:8000';
|
|
19
|
-
this.timeout = config.timeout || 30000;
|
|
20
|
-
this.maxRetries = config.maxRetries || 3;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Check if the embedding service is healthy
|
|
24
|
-
*
|
|
25
|
-
* @returns Health status and model information
|
|
26
|
-
*/
|
|
27
|
-
async health() {
|
|
28
|
-
const response = await this.fetchWithRetry(`${this.serviceUrl}/health`, {
|
|
29
|
-
method: 'GET',
|
|
30
|
-
});
|
|
31
|
-
if (!response.ok) {
|
|
32
|
-
throw new Error(`Health check failed: ${response.status} ${response.statusText}`);
|
|
33
|
-
}
|
|
34
|
-
return (await response.json());
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Generate embedding for a single text
|
|
38
|
-
*
|
|
39
|
-
* @param text - Text to embed
|
|
40
|
-
* @param normalize - Whether to normalize the embedding (default: true)
|
|
41
|
-
* @returns 1024-dimensional embedding vector
|
|
42
|
-
*/
|
|
43
|
-
async embed(text, normalize = true) {
|
|
44
|
-
const response = await this.embedBatch([text], normalize);
|
|
45
|
-
return response.embeddings[0];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Generate embeddings for multiple texts
|
|
49
|
-
*
|
|
50
|
-
* @param texts - Array of texts to embed
|
|
51
|
-
* @param normalize - Whether to normalize embeddings (default: true)
|
|
52
|
-
* @returns Array of 1024-dimensional embedding vectors
|
|
53
|
-
*/
|
|
54
|
-
async embedBatch(texts, normalize = true) {
|
|
55
|
-
if (texts.length === 0) {
|
|
56
|
-
return {
|
|
57
|
-
embeddings: [],
|
|
58
|
-
dimensions: 1024,
|
|
59
|
-
count: 0,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const response = await this.fetchWithRetry(`${this.serviceUrl}/embed`, {
|
|
63
|
-
method: 'POST',
|
|
64
|
-
headers: {
|
|
65
|
-
'Content-Type': 'application/json',
|
|
66
|
-
},
|
|
67
|
-
body: JSON.stringify({
|
|
68
|
-
text: texts,
|
|
69
|
-
normalize,
|
|
70
|
-
}),
|
|
71
|
-
});
|
|
72
|
-
if (!response.ok) {
|
|
73
|
-
const error = await response.text();
|
|
74
|
-
throw new Error(`Embedding generation failed: ${response.status} ${error}`);
|
|
75
|
-
}
|
|
76
|
-
const result = (await response.json());
|
|
77
|
-
// Validate dimensions
|
|
78
|
-
if (result.dimensions !== 1024) {
|
|
79
|
-
throw new Error(`Expected 1024-dimensional embeddings, got ${result.dimensions}`);
|
|
80
|
-
}
|
|
81
|
-
// Validate count
|
|
82
|
-
if (result.count !== texts.length) {
|
|
83
|
-
throw new Error(`Expected ${texts.length} embeddings, got ${result.count}`);
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Generate embeddings with optimized batching
|
|
89
|
-
*
|
|
90
|
-
* Automatically splits large batches to avoid memory issues
|
|
91
|
-
* and timeouts on the embedding service.
|
|
92
|
-
*
|
|
93
|
-
* @param texts - Array of texts to embed
|
|
94
|
-
* @param batchSize - Number of texts per batch (default: 32)
|
|
95
|
-
* @returns Array of 1024-dimensional embedding vectors
|
|
96
|
-
*/
|
|
97
|
-
async embedLargeBatch(texts, batchSize = 32) {
|
|
98
|
-
const allEmbeddings = [];
|
|
99
|
-
for (let i = 0; i < texts.length; i += batchSize) {
|
|
100
|
-
const batch = texts.slice(i, i + batchSize);
|
|
101
|
-
const response = await this.embedBatch(batch);
|
|
102
|
-
allEmbeddings.push(...response.embeddings);
|
|
103
|
-
}
|
|
104
|
-
return allEmbeddings;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Fetch with automatic retry on failure
|
|
108
|
-
*
|
|
109
|
-
* @param url - URL to fetch
|
|
110
|
-
* @param options - Fetch options
|
|
111
|
-
* @returns Response
|
|
112
|
-
*/
|
|
113
|
-
async fetchWithRetry(url, options, retries = 0) {
|
|
114
|
-
try {
|
|
115
|
-
const controller = new AbortController();
|
|
116
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
117
|
-
const response = await fetch(url, {
|
|
118
|
-
...options,
|
|
119
|
-
signal: controller.signal,
|
|
120
|
-
});
|
|
121
|
-
clearTimeout(timeoutId);
|
|
122
|
-
return response;
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
if (retries < this.maxRetries) {
|
|
126
|
-
// Wait before retrying (exponential backoff)
|
|
127
|
-
const delay = Math.pow(2, retries) * 1000;
|
|
128
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
129
|
-
return this.fetchWithRetry(url, options, retries + 1);
|
|
130
|
-
}
|
|
131
|
-
throw new Error(`Embedding service request failed after ${this.maxRetries} retries: ${error instanceof Error ? error.message : String(error)}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Factory function to create an embedding client
|
|
137
|
-
*
|
|
138
|
-
* @param config - Optional configuration
|
|
139
|
-
* @returns Embedding client instance
|
|
140
|
-
*/
|
|
141
|
-
export function createEmbeddingClient(config) {
|
|
142
|
-
return new EmbeddingClient(config);
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/embeddings/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAClB,UAAU,CAAS;IACnB,OAAO,CAAS;IAChB,UAAU,CAAS;IAE3B,YAAY,SAAgC,EAAE;QAC5C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,uBAAuB,CAAC;QACpG,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,UAAU,SAAS,EAAE;YACtE,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,CAAC;QAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmB,CAAC;IACnD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,YAAqB,IAAI;QACjD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,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,KAAK,CAAC,CAAC,CAAC;gBAC3D,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;YACxD,CAAC;YAED,MAAM,IAAI,KAAK,CACb,0CAA0C,IAAI,CAAC,UAAU,aAAa,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC/H,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA8B;IAE9B,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Semantic Memory Layer - v3.0 Implementation
|
|
3
|
-
*
|
|
4
|
-
* SQLite knowledge graph with HippoRAG Personalized PageRank.
|
|
5
|
-
*/
|
|
6
|
-
import Database from 'better-sqlite3';
|
|
7
|
-
export interface Entity {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
type: 'person' | 'project' | 'concept' | 'preference';
|
|
11
|
-
description?: string;
|
|
12
|
-
confidence: number;
|
|
13
|
-
}
|
|
14
|
-
export declare class SemanticMemoryLayer {
|
|
15
|
-
private db;
|
|
16
|
-
constructor(db: Database.Database);
|
|
17
|
-
upsertEntity(entity: Partial<Entity> & {
|
|
18
|
-
name: string;
|
|
19
|
-
type: string;
|
|
20
|
-
}): Entity;
|
|
21
|
-
getEntity(name: string): any | null;
|
|
22
|
-
upsertRelationship(rel: {
|
|
23
|
-
sourceId: string;
|
|
24
|
-
targetId: string;
|
|
25
|
-
relationType: string;
|
|
26
|
-
strength?: number;
|
|
27
|
-
}): void;
|
|
28
|
-
personalizedPageRank(entityId: string, depth?: number): any[];
|
|
29
|
-
applyTemporalDecay(): number;
|
|
30
|
-
getPreferences(domain?: string): any[];
|
|
31
|
-
getByTimeRange(start?: Date, end?: Date): any[];
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=semantic-memory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"semantic-memory.d.ts","sourceRoot":"","sources":["../../src/memory-layers/semantic-memory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,EAAE,CAAoB;gBAElB,EAAE,EAAE,QAAQ,CAAC,QAAQ;IAIjC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAiC9E,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI;IAcnC,kBAAkB,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAuB9G,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,GAAG,EAAE;IAmChE,kBAAkB,IAAI,MAAM;IAgB5B,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE;IAStC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,GAAG,GAAG,EAAE;CAgBhD"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Semantic Memory Layer - v3.0 Implementation
|
|
3
|
-
*
|
|
4
|
-
* SQLite knowledge graph with HippoRAG Personalized PageRank.
|
|
5
|
-
*/
|
|
6
|
-
export class SemanticMemoryLayer {
|
|
7
|
-
db;
|
|
8
|
-
constructor(db) {
|
|
9
|
-
this.db = db;
|
|
10
|
-
}
|
|
11
|
-
upsertEntity(entity) {
|
|
12
|
-
if (!entity.name || entity.name.trim() === '') {
|
|
13
|
-
throw new Error('Entity name cannot be empty');
|
|
14
|
-
}
|
|
15
|
-
const existing = this.db.prepare('SELECT * FROM entities WHERE name = ? AND type = ?').get(entity.name, entity.type);
|
|
16
|
-
if (existing) {
|
|
17
|
-
this.db.prepare('UPDATE entities SET last_accessed = ?, access_count = access_count + 1 WHERE id = ?').run(new Date().toISOString(), existing.id);
|
|
18
|
-
return existing;
|
|
19
|
-
}
|
|
20
|
-
const id = 'entity_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
|
|
21
|
-
const now = new Date().toISOString();
|
|
22
|
-
this.db.prepare(`
|
|
23
|
-
INSERT INTO entities (id, name, type, description, confidence, created_at, last_accessed, access_count)
|
|
24
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
25
|
-
`).run(id, entity.name, entity.type, entity.description || null, entity.confidence || 1.0, now, now, 1);
|
|
26
|
-
return {
|
|
27
|
-
id,
|
|
28
|
-
name: entity.name,
|
|
29
|
-
type: entity.type,
|
|
30
|
-
description: entity.description,
|
|
31
|
-
confidence: entity.confidence || 1.0
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
getEntity(name) {
|
|
35
|
-
const result = this.db.prepare('SELECT * FROM entities WHERE name = ? ORDER BY confidence DESC LIMIT 1').get(name);
|
|
36
|
-
if (result) {
|
|
37
|
-
this.db.prepare('UPDATE entities SET last_accessed = ?, access_count = access_count + 1 WHERE id = ?').run(new Date().toISOString(), result.id);
|
|
38
|
-
}
|
|
39
|
-
return result || null;
|
|
40
|
-
}
|
|
41
|
-
upsertRelationship(rel) {
|
|
42
|
-
const existing = this.db.prepare('SELECT * FROM relationships WHERE source_id = ? AND target_id = ? AND relation_type = ?').get(rel.sourceId, rel.targetId, rel.relationType);
|
|
43
|
-
const now = new Date().toISOString();
|
|
44
|
-
if (existing) {
|
|
45
|
-
const newStrength = Math.min(1.0, existing.strength + 0.2);
|
|
46
|
-
this.db.prepare('UPDATE relationships SET strength = ?, last_reinforced = ? WHERE id = ?').run(newStrength, now, existing.id);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const id = 'rel_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
|
|
50
|
-
this.db.prepare(`
|
|
51
|
-
INSERT INTO relationships (id, source_id, target_id, relation_type, strength, evidence, created_at, last_reinforced)
|
|
52
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
53
|
-
`).run(id, rel.sourceId, rel.targetId, rel.relationType, rel.strength || 0.8, '[]', now, now);
|
|
54
|
-
}
|
|
55
|
-
personalizedPageRank(entityId, depth = 2) {
|
|
56
|
-
const visited = new Set();
|
|
57
|
-
const results = [];
|
|
58
|
-
let currentLayer = [{ entityId, score: 1.0 }];
|
|
59
|
-
for (let d = 0; d < depth && currentLayer.length > 0; d++) {
|
|
60
|
-
const nextLayer = [];
|
|
61
|
-
for (const node of currentLayer) {
|
|
62
|
-
if (visited.has(node.entityId))
|
|
63
|
-
continue;
|
|
64
|
-
visited.add(node.entityId);
|
|
65
|
-
const entity = this.db.prepare('SELECT * FROM entities WHERE id = ?').get(node.entityId);
|
|
66
|
-
if (entity)
|
|
67
|
-
results.push({ ...entity, relevanceScore: node.score });
|
|
68
|
-
const rels = this.db.prepare('SELECT * FROM relationships WHERE source_id = ? OR target_id = ?').all(node.entityId, node.entityId);
|
|
69
|
-
for (const rel of rels) {
|
|
70
|
-
const nextId = rel.source_id === node.entityId ? rel.target_id : rel.source_id;
|
|
71
|
-
const score = node.score * rel.strength * 0.7;
|
|
72
|
-
if (!visited.has(nextId) && score > 0.1) {
|
|
73
|
-
nextLayer.push({ entityId: nextId, score });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
currentLayer = nextLayer;
|
|
78
|
-
}
|
|
79
|
-
return results.sort((a, b) => b.relevanceScore - a.relevanceScore);
|
|
80
|
-
}
|
|
81
|
-
applyTemporalDecay() {
|
|
82
|
-
const relationships = this.db.prepare('SELECT * FROM relationships').all();
|
|
83
|
-
let updated = 0;
|
|
84
|
-
for (const rel of relationships) {
|
|
85
|
-
const daysSince = (Date.now() - new Date(rel.last_reinforced).getTime()) / (1000 * 60 * 60 * 24);
|
|
86
|
-
const newStrength = rel.strength * Math.exp(-daysSince / 30);
|
|
87
|
-
// Just update strength, pruning happens later in consolidation
|
|
88
|
-
this.db.prepare('UPDATE relationships SET strength = ? WHERE id = ?').run(newStrength, rel.id);
|
|
89
|
-
updated++;
|
|
90
|
-
}
|
|
91
|
-
return updated;
|
|
92
|
-
}
|
|
93
|
-
getPreferences(domain) {
|
|
94
|
-
if (domain) {
|
|
95
|
-
return this.db.prepare('SELECT * FROM entities WHERE type = ? AND (name LIKE ? OR description LIKE ?)').all('preference', `%${domain}%`, `%${domain}%`);
|
|
96
|
-
}
|
|
97
|
-
return this.db.prepare('SELECT * FROM entities WHERE type = ?').all('preference');
|
|
98
|
-
}
|
|
99
|
-
getByTimeRange(start, end) {
|
|
100
|
-
let query = 'SELECT * FROM entities WHERE 1=1';
|
|
101
|
-
const params = [];
|
|
102
|
-
if (start) {
|
|
103
|
-
query += ' AND created_at >= ?';
|
|
104
|
-
params.push(start.toISOString());
|
|
105
|
-
}
|
|
106
|
-
if (end) {
|
|
107
|
-
query += ' AND created_at <= ?';
|
|
108
|
-
params.push(end.toISOString());
|
|
109
|
-
}
|
|
110
|
-
query += ' ORDER BY created_at DESC LIMIT 20';
|
|
111
|
-
return this.db.prepare(query).all(...params);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=semantic-memory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"semantic-memory.js","sourceRoot":"","sources":["../../src/memory-layers/semantic-memory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,MAAM,OAAO,mBAAmB;IACtB,EAAE,CAAoB;IAE9B,YAAY,EAAqB;QAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,YAAY,CAAC,MAAwD;QACnE,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAC9B,oDAAoD,CACrD,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAQ,CAAC;QAEvC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,EAAE,CAAC,OAAO,CACb,qFAAqF,CACtF,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC7C,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAClF,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAErC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;KAGf,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,C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
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill Library - v3.0 Voyager-Style Implementation
|
|
3
|
-
*
|
|
4
|
-
* Procedural memory: reusable patterns learned from conversations.
|
|
5
|
-
*/
|
|
6
|
-
import Database from 'better-sqlite3';
|
|
7
|
-
export interface Skill {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
category: string;
|
|
12
|
-
triggers: string[];
|
|
13
|
-
successCount: number;
|
|
14
|
-
failureCount: number;
|
|
15
|
-
avgSatisfaction: number;
|
|
16
|
-
}
|
|
17
|
-
export declare class SkillLibrary {
|
|
18
|
-
private db;
|
|
19
|
-
constructor(db: Database.Database);
|
|
20
|
-
addSkill(skill: Omit<Skill, 'id' | 'successCount' | 'failureCount' | 'avgSatisfaction'>): string;
|
|
21
|
-
search(query: string, limit?: number): Skill[];
|
|
22
|
-
recordSuccess(skillId: string, satisfaction: number): void;
|
|
23
|
-
recordFailure(skillId: string): void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=skill-library.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill-library.d.ts","sourceRoot":"","sources":["../../src/memory-layers/skill-library.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAoB;gBAElB,EAAE,EAAE,QAAQ,CAAC,QAAQ;IAIjC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,cAAc,GAAG,cAAc,GAAG,iBAAiB,CAAC,GAAG,MAAM;IAiBhG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,KAAK,EAAE;IAkCjD,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAY1D,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAGrC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill Library - v3.0 Voyager-Style Implementation
|
|
3
|
-
*
|
|
4
|
-
* Procedural memory: reusable patterns learned from conversations.
|
|
5
|
-
*/
|
|
6
|
-
export class SkillLibrary {
|
|
7
|
-
db;
|
|
8
|
-
constructor(db) {
|
|
9
|
-
this.db = db;
|
|
10
|
-
}
|
|
11
|
-
addSkill(skill) {
|
|
12
|
-
const id = 'skill_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
|
|
13
|
-
this.db.prepare(`
|
|
14
|
-
INSERT INTO skills (id, name, description, category, triggers, success_count, failure_count, avg_user_satisfaction)
|
|
15
|
-
VALUES (?, ?, ?, ?, ?, 0, 0, 0.5)
|
|
16
|
-
`).run(id, skill.name, skill.description, skill.category, JSON.stringify(skill.triggers));
|
|
17
|
-
return id;
|
|
18
|
-
}
|
|
19
|
-
search(query, limit = 5) {
|
|
20
|
-
const queryLower = query.toLowerCase();
|
|
21
|
-
const skills = this.db.prepare('SELECT * FROM skills ORDER BY avg_user_satisfaction DESC, success_count DESC').all();
|
|
22
|
-
const scored = skills
|
|
23
|
-
.map(skill => {
|
|
24
|
-
const triggers = JSON.parse(skill.triggers || '[]');
|
|
25
|
-
const matchScore = triggers.some((t) => queryLower.includes(t.toLowerCase()) || t.toLowerCase().includes(queryLower)) ? 1 : 0;
|
|
26
|
-
const nameMatch = skill.name.toLowerCase().includes(queryLower) ? 0.5 : 0;
|
|
27
|
-
return {
|
|
28
|
-
id: skill.id,
|
|
29
|
-
name: skill.name,
|
|
30
|
-
description: skill.description,
|
|
31
|
-
category: skill.category,
|
|
32
|
-
triggers,
|
|
33
|
-
successCount: skill.success_count,
|
|
34
|
-
failureCount: skill.failure_count,
|
|
35
|
-
avgSatisfaction: skill.avg_user_satisfaction,
|
|
36
|
-
score: matchScore + nameMatch
|
|
37
|
-
};
|
|
38
|
-
})
|
|
39
|
-
.filter(s => s.score > 0)
|
|
40
|
-
.sort((a, b) => b.score - a.score);
|
|
41
|
-
return scored.slice(0, limit);
|
|
42
|
-
}
|
|
43
|
-
recordSuccess(skillId, satisfaction) {
|
|
44
|
-
const skill = this.db.prepare('SELECT * FROM skills WHERE id = ?').get(skillId);
|
|
45
|
-
if (skill) {
|
|
46
|
-
const newAvg = (skill.avg_user_satisfaction * skill.success_count + satisfaction) / (skill.success_count + 1);
|
|
47
|
-
this.db.prepare('UPDATE skills SET success_count = success_count + 1, avg_user_satisfaction = ? WHERE id = ?').run(newAvg, skillId);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
recordFailure(skillId) {
|
|
51
|
-
this.db.prepare('UPDATE skills SET failure_count = failure_count + 1 WHERE id = ?').run(skillId);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=skill-library.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill-library.js","sourceRoot":"","sources":["../../src/memory-layers/skill-library.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,MAAM,OAAO,YAAY;IACf,EAAE,CAAoB;IAE9B,YAAY,EAAqB;QAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,QAAQ,CAAC,KAA8E;QACrF,MAAM,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,E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C,QAAQ;gBACxB,QAAQ;gBACR,YAAY,EAAE,KAAK,CAAC,aAAa;gBACjC,YAAY,EAAE,KAAK,CAAC,aAAa;gBACjC,eAAe,EAAE,KAAK,CAAC,qBAAqB;gBAC5C,KAAK,EAAE,UAAU,GAAG,SAAS;aAC9B,CAAC;QACJ,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;aACxB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QAErC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,aAAa,CAAC,OAAe,EAAE,YAAoB;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAQ,CAAC;QAEvF,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,qBAAqB,GAAG,KAAK,CAAC,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;YAE9G,IAAI,CAAC,EAAE,CAAC,OAAO,CACb,6FAA6F,CAC9F,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,aAAa,CAAC,OAAe;QAC3B,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,kEAAkE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnG,CAAC;CACF"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Working Memory Layer - v3.0 Implementation
|
|
3
|
-
*
|
|
4
|
-
* Redis-based cache for last 5 conversations with 7-day TTL.
|
|
5
|
-
* Simple but effective - instant recall for recent context.
|
|
6
|
-
*/
|
|
7
|
-
import { Redis } from 'ioredis';
|
|
8
|
-
export interface WorkingMemory {
|
|
9
|
-
conversationId: string;
|
|
10
|
-
timestamp: Date;
|
|
11
|
-
fullText: string;
|
|
12
|
-
embedding?: number[];
|
|
13
|
-
keyEntities: string[];
|
|
14
|
-
topics: string[];
|
|
15
|
-
userIntent: string;
|
|
16
|
-
}
|
|
17
|
-
export declare class WorkingMemoryLayer {
|
|
18
|
-
private redis;
|
|
19
|
-
private readonly MAX_CONVERSATIONS;
|
|
20
|
-
private readonly TTL_DAYS;
|
|
21
|
-
constructor(redis: Redis, maxConversations?: number);
|
|
22
|
-
store(memory: WorkingMemory): Promise<void>;
|
|
23
|
-
search(query: string, limit?: number): Promise<Array<{
|
|
24
|
-
memory: WorkingMemory;
|
|
25
|
-
similarity: number;
|
|
26
|
-
}>>;
|
|
27
|
-
getRecent(limit?: number): Promise<WorkingMemory[]>;
|
|
28
|
-
getAll(limit?: number): Promise<WorkingMemory[]>;
|
|
29
|
-
get(conversationId: string): Promise<WorkingMemory | null>;
|
|
30
|
-
delete(conversationId: string): Promise<void>;
|
|
31
|
-
searchByEntities(entities: string[], limit?: number): Promise<Array<{
|
|
32
|
-
memory: WorkingMemory;
|
|
33
|
-
similarity: number;
|
|
34
|
-
matchedEntities: string[];
|
|
35
|
-
}>>;
|
|
36
|
-
searchByTopics(topics: string[], limit?: number): Promise<Array<{
|
|
37
|
-
memory: WorkingMemory;
|
|
38
|
-
similarity: number;
|
|
39
|
-
matchedTopics: string[];
|
|
40
|
-
}>>;
|
|
41
|
-
getStats(): Promise<{
|
|
42
|
-
totalConversations: number;
|
|
43
|
-
oldestConversation: Date | null;
|
|
44
|
-
newestConversation: Date | null;
|
|
45
|
-
totalTextSize: number;
|
|
46
|
-
}>;
|
|
47
|
-
/**
|
|
48
|
-
* Clear all working memory entries
|
|
49
|
-
*
|
|
50
|
-
* Uses SCAN instead of KEYS to avoid blocking Redis server.
|
|
51
|
-
* Deletes keys in batches to prevent memory exhaustion.
|
|
52
|
-
*
|
|
53
|
-
* Security: Prevents DoS attacks on Redis
|
|
54
|
-
*/
|
|
55
|
-
clear(): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=working-memory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"working-memory.d.ts","sourceRoot":"","sources":["../../src/memory-layers/working-memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAK;gBAElB,KAAK,EAAE,KAAK,EAAE,gBAAgB,GAAE,MAAU;IAKhD,KAAK,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB3C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAwBvG,SAAS,CAAC,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAYtD,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAIhD,GAAG,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAK1D,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7C,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAsBjJ,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAsB3I,QAAQ,IAAI,OAAO,CAAC;QACxB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,kBAAkB,EAAE,IAAI,GAAG,IAAI,CAAC;QAChC,kBAAkB,EAAE,IAAI,GAAG,IAAI,CAAC;QAChC,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IA6BF;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAwB7B"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Working Memory Layer - v3.0 Implementation
|
|
3
|
-
*
|
|
4
|
-
* Redis-based cache for last 5 conversations with 7-day TTL.
|
|
5
|
-
* Simple but effective - instant recall for recent context.
|
|
6
|
-
*/
|
|
7
|
-
export class WorkingMemoryLayer {
|
|
8
|
-
redis;
|
|
9
|
-
MAX_CONVERSATIONS;
|
|
10
|
-
TTL_DAYS = 7;
|
|
11
|
-
constructor(redis, maxConversations = 5) {
|
|
12
|
-
this.redis = redis;
|
|
13
|
-
this.MAX_CONVERSATIONS = maxConversations;
|
|
14
|
-
}
|
|
15
|
-
async store(memory) {
|
|
16
|
-
const key = `working:${memory.conversationId}`;
|
|
17
|
-
const ttl = this.TTL_DAYS * 24 * 60 * 60;
|
|
18
|
-
await this.redis.setex(key, ttl, JSON.stringify(memory));
|
|
19
|
-
await this.redis.lpush('working:recent', memory.conversationId);
|
|
20
|
-
// Get IDs that will be evicted (beyond MAX_CONVERSATIONS)
|
|
21
|
-
const allIds = await this.redis.lrange('working:recent', 0, -1);
|
|
22
|
-
const toEvict = allIds.slice(this.MAX_CONVERSATIONS);
|
|
23
|
-
await this.redis.ltrim('working:recent', 0, this.MAX_CONVERSATIONS - 1);
|
|
24
|
-
// Delete evicted conversation data
|
|
25
|
-
for (const id of toEvict) {
|
|
26
|
-
await this.redis.del(`working:${id}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async search(query, limit = 3) {
|
|
30
|
-
const recentIds = await this.redis.lrange('working:recent', 0, this.MAX_CONVERSATIONS - 1);
|
|
31
|
-
const results = [];
|
|
32
|
-
const queryLower = query.toLowerCase();
|
|
33
|
-
const queryWords = queryLower.split(/\s+/);
|
|
34
|
-
for (const id of recentIds) {
|
|
35
|
-
const data = await this.redis.get(`working:${id}`);
|
|
36
|
-
if (!data)
|
|
37
|
-
continue;
|
|
38
|
-
const memory = JSON.parse(data);
|
|
39
|
-
const textLower = memory.fullText.toLowerCase();
|
|
40
|
-
const matchCount = queryWords.filter(word => textLower.includes(word)).length;
|
|
41
|
-
const similarity = matchCount / queryWords.length;
|
|
42
|
-
if (similarity > 0.3) {
|
|
43
|
-
results.push({ memory, similarity });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return results.sort((a, b) => b.similarity - a.similarity).slice(0, limit);
|
|
47
|
-
}
|
|
48
|
-
async getRecent(limit = 5) {
|
|
49
|
-
const recentIds = await this.redis.lrange('working:recent', 0, limit - 1);
|
|
50
|
-
const memories = [];
|
|
51
|
-
for (const id of recentIds) {
|
|
52
|
-
const data = await this.redis.get(`working:${id}`);
|
|
53
|
-
if (data)
|
|
54
|
-
memories.push(JSON.parse(data));
|
|
55
|
-
}
|
|
56
|
-
return memories;
|
|
57
|
-
}
|
|
58
|
-
async getAll(limit) {
|
|
59
|
-
return this.getRecent(limit || this.MAX_CONVERSATIONS);
|
|
60
|
-
}
|
|
61
|
-
async get(conversationId) {
|
|
62
|
-
const data = await this.redis.get(`working:${conversationId}`);
|
|
63
|
-
return data ? JSON.parse(data) : null;
|
|
64
|
-
}
|
|
65
|
-
async delete(conversationId) {
|
|
66
|
-
await this.redis.del(`working:${conversationId}`);
|
|
67
|
-
await this.redis.lrem('working:recent', 1, conversationId);
|
|
68
|
-
}
|
|
69
|
-
async searchByEntities(entities, limit = 3) {
|
|
70
|
-
const recentIds = await this.redis.lrange('working:recent', 0, this.MAX_CONVERSATIONS - 1);
|
|
71
|
-
const results = [];
|
|
72
|
-
for (const id of recentIds) {
|
|
73
|
-
const data = await this.redis.get(`working:${id}`);
|
|
74
|
-
if (!data)
|
|
75
|
-
continue;
|
|
76
|
-
const memory = JSON.parse(data);
|
|
77
|
-
const matchedEntities = entities.filter(entity => memory.keyEntities.some(ke => ke.toLowerCase() === entity.toLowerCase()));
|
|
78
|
-
const similarity = matchedEntities.length / entities.length;
|
|
79
|
-
if (similarity > 0) {
|
|
80
|
-
results.push({ memory, similarity, matchedEntities });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return results.sort((a, b) => b.similarity - a.similarity).slice(0, limit);
|
|
84
|
-
}
|
|
85
|
-
async searchByTopics(topics, limit = 3) {
|
|
86
|
-
const recentIds = await this.redis.lrange('working:recent', 0, this.MAX_CONVERSATIONS - 1);
|
|
87
|
-
const results = [];
|
|
88
|
-
for (const id of recentIds) {
|
|
89
|
-
const data = await this.redis.get(`working:${id}`);
|
|
90
|
-
if (!data)
|
|
91
|
-
continue;
|
|
92
|
-
const memory = JSON.parse(data);
|
|
93
|
-
const matchedTopics = topics.filter(topic => memory.topics.some(t => t.toLowerCase() === topic.toLowerCase()));
|
|
94
|
-
const similarity = matchedTopics.length / topics.length;
|
|
95
|
-
if (similarity > 0) {
|
|
96
|
-
results.push({ memory, similarity, matchedTopics });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return results.sort((a, b) => b.similarity - a.similarity).slice(0, limit);
|
|
100
|
-
}
|
|
101
|
-
async getStats() {
|
|
102
|
-
const recentIds = await this.redis.lrange('working:recent', 0, this.MAX_CONVERSATIONS - 1);
|
|
103
|
-
const memories = [];
|
|
104
|
-
for (const id of recentIds) {
|
|
105
|
-
const data = await this.redis.get(`working:${id}`);
|
|
106
|
-
if (data)
|
|
107
|
-
memories.push(JSON.parse(data));
|
|
108
|
-
}
|
|
109
|
-
if (memories.length === 0) {
|
|
110
|
-
return {
|
|
111
|
-
totalConversations: 0,
|
|
112
|
-
oldestConversation: null,
|
|
113
|
-
newestConversation: null,
|
|
114
|
-
totalTextSize: 0
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
const timestamps = memories.map(m => new Date(m.timestamp));
|
|
118
|
-
const totalTextSize = memories.reduce((sum, m) => sum + m.fullText.length, 0);
|
|
119
|
-
return {
|
|
120
|
-
totalConversations: memories.length,
|
|
121
|
-
oldestConversation: new Date(Math.min(...timestamps.map(d => d.getTime()))),
|
|
122
|
-
newestConversation: new Date(Math.max(...timestamps.map(d => d.getTime()))),
|
|
123
|
-
totalTextSize
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Clear all working memory entries
|
|
128
|
-
*
|
|
129
|
-
* Uses SCAN instead of KEYS to avoid blocking Redis server.
|
|
130
|
-
* Deletes keys in batches to prevent memory exhaustion.
|
|
131
|
-
*
|
|
132
|
-
* Security: Prevents DoS attacks on Redis
|
|
133
|
-
*/
|
|
134
|
-
async clear() {
|
|
135
|
-
let cursor = '0';
|
|
136
|
-
const keysToDelete = [];
|
|
137
|
-
// Use SCAN to iterate through keys without blocking
|
|
138
|
-
do {
|
|
139
|
-
const [nextCursor, keys] = await this.redis.scan(cursor, 'MATCH', 'working:*', 'COUNT', 100);
|
|
140
|
-
cursor = nextCursor;
|
|
141
|
-
keysToDelete.push(...keys);
|
|
142
|
-
} while (cursor !== '0');
|
|
143
|
-
// Delete in batches to avoid memory issues
|
|
144
|
-
const BATCH_SIZE = 100;
|
|
145
|
-
for (let i = 0; i < keysToDelete.length; i += BATCH_SIZE) {
|
|
146
|
-
const batch = keysToDelete.slice(i, i + BATCH_SIZE);
|
|
147
|
-
if (batch.length > 0) {
|
|
148
|
-
await this.redis.del(...batch);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=working-memory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"working-memory.js","sourceRoot":"","sources":["../../src/memory-layers/working-memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,MAAM,OAAO,kBAAkB;IACrB,KAAK,CAAQ;IACJ,iBAAiB,CAAS;IAC1B,QAAQ,GAAG,CAAC,CAAC;IAE9B,YAAY,KAAY,EAAE,mBAA2B,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,MAAqB;QAC/B,MAAM,GAAG,GAAG,WAAW,MAAM,CAAC,cAAc,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QAEzC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACzD,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;QAEhE,0DAA0D;QAC1D,MAAM,MAAM,G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