Integration
Lucy Openclaw
Lucy SuperBrain integration plugin for OpenClaw
Install
npm install
#
Configuration Example
{
"plugins": {
"lucy": {
"gatewayUrl": "http://localhost:8000",
"agentId": "openclaw_agent",
"strictMode": true
}
}
}
README
# Lucy OpenClaw Plugin
> 让 SuperBrain (Lucy) 成为 OpenClaw 的超脑
## 架构
```
┌─────────────────────────────────────────────────────────────┐
│ OpenClaw (Client/Frontend) │
│ Lucy Plugin │
│ - onMessageReceived → 消息预处理 │
│ - beforeAgentRun → Agent 执行前 │
│ - onToolCall → 工具拦截/优化 │
│ - beforeMessageSend → 回复审查 │
└────────────────────────┬────────────────────────────────────┘
│ HTTP API
▼
┌─────────────────────────────────────────────────────────────┐
│ SuperBrain Gateway (Server/Backend) │
│ http://localhost:8000 │
│ /think, /audit, /assimilate, /health │
└─────────────────────────────────────────────────────────────┘
```
## 目录结构
```
lucy-openclaw-plugin/
├── src/
│ ├── index.ts # 插件入口
│ ├── types/
│ │ └── index.ts # TypeScript 类型定义
│ ├── client/
│ │ └── lucy-client.ts # Lucy Gateway HTTP 客户端
│ └── hooks/
│ ├── onMessageReceived.ts # 消息预处理
│ ├── beforeAgentRun.ts # Agent 执行前
│ ├── onToolCall.ts # 工具拦截
│ └── beforeMessageSend.ts # 回复审查
├── configs/
│ └── default.json # 默认配置
├── package.json
├── tsconfig.json
└── README.md
```
## 开发任务
### Phase 1: 基础框架 (v0.1.0) - 进行中
- [x] 项目初始化
- [x] TypeScript 类型定义
- [x] LucyClient 实现
- [x] Hook 框架基础
### Phase 2: Hook 实现 (v0.2.0)
- [ ] onMessageReceived hook
- [ ] 调用 `/think` 获取上下文
- [ ] 注入记忆到 session
- [ ] 飞书上下文提取
- [ ] beforeAgentRun hook
- [ ] 安全审查
- [ ] 深度思考注入
- [ ] Persona 设置
- [ ] onToolCall hook
- [ ] 高危操作拦截
- [ ] 审批流程集成
- [ ] 执行后学习
- [ ] beforeMessageSend hook
- [ ] 回复审查
- [ ] 安全警告注入
### Phase 3: 飞书集成 (v0.3.0)
- [ ] 审批卡片发送
- [ ] 审批回调处理
- [ ] 状态通知
### Phase 4: 测试与部署 (v0.4.0)
- [ ] 单元测试
- [ ] 集成测试
- [ ] OpenClaw 插件注册
- [ ] 生产部署
## 安装
```bash
# 安装依赖
npm install
# 开发模式
npm run dev
# 构建
npm run build
# 测试
npm test
```
## 配置
在 OpenClaw 配置文件中添加:
```json
{
"plugins": {
"lucy": {
"gatewayUrl": "http://localhost:8000",
"agentId": "openclaw_agent",
"strictMode": true
}
}
}
```
环境变量:
| 变量 | 默认值 | 说明 |
|------|--------|------|
| `LUCY_GATEWAY_URL` | http://localhost:8000 | Lucy Gateway 地址 |
| `AGENT_ID` | openclaw_agent | Agent ID |
| `LUCY_STRICT_MODE` | true | 严格模式 |
| `LUCY_TIMEOUT` | 30000 | 超时(ms) |
## Hook 详情
### onMessageReceived
用户消息到达时触发:
1. 调用 `/think` 获取相关记忆
2. 提取飞书上下文
3. 注入记忆到 session
4. 设置安全警告
### beforeAgentRun
Agent 执行前触发:
1. 安全审查 (`/audit`)
2. 深度思考 (`/think` mode=deep)
3. 注入 system prompt
### onToolCall
工具调用前/后触发:
**Before:**
1. 高危操作审查
2. 审批请求(如果需要)
3. 参数优化
**After:**
1. 提取有价值信息
2.Assimilate 到 Lucy
3. 错误学习
### beforeMessageSend
回复发送前触发:
1. 审查回复内容
2. 注入安全警告
3. 添加 Lucy 签名
## 与 SuperBrain 通信
```typescript
import { getLucyClient } from 'lucy-openclaw-plugin';
const lucy = getLucyClient();
// 思考
const context = await lucy.think({
agent_id: 'openclaw',
query: '分析这个任务'
});
// 审查
const result = await lucy.audit({
agent_id: 'openclaw',
action: 'bash',
params: { command: 'ls -la' }
});
// 学习
await lucy.assimilate({
agent_id: 'openclaw',
observation: 'Task completed',
learned_lesson: 'Use async/await'
});
```
## 相关文档
- [SuperBrain 项目](../SuperBrain/)
- [OpenClaw Hooks](https://docs.openclaw.ai/gateway/hooks)
- [OpenClaw 插件开发](https://docs.openclaw.ai/plugins)
## License
MIT
integration
Comments
Sign in to leave a comment