Skip to Content

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.

See Updating to update the macOS companion.

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.

Ask if I want the companion to start automatically. Use the foreground commands by default. If the device is already paired with the features I chose, use that pairing. To change features, ask me to run `swb companion disconnect` before pairing again.

For a new pairing, get a pairing code. If you can create a private file on my device, use an owner session. Call `companion_code` from that 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.

For SwB on this device, use its local address, such as `http://127.0.0.1:8870`. Use this command for a new foreground pairing. Include my SwB address and selected options. Before release, use `swb companion connect` from a source install.

```sh
uvx swb.one companion connect https://swb.example.com
```

For a new foreground pairing, ask me to run the pairing command on my device. Ask me to enter the code at the hidden prompt. Ask me to leave the command running. The foreground uses Python directly. For an existing foreground pairing, ask me to start the companion with `swb companion run` if needed. Use the same way of running `swb` as for pairing.

If I choose the background service, install SwB with `uv tool install swb.one` For a source build, use the installed source build. Follow the background section of the guide for my operating system. On macOS, the SwB release automatically installs and verifies the signed SwB Companion app when setting up the service. `launchd` uses that app to start the service.

For a new pairing with the service, use `swb companion connect https://swb.example.com --no-run` with my SwB address and selected options. Ask me to enter the code at the hidden prompt. For an existing pairing, reuse the device key. Ask me to stop any foreground run. Ask me to run `swb companion service install` with the installed `swb`. Check the connection with `swb companion status`.

Wait for me to confirm the companion is running. 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.

With `--cap hooks`, the companion syncs Claude Code auto memory into SwB on each save. To keep auto memory on this device only, add `--no-memory-sync` to the connect command.

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 notify

Enter 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.

OptionFeature
--cap notifyShows desktop notifications on the device
--cap dropShares files up to 10 MiB each through the ~/SwB Drop folder
--cap mcp --mcp NAME=COMMANDGives your agents access to tools on an MCP server on the device
--cap herdrHerdr
--cap codexCodex app server
--cap opencodeOpenCode server
--cap dshDeepSeek Harness
--cap hooksStatus hooks

On Linux, notifications use notify-send. On Debian and Ubuntu, install it with the libnotify-bin package.

Add 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.

SwB keeps grants for the features the companion still offers. New features wait for the owner's approval.

Use companion_list or switchboard_status to see pending features. Use companion_grant from the owner session to grant the selected IDs.

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.

If you paired with uvx, use uvx swb.one in place of swb. In the foreground, the companion runs directly in Python.

The device starts each connection to SwB.

Run in the background

Install a background service to start the companion automatically. Install SwB with uv tool install swb.one.

For a new pairing, run swb companion connect with your pairing options and add --no-run. This pairs the device and exits. If the companion is running in your terminal, stop it before you install the service. Use the installed swb for the service commands.

swb companion service install

On Linux, systemd --user runs the service under your account. Run loginctl enable-linger "$USER" to start at boot and keep running after sign-out.

On macOS, install the service from your desktop session. The SwB release automatically installs and verifies the signed SwB Companion app in ~/Applications. launchd uses the app to start the service.

On Windows, Task Scheduler starts the service when you sign in.

Set the variables your local tools need in your service manager.

Use swb companion service start to start the service. Use swb companion service status to check the service. Use swb companion service logs to read its logs.

Use swb companion status to check the connection, the SwB address and whether the companion is running.

Use swb companion service stop to stop the service now. Use swb companion service uninstall to remove automatic starts. This keeps the device key.

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.

On this page