snow-flow 3.0.9 → 3.0.10

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 (294) hide show
  1. package/claude-flow.bat +0 -0
  2. package/claude-flow.ps1 +0 -0
  3. package/dist/mcp/servicenow-automation-mcp.js +0 -0
  4. package/dist/mcp/servicenow-deployment-mcp.js +0 -0
  5. package/dist/mcp/servicenow-integration-mcp.js +0 -0
  6. package/dist/mcp/servicenow-mcp-server.js +0 -0
  7. package/dist/mcp/servicenow-operations-mcp.js +0 -0
  8. package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
  9. package/dist/mcp/servicenow-progressive-indexer.js +0 -0
  10. package/dist/mcp/servicenow-reporting-analytics-mcp.js +133 -19
  11. package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
  12. package/dist/mcp/servicenow-update-set-mcp.js +0 -0
  13. package/dist/mcp/start-all-mcp-servers.js +0 -0
  14. package/dist/mcp/start-servicenow-mcp.js +0 -0
  15. package/memory/agents/README.md +1 -1
  16. package/memory/claude-flow-data.json +1 -1
  17. package/memory/sessions/README.md +1 -1
  18. package/package.json +2 -2
  19. package/.mcp.json +0 -22
  20. package/claude-flow.config.json +0 -20
  21. package/dist/agents/app-creator.agent.d.ts +0 -55
  22. package/dist/agents/app-creator.agent.js +0 -1292
  23. package/dist/agents/base/base-snow-agent.d.ts +0 -75
  24. package/dist/agents/base/base-snow-agent.js +0 -169
  25. package/dist/agents/base-snow-agent.d.ts +0 -63
  26. package/dist/agents/base-snow-agent.js +0 -296
  27. package/dist/agents/coordinator.d.ts +0 -200
  28. package/dist/agents/coordinator.js +0 -777
  29. package/dist/agents/flow-builder-agent.d.ts +0 -18
  30. package/dist/agents/flow-builder-agent.js +0 -197
  31. package/dist/agents/queen-403-handler.d.ts +0 -47
  32. package/dist/agents/queen-403-handler.js +0 -175
  33. package/dist/agents/queen-agent-example.d.ts +0 -23
  34. package/dist/agents/queen-agent-example.js +0 -240
  35. package/dist/agents/queen-agent.test.d.ts +0 -6
  36. package/dist/agents/script-generator.agent.d.ts +0 -32
  37. package/dist/agents/script-generator.agent.js +0 -772
  38. package/dist/agents/script-writer-agent.d.ts +0 -22
  39. package/dist/agents/script-writer-agent.js +0 -695
  40. package/dist/agents/security-agent.d.ts +0 -23
  41. package/dist/agents/security-agent.js +0 -619
  42. package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
  43. package/dist/agents/specialists/automation-specialist.agent.js +0 -204
  44. package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
  45. package/dist/agents/specialists/data-specialist.agent.js +0 -484
  46. package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
  47. package/dist/agents/specialists/integration-specialist.agent.js +0 -725
  48. package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
  49. package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
  50. package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
  51. package/dist/agents/specialists/security-specialist.agent.js +0 -309
  52. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
  53. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
  54. package/dist/agents/teams/base-team.d.ts +0 -72
  55. package/dist/agents/teams/base-team.js +0 -253
  56. package/dist/agents/teams/team-types.d.ts +0 -265
  57. package/dist/agents/teams/team-types.js +0 -3
  58. package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
  59. package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
  60. package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
  61. package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
  62. package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
  63. package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
  64. package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
  65. package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
  66. package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
  67. package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
  68. package/dist/agents/test-agent.d.ts +0 -26
  69. package/dist/agents/test-agent.js +0 -734
  70. package/dist/agents/test-agents.d.ts +0 -7
  71. package/dist/agents/test-agents.js +0 -64
  72. package/dist/agents/ui-builder.agent.d.ts +0 -50
  73. package/dist/agents/ui-builder.agent.js +0 -1539
  74. package/dist/agents/widget-builder.agent.d.ts +0 -32
  75. package/dist/agents/widget-builder.agent.js +0 -439
  76. package/dist/agents/widget-creator-agent.d.ts +0 -18
  77. package/dist/agents/widget-creator-agent.js +0 -498
  78. package/dist/agents/workflow-designer.agent.d.ts +0 -31
  79. package/dist/agents/workflow-designer.agent.js +0 -583
  80. package/dist/api/error-handling.d.ts +0 -325
  81. package/dist/api/error-handling.js +0 -1488
  82. package/dist/api/flow-designer-api.d.ts +0 -167
  83. package/dist/api/flow-designer-api.js +0 -554
  84. package/dist/api/natural-language-mapper.d.ts +0 -124
  85. package/dist/api/natural-language-mapper.js +0 -501
  86. package/dist/api/performance-optimizer.d.ts +0 -240
  87. package/dist/api/performance-optimizer.js +0 -706
  88. package/dist/api/transaction-manager.d.ts +0 -189
  89. package/dist/api/transaction-manager.js +0 -576
  90. package/dist/assembly/team-assembler.d.ts +0 -140
  91. package/dist/assembly/team-assembler.js +0 -502
  92. package/dist/benchmark-performance.d.ts +0 -41
  93. package/dist/benchmark-performance.js +0 -230
  94. package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
  95. package/dist/cli/snow-flow-cli-integration.js +0 -396
  96. package/dist/coordination/coordination-engine.d.ts +0 -41
  97. package/dist/coordination/coordination-engine.js +0 -324
  98. package/dist/coordination/coordination.test.d.ts +0 -6
  99. package/dist/coordination/example.d.ts +0 -31
  100. package/dist/coordination/example.js +0 -394
  101. package/dist/coordination/execution-patterns.d.ts +0 -43
  102. package/dist/coordination/execution-patterns.js +0 -507
  103. package/dist/coordination/factory.d.ts +0 -94
  104. package/dist/coordination/factory.js +0 -433
  105. package/dist/coordination/index.d.ts +0 -71
  106. package/dist/coordination/index.js +0 -135
  107. package/dist/coordination/progress-monitor.d.ts +0 -71
  108. package/dist/coordination/progress-monitor.js +0 -505
  109. package/dist/coordination/quality-gates.d.ts +0 -124
  110. package/dist/coordination/quality-gates.js +0 -577
  111. package/dist/coordination/shared-memory.d.ts +0 -39
  112. package/dist/coordination/shared-memory.js +0 -289
  113. package/dist/coordination/task-dependencies.d.ts +0 -50
  114. package/dist/coordination/task-dependencies.js +0 -407
  115. package/dist/coordination/team-coordinator.d.ts +0 -59
  116. package/dist/coordination/team-coordinator.js +0 -550
  117. package/dist/coordination/types.d.ts +0 -152
  118. package/dist/coordination/types.js +0 -3
  119. package/dist/mcp/mcp-wrapper.d.ts +0 -8
  120. package/dist/mcp/mcp-wrapper.js +0 -77
  121. package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
  122. package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
  123. package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
  124. package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
  125. package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
  126. package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
  127. package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
  128. package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
  129. package/dist/mcp/singleton-check.js +0 -31
  130. package/dist/mcp/test-simple-mcp.d.ts +0 -6
  131. package/dist/mcp/test-simple-mcp.js +0 -63
  132. package/dist/memory/hierarchical-memory-system.d.ts +0 -90
  133. package/dist/memory/hierarchical-memory-system.js +0 -400
  134. package/dist/memory/index.d.ts +0 -9
  135. package/dist/memory/index.js +0 -20
  136. package/dist/memory/mcp-integration-example.d.ts +0 -6
  137. package/dist/memory/mcp-integration-example.js +0 -281
  138. package/dist/memory/memory-client.d.ts +0 -199
  139. package/dist/memory/memory-client.js +0 -364
  140. package/dist/memory/memory-manager.d.ts +0 -29
  141. package/dist/memory/memory-manager.js +0 -280
  142. package/dist/memory/memory-operations.d.ts +0 -179
  143. package/dist/memory/memory-operations.js +0 -691
  144. package/dist/memory/memory-system.d.ts +0 -153
  145. package/dist/memory/memory-system.js +0 -651
  146. package/dist/memory/memory-test.d.ts +0 -6
  147. package/dist/memory/memory-test.js +0 -161
  148. package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
  149. package/dist/memory/snow-flow-memory-patterns.js +0 -200
  150. package/dist/memory/snow-memory.d.ts +0 -54
  151. package/dist/memory/snow-memory.js +0 -301
  152. package/dist/memory/swarm-memory.d.ts +0 -135
  153. package/dist/memory/swarm-memory.js +0 -378
  154. package/dist/optimization/flow-performance-optimizer.js +0 -723
  155. package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
  156. package/dist/orchestration/discovery/service-discovery.js +0 -808
  157. package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
  158. package/dist/orchestration/distributed-orchestrator.js +0 -712
  159. package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
  160. package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
  161. package/dist/orchestration/flow-update-orchestrator.js +0 -648
  162. package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
  163. package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
  164. package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
  165. package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
  166. package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
  167. package/dist/orchestration/state/distributed-state-manager.js +0 -716
  168. package/dist/orchestrator/flow-composer.d.ts +0 -105
  169. package/dist/orchestrator/flow-composer.js +0 -404
  170. package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
  171. package/dist/orchestrator/flow-pattern-templates.js +0 -908
  172. package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
  173. package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
  174. package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
  175. package/dist/orchestrator/flow-validation-engine.js +0 -913
  176. package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
  177. package/dist/orchestrator/snow-orchestrator.js +0 -235
  178. package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
  179. package/dist/orchestrator/subflow-creation-handler.js +0 -791
  180. package/dist/patterns/adaptive-patterns.d.ts +0 -140
  181. package/dist/patterns/adaptive-patterns.js +0 -549
  182. package/dist/queen/advanced-integration-test.d.ts +0 -48
  183. package/dist/queen/advanced-integration-test.js +0 -473
  184. package/dist/queen/integration-example.d.ts +0 -82
  185. package/dist/queen/integration-example.js +0 -219
  186. package/dist/queen/integration-test.d.ts +0 -72
  187. package/dist/queen/integration-test.js +0 -563
  188. package/dist/queen/mock-mcp-client.d.ts +0 -71
  189. package/dist/queen/mock-mcp-client.js +0 -317
  190. package/dist/queen/run-integration-tests.d.ts +0 -9
  191. package/dist/queen/run-integration-tests.js +0 -27
  192. package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
  193. package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
  194. package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
  195. package/dist/sparc/coordinators/team-coordinator.js +0 -402
  196. package/dist/sparc/modes/team-modes.d.ts +0 -33
  197. package/dist/sparc/modes/team-modes.js +0 -399
  198. package/dist/sparc/teams/application-team.d.ts +0 -73
  199. package/dist/sparc/teams/application-team.js +0 -463
  200. package/dist/sparc/teams/flow-team.d.ts +0 -67
  201. package/dist/sparc/teams/flow-team.js +0 -373
  202. package/dist/sparc/teams/widget-team.d.ts +0 -61
  203. package/dist/sparc/teams/widget-team.js +0 -280
  204. package/dist/specialists/app-specialists.d.ts +0 -93
  205. package/dist/specialists/app-specialists.js +0 -1639
  206. package/dist/specialists/base-specialist.d.ts +0 -19
  207. package/dist/specialists/base-specialist.js +0 -54
  208. package/dist/specialists/flow-specialists.d.ts +0 -113
  209. package/dist/specialists/flow-specialists.js +0 -1787
  210. package/dist/specialists/individual-specialists.d.ts +0 -67
  211. package/dist/specialists/individual-specialists.js +0 -632
  212. package/dist/specialists/widget-specialists.d.ts +0 -70
  213. package/dist/specialists/widget-specialists.js +0 -1264
  214. package/dist/src/utils/agent-detector.js +0 -655
  215. package/dist/teams/adaptive-team.d.ts +0 -81
  216. package/dist/teams/adaptive-team.js +0 -1153
  217. package/dist/teams/application-team.d.ts +0 -30
  218. package/dist/teams/application-team.js +0 -547
  219. package/dist/teams/base-team.d.ts +0 -55
  220. package/dist/teams/base-team.js +0 -243
  221. package/dist/teams/flow-team.d.ts +0 -28
  222. package/dist/teams/flow-team.js +0 -525
  223. package/dist/teams/widget-team.d.ts +0 -26
  224. package/dist/teams/widget-team.js +0 -459
  225. package/dist/templates/flow-template-system.js +0 -625
  226. package/dist/test-fetch-incidents.d.ts +0 -2
  227. package/dist/test-fetch-incidents.js +0 -84
  228. package/dist/test-incident-access.d.ts +0 -2
  229. package/dist/test-incident-access.js +0 -72
  230. package/dist/test-iphone-flow.js +0 -189
  231. package/dist/test-limit-problem.d.ts +0 -2
  232. package/dist/test-limit-problem.js +0 -60
  233. package/dist/test-ml-batch-fix.d.ts +0 -2
  234. package/dist/test-ml-batch-fix.js +0 -104
  235. package/dist/test-ml-batch.d.ts +0 -2
  236. package/dist/test-ml-batch.js +0 -87
  237. package/dist/test-ml-query.d.ts +0 -2
  238. package/dist/test-ml-query.js +0 -100
  239. package/dist/test-ml-training-fix.d.ts +0 -12
  240. package/dist/test-ml-training-fix.js +0 -113
  241. package/dist/test-ml-training.d.ts +0 -2
  242. package/dist/test-ml-training.js +0 -32
  243. package/dist/test-operations-query.d.ts +0 -2
  244. package/dist/test-operations-query.js +0 -84
  245. package/dist/test-performance-query.d.ts +0 -2
  246. package/dist/test-performance-query.js +0 -52
  247. package/dist/test-singleton-protection.d.ts +0 -8
  248. package/dist/test-singleton-protection.js +0 -110
  249. package/dist/test-smart-limits.d.ts +0 -13
  250. package/dist/test-smart-limits.js +0 -100
  251. package/dist/test-snow-query-incidents.d.ts +0 -2
  252. package/dist/test-snow-query-incidents.js +0 -66
  253. package/dist/test-universal-query.d.ts +0 -2
  254. package/dist/test-universal-query.js +0 -106
  255. package/dist/testing/flow-testing-automation.js +0 -641
  256. package/dist/utils/complete-flow-xml-generator.js +0 -1285
  257. package/dist/utils/file-storage-fallback.d.ts +0 -62
  258. package/dist/utils/file-storage-fallback.js +0 -289
  259. package/dist/utils/flow-api-discovery.d.ts +0 -151
  260. package/dist/utils/flow-api-discovery.js +0 -439
  261. package/dist/utils/flow-examples.js +0 -720
  262. package/dist/utils/flow-structure-builder.js +0 -677
  263. package/dist/utils/flow-xml-generator.d.ts +0 -41
  264. package/dist/utils/flow-xml-generator.js +0 -258
  265. package/dist/utils/improved-flow-xml-generator.js +0 -820
  266. package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
  267. package/dist/utils/mcp-process-manager.backup.js +0 -220
  268. package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
  269. package/dist/utils/mcp-singleton-enforcer.js +0 -201
  270. package/dist/utils/mcp-timeout-fix.d.ts +0 -53
  271. package/dist/utils/mcp-timeout-fix.js +0 -221
  272. package/dist/utils/migrate-claude-flow.d.ts +0 -22
  273. package/dist/utils/migrate-claude-flow.js +0 -120
  274. package/dist/utils/scope-utils.d.ts +0 -72
  275. package/dist/utils/scope-utils.js +0 -386
  276. package/dist/utils/snow-oauth-old.d.ts +0 -65
  277. package/dist/utils/snow-oauth-old.js +0 -345
  278. package/dist/utils/xml-first-flow-generator.js +0 -513
  279. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
  280. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
  281. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
  282. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
  283. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
  284. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
  285. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
  286. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
  287. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
  288. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
  289. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
  290. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
  291. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
  292. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
  293. package/reports/swarm-auto-centralized-1752649029776.json +0 -13
  294. package/src/memory/README.md +0 -240
@@ -1,691 +0,0 @@
1
- "use strict";
2
- /**
3
- * Snow-Flow Memory Operations
4
- * High-level operations for agent coordination and data management
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.MemoryOperations = void 0;
8
- const uuid_1 = require("uuid");
9
- const logger_js_1 = require("../utils/logger.js");
10
- class MemoryOperations {
11
- constructor(memory) {
12
- this.memory = memory;
13
- this.logger = new logger_js_1.Logger('MemoryOperations');
14
- }
15
- // ==================== Agent Coordination Operations ====================
16
- /**
17
- * Register a new agent in the coordination system
18
- */
19
- async registerAgent(session_id, agent_id, agent_type, assigned_tasks = []) {
20
- try {
21
- this.memory.run(`
22
- INSERT OR REPLACE INTO agent_coordination
23
- (session_id, agent_id, agent_type, status, assigned_tasks, progress_percentage, last_activity)
24
- VALUES (?, ?, ?, 'spawned', ?, 0, datetime('now'))
25
- `, [session_id, agent_id, agent_type, JSON.stringify(assigned_tasks)]);
26
- this.logger.info('Agent registered', { session_id, agent_id, agent_type });
27
- }
28
- catch (error) {
29
- this.logger.error('Failed to register agent', error);
30
- throw error;
31
- }
32
- }
33
- /**
34
- * Update agent status and progress
35
- */
36
- async updateAgentStatus(session_id, agent_id, updates) {
37
- const setters = ["last_activity = datetime('now')"];
38
- const params = [];
39
- if (updates.status !== undefined) {
40
- setters.push('status = ?');
41
- params.push(updates.status);
42
- }
43
- if (updates.progress_percentage !== undefined) {
44
- setters.push('progress_percentage = ?');
45
- params.push(updates.progress_percentage);
46
- }
47
- if (updates.current_tool !== undefined) {
48
- setters.push('current_tool = ?');
49
- params.push(updates.current_tool);
50
- }
51
- if (updates.error_state !== undefined) {
52
- setters.push('error_state = ?');
53
- params.push(updates.error_state);
54
- }
55
- if (updates.assigned_tasks !== undefined) {
56
- setters.push('assigned_tasks = ?');
57
- params.push(updates.assigned_tasks);
58
- }
59
- params.push(session_id, agent_id);
60
- try {
61
- this.memory.run(`
62
- UPDATE agent_coordination
63
- SET ${setters.join(', ')}
64
- WHERE session_id = ? AND agent_id = ?
65
- `, params);
66
- this.logger.debug('Agent status updated', { session_id, agent_id, updates });
67
- }
68
- catch (error) {
69
- this.logger.error('Failed to update agent status', error);
70
- throw error;
71
- }
72
- }
73
- /**
74
- * Get all active agents for a session
75
- */
76
- async getActiveAgents(session_id) {
77
- return this.memory.all(`
78
- SELECT * FROM agent_coordination
79
- WHERE session_id = ? AND status IN ('spawned', 'active', 'blocked')
80
- ORDER BY last_activity DESC
81
- `, [session_id]);
82
- }
83
- /**
84
- * Get agent coordination status
85
- */
86
- async getAgentStatus(session_id, agent_id) {
87
- return this.memory.get(`
88
- SELECT * FROM agent_coordination
89
- WHERE session_id = ? AND agent_id = ?
90
- `, [session_id, agent_id]);
91
- }
92
- // ==================== ServiceNow Artifact Operations ====================
93
- /**
94
- * Store a ServiceNow artifact
95
- */
96
- async storeArtifact(artifact) {
97
- try {
98
- this.memory.run(`
99
- INSERT OR REPLACE INTO servicenow_artifacts
100
- (sys_id, artifact_type, name, description, created_by_agent, session_id,
101
- deployment_status, update_set_id, dependencies, metadata)
102
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
103
- `, [
104
- artifact.sys_id,
105
- artifact.artifact_type,
106
- artifact.name,
107
- artifact.description || null,
108
- artifact.created_by_agent,
109
- artifact.session_id,
110
- artifact.deployment_status,
111
- artifact.update_set_id || null,
112
- artifact.dependencies || null,
113
- artifact.metadata || null
114
- ]);
115
- this.logger.info('Artifact stored', {
116
- sys_id: artifact.sys_id,
117
- type: artifact.artifact_type,
118
- name: artifact.name
119
- });
120
- }
121
- catch (error) {
122
- this.logger.error('Failed to store artifact', error);
123
- throw error;
124
- }
125
- }
126
- /**
127
- * Update artifact deployment status
128
- */
129
- async updateArtifactStatus(sys_id, deployment_status) {
130
- try {
131
- this.memory.run(`
132
- UPDATE servicenow_artifacts
133
- SET deployment_status = ?, updated_at = datetime('now')
134
- WHERE sys_id = ?
135
- `, [deployment_status, sys_id]);
136
- this.logger.debug('Artifact status updated', { sys_id, deployment_status });
137
- }
138
- catch (error) {
139
- this.logger.error('Failed to update artifact status', error);
140
- throw error;
141
- }
142
- }
143
- /**
144
- * Search for artifacts
145
- */
146
- async searchArtifacts(options = {}) {
147
- const conditions = [];
148
- const params = [];
149
- if (options.session_id) {
150
- conditions.push('session_id = ?');
151
- params.push(options.session_id);
152
- }
153
- if (options.artifact_type) {
154
- conditions.push('artifact_type = ?');
155
- params.push(options.artifact_type);
156
- }
157
- if (options.deployment_status) {
158
- conditions.push('deployment_status = ?');
159
- params.push(options.deployment_status);
160
- }
161
- if (options.created_by_agent) {
162
- conditions.push('created_by_agent = ?');
163
- params.push(options.created_by_agent);
164
- }
165
- const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
166
- const limitClause = options.limit ? `LIMIT ${options.limit}` : '';
167
- return this.memory.all(`
168
- SELECT * FROM servicenow_artifacts
169
- ${whereClause}
170
- ORDER BY updated_at DESC
171
- ${limitClause}
172
- `, params);
173
- }
174
- /**
175
- * Get artifact by sys_id
176
- */
177
- async getArtifact(sys_id) {
178
- return this.memory.get(`
179
- SELECT * FROM servicenow_artifacts
180
- WHERE sys_id = ?
181
- `, [sys_id]);
182
- }
183
- // ==================== Agent Message Operations ====================
184
- /**
185
- * Send a message between agents
186
- */
187
- async sendMessage(session_id, from_agent, to_agent, message_type, content, artifact_reference) {
188
- const id = (0, uuid_1.v4)();
189
- try {
190
- this.memory.run(`
191
- INSERT INTO agent_messages
192
- (id, session_id, from_agent, to_agent, message_type, content, artifact_reference, processed)
193
- VALUES (?, ?, ?, ?, ?, ?, ?, 0)
194
- `, [
195
- id,
196
- session_id,
197
- from_agent,
198
- to_agent,
199
- message_type,
200
- typeof content === 'string' ? content : JSON.stringify(content),
201
- artifact_reference || null
202
- ]);
203
- this.logger.debug('Message sent', { id, from_agent, to_agent, message_type });
204
- return id;
205
- }
206
- catch (error) {
207
- this.logger.error('Failed to send message', error);
208
- throw error;
209
- }
210
- }
211
- /**
212
- * Get unprocessed messages for an agent
213
- */
214
- async getUnprocessedMessages(to_agent, session_id) {
215
- const conditions = ['to_agent = ?', 'processed = 0'];
216
- const params = [to_agent];
217
- if (session_id) {
218
- conditions.push('session_id = ?');
219
- params.push(session_id);
220
- }
221
- return this.memory.all(`
222
- SELECT * FROM agent_messages
223
- WHERE ${conditions.join(' AND ')}
224
- ORDER BY timestamp ASC
225
- `, params);
226
- }
227
- /**
228
- * Mark message as processed
229
- */
230
- async markMessageProcessed(message_id) {
231
- try {
232
- this.memory.run(`
233
- UPDATE agent_messages
234
- SET processed = 1
235
- WHERE id = ?
236
- `, [message_id]);
237
- this.logger.debug('Message marked as processed', { message_id });
238
- }
239
- catch (error) {
240
- this.logger.error('Failed to mark message as processed', error);
241
- throw error;
242
- }
243
- }
244
- /**
245
- * Search messages
246
- */
247
- async searchMessages(options = {}) {
248
- const conditions = [];
249
- const params = [];
250
- if (options.session_id) {
251
- conditions.push('session_id = ?');
252
- params.push(options.session_id);
253
- }
254
- if (options.to_agent) {
255
- conditions.push('to_agent = ?');
256
- params.push(options.to_agent);
257
- }
258
- if (options.from_agent) {
259
- conditions.push('from_agent = ?');
260
- params.push(options.from_agent);
261
- }
262
- if (options.message_type) {
263
- conditions.push('message_type = ?');
264
- params.push(options.message_type);
265
- }
266
- if (options.processed !== undefined) {
267
- conditions.push('processed = ?');
268
- params.push(options.processed ? 1 : 0);
269
- }
270
- const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
271
- const limitClause = options.limit ? `LIMIT ${options.limit}` : '';
272
- return this.memory.all(`
273
- SELECT * FROM agent_messages
274
- ${whereClause}
275
- ORDER BY timestamp DESC
276
- ${limitClause}
277
- `, params);
278
- }
279
- // ==================== Shared Context Operations ====================
280
- /**
281
- * Create agent-specific namespaced key for memory isolation
282
- * This prevents agents from overwriting each other's memory within the same session
283
- */
284
- createNamespacedKey(context_key, agent_id) {
285
- // Use a delimiter that's unlikely to conflict with normal keys
286
- return `${agent_id}::${context_key}`;
287
- }
288
- /**
289
- * Parse namespaced key to extract original key and agent ID
290
- */
291
- parseNamespacedKey(namespaced_key) {
292
- const parts = namespaced_key.split('::');
293
- if (parts.length === 2) {
294
- return { agent_id: parts[0], original_key: parts[1] };
295
- }
296
- return { agent_id: null, original_key: namespaced_key };
297
- }
298
- /**
299
- * Store shared context with agent isolation
300
- */
301
- async setContext(session_id, context_key, context_value, created_by_agent, expires_at, access_permissions) {
302
- try {
303
- // CRITICAL FIX: Create agent-specific namespace for the context key
304
- // This ensures agents don't overwrite each other's memory
305
- const namespacedKey = this.createNamespacedKey(context_key, created_by_agent);
306
- this.memory.run(`
307
- INSERT OR REPLACE INTO shared_context
308
- (session_id, context_key, context_value, created_by_agent, expires_at, access_permissions)
309
- VALUES (?, ?, ?, ?, ?, ?)
310
- `, [
311
- session_id,
312
- namespacedKey,
313
- typeof context_value === 'string' ? context_value : JSON.stringify(context_value),
314
- created_by_agent,
315
- expires_at ? expires_at.toISOString() : null,
316
- access_permissions ? JSON.stringify(access_permissions) : null
317
- ]);
318
- this.logger.debug('Context stored with agent isolation', {
319
- session_id,
320
- original_key: context_key,
321
- namespaced_key: namespacedKey,
322
- created_by_agent
323
- });
324
- }
325
- catch (error) {
326
- this.logger.error('Failed to store context', error);
327
- throw error;
328
- }
329
- }
330
- /**
331
- * Get shared context with agent isolation support
332
- */
333
- async getContext(session_id, context_key, requesting_agent) {
334
- // CRITICAL FIX: Try to get agent-specific namespaced key first
335
- let result = null;
336
- if (requesting_agent) {
337
- const namespacedKey = this.createNamespacedKey(context_key, requesting_agent);
338
- result = this.memory.get(`
339
- SELECT * FROM shared_context
340
- WHERE session_id = ? AND context_key = ?
341
- AND (expires_at IS NULL OR expires_at > datetime('now'))
342
- `, [session_id, namespacedKey]);
343
- this.logger.debug('Attempting namespaced context retrieval', {
344
- session_id,
345
- original_key: context_key,
346
- namespaced_key: namespacedKey,
347
- requesting_agent,
348
- found: !!result
349
- });
350
- }
351
- // Fallback: Try to get the original key for backward compatibility or shared data
352
- if (!result) {
353
- result = this.memory.get(`
354
- SELECT * FROM shared_context
355
- WHERE session_id = ? AND context_key = ?
356
- AND (expires_at IS NULL OR expires_at > datetime('now'))
357
- `, [session_id, context_key]);
358
- this.logger.debug('Fallback context retrieval', {
359
- session_id,
360
- context_key,
361
- found: !!result
362
- });
363
- }
364
- if (result) {
365
- try {
366
- // Try to parse JSON values
367
- if (result.context_value && (result.context_value.startsWith('{') || result.context_value.startsWith('['))) {
368
- result.context_value = JSON.parse(result.context_value);
369
- }
370
- if (result.access_permissions) {
371
- result.access_permissions = JSON.parse(result.access_permissions);
372
- }
373
- }
374
- catch (e) {
375
- // If parsing fails, return as-is
376
- this.logger.warn('Failed to parse stored JSON context', { context_key, error: e });
377
- }
378
- }
379
- return result;
380
- }
381
- /**
382
- * Get all context for a session
383
- */
384
- async getSessionContext(session_id) {
385
- const results = this.memory.all(`
386
- SELECT * FROM shared_context
387
- WHERE session_id = ?
388
- AND (expires_at IS NULL OR expires_at > datetime('now'))
389
- ORDER BY updated_at DESC
390
- `, [session_id]);
391
- // Parse JSON values
392
- return results.map(result => {
393
- try {
394
- if (result.context_value && (result.context_value.startsWith('{') || result.context_value.startsWith('['))) {
395
- result.context_value = JSON.parse(result.context_value);
396
- }
397
- if (result.access_permissions) {
398
- result.access_permissions = JSON.parse(result.access_permissions);
399
- }
400
- }
401
- catch (e) {
402
- // If parsing fails, return as-is
403
- }
404
- return result;
405
- });
406
- }
407
- // ==================== Deployment History Operations ====================
408
- /**
409
- * Record deployment event
410
- */
411
- async recordDeployment(session_id, artifact_sys_id, deployment_type, agent_id, success, error_details, rollback_available = false) {
412
- const id = (0, uuid_1.v4)();
413
- try {
414
- this.memory.run(`
415
- INSERT INTO deployment_history
416
- (id, session_id, artifact_sys_id, deployment_type, success, agent_id, error_details, rollback_available)
417
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
418
- `, [
419
- id,
420
- session_id,
421
- artifact_sys_id,
422
- deployment_type,
423
- success ? 1 : 0,
424
- agent_id,
425
- error_details || null,
426
- rollback_available ? 1 : 0
427
- ]);
428
- this.logger.info('Deployment recorded', {
429
- id,
430
- artifact_sys_id,
431
- deployment_type,
432
- success
433
- });
434
- return id;
435
- }
436
- catch (error) {
437
- this.logger.error('Failed to record deployment', error);
438
- throw error;
439
- }
440
- }
441
- /**
442
- * Get deployment history for an artifact
443
- */
444
- async getDeploymentHistory(artifact_sys_id) {
445
- return this.memory.all(`
446
- SELECT * FROM deployment_history
447
- WHERE artifact_sys_id = ?
448
- ORDER BY deployment_time DESC
449
- `, [artifact_sys_id]);
450
- }
451
- /**
452
- * Get latest deployment for an artifact
453
- */
454
- async getLatestDeployment(artifact_sys_id) {
455
- return this.memory.get(`
456
- SELECT * FROM deployment_history
457
- WHERE artifact_sys_id = ?
458
- ORDER BY deployment_time DESC
459
- LIMIT 1
460
- `, [artifact_sys_id]);
461
- }
462
- // ==================== Agent Dependency Operations ====================
463
- /**
464
- * Add agent dependency
465
- */
466
- async addDependency(session_id, agent_id, depends_on_agent, dependency_type, artifact_reference) {
467
- try {
468
- this.memory.run(`
469
- INSERT OR REPLACE INTO agent_dependencies
470
- (session_id, agent_id, depends_on_agent, dependency_type, artifact_reference, status)
471
- VALUES (?, ?, ?, ?, ?, 'pending')
472
- `, [
473
- session_id,
474
- agent_id,
475
- depends_on_agent,
476
- dependency_type,
477
- artifact_reference || null
478
- ]);
479
- this.logger.debug('Dependency added', {
480
- session_id,
481
- agent_id,
482
- depends_on_agent,
483
- dependency_type
484
- });
485
- }
486
- catch (error) {
487
- this.logger.error('Failed to add dependency', error);
488
- throw error;
489
- }
490
- }
491
- /**
492
- * Mark dependency as satisfied
493
- */
494
- async satisfyDependency(session_id, agent_id, depends_on_agent) {
495
- try {
496
- this.memory.run(`
497
- UPDATE agent_dependencies
498
- SET status = 'satisfied', satisfied_at = datetime('now')
499
- WHERE session_id = ? AND agent_id = ? AND depends_on_agent = ?
500
- `, [session_id, agent_id, depends_on_agent]);
501
- this.logger.debug('Dependency satisfied', {
502
- session_id,
503
- agent_id,
504
- depends_on_agent
505
- });
506
- }
507
- catch (error) {
508
- this.logger.error('Failed to satisfy dependency', error);
509
- throw error;
510
- }
511
- }
512
- /**
513
- * Get pending dependencies for an agent
514
- */
515
- async getPendingDependencies(session_id, agent_id) {
516
- return this.memory.all(`
517
- SELECT * FROM agent_dependencies
518
- WHERE session_id = ? AND agent_id = ? AND status = 'pending'
519
- ORDER BY created_at ASC
520
- `, [session_id, agent_id]);
521
- }
522
- /**
523
- * Check if all dependencies are satisfied
524
- */
525
- async checkDependenciesSatisfied(session_id, agent_id) {
526
- const pending = this.memory.get(`
527
- SELECT COUNT(*) as count FROM agent_dependencies
528
- WHERE session_id = ? AND agent_id = ? AND status = 'pending'
529
- `, [session_id, agent_id]);
530
- return pending?.count === 0;
531
- }
532
- // ==================== Performance Metric Operations ====================
533
- /**
534
- * Start performance tracking
535
- */
536
- startPerformanceTracking(session_id, agent_id, operation_name) {
537
- return {
538
- id: (0, uuid_1.v4)(),
539
- startTime: Date.now()
540
- };
541
- }
542
- /**
543
- * Complete performance tracking
544
- */
545
- async completePerformanceTracking(tracking, session_id, agent_id, operation_name, success, error_message, metadata) {
546
- const duration_ms = Date.now() - tracking.startTime;
547
- try {
548
- this.memory.run(`
549
- INSERT INTO performance_metrics
550
- (id, session_id, agent_id, operation_name, duration_ms, success, error_message, metadata)
551
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
552
- `, [
553
- tracking.id,
554
- session_id,
555
- agent_id,
556
- operation_name,
557
- duration_ms,
558
- success ? 1 : 0,
559
- error_message || null,
560
- metadata ? JSON.stringify(metadata) : null
561
- ]);
562
- this.logger.debug('Performance metric recorded', {
563
- id: tracking.id,
564
- operation_name,
565
- duration_ms,
566
- success
567
- });
568
- }
569
- catch (error) {
570
- this.logger.error('Failed to record performance metric', error);
571
- throw error;
572
- }
573
- }
574
- /**
575
- * Query performance metrics
576
- */
577
- async queryPerformanceMetrics(query = {}) {
578
- const conditions = [];
579
- const params = [];
580
- if (query.session_id) {
581
- conditions.push('session_id = ?');
582
- params.push(query.session_id);
583
- }
584
- if (query.agent_id) {
585
- conditions.push('agent_id = ?');
586
- params.push(query.agent_id);
587
- }
588
- if (query.operation_name) {
589
- conditions.push('operation_name = ?');
590
- params.push(query.operation_name);
591
- }
592
- if (query.success !== undefined) {
593
- conditions.push('success = ?');
594
- params.push(query.success ? 1 : 0);
595
- }
596
- if (query.start_time) {
597
- conditions.push('timestamp >= ?');
598
- params.push(query.start_time.toISOString());
599
- }
600
- if (query.end_time) {
601
- conditions.push('timestamp <= ?');
602
- params.push(query.end_time.toISOString());
603
- }
604
- const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
605
- const limitClause = query.limit ? `LIMIT ${query.limit}` : '';
606
- return this.memory.all(`
607
- SELECT * FROM performance_metrics
608
- ${whereClause}
609
- ORDER BY timestamp DESC
610
- ${limitClause}
611
- `, params);
612
- }
613
- /**
614
- * Get average performance for an operation
615
- */
616
- async getAveragePerformance(operation_name, session_id) {
617
- const conditions = ['operation_name = ?'];
618
- const params = [operation_name];
619
- if (session_id) {
620
- conditions.push('session_id = ?');
621
- params.push(session_id);
622
- }
623
- return this.memory.get(`
624
- SELECT
625
- AVG(duration_ms) as avg_duration_ms,
626
- AVG(CASE WHEN success = 1 THEN 1.0 ELSE 0.0 END) as success_rate,
627
- COUNT(*) as total_operations
628
- FROM performance_metrics
629
- WHERE ${conditions.join(' AND ')}
630
- `, params);
631
- }
632
- // ==================== Session Management ====================
633
- /**
634
- * Get complete session state
635
- */
636
- async getSessionState(session_id) {
637
- const agents = await this.getActiveAgents(session_id);
638
- const artifacts = await this.searchArtifacts({ session_id });
639
- const activeContext = await this.getSessionContext(session_id);
640
- const pendingMessages = this.memory.get(`
641
- SELECT COUNT(*) as count FROM agent_messages
642
- WHERE session_id = ? AND processed = 0
643
- `, [session_id])?.count || 0;
644
- const performanceSummary = this.memory.get(`
645
- SELECT
646
- COUNT(*) as total_operations,
647
- AVG(duration_ms) as avg_duration_ms,
648
- MIN(duration_ms) as min_duration_ms,
649
- MAX(duration_ms) as max_duration_ms,
650
- AVG(CASE WHEN success = 1 THEN 1.0 ELSE 0.0 END) as success_rate
651
- FROM performance_metrics
652
- WHERE session_id = ?
653
- `, [session_id]);
654
- return {
655
- agents,
656
- artifacts,
657
- pendingMessages,
658
- activeContext,
659
- performanceSummary
660
- };
661
- }
662
- /**
663
- * Clean up session data
664
- */
665
- async cleanupSession(session_id) {
666
- this.logger.info('Cleaning up session', { session_id });
667
- this.memory.transaction(() => {
668
- // Mark all agents as completed
669
- this.memory.run(`
670
- UPDATE agent_coordination
671
- SET status = 'completed'
672
- WHERE session_id = ? AND status IN ('spawned', 'active', 'blocked')
673
- `, [session_id]);
674
- // Mark all messages as processed
675
- this.memory.run(`
676
- UPDATE agent_messages
677
- SET processed = 1
678
- WHERE session_id = ? AND processed = 0
679
- `, [session_id]);
680
- // Mark all dependencies as satisfied or failed
681
- this.memory.run(`
682
- UPDATE agent_dependencies
683
- SET status = 'failed'
684
- WHERE session_id = ? AND status = 'pending'
685
- `, [session_id]);
686
- });
687
- this.logger.info('Session cleanup completed', { session_id });
688
- }
689
- }
690
- exports.MemoryOperations = MemoryOperations;
691
- //# sourceMappingURL=memory-operations.js.map