natureco-cli 5.6.13 → 5.6.14
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/agents.js +242 -241
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.14",
|
|
4
4
|
"description": "OpenClaw'dan daha güvenli, daha hızlı, daha ucuz AI agent CLI. Multi-agent, self-evolving skills, audit log, maliyet optimizasyonu ve NatureCo platform-native.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"natureco": "bin/natureco.js"
|
package/src/commands/agents.js
CHANGED
|
@@ -1,241 +1,242 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fs.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
fs.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (action === '
|
|
42
|
-
if (action === '
|
|
43
|
-
if (action === '
|
|
44
|
-
if (action === '
|
|
45
|
-
if (action === '
|
|
46
|
-
if (action === '
|
|
47
|
-
if (action === '
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.log(chalk.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.log(tui.styled('
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
console.log(' ' + tui.C.muted('
|
|
71
|
-
console.log('');
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{ key: '
|
|
92
|
-
{ key: '
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
console.log('');
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
F.kv('
|
|
157
|
-
|
|
158
|
-
if (bot.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
F.kv('
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log(
|
|
178
|
-
console.log(chalk.
|
|
179
|
-
console.log(chalk.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (!bindings[agentId]
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
identities
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const tui = require('../utils/tui');
|
|
3
|
+
const F = require('../utils/format');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
const inquirer = require('../utils/inquirer-wrapper');
|
|
8
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
9
|
+
const { getBots } = require('../utils/api');
|
|
10
|
+
|
|
11
|
+
const BINDINGS_FILE = path.join(os.homedir(), '.natureco', 'agent-bindings.json');
|
|
12
|
+
const IDENTITIES_FILE = path.join(os.homedir(), '.natureco', 'agent-identities.json');
|
|
13
|
+
|
|
14
|
+
function loadBindings() {
|
|
15
|
+
try {
|
|
16
|
+
if (fs.existsSync(BINDINGS_FILE)) return JSON.parse(fs.readFileSync(BINDINGS_FILE, 'utf8'));
|
|
17
|
+
} catch {}
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function saveBindings(data) {
|
|
22
|
+
fs.mkdirSync(path.dirname(BINDINGS_FILE), { recursive: true });
|
|
23
|
+
fs.writeFileSync(BINDINGS_FILE, JSON.stringify(data, null, 2));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function loadIdentities() {
|
|
27
|
+
try {
|
|
28
|
+
if (fs.existsSync(IDENTITIES_FILE)) return JSON.parse(fs.readFileSync(IDENTITIES_FILE, 'utf8'));
|
|
29
|
+
} catch {}
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function saveIdentities(data) {
|
|
34
|
+
fs.mkdirSync(path.dirname(IDENTITIES_FILE), { recursive: true });
|
|
35
|
+
fs.writeFileSync(IDENTITIES_FILE, JSON.stringify(data, null, 2));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function agents(args) {
|
|
39
|
+
const [action, ...params] = (args || []);
|
|
40
|
+
|
|
41
|
+
if (!action || action === 'list') return listAgents();
|
|
42
|
+
if (action === 'set') return setActiveAgent(params[0]);
|
|
43
|
+
if (action === 'info') return agentInfo(params[0]);
|
|
44
|
+
if (action === 'add') return addAgent();
|
|
45
|
+
if (action === 'bindings') return listBindings();
|
|
46
|
+
if (action === 'bind') return bindAgent(params[0], params[1]);
|
|
47
|
+
if (action === 'unbind') return unbindAgent(params[0], params[1]);
|
|
48
|
+
if (action === 'set-identity') return setIdentity(params[0], params.slice(1).join(' '));
|
|
49
|
+
|
|
50
|
+
console.log(chalk.red(`\n ❌ Bilinmeyen komut: ${action}\n`));
|
|
51
|
+
console.log(chalk.gray(' Kullanım: natureco agents [list|set|info|add|bindings|bind|unbind|set-identity]\n'));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function listAgents() {
|
|
56
|
+
const config = getConfig();
|
|
57
|
+
const apiKey = config.providerApiKey || config.apiKey || '';
|
|
58
|
+
|
|
59
|
+
F.info('Agentlar yükleniyor...');
|
|
60
|
+
|
|
61
|
+
let botList = { bots: [] };
|
|
62
|
+
try {
|
|
63
|
+
botList = await getBots(apiKey);
|
|
64
|
+
} catch {}
|
|
65
|
+
|
|
66
|
+
console.log('\n' + tui.styled(' 🤖 Agents', { color: tui.PALETTE.primary, bold: true }));
|
|
67
|
+
console.log(tui.styled(' ' + '─'.repeat(56), { color: tui.PALETTE.border }));
|
|
68
|
+
|
|
69
|
+
if (!botList.bots?.length) {
|
|
70
|
+
console.log('\n ' + tui.C.muted('Agent bulunamadı.'));
|
|
71
|
+
console.log(' ' + tui.C.muted('Oluşturmak için: ') + tui.C.brand('developers.natureco.me'));
|
|
72
|
+
console.log('');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const rows = botList.bots.map(bot => ({
|
|
77
|
+
name: bot.name + (config.botName === bot.name ? ' ●' : ''),
|
|
78
|
+
id: bot.id,
|
|
79
|
+
provider: bot.ai_provider || 'groq',
|
|
80
|
+
model: bot.model || '—',
|
|
81
|
+
active: config.botName === bot.name,
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
console.log('\n' + tui.table(rows, [
|
|
85
|
+
{
|
|
86
|
+
key: 'name', label: 'İsim', minWidth: 18,
|
|
87
|
+
render: r => r.active
|
|
88
|
+
? tui.styled(r.name, { color: tui.PALETTE.success, bold: true })
|
|
89
|
+
: tui.C.text(r.name)
|
|
90
|
+
},
|
|
91
|
+
{ key: 'id', label: 'ID', minWidth: 16, render: r => tui.C.muted(r.id) },
|
|
92
|
+
{ key: 'provider', label: 'Provider', minWidth: 12, render: r => tui.C.text(r.provider) },
|
|
93
|
+
{ key: 'model', label: 'Model', minWidth: 18, render: r => tui.C.muted(r.model) },
|
|
94
|
+
], { borderStyle: 'round', zebra: true }));
|
|
95
|
+
|
|
96
|
+
console.log('\n ' + tui.C.muted('Değiştirmek için: ') + tui.C.brand('natureco agents set <bot-adı>'));
|
|
97
|
+
console.log('');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function setActiveAgent(botName) {
|
|
101
|
+
const config = getConfig();
|
|
102
|
+
const apiKey = config.providerApiKey || config.apiKey || '';
|
|
103
|
+
|
|
104
|
+
let botList = { bots: [] };
|
|
105
|
+
try {
|
|
106
|
+
botList = await getBots(apiKey);
|
|
107
|
+
} catch {}
|
|
108
|
+
|
|
109
|
+
if (!botName) {
|
|
110
|
+
if (!botList.bots?.length) {
|
|
111
|
+
console.log(chalk.gray('\n Agent bulunamadı.\n'));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const { selected } = await inquirer.prompt([{
|
|
115
|
+
type: 'list',
|
|
116
|
+
name: 'selected',
|
|
117
|
+
message: ' Aktif agent seç:',
|
|
118
|
+
choices: botList.bots.map(b => ({ name: b.name, value: b.name })),
|
|
119
|
+
}]);
|
|
120
|
+
botName = selected;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const bot = botList.bots?.find(b => b.name === botName || b.id === botName);
|
|
124
|
+
if (!bot && botList.bots?.length) {
|
|
125
|
+
console.log(chalk.red(`\n ❌ Agent bulunamadı: ${botName}\n`));
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
config.botName = botName;
|
|
130
|
+
if (bot?.id) config.defaultBotId = bot.id;
|
|
131
|
+
saveConfig(config);
|
|
132
|
+
|
|
133
|
+
console.log(chalk.green(`\n ✓ Aktif agent: ${botName}\n`));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function agentInfo(botName) {
|
|
137
|
+
const config = getConfig();
|
|
138
|
+
const apiKey = config.providerApiKey || config.apiKey || '';
|
|
139
|
+
const name = botName || config.botName;
|
|
140
|
+
|
|
141
|
+
if (!name) {
|
|
142
|
+
F.error('Agent adı belirtin: natureco agents info <bot-adı>');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let botList = { bots: [] };
|
|
147
|
+
try {
|
|
148
|
+
botList = await getBots(apiKey);
|
|
149
|
+
} catch {}
|
|
150
|
+
|
|
151
|
+
const bot = botList.bots?.find(b => b.name === name || b.id === name);
|
|
152
|
+
|
|
153
|
+
F.header('Agent: ' + name);
|
|
154
|
+
|
|
155
|
+
if (bot) {
|
|
156
|
+
F.kv('ID', bot.id);
|
|
157
|
+
F.kv('Provider', bot.ai_provider || 'groq');
|
|
158
|
+
if (bot.model) F.kv('Model', bot.model);
|
|
159
|
+
if (bot.system_prompt) {
|
|
160
|
+
F.kv('Prompt', bot.system_prompt.slice(0, 80) + (bot.system_prompt.length > 80 ? '...' : ''));
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
F.meta('(Detay alınamadı)');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const { loadMemory } = require('../utils/memory');
|
|
168
|
+
const mem = loadMemory(bot?.id || 'universal-provider');
|
|
169
|
+
if (mem.name || mem.facts?.length) {
|
|
170
|
+
if (mem.name) F.kv('Kullanıcı', mem.name);
|
|
171
|
+
F.kv('Hafıza', (mem.facts || []).length + ' bilgi');
|
|
172
|
+
}
|
|
173
|
+
} catch {}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function addAgent() {
|
|
177
|
+
console.log('');
|
|
178
|
+
console.log(chalk.gray(' Yeni agent oluşturmak için Developers Portal\'ı kullanın:'));
|
|
179
|
+
console.log(chalk.cyan(' developers.natureco.me\n'));
|
|
180
|
+
console.log(chalk.gray(' Oluşturduktan sonra: ') + chalk.cyan('natureco agents list\n'));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ── Bindings ──────────────────────────────────────────────────────────────────
|
|
184
|
+
|
|
185
|
+
function listBindings() {
|
|
186
|
+
const bindings = loadBindings();
|
|
187
|
+
const keys = Object.keys(bindings);
|
|
188
|
+
|
|
189
|
+
F.section('Bindings (' + keys.length + ')');
|
|
190
|
+
|
|
191
|
+
if (keys.length === 0) {
|
|
192
|
+
F.meta('Henüz binding yok.');
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const items = [];
|
|
197
|
+
keys.forEach(agentId => {
|
|
198
|
+
bindings[agentId].forEach(ch => items.push(agentId + ' → ' + ch));
|
|
199
|
+
});
|
|
200
|
+
F.list(items);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function bindAgent(agentId, channel) {
|
|
204
|
+
if (!agentId || !channel) {
|
|
205
|
+
F.error('Kullanım: natureco agents bind <agentId> <channel>');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const bindings = loadBindings();
|
|
209
|
+
if (!bindings[agentId]) bindings[agentId] = [];
|
|
210
|
+
if (!bindings[agentId].includes(channel)) bindings[agentId].push(channel);
|
|
211
|
+
saveBindings(bindings);
|
|
212
|
+
F.success('Agent ' + agentId + ' → ' + channel + ' bağlandı');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function unbindAgent(agentId, channel) {
|
|
216
|
+
if (!agentId || !channel) {
|
|
217
|
+
F.error('Kullanım: natureco agents unbind <agentId> <channel>');
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const bindings = loadBindings();
|
|
221
|
+
if (!bindings[agentId]) {
|
|
222
|
+
F.warning('Agent ' + agentId + ' için binding bulunamadı');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
bindings[agentId] = bindings[agentId].filter(ch => ch !== channel);
|
|
226
|
+
if (bindings[agentId].length === 0) delete bindings[agentId];
|
|
227
|
+
saveBindings(bindings);
|
|
228
|
+
F.success('Agent ' + agentId + ' → ' + channel + ' bağlantısı kaldırıldı');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function setIdentity(agentId, identity) {
|
|
232
|
+
if (!agentId) {
|
|
233
|
+
F.error('Kullanım: natureco agents set-identity <agentId> <identity>');
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const identities = loadIdentities();
|
|
237
|
+
identities[agentId] = identity || 'default';
|
|
238
|
+
saveIdentities(identities);
|
|
239
|
+
F.success('Agent ' + agentId + ' identity: ' + (identity || 'default'));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
module.exports = agents;
|