Files
KingClawArmy/docs/guides/guide_openclaw_config.md
Chris edc1036435 docs: 重整文件結構,移除 v2/v3 舊文檔,新增實作指南
- 刪除 v2/v3 所有舊規格文件
- 將 v4 規格文件移至 spec/ 目錄
- 新增 guides/ 目錄,包含:
  - guide_openclaw_config.md:openclaw.json 設定、Discord 接入、Gateway 管理
  - guide_workspace_files.md:8 個 Workspace 設定檔正確用途
  - guide_sessions_tools.md:sessions_spawn/send 參數與 Agents vs Sub-agent run 說明
- 更新 spec_v4_rollout_and_risks.md:加入 Phase 0/1 實際進度
- 新增 INDEX.md 文件索引

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 07:23:17 +00:00

3.1 KiB
Raw Blame History

OpenClaw 實際設定指南

適用版本OpenClaw v2026.4.x
更新日期2026-04-09


openclaw.json 結構

設定檔位置:~/.openclaw/openclaw.json

{
  "agents": {
    "defaults": {
      "workspace": "~/.openclaw/workspace",
      "model": { "primary": "openai-codex/gpt-5.4-mini" }
    },
    "list": [
      {
        "id": "main"
      },
      {
        "id": "ceo_coo",
        "name": "ceo_coo",
        "workspace": "~/.openclaw/workspaces/ceo_coo",
        "agentDir": "~/.openclaw/agents/ceo_coo/agent",
        "model": "openai-codex/gpt-5.4"
      }
    ]
  },
  "channels": {
    "discord": {
      "enabled": true,
      "token": "<BOT_TOKEN>",
      "guilds": {
        "<GUILD_ID>": {
          "channels": {
            "<CHANNEL_ID>": {}
          }
        }
      }
    }
  },
  "bindings": [
    {
      "type": "route",
      "agentId": "ceo_coo",
      "match": {
        "channel": "discord",
        "peer": {
          "kind": "channel",
          "id": "<CHANNEL_ID>"
        }
      }
    }
  ]
}

新增 Agent

openclaw agents add <agent_id> \
  --workspace ~/.openclaw/workspaces/<agent_id> \
  --model <model_id> \
  --non-interactive

Discord 設定

1. 接入 Discord Bot

openclaw channels add --channel discord --token <BOT_TOKEN>

2. Discord Developer Portal 必開設定

Bot → Privileged Gateway Intents

  • Message Content Intent
  • Server Members Intent

3. 設定 Guild 頻道白名單

openclaw.jsonchannels.discord.guilds 下新增:

"guilds": {
  "<GUILD_ID>": {
    "channels": {
      "<CHANNEL_ID>": {}
    }
  }
}

4. 設定 Agent 路由 Binding

"bindings": [
  {
    "type": "route",
    "agentId": "<agent_id>",
    "match": {
      "channel": "discord",
      "peer": {
        "kind": "channel",
        "id": "<CHANNEL_ID>"
      }
    }
  }
]

5. 授權 Discord 用戶

Bot 初次收到 DM 時會顯示 pairing code

openclaw pairing approve discord <PAIRING_CODE>

Gateway 管理

Gateway 以 systemd user service 常駐:

# 啟動
systemctl --user start openclaw-gateway.service

# 重啟
systemctl --user restart openclaw-gateway.service

# 狀態
systemctl --user status openclaw-gateway.service

# 查 log
journalctl --user -u openclaw-gateway.service -f

設定異動通常不需重啟(熱重載)。
以下異動需要重啟Discord token、Channel 設定、Plugin 設定。


常用指令

# 查 agent 清單與路由
openclaw agents list --json

# 查 channel 連線狀態
openclaw channels status --probe

# 查 binding 清單
openclaw agents bindings

# 設定 agent 路由
openclaw agents bind --agent <id> --bind "discord:<channel_id>"

# 移除 binding
openclaw agents unbind --agent <id> --all

King Claw 實際設定

項目
Guild ID 1486353934594342924
#總機 Channel ID 1486739757957644319
CEO Agent ID ceo_coo
CEO 模型 openai-codex/gpt-5.4
預設模型 openai-codex/gpt-5.4-mini