natureco-cli 2.10.7 → 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 +1 -1
- package/package.json +1 -1
- package/src/commands/dashboard.js +2 -2
- package/src/commands/gateway-server.js +1 -1
- package/src/utils/api.js +33 -18
package/bin/natureco.js
CHANGED
package/package.json
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
@@ -196,6 +196,32 @@ async function executeMcpTool(toolName, toolArgs) {
|
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
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
|
+
|
|
199
225
|
/**
|
|
200
226
|
* Check if debug mode is enabled
|
|
201
227
|
*/
|
|
@@ -451,7 +477,7 @@ async function sendMessageToProvider(apiKey, message, conversationId = null, sys
|
|
|
451
477
|
// Execute MCP tool
|
|
452
478
|
debugLog(`[MCP] Executing tool: ${toolCall.name}`);
|
|
453
479
|
const result = await executeMcpTool(toolCall.name, toolCall.input);
|
|
454
|
-
console.log('[DEBUG] MCP result
|
|
480
|
+
console.log('[DEBUG] MCP result:', JSON.stringify(result).slice(0, 200));
|
|
455
481
|
toolResults.push({
|
|
456
482
|
id: toolCall.id,
|
|
457
483
|
name: toolCall.name,
|
|
@@ -461,37 +487,26 @@ async function sendMessageToProvider(apiKey, message, conversationId = null, sys
|
|
|
461
487
|
// Execute local tool
|
|
462
488
|
debugLog(`[Local] Executing tool: ${toolCall.name}`);
|
|
463
489
|
const localResults = await executeToolCalls([toolCall]);
|
|
464
|
-
console.log('[DEBUG] Local result
|
|
490
|
+
console.log('[DEBUG] Local result:', JSON.stringify(localResults[0]).slice(0, 200));
|
|
465
491
|
toolResults.push(...localResults);
|
|
466
492
|
}
|
|
467
493
|
}
|
|
468
494
|
|
|
469
495
|
// Add tool results to messages (base64 encoded for safety)
|
|
470
496
|
for (const result of toolResults) {
|
|
471
|
-
|
|
472
|
-
let contentToEncode;
|
|
497
|
+
console.log('[ENCODE]', result.name, 'Result type:', typeof result.result);
|
|
473
498
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
contentToEncode = {
|
|
477
|
-
result: result.result.output || result.result.data || result.result
|
|
478
|
-
};
|
|
479
|
-
} else {
|
|
480
|
-
contentToEncode = { error: result.result.error };
|
|
481
|
-
}
|
|
499
|
+
// Encode tool result (works for both MCP and local tools)
|
|
500
|
+
const encodedContent = encodeToolResult(result.result);
|
|
482
501
|
|
|
483
|
-
|
|
484
|
-
const encoded = Buffer.from(JSON.stringify(contentToEncode)).toString('base64');
|
|
502
|
+
console.log('[ENCODE]', result.name, 'Encoded preview:', encodedContent.slice(0, 50));
|
|
485
503
|
|
|
486
504
|
messages.push({
|
|
487
505
|
role: 'tool',
|
|
488
506
|
tool_call_id: result.id,
|
|
489
507
|
name: result.name,
|
|
490
|
-
content:
|
|
508
|
+
content: encodedContent
|
|
491
509
|
});
|
|
492
|
-
|
|
493
|
-
// DEBUG: Check if MCP results are being encoded
|
|
494
|
-
console.log(`[DEBUG] Tool: ${result.name}, Content preview:`, messages[messages.length-1].content.slice(0, 50));
|
|
495
510
|
}
|
|
496
511
|
|
|
497
512
|
// Continue loop to get final response
|