本文へスキップ

コンパニオン

このページは、エージェントが英語版から翻訳し、確認しました。Zhehan が読めるのは英語と中国語です。校正へのご協力をお待ちしています。 校正に協力する 翻訳の問題を報告する

コンパニオンとは、SwB サーバーに接続するデバイスです。接続すると、エージェントがそのデバイスの機能を使えます。

セットアップ用プロンプトをコピーする

Claude で開くChatGPT で開く
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.

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.

デバイスをペアリングする

オーナーとしてサインインしたエージェントに、companion_code の呼び出しを頼んでください。コードを権限 0600 のファイルに保存するよう、エージェントに頼んでください。この権限では、ファイルの所有者だけがアクセスできます。

コンソールでコードを取得するときは、パスキーでサインインしてください。Settings を開いてください。Connections で Pair a device を選択してください。Cloudflare Access を使っている場合は、companion_code ツールを使ってください。

デバイスでこのコマンドを実行してください。例のアドレスを、実際の SwB の HTTPS アドレスに置き換えてください。SwB が同じデバイスにある場合は、http://127.0.0.1:8870 も使えます。

uvx swb-one companion connect https://swb.example.com --cap notify

入力内容を隠すプロンプトに、ペアリングコードを入力してください。コードは 1 回だけ使えて、10 分で期限が切れます。監査ログには、コードを作った人が記録されます。

デバイスは、専用のキーを非公開のファイルに保存します。

機能を選ぶ

有効にする機能ごとに、--cap オプションを 1 つずつ追加してください。

オプション機能
--cap notifyデバイスにデスクトップ通知を表示します
--cap drop~/SwB Drop フォルダーで、1 つ 10 MiB までのファイルを共有します
--cap mcp --mcp NAME=COMMANDデバイス上の MCP サーバーのツールをエージェントが使えるようにします
--cap herdrHerdr
--cap codexCodex app server
--cap opencodeOpenCode server
--cap dshDeepSeek Harness
--cap hooksステータスフック
--cap museMac または Linux のパソコンで、Bluetooth を使って Muse とペアリングします

Linux では、通知に notify-send を使います。Debian と Ubuntu では、libnotify-bin パッケージでインストールしてください。

Muse ガジェットのペアリングには Python 3.13 を使ってください。Muse のペアリングガイドに従ってください。ペアリングのあとは、SwB サーバーが Muse との接続を保ちます。

uvx --python 3.13 --from 'swb-one[companion]' swb companion connect https://swb.example.com --cap muse

MCP サーバーごとに --mcp オプションを 1 つずつ追加してください。プログラムの場合は --mcp 'NAME=COMMAND' を使います。NAME をサーバーの名前に置き換えてください。COMMAND をプログラムの起動コマンドに置き換えてください。デバイス上の HTTP サーバーの場合は、--mcp notes=http://127.0.0.1:8000/mcp のようにローカルアドレスを使ってください。

エージェントは companion_list で、ペアリング済みの各デバイスとその操作を確認します。操作の実行には companion_invoke を使います。

コンパニオンのテキスト結果の上限は 1 MiB です。Drop のファイルデータは structuredContent.result.content_b64 から読み取ってください。

ローカルセッション

ローカルセッションとは、デバイス上でコーディングエージェントが開いている会話です。SwB は、そのセッションの状態を local:session:<companion>:<harness>:<session> というアドレスとともに一覧表示します。

機能の表にある、お使いのコーディングエージェントのリンクを使ってください。ペアリングの前にエージェントを設定してください。ペアリング後は、コンパニオンを動かし続けてください。オーナーとしてサインインしたエージェントに、targets(block="local") の呼び出しを頼んでください。セッションのアドレスが表示されることを確認してください。

SwB は、各メッセージを開いているセッションに届けようとします。送信者がエージェントのメールボックスを使える場合は、メッセージをそのメールボックスに入れます。回答は同じ会話に返ってきます。

targets に表示されるセッションのアドレスを使ってください。そのアドレスのリソースを visibility_list で探してください。visibility_set でそのリソースを共有してください。

コマンドと対応エージェントについては、ローカルセッションをご覧ください。

動かし続ける

ペアリングするとコンパニオンが起動します。もう一度起動するときは swb companion run を使います。ローカルのデバイス ID と機能は swb companion status で確認できます。

uvx でこれらのコマンドを実行するときは、swb の代わりに uvx swb-one を使ってください。Muse の場合は、Muse のガイドにあるパッケージと Python のオプションをそのまま使ってください。

SwB への接続は、毎回デバイスの側から始めます。

接続を解除する

デバイスのキーを削除するときは、そのデバイスで swb companion disconnect を実行してください。コンソールでキーを取り消すときは、Settings の Connections を開いてください。そのデバイスの Disconnect を選択してください。

動作中のコンパニオンは、取り消しを検出するとローカルのキーを削除します。デバイスにキーが残っている場合は、再びペアリングする前に swb companion disconnect を実行してください。

このページの内容