Files
hermes-agent/plugins/computer_use/cua/__init__.py
Teknium 63f5e0ea45 feat(computer-use): pluggable single-select computer-use providers
Third-party drivers (e.g. a Codex-style computer-use reimplementation) could
only replace cua-driver by patching core. computer_use now follows the
single-select provider model Hermes uses for memory providers, context
engines and cron schedulers:

- plugins/computer_use/__init__.py discovers bundled
  plugins/computer_use/<name>/ then user $HERMES_HOME/plugins/<name>/
  (marker: register_computer_use_provider / ComputerUseProvider) and loads
  ONLY the provider computer_use.backend names (default "cua"), read per
  call so each profile gets its own. Unselected providers are never
  imported; listing reads plugin.yaml only. An unknown/unloadable name
  returns an error naming it and the installed providers; no fallback.
- The built-in cua-driver is an ordinary bundled provider at
  plugins/computer_use/cua/ (driver implementation stays in
  tools/computer_use). tools/computer_use/backend.py gains
  ComputerUseProvider (create_backend(permission_mode=...), is_available(),
  optional doctor()).
- The tool's check_fn and backend construction go through the selected
  provider; the model-facing schema is unchanged for every provider
  (prompt-cache invariant). The test-only HERMES_COMPUTER_USE_BACKEND env
  switch is gone (tests patch _new_backend).
- General plugin discovery treats computer-use providers as exclusive
  (not eagerly imported, not listed as toggleable) and skips the bundled
  computer_use/ category, same as memory/, context_engine/, cron_providers/.
- hermes tools and the Desktop toolset panel list installed providers next
  to cua; computer-use doctor/status/permissions and the Desktop status
  payload skip cua-driver/TCC probes when another provider is selected.
2026-10-05 17:20:30 -07:00

34 lines
1.4 KiB
Python

"""Built-in ``cua`` computer-use provider: cua-driver over MCP (:mod:`tools.computer_use.cua_backend`)."""
from __future__ import annotations
import sys
from tools.computer_use.backend import ComputerUseBackend, ComputerUseProvider
class CuaDriverProvider(ComputerUseProvider):
name = "cua"
display_name = "cua-driver (background)"
def create_backend(self, *, permission_mode: str) -> ComputerUseBackend:
from tools.computer_use.cua_backend import CuaDriverBackend
return CuaDriverBackend(permission_mode=permission_mode)
def is_available(self) -> bool:
"""macOS/Windows/Linux + cua-driver binary (or env override). `hermes computer-use doctor` names blocked checks."""
if sys.platform not in ("darwin", "win32", "linux"):
return False
from tools.computer_use.cua_backend_driver import cua_driver_binary_available
if cua_driver_binary_available():
return True
# No host driver: the tool is still real when the desktop is placed inside a terminal backend whose image
# carries cua-driver (nousresearch/hermes-sandbox:desktop). Placement is config; the binary is probed lazily
# at first use, so this stays a cheap check_fn.
from tools.bot_desktop import placement
return placement.resolve().where == placement.TERMINAL
def register(ctx):
ctx.register_computer_use_provider(CuaDriverProvider())