xkat-cli 2.0.10 → 2.0.12
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/checksums.json +5 -5
- package/bin/xkat-cli.js +61 -5
- package/package.json +1 -1
package/bin/checksums.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"xkat-agent-macos-aarch64": "
|
|
3
|
-
"xkat-agent-macos-x64": "
|
|
4
|
-
"xkat-agent-linux-x64": "
|
|
5
|
-
"xkat-agent-linux-aarch64": "
|
|
6
|
-
"xkat-agent-win-x64.exe": "
|
|
2
|
+
"xkat-agent-macos-aarch64": "00c11219374b24b645c4b0f3768c8893f292b157b464b02e47f883fb4db8f7ea",
|
|
3
|
+
"xkat-agent-macos-x64": "98f6ff2a6a94c38e95b15b4ee15ebf9f8c32dbaca002552c9a897c9048d9ce68",
|
|
4
|
+
"xkat-agent-linux-x64": "d184e66de8d3bb221f308f7326dddb83cab6040d535f21f279009e9e4220c0f7",
|
|
5
|
+
"xkat-agent-linux-aarch64": "2e004d3278b9c5f0ef996bb2575e20a4c76a4d1d00ab117afb2b862366d4ef69",
|
|
6
|
+
"xkat-agent-win-x64.exe": "0470f3cf2f7aadac82a06c32c850bbc9e664eac690d1afdbca0d7d787217e7dd"
|
|
7
7
|
}
|
package/bin/xkat-cli.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* xkat-cli.js
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Lightweight CLI entry point for `npx -y xkat-cli@latest`.
|
|
6
|
+
* Launches the live local agent bridge in the foreground by default,
|
|
7
|
+
* connecting your browser to your local environment with zero manual configuration.
|
|
8
8
|
*/
|
|
9
9
|
const { spawnSync } = require('child_process');
|
|
10
10
|
const path = require('path');
|
|
@@ -35,23 +35,79 @@ function getBinaryName() {
|
|
|
35
35
|
return binary;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
const LAB_NAME = 'xkat-lab';
|
|
39
|
+
|
|
38
40
|
const candidatePaths = [
|
|
39
41
|
path.join(__dirname, '..', 'target', 'release', os.platform() === 'win32' ? 'xkat-agent.exe' : 'xkat-agent'),
|
|
40
42
|
path.join(__dirname, '..', 'target', 'debug', os.platform() === 'win32' ? 'xkat-agent.exe' : 'xkat-agent'),
|
|
41
43
|
path.join(__dirname, '..', 'binaries', getBinaryName()),
|
|
44
|
+
path.join(os.homedir(), '.xkat', os.platform() === 'win32' ? 'xkat-agent.exe' : 'xkat-agent'),
|
|
42
45
|
];
|
|
43
46
|
|
|
44
47
|
const binaryPath = candidatePaths.find((p) => fs.existsSync(p));
|
|
45
48
|
|
|
49
|
+
const args = process.argv.slice(2);
|
|
50
|
+
const subCmd = args.join(' ').trim();
|
|
51
|
+
|
|
52
|
+
// ── 1. Zero-Touch Port 10022 Cleanup Command ──
|
|
53
|
+
if (subCmd === 'down' || subCmd === 'stop' || subCmd === 'kill' || subCmd === 'clean') {
|
|
54
|
+
console.log('🛑 Cleaning up port 10022 and stopping existing xkat agent instances...');
|
|
55
|
+
if (os.platform() === 'win32') {
|
|
56
|
+
spawnSync('powershell', [
|
|
57
|
+
'-NoProfile',
|
|
58
|
+
'-NonInteractive',
|
|
59
|
+
'-Command',
|
|
60
|
+
'Get-NetTCPConnection -LocalPort 10022 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique | Where-Object { $_ -gt 0 } | ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }; Get-Process -Name xkat-agent*, xkat* -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue'
|
|
61
|
+
], { stdio: 'inherit' });
|
|
62
|
+
} else {
|
|
63
|
+
spawnSync('sh', ['-c', 'fuser -k 10022/tcp 2>/dev/null || true; pgrep -f "xkat-agent" | xargs -r kill -9 2>/dev/null || true'], { stdio: 'inherit' });
|
|
64
|
+
}
|
|
65
|
+
console.log('✅ Port 10022 is now completely free.');
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ── 2. Fallback for Lab VM commands when native agent is not built ──
|
|
46
70
|
if (!binaryPath) {
|
|
71
|
+
if (subCmd === 'lab shell') {
|
|
72
|
+
const result = spawnSync('multipass', ['shell', LAB_NAME], { stdio: 'inherit' });
|
|
73
|
+
process.exit(result.status || 0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (subCmd === 'lab reset') {
|
|
77
|
+
console.log('🔄 Resetting Lab VM...');
|
|
78
|
+
spawnSync('multipass', ['delete', LAB_NAME, '--purge'], { stdio: 'inherit' });
|
|
79
|
+
console.log('🚀 Launching fresh Lab VM...');
|
|
80
|
+
const launch = spawnSync('multipass', ['launch', '--name', LAB_NAME, '24.04', '--cpus', '2', '--memory', '2G', '--disk', '10G'], { stdio: 'inherit' });
|
|
81
|
+
if (launch.status === 0) {
|
|
82
|
+
console.log('✅ Lab reset complete.');
|
|
83
|
+
console.log(' Enter: npx -y xkat-cli@latest lab shell');
|
|
84
|
+
} else {
|
|
85
|
+
console.error('❌ Could not recreate Lab. Check multipass installation.');
|
|
86
|
+
}
|
|
87
|
+
process.exit(launch.status || 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (subCmd === 'lab up' || subCmd === 'lab install') {
|
|
91
|
+
const info = spawnSync('multipass', ['info', LAB_NAME], { encoding: 'utf8' });
|
|
92
|
+
if (info.status !== 0) {
|
|
93
|
+
console.log('🚀 Creating Lab VM...');
|
|
94
|
+
const launch = spawnSync('multipass', ['launch', '--name', LAB_NAME, '24.04', '--cpus', '2', '--memory', '2G', '--disk', '10G'], { stdio: 'inherit' });
|
|
95
|
+
process.exit(launch.status || 0);
|
|
96
|
+
} else {
|
|
97
|
+
console.log(`✅ Lab VM '${LAB_NAME}' already exists.`);
|
|
98
|
+
console.log(' Enter: npx -y xkat-cli@latest lab shell');
|
|
99
|
+
process.exit(0);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
47
103
|
console.error('❌ xkat-agent binary not found.');
|
|
48
104
|
console.error(' Try reinstalling: npm install -g xkat-cli');
|
|
49
105
|
console.error(' Or for local development: cargo build');
|
|
50
106
|
process.exit(1);
|
|
51
107
|
}
|
|
52
108
|
|
|
53
|
-
//
|
|
54
|
-
const result = spawnSync(binaryPath,
|
|
109
|
+
// ── 3. Forward to Rust binary ──
|
|
110
|
+
const result = spawnSync(binaryPath, args, {
|
|
55
111
|
stdio: 'inherit',
|
|
56
112
|
env: process.env,
|
|
57
113
|
});
|