natureco-cli 2.9.0 → 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/bin/natureco.js +9 -5
- package/package.json +1 -1
- package/src/commands/cron.js +10 -34
- package/src/commands/dashboard.js +2 -2
- package/src/commands/gateway-server.js +64 -7
package/bin/natureco.js
CHANGED
|
@@ -106,12 +106,16 @@ program
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
program
|
|
109
|
-
.command('cron <action>
|
|
110
|
-
.
|
|
111
|
-
.
|
|
109
|
+
.command('cron <action>')
|
|
110
|
+
.option('--name <name>', 'Cron job adı')
|
|
111
|
+
.option('--schedule <schedule>', 'Cron schedule (örnek: "0 9 * * *")')
|
|
112
|
+
.option('--action <action>', 'Aksiyon: whatsapp veya telegram')
|
|
113
|
+
.option('--target <target>', 'Hedef numara veya chat ID')
|
|
114
|
+
.option('--prompt <prompt>', 'AI\'a gönderilecek prompt')
|
|
115
|
+
.description('Cron job yönetimi (add|list|remove)')
|
|
116
|
+
.action((action, options) => {
|
|
112
117
|
const cronCmd = require('../src/commands/cron');
|
|
113
|
-
|
|
114
|
-
cronCmd(args);
|
|
118
|
+
cronCmd(action, options);
|
|
115
119
|
});
|
|
116
120
|
|
|
117
121
|
program
|
package/package.json
CHANGED
package/src/commands/cron.js
CHANGED
|
@@ -24,9 +24,7 @@ function saveCrons(crons) {
|
|
|
24
24
|
fs.writeFileSync(CRONS_FILE, JSON.stringify(crons, null, 2), 'utf-8');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
async function cron(
|
|
28
|
-
const action = args[0];
|
|
29
|
-
|
|
27
|
+
async function cron(action, options) {
|
|
30
28
|
if (!action || !['add', 'list', 'remove'].includes(action)) {
|
|
31
29
|
console.log(chalk.red('\n❌ Geçersiz aksiyon\n'));
|
|
32
30
|
console.log(chalk.gray('Kullanım:'));
|
|
@@ -39,35 +37,20 @@ async function cron(args) {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
if (action === 'add') {
|
|
42
|
-
await addCron(
|
|
40
|
+
await addCron(options);
|
|
43
41
|
} else if (action === 'list') {
|
|
44
42
|
listCrons();
|
|
45
43
|
} else if (action === 'remove') {
|
|
46
|
-
removeCron(
|
|
44
|
+
removeCron(options);
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
async function addCron(
|
|
51
|
-
const
|
|
52
|
-
const scheduleIndex = args.indexOf('--schedule');
|
|
53
|
-
const actionIndex = args.indexOf('--action');
|
|
54
|
-
const targetIndex = args.indexOf('--target');
|
|
55
|
-
const promptIndex = args.indexOf('--prompt');
|
|
56
|
-
|
|
57
|
-
if (nameIndex === -1 || scheduleIndex === -1 || actionIndex === -1 || targetIndex === -1 || promptIndex === -1) {
|
|
58
|
-
console.log(chalk.red('\n❌ Eksik parametre\n'));
|
|
59
|
-
console.log(chalk.gray('Gerekli parametreler: --name, --schedule, --action, --target, --prompt\n'));
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const name = args[nameIndex + 1];
|
|
64
|
-
const schedule = args[scheduleIndex + 1];
|
|
65
|
-
const action = args[actionIndex + 1];
|
|
66
|
-
const target = args[targetIndex + 1];
|
|
67
|
-
const prompt = args[promptIndex + 1];
|
|
48
|
+
async function addCron(options) {
|
|
49
|
+
const { name, schedule, action, target, prompt } = options;
|
|
68
50
|
|
|
69
51
|
if (!name || !schedule || !action || !target || !prompt) {
|
|
70
|
-
console.log(chalk.red('\n❌
|
|
52
|
+
console.log(chalk.red('\n❌ Eksik parametre\n'));
|
|
53
|
+
console.log(chalk.gray('Gerekli parametreler: --name, --schedule, --action, --target, --prompt\n'));
|
|
71
54
|
process.exit(1);
|
|
72
55
|
}
|
|
73
56
|
|
|
@@ -142,18 +125,11 @@ function listCrons() {
|
|
|
142
125
|
});
|
|
143
126
|
}
|
|
144
127
|
|
|
145
|
-
function removeCron(
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
if (nameIndex === -1) {
|
|
149
|
-
console.log(chalk.red('\n❌ --name parametresi gerekli\n'));
|
|
150
|
-
process.exit(1);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const name = args[nameIndex + 1];
|
|
128
|
+
function removeCron(options) {
|
|
129
|
+
const { name } = options;
|
|
154
130
|
|
|
155
131
|
if (!name) {
|
|
156
|
-
console.log(chalk.red('\n❌
|
|
132
|
+
console.log(chalk.red('\n❌ --name parametresi gerekli\n'));
|
|
157
133
|
process.exit(1);
|
|
158
134
|
}
|
|
159
135
|
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
-
//
|
|
604
|
-
const {
|
|
605
|
-
const
|
|
603
|
+
// Get provider config
|
|
604
|
+
const { getConfig } = require('../utils/config');
|
|
605
|
+
const cfg = getConfig();
|
|
606
606
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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');
|