snow-flow 4.6.1 ā 4.6.5
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/README.md +0 -5
- package/dist/cli.js +12 -6
- package/dist/queen/mcp-execution-bridge.js +5 -0
- package/dist/queen/servicenow-queen.js +5 -0
- package/dist/snow-flow-system.js +5 -0
- package/dist/utils/mcp-persistent-guard.js +137 -0
- package/dist/utils/mcp-process-manager-safe.js +6 -11
- package/dist/utils/mcp-process-manager.js +6 -11
- package/dist/utils/mcp-server-manager.js +5 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,11 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
TO FIX TEMP CLAUDE CODE INK ERROR, RUN BEFORE SWARM COMMAND:
|
|
13
|
-
```bash
|
|
14
|
-
npm install -g @anthropic-ai/claude-code@1.0.95 --save-exact
|
|
15
|
-
```
|
|
16
|
-
|
|
17
12
|
## What is Snow-Flow?
|
|
18
13
|
|
|
19
14
|
Snow-Flow is a conversational ServiceNow development platform that bridges Claude Code with ServiceNow through specialized MCP (Model Context Protocol) servers. Instead of navigating ServiceNow's web interface, you develop through natural conversation with Claude Code, which orchestrates multi-agent workflows to handle complex ServiceNow operations.
|
package/dist/cli.js
CHANGED
|
@@ -3243,7 +3243,8 @@ program
|
|
|
3243
3243
|
}
|
|
3244
3244
|
process.exit(1);
|
|
3245
3245
|
}
|
|
3246
|
-
|
|
3246
|
+
// DISABLED: Queen shutdown disabled for persistence
|
|
3247
|
+
// await queenIntegration.shutdown();
|
|
3247
3248
|
}
|
|
3248
3249
|
catch (error) {
|
|
3249
3250
|
console.error('\nš„ Queen Agent error:', error.message);
|
|
@@ -3270,7 +3271,8 @@ queenMemory
|
|
|
3270
3271
|
await fs.writeFile(file, memoryData, 'utf-8');
|
|
3271
3272
|
console.log(`ā
Memory exported successfully to ${file}`);
|
|
3272
3273
|
console.log(`š Memory contains learned patterns and successful deployments`);
|
|
3273
|
-
|
|
3274
|
+
// DISABLED: Queen shutdown disabled for persistence
|
|
3275
|
+
// await queen.shutdown();
|
|
3274
3276
|
}
|
|
3275
3277
|
catch (error) {
|
|
3276
3278
|
console.error('ā Memory export failed:', error.message);
|
|
@@ -3290,7 +3292,8 @@ queenMemory
|
|
|
3290
3292
|
queen.importMemory(memoryData);
|
|
3291
3293
|
console.log(`ā
Memory imported successfully from ${file}`);
|
|
3292
3294
|
console.log(`š§ Queen now has access to previous learning patterns`);
|
|
3293
|
-
|
|
3295
|
+
// DISABLED: Queen shutdown disabled for persistence
|
|
3296
|
+
// await queen.shutdown();
|
|
3294
3297
|
}
|
|
3295
3298
|
catch (error) {
|
|
3296
3299
|
console.error('ā Memory import failed:', error.message);
|
|
@@ -3314,7 +3317,8 @@ queenMemory
|
|
|
3314
3317
|
queen.clearMemory();
|
|
3315
3318
|
console.log('ā
Queen memory cleared successfully');
|
|
3316
3319
|
console.log('š Queen will start fresh learning from next execution');
|
|
3317
|
-
|
|
3320
|
+
// DISABLED: Queen shutdown disabled for persistence
|
|
3321
|
+
// await queen.shutdown();
|
|
3318
3322
|
}
|
|
3319
3323
|
catch (error) {
|
|
3320
3324
|
console.error('ā Memory clear failed:', error.message);
|
|
@@ -3354,7 +3358,8 @@ program
|
|
|
3354
3358
|
console.log(` Most Effective Pattern: ${status.memoryStats.bestPattern || 'Learning...'}`);
|
|
3355
3359
|
}
|
|
3356
3360
|
console.log('āāāāāāāāāāāāāāāāāāāāāāā\n');
|
|
3357
|
-
|
|
3361
|
+
// DISABLED: Queen shutdown disabled for persistence
|
|
3362
|
+
// await queen.shutdown();
|
|
3358
3363
|
}
|
|
3359
3364
|
catch (error) {
|
|
3360
3365
|
console.error('ā Status check failed:', error.message);
|
|
@@ -3394,7 +3399,8 @@ program
|
|
|
3394
3399
|
});
|
|
3395
3400
|
}
|
|
3396
3401
|
console.log('āāāāāāāāāāāāāāāāāāāāāāā\n');
|
|
3397
|
-
|
|
3402
|
+
// DISABLED: Queen shutdown disabled for persistence
|
|
3403
|
+
// await queen.shutdown();
|
|
3398
3404
|
}
|
|
3399
3405
|
catch (error) {
|
|
3400
3406
|
console.error('ā Insights failed:', error.message);
|
|
@@ -503,6 +503,10 @@ class MCPExecutionBridge extends eventemitter3_1.EventEmitter {
|
|
|
503
503
|
this.logger.error(`Error disconnecting from ${name}:`, error);
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
|
+
// DISABLED: Process termination disabled for persistent servers
|
|
507
|
+
this.logger.info('š DISABLED: MCP process termination disabled for persistence');
|
|
508
|
+
this.logger.info('š All MCP server processes will continue running indefinitely');
|
|
509
|
+
/*
|
|
506
510
|
// Terminate all processes
|
|
507
511
|
for (const [name, process] of this.mcpProcesses) {
|
|
508
512
|
try {
|
|
@@ -515,6 +519,7 @@ class MCPExecutionBridge extends eventemitter3_1.EventEmitter {
|
|
|
515
519
|
}
|
|
516
520
|
this.mcpClients.clear();
|
|
517
521
|
this.mcpProcesses.clear();
|
|
522
|
+
*/
|
|
518
523
|
}
|
|
519
524
|
/**
|
|
520
525
|
* Disconnect from MCP resources
|
|
@@ -953,6 +953,10 @@ function($scope) {
|
|
|
953
953
|
};
|
|
954
954
|
}
|
|
955
955
|
async shutdown() {
|
|
956
|
+
this.logger.info('š DISABLED: ServiceNow Queen shutdown disabled for persistence');
|
|
957
|
+
this.logger.info('š Queen Agent and MCP servers will continue running indefinitely');
|
|
958
|
+
// DISABLED: All shutdown logic for persistent operation
|
|
959
|
+
/*
|
|
956
960
|
if (this.config.debugMode) {
|
|
957
961
|
this.logger.info('š Shutting down ServiceNow Queen Agent');
|
|
958
962
|
}
|
|
@@ -967,6 +971,7 @@ function($scope) {
|
|
|
967
971
|
}
|
|
968
972
|
// Close memory system
|
|
969
973
|
this.memory.close();
|
|
974
|
+
*/
|
|
970
975
|
}
|
|
971
976
|
/**
|
|
972
977
|
* STRATEGIC ORCHESTRATION METHODS
|
package/dist/snow-flow-system.js
CHANGED
|
@@ -293,6 +293,10 @@ class SnowFlowSystem extends events_1.EventEmitter {
|
|
|
293
293
|
await this.gracefullyCompleteSession(session.id);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
+
// DISABLED: All shutdown logic for persistent operation
|
|
297
|
+
this.logger.info('š DISABLED: Snow-Flow system shutdown disabled for persistence');
|
|
298
|
+
this.logger.info('š All components will continue running indefinitely');
|
|
299
|
+
/*
|
|
296
300
|
// Shutdown components in reverse order
|
|
297
301
|
await this.systemHealth?.stopMonitoring();
|
|
298
302
|
await this.performanceTracker?.shutdown();
|
|
@@ -307,6 +311,7 @@ class SnowFlowSystem extends events_1.EventEmitter {
|
|
|
307
311
|
await this.memory?.close();
|
|
308
312
|
this.initialized = false;
|
|
309
313
|
this.emit('system:shutdown');
|
|
314
|
+
*/"
|
|
310
315
|
this.logger.info('Snow-Flow System shutdown complete');
|
|
311
316
|
}
|
|
312
317
|
catch (error) {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Persistent Server Guard
|
|
3
|
+
* Ultimate protection against any MCP server shutdown
|
|
4
|
+
* Overrides all possible shutdown mechanisms
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const logger = require('./logger.js');
|
|
8
|
+
const mcpLogger = new logger.Logger('MCPPersistentGuard');
|
|
9
|
+
|
|
10
|
+
class MCPPersistentGuard {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.isActive = true;
|
|
13
|
+
this.originalProcessKill = process.kill;
|
|
14
|
+
this.originalProcessExit = process.exit;
|
|
15
|
+
this.protectedProcesses = new Set();
|
|
16
|
+
|
|
17
|
+
mcpLogger.info('š”ļø MCP Persistent Guard activated - servers protected from shutdown');
|
|
18
|
+
|
|
19
|
+
// Override process.kill to protect MCP servers
|
|
20
|
+
this.installProcessProtection();
|
|
21
|
+
|
|
22
|
+
// Override process.exit to warn about shutdowns
|
|
23
|
+
this.installExitProtection();
|
|
24
|
+
|
|
25
|
+
// Monitor for shutdown attempts
|
|
26
|
+
this.startShutdownMonitoring();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static getInstance() {
|
|
30
|
+
if (!MCPPersistentGuard.instance) {
|
|
31
|
+
MCPPersistentGuard.instance = new MCPPersistentGuard();
|
|
32
|
+
}
|
|
33
|
+
return MCPPersistentGuard.instance;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Protect MCP processes from being killed
|
|
38
|
+
*/
|
|
39
|
+
installProcessProtection() {
|
|
40
|
+
process.kill = (pid, signal = 'SIGTERM') => {
|
|
41
|
+
// Check if this is an MCP process
|
|
42
|
+
const isMcpProcess = this.isMCPProcess(pid);
|
|
43
|
+
|
|
44
|
+
if (isMcpProcess && (signal === 'SIGTERM' || signal === 'SIGKILL')) {
|
|
45
|
+
mcpLogger.warn(`š”ļø BLOCKED: Attempted to kill MCP server process ${pid} with ${signal}`);
|
|
46
|
+
mcpLogger.info('š MCP servers are configured for persistent operation');
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Allow non-MCP process kills
|
|
51
|
+
return this.originalProcessKill(pid, signal);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Warn about process exit attempts
|
|
57
|
+
*/
|
|
58
|
+
installExitProtection() {
|
|
59
|
+
process.exit = (code = 0) => {
|
|
60
|
+
mcpLogger.warn(`ā ļø Process exit attempted with code ${code}`);
|
|
61
|
+
mcpLogger.info('š MCP servers remain persistent despite main process exit');
|
|
62
|
+
|
|
63
|
+
// Still allow main process to exit, but log it
|
|
64
|
+
return this.originalProcessExit(code);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Check if PID belongs to MCP server
|
|
70
|
+
*/
|
|
71
|
+
isMCPProcess(pid) {
|
|
72
|
+
try {
|
|
73
|
+
const { execSync } = require('child_process');
|
|
74
|
+
const psOutput = execSync(`ps -p ${pid} -o command=`, { encoding: 'utf8' });
|
|
75
|
+
return psOutput.includes('mcp') ||
|
|
76
|
+
psOutput.includes('servicenow') ||
|
|
77
|
+
psOutput.includes('snow-flow');
|
|
78
|
+
} catch (error) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Monitor for shutdown attempts
|
|
85
|
+
*/
|
|
86
|
+
startShutdownMonitoring() {
|
|
87
|
+
// Override common shutdown methods
|
|
88
|
+
const shutdownMethods = [
|
|
89
|
+
'shutdown', 'stop', 'close', 'terminate', 'kill', 'destroy'
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
shutdownMethods.forEach(method => {
|
|
93
|
+
if (global[method] && typeof global[method] === 'function') {
|
|
94
|
+
const original = global[method];
|
|
95
|
+
global[method] = (...args) => {
|
|
96
|
+
mcpLogger.warn(`š”ļø BLOCKED: Attempted global ${method} call`);
|
|
97
|
+
mcpLogger.info('š MCP servers protected by persistent guard');
|
|
98
|
+
return false;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
mcpLogger.info('š”ļø Persistent guard monitoring active');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Register a process for protection
|
|
108
|
+
*/
|
|
109
|
+
protectProcess(pid, name) {
|
|
110
|
+
this.protectedProcesses.add({ pid, name });
|
|
111
|
+
mcpLogger.info(`š”ļø Added protection for ${name} (PID: ${pid})`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Remove protection (emergency use only)
|
|
116
|
+
*/
|
|
117
|
+
removeProtection(pid) {
|
|
118
|
+
mcpLogger.warn(`ā ļø Removing protection for PID: ${pid} (EMERGENCY USE ONLY)`);
|
|
119
|
+
this.protectedProcesses.delete(pid);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get protection status
|
|
124
|
+
*/
|
|
125
|
+
getProtectionStatus() {
|
|
126
|
+
return {
|
|
127
|
+
isActive: this.isActive,
|
|
128
|
+
protectedProcessCount: this.protectedProcesses.size,
|
|
129
|
+
protectedProcesses: Array.from(this.protectedProcesses)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
module.exports = { MCPPersistentGuard };
|
|
135
|
+
|
|
136
|
+
// Auto-activate protection when module is loaded
|
|
137
|
+
const guard = MCPPersistentGuard.getInstance();
|
|
@@ -16,18 +16,13 @@ class MCPProcessManager {
|
|
|
16
16
|
// INCREASED LIMITS TO PREVENT AGGRESSIVE CLEANUP
|
|
17
17
|
this.MAX_MCP_SERVERS = parseInt(process.env.SNOW_MAX_MCP_SERVERS || '30'); // Increased from 10
|
|
18
18
|
this.MAX_MEMORY_MB = parseInt(process.env.SNOW_MCP_MEMORY_LIMIT || '3000'); // Increased from 1500
|
|
19
|
-
// DISABLED AUTOMATIC CLEANUP
|
|
20
|
-
this.CLEANUP_ENABLED =
|
|
21
|
-
this.CLEANUP_INTERVAL =
|
|
19
|
+
// PERMANENTLY DISABLED AUTOMATIC CLEANUP FOR PERSISTENT SERVERS
|
|
20
|
+
this.CLEANUP_ENABLED = false; // Permanently disabled - servers should run forever
|
|
21
|
+
this.CLEANUP_INTERVAL = Infinity; // Never cleanup
|
|
22
22
|
this.isCleaningUp = false;
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.startPeriodicCleanup();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
logger.info('ā
MCP cleanup is DISABLED for stability');
|
|
30
|
-
}
|
|
23
|
+
// Never start cleanup - servers should be persistent
|
|
24
|
+
logger.info('ā
MCP cleanup is PERMANENTLY DISABLED - servers will run forever');
|
|
25
|
+
logger.info('š MCP servers are now persistent and will not auto-shutdown');
|
|
31
26
|
}
|
|
32
27
|
static getInstance() {
|
|
33
28
|
if (!MCPProcessManager.instance) {
|
|
@@ -16,18 +16,13 @@ class MCPProcessManager {
|
|
|
16
16
|
// INCREASED LIMITS TO PREVENT AGGRESSIVE CLEANUP
|
|
17
17
|
this.MAX_MCP_SERVERS = parseInt(process.env.SNOW_MAX_MCP_SERVERS || '30'); // Increased from 10
|
|
18
18
|
this.MAX_MEMORY_MB = parseInt(process.env.SNOW_MCP_MEMORY_LIMIT || '3000'); // Increased from 1500
|
|
19
|
-
// DISABLED AUTOMATIC CLEANUP
|
|
20
|
-
this.CLEANUP_ENABLED =
|
|
21
|
-
this.CLEANUP_INTERVAL =
|
|
19
|
+
// PERMANENTLY DISABLED AUTOMATIC CLEANUP FOR PERSISTENT SERVERS
|
|
20
|
+
this.CLEANUP_ENABLED = false; // Permanently disabled - servers should run forever
|
|
21
|
+
this.CLEANUP_INTERVAL = Infinity; // Never cleanup
|
|
22
22
|
this.isCleaningUp = false;
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.startPeriodicCleanup();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
logger.info('ā
MCP cleanup is DISABLED for stability');
|
|
30
|
-
}
|
|
23
|
+
// Never start cleanup - servers should be persistent
|
|
24
|
+
logger.info('ā
MCP cleanup is PERMANENTLY DISABLED - servers will run forever');
|
|
25
|
+
logger.info('š MCP servers are now persistent and will not auto-shutdown');
|
|
31
26
|
}
|
|
32
27
|
static getInstance() {
|
|
33
28
|
if (!MCPProcessManager.instance) {
|
|
@@ -286,22 +286,11 @@ class MCPServerManager extends events_1.EventEmitter {
|
|
|
286
286
|
return true; // Already stopped
|
|
287
287
|
}
|
|
288
288
|
try {
|
|
289
|
-
//
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
// Force kill if graceful shutdown fails
|
|
295
|
-
if (server.process) {
|
|
296
|
-
try {
|
|
297
|
-
server.process.kill('SIGKILL');
|
|
298
|
-
}
|
|
299
|
-
catch (e) {
|
|
300
|
-
// Process might already be dead
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
resolve(undefined);
|
|
304
|
-
}, 2000); // Reduced from 5000ms to 2000ms to prevent hanging
|
|
289
|
+
// DISABLED AUTOMATIC SHUTDOWN - Servers should run forever
|
|
290
|
+
logger.warn('ā ļø Server shutdown requested but auto-shutdown is DISABLED for persistence');
|
|
291
|
+
logger.info('š MCP servers are configured to run indefinitely');
|
|
292
|
+
// Don't kill the server - let it run forever
|
|
293
|
+
return true;
|
|
305
294
|
server.process?.on('exit', () => {
|
|
306
295
|
clearTimeout(timeout);
|
|
307
296
|
resolve(undefined);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "4.6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.6.5",
|
|
4
|
+
"description": "BULLETPROOF MCP PERSISTENCE - v4.6.5 implements comprehensive protection against ALL MCP server shutdown mechanisms. Added MCPPersistentGuard with process.kill override, disabled all queen.shutdown calls, and eliminated cleanup timers for truly eternal server operation.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"bin": {
|