natureco-cli 2.13.29 → 2.14.0
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 +1 -1
- package/src/commands/chat.js +54 -31
- package/src/commands/dashboard.js +2 -2
- package/src/utils/api.js +7 -0
package/package.json
CHANGED
package/src/commands/chat.js
CHANGED
|
@@ -85,9 +85,23 @@ async function chat(botName, options = {}) {
|
|
|
85
85
|
|
|
86
86
|
// Chat başlat
|
|
87
87
|
console.clear();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
|
|
89
|
+
// Get botName from memory
|
|
90
|
+
const memory = loadMemory(bot.id);
|
|
91
|
+
const displayBotName = memory.botName || bot.name;
|
|
92
|
+
|
|
93
|
+
// Get provider model (short name)
|
|
94
|
+
const { getConfig } = require('../utils/config');
|
|
95
|
+
const config = getConfig();
|
|
96
|
+
const providerModel = config.providerModel || 'unknown';
|
|
97
|
+
const shortModel = providerModel.split('/').pop().split('-').slice(0, 2).join('-'); // e.g., "llama-3.1" from "llama-3.1-8b-instant"
|
|
98
|
+
|
|
99
|
+
// Minimal header with separator
|
|
100
|
+
const separator = '─'.repeat(40);
|
|
101
|
+
console.log(chalk.gray(separator));
|
|
102
|
+
console.log(chalk.white('NatureCo') + chalk.gray(' · ') + chalk.cyan(displayBotName) + chalk.gray(' · ') + chalk.gray(shortModel));
|
|
103
|
+
console.log(chalk.gray(separator));
|
|
104
|
+
console.log('');
|
|
91
105
|
|
|
92
106
|
// Session management
|
|
93
107
|
let session;
|
|
@@ -96,41 +110,42 @@ async function chat(botName, options = {}) {
|
|
|
96
110
|
// Resume latest session
|
|
97
111
|
session = getLatestSession(bot.id);
|
|
98
112
|
if (session) {
|
|
99
|
-
console.log(chalk.blue(
|
|
113
|
+
console.log(chalk.blue(`Resumed: ${session.id}\n`));
|
|
100
114
|
// Display last few messages
|
|
101
115
|
const lastMessages = session.messages.slice(-3);
|
|
102
116
|
lastMessages.forEach(msg => {
|
|
103
|
-
console.log(chalk.
|
|
104
|
-
console.log(chalk.
|
|
117
|
+
console.log(chalk.gray('You ') + msg.user);
|
|
118
|
+
console.log(chalk.cyan(displayBotName + ' ') + msg.bot);
|
|
119
|
+
console.log('');
|
|
105
120
|
});
|
|
106
121
|
} else {
|
|
107
|
-
console.log(chalk.gray('No previous session
|
|
122
|
+
console.log(chalk.gray('No previous session. Starting new.\n'));
|
|
108
123
|
session = createSession(bot.id, bot.name);
|
|
109
124
|
}
|
|
110
125
|
} else {
|
|
111
126
|
// Resume specific session
|
|
112
127
|
session = loadSession(bot.id, options.resume);
|
|
113
128
|
if (session) {
|
|
114
|
-
console.log(chalk.blue(
|
|
129
|
+
console.log(chalk.blue(`Resumed: ${session.id}\n`));
|
|
115
130
|
// Display last few messages
|
|
116
131
|
const lastMessages = session.messages.slice(-3);
|
|
117
132
|
lastMessages.forEach(msg => {
|
|
118
|
-
console.log(chalk.
|
|
119
|
-
console.log(chalk.
|
|
133
|
+
console.log(chalk.gray('You ') + msg.user);
|
|
134
|
+
console.log(chalk.cyan(displayBotName + ' ') + msg.bot);
|
|
135
|
+
console.log('');
|
|
120
136
|
});
|
|
121
137
|
} else {
|
|
122
|
-
console.log(chalk.red(
|
|
138
|
+
console.log(chalk.red(`Session not found: ${options.resume}\n`));
|
|
123
139
|
process.exit(1);
|
|
124
140
|
}
|
|
125
141
|
}
|
|
126
142
|
} else {
|
|
127
143
|
// Create new session
|
|
128
144
|
session = createSession(bot.id, bot.name);
|
|
129
|
-
console.log(chalk.gray(`Session
|
|
145
|
+
console.log(chalk.gray(`Session: ${session.id}\n`));
|
|
130
146
|
}
|
|
131
147
|
|
|
132
|
-
console.log(chalk.gray('
|
|
133
|
-
console.log(chalk.gray('Ctrl+B: Arka plana al | Ctrl+C: Çık\n'));
|
|
148
|
+
console.log(chalk.gray('Commands: /clear /bot /skills /memory /help · Ctrl+C to exit\n'));
|
|
134
149
|
|
|
135
150
|
// Run on-start hooks
|
|
136
151
|
await runHooks('on-start', null, { botId: bot.id, botName: bot.name });
|
|
@@ -162,7 +177,7 @@ async function chat(botName, options = {}) {
|
|
|
162
177
|
const rl = readline.createInterface({
|
|
163
178
|
input: process.stdin,
|
|
164
179
|
output: process.stdout,
|
|
165
|
-
prompt: chalk.
|
|
180
|
+
prompt: chalk.gray('You '),
|
|
166
181
|
historySize: 100,
|
|
167
182
|
});
|
|
168
183
|
|
|
@@ -229,10 +244,12 @@ async function chat(botName, options = {}) {
|
|
|
229
244
|
switch (command.toLowerCase()) {
|
|
230
245
|
case 'clear':
|
|
231
246
|
console.clear();
|
|
232
|
-
|
|
233
|
-
console.log(chalk.
|
|
234
|
-
console.log(chalk.
|
|
235
|
-
console.log(chalk.gray(
|
|
247
|
+
const separator2 = '─'.repeat(40);
|
|
248
|
+
console.log(chalk.gray(separator2));
|
|
249
|
+
console.log(chalk.white('NatureCo') + chalk.gray(' · ') + chalk.cyan(displayBotName) + chalk.gray(' · ') + chalk.gray(shortModel));
|
|
250
|
+
console.log(chalk.gray(separator2));
|
|
251
|
+
console.log('');
|
|
252
|
+
console.log(chalk.gray('Commands: /clear /bot /skills /memory /help\n'));
|
|
236
253
|
rl.prompt();
|
|
237
254
|
return;
|
|
238
255
|
|
|
@@ -262,8 +279,13 @@ async function chat(botName, options = {}) {
|
|
|
262
279
|
bot = newBot;
|
|
263
280
|
conversationId = null;
|
|
264
281
|
session = createSession(bot.id, bot.name);
|
|
265
|
-
|
|
266
|
-
|
|
282
|
+
|
|
283
|
+
// Update displayBotName
|
|
284
|
+
const newMemory = loadMemory(bot.id);
|
|
285
|
+
const newDisplayBotName = newMemory.botName || bot.name;
|
|
286
|
+
|
|
287
|
+
console.log(chalk.green(`\nBot changed: ${newDisplayBotName}\n`));
|
|
288
|
+
console.log(chalk.gray(`Session: ${session.id}\n`));
|
|
267
289
|
rl.prompt();
|
|
268
290
|
return;
|
|
269
291
|
|
|
@@ -401,13 +423,13 @@ ${lastCodeBlock}
|
|
|
401
423
|
}
|
|
402
424
|
|
|
403
425
|
const botReply = response.reply || response.message || 'No response';
|
|
404
|
-
console.log(chalk.
|
|
426
|
+
console.log(chalk.cyan(`${displayBotName} `) + botReply + '\n');
|
|
405
427
|
|
|
406
428
|
addToHistory(bot.id, '/ultrareview', botReply, conversationId);
|
|
407
429
|
addMessageToSession(bot.id, session.id, '/ultrareview', botReply);
|
|
408
430
|
} catch (err) {
|
|
409
431
|
stopLoadingAnimation(loadingInterval);
|
|
410
|
-
console.log(chalk.red(
|
|
432
|
+
console.log(chalk.red(`Error: ${err.message}\n`));
|
|
411
433
|
}
|
|
412
434
|
|
|
413
435
|
rl.prompt();
|
|
@@ -436,13 +458,13 @@ ${lastCodeBlock}
|
|
|
436
458
|
}
|
|
437
459
|
|
|
438
460
|
const botReply = response.reply || response.message || 'No response';
|
|
439
|
-
console.log(chalk.
|
|
461
|
+
console.log(chalk.cyan(`${displayBotName} `) + botReply + '\n');
|
|
440
462
|
|
|
441
463
|
addToHistory(bot.id, userMessage, botReply, conversationId);
|
|
442
464
|
addMessageToSession(bot.id, session.id, userMessage, botReply);
|
|
443
465
|
} catch (err) {
|
|
444
466
|
stopLoadingAnimation(loadingInterval);
|
|
445
|
-
console.log(chalk.red(
|
|
467
|
+
console.log(chalk.red(`Error: ${err.message}\n`));
|
|
446
468
|
}
|
|
447
469
|
|
|
448
470
|
rl.prompt();
|
|
@@ -532,7 +554,7 @@ ${lastCodeBlock}
|
|
|
532
554
|
// Run post-message hooks
|
|
533
555
|
botReply = await runHooks('post-message', botReply, { botId: bot.id, botName: bot.name });
|
|
534
556
|
|
|
535
|
-
console.log(chalk.
|
|
557
|
+
console.log(chalk.cyan(`${displayBotName} `) + botReply + '\n');
|
|
536
558
|
|
|
537
559
|
// Save to history and session
|
|
538
560
|
addToHistory(bot.id, userMessage, botReply, conversationId);
|
|
@@ -546,7 +568,7 @@ ${lastCodeBlock}
|
|
|
546
568
|
}
|
|
547
569
|
} catch (err) {
|
|
548
570
|
stopLoadingAnimation(loadingInterval);
|
|
549
|
-
console.log(chalk.red(
|
|
571
|
+
console.log(chalk.red(`Error: ${err.message}\n`));
|
|
550
572
|
}
|
|
551
573
|
|
|
552
574
|
currentMessage = '';
|
|
@@ -568,15 +590,16 @@ ${lastCodeBlock}
|
|
|
568
590
|
}
|
|
569
591
|
|
|
570
592
|
function startLoadingAnimation() {
|
|
571
|
-
const frames = ['
|
|
593
|
+
const frames = ['●○○', '○●○', '○○●'];
|
|
572
594
|
let i = 0;
|
|
573
595
|
|
|
574
|
-
|
|
596
|
+
// Get displayBotName from current context (will be passed as parameter)
|
|
597
|
+
process.stdout.write(chalk.cyan('... '));
|
|
575
598
|
|
|
576
599
|
return setInterval(() => {
|
|
577
|
-
process.stdout.write(`\r${chalk.
|
|
600
|
+
process.stdout.write(`\r${chalk.cyan(frames[i] + ' ')}`);
|
|
578
601
|
i = (i + 1) % frames.length;
|
|
579
|
-
},
|
|
602
|
+
}, 300);
|
|
580
603
|
}
|
|
581
604
|
|
|
582
605
|
function stopLoadingAnimation(interval) {
|
|
@@ -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.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.14.0</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.
|
|
344
|
+
version: 'v2.14.0',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
package/src/utils/api.js
CHANGED
|
@@ -784,6 +784,13 @@ TOOL SELECTION GUIDE:
|
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
|
|
787
|
+
// Add memory prompt
|
|
788
|
+
const { getMemoryPrompt } = require('./memory');
|
|
789
|
+
const memoryPrompt = getMemoryPrompt(botId);
|
|
790
|
+
if (memoryPrompt) {
|
|
791
|
+
systemPrompt += '\n\n' + memoryPrompt;
|
|
792
|
+
}
|
|
793
|
+
|
|
787
794
|
return sendMessageToProvider(apiKey, message, conversationId, systemPrompt);
|
|
788
795
|
}
|
|
789
796
|
|