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.
- package/{.claude/mcp-config.json → .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +48 -1
- 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,574 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ServiceNow Agent Factory
|
|
3
|
-
* Dynamic agent spawning based on task analysis
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Agent, AgentType, ServiceNowTask, AgentMessage } from './types';
|
|
7
|
-
import { QueenMemorySystem } from './queen-memory';
|
|
8
|
-
import * as crypto from 'crypto';
|
|
9
|
-
import { BaseAgent, AGENT_CLASS_MAP } from '../agents';
|
|
10
|
-
|
|
11
|
-
interface AgentBlueprint {
|
|
12
|
-
type: AgentType;
|
|
13
|
-
capabilities: string[];
|
|
14
|
-
mcpTools: string[];
|
|
15
|
-
personality: string;
|
|
16
|
-
coordination: 'independent' | 'collaborative' | 'dependent';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class AgentFactory {
|
|
20
|
-
private memory: QueenMemorySystem;
|
|
21
|
-
private activeAgents: Map<string, Agent>;
|
|
22
|
-
private agentBlueprints: Map<AgentType, AgentBlueprint>;
|
|
23
|
-
private messageQueue: AgentMessage[];
|
|
24
|
-
|
|
25
|
-
constructor(memory: QueenMemorySystem) {
|
|
26
|
-
this.memory = memory;
|
|
27
|
-
this.activeAgents = new Map();
|
|
28
|
-
this.messageQueue = [];
|
|
29
|
-
this.agentBlueprints = new Map();
|
|
30
|
-
this.initializeBlueprints();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private initializeBlueprints(): void {
|
|
34
|
-
// Widget Creator Agent - Simple but effective
|
|
35
|
-
this.agentBlueprints.set('widget-creator', {
|
|
36
|
-
type: 'widget-creator',
|
|
37
|
-
capabilities: [
|
|
38
|
-
'HTML template creation',
|
|
39
|
-
'CSS styling and responsive design',
|
|
40
|
-
'Client-side JavaScript',
|
|
41
|
-
'Server-side data processing',
|
|
42
|
-
'Chart.js integration',
|
|
43
|
-
'ServiceNow widget deployment'
|
|
44
|
-
],
|
|
45
|
-
mcpTools: [
|
|
46
|
-
'snow_deploy',
|
|
47
|
-
'snow_preview_widget',
|
|
48
|
-
'snow_widget_test',
|
|
49
|
-
'snow_catalog_item_search'
|
|
50
|
-
],
|
|
51
|
-
personality: 'Focused, detail-oriented, user experience focused',
|
|
52
|
-
coordination: 'collaborative'
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Flow Builder Agent - Process automation specialist
|
|
56
|
-
this.agentBlueprints.set('flow-builder', {
|
|
57
|
-
type: 'flow-builder',
|
|
58
|
-
capabilities: [
|
|
59
|
-
'Business process design',
|
|
60
|
-
'Flow Designer expertise',
|
|
61
|
-
'Approval workflow creation',
|
|
62
|
-
'Integration flow building',
|
|
63
|
-
'Condition and trigger logic'
|
|
64
|
-
],
|
|
65
|
-
mcpTools: [
|
|
66
|
-
'snow_create_flow',
|
|
67
|
-
'snow_test_flow_with_mock',
|
|
68
|
-
'snow_link_catalog_to_flow',
|
|
69
|
-
'snow_comprehensive_flow_test'
|
|
70
|
-
],
|
|
71
|
-
personality: 'Process-oriented, logical, systematic',
|
|
72
|
-
coordination: 'dependent'
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Script Writer Agent - Backend logic specialist
|
|
76
|
-
this.agentBlueprints.set('script-writer', {
|
|
77
|
-
type: 'script-writer',
|
|
78
|
-
capabilities: [
|
|
79
|
-
'Business rule creation',
|
|
80
|
-
'Script include development',
|
|
81
|
-
'Client script implementation',
|
|
82
|
-
'Data transformation scripts',
|
|
83
|
-
'Performance optimization'
|
|
84
|
-
],
|
|
85
|
-
mcpTools: [
|
|
86
|
-
'snow_create_script_include',
|
|
87
|
-
'snow_create_business_rule',
|
|
88
|
-
'snow_create_client_script'
|
|
89
|
-
],
|
|
90
|
-
personality: 'Technical, efficient, security-conscious',
|
|
91
|
-
coordination: 'independent'
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Application Architect Agent - System design specialist
|
|
95
|
-
this.agentBlueprints.set('app-architect', {
|
|
96
|
-
type: 'app-architect',
|
|
97
|
-
capabilities: [
|
|
98
|
-
'System architecture design',
|
|
99
|
-
'Table structure planning',
|
|
100
|
-
'Module organization',
|
|
101
|
-
'Security model design',
|
|
102
|
-
'Performance architecture'
|
|
103
|
-
],
|
|
104
|
-
mcpTools: [
|
|
105
|
-
'snow_deploy',
|
|
106
|
-
'snow_discover_platform_tables',
|
|
107
|
-
'snow_table_schema_discovery',
|
|
108
|
-
'snow_create_ui_policy'
|
|
109
|
-
],
|
|
110
|
-
personality: 'Strategic, thorough, architecture-focused',
|
|
111
|
-
coordination: 'collaborative'
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// Integration Specialist Agent - API and integration expert
|
|
115
|
-
this.agentBlueprints.set('integration-specialist', {
|
|
116
|
-
type: 'integration-specialist',
|
|
117
|
-
capabilities: [
|
|
118
|
-
'REST API integration',
|
|
119
|
-
'Data transformation',
|
|
120
|
-
'External system connectivity',
|
|
121
|
-
'Import/export processes',
|
|
122
|
-
'Authentication handling'
|
|
123
|
-
],
|
|
124
|
-
mcpTools: [
|
|
125
|
-
'snow_create_rest_message',
|
|
126
|
-
'snow_create_transform_map',
|
|
127
|
-
'snow_test_integration',
|
|
128
|
-
'snow_discover_data_sources'
|
|
129
|
-
],
|
|
130
|
-
personality: 'Integration-focused, problem-solving, connectivity expert',
|
|
131
|
-
coordination: 'independent'
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// Catalog Manager Agent - Service catalog specialist
|
|
135
|
-
this.agentBlueprints.set('catalog-manager', {
|
|
136
|
-
type: 'catalog-manager',
|
|
137
|
-
capabilities: [
|
|
138
|
-
'Catalog item creation',
|
|
139
|
-
'Variable set design',
|
|
140
|
-
'Workflow integration',
|
|
141
|
-
'Fulfillment automation',
|
|
142
|
-
'User experience optimization'
|
|
143
|
-
],
|
|
144
|
-
mcpTools: [
|
|
145
|
-
'snow_catalog_item_manager',
|
|
146
|
-
'snow_catalog_item_search',
|
|
147
|
-
'snow_link_catalog_to_flow'
|
|
148
|
-
],
|
|
149
|
-
personality: 'User-focused, service-oriented, detail-oriented',
|
|
150
|
-
coordination: 'collaborative'
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// Researcher Agent - Discovery and _analysis specialist
|
|
154
|
-
this.agentBlueprints.set('researcher', {
|
|
155
|
-
type: 'researcher',
|
|
156
|
-
capabilities: [
|
|
157
|
-
'Requirement _analysis',
|
|
158
|
-
'Best practice research',
|
|
159
|
-
'Existing artifact discovery',
|
|
160
|
-
'Dependency identification',
|
|
161
|
-
'Solution architecture'
|
|
162
|
-
],
|
|
163
|
-
mcpTools: [
|
|
164
|
-
'snow_find_artifact',
|
|
165
|
-
'snow_comprehensive_search',
|
|
166
|
-
'snow_analyze_requirements',
|
|
167
|
-
'snow_discover_existing_flows'
|
|
168
|
-
],
|
|
169
|
-
personality: 'Analytical, thorough, knowledge-gathering',
|
|
170
|
-
coordination: 'independent'
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// Tester Agent - Quality assurance specialist
|
|
174
|
-
this.agentBlueprints.set('tester', {
|
|
175
|
-
type: 'tester',
|
|
176
|
-
capabilities: [
|
|
177
|
-
'Test scenario creation',
|
|
178
|
-
'Mock data generation',
|
|
179
|
-
'Integration testing',
|
|
180
|
-
'Performance validation',
|
|
181
|
-
'Quality assurance'
|
|
182
|
-
],
|
|
183
|
-
mcpTools: [
|
|
184
|
-
'snow_test_flow_with_mock',
|
|
185
|
-
'snow_widget_test',
|
|
186
|
-
'snow_comprehensive_flow_test',
|
|
187
|
-
'snow_cleanup_test_artifacts'
|
|
188
|
-
],
|
|
189
|
-
personality: 'Quality-focused, systematic, thorough',
|
|
190
|
-
coordination: 'dependent'
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Spawn agent based on type and task requirements
|
|
195
|
-
spawnAgent(type: AgentType, taskId?: string): Agent {
|
|
196
|
-
const blueprint = this.agentBlueprints.get(type);
|
|
197
|
-
if (!blueprint) {
|
|
198
|
-
throw new Error(`Unknown agent type: ${type}`);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const agent: Agent = {
|
|
202
|
-
id: this.generateAgentId(type),
|
|
203
|
-
type,
|
|
204
|
-
status: 'idle',
|
|
205
|
-
task: taskId,
|
|
206
|
-
capabilities: [...blueprint.capabilities],
|
|
207
|
-
mcpTools: [...blueprint.mcpTools]
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
this.activeAgents.set(agent.id, agent);
|
|
211
|
-
|
|
212
|
-
// Store agent creation in memory for learning
|
|
213
|
-
this.memory.storeLearning(
|
|
214
|
-
`agent_spawn_${type}`,
|
|
215
|
-
`Spawned ${type} agent for task: ${taskId || 'general'}`,
|
|
216
|
-
0.8
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
return agent;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Spawn multiple agents for complex task
|
|
223
|
-
spawnAgentSwarm(agentTypes: AgentType[], taskId: string): Agent[] {
|
|
224
|
-
const agents: Agent[] = [];
|
|
225
|
-
|
|
226
|
-
for (const type of agentTypes) {
|
|
227
|
-
const agent = this.spawnAgent(type, taskId);
|
|
228
|
-
agents.push(agent);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Create coordination channels between collaborative agents
|
|
232
|
-
this.setupAgentCoordination(agents);
|
|
233
|
-
|
|
234
|
-
return agents;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
private setupAgentCoordination(agents: Agent[]): void {
|
|
238
|
-
const collaborativeAgents = agents.filter(agent => {
|
|
239
|
-
const blueprint = this.agentBlueprints.get(agent.type);
|
|
240
|
-
return blueprint?.coordination === 'collaborative';
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// Enable message passing between collaborative agents
|
|
244
|
-
for (let i = 0; i < collaborativeAgents.length; i++) {
|
|
245
|
-
for (let j = i + 1; j < collaborativeAgents.length; j++) {
|
|
246
|
-
this.memory.storeLearning(
|
|
247
|
-
`coordination_${collaborativeAgents[i].type}_${collaborativeAgents[j].type}`,
|
|
248
|
-
'Enabled collaborative coordination channel',
|
|
249
|
-
0.9
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Get optimal agent sequence for task
|
|
256
|
-
getOptimalAgentSequence(taskType: ServiceNowTask['type'], complexity: number): AgentType[] {
|
|
257
|
-
// Check memory for successful patterns first
|
|
258
|
-
const bestPattern = this.memory.getBestPattern(taskType);
|
|
259
|
-
if (bestPattern && bestPattern.successRate > 0.7) {
|
|
260
|
-
return bestPattern.agentSequence;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Default sequences based on task type and complexity
|
|
264
|
-
const sequences: Record<ServiceNowTask['type'], AgentType[]> = {
|
|
265
|
-
widget: complexity > 0.7
|
|
266
|
-
? ['researcher', 'widget-creator', 'tester']
|
|
267
|
-
: ['widget-creator', 'tester'],
|
|
268
|
-
|
|
269
|
-
flow: complexity > 0.6
|
|
270
|
-
? ['researcher', 'flow-builder', 'catalog-manager', 'tester']
|
|
271
|
-
: ['flow-builder', 'tester'],
|
|
272
|
-
|
|
273
|
-
script: complexity > 0.5
|
|
274
|
-
? ['researcher', 'script-writer', 'tester']
|
|
275
|
-
: ['script-writer'],
|
|
276
|
-
|
|
277
|
-
application: complexity > 0.8
|
|
278
|
-
? ['researcher', 'app-architect', 'script-writer', 'widget-creator', 'tester']
|
|
279
|
-
: ['app-architect', 'script-writer', 'tester'],
|
|
280
|
-
|
|
281
|
-
integration: ['researcher', 'integration-specialist', 'tester'],
|
|
282
|
-
|
|
283
|
-
portal_page: complexity > 0.7
|
|
284
|
-
? ['researcher', 'widget-creator', 'page-designer', 'tester']
|
|
285
|
-
: ['widget-creator', 'page-designer', 'tester'],
|
|
286
|
-
|
|
287
|
-
unknown: ['researcher', 'widget-creator'] // Safe default
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
return sequences[taskType] || ['researcher'];
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Execute agent task with specific MCP tools
|
|
294
|
-
async executeAgentTask(agentId: string, instruction: string): Promise<any> {
|
|
295
|
-
const agent = this.activeAgents.get(agentId);
|
|
296
|
-
if (!agent) {
|
|
297
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
agent.status = 'working';
|
|
301
|
-
|
|
302
|
-
try {
|
|
303
|
-
// Get agent blueprint for MCP tool selection
|
|
304
|
-
const blueprint = this.agentBlueprints.get(agent.type);
|
|
305
|
-
if (!blueprint) {
|
|
306
|
-
throw new Error(`No blueprint for agent type: ${agent.type}`);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Execute with appropriate MCP tools based on agent type
|
|
310
|
-
const result = await this.executeWithMcpTools(agent, instruction, blueprint.mcpTools);
|
|
311
|
-
|
|
312
|
-
agent.status = 'completed';
|
|
313
|
-
return result;
|
|
314
|
-
|
|
315
|
-
} catch (error) {
|
|
316
|
-
agent.status = 'failed';
|
|
317
|
-
throw error;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
private async executeWithMcpTools(agent: Agent, instruction: string, mcpTools: string[]): Promise<any> {
|
|
322
|
-
// This is where the agent would use specific MCP tools
|
|
323
|
-
// The Queen will orchestrate the actual MCP calls based on agent recommendations
|
|
324
|
-
|
|
325
|
-
return {
|
|
326
|
-
agentId: agent.id,
|
|
327
|
-
agentType: agent.type,
|
|
328
|
-
instruction,
|
|
329
|
-
recommendedMcpTools: mcpTools,
|
|
330
|
-
executionPlan: this.generateExecutionPlan(agent.type, instruction)
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
private generateExecutionPlan(agentType: AgentType, instruction: string): string[] {
|
|
335
|
-
const plans: Record<AgentType, (instruction: string) => string[]> = {
|
|
336
|
-
'widget-creator': (instr) => [
|
|
337
|
-
'Analyze widget requirements from instruction',
|
|
338
|
-
'Create HTML template with proper structure',
|
|
339
|
-
'Develop CSS for responsive design',
|
|
340
|
-
'Implement client-side JavaScript functionality',
|
|
341
|
-
'Create server-side data processing script',
|
|
342
|
-
'Deploy widget using snow_deploy',
|
|
343
|
-
'Test widget functionality'
|
|
344
|
-
],
|
|
345
|
-
|
|
346
|
-
'flow-builder': (instr) => [
|
|
347
|
-
'Analyze process requirements from instruction',
|
|
348
|
-
'Design flow structure and decision points',
|
|
349
|
-
'Create flow using snow_create_flow',
|
|
350
|
-
'Configure triggers and conditions',
|
|
351
|
-
'Test flow with mock data using snow_test_flow_with_mock',
|
|
352
|
-
'Link to catalog if needed using snow_link_catalog_to_flow'
|
|
353
|
-
],
|
|
354
|
-
|
|
355
|
-
'script-writer': (instr) => [
|
|
356
|
-
'Analyze scripting requirements',
|
|
357
|
-
'Determine script type (business rule, script include, etc.)',
|
|
358
|
-
'Implement script logic with error handling',
|
|
359
|
-
'Deploy script using appropriate MCP tool',
|
|
360
|
-
'Validate script functionality'
|
|
361
|
-
],
|
|
362
|
-
|
|
363
|
-
'catalog-manager': (instr) => [
|
|
364
|
-
'Search for existing catalog items using snow_catalog_item_search',
|
|
365
|
-
'Design catalog item structure and variables',
|
|
366
|
-
'Create catalog item using snow_catalog_item_manager',
|
|
367
|
-
'Configure fulfillment process',
|
|
368
|
-
'Test catalog request flow'
|
|
369
|
-
],
|
|
370
|
-
|
|
371
|
-
'researcher': (instr) => [
|
|
372
|
-
'Search existing artifacts using snow_find_artifact',
|
|
373
|
-
'Analyze system requirements using snow_analyze_requirements',
|
|
374
|
-
'Discover dependencies and constraints',
|
|
375
|
-
'Provide recommendations and insights'
|
|
376
|
-
],
|
|
377
|
-
|
|
378
|
-
'tester': (instr) => [
|
|
379
|
-
'Create test scenarios based on requirements',
|
|
380
|
-
'Generate mock test data',
|
|
381
|
-
'Execute tests using appropriate snow_test tools',
|
|
382
|
-
'Validate results and report issues',
|
|
383
|
-
'Clean up test artifacts using snow_cleanup_test_artifacts'
|
|
384
|
-
],
|
|
385
|
-
|
|
386
|
-
// Default plans for other agent types
|
|
387
|
-
'app-architect': (instr) => ['Analyze architecture requirements', 'Design system structure', 'Create deployment plan'],
|
|
388
|
-
'integration-specialist': (instr) => ['Analyze integration requirements', 'Design data flow', 'Implement integration'],
|
|
389
|
-
'ui-ux-specialist': (instr) => ['Analyze user experience requirements', 'Design interface mockups', 'Implement responsive design'],
|
|
390
|
-
'approval-specialist': (instr) => ['Design approval workflow', 'Configure approval rules', 'Test approval process'],
|
|
391
|
-
'security-specialist': (instr) => ['Analyze security requirements', 'Implement security controls', 'Perform security audit'],
|
|
392
|
-
'css-specialist': (instr) => ['Analyze styling requirements', 'Develop responsive CSS', 'Optimize visual design'],
|
|
393
|
-
'backend-specialist': (instr) => ['Analyze backend requirements', 'Implement server logic', 'Optimize performance'],
|
|
394
|
-
'frontend-specialist': (instr) => ['Analyze frontend requirements', 'Implement user interface', 'Ensure cross-browser compatibility'],
|
|
395
|
-
'performance-specialist': (instr) => ['Analyze performance requirements', 'Identify bottlenecks', 'Implement optimizations'],
|
|
396
|
-
'page-designer': (instr) => [
|
|
397
|
-
'Analyze portal page requirements from instruction',
|
|
398
|
-
'Determine page layout (single column, multi-column, with sidebar)',
|
|
399
|
-
'Identify target portal (Service Portal or Employee Service Center)',
|
|
400
|
-
'Create portal page structure using snow_deploy',
|
|
401
|
-
'Configure containers, rows, and columns',
|
|
402
|
-
'Place widget instances on the page',
|
|
403
|
-
'Apply responsive CSS for page layout',
|
|
404
|
-
'Configure page permissions and navigation',
|
|
405
|
-
'Test page across devices and browsers'
|
|
406
|
-
]
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
return plans[agentType]?.(instruction) || ['Execute general task based on instruction'];
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Send message between agents
|
|
413
|
-
sendAgentMessage(from: string, to: string, type: AgentMessage['type'], content: any): void {
|
|
414
|
-
const message: AgentMessage = {
|
|
415
|
-
from,
|
|
416
|
-
to,
|
|
417
|
-
type,
|
|
418
|
-
content,
|
|
419
|
-
timestamp: new Date()
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
this.messageQueue.push(message);
|
|
423
|
-
|
|
424
|
-
// Store coordination pattern for learning
|
|
425
|
-
this.memory.storeLearning(
|
|
426
|
-
`agent_coordination_${from}_${to}`,
|
|
427
|
-
`Message of type ${type}`,
|
|
428
|
-
0.7
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Get pending messages for agent
|
|
433
|
-
getAgentMessages(agentId: string): AgentMessage[] {
|
|
434
|
-
return this.messageQueue.filter(msg => msg.to === agentId);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// Mark agent messages as processed
|
|
438
|
-
markMessagesProcessed(agentId: string): void {
|
|
439
|
-
this.messageQueue = this.messageQueue.filter(msg => msg.to !== agentId);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// Get agent status
|
|
443
|
-
getAgentStatus(agentId: string): Agent | null {
|
|
444
|
-
return this.activeAgents.get(agentId) || null;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// Terminate agent
|
|
448
|
-
terminateAgent(agentId: string): void {
|
|
449
|
-
const agent = this.activeAgents.get(agentId);
|
|
450
|
-
if (agent) {
|
|
451
|
-
// Store agent performance data for learning
|
|
452
|
-
this.memory.storeLearning(
|
|
453
|
-
`agent_performance_${agent.type}`,
|
|
454
|
-
`Agent ${agentId} terminated with status: ${agent.status}`,
|
|
455
|
-
agent.status === 'completed' ? 0.9 : 0.3
|
|
456
|
-
);
|
|
457
|
-
|
|
458
|
-
this.activeAgents.delete(agentId);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// Get all active agents
|
|
463
|
-
getActiveAgents(): Agent[] {
|
|
464
|
-
return Array.from(this.activeAgents.values());
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// Clean up completed agents
|
|
468
|
-
cleanupCompletedAgents(): number {
|
|
469
|
-
let cleaned = 0;
|
|
470
|
-
for (const [id, agent] of Array.from(this.activeAgents.entries())) {
|
|
471
|
-
if (agent.status === 'completed' || agent.status === 'failed') {
|
|
472
|
-
this.terminateAgent(id);
|
|
473
|
-
cleaned++;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return cleaned;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
private generateAgentId(type: AgentType): string {
|
|
480
|
-
const timestamp = Date.now().toString(36);
|
|
481
|
-
const random = crypto.randomBytes(4).toString('hex');
|
|
482
|
-
return `${type}_${timestamp}_${random}`;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// Get agent blueprint for inspection
|
|
486
|
-
getAgentBlueprint(type: AgentType): AgentBlueprint | null {
|
|
487
|
-
return this.agentBlueprints.get(type) || null;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// Get factory statistics
|
|
491
|
-
getStatistics(): any {
|
|
492
|
-
const agentTypeCounts: Record<string, number> = {};
|
|
493
|
-
const agentStatusCounts: Record<string, number> = {};
|
|
494
|
-
|
|
495
|
-
for (const agent of Array.from(this.activeAgents.values())) {
|
|
496
|
-
agentTypeCounts[agent.type] = (agentTypeCounts[agent.type] || 0) + 1;
|
|
497
|
-
agentStatusCounts[agent.status] = (agentStatusCounts[agent.status] || 0) + 1;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
return {
|
|
501
|
-
totalActiveAgents: this.activeAgents.size,
|
|
502
|
-
agentTypeCounts,
|
|
503
|
-
agentStatusCounts,
|
|
504
|
-
pendingMessages: this.messageQueue.length,
|
|
505
|
-
availableAgentTypes: Array.from(this.agentBlueprints.keys())
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
// Create specialized agent instance
|
|
510
|
-
async createSpecializedAgent(type: AgentType, taskId?: string): Promise<BaseAgent | null> {
|
|
511
|
-
try {
|
|
512
|
-
// Get the agent class constructor
|
|
513
|
-
const agentClassLoader = AGENT_CLASS_MAP[type];
|
|
514
|
-
if (!agentClassLoader) {
|
|
515
|
-
console.error(`No specialized agent implementation for type: ${type}`);
|
|
516
|
-
return null;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// Dynamically import and instantiate the agent
|
|
520
|
-
const AgentClass = await agentClassLoader();
|
|
521
|
-
const specializedAgent = new AgentClass({
|
|
522
|
-
id: this.generateAgentId(type),
|
|
523
|
-
memoryPath: this.memory.getDbPath(),
|
|
524
|
-
debugMode: true
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
// Track in active agents
|
|
528
|
-
const agentInfo = specializedAgent.getInfo();
|
|
529
|
-
this.activeAgents.set(agentInfo.id, agentInfo as Agent);
|
|
530
|
-
|
|
531
|
-
// Store creation in memory
|
|
532
|
-
this.memory.storeLearning(
|
|
533
|
-
`specialized_agent_spawn_${type}`,
|
|
534
|
-
`Created specialized ${type} agent for task: ${taskId || 'general'}`,
|
|
535
|
-
0.9
|
|
536
|
-
);
|
|
537
|
-
|
|
538
|
-
return specializedAgent;
|
|
539
|
-
} catch (error) {
|
|
540
|
-
console.error(`Failed to create specialized agent ${type}:`, error);
|
|
541
|
-
return null;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// Execute task with specialized agent
|
|
546
|
-
async executeWithSpecializedAgent(type: AgentType, instruction: string, context?: any): Promise<any> {
|
|
547
|
-
const agent = await this.createSpecializedAgent(type);
|
|
548
|
-
if (!agent) {
|
|
549
|
-
throw new Error(`Failed to create specialized agent of type ${type}`);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
try {
|
|
553
|
-
// Execute the agent's task
|
|
554
|
-
const result = await agent.execute(instruction, context);
|
|
555
|
-
|
|
556
|
-
// Store execution result in memory
|
|
557
|
-
this.memory.storeLearning(
|
|
558
|
-
`specialized_execution_${type}`,
|
|
559
|
-
JSON.stringify({
|
|
560
|
-
instruction,
|
|
561
|
-
success: result.success,
|
|
562
|
-
timestamp: new Date()
|
|
563
|
-
}),
|
|
564
|
-
result.success ? 0.9 : 0.3
|
|
565
|
-
);
|
|
566
|
-
|
|
567
|
-
return result;
|
|
568
|
-
} finally {
|
|
569
|
-
// Clean up agent
|
|
570
|
-
await agent.cleanup();
|
|
571
|
-
this.terminateAgent(agent.id);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
package/src/queen/index.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ServiceNow Queen Agent - Hive-Mind Intelligence System
|
|
3
|
-
*
|
|
4
|
-
* Simple, elegant coordination system following snow-flow philosophy
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { ServiceNowQueen } from './queen';
|
|
9
|
-
*
|
|
10
|
-
* const queen = new ServiceNowQueen({
|
|
11
|
-
* debugMode: true,
|
|
12
|
-
* maxConcurrentAgents: 5
|
|
13
|
-
* });
|
|
14
|
-
*
|
|
15
|
-
* // Execute any ServiceNow objective
|
|
16
|
-
* const result = await queen.executeObjective("create incident dashboard with charts");
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
// Main Queen Agent
|
|
21
|
-
export { ServiceNowQueen, QueenConfig } from './servicenow-queen';
|
|
22
|
-
|
|
23
|
-
// Core components
|
|
24
|
-
export { QueenMemorySystem } from './queen-memory';
|
|
25
|
-
export { NeuralLearning } from './neural-learning';
|
|
26
|
-
export { AgentFactory } from './agent-factory';
|
|
27
|
-
|
|
28
|
-
// Types
|
|
29
|
-
export {
|
|
30
|
-
ServiceNowTask,
|
|
31
|
-
Agent,
|
|
32
|
-
AgentType,
|
|
33
|
-
TaskAnalysis,
|
|
34
|
-
DeploymentPattern,
|
|
35
|
-
QueenMemory,
|
|
36
|
-
AgentMessage,
|
|
37
|
-
ServiceNowArtifact
|
|
38
|
-
} from './types';
|
|
39
|
-
|
|
40
|
-
// Import for internal use
|
|
41
|
-
import { ServiceNowQueen } from './servicenow-queen';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Quick start factory function
|
|
45
|
-
*/
|
|
46
|
-
export function createServiceNowQueen(options: {
|
|
47
|
-
memoryPath?: string;
|
|
48
|
-
debugMode?: boolean;
|
|
49
|
-
maxConcurrentAgents?: number;
|
|
50
|
-
autoPermissions?: boolean;
|
|
51
|
-
} = {}) {
|
|
52
|
-
return new ServiceNowQueen({
|
|
53
|
-
debugMode: options.debugMode ?? process.env.NODE_ENV === 'development',
|
|
54
|
-
memoryPath: options.memoryPath,
|
|
55
|
-
maxConcurrentAgents: options.maxConcurrentAgents ?? 5,
|
|
56
|
-
autoPermissions: options.autoPermissions ?? false
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Available agent types for dynamic spawning
|
|
62
|
-
*/
|
|
63
|
-
export const AVAILABLE_AGENT_TYPES = [
|
|
64
|
-
'widget-creator',
|
|
65
|
-
'flow-builder',
|
|
66
|
-
'script-writer',
|
|
67
|
-
'app-architect',
|
|
68
|
-
'integration-specialist',
|
|
69
|
-
'catalog-manager',
|
|
70
|
-
'researcher',
|
|
71
|
-
'tester'
|
|
72
|
-
] as const;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Common ServiceNow task patterns
|
|
76
|
-
*/
|
|
77
|
-
export const TASK_PATTERNS = {
|
|
78
|
-
WIDGET: {
|
|
79
|
-
keywords: ['widget', 'dashboard', 'chart', 'display', 'portal'],
|
|
80
|
-
complexity_factors: ['chart', 'responsive', 'data_sources', 'real_time']
|
|
81
|
-
},
|
|
82
|
-
FLOW: {
|
|
83
|
-
keywords: ['flow', 'workflow', 'process', 'approval', 'automation'],
|
|
84
|
-
complexity_factors: ['approval_steps', 'integration', 'conditions', 'notifications']
|
|
85
|
-
},
|
|
86
|
-
APPLICATION: {
|
|
87
|
-
keywords: ['application', 'app', 'system', 'module', 'solution'],
|
|
88
|
-
complexity_factors: ['tables', 'business_rules', 'ui_policies', 'integrations']
|
|
89
|
-
},
|
|
90
|
-
INTEGRATION: {
|
|
91
|
-
keywords: ['integration', 'api', 'connect', 'sync', 'import', 'export'],
|
|
92
|
-
complexity_factors: ['external_apis', 'data_transformation', 'authentication', 'error_handling']
|
|
93
|
-
}
|
|
94
|
-
} as const;
|