vamp-mcp 0.1.8 → 0.2.0
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 +23 -9
- package/bin/vamp-mcp.mjs +1 -1
- package/package.json +1 -1
- package/runtime/backends/kvm/debian-preseed.cfg +35 -0
- package/runtime/backends/remote_ssh/server.mjs +279 -8
- package/runtime/backends/virtualbox/provision.py +69 -21
- package/runtime/backends/virtualbox/server.mjs +390 -50
- package/runtime/guest_setup/http/postdeb.sh +47 -0
- package/runtime/guest_setup/http/postwin.ps1 +28 -0
- package/runtime/guest_setup/http/setup-all.ps1 +25 -0
- package/runtime/guest_setup/http/setup-win.cmd +7 -0
- package/runtime/guest_setup/http/setup.ps1 +29 -0
- package/runtime/guest_setup/http/setup.sh +50 -0
- package/runtime/guest_setup/kvm/setup-debian.sh +73 -0
- package/runtime/guest_setup/kvm/setup-windows.ps1 +52 -0
- package/runtime/guest_setup/recorder/README.txt +4 -0
- package/runtime/guest_setup/recorder/recorder.zip +0 -0
- package/runtime/guest_setup/recorder/setup-user.py +19 -1
- package/runtime/guest_setup/recorder/setup-win.cmd +55 -6
- package/runtime/guest_setup/recorder/setup.ps1 +57 -6
- package/runtime/guest_setup/recorder/setup.sh +18 -1
- package/runtime/guest_setup/requirements.txt +2 -0
- package/runtime/guest_setup/setup-all.ps1 +35 -0
- package/runtime/guest_setup/setup-all.sh +22 -0
- package/runtime/guest_setup/vault/Install-VCRuntime.ps1 +26 -0
- package/runtime/guest_setup/vault/setup-guest-vault.ps1 +148 -0
- package/runtime/guest_setup/vault/setup-guest-vault.sh +75 -0
- package/runtime/scripts/macos/setup-host.sh +126 -0
- package/runtime/scripts/remote_host_setup.sh +7 -4
- package/runtime/scripts/script_server.py +517 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Independent stdio MCP servers for VM-isolated GUI automation. Run with an MCP cl
|
|
|
6
6
|
|
|
7
7
|
- Node.js 22+.
|
|
8
8
|
- Local VirtualBox tools need VirtualBox 7.x. Python helper tools need Python 3.11+; set `RPA_HOST_PYTHON` to your Python executable. Install Robot Framework, pycdlib, asyncvnc or the matching VirtualBox Python SDK when the chosen operation requires them.
|
|
9
|
-
- The `remote` server runs on the host owning KVM/libvirt or VirtualBox. To operate a different machine, start it there over SSH. Linux KVM requires access to `virsh` and the selected libvirt URI.
|
|
9
|
+
- The `remote` server runs on the host owning KVM/libvirt or VirtualBox. To operate a different machine, start it there over SSH. Linux KVM requires access to `virsh` and the selected libvirt URI. VM creation also needs `virt-install` and `qemu-img`. Debian automatic installation boots the stock ISO and injects a preseed into the initrd; `xorriso` is not used. Guest setup is served over HTTP from a host Python 3 server on port 8421.
|
|
10
10
|
- Provide your own VMs, guest operating systems, licenses and Guest Additions when needed. Package installation does not create VMs or install system dependencies.
|
|
11
11
|
- VAMP Vault MCP is a separate npm package, `vamp-mcp-vault`. The live viewer and graphical manager require the VS Code extensions; npm does not install them. Hyper-V is not included in this npm release.
|
|
12
12
|
- Full SPICE/OCR/YOLO workflows still require the source repository and their documented environments.
|
|
@@ -21,10 +21,10 @@ vamp-mcp --help
|
|
|
21
21
|
Or run without a global install:
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
|
-
npx -y vamp-mcp@0.
|
|
25
|
-
npx -y vamp-mcp@0.
|
|
26
|
-
npx -y vamp-mcp@0.
|
|
27
|
-
npx -y vamp-mcp@0.
|
|
24
|
+
npx -y vamp-mcp@0.2.0 virtualbox
|
|
25
|
+
npx -y vamp-mcp@0.2.0 kvm
|
|
26
|
+
npx -y vamp-mcp@0.2.0 library
|
|
27
|
+
npx -y vamp-mcp@0.2.0 remote --backend kvm
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Servers communicate over standard input/output and wait for an MCP client. Use separate MCP registrations for each server. Installation alone does not register them with every client.
|
|
@@ -39,7 +39,7 @@ Add a server to `.vscode/mcp.json` (on Windows use `npx.cmd` if your client requ
|
|
|
39
39
|
"vamp": {
|
|
40
40
|
"type": "stdio",
|
|
41
41
|
"command": "npx",
|
|
42
|
-
"args": ["-y", "vamp-mcp@0.
|
|
42
|
+
"args": ["-y", "vamp-mcp@0.2.0", "virtualbox"],
|
|
43
43
|
"env": {"RPA_HOST_PYTHON": "/absolute/path/to/python"}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -55,13 +55,13 @@ In `~/.codex/config.toml`:
|
|
|
55
55
|
```toml
|
|
56
56
|
[mcp_servers.vamp]
|
|
57
57
|
command = "npx"
|
|
58
|
-
args = ["-y", "vamp-mcp@0.
|
|
58
|
+
args = ["-y", "vamp-mcp@0.2.0", "virtualbox"]
|
|
59
59
|
|
|
60
60
|
[mcp_servers.vamp.env]
|
|
61
61
|
RPA_HOST_PYTHON = "/absolute/path/to/python"
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
For KVM, change the final argument from `virtualbox` to `kvm`. This uses the existing host controller: inventory, start/stop, screenshots, keyboard/mouse and saved RPA replay. It does not provide the full source-repository SPICE/OCR environment or a live viewer.
|
|
64
|
+
For KVM, change the final argument from `virtualbox` to `kvm`. This uses the existing host controller: inventory, VM creation, start/stop, screenshots, keyboard/mouse and saved RPA replay. It does not provide the full source-repository SPICE/OCR environment or a live viewer.
|
|
65
65
|
|
|
66
66
|
For the RPA library, register `library` instead and set `VAMP_RPA_REGISTRY` to your saved VAMP catalog directory. Its default is `~/.vamp/rpa-catalog`; an existing VS Code catalog must be selected explicitly. The library searches and replays reviewed definitions; it does not provide the extension's authoring UI. Replay needs its Python dependencies and a reviewed, compatible RPA. Actions completing does not prove application success; verify the expected outcome.
|
|
67
67
|
|
|
@@ -85,9 +85,23 @@ npm run build --prefix third_party/mcp-virtualbox
|
|
|
85
85
|
npm ci --prefix vscode-extension --ignore-scripts
|
|
86
86
|
npm run build --prefix npm-package
|
|
87
87
|
npm pack ./npm-package --pack-destination /tmp
|
|
88
|
-
VAMP_TEST_TARBALL=/tmp/vamp-mcp-0.
|
|
88
|
+
VAMP_TEST_TARBALL=/tmp/vamp-mcp-0.2.0.tgz npm test --prefix npm-package
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
The build reuses the VSIX runtime bundling and dependency license notices. The published package has no install scripts and no npm runtime dependencies; JavaScript dependencies are bundled. See the repository for backend-specific setup and validation limits.
|
|
92
92
|
|
|
93
93
|
[Source and documentation](https://github.com/wayfarer6/vamp-mcp)
|
|
94
|
+
|
|
95
|
+
## VM creation and installation
|
|
96
|
+
|
|
97
|
+
For KVM, call `remote_vm_create` with `name`, an absolute host `iso_path`, `guest_os:"debian"`, and `confirmed:true` after user authorization. Debian amd64 installer ISOs default to unattended installation; use `installation_mode:"manual"` to opt out. Ubuntu/Windows installation is manual; Windows additionally requires `windows_confirmed:true` and your own valid license.
|
|
98
|
+
|
|
99
|
+
For VirtualBox, use `vm_create`. Compatible ISOs use VirtualBox unattended installation; when VirtualBox reports the ISO as unsupported, the stock installer runs and you complete it manually. VAMP never rewrites the ISO and does not use `xorriso`. The post-install hook downloads the guest setup from the host HTTP server on port 8421 (`vm_script_server_start`, `vm_script_server_stop`, `vm_script_server_status`), and `vm_guest_bootstrap` serves and types the wget/`irm` command.
|
|
100
|
+
|
|
101
|
+
Automatic Debian installation uses the **public sandbox account `vboxuser` / `password123!`**. Change it before using the VM for private work. The source ISO and existing VMs are never overwritten; the stock ISO is attached or read as-is. Guest setup scripts are staged into a per-user state folder and served read-only on port 8421 (no directory listing, 30-minute default TTL). Unsupported installer layouts fail with an error; they do not silently count as successful installation.
|
|
102
|
+
|
|
103
|
+
`startup_verified:true` confirms Running state only. Verify OS installation and the guest desktop separately. Recorder/Vault guest setup is not automatically completed by this Debian path. The full repository's richer lab installers remain separate workflows.
|
|
104
|
+
|
|
105
|
+
On Linux, stop active VirtualBox VMs before starting KVM and vice versa. Concurrent use can crash VirtualBox with `VERR_SVM_IN_USE`; creation/start paths check for the other hypervisor.
|
|
106
|
+
|
|
107
|
+
한국어: `vamp-mcp` 하나에서 VirtualBox와 KVM을 선택합니다. KVM의 `remote_vm_create`는 명시적 확인 후 VM을 생성·기동하며, Debian amd64 설치 ISO는 순정 ISO 부팅과 preseed 커널 주입으로 자동 설치합니다(xorriso 불필요). Python·virt-install·qemu-img를 호스트에 준비하세요. 게스트 설정 스크립트는 파이썬 HTTP 서버가 8421 포트로 제공하고 게스트가 wget/curl로 내려받습니다. 공개 테스트 계정은 `vboxuser` / `password123!`입니다. VM 기동 성공과 OS·게스트 도구 설치 완료는 별도로 검증해야 합니다. Linux에서는 KVM과 VirtualBox VM을 동시에 실행하지 마세요.
|
package/bin/vamp-mcp.mjs
CHANGED
|
@@ -12,7 +12,7 @@ if (command==='--version' || command==='-v') {
|
|
|
12
12
|
console.log(`VAMP MCP — independent stdio servers
|
|
13
13
|
Usage: vamp-mcp [virtualbox|kvm|library|remote] [remote options]
|
|
14
14
|
virtualbox Local VirtualBox MCP (default); needs VirtualBox and Python 3.11+
|
|
15
|
-
kvm
|
|
15
|
+
kvm KVM/libvirt inventory, creation and control (Debian automatic install)
|
|
16
16
|
library Reviewed RPA search/replay; VAMP_RPA_REGISTRY selects saved RPAs
|
|
17
17
|
remote KVM/VirtualBox host MCP; pass --backend kvm or --backend virtualbox
|
|
18
18
|
--version Package version
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
d-i debian-installer/locale string en_US.UTF-8
|
|
2
|
+
d-i keyboard-configuration/xkb-keymap select us
|
|
3
|
+
d-i netcfg/choose_interface select auto
|
|
4
|
+
d-i netcfg/get_hostname string vamp-desktop
|
|
5
|
+
d-i netcfg/get_domain string local
|
|
6
|
+
d-i mirror/country string manual
|
|
7
|
+
d-i mirror/http/hostname string deb.debian.org
|
|
8
|
+
d-i mirror/http/directory string /debian
|
|
9
|
+
d-i mirror/http/proxy string
|
|
10
|
+
d-i passwd/root-login boolean false
|
|
11
|
+
d-i passwd/user-fullname string VAMP Test
|
|
12
|
+
d-i passwd/username string vboxuser
|
|
13
|
+
d-i passwd/user-password password password123!
|
|
14
|
+
d-i passwd/user-password-again password password123!
|
|
15
|
+
d-i clock-setup/utc boolean true
|
|
16
|
+
d-i time/zone string Asia/Seoul
|
|
17
|
+
d-i clock-setup/ntp boolean false
|
|
18
|
+
d-i partman-auto/method string regular
|
|
19
|
+
d-i partman-auto/choose_recipe select atomic
|
|
20
|
+
d-i partman-partitioning/confirm_write_new_label boolean true
|
|
21
|
+
d-i partman/choose_partition select finish
|
|
22
|
+
d-i partman/confirm boolean true
|
|
23
|
+
d-i partman/confirm_nooverwrite boolean true
|
|
24
|
+
d-i apt-setup/cdrom/set-first boolean false
|
|
25
|
+
d-i apt-setup/disable-cdrom-entries boolean true
|
|
26
|
+
d-i apt-setup/use_mirror boolean true
|
|
27
|
+
d-i pkgsel/run_tasksel boolean false
|
|
28
|
+
d-i pkgsel/include string qemu-guest-agent sudo python3 xserver-xorg lightdm lightdm-gtk-greeter openbox xterm firefox-esr fonts-dejavu dbus-x11 x11-xserver-utils
|
|
29
|
+
d-i pkgsel/upgrade select none
|
|
30
|
+
popularity-contest popularity-contest/participate boolean false
|
|
31
|
+
d-i grub-installer/only_debian boolean true
|
|
32
|
+
d-i grub-installer/bootdev string default
|
|
33
|
+
d-i preseed/late_command string mkdir -p /target/etc/lightdm/lightdm.conf.d /target/home/vboxuser/.config/openbox; printf '[Seat:*]\nautologin-user=vboxuser\nautologin-user-timeout=0\nuser-session=openbox\n' > /target/etc/lightdm/lightdm.conf.d/50-vamp.conf; printf 'xrandr --output Virtual-1 --mode 1920x1080 || xrandr --output Virtual1 --mode 1920x1080 || true\nxset s off\nxset -dpms\nxterm -geometry 100x28+80+80 -fa Monospace -fs 18 -title VAMP-DESKTOP-READY &\n' > /target/home/vboxuser/.config/openbox/autostart; in-target chown -R vboxuser:vboxuser /home/vboxuser/.config; in-target systemctl enable lightdm; in-target systemctl set-default graphical.target; in-target touch /var/lib/vamp-debian-installed; echo VAMP-DEBIAN-INSTALL-COMPLETE > /dev/ttyS0 || true
|
|
34
|
+
d-i finish-install/reboot_in_progress note
|
|
35
|
+
d-i cdrom-detect/eject boolean true
|
|
@@ -1,5 +1,208 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vampRequire } from 'node:module'; const require = __vampRequire(import.meta.url);
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
// backends/common/host-backends.cjs
|
|
36
|
+
var require_host_backends = __commonJS({
|
|
37
|
+
"backends/common/host-backends.cjs"(exports, module) {
|
|
38
|
+
var fs2 = __require("node:fs");
|
|
39
|
+
var path3 = __require("node:path");
|
|
40
|
+
var { execFile: execFile2 } = __require("node:child_process");
|
|
41
|
+
var { promisify } = __require("node:util");
|
|
42
|
+
var run = promisify(execFile2);
|
|
43
|
+
var UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
44
|
+
var decode2 = (s) => s.replace(/&(?:amp|lt|gt|quot|apos);/g, (c) => ({ "&": "&", "<": "<", ">": ">", """: '"', "'": "'" })[c]);
|
|
45
|
+
function attributes2(text) {
|
|
46
|
+
const result = {};
|
|
47
|
+
for (const m of text.matchAll(/([\w:-]+)\s*=\s*(['"])(.*?)\2/g)) result[m[1]] = decode2(m[3]);
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
function domainInfo(xml) {
|
|
51
|
+
const tag2 = (name) => decode2(xml.match(new RegExp("<" + name + "(?:\\s[^>]*)?>([^<]*)</" + name + ">"))?.[1] || "");
|
|
52
|
+
const memoryTag = xml.match(/<memory\b([^>]*)>/)?.[1] || "";
|
|
53
|
+
const unit = attributes2(memoryTag).unit || "KiB";
|
|
54
|
+
const multipliers = { KiB: 1 / 1024, MiB: 1, GiB: 1024, bytes: 1 / 1024 ** 2, k: 1 / 1024, M: 1, G: 1024 };
|
|
55
|
+
return { id: tag2("uuid"), name: tag2("name"), memory: Math.round(Number(tag2("memory")) * (multipliers[unit] || 1 / 1024)), cpus: Number(tag2("vcpu")) };
|
|
56
|
+
}
|
|
57
|
+
function vncEndpoint(xml) {
|
|
58
|
+
for (const tag2 of xml.matchAll(/<graphics\b([^>]*)(?:\/>|>([\s\S]*?)<\/graphics>)/g)) {
|
|
59
|
+
const a = attributes2(tag2[1]);
|
|
60
|
+
if (a.type !== "vnc") continue;
|
|
61
|
+
const listen = attributes2(tag2[2]?.match(/<listen\b([^>]*)\/>/)?.[1] || "");
|
|
62
|
+
const host = a.listen || listen.address || "127.0.0.1", port = Number(a.port);
|
|
63
|
+
if (!["127.0.0.1", "localhost", "::1"].includes(host) || !Number.isInteger(port) || port < 1 || port > 65535) throw Error("This VM needs an active VNC display listening on localhost.");
|
|
64
|
+
return { host, port };
|
|
65
|
+
}
|
|
66
|
+
throw Error("This VM does not expose VNC. Create a KVM desktop here to use the embedded viewer.");
|
|
67
|
+
}
|
|
68
|
+
function hostBackends(context, { runtime, config, execute = run }) {
|
|
69
|
+
const storage = path3.join(context.globalStorageUri.fsPath, "desktops");
|
|
70
|
+
const uri = () => config().get("libvirtUri") || "qemu:///session";
|
|
71
|
+
const command = async (exe, args, timeout = 3e4) => (await execute(exe, args, { timeout, maxBuffer: 4 * 1024 ** 2, env: { ...process.env, LC_ALL: "C" } })).stdout;
|
|
72
|
+
const virsh = (args) => command("virsh", ["-c", uri(), ...args]);
|
|
73
|
+
const checkID = (id) => {
|
|
74
|
+
if (!UUID.test(id)) throw Error("Invalid VM identifier");
|
|
75
|
+
return id;
|
|
76
|
+
};
|
|
77
|
+
const record = (backend, name) => path3.join(storage, backend, name, "vamp-ui.json");
|
|
78
|
+
function managed(backend, id) {
|
|
79
|
+
const root = path3.join(storage, backend);
|
|
80
|
+
if (!fs2.existsSync(root)) return;
|
|
81
|
+
for (const name of fs2.readdirSync(root)) {
|
|
82
|
+
try {
|
|
83
|
+
const item = JSON.parse(fs2.readFileSync(record(backend, name), "utf8"));
|
|
84
|
+
if (item.id === id) return { ...item, folder: path3.dirname(record(backend, name)) };
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function hyperv(action, data = {}) {
|
|
90
|
+
if (process.platform !== "win32") throw Error("Hyper-V management is available on a Windows host with Hyper-V enabled.");
|
|
91
|
+
const result = await command("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-File", path3.join(runtime, "backends/hyperv/scripts/Manage-Desktop.ps1"), "-RequestBase64", Buffer.from(JSON.stringify({ action, ...data })).toString("base64"), "-StoragePath", path3.join(storage, "hyperv")], 18e4);
|
|
92
|
+
return JSON.parse(result);
|
|
93
|
+
}
|
|
94
|
+
async function ensureNoVirtualBox() {
|
|
95
|
+
if (process.platform !== "linux") return;
|
|
96
|
+
try {
|
|
97
|
+
const active = await command(process.env.VBOXMANAGE_PATH || "VBoxManage", ["list", "runningvms"]);
|
|
98
|
+
if (active.trim()) throw Error("A VirtualBox VM is active. Shut it down before starting KVM; simultaneous execution can crash VirtualBox (VERR_SVM_IN_USE).");
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (error.code !== "ENOENT") throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
async check(backend) {
|
|
105
|
+
if (backend === "hyperv") {
|
|
106
|
+
await hyperv("check");
|
|
107
|
+
return "Hyper-V ready";
|
|
108
|
+
}
|
|
109
|
+
if (process.platform !== "linux") throw Error("KVM requires a Linux host. Choose VirtualBox or Hyper-V on Windows.");
|
|
110
|
+
await virsh(["list", "--all", "--uuid"]);
|
|
111
|
+
await command("virt-install", ["--version"]);
|
|
112
|
+
await command("qemu-img", ["--version"]);
|
|
113
|
+
return "KVM \xB7 " + uri();
|
|
114
|
+
},
|
|
115
|
+
async list(backend) {
|
|
116
|
+
if (backend === "hyperv") return (await hyperv("list")).vms;
|
|
117
|
+
const ids = (await virsh(["list", "--all", "--uuid"])).split(/\s+/).filter((id) => UUID.test(id));
|
|
118
|
+
return Promise.all(ids.map(async (id) => {
|
|
119
|
+
const info = domainInfo(await virsh(["dumpxml", id]));
|
|
120
|
+
const raw = (await virsh(["domstate", id])).trim();
|
|
121
|
+
return { ...info, backend: "kvm", state: { "shut off": "poweroff", running: "running", paused: "paused", crashed: "aborted" }[raw] || raw, managed: !!managed("kvm", id) };
|
|
122
|
+
}));
|
|
123
|
+
},
|
|
124
|
+
async create(backend, { name, iso_path, guest_os, memory_mb, cpus, disk_mb, installation_mode }) {
|
|
125
|
+
if (!/^[A-Za-z][A-Za-z0-9_-]{0,62}$/.test(name)) throw Error("Use a name starting with a letter, followed by letters, numbers, hyphens or underscores.");
|
|
126
|
+
if (!["debian", "ubuntu", "windows11"].includes(guest_os)) throw Error("Unsupported operating system");
|
|
127
|
+
if (backend === "hyperv") return hyperv("create", { name, iso_path, guest_os, memory_mb, cpus, disk_mb, installation_mode });
|
|
128
|
+
if (backend !== "kvm") throw Error("Unsupported backend");
|
|
129
|
+
for (const [value, min, max] of [[memory_mb, guest_os === "windows11" ? 4096 : 2048, 131072], [cpus, 1, 64], [disk_mb, 32768, 2097152]]) if (!Number.isInteger(value) || value < min || value > max) throw Error("Invalid VM resources");
|
|
130
|
+
const mode = installation_mode || (guest_os === "debian" ? "unattended" : "manual");
|
|
131
|
+
if (!["manual", "unattended"].includes(mode) || mode === "unattended" && guest_os !== "debian") throw Error("Automatic installation is supported for Debian amd64 installer ISOs only");
|
|
132
|
+
if (!fs2.statSync(iso_path).isFile() || iso_path.includes(",")) throw Error("Choose a readable local ISO without a comma in its path.");
|
|
133
|
+
await ensureNoVirtualBox();
|
|
134
|
+
const existing = await virsh(["list", "--all", "--name"]);
|
|
135
|
+
if (existing.split(/\r?\n/).includes(name)) throw Error("A VM with this name already exists.");
|
|
136
|
+
const folder = path3.join(storage, "kvm", name);
|
|
137
|
+
fs2.mkdirSync(path3.dirname(folder), { recursive: true });
|
|
138
|
+
fs2.mkdirSync(folder);
|
|
139
|
+
const disk = path3.join(folder, "disk.qcow2");
|
|
140
|
+
let installer = iso_path, location = [];
|
|
141
|
+
if (mode === "unattended") {
|
|
142
|
+
const packaged = path3.join(runtime, "backends/kvm/debian-preseed.cfg");
|
|
143
|
+
if (!fs2.existsSync(packaged)) throw Error("Packaged Debian preseed file is missing from the VAMP runtime; choose manual installation.");
|
|
144
|
+
const preseed = path3.join(folder, "preseed.cfg");
|
|
145
|
+
fs2.copyFileSync(packaged, preseed);
|
|
146
|
+
location = [
|
|
147
|
+
"--location",
|
|
148
|
+
`${iso_path},kernel=install.amd/vmlinuz,initrd=install.amd/initrd.gz`,
|
|
149
|
+
"--initrd-inject",
|
|
150
|
+
preseed,
|
|
151
|
+
"--extra-args",
|
|
152
|
+
"auto=true priority=critical preseed/file=/preseed.cfg console=ttyS0,115200n8 console=tty0"
|
|
153
|
+
];
|
|
154
|
+
installer = null;
|
|
155
|
+
}
|
|
156
|
+
fs2.writeFileSync(path3.join(folder, "creation.json"), JSON.stringify({ status: "preparing", name, disk, iso_path }));
|
|
157
|
+
await command("qemu-img", ["create", "-f", "qcow2", disk, `${disk_mb}M`]);
|
|
158
|
+
const args = ["--connect", uri(), "--name", name, "--virt-type", "kvm", "--memory", String(memory_mb), "--vcpus", String(cpus), "--cpu", "host-passthrough", "--disk", `path=${disk},format=qcow2,bus=${guest_os === "windows11" ? "sata" : "virtio"}`, ...installer ? ["--disk", `path=${installer},device=cdrom,readonly=on`] : [], ...location, ...location.length ? [] : ["--import"], "--osinfo", "detect=on,require=off", "--graphics", "vnc,listen=127.0.0.1", "--video", guest_os === "windows11" ? "vga" : "virtio", "--input", "tablet,bus=usb", "--network", uri().endsWith("/session") ? "user,model=e1000e" : "network=default,model=virtio", "--noautoconsole", "--serial", `pty,log.file=${path3.join(folder, "serial.log")},log.append=on`];
|
|
159
|
+
if (guest_os === "windows11") args.push("--boot", "uefi,hd,cdrom", "--tpm", "backend.type=emulator,backend.version=2.0,model=tpm-crb");
|
|
160
|
+
else args.push("--boot", "hd,cdrom");
|
|
161
|
+
try {
|
|
162
|
+
await command("virt-install", args, 18e4);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw Error(`KVM setup failed. Partial setup preserved at ${folder}. ${error.message}${mode === "unattended" ? " Debian automatic installation reads the stock ISO with virt-install; if the host lacks that tooling, choose manual installation (xorriso is no longer used)." : ""}`);
|
|
165
|
+
}
|
|
166
|
+
const id = (await virsh(["domuuid", name])).trim();
|
|
167
|
+
checkID(id);
|
|
168
|
+
const state = (await virsh(["domstate", id])).trim();
|
|
169
|
+
if (state !== "running") throw Error(`VM was created but did not start (state: ${state}). Setup is preserved at ${folder}`);
|
|
170
|
+
fs2.writeFileSync(record("kvm", name), JSON.stringify({ id, name, disk, guest_os, installation_mode: mode }));
|
|
171
|
+
return { status: "installation_started", installation_mode: mode, vm: name, id, vm_state: state, startup_verified: true, installation_verified: false, serial_log: path3.join(folder, "serial.log"), ...mode === "unattended" ? { credentials: { username: "vboxuser", password: "password123!", public_sandbox_credentials: true } } : {} };
|
|
172
|
+
},
|
|
173
|
+
async start(backend, id) {
|
|
174
|
+
checkID(id);
|
|
175
|
+
if (backend === "hyperv") return hyperv("start", { id });
|
|
176
|
+
await ensureNoVirtualBox();
|
|
177
|
+
await virsh(["start", id]);
|
|
178
|
+
const state = (await virsh(["domstate", id])).trim();
|
|
179
|
+
if (state !== "running") throw Error("VM did not reach Running state: " + state);
|
|
180
|
+
return { status: "running", startup_verified: true };
|
|
181
|
+
},
|
|
182
|
+
async stop(backend, id) {
|
|
183
|
+
checkID(id);
|
|
184
|
+
if (backend === "hyperv") return hyperv("stop", { id });
|
|
185
|
+
return virsh(["shutdown", id]);
|
|
186
|
+
},
|
|
187
|
+
async endpoint(id) {
|
|
188
|
+
checkID(id);
|
|
189
|
+
return vncEndpoint(await virsh(["dumpxml", id]));
|
|
190
|
+
},
|
|
191
|
+
async remove(backend, id) {
|
|
192
|
+
checkID(id);
|
|
193
|
+
if (backend === "hyperv") return hyperv("delete", { id });
|
|
194
|
+
const item = managed("kvm", id);
|
|
195
|
+
if (!item) throw Error("Only desktops created by VAMP can be deleted here.");
|
|
196
|
+
const state = (await virsh(["domstate", id])).trim();
|
|
197
|
+
if (state !== "shut off") throw Error("Shut down the VM before deleting it.");
|
|
198
|
+
await virsh(["undefine", id, "--nvram", "--tpm", "--managed-save", "--snapshots-metadata", "--checkpoints-metadata"]);
|
|
199
|
+
fs2.rmSync(item.folder, { recursive: true, force: true });
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
module.exports = { hostBackends, domainInfo, vncEndpoint };
|
|
204
|
+
}
|
|
205
|
+
});
|
|
3
206
|
|
|
4
207
|
// backends/remote_ssh/server.mjs
|
|
5
208
|
import { execFile } from "node:child_process";
|
|
@@ -538,7 +741,7 @@ function toPng(buffer) {
|
|
|
538
741
|
}
|
|
539
742
|
|
|
540
743
|
// backends/remote_ssh/tools.mjs
|
|
541
|
-
var VERSION = "0.1.
|
|
744
|
+
var VERSION = "0.1.9";
|
|
542
745
|
var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
543
746
|
var MAX_SCREENSHOT_BYTES = 12 * 1024 * 1024;
|
|
544
747
|
function assertVm(value) {
|
|
@@ -553,8 +756,12 @@ function positiveNumber(value, fallback, min, max) {
|
|
|
553
756
|
return Math.max(min, Math.min(max, number));
|
|
554
757
|
}
|
|
555
758
|
function compare(version, minimum) {
|
|
556
|
-
const
|
|
557
|
-
|
|
759
|
+
const segments = (value) => String(value ?? "").trim().replace(/^v/i, "").split(".").map((part) => {
|
|
760
|
+
const match = /^\d+/.exec(part);
|
|
761
|
+
return match ? Number(match[0]) : 0;
|
|
762
|
+
});
|
|
763
|
+
const left = segments(version);
|
|
764
|
+
const right = segments(minimum);
|
|
558
765
|
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
559
766
|
const a = left[index] || 0;
|
|
560
767
|
const b = right[index] || 0;
|
|
@@ -661,6 +868,15 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
661
868
|
}
|
|
662
869
|
async function start({ vm }) {
|
|
663
870
|
const target = assertVm(vm);
|
|
871
|
+
if (config.platform === "linux") {
|
|
872
|
+
if (config.backend === "kvm") {
|
|
873
|
+
const active = await vbox(["list", "runningvms"]);
|
|
874
|
+
if (active.ok && active.stdout.trim()) throw new Error("A VirtualBox VM is active. Shut it down before starting KVM (VERR_SVM_IN_USE).");
|
|
875
|
+
} else for (const uri of ["qemu:///session", "qemu:///system"]) {
|
|
876
|
+
const active = await exec("virsh", ["-c", uri, "list", "--name"]);
|
|
877
|
+
if (active.ok && active.stdout.trim()) throw new Error("A KVM VM is active. Shut it down before starting VirtualBox (VERR_SVM_IN_USE).");
|
|
878
|
+
}
|
|
879
|
+
}
|
|
664
880
|
const result = config.backend === "kvm" ? await virsh(["start", target], { timeoutMs: 6e4 }) : await vbox(["startvm", target, "--type", "headless"], { timeoutMs: 9e4 });
|
|
665
881
|
if (!result.ok) throw new Error(`Could not start ${target}: ${detail(result)}`);
|
|
666
882
|
const after = await status({ vm: target }).catch(() => null);
|
|
@@ -674,6 +890,15 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
674
890
|
}
|
|
675
891
|
async function stop({ vm, force = false }) {
|
|
676
892
|
const target = assertVm(vm);
|
|
893
|
+
if (config.platform === "linux") {
|
|
894
|
+
if (config.backend === "kvm") {
|
|
895
|
+
const active = await vbox(["list", "runningvms"]);
|
|
896
|
+
if (active.ok && active.stdout.trim()) throw new Error("A VirtualBox VM is active. Shut it down before starting KVM (VERR_SVM_IN_USE).");
|
|
897
|
+
} else for (const uri of ["qemu:///session", "qemu:///system"]) {
|
|
898
|
+
const active = await exec("virsh", ["-c", uri, "list", "--name"]);
|
|
899
|
+
if (active.ok && active.stdout.trim()) throw new Error("A KVM VM is active. Shut it down before starting VirtualBox (VERR_SVM_IN_USE).");
|
|
900
|
+
}
|
|
901
|
+
}
|
|
677
902
|
const result = config.backend === "kvm" ? await virsh([force ? "destroy" : "shutdown", target], { timeoutMs: 9e4 }) : await vbox(["controlvm", target, force ? "poweroff" : "acpipowerbutton"], { timeoutMs: 6e4 });
|
|
678
903
|
if (!result.ok) throw new Error(`Could not stop ${target}: ${detail(result)}`);
|
|
679
904
|
return {
|
|
@@ -904,7 +1129,7 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
904
1129
|
add("node", "Node.js runtime for this server", compare(nodeVersion, "20.0.0") >= 0 ? "ok" : "warn", `v${nodeVersion}`, compare(nodeVersion, "20.0.0") >= 0 ? void 0 : "Node.js 20 or newer is recommended on the remote host.");
|
|
905
1130
|
const pythonVersion = await exec(config.python, ["-c", 'import sys;print("%d.%d.%d"%sys.version_info[:3])'], { timeoutMs: 15e3 });
|
|
906
1131
|
const python = pythonVersion.ok ? pythonVersion.stdout.trim() : "";
|
|
907
|
-
add("python", "Python for RPA replay", python && compare(python, "3.11.0") >= 0 ? "ok" : python ? "warn" : "missing", python || detail(pythonVersion), python && compare(python, "3.11.0") >= 0 ? void 0 : `Install Python 3.11+ and set remotePython (${config.python}).`);
|
|
1132
|
+
add("python", "Python for RPA replay", python && compare(python, "3.11.0") >= 0 ? "ok" : python ? "warn" : "missing", python || detail(pythonVersion), python && compare(python, "3.11.0") >= 0 ? void 0 : `Install Python 3.11+ (3.15 and newer work too) and set remotePython (${config.python}).`);
|
|
908
1133
|
if (config.backend === "kvm") {
|
|
909
1134
|
const libvirtVersion = await exec("virsh", ["--version"], { timeoutMs: 15e3 });
|
|
910
1135
|
add("virsh", "libvirt client (virsh)", libvirtVersion.ok ? "ok" : "missing", libvirtVersion.ok ? libvirtVersion.stdout.trim() : "virsh not found", libvirtVersion.ok ? void 0 : "Install libvirt-clients / libvirt-client.");
|
|
@@ -971,13 +1196,13 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
971
1196
|
});
|
|
972
1197
|
}
|
|
973
1198
|
record("workdir", "Work directory and server configuration", dry_run ? "planned" : "done", config.workdir);
|
|
974
|
-
const pythonProbe = await exec(config.python, ["-c", 'import sys;print("%d.%d"%sys.version_info[:
|
|
1199
|
+
const pythonProbe = await exec(config.python, ["-c", 'import sys;print("%d.%d.%d"%sys.version_info[:3])'], { timeoutMs: 15e3 });
|
|
975
1200
|
if (!pythonProbe.ok) {
|
|
976
|
-
record("python", "Python 3.11+", "needs_manual", `${config.python} -V`, { fix: "Install Python 3.11 or newer on the remote host, then run setup again." });
|
|
1201
|
+
record("python", "Python 3.11+ (3.15+ supported)", "needs_manual", `${config.python} -V`, { fix: "Install Python 3.11 or newer (3.15 and newer work too) on the remote host, then run setup again." });
|
|
977
1202
|
} else if (compare(pythonProbe.stdout.trim(), "3.11") < 0) {
|
|
978
|
-
record("python", "Python 3.11+", "needs_manual", `${config.python} -V`, { fix: `Detected Python ${pythonProbe.stdout.trim()}. Install 3.11 or newer and set remotePython.` });
|
|
1203
|
+
record("python", "Python 3.11+ (3.15+ supported)", "needs_manual", `${config.python} -V`, { fix: `Detected Python ${pythonProbe.stdout.trim()}. Install 3.11 or newer and set remotePython.` });
|
|
979
1204
|
} else {
|
|
980
|
-
record("python", "Python 3.11+", "ok", `Python ${pythonProbe.stdout.trim()}`);
|
|
1205
|
+
record("python", "Python 3.11+ (3.15+ supported)", "ok", `Python ${pythonProbe.stdout.trim()}`);
|
|
981
1206
|
if (python_venv) {
|
|
982
1207
|
const venv = path2.join(config.workdir, "venv");
|
|
983
1208
|
const exists = await fsx.access(path2.join(venv, config.platform === "win32" ? "Scripts/python.exe" : "bin/python")).then(() => true).catch(() => false);
|
|
@@ -1049,6 +1274,35 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1049
1274
|
next_step: failed.length ? "Read the failed steps. Nothing was removed; fix the reported command and run setup again." : manual.length ? "Some steps need an administrator or a manual install; the rest is ready." : "Remote environment is ready. Verify with remote_env_check."
|
|
1050
1275
|
};
|
|
1051
1276
|
}
|
|
1277
|
+
async function createVm(args = {}) {
|
|
1278
|
+
if (config.backend !== "kvm") throw new Error("VM creation through this host server is KVM-only. Use the VirtualBox vm_create tool for VirtualBox.");
|
|
1279
|
+
if (config.platform !== "linux") throw new Error("KVM creation requires a Linux host.");
|
|
1280
|
+
if (args.confirmed !== true) return { status: "needs_confirmation", vm_created: false, message: "Authorize creation and startup, then pass confirmed:true with a host ISO path." };
|
|
1281
|
+
const guest_os = args.guest_os ?? "debian";
|
|
1282
|
+
if (!["debian", "ubuntu", "windows11"].includes(guest_os)) throw new Error("Unsupported guest_os");
|
|
1283
|
+
if (guest_os === "windows11" && args.windows_confirmed !== true) return { status: "needs_windows_confirmation", vm_created: false, message: "Windows requires your own valid license and explicit windows_confirmed:true." };
|
|
1284
|
+
if (typeof args.name !== "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,62}$/.test(args.name)) throw new Error("Invalid VM name");
|
|
1285
|
+
if (typeof args.iso_path !== "string" || !path2.isAbsolute(args.iso_path)) throw new Error("Choose an absolute host ISO path");
|
|
1286
|
+
const values = { memory_mb: args.memory_mb ?? (guest_os === "windows11" ? 4096 : 2048), cpus: args.cpus ?? 2, disk_mb: args.disk_mb ?? 256e3 };
|
|
1287
|
+
for (const [key, min, max] of [["memory_mb", guest_os === "windows11" ? 4096 : 2048, 131072], ["cpus", 1, 64], ["disk_mb", 32768, 2097152]]) {
|
|
1288
|
+
if (!Number.isInteger(values[key]) || values[key] < min || values[key] > max) throw new Error(`Invalid ${key}: expected integer ${min}..${max}`);
|
|
1289
|
+
}
|
|
1290
|
+
const lifecycle = (await Promise.resolve().then(() => __toESM(require_host_backends(), 1))).default;
|
|
1291
|
+
const adapter = lifecycle.hostBackends({ globalStorageUri: { fsPath: config.workdir } }, {
|
|
1292
|
+
runtime: config.repo || config.workdir,
|
|
1293
|
+
config: () => ({ get: (key) => key === "libvirtUri" ? config.libvirtUri : key === "kvmPythonExecutable" ? config.python : void 0 }),
|
|
1294
|
+
execute: (exe, argv, options) => run(exe, argv, { timeoutMs: options.timeout })
|
|
1295
|
+
});
|
|
1296
|
+
const created = await adapter.create("kvm", { name: args.name, iso_path: args.iso_path, guest_os, installation_mode: args.installation_mode, ...values });
|
|
1297
|
+
return {
|
|
1298
|
+
...created,
|
|
1299
|
+
backend: "kvm",
|
|
1300
|
+
guest_os,
|
|
1301
|
+
os_installation_completed: false,
|
|
1302
|
+
guest_setup_completed: false,
|
|
1303
|
+
next_action: created.installation_mode === "unattended" ? "Debian unattended installation started; verify the guest desktop before declaring completion. Public sandbox login: vboxuser / password123!." : "Complete the OS installer in the guest console. VM startup is not installation completion."
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1052
1306
|
const tools = [
|
|
1053
1307
|
{
|
|
1054
1308
|
name: "remote_env_check",
|
|
@@ -1072,6 +1326,23 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1072
1326
|
},
|
|
1073
1327
|
handler: (args) => envSetup(args)
|
|
1074
1328
|
},
|
|
1329
|
+
{
|
|
1330
|
+
name: "remote_vm_create",
|
|
1331
|
+
title: "Create a KVM VM from a host ISO",
|
|
1332
|
+
description: "KVM only: create and start a new VM using the same provisioner as the VS Code manager. Requires confirmed:true. Debian default; Windows additionally requires windows_confirmed:true and your own license. Debian amd64 installer ISOs default to automatic installation using public sandbox credentials vboxuser/password123!. Ubuntu/Windows are manual; use installation_mode:manual to opt out.",
|
|
1333
|
+
inputSchema: { type: "object", properties: {
|
|
1334
|
+
name: { type: "string", pattern: "^[A-Za-z][A-Za-z0-9_-]{0,62}$" },
|
|
1335
|
+
iso_path: { type: "string", description: "Absolute ISO path on the host running this server" },
|
|
1336
|
+
guest_os: { type: "string", enum: ["debian", "ubuntu", "windows11"], default: "debian" },
|
|
1337
|
+
installation_mode: { type: "string", enum: ["manual", "unattended"] },
|
|
1338
|
+
memory_mb: { type: "integer", minimum: 2048, maximum: 131072 },
|
|
1339
|
+
cpus: { type: "integer", minimum: 1, maximum: 64 },
|
|
1340
|
+
disk_mb: { type: "integer", minimum: 32768, maximum: 2097152 },
|
|
1341
|
+
confirmed: { type: "boolean", default: false },
|
|
1342
|
+
windows_confirmed: { type: "boolean", default: false }
|
|
1343
|
+
}, required: ["name", "iso_path"], additionalProperties: false },
|
|
1344
|
+
handler: (args) => createVm(args)
|
|
1345
|
+
},
|
|
1075
1346
|
{
|
|
1076
1347
|
name: "remote_vm_list",
|
|
1077
1348
|
title: "List remote desktops",
|