snow-flow 3.6.2 → 3.6.4

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
@@ -2584,6 +2584,14 @@ async function createMCPConfig(targetDir, force = false) {
2584
2584
  "Bash(sudo *)"
2585
2585
  ]
2586
2586
  },
2587
+ "autoCompactThreshold": 0.65,
2588
+ "compactMode": "aggressive",
2589
+ "contextPreservation": {
2590
+ "preserveMCPState": true,
2591
+ "preserveToolResults": true,
2592
+ "preserveRecentContext": 5000,
2593
+ "prioritizeServiceNowOperations": true
2594
+ },
2587
2595
  "hooks": {
2588
2596
  "PreCompact": [
2589
2597
  {
@@ -2597,10 +2605,11 @@ async function createMCPConfig(targetDir, force = false) {
2597
2605
  },
2598
2606
  {
2599
2607
  "matcher": "auto",
2608
+ "threshold": 0.65,
2600
2609
  "hooks": [
2601
2610
  {
2602
2611
  "type": "command",
2603
- "command": "/bin/bash -c 'echo \"šŸ”„ Auto-Compact Guidance (Context Window Full):\"; echo \"šŸ“‹ CRITICAL: Before compacting, ensure you understand:\"; echo \" • All 18+ MCP servers including servicenow-local-development\"; echo \" • Use snow_pull_artifact for widget debugging (NOT snow_query_table)\"; echo \" • Concurrent execution patterns from CLAUDE.md\"; echo \" • Batchtools optimization for 300% performance gains\"; echo \" • Swarm coordination strategies for complex tasks\"; echo \"⚔ Apply GOLDEN RULE: Always batch operations in single messages\"; echo \"āœ… Auto-compact proceeding with full agent context\"'"
2612
+ "command": "/bin/bash -c 'echo \"⚔ EARLY Auto-Compact triggered at 65% context usage\"; echo \"šŸ”” Compacting BEFORE API calls fail\"; echo \"šŸ“‹ Preserving critical Snow-Flow context:\"; echo \" • Active MCP connections and tool state\"; echo \" • Recent ServiceNow operations and results\"; echo \" • Current artifact sync status\"; echo \" • Authentication and session data\"; echo \"āš ļø This prevents mid-operation failures\"; echo \"āœ… Safe compact at 65% threshold\"'"
2604
2613
  }
2605
2614
  ]
2606
2615
  }
@@ -2620,6 +2629,10 @@ async function createMCPConfig(targetDir, force = false) {
2620
2629
  "CLAUDE_CODE_TIMEOUT": "0",
2621
2630
  "CLAUDE_CODE_SESSION_TIMEOUT": "0",
2622
2631
  "CLAUDE_CODE_EXECUTION_TIMEOUT": "0",
2632
+ "CLAUDE_CODE_EARLY_COMPACT": "true",
2633
+ "CLAUDE_CODE_COMPACT_THRESHOLD": "0.65",
2634
+ "CLAUDE_CODE_PRESERVE_MCP_STATE": "true",
2635
+ "CLAUDE_CODE_CONTEXT_WINDOW_BUFFER": "35",
2623
2636
  "SNOW_FLOW_DEBUG": "false",
2624
2637
  "SNOW_FLOW_LOG_LEVEL": "info",
2625
2638
  "MCP_DEBUG": "false",
@@ -262,8 +262,8 @@ class ServiceNowLocalDevelopmentMCP extends enhanced_base_mcp_server_js_1.Enhanc
262
262
  async pullArtifact(args) {
263
263
  const { sys_id, table } = args;
264
264
  const startTime = Date.now();
265
- // Add timeout for pull operations
266
- const PULL_TIMEOUT = 15000; // 15 seconds for pull operations
265
+ // Add timeout for pull operations (must be longer than pullArtifactBySysId's 30s timeout)
266
+ const PULL_TIMEOUT = 35000; // 35 seconds for pull operations (allows 30s for detection + 5s buffer)
267
267
  try {
268
268
  const pullPromise = (async () => {
269
269
  let artifact;
@@ -47,6 +47,15 @@ class MCPLogger {
47
47
  // Send progress every 5 seconds (reduced frequency)
48
48
  this.progressInterval = setInterval(() => {
49
49
  const duration = Math.round((Date.now() - this.startTime) / 1000);
50
+ // CRITICAL: Stop progress after 60 seconds to prevent infinite loops
51
+ if (duration > 60) {
52
+ console.error(`āš ļø [${this.name}] Operation exceeded maximum time (60s). Stopping progress indicator.`);
53
+ this.stopProgress();
54
+ // Force stop the operation by throwing timeout error
55
+ const timeoutError = new Error(`Operation timeout: exceeded 60 seconds`);
56
+ this.operationError('Operation timeout', timeoutError);
57
+ return;
58
+ }
50
59
  if (duration > 3) { // Only show progress after 3+ seconds
51
60
  this.progress(`Operation in progress... (${duration}s elapsed, ${this.tokenUsage.total} tokens used)`);
52
61
  }
@@ -708,6 +708,9 @@ snow-flow sync status ${widget.sys_id}
708
708
  async pullArtifactBySysId(sys_id) {
709
709
  console.log(`\nšŸ” Auto-detecting artifact type for sys_id: ${sys_id}`);
710
710
  console.log(`šŸ“‹ Checking ${Object.keys(artifact_registry_1.ARTIFACT_REGISTRY).length} supported tables...`);
711
+ // CRITICAL: Add MAXIMUM operation timeout to prevent infinite hanging
712
+ const MAX_OPERATION_TIME = 30000; // 30 seconds max for entire operation
713
+ const operationStart = Date.now();
711
714
  // SMART ORDER: Check most common tables first for better performance
712
715
  const allTables = Object.keys(artifact_registry_1.ARTIFACT_REGISTRY);
713
716
  const commonTables = ['sp_widget', 'sys_script_include', 'sys_script', 'sys_ui_page'];
@@ -716,10 +719,15 @@ snow-flow sync status ${widget.sys_id}
716
719
  const timeoutConfig = (0, mcp_timeout_config_js_1.getMCPTimeoutConfig)();
717
720
  const errors = [];
718
721
  for (const table of tables) {
722
+ // Check if we've exceeded maximum operation time
723
+ if (Date.now() - operationStart > MAX_OPERATION_TIME) {
724
+ console.log(`\nā±ļø Maximum operation time (30s) exceeded. Stopping search.`);
725
+ break;
726
+ }
719
727
  try {
720
728
  console.log(` šŸ”Ž Checking table: ${table}...`);
721
- // Increased timeout for better reliability
722
- const response = await (0, mcp_timeout_config_js_1.withMCPTimeout)(this.client.searchRecords(table, `sys_id=${sys_id}`, 1), 8000, // 8 second timeout per table (was 3s)
729
+ // Reduced timeout per table for faster failure
730
+ const response = await (0, mcp_timeout_config_js_1.withMCPTimeout)(this.client.searchRecords(table, `sys_id=${sys_id}`, 1), 3000, // 3 second timeout per table (reduced from 8s)
723
731
  `Detect table for ${sys_id}`);
724
732
  if (response.result?.[0]) {
725
733
  console.log(` āœ… Found in table: ${table}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.6.2",
4
- "description": "ServiceNow framework with CONSOLIDATED CLAUDE.md (78% smaller, 100% complete). v3.6.2 features systematic documentation of ALL 18 MCP servers and 200+ tools. NO MOCK DATA policy enforced. Complete tool reference for snow_pull_artifact, snow_deploy, snow_execute_script_with_output, and all ServiceNow operations. Includes audit logging, token tracking, ES5 enforcement, and production-ready code requirements. Optimized for Claude Code with comprehensive MCP tool awareness.",
3
+ "version": "3.6.4",
4
+ "description": "EARLY AUTO-COMPACT at 65% context usage prevents mid-API failures. v3.6.4 triggers compact BEFORE context window issues, not after. Aggressive compact mode with MCP state preservation. Prevents 'too many tokens' errors during ServiceNow operations. Includes infinite hanging fix, consolidated CLAUDE.md with 18 MCP servers, NO MOCK DATA policy, audit logging, and ES5 enforcement.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
7
7
  "bin": {