Commit Graph

86 Commits

Author SHA1 Message Date
teknium1
d28938d3da fix(computer-use): screenshot dedup forgets its last frame at a compaction boundary
The "screen unchanged" result points the model at its previous capture. After
context compression that capture may be summarized away, so the note would refer
to pixels no longer in context. Mirror read_file's reset_file_dedup: the
compaction boundary (both the summary path and the codex app-server path) now
clears the session's screenshot digest, and the first capture afterwards delivers
the image again even when the screen is byte-identical.
2026-09-14 07:21:18 -07:00
teknium1
31964ff4c6 fix(computer-use): dedup keyed by the scoped session, cleared on release
Key the screenshot-dedup state by the same profile-scoped session id the
backend cache uses, so two multiplexed profiles sharing a session id (or a
DISPLAY) never dedup against each other's frames, and forget the state in
release_computer_use_session so a re-created session's first capture
always delivers pixels. Reword the unchanged note to cover the aux-vision
path (where the prior result was an analysis, not an image). Tests: the
dispatch path (explicit capture + capture_after) honours the streak cap;
release forgets state.
2026-09-14 07:21:18 -07:00
Teknium
682b973b32 feat(computer-use): stop resending unchanged screenshots
Port from openclaw/openclaw#129924: a capture whose pixels are
byte-identical to the previous capture of the same target in the same
session returns its full text metadata (element index included) plus an
explicit 'screen unchanged' note instead of the multimodal image block.

Adapted for Hermes: openclaw gates dedup on per-frame context-epoch
tracking; Hermes bounds staleness with a consecutive-omission streak cap
(2) so full pixels are re-delivered before compaction could evict the
referenced image. Dedup state is per-session (no cross-session leaks),
append-only (no history rewrites — prompt cache prefixes untouched),
and skipped entirely when no session_id is present.
2026-09-14 07:21:18 -07:00
teknium1
71cebc6348 fix(tools): browser_exec and computer_use caches are namespaced by the served profile
Both process-global caches were keyed by the caller's session/task id alone, so under
gateway.multiplex_profiles two profiles using the same id — a shared `browser_exec session=`
name, or two Hermes sessions whose screens report the same DISPLAY — resolved to the FIRST
profile's cloud browser / cua-driver, and a command issued in one bot's chat could act on
another bot's screen.

The key now carries the routed profile's home key whenever a served-profile scope is active
(`get_hermes_home_override()` set), the same shape `tools/approval.py::_baseline_key` and the
camofox/cloud caches already use; outside a scope every key is byte-identical to before. The
computer_use lookup, install and release paths all go through one `_scoped_sid`, so a release
under profile B never stops profile A's driver; approval-bypass state keeps the bare session id.

Fixes #110032 (report by @wolfyy970, from @vandaimer's manual test on #108914).
2026-09-13 14:41:26 -07:00
teknium1
3e066dfedd fix(computer_use): approval goes through the shared gate; no callback now fails closed
computer_use kept its own approval decision: two module dicts
(_session_auto_approve / _always_allow) mirroring tools.approval's
session store and _persist_choice, a private verdict vocabulary
(approve_once/approve_session/always_approve) that hermes_cli mapped
back to once/session/always, and — the real problem — `if
_approval_callback is None: return None`. Only the interactive CLI ever
installed that callback, so every other host (gateway turns, cron,
api_server, tui_gateway, ACP) ran destructive desktop input with no
approval at all, ignoring cron_mode / unattended_mode / the permanent
allowlist, and "always" grants were invisible to `is_approved`,
`clear_session` and the messaging-platform approval buttons.

_request_approval now calls tools.approval._run_approval_gate with
pattern_key `cua:<action>:<background|foreground>` (the old scope shape,
so a background grant still never covers the visible foreground variant)
and fail_closed_when_no_human=True, the same posture as
request_tool_approval / the SSH-config write gate. The private dicts,
their release/atexit clearing, the verdict mapping in
hermes_cli/cli_modal_mixin.py and the extra callback install in cli.py
are deleted: the CLI's terminal_tool callback answers computer_use
prompts like any other tool. set_approval_callback stays as an optional
explicit-callback hook with the shared callback contract
(cb(command, description, **kw) -> once|session|always|deny|timeout);
no in-tree host uses it.

Behavior change:
- No approval callback and no gateway (cron, api_server/webhook,
  headless -q, plain library use): destructive actions are now REFUSED
  with a BLOCKED error and never reach the backend. Previously they
  silently ran. cron honors approvals.cron_mode, unattended platforms
  approvals.unattended_mode, -q approvals.single_query_mode.
- --yolo / gateway /yolo / approvals.mode: off still allow (unchanged).
- Gateway sessions (Telegram/Discord/Slack/...) now get a real pending
  approval with once/session/always buttons instead of default-allow.
- session/always grants live in tools.approval's store; "always" is one
  command_allowlist entry (`cua:click:background`) and is scoped to that
  action+mode — the old blanket "always_approve unlocks everything for
  the session" no longer exists.
- Denial wording is the shared gate's ("BLOCKED: User denied ...",
  "BLOCKED: Action timed out ..."); the error JSON keeps `action`.

Tests: tests/tools/test_computer_use_approval_isolation.py
::test_no_callback_refuses_unless_yolo (blocked + no backend call, then
yolo executes) and ::test_always_grant_lands_in_the_shared_store
(is_approved sees the cua:<action>:<mode> key; second call served from
the store). Sabotage: restoring the `callback is None -> allow`
short-circuit fails the first; swapping the shared gate for a private
grant set fails the second plus the three delivery-ladder scope tests.
tests/tools/conftest.py gains `grant_computer_use_approvals` for
dispatch tests that only care about routing.
2026-09-13 05:21:02 -07:00
Teknium
4b8c01f691 fix(multiplex): key tool-side and agent-side memos by profile home
Camofox VNC one-shot, computer-use aux-vision verdict, tirith binary path, MCP
discovery lock path, remote-backend probe text, learned image token costs,
auxiliary per-task semaphores and the custom-endpoint /models memo all held one
profile's config-derived value for the whole process. The skill-sync debounce
Timer ran with empty ContextVars, so a secondary's write pushed as the launch
profile (and cancelled its pending push).

Each memo is now keyed by hermes_home_key() (or credential fingerprint for the
per-key catalog) under an override; the timer is per home and runs its callback
inside the scheduling turn's copied context. Unscoped slots are unchanged.
2026-09-12 01:35:05 -07:00
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