snow-flow 2.0.4 → 2.0.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/config/snow-flow-config.d.ts +1492 -0
- package/dist/config/snow-flow-config.js +938 -0
- package/dist/coordination/coordination-engine.d.ts +41 -0
- package/dist/coordination/coordination-engine.js +324 -0
- package/dist/coordination/coordination.test.d.ts +6 -0
- package/dist/coordination/example.d.ts +31 -0
- package/dist/coordination/example.js +394 -0
- package/dist/coordination/execution-patterns.d.ts +43 -0
- package/dist/coordination/execution-patterns.js +507 -0
- package/dist/coordination/factory.d.ts +94 -0
- package/dist/coordination/factory.js +433 -0
- package/dist/coordination/index.d.ts +71 -0
- package/dist/coordination/index.js +135 -0
- package/dist/coordination/progress-monitor.d.ts +71 -0
- package/dist/coordination/progress-monitor.js +505 -0
- package/dist/coordination/quality-gates.d.ts +124 -0
- package/dist/coordination/quality-gates.js +577 -0
- package/dist/coordination/shared-memory.d.ts +39 -0
- package/dist/coordination/shared-memory.js +289 -0
- package/dist/coordination/task-dependencies.d.ts +50 -0
- package/dist/coordination/task-dependencies.js +407 -0
- package/dist/coordination/team-coordinator.d.ts +59 -0
- package/dist/coordination/team-coordinator.js +550 -0
- package/dist/coordination/types.d.ts +152 -0
- package/dist/coordination/types.js +3 -0
- package/dist/memory/hierarchical-memory-system.d.ts +90 -0
- package/dist/memory/hierarchical-memory-system.js +400 -0
- package/dist/memory/index.d.ts +9 -0
- package/dist/memory/index.js +20 -0
- package/dist/memory/mcp-integration-example.d.ts +6 -0
- package/dist/memory/mcp-integration-example.js +281 -0
- package/dist/memory/memory-client.d.ts +199 -0
- package/dist/memory/memory-client.js +364 -0
- package/dist/memory/memory-manager.d.ts +29 -0
- package/dist/memory/memory-manager.js +280 -0
- package/dist/memory/memory-operations.d.ts +179 -0
- package/dist/memory/memory-operations.js +691 -0
- package/dist/memory/memory-system.d.ts +152 -0
- package/dist/memory/memory-system.js +632 -0
- package/dist/memory/memory-test.d.ts +6 -0
- package/dist/memory/memory-test.js +161 -0
- package/dist/memory/servicenow-artifact-indexer.d.ts +119 -0
- package/dist/memory/servicenow-artifact-indexer.js +560 -0
- package/dist/memory/snow-flow-memory-patterns.d.ts +213 -0
- package/dist/memory/snow-flow-memory-patterns.js +200 -0
- package/dist/memory/snow-memory.d.ts +54 -0
- package/dist/memory/snow-memory.js +301 -0
- package/dist/memory/swarm-memory.d.ts +135 -0
- package/dist/memory/swarm-memory.js +378 -0
- package/memory/claude-flow-data.json +5 -0
- package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +30 -0
- package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +36 -0
- package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +30 -0
- package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +30 -0
- package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +55 -0
- package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +55 -0
- package/memory/sessions/README.md +32 -0
- package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +9 -0
- package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +9 -0
- package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +8 -0
- package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +9 -0
- package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +9 -0
- package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +9 -0
- package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +58 -0
- package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +9 -0
- package/package.json +1 -1
- package/reports/swarm-auto-centralized-1752649029776.json +13 -0
- package/scripts/postinstall.js +30 -0
- package/scripts/update-version.js +31 -0
- package/servicenow/widgets/openai_incident_classifier/client_controller.js +284 -0
- package/servicenow/widgets/openai_incident_classifier/server_script.js +314 -0
- package/servicenow/widgets/openai_incident_classifier/style.css +354 -0
- package/servicenow/widgets/openai_incident_classifier/template.html +167 -0
- package/servicenow/widgets/openai_incident_classifier/widget.json +86 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Snow-Flow Swarm Memory System
|
|
4
|
+
* Core SQLite database management for agent coordination
|
|
5
|
+
*
|
|
6
|
+
* This module provides the foundation for cross-agent communication,
|
|
7
|
+
* artifact tracking, and performance monitoring.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.SwarmMemory = void 0;
|
|
44
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
let Database;
|
|
48
|
+
try {
|
|
49
|
+
Database = require('better-sqlite3');
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('Failed to load better-sqlite3:', error);
|
|
53
|
+
throw new Error('better-sqlite3 module is required. Please run: npm install better-sqlite3');
|
|
54
|
+
}
|
|
55
|
+
class SwarmMemory {
|
|
56
|
+
constructor(config = {}) {
|
|
57
|
+
this.migrationVersion = 1;
|
|
58
|
+
this.logger = new logger_js_1.Logger('SwarmMemory');
|
|
59
|
+
this.config = config;
|
|
60
|
+
// Ensure memory directory exists
|
|
61
|
+
if (!config.inMemory && !config.dbPath) {
|
|
62
|
+
const memoryDir = path.join(process.cwd(), '.snow-flow', 'memory');
|
|
63
|
+
if (!fs.existsSync(memoryDir)) {
|
|
64
|
+
fs.mkdirSync(memoryDir, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
config.dbPath = path.join(memoryDir, 'swarm-memory.db');
|
|
67
|
+
}
|
|
68
|
+
// Initialize database
|
|
69
|
+
if (config.inMemory) {
|
|
70
|
+
this.db = new Database(':memory:');
|
|
71
|
+
this.logger.info('Initialized in-memory database');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.db = new Database(config.dbPath);
|
|
75
|
+
this.logger.info('Initialized file-based database', { path: config.dbPath });
|
|
76
|
+
}
|
|
77
|
+
// Configure database for performance
|
|
78
|
+
this.configureDatabase();
|
|
79
|
+
// Run migrations
|
|
80
|
+
if (config.autoMigrate !== false) {
|
|
81
|
+
this.migrate();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
configureDatabase() {
|
|
85
|
+
// Enable foreign keys for data integrity
|
|
86
|
+
this.db.pragma('foreign_keys = ON');
|
|
87
|
+
// Optimize for concurrent reads
|
|
88
|
+
this.db.pragma('journal_mode = WAL');
|
|
89
|
+
// Increase cache size for better performance
|
|
90
|
+
this.db.pragma('cache_size = 10000');
|
|
91
|
+
// Optimize for fast queries
|
|
92
|
+
this.db.pragma('synchronous = NORMAL');
|
|
93
|
+
if (this.config.verbose) {
|
|
94
|
+
this.logger.info('Database configured for optimal performance');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
migrate() {
|
|
98
|
+
this.logger.info('Running database migrations');
|
|
99
|
+
// Check current migration version
|
|
100
|
+
const userVersion = this.db.pragma('user_version', { simple: true });
|
|
101
|
+
if (userVersion < this.migrationVersion) {
|
|
102
|
+
this.logger.info(`Migrating from version ${userVersion} to ${this.migrationVersion}`);
|
|
103
|
+
try {
|
|
104
|
+
this.db.transaction(() => {
|
|
105
|
+
// Create all tables as specified in MCP_ARCHITECTURE.md
|
|
106
|
+
this.createTables();
|
|
107
|
+
// Create indexes for performance
|
|
108
|
+
this.createIndexes();
|
|
109
|
+
// Update migration version
|
|
110
|
+
this.db.pragma(`user_version = ${this.migrationVersion}`);
|
|
111
|
+
})();
|
|
112
|
+
this.logger.info('Migration completed successfully');
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.logger.error('Migration failed', error);
|
|
116
|
+
throw new Error(`Database migration failed: ${error.message}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
createTables() {
|
|
121
|
+
// Agent coordination and communication
|
|
122
|
+
this.db.exec(`
|
|
123
|
+
CREATE TABLE IF NOT EXISTS agent_coordination (
|
|
124
|
+
session_id TEXT NOT NULL,
|
|
125
|
+
agent_id TEXT NOT NULL,
|
|
126
|
+
agent_type TEXT NOT NULL,
|
|
127
|
+
status TEXT NOT NULL CHECK (status IN ('spawned', 'active', 'blocked', 'completed', 'failed')),
|
|
128
|
+
assigned_tasks TEXT NOT NULL,
|
|
129
|
+
progress_percentage INTEGER DEFAULT 0 CHECK (progress_percentage >= 0 AND progress_percentage <= 100),
|
|
130
|
+
last_activity TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
131
|
+
current_tool TEXT,
|
|
132
|
+
error_state TEXT,
|
|
133
|
+
PRIMARY KEY (session_id, agent_id)
|
|
134
|
+
);
|
|
135
|
+
`);
|
|
136
|
+
// ServiceNow artifact tracking
|
|
137
|
+
this.db.exec(`
|
|
138
|
+
CREATE TABLE IF NOT EXISTS servicenow_artifacts (
|
|
139
|
+
sys_id TEXT PRIMARY KEY,
|
|
140
|
+
artifact_type TEXT NOT NULL CHECK (artifact_type IN ('widget', 'flow', 'script', 'business_rule', 'table', 'catalog_item')),
|
|
141
|
+
name TEXT NOT NULL,
|
|
142
|
+
description TEXT,
|
|
143
|
+
created_by_agent TEXT NOT NULL,
|
|
144
|
+
session_id TEXT NOT NULL,
|
|
145
|
+
deployment_status TEXT NOT NULL CHECK (deployment_status IN ('created', 'tested', 'deployed', 'verified', 'failed')),
|
|
146
|
+
update_set_id TEXT,
|
|
147
|
+
dependencies TEXT, -- JSON array of dependent artifacts
|
|
148
|
+
metadata TEXT, -- JSON blob of artifact-specific data
|
|
149
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
150
|
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
151
|
+
);
|
|
152
|
+
`);
|
|
153
|
+
// Inter-agent communication
|
|
154
|
+
this.db.exec(`
|
|
155
|
+
CREATE TABLE IF NOT EXISTS agent_messages (
|
|
156
|
+
id TEXT PRIMARY KEY,
|
|
157
|
+
session_id TEXT NOT NULL,
|
|
158
|
+
from_agent TEXT NOT NULL,
|
|
159
|
+
to_agent TEXT NOT NULL,
|
|
160
|
+
message_type TEXT NOT NULL CHECK (message_type IN ('handoff', 'dependency_ready', 'error', 'status_update', 'coordination')),
|
|
161
|
+
content TEXT NOT NULL,
|
|
162
|
+
artifact_reference TEXT,
|
|
163
|
+
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
164
|
+
processed BOOLEAN DEFAULT FALSE
|
|
165
|
+
);
|
|
166
|
+
`);
|
|
167
|
+
// Shared context between agents
|
|
168
|
+
this.db.exec(`
|
|
169
|
+
CREATE TABLE IF NOT EXISTS shared_context (
|
|
170
|
+
session_id TEXT NOT NULL,
|
|
171
|
+
context_key TEXT NOT NULL,
|
|
172
|
+
context_value TEXT NOT NULL,
|
|
173
|
+
created_by_agent TEXT NOT NULL,
|
|
174
|
+
expires_at TIMESTAMP,
|
|
175
|
+
access_permissions TEXT, -- JSON array of agent types that can access
|
|
176
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
177
|
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
178
|
+
PRIMARY KEY (session_id, context_key)
|
|
179
|
+
);
|
|
180
|
+
`);
|
|
181
|
+
// Deployment tracking
|
|
182
|
+
this.db.exec(`
|
|
183
|
+
CREATE TABLE IF NOT EXISTS deployment_history (
|
|
184
|
+
id TEXT PRIMARY KEY,
|
|
185
|
+
session_id TEXT NOT NULL,
|
|
186
|
+
artifact_sys_id TEXT NOT NULL,
|
|
187
|
+
deployment_type TEXT NOT NULL CHECK (deployment_type IN ('create', 'update', 'test', 'verify', 'rollback')),
|
|
188
|
+
success BOOLEAN NOT NULL,
|
|
189
|
+
deployment_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
190
|
+
agent_id TEXT NOT NULL,
|
|
191
|
+
error_details TEXT,
|
|
192
|
+
rollback_available BOOLEAN DEFAULT FALSE
|
|
193
|
+
);
|
|
194
|
+
`);
|
|
195
|
+
// Agent dependencies and handoffs
|
|
196
|
+
this.db.exec(`
|
|
197
|
+
CREATE TABLE IF NOT EXISTS agent_dependencies (
|
|
198
|
+
session_id TEXT NOT NULL,
|
|
199
|
+
agent_id TEXT NOT NULL,
|
|
200
|
+
depends_on_agent TEXT NOT NULL,
|
|
201
|
+
dependency_type TEXT NOT NULL CHECK (dependency_type IN ('artifact_ready', 'approval_needed', 'data_available', 'task_complete')),
|
|
202
|
+
artifact_reference TEXT,
|
|
203
|
+
status TEXT NOT NULL CHECK (status IN ('pending', 'satisfied', 'blocked', 'failed')),
|
|
204
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
205
|
+
satisfied_at TIMESTAMP,
|
|
206
|
+
PRIMARY KEY (session_id, agent_id, depends_on_agent)
|
|
207
|
+
);
|
|
208
|
+
`);
|
|
209
|
+
// Performance metrics
|
|
210
|
+
this.db.exec(`
|
|
211
|
+
CREATE TABLE IF NOT EXISTS performance_metrics (
|
|
212
|
+
id TEXT PRIMARY KEY,
|
|
213
|
+
session_id TEXT NOT NULL,
|
|
214
|
+
agent_id TEXT NOT NULL,
|
|
215
|
+
operation_name TEXT NOT NULL,
|
|
216
|
+
duration_ms INTEGER NOT NULL CHECK (duration_ms >= 0),
|
|
217
|
+
success BOOLEAN NOT NULL,
|
|
218
|
+
error_message TEXT,
|
|
219
|
+
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
220
|
+
metadata TEXT -- JSON blob for additional metrics
|
|
221
|
+
);
|
|
222
|
+
`);
|
|
223
|
+
}
|
|
224
|
+
createIndexes() {
|
|
225
|
+
// Indexes for agent_coordination
|
|
226
|
+
this.db.exec(`
|
|
227
|
+
CREATE INDEX IF NOT EXISTS idx_agent_coordination_status
|
|
228
|
+
ON agent_coordination(status);
|
|
229
|
+
|
|
230
|
+
CREATE INDEX IF NOT EXISTS idx_agent_coordination_session
|
|
231
|
+
ON agent_coordination(session_id);
|
|
232
|
+
`);
|
|
233
|
+
// Indexes for servicenow_artifacts
|
|
234
|
+
this.db.exec(`
|
|
235
|
+
CREATE INDEX IF NOT EXISTS idx_artifacts_session
|
|
236
|
+
ON servicenow_artifacts(session_id);
|
|
237
|
+
|
|
238
|
+
CREATE INDEX IF NOT EXISTS idx_artifacts_type
|
|
239
|
+
ON servicenow_artifacts(artifact_type);
|
|
240
|
+
|
|
241
|
+
CREATE INDEX IF NOT EXISTS idx_artifacts_status
|
|
242
|
+
ON servicenow_artifacts(deployment_status);
|
|
243
|
+
`);
|
|
244
|
+
// Indexes for agent_messages
|
|
245
|
+
this.db.exec(`
|
|
246
|
+
CREATE INDEX IF NOT EXISTS idx_messages_session
|
|
247
|
+
ON agent_messages(session_id);
|
|
248
|
+
|
|
249
|
+
CREATE INDEX IF NOT EXISTS idx_messages_to_agent
|
|
250
|
+
ON agent_messages(to_agent, processed);
|
|
251
|
+
|
|
252
|
+
CREATE INDEX IF NOT EXISTS idx_messages_timestamp
|
|
253
|
+
ON agent_messages(timestamp);
|
|
254
|
+
`);
|
|
255
|
+
// Indexes for shared_context
|
|
256
|
+
this.db.exec(`
|
|
257
|
+
CREATE INDEX IF NOT EXISTS idx_context_session
|
|
258
|
+
ON shared_context(session_id);
|
|
259
|
+
|
|
260
|
+
CREATE INDEX IF NOT EXISTS idx_context_expires
|
|
261
|
+
ON shared_context(expires_at);
|
|
262
|
+
`);
|
|
263
|
+
// Indexes for performance_metrics
|
|
264
|
+
this.db.exec(`
|
|
265
|
+
CREATE INDEX IF NOT EXISTS idx_metrics_session
|
|
266
|
+
ON performance_metrics(session_id);
|
|
267
|
+
|
|
268
|
+
CREATE INDEX IF NOT EXISTS idx_metrics_agent
|
|
269
|
+
ON performance_metrics(agent_id);
|
|
270
|
+
|
|
271
|
+
CREATE INDEX IF NOT EXISTS idx_metrics_timestamp
|
|
272
|
+
ON performance_metrics(timestamp);
|
|
273
|
+
`);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Get the underlying database instance for direct queries
|
|
277
|
+
*/
|
|
278
|
+
getDatabase() {
|
|
279
|
+
return this.db;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Prepare a statement for repeated execution
|
|
283
|
+
*/
|
|
284
|
+
prepare(sql) {
|
|
285
|
+
return this.db.prepare(sql);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Execute a query and return all results
|
|
289
|
+
*/
|
|
290
|
+
all(sql, params) {
|
|
291
|
+
const stmt = this.db.prepare(sql);
|
|
292
|
+
return params ? stmt.all(...params) : stmt.all();
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Execute a query and return the first result
|
|
296
|
+
*/
|
|
297
|
+
get(sql, params) {
|
|
298
|
+
const stmt = this.db.prepare(sql);
|
|
299
|
+
return params ? stmt.get(...params) : stmt.get();
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Execute a statement that doesn't return data
|
|
303
|
+
*/
|
|
304
|
+
run(sql, params) {
|
|
305
|
+
const stmt = this.db.prepare(sql);
|
|
306
|
+
return params ? stmt.run(...params) : stmt.run();
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Execute multiple statements in a transaction
|
|
310
|
+
*/
|
|
311
|
+
transaction(fn) {
|
|
312
|
+
const transaction = this.db.transaction(fn);
|
|
313
|
+
return transaction();
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Clean up expired data
|
|
317
|
+
*/
|
|
318
|
+
cleanup() {
|
|
319
|
+
this.logger.info('Running memory cleanup');
|
|
320
|
+
this.transaction(() => {
|
|
321
|
+
// Remove expired context
|
|
322
|
+
this.run(`
|
|
323
|
+
DELETE FROM shared_context
|
|
324
|
+
WHERE expires_at IS NOT NULL AND expires_at < datetime('now')
|
|
325
|
+
`);
|
|
326
|
+
// Archive old messages
|
|
327
|
+
const thirtyDaysAgo = new Date();
|
|
328
|
+
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
|
|
329
|
+
this.run(`
|
|
330
|
+
DELETE FROM agent_messages
|
|
331
|
+
WHERE processed = 1 AND timestamp < ?
|
|
332
|
+
`, [thirtyDaysAgo.toISOString()]);
|
|
333
|
+
// Archive old performance metrics
|
|
334
|
+
this.run(`
|
|
335
|
+
DELETE FROM performance_metrics
|
|
336
|
+
WHERE timestamp < ?
|
|
337
|
+
`, [thirtyDaysAgo.toISOString()]);
|
|
338
|
+
});
|
|
339
|
+
// Optimize database
|
|
340
|
+
this.db.pragma('optimize');
|
|
341
|
+
this.logger.info('Memory cleanup completed');
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Get database statistics
|
|
345
|
+
*/
|
|
346
|
+
getStats() {
|
|
347
|
+
const stats = {};
|
|
348
|
+
const tables = [
|
|
349
|
+
'agent_coordination',
|
|
350
|
+
'servicenow_artifacts',
|
|
351
|
+
'agent_messages',
|
|
352
|
+
'shared_context',
|
|
353
|
+
'deployment_history',
|
|
354
|
+
'agent_dependencies',
|
|
355
|
+
'performance_metrics'
|
|
356
|
+
];
|
|
357
|
+
for (const table of tables) {
|
|
358
|
+
const count = this.get(`SELECT COUNT(*) as count FROM ${table}`)?.count || 0;
|
|
359
|
+
stats[table] = count;
|
|
360
|
+
}
|
|
361
|
+
// Add database size
|
|
362
|
+
const pageCount = this.db.pragma('page_count', { simple: true });
|
|
363
|
+
const pageSize = this.db.pragma('page_size', { simple: true });
|
|
364
|
+
if (pageCount && pageSize) {
|
|
365
|
+
stats.database_size_bytes = pageCount * pageSize;
|
|
366
|
+
}
|
|
367
|
+
return stats;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Close the database connection
|
|
371
|
+
*/
|
|
372
|
+
close() {
|
|
373
|
+
this.logger.info('Closing database connection');
|
|
374
|
+
this.db.close();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
exports.SwarmMemory = SwarmMemory;
|
|
378
|
+
//# sourceMappingURL=swarm-memory.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"sys_id": "000d9224c895221055906c7518aa2d3d",
|
|
4
|
+
"name": "open_nlu_predict_log0001",
|
|
5
|
+
"type": "sys_db_object",
|
|
6
|
+
"last_updated": "2025-05-01 00:51:23"
|
|
7
|
+
},
|
|
8
|
+
"structure": {
|
|
9
|
+
"type": "unknown",
|
|
10
|
+
"components": []
|
|
11
|
+
},
|
|
12
|
+
"context": {
|
|
13
|
+
"usage": "Context analysis would determine usage patterns",
|
|
14
|
+
"dependencies": "Related artifacts would be identified here",
|
|
15
|
+
"impact": "Impact analysis would be performed here"
|
|
16
|
+
},
|
|
17
|
+
"relationships": {
|
|
18
|
+
"relatedArtifacts": [],
|
|
19
|
+
"dependencies": [],
|
|
20
|
+
"usage": []
|
|
21
|
+
},
|
|
22
|
+
"claudeSummary": "open_nlu_predict_log0001 is a sys_db_object in ServiceNow. It can be modified using natural language instructions through Snow-Flow.",
|
|
23
|
+
"modificationPoints": [
|
|
24
|
+
{
|
|
25
|
+
"location": "main_configuration",
|
|
26
|
+
"type": "modify_settings",
|
|
27
|
+
"description": "Main configuration can be modified"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"sys_id": "0196b66173303010e46b4a2214f6a7a2",
|
|
4
|
+
"name": "Flow Template Subflow",
|
|
5
|
+
"type": "sys_hub_flow",
|
|
6
|
+
"last_updated": "2021-09-29 04:49:06"
|
|
7
|
+
},
|
|
8
|
+
"structure": {
|
|
9
|
+
"type": "flow",
|
|
10
|
+
"components": {
|
|
11
|
+
"name": "Flow Template Subflow",
|
|
12
|
+
"description": "",
|
|
13
|
+
"active": "false",
|
|
14
|
+
"trigger": "Unknown trigger",
|
|
15
|
+
"steps": "Flow definition analysis would go here"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"context": {
|
|
19
|
+
"usage": "Context analysis would determine usage patterns",
|
|
20
|
+
"dependencies": "Related artifacts would be identified here",
|
|
21
|
+
"impact": "Impact analysis would be performed here"
|
|
22
|
+
},
|
|
23
|
+
"relationships": {
|
|
24
|
+
"relatedArtifacts": [],
|
|
25
|
+
"dependencies": [],
|
|
26
|
+
"usage": []
|
|
27
|
+
},
|
|
28
|
+
"claudeSummary": "Flow Template Subflow is a sys_hub_flow in ServiceNow. It can be modified using natural language instructions through Snow-Flow.",
|
|
29
|
+
"modificationPoints": [
|
|
30
|
+
{
|
|
31
|
+
"location": "main_configuration",
|
|
32
|
+
"type": "modify_settings",
|
|
33
|
+
"description": "Main configuration can be modified"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"sys_id": "125e5d1d837e2a102a7ea130ceaad397",
|
|
4
|
+
"name": "iPhone 6 Request Approval Flow",
|
|
5
|
+
"type": "wf_workflow",
|
|
6
|
+
"last_updated": "2025-07-16 17:47:17"
|
|
7
|
+
},
|
|
8
|
+
"structure": {
|
|
9
|
+
"type": "unknown",
|
|
10
|
+
"components": []
|
|
11
|
+
},
|
|
12
|
+
"context": {
|
|
13
|
+
"usage": "Context analysis would determine usage patterns",
|
|
14
|
+
"dependencies": "Related artifacts would be identified here",
|
|
15
|
+
"impact": "Impact analysis would be performed here"
|
|
16
|
+
},
|
|
17
|
+
"relationships": {
|
|
18
|
+
"relatedArtifacts": [],
|
|
19
|
+
"dependencies": [],
|
|
20
|
+
"usage": []
|
|
21
|
+
},
|
|
22
|
+
"claudeSummary": "iPhone 6 Request Approval Flow is a wf_workflow in ServiceNow. It can be modified using natural language instructions through Snow-Flow.",
|
|
23
|
+
"modificationPoints": [
|
|
24
|
+
{
|
|
25
|
+
"location": "main_configuration",
|
|
26
|
+
"type": "modify_settings",
|
|
27
|
+
"description": "Main configuration can be modified"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"sys_id": "7637c1f2b7112210a5e5911cde11a972",
|
|
4
|
+
"name": "Prevent invalid language code",
|
|
5
|
+
"type": "sys_script",
|
|
6
|
+
"last_updated": "2025-05-18 23:10:10"
|
|
7
|
+
},
|
|
8
|
+
"structure": {
|
|
9
|
+
"type": "unknown",
|
|
10
|
+
"components": []
|
|
11
|
+
},
|
|
12
|
+
"context": {
|
|
13
|
+
"usage": "Context analysis would determine usage patterns",
|
|
14
|
+
"dependencies": "Related artifacts would be identified here",
|
|
15
|
+
"impact": "Impact analysis would be performed here"
|
|
16
|
+
},
|
|
17
|
+
"relationships": {
|
|
18
|
+
"relatedArtifacts": [],
|
|
19
|
+
"dependencies": [],
|
|
20
|
+
"usage": []
|
|
21
|
+
},
|
|
22
|
+
"claudeSummary": "Prevent invalid language code is a sys_script in ServiceNow. It can be modified using natural language instructions through Snow-Flow.",
|
|
23
|
+
"modificationPoints": [
|
|
24
|
+
{
|
|
25
|
+
"location": "main_configuration",
|
|
26
|
+
"type": "modify_settings",
|
|
27
|
+
"description": "Main configuration can be modified"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "default:documentation_tables_1754056582292",
|
|
3
|
+
"data": {
|
|
4
|
+
"generation_metadata": {
|
|
5
|
+
"timestamp": "2025-08-01T13:56:22.292Z",
|
|
6
|
+
"execution_time_ms": 14,
|
|
7
|
+
"scope": [
|
|
8
|
+
"tables"
|
|
9
|
+
],
|
|
10
|
+
"format": "markdown",
|
|
11
|
+
"audience_level": "mixed",
|
|
12
|
+
"objects_documented": 1,
|
|
13
|
+
"auto_update_enabled": false
|
|
14
|
+
},
|
|
15
|
+
"discovered_objects": [
|
|
16
|
+
{
|
|
17
|
+
"type": "table",
|
|
18
|
+
"name": "incident",
|
|
19
|
+
"label": "Incident",
|
|
20
|
+
"description": "Incident management table",
|
|
21
|
+
"sys_id": "incident_table_id"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"documentation_content": {
|
|
25
|
+
"format": "markdown",
|
|
26
|
+
"content": "# ServiceNow tables Documentation\n\n*Generated on: 8/1/2025*\n*Objects documented: 1*\n\n## Table of Contents\n\n- [Executive Summary](#executive-summary)\n- [Architecture Overview](#architecture-overview)\n- [table: incident](#table:-incident)\n- [Best Practices and Recommendations](#best-practices-and-recommendations)\n\n\n## Executive Summary\n\nThis documentation covers 1 ServiceNow objects across multiple categories: 1 table.\n\n### Scope:\n- **Documentation Type**: undefined level\n- **Format**: markdown\n- **Coverage**: tables\n- **Generated**: 8/1/2025\n\n### Key Highlights:\n- Comprehensive coverage of core system components\n- Detailed technical specifications and usage guidelines\n- Best practices and recommendations for optimal implementation\n- Architecture diagrams and relationship mappings\n- API documentation not included\n\n### Audience:\nThis documentation is designed for both technical and business stakeholders.\n \n\n\n## incident\n\n**Type**: table\n**Description**: Incident management table\n\n**System ID**: incident_table_id\n\n### Overview\nIncident management table\n\n### Table Structure\n\n## Incident\n\n**Table Name:** incident\n**Description:** Incident management table\n**Type:** Core ServiceNow Table\n\n### Key Characteristics:\n- Primary table for incident records\n- Extends: task (if applicable)\n- Access controlled by ACLs\n- Supports workflows and business rules\n \n\n### Field Definitions\n\n### Core Fields:\n- **sys_id**: Unique identifier (32-character GUID)\n- **number**: Auto-generated record number\n- **state**: Current state of the record\n- **priority**: Priority level (1-5)\n- **assigned_to**: User assigned to handle the record\n- **short_description**: Brief description of the issue/request\n- **description**: Detailed description\n\n### Custom Fields:\n_(Document any custom fields added to this table)_\n \n\n### Relationships\n\n### Parent-Child Relationships:\n- Extends: task table (inherits all task fields)\n- Child tables: None\n\n### Reference Relationships:\n- assigned_to → sys_user\n- caller_id → sys_user (if applicable)\n- cmdb_ci → cmdb_ci (if applicable)\n\n### Related Lists:\n- Approvals\n- Activities (work notes, comments)\n- Attachments\n \n\n### Dependencies\n- **sys_user** (table): references\n- **task** (table): extends\n- **approval_workflow** (workflow): triggers\n\n### Usage Patterns\n**High Volume Usage**: This object is accessed frequently during business hours\n*Recommendation: Consider performance optimization for peak times*\n\n**Integration Dependency**: Relies on external system integration\n*Recommendation: Ensure proper error handling for integration failures*\n\n### Best Practices\n- Always validate required fields before saving\n- Use proper ACLs to control access\n- Consider performance impact of large datasets\n- Document any custom fields and their purpose\n\n\n\n\n## Best Practices and Recommendations\n\n### General Guidelines:\n- Follow ServiceNow best practices for development and configuration\n- Use proper naming conventions for all objects\n- Document all customizations and configurations\n- Test thoroughly in development before deploying to production\n- Implement proper error handling and logging\n\n### Performance Considerations:\n- Optimize database queries and avoid N+1 query patterns\n- Use appropriate indexes for frequently queried fields\n- Consider caching for frequently accessed data\n- Monitor system performance and resource usage\n\n### Security Best Practices:\n- Implement proper access controls using ACLs\n- Follow principle of least privilege for user permissions\n- Validate all user inputs to prevent security vulnerabilities\n- Regularly review and audit security configurations\n\n### Maintenance and Support:\n- Keep documentation up to date with system changes\n- Implement proper version control for customizations\n- Plan for regular maintenance windows and updates\n- Establish monitoring and alerting for critical processes\n\n### Integration Guidelines:\n- Use standard ServiceNow APIs where possible\n- Implement proper error handling for external integrations\n- Document all integration points and data flows\n- Test integrations thoroughly including failure scenarios\n \n\n",
|
|
27
|
+
"filename": "ServiceNow_tables_Documentation.md"
|
|
28
|
+
},
|
|
29
|
+
"diagrams": null,
|
|
30
|
+
"api_documentation": null,
|
|
31
|
+
"auto_update_config": null,
|
|
32
|
+
"statistics": {
|
|
33
|
+
"total_objects": 1,
|
|
34
|
+
"content_sections": 3,
|
|
35
|
+
"diagrams_generated": 0,
|
|
36
|
+
"api_endpoints_documented": 0,
|
|
37
|
+
"total_words": 538,
|
|
38
|
+
"estimated_reading_time_minutes": 3
|
|
39
|
+
},
|
|
40
|
+
"quality_metrics": {
|
|
41
|
+
"completeness_score": 60,
|
|
42
|
+
"accuracy_score": 100,
|
|
43
|
+
"readability_score": 25,
|
|
44
|
+
"coverage_percentage": 100
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"timestamp": 1754056582292,
|
|
48
|
+
"ttl": 604800000,
|
|
49
|
+
"tags": [],
|
|
50
|
+
"metadata": {
|
|
51
|
+
"creator": "ServiceNowAdvancedFeaturesMCP",
|
|
52
|
+
"version": "1.0.0",
|
|
53
|
+
"description": "Cached data for key: documentation_tables_1754056582292"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "default:documentation_tables_1754057477189",
|
|
3
|
+
"data": {
|
|
4
|
+
"generation_metadata": {
|
|
5
|
+
"timestamp": "2025-08-01T14:11:17.189Z",
|
|
6
|
+
"execution_time_ms": 14,
|
|
7
|
+
"scope": [
|
|
8
|
+
"tables"
|
|
9
|
+
],
|
|
10
|
+
"format": "markdown",
|
|
11
|
+
"audience_level": "mixed",
|
|
12
|
+
"objects_documented": 1,
|
|
13
|
+
"auto_update_enabled": false
|
|
14
|
+
},
|
|
15
|
+
"discovered_objects": [
|
|
16
|
+
{
|
|
17
|
+
"type": "table",
|
|
18
|
+
"name": "incident",
|
|
19
|
+
"label": "Incident",
|
|
20
|
+
"description": "Incident management table",
|
|
21
|
+
"sys_id": "incident_table_id"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"documentation_content": {
|
|
25
|
+
"format": "markdown",
|
|
26
|
+
"content": "# ServiceNow tables Documentation\n\n*Generated on: 8/1/2025*\n*Objects documented: 1*\n\n## Table of Contents\n\n- [Executive Summary](#executive-summary)\n- [Architecture Overview](#architecture-overview)\n- [table: incident](#table:-incident)\n- [Best Practices and Recommendations](#best-practices-and-recommendations)\n\n\n## Executive Summary\n\nThis documentation covers 1 ServiceNow objects across multiple categories: 1 table.\n\n### Scope:\n- **Documentation Type**: undefined level\n- **Format**: markdown\n- **Coverage**: tables\n- **Generated**: 8/1/2025\n\n### Key Highlights:\n- Comprehensive coverage of core system components\n- Detailed technical specifications and usage guidelines\n- Best practices and recommendations for optimal implementation\n- Architecture diagrams and relationship mappings\n- API documentation not included\n\n### Audience:\nThis documentation is designed for both technical and business stakeholders.\n \n\n\n## incident\n\n**Type**: table\n**Description**: Incident management table\n\n**System ID**: incident_table_id\n\n### Overview\nIncident management table\n\n### Table Structure\n\n## Incident\n\n**Table Name:** incident\n**Description:** Incident management table\n**Type:** Core ServiceNow Table\n\n### Key Characteristics:\n- Primary table for incident records\n- Extends: task (if applicable)\n- Access controlled by ACLs\n- Supports workflows and business rules\n \n\n### Field Definitions\n\n### Core Fields:\n- **sys_id**: Unique identifier (32-character GUID)\n- **number**: Auto-generated record number\n- **state**: Current state of the record\n- **priority**: Priority level (1-5)\n- **assigned_to**: User assigned to handle the record\n- **short_description**: Brief description of the issue/request\n- **description**: Detailed description\n\n### Custom Fields:\n_(Document any custom fields added to this table)_\n \n\n### Relationships\n\n### Parent-Child Relationships:\n- Extends: task table (inherits all task fields)\n- Child tables: None\n\n### Reference Relationships:\n- assigned_to → sys_user\n- caller_id → sys_user (if applicable)\n- cmdb_ci → cmdb_ci (if applicable)\n\n### Related Lists:\n- Approvals\n- Activities (work notes, comments)\n- Attachments\n \n\n### Dependencies\n- **sys_user** (table): references\n- **task** (table): extends\n- **approval_workflow** (workflow): triggers\n\n### Usage Patterns\n**High Volume Usage**: This object is accessed frequently during business hours\n*Recommendation: Consider performance optimization for peak times*\n\n**Integration Dependency**: Relies on external system integration\n*Recommendation: Ensure proper error handling for integration failures*\n\n### Best Practices\n- Always validate required fields before saving\n- Use proper ACLs to control access\n- Consider performance impact of large datasets\n- Document any custom fields and their purpose\n\n\n\n\n## Best Practices and Recommendations\n\n### General Guidelines:\n- Follow ServiceNow best practices for development and configuration\n- Use proper naming conventions for all objects\n- Document all customizations and configurations\n- Test thoroughly in development before deploying to production\n- Implement proper error handling and logging\n\n### Performance Considerations:\n- Optimize database queries and avoid N+1 query patterns\n- Use appropriate indexes for frequently queried fields\n- Consider caching for frequently accessed data\n- Monitor system performance and resource usage\n\n### Security Best Practices:\n- Implement proper access controls using ACLs\n- Follow principle of least privilege for user permissions\n- Validate all user inputs to prevent security vulnerabilities\n- Regularly review and audit security configurations\n\n### Maintenance and Support:\n- Keep documentation up to date with system changes\n- Implement proper version control for customizations\n- Plan for regular maintenance windows and updates\n- Establish monitoring and alerting for critical processes\n\n### Integration Guidelines:\n- Use standard ServiceNow APIs where possible\n- Implement proper error handling for external integrations\n- Document all integration points and data flows\n- Test integrations thoroughly including failure scenarios\n \n\n",
|
|
27
|
+
"filename": "ServiceNow_tables_Documentation.md"
|
|
28
|
+
},
|
|
29
|
+
"diagrams": null,
|
|
30
|
+
"api_documentation": null,
|
|
31
|
+
"auto_update_config": null,
|
|
32
|
+
"statistics": {
|
|
33
|
+
"total_objects": 1,
|
|
34
|
+
"content_sections": 3,
|
|
35
|
+
"diagrams_generated": 0,
|
|
36
|
+
"api_endpoints_documented": 0,
|
|
37
|
+
"total_words": 538,
|
|
38
|
+
"estimated_reading_time_minutes": 3
|
|
39
|
+
},
|
|
40
|
+
"quality_metrics": {
|
|
41
|
+
"completeness_score": 60,
|
|
42
|
+
"accuracy_score": 100,
|
|
43
|
+
"readability_score": 25,
|
|
44
|
+
"coverage_percentage": 100
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"timestamp": 1754057477189,
|
|
48
|
+
"ttl": 604800000,
|
|
49
|
+
"tags": [],
|
|
50
|
+
"metadata": {
|
|
51
|
+
"creator": "ServiceNowAdvancedFeaturesMCP",
|
|
52
|
+
"version": "1.0.0",
|
|
53
|
+
"description": "Cached data for key: documentation_tables_1754057477189"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Session Memory Storage
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
This directory stores session-based memory data, conversation history, and contextual information for development sessions using the Claude-Flow orchestration system.
|
|
5
|
+
|
|
6
|
+
## Structure
|
|
7
|
+
Sessions are organized by date and session ID for easy retrieval:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
memory/sessions/
|
|
11
|
+
├── 2024-01-10/
|
|
12
|
+
│ ├── session_001/
|
|
13
|
+
│ │ ├── metadata.json # Session metadata and configuration
|
|
14
|
+
│ │ ├── conversation.md # Full conversation history
|
|
15
|
+
│ │ ├── decisions.md # Key decisions and rationale
|
|
16
|
+
│ │ ├── artifacts/ # Generated files and outputs
|
|
17
|
+
│ │ └── coordination_state/ # Coordination system snapshots
|
|
18
|
+
│ └── ...
|
|
19
|
+
└── shared/
|
|
20
|
+
├── patterns.md # Common session patterns
|
|
21
|
+
└── templates/ # Session template files
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage Guidelines
|
|
25
|
+
1. **Session Isolation**: Each session gets its own directory
|
|
26
|
+
2. **Metadata Completeness**: Always fill out session metadata
|
|
27
|
+
3. **Conversation Logging**: Document all significant interactions
|
|
28
|
+
4. **Artifact Organization**: Structure generated files clearly
|
|
29
|
+
5. **State Preservation**: Snapshot coordination state regularly
|
|
30
|
+
|
|
31
|
+
## Last Updated
|
|
32
|
+
2025-08-01T08:50:14.952Z
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "01f82af583faea102a7ea130ceaad3d4",
|
|
3
|
+
"name": "iPhone 6 Approval Flow",
|
|
4
|
+
"description": "Flow to check if request is for iPhone 6 and require admin approval for such requests",
|
|
5
|
+
"user_story": "FLOW-001",
|
|
6
|
+
"created_at": "2025-07-18T12:30:12.807Z",
|
|
7
|
+
"state": "in_progress",
|
|
8
|
+
"artifacts": []
|
|
9
|
+
}
|