natureco-cli 2.23.29 β 2.23.30
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/README.md +94 -11
- package/bin/natureco.js +402 -4
- package/package.json +1 -1
- package/src/commands/admin-rpc.js +219 -0
- package/src/commands/agent.js +89 -0
- package/src/commands/approvals.js +53 -0
- package/src/commands/backup.js +124 -0
- package/src/commands/bonjour.js +167 -0
- package/src/commands/capability.js +64 -0
- package/src/commands/clickclack.js +130 -0
- package/src/commands/commitments.js +32 -0
- package/src/commands/completion.js +76 -0
- package/src/commands/configure.js +93 -0
- package/src/commands/crestodian.js +92 -0
- package/src/commands/daemon.js +60 -0
- package/src/commands/device-pair.js +248 -0
- package/src/commands/devices.js +110 -0
- package/src/commands/directory.js +47 -0
- package/src/commands/dns.js +58 -0
- package/src/commands/docs.js +43 -0
- package/src/commands/exec-policy.js +71 -0
- package/src/commands/gateway-server.js +1155 -24
- package/src/commands/health.js +18 -0
- package/src/commands/imessage.js +128 -14
- package/src/commands/infer.js +73 -0
- package/src/commands/irc.js +64 -15
- package/src/commands/mattermost.js +114 -12
- package/src/commands/memory-cmd.js +134 -1
- package/src/commands/message.js +9 -3
- package/src/commands/migrate.js +213 -2
- package/src/commands/node.js +98 -0
- package/src/commands/nodes.js +106 -0
- package/src/commands/oc-path.js +200 -0
- package/src/commands/onboard.js +70 -0
- package/src/commands/open-prose.js +67 -0
- package/src/commands/policy.js +176 -0
- package/src/commands/proxy.js +155 -0
- package/src/commands/qr.js +28 -0
- package/src/commands/sandbox.js +125 -0
- package/src/commands/secrets.js +118 -0
- package/src/commands/setup.js +113 -7
- package/src/commands/signal.js +447 -18
- package/src/commands/sms.js +123 -19
- package/src/commands/system.js +53 -0
- package/src/commands/terminal.js +21 -0
- package/src/commands/thread-ownership.js +157 -0
- package/src/commands/transcripts.js +72 -0
- package/src/commands/voice.js +82 -0
- package/src/commands/vydra.js +98 -0
- package/src/commands/workboard.js +207 -0
- package/src/tools/audio_understanding.js +154 -0
- package/src/tools/browser.js +112 -0
- package/src/tools/canvas.js +104 -0
- package/src/tools/document_extract.js +84 -0
- package/src/tools/duckduckgo.js +54 -0
- package/src/tools/exa_search.js +66 -0
- package/src/tools/firecrawl.js +104 -0
- package/src/tools/image_generation.js +99 -0
- package/src/tools/llm_task.js +118 -0
- package/src/tools/media_understanding.js +128 -0
- package/src/tools/music_generation.js +113 -0
- package/src/tools/parallel_search.js +77 -0
- package/src/tools/phone_control.js +80 -0
- package/src/tools/phone_control_enhanced.js +184 -0
- package/src/tools/searxng.js +61 -0
- package/src/tools/speech_to_text.js +135 -0
- package/src/tools/text_to_speech.js +105 -0
- package/src/tools/thread_ownership.js +88 -0
- package/src/tools/video_generation.js +72 -0
- package/src/tools/web_readability.js +104 -0
- package/src/utils/memory.js +200 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
7
|
+
|
|
8
|
+
const PAIRING_FILE = path.join(os.homedir(), '.natureco', 'data', 'pairings.json');
|
|
9
|
+
|
|
10
|
+
function loadPairings() {
|
|
11
|
+
try {
|
|
12
|
+
if (fs.existsSync(PAIRING_FILE)) return JSON.parse(fs.readFileSync(PAIRING_FILE, 'utf8'));
|
|
13
|
+
} catch {}
|
|
14
|
+
return { pairedDevices: [], pendingRequests: [] };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function savePairings(data) {
|
|
18
|
+
const dir = path.dirname(PAIRING_FILE);
|
|
19
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
20
|
+
fs.writeFileSync(PAIRING_FILE, JSON.stringify(data, null, 2));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function generatePairingCode() {
|
|
24
|
+
return crypto.randomBytes(4).toString('hex').toUpperCase();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function devicePair(args) {
|
|
28
|
+
const [action, ...params] = args || [];
|
|
29
|
+
|
|
30
|
+
if (!action || action === 'list') return listDevices();
|
|
31
|
+
if (action === 'request') return requestPairing(params[0], params[1]);
|
|
32
|
+
if (action === 'approve') return approvePairing(params[0]);
|
|
33
|
+
if (action === 'reject') return rejectPairing(params[0]);
|
|
34
|
+
if (action === 'remove') return removeDevice(params[0]);
|
|
35
|
+
if (action === 'pairing-code') return showPairingCode();
|
|
36
|
+
if (action === 'verify') return verifyPairing(params[0], params[1]);
|
|
37
|
+
|
|
38
|
+
console.log(chalk.red(`\n β Bilinmeyen komut: ${action}\n`));
|
|
39
|
+
console.log(chalk.gray(' KullanΔ±m: natureco device-pair [list|request|approve|reject|remove|pairing-code|verify]\n'));
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function listDevices() {
|
|
44
|
+
const data = loadPairings();
|
|
45
|
+
|
|
46
|
+
console.log(chalk.cyan('\n π± Paired Devices\n'));
|
|
47
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
48
|
+
|
|
49
|
+
const devices = data.pairedDevices || [];
|
|
50
|
+
if (devices.length === 0) {
|
|
51
|
+
console.log(chalk.gray(' EΕleΕtirilmiΕ cihaz yok.\n'));
|
|
52
|
+
} else {
|
|
53
|
+
for (const d of devices) {
|
|
54
|
+
console.log(` ${chalk.green('β')} ${chalk.white(d.name || d.id)} ${chalk.gray(`(${d.type || 'unknown'})`)}`);
|
|
55
|
+
console.log(` ${chalk.gray('ID:')} ${d.id}`);
|
|
56
|
+
console.log(` ${chalk.gray('Since:')} ${d.pairedAt ? new Date(d.pairedAt).toLocaleString() : '-'}`);
|
|
57
|
+
console.log(` ${chalk.gray('Token:')} ${d.token ? d.token.substring(0, 8) + 'β¦' : '-'}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const pending = data.pendingRequests || [];
|
|
62
|
+
if (pending.length > 0) {
|
|
63
|
+
console.log(chalk.yellow(`\n β³ Bekleyen Δ°stekler (${pending.length})\n`));
|
|
64
|
+
for (const p of pending) {
|
|
65
|
+
console.log(` ${chalk.yellow('β')} ${chalk.white(p.name || p.id)} ${chalk.gray(`(${p.type || 'unknown'})`)}`);
|
|
66
|
+
console.log(` ${chalk.gray('Code:')} ${chalk.cyan(p.code)}`);
|
|
67
|
+
console.log(` ${chalk.gray('Since:')} ${p.requestedAt ? new Date(p.requestedAt).toLocaleString() : '-'}`);
|
|
68
|
+
}
|
|
69
|
+
console.log(chalk.gray('\n Onaylamak iΓ§in:'));
|
|
70
|
+
console.log(chalk.cyan(' natureco device-pair approve <code>'));
|
|
71
|
+
console.log(chalk.cyan(' natureco device-pair reject <code>'));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function requestPairing(deviceName, deviceType) {
|
|
78
|
+
const name = deviceName || `Device-${crypto.randomBytes(3).toString('hex')}`;
|
|
79
|
+
const type = deviceType || 'cli';
|
|
80
|
+
const code = generatePairingCode();
|
|
81
|
+
const id = `dev_${crypto.randomBytes(8).toString('hex')}`;
|
|
82
|
+
|
|
83
|
+
const data = loadPairings();
|
|
84
|
+
if (!data.pendingRequests) data.pendingRequests = [];
|
|
85
|
+
|
|
86
|
+
data.pendingRequests.push({
|
|
87
|
+
id,
|
|
88
|
+
name,
|
|
89
|
+
type,
|
|
90
|
+
code,
|
|
91
|
+
requestedAt: new Date().toISOString(),
|
|
92
|
+
expiresAt: new Date(Date.now() + 15 * 60 * 1000).toISOString()
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
savePairings(data);
|
|
96
|
+
|
|
97
|
+
console.log(chalk.cyan('\n π± Pairing Request\n'));
|
|
98
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
99
|
+
console.log(` ${chalk.white('Name:')} ${chalk.cyan(name)}`);
|
|
100
|
+
console.log(` ${chalk.white('Type:')} ${chalk.cyan(type)}`);
|
|
101
|
+
console.log(` ${chalk.white('Code:')} ${chalk.yellow(code)}`);
|
|
102
|
+
console.log(` ${chalk.white('ID:')} ${chalk.gray(id)}`);
|
|
103
|
+
console.log(chalk.gray(`\n Pairing code expires: ${new Date(Date.now() + 15 * 60 * 1000).toLocaleString()}`));
|
|
104
|
+
console.log(chalk.gray('\n On another terminal:'));
|
|
105
|
+
console.log(chalk.cyan(` natureco device-pair approve ${code}`));
|
|
106
|
+
console.log(chalk.cyan(` natureco device-pair reject ${code}`));
|
|
107
|
+
console.log();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function approvePairing(code) {
|
|
111
|
+
if (!code) {
|
|
112
|
+
console.log(chalk.red('\n β Pairing code gerekli\n'));
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const data = loadPairings();
|
|
117
|
+
const idx = (data.pendingRequests || []).findIndex(p => p.code === code);
|
|
118
|
+
|
|
119
|
+
if (idx === -1) {
|
|
120
|
+
console.log(chalk.red(`\n β GeΓ§ersiz pairing code: ${code}\n`));
|
|
121
|
+
console.log(chalk.gray(' Bekleyen istekleri gΓΆrmek iΓ§in: natureco device-pair list\n'));
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const request = data.pendingRequests[idx];
|
|
126
|
+
const token = `nc_${crypto.randomBytes(16).toString('hex')}`;
|
|
127
|
+
|
|
128
|
+
if (!data.pairedDevices) data.pairedDevices = [];
|
|
129
|
+
data.pairedDevices.push({
|
|
130
|
+
id: request.id,
|
|
131
|
+
name: request.name,
|
|
132
|
+
type: request.type,
|
|
133
|
+
token,
|
|
134
|
+
pairedAt: new Date().toISOString()
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
data.pendingRequests.splice(idx, 1);
|
|
138
|
+
savePairings(data);
|
|
139
|
+
|
|
140
|
+
console.log(chalk.green(`\n β
Paired: ${request.name}\n`));
|
|
141
|
+
console.log(chalk.gray(` Device ID: ${request.id}`));
|
|
142
|
+
console.log(chalk.gray(` Token: ${token}\n`));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function rejectPairing(code) {
|
|
146
|
+
if (!code) {
|
|
147
|
+
console.log(chalk.red('\n β Pairing code gerekli\n'));
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const data = loadPairings();
|
|
152
|
+
const idx = (data.pendingRequests || []).findIndex(p => p.code === code);
|
|
153
|
+
|
|
154
|
+
if (idx === -1) {
|
|
155
|
+
console.log(chalk.red(`\n β GeΓ§ersiz pairing code: ${code}\n`));
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const request = data.pendingRequests[idx];
|
|
160
|
+
data.pendingRequests.splice(idx, 1);
|
|
161
|
+
savePairings(data);
|
|
162
|
+
|
|
163
|
+
console.log(chalk.gray(`\n π΄ Rejected: ${request.name}\n`));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function removeDevice(deviceId) {
|
|
167
|
+
if (!deviceId) {
|
|
168
|
+
console.log(chalk.red('\n β Device ID gerekli\n'));
|
|
169
|
+
console.log(chalk.cyan(' natureco device-pair remove dev_abc123\n'));
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const data = loadPairings();
|
|
174
|
+
const idx = (data.pairedDevices || []).findIndex(d => d.id === deviceId);
|
|
175
|
+
|
|
176
|
+
if (idx === -1) {
|
|
177
|
+
console.log(chalk.red(`\n β Cihaz bulunamadΔ±: ${deviceId}\n`));
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const device = data.pairedDevices[idx];
|
|
182
|
+
data.pairedDevices.splice(idx, 1);
|
|
183
|
+
savePairings(data);
|
|
184
|
+
|
|
185
|
+
console.log(chalk.gray(`\n ποΈ Removed: ${device.name} (${deviceId})\n`));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function showPairingCode() {
|
|
189
|
+
const code = generatePairingCode();
|
|
190
|
+
const expiresAt = new Date(Date.now() + 15 * 60 * 1000);
|
|
191
|
+
|
|
192
|
+
console.log(chalk.cyan('\n π Pairing Code\n'));
|
|
193
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
194
|
+
console.log(` Code: ${chalk.bold.yellow(code)}`);
|
|
195
|
+
console.log(` Expires: ${chalk.gray(expiresAt.toLocaleString())}`);
|
|
196
|
+
console.log(chalk.gray('\n Share this code with the device to pair.\n'));
|
|
197
|
+
console.log(chalk.gray(' On the other device:'));
|
|
198
|
+
console.log(chalk.cyan(` natureco device-pair verify ${code} <device-name>\n`));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function verifyPairing(code, deviceName) {
|
|
202
|
+
if (!code) {
|
|
203
|
+
console.log(chalk.red('\n β Pairing code gerekli\n'));
|
|
204
|
+
process.exit(1);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const data = loadPairings();
|
|
208
|
+
const pending = data.pendingRequests || [];
|
|
209
|
+
|
|
210
|
+
if (pending.some(p => p.code === code)) {
|
|
211
|
+
console.log(chalk.green('\n β
Pairing code valid β awaiting approval\n'));
|
|
212
|
+
console.log(chalk.gray(' Ask the admin to run:'));
|
|
213
|
+
console.log(chalk.cyan(` natureco device-pair approve ${code}\n`));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const paired = data.pairedDevices || [];
|
|
218
|
+
const matched = paired.find(d => {
|
|
219
|
+
const cfg = getConfig();
|
|
220
|
+
return cfg.pairingToken && d.token === cfg.pairingToken;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
if (matched) {
|
|
224
|
+
console.log(chalk.green(`\n β
Already paired as: ${matched.name}\n`));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const name = deviceName || `Device-${crypto.randomBytes(3).toString('hex')}`;
|
|
229
|
+
const newId = `dev_${crypto.randomBytes(8).toString('hex')}`;
|
|
230
|
+
|
|
231
|
+
if (!data.pendingRequests) data.pendingRequests = [];
|
|
232
|
+
data.pendingRequests.push({
|
|
233
|
+
id: newId,
|
|
234
|
+
name,
|
|
235
|
+
type: 'cli',
|
|
236
|
+
code,
|
|
237
|
+
requestedAt: new Date().toISOString(),
|
|
238
|
+
expiresAt: new Date(Date.now() + 15 * 60 * 1000).toISOString()
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
savePairings(data);
|
|
242
|
+
|
|
243
|
+
console.log(chalk.yellow(`\n β³ Pairing requested for "${name}" with code ${code}\n`));
|
|
244
|
+
console.log(chalk.gray(' Admin should approve with:'));
|
|
245
|
+
console.log(chalk.cyan(` natureco device-pair approve ${code}\n`));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
module.exports = devicePair;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
function devices(args) {
|
|
7
|
+
const [action, ...params] = args || [];
|
|
8
|
+
|
|
9
|
+
if (!action || action === 'list') return listDevices();
|
|
10
|
+
if (action === 'pair') return pairDevice(params[0], params[1]);
|
|
11
|
+
if (action === 'unpair') return unpairDevice(params[0]);
|
|
12
|
+
if (action === 'token' || action === 'show-token') return showToken();
|
|
13
|
+
if (action === 'regenerate-token') return regenerateToken();
|
|
14
|
+
|
|
15
|
+
console.log(chalk.red(`\n β Bilinmeyen komut: ${action}\n`));
|
|
16
|
+
console.log(chalk.gray(' KullanΔ±m: natureco devices [list|pair|unpair|token|regenerate-token]\n'));
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function listDevices() {
|
|
21
|
+
const config = getConfig();
|
|
22
|
+
const devices = config.pairedDevices || [];
|
|
23
|
+
|
|
24
|
+
console.log(chalk.cyan('\n π± Devices\n'));
|
|
25
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
26
|
+
|
|
27
|
+
if (devices.length === 0) {
|
|
28
|
+
console.log(chalk.gray(' No paired devices.\n'));
|
|
29
|
+
console.log(chalk.gray(' Pair a device:'));
|
|
30
|
+
console.log(chalk.cyan(' natureco devices pair <name> <type>\n'));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const d of devices) {
|
|
35
|
+
console.log(` ${chalk.green('β')} ${chalk.white(d.name)} ${chalk.gray(`(${d.type || 'unknown'})`)}`);
|
|
36
|
+
console.log(` ${chalk.gray('ID:')} ${chalk.cyan(d.id)}`);
|
|
37
|
+
console.log(` ${chalk.gray('Since:')} ${d.pairedAt ? new Date(d.pairedAt).toLocaleString() : '-'}`);
|
|
38
|
+
}
|
|
39
|
+
console.log();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function pairDevice(name, type) {
|
|
43
|
+
if (!name) {
|
|
44
|
+
console.log(chalk.red('\n β Device name gerekli\n'));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const config = getConfig();
|
|
49
|
+
if (!config.pairedDevices) config.pairedDevices = [];
|
|
50
|
+
|
|
51
|
+
const device = {
|
|
52
|
+
id: `dev_${crypto.randomBytes(8).toString('hex')}`,
|
|
53
|
+
name,
|
|
54
|
+
type: type || 'unknown',
|
|
55
|
+
token: crypto.randomBytes(16).toString('hex'),
|
|
56
|
+
pairedAt: new Date().toISOString()
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
config.pairedDevices.push(device);
|
|
60
|
+
saveConfig(config);
|
|
61
|
+
|
|
62
|
+
console.log(chalk.green(`\n β
Paired: ${name}\n`));
|
|
63
|
+
console.log(chalk.gray(` Device ID: ${device.id}`));
|
|
64
|
+
console.log(chalk.gray(` Token: ${device.token}\n`));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function unpairDevice(id) {
|
|
68
|
+
if (!id) {
|
|
69
|
+
console.log(chalk.red('\n β Device ID gerekli\n'));
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const config = getConfig();
|
|
74
|
+
const devices = config.pairedDevices || [];
|
|
75
|
+
const idx = devices.findIndex(d => d.id === id);
|
|
76
|
+
|
|
77
|
+
if (idx === -1) {
|
|
78
|
+
console.log(chalk.red(`\n β Cihaz bulunamadΔ±: ${id}\n`));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const removed = devices.splice(idx, 1)[0];
|
|
83
|
+
config.pairedDevices = devices;
|
|
84
|
+
saveConfig(config);
|
|
85
|
+
|
|
86
|
+
console.log(chalk.gray(`\n ποΈ Unpaired: ${removed.name}\n`));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function showToken() {
|
|
90
|
+
const config = getConfig();
|
|
91
|
+
const token = config.pairingToken || 'not-set';
|
|
92
|
+
|
|
93
|
+
console.log(chalk.cyan('\n π Device Token\n'));
|
|
94
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
95
|
+
console.log(` Token: ${chalk.yellow(token)}`);
|
|
96
|
+
console.log(chalk.gray('\n This token identifies this device for pairing.\n'));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function regenerateToken() {
|
|
100
|
+
const config = getConfig();
|
|
101
|
+
config.pairingToken = `nc_${crypto.randomBytes(16).toString('hex')}`;
|
|
102
|
+
saveConfig(config);
|
|
103
|
+
|
|
104
|
+
console.log(chalk.green('\n β
Token regenerated\n'));
|
|
105
|
+
console.log(chalk.gray(` New token: ${chalk.yellow(config.pairingToken)}\n`));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const crypto = require('crypto');
|
|
109
|
+
|
|
110
|
+
module.exports = devices;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const { getConfig } = require('../utils/config');
|
|
3
|
+
|
|
4
|
+
function directory(args) {
|
|
5
|
+
const [action, ...params] = args || [];
|
|
6
|
+
|
|
7
|
+
if (!action || action === 'self') return showSelf();
|
|
8
|
+
if (action === 'channels' || action === 'peers') return listChannels();
|
|
9
|
+
|
|
10
|
+
console.log(chalk.red(`\n β Bilinmeyen komut: ${action}\n`));
|
|
11
|
+
console.log(chalk.gray(' KullanΔ±m: natureco directory [self|channels]\n'));
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function showSelf() {
|
|
16
|
+
const config = getConfig();
|
|
17
|
+
console.log(chalk.cyan('\n π€ Self\n'));
|
|
18
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
19
|
+
console.log(` ${chalk.white('Name:')} ${chalk.cyan(config.agentName || process.env.USER || 'user')}`);
|
|
20
|
+
console.log(` ${chalk.white('Gateway:')} ${chalk.gray(config.gatewayUrl || 'not configured')}`);
|
|
21
|
+
console.log(` ${chalk.white('Provider:')} ${chalk.gray(config.provider || 'not set')}`);
|
|
22
|
+
console.log(` ${chalk.white('Model:')} ${chalk.gray(config.model || 'not set')}`);
|
|
23
|
+
console.log(` ${chalk.white('User ID:')} ${chalk.gray(config.userId || 'local')}`);
|
|
24
|
+
console.log();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function listChannels() {
|
|
28
|
+
const config = getConfig();
|
|
29
|
+
console.log(chalk.cyan('\n π‘ Channels\n'));
|
|
30
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
31
|
+
|
|
32
|
+
const channels = ['telegram', 'whatsapp', 'discord', 'slack', 'signal', 'irc', 'mattermost', 'imessage', 'sms'];
|
|
33
|
+
let found = false;
|
|
34
|
+
|
|
35
|
+
for (const ch of channels) {
|
|
36
|
+
if (config[ch]) {
|
|
37
|
+
const info = typeof config[ch] === 'object' ? Object.keys(config[ch]).join(', ') : 'connected';
|
|
38
|
+
console.log(` ${chalk.green('β')} ${chalk.white(ch)}: ${chalk.gray(info)}`);
|
|
39
|
+
found = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!found) console.log(chalk.gray(' No channels configured.\n'));
|
|
44
|
+
console.log();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = directory;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const dns = require('dns');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
function dnsCmd(args) {
|
|
6
|
+
const [action, ...params] = args || [];
|
|
7
|
+
|
|
8
|
+
if (!action || action === 'discover') return discoverNetwork();
|
|
9
|
+
if (action === 'resolve') return resolveHost(params[0]);
|
|
10
|
+
|
|
11
|
+
console.log(chalk.red(`\n β Bilinmeyen komut: ${action}\n`));
|
|
12
|
+
console.log(chalk.gray(' KullanΔ±m: natureco dns [discover|resolve]\n'));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function discoverNetwork() {
|
|
17
|
+
console.log(chalk.cyan('\n π Network Discovery (DNS)\n'));
|
|
18
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
19
|
+
|
|
20
|
+
const interfaces = os.networkInterfaces();
|
|
21
|
+
for (const [name, addrs] of Object.entries(interfaces)) {
|
|
22
|
+
if (!addrs) continue;
|
|
23
|
+
for (const addr of addrs) {
|
|
24
|
+
if (addr.family === 'IPv4' && !addr.internal) {
|
|
25
|
+
console.log(` ${chalk.white(name)}`);
|
|
26
|
+
console.log(` ${chalk.gray('IP:')} ${addr.address}`);
|
|
27
|
+
console.log(` ${chalk.gray('MAC:')} ${addr.mac}`);
|
|
28
|
+
console.log(` ${chalk.gray('Mask:')} ${addr.netmask}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(chalk.gray('\n Service discovery for wide-area (Tailscale + CoreDNS).'));
|
|
34
|
+
console.log(chalk.gray(' For full mDNS: ') + chalk.cyan('natureco bonjour scan\n'));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function resolveHost(hostname) {
|
|
38
|
+
if (!hostname) {
|
|
39
|
+
console.log(chalk.red('\n β Hostname gerekli\n'));
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(chalk.cyan(`\n π Resolving: ${hostname}\n`));
|
|
44
|
+
|
|
45
|
+
dns.resolve4(hostname, (err, addresses) => {
|
|
46
|
+
if (err) {
|
|
47
|
+
console.log(chalk.red(` β ${err.message}\n`));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
51
|
+
for (const addr of addresses) {
|
|
52
|
+
console.log(` ${chalk.white(hostname)} β ${chalk.cyan(addr)}`);
|
|
53
|
+
}
|
|
54
|
+
console.log();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = dnsCmd;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
async function docs(args) {
|
|
4
|
+
const query = args.join(' ').trim();
|
|
5
|
+
|
|
6
|
+
if (!query) {
|
|
7
|
+
console.log(chalk.cyan('\n π NatureCo Docs Search\n'));
|
|
8
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
9
|
+
console.log(chalk.gray(' Search live documentation from the web.\n'));
|
|
10
|
+
console.log(chalk.gray(' Usage:'));
|
|
11
|
+
console.log(chalk.cyan(' natureco docs <search query>'));
|
|
12
|
+
console.log(chalk.gray('\n Examples:'));
|
|
13
|
+
console.log(chalk.gray(' natureco docs how to setup gateway'));
|
|
14
|
+
console.log(chalk.gray(' natureco docs channels telegram'));
|
|
15
|
+
console.log();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
console.log(chalk.cyan(`\n π Searching docs for: "${query}"\n`));
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const response = await fetch(`https://api.duckduckgo.com/?q=${encodeURIComponent('natureco ' + query)}&format=json&no_html=1`, {
|
|
23
|
+
headers: { 'User-Agent': 'NatureCo-CLI/2.0' }
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (!response.ok) throw new Error(`Search error: ${response.status}`);
|
|
27
|
+
|
|
28
|
+
const data = await response.json();
|
|
29
|
+
if (data.AbstractText) {
|
|
30
|
+
console.log(chalk.white(data.AbstractText));
|
|
31
|
+
if (data.AbstractURL) console.log(chalk.gray(`\n Source: ${data.AbstractURL}`));
|
|
32
|
+
} else {
|
|
33
|
+
console.log(chalk.gray(' No documentation found for this query.'));
|
|
34
|
+
console.log(chalk.gray('\n Try searching the web:'));
|
|
35
|
+
console.log(chalk.cyan(` natureco web_search query="${query}"`));
|
|
36
|
+
}
|
|
37
|
+
console.log();
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.log(chalk.red(` β ${err.message}\n`));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = docs;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
3
|
+
|
|
4
|
+
function execPolicy(args) {
|
|
5
|
+
const [action, ...params] = args || [];
|
|
6
|
+
|
|
7
|
+
if (!action || action === 'show') return showPolicy();
|
|
8
|
+
if (action === 'set') return setPolicy(params[0]);
|
|
9
|
+
if (action === 'sync') return syncPolicy();
|
|
10
|
+
|
|
11
|
+
console.log(chalk.red(`\n β Bilinmeyen komut: ${action}\n`));
|
|
12
|
+
console.log(chalk.gray(' KullanΔ±m: natureco exec-policy [show|set|sync]\n'));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function showPolicy() {
|
|
17
|
+
const config = getConfig();
|
|
18
|
+
const policy = config.execPolicy || 'default';
|
|
19
|
+
|
|
20
|
+
console.log(chalk.cyan('\n π Exec Policy\n'));
|
|
21
|
+
console.log(chalk.gray(' ' + 'β'.repeat(48)));
|
|
22
|
+
console.log(` ${chalk.white('Policy:')} ${chalk.cyan(policy)}`);
|
|
23
|
+
console.log(` ${chalk.white('Allow commands:')} ${chalk.gray(config.execAllowCommands !== false ? 'Yes' : 'No')}`);
|
|
24
|
+
console.log(` ${chalk.white('Timeout:')} ${chalk.gray(config.execTimeout || 30000)}ms`);
|
|
25
|
+
console.log(` ${chalk.white('Sandbox:')} ${chalk.gray(config.execSandbox || 'none')}`);
|
|
26
|
+
console.log();
|
|
27
|
+
console.log(chalk.gray(' Set policy:'));
|
|
28
|
+
console.log(chalk.cyan(' natureco exec-policy set <policy>'));
|
|
29
|
+
console.log(chalk.cyan(' natureco exec-policy sync\n'));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function setPolicy(policy) {
|
|
33
|
+
if (!policy) {
|
|
34
|
+
console.log(chalk.red('\n β Policy gerekli\n'));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const config = getConfig();
|
|
39
|
+
config.execPolicy = policy;
|
|
40
|
+
saveConfig(config);
|
|
41
|
+
console.log(chalk.green(`\n β
Exec policy: ${policy}\n`));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function syncPolicy() {
|
|
45
|
+
const config = getConfig();
|
|
46
|
+
console.log(chalk.cyan('\n π Syncing exec policy...\n'));
|
|
47
|
+
|
|
48
|
+
const defaults = {
|
|
49
|
+
execPolicy: 'default',
|
|
50
|
+
execAllowCommands: true,
|
|
51
|
+
execTimeout: 30000,
|
|
52
|
+
execSandbox: 'none'
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let changed = 0;
|
|
56
|
+
for (const [key, val] of Object.entries(defaults)) {
|
|
57
|
+
if (config[key] === undefined) {
|
|
58
|
+
config[key] = val;
|
|
59
|
+
changed++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (changed > 0) {
|
|
64
|
+
saveConfig(config);
|
|
65
|
+
console.log(chalk.green(` β
Synced ${changed} policy settings\n`));
|
|
66
|
+
} else {
|
|
67
|
+
console.log(chalk.gray(' β
Already in sync\n'));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = execPolicy;
|