# Tauri Driver

Bundled, first-party verify-proof driver for [Tauri](https://tauri.app)
desktop applications. The most common non-Electron desktop framework.

## When Aperant picks this driver

`/apt:verify-proof` auto-selects `tauri` when:

- The project's `package.json` declares `@tauri-apps/api` (or `tauri`) as
  a dependency — including the `apps/*` monorepo walk that
  `loadRuntimeCapabilities` performs.
- The required IDL capabilities are a subset of: `click`, `type`, `key`,
  `navigate`, `screenshot`, `assert_visible`, `assert_text`,
  `wait_for_idle`, `execute_js`, `dump_state`.

## Capabilities

| IDL verb | Maps to Tauri MCP tool |
|----------|------------------------|
| `click` | `mcp__tauri__click` |
| `type` | `mcp__tauri__type_text` |
| `key` | `mcp__tauri__mouse_action` (keyboard/shortcut dispatch) |
| `navigate` | `mcp__tauri__navigate` |
| `screenshot` | `mcp__tauri__take_screenshot` |
| `assert_visible` | `mcp__tauri__query_page` (mode: `find_element`) |
| `assert_text` | `mcp__tauri__query_page` (mode: `html`, textContent match) |
| `wait_for_idle` | `mcp__tauri__wait_for` |
| `execute_js` | `mcp__tauri__execute_js` |
| `dump_state` | `mcp__tauri__query_page` (mode: `state`) / `mcp__tauri__manage_window` |

These are the documented tools of the
[`tauri-plugin-mcp-server`](https://www.npmjs.com/package/tauri-plugin-mcp-server)
npm package (`take_screenshot`, `query_page`, `click`, `type_text`,
`mouse_action`, `navigate`, `execute_js`, `manage_storage`,
`manage_window`, `wait_for`, `restart_app`, `list_windows`, `ping`),
namespaced under `mcp__tauri__*` by the MCP server id.

## Manifest

- **Priority:** 85 (below the electron driver's 90 — Tauri is rarer than
  Electron in the desktop-app population).
- **Stability:** `ga`.
- **Trust:** `first_party_signed` (default-allow).
- **Network posture:** `deny` (Tauri apps shouldn't be hitting the network
  during proof verification).
- **Transport:** `{ mcp_server_id: "tauri" }`.

## Transport — how the MCP server is launched

The `tauri-plugin-mcp-server` npm bin ships **without a shebang**, so
`npx -y tauri-plugin-mcp-server` runs the `.js` as a shell script and
fails. Install-time provisioning therefore writes a launcher script at
`scripts/tauri-mcp.sh` that `exec node`s the bin via a stable path, loads
`.env`, and sets `TAURI_MCP_CONNECTION_TYPE=ipc` +
`TAURI_MCP_IPC_PATH` (a per-project socket). The host config entry is:

```json
{ "command": "bash", "args": ["./scripts/tauri-mcp.sh"] }
```

— identical to the proven shape. The launcher template lives at
`drivers/tauri/scripts/tauri-mcp.sh`; provisioning copies it idempotently
(never clobbering a user-edited launcher).

## PREREQUISITE — the app-side Rust plugin (OUT of framework scope)

This driver names the **transport**; it does NOT install the app-side
plugin. For the `mcp__tauri__*` tools to actually reach a running Tauri
app you must, in your own Tauri project:

1. Add the [`tauri-plugin-mcp`](https://github.com/P3GLEG/tauri-plugin-mcp)
   Rust plugin to `src-tauri/` and register it in your app builder.
2. Run the app with the MCP debug feature enabled, e.g.
   `tauri dev --features mcp-debug` (or your project's equivalent), so the
   plugin opens the IPC socket the launcher connects to.
3. Install the npm transport package as a devDependency:
   `pnpm add -D tauri-plugin-mcp-server`.

This is the SAME class of one-time, project-specific prerequisite as the
`electron-mcp-server` npm package for the electron driver — documented
here, never installed or modified by the Aperant framework.

**macOS note:** the plugin's `take_screenshot` does *screen-region*
capture at the window's bounds — keep the app foregrounded on the active
Space, or prefer `query_page` (DOM-only) for pixel-free assertions.

## Why hardcoded MCP tool names live here

Per [ID-01](../../../docs/frameworks/spec-gaps.md): the verify-proof
workflow prose refers ONLY to IDL verbs (`driver.click(target)`,
`driver.screenshot(path)`). The mapping from a verb to a concrete
`mcp__tauri__*` tool name exists in exactly two places — this README and
`driver.mjs`. The grep guard in
`packages/framework/src/__tests__/verify-proof-workflow-grep-guard.test.ts`
asserts zero `mcp__tauri__*` matches in `workflows/verify-proof.md`.
Adding this Tauri driver required zero edits to the workflow.

## V1 scope — adapter is thin

This driver's `driver.mjs` is a manifest-conformant **adapter shim** in
v1: each verb validates its args against `IDL_VERB_ARGS` and returns a
VerbResult stub. The actual `mcp__tauri__*` tool invocations happen at the
workflow-runner layer (the model holds the MCP tool surface, NOT the
driver process). The verb→tool mapping table above is the contract the
workflow runner consults; the driver itself is the validator + manifest +
resolver-anchor in v1 — same shape as `electron/driver.mjs`.
