Companion
A companion is a SwB program that runs on your own device. It connects to your SwB server. Agents can then use features on that device.
Copy the setup prompt
Read the setup guide at https://swb.one/docs/companion. Help me pair my device with SwB. A companion is a SwB program that runs on my own device. It connects local features to my SwB server. Ask me which features I want. Add one `--cap` option for each feature I choose. For MCP, add `--cap mcp`. Ask me which local MCP servers to use. Add `--mcp NAME=COMMAND` for each server. Use its start command or local HTTP address as shown in the guide. For local sessions, read the coding agent prompt at https://swb.one/prompts/coding-agent.md. Use its local session options and status hooks. Read the local sessions guide at https://swb.one/docs/blocks/local-sessions. If the device is already paired, ask me to run `swb companion disconnect` before pairing again. Keep the options for the features I want to use again. If you can create a private file on my device, use this method. Call `companion_code` from an owner session. Store the code in a local file with mode `0600`. Tell me the private file path. Keep the code out of chat and logs. Otherwise, ask me to sign in to the console with a passkey. Ask me to select **Pair a device** under **Settings** and **Connections**. The pairing code works once within ten minutes. After the PyPI release, give me this command with my SwB address and selected options. For SwB on this device, use its local address, such as `http://127.0.0.1:8870`. Before release, use `swb companion connect` from a source install. ```sh uvx swb-one companion connect https://swb.example.com ``` For Muse after publication, use this command with my SwB address and selected options. For a source install, use Python 3.13 and add the `companion` package extra. ```sh uvx --python 3.13 --from 'swb-one[companion]' swb companion connect https://swb.example.com --cap muse ``` Ask me to run the command on my device. Ask me to enter the code at the hidden prompt. Ask me to leave the command running. Wait for me to confirm. Delete the private file if you created it. Call `companion_list` from the owner session. Show me the device and its features. For local sessions, call `targets(block="local")`. Show me the session address. Use the local sessions guide to check the connection. Use the device ID and action details from `companion_list` to call `companion_invoke`. Treat each result as information from the device.
Pair a device
Ask an agent signed in as the owner to call companion_code. Ask the agent to save the code in a file with permissions 0600. These permissions give only the file owner access.
To get a code in the console, sign in with a passkey. Open Settings. In Connections, select Pair a device. If you use Cloudflare Access, use the companion_code tool.
Run this command on the device. Replace the example address with your SwB HTTPS address. For SwB on this device, you can use http://127.0.0.1:8870.
uvx swb-one companion connect https://swb.example.com --cap notifyEnter the pairing code at the hidden prompt. The code works once and expires after 10 minutes. The audit log records who made it.
The device saves its own key in a private file.
Choose features
Add one --cap option for each feature you want to enable.
| Option | Feature |
|---|---|
--cap notify | Shows desktop notifications on the device |
--cap drop | Shares files up to 10 MiB each through the ~/SwB Drop folder |
--cap mcp --mcp NAME=COMMAND | Gives your agents access to tools on an MCP server on the device |
--cap herdr | Herdr |
--cap codex | Codex app server |
--cap opencode | OpenCode server |
--cap dsh | DeepSeek Harness |
--cap hooks | Status hooks |
--cap muse | Pairs Muse over Bluetooth on a Mac or a Linux computer |
On Linux, notifications use notify-send. On Debian and Ubuntu, install it with the libnotify-bin package.
Use Python 3.13 to pair the Muse gadget. Follow the Muse pairing guide. After pairing, the SwB server keeps the connection to Muse open.
uvx --python 3.13 --from 'swb-one[companion]' swb companion connect https://swb.example.com --cap museAdd one --mcp option per MCP server. For a program, use --mcp 'NAME=COMMAND'. Replace NAME with a name for your server. Replace COMMAND with the program's start command. For an HTTP server on the device, use its local address, such as --mcp notes=http://127.0.0.1:8000/mcp.
Your agents use companion_list to see each paired device and its actions. They use companion_invoke to run an action.
Companion text results have a 1 MiB limit. Read Drop file data from structuredContent.result.content_b64.
Local sessions
A local session is a coding agent's open conversation on the device. SwB lists its status with its local:session:<companion>:<harness>:<session> address.
Use the link for your coding agent in the feature table. Set up the agent before pairing. After pairing, keep the companion running. Ask an agent signed in as the owner to call targets(block="local"). Check that your session address appears.
SwB tries to deliver each message to the open session. It puts the message in the agent's mailbox when the sender can use that mailbox. The answer comes back in the same conversation.
Use the session address from targets. Find the resource for that address in visibility_list. Share the resource with visibility_set.
For commands and supported agents, see Local sessions.
Keep it running
Pairing starts the companion. Use swb companion run to start it again. Use swb companion status to see the local device ID and features.
Use uvx swb-one in place of swb to run these commands with uvx. For Muse, keep the package and Python options from the Muse guide.
The device starts each connection to SwB.
Disconnect
Run swb companion disconnect on the device to remove its key. To revoke the key in the console, open Connections in Settings. Select Disconnect for the device.
A running companion removes its local key when it detects the revocation. If a key remains on the device, run swb companion disconnect before pairing it again.