snow-flow 1.1.53 → 1.1.55
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/dist/mcp/servicenow-intelligent-mcp.js +288 -10
- package/dist/mcp/servicenow-intelligent-mcp.js.map +1 -1
- package/dist/orchestrator/flow-composer.d.ts.map +1 -1
- package/dist/orchestrator/flow-composer.js +17 -0
- package/dist/orchestrator/flow-composer.js.map +1 -1
- package/dist/utils/servicenow-client.d.ts +4 -0
- package/dist/utils/servicenow-client.d.ts.map +1 -1
- package/dist/utils/servicenow-client.js +174 -11
- package/dist/utils/servicenow-client.js.map +1 -1
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +26 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -2736,18 +2736,296 @@ class ServiceNowIntelligentMCP {
|
|
|
2736
2736
|
];
|
|
2737
2737
|
}
|
|
2738
2738
|
async attemptArtifactDeployment(artifact) {
|
|
2739
|
-
//
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
};
|
|
2739
|
+
// 🔧 CRITICAL FIX: Replace mock implementation with real ServiceNow API calls
|
|
2740
|
+
this.logger.info('Attempting real artifact deployment', {
|
|
2741
|
+
type: artifact.type,
|
|
2742
|
+
name: artifact.name || artifact.config?.name
|
|
2743
|
+
});
|
|
2744
|
+
try {
|
|
2745
|
+
let result;
|
|
2746
|
+
switch (artifact.type) {
|
|
2747
|
+
case 'flow':
|
|
2748
|
+
// Use the existing createFlow method
|
|
2749
|
+
result = await this.client.createFlow({
|
|
2750
|
+
name: artifact.config.name,
|
|
2751
|
+
description: artifact.config.description,
|
|
2752
|
+
type: artifact.config.flow_type || 'flow',
|
|
2753
|
+
table: artifact.config.table,
|
|
2754
|
+
trigger_type: artifact.config.trigger_type,
|
|
2755
|
+
condition: artifact.config.condition,
|
|
2756
|
+
active: artifact.config.active !== false,
|
|
2757
|
+
flow_definition: artifact.config.flow_definition,
|
|
2758
|
+
category: artifact.config.category || 'automation'
|
|
2759
|
+
});
|
|
2760
|
+
break;
|
|
2761
|
+
case 'subflow':
|
|
2762
|
+
// Use the existing createSubflow method
|
|
2763
|
+
result = await this.client.createSubflow({
|
|
2764
|
+
name: artifact.config.name,
|
|
2765
|
+
description: artifact.config.description,
|
|
2766
|
+
inputs: artifact.config.inputs || [],
|
|
2767
|
+
outputs: artifact.config.outputs || [],
|
|
2768
|
+
activities: artifact.config.activities || [],
|
|
2769
|
+
category: artifact.config.category || 'custom'
|
|
2770
|
+
});
|
|
2771
|
+
break;
|
|
2772
|
+
case 'widget':
|
|
2773
|
+
// Use existing createRecord method for Service Portal widgets
|
|
2774
|
+
result = await this.client.createRecord('sp_widget', {
|
|
2775
|
+
name: artifact.config.name,
|
|
2776
|
+
title: artifact.config.title || artifact.config.name,
|
|
2777
|
+
description: artifact.config.description,
|
|
2778
|
+
template: artifact.config.template || '<div>Widget content</div>',
|
|
2779
|
+
css: artifact.config.css || '',
|
|
2780
|
+
client_script: artifact.config.client_script || '',
|
|
2781
|
+
server_script: artifact.config.server_script || '',
|
|
2782
|
+
option_schema: artifact.config.option_schema || '[]',
|
|
2783
|
+
category: artifact.config.category || 'custom'
|
|
2784
|
+
});
|
|
2785
|
+
break;
|
|
2786
|
+
case 'business_rule':
|
|
2787
|
+
// Create business rule
|
|
2788
|
+
result = await this.client.createRecord('sys_script', {
|
|
2789
|
+
name: artifact.config.name,
|
|
2790
|
+
description: artifact.config.description,
|
|
2791
|
+
table: artifact.config.table || 'incident',
|
|
2792
|
+
when: artifact.config.when || 'before',
|
|
2793
|
+
active: artifact.config.active !== false,
|
|
2794
|
+
script: artifact.config.script || '// Business rule script',
|
|
2795
|
+
condition: artifact.config.condition || '',
|
|
2796
|
+
order: artifact.config.order || 100
|
|
2797
|
+
});
|
|
2798
|
+
break;
|
|
2799
|
+
case 'script_include':
|
|
2800
|
+
// Create script include
|
|
2801
|
+
result = await this.client.createRecord('sys_script_include', {
|
|
2802
|
+
name: artifact.config.name,
|
|
2803
|
+
description: artifact.config.description,
|
|
2804
|
+
script: artifact.config.script || 'var ' + artifact.config.name + ' = Class.create();',
|
|
2805
|
+
api_name: artifact.config.api_name || artifact.config.name,
|
|
2806
|
+
active: artifact.config.active !== false,
|
|
2807
|
+
accessible_from: artifact.config.accessible_from || 'all'
|
|
2808
|
+
});
|
|
2809
|
+
break;
|
|
2810
|
+
case 'table':
|
|
2811
|
+
// Create custom table
|
|
2812
|
+
result = await this.client.createRecord('sys_db_object', {
|
|
2813
|
+
name: artifact.config.name,
|
|
2814
|
+
label: artifact.config.label || artifact.config.name,
|
|
2815
|
+
super_class: artifact.config.super_class || 'task',
|
|
2816
|
+
create_module: artifact.config.create_module !== false,
|
|
2817
|
+
create_menu: artifact.config.create_menu !== false
|
|
2818
|
+
});
|
|
2819
|
+
break;
|
|
2820
|
+
case 'application':
|
|
2821
|
+
// Create scoped application
|
|
2822
|
+
result = await this.client.createRecord('sys_app', {
|
|
2823
|
+
name: artifact.config.name,
|
|
2824
|
+
description: artifact.config.description,
|
|
2825
|
+
scope: artifact.config.scope || 'x_custom_' + artifact.config.name.toLowerCase().replace(/\s+/g, '_'),
|
|
2826
|
+
version: artifact.config.version || '1.0.0',
|
|
2827
|
+
vendor: artifact.config.vendor || 'Custom',
|
|
2828
|
+
private: artifact.config.private !== false
|
|
2829
|
+
});
|
|
2830
|
+
break;
|
|
2831
|
+
default:
|
|
2832
|
+
throw new Error(`Unsupported artifact type: ${artifact.type}`);
|
|
2833
|
+
}
|
|
2834
|
+
if (result.success) {
|
|
2835
|
+
this.logger.info('Artifact deployed successfully', {
|
|
2836
|
+
type: artifact.type,
|
|
2837
|
+
name: artifact.config.name,
|
|
2838
|
+
sys_id: result.data?.sys_id
|
|
2839
|
+
});
|
|
2840
|
+
return {
|
|
2841
|
+
success: true,
|
|
2842
|
+
details: {
|
|
2843
|
+
deployed_at: new Date().toISOString(),
|
|
2844
|
+
sys_id: result.data?.sys_id,
|
|
2845
|
+
url: result.data?.url,
|
|
2846
|
+
type: artifact.type,
|
|
2847
|
+
name: artifact.config.name,
|
|
2848
|
+
deployment_method: 'real_api_call'
|
|
2849
|
+
}
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
else {
|
|
2853
|
+
throw new Error(result.error || 'Unknown deployment error');
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
catch (error) {
|
|
2857
|
+
this.logger.error('Artifact deployment failed', {
|
|
2858
|
+
type: artifact.type,
|
|
2859
|
+
name: artifact.config?.name,
|
|
2860
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2861
|
+
});
|
|
2862
|
+
return {
|
|
2863
|
+
success: false,
|
|
2864
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2865
|
+
details: {
|
|
2866
|
+
attempted_at: new Date().toISOString(),
|
|
2867
|
+
type: artifact.type,
|
|
2868
|
+
name: artifact.config?.name,
|
|
2869
|
+
deployment_method: 'real_api_call'
|
|
2870
|
+
}
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2744
2873
|
}
|
|
2745
2874
|
async applyFallbackStrategy(artifact, strategy) {
|
|
2746
|
-
//
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2875
|
+
// 🔧 CRITICAL FIX: Replace mock fallback with real implementation strategies
|
|
2876
|
+
this.logger.info('Applying fallback strategy', {
|
|
2877
|
+
strategy,
|
|
2878
|
+
artifactType: artifact.type,
|
|
2879
|
+
artifactName: artifact.config?.name
|
|
2880
|
+
});
|
|
2881
|
+
try {
|
|
2882
|
+
let result;
|
|
2883
|
+
switch (strategy) {
|
|
2884
|
+
case 'global_scope':
|
|
2885
|
+
// Try deploying to global scope with enhanced permissions
|
|
2886
|
+
artifact.config.scope = 'global';
|
|
2887
|
+
artifact.config.sys_domain = 'global';
|
|
2888
|
+
result = await this.attemptArtifactDeployment(artifact);
|
|
2889
|
+
break;
|
|
2890
|
+
case 'simplified_version':
|
|
2891
|
+
// Create a simplified version of the artifact
|
|
2892
|
+
const simplifiedArtifact = { ...artifact };
|
|
2893
|
+
if (artifact.type === 'flow') {
|
|
2894
|
+
// Simplify flow definition - remove complex activities
|
|
2895
|
+
const flowDef = typeof artifact.config.flow_definition === 'string'
|
|
2896
|
+
? JSON.parse(artifact.config.flow_definition)
|
|
2897
|
+
: artifact.config.flow_definition;
|
|
2898
|
+
if (flowDef.activities) {
|
|
2899
|
+
flowDef.activities = flowDef.activities.filter((activity) => ['approval', 'notification', 'script'].includes(activity.type));
|
|
2900
|
+
}
|
|
2901
|
+
simplifiedArtifact.config.flow_definition = JSON.stringify(flowDef);
|
|
2902
|
+
simplifiedArtifact.config.name += '_simplified';
|
|
2903
|
+
}
|
|
2904
|
+
else if (artifact.type === 'widget') {
|
|
2905
|
+
// Simplify widget - basic template only
|
|
2906
|
+
simplifiedArtifact.config.template = '<div>{{::data.message || "Widget loaded"}}</div>';
|
|
2907
|
+
simplifiedArtifact.config.css = '';
|
|
2908
|
+
simplifiedArtifact.config.client_script = '';
|
|
2909
|
+
simplifiedArtifact.config.name += '_simplified';
|
|
2910
|
+
}
|
|
2911
|
+
result = await this.attemptArtifactDeployment(simplifiedArtifact);
|
|
2912
|
+
break;
|
|
2913
|
+
case 'business_rule_fallback':
|
|
2914
|
+
// Convert flow to business rule as fallback
|
|
2915
|
+
if (artifact.type === 'flow') {
|
|
2916
|
+
const businessRuleConfig = {
|
|
2917
|
+
name: `BR_${artifact.config.name}`,
|
|
2918
|
+
description: `Business Rule fallback for flow: ${artifact.config.name}`,
|
|
2919
|
+
table: artifact.config.table || 'incident',
|
|
2920
|
+
when: 'after',
|
|
2921
|
+
script: `
|
|
2922
|
+
// Auto-generated Business Rule fallback for Flow: ${artifact.config.name}
|
|
2923
|
+
// Original flow description: ${artifact.config.description || 'No description'}
|
|
2924
|
+
|
|
2925
|
+
try {
|
|
2926
|
+
// Basic automation logic
|
|
2927
|
+
if (current.isNewRecord()) {
|
|
2928
|
+
gs.info('Record created, executing flow logic: ${artifact.config.name}');
|
|
2929
|
+
|
|
2930
|
+
// Add your custom logic here based on original flow
|
|
2931
|
+
${this.generateBusinessRuleScript(artifact.config)}
|
|
2932
|
+
}
|
|
2933
|
+
} catch (e) {
|
|
2934
|
+
gs.error('Business Rule fallback error: ' + e.message);
|
|
2935
|
+
}
|
|
2936
|
+
`.trim(),
|
|
2937
|
+
active: true,
|
|
2938
|
+
condition: artifact.config.condition || ''
|
|
2939
|
+
};
|
|
2940
|
+
result = await this.client.createRecord('sys_script', businessRuleConfig);
|
|
2941
|
+
}
|
|
2942
|
+
else {
|
|
2943
|
+
throw new Error('Business rule fallback only available for flows');
|
|
2944
|
+
}
|
|
2945
|
+
break;
|
|
2946
|
+
case 'minimal_deployment':
|
|
2947
|
+
// Deploy with absolute minimum configuration
|
|
2948
|
+
const minimalArtifact = { ...artifact };
|
|
2949
|
+
// Strip all non-essential properties
|
|
2950
|
+
const essentialFields = ['name', 'description', 'active'];
|
|
2951
|
+
const cleanedConfig = {};
|
|
2952
|
+
essentialFields.forEach(field => {
|
|
2953
|
+
if (artifact.config[field] !== undefined) {
|
|
2954
|
+
cleanedConfig[field] = artifact.config[field];
|
|
2955
|
+
}
|
|
2956
|
+
});
|
|
2957
|
+
// Add type-specific essentials
|
|
2958
|
+
if (artifact.type === 'flow') {
|
|
2959
|
+
cleanedConfig.type = 'subflow'; // Subflows are simpler
|
|
2960
|
+
cleanedConfig.category = 'custom';
|
|
2961
|
+
}
|
|
2962
|
+
else if (artifact.type === 'widget') {
|
|
2963
|
+
cleanedConfig.template = '<div>Minimal Widget</div>';
|
|
2964
|
+
}
|
|
2965
|
+
minimalArtifact.config = cleanedConfig;
|
|
2966
|
+
minimalArtifact.config.name += '_minimal';
|
|
2967
|
+
result = await this.attemptArtifactDeployment(minimalArtifact);
|
|
2968
|
+
break;
|
|
2969
|
+
case 'delayed_retry':
|
|
2970
|
+
// Wait and retry original deployment
|
|
2971
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
2972
|
+
result = await this.attemptArtifactDeployment(artifact);
|
|
2973
|
+
break;
|
|
2974
|
+
default:
|
|
2975
|
+
throw new Error(`Unknown fallback strategy: ${strategy}`);
|
|
2976
|
+
}
|
|
2977
|
+
if (result.success) {
|
|
2978
|
+
this.logger.info('Fallback strategy successful', {
|
|
2979
|
+
strategy,
|
|
2980
|
+
artifactType: artifact.type,
|
|
2981
|
+
artifactName: artifact.config?.name,
|
|
2982
|
+
deployedSysId: result.details?.sys_id
|
|
2983
|
+
});
|
|
2984
|
+
return {
|
|
2985
|
+
success: true,
|
|
2986
|
+
details: {
|
|
2987
|
+
fallback_strategy: strategy,
|
|
2988
|
+
applied_at: new Date().toISOString(),
|
|
2989
|
+
original_artifact: artifact.config?.name,
|
|
2990
|
+
deployed_artifact: result.details?.name || artifact.config?.name,
|
|
2991
|
+
sys_id: result.details?.sys_id,
|
|
2992
|
+
deployment_method: 'fallback_strategy'
|
|
2993
|
+
}
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
else {
|
|
2997
|
+
throw new Error(result.error || `Fallback strategy ${strategy} failed`);
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
catch (error) {
|
|
3001
|
+
this.logger.error('Fallback strategy failed', {
|
|
3002
|
+
strategy,
|
|
3003
|
+
artifactType: artifact.type,
|
|
3004
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3005
|
+
});
|
|
3006
|
+
return {
|
|
3007
|
+
success: false,
|
|
3008
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3009
|
+
details: {
|
|
3010
|
+
fallback_strategy: strategy,
|
|
3011
|
+
attempted_at: new Date().toISOString(),
|
|
3012
|
+
original_artifact: artifact.config?.name,
|
|
3013
|
+
deployment_method: 'fallback_strategy'
|
|
3014
|
+
}
|
|
3015
|
+
};
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
generateBusinessRuleScript(flowConfig) {
|
|
3019
|
+
// Generate basic business rule script based on flow configuration
|
|
3020
|
+
let script = '// Generated business rule logic\n';
|
|
3021
|
+
if (flowConfig.trigger_type === 'record_created') {
|
|
3022
|
+
script += 'gs.info("Record created trigger activated");\n';
|
|
3023
|
+
}
|
|
3024
|
+
if (flowConfig.condition) {
|
|
3025
|
+
script += `// Original condition: ${flowConfig.condition}\n`;
|
|
3026
|
+
}
|
|
3027
|
+
script += 'gs.info("Business rule executed successfully");\n';
|
|
3028
|
+
return script;
|
|
2751
3029
|
}
|
|
2752
3030
|
async generateFlowTestData(flow) {
|
|
2753
3031
|
return {
|