natureco-cli 2.23.30 → 2.23.32
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/bin/natureco.js +178 -167
- package/package.json +1 -1
- package/src/commands/acp.js +39 -0
- package/src/commands/admin-rpc.js +83 -0
- package/src/commands/agent.js +214 -23
- package/src/commands/agents.js +114 -30
- package/src/commands/approvals.js +172 -11
- package/src/commands/ask.js +1 -1
- package/src/commands/browser.js +815 -0
- package/src/commands/capability.js +195 -22
- package/src/commands/channels.js +422 -267
- package/src/commands/chat.js +5 -8
- package/src/commands/clawbot.js +19 -0
- package/src/commands/code.js +3 -2
- package/src/commands/commitments.js +125 -9
- package/src/commands/completion.js +40 -32
- package/src/commands/config.js +228 -30
- package/src/commands/configure.js +84 -67
- package/src/commands/cron.js +239 -19
- package/src/commands/daemon.js +34 -4
- package/src/commands/dashboard.js +47 -374
- package/src/commands/devices.js +53 -26
- package/src/commands/directory.js +146 -14
- package/src/commands/dns.js +148 -10
- package/src/commands/docs.js +119 -26
- package/src/commands/doctor.js +143 -492
- package/src/commands/exec-policy.js +57 -48
- package/src/commands/gateway.js +492 -249
- package/src/commands/health.js +141 -11
- package/src/commands/help.js +24 -25
- package/src/commands/hooks.js +141 -87
- package/src/commands/infer.js +1442 -41
- package/src/commands/logs.js +122 -99
- package/src/commands/mcp.js +121 -309
- package/src/commands/memory.js +128 -0
- package/src/commands/message.js +720 -140
- package/src/commands/models.js +39 -1
- package/src/commands/node.js +77 -77
- package/src/commands/nodes.js +278 -22
- package/src/commands/onboard.js +115 -56
- package/src/commands/pairing.js +108 -107
- package/src/commands/path.js +206 -0
- package/src/commands/plugins.js +35 -1
- package/src/commands/proxy.js +159 -8
- package/src/commands/qr.js +55 -13
- package/src/commands/reset.js +101 -94
- package/src/commands/secrets.js +104 -21
- package/src/commands/sessions.js +110 -51
- package/src/commands/setup.js +229 -649
- package/src/commands/skills.js +67 -1
- package/src/commands/status.js +101 -127
- package/src/commands/tasks.js +208 -100
- package/src/commands/terminal.js +130 -12
- package/src/commands/transcripts.js +24 -1
- package/src/commands/tui.js +41 -0
- package/src/commands/uninstall.js +73 -92
- package/src/commands/update.js +146 -91
- package/src/commands/web-fetch.js +34 -0
- package/src/commands/webhooks.js +58 -66
- package/src/commands/wiki.js +783 -0
- package/src/utils/agents-md.js +85 -0
- package/src/utils/api.js +40 -41
- package/src/utils/format.js +144 -0
- package/src/utils/headless.js +2 -1
- package/src/utils/parallel-tools.js +106 -0
- package/src/utils/sub-agent.js +148 -0
- package/src/utils/token-budget.js +304 -0
- package/src/utils/tool-runner.js +7 -5
- package/src/utils/web-fetch.js +107 -0
|
@@ -1,92 +1,73 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
console.log('');
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.log(chalk.green(' ✓ Dashboard durduruldu'));
|
|
75
|
-
} catch {}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// --all ise tüm veriyi sil
|
|
79
|
-
if (all && fs.existsSync(CONFIG_DIR)) {
|
|
80
|
-
fs.rmSync(CONFIG_DIR, { recursive: true, force: true });
|
|
81
|
-
console.log(chalk.green(' ✓ ~/.natureco/ silindi'));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log('');
|
|
85
|
-
console.log(chalk.green(' ✓ Temizlik tamamlandı!'));
|
|
86
|
-
console.log('');
|
|
87
|
-
console.log(chalk.gray(' CLI\'yi tamamen kaldırmak için:'));
|
|
88
|
-
console.log(chalk.cyan(' npm uninstall -g natureco-cli'));
|
|
89
|
-
console.log('');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
module.exports = uninstall;
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
const readline = require('readline');
|
|
7
|
+
|
|
8
|
+
const BASE_DIR = path.join(os.homedir(), '.natureco');
|
|
9
|
+
|
|
10
|
+
function rlQuestion(query) {
|
|
11
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
12
|
+
return new Promise(resolve => {
|
|
13
|
+
rl.question(query, answer => { rl.close(); resolve(answer.trim().toLowerCase()); });
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function uninstall(params) {
|
|
18
|
+
try {
|
|
19
|
+
const [action] = params || [];
|
|
20
|
+
|
|
21
|
+
if (action === 'dry-run') return cmdDryRun();
|
|
22
|
+
|
|
23
|
+
if (!action || action === 'run') return await cmdRun();
|
|
24
|
+
|
|
25
|
+
console.log(chalk.red(`\n Unknown uninstall action: ${action}\n`));
|
|
26
|
+
console.log(chalk.gray(' Usage: natureco uninstall [run|dry-run]\n'));
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.log(chalk.red(`\n Uninstall error: ${err.message}\n`));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function cmdDryRun() {
|
|
33
|
+
console.log(chalk.cyan('\n Uninstall — Dry Run\n'));
|
|
34
|
+
console.log(chalk.gray(' Would remove:\n'));
|
|
35
|
+
|
|
36
|
+
if (fs.existsSync(BASE_DIR)) {
|
|
37
|
+
console.log(chalk.gray(' • ') + chalk.white('~/.natureco/') + chalk.gray(' — all config and data'));
|
|
38
|
+
} else {
|
|
39
|
+
console.log(chalk.gray(' • ') + chalk.white('~/.natureco/') + chalk.gray(' — not found'));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log(chalk.gray(' • ') + chalk.white('npm uninstall -g natureco-cli'));
|
|
43
|
+
console.log(chalk.gray(' • ') + chalk.white('Remove global symlink\n'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function cmdRun() {
|
|
47
|
+
console.log(chalk.cyan('\n Uninstall NatureCo\n'));
|
|
48
|
+
|
|
49
|
+
const answer = await rlQuestion(chalk.red(' This will remove all NatureCo data. Continue? [y/N]: '));
|
|
50
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
51
|
+
console.log(chalk.gray('\n Cancelled.\n'));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (fs.existsSync(BASE_DIR)) {
|
|
56
|
+
console.log(chalk.gray(' Removing ~/.natureco/...'));
|
|
57
|
+
fs.rmSync(BASE_DIR, { recursive: true, force: true });
|
|
58
|
+
console.log(chalk.green(' ✓ Removed ~/.natureco/'));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log(chalk.gray(' Uninstalling global package...'));
|
|
62
|
+
try {
|
|
63
|
+
execSync('npm uninstall -g natureco-cli', { stdio: 'inherit' });
|
|
64
|
+
console.log(chalk.green(' ✓ Global package uninstalled'));
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.log(chalk.yellow(' Could not uninstall package: ' + e.message));
|
|
67
|
+
console.log(chalk.gray(' Try manually: npm uninstall -g natureco-cli'));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(chalk.green('\n Uninstall complete.\n'));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = uninstall;
|
package/src/commands/update.js
CHANGED
|
@@ -1,91 +1,146 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.log(chalk.
|
|
74
|
-
|
|
75
|
-
console.log('');
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
const readline = require('readline');
|
|
7
|
+
|
|
8
|
+
const VERSION_FILE = path.join(os.homedir(), '.natureco', 'version.json');
|
|
9
|
+
|
|
10
|
+
function rlQuestion(query) {
|
|
11
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
12
|
+
return new Promise(resolve => {
|
|
13
|
+
rl.question(query, answer => { rl.close(); resolve(answer.trim().toLowerCase()); });
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function loadVersion() {
|
|
18
|
+
if (!fs.existsSync(VERSION_FILE)) return { installed: null, checked: null };
|
|
19
|
+
try { return JSON.parse(fs.readFileSync(VERSION_FILE, 'utf8')); }
|
|
20
|
+
catch { return { installed: null, checked: null }; }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function saveVersion(data) {
|
|
24
|
+
const dir = path.dirname(VERSION_FILE);
|
|
25
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
26
|
+
fs.writeFileSync(VERSION_FILE, JSON.stringify(data, null, 2), 'utf8');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getCurrentVersion() {
|
|
30
|
+
try {
|
|
31
|
+
const pkg = require('../../package.json');
|
|
32
|
+
return pkg.version;
|
|
33
|
+
} catch {
|
|
34
|
+
return '0.0.0';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getLatestVersion() {
|
|
39
|
+
try {
|
|
40
|
+
const result = execSync('npm view natureco-cli version', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
41
|
+
return result.trim();
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function update(params) {
|
|
48
|
+
try {
|
|
49
|
+
const [action] = params || [];
|
|
50
|
+
|
|
51
|
+
if (!action || action === 'status') return cmdStatus();
|
|
52
|
+
if (action === 'run') return await cmdRun();
|
|
53
|
+
if (action === 'wizard') return await cmdWizard();
|
|
54
|
+
|
|
55
|
+
console.log(chalk.red(`\n Unknown update action: ${action}\n`));
|
|
56
|
+
console.log(chalk.gray(' Usage: natureco update [run|status|wizard]\n'));
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.log(chalk.red(`\n Update error: ${err.message}\n`));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function cmdStatus() {
|
|
63
|
+
const current = getCurrentVersion();
|
|
64
|
+
const latest = getLatestVersion();
|
|
65
|
+
const ver = loadVersion();
|
|
66
|
+
|
|
67
|
+
console.log(chalk.cyan('\n Update Status\n'));
|
|
68
|
+
console.log(chalk.white(' Installed: ') + chalk.cyan('v' + current));
|
|
69
|
+
|
|
70
|
+
if (latest) {
|
|
71
|
+
console.log(chalk.white(' Latest: ') + chalk.cyan('v' + latest));
|
|
72
|
+
if (current === latest) {
|
|
73
|
+
console.log(chalk.green(' ✓ You are up to date.\n'));
|
|
74
|
+
} else {
|
|
75
|
+
console.log(chalk.yellow(' Update available: v' + current + ' → v' + latest + '\n'));
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
console.log(chalk.gray(' Could not check latest version.\n'));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
saveVersion({ installed: current, checked: new Date().toISOString(), latest: latest || ver.latest });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function cmdRun() {
|
|
85
|
+
const current = getCurrentVersion();
|
|
86
|
+
const latest = getLatestVersion();
|
|
87
|
+
|
|
88
|
+
if (!latest) {
|
|
89
|
+
console.log(chalk.yellow('\n Could not fetch latest version. Check your internet connection.\n'));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (current === latest) {
|
|
94
|
+
console.log(chalk.green('\n Already up to date (v' + current + ').\n'));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
console.log(chalk.cyan('\n Updating: v' + current + ' → v' + latest + '\n'));
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
execSync('npm update -g natureco-cli', { stdio: 'inherit' });
|
|
102
|
+
saveVersion({ installed: latest, updated: new Date().toISOString(), latest });
|
|
103
|
+
console.log(chalk.green('\n ✓ Updated to v' + latest + '\n'));
|
|
104
|
+
} catch (e) {
|
|
105
|
+
console.log(chalk.red('\n Update failed: ' + e.message + '\n'));
|
|
106
|
+
console.log(chalk.gray(' Try: npm install -g natureco-cli@latest\n'));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function cmdWizard() {
|
|
111
|
+
const current = getCurrentVersion();
|
|
112
|
+
const latest = getLatestVersion();
|
|
113
|
+
|
|
114
|
+
console.log(chalk.cyan('\n Update Wizard\n'));
|
|
115
|
+
|
|
116
|
+
if (!latest) {
|
|
117
|
+
console.log(chalk.yellow(' Could not check for updates.\n'));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
console.log(chalk.white(' Current: v' + current));
|
|
122
|
+
console.log(chalk.white(' Latest: v' + latest));
|
|
123
|
+
|
|
124
|
+
if (current === latest) {
|
|
125
|
+
console.log(chalk.green('\n You are up to date!\n'));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const answer = await rlQuestion(chalk.yellow(' Update to v' + latest + '? [Y/n]: '));
|
|
130
|
+
if (answer === 'n' || answer === 'no') {
|
|
131
|
+
console.log(chalk.gray('\n Skipped.\n'));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.log(chalk.gray('\n Installing...\n'));
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
execSync('npm install -g natureco-cli@latest', { stdio: 'inherit' });
|
|
139
|
+
saveVersion({ installed: latest, updated: new Date().toISOString(), latest });
|
|
140
|
+
console.log(chalk.green('\n ✓ Updated to v' + latest + '\n'));
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.log(chalk.red('\n Update failed: ' + e.message + '\n'));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
module.exports = update;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { fetchAsMarkdown } = require('../utils/web-fetch');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
|
|
4
|
+
async function webFetch(url) {
|
|
5
|
+
if (!url) {
|
|
6
|
+
console.log(chalk.yellow('\n Usage: natureco web-fetch <url>\n'));
|
|
7
|
+
console.log(chalk.gray(' Fetches a URL and converts it to clean markdown.\n'));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
console.log(chalk.gray(` Fetching: ${url}\n`));
|
|
12
|
+
|
|
13
|
+
const result = await fetchAsMarkdown(url);
|
|
14
|
+
|
|
15
|
+
if (result.error) {
|
|
16
|
+
console.log(chalk.red(` ❌ ${result.error}\n`));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (result.title) {
|
|
21
|
+
console.log(chalk.white(' Title: ') + chalk.cyan(result.title));
|
|
22
|
+
}
|
|
23
|
+
console.log(chalk.gray(` Source: ${result.url}`));
|
|
24
|
+
console.log(chalk.gray(` Fetched: ${result.fetchedAt}`));
|
|
25
|
+
console.log('');
|
|
26
|
+
|
|
27
|
+
if (result.content) {
|
|
28
|
+
console.log(result.content);
|
|
29
|
+
} else {
|
|
30
|
+
console.log(chalk.yellow(' No content extracted.\n'));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = webFetch;
|
package/src/commands/webhooks.js
CHANGED
|
@@ -1,79 +1,71 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
console.log(chalk.gray('Available actions: connect, disconnect, status, list\n'));
|
|
12
|
-
process.exit(1);
|
|
6
|
+
const WEBHOOKS_FILE = path.join(os.homedir(), '.natureco', 'webhooks.json');
|
|
7
|
+
|
|
8
|
+
function loadWebhooks() {
|
|
9
|
+
if (!fs.existsSync(WEBHOOKS_FILE)) return [];
|
|
10
|
+
try { return JSON.parse(fs.readFileSync(WEBHOOKS_FILE, 'utf8')); }
|
|
11
|
+
catch { return []; }
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
webhooks.push(entry);
|
|
34
|
-
config.webhooks = webhooks;
|
|
35
|
-
config.webhookEnabled = true;
|
|
36
|
-
saveConfig(config);
|
|
37
|
-
console.log(chalk.green('\n✅ Webhook eklendi!\n'));
|
|
38
|
-
console.log(chalk.cyan('ID:'), chalk.white(entry.id));
|
|
39
|
-
console.log(chalk.cyan('İsim:'), chalk.white(entry.name));
|
|
40
|
-
console.log(chalk.cyan('Yol:'), chalk.white(entry.path));
|
|
41
|
-
console.log(chalk.gray('\nGateway ile başlatmak için: natureco gateway start\n'));
|
|
14
|
+
function saveWebhooks(webhooks) {
|
|
15
|
+
const dir = path.dirname(WEBHOOKS_FILE);
|
|
16
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
17
|
+
fs.writeFileSync(WEBHOOKS_FILE, JSON.stringify(webhooks, null, 2), 'utf8');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function webhooks(args) {
|
|
21
|
+
const [action, subAction, ...params] = args || [];
|
|
22
|
+
|
|
23
|
+
if (!action || action === 'list') return cmdList();
|
|
24
|
+
if (action === 'gmail' && subAction === 'setup') return cmdGmailSetup();
|
|
25
|
+
if (action === 'gmail' && subAction === 'run') return cmdGmailRun();
|
|
26
|
+
|
|
27
|
+
console.log(chalk.red(`\n Unknown webhooks action: ${action} ${subAction || ''}\n`));
|
|
28
|
+
console.log(chalk.gray(' Usage: natureco webhooks <action> [params]'));
|
|
29
|
+
console.log(chalk.gray(' Actions: list, gmail setup, gmail run\n'));
|
|
30
|
+
process.exit(1);
|
|
42
31
|
}
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
function cmdList() {
|
|
34
|
+
const webhooks = loadWebhooks();
|
|
35
|
+
|
|
36
|
+
console.log(chalk.cyan(`\n Webhooks (${webhooks.length})\n`));
|
|
37
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
38
|
+
|
|
39
|
+
if (webhooks.length === 0) {
|
|
40
|
+
console.log(chalk.gray(' No webhooks configured.\n'));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (const w of webhooks) {
|
|
45
|
+
console.log(` ${chalk.white(w.name || w.id || 'unnamed')}`);
|
|
46
|
+
if (w.url) console.log(chalk.gray(` URL: ${w.url}`));
|
|
47
|
+
if (w.path) console.log(chalk.gray(` Path: ${w.path}`));
|
|
48
|
+
if (w.type) console.log(chalk.gray(` Type: ${w.type}`));
|
|
49
|
+
}
|
|
50
|
+
console.log('');
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
console.log(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
53
|
+
function cmdGmailSetup() {
|
|
54
|
+
console.log(chalk.cyan('\n Gmail Pub/Sub Webhook Setup\n'));
|
|
55
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
56
|
+
console.log(` ${chalk.white('Status:')} ${chalk.yellow('Not configured')}`);
|
|
57
|
+
console.log('');
|
|
58
|
+
console.log(chalk.gray(' To set up Gmail webhooks:'));
|
|
59
|
+
console.log(chalk.gray(' 1. Enable Gmail API in Google Cloud Console'));
|
|
60
|
+
console.log(chalk.gray(' 2. Create a Pub/Sub topic'));
|
|
61
|
+
console.log(chalk.gray(' 3. Configure the push endpoint'));
|
|
62
|
+
console.log(chalk.gray(' 4. Run: natureco webhooks gmail run'));
|
|
63
|
+
console.log('');
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (webhooks.length === 0) { console.log(chalk.gray('\n⚠️ No webhooks configured\n')); console.log(chalk.gray('Add with: natureco webhooks connect\n')); return; }
|
|
74
|
-
console.log(chalk.green(`\n✅ Webhooks active (${webhooks.length} route(s))\n`));
|
|
75
|
-
webhooks.forEach(w => console.log(chalk.white(` ${w.path} → ${w.name}`)));
|
|
76
|
-
console.log(chalk.gray('\nDisconnect with: natureco webhooks disconnect\n'));
|
|
66
|
+
function cmdGmailRun() {
|
|
67
|
+
console.log(chalk.cyan('\n Triggering Gmail Webhook\n'));
|
|
68
|
+
console.log(chalk.gray(' (Stub — Gmail webhook execution not implemented)\n'));
|
|
77
69
|
}
|
|
78
70
|
|
|
79
71
|
module.exports = webhooks;
|