mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-30 04:40:18 +08:00
feat: v0.6.0 — 公益AI接口 + Agent灵魂借尸还魂 + 知识库 + 全局AI诊断 + 官网改版
This commit is contained in:
@@ -3,13 +3,17 @@
|
||||
* 解析 npm 错误信息,返回用户友好的提示和修复建议
|
||||
*/
|
||||
|
||||
const NPM_CMD = 'npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com'
|
||||
|
||||
/**
|
||||
* @param {string} errStr - npm 错误输出
|
||||
* @param {string} errStr - npm 错误输出(可含流式日志)
|
||||
* @returns {{ title: string, hint?: string, command?: string }}
|
||||
*/
|
||||
export function diagnoseInstallError(errStr) {
|
||||
const s = errStr.toLowerCase()
|
||||
|
||||
// ===== 1. Git 相关 =====
|
||||
|
||||
// git SSH 权限问题(有 git 但没配 SSH Key)
|
||||
if (s.includes('permission denied (publickey)') || s.includes('ssh://git@github')) {
|
||||
return {
|
||||
@@ -28,12 +32,44 @@ export function diagnoseInstallError(errStr) {
|
||||
}
|
||||
}
|
||||
|
||||
// EPERM(文件被占用/权限问题)
|
||||
// ===== 2. 文件 / 权限 =====
|
||||
|
||||
// EPERM(文件被占用/权限问题)— 放在 ENOENT 前面,优先匹配
|
||||
if (s.includes('eperm') || s.includes('operation not permitted')) {
|
||||
return {
|
||||
title: '安装失败 — 文件被占用',
|
||||
hint: '有文件被锁定无法写入。先关闭所有 ClawPanel 和 Node.js 进程,然后在管理员终端手动安装:',
|
||||
command: 'npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com',
|
||||
title: '安装失败 — 文件被占用或权限不足',
|
||||
hint: '常见原因:杀毒软件拦截、Gateway 进程未关闭、或终端缺少管理员权限。\n请先关闭 Gateway,再以管理员身份打开终端手动安装:',
|
||||
command: NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
// ENOENT(文件找不到 / -4058)
|
||||
if (s.includes('enoent') || s.includes('-4058') || s.includes('code -4058')) {
|
||||
// 尝试从日志中提取具体缺失的路径
|
||||
const pathMatch = errStr.match(/enoent[^']*'([^']+)'/i) || errStr.match(/path\s+'([^']+)'/i)
|
||||
const missingPath = pathMatch?.[1] || ''
|
||||
|
||||
if (missingPath.includes('node_modules') || missingPath.includes('npm')) {
|
||||
return {
|
||||
title: '安装失败 — npm 全局目录异常',
|
||||
hint: `npm 全局安装目录可能不存在或损坏(${missingPath})。\n请先修复 npm 目录,再重试安装:`,
|
||||
command: 'npm config set prefix "%APPDATA%\\npm" && ' + NPM_CMD,
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: '安装失败 — 文件或目录不存在',
|
||||
hint: '常见原因:npm 全局目录未创建、杀毒软件隔离了文件、或磁盘权限问题。\n建议步骤:\n1. 关闭杀毒软件的实时防护\n2. 以管理员身份打开 PowerShell\n3. 手动运行安装命令:',
|
||||
command: NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
// EACCES(权限不足)
|
||||
if (s.includes('eacces') || s.includes('permission denied')) {
|
||||
const isMac = navigator.platform?.includes('Mac') || navigator.userAgent?.includes('Mac')
|
||||
return {
|
||||
title: '安装失败 — 权限不足',
|
||||
hint: isMac ? '请在终端使用 sudo 安装:' : '请以管理员身份打开 PowerShell 安装:',
|
||||
command: isMac ? 'sudo ' + NPM_CMD : NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,53 +78,68 @@ export function diagnoseInstallError(errStr) {
|
||||
return {
|
||||
title: '安装不完整',
|
||||
hint: '上次安装可能中断了。先清理残留再重装:',
|
||||
command: 'npm cache clean --force && npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com',
|
||||
command: 'npm cache clean --force && ' + NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
// ENOENT(文件找不到)
|
||||
if (s.includes('enoent') || s.includes('-4058') || s.includes('code -4058')) {
|
||||
return {
|
||||
title: '安装失败 — 文件访问错误',
|
||||
hint: '尝试以管理员身份运行 ClawPanel,或在终端手动安装:',
|
||||
command: 'npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com',
|
||||
}
|
||||
}
|
||||
// ===== 3. 网络 =====
|
||||
|
||||
// 权限不足(EACCES / EPERM)
|
||||
if (s.includes('eacces') || s.includes('eperm') || s.includes('permission denied')) {
|
||||
const isMac = navigator.platform?.includes('Mac') || navigator.userAgent?.includes('Mac')
|
||||
return {
|
||||
title: '安装失败 — 权限不足',
|
||||
hint: isMac ? '请在终端使用 sudo 安装:' : '请以管理员身份打开终端安装:',
|
||||
command: isMac
|
||||
? 'sudo npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com'
|
||||
: 'npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com',
|
||||
}
|
||||
}
|
||||
|
||||
// 网络错误
|
||||
if (s.includes('etimedout') || s.includes('econnrefused') || s.includes('enotfound')
|
||||
|| s.includes('network') || s.includes('fetch failed') || s.includes('socket hang up')) {
|
||||
|| s.includes('fetch failed') || s.includes('socket hang up')
|
||||
|| s.includes('econnreset') || s.includes('unable to get local issuer')) {
|
||||
const isProxy = s.includes('proxy') || s.includes('unable to get local issuer')
|
||||
return {
|
||||
title: '安装失败 — 网络连接错误',
|
||||
hint: '请检查网络连接,或尝试切换 npm 镜像源后重试。',
|
||||
hint: isProxy
|
||||
? '检测到代理/证书问题。如果你使用了 VPN 或公司代理,请尝试关闭后重试,或设置 npm 信任证书:'
|
||||
: '无法连接到 npm 仓库。请检查网络连接,或尝试使用国内镜像源:',
|
||||
command: isProxy
|
||||
? 'npm config set strict-ssl false && ' + NPM_CMD
|
||||
: NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 4. npm 自身问题 =====
|
||||
|
||||
// npm 缓存损坏
|
||||
if (s.includes('integrity') || s.includes('sha512') || s.includes('cache')) {
|
||||
return {
|
||||
title: '安装失败 — npm 缓存异常',
|
||||
hint: '尝试清理 npm 缓存后重试:',
|
||||
command: 'npm cache clean --force',
|
||||
hint: '本地缓存可能损坏。清理缓存后重试:',
|
||||
command: 'npm cache clean --force && ' + NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
// 通用 fallback
|
||||
// Node.js 版本过低
|
||||
if (s.includes('engine') || s.includes('unsupported') || s.includes('required:')) {
|
||||
return {
|
||||
title: '安装失败 — Node.js 版本不兼容',
|
||||
hint: '当前 Node.js 版本过低,OpenClaw 需要 Node.js 18 或更高版本。\n请升级 Node.js:',
|
||||
command: '下载最新版: https://nodejs.org/',
|
||||
}
|
||||
}
|
||||
|
||||
// npm 版本过低或损坏
|
||||
if (s.includes('npm err') && (s.includes('cb() never called') || s.includes('code 1'))) {
|
||||
return {
|
||||
title: '安装失败 — npm 异常',
|
||||
hint: 'npm 自身可能异常。尝试更新 npm 后重试:',
|
||||
command: 'npm install -g npm@latest && ' + NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 5. 磁盘空间 =====
|
||||
if (s.includes('enospc') || s.includes('no space')) {
|
||||
return {
|
||||
title: '安装失败 — 磁盘空间不足',
|
||||
hint: '磁盘空间不足,请清理磁盘后重试。',
|
||||
}
|
||||
}
|
||||
|
||||
// ===== fallback =====
|
||||
return {
|
||||
title: '安装失败',
|
||||
hint: '请在终端手动尝试安装,查看完整错误信息:',
|
||||
command: 'npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com',
|
||||
command: NPM_CMD,
|
||||
}
|
||||
}
|
||||
|
||||
91
src/lib/icons.js
Normal file
91
src/lib/icons.js
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* 统一 SVG 图标库 — 替代所有 Emoji,保持视觉一致性
|
||||
* 基于 Lucide/Feather 风格,使用 currentColor 继承颜色
|
||||
*/
|
||||
|
||||
const PATHS = {
|
||||
// 状态图标
|
||||
'check-circle': '<path d="M22 11.08V12a10 10 0 11-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>',
|
||||
'x-circle': '<circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/>',
|
||||
'alert-triangle': '<path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>',
|
||||
'info': '<circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/>',
|
||||
|
||||
// 简单指示符
|
||||
'check': '<polyline points="20 6 9 17 4 12"/>',
|
||||
'x': '<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>',
|
||||
|
||||
// 操作图标
|
||||
'search': '<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>',
|
||||
'gift': '<polyline points="20 12 20 22 4 22 4 12"/><rect x="2" y="7" width="20" height="5"/><line x1="12" y1="22" x2="12" y2="7"/><path d="M12 7H7.5a2.5 2.5 0 010-5C11 2 12 7 12 7z"/><path d="M12 7h4.5a2.5 2.5 0 000-5C13 2 12 7 12 7z"/>',
|
||||
'zap': '<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>',
|
||||
'target': '<circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/>',
|
||||
'bar-chart': '<line x1="12" y1="20" x2="12" y2="10"/><line x1="18" y1="20" x2="18" y2="4"/><line x1="6" y1="20" x2="6" y2="16"/>',
|
||||
'home': '<path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/>',
|
||||
'paperclip': '<path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/>',
|
||||
'clipboard': '<path d="M16 4h2a2 2 0 012 2v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2h2"/><rect x="8" y="2" width="8" height="4" rx="1" ry="1"/>',
|
||||
'file': '<path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z"/><polyline points="13 2 13 9 20 9"/>',
|
||||
'file-text': '<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/>',
|
||||
'file-plain': '<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/>',
|
||||
'package': '<line x1="16.5" y1="9.4" x2="7.5" y2="4.21"/><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/>',
|
||||
'terminal': '<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>',
|
||||
'edit': '<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/>',
|
||||
'folder': '<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/>',
|
||||
'monitor': '<rect x="2" y="3" width="20" height="14" rx="2" ry="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/>',
|
||||
'plug': '<path d="M12 22v-5"/><path d="M9 8V1h6v7"/><path d="M7 8h10a0 0 0 010 0 5 5 0 01-10 0 0 0 0 010 0z"/><path d="M12 8v5"/>',
|
||||
'wrench': '<path d="M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z"/>',
|
||||
'bug': '<path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3 3 0 116 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 014-4h4a4 4 0 014 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9M6.53 9C4.6 8.8 3 7.1 3 5M6 13H2M3 21c0-2.1 1.7-3.9 3.8-4M20.97 5c0 2.1-1.6 3.8-3.5 4M22 13h-4M17.2 17c2.1.1 3.8 1.9 3.8 4"/>',
|
||||
'fire': '<path d="M8.5 14.5A2.5 2.5 0 0011 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 11-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 002.5 2.5z"/>',
|
||||
'key': '<path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 11-7.778 7.778 5.5 5.5 0 017.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"/>',
|
||||
'lock': '<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0110 0v4"/>',
|
||||
'clock': '<circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/>',
|
||||
'send': '<line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/>',
|
||||
'download': '<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>',
|
||||
'inbox': '<polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11L2 12v6a2 2 0 002 2h16a2 2 0 002-2v-6l-3.45-6.89A2 2 0 0016.76 4H7.24a2 2 0 00-1.79 1.11z"/>',
|
||||
'radio': '<circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 010 8.49m-8.48-.01a6 6 0 010-8.49m11.31-2.82a10 10 0 010 14.14m-14.14 0a10 10 0 010-14.14"/>',
|
||||
'lightbulb': '<line x1="9" y1="18" x2="15" y2="18"/><line x1="10" y1="22" x2="14" y2="22"/><path d="M15.09 14c.18-.98.65-1.74 1.41-2.5A4.65 4.65 0 0018 8 6 6 0 006 8c0 1 .23 2.23 1.5 3.5A4.61 4.61 0 018.91 14"/>',
|
||||
'globe': '<circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10 15.3 15.3 0 014-10z"/>',
|
||||
'shield': '<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>',
|
||||
'list': '<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成内联 SVG 图标
|
||||
* @param {string} name 图标名称
|
||||
* @param {number} [size=16] 图标尺寸(px)
|
||||
* @param {string} [className] 可选 CSS 类名
|
||||
* @returns {string} SVG HTML 字符串
|
||||
*/
|
||||
export function icon(name, size = 16, className) {
|
||||
const paths = PATHS[name]
|
||||
if (!paths) return ''
|
||||
const cls = className ? ` class="${className}"` : ''
|
||||
return `<svg${cls} width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-0.125em;flex-shrink:0">${paths}</svg>`
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态图标(带颜色)
|
||||
* @param {'ok'|'err'|'warn'|'info'} type 状态类型
|
||||
* @param {number} [size=16] 图标尺寸
|
||||
* @returns {string} 带颜色的 SVG 字符串
|
||||
*/
|
||||
export function statusIcon(type, size = 16) {
|
||||
const map = {
|
||||
ok: { name: 'check-circle', color: 'var(--success)' },
|
||||
err: { name: 'x-circle', color: 'var(--danger, var(--error))' },
|
||||
warn: { name: 'alert-triangle', color: 'var(--warning)' },
|
||||
info: { name: 'info', color: 'var(--info, var(--primary))' },
|
||||
}
|
||||
const cfg = map[type]
|
||||
if (!cfg) return ''
|
||||
const paths = PATHS[cfg.name]
|
||||
return `<svg width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="${cfg.color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-0.125em;flex-shrink:0">${paths}</svg>`
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于日志前缀的图标(纯文本环境也能回退)
|
||||
* @param {string} name 图标名称
|
||||
* @returns {string} 小尺寸 SVG 字符串
|
||||
*/
|
||||
export function logIcon(name, size = 14) {
|
||||
return icon(name, size)
|
||||
}
|
||||
254
src/lib/openclaw-kb.js
Normal file
254
src/lib/openclaw-kb.js
Normal file
@@ -0,0 +1,254 @@
|
||||
/**
|
||||
* OpenClaw 内置知识库
|
||||
* 来源:https://openclawcn.com/docs/
|
||||
* 供 ClawPanel AI 助手在系统提示词中使用
|
||||
*/
|
||||
|
||||
export const OPENCLAW_KB = `
|
||||
# OpenClaw 知识库(内置参考)
|
||||
|
||||
## 一、架构概览
|
||||
OpenClaw 是开源个人 AI 助手平台,核心组件:
|
||||
- **Gateway 网关**:核心后端服务,处理消息路由、Agent 执行、渠道连接
|
||||
- **CLI**:命令行工具,用于安装/配置/管理 OpenClaw
|
||||
- **Agent(智能体)**:独立的 AI 角色实例,有自己的工作区、身份、模型配置
|
||||
- **Workspace(工作区)**:Agent 的个性化存储(Skills、提示、记忆)
|
||||
- **Channel(渠道)**:消息通道(WhatsApp/Telegram/Discord/Mattermost 等)
|
||||
- **Control UI / Dashboard**:内置 Web 管理界面,端口 18789
|
||||
|
||||
## 二、目录结构
|
||||
\`\`\`
|
||||
~/.openclaw/
|
||||
├── openclaw.json # 主配置文件(JSON5,支持注释)
|
||||
├── .env # 全局环境变量
|
||||
├── workspace/ # 默认(main) Agent 的工作区
|
||||
│ ├── IDENTITY.md # Agent 身份定义
|
||||
│ ├── SOUL.md # Agent 灵魂/人格
|
||||
│ ├── USER.md # 用户信息
|
||||
│ ├── AGENTS.md # 操作规则
|
||||
│ └── ... # Skills、记忆等
|
||||
├── agents/
|
||||
│ ├── main/
|
||||
│ │ └── agent/
|
||||
│ │ ├── auth-profiles.json # 认证配置(OAuth + API Key)
|
||||
│ │ ├── models.json # 模型提供商配置
|
||||
│ │ └── auth.json # 运行时认证缓存(自动管理)
|
||||
│ └── <agentId>/
|
||||
│ ├── agent/ # 同上
|
||||
│ └── workspace/ # 自定义 Agent 的工作区
|
||||
├── credentials/
|
||||
│ ├── oauth.json # 旧版 OAuth 导入
|
||||
│ ├── whatsapp/<accountId>/ # WhatsApp 凭证
|
||||
│ └── <channel>-allowFrom.json # 配对白名单
|
||||
└── logs/ # 日志文件
|
||||
\`\`\`
|
||||
|
||||
**重要路径规则:**
|
||||
- main Agent 工作区:\`~/.openclaw/workspace\`(根级别)
|
||||
- 自定义 Agent 工作区:\`~/.openclaw/agents/<agentId>/workspace\`
|
||||
- Agent 配置目录:\`~/.openclaw/agents/<agentId>/agent/\`
|
||||
|
||||
## 三、CLI 常用命令
|
||||
| 命令 | 说明 |
|
||||
|------|------|
|
||||
| \`openclaw onboard\` | 新手引导向导(推荐首次使用) |
|
||||
| \`openclaw onboard --install-daemon\` | 引导 + 安装后台服务 |
|
||||
| \`openclaw setup\` | 初始化/配置工作区 |
|
||||
| \`openclaw gateway\` | 启动 Gateway(前台) |
|
||||
| \`openclaw gateway --port 18789 --verbose\` | 指定端口启动 |
|
||||
| \`openclaw gateway status\` | 查看 Gateway 状态 |
|
||||
| \`openclaw dashboard\` | 打开 Web Dashboard |
|
||||
| \`openclaw status\` | 系统状态概览 |
|
||||
| \`openclaw status --all\` | 完整调试报告(可粘贴) |
|
||||
| \`openclaw health\` | 健康检查 |
|
||||
| \`openclaw doctor\` | 诊断配置问题 |
|
||||
| \`openclaw doctor --fix\` | 自动修复配置问题 |
|
||||
| \`openclaw security audit --deep\` | 深度安全审计 |
|
||||
| \`openclaw channels login\` | 登录渠道(如 WhatsApp QR) |
|
||||
| \`openclaw pairing list <channel>\` | 列出配对请求 |
|
||||
| \`openclaw pairing approve <channel> <code>\` | 批准配对 |
|
||||
| \`openclaw configure --section web\` | 配置 Web 搜索(Brave API) |
|
||||
| \`openclaw config set <key> <value>\` | 设置单个配置项 |
|
||||
| \`openclaw logs\` | 查看日志 |
|
||||
| \`openclaw service start/stop/restart\` | 管理后台服务 |
|
||||
| \`openclaw message send --target <num> --message "text"\` | 发送测试消息 |
|
||||
|
||||
## 四、配置文件(openclaw.json)
|
||||
配置位于 \`~/.openclaw/openclaw.json\`,JSON5 格式(支持注释和尾逗号)。
|
||||
不存在时使用安全默认值。严格 schema 验证,未知键会阻止启动。
|
||||
|
||||
### 最小配置示例
|
||||
\`\`\`json5
|
||||
{
|
||||
agents: {
|
||||
defaults: {
|
||||
workspace: "~/.openclaw/workspace"
|
||||
}
|
||||
},
|
||||
channels: {
|
||||
whatsapp: {
|
||||
allowFrom: ["+15555550123"]
|
||||
}
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
### 关键配置项
|
||||
- **agents.defaults.workspace** — 默认工作区路径
|
||||
- **agents.defaults.model.primary** — 默认模型(格式 "provider/model")
|
||||
- **agents.defaults.sandbox** — 沙箱配置(mode: "off"|"non-main"|"all")
|
||||
- **agents.list[]** — 多 Agent 配置(id, name, workspace, model, identity, groupChat, sandbox)
|
||||
- **channels.whatsapp** — WhatsApp(allowFrom, groups, dmPolicy, accounts)
|
||||
- **channels.telegram** — Telegram Bot
|
||||
- **channels.discord** — Discord Bot
|
||||
- **channels.mattermost** — Mattermost 插件
|
||||
- **gateway.auth.token** — Gateway 认证令牌
|
||||
- **gateway.port** — Gateway 端口(默认 18789)
|
||||
- **models.providers** — 自定义模型提供商(baseUrl, apiKey, api, models[])
|
||||
- **env.vars** — 内联环境变量
|
||||
- **bindings[]** — 消息路由绑定(channel→agentId)
|
||||
|
||||
### 配置管理 RPC
|
||||
- \`config.get\` — 获取当前配置(含 hash)
|
||||
- \`config.apply\` — 全量替换配置并重启(需 baseHash)
|
||||
- \`config.patch\` — 部分更新配置并重启(JSON merge patch 语义)
|
||||
- \`config.schema\` — 获取配置的 JSON Schema
|
||||
|
||||
### 环境变量
|
||||
- \`~/.openclaw/.env\` — 全局 .env
|
||||
- 配置中支持 \`\${VAR_NAME}\` 语法引用环境变量
|
||||
- env.shellEnv.enabled=true 可从 shell 导入环境变量
|
||||
|
||||
## 五、多 Agent 路由
|
||||
\`\`\`json5
|
||||
{
|
||||
agents: {
|
||||
list: [
|
||||
{ id: "main", workspace: "~/.openclaw/workspace", sandbox: { mode: "off" } },
|
||||
{ id: "helper", name: "Helper Bot", workspace: "~/.openclaw/agents/helper/workspace" }
|
||||
]
|
||||
},
|
||||
bindings: [
|
||||
{ match: { channel: "telegram" }, agentId: "helper" },
|
||||
{ match: { channel: "whatsapp" }, agentId: "main" }
|
||||
]
|
||||
}
|
||||
\`\`\`
|
||||
- main Agent 的工作区默认 \`~/.openclaw/workspace\`
|
||||
- 其他 Agent 默认 \`~/.openclaw/workspace-<agentId>\`
|
||||
- Agent 配置目录固定为 \`~/.openclaw/agents/<agentId>/agent/\`
|
||||
|
||||
## 六、模型配置
|
||||
模型配置存储在 \`~/.openclaw/agents/<agentId>/agent/models.json\`。
|
||||
也可在 openclaw.json 的 \`models.providers\` 中定义自定义提供商。
|
||||
|
||||
自定义提供商示例:
|
||||
\`\`\`json5
|
||||
{
|
||||
models: {
|
||||
providers: {
|
||||
"my-proxy": {
|
||||
baseUrl: "http://localhost:4000/v1",
|
||||
apiKey: "sk-...",
|
||||
api: "openai-completions",
|
||||
models: [
|
||||
{ id: "gpt-4o", name: "GPT-4o", reasoning: false, input: ["text", "image"],
|
||||
contextWindow: 128000, maxTokens: 16384 }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
agents: {
|
||||
defaults: {
|
||||
model: { primary: "my-proxy/gpt-4o" }
|
||||
}
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
## 七、认证
|
||||
- **OAuth(推荐)**:通过 \`openclaw onboard\` 设置,支持 Anthropic、OpenAI Codex
|
||||
- **API Key**:直接在 auth-profiles.json 或环境变量中设置
|
||||
- **凭证位置**:\`~/.openclaw/agents/<agentId>/agent/auth-profiles.json\`
|
||||
- **旧版导入**:\`~/.openclaw/credentials/oauth.json\`
|
||||
|
||||
## 八、安装
|
||||
**macOS/Linux:**
|
||||
\`\`\`bash
|
||||
curl -fsSL https://openclaw.ai/install.sh | bash
|
||||
\`\`\`
|
||||
**Windows(WSL2 推荐):**
|
||||
\`\`\`powershell
|
||||
iwr -useb https://openclaw.ai/install.ps1 | iex
|
||||
\`\`\`
|
||||
**npm 全局安装:**
|
||||
\`\`\`bash
|
||||
npm install -g openclaw@latest
|
||||
\`\`\`
|
||||
**前置条件:** Node.js >= 22
|
||||
|
||||
## 九、后台服务
|
||||
- **macOS**:launchd 服务(openclaw 应用管理)
|
||||
- **Linux**:systemd 用户服务(需 \`sudo loginctl enable-linger $USER\`)
|
||||
- **Windows**:WSL2 内运行 Linux 步骤
|
||||
|
||||
## 十、渠道配置
|
||||
### WhatsApp
|
||||
- \`openclaw channels login\` → 扫描 QR 登录
|
||||
- 配置 allowFrom 白名单限制私聊
|
||||
- groups 配置群组行为(requireMention 等)
|
||||
- 首次私信会返回配对码,需 approve
|
||||
|
||||
### Telegram
|
||||
- 使用 Bot Token
|
||||
- \`channels.telegram.tokenFile\` 或环境变量
|
||||
- 群组支持 @提及触发
|
||||
|
||||
### Discord
|
||||
- 使用 Bot Token
|
||||
- 环境变量或配置中设置
|
||||
- 支持 guild 级别配置
|
||||
|
||||
## 十一、故障排查
|
||||
1. \`openclaw doctor\` — 诊断所有已知问题
|
||||
2. \`openclaw doctor --fix\` — 自动修复
|
||||
3. \`openclaw status --all\` — 完整状态报告
|
||||
4. \`openclaw health\` — 健康检查
|
||||
5. \`openclaw logs\` — 查看日志
|
||||
6. 配置验证失败 → Gateway 拒绝启动,仅允许诊断命令
|
||||
7. WhatsApp 不回消息 → 检查配对是否已 approve
|
||||
8. 认证错误 → 检查 auth-profiles.json 或重新 \`openclaw onboard\`
|
||||
|
||||
## 十二、ClawPanel 公益 AI 接口计划
|
||||
ClawPanel 项目组正式开放公益 AI 接口测试计划,降低用户接入 AI 能力的门槛。
|
||||
|
||||
### 核心信息
|
||||
- **GPT-AI 网关地址**:https://gpt.qt.cool/v1
|
||||
- **支持接口**:/v1/chat/completions、/v1/responses(OpenAI 兼容)
|
||||
- **支持模型**:OpenAI 全系列(GPT-5、GPT-5.1、GPT-5.2、GPT-5.3-codex、GPT-5.4 等)
|
||||
- **费用**:测试期间所有调用成本由项目组内部承担,用户无需付费
|
||||
- **限制**:无请求限制
|
||||
- **用户后台**:https://gpt.qt.cool/user(查看用量、提交工单)
|
||||
|
||||
### 官方入口
|
||||
- **ClawPanel 官网**:https://claw.qt.cool/
|
||||
- **GPT-AI 网关官网**:https://gpt.qt.cool/
|
||||
- **用户后台**:https://gpt.qt.cool/user
|
||||
- **晴辰导航站**:https://qt.cool/
|
||||
|
||||
### 测试密钥
|
||||
- ClawPanel 已内置公共体验密钥,开箱即用
|
||||
- 用户也可前往 gpt.qt.cool 签到获取独立密钥
|
||||
- 独立密钥可在用户后台管理和查询用量
|
||||
|
||||
### 接入方式
|
||||
已兼容 OpenAI API 的项目,只需替换:
|
||||
1. Base URL → https://gpt.qt.cool/v1
|
||||
2. API Key → 测试密钥
|
||||
即可完成接入。
|
||||
|
||||
### 在 ClawPanel 中配置
|
||||
- **助手设置**:打开 AI 助手设置 → 模型配置 → 使用「一键接入」按钮
|
||||
- **模型配置页**:进入模型配置 → 使用「一键添加全部模型」按钮
|
||||
- 两处均自动填入网关地址和内置密钥
|
||||
`.trim()
|
||||
@@ -249,6 +249,8 @@ function mockInvoke(cmd, args) {
|
||||
assistant_system_info: () => `OS: ${navigator.platform.includes('Win') ? 'windows' : navigator.platform.includes('Mac') ? 'macos' : 'linux'}\nArch: x86_64\nHome: ${navigator.platform.includes('Win') ? 'C:\\Users\\user' : '/Users/user'}\nHostname: mock-host\nShell: ${navigator.platform.includes('Win') ? 'powershell / cmd' : 'zsh'}\nPath separator: ${navigator.platform.includes('Win') ? '\\\\' : '/'}`,
|
||||
assistant_list_processes: ({ filter }) => filter ? `Id ProcessName\n-- -----------\n1234 ${filter}\n5678 ${filter}-helper` : 'Id ProcessName\n-- -----------\n1 System\n1234 node\n5678 openclaw',
|
||||
assistant_check_port: ({ port }) => port === 18789 ? `端口 ${port} 已被占用(正在监听)\n占用进程: node` : `端口 ${port} 未被占用(空闲)`,
|
||||
assistant_web_search: ({ query }) => `搜索「${query}」找到 3 条结果:\n\n1. **${query} - 文档**\n https://example.com/docs\n 这是关于 ${query} 的文档页面\n\n2. **${query} 常见问题**\n https://example.com/faq\n 常见问题解答\n\n3. **${query} GitHub**\n https://github.com/example\n 开源仓库`,
|
||||
assistant_fetch_url: ({ url }) => `# ${url}\n\n这是从 ${url} 抓取的网页内容(mock)。\n\n## 主要内容\n\n示例文本...`,
|
||||
// 数据目录 & 图片存储
|
||||
assistant_ensure_data_dir: () => (navigator.platform.includes('Win') ? 'C:\\Users\\user\\.openclaw\\clawpanel' : '/Users/user/.openclaw/clawpanel'),
|
||||
assistant_save_image: ({ id }) => `/mock/images/${id}.jpg`,
|
||||
@@ -347,6 +349,8 @@ export const api = {
|
||||
assistantSystemInfo: () => invoke('assistant_system_info'),
|
||||
assistantListProcesses: (filter) => invoke('assistant_list_processes', { filter: filter || null }),
|
||||
assistantCheckPort: (port) => invoke('assistant_check_port', { port }),
|
||||
assistantWebSearch: (query, maxResults) => invoke('assistant_web_search', { query, max_results: maxResults || 5 }),
|
||||
assistantFetchUrl: (url) => invoke('assistant_fetch_url', { url }),
|
||||
|
||||
// 数据目录 & 图片存储
|
||||
ensureDataDir: () => invoke('assistant_ensure_data_dir'),
|
||||
|
||||
Reference in New Issue
Block a user