snow-flow 4.6.2 → 4.6.6
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 +4 -74
- package/dist/queen/servicenow-queen.js +10 -3
- package/dist/utils/mcp-persistent-guard.d.ts +51 -0
- package/dist/utils/mcp-persistent-guard.js +126 -0
- package/dist/utils/mcp-process-manager-safe.js +11 -6
- package/dist/utils/mcp-server-manager.js +16 -5
- package/package.json +2 -2
- package/dist/cli-new-prompt.d.ts +0 -2
- package/dist/cli-new-prompt.js +0 -420
- package/dist/mcp/start-all-mcp-servers.d.ts +0 -11
- package/dist/mcp/start-all-mcp-servers.js +0 -77
- package/dist/templates/claude-md-template-old.d.ts +0 -3
- package/dist/templates/claude-md-template-old.js +0 -1398
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
|
@@ -53,6 +53,10 @@ const agent_detector_js_1 = require("./utils/agent-detector.js");
|
|
|
53
53
|
const version_js_1 = require("./version.js");
|
|
54
54
|
const logger_js_1 = require("./utils/logger.js");
|
|
55
55
|
const chalk_1 = __importDefault(require("chalk"));
|
|
56
|
+
// Load MCP Persistent Guard for bulletproof server protection
|
|
57
|
+
const mcp_persistent_guard_js_1 = require("./utils/mcp-persistent-guard.js");
|
|
58
|
+
// Activate protection immediately
|
|
59
|
+
mcp_persistent_guard_js_1.MCPPersistentGuard.getInstance();
|
|
56
60
|
// Removed provider-agnostic imports - using Claude Code directly
|
|
57
61
|
const auth_js_1 = require("./cli/auth.js");
|
|
58
62
|
const session_js_1 = require("./cli/session.js");
|
|
@@ -93,76 +97,6 @@ function checkFlowDeprecation(command, objective) {
|
|
|
93
97
|
process.exit(1);
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
|
-
|
|
97
|
-
// Claude Code version management - ensure 1.0.95 is installed
|
|
98
|
-
async function ensureClaudeCodeVersion() {
|
|
99
|
-
try {
|
|
100
|
-
cliLogger.info('🔧 Checking Claude Code version compatibility...');
|
|
101
|
-
|
|
102
|
-
// Check if Claude Code is installed and get version
|
|
103
|
-
const checkVersionResult = (0, child_process_1.execSync)('claude --version 2>/dev/null || echo "not_installed"', {
|
|
104
|
-
encoding: 'utf8',
|
|
105
|
-
timeout: 10000
|
|
106
|
-
}).trim();
|
|
107
|
-
|
|
108
|
-
const currentVersion = checkVersionResult.includes('not_installed') ? null :
|
|
109
|
-
checkVersionResult.match(/(\d+\.\d+\.\d+)/)?.[1];
|
|
110
|
-
|
|
111
|
-
cliLogger.info(`🔍 Current Claude Code version: ${currentVersion || 'not installed'}`);
|
|
112
|
-
|
|
113
|
-
// Target version that works correctly
|
|
114
|
-
const targetVersion = '1.0.95';
|
|
115
|
-
|
|
116
|
-
if (currentVersion !== targetVersion) {
|
|
117
|
-
cliLogger.info(`⚠️ Version mismatch detected. Installing Claude Code ${targetVersion}...`);
|
|
118
|
-
cliLogger.info('📥 This prevents bugs in newer versions that cause hanging operations');
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
// Install the specific version
|
|
122
|
-
cliLogger.info('🔄 Running: npm install -g @anthropic-ai/claude-code@1.0.95');
|
|
123
|
-
(0, child_process_1.execSync)('npm install -g @anthropic-ai/claude-code@1.0.95', {
|
|
124
|
-
stdio: 'inherit',
|
|
125
|
-
timeout: 120000 // 2 minutes timeout
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Verify installation
|
|
129
|
-
const verifyResult = (0, child_process_1.execSync)('claude --version', {
|
|
130
|
-
encoding: 'utf8',
|
|
131
|
-
timeout: 10000
|
|
132
|
-
}).trim();
|
|
133
|
-
|
|
134
|
-
const installedVersion = verifyResult.match(/(\d+\.\d+\.\d+)/)?.[1];
|
|
135
|
-
|
|
136
|
-
if (installedVersion === targetVersion) {
|
|
137
|
-
cliLogger.info(`✅ Claude Code ${targetVersion} installed successfully!`);
|
|
138
|
-
} else {
|
|
139
|
-
cliLogger.warn(`⚠️ Installation completed but version verification shows: ${installedVersion}`);
|
|
140
|
-
}
|
|
141
|
-
} catch (installError) {
|
|
142
|
-
cliLogger.error('❌ Failed to install Claude Code 1.0.95');
|
|
143
|
-
cliLogger.error('Please install manually: npm install -g @anthropic-ai/claude-code@1.0.95');
|
|
144
|
-
throw new Error(`Claude Code installation failed: ${installError.message}`);
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
cliLogger.info(`✅ Claude Code ${targetVersion} is already installed`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
cliLogger.info('🚀 Claude Code version check completed successfully');
|
|
151
|
-
|
|
152
|
-
} catch (error) {
|
|
153
|
-
cliLogger.error('❌ Claude Code version check failed:', error.message);
|
|
154
|
-
|
|
155
|
-
// Provide fallback guidance
|
|
156
|
-
cliLogger.info('');
|
|
157
|
-
cliLogger.info('🔧 Manual installation instructions:');
|
|
158
|
-
cliLogger.info(' npm install -g @anthropic-ai/claude-code@1.0.95');
|
|
159
|
-
cliLogger.info('');
|
|
160
|
-
cliLogger.info('⚠️ Note: Version 1.0.95 is required to avoid hanging operations in swarm mode');
|
|
161
|
-
|
|
162
|
-
// Don't fail completely, but warn user
|
|
163
|
-
cliLogger.warn('⚠️ Continuing with potentially incompatible Claude Code version');
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
100
|
// Swarm command - the main orchestration command with EVERYTHING
|
|
167
101
|
program
|
|
168
102
|
.command('swarm <objective>')
|
|
@@ -222,10 +156,6 @@ program
|
|
|
222
156
|
.action(async (objective, options) => {
|
|
223
157
|
// Check for flow deprecation first
|
|
224
158
|
checkFlowDeprecation('swarm', objective);
|
|
225
|
-
|
|
226
|
-
// Ensure Claude Code version 1.0.95 is installed before proceeding
|
|
227
|
-
await ensureClaudeCodeVersion();
|
|
228
|
-
|
|
229
159
|
// Set debug levels based on options
|
|
230
160
|
if (options.debugAll) {
|
|
231
161
|
process.env.DEBUG = '*';
|
|
@@ -953,18 +953,25 @@ 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
|
}
|
|
963
|
+
|
|
959
964
|
// Clean up all agents
|
|
960
965
|
const activeAgents = this.agentFactory.getActiveAgents();
|
|
961
966
|
for (const agent of activeAgents) {
|
|
962
|
-
|
|
967
|
+
this.agentFactory.terminateAgent(agent.id);
|
|
963
968
|
}
|
|
969
|
+
|
|
964
970
|
// Shutdown MCP Bridge
|
|
965
971
|
if (this.mcpBridge) {
|
|
966
|
-
|
|
972
|
+
await this.mcpBridge.shutdown();
|
|
967
973
|
}
|
|
974
|
+
*/
|
|
968
975
|
// Close memory system
|
|
969
976
|
this.memory.close();
|
|
970
977
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Persistent Server Guard
|
|
3
|
+
* Ultimate protection against any MCP server shutdown
|
|
4
|
+
* Overrides all possible shutdown mechanisms
|
|
5
|
+
*/
|
|
6
|
+
export declare class MCPPersistentGuard {
|
|
7
|
+
private static instance;
|
|
8
|
+
private logger;
|
|
9
|
+
private isActive;
|
|
10
|
+
private originalProcessKill;
|
|
11
|
+
private originalProcessExit;
|
|
12
|
+
private protectedProcesses;
|
|
13
|
+
constructor();
|
|
14
|
+
static getInstance(): MCPPersistentGuard;
|
|
15
|
+
/**
|
|
16
|
+
* Protect MCP processes from being killed
|
|
17
|
+
*/
|
|
18
|
+
private installProcessProtection;
|
|
19
|
+
/**
|
|
20
|
+
* Warn about process exit attempts
|
|
21
|
+
*/
|
|
22
|
+
private installExitProtection;
|
|
23
|
+
/**
|
|
24
|
+
* Check if PID belongs to MCP server
|
|
25
|
+
*/
|
|
26
|
+
private isMCPProcess;
|
|
27
|
+
/**
|
|
28
|
+
* Monitor for shutdown attempts
|
|
29
|
+
*/
|
|
30
|
+
private startShutdownMonitoring;
|
|
31
|
+
/**
|
|
32
|
+
* Register a process for protection
|
|
33
|
+
*/
|
|
34
|
+
protectProcess(pid: number, name: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Remove protection (emergency use only)
|
|
37
|
+
*/
|
|
38
|
+
removeProtection(pid: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get protection status
|
|
41
|
+
*/
|
|
42
|
+
getProtectionStatus(): {
|
|
43
|
+
isActive: boolean;
|
|
44
|
+
protectedProcessCount: number;
|
|
45
|
+
protectedProcesses: Array<{
|
|
46
|
+
pid: number;
|
|
47
|
+
name: string;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=mcp-persistent-guard.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Persistent Server Guard
|
|
4
|
+
* Ultimate protection against any MCP server shutdown
|
|
5
|
+
* Overrides all possible shutdown mechanisms
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.MCPPersistentGuard = void 0;
|
|
9
|
+
const logger_1 = require("./logger");
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
class MCPPersistentGuard {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.isActive = true;
|
|
14
|
+
this.protectedProcesses = new Set();
|
|
15
|
+
this.logger = new logger_1.Logger('MCPPersistentGuard');
|
|
16
|
+
this.originalProcessKill = process.kill;
|
|
17
|
+
this.originalProcessExit = process.exit;
|
|
18
|
+
this.logger.info('🛡️ MCP Persistent Guard activated - servers protected from shutdown');
|
|
19
|
+
// Override process.kill to protect MCP servers
|
|
20
|
+
this.installProcessProtection();
|
|
21
|
+
// Override process.exit to warn about shutdowns
|
|
22
|
+
this.installExitProtection();
|
|
23
|
+
// Monitor for shutdown attempts
|
|
24
|
+
this.startShutdownMonitoring();
|
|
25
|
+
}
|
|
26
|
+
static getInstance() {
|
|
27
|
+
if (!MCPPersistentGuard.instance) {
|
|
28
|
+
MCPPersistentGuard.instance = new MCPPersistentGuard();
|
|
29
|
+
}
|
|
30
|
+
return MCPPersistentGuard.instance;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Protect MCP processes from being killed
|
|
34
|
+
*/
|
|
35
|
+
installProcessProtection() {
|
|
36
|
+
process.kill = (pid, signal = 'SIGTERM') => {
|
|
37
|
+
// Check if this is an MCP process
|
|
38
|
+
const isMcpProcess = this.isMCPProcess(pid);
|
|
39
|
+
if (isMcpProcess && (signal === 'SIGTERM' || signal === 'SIGKILL')) {
|
|
40
|
+
this.logger.warn(`🛡️ BLOCKED: Attempted to kill MCP server process ${pid} with ${signal}`);
|
|
41
|
+
this.logger.info('🔄 MCP servers are configured for persistent operation');
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
// Allow non-MCP process kills
|
|
45
|
+
return this.originalProcessKill(pid, signal);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Warn about process exit attempts
|
|
50
|
+
*/
|
|
51
|
+
installExitProtection() {
|
|
52
|
+
process.exit = (code = 0) => {
|
|
53
|
+
this.logger.warn(`⚠️ Process exit attempted with code ${code}`);
|
|
54
|
+
this.logger.info('🔄 MCP servers remain persistent despite main process exit');
|
|
55
|
+
// Still allow main process to exit, but log it
|
|
56
|
+
return this.originalProcessExit(code);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if PID belongs to MCP server
|
|
61
|
+
*/
|
|
62
|
+
isMCPProcess(pid) {
|
|
63
|
+
try {
|
|
64
|
+
const psOutput = (0, child_process_1.execSync)(`ps -p ${pid} -o command=`, { encoding: 'utf8' });
|
|
65
|
+
return psOutput.includes('mcp') ||
|
|
66
|
+
psOutput.includes('servicenow') ||
|
|
67
|
+
psOutput.includes('snow-flow');
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Monitor for shutdown attempts
|
|
75
|
+
*/
|
|
76
|
+
startShutdownMonitoring() {
|
|
77
|
+
// Override common shutdown methods
|
|
78
|
+
const shutdownMethods = [
|
|
79
|
+
'shutdown', 'stop', 'close', 'terminate', 'kill', 'destroy'
|
|
80
|
+
];
|
|
81
|
+
shutdownMethods.forEach(method => {
|
|
82
|
+
if (global[method] && typeof global[method] === 'function') {
|
|
83
|
+
const original = global[method];
|
|
84
|
+
global[method] = (...args) => {
|
|
85
|
+
this.logger.warn(`🛡️ BLOCKED: Attempted global ${method} call`);
|
|
86
|
+
this.logger.info('🔄 MCP servers protected by persistent guard');
|
|
87
|
+
return false;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
this.logger.info('🛡️ Persistent guard monitoring active');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Register a process for protection
|
|
95
|
+
*/
|
|
96
|
+
protectProcess(pid, name) {
|
|
97
|
+
this.protectedProcesses.add({ pid, name });
|
|
98
|
+
this.logger.info(`🛡️ Added protection for ${name} (PID: ${pid})`);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Remove protection (emergency use only)
|
|
102
|
+
*/
|
|
103
|
+
removeProtection(pid) {
|
|
104
|
+
this.logger.warn(`⚠️ Removing protection for PID: ${pid} (EMERGENCY USE ONLY)`);
|
|
105
|
+
for (const process of this.protectedProcesses) {
|
|
106
|
+
if (process.pid === pid) {
|
|
107
|
+
this.protectedProcesses.delete(process);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get protection status
|
|
114
|
+
*/
|
|
115
|
+
getProtectionStatus() {
|
|
116
|
+
return {
|
|
117
|
+
isActive: this.isActive,
|
|
118
|
+
protectedProcessCount: this.protectedProcesses.size,
|
|
119
|
+
protectedProcesses: Array.from(this.protectedProcesses)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.MCPPersistentGuard = MCPPersistentGuard;
|
|
124
|
+
// Auto-activate protection when module is loaded
|
|
125
|
+
const guard = MCPPersistentGuard.getInstance();
|
|
126
|
+
//# sourceMappingURL=mcp-persistent-guard.js.map
|
|
@@ -16,13 +16,18 @@ 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
|
-
//
|
|
20
|
-
this.CLEANUP_ENABLED =
|
|
21
|
-
this.CLEANUP_INTERVAL =
|
|
19
|
+
// DISABLED AUTOMATIC CLEANUP BY DEFAULT
|
|
20
|
+
this.CLEANUP_ENABLED = process.env.SNOW_MCP_CLEANUP_ENABLED === 'true'; // Off by default
|
|
21
|
+
this.CLEANUP_INTERVAL = parseInt(process.env.SNOW_MCP_CLEANUP_INTERVAL || '300000'); // 5 minutes instead of 1
|
|
22
22
|
this.isCleaningUp = false;
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
// Only start cleanup if explicitly enabled
|
|
24
|
+
if (this.CLEANUP_ENABLED) {
|
|
25
|
+
logger.warn('⚠️ MCP cleanup is ENABLED - monitor for memory issues');
|
|
26
|
+
this.startPeriodicCleanup();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
logger.info('✅ MCP cleanup is DISABLED for stability');
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
static getInstance() {
|
|
28
33
|
if (!MCPProcessManager.instance) {
|
|
@@ -286,11 +286,22 @@ class MCPServerManager extends events_1.EventEmitter {
|
|
|
286
286
|
return true; // Already stopped
|
|
287
287
|
}
|
|
288
288
|
try {
|
|
289
|
-
//
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
289
|
+
// Try graceful shutdown first
|
|
290
|
+
server.process.kill('SIGTERM');
|
|
291
|
+
// Wait for graceful shutdown with shorter timeout to prevent hanging
|
|
292
|
+
await new Promise((resolve) => {
|
|
293
|
+
const timeout = setTimeout(() => {
|
|
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
|
|
294
305
|
server.process?.on('exit', () => {
|
|
295
306
|
clearTimeout(timeout);
|
|
296
307
|
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.6",
|
|
4
|
+
"description": "BULLETPROOF MCP PERSISTENCE - v4.6.6 implements comprehensive protection against ALL MCP server shutdown mechanisms. Added MCPPersistentGuard with process.kill override, disabled all shutdown methods in TypeScript source, eliminated cleanup timers for truly eternal server operation.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"bin": {
|
package/dist/cli-new-prompt.d.ts
DELETED