snow-flow 2.6.5 โ 2.6.6
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/queen/queen-memory.d.ts +12 -6
- package/dist/queen/queen-memory.js +264 -187
- package/dist/queen/types.d.ts +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +9 -0
- package/package.json +1 -1
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ServiceNow Queen Memory System
|
|
3
|
-
* Simple
|
|
2
|
+
* ServiceNow Queen Memory System - JSON-based implementation
|
|
3
|
+
* Simple JSON file storage for the hive-mind - no more SQLite permission issues!
|
|
4
4
|
*/
|
|
5
5
|
import { DeploymentPattern, ServiceNowArtifact } from './types';
|
|
6
6
|
export declare class QueenMemorySystem {
|
|
7
|
-
private
|
|
7
|
+
private memoryDir;
|
|
8
8
|
private memory;
|
|
9
|
-
private
|
|
9
|
+
private storage;
|
|
10
|
+
private saveDebounceTimer?;
|
|
11
|
+
private readonly SAVE_DELAY;
|
|
10
12
|
constructor(dbPath?: string);
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
+
private getFilePath;
|
|
14
|
+
private loadStorage;
|
|
15
|
+
private convertStorageToMemory;
|
|
16
|
+
private scheduleSave;
|
|
17
|
+
private saveAll;
|
|
18
|
+
private saveJSON;
|
|
13
19
|
storePattern(pattern: DeploymentPattern): void;
|
|
14
20
|
getBestPattern(taskType: string): DeploymentPattern | null;
|
|
15
21
|
storeArtifact(artifact: ServiceNowArtifact): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* ServiceNow Queen Memory System
|
|
4
|
-
* Simple
|
|
3
|
+
* ServiceNow Queen Memory System - JSON-based implementation
|
|
4
|
+
* Simple JSON file storage for the hive-mind - no more SQLite permission issues!
|
|
5
5
|
*/
|
|
6
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
7
|
if (k2 === undefined) k2 = k;
|
|
@@ -42,104 +42,167 @@ const path = __importStar(require("path"));
|
|
|
42
42
|
const fs = __importStar(require("fs"));
|
|
43
43
|
class QueenMemorySystem {
|
|
44
44
|
constructor(dbPath) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
this.SAVE_DELAY = 1000; // Debounce saves by 1 second
|
|
46
|
+
// Use same directory structure but with JSON files
|
|
47
|
+
this.memoryDir = path.dirname(dbPath || path.join(process.cwd(), '.snow-flow', 'queen', 'memory'));
|
|
48
|
+
// Ensure directory exists
|
|
49
|
+
if (!fs.existsSync(this.memoryDir)) {
|
|
50
|
+
fs.mkdirSync(this.memoryDir, { recursive: true });
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
this.
|
|
51
|
-
|
|
52
|
-
this.memory = this.
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
52
|
+
// Load or initialize storage
|
|
53
|
+
this.storage = this.loadStorage();
|
|
54
|
+
// Convert storage to memory format
|
|
55
|
+
this.memory = this.convertStorageToMemory();
|
|
56
|
+
}
|
|
57
|
+
getFilePath(filename) {
|
|
58
|
+
return path.join(this.memoryDir, filename);
|
|
59
|
+
}
|
|
60
|
+
loadStorage() {
|
|
61
|
+
const files = {
|
|
62
|
+
patterns: this.getFilePath('patterns.json'),
|
|
63
|
+
artifacts: this.getFilePath('artifacts.json'),
|
|
64
|
+
learnings: this.getFilePath('learnings.json'),
|
|
65
|
+
context: this.getFilePath('context.json'),
|
|
66
|
+
taskHistory: this.getFilePath('task-history.json')
|
|
67
|
+
};
|
|
68
|
+
const storage = {
|
|
69
|
+
patterns: [],
|
|
70
|
+
artifacts: {},
|
|
71
|
+
learnings: {},
|
|
72
|
+
context: {},
|
|
73
|
+
taskHistory: []
|
|
74
|
+
};
|
|
75
|
+
// Load patterns
|
|
76
|
+
if (fs.existsSync(files.patterns)) {
|
|
77
|
+
try {
|
|
78
|
+
const data = fs.readFileSync(files.patterns, 'utf-8');
|
|
79
|
+
storage.patterns = JSON.parse(data);
|
|
80
|
+
// Convert date strings back to Date objects
|
|
81
|
+
storage.patterns.forEach(p => {
|
|
82
|
+
p.lastUsed = new Date(p.lastUsed);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.warn('โ ๏ธ Could not load patterns.json:', error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Load artifacts
|
|
90
|
+
if (fs.existsSync(files.artifacts)) {
|
|
91
|
+
try {
|
|
92
|
+
const data = fs.readFileSync(files.artifacts, 'utf-8');
|
|
93
|
+
storage.artifacts = JSON.parse(data);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.warn('โ ๏ธ Could not load artifacts.json:', error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Load learnings
|
|
100
|
+
if (fs.existsSync(files.learnings)) {
|
|
101
|
+
try {
|
|
102
|
+
const data = fs.readFileSync(files.learnings, 'utf-8');
|
|
103
|
+
storage.learnings = JSON.parse(data);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.warn('โ ๏ธ Could not load learnings.json:', error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Load context
|
|
110
|
+
if (fs.existsSync(files.context)) {
|
|
111
|
+
try {
|
|
112
|
+
const data = fs.readFileSync(files.context, 'utf-8');
|
|
113
|
+
storage.context = JSON.parse(data);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.warn('โ ๏ธ Could not load context.json:', error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Load task history
|
|
120
|
+
if (fs.existsSync(files.taskHistory)) {
|
|
121
|
+
try {
|
|
122
|
+
const data = fs.readFileSync(files.taskHistory, 'utf-8');
|
|
123
|
+
storage.taskHistory = JSON.parse(data);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.warn('โ ๏ธ Could not load task-history.json:', error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return storage;
|
|
130
|
+
}
|
|
131
|
+
convertStorageToMemory() {
|
|
111
132
|
const artifacts = new Map();
|
|
112
|
-
this.
|
|
113
|
-
.
|
|
114
|
-
artifacts.set(row.id, {
|
|
115
|
-
type: row.type,
|
|
116
|
-
name: row.name,
|
|
117
|
-
sys_id: row.sys_id,
|
|
118
|
-
config: JSON.parse(row.config),
|
|
119
|
-
dependencies: JSON.parse(row.dependencies)
|
|
120
|
-
});
|
|
133
|
+
Object.entries(this.storage.artifacts).forEach(([key, value]) => {
|
|
134
|
+
artifacts.set(key, value);
|
|
121
135
|
});
|
|
122
136
|
const learnings = new Map();
|
|
123
|
-
this.
|
|
124
|
-
.
|
|
125
|
-
learnings.set(row.key, row.value);
|
|
137
|
+
Object.entries(this.storage.learnings).forEach(([key, value]) => {
|
|
138
|
+
learnings.set(key, typeof value === 'string' ? value : JSON.stringify(value));
|
|
126
139
|
});
|
|
127
140
|
return {
|
|
128
|
-
patterns,
|
|
141
|
+
patterns: this.storage.patterns,
|
|
129
142
|
artifacts,
|
|
130
143
|
agentHistory: new Map(),
|
|
131
144
|
learnings
|
|
132
145
|
};
|
|
133
146
|
}
|
|
147
|
+
scheduleSave() {
|
|
148
|
+
// Debounce saves to avoid excessive file writes
|
|
149
|
+
if (this.saveDebounceTimer) {
|
|
150
|
+
clearTimeout(this.saveDebounceTimer);
|
|
151
|
+
}
|
|
152
|
+
this.saveDebounceTimer = setTimeout(() => {
|
|
153
|
+
this.saveAll();
|
|
154
|
+
}, this.SAVE_DELAY);
|
|
155
|
+
}
|
|
156
|
+
saveAll() {
|
|
157
|
+
// Save patterns
|
|
158
|
+
this.saveJSON('patterns.json', this.storage.patterns);
|
|
159
|
+
// Save artifacts
|
|
160
|
+
this.saveJSON('artifacts.json', this.storage.artifacts);
|
|
161
|
+
// Save learnings
|
|
162
|
+
this.saveJSON('learnings.json', this.storage.learnings);
|
|
163
|
+
// Save context
|
|
164
|
+
this.saveJSON('context.json', this.storage.context);
|
|
165
|
+
// Save task history
|
|
166
|
+
this.saveJSON('task-history.json', this.storage.taskHistory);
|
|
167
|
+
}
|
|
168
|
+
saveJSON(filename, data) {
|
|
169
|
+
const filepath = this.getFilePath(filename);
|
|
170
|
+
try {
|
|
171
|
+
// Write to temp file first for atomicity
|
|
172
|
+
const tempPath = filepath + '.tmp';
|
|
173
|
+
fs.writeFileSync(tempPath, JSON.stringify(data, null, 2));
|
|
174
|
+
// Atomic rename
|
|
175
|
+
fs.renameSync(tempPath, filepath);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
console.error(`โ Failed to save ${filename}:`, error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
134
181
|
// Store successful deployment pattern
|
|
135
182
|
storePattern(pattern) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
183
|
+
// Update or add pattern
|
|
184
|
+
const existingIndex = this.storage.patterns.findIndex(p => p.taskType === pattern.taskType);
|
|
185
|
+
if (existingIndex >= 0) {
|
|
186
|
+
// Update existing pattern
|
|
187
|
+
const existing = this.storage.patterns[existingIndex];
|
|
188
|
+
existing.successRate = pattern.successRate;
|
|
189
|
+
existing.agentSequence = pattern.agentSequence;
|
|
190
|
+
existing.mcpSequence = pattern.mcpSequence;
|
|
191
|
+
existing.avgDuration = pattern.avgDuration;
|
|
192
|
+
existing.lastUsed = pattern.lastUsed;
|
|
193
|
+
existing.useCount = (existing.useCount || 0) + 1;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
// Add new pattern
|
|
197
|
+
this.storage.patterns.push({
|
|
198
|
+
...pattern,
|
|
199
|
+
useCount: 1
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// Update memory
|
|
203
|
+
this.memory.patterns = this.storage.patterns;
|
|
204
|
+
// Schedule save
|
|
205
|
+
this.scheduleSave();
|
|
143
206
|
}
|
|
144
207
|
// Get best pattern for task type
|
|
145
208
|
getBestPattern(taskType) {
|
|
@@ -148,12 +211,11 @@ class QueenMemorySystem {
|
|
|
148
211
|
// Store artifact information
|
|
149
212
|
storeArtifact(artifact) {
|
|
150
213
|
const id = `${artifact.type}_${artifact.name}`;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
154
|
-
`);
|
|
155
|
-
stmt.run(id, artifact.type, artifact.name, artifact.sys_id || null, JSON.stringify(artifact.config), JSON.stringify(artifact.dependencies), new Date().toISOString());
|
|
214
|
+
// Store in both storage and memory
|
|
215
|
+
this.storage.artifacts[id] = artifact;
|
|
156
216
|
this.memory.artifacts.set(id, artifact);
|
|
217
|
+
// Schedule save
|
|
218
|
+
this.scheduleSave();
|
|
157
219
|
}
|
|
158
220
|
// Find similar artifacts
|
|
159
221
|
findSimilarArtifacts(type, namePattern) {
|
|
@@ -167,13 +229,17 @@ class QueenMemorySystem {
|
|
|
167
229
|
}
|
|
168
230
|
// Store learning from task execution
|
|
169
231
|
storeLearning(key, value, confidence = 1.0) {
|
|
170
|
-
const stmt = this.db.prepare(`
|
|
171
|
-
INSERT OR REPLACE INTO learnings (key, value, confidence, updated_at)
|
|
172
|
-
VALUES (?, ?, ?, ?)
|
|
173
|
-
`);
|
|
174
232
|
const valueStr = typeof value === 'string' ? value : JSON.stringify(value);
|
|
175
|
-
|
|
233
|
+
// Store with metadata
|
|
234
|
+
this.storage.learnings[key] = {
|
|
235
|
+
value: valueStr,
|
|
236
|
+
confidence,
|
|
237
|
+
updatedAt: new Date().toISOString()
|
|
238
|
+
};
|
|
239
|
+
// Update memory
|
|
176
240
|
this.memory.learnings.set(key, valueStr);
|
|
241
|
+
// Schedule save
|
|
242
|
+
this.scheduleSave();
|
|
177
243
|
}
|
|
178
244
|
// Get learning
|
|
179
245
|
getLearning(key) {
|
|
@@ -193,74 +259,83 @@ class QueenMemorySystem {
|
|
|
193
259
|
}
|
|
194
260
|
// Record task completion for learning
|
|
195
261
|
recordTaskCompletion(taskId, objective, type, agentsUsed, success, duration) {
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
262
|
+
const entry = {
|
|
263
|
+
id: taskId,
|
|
264
|
+
objective,
|
|
265
|
+
type,
|
|
266
|
+
agentsUsed,
|
|
267
|
+
success,
|
|
268
|
+
duration,
|
|
269
|
+
completedAt: new Date().toISOString()
|
|
270
|
+
};
|
|
271
|
+
// Add to history
|
|
272
|
+
this.storage.taskHistory.push(entry);
|
|
273
|
+
// Keep only last 1000 entries to prevent unbounded growth
|
|
274
|
+
if (this.storage.taskHistory.length > 1000) {
|
|
275
|
+
this.storage.taskHistory = this.storage.taskHistory.slice(-1000);
|
|
276
|
+
}
|
|
277
|
+
// Schedule save
|
|
278
|
+
this.scheduleSave();
|
|
202
279
|
}
|
|
203
280
|
// Get success rate for task type
|
|
204
281
|
getSuccessRate(taskType) {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
COUNT(*) as total
|
|
209
|
-
FROM task_history
|
|
210
|
-
WHERE type = ?
|
|
211
|
-
`).get(taskType);
|
|
212
|
-
if (result && result.total > 0) {
|
|
213
|
-
return result.successes / result.total;
|
|
282
|
+
const relevantTasks = this.storage.taskHistory.filter(t => t.type === taskType);
|
|
283
|
+
if (relevantTasks.length === 0) {
|
|
284
|
+
return 0.5; // Default success rate
|
|
214
285
|
}
|
|
215
|
-
|
|
286
|
+
const successes = relevantTasks.filter(t => t.success).length;
|
|
287
|
+
return successes / relevantTasks.length;
|
|
216
288
|
}
|
|
217
289
|
// Export memory for backup
|
|
218
290
|
exportMemory() {
|
|
219
291
|
return JSON.stringify({
|
|
220
|
-
patterns: this.
|
|
221
|
-
artifacts:
|
|
222
|
-
learnings:
|
|
223
|
-
|
|
292
|
+
patterns: this.storage.patterns,
|
|
293
|
+
artifacts: Object.entries(this.storage.artifacts),
|
|
294
|
+
learnings: Object.entries(this.storage.learnings),
|
|
295
|
+
context: Object.entries(this.storage.context),
|
|
296
|
+
taskHistory: this.storage.taskHistory
|
|
297
|
+
}, null, 2);
|
|
224
298
|
}
|
|
225
299
|
// Import memory from backup
|
|
226
300
|
importMemory(memoryData) {
|
|
227
301
|
try {
|
|
228
302
|
const data = JSON.parse(memoryData);
|
|
229
|
-
// Clear existing data
|
|
230
|
-
this.clearMemory();
|
|
231
303
|
// Import patterns
|
|
232
304
|
if (data.patterns) {
|
|
233
|
-
data.patterns.
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
238
|
-
`);
|
|
239
|
-
stmt.run(pattern.taskType, pattern.successRate, JSON.stringify(pattern.agentSequence), JSON.stringify(pattern.mcpSequence), pattern.avgDuration, pattern.lastUsed, 1);
|
|
240
|
-
});
|
|
305
|
+
this.storage.patterns = data.patterns.map((p) => ({
|
|
306
|
+
...p,
|
|
307
|
+
lastUsed: new Date(p.lastUsed)
|
|
308
|
+
}));
|
|
241
309
|
}
|
|
242
310
|
// Import artifacts
|
|
243
311
|
if (data.artifacts) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
248
|
-
`);
|
|
249
|
-
stmt.run(id, artifact.type, artifact.name, artifact.sys_id || null, JSON.stringify(artifact.config), JSON.stringify(artifact.dependencies), new Date().toISOString());
|
|
312
|
+
this.storage.artifacts = {};
|
|
313
|
+
data.artifacts.forEach(([key, value]) => {
|
|
314
|
+
this.storage.artifacts[key] = value;
|
|
250
315
|
});
|
|
251
316
|
}
|
|
252
317
|
// Import learnings
|
|
253
318
|
if (data.learnings) {
|
|
319
|
+
this.storage.learnings = {};
|
|
254
320
|
data.learnings.forEach(([key, value]) => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
321
|
+
this.storage.learnings[key] = value;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
// Import context
|
|
325
|
+
if (data.context) {
|
|
326
|
+
this.storage.context = {};
|
|
327
|
+
data.context.forEach(([key, value]) => {
|
|
328
|
+
this.storage.context[key] = value;
|
|
260
329
|
});
|
|
261
330
|
}
|
|
262
|
-
//
|
|
263
|
-
|
|
331
|
+
// Import task history
|
|
332
|
+
if (data.taskHistory) {
|
|
333
|
+
this.storage.taskHistory = data.taskHistory;
|
|
334
|
+
}
|
|
335
|
+
// Update memory from storage
|
|
336
|
+
this.memory = this.convertStorageToMemory();
|
|
337
|
+
// Save all
|
|
338
|
+
this.saveAll();
|
|
264
339
|
}
|
|
265
340
|
catch (error) {
|
|
266
341
|
throw new Error(`Failed to import memory: ${error.message}`);
|
|
@@ -268,31 +343,32 @@ class QueenMemorySystem {
|
|
|
268
343
|
}
|
|
269
344
|
// Clear all memory (reset learning)
|
|
270
345
|
clearMemory() {
|
|
271
|
-
//
|
|
272
|
-
this.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
346
|
+
// Reset storage
|
|
347
|
+
this.storage = {
|
|
348
|
+
patterns: [],
|
|
349
|
+
artifacts: {},
|
|
350
|
+
learnings: {},
|
|
351
|
+
context: {},
|
|
352
|
+
taskHistory: []
|
|
353
|
+
};
|
|
354
|
+
// Reset memory
|
|
279
355
|
this.memory = {
|
|
280
356
|
patterns: [],
|
|
281
357
|
artifacts: new Map(),
|
|
282
358
|
agentHistory: new Map(),
|
|
283
359
|
learnings: new Map()
|
|
284
360
|
};
|
|
361
|
+
// Save empty state
|
|
362
|
+
this.saveAll();
|
|
285
363
|
}
|
|
286
364
|
// Store data in context (key-value store)
|
|
287
365
|
storeInContext(key, value) {
|
|
288
|
-
|
|
289
|
-
|
|
366
|
+
this.storage.context[key] = value;
|
|
367
|
+
this.scheduleSave();
|
|
290
368
|
}
|
|
291
369
|
// Get data from context
|
|
292
370
|
getFromContext(key) {
|
|
293
|
-
|
|
294
|
-
const row = stmt.get(key);
|
|
295
|
-
return row ? JSON.parse(row.value) : null;
|
|
371
|
+
return this.storage.context[key] || null;
|
|
296
372
|
}
|
|
297
373
|
// Store generic data (alias for storeInContext for compatibility)
|
|
298
374
|
store(key, value) {
|
|
@@ -302,34 +378,33 @@ class QueenMemorySystem {
|
|
|
302
378
|
get(key) {
|
|
303
379
|
return this.getFromContext(key);
|
|
304
380
|
}
|
|
305
|
-
// Get database path
|
|
381
|
+
// Get database path (for compatibility)
|
|
306
382
|
getDbPath() {
|
|
307
|
-
return this.
|
|
383
|
+
return this.memoryDir;
|
|
308
384
|
}
|
|
309
|
-
// Close database connection
|
|
385
|
+
// Close database connection (no-op for JSON, but kept for compatibility)
|
|
310
386
|
close() {
|
|
311
|
-
|
|
387
|
+
// Save any pending changes
|
|
388
|
+
if (this.saveDebounceTimer) {
|
|
389
|
+
clearTimeout(this.saveDebounceTimer);
|
|
390
|
+
this.saveAll();
|
|
391
|
+
}
|
|
312
392
|
}
|
|
313
393
|
// Additional methods needed by other components
|
|
314
394
|
/**
|
|
315
395
|
* Find similar patterns for a given task type
|
|
316
396
|
*/
|
|
317
397
|
findSimilarPatterns(taskType) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
agentSequence: JSON.parse(row.agent_sequence),
|
|
329
|
-
mcpSequence: JSON.parse(row.mcp_sequence),
|
|
330
|
-
avgDuration: row.avg_duration,
|
|
331
|
-
lastUsed: new Date(row.last_used)
|
|
332
|
-
}));
|
|
398
|
+
return this.storage.patterns
|
|
399
|
+
.filter(p => p.taskType.toLowerCase().includes(taskType.toLowerCase()))
|
|
400
|
+
.sort((a, b) => {
|
|
401
|
+
// Sort by success rate first, then by use count
|
|
402
|
+
if (b.successRate !== a.successRate) {
|
|
403
|
+
return b.successRate - a.successRate;
|
|
404
|
+
}
|
|
405
|
+
return (b.useCount || 0) - (a.useCount || 0);
|
|
406
|
+
})
|
|
407
|
+
.slice(0, 5);
|
|
333
408
|
}
|
|
334
409
|
/**
|
|
335
410
|
* Store a decision made by the Queen
|
|
@@ -351,17 +426,22 @@ class QueenMemorySystem {
|
|
|
351
426
|
* Get memory statistics
|
|
352
427
|
*/
|
|
353
428
|
getStats() {
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
artifacts: artifactCount.count,
|
|
361
|
-
tasks: taskCount.count,
|
|
362
|
-
learnings: learningCount.count,
|
|
363
|
-
databaseSize: fs.statSync(this.dbPath).size
|
|
429
|
+
const stats = {
|
|
430
|
+
patterns: this.storage.patterns.length,
|
|
431
|
+
artifacts: Object.keys(this.storage.artifacts).length,
|
|
432
|
+
tasks: this.storage.taskHistory.length,
|
|
433
|
+
learnings: Object.keys(this.storage.learnings).length,
|
|
434
|
+
databaseSize: 0
|
|
364
435
|
};
|
|
436
|
+
// Calculate total file sizes
|
|
437
|
+
const files = ['patterns.json', 'artifacts.json', 'learnings.json', 'context.json', 'task-history.json'];
|
|
438
|
+
for (const file of files) {
|
|
439
|
+
const filepath = this.getFilePath(file);
|
|
440
|
+
if (fs.existsSync(filepath)) {
|
|
441
|
+
stats.databaseSize += fs.statSync(filepath).size;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return stats;
|
|
365
445
|
}
|
|
366
446
|
/**
|
|
367
447
|
* Store progress information
|
|
@@ -379,11 +459,8 @@ class QueenMemorySystem {
|
|
|
379
459
|
* Store failure pattern for learning
|
|
380
460
|
*/
|
|
381
461
|
storeFailurePattern(pattern) {
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
VALUES (?, ?, ?, ?)
|
|
385
|
-
`);
|
|
386
|
-
stmt.run(`failure_${Date.now()}`, JSON.stringify(pattern), 0.8, new Date().toISOString());
|
|
462
|
+
const key = `failure_${Date.now()}`;
|
|
463
|
+
this.storeLearning(key, pattern, 0.8);
|
|
387
464
|
}
|
|
388
465
|
}
|
|
389
466
|
exports.QueenMemorySystem = QueenMemorySystem;
|
package/dist/queen/types.d.ts
CHANGED
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -14,6 +14,15 @@ exports.VERSION_INFO = {
|
|
|
14
14
|
name: 'Snow-Flow',
|
|
15
15
|
description: 'ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development',
|
|
16
16
|
features: {
|
|
17
|
+
'2.6.6': [
|
|
18
|
+
'๐ JSON-BASED QUEEN MEMORY: Replaced SQLite with simple JSON file storage',
|
|
19
|
+
'โ
NO MORE PERMISSION ERRORS: Fixed SQLITE_READONLY_DBMOVED database issues permanently',
|
|
20
|
+
'๐ TRANSPARENT STORAGE: All memory data in readable JSON files (.snow-flow/queen/*.json)',
|
|
21
|
+
'๐ง ATOMIC SAVES: Safe file writes with temp file + rename for data integrity',
|
|
22
|
+
'๐พ DEBOUNCED PERSISTENCE: 1-second delay prevents excessive file writes',
|
|
23
|
+
'๐งน CLEANER SYSTEM: Removed better-sqlite3 dependency from Queen memory',
|
|
24
|
+
'๐ BACKWARDS COMPATIBLE: Same API, just simpler storage backend',
|
|
25
|
+
],
|
|
17
26
|
'1.4.39': [
|
|
18
27
|
'๐งน NEO4J REMOVAL: Removed Neo4j graph memory from available tools (implementation preserved)',
|
|
19
28
|
'โ
NEW TOOLS: Implemented neural_status and token_usage in snow-flow-mcp',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.6",
|
|
4
4
|
"description": "Snow-Flow: ServiceNow Advanced Intelligence Platform - 100+ real MCP tools with AI-powered swarm orchestration and neural networks. Dynamic task categorization using AI. Machine learning for incident classification, change risk prediction, and anomaly detection. Zero Mock Data, 100% Real API Integration.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|