hermes-agent/skills
Teknium b07791db05
feat(computer-use): cua-driver backend, universal any-model schema
Background macOS desktop control via cua-driver MCP — does NOT steal the
user's cursor or keyboard focus, works with any tool-capable model.

Replaces the Anthropic-native `computer_20251124` approach from the
abandoned #4562 with a generic OpenAI function-calling schema plus SOM
(set-of-mark) captures so Claude, GPT, Gemini, and open models can all
drive the desktop via numbered element indices.

## What this adds

- `tools/computer_use/` package — swappable ComputerUseBackend ABC +
  CuaDriverBackend (stdio MCP client to trycua/cua's cua-driver binary).
- Universal `computer_use` tool with one schema for all providers.
  Actions: capture (som/vision/ax), click, double_click, right_click,
  middle_click, drag, scroll, type, key, wait, list_apps, focus_app.
- Multimodal tool-result envelope (`_multimodal=True`, OpenAI-style
  `content: [text, image_url]` parts) that flows through
  handle_function_call into the tool message. Anthropic adapter converts
  into native `tool_result` image blocks; OpenAI-compatible providers
  get the parts list directly.
- Image eviction in convert_messages_to_anthropic: only the 3 most
  recent screenshots carry real image data; older ones become text
  placeholders to cap per-turn token cost.
- Context compressor image pruning: old multimodal tool results have
  their image parts stripped instead of being skipped.
- Image-aware token estimation: each image counts as a flat 1500 tokens
  instead of its base64 char length (~1MB would have registered as
  ~250K tokens before).
- COMPUTER_USE_GUIDANCE system-prompt block — injected when the toolset
  is active.
- Session DB persistence strips base64 from multimodal tool messages.
- Trajectory saver normalises multimodal messages to text-only.
- `hermes tools` post-setup installs cua-driver via the upstream script
  and prints permission-grant instructions.
- CLI approval callback wired so destructive computer_use actions go
  through the same prompt_toolkit approval dialog as terminal commands.
- Hard safety guards at the tool level: blocked type patterns
  (curl|bash, sudo rm -rf, fork bomb), blocked key combos (empty trash,
  force delete, lock screen, log out).
- Skill `apple/macos-computer-use/SKILL.md` — universal (model-agnostic)
  workflow guide.
- Docs: `user-guide/features/computer-use.md` plus reference catalog
  entries.

## Tests

44 new tests in tests/tools/test_computer_use.py covering schema
shape (universal, not Anthropic-native), dispatch routing, safety
guards, multimodal envelope, Anthropic adapter conversion, screenshot
eviction, context compressor pruning, image-aware token estimation,
run_agent helpers, and universality guarantees.

469/469 pass across tests/tools/test_computer_use.py + the affected
agent/ test suites.

## Not in this PR

- `model_tools.py` provider-gating: the tool is available to every
  provider. Providers without multi-part tool message support will see
  text-only tool results (graceful degradation via `text_summary`).
- Anthropic server-side `clear_tool_uses_20250919` — deferred;
  client-side eviction + compressor pruning cover the same cost ceiling
  without a beta header.

## Caveats

- macOS only. cua-driver uses private SkyLight SPIs
  (SLEventPostToPid, SLPSPostEventRecordTo,
  _AXObserverAddNotificationAndCheckRemote) that can break on any macOS
  update. Pin with HERMES_CUA_DRIVER_VERSION.
- Requires Accessibility + Screen Recording permissions — the post-setup
  prints the Settings path.

Supersedes PR #4562 (pyautogui/Quartz foreground backend, Anthropic-
native schema). Credit @0xbyt4 for the original #3816 groundwork whose
context/eviction/token design is preserved here in generic form.
2026-04-23 16:44:24 -07:00
..
apple feat(computer-use): cua-driver backend, universal any-model schema 2026-04-23 16:44:24 -07:00
autonomous-ai-agents refactor: remove smart_model_routing feature (#12732) 2026-04-19 18:12:55 -07:00
creative fix(skills/baoyu-comic): absolute curl paths + clarify-timeout handling (#13775) 2026-04-21 19:35:42 -07:00
data-science feat: restore ACP server implementation from PR #949 (#1254) 2026-03-14 00:09:05 -07:00
devops/webhook-subscriptions feat(webhook): direct delivery mode for zero-LLM push notifications (#12473) 2026-04-19 05:18:19 -07:00
diagramming refactor: reorganize skills into sub-categories 2026-03-09 03:35:53 -07:00
dogfood refactor: remove browser_close tool — auto-cleanup handles it (#5792) 2026-04-07 03:28:44 -07:00
domain refactor: reorganize skills into sub-categories 2026-03-09 03:35:53 -07:00
email feat: secure skill env setup on load (core #688) 2026-03-13 03:14:04 -07:00
feeds refactor: reorganize skills into sub-categories 2026-03-09 03:35:53 -07:00
gaming feat: add pokemon-player skill with battle-tested gameplay tips 2026-03-09 20:29:38 -07:00
gifs refactor: reorganize skills into sub-categories 2026-03-09 03:35:53 -07:00
github fix: five HERMES_HOME profile-isolation leaks (#10570) 2026-04-15 17:09:41 -07:00
index-cache Release set of skills 2026-02-25 05:21:17 -08:00
inference-sh feat(gateway): skill-aware slash commands, paginated /commands, Telegram 100-cap (#3934) 2026-03-30 10:57:30 -07:00
mcp skills: move 7 niche mlops/mcp skills to optional (#12474) 2026-04-19 05:14:17 -07:00
media docs: improve youtube-content skill structure and workflow 2026-04-03 22:18:00 -07:00
mlops fix(skills/llama-cpp): concise description, restore python bindings, fix curl 2026-04-21 13:30:10 -07:00
note-taking refactor: update Obsidian vault path handling 2026-02-25 20:24:51 -08:00
productivity feat(maps): add guest_house, camp_site, and dual-key bakery lookup (#13398) 2026-04-21 00:52:25 -07:00
red-teaming/godmode fix: five HERMES_HOME profile-isolation leaks (#10570) 2026-04-15 17:09:41 -07:00
research fix(skills): remove invalid llm-wiki related skill 2026-04-22 18:44:45 -07:00
smart-home feat: secure skill env setup on load (core #688) 2026-03-13 03:14:04 -07:00
social-media docs(xurl skill): document UsernameNotFound workaround (xurl v1.1.0) (#13458) 2026-04-21 03:09:10 -07:00
software-development refactor(skills): consolidate code verification skills into one (#4854) 2026-04-03 14:13:27 -07:00