vamp-mcp 0.1.9 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +142 -107
- package/THIRD_PARTY_NOTICES.md +32 -27
- package/bin/vamp-mcp.mjs +37 -37
- package/notices/mcp-virtualbox-LICENSE +21 -21
- package/notices/mcp-virtualbox-PROVENANCE.json +37 -37
- package/package.json +51 -17
- package/runtime/backends/common/Test-Environment.ps1 +7 -6
- package/runtime/backends/common/guest-install.json +58 -0
- package/runtime/backends/common/guest_install.py +57 -0
- package/runtime/backends/common/host-support.cjs +16 -0
- package/runtime/backends/common/packer.cjs +16 -0
- package/runtime/backends/hyperv/scripts/Manage-Desktop.ps1 +40 -67
- package/runtime/backends/hyperv/scripts/Send-InstallerBoot.ps1 +25 -0
- package/runtime/backends/kvm/debian-preseed.cfg +35 -35
- package/runtime/backends/library/registry.py +77 -77
- package/runtime/backends/library/replay.py +154 -154
- package/runtime/backends/packer/answer_media.py +16 -0
- package/runtime/backends/packer/deploy-hyperv.ps1 +10 -0
- package/runtime/backends/packer/drivers.py +49 -0
- package/runtime/backends/packer/hyperv-network.ps1 +10 -0
- package/runtime/backends/packer/images.py +75 -0
- package/runtime/backends/packer/osinfo.py +113 -0
- package/runtime/backends/packer/policy.json +15 -0
- package/runtime/backends/packer/runner.py +224 -0
- package/runtime/backends/packer/templates.py +118 -0
- package/runtime/backends/packer/toolchain.py +80 -0
- package/runtime/backends/remote_ssh/server.mjs +321 -94
- package/runtime/backends/virtualbox/desktop.cjs +37 -0
- package/runtime/backends/virtualbox/display.py +101 -101
- package/runtime/backends/virtualbox/history.py +139 -139
- package/runtime/backends/virtualbox/mouse_click.py +15 -15
- package/runtime/backends/virtualbox/mouse_move.py +18 -18
- package/runtime/backends/virtualbox/profiles.json +46 -46
- package/runtime/backends/virtualbox/provision.py +238 -184
- package/runtime/backends/virtualbox/recording_listener.py +29 -29
- package/runtime/backends/virtualbox/recordings.py +39 -39
- package/runtime/backends/virtualbox/requirements.txt +7 -7
- package/runtime/backends/virtualbox/rpas/debian_first_boot/manifest.json +1 -1
- package/runtime/backends/virtualbox/rpas/debian_first_boot/run.robot +13 -13
- package/runtime/backends/virtualbox/rpas/debian_first_boot/workflow.py +75 -75
- package/runtime/backends/virtualbox/rpas/observe/manifest.json +7 -7
- package/runtime/backends/virtualbox/rpas/observe/run.robot +13 -13
- package/runtime/backends/virtualbox/rpas/observe/workflow.py +14 -14
- package/runtime/backends/virtualbox/server.mjs +440 -63
- package/runtime/backends/virtualbox/setup_windows_sdk.py +58 -58
- package/runtime/backends/virtualbox/shares.py +68 -68
- package/runtime/backends/virtualbox/snapshots.py +53 -53
- package/runtime/backends/virtualbox/transfers.py +89 -89
- package/runtime/backends/virtualbox/vnc.py +61 -61
- package/runtime/guest_keys.py +13 -13
- package/runtime/guest_setup/http/debian-preseed.cfg +39 -0
- package/runtime/guest_setup/http/postdeb.sh +94 -0
- package/runtime/guest_setup/http/postwin.ps1 +53 -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 +44 -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 +12 -8
- package/runtime/guest_setup/recorder/RECORDER-LICENSE +674 -674
- package/runtime/guest_setup/recorder/RECORDING-GUIDE.txt +31 -31
- package/runtime/guest_setup/recorder/apply-display.py +41 -41
- package/runtime/guest_setup/recorder/configure-debian-mirrors.py +62 -62
- package/runtime/guest_setup/recorder/configure-gdm.py +23 -0
- package/runtime/guest_setup/recorder/configure-session.ps1 +14 -0
- package/runtime/guest_setup/recorder/gnome-display.py +60 -60
- package/runtime/guest_setup/recorder/install-display-startup.py +66 -39
- package/runtime/guest_setup/recorder/install-hypervisor-drivers.ps1 +34 -0
- package/runtime/guest_setup/recorder/install-resolution-shortcut.ps1 +36 -0
- package/runtime/guest_setup/recorder/postwin.cmd +10 -10
- package/runtime/guest_setup/recorder/prepare-recording.py +30 -30
- package/runtime/guest_setup/recorder/recorder.zip +0 -0
- package/runtime/guest_setup/recorder/requirements-recorder.txt +2 -2
- package/runtime/guest_setup/recorder/session-policy.py +22 -0
- package/runtime/guest_setup/recorder/setup-user.py +53 -35
- package/runtime/guest_setup/recorder/setup-win.cmd +4 -11
- package/runtime/guest_setup/recorder/setup.ps1 +108 -30
- package/runtime/guest_setup/recorder/setup.sh +19 -1
- package/runtime/guest_setup/recorder/vamp-recorder.py +148 -148
- package/runtime/guest_setup/recorder/verify-recorder.py +4 -4
- package/runtime/guest_setup/recorder/windows-display.py +76 -76
- 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/recording_converter.py +230 -230
- package/runtime/requirements-mcp.txt +11 -11
- package/runtime/rpas/README.md +161 -161
- package/runtime/rpas/captcha_handoff/manifest.json +27 -27
- package/runtime/rpas/captcha_handoff/run.robot +16 -16
- package/runtime/rpas/captcha_handoff/workflow.py +11 -11
- package/runtime/rpas/common.resource +26 -26
- package/runtime/rpas/debian_update/manifest.json +27 -27
- package/runtime/rpas/debian_update/run.robot +17 -17
- package/runtime/rpas/debian_update/workflow.py +13 -13
- package/runtime/rpas/desktop_control/manifest.json +26 -26
- package/runtime/rpas/desktop_control/run.robot +27 -27
- package/runtime/rpas/desktop_control/workflow.py +51 -51
- package/runtime/rpas/firefox_launch/manifest.json +27 -27
- package/runtime/rpas/firefox_launch/run.robot +15 -15
- package/runtime/rpas/firefox_launch/workflow.py +25 -25
- package/runtime/rpas/firefox_naver/manifest.json +27 -27
- package/runtime/rpas/firefox_naver/run.robot +21 -21
- package/runtime/rpas/firefox_naver/workflow.py +28 -28
- package/runtime/rpas/kvm_validation/README.md +11 -11
- package/runtime/rpas/kvm_validation/manifest.json +28 -28
- package/runtime/rpas/kvm_validation/run.robot +30 -30
- package/runtime/rpas/kvm_validation/workflow.py +91 -91
- package/runtime/rpas/manifest.schema.json +105 -105
- package/runtime/rpas/naver_login/login.robot +25 -25
- package/runtime/rpas/naver_login/manifest.json +33 -33
- package/runtime/rpas/naver_login/run.robot +20 -20
- package/runtime/rpas/naver_login/workflow.py +32 -32
- package/runtime/rpas/windows_naver_recorded/README.md +24 -24
- package/runtime/rpas/windows_naver_recorded/conversion.json +25 -25
- package/runtime/rpas/windows_naver_recorded/manifest.json +28 -28
- package/runtime/rpas/windows_naver_recorded/run.robot +37 -37
- package/runtime/rpas/windows_naver_recorded/workflow.py +32 -32
- package/runtime/scripts/build_recorder_media.py +39 -39
- package/runtime/scripts/macos/setup-host.sh +126 -0
- package/runtime/scripts/remote_host_setup.sh +7 -4
- package/runtime/scripts/script_server.py +571 -0
- package/runtime/skills/vamp-rpa-ui-checks/SKILL.md +26 -0
- package/runtime/skills/vamp-rpa-ui-checks/agents/openai.yaml +4 -0
- package/runtime/skills/vamp-rpa-ui-checks/references/display.md +12 -0
- package/runtime/skills/vamp-rpa-ui-checks/references/user-guide.md +49 -0
- package/runtime/skills/vamp-ui-cleanup/SKILL.md +15 -0
- package/runtime/skills/vamp-ui-cleanup/agents/openai.yaml +4 -0
- package/runtime/skills/vamp-ui-validation/SKILL.md +27 -0
- package/runtime/skills/vamp-ui-validation/agents/openai.yaml +4 -0
- package/runtime/third_party/mcp-virtualbox/scripts/mouse_click.py +65 -65
- package/runtime/third_party/pyautogui-recorder/LICENSE +674 -674
- package/runtime/third_party/pyautogui-recorder/PROVENANCE.json +16 -16
- package/runtime/third_party/pyautogui-recorder/PyAutoGuiRecorder.py +169 -169
- package/runtime/third_party/pyautogui-recorder/README.md +53 -53
- package/runtime/scripts/build_debian_installer.py +0 -48
|
@@ -32,9 +32,125 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
// backends/common/
|
|
36
|
-
var
|
|
37
|
-
"backends/common/
|
|
35
|
+
// backends/common/guest-install.json
|
|
36
|
+
var require_guest_install = __commonJS({
|
|
37
|
+
"backends/common/guest-install.json"(exports, module) {
|
|
38
|
+
module.exports = {
|
|
39
|
+
schema_version: 1,
|
|
40
|
+
boot_wait_seconds: 10,
|
|
41
|
+
script_server_port: 8421,
|
|
42
|
+
hosts: {
|
|
43
|
+
virtualbox: [
|
|
44
|
+
"win32",
|
|
45
|
+
"linux",
|
|
46
|
+
"darwin"
|
|
47
|
+
],
|
|
48
|
+
hyperv: [
|
|
49
|
+
"win32"
|
|
50
|
+
],
|
|
51
|
+
kvm: [
|
|
52
|
+
"linux"
|
|
53
|
+
],
|
|
54
|
+
"apple-hypervisor": [
|
|
55
|
+
"darwin"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
amd64_install_host_arches: [
|
|
59
|
+
"x64",
|
|
60
|
+
"AMD64",
|
|
61
|
+
"x86_64"
|
|
62
|
+
],
|
|
63
|
+
debian: {
|
|
64
|
+
cfg: "debian-preseed.cfg",
|
|
65
|
+
efi_boot: [
|
|
66
|
+
{
|
|
67
|
+
kind: "text",
|
|
68
|
+
text: "c"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
kind: "wait",
|
|
72
|
+
seconds: 1
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
kind: "line",
|
|
76
|
+
text: "linux /install.amd/vmlinuz auto=true priority=critical preseed/url={base_url}/debian-preseed.cfg vamp_base={base_url} --- quiet"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
kind: "line",
|
|
80
|
+
text: "initrd /install.amd/initrd.gz"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
kind: "line",
|
|
84
|
+
text: "boot"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
windows11: {
|
|
89
|
+
efi_boot: [
|
|
90
|
+
{
|
|
91
|
+
kind: "enter"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// backends/common/host-support.cjs
|
|
100
|
+
var require_host_support = __commonJS({
|
|
101
|
+
"backends/common/host-support.cjs"(exports, module) {
|
|
102
|
+
var profile = require_guest_install();
|
|
103
|
+
function requireBackendHost(backend, platform = process.platform) {
|
|
104
|
+
if (!profile.hosts[backend]?.includes(platform)) throw Error(`${backend} local management is unsupported on ${platform}`);
|
|
105
|
+
}
|
|
106
|
+
function requireInstallHost(backend, platform = process.platform, architecture = process.arch) {
|
|
107
|
+
requireBackendHost(backend, platform);
|
|
108
|
+
if (!profile.amd64_install_host_arches.includes(architecture)) throw Error(`Current amd64 installer profiles require an x64 host; ${architecture} is unsupported`);
|
|
109
|
+
}
|
|
110
|
+
function backendCapabilities(platform = process.platform) {
|
|
111
|
+
return Object.fromEntries(Object.entries(profile.hosts).map(([backend, hosts]) => [backend, {
|
|
112
|
+
hostSupported: hosts.includes(platform),
|
|
113
|
+
implemented: backend !== "apple-hypervisor",
|
|
114
|
+
reason: !hosts.includes(platform) ? "unsupported_host" : backend === "apple-hypervisor" ? "not_implemented" : null
|
|
115
|
+
}]));
|
|
116
|
+
}
|
|
117
|
+
module.exports = { requireBackendHost, requireInstallHost, backendCapabilities };
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// backends/common/packer.cjs
|
|
122
|
+
var require_packer = __commonJS({
|
|
123
|
+
"backends/common/packer.cjs"(exports, module) {
|
|
124
|
+
var path3 = __require("node:path");
|
|
125
|
+
var { execFile: execFile2 } = __require("node:child_process");
|
|
126
|
+
function packer({ runtime, python = () => process.env.RPA_HOST_PYTHON || (process.platform === "win32" ? "python" : "python3"), spawn = execFile2 } = {}) {
|
|
127
|
+
return function call(action, { backend = "virtualbox", id, confirmed = false, ...request } = {}) {
|
|
128
|
+
const args = [path3.join(runtime, "backends/packer/runner.py"), action, "--backend", backend];
|
|
129
|
+
if (id) args.push("--id", id);
|
|
130
|
+
if (confirmed) args.push("--confirmed");
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
const child = spawn(typeof python === "function" ? python() : python, args, { windowsHide: true, timeout: 6e5, maxBuffer: 4 * 1024 ** 2 }, (error, stdout, stderr) => {
|
|
133
|
+
let data;
|
|
134
|
+
try {
|
|
135
|
+
data = JSON.parse(stdout);
|
|
136
|
+
} catch {
|
|
137
|
+
}
|
|
138
|
+
if (error || data?.status === "failed") reject(Error(data?.error || stderr || error?.message || "Packer response was invalid"));
|
|
139
|
+
else resolve(data);
|
|
140
|
+
});
|
|
141
|
+
child.stdin.on("error", () => {
|
|
142
|
+
});
|
|
143
|
+
child.stdin.end(action === "create" ? JSON.stringify({ backend, ...request }) : "");
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
module.exports = { packer };
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// backends/kvm/desktop.cjs
|
|
152
|
+
var require_desktop = __commonJS({
|
|
153
|
+
"backends/kvm/desktop.cjs"(exports, module) {
|
|
38
154
|
var fs2 = __require("node:fs");
|
|
39
155
|
var path3 = __require("node:path");
|
|
40
156
|
var { execFile: execFile2 } = __require("node:child_process");
|
|
@@ -65,8 +181,9 @@ var require_host_backends = __commonJS({
|
|
|
65
181
|
}
|
|
66
182
|
throw Error("This VM does not expose VNC. Create a KVM desktop here to use the embedded viewer.");
|
|
67
183
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
184
|
+
function createKvmAdapter(context, { runtime, config, execute = run, platform = process.platform }) {
|
|
185
|
+
require_host_support().requireBackendHost("kvm", platform);
|
|
186
|
+
const storage = path3.join(process.env.VAMP_HOME || path3.join(__require("node:os").homedir(), ".vamp"), "vms");
|
|
70
187
|
const uri = () => config().get("libvirtUri") || "qemu:///session";
|
|
71
188
|
const command = async (exe, args, timeout = 3e4) => (await execute(exe, args, { timeout, maxBuffer: 4 * 1024 ** 2, env: { ...process.env, LC_ALL: "C" } })).stdout;
|
|
72
189
|
const virsh = (args) => command("virsh", ["-c", uri(), ...args]);
|
|
@@ -74,25 +191,22 @@ var require_host_backends = __commonJS({
|
|
|
74
191
|
if (!UUID.test(id)) throw Error("Invalid VM identifier");
|
|
75
192
|
return id;
|
|
76
193
|
};
|
|
77
|
-
const record = (backend, name) => path3.join(storage, backend, name, "vamp-ui.json");
|
|
78
194
|
function managed(backend, id) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
195
|
+
for (const base of [storage, path3.join(context.globalStorageUri.fsPath, "desktops")]) {
|
|
196
|
+
const root = path3.join(base, backend);
|
|
197
|
+
if (!fs2.existsSync(root)) continue;
|
|
198
|
+
for (const name of fs2.readdirSync(root)) {
|
|
199
|
+
const record = path3.join(root, name, "vamp-ui.json");
|
|
200
|
+
try {
|
|
201
|
+
const item = JSON.parse(fs2.readFileSync(record, "utf8"));
|
|
202
|
+
if (item.id === id) return { ...item, folder: path3.dirname(record) };
|
|
203
|
+
} catch {
|
|
204
|
+
}
|
|
86
205
|
}
|
|
87
206
|
}
|
|
88
207
|
}
|
|
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
208
|
async function ensureNoVirtualBox() {
|
|
95
|
-
if (
|
|
209
|
+
if (platform !== "linux") return;
|
|
96
210
|
try {
|
|
97
211
|
const active = await command(process.env.VBOXMANAGE_PATH || "VBoxManage", ["list", "runningvms"]);
|
|
98
212
|
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).");
|
|
@@ -101,19 +215,14 @@ var require_host_backends = __commonJS({
|
|
|
101
215
|
}
|
|
102
216
|
}
|
|
103
217
|
return {
|
|
104
|
-
async check(
|
|
105
|
-
if (
|
|
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.");
|
|
218
|
+
async check() {
|
|
219
|
+
if (platform !== "linux") throw Error("KVM requires a Linux host. Choose VirtualBox or Hyper-V on Windows.");
|
|
110
220
|
await virsh(["list", "--all", "--uuid"]);
|
|
111
221
|
await command("virt-install", ["--version"]);
|
|
112
222
|
await command("qemu-img", ["--version"]);
|
|
113
223
|
return "KVM \xB7 " + uri();
|
|
114
224
|
},
|
|
115
|
-
async list(
|
|
116
|
-
if (backend === "hyperv") return (await hyperv("list")).vms;
|
|
225
|
+
async list() {
|
|
117
226
|
const ids = (await virsh(["list", "--all", "--uuid"])).split(/\s+/).filter((id) => UUID.test(id));
|
|
118
227
|
return Promise.all(ids.map(async (id) => {
|
|
119
228
|
const info = domainInfo(await virsh(["dumpxml", id]));
|
|
@@ -121,80 +230,183 @@ var require_host_backends = __commonJS({
|
|
|
121
230
|
return { ...info, backend: "kvm", state: { "shut off": "poweroff", running: "running", paused: "paused", crashed: "aborted" }[raw] || raw, managed: !!managed("kvm", id) };
|
|
122
231
|
}));
|
|
123
232
|
},
|
|
124
|
-
|
|
125
|
-
|
|
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();
|
|
233
|
+
create: (values) => require_packer().packer({ runtime, python: () => config().get("kvmPythonExecutable") || "python3" })("create", { backend: "kvm", libvirt_uri: uri(), ...values }),
|
|
234
|
+
async start(id) {
|
|
161
235
|
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
236
|
await ensureNoVirtualBox();
|
|
171
237
|
await virsh(["start", id]);
|
|
172
238
|
const state = (await virsh(["domstate", id])).trim();
|
|
173
239
|
if (state !== "running") throw Error("VM did not reach Running state: " + state);
|
|
174
240
|
return { status: "running", startup_verified: true };
|
|
175
241
|
},
|
|
176
|
-
async stop(
|
|
242
|
+
async stop(id) {
|
|
177
243
|
checkID(id);
|
|
178
|
-
if (backend === "hyperv") return hyperv("stop", { id });
|
|
179
244
|
return virsh(["shutdown", id]);
|
|
180
245
|
},
|
|
181
246
|
async endpoint(id) {
|
|
182
247
|
checkID(id);
|
|
183
248
|
return vncEndpoint(await virsh(["dumpxml", id]));
|
|
184
249
|
},
|
|
185
|
-
async remove(
|
|
250
|
+
async remove(id) {
|
|
186
251
|
checkID(id);
|
|
187
|
-
if (backend === "hyperv") return hyperv("delete", { id });
|
|
188
252
|
const item = managed("kvm", id);
|
|
189
253
|
if (!item) throw Error("Only desktops created by VAMP can be deleted here.");
|
|
190
254
|
const state = (await virsh(["domstate", id])).trim();
|
|
191
255
|
if (state !== "shut off") throw Error("Shut down the VM before deleting it.");
|
|
192
256
|
await virsh(["undefine", id, "--nvram", "--tpm", "--managed-save", "--snapshots-metadata", "--checkpoints-metadata"]);
|
|
257
|
+
if (item.volume) {
|
|
258
|
+
if (item.pool !== "default" || !/^vamp-[A-Za-z][A-Za-z0-9_-]{0,62}\.qcow2$/.test(item.volume)) throw Error("Unexpected managed storage volume; inspect the ownership record.");
|
|
259
|
+
await virsh(["vol-delete", "--pool", item.pool, item.volume]);
|
|
260
|
+
}
|
|
193
261
|
fs2.rmSync(item.folder, { recursive: true, force: true });
|
|
194
262
|
}
|
|
195
263
|
};
|
|
196
264
|
}
|
|
197
|
-
module.exports = {
|
|
265
|
+
module.exports = { createKvmAdapter, domainInfo, vncEndpoint };
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// backends/hyperv/desktop.cjs
|
|
270
|
+
var require_desktop2 = __commonJS({
|
|
271
|
+
"backends/hyperv/desktop.cjs"(exports, module) {
|
|
272
|
+
var path3 = __require("node:path");
|
|
273
|
+
var { execFile: execFile2 } = __require("node:child_process");
|
|
274
|
+
var { promisify } = __require("node:util");
|
|
275
|
+
var { requireBackendHost } = require_host_support();
|
|
276
|
+
function createHyperVAdapter(context, { runtime, execute = promisify(execFile2), platform = process.platform }) {
|
|
277
|
+
requireBackendHost("hyperv", platform);
|
|
278
|
+
const storage = path3.join(process.env.VAMP_HOME || path3.join(__require("node:os").homedir(), ".vamp"), "vms/hyperv");
|
|
279
|
+
async function call(action, data = {}) {
|
|
280
|
+
const request = Buffer.from(JSON.stringify({ action, ...data })).toString("base64");
|
|
281
|
+
const result = await execute("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-File", path3.join(runtime, "backends/hyperv/scripts/Manage-Desktop.ps1"), "-RequestBase64", request, "-StoragePath", storage, "-LegacyStoragePath", path3.join(context.globalStorageUri.fsPath, "desktops/hyperv")], { timeout: 18e4, maxBuffer: 4 * 1024 ** 2 });
|
|
282
|
+
return JSON.parse(result.stdout);
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
check: async () => {
|
|
286
|
+
await call("check");
|
|
287
|
+
return "Hyper-V ready";
|
|
288
|
+
},
|
|
289
|
+
list: async () => (await call("list")).vms,
|
|
290
|
+
create: (values) => require_packer().packer({ runtime })("create", { backend: "hyperv", ...values }),
|
|
291
|
+
start: (id) => call("start", { id }),
|
|
292
|
+
stop: (id) => call("stop", { id }),
|
|
293
|
+
remove: (id) => call("delete", { id })
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
module.exports = { createHyperVAdapter };
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// backends/virtualbox/desktop.cjs
|
|
301
|
+
var require_desktop3 = __commonJS({
|
|
302
|
+
"backends/virtualbox/desktop.cjs"(exports, module) {
|
|
303
|
+
var path3 = __require("node:path");
|
|
304
|
+
var fs2 = __require("node:fs");
|
|
305
|
+
var { execFile: execFile2 } = __require("node:child_process");
|
|
306
|
+
var { promisify } = __require("node:util");
|
|
307
|
+
var { requireBackendHost, requireInstallHost } = require_host_support();
|
|
308
|
+
function createVirtualBoxAdapter(_context, { runtime, config = () => ({ get: () => void 0 }), execute = promisify(execFile2), spawn = execFile2, python = () => process.env.RPA_HOST_PYTHON || (process.platform === "win32" ? "python" : "python3"), platform = process.platform, architecture = process.arch, vboxExecutable } = {}) {
|
|
309
|
+
requireBackendHost("virtualbox", platform);
|
|
310
|
+
const executable = () => typeof vboxExecutable === "function" ? vboxExecutable() : vboxExecutable || config().get("vboxManagePath") || process.env.VBOXMANAGE_PATH || (platform === "win32" ? path3.join(process.env.ProgramFiles || "C:/Program Files", "Oracle/VirtualBox/VBoxManage.exe") : "VBoxManage");
|
|
311
|
+
const command = async (args) => (await execute(executable(), args, { timeout: 3e4, maxBuffer: 4 * 1024 ** 2 })).stdout;
|
|
312
|
+
const info = (text) => Object.fromEntries(text.split(/\r?\n/).flatMap((line) => {
|
|
313
|
+
const m = line.match(/^([^=]+)=(.*)$/);
|
|
314
|
+
return m ? [[m[1], m[2].replace(/^"|"$/g, "")]] : [];
|
|
315
|
+
}));
|
|
316
|
+
return {
|
|
317
|
+
command,
|
|
318
|
+
async list() {
|
|
319
|
+
const rows = (await command(["list", "vms"])).split(/\r?\n/).flatMap((line) => {
|
|
320
|
+
const m = line.match(/^"(.*)"\s+\{([a-f0-9-]{36})\}$/i);
|
|
321
|
+
return m ? [{ name: m[1], id: m[2] }] : [];
|
|
322
|
+
});
|
|
323
|
+
return (await Promise.all(rows.map(async (row) => {
|
|
324
|
+
try {
|
|
325
|
+
const details = info(await command(["showvminfo", row.id, "--machinereadable"]));
|
|
326
|
+
let installation;
|
|
327
|
+
try {
|
|
328
|
+
installation = JSON.parse(fs2.readFileSync(path3.join(path3.dirname(details.CfgFile), "vamp-install.json"), "utf8"));
|
|
329
|
+
} catch {
|
|
330
|
+
}
|
|
331
|
+
if (installation?.development_only && process.env.VAMP_SHOW_DEVELOPMENT_VMS !== "1") return null;
|
|
332
|
+
return {
|
|
333
|
+
...row,
|
|
334
|
+
backend: "virtualbox",
|
|
335
|
+
managed: true,
|
|
336
|
+
state: details.VMState,
|
|
337
|
+
memory: details.memory,
|
|
338
|
+
cpus: details.cpus,
|
|
339
|
+
guestOS: details.ostype,
|
|
340
|
+
installation: installation ? { status: installation.status, verified: installation.installation_verified, mode: installation.installation_mode } : void 0
|
|
341
|
+
};
|
|
342
|
+
} catch {
|
|
343
|
+
return { ...row, state: "unavailable" };
|
|
344
|
+
}
|
|
345
|
+
}))).filter(Boolean);
|
|
346
|
+
},
|
|
347
|
+
async start(id) {
|
|
348
|
+
await command(["startvm", id, "--type", "headless"]);
|
|
349
|
+
const state = info(await command(["showvminfo", id, "--machinereadable"])).VMState;
|
|
350
|
+
if (state !== "running") throw Error("VM did not reach Running state: " + (state || "unknown"));
|
|
351
|
+
return { status: "running", startup_verified: true };
|
|
352
|
+
},
|
|
353
|
+
stop: (id) => command(["controlvm", id, "acpipowerbutton"]),
|
|
354
|
+
remove: (id) => command(["unregistervm", id, "--delete"]),
|
|
355
|
+
check: async () => (await command(["--version"])).trim(),
|
|
356
|
+
async create(request) {
|
|
357
|
+
requireInstallHost("virtualbox", platform, architecture);
|
|
358
|
+
return require_packer().packer({ runtime, python, spawn })("create", { backend: "virtualbox", ...request });
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
module.exports = { createVirtualBoxAdapter };
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
// backends/common/host-backends.cjs
|
|
367
|
+
var require_host_backends = __commonJS({
|
|
368
|
+
"backends/common/host-backends.cjs"(exports, module) {
|
|
369
|
+
var { requireBackendHost, requireInstallHost, backendCapabilities } = require_host_support();
|
|
370
|
+
var { domainInfo, vncEndpoint } = require_desktop();
|
|
371
|
+
function hostBackends(context, options) {
|
|
372
|
+
const platform = options.platform || process.platform;
|
|
373
|
+
const cache = /* @__PURE__ */ new Map();
|
|
374
|
+
function adapter(backend) {
|
|
375
|
+
requireBackendHost(backend, platform);
|
|
376
|
+
if (backend === "apple-hypervisor") throw Error("Apple Hypervisor adapter is not implemented");
|
|
377
|
+
if (!cache.has(backend)) {
|
|
378
|
+
if (backend === "kvm") cache.set(backend, require_desktop().createKvmAdapter(context, { ...options, platform }));
|
|
379
|
+
else if (backend === "hyperv") cache.set(backend, require_desktop2().createHyperVAdapter(context, { ...options, platform }));
|
|
380
|
+
else if (backend === "virtualbox") cache.set(backend, require_desktop3().createVirtualBoxAdapter(context, { ...options, platform }));
|
|
381
|
+
else throw Error("Unsupported backend");
|
|
382
|
+
}
|
|
383
|
+
const implementation = cache.get(backend);
|
|
384
|
+
for (const method of ["check", "list", "create", "start", "stop", "remove"]) {
|
|
385
|
+
if (typeof implementation[method] !== "function") throw Error(`${backend} adapter is missing ${method}`);
|
|
386
|
+
}
|
|
387
|
+
return implementation;
|
|
388
|
+
}
|
|
389
|
+
const uuid = (id) => {
|
|
390
|
+
if (!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(id)) throw Error("Invalid VM identifier");
|
|
391
|
+
return id;
|
|
392
|
+
};
|
|
393
|
+
return {
|
|
394
|
+
command: async (backend, args) => adapter(backend).command(args),
|
|
395
|
+
capabilities: () => backendCapabilities(platform),
|
|
396
|
+
check: async (backend) => adapter(backend).check(),
|
|
397
|
+
list: async (backend) => adapter(backend).list(),
|
|
398
|
+
async create(backend, values) {
|
|
399
|
+
requireInstallHost(backend, platform, options.architecture || process.arch);
|
|
400
|
+
return (options.packerCall || require_packer().packer(options))("create", { backend, libvirt_uri: options.config?.().get("libvirtUri"), ...values });
|
|
401
|
+
},
|
|
402
|
+
start: async (backend, id) => adapter(backend).start(uuid(id)),
|
|
403
|
+
stop: async (backend, id) => adapter(backend).stop(uuid(id)),
|
|
404
|
+
remove: async (backend, id) => adapter(backend).remove(uuid(id)),
|
|
405
|
+
endpoint: async (id) => adapter("kvm").endpoint(uuid(id))
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
var preparePacker = (options, backend) => require_packer().packer(options)("prepare", { backend: backend === "remote" ? "virtualbox" : backend });
|
|
409
|
+
module.exports = { hostBackends, domainInfo, vncEndpoint, preparePacker, packer: require_packer().packer };
|
|
198
410
|
}
|
|
199
411
|
});
|
|
200
412
|
|
|
@@ -260,6 +472,8 @@ function describeConfig(config) {
|
|
|
260
472
|
}
|
|
261
473
|
|
|
262
474
|
// backends/remote_ssh/tools.mjs
|
|
475
|
+
var import_host_support = __toESM(require_host_support(), 1);
|
|
476
|
+
var import_packer = __toESM(require_packer(), 1);
|
|
263
477
|
import fs from "node:fs/promises";
|
|
264
478
|
import path2 from "node:path";
|
|
265
479
|
|
|
@@ -750,8 +964,12 @@ function positiveNumber(value, fallback, min, max) {
|
|
|
750
964
|
return Math.max(min, Math.min(max, number));
|
|
751
965
|
}
|
|
752
966
|
function compare(version, minimum) {
|
|
753
|
-
const
|
|
754
|
-
|
|
967
|
+
const segments = (value) => String(value ?? "").trim().replace(/^v/i, "").split(".").map((part) => {
|
|
968
|
+
const match = /^\d+/.exec(part);
|
|
969
|
+
return match ? Number(match[0]) : 0;
|
|
970
|
+
});
|
|
971
|
+
const left = segments(version);
|
|
972
|
+
const right = segments(minimum);
|
|
755
973
|
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
756
974
|
const a = left[index] || 0;
|
|
757
975
|
const b = right[index] || 0;
|
|
@@ -770,6 +988,8 @@ function parseMonitorReply(stdout) {
|
|
|
770
988
|
function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Date() }) {
|
|
771
989
|
const exec = async (exe, args, { timeoutMs = 3e4, input } = {}) => {
|
|
772
990
|
try {
|
|
991
|
+
const tool = path2.basename(exe).replace(/\.exe$/i, "");
|
|
992
|
+
if (["virsh", "virt-install", "qemu-img"].includes(tool)) import_host_support.default.requireBackendHost("kvm", config.platform);
|
|
773
993
|
const result = await run(exe, args, { timeoutMs, input });
|
|
774
994
|
return { ok: true, stdout: String(result?.stdout ?? ""), stderr: String(result?.stderr ?? "") };
|
|
775
995
|
} catch (error) {
|
|
@@ -1119,7 +1339,7 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1119
1339
|
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.");
|
|
1120
1340
|
const pythonVersion = await exec(config.python, ["-c", 'import sys;print("%d.%d.%d"%sys.version_info[:3])'], { timeoutMs: 15e3 });
|
|
1121
1341
|
const python = pythonVersion.ok ? pythonVersion.stdout.trim() : "";
|
|
1122
|
-
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}).`);
|
|
1342
|
+
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}).`);
|
|
1123
1343
|
if (config.backend === "kvm") {
|
|
1124
1344
|
const libvirtVersion = await exec("virsh", ["--version"], { timeoutMs: 15e3 });
|
|
1125
1345
|
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.");
|
|
@@ -1186,13 +1406,13 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1186
1406
|
});
|
|
1187
1407
|
}
|
|
1188
1408
|
record("workdir", "Work directory and server configuration", dry_run ? "planned" : "done", config.workdir);
|
|
1189
|
-
const pythonProbe = await exec(config.python, ["-c", 'import sys;print("%d.%d"%sys.version_info[:
|
|
1409
|
+
const pythonProbe = await exec(config.python, ["-c", 'import sys;print("%d.%d.%d"%sys.version_info[:3])'], { timeoutMs: 15e3 });
|
|
1190
1410
|
if (!pythonProbe.ok) {
|
|
1191
|
-
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." });
|
|
1411
|
+
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." });
|
|
1192
1412
|
} else if (compare(pythonProbe.stdout.trim(), "3.11") < 0) {
|
|
1193
|
-
record("python", "Python 3.11+", "needs_manual", `${config.python} -V`, { fix: `Detected Python ${pythonProbe.stdout.trim()}. Install 3.11 or newer and set remotePython.` });
|
|
1413
|
+
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.` });
|
|
1194
1414
|
} else {
|
|
1195
|
-
record("python", "Python 3.11+", "ok", `Python ${pythonProbe.stdout.trim()}`);
|
|
1415
|
+
record("python", "Python 3.11+ (3.15+ supported)", "ok", `Python ${pythonProbe.stdout.trim()}`);
|
|
1196
1416
|
if (python_venv) {
|
|
1197
1417
|
const venv = path2.join(config.workdir, "venv");
|
|
1198
1418
|
const exists = await fsx.access(path2.join(venv, config.platform === "win32" ? "Scripts/python.exe" : "bin/python")).then(() => true).catch(() => false);
|
|
@@ -1222,7 +1442,7 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1222
1442
|
const manager = managers.find(([, found]) => found)?.[0];
|
|
1223
1443
|
const sudo = await exec("sudo", ["-n", "true"], { timeoutMs: 1e4 });
|
|
1224
1444
|
const installs = {
|
|
1225
|
-
"apt-get": ["apt-get", "install", "-y", "qemu-kvm", "libvirt-daemon-system", "libvirt-clients", "virtinst", "qemu-utils"],
|
|
1445
|
+
"apt-get": ["apt-get", "install", "-y", "qemu-kvm", "libvirt-daemon-system", "libvirt-clients", "virtinst", "qemu-utils", "osinfo-db", "libosinfo-bin", "ovmf", "swtpm"],
|
|
1226
1446
|
dnf: ["dnf", "install", "-y", "qemu-kvm", "libvirt-daemon-config-network", "libvirt-daemon-kvm", "virt-install", "qemu-img"],
|
|
1227
1447
|
yum: ["yum", "install", "-y", "qemu-kvm", "libvirt", "libvirt-client", "virt-install", "qemu-img"],
|
|
1228
1448
|
zypper: ["zypper", "--non-interactive", "install", "qemu-kvm", "libvirt", "virt-install"],
|
|
@@ -1254,6 +1474,8 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1254
1474
|
const vboxState2 = dry_run ? "planned" : version.ok ? "ok" : "needs_manual";
|
|
1255
1475
|
record("vboxmanage", "VBoxManage", vboxState2, `${config.vboxManage} --version`, dry_run ? void 0 : version.ok ? { note: version.stdout.trim() } : { fix: "Install VirtualBox on the remote host (https://www.virtualbox.org/wiki/Downloads), then set remoteVboxManage if it is not on PATH." });
|
|
1256
1476
|
}
|
|
1477
|
+
const packerScript = path2.join(config.repo || config.workdir, "backends/packer/runner.py");
|
|
1478
|
+
await runStep("packer", "Install HashiCorp Packer CLI and official hypervisor plugin", [config.python || "python3", packerScript, "prepare", "--backend", config.backend], 6e5);
|
|
1257
1479
|
const failed = steps.filter((step) => step.status === "failed");
|
|
1258
1480
|
const manual = steps.filter((step) => step.status === "needs_manual");
|
|
1259
1481
|
return {
|
|
@@ -1265,8 +1487,7 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1265
1487
|
};
|
|
1266
1488
|
}
|
|
1267
1489
|
async function createVm(args = {}) {
|
|
1268
|
-
|
|
1269
|
-
if (config.platform !== "linux") throw new Error("KVM creation requires a Linux host.");
|
|
1490
|
+
import_host_support.default.requireBackendHost(config.backend, config.platform);
|
|
1270
1491
|
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
1492
|
const guest_os = args.guest_os ?? "debian";
|
|
1272
1493
|
if (!["debian", "ubuntu", "windows11"].includes(guest_os)) throw new Error("Unsupported guest_os");
|
|
@@ -1280,20 +1501,26 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1280
1501
|
const lifecycle = (await Promise.resolve().then(() => __toESM(require_host_backends(), 1))).default;
|
|
1281
1502
|
const adapter = lifecycle.hostBackends({ globalStorageUri: { fsPath: config.workdir } }, {
|
|
1282
1503
|
runtime: config.repo || config.workdir,
|
|
1504
|
+
python: () => config.python || (process.platform === "win32" ? "python" : "python3"),
|
|
1505
|
+
platform: config.platform,
|
|
1283
1506
|
config: () => ({ get: (key) => key === "libvirtUri" ? config.libvirtUri : key === "kvmPythonExecutable" ? config.python : void 0 }),
|
|
1284
1507
|
execute: (exe, argv, options) => run(exe, argv, { timeoutMs: options.timeout })
|
|
1285
1508
|
});
|
|
1286
|
-
const created = await adapter.create(
|
|
1509
|
+
const created = await adapter.create(config.backend, { name: args.name, iso_path: args.iso_path, guest_os, installation_mode: args.installation_mode, windows_confirmed: args.windows_confirmed, ...values });
|
|
1287
1510
|
return {
|
|
1288
1511
|
...created,
|
|
1289
|
-
backend:
|
|
1512
|
+
backend: config.backend,
|
|
1290
1513
|
guest_os,
|
|
1291
1514
|
os_installation_completed: false,
|
|
1292
1515
|
guest_setup_completed: false,
|
|
1293
|
-
next_action:
|
|
1516
|
+
next_action: "Packer build queued. Use remote_golden_images for completion status, file paths, sizes and logs. Public sandbox autologin: vboxuser / password123!."
|
|
1294
1517
|
};
|
|
1295
1518
|
}
|
|
1519
|
+
const packer = import_packer.default.packer({ runtime: config.repo || config.workdir, python: () => config.python || (process.platform === "win32" ? "python" : "python3") });
|
|
1296
1520
|
const tools = [
|
|
1521
|
+
{ name: "remote_packer_prepare", description: "Download the managed Packer CLI and selected official plugin on this host; creates no VM.", inputSchema: { type: "object", properties: {}, additionalProperties: false }, handler: () => packer("prepare", { backend: config.backend }) },
|
|
1522
|
+
{ name: "remote_golden_images", description: "List golden image build status, absolute paths and byte sizes on this host.", inputSchema: { type: "object", properties: {}, additionalProperties: false }, handler: () => packer("images") },
|
|
1523
|
+
{ name: "remote_golden_image_delete", description: "Delete a VAMP golden image by ID. Without confirmed returns path/size; get explicit user approval before confirmed:true. Live VM disks are separate.", inputSchema: { type: "object", properties: { id: { type: "string", pattern: "^[a-f0-9]{32}$" }, confirmed: { type: "boolean", default: false } }, required: ["id"], additionalProperties: false }, handler: (args) => packer("delete-image", args) },
|
|
1297
1524
|
{
|
|
1298
1525
|
name: "remote_env_check",
|
|
1299
1526
|
title: "Check the remote host environment",
|
|
@@ -1318,13 +1545,13 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1318
1545
|
},
|
|
1319
1546
|
{
|
|
1320
1547
|
name: "remote_vm_create",
|
|
1321
|
-
title: "Create a
|
|
1322
|
-
description: "
|
|
1548
|
+
title: "Create a VM with HashiCorp Packer",
|
|
1549
|
+
description: "Create and deploy a new VM with the selected hypervisor through the same Packer runner as VS Code. Requires confirmed:true. HashiCorp Packer installs Debian/Windows and post-install scripts, waits 60s after reboot, exports a golden image and deploys a separate live disk. Windows requires windows_confirmed:true and your own license. Public sandbox autologin vboxuser/password123!.",
|
|
1323
1550
|
inputSchema: { type: "object", properties: {
|
|
1324
1551
|
name: { type: "string", pattern: "^[A-Za-z][A-Za-z0-9_-]{0,62}$" },
|
|
1325
1552
|
iso_path: { type: "string", description: "Absolute ISO path on the host running this server" },
|
|
1326
|
-
guest_os: { type: "string", enum: ["debian", "
|
|
1327
|
-
installation_mode: { type: "string", enum: ["
|
|
1553
|
+
guest_os: { type: "string", enum: ["debian", "windows11"], default: "debian" },
|
|
1554
|
+
installation_mode: { type: "string", enum: ["auto", "unattended"] },
|
|
1328
1555
|
memory_mb: { type: "integer", minimum: 2048, maximum: 131072 },
|
|
1329
1556
|
cpus: { type: "integer", minimum: 1, maximum: 64 },
|
|
1330
1557
|
disk_mb: { type: "integer", minimum: 32768, maximum: 2097152 },
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Cross-platform VirtualBox adapter. Guest provisioning stays in shared Python.
|
|
2
|
+
const path=require('node:path');
|
|
3
|
+
const fs=require('node:fs');
|
|
4
|
+
const {execFile}=require('node:child_process');
|
|
5
|
+
const {promisify}=require('node:util');
|
|
6
|
+
const {requireBackendHost,requireInstallHost}=require('../common/host-support.cjs');
|
|
7
|
+
/** @returns {import('../common/desktop-interface').DesktopAdapter} */
|
|
8
|
+
function createVirtualBoxAdapter(_context,{runtime,config=()=>({get:()=>undefined}),execute=promisify(execFile),spawn=execFile,python=()=>process.env.RPA_HOST_PYTHON||(process.platform==='win32'?'python':'python3'),platform=process.platform,architecture=process.arch,vboxExecutable}={}){
|
|
9
|
+
requireBackendHost('virtualbox',platform);
|
|
10
|
+
const executable=()=>typeof vboxExecutable==='function'?vboxExecutable():vboxExecutable||config().get('vboxManagePath')||process.env.VBOXMANAGE_PATH||(platform==='win32'?path.join(process.env.ProgramFiles||'C:/Program Files','Oracle/VirtualBox/VBoxManage.exe'):'VBoxManage');
|
|
11
|
+
const command=async args=>(await execute(executable(),args,{timeout:30000,maxBuffer:4*1024**2})).stdout;
|
|
12
|
+
const info=text=>Object.fromEntries(text.split(/\r?\n/).flatMap(line=>{const m=line.match(/^([^=]+)=(.*)$/);return m?[[m[1],m[2].replace(/^"|"$/g,'')]]:[];}));
|
|
13
|
+
return {command,
|
|
14
|
+
async list(){
|
|
15
|
+
const rows=(await command(['list','vms'])).split(/\r?\n/).flatMap(line=>{const m=line.match(/^"(.*)"\s+\{([a-f0-9-]{36})\}$/i);return m?[{name:m[1],id:m[2]}]:[];});
|
|
16
|
+
return (await Promise.all(rows.map(async row=>{
|
|
17
|
+
try{
|
|
18
|
+
const details=info(await command(['showvminfo',row.id,'--machinereadable']));
|
|
19
|
+
let installation;
|
|
20
|
+
try{installation=JSON.parse(fs.readFileSync(path.join(path.dirname(details.CfgFile),'vamp-install.json'),'utf8'));}catch{}
|
|
21
|
+
if(installation?.development_only && process.env.VAMP_SHOW_DEVELOPMENT_VMS!=='1')return null;
|
|
22
|
+
return {...row,backend:'virtualbox',managed:true,state:details.VMState,memory:details.memory,cpus:details.cpus,guestOS:details.ostype,
|
|
23
|
+
installation:installation?{status:installation.status,verified:installation.installation_verified,mode:installation.installation_mode}:undefined};
|
|
24
|
+
}catch{return {...row,state:'unavailable'};}
|
|
25
|
+
}))).filter(Boolean);
|
|
26
|
+
},
|
|
27
|
+
async start(id){await command(['startvm',id,'--type','headless']);const state=info(await command(['showvminfo',id,'--machinereadable'])).VMState;if(state!=='running')throw Error('VM did not reach Running state: '+(state||'unknown'));return {status:'running',startup_verified:true};},
|
|
28
|
+
stop:id=>command(['controlvm',id,'acpipowerbutton']),
|
|
29
|
+
remove:id=>command(['unregistervm',id,'--delete']),
|
|
30
|
+
check:async()=>(await command(['--version'])).trim(),
|
|
31
|
+
async create(request){
|
|
32
|
+
requireInstallHost('virtualbox',platform,architecture);
|
|
33
|
+
return require('../common/packer.cjs').packer({runtime,python,spawn})('create',{backend:'virtualbox',...request});
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
module.exports={createVirtualBoxAdapter};
|