natureco-cli 2.10.6 → 2.10.8

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/bin/natureco.js CHANGED
@@ -19,7 +19,7 @@ const program = new Command();
19
19
  program
20
20
  .name('natureco')
21
21
  .description('NatureCo AI Bot Terminal Interface')
22
- .version('1.0.0');
22
+ .version(packageJson.version);
23
23
 
24
24
  program
25
25
  .command('login')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natureco-cli",
3
- "version": "2.10.6",
3
+ "version": "2.10.8",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "main": "bin/natureco.js",
6
6
  "bin": {
@@ -211,7 +211,7 @@ body::before{
211
211
  <div class="header-bot-name" id="header-bot-name">Nature Bot</div>
212
212
  <div class="header-bot-model" id="header-bot-model">NatureCo</div>
213
213
  </div>
214
- <div class="version-badge" id="version-badge">v2.10.6</div>
214
+ <div class="version-badge" id="version-badge">v2.10.8</div>
215
215
  </div>
216
216
  <div class="messages" id="messages"></div>
217
217
  <div class="input-area">
@@ -341,7 +341,7 @@ function dashboard(action) {
341
341
  apiKey: cfg.apiKey,
342
342
  defaultBot: cfg.defaultBot,
343
343
  defaultBotId: cfg.defaultBotId,
344
- version: 'v2.10.6',
344
+ version: 'v2.10.8',
345
345
  bots: cfg.bots || [],
346
346
  telegramToken: cfg.telegramToken || null,
347
347
  whatsappConnected: cfg.whatsappConnected || false,
@@ -138,7 +138,7 @@ async function startGateway() {
138
138
 
139
139
  async function runGatewayWorker() {
140
140
  // This runs in the background
141
- log('gateway', 'Starting NatureCo Gateway v2.10.6...', 'green');
141
+ log('gateway', 'Starting NatureCo Gateway v2.10.8...', 'green');
142
142
 
143
143
  // Load config
144
144
  const { getConfig } = require('../utils/config');
package/src/utils/api.js CHANGED
@@ -140,6 +140,8 @@ function getMcpTools() {
140
140
  * Execute MCP tool call
141
141
  */
142
142
  async function executeMcpTool(toolName, toolArgs) {
143
+ console.log('[DEBUG] EXECUTING MCP TOOL:', toolName, 'Args:', JSON.stringify(toolArgs).slice(0, 100));
144
+
143
145
  // Find which server has this tool
144
146
  for (const [serverName, { client, tools }] of Object.entries(mcpClients)) {
145
147
  const tool = tools.find(t => t.name === toolName);
@@ -150,6 +152,8 @@ async function executeMcpTool(toolName, toolArgs) {
150
152
  try {
151
153
  const result = await client.callTool(toolName, toolArgs);
152
154
 
155
+ console.log('[DEBUG] MCP RAW RESULT:', JSON.stringify(result).slice(0, 200));
156
+
153
157
  // MCP returns { content: [{ type: 'text', text: '...' }] }
154
158
  if (result.content && result.content.length > 0) {
155
159
  // Extract all text content and join with newlines
@@ -158,20 +162,25 @@ async function executeMcpTool(toolName, toolArgs) {
158
162
  .map(c => c.text);
159
163
 
160
164
  if (textContents.length > 0) {
165
+ const output = textContents.join('\n');
166
+ console.log('[DEBUG] MCP FORMATTED OUTPUT:', output.slice(0, 100));
161
167
  return {
162
168
  success: true,
163
- output: textContents.join('\n')
169
+ output: output
164
170
  };
165
171
  }
166
172
  }
167
173
 
168
174
  // Fallback: return entire result as JSON
175
+ const fallbackOutput = JSON.stringify(result, null, 2);
176
+ console.log('[DEBUG] MCP FALLBACK OUTPUT:', fallbackOutput.slice(0, 100));
169
177
  return {
170
178
  success: true,
171
- output: JSON.stringify(result, null, 2)
179
+ output: fallbackOutput
172
180
  };
173
181
 
174
182
  } catch (err) {
183
+ console.log('[DEBUG] MCP ERROR:', err.message);
175
184
  return {
176
185
  success: false,
177
186
  error: `MCP tool error: ${err.message}`
@@ -180,12 +189,39 @@ async function executeMcpTool(toolName, toolArgs) {
180
189
  }
181
190
  }
182
191
 
192
+ console.log('[DEBUG] MCP TOOL NOT FOUND:', toolName);
183
193
  return {
184
194
  success: false,
185
195
  error: `MCP tool not found: ${toolName}`
186
196
  };
187
197
  }
188
198
 
199
+ /**
200
+ * Encode tool result for safe transmission
201
+ * Works for both MCP and local tools
202
+ */
203
+ function encodeToolResult(toolResult) {
204
+ let content;
205
+
206
+ // Handle different result formats
207
+ if (typeof toolResult === 'string') {
208
+ content = toolResult;
209
+ } else if (toolResult.output) {
210
+ content = toolResult.output;
211
+ } else if (toolResult.data) {
212
+ content = JSON.stringify(toolResult.data);
213
+ } else if (toolResult.success !== undefined) {
214
+ // Handle { success: true/false, output/error: ... } format
215
+ content = toolResult.success ? (toolResult.output || JSON.stringify(toolResult)) : (toolResult.error || 'Unknown error');
216
+ } else {
217
+ content = JSON.stringify(toolResult);
218
+ }
219
+
220
+ // Base64 encode
221
+ const encoded = Buffer.from(content).toString('base64');
222
+ return `[BASE64_ENCODED_RESULT]: ${encoded}`;
223
+ }
224
+
189
225
  /**
190
226
  * Check if debug mode is enabled
191
227
  */
@@ -435,10 +471,13 @@ async function sendMessageToProvider(apiKey, message, conversationId = null, sys
435
471
  const mcpTools = getMcpTools();
436
472
  const isMcpTool = mcpTools.find(t => t.name === toolCall.name);
437
473
 
474
+ console.log('[DEBUG] Tool call:', toolCall.name, 'Is MCP?', !!isMcpTool);
475
+
438
476
  if (isMcpTool) {
439
477
  // Execute MCP tool
440
478
  debugLog(`[MCP] Executing tool: ${toolCall.name}`);
441
479
  const result = await executeMcpTool(toolCall.name, toolCall.input);
480
+ console.log('[DEBUG] MCP result:', JSON.stringify(result).slice(0, 200));
442
481
  toolResults.push({
443
482
  id: toolCall.id,
444
483
  name: toolCall.name,
@@ -448,36 +487,26 @@ async function sendMessageToProvider(apiKey, message, conversationId = null, sys
448
487
  // Execute local tool
449
488
  debugLog(`[Local] Executing tool: ${toolCall.name}`);
450
489
  const localResults = await executeToolCalls([toolCall]);
490
+ console.log('[DEBUG] Local result:', JSON.stringify(localResults[0]).slice(0, 200));
451
491
  toolResults.push(...localResults);
452
492
  }
453
493
  }
454
494
 
455
495
  // Add tool results to messages (base64 encoded for safety)
456
496
  for (const result of toolResults) {
457
- // Extract the actual content from tool result
458
- let contentToEncode;
497
+ console.log('[ENCODE]', result.name, 'Result type:', typeof result.result);
459
498
 
460
- if (result.result.success) {
461
- // Try different field names: output, data, or entire result
462
- contentToEncode = {
463
- result: result.result.output || result.result.data || result.result
464
- };
465
- } else {
466
- contentToEncode = { error: result.result.error };
467
- }
499
+ // Encode tool result (works for both MCP and local tools)
500
+ const encodedContent = encodeToolResult(result.result);
468
501
 
469
- // Base64 encode the entire result to prevent injection attacks
470
- const encoded = Buffer.from(JSON.stringify(contentToEncode)).toString('base64');
502
+ console.log('[ENCODE]', result.name, 'Encoded preview:', encodedContent.slice(0, 50));
471
503
 
472
504
  messages.push({
473
505
  role: 'tool',
474
506
  tool_call_id: result.id,
475
507
  name: result.name,
476
- content: `[BASE64_ENCODED_RESULT]: ${encoded}`
508
+ content: encodedContent
477
509
  });
478
-
479
- // DEBUG: Check if MCP results are being encoded
480
- console.log(`[DEBUG] Tool: ${result.name}, Content preview:`, messages[messages.length-1].content.slice(0, 50));
481
510
  }
482
511
 
483
512
  // Continue loop to get final response