| author | |
| committer | |
| log | 38232d1d522b2c555b7ccf5fd3d84499829fb64e |
| tree | 194d7e900ff7dad288d876059f8f7ac16acb9f65 |
| parent | 2a5ae6ab62a20d20e9077bde2718caf8c50fce89 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Report the actual Windows token elevation and desktop session, or Unix UID/GID and account name, without changing execution privileges. Distinguish hardware accelerated libvirt domains from emulated domains in status, including when stopped.
Verified Linux identity against id, Windows elevated and least-privilege tokens against actual command integrity labels, and an isolated stopped emulated domain. 43 protocol tests, 28 VM boundary tests, 61 Rust tests and the OAuth client integration pass.
Assisted-by: gpt-6.1-sol4 files changed, 13 insertions(+), 3 deletions(-)
dashboard/src/computer-tools.json+2-2| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | }, |
| 15 | 15 | { |
| 16 | 16 | "name": "computer_status", |
| 17 | "description": "Report VM power, command readiness, runtimes and desktop capabilities. Status and screenshots remain available during commands on Linux-hosted VMs. Use active_operation.id with computer_process to inspect or cancel an active operation. Available runtimes do not prove a particular command succeeded.", | |
| 17 | "description": "Report VM power, command readiness, CPU acceleration, runtimes, execution context and desktop capabilities. Status and screenshots remain available during commands on Linux-hosted VMs. Use active_operation.id with computer_process to inspect or cancel an active operation. Available runtimes do not prove a particular command succeeded.", | |
| 18 | 18 | "inputSchema": { |
| 19 | 19 | "type": "object", |
| 20 | 20 | "properties": { |
| ... | ... | @@ -339,7 +339,7 @@ |
| 339 | 339 | }, |
| 340 | 340 | { |
| 341 | 341 | "name": "computer_exec", |
| 342 | "description": "Run a script in the VM’s logged-in desktop session. Runtimes come from computer_status: zsh/bash on Unix, PowerShell/cmd/AutoHotkey v2 on Windows. Default uses the platform shell. AHK sets Mouse/Pixel CoordMode to Screen; SendText types literal text and FileAppend(text,\"*\") writes stdout. Returns bounded stdout/stderr, exit status, timeout state and optional screenshot. Timeout stops the command group; effects already performed remain. Use computer_spawn for persistent apps.", | |
| 342 | "description": "Run a script in the VM’s logged-in desktop session. Runtimes come from computer_status: zsh/bash on Unix, PowerShell/cmd/AutoHotkey v2 on Windows. Default uses the platform shell. Windows uses the desktop account's highest available privileges; check execution_context in computer_status. AHK sets Mouse/Pixel CoordMode to Screen; SendText types literal text and FileAppend(text,\"*\") writes stdout. Returns bounded stdout/stderr, exit status, timeout state and optional screenshot. Timeout stops the command group; effects already performed remain. Use computer_spawn for persistent apps.", | |
| 343 | 343 | "inputSchema": { |
| 344 | 344 | "type": "object", |
| 345 | 345 | "properties": { |
guest/computer-windows.cs+8-1| ... | ... | @@ -121,6 +121,7 @@ public static class ComputerWorker { |
| 121 | 121 | static string Text(System.Collections.Generic.Dictionary<string,object> value, string key, string fallback = "") { return Convert.ToString(Get(value,key,fallback)); } |
| 122 | 122 | static int Number(System.Collections.Generic.Dictionary<string,object> value, string key, int fallback = 0) { return Convert.ToInt32(Get(value,key,fallback)); } |
| 123 | 123 | [DllImport("user32.dll")] static extern bool SetProcessDPIAware(); |
| 124 | [DllImport("advapi32.dll",SetLastError=true)] static extern bool GetTokenInformation(IntPtr token,int informationClass,out int elevation,int length,out int returned); | |
| 124 | 125 | [STAThread] public static int Main(string[] args) { |
| 125 | 126 | if(args.Length==2 && (args[0]=="--prepare" || args[0]=="--cleanup" || args[0]=="--release")) { |
| 126 | 127 | try { |
| ... | ... | @@ -269,7 +270,13 @@ public static class ComputerWorker { |
| 269 | 270 | string action=Text(request,"action");string root=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); |
| 270 | 271 | if(action=="status") { |
| 271 | 272 | var runtimes=new System.Collections.Generic.List<string>(new[]{"powershell","cmd"});if(System.IO.File.Exists(System.IO.Path.Combine(root,"AutoHotkey.exe")))runtimes.Add("ahk"); |
| 272 | return new {platform="windows",hostname=Environment.MachineName,runtimes=runtimes,capabilities=new[]{"shot","input","ui","ui_action","exec","spawn","process","file"},coordinate_units="screenshot_pixels",max_timeout_ms=180000}; | |
| 273 | using(var identity=System.Security.Principal.WindowsIdentity.GetCurrent()) | |
| 274 | using(var process=Process.GetCurrentProcess()) { | |
| 275 | int elevation,returned; | |
| 276 | if(!GetTokenInformation(identity.Token,20,out elevation,4,out returned))throw new System.ComponentModel.Win32Exception(); | |
| 277 | return new {platform="windows",hostname=Environment.MachineName,runtimes=runtimes,capabilities=new[]{"shot","input","ui","ui_action","exec","spawn","process","file"},coordinate_units="screenshot_pixels",max_timeout_ms=180000, | |
| 278 | execution_context=new {user=identity.Name,elevated=elevation!=0,session=process.SessionId}}; | |
| 279 | } | |
| 273 | 280 | } |
| 274 | 281 | if(action=="input") { |
| 275 | 282 | var actions=(object[])Get(request,"actions");foreach(var value in actions) {var item=Map(value);if(Text(item,"type")!="text")throw new Exception("Use the VM console for pointer and key actions.");ComputerProcess.Type(Text(item,"text"));}return new {completed=actions.Length}; |
tools/mac-computer.py+2| ... | ... | @@ -8,6 +8,7 @@ import shutil |
| 8 | 8 | import stat |
| 9 | 9 | import uuid |
| 10 | 10 | import os |
| 11 | import pwd | |
| 11 | 12 | from pathlib import Path |
| 12 | 13 | import selectors |
| 13 | 14 | import signal |
| ... | ... | @@ -277,6 +278,7 @@ def execute(request): |
| 277 | 278 | except (ImportError, ValueError): |
| 278 | 279 | permissions["accessibility"] = False |
| 279 | 280 | return {"permissions": permissions, "hostname": os.uname().nodename, |
| 281 | "execution_context": {"user": pwd.getpwuid(os.geteuid()).pw_name, "uid": os.geteuid(), "gid": os.getegid(), "elevated": os.geteuid() == 0}, | |
| 280 | 282 | "platform": "macos" if MAC else "linux", "runtimes": [r for r in ("zsh","bash") if shutil.which(r)], |
| 281 | 283 | "capabilities": ["shot","input","exec","spawn","process","file"] + (["ui","ui_action"] if permissions.get("accessibility") else []), |
| 282 | 284 | "max_timeout_ms": 180000, "coordinate_units":"screenshot_pixels"} |
tools/vm-computer.py+1| ... | ... | @@ -573,6 +573,7 @@ def handle(name, request, *, active_snapshot=None): |
| 573 | 573 | power = vms.virsh('domstate',name,timeout=remaining(15)).strip() |
| 574 | 574 | platform = root.findtext(f'metadata/{vms.NS}vm/{vms.NS}platform','linux') |
| 575 | 575 | status = {'platform': platform, 'power_state': power, 'readiness': 'starting', |
| 576 | 'cpu_acceleration': {'kvm': 'hardware', 'qemu': 'emulated'}.get(root.get('type')), | |
| 576 | 577 | 'capabilities': ['shot', 'input'] if power == 'running' else [], |
| 577 | 578 | 'runtimes': [], 'coordinate_units': 'screenshot_pixels'} |
| 578 | 579 | if power != 'running': |