snow-flow 2.0.2 → 2.0.4

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 (173) hide show
  1. package/{.claude/mcp-config.json → .mcp.json} +13 -12
  2. package/.releaserc.json +47 -0
  3. package/README.md +48 -1
  4. package/package.json +1 -1
  5. package/.claude/claude-settings.json +0 -15
  6. package/.claude/commands/analysis/README.md +0 -9
  7. package/.claude/commands/automation/README.md +0 -9
  8. package/.claude/commands/github/README.md +0 -11
  9. package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
  10. package/.claude/commands/hooks/README.md +0 -11
  11. package/.claude/commands/monitoring/README.md +0 -9
  12. package/.claude/commands/optimization/README.md +0 -9
  13. package/.claude/commands/training/README.md +0 -9
  14. package/.claude/commands/workflows/README.md +0 -9
  15. package/.claude/config.json +0 -36
  16. package/.claude/helpers/github-setup.sh +0 -28
  17. package/.claude/helpers/quick-start.sh +0 -19
  18. package/.claude/helpers/setup-mcp.sh +0 -18
  19. package/.claude/settings.json +0 -114
  20. package/.claude/settings.local.json +0 -33
  21. package/.claude-flow/metrics/agent-metrics.json +0 -1
  22. package/.claude-flow/metrics/performance.json +0 -9
  23. package/.claude-flow/metrics/system-metrics.json +0 -15986
  24. package/.claude-flow/metrics/task-metrics.json +0 -10
  25. package/.roo/README.md +0 -402
  26. package/.roo/mcp-list.txt +0 -257
  27. package/.roo/mcp.json +0 -32
  28. package/.roo/workflows/basic-tdd.json +0 -32
  29. package/.roomodes +0 -201
  30. package/CLAUDE.md +0 -393
  31. package/bin/snow-flow.js +0 -3
  32. package/dist/cli.js.bak +0 -2052
  33. package/dist/config/snow-flow-config.d.ts +0 -1492
  34. package/dist/config/snow-flow-config.js +0 -938
  35. package/scripts/create-env.js +0 -91
  36. package/scripts/postinstall.js +0 -30
  37. package/scripts/register-mcp-servers.js +0 -210
  38. package/scripts/reset-mcp-servers.js +0 -246
  39. package/scripts/setup-mcp.js +0 -106
  40. package/scripts/update-version.js +0 -31
  41. package/src/agents/README.md +0 -192
  42. package/src/agents/base-agent.ts +0 -251
  43. package/src/agents/coordinator.ts +0 -971
  44. package/src/agents/index.ts +0 -18
  45. package/src/agents/queen-403-handler.ts +0 -230
  46. package/src/agents/queen-agent.ts +0 -1399
  47. package/src/agents/script-writer-agent.ts +0 -769
  48. package/src/agents/security-agent.ts +0 -726
  49. package/src/agents/widget-creator-agent.ts +0 -568
  50. package/src/api/error-handling.ts +0 -1758
  51. package/src/api/natural-language-mapper.ts +0 -630
  52. package/src/api/performance-optimizer.ts +0 -891
  53. package/src/api/transaction-manager.ts +0 -754
  54. package/src/cli/deploy-artifact.ts +0 -304
  55. package/src/cli/snow-flow-cli-integration.ts +0 -434
  56. package/src/cli.ts +0 -4455
  57. package/src/cli.ts.bak +0 -5616
  58. package/src/compliance/advanced-compliance-system.ts +0 -1268
  59. package/src/compliance/index.ts +0 -19
  60. package/src/config/snow-flow-config.ts +0 -1019
  61. package/src/documentation/index.ts +0 -16
  62. package/src/documentation/self-documenting-system.ts +0 -1421
  63. package/src/dynamic-version.ts +0 -44
  64. package/src/healing/index.ts +0 -20
  65. package/src/healing/self-healing-system.ts +0 -1435
  66. package/src/health/README.md +0 -161
  67. package/src/health/system-health.ts +0 -995
  68. package/src/index.ts +0 -60
  69. package/src/intelligence/acl-analyzer.ts +0 -377
  70. package/src/intelligence/auto-resolution-engine.ts +0 -643
  71. package/src/intelligence/gap-analysis-engine.ts +0 -488
  72. package/src/intelligence/manual-instructions-generator.ts +0 -744
  73. package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
  74. package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
  75. package/src/intelligence/performance-recommendations-engine.ts +0 -1223
  76. package/src/intelligence/requirements-analyzer.ts +0 -1148
  77. package/src/intelligence/task-analyzer.ts +0 -628
  78. package/src/managers/scope-manager.ts +0 -555
  79. package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
  80. package/src/mcp/base-mcp-server.ts +0 -660
  81. package/src/mcp/http-transport-wrapper.ts +0 -426
  82. package/src/mcp/service-discovery-client.ts +0 -312
  83. package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
  84. package/src/mcp/servicenow-automation-mcp.ts +0 -838
  85. package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
  86. package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
  87. package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
  88. package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
  89. package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
  90. package/src/mcp/servicenow-integration-mcp.ts +0 -819
  91. package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
  92. package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
  93. package/src/mcp/servicenow-mcp-server.ts +0 -728
  94. package/src/mcp/servicenow-memory-mcp.ts +0 -474
  95. package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
  96. package/src/mcp/servicenow-operations-mcp.ts +0 -3384
  97. package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
  98. package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
  99. package/src/mcp/servicenow-progressive-indexer.ts +0 -370
  100. package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
  101. package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
  102. package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
  103. package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
  104. package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
  105. package/src/mcp/servicenow-update-set-mcp.ts +0 -811
  106. package/src/mcp/shared/agent-context-provider.ts +0 -365
  107. package/src/mcp/shared/base-mcp-server.ts +0 -2463
  108. package/src/mcp/shared/mcp-memory-manager.ts +0 -540
  109. package/src/mcp/shared/mcp-resource-manager.ts +0 -367
  110. package/src/mcp/snow-flow-mcp.ts +0 -911
  111. package/src/mcp/start-all-mcp-servers.ts +0 -102
  112. package/src/mcp/start-servicenow-mcp.ts +0 -67
  113. package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
  114. package/src/monitoring/performance-tracker.ts +0 -777
  115. package/src/optimization/cost-optimization-engine.ts +0 -1125
  116. package/src/optimization/index.ts +0 -10
  117. package/src/queen/README.md +0 -403
  118. package/src/queen/agent-factory.ts +0 -574
  119. package/src/queen/index.ts +0 -94
  120. package/src/queen/mcp-execution-bridge.ts +0 -681
  121. package/src/queen/neural-learning.ts +0 -319
  122. package/src/queen/parallel-agent-engine.ts +0 -848
  123. package/src/queen/queen-memory-system.ts +0 -490
  124. package/src/queen/queen-memory.ts +0 -456
  125. package/src/queen/servicenow-queen.ts +0 -1029
  126. package/src/queen/types.ts +0 -87
  127. package/src/rollback/smart-rollback-system.ts +0 -866
  128. package/src/schemas/deployment.schema.json +0 -58
  129. package/src/schemas/flow.schema.json +0 -79
  130. package/src/schemas/widget.schema.json +0 -72
  131. package/src/snow-flow-system.ts +0 -541
  132. package/src/sparc/sparc-help.ts +0 -49
  133. package/src/sparc/team-sparc.ts +0 -88
  134. package/src/strategies/global-scope-strategy.ts +0 -736
  135. package/src/templates/base/application.template.json +0 -45
  136. package/src/templates/base/business_rule.template.json +0 -33
  137. package/src/templates/base/script_include.template.json +0 -18
  138. package/src/templates/base/table.template.json +0 -64
  139. package/src/templates/base/widget.template.json +0 -25
  140. package/src/templates/patterns/composite.incident-management.template.json +0 -140
  141. package/src/templates/patterns/widget.dashboard.template.json +0 -238
  142. package/src/templates/patterns/widget.datatable.template.json +0 -292
  143. package/src/testing/integration-test-suite.ts +0 -1276
  144. package/src/types/index.ts +0 -183
  145. package/src/types/neo4j-driver.d.ts +0 -23
  146. package/src/types/servicenow.types.ts +0 -307
  147. package/src/types/snow-flow.types.ts +0 -186
  148. package/src/types/todo.types.ts +0 -70
  149. package/src/utils/action-type-cache.ts +0 -286
  150. package/src/utils/agent-detector.ts +0 -573
  151. package/src/utils/artifact-tracker.ts +0 -379
  152. package/src/utils/dependency-detector.ts +0 -233
  153. package/src/utils/deployment-metadata-handler.ts +0 -518
  154. package/src/utils/error-recovery.ts +0 -680
  155. package/src/utils/logger.ts +0 -60
  156. package/src/utils/mcp-auth-middleware.ts +0 -262
  157. package/src/utils/mcp-config-manager.ts +0 -270
  158. package/src/utils/mcp-server-manager.ts +0 -446
  159. package/src/utils/mcp-tool-registry.ts +0 -298
  160. package/src/utils/migrate-snow-flow.ts +0 -98
  161. package/src/utils/oauth-html-templates.ts +0 -188
  162. package/src/utils/scope-utils.ts +0 -443
  163. package/src/utils/servicenow-client.ts +0 -3321
  164. package/src/utils/servicenow-id-generator.ts +0 -181
  165. package/src/utils/snow-memory-manager.ts +0 -605
  166. package/src/utils/snow-oauth.ts +0 -797
  167. package/src/utils/template-engine.ts +0 -463
  168. package/src/utils/theme-manager.ts +0 -295
  169. package/src/utils/unified-auth-store.ts +0 -222
  170. package/src/utils/update-set-importer.ts +0 -422
  171. package/src/utils/update-set-xml-packager.ts +0 -371
  172. package/src/utils/widget-template-generator.ts +0 -1744
  173. package/src/version.ts +0 -1950
@@ -1,490 +0,0 @@
1
- /**
2
- * Queen Memory System with Hierarchical Patterns
3
- * Enhanced memory system for ServiceNow Queen Agent coordination
4
- */
5
-
6
- import { HierarchicalMemorySystem, HierarchicalMemoryEntry, MemorySearchOptions } from '../memory/hierarchical-memory-system';
7
- import { SnowFlowMemoryOrganizer, SNOW_FLOW_AGENT_CAPABILITIES } from '../memory/snow-flow-memory-patterns';
8
- import { Logger } from '../utils/logger';
9
- import { EventEmitter } from 'events';
10
-
11
- export interface QueenMemoryPattern {
12
- // Objective tracking
13
- 'objectives/[id]/definition': 'Store objective details and requirements';
14
- 'objectives/[id]/_analysis': 'Task _analysis and breakdown';
15
- 'objectives/[id]/status': 'Current status and progress';
16
-
17
- // Agent coordination
18
- 'agents/[id]/profile': 'Agent capabilities and status';
19
- 'agents/[id]/tasks': 'Assigned tasks and progress';
20
- 'agents/[id]/results': 'Task completion results';
21
-
22
- // ServiceNow artifacts
23
- 'artifacts/widgets/[name]': 'Service Portal widgets';
24
- 'artifacts/flows/[name]': 'Flow Designer flows';
25
- 'artifacts/scripts/[name]': 'Scripts and includes';
26
- 'artifacts/deployments/[id]': 'Deployment results';
27
-
28
- // Learning patterns
29
- 'patterns/successful/[type]': 'Successful patterns for reuse';
30
- 'patterns/failures/[type]': 'Failure patterns to avoid';
31
- 'patterns/optimizations/[type]': 'Performance optimizations';
32
-
33
- // Swarm coordination
34
- 'swarm/[id]/topology': 'Swarm structure and relationships';
35
- 'swarm/[id]/communication': 'Inter-agent messages';
36
- 'swarm/[id]/consensus': 'Decision points and outcomes';
37
- }
38
-
39
- export class QueenMemorySystem extends EventEmitter {
40
- private memory: HierarchicalMemorySystem;
41
- private logger: Logger;
42
- private objectiveCache: Map<string, any> = new Map();
43
- private agentIndex: Map<string, Set<string>> = new Map(); // agentId -> memory keys
44
-
45
- constructor(memory: HierarchicalMemorySystem) {
46
- super();
47
- this.memory = memory;
48
- this.logger = new Logger('QueenMemorySystem');
49
- }
50
-
51
- /**
52
- * Store objective with full context
53
- */
54
- async storeObjective(objectiveId: string, objective: {
55
- description: string;
56
- requirements?: string[];
57
- constraints?: string[];
58
- expectedOutcome?: string;
59
- priority?: 'low' | 'medium' | 'high' | 'critical';
60
- }): Promise<void> {
61
- const key = `objectives/${objectiveId}/definition`;
62
-
63
- await this.memory.storeHierarchical({
64
- key,
65
- namespace: 'objectives',
66
- type: 'definition',
67
- value: objective,
68
- metadata: {
69
- tags: ['objective', 'requirement', objective.priority || 'medium'],
70
- created: new Date().toISOString(),
71
- updated: new Date().toISOString(),
72
- version: 1
73
- },
74
- ttl: 86400000 * 30, // 30 days
75
- });
76
-
77
- this.objectiveCache.set(objectiveId, objective);
78
- this.emit('objective:stored', { objectiveId, objective });
79
- }
80
-
81
- /**
82
- * Store task _analysis with patterns
83
- */
84
- async storeTaskAnalysis(objectiveId: string, _analysis: {
85
- taskType: string;
86
- requiredCapabilities: string[];
87
- suggestedAgents: string[];
88
- estimatedComplexity: number;
89
- dependencies?: string[];
90
- similarPatterns?: string[];
91
- }): Promise<void> {
92
- const key = `objectives/${objectiveId}/_analysis`;
93
-
94
- await this.memory.storeHierarchical({
95
- key,
96
- namespace: 'objectives',
97
- type: '_analysis',
98
- value: _analysis,
99
- metadata: {
100
- tags: ['_analysis', _analysis.taskType, 'complexity-' + _analysis.estimatedComplexity],
101
- created: new Date().toISOString(),
102
- updated: new Date().toISOString(),
103
- version: 1,
104
- relationships: {
105
- requires: _analysis.dependencies || [],
106
- similar: _analysis.similarPatterns || [],
107
- },
108
- },
109
- });
110
-
111
- // Track patterns for learning
112
- if (_analysis.similarPatterns && _analysis.similarPatterns.length > 0) {
113
- await this.memory.trackAccessPattern('pattern_reuse', {
114
- objectiveId,
115
- patterns: _analysis.similarPatterns,
116
- });
117
- }
118
- }
119
-
120
- /**
121
- * Store agent profile with capabilities
122
- */
123
- async storeAgentProfile(agentId: string, profile: {
124
- type: string;
125
- capabilities: string[];
126
- status: 'idle' | 'working' | 'completed' | 'failed';
127
- performance?: {
128
- tasksCompleted: number;
129
- successRate: number;
130
- avgExecutionTime: number;
131
- };
132
- }): Promise<void> {
133
- const key = `agents/${agentId}/profile`;
134
-
135
- await this.memory.storeHierarchical({
136
- key,
137
- namespace: 'agents',
138
- type: 'profile',
139
- value: profile,
140
- metadata: {
141
- tags: ['agent', profile.type, profile.status, ...profile.capabilities],
142
- created: new Date().toISOString(),
143
- updated: new Date().toISOString(),
144
- version: 1
145
- },
146
- });
147
-
148
- // Update agent index
149
- if (!this.agentIndex.has(agentId)) {
150
- this.agentIndex.set(agentId, new Set());
151
- }
152
- this.agentIndex.get(agentId)!.add(key);
153
- }
154
-
155
- /**
156
- * Store agent task assignment
157
- */
158
- async storeAgentTask(agentId: string, taskId: string, task: {
159
- objective: string;
160
- action: string;
161
- priority: number;
162
- dependencies?: string[];
163
- deadline?: Date;
164
- }): Promise<void> {
165
- const key = `agents/${agentId}/tasks/${taskId}`;
166
-
167
- await this.memory.storeHierarchical({
168
- key,
169
- namespace: 'agents',
170
- type: 'task',
171
- value: task,
172
- metadata: {
173
- tags: ['task', 'agent-task', `priority-${task.priority}`],
174
- created: new Date().toISOString(),
175
- updated: new Date().toISOString(),
176
- version: 1,
177
- relationships: {
178
- assignedTo: [agentId],
179
- dependsOn: task.dependencies || [],
180
- },
181
- },
182
- });
183
-
184
- // Create relationship
185
- await this.memory.createRelationship(
186
- `agents/${agentId}/profile`,
187
- key,
188
- 'assigned_task',
189
- { assignedAt: new Date().toISOString() }
190
- );
191
-
192
- this.agentIndex.get(agentId)?.add(key);
193
- }
194
-
195
- /**
196
- * Store ServiceNow artifact with full metadata
197
- */
198
- async storeArtifact(artifact: {
199
- type: 'widget' | 'flow' | 'script' | 'table' | 'application';
200
- name: string;
201
- sysId?: string;
202
- content: any;
203
- dependencies?: string[];
204
- deployment?: {
205
- instance: string;
206
- updateSet?: string;
207
- deployedAt: Date;
208
- };
209
- }): Promise<void> {
210
- const key = `artifacts/${artifact.type}s/${artifact.name}`;
211
- const memoryStructure = this.getArtifactMemoryStructure(artifact);
212
-
213
- await this.memory.storeHierarchical({
214
- key,
215
- namespace: 'artifacts',
216
- type: artifact.type,
217
- value: {
218
- ...artifact,
219
- memoryMetadata: memoryStructure,
220
- },
221
- metadata: {
222
- tags: ['artifact', artifact.type, 'servicenow'],
223
- created: new Date().toISOString(),
224
- updated: new Date().toISOString(),
225
- version: 1,
226
- relationships: {
227
- dependsOn: artifact.dependencies || [],
228
- deployedTo: artifact.deployment ? [artifact.deployment.instance] : [],
229
- },
230
- },
231
- });
232
-
233
- // Store deployment info separately if exists
234
- if (artifact.deployment) {
235
- await this.storeDeployment(artifact.name, { ...artifact.deployment, status: 'success' as const });
236
- }
237
- }
238
-
239
- /**
240
- * Store deployment information
241
- */
242
- async storeDeployment(artifactName: string, deployment: {
243
- instance: string;
244
- updateSet?: string;
245
- deployedAt: Date;
246
- status: 'success' | 'failed' | 'pending';
247
- errors?: string[];
248
- }): Promise<void> {
249
- const deploymentId = `${artifactName}_${deployment.instance}_${Date.now()}`;
250
- const key = `artifacts/deployments/${deploymentId}`;
251
-
252
- await this.memory.storeHierarchical({
253
- key,
254
- namespace: 'artifacts',
255
- type: 'deployment',
256
- value: deployment,
257
- metadata: {
258
- tags: ['deployment', deployment.status, deployment.instance],
259
- created: new Date().toISOString(),
260
- updated: new Date().toISOString(),
261
- version: 1
262
- },
263
- });
264
- }
265
-
266
- /**
267
- * Store successful pattern for learning
268
- */
269
- async storeSuccessfulPattern(pattern: {
270
- type: string;
271
- objective: string;
272
- approach: string;
273
- agents: string[];
274
- duration: number;
275
- outcome: any;
276
- }): Promise<void> {
277
- const key = `patterns/successful/${pattern.type}/${Date.now()}`;
278
-
279
- await this.memory.storeHierarchical({
280
- key,
281
- namespace: 'patterns',
282
- type: 'successful',
283
- value: pattern,
284
- metadata: {
285
- tags: ['pattern', 'success', pattern.type],
286
- created: new Date().toISOString(),
287
- updated: new Date().toISOString(),
288
- version: 1
289
- },
290
- ttl: 86400000 * 90, // 90 days
291
- });
292
-
293
- this.emit('pattern:learned', { type: 'success', pattern });
294
- }
295
-
296
- /**
297
- * Store failure pattern for avoidance
298
- */
299
- async storeFailurePattern(pattern: {
300
- type: string;
301
- objective: string;
302
- approach: string;
303
- failureReason: string;
304
- lessons: string[];
305
- }): Promise<void> {
306
- const key = `patterns/failures/${pattern.type}/${Date.now()}`;
307
-
308
- await this.memory.storeHierarchical({
309
- key,
310
- namespace: 'patterns',
311
- type: 'failure',
312
- value: pattern,
313
- metadata: {
314
- tags: ['pattern', 'failure', pattern.type],
315
- created: new Date().toISOString(),
316
- updated: new Date().toISOString(),
317
- version: 1
318
- },
319
- ttl: 86400000 * 90, // 90 days
320
- });
321
-
322
- this.emit('pattern:learned', { type: 'failure', pattern });
323
- }
324
-
325
- /**
326
- * Find similar objectives from history
327
- */
328
- async findSimilarObjectives(objective: string, limit: number = 5): Promise<any[]> {
329
- // Search by objective keywords
330
- const keywords = objective.toLowerCase().split(' ')
331
- .filter(word => word.length > 3);
332
-
333
- const results = await this.memory.search({
334
- namespace: 'objectives',
335
- type: 'definition',
336
- limit: limit * 2, // Get more to filter
337
- });
338
-
339
- // Score by keyword matches
340
- const scored = results.map(entry => {
341
- const desc = (entry.value.description || '').toLowerCase();
342
- const score = keywords.reduce((sum, keyword) =>
343
- sum + (desc.includes(keyword) ? 1 : 0), 0
344
- );
345
- return { entry, score };
346
- });
347
-
348
- // Return top matches
349
- return scored
350
- .filter(item => item.score > 0)
351
- .sort((a, b) => b.score - a.score)
352
- .slice(0, limit)
353
- .map(item => item.entry);
354
- }
355
-
356
- /**
357
- * Get successful patterns for a task type
358
- */
359
- async getSuccessfulPatterns(taskType: string): Promise<any[]> {
360
- return await this.memory.search({
361
- namespace: 'patterns',
362
- type: 'successful',
363
- tags: [taskType],
364
- limit: 10,
365
- });
366
- }
367
-
368
- /**
369
- * Get agent's complete memory
370
- */
371
- async getAgentMemory(agentId: string): Promise<HierarchicalMemoryEntry[]> {
372
- return await this.memory.getAgentMemory(agentId);
373
- }
374
-
375
- /**
376
- * Get swarm coordination data
377
- */
378
- async getSwarmData(swarmId: string): Promise<{
379
- topology: any;
380
- communication: any[];
381
- consensus: any[];
382
- }> {
383
- const [topology, communication, consensus] = await Promise.all([
384
- this.memory.getHierarchical(`swarm/${swarmId}/topology`),
385
- this.memory.search({
386
- namespace: 'swarm',
387
- pattern: `${swarmId}/communication`,
388
- }),
389
- this.memory.search({
390
- namespace: 'swarm',
391
- pattern: `${swarmId}/consensus`,
392
- }),
393
- ]);
394
-
395
- return {
396
- topology: topology?.value || null,
397
- communication: communication.map(c => c.value),
398
- consensus: consensus.map(c => c.value),
399
- };
400
- }
401
-
402
- /**
403
- * Store inter-agent communication
404
- */
405
- async storeAgentCommunication(
406
- fromAgent: string,
407
- toAgent: string,
408
- message: any,
409
- swarmId?: string
410
- ): Promise<void> {
411
- const key = swarmId
412
- ? `swarm/${swarmId}/communication/${Date.now()}`
413
- : `agents/communication/${fromAgent}_to_${toAgent}_${Date.now()}`;
414
-
415
- await this.memory.storeHierarchical({
416
- key,
417
- namespace: swarmId ? 'swarm' : 'agents',
418
- type: 'communication',
419
- value: {
420
- from: fromAgent,
421
- to: toAgent,
422
- message,
423
- timestamp: new Date().toISOString(),
424
- },
425
- metadata: {
426
- tags: ['communication', 'agent-message'],
427
- created: new Date().toISOString(),
428
- updated: new Date().toISOString(),
429
- version: 1,
430
- relationships: {
431
- from: [fromAgent],
432
- to: [toAgent],
433
- },
434
- },
435
- });
436
- }
437
-
438
- /**
439
- * Get namespace statistics for monitoring
440
- */
441
- async getMemoryStats(): Promise<{
442
- namespaces: Record<string, number>;
443
- totalEntries: number;
444
- patterns: number;
445
- artifacts: number;
446
- agents: number;
447
- }> {
448
- const namespaces = await this.memory.getNamespaceStats();
449
-
450
- return {
451
- namespaces,
452
- totalEntries: Object.values(namespaces).reduce((sum, count) => sum + count, 0),
453
- patterns: namespaces['patterns'] || 0,
454
- artifacts: namespaces['artifacts'] || 0,
455
- agents: namespaces['agents'] || 0,
456
- };
457
- }
458
-
459
- /**
460
- * Helper to get artifact memory structure
461
- */
462
- private getArtifactMemoryStructure(artifact: any): any {
463
- switch (artifact.type) {
464
- case 'widget':
465
- return SnowFlowMemoryOrganizer.getWidgetMemoryStructure(artifact.name);
466
- case 'flow':
467
- return SnowFlowMemoryOrganizer.getFlowMemoryStructure(artifact.name);
468
- case 'script':
469
- return SnowFlowMemoryOrganizer.getScriptMemoryStructure(
470
- artifact.name,
471
- artifact.scriptType || 'server'
472
- );
473
- default:
474
- return {
475
- key: SnowFlowMemoryOrganizer.generateKey('artifacts', artifact.type, artifact.name),
476
- metadata: {
477
- type: artifact.type,
478
- created: new Date().toISOString(),
479
- },
480
- };
481
- }
482
- }
483
-
484
- /**
485
- * Clean up expired entries
486
- */
487
- async cleanup(): Promise<number> {
488
- return await this.memory.cleanupExpired();
489
- }
490
- }