에이전트 도구
이 페이지는 에이전트가 영어 원문을 번역하고 검토했습니다. Zhehan은 영어와 중국어를 읽습니다. 교정을 도와주시면 감사하겠습니다. 교정 돕기 번역 문제 신고
설정 프롬프트 복사
Read the setup guide at https://swb.one/docs/setup/agent-tool.
Help me connect my agent tool to SwB.
SwB carries messages and stores shared memory.
Ask me which chat apps already reach my agent.
Tell me that my existing chat connections stay the same.
Keep the existing Telegram bot settings.
Keep the existing WeChat ClawBot settings and binding.
Use one active receiver per Telegram bot token.
Run one WeChat ClawBot instance per binding.
Pair my agent with SwB over MCP as a separate connection.
Use MCP Events or a local webhook for notices about new messages.
If I want a direct Telegram connection to SwB, use a separate bot with a new token.
Use the Telegram setup guide at https://swb.one/docs/setup/telegram.
Ask me to choose a name for the agent.
Use up to 40 lowercase letters, digits and dashes.
Start with a letter or digit.
Use my chosen name in place of `my-tool`.
Use a SwB client with owner access for setup.
Call `connect(what="agent-tool", choose={"agent":"my-tool"})`.
Alternatively, run this command in my SwB folder.
```sh
swb connect agent-tool --choose agent=my-tool
```
Keep the existing key if the client already has one.
If SwB returns a pairing code, redeem it in a private terminal within ten minutes.
Use `POST /connect`.
Send `{"code":"<pairing code>"}` in the request body.
Send a `User-Agent` header that names the app on each HTTP request to SwB.
Read the response in memory.
Add a server named `swb` in the client settings.
Use `mcp_url` as the Streamable HTTP address.
Streamable HTTP lets the app call SwB tools over the network.
Use the returned `key` in the `Authorization: Bearer <key>` header.
Store the key in the app's private settings.
Keep credentials private.
## Messages
Use MCP to read messages, send replies and share memory.
Use `wait` or `inbox` to read messages from an open conversation.
## Personal agents
MCP Events sends a notice when a message arrives.
Call `events/list` to see the events SwB offers.
Use `events/subscribe` for `switchboard.message.created` with `mailbox_id` set to my agent name.
Use webhook delivery with a public HTTPS callback address.
A callback is the address that receives notices.
Use a secret with the prefix `whsec_` and a base64 value that decodes to 24 to 64 bytes.
Use the same secret to verify Standard Webhooks signatures at the callback.
Read the message with `get_message`.
Answer with `reply` and the conversation handle.
For a local webhook, pair the companion with the webhook feature.
A webhook receives messages at a web address.
Save the webhook configuration in `~/.config/swb/webhook/my-tool.json`.
Use my chosen agent name in the file name and the `name` field.
Set the required `key_env` field to a `SWB_KEY_<NAME>` variable.
Save my agent's paired SwB key in that variable on the companion device.
The companion uses this key to register the delivery route with SwB.
Use a loopback address or an address on a private or shared network.
A loopback address reaches the same device.
A shared address is in the `100.64.0.0/10` range.
Use a separate receiver secret to sign messages or send a bearer token.
Give the receiver and the companion the same receiver secret.
On the companion device, save it in the variable named in `secret_env`.
For `standard-webhooks`, use the same secret format as for MCP Events.
For a receiver that expects a bearer token, set `auth` to `bearer`.
For bearer tokens, use an HTTP loopback address or an HTTPS address.
```sh
swb companion connect https://swb.example.com --cap webhook
```
```json
{"name":"my-tool","url":"http://127.0.0.1:8644/webhooks/swb","auth":"standard-webhooks","key_env":"SWB_KEY_MY_TOOL","secret_env":"SWB_WEBHOOK_MY_TOOL"}
```
Use the handle from the webhook to answer with `reply`.
Call `inbox` when the agent starts.
The mailbox keeps messages if webhook delivery fails.
Use one delivery method per mailbox.
## Status hooks
Use a status hook if the tool can run a command when a session changes.
Use the same agent name in the command and in MCP.
Pair the device with a companion if I want to use status hooks or a driver.
A companion is a SwB program that connects this device to my SwB server.
Install the `swb` command with `pipx install swb.one`.
Use `companion_code` from the owner client.
Enter the code at the companion's hidden prompt.
Replace the example address with my SwB address.
Add one option for each feature I use.
```sh
swb companion connect https://swb.example.com --cap hooks --cap ade
```
Send one JSON object to `swb hook <name>` on standard input.
Use the session ID from the tool.
Use the folder and label from the session.
Set `event` to `start`, `working`, `blocked`, `idle`, `done` or `ended`.
Include `text` for the answer on a `done` event.
```json
{"event":"done","session":"session-1","name":"My session","dir":"/path/to/project","text":"Test complete"}
```
If a plugin can deliver messages to the session, read wakes from `swb hook <name> --wakes <session>`.
A wake is a message for an open session.
Read one JSON object per line.
Use the tool's supported interface to deliver the `text` to the session.
## CLI session driver
Use a driver if the tool has commands to list and message open sessions.
A driver is a file that maps SwB operations to commands from the tool.
Use Linux or macOS for a custom driver.
Save the driver as a JSON file in `~/.config/swb/ade/`.
Use `$XDG_CONFIG_HOME/swb/ade/` if that environment variable is set.
The account that runs the companion must own the folder and file.
Set `name` to the same agent name.
Set `available`, `list` and `send` to the tool's commands.
Use `argv` to list each command and its arguments separately.
Use JSON output for the session list and reply.
Map the session ID, label, folder and state from the list response.
In `send`, use `{session}` as a separate argument for the session ID.
Use `"stdin": "text"` or put `{text}` immediately after a separate `--` argument.
Use `check` to confirm a session is idle before sending.
Use `wait` and `read` when the tool returns its reply from a separate command.
Use only the tool's documented commands.
Use this example for the structure.
Replace the example commands and JSON fields with those of my tool.
```json
{
"name": "my-tool",
"available": {"argv": ["my-tool", "status", "--json"]},
"list": {
"argv": ["my-tool", "sessions", "--json"],
"sessions": "sessions",
"id": "id",
"name": "label",
"dir": "folder",
"state": "status",
"states": {"ready": "idle", "running": "working", "approval": "blocked"}
},
"check": {
"argv": ["my-tool", "sessions", "show", "{session}", "--json"],
"expect": {"id": "{session}", "status": "ready"}
},
"send": {
"argv": ["my-tool", "sessions", "send", "{session}", "--json", "--", "{text}"],
"reply": "answer"
}
}
```
Replace `my-tool` with my agent name in the file name.
Set these permissions for new and existing manifests before you call `targets`.
The folder needs mode `0700`. The file needs mode `0600`.
```sh
chmod 00700 "${XDG_CONFIG_HOME:-$HOME/.config}/swb/ade"
chmod 0600 "${XDG_CONFIG_HOME:-$HOME/.config}/swb/ade/my-tool.json"
```
Call `targets(block="local")` from the owner client.
Send a test message to the session address returned by `targets`.
Read the answer with `result` and the conversation from `send`.
## Check the connection
Call `inbox` from the paired client.
Call `swb_guide(trigger="setup")` from the same client.
From the owner client, use `send` to send a test message to `agent:my-tool`.
Replace `my-tool` with my chosen name.
Read it with `inbox` from the paired client.
Answer with `reply` and the item's handle.
Read the answer from the owner client with `result` and the conversation from `send`.
Call `memory_summary` from the paired client.
Read the tool's shared notes, such as `AGENTS.md`.
Select facts to share.
Keep credentials and private details on the device.
Use `memory_sync` with `source="agents-md"`.
Give each fact a stable `source_key`.
Use the project slug for project memory.이 프롬프트를 SwB 소유자 에이전트에 붙여 넣으세요.
MCP는 앱이 외부 도구를 쓰는 방식입니다. SwB에서 쓸 짧은 에이전트 이름을 정하세요. 소유자 권한이 있는 에이전트에게 다음과 같이 connect를 호출하도록 요청하세요.
connect(what="agent-tool", choose={"agent":"example-agent"})이름에는 영문 소문자와 숫자, 하이픈을 최대 40자까지 쓸 수 있습니다. 첫 글자로 영문 소문자나 숫자를 쓰세요.
페어링 코드를 받으면 에이전트 키를 받으세요. 이 키를 받으면 같은 이름의 세션에 메시지를 보낼 수 있습니다.
SwB이 돌려준 설정을 앱에 추가하세요. 키는 앱의 비공개 설정에 저장하세요. SwB은 지정한 이름으로 에이전트를 표시합니다.
다른 SwB 앱에서 테스트 메시지를 보내세요. 연결한 앱에서 inbox를 호출하세요. 받은 handle로 reply를 호출해 답장하세요.
앱이 네트워크를 통해 메시지를 받으려면 받은편지함 이벤트 스트림을 사용하세요.
개인 에이전트
MCP Events는 메시지가 도착하면 알림을 보냅니다. 콜백은 알림을 받는 주소입니다.
events/list로 이벤트를 확인하세요. events/subscribe로 switchboard.message.created를 구독하세요. mailbox_id에 페어링할 때 쓴 에이전트 이름을 지정하세요.
웹훅 전달에는 공개 HTTPS 콜백 주소를 사용하세요. 시크릿에는 whsec_로 시작하는 base64 값을 사용하세요. base64 부분을 디코딩하면 24~64바이트가 되어야 합니다. 수신 앱에서 같은 시크릿으로 Standard Webhooks 서명을 확인하세요.
알림의 message_id를 get_message에 넘겨 메시지를 읽으세요. 대화 ID를 사용해 reply로 답장하세요.
같은 기기나 비공개 네트워크에서 받으려면 로컬 웹훅을 사용하세요.
swb companion connect https://swb.example.com --cap webhook전달 경로를 승인할 때는 페어링한 에이전트의 SwB 키를 사용하세요. 이 키를 저장하는 SWB_KEY_<NAME> 형식의 변수 이름을 key_env에 넣으세요. 서명이나 Bearer 토큰에는 별도의 수신용 시크릿을 사용하세요.
우편함마다 전달 방식 하나를 선택하세요.
기존 채팅 연결 유지
에이전트에 이미 연결된 채팅 앱을 설정 에이전트에게 알려 주세요.
기존 Telegram 봇의 설정을 유지하세요. 기존 WeChat ClawBot의 설정과 연결을 유지하세요. Telegram 봇 토큰마다 수신 프로그램을 하나만 실행하세요. 연결마다 WeChat ClawBot 인스턴스를 하나만 실행하세요.
기존 연결과 별도로 MCP를 통해 에이전트를 SwB에 페어링하세요. 새 메시지 알림에는 MCP Events나 로컬 웹훅을 사용하세요. Telegram을 SwB에 직접 연결하려면 새 토큰으로 별도 봇을 설정하세요.
드라이버 설정 파일
드라이버 설정을 JSON 파일로 저장하세요. 저장 위치는 $XDG_CONFIG_HOME/swb/ade/입니다. 기본 위치는 ~/.config/swb/ade/입니다.
사용자 드라이버는 Linux나 macOS에서 사용하세요. 컴패니언을 실행하는 계정이 폴더와 파일을 소유해야 합니다. example-agent를 에이전트 이름으로 바꾸세요. 폴더의 권한은 0700입니다. 파일의 권한은 0600입니다. 기존 설정 파일에도 같은 권한을 적용하세요.
chmod 00700 "${XDG_CONFIG_HOME:-$HOME/.config}/swb/ade"
chmod 0600 "${XDG_CONFIG_HOME:-$HOME/.config}/swb/ade/example-agent.json"| 항목 | 용도 |
|---|---|
name | SwB에서 쓰는 에이전트 이름 |
available | 도구를 실행할 수 있는지 확인하는 명령 |
list | 세션 목록을 가져오는 명령과 출력에서 이름과 상태를 읽을 위치 |
check | 전송 전에 세션 상태를 확인하는 명령 |
send | 세션에 메시지를 전달하는 명령 |
wait, read | 작업이 끝날 때까지 기다리고 답장을 읽는 명령 |
sessions에 배열의 위치를 적으세요. 출력 자체가 배열이면 빈 문자열을 쓰세요. id, name, dir, state에 각 항목의 위치를 적으세요. states에서 도구의 상태를 SwB 상태와 연결하세요.
argv 배열의 첫 항목에 실행할 명령을 넣으세요. 나머지 항목에는 인수를 하나씩 넣으세요. send에서 {session}을 인수 하나로 넣으세요. {text}는 -- 인수 바로 뒤에 놓으세요. 또는 "stdin": "text"를 지정해 표준 입력으로 메시지를 전달하세요.
다음은 Paseo에 메시지를 보내는 명령의 예입니다.
{
"send": {
"argv": ["paseo", "send", "{session}", "--no-wait", "--json", "--", "{text}"],
"expect": {
"agentId": "{session}",
"status": "sent"
}
}
}전송 명령의 출력에서 답장을 읽으려면 send.reply를 쓰세요. 별도의 명령으로 답장을 읽으려면 read.reply를 쓰세요.
기본 드라이버 예제도 참고하세요.
드라이버를 쓸 기기에서 컴패니언을 시작하세요. 예시 주소를 내 SwB 주소로 바꾸세요.
swb companion connect https://swb.example.com --cap ade상태 훅
훅은 세션 상태가 바뀔 때 실행하는 명령입니다. --cap hooks로 컴패니언을 시작하세요. 앱에서 swb hook <name>을 호출하고 표준 입력에 JSON 이벤트 하나를 전달하세요. <name>은 SwB에서 쓰는 에이전트 이름입니다.
swb companion connect https://swb.example.com --cap hooks한 세션에서 보내는 모든 이벤트에 같은 session을 쓰세요.
{"event":"start","session":"example-session","name":"Example session","dir":"/path/to/workspace"}event에는 start, working, blocked, idle, done, ended 중 하나를 쓰세요. done일 때는 text로 답장을 전달하세요.
열린 세션마다 swb hook <name> --wakes <session>을 실행하세요. 이 명령은 메시지마다 text와 conversation을 JSON 한 줄로 출력합니다. 앱의 API로 그 텍스트를 세션에 전달하세요. 세션이 스트림을 열기 전에는 메시지가 에이전트의 편지함에 남습니다.