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,31 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Update version.ts with the current version from package.json
5
- * This script runs automatically after npm version
6
- */
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
-
11
- // Read package.json
12
- const packageJsonPath = path.join(__dirname, '..', 'package.json');
13
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
14
- const version = packageJson.version;
15
-
16
- // Path to version.ts
17
- const versionTsPath = path.join(__dirname, '..', 'src', 'version.ts');
18
-
19
- // Read current version.ts content
20
- const versionTsContent = fs.readFileSync(versionTsPath, 'utf8');
21
-
22
- // Replace the VERSION constant
23
- const updatedContent = versionTsContent.replace(
24
- /export const VERSION = '[^']+';/,
25
- `export const VERSION = '${version}';`
26
- );
27
-
28
- // Write updated content back
29
- fs.writeFileSync(versionTsPath, updatedContent, 'utf8');
30
-
31
- console.log(`โœ… Updated version.ts to ${version}`);
@@ -1,192 +0,0 @@
1
- # ServiceNow Specialist Agents
2
-
3
- This directory contains the implementation of ServiceNow specialist agents that work together through Claude Code to build, deploy, and maintain ServiceNow solutions.
4
-
5
- ## โš ๏ธ IMPORTANT: Flow Builder Agent Removed in v1.4.0 โš ๏ธ
6
-
7
- **Note**: The Flow Builder Agent and all flow-related functionality have been removed in v1.4.0 due to critical bugs. The agent file may still exist but is no longer functional. Please use ServiceNow's native Flow Designer interface directly for flow creation.
8
-
9
- ## ๐Ÿค– Available Agents
10
-
11
- ### 1. Widget Creator Agent (`widget-creator-agent.ts`)
12
- Specializes in creating ServiceNow Service Portal widgets.
13
-
14
- **Capabilities:**
15
- - HTML template creation
16
- - CSS styling and responsive design
17
- - Client-side JavaScript development
18
- - Server-side data processing
19
- - Chart.js integration
20
- - Demo data generation
21
-
22
- **MCP Tools Used:**
23
- - `snow_deploy` - Deploy widgets to ServiceNow
24
- - `snow_preview_widget` - Preview widget rendering
25
- - `snow_widget_test` - Test widget functionality
26
-
27
- ### 2. Flow Builder Agent (`flow-builder-agent.ts`)
28
- Specializes in creating ServiceNow Flow Designer workflows.
29
-
30
- **Capabilities:**
31
- - Business process design
32
- - Flow trigger configuration
33
- - Approval workflow creation
34
- - Integration flow building
35
- - Error handling design
36
-
37
- **MCP Tools Used:**
38
- - `snow_create_flow` - Create flows from natural language
39
- - `snow_test_flow_with_mock` - Test flows with mock data
40
- - `snow_link_catalog_to_flow` - Link flows to catalog items
41
-
42
- ### 3. Script Writer Agent (`script-writer-agent.ts`)
43
- Specializes in creating ServiceNow scripts.
44
-
45
- **Capabilities:**
46
- - Business rule creation
47
- - Script include development
48
- - Client script implementation
49
- - Scheduled job scripts
50
- - Performance optimization
51
-
52
- **MCP Tools Used:**
53
- - `snow_create_script_include` - Create script includes
54
- - `snow_create_business_rule` - Create business rules
55
- - `snow_create_client_script` - Create client scripts
56
-
57
- ### 4. Test Agent (`test-agent.ts`)
58
- Specializes in testing ServiceNow artifacts.
59
-
60
- **Capabilities:**
61
- - Test scenario creation
62
- - Mock data generation
63
- - Integration testing
64
- - Performance validation
65
- - Quality assurance
66
-
67
- **MCP Tools Used:**
68
- - `snow_test_flow_with_mock` - Test flows
69
- - `snow_widget_test` - Test widgets
70
- - `snow_comprehensive_flow_test` - Comprehensive testing
71
- - `snow_cleanup_test_artifacts` - Clean up test data
72
-
73
- ### 5. Security Agent (`security-agent.ts`)
74
- Specializes in ServiceNow security and compliance.
75
-
76
- **Capabilities:**
77
- - Security policy enforcement
78
- - Vulnerability scanning
79
- - Access control validation
80
- - Compliance checking (SOX, GDPR, HIPAA)
81
- - Security best practices
82
-
83
- **MCP Tools Used:**
84
- - `snow_create_access_control` - Create ACLs
85
- - `snow_security_scan` - Security scanning
86
- - `snow_run_compliance_scan` - Compliance validation
87
-
88
- ## ๐Ÿ—๏ธ Architecture
89
-
90
- ### Base Agent Class (`base-agent.ts`)
91
- All agents extend the `BaseAgent` class which provides:
92
- - Shared memory integration via SQLite
93
- - Progress reporting to Queen Agent
94
- - Inter-agent communication
95
- - Error handling and logging
96
- - Lifecycle management
97
-
98
- ### Agent Communication Pattern
99
- ```typescript
100
- // Agents communicate through shared memory
101
- await agent.storeArtifact(artifact);
102
- await agent.reportProgress('Task completed', 100);
103
- await agent.sendMessage(otherAgentId, 'coordination', data);
104
- ```
105
-
106
- ### Integration with Queen Agent
107
- The Queen Agent uses `AgentFactory` to spawn these specialized agents:
108
- ```typescript
109
- const agent = await agentFactory.createSpecializedAgent('widget-creator');
110
- const result = await agent.execute(instruction, context);
111
- ```
112
-
113
- ## ๐Ÿš€ Usage Examples
114
-
115
- ### Creating a Widget
116
- ```typescript
117
- const widgetAgent = new WidgetCreatorAgent({ debugMode: true });
118
- const result = await widgetAgent.execute(
119
- 'Create an incident dashboard widget with real-time charts'
120
- );
121
- ```
122
-
123
- ### Building a Flow
124
- ```typescript
125
- const flowAgent = new FlowBuilderAgent({ debugMode: true });
126
- const result = await flowAgent.execute(
127
- 'Create an approval flow for catalog requests with manager approval'
128
- );
129
- ```
130
-
131
- ### Writing a Script
132
- ```typescript
133
- const scriptAgent = new ScriptWriterAgent({ debugMode: true });
134
- const result = await scriptAgent.execute(
135
- 'Create a business rule to calculate incident priority'
136
- );
137
- ```
138
-
139
- ### Testing Artifacts
140
- ```typescript
141
- const testAgent = new TestAgent({ debugMode: true });
142
- const result = await testAgent.execute(
143
- 'Test the incident dashboard widget with comprehensive scenarios'
144
- );
145
- ```
146
-
147
- ### Security Scanning
148
- ```typescript
149
- const securityAgent = new SecurityAgent({ debugMode: true });
150
- const result = await securityAgent.execute(
151
- 'Perform security scan on all recent artifacts'
152
- );
153
- ```
154
-
155
- ## ๐Ÿงช Testing
156
-
157
- Run the agent test suite:
158
- ```bash
159
- npm test src/agents/test-agents.ts
160
- ```
161
-
162
- ## ๐Ÿ“ Best Practices
163
-
164
- 1. **Always use shared memory** for coordination between agents
165
- 2. **Report progress regularly** for long-running tasks
166
- 3. **Handle errors gracefully** and provide meaningful error messages
167
- 4. **Store artifacts** in shared memory for other agents to use
168
- 5. **Clean up resources** when agent tasks complete
169
-
170
- ## ๐Ÿ”„ Agent Lifecycle
171
-
172
- 1. **Initialization**: Agent is created with configuration
173
- 2. **Execution**: Agent performs its specialized task
174
- 3. **Coordination**: Agent communicates with other agents
175
- 4. **Completion**: Agent reports results and stores artifacts
176
- 5. **Cleanup**: Agent releases resources
177
-
178
- ## ๐Ÿ”— MCP Tool Integration
179
-
180
- Each agent knows which MCP tools to recommend for its tasks. The actual MCP tool execution happens through Claude Code, not directly by the agents. Agents provide:
181
- - Tool recommendations
182
- - Parameter preparation
183
- - Result interpretation
184
- - Error handling
185
-
186
- ## ๐ŸŽฏ Future Enhancements
187
-
188
- - [ ] Add more specialized agents (Catalog Manager, Integration Specialist)
189
- - [ ] Implement agent learning from past executions
190
- - [ ] Add performance metrics collection
191
- - [ ] Enhance inter-agent coordination protocols
192
- - [ ] Add agent health monitoring
@@ -1,251 +0,0 @@
1
- /**
2
- * Base Agent Class
3
- * Common functionality for all ServiceNow specialist agents
4
- */
5
-
6
- import { Agent, AgentMessage, ServiceNowArtifact, AgentType } from '../queen/types';
7
- import { QueenMemorySystem } from '../queen/queen-memory';
8
- import * as crypto from 'crypto';
9
-
10
- export interface AgentConfig {
11
- id?: string;
12
- type: AgentType;
13
- capabilities: string[];
14
- mcpTools: string[];
15
- memoryPath?: string;
16
- debugMode?: boolean;
17
- }
18
-
19
- export interface AgentResult {
20
- success: boolean;
21
- artifacts?: ServiceNowArtifact[];
22
- message?: string;
23
- error?: Error;
24
- metadata?: Record<string, any>;
25
- }
26
-
27
- export abstract class BaseAgent implements Agent {
28
- public id: string;
29
- public type: AgentType;
30
- public status: Agent['status'];
31
- public task?: string;
32
- public capabilities: string[];
33
- public mcpTools: string[];
34
-
35
- protected memory: QueenMemorySystem;
36
- protected debugMode: boolean;
37
- protected messageQueue: AgentMessage[] = [];
38
-
39
- constructor(config: AgentConfig) {
40
- this.id = config.id || this.generateAgentId(config.type);
41
- this.type = config.type;
42
- this.status = 'idle';
43
- this.capabilities = config.capabilities;
44
- this.mcpTools = config.mcpTools;
45
- this.debugMode = config.debugMode || false;
46
-
47
- // Initialize memory system
48
- this.memory = new QueenMemorySystem(config.memoryPath);
49
-
50
- if (this.debugMode) {
51
- console.log(`๐Ÿค– ${this.type} agent initialized with ID: ${this.id}`);
52
- }
53
- }
54
-
55
- /**
56
- * Execute the agent's main task
57
- * Must be implemented by each specific agent
58
- */
59
- abstract execute(instruction: string, context?: Record<string, any>): Promise<AgentResult>;
60
-
61
- /**
62
- * Validate agent can handle the task
63
- * Can be overridden by specific agents
64
- */
65
- async canHandle(instruction: string): Promise<boolean> {
66
- // Default implementation checks if instruction mentions agent capabilities
67
- const lowerInstruction = instruction.toLowerCase();
68
- return this.capabilities.some(capability =>
69
- lowerInstruction.includes(capability.toLowerCase().split(' ')[0])
70
- );
71
- }
72
-
73
- /**
74
- * Store artifact in shared memory for other agents
75
- */
76
- protected async storeArtifact(artifact: ServiceNowArtifact): Promise<void> {
77
- const key = `artifact_${artifact.type}_${artifact.name}`;
78
- await this.memory.storeInContext(key, artifact);
79
-
80
- if (this.debugMode) {
81
- console.log(`๐Ÿ“ฆ Stored artifact: ${key}`);
82
- }
83
- }
84
-
85
- /**
86
- * Retrieve artifact from shared memory
87
- */
88
- protected async getArtifact(type: string, name: string): Promise<ServiceNowArtifact | null> {
89
- const key = `artifact_${type}_${name}`;
90
- return await this.memory.getFromContext(key);
91
- }
92
-
93
- /**
94
- * Report progress to Queen Agent
95
- */
96
- protected async reportProgress(message: string, percentage: number): Promise<void> {
97
- const progressKey = `progress_${this.id}`;
98
- await this.memory.storeInContext(progressKey, {
99
- agentId: this.id,
100
- agentType: this.type,
101
- message,
102
- percentage,
103
- timestamp: new Date()
104
- });
105
-
106
- if (this.debugMode) {
107
- console.log(`๐Ÿ“Š ${this.type}: ${message} (${percentage}%)`);
108
- }
109
- }
110
-
111
- /**
112
- * Send message to another agent
113
- */
114
- protected sendMessage(to: string, type: AgentMessage['type'], content: any): void {
115
- const message: AgentMessage = {
116
- from: this.id,
117
- to,
118
- type,
119
- content,
120
- timestamp: new Date()
121
- };
122
-
123
- // Store in shared memory for recipient
124
- const messageKey = `message_${to}_${Date.now()}`;
125
- this.memory.storeInContext(messageKey, message);
126
-
127
- if (this.debugMode) {
128
- console.log(`๐Ÿ“จ Message sent from ${this.id} to ${to}: ${type}`);
129
- }
130
- }
131
-
132
- /**
133
- * Retrieve messages for this agent
134
- */
135
- protected async getMessages(): Promise<AgentMessage[]> {
136
- const _messagePrefix = `message_${this.id}_`;
137
- const messages: AgentMessage[] = [];
138
-
139
- // This is a simplified implementation
140
- // In a real system, we'd query the memory system more efficiently
141
- return messages;
142
- }
143
-
144
- /**
145
- * Handle coordination with other agents
146
- */
147
- protected async coordinateWith(agentType: AgentType, request: any): Promise<any> {
148
- const coordinationKey = `coordination_${this.id}_${agentType}_${Date.now()}`;
149
- await this.memory.storeInContext(coordinationKey, {
150
- from: this.id,
151
- toType: agentType,
152
- request,
153
- timestamp: new Date()
154
- });
155
-
156
- // Wait for response (simplified)
157
- const responseKey = `${coordinationKey}_response`;
158
- let attempts = 0;
159
- while (attempts < 30) { // 30 second timeout
160
- const response = await this.memory.getFromContext(responseKey);
161
- if (response) {
162
- return response;
163
- }
164
- await new Promise(resolve => setTimeout(resolve, 1000));
165
- attempts++;
166
- }
167
-
168
- throw new Error(`Coordination timeout with ${agentType}`);
169
- }
170
-
171
- /**
172
- * Log activity for learning
173
- */
174
- protected async logActivity(action: string, success: boolean, details?: any): Promise<void> {
175
- const learningKey = `agent_activity_${this.type}_${action}`;
176
- await this.memory.storeLearning(learningKey, JSON.stringify({
177
- agentId: this.id,
178
- action,
179
- success,
180
- details,
181
- timestamp: new Date()
182
- }), success ? 0.9 : 0.3);
183
- }
184
-
185
- /**
186
- * Update agent status
187
- */
188
- protected setStatus(status: Agent['status']): void {
189
- this.status = status;
190
- const statusKey = `agent_status_${this.id}`;
191
- this.memory.storeInContext(statusKey, {
192
- agentId: this.id,
193
- status,
194
- timestamp: new Date()
195
- });
196
- }
197
-
198
- /**
199
- * Check if agent should work with another agent
200
- */
201
- protected shouldCoordinate(otherAgentType: AgentType): boolean {
202
- // Define coordination rules
203
- // Simplified coordination rules after flow-builder removal
204
- const coordinationRules: Partial<Record<AgentType, AgentType[]>> = {
205
- 'researcher': ['script-writer', 'researcher'],
206
- 'script-writer': ['tester', 'app-architect'],
207
- 'widget-creator': ['researcher', 'ui-ux-specialist'],
208
- 'app-architect': ['script-writer', 'integration-specialist'],
209
- 'tester': ['script-writer', 'security-specialist'],
210
- 'integration-specialist': ['app-architect', 'script-writer']
211
- };
212
-
213
- return coordinationRules[this.type]?.includes(otherAgentType) || false;
214
- }
215
-
216
- /**
217
- * Generate unique agent ID
218
- */
219
- private generateAgentId(type: AgentType): string {
220
- const timestamp = Date.now().toString(36);
221
- const random = crypto.randomBytes(4).toString('hex');
222
- return `${type}_${timestamp}_${random}`;
223
- }
224
-
225
- /**
226
- * Get agent information
227
- */
228
- getInfo(): Record<string, any> {
229
- return {
230
- id: this.id,
231
- type: this.type,
232
- status: this.status,
233
- capabilities: this.capabilities,
234
- mcpTools: this.mcpTools,
235
- task: this.task
236
- };
237
- }
238
-
239
- /**
240
- * Cleanup agent resources
241
- */
242
- async cleanup(): Promise<void> {
243
- // Clean up any resources
244
- this.messageQueue = [];
245
- this.status = 'idle';
246
-
247
- if (this.debugMode) {
248
- console.log(`๐Ÿงน ${this.type} agent ${this.id} cleaned up`);
249
- }
250
- }
251
- }