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};needsApprovalis 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 }. Appendtextto the owner message, putcapri_tools::WEB_SEARCH_INSTRUCTIONin the system prompt, storesources(≤5{title,url}) on the assistant message, showmessagewhen set. Drop the future to cancel.capri_tools::web::public_web_source_urlre-validates a URL before opening it. - Dedicated music route:
capri_tools::spotify::{PLANNER_PROMPT, planner_format}for the Ollama/api/chatcall, thenspotify::validate_command(&plan)andspotify_tool.call(plan, ctx). Thespotify_controlresult is already the model projection (model_result). - Calculator fast path: call
application_controlwith{"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>andlaunch(&AppEntry) -> Result<>: XDG.desktopcatalog 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,targetpath validation,grant/set_write/revoke) andfiles::trash_file(path, home_trash)fordesktop_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)/snapshotfor 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 scopeca9f1000-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/controlsare not available (need the computer-control window/AT-SPI layer);launchdoes not verify the window.- Spotify: volume is MPRIS
Volume(not the PipeWire stream); play/search by name opens Spotify's search page (spotify:search:viaOpenUri) and does not start playback;mute, seek, shuffle, repeat, liked_songs, queue, queue_add, libraryreturnunsupported; no oEmbed title check for links. - Trash keeps no extra private recovery copy (the Trash is the recovery); no
openat2sandboxing, 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).