Commit Graph

80 Commits

Author SHA1 Message Date
Teknium
2776813df3 compat(plugins): temporary import-path shims for external plugins — ONE commit, revert on schedule
The Sep 2026 decomposition (PR #102117) makes internal import paths a non-API: names now live in
the focused modules that define them. This commit is the ONLY thing keeping the old paths alive,
so external plugins have time to update. It is deliberately a single, unsquashed commit:

    git revert <this sha>

removes every shim, stub and manifest at once on the announced date. Nothing in-tree may depend on
these pointers: scripts/check_compat_pointers.py (wired into lint.yml) fails CI if it does.

What it adds (see COMPAT_MANIFEST.md, compat_manifest.json):
- 332 facade modules get one delimited `PLUGIN-COMPAT` block appended at the end of the file
- 1,172 moved names resolved lazily via a module `__getattr__` (PEP 562) — never a top-level import,
  so no import cycles; facades that already had `__getattr__` get a chained one
- 592 third-party/stdlib names the old modules used to expose, with their original import statements
- 266 public definitions that had been deleted as unused, restored byte-for-byte from the pre-decomposition
  tree (+40 private helpers and 16 imports pulled in only because a restored definition needs them)
- 3 deleted modules recreated as re-export stubs (gateway/startup_watchdog, hermes_cli/observability/
  relay_runtime, tools/environments/modal_utils)
- private names (`_x`) get no pointer: they were never API (3,792 skipped)

Verified: all 335 touched modules import under a fresh HERMES_HOME and every manifest name resolves;
the lint reports zero in-tree uses; ruff clean; targeted suites unchanged.
2026-09-03 17:13:22 -07:00
Teknium
5c3db6750f simplify(compat): tools/computer_use/cua_backend — drop 24 re-exports + shutil re-import, repoint 5 callers + 14 test files 2026-09-03 13:22:51 -07:00
Teknium
75f8dd3293 review-fix(suppress-audit): tools/computer_use/tool.py — restore BASE exception semantics in _bounds_hints (int() failures propagate as on main) 2026-09-03 09:47:10 -07:00
Teknium
e83816a4d1 review-fix(comments): restore lost #NNNN rationale comments across non-test source (mechanical sweep, condensed, code unchanged)
For each issue anchor present in BASE 63279301bc non-test .py and absent on HEAD, the BASE comment/docstring block was re-attached at the HEAD location of the code it explained (matched by the distinctive code line / enclosing def). Sentences already covered by an existing HEAD comment were deduped; the issue number always survives. Insert-only: no code lines changed.
2026-09-03 09:44:26 -07:00
Teknium
febbe6ae12 review-fix(computer_use): restore per-axis scroll coordinate semantics
main guarded scroll's x/y independently (coordinate=[null,100] -> y=100),
while click treats a coordinate without x as no point. The shared _xy()
applied click semantics to scroll; split out _scroll_xy() with main's
per-axis guard and pin both behaviors in a test.
2026-09-03 09:32:38 -07:00
Teknium
72f5578b3a refactor(computer_use): restore leading comments on capture-cap constants; wrap _write_cache_file signature (legibility) 2026-09-02 23:49:02 -07:00
Teknium
de2c49b0d6 refactor(computer_use): compact section headers, wrapped literals, and one-shot walrus guards 2026-09-02 23:35:38 -07:00
Teknium
1fcb6f521d refactor(computer_use): atexit decorator, list-comprehension _format_elements, tighter signatures 2026-09-02 23:30:17 -07:00
Teknium
b8f6a8693a refactor(computer_use): set_value/focus_app handlers as table lambdas 2026-09-02 23:23:59 -07:00
Teknium
06c0243180 refactor(computer_use): lambda writer for element spill; single prefix assignment in follow capture 2026-09-02 23:22:16 -07:00
Teknium
0bd806bd22 refactor(computer_use): drop cap aliases in capture builders, single-line noop __init__, compact section spacing 2026-09-02 23:21:06 -07:00
Teknium
eebddc22e8 refactor(computer_use): drop dead re-raise branch in _stop_backend; compact _do_capture target forwarding 2026-09-02 23:19:21 -07:00
Teknium
775f1d77dc refactor(computer_use): inline _multimodal_capture, drop dead non-JSON fallback in follow capture, _xy as kwargs 2026-09-02 23:17:04 -07:00
Teknium
b651b77af5 refactor(computer_use): inline _view into its two builders; fold constant comments and _VERDICT_FIELDS 2026-09-02 23:12:47 -07:00
Teknium
230524b5d1 refactor(computer_use): _NoopBackend capture/focus_app via _noop_stub result factory 2026-09-02 23:10:01 -07:00
Teknium
b569633449 refactor(computer_use): fold _configured_permission_mode, _listing, _input into callers; merge capture MIME/ext helpers 2026-09-02 23:08:33 -07:00
Teknium
982f22fd56 refactor(computer_use): suppress-based bounds parsing; inline scale note into summary notes 2026-09-02 21:07:03 -07:00
Teknium
e368f42a0f refactor(computer_use): table-lookup summarize default, inline listing lambda and app-guard walrus 2026-09-02 21:02:45 -07:00
Teknium
a791dfbc63 refactor(computer_use): _stop_backend on_error hook replaces three try/except blocks; _install_backend owns the hook mirror 2026-09-02 20:58:47 -07:00
Teknium
29fb6e8ea9 refactor(computer_use): namedtuple _ActionSpec, walrus cache write, suppress-based vision analysis parse 2026-09-02 20:55:01 -07:00
Teknium
7390fa2929 refactor(computer_use): suppress-based bypass check, single denial payload, cache glob prune without branch 2026-09-02 20:45:36 -07:00
Teknium
74dccc1eaa refactor(computer_use): _view namespace builder replaces _CaptureView dataclass; suppress-based config readers; exact-target dict in follow capture 2026-09-02 20:41:54 -07:00
Teknium
05fd050547 refactor(computer_use): inline b64-dimension and vision-analysis helpers; generic _noop_stub covers all recording methods 2026-09-02 20:35:48 -07:00
Teknium
5d3f838606 refactor(computer_use): fold bypass warning into _cua_permission_mode; tighten reject/approval/summary helpers 2026-09-02 20:30:27 -07:00
Teknium
e0e2f26347 refactor(computer_use): fold bounds divergence into _bounds_hints, total as _CaptureView property, tighter payload/summary builders 2026-09-02 20:24:20 -07:00
Teknium
e04fa94299 refactor(computer_use): one _write_cache_file helper for spill/screenshot; _NoopBackend input stubs from a factory 2026-09-02 20:17:44 -07:00
Teknium
198eede489 refactor(computer_use): single _ACTIONS spec table replaces destructive/click/summary/simple/input tables 2026-09-02 20:13:15 -07:00
Teknium
0b60cceb0d refactor(computer_use): wrap wide lines, fold approval verdict branches and drag arg parsing (898->897 LOC) 2026-09-02 17:10:39 -07:00
Teknium
741886e576 refactor(computer_use): dict-literal action payload/escalation, single capture call in follow-up, drop unused noop state (912->898 LOC) 2026-09-02 17:09:06 -07:00
Teknium
770ad1f28d refactor(computer_use): single staged try in aux-vision routing, lambda summaries, tighter docstrings (929->912 LOC) 2026-09-02 17:06:42 -07:00
Teknium
0223eeca66 refactor(computer_use): walrus-fold guard checks, wrap wide lines (931->929 LOC) 2026-09-02 17:03:36 -07:00
Teknium
21372a16b2 refactor(computer_use): compact response helpers, NoopBackend recorder, docstrings/comments (976->931 LOC) 2026-09-02 17:00:40 -07:00
Teknium
18fa584366 refactor(computer_use): _CaptureView shares capture-derived facts across response branches; _detach_locked, _bounds_hints, _best_effort_write dedupe (997->976 LOC) 2026-09-02 16:52:47 -07:00
Teknium
d2add66648 refactor(computer_use): tool.py — verdict-field table, payload merge, stub/record cleanups 2026-09-02 16:16:54 -07:00
Teknium
d4b59e044c refactor(computer_use): tool.py — nullcontext in _stop_backend 2026-09-02 15:54:13 -07:00
Teknium
1d676837e0 refactor(computer_use): tool.py — reflow long literals, tighten signatures 2026-09-02 15:50:49 -07:00
Teknium
a1314db032 refactor(computer_use): tool.py — single-blank layout, **delivery kwargs for input handlers, staged try/except merge 2026-09-02 15:47:52 -07:00
Teknium
e3b79addc6 refactor(computer_use): tool.py — compact comments/docstrings, hoist vision prompt, tighten layout 2026-09-02 15:43:11 -07:00
Teknium
cf9f454cdc refactor(computer_use): tool.py — _reject_unsafe, _pop_session_locked, _cache_file, summary/envelope helpers, dispatch table for _summarize_action 2026-09-02 15:37:47 -07:00
Teknium
33ae442e94 refactor(tools/computer_use): split cua_backend into daemon/actions/... siblings; dispatch tables; compact doctor/tool 2026-09-02 14:45:15 -07:00
Teknium
f780cb36d8 refactor(computer_use): drop the cua_browser_* route — browser work goes through browser_exec
Real-profile browsing routes all in-page browser work through the Browser Use
CLI (browser_exec), which obsoletes the cua-driver typed-browser surface baked
into computer_use. Remove it so computer_use is a pure DESKTOP-control tool
(screenshots / mouse / keyboard / window management) and every call's schema
drops ~24 browser-only params + 9 actions.

- schema.py: 9 cua_browser_* actions and the typed-browser param block removed;
  14 desktop actions + shared params kept; description drops the browser rung.
- tool.py: cua_browser entries out of _SAFE/_DESTRUCTIVE_ACTIONS; the whole
  cua_browser dispatch block deleted; {"type","cua_browser_type"} → "type"
  (desktop typing untouched); _config_preauthorized (browser-prepare-only, a
  no-op for every desktop action) and the browser-page escalation hint removed.
- browser_route.py deleted (no importers outside the package); cua_backend.py
  drops the import + typed_browser_* methods; backend.py drops the non-abstract
  defaults.
- tests: browser-route/contract suites removed; browser assertions trimmed.

Desktop control unchanged. 233 computer_use tests pass; the 1 remaining failure
(test_gateway_session_key_yolo_maps_to_unrestricted_mode) is a pre-existing
cross-test state leak — fails identically on origin/main, passes in isolation.
2026-08-26 19:25:33 -07:00
Teknium
3da5897c39 refactor(computer_use): diet schema + delete prompt block (~1.4K tok/call); remove max_elements, ladder moves to response verdicts 2026-08-26 04:50:13 -07:00
Teknium
ce9b9a6351 feat(computer_use): guide models from full-screen grabs to interactive lanes
Full-screen captures carry no element tree, so the CaptureResult now has a
'note' field surfaced in the tool summary telling the model to call
capture(app='<AppName>') or capture(app='desktop') when it needs to act on
what it sees. Schema description updated to distinguish app='screen'
(composited full-screen image) from app='desktop' (shell surface with
clickable elements); docs + regression tests (14, sabotage-verified) added.
2026-08-25 02:31:34 -07:00
Gille
188d47919a feat(computer-use): expose screenshots for chat delivery 2026-08-19 22:58:02 -07:00
Francesco Bonacci
3e0087abe2 fix(computer-use): warn when an approval bypass widens the driver mode
`--yolo` / `-z` read as "don't prompt me", but they also swap computer_use
onto a private `unrestricted` daemon, dropping the ceilings the configured
mode would have applied. Nothing said so. A script picks up `-z` for quiet
output and loses its limits as a side effect, and the only trace is a driver
process nobody inspects.

The mapping itself stays. It is deliberate, and `unrestricted` is reachable
no other way: it is intentionally not a config value so a stale config line
can never silently bypass approvals (see `_cua_configured_permission_mode`).
Removing the mapping would delete the capability rather than fix it, and
splitting it onto a second CLI flag was declined to avoid growing the
surface.

So the widening is now stated instead: one warning per session naming the
configured mode it left, what stopped applying, and the two ways to keep a
ceiling - drop the bypass flag, or declare a version-3 capability manifest,
which now rides along with unrestricted as of the previous commit.

Once per session, not per dispatch: the resolver runs on every tool call.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 11:34:40 -07:00
Francesco Bonacci
9a96fdc5b8 fix(computer-use): enforce existing-profile grant, unblock the opt-in
Live-testing the Cua Driver 0.20 convergence on Windows 11 (session 2,
cua-driver 0.20.0) surfaced three defects in the existing-profile browser
path and in install status.

1. The config grant was silently nullified by an approval bypass.

`--yolo` / `-z` map onto a private unrestricted daemon, which answers every
browser_prepare. Because the host delegated the entire existing-profile
decision to the driver, that bypass also nullified
`computer_use.grant_existing_profile: false`: a plain `hermes -z` attached
to the user's real Chrome profile and read live page content over CDP, with
the driver reporting it as "the approved existing Chromium profile". It was
never approved.

An approval bypass is consent to skip prompts, not consent to read an
existing profile's pages, cookies, and storage. CuaTypedBrowserRoute.prepare
now enforces the key itself, regardless of permission mode. bounded stays
exempt - its reviewed capability manifest is the authorization boundary.
The authorization inputs are resolved in the backend from config and the
backend's immutable mode, never from model-supplied kwargs.

2. The grant, once set, still could not be used.

With `grant_existing_profile: true` the runtime is launched
`--grant existing-profile` correctly, but cua_browser_prepare then hit a
runtime approval prompt anyway - re-asking the user to authorize what the
config already authorized, and making the documented opt-in unusable on any
non-interactive run, where the prompt has nobody to answer it and the call
dies on approval timeout. The durable, file-backed grant now stands in for
that prompt. Scope is narrow: only the existing-profile prepare, only when
the grant is present; isolated launches still prompt and any resolution
failure falls closed to prompting.

3. `computer-use status` hid a custom override and spliced its output.

With HERMES_CUA_DRIVER_CMD pointed at cmd.exe, status printed the child's
multi-line banner and prompt inside the one-line version field, never
mentioned the override, and advised `hermes computer-use install` - which
install itself (correctly) refuses to run against an overridden path. It now
names the override and mirrors install's update-or-unset guidance, and
version output is reduced to one bounded line.

Verified on the reported host: `-z` existing-profile attach now refuses and
names the key; `grant: true` no longer prompts (33s vs a 300s approval
timeout); status names the override and prints one line. No change to the
reconciliation path - driver SHA256 unchanged end to end.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 11:34:40 -07:00
Francesco Bonacci
a403fe6f92 feat(computer-use): support Cua Driver 0.20 runtime contracts 2026-08-16 11:34:40 -07:00
Teknium
9b9dd6eeab fix(computer-use): zero-rect AX bounds serialize as unknown, not a position
KDE/Qt apps report [0,0,0,0] bounds for elements that are perfectly
clickable by index (live QA: all 50 of kcalc's zero-rect elements,
including every radio button). Serializing that as a plausible rect
invites a model to derive coordinate=[0,0] and click the screen corner.

- _element_to_dict: zero rect -> bounds: null
- _format_elements: '@ bounds-unknown (click by element index)' instead
  of the fake rect in the summary line
- malformed bounds fail open (unchanged serialization)

Live-proven on real kcalc (cua-driver 0.20.0): 50 elements now null, 0
zero-rect leftovers, summary annotated, real rects preserved, and a
null-bounds radio button still clicks fine by index.
2026-08-15 22:36:52 -07:00
Teknium
b7f6280259 fix(computer-use): refuse wrong-window input on app= mismatch; hint near-miss actions
Live complex-action QA on a real KDE desktop (kcalc + kate multi-app
flows) found two dispatch gaps:

1. Wrong-window input reported as success. Input actions deliver to the
   backend's sticky target (last capture/focus_app); the app= argument
   models routinely pass on the input call itself was silently dropped.
   Proven live: with kcalc sticky, type(text='777', app='kate') returned
   ok:true and typed 777 INTO KCALC. New guard: provable mismatch
   (both names known, neither substring of the other — list_windows
   names are localized/variant) refuses with input_target_mismatch and
   a one-call fix instruction. Unknown current target fails open so
   legacy no-app flows are untouched.

2. Near-miss unknown actions were dead ends. A model emitting 'hotkey'
   got a bare unknown-action error. Suggestion map now names the real
   action ('did you mean key?') without aliasing — we never repair bad
   model output, we just point at the schema.

Also documents the verified-lost-keystroke rung in the computer-use
skill: KTextEditor (Kate/KWrite) discards synthetic X keystrokes at the
toolkit level — foreground type reports ok but AX shows nothing arrived,
and a raw XTest control fails identically outside our stack. Guidance:
after one verified-lost round trip, switch to file/DBus I/O instead of
looping the ladder.

Live proof on the fixed build: mismatch refused, kcalc display clean,
same call after capture(app=kate) succeeds, 'hotkey' suggests 'key'.
11 new tests; 158 sibling tests green.
2026-08-15 22:18:09 -07:00
Teknium
48dd9c87cf feat(computer-use): user-facing authorization for cua-driver browser attachment
Completes the typed cua_browser_* route (PR #74166 lineage) with the
authorization surface that makes existing-profile attachment and
repeatable bounded automation reachable by real users:

- hermes computer-use browser-approve: CLI passthrough that mints
  cua-driver's five-minute single-use attachment token for one exact
  (pid, window_id). The user, never the model, is the token source.
- approval_token passthrough on cua_browser_prepare (schema + dispatch +
  browser_route), forwarded only for existing_profile and only as a
  non-empty string.
- computer_use.permission_mode: bounded + capability_manifest config:
  private per-session embedded daemon launched with
  --capability-manifest/--approve-capability-manifest; missing manifest
  fails loudly. 'unrestricted' is deliberately NOT a config value —
  it stays bound to the explicit per-session YOLO toggle.
- Skill + system-prompt + docs guidance for the three authorization
  rungs and the isolated-profile-first default.

E2E-verified against a temp HERMES_HOME: real config resolution to
bounded, loud failure without a manifest, real argparse path driving a
fake cua-driver binary, standard default preserved.
2026-08-15 15:04:32 -07:00