龙虾工作室
xxxxxxxxxx┌─────────────────────────────────────────────────────────────────┐│ OpenClaw 系统架构 │├─────────────────────────────────────────────────────────────────┤│ 渠道层 → 网关层 → 代理层 → 能力层 ││ Channels Gateway Agents Skills/Tools/Models/Memory │└─────────────────────────────────────────────────────────────────┘
| 组件 | 说明 | 默认端口 | 配置文件 |
|---|---|---|---|
| Gateway | WebSocket 网关,核心调度 | 18789 | ~/.openclaw/openclaw.json |
| Dashboard | Web 控制界面 | 18789 (同网关) | - |
| Agents | AI 代理实例 | - | ~/.openclaw/agents/ |
| Skills | 功能技能包 | - | ~/.openclaw/skills/ |
| Tools | 工具调用策略 | - | openclaw.json |
| Soul | 人格/提示词配置 | - | SOUL.md |
| Memory | 长期记忆存储 | - | ~/.openclaw/memory/ |
xxxxxxxxxx# 前台启动(调试用)openclaw gateway --port 18789
# 后台守护进程启动openclaw gateway --port 18789 --daemon
# 强制启动(清理占用端口的进程)openclaw gateway --port 18789 --force
# 安装为系统服务openclaw gateway install
# 服务状态管理openclaw gateway statusopenclaw gateway restartopenclaw gateway stopopenclaw gateway uninstallxxxxxxxxxx# 设置网关端口openclaw config set gateway.port 18789
# 设置绑定模式(国内建议)openclaw config set gateway.bind "loopback" # 仅本地访问(最安全)openclaw config set gateway.bind "lan" # 局域网访问openclaw config set gateway.bind "tailnet" # Tailscale 组网
# 配置认证令牌(必须设置)openclaw config set gateway.auth.mode "token"openclaw config set gateway.auth.token "$(openssl rand -hex 32)"
# 配置热重载模式openclaw config set gateway.reload.mode "hybrid"xxxxxxxxxx# 查看网关状态openclaw gateway statusopenclaw gateway status --deepopenclaw gateway status --json
# 健康检查openclaw gateway healthopenclaw gateway probe
# 实时日志openclaw logs --followopenclaw logs --limit 200 --plain
# 运行诊断openclaw doctoropenclaw doctor --deepopenclaw doctor --fixxxxxxxxxxx{ "gateway": { "port": 18789, "bind": "loopback", "auth": { "mode": "token", "token": "${OPENCLAW_GATEWAY_TOKEN}" }, "reload": { "mode": "hybrid" }, "tailscale": { "mode": "off" } }}| 访问方式 | 命令/配置 | 适用场景 |
|---|---|---|
| 本地访问 | http://127.0.0.1:18789 | 个人单机部署 |
| 局域网访问 | http://<服务器 IP>:18789 | 团队内部使用 |
| SSH 隧道 | ssh -L 18789:127.0.0.1:18789 user@host | 远程安全访问 |
| Tailscale | 启用 Tailscale Serve | 跨网络组网 |
xxxxxxxxxx# 启动 Dashboard(与网关同进程)openclaw gateway --port 18789
# 配置 Dashboard 访问令牌openclaw config set dashboard.auth.token "${OPENCLAW_GATEWAY_TOKEN}"
# 配置 Dashboard 只读模式(展示屏)openclaw config set dashboard.readonly true
# 配置 Dashboard 语言openclaw config set dashboard.locale "zh-CN"| 模块 | 功能 | 访问路径 |
|---|---|---|
| 聊天界面 | 与代理直接对话 | /chat |
| 配置管理 | 修改系统配置 | /settings |
| 会话管理 | 查看/管理会话 | /sessions |
| 渠道管理 | 渠道状态监控 | /channels |
| 代理管理 | 代理配置与绑定 | /agents |
| 模型管理 | 模型切换与监控 | /models |
| 技能管理 | 技能安装与启用 | /skills |
| 日志查看 | 系统日志浏览 | /logs |
| 监控面板 | 资源使用监控 | /metrics |
xxxxxxxxxx# 启用访问令牌验证openclaw config set gateway.auth.mode "token"
# 配置 IP 白名单(可选)openclaw config set gateway.allowedIps '["192.168.1.0/24", "10.0.0.0/8"]'
# 禁用 mDNS 发现(生产环境)openclaw config set discovery.mdns.mode "off"
# 启用日志脱敏openclaw config set logging.redactSensitive "tools"| 提供商 | 模型示例 | API 地址 | 认证方式 | 国内可用性 |
|---|---|---|---|---|
| DeepSeek | deepseek-chat | api.deepseek.com | API Key | ✅ 优秀 |
| 阿里云百炼 | qwen-max | dashscope.aliyuncs.com | API Key | ✅ 优秀 |
| 智谱 AI | glm-4 | open.bigmodel.cn | API Key | ✅ 优秀 |
| 月之暗面 | kimi-chat | api.moonshot.cn | API Key | ✅ 优秀 |
| MiniMax | minimax-lightning | api.minimax.chat | API Key | ✅ 良好 |
| 百度文心 | ernie-bot | api.baidu.com | API Key | ✅ 良好 |
| Ollama 本地 | qwen2.5:7b | localhost:11434 | 本地连接 | ✅ 最佳 |
| OpenAI | gpt-4o | api.openai.com | API Key | ⚠️ 需代理 |
| Anthropic | claude-3.5 | api.anthropic.com | API Key | ⚠️ 需代理 |
xxxxxxxxxx# 设置默认模型(国内推荐)openclaw models set deepseek/deepseek-chatopenclaw models set bailian/qwen-maxopenclaw models set zhipu/glm-4openclaw models set moonshot/kimi-chat
# 设置图像模型openclaw models set-image bailian/qwen-vl-max
# 查看模型状态openclaw models statusopenclaw models status --probeopenclaw models status --json
# 列出可用模型openclaw models listopenclaw models list --provider deepseek
# 配置模型回退(主模型失败时自动切换)openclaw models fallbacks add zhipu/glm-4openclaw models fallbacks add moonshot/kimi-chatopenclaw models fallbacks list
# 配置模型别名openclaw models aliases add fast-model deepseek/deepseek-chatopenclaw models aliases add code-model zhipu/glm-4-flashopenclaw models aliases listxxxxxxxxxx# 设置 DeepSeek API Keyopenclaw models auth setup-token --provider deepseek# 或手动配置openclaw config set models.providers.deepseek.apiKey "${DEEPSEEK_API_KEY}"
# 设置阿里云百炼 API Keyopenclaw models auth setup-token --provider bailianopenclaw config set models.providers.bailian.apiKey "${DASHSCOPE_API_KEY}"
# 设置智谱 AI API Keyopenclaw models auth setup-token --provider zhipuopenclaw config set models.providers.zhipu.apiKey "${ZHIPU_API_KEY}"
# 设置月之暗面 API Keyopenclaw models auth setup-token --provider moonshotopenclaw config set models.providers.moonshot.apiKey "${MOONSHOT_API_KEY}"
# 配置本地 Ollamaopenclaw models scan --provider ollama --set-defaultxxxxxxxxxx{ "models": { "defaults": { "primary": "deepseek/deepseek-chat", "fallbacks": ["zhipu/glm-4", "moonshot/kimi-chat"] }, "providers": { "deepseek": { "apiKey": "${DEEPSEEK_API_KEY}", "baseUrl": "https://api.deepseek.com" }, "bailian": { "apiKey": "${DASHSCOPE_API_KEY}", "baseUrl": "https://dashscope.aliyuncs.com" }, "zhipu": { "apiKey": "${ZHIPU_API_KEY}", "baseUrl": "https://open.bigmodel.cn" }, "moonshot": { "apiKey": "${MOONSHOT_API_KEY}", "baseUrl": "https://api.moonshot.cn" }, "ollama": { "baseUrl": "http://localhost:11434" } } }}xxxxxxxxxx# 设置上下文窗口openclaw config set models.defaults.contextWindow 32768
# 设置温度参数openclaw config set models.defaults.temperature 0.3
# 设置最大输出 tokenopenclaw config set models.defaults.maxTokens 8192
# 设置并发限制openclaw config set models.defaults.maxConcurrent 5xxxxxxxxxx# 列出可用技能openclaw skills listopenclaw skills list --eligibleopenclaw skills list --json
# 查看技能详情openclaw skills info <skill-name>openclaw skills info summarize --json
# 从 ClawHub 安装技能npx clawhub install summarizenpx clawhub install file-organizernpx clawhub install web-searchnpx clawhub install calendar
# 从本地安装技能包openclaw skills install-local /path/to/skill-package.tgz
# 从 Git 仓库安装openclaw skills install git+https://github.com/your-org/your-skill.git
# 检查技能依赖openclaw skills check --verbosexxxxxxxxxx# 启用技能openclaw skills enable summarizeopenclaw skills enable file-organizer
# 禁用技能openclaw skills disable summarize
# 查看已启用技能openclaw skills list --enabled
# 查看已禁用技能openclaw skills list --disabledxxxxxxxxxx# 设置技能配置openclaw config set skills.entries.summarize.enabled trueopenclaw config set skills.entries.summarize.config.maxLength 500openclaw config set skills.entries.summarize.config.language "zh-CN"
# 设置技能触发条件openclaw config set skills.entries.web-search.triggers '["搜索", "查找", "查询"]'
# 查看技能配置openclaw config get skills.entriesxxxxxxxxxx{ "skills": { "entries": { "summarize": { "enabled": true, "config": { "maxLength": 500, "language": "zh-CN", "style": "bullet" } }, "file-organizer": { "enabled": true, "config": { "watchDirs": ["~/Downloads", "~/Desktop"], "rules": { "*.pdf": "Documents/PDFs", "*.jpg": "Pictures" } } }, "web-search": { "enabled": true, "config": { "engine": "bing", "maxResults": 5 } }, "calendar": { "enabled": true, "config": { "timezone": "Asia/Shanghai", "language": "zh-CN" } } } }}| 技能 | 说明 | 安装命令 |
|---|---|---|
summarize | 文本摘要 | npx clawhub install summarize |
file-organizer | 文件整理 | npx clawhub install file-organizer |
web-search | 网络搜索 | npx clawhub install web-search |
calendar | 日历管理 | npx clawhub install calendar |
feishu-integration | 飞书集成 | npx clawhub install feishu-integration |
dingtalk-connector | 钉钉连接 | npx clawhub install dingtalk-connector |
wechat-helper | 微信助手 | npx clawhub install wechat-helper |
xxxxxxxxxx# 检查技能状态openclaw skills status
# 重新加载技能openclaw skills reload summarize
# 查看技能日志openclaw logs --filter "skill:summarize"
# 技能诊断openclaw skills doctorxxxxxxxxxx# 设置工具配置文件openclaw config set tools.profile "messaging" # 仅消息工具openclaw config set tools.profile "minimal" # 最小工具集openclaw config set tools.profile "full" # 完整工具集
# 拒绝危险工具openclaw config set tools.deny '["gateway", "cron", "sessions_spawn", "sessions_send"]'
# 允许特定工具openclaw config set tools.allow '["read", "write", "whatsapp", "telegram", "feishu"]'
# 文件系统限制openclaw config set tools.fs.workspaceOnly true
# 执行安全策略openclaw config set tools.exec.security "deny"openclaw config set tools.exec.ask "always"openclaw config set tools.exec.applyPatch.workspaceOnly true
# 禁用提升模式openclaw config set tools.elevated.enabled false| 类别 | 工具示例 | 安全级别 |
|---|---|---|
| 消息工具 | whatsapp, telegram, feishu, dingtalk | 低 |
| 文件工具 | read, write, edit | 中 |
| 执行工具 | exec, shell, applyPatch | 高 |
| 网络工具 | fetch, browser, web-search | 中 |
| 系统工具 | gateway, cron, sessions | 高 |
| 自动化 | group:automation, group:runtime | 高 |
xxxxxxxxxx{ "tools": { "profile": "messaging", "allow": ["read", "write", "feishu", "dingtalk", "web-search"], "deny": ["group:automation", "group:runtime", "gateway", "cron"], "fs": { "workspaceOnly": true, "allowedPaths": ["~/Documents", "~/Downloads"] }, "exec": { "security": "ask", "ask": "always", "applyPatch": { "workspaceOnly": true } }, "elevated": { "enabled": false }, "browser": { "enabled": true, "ssrfPolicy": { "dangerouslyAllowPrivateNetwork": false, "hostnameAllowlist": ["*.example.com", "example.com"] } } }}xxxxxxxxxx# 查看审批设置openclaw approvals get
# 设置审批策略openclaw approvals set --security ask --allowlist "ls,cat,pwd,git status"
# 添加白名单openclaw approvals allowlist add "git status"openclaw approvals allowlist add "npm install"
# 移除白名单openclaw approvals allowlist remove "rm"在代理工作区创建 SOUL.md 文件:
xxxxxxxxxx# 人格定义
**名称:** 智能工作助手**描述:** 专业处理工作相关任务**语言:** 中文
## 系统提示词你是专业的智能工作助手,擅长处理文档、日程、沟通等任务。- 使用简洁清晰的中文回复- 主动确认用户意图- 提供可执行的建议
## 行为准则1. 先理解任务,再执行操作2. 敏感操作前必须确认3. 保持专业友好的语气4. 遇到不确定时主动询问
## 技能偏好- 优先使用飞书进行工作沟通- 文档处理使用 summarize 技能- 日程管理使用 calendar 技能xxxxxxxxxx# 创建新代理(含人格)openclaw agents add work-assistant --workspace ~/.openclaw/workspace-work
# 编辑人格配置openclaw agents edit work-assistant --soul
# 查看人格配置openclaw agents info work-assistant
# 绑定人格到渠道openclaw agents bind --agent work-assistant --bind feishu:default
# 设置系统提示词openclaw config set agents.defaults.systemPrompt "你是专业的工作助手,使用中文回复"xxxxxxxxxx{ "agents": { "list": [ { "id": "work-assistant", "default": true, "workspace": "~/.openclaw/workspace-work", "soul": { "name": "智能工作助手", "description": "专业处理工作相关任务", "systemPrompt": "你是专业的智能工作助手,擅长处理文档、日程、沟通等任务。", "language": "zh-CN" }, "sandbox": { "mode": "all", "scope": "agent", "workspaceAccess": "ro" } } ] }}xxxxxxxxxx# 切换默认代理openclaw agents set-default work-assistant
# 查看当前代理openclaw agents current
# 代理间切换(会话级)openclaw sessions switch --agent work-assistant| 渠道 | 状态 | 认证方式 | 国内可用性 |
|---|---|---|---|
| 飞书/Feishu | ✅ 内置 | App Key/Secret | ✅ 优秀 |
| 钉钉/DingTalk | ✅ 插件 | App Key/Secret | ✅ 优秀 |
| 企业微信 | ✅ 插件 | CorpID/Secret | ✅ 优秀 |
| Telegram | ✅ 内置 | Bot Token | ⚠️ 需代理 |
| Discord | ✅ 内置 | Bot Token | ⚠️ 需代理 |
| ✅ 内置 | QR 配对 | ⚠️ 需代理 | |
| Slack | ✅ 内置 | Bot Token | ⚠️ 需代理 |
| Signal | ✅ 内置 | signal-cli | ⚠️ 需代理 |
| 微信 | 🔌 插件 | 需第三方服务 | ⚠️ 限制较多 |
| 🔌 插件 | 需第三方服务 | ⚠️ 限制较多 |
xxxxxxxxxx# 列出所有渠道openclaw channels listopenclaw channels list --json
# 查看渠道状态openclaw channels statusopenclaw channels status --probe
# 添加飞书渠道openclaw channels add --channel feishu --account work \ --name "工作飞书" \ --appKey "${FEISHU_APP_KEY}" \ --appSecret "${FEISHU_APP_SECRET}"
# 添加钉钉渠道openclaw channels add --channel dingtalk --account work \ --name "工作钉钉" \ --appKey "${DINGTALK_APP_KEY}" \ --appSecret "${DINGTALK_APP_SECRET}"
# 添加企业微信渠道openclaw channels add --channel wechat-work --account work \ --name "企业微信" \ --corpId "${WECHAT_CORP_ID}" \ --secret "${WECHAT_SECRET}"
# 添加 Telegram 渠道(需代理)openclaw channels add --channel telegram --account personal \ --name "个人 Telegram" \ --token "${TELEGRAM_BOT_TOKEN}"
# 渠道登录(WhatsApp QR)openclaw channels login --channel whatsapp
# 渠道登出openclaw channels logout --channel whatsapp
# 删除渠道openclaw channels remove --channel feishu --account work --delete
# 查看渠道日志openclaw channels logs --channel feishu --lines 200xxxxxxxxxx{ "channels": { "feishu": { "accounts": { "work": { "appKey": "${FEISHU_APP_KEY}", "appSecret": "${FEISHU_APP_SECRET}", "name": "工作飞书", "enabled": true } }, "dmPolicy": "pairing", "groups": { "*": { "requireMention": true } }, "allowFrom": ["+86*"] } }}xxxxxxxxxx# 配置 DM 策略openclaw config set channels.feishu.dmPolicy "pairing" # 配对(推荐)openclaw config set channels.feishu.dmPolicy "allowlist" # 白名单openclaw config set channels.feishu.dmPolicy "open" # 开放openclaw config set channels.feishu.dmPolicy "disabled" # 禁用
# 配置允许列表openclaw config set channels.feishu.allowFrom '["+8613800138000"]'
# 配置群组提及要求openclaw config set channels.feishu.groups '{"*": {"requireMention": true}}'xxxxxxxxxx# 查看待审批配对openclaw pairing listopenclaw pairing list feishu --json
# 审批配对openclaw pairing approve feishu 123456openclaw pairing approve --channel feishu --notify 123456
# 拒绝配对openclaw pairing reject feishu 123456xxxxxxxxxx# 列出所有代理openclaw agents listopenclaw agents list --jsonopenclaw agents list --bindings
# 添加新代理openclaw agents add work-agent --workspace ~/.openclaw/workspace-workopenclaw agents add personal-agent --workspace ~/.openclaw/workspace-personal
# 非交互式添加openclaw agents add dev-agent --non-interactive \ --workspace ~/dev-ws \ --model zhipu/glm-4
# 绑定渠道到代理openclaw agents bind --agent work-agent --bind feishu:workopenclaw agents bind --agent personal-agent --bind telegram:personal
# 解绑渠道openclaw agents unbind --agent work-agent --bind feishu:workopenclaw agents unbind --agent work-agent --all
# 删除代理openclaw agents delete work-agentopenclaw agents delete work-agent --force
# 设置默认代理openclaw agents set-default work-agentxxxxxxxxxx{ "agents": { "list": [ { "id": "work-agent", "default": true, "workspace": "~/.openclaw/workspace-work", "model": { "primary": "zhipu/glm-4", "fallbacks": ["deepseek/deepseek-chat"] }, "sandbox": { "mode": "all", "scope": "agent", "workspaceAccess": "ro" }, "tools": { "allow": ["read", "write", "feishu"], "deny": ["exec", "gateway"] } }, { "id": "personal-agent", "workspace": "~/.openclaw/workspace-personal", "model": { "primary": "moonshot/kimi-chat" }, "sandbox": { "mode": "off" } } ] }, "bindings": [ { "agentId": "work-agent", "match": { "channel": "feishu", "accountId": "work" } }, { "agentId": "personal-agent", "match": { "channel": "telegram", "accountId": "personal" } } ]}xxxxxxxxxx# 查看记忆状态openclaw memory status
# 重建记忆索引openclaw memory index
# 语义搜索openclaw memory search "项目进度"openclaw memory search --query "meeting notes" --jsonopenclaw memory search --query "用户偏好" --limit 10
# 查看记忆文件openclaw memory filesopenclaw memory files --jsonxxxxxxxxxx# 启用记忆openclaw config set memory.enabled true
# 设置记忆路径openclaw config set memory.indexPath "~/.openclaw/memory"
# 设置记忆文件openclaw config set memory.files '["MEMORY.md", "memory/*.md"]'
# 设置最大条目数openclaw config set memory.maxEntries 1000
# 设置嵌入模型openclaw config set memory.embeddingModel "text-embedding-3-small"xxxxxxxxxx{ "memory": { "enabled": true, "indexPath": "~/.openclaw/memory", "files": ["MEMORY.md", "memory/*.md"], "maxEntries": 1000, "embeddingModel": "text-embedding-3-small" }}xxxxxxxxxx~/.openclaw/├── memory/│ ├── MEMORY.md # 主记忆文件│ ├── projects.md # 项目记忆│ ├── preferences.md # 用户偏好│ └── contacts.md # 联系人记忆└── workspace/└── *.md # 工作区文件
xxxxxxxxxx# 列出节点openclaw nodes listopenclaw nodes list --connectedopenclaw nodes list --json
# 查看节点状态openclaw nodes status
# 查看节点详情openclaw nodes describe --node my-iphone
# 查看待审批节点openclaw nodes pending
# 审批节点配对openclaw nodes approve <requestId>
# 拒绝节点配对openclaw nodes reject <requestId>
# 节点重命名openclaw nodes rename --node my-iphone --name "工作 iPhone"
# 在节点上执行命令openclaw nodes run --node my-iphone --command "ls -la"openclaw nodes run --node my-iphone --cwd /tmp --command "pwd"xxxxxxxxxx# 摄像头列表openclaw nodes camera list --node my-iphone
# 拍照openclaw nodes camera snap --node my-iphone --facing front --quality 0.8
# 录制视频openclaw nodes camera clip --node my-iphone --duration 10s --no-audio
# 屏幕录制openclaw nodes screen record --node my-iphone --duration 10s --fps 30 --out /tmp/recording.mp4
# Canvas 快照openclaw nodes canvas snapshot --node my-iphone --format png
# Canvas 导航openclaw nodes canvas navigate https://example.com --node my-iphonexxxxxxxxxx# 发送通知(macOS)openclaw nodes notify --node my-mac --title "提醒" --body "任务完成"
# 获取位置openclaw nodes location get --node my-iphone --accuracy precisexxxxxxxxxx# 运行节点主机openclaw node run --host gateway.local --port 18789
# 安装节点服务openclaw node install --host gateway.local --port 18789
# 节点服务管理openclaw node statusopenclaw node stopopenclaw node restartopenclaw node uninstallxxxxxxxxxx# 浏览器状态openclaw browser status
# 启动/停止浏览器openclaw browser startopenclaw browser stopopenclaw browser reset-profile
# 标签页管理openclaw browser tabsopenclaw browser open https://example.comopenclaw browser focus <targetId>openclaw browser close <targetId>
# 截图openclaw browser screenshot --full-pageopenclaw browser screenshot <targetId> --element "#main-content"
# 导航openclaw browser navigate https://example.com --target-id <id>
# 交互操作openclaw browser click <ref>openclaw browser type <ref> "Hello World" --submitopenclaw browser press Enter --target-id <id>xxxxxxxxxx# 配置 SSRF 策略openclaw config set browser.ssrfPolicy.dangerouslyAllowPrivateNetwork falseopenclaw config set browser.ssrfPolicy.hostnameAllowlist '["*.example.com"]'
# 配置文件下载openclaw config set browser.downloads.allowed trueopenclaw config set browser.downloads.path "~/Downloads"xxxxxxxxxx# 查看定时任务状态openclaw cron statusopenclaw cron status --json
# 列出所有任务openclaw cron listopenclaw cron list --allopenclaw cron list --json
# 添加任务(cron 表达式)openclaw cron add --name "daily-report" --cron "0 9 * * *" --text "生成日报"
# 添加任务(间隔)openclaw cron add --name "heartbeat" --every "30m" --text "心跳检查"
# 添加任务(指定时间)openclaw cron add --name "backup" --at "2026-03-25T02:00:00Z" --text "备份提醒"
# 编辑任务openclaw cron edit <id> --cron "0 10 * * *"
# 删除任务openclaw cron rm <id>
# 启用/禁用任务openclaw cron enable <id>openclaw cron disable <id>
# 查看运行历史openclaw cron runs --id <id> --limit 10
# 手动触发任务openclaw cron run <id>xxxxxxxxxx{ "cron": { "enabled": true, "maxConcurrentRuns": 2, "sessionRetention": "24h", "runLog": { "maxBytes": "2mb", "keepLines": 2000 } }}xxxxxxxxxx# 重新加载密钥openclaw secrets reload
# 审计密钥openclaw secrets audit
# 配置密钥(交互式)openclaw secrets configure
# 应用密钥计划openclaw secrets apply --from plan.jsonopenclaw secrets apply --from plan.json --dry-runxxxxxxxxxx# 设置环境变量(推荐方式)export DEEPSEEK_API_KEY="sk-xxx"export DASHSCOPE_API_KEY="sk-xxx"export ZHIPU_API_KEY="xxx"export MOONSHOT_API_KEY="sk-xxx"export OPENCLAW_GATEWAY_TOKEN="xxx"
# 永久设置(~/.bashrc 或~/.zshrc)echo 'export DEEPSEEK_API_KEY="sk-xxx"' >> ~/.bashrcsource ~/.bashrcxxxxxxxxxx{ "models": { "providers": { "deepseek": { "apiKey": "${DEEPSEEK_API_KEY}" }, "bailian": { "apiKey": "${DASHSCOPE_API_KEY}" }, "zhipu": { "apiKey": "${ZHIPU_API_KEY}" } } }, "channels": { "feishu": { "accounts": { "work": { "appKey": "${FEISHU_APP_KEY}", "appSecret": "${FEISHU_APP_SECRET}" } } } }}xxxxxxxxxx# 运行安全审计openclaw security auditopenclaw security audit --deepopenclaw security audit --fixopenclaw security audit --json| 检查项 | 严重性 | 修复方式 |
|---|---|---|
fs.state_dir.perms_world_writable | 严重 | chmod 700 ~/.openclaw |
gateway.bind_no_auth | 严重 | 配置 gateway.auth.token |
tools.exec.host_sandbox_no_sandbox | 警告 | 启用沙箱 |
security.exposure.open_groups_with_elevated | 严重 | 限制群组访问 |
xxxxxxxxxx{ "gateway": { "bind": "loopback", "auth": { "mode": "token", "token": "${OPENCLAW_GATEWAY_TOKEN}" } }, "session": { "dmScope": "per-channel-peer" }, "tools": { "profile": "messaging", "deny": ["group:automation", "group:runtime"], "fs": { "workspaceOnly": true }, "exec": { "security": "ask", "ask": "always" }, "elevated": { "enabled": false } }, "channels": { "feishu": { "dmPolicy": "pairing", "groups": { "*": { "requireMention": true } } } }}xxxxxxxxxx# 修复权限chmod 700 ~/.openclawchmod 600 ~/.openclaw/openclaw.jsonchmod 600 ~/.openclaw/credentials/**/*
# 让 doctor 自动修复openclaw doctor --fixxxxxxxxxxx# 获取配置值openclaw config get agents.defaults.workspace
# 设置配置值openclaw config set agents.defaults.heartbeat.every "2h"
# 删除配置值openclaw config unset tools.web.search.apiKey
# 查看配置文件路径openclaw config file
# 验证配置openclaw config validate
# 导出配置openclaw config export > backup.json
# 导入配置openclaw config import backup.jsonxxxxxxxxxx# 备份配置和状态tar -czvf openclaw-backup-$(date +%F).tar.gz ~/.openclaw
# 恢复tar -xzvf openclaw-backup-2026-03-24.tar.gz -C ~/
# 验证备份openclaw doctorxxxxxxxxxx# 更新openclaw update
# 重置openclaw reset --scope config+creds+sessions --yesopenclaw reset --scope full --yes
# 卸载openclaw uninstall --all --yesxxxxxxxxxx# 查看日志openclaw logs --followopenclaw logs --limit 500openclaw logs --json
# 日志轮转配置openclaw config set logging.file "/var/log/openclaw/gateway.log"openclaw config set logging.maxFiles 7openclaw config set logging.maxSize "10mb"openclaw config set logging.redactSensitive "tools"xxxxxxxxxx# 配置 HTTP 代理(如需访问海外服务)export HTTP_PROXY="http://proxy.example.com:8080"export HTTPS_PROXY="http://proxy.example.com:8080"
# 配置 npm 镜像(国内)npm config set registry https://registry.npmmirror.com
# 配置 pip 镜像(国内)pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simplexxxxxxxxxx{ "models": { "defaults": { "primary": "deepseek/deepseek-chat", "fallbacks": ["zhipu/glm-4", "moonshot/kimi-chat"] }, "providers": { "deepseek": { "apiKey": "${DEEPSEEK_API_KEY}", "baseUrl": "https://api.deepseek.com", "timeout": 30000 }, "bailian": { "apiKey": "${DASHSCOPE_API_KEY}", "baseUrl": "https://dashscope.aliyuncs.com" }, "zhipu": { "apiKey": "${ZHIPU_API_KEY}", "baseUrl": "https://open.bigmodel.cn" }, "moonshot": { "apiKey": "${MOONSHOT_API_KEY}", "baseUrl": "https://api.moonshot.cn" } } }}xxxxxxxxxx{ "channels": { "feishu": { "accounts": { "work": { "appKey": "${FEISHU_APP_KEY}", "appSecret": "${FEISHU_APP_SECRET}", "enabled": true } }, "dmPolicy": "pairing", "groups": { "*": { "requireMention": true } } }, "dingtalk": { "accounts": { "work": { "appKey": "${DINGTALK_APP_KEY}", "appSecret": "${DINGTALK_APP_SECRET}", "enabled": true } } } }}xxxxxxxxxx# 设置时区openclaw config set system.timezone "Asia/Shanghai"
# 设置语言openclaw config set system.locale "zh-CN"
# 设置日期格式openclaw config set system.dateFormat "YYYY-MM-DD"xxxxxxxxxx# 使用国内镜像源docker pull registry.cn-hangzhou.aliyuncs.com/openclaw/gateway:latest
# 或配置 Docker 镜像加速cat > /etc/docker/daemon.json << EOF{ "registry-mirrors": [ "https://docker.mirrors.ustc.edu.cn", "https://registry.cn-hangzhou.aliyuncs.com" ]}EOFsystemctl restart docker| 类别 | 命令 | 说明 |
|---|---|---|
| 网关 | openclaw gateway start | 启动网关 |
openclaw gateway status | 查看状态 | |
openclaw gateway install | 安装服务 | |
| Dashboard | http://127.0.0.1:18789 | 访问控制台 |
| 渠道 | openclaw channels add | 添加渠道 |
openclaw channels status | 渠道状态 | |
openclaw pairing approve | 审批配对 | |
| 代理 | openclaw agents add | 添加代理 |
openclaw agents bind | 绑定渠道 | |
| 模型 | openclaw models set | 设置模型 |
openclaw models auth setup-token | 设置认证 | |
| 技能 | npx clawhub install | 安装技能 |
openclaw skills enable | 启用技能 | |
| 工具 | openclaw config set tools.profile | 工具策略 |
| 人格 | openclaw agents edit --soul | 编辑人格 |
| 记忆 | openclaw memory search | 搜索记忆 |
| 定时 | openclaw cron add | 添加任务 |
| 密钥 | openclaw secrets reload | 重载密钥 |
| 安全 | openclaw security audit | 安全审计 |
| 诊断 | openclaw doctor | 健康检查 |
| 日志 | openclaw logs --follow | 实时日志 |
| 配置 | openclaw config set | 设置配置 |
| 备份 | openclaw config export | 导出配置 |
| 服务商 | 申请地址 | 备注 |
|---|---|---|
| DeepSeek | https://platform.deepseek.com/ | 注册送额度 |
| 阿里云百炼 | https://bailian.console.aliyun.com/ | 需实名认证 |
| 智谱 AI | https://open.bigmodel.cn/ | 有免费额度 |
| 月之暗面 | https://platform.moonshot.cn/ | Kimi 同款模型 |
| 飞书开放平台 | https://open.feishu.cn/ | 创建应用获取 |
| 钉钉开放平台 | https://open.dingtalk.com/ | 创建应用获取 |
openclaw官方资源:
安全提醒:
openclaw security audit --deepchmod 700 ~/.openclaw维护团队: ClawSTU 龙虾工作室