跳到内容

部署

在自己的电脑上运行

按安装中的步骤操作。

要更新已有部署,请参阅更新。

部署 SwB

把下面的提示词粘贴到 Claude Code、Codex 等编程智能体中。它会帮你完成 SwB 的设置。

Read the setup guide at https://swb.one/docs/deploy.

Help me run SwB. Use your terminal for commands you can run. Ask me to make choices and to take actions that need my account.

Send a `User-Agent` header that names your app in each HTTP request to SwB.

Ask me to choose where to run SwB. Offer this computer, Render, Railway, Fly.io, Koyeb or my server with Docker.

## This computer

For a source build, use **Build from source**. Install uv using the [official guide](https://docs.astral.sh/uv/getting-started/installation/). SwB needs Python 3.12 or later. The command below uses Python 3.12.

Choose an empty folder with me. Check that port 8870 is free. To choose another port, use a command such as `SWB_PORT=8871 uvx --python 3.12 swb.one up`.

If your terminal is on my SwB computer, run this in the chosen folder. Keep SwB running.

```bash
(umask 077; log=$(mktemp .swb-startup.XXXXXXXX) || exit
printf 'Private startup log: %s/%s\n' "$PWD" "$log"
uvx --python 3.12 swb.one up > "$log")
```

Use a fresh file for each start. Use file mode `0600` for each private link file. Use equivalent protection in other shells. Give me the file path.

Tell me how to read the link in my private terminal. Give me this command with the actual file path.

```bash
grep -F '/login#t=' '/path/to/.swb-startup.ABC12345'
```

If I start SwB in my terminal, give me the `uvx` command by itself. SwB prints the first link when it starts.

Ask me to open the `/login#t=` link within five minutes. Ask me to delete any private link file after sign-in.

For later sign-ins, ask me to use a passkey or get a fresh link. To get a link, run `uvx --python 3.12 swb.one login-link` from the same folder in another terminal. Save its output to a new private file. If I run the command, ask me to open the link there. Keep links out of chat and shared output.

Use `http://localhost:8870/mcp` with the chosen port.

## Build from source

Use the release branch for a source build. Run these commands on the computer you will use to build or deploy SwB.

```bash
git clone --branch release/1.0 https://github.com/ZhehanZhang/SwB.git
cd SwB
```

To run SwB on this computer, follow https://swb.one/docs/deploy#docker-compose. Start with the command that copies `.env.example`.

## Render and Railway

Read the deployment guide at https://github.com/ZhehanZhang/SwB/tree/release/1.0/deploy. Guide me through the Render Blueprint or Railway service setup. Use `release/1.0` as the source branch. Use one instance with one 1 GB volume at `/data`. On Render, use a Hobby workspace and the 512 MB service. On Railway, use the Hobby plan and set the variables from the guide, including a private `SWB_SETUP_CODE`. Ask me to copy `SWB_SETUP_CODE` from the service settings. Keep the code out of chat and logs.

## Fly.io, Koyeb and Docker

Run these commands in the `release/1.0` checkout.

For Fly.io, ask for an app name. Check the Fly CLI and Python 3.11 or later, or uv. Run `fly auth whoami`. If needed, run `fly auth login` and wait for me to sign in. Use my personal organization for the Fly.io Free plan. Run `sh deploy/fly.sh my-swb` with my app name. Stop if the script reports a resource outside the supported setup.

For Koyeb, ask for an app name. Check the Koyeb CLI and my sign-in. Run `sh deploy/koyeb.sh my-swb release/1.0` with my app name.

For my own server, ask for my domain. Ask me to point its DNS at the server. Ask me to open ports 80 and 443. Wait for me to confirm. Run `sh deploy/compose/start.sh swb.example.com` on the server with my domain.

Keep the setup code in its private file. Give me the file path. Fly.io uses `.env.swb-setup-fly-my-swb`. Koyeb uses `.env.swb-setup-koyeb-my-swb`. Docker uses `deploy/compose/.env`. Ask me to copy `SWB_SETUP_CODE` from that file.

## Sign in on a server

Wait for SwB to start. Give me the public URL and the sign-in page address from the log. Add `/mcp` to the public URL for the MCP address.

Ask me to paste the code into **Setup code** on the sign-in page. The code works once. Ask me to add a passkey to sign in again. For Fly.io or Koyeb, ask me to delete the private file after sign-in.

## Connect my first agent

Ask me where the app runs. To let the first agent set up other apps, give it owner access. For a local owner client, follow https://swb.one/prompts/mcp-client.md. For a coding agent, use https://swb.one/docs/setup/coding-agent.

For a hosted app, have me approve its OAuth sign-in to give it owner access. Use a public HTTPS address. If SwB is local, offer a [public address](https://swb.one/docs/first-run#get-a-public-address) or a hosted deployment. For Claude, use https://swb.one/prompts/claude.md. For ChatGPT, use https://swb.one/prompts/chatgpt.md. For Grok, use https://swb.one/prompts/grok.md.

Once the first app connects, ask me to paste https://swb.one/prompts/coordinator.md into that app. If it uses a paired key, have it give me the matching `swb connect` command for each owner-only connection.

If you keep your own memory, set up memory sync as described at https://swb.one/docs/memory.

在自己的服务器上运行

Docker Compose

安装 Docker Compose 2.24 或更高版本,用它在容器中运行 SwB。以数据目录所属的用户身份运行下面的命令。

git clone --branch release/1.0 https://github.com/ZhehanZhang/SwB.git
cd SwB
(umask 077; cp .env.example .env)
{
  printf 'SWB_UID=%s\n' "$(id -u)"
  printf 'SWB_KEY_OWNER='
  openssl rand -hex 32
} >> .env
printf 'SWB_PUBLIC_URL=http://localhost:8870\n' >> .env
mkdir -p data
docker compose up -d --build --wait
curl -fsS http://127.0.0.1:8870/healthz
docker compose exec -T switchboard swb login-link --url http://127.0.0.1:8000

如果是远程服务器,把它的 8870 端口转发到你电脑上的 8870 端口。在 5 分钟内打开这个一次性登录链接。妥善保管这个链接。

浏览器通过 http://localhost:8870 登录,容器内的命令使用 8000 端口。Compose 把数据保存在 ./data 中。修改 .env 后,运行 docker compose up -d。

匿名请求 /healthz 会返回 status 和 version。要查看完整的健康检查信息,使用所有者会话或所有者密钥。

Cloudflare Tunnel

隧道把你的服务器连接到 Cloudflare,并为 SwB 提供公网 HTTPS 地址。按 Cloudflare 中的步骤设置隧道。

在云端运行

只运行一个 SwB 实例,并在 /data 挂载一块磁盘。实例重启后,数据仍保存在这块磁盘上。各平台的模板和脚本见部署指南。

一键部署

Fly.io

使用 Docker Compose 示例中的 SwB 文件。安装 Python 3.11 或更高版本,或者安装 uv。安装 Fly.io 命令行工具,然后登录 Fly.io。

绑定一张支付卡后,Fly.io 免费套餐每月提供 5 美元的用量。在你的个人组织(personal organization)下使用这个套餐。5 美元用满后,Fly 按标准价格收取整月的费用。这套配置在 Ashburn 运行 30 天约需 3.84 美元,数据传输费用另计。

在 SwB 文件夹中运行 sh deploy/fly.sh my-swb,把 my-swb 换成一个唯一的应用名称。脚本用 fly deploy --ha=false 启动一台 Machine,再检查 Machine、卷和 IP 地址。

打开应用的登录页面。从 SwB 文件夹中的 .env.swb-setup-fly-my-swb 复制 SWB_SETUP_CODE,填入 Setup code。登录后删除这个文件。

计费详情见当前价格。

Render

打开 Render Blueprint。Blueprint 会创建一个付费 Web 服务和一块 1 GB 的磁盘。在服务中打开 Environment,复制 SWB_SETUP_CODE。

Railway

用 Railway 上的 SwB 模板部署。副本数保持为 1。在 /data 挂载一个 1 GB 的卷。

要让 SwB 始终运行,选用 Hobby 套餐。它每月 5 美元,包含 5 美元的用量。

免费套餐支持 0.5 GB 的卷,服务空闲时会休眠。这个套餐每月包含 1 美元的用量,大约够 SwB 持续占用 100 MB 内存。在一次测试中,空闲的 SwB 占用约 107 MiB 内存。

登录

在服务日志中找到登录地址并打开。从服务设置或部署命令指明的私有文件中复制 SWB_SETUP_CODE,粘贴到 Setup code。选择 Sign in。再添加一个通行密钥,供以后登录使用。

连接你的智能体

先把 SwB 连接到一个智能体。再把下面的提示词粘贴到这个智能体中,让它连接你的其他应用。

Read the setup guide at https://swb.one/docs/connect.

Help me connect my agents and channels to SwB.

Use the owner's SwB sign-in for setup that needs owner access. If you use a paired key, give me the matching `swb connect` command for my SwB instance folder. Keep private links and codes in my terminal.

Call `connect` with the app I want to add. Call `connect(what="unknown")` for the available names. Do each step marked "you" yourself. Give me each step marked "person" as it comes up. Include its button names and links. Ask me to enter credentials through the private claim links.

Call `connect` again with the same choices to check progress. When setup is complete, call `swb_guide(trigger="setup")`. Follow the install guidance in `skill_install` for this version of SwB.

Save these three lines as my agent's SwB instructions. Replace each placeholder with my agent name or SwB project slug.

```text
You are <agent>.
Your SwB project is <project>.
On every wake, call swb_guide and follow its guidance.
```

For a coordinator, offer the `swb-captain` skill if my app loads skills.

本页内容