Commit Graph

400 Commits

Author SHA1 Message Date
晴天
42d6758eb4 feat(hermes): dynamically load provider registry in setup & dashboard (Step 2)
Wire the new Rust `hermes_list_providers` command into the frontend and
replace the hardcoded OpenClaw PROVIDER_PRESETS usage with the
authoritative Hermes registry. Closes the G4 gap from the v3 design.

New module `src/engines/hermes/lib/providers.js`:
- Async `loadHermesProviders()` with per-session cache.
- `groupProviders()` buckets by authType + region: apiKeyIntl,
  apiKeyCn, aggregators, oauth, externalProc, custom.
- Lookup helpers: `findProviderById`, `inferProviderByBaseUrl`,
  `defaultModelFor`, plus cache reset for hot-reload scenarios.
- Exported auth_type / transport string constants mirroring Rust.

Refactored `src/engines/hermes/pages/setup.js`:
- Drops `PROVIDER_PRESETS` import; loads registry before first paint.
- Provider buttons are grouped under labeled sections (International,
  China, Aggregators), with an OAuth hint block listing the CLI
  commands users must run (e.g. `hermes auth login nous`).
- Selected provider detail panel now shows target env var
  (`ANTHROPIC_API_KEY`, `DEEPSEEK_API_KEY`, etc.) and model catalog
  size.
- `doSaveConfig` sends the provider id (not preset key) through
  `api.configureHermes`; falls back to `custom` when the base URL
  doesn't match any registered provider.
- `doFetchModels` maps provider.transport → apiType.
- Graceful fallback: when the registry is empty (Web mode), UI
  degrades to manual Base URL + API Key entry.

Refactored `src/engines/hermes/pages/dashboard.js`:
- Loads provider registry in parallel with gateway refresh.
- Preset buttons filter out the `custom` placeholder and source
  data from the async-loaded list.
- Uses `inferProviderByBaseUrl` consistently for highlight / fetch /
  save flows.

Frontend API wiring:
- `src/lib/tauri-api.js`:
  - Added `hermesListProviders` (10-minute cache).
  - Extended `hermesFetchModels` and `hermesUpdateModel` with
    optional `provider` param.
- `scripts/dev-api.js`:
  - `hermes_list_providers`: Web-mode stub returning [] (triggers
    frontend fallback UI).
  - `hermes_fetch_models` / `hermes_update_model` accept provider
    param (no-op in fetch; full YAML rewrite in update_model matching
    Rust behavior).

Verified: `npm run build` green (1.04s). Setup chunk 24.34 kB,
dashboard chunk 24.30 kB. No new warnings.
2026-04-24 20:41:06 +08:00
晴天
17759fc1e6 feat(hermes): add 22-provider registry + rewrite core commands (Step 1)
Introduce an authoritative Hermes provider registry in Rust, mirroring
upstream `hermes-agent` data (PROVIDER_REGISTRY + _PROVIDER_MODELS), and
refactor the four critical Hermes commands to be provider-aware.

Closes the G1/G2/G3 blockers identified in the v3 integration design.

New module `src-tauri/src/commands/hermes_providers.rs`:
- Static catalog of 22 providers: 17 api_key (incl. DeepSeek, Gemini,
  xAI, GLM/Z.AI, Kimi, MiniMax int'l + CN, Alibaba DashScope, Xiaomi,
  Copilot PAT, HuggingFace, OpenRouter, Vercel AI Gateway, OpenCode
  Zen/Go, Kilocode), 3 OAuth (Nous, OpenAI Codex, Qwen OAuth), 1
  external_process (Copilot ACP), and `custom` placeholder.
- Each entry carries id, display name, auth_type, base_url, env var
  priority list, transport, probe strategy, known models, aggregator
  flag, and CLI auth hint.
- Helpers: `get_provider`, `primary_api_key_env`, `primary_base_url_env`,
  `all_managed_env_keys`, `infer_provider_from_env_keys`,
  `find_provider_by_model`.
- New Tauri command `hermes_list_providers` (cached client-side).
- 5 unit tests covering registry integrity and lookup semantics.

Refactored `src-tauri/src/commands/hermes.rs`:
- `configure_hermes`: writes `model.provider` in config.yaml and routes
  API keys through the registry's `api_key_env_vars`. Skips key write
  for OAuth providers (Hermes CLI manages auth.json itself). Clears
  all managed keys on provider switch to avoid stale credentials.
- `hermes_read_config`: reads `model.provider`, then reverse-looks up
  the matching API key from the registry's env var priority list.
  Falls back to inferring provider from .env when config.yaml omits
  the provider field.
- `hermes_update_model`: accepts optional `provider` param; writes
  `model.provider` line into config.yaml (adds it when missing, updates
  in place when present, removes it for `custom`).
- `hermes_fetch_models`: accepts optional `provider` param; uses
  registry's probe strategy (`PROBE_NONE` returns static catalog for
  OAuth providers instead of hitting the API).

Registration:
- `src-tauri/src/commands/mod.rs`: declare `hermes_providers` module.
- `src-tauri/src/lib.rs`: import + register `hermes_list_providers`.

Verified: cargo fmt / cargo clippy -D warnings / cargo test all green
(5 new unit tests pass).
2026-04-24 20:40:40 +08:00
晴天
11cd6218dc feat(diagnose): detect and inform about @homebridge/ciao cmd popup bug (#250)
* feat(diagnose): detect and inform about @homebridge/ciao cmd popup bug

On Windows, OpenClaw's transitive dependency @homebridge/ciao (<=1.3.6)
calls child_process.exec('arp -a ...') every 15-30 seconds without
passing windowsHide:true, causing a cmd.exe popup to flash.

This is an upstream library bug:
- Issue: homebridge/ciao#64
- PR:    homebridge/ciao#65 (open, not merged)

ClawPanel deliberately chooses 'detect and inform' rather than silently
patching the user's node_modules. We respect the user's control over
their own machine.

Changes:
- src-tauri/src/commands/diagnose.rs: new check_ciao_windowshide_bug
  command; scans openclaw's @homebridge/ciao/lib/NetworkManager.js and
  reports whether the buggy exec pattern is present
- src-tauri/src/lib.rs: register the new command
- scripts/dev-api.js: Web-mode stub (returns affected:false since the
  bug does not manifest off-Windows)
- src/lib/tauri-api.js: add api.checkCiaoWindowsHideBug
- src/lib/ciao-bug-warning.js: new module with toast + modal flow,
  version-scoped dismiss (localStorage)
- src/locales/modules/ciaoBug.js: translations in 5 primary languages
- src/locales/index.js: register the ciaoBug module
- src/main.js: call checker 3s after splash hides

Non-Windows users see nothing; Windows users see a single warning toast
(version-dismissible) linking to three fix paths: wait for upstream,
apply patch-package, or edit NetworkManager.js manually.

* fix(diagnose): gate helper with cfg(windows), drop unneeded return

CI failures on Linux + macOS:
- openclaw_module_root was dead code when target_os != windows
  since the only caller is the #[cfg(target_os = "windows")] block
  inside check_ciao_windowshide_bug
- Explicit `return CiaoCheckResult {...};` in the non-Windows branch
  triggered clippy::needless_return

Fix:
- Add #[cfg(target_os = "windows")] to openclaw_module_root so it
  is not compiled on other platforms
- Convert the non-Windows early exit to a tail expression
2026-04-24 19:36:20 +08:00
晴天
da5adc5843 fix(gateway): conservative zombie cleanup on windows (#249)
Fix for #244 Hidden-start repeat loop:

cleanup_zombie_gateway_processes used a single /health probe to
decide whether a port-listening process is a zombie. When Gateway
reaches 'ready' but is still initializing (loading plugins, connecting
channels, warming up networks), a single probe can time out -> the
healthy Gateway gets killed -> start_service_impl Hidden-starts a new
one -> loop.

Add is_gateway_port_responsive_with_retry: 3 attempts with 800ms
interval before classifying as zombie. Maximum wait 2.4s for a
process that's genuinely healthy to show up as such.

Effect: healthy Gateway no longer misidentified during warm-up,
Hidden-start no longer triggered on an already-ready Gateway.

Refs #244
2026-04-24 19:36:07 +08:00
晴天
5235853373 fix(gateway): debounce restart with single-flight queue (#248)
Root cause for #243 / #244 / #240: model edits trigger
api.restartGateway() with only 300ms debounce. Fast consecutive
edits stack up restart calls, creating zombie Gateway processes,
failed restarts, and CPU fan spikes.

Layer A (frontend):
- New src/lib/gateway-restart-queue.js: 3s debounce + single-flight
  lock + reschedule on in-flight request
- Refactor src/pages/models.js doAutoSave: write config immediately,
  schedule restart via queue with 'Apply now' toast button
- Subscribe to queue state for unified success/failure toast
- Add i18n: models.configQueued, models.applyNow

Layer B (backend):
- src-tauri/src/commands/config.rs: wrap restart_gateway /
  reload_gateway with tokio::sync::Mutex + 2s cooldown
- Cargo.toml: add tokio 'sync' feature
- scripts/dev-api.js: same guard for Web mode (inflight promise
  reuse + 2s cooldown)

Effects:
- 10 rapid edits within 3s -> 1 restart (was 10+ with races)
- Backend serializes concurrent restart calls, no zombie spawns
- User sees single 'Apply now' toast instead of restart storm

Refs #243 #244 #240
2026-04-24 19:35:39 +08:00
friendfish
66e57adab0 fix(models): recognize google-generative-ai as google-gemini api type (#241)
Fixes #239
2026-04-24 17:39:39 +08:00
晴天
cb540564f8 docs: add FAQ for hot update rollback 2026-04-21 17:50:07 +08:00
github-actions[bot]
96aa1f061d ci: update latest.json for v0.13.4 2026-04-20 08:31:04 +00:00
晴天
53720e4e33 fix: cargo fmt formatting for list_remote_models v0.13.4 2026-04-20 16:16:57 +08:00
晴天
1d4f4a4db2 chore: release v0.13.4 2026-04-20 16:08:15 +08:00
晴天
46cd8ae01e fix(deploy): 修复 Linux 全新系统部署 npm 缓存权限问题 (#236)
现象:全新 Ubuntu 上执行一键部署脚本后,npm install 报大量
TAR_ENTRY_ERROR / ENOTEMPTY / EACCES 错误,node_modules 处于半损坏状态,
导致后续 vite build 找不到 picomatch 等依赖。

根因:OpenClaw 安装阶段使用 sudo -E npm install -g 安装全局包时,
会在用户主目录 ~/.npm 缓存目录里留下 root 拥有的文件,
后续用户态的 npm install 无法写缓存 → 安装中断 → node_modules 残缺。

修复:
- 新增 fix_npm_cache_permissions:检测 ~/.npm 中是否存在 root 拥有的文件,
  自动执行 chown 恢复当前用户权限(root/普通用户分别走 chown 与 sudo chown)
- install_clawpanel 调用一次权限预检,并对 npm install 失败场景增加一次
  清理 node_modules 后的重试,避免半损坏目录污染构建
- 升级路径里补充对不完整 node_modules 的探测(缺少 .package-lock.json 即清理)
2026-04-20 16:01:43 +08:00
晴天
1ef9ca8ede fix(models): 获取模型列表 404 改为友好提示 + 助手侧走后端绕 CORS
场景:部分服务商(如某些厂商的 Anthropic 兼容接口)不提供 /models 列表接口,
之前会直接显示 HTTP 404 Not Found / Failed to fetch 等技术错误,用户体验差。

- Rust list_remote_models:识别 404/405/501 作为"不支持自动获取"场景,
  返回带 [NOT_SUPPORTED] 前缀的友好错误,而非裸 HTTP 状态码
- 模型配置页「获取列表」:识别 [NOT_SUPPORTED] 后弹出引导对话框,
  点击「模型」按钮直接进入手动添加流程
- 助手设置页「获取列表」:改为走 Rust 后端 api.listRemoteModels,
  原先直接用前端 fetch 会被 WebView CORS 拦截(provider 不返回 CORS 头),
  改走后端既绕开 CORS 又能获得一致的友好提示
- Web 模式 dev-api.js 同步 404 识别逻辑,保证桌面 / Web 行为一致
- 补齐 models.fetchNotSupported / assistant.fetchNotSupported 多语言文案
2026-04-20 16:01:24 +08:00
晴天
12cdc72d2b fix(assistant): 模型测试按钮改用流式累积 + 增强诊断信息
- 测试请求切换到 stream: true + SSE 累积,绕开部分兼容网关
  non-streaming 分支对某些模型返回 200 + 空 body 的已知 bug,
  行为与真实对话路径一致
- 后端 test_model_verbose 显式设置 Accept-Encoding: identity,
  避免压缩协商带来的解码风险
- 用 resp.bytes() + 严格 UTF-8 decode,失败时 fallback 到
  lossy 字符串 + 前 200 字节 hex dump,方便定位非 UTF-8 响应
- 展开 reqwest error source 链,响应头与字节数原样返回前端
- 前端结果面板突出显示完整模型回复、固定 prompt 标注、
  响应头与 raw bytes hex,方便用户自查上游问题
- scripts/dev-api.js 同步 Rust 后端行为,保证 Web/桌面两侧诊断一致
2026-04-20 15:36:09 +08:00
晴天
b1902baa13 feat(http): reqwest 客户端启用 brotli / deflate 解码
对接部分 provider 时会返回 Content-Encoding: br / deflate,
缺少对应 feature 时 reqwest 只能按压缩字节原样交给调用方,
导致 text() 解码异常或 body 看似为空。显式开启两项 feature,
让所有标准压缩响应都可被正常还原。
2026-04-20 15:35:43 +08:00
晴天
f69360744f fix(assistant): 修复测试 Response Body 为 (empty) + 优化结果展示
## 用户反馈

截图显示测试结果详情里 "Response Body: (empty)",但对话实际可用。
用户:"有一个比较严重的bug...具体返回参数看不到...我感觉我们的功能不完整"

## 根因分析

1. **Accept-Encoding 未限制**:reqwest 只启用了 gzip feature(未启用 brotli),
   但 provider 经 CDN/反代可能返回 Content-Encoding: br,导致 resp.text() 解码失败。
2. **错误被静默吞**:`resp.text().await.unwrap_or_default()` 在解码失败时返回 "",
   前端展示为 (empty) 但没有任何错误提示,用户无法诊断。
3. **展示设计:reply 被截断 + 藏在折叠面板**:成功时模型回复只显示前 80 字符的
   预览,完整内容要展开 "查看完整请求/响应参数" 才能看到(还被 JSON 混在一起)。

## 修复

### Rust test_model_verbose

三个分支(OpenAI / Anthropic / Gemini)都显式加 `Accept-Encoding: identity`
头,禁止响应压缩。测试请求的响应体很小(几百字节),不压缩的性能损失可忽略。

`resp.text().await` 失败时不再 unwrap_or_default 静默吞,而是返回带 error 的
JSON:`"读取响应体失败: {e} (可能是压缩编码未支持或非 UTF-8 响应)"`

### dev-api.js test_model_verbose(Web 模式)

三个分支的 headers 都加 `'Accept-Encoding': 'identity'`,和 Rust 行为一致。

### 前端 buildTestResult 重写

- **顶部显眼展示模型回复**(边框高亮 + 完整内容 + max-height:180px 加 scroll,
  不再截断为 80 字预览):
  ```
  ✓ 连接成功 (300ms, Chat Completions)

  ╔═════════════════════════════╗
  ║ MODEL REPLY                 ║   ← 完整回复全文
  ║ 你好!我是 QC-A04...         ║
  ╚═════════════════════════════╝
  ```
- **空 respBody + 非空 reply 时给明确诊断**:"响应主体未能读取(可能是压缩
  编码异常),但已从响应流中提取到回复内容"
- **固定 prompt 脚注**:`📌 本次测试使用预设 prompt "你好,请用一句话回复"
  + max_tokens=200` —— 让用户明白这是固定诊断请求,不是真实对话。
- **详情面板的空 body 展示优化**:不再显示 "(empty)" 字面量(可能被误解为
  服务器真的返回了空字符串),改为带颜色和 italic 的 "(响应体为空)" 提示。

### i18n 新增 5 个翻译键

- testModelReply:Model Reply
- testFixedPrompt:本次测试使用预设 prompt...
- testRespBodyEmpty:响应主体未能读取...但已从流中提取回复
- testShowDetails:查看完整请求/响应参数(原来硬编码中文)
- testRespBodyEmptyDetail:(响应体为空) [原来是硬编码 "(empty)"]

均覆盖 zh-CN / en / zh-TW / ja / ko / vi。

## 验证

- npm run build 通过(assistant chunk gzip 49.43 KB)
- cargo check 通过
- 下一步:用户实测后确认 Response Body 正常显示再发 v0.13.4

## 相关

- Roadmap v0.14.0:把测试功能升级成迷你 Playground(自定义 prompt / 多轮
  对话 / 流式显示 / max_tokens 滑块)
2026-04-20 14:12:40 +08:00
晴天
d6cc0e04d3 fix(assistant): 补齐备用模型重设计缺失的变量声明
上一个 commit (b00c457) 的 edit 只替换了 renderFallbackList 函数体,
漏掉了前置的 5 个变量/函数声明,导致打开设置弹窗时抛错:

  Uncaught ReferenceError: renderPrimaryRow is not defined
      at assistant.js:3428:59
      at Array.forEach
      at showSettings

补齐:
- fallbackPrimaryModelEl (主模型只读行里的 model 显示)
- fallbackPrimaryHostEl  (主模型只读行里的 hostname 显示)
- fallbackPresetsEl      (厂商预设按钮容器)
- hostOf(url)            (从 URL 提取 hostname)
- renderPrimaryRow()     (渲染主模型只读行)

验证:npm run build 通过,settings modal 可正常打开。
2026-04-20 13:35:35 +08:00
晴天
b00c457c2b refactor(assistant): 备用模型 UI 重设计 - 厂商预设快捷添加 + 极简列表
## 用户反馈

"晴辰助手的备用模型配置,很复杂,很麻烦" —— 旧 UI 每个备用要填
6 个字段(label / baseUrl / apiKey / model / apiType / enabled),
每张卡 3 行 6 输入框 ~200px 高,添加流程比配主模型还复杂。

## 重设计原则

备用模型本质是"主模型挂了用啥兜底",应该是**选一个**而不是**重新配一个**。
复用 PROVIDER_PRESETS 里已有的 16 个厂商预设,一键预填 baseUrl / apiType。

## 新 UI 结构

```
┌─ 备用模型 (已启用 2 个) ────────────────────── [▼] ─┐
│ 主模型失败时按顺序切换到备用(401/403 除外)         │
│                                                      │
│ 📌 主模型(当前)  gpt-4o-mini     gpt.qt.cool      │  ← 只读
│ ⋮⋮ #2 [晴辰云] claude-haiku · api.anthropic   编辑 × │  ← 紧凑一行
│ ⋮⋮ #3 qwen3-30b · localhost:8000               编辑 × │
│                                                      │
│ 选择服务商快速添加:                                 │
│ [★晴辰云][OpenAI][Anthropic][DeepSeek][Google][Ollama]│
│ [📋 从主模型复制] [+ 自定义/自建] [更多服务商…]      │
└──────────────────────────────────────────────────────┘
```

## 关键变化

| 维度              | 旧                           | 新                                    |
|-------------------|------------------------------|---------------------------------------|
| 每行高度          | ~200px 卡片                  | ~36px 紧凑,点编辑才展开              |
| 添加方式          | 空白卡 6 字段填              | 点厂商 → 只填 apiKey + 选 model       |
| label 字段        | 用户手填                     | 去掉,自动用 model 显示               |
| enabled 开关      | 显式               | 去掉(删除即停用)+ 迁移旧禁用条目    |
| 主模型可见        | 无                           | 列表顶部显示完整调用链 (📌 主模型行) |
| 排序              | 隐式按数组顺序               | 显式 HTML5 drag-drop 拖拽手柄        |
| baseUrl/apiType   | 始终暴露                     | 折叠到"高级选项"(选 preset 后不用碰)|
| 快捷"从主模型复制"| 无                           | 有(解决"备用和主只想换个模型"场景)  |

## 实现细节

- 复用 `src/lib/model-presets.js` 的 `PROVIDER_PRESETS` 16 个厂商
- 主按钮区展示 6 个最常用(qtcool / openai / anthropic / deepseek
  / google / ollama),其余点"更多服务商…"展开
- 点厂商 → push draft 对象(含临时字段 `_editing`/`_brandLabel`),
  默认展开编辑态,autofocus 到 apiKey
- 保存时 .map 只挑 5 个字段(自动 strip 临时字段 + 不再写 enabled)
- 迁移:保存时过滤 `enabled === false` 的老条目,用户下次看到的
  都是启用状态(避免 UI 不暴露 enabled 导致的"隐形禁用"困惑)
- 主模型只读行实时跟随表单 `#ast-baseurl` / `#ast-model` 变化
- 每行折叠态的 model / hostname 在编辑态输入时实时更新(不重渲染
  避免输入框失焦)
- HTML5 drag-drop 拖拽排序(dragstart/dragover/drop),无第三方库

## i18n

新增 10 个翻译 key(至少覆盖 zh-CN / en / zh-TW / ja / ko / vi):
- fallbackPrimaryRow / fallbackPickProviderHint
- fallbackAddCopyPrimary / fallbackAddCustom / fallbackMoreProviders
- fallbackEditAdvanced / fallbackHideAdvanced / fallbackShowAdvanced
- fallbackUnnamedModel / fallbackPickProviderTitle

## 验证

- npm run build 通过
- assistant chunk 156.24KB → 162.02KB(gzip +1.5KB),合理
- 向后兼容:已存的 fallbackModels 数据(含 label/enabled 字段)
  可正常读取和显示,保存时会"隐式迁移"(去掉 enabled 字段,禁用
  条目被清理)

## 相关

- #Compat-3 系列(备用模型 failover)
- 用户反馈:"很复杂,很麻烦,整体重新设计下!"
2026-04-20 13:31:16 +08:00
晴天
7c63438c0e feat(assistant): 识别本地 LLM 服务端常见错误并给出修复指引
用户反馈:切本地 vLLM(Qwen/Qwen3-30B-A3B)后在助手里调用工具报错:
  "auto" tool choice requires --enable-auto-tool-choice and
  --tool-call-parser to be set

这是 vLLM 0.6+ 的默认安全策略 —— 必须在启动参数显式开启工具调用
才允许客户端在 body 里带 tools 字段。ClawPanel 发的请求符合 OpenAI
规范,不是我们的 bug,但用户面对这个原始报错字面上看不出是 vLLM
配置问题也不知道怎么修。

## 解决

新增 src/lib/model-error-diagnosis.js,提供 enhanceModelCallError:
保留原始错误文本 + 附加中文修复指引。目前覆盖 5 类常见本地部署错误:

1. **vLLM tool choice 限制**(本次用户实际踩的)
   - 给出 --enable-auto-tool-choice + --tool-call-parser 启动命令
   - Qwen / Mistral / Llama 各系列推荐的 parser 值
   - 建议临时切到"聊天"模式规避

2. **llama.cpp / LM Studio 旧版本不支持 tools**
3. **Ollama 模型不支持 tools**
4. **模型 ID 不存在 / 404**
5. **上下文超长 / token limit**

在 assistant.js 的 5 个错误抛出点统一接入:
- callChatCompletions(OpenAI 聊天模式)
- callResponsesAPI(新 /v1/responses 接口)
- callAnthropicMessages(Claude)
- callGeminiGenerate(Gemini)
- callAIWithTools(工具模式,就是用户踩坑的那条路径)

## 验证

- npm run build 通过
- assistant chunk 从 153.98KB → 156.24KB(gzip +0.86KB),合理
- 所有增强都走 try { parseJSON } 之后,不会影响原有错误处理路径

## 相关

- #Compat-5 系列的一部分(运行时错误诊断)
- 用户场景:vLLM + Qwen3 MoE,切换到本地模型后调工具
- 用户侧实际修复命令:
  vllm serve <model> --enable-auto-tool-choice --tool-call-parser hermes
2026-04-20 13:02:05 +08:00
晴天
e39233f2c1 fix(lifecycle): 卸载/升级 OpenClaw 后同步刷新 Rust 缓存与前端缓存
这是 #Compat-4(安装不识别修复)的收尾补丁。除了 setup 安装场景,
OpenClaw 的卸载和升级场景也存在类似的缓存失效问题。

## Rust 端:uninstall_openclaw_inner 卸载后刷缓存

卸载完成时只 emit 了 "upgrade-progress 100",但没有刷 enhanced_path
和 CLI 检测缓存。后果:

- `is_cli_installed`(60s TTL)在卸载后 60 秒内仍返回 true,UI 显示
  「CLI 已安装」
- 服务状态页 gateway 被误判为还在运行

在 emit 进度 100 之后立刻调用:
- `super::refresh_enhanced_path()`
- `crate::commands::service::invalidate_cli_detection_cache()`

## 前端:upgrade/uninstall/installGateway/uninstallGateway 清前端缓存

`upgrade_openclaw` / `uninstall_openclaw` / `install_gateway` /
`uninstall_gateway` 这四个 API 会改变 CLI 状态或 Gateway 状态,但
原先直接 invoke,没有清前端的 cachedInvoke 缓存。Rust 端自己刷了
缓存没用,前端仍吃旧的 `check_installation` / `get_services_status`
/ `get_version_info` 缓存(60s / 10s / 30s TTL)。

统一在调用前 invalidate 相关缓存:

- upgrade/uninstall OpenClaw → 清 check_installation / check_node /
  check_git / get_services_status / get_status_summary / get_version_info
- install/uninstall Gateway → 清 get_services_status / get_status_summary

## 验证

- `cargo check` 通过
- `npm run build` 通过
2026-04-20 12:46:06 +08:00
晴天
788b165586 chore(gitignore): 忽略 linux-schema.json 防止贡献者误提
上下文:
PR #232 的作者本地在 Linux 上 tauri build 后,src-tauri/gen/schemas/
linux-schema.json 被自动生成并带进了 PR(+2606 行)。main 分支从未
commit 过这个文件(git log 无记录)。

问题:
- 这个 schema 是 Linux 平台构建时自动生成的,不同 Linux 机器产出可能
  不一致,容易引起 PR diff 噪声和合并冲突。
- 历史原因 desktop-schema.json / macOS-schema.json / windows-schema.json
  已经被 track 了,暂不动以免其他 maintainer 的工作流受影响。
- 但 Linux schema 在本仓库从未入库,纯属贡献者本地构建副产物,应当忽略。

防护:
- 在 main 的 .gitignore 加入 src-tauri/gen/schemas/linux-schema.json
- 配合 review 里已经要求 PR #232 作者 git rm 该文件的 action item

Refs: PR #232 review comment
2026-04-20 12:39:07 +08:00
晴天
bf9cb52e25 fix(setup): 修复 Node.js/Git/OpenClaw 装完不识别(需重启客户端)
用户反馈 0.13.3 版本有三个共性 bug:
1. 手动装 Node.js → 装完 panel 不识别,必须重启客户端
2. 一键装 Git → 装完 panel 不识别,必须重启客户端
3. 一键装 OpenClaw → 装完 panel 不识别,必须重启客户端

## 根因

Tauri 进程的 `std::env::var("PATH")` 是启动时快照,不会随系统 PATH 更
新。`enhanced_path()` 虽然扫描了常见安装目录,但**不存在的目录不会被
加入缓存**(line 828 `std::path::Path::new(p).exists()` 过滤)。装完
新程序后,新路径不在 enhanced_path 缓存里,CLI 检测又依赖子进程的
PATH,导致「找不到刚装的二进制」。

三个 bug 各有其子因:

### Bug 1: Git 检测 `find_git_path` 不用 enhanced_path
对比 `find_node_path` 显式 `cmd.env("PATH", enhanced_path)`,
`find_git_path` 里的 `where git` / `which git` 子进程继承的是 Tauri
启动时快照的老 PATH。即使 `refresh_enhanced_path()` 刷了缓存,子进
程也看不到新路径。`check_git` 后续调 `Command::new("git")` 同理,且
拿到 `git_path` 绝对路径后也没用。

### Bug 2: `auto_install_git` 三平台都不刷缓存
winget/xcode-select/apt 安装成功后直接 return,没有
`refresh_enhanced_path()` / `invalidate_cli_detection_cache()`。前端
`runDetect` 虽然会调 `invalidatePathCache`,但 Bug 1 让刷缓存也白刷。

### Bug 3: `upgrade_openclaw` npm 首装分支不刷缓存
npm 分支里只有 `if need_uninstall_old`(切换源场景)分支末尾刷了
PATH 缓存。**首次安装** `need_uninstall_old == false`,if 块整个跳
过,函数直接返回,CLI 检测缓存(60s TTL)和 PATH 缓存都是旧的。前
端 `setTimeout(reload, 1500)` 触发 SPA 重建,但 Tauri 进程没重启,
缓存没刷 → `is_cli_installed()` 返回 false。

### Bug 4: 手动装 Node.js 没有 hook 点
用户点「下载 Node.js」跳浏览器,装完回到 panel,panel 不知道用户装
了。虽然顶部有「重新检测」按钮,但 UX 上容易错过。`runDetect` 里虽
然会 `await api.invalidatePathCache()`,但需要用户主动触发。

## 修复

### Rust 端

1. **`find_git_path`**:子进程 `where`/`which` 显式 `env("PATH",
   enhanced_path)`,对齐 `find_node_path` 的做法。
2. **`check_git`**:优先用 `find_git_path` 返回的绝对路径执行
   `--version`;fallback 到 `"git"` 时也注入 enhanced_path 到子进程
   PATH,确保刚装完的场景能识别。
3. **`auto_install_git`**:winget/xcode-select/apt 三个平台的成功分
   支都调 `super::refresh_enhanced_path()` +
   `invalidate_cli_detection_cache()`。
4. **`upgrade_openclaw`**:npm 分支末尾(if need_uninstall_old 块之
   后、`get_local_version` 之前)无条件刷缓存,覆盖首装场景。切换源
   场景虽然前面已刷过一次,这里重刷无害(几十 ms 文件系统扫描开销
   可接受)。

### 前端

5. **`setup.js::render`**:注册 `visibilitychange` + window `focus`
   监听器,用户从浏览器装完 Node.js 切回 panel 时自动 `runDetect`。
   handler 自带 guard(`page.isConnected` 检查),页面切走后监听器
   自动卸载,防止泄漏。加 3 秒节流,避免 focus + visibilitychange
   同时连发触发重复检测。

## 验证

- `cargo fmt --check` 通过
- `cargo clippy --all-targets -- -D warnings` 通过
- `npm run build` 通过(setup chunk 未变,setup.js 新增 ~22 行)
- 本地需要用户验证:
  - [ ] 手动装完 Node.js → 切回 panel 自动识别
  - [ ] 一键装 Git → 装完立刻识别(无需重启)
  - [ ] 一键装 OpenClaw(首次 npm 安装)→ 装完立刻识别
  - [ ] 一键装 OpenClaw(切换源)→ 装完立刻识别(原本就工作,不回归)

Refs: 0.13.3 用户实测反馈
2026-04-20 11:57:08 +08:00
晴天
dfb81066b4 feat(assistant): 备用模型组 failover + 测试按钮走 Rust 后端(修 status 0)
解决用户反馈的两个问题:晴辰助手设置里"测试"按钮在某些 provider
(如 gpt.qt.cool)上显示 Response Status: 0、Body 空,以及只能配
一个模型、挂了就没法用。

## 1. 测试按钮 status 0 根因 & 修复

**根因**:Tauri 桌面端以前走 webview 的 `fetch()` 直打外部 API,
受 Chromium 网络栈限制 —— 某些 provider 的 HTTP/2 分块编码、TLS
握手、CORS 预检、或特殊响应头会被静默拒绝并抛 TypeError: Failed
to fetch,前端 catch 后把 `respStatus` 写死 0、`respBody` 空。这
不是 provider 的问题,也不是 key 的问题,是 Chromium net stack 的
兼容性问题。

**修复**:新增 Rust 命令 `test_model_verbose`(基于已有的 reqwest
HTTP 客户端),返回结构化 JSON
  `{success, status, reqUrl, reqBody, respBody, reply, error,
   elapsedMs, usedApi}`。

  前端测试按钮无论 Tauri/Web 模式,一律调 `api.testModelVerbose()`:
  - Tauri → `invoke('test_model_verbose')` → 走原生 reqwest
  - Web → `fetch('/__api/test_model_verbose')` → 走 dev-api.js 服务端
    fetch

  这样绕过了 webview net stack 所有兼容性陷阱,拿到的永远是真实
  HTTP status(含 401/429/5xx)和原始 body,debug 面板展示完整信息。

  相比旧的 `test_model` 命令,`test_model_verbose` 不会因 400/422/429
  就吞错误返回 "连接正常",而是如实回传,便于用户排查。

## 2. 备用模型组 failover(参考 OpenClaw)

**新增配置**:`_config.fallbackModels: Array<{label, baseUrl, apiKey,
model, apiType, enabled}>`,存在 localStorage 里。

**callAI 改造**:
- 旧的 `callAI` 改名为 `_callAIOnce`,保持不变
- 新增 `callAIWithSlot(slot, messages, onChunk)`:临时把 slot 注入
  到 `_config`,调 `_callAIOnce`,finally 恢复(单线程安全,因为
  `_isStreaming` 防并发)
- 新的 `callAI`:`buildActiveSlots()` 收集主模型 + 启用且配置完整
  的 fallback,按序尝试
  - 成功 → return
  - `AbortError`(用户中止)→ 直抛,不 failover
  - 鉴权错误 401/403/`unauthorized`/`invalid api key` → 直抛,不
    failover(切也白切)
  - 其他可重试错误(网络/超时/5xx/429/400 请求错/模型不存在)→ 在
    聊天里插入 `⚠ 模型「X」失败,切换到备用「Y」` 引用块,继续下
    一个 slot
  - 全部 slot 都失败 → 抛最后一个错误,触发既有 retry bar + circuit
    breaker 流程

**UI**:设置面板 API 标签页,在晴辰云 promo 卡片下方新增一个默认
折叠的 `<details>` 区块"备用模型组":
- 顶部 summary 显示启用数量 + 折叠箭头
- 每张卡片:label / baseUrl / apiType / apiKey / model(紧凑 2 列
  栅格)+ enabled 开关 + 删除按钮
- 顶部 "添加备用模型" 按钮:默认继承主模型的 apiType,减少配置项
- 编辑态用 fallbackDrafts(深拷贝),保存按钮才过滤空卡片写回
  `_config.fallbackModels`
- 单个 input 变化时只同步 drafts + 更新计数,不重渲染列表(保持
  输入框焦点)

**文件改动**:
- `src-tauri/src/commands/config.rs`:+175 行 `test_model_verbose`
- `src-tauri/src/lib.rs`:注册新命令
- `src/lib/tauri-api.js`:+1 行 `testModelVerbose` 封装
- `scripts/dev-api.js`:+75 行 Web 模式 test_model_verbose handler
- `src/pages/assistant.js`:
  - `loadConfig`: 新增 `fallbackModels = []` 默认值
  - `callAI` 重构为 failover loop(+80 行)
  - 测试按钮:移除 90 行的 webview fetch 双分支,统一调 verbose
    API(净减 ~60 行)
  - `showSettings`: 新增备用模型 UI + 事件绑定(+85 行)
  - 保存按钮:收集 fallbackDrafts 写回 _config
- `src/locales/modules/assistant.js`:11 语言翻译(slotPrimary /
  failoverNotice / fallbackModelsTitle / fallbackModelsDesc /
  fallbackEnabledSuffix / fallbackEmpty / fallbackAdd /
  fallbackRemove / fallbackEnabled / placeholders)

## 验证

- `npm run build` 通过(assistant chunk 149.85 → 153.98 kB)
- `cargo fmt --check` 通过
- `cargo clippy --all-targets -- -D warnings` 通过
- 向后兼容:旧用户的 `localStorage` 无 `fallbackModels` 字段,
  loadConfig 会初始化空数组,既有行为不变

Refs: 模型兼容性优化 + 多模型 failover 需求
2026-04-20 03:43:43 +08:00
晴天
58f5525445 fix(assistant): 连续错误自动熔断,避免无限重试循环 (#226)
在路径拦截 + sanitize 的基础上再加一道保险:用户粘贴的不只是
markdown 本地图片、而是其他 API 不接受的内容时(如意外内容格式、
鉴权失败、quota 耗尽),单纯清洗无法解决,用户反复点"重试"会陷
入同样的错误循环。

熔断机制:
- 2 分钟滑动窗口内,同一错误指纹累计 ≥3 次触发熔断
- 错误指纹归一化:去掉数字(时间戳/请求 ID)、URL、多余空白,
  只对比核心语义
- 熔断状态下重试按钮禁用 + 警告色样式,hint 文案改为"请先检查
  API 配置或网络",点击后 toast 提示而非触发重试
- 自动恢复:修改配置(saveConfig)或新建会话(createSession)时
  调用 resetCircuit() 清空失败历史

UI 共用:抽出 createRetryBar(session, circuitOpen) 供 sendMessageDirect
和 retryAIResponse 两处复用,消除原本重复的 30 行错误处理代码。
新增 .ast-retry-bar-circuit CSS 变体(warning 色 + 禁用态)。

翻译键(11 语言):
- retryCircuitHint — 熔断状态下的重试栏 hint
- retryCircuitBlocked — 点击已禁用重试按钮时的 toast

Refs: #226
2026-04-20 03:25:40 +08:00
晴天
3a4566d26a fix(assistant): 拦截本地文件路径粘贴/拖拽,清洗消息中的本地路径引用 (#226)
用户将 C:\...\image.png 等本地路径粘贴到晴辰助手输入框,消息发送到
OpenAI 兼容 API 时触发 "Only base64, http or https URLs are supported"
错误;由于历史上下文包含坏消息,后续对话会继续报错形成循环。

三处修复:
1. paste 事件:如果剪贴板是纯文本且为本地路径(Windows/Unix/file://),
   阻止默认粘贴并 toast 提示用户
2. drop 事件:若拖入的是路径文本(无 files),同样拦截并提示
3. buildMessageContent:调用 sanitizeUserTextForApi,把
   ![alt](C:\...) 这类 markdown 图片替换为占位文本 "[本地文件(已忽略)]",
   让已经输入路径的老会话也能自愈,不再循环报错

路径识别支持:
- Windows 绝对路径(C:\... / D:/...)
- macOS/Linux 常见路径前缀(/Users /home /mnt /media /opt /tmp /var /root)
- file:// URL

翻译覆盖 11 种语言(zh-CN/zh-TW/en/ja/ko/vi/es/pt/ru/fr/de)。

Refs: #226
2026-04-20 03:07:24 +08:00
晴天
97e2fb507b fix(sidebar): 增强引擎切换器视觉发现性 (#228, #235)
用户反馈"翻遍界面"找不到引擎切换入口,原切换器样式与 sidebar 其他
元素区分度低,容易被当作静态装饰忽略。

改进:
- 切换器上方新增 "ENGINE" section 标签,明确告诉用户这是引擎选择
- 按钮背景改为 accent 色调混合,提示可交互
- 图标使用 accent 色,尺寸从 14px 增大到 16px
- chevron 透明度 0.4 → 0.75,尺寸 12px → 14px
- 打开下拉时 chevron 旋转 180°(aria-expanded 驱动)
- 按钮加 title tooltip 和 aria-haspopup / aria-expanded(可访问性)
- 字体从 xs 增到 sm,字体权重 500
- :active 时轻微下沉,给出点击反馈

翻译覆盖 11 种语言。折叠侧边栏时仍然隐藏切换器(保持原行为)。
2026-04-20 03:07:10 +08:00
晴天
024e4c9517 chore(gitignore): 忽略 pnpm-lock.yaml 和 yarn.lock
本项目使用 npm / package-lock.json,防止贡献者用 pnpm 或 yarn
安装依赖时误提交 lock 文件(见 PR #232 的 review)。
2026-04-20 03:06:58 +08:00
h91312
ef1e409dc3 refactor(chat): 聊天界面字体大小统一使用 CSS 变量 (#194)
将 chat.css 中硬编码的 font-size 改为 --font-size-xs/sm/md/lg/xl 变量,支持统一字体缩放。

Thanks @h91312 for the contribution!
2026-04-20 02:58:30 +08:00
github-actions[bot]
a798f4e09b ci: update latest.json for v0.13.3 2026-04-16 06:42:03 +00:00
晴天
08b767b212 chore(deps): update Rust dependencies for security
- Bump rand 0.9.2 -> 0.9.4 (addresses unsoundness alert)
- Update getrandom, fastrand, and other transitive deps via cargo update

Note: rand 0.8.5/0.7.3 remain as indirect deps of upstream crates
(Tauri/winit/etc) and cannot be forced to 0.9.x due to API breakage.
The vulnerable code path (custom logger calling rand::rng()) is not
exercised by ClawPanel.
v0.13.3
2026-04-16 14:19:48 +08:00
晴天
a6e200793a Merge branch 'main' of https://github.com/qingchencloud/clawpanel 2026-04-16 13:55:48 +08:00
晴天
36eaa64bf4 chore(release): v0.13.3
- 修复 #212 AI 消息气泡空白
- 修复 #215 HTTPS 下 WebSocket Mixed Content
- 修复 #219 多实例版本检测错误
- 修复引擎切换后仪表盘无限加载
- 修复热更新假更新循环(macOS/Linux)
- CI release 构建前自动同步版本号
2026-04-16 13:55:26 +08:00
github-actions[bot]
283c4df24d ci: update latest.json for v0.13.2 2026-04-13 07:27:09 +00:00
晴天
55e8365cab chore: release v0.13.2 v0.13.2 2026-04-13 15:10:20 +08:00
github-actions[bot]
fc75426aef ci: update latest.json for v0.13.1 2026-04-13 03:33:27 +00:00
晴天
7731b138ba chore: release v0.13.1 v0.13.1 2026-04-13 11:20:28 +08:00
晴天
7e527228c2 fix: show loading skeleton during engine switch and initial boot
引擎切换和初始启动时 boot() 是异步的,期间内容区完全空白。
现在在 boot() 开始前立即显示骨架屏动画,消除空白等待期。
- sidebar.js: 引擎切换点击时立即在 content 区注入骨架屏
- main.js: 初始启动 boot() 前也显示骨架屏
2026-04-13 11:14:33 +08:00
晴天
6d0fad10f7 chore(hermes): remove cron quick action from dashboard
定时任务功能暂不需要,移除仪表盘快捷操作中的"定时任务"入口
2026-04-13 11:10:17 +08:00
晴天
549801e007 fix: sidebar menu not updating after engine switch + dashboard loading skeleton
1. engine-manager: activateEngine 切换时调用 engine.boot() 检测状态
2. main.js: onEngineChange 监听器重绑 state/ready 回调,确保新引擎
   状态变化时侧边栏自动刷新
3. Hermes 仪表盘: loading 期间显示骨架屏动画,消除空白等待
4. components.css: 新增 .skeleton-line 通用骨架行样式
2026-04-13 11:08:55 +08:00
晴天
c02cb8e659 feat(setup): add local/custom install mode for Hermes Agent
安装步骤新增"本地"和"自定义"两种模式切换:
- 本地模式:原有一键安装流程(uv tool install)
- 自定义模式:输入已有 Hermes Gateway URL,测试连接后保存并跳到配置步骤
  适用于已在其他机器安装或手动安装的用户
- URL 格式校验 + 连接失败错误提示
- 新增 10 个 i18n 键
2026-04-13 11:01:47 +08:00
晴天
5df0cd36ae fix(hermes): add --force to uv tool install, improve install error handling
1. Rust + dev-api: uv tool install 添加 --force 标志,解决
   "Executable already exists: hermes.exe" 错误
2. 安装失败时显示醒目的错误提示框(红色边框+图标+详细错误信息)
3. 失败后保留日志面板 + 进度条变红,方便排查
4. 安装按钮变为"重试",点击后清除错误状态重新安装
5. 进度条 error 状态 CSS 样式
2026-04-13 10:51:41 +08:00
晴天
b676db6a46 feat(setup): simplify Hermes install — remove extras, add inline logs
1. 移除可选组件(extras)选择 UI,只安装核心包,提高安装成功率
2. 安装过程中内嵌显示实时日志 + 进度条 + 百分比
3. 安装前显示安装说明(uv 管理器、核心包、扩展后装提示)
4. 进度条样式优化:渐变色、更粗、更圆润
5. 日志面板优化:等宽字体、空状态提示、min-height
6. 新增 4 个 i18n 键(installDescSimple/installInfoUv/installInfoCore/installInfoExtrasLater)
2026-04-13 10:43:58 +08:00
晴天
3fc73b485b feat(about): Hermes config/upgrade/uninstall use modal dialogs with logs
配置按钮: 弹出模态框显示当前 Hermes 配置(Provider/URL/Key/Model),
  带"前往配置向导"按钮跳转 setup 页面
升级按钮: 确认模态框 → 进度条+实时日志(监听 hermes-install-log 事件)
卸载按钮: 两步确认(是否卸载 → 是否清除配置) → 进度条+日志
所有操作完成后自动刷新 Hermes 卡片数据
新增 6 个 i18n 键
2026-04-13 10:35:37 +08:00
晴天
d8d671a221 fix(setup): make Hermes wizard phases clickable, stop auto-redirect
1. 已完成的步骤指示器可点击返回(检测/安装/配置/启动)
2. 已安装+Gateway 运行时不再自动跳转仪表盘,停在"完成"步骤
3. 用户从 About 页点"配置"进入向导后可自由浏览每个步骤
2026-04-13 10:29:24 +08:00
晴天
6971bd32e8 feat(about): add Hermes Agent upgrade/uninstall/config buttons
Hermes 卡片已安装状态下新增三个操作按钮:
- 配置: 跳转到 Hermes 设置页
- 升级: 调用 updateHermes() 重新安装最新版
- 卸载: 调用 uninstallHermes(),支持选择是否清除配置
新增 12 个 i18n 键 (zh/en/繁/ja/ko)
2026-04-13 10:24:03 +08:00
晴天
c88a652bc5 chore: v0.13.1 release prep — fix fake update, cleanup hot update, version bump
1. main.js: import package.json → __APP_VERSION__ (统一版本来源)
2. dev-api.js: check_panel_update 实现 GitHub/Gitee API 查询
   (与 Rust 端逻辑一致,Web 模式可正常检测新版本)
3. dev-api.js: 移除 check_hermes 中未使用的 enhanced 变量
4. i18n: 清理 14 个废弃的热更新相关翻译键
5. 版本号升级: 0.13.0 → 0.13.1
   (package.json, Cargo.toml, tauri.conf.json)
2026-04-13 10:20:36 +08:00
晴天
2b6f80091a fix: fake update detection, Hermes web mode commands, cleanup hot update
1. 假更新检测: checkNewVersion 对比 Tauri 二进制版本与前端版本,
   若前端版本 > 二进制版本(热更新导致),提示用户下载完整安装包
2. 版本统一: sidebar 和 about 页面均使用 __APP_VERSION__
3. 更新机制: checkHotUpdate → checkNewVersion,改用 GitHub Releases API,
   移除 check_frontend_update / download / rollback / get_update_status 死代码
4. Hermes Web 模式: dev-api.js 实现全部 15 个 Hermes 命令处理器
   (check_python, check_hermes, install_hermes, configure_hermes,
    hermes_gateway_action, hermes_health_check, hermes_api_proxy,
    hermes_agent_run, hermes_read_config, hermes_fetch_models,
    hermes_update_model, hermes_detect_environments, hermes_set_gateway_url,
    update_hermes, uninstall_hermes)
5. i18n: 新增 versionMismatch, hotUpdateDeprecated, downloadFullInstaller
2026-04-13 09:50:36 +08:00
晴天
f5ce70dde6 fix: 修正所有 README 中 Hermes Agent GitHub 链接
org-2048/hermes-agent → nousresearch/hermes-agent(11 个语言文件)
2026-04-13 04:40:22 +08:00
github-actions[bot]
e422bd7b19 ci: update latest.json for v0.13.0 2026-04-12 20:36:30 +00:00
晴天
2de05d9ca6 fix: Hermes setup 完成后自动更新引擎状态并跳转仪表盘
- detectHermesStatus 每次调用前清除 check_hermes 缓存,确保拿到最新数据
- setup 向导检测到已安装+Gateway 运行中时,自动调用 engine.detect() 更新 _ready
- refreshHermes 同样清缓存+自动跳转,覆盖安装/配置/启动后的刷新场景
- 修复 sidebar 停留在"初始设置"的问题
v0.13.0
2026-04-13 04:28:18 +08:00
晴天
a69d0404ac fix: Hermes 模式下隐藏 OpenClaw Gateway 横幅
- setupGatewayBanner 移到引擎无关位置,update() 内部按引擎判断显隐
- 新增 onEngineChange 监听,切换引擎时自动刷新横幅状态
- Hermes 模式不再显示"Gateway 未运行"提示
2026-04-13 04:22:49 +08:00