natureco-cli 2.12.5 → 2.12.7

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.12.5",
3
+ "version": "2.12.7",
4
4
  "description": "NatureCo AI Bot Terminal Interface",
5
5
  "main": "bin/natureco.js",
6
6
  "bin": {
@@ -5,6 +5,17 @@ const os = require('os');
5
5
 
6
6
  const CRONS_FILE = path.join(os.homedir(), '.natureco', 'crons.json');
7
7
 
8
+ /**
9
+ * Normalize WhatsApp number from JID format to clean phone number
10
+ * "905422842631:49@s.whatsapp.net" → "+905422842631"
11
+ */
12
+ function normalizeWhatsAppNumber(target) {
13
+ if (!target) return target;
14
+ // Extract digits from JID format
15
+ const match = target.match(/^(\d+)/);
16
+ return match ? '+' + match[1] : target;
17
+ }
18
+
8
19
  function loadCrons() {
9
20
  try {
10
21
  if (!fs.existsSync(CRONS_FILE)) {
@@ -116,7 +127,7 @@ function listCrons() {
116
127
  // Load config for fallback targets
117
128
  const { getConfig } = require('../utils/config');
118
129
  const config = getConfig();
119
- const defaultWhatsappTarget = config.whatsappPhone || 'N/A';
130
+ const defaultWhatsappTarget = normalizeWhatsAppNumber(config.whatsappPhone) || 'N/A';
120
131
  const defaultTelegramTarget = (config.telegramAllowedChats && config.telegramAllowedChats[0]) || 'N/A';
121
132
 
122
133
  console.log(chalk.green(`\n📅 Kayıtlı Cron'lar (${crons.length})\n`));
@@ -126,6 +137,9 @@ function listCrons() {
126
137
  let target = c.target;
127
138
  if (!target || target === 'undefined') {
128
139
  target = c.action === 'telegram' ? defaultTelegramTarget : defaultWhatsappTarget;
140
+ } else if (c.action === 'whatsapp') {
141
+ // Normalize WhatsApp JID format
142
+ target = normalizeWhatsAppNumber(target);
129
143
  }
130
144
 
131
145
  console.log(chalk.cyan(`${i + 1}. ${c.name}`));
@@ -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.12.5</div>
214
+ <div class="version-badge" id="version-badge">v2.12.7</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.12.5',
344
+ version: 'v2.12.7',
345
345
  bots: cfg.bots || [],
346
346
  telegramToken: cfg.telegramToken || null,
347
347
  whatsappConnected: cfg.whatsappConnected || false,
@@ -4,6 +4,17 @@ const os = require('os');
4
4
  const chalk = require('chalk');
5
5
  const { getConfig, setConfig } = require('../utils/config');
6
6
 
7
+ /**
8
+ * Normalize WhatsApp number from JID format to clean phone number
9
+ * "905422842631:49@s.whatsapp.net" → "+905422842631"
10
+ */
11
+ function normalizeWhatsAppNumber(target) {
12
+ if (!target) return target;
13
+ // Extract digits from JID format
14
+ const match = target.match(/^(\d+)/);
15
+ return match ? '+' + match[1] : target;
16
+ }
17
+
7
18
  async function migrate(options) {
8
19
  const from = options.from || 'openclaw';
9
20
 
@@ -32,6 +43,7 @@ async function migrate(options) {
32
43
  crons: { total: 0, active: 0, inactive: 0 },
33
44
  telegram: null,
34
45
  whatsapp: false,
46
+ scripts: 0,
35
47
  };
36
48
 
37
49
  // 1. Memory migration
@@ -79,6 +91,48 @@ async function migrate(options) {
79
91
  console.log(chalk.gray('⚠️ Memory migration atlandı:', err.message));
80
92
  }
81
93
 
94
+ // 1.5. Workspace scripts migration
95
+ try {
96
+ const scriptsSourceDir = path.join(openclawDir, 'workspace', 'scripts');
97
+
98
+ if (fs.existsSync(scriptsSourceDir)) {
99
+ const scriptsDestDir = path.join(os.homedir(), '.natureco', 'workspace', 'scripts');
100
+ fs.mkdirSync(scriptsDestDir, { recursive: true });
101
+
102
+ // Copy all files and fix paths
103
+ const files = fs.readdirSync(scriptsSourceDir);
104
+
105
+ for (const file of files) {
106
+ const sourcePath = path.join(scriptsSourceDir, file);
107
+ const destPath = path.join(scriptsDestDir, file);
108
+
109
+ // Skip directories
110
+ if (fs.statSync(sourcePath).isDirectory()) continue;
111
+
112
+ // Read file content
113
+ let content = fs.readFileSync(sourcePath, 'utf8');
114
+
115
+ // Fix Windows paths in .js files
116
+ if (file.endsWith('.js')) {
117
+ // C:\Users\user\.openclaw\ → ~/.natureco/
118
+ content = content.replace(/C:\\Users\\[^\\]+\\.openclaw\\/g, '~/.natureco/');
119
+ // E:\.openclaw\ → ~/.natureco/
120
+ content = content.replace(/E:\\.openclaw\\/g, '~/.natureco/');
121
+ // C:\Users\user\ → ~/
122
+ content = content.replace(/C:\\Users\\[^\\]+\\/g, '~/');
123
+ // General .openclaw path fix
124
+ content = content.replace(/\\.openclaw\\/g, '/.natureco/');
125
+ }
126
+
127
+ // Write fixed content
128
+ fs.writeFileSync(destPath, content);
129
+ report.scripts++;
130
+ }
131
+ }
132
+ } catch (err) {
133
+ console.log(chalk.gray('⚠️ Workspace scripts migration atlandı:', err.message));
134
+ }
135
+
82
136
  // 2. Cron jobs migration
83
137
  try {
84
138
  const cronJobsPath = path.join(openclawDir, 'cron', 'jobs.json');
@@ -90,7 +144,7 @@ async function migrate(options) {
90
144
 
91
145
  // Get WhatsApp target from config
92
146
  const config = getConfig();
93
- const whatsappTarget = config.whatsappPhone || '+905422842631'; // fallback
147
+ const whatsappTarget = normalizeWhatsAppNumber(config.whatsappPhone) || '+905422842631'; // fallback
94
148
 
95
149
  const naturecoCrons = [];
96
150
 
@@ -122,6 +176,14 @@ async function migrate(options) {
122
176
 
123
177
  // Get prompt (max 300 chars)
124
178
  let prompt = job.payload?.message || '';
179
+
180
+ // Fix Windows paths in prompts
181
+ // "node C:\Users\user\.openclaw\workspace\scripts\xxx.js" → "node ~/.natureco/workspace/scripts/xxx.js"
182
+ prompt = prompt.replace(/C:\\Users\\[^\\]+\\.openclaw\\/g, '~/.natureco/');
183
+ prompt = prompt.replace(/E:\\.openclaw\\/g, '~/.natureco/');
184
+ prompt = prompt.replace(/C:\\Users\\[^\\]+\\/g, '~/');
185
+ prompt = prompt.replace(/\\.openclaw\\/g, '/.natureco/');
186
+
125
187
  if (prompt.length > 300) {
126
188
  prompt = prompt.slice(0, 300);
127
189
  }
@@ -130,7 +192,7 @@ async function migrate(options) {
130
192
  name: job.name || 'Unnamed Job',
131
193
  schedule: job.schedule.expr,
132
194
  action: action,
133
- target: target,
195
+ target: target, // Already normalized for WhatsApp
134
196
  prompt: prompt,
135
197
  enabled: true, // Enable migrated crons
136
198
  });
@@ -207,6 +269,10 @@ async function migrate(options) {
207
269
  console.log(chalk.green('✅ Memory:'), chalk.white(`${report.memory.name || 'N/A'}${facts ? ', ' + facts : ''}`));
208
270
  }
209
271
 
272
+ if (report.scripts > 0) {
273
+ console.log(chalk.green('✅ Scripts:'), chalk.white(`${report.scripts} script kopyalandı ve path'ler güncellendi`));
274
+ }
275
+
210
276
  if (report.crons.total > 0) {
211
277
  console.log(chalk.green('✅ Cron jobs:'), chalk.white(`${report.crons.total} job bulundu (${report.crons.active} aktif migrate edildi, ${report.crons.inactive} pasif atlandı)`));
212
278
  }