Clawdbot Gateway 配置

Clawdbot AI 助手 Gateway 完整配置指南。了解配置選項、環境變數和進階設定。

Clawdbot Gateway 配置概覽

Clawdbot Gateway 通過 ~/.clawdbot/clawdbot.json 進行配置。本指南涵蓋所有用於自訂 Gateway 的配置選項。

配置檔案

位置

~/.clawdbot/clawdbot.json

基本結構

{
  "gateway": {
    "port": 3010,
    "host": "localhost"
  },
  "providers": {},
  "agents": {},
  "tools": {},
  "sessions": {}
}

Gateway 設定

核心設定

{
  "gateway": {
    "port": 3010,
    "host": "localhost",
    "logLevel": "info",
    "maxConnections": 100
  }
}

選項

選項預設值說明
port3010WebSocket 伺服器埠號
hostlocalhost綁定地址
logLevelinfo日誌詳細程度
maxConnections100最大並發連線數

服務提供者配置

WhatsApp

{
  "providers": {
    "whatsapp": {
      "enabled": true,
      "authStrategy": "qr",
      "dmPolicy": "main"
    }
  }
}

Telegram

{
  "providers": {
    "telegram": {
      "enabled": true,
      "token": "${TELEGRAM_BOT_TOKEN}"
    }
  }
}

Discord

{
  "providers": {
    "discord": {
      "enabled": true,
      "token": "${DISCORD_BOT_TOKEN}",
      "intents": ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES"]
    }
  }
}

代理配置

單一代理

{
  "agents": {
    "main": {
      "workspace": "~/.clawdbot/workspace",
      "model": "claude-3-sonnet"
    }
  }
}

多代理

{
  "agents": {
    "main": {
      "workspace": "~/.clawdbot/agents/main/workspace"
    },
    "work": {
      "workspace": "~/.clawdbot/agents/work/workspace"
    }
  }
}

會話配置

會話策略

{
  "sessions": {
    "dmScope": "main",
    "resetTime": "04:00",
    "idleMinutes": 60,
    "maxHistory": 100
  }
}

會話選項

選項預設值說明
dmScopemain私訊會話範圍
resetTime04:00每日重置時間
idleMinutesnull閒置逾時
maxHistory100歷史訊息最大數量

工具配置

工具策略

{
  "tools": {
    "profile": "full",
    "allow": ["*"],
    "deny": ["browser"]
  }
}

依服務提供者設定工具

{
  "tools": {
    "byProvider": {
      "whatsapp": {
        "deny": ["exec"]
      }
    }
  }
}

環境變數

使用環境變數

{
  "providers": {
    "telegram": {
      "token": "${TELEGRAM_BOT_TOKEN}"
    }
  }
}

常用變數

變數說明
CLAWDBOT_CONFIG配置檔案路徑
CLAWDBOT_LOG_LEVEL日誌等級覆蓋
CLAWDBOT_PORT埠號覆蓋

CLI 配置

覆蓋配置

clawdbot gateway start --port 3011 --log-level debug

配置命令

# 檢視目前配置
clawdbot config get

# 設定配置值
clawdbot config set gateway.port 3011

# 重置為預設值
clawdbot config reset

進階設定

效能

{
  "gateway": {
    "messageBuffer": 1000,
    "processTimeout": 30000,
    "streamChunkSize": 50
  }
}

限制

{
  "limits": {
    "maxMessageLength": 10000,
    "maxConcurrentRequests": 10,
    "rateLimitPerMinute": 60
  }
}

後續步驟