vortix 1.0.1 → 1.0.3
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/agent/agent.js +67 -7
- package/package.json +5 -1
- package/scripts/postinstall.js +73 -0
package/agent/agent.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const WebSocket = require("ws");
|
|
2
2
|
const { exec } = require("child_process");
|
|
3
3
|
const os = require("os");
|
|
4
|
+
const readline = require("readline");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
4
7
|
|
|
5
8
|
process.on("uncaughtException", (err) => {
|
|
6
9
|
console.error("Uncaught Exception:", err);
|
|
@@ -10,11 +13,60 @@ process.on("unhandledRejection", (err) => {
|
|
|
10
13
|
console.error("Unhandled Rejection:", err);
|
|
11
14
|
});
|
|
12
15
|
|
|
16
|
+
const CONFIG_FILE = path.join(os.homedir(), '.vortix-config.json');
|
|
17
|
+
|
|
18
|
+
// Load or create config
|
|
19
|
+
function loadConfig() {
|
|
20
|
+
try {
|
|
21
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
22
|
+
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
23
|
+
}
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error("Error loading config:", err.message);
|
|
26
|
+
}
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function saveConfig(config) {
|
|
31
|
+
try {
|
|
32
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.error("Error saving config:", err.message);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function promptPassword() {
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
const rl = readline.createInterface({
|
|
41
|
+
input: process.stdin,
|
|
42
|
+
output: process.stdout
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
rl.question('Set a password for this device: ', (password) => {
|
|
46
|
+
rl.close();
|
|
47
|
+
resolve(password.trim());
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
13
52
|
const command = process.argv[2];
|
|
14
53
|
|
|
15
54
|
if (command === "login") {
|
|
16
|
-
|
|
17
|
-
|
|
55
|
+
(async () => {
|
|
56
|
+
const password = await promptPassword();
|
|
57
|
+
if (!password) {
|
|
58
|
+
console.log("Password is required");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const config = loadConfig();
|
|
63
|
+
config.password = password;
|
|
64
|
+
saveConfig(config);
|
|
65
|
+
|
|
66
|
+
console.log("Password saved successfully!");
|
|
67
|
+
console.log("You can now run: vortix start");
|
|
68
|
+
console.log("\nIMPORTANT: Use this same password in the dashboard to access this device.");
|
|
69
|
+
})();
|
|
18
70
|
return;
|
|
19
71
|
}
|
|
20
72
|
|
|
@@ -24,20 +76,28 @@ if (command === "start") {
|
|
|
24
76
|
}
|
|
25
77
|
|
|
26
78
|
console.log("Available commands:");
|
|
79
|
+
console.log(" vortix login - Set device password");
|
|
27
80
|
console.log(" vortix start - Start the agent");
|
|
28
|
-
console.log(" vortix help - Show help");
|
|
29
81
|
|
|
30
82
|
function startAgent() {
|
|
83
|
+
const config = loadConfig();
|
|
84
|
+
|
|
85
|
+
if (!config.password) {
|
|
86
|
+
console.log("Please set a password first: vortix login");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
31
90
|
const deviceName = os.hostname();
|
|
32
|
-
const
|
|
91
|
+
const deviceToken = `device-${deviceName.toLowerCase()}`;
|
|
92
|
+
const token = `${deviceToken}:${config.password}`;
|
|
33
93
|
|
|
34
|
-
console.log(`
|
|
35
|
-
console.log(
|
|
94
|
+
console.log(`Device: ${deviceName}`);
|
|
95
|
+
console.log("Connecting to backend...");
|
|
36
96
|
|
|
37
97
|
// Production backend URL - Render deployment
|
|
38
98
|
const BACKEND_URL = process.env.BACKEND_URL || 'wss://vortix.onrender.com';
|
|
39
99
|
|
|
40
|
-
const ws = new WebSocket(`${BACKEND_URL}?token=${token}`);
|
|
100
|
+
const ws = new WebSocket(`${BACKEND_URL}?token=${encodeURIComponent(token)}`);
|
|
41
101
|
|
|
42
102
|
ws.on("open", () => {
|
|
43
103
|
console.log("Authenticated and connected to backend");
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vortix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "AI-powered OS control system with remote command execution",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"vortix": "./bin/vortix.js"
|
|
8
8
|
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node scripts/postinstall.js"
|
|
11
|
+
},
|
|
9
12
|
"keywords": [
|
|
10
13
|
"ai",
|
|
11
14
|
"automation",
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
"bin/",
|
|
28
31
|
"agent/",
|
|
29
32
|
"backend/",
|
|
33
|
+
"scripts/",
|
|
30
34
|
"README.md"
|
|
31
35
|
],
|
|
32
36
|
"dependencies": {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const colors = {
|
|
4
|
+
reset: '\x1b[0m',
|
|
5
|
+
bright: '\x1b[1m',
|
|
6
|
+
green: '\x1b[32m',
|
|
7
|
+
cyan: '\x1b[36m',
|
|
8
|
+
yellow: '\x1b[33m',
|
|
9
|
+
magenta: '\x1b[35m',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const box = {
|
|
13
|
+
topLeft: '╔',
|
|
14
|
+
topRight: '╗',
|
|
15
|
+
bottomLeft: '╚',
|
|
16
|
+
bottomRight: '╝',
|
|
17
|
+
horizontal: '═',
|
|
18
|
+
vertical: '║',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function printBox(lines, width = 60) {
|
|
22
|
+
console.log('\n');
|
|
23
|
+
console.log(colors.green + box.topLeft + box.horizontal.repeat(width) + box.topRight + colors.reset);
|
|
24
|
+
|
|
25
|
+
lines.forEach(line => {
|
|
26
|
+
const padding = width - line.length;
|
|
27
|
+
const leftPad = Math.floor(padding / 2);
|
|
28
|
+
const rightPad = padding - leftPad;
|
|
29
|
+
console.log(
|
|
30
|
+
colors.green + box.vertical + colors.reset +
|
|
31
|
+
' '.repeat(leftPad) + line + ' '.repeat(rightPad) +
|
|
32
|
+
colors.green + box.vertical + colors.reset
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log(colors.green + box.bottomLeft + box.horizontal.repeat(width) + box.bottomRight + colors.reset);
|
|
37
|
+
console.log('\n');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log('\n');
|
|
41
|
+
console.log(colors.bright + colors.green + ' ╦ ╦┌─┐┬─┐┌┬┐┬─┐ ┬' + colors.reset);
|
|
42
|
+
console.log(colors.bright + colors.green + ' ╚╗╔╝│ │├┬┘ │ │┌┴┬┘' + colors.reset);
|
|
43
|
+
console.log(colors.bright + colors.green + ' ╚╝ └─┘┴└─ ┴ ┴┴ └─' + colors.reset);
|
|
44
|
+
console.log('\n');
|
|
45
|
+
|
|
46
|
+
printBox([
|
|
47
|
+
colors.bright + colors.cyan + '🚀 Installation Successful!' + colors.reset,
|
|
48
|
+
'',
|
|
49
|
+
colors.yellow + 'AI-Powered Remote OS Control' + colors.reset,
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
console.log(colors.bright + ' 📖 Quick Start:' + colors.reset);
|
|
53
|
+
console.log('');
|
|
54
|
+
console.log(' ' + colors.cyan + '1.' + colors.reset + ' Set device password:');
|
|
55
|
+
console.log(' ' + colors.green + 'vortix login' + colors.reset);
|
|
56
|
+
console.log('');
|
|
57
|
+
console.log(' ' + colors.cyan + '2.' + colors.reset + ' Start the agent:');
|
|
58
|
+
console.log(' ' + colors.green + 'vortix start' + colors.reset);
|
|
59
|
+
console.log('');
|
|
60
|
+
console.log(' ' + colors.cyan + '3.' + colors.reset + ' Open dashboard:');
|
|
61
|
+
console.log(' ' + colors.magenta + colors.bright + 'https://vortixai.vercel.app' + colors.reset);
|
|
62
|
+
console.log('');
|
|
63
|
+
|
|
64
|
+
console.log(colors.bright + ' 📚 Documentation:' + colors.reset);
|
|
65
|
+
console.log(' ' + colors.cyan + 'https://github.com/Vaibhav262610/vortix' + colors.reset);
|
|
66
|
+
console.log('');
|
|
67
|
+
|
|
68
|
+
console.log(colors.bright + ' 💡 Need Help?' + colors.reset);
|
|
69
|
+
console.log(' ' + colors.cyan + 'Run:' + colors.reset + ' ' + colors.green + 'vortix help' + colors.reset);
|
|
70
|
+
console.log('');
|
|
71
|
+
|
|
72
|
+
console.log(colors.yellow + ' ⚡ Pro Tip: ' + colors.reset + 'Use AI commands in the dashboard for natural language control!');
|
|
73
|
+
console.log('');
|