mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-11 18:10:41 +08:00
feat: v0.8.2 — 15 fixes + 4 features + 3 improvements
Fixes: - Stop force-appending /v1 to API URLs (breaks Volcengine /v3 etc) - SSH upgrade: --unset-all + --add for 4 git insteadOf rules - Feishu: builtin detection, overlay→modal fix, select field, plugin version persistence - Docker: HTML response detection, Web mode guidance - Chat: runId dedup prevents duplicate messages - Cron: RPC params name→id - Channels: Gateway reload async (instant UI response), toggle cache invalidation - Linux: auto sudo for non-root npm installs (libc geteuid) - Control UI: dynamic hostname + auth token for remote access - npm: mirror fallback (npmmirror→npmjs.org) - QQBot: native binding friendly error message - Error diagnosis: SSH vs Git-not-installed, native binding detection Features: - About page: company info (武汉晴辰天下网络科技有限公司) - model-presets.js: shared module for models.js + assistant.js - Feishu: dual plugin support (builtin vs official @larksuiteoapi) - Assistant: provider preset quick-fill buttons Improvements: - Website: dynamic download links from latest.json + claw.qt.cool proxy - Linux deploy docs: upgrade guide, Gitee mirror, sudo notes - linux-deploy.sh: Gitee fallback + sudo npm + mirror retry
This commit is contained in:
@@ -15,20 +15,36 @@ export function diagnoseInstallError(errStr) {
|
||||
// ===== 1. Git 相关 =====
|
||||
|
||||
// git SSH 权限问题(有 git 但没配 SSH Key)
|
||||
if (s.includes('permission denied (publickey)') || s.includes('ssh://git@github')) {
|
||||
if (s.includes('permission denied (publickey)') || s.includes('ssh://git@github') || s.includes('git@github.com')) {
|
||||
return {
|
||||
title: '安装失败 — Git SSH 权限',
|
||||
hint: '依赖包用了 SSH 协议拉取代码,但你没配 GitHub SSH Key。运行以下命令改用 HTTPS:',
|
||||
command: 'git config --global url."https://github.com/".insteadOf ssh://git@github.com/',
|
||||
command: 'git config --global url."https://github.com/".insteadOf ssh://git@github.com/ && git config --global --add url."https://github.com/".insteadOf git@github.com: && git config --global --add url."https://github.com/".insteadOf git://github.com/',
|
||||
}
|
||||
}
|
||||
|
||||
// git 未安装(exit 128 + access rights)
|
||||
if (s.includes('code 128') || s.includes('exit 128') || s.includes('access rights')) {
|
||||
// git exit 128:优先判断是 SSH 失败还是 Git 未安装
|
||||
if (s.includes('code 128') || s.includes('exit 128')) {
|
||||
if (s.includes('ssh') || s.includes('git@') || s.includes('publickey') || s.includes('access rights')) {
|
||||
return {
|
||||
title: '安装失败 — Git SSH 权限',
|
||||
hint: '依赖包用了 SSH 协议拉取代码,但你没配 GitHub SSH Key。运行以下命令改用 HTTPS:',
|
||||
command: 'git config --global url."https://github.com/".insteadOf ssh://git@github.com/ && git config --global --add url."https://github.com/".insteadOf git@github.com: && git config --global --add url."https://github.com/".insteadOf git://github.com/',
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: '安装失败 — 需要安装 Git',
|
||||
hint: '部分依赖需要通过 Git 下载。请先安装 Git 后重试。',
|
||||
command: '下载 Git: https://git-scm.com/downloads',
|
||||
title: '安装失败 — Git 错误',
|
||||
hint: 'Git 操作返回错误(exit 128)。可能是 Git 未安装,或 SSH 认证失败。请确认 Git 已安装,或手动执行以下命令切换到 HTTPS 模式:',
|
||||
command: 'git config --global url."https://github.com/".insteadOf ssh://git@github.com/ && git config --global --add url."https://github.com/".insteadOf git@github.com:',
|
||||
}
|
||||
}
|
||||
|
||||
// native binding 缺失(macOS/Linux 上 OpenClaw 的原生依赖问题)
|
||||
if (s.includes('cannot find native binding') || s.includes('native binding')) {
|
||||
return {
|
||||
title: '安装失败 — 原生依赖缺失',
|
||||
hint: 'OpenClaw 的原生模块未正确安装。这通常是 npm optional dependencies 的 bug。请尝试在终端手动重装:',
|
||||
command: 'npm i -g @qingchencloud/openclaw-zh@latest --registry https://registry.npmmirror.com',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
83
src/lib/model-presets.js
Normal file
83
src/lib/model-presets.js
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 共享模型预设配置
|
||||
* models.js 和 assistant.js 共用,只需维护一套数据
|
||||
*/
|
||||
|
||||
// API 接口类型选项
|
||||
export const API_TYPES = [
|
||||
{ value: 'openai-completions', label: 'OpenAI 兼容 (最常用)' },
|
||||
{ value: 'anthropic-messages', label: 'Anthropic 原生' },
|
||||
{ value: 'openai-responses', label: 'OpenAI Responses' },
|
||||
{ value: 'google-gemini', label: 'Google Gemini' },
|
||||
]
|
||||
|
||||
// 服务商快捷预设
|
||||
export const PROVIDER_PRESETS = [
|
||||
{ key: 'openai', label: 'OpenAI 官方', baseUrl: 'https://api.openai.com/v1', api: 'openai-completions' },
|
||||
{ key: 'anthropic', label: 'Anthropic 官方', baseUrl: 'https://api.anthropic.com', api: 'anthropic-messages' },
|
||||
{ key: 'deepseek', label: 'DeepSeek', baseUrl: 'https://api.deepseek.com/v1', api: 'openai-completions' },
|
||||
{ key: 'google', label: 'Google Gemini', baseUrl: 'https://generativelanguage.googleapis.com/v1beta', api: 'google-gemini' },
|
||||
{ key: 'ollama', label: 'Ollama (本地)', baseUrl: 'http://127.0.0.1:11434/v1', api: 'openai-completions' },
|
||||
]
|
||||
|
||||
// gpt.qt.cool 推广配置
|
||||
export const QTCOOL = {
|
||||
baseUrl: 'https://gpt.qt.cool/v1',
|
||||
defaultKey: 'sk-0JDu7hyc51ZKD4iNebpFu07EUEhXmVVc',
|
||||
site: 'https://gpt.qt.cool/',
|
||||
usageUrl: 'https://gpt.qt.cool/user?key=',
|
||||
providerKey: 'qtcool',
|
||||
api: 'openai-completions',
|
||||
models: [] // 始终从 API 动态获取最新模型列表
|
||||
}
|
||||
|
||||
// 常用模型预设(按服务商分组)
|
||||
export const MODEL_PRESETS = {
|
||||
openai: [
|
||||
{ id: 'gpt-4o', name: 'GPT-4o', contextWindow: 128000 },
|
||||
{ id: 'gpt-4o-mini', name: 'GPT-4o Mini', contextWindow: 128000 },
|
||||
{ id: 'o3-mini', name: 'o3 Mini', contextWindow: 200000, reasoning: true },
|
||||
],
|
||||
anthropic: [
|
||||
{ id: 'claude-sonnet-4-5-20250514', name: 'Claude Sonnet 4.5', contextWindow: 200000 },
|
||||
{ id: 'claude-haiku-3-5-20241022', name: 'Claude Haiku 3.5', contextWindow: 200000 },
|
||||
],
|
||||
deepseek: [
|
||||
{ id: 'deepseek-chat', name: 'DeepSeek V3', contextWindow: 64000 },
|
||||
{ id: 'deepseek-reasoner', name: 'DeepSeek R1', contextWindow: 64000, reasoning: true },
|
||||
],
|
||||
google: [
|
||||
{ id: 'gemini-2.5-pro', name: 'Gemini 2.5 Pro', contextWindow: 1000000, reasoning: true },
|
||||
{ id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash', contextWindow: 1000000 },
|
||||
],
|
||||
ollama: [
|
||||
{ id: 'qwen2.5:7b', name: 'Qwen 2.5 7B', contextWindow: 32768 },
|
||||
{ id: 'llama3.2', name: 'Llama 3.2', contextWindow: 8192 },
|
||||
{ id: 'gemma3', name: 'Gemma 3', contextWindow: 32768 },
|
||||
],
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态获取 QTCOOL 模型列表
|
||||
* @param {string} [apiKey] - 自定义密钥,不传则用默认密钥
|
||||
* @returns {Promise<Array<{id:string, name:string, contextWindow:number, reasoning?:boolean}>>}
|
||||
*/
|
||||
export async function fetchQtcoolModels(apiKey) {
|
||||
const key = apiKey || QTCOOL.defaultKey
|
||||
try {
|
||||
const resp = await fetch(QTCOOL.baseUrl + '/models', {
|
||||
headers: { 'Authorization': 'Bearer ' + key },
|
||||
signal: AbortSignal.timeout(8000)
|
||||
})
|
||||
if (resp.ok) {
|
||||
const data = await resp.json()
|
||||
if (data.data && data.data.length) {
|
||||
return data.data.map(m => ({
|
||||
id: m.id, name: m.id, contextWindow: 128000,
|
||||
reasoning: m.id.includes('codex')
|
||||
})).sort((a, b) => b.id.localeCompare(a.id))
|
||||
}
|
||||
}
|
||||
} catch { /* use fallback */ }
|
||||
return QTCOOL.models
|
||||
}
|
||||
@@ -107,6 +107,11 @@ async function webInvoke(cmd, args) {
|
||||
if (!isTauri && window.__clawpanel_show_login) window.__clawpanel_show_login()
|
||||
throw new Error('需要登录')
|
||||
}
|
||||
// 检测后端是否可用:如果返回的是 HTML(非 JSON),说明后端未运行
|
||||
const ct = (resp.headers.get('content-type') || '').toLowerCase()
|
||||
if (ct.includes('text/html') || ct.includes('text/plain')) {
|
||||
throw new Error('后端服务未运行,该功能需要 Web 部署模式')
|
||||
}
|
||||
if (!resp.ok) {
|
||||
const data = await resp.json().catch(() => ({ error: `HTTP ${resp.status}` }))
|
||||
throw new Error(data.error || `HTTP ${resp.status}`)
|
||||
@@ -196,7 +201,7 @@ export const api = {
|
||||
readPlatformConfig: (platform) => invoke('read_platform_config', { platform }),
|
||||
saveMessagingPlatform: (platform, form) => { invalidate('list_configured_platforms', 'read_platform_config'); return invoke('save_messaging_platform', { platform, form }) },
|
||||
removeMessagingPlatform: (platform) => { invalidate('list_configured_platforms', 'read_platform_config'); return invoke('remove_messaging_platform', { platform }) },
|
||||
toggleMessagingPlatform: (platform, enabled) => { invalidate('list_configured_platforms'); return invoke('toggle_messaging_platform', { platform, enabled }) },
|
||||
toggleMessagingPlatform: (platform, enabled) => { invalidate('list_configured_platforms', 'read_openclaw_config', 'read_platform_config'); return invoke('toggle_messaging_platform', { platform, enabled }) },
|
||||
verifyBotToken: (platform, form) => invoke('verify_bot_token', { platform, form }),
|
||||
listConfiguredPlatforms: () => cachedInvoke('list_configured_platforms', {}, 5000),
|
||||
getChannelPluginStatus: (pluginId) => invoke('get_channel_plugin_status', { pluginId }),
|
||||
|
||||
@@ -41,9 +41,13 @@ export async function render() {
|
||||
<div class="config-section-title">快捷链接</div>
|
||||
<div id="links-list"></div>
|
||||
</div>
|
||||
<div class="config-section">
|
||||
<div class="config-section-title">关于我们</div>
|
||||
<div id="company-section"></div>
|
||||
</div>
|
||||
<div class="config-section" style="color:var(--text-tertiary);font-size:var(--font-size-xs)">
|
||||
<p>ClawPanel 基于 Tauri v2 构建,前端 Vanilla JS + Vite,后端 Rust。</p>
|
||||
<p style="margin-top:8px">MIT License © 2026 qingchencloud</p>
|
||||
<p style="margin-top:8px">MIT License © 2026 武汉晴辰天下网络科技有限公司</p>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -52,6 +56,7 @@ export async function render() {
|
||||
renderProjects(page)
|
||||
renderContribute(page)
|
||||
renderLinks(page)
|
||||
renderCompany(page)
|
||||
return page
|
||||
}
|
||||
|
||||
@@ -470,7 +475,7 @@ const PROJECTS = [
|
||||
},
|
||||
{
|
||||
name: 'OpenClaw-zh',
|
||||
desc: 'AI Agent 框架,支持多模型协作、工具调用、记忆管理-中文优化版',
|
||||
desc: '我们维护的 OpenClaw 汉化版,3000+ Star,中文界面 + 国内镜像优化',
|
||||
url: 'https://github.com/1186258278/OpenClawChineseTranslation',
|
||||
},
|
||||
{
|
||||
@@ -540,3 +545,39 @@ function renderLinks(page) {
|
||||
${LINKS.map(l => `<a class="btn ${l.primary ? 'btn-primary' : 'btn-secondary'} btn-sm" href="${l.url}" target="_blank" rel="noopener">${l.label}</a>`).join('')}
|
||||
</div>`
|
||||
}
|
||||
|
||||
function renderCompany(page) {
|
||||
const el = page.querySelector('#company-section')
|
||||
el.innerHTML = `
|
||||
<div style="display:flex;flex-direction:column;gap:12px">
|
||||
<div style="display:flex;align-items:center;gap:12px">
|
||||
<img src="/images/logo-brand.png" alt="晴辰云" style="width:40px;height:40px;border-radius:10px;flex-shrink:0">
|
||||
<div>
|
||||
<div style="font-weight:700;font-size:var(--font-size-md)">武汉晴辰天下网络科技有限公司</div>
|
||||
<div style="font-size:var(--font-size-sm);color:var(--text-secondary)">QingchenCloud</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px;font-size:var(--font-size-sm)">
|
||||
<div style="padding:12px;border-radius:var(--radius-md);border:1px solid var(--border-primary);background:var(--bg-secondary)">
|
||||
<div style="color:var(--text-tertiary);font-size:var(--font-size-xs);margin-bottom:4px">官方网站</div>
|
||||
<a href="https://qingchencloud.com" target="_blank" rel="noopener" style="color:var(--accent)">qingchencloud.com</a>
|
||||
</div>
|
||||
<div style="padding:12px;border-radius:var(--radius-md);border:1px solid var(--border-primary);background:var(--bg-secondary)">
|
||||
<div style="color:var(--text-tertiary);font-size:var(--font-size-xs);margin-bottom:4px">产品官网</div>
|
||||
<a href="https://claw.qt.cool" target="_blank" rel="noopener" style="color:var(--accent)">claw.qt.cool</a>
|
||||
</div>
|
||||
<div style="padding:12px;border-radius:var(--radius-md);border:1px solid var(--border-primary);background:var(--bg-secondary)">
|
||||
<div style="color:var(--text-tertiary);font-size:var(--font-size-xs);margin-bottom:4px">开源仓库</div>
|
||||
<a href="https://github.com/qingchencloud" target="_blank" rel="noopener" style="color:var(--accent)">github.com/qingchencloud</a>
|
||||
</div>
|
||||
<div style="padding:12px;border-radius:var(--radius-md);border:1px solid var(--border-primary);background:var(--bg-secondary)">
|
||||
<div style="color:var(--text-tertiary);font-size:var(--font-size-xs);margin-bottom:4px">商务合作</div>
|
||||
<span style="color:var(--text-primary)">请通过官网联系我们</span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size:var(--font-size-xs);color:var(--text-tertiary);line-height:1.6">
|
||||
我们是 OpenClaw 汉化版(3000+ Star)和 ClawPanel 的作者团队。日常做 AI Agent 相关的产品和开源工具,也接企业私有化部署、定制开发之类的活儿。有事直接群里找我们就行。
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { showConfirm } from '../components/modal.js'
|
||||
import { api } from '../lib/tauri-api.js'
|
||||
import { OPENCLAW_KB } from '../lib/openclaw-kb.js'
|
||||
import { icon, statusIcon } from '../lib/icons.js'
|
||||
import { QTCOOL, PROVIDER_PRESETS, API_TYPES as SHARED_API_TYPES, fetchQtcoolModels } from '../lib/model-presets.js'
|
||||
|
||||
// ── 常量 ──
|
||||
const STORAGE_KEY = 'clawpanel-assistant'
|
||||
@@ -16,15 +17,6 @@ const SESSIONS_KEY = 'clawpanel-assistant-sessions'
|
||||
const MAX_SESSIONS = 50
|
||||
const MAX_CONTEXT_TOKENS = 30 // 最近 N 条消息作为上下文
|
||||
|
||||
// ── gpt.qt.cool 推广配置 ──
|
||||
const QTCOOL = {
|
||||
baseUrl: 'https://gpt.qt.cool/v1',
|
||||
defaultKey: 'sk-0JDu7hyc51ZKD4iNebpFu07EUEhXmVVc',
|
||||
site: 'https://gpt.qt.cool/',
|
||||
usageUrl: 'https://gpt.qt.cool/user?key=',
|
||||
models: [] // 始终从 API 动态获取最新模型列表
|
||||
}
|
||||
|
||||
// ── 图片文件存储(通过 Tauri 后端持久化到 ~/.openclaw/clawpanel/images/)──
|
||||
async function saveImageToFile(id, dataUrl) {
|
||||
try { await api.saveImage(id, dataUrl) } catch (e) { console.warn('图片保存失败:', e) }
|
||||
@@ -53,12 +45,8 @@ const MODES = {
|
||||
}
|
||||
const DEFAULT_MODE = 'execute'
|
||||
|
||||
// ── API 类型 ──
|
||||
const API_TYPES = [
|
||||
{ value: 'openai-completions', label: 'OpenAI 兼容 (最常用)' },
|
||||
{ value: 'anthropic-messages', label: 'Anthropic 原生' },
|
||||
{ value: 'google-gemini', label: 'Google Gemini' },
|
||||
]
|
||||
// ── API 类型(从共享模块导入)──
|
||||
const API_TYPES = SHARED_API_TYPES
|
||||
|
||||
function normalizeApiType(raw) {
|
||||
const type = (raw || '').trim()
|
||||
@@ -1445,11 +1433,8 @@ function cleanBaseUrl(raw, apiType) {
|
||||
// Gemini: https://generativelanguage.googleapis.com/v1beta
|
||||
return base
|
||||
}
|
||||
if (/:(11434)$/i.test(base)) return `${base}/v1`
|
||||
if (!base.endsWith('/v1')) {
|
||||
if (/\/v1\/.+/.test(base)) base = base.replace(/\/v1\/.*$/, '/v1')
|
||||
else base += '/v1'
|
||||
}
|
||||
if (/:(11434)$/i.test(base) && !base.endsWith('/v1')) return `${base}/v1`
|
||||
// 不再强制追加 /v1,尊重用户填写的 URL(火山引擎等第三方用 /v3 等路径)
|
||||
return base
|
||||
}
|
||||
|
||||
@@ -2534,6 +2519,12 @@ function showSettings() {
|
||||
<div class="modal-body">
|
||||
<div class="ast-settings-form">
|
||||
<div class="ast-tab-panel active" data-panel="api">
|
||||
<div class="form-group" style="margin-bottom:8px">
|
||||
<label class="form-label">快捷选择</label>
|
||||
<div id="ast-provider-presets" style="display:flex;flex-wrap:wrap;gap:6px">
|
||||
${PROVIDER_PRESETS.map(p => `<button class="btn btn-sm btn-secondary ast-preset-btn" data-key="${p.key}" data-url="${escHtml(p.baseUrl)}" data-api="${p.api}" style="font-size:12px;padding:3px 10px">${p.label}</button>`).join('')}
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;gap:10px">
|
||||
<div class="form-group" style="flex:1">
|
||||
<label class="form-label">API Base URL</label>
|
||||
@@ -2732,11 +2723,23 @@ function showSettings() {
|
||||
})
|
||||
})
|
||||
|
||||
// API 类型切换时更新提示文本和 placeholder
|
||||
// 服务商快捷预设按钮
|
||||
const apiTypeSelect = overlay.querySelector('#ast-apitype')
|
||||
const apiHintEl = overlay.querySelector('#ast-api-hint')
|
||||
const baseUrlInput = overlay.querySelector('#ast-baseurl')
|
||||
const apiKeyInput = overlay.querySelector('#ast-apikey')
|
||||
overlay.querySelectorAll('.ast-preset-btn').forEach(btn => {
|
||||
btn.onclick = () => {
|
||||
baseUrlInput.value = btn.dataset.url
|
||||
apiTypeSelect.value = btn.dataset.api
|
||||
apiTypeSelect.dispatchEvent(new Event('change'))
|
||||
// 高亮选中
|
||||
overlay.querySelectorAll('.ast-preset-btn').forEach(b => b.style.opacity = '0.5')
|
||||
btn.style.opacity = '1'
|
||||
}
|
||||
})
|
||||
|
||||
// API 类型切换时更新提示文本和 placeholder
|
||||
apiTypeSelect.addEventListener('change', () => {
|
||||
const v = normalizeApiType(apiTypeSelect.value)
|
||||
apiHintEl.textContent = apiHintText(v)
|
||||
@@ -2924,21 +2927,9 @@ function showSettings() {
|
||||
const qtcoolKeyInput = overlay.querySelector('#ast-qtcool-key')
|
||||
const qtcoolUsageLink = overlay.querySelector('#ast-qtcool-usage')
|
||||
|
||||
// 动态获取模型列表
|
||||
// 动态获取模型列表(共享逻辑)
|
||||
;(async () => {
|
||||
let models = QTCOOL.models // fallback
|
||||
try {
|
||||
const resp = await fetch(QTCOOL.baseUrl + '/models', {
|
||||
headers: { 'Authorization': 'Bearer ' + QTCOOL.defaultKey },
|
||||
signal: AbortSignal.timeout(8000)
|
||||
})
|
||||
if (resp.ok) {
|
||||
const data = await resp.json()
|
||||
if (data.data && data.data.length) {
|
||||
models = data.data.map(m => ({ id: m.id, name: m.id })).sort((a, b) => b.id.localeCompare(a.id))
|
||||
}
|
||||
}
|
||||
} catch { /* use fallback */ }
|
||||
const models = await fetchQtcoolModels()
|
||||
qtcoolModelSelect.innerHTML = models.map((m, i) =>
|
||||
`<option value="${m.id}" style="color:#333"${i === 0 ? ' selected' : ''}>${m.name || m.id}${i === 0 ? ' ★' : ''}</option>`
|
||||
).join('')
|
||||
|
||||
@@ -48,18 +48,23 @@ const PLATFORM_REGISTRY = {
|
||||
iconName: 'message-square',
|
||||
desc: '飞书/Lark 企业消息集成,支持文档、多维表格、日历等飞书生态能力',
|
||||
guide: [
|
||||
'<b>选择插件版本</b>:<br>• <b>内置插件</b>(默认)— OpenClaw 自带,主要做聊天入口,安装简单<br>• <b>飞书官方插件</b> — 飞书团队开发,能以你的身份操作飞书(写文档、建表、约日程)<br><span style="color:var(--text-tertiary)">两者互斥,只能启用一个</span>',
|
||||
'前往 <a href="https://open.feishu.cn/app" target="_blank" style="color:var(--accent);text-decoration:underline">飞书开放平台</a>,创建企业自建应用,在「应用能力」中添加<b>机器人</b>能力',
|
||||
'在<b>凭证与基础信息</b>页面获取 <b>App ID</b> 和 <b>App Secret</b>',
|
||||
'进入<b>权限管理</b>,参照 <a href="https://open.larkoffice.com/document/server-docs/application-scope/scope-list" target="_blank" style="color:var(--accent);text-decoration:underline">权限列表</a> 开通所需权限(<code>im:message</code> 等)',
|
||||
'进入<b>事件订阅</b>,选择<b>使用长连接(WebSocket)</b>模式,订阅<b>接收消息</b>和<b>卡片回调</b>事件。如有 user access token 开关请打开',
|
||||
'将 App ID 和 App Secret 填入下方表单,校验后保存。ClawPanel 会自动安装飞书插件并写入配置',
|
||||
'保存后在飞书中向机器人发消息,获取配对码;你可以直接在下方“配对审批”区域粘贴配对码完成绑定,也可以在终端执行 <code>openclaw pairing approve feishu <配对码> --notify</code>',
|
||||
'将 App ID 和 App Secret 填入下方表单,校验后保存',
|
||||
'保存后在飞书中向机器人发消息,获取配对码;你可以直接在下方"配对审批"区域粘贴配对码完成绑定,也可以在终端执行 <code>openclaw pairing approve feishu <配对码> --notify</code>',
|
||||
],
|
||||
guideFooter: '<div style="margin-top:8px;font-size:var(--font-size-xs);color:var(--text-tertiary)">国际版 Lark 用户请将域名切换为 <b>lark</b>。详细教程:<a href="https://www.feishu.cn/content/article/7613711414611463386" target="_blank" style="color:var(--accent);text-decoration:underline">OpenClaw 飞书官方插件使用指南</a></div>',
|
||||
guideFooter: '<div style="margin-top:8px;font-size:var(--font-size-xs);color:var(--text-tertiary)">国际版 Lark 用户请将域名切换为 <b>lark</b>。详细教程:<a href="https://www.feishu.cn/content/article/7613711414611463386" target="_blank" style="color:var(--accent);text-decoration:underline">OpenClaw 飞书官方插件使用指南</a> · <a href="https://github.com/AlexAnys/openclaw-feishu" target="_blank" style="color:var(--accent);text-decoration:underline">两个插件怎么选</a></div>',
|
||||
fields: [
|
||||
{ key: 'appId', label: 'App ID', placeholder: 'cli_xxxxxxxxxx', required: true },
|
||||
{ key: 'appSecret', label: 'App Secret', placeholder: '应用密钥', secret: true, required: true },
|
||||
{ key: 'domain', label: '域名', placeholder: 'feishu(国际版选 lark)', required: false },
|
||||
{ key: 'pluginVersion', label: '插件版本', type: 'select', required: false, options: [
|
||||
{ value: 'builtin', label: '内置插件(默认,聊天入口)' },
|
||||
{ value: 'official', label: '飞书官方插件(操作文档/日历/任务)' },
|
||||
]},
|
||||
],
|
||||
pluginRequired: '@openclaw/feishu@latest',
|
||||
pluginId: 'feishu',
|
||||
@@ -293,8 +298,27 @@ async function openConfigDialog(pid, page, state) {
|
||||
</div>
|
||||
`
|
||||
|
||||
// 飞书插件版本检测:根据已安装的插件自动选择
|
||||
if (pid === 'feishu' && !existing.pluginVersion) {
|
||||
try {
|
||||
const officialStatus = await api.getChannelPluginStatus('feishu-openclaw-plugin')
|
||||
if (officialStatus?.installed) existing.pluginVersion = 'official'
|
||||
else existing.pluginVersion = localStorage.getItem('clawpanel-feishu-plugin-version') || 'builtin'
|
||||
} catch { existing.pluginVersion = 'builtin' }
|
||||
}
|
||||
|
||||
const fieldsHtml = reg.fields.map((f, i) => {
|
||||
const val = existing[f.key] || ''
|
||||
if (f.type === 'select' && f.options) {
|
||||
return `
|
||||
<div class="form-group">
|
||||
<label class="form-label">${f.label}${f.required ? ' *' : ''}</label>
|
||||
<select class="form-input" name="${f.key}" data-name="${f.key}">
|
||||
${f.options.map(o => `<option value="${o.value}" ${val === o.value ? 'selected' : ''}>${o.label}</option>`).join('')}
|
||||
</select>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
return `
|
||||
<div class="form-group">
|
||||
<label class="form-label">${f.label}${f.required ? ' *' : ''}</label>
|
||||
@@ -379,7 +403,7 @@ async function openConfigDialog(pid, page, state) {
|
||||
const collectForm = () => {
|
||||
const obj = {}
|
||||
reg.fields.forEach(f => {
|
||||
const el = modal.querySelector(`input[name="${f.key}"]`)
|
||||
const el = modal.querySelector(`input[name="${f.key}"]`) || modal.querySelector(`select[name="${f.key}"]`)
|
||||
if (el) obj[f.key] = el.value.trim()
|
||||
})
|
||||
return obj
|
||||
@@ -495,7 +519,18 @@ async function openConfigDialog(pid, page, state) {
|
||||
try {
|
||||
// 如果需要安装插件,先安装并显示日志
|
||||
if (reg.pluginRequired) {
|
||||
const pluginId = reg.pluginId || pid
|
||||
// 飞书特殊处理:根据用户选择的插件版本决定安装包
|
||||
let pluginPackage = reg.pluginRequired
|
||||
let pluginId = reg.pluginId || pid
|
||||
if (pid === 'feishu') {
|
||||
const pluginVersionField = modal.querySelector('[data-name="pluginVersion"]')
|
||||
const pluginVersion = pluginVersionField?.value || 'builtin'
|
||||
localStorage.setItem('clawpanel-feishu-plugin-version', pluginVersion)
|
||||
if (pluginVersion === 'official') {
|
||||
pluginPackage = '@larksuiteoapi/feishu-openclaw-plugin'
|
||||
pluginId = 'feishu-openclaw-plugin'
|
||||
}
|
||||
}
|
||||
const pluginStatus = await api.getChannelPluginStatus(pluginId)
|
||||
// 跳过安装:插件已安装 或 已内置(新版 OpenClaw 内置了 feishu 等插件)
|
||||
if (!pluginStatus?.installed && !pluginStatus?.builtin) {
|
||||
@@ -534,7 +569,7 @@ async function openConfigDialog(pid, page, state) {
|
||||
if (pid === 'qqbot') {
|
||||
await api.installQqbotPlugin()
|
||||
} else {
|
||||
await api.installChannelPlugin(reg.pluginRequired, pluginId)
|
||||
await api.installChannelPlugin(pluginPackage, pluginId)
|
||||
}
|
||||
} catch (e) {
|
||||
toast('插件安装失败: ' + e, 'error')
|
||||
|
||||
@@ -49,6 +49,7 @@ let _currentAiBubble = null, _currentAiText = '', _currentAiImages = [], _curren
|
||||
let _isStreaming = false, _isSending = false, _messageQueue = [], _streamStartTime = 0
|
||||
let _lastRenderTime = 0, _renderPending = false, _lastHistoryHash = ''
|
||||
let _streamSafetyTimer = null, _unsubEvent = null, _unsubReady = null, _unsubStatus = null
|
||||
let _seenRunIds = new Set()
|
||||
let _pageActive = false
|
||||
let _errorTimer = null, _lastErrorMsg = null
|
||||
let _attachments = []
|
||||
@@ -886,6 +887,17 @@ function handleChatEvent(payload) {
|
||||
if (payload.sessionKey && payload.sessionKey !== _sessionKey && _sessionKey) return
|
||||
|
||||
const { state } = payload
|
||||
const runId = payload.runId
|
||||
|
||||
// 重复 run 过滤:跳过已完成的 runId 的后续事件(Gateway 可能对同一消息触发多个 run)
|
||||
if (runId && state === 'final' && _seenRunIds.has(runId)) {
|
||||
console.log('[chat] 跳过重复 final, runId:', runId)
|
||||
return
|
||||
}
|
||||
if (runId && state === 'delta' && _seenRunIds.has(runId) && !_isStreaming) {
|
||||
console.log('[chat] 跳过已完成 run 的 delta, runId:', runId)
|
||||
return
|
||||
}
|
||||
|
||||
if (state === 'delta') {
|
||||
const c = extractChatContent(payload.message)
|
||||
@@ -935,6 +947,14 @@ function handleChatEvent(payload) {
|
||||
const hasContent = finalText || _currentAiImages.length || _currentAiVideos.length || _currentAiAudios.length || _currentAiFiles.length
|
||||
// 忽略空 final(Gateway 会为一条消息触发多个 run,部分是空 final)
|
||||
if (!_currentAiBubble && !hasContent) return
|
||||
// 标记 runId 为已处理,防止重复
|
||||
if (runId) {
|
||||
_seenRunIds.add(runId)
|
||||
if (_seenRunIds.size > 200) {
|
||||
const first = _seenRunIds.values().next().value
|
||||
_seenRunIds.delete(first)
|
||||
}
|
||||
}
|
||||
showTyping(false)
|
||||
// 如果流式阶段没有创建 bubble,从 final message 中提取
|
||||
if (!_currentAiBubble && hasContent) {
|
||||
|
||||
@@ -247,7 +247,7 @@ function renderList(page, state) {
|
||||
const btn = e.currentTarget
|
||||
btn.disabled = true
|
||||
try {
|
||||
await wsClient.request('cron.run', { name: jid })
|
||||
await wsClient.request('cron.run', { id: jid })
|
||||
toast('任务已触发执行', 'success')
|
||||
setTimeout(() => fetchJobs(page, state), 2000)
|
||||
} catch (err) { toast('触发失败: ' + err, 'error') }
|
||||
@@ -259,7 +259,7 @@ function renderList(page, state) {
|
||||
btn.disabled = true
|
||||
btn.innerHTML = icon('refresh-cw', 14)
|
||||
try {
|
||||
await wsClient.request('cron.update', { name: jid, patch: { enabled: !job.enabled } })
|
||||
await wsClient.request('cron.update', { id: jid, patch: { enabled: !job.enabled } })
|
||||
toast(job.enabled ? '已暂停' : '已启用', 'info')
|
||||
await fetchJobs(page, state)
|
||||
} catch (err) { toast('操作失败: ' + err, 'error'); btn.disabled = false; btn.innerHTML = job.enabled ? icon('pause', 14) : icon('play', 14) }
|
||||
@@ -273,7 +273,7 @@ function renderList(page, state) {
|
||||
if (!yes) return
|
||||
if (btn) btn.disabled = true
|
||||
try {
|
||||
await wsClient.request('cron.remove', { name: jid })
|
||||
await wsClient.request('cron.remove', { id: jid })
|
||||
toast('已删除', 'info')
|
||||
await fetchJobs(page, state)
|
||||
} catch (err) { toast('删除失败: ' + err, 'error'); if (btn) btn.disabled = false }
|
||||
@@ -404,7 +404,7 @@ async function openTaskDialog(job, page, state) {
|
||||
patch.schedule = { kind: 'cron', expr: schedule }
|
||||
patch.payload = { kind: 'agentTurn', message }
|
||||
if (agentId) patch.agentId = agentId
|
||||
await wsClient.request('cron.update', { name: job.id, patch })
|
||||
await wsClient.request('cron.update', { id: job.id, patch })
|
||||
toast('任务已更新', 'success')
|
||||
} else {
|
||||
const params = {
|
||||
|
||||
@@ -301,7 +301,13 @@ function bindActions(page) {
|
||||
try {
|
||||
const config = await api.readOpenclawConfig()
|
||||
const port = config?.gateway?.port || 18789
|
||||
const url = `http://127.0.0.1:${port}`
|
||||
// 远程部署时使用当前浏览器域名/IP,桌面版用 127.0.0.1
|
||||
const host = window.__TAURI_INTERNALS__ ? '127.0.0.1' : (location.hostname || '127.0.0.1')
|
||||
const proto = location.protocol === 'https:' ? 'https' : 'http'
|
||||
let url = `${proto}://${host}:${port}`
|
||||
// 如果 Gateway 配置了 token 鉴权,附加到 URL 方便直接访问
|
||||
const authToken = config?.gateway?.auth?.token
|
||||
if (authToken) url += `?token=${encodeURIComponent(authToken)}`
|
||||
// 尝试多种方式打开浏览器
|
||||
if (window.__TAURI_INTERNALS__) {
|
||||
try {
|
||||
|
||||
@@ -190,7 +190,11 @@ async function loadClusterOverview(page) {
|
||||
const detail = page.querySelector('#infra-detail')
|
||||
if (detail) detail.textContent = `${nodes.length} 节点 · ${runningContainers} 运行 / ${totalContainers} 总计`
|
||||
} catch (e) {
|
||||
page.querySelector('#cluster-stats').innerHTML = `<span class="cluster-stat" style="color:var(--error,#ef4444)">${icon('x-circle', 12)} Docker 未连接: ${esc(e.message)}</span>`
|
||||
const errMsg = String(e.message || e)
|
||||
// 后端未运行(Tauri 桌面版不含 Docker 后端,或 Web 模式后端未启动)
|
||||
const isBackendMissing = errMsg.includes('后端服务未运行') || errMsg.includes('is not valid JSON') || errMsg.includes('<!DOCTYPE')
|
||||
const displayMsg = isBackendMissing ? 'Docker 管理后端未运行' : errMsg
|
||||
page.querySelector('#cluster-stats').innerHTML = `<span class="cluster-stat" style="color:var(--error,#ef4444)">${icon('x-circle', 12)} Docker 未连接: ${esc(displayMsg)}</span>`
|
||||
|
||||
// ClawPanel 自身运行在 Docker 容器中时,显示容器内专属指引
|
||||
if (isInDocker()) {
|
||||
@@ -218,6 +222,31 @@ async function loadClusterOverview(page) {
|
||||
return
|
||||
}
|
||||
|
||||
// 后端缺失时显示专属指引(桌面版需要 Web 部署模式)
|
||||
if (isBackendMissing) {
|
||||
page.querySelector('#workers-grid').innerHTML = `
|
||||
<div class="docker-empty">
|
||||
<div class="docker-empty-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" width="48" height="48"><rect x="1" y="11" width="4" height="3" rx=".5"/><rect x="6" y="11" width="4" height="3" rx=".5"/><rect x="11" y="11" width="4" height="3" rx=".5"/><rect x="6" y="7" width="4" height="3" rx=".5"/><rect x="11" y="7" width="4" height="3" rx=".5"/><rect x="16" y="11" width="4" height="3" rx=".5"/><rect x="11" y="3" width="4" height="3" rx=".5"/><path d="M2 17c1 3 4 5 10 5s9-2 10-5"/></svg>
|
||||
</div>
|
||||
<div class="docker-empty-title">龙虾军团需要 Web 部署模式</div>
|
||||
<div class="docker-empty-desc">Docker 容器管理功能需要 ClawPanel Web 后端支持。桌面版暂不内置 Docker 管理后端。</div>
|
||||
<div class="docker-guide-section">
|
||||
<div class="docker-guide-title">${icon('info', 14)} 如何使用龙虾军团</div>
|
||||
<ol>
|
||||
<li>使用 Docker 部署 ClawPanel Web 版(推荐):<code style="font-size:11px">docker run -d -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/qingchencloud/openclaw:latest</code></li>
|
||||
<li>或使用开发模式启动:<code style="font-size:11px">npm run dev</code>,后端会自动启动 Docker 管理服务</li>
|
||||
<li>确保 Docker Desktop 已安装并运行</li>
|
||||
</ol>
|
||||
<div style="margin-top:8px;font-size:12px;color:var(--text-tertiary)">桌面版的 Docker 管理功能正在开发中,敬请期待后续版本更新。</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
page.querySelector('#docker-nodes').innerHTML = ''
|
||||
page.querySelector('#docker-containers').innerHTML = ''
|
||||
return
|
||||
}
|
||||
|
||||
const isWin = navigator.userAgent.includes('Windows')
|
||||
const isMacOS = navigator.userAgent.includes('Mac')
|
||||
const installGuide = isWin
|
||||
|
||||
@@ -6,60 +6,7 @@ import { api } from '../lib/tauri-api.js'
|
||||
import { toast } from '../components/toast.js'
|
||||
import { showModal, showConfirm } from '../components/modal.js'
|
||||
import { icon, statusIcon } from '../lib/icons.js'
|
||||
|
||||
// API 接口类型选项
|
||||
const API_TYPES = [
|
||||
{ value: 'openai-completions', label: 'OpenAI 兼容 (最常用)' },
|
||||
{ value: 'anthropic-messages', label: 'Anthropic 原生' },
|
||||
{ value: 'openai-responses', label: 'OpenAI Responses' },
|
||||
{ value: 'google-gemini', label: 'Google Gemini' },
|
||||
]
|
||||
|
||||
// 服务商快捷预设
|
||||
const PROVIDER_PRESETS = [
|
||||
{ key: 'openai', label: 'OpenAI 官方', baseUrl: 'https://api.openai.com/v1', api: 'openai-completions' },
|
||||
{ key: 'anthropic', label: 'Anthropic 官方', baseUrl: 'https://api.anthropic.com', api: 'anthropic-messages' },
|
||||
{ key: 'deepseek', label: 'DeepSeek', baseUrl: 'https://api.deepseek.com/v1', api: 'openai-completions' },
|
||||
{ key: 'google', label: 'Google Gemini', baseUrl: 'https://generativelanguage.googleapis.com/v1beta', api: 'google-gemini' },
|
||||
{ key: 'ollama', label: 'Ollama (本地)', baseUrl: 'http://127.0.0.1:11434/v1', api: 'openai-completions' },
|
||||
]
|
||||
|
||||
// gpt.qt.cool 推广配置
|
||||
const QTCOOL = {
|
||||
baseUrl: 'https://gpt.qt.cool/v1',
|
||||
defaultKey: 'sk-0JDu7hyc51ZKD4iNebpFu07EUEhXmVVc',
|
||||
site: 'https://gpt.qt.cool/',
|
||||
usageUrl: 'https://gpt.qt.cool/user?key=',
|
||||
providerKey: 'qtcool',
|
||||
api: 'openai-completions',
|
||||
models: [] // 不使用硬编码模型列表,始终从 API 动态获取最新列表
|
||||
}
|
||||
|
||||
// 常用模型预设(按服务商分组)
|
||||
const MODEL_PRESETS = {
|
||||
openai: [
|
||||
{ id: 'gpt-4o', name: 'GPT-4o', contextWindow: 128000 },
|
||||
{ id: 'gpt-4o-mini', name: 'GPT-4o Mini', contextWindow: 128000 },
|
||||
{ id: 'o3-mini', name: 'o3 Mini', contextWindow: 200000, reasoning: true },
|
||||
],
|
||||
anthropic: [
|
||||
{ id: 'claude-sonnet-4-5-20250514', name: 'Claude Sonnet 4.5', contextWindow: 200000 },
|
||||
{ id: 'claude-haiku-3-5-20241022', name: 'Claude Haiku 3.5', contextWindow: 200000 },
|
||||
],
|
||||
deepseek: [
|
||||
{ id: 'deepseek-chat', name: 'DeepSeek V3', contextWindow: 64000 },
|
||||
{ id: 'deepseek-reasoner', name: 'DeepSeek R1', contextWindow: 64000, reasoning: true },
|
||||
],
|
||||
google: [
|
||||
{ id: 'gemini-2.5-pro', name: 'Gemini 2.5 Pro', contextWindow: 1000000, reasoning: true },
|
||||
{ id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash', contextWindow: 1000000 },
|
||||
],
|
||||
ollama: [
|
||||
{ id: 'qwen2.5:7b', name: 'Qwen 2.5 7B', contextWindow: 32768 },
|
||||
{ id: 'llama3.2', name: 'Llama 3.2', contextWindow: 8192 },
|
||||
{ id: 'gemma3', name: 'Gemma 3', contextWindow: 32768 },
|
||||
],
|
||||
}
|
||||
import { API_TYPES, PROVIDER_PRESETS, QTCOOL, MODEL_PRESETS, fetchQtcoolModels } from '../lib/model-presets.js'
|
||||
|
||||
export async function render() {
|
||||
const page = document.createElement('div')
|
||||
@@ -431,13 +378,8 @@ function normalizeProviderUrls(config) {
|
||||
if (!url.endsWith('/v1')) url += '/v1'
|
||||
} else if (apiType !== 'google-gemini') {
|
||||
// Ollama 端口检测:11434 默认需要加 /v1
|
||||
if (/:11434$/.test(url)) url += '/v1'
|
||||
// 其他 OpenAI 兼容: 确保有 /v1
|
||||
if (!url.endsWith('/v1')) {
|
||||
const idx = url.indexOf('/v1/')
|
||||
if (idx >= 0) url = url.slice(0, idx + 3)
|
||||
else url += '/v1'
|
||||
}
|
||||
if (/:11434$/.test(url) && !url.endsWith('/v1')) url += '/v1'
|
||||
// 不再强制追加 /v1,尊重用户填写的 URL(火山引擎等第三方用 /v3 等路径)
|
||||
}
|
||||
p.baseUrl = url
|
||||
}
|
||||
@@ -786,23 +728,8 @@ function bindTopActions(page, state) {
|
||||
btn.textContent = '获取模型列表...'
|
||||
btn.disabled = true
|
||||
|
||||
// 动态获取模型列表,失败则用静态 fallback
|
||||
let models = QTCOOL.models
|
||||
try {
|
||||
const resp = await fetch(QTCOOL.baseUrl + '/models', {
|
||||
headers: { 'Authorization': 'Bearer ' + QTCOOL.defaultKey },
|
||||
signal: AbortSignal.timeout(8000)
|
||||
})
|
||||
if (resp.ok) {
|
||||
const data = await resp.json()
|
||||
if (data.data && data.data.length) {
|
||||
models = data.data.map(m => ({
|
||||
id: m.id, name: m.id, contextWindow: 128000,
|
||||
reasoning: m.id.includes('codex')
|
||||
})).sort((a, b) => b.id.localeCompare(a.id))
|
||||
}
|
||||
}
|
||||
} catch { /* use fallback */ }
|
||||
// 动态获取模型列表(共享逻辑)
|
||||
const models = await fetchQtcoolModels()
|
||||
|
||||
btn.innerHTML = `${icon('zap', 14)} 一键添加全部模型`
|
||||
btn.disabled = false
|
||||
|
||||
Reference in New Issue
Block a user