agents-library 0.1.0
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/base-agent.d.ts +172 -0
- package/dist/base-agent.d.ts.map +1 -0
- package/dist/base-agent.js +255 -0
- package/dist/base-agent.js.map +1 -0
- package/dist/base-bot.d.ts +282 -0
- package/dist/base-bot.d.ts.map +1 -0
- package/dist/base-bot.js +375 -0
- package/dist/base-bot.js.map +1 -0
- package/dist/common/result.d.ts +51 -0
- package/dist/common/result.d.ts.map +1 -0
- package/dist/common/result.js +45 -0
- package/dist/common/result.js.map +1 -0
- package/dist/common/types.d.ts +57 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +42 -0
- package/dist/common/types.js.map +1 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -0
- package/dist/kadi-event-publisher.d.ts +163 -0
- package/dist/kadi-event-publisher.d.ts.map +1 -0
- package/dist/kadi-event-publisher.js +286 -0
- package/dist/kadi-event-publisher.js.map +1 -0
- package/dist/memory/arcadedb-adapter.d.ts +159 -0
- package/dist/memory/arcadedb-adapter.d.ts.map +1 -0
- package/dist/memory/arcadedb-adapter.js +314 -0
- package/dist/memory/arcadedb-adapter.js.map +1 -0
- package/dist/memory/file-storage-adapter.d.ts +122 -0
- package/dist/memory/file-storage-adapter.d.ts.map +1 -0
- package/dist/memory/file-storage-adapter.js +352 -0
- package/dist/memory/file-storage-adapter.js.map +1 -0
- package/dist/memory/memory-service.d.ts +208 -0
- package/dist/memory/memory-service.d.ts.map +1 -0
- package/dist/memory/memory-service.js +410 -0
- package/dist/memory/memory-service.js.map +1 -0
- package/dist/memory/types.d.ts +126 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +41 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/producer-tool-utils.d.ts +474 -0
- package/dist/producer-tool-utils.d.ts.map +1 -0
- package/dist/producer-tool-utils.js +664 -0
- package/dist/producer-tool-utils.js.map +1 -0
- package/dist/providers/anthropic-provider.d.ts +160 -0
- package/dist/providers/anthropic-provider.d.ts.map +1 -0
- package/dist/providers/anthropic-provider.js +527 -0
- package/dist/providers/anthropic-provider.js.map +1 -0
- package/dist/providers/model-manager-provider.d.ts +91 -0
- package/dist/providers/model-manager-provider.d.ts.map +1 -0
- package/dist/providers/model-manager-provider.js +355 -0
- package/dist/providers/model-manager-provider.js.map +1 -0
- package/dist/providers/provider-manager.d.ts +111 -0
- package/dist/providers/provider-manager.d.ts.map +1 -0
- package/dist/providers/provider-manager.js +337 -0
- package/dist/providers/provider-manager.js.map +1 -0
- package/dist/providers/types.d.ts +145 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +23 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/shadow-agent-factory.d.ts +623 -0
- package/dist/shadow-agent-factory.d.ts.map +1 -0
- package/dist/shadow-agent-factory.js +1117 -0
- package/dist/shadow-agent-factory.js.map +1 -0
- package/dist/types/agent-config.d.ts +307 -0
- package/dist/types/agent-config.d.ts.map +1 -0
- package/dist/types/agent-config.js +15 -0
- package/dist/types/agent-config.js.map +1 -0
- package/dist/types/event-schemas.d.ts +358 -0
- package/dist/types/event-schemas.d.ts.map +1 -0
- package/dist/types/event-schemas.js +188 -0
- package/dist/types/event-schemas.js.map +1 -0
- package/dist/types/tool-schemas.d.ts +498 -0
- package/dist/types/tool-schemas.d.ts.map +1 -0
- package/dist/types/tool-schemas.js +457 -0
- package/dist/types/tool-schemas.js.map +1 -0
- package/dist/utils/logger.d.ts +135 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +205 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/timer.d.ts +186 -0
- package/dist/utils/timer.d.ts.map +1 -0
- package/dist/utils/timer.js +211 -0
- package/dist/utils/timer.js.map +1 -0
- package/dist/worker-agent-factory.d.ts +688 -0
- package/dist/worker-agent-factory.d.ts.map +1 -0
- package/dist/worker-agent-factory.js +1517 -0
- package/dist/worker-agent-factory.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Service - Hybrid Storage Orchestration
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates hybrid memory system:
|
|
5
|
+
* - Short-term: Conversation context in JSON files (FileStorageAdapter)
|
|
6
|
+
* - Long-term: Summarized history in ArcadeDB (ArcadeDBAdapter)
|
|
7
|
+
* - Private: User preferences in JSON files
|
|
8
|
+
* - Public: Shared knowledge base in JSON files
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Automatic archival when conversation exceeds 20 messages
|
|
12
|
+
* - LLM-based summarization before archival
|
|
13
|
+
* - Graceful degradation if ArcadeDB unavailable
|
|
14
|
+
*/
|
|
15
|
+
import { ok, err } from '../common/result.js';
|
|
16
|
+
import { FileStorageAdapter } from './file-storage-adapter.js';
|
|
17
|
+
import { ArcadeDBAdapter } from './arcadedb-adapter.js';
|
|
18
|
+
/**
|
|
19
|
+
* Memory Service
|
|
20
|
+
*
|
|
21
|
+
* Manages hybrid memory storage with automatic archival and graceful degradation
|
|
22
|
+
*/
|
|
23
|
+
export class MemoryService {
|
|
24
|
+
providerManager;
|
|
25
|
+
fileStorage;
|
|
26
|
+
dbAdapter = null;
|
|
27
|
+
isDbAvailable = false;
|
|
28
|
+
archiveThreshold = 20;
|
|
29
|
+
/**
|
|
30
|
+
* Create Memory Service
|
|
31
|
+
*
|
|
32
|
+
* @param memoryDataPath - Base directory for file storage
|
|
33
|
+
* @param arcadedbUrl - ArcadeDB connection URL (optional)
|
|
34
|
+
* @param arcadedbPassword - ArcadeDB root password (optional, defaults to 'root')
|
|
35
|
+
* @param providerManager - LLM provider for summarization (optional)
|
|
36
|
+
*/
|
|
37
|
+
constructor(memoryDataPath, arcadedbUrl, arcadedbPassword, providerManager) {
|
|
38
|
+
this.providerManager = providerManager;
|
|
39
|
+
this.fileStorage = new FileStorageAdapter(memoryDataPath);
|
|
40
|
+
if (arcadedbUrl) {
|
|
41
|
+
this.dbAdapter = new ArcadeDBAdapter(arcadedbUrl, 'root', arcadedbPassword || 'root');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Initialize memory service
|
|
46
|
+
*
|
|
47
|
+
* Attempts to connect to ArcadeDB, logs warning if unavailable but continues
|
|
48
|
+
*
|
|
49
|
+
* @returns Result indicating initialization success
|
|
50
|
+
*/
|
|
51
|
+
async initialize() {
|
|
52
|
+
if (this.dbAdapter) {
|
|
53
|
+
const result = await this.dbAdapter.connect();
|
|
54
|
+
if (!result.success) {
|
|
55
|
+
console.warn(`[MemoryService] ArcadeDB unavailable: ${result.error.message}. ` +
|
|
56
|
+
'Continuing with short-term storage only.');
|
|
57
|
+
this.isDbAvailable = false;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.isDbAvailable = true;
|
|
61
|
+
console.log('[MemoryService] ArcadeDB connected successfully');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.log('[MemoryService] ArcadeDB not configured, using file storage only');
|
|
66
|
+
}
|
|
67
|
+
return ok(undefined);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Store message in conversation history
|
|
71
|
+
*
|
|
72
|
+
* Appends message to short-term storage and checks if archival is needed
|
|
73
|
+
*
|
|
74
|
+
* @param userId - User identifier
|
|
75
|
+
* @param channelId - Channel/conversation identifier
|
|
76
|
+
* @param message - Message to store
|
|
77
|
+
* @returns Result indicating success or error
|
|
78
|
+
*/
|
|
79
|
+
async storeMessage(userId, channelId, message) {
|
|
80
|
+
// Validate message
|
|
81
|
+
if (!message.role || !message.content) {
|
|
82
|
+
return err({
|
|
83
|
+
type: 'VALIDATION_ERROR',
|
|
84
|
+
message: 'Message must have role and content',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Append to conversation file
|
|
88
|
+
const conversationPath = `${userId}/${channelId}.json`;
|
|
89
|
+
const result = await this.fileStorage.appendToJSONArray(conversationPath, message);
|
|
90
|
+
if (!result.success) {
|
|
91
|
+
return err({
|
|
92
|
+
type: 'FILE_ERROR',
|
|
93
|
+
message: `Failed to store message: ${result.error.message}`,
|
|
94
|
+
originalError: result.error,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Check if archival is needed
|
|
98
|
+
await this.checkArchiveThreshold(userId, channelId);
|
|
99
|
+
return ok(undefined);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Retrieve conversation context
|
|
103
|
+
*
|
|
104
|
+
* Reads recent messages from short-term storage
|
|
105
|
+
*
|
|
106
|
+
* @param userId - User identifier
|
|
107
|
+
* @param channelId - Channel/conversation identifier
|
|
108
|
+
* @param limit - Maximum number of messages to retrieve (default: 20)
|
|
109
|
+
* @returns Result with conversation messages or error
|
|
110
|
+
*/
|
|
111
|
+
async retrieveContext(userId, channelId, limit = 20) {
|
|
112
|
+
const conversationPath = `${userId}/${channelId}.json`;
|
|
113
|
+
const result = await this.fileStorage.readJSON(conversationPath);
|
|
114
|
+
if (!result.success) {
|
|
115
|
+
return err({
|
|
116
|
+
type: 'FILE_ERROR',
|
|
117
|
+
message: `Failed to retrieve context: ${result.error.message}`,
|
|
118
|
+
originalError: result.error,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// Handle no conversation history
|
|
122
|
+
if (result.data === null) {
|
|
123
|
+
return ok([]);
|
|
124
|
+
}
|
|
125
|
+
// Return last N messages
|
|
126
|
+
const messages = result.data;
|
|
127
|
+
const recentMessages = messages.slice(-limit);
|
|
128
|
+
return ok(recentMessages);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Store user preference
|
|
132
|
+
*
|
|
133
|
+
* Saves preference to user's preference file
|
|
134
|
+
*
|
|
135
|
+
* @param userId - User identifier
|
|
136
|
+
* @param key - Preference key
|
|
137
|
+
* @param value - Preference value
|
|
138
|
+
* @returns Result indicating success or error
|
|
139
|
+
*/
|
|
140
|
+
async storePreference(userId, key, value) {
|
|
141
|
+
const preferencePath = `${userId}/preferences.json`;
|
|
142
|
+
// Read existing preferences
|
|
143
|
+
const readResult = await this.fileStorage.readJSON(preferencePath);
|
|
144
|
+
if (!readResult.success) {
|
|
145
|
+
return err({
|
|
146
|
+
type: 'FILE_ERROR',
|
|
147
|
+
message: `Failed to read preferences: ${readResult.error.message}`,
|
|
148
|
+
originalError: readResult.error,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const preferences = readResult.data || {};
|
|
152
|
+
// Update preference
|
|
153
|
+
preferences[key] = {
|
|
154
|
+
key,
|
|
155
|
+
value,
|
|
156
|
+
updatedAt: Date.now(),
|
|
157
|
+
};
|
|
158
|
+
// Write back
|
|
159
|
+
const writeResult = await this.fileStorage.writeJSON(preferencePath, preferences);
|
|
160
|
+
if (!writeResult.success) {
|
|
161
|
+
return err({
|
|
162
|
+
type: 'FILE_ERROR',
|
|
163
|
+
message: `Failed to write preferences: ${writeResult.error.message}`,
|
|
164
|
+
originalError: writeResult.error,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return ok(undefined);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get user preference
|
|
171
|
+
*
|
|
172
|
+
* Retrieves preference value from user's preference file
|
|
173
|
+
*
|
|
174
|
+
* @param userId - User identifier
|
|
175
|
+
* @param key - Preference key
|
|
176
|
+
* @returns Result with preference value or null if not found
|
|
177
|
+
*/
|
|
178
|
+
async getPreference(userId, key) {
|
|
179
|
+
const preferencePath = `${userId}/preferences.json`;
|
|
180
|
+
const result = await this.fileStorage.readJSON(preferencePath);
|
|
181
|
+
if (!result.success) {
|
|
182
|
+
return err({
|
|
183
|
+
type: 'FILE_ERROR',
|
|
184
|
+
message: `Failed to read preferences: ${result.error.message}`,
|
|
185
|
+
originalError: result.error,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (result.data === null || !(key in result.data)) {
|
|
189
|
+
return ok(null);
|
|
190
|
+
}
|
|
191
|
+
return ok(result.data[key].value);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Store knowledge in public knowledge base
|
|
195
|
+
*
|
|
196
|
+
* Adds entry to shared knowledge base
|
|
197
|
+
*
|
|
198
|
+
* @param entry - Knowledge entry
|
|
199
|
+
* @returns Result indicating success or error
|
|
200
|
+
*/
|
|
201
|
+
async storeKnowledge(entry) {
|
|
202
|
+
const knowledgePath = 'public/knowledge.json';
|
|
203
|
+
// Read existing knowledge base
|
|
204
|
+
const readResult = await this.fileStorage.readJSON(knowledgePath);
|
|
205
|
+
if (!readResult.success) {
|
|
206
|
+
return err({
|
|
207
|
+
type: 'FILE_ERROR',
|
|
208
|
+
message: `Failed to read knowledge base: ${readResult.error.message}`,
|
|
209
|
+
originalError: readResult.error,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
const knowledge = readResult.data || {};
|
|
213
|
+
// Add/update entry
|
|
214
|
+
knowledge[entry.id] = {
|
|
215
|
+
...entry,
|
|
216
|
+
updatedAt: Date.now(),
|
|
217
|
+
};
|
|
218
|
+
// Write back
|
|
219
|
+
const writeResult = await this.fileStorage.writeJSON(knowledgePath, knowledge);
|
|
220
|
+
if (!writeResult.success) {
|
|
221
|
+
return err({
|
|
222
|
+
type: 'FILE_ERROR',
|
|
223
|
+
message: `Failed to write knowledge base: ${writeResult.error.message}`,
|
|
224
|
+
originalError: writeResult.error,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return ok(undefined);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get knowledge from public knowledge base
|
|
231
|
+
*
|
|
232
|
+
* Retrieves entry by ID
|
|
233
|
+
*
|
|
234
|
+
* @param id - Knowledge entry ID
|
|
235
|
+
* @returns Result with knowledge entry or null if not found
|
|
236
|
+
*/
|
|
237
|
+
async getKnowledge(id) {
|
|
238
|
+
const knowledgePath = 'public/knowledge.json';
|
|
239
|
+
const result = await this.fileStorage.readJSON(knowledgePath);
|
|
240
|
+
if (!result.success) {
|
|
241
|
+
return err({
|
|
242
|
+
type: 'FILE_ERROR',
|
|
243
|
+
message: `Failed to read knowledge base: ${result.error.message}`,
|
|
244
|
+
originalError: result.error,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (result.data === null || !(id in result.data)) {
|
|
248
|
+
return ok(null);
|
|
249
|
+
}
|
|
250
|
+
return ok(result.data[id]);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Check if conversation exceeds archival threshold
|
|
254
|
+
*
|
|
255
|
+
* If threshold exceeded, triggers archival to long-term storage
|
|
256
|
+
*
|
|
257
|
+
* @param userId - User identifier
|
|
258
|
+
* @param channelId - Channel identifier
|
|
259
|
+
*/
|
|
260
|
+
async checkArchiveThreshold(userId, channelId) {
|
|
261
|
+
const conversationPath = `${userId}/${channelId}.json`;
|
|
262
|
+
const result = await this.fileStorage.readJSON(conversationPath);
|
|
263
|
+
if (!result.success || result.data === null) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const messages = result.data;
|
|
267
|
+
if (messages.length >= this.archiveThreshold) {
|
|
268
|
+
await this.archiveToLongTerm(userId, channelId, messages);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Archive conversation to long-term storage
|
|
273
|
+
*
|
|
274
|
+
* Summarizes conversation using LLM and stores in ArcadeDB
|
|
275
|
+
* Trims short-term storage to keep only recent messages
|
|
276
|
+
*
|
|
277
|
+
* @param userId - User identifier
|
|
278
|
+
* @param channelId - Channel identifier
|
|
279
|
+
* @param messages - Messages to archive
|
|
280
|
+
*/
|
|
281
|
+
async archiveToLongTerm(userId, channelId, messages) {
|
|
282
|
+
// Skip if database unavailable
|
|
283
|
+
if (!this.isDbAvailable || !this.dbAdapter) {
|
|
284
|
+
console.warn(`[MemoryService] Cannot archive conversation for ${userId}/${channelId}: ` +
|
|
285
|
+
'Database unavailable');
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// Generate summary using LLM
|
|
289
|
+
let summary;
|
|
290
|
+
if (this.providerManager) {
|
|
291
|
+
const summaryResult = await this.summarizeConversation(messages);
|
|
292
|
+
summary = summaryResult.success ? summaryResult.data : 'Summary generation failed';
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
summary = `Conversation with ${messages.length} messages`;
|
|
296
|
+
}
|
|
297
|
+
// Create archived summary
|
|
298
|
+
const archivedSummary = {
|
|
299
|
+
userId,
|
|
300
|
+
channelId,
|
|
301
|
+
summary,
|
|
302
|
+
messageCount: messages.length,
|
|
303
|
+
startTime: messages[0].timestamp,
|
|
304
|
+
endTime: messages[messages.length - 1].timestamp,
|
|
305
|
+
};
|
|
306
|
+
// Store in ArcadeDB as vertex
|
|
307
|
+
const vertexResult = await this.dbAdapter.createVertex('ArchivedConversation', archivedSummary);
|
|
308
|
+
if (!vertexResult.success) {
|
|
309
|
+
console.error(`[MemoryService] Failed to archive conversation: ${vertexResult.error.message}`);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
console.log(`[MemoryService] Archived conversation ${userId}/${channelId} ` +
|
|
313
|
+
`(${messages.length} messages) with @rid ${vertexResult.data}`);
|
|
314
|
+
// Trim short-term storage to keep last 10 messages
|
|
315
|
+
const conversationPath = `${userId}/${channelId}.json`;
|
|
316
|
+
await this.fileStorage.trimJSONArray(conversationPath, 10);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Summarize conversation using LLM
|
|
320
|
+
*
|
|
321
|
+
* @param messages - Messages to summarize
|
|
322
|
+
* @returns Result with summary text
|
|
323
|
+
*/
|
|
324
|
+
async summarizeConversation(messages) {
|
|
325
|
+
if (!this.providerManager) {
|
|
326
|
+
return err({
|
|
327
|
+
type: 'PROVIDER_ERROR',
|
|
328
|
+
message: 'Provider manager not available for summarization',
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
// Build conversation text
|
|
332
|
+
const conversationText = messages
|
|
333
|
+
.map(m => `${m.role}: ${m.content}`)
|
|
334
|
+
.join('\n');
|
|
335
|
+
// Generate summary
|
|
336
|
+
const result = await this.providerManager.chat([
|
|
337
|
+
{
|
|
338
|
+
role: 'user',
|
|
339
|
+
content: `Summarize the following conversation in 2-3 sentences:\n\n${conversationText}`,
|
|
340
|
+
},
|
|
341
|
+
]);
|
|
342
|
+
if (!result.success) {
|
|
343
|
+
return err({
|
|
344
|
+
type: 'PROVIDER_ERROR',
|
|
345
|
+
message: `Summarization failed: ${result.error.message}`,
|
|
346
|
+
originalError: result.error,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return ok(result.data);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Search long-term storage
|
|
353
|
+
*
|
|
354
|
+
* Queries ArcadeDB for archived conversations matching criteria
|
|
355
|
+
*
|
|
356
|
+
* @param userId - User identifier
|
|
357
|
+
* @param searchTerm - Search term for summary content
|
|
358
|
+
* @param limit - Maximum results to return (default: 10)
|
|
359
|
+
* @returns Result with archived summaries or error
|
|
360
|
+
*/
|
|
361
|
+
async searchLongTerm(userId, searchTerm, limit = 10) {
|
|
362
|
+
if (!this.isDbAvailable || !this.dbAdapter) {
|
|
363
|
+
return err({
|
|
364
|
+
type: 'DATABASE_ERROR',
|
|
365
|
+
message: 'Long-term storage unavailable',
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
// Query ArcadeDB using Cypher
|
|
369
|
+
const cypher = `
|
|
370
|
+
MATCH (c:ArchivedConversation)
|
|
371
|
+
WHERE c.userId = $userId AND c.summary CONTAINS $searchTerm
|
|
372
|
+
RETURN c
|
|
373
|
+
ORDER BY c.endTime DESC
|
|
374
|
+
LIMIT $limit
|
|
375
|
+
`;
|
|
376
|
+
const result = await this.dbAdapter.query(cypher, { userId, searchTerm, limit });
|
|
377
|
+
if (!result.success) {
|
|
378
|
+
return err({
|
|
379
|
+
type: 'DATABASE_ERROR',
|
|
380
|
+
message: `Search failed: ${result.error.message}`,
|
|
381
|
+
originalError: result.error,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
// Extract ArchivedSummary from results
|
|
385
|
+
const summaries = result.data.map((row) => row.c);
|
|
386
|
+
return ok(summaries);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Dispose of memory service
|
|
390
|
+
*
|
|
391
|
+
* Disconnects from ArcadeDB and performs cleanup
|
|
392
|
+
*
|
|
393
|
+
* @returns Result indicating success or error
|
|
394
|
+
*/
|
|
395
|
+
async dispose() {
|
|
396
|
+
if (this.dbAdapter && this.isDbAvailable) {
|
|
397
|
+
const result = await this.dbAdapter.disconnect();
|
|
398
|
+
if (!result.success) {
|
|
399
|
+
return err({
|
|
400
|
+
type: 'DATABASE_ERROR',
|
|
401
|
+
message: `Failed to disconnect: ${result.error.message}`,
|
|
402
|
+
originalError: result.error,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
this.isDbAvailable = false;
|
|
406
|
+
}
|
|
407
|
+
return ok(undefined);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
//# sourceMappingURL=memory-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-service.js","sourceRoot":"","sources":["../../src/memory/memory-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAgExD;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAkBL;IAjBX,WAAW,CAAqB;IAChC,SAAS,GAA2B,IAAI,CAAC;IACzC,aAAa,GAAY,KAAK,CAAC;IACtB,gBAAgB,GAAW,EAAE,CAAC;IA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GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;YAEjD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,GAAG,CAAC;oBACT,IAAI,EAAE,gBAAgB;oBACtB,OAAO,EAAE,yBAAyB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;oBACxD,aAAa,EAAE,MAAM,CAAC,KAAK;iBAC5B,CAAC,CAAC;YACL,CAAC;YAED,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC7B,CAAC;QAED,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory System Types
|
|
3
|
+
*
|
|
4
|
+
* Defines data models for the hybrid memory system combining file-based
|
|
5
|
+
* short-term storage (JSON/MD files) with ArcadeDB long-term persistence.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Memory entry types
|
|
9
|
+
*/
|
|
10
|
+
export type MemoryType = 'short-term' | 'long-term' | 'private' | 'public';
|
|
11
|
+
/**
|
|
12
|
+
* Base memory entry structure
|
|
13
|
+
*/
|
|
14
|
+
export interface MemoryEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
channelId?: string;
|
|
18
|
+
type: MemoryType;
|
|
19
|
+
content: string;
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Conversation message (stored in short-term memory)
|
|
25
|
+
*/
|
|
26
|
+
export interface ConversationMessage {
|
|
27
|
+
id: string;
|
|
28
|
+
role: 'user' | 'assistant' | 'system';
|
|
29
|
+
content: string;
|
|
30
|
+
timestamp: Date;
|
|
31
|
+
userId: string;
|
|
32
|
+
channelId: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Conversation summary (stored in long-term memory after archival)
|
|
36
|
+
*/
|
|
37
|
+
export interface ConversationSummary {
|
|
38
|
+
id: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
channelId: string;
|
|
41
|
+
summary: string;
|
|
42
|
+
messageCount: number;
|
|
43
|
+
startTime: Date;
|
|
44
|
+
endTime: Date;
|
|
45
|
+
keyTopics: string[];
|
|
46
|
+
archived: Date;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* User preference (stored in private memory)
|
|
50
|
+
*/
|
|
51
|
+
export interface UserPreference {
|
|
52
|
+
userId: string;
|
|
53
|
+
key: string;
|
|
54
|
+
value: unknown;
|
|
55
|
+
updatedAt: Date;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Public knowledge entry (stored in shared memory)
|
|
59
|
+
*/
|
|
60
|
+
export interface PublicKnowledge {
|
|
61
|
+
key: string;
|
|
62
|
+
value: unknown;
|
|
63
|
+
source?: string;
|
|
64
|
+
confidence?: number;
|
|
65
|
+
createdAt: Date;
|
|
66
|
+
updatedAt: Date;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Memory error types
|
|
70
|
+
*/
|
|
71
|
+
export declare enum MemoryErrorType {
|
|
72
|
+
FILE_NOT_FOUND = "FILE_NOT_FOUND",
|
|
73
|
+
FILE_WRITE_ERROR = "FILE_WRITE_ERROR",
|
|
74
|
+
FILE_READ_ERROR = "FILE_READ_ERROR",
|
|
75
|
+
DATABASE_ERROR = "DATABASE_ERROR",
|
|
76
|
+
SERIALIZATION_ERROR = "SERIALIZATION_ERROR",
|
|
77
|
+
UNKNOWN = "UNKNOWN"
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Memory operation error
|
|
81
|
+
*/
|
|
82
|
+
export interface MemoryError {
|
|
83
|
+
type: MemoryErrorType;
|
|
84
|
+
message: string;
|
|
85
|
+
operation: string;
|
|
86
|
+
originalError?: unknown;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* File error types (for FileStorageAdapter)
|
|
90
|
+
*/
|
|
91
|
+
export declare enum FileErrorType {
|
|
92
|
+
NOT_FOUND = "NOT_FOUND",
|
|
93
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
94
|
+
WRITE_FAILED = "WRITE_FAILED",
|
|
95
|
+
READ_FAILED = "READ_FAILED",
|
|
96
|
+
PARSE_ERROR = "PARSE_ERROR",
|
|
97
|
+
UNKNOWN = "UNKNOWN"
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* File operation error
|
|
101
|
+
*/
|
|
102
|
+
export interface FileError {
|
|
103
|
+
type: FileErrorType;
|
|
104
|
+
message: string;
|
|
105
|
+
filePath: string;
|
|
106
|
+
originalError?: unknown;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Database error types (for ArcadeDBAdapter)
|
|
110
|
+
*/
|
|
111
|
+
export declare enum DatabaseErrorType {
|
|
112
|
+
CONNECTION_FAILED = "CONNECTION_FAILED",
|
|
113
|
+
QUERY_FAILED = "QUERY_FAILED",
|
|
114
|
+
TIMEOUT = "TIMEOUT",
|
|
115
|
+
UNKNOWN = "UNKNOWN"
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Database operation error
|
|
119
|
+
*/
|
|
120
|
+
export interface DatabaseError {
|
|
121
|
+
type: DatabaseErrorType;
|
|
122
|
+
message: string;
|
|
123
|
+
query?: string;
|
|
124
|
+
originalError?: unknown;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,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,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,oBAAY,aAAa;IACvB,SAAS,cAAc;IACvB,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory System Types
|
|
3
|
+
*
|
|
4
|
+
* Defines data models for the hybrid memory system combining file-based
|
|
5
|
+
* short-term storage (JSON/MD files) with ArcadeDB long-term persistence.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Memory error types
|
|
9
|
+
*/
|
|
10
|
+
export var MemoryErrorType;
|
|
11
|
+
(function (MemoryErrorType) {
|
|
12
|
+
MemoryErrorType["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
13
|
+
MemoryErrorType["FILE_WRITE_ERROR"] = "FILE_WRITE_ERROR";
|
|
14
|
+
MemoryErrorType["FILE_READ_ERROR"] = "FILE_READ_ERROR";
|
|
15
|
+
MemoryErrorType["DATABASE_ERROR"] = "DATABASE_ERROR";
|
|
16
|
+
MemoryErrorType["SERIALIZATION_ERROR"] = "SERIALIZATION_ERROR";
|
|
17
|
+
MemoryErrorType["UNKNOWN"] = "UNKNOWN";
|
|
18
|
+
})(MemoryErrorType || (MemoryErrorType = {}));
|
|
19
|
+
/**
|
|
20
|
+
* File error types (for FileStorageAdapter)
|
|
21
|
+
*/
|
|
22
|
+
export var FileErrorType;
|
|
23
|
+
(function (FileErrorType) {
|
|
24
|
+
FileErrorType["NOT_FOUND"] = "NOT_FOUND";
|
|
25
|
+
FileErrorType["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
26
|
+
FileErrorType["WRITE_FAILED"] = "WRITE_FAILED";
|
|
27
|
+
FileErrorType["READ_FAILED"] = "READ_FAILED";
|
|
28
|
+
FileErrorType["PARSE_ERROR"] = "PARSE_ERROR";
|
|
29
|
+
FileErrorType["UNKNOWN"] = "UNKNOWN";
|
|
30
|
+
})(FileErrorType || (FileErrorType = {}));
|
|
31
|
+
/**
|
|
32
|
+
* Database error types (for ArcadeDBAdapter)
|
|
33
|
+
*/
|
|
34
|
+
export var DatabaseErrorType;
|
|
35
|
+
(function (DatabaseErrorType) {
|
|
36
|
+
DatabaseErrorType["CONNECTION_FAILED"] = "CONNECTION_FAILED";
|
|
37
|
+
DatabaseErrorType["QUERY_FAILED"] = "QUERY_FAILED";
|
|
38
|
+
DatabaseErrorType["TIMEOUT"] = "TIMEOUT";
|
|
39
|
+
DatabaseErrorType["UNKNOWN"] = "UNKNOWN";
|
|
40
|
+
})(DatabaseErrorType || (DatabaseErrorType = {}));
|
|
41
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqEH;;GAEG;AACH,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,oDAAiC,CAAA;IACjC,wDAAqC,CAAA;IACrC,sDAAmC,CAAA;IACnC,oDAAiC,CAAA;IACjC,8DAA2C,CAAA;IAC3C,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAYD;;GAEG;AACH,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,wDAAuC,CAAA;IACvC,8CAA6B,CAAA;IAC7B,4CAA2B,CAAA;IAC3B,4CAA2B,CAAA;IAC3B,oCAAmB,CAAA;AACrB,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB;AAYD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,4DAAuC,CAAA;IACvC,kDAA6B,CAAA;IAC7B,wCAAmB,CAAA;IACnB,wCAAmB,CAAA;AACrB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B"}
|