natureco-cli 2.13.27 → 2.13.29

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.13.27",
3
+ "version": "2.13.29",
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.13.27</div>
214
+ <div class="version-badge" id="version-badge">v2.13.29</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.13.27',
344
+ version: 'v2.13.29',
345
345
  bots: cfg.bots || [],
346
346
  telegramToken: cfg.telegramToken || null,
347
347
  whatsappConnected: cfg.whatsappConnected || false,
@@ -46,12 +46,29 @@ function loadMemory(botId) {
46
46
  lastSeen: data.lastSeen || null,
47
47
  };
48
48
 
49
- // Migrate old format to new format
50
- if (Array.isArray(memory.preferences) && memory.preferences.length > 0 && typeof memory.preferences[0] === 'string') {
51
- memory.preferences = memory.preferences.map(p => ({ value: p, score: 5, updatedAt: new Date().toISOString() }));
49
+ // Migrate old format to new format - check each item individually
50
+ if (Array.isArray(memory.preferences)) {
51
+ memory.preferences = memory.preferences.map(p => {
52
+ if (typeof p === 'string') return { value: p, score: 5, updatedAt: new Date().toISOString() };
53
+ return p; // already correct format
54
+ });
52
55
  }
53
- if (Array.isArray(memory.facts) && memory.facts.length > 0 && typeof memory.facts[0] === 'string') {
54
- memory.facts = memory.facts.map(f => ({ value: f, score: 5, updatedAt: new Date().toISOString() }));
56
+
57
+ if (Array.isArray(memory.facts)) {
58
+ memory.facts = memory.facts.map(f => {
59
+ if (typeof f === 'string') {
60
+ return { value: f, score: 5, updatedAt: new Date().toISOString() };
61
+ }
62
+ if (f && typeof f === 'object' && typeof f.value === 'object') {
63
+ // Nested object: {value: {value: "...", score: 6}} → flatten
64
+ return {
65
+ value: f.value.value || '',
66
+ score: f.value.score || 5,
67
+ updatedAt: f.value.updatedAt || new Date().toISOString()
68
+ };
69
+ }
70
+ return f; // already correct format
71
+ }).filter(f => f && f.value && typeof f.value === 'string' && f.value.length > 0);
55
72
  }
56
73
 
57
74
  return memory;
@@ -237,15 +254,17 @@ function getMemoryPrompt(botId) {
237
254
  }
238
255
 
239
256
  if (facts.length > 0) {
240
- // Limit to top 15 facts to reduce token usage
241
- const sorted = facts.sort((a, b) => (b.score || 0) - (a.score || 0));
242
- const topFacts = sorted.slice(0, 15)
257
+ // Normalize all facts to objects with score, then sort and limit
258
+ const topFacts = facts
243
259
  .map(f => {
244
- if (typeof f === 'string') return f;
245
- if (f && typeof f === 'object') return f.value || '';
246
- return '';
260
+ if (typeof f === 'string') return { value: f, score: 5 };
261
+ if (f && typeof f === 'object') return { value: f.value || '', score: f.score || 5 };
262
+ return null;
247
263
  })
248
- .filter(f => f && f.length > 0);
264
+ .filter(f => f && f.value && f.value.length > 0)
265
+ .sort((a, b) => (b.score || 0) - (a.score || 0))
266
+ .slice(0, 15)
267
+ .map(f => f.value);
249
268
 
250
269
  if (topFacts.length > 0) {
251
270
  parts.push(`Bilgiler: ${topFacts.join(', ')}`);