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 @@...@@ -14,7 +14,7 @@
14 },14 },
15 {15 {
16 "name": "computer_status",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 "inputSchema": {18 "inputSchema": {
19 "type": "object",19 "type": "object",
20 "properties": {20 "properties": {
...@@ -339,7 +339,7 @@...@@ -339,7 +339,7 @@
339 },339 },
340 {340 {
341 "name": "computer_exec",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 "inputSchema": {343 "inputSchema": {
344 "type": "object",344 "type": "object",
345 "properties": {345 "properties": {
guest/computer-windows.cs+8-1
...@@ -121,6 +121,7 @@ public static class ComputerWorker {...@@ -121,6 +121,7 @@ public static class ComputerWorker {
121 static string Text(System.Collections.Generic.Dictionary<string,object> value, string key, string fallback = "") { return Convert.ToString(Get(value,key,fallback)); }121 static string Text(System.Collections.Generic.Dictionary<string,object> value, string key, string fallback = "") { return Convert.ToString(Get(value,key,fallback)); }
122 static int Number(System.Collections.Generic.Dictionary<string,object> value, string key, int fallback = 0) { return Convert.ToInt32(Get(value,key,fallback)); }122 static int Number(System.Collections.Generic.Dictionary<string,object> value, string key, int fallback = 0) { return Convert.ToInt32(Get(value,key,fallback)); }
123 [DllImport("user32.dll")] static extern bool SetProcessDPIAware();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 [STAThread] public static int Main(string[] args) {125 [STAThread] public static int Main(string[] args) {
125 if(args.Length==2 && (args[0]=="--prepare" || args[0]=="--cleanup" || args[0]=="--release")) {126 if(args.Length==2 && (args[0]=="--prepare" || args[0]=="--cleanup" || args[0]=="--release")) {
126 try {127 try {
...@@ -269,7 +270,13 @@ public static class ComputerWorker {...@@ -269,7 +270,13 @@ public static class ComputerWorker {
269 string action=Text(request,"action");string root=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);270 string action=Text(request,"action");string root=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
270 if(action=="status") {271 if(action=="status") {
271 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 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 if(action=="input") {281 if(action=="input") {
275 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};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,6 +8,7 @@ import shutil
8import stat8import stat
9import uuid9import uuid
10import os10import os
11import pwd
11from pathlib import Path12from pathlib import Path
12import selectors13import selectors
13import signal14import signal
...@@ -277,6 +278,7 @@ def execute(request):...@@ -277,6 +278,7 @@ def execute(request):
277 except (ImportError, ValueError):278 except (ImportError, ValueError):
278 permissions["accessibility"] = False279 permissions["accessibility"] = False
279 return {"permissions": permissions, "hostname": os.uname().nodename,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 "platform": "macos" if MAC else "linux", "runtimes": [r for r in ("zsh","bash") if shutil.which(r)],282 "platform": "macos" if MAC else "linux", "runtimes": [r for r in ("zsh","bash") if shutil.which(r)],
281 "capabilities": ["shot","input","exec","spawn","process","file"] + (["ui","ui_action"] if permissions.get("accessibility") else []),283 "capabilities": ["shot","input","exec","spawn","process","file"] + (["ui","ui_action"] if permissions.get("accessibility") else []),
282 "max_timeout_ms": 180000, "coordinate_units":"screenshot_pixels"}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,6 +573,7 @@ def handle(name, request, *, active_snapshot=None):
573 power = vms.virsh('domstate',name,timeout=remaining(15)).strip()573 power = vms.virsh('domstate',name,timeout=remaining(15)).strip()
574 platform = root.findtext(f'metadata/{vms.NS}vm/{vms.NS}platform','linux')574 platform = root.findtext(f'metadata/{vms.NS}vm/{vms.NS}platform','linux')
575 status = {'platform': platform, 'power_state': power, 'readiness': 'starting',575 status = {'platform': platform, 'power_state': power, 'readiness': 'starting',
576 'cpu_acceleration': {'kvm': 'hardware', 'qemu': 'emulated'}.get(root.get('type')),
576 'capabilities': ['shot', 'input'] if power == 'running' else [],577 'capabilities': ['shot', 'input'] if power == 'running' else [],
577 'runtimes': [], 'coordinate_units': 'screenshot_pixels'}578 'runtimes': [], 'coordinate_units': 'screenshot_pixels'}
578 if power != 'running':579 if power != 'running':