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,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedMemoryManager = void 0;
|
|
4
|
+
const eventemitter3_1 = require("eventemitter3");
|
|
5
|
+
const logger_1 = require("../utils/logger");
|
|
6
|
+
class SharedMemoryManager extends eventemitter3_1.EventEmitter {
|
|
7
|
+
constructor(ttl = 3600000) {
|
|
8
|
+
super();
|
|
9
|
+
this.memory = new Map();
|
|
10
|
+
this.subscribers = new Map();
|
|
11
|
+
this.versionCounters = new Map();
|
|
12
|
+
this.accessLogs = new Map();
|
|
13
|
+
this.ttl = ttl;
|
|
14
|
+
// Start cleanup interval every 5 minutes
|
|
15
|
+
this.cleanupInterval = setInterval(() => {
|
|
16
|
+
this.cleanupExpiredEntries();
|
|
17
|
+
}, 300000);
|
|
18
|
+
logger_1.logger.info('๐ง Shared Memory Manager initialized', { ttl });
|
|
19
|
+
}
|
|
20
|
+
async store(key, value, notifySubscribers = true) {
|
|
21
|
+
try {
|
|
22
|
+
const version = this.getNextVersion(key);
|
|
23
|
+
const memoryValue = {
|
|
24
|
+
value,
|
|
25
|
+
timestamp: Date.now(),
|
|
26
|
+
version,
|
|
27
|
+
metadata: {
|
|
28
|
+
size: this.calculateSize(value),
|
|
29
|
+
type: typeof value,
|
|
30
|
+
lastAccess: Date.now()
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.memory.set(key, memoryValue);
|
|
34
|
+
// Log access
|
|
35
|
+
this.logAccess(key, 'write', value);
|
|
36
|
+
logger_1.logger.debug('๐พ Stored value in shared memory', {
|
|
37
|
+
key,
|
|
38
|
+
version,
|
|
39
|
+
size: memoryValue.metadata?.size
|
|
40
|
+
});
|
|
41
|
+
if (notifySubscribers) {
|
|
42
|
+
await this.notifySubscribers(key, value, version);
|
|
43
|
+
}
|
|
44
|
+
this.emit('memory:stored', { key, value, version });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger_1.logger.error('โ Failed to store in shared memory', { key, error: error.message });
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async get(key) {
|
|
52
|
+
try {
|
|
53
|
+
const entry = this.memory.get(key);
|
|
54
|
+
if (!entry) {
|
|
55
|
+
logger_1.logger.debug('๐ Key not found in shared memory', { key });
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
// Check if expired
|
|
59
|
+
if (this.isExpired(entry)) {
|
|
60
|
+
this.memory.delete(key);
|
|
61
|
+
logger_1.logger.debug('โฐ Expired entry removed from shared memory', { key });
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
// Update last access
|
|
65
|
+
entry.metadata = {
|
|
66
|
+
...entry.metadata,
|
|
67
|
+
lastAccess: Date.now()
|
|
68
|
+
};
|
|
69
|
+
// Log access
|
|
70
|
+
this.logAccess(key, 'read', entry.value);
|
|
71
|
+
logger_1.logger.debug('๐ Retrieved value from shared memory', {
|
|
72
|
+
key,
|
|
73
|
+
version: entry.version
|
|
74
|
+
});
|
|
75
|
+
return entry.value;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
logger_1.logger.error('โ Failed to get from shared memory', { key, error: error.message });
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async subscribe(key, agent, callback) {
|
|
83
|
+
try {
|
|
84
|
+
if (!this.subscribers.has(key)) {
|
|
85
|
+
this.subscribers.set(key, new Set());
|
|
86
|
+
}
|
|
87
|
+
const subscriber = { agent, callback };
|
|
88
|
+
this.subscribers.get(key).add(subscriber);
|
|
89
|
+
logger_1.logger.info('๐ก Agent subscribed to memory key', {
|
|
90
|
+
agentId: agent.id,
|
|
91
|
+
key
|
|
92
|
+
});
|
|
93
|
+
this.emit('memory:subscribed', { agentId: agent.id, key });
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
logger_1.logger.error('โ Failed to subscribe to shared memory', { key, agentId: agent.id, error: error.message });
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async unsubscribe(key, agent) {
|
|
101
|
+
const subscribers = this.subscribers.get(key);
|
|
102
|
+
if (subscribers) {
|
|
103
|
+
const toRemove = Array.from(subscribers).find(sub => sub.agent.id === agent.id);
|
|
104
|
+
if (toRemove) {
|
|
105
|
+
subscribers.delete(toRemove);
|
|
106
|
+
logger_1.logger.info('๐ก Agent unsubscribed from memory key', {
|
|
107
|
+
agentId: agent.id,
|
|
108
|
+
key
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async getHistory(key, limit = 10) {
|
|
114
|
+
const accessLogs = this.accessLogs.get(key) || [];
|
|
115
|
+
return accessLogs
|
|
116
|
+
.filter(log => log.operation === 'write')
|
|
117
|
+
.slice(-limit)
|
|
118
|
+
.map(log => ({
|
|
119
|
+
value: log.value,
|
|
120
|
+
timestamp: log.timestamp,
|
|
121
|
+
version: log.version || 1,
|
|
122
|
+
metadata: log.metadata
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
async getKeys(pattern) {
|
|
126
|
+
const keys = Array.from(this.memory.keys());
|
|
127
|
+
if (pattern) {
|
|
128
|
+
const regex = new RegExp(pattern);
|
|
129
|
+
return keys.filter(key => regex.test(key));
|
|
130
|
+
}
|
|
131
|
+
return keys;
|
|
132
|
+
}
|
|
133
|
+
async delete(key) {
|
|
134
|
+
try {
|
|
135
|
+
const existed = this.memory.has(key);
|
|
136
|
+
this.memory.delete(key);
|
|
137
|
+
this.subscribers.delete(key);
|
|
138
|
+
this.versionCounters.delete(key);
|
|
139
|
+
this.accessLogs.delete(key);
|
|
140
|
+
if (existed) {
|
|
141
|
+
logger_1.logger.info('๐๏ธ Deleted key from shared memory', { key });
|
|
142
|
+
this.emit('memory:deleted', { key });
|
|
143
|
+
}
|
|
144
|
+
return existed;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
logger_1.logger.error('โ Failed to delete from shared memory', { key, error: error.message });
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async clear() {
|
|
152
|
+
try {
|
|
153
|
+
const keyCount = this.memory.size;
|
|
154
|
+
this.memory.clear();
|
|
155
|
+
this.subscribers.clear();
|
|
156
|
+
this.versionCounters.clear();
|
|
157
|
+
this.accessLogs.clear();
|
|
158
|
+
logger_1.logger.info('๐งน Cleared all shared memory', { deletedKeys: keyCount });
|
|
159
|
+
this.emit('memory:cleared', { deletedKeys: keyCount });
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
logger_1.logger.error('โ Failed to clear shared memory', { error: error.message });
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async getStats() {
|
|
167
|
+
const totalEntries = this.memory.size;
|
|
168
|
+
const totalSize = Array.from(this.memory.values())
|
|
169
|
+
.reduce((sum, entry) => sum + (entry.metadata?.size || 0), 0);
|
|
170
|
+
const subscriberCount = Array.from(this.subscribers.values())
|
|
171
|
+
.reduce((sum, subs) => sum + subs.size, 0);
|
|
172
|
+
const oldestEntry = Array.from(this.memory.values())
|
|
173
|
+
.reduce((oldest, entry) => !oldest || entry.timestamp < oldest.timestamp ? entry : oldest);
|
|
174
|
+
return {
|
|
175
|
+
totalEntries,
|
|
176
|
+
totalSize,
|
|
177
|
+
subscriberCount,
|
|
178
|
+
oldestEntryAge: oldestEntry ? Date.now() - oldestEntry.timestamp : 0,
|
|
179
|
+
averageEntrySize: totalEntries > 0 ? totalSize / totalEntries : 0
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async compareAndSwap(key, expectedValue, newValue) {
|
|
183
|
+
try {
|
|
184
|
+
const currentEntry = this.memory.get(key);
|
|
185
|
+
if (!currentEntry) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (JSON.stringify(currentEntry.value) === JSON.stringify(expectedValue)) {
|
|
189
|
+
await this.store(key, newValue);
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
logger_1.logger.error('โ Compare and swap failed', { key, error: error.message });
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async atomicUpdate(key, updateFunction) {
|
|
200
|
+
try {
|
|
201
|
+
const currentValue = await this.get(key);
|
|
202
|
+
const newValue = updateFunction(currentValue);
|
|
203
|
+
await this.store(key, newValue);
|
|
204
|
+
return newValue;
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
logger_1.logger.error('โ Atomic update failed', { key, error: error.message });
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
getNextVersion(key) {
|
|
212
|
+
const current = this.versionCounters.get(key) || 0;
|
|
213
|
+
const next = current + 1;
|
|
214
|
+
this.versionCounters.set(key, next);
|
|
215
|
+
return next;
|
|
216
|
+
}
|
|
217
|
+
async notifySubscribers(key, value, version) {
|
|
218
|
+
const subscribers = this.subscribers.get(key);
|
|
219
|
+
if (!subscribers || subscribers.size === 0) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const notifications = Array.from(subscribers).map(async (sub) => {
|
|
223
|
+
try {
|
|
224
|
+
await sub.callback(key, value, version);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
logger_1.logger.error('โ Subscriber notification failed', {
|
|
228
|
+
agentId: sub.agent.id,
|
|
229
|
+
key,
|
|
230
|
+
error: error.message
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
await Promise.allSettled(notifications);
|
|
235
|
+
}
|
|
236
|
+
logAccess(key, operation, value) {
|
|
237
|
+
if (!this.accessLogs.has(key)) {
|
|
238
|
+
this.accessLogs.set(key, []);
|
|
239
|
+
}
|
|
240
|
+
const logs = this.accessLogs.get(key);
|
|
241
|
+
logs.push({
|
|
242
|
+
timestamp: Date.now(),
|
|
243
|
+
operation,
|
|
244
|
+
value: operation === 'write' ? value : undefined,
|
|
245
|
+
version: this.versionCounters.get(key),
|
|
246
|
+
metadata: {
|
|
247
|
+
size: this.calculateSize(value)
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
// Keep only last 100 access logs per key
|
|
251
|
+
if (logs.length > 100) {
|
|
252
|
+
logs.splice(0, logs.length - 100);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
calculateSize(value) {
|
|
256
|
+
try {
|
|
257
|
+
return new Blob([JSON.stringify(value)]).size;
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
isExpired(entry) {
|
|
264
|
+
return Date.now() - entry.timestamp > this.ttl;
|
|
265
|
+
}
|
|
266
|
+
cleanupExpiredEntries() {
|
|
267
|
+
const expiredKeys = [];
|
|
268
|
+
for (const [key, entry] of this.memory.entries()) {
|
|
269
|
+
if (this.isExpired(entry)) {
|
|
270
|
+
expiredKeys.push(key);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
for (const key of expiredKeys) {
|
|
274
|
+
this.delete(key);
|
|
275
|
+
}
|
|
276
|
+
if (expiredKeys.length > 0) {
|
|
277
|
+
logger_1.logger.info('๐งน Cleaned up expired memory entries', { count: expiredKeys.length });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
destroy() {
|
|
281
|
+
if (this.cleanupInterval) {
|
|
282
|
+
clearInterval(this.cleanupInterval);
|
|
283
|
+
}
|
|
284
|
+
this.clear();
|
|
285
|
+
this.removeAllListeners();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
exports.SharedMemoryManager = SharedMemoryManager;
|
|
289
|
+
//# sourceMappingURL=shared-memory.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { TaskNode, TaskRequirements, ExecutionPlan, CoordinationConfig } from './types';
|
|
3
|
+
import { SnowAgent } from '../types/snow-flow.types';
|
|
4
|
+
import { SharedMemoryManager } from './shared-memory';
|
|
5
|
+
export declare class TaskDependencyGraph extends EventEmitter {
|
|
6
|
+
private nodes;
|
|
7
|
+
private edges;
|
|
8
|
+
private reverseEdges;
|
|
9
|
+
private sharedMemory;
|
|
10
|
+
private config;
|
|
11
|
+
private executionStartTime?;
|
|
12
|
+
constructor(sharedMemory: SharedMemoryManager, config: CoordinationConfig);
|
|
13
|
+
addTask(taskId: string, agent: SnowAgent, requirements: TaskRequirements, dependencies?: string[]): void;
|
|
14
|
+
getReadyTasks(): Promise<TaskNode[]>;
|
|
15
|
+
areDependenciesComplete(taskId: string): Promise<boolean>;
|
|
16
|
+
executeTask(taskId: string): Promise<any>;
|
|
17
|
+
private executeTaskWithRetry;
|
|
18
|
+
private executeAgentTask;
|
|
19
|
+
private simulateAgentExecution;
|
|
20
|
+
private scheduleRetry;
|
|
21
|
+
private handleTaskFailure;
|
|
22
|
+
private markDependentTasksAsSkipped;
|
|
23
|
+
getDependencyResults(taskId: string): Promise<Record<string, any>>;
|
|
24
|
+
topologicalSort(): Promise<string[][]>;
|
|
25
|
+
validateGraph(): Promise<void>;
|
|
26
|
+
generateExecutionPlan(): Promise<ExecutionPlan>;
|
|
27
|
+
private estimatePhaseDuration;
|
|
28
|
+
private findCriticalPath;
|
|
29
|
+
private getTopologicalLevels;
|
|
30
|
+
private findParallelizationOpportunities;
|
|
31
|
+
getTotalTasks(): number;
|
|
32
|
+
getCompletedTasks(): TaskNode[];
|
|
33
|
+
getFailedTasks(): TaskNode[];
|
|
34
|
+
getInProgressTasks(): TaskNode[];
|
|
35
|
+
getPendingTasks(): TaskNode[];
|
|
36
|
+
getTask(taskId: string): TaskNode | undefined;
|
|
37
|
+
getMaxParallelism(): number;
|
|
38
|
+
getComplexityScore(): number;
|
|
39
|
+
getExecutionStats(): Promise<ExecutionStats>;
|
|
40
|
+
}
|
|
41
|
+
interface ExecutionStats {
|
|
42
|
+
totalTasks: number;
|
|
43
|
+
completedTasks: number;
|
|
44
|
+
failedTasks: number;
|
|
45
|
+
inProgressTasks: number;
|
|
46
|
+
averageExecutionTime: number;
|
|
47
|
+
totalRetries: number;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=task-dependencies.d.ts.map
|