vamp-mcp 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/package.json +1 -1
- package/runtime/backends/remote_ssh/server.mjs +27 -17
- package/runtime/backends/virtualbox/provision.py +45 -32
- package/runtime/backends/virtualbox/server.mjs +377 -51
- package/runtime/guest_setup/http/postdeb.sh +47 -0
- package/runtime/guest_setup/http/postwin.ps1 +28 -0
- package/runtime/guest_setup/http/setup-all.ps1 +25 -0
- package/runtime/guest_setup/http/setup-win.cmd +7 -0
- package/runtime/guest_setup/http/setup.ps1 +29 -0
- package/runtime/guest_setup/http/setup.sh +50 -0
- package/runtime/guest_setup/kvm/setup-debian.sh +73 -0
- package/runtime/guest_setup/kvm/setup-windows.ps1 +52 -0
- package/runtime/guest_setup/recorder/README.txt +4 -0
- package/runtime/guest_setup/recorder/recorder.zip +0 -0
- package/runtime/guest_setup/recorder/setup-user.py +19 -1
- package/runtime/guest_setup/recorder/setup-win.cmd +55 -6
- package/runtime/guest_setup/recorder/setup.ps1 +57 -6
- package/runtime/guest_setup/recorder/setup.sh +18 -1
- package/runtime/guest_setup/requirements.txt +2 -0
- package/runtime/guest_setup/setup-all.ps1 +35 -0
- package/runtime/guest_setup/setup-all.sh +22 -0
- package/runtime/guest_setup/vault/Install-VCRuntime.ps1 +26 -0
- package/runtime/guest_setup/vault/setup-guest-vault.ps1 +148 -0
- package/runtime/guest_setup/vault/setup-guest-vault.sh +75 -0
- package/runtime/scripts/macos/setup-host.sh +126 -0
- package/runtime/scripts/remote_host_setup.sh +7 -4
- package/runtime/scripts/script_server.py +517 -0
- package/runtime/scripts/build_debian_installer.py +0 -48
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. VM creation also needs `virt-install` and `qemu-img
|
|
9
|
+
- The `remote` server runs on the host owning KVM/libvirt or VirtualBox. To operate a different machine, start it there over SSH. Linux KVM requires access to `virsh` and the selected libvirt URI. VM creation also needs `virt-install` and `qemu-img`. Debian automatic installation boots the stock ISO and injects a preseed into the initrd; `xorriso` is not used. Guest setup is served over HTTP from a host Python 3 server on port 8421.
|
|
10
10
|
- Provide your own VMs, guest operating systems, licenses and Guest Additions when needed. Package installation does not create VMs or install system dependencies.
|
|
11
11
|
- VAMP Vault MCP is a separate npm package, `vamp-mcp-vault`. The live viewer and graphical manager require the VS Code extensions; npm does not install them. Hyper-V is not included in this npm release.
|
|
12
12
|
- Full SPICE/OCR/YOLO workflows still require the source repository and their documented environments.
|
|
@@ -21,10 +21,10 @@ vamp-mcp --help
|
|
|
21
21
|
Or run without a global install:
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
|
-
npx -y vamp-mcp@0.
|
|
25
|
-
npx -y vamp-mcp@0.
|
|
26
|
-
npx -y vamp-mcp@0.
|
|
27
|
-
npx -y vamp-mcp@0.
|
|
24
|
+
npx -y vamp-mcp@0.2.0 virtualbox
|
|
25
|
+
npx -y vamp-mcp@0.2.0 kvm
|
|
26
|
+
npx -y vamp-mcp@0.2.0 library
|
|
27
|
+
npx -y vamp-mcp@0.2.0 remote --backend kvm
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Servers communicate over standard input/output and wait for an MCP client. Use separate MCP registrations for each server. Installation alone does not register them with every client.
|
|
@@ -39,7 +39,7 @@ Add a server to `.vscode/mcp.json` (on Windows use `npx.cmd` if your client requ
|
|
|
39
39
|
"vamp": {
|
|
40
40
|
"type": "stdio",
|
|
41
41
|
"command": "npx",
|
|
42
|
-
"args": ["-y", "vamp-mcp@0.
|
|
42
|
+
"args": ["-y", "vamp-mcp@0.2.0", "virtualbox"],
|
|
43
43
|
"env": {"RPA_HOST_PYTHON": "/absolute/path/to/python"}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -55,7 +55,7 @@ In `~/.codex/config.toml`:
|
|
|
55
55
|
```toml
|
|
56
56
|
[mcp_servers.vamp]
|
|
57
57
|
command = "npx"
|
|
58
|
-
args = ["-y", "vamp-mcp@0.
|
|
58
|
+
args = ["-y", "vamp-mcp@0.2.0", "virtualbox"]
|
|
59
59
|
|
|
60
60
|
[mcp_servers.vamp.env]
|
|
61
61
|
RPA_HOST_PYTHON = "/absolute/path/to/python"
|
|
@@ -85,7 +85,7 @@ npm run build --prefix third_party/mcp-virtualbox
|
|
|
85
85
|
npm ci --prefix vscode-extension --ignore-scripts
|
|
86
86
|
npm run build --prefix npm-package
|
|
87
87
|
npm pack ./npm-package --pack-destination /tmp
|
|
88
|
-
VAMP_TEST_TARBALL=/tmp/vamp-mcp-0.
|
|
88
|
+
VAMP_TEST_TARBALL=/tmp/vamp-mcp-0.2.0.tgz npm test --prefix npm-package
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
The build reuses the VSIX runtime bundling and dependency license notices. The published package has no install scripts and no npm runtime dependencies; JavaScript dependencies are bundled. See the repository for backend-specific setup and validation limits.
|
|
@@ -96,12 +96,12 @@ The build reuses the VSIX runtime bundling and dependency license notices. The p
|
|
|
96
96
|
|
|
97
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
98
|
|
|
99
|
-
For VirtualBox, use `vm_create`. Compatible ISOs use VirtualBox unattended installation;
|
|
99
|
+
For VirtualBox, use `vm_create`. Compatible ISOs use VirtualBox unattended installation; when VirtualBox reports the ISO as unsupported, the stock installer runs and you complete it manually. VAMP never rewrites the ISO and does not use `xorriso`. The post-install hook downloads the guest setup from the host HTTP server on port 8421 (`vm_script_server_start`, `vm_script_server_stop`, `vm_script_server_status`), and `vm_guest_bootstrap` serves and types the wget/`irm` command.
|
|
100
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
|
|
101
|
+
Automatic Debian installation uses the **public sandbox account `vboxuser` / `password123!`**. Change it before using the VM for private work. The source ISO and existing VMs are never overwritten; the stock ISO is attached or read as-is. Guest setup scripts are staged into a per-user state folder and served read-only on port 8421 (no directory listing, 30-minute default TTL). Unsupported installer layouts fail with an error; they do not silently count as successful installation.
|
|
102
102
|
|
|
103
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
104
|
|
|
105
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
106
|
|
|
107
|
-
한국어: `vamp-mcp` 하나에서 VirtualBox와 KVM을 선택합니다. KVM의 `remote_vm_create`는 명시적 확인 후 VM을 생성·기동하며, Debian amd64 설치 ISO는
|
|
107
|
+
한국어: `vamp-mcp` 하나에서 VirtualBox와 KVM을 선택합니다. KVM의 `remote_vm_create`는 명시적 확인 후 VM을 생성·기동하며, Debian amd64 설치 ISO는 순정 ISO 부팅과 preseed 커널 주입으로 자동 설치합니다(xorriso 불필요). Python·virt-install·qemu-img를 호스트에 준비하세요. 게스트 설정 스크립트는 파이썬 HTTP 서버가 8421 포트로 제공하고 게스트가 wget/curl로 내려받습니다. 공개 테스트 계정은 `vboxuser` / `password123!`입니다. VM 기동 성공과 OS·게스트 도구 설치 완료는 별도로 검증해야 합니다. Linux에서는 KVM과 VirtualBox VM을 동시에 실행하지 마세요.
|
package/package.json
CHANGED
|
@@ -137,25 +137,31 @@ var require_host_backends = __commonJS({
|
|
|
137
137
|
fs2.mkdirSync(path3.dirname(folder), { recursive: true });
|
|
138
138
|
fs2.mkdirSync(folder);
|
|
139
139
|
const disk = path3.join(folder, "disk.qcow2");
|
|
140
|
-
let installer = iso_path;
|
|
140
|
+
let installer = iso_path, location = [];
|
|
141
141
|
if (mode === "unattended") {
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
const packaged = path3.join(runtime, "backends/kvm/debian-preseed.cfg");
|
|
143
|
+
if (!fs2.existsSync(packaged)) throw Error("Packaged Debian preseed file is missing from the VAMP runtime; choose manual installation.");
|
|
144
|
+
const preseed = path3.join(folder, "preseed.cfg");
|
|
145
|
+
fs2.copyFileSync(packaged, preseed);
|
|
146
|
+
location = [
|
|
147
|
+
"--location",
|
|
148
|
+
`${iso_path},kernel=install.amd/vmlinuz,initrd=install.amd/initrd.gz`,
|
|
149
|
+
"--initrd-inject",
|
|
150
|
+
preseed,
|
|
151
|
+
"--extra-args",
|
|
152
|
+
"auto=true priority=critical preseed/file=/preseed.cfg console=ttyS0,115200n8 console=tty0"
|
|
153
|
+
];
|
|
154
|
+
installer = null;
|
|
149
155
|
}
|
|
150
156
|
fs2.writeFileSync(path3.join(folder, "creation.json"), JSON.stringify({ status: "preparing", name, disk, iso_path }));
|
|
151
157
|
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
|
|
158
|
+
const args = ["--connect", uri(), "--name", name, "--virt-type", "kvm", "--memory", String(memory_mb), "--vcpus", String(cpus), "--cpu", "host-passthrough", "--disk", `path=${disk},format=qcow2,bus=${guest_os === "windows11" ? "sata" : "virtio"}`, ...installer ? ["--disk", `path=${installer},device=cdrom,readonly=on`] : [], ...location, ...location.length ? [] : ["--import"], "--osinfo", "detect=on,require=off", "--graphics", "vnc,listen=127.0.0.1", "--video", guest_os === "windows11" ? "vga" : "virtio", "--input", "tablet,bus=usb", "--network", uri().endsWith("/session") ? "user,model=e1000e" : "network=default,model=virtio", "--noautoconsole", "--serial", `pty,log.file=${path3.join(folder, "serial.log")},log.append=on`];
|
|
153
159
|
if (guest_os === "windows11") args.push("--boot", "uefi,hd,cdrom", "--tpm", "backend.type=emulator,backend.version=2.0,model=tpm-crb");
|
|
154
160
|
else args.push("--boot", "hd,cdrom");
|
|
155
161
|
try {
|
|
156
162
|
await command("virt-install", args, 18e4);
|
|
157
163
|
} catch (error) {
|
|
158
|
-
throw Error(`KVM setup failed. Partial setup preserved at ${folder}. ${error.message}`);
|
|
164
|
+
throw Error(`KVM setup failed. Partial setup preserved at ${folder}. ${error.message}${mode === "unattended" ? " Debian automatic installation reads the stock ISO with virt-install; if the host lacks that tooling, choose manual installation (xorriso is no longer used)." : ""}`);
|
|
159
165
|
}
|
|
160
166
|
const id = (await virsh(["domuuid", name])).trim();
|
|
161
167
|
checkID(id);
|
|
@@ -750,8 +756,12 @@ function positiveNumber(value, fallback, min, max) {
|
|
|
750
756
|
return Math.max(min, Math.min(max, number));
|
|
751
757
|
}
|
|
752
758
|
function compare(version, minimum) {
|
|
753
|
-
const
|
|
754
|
-
|
|
759
|
+
const segments = (value) => String(value ?? "").trim().replace(/^v/i, "").split(".").map((part) => {
|
|
760
|
+
const match = /^\d+/.exec(part);
|
|
761
|
+
return match ? Number(match[0]) : 0;
|
|
762
|
+
});
|
|
763
|
+
const left = segments(version);
|
|
764
|
+
const right = segments(minimum);
|
|
755
765
|
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
756
766
|
const a = left[index] || 0;
|
|
757
767
|
const b = right[index] || 0;
|
|
@@ -1119,7 +1129,7 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1119
1129
|
add("node", "Node.js runtime for this server", compare(nodeVersion, "20.0.0") >= 0 ? "ok" : "warn", `v${nodeVersion}`, compare(nodeVersion, "20.0.0") >= 0 ? void 0 : "Node.js 20 or newer is recommended on the remote host.");
|
|
1120
1130
|
const pythonVersion = await exec(config.python, ["-c", 'import sys;print("%d.%d.%d"%sys.version_info[:3])'], { timeoutMs: 15e3 });
|
|
1121
1131
|
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}).`);
|
|
1132
|
+
add("python", "Python for RPA replay", python && compare(python, "3.11.0") >= 0 ? "ok" : python ? "warn" : "missing", python || detail(pythonVersion), python && compare(python, "3.11.0") >= 0 ? void 0 : `Install Python 3.11+ (3.15 and newer work too) and set remotePython (${config.python}).`);
|
|
1123
1133
|
if (config.backend === "kvm") {
|
|
1124
1134
|
const libvirtVersion = await exec("virsh", ["--version"], { timeoutMs: 15e3 });
|
|
1125
1135
|
add("virsh", "libvirt client (virsh)", libvirtVersion.ok ? "ok" : "missing", libvirtVersion.ok ? libvirtVersion.stdout.trim() : "virsh not found", libvirtVersion.ok ? void 0 : "Install libvirt-clients / libvirt-client.");
|
|
@@ -1186,13 +1196,13 @@ function createTools({ run, config, fsx = fs, now = () => /* @__PURE__ */ new Da
|
|
|
1186
1196
|
});
|
|
1187
1197
|
}
|
|
1188
1198
|
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[:
|
|
1199
|
+
const pythonProbe = await exec(config.python, ["-c", 'import sys;print("%d.%d.%d"%sys.version_info[:3])'], { timeoutMs: 15e3 });
|
|
1190
1200
|
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." });
|
|
1201
|
+
record("python", "Python 3.11+ (3.15+ supported)", "needs_manual", `${config.python} -V`, { fix: "Install Python 3.11 or newer (3.15 and newer work too) on the remote host, then run setup again." });
|
|
1192
1202
|
} 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.` });
|
|
1203
|
+
record("python", "Python 3.11+ (3.15+ supported)", "needs_manual", `${config.python} -V`, { fix: `Detected Python ${pythonProbe.stdout.trim()}. Install 3.11 or newer and set remotePython.` });
|
|
1194
1204
|
} else {
|
|
1195
|
-
record("python", "Python 3.11+", "ok", `Python ${pythonProbe.stdout.trim()}`);
|
|
1205
|
+
record("python", "Python 3.11+ (3.15+ supported)", "ok", `Python ${pythonProbe.stdout.trim()}`);
|
|
1196
1206
|
if (python_venv) {
|
|
1197
1207
|
const venv = path2.join(config.workdir, "venv");
|
|
1198
1208
|
const exists = await fsx.access(path2.join(venv, config.platform === "win32" ? "Scripts/python.exe" : "bin/python")).then(() => true).catch(() => false);
|
|
@@ -14,14 +14,15 @@ import uuid
|
|
|
14
14
|
ROOT=Path(__file__).resolve().parents[2]
|
|
15
15
|
sys.path.insert(0,str(ROOT/'scripts'))
|
|
16
16
|
sys.path.insert(0,str(Path(__file__).resolve().parent))
|
|
17
|
-
from
|
|
18
|
-
from build_debian_installer import build as build_debian_installer
|
|
17
|
+
from script_server import SCRIPT_SERVER_PORT, guest_commands, start as start_script_server
|
|
19
18
|
|
|
20
19
|
PUBLIC_CREDENTIALS={'username':'vboxuser','password':'password123!','public_sandbox_credentials':True}
|
|
21
20
|
|
|
21
|
+
|
|
22
22
|
def parse(text):
|
|
23
23
|
return {m[1].strip():m[2].strip() for line in text.splitlines()
|
|
24
|
-
if (m:=re.match(r'([^=]+)
|
|
24
|
+
if (m:=re.match(r'([^=]+)=\"?(.*?)\"?$',line.strip()))}
|
|
25
|
+
|
|
25
26
|
|
|
26
27
|
def executable():
|
|
27
28
|
if os.environ.get('VBOXMANAGE_PATH'): return os.environ['VBOXMANAGE_PATH']
|
|
@@ -30,6 +31,7 @@ def executable():
|
|
|
30
31
|
if candidate.is_file():return str(candidate)
|
|
31
32
|
return shutil.which('VBoxManage') or 'VBoxManage'
|
|
32
33
|
|
|
34
|
+
|
|
33
35
|
def assert_no_active_kvm():
|
|
34
36
|
if not sys.platform.startswith('linux'):return
|
|
35
37
|
for uri in ('qemu:///session','qemu:///system'):
|
|
@@ -39,14 +41,23 @@ def assert_no_active_kvm():
|
|
|
39
41
|
if result.returncode==0 and result.stdout.strip():
|
|
40
42
|
raise RuntimeError('A KVM VM is active. Shut it down before starting VirtualBox; simultaneous execution can cause VERR_SVM_IN_USE.')
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
|
|
45
|
+
def post_install_command(guest_os, base_url):
|
|
46
|
+
"""Post-install hook fetched from the host script server; no ISO is rewritten or mounted."""
|
|
47
|
+
if guest_os=='windows11':
|
|
48
|
+
return f'powershell -ExecutionPolicy Bypass -Command "irm {base_url}/postwin.ps1 | iex"'
|
|
49
|
+
return f'wget -qO /tmp/vamp-postdeb.sh {base_url}/postdeb.sh && sh /tmp/vamp-postdeb.sh'
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
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",serve_scripts=True,script_server_ttl=3600):
|
|
43
53
|
if installation_mode not in ('auto','manual'):raise ValueError('installation_mode must be auto or manual')
|
|
44
54
|
name=name or ('VAMP-'+uuid.uuid4().hex[:8])
|
|
45
55
|
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')
|
|
46
56
|
iso=Path(iso_path).expanduser().resolve(strict=True)
|
|
47
57
|
if not iso.is_file():raise ValueError('ISO path must be a readable local file on the VM host')
|
|
48
58
|
journal={'status':'preparing','vm':name,'credentials':PUBLIC_CREDENTIALS,'events':[],
|
|
49
|
-
'installation_verified':False,'recorder_installed_verified':False
|
|
59
|
+
'installation_verified':False,'recorder_installed_verified':False,
|
|
60
|
+
'guest_setup_transport':f'http://10.0.2.2:{SCRIPT_SERVER_PORT} (host Python script server)'}
|
|
50
61
|
folder=Path(basedir or Path.home()/'VirtualBox VMs').expanduser().resolve()/name
|
|
51
62
|
def run(*args,timeout=120):
|
|
52
63
|
proc=subprocess.run([executable(),*map(str,args)],capture_output=True,text=True,timeout=timeout)
|
|
@@ -69,7 +80,6 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
69
80
|
raise ValueError('VirtualBox reports this ISO does not support unattended installation')
|
|
70
81
|
selected='windows11' if os_type=='Windows11_64' else ('ubuntu' if os_type.startswith('Ubuntu') else 'debian')
|
|
71
82
|
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'
|
|
73
83
|
profile=json.loads(Path(__file__).with_name('profiles.json').read_text())['profiles'][selected]
|
|
74
84
|
memory_mb=memory_mb if memory_mb is not None else profile['memory_mb']
|
|
75
85
|
cpus=cpus if cpus is not None else profile['cpus']
|
|
@@ -80,7 +90,8 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
80
90
|
return {'status':'preflight_ready','vm_created':False,'guest_os':selected,
|
|
81
91
|
'resource_profile':{'memory_mb':memory_mb,'cpus':cpus,'disk_mb':disk_mb},
|
|
82
92
|
'windows_confirmation_required':selected=='windows11' and not windows_confirmed,
|
|
83
|
-
'installation_mode':'unattended' if unattended_supported
|
|
93
|
+
'installation_mode':'unattended' if unattended_supported else 'manual',
|
|
94
|
+
'guest_setup':{'transport':'http','port':SCRIPT_SERVER_PORT,'commands':guest_commands(SCRIPT_SERVER_PORT)},
|
|
84
95
|
'credentials':PUBLIC_CREDENTIALS,'iso':str(iso)}
|
|
85
96
|
if selected=='windows11' and not windows_confirmed:
|
|
86
97
|
return {'status':'needs_windows_confirmation','no_vm_created':True,'profile':profile,
|
|
@@ -114,12 +125,18 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
114
125
|
def record(stage):
|
|
115
126
|
journal['events'].append(stage)
|
|
116
127
|
journal_path.write_text(json.dumps(journal,indent=2)+'\n')
|
|
128
|
+
script_server=None
|
|
129
|
+
if serve_scripts and not os.environ.get('VAMP_SCRIPT_SERVER_DISABLE'):
|
|
130
|
+
try:
|
|
131
|
+
script_server=start_script_server(port=SCRIPT_SERVER_PORT,ttl=script_server_ttl)
|
|
132
|
+
except Exception as exc:
|
|
133
|
+
script_server={'status':'failed','port':SCRIPT_SERVER_PORT,'error':str(exc)}
|
|
134
|
+
journal['script_server']=script_server
|
|
135
|
+
if script_server.get('status')!='running':
|
|
136
|
+
journal['script_server_warning']=('Guest setup scripts are not being served. Start them with '
|
|
137
|
+
f'"python3 scripts/script_server.py start" before the guest runs its post-install step ({script_server.get("error","unknown error")}).')
|
|
138
|
+
base_url=(script_server or {}).get('guest_urls',{}).get('virtualbox_nat') or f'http://10.0.2.2:{SCRIPT_SERVER_PORT}'
|
|
117
139
|
try:
|
|
118
|
-
media=build(folder/'recorder-setup.iso')
|
|
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')
|
|
123
140
|
run('createvm','--name',name,'--ostype',os_type,'--register','--basefolder',folder.parent)
|
|
124
141
|
record('vm-created')
|
|
125
142
|
from display import preferences
|
|
@@ -127,11 +144,8 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
127
144
|
from shares import prepare
|
|
128
145
|
journal['recording_share']=prepare(name,run)
|
|
129
146
|
options=['modifyvm',name,'--memory',memory_mb,'--cpus',cpus,'--vram',128,
|
|
130
|
-
'--mouse','usbtablet','--nic1','nat','--boot1','
|
|
147
|
+
'--mouse','usbtablet','--nic1','nat','--boot1','dvd','--boot2','disk',
|
|
131
148
|
'--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']
|
|
135
149
|
if os_type=='Windows11_64':options+=['--firmware','efi','--tpm-type','2.0','--ioapic','on']
|
|
136
150
|
run(*options)
|
|
137
151
|
disk=folder/(name+'.vdi')
|
|
@@ -142,31 +156,29 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
142
156
|
if not unattended_supported:
|
|
143
157
|
run('storageattach',name,'--storagectl','SATA','--port','1','--device','0','--type','dvddrive','--medium',iso)
|
|
144
158
|
start_verified()
|
|
145
|
-
journal.update(status='installation_started',installation_mode='
|
|
159
|
+
journal.update(status='installation_started',installation_mode='manual',os_type=os_type,
|
|
146
160
|
frontend='headless',journal=str(journal_path),
|
|
147
|
-
credentials=
|
|
148
|
-
action_required='
|
|
149
|
-
|
|
150
|
-
|
|
161
|
+
credentials={'public_sandbox_credentials':False,'account_setup':'Choose your account in the OS installer'},
|
|
162
|
+
action_required=(f'This ISO needs a manual installation: complete the stock installer in the VM screen, '
|
|
163
|
+
f'choose your own guest account, then run the guest setup command from '
|
|
164
|
+
f'http://10.0.2.2:{SCRIPT_SERVER_PORT}/ (for example '
|
|
165
|
+
f'"wget -qO- {base_url}/setup.sh | sh"). No ISO was rewritten and no automatic account or recorder setup ran.'))
|
|
166
|
+
record('manual-installation-started')
|
|
151
167
|
return journal
|
|
152
|
-
# Recorder media stays on a dedicated DVD; unattended owns its own installer/auxiliary slots.
|
|
153
|
-
run('storageattach',name,'--storagectl','SATA','--port','3','--device','0','--type','dvddrive','--medium',media['iso'])
|
|
154
168
|
if os_type=='Windows11_64':
|
|
155
169
|
from display import insert_additions
|
|
156
170
|
journal['guest_additions']=insert_additions(name,run=run)
|
|
157
|
-
|
|
158
|
-
else:
|
|
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'"
|
|
160
|
-
args=['unattended','install',name,'--iso',iso,'--user','vboxuser',password_flag,'password123!',
|
|
171
|
+
install_args=['unattended','install',name,'--iso',iso,'--user','vboxuser',password_flag,'password123!',
|
|
161
172
|
'--full-user-name','VAMP Sandbox User','--hostname',name.lower()+'.vamp.local',
|
|
162
|
-
'--no-install-additions','--post-install-command',
|
|
173
|
+
'--no-install-additions','--post-install-command',post_install_command(selected,base_url)]
|
|
163
174
|
if os_type=='Windows11_64':
|
|
164
|
-
|
|
165
|
-
if product_key:
|
|
166
|
-
run(*
|
|
175
|
+
install_args+=['--image-index',image_index]
|
|
176
|
+
if product_key:install_args+=['--key',product_key]
|
|
177
|
+
run(*install_args,timeout=300)
|
|
167
178
|
start_verified()
|
|
168
179
|
journal.update(status='installation_started',installation_mode='unattended',os_type=os_type,frontend='headless',
|
|
169
|
-
recorder_setup='
|
|
180
|
+
recorder_setup=f'First login downloads the setup bundle from the host script server on port {SCRIPT_SERVER_PORT}',
|
|
181
|
+
guest_setup_command=f'wget -qO- {base_url}/setup.sh | sh' if selected!='windows11' else f'irm {base_url}/setup.ps1 | iex',
|
|
170
182
|
requires_ai_loop=False,journal=str(journal_path))
|
|
171
183
|
record('unattended-installation-started')
|
|
172
184
|
return journal
|
|
@@ -175,6 +187,7 @@ def create(iso_path,name=None,memory_mb=None,cpus=None,disk_mb=None,basedir=None
|
|
|
175
187
|
record('failed')
|
|
176
188
|
raise RuntimeError(f'{exc}; partial setup preserved at {folder}') from exc
|
|
177
189
|
|
|
190
|
+
|
|
178
191
|
if __name__=='__main__':
|
|
179
192
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
180
193
|
parser.add_argument('--json-stdin',action='store_true',required=True)
|