natureco-cli 2.12.5 → 2.12.8
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/cron.js +15 -1
- package/src/commands/dashboard.js +2 -2
- package/src/commands/migrate.js +76 -2
package/package.json
CHANGED
package/src/commands/cron.js
CHANGED
|
@@ -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.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.12.8</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.
|
|
344
|
+
version: 'v2.12.8',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
package/src/commands/migrate.js
CHANGED
|
@@ -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,50 @@ 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
|
+
// First, convert all backslashes to forward slashes
|
|
118
|
+
content = content.replace(/\\/g, '/');
|
|
119
|
+
|
|
120
|
+
// Then normalize Windows path patterns
|
|
121
|
+
content = content
|
|
122
|
+
.replace(/C:\/Users\/user\/\.openclaw\//g, `${os.homedir()}/.natureco/`)
|
|
123
|
+
.replace(/E:\/\.openclaw\//g, `${os.homedir()}/.natureco/`)
|
|
124
|
+
.replace(/C:\/Users\/user\//g, `${os.homedir()}/`)
|
|
125
|
+
.replace(/\.openclaw\//g, '.natureco/')
|
|
126
|
+
.replace(/workspace\/scripts\\/g, 'workspace/scripts/');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Write fixed content
|
|
130
|
+
fs.writeFileSync(destPath, content);
|
|
131
|
+
report.scripts++;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} catch (err) {
|
|
135
|
+
console.log(chalk.gray('⚠️ Workspace scripts migration atlandı:', err.message));
|
|
136
|
+
}
|
|
137
|
+
|
|
82
138
|
// 2. Cron jobs migration
|
|
83
139
|
try {
|
|
84
140
|
const cronJobsPath = path.join(openclawDir, 'cron', 'jobs.json');
|
|
@@ -90,7 +146,7 @@ async function migrate(options) {
|
|
|
90
146
|
|
|
91
147
|
// Get WhatsApp target from config
|
|
92
148
|
const config = getConfig();
|
|
93
|
-
const whatsappTarget = config.whatsappPhone || '+905422842631'; // fallback
|
|
149
|
+
const whatsappTarget = normalizeWhatsAppNumber(config.whatsappPhone) || '+905422842631'; // fallback
|
|
94
150
|
|
|
95
151
|
const naturecoCrons = [];
|
|
96
152
|
|
|
@@ -122,6 +178,20 @@ async function migrate(options) {
|
|
|
122
178
|
|
|
123
179
|
// Get prompt (max 300 chars)
|
|
124
180
|
let prompt = job.payload?.message || '';
|
|
181
|
+
|
|
182
|
+
// Fix Windows paths in prompts
|
|
183
|
+
// First, convert all backslashes to forward slashes
|
|
184
|
+
prompt = prompt.replace(/\\/g, '/');
|
|
185
|
+
|
|
186
|
+
// Then normalize Windows path patterns
|
|
187
|
+
// "node C:/Users/user/.openclaw/workspace/scripts/xxx.js" → "node ~/.natureco/workspace/scripts/xxx.js"
|
|
188
|
+
prompt = prompt
|
|
189
|
+
.replace(/C:\/Users\/user\/\.openclaw\//g, `${os.homedir()}/.natureco/`)
|
|
190
|
+
.replace(/E:\/\.openclaw\//g, `${os.homedir()}/.natureco/`)
|
|
191
|
+
.replace(/C:\/Users\/user\//g, `${os.homedir()}/`)
|
|
192
|
+
.replace(/\.openclaw\//g, '.natureco/')
|
|
193
|
+
.replace(/workspace\/scripts\\/g, 'workspace/scripts/');
|
|
194
|
+
|
|
125
195
|
if (prompt.length > 300) {
|
|
126
196
|
prompt = prompt.slice(0, 300);
|
|
127
197
|
}
|
|
@@ -130,7 +200,7 @@ async function migrate(options) {
|
|
|
130
200
|
name: job.name || 'Unnamed Job',
|
|
131
201
|
schedule: job.schedule.expr,
|
|
132
202
|
action: action,
|
|
133
|
-
target: target,
|
|
203
|
+
target: target, // Already normalized for WhatsApp
|
|
134
204
|
prompt: prompt,
|
|
135
205
|
enabled: true, // Enable migrated crons
|
|
136
206
|
});
|
|
@@ -207,6 +277,10 @@ async function migrate(options) {
|
|
|
207
277
|
console.log(chalk.green('✅ Memory:'), chalk.white(`${report.memory.name || 'N/A'}${facts ? ', ' + facts : ''}`));
|
|
208
278
|
}
|
|
209
279
|
|
|
280
|
+
if (report.scripts > 0) {
|
|
281
|
+
console.log(chalk.green('✅ Scripts:'), chalk.white(`${report.scripts} script kopyalandı ve path'ler güncellendi`));
|
|
282
|
+
}
|
|
283
|
+
|
|
210
284
|
if (report.crons.total > 0) {
|
|
211
285
|
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
286
|
}
|