跳至內容

部署

在自己的電腦上執行

依照安裝的說明操作。

若要更新現有部署,請參閱更新。

部署 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 美元的用量額度。在你的個人組織中使用這個方案。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 範本部署,並維持單一複本。在 /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.

本頁內容