diff --git a/modules/tool-computer-use/README.md b/modules/tool-computer-use/README.md
index 71ecb05..49c7673 100644
--- a/modules/tool-computer-use/README.md
+++ b/modules/tool-computer-use/README.md
@@ -30,3 +30,42 @@ transport remain local mechanisms. Fresh, bounded qualification is checked throu
`tests/fixtures/neutral-qualification.json` and its expected package bindings.
Retained historical evidence does not qualify neutral v1; expired or mismatched
current evidence fails the release consumer.
+
+### macOS Edge media test fixtures
+
+The local test launcher can call
+`ComputerTool.bind_edge_media_fixture(process, profile, url)` in an already
+active, disclosed control episode. Supply the launcher’s original Edge
+`Popen`, private test profile directory, and exact loopback fixture URL. Bind
+once while the dedicated browser has a single window. The returned run accepts
+`press("mute")`, `press("unmute")`, `press("play")`, `press("pause")`,
+`press("fullscreen")`, `press("exit_fullscreen")`, `press("volume_up")` and
+`press("volume_down")` when Edge exposes the corresponding native control.
+
+Each step waits up to 60 seconds for five seconds of quiet with the original
+window in front. Activity postpones the step. The launcher retains responsibility
+for the episode heartbeat and checking the resulting media state. Stop closes the
+episode. An uncertain native acknowledgement retires the fixture binding.
+For the visibility check, start with two fixture tabs in that same window and
+pass the companion tab’s title as `companion_tab_title`. The run supports
+`background_tab` and `restore_tab` only if Edge exposes both original tabs as
+distinct accessibility elements. Browser keyboard zoom is unsupported by this
+receiver. The media harness must report it as unrun.
+
+A remote media test launcher can serve the same fixture on the regular runner
+transport. In the target process that already owns the disposable Edge browser,
+call `remote_agent.main(["--read-only=false"], edge_media_launcher=fixture)`.
+The one-shot `fixture()` returns the launcher's original `process`, `profile`,
+`url`, an optional `companion_tab_title` and a `check_binding` callback that
+raises if the local test run has stopped. The caller keeps its existing Stop
+and heartbeat handling active. No process, URL or window selector travels with
+a media action.
+
+On the sponsoring computer, await `ComputerTool.remote_edge_media_step("mute")`
+in the active Mac episode. The caller checks the current write policy and the
+target verifies the same episode and original fixture at each attempt. It
+waits again only on a correlated reply that explicitly reports zero input.
+A lost reply ends the step. An ordinary SSH worker with no fixture launcher
+cannot adopt an existing browser window.
+
+For the installed SSH runner, set `edge_media_url` to the loopback URL served by the Mac test harness. The runner opens a separate Edge profile without requesting activation when the first admitted step finds the Mac idle. The target pins the window and document. Discovery and read-only connections start no browser.
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/__init__.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/__init__.py
index e8a8d7c..efc81af 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/__init__.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/__init__.py
@@ -2151,6 +2151,106 @@ def release():
# by actual calls. Hosts call the capability's heartbeat explicitly.
return result
+ def bind_edge_media_fixture(
+ self, process, profile, url, *, companion_tab_title=None
+ ):
+ """Bind native media controls for a local, already sponsored test launcher."""
+ from .edge_media import EdgeMediaRun, FixtureUnavailable, MacEdgeFixture
+
+ binding = self._binding
+ episode = self._episode
+ identity = self._episode_identity
+ if (
+ not self._episode_enabled
+ or episode is None
+ or identity is None
+ or binding.backend.name != "macos"
+ or binding.is_remote
+ or self._observed_control is not None
+ or binding.coexistence_guard is None
+ or binding.coexistence_guard.operator_presence_override is not None
+ ):
+ raise FixtureUnavailable("fixture requires a local guarded Mac episode")
+
+ def check_binding():
+ if (
+ binding is not self._binding
+ or not binding.announced
+ or binding.announce_refused is not None
+ or binding.read_only
+ or binding.gate_writes
+ or self._cleanup_started
+ or self._episode_fenced_status is not None
+ or self._episode is not episode
+ or self._episode_identity != identity
+ or self._mouse_pending
+ or (binding.ledger is not None and binding.ledger.held_tokens)
+ ):
+ raise FixtureUnavailable("fixture does not have an admitted write")
+ binding.coexistence_guard.check_sponsored_halt()
+ binding.coexistence_guard.pause.check()
+
+ check_binding()
+ fixture = MacEdgeFixture(process, profile, url, binding.backend)
+ if companion_tab_title is not None:
+ fixture.bind_companion_tab(companion_tab_title)
+ return EdgeMediaRun(episode, identity, check_binding, fixture)
+
+ async def remote_edge_media_step(self, control):
+ """Dispatch a bounded step to the fixture owned by the target's launcher."""
+ from .edge_media import MEDIA_CONTROLS
+
+ if not isinstance(control, str) or control not in MEDIA_CONTROLS:
+ raise BackendError("unsupported window-bound Edge control")
+ binding = self._binding
+ identity = self._episode_identity
+ if (
+ not binding.is_remote
+ or binding.backend.presence_platform != "macos"
+ or not self._episode_enabled
+ or identity is None
+ or self._episode is not binding.backend
+ or self._observed_control is not None
+ or binding.coexistence_guard is None
+ ):
+ raise BackendError("no sponsored remote Mac fixture")
+ binding.coexistence_guard.check_sponsored_halt()
+ binding.coexistence_guard.pause.check()
+ await asyncio.to_thread(self._ensure_announced)
+ binding = self._disclosed_binding(binding)
+ approval = await self._approve_write(
+ {"action": "edge_media_step", "control": control}, binding, True
+ )
+
+ def dispatch():
+ current = self._disclosed_binding(binding)
+ if (
+ not current.announced
+ or current.announce_refused is not None
+ or (current.gate_writes and approval is not self._write_approval)
+ or self._mouse_pending
+ or (current.ledger is not None and current.ledger.held_tokens)
+ or self._cleanup_started
+ or self._episode_fenced_status is not None
+ ):
+ raise BackendError("remote fixture interrupted")
+ with self._episode_admission(
+ "edge_media_step", binding, episode=binding.backend, identity=identity
+ ):
+ guard = binding.coexistence_guard
+ self._sync_remote_announcement_state(guard)
+ guard.check_sponsored_halt()
+ guard.pause.check()
+ return binding.backend.edge_media_step(identity, control)
+
+ deadline = time.monotonic() + 60
+ while time.monotonic() < deadline:
+ if await asyncio.to_thread(dispatch):
+ return
+ # The target acknowledged zero input. Check both ends again.
+ await asyncio.sleep(0.1)
+ raise TimeoutError("the Edge test window did not become ready")
+
def episode_status(self) -> dict:
if self._episode is None:
return {"state": "idle", "release_confirmed": False, "workers": 0}
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/coexistence_guard.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/coexistence_guard.py
index c3b1cc8..4d03e65 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/coexistence_guard.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/coexistence_guard.py
@@ -336,17 +336,21 @@ def release_target(self) -> None:
self.binding.release()
# -- start permission (D5, \u00a77.6) - governs BEGINNING to drive only ------
+ def check_sponsored_halt(self) -> None:
+ """Observe sticky halts during a read-only wait for fixture input."""
+ self._poll_durable_halt()
+ if self._halted:
+ assert self._halt_snapshot is not None
+ self.release_all("halted")
+ raise HaltedError(self._halt_snapshot)
+
def check_start_permission(self) -> None:
"""Call once, before the first write of a session. Raises
`HaltedError` if a human is already detected AND `drive_anyway` is
False. This is the ONLY method `drive_anyway` affects - it never
reaches `before_event()`'s halt check. The separate finite operator
policy (\u00a76.0a) applies to START and continuing live classifications."""
- self._poll_durable_halt()
- if self._halted:
- assert self._halt_snapshot is not None
- self.release_all("halted")
- raise HaltedError(self._halt_snapshot)
+ self.check_sponsored_halt()
overridden = self._presence_override_active()
if self.presence.state is PresenceState.HUMAN_ACTIVE and not (
self.drive_anyway or overridden
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/edge_launcher.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/edge_launcher.py
new file mode 100644
index 0000000..fc9aa16
--- /dev/null
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/edge_launcher.py
@@ -0,0 +1,178 @@
+"""Start a disposable Edge window without activating it on the user's desktop."""
+
+from __future__ import annotations
+
+import logging
+import math
+import os
+import shutil
+import tempfile
+import time
+from pathlib import Path
+from urllib.parse import urlsplit
+
+from .edge_media import DocumentNotReady, FixtureUnavailable, MacEdgeFixture
+
+
+def fixture_url(value: str) -> str:
+ parts = urlsplit(value)
+ if (
+ parts.scheme not in {"https", "http"}
+ or parts.hostname not in {"localhost", "127.0.0.1", "::1"}
+ or parts.username is not None
+ or parts.password is not None
+ or any(ord(char) < 32 for char in value)
+ ):
+ raise ValueError("the Edge fixture needs a loopback HTTP URL")
+ return value
+
+
+class EdgeApplication:
+ """Hold the application instance returned by Launch Services for this launch."""
+
+ def __init__(self, profile, url):
+ from AppKit import (
+ NSWorkspace,
+ NSWorkspaceLaunchConfigurationArguments,
+ NSWorkspaceLaunchNewInstance,
+ NSWorkspaceLaunchWithoutActivation,
+ )
+
+ workspace = NSWorkspace.sharedWorkspace()
+ executable = workspace.URLForApplicationWithBundleIdentifier_(
+ "com.microsoft.edgemac"
+ )
+ existing = {app.processIdentifier() for app in workspace.runningApplications()}
+ if executable is None:
+ raise FixtureUnavailable("Microsoft Edge is unavailable")
+ self.args = [
+ f"--user-data-dir={profile}",
+ "--no-first-run",
+ "--no-default-browser-check",
+ "--force-renderer-accessibility",
+ url,
+ "data:text/html,
Edge%20media%20companion",
+ ]
+ self.app, error = workspace.launchApplicationAtURL_options_configuration_error_(
+ executable,
+ NSWorkspaceLaunchNewInstance | NSWorkspaceLaunchWithoutActivation,
+ {NSWorkspaceLaunchConfigurationArguments: self.args},
+ None,
+ )
+ if error or self.app is None:
+ raise FixtureUnavailable(f"Edge launch failed: {error}")
+ self.pid = self.app.processIdentifier()
+ if (
+ self.pid in existing
+ or self.app.bundleIdentifier() != "com.microsoft.edgemac"
+ ):
+ raise FixtureUnavailable("Edge did not return a dedicated instance")
+
+ def poll(self):
+ return 0 if self.app.isTerminated() else None
+
+
+class EdgeLauncher:
+ """A single launch per remote worker. Startup and polling send no test input."""
+
+ def __init__(self, url, backend):
+ self.url = fixture_url(url)
+ self.backend = backend
+ self.profile = None
+ self.process = None
+ self.window = None
+ self.fixture = None
+ self.owned_browser = False
+
+ def __call__(self):
+ from . import macos_accessibility as ax
+
+ self.backend._ensure_not_locked()
+ idle = self.backend.presence_idle_ms()
+ if not math.isfinite(idle) or idle < 0:
+ raise FixtureUnavailable("Mac input activity is unavailable")
+ if idle < 5000:
+ return None
+ if self.process is None:
+ if self.profile is not None:
+ raise FixtureUnavailable("the previous Edge launch was interrupted")
+ self.profile = tempfile.mkdtemp(prefix="amplifier-edge-media-")
+ self.process = EdgeApplication(self.profile, self.url)
+ if self.process.poll() is not None:
+ raise FixtureUnavailable("the original Edge instance exited")
+ # Chromium holds a symlink ending in the browser PID in its profile.
+ # Require both the Launch Services instance and its private profile.
+ if not self.owns_profile():
+ if self.owned_browser:
+ raise FixtureUnavailable(
+ "the original Edge profile is no longer in use"
+ )
+ return None
+ self.owned_browser = True
+ root = ax.AXUIElementCreateApplication(self.process.pid)
+ error, windows = ax.AXUIElementCopyAttributeValue(root, "AXWindows", None)
+ if error or not windows:
+ if self.window is not None:
+ raise FixtureUnavailable("the original Edge window disappeared")
+ return None
+ if len(windows) != 1 or (self.window is not None and windows[0] != self.window):
+ raise FixtureUnavailable("the original Edge window changed")
+ self.window = windows[0]
+ # Wait for the local document in this exact window. A different URL or
+ # a partially loaded accessibility tree cannot receive a media action.
+ try:
+ if self.fixture is None:
+ self.fixture = MacEdgeFixture(
+ self.process,
+ self.profile,
+ self.url,
+ self.backend,
+ expected_window=self.window,
+ )
+ except DocumentNotReady:
+ return None
+ if not self.fixture.foreground():
+ return None
+ return {
+ "process": self.process,
+ "profile": self.profile,
+ "url": self.url,
+ "check_binding": self.check,
+ "window": self.fixture,
+ "companion_tab_title": "Edge media companion",
+ }
+
+ def owns_profile(self):
+ try:
+ owner = os.readlink(Path(self.profile) / "SingletonLock")
+ except OSError:
+ return False
+ return owner.rpartition("-")[2] == str(self.process.pid)
+
+ def check(self):
+ if (
+ self.process is None
+ or self.process.poll() is not None
+ or not self.owns_profile()
+ ):
+ raise FixtureUnavailable("the original Edge instance exited")
+
+ def close(self):
+ if self.process is not None and self.process.poll() is None:
+ if not self.owns_profile():
+ logging.getLogger(__name__).warning(
+ "Edge profile ownership unconfirmed; retaining %s", self.profile
+ )
+ return
+ self.process.app.terminate()
+ deadline = time.monotonic() + 3
+ while self.process.poll() is None and time.monotonic() < deadline:
+ time.sleep(0.05)
+ if self.process.poll() is None:
+ logging.getLogger(__name__).warning(
+ "Edge is still exiting; retaining %s", self.profile
+ )
+ return
+ if self.profile is not None:
+ shutil.rmtree(Path(self.profile))
+ self.profile = None
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/edge_media.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/edge_media.py
new file mode 100644
index 0000000..81397bc
--- /dev/null
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/edge_media.py
@@ -0,0 +1,301 @@
+"""Idle retry for a previously admitted, window-addressed Edge media fixture.
+
+The launcher retains the original browser process and accessibility objects.
+Nothing here launches or activates a browser, posts a key, or holds a button.
+"""
+
+from __future__ import annotations
+
+import math
+import threading
+import time
+from pathlib import Path
+from urllib.parse import urlsplit
+
+
+class FixtureUnavailable(RuntimeError):
+ """The check cannot proceed on this binding. Acquire no replacement."""
+
+
+class DocumentNotReady(FixtureUnavailable):
+ """The original window has not exposed the test document yet."""
+
+
+class UncertainDelivery(FixtureUnavailable):
+ """An action may have landed. Inspect the media before another attempt."""
+
+
+class EdgeMediaRun:
+ """One fixture, guard and sponsored episode generation for the whole run."""
+
+ def __init__(self, episode, identity, check_binding, fixture, *, quiet_seconds=5.0):
+ if not math.isfinite(quiet_seconds) or quiet_seconds <= 0:
+ raise ValueError("quiet_seconds must be positive and finite")
+ if not episode.status(identity)["admission_open"]:
+ raise FixtureUnavailable("a live guarded episode is required")
+ self._episode = episode
+ self._identity = dict(identity)
+ self._check_binding = check_binding
+ self._fixture = fixture
+ self._quiet = quiet_seconds
+ self._lock = threading.Lock()
+ self._retired = False
+ self._quiet_since = None
+
+ def press(self, control, *, timeout=60.0):
+ """Press once, waiting through confirmed non-delivery only."""
+ if not math.isfinite(timeout) or timeout <= 0:
+ raise ValueError("timeout must be positive and finite")
+ with self._lock, self._episode.admit(self._identity, controlling=True) as stop:
+ if self._retired:
+ raise FixtureUnavailable("this fixture binding is retired")
+ deadline = time.monotonic() + timeout
+ while time.monotonic() < deadline:
+ if self._attempt(control, stop, deadline):
+ return
+ stop.wait(min(0.05, max(0, deadline - time.monotonic())))
+ raise TimeoutError("Edge did not become ready within the wait")
+
+ def try_press(self, control):
+ """A false result proves that this request dispatched no input."""
+ with self._lock, self._episode.admit(self._identity, controlling=True) as stop:
+ return self._attempt(control, stop, math.inf)
+
+ def _attempt(self, control, stop, deadline):
+ if self._retired:
+ raise FixtureUnavailable("this fixture binding is retired")
+ try:
+ self._check(stop)
+ focused = self._fixture.foreground()
+ idle = self._fixture.idle_seconds()
+ if not math.isfinite(idle) or idle < 0:
+ raise FixtureUnavailable("Mac input activity is unavailable")
+ now = time.monotonic()
+ if not focused:
+ self._quiet_since = None
+ return False
+ if self._quiet_since is None:
+ # Age on the first sample proves prior input quiet, not focus.
+ self._quiet_since = now
+ if min(idle, now - self._quiet_since) < self._quiet:
+ return False
+ recipient = self._fixture.locate(control)
+ if not self._fixture.foreground():
+ self._quiet_since = None
+ return False
+ idle = self._fixture.idle_seconds()
+ if not math.isfinite(idle) or idle < 0:
+ raise FixtureUnavailable("Mac input activity is unavailable")
+ self._check(stop)
+ if idle < self._quiet or time.monotonic() >= deadline:
+ self._quiet_since = None
+ return False
+ self._fixture.press(recipient)
+ self._quiet_since = None
+ return True
+ except Exception:
+ self._retired = True
+ raise
+
+ def _check(self, stop):
+ self._check_binding()
+ if stop.is_set() or not self._episode.status(self._identity)["admission_open"]:
+ raise FixtureUnavailable("the fixture episode stopped")
+
+
+class MacEdgeFixture:
+ """Use an AX element from the original fixture document as the recipient."""
+
+ _controls = {
+ "fullscreen": (
+ "AXButton",
+ {"enter full screen", "enter fullscreen", "full screen"},
+ "AXPress",
+ ),
+ "exit_fullscreen": (
+ "AXButton",
+ {"exit full screen", "exit fullscreen"},
+ "AXPress",
+ ),
+ "mute": ("AXButton", {"mute"}, "AXPress"),
+ "unmute": ("AXButton", {"unmute"}, "AXPress"),
+ "play": ("AXButton", {"play"}, "AXPress"),
+ "pause": ("AXButton", {"pause"}, "AXPress"),
+ "volume_up": ("AXSlider", {"volume"}, "AXIncrement"),
+ "volume_down": ("AXSlider", {"volume"}, "AXDecrement"),
+ }
+
+ def __init__(self, process, profile, url, backend, *, expected_window=None):
+ from AppKit import NSRunningApplication
+
+ from . import macos_accessibility as ax
+
+ # Require the Popen for the dedicated Edge launched by the fixture.
+ # The launcher owns this temporary profile and the local URL.
+ args = process.args
+ if (
+ process.poll() is not None
+ or not isinstance(args, (list, tuple))
+ or not Path(profile).is_absolute()
+ or [a for a in args if a.startswith("--user-data-dir=")]
+ != [f"--user-data-dir={profile}"]
+ or urlsplit(url).scheme not in {"http", "https"}
+ or urlsplit(url).hostname not in {"localhost", "127.0.0.1", "::1"}
+ ):
+ raise FixtureUnavailable(
+ "expected a dedicated Edge process and local fixture"
+ )
+ self._app = NSRunningApplication.runningApplicationWithProcessIdentifier_(
+ process.pid
+ )
+ if self._app is None or self._app.bundleIdentifier() != "com.microsoft.edgemac":
+ raise FixtureUnavailable("the fixture process is not Microsoft Edge")
+ self._process = process
+ self._backend = backend
+ self._ax = ax
+ self._root = ax.AXUIElementCreateApplication(process.pid)
+ self._url = url
+ windows = self._attr(self._root, "AXWindows") or []
+ if len(windows) != 1:
+ raise FixtureUnavailable("expected one initial fixture window")
+ self._window = windows[0]
+ if expected_window is not None and self._window != expected_window:
+ raise FixtureUnavailable("the original Edge window changed")
+ documents = [
+ node
+ for node in self._walk(self._window)
+ if self._attr(node, "AXRole") == "AXWebArea"
+ and self._document_url(node) == url
+ ]
+ if len(documents) > 1:
+ raise FixtureUnavailable("ambiguous fixture documents")
+ if not documents:
+ raise DocumentNotReady("could not identify the original fixture document")
+ self._document = documents[0]
+
+ self._tabs = None
+
+ def bind_companion_tab(self, title):
+ """Pin both tabs in the launcher-owned window before the visibility test."""
+ if self._tabs is not None or not title or not self.foreground():
+ raise FixtureUnavailable("cannot enroll the companion tab")
+ groups = [
+ node
+ for node in self._walk(self._window)
+ if self._attr(node, "AXRole") == "AXTabGroup"
+ ]
+ if len(groups) != 1:
+ raise FixtureUnavailable("could not identify the fixture tab group")
+ group = groups[0]
+ members = self._attr(group, "AXTabs") or []
+ if len(members) != 2:
+ raise FixtureUnavailable("expected exactly the two fixture tabs")
+ selected = self._attr(group, "AXValue")
+ original = [
+ tab for tab in members if tab == selected or self._attr(tab, "AXValue") == 1
+ ]
+ companion = [tab for tab in members if self._attr(tab, "AXTitle") == title]
+ if len(original) != 1 or len(companion) != 1 or original[0] == companion[0]:
+ raise FixtureUnavailable("could not distinguish the fixture tabs")
+ self._tabs = (group, original[0], companion[0])
+
+ def _attr(self, node, key):
+ error, value = self._ax.AXUIElementCopyAttributeValue(node, key, None)
+ return value if error == 0 else None
+
+ def _document_url(self, node):
+ value = self._attr(node, "AXURL")
+ return (
+ str(value.absoluteString()) if hasattr(value, "absoluteString") else value
+ )
+
+ def _walk(self, root):
+ pending = [root]
+ for _ in range(2048):
+ if not pending:
+ return
+ node = pending.pop()
+ yield node
+ pending.extend(self._attr(node, "AXChildren") or [])
+ if pending:
+ raise FixtureUnavailable("fixture accessibility tree exceeds search limit")
+
+ def idle_seconds(self):
+ self._backend._ensure_not_locked()
+ return self._backend.presence_idle_ms() / 1000
+
+ def foreground(self):
+ if self._process.poll() is not None or self._window not in (
+ self._attr(self._root, "AXWindows") or []
+ ):
+ raise FixtureUnavailable("original fixture window or document is gone")
+ companion_selected = False
+ if self._tabs is not None:
+ group, original, companion = self._tabs
+ members = self._attr(group, "AXTabs") or []
+ if (
+ self._attr(group, "AXWindow") != self._window
+ or original not in members
+ or companion not in members
+ ):
+ raise FixtureUnavailable("one of the original fixture tabs is gone")
+ companion_selected = (
+ self._attr(group, "AXValue") == companion
+ or self._attr(companion, "AXValue") == 1
+ )
+ if not companion_selected and (
+ self._document_url(self._document) != self._url
+ or self._attr(self._document, "AXWindow") != self._window
+ ):
+ raise FixtureUnavailable("the original fixture document is gone")
+ return (
+ self._app.isActive()
+ and self._attr(self._root, "AXFocusedWindow") == self._window
+ )
+
+ def locate(self, control):
+ if control in {"background_tab", "restore_tab"}:
+ if self._tabs is None:
+ raise FixtureUnavailable(
+ "the launcher has not enrolled both fixture tabs"
+ )
+ _, original, companion = self._tabs
+ element = companion if control == "background_tab" else original
+ if self._attr(element, "AXWindow") != self._window:
+ raise FixtureUnavailable("fixture tab left its original window")
+ return self._recipient(element, "AXPress")
+ spec = self._controls.get(control)
+ if spec is None:
+ raise FixtureUnavailable("no window-addressed action for this control")
+ if (
+ self._document_url(self._document) != self._url
+ or self._attr(self._document, "AXWindow") != self._window
+ ):
+ raise FixtureUnavailable("the fixture document is unavailable")
+ role, names, action = spec
+ matches = []
+ for node in self._walk(self._document):
+ if self._attr(node, "AXRole") == role and any(
+ str(self._attr(node, key) or "").strip().casefold() in names
+ for key in ("AXTitle", "AXDescription")
+ ):
+ matches.append(node)
+ if len(matches) != 1 or self._attr(matches[0], "AXWindow") != self._window:
+ raise FixtureUnavailable("media control is absent or ambiguous")
+ return self._recipient(matches[0], action)
+
+ def _recipient(self, element, action):
+ error, actions = self._ax.AXUIElementCopyActionNames(element, None)
+ if error or action not in (actions or []):
+ raise FixtureUnavailable("Edge does not expose this accessibility action")
+ return element, action
+
+ def press(self, recipient):
+ # No focus restoration, coordinates, keyboard emulation or PID-based
+ # input. AXPress addresses this element even when OS focus changes.
+ element, action = recipient
+ if self._ax.AXUIElementPerformAction(element, action) != 0:
+ raise UncertainDelivery("Edge did not acknowledge the media control")
+
+
+MEDIA_CONTROLS = frozenset((*MacEdgeFixture._controls, "background_tab", "restore_tab"))
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/halt_state.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/halt_state.py
index 1bf982e..b6191fd 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/halt_state.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/halt_state.py
@@ -50,6 +50,7 @@
import os
import re
import sys
+import tempfile
import time
from collections.abc import Callable
from dataclasses import dataclass
@@ -110,7 +111,6 @@ def resolve_resume_command() -> str:
DEFAULT_STATE_DIR = Path.home() / ".amplifier" / "computer-use" / "halt"
_PRIVATE_DIR_MODE = 0o700
-_PRIVATE_FILE_MODE = 0o600
#: Distinguishes a seeded-from-disk snapshot from a live sample
#: (`presence.py`'s own `basis` values are `"idle_reconciliation"` and
@@ -248,10 +248,24 @@ def record_halt(
),
)
path = _path_for(platform, state_dir)
- tmp_path = path.with_suffix(f"{path.suffix}.tmp-{os.getpid()}")
- tmp_path.write_text(json.dumps(record.to_dict(), indent=2), encoding="utf-8")
- os.chmod(tmp_path, _PRIVATE_FILE_MODE)
- os.replace(tmp_path, path) # atomic on the same filesystem
+ # A concurrent activity sample may replace the last observation. Keep
+ # an explicit operator cancellation independently until explicit resume.
+ stop_path = path.with_suffix(".stop")
+ writes = [(path, record)]
+ if snapshot.basis == "overlay_cancel":
+ writes.insert(0, (stop_path, record))
+ elif not stop_path.exists():
+ previous = load_halt(platform, state_dir=state_dir)
+ if previous and previous.reason == "cancelled via overlay Cancel button":
+ writes.insert(0, (stop_path, previous))
+ for destination, observation in writes:
+ fd, name = tempfile.mkstemp(dir=state_dir)
+ try:
+ with os.fdopen(fd, "w", encoding="utf-8") as tmp:
+ json.dump(observation.to_dict(), tmp, indent=2)
+ os.replace(name, destination)
+ finally:
+ Path(name).unlink(missing_ok=True)
logger.warning(
"coexistence: durable halt record written for backend %r (%s) - a "
"safety halt is retained; every future session for this backend "
@@ -276,6 +290,9 @@ def load_halt(
the human still has to look and explicitly clear it either way.
"""
path = _path_for(platform, state_dir)
+ stop_path = path.with_suffix(".stop")
+ if stop_path.exists():
+ path = stop_path
if not path.exists():
return None
try:
@@ -312,9 +329,15 @@ def clear_halt(platform: str, *, state_dir: Path = DEFAULT_STATE_DIR) -> bool:
Returns whether a record existed and was removed.
"""
path = _path_for(platform, state_dir)
- if not path.exists():
+ existed = False
+ for target in (path, path.with_suffix(".stop")):
+ try:
+ target.unlink()
+ existed = True
+ except FileNotFoundError:
+ pass
+ if not existed:
return False
- path.unlink()
logger.warning(
"coexistence: durable halt record for backend %r explicitly cleared "
"- future sessions may drive again",
@@ -329,7 +352,9 @@ def list_halted_platforms(*, state_dir: Path = DEFAULT_STATE_DIR) -> list[str]:
state to a human."""
if not state_dir.exists():
return []
- return sorted(p.stem for p in state_dir.glob("*.json"))
+ return sorted(
+ {p.stem for p in state_dir.iterdir() if p.suffix in {".json", ".stop"}}
+ )
def make_durable_halt_poll(
@@ -346,34 +371,11 @@ def make_durable_halt_poll(
after that point succeeded, exactly the defect this closes (see the
module docstring above for the real evaluation evidence).
- The fix is to poll on every `before_event()` call, not just at
- construction - but `load_halt()` does a full file read + JSON parse,
- which is not something to pay on every elementary injected event
- (`docs/designs/coexistence.md` \u00a75's per-sample cost budget: this
- mechanism already does an in-process idle read on that same hot path,
- and is sized in microseconds, not milliseconds). This closure keeps the
- common case - no halt has ever been recorded for this platform - down
- to exactly one `Path.stat()` syscall: `FileNotFoundError` short-circuits
- before any read or parse happens. The heavier `load_halt()` path runs at
- most ONCE per guard's lifetime: the moment it does run, the caller is
- expected to call `CoexistenceGuard.seed_halted()` (additive-only, never
- a clear), which flips `_halted` to `True` permanently - `before_event()`
- stops calling this poll at all once halted (see its own docstring), so
- there is nothing left to poll for the rest of that guard's life either
- way.
-
- Returns `None` when there is nothing to report (no record, or the
- caller should keep going) - never raises for the common "no file" case,
- since that is not a failure, it is the ordinary state of a machine
- nobody has been detected on.
+ Poll the retained Stop and the last observed halt so a newly mounted
+ guard sees cancellation even if an older process replaced its observation.
"""
def _poll() -> PresenceSnapshot | None:
- path = _path_for(platform, state_dir)
- try:
- path.stat()
- except FileNotFoundError:
- return None
persisted = load_halt(platform, state_dir=state_dir)
return persisted.to_snapshot() if persisted is not None else None
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/macos_accessibility.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/macos_accessibility.py
new file mode 100644
index 0000000..b94809e
--- /dev/null
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/macos_accessibility.py
@@ -0,0 +1,33 @@
+"""The five Accessibility functions used by the Edge fixture, from macOS itself."""
+
+import objc
+from Foundation import NSBundle
+
+_bundle = NSBundle.bundleWithPath_(
+ "/System/Library/Frameworks/ApplicationServices.framework"
+)
+_element = b"^{__AXUIElement=}"
+_owned = {"retval": {"already_cfretained": True}}
+_out = {"arguments": {2: {"already_cfretained": True}}}
+objc.loadBundleFunctions(
+ _bundle, globals(), [("AXUIElementGetTypeID", b"Q", "")], skip_undefined=False
+)
+objc.registerCFSignature(
+ "AXUIElementRef", _element, globals()["AXUIElementGetTypeID"]()
+)
+objc.loadBundleFunctions(
+ _bundle,
+ globals(),
+ [
+ ("AXUIElementCreateApplication", _element + b"i", "", _owned),
+ ("AXUIElementCopyAttributeValue", b"i" + _element + b"@o^@", "", _out),
+ (
+ "AXUIElementCopyActionNames",
+ b"i" + _element + b"o^@",
+ "",
+ {"arguments": {1: {"already_cfretained": True}}},
+ ),
+ ("AXUIElementPerformAction", b"i" + _element + b"@", ""),
+ ],
+ skip_undefined=False,
+)
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/registry.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/registry.py
index 4a69990..db39426 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/registry.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/registry.py
@@ -203,6 +203,12 @@ def _build_ssh_transport(
ssh_path = str(config.get("ssh_path", "ssh"))
+ edge_url = config.get("edge_media_url")
+ if edge_url is not None:
+ from .edge_launcher import fixture_url
+
+ edge_url = fixture_url(edge_url)
+
def _factory() -> SshTransport:
return SshTransport(
host,
@@ -212,13 +218,16 @@ def _factory() -> SshTransport:
read_only=bool(config.get("read_only", True)),
with_pillow=bool(config.get("with_pillow", True)),
port=port,
+ edge_media_url=edge_url,
)
# `port` is part of the sharing key (bug-hunt defect B): two configured
# targets that differ ONLY by port (e.g. two agents on the same host,
# one on 22 and one on 2222) are genuinely different destinations and
# must never be folded into the same shared transport/agent process.
- return acquire_shared_transport((ssh_path, host, port), _factory)
+ return acquire_shared_transport(
+ (ssh_path, host, port), _factory, edge_media_url=edge_url
+ )
def select_backend(
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_agent.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_agent.py
index 934d298..8009fe9 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_agent.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_agent.py
@@ -180,6 +180,7 @@ def __init__(
read_only: bool = True,
require_episode: bool = False,
indicator_factory: Callable | None = None,
+ edge_media_launcher: Callable | None = None,
) -> None:
self.backend = backend
self.read_only = read_only
@@ -215,6 +216,12 @@ def __init__(
self._episode_control_lock = threading.RLock()
self._revoked_generations: set[tuple[str, str]] = set()
self._episode_highwater = 0
+ # Set only by the target-side fixture launcher which owns the Edge
+ # process. Wire requests cannot choose a PID, window, URL, or profile.
+ self._edge_fixture = None
+ self._edge_launch_generation = None
+ self._edge_media_launcher = edge_media_launcher
+ self._edge_media_only = edge_media_launcher is not None
def _make_indicator(self):
if self._indicator_factory:
@@ -276,6 +283,7 @@ def _op_episode_begin(self, args):
)
if current is not None:
self._episode = None
+ self._edge_fixture = None
if self._episode is None:
self._episode = Episode(
self._episode_target,
@@ -517,6 +525,8 @@ def handshake(self) -> dict[str, Any]:
except BackendError as exc:
logger.warning("handshake: list_monitors unavailable: %s", exc)
capabilities = ["capture_scaled", "held_ledger", "audit", "read_only"]
+ if self._edge_media_only:
+ capabilities.append("edge_media_fixture")
return {
"protocol": PROTOCOL_VERSION,
"agent_sha256": _content_hash(),
@@ -632,6 +642,7 @@ def _dispatch(self, req: Request) -> Response:
"type_text",
"focus_window",
"set_clipboard",
+ "edge_media_step",
}
if getattr(self, "_require_episode", False) and protected:
try:
@@ -677,6 +688,17 @@ def _dispatch_admitted(self, req: Request) -> Response:
error_message=f"op {req.op!r} blocked: agent enforces read_only "
"(defence in depth - see docs/designs/remote-transport.md \u00a710.4)",
)
+ if (
+ self._edge_media_only
+ and op_class == "write"
+ and req.op not in {"edge_media_step", "release_all"}
+ ):
+ return Response(
+ id=req.id,
+ ok=False,
+ error_type="BackendError",
+ error_message="this runner only accepts Edge fixture controls",
+ )
handler = self._HANDLERS.get(req.op)
if handler is None:
return Response(
@@ -734,6 +756,101 @@ def _dispatch_admitted(self, req: Request) -> Response:
# -- op handlers --------------------------------------------------------
+ def bind_edge_media_fixture(
+ self,
+ identity,
+ process,
+ profile,
+ url,
+ check_binding,
+ *,
+ companion_tab_title=None,
+ window=None,
+ ):
+ """Enroll the launcher's own Edge in one already sponsored Mac episode."""
+ from .edge_media import EdgeMediaRun, FixtureUnavailable, MacEdgeFixture
+
+ with self._episode_control_lock:
+ episode = self._episode
+ if (
+ self.backend.name != "macos"
+ or self.read_only
+ or episode is None
+ or not self._require_episode
+ or self._edge_fixture is not None
+ ):
+ raise FixtureUnavailable("no available Mac fixture episode")
+ # Claim the slot before native lookup. A failed bind cannot enroll
+ # a lookalike window later under this generation.
+ generation = dict(identity)
+ if not episode.status(generation)["admission_open"]:
+ raise FixtureUnavailable("the fixture episode is closed")
+ self._edge_media_only = True
+ self._edge_fixture = (generation, None)
+
+ def eligible():
+ if (
+ self._disconnected.is_set()
+ or self._announce_cancelled
+ or self._announce_paused
+ or self._episode is not episode
+ or self.read_only
+ or self._mouse_pending
+ or self._ledger.held_tokens
+ ):
+ raise FixtureUnavailable("fixture input interrupted")
+ check_binding()
+
+ with episode.admit(generation):
+ eligible()
+ if window is None:
+ window = MacEdgeFixture(process, profile, url, self.backend)
+ if companion_tab_title is not None:
+ window.bind_companion_tab(companion_tab_title)
+ run = EdgeMediaRun(episode, generation, eligible, window)
+ with self._episode_control_lock:
+ eligible()
+ self._edge_fixture = (generation, run)
+
+ def _op_edge_media_step(self, args):
+ from .edge_media import MEDIA_CONTROLS
+
+ if (
+ set(args) != {"_episode", "control"}
+ or not isinstance(args["control"], str)
+ or args["control"] not in MEDIA_CONTROLS
+ ):
+ raise BackendError("expected a named Edge fixture control")
+ if not self._require_episode or self._episode is None or self.read_only:
+ raise EpisodeError("Edge fixture needs an admitted write episode")
+ if self._edge_fixture is None and self._edge_media_launcher is not None:
+ # This is a target-side callback supplied by the test launcher, not
+ # request data. Consume it once, including on failure or reconnect.
+ generation = args["_episode"]
+ if self._edge_launch_generation is None:
+ self._edge_launch_generation = dict(generation)
+ if (
+ self._edge_launch_generation != generation
+ or not self._episode.status(generation)["admission_open"]
+ or self._announce_cancelled
+ or self._announce_paused
+ or self._disconnected.is_set()
+ or self._mouse_pending
+ or self._ledger.held_tokens
+ ):
+ raise EpisodeError("fixture launch interrupted")
+ launcher, self._edge_media_launcher = self._edge_media_launcher, None
+ registration = launcher()
+ if registration is None:
+ # No input was sent. Only the original launcher and episode may poll.
+ self._edge_media_launcher = launcher
+ return {"dispatched": False}
+ self.bind_edge_media_fixture(args["_episode"], **registration)
+ entry = self._edge_fixture
+ if entry is None or entry[0] != args["_episode"] or entry[1] is None:
+ raise EpisodeError("no matching target-owned Edge fixture")
+ return {"dispatched": entry[1].try_press(args["control"])}
+
def _op_probe(self, _args: dict[str, Any]) -> dict[str, Any]:
p = self.backend.probe()
return {"available": p.available, "reason": p.reason}
@@ -1046,6 +1163,7 @@ def _op_bye(self, _args: dict[str, Any]) -> dict[str, Any]:
"release_all": _op_release_all,
"episode_begin": _op_episode_begin,
"episode_status": _op_episode_status,
+ "edge_media_step": _op_edge_media_step,
"episode_end": _op_episode_end,
"bye": _op_bye,
}
@@ -1135,7 +1253,10 @@ def _release() -> None:
}
-def main(argv: list[str] | None = None) -> int:
+def main(
+ argv: list[str] | None = None, *, edge_media_launcher: Callable | None = None
+) -> int:
+ """Serve the normal transport, optionally embedded in an owned Edge fixture."""
parser = argparse.ArgumentParser(description="Amplifier remote computer-use agent")
parser.add_argument(
"--deadman-seconds", type=float, default=DEFAULT_DEADMAN_SECONDS
@@ -1147,6 +1268,7 @@ def main(argv: list[str] | None = None) -> int:
help="'true' (default, safe) or 'false' - agent-side enforcement, "
"defence in depth alongside the controller's own gate (\u00a710.4)",
)
+ parser.add_argument("--edge-media-url", help="dedicated loopback media test page")
args = parser.parse_args(argv)
# Best-effort hygiene for whatever a hard-killed predecessor left behind -
@@ -1187,11 +1309,21 @@ def main(argv: list[str] | None = None) -> int:
logger.error("no backend available: %s", exc)
return 1
+ managed = None
+ if args.edge_media_url is not None:
+ from .edge_launcher import EdgeLauncher
+
+ if backend.name != "macos" or edge_media_launcher is not None:
+ parser.error("Edge media mode requires the Mac target runner")
+ managed = EdgeLauncher(args.edge_media_url, backend)
+ edge_media_launcher = managed
+
agent = RemoteAgent(
backend,
deadman_seconds=args.deadman_seconds,
read_only=str(args.read_only).lower() != "false",
require_episode=backend.name == "macos",
+ edge_media_launcher=edge_media_launcher,
)
agent.install_signal_handlers()
try:
@@ -1201,6 +1333,9 @@ def main(argv: list[str] | None = None) -> int:
logger.error("agent loop crashed:\n%s", traceback.format_exc())
agent._ledger.stop()
return 1
+ finally:
+ if managed is not None:
+ managed.close()
return 0
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_backend.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_backend.py
index 00304d9..18b4a64 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_backend.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/remote_backend.py
@@ -171,6 +171,18 @@ def begin_episode(self, identity):
self._episode_status_cache = result
return result
+ def edge_media_step(self, identity, control):
+ """One action on the remote launcher's fixture. Never replay a lost reply."""
+ self.check_episode(identity)
+ result = self._call("edge_media_step", _episode=dict(identity), control=control)
+ if (
+ not isinstance(result, dict)
+ or set(result) != {"dispatched"}
+ or type(result["dispatched"]) is not bool
+ ):
+ raise BackendError("Edge fixture dispatch was not acknowledged")
+ return result["dispatched"]
+
def check_episode(self, identity):
with self._episode_state_lock:
if self._episode_fenced or identity != self._episode_identity:
@@ -346,8 +358,9 @@ def _call(self, op: str, **args: Any) -> Any:
"ping",
"announce_raise",
}:
- self.check_episode(self._episode_identity)
- args["_episode"] = self._episode_identity
+ identity = args.get("_episode", self._episode_identity)
+ self.check_episode(identity)
+ args["_episode"] = identity
exchange = (
CURRENT_TARGET_CLOCK.get()
if self.presence_platform == "windows-wsl2" and op_class == "write"
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/shared_transport.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/shared_transport.py
index b74dd81..15e15b9 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/shared_transport.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/shared_transport.py
@@ -97,6 +97,7 @@ def __init__(
) -> None:
self.key = key
self.transport = transport
+ self.edge_media_url = None
self.refcount = 0
self.handshake: dict[str, Any] | None = None
self.broken = False
@@ -214,7 +215,10 @@ def close(self) -> None:
def acquire_shared_transport(
- key: tuple[str, str, int | None], factory: Callable[[], SshTransport]
+ key: tuple[str, str, int | None],
+ factory: Callable[[], SshTransport],
+ *,
+ edge_media_url: str | None = None,
) -> SharedTransportHandle:
"""Return a handle onto the shared `SshTransport` for `key`, creating one
via `factory()` if none exists yet (or the previous one was retired).
@@ -229,7 +233,12 @@ def acquire_shared_transport(
entry = _registry.get(key)
if entry is None or entry.broken:
entry = _SharedEntry(key, factory())
+ entry.edge_media_url = edge_media_url
_registry[key] = entry
+ elif entry.edge_media_url != edge_media_url:
+ raise SshConnectError(
+ "this connection already belongs to a different desktop or Edge fixture session"
+ )
entry.refcount += 1
return SharedTransportHandle(entry)
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/ssh_transport.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/ssh_transport.py
index 99084d1..407169c 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/ssh_transport.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/ssh_transport.py
@@ -54,6 +54,9 @@
"wire.py",
"ledger.py",
"episode.py",
+ "edge_media.py",
+ "edge_launcher.py",
+ "macos_accessibility.py",
"agent_scratch_lease.py",
"remote_agent.py",
# The session-start disclosure channel (docs/designs/coexistence.md
@@ -265,7 +268,9 @@ def _resolve_uv_command(
_SIZE_LINE_RE = re.compile(rb"^\d+$")
-def _bootstrap_stub(deadman_seconds: float, read_only: bool) -> str:
+def _bootstrap_stub(
+ deadman_seconds: float, read_only: bool, edge_media_url: str | None = None
+) -> str:
"""The pure-Python stub run as the SSH remote command's payload consumer.
Reads a `SIZE\\n` line, then exactly that many raw bytes
@@ -299,6 +304,15 @@ def _bootstrap_stub(deadman_seconds: float, read_only: bool) -> str:
atexit cleanup, not a replacement for it.
"""
read_only_arg = "true" if read_only else "false"
+ argv = [
+ "remote_agent",
+ f"--deadman-seconds={deadman_seconds}",
+ f"--read-only={read_only_arg}",
+ ]
+ if edge_media_url is not None:
+ from .edge_launcher import fixture_url
+
+ argv.extend(["--edge-media-url", fixture_url(edge_media_url)])
# Restrict even older Python 3.11 patch releases without tar filters to
# our fixed, regular-file manifest. Never fall back to arbitrary extraction.
allowed_names = tuple(f"{_PACKAGE_NAME}/{name}" for name in PAYLOAD_MODULES)
@@ -325,8 +339,7 @@ def _bootstrap_stub(deadman_seconds: float, read_only: bool) -> str:
"from amplifier_cu_agent.agent_scratch_lease import acquire_agent_lease;"
"lease_fd=acquire_agent_lease(w);"
"os.environ['AMPLIFIER_CU_AGENT_SHA256']=d;"
- f"sys.argv=['remote_agent','--deadman-seconds={deadman_seconds}',"
- f"'--read-only={read_only_arg}'];"
+ f"sys.argv={argv!r};"
"runpy.run_module('amplifier_cu_agent.remote_agent',run_name='__main__')"
)
@@ -351,7 +364,9 @@ def __init__(
read_only: bool = True,
with_pillow: bool = True,
port: int | None = None,
+ edge_media_url: str | None = None,
) -> None:
+ self.edge_media_url = edge_media_url
self.user_host = user_host
self._package_dir = package_dir
self._ssh_path = ssh_path
@@ -378,7 +393,9 @@ def connect(
self._sent_sha256 = hashlib.sha256(payload).hexdigest()
uv_cmd = _resolve_uv_command(self.user_host, self._ssh_path, port=self.port)
- stub = _bootstrap_stub(self._deadman_seconds, self._read_only)
+ stub = _bootstrap_stub(
+ self._deadman_seconds, self._read_only, self.edge_media_url
+ )
if self._with_pillow:
# Mirrors this bundle's own pyproject.toml dependency markers
# exactly (pyobjc-framework-Quartz only on darwin, python-xlib
diff --git a/modules/tool-computer-use/amplifier_module_tool_computer_use/wire.py b/modules/tool-computer-use/amplifier_module_tool_computer_use/wire.py
index 0515cb8..cbf4fa5 100644
--- a/modules/tool-computer-use/amplifier_module_tool_computer_use/wire.py
+++ b/modules/tool-computer-use/amplifier_module_tool_computer_use/wire.py
@@ -67,6 +67,7 @@
"type_text",
"focus_window",
"set_clipboard",
+ "edge_media_step",
}
)
CONTROL_OPS = frozenset(
diff --git a/modules/tool-computer-use/uv.lock b/modules/tool-computer-use/uv.lock
index d3f55eb..397ec3d 100644
--- a/modules/tool-computer-use/uv.lock
+++ b/modules/tool-computer-use/uv.lock
@@ -8,16 +8,27 @@ version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "pillow" },
+ { name = "pyobjc-framework-cocoa", marker = "sys_platform == 'darwin'" },
{ name = "pyobjc-framework-quartz", marker = "sys_platform == 'darwin'" },
{ name = "python-xlib", marker = "sys_platform == 'linux'" },
+ { name = "pyyaml" },
+]
+
+[package.optional-dependencies]
+edge-media = [
+ { name = "pyobjc-framework-applicationservices", marker = "sys_platform == 'darwin'" },
]
[package.metadata]
requires-dist = [
{ name = "pillow", specifier = ">=10.0" },
+ { name = "pyobjc-framework-applicationservices", marker = "sys_platform == 'darwin' and extra == 'edge-media'", specifier = ">=10.0" },
+ { name = "pyobjc-framework-cocoa", marker = "sys_platform == 'darwin'", specifier = ">=10.0" },
{ name = "pyobjc-framework-quartz", marker = "sys_platform == 'darwin'", specifier = ">=10.0" },
{ name = "python-xlib", marker = "sys_platform == 'linux'", specifier = ">=0.33" },
+ { name = "pyyaml", specifier = ">=6.0" },
]
+provides-extras = ["edge-media"]
[[package]]
name = "pillow"
@@ -120,6 +131,28 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b5/a8/cb9fcc150f97d0bf22a2028f88b24cc35949beb1bcc7b8bc5c17d4401677/pyobjc_core-12.2.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:1188613805336270279570467e4455b74cb6c0f60913ac74c917ee1c37cfaecb", size = 6733064, upload-time = "2026-06-19T16:05:14.313Z" },
]
+[[package]]
+name = "pyobjc-framework-applicationservices"
+version = "12.2.1"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "pyobjc-core" },
+ { name = "pyobjc-framework-cocoa" },
+ { name = "pyobjc-framework-coretext" },
+ { name = "pyobjc-framework-quartz" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/5e/4d/0ebdd8144aba94b8fe9828ccee5616a4bf53d1f8bc51cff55f3cce86d695/pyobjc_framework_applicationservices-12.2.1.tar.gz", hash = "sha256:048ea663c9ac75c44a15dc7d5b8d78cbb4c97bf1c76e83835e8d5498e184001f", size = 109342, upload-time = "2026-06-19T16:19:46.149Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/cd/8a/5a9310929bb303c31c04a1c6dc7b3213c9bd964a692d024a00c0643af2c8/pyobjc_framework_applicationservices-12.2.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:dabec481217b0d0c1ea835e9fef6b0681381b14b3f16a30d4a9d801ee3852dd2", size = 32715, upload-time = "2026-06-19T16:05:38.448Z" },
+ { url = "https://files.pythonhosted.org/packages/bf/89/39a7462006afbc06c69029fe4181b7359a9da25ae7864ef75f9d3ffb9272/pyobjc_framework_applicationservices-12.2.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:f519ced13888d03410cd7da1f08fc56ee2944099e607216cef7ca26ecfdef61b", size = 32764, upload-time = "2026-06-19T16:05:39.26Z" },
+ { url = "https://files.pythonhosted.org/packages/b2/6e/8e928d5e3025529ed92c6eb5fd88a5e6e485cc6df945c541f29b4af7f2c6/pyobjc_framework_applicationservices-12.2.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:8749290f796e6cca341d443769b79329dde5d157bcc4413c1f7fdb68ea4a8e48", size = 32782, upload-time = "2026-06-19T16:05:40.284Z" },
+ { url = "https://files.pythonhosted.org/packages/50/a5/c7b5a31777fe2ce7c07b9c16941ff4fbf0a150bf755164d96228d32ccb4f/pyobjc_framework_applicationservices-12.2.1-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:9ee11677fbd6a0987234814c7dde88ffd11242e8c1f76952e6654ea07f2370ac", size = 33048, upload-time = "2026-06-19T16:05:41.308Z" },
+ { url = "https://files.pythonhosted.org/packages/8b/47/cd2bd76b862686c0aa78568ed9dff175764353c209a3096c72d6e2a9b151/pyobjc_framework_applicationservices-12.2.1-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:a1c0ee536cb8bd7f5a811165ec323a9207b1e8dad9534fe2081f767fb90b0411", size = 32921, upload-time = "2026-06-19T16:05:42.23Z" },
+ { url = "https://files.pythonhosted.org/packages/05/db/6989a96f8501aa3a16513d08b2c4c78ca906a10b6a4e5a33c4c59fd1bea9/pyobjc_framework_applicationservices-12.2.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:0d55dd5be19e4a1363662bc8b48894d45714d07f0ee3958665fc9ea7df0f61b7", size = 33163, upload-time = "2026-06-19T16:05:43.256Z" },
+ { url = "https://files.pythonhosted.org/packages/5c/41/66f2bcd12454a85f0479393f5825021332ee84b49583c7954cd20310cab5/pyobjc_framework_applicationservices-12.2.1-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:e91c84238b2f68f608473854bcabb8770f15ad837e7561d217f24a1e482e42be", size = 32915, upload-time = "2026-06-19T16:05:44.151Z" },
+ { url = "https://files.pythonhosted.org/packages/81/cf/04b6b1eb181fa3071e9743bab7551f5d2ec3f650ac74bab790f21717ba51/pyobjc_framework_applicationservices-12.2.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:09bfa27765d4c74155323fd8185b7aba6d639ce06c0a9f00ee2d9e7dce3d7800", size = 33158, upload-time = "2026-06-19T16:05:45.017Z" },
+]
+
[[package]]
name = "pyobjc-framework-cocoa"
version = "12.2.1"
@@ -139,6 +172,27 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b6/f3/eedf743a303ea742b8e082afe3613fb4d6618bc1a48cf2568b004ce906f7/pyobjc_framework_cocoa-12.2.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:c685ccd8e266a07cf912a2c5a13b1f2eff2a868a1aff163b4801b4687bd425e1", size = 392691, upload-time = "2026-06-19T16:07:47.477Z" },
]
+[[package]]
+name = "pyobjc-framework-coretext"
+version = "12.2.1"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "pyobjc-core" },
+ { name = "pyobjc-framework-cocoa" },
+ { name = "pyobjc-framework-quartz" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/5a/9c/4c7f452059dc1d3845b8e627b9113c247a997b9b07518e848c2ab7ff3149/pyobjc_framework_coretext-12.2.1.tar.gz", hash = "sha256:af740e784d7c592c34025ec7165f4f6c1a69b5a2d9075f06e41e4f77c212aed2", size = 97349, upload-time = "2026-06-19T16:20:22.508Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/13/53/c262cf5052c648c48b3f7562fcce188fb78ff94e44cf1c48fdfc62fdfcce/pyobjc_framework_coretext-12.2.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:02a448675d28005fdb88fb3c585572b02871e9e5d4d08f88334ec937ea5de6e7", size = 30022, upload-time = "2026-06-19T16:09:50.37Z" },
+ { url = "https://files.pythonhosted.org/packages/c5/11/c1298c2ec3b0cd19a457a1fd0da47898f894a13df5516f80dc04d1a7a4d9/pyobjc_framework_coretext-12.2.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:ac2ead13dfa4379a1566129d0e8a8ea778a2bcac9ac360a583360fd4f1ba39c6", size = 30123, upload-time = "2026-06-19T16:09:51.183Z" },
+ { url = "https://files.pythonhosted.org/packages/05/8c/154e8f34923b24aade64a20eca2b759f8f67e109654308103080751f246f/pyobjc_framework_coretext-12.2.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:5c5a3c6e2d905a17efb15572dad97ce582feeab5c3b92537015445e0e0bb46de", size = 30116, upload-time = "2026-06-19T16:09:52.219Z" },
+ { url = "https://files.pythonhosted.org/packages/01/61/f53458c8f7fe74008e342946eca1fa82b777b284d4e13d8bd2e3e5724cab/pyobjc_framework_coretext-12.2.1-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:5c979058c77df8cd3dac5fd7db4c484f9886fbe09e2687bfaf269a856f631f78", size = 30659, upload-time = "2026-06-19T16:09:53.034Z" },
+ { url = "https://files.pythonhosted.org/packages/c6/d8/d1178bb1ba3bb7a0d7a55db460aa89f2a8b232ed7eaf76cb402923cacf2d/pyobjc_framework_coretext-12.2.1-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:d0b3b0467a23dbc2a39d0839e7100cc98b429fb7d52a471bd65477f46bb4c9e5", size = 30100, upload-time = "2026-06-19T16:09:53.902Z" },
+ { url = "https://files.pythonhosted.org/packages/12/c3/780d739909e6d8ddd9e8786fd19e8ea10ccfcc7275df987e349af0fb33b1/pyobjc_framework_coretext-12.2.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:3d4a92fa657180cd0e900b98535da4f0f4d8c76a7077730a507e50d52d2853e3", size = 30642, upload-time = "2026-06-19T16:09:54.736Z" },
+ { url = "https://files.pythonhosted.org/packages/0f/e9/867197c6cf2396b33e95d6175d7fdc6f789314859fb107560ae9b19c7b14/pyobjc_framework_coretext-12.2.1-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:7a17034fd0a08cf58323b7234a385ce0ec355509d414df69e3f8f88df26de1fc", size = 30098, upload-time = "2026-06-19T16:09:55.679Z" },
+ { url = "https://files.pythonhosted.org/packages/10/a3/f4e6d1a38cd4db8a1275eddb287f3cdc2c01c48f80b30e89cc58cfd92156/pyobjc_framework_coretext-12.2.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:28980144af75598654f6997b2bbb427885f4f5df90aa4d840f452ba5778ab155", size = 30669, upload-time = "2026-06-19T16:09:56.521Z" },
+]
+
[[package]]
name = "pyobjc-framework-quartz"
version = "12.2.1"
@@ -171,6 +225,79 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/fc/b8/ff33610932e0ee81ae7f1269c890f697d56ff74b9f5b2ee5d9b7fa2c5355/python_xlib-0.33-py2.py3-none-any.whl", hash = "sha256:c3534038d42e0df2f1392a1b30a15a4ff5fdc2b86cfa94f072bf11b10a164398", size = 182185, upload-time = "2022-12-25T18:52:58.662Z" },
]
+[[package]]
+name = "pyyaml"
+version = "6.0.4"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/76/b8/c0b780928e2fb1c87e9e375818c6f121da2398b071012d1747be300b83f4/pyyaml-6.0.4.tar.gz", hash = "sha256:e24bf71af8a432d7808fabff134d38dfe16d3cbb41f2873bb4b1e42422de0a1a", size = 136336, upload-time = "2026-11-20T23:37:05.977Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/e1/ba/fb2aad330bc4f31041f989630ceae5f32e307d3ba9819573d35b71e078fa/pyyaml-6.0.4-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:180ac792c958c2173f6e4467c55ae5f73ab1a9a624ee29fc7095c56d5e3a4055", size = 190856, upload-time = "2026-11-20T23:34:50.753Z" },
+ { url = "https://files.pythonhosted.org/packages/16/da/1b8397614250ec63bb7ef1cbb0aa5878367ff729ef35a4abf2accbf48a18/pyyaml-6.0.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:730788375056c43d3ac15bd894c9cd2fb7a931a38b302f408620c64b3ef176ed", size = 180950, upload-time = "2026-11-20T23:34:51.629Z" },
+ { url = "https://files.pythonhosted.org/packages/fa/88/d99fc8f2cfb33ab7786fb3f6da90eddc1ed9709196bffcb4a487d7f53844/pyyaml-6.0.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:71bb5b87465d88d1dfc577115af6d435bff9b26f2512936f610c26aa55966028", size = 810905, upload-time = "2026-11-20T23:34:52.77Z" },
+ { url = "https://files.pythonhosted.org/packages/d7/7f/500e5ec119990d1784c72b64197cee8a4f2982f6bc76c572af7f8df02385/pyyaml-6.0.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b9fe0b8c65a1611053eb7fcaa7c022f655b7eebeb0ea034572615453cae6b843", size = 914779, upload-time = "2026-11-20T23:34:54.086Z" },
+ { url = "https://files.pythonhosted.org/packages/9d/3e/c1c307b6c03e4ea7d86f166f14920ead07aecc35e88d873814d12aa2da66/pyyaml-6.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:622aa875fa6533f25fedcffe23079357d65a690d462200afed5d8e9d0e01ebee", size = 828016, upload-time = "2026-11-20T23:34:55.213Z" },
+ { url = "https://files.pythonhosted.org/packages/03/49/dc931722d7de757596c1c3b944287e4f7d3f419655cd8f5fae382c6179e6/pyyaml-6.0.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:49e38a95e24738908ea852e61df0abc58d1e4d4f974ccdb2386eaee412bedc67", size = 799807, upload-time = "2026-11-20T23:34:56.589Z" },
+ { url = "https://files.pythonhosted.org/packages/bf/8b/2b7ad9af1c6c5b147c3c860a31586737034a83693d7ae86f854036c6aeb4/pyyaml-6.0.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:4d3bbc5e8a84a5a6775adecac786f489510a7159b1c343d6f31426d888cfdd6e", size = 836213, upload-time = "2026-11-20T23:34:57.655Z" },
+ { url = "https://files.pythonhosted.org/packages/8c/d8/ebdc04bbf7c00a3c78ea577322239534556418a958d2242af8c0c6ef9093/pyyaml-6.0.4-cp311-cp311-win32.whl", hash = "sha256:c0d68d972f6f6417b4e85e9522f3d57bb4fbc924379766ccd87254a31009c1cd", size = 146012, upload-time = "2026-11-20T23:34:58.75Z" },
+ { url = "https://files.pythonhosted.org/packages/7f/c6/ffe94f3159f3543b1ea1702519e1e0a74a67f3a255c286c1f00d51780b82/pyyaml-6.0.4-cp311-cp311-win_amd64.whl", hash = "sha256:0db75f402e99c25239003a499c214a61947b4ef5312af34711d4c63e5c179318", size = 161819, upload-time = "2026-11-20T23:34:59.853Z" },
+ { url = "https://files.pythonhosted.org/packages/86/df/5aec8a8c65e4c11fab31b55d53029d8013e5ccfcf409c20f8175e3e267c7/pyyaml-6.0.4-cp312-cp312-macosx_10_15_x86_64.whl", hash = "sha256:1088ad740f50c13178dad16fbc2fa1f634c791d42c7009fdb390e38e5b90b788", size = 187835, upload-time = "2026-11-20T23:35:00.829Z" },
+ { url = "https://files.pythonhosted.org/packages/c7/30/efaabf2d135d11f32cbd4752f3b7df0d592894ee3ca252bbba013a7d5891/pyyaml-6.0.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4d30c2f186612bd2f9f07c08a4c96721af59cfc8da3ec7cb27dfa2834e8bb019", size = 179510, upload-time = "2026-11-20T23:35:01.826Z" },
+ { url = "https://files.pythonhosted.org/packages/af/fb/d5ff6957db5c843151ff13196277bb8e20b2d5db2e2db3e8d051038d888b/pyyaml-6.0.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:45e37dd647db9d67b757444c74060c064ace5fdaa08f42bf4fda3812275d423e", size = 814700, upload-time = "2026-11-20T23:35:02.923Z" },
+ { url = "https://files.pythonhosted.org/packages/c4/de/569b907a281bbc49b934bcdad881486b7a476b011cf733f936ca85a8b37d/pyyaml-6.0.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:9e7ec9dc75cadd392fd687cc9b8ccf7dd59ada0a991e0d14ae0fad9ecdba00c3", size = 879806, upload-time = "2026-11-20T23:35:04.34Z" },
+ { url = "https://files.pythonhosted.org/packages/94/80/1d27f7084b983b7cfd1fb35e65a38276d9eddfdcdabc0922bb26cf9521bc/pyyaml-6.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:93bfb2459195406a518e2f487a9bbf01df240175f31e06f5a252ac6734c7bbf0", size = 849249, upload-time = "2026-11-20T23:35:05.457Z" },
+ { url = "https://files.pythonhosted.org/packages/53/37/9b49dff68570bedf27a05ff447e9a281d75bbdfa4d08dc1ee100a844c612/pyyaml-6.0.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:84e97378010f3da8daf673b82d39ed638098d236a1b760d61c0c1348a642bd70", size = 799796, upload-time = "2026-11-20T23:35:06.566Z" },
+ { url = "https://files.pythonhosted.org/packages/05/bb/f7df529541b98113bea84129a78f93c3889acb08385ca25f9786823dce67/pyyaml-6.0.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:f5c410f9e2ffc9286279a46f2e8c107edaf3b1123510af59c828a9c15b23c9db", size = 825424, upload-time = "2026-11-20T23:35:07.783Z" },
+ { url = "https://files.pythonhosted.org/packages/44/00/fc5d40087cc55bf3d7bb5ef55cc3e6513e6946afe33a188680fe1d846eb0/pyyaml-6.0.4-cp312-cp312-win32.whl", hash = "sha256:60e9da2772e259307650e03c24f50e3bc2d9fa5ed1ba44c47582e13b0e7708d1", size = 140667, upload-time = "2026-11-20T23:35:08.846Z" },
+ { url = "https://files.pythonhosted.org/packages/a3/95/307a6ceafbad9a08300743d19329c31726224e583e05c4fe5358522ba283/pyyaml-6.0.4-cp312-cp312-win_amd64.whl", hash = "sha256:131d11bd9b60d705a6388366d77ed67850995a4d2be85fe149785a257c17e531", size = 154452, upload-time = "2026-11-20T23:35:09.792Z" },
+ { url = "https://files.pythonhosted.org/packages/62/81/15c300b14cca818cb9ee27d8cb61cc124229d04f4f7f7bc4e3fca8e2e8d8/pyyaml-6.0.4-cp312-cp312-win_arm64.whl", hash = "sha256:69380d4bae12aab2a2c9532deff6a2841bc9fda47c333691bd2368b696301768", size = 147167, upload-time = "2026-11-20T23:35:10.763Z" },
+ { url = "https://files.pythonhosted.org/packages/95/22/b445c43210fe7f466fcf5a38bcbe850fd3db31b85594db22b5a43e63c482/pyyaml-6.0.4-cp313-cp313-macosx_10_15_x86_64.whl", hash = "sha256:61eef2f08e977b725f37a8d1663f5a222c6f09207ac0794030d5fca062e7c96e", size = 188392, upload-time = "2026-11-20T23:35:11.776Z" },
+ { url = "https://files.pythonhosted.org/packages/1f/c3/1536ad41fd962d3915f3f8252ecc7f91192ab15c3120ba72ff45e76b7077/pyyaml-6.0.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9d4211f080920629a90c9e31c51e326fb70cfae38f18d4128b9913c23642bace", size = 179961, upload-time = "2026-11-20T23:35:12.722Z" },
+ { url = "https://files.pythonhosted.org/packages/40/fd/c5297cc6370e4ab63d0c44d2e63510cc53354f5e8e74bcff047e2a384698/pyyaml-6.0.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:41b4669c3a8fd5750e594dff59d3e62d40e321fec467b50449603710ed0a68f3", size = 804464, upload-time = "2026-11-20T23:35:14.066Z" },
+ { url = "https://files.pythonhosted.org/packages/0c/2e/20385f63727a6c08df1adad34a88bde90e2bcc1146d1c8588a83190d53b8/pyyaml-6.0.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:efe68ed09903cca9ab4117c2b9ea6ee8d369818808945bb5a7fa8009b5630b45", size = 875357, upload-time = "2026-11-20T23:35:15.537Z" },
+ { url = "https://files.pythonhosted.org/packages/70/f2/f280d52f22f6d9853517d02495c02fbf4c80214fae8ca498efa8605013da/pyyaml-6.0.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:50588147ab2c6a59b5f990a4905db80899a6c2bd197e046a6201f1e67587e794", size = 838459, upload-time = "2026-11-20T23:35:16.681Z" },
+ { url = "https://files.pythonhosted.org/packages/2a/ee/5f7142110583686e94ab4492e3724ed0869cd9fe26ba8293ec25a47ee223/pyyaml-6.0.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:4d1e8d6e345b4b4424a05a11e699e999e65a88f422f73636f8a0b354bf219ffa", size = 789384, upload-time = "2026-11-20T23:35:17.734Z" },
+ { url = "https://files.pythonhosted.org/packages/4f/ab/1fd22df5305561cbefb85363182a0af5e81d219e8b8b8dfd73f20eb70859/pyyaml-6.0.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a56491babf0d976625807953bd192dd9de973fccb3270e77b1a795b152a26175", size = 814502, upload-time = "2026-11-20T23:35:19.171Z" },
+ { url = "https://files.pythonhosted.org/packages/c1/5a/6b53e1711a78fcc14619a341618c36b862ad8c634e7bc43ae18e6a7376b2/pyyaml-6.0.4-cp313-cp313-win32.whl", hash = "sha256:1631d566655f3af7d6c4a4485267830f6b680d3dc9704b659b3c3f4541b5a3fe", size = 140447, upload-time = "2026-11-20T23:35:20.134Z" },
+ { url = "https://files.pythonhosted.org/packages/bd/09/e785d2a9d64de2449cc3aecaa03f1c34670d7a688dc00da7246a858b7e8f/pyyaml-6.0.4-cp313-cp313-win_amd64.whl", hash = "sha256:0a3a351f04dc124f9357512bdb80ac37cd1750cf1371da33e7cbb96d80ac865f", size = 154298, upload-time = "2026-11-20T23:36:22.105Z" },
+ { url = "https://files.pythonhosted.org/packages/94/44/0ed649c2c1cc37b342042c3a4609247b74201c23a6f7f01f5dd222eae2bd/pyyaml-6.0.4-cp313-cp313-win_arm64.whl", hash = "sha256:f617e4e5c619fef5284335b24e3af3a77ce08dc5c389ff4b25033bb2749032b7", size = 146938, upload-time = "2026-11-20T23:36:23.305Z" },
+ { url = "https://files.pythonhosted.org/packages/70/90/a2d37db959cb771389bb6171eff83905776e5aead12a985a5118a587d6eb/pyyaml-6.0.4-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:4a329472db6c8858ebd94f2214a54c8bff8f035a6cc7af1ab39cc1b33a5f0e56", size = 189727, upload-time = "2026-11-20T23:36:24.518Z" },
+ { url = "https://files.pythonhosted.org/packages/71/40/de4380acb2bcc733f502a7c8562b08f741890741dcaa8a7f018c87acc060/pyyaml-6.0.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:7335809813ec838d9cd334b1744cda33deb141c9ef23a9c0df371c37980d3851", size = 181969, upload-time = "2026-11-20T23:36:25.675Z" },
+ { url = "https://files.pythonhosted.org/packages/7f/a1/88baf9d84981ea723fc1dd5cb534548caebff3071939f899509ab7c62d2f/pyyaml-6.0.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ed9b957abb12f6ffcd92d5db32fa3ffd4e4a8423d80ddd51b4efa63b42f6a76b", size = 804091, upload-time = "2026-11-20T23:36:26.979Z" },
+ { url = "https://files.pythonhosted.org/packages/b8/d4/ce94fe5b0e3cc04834d4a30237c1b5388a13ff5a383b919e857898834857/pyyaml-6.0.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b525488d5addf5d59ff4610cd8b1deab9dc97fe0fb3fb74533d7f65e9792bd92", size = 869794, upload-time = "2026-11-20T23:36:28.069Z" },
+ { url = "https://files.pythonhosted.org/packages/ef/1b/54ce11b40c8fa1883f14eef46525c3c329509dcc268164074fbe60add8ed/pyyaml-6.0.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c604dc2613c417130479cdd6e55c2faa691b6365aa82b3dafddfcecc2eaf1ac7", size = 819491, upload-time = "2026-11-20T23:36:29.189Z" },
+ { url = "https://files.pythonhosted.org/packages/8a/d2/6202ffb5d61667c993211a9231836b5d9be5e34165efd1714ac68ea76029/pyyaml-6.0.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f1a4a85b419f5cb6470dd4be5f766bc59532f11b9c22c076b58a0348f05dca5f", size = 790345, upload-time = "2026-11-20T23:36:30.597Z" },
+ { url = "https://files.pythonhosted.org/packages/d4/39/d62587fae4a9a32197ea43182c38f221f3f173a09c6f4380254533bdd89e/pyyaml-6.0.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:132c3c7c37a8e6f334921b05cfea5d26e241d792dcbb4db0462129d25ca53b43", size = 824626, upload-time = "2026-11-20T23:36:31.9Z" },
+ { url = "https://files.pythonhosted.org/packages/b4/b5/e5cf6ca786f8a5b9bd91e01fe8f2113300bc5628fcfdd3ca02d271970824/pyyaml-6.0.4-cp314-cp314-win_amd64.whl", hash = "sha256:1d2f08c122727c86f8303bb1dd45159ca1de1f2d68798e671ec46974e321008e", size = 157525, upload-time = "2026-11-20T23:36:44.254Z" },
+ { url = "https://files.pythonhosted.org/packages/75/9c/d78ce9adda3f7db933f73bb2b17ede76f5786fff747a2b73f6e8a6b7bab5/pyyaml-6.0.4-cp314-cp314-win_arm64.whl", hash = "sha256:33506a2620f0e7c49858f09cb44e99f144878d03af3d9c10aa136e9a1d103bcd", size = 151175, upload-time = "2026-11-20T23:36:45.191Z" },
+ { url = "https://files.pythonhosted.org/packages/83/f0/e48b8e9736380a039a17506200c4c3080ef181ee86b0e8e2cd6c345ae78a/pyyaml-6.0.4-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:1db4d51d3c2c9545dd44c614febc4594240754f74b30d8e501415b118347f0d1", size = 193903, upload-time = "2026-11-20T23:36:33.086Z" },
+ { url = "https://files.pythonhosted.org/packages/98/ba/682030d1e08f2e4bbd57f164b9085d37560386cf54f6299825e754b32d1a/pyyaml-6.0.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:93da48af92c84c4236578e330a514ca324362c0bb62894d8d2343363ed57ff03", size = 188971, upload-time = "2026-11-20T23:36:34.034Z" },
+ { url = "https://files.pythonhosted.org/packages/e9/2b/4b29107aae981b4d4575945a73d6c73ebd407d27934dcf35a7daa8fbeb43/pyyaml-6.0.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3c7129bcee5c88c1450802cc6a95b690ee7c51bfcc7a9b60bbd9549a7a4fcbe6", size = 851356, upload-time = "2026-11-20T23:36:35.21Z" },
+ { url = "https://files.pythonhosted.org/packages/12/d4/2b05dddc8f59c3762e67c8d5ac01c1759767ee6ea4aba183a01950644668/pyyaml-6.0.4-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2018fda285d1289527a389e1b4ace1e2d3af410930f949136b55ecb0747744d1", size = 887294, upload-time = "2026-11-20T23:36:36.484Z" },
+ { url = "https://files.pythonhosted.org/packages/3e/2a/ce3e0ff674c67b9e1706912aae61063581b3dba22142e60ccdaa64b25c75/pyyaml-6.0.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:15c52bb238a15bb4fd7e6342a5ac71d594507667c7fe0e5a5abbc0f6875d1e91", size = 850982, upload-time = "2026-11-20T23:36:38.247Z" },
+ { url = "https://files.pythonhosted.org/packages/7e/ad/701d83221865b2512067a9ab2b8e062145af2d362cc2451e72c146ef34cf/pyyaml-6.0.4-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ab874ebcc5c12c31c859a9e9fe159d688df1f7a099818ef8a35906264a8f5d6b", size = 822547, upload-time = "2026-11-20T23:36:39.852Z" },
+ { url = "https://files.pythonhosted.org/packages/61/d1/d88b389313be382ddabd1bca86dbf5da31ac02ecbf29c893588aafb6e11f/pyyaml-6.0.4-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:62c5b5669b05dabf991a705f3a3601f57b65e95121a1d3e3a4ae4446c8632865", size = 845538, upload-time = "2026-11-20T23:36:41.285Z" },
+ { url = "https://files.pythonhosted.org/packages/1a/a6/c25ff1b5ebc8bfb11a783a5fde40435f0459629af6f56f9487479bca9766/pyyaml-6.0.4-cp314-cp314t-win_amd64.whl", hash = "sha256:609e8efaffa5662da16b7d53eef76fc4eedbbe56fce5829b67ba808a6e35d399", size = 164060, upload-time = "2026-11-20T23:36:42.238Z" },
+ { url = "https://files.pythonhosted.org/packages/08/ad/25d2ac566f0e2f4eb822c9c5e8d9a053406cbfff142273a072b194856823/pyyaml-6.0.4-cp314-cp314t-win_arm64.whl", hash = "sha256:a266cf55ee5cf63c1803432a61c6386e750e0012ca49d12d26ccb0ffd80b343a", size = 157379, upload-time = "2026-11-20T23:36:43.181Z" },
+ { url = "https://files.pythonhosted.org/packages/e5/29/fb680bd299c2c6e004c1cc1914f8bad276c6014fe8debd5d6d61ea4c4ff4/pyyaml-6.0.4-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:12a155bc41509d71a2eb73e2191d9e400c1345ea99ac3d9946c31f40a4c840f8", size = 189560, upload-time = "2026-11-20T23:36:46.145Z" },
+ { url = "https://files.pythonhosted.org/packages/af/6c/2ffdab56d7afeb039d957479a305516ddbaa08d0162d1e9165fb928e3aeb/pyyaml-6.0.4-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:070c22b6f490d6cc30912be9fb9ab1af9c752769b39b53616f6510c3f038ee6a", size = 181949, upload-time = "2026-11-20T23:36:47.065Z" },
+ { url = "https://files.pythonhosted.org/packages/b3/07/3a20ed31a60084206ac20449583b0d1a42116b3c530d6857918e4ddbe4b6/pyyaml-6.0.4-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:872d2a592289061c1b987e335b3568a2616b474be02bd0608d8f551a385441cd", size = 803806, upload-time = "2026-11-20T23:36:48.145Z" },
+ { url = "https://files.pythonhosted.org/packages/26/5b/3dd56027457b96e7e5ea2f4f5976e530d699884b4fd4e360e99e57fa6cca/pyyaml-6.0.4-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:914b19e17814315fbcca52031bf79b68237f3d87a948c584a667b18b468e4df7", size = 876808, upload-time = "2026-11-20T23:36:49.294Z" },
+ { url = "https://files.pythonhosted.org/packages/b0/51/096a5495b33ff2da32f0c84f5bf8e042cf76f72641cba06ee9618ad01f4d/pyyaml-6.0.4-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c57e40928738c4a202852759f9e1ee2c7063429a9469ee1ac15651bbf7d69963", size = 833052, upload-time = "2026-11-20T23:36:50.505Z" },
+ { url = "https://files.pythonhosted.org/packages/da/75/b4e86b5a27fcb9a9cf88e3b81d1b0c12cae2734311e508af18b93ff56286/pyyaml-6.0.4-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:8e0cd755ce5e9009fd95f9c553e5942478feb8f7dffa19435641fcdc3c20e8ca", size = 788983, upload-time = "2026-11-20T23:36:51.821Z" },
+ { url = "https://files.pythonhosted.org/packages/2c/00/2a2cdad68237bcd416bd01688ecfb0e3fa1e68a841b74193db97ffd1c716/pyyaml-6.0.4-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:2c11be5ab4d9f603a598b5ce93a2064ae38087bdf1b384c5397170054cda4e36", size = 828806, upload-time = "2026-11-20T23:36:52.959Z" },
+ { url = "https://files.pythonhosted.org/packages/a8/15/39efefc88dd6fbc3be23cef08a819f5e8bf9a6c0bcf003fc09d38dd0010e/pyyaml-6.0.4-cp315-cp315-win_amd64.whl", hash = "sha256:67da066ca12eb60114ea87f2ecbcca622fff0c205c743cc900437127564fabf6", size = 157467, upload-time = "2026-11-20T23:37:04.171Z" },
+ { url = "https://files.pythonhosted.org/packages/40/1d/fddc53420d9c12e7d27c36a59fabf186ba1f6117314da4927dc40b2da19b/pyyaml-6.0.4-cp315-cp315-win_arm64.whl", hash = "sha256:573debb9fe3075423d4f823795a678580e597218c25baef178d532b124a25a25", size = 151203, upload-time = "2026-11-20T23:37:05.079Z" },
+ { url = "https://files.pythonhosted.org/packages/fa/ea/48e62a25084fc4b317f8bcc5c9823ddaaa73a0c7769ca451dda6919ff491/pyyaml-6.0.4-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:c680622f85979f2ff59b4ae44c1ecb5566b2f0f0ffe5d0dc8b4bb6a0e916dabb", size = 193500, upload-time = "2026-11-20T23:36:54.416Z" },
+ { url = "https://files.pythonhosted.org/packages/49/dd/8c4df6becc936125261607073fbcd55e1d902a8d53ae4e4893d53b9df0ef/pyyaml-6.0.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:18ea9bda247857fc0de05181675dc116b54c1b04ca3db71de5d2108c882823b7", size = 188474, upload-time = "2026-11-20T23:36:55.651Z" },
+ { url = "https://files.pythonhosted.org/packages/d0/63/b60236ef09cbab7c5ce174aff59d49a3425b9a8e9bbe4690bd3b9b7d4fba/pyyaml-6.0.4-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6ac167ebebc0c387290406a337b9b5c8c343fa5f7928d5941e45a94b8ba3aa39", size = 848311, upload-time = "2026-11-20T23:36:56.961Z" },
+ { url = "https://files.pythonhosted.org/packages/f6/3b/4b14f064ae5d6f69638a86bb7bf1a46d02bb4de083798e693a4a83b1418a/pyyaml-6.0.4-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4a2a8f27d24d4cdc05aa11df5f4c08e13f30d9e6674809b6a5ddcfcba49a653a", size = 891181, upload-time = "2026-11-20T23:36:58.077Z" },
+ { url = "https://files.pythonhosted.org/packages/01/36/4e0b01e380bf3695d34a4bf6b9272c529f4c8d3195c733687d64fb9f8f06/pyyaml-6.0.4-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e956541cc7a3fff2bb5b17aeb6c5bb42c86c8e6dafb5ebdd41a05e72e702076b", size = 855715, upload-time = "2026-11-20T23:36:59.165Z" },
+ { url = "https://files.pythonhosted.org/packages/6d/a8/2784a29e687fa7a5882d47c925a98d1dbdd60ead521be14a9342c6a74ff9/pyyaml-6.0.4-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:8708f6ab9c2581ffa05f66dae3206bb0385949650537d7295fc7ab0d6454dd70", size = 818754, upload-time = "2026-11-20T23:37:00.248Z" },
+ { url = "https://files.pythonhosted.org/packages/bb/85/62d54e223b4bc89ff85f087a5ce2648e5d929d3214d64613dbae17d5e045/pyyaml-6.0.4-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:a65339c24f2fb8d4419e06ceec1bda98bdcff727b3b533a81d5af6bb2dd34520", size = 845763, upload-time = "2026-11-20T23:37:01.331Z" },
+ { url = "https://files.pythonhosted.org/packages/eb/40/6bd9090368664be984a83fd7fe64f8e044b067a52449679c309706e3199d/pyyaml-6.0.4-cp315-cp315t-win_amd64.whl", hash = "sha256:a3cc63af3d639d1609143711837b926183418260aae89ed95193c07b25b99d33", size = 163170, upload-time = "2026-11-20T23:37:02.3Z" },
+ { url = "https://files.pythonhosted.org/packages/0d/22/468d36762a0c650cf2295052998eb1d419053335ea9ff48a043f5ae4d578/pyyaml-6.0.4-cp315-cp315t-win_arm64.whl", hash = "sha256:d276f23e2371deb5ee68dd252cc9c2402b806b54d8d2cc7efbb6c34c3a78d886", size = 156942, upload-time = "2026-11-20T23:37:03.209Z" },
+]
+
[[package]]
name = "six"
version = "1.17.0"
diff --git a/tests/test_edge_launcher.py b/tests/test_edge_launcher.py
new file mode 100644
index 0000000..c0c25ab
--- /dev/null
+++ b/tests/test_edge_launcher.py
@@ -0,0 +1,78 @@
+from pathlib import Path
+from types import SimpleNamespace
+from unittest.mock import Mock
+
+import pytest
+from amplifier_module_tool_computer_use import edge_launcher, shared_transport
+from amplifier_module_tool_computer_use.edge_media import FixtureUnavailable
+from amplifier_module_tool_computer_use.ssh_transport import SshConnectError
+
+
+@pytest.mark.parametrize(
+ "url",
+ [
+ "https://example.com/media",
+ "file:///tmp/q",
+ "http://user@localhost/",
+ "http://localhost/\n",
+ ],
+)
+def test_only_local_fixture_urls(url):
+ with pytest.raises(ValueError):
+ edge_launcher.fixture_url(url)
+
+
+def test_generic_transport_cannot_share_edge_fixture():
+ key = ("ssh", "edge-test-host", None)
+ fixture = shared_transport.acquire_shared_transport(
+ key, Mock, edge_media_url="http://localhost/test"
+ )
+ try:
+ with pytest.raises(SshConnectError):
+ shared_transport.acquire_shared_transport(key, Mock)
+ finally:
+ fixture.close()
+
+
+def test_target_launch_yields_and_pins_first_window(tmp_path, monkeypatch):
+ import amplifier_module_tool_computer_use as package
+
+ backend = Mock()
+ backend.presence_idle_ms.return_value = 12
+ launcher = edge_launcher.EdgeLauncher("http://localhost/test", backend)
+ app = Mock(pid=492)
+ app.poll.return_value = None
+ create = Mock(return_value=app)
+ windows = [object()]
+ ax = SimpleNamespace(
+ AXUIElementCreateApplication=lambda pid: pid,
+ AXUIElementCopyAttributeValue=lambda *args: (0, windows),
+ )
+ monkeypatch.setattr(package, "macos_accessibility", ax, raising=False)
+ monkeypatch.setattr(edge_launcher, "EdgeApplication", create)
+ monkeypatch.setattr(edge_launcher.tempfile, "mkdtemp", lambda **kw: str(tmp_path))
+ fixture = Mock()
+ fixture.foreground.return_value = False
+ bind = Mock(return_value=fixture)
+ monkeypatch.setattr(edge_launcher, "MacEdgeFixture", bind)
+ assert launcher() is None
+ create.assert_not_called()
+ backend.presence_idle_ms.return_value = 6000
+ assert launcher() is None
+ create.assert_called_once()
+ (tmp_path / "SingletonLock").symlink_to("machine-492")
+ assert launcher() is None
+ fixture.foreground.return_value = True
+ result = launcher()
+ assert result["process"] is app and result["window"] is fixture
+ assert result["companion_tab_title"] == "Edge media companion"
+ bind.assert_called_once()
+ windows[0] = object()
+ with pytest.raises(FixtureUnavailable, match="window changed"):
+ launcher()
+ (tmp_path / "SingletonLock").unlink()
+ with pytest.raises(FixtureUnavailable):
+ result["check_binding"]()
+ launcher.close()
+ app.app.terminate.assert_not_called()
+ assert Path(launcher.profile).is_dir()
diff --git a/tests/test_edge_media.py b/tests/test_edge_media.py
new file mode 100644
index 0000000..c8e4de8
--- /dev/null
+++ b/tests/test_edge_media.py
@@ -0,0 +1,214 @@
+"""The recipient is an element in the fixture, never the foreground window."""
+
+import threading
+import time
+import unittest
+from concurrent.futures import ThreadPoolExecutor
+from unittest.mock import Mock
+
+from amplifier_module_tool_computer_use.edge_media import (
+ EdgeMediaRun,
+ FixtureUnavailable,
+ MacEdgeFixture,
+ UncertainDelivery,
+)
+from amplifier_module_tool_computer_use.episode import Episode, EpisodeError
+
+
+class Fixture:
+ def __init__(self):
+ self.focus = "fixture"
+ self.idle = 20
+ self.received = []
+ self.sampled = threading.Event()
+ self.before_press = lambda: None
+
+ def idle_seconds(self):
+ self.sampled.set()
+ return self.idle
+
+ def foreground(self):
+ return self.focus == "fixture"
+
+ def locate(self, control):
+ return "fixture", control
+
+ def press(self, recipient):
+ self.before_press()
+ self.received.append(recipient)
+
+
+class EdgeRunTests(unittest.TestCase):
+ def setUp(self):
+ self.fixture = Fixture()
+ self.identity = {"target": "mac", "owner": "fixture", "generation": "one"}
+ indicator = Mock()
+ indicator.start.return_value = indicator.update.return_value = (
+ indicator.status.return_value
+ ) = {"available": True, "ready": True, "healthy": True}
+ self.episode = Episode("mac", lambda: indicator, lambda: True)
+ self.episode.begin(self.identity)
+ self.addCleanup(self.episode.close, self.identity)
+ self.guard = Mock()
+ self.run = EdgeMediaRun(
+ self.episode, self.identity, self.guard, self.fixture, quiet_seconds=0.06
+ )
+
+ def test_user_input_during_lookup_yields_and_retries_after_idle(self):
+ interrupted = threading.Event()
+ original = self.fixture.locate
+
+ def locate(control):
+ if not interrupted.is_set():
+ self.fixture.idle = 0
+ interrupted.set()
+ return original(control)
+
+ self.fixture.locate = locate
+ with ThreadPoolExecutor(1) as pool:
+ work = pool.submit(self.run.press, "mute", timeout=3)
+ self.assertTrue(interrupted.wait(1))
+ time.sleep(0.15)
+ self.assertFalse(work.done())
+ self.assertEqual(self.fixture.received, [])
+ self.fixture.idle = 10
+ work.result(2)
+ self.assertEqual(self.fixture.received, [("fixture", "mute")])
+
+ def test_focus_changes_at_delivery_never_redirect_the_action(self):
+ self.fixture.before_press = lambda: setattr(
+ self.fixture, "focus", "other Edge window"
+ )
+ self.run.press("play")
+ self.assertEqual(self.fixture.received, [("fixture", "play")])
+
+ def test_other_window_is_left_in_front(self):
+ self.fixture.focus = "other Edge window"
+ with self.assertRaises(TimeoutError):
+ self.run.press("mute", timeout=0.1)
+ self.assertEqual(self.fixture.focus, "other Edge window")
+ self.assertEqual(self.fixture.received, [])
+
+ def test_stop_while_yielded_fences_future_attempts(self):
+ self.fixture.idle = 0
+ with ThreadPoolExecutor(1) as pool:
+ work = pool.submit(self.run.press, "play")
+ self.assertTrue(self.fixture.sampled.wait(1))
+ self.episode.fence(self.identity)
+ self.fixture.idle = 100
+ with self.assertRaises(FixtureUnavailable):
+ work.result(1)
+ with self.assertRaises(EpisodeError):
+ self.run.press("play")
+ self.assertEqual(self.fixture.received, [])
+
+ def test_old_halt_refuses_even_on_idle_mac(self):
+ self.guard.side_effect = PermissionError("persisted halt")
+ with self.assertRaises(PermissionError):
+ self.run.press("mute")
+ self.assertEqual(self.fixture.received, [])
+
+ def test_window_replacement_retires_binding(self):
+ self.fixture.foreground = Mock(side_effect=FixtureUnavailable("closed"))
+ with self.assertRaises(FixtureUnavailable):
+ self.run.press("mute")
+ self.fixture.foreground = lambda: True
+ with self.assertRaisesRegex(FixtureUnavailable, "retired"):
+ self.run.press("mute")
+ self.assertFalse(self.fixture.received)
+
+ def test_unreadable_input_is_never_idle(self):
+ self.fixture.idle = float("nan")
+ with self.assertRaises(FixtureUnavailable):
+ self.run.press("mute")
+ self.assertFalse(self.fixture.received)
+
+ def test_uncertain_toggle_is_not_replayed(self):
+ def uncertain(recipient):
+ self.fixture.received.append(recipient)
+ raise UncertainDelivery("no acknowledgement")
+
+ self.fixture.press = uncertain
+ with self.assertRaises(UncertainDelivery):
+ self.run.press("mute")
+ with self.assertRaisesRegex(FixtureUnavailable, "retired"):
+ self.run.press("mute")
+ self.assertEqual(self.fixture.received, [("fixture", "mute")])
+
+ def test_native_receiver_uses_retained_element(self):
+ fixture = MacEdgeFixture.__new__(MacEdgeFixture)
+ fixture._ax = Mock()
+ fixture._ax.AXUIElementPerformAction.return_value = 0
+ recipient = object()
+ fixture.press((recipient, "AXPress"))
+ fixture._ax.AXUIElementPerformAction.assert_called_once_with(
+ recipient, "AXPress"
+ )
+
+ def test_unsupported_keyboard_gesture_has_no_fallback(self):
+ fixture = MacEdgeFixture.__new__(MacEdgeFixture)
+ with self.assertRaises(FixtureUnavailable):
+ fixture.locate("keyboard zoom")
+
+
+class BoundControlTests(unittest.TestCase):
+ def setUp(self):
+ self.nodes = {
+ "app": {"AXWindows": ["owned", "other"], "AXFocusedWindow": "owned"},
+ "document": {"AXWindow": "owned", "AXURL": "http://localhost:8432/test"},
+ "group": {
+ "AXWindow": "owned",
+ "AXTabs": ["main", "companion"],
+ "AXValue": "main",
+ },
+ "main": {"AXWindow": "owned", "AXValue": 1},
+ "companion": {"AXWindow": "owned", "AXValue": 0},
+ }
+ fixture = MacEdgeFixture.__new__(MacEdgeFixture)
+ fixture._attr = lambda node, key: self.nodes[node].get(key)
+ fixture._root = "app"
+ fixture._app = Mock()
+ fixture._app.isActive.return_value = True
+ fixture._process = Mock()
+ fixture._process.poll.return_value = None
+ fixture._window = "owned"
+ fixture._document = "document"
+ fixture._url = self.nodes["document"]["AXURL"]
+ fixture._tabs = ("group", "main", "companion")
+ fixture._ax = Mock()
+ fixture._ax.AXUIElementCopyActionNames.return_value = (0, ["AXPress"])
+ fixture._ax.AXUIElementPerformAction.return_value = 0
+ self.fixture = fixture
+
+ def test_tab_roundtrip_addresses_original_elements(self):
+ self.assertTrue(self.fixture.foreground())
+ self.fixture.press(self.fixture.locate("background_tab"))
+ self.nodes["group"]["AXValue"] = "companion"
+ self.assertTrue(self.fixture.foreground())
+ self.fixture.press(self.fixture.locate("restore_tab"))
+ recipients = [
+ call.args
+ for call in self.fixture._ax.AXUIElementPerformAction.call_args_list
+ ]
+ self.assertEqual(recipients, [("companion", "AXPress"), ("main", "AXPress")])
+
+ def test_closing_original_tab_while_away_ends_run(self):
+ self.nodes["group"].update(
+ AXValue="companion", AXTabs=["replacement", "companion"]
+ )
+ with self.assertRaises(FixtureUnavailable):
+ self.fixture.foreground()
+
+ def test_navigation_ends_run(self):
+ self.nodes["document"]["AXURL"] = "http://localhost:8432/replacement"
+ with self.assertRaises(FixtureUnavailable):
+ self.fixture.foreground()
+
+ def test_other_edge_window_with_same_process_is_ineligible(self):
+ self.nodes["app"]["AXFocusedWindow"] = "other"
+ self.assertFalse(self.fixture.foreground())
+
+ def test_moved_tab_is_ineligible(self):
+ self.nodes["companion"]["AXWindow"] = "other"
+ with self.assertRaises(FixtureUnavailable):
+ self.fixture.locate("background_tab")
diff --git a/tests/test_episode_lifecycle.py b/tests/test_episode_lifecycle.py
index 0ecb19a..e163c95 100644
--- a/tests/test_episode_lifecycle.py
+++ b/tests/test_episode_lifecycle.py
@@ -1270,3 +1270,118 @@ def broken(*args, **kwargs):
assert indicator.status()["process_settled"] is True
assert result["indicator_settled"] and result["release_confirmed"]
assert result["state"] == "interrupted" and not result["admission_open"]
+
+
+def test_remote_edge_runner_addresses_registered_fixture_and_keeps_stop(monkeypatch):
+ from amplifier_module_tool_computer_use import edge_media
+ from amplifier_module_tool_computer_use.wire import is_retryable
+
+ backend, indicator = _FakeBackend(), Indicator()
+ backend.name = "macos"
+ delivered = []
+ enrolled = []
+ window = MockEdgeWindow(delivered)
+ monkeypatch.setattr(edge_media, "MacEdgeFixture", lambda *args: window)
+ agent = RemoteAgent(
+ backend,
+ read_only=False,
+ require_episode=True,
+ indicator_factory=lambda: indicator,
+ edge_media_launcher=lambda: (
+ enrolled.append(True)
+ or {
+ "process": object(),
+ "profile": "/private/test-profile",
+ "url": "http://localhost:8123/media",
+ "check_binding": lambda: None,
+ }
+ ),
+ )
+ identity = {
+ "owner": "fixture",
+ "target": agent._episode_target,
+ "generation": new_episode_generation(),
+ }
+ try:
+ assert agent._dispatch(Request(1, "episode_begin", {"identity": identity})).ok
+
+ def step(**args):
+ return agent._dispatch(Request(2, "edge_media_step", args))
+
+ assert not is_retryable("edge_media_step")
+ assert not agent._dispatch(
+ Request(2, "key", {"_episode": identity, "combo": "A"})
+ ).ok
+ assert not step(control="unknown", _episode=identity).ok
+ assert not step(control="mute").ok
+ assert not step(control="mute", _episode=identity, pid=12).ok
+ assert not enrolled
+ assert step(control="mute", _episode=identity).result == {"dispatched": False}
+ assert delivered == []
+ agent._edge_fixture[1]._quiet_since -= 6
+ assert step(control="mute", _episode=identity).result == {"dispatched": True}
+ assert delivered == ["original mute button"]
+ assert agent._episode_notice(
+ Request(3, "episode_revoke", {"identity": identity})
+ )
+ assert not step(control="mute", _episode=identity).ok
+ assert delivered == ["original mute button"] and enrolled == [True]
+ finally:
+ agent._dispatch(Request(4, "episode_end", {"identity": identity}))
+ agent._ledger.stop()
+
+
+class MockEdgeWindow:
+ def __init__(self, delivered):
+ self.delivered = delivered
+
+ def idle_seconds(self):
+ return 30
+
+ def foreground(self):
+ return True
+
+ def locate(self, control):
+ assert control == "mute"
+ return "original mute button"
+
+ def press(self, recipient):
+ self.delivered.append(recipient)
+
+
+@run_async
+async def test_remote_media_host_rechecks_stop_after_zero_input_reply(monkeypatch):
+ from unittest.mock import Mock
+
+ from amplifier_module_tool_computer_use import edge_media
+
+ tool, agent, target = remote_rig()
+ target.name = tool._backend.presence_platform = "macos"
+ guard = Mock()
+ guard.check_sponsored_halt.side_effect = [
+ None,
+ None,
+ PermissionError("operator stopped"),
+ ]
+ tool._coexistence_guard = guard
+ delivered = []
+ monkeypatch.setattr(
+ edge_media, "MacEdgeFixture", lambda *args: MockEdgeWindow(delivered)
+ )
+ agent._edge_media_launcher = lambda: {
+ "process": object(),
+ "profile": "/private/test-profile",
+ "url": "http://localhost/media",
+ "check_binding": lambda: None,
+ }
+ try:
+ tool.begin_episode()
+ with pytest.raises(PermissionError, match="operator stopped"):
+ await tool.remote_edge_media_step("mute")
+ assert agent._edge_fixture is not None
+ assert guard.check_sponsored_halt.call_count == 3
+ assert delivered == []
+ finally:
+ tool.end_episode()
+ agent._ledger.stop()
+ tool._ledger.stop()
diff --git a/tests/test_halt_state.py b/tests/test_halt_state.py
index 87ed971..f6a966c 100644
--- a/tests/test_halt_state.py
+++ b/tests/test_halt_state.py
@@ -297,3 +297,31 @@ def test_persisted_halt_round_trip_dict() -> None:
)
restored = PersistedHalt.from_dict(original.to_dict())
assert restored == original
+
+
+def test_explicit_cancel_survives_subsequent_activity_and_new_guard(tmp_path):
+ from dataclasses import replace
+
+ saved_stop = replace(_snapshot(), basis="overlay_cancel", margin_ms=None)
+ record_halt("macos", saved_stop, reason="operator cancelled", state_dir=tmp_path)
+ record_halt("macos", _snapshot(), reason="activity", state_dir=tmp_path)
+ assert load_halt("macos", state_dir=tmp_path).reason == "operator cancelled"
+ (
+ tmp_path / "macos.json"
+ ).unlink() # Older worker cleared only its last observation.
+ assert make_durable_halt_poll("macos", state_dir=tmp_path)() is not None
+ assert list_halted_platforms(state_dir=tmp_path) == ["macos"]
+ assert clear_halt("macos", state_dir=tmp_path)
+ assert load_halt("macos", state_dir=tmp_path) is None
+
+
+def test_old_overlay_stop_is_preserved_when_new_worker_records_activity(tmp_path):
+ import json
+
+ record_halt("macos", _snapshot(), reason="old activity", state_dir=tmp_path)
+ path = tmp_path / "macos.json"
+ previous = json.loads(path.read_text())
+ previous["reason"] = "cancelled via overlay Cancel button"
+ path.write_text(json.dumps(previous))
+ record_halt("macos", _snapshot(), reason="later activity", state_dir=tmp_path)
+ assert load_halt("macos", state_dir=tmp_path).reason == previous["reason"]
diff --git a/tests/test_typing_attribution.py b/tests/test_typing_attribution.py
index d4b4408..0698d03 100644
--- a/tests/test_typing_attribution.py
+++ b/tests/test_typing_attribution.py
@@ -133,7 +133,10 @@ def observation():
windows.raw = raw
agent = SimpleNamespace(
- backend=windows, read_only=False, _HANDLERS=RemoteAgent._HANDLERS
+ backend=windows,
+ read_only=False,
+ _edge_media_only=False,
+ _HANDLERS=RemoteAgent._HANDLERS,
)
class Transport: