# 08 — Model tools, permissions and secrets (feature prefix `TL`) Source of truth: CapriCore 1.0.4 tree at `~/Capri` (read-only), including the local `FWS-LINUX-BRIDGE` patches. Line numbers below refer to that tree. All examples are synthetic. Conventions used in this document: | Symbol | Meaning in Capri | Suggested Rust/Linux location | |---|---|---| | `` | installation/source root (the folder containing `apps/`, `integrations/`) | install dir, e.g. `/opt/capri` or a user checkout | | `` | `/data` | keep `/data` for parity, or `$XDG_DATA_HOME/capri` (decision in §12) | | `` | `/desktop` (private desktop state; `0700`) | same relative layout under `` | | `` | `/.runtime` (generated, disposable) | `$XDG_CACHE_HOME/capri` or `/.runtime` | | "JS length" | UTF-16 code units (`String.length`, `slice`) | Rust must count `char`s (never bytes) and never split a char; document any off-by-surrogate drift as accepted | --- ## 1. Purpose and scope This subsystem decides **which actions the model may call, under which grants, with which confirmations, and how secrets are stored**. It also owns the concrete tools that are not computer-control: scoped files, fixed/catalog application grants, Spotify, web search, GitHub credentials, owner-written "user tools" (sandboxed scripts), the DaVinci Resolve adapter, and the two consent mechanisms (approval cards and modal confirmations). | Capri file(s) | Covered by | |---|---| | `apps/desktop/tool-manifest.mjs` | TL-44 (manifest + bounded JSON-schema validator) | | `apps/desktop/user-tools.mjs`, `apps/desktop/native/tool-sandbox.cs`, `docs/user-tools.md` | TL-44..TL-50 | | `apps/desktop/web-search.mjs`, `web-sources.mjs`, `internet-search.mjs` | TL-36..TL-40 | | `apps/desktop/github-access.mjs` (+ `packages/updater/src/github.mjs`, `releases.mjs`) | TL-41, TL-42 | | `apps/desktop/spotify-planner.mjs`, `spotify-settings.mjs`, `integrations/spotify/*` (incl. `native/*.cs`) | TL-27..TL-35 | | `integrations/companion-tools/*` (`index.mjs`, `client.mjs`, `openclaw.plugin.json`) | TL-01..TL-03, TL-26, registry entries TL-54..TL-56 | | `integrations/filesystem/*`, `docs/file-actions.md` | TL-10..TL-21 | | `integrations/resolve/*` | TL-51 | | `apps/desktop/main/access-ipc.mjs` | TL-10, TL-23 (UI grant channels) | | `apps/desktop/main/confirmations.mjs` | TL-06 | | `apps/desktop/main/secure-window.mjs` | TL-52 | | `docs/application-actions.md`, `data/applications` | TL-22..TL-25 | | Followed imports (not owned, behaviour needed here): `apps/desktop/action-broker.mjs` (loopback bridge + `ActionApprovals`), `companion-actions.mjs` (dispatcher), `desktop-catalog.mjs` (app catalog + trash/recovery), `application-access.mjs`, `full-computer-access.mjs`, `tool-loop.mjs`, `action-replies.mjs`, `storage.mjs`/`packages/runtime/src/atomic-json.mjs`, `integrations/desktop-actions/{index,service,settings}.mjs`, `integrations/openclaw-compat/patches.json` (per-turn tool filter), `packages/runtime/src/context.mjs` (tool allow-list) | TL-01..TL-09, TL-19, TL-22..TL-25 | Out of scope (owned by other specs, only the interface is described here): computer-control internals behind `desktop_control` (`inspect`, `type_text`, `browser_input`, `open_url`, `run_task`, observe/input), workflows, timers (`time_control`), Calculator math engine, chat routing/prompts, memory tools, installer/updater download pipeline, UI rendering. Key architectural change for Rust: Capri ran tools inside the OpenClaw Gateway (Node plugins) and forwarded them to the Electron main process over an authenticated loopback HTTP bridge (`data/secrets/desktop-actions.json`). The Rust app is one process: the bridge disappears, but every check the bridge performed (allow-listed tool names, size limits, per-tool timeouts, owner-turn gate, call-ID derivation, result envelope) must be kept in the in-process dispatcher. --- ## 2. Feature catalog ### 2.1 Registry, dispatch and consent #### TL-01 Tool registry and exposure gating — P0 - The model-callable tools are exactly (Capri names, keep them; prompts and tests depend on them): `filesystem_control`, `application_control`, `time_control`, `settings_control`, `desktop_control`, `workflow_control`, `spotify_control` (only when Spotify is enabled), `capri_tool_01` … `capri_tool_20` (only enabled user-tool slots), plus agent built-ins provided by other specs: `memory_search`, `memory_get`, workspace `read`/`write`/`edit` (workspace-only), `session_status` (`packages/runtime/src/context.mjs:134-155`). - A tool definition is created only when the turn is an **owner desktop chat turn**: in Capri `ctx.agentId === 'capri' && ctx.senderIsOwner === true && ctx.messageChannel === 'webchat' && !ctx.sandboxed && ctx.sessionKey && ctx.sessionId` (`integrations/companion-tools/index.mjs:207-215`, same in `filesystem/index.mjs:42-48`, `spotify/index.mjs:88-94`, `desktop-actions/index.mjs:36-42`). Otherwise the factory returns `null` (tool absent). Rust: a `TurnContext { origin, session_key, session_id, turn_id, cancel }`; tools are listed only for `origin == OwnerDesktop`. Telegram, delegated/sub-agents, initiative/proactive generations and any non-owner origin get no action tools. - Per-turn domain filter (`x-capri-tools-once`, OpenClaw patch `integrations/openclaw-compat/patches.json` patch #4, file `dist/openai-tool-choice-*.mjs`): the chat layer may restrict the next model run to one domain. Final map (intersection with the normal list, never persisted): | domain | tools offered | |---|---| | `dialogue` | none | | `conversation` | `memory_search`, `memory_get` | | `spotify` | `spotify_control` | | `calculator` | `application_control` | | `desktop` | `desktop_control`, `settings_control` | | (absent) | full list above | The header is accepted only for owner turns of agent `capri`; any other value is a 400 ("Invalid Capri one-shot tool mode"). Rust: `ToolRegistry::specs_for(&TurnContext, Option)`. - If the selected model lacks tool support (`modelCapabilities` without `tools`) no tool is offered (`compat.supportsTools=false`, `context.mjs:107-109`); context scripts (TL-49) still run. - `capri_tool_NN` appears only if `data/user-tool-definitions.json` (≤256 KiB, regular file, not a symlink, `version===1`, ≤20 entries) contains that exact name with a string description ≤1000 and `parameters.type==='object'` (`companion-tools/index.mjs:217-241`). Its label is the manifest name and its description is `Owner-approved isolated user tool "