natureco-cli 2.9.1 → 2.9.2

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": "natureco-cli",
3
- "version": "2.9.1",
3
+ "version": "2.9.2",
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.9.1</div>
214
+ <div class="version-badge" id="version-badge">v2.9.2</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.9.1',
344
+ version: 'v2.9.2',
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.9.1...', 'green');
141
+ log('gateway', 'Starting NatureCo Gateway v2.9.2...', 'green');
142
142
 
143
143
  // Load config
144
144
  const { getConfig } = require('../utils/config');
@@ -600,13 +600,70 @@ function startCronJobs(config) {
600
600
  log('cron', `Triggered: ${cronJob.name}`, 'yellow');
601
601
 
602
602
  try {
603
- // Send prompt to AI
604
- const { sendMessage } = require('../utils/api');
605
- const conversationId = `cron_${cronJob.name.replace(/\s+/g, '_')}`;
603
+ // Get provider config
604
+ const { getConfig } = require('../utils/config');
605
+ const cfg = getConfig();
606
606
 
607
- log('cron', `Sending prompt to AI...`, 'cyan');
608
- const response = await sendMessage(null, null, cronJob.prompt, conversationId);
609
- const reply = response?.reply || response?.message || '';
607
+ if (!cfg.providerUrl || !cfg.providerApiKey) {
608
+ log('cron', 'Provider not configured', 'red');
609
+ return;
610
+ }
611
+
612
+ const isAnthropic = cfg.providerUrl.includes('anthropic.com');
613
+
614
+ log('cron', `Sending prompt to AI (no tools)...`, 'cyan');
615
+
616
+ // Make direct API call without tools
617
+ let reply = '';
618
+
619
+ if (isAnthropic) {
620
+ // Anthropic API
621
+ const response = await fetch(`${cfg.providerUrl}/v1/messages`, {
622
+ method: 'POST',
623
+ headers: {
624
+ 'x-api-key': cfg.providerApiKey,
625
+ 'anthropic-version': '2023-06-01',
626
+ 'Content-Type': 'application/json',
627
+ },
628
+ body: JSON.stringify({
629
+ model: cfg.providerModel || 'claude-3-5-sonnet-20241022',
630
+ max_tokens: 1000,
631
+ messages: [{ role: 'user', content: cronJob.prompt }]
632
+ }),
633
+ });
634
+
635
+ if (!response.ok) {
636
+ const errorText = await response.text();
637
+ throw new Error(`Anthropic API error: ${response.status} - ${errorText}`);
638
+ }
639
+
640
+ const data = await response.json();
641
+ reply = data.content.find(c => c.type === 'text')?.text || '';
642
+
643
+ } else {
644
+ // OpenAI-compatible API
645
+ const response = await fetch(`${cfg.providerUrl}/chat/completions`, {
646
+ method: 'POST',
647
+ headers: {
648
+ 'Authorization': `Bearer ${cfg.providerApiKey}`,
649
+ 'Content-Type': 'application/json',
650
+ },
651
+ body: JSON.stringify({
652
+ model: cfg.providerModel || 'llama-3.1-8b-instant',
653
+ messages: [{ role: 'user', content: cronJob.prompt }],
654
+ temperature: 0.7,
655
+ max_tokens: 1000,
656
+ }),
657
+ });
658
+
659
+ if (!response.ok) {
660
+ const errorText = await response.text();
661
+ throw new Error(`Provider API error: ${response.status} - ${errorText}`);
662
+ }
663
+
664
+ const data = await response.json();
665
+ reply = data.choices[0].message.content;
666
+ }
610
667
 
611
668
  if (!reply) {
612
669
  log('cron', `No response from AI`, 'red');