snow-flow 1.1.76 → 1.1.78
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-flow/queen/queen-memory.db +0 -0
- package/CLAUDE.md +34 -5
- package/README.md +256 -384
- package/dist/agents/base-agent.d.ts +92 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +228 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/coordinator.d.ts +200 -0
- package/dist/agents/coordinator.d.ts.map +1 -0
- package/dist/agents/coordinator.js +775 -0
- package/dist/agents/coordinator.js.map +1 -0
- package/dist/agents/flow-builder-agent.d.ts +18 -0
- package/dist/agents/flow-builder-agent.d.ts.map +1 -0
- package/dist/agents/flow-builder-agent.js +536 -0
- package/dist/agents/flow-builder-agent.js.map +1 -0
- package/dist/agents/index.d.ts +18 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +61 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/queen-agent-example.d.ts +23 -0
- package/dist/agents/queen-agent-example.d.ts.map +1 -0
- package/dist/agents/queen-agent-example.js +241 -0
- package/dist/agents/queen-agent-example.js.map +1 -0
- package/dist/agents/queen-agent.d.ts +180 -0
- package/dist/agents/queen-agent.d.ts.map +1 -0
- package/dist/agents/queen-agent.js +909 -0
- package/dist/agents/queen-agent.js.map +1 -0
- package/dist/agents/queen-agent.test.d.ts +6 -0
- package/dist/agents/queen-agent.test.d.ts.map +1 -0
- package/dist/agents/queen-agent.test.js.map +1 -0
- package/dist/agents/script-writer-agent.d.ts +22 -0
- package/dist/agents/script-writer-agent.d.ts.map +1 -0
- package/dist/agents/script-writer-agent.js +695 -0
- package/dist/agents/script-writer-agent.js.map +1 -0
- package/dist/agents/security-agent.d.ts +23 -0
- package/dist/agents/security-agent.d.ts.map +1 -0
- package/dist/agents/security-agent.js +619 -0
- package/dist/agents/security-agent.js.map +1 -0
- package/dist/agents/test-agent.d.ts +26 -0
- package/dist/agents/test-agent.d.ts.map +1 -0
- package/dist/agents/test-agent.js +735 -0
- package/dist/agents/test-agent.js.map +1 -0
- package/dist/agents/test-agents.d.ts +7 -0
- package/dist/agents/test-agents.d.ts.map +1 -0
- package/dist/agents/test-agents.js +65 -0
- package/dist/agents/test-agents.js.map +1 -0
- package/dist/agents/widget-creator-agent.d.ts +18 -0
- package/dist/agents/widget-creator-agent.d.ts.map +1 -0
- package/dist/agents/widget-creator-agent.js +440 -0
- package/dist/agents/widget-creator-agent.js.map +1 -0
- package/dist/cli/snow-flow-cli-integration.d.ts +30 -0
- package/dist/cli/snow-flow-cli-integration.d.ts.map +1 -0
- package/dist/cli/snow-flow-cli-integration.js +385 -0
- package/dist/cli/snow-flow-cli-integration.js.map +1 -0
- package/dist/cli.js +466 -150
- package/dist/cli.js.map +1 -1
- package/dist/config/snow-flow-config.d.ts +1454 -0
- package/dist/config/snow-flow-config.d.ts.map +1 -0
- package/dist/config/snow-flow-config.js +403 -0
- package/dist/config/snow-flow-config.js.map +1 -0
- package/dist/health/system-health.d.ts +123 -0
- package/dist/health/system-health.d.ts.map +1 -0
- package/dist/health/system-health.js +580 -0
- package/dist/health/system-health.js.map +1 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/servicenow-deployment-mcp-refactored.d.ts +58 -0
- package/dist/mcp/servicenow-deployment-mcp-refactored.d.ts.map +1 -0
- package/dist/mcp/servicenow-deployment-mcp-refactored.js +651 -0
- package/dist/mcp/servicenow-deployment-mcp-refactored.js.map +1 -0
- package/dist/mcp/servicenow-intelligent-mcp-refactored.d.ts +43 -0
- package/dist/mcp/servicenow-intelligent-mcp-refactored.d.ts.map +1 -0
- package/dist/mcp/servicenow-intelligent-mcp-refactored.js +576 -0
- package/dist/mcp/servicenow-intelligent-mcp-refactored.js.map +1 -0
- package/dist/mcp/servicenow-intelligent-mcp.d.ts +102 -1
- package/dist/mcp/servicenow-intelligent-mcp.d.ts.map +1 -1
- package/dist/mcp/servicenow-intelligent-mcp.js +2 -0
- package/dist/mcp/servicenow-intelligent-mcp.js.map +1 -1
- package/dist/mcp/shared/agent-context-provider.d.ts +77 -0
- package/dist/mcp/shared/agent-context-provider.d.ts.map +1 -0
- package/dist/mcp/shared/agent-context-provider.js +292 -0
- package/dist/mcp/shared/agent-context-provider.js.map +1 -0
- package/dist/mcp/shared/base-mcp-server.d.ts +97 -0
- package/dist/mcp/shared/base-mcp-server.d.ts.map +1 -0
- package/dist/mcp/shared/base-mcp-server.js +216 -0
- package/dist/mcp/shared/base-mcp-server.js.map +1 -0
- package/dist/mcp/shared/mcp-memory-manager.d.ts +87 -0
- package/dist/mcp/shared/mcp-memory-manager.d.ts.map +1 -0
- package/dist/mcp/shared/mcp-memory-manager.js +423 -0
- package/dist/mcp/shared/mcp-memory-manager.js.map +1 -0
- package/dist/memory/index.d.ts +9 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +20 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/mcp-integration-example.d.ts +6 -0
- package/dist/memory/mcp-integration-example.d.ts.map +1 -0
- package/dist/memory/mcp-integration-example.js +282 -0
- package/dist/memory/mcp-integration-example.js.map +1 -0
- package/dist/memory/memory-client.d.ts +184 -0
- package/dist/memory/memory-client.d.ts.map +1 -0
- package/dist/memory/memory-client.js +325 -0
- package/dist/memory/memory-client.js.map +1 -0
- package/dist/memory/memory-operations.d.ts +170 -0
- package/dist/memory/memory-operations.d.ts.map +1 -0
- package/dist/memory/memory-operations.js +639 -0
- package/dist/memory/memory-operations.js.map +1 -0
- package/dist/memory/memory-system.d.ts +118 -0
- package/dist/memory/memory-system.d.ts.map +1 -0
- package/dist/memory/memory-system.js +477 -0
- package/dist/memory/memory-system.js.map +1 -0
- package/dist/memory/memory-test.d.ts +6 -0
- package/dist/memory/memory-test.d.ts.map +1 -0
- package/dist/memory/memory-test.js +162 -0
- package/dist/memory/memory-test.js.map +1 -0
- package/dist/memory/swarm-memory.d.ts +135 -0
- package/dist/memory/swarm-memory.d.ts.map +1 -0
- package/dist/memory/swarm-memory.js +378 -0
- package/dist/memory/swarm-memory.js.map +1 -0
- package/dist/monitoring/performance-tracker.d.ts +157 -0
- package/dist/monitoring/performance-tracker.d.ts.map +1 -0
- package/dist/monitoring/performance-tracker.js +571 -0
- package/dist/monitoring/performance-tracker.js.map +1 -0
- package/dist/queen/agent-factory.d.ts +3 -0
- package/dist/queen/agent-factory.d.ts.map +1 -1
- package/dist/queen/agent-factory.js +52 -0
- package/dist/queen/agent-factory.js.map +1 -1
- package/dist/queen/queen-memory.d.ts +8 -2
- package/dist/queen/queen-memory.d.ts.map +1 -1
- package/dist/queen/queen-memory.js +46 -4
- package/dist/queen/queen-memory.js.map +1 -1
- package/dist/snow-flow-system.d.ts +132 -0
- package/dist/snow-flow-system.d.ts.map +1 -0
- package/dist/snow-flow-system.js +396 -0
- package/dist/snow-flow-system.js.map +1 -0
- package/dist/types/todo.types.d.ts +61 -0
- package/dist/types/todo.types.d.ts.map +1 -0
- package/dist/types/todo.types.js +7 -0
- package/dist/types/todo.types.js.map +1 -0
- package/dist/utils/error-recovery.d.ts +101 -0
- package/dist/utils/error-recovery.d.ts.map +1 -0
- package/dist/utils/error-recovery.js +548 -0
- package/dist/utils/error-recovery.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -2
- package/deploy.sh +0 -366
- package/docker/base/Dockerfile.base +0 -45
- package/docker/generate-services.js +0 -244
- package/docker/nginx/Dockerfile +0 -71
- package/docker/nginx/consul-template.hcl +0 -64
- package/docker/nginx/healthcheck.sh +0 -178
- package/docker/nginx/nginx.conf +0 -210
- package/docker/nginx/supervisord.conf +0 -57
- package/docker/nginx/templates/upstreams.conf.tpl +0 -48
- package/docker/services/automation-mcp/Dockerfile +0 -32
- package/docker/services/automation-mcp/config/service.json +0 -28
- package/docker/services/automation-mcp/entrypoint.js +0 -51
- package/docker/services/deployment-mcp/Dockerfile +0 -32
- package/docker/services/deployment-mcp/entrypoint.js +0 -51
- package/docker/services/flow-composer-mcp/Dockerfile +0 -32
- package/docker/services/flow-composer-mcp/config/service.json +0 -28
- package/docker/services/flow-composer-mcp/entrypoint.js +0 -51
- package/docker/services/graph-memory-mcp/Dockerfile +0 -32
- package/docker/services/graph-memory-mcp/config/service.json +0 -28
- package/docker/services/graph-memory-mcp/entrypoint.js +0 -51
- package/docker/services/integration-mcp/Dockerfile +0 -32
- package/docker/services/integration-mcp/config/service.json +0 -28
- package/docker/services/integration-mcp/entrypoint.js +0 -51
- package/docker/services/intelligent-mcp/Dockerfile +0 -32
- package/docker/services/intelligent-mcp/config/service.json +0 -28
- package/docker/services/intelligent-mcp/entrypoint.js +0 -51
- package/docker/services/operations-mcp/Dockerfile +0 -32
- package/docker/services/operations-mcp/config/service.json +0 -28
- package/docker/services/operations-mcp/entrypoint.js +0 -51
- package/docker/services/platform-development-mcp/Dockerfile +0 -32
- package/docker/services/platform-development-mcp/config/service.json +0 -28
- package/docker/services/platform-development-mcp/entrypoint.js +0 -51
- package/docker/services/reporting-analytics-mcp/Dockerfile +0 -32
- package/docker/services/reporting-analytics-mcp/config/service.json +0 -28
- package/docker/services/reporting-analytics-mcp/entrypoint.js +0 -51
- package/docker/services/security-compliance-mcp/Dockerfile +0 -32
- package/docker/services/security-compliance-mcp/config/service.json +0 -28
- package/docker/services/security-compliance-mcp/entrypoint.js +0 -51
- package/docker/services/update-set-mcp/Dockerfile +0 -32
- package/docker/services/update-set-mcp/config/service.json +0 -28
- package/docker/services/update-set-mcp/entrypoint.js +0 -51
- package/docker-compose.override.yml +0 -132
- package/docker-compose.prod.yml +0 -340
- package/docker-compose.yml +0 -579
- package/k8s/automation-mcp.yaml +0 -232
- package/k8s/configmap.yaml +0 -237
- package/k8s/deployment-mcp.yaml +0 -232
- package/k8s/flow-composer-mcp.yaml +0 -232
- package/k8s/generate-k8s-manifests.js +0 -453
- package/k8s/graph-memory-mcp.yaml +0 -232
- package/k8s/infrastructure.yaml +0 -456
- package/k8s/ingress.yaml +0 -361
- package/k8s/integration-mcp.yaml +0 -232
- package/k8s/intelligent-mcp.yaml +0 -232
- package/k8s/kustomization.yaml +0 -111
- package/k8s/mcp-services.yaml +0 -2552
- package/k8s/monitoring.yaml +0 -515
- package/k8s/namespace.yaml +0 -80
- package/k8s/operations-mcp.yaml +0 -232
- package/k8s/platform-development-mcp.yaml +0 -232
- package/k8s/rbac.yaml +0 -140
- package/k8s/reporting-analytics-mcp.yaml +0 -232
- package/k8s/security-compliance-mcp.yaml +0 -232
- package/k8s/update-set-mcp.yaml +0 -232
- package/test-clean-install/.claude/config.json +0 -12
- package/test-clean-install/.env.example +0 -49
- package/test-clean-install/CLAUDE.md +0 -26
- package/test-clean-install/README.md +0 -23
- package/test-global-install/.claude/config.json +0 -12
- package/test-global-install/CLAUDE.md +0 -26
- package/test-global-install/README.md +0 -23
- package/test-global-install/test-global-install/.claude/config.json +0 -12
- package/test-global-install/test-global-install/CLAUDE.md +0 -26
- package/test-global-install/test-global-install/README.md +0 -23
- package/test-global-install/test-global-install/test-global-install/.claude/config.json +0 -12
- package/test-global-install/test-global-install/test-global-install/.env.example +0 -49
- package/test-global-install/test-global-install/test-global-install/CLAUDE.md +0 -26
- package/test-global-install/test-global-install/test-global-install/README.md +0 -23
- package/test-init-debug/.claude/config.json +0 -12
- package/test-init-debug/CLAUDE.md +0 -693
- package/test-init-debug/README.md +0 -392
- package/test-init-real/.claude/config.json +0 -12
- package/test-init-real/.claude/mcp-config.json +0 -128
- package/test-init-real/.claude/settings.json +0 -37
- package/test-init-real/CLAUDE.md +0 -693
- package/test-init-real/README.md +0 -392
- package/test-init-real/activate-mcp.sh +0 -15
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* ServiceNow Deployment MCP Server - Agent-Integrated Version
|
|
5
|
+
* Provides specialized deployment tools with full agent coordination
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ServiceNowDeploymentMCP = void 0;
|
|
9
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
10
|
+
const base_mcp_server_js_1 = require("./shared/base-mcp-server.js");
|
|
11
|
+
const scope_manager_js_1 = require("../managers/scope-manager.js");
|
|
12
|
+
const global_scope_strategy_js_1 = require("../strategies/global-scope-strategy.js");
|
|
13
|
+
const artifact_tracker_js_1 = require("../utils/artifact-tracker.js");
|
|
14
|
+
class ServiceNowDeploymentMCP extends base_mcp_server_js_1.BaseMCPServer {
|
|
15
|
+
constructor() {
|
|
16
|
+
super('servicenow-deployment', '2.0.0');
|
|
17
|
+
// Initialize scope management
|
|
18
|
+
this.scopeManager = new scope_manager_js_1.ScopeManager({
|
|
19
|
+
defaultScope: global_scope_strategy_js_1.ScopeType.GLOBAL,
|
|
20
|
+
allowFallback: true,
|
|
21
|
+
validatePermissions: true,
|
|
22
|
+
enableMigration: false
|
|
23
|
+
});
|
|
24
|
+
this.globalScopeStrategy = new global_scope_strategy_js_1.GlobalScopeStrategy();
|
|
25
|
+
// Start artifact tracking session
|
|
26
|
+
artifact_tracker_js_1.artifactTracker.startSession();
|
|
27
|
+
this.setupHandlers();
|
|
28
|
+
}
|
|
29
|
+
setupHandlers() {
|
|
30
|
+
// Define available tools
|
|
31
|
+
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
32
|
+
tools: [
|
|
33
|
+
{
|
|
34
|
+
name: 'snow_deploy',
|
|
35
|
+
description: 'AGENT-AWARE DEPLOYMENT - Complete deployment workflow with automatic update set management, agent coordination, and memory integration',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
type: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
enum: ['widget', 'flow', 'application', 'script', 'business_rule', 'table', 'batch'],
|
|
42
|
+
description: 'Type of artifact to deploy'
|
|
43
|
+
},
|
|
44
|
+
instruction: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Natural language instruction for what to create (for flows/widgets)'
|
|
47
|
+
},
|
|
48
|
+
config: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
description: 'Artifact configuration (alternative to instruction for direct config)'
|
|
51
|
+
},
|
|
52
|
+
artifacts: {
|
|
53
|
+
type: 'array',
|
|
54
|
+
description: 'For batch deployments - array of artifacts',
|
|
55
|
+
items: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
type: { type: 'string' },
|
|
59
|
+
config: { type: 'object' },
|
|
60
|
+
instruction: { type: 'string' }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
// Agent context parameters
|
|
65
|
+
session_id: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Agent session ID for coordination'
|
|
68
|
+
},
|
|
69
|
+
agent_id: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'Deploying agent ID'
|
|
72
|
+
},
|
|
73
|
+
agent_type: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Type of agent performing deployment'
|
|
76
|
+
},
|
|
77
|
+
// Deployment options
|
|
78
|
+
auto_update_set: {
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
description: 'Automatically ensure active Update Set session (default: true)',
|
|
81
|
+
default: true
|
|
82
|
+
},
|
|
83
|
+
fallback_strategy: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
enum: ['manual_steps', 'update_set_only', 'none'],
|
|
86
|
+
description: 'Strategy when direct deployment fails (default: manual_steps)',
|
|
87
|
+
default: 'manual_steps'
|
|
88
|
+
},
|
|
89
|
+
permission_escalation: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
enum: ['auto_request', 'manual', 'none'],
|
|
92
|
+
description: 'How to handle permission errors (default: auto_request)',
|
|
93
|
+
default: 'auto_request'
|
|
94
|
+
},
|
|
95
|
+
deployment_context: {
|
|
96
|
+
type: 'string',
|
|
97
|
+
description: 'Context for Update Set naming (e.g., "incident widget", "approval flow")'
|
|
98
|
+
},
|
|
99
|
+
// Batch options
|
|
100
|
+
parallel: {
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
description: 'Deploy batch artifacts in parallel',
|
|
103
|
+
default: false
|
|
104
|
+
},
|
|
105
|
+
transaction_mode: {
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
description: 'All-or-nothing batch deployment',
|
|
108
|
+
default: true
|
|
109
|
+
},
|
|
110
|
+
dry_run: {
|
|
111
|
+
type: 'boolean',
|
|
112
|
+
description: 'Validate without deploying',
|
|
113
|
+
default: false
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
required: ['type']
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'snow_deployment_status',
|
|
121
|
+
description: 'Check deployment status and history with agent tracking',
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
session_id: { type: 'string', description: 'Session ID to filter by' },
|
|
126
|
+
limit: { type: 'number', description: 'Number of recent deployments to show', default: 10 },
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'snow_validate_deployment',
|
|
132
|
+
description: 'Validate a deployment before executing with agent coordination',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
type: { type: 'string', enum: ['widget', 'workflow', 'application'] },
|
|
137
|
+
artifact: { type: 'object', description: 'The artifact to validate' },
|
|
138
|
+
session_id: { type: 'string' },
|
|
139
|
+
agent_id: { type: 'string' }
|
|
140
|
+
},
|
|
141
|
+
required: ['type', 'artifact']
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'snow_rollback_deployment',
|
|
146
|
+
description: 'Rollback a deployment with agent coordination',
|
|
147
|
+
inputSchema: {
|
|
148
|
+
type: 'object',
|
|
149
|
+
properties: {
|
|
150
|
+
update_set_id: { type: 'string', description: 'Update set sys_id to rollback' },
|
|
151
|
+
reason: { type: 'string', description: 'Reason for rollback' },
|
|
152
|
+
session_id: { type: 'string' },
|
|
153
|
+
agent_id: { type: 'string' }
|
|
154
|
+
},
|
|
155
|
+
required: ['update_set_id', 'reason']
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
}));
|
|
160
|
+
// Handle tool calls
|
|
161
|
+
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
162
|
+
const { name, arguments: args } = request.params;
|
|
163
|
+
try {
|
|
164
|
+
switch (name) {
|
|
165
|
+
case 'snow_deploy':
|
|
166
|
+
return await this.deployWithAgentCoordination(args);
|
|
167
|
+
case 'snow_deployment_status':
|
|
168
|
+
return await this.getDeploymentStatusWithContext(args);
|
|
169
|
+
case 'snow_validate_deployment':
|
|
170
|
+
return await this.validateDeploymentWithContext(args);
|
|
171
|
+
case 'snow_rollback_deployment':
|
|
172
|
+
return await this.rollbackDeploymentWithContext(args);
|
|
173
|
+
default:
|
|
174
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
return this.createErrorResponse(`Tool execution failed: ${name}`, error);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Main deployment method with full agent integration
|
|
184
|
+
*/
|
|
185
|
+
async deployWithAgentCoordination(args) {
|
|
186
|
+
return await this.executeWithAgentContext('snow_deploy', args, async (context) => {
|
|
187
|
+
// Check authentication
|
|
188
|
+
if (!await this.checkAuthentication()) {
|
|
189
|
+
return this.createAuthenticationError();
|
|
190
|
+
}
|
|
191
|
+
// Assert no mock data
|
|
192
|
+
this.assertNoMockData('deployment');
|
|
193
|
+
// Get session context for coordination
|
|
194
|
+
const sessionContext = await this.getSessionContext(context.session_id);
|
|
195
|
+
// Report initial progress
|
|
196
|
+
await this.reportProgress(context, 10, 'Initializing deployment');
|
|
197
|
+
try {
|
|
198
|
+
// Handle different deployment types
|
|
199
|
+
if (args.type === 'batch') {
|
|
200
|
+
return await this.deployBatch(args, context);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return await this.deploySingleArtifact(args, context);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
// Request Queen intervention for critical errors
|
|
208
|
+
await this.requestQueenIntervention(context, {
|
|
209
|
+
type: 'deployment_failure',
|
|
210
|
+
priority: 'high',
|
|
211
|
+
description: `Failed to deploy ${args.type}: ${error instanceof Error ? error.message : String(error)}`,
|
|
212
|
+
attempted_solutions: ['direct_deployment', 'fallback_strategy']
|
|
213
|
+
});
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Deploy a single artifact with memory tracking
|
|
220
|
+
*/
|
|
221
|
+
async deploySingleArtifact(args, context) {
|
|
222
|
+
const { type, config, instruction } = args;
|
|
223
|
+
// Report planning phase
|
|
224
|
+
await this.reportProgress(context, 20, 'Planning deployment');
|
|
225
|
+
// Ensure update set if requested
|
|
226
|
+
let updateSetId;
|
|
227
|
+
if (args.auto_update_set !== false) {
|
|
228
|
+
const updateSetResult = await this.ensureUpdateSet(type, config?.name || 'artifact', context);
|
|
229
|
+
updateSetId = updateSetResult.updateSetId;
|
|
230
|
+
await this.reportProgress(context, 30, 'Update set ready');
|
|
231
|
+
}
|
|
232
|
+
// Deploy based on type
|
|
233
|
+
let result;
|
|
234
|
+
await this.reportProgress(context, 50, `Deploying ${type}`);
|
|
235
|
+
switch (type) {
|
|
236
|
+
case 'widget':
|
|
237
|
+
result = await this.deployWidget(config, context, updateSetId);
|
|
238
|
+
break;
|
|
239
|
+
case 'flow':
|
|
240
|
+
result = await this.deployFlow(config || { instruction }, context, updateSetId);
|
|
241
|
+
break;
|
|
242
|
+
case 'application':
|
|
243
|
+
result = await this.deployApplication(config, context, updateSetId);
|
|
244
|
+
break;
|
|
245
|
+
case 'script':
|
|
246
|
+
case 'business_rule':
|
|
247
|
+
result = await this.deployScript(type, config, context, updateSetId);
|
|
248
|
+
break;
|
|
249
|
+
default:
|
|
250
|
+
throw new Error(`Unsupported deployment type: ${type}`);
|
|
251
|
+
}
|
|
252
|
+
// Store artifact in memory
|
|
253
|
+
await this.storeArtifact(context, {
|
|
254
|
+
sys_id: result.sys_id,
|
|
255
|
+
type,
|
|
256
|
+
name: result.name || config?.name || 'unnamed',
|
|
257
|
+
description: config?.description,
|
|
258
|
+
config,
|
|
259
|
+
update_set_id: updateSetId
|
|
260
|
+
});
|
|
261
|
+
// Record deployment in history
|
|
262
|
+
await this.memory.recordDeployment(context.session_id, result.sys_id, type, true, context.agent_id);
|
|
263
|
+
await this.reportProgress(context, 90, 'Finalizing deployment');
|
|
264
|
+
// Notify next agent if needed
|
|
265
|
+
if (result.next_agent) {
|
|
266
|
+
await this.notifyHandoff(context, result.next_agent, {
|
|
267
|
+
type,
|
|
268
|
+
sys_id: result.sys_id,
|
|
269
|
+
next_steps: result.next_steps || []
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
await this.reportProgress(context, 100, 'Deployment complete');
|
|
273
|
+
return this.createSuccessResponse(`Successfully deployed ${type}: ${result.name}`, {
|
|
274
|
+
sys_id: result.sys_id,
|
|
275
|
+
name: result.name,
|
|
276
|
+
update_set_id: updateSetId,
|
|
277
|
+
deployment_details: result
|
|
278
|
+
}, {
|
|
279
|
+
agent_id: context.agent_id,
|
|
280
|
+
session_id: context.session_id,
|
|
281
|
+
artifacts_created: [result.sys_id]
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Deploy multiple artifacts in batch
|
|
286
|
+
*/
|
|
287
|
+
async deployBatch(args, context) {
|
|
288
|
+
const { artifacts, parallel, transaction_mode, dry_run } = args;
|
|
289
|
+
if (!artifacts || !Array.isArray(artifacts)) {
|
|
290
|
+
throw new Error('Batch deployment requires artifacts array');
|
|
291
|
+
}
|
|
292
|
+
await this.reportProgress(context, 10, `Preparing batch deployment of ${artifacts.length} artifacts`);
|
|
293
|
+
// Dry run validation
|
|
294
|
+
if (dry_run) {
|
|
295
|
+
const validationResults = await Promise.all(artifacts.map(artifact => this.validateArtifact(artifact, context)));
|
|
296
|
+
return this.createSuccessResponse('Dry run completed - all artifacts validated', { validationResults });
|
|
297
|
+
}
|
|
298
|
+
// Create update set for batch
|
|
299
|
+
const updateSetResult = await this.ensureUpdateSet('batch', `Batch deployment`, context);
|
|
300
|
+
const updateSetId = updateSetResult.updateSetId;
|
|
301
|
+
const results = [];
|
|
302
|
+
const errors = [];
|
|
303
|
+
try {
|
|
304
|
+
if (parallel) {
|
|
305
|
+
// Deploy in parallel
|
|
306
|
+
await this.reportProgress(context, 30, 'Deploying artifacts in parallel');
|
|
307
|
+
const deploymentPromises = artifacts.map((artifact, index) => this.deploySingleArtifact({ ...artifact, auto_update_set: false }, context).catch(error => {
|
|
308
|
+
errors.push({ artifact, error: error.message });
|
|
309
|
+
return null;
|
|
310
|
+
}));
|
|
311
|
+
const parallelResults = await Promise.all(deploymentPromises);
|
|
312
|
+
results.push(...parallelResults.filter(r => r !== null));
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
// Deploy sequentially
|
|
316
|
+
for (let i = 0; i < artifacts.length; i++) {
|
|
317
|
+
const artifact = artifacts[i];
|
|
318
|
+
await this.reportProgress(context, 30 + (60 * i / artifacts.length), `Deploying artifact ${i + 1} of ${artifacts.length}`);
|
|
319
|
+
try {
|
|
320
|
+
const result = await this.deploySingleArtifact({ ...artifact, auto_update_set: false }, context);
|
|
321
|
+
results.push(result);
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
errors.push({ artifact, error: error instanceof Error ? error.message : String(error) });
|
|
325
|
+
if (transaction_mode) {
|
|
326
|
+
// Rollback on error in transaction mode
|
|
327
|
+
await this.rollbackBatch(results, updateSetId, context);
|
|
328
|
+
throw new Error(`Batch deployment failed at artifact ${i + 1}: ${error}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// Check if we need to rollback
|
|
334
|
+
if (transaction_mode && errors.length > 0) {
|
|
335
|
+
await this.rollbackBatch(results, updateSetId, context);
|
|
336
|
+
throw new Error(`Batch deployment failed with ${errors.length} errors`);
|
|
337
|
+
}
|
|
338
|
+
await this.reportProgress(context, 100, 'Batch deployment complete');
|
|
339
|
+
return this.createSuccessResponse(`Batch deployment completed: ${results.length} succeeded, ${errors.length} failed`, {
|
|
340
|
+
successful: results.length,
|
|
341
|
+
failed: errors.length,
|
|
342
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
343
|
+
update_set_id: updateSetId
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
// Record failed deployment
|
|
348
|
+
await this.memory.recordDeployment(context.session_id, 'batch_deployment', 'batch', false, context.agent_id, error instanceof Error ? error.message : String(error));
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Deploy widget with agent tracking
|
|
354
|
+
*/
|
|
355
|
+
async deployWidget(config, context, updateSetId) {
|
|
356
|
+
this.logger.info('Deploying widget', {
|
|
357
|
+
name: config.name,
|
|
358
|
+
agent_id: context.agent_id
|
|
359
|
+
});
|
|
360
|
+
try {
|
|
361
|
+
// Create widget in ServiceNow
|
|
362
|
+
const widgetData = {
|
|
363
|
+
name: config.name,
|
|
364
|
+
id: config.name,
|
|
365
|
+
template: config.template || '<div>Widget Template</div>',
|
|
366
|
+
css: config.css || '',
|
|
367
|
+
server_script: config.server_script || '',
|
|
368
|
+
client_script: config.client_script || '',
|
|
369
|
+
public: false,
|
|
370
|
+
roles: '',
|
|
371
|
+
active: true
|
|
372
|
+
};
|
|
373
|
+
const response = await this.client.createRecord('sp_widget', widgetData);
|
|
374
|
+
if (!response.success || !response.result) {
|
|
375
|
+
throw new Error('Failed to create widget in ServiceNow');
|
|
376
|
+
}
|
|
377
|
+
const widgetSysId = response.result.sys_id;
|
|
378
|
+
// Determine next agent based on widget complexity
|
|
379
|
+
let nextAgent;
|
|
380
|
+
let nextSteps = [];
|
|
381
|
+
if (config.requires_styling || config.template?.includes('class=')) {
|
|
382
|
+
nextAgent = 'ui_specialist';
|
|
383
|
+
nextSteps = ['responsive_styling', 'accessibility_compliance'];
|
|
384
|
+
}
|
|
385
|
+
else if (config.requires_testing) {
|
|
386
|
+
nextAgent = 'test_agent';
|
|
387
|
+
nextSteps = ['functional_testing', 'performance_testing'];
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
sys_id: widgetSysId,
|
|
391
|
+
name: config.name,
|
|
392
|
+
table: 'sp_widget',
|
|
393
|
+
next_agent: nextAgent,
|
|
394
|
+
next_steps: nextSteps
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
this.logger.error('Widget deployment failed', error);
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Deploy flow with agent tracking
|
|
404
|
+
*/
|
|
405
|
+
async deployFlow(config, context, updateSetId) {
|
|
406
|
+
// For flows with natural language instructions, delegate to flow composer
|
|
407
|
+
if (config.instruction) {
|
|
408
|
+
// Store instruction in shared context for flow builder agent
|
|
409
|
+
await this.memory.updateSharedContext({
|
|
410
|
+
session_id: context.session_id,
|
|
411
|
+
context_key: 'flow_instruction',
|
|
412
|
+
context_value: config.instruction,
|
|
413
|
+
created_by_agent: context.agent_id
|
|
414
|
+
});
|
|
415
|
+
return {
|
|
416
|
+
sys_id: `pending_flow_${Date.now()}`,
|
|
417
|
+
name: 'Flow from instruction',
|
|
418
|
+
instruction: config.instruction,
|
|
419
|
+
next_agent: 'flow_builder',
|
|
420
|
+
next_steps: ['analyze_requirements', 'create_flow_structure', 'deploy_flow']
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
// Direct flow deployment
|
|
424
|
+
const flowData = {
|
|
425
|
+
name: config.name,
|
|
426
|
+
description: config.description,
|
|
427
|
+
active: config.active !== false,
|
|
428
|
+
sys_scope: 'global'
|
|
429
|
+
};
|
|
430
|
+
const response = await this.client.createRecord('sys_hub_flow', flowData);
|
|
431
|
+
if (!response.success || !response.result) {
|
|
432
|
+
throw new Error('Failed to create flow in ServiceNow');
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
sys_id: response.result.sys_id,
|
|
436
|
+
name: config.name,
|
|
437
|
+
table: 'sys_hub_flow'
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Deploy application with scope management
|
|
442
|
+
*/
|
|
443
|
+
async deployApplication(config, context, updateSetId) {
|
|
444
|
+
// Determine deployment scope
|
|
445
|
+
const scopeStrategy = config.scope_strategy || 'auto';
|
|
446
|
+
const deploymentContext = {
|
|
447
|
+
artifactType: 'application',
|
|
448
|
+
targetScope: scopeStrategy === 'auto' ? undefined : config.scope,
|
|
449
|
+
environment: config.environment || 'development',
|
|
450
|
+
permissions: [] // Will be populated based on auth
|
|
451
|
+
};
|
|
452
|
+
const scope = await this.scopeManager.determineScope(deploymentContext);
|
|
453
|
+
const appData = {
|
|
454
|
+
name: config.name,
|
|
455
|
+
scope: scope.scopeName,
|
|
456
|
+
short_description: config.short_description,
|
|
457
|
+
version: config.version,
|
|
458
|
+
vendor: config.vendor || 'Custom',
|
|
459
|
+
vendor_prefix: config.vendor_prefix || 'x',
|
|
460
|
+
active: config.active !== false
|
|
461
|
+
};
|
|
462
|
+
const response = await this.client.createRecord('sys_app', appData);
|
|
463
|
+
if (!response.success || !response.result) {
|
|
464
|
+
throw new Error('Failed to create application in ServiceNow');
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
sys_id: response.result.sys_id,
|
|
468
|
+
name: config.name,
|
|
469
|
+
scope: scope.scopeName,
|
|
470
|
+
table: 'sys_app'
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Deploy script or business rule
|
|
475
|
+
*/
|
|
476
|
+
async deployScript(type, config, context, updateSetId) {
|
|
477
|
+
const table = type === 'script' ? 'sys_script' : 'sys_script';
|
|
478
|
+
const scriptData = {
|
|
479
|
+
name: config.name,
|
|
480
|
+
script: config.script,
|
|
481
|
+
active: config.active !== false,
|
|
482
|
+
description: config.description
|
|
483
|
+
};
|
|
484
|
+
const response = await this.client.createRecord(table, scriptData);
|
|
485
|
+
if (!response.success || !response.result) {
|
|
486
|
+
throw new Error(`Failed to create ${type} in ServiceNow`);
|
|
487
|
+
}
|
|
488
|
+
// Scripts often need testing
|
|
489
|
+
return {
|
|
490
|
+
sys_id: response.result.sys_id,
|
|
491
|
+
name: config.name,
|
|
492
|
+
table,
|
|
493
|
+
next_agent: 'test_agent',
|
|
494
|
+
next_steps: ['syntax_validation', 'unit_testing']
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Get deployment status with session filtering
|
|
499
|
+
*/
|
|
500
|
+
async getDeploymentStatusWithContext(args) {
|
|
501
|
+
return await this.executeWithAgentContext('snow_deployment_status', args, async (context) => {
|
|
502
|
+
const session_id = args.session_id || context.session_id;
|
|
503
|
+
// Get artifacts from memory
|
|
504
|
+
const artifacts = await this.memory.getSessionArtifacts(session_id);
|
|
505
|
+
// Get active agents
|
|
506
|
+
const activeAgents = await this.memory.query(`
|
|
507
|
+
SELECT * FROM agent_coordination
|
|
508
|
+
WHERE session_id = ?
|
|
509
|
+
ORDER BY last_activity DESC
|
|
510
|
+
`, [session_id]);
|
|
511
|
+
// Get recent deployments
|
|
512
|
+
const deployments = await this.memory.query(`
|
|
513
|
+
SELECT * FROM deployment_history
|
|
514
|
+
WHERE session_id = ?
|
|
515
|
+
ORDER BY deployment_time DESC
|
|
516
|
+
LIMIT ?
|
|
517
|
+
`, [session_id, args.limit || 10]);
|
|
518
|
+
return this.createSuccessResponse(`Deployment status for session ${session_id}`, {
|
|
519
|
+
artifacts: artifacts.length,
|
|
520
|
+
active_agents: activeAgents.length,
|
|
521
|
+
recent_deployments: deployments,
|
|
522
|
+
session_summary: {
|
|
523
|
+
total_artifacts: artifacts.length,
|
|
524
|
+
artifact_types: this.groupByType(artifacts),
|
|
525
|
+
success_rate: this.calculateSuccessRate(deployments)
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Validate deployment with agent context
|
|
532
|
+
*/
|
|
533
|
+
async validateDeploymentWithContext(args) {
|
|
534
|
+
return await this.executeWithAgentContext('snow_validate_deployment', args, async (context) => {
|
|
535
|
+
const { type, artifact } = args;
|
|
536
|
+
const validationResult = await this.validateArtifact({ type, config: artifact }, context);
|
|
537
|
+
if (validationResult.valid) {
|
|
538
|
+
return this.createSuccessResponse(`Validation passed for ${type}`, validationResult);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
// Store validation failure in context
|
|
542
|
+
await this.memory.updateSharedContext({
|
|
543
|
+
session_id: context.session_id,
|
|
544
|
+
context_key: `validation_failure_${type}`,
|
|
545
|
+
context_value: JSON.stringify(validationResult),
|
|
546
|
+
created_by_agent: context.agent_id
|
|
547
|
+
});
|
|
548
|
+
return this.createErrorResponse(`Validation failed for ${type}`, validationResult.errors);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Rollback deployment with coordination
|
|
554
|
+
*/
|
|
555
|
+
async rollbackDeploymentWithContext(args) {
|
|
556
|
+
return await this.executeWithAgentContext('snow_rollback_deployment', args, async (context) => {
|
|
557
|
+
const { update_set_id, reason } = args;
|
|
558
|
+
// Notify all agents about rollback
|
|
559
|
+
await this.memory.sendAgentMessage({
|
|
560
|
+
session_id: context.session_id,
|
|
561
|
+
from_agent: context.agent_id,
|
|
562
|
+
to_agent: 'all',
|
|
563
|
+
message_type: 'status_update',
|
|
564
|
+
content: JSON.stringify({
|
|
565
|
+
action: 'rollback_initiated',
|
|
566
|
+
update_set_id,
|
|
567
|
+
reason
|
|
568
|
+
})
|
|
569
|
+
});
|
|
570
|
+
// Perform rollback
|
|
571
|
+
const rollbackResult = await this.client.updateRecord('sys_update_set', update_set_id, {
|
|
572
|
+
state: 'reverted',
|
|
573
|
+
description: `Rolled back: ${reason}`
|
|
574
|
+
});
|
|
575
|
+
if (rollbackResult.success) {
|
|
576
|
+
// Update deployment history
|
|
577
|
+
await this.memory.recordDeployment(context.session_id, update_set_id, 'rollback', true, context.agent_id);
|
|
578
|
+
return this.createSuccessResponse(`Successfully rolled back update set ${update_set_id}`, { reason });
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
throw new Error('Rollback failed');
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
// Helper methods
|
|
586
|
+
async ensureUpdateSet(type, name, context) {
|
|
587
|
+
// Implementation would check for existing update set or create new one
|
|
588
|
+
// This is simplified for the example
|
|
589
|
+
const updateSetName = `${context.session_id}_${type}_${Date.now()}`;
|
|
590
|
+
const response = await this.client.createRecord('sys_update_set', {
|
|
591
|
+
name: updateSetName,
|
|
592
|
+
description: `Created by ${context.agent_type} agent ${context.agent_id}`,
|
|
593
|
+
state: 'in_progress'
|
|
594
|
+
});
|
|
595
|
+
return {
|
|
596
|
+
updateSetId: response.result?.sys_id,
|
|
597
|
+
updateSetName
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
async validateArtifact(artifact, context) {
|
|
601
|
+
// Simplified validation logic
|
|
602
|
+
const errors = [];
|
|
603
|
+
if (!artifact.type)
|
|
604
|
+
errors.push('Missing artifact type');
|
|
605
|
+
if (!artifact.config && !artifact.instruction)
|
|
606
|
+
errors.push('Missing configuration or instruction');
|
|
607
|
+
if (artifact.type === 'widget') {
|
|
608
|
+
if (!artifact.config?.name)
|
|
609
|
+
errors.push('Widget name is required');
|
|
610
|
+
if (!artifact.config?.template)
|
|
611
|
+
errors.push('Widget template is required');
|
|
612
|
+
}
|
|
613
|
+
return {
|
|
614
|
+
valid: errors.length === 0,
|
|
615
|
+
errors,
|
|
616
|
+
warnings: []
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
async rollbackBatch(results, updateSetId, context) {
|
|
620
|
+
// Rollback logic for batch deployments
|
|
621
|
+
for (const result of results) {
|
|
622
|
+
if (result?.data?.sys_id) {
|
|
623
|
+
try {
|
|
624
|
+
await this.client.deleteRecord(result.data.table || 'sys_metadata', result.data.sys_id);
|
|
625
|
+
}
|
|
626
|
+
catch (error) {
|
|
627
|
+
this.logger.error('Failed to rollback artifact', error);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
groupByType(artifacts) {
|
|
633
|
+
return artifacts.reduce((acc, artifact) => {
|
|
634
|
+
acc[artifact.artifact_type] = (acc[artifact.artifact_type] || 0) + 1;
|
|
635
|
+
return acc;
|
|
636
|
+
}, {});
|
|
637
|
+
}
|
|
638
|
+
calculateSuccessRate(deployments) {
|
|
639
|
+
if (deployments.length === 0)
|
|
640
|
+
return 0;
|
|
641
|
+
const successful = deployments.filter(d => d.success).length;
|
|
642
|
+
return Math.round((successful / deployments.length) * 100);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
exports.ServiceNowDeploymentMCP = ServiceNowDeploymentMCP;
|
|
646
|
+
// Start the server
|
|
647
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
648
|
+
const server = new ServiceNowDeploymentMCP();
|
|
649
|
+
server.start().catch(console.error);
|
|
650
|
+
}
|
|
651
|
+
//# sourceMappingURL=servicenow-deployment-mcp-refactored.js.map
|