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.
Files changed (140) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +142 -107
  3. package/THIRD_PARTY_NOTICES.md +32 -27
  4. package/bin/vamp-mcp.mjs +37 -37
  5. package/notices/mcp-virtualbox-LICENSE +21 -21
  6. package/notices/mcp-virtualbox-PROVENANCE.json +37 -37
  7. package/package.json +51 -17
  8. package/runtime/backends/common/Test-Environment.ps1 +7 -6
  9. package/runtime/backends/common/guest-install.json +58 -0
  10. package/runtime/backends/common/guest_install.py +57 -0
  11. package/runtime/backends/common/host-support.cjs +16 -0
  12. package/runtime/backends/common/packer.cjs +16 -0
  13. package/runtime/backends/hyperv/scripts/Manage-Desktop.ps1 +40 -67
  14. package/runtime/backends/hyperv/scripts/Send-InstallerBoot.ps1 +25 -0
  15. package/runtime/backends/kvm/debian-preseed.cfg +35 -35
  16. package/runtime/backends/library/registry.py +77 -77
  17. package/runtime/backends/library/replay.py +154 -154
  18. package/runtime/backends/packer/answer_media.py +16 -0
  19. package/runtime/backends/packer/deploy-hyperv.ps1 +10 -0
  20. package/runtime/backends/packer/drivers.py +49 -0
  21. package/runtime/backends/packer/hyperv-network.ps1 +10 -0
  22. package/runtime/backends/packer/images.py +75 -0
  23. package/runtime/backends/packer/osinfo.py +113 -0
  24. package/runtime/backends/packer/policy.json +15 -0
  25. package/runtime/backends/packer/runner.py +224 -0
  26. package/runtime/backends/packer/templates.py +118 -0
  27. package/runtime/backends/packer/toolchain.py +80 -0
  28. package/runtime/backends/remote_ssh/server.mjs +321 -94
  29. package/runtime/backends/virtualbox/desktop.cjs +37 -0
  30. package/runtime/backends/virtualbox/display.py +101 -101
  31. package/runtime/backends/virtualbox/history.py +139 -139
  32. package/runtime/backends/virtualbox/mouse_click.py +15 -15
  33. package/runtime/backends/virtualbox/mouse_move.py +18 -18
  34. package/runtime/backends/virtualbox/profiles.json +46 -46
  35. package/runtime/backends/virtualbox/provision.py +238 -184
  36. package/runtime/backends/virtualbox/recording_listener.py +29 -29
  37. package/runtime/backends/virtualbox/recordings.py +39 -39
  38. package/runtime/backends/virtualbox/requirements.txt +7 -7
  39. package/runtime/backends/virtualbox/rpas/debian_first_boot/manifest.json +1 -1
  40. package/runtime/backends/virtualbox/rpas/debian_first_boot/run.robot +13 -13
  41. package/runtime/backends/virtualbox/rpas/debian_first_boot/workflow.py +75 -75
  42. package/runtime/backends/virtualbox/rpas/observe/manifest.json +7 -7
  43. package/runtime/backends/virtualbox/rpas/observe/run.robot +13 -13
  44. package/runtime/backends/virtualbox/rpas/observe/workflow.py +14 -14
  45. package/runtime/backends/virtualbox/server.mjs +440 -63
  46. package/runtime/backends/virtualbox/setup_windows_sdk.py +58 -58
  47. package/runtime/backends/virtualbox/shares.py +68 -68
  48. package/runtime/backends/virtualbox/snapshots.py +53 -53
  49. package/runtime/backends/virtualbox/transfers.py +89 -89
  50. package/runtime/backends/virtualbox/vnc.py +61 -61
  51. package/runtime/guest_keys.py +13 -13
  52. package/runtime/guest_setup/http/debian-preseed.cfg +39 -0
  53. package/runtime/guest_setup/http/postdeb.sh +94 -0
  54. package/runtime/guest_setup/http/postwin.ps1 +53 -0
  55. package/runtime/guest_setup/http/setup-all.ps1 +25 -0
  56. package/runtime/guest_setup/http/setup-win.cmd +7 -0
  57. package/runtime/guest_setup/http/setup.ps1 +44 -0
  58. package/runtime/guest_setup/http/setup.sh +50 -0
  59. package/runtime/guest_setup/kvm/setup-debian.sh +73 -0
  60. package/runtime/guest_setup/kvm/setup-windows.ps1 +52 -0
  61. package/runtime/guest_setup/recorder/README.txt +12 -8
  62. package/runtime/guest_setup/recorder/RECORDER-LICENSE +674 -674
  63. package/runtime/guest_setup/recorder/RECORDING-GUIDE.txt +31 -31
  64. package/runtime/guest_setup/recorder/apply-display.py +41 -41
  65. package/runtime/guest_setup/recorder/configure-debian-mirrors.py +62 -62
  66. package/runtime/guest_setup/recorder/configure-gdm.py +23 -0
  67. package/runtime/guest_setup/recorder/configure-session.ps1 +14 -0
  68. package/runtime/guest_setup/recorder/gnome-display.py +60 -60
  69. package/runtime/guest_setup/recorder/install-display-startup.py +66 -39
  70. package/runtime/guest_setup/recorder/install-hypervisor-drivers.ps1 +34 -0
  71. package/runtime/guest_setup/recorder/install-resolution-shortcut.ps1 +36 -0
  72. package/runtime/guest_setup/recorder/postwin.cmd +10 -10
  73. package/runtime/guest_setup/recorder/prepare-recording.py +30 -30
  74. package/runtime/guest_setup/recorder/recorder.zip +0 -0
  75. package/runtime/guest_setup/recorder/requirements-recorder.txt +2 -2
  76. package/runtime/guest_setup/recorder/session-policy.py +22 -0
  77. package/runtime/guest_setup/recorder/setup-user.py +53 -35
  78. package/runtime/guest_setup/recorder/setup-win.cmd +4 -11
  79. package/runtime/guest_setup/recorder/setup.ps1 +108 -30
  80. package/runtime/guest_setup/recorder/setup.sh +19 -1
  81. package/runtime/guest_setup/recorder/vamp-recorder.py +148 -148
  82. package/runtime/guest_setup/recorder/verify-recorder.py +4 -4
  83. package/runtime/guest_setup/recorder/windows-display.py +76 -76
  84. package/runtime/guest_setup/requirements.txt +2 -0
  85. package/runtime/guest_setup/setup-all.ps1 +35 -0
  86. package/runtime/guest_setup/setup-all.sh +22 -0
  87. package/runtime/guest_setup/vault/Install-VCRuntime.ps1 +26 -0
  88. package/runtime/guest_setup/vault/setup-guest-vault.ps1 +148 -0
  89. package/runtime/guest_setup/vault/setup-guest-vault.sh +75 -0
  90. package/runtime/recording_converter.py +230 -230
  91. package/runtime/requirements-mcp.txt +11 -11
  92. package/runtime/rpas/README.md +161 -161
  93. package/runtime/rpas/captcha_handoff/manifest.json +27 -27
  94. package/runtime/rpas/captcha_handoff/run.robot +16 -16
  95. package/runtime/rpas/captcha_handoff/workflow.py +11 -11
  96. package/runtime/rpas/common.resource +26 -26
  97. package/runtime/rpas/debian_update/manifest.json +27 -27
  98. package/runtime/rpas/debian_update/run.robot +17 -17
  99. package/runtime/rpas/debian_update/workflow.py +13 -13
  100. package/runtime/rpas/desktop_control/manifest.json +26 -26
  101. package/runtime/rpas/desktop_control/run.robot +27 -27
  102. package/runtime/rpas/desktop_control/workflow.py +51 -51
  103. package/runtime/rpas/firefox_launch/manifest.json +27 -27
  104. package/runtime/rpas/firefox_launch/run.robot +15 -15
  105. package/runtime/rpas/firefox_launch/workflow.py +25 -25
  106. package/runtime/rpas/firefox_naver/manifest.json +27 -27
  107. package/runtime/rpas/firefox_naver/run.robot +21 -21
  108. package/runtime/rpas/firefox_naver/workflow.py +28 -28
  109. package/runtime/rpas/kvm_validation/README.md +11 -11
  110. package/runtime/rpas/kvm_validation/manifest.json +28 -28
  111. package/runtime/rpas/kvm_validation/run.robot +30 -30
  112. package/runtime/rpas/kvm_validation/workflow.py +91 -91
  113. package/runtime/rpas/manifest.schema.json +105 -105
  114. package/runtime/rpas/naver_login/login.robot +25 -25
  115. package/runtime/rpas/naver_login/manifest.json +33 -33
  116. package/runtime/rpas/naver_login/run.robot +20 -20
  117. package/runtime/rpas/naver_login/workflow.py +32 -32
  118. package/runtime/rpas/windows_naver_recorded/README.md +24 -24
  119. package/runtime/rpas/windows_naver_recorded/conversion.json +25 -25
  120. package/runtime/rpas/windows_naver_recorded/manifest.json +28 -28
  121. package/runtime/rpas/windows_naver_recorded/run.robot +37 -37
  122. package/runtime/rpas/windows_naver_recorded/workflow.py +32 -32
  123. package/runtime/scripts/build_recorder_media.py +39 -39
  124. package/runtime/scripts/macos/setup-host.sh +126 -0
  125. package/runtime/scripts/remote_host_setup.sh +7 -4
  126. package/runtime/scripts/script_server.py +571 -0
  127. package/runtime/skills/vamp-rpa-ui-checks/SKILL.md +26 -0
  128. package/runtime/skills/vamp-rpa-ui-checks/agents/openai.yaml +4 -0
  129. package/runtime/skills/vamp-rpa-ui-checks/references/display.md +12 -0
  130. package/runtime/skills/vamp-rpa-ui-checks/references/user-guide.md +49 -0
  131. package/runtime/skills/vamp-ui-cleanup/SKILL.md +15 -0
  132. package/runtime/skills/vamp-ui-cleanup/agents/openai.yaml +4 -0
  133. package/runtime/skills/vamp-ui-validation/SKILL.md +27 -0
  134. package/runtime/skills/vamp-ui-validation/agents/openai.yaml +4 -0
  135. package/runtime/third_party/mcp-virtualbox/scripts/mouse_click.py +65 -65
  136. package/runtime/third_party/pyautogui-recorder/LICENSE +674 -674
  137. package/runtime/third_party/pyautogui-recorder/PROVENANCE.json +16 -16
  138. package/runtime/third_party/pyautogui-recorder/PyAutoGuiRecorder.py +169 -169
  139. package/runtime/third_party/pyautogui-recorder/README.md +53 -53
  140. package/runtime/scripts/build_debian_installer.py +0 -48
@@ -1,46 +1,46 @@
1
- {
2
- "schema_version": 1,
3
- "observed_at": "2026-11-15",
4
- "source": "Read-only VirtualBox showvminfo/showmediuminfo on current running user VMs, 2026-11-15. Capacity is virtual disk capacity, not allocated host space.",
5
- "profiles": {
6
- "windows11": {
7
- "memory_mb": 4096,
8
- "cpus": 2,
9
- "disk_mb": 256000,
10
- "firmware": "efi",
11
- "disk_allocation": "dynamic",
12
- "native_resolution": [
13
- 1920,
14
- 1080
15
- ],
16
- "reference_guest": "Win-RPA",
17
- "windows_license_required": true
18
- },
19
- "debian": {
20
- "memory_mb": 2048,
21
- "cpus": 2,
22
- "disk_mb": 256000,
23
- "firmware": "bios",
24
- "disk_allocation": "dynamic",
25
- "native_resolution": [
26
- 1920,
27
- 1080
28
- ],
29
- "reference_guest": "Debian-RPA",
30
- "windows_license_required": false
31
- },
32
- "ubuntu": {
33
- "memory_mb": 2048,
34
- "cpus": 2,
35
- "disk_mb": 256000,
36
- "firmware": "bios",
37
- "disk_allocation": "dynamic",
38
- "native_resolution": [
39
- 1920,
40
- 1080
41
- ],
42
- "reference_guest": "Debian-RPA resources only; Ubuntu guest not observed",
43
- "windows_license_required": false
44
- }
45
- }
46
- }
1
+ {
2
+ "schema_version": 1,
3
+ "observed_at": "2026-11-15",
4
+ "source": "Read-only VirtualBox showvminfo/showmediuminfo on current running user VMs, 2026-11-15. Capacity is virtual disk capacity, not allocated host space.",
5
+ "profiles": {
6
+ "windows11": {
7
+ "memory_mb": 4096,
8
+ "cpus": 2,
9
+ "disk_mb": 256000,
10
+ "firmware": "efi",
11
+ "disk_allocation": "dynamic",
12
+ "native_resolution": [
13
+ 1920,
14
+ 1080
15
+ ],
16
+ "reference_guest": "Win-RPA",
17
+ "windows_license_required": true
18
+ },
19
+ "debian": {
20
+ "memory_mb": 2048,
21
+ "cpus": 2,
22
+ "disk_mb": 256000,
23
+ "firmware": "bios",
24
+ "disk_allocation": "dynamic",
25
+ "native_resolution": [
26
+ 1920,
27
+ 1080
28
+ ],
29
+ "reference_guest": "Debian-RPA",
30
+ "windows_license_required": false
31
+ },
32
+ "ubuntu": {
33
+ "memory_mb": 2048,
34
+ "cpus": 2,
35
+ "disk_mb": 256000,
36
+ "firmware": "bios",
37
+ "disk_allocation": "dynamic",
38
+ "native_resolution": [
39
+ 1920,
40
+ 1080
41
+ ],
42
+ "reference_guest": "Debian-RPA resources only; Ubuntu guest not observed",
43
+ "windows_license_required": false
44
+ }
45
+ }
46
+ }
@@ -1,184 +1,238 @@
1
- """Deterministic VirtualBox unattended provisioning; no AI loop required."""
2
- from __future__ import annotations
3
- import argparse
4
- import json
5
- import os
6
- from pathlib import Path
7
- import re
8
- import shutil
9
- import subprocess
10
- import sys
11
- import time
12
- import uuid
13
-
14
- ROOT=Path(__file__).resolve().parents[2]
15
- sys.path.insert(0,str(ROOT/'scripts'))
16
- sys.path.insert(0,str(Path(__file__).resolve().parent))
17
- from build_recorder_media import build
18
- from build_debian_installer import build as build_debian_installer
19
-
20
- PUBLIC_CREDENTIALS={'username':'vboxuser','password':'password123!','public_sandbox_credentials':True}
21
-
22
- def parse(text):
23
- return {m[1].strip():m[2].strip() for line in text.splitlines()
24
- if (m:=re.match(r'([^=]+)="?(.*?)"?$',line.strip()))}
25
-
26
- def executable():
27
- if os.environ.get('VBOXMANAGE_PATH'): return os.environ['VBOXMANAGE_PATH']
28
- if sys.platform=='win32':
29
- candidate=Path(os.environ.get('PROGRAMFILES','C:/Program Files'))/'Oracle/VirtualBox/VBoxManage.exe'
30
- if candidate.is_file():return str(candidate)
31
- return shutil.which('VBoxManage') or 'VBoxManage'
32
-
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')
44
- name=name or ('VAMP-'+uuid.uuid4().hex[:8])
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')
46
- iso=Path(iso_path).expanduser().resolve(strict=True)
47
- if not iso.is_file():raise ValueError('ISO path must be a readable local file on the VM host')
48
- journal={'status':'preparing','vm':name,'credentials':PUBLIC_CREDENTIALS,'events':[],
49
- 'installation_verified':False,'recorder_installed_verified':False}
50
- folder=Path(basedir or Path.home()/'VirtualBox VMs').expanduser().resolve()/name
51
- def run(*args,timeout=120):
52
- proc=subprocess.run([executable(),*map(str,args)],capture_output=True,text=True,timeout=timeout)
53
- if proc.returncode:raise RuntimeError(f'VBoxManage {args[0]} failed: {proc.stderr.strip()[:500]}')
54
- return proc.stdout
55
- listed=run('list','vms')
56
- if any(line.startswith('"'+name+'" ') for line in listed.splitlines()):raise ValueError('VM name already exists; refusing to modify it')
57
- try:
58
- detected=parse(run('unattended','detect','--iso',iso,'--machine-readable'))
59
- except RuntimeError:
60
- manual_types={'debian':'Debian_64','ubuntu':'Ubuntu_64','windows11':'Windows11_64'}
61
- if not allow_manual_install or guest_os not in manual_types:raise
62
- detected={'OSTypeId':manual_types[guest_os],'IsInstallSupported':'false'}
63
- os_type=detected.get('OSTypeId',detected.get('detectedOSTypeId',''))
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'):
65
- raise ValueError(f'Only detected Debian/Ubuntu amd64 or Windows11 x64 ISO supported by this initial profile: {os_type or "unknown"}')
66
- unattended_supported=detected.get('IsInstallSupported',detected.get('isInstallSupported','true')).lower() in ('true','1','yes','on')
67
- if installation_mode=='manual':unattended_supported=False
68
- if not unattended_supported and not allow_manual_install:
69
- raise ValueError('VirtualBox reports this ISO does not support unattended installation')
70
- selected='windows11' if os_type=='Windows11_64' else ('ubuntu' if os_type.startswith('Ubuntu') else 'debian')
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'
73
- profile=json.loads(Path(__file__).with_name('profiles.json').read_text())['profiles'][selected]
74
- memory_mb=memory_mb if memory_mb is not None else profile['memory_mb']
75
- cpus=cpus if cpus is not None else profile['cpus']
76
- disk_mb=disk_mb if disk_mb is not None else profile['disk_mb']
77
- if not (2048<=memory_mb<=131072 and 1<=cpus<=64 and 32768<=disk_mb<=2097152 and image_index>=1):
78
- raise ValueError('Invalid VM resource/image limits')
79
- if preflight_only:
80
- return {'status':'preflight_ready','vm_created':False,'guest_os':selected,
81
- 'resource_profile':{'memory_mb':memory_mb,'cpus':cpus,'disk_mb':disk_mb},
82
- 'windows_confirmation_required':selected=='windows11' and not windows_confirmed,
83
- 'installation_mode':'unattended' if unattended_supported or custom_debian else 'manual',
84
- 'credentials':PUBLIC_CREDENTIALS,'iso':str(iso)}
85
- if selected=='windows11' and not windows_confirmed:
86
- return {'status':'needs_windows_confirmation','no_vm_created':True,'profile':profile,
87
- 'action_required':'Ask the user whether to create Windows with these specs. Windows requires a valid license; activate it yourself after installation in Settings > System > Activation. VAMP does not include a Windows license.',
88
- 'credentials':PUBLIC_CREDENTIALS}
89
- journal['resource_profile']={'guest_os':selected,'memory_mb':memory_mb,'cpus':cpus,'disk_mb':disk_mb,
90
- 'native_resolution':[1920,1080]}
91
- if selected=='windows11':journal['license_notice']='Windows requires a valid license. Activate Windows yourself after installation; VAMP supplies no license or activation bypass.'
92
- if os_type=='Windows11_64' and memory_mb<4096:raise ValueError('Windows 11 requires at least 4096 MB')
93
- # Check version-specific password option before creating any VM.
94
- help_text=''
95
- if unattended_supported:
96
- help_proc=subprocess.run([executable(),'unattended','install','--help'],capture_output=True,text=True)
97
- help_text=help_proc.stdout+help_proc.stderr
98
- password_flag='--user-password' if '--user-password' in help_text else '--password'
99
- assert_no_active_kvm()
100
- folder.mkdir(parents=True,exist_ok=False)
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')
114
- def record(stage):
115
- journal['events'].append(stage)
116
- journal_path.write_text(json.dumps(journal,indent=2)+'\n')
117
- 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
- run('createvm','--name',name,'--ostype',os_type,'--register','--basefolder',folder.parent)
124
- record('vm-created')
125
- from display import preferences
126
- journal['display']=preferences(name,run)
127
- from shares import prepare
128
- journal['recording_share']=prepare(name,run)
129
- options=['modifyvm',name,'--memory',memory_mb,'--cpus',cpus,'--vram',128,
130
- '--mouse','usbtablet','--nic1','nat','--boot1','disk' if custom_debian else 'dvd','--boot2','dvd' if custom_debian else 'disk',
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']
135
- if os_type=='Windows11_64':options+=['--firmware','efi','--tpm-type','2.0','--ioapic','on']
136
- run(*options)
137
- disk=folder/(name+'.vdi')
138
- run('createmedium','disk','--filename',disk,'--size',disk_mb,'--format','VDI')
139
- run('storagectl',name,'--name','SATA','--add','sata','--controller','IntelAhci','--portcount','4')
140
- run('storageattach',name,'--storagectl','SATA','--port','0','--device','0','--type','hdd','--medium',disk)
141
- run('storagectl',name,'--name','IDE','--add','ide')
142
- if not unattended_supported:
143
- run('storageattach',name,'--storagectl','SATA','--port','1','--device','0','--type','dvddrive','--medium',iso)
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')
151
- 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
- if os_type=='Windows11_64':
155
- from display import insert_additions
156
- journal['guest_additions']=insert_additions(name,run=run)
157
- hook='cmd.exe /c "for %%D in (D E F G H I J K L M N O P) do @if exist %%D:\\postwin.cmd call %%D:\\postwin.cmd"'
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!',
161
- '--full-user-name','VAMP Sandbox User','--hostname',name.lower()+'.vamp.local',
162
- '--no-install-additions','--post-install-command',hook]
163
- if os_type=='Windows11_64':
164
- args+=['--image-index',image_index]
165
- if product_key:args+=['--key',product_key]
166
- run(*args,timeout=300)
167
- start_verified()
168
- journal.update(status='installation_started',installation_mode='unattended',os_type=os_type,frontend='headless',
169
- recorder_setup='Debian postinstall; Windows first desktop login',
170
- requires_ai_loop=False,journal=str(journal_path))
171
- record('unattended-installation-started')
172
- return journal
173
- except Exception as exc:
174
- journal.update(status='failed',error=str(exc),partial_vm_preserved=True)
175
- record('failed')
176
- raise RuntimeError(f'{exc}; partial setup preserved at {folder}') from exc
177
-
178
- if __name__=='__main__':
179
- parser=argparse.ArgumentParser(description=__doc__)
180
- parser.add_argument('--json-stdin',action='store_true',required=True)
181
- parser.parse_args()
182
- try: print(json.dumps(create(**json.load(sys.stdin))))
183
- except Exception as exc:
184
- print(json.dumps({'status':'failed','error':str(exc)}));sys.exit(1)
1
+ """Deterministic VirtualBox unattended provisioning; no AI loop required."""
2
+ from __future__ import annotations
3
+ import argparse
4
+ import base64
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+ import re
9
+ import shutil
10
+ import subprocess
11
+ import sys
12
+ import time
13
+ import uuid
14
+
15
+ ROOT=Path(__file__).resolve().parents[2]
16
+ sys.path.insert(0,str(ROOT/'scripts'))
17
+ sys.path.insert(0,str(ROOT/'backends/common'))
18
+ from guest_install import PROFILE, require_install_host, efi_boot_plan, virtualbox_preseed, post_create_notice
19
+ sys.path.insert(0,str(Path(__file__).resolve().parent))
20
+ from script_server import SCRIPT_SERVER_PORT, guest_commands, start as start_script_server
21
+
22
+ PUBLIC_CREDENTIALS={'username':'vboxuser','password':'password123!','public_sandbox_credentials':True}
23
+
24
+
25
+ def parse(text):
26
+ return {m[1].strip():m[2].strip() for line in text.splitlines()
27
+ if (m:=re.match(r'([^=]+)=\"?(.*?)\"?$',line.strip()))}
28
+
29
+
30
+ def executable():
31
+ if os.environ.get('VBOXMANAGE_PATH'): return os.environ['VBOXMANAGE_PATH']
32
+ if sys.platform=='win32':
33
+ candidate=Path(os.environ.get('PROGRAMFILES','C:/Program Files'))/'Oracle/VirtualBox/VBoxManage.exe'
34
+ if candidate.is_file():return str(candidate)
35
+ return shutil.which('VBoxManage') or 'VBoxManage'
36
+
37
+
38
+ def assert_no_active_kvm():
39
+ if not sys.platform.startswith('linux'):return
40
+ for uri in ('qemu:///session','qemu:///system'):
41
+ try:
42
+ result=subprocess.run(['virsh','-c',uri,'list','--name'],capture_output=True,text=True,timeout=10)
43
+ except (FileNotFoundError,subprocess.TimeoutExpired):continue
44
+ if result.returncode==0 and result.stdout.strip():
45
+ raise RuntimeError('A KVM VM is active. Shut it down before starting VirtualBox; simultaneous execution can cause VERR_SVM_IN_USE.')
46
+
47
+
48
+ def post_install_command(guest_os, base_url):
49
+ """Post-install hook fetched from the host script server; no ISO is rewritten or mounted."""
50
+ if guest_os=='windows11':
51
+ command=("$ErrorActionPreference='Stop'; $p=Join-Path $env:TEMP 'vamp-postwin.ps1'; "
52
+ "for($i=0;$i -lt 30;$i++){try{"
53
+ f"Invoke-WebRequest -UseBasicParsing -Uri '{base_url}/postwin.ps1' -OutFile $p -TimeoutSec 20; break"
54
+ "}catch{if($i -eq 29){throw}; Start-Sleep -Seconds 3}}; & $p")
55
+ # VBox's VBOXPOST.CMD also echoes this command inside double quotes.
56
+ # A nested -Command string exposes its pipe/operators to cmd.exe there.
57
+ encoded=base64.b64encode(command.encode('utf-16-le')).decode('ascii')
58
+ return f'powershell.exe -NoProfile -ExecutionPolicy Bypass -EncodedCommand {encoded}'
59
+ return f'wget -qO /tmp/vamp-postdeb.sh {base_url}/postdeb.sh && sh /tmp/vamp-postdeb.sh'
60
+
61
+
62
+ 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=7200):
63
+ require_install_host('virtualbox')
64
+ if installation_mode not in ('auto','manual'):raise ValueError('installation_mode must be auto or manual')
65
+ name=name or ('VAMP-'+uuid.uuid4().hex[:8])
66
+ 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')
67
+ iso=Path(iso_path).expanduser().resolve(strict=True)
68
+ if not iso.is_file():raise ValueError('ISO path must be a readable local file on the VM host')
69
+ journal={'status':'preparing','vm':name,'credentials':PUBLIC_CREDENTIALS,'events':[],
70
+ 'installation_verified':False,'recorder_installed_verified':False,
71
+ 'development_only':os.environ.get('VAMP_DEVELOPMENT_VM')=='1',
72
+ 'guest_setup_transport':f'http://10.0.2.2:{SCRIPT_SERVER_PORT} (host Python script server)'}
73
+ folder=Path(basedir or Path.home()/'VirtualBox VMs').expanduser().resolve()/name
74
+ def run(*args,timeout=120):
75
+ proc=subprocess.run([executable(),*map(str,args)],capture_output=True,text=True,timeout=timeout)
76
+ if proc.returncode:raise RuntimeError(f'VBoxManage {args[0]} failed: {proc.stderr.strip()[:500]}')
77
+ return proc.stdout
78
+ listed=run('list','vms')
79
+ if any(line.startswith('"'+name+'" ') for line in listed.splitlines()):raise ValueError('VM name already exists; refusing to modify it')
80
+ try:
81
+ detected=parse(run('unattended','detect','--iso',iso,'--machine-readable'))
82
+ except RuntimeError:
83
+ manual_types={'debian':'Debian_64','ubuntu':'Ubuntu_64','windows11':'Windows11_64'}
84
+ if guest_os not in manual_types or not (allow_manual_install or (guest_os=='debian' and installation_mode=='auto')):raise
85
+ detected={'OSTypeId':manual_types[guest_os],'IsInstallSupported':'false'}
86
+ os_type=detected.get('OSTypeId',detected.get('detectedOSTypeId',''))
87
+ 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'):
88
+ raise ValueError(f'Only detected Debian/Ubuntu amd64 or Windows11 x64 ISO supported by this initial profile: {os_type or "unknown"}')
89
+ unattended_supported=detected.get('IsInstallSupported',detected.get('isInstallSupported','true')).lower() in ('true','1','yes','on')
90
+ if installation_mode=='manual':unattended_supported=False
91
+ direct_debian_boot=(installation_mode=='auto' and guest_os=='debian' and not unattended_supported)
92
+ if not unattended_supported and not allow_manual_install and not direct_debian_boot:
93
+ raise ValueError('VirtualBox reports this ISO does not support unattended installation')
94
+ selected='windows11' if os_type=='Windows11_64' else ('ubuntu' if os_type.startswith('Ubuntu') else 'debian')
95
+ if guest_os and guest_os!=selected:raise ValueError('Selected guest OS does not match detected ISO')
96
+ profile=json.loads(Path(__file__).with_name('profiles.json').read_text())['profiles'][selected]
97
+ memory_mb=memory_mb if memory_mb is not None else profile['memory_mb']
98
+ cpus=cpus if cpus is not None else profile['cpus']
99
+ disk_mb=disk_mb if disk_mb is not None else profile['disk_mb']
100
+ if not (2048<=memory_mb<=131072 and 1<=cpus<=64 and 32768<=disk_mb<=2097152 and image_index>=1):
101
+ raise ValueError('Invalid VM resource/image limits')
102
+ if preflight_only:
103
+ return {'status':'preflight_ready','vm_created':False,'guest_os':selected,
104
+ 'resource_profile':{'memory_mb':memory_mb,'cpus':cpus,'disk_mb':disk_mb},
105
+ 'windows_confirmation_required':selected=='windows11' and not windows_confirmed,
106
+ 'installation_mode':'unattended' if unattended_supported or direct_debian_boot else 'manual',
107
+ 'guest_setup':{'transport':'http','port':SCRIPT_SERVER_PORT,'commands':guest_commands(SCRIPT_SERVER_PORT)},
108
+ 'credentials':PUBLIC_CREDENTIALS,'iso':str(iso)}
109
+ if selected=='windows11' and not windows_confirmed:
110
+ return {'status':'needs_windows_confirmation','no_vm_created':True,'profile':profile,
111
+ 'action_required':'Ask the user whether to create Windows with these specs. Windows requires a valid license; activate it yourself after installation in Settings > System > Activation. VAMP does not include a Windows license.',
112
+ 'credentials':PUBLIC_CREDENTIALS}
113
+ journal['resource_profile']={'guest_os':selected,'memory_mb':memory_mb,'cpus':cpus,'disk_mb':disk_mb,
114
+ 'native_resolution':[1920,1080]}
115
+ if selected=='windows11':journal['license_notice']='Windows requires a valid license. Activate Windows yourself after installation; VAMP supplies no license or activation bypass.'
116
+ if os_type=='Windows11_64' and memory_mb<4096:raise ValueError('Windows 11 requires at least 4096 MB')
117
+ # Check version-specific password option before creating any VM.
118
+ help_text=''
119
+ if unattended_supported:
120
+ help_proc=subprocess.run([executable(),'unattended','install','--help'],capture_output=True,text=True)
121
+ help_text=help_proc.stdout+help_proc.stderr
122
+ password_flag='--user-password' if '--user-password' in help_text else '--password'
123
+ assert_no_active_kvm()
124
+ folder.mkdir(parents=True,exist_ok=False)
125
+ journal_path=folder/'vamp-install.json'
126
+ def start_verified():
127
+ # startvm waits for its session to open; still verify the hypervisor state.
128
+ run('startvm',name,'--type','headless')
129
+ state=''
130
+ for attempt in range(15):
131
+ state=parse(run('showvminfo',name,'--machinereadable')).get('VMState','unknown')
132
+ if state=='running':
133
+ journal.update(vm_state=state,startup_verified=True)
134
+ # Stock Windows install media waits for a key before booting.
135
+ # Send once on the initial provisioning boot, never on later reboots.
136
+ if selected=='windows11':
137
+ time.sleep(PROFILE['boot_wait_seconds'])
138
+ run('controlvm',name,'keyboardputscancode','1c','9c')
139
+ journal['events'].append('installer-boot-enter-sent')
140
+ return
141
+ if state not in ('starting','restoring'):break
142
+ time.sleep(1)
143
+ raise RuntimeError(f'VM creation completed but startup was not verified (state: {state}); inspect the VM log')
144
+ def record(stage):
145
+ journal['events'].append(stage)
146
+ journal_path.write_text(json.dumps(journal,indent=2)+'\n')
147
+ script_server=None
148
+ if serve_scripts and not os.environ.get('VAMP_SCRIPT_SERVER_DISABLE'):
149
+ try:
150
+ script_server=start_script_server(port=SCRIPT_SERVER_PORT,ttl=script_server_ttl)
151
+ except Exception as exc:
152
+ script_server={'status':'failed','port':SCRIPT_SERVER_PORT,'error':str(exc)}
153
+ journal['script_server']=script_server
154
+ if script_server.get('status')!='running':
155
+ journal.update(status='failed',error='Guest setup HTTP server could not start: '+str(script_server.get('error',script_server.get('status'))))
156
+ record('script-server-failed')
157
+ raise RuntimeError(journal['error'])
158
+ base_url=(script_server or {}).get('guest_urls',{}).get('virtualbox_nat') or f'http://10.0.2.2:{SCRIPT_SERVER_PORT}'
159
+ journal['post_create_notice']=post_create_notice(selected,base_url)
160
+ try:
161
+ run('createvm','--name',name,'--ostype',os_type,'--register','--basefolder',folder.parent)
162
+ record('vm-created')
163
+ from display import preferences
164
+ journal['display']=preferences(name,run)
165
+ from shares import prepare
166
+ journal['recording_share']=prepare(name,run)
167
+ options=['modifyvm',name,'--memory',memory_mb,'--cpus',cpus,'--vram',128,
168
+ '--mouse','usbtablet','--nic1','nat','--nat-localhostreachable1','on','--boot1','dvd','--boot2','disk',
169
+ '--graphicscontroller','vboxsvga' if os_type=='Windows11_64' else 'vmsvga']
170
+ if os_type=='Windows11_64':options+=['--firmware','efi','--tpm-type','2.0','--ioapic','on']
171
+ if direct_debian_boot:options+=['--firmware','efi']
172
+ run(*options)
173
+ disk=folder/(name+'.vdi')
174
+ run('createmedium','disk','--filename',disk,'--size',disk_mb,'--format','VDI')
175
+ run('storagectl',name,'--name','SATA','--add','sata','--controller','IntelAhci','--portcount','4')
176
+ run('storageattach',name,'--storagectl','SATA','--port','0','--device','0','--type','hdd','--medium',disk)
177
+ run('storagectl',name,'--name','IDE','--add','ide')
178
+ if not unattended_supported:
179
+ run('storageattach',name,'--storagectl','SATA','--port','1','--device','0','--type','dvddrive','--medium',iso)
180
+ start_verified()
181
+ if direct_debian_boot:
182
+ # Debian 13 DVD detection is unimplemented in some VBox builds.
183
+ # Boot the stock EFI GRUB console with the HTTP preseed instead.
184
+ time.sleep(PROFILE['boot_wait_seconds'])
185
+ for step in efi_boot_plan('debian',base_url):
186
+ if step['kind']=='wait':time.sleep(step['seconds'])
187
+ elif step['kind'] in ('text','line'):
188
+ run('controlvm',name,'keyboardputstring',step['text'])
189
+ if step['kind'] in ('line','enter'):
190
+ run('controlvm',name,'keyboardputscancode','1c','9c')
191
+ journal.update(status='installation_started',installation_mode='unattended',boot_method='efi-http-preseed',os_type=os_type,credentials=PUBLIC_CREDENTIALS,journal=str(journal_path))
192
+ record('debian-http-preseed-boot-dispatched')
193
+ return journal
194
+ journal.update(status='installation_started',installation_mode='manual',os_type=os_type,
195
+ frontend='headless',journal=str(journal_path),
196
+ credentials={'public_sandbox_credentials':False,'account_setup':'Choose your account in the OS installer'},
197
+ action_required=(f'This ISO needs a manual installation: complete the stock installer in the VM screen, '
198
+ f'choose your own guest account, then run the guest setup command from '
199
+ f'http://10.0.2.2:{SCRIPT_SERVER_PORT}/ (for example '
200
+ f'"wget -qO- {base_url}/setup.sh | sh"). No ISO was rewritten and no automatic account or recorder setup ran.'))
201
+ record('manual-installation-started')
202
+ return journal
203
+ if os_type=='Windows11_64':
204
+ from display import insert_additions
205
+ journal['guest_additions']=insert_additions(name,run=run)
206
+ install_args=['unattended','install',name,'--iso',iso,'--user','vboxuser',password_flag,'password123!',
207
+ '--full-user-name','VAMP Sandbox User','--hostname',name.lower()+'.vamp.local',
208
+ '--no-install-additions','--post-install-command',post_install_command(selected,base_url)]
209
+ if selected=='debian':
210
+ template=folder/'debian-preseed.cfg'
211
+ template.write_text(virtualbox_preseed(),encoding='utf-8')
212
+ install_args+=['--script-template',str(template)]
213
+ if os_type=='Windows11_64':
214
+ install_args+=['--image-index',image_index]
215
+ if product_key:install_args+=['--key',product_key]
216
+ run(*install_args,timeout=300)
217
+ start_verified()
218
+ journal.update(status='installation_started',installation_mode='unattended',os_type=os_type,frontend='headless',
219
+ recorder_setup=f'First login downloads the setup bundle from the host script server on port {SCRIPT_SERVER_PORT}',
220
+ guest_setup_command=f'wget -qO- {base_url}/setup.sh | sh' if selected!='windows11' else f'irm {base_url}/setup.ps1 | iex',
221
+ requires_ai_loop=False,journal=str(journal_path))
222
+ record('unattended-installation-started')
223
+ return journal
224
+ except Exception as exc:
225
+ journal.update(status='failed',error=str(exc),partial_vm_preserved=True)
226
+ record('failed')
227
+ raise RuntimeError(f'{exc}; partial setup preserved at {folder}') from exc
228
+
229
+
230
+ if __name__=='__main__':
231
+ parser=argparse.ArgumentParser(description=__doc__)
232
+ parser.add_argument('--json-stdin',action='store_true',required=True)
233
+ parser.parse_args()
234
+ sys.path.insert(0,str(ROOT/'backends/packer'))
235
+ from runner import create as packer_create
236
+ try: print(json.dumps(packer_create({'backend':'virtualbox',**json.load(sys.stdin)})))
237
+ except Exception as exc:
238
+ print(json.dumps({'status':'failed','error':str(exc)}));sys.exit(1)
@@ -1,29 +1,29 @@
1
- """Robot Framework v3 listener: optional low-resolution video and SQLite evidence."""
2
- import sys
3
- from pathlib import Path
4
- sys.path.insert(0,str(Path(__file__).resolve().parent))
5
- from history import begin,capture,end,event
6
-
7
- class RecordingListener:
8
- ROBOT_LISTENER_API_VERSION=3
9
- def __init__(self,vm,video='false'):
10
- self.vm=vm;self.video=str(video).lower() in ('true','1','yes');self.depth=0;self.run_id=None
11
- def start_suite(self,data,result):
12
- self.depth+=1
13
- if self.depth==1:
14
- try:self.run_id=begin(self.vm,self.video)['run_id']
15
- except Exception as exc:
16
- from robot.api import logger
17
- logger.warn('VAMP evidence initialization failed: '+str(exc))
18
- def end_test(self,data,result):
19
- if self.run_id:
20
- event(self.run_id,'robot_task',{'name':result.name,'status':result.status,'elapsed_ms':int(result.elapsed_time.total_seconds()*1000)})
21
- try:capture(self.run_id,'task-'+result.status.lower())
22
- except Exception as exc:event(self.run_id,'capture_error',{'error':str(exc)[:300]})
23
- def end_suite(self,data,result):
24
- if self.depth==1 and self.run_id:
25
- try:end(self.run_id,result.status)
26
- except Exception as exc:
27
- from robot.api import logger
28
- logger.warn('VAMP evidence finalization failed: '+str(exc))
29
- self.depth-=1
1
+ """Robot Framework v3 listener: optional low-resolution video and SQLite evidence."""
2
+ import sys
3
+ from pathlib import Path
4
+ sys.path.insert(0,str(Path(__file__).resolve().parent))
5
+ from history import begin,capture,end,event
6
+
7
+ class RecordingListener:
8
+ ROBOT_LISTENER_API_VERSION=3
9
+ def __init__(self,vm,video='false'):
10
+ self.vm=vm;self.video=str(video).lower() in ('true','1','yes');self.depth=0;self.run_id=None
11
+ def start_suite(self,data,result):
12
+ self.depth+=1
13
+ if self.depth==1:
14
+ try:self.run_id=begin(self.vm,self.video)['run_id']
15
+ except Exception as exc:
16
+ from robot.api import logger
17
+ logger.warn('VAMP evidence initialization failed: '+str(exc))
18
+ def end_test(self,data,result):
19
+ if self.run_id:
20
+ event(self.run_id,'robot_task',{'name':result.name,'status':result.status,'elapsed_ms':int(result.elapsed_time.total_seconds()*1000)})
21
+ try:capture(self.run_id,'task-'+result.status.lower())
22
+ except Exception as exc:event(self.run_id,'capture_error',{'error':str(exc)[:300]})
23
+ def end_suite(self,data,result):
24
+ if self.depth==1 and self.run_id:
25
+ try:end(self.run_id,result.status)
26
+ except Exception as exc:
27
+ from robot.api import logger
28
+ logger.warn('VAMP evidence finalization failed: '+str(exc))
29
+ self.depth-=1