安全与风控
需要审计和可视化 OpenClaw agent 运行…
在本地安全查看并排查 OpenClaw agent 状态、用量、任务、记忆和接线情况,默认只读。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 60/100 ×0.15
适用场景
需要审计和可视化 OpenClaw ag特定
解决思路
- 克隆仓库:git clone https://github.com/TianyiDataScience/openclaw-control-center.git
- 进入目录:cd openclaw-control-center
- 安装依赖:npm install
- 复制环境变量模板:cp .env.example .env
- 构建:npm run build
- 运行测试:npm test
- 运行 UI 冒烟测试:npm run smoke:ui
- 启动 UI 服务器:npm run dev:ui
- 打开控制台:http://127.0.0.1:4310/?section=overview&lang=zh 或 http://127.0.0.1:4310/?section=overview&lang=en
- 在 Windows 或不稳定 shell 中优先使用 npm run dev:ui,而不是 UI_MODE=true npm run dev
- 只修改 control-center/ 目录内文件
- 绝不修改 ~/.openclaw/openclaw.json
- 配置 .env:设置 OPENCLAW_GATEWAY_URL=http://127.0.0.1:PORT、OPENCLAW_HOME=~/.openclaw、PORT=4310、DEFAULT_LANG=zh
- 保持安全默认值:READONLY_MODE=true、LOCAL_TOKEN_AUTH_REQUIRED=true、IMPORT_MUTATION_ENABLED=false、IMPORT_MUTATION_DRY_RUN=false、APPROVAL_ACTIONS_ENABLED=false、APPROVAL_ACTIONS_DRY_RUN=true;除非理解影响,否则不要改
- READONLY_MODE=true:禁用所有改变状态的 endpoint
- LOCAL_TOKEN_AUTH_REQUIRED=true:导入/导出和写 API 需要本地 token
- IMPORT_MUTATION_ENABLED=false:完全阻止导入 mutation
- IMPORT_MUTATION_DRY_RUN=false:启用导入时使用 dry-run 模式
- APPROVAL_ACTIONS_ENABLED=false:硬禁用审批操作
- APPROVAL_ACTIONS_DRY_RUN=true:启用审批操作时按 dry-run 运行
- 开发命令:npm run dev:ui 启动 UI 服务器(推荐)
- npm run dev 运行一次性 monitor,不启动 HTTP UI
- npm run build 做 TypeScript 编译
- npm test 运行测试套件
- npm run smoke:ui 对 UI endpoints 做冒烟测试
- npm run lint 做 ESLint 检查
- npm run lint:fix 自动修复 lint 问题
- 连接 runtime monitor:从 './src/runtime/monitor' 导入 createMonitor,传入 gatewayUrl、readonlyMode、localTokenAuthRequired,调用 await monitor.getOverview(),读取 systemStatus、pendingItems、activeAgents
- 读取 agent 员工状态:从 './src/runtime/connectors/staff' 导入 StaffConnector,new StaffConnector({ gatewayUrl }),调用 await staff.getActiveAgents(),读取 name、status、currentTask?.title、lastOutput;status 为 executing/queued/idle/blocked;调用 await staff.getRoster() 获取完整 roster 和队列深度
- 追踪跨会话协作:从 './src/runtime/connectors/collaboration' 导入 CollaborationTracer,new CollaborationTracer({ gatewayUrl }),调用 await tracer.getSessionHandoffs(),读取 parentSession→childSession、taskTitle、status;调用 await tracer.getCrossSessionMessages(),读取 fromAgent⇄toAgent、messageType(sessions_send/inter-session message)
- 获取 token 用量与花费:从 './src/runtime/connectors/usage' 导入 UsageConnector,new UsageConnector({ gatewayUrl }),调用 await usage.getUsageSummary('today'),读取 tokensUsed、costUsd、contextPressure(low/medium/high/critical);调用 await usage.getUsageTrend(7),遍历 date、tokensUsed、costUsd;调用 await usage.getTokenAttribution(),遍历 tasks 的 title、tokensUsed、percentOfTotal
- 读取记忆状态:从 './src/runtime/connectors/memory' 导入 MemoryConnector,new MemoryConnector({ openclawHome: process.env.OPENCLAW_HOME ?? '~/.openclaw' }),调用 await memory.getMemoryState(),遍历 agents 读取 name、memoryAvailable、memorySearchable、needsReview;调用 await memory.readDailyMemory('main-agent') 读取 content;调用 await memory.writeDailyMemory('main-agent', updatedContent, { token: localToken }) 写记忆,需要 READONLY_MODE=false 和有效 local token
- 检查接线状态:从 './src/runtime/connectors/wiring' 导入 WiringChecker,new WiringChecker({ gatewayUrl }),调用 await wiring.getWiringStatus(),遍历 connectors 读取 name、status(connected/partial/disconnected),若 status 非 connected 则读取 nextStep
- 审批任务(受控 endpoint):从 './src/runtime/connectors/tasks' 导入 TaskConnector,new TaskConnector({ gatewayUrl, approvalActionsEnabled: process.env.APPROVAL_ACTIONS_ENABLED === 'true', approvalActionsDryRun: process.env.APPROVAL_ACTIONS_DRY_RUN !== 'false' });调用 await tasks.approveTask('task-id-123', { token: localToken });若 APPROVAL_ACTIONS_ENABLED=false 默认会抛错;若 result.dryRun 为 true 表示无状态变更;捕获 err.code === 'APPROVAL_ACTIONS_DISABLED' 后设置 APPROVAL_ACTIONS_ENABLED=true
- 用 query params 导航 UI:http://127.0.0.1:4310/?section=overview&lang=zh、?section=usage&lang=en、?section=staff&lang=zh、?section=collaboration&lang=en、?section=tasks&lang=zh、?section=memory&lang=en、?section=documents&lang=zh、?section=settings&lang=en
- UI sections 可用:overview、usage、staff、collaboration、tasks、memory、documents、settings
- UI 语言可用:zh(中文,默认)、en(英文)
- 使用 Overview 查看系统健康、待处理项、风险信号和操作摘要
- 使用 Usage 查看 daily/7d/30d token 花费、配额、上下文压力、订阅窗口
- 使用 Staff 查看正在执行的 agent 与排队情况,而不只是“有任务”
- 使用 Collaboration 查看父子会话交接和已验证的跨会话消息(例如 Main ⇄ Pandas)
- 使用 Tasks 查看任务板、审批、执行链、运行证据
- 使用 Memory 查看每个 agent 的记忆健康、可搜索性和源文件编辑
- 使用 Documents 从实际源文件打开共享文档和 agent-core 文档
- 使用 Settings 查看 connector 接线状态、安全风险摘要、更新状态
- 嵌入已有 OpenClaw 工作流:如果 OpenClaw agent 需要交接安装指令,在执行任务中使用安装块:cd openclaw-control-center; npm install; cp .env.example .env; 编辑 .env 设置 OPENCLAW_GATEWAY_URL 和 OPENCLAW_HOME; npm run build && npm test && npm run dev:ui
- 添加自定义 connector:所有 connector 放在 control-center/src/runtime/connectors/;遵循模式:从 './base' 导入 BaseConnector、ConnectorOptions;定义 MyData 接口;class MyConnector extends BaseConnector;constructor 调用 super(options);async getData() 中先调用 this.assertNotReadonly('getData is readonly-safe');调用 this.fetch('/api/my-endpoint');返回 response.json() as Promise<MyData[]>
- 添加自定义 UI section:创建 control-center/src/ui/sections/MySection.tsx;从 React 导入;从 '../hooks/useConnector' 导入 useConnector;从 '../../runtime/connectors/my-connector' 导入 MyConnector;使用 useConnector(MyConnector, 'getData');处理 loading/error;将 data 映射为列表
- 排查 Missing src/runtime 或 Missing core source:确认工作目录在 repo 根(pwd 以 /openclaw-control-center 结尾);执行 ls control-center/src/runtime;若克隆不完整则重新执行 git clone https://github.com/TianyiDataScience/openclaw-control-center.git
- 排查 UI 不启动/端口冲突:执行 lsof -i :4310,Windows 执行 netstat -ano | findstr :4310;在 .env 中改 PORT=4311
- 排查数据不显示/部分为空:打开 Settings -> 接线状态;检查哪些 connector 是 connected/partial/missing;常见原因:OPENCLAW_GATEWAY_URL 未设置或端口错误;OPENCLAW_HOME 未指向实际 ~/.openclaw;OpenClaw subscription snapshot 不在默认路径
- 排查 token 认证失败:执行 cat ~/.openclaw/local-token;调用 API 时通过 header 传入:curl -H 'X-Local-Token: <token>' http://127.0.0.1:4310/api/tasks/approve
- 排查审批操作静默无效果:在 .env 中设置 APPROVAL_ACTIONS_ENABLED=true 和 APPROVAL_ACTIONS_DRY_RUN=false;两者都必须显式设置;默认是 disabled + dry-run
- 排查 Memory 区显示 inactive agents:Memory 区作用域是 openclaw.json 中列出的 agents;若已删除的 agent 仍出现,执行 cat ~/.openclaw/openclaw.json | grep -A5 agents 检查;从 openclaw.json 删除过期条目;下次加载时 Memory 区更新
- 排查 Windows shell 问题:优先使用 npm run dev:ui,而不是 UI_MODE=true npm run dev;dev:ui 脚本内部处理 cross-env 变量设置差异
适用边界 · 注意事项
- 不适用于未安装 OpenClaw、无法访问 OpenClaw Gateway 或没有 ~/.openclaw 本地读权限的环境
- 不适用于需要修改 control-center/ 外文件或 ~/.openclaw/openclaw.json 的场景
- 不适用于不愿配置本地 token/安全标志却默认开启写操作、导入 mutation 或审批操作的场景