snow-flow 1.1.70 → 1.1.71

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.
@@ -2524,10 +2524,13 @@ class ServiceNowIntelligentMCP {
2524
2524
  orchestration_id: `orchestration_${Date.now()}`,
2525
2525
  started_at: new Date().toISOString(),
2526
2526
  status: 'initializing',
2527
+ mode: auto_deploy ? '🚀 DEPLOYMENT MODE (WILL CREATE REAL ARTIFACTS)' : '📋 PLANNING MODE (ANALYSIS ONLY)',
2528
+ warning: auto_deploy ? '⚠️ WARNING: This will create REAL artifacts in ServiceNow!' : '✅ SAFE: This is planning only, no artifacts will be created',
2527
2529
  agents_spawned: [],
2528
2530
  shared_memory_enabled: shared_memory,
2529
2531
  progress_monitor: {},
2530
- execution_plan: {}
2532
+ execution_plan: {},
2533
+ actual_deployments: []
2531
2534
  };
2532
2535
  // Step 1: Analyze requirements
2533
2536
  if (smart_discovery) {
@@ -2599,13 +2602,98 @@ class ServiceNowIntelligentMCP {
2599
2602
  completion_notifications: true
2600
2603
  };
2601
2604
  }
2602
- orchestration.status = 'ready_for_execution';
2603
- orchestration.next_steps = [
2604
- 'Execute snow_resilient_deployment to begin artifact development',
2605
- 'Monitor progress using progress_monitor configuration',
2606
- 'Use snow_comprehensive_flow_test for validation phase',
2607
- 'Deploy using automatic deployment if auto_deploy is enabled'
2608
- ];
2605
+ // Step 6: Execute actual deployment if auto_deploy is enabled
2606
+ if (auto_deploy) {
2607
+ orchestration.status = 'executing_deployment';
2608
+ // Attempt to create real artifacts based on the objective
2609
+ try {
2610
+ const artifactAnalysis = await this.analyzeArtifactRequirements(objective);
2611
+ for (const artifact of artifactAnalysis.recommended_artifacts) {
2612
+ try {
2613
+ let deploymentResult;
2614
+ if (artifact.type === 'flow') {
2615
+ // Use flow composer to create real flow
2616
+ deploymentResult = await this.client.post('/api/now/table/sys_hub_flow', {
2617
+ name: artifact.name,
2618
+ description: artifact.description,
2619
+ active: true,
2620
+ type: 'flow'
2621
+ });
2622
+ }
2623
+ else if (artifact.type === 'widget') {
2624
+ // Create real widget
2625
+ deploymentResult = await this.client.post('/api/now/table/sp_widget', {
2626
+ name: artifact.name,
2627
+ title: artifact.name,
2628
+ description: artifact.description,
2629
+ template: artifact.template || '<div>{{data.message || "Widget created"}}</div>',
2630
+ css: artifact.css || '',
2631
+ client_script: artifact.client_script || '',
2632
+ server_script: artifact.server_script || '(function() { data.message = "Successfully deployed!"; })()',
2633
+ public: true,
2634
+ has_preview: true
2635
+ });
2636
+ }
2637
+ if (deploymentResult?.result) {
2638
+ orchestration.actual_deployments.push({
2639
+ type: artifact.type,
2640
+ name: artifact.name,
2641
+ sys_id: deploymentResult.result.sys_id,
2642
+ status: 'deployed',
2643
+ url: `https://${process.env.SNOW_INSTANCE ? process.env.SNOW_INSTANCE.replace(/\/$/, '') : 'instance'}.service-now.com/nav_to.do?uri=${artifact.type === 'flow' ? 'sys_hub_flow' : 'sp_widget'}.do?sys_id=${deploymentResult.result.sys_id}`
2644
+ });
2645
+ }
2646
+ }
2647
+ catch (deployError) {
2648
+ orchestration.actual_deployments.push({
2649
+ type: artifact.type,
2650
+ name: artifact.name,
2651
+ status: 'failed',
2652
+ error: deployError instanceof Error ? deployError.message : String(deployError)
2653
+ });
2654
+ }
2655
+ }
2656
+ orchestration.status = 'deployment_complete';
2657
+ orchestration.completed_at = new Date().toISOString();
2658
+ }
2659
+ catch (error) {
2660
+ orchestration.status = 'deployment_failed';
2661
+ orchestration.deployment_error = error instanceof Error ? error.message : String(error);
2662
+ }
2663
+ }
2664
+ else {
2665
+ orchestration.status = 'planning_complete';
2666
+ orchestration.completed_at = new Date().toISOString();
2667
+ }
2668
+ // Set appropriate next steps based on mode
2669
+ if (auto_deploy) {
2670
+ if (orchestration.actual_deployments.length > 0) {
2671
+ orchestration.next_steps = [
2672
+ '✅ DEPLOYMENT COMPLETE: Real artifacts have been created in ServiceNow',
2673
+ `📊 Created ${orchestration.actual_deployments.filter((d) => d.status === 'deployed').length} artifacts successfully`,
2674
+ 'Use snow_test_flow_execution or snow_widget_test to validate deployments',
2675
+ 'Check ServiceNow instance to verify artifacts are working correctly'
2676
+ ];
2677
+ }
2678
+ else {
2679
+ orchestration.next_steps = [
2680
+ '❌ DEPLOYMENT FAILED: No artifacts were created',
2681
+ 'Check deployment errors in actual_deployments array',
2682
+ 'Verify ServiceNow permissions and authentication',
2683
+ 'Consider running in planning mode first (auto_deploy: false)'
2684
+ ];
2685
+ }
2686
+ }
2687
+ else {
2688
+ orchestration.next_steps = [
2689
+ '📋 PLANNING COMPLETE: This was analysis only - no artifacts created',
2690
+ '🚀 To deploy: Re-run with auto_deploy: true',
2691
+ 'Execute specific MCP tools manually:',
2692
+ ' - snow_create_flow for flow creation',
2693
+ ' - snow_deploy_widget for widget deployment',
2694
+ ' - snow_resilient_deployment for batch deployment'
2695
+ ];
2696
+ }
2609
2697
  return { content: [{ type: 'text', text: JSON.stringify(orchestration, null, 2) }] };
2610
2698
  }
2611
2699
  catch (error) {
@@ -3249,6 +3337,53 @@ try {
3249
3337
  details: 'Custom scenario executed successfully'
3250
3338
  };
3251
3339
  }
3340
+ async analyzeArtifactRequirements(objective) {
3341
+ const artifactAnalysis = {
3342
+ objective,
3343
+ recommended_artifacts: []
3344
+ };
3345
+ const lowerObjective = objective.toLowerCase();
3346
+ // Simple keyword-based analysis for artifact type detection
3347
+ if (lowerObjective.includes('flow') || lowerObjective.includes('workflow') || lowerObjective.includes('automation')) {
3348
+ artifactAnalysis.recommended_artifacts.push({
3349
+ type: 'flow',
3350
+ name: `Flow for ${objective.substring(0, 50)}`,
3351
+ description: `Automated flow created for: ${objective}`,
3352
+ priority: 'high'
3353
+ });
3354
+ }
3355
+ if (lowerObjective.includes('widget') || lowerObjective.includes('dashboard') || lowerObjective.includes('display')) {
3356
+ artifactAnalysis.recommended_artifacts.push({
3357
+ type: 'widget',
3358
+ name: `Widget for ${objective.substring(0, 50)}`,
3359
+ description: `Service Portal widget for: ${objective}`,
3360
+ template: '<div class="panel panel-default"><div class="panel-body">{{data.message || "Widget deployed successfully"}}<br><small>Created for: ' + objective + '</small></div></div>',
3361
+ css: '.panel { margin: 10px; }',
3362
+ client_script: 'function() { console.log("Widget loaded"); }',
3363
+ server_script: '(function() { data.message = "Successfully deployed for: ' + objective.replace(/"/g, '\\"') + '"; })()',
3364
+ priority: 'medium'
3365
+ });
3366
+ }
3367
+ if (lowerObjective.includes('script') || lowerObjective.includes('function') || lowerObjective.includes('utility')) {
3368
+ artifactAnalysis.recommended_artifacts.push({
3369
+ type: 'script_include',
3370
+ name: `Script for ${objective.substring(0, 50)}`,
3371
+ description: `Script include for: ${objective}`,
3372
+ script: `// Script created for: ${objective}\nvar ScriptUtility = Class.create();\nScriptUtility.prototype = {\n initialize: function() {},\n execute: function() {\n gs.info('Script executed for: ${objective}');\n return true;\n },\n type: 'ScriptUtility'\n};\n`,
3373
+ priority: 'low'
3374
+ });
3375
+ }
3376
+ // If no specific artifacts detected, create a default flow
3377
+ if (artifactAnalysis.recommended_artifacts.length === 0) {
3378
+ artifactAnalysis.recommended_artifacts.push({
3379
+ type: 'flow',
3380
+ name: `General Flow for ${objective.substring(0, 40)}`,
3381
+ description: `General purpose flow for: ${objective}`,
3382
+ priority: 'medium'
3383
+ });
3384
+ }
3385
+ return artifactAnalysis;
3386
+ }
3252
3387
  generateTestRecommendations(testResults) {
3253
3388
  const recommendations = [];
3254
3389
  if (testResults.test_summary.success_rate < 90) {