Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(core): 本地核心低于内置插件基线时回退预打包核心(#596)

hairyff935cb2a5ab3
diff --git a/docs/AGENTS.desktop.md b/docs/AGENTS.desktop.md
index 97db7408..3c841f41 100644
--- a/docs/AGENTS.desktop.md
+++ b/docs/AGENTS.desktop.md
@@ -194,5 +194,6 @@ function ConfirmDialog(props: ConfirmDialogProps) {
* **pnpm `link:` 回读失败兜底 (Issue #264)**:pnpm 建好内置插件目录链接后回读 `package.json` 可能**恒定**失败(libuv `UV_UNKNOWN` / 退出码 -4094,实时防护 / EDR / 云盘 / 重解析点过滤驱动所致),重试无法越过且会让启动永久卡在 Plugin installation 阶段;此时由桌面端自建链接并补齐清单(`service::plugin::internal::materialize`,日志标记 `INTERNAL_PLUGIN_OFFLINE_LINK_*`),**仅在诊断里的失败路径确属本轮待装入口时**才兜底(同一签名也可能来自用户自己的 `link:` 依赖,路径不可归因时只给排除项提示、绝不吞成成功)。该路径不写 `pnpm-lock.yaml` 的 importers 条目,由下一次 pnpm 操作补齐。
* **旧版 WebKit 缺失 Iterator 补丁 (Issue #539)**:在非 Windows 平台的 WebView 初始化时注入 `compat_iterator.js.inc` 垫片,补齐 ES2025 Iterator Helpers(在 `Object.getPrototypeOf(...)` 上挂载),防止旧 macOS WebKit 崩溃。
* **Windows `.cmd` shim 行尾 (Issue #581)**:`.gitattributes` 把 `.rs` 固定为 LF,生成的 `dsh.cmd`/`pnpm.cmd` 必须在返回前统一转 CRLF(`normalize_cmd_line_endings`),LF-only 会让部分环境下 cmd.exe 解析错位、内置插件安装全部失败。
+* **本地核心低于内置插件基线 (Issue #596)**:内置插件在构建期按 catalog 的 dsh 版本编译,`scripts/build-plugins.ts` 会把整个 `@deepseek-ai` scope 从产物里删掉,client bundle 只能靠运行时模块表解析这些模块。核心低于该基线时模块表里根本没有它们(`@deepseek-ai/dsh-client-store` 首版为 dsh 0.1.2-alpha.2,0.1.5 起才是平台种子词),插件加载必然失败并把应用卡在启动阶段。`service::core::source::core_supports_bundled_plugins` 以 `version-recommend.json` 的推荐核心版本为基线(与 catalog 同源):低于基线的本地核心不参与「本地优先」并回退预打包核心(日志标记 `CORE_LOCAL_UNSUPPORTED`),`set_active("local")` 同样拒绝;持久化的 `active_core` 不改写,用户升级本地核心后自动恢复。核心面板据此标注「不兼容」并给出更新提示。
* **macOS 媒体权限配置 (Issue #214)**:必须同时在 `Info.plist` (声明 Usage Description) 与 `Entitlements.plist` (声明 `com.apple.security.device.*`) 中配置,相对路径基于 tauri bundle 运行时的 CWD 目录。
* **Linux 托盘点击适配 (Issue #386/#438)**:Linux 环境下通过 `linux_tray.rs` 基于 `tray-icon 0.25 (ksni)` 单独构建托盘,避免 muda 依赖版本冲突,通过 `Box::leak` 保活并在独立线程中处理事件。
\ No newline at end of file
diff --git a/src-tauri/src/service/core/mod.rs b/src-tauri/src/service/core/mod.rs
index c7ceb54a..8c6ae95b 100644
--- a/src-tauri/src/service/core/mod.rs
+++ b/src-tauri/src/service/core/mod.rs
@@ -8,9 +8,10 @@
//! 历史版本存放在 `dependencies/dsh-<tag>` 槽位,切换时两个目录互换。debug 与
//! release 的整个 AppData 根目录不同,因此两套构建不会互换或覆盖对方核心。
//!
-//! 启动优先级(需求):本地核心存在时优先使用本地核心;未检测到才走预打包。
-//! 用户在「核心」面板可显式切回预打包;显式选择持久化在 store 设置
-//! (`active_core`),`None` = 自动(本地优先)。
+//! 启动优先级(需求):本地核心存在且不低于内置插件基线时优先使用本地核心;未检测到
+//! 或低于基线(随包内置插件按推荐核心版本编译,见 [`source`])才走预打包。用户在
+//! 「核心」面板可显式切回预打包;显式选择持久化在 store 设置(`active_core`),
+//! `None` = 自动(本地优先)。
//!
//! 本地核心更新通过其包管理器 CLI 完成(npm `update -g` / pnpm `add -g`),
//! 不触碰用户安装本身之外的文件。
diff --git a/src-tauri/src/service/core/source.rs b/src-tauri/src/service/core/source.rs
index b72d1afd..6666e358 100644
--- a/src-tauri/src/service/core/source.rs
+++ b/src-tauri/src/service/core/source.rs
@@ -7,6 +7,7 @@
use crate::config;
use serde::Serialize;
use std::path::PathBuf;
+use std::sync::OnceLock;
use tauri::AppHandle;
use super::local::local_core;
@@ -71,17 +72,71 @@ pub struct HarnessCore {
pub error: Option<String>,
}
+/// 基线告警只发一次:`active_source` 在启动、核心列表与插件操作中反复调用。
+static UNSUPPORTED_LOCAL_WARNED: OnceLock<()> = OnceLock::new();
+
+/// 版本是否达到内置插件基线;任一版本无法解析时按「达标」处理,宁可放行也不误判。
+fn meets_baseline(version: &str, baseline: &str) -> bool {
+ match (
+ semver::Version::parse(version),
+ semver::Version::parse(baseline),
+ ) {
+ (Ok(actual), Ok(baseline)) => actual >= baseline,
+ _ => true,
+ }
+}
+
+/// 本地核心能否承载随包内置插件。
+///
+/// `resources/node_modules` 的内置插件在构建期按 catalog 的 dsh 版本编译,client
+/// bundle 把 `@deepseek-ai/*` 全部留给运行时模块表解析(`scripts/build-plugins.ts`
+/// 会把整个 scope 从产物里删掉)。核心低于该基线时这些模块在模块表里根本不存在
+/// (`@deepseek-ai/dsh-client-store` 首版为 dsh 0.1.2-alpha.2,0.1.5 起才成为平台
+/// 种子词),内置插件必然加载失败并把应用卡在启动阶段(issue #596)。基线取应用
+/// 资源里的推荐核心版本(`version-recommend.json`,与 catalog 的 dsh 版本同源)。
+pub(super) fn core_supports_bundled_plugins(app_handle: &AppHandle, version: &str) -> bool {
+ config::recommended_dsh_version(app_handle)
+ .is_none_or(|baseline| meets_baseline(version, &baseline))
+}
+
+fn warn_unsupported_local_core(app_handle: &AppHandle, version: &str) {
+ if UNSUPPORTED_LOCAL_WARNED.set(()).is_err() {
+ return;
+ }
+ log::warn!(
+ "CORE_LOCAL_UNSUPPORTED: local dsh {} is below the bundled-plugin baseline {}; using the bundled core instead (issue #596)",
+ version,
+ config::recommended_dsh_version(app_handle).unwrap_or_default(),
+ );
+}
+
/// 当前活动核心来源(需求 3:本地核心存在时优先,除非用户显式选择预打包)。
+///
+/// 本地核心低于内置插件基线时不参与优先,一律回退预打包核心:内置插件是桌面壳的
+/// 组成部分,装上也无法加载,只会把启动卡在插件阶段(issue #596)。持久化的
+/// `active_core` 设置不改写——用户升级本地核心后自动恢复「本地优先」。
pub fn active_source(app_handle: &AppHandle) -> CoreSource {
let setting = config::get_store_dat_setting(app_handle);
- let local_present = local_core(app_handle).is_some();
+ let local = local_core(app_handle);
+ let local_usable = local
+ .as_ref()
+ .is_some_and(|core| core_supports_bundled_plugins(app_handle, &core.version));
+ if local.is_some() && !local_usable {
+ warn_unsupported_local_core(
+ app_handle,
+ local
+ .as_ref()
+ .map(|core| core.version.as_str())
+ .unwrap_or_default(),
+ );
+ }
match setting.active_core.as_deref().and_then(CoreSource::parse) {
Some(CoreSource::App) => CoreSource::App,
- // 显式选择本地但本地已失效 → 回退预打包
- Some(CoreSource::Local) if local_present => CoreSource::Local,
- // 未设置(自动)或显式本地已失效:本地存在时优先
+ // 显式选择本地但本地已失效/低于基线 → 回退预打包
+ Some(CoreSource::Local) if local_usable => CoreSource::Local,
+ // 未设置(自动)或显式本地不可用:本地可用时优先
_ => {
- if local_present {
+ if local_usable {
CoreSource::Local
} else {
CoreSource::App
@@ -126,4 +181,29 @@ mod tests {
assert_eq!(CoreSource::Local.as_str(), "local");
assert_eq!(CoreSource::App.as_str(), "app");
}
+
+ #[test]
+ fn baseline_gate_accepts_equal_or_newer_versions() {
+ assert!(meets_baseline("0.1.5-rc.2", "0.1.5-rc.2"));
+ assert!(meets_baseline("0.1.5-rc.3", "0.1.5-rc.2"));
+ assert!(meets_baseline("0.1.6-alpha.2", "0.1.5-rc.2"));
+ }
+
+ /// issue #596:本地核心 0.1.0-rc.7 早于 `@deepseek-ai/dsh-client-store` 首版
+ /// (0.1.2-alpha.2),更早于它成为平台种子词的 0.1.5,内置插件必然加载失败。
+ #[test]
+ fn baseline_gate_rejects_older_versions() {
+ assert!(!meets_baseline("0.1.0-rc.7", "0.1.5-rc.2"));
+ assert!(!meets_baseline("0.1.2-rc.1", "0.1.5-rc.2"));
+ assert!(!meets_baseline("0.1.5-rc.1", "0.1.5-rc.2"));
+ }
+
+ /// 版本不可解析(旧安装记录/异常清单)时不阻断:漏放行只是回到修复前的行为,
+ /// 误拦截会把可用的本地核心判死。
+ #[test]
+ fn baseline_gate_passes_unparsable_versions() {
+ assert!(meets_baseline("", "0.1.5-rc.2"));
+ assert!(meets_baseline("not-a-version", "0.1.5-rc.2"));
+ assert!(meets_baseline("0.1.0-rc.7", ""));
+ }
}
diff --git a/src-tauri/src/service/core/version.rs b/src-tauri/src/service/core/version.rs
index de96d2fd..a61c3dea 100644
--- a/src-tauri/src/service/core/version.rs
+++ b/src-tauri/src/service/core/version.rs
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
use tauri::{AppHandle, Manager};
use super::local::{find_user_dsh_bin, local_core};
-use super::source::{active_source, CoreSource, HarnessCore};
+use super::source::{active_source, core_supports_bundled_plugins, CoreSource, HarnessCore};
/// `dependencies` 目录(激活 `dsh` 与历史 `dsh-<tag>` 槽位的共同父级)。
fn dependencies_dir(app_handle: &AppHandle) -> PathBuf {
@@ -350,8 +350,17 @@ pub async fn set_active(app_handle: &AppHandle, id: &str) -> Result<HarnessCore,
None
};
if id == "local" {
- if local_core(app_handle).is_none() {
+ let Some(core) = local_core(app_handle) else {
return Err("CORE_LOCAL_NOT_FOUND: no local core detected".to_string());
+ };
+ // 低于内置插件基线的本地核心无法加载随包插件(issue #596):显式切换同样
+ // 拒绝并给出可操作提示,而不是让用户切过去再撞一次启动失败。
+ if !core_supports_bundled_plugins(app_handle, &core.version) {
+ return Err(format!(
+ "CORE_LOCAL_UNSUPPORTED: local dsh {} is below the bundled-plugin baseline {}; update it (`npm install -g @deepseek-ai/dsh@latest`) or keep a bundled version",
+ core.version,
+ config::recommended_dsh_version(app_handle).unwrap_or_default(),
+ ));
}
stop_harness_for_core_switch(app_handle).await?;
let mut setting = config::get_store_dat_setting(app_handle);
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index edf993e4..28d12d7e 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -300,6 +300,9 @@
"core.open_dir_failed": "Failed to open the folder",
"core.remove_failed": "Failed to uninstall the core version",
"core.local_missing_hint": "No local core detected. Install @deepseek-ai/dsh globally via npm/pnpm and the desktop will prefer it automatically.",
+ "core.local_unsupported": "Unsupported",
+ "core.local_unsupported_toast": "Local core is too old",
+ "core.local_unsupported_hint": "Built-in plugins need dsh {{version}} or newer, so the bundled core is used instead. Update the local core before switching back to it.",
"app.dev_env": "Development",
"app.config": "Config",
"config.application": "Application",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 1d79be76..d82319ed 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -300,6 +300,9 @@
"core.open_dir_failed": "打开目录失败",
"core.remove_failed": "卸载核心版本失败",
"core.local_missing_hint": "未检测到本地核心。通过 npm/pnpm 全局安装 @deepseek-ai/dsh 后,桌面端将自动优先使用它。",
+ "core.local_unsupported": "不兼容",
+ "core.local_unsupported_toast": "本地核心版本过低",
+ "core.local_unsupported_hint": "内置插件需要 dsh {{version}} 及以上,已自动改用预打包核心。请先更新本地核心,再切换回它。",
"app.dev_env": "开发环境",
"app.config": "配置",
"config.application": "应用",
diff --git a/src/ui/config/core.tsx b/src/ui/config/core.tsx
index ee88a740..206cd866 100644
--- a/src/ui/config/core.tsx
+++ b/src/ui/config/core.tsx
@@ -17,7 +17,7 @@ import { useInvalidateOnSettingUpdated } from '@/hooks/use-invalidate-on-setting
import { store } from '@/store'
import { useCoreBreakingConfirm } from '@/ui/config/hooks/use-core-breaking-confirm'
import { DownloadCoreDialog } from '@/ui/dialog/update-core'
-import { compareVersions } from '@/utils/core-version'
+import { compareVersions, isCoreBelowBaseline } from '@/utils/core-version'
import { silence } from '@/utils/silence'
import { toast } from '@/utils/toast'
@@ -25,7 +25,8 @@ import { toast } from '@/utils/toast'
* 「核心」面板:管理 Harness 引擎来源与多版本。
*
* - 列表来自 `get_cores` 查询(`setting_updated` 事件一并失效刷新):
- * `local` = 用户通过 CLI 全局安装的本地核心(存在时优先使用,需求 3);
+ * `local` = 用户通过 CLI 全局安装的本地核心(存在且不低于内置插件基线时优先使用,
+ * 需求 3;低于基线时后端改用预打包核心,行内标注「不兼容」并给出更新提示);
* `app-<tag>` = deepseek-harness-pkg 各发布版本(GitHub releases 拉取失败时
* 降级为 git tags / 磁盘扫描,仅显示已下载版本)。预览版(Pre-release label
* 或 tag 命名)照常列出、可下载安装,但带「预览版」标签、不参与更新提示。
@@ -128,6 +129,16 @@ export function ConfigCore() {
async function onActivate(core: HarnessCore) {
if (core.active || busy || !core.present)
return
+ // 低于内置插件基线的本地核心无法加载随包插件(issue #596):桌面端此时使用
+ // 预打包核心,激活入口改为给出可操作提示,而不是切过去再撞一次启动失败。
+ if (isUnsupportedLocal(core)) {
+ toast(t('core.local_unsupported_toast'), {
+ variant: 'warning',
+ description: t('core.local_unsupported_hint', { version: core.recommendedVersion ?? '' }),
+ timeout: 10_000,
+ })
+ return
+ }
try {
const isRiskyVersion = core.recommendedVersion !== null
&& (core.aboveRecommended || compareVersions(core.version, core.recommendedVersion) > 0)
@@ -339,6 +350,12 @@ export function ConfigCore() {
{t('core.preview')}
</Chip>
</If>
+ {/* 低于内置插件基线的本地核心:桌面端改用预打包核心,激活会被拒绝并给出更新提示 */}
+ <If cond={isUnsupportedLocal(core)}>
+ <Chip size="sm" variant="soft" color="danger" className="shrink-0 font-medium">
+ {t('core.local_unsupported')}
+ </Chip>
+ </If>
{/* 已下载:Chip 右侧的文件夹图标,点击打开所在目录 */}
<If cond={core.present}>
<Button
@@ -451,3 +468,11 @@ export function ConfigCore() {
function displayVersion(version: HarnessCore): string {
return version.version || (version.source === 'local' ? 'local' : 'app')
}
+
+/**
+ * 本地核心是否低于内置插件基线(推荐核心版本)。低于基线时随包内置插件无法加载
+ * (见 `isCoreBelowBaseline`),桌面端自动改用预打包核心。
+ */
+function isUnsupportedLocal(core: HarnessCore): boolean {
+ return core.source === 'local' && core.present && isCoreBelowBaseline(core.version, core.recommendedVersion)
+}
diff --git a/src/utils/core-version.ts b/src/utils/core-version.ts
index 000f1d72..dbf44e3f 100644
--- a/src/utils/core-version.ts
+++ b/src/utils/core-version.ts
@@ -30,3 +30,13 @@ export function compareVersions(a: string, b: string): number {
export function isCoreBreakingVersion(version: string): boolean {
return !!version && compareVersions(version, CORE_BREAKING_BASELINE) > 0
}
+
+/**
+ * 核心是否低于内置插件基线(即推荐核心版本):随包内置插件按该基线编译,核心低于
+ * 它时 client bundle 需要的 `@deepseek-ai/*` 平台模块在运行时模块表里不存在,插件
+ * 必然加载失败并把应用卡在启动阶段(issue #596)。版本缺失或不可解析时返回 false
+ * ——漏放行只是回到修复前的行为,误拦截会把可用的本地核心判死。
+ */
+export function isCoreBelowBaseline(version: string, baseline: string | null | undefined): boolean {
+ return !!version && !!baseline && compareVersions(version, baseline) < 0
+}
diff --git a/test/core-version.test.ts b/test/core-version.test.ts
new file mode 100644
index 00000000..4bb4ad92
--- /dev/null
+++ b/test/core-version.test.ts
@@ -0,0 +1,34 @@
+import { describe, expect, it } from 'vitest'
+import { compareVersions, isCoreBelowBaseline } from '@/utils/core-version'
+
+/**
+ * issue #596:随包内置插件按推荐核心版本(`version-recommend.json`)编译,本地核心
+ * 低于该基线时 client bundle 需要的 `@deepseek-ai/*` 平台模块在运行时模块表里不存在
+ * (`@deepseek-ai/dsh-client-store` 首版为 dsh 0.1.2-alpha.2,0.1.5 起才成为平台种子
+ * 词),插件必然加载失败并把应用卡在启动阶段。
+ *
+ * 后端据此回退预打包核心,前端核心面板据此标注「不兼容」并拒绝激活;这里锁住两侧
+ * 共用的版本判定:低于基线为 true,等于/高于为 false,不可解析不误判。
+ */
+describe('isCoreBelowBaseline', () => {
+ it('detects the issue #596 local core (0.1.0-rc.7) as below the bundled baseline', () => {
+ expect(isCoreBelowBaseline('0.1.0-rc.7', '0.1.5-rc.2')).toBe(true)
+ expect(isCoreBelowBaseline('0.1.2-rc.1', '0.1.5-rc.2')).toBe(true)
+ expect(isCoreBelowBaseline('0.1.5-rc.1', '0.1.5-rc.2')).toBe(true)
+ })
+
+ it('accepts the baseline itself and newer cores', () => {
+ expect(isCoreBelowBaseline('0.1.5-rc.2', '0.1.5-rc.2')).toBe(false)
+ expect(isCoreBelowBaseline('0.1.5-rc.3', '0.1.5-rc.2')).toBe(false)
+ expect(isCoreBelowBaseline('0.1.6-alpha.2', '0.1.5-rc.2')).toBe(false)
+ })
+
+ it('never blocks when a version is missing or unparsable', () => {
+ expect(isCoreBelowBaseline('', '0.1.5-rc.2')).toBe(false)
+ expect(isCoreBelowBaseline('0.1.0-rc.7', null)).toBe(false)
+ expect(isCoreBelowBaseline('0.1.0-rc.7', '')).toBe(false)
+ // compareVersions 对不可解析值返回 0 → 视为达标,避免把可用核心判死
+ expect(compareVersions('not-a-version', '0.1.5-rc.2')).toBe(0)
+ expect(isCoreBelowBaseline('not-a-version', '0.1.5-rc.2')).toBe(false)
+ })
+})
diff --git a/vitest.config.ts b/vitest.config.ts
index 3a4085c7..1516d2b0 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -32,6 +32,8 @@ export default defineConfig({
'test/patch-layer.test.ts',
// issue #539:旧版 WebKit 缺全局 Iterator 导致插件加载失败,壳层兼容垫片回归。
'test/compat-iterator.test.ts',
+ // issue #596:本地核心低于内置插件基线导致启动失败,核心面板与后端共用的版本判定回归。
+ 'test/core-version.test.ts',
// v0.2.0:气泡托管给 dsh-pet-component,宿主侧只剩「会话快照 → pet.bubble」的映射。
'src/pet/hooks/use-bubble-tracker.test.ts',
// 桌宠素材响应头:GitHub 对中文动画名回 `content-disposition`,插件版 fetch 会因