snow-flow 2.0.2 โ 2.0.3
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/{.claude/mcp-config.json โ .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/.claude/claude-settings.json +0 -15
- package/.claude/commands/analysis/README.md +0 -9
- package/.claude/commands/automation/README.md +0 -9
- package/.claude/commands/github/README.md +0 -11
- package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
- package/.claude/commands/hooks/README.md +0 -11
- package/.claude/commands/monitoring/README.md +0 -9
- package/.claude/commands/optimization/README.md +0 -9
- package/.claude/commands/training/README.md +0 -9
- package/.claude/commands/workflows/README.md +0 -9
- package/.claude/config.json +0 -36
- package/.claude/helpers/github-setup.sh +0 -28
- package/.claude/helpers/quick-start.sh +0 -19
- package/.claude/helpers/setup-mcp.sh +0 -18
- package/.claude/settings.json +0 -114
- package/.claude/settings.local.json +0 -33
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -9
- package/.claude-flow/metrics/system-metrics.json +0 -15986
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.roo/README.md +0 -402
- package/.roo/mcp-list.txt +0 -257
- package/.roo/mcp.json +0 -32
- package/.roo/workflows/basic-tdd.json +0 -32
- package/.roomodes +0 -201
- package/CLAUDE.md +0 -393
- package/bin/snow-flow.js +0 -3
- package/dist/cli.js.bak +0 -2052
- package/dist/config/snow-flow-config.d.ts +0 -1492
- package/dist/config/snow-flow-config.js +0 -938
- package/scripts/create-env.js +0 -91
- package/scripts/postinstall.js +0 -30
- package/scripts/register-mcp-servers.js +0 -210
- package/scripts/reset-mcp-servers.js +0 -246
- package/scripts/setup-mcp.js +0 -106
- package/scripts/update-version.js +0 -31
- package/src/agents/README.md +0 -192
- package/src/agents/base-agent.ts +0 -251
- package/src/agents/coordinator.ts +0 -971
- package/src/agents/index.ts +0 -18
- package/src/agents/queen-403-handler.ts +0 -230
- package/src/agents/queen-agent.ts +0 -1399
- package/src/agents/script-writer-agent.ts +0 -769
- package/src/agents/security-agent.ts +0 -726
- package/src/agents/widget-creator-agent.ts +0 -568
- package/src/api/error-handling.ts +0 -1758
- package/src/api/natural-language-mapper.ts +0 -630
- package/src/api/performance-optimizer.ts +0 -891
- package/src/api/transaction-manager.ts +0 -754
- package/src/cli/deploy-artifact.ts +0 -304
- package/src/cli/snow-flow-cli-integration.ts +0 -434
- package/src/cli.ts +0 -4455
- package/src/cli.ts.bak +0 -5616
- package/src/compliance/advanced-compliance-system.ts +0 -1268
- package/src/compliance/index.ts +0 -19
- package/src/config/snow-flow-config.ts +0 -1019
- package/src/documentation/index.ts +0 -16
- package/src/documentation/self-documenting-system.ts +0 -1421
- package/src/dynamic-version.ts +0 -44
- package/src/healing/index.ts +0 -20
- package/src/healing/self-healing-system.ts +0 -1435
- package/src/health/README.md +0 -161
- package/src/health/system-health.ts +0 -995
- package/src/index.ts +0 -60
- package/src/intelligence/acl-analyzer.ts +0 -377
- package/src/intelligence/auto-resolution-engine.ts +0 -643
- package/src/intelligence/gap-analysis-engine.ts +0 -488
- package/src/intelligence/manual-instructions-generator.ts +0 -744
- package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
- package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
- package/src/intelligence/performance-recommendations-engine.ts +0 -1223
- package/src/intelligence/requirements-analyzer.ts +0 -1148
- package/src/intelligence/task-analyzer.ts +0 -628
- package/src/managers/scope-manager.ts +0 -555
- package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
- package/src/mcp/base-mcp-server.ts +0 -660
- package/src/mcp/http-transport-wrapper.ts +0 -426
- package/src/mcp/service-discovery-client.ts +0 -312
- package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
- package/src/mcp/servicenow-automation-mcp.ts +0 -838
- package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
- package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
- package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
- package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
- package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
- package/src/mcp/servicenow-integration-mcp.ts +0 -819
- package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
- package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
- package/src/mcp/servicenow-mcp-server.ts +0 -728
- package/src/mcp/servicenow-memory-mcp.ts +0 -474
- package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
- package/src/mcp/servicenow-operations-mcp.ts +0 -3384
- package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
- package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
- package/src/mcp/servicenow-progressive-indexer.ts +0 -370
- package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
- package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
- package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
- package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
- package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
- package/src/mcp/servicenow-update-set-mcp.ts +0 -811
- package/src/mcp/shared/agent-context-provider.ts +0 -365
- package/src/mcp/shared/base-mcp-server.ts +0 -2463
- package/src/mcp/shared/mcp-memory-manager.ts +0 -540
- package/src/mcp/shared/mcp-resource-manager.ts +0 -367
- package/src/mcp/snow-flow-mcp.ts +0 -911
- package/src/mcp/start-all-mcp-servers.ts +0 -102
- package/src/mcp/start-servicenow-mcp.ts +0 -67
- package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
- package/src/monitoring/performance-tracker.ts +0 -777
- package/src/optimization/cost-optimization-engine.ts +0 -1125
- package/src/optimization/index.ts +0 -10
- package/src/queen/README.md +0 -403
- package/src/queen/agent-factory.ts +0 -574
- package/src/queen/index.ts +0 -94
- package/src/queen/mcp-execution-bridge.ts +0 -681
- package/src/queen/neural-learning.ts +0 -319
- package/src/queen/parallel-agent-engine.ts +0 -848
- package/src/queen/queen-memory-system.ts +0 -490
- package/src/queen/queen-memory.ts +0 -456
- package/src/queen/servicenow-queen.ts +0 -1029
- package/src/queen/types.ts +0 -87
- package/src/rollback/smart-rollback-system.ts +0 -866
- package/src/schemas/deployment.schema.json +0 -58
- package/src/schemas/flow.schema.json +0 -79
- package/src/schemas/widget.schema.json +0 -72
- package/src/snow-flow-system.ts +0 -541
- package/src/sparc/sparc-help.ts +0 -49
- package/src/sparc/team-sparc.ts +0 -88
- package/src/strategies/global-scope-strategy.ts +0 -736
- package/src/templates/base/application.template.json +0 -45
- package/src/templates/base/business_rule.template.json +0 -33
- package/src/templates/base/script_include.template.json +0 -18
- package/src/templates/base/table.template.json +0 -64
- package/src/templates/base/widget.template.json +0 -25
- package/src/templates/patterns/composite.incident-management.template.json +0 -140
- package/src/templates/patterns/widget.dashboard.template.json +0 -238
- package/src/templates/patterns/widget.datatable.template.json +0 -292
- package/src/testing/integration-test-suite.ts +0 -1276
- package/src/types/index.ts +0 -183
- package/src/types/neo4j-driver.d.ts +0 -23
- package/src/types/servicenow.types.ts +0 -307
- package/src/types/snow-flow.types.ts +0 -186
- package/src/types/todo.types.ts +0 -70
- package/src/utils/action-type-cache.ts +0 -286
- package/src/utils/agent-detector.ts +0 -573
- package/src/utils/artifact-tracker.ts +0 -379
- package/src/utils/dependency-detector.ts +0 -233
- package/src/utils/deployment-metadata-handler.ts +0 -518
- package/src/utils/error-recovery.ts +0 -680
- package/src/utils/logger.ts +0 -60
- package/src/utils/mcp-auth-middleware.ts +0 -262
- package/src/utils/mcp-config-manager.ts +0 -270
- package/src/utils/mcp-server-manager.ts +0 -446
- package/src/utils/mcp-tool-registry.ts +0 -298
- package/src/utils/migrate-snow-flow.ts +0 -98
- package/src/utils/oauth-html-templates.ts +0 -188
- package/src/utils/scope-utils.ts +0 -443
- package/src/utils/servicenow-client.ts +0 -3321
- package/src/utils/servicenow-id-generator.ts +0 -181
- package/src/utils/snow-memory-manager.ts +0 -605
- package/src/utils/snow-oauth.ts +0 -797
- package/src/utils/template-engine.ts +0 -463
- package/src/utils/theme-manager.ts +0 -295
- package/src/utils/unified-auth-store.ts +0 -222
- package/src/utils/update-set-importer.ts +0 -422
- package/src/utils/update-set-xml-packager.ts +0 -371
- package/src/utils/widget-template-generator.ts +0 -1744
- 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}`);
|
package/src/agents/README.md
DELETED
|
@@ -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
|
package/src/agents/base-agent.ts
DELETED
|
@@ -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
|
-
}
|