Files
capri-core-rust/crates/capri-tools
nocodeandClaude Opus 5.5 844435f21f
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:15:49 +01:00
..
2026-11-11 20:20:48 +01:00
2026-11-11 20:20:48 +01:00

capri-tools

Model tools other than memory, perception and computer control, ported from CapriCore 1.0.4: filesystem_control, application_control, time_control, settings_control, spotify_control, plus host-side web search, action receipts, the XDG application catalog and the matching settings pages.

Names, descriptions and JSON schemas are Capri's, with Linux wording (Trash, text editor, Spotify desktop app). Results keep Capri's shapes (ok, error, cancelled, confirmation...).

Integration

Build the tools (app start)

let (events_tx, events_rx) = tokio::sync::mpsc::unbounded_channel::<capri_tools::ToolEvent>;
let external: capri_agent::tools::StateProvider = Arc::new(|| json!({
    "fullComputerAccess": computer.enabled,      // computer-control crate
    "screenObservation": screen.active,          // perception crate
    "glitchEnabled": ui.glitch, "glitchStrength": ui.glitch_strength,
}));
let tools = capri_tools::tools(store.clone, &paths, events_tx, external)?;
tools.time.clone.spawn;          // 500 ms scheduler, inside the tokio runtime
engine_tools.extend(tools.list);     // Vec<Arc<dyn Tool>>
// at exit:
tools.time.close;                  // checkpoints running clocks

tools.list holds, in order: filesystem_control, application_control, time_control, settings_control, spotify_control. spotify_control.available is false unless Spotify is enabled and Application access is on; the engine must re-check available per turn.

What the engine must do

  • Offer the tools only on owner desktop turns and apply the per-turn domain filter.
  • Pass ToolContext.call_id = sha256_hex(sessionKey + "\0" + sessionId + "\0" + modelCallId). Mutations are journaled by this id: a replay returns the stored result, a replay with other arguments is refused, an interrupted one is never retried.
  • Honour Tool::timeout: filesystem 105 s and settings 180 s, because approvals block the call until the owner answers (ctx.approvals.confirm, 90 s card). A refused card returns {"ok":true,"cancelled":true}; needsApproval is never returned with this blocking contract. Approval kinds: file.replace, file.trash, settings.notepad, settings.calculator, settings.screenObservation, settings.spotify, settings.languages, settings.models, settings.fullComputerAccess (show this one as the danger modal with a 3 s delay).
  • Receipts: after each tool result call capri_tools::factual_action_reply(tool, &args, &result) -> Option<String> (English key; translate).
  • Internet mode (..39): before the model call, capri_tools::web_context(&owner_text, Some(lang)).await? -> WebContext { text, sources, status, message }. Append text to the owner message, put capri_tools::WEB_SEARCH_INSTRUCTION in the system prompt, store sources (≤5 {title,url}) on the assistant message, show message when set. Drop the future to cancel. capri_tools::web::public_web_source_url re-validates a URL before opening it.
  • Dedicated music route: capri_tools::spotify::{PLANNER_PROMPT, planner_format} for the Ollama /api/chat call, then spotify::validate_command(&plan) and spotify_tool.call(plan, ctx). The spotify_control result is already the model projection (model_result).
  • Calculator fast path: call application_control with {"action":"calculate","expression":…,"showWindow":false}.

Events (ToolEvent)

Event App action
TimeDue(object) Show the due card; notify(&reminder_notification(&o, locked).0, &….1).await; speak reminder_speech(&o) unless voice is off (wakeOnReminder in the section). Delivered at least once (object.deliveryId dedupes).
TimeChanged Refresh timers panel / stopwatch HUD.
OpenPanel("screen" | "applications" | "languages" | "models") Owner approved: open that settings page.
Setting { name, value } Apply glitchEnabled, glitchStrength or fullComputerAccess (approved by the owner, or revoked).

Other public API

  • catalog -> Vec<AppEntry> and launch(&AppEntry) -> Result<>: XDG .desktop catalog for the computer-control crate (Hidden/NoDisplay respected, field codes stripped, no shell, own session, allow-listed environment). apps::fixed_app("notepad" | "calculator", &entries).
  • notify(summary, body) -> Result<u32>: org.freedesktop.Notifications (call from the app only).
  • files::Access (scopes, target path validation, grant/set_write/revoke) and files::trash_file(path, home_trash) for desktop_control trash.
  • settings_ui(ui, &Arc<SettingsStore>): Application access, Timers options, File access, Internet search.
  • timers_ui(ui, &TimeService): the Timers and reminders panel (create, list, pause/resume/snooze/dismiss).
  • TimeService::execute(call_id, args) / snapshot for the UI and the elapsed-time fast path.

Settings and files

  • Section tools (ToolsSettings): applicationAccess (true), notepad, calculator, spotify (false), wakeOnReminder (true), folders: [{id, root, write}] (default: installation scope ca9f1000-0000-4000-8000-000000000001, stored with an empty root = the data dir, writable).
  • <data>/desktop/time.sqlite: Capri's exact schema (imports from Capri work as is).
  • <data>/filesystem/operations.sqlite + recovery/: file journal and replace/undo copies.
  • Private (unreachable through any scope): config dir, cache dir, <data>/desktop, workspace, agent, brain, workflows, secrets, filesystem, user-tool-definitions.json.

Known limits (shortcut: comments)

  • Calculator uses f64 (15 significant digits), not 64-digit BigNumber; unit table is built in.
  • application_control focus/controls are not available (need the computer-control window/AT-SPI layer); launch does not verify the window.
  • Spotify: volume is MPRIS Volume (not the PipeWire stream); play/search by name opens Spotify's search page (spotify:search: via OpenUri) and does not start playback; mute, seek, shuffle, repeat, liked_songs, queue, queue_add, library return unsupported; no oEmbed title check for links.
  • Trash keeps no extra private recovery copy (the Trash is the recovery); no openat2 sandboxing, path checks are re-run before each step as in Capri.
  • Folder grants are typed paths in the settings page (no portal picker yet); Spotify toggle has no modal.
  • No web search rate limit (Capri had none).