2025-12-09 17:51:05 +00:00
---
2026-01-04 14:32:47 +00:00
summary: "Spec for the Clawdbot macOS companion menu bar app (gateway + node broker)"
2025-12-09 17:51:05 +00:00
read_when:
- Implementing macOS app features
2025-12-20 02:08:04 +00:00
- Changing gateway lifecycle or node bridging on macOS
2025-12-09 17:51:05 +00:00
---
2026-01-04 14:32:47 +00:00
# Clawdbot macOS Companion (menu bar + gateway broker)
2025-12-05 23:13:53 +01:00
2025-12-20 02:08:04 +00:00
Author: steipete · Status: draft spec · Date: 2025-12-20
2025-12-05 23:13:53 +01:00
## Purpose
2026-01-04 14:32:47 +00:00
- Single macOS menu-bar app named **Clawdbot** that:
- Shows native notifications for Clawdbot/clawdbot events.
2025-12-07 02:34:21 +01:00
- Owns TCC prompts (Notifications, Accessibility, Screen Recording, Automation/AppleScript, Microphone, Speech Recognition).
2025-12-20 02:08:04 +00:00
- Runs (or connects to) the **Gateway** and exposes itself as a **node** so agents can reach macOS‑ only features.
2026-01-06 18:59:06 +01:00
- Hosts **PeekabooBridge** for UI automation (consumed by `peekaboo` ; see [`docs/mac/peekaboo.md` ](https://docs.clawd.bot/mac/peekaboo )).
2026-01-04 14:32:47 +00:00
- Installs a single CLI (`clawdbot` ) by symlinking the bundled binary.
2025-12-05 23:13:53 +01:00
## High-level design
2025-12-13 16:55:41 +00:00
- SwiftPM package in `apps/macos/` (macOS 15+, Swift 6).
- Targets:
2026-01-04 14:32:47 +00:00
- `ClawdbotIPC` (shared Codable types + helpers for app‑ internal actions).
- `Clawdbot` (LSUIElement MenuBarExtra app; hosts Gateway + node bridge + PeekabooBridgeHost).
- Bundle ID: `com.clawdbot.mac` .
2025-12-20 02:08:04 +00:00
- Bundled runtime binaries live under `Contents/Resources/Relay/` :
2026-01-04 14:32:47 +00:00
- `clawdbot` (bun‑ compiled relay: CLI + gateway-daemon)
- The app symlinks `clawdbot` into `/usr/local/bin` and `/opt/homebrew/bin` .
2025-12-20 02:08:04 +00:00
## Gateway + node bridge
- The mac app runs the Gateway in **local** mode (unless configured remote).
2026-01-04 14:32:47 +00:00
- The gateway port is configurable via `gateway.port` or `CLAWDBOT_GATEWAY_PORT` (default 18789). The mac app reads that value for launchd, probes, and remote SSH tunnels.
2025-12-20 02:08:04 +00:00
- The mac app connects to the bridge as a **node** and advertises capabilities/commands.
- Agent‑ facing actions are exposed via `node.invoke` (no local control socket).
2026-01-04 14:32:47 +00:00
- The mac app watches `~/.clawdbot/clawdbot.json` and switches modes live when `gateway.mode` or `gateway.remote.url` changes.
2026-01-04 00:09:18 +01:00
- If `gateway.mode` is unset but `gateway.remote.url` is set, the mac app treats it as remote mode.
- Changing connection mode in the mac app writes `gateway.mode` (and `gateway.remote.url` in remote mode) back to the config file.
2025-12-20 02:08:04 +00:00
### Node commands (mac)
- Canvas: `canvas.present|navigate|eval|snapshot|a2ui.*`
- Camera: `camera.snap|camera.clip`
- Screen: `screen.record`
- System: `system.run` (shell) and `system.notify`
### Permission advertising
- Nodes include a `permissions` map in hello/pairing.
- The Gateway surfaces it via `node.list` / `node.describe` so agents can decide what to run.
2026-01-04 14:32:47 +00:00
## CLI (`clawdbot`)
- The **only** CLI is `clawdbot` (TS/bun). There is no `clawdbot-mac` helper.
2025-12-20 02:08:04 +00:00
- For mac‑ specific actions, the CLI uses `node.invoke` :
2026-01-04 14:32:47 +00:00
- `clawdbot canvas present|navigate|eval|snapshot|a2ui push|a2ui reset`
- `clawdbot nodes run --node <id> -- <command...>`
- `clawdbot nodes notify --node <id> --title ...`
2025-12-20 02:08:04 +00:00
## Onboarding
- Install CLI (symlink) → Permissions checklist → Test notification → Done.
- Remote mode skips local gateway/CLI steps.
2025-12-20 14:46:53 +00:00
- Selecting Local auto-enables the bundled Gateway via launchd (unless “Attach only” debug mode is enabled).
2025-12-05 23:13:53 +01:00
2025-12-12 23:22:40 +00:00
## Deep links (URL scheme)
2026-01-04 14:32:47 +00:00
Clawdbot (the macOS app) registers a URL scheme for triggering local actions from anywhere (browser, Shortcuts, CLI, etc.).
2025-12-12 23:22:40 +00:00
Scheme:
2026-01-04 14:32:47 +00:00
- `clawdbot://…`
2025-12-12 23:22:40 +00:00
2026-01-04 14:32:47 +00:00
### `clawdbot://agent`
2025-12-12 23:22:40 +00:00
Triggers a Gateway `agent` request (same machinery as WebChat/agent runs).
Example:
```bash
2026-01-04 14:32:47 +00:00
open 'clawdbot://agent?message=Hello%20from%20deep%20link'
2025-12-12 23:22:40 +00:00
```
Query parameters:
- `message` (required): the agent prompt (URL-encoded).
- `sessionKey` (optional): explicit session key to use.
2025-12-17 19:21:54 +01:00
- `thinking` (optional): thinking hint (e.g. `low` ; omit for default).
2025-12-12 23:22:40 +00:00
- `deliver` (optional): `true|false` (default: false).
2026-01-06 18:25:52 +00:00
- `to` / `provider` (optional): forwarded to the Gateway `agent` method (only meaningful with `deliver=true` ).
2025-12-12 23:22:40 +00:00
- `timeoutSeconds` (optional): timeout hint forwarded to the Gateway.
- `key` (optional): unattended mode key (see below).
Safety/guardrails:
2025-12-17 19:21:54 +01:00
- Always enabled.
- Without a `key` query param, the app will prompt for confirmation before invoking the agent.
2026-01-04 14:32:47 +00:00
- With `key=<value>` , Clawdbot runs without prompting (intended for personal automations).
2025-12-12 23:22:40 +00:00
- The current key is shown in Debug Settings and stored locally in UserDefaults.
Notes:
2026-01-04 14:32:47 +00:00
- In local mode, Clawdbot will start the local Gateway if needed before issuing the request.
- In remote mode, Clawdbot will use the configured remote tunnel/endpoint.
2025-12-12 23:22:40 +00:00
2025-12-05 23:13:53 +01:00
## Build & dev workflow (native)
2026-01-05 21:30:19 +01:00
- `cd apps/macos && swift build` (debug) / `swift build -c release` .
2026-01-04 14:32:47 +00:00
- Run app for dev: `swift run Clawdbot` (or Xcode scheme).
2025-12-20 02:08:04 +00:00
- Package app + CLI: `scripts/package-mac-app.sh` (builds bun CLI + gateway).
- Tests: add Swift Testing suites under `apps/macos/Tests` .
2025-12-06 21:00:32 +01:00
2025-12-05 23:13:53 +01:00
## Open questions / decisions
2025-12-20 02:08:04 +00:00
- Should `system.run` support streaming stdout/stderr or keep buffered responses only?
- Should we allow node‑ side permission prompts, or always require explicit app UI action?