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,643 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-Resolution Engine - Automatically fixes ServiceNow configuration gaps
|
|
3
|
-
*
|
|
4
|
-
* This engine attempts to automatically resolve ServiceNow configuration requirements
|
|
5
|
-
* that fall outside the scope of standard MCP tools, including:
|
|
6
|
-
* - System properties and configurations
|
|
7
|
-
* - Database indexes and views
|
|
8
|
-
* - Navigation and menu items
|
|
9
|
-
* - Advanced authentication settings
|
|
10
|
-
* - Performance and monitoring configurations
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { ServiceNowRequirement, RequirementType } from './requirements-analyzer';
|
|
14
|
-
import { McpCoverageAnalyzer, AutomationCapability } from './mcp-coverage-analyzer';
|
|
15
|
-
|
|
16
|
-
export interface ResolutionResult {
|
|
17
|
-
requirement: ServiceNowRequirement;
|
|
18
|
-
status: 'success' | 'partial' | 'failed' | 'manual_required';
|
|
19
|
-
automationUsed?: string;
|
|
20
|
-
manualSteps?: string[];
|
|
21
|
-
errorMessage?: string;
|
|
22
|
-
sysId?: string;
|
|
23
|
-
timeElapsed?: number;
|
|
24
|
-
fallbackStrategy?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ResolutionStrategy {
|
|
28
|
-
requirementType: RequirementType;
|
|
29
|
-
automationMethod: string;
|
|
30
|
-
apiEndpoint?: string;
|
|
31
|
-
parameters: Record<string, any>;
|
|
32
|
-
requiredPermissions: string[];
|
|
33
|
-
riskLevel: 'low' | 'medium' | 'high';
|
|
34
|
-
fallbackInstructions: string[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface BulkResolutionResult {
|
|
38
|
-
successful: ResolutionResult[];
|
|
39
|
-
failed: ResolutionResult[];
|
|
40
|
-
manual: ResolutionResult[];
|
|
41
|
-
totalTime: number;
|
|
42
|
-
successRate: number;
|
|
43
|
-
recommendations: string[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Resolution strategies for ServiceNow configurations beyond MCP tools
|
|
48
|
-
*/
|
|
49
|
-
export const AUTO_RESOLUTION_STRATEGIES: ResolutionStrategy[] = [
|
|
50
|
-
// System Configuration
|
|
51
|
-
{
|
|
52
|
-
requirementType: 'system_property',
|
|
53
|
-
automationMethod: 'createSystemProperty',
|
|
54
|
-
apiEndpoint: '/api/now/table/sys_properties',
|
|
55
|
-
parameters: {
|
|
56
|
-
name: 'property_name',
|
|
57
|
-
value: 'property_value',
|
|
58
|
-
description: 'Property description',
|
|
59
|
-
type: 'string'
|
|
60
|
-
},
|
|
61
|
-
requiredPermissions: ['admin'],
|
|
62
|
-
riskLevel: 'medium',
|
|
63
|
-
fallbackInstructions: [
|
|
64
|
-
'Navigate to System Definition > System Properties',
|
|
65
|
-
'Click "New" to create property',
|
|
66
|
-
'Set Name, Value, and Description fields',
|
|
67
|
-
'Click Submit'
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
// Navigation and Menus
|
|
72
|
-
{
|
|
73
|
-
requirementType: 'application_menu',
|
|
74
|
-
automationMethod: 'createApplicationMenu',
|
|
75
|
-
apiEndpoint: '/api/now/table/sys_app_module',
|
|
76
|
-
parameters: {
|
|
77
|
-
title: 'Menu Title',
|
|
78
|
-
application: 'application_sys_id',
|
|
79
|
-
order: 100,
|
|
80
|
-
active: true,
|
|
81
|
-
link_type: 'LIST'
|
|
82
|
-
},
|
|
83
|
-
requiredPermissions: ['admin'],
|
|
84
|
-
riskLevel: 'low',
|
|
85
|
-
fallbackInstructions: [
|
|
86
|
-
'Navigate to System Definition > Application Menus',
|
|
87
|
-
'Find the target application',
|
|
88
|
-
'Right-click and select "New Module"',
|
|
89
|
-
'Configure title, table, and permissions'
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
requirementType: 'module_navigation',
|
|
95
|
-
automationMethod: 'createNavigationModule',
|
|
96
|
-
apiEndpoint: '/api/now/table/sys_app_module',
|
|
97
|
-
parameters: {
|
|
98
|
-
title: 'Module Name',
|
|
99
|
-
application: 'application_sys_id',
|
|
100
|
-
name: 'module_name',
|
|
101
|
-
link_type: 'LIST',
|
|
102
|
-
table: 'target_table'
|
|
103
|
-
},
|
|
104
|
-
requiredPermissions: ['admin'],
|
|
105
|
-
riskLevel: 'low',
|
|
106
|
-
fallbackInstructions: [
|
|
107
|
-
'Go to System Definition > Modules',
|
|
108
|
-
'Click New',
|
|
109
|
-
'Set Title, Application, and Table',
|
|
110
|
-
'Configure View and Filter if needed'
|
|
111
|
-
]
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
// Database and Performance
|
|
115
|
-
{
|
|
116
|
-
requirementType: 'database_index',
|
|
117
|
-
automationMethod: 'createDatabaseIndex',
|
|
118
|
-
apiEndpoint: '/api/now/table/sys_db_index',
|
|
119
|
-
parameters: {
|
|
120
|
-
table: 'table_name',
|
|
121
|
-
name: 'index_name',
|
|
122
|
-
type: 'index',
|
|
123
|
-
unique: false
|
|
124
|
-
},
|
|
125
|
-
requiredPermissions: ['admin'],
|
|
126
|
-
riskLevel: 'high',
|
|
127
|
-
fallbackInstructions: [
|
|
128
|
-
'Navigate to System Definition > Tables',
|
|
129
|
-
'Open the target table',
|
|
130
|
-
'Go to Database Indexes tab',
|
|
131
|
-
'Click New to create index',
|
|
132
|
-
'WARNING: Test in development first!'
|
|
133
|
-
]
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
// User Interface
|
|
137
|
-
{
|
|
138
|
-
requirementType: 'form_layout',
|
|
139
|
-
automationMethod: 'createFormLayout',
|
|
140
|
-
apiEndpoint: '/api/now/table/sys_ui_form',
|
|
141
|
-
parameters: {
|
|
142
|
-
name: 'form_name',
|
|
143
|
-
table: 'table_name',
|
|
144
|
-
view: 'default'
|
|
145
|
-
},
|
|
146
|
-
requiredPermissions: ['admin'],
|
|
147
|
-
riskLevel: 'medium',
|
|
148
|
-
fallbackInstructions: [
|
|
149
|
-
'Navigate to System UI > Forms',
|
|
150
|
-
'Find or create form for target table',
|
|
151
|
-
'Configure form sections and field layout',
|
|
152
|
-
'Set view name and save'
|
|
153
|
-
]
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
{
|
|
157
|
-
requirementType: 'form_section',
|
|
158
|
-
automationMethod: 'createFormSection',
|
|
159
|
-
apiEndpoint: '/api/now/table/sys_ui_form_section',
|
|
160
|
-
parameters: {
|
|
161
|
-
sys_ui_form: 'form_sys_id',
|
|
162
|
-
caption: 'Section Caption',
|
|
163
|
-
position: 0
|
|
164
|
-
},
|
|
165
|
-
requiredPermissions: ['admin'],
|
|
166
|
-
riskLevel: 'low',
|
|
167
|
-
fallbackInstructions: [
|
|
168
|
-
'Navigate to target form',
|
|
169
|
-
'Right-click in design mode',
|
|
170
|
-
'Select "Add Section"',
|
|
171
|
-
'Set caption and position'
|
|
172
|
-
]
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
// Authentication and Security
|
|
176
|
-
{
|
|
177
|
-
requirementType: 'oauth_provider',
|
|
178
|
-
automationMethod: 'createOAuthProvider',
|
|
179
|
-
apiEndpoint: '/api/now/table/oauth_entity',
|
|
180
|
-
parameters: {
|
|
181
|
-
name: 'OAuth Provider',
|
|
182
|
-
client_id: 'client_id',
|
|
183
|
-
client_secret: 'client_secret',
|
|
184
|
-
default_grant_type: 'authorization_code'
|
|
185
|
-
},
|
|
186
|
-
requiredPermissions: ['security_admin'],
|
|
187
|
-
riskLevel: 'high',
|
|
188
|
-
fallbackInstructions: [
|
|
189
|
-
'Navigate to System OAuth > Application Registry',
|
|
190
|
-
'Create new OAuth API endpoint for external clients',
|
|
191
|
-
'Configure client credentials and grant types',
|
|
192
|
-
'Set redirect URIs and scopes',
|
|
193
|
-
'TEST THOROUGHLY in development!'
|
|
194
|
-
]
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
// Email and Notifications
|
|
198
|
-
{
|
|
199
|
-
requirementType: 'email_template',
|
|
200
|
-
automationMethod: 'createEmailTemplate',
|
|
201
|
-
apiEndpoint: '/api/now/table/sysevent_email_template',
|
|
202
|
-
parameters: {
|
|
203
|
-
name: 'Template Name',
|
|
204
|
-
subject: 'Email Subject',
|
|
205
|
-
message: 'Email Body Template',
|
|
206
|
-
type: 'email'
|
|
207
|
-
},
|
|
208
|
-
requiredPermissions: ['notification_admin'],
|
|
209
|
-
riskLevel: 'low',
|
|
210
|
-
fallbackInstructions: [
|
|
211
|
-
'Navigate to System Notification > Email > Templates',
|
|
212
|
-
'Click New',
|
|
213
|
-
'Set Name, Subject, and Message body',
|
|
214
|
-
'Use variables like ${field_name} for dynamic content'
|
|
215
|
-
]
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
// Workflow and Process
|
|
219
|
-
{
|
|
220
|
-
requirementType: 'sla_definition',
|
|
221
|
-
automationMethod: 'createSLADefinition',
|
|
222
|
-
apiEndpoint: '/api/now/table/contract_sla',
|
|
223
|
-
parameters: {
|
|
224
|
-
name: 'SLA Name',
|
|
225
|
-
table: 'incident',
|
|
226
|
-
duration_type: 'calendar',
|
|
227
|
-
duration: '24 00:00:00'
|
|
228
|
-
},
|
|
229
|
-
requiredPermissions: ['sla_admin'],
|
|
230
|
-
riskLevel: 'medium',
|
|
231
|
-
fallbackInstructions: [
|
|
232
|
-
'Navigate to Service Level Management > SLA > Definitions',
|
|
233
|
-
'Click New',
|
|
234
|
-
'Set Name, Table, and Duration',
|
|
235
|
-
'Configure Start and Stop conditions',
|
|
236
|
-
'Set Schedule and Time Zone'
|
|
237
|
-
]
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
// Integration
|
|
241
|
-
{
|
|
242
|
-
requirementType: 'web_service',
|
|
243
|
-
automationMethod: 'createWebService',
|
|
244
|
-
apiEndpoint: '/api/now/table/sys_web_service',
|
|
245
|
-
parameters: {
|
|
246
|
-
name: 'Web Service Name',
|
|
247
|
-
namespace: 'http://www.service-now.com/',
|
|
248
|
-
wsdl: 'WSDL_URL'
|
|
249
|
-
},
|
|
250
|
-
requiredPermissions: ['web_service_admin'],
|
|
251
|
-
riskLevel: 'medium',
|
|
252
|
-
fallbackInstructions: [
|
|
253
|
-
'Navigate to System Web Services > Inbound > SOAP',
|
|
254
|
-
'Click New',
|
|
255
|
-
'Set Name and Namespace',
|
|
256
|
-
'Import WSDL or define operations manually'
|
|
257
|
-
]
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
// Performance and Monitoring
|
|
261
|
-
{
|
|
262
|
-
requirementType: 'performance_analytics',
|
|
263
|
-
automationMethod: 'createPerformanceAnalytics',
|
|
264
|
-
apiEndpoint: '/api/now/table/pa_cube',
|
|
265
|
-
parameters: {
|
|
266
|
-
name: 'Analytics Cube',
|
|
267
|
-
table: 'source_table',
|
|
268
|
-
description: 'Analytics description'
|
|
269
|
-
},
|
|
270
|
-
requiredPermissions: ['pa_admin'],
|
|
271
|
-
riskLevel: 'medium',
|
|
272
|
-
fallbackInstructions: [
|
|
273
|
-
'Navigate to Performance Analytics > Data Collector > Cubes',
|
|
274
|
-
'Click New',
|
|
275
|
-
'Set Name, Source Table, and Collection schedule',
|
|
276
|
-
'Define Dimensions and Measures'
|
|
277
|
-
]
|
|
278
|
-
}
|
|
279
|
-
];
|
|
280
|
-
|
|
281
|
-
export class AutoResolutionEngine {
|
|
282
|
-
private mcpTools: any;
|
|
283
|
-
private logger: any;
|
|
284
|
-
private autoPermissions: boolean;
|
|
285
|
-
|
|
286
|
-
constructor(mcpTools: any, logger: any, autoPermissions = false) {
|
|
287
|
-
this.mcpTools = mcpTools;
|
|
288
|
-
this.logger = logger;
|
|
289
|
-
this.autoPermissions = autoPermissions;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Attempt to automatically resolve a single requirement
|
|
294
|
-
*/
|
|
295
|
-
async resolveRequirement(requirement: ServiceNowRequirement): Promise<ResolutionResult> {
|
|
296
|
-
const startTime = Date.now();
|
|
297
|
-
|
|
298
|
-
try {
|
|
299
|
-
this.logger.info(`🔧 Attempting auto-resolution for: ${requirement.type} - ${requirement.name}`);
|
|
300
|
-
|
|
301
|
-
// Check if we have an automation strategy
|
|
302
|
-
const strategy = this.findResolutionStrategy(requirement.type);
|
|
303
|
-
if (!strategy) {
|
|
304
|
-
return this.createManualResult(requirement, 'No automation strategy available');
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Check capabilities with MCP Coverage Analyzer
|
|
308
|
-
const capability = McpCoverageAnalyzer.analyzeAutomationCapability(requirement);
|
|
309
|
-
|
|
310
|
-
// If MCP tools can handle it, use them instead
|
|
311
|
-
if (capability.canAutomate && capability.automationTool) {
|
|
312
|
-
this.logger.info(`🎯 Using MCP tool: ${capability.automationTool}`);
|
|
313
|
-
return await this.executeMcpResolution(requirement, capability);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Check permissions
|
|
317
|
-
if (!this.autoPermissions && strategy.riskLevel === 'high') {
|
|
318
|
-
return this.createManualResult(
|
|
319
|
-
requirement,
|
|
320
|
-
'High-risk operation requires manual approval',
|
|
321
|
-
strategy.fallbackInstructions
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// Attempt direct ServiceNow API resolution
|
|
326
|
-
const result = await this.executeDirectResolution(requirement, strategy);
|
|
327
|
-
|
|
328
|
-
result.timeElapsed = Date.now() - startTime;
|
|
329
|
-
return result;
|
|
330
|
-
|
|
331
|
-
} catch (error) {
|
|
332
|
-
this.logger.error(`❌ Auto-resolution failed for ${requirement.type}:`, error);
|
|
333
|
-
|
|
334
|
-
return {
|
|
335
|
-
requirement,
|
|
336
|
-
status: 'failed',
|
|
337
|
-
errorMessage: error instanceof Error ? error.message : 'Unknown error',
|
|
338
|
-
timeElapsed: Date.now() - startTime,
|
|
339
|
-
fallbackStrategy: 'Manual configuration required'
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Resolve multiple requirements in optimized order
|
|
346
|
-
*/
|
|
347
|
-
async resolveBulk(requirements: ServiceNowRequirement[]): Promise<BulkResolutionResult> {
|
|
348
|
-
const startTime = Date.now();
|
|
349
|
-
const results: ResolutionResult[] = [];
|
|
350
|
-
|
|
351
|
-
this.logger.info(`🚀 Starting bulk resolution of ${requirements.length} requirements`);
|
|
352
|
-
|
|
353
|
-
// Generate automation strategy
|
|
354
|
-
const strategy = McpCoverageAnalyzer.generateAutomationStrategy(requirements);
|
|
355
|
-
|
|
356
|
-
// Process automatable requirements first
|
|
357
|
-
for (const req of strategy.automatable) {
|
|
358
|
-
const result = await this.resolveRequirement(req);
|
|
359
|
-
results.push(result);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// Create manual results for non-automatable requirements
|
|
363
|
-
for (const req of strategy.manual) {
|
|
364
|
-
const manualResult = this.createManualResult(
|
|
365
|
-
req,
|
|
366
|
-
'Requires manual configuration',
|
|
367
|
-
this.generateManualInstructions(req)
|
|
368
|
-
);
|
|
369
|
-
results.push(manualResult);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Categorize results
|
|
373
|
-
const successful = results.filter(r => r.status === 'success');
|
|
374
|
-
const failed = results.filter(r => r.status === 'failed');
|
|
375
|
-
const manual = results.filter(r => r.status === 'manual_required');
|
|
376
|
-
|
|
377
|
-
const totalTime = Date.now() - startTime;
|
|
378
|
-
const successRate = Math.round((successful.length / results.length) * 100);
|
|
379
|
-
|
|
380
|
-
const recommendations = this.generateBulkRecommendations(successful, failed, manual);
|
|
381
|
-
|
|
382
|
-
this.logger.info(`✅ Bulk resolution complete: ${successful.length}/${results.length} automated`);
|
|
383
|
-
|
|
384
|
-
return {
|
|
385
|
-
successful,
|
|
386
|
-
failed,
|
|
387
|
-
manual,
|
|
388
|
-
totalTime,
|
|
389
|
-
successRate,
|
|
390
|
-
recommendations
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Get available resolution strategies for a requirement type
|
|
396
|
-
*/
|
|
397
|
-
getResolutionStrategies(requirementType: RequirementType): ResolutionStrategy[] {
|
|
398
|
-
return AUTO_RESOLUTION_STRATEGIES.filter(s => s.requirementType === requirementType);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Check if a requirement can be auto-resolved
|
|
403
|
-
*/
|
|
404
|
-
canAutoResolve(requirement: ServiceNowRequirement): boolean {
|
|
405
|
-
// Check MCP coverage first
|
|
406
|
-
const capability = McpCoverageAnalyzer.analyzeAutomationCapability(requirement);
|
|
407
|
-
if (capability.canAutomate) {
|
|
408
|
-
return true;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// Check direct automation strategies
|
|
412
|
-
const strategy = this.findResolutionStrategy(requirement.type);
|
|
413
|
-
if (!strategy) {
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// High-risk operations require manual approval unless auto-permissions enabled
|
|
418
|
-
if (strategy.riskLevel === 'high' && !this.autoPermissions) {
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return true;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// Private helper methods
|
|
426
|
-
|
|
427
|
-
private findResolutionStrategy(requirementType: RequirementType): ResolutionStrategy | undefined {
|
|
428
|
-
return AUTO_RESOLUTION_STRATEGIES.find(s => s.requirementType === requirementType);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
private async executeMcpResolution(
|
|
432
|
-
requirement: ServiceNowRequirement,
|
|
433
|
-
capability: AutomationCapability
|
|
434
|
-
): Promise<ResolutionResult> {
|
|
435
|
-
try {
|
|
436
|
-
// This would call the appropriate MCP tool
|
|
437
|
-
// Implementation depends on the specific tool structure
|
|
438
|
-
|
|
439
|
-
this.logger.info(`🎯 Executing MCP tool: ${capability.automationTool}`);
|
|
440
|
-
|
|
441
|
-
// Placeholder for MCP tool execution
|
|
442
|
-
// In reality, this would call the appropriate MCP function
|
|
443
|
-
|
|
444
|
-
return {
|
|
445
|
-
requirement,
|
|
446
|
-
status: 'success',
|
|
447
|
-
automationUsed: capability.automationTool,
|
|
448
|
-
sysId: 'generated_sys_id',
|
|
449
|
-
manualSteps: []
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
} catch (error) {
|
|
453
|
-
return {
|
|
454
|
-
requirement,
|
|
455
|
-
status: 'failed',
|
|
456
|
-
errorMessage: `MCP tool failed: ${error}`,
|
|
457
|
-
fallbackStrategy: 'Use manual configuration'
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
private async executeDirectResolution(
|
|
463
|
-
requirement: ServiceNowRequirement,
|
|
464
|
-
strategy: ResolutionStrategy
|
|
465
|
-
): Promise<ResolutionResult> {
|
|
466
|
-
try {
|
|
467
|
-
this.logger.info(`🔧 Executing direct resolution: ${strategy.automationMethod}`);
|
|
468
|
-
|
|
469
|
-
// Build API request parameters
|
|
470
|
-
const requestData = this.buildRequestData(requirement, strategy);
|
|
471
|
-
|
|
472
|
-
// Make ServiceNow API call
|
|
473
|
-
const response = await this.makeServiceNowAPICall(strategy.apiEndpoint!, requestData);
|
|
474
|
-
|
|
475
|
-
if (response.success) {
|
|
476
|
-
return {
|
|
477
|
-
requirement,
|
|
478
|
-
status: 'success',
|
|
479
|
-
automationUsed: strategy.automationMethod,
|
|
480
|
-
sysId: response.result?.sys_id,
|
|
481
|
-
manualSteps: []
|
|
482
|
-
};
|
|
483
|
-
} else {
|
|
484
|
-
return {
|
|
485
|
-
requirement,
|
|
486
|
-
status: 'failed',
|
|
487
|
-
errorMessage: response.error || 'API call failed',
|
|
488
|
-
manualSteps: strategy.fallbackInstructions
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
} catch (error) {
|
|
493
|
-
return {
|
|
494
|
-
requirement,
|
|
495
|
-
status: 'failed',
|
|
496
|
-
errorMessage: error instanceof Error ? error.message : 'Unknown error',
|
|
497
|
-
manualSteps: strategy.fallbackInstructions
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
private buildRequestData(
|
|
503
|
-
requirement: ServiceNowRequirement,
|
|
504
|
-
strategy: ResolutionStrategy
|
|
505
|
-
): Record<string, any> {
|
|
506
|
-
const data: Record<string, any> = {};
|
|
507
|
-
|
|
508
|
-
// Map requirement properties to API parameters
|
|
509
|
-
for (const [param, defaultValue] of Object.entries(strategy.parameters)) {
|
|
510
|
-
if ((requirement as any).properties && (requirement as any).properties[param]) {
|
|
511
|
-
data[param] = (requirement as any).properties[param];
|
|
512
|
-
} else if (param === 'name') {
|
|
513
|
-
data[param] = requirement.name;
|
|
514
|
-
} else if (param === 'description') {
|
|
515
|
-
data[param] = requirement.description || requirement.name;
|
|
516
|
-
} else {
|
|
517
|
-
data[param] = defaultValue;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
return data;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
private async makeServiceNowAPICall(
|
|
525
|
-
endpoint: string,
|
|
526
|
-
data: Record<string, any>
|
|
527
|
-
): Promise<{success: boolean; result?: any; error?: string}> {
|
|
528
|
-
try {
|
|
529
|
-
// This would make the actual ServiceNow API call
|
|
530
|
-
// Implementation depends on the ServiceNow client setup
|
|
531
|
-
|
|
532
|
-
this.logger.info(`📡 Making API call to: ${endpoint}`);
|
|
533
|
-
|
|
534
|
-
// Placeholder for actual API implementation
|
|
535
|
-
// In reality, this would use the ServiceNow REST client
|
|
536
|
-
|
|
537
|
-
return {
|
|
538
|
-
success: true,
|
|
539
|
-
result: {
|
|
540
|
-
sys_id: 'generated_sys_id_' + Date.now(),
|
|
541
|
-
...data
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
} catch (error) {
|
|
546
|
-
return {
|
|
547
|
-
success: false,
|
|
548
|
-
error: error instanceof Error ? error.message : 'API call failed'
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
private createManualResult(
|
|
554
|
-
requirement: ServiceNowRequirement,
|
|
555
|
-
reason: string,
|
|
556
|
-
instructions?: string[]
|
|
557
|
-
): ResolutionResult {
|
|
558
|
-
return {
|
|
559
|
-
requirement,
|
|
560
|
-
status: 'manual_required',
|
|
561
|
-
manualSteps: instructions || this.generateManualInstructions(requirement),
|
|
562
|
-
errorMessage: reason
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
private generateManualInstructions(requirement: ServiceNowRequirement): string[] {
|
|
567
|
-
const strategy = this.findResolutionStrategy(requirement.type);
|
|
568
|
-
|
|
569
|
-
if (strategy) {
|
|
570
|
-
return strategy.fallbackInstructions;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// Generic fallback instructions
|
|
574
|
-
return [
|
|
575
|
-
`Manual configuration required for: ${requirement.type}`,
|
|
576
|
-
`Navigate to appropriate ServiceNow application`,
|
|
577
|
-
`Create new ${requirement.type} with name: ${requirement.name}`,
|
|
578
|
-
`Configure according to business requirements`,
|
|
579
|
-
`Test thoroughly before production deployment`
|
|
580
|
-
];
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
private generateBulkRecommendations(
|
|
584
|
-
successful: ResolutionResult[],
|
|
585
|
-
failed: ResolutionResult[],
|
|
586
|
-
manual: ResolutionResult[]
|
|
587
|
-
): string[] {
|
|
588
|
-
const recommendations: string[] = [];
|
|
589
|
-
|
|
590
|
-
if (successful.length > 0) {
|
|
591
|
-
recommendations.push(`✅ Successfully automated ${successful.length} configurations`);
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
if (failed.length > 0) {
|
|
595
|
-
recommendations.push(`❌ ${failed.length} automations failed - check permissions and connectivity`);
|
|
596
|
-
|
|
597
|
-
// Analyze failure patterns
|
|
598
|
-
const failureReasons = failed.map(f => f.errorMessage).filter(Boolean);
|
|
599
|
-
const uniqueReasons = [...new Set(failureReasons)];
|
|
600
|
-
if (uniqueReasons.length > 0) {
|
|
601
|
-
recommendations.push(`🔍 Common failure reasons: ${uniqueReasons.slice(0, 3).join(', ')}`);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
if (manual.length > 0) {
|
|
606
|
-
recommendations.push(`📋 ${manual.length} configurations require manual setup`);
|
|
607
|
-
|
|
608
|
-
// Group manual items by type
|
|
609
|
-
const manualTypes = manual.map(m => m.requirement.type);
|
|
610
|
-
const typeCounts = manualTypes.reduce((acc, type) => {
|
|
611
|
-
acc[type] = (acc[type] || 0) + 1;
|
|
612
|
-
return acc;
|
|
613
|
-
}, {} as Record<string, number>);
|
|
614
|
-
|
|
615
|
-
const topTypes = Object.entries(typeCounts)
|
|
616
|
-
.sort(([,a], [,b]) => b - a)
|
|
617
|
-
.slice(0, 3)
|
|
618
|
-
.map(([type, count]) => `${count} ${type}`)
|
|
619
|
-
.join(', ');
|
|
620
|
-
|
|
621
|
-
if (topTypes) {
|
|
622
|
-
recommendations.push(`📊 Manual work needed for: ${topTypes}`);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// Strategic recommendations
|
|
627
|
-
const automationRate = successful.length / (successful.length + failed.length + manual.length);
|
|
628
|
-
|
|
629
|
-
if (automationRate < 0.3) {
|
|
630
|
-
recommendations.push('💡 Consider enabling auto-permissions to increase automation');
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
if (failed.length > successful.length) {
|
|
634
|
-
recommendations.push('🔧 Check ServiceNow permissions and connectivity');
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
if (manual.length > 0) {
|
|
638
|
-
recommendations.push('📚 Review manual instructions and consider creating custom MCP tools');
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
return recommendations;
|
|
642
|
-
}
|
|
643
|
-
}
|