mirror of
https://github.com/vercel-labs/agent-desktop.git
synced 2026-12-06 11:13:31 +08:00
* feat: run background actions headless on all three platforms - One core foreground gate: adapters report the headed requirement and the preflight refuses before visibility and stability checks. - macOS runs its actions headless with real effects, and fixes menu items, file name fields, row disclosure and the effect truth reported. - Linux moves onto the core delivery chain and foreground owner; its own chain engine is deleted. - Windows gets headless routes, each behind a gate. - A label borrowed as a name is no longer element identity when the element has a native id. - Command-level effect gates cover clipboard set and clear, focus-window, launch --activate, unscoped press, cursor and notifications. * fix: suggest only --headed when the interaction policy refuses an effect A refused clipboard write, focus-window or launch --activate told the agent to refresh the snapshot or target another element, which cannot grant the effect. The refusal now names headed mode and the effect it needs. * test: pass --headed to the harness focus-window calls that expect focus Headless focus-window is refused, so the macOS scenarios and the Windows precondition, acceptance and integrity legs aborted before their checks. * docs: say that clipboard writes, focus-window and an unscoped press need --headed The pages still said no --headed was needed, so their examples returned POLICY_DENIED. * test: give the gone-wait cases that end early a long budget The cases that return as soon as the window is gone had 250 ms, which a loaded CI runner missed. Only the timeout case keeps the short budget. * docs(linux): name the check a refused popup opener reports A ref-action refusal carries the actionability report, so a refused click on a popup opener reports details.checks[0].check foreground (supported_action for double-click and triple-click), not details.effect. * execute_by_ref no longer joins a per-action base policy, but its doc comments, the FFI docs, the generated header and CONCEPTS.md still said it did and that PressKey permits focus. Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> * fix: judge headless refusals from the resolved name and the real policy - Linux resolves a node's name through LabelledBy before the headless foreground gate, so a dialog opener labelled only by its relation is refused, and an unread label fails closed. - scroll_into_view and scroll_ref_into_view take the request's interaction policy, so a headed action on an offscreen non-WPF element scrolls through the headed route instead of being refused. - The platform docs, skills and Linux acceptance legs list focus-window and the clipboard writes as headed, and the menu and Wayland legs run under the policy each mode now produces. * fix: keep the Linux close-app legs and the Windows clipboard claim honest The Linux harness ends the apps it launched with `close-app --force`, and the undelivered-report leg runs headed, because a headless graceful close is now POLICY_DENIED. The Windows capability table's clipboard row reads as available again, so the claim parser stops counting the clipboard writes as unavailable. --------- Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
95 lines
3.5 KiB
Python
95 lines
3.5 KiB
Python
"""Verify Linux owner discovery from a foreign host with an empty PATH."""
|
|
import ctypes
|
|
import os
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def read_foreign_text():
|
|
import gi
|
|
gi.require_version("Gtk", "3.0")
|
|
gi.require_version("Gdk", "3.0")
|
|
from gi.repository import Gdk, Gtk
|
|
Gtk.init([])
|
|
return Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD).wait_for_text()
|
|
|
|
|
|
def verify(lib, empty_path, reader=read_foreign_text):
|
|
signatures = {
|
|
"ad_adapter_create": (ctypes.c_void_p, []),
|
|
"ad_adapter_destroy": (None, [ctypes.c_void_p]),
|
|
"ad_set_clipboard": (ctypes.c_int, [ctypes.c_void_p, ctypes.c_char_p]),
|
|
"ad_clear_clipboard": (ctypes.c_int, [ctypes.c_void_p]),
|
|
"ad_last_error_message": (ctypes.c_char_p, []),
|
|
}
|
|
for name, (result, args) in signatures.items():
|
|
function = getattr(lib, name)
|
|
function.restype, function.argtypes = result, args
|
|
original_path = os.environ.get("PATH")
|
|
payload = b"agent-desktop-library-adjacent-owner"
|
|
adapter = None
|
|
written = False
|
|
try:
|
|
os.environ["PATH"] = empty_path
|
|
adapter = lib.ad_adapter_create()
|
|
if not adapter:
|
|
raise AssertionError("helper probe could not create adapter")
|
|
rc = lib.ad_set_clipboard(adapter, payload)
|
|
lib.ad_adapter_destroy(adapter)
|
|
adapter = None
|
|
if rc != 0:
|
|
raise AssertionError(f"packaged owner set failed rc={rc}: {lib.ad_last_error_message()!r}")
|
|
written = True
|
|
if reader() != payload.decode():
|
|
raise AssertionError("foreign GTK reader did not receive the owner payload after adapter destruction")
|
|
adapter = lib.ad_adapter_create()
|
|
if not adapter:
|
|
raise AssertionError("helper probe could not create clear adapter")
|
|
rc = lib.ad_clear_clipboard(adapter)
|
|
if rc != 0:
|
|
raise AssertionError(f"packaged owner clear failed rc={rc}: {lib.ad_last_error_message()!r}")
|
|
if reader() is not None:
|
|
raise AssertionError("foreign GTK reader still sees a cleared selection")
|
|
written = False
|
|
finally:
|
|
if written:
|
|
if adapter is None:
|
|
adapter = lib.ad_adapter_create()
|
|
if adapter:
|
|
lib.ad_clear_clipboard(adapter)
|
|
if adapter:
|
|
lib.ad_adapter_destroy(adapter)
|
|
if original_path is None:
|
|
os.environ.pop("PATH", None)
|
|
else:
|
|
os.environ["PATH"] = original_path
|
|
|
|
|
|
def verify_cli(entry, empty_path, reader=read_foreign_text, run=subprocess.run):
|
|
payload = "agent-desktop-installed-owner"
|
|
env = dict(os.environ, PATH=empty_path)
|
|
def command(*args):
|
|
result = run([entry, "--headed", *args], env=env, capture_output=True,
|
|
text=True, timeout=15, check=False)
|
|
if result.returncode != 0 or json.loads(result.stdout).get("ok") is not True:
|
|
raise AssertionError(f"installed clipboard command failed: {args[0]}: {result.stdout} {result.stderr}")
|
|
written = False
|
|
try:
|
|
command("clipboard-set", payload)
|
|
written = True
|
|
if reader() != payload:
|
|
raise AssertionError("installed owner payload did not reach the foreign reader")
|
|
command("clipboard-clear")
|
|
if reader() is not None:
|
|
raise AssertionError("installed clear left a selection")
|
|
written = False
|
|
finally:
|
|
if written:
|
|
command("clipboard-clear")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
verify_cli(*sys.argv[1:])
|
|
print("installed owner set/read/clear passed with empty PATH")
|