snow-flow 1.1.74 → 1.1.76
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-flow/queen-test/test-memory.db +0 -0
- package/.claude-flow/queen-test/test-memory.db-agents +0 -0
- package/.claude-flow/queen-test/test-memory.db-import +0 -0
- package/.claude-flow/queen-test/test-memory.db-memory +0 -0
- package/.claude-flow/queen-test/test-memory.db-neural +0 -0
- package/CLAUDE.md +111 -8
- package/README.md +117 -50
- package/deploy.sh +366 -0
- package/dist/cli.js +226 -0
- package/dist/cli.js.map +1 -1
- package/dist/mcp/http-transport-wrapper.d.ts +29 -0
- package/dist/mcp/http-transport-wrapper.d.ts.map +1 -0
- package/dist/mcp/http-transport-wrapper.js +318 -0
- package/dist/mcp/http-transport-wrapper.js.map +1 -0
- package/dist/mcp/service-discovery-client.d.ts +83 -0
- package/dist/mcp/service-discovery-client.d.ts.map +1 -0
- package/dist/mcp/service-discovery-client.js +211 -0
- package/dist/mcp/service-discovery-client.js.map +1 -0
- package/dist/mcp/servicenow-deployment-mcp.js +262 -29
- package/dist/mcp/servicenow-deployment-mcp.js.map +1 -1
- package/dist/mcp/servicenow-intelligent-mcp.js +252 -18
- package/dist/mcp/servicenow-intelligent-mcp.js.map +1 -1
- package/dist/mcp/servicenow-operations-mcp.js +274 -46
- package/dist/mcp/servicenow-operations-mcp.js.map +1 -1
- package/dist/orchestration/discovery/service-discovery.d.ts +81 -0
- package/dist/orchestration/discovery/service-discovery.d.ts.map +1 -0
- package/dist/orchestration/discovery/service-discovery.js +808 -0
- package/dist/orchestration/discovery/service-discovery.js.map +1 -0
- package/dist/orchestration/distributed-orchestrator.d.ts +131 -0
- package/dist/orchestration/distributed-orchestrator.d.ts.map +1 -0
- package/dist/orchestration/distributed-orchestrator.js +712 -0
- package/dist/orchestration/distributed-orchestrator.js.map +1 -0
- package/dist/orchestration/distribution/task-distribution-engine.d.ts +53 -0
- package/dist/orchestration/distribution/task-distribution-engine.d.ts.map +1 -0
- package/dist/orchestration/distribution/task-distribution-engine.js +586 -0
- package/dist/orchestration/distribution/task-distribution-engine.js.map +1 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +606 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts.map +1 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js +65 -0
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js.map +1 -0
- package/dist/orchestration/protocols/mcpx-protocol.d.ts +71 -0
- package/dist/orchestration/protocols/mcpx-protocol.d.ts.map +1 -0
- package/dist/orchestration/protocols/mcpx-protocol.js +668 -0
- package/dist/orchestration/protocols/mcpx-protocol.js.map +1 -0
- package/dist/orchestration/state/distributed-state-manager.d.ts +89 -0
- package/dist/orchestration/state/distributed-state-manager.d.ts.map +1 -0
- package/dist/orchestration/state/distributed-state-manager.js +716 -0
- package/dist/orchestration/state/distributed-state-manager.js.map +1 -0
- package/dist/queen/advanced-integration-test.d.ts +48 -0
- package/dist/queen/advanced-integration-test.d.ts.map +1 -0
- package/dist/queen/advanced-integration-test.js +474 -0
- package/dist/queen/advanced-integration-test.js.map +1 -0
- package/dist/queen/agent-factory.d.ts +40 -0
- package/dist/queen/agent-factory.d.ts.map +1 -0
- package/dist/queen/agent-factory.js +433 -0
- package/dist/queen/agent-factory.js.map +1 -0
- package/dist/queen/index.d.ts +58 -0
- package/dist/queen/index.d.ts.map +1 -0
- package/dist/queen/index.js +79 -0
- package/dist/queen/index.js.map +1 -0
- package/dist/queen/integration-example.d.ts +82 -0
- package/dist/queen/integration-example.d.ts.map +1 -0
- package/dist/queen/integration-example.js +220 -0
- package/dist/queen/integration-example.js.map +1 -0
- package/dist/queen/integration-test.d.ts +72 -0
- package/dist/queen/integration-test.d.ts.map +1 -0
- package/dist/queen/integration-test.js +564 -0
- package/dist/queen/integration-test.js.map +1 -0
- package/dist/queen/mock-mcp-client.d.ts +66 -0
- package/dist/queen/mock-mcp-client.d.ts.map +1 -0
- package/dist/queen/mock-mcp-client.js +297 -0
- package/dist/queen/mock-mcp-client.js.map +1 -0
- package/dist/queen/neural-learning.d.ts +28 -0
- package/dist/queen/neural-learning.d.ts.map +1 -0
- package/dist/queen/neural-learning.js +244 -0
- package/dist/queen/neural-learning.js.map +1 -0
- package/dist/queen/queen-memory.d.ts +25 -0
- package/dist/queen/queen-memory.d.ts.map +1 -0
- package/dist/queen/queen-memory.js +273 -0
- package/dist/queen/queen-memory.js.map +1 -0
- package/dist/queen/run-integration-tests.d.ts +9 -0
- package/dist/queen/run-integration-tests.d.ts.map +1 -0
- package/dist/queen/run-integration-tests.js +28 -0
- package/dist/queen/run-integration-tests.js.map +1 -0
- package/dist/queen/servicenow-queen.d.ts +56 -0
- package/dist/queen/servicenow-queen.d.ts.map +1 -0
- package/dist/queen/servicenow-queen.js +659 -0
- package/dist/queen/servicenow-queen.js.map +1 -0
- package/dist/queen/types.d.ts +58 -0
- package/dist/queen/types.d.ts.map +1 -0
- package/dist/queen/types.js +7 -0
- package/dist/queen/types.js.map +1 -0
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +27 -2
- package/dist/version.js.map +1 -1
- package/docker/base/Dockerfile.base +45 -0
- package/docker/generate-services.js +244 -0
- package/docker/nginx/Dockerfile +71 -0
- package/docker/nginx/consul-template.hcl +64 -0
- package/docker/nginx/healthcheck.sh +178 -0
- package/docker/nginx/nginx.conf +210 -0
- package/docker/nginx/supervisord.conf +57 -0
- package/docker/nginx/templates/upstreams.conf.tpl +48 -0
- package/docker/services/automation-mcp/Dockerfile +32 -0
- package/docker/services/automation-mcp/config/service.json +28 -0
- package/docker/services/automation-mcp/entrypoint.js +51 -0
- package/docker/services/deployment-mcp/Dockerfile +32 -0
- package/docker/services/deployment-mcp/entrypoint.js +51 -0
- package/docker/services/flow-composer-mcp/Dockerfile +32 -0
- package/docker/services/flow-composer-mcp/config/service.json +28 -0
- package/docker/services/flow-composer-mcp/entrypoint.js +51 -0
- package/docker/services/graph-memory-mcp/Dockerfile +32 -0
- package/docker/services/graph-memory-mcp/config/service.json +28 -0
- package/docker/services/graph-memory-mcp/entrypoint.js +51 -0
- package/docker/services/integration-mcp/Dockerfile +32 -0
- package/docker/services/integration-mcp/config/service.json +28 -0
- package/docker/services/integration-mcp/entrypoint.js +51 -0
- package/docker/services/intelligent-mcp/Dockerfile +32 -0
- package/docker/services/intelligent-mcp/config/service.json +28 -0
- package/docker/services/intelligent-mcp/entrypoint.js +51 -0
- package/docker/services/operations-mcp/Dockerfile +32 -0
- package/docker/services/operations-mcp/config/service.json +28 -0
- package/docker/services/operations-mcp/entrypoint.js +51 -0
- package/docker/services/platform-development-mcp/Dockerfile +32 -0
- package/docker/services/platform-development-mcp/config/service.json +28 -0
- package/docker/services/platform-development-mcp/entrypoint.js +51 -0
- package/docker/services/reporting-analytics-mcp/Dockerfile +32 -0
- package/docker/services/reporting-analytics-mcp/config/service.json +28 -0
- package/docker/services/reporting-analytics-mcp/entrypoint.js +51 -0
- package/docker/services/security-compliance-mcp/Dockerfile +32 -0
- package/docker/services/security-compliance-mcp/config/service.json +28 -0
- package/docker/services/security-compliance-mcp/entrypoint.js +51 -0
- package/docker/services/update-set-mcp/Dockerfile +32 -0
- package/docker/services/update-set-mcp/config/service.json +28 -0
- package/docker/services/update-set-mcp/entrypoint.js +51 -0
- package/docker-compose.override.yml +132 -0
- package/docker-compose.prod.yml +340 -0
- package/docker-compose.yml +579 -0
- package/k8s/automation-mcp.yaml +232 -0
- package/k8s/configmap.yaml +237 -0
- package/k8s/deployment-mcp.yaml +232 -0
- package/k8s/flow-composer-mcp.yaml +232 -0
- package/k8s/generate-k8s-manifests.js +453 -0
- package/k8s/graph-memory-mcp.yaml +232 -0
- package/k8s/infrastructure.yaml +456 -0
- package/k8s/ingress.yaml +361 -0
- package/k8s/integration-mcp.yaml +232 -0
- package/k8s/intelligent-mcp.yaml +232 -0
- package/k8s/kustomization.yaml +111 -0
- package/k8s/mcp-services.yaml +2552 -0
- package/k8s/monitoring.yaml +515 -0
- package/k8s/namespace.yaml +80 -0
- package/k8s/operations-mcp.yaml +232 -0
- package/k8s/platform-development-mcp.yaml +232 -0
- package/k8s/rbac.yaml +140 -0
- package/k8s/reporting-analytics-mcp.yaml +232 -0
- package/k8s/security-compliance-mcp.yaml +232 -0
- package/k8s/update-set-mcp.yaml +232 -0
- package/package.json +2 -2
|
@@ -1073,6 +1073,17 @@ Use \`snow_deployment_debug\` for more information about this session.`,
|
|
|
1073
1073
|
],
|
|
1074
1074
|
};
|
|
1075
1075
|
}
|
|
1076
|
+
// Ensure we have a flow definition
|
|
1077
|
+
if (!args.flow_definition) {
|
|
1078
|
+
return {
|
|
1079
|
+
content: [
|
|
1080
|
+
{
|
|
1081
|
+
type: 'text',
|
|
1082
|
+
text: '❌ Flow deployment failed: No flow_definition provided.\n\n💡 You need to provide a flow_definition with activities.\n\nExample:\n```json\n{\n "name": "approval_flow",\n "flow_definition": {\n "activities": [\n {\n "id": "activity_1",\n "name": "Check Condition",\n "type": "condition"\n }\n ]\n }\n}\n```\n\nOr use snow_create_flow with natural language for easier flow creation.',
|
|
1083
|
+
},
|
|
1084
|
+
],
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1076
1087
|
const flowType = args.flow_type || 'flow';
|
|
1077
1088
|
this.logger.info(`Deploying ${flowType} to ServiceNow`, { name: args.name, type: flowType });
|
|
1078
1089
|
// Validate flow definition first if requested
|
|
@@ -1426,9 +1437,12 @@ ${isComposedFlow ? `
|
|
|
1426
1437
|
access: 'public'
|
|
1427
1438
|
};
|
|
1428
1439
|
const result = await this.client.createScriptInclude(scriptIncludeData);
|
|
1440
|
+
if (!result.data?.sys_id) {
|
|
1441
|
+
throw new Error(`Script Include deployment failed: No sys_id returned from ServiceNow. Result: ${JSON.stringify(result)}`);
|
|
1442
|
+
}
|
|
1429
1443
|
return {
|
|
1430
1444
|
originalId: artifact.sys_id,
|
|
1431
|
-
sys_id: result.data
|
|
1445
|
+
sys_id: result.data.sys_id,
|
|
1432
1446
|
name: artifact.name,
|
|
1433
1447
|
api_name: scriptIncludeData.api_name,
|
|
1434
1448
|
type: 'script_include',
|
|
@@ -1450,9 +1464,12 @@ ${isComposedFlow ? `
|
|
|
1450
1464
|
order: 100
|
|
1451
1465
|
};
|
|
1452
1466
|
const result = await this.client.createBusinessRule(businessRuleData);
|
|
1467
|
+
if (!result.data?.sys_id) {
|
|
1468
|
+
throw new Error(`Business Rule deployment failed: No sys_id returned from ServiceNow. Result: ${JSON.stringify(result)}`);
|
|
1469
|
+
}
|
|
1453
1470
|
return {
|
|
1454
1471
|
originalId: artifact.sys_id,
|
|
1455
|
-
sys_id: result.data
|
|
1472
|
+
sys_id: result.data.sys_id,
|
|
1456
1473
|
name: artifact.name,
|
|
1457
1474
|
type: 'business_rule',
|
|
1458
1475
|
success: result.success
|
|
@@ -1483,9 +1500,12 @@ ${isComposedFlow ? `
|
|
|
1483
1500
|
});
|
|
1484
1501
|
}
|
|
1485
1502
|
}
|
|
1503
|
+
if (!result.data?.sys_id) {
|
|
1504
|
+
throw new Error(`Table deployment failed: No sys_id returned from ServiceNow. Result: ${JSON.stringify(result)}`);
|
|
1505
|
+
}
|
|
1486
1506
|
return {
|
|
1487
1507
|
originalId: artifact.sys_id,
|
|
1488
|
-
sys_id: result.data
|
|
1508
|
+
sys_id: result.data.sys_id,
|
|
1489
1509
|
name: artifact.name,
|
|
1490
1510
|
type: 'table',
|
|
1491
1511
|
success: result.success
|
|
@@ -1662,9 +1682,52 @@ ${this.getScopeBenefits(deploymentResult.scope).map(b => `- ${b}`).join('\n')}`,
|
|
|
1662
1682
|
async deployUpdateSet(args) {
|
|
1663
1683
|
try {
|
|
1664
1684
|
this.logger.info('Creating update set', { name: args.name });
|
|
1665
|
-
//
|
|
1666
|
-
|
|
1667
|
-
|
|
1685
|
+
// Create the update set using the real ServiceNow API
|
|
1686
|
+
const updateSetResult = await this.client.createUpdateSet({
|
|
1687
|
+
name: args.name,
|
|
1688
|
+
description: args.description || `Update Set created via Snow-Flow deployment`
|
|
1689
|
+
});
|
|
1690
|
+
if (!updateSetResult.success || !updateSetResult.data) {
|
|
1691
|
+
throw new Error(`Failed to create Update Set: ${updateSetResult.error || 'Unknown error'}`);
|
|
1692
|
+
}
|
|
1693
|
+
const updateSetId = updateSetResult.data.sys_id;
|
|
1694
|
+
this.logger.info('Update Set created successfully', { id: updateSetId, name: args.name });
|
|
1695
|
+
// Set as current update set for tracking
|
|
1696
|
+
const activateResult = await this.client.setCurrentUpdateSet(updateSetId);
|
|
1697
|
+
if (!activateResult.success) {
|
|
1698
|
+
this.logger.warn('Warning: Could not set as current Update Set', { id: updateSetId });
|
|
1699
|
+
}
|
|
1700
|
+
// Track all provided artifacts in the update set
|
|
1701
|
+
const trackingResults = [];
|
|
1702
|
+
if (args.artifacts && Array.isArray(args.artifacts)) {
|
|
1703
|
+
for (const artifact of args.artifacts) {
|
|
1704
|
+
try {
|
|
1705
|
+
// Create sys_update_xml record to track the artifact in the update set
|
|
1706
|
+
const trackingResult = await this.client.createRecord('sys_update_xml', {
|
|
1707
|
+
name: `${artifact.type}_${artifact.sys_id}`,
|
|
1708
|
+
category: 'customer',
|
|
1709
|
+
update_set: updateSetId,
|
|
1710
|
+
target_name: artifact.name,
|
|
1711
|
+
type: artifact.type,
|
|
1712
|
+
target_sys_id: artifact.sys_id,
|
|
1713
|
+
action: 'INSERT_OR_UPDATE'
|
|
1714
|
+
});
|
|
1715
|
+
if (trackingResult.success) {
|
|
1716
|
+
trackingResults.push(`✅ ${artifact.type}: ${artifact.name}`);
|
|
1717
|
+
}
|
|
1718
|
+
else {
|
|
1719
|
+
trackingResults.push(`⚠️ ${artifact.type}: ${artifact.name} (tracking failed)`);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
catch (trackingError) {
|
|
1723
|
+
this.logger.warn('Failed to track artifact in Update Set', {
|
|
1724
|
+
artifact: artifact.sys_id,
|
|
1725
|
+
error: trackingError
|
|
1726
|
+
});
|
|
1727
|
+
trackingResults.push(`⚠️ ${artifact.type}: ${artifact.name} (tracking failed)`);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1668
1731
|
return {
|
|
1669
1732
|
content: [
|
|
1670
1733
|
{
|
|
@@ -1675,21 +1738,24 @@ ${this.getScopeBenefits(deploymentResult.scope).map(b => `- ${b}`).join('\n')}`,
|
|
|
1675
1738
|
- Name: ${args.name}
|
|
1676
1739
|
- ID: ${updateSetId}
|
|
1677
1740
|
- Description: ${args.description || 'N/A'}
|
|
1678
|
-
- Artifacts: ${args.artifacts
|
|
1741
|
+
- Artifacts: ${args.artifacts?.length || 0} items
|
|
1679
1742
|
|
|
1680
|
-
📦
|
|
1681
|
-
${
|
|
1743
|
+
📦 Tracked Artifacts:
|
|
1744
|
+
${trackingResults.length > 0 ? trackingResults.join('\n') : '- No artifacts specified'}
|
|
1682
1745
|
|
|
1683
1746
|
📝 Next Steps:
|
|
1684
|
-
1. Review update set contents
|
|
1685
|
-
2. Mark as complete
|
|
1686
|
-
3. Export for migration
|
|
1687
|
-
4. Deploy to target instance
|
|
1747
|
+
1. Review update set contents in ServiceNow
|
|
1748
|
+
2. Mark as complete when ready: \`snow_update_set_complete\`
|
|
1749
|
+
3. Export for migration: \`snow_update_set_export\`
|
|
1750
|
+
4. Deploy to target instance
|
|
1751
|
+
|
|
1752
|
+
💡 The Update Set is now active and will automatically track future changes.`,
|
|
1688
1753
|
},
|
|
1689
1754
|
],
|
|
1690
1755
|
};
|
|
1691
1756
|
}
|
|
1692
1757
|
catch (error) {
|
|
1758
|
+
this.logger.error('Update set creation failed', error);
|
|
1693
1759
|
throw new Error(`Update set creation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1694
1760
|
}
|
|
1695
1761
|
}
|
|
@@ -2760,6 +2826,17 @@ Use \`snow_preview_widget\` to see a detailed preview of the widget rendering.`,
|
|
|
2760
2826
|
]
|
|
2761
2827
|
};
|
|
2762
2828
|
}
|
|
2829
|
+
// Check if definition is null or undefined
|
|
2830
|
+
if (!definition) {
|
|
2831
|
+
return {
|
|
2832
|
+
content: [
|
|
2833
|
+
{
|
|
2834
|
+
type: 'text',
|
|
2835
|
+
text: `❌ Flow validation failed: No definition provided.\n\n💡 Please provide a flow definition with activities.\n\nExample:\n\`\`\`json\n{\n "activities": [\n {\n "id": "activity_1",\n "name": "Send Notification",\n "type": "notification"\n }\n ]\n}\n\`\`\``
|
|
2836
|
+
}
|
|
2837
|
+
]
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2763
2840
|
const issues = [];
|
|
2764
2841
|
const warnings = [];
|
|
2765
2842
|
const info = [];
|
|
@@ -2768,13 +2845,13 @@ Use \`snow_preview_widget\` to see a detailed preview of the widget rendering.`,
|
|
|
2768
2845
|
// Handle multiple JSON structure variations: top-level, nested in "flow", nested in "flow_definition"
|
|
2769
2846
|
let workingDefinition = definition;
|
|
2770
2847
|
// Check if we have a nested structure like { "flow": { "steps": [...] } }
|
|
2771
|
-
if (definition.flow && typeof definition.flow === 'object') {
|
|
2848
|
+
if (definition && definition.flow && typeof definition.flow === 'object') {
|
|
2772
2849
|
workingDefinition = definition.flow;
|
|
2773
2850
|
corrections.push('✅ Processing nested flow structure (definition.flow)');
|
|
2774
2851
|
info.push('💡 Detected nested flow definition format - extracting flow content');
|
|
2775
2852
|
}
|
|
2776
2853
|
// Check if we have nested flow_definition
|
|
2777
|
-
if (definition.flow_definition && typeof definition.flow_definition === 'object') {
|
|
2854
|
+
if (definition && definition.flow_definition && typeof definition.flow_definition === 'object') {
|
|
2778
2855
|
workingDefinition = definition.flow_definition;
|
|
2779
2856
|
corrections.push('✅ Processing nested flow_definition structure');
|
|
2780
2857
|
}
|
|
@@ -3559,8 +3636,22 @@ Use \`snow_preview_widget\` to see a detailed preview of the widget rendering.`,
|
|
|
3559
3636
|
script += this.generateConditionScript(activity);
|
|
3560
3637
|
break;
|
|
3561
3638
|
default:
|
|
3562
|
-
|
|
3563
|
-
|
|
3639
|
+
// Handle unknown activity types with a comprehensive fallback
|
|
3640
|
+
script += `\n // Unknown activity type: ${activity.type}
|
|
3641
|
+
// Available activity data: ${JSON.stringify(activity, null, 2).replace(/"/g, '\\"')}
|
|
3642
|
+
gs.warn('Unsupported activity type in flow: ${activity.type}', 'SNOW_FLOW');
|
|
3643
|
+
|
|
3644
|
+
// Attempt to execute any custom script if provided
|
|
3645
|
+
${activity.script ? `
|
|
3646
|
+
// Custom script from activity definition
|
|
3647
|
+
try {
|
|
3648
|
+
${activity.script}
|
|
3649
|
+
} catch (error) {
|
|
3650
|
+
gs.error('Custom script execution failed for activity ${activity.name || activity.type}: ' + error.message);
|
|
3651
|
+
}` : ''}
|
|
3652
|
+
|
|
3653
|
+
// Log completion
|
|
3654
|
+
gs.log('Activity ${activity.name || activity.type} processed (unsupported type: ${activity.type})', 'INFO');`;
|
|
3564
3655
|
}
|
|
3565
3656
|
script += '\n';
|
|
3566
3657
|
});
|
|
@@ -3784,13 +3875,127 @@ Use individual deployment tools like \`snow_deploy_${args.type}\` with manual co
|
|
|
3784
3875
|
* Process natural language instruction into deployment configuration
|
|
3785
3876
|
*/
|
|
3786
3877
|
async processNaturalLanguageInstruction(type, instruction) {
|
|
3787
|
-
// For flows,
|
|
3878
|
+
// For flows, create a proper flow structure
|
|
3788
3879
|
if (type === 'flow') {
|
|
3789
|
-
//
|
|
3880
|
+
// Extract flow name from instruction
|
|
3881
|
+
const flowName = this.extractNameFromInstruction(instruction);
|
|
3882
|
+
// Create a basic flow definition based on the instruction
|
|
3883
|
+
// This is a simplified version - in production, this would call the flow composer
|
|
3884
|
+
const lowerInstruction = instruction.toLowerCase();
|
|
3885
|
+
// Determine trigger type
|
|
3886
|
+
let triggerType = 'manual';
|
|
3887
|
+
let triggerTable = '';
|
|
3888
|
+
if (lowerInstruction.includes('new service catalog request') ||
|
|
3889
|
+
lowerInstruction.includes('new catalog request')) {
|
|
3890
|
+
triggerType = 'record_created';
|
|
3891
|
+
triggerTable = 'sc_request';
|
|
3892
|
+
}
|
|
3893
|
+
else if (lowerInstruction.includes('new incident')) {
|
|
3894
|
+
triggerType = 'record_created';
|
|
3895
|
+
triggerTable = 'incident';
|
|
3896
|
+
}
|
|
3897
|
+
else if (lowerInstruction.includes('updated') || lowerInstruction.includes('changes')) {
|
|
3898
|
+
triggerType = 'record_updated';
|
|
3899
|
+
}
|
|
3900
|
+
// Create activities based on instruction
|
|
3901
|
+
const activities = [];
|
|
3902
|
+
let activityId = 1;
|
|
3903
|
+
// Check for approval requirement
|
|
3904
|
+
if (lowerInstruction.includes('approval') || lowerInstruction.includes('approve')) {
|
|
3905
|
+
// Check for condition
|
|
3906
|
+
if (lowerInstruction.includes('if') &&
|
|
3907
|
+
(lowerInstruction.includes('monitor') || lowerInstruction.includes('display') ||
|
|
3908
|
+
lowerInstruction.includes('screen') || lowerInstruction.includes('lcd'))) {
|
|
3909
|
+
// Add condition activity
|
|
3910
|
+
activities.push({
|
|
3911
|
+
id: `activity_${activityId++}`,
|
|
3912
|
+
name: 'Check Item Type',
|
|
3913
|
+
type: 'condition',
|
|
3914
|
+
condition: 'current.cat_item.name.toLowerCase().includes("monitor") || current.cat_item.name.toLowerCase().includes("display") || current.cat_item.name.toLowerCase().includes("screen") || current.cat_item.name.toLowerCase().includes("lcd")',
|
|
3915
|
+
outputs: {
|
|
3916
|
+
condition_met: true
|
|
3917
|
+
}
|
|
3918
|
+
});
|
|
3919
|
+
}
|
|
3920
|
+
// Add approval activity
|
|
3921
|
+
activities.push({
|
|
3922
|
+
id: `activity_${activityId++}`,
|
|
3923
|
+
name: 'Request Approval',
|
|
3924
|
+
type: 'approval',
|
|
3925
|
+
approval_type: 'user',
|
|
3926
|
+
approvers: lowerInstruction.includes('admin') ? 'admin' : 'assignment_group.manager',
|
|
3927
|
+
inputs: {
|
|
3928
|
+
record: '${trigger.current}',
|
|
3929
|
+
approvers: lowerInstruction.includes('admin') ? 'admin' : 'assignment_group.manager'
|
|
3930
|
+
},
|
|
3931
|
+
outputs: {
|
|
3932
|
+
approval_state: '${approval.state}',
|
|
3933
|
+
approval_comments: '${approval.comments}'
|
|
3934
|
+
}
|
|
3935
|
+
});
|
|
3936
|
+
// Add wait for approval if mentioned
|
|
3937
|
+
if (lowerInstruction.includes('wait for approval')) {
|
|
3938
|
+
activities.push({
|
|
3939
|
+
id: `activity_${activityId++}`,
|
|
3940
|
+
name: 'Wait for Approval',
|
|
3941
|
+
type: 'wait',
|
|
3942
|
+
wait_type: 'approval',
|
|
3943
|
+
inputs: {
|
|
3944
|
+
approval_record: '${activity_' + (activityId - 2) + '.approval_id}'
|
|
3945
|
+
}
|
|
3946
|
+
});
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
// Add update status if mentioned
|
|
3950
|
+
if (lowerInstruction.includes('update') && lowerInstruction.includes('status')) {
|
|
3951
|
+
activities.push({
|
|
3952
|
+
id: `activity_${activityId++}`,
|
|
3953
|
+
name: 'Update Request Status',
|
|
3954
|
+
type: 'update_record',
|
|
3955
|
+
table: triggerTable || 'sc_request',
|
|
3956
|
+
inputs: {
|
|
3957
|
+
record: '${trigger.current}',
|
|
3958
|
+
fields: {
|
|
3959
|
+
state: '${activity_' + (activityId - 2) + '.approval_state === "approved" ? "approved" : "rejected"}'
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
});
|
|
3963
|
+
}
|
|
3964
|
+
// Create flow definition
|
|
3965
|
+
const flowDefinition = {
|
|
3966
|
+
name: flowName,
|
|
3967
|
+
description: instruction,
|
|
3968
|
+
table: triggerTable,
|
|
3969
|
+
trigger: {
|
|
3970
|
+
type: triggerType,
|
|
3971
|
+
table: triggerTable,
|
|
3972
|
+
condition: ''
|
|
3973
|
+
},
|
|
3974
|
+
activities: activities.length > 0 ? activities : [{
|
|
3975
|
+
id: 'activity_1',
|
|
3976
|
+
name: 'Log Action',
|
|
3977
|
+
type: 'log',
|
|
3978
|
+
message: 'Flow executed for: ' + instruction,
|
|
3979
|
+
level: 'info'
|
|
3980
|
+
}],
|
|
3981
|
+
connections: []
|
|
3982
|
+
};
|
|
3983
|
+
// Generate connections between activities
|
|
3984
|
+
for (let i = 0; i < activities.length - 1; i++) {
|
|
3985
|
+
flowDefinition.connections.push({
|
|
3986
|
+
from: activities[i].id,
|
|
3987
|
+
to: activities[i + 1].id,
|
|
3988
|
+
type: 'always'
|
|
3989
|
+
});
|
|
3990
|
+
}
|
|
3790
3991
|
return {
|
|
3791
|
-
name:
|
|
3992
|
+
name: flowName,
|
|
3792
3993
|
description: instruction,
|
|
3793
|
-
|
|
3994
|
+
flow_definition: flowDefinition,
|
|
3995
|
+
table: triggerTable,
|
|
3996
|
+
trigger_type: triggerType,
|
|
3997
|
+
condition: '',
|
|
3998
|
+
active: true
|
|
3794
3999
|
};
|
|
3795
4000
|
}
|
|
3796
4001
|
// For widgets, delegate to widget composer
|
|
@@ -3799,6 +4004,10 @@ Use individual deployment tools like \`snow_deploy_${args.type}\` with manual co
|
|
|
3799
4004
|
name: this.extractNameFromInstruction(instruction),
|
|
3800
4005
|
title: this.extractNameFromInstruction(instruction),
|
|
3801
4006
|
description: instruction,
|
|
4007
|
+
template: '<div>Widget placeholder - implement with proper template</div>',
|
|
4008
|
+
css: '',
|
|
4009
|
+
server_script: '',
|
|
4010
|
+
client_script: '',
|
|
3802
4011
|
instruction: instruction
|
|
3803
4012
|
};
|
|
3804
4013
|
}
|
|
@@ -4203,15 +4412,39 @@ ${updateSetSession ? `📋 **Update Set**: ${updateSetSession.name}
|
|
|
4203
4412
|
* Ensure active Update Set session
|
|
4204
4413
|
*/
|
|
4205
4414
|
async ensureActiveUpdateSet(context) {
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4415
|
+
try {
|
|
4416
|
+
// Call the real Update Set MCP to ensure active session
|
|
4417
|
+
const result = await this.client.ensureUpdateSet();
|
|
4418
|
+
if (result.success && result.data) {
|
|
4419
|
+
return {
|
|
4420
|
+
session: {
|
|
4421
|
+
update_set_id: result.data.sys_id,
|
|
4422
|
+
name: result.data.name,
|
|
4423
|
+
artifacts: []
|
|
4424
|
+
}
|
|
4425
|
+
};
|
|
4213
4426
|
}
|
|
4214
|
-
|
|
4427
|
+
// If no current update set, create a new one via the Update Set MCP
|
|
4428
|
+
const createResult = await this.client.createUpdateSet({
|
|
4429
|
+
name: `Auto-${context}-${Date.now()}`,
|
|
4430
|
+
description: `Automatically created for ${context}`,
|
|
4431
|
+
context: context
|
|
4432
|
+
});
|
|
4433
|
+
if (createResult.success && createResult.data) {
|
|
4434
|
+
return {
|
|
4435
|
+
session: {
|
|
4436
|
+
update_set_id: createResult.data.sys_id,
|
|
4437
|
+
name: createResult.data.name,
|
|
4438
|
+
artifacts: []
|
|
4439
|
+
}
|
|
4440
|
+
};
|
|
4441
|
+
}
|
|
4442
|
+
throw new Error('Failed to ensure Update Set session');
|
|
4443
|
+
}
|
|
4444
|
+
catch (error) {
|
|
4445
|
+
this.logger.error('Failed to ensure Update Set session', error);
|
|
4446
|
+
throw new Error(`Update Set session required for deployment. Error: ${error.message}`);
|
|
4447
|
+
}
|
|
4215
4448
|
}
|
|
4216
4449
|
/**
|
|
4217
4450
|
* DEPRECATION HANDLERS - Redirect old tools to new unified system
|