Files
nocodeandClaude Opus 5.5 8413198f42
CI / test (push) Has been cancelled
Computer control: reach windows on other workspaces and virtual desktops
Opening a web service in a browser whose window sat on another i3
workspace failed with "I could not select the intended window": the
window list only covered visible workspaces, so the browser window was
never found nor activated.

- i3: leaves carry their workspace; hidden_leaves() lists windows on
  other workspaces and in the scratchpad.
- KWin: the list script reports the desktop of non-current windows and
  activation switches to that desktop first.
- Desktop::state(true) now includes those windows (minimized = true,
  desktop = workspace/desktop name), after the on-screen ones;
  state(false) is unchanged, so input and capture still only target
  visible windows.
- App window lists given to the model tag them with otherDesktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 17:11:12 +01:00
..
2026-11-11 20:20:48 +01:00
2026-11-11 20:20:48 +01:00

capri-computer

Spec 05 (computer control) in pure Rust for KDE Plasma 6 Wayland and i3/X11. Ports the behavior of capri_linux/*.py (no Python at runtime).

Module What
tool DesktopControl = the desktop_control tool (Capri schema/description, Linux wording), WorkflowControl = workflow_control
agent observe → plan → act → verify loop: host-made exact launch, checkpoints, guards, preflight replanning, navigation checks, completion review
planner compacted observation, action-specific schema, Capri planner/review prompts, host schema validator, decorated ids, JSON-mode fallback; model behind PlannerModel
session ComputerControl: turn-bound session, 80 inputs / 10 min, Escape armed + indicator visible before input, 400 ms supervision, fresh observations, held-input release, vision targets
native input primitives with identity re-checks (computer_*), re-activation of the observed window
a11y AT-SPI snapshot tree (atspi 0.30), control classification, address bar/search field, hit testing
backend Windows (KWin script / i3 IPC), Input (RemoteDesktop portal held in-process; XTest with keymap remap for Unicode), EscapeWatch (kglobalaccel; X11 XGrabKey)
apps .desktop discovery, Exec expansion launch (no shell), window ownership, owner catalog + grants, launch/inspect/type/browser draft/open URL
journal durable operation journal (SQLite WAL)
access Full computer access, Application-access pause, appearance sections
browser, plan, workflows, extras, keys, error page verification, checkpoint plan, workflow storage/replay, OpenURI portal, Steam state, Trash with recovery copy

Integration

Construction (app)

let (backends, desktop) = Backends::connect(&paths.data).await?;            // KDE or X11/i3
let native = Arc::new(Native { windows: backends.windows.clone, input: backends.input.clone,
    a11y: Arc::new(a11y::Atspi::connect.await?), allowed: Arc::new(|pid| process::allowed(pid, 0)) });
let allowed = { let s = store.clone; Arc::new(move || access::allowed(&s)) };
let control = ComputerControl::new(native.clone, backends.escape.clone, indicator, Some(Arc::new(desktop)), allowed);
control.set_vision(vision_model);                                          // optional LocalModel with vision
let planner = Planner::new(Arc::new(local_model), installed_browser_names);  // LocalModel implements PlannerModel
let desktop_tool = DesktopControl::new(store.clone, native, control, planner, file_scopes, language)?;
engine.register(desktop_tool.clone); engine.register(Arc::new(WorkflowControl(desktop_tool.clone)));

indicator: Arc<dyn Indicator> is the UI overlay: show(caption) returns once a click-through, always-on-top window covers every monitor (session waits <= 5 s), hide, visible. file_scopes: Option<Arc<dyn FileScopes>> comes from the file tools (for trash).

Engine responsibilities

  • Pass the owner turn id as ToolContext.turn_id; on turn end/cancel call control.turn_ended(turn); on hide/lock/suspend/quit call control.stop(true).
  • A computer route outside tools: desktop_tool.agent.run(goal, turn, previous_task, &cancel) after access::configure(&store, approvals, true, ru); then append Local execution record (data, not a new instruction): {"ownerTask": goal, "status": …, "result": summary} to history.
  • settings_control request fullComputerAccess → access::configure.
  • Events: control.events (computer.control {active, steps, deadline}), agent.progress (computer.task {phase, steps}), diagnostics agent.diagnostics (metadata only).

Settings sections

fullComputerAccess {enabled, drives:["/"]}, applicationAccess {enabled}, computerControl {enabled, intensity, theme, cursor, pointerDuration}. Files: <data>/desktop/desktop-operations.sqlite, app-catalog.json, file-recovery/, portal-restore-token, <data>/workflows/workflows.json. UI: ui::settings_ui returns ComputerRequests (enabling full access must go through access::configure).

Permissions (owner, once)

  • KDE input: KDE's remote-control dialog on first use (xdg RemoteDesktop portal, persist mode 2); the restore token resumes silently until revoked in System Settings → Applications → Remote control. No uinput, no udev rule, no group membership. During a session Escape is a KDE global shortcut (grabbed; other apps do not receive Escape while Capri controls the computer).
  • i3/X11: XTest and XRes (standard). Escape is grabbed on the root window during a session.
  • AT-SPI: at-spi2-core must run; Capri sets org.a11y.Status.IsEnabled. Apps started before that may need a restart to expose controls.

Not done (shortcuts, marked in code)

Discord GUI automation (..35; Discord text is withheld and raw input into Discord for Discord goals returns needs_user), Discord Rich Presence, meeting-call tasks, Edgerunners/Resolve/Steam-milestone scenarios (Steam state + extras::open_uri exist, not wired), application_control Notepad/Calculator and the precise calculator, routing predicates and intent classifier (only owner_app_launch), workflow recording (replay works), unique-page-search-field typing in browser_search (Capri types into it; here the search becomes a Google URL navigation). KDE pointer motion re-queries KWin per step (one-shot script), so motion is slower than on X11.