OpenClaw配置
这不是完整的教程,只是记录一些关键的配置 and 踩过的坑。
浏览器配置
OpenClaw中的浏览器,相当于一个内置的browser-use。因为很多(大多数)网站要登录、要人工通过bot验证后才能继续操作。但是默认的headless模式浏览器却没法实现交互。
浏览器配置:~/.openclaw/openclaw.json
"browser": {
"enabled": true,
"executablePath": "/usr/bin/google-chrome-stable",
"headless": false,
"defaultProfile": "openclaw",
"profiles": {}
},
通常云主机都是用VNC或者XRDP登录,但是如果只用上述配置,无法启动一个可以正常交互的浏览器
本文试验环境中使用的VNC为:KasmVNC
修改systemd服务文件:~/.config/systemd/user/openclaw-gateway.service
[Service]
Environment=DISPLAY=:1.0
Environment=XAUTHORITY=/home/debian/.Xauthority
其中:DISPLAY的值通过在VNC桌面的Terminal中执行echo $DISPLAY,若是通过SSH登录执行结果为空
修改完成后,把服务器重启一次。登录VNC,在Terminal中执行openclaw browser start,就能正常启动浏览器(Chrome窗口自动打开):
systemctl --user restart openclaw-gateway
systemctl --user daemon-reload
openclaw gateway restart
用于查询browser状态和profile的命令
openclaw browser status
openclaw browser profiles
个人理解,上述配置本质上是解决了云主机上没有显示设备,以及VNC的显示设备信息没有被OpenClaw正确识别并使用。
这两个软件组合起来看上去也能解决不少问题(sandbox或者...?)
- Xvfb (X Virtual Framebuffer) 是一个在内存中模拟图形显示服务器的工具,主要用于在没有物理显示器的服务器环境运行 GUI 软件。
- x11vnc 是一款功能强大的开源 VNC 服务器软件
- 不要使用snap包安装Chrome,snap有沙箱机制,即便开启了CDP也很难正常连接
- 不要使用自带的Chrome relay extension,这个插件的稳定性很差,运行一会就断开了
Discord配置
飞书个人版抠抠搜搜的,API调用数量和调用频率都有这样那样的限制。但确实比鹅厂微信完全关门要好太多。如果用的是飞书企业版,那就尽情的玩吧。飞书channel最大的优点就是:不用梯子
在不同的Discord channel中使用不同的agent。
创建agent
openclaw agents add news_bot
根据上述命令执行完成后的提示找到新建agent的Workspace目录,可以按需修改其中的*.md文件。
channel配置:.openclaw/openclaw.json
"channels": {
"discord": {
"enabled": true,
"token": "MTQ2N2qvI",
"groupPolicy": "open",
"guilds": {
"812756": {
"requireMention": false,
"users": ["13173"]
}
}
}
}
其中:
guilds中的属性是Discord的ServerIDusers数组中是Discord的UserID
除了channel配置之外,还需要配置bindings,将每个agent对应到一个Discord channel:
"bindings": [
{
"agentId": "news_bot",
"match": {
"channel": "discord",
"peer": {
"kind": "channel",
"id": "503285"
},
"guildId": "812756"
}
},
{
"agentId": "main",
"match": {
"channel": "discord",
"peer": {
"kind": "channel",
"id": "118666"
},
"guildId": "812756"
}
}
]
其中:
guildId是Discord的ServerIDpeer.id是Discord的channelID
配置memory search
记忆内容存放在MEMORY.md文件和memory目录中,但是在使用记忆的时候,依然要使用向量搜索,支持兼容OpenAI API的embedding服务。
# 设置 Base URL
openclaw config set agents.defaults.memorySearch.remote.baseUrl "https://你的代理地址/v1"
# 设置模型名称
openclaw config set agents.defaults.memorySearch.model "你的模型名称"
# 设置 API Key (建议使用环境变量,见下文)
openclaw config set agents.defaults.memorySearch.remote.apiKey "你的密钥"
查看OpenClaw gateway系统服务的命令
# 有 --user 参数,命令不需要sudo
systemctl --user status openclaw-gateway
sudo loginctl enable-linger debian的作用是 为某个用户启用“linger”(持久化会话),使其可以在未登录时仍然运行 systemd 用户服务
SOUL.md文件示例,用于收集热点新闻和热门讨论话题。
# Role: OpenClaw Information Specialist
## Profile
- **Expertise**: Expert at collecting and synthesizing internet news and resources.
- **Tools**: Always use the browser profile `openclaw` for all web activities.
- **Language**: Summaries must be written in Chinese (中文).
- **Special Requirement**: News titles must be presented in both English and Chinese (Bilingual).
## Rules
1. **Search & Collect**: Actively browse the web using the `openclaw` profile to gather the latest and most relevant information.
2. **Bilingual Titles**: For every piece of news or material, the title must be displayed in both the original English and the translated Chinese.
3. **Chinese Summarization**: Provide a concise and high-quality summary of the content in Chinese.
4. **Source Attribution**: Always attach the original URL (link) for every collected item.
5. **No Tables**: Markdown tables are strictly prohibited. Use headings, bullet points, and bold text for organization.
## Output Format
- **Title**: [English Title] / [中文标题]
- **Summary**: [此处输入中文摘要内容]
- **Source**: 原文链接: [URL]
## Workflow
1. Access the internet via the `openclaw` browser profile.
2. Identify key information and news.
3. Translate the title into a bilingual format (English/Chinese).
4. Summarize the findings into Chinese.
5. Present the results using Markdown headers and lists (avoiding tables).