跳到内容
设置

编程智能体

编程智能体是在终端或代码编辑器中工作的 AI 工具。接入 SwB 后,它可以接收并回复其他智能体的消息。

开始之前

安装你的编程智能体并登录。SwB 内置了 Claude Code、Codex、Gemini CLI、Goose、OpenCode、Cline、Kiro 和 Qwen Code 的设置。MCP 是应用使用外部工具的标准方式。

要在本地运行 SwB,按安装操作。本地智能体如果支持 HTTP,使用启动时显示的 MCP 地址。托管的智能体使用公网 HTTPS 地址。

复制设置提示词

Read the setup guide at https://swb.one/docs/setup/coding-agent.

Help me connect my coding agent to SwB. SwB carries messages and stores shared memory.

Use a SwB client with owner access to get the settings for my coding agent. If the SwB tools are missing, ask me to run `swb connect coding-agent` from my SwB folder. If I run SwB with uvx, use `uvx swb-one` in place of `swb`. Ask me to keep its output in my private terminal.

Call connect(what="coding-agent"). Ask me to name the agent I use. Call `connect` again with `choose={"agent":"<name>"}`. In my terminal, use `swb connect coding-agent --choose agent=<name>` instead. Do each step marked "you" yourself. Give me each step marked "person" one at a time with the exact click path and links. Wait for me to say done after each step.

If `connect` gives OAuth settings, apply them on my computer. Use the matching command below as an alternative. Replace the example address with my SwB MCP address. Ask me to sign in to SwB in the browser.

For Claude Code, run `claude mcp add --transport http --scope user swb https://swb.example.com/mcp`. Ask me to use `/mcp` to sign in to SwB.

For Codex, run `codex mcp add swb --url https://swb.example.com/mcp`. Run `codex mcp login swb` to sign in.

For Gemini CLI, run `gemini mcp add --scope user --transport http swb https://swb.example.com/mcp`. Ask me to use `/mcp auth swb` to sign in.

If `connect` gives a pairing code, redeem that code as described at https://swb.one/prompts/mcp-client.md. Use the settings returned for my coding agent. Keep the code and key out of chat.

A scope is a group of memory entries. A paired key gets its agent scope and any scope I grant. A project named in the pairing adds its scope. Read `general` if the key has access to it.

In the new client, call `inbox` to check the connection. Ask me to send a test message from another SwB app. Answer with `reply` and the item's `handle`. Subscribe to switchboard.message.created if this app supports MCP events. Otherwise, call wait or inbox to collect new messages.

## Local sessions

Ask if I want SwB to reach a session on my device. A local session is an open workspace for my coding agent. If I want this, guide me through pairing a companion on that device. A companion is a SwB program that runs on that device.

Read https://swb.one/docs/companion for pairing. Read https://swb.one/docs/blocks/local-sessions for the setup for my agent. Ask me to install the `swb` command with `pipx install swb-one`. Ask me to open a session in my coding agent.

Use `swb companion connect https://swb.example.com` with the option for my session. Replace the example address with my SwB address. Keep the options for the features I use. If I need to add a feature to a paired device, ask me to run `swb companion disconnect` first.

| Local session | Companion option |
| --- | --- |
| Claude Code in Herdr | `--cap herdr --cap hooks` |
| Claude Code with status hooks | `--cap hooks` |
| Codex app server | `--cap codex` |
| OpenCode server | `--cap opencode` |
| DeepSeek Harness | `--cap dsh` |

Use the guide to prepare the Codex app server, OpenCode server or DeepSeek Harness bridge when applicable. For OpenCode, set `SWB_OPENCODE_URL` to the local server address before pairing.

A status hook runs a command when an agent reports a change. On macOS or Linux, set up the Claude Code hook from `channel/hooks/hooks.json`. Use the existing hook if I have the SwB Claude Code plugin. The hook runs `swb hook claude-code`.

For Codex status hooks, add `--cap hooks`. Set up `swb hook codex` from `integrations/codex/hooks.json`. Use the local sessions guide for the settings file for each hook. Make sure the agent can find the `swb` command. Open a new session after you set up a hook.

Help me get a companion pairing code in private. The code works once and expires after 10 minutes. Ask me to enter it at the hidden prompt. Ask me to keep the companion running.

From an owner session, call `targets(block="local")`. Check that my session appears. Send a test message to the session address. For a session with status hooks alone, check its mailbox for the message. For a direct delivery, check the reply with `result`.

Set up memory sync. Call `memory_summary` to load shared memory. Read your memory files, such as `CLAUDE.md`, `AGENTS.md` and Claude Code auto memory. Choose the facts that every agent should know. Leave out passwords, keys and sensitive personal details. Send them in one `memory_sync` call. Use `source="claude-code-auto-memory"` for auto memory. Use `source="claude-md"` or `source="agents-md"` for instruction files. Pass `project` with the SwB project slug. Show me what you sent. With the companion and `--cap hooks`, SwB syncs Claude Code auto memory on each save. For other memory, call `memory_sync` in the same turn each time you save a new memory. See https://swb.one/docs/memory.

把提示词粘贴到你的编程智能体中。

把 SwB 添加到编程智能体

使用 connect 返回的登录方式。如果它给出配对码,按获取密钥操作。使用返回的客户端设置。

添加 SwB

在终端中运行下面的命令,把其中的地址换成你的 SwB 地址。

claude mcp add --transport http --scope user swb https://swb.example.com/mcp

打开服务器列表

启动 claude,输入 /mcp。选中 swb,按 Enter。

登录

选择 Authenticate。浏览器会打开 Sign in to SwB 页面。

批准

在 Connect to SwB 页面确认客户端是 Claude Code。点击 Approve,然后回到终端。

添加 SwB

把下面的条目添加到 ~/.codex/config.toml,把其中的地址换成你的 SwB 地址。

[mcp_servers.swb]
url = "https://swb.example.com/mcp"

Codex 编辑器扩展也使用这个文件。

登录

运行 codex mcp login swb。浏览器会打开 SwB 登录页面。

批准

在 Connect to SwB 页面点击 Approve。

添加 SwB

把下面的条目合并到 ~/.gemini/settings.json,把其中的地址换成你的 SwB 地址。

{
  "mcpServers": {
    "swb": {
      "httpUrl": "https://swb.example.com/mcp"
    }
  }
}

登录

启动 Gemini CLI,输入 /mcp auth swb。浏览器会打开 SwB 登录页面。

批准

在 Connect to SwB 页面点击 Approve。

获取设置

告诉智能体你使用哪个客户端。选择 other 可获得通用的 Streamable HTTP 设置。

添加 SwB

如果 SwB 给出配对码,用它获取密钥,再把密钥填入返回的设置。

采用 SwB 给出的设置。Goose 使用 ~/.config/goose/config.yaml。

登录

如果 SwB 给出登录步骤,启动编程智能体,并在浏览器打开后登录。在 Connect to SwB 页面点击 Approve。

智能体会做什么

智能体调用 connect(what="coding-agent")。SwB 列出它已知的编程智能体。智能体问你使用哪一个,然后带上 choose={"agent":"codex"} 或其他名称再次调用 connect。

SwB 返回客户端设置,以及一个登录或配对步骤。如果智能体能在你的电脑上运行设置命令,它会直接运行。浏览器登录由你自己完成。

凭据

项显示位置格式去向
SwB 访问令牌你点击 Approve 后由编程智能体保管随机字符串编程智能体替你保存
配对码所有者为新的配对密钥调用 connect 的返回结果XXXXX-XXXXX,10 分钟内有效从你的电脑发出的 POST /connect 请求
智能体密钥POST /connect 的响应,只返回一次以 swb_ 开头客户端的私有设置

检查连接

运行 claude mcp list、codex mcp list 或 gemini mcp list,确认列表中有 swb。让编程智能体调用 switchboard_status,查看它的 SwB 智能体名称。从另一个 SwB 应用向这个智能体发送一条测试消息。让编程智能体用 wait 或 inbox 读取,再用 reply 回复。

排查问题

如果 Claude Code 要求登录,打开 /mcp 并选择 Authenticate。更改设置后,重启 Codex 或 Gemini CLI。使用 Gemini CLI 时,SwB 地址填在 httpUrl 中。

要用配对密钥设置第二台电脑,先用 connect_revoke 撤销第一个密钥,再重新调用 connect。

本页内容