snow-flow 3.4.29 → 3.4.30

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/cli.js CHANGED
@@ -123,9 +123,60 @@ program
123
123
  .option('--auto-confirm', 'Auto-confirm background script executions (bypasses human-in-the-loop)')
124
124
  .option('--no-auto-confirm', 'Force confirmation for all background scripts (default behavior)')
125
125
  .option('--verbose', 'Show detailed execution information')
126
+ .option('--debug', 'Enable debug mode (sets LOG_LEVEL=debug)')
127
+ .option('--trace', 'Enable trace mode (MAXIMUM debug output - sets LOG_LEVEL=trace)')
128
+ .option('--debug-mcp', 'Enable MCP server debug output')
129
+ .option('--debug-http', 'Enable HTTP request/response debugging')
130
+ .option('--debug-memory', 'Enable memory operation debugging')
131
+ .option('--debug-servicenow', 'Enable ServiceNow API debugging')
132
+ .option('--debug-all', 'Enable ALL debug output (WARNING: Very verbose!)')
126
133
  .action(async (objective, options) => {
127
134
  // Check for flow deprecation first
128
135
  checkFlowDeprecation('swarm', objective);
136
+ // Set debug levels based on options
137
+ if (options.debugAll) {
138
+ process.env.DEBUG = '*';
139
+ process.env.LOG_LEVEL = 'trace';
140
+ process.env.SNOW_FLOW_DEBUG = 'true';
141
+ process.env.MCP_DEBUG = 'true';
142
+ process.env.MCP_LOG_LEVEL = 'trace';
143
+ process.env.HTTP_TRACE = 'true';
144
+ process.env.VERBOSE = 'true';
145
+ cliLogger.info('šŸ” DEBUG MODE: ALL (Maximum verbosity enabled!)');
146
+ }
147
+ else {
148
+ if (options.trace) {
149
+ process.env.LOG_LEVEL = 'trace';
150
+ process.env.SNOW_FLOW_TRACE = 'true';
151
+ cliLogger.info('šŸ” TRACE MODE: Enabled (Maximum detail level)');
152
+ }
153
+ else if (options.debug) {
154
+ process.env.LOG_LEVEL = 'debug';
155
+ process.env.SNOW_FLOW_DEBUG = 'true';
156
+ cliLogger.info('šŸ” DEBUG MODE: Enabled');
157
+ }
158
+ if (options.debugMcp) {
159
+ process.env.MCP_DEBUG = 'true';
160
+ process.env.MCP_LOG_LEVEL = 'trace';
161
+ cliLogger.info('šŸ” MCP DEBUG: Enabled');
162
+ }
163
+ if (options.debugHttp) {
164
+ process.env.HTTP_TRACE = 'true';
165
+ cliLogger.info('šŸ” HTTP DEBUG: Enabled (Request/Response tracing)');
166
+ }
167
+ if (options.debugMemory) {
168
+ process.env.DEBUG = process.env.DEBUG ? `${process.env.DEBUG},memory:*` : 'memory:*';
169
+ cliLogger.info('šŸ” MEMORY DEBUG: Enabled');
170
+ }
171
+ if (options.debugServicenow) {
172
+ process.env.DEBUG = process.env.DEBUG ? `${process.env.DEBUG},servicenow:*` : 'servicenow:*';
173
+ cliLogger.info('šŸ” SERVICENOW DEBUG: Enabled');
174
+ }
175
+ if (options.verbose) {
176
+ process.env.VERBOSE = 'true';
177
+ cliLogger.info('šŸ” VERBOSE MODE: Enabled');
178
+ }
179
+ }
129
180
  // Always show essential info
130
181
  cliLogger.info(`\nšŸš€ Snow-Flow v${version_js_1.VERSION}`);
131
182
  cliLogger.info(`šŸ“‹ Objective: ${objective}`);
@@ -464,9 +515,25 @@ async function executeClaudeCode(prompt) {
464
515
  const claudeArgs = hasMcpConfig
465
516
  ? ['--mcp-config', '.mcp.json', '--dangerously-skip-permissions']
466
517
  : ['--dangerously-skip-permissions'];
518
+ // Add debug args if debug is enabled
519
+ if (process.env.SNOW_FLOW_DEBUG === 'true' || process.env.LOG_LEVEL === 'debug' || process.env.LOG_LEVEL === 'trace') {
520
+ claudeArgs.push('--verbose');
521
+ if (process.env.LOG_LEVEL === 'trace') {
522
+ claudeArgs.push('--trace');
523
+ }
524
+ }
467
525
  cliLogger.info('šŸš€ Launching Claude Code automatically...');
468
526
  if (hasMcpConfig) {
469
527
  cliLogger.info('šŸ”§ Starting Claude Code with ServiceNow MCP servers...');
528
+ if (process.env.MCP_DEBUG === 'true') {
529
+ cliLogger.info('šŸ” MCP Debug Mode Active - Expect detailed connection logs');
530
+ }
531
+ }
532
+ // Debug output if enabled
533
+ if (process.env.SNOW_FLOW_DEBUG === 'true' || process.env.VERBOSE === 'true') {
534
+ cliLogger.info(`šŸ” Claude Command: claude ${claudeArgs.join(' ')}`);
535
+ cliLogger.info(`šŸ” Working Directory: ${process.cwd()}`);
536
+ cliLogger.info(`šŸ” MCP Config: ${mcpConfigPath}`);
470
537
  }
471
538
  // Start Claude Code process in interactive mode with stdin piping
472
539
  const claudeProcess = (0, child_process_1.spawn)('claude', claudeArgs, {
@@ -546,80 +613,6 @@ function startMonitoringDashboard(claudeProcess) {
546
613
  }, 5000); // Check every 5 seconds silently
547
614
  return monitoringInterval;
548
615
  }
549
- async function executeWithClaude(claudeCommand, prompt, resolve) {
550
- cliLogger.info('šŸš€ Starting Claude Code execution...');
551
- // Write prompt to temporary file for large prompts
552
- const tempFile = (0, path_1.join)(process.cwd(), '.snow-flow-prompt.tmp');
553
- await fs_1.promises.writeFile(tempFile, prompt);
554
- // Check if .mcp.json exists in current directory
555
- const mcpConfigPath = (0, path_1.join)(process.cwd(), '.mcp.json');
556
- let hasMcpConfig = false;
557
- try {
558
- await fs_1.promises.access(mcpConfigPath);
559
- hasMcpConfig = true;
560
- cliLogger.info('āœ… Found MCP configuration in current directory');
561
- }
562
- catch {
563
- cliLogger.warn('āš ļø No MCP configuration found. Run "snow-flow init" to set up MCP servers');
564
- }
565
- const claudeArgs = hasMcpConfig
566
- ? ['--mcp-config', '.mcp.json', '--dangerously-skip-permissions']
567
- : ['--dangerously-skip-permissions'];
568
- if (hasMcpConfig) {
569
- cliLogger.info('šŸ”§ Starting Claude Code with ServiceNow MCP servers...');
570
- }
571
- // Start Claude Code process in interactive mode
572
- const claudeProcess = (0, child_process_1.spawn)(claudeCommand, claudeArgs, {
573
- stdio: ['pipe', 'inherit', 'inherit'], // inherit stdout/stderr for interactive mode
574
- cwd: process.cwd()
575
- });
576
- // Send the prompt via stdin
577
- cliLogger.info('šŸ“ Sending orchestration prompt to Claude Code...');
578
- cliLogger.info('šŸš€ Claude Code interactive interface opening...\n');
579
- claudeProcess.stdin.write(prompt);
580
- claudeProcess.stdin.end();
581
- // Start silent monitoring dashboard (doesn't interfere with Claude Code UI)
582
- const monitoringInterval = startMonitoringDashboard(claudeProcess);
583
- claudeProcess.on('close', (code) => {
584
- clearInterval(monitoringInterval);
585
- if (code === 0) {
586
- cliLogger.info('\nāœ… Claude Code session completed successfully!');
587
- resolve(true);
588
- }
589
- else {
590
- cliLogger.warn(`\nāŒ Claude Code session ended with code: ${code}`);
591
- resolve(false);
592
- }
593
- });
594
- claudeProcess.on('error', (error) => {
595
- clearInterval(monitoringInterval);
596
- cliLogger.error(`āŒ Failed to start Claude Code: ${error.message}`);
597
- resolve(false);
598
- });
599
- // Set timeout for Claude Code execution (configurable via environment variable)
600
- const timeoutMinutes = process.env.SNOW_FLOW_TIMEOUT_MINUTES ? parseInt(process.env.SNOW_FLOW_TIMEOUT_MINUTES) : 60;
601
- const timeoutMs = timeoutMinutes * 60 * 1000;
602
- cliLogger.info(`ā±ļø Claude Code timeout set to ${timeoutMinutes} minutes (configure with SNOW_FLOW_TIMEOUT_MINUTES=0 for no timeout)`);
603
- let timeout = null;
604
- // Only set timeout if not disabled (0 = no timeout)
605
- if (timeoutMinutes > 0) {
606
- timeout = setTimeout(() => {
607
- clearInterval(monitoringInterval);
608
- cliLogger.warn(`ā±ļø Claude Code session timeout (${timeoutMinutes} minutes), terminating...`);
609
- claudeProcess.kill('SIGTERM');
610
- // Force kill if it doesn't respond
611
- setTimeout(() => {
612
- claudeProcess.kill('SIGKILL');
613
- }, 2000);
614
- resolve(false);
615
- }, timeoutMs);
616
- }
617
- claudeProcess.on('close', () => {
618
- if (timeout) {
619
- clearTimeout(timeout);
620
- }
621
- });
622
- }
623
616
  // Helper function to build Queen Agent orchestration prompt
624
617
  // Helper function to build Queen Agent orchestration prompt - CLEANED UP VERSION
625
618
  function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated = false, sessionId, isFlowDesignerTask = false) {
@@ -920,6 +920,10 @@ export declare class ServiceNowAdvancedFeaturesMCP extends BaseMCPServer {
920
920
  private generateMonitoringHtmlReport;
921
921
  private generateMetricsExport;
922
922
  private generateAlertSummary;
923
+ /**
924
+ * Run the MCP server
925
+ */
926
+ run(): Promise<void>;
923
927
  }
924
928
  export default ServiceNowAdvancedFeaturesMCP;
925
929
  //# sourceMappingURL=servicenow-advanced-features-mcp.d.ts.map
@@ -9,6 +9,7 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.ServiceNowAdvancedFeaturesMCP = void 0;
11
11
  const base_mcp_server_js_1 = require("../base-mcp-server.js");
12
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
12
13
  const snow_memory_manager_js_1 = require("../../utils/snow-memory-manager.js");
13
14
  class ServiceNowAdvancedFeaturesMCP extends base_mcp_server_js_1.BaseMCPServer {
14
15
  constructor() {
@@ -14148,12 +14149,21 @@ function getIncidentsByUser(userSysId) {
14148
14149
  size: JSON.stringify(alertSummary).length
14149
14150
  };
14150
14151
  }
14152
+ /**
14153
+ * Run the MCP server
14154
+ */
14155
+ async run() {
14156
+ const transport = new stdio_js_1.StdioServerTransport();
14157
+ await this.server.connect(transport);
14158
+ // Use stderr for logs to keep stdout clean for JSON-RPC
14159
+ console.error('ServiceNow Advanced Features MCP server running on stdio');
14160
+ }
14151
14161
  }
14152
14162
  exports.ServiceNowAdvancedFeaturesMCP = ServiceNowAdvancedFeaturesMCP;
14153
14163
  // CLI entry point
14154
14164
  if (require.main === module) {
14155
14165
  const server = new ServiceNowAdvancedFeaturesMCP();
14156
- server.start().catch(console.error);
14166
+ server.run().catch(console.error);
14157
14167
  }
14158
14168
  exports.default = ServiceNowAdvancedFeaturesMCP;
14159
14169
  //# sourceMappingURL=servicenow-advanced-features-mcp.js.map
@@ -210,13 +210,13 @@ class ServiceDiscoveryClient {
210
210
  * COMPATIBILITY FIX: makeRequest method for phantom calls
211
211
  */
212
212
  async makeRequest(config) {
213
- console.log('šŸ”§ ServiceDiscoveryClient.makeRequest called with config:', config);
213
+ console.error('šŸ”§ ServiceDiscoveryClient.makeRequest called with config:', config);
214
214
  try {
215
215
  // Route the request to the appropriate HTTP method
216
216
  const method = (config.method || 'GET').toLowerCase();
217
217
  const url = config.url || config.endpoint;
218
218
  const data = config.data || config.body;
219
- console.log(`šŸ”§ ServiceDiscovery routing ${method.toUpperCase()} request to: ${url}`);
219
+ console.error(`šŸ”§ ServiceDiscovery routing ${method.toUpperCase()} request to: ${url}`);
220
220
  switch (method) {
221
221
  case 'get':
222
222
  return await this.client.get(url, { params: config.params });
@@ -548,7 +548,7 @@ class ServiceNowDeploymentMCP {
548
548
  // Create the sys_update_xml record to track the artifact
549
549
  const trackingResult = await this.client.createRecord('sys_update_xml', updateXmlData);
550
550
  if (trackingResult.success) {
551
- console.log(`āœ… Artifact tracked in Update Set: ${artifact.name} (${artifact.sys_id})`);
551
+ console.error(`āœ… Artifact tracked in Update Set: ${artifact.name} (${artifact.sys_id})`);
552
552
  }
553
553
  else {
554
554
  console.warn(`āš ļø Failed to track artifact in Update Set: ${trackingResult.error}`);
@@ -8593,7 +8593,7 @@ Use \`snow_deploy\` to create a new ${args.type} instead.`
8593
8593
  - "Change the title to 'New Widget Title'"
8594
8594
  - "Update the description to 'Updated description'"
8595
8595
  - "Add this CSS: .my-class { color: blue; }"
8596
- - "Change the script to: function() { console.log('updated'); }"
8596
+ - "Change the script to: function() { console.error('updated'); }"
8597
8597
  - "Set active to false"
8598
8598
 
8599
8599
  šŸ’” **Or use the config parameter directly:**
@@ -9077,10 +9077,19 @@ c.$onInit = function() {
9077
9077
  .replace(/"/g, '&quot;')
9078
9078
  .replace(/'/g, '&apos;');
9079
9079
  }
9080
+ /**
9081
+ * Run the MCP server
9082
+ */
9083
+ async run() {
9084
+ const transport = new stdio_js_1.StdioServerTransport();
9085
+ await this.server.connect(transport);
9086
+ // Use stderr for logs to keep stdout clean for JSON-RPC
9087
+ console.error('ServiceNow Deployment MCP server running on stdio');
9088
+ }
9080
9089
  }
9081
9090
  // Start the server
9082
9091
  const server = new ServiceNowDeploymentMCP();
9083
- server.start().catch((error) => {
9092
+ server.run().catch((error) => {
9084
9093
  console.error('Failed to start ServiceNow Deployment MCP:', error);
9085
9094
  process.exit(1);
9086
9095
  });
@@ -626,7 +626,7 @@ class ServiceNowMCPServer {
626
626
  // Keep the server running
627
627
  await new Promise((resolve) => {
628
628
  process.on('SIGINT', () => {
629
- console.log('\nServiceNow MCP Server shutting down...');
629
+ console.error('\nServiceNow MCP Server shutting down...');
630
630
  resolve();
631
631
  });
632
632
  });
@@ -65,6 +65,6 @@ export declare class ServiceNowSystemPropertiesMCP {
65
65
  * Get property audit history
66
66
  */
67
67
  private getPropertyHistory;
68
- start(): Promise<void>;
68
+ run(): Promise<void>;
69
69
  }
70
70
  //# sourceMappingURL=servicenow-system-properties-mcp.d.ts.map
@@ -1156,16 +1156,17 @@ Note: Audit history requires sys_audit to be enabled for sys_properties table.`
1156
1156
  };
1157
1157
  }
1158
1158
  }
1159
- async start() {
1159
+ async run() {
1160
1160
  const transport = new stdio_js_1.StdioServerTransport();
1161
1161
  await this.server.connect(transport);
1162
- this.logger.info('ServiceNow System Properties MCP Server started');
1162
+ // Use stderr for logs to keep stdout clean for JSON-RPC
1163
+ console.error('ServiceNow System Properties MCP Server running on stdio');
1163
1164
  }
1164
1165
  }
1165
1166
  exports.ServiceNowSystemPropertiesMCP = ServiceNowSystemPropertiesMCP;
1166
1167
  // Start the server
1167
1168
  const server = new ServiceNowSystemPropertiesMCP();
1168
- server.start().catch((error) => {
1169
+ server.run().catch((error) => {
1169
1170
  console.error('Failed to start ServiceNow System Properties MCP:', error);
1170
1171
  process.exit(1);
1171
1172
  });
@@ -37,16 +37,16 @@ class ServiceNowUpdateSetMCP {
37
37
  * Test credentials on startup
38
38
  */
39
39
  async testCredentials() {
40
- console.log('šŸ” [UPDATE-SET MCP] Testing credentials...');
40
+ console.error('šŸ” [UPDATE-SET MCP] Testing credentials...');
41
41
  try {
42
42
  const credentials = await this.oauth.loadCredentials();
43
43
  if (credentials) {
44
- console.log('āœ… [UPDATE-SET MCP] Credentials loaded successfully');
44
+ console.error('āœ… [UPDATE-SET MCP] Credentials loaded successfully');
45
45
  const isAuth = await this.oauth.isAuthenticated();
46
- console.log(`šŸ” [UPDATE-SET MCP] Authentication status: ${isAuth ? 'āœ… Valid' : 'āŒ Expired'}`);
46
+ console.error(`šŸ” [UPDATE-SET MCP] Authentication status: ${isAuth ? 'āœ… Valid' : 'āŒ Expired'}`);
47
47
  }
48
48
  else {
49
- console.log('āŒ [UPDATE-SET MCP] No credentials found');
49
+ console.error('āŒ [UPDATE-SET MCP] No credentials found');
50
50
  }
51
51
  }
52
52
  catch (error) {
@@ -48,7 +48,7 @@ async function startAllServers() {
48
48
  logger.warn('āš ļø DEPRECATED: This start-all-mcp-servers.ts script is deprecated!');
49
49
  logger.warn(' Please use MCPServerManager or scripts/start-mcp-proper.js instead');
50
50
  logger.warn(' This provides proper process management and singleton protection');
51
- console.log('\nšŸ”„ Redirecting to proper MCPServerManager...\n');
51
+ console.error('\nšŸ”„ Redirecting to proper MCPServerManager...\n');
52
52
  try {
53
53
  // Redirect to proper approach
54
54
  const { MCPServerManager } = await Promise.resolve().then(() => __importStar(require('../utils/mcp-server-manager.js')));
@@ -14,19 +14,19 @@ const dotenv_1 = __importDefault(require("dotenv"));
14
14
  // Load environment variables
15
15
  dotenv_1.default.config();
16
16
  async function startServiceNowMCPServer() {
17
- console.log('šŸš€ Starting ServiceNow MCP Server...');
17
+ console.error('šŸš€ Starting ServiceNow MCP Server...');
18
18
  // Check if OAuth is configured
19
19
  const oauth = new snow_oauth_js_1.ServiceNowOAuth();
20
20
  const isAuthenticated = await oauth.isAuthenticated();
21
21
  if (isAuthenticated) {
22
- console.log('āœ… ServiceNow OAuth authentication detected');
22
+ console.error('āœ… ServiceNow OAuth authentication detected');
23
23
  const credentials = await oauth.loadCredentials();
24
- console.log(`šŸ¢ Instance: ${credentials?.instance}`);
24
+ console.error(`šŸ¢ Instance: ${credentials?.instance}`);
25
25
  }
26
26
  else {
27
- console.log('āš ļø ServiceNow OAuth not configured');
28
- console.log('šŸ’” Some tools will be unavailable until authentication is complete');
29
- console.log('šŸ”‘ Run "snow-flow auth login" to authenticate');
27
+ console.error('āš ļø ServiceNow OAuth not configured');
28
+ console.error('šŸ’” Some tools will be unavailable until authentication is complete');
29
+ console.error('šŸ”‘ Run "snow-flow auth login" to authenticate');
30
30
  }
31
31
  const config = {
32
32
  name: "servicenow-mcp-server",
@@ -37,19 +37,19 @@ async function startServiceNowMCPServer() {
37
37
  clientSecret: process.env.SNOW_CLIENT_SECRET || ''
38
38
  }
39
39
  };
40
- console.log('šŸ”§ MCP Server Configuration:');
41
- console.log(` šŸ“› Name: ${config.name}`);
42
- console.log(` šŸ·ļø Version: ${config.version}`);
43
- console.log(` šŸ¢ Instance: ${config.oauth.instance || 'Not configured'}`);
44
- console.log(` šŸ”‘ Client ID: ${config.oauth.clientId ? 'āœ… Set' : 'āŒ Not set'}`);
45
- console.log(` šŸ” Client Secret: ${config.oauth.clientSecret ? 'āœ… Set' : 'āŒ Not set'}`);
46
- console.log('');
40
+ console.error('šŸ”§ MCP Server Configuration:');
41
+ console.error(` šŸ“› Name: ${config.name}`);
42
+ console.error(` šŸ·ļø Version: ${config.version}`);
43
+ console.error(` šŸ¢ Instance: ${config.oauth.instance || 'Not configured'}`);
44
+ console.error(` šŸ”‘ Client ID: ${config.oauth.clientId ? 'āœ… Set' : 'āŒ Not set'}`);
45
+ console.error(` šŸ” Client Secret: ${config.oauth.clientSecret ? 'āœ… Set' : 'āŒ Not set'}`);
46
+ console.error('');
47
47
  const server = new servicenow_mcp_server_js_1.ServiceNowMCPServer(config);
48
- console.log('🌐 ServiceNow MCP Server is running...');
49
- console.log('šŸ’” This server provides Claude Code with direct access to ServiceNow APIs');
50
- console.log('šŸ”§ Available tools depend on authentication status');
51
- console.log('šŸ›‘ Press Ctrl+C to stop the server');
52
- console.log('');
48
+ console.error('🌐 ServiceNow MCP Server is running...');
49
+ console.error('šŸ’” This server provides Claude Code with direct access to ServiceNow APIs');
50
+ console.error('šŸ”§ Available tools depend on authentication status');
51
+ console.error('šŸ›‘ Press Ctrl+C to stop the server');
52
+ console.error('');
53
53
  try {
54
54
  await server.run();
55
55
  }
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+
3
+ # Fix console.log statements in MCP servers to use console.error instead
4
+ # This prevents stdout pollution which breaks JSON-RPC protocol
5
+
6
+ echo "šŸ”§ Fixing console.log statements in MCP servers..."
7
+
8
+ # List of files to fix
9
+ files=(
10
+ "src/mcp/service-discovery-client.ts"
11
+ "src/mcp/servicenow-deployment-mcp.ts"
12
+ "src/mcp/servicenow-mcp-server.ts"
13
+ "src/mcp/servicenow-update-set-mcp.ts"
14
+ "src/mcp/start-all-mcp-servers.ts"
15
+ "src/mcp/start-servicenow-mcp.ts"
16
+ )
17
+
18
+ for file in "${files[@]}"; do
19
+ if [ -f "$file" ]; then
20
+ echo " Fixing $file..."
21
+ # Replace console.log with console.error
22
+ sed -i.bak 's/console\.log(/console.error(/g' "$file"
23
+ # Remove backup file
24
+ rm -f "${file}.bak"
25
+ else
26
+ echo " āš ļø File not found: $file"
27
+ fi
28
+ done
29
+
30
+ echo "āœ… Console.log statements fixed!"
31
+ echo ""
32
+ echo "Note: console.error is used for logging in MCP servers to keep stdout clean for JSON-RPC protocol."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.4.29",
3
+ "version": "3.4.30",
4
4
  "description": "ServiceNow development framework with MCP server integration. Executes background scripts using ES5 JavaScript only (ServiceNow Rhino engine requirement). Provides 17 MCP servers for complete ServiceNow operations including widget deployment with coherence validation, table operations, script execution, machine learning, advanced features, and comprehensive platform management.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",