snow-flow 3.4.21 → 3.4.23

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.
@@ -852,7 +852,7 @@ class ServiceNowOperationsMCP {
852
852
  return result;
853
853
  }
854
854
  catch (error) {
855
- this.logger.error(`Error executing tool ${name}:`, error);
855
+ this.logger.operationError(name, error);
856
856
  throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Failed to execute ${name}: ${error}`);
857
857
  }
858
858
  });
@@ -38,6 +38,10 @@ export declare class MCPLogger {
38
38
  * Log error message
39
39
  */
40
40
  error(message: string, error?: any): void;
41
+ /**
42
+ * Log operation error - ensures progress indicator is stopped
43
+ */
44
+ operationError(operation: string, error: any): void;
41
45
  /**
42
46
  * Log debug message
43
47
  */
@@ -68,7 +72,7 @@ export declare class MCPLogger {
68
72
  getTokenUsage(): TokenUsage;
69
73
  /**
70
74
  * Add token usage to MCP response
71
- * Helper method to append token usage to tool response
75
+ * Helper method to append token usage to tool response via _meta field
72
76
  */
73
77
  addTokenUsageToResponse(result: any): any;
74
78
  /**
@@ -14,8 +14,7 @@ class MCPLogger {
14
14
  this.lastProgressTime = Date.now();
15
15
  this.progressInterval = null;
16
16
  this.name = name;
17
- // Start progress indicator
18
- this.startProgressIndicator();
17
+ // Don't start progress indicator automatically - only start when needed
19
18
  }
20
19
  /**
21
20
  * Log to stderr with proper formatting
@@ -45,13 +44,13 @@ class MCPLogger {
45
44
  * Start progress indicator for long-running operations
46
45
  */
47
46
  startProgressIndicator() {
48
- // Send progress every 2 seconds
47
+ // Send progress every 5 seconds (reduced frequency)
49
48
  this.progressInterval = setInterval(() => {
50
49
  const duration = Math.round((Date.now() - this.startTime) / 1000);
51
- if (duration > 0) {
50
+ if (duration > 3) { // Only show progress after 3+ seconds
52
51
  this.progress(`Operation in progress... (${duration}s elapsed, ${this.tokenUsage.total} tokens used)`);
53
52
  }
54
- }, 2000);
53
+ }, 5000);
55
54
  }
56
55
  /**
57
56
  * Stop progress indicator
@@ -85,6 +84,15 @@ class MCPLogger {
85
84
  } : error;
86
85
  this.log('ERROR', message, errorData);
87
86
  }
87
+ /**
88
+ * Log operation error - ensures progress indicator is stopped
89
+ */
90
+ operationError(operation, error) {
91
+ const duration = Math.round((Date.now() - this.startTime) / 1000);
92
+ // Always stop progress indicator when operation fails
93
+ this.stopProgress();
94
+ this.error(`āŒ Failed: ${operation} (${duration}s)`, error);
95
+ }
88
96
  /**
89
97
  * Log debug message
90
98
  */
@@ -133,27 +141,24 @@ class MCPLogger {
133
141
  this.startTime = Date.now();
134
142
  this.resetTokens(); // Actually reset tokens when starting new operation!
135
143
  this.info(`šŸš€ Starting: ${operation}`, params);
144
+ // Start progress indicator after 3 seconds (only for long operations)
145
+ setTimeout(() => {
146
+ if (!this.progressInterval) {
147
+ this.startProgressIndicator();
148
+ }
149
+ }, 3000);
136
150
  }
137
151
  /**
138
152
  * Log operation complete
139
153
  */
140
154
  operationComplete(operation, result) {
141
155
  const duration = Math.round((Date.now() - this.startTime) / 1000);
156
+ // Always stop progress indicator first
142
157
  this.stopProgress();
143
158
  this.info(`āœ… Completed: ${operation} (${duration}s, ${this.tokenUsage.total} tokens)`, result);
144
- // Send final token report
145
- if (this.tokenUsage.total > 0) {
146
- console.error(`
147
- ═══════════════════════════════════════════════════════════
148
- šŸ“Š ${this.name} - Operation Complete
149
- ─────────────────────────────────────────────────────────
150
- ā±ļø Duration: ${duration} seconds
151
- šŸ”¢ Tokens Used: ${this.tokenUsage.total}
152
- ā”œā”€ Input: ${this.tokenUsage.input}
153
- └─ Output: ${this.tokenUsage.output}
154
- šŸŽÆ Operation: ${operation}
155
- ═══════════════════════════════════════════════════════════
156
- `);
159
+ // Only show token report for operations with actual token usage
160
+ if (this.tokenUsage.total > 0 && duration > 1) {
161
+ console.error(`šŸ“Š [${this.name}] ${operation} completed: ${duration}s, ${this.tokenUsage.total} tokens`);
157
162
  }
158
163
  }
159
164
  /**
@@ -164,15 +169,26 @@ class MCPLogger {
164
169
  }
165
170
  /**
166
171
  * Add token usage to MCP response
167
- * Helper method to append token usage to tool response
172
+ * Helper method to append token usage to tool response via _meta field
168
173
  */
169
174
  addTokenUsageToResponse(result) {
170
175
  const tokenUsage = this.getTokenUsage();
171
- if (result && result.content && Array.isArray(result.content) && tokenUsage.total > 0) {
172
- // Append token usage info to the last content item
173
- const lastContent = result.content[result.content.length - 1];
174
- if (lastContent && lastContent.type === 'text') {
175
- lastContent.text += `\n\nšŸ“Š Token Usage: ${tokenUsage.total} (Input: ${tokenUsage.input}, Output: ${tokenUsage.output})`;
176
+ if (tokenUsage.total > 0) {
177
+ // Add token usage to _meta field for Claude Code UI
178
+ if (!result._meta) {
179
+ result._meta = {};
180
+ }
181
+ result._meta.tokenUsage = {
182
+ input: tokenUsage.input,
183
+ output: tokenUsage.output,
184
+ total: tokenUsage.total
185
+ };
186
+ // Also keep text display for compatibility
187
+ if (result && result.content && Array.isArray(result.content)) {
188
+ const lastContent = result.content[result.content.length - 1];
189
+ if (lastContent && lastContent.type === 'text') {
190
+ lastContent.text += `\n\nšŸ“Š Token Usage: ${tokenUsage.total} (Input: ${tokenUsage.input}, Output: ${tokenUsage.output})`;
191
+ }
176
192
  }
177
193
  }
178
194
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.4.21",
3
+ "version": "3.4.23",
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",