Files
capri-core-rust/crates/capri-computer
nocodeandClaude Opus 5.5 49349d6ecd
CI / test (push) Has been cancelled
Linux port: first run, packaging, single instance, privacy and wiring
First run and backend
- The companion opens without Ollama or a model (OFFLINE / SETUP REQUIRED),
  opens Settings > Language model and picks the model up once downloaded.
- Model, provider and GPU changes apply without restarting (Ollama is
  restarted when launch settings change); no silent fallback from API mode.
- Fatal startup errors are shown in a window; the fallback avatar loads
  again; the shipped Capri artwork is used when nothing was imported.

Packaging and tooling
- packaging/arch/PKGBUILD, capri.desktop (KWin ScreenShot2 key), icons,
  artwork under /usr/share/capri/assets, Gitea Actions CI.
- xtask: `icons` and `release-check` (no private data or credentials).

Runtime
- One instance per data folder (flock + control socket): second launch
  shows the window; capri stop / restart / toggle / status (JSON, starts
  nothing) / doctor / setup / diagnostics export / purge.
- A foreign program on the Ollama port is refused; an Ollama left behind
  by Capri is replaced.

Privacy and security
- No raw Ollama log on disk; API keys are never saved in plaintext (old
  ones move to the keyring); refused credential notes are stored as
  [Credentials omitted]; launched apps get an allow-listed environment.

Fixes
- Stop/Escape silence the voice; saved voice effects apply to replies;
  settings_control glitch settings apply; distinct KWin cursor scripts;
  KDE window capture authorized for source builds; Linux wording.
- Voice pack references zipped with Windows separators are found.

Wired features
- Initiatives, request router, resource monitor, "clip that", questions
  about a snapshot, sleep mode, tap reactions, stopwatch, attachments,
  Internet mode button, voice-synced subtitles, wake visuals, dictation
  draft, tray switches, Spotify seek/shuffle/repeat; computer-control
  planner and classifier follow model switches and API mode.
- Approval cards: one shown, 8 queued, deduplicated, cancelled on stop,
  failure, lock or pause; one Application access switch.

Desktop
- Compositor detection (no black overlay on i3 without picom), i3lock
  detection, unsupported desktops reported at startup, screenshot-only
  control without AT-SPI, fontconfig fallbacks, translatable feature
  pages with French translations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:21:40 +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.