vamp-mcp 0.1.8 → 0.1.9
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 +262 -1
- package/runtime/backends/virtualbox/provision.py +46 -11
- package/runtime/backends/virtualbox/server.mjs +15 -1
- package/runtime/scripts/build_debian_installer.py +48 -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 needs Python 3.11+ and `xorriso`.
|
|
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.1.
|
|
25
|
-
npx -y vamp-mcp@0.1.
|
|
26
|
-
npx -y vamp-mcp@0.1.
|
|
27
|
-
npx -y vamp-mcp@0.1.
|
|
24
|
+
npx -y vamp-mcp@0.1.9 virtualbox
|
|
25
|
+
npx -y vamp-mcp@0.1.9 kvm
|
|
26
|
+
npx -y vamp-mcp@0.1.9 library
|
|
27
|
+
npx -y vamp-mcp@0.1.9 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.1.
|
|
42
|
+
"args": ["-y", "vamp-mcp@0.1.9", "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.1.
|
|
58
|
+
args = ["-y", "vamp-mcp@0.1.9", "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.1.
|
|
88
|
+
VAMP_TEST_TARBALL=/tmp/vamp-mcp-0.1.9.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; Debian detection failures can use a prepared preseed installer. It needs `xorriso` and requires `guest_os:"debian"`. Use `installation_mode:"manual"` to install manually.
|
|
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. Installation media is built into a new per-VM directory. 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는 기본으로 자동 설치합니다. Python·xorriso·virt-install·qemu-img를 호스트에 준비하세요. 공개 테스트 계정은 `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,202 @@
|
|
|
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;
|
|
141
|
+
if (mode === "unattended") {
|
|
142
|
+
const python = config().get("kvmPythonExecutable") || config().get("pythonExecutable") || process.env.RPA_HOST_PYTHON || "python3";
|
|
143
|
+
try {
|
|
144
|
+
const result = JSON.parse(await command(python, [path3.join(runtime, "scripts/build_debian_installer.py"), "--source", iso_path, "--output", path3.join(folder, "installer.iso")], 66e4));
|
|
145
|
+
installer = result.iso;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
throw Error(`Debian installer preparation failed. No VM was started; inspect ${folder}. ${error.message}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
fs2.writeFileSync(path3.join(folder, "creation.json"), JSON.stringify({ status: "preparing", name, disk, iso_path }));
|
|
151
|
+
await command("qemu-img", ["create", "-f", "qcow2", disk, `${disk_mb}M`]);
|
|
152
|
+
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"}`, "--disk", `path=${installer},device=cdrom,readonly=on`, "--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`];
|
|
153
|
+
if (guest_os === "windows11") args.push("--boot", "uefi,hd,cdrom", "--tpm", "backend.type=emulator,backend.version=2.0,model=tpm-crb");
|
|
154
|
+
else args.push("--boot", "hd,cdrom");
|
|
155
|
+
try {
|
|
156
|
+
await command("virt-install", args, 18e4);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw Error(`KVM setup failed. Partial setup preserved at ${folder}. ${error.message}`);
|
|
159
|
+
}
|
|
160
|
+
const id = (await virsh(["domuuid", name])).trim();
|
|
161
|
+
checkID(id);
|
|
162
|
+
const state = (await virsh(["domstate", id])).trim();
|
|
163
|
+
if (state !== "running") throw Error(`VM was created but did not start (state: ${state}). Setup is preserved at ${folder}`);
|
|
164
|
+
fs2.writeFileSync(record("kvm", name), JSON.stringify({ id, name, disk, guest_os, installation_mode: mode }));
|
|
165
|
+
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 } } : {} };
|
|
166
|
+
},
|
|
167
|
+
async start(backend, id) {
|
|
168
|
+
checkID(id);
|
|
169
|
+
if (backend === "hyperv") return hyperv("start", { id });
|
|
170
|
+
await ensureNoVirtualBox();
|
|
171
|
+
await virsh(["start", id]);
|
|
172
|
+
const state = (await virsh(["domstate", id])).trim();
|
|
173
|
+
if (state !== "running") throw Error("VM did not reach Running state: " + state);
|
|
174
|
+
return { status: "running", startup_verified: true };
|
|
175
|
+
},
|
|
176
|
+
async stop(backend, id) {
|
|
177
|
+
checkID(id);
|
|
178
|
+
if (backend === "hyperv") return hyperv("stop", { id });
|
|
179
|
+
return virsh(["shutdown", id]);
|
|
180
|
+
},
|
|
181
|
+
async endpoint(id) {
|
|
182
|
+
checkID(id);
|
|
183
|
+
return vncEndpoint(await virsh(["dumpxml", id]));
|
|
184
|
+
},
|
|
185
|
+
async remove(backend, id) {
|
|
186
|
+
checkID(id);
|
|
187
|
+
if (backend === "hyperv") return hyperv("delete", { id });
|
|
188
|
+
const item = managed("kvm", id);
|
|
189
|
+
if (!item) throw Error("Only desktops created by VAMP can be deleted here.");
|
|
190
|
+
const state = (await virsh(["domstate", id])).trim();
|
|
191
|
+
if (state !== "shut off") throw Error("Shut down the VM before deleting it.");
|
|
192
|
+
await virsh(["undefine", id, "--nvram", "--tpm", "--managed-save", "--snapshots-metadata", "--checkpoints-metadata"]);
|
|
193
|
+
fs2.rmSync(item.folder, { recursive: true, force: true });
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
module.exports = { hostBackends, domainInfo, vncEndpoint };
|
|
198
|
+
}
|
|
199
|
+
});
|
|
3
200
|
|
|
4
201
|
// backends/remote_ssh/server.mjs
|
|
5
202
|
import { execFile } from "node:child_process";
|
|
@@ -538,7 +735,7 @@ function toPng(buffer) {
|
|
|
538
735
|
}
|
|
539
736
|
|
|
540
737
|
// backends/remote_ssh/tools.mjs
|
|
541
|
-
var VERSION = "0.1.
|
|
738
|
+
var VERSION = "0.1.9";
|
|
542
739
|
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
740
|
var MAX_SCREENSHOT_BYTES = 12 * 1024 * 1024;
|
|
544
741
|
function assertVm(value) {
|
|
@@ -661,6 +858,15 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
661
858
|
}
|
|
662
859
|
async function start({ vm }) {
|
|
663
860
|
const target = assertVm(vm);
|
|
861
|
+
if (config.platform === "linux") {
|
|
862
|
+
if (config.backend === "kvm") {
|
|
863
|
+
const active = await vbox(["list", "runningvms"]);
|
|
864
|
+
if (active.ok && active.stdout.trim()) throw new Error("A VirtualBox VM is active. Shut it down before starting KVM (VERR_SVM_IN_USE).");
|
|
865
|
+
} else for (const uri of ["qemu:///session", "qemu:///system"]) {
|
|
866
|
+
const active = await exec("virsh", ["-c", uri, "list", "--name"]);
|
|
867
|
+
if (active.ok && active.stdout.trim()) throw new Error("A KVM VM is active. Shut it down before starting VirtualBox (VERR_SVM_IN_USE).");
|
|
868
|
+
}
|
|
869
|
+
}
|
|
664
870
|
const result = config.backend === "kvm" ? await virsh(["start", target], { timeoutMs: 6e4 }) : await vbox(["startvm", target, "--type", "headless"], { timeoutMs: 9e4 });
|
|
665
871
|
if (!result.ok) throw new Error(`Could not start ${target}: ${detail(result)}`);
|
|
666
872
|
const after = await status({ vm: target }).catch(() => null);
|
|
@@ -674,6 +880,15 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
674
880
|
}
|
|
675
881
|
async function stop({ vm, force = false }) {
|
|
676
882
|
const target = assertVm(vm);
|
|
883
|
+
if (config.platform === "linux") {
|
|
884
|
+
if (config.backend === "kvm") {
|
|
885
|
+
const active = await vbox(["list", "runningvms"]);
|
|
886
|
+
if (active.ok && active.stdout.trim()) throw new Error("A VirtualBox VM is active. Shut it down before starting KVM (VERR_SVM_IN_USE).");
|
|
887
|
+
} else for (const uri of ["qemu:///session", "qemu:///system"]) {
|
|
888
|
+
const active = await exec("virsh", ["-c", uri, "list", "--name"]);
|
|
889
|
+
if (active.ok && active.stdout.trim()) throw new Error("A KVM VM is active. Shut it down before starting VirtualBox (VERR_SVM_IN_USE).");
|
|
890
|
+
}
|
|
891
|
+
}
|
|
677
892
|
const result = config.backend === "kvm" ? await virsh([force ? "destroy" : "shutdown", target], { timeoutMs: 9e4 }) : await vbox(["controlvm", target, force ? "poweroff" : "acpipowerbutton"], { timeoutMs: 6e4 });
|
|
678
893
|
if (!result.ok) throw new Error(`Could not stop ${target}: ${detail(result)}`);
|
|
679
894
|
return {
|
|
@@ -1049,6 +1264,35 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1049
1264
|
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
1265
|
};
|
|
1051
1266
|
}
|
|
1267
|
+
async function createVm(args = {}) {
|
|
1268
|
+
if (config.backend !== "kvm") throw new Error("VM creation through this host server is KVM-only. Use the VirtualBox vm_create tool for VirtualBox.");
|
|
1269
|
+
if (config.platform !== "linux") throw new Error("KVM creation requires a Linux host.");
|
|
1270
|
+
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." };
|
|
1271
|
+
const guest_os = args.guest_os ?? "debian";
|
|
1272
|
+
if (!["debian", "ubuntu", "windows11"].includes(guest_os)) throw new Error("Unsupported guest_os");
|
|
1273
|
+
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." };
|
|
1274
|
+
if (typeof args.name !== "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,62}$/.test(args.name)) throw new Error("Invalid VM name");
|
|
1275
|
+
if (typeof args.iso_path !== "string" || !path2.isAbsolute(args.iso_path)) throw new Error("Choose an absolute host ISO path");
|
|
1276
|
+
const values = { memory_mb: args.memory_mb ?? (guest_os === "windows11" ? 4096 : 2048), cpus: args.cpus ?? 2, disk_mb: args.disk_mb ?? 256e3 };
|
|
1277
|
+
for (const [key, min, max] of [["memory_mb", guest_os === "windows11" ? 4096 : 2048, 131072], ["cpus", 1, 64], ["disk_mb", 32768, 2097152]]) {
|
|
1278
|
+
if (!Number.isInteger(values[key]) || values[key] < min || values[key] > max) throw new Error(`Invalid ${key}: expected integer ${min}..${max}`);
|
|
1279
|
+
}
|
|
1280
|
+
const lifecycle = (await Promise.resolve().then(() => __toESM(require_host_backends(), 1))).default;
|
|
1281
|
+
const adapter = lifecycle.hostBackends({ globalStorageUri: { fsPath: config.workdir } }, {
|
|
1282
|
+
runtime: config.repo || config.workdir,
|
|
1283
|
+
config: () => ({ get: (key) => key === "libvirtUri" ? config.libvirtUri : key === "kvmPythonExecutable" ? config.python : void 0 }),
|
|
1284
|
+
execute: (exe, argv, options) => run(exe, argv, { timeoutMs: options.timeout })
|
|
1285
|
+
});
|
|
1286
|
+
const created = await adapter.create("kvm", { name: args.name, iso_path: args.iso_path, guest_os, installation_mode: args.installation_mode, ...values });
|
|
1287
|
+
return {
|
|
1288
|
+
...created,
|
|
1289
|
+
backend: "kvm",
|
|
1290
|
+
guest_os,
|
|
1291
|
+
os_installation_completed: false,
|
|
1292
|
+
guest_setup_completed: false,
|
|
1293
|
+
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."
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1052
1296
|
const tools = [
|
|
1053
1297
|
{
|
|
1054
1298
|
name: "remote_env_check",
|
|
@@ -1072,6 +1316,23 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1072
1316
|
},
|
|
1073
1317
|
handler: (args) => envSetup(args)
|
|
1074
1318
|
},
|
|
1319
|
+
{
|
|
1320
|
+
name: "remote_vm_create",
|
|
1321
|
+
title: "Create a KVM VM from a host ISO",
|
|
1322
|
+
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.",
|
|
1323
|
+
inputSchema: { type: "object", properties: {
|
|
1324
|
+
name: { type: "string", pattern: "^[A-Za-z][A-Za-z0-9_-]{0,62}$" },
|
|
1325
|
+
iso_path: { type: "string", description: "Absolute ISO path on the host running this server" },
|
|
1326
|
+
guest_os: { type: "string", enum: ["debian", "ubuntu", "windows11"], default: "debian" },
|
|
1327
|
+
installation_mode: { type: "string", enum: ["manual", "unattended"] },
|
|
1328
|
+
memory_mb: { type: "integer", minimum: 2048, maximum: 131072 },
|
|
1329
|
+
cpus: { type: "integer", minimum: 1, maximum: 64 },
|
|
1330
|
+
disk_mb: { type: "integer", minimum: 32768, maximum: 2097152 },
|
|
1331
|
+
confirmed: { type: "boolean", default: false },
|
|
1332
|
+
windows_confirmed: { type: "boolean", default: false }
|
|
1333
|
+
}, required: ["name", "iso_path"], additionalProperties: false },
|
|
1334
|
+
handler: (args) => createVm(args)
|
|
1335
|
+
},
|
|
1075
1336
|
{
|
|
1076
1337
|
name: "remote_vm_list",
|
|
1077
1338
|
title: "List remote desktops",
|
|
@@ -8,12 +8,14 @@ import re
|
|
|
8
8
|
import shutil
|
|
9
9
|
import subprocess
|
|
10
10
|
import sys
|
|
11
|
+
import time
|
|
11
12
|
import uuid
|
|
12
13
|
|
|
13
14
|
ROOT=Path(__file__).resolve().parents[2]
|
|
14
15
|
sys.path.insert(0,str(ROOT/'scripts'))
|
|
15
16
|
sys.path.insert(0,str(Path(__file__).resolve().parent))
|
|
16
17
|
from build_recorder_media import build
|
|
18
|
+
from build_debian_installer import build as build_debian_installer
|
|
17
19
|
|
|
18
20
|
PUBLIC_CREDENTIALS={'username':'vboxuser','password':'password123!','public_sandbox_credentials':True}
|
|
19
21
|
|
|
@@ -28,7 +30,17 @@ def executable():
|
|
|
28
30
|
if candidate.is_file():return str(candidate)
|
|
29
31
|
return shutil.which('VBoxManage') or 'VBoxManage'
|
|
30
32
|
|
|
31
|
-
def
|
|
33
|
+
def assert_no_active_kvm():
|
|
34
|
+
if not sys.platform.startswith('linux'):return
|
|
35
|
+
for uri in ('qemu:///session','qemu:///system'):
|
|
36
|
+
try:
|
|
37
|
+
result=subprocess.run(['virsh','-c',uri,'list','--name'],capture_output=True,text=True,timeout=10)
|
|
38
|
+
except (FileNotFoundError,subprocess.TimeoutExpired):continue
|
|
39
|
+
if result.returncode==0 and result.stdout.strip():
|
|
40
|
+
raise RuntimeError('A KVM VM is active. Shut it down before starting VirtualBox; simultaneous execution can cause VERR_SVM_IN_USE.')
|
|
41
|
+
|
|
42
|
+
def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None,image_index=1,product_key='',windows_confirmed=False,guest_os=None,preflight_only=False,allow_manual_install=False,installation_mode="auto"):
|
|
43
|
+
if installation_mode not in ('auto','manual'):raise ValueError('installation_mode must be auto or manual')
|
|
32
44
|
name=name or ('VAMP-'+uuid.uuid4().hex[:8])
|
|
33
45
|
if not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9_-]{0,63}',name):raise ValueError('Use 1-64 letters/digits/underscore/hyphen for name')
|
|
34
46
|
iso=Path(iso_path).expanduser().resolve(strict=True)
|
|
@@ -52,10 +64,12 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
52
64
|
if not (re.fullmatch(r'Debian[0-9]*_64',os_type) or re.fullmatch(r'Ubuntu[0-9]*_64',os_type) or os_type=='Windows11_64'):
|
|
53
65
|
raise ValueError(f'Only detected Debian/Ubuntu amd64 or Windows11 x64 ISO supported by this initial profile: {os_type or "unknown"}')
|
|
54
66
|
unattended_supported=detected.get('IsInstallSupported',detected.get('isInstallSupported','true')).lower() in ('true','1','yes','on')
|
|
67
|
+
if installation_mode=='manual':unattended_supported=False
|
|
55
68
|
if not unattended_supported and not allow_manual_install:
|
|
56
69
|
raise ValueError('VirtualBox reports this ISO does not support unattended installation')
|
|
57
70
|
selected='windows11' if os_type=='Windows11_64' else ('ubuntu' if os_type.startswith('Ubuntu') else 'debian')
|
|
58
71
|
if guest_os and guest_os!=selected:raise ValueError('Selected guest OS does not match detected ISO')
|
|
72
|
+
custom_debian=not unattended_supported and selected=='debian' and installation_mode!='manual'
|
|
59
73
|
profile=json.loads(Path(__file__).with_name('profiles.json').read_text())['profiles'][selected]
|
|
60
74
|
memory_mb=memory_mb if memory_mb is not None else profile['memory_mb']
|
|
61
75
|
cpus=cpus if cpus is not None else profile['cpus']
|
|
@@ -66,7 +80,7 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
66
80
|
return {'status':'preflight_ready','vm_created':False,'guest_os':selected,
|
|
67
81
|
'resource_profile':{'memory_mb':memory_mb,'cpus':cpus,'disk_mb':disk_mb},
|
|
68
82
|
'windows_confirmation_required':selected=='windows11' and not windows_confirmed,
|
|
69
|
-
'installation_mode':'unattended' if unattended_supported else 'manual',
|
|
83
|
+
'installation_mode':'unattended' if unattended_supported or custom_debian else 'manual',
|
|
70
84
|
'credentials':PUBLIC_CREDENTIALS,'iso':str(iso)}
|
|
71
85
|
if selected=='windows11' and not windows_confirmed:
|
|
72
86
|
return {'status':'needs_windows_confirmation','no_vm_created':True,'profile':profile,
|
|
@@ -82,14 +96,30 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
82
96
|
help_proc=subprocess.run([executable(),'unattended','install','--help'],capture_output=True,text=True)
|
|
83
97
|
help_text=help_proc.stdout+help_proc.stderr
|
|
84
98
|
password_flag='--user-password' if '--user-password' in help_text else '--password'
|
|
99
|
+
assert_no_active_kvm()
|
|
85
100
|
folder.mkdir(parents=True,exist_ok=False)
|
|
86
101
|
journal_path=folder/'vamp-install.json'
|
|
102
|
+
def start_verified():
|
|
103
|
+
# startvm waits for its session to open; still verify the hypervisor state.
|
|
104
|
+
run('startvm',name,'--type','headless')
|
|
105
|
+
state=''
|
|
106
|
+
for attempt in range(15):
|
|
107
|
+
state=parse(run('showvminfo',name,'--machinereadable')).get('VMState','unknown')
|
|
108
|
+
if state=='running':
|
|
109
|
+
journal.update(vm_state=state,startup_verified=True)
|
|
110
|
+
return
|
|
111
|
+
if state not in ('starting','restoring'):break
|
|
112
|
+
time.sleep(1)
|
|
113
|
+
raise RuntimeError(f'VM creation completed but startup was not verified (state: {state}); inspect the VM log')
|
|
87
114
|
def record(stage):
|
|
88
115
|
journal['events'].append(stage)
|
|
89
116
|
journal_path.write_text(json.dumps(journal,indent=2)+'\n')
|
|
90
117
|
try:
|
|
91
118
|
media=build(folder/'recorder-setup.iso')
|
|
92
119
|
record('recorder-media-built')
|
|
120
|
+
if custom_debian:
|
|
121
|
+
iso=Path(build_debian_installer(iso,folder/'debian-installer.iso')['iso'])
|
|
122
|
+
record('debian-installer-prepared')
|
|
93
123
|
run('createvm','--name',name,'--ostype',os_type,'--register','--basefolder',folder.parent)
|
|
94
124
|
record('vm-created')
|
|
95
125
|
from display import preferences
|
|
@@ -97,8 +127,11 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
97
127
|
from shares import prepare
|
|
98
128
|
journal['recording_share']=prepare(name,run)
|
|
99
129
|
options=['modifyvm',name,'--memory',memory_mb,'--cpus',cpus,'--vram',128,
|
|
100
|
-
'--mouse','usbtablet','--nic1','nat','--boot1','dvd','--boot2','disk',
|
|
130
|
+
'--mouse','usbtablet','--nic1','nat','--boot1','disk' if custom_debian else 'dvd','--boot2','dvd' if custom_debian else 'disk',
|
|
101
131
|
'--graphicscontroller','vboxsvga' if os_type=='Windows11_64' else 'vmsvga']
|
|
132
|
+
if custom_debian:
|
|
133
|
+
journal['serial_log']=str(folder/'serial.log')
|
|
134
|
+
options+=['--uart1','0x3F8',4,'--uartmode1','file',folder/'serial.log']
|
|
102
135
|
if os_type=='Windows11_64':options+=['--firmware','efi','--tpm-type','2.0','--ioapic','on']
|
|
103
136
|
run(*options)
|
|
104
137
|
disk=folder/(name+'.vdi')
|
|
@@ -108,12 +141,13 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
108
141
|
run('storagectl',name,'--name','IDE','--add','ide')
|
|
109
142
|
if not unattended_supported:
|
|
110
143
|
run('storageattach',name,'--storagectl','SATA','--port','1','--device','0','--type','dvddrive','--medium',iso)
|
|
111
|
-
|
|
112
|
-
journal.update(status='installation_started',installation_mode='manual',os_type=os_type,
|
|
113
|
-
frontend='
|
|
114
|
-
credentials={'public_sandbox_credentials':False,'account_setup':'Choose your account in the OS installer'},
|
|
115
|
-
action_required='This ISO needs manual installation. Follow the installer in the VM screen. Choose your own guest account; automatic recorder setup has not run.')
|
|
116
|
-
|
|
144
|
+
start_verified()
|
|
145
|
+
journal.update(status='installation_started',installation_mode='unattended' if custom_debian else 'manual',os_type=os_type,
|
|
146
|
+
frontend='headless',journal=str(journal_path),
|
|
147
|
+
credentials=PUBLIC_CREDENTIALS if custom_debian else {'public_sandbox_credentials':False,'account_setup':'Choose your account in the OS installer'},
|
|
148
|
+
action_required='Debian unattended installation started with a single installation DVD. Recorder media was built but is not attached; install it after the OS is ready.' if custom_debian else 'This ISO needs manual installation. Follow the installer in the VM screen. Choose your own guest account; automatic recorder setup has not run.')
|
|
149
|
+
if custom_debian:journal.update(recorder_media=media['iso'],recorder_media_attached=False)
|
|
150
|
+
record('unattended-installation-started' if custom_debian else 'manual-installation-started')
|
|
117
151
|
return journal
|
|
118
152
|
# Recorder media stays on a dedicated DVD; unattended owns its own installer/auxiliary slots.
|
|
119
153
|
run('storageattach',name,'--storagectl','SATA','--port','3','--device','0','--type','dvddrive','--medium',media['iso'])
|
|
@@ -125,12 +159,13 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
125
159
|
hook="sh -c 'mkdir -p /tmp/vamp-recorder; for d in /dev/sr*; do mount -o ro \"$d\" /tmp/vamp-recorder 2>/dev/null || continue; if [ -f /tmp/vamp-recorder/postdeb.sh ]; then sh /tmp/vamp-recorder/postdeb.sh; exit $?; fi; umount /tmp/vamp-recorder; done; exit 1'"
|
|
126
160
|
args=['unattended','install',name,'--iso',iso,'--user','vboxuser',password_flag,'password123!',
|
|
127
161
|
'--full-user-name','VAMP Sandbox User','--hostname',name.lower()+'.vamp.local',
|
|
128
|
-
'--no-install-additions','--post-install-command',hook
|
|
162
|
+
'--no-install-additions','--post-install-command',hook]
|
|
129
163
|
if os_type=='Windows11_64':
|
|
130
164
|
args+=['--image-index',image_index]
|
|
131
165
|
if product_key:args+=['--key',product_key]
|
|
132
166
|
run(*args,timeout=300)
|
|
133
|
-
|
|
167
|
+
start_verified()
|
|
168
|
+
journal.update(status='installation_started',installation_mode='unattended',os_type=os_type,frontend='headless',
|
|
134
169
|
recorder_setup='Debian postinstall; Windows first desktop login',
|
|
135
170
|
requires_ai_loop=False,journal=str(journal_path))
|
|
136
171
|
record('unattended-installation-started')
|
|
@@ -37058,7 +37058,7 @@ var StdioServerTransport = class {
|
|
|
37058
37058
|
// backends/virtualbox/server.mjs
|
|
37059
37059
|
config2.mouseHelperPath = process.env.MOUSE_HELPER_PATH || fileURLToPath2(new URL("./mouse_click.py", import.meta.url));
|
|
37060
37060
|
config2.pythonPath = process.env.PYTHON_PATH || process.env.RPA_HOST_PYTHON || (process.platform === "win32" ? "python" : "python3");
|
|
37061
|
-
var server = new McpServer({ name: "VAMP", version: "0.1.
|
|
37061
|
+
var server = new McpServer({ name: "VAMP", version: "0.1.9" }, { instructions: "Before repeated CUA or multimodal analysis, use VAMP RPA Library rpa_search/rpa_details to find suitable reviewed skills. Prefer an authorized compatible skill; read its compact result before requesting screenshots, and verify application outcomes. Token efficiency: run reusable RPA and outcome checks locally; on success return compact status, verification and evidence paths. Do not forward full OCR text, YOLO arrays, unchanged screenshots, base64 images, full logs or source into the model context by default. For failure, ambiguity, UI changes or requested inspection, read only a targeted region/query/page first. Local OCR/YOLO reduces model tokens only when outputs stay local or compact; do not claim a measured saving without a comparable benchmark. When authoring or repairing GUI RPAs, include task-specific local OCR/YOLO verification in Python and assert its result in Robot by default; add artifact checks when available. Input dispatch or an arbitrary detection alone is not success. Fall back to targeted CUA when needed. For first-time setup call vamp_setup. Ask whether to set up the VM environment and obtain a host ISO path. Ask once each session whether to take a snapshot, explain space use, and never assume consent. Debian is default; ask explicitly before Windows and disclose licensing and public sandbox credentials. Do not create a VM merely on server startup." });
|
|
37062
37062
|
var result = (value) => ({ content: [{ type: "text", text: JSON.stringify(value) }] });
|
|
37063
37063
|
async function displayAction(action, values) {
|
|
37064
37064
|
const python = process.env.RPA_HOST_PYTHON || "python";
|
|
@@ -37271,7 +37271,19 @@ server.tool("vm_start", "Explicitly start an existing VM with detachable observa
|
|
|
37271
37271
|
if (!["poweroff", "saved", "aborted"].includes(state)) throw new Error(`Cannot start VM in state ${state}`);
|
|
37272
37272
|
const display = await displayAction("configure", { vm });
|
|
37273
37273
|
const recording_share = state === "saved" ? null : await prepareShareOnStart(vm);
|
|
37274
|
+
if (process.platform === "linux") {
|
|
37275
|
+
for (const uri of ["qemu:///session", "qemu:///system"]) {
|
|
37276
|
+
let active = "";
|
|
37277
|
+
try {
|
|
37278
|
+
active = (await promisify(execFile3)("virsh", ["-c", uri, "list", "--name"], { timeout: 1e4 })).stdout;
|
|
37279
|
+
} catch {
|
|
37280
|
+
}
|
|
37281
|
+
if (active.trim()) throw new Error("A KVM VM is active. Shut it down before starting VirtualBox (VERR_SVM_IN_USE).");
|
|
37282
|
+
}
|
|
37283
|
+
}
|
|
37274
37284
|
await vboxManage("startvm", vm, "--type", type);
|
|
37285
|
+
const started = parseMachineReadable(await vboxManage("showvminfo", vm, "--machinereadable")).VMState;
|
|
37286
|
+
if (started !== "running") throw new Error("VM did not reach Running state: " + started);
|
|
37275
37287
|
return result({ status: "start_requested", vm, type, display, recording_share, guest_ready_verified: false });
|
|
37276
37288
|
});
|
|
37277
37289
|
registerDisplayTools(server);
|
|
@@ -37286,6 +37298,8 @@ server.tool("vm_create", "Create a NEW Debian/Windows11 VM from a host ISO, star
|
|
|
37286
37298
|
image_index: external_exports.number().int().default(1),
|
|
37287
37299
|
product_key: external_exports.string().default(""),
|
|
37288
37300
|
guest_os: external_exports.enum(["debian", "windows11", "ubuntu"]).optional(),
|
|
37301
|
+
allow_manual_install: external_exports.boolean().default(true),
|
|
37302
|
+
installation_mode: external_exports.enum(["auto", "manual"]).default("auto"),
|
|
37289
37303
|
windows_confirmed: external_exports.boolean().default(false),
|
|
37290
37304
|
preflight_only: external_exports.boolean().default(false)
|
|
37291
37305
|
}, async (args) => {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Create an unattended Debian amd64 BIOS installer without modifying the source ISO."""
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
9
|
+
CREDENTIALS = {'username': 'vboxuser', 'password': 'password123!', 'public_sandbox_credentials': True}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def build(source, output):
|
|
13
|
+
source = Path(source).expanduser().resolve(strict=True)
|
|
14
|
+
output = Path(output).expanduser().resolve()
|
|
15
|
+
if not source.is_file() or source == output or output.exists():
|
|
16
|
+
raise ValueError('Choose a readable source ISO and a new output path')
|
|
17
|
+
preseed = ROOT / 'backends/kvm/debian-preseed.cfg'
|
|
18
|
+
if not preseed.is_file():
|
|
19
|
+
raise ValueError('Packaged Debian preseed file is missing')
|
|
20
|
+
def run(args):
|
|
21
|
+
try:
|
|
22
|
+
result = subprocess.run(['xorriso', *map(str, args)], capture_output=True, text=True, timeout=600)
|
|
23
|
+
except FileNotFoundError as error:
|
|
24
|
+
raise RuntimeError('Install xorriso on the VM host for Debian automatic installation, or choose manual installation') from error
|
|
25
|
+
if result.returncode:
|
|
26
|
+
raise RuntimeError('Debian installer preparation failed: ' + result.stderr[-1500:])
|
|
27
|
+
return result
|
|
28
|
+
# Fail before creating a VM/disk if this is not the supported Debian installer layout.
|
|
29
|
+
run(['-indev', source, '-ls', '/install.amd/vmlinuz', '/install.amd/initrd.gz', '/isolinux/isolinux.bin'])
|
|
30
|
+
output.parent.mkdir(parents=True, exist_ok=True)
|
|
31
|
+
menu = output.with_suffix('.isolinux.cfg')
|
|
32
|
+
menu.write_text('default vamp\nprompt 0\ntimeout 10\nlabel vamp\n kernel /install.amd/vmlinuz\n append initrd=/install.amd/initrd.gz auto=true priority=critical preseed/file=/cdrom/preseed.cfg console=tty0 --- quiet\n')
|
|
33
|
+
result = run(['-indev', source, '-outdev', output, '-boot_image', 'any', 'replay',
|
|
34
|
+
'-map', preseed, '/preseed.cfg', '-map', menu, '/isolinux/isolinux.cfg'])
|
|
35
|
+
output.with_suffix('.build.log').write_text(result.stdout + '\n' + result.stderr)
|
|
36
|
+
return {'status': 'media_built', 'iso': str(output), 'credentials': CREDENTIALS,
|
|
37
|
+
'installation_verified': False, 'recorder_installed_verified': False}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if __name__ == '__main__':
|
|
41
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
42
|
+
parser.add_argument('--source', required=True)
|
|
43
|
+
parser.add_argument('--output', required=True)
|
|
44
|
+
args = parser.parse_args()
|
|
45
|
+
try:
|
|
46
|
+
print(json.dumps(build(args.source, args.output)))
|
|
47
|
+
except (OSError, ValueError, RuntimeError, subprocess.TimeoutExpired) as error:
|
|
48
|
+
parser.exit(1, str(error) + '\n')
|