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.
Files changed (74) hide show
  1. package/dist/config/snow-flow-config.d.ts +1492 -0
  2. package/dist/config/snow-flow-config.js +938 -0
  3. package/dist/coordination/coordination-engine.d.ts +41 -0
  4. package/dist/coordination/coordination-engine.js +324 -0
  5. package/dist/coordination/coordination.test.d.ts +6 -0
  6. package/dist/coordination/example.d.ts +31 -0
  7. package/dist/coordination/example.js +394 -0
  8. package/dist/coordination/execution-patterns.d.ts +43 -0
  9. package/dist/coordination/execution-patterns.js +507 -0
  10. package/dist/coordination/factory.d.ts +94 -0
  11. package/dist/coordination/factory.js +433 -0
  12. package/dist/coordination/index.d.ts +71 -0
  13. package/dist/coordination/index.js +135 -0
  14. package/dist/coordination/progress-monitor.d.ts +71 -0
  15. package/dist/coordination/progress-monitor.js +505 -0
  16. package/dist/coordination/quality-gates.d.ts +124 -0
  17. package/dist/coordination/quality-gates.js +577 -0
  18. package/dist/coordination/shared-memory.d.ts +39 -0
  19. package/dist/coordination/shared-memory.js +289 -0
  20. package/dist/coordination/task-dependencies.d.ts +50 -0
  21. package/dist/coordination/task-dependencies.js +407 -0
  22. package/dist/coordination/team-coordinator.d.ts +59 -0
  23. package/dist/coordination/team-coordinator.js +550 -0
  24. package/dist/coordination/types.d.ts +152 -0
  25. package/dist/coordination/types.js +3 -0
  26. package/dist/memory/hierarchical-memory-system.d.ts +90 -0
  27. package/dist/memory/hierarchical-memory-system.js +400 -0
  28. package/dist/memory/index.d.ts +9 -0
  29. package/dist/memory/index.js +20 -0
  30. package/dist/memory/mcp-integration-example.d.ts +6 -0
  31. package/dist/memory/mcp-integration-example.js +281 -0
  32. package/dist/memory/memory-client.d.ts +199 -0
  33. package/dist/memory/memory-client.js +364 -0
  34. package/dist/memory/memory-manager.d.ts +29 -0
  35. package/dist/memory/memory-manager.js +280 -0
  36. package/dist/memory/memory-operations.d.ts +179 -0
  37. package/dist/memory/memory-operations.js +691 -0
  38. package/dist/memory/memory-system.d.ts +152 -0
  39. package/dist/memory/memory-system.js +632 -0
  40. package/dist/memory/memory-test.d.ts +6 -0
  41. package/dist/memory/memory-test.js +161 -0
  42. package/dist/memory/servicenow-artifact-indexer.d.ts +119 -0
  43. package/dist/memory/servicenow-artifact-indexer.js +560 -0
  44. package/dist/memory/snow-flow-memory-patterns.d.ts +213 -0
  45. package/dist/memory/snow-flow-memory-patterns.js +200 -0
  46. package/dist/memory/snow-memory.d.ts +54 -0
  47. package/dist/memory/snow-memory.js +301 -0
  48. package/dist/memory/swarm-memory.d.ts +135 -0
  49. package/dist/memory/swarm-memory.js +378 -0
  50. package/memory/claude-flow-data.json +5 -0
  51. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +30 -0
  52. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +36 -0
  53. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +30 -0
  54. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +30 -0
  55. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +55 -0
  56. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +55 -0
  57. package/memory/sessions/README.md +32 -0
  58. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +9 -0
  59. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +9 -0
  60. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +8 -0
  61. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +9 -0
  62. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +9 -0
  63. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +9 -0
  64. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +58 -0
  65. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +9 -0
  66. package/package.json +1 -1
  67. package/reports/swarm-auto-centralized-1752649029776.json +13 -0
  68. package/scripts/postinstall.js +30 -0
  69. package/scripts/update-version.js +31 -0
  70. package/servicenow/widgets/openai_incident_classifier/client_controller.js +284 -0
  71. package/servicenow/widgets/openai_incident_classifier/server_script.js +314 -0
  72. package/servicenow/widgets/openai_incident_classifier/style.css +354 -0
  73. package/servicenow/widgets/openai_incident_classifier/template.html +167 -0
  74. package/servicenow/widgets/openai_incident_classifier/widget.json +86 -0
@@ -0,0 +1,301 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SnowMemory = void 0;
7
+ const sqlite3_1 = require("sqlite3");
8
+ const util_1 = require("util");
9
+ const path_1 = __importDefault(require("path"));
10
+ const promises_1 = __importDefault(require("fs/promises"));
11
+ const nanoid_1 = require("nanoid");
12
+ class SnowMemory {
13
+ constructor(options = {}) {
14
+ this.namespace = options.namespace || 'default';
15
+ this.dbPath = options.dbPath || path_1.default.join(process.cwd(), 'memory', 'snow-memory.db');
16
+ this.options = options;
17
+ }
18
+ async initialize() {
19
+ // Ensure memory directory exists
20
+ const memoryDir = path_1.default.dirname(this.dbPath);
21
+ await promises_1.default.mkdir(memoryDir, { recursive: true });
22
+ // Open database connection
23
+ this.db = new sqlite3_1.Database(this.dbPath);
24
+ // Promisify database methods
25
+ const run = (0, util_1.promisify)(this.db.run.bind(this.db));
26
+ const get = (0, util_1.promisify)(this.db.get.bind(this.db));
27
+ // Create tables if not exists
28
+ await run(`
29
+ CREATE TABLE IF NOT EXISTS memory_entries (
30
+ id TEXT PRIMARY KEY,
31
+ key TEXT NOT NULL,
32
+ value TEXT NOT NULL,
33
+ namespace TEXT NOT NULL,
34
+ ttl INTEGER,
35
+ created_at INTEGER NOT NULL,
36
+ updated_at INTEGER NOT NULL,
37
+ accessed_at INTEGER NOT NULL,
38
+ access_count INTEGER DEFAULT 1,
39
+ metadata TEXT,
40
+ UNIQUE(key, namespace)
41
+ )
42
+ `);
43
+ await run(`
44
+ CREATE INDEX IF NOT EXISTS idx_memory_namespace ON memory_entries(namespace);
45
+ `);
46
+ await run(`
47
+ CREATE INDEX IF NOT EXISTS idx_memory_key ON memory_entries(key);
48
+ `);
49
+ await run(`
50
+ CREATE INDEX IF NOT EXISTS idx_memory_ttl ON memory_entries(ttl);
51
+ `);
52
+ // Start cleanup timer
53
+ if (this.options.cleanupInterval) {
54
+ this.cleanupTimer = setInterval(() => this.cleanup(), this.options.cleanupInterval);
55
+ }
56
+ else {
57
+ // Default cleanup every 5 minutes
58
+ this.cleanupTimer = setInterval(() => this.cleanup(), 300000);
59
+ }
60
+ }
61
+ async store(key, value, options = {}) {
62
+ const namespace = options.namespace || this.namespace;
63
+ const ttl = options.ttl;
64
+ const metadata = options.metadata || {};
65
+ const now = Date.now();
66
+ const expiresAt = ttl ? now + ttl : null;
67
+ const run = (0, util_1.promisify)(this.db.run.bind(this.db));
68
+ const id = (0, nanoid_1.nanoid)();
69
+ const serializedValue = JSON.stringify(value);
70
+ const serializedMetadata = JSON.stringify(metadata);
71
+ await run(`
72
+ INSERT OR REPLACE INTO memory_entries
73
+ (id, key, value, namespace, ttl, created_at, updated_at, accessed_at, access_count, metadata)
74
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?,
75
+ COALESCE((SELECT access_count FROM memory_entries WHERE key = ? AND namespace = ?), 0) + 1,
76
+ ?)
77
+ `, [
78
+ id,
79
+ key,
80
+ serializedValue,
81
+ namespace,
82
+ expiresAt,
83
+ now,
84
+ now,
85
+ now,
86
+ key,
87
+ namespace,
88
+ serializedMetadata
89
+ ]);
90
+ // Check max entries limit
91
+ if (this.options.maxEntries) {
92
+ await this.enforceMaxEntries();
93
+ }
94
+ }
95
+ async retrieve(key, namespace) {
96
+ const ns = namespace || this.namespace;
97
+ const get = (0, util_1.promisify)(this.db.get.bind(this.db));
98
+ const run = (0, util_1.promisify)(this.db.run.bind(this.db));
99
+ const now = Date.now();
100
+ // Get entry and check TTL
101
+ const entry = await get(`
102
+ SELECT * FROM memory_entries
103
+ WHERE key = ? AND namespace = ? AND (ttl IS NULL OR ttl > ?)
104
+ `, [key, ns, now]);
105
+ if (!entry) {
106
+ return null;
107
+ }
108
+ // Update access time and count
109
+ await run(`
110
+ UPDATE memory_entries
111
+ SET accessed_at = ?, access_count = access_count + 1
112
+ WHERE key = ? AND namespace = ?
113
+ `, [now, key, ns]);
114
+ return JSON.parse(entry.value);
115
+ }
116
+ async delete(key, namespace) {
117
+ const ns = namespace || this.namespace;
118
+ const run = (0, util_1.promisify)(this.db.run.bind(this.db));
119
+ await run(`
120
+ DELETE FROM memory_entries
121
+ WHERE key = ? AND namespace = ?
122
+ `, [key, ns]);
123
+ }
124
+ async search(options = {}) {
125
+ const all = (0, util_1.promisify)(this.db.all.bind(this.db));
126
+ let query = `SELECT * FROM memory_entries WHERE 1=1`;
127
+ const params = [];
128
+ if (options.namespace) {
129
+ query += ` AND namespace = ?`;
130
+ params.push(options.namespace);
131
+ }
132
+ if (options.pattern) {
133
+ query += ` AND key LIKE ?`;
134
+ params.push(`%${options.pattern}%`);
135
+ }
136
+ // Filter out expired entries
137
+ query += ` AND (ttl IS NULL OR ttl > ?)`;
138
+ params.push(Date.now());
139
+ // Ordering
140
+ const orderBy = options.orderBy || 'updated';
141
+ const order = options.order || 'desc';
142
+ const orderColumn = {
143
+ 'created': 'created_at',
144
+ 'updated': 'updated_at',
145
+ 'accessed': 'accessed_at'
146
+ }[orderBy] || 'updated_at';
147
+ query += ` ORDER BY ${orderColumn} ${order.toUpperCase()}`;
148
+ // Pagination
149
+ const limit = options.limit || 100;
150
+ const offset = options.offset || 0;
151
+ query += ` LIMIT ? OFFSET ?`;
152
+ params.push(limit, offset);
153
+ const rows = await all(query, params);
154
+ return rows.map(row => ({
155
+ key: row.key,
156
+ value: JSON.parse(row.value),
157
+ namespace: row.namespace,
158
+ ttl: row.ttl ? row.ttl - Date.now() : undefined,
159
+ createdAt: new Date(row.created_at),
160
+ updatedAt: new Date(row.updated_at),
161
+ accessCount: row.access_count,
162
+ metadata: JSON.parse(row.metadata || '{}')
163
+ }));
164
+ }
165
+ async list(namespace) {
166
+ const ns = namespace || this.namespace;
167
+ const all = (0, util_1.promisify)(this.db.all.bind(this.db));
168
+ const rows = await all(`
169
+ SELECT key FROM memory_entries
170
+ WHERE namespace = ? AND (ttl IS NULL OR ttl > ?)
171
+ ORDER BY updated_at DESC
172
+ `, [ns, Date.now()]);
173
+ return rows.map(row => row.key);
174
+ }
175
+ async exists(key, namespace) {
176
+ const ns = namespace || this.namespace;
177
+ const get = (0, util_1.promisify)(this.db.get.bind(this.db));
178
+ const result = await get(`
179
+ SELECT 1 FROM memory_entries
180
+ WHERE key = ? AND namespace = ? AND (ttl IS NULL OR ttl > ?)
181
+ `, [key, ns, Date.now()]);
182
+ return !!result;
183
+ }
184
+ async clear(namespace) {
185
+ const run = (0, util_1.promisify)(this.db.run.bind(this.db));
186
+ if (namespace) {
187
+ await run(`DELETE FROM memory_entries WHERE namespace = ?`, [namespace]);
188
+ }
189
+ else {
190
+ await run(`DELETE FROM memory_entries`);
191
+ }
192
+ }
193
+ async cleanup() {
194
+ const run = (0, util_1.promisify)(this.db.run.bind(this.db));
195
+ const get = (0, util_1.promisify)(this.db.get.bind(this.db));
196
+ // Count expired entries before deletion
197
+ const countResult = await get(`
198
+ SELECT COUNT(*) as count FROM memory_entries
199
+ WHERE ttl IS NOT NULL AND ttl <= ?
200
+ `, [Date.now()]);
201
+ // Delete expired entries
202
+ await run(`
203
+ DELETE FROM memory_entries
204
+ WHERE ttl IS NOT NULL AND ttl <= ?
205
+ `, [Date.now()]);
206
+ return countResult?.count || 0;
207
+ }
208
+ async enforceMaxEntries() {
209
+ if (!this.options.maxEntries)
210
+ return;
211
+ const run = (0, util_1.promisify)(this.db.run.bind(this.db));
212
+ const get = (0, util_1.promisify)(this.db.get.bind(this.db));
213
+ // Get current count
214
+ const countResult = await get(`SELECT COUNT(*) as count FROM memory_entries`);
215
+ const count = countResult?.count || 0;
216
+ if (count > this.options.maxEntries) {
217
+ const toDelete = count - this.options.maxEntries;
218
+ // Delete oldest entries based on access time
219
+ await run(`
220
+ DELETE FROM memory_entries
221
+ WHERE id IN (
222
+ SELECT id FROM memory_entries
223
+ ORDER BY accessed_at ASC
224
+ LIMIT ?
225
+ )
226
+ `, [toDelete]);
227
+ }
228
+ }
229
+ async getStats() {
230
+ const get = (0, util_1.promisify)(this.db.get.bind(this.db));
231
+ const all = (0, util_1.promisify)(this.db.all.bind(this.db));
232
+ const stats = await get(`
233
+ SELECT
234
+ COUNT(*) as total_entries,
235
+ SUM(LENGTH(value)) as total_size,
236
+ MIN(created_at) as oldest,
237
+ MAX(created_at) as newest
238
+ FROM memory_entries
239
+ WHERE ttl IS NULL OR ttl > ?
240
+ `, [Date.now()]);
241
+ const namespaces = await all(`
242
+ SELECT DISTINCT namespace FROM memory_entries
243
+ `);
244
+ const mostAccessed = await get(`
245
+ SELECT key, access_count
246
+ FROM memory_entries
247
+ WHERE ttl IS NULL OR ttl > ?
248
+ ORDER BY access_count DESC
249
+ LIMIT 1
250
+ `, [Date.now()]);
251
+ return {
252
+ totalEntries: stats?.total_entries || 0,
253
+ namespaces: namespaces.map(row => row.namespace),
254
+ totalSize: stats?.total_size || 0,
255
+ oldestEntry: stats?.oldest ? new Date(stats.oldest) : null,
256
+ newestEntry: stats?.newest ? new Date(stats.newest) : null,
257
+ mostAccessed: mostAccessed ? {
258
+ key: mostAccessed.key,
259
+ count: mostAccessed.access_count
260
+ } : null
261
+ };
262
+ }
263
+ async export(filePath, namespace) {
264
+ const entries = await this.search({ namespace, limit: Number.MAX_SAFE_INTEGER });
265
+ const data = {
266
+ exported: new Date(),
267
+ namespace: namespace || 'all',
268
+ entries: entries
269
+ };
270
+ await promises_1.default.writeFile(filePath, JSON.stringify(data, null, 2), 'utf-8');
271
+ }
272
+ async import(filePath) {
273
+ const content = await promises_1.default.readFile(filePath, 'utf-8');
274
+ const data = JSON.parse(content);
275
+ let imported = 0;
276
+ for (const entry of data.entries) {
277
+ await this.store(entry.key, entry.value, {
278
+ namespace: entry.namespace,
279
+ ttl: entry.ttl,
280
+ metadata: entry.metadata
281
+ });
282
+ imported++;
283
+ }
284
+ return imported;
285
+ }
286
+ async close() {
287
+ if (this.cleanupTimer) {
288
+ clearInterval(this.cleanupTimer);
289
+ }
290
+ return new Promise((resolve) => {
291
+ this.db.close((err) => {
292
+ if (err) {
293
+ console.error('Error closing database:', err);
294
+ }
295
+ resolve();
296
+ });
297
+ });
298
+ }
299
+ }
300
+ exports.SnowMemory = SnowMemory;
301
+ //# sourceMappingURL=snow-memory.js.map
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Snow-Flow Swarm Memory System
3
+ * Core SQLite database management for agent coordination
4
+ *
5
+ * This module provides the foundation for cross-agent communication,
6
+ * artifact tracking, and performance monitoring.
7
+ */
8
+ export interface SwarmMemoryConfig {
9
+ dbPath?: string;
10
+ inMemory?: boolean;
11
+ autoMigrate?: boolean;
12
+ verbose?: boolean;
13
+ }
14
+ export interface AgentCoordination {
15
+ session_id: string;
16
+ agent_id: string;
17
+ agent_type: string;
18
+ status: 'spawned' | 'active' | 'blocked' | 'completed' | 'failed';
19
+ assigned_tasks: string;
20
+ progress_percentage: number;
21
+ last_activity: Date;
22
+ current_tool?: string;
23
+ error_state?: string;
24
+ }
25
+ export interface ServiceNowArtifactRecord {
26
+ sys_id: string;
27
+ artifact_type: 'widget' | 'flow' | 'script' | 'business_rule' | 'table' | 'catalog_item';
28
+ name: string;
29
+ description?: string;
30
+ created_by_agent: string;
31
+ session_id: string;
32
+ deployment_status: 'created' | 'tested' | 'deployed' | 'verified' | 'failed';
33
+ update_set_id?: string;
34
+ dependencies?: string;
35
+ metadata?: string;
36
+ }
37
+ export interface AgentMessage {
38
+ id: string;
39
+ session_id: string;
40
+ from_agent: string;
41
+ to_agent: string;
42
+ message_type: 'handoff' | 'dependency_ready' | 'error' | 'status_update' | 'coordination';
43
+ content: string;
44
+ artifact_reference?: string;
45
+ timestamp: Date;
46
+ processed: boolean;
47
+ }
48
+ export interface SharedContext {
49
+ session_id: string;
50
+ context_key: string;
51
+ context_value: string;
52
+ created_by_agent: string;
53
+ expires_at?: Date;
54
+ access_permissions?: string;
55
+ }
56
+ export interface DeploymentHistory {
57
+ id: string;
58
+ session_id: string;
59
+ artifact_sys_id: string;
60
+ deployment_type: 'create' | 'update' | 'test' | 'verify' | 'rollback';
61
+ success: boolean;
62
+ deployment_time: Date;
63
+ agent_id: string;
64
+ error_details?: string;
65
+ rollback_available: boolean;
66
+ }
67
+ export interface AgentDependency {
68
+ session_id: string;
69
+ agent_id: string;
70
+ depends_on_agent: string;
71
+ dependency_type: 'artifact_ready' | 'approval_needed' | 'data_available' | 'task_complete';
72
+ artifact_reference?: string;
73
+ status: 'pending' | 'satisfied' | 'blocked' | 'failed';
74
+ created_at: Date;
75
+ satisfied_at?: Date;
76
+ }
77
+ export interface PerformanceMetric {
78
+ id: string;
79
+ session_id: string;
80
+ agent_id: string;
81
+ operation_name: string;
82
+ duration_ms: number;
83
+ success: boolean;
84
+ error_message?: string;
85
+ timestamp: Date;
86
+ metadata?: string;
87
+ }
88
+ export declare class SwarmMemory {
89
+ private db;
90
+ private logger;
91
+ private config;
92
+ private migrationVersion;
93
+ constructor(config?: SwarmMemoryConfig);
94
+ private configureDatabase;
95
+ private migrate;
96
+ private createTables;
97
+ private createIndexes;
98
+ /**
99
+ * Get the underlying database instance for direct queries
100
+ */
101
+ getDatabase(): any;
102
+ /**
103
+ * Prepare a statement for repeated execution
104
+ */
105
+ prepare(sql: string): any;
106
+ /**
107
+ * Execute a query and return all results
108
+ */
109
+ all(sql: string, params?: any[]): any[];
110
+ /**
111
+ * Execute a query and return the first result
112
+ */
113
+ get(sql: string, params?: any[]): any;
114
+ /**
115
+ * Execute a statement that doesn't return data
116
+ */
117
+ run(sql: string, params?: any[]): any;
118
+ /**
119
+ * Execute multiple statements in a transaction
120
+ */
121
+ transaction<T>(fn: () => T): T;
122
+ /**
123
+ * Clean up expired data
124
+ */
125
+ cleanup(): void;
126
+ /**
127
+ * Get database statistics
128
+ */
129
+ getStats(): Record<string, any>;
130
+ /**
131
+ * Close the database connection
132
+ */
133
+ close(): void;
134
+ }
135
+ //# sourceMappingURL=swarm-memory.d.ts.map