authoravatarclover caruso<git@paperclover.net>2026-11-17 00:33:39-08:00
committeravatarclover caruso<git@paperclover.net>2026-11-22 00:44:02-08:00
log38232d1d522b2c555b7ccf5fd3d84499829fb64e
tree194d7e900ff7dad288d876059f8f7ac16acb9f65
parent2a5ae6ab62a20d20e9077bde2718caf8c50fce89
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Report VM command identity, elevation and CPU acceleration

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-sol

4 files changed, 13 insertions(+), 3 deletions(-)

dashboard/src/computer-tools.json+2-2
......@@ -14,7 +14,7 @@
1414 },
1515 {
1616 "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.",
1818 "inputSchema": {
1919 "type": "object",
2020 "properties": {
......@@ -339,7 +339,7 @@
339339 },
340340 {
341341 "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.",
343343 "inputSchema": {
344344 "type": "object",
345345 "properties": {
guest/computer-windows.cs+8-1
......@@ -121,6 +121,7 @@ public static class ComputerWorker {
121121 static string Text(System.Collections.Generic.Dictionary<string,object> value, string key, string fallback = "") { return Convert.ToString(Get(value,key,fallback)); }
122122 static int Number(System.Collections.Generic.Dictionary<string,object> value, string key, int fallback = 0) { return Convert.ToInt32(Get(value,key,fallback)); }
123123 [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);
124125 [STAThread] public static int Main(string[] args) {
125126 if(args.Length==2 && (args[0]=="--prepare" || args[0]=="--cleanup" || args[0]=="--release")) {
126127 try {
......@@ -269,7 +270,13 @@ public static class ComputerWorker {
269270 string action=Text(request,"action");string root=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
270271 if(action=="status") {
271272 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 }
273280 }
274281 if(action=="input") {
275282 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
88import stat
99import uuid
1010import os
11import pwd
1112from pathlib import Path
1213import selectors
1314import signal
......@@ -277,6 +278,7 @@ def execute(request):
277278 except (ImportError, ValueError):
278279 permissions["accessibility"] = False
279280 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},
280282 "platform": "macos" if MAC else "linux", "runtimes": [r for r in ("zsh","bash") if shutil.which(r)],
281283 "capabilities": ["shot","input","exec","spawn","process","file"] + (["ui","ui_action"] if permissions.get("accessibility") else []),
282284 "max_timeout_ms": 180000, "coordinate_units":"screenshot_pixels"}
tools/vm-computer.py+1
......@@ -573,6 +573,7 @@ def handle(name, request, *, active_snapshot=None):
573573 power = vms.virsh('domstate',name,timeout=remaining(15)).strip()
574574 platform = root.findtext(f'metadata/{vms.NS}vm/{vms.NS}platform','linux')
575575 status = {'platform': platform, 'power_state': power, 'readiness': 'starting',
576 'cpu_acceleration': {'kvm': 'hardware', 'qemu': 'emulated'}.get(root.get('type')),
576577 'capabilities': ['shot', 'input'] if power == 'running' else [],
577578 'runtimes': [], 'coordinate_units': 'screenshot_pixels'}
578579 if power != 'running':