getmy-ruflo 3.5.48 → 3.5.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getmy-ruflo",
3
- "version": "3.5.48",
3
+ "version": "3.5.50",
4
4
  "description": "GetMy Ruflo - AI agent orchestration platform with real terminal execution, 259 MCP tools, 60+ agents, and swarm coordination",
5
5
  "main": "bin/ruflo.js",
6
6
  "type": "module",
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @claude-flow/cli - CLI Entry Point
4
+ *
5
+ * Claude Flow V3 Command Line Interface
6
+ *
7
+ * Auto-detects MCP mode when stdin is piped and no args provided.
8
+ * This allows: echo '{"jsonrpc":"2.0",...}' | npx @claude-flow/cli
9
+ */
10
+
11
+ import { randomUUID } from 'crypto';
12
+
13
+ // Check if we should run in MCP server mode
14
+ // Conditions:
15
+ // 1. stdin is being piped AND no CLI arguments provided (auto-detect)
16
+ // 2. stdin is being piped AND args are "mcp start" (explicit, e.g. npx claude-flow@alpha mcp start)
17
+ const cliArgs = process.argv.slice(2);
18
+ const isExplicitMCP = cliArgs.length >= 1 && cliArgs[0] === 'mcp' && (cliArgs.length === 1 || cliArgs[1] === 'start');
19
+ const isMCPMode = !process.stdin.isTTY && (process.argv.length === 2 || isExplicitMCP);
20
+
21
+ if (isMCPMode) {
22
+ // Run MCP server mode
23
+ const { listMCPTools, callMCPTool, hasTool } = await import('../dist/src/mcp-client.js');
24
+
25
+ const VERSION = '3.0.0';
26
+ const sessionId = `mcp-${Date.now()}-${randomUUID().slice(0, 8)}`;
27
+
28
+ console.error(
29
+ `[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Starting in stdio mode`
30
+ );
31
+
32
+ let buffer = '';
33
+ process.stdin.setEncoding('utf8');
34
+ process.stdin.on('data', async (chunk) => {
35
+ buffer += chunk;
36
+ let lines = buffer.split('\n');
37
+ buffer = lines.pop() || '';
38
+
39
+ for (const line of lines) {
40
+ if (line.trim()) {
41
+ try {
42
+ const message = JSON.parse(line);
43
+ const response = await handleMessage(message);
44
+ if (response) {
45
+ console.log(JSON.stringify(response));
46
+ }
47
+ } catch (error) {
48
+ console.log(JSON.stringify({
49
+ jsonrpc: '2.0',
50
+ id: null,
51
+ error: { code: -32700, message: 'Parse error' },
52
+ }));
53
+ }
54
+ }
55
+ }
56
+ });
57
+
58
+ process.stdin.on('end', () => {
59
+ process.exit(0);
60
+ });
61
+
62
+ async function handleMessage(message) {
63
+ if (!message.method) {
64
+ return {
65
+ jsonrpc: '2.0',
66
+ id: message.id,
67
+ error: { code: -32600, message: 'Invalid Request: missing method' },
68
+ };
69
+ }
70
+
71
+ const params = message.params || {};
72
+
73
+ switch (message.method) {
74
+ case 'initialize': {
75
+ // Negotiate protocol version: echo client's version if supported,
76
+ // otherwise fall back to the default version.
77
+ const supportedVersions = ['2024-11-05', '2025-11-05'];
78
+ const negotiatedVersion = supportedVersions.includes(params.protocolVersion)
79
+ ? params.protocolVersion
80
+ : '2024-11-05';
81
+ return {
82
+ jsonrpc: '2.0',
83
+ id: message.id,
84
+ result: {
85
+ protocolVersion: negotiatedVersion,
86
+ serverInfo: { name: 'claude-flow', version: VERSION },
87
+ capabilities: {
88
+ tools: { listChanged: true },
89
+ resources: { subscribe: true, listChanged: true },
90
+ },
91
+ },
92
+ };
93
+ }
94
+
95
+ case 'tools/list': {
96
+ const tools = listMCPTools();
97
+ return {
98
+ jsonrpc: '2.0',
99
+ id: message.id,
100
+ result: {
101
+ tools: tools.map(tool => ({
102
+ name: tool.name,
103
+ description: tool.description,
104
+ inputSchema: tool.inputSchema,
105
+ })),
106
+ },
107
+ };
108
+ }
109
+
110
+ case 'tools/call': {
111
+ const toolName = params.name;
112
+ const toolParams = params.arguments || {};
113
+
114
+ if (!hasTool(toolName)) {
115
+ return {
116
+ jsonrpc: '2.0',
117
+ id: message.id,
118
+ error: { code: -32601, message: `Tool not found: ${toolName}` },
119
+ };
120
+ }
121
+
122
+ try {
123
+ const result = await callMCPTool(toolName, toolParams, { sessionId });
124
+ return {
125
+ jsonrpc: '2.0',
126
+ id: message.id,
127
+ result: { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] },
128
+ };
129
+ } catch (error) {
130
+ return {
131
+ jsonrpc: '2.0',
132
+ id: message.id,
133
+ error: {
134
+ code: -32603,
135
+ message: error instanceof Error ? error.message : 'Tool execution failed',
136
+ },
137
+ };
138
+ }
139
+ }
140
+
141
+ case 'notifications/initialized':
142
+ return null;
143
+
144
+ case 'ping':
145
+ return { jsonrpc: '2.0', id: message.id, result: {} };
146
+
147
+ default:
148
+ return {
149
+ jsonrpc: '2.0',
150
+ id: message.id,
151
+ error: { code: -32601, message: `Method not found: ${message.method}` },
152
+ };
153
+ }
154
+ }
155
+ } else {
156
+ // Run normal CLI mode
157
+ const { CLI } = await import('../dist/src/index.js');
158
+ const cli = new CLI();
159
+ cli.run().catch((error) => {
160
+ console.error('Fatal error:', error.message);
161
+ process.exit(1);
162
+ });
163
+ }
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @claude-flow/cli - MCP Server Entry Point
4
+ *
5
+ * Direct stdio MCP server for Claude Code integration.
6
+ * This entry point handles stdin/stdout directly for MCP protocol
7
+ * without any CLI formatting output that would corrupt the protocol.
8
+ */
9
+
10
+ import { randomUUID } from 'crypto';
11
+ import { listMCPTools, callMCPTool, hasTool, initializePluginTools } from '../dist/src/mcp-client.js';
12
+
13
+ const VERSION = '3.0.0';
14
+ const sessionId = `mcp-${Date.now()}-${randomUUID().slice(0, 8)}`;
15
+
16
+ // Log to stderr (doesn't corrupt stdout for MCP protocol)
17
+ console.error(
18
+ `[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Starting in stdio mode`
19
+ );
20
+ console.error(JSON.stringify({
21
+ arch: process.arch,
22
+ mode: 'mcp-stdio',
23
+ nodeVersion: process.version,
24
+ pid: process.pid,
25
+ platform: process.platform,
26
+ protocol: 'stdio',
27
+ sessionId,
28
+ version: VERSION,
29
+ }));
30
+
31
+ // Load plugin tools
32
+ try {
33
+ const pluginToolCount = await initializePluginTools();
34
+ if (pluginToolCount > 0) {
35
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] Loaded ${pluginToolCount} plugin tools`);
36
+ }
37
+ } catch (error) {
38
+ console.error(`[${new Date().toISOString()}] WARN [claude-flow-mcp] Plugin tool loading failed:`, error);
39
+ }
40
+
41
+ // Handle stdin messages
42
+ let buffer = '';
43
+
44
+ process.stdin.setEncoding('utf8');
45
+ process.stdin.on('data', async (chunk) => {
46
+ buffer += chunk;
47
+
48
+ // Process complete JSON messages (newline-delimited)
49
+ let lines = buffer.split('\n');
50
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
51
+
52
+ for (const line of lines) {
53
+ if (line.trim()) {
54
+ try {
55
+ const message = JSON.parse(line);
56
+ const response = await handleMessage(message);
57
+ if (response) {
58
+ console.log(JSON.stringify(response));
59
+ }
60
+ } catch (error) {
61
+ console.error(
62
+ `[${new Date().toISOString()}] ERROR [claude-flow-mcp] Failed to parse:`,
63
+ error instanceof Error ? error.message : String(error)
64
+ );
65
+ // Send parse error response
66
+ console.log(JSON.stringify({
67
+ jsonrpc: '2.0',
68
+ id: null,
69
+ error: { code: -32700, message: 'Parse error' },
70
+ }));
71
+ }
72
+ }
73
+ }
74
+ });
75
+
76
+ process.stdin.on('end', () => {
77
+ console.error(
78
+ `[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) stdin closed, shutting down...`
79
+ );
80
+ process.exit(0);
81
+ });
82
+
83
+ // Handle process termination
84
+ process.on('SIGINT', () => {
85
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] Received SIGINT`);
86
+ process.exit(0);
87
+ });
88
+
89
+ process.on('SIGTERM', () => {
90
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] Received SIGTERM`);
91
+ process.exit(0);
92
+ });
93
+
94
+ /**
95
+ * Handle MCP message
96
+ */
97
+ async function handleMessage(message) {
98
+ if (!message.method) {
99
+ return {
100
+ jsonrpc: '2.0',
101
+ id: message.id,
102
+ error: { code: -32600, message: 'Invalid Request: missing method' },
103
+ };
104
+ }
105
+
106
+ const params = message.params || {};
107
+
108
+ try {
109
+ switch (message.method) {
110
+ case 'initialize': {
111
+ // Negotiate protocol version: echo client's version if supported,
112
+ // otherwise fall back to the default version.
113
+ const supportedVersions = ['2024-11-05', '2025-11-05'];
114
+ const negotiatedVersion = supportedVersions.includes(params.protocolVersion)
115
+ ? params.protocolVersion
116
+ : '2024-11-05';
117
+ return {
118
+ jsonrpc: '2.0',
119
+ id: message.id,
120
+ result: {
121
+ protocolVersion: negotiatedVersion,
122
+ serverInfo: { name: 'claude-flow', version: VERSION },
123
+ capabilities: {
124
+ tools: { listChanged: true },
125
+ resources: { subscribe: true, listChanged: true },
126
+ },
127
+ },
128
+ };
129
+ }
130
+
131
+ case 'tools/list': {
132
+ const tools = listMCPTools();
133
+ return {
134
+ jsonrpc: '2.0',
135
+ id: message.id,
136
+ result: {
137
+ tools: tools.map(tool => ({
138
+ name: tool.name,
139
+ description: tool.description,
140
+ inputSchema: tool.inputSchema,
141
+ })),
142
+ },
143
+ };
144
+ }
145
+
146
+ case 'tools/call': {
147
+ const toolName = params.name;
148
+ const toolParams = params.arguments || {};
149
+
150
+ if (!hasTool(toolName)) {
151
+ return {
152
+ jsonrpc: '2.0',
153
+ id: message.id,
154
+ error: { code: -32601, message: `Tool not found: ${toolName}` },
155
+ };
156
+ }
157
+
158
+ try {
159
+ const result = await callMCPTool(toolName, toolParams, { sessionId });
160
+ return {
161
+ jsonrpc: '2.0',
162
+ id: message.id,
163
+ result: { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] },
164
+ };
165
+ } catch (error) {
166
+ return {
167
+ jsonrpc: '2.0',
168
+ id: message.id,
169
+ error: {
170
+ code: -32603,
171
+ message: error instanceof Error ? error.message : 'Tool execution failed',
172
+ },
173
+ };
174
+ }
175
+ }
176
+
177
+ case 'notifications/initialized':
178
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] Client initialized`);
179
+ return null; // No response for notifications
180
+
181
+ case 'ping':
182
+ return {
183
+ jsonrpc: '2.0',
184
+ id: message.id,
185
+ result: {},
186
+ };
187
+
188
+ default:
189
+ return {
190
+ jsonrpc: '2.0',
191
+ id: message.id,
192
+ error: { code: -32601, message: `Method not found: ${message.method}` },
193
+ };
194
+ }
195
+ } catch (error) {
196
+ console.error(`[${new Date().toISOString()}] ERROR [claude-flow-mcp] ${message.method}:`, error);
197
+ return {
198
+ jsonrpc: '2.0',
199
+ id: message.id,
200
+ error: {
201
+ code: -32603,
202
+ message: error instanceof Error ? error.message : 'Internal error',
203
+ },
204
+ };
205
+ }
206
+ }