From 7f252472b4e236a5eca04610969481f125c73b40 Mon Sep 17 00:00:00 2001 From: winewill Date: Thu, 12 Nov 2026 15:31:21 +0800 Subject: [PATCH 1/2] fix(desktop): supply error peer and inline it in command worker --- apps/desktop/README.i18n.yaml | 4 +- apps/desktop/README.md | 2 +- apps/desktop/README.zh.md | 2 +- apps/desktop/package.json | 1 + .../tests/desktop-bundle-imports.spec.ts | 38 ++++++++++++++++++- apps/desktop/tsdown.config.ts | 2 +- pnpm-lock.yaml | 3 ++ 7 files changed, 45 insertions(+), 7 deletions(-) diff --git a/apps/desktop/README.i18n.yaml b/apps/desktop/README.i18n.yaml index df7fc71613..9729855459 100644 --- a/apps/desktop/README.i18n.yaml +++ b/apps/desktop/README.i18n.yaml @@ -33,8 +33,8 @@ en: 372297005b57a08b zh: 074a635ac17e4362 /deepseek-harness-desktop/installation-ownership: - en: 575d82acb5d61018 - zh: b1064786f63863f7 + en: ce1e85e08b5475c0 + zh: 165353b7bdb7df05 /deepseek-harness-desktop/installation-ownership/runtime-and-plugin-activation: en: 4951cd3ee659eb33 zh: 96bdd6358dad587a diff --git a/apps/desktop/README.md b/apps/desktop/README.md index d580cee23b..80a5f28e8a 100644 --- a/apps/desktop/README.md +++ b/apps/desktop/README.md @@ -143,7 +143,7 @@ Finish CLI commands before updating or uninstalling Desktop; the installer does ## Installation ownership -Electron owns `$DSH_HOME/profiles/desktop`. Its `dependencies` contains packages installed by pnpm; `dsh.profile.bundles` contains the built-in bundles followed by enabled plugins. The signed application supplies dsh, the private Desktop Host, and their production packages from `resources/app.asar/dsh`. Packaged applications select runtime profile resolution without creating package links; development profiles use filesystem links. Both host and plugins execute in the same Electron Node-mode process; Desktop does not enable `--preserve-symlinks`. The CLI cannot boot this profile. The Desktop-installed command can manage its plugins while the application is quit; npm-installed dsh cannot mutate it. +Electron owns `$DSH_HOME/profiles/desktop`. Its `dependencies` contains packages installed by pnpm; `dsh.profile.bundles` contains the built-in bundles followed by enabled plugins. The Electron main process supplies the required workspace peers of its production dependencies, including the shared error base used by Typert. Its dependencies resolve from `app.asar/node_modules`, independently of the Harness runtime under `app.asar/dsh`. The standalone command-management worker inlines atomic-write and its error base so it does not require those packages at its execution location. The signed application supplies dsh, the private Desktop Host, and their production packages from `resources/app.asar/dsh`. Packaged applications select runtime profile resolution without creating package links; development profiles use filesystem links. Both host and plugins execute in the same Electron Node-mode process; Desktop does not enable `--preserve-symlinks`. The CLI cannot boot this profile. The Desktop-installed command can manage its plugins while the application is quit; npm-installed dsh cannot mutate it. The application preload exposes boot readiness, fatal startup reporting, native directory selection, the `__DSH_HOST_PATHS__` bridge for composer path references, and the lease-scoped Browser bridge only to `dsh-app://app` documents. The same preload forwards the main-process machine description from `dshDesktop.deviceInfo()` as `name=value` fields separated by `; `: `platform`, `os`, `app_arch` (the architecture the application binary runs as, which differs from the hardware architecture under emulation), `cpu`, and `memory_gib` (total physical memory in GiB with one decimal). A field is omitted when its source is unavailable. The description carries no hostname, user name, or serial number. Product documents use the shared authenticated HTTP APIs and receive the Desktop marker, update presentation, and an action that opens native confirmation; they cannot choose artifacts or authorize installation. Plugin management uses the Web application's authenticated HTTP APIs. Electron serves update-dialog documents and assets locally at `dsh-app://shell/`, independently of Host readiness. Electron exposes no plugin-management IPC or separate management document. No renderer receives filesystem access, raw Electron IPC, a shell, or arbitrary pnpm arguments. diff --git a/apps/desktop/README.zh.md b/apps/desktop/README.zh.md index 93d0fc5d0c..579b83b84d 100644 --- a/apps/desktop/README.zh.md +++ b/apps/desktop/README.zh.md @@ -143,7 +143,7 @@ Welcome 加载共享 Toast 的配色和阴影变量,挂载在 body 下的通 ## 安装归属 -Electron 拥有 `$DSH_HOME/profiles/desktop`。其 `dependencies` 包含 pnpm 安装的包;`dsh.profile.bundles` 包含内置 bundle,后接已启用插件。签名应用从 `resources/app.asar/dsh` 提供 dsh、私有 Desktop Host 及其生产依赖。打包应用选择 runtime profile 解析,不创建包链接;开发 profile 使用文件系统链接。宿主与插件在同一个 Electron Node 模式进程中执行;Desktop 不启用 `--preserve-symlinks`。CLI 不能启动此 profile。Desktop 内置命令可在应用退出后管理其插件;npm 安装的 dsh 不能修改它。 +Electron 拥有 `$DSH_HOME/profiles/desktop`。其 `dependencies` 包含 pnpm 安装的包;`dsh.profile.bundles` 包含内置 bundle,后接已启用插件。Electron 主进程提供其生产依赖所需的工作区 peer,包括 Typert 使用的共享错误基类。主进程依赖从 `app.asar/node_modules` 解析,与 `app.asar/dsh` 下的 Harness 运行时相互独立。独立命令管理 worker 内联 atomic-write 及其错误基类,执行位置不需要另行提供这些包。签名应用从 `resources/app.asar/dsh` 提供 dsh、私有 Desktop Host 及其生产依赖。打包应用选择 runtime profile 解析,不创建包链接;开发 profile 使用文件系统链接。宿主与插件在同一个 Electron Node 模式进程中执行;Desktop 不启用 `--preserve-symlinks`。CLI 不能启动此 profile。Desktop 内置命令可在应用退出后管理其插件;npm 安装的 dsh 不能修改它。 应用 preload 只向 `dsh-app://app` 文档暴露启动就绪、致命启动失败上报、原生目录选择、用于 composer 路径引用的 `__DSH_HOST_PATHS__` 桥接和租约范围内的 Browser 桥接。同一个 preload 通过 `dshDesktop.deviceInfo()` 转发主进程采集的机器描述,按 `name=value` 字段以 `; ` 分隔:`platform`、`os`、`app_arch`(应用二进制实际运行的架构,模拟运行时与硬件架构不同)、`cpu` 和 `memory_gib`(物理内存总量,GiB,保留一位小数)。取值不可用时省略对应字段。该描述不包含主机名、用户名或序列号。产品页面还获得 Desktop 标记、更新展示数据和打开原生确认的操作,不能选择安装产物或授权安装。插件管理使用 Web 应用经过认证的 HTTP API;Electron 在 `dsh-app://shell/` 本地提供更新弹窗文档和资源,不依赖 Host 就绪。Electron 不提供插件管理 IPC 或独立管理页面。任何渲染进程都不会获得文件系统访问、原始 Electron IPC、shell 或任意 pnpm 参数。 diff --git a/apps/desktop/package.json b/apps/desktop/package.json index d49ddf0a13..1dbf6596ff 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -52,6 +52,7 @@ "semver": "^7.8.5", "ws": "^8.21.3", "@deepseek-ai/dsh-api-gateway": "workspace:*", + "@deepseek-ai/dsh-error": "workspace:*", "@deepseek-ai/cordis": "workspace:~" }, "devDependencies": { diff --git a/apps/desktop/tests/desktop-bundle-imports.spec.ts b/apps/desktop/tests/desktop-bundle-imports.spec.ts index 11c71c9662..339503d973 100644 --- a/apps/desktop/tests/desktop-bundle-imports.spec.ts +++ b/apps/desktop/tests/desktop-bundle-imports.spec.ts @@ -1,6 +1,6 @@ -import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { globSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' -import { join } from 'node:path' +import { join, resolve } from 'node:path' import { Rolldown } from 'tsdown' import { afterAll, describe, expect, it } from 'vitest' import { @@ -119,3 +119,37 @@ describe('packaged imports plugin', () => { expect(output.output.map(chunk => chunk.fileName)).toEqual(['require.js']) }) }) + +interface RuntimeManifest { + name: string + dependencies?: Record + peerDependencies?: Record + peerDependenciesMeta?: Record +} + +it('supplies required workspace peers of the Electron production dependency tree', () => { + const root = resolve(import.meta.dirname, '../../..') + const manifests = new Map(globSync(['apps/*/package.json', 'packages/*/*/package.json', 'vendor/*/package.json'], { cwd: root }) + .map((path) => { + const manifest = JSON.parse(readFileSync(join(root, path), 'utf8')) as RuntimeManifest + return [manifest.name, manifest] as const + })) + const desktop = JSON.parse(readFileSync(join(root, 'apps/desktop/package.json'), 'utf8')) as RuntimeManifest + const shipped = new Set() + const visit = (name: string): void => { + if (shipped.has(name)) return + shipped.add(name) + for (const dependency of Object.keys(manifests.get(name)?.dependencies ?? {})) visit(dependency) + } + for (const dependency of Object.keys(desktop.dependencies ?? {})) visit(dependency) + const missing: string[] = [] + for (const name of shipped) { + const manifest = manifests.get(name) + for (const peer of Object.keys(manifest?.peerDependencies ?? {})) { + if (manifests.has(peer) && !shipped.has(peer) && !manifest?.peerDependenciesMeta?.[peer]?.optional) { + missing.push(`${name} requires ${peer}`) + } + } + } + expect(missing).toEqual([]) +}) diff --git a/apps/desktop/tsdown.config.ts b/apps/desktop/tsdown.config.ts index 40ed1a0316..4683b56efb 100644 --- a/apps/desktop/tsdown.config.ts +++ b/apps/desktop/tsdown.config.ts @@ -50,7 +50,7 @@ export default defineConfig([ dts: false, clean: false, codeSplitting: false, - deps: { alwaysBundle: ['@deepseek-ai/dsh-atomic-write'] }, + deps: { alwaysBundle: ['@deepseek-ai/dsh-atomic-write', '@deepseek-ai/dsh-error'] }, }, { entry: ['lib/types/main.js'], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0145021f8..09d02a64d5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -733,6 +733,9 @@ importers: '@deepseek-ai/dsh-api-gateway': specifier: workspace:* version: link:../../packages/api/gateway + '@deepseek-ai/dsh-error': + specifier: workspace:* + version: link:../../packages/util/error electron-updater: specifier: ^6.8.9 version: 6.8.9(supports-color@9.4.0) From d4d4468247302715acde6b9f1a7d57e38fb8b1f8 Mon Sep 17 00:00:00 2001 From: winewill Date: Thu, 12 Nov 2026 16:11:08 +0800 Subject: [PATCH 2/2] test(desktop): reuse runtime closure validation for packaged peers --- apps/desktop/README.i18n.yaml | 8 ++-- apps/desktop/README.md | 4 +- apps/desktop/README.zh.md | 4 +- .../tests/desktop-bundle-imports.spec.ts | 38 +------------------ apps/desktop/tsdown.config.ts | 1 + scripts/verify-runtime-closure.spec.ts | 7 +++- 6 files changed, 19 insertions(+), 43 deletions(-) diff --git a/apps/desktop/README.i18n.yaml b/apps/desktop/README.i18n.yaml index 9729855459..9ab02cc078 100644 --- a/apps/desktop/README.i18n.yaml +++ b/apps/desktop/README.i18n.yaml @@ -27,14 +27,14 @@ en: 3724c53da4f7647b zh: 76ae549d43c99bb4 /deepseek-harness-desktop/key-technical-decisions/bundled-workspace-dependencies: - en: 9eb34500d71cbc0a - zh: 90e6a98d4c2c0f14 + en: ee552473b21809bf + zh: f99db7657947b7e6 /deepseek-harness-desktop/bundled-command-runtime: en: 372297005b57a08b zh: 074a635ac17e4362 /deepseek-harness-desktop/installation-ownership: - en: ce1e85e08b5475c0 - zh: 165353b7bdb7df05 + en: 575d82acb5d61018 + zh: b1064786f63863f7 /deepseek-harness-desktop/installation-ownership/runtime-and-plugin-activation: en: 4951cd3ee659eb33 zh: 96bdd6358dad587a diff --git a/apps/desktop/README.md b/apps/desktop/README.md index 80a5f28e8a..20d6018932 100644 --- a/apps/desktop/README.md +++ b/apps/desktop/README.md @@ -101,6 +101,8 @@ The macOS PNG uses an inset rounded background for legacy ICNS packaging, with r electron-builder copies only the manifest's `dependencies` into `app.asar/node_modules`, so the Electron main bundle `lib/main.js` inlines its workspace devDependencies and leaves `electron`, Node builtins, and those `dependencies` as its only bare imports; a sandboxed preload may leave only `electron`, `events`, `timers`, and `url`, the modules its `require` polyfill resolves. The main bundle resolves the inlined packages from their `lib/` output, so the root `build:lib:host` bundles `apps/desktop` after the concurrent workspace tsdown pass, and [`desktop-bundle-imports`](scripts/desktop-bundle-imports.mjs) fails any Desktop bundle whose static, dynamic, or `require()` import the packaged application cannot resolve. Without that check an import rolldown could not resolve ships as an external specifier and fails at launch with `ERR_MODULE_NOT_FOUND`. The [archived bundle-order decision](../../.agents/notes/archived/process/2026-09-22-desktop-main-bundle-after-workspace-tsdown.md) records the alternatives. +The Electron main process declares `@deepseek-ai/dsh-error` as a production dependency to supply the required peer of `@deepseek-ai/dsh-typert-protocol`. The standalone command-management worker at `resources/runtime/cli/command-manager.js` has no adjacent `node_modules`, so its bundle inlines `@deepseek-ai/dsh-atomic-write` and `@deepseek-ai/dsh-error`. + Signed Windows packaging scans the primary runtime and application production dependencies for PE content, including files without a conventional extension. The final scan covers the entire unpacked application. Directory links, malformed `MZ` files and non-PE `.exe`, `.dll` or `.pyd` files stop packaging; data files beginning with `MZ` are also rejected unless they contain a valid PE header. It preserves valid vendor signatures and signs unsigned code before sealing runtime hashes or executing smoke checks. Public-key inspection uses batches of 32 files with at most four processes; hardware-token signing remains serial, and each new signature must match the configured certificate and carry a timestamp. Hardware signing and verification failures stop the run; isolated timestamp requests follow the [bounded retry policy](windows-signing/README.md#windows-ev-signing). Electron-builder preserves copied runtime executables only after signature and exact-byte verification. A final PE-signature audit and a fresh-cache ASAR payload and Host smoke must pass before the release completion record is written. Development, preparation-only and unsigned builds do not use the hardware token and can be blocked by Windows code-integrity policy; no build mode disables that policy. Passing smoke checks does not establish compatibility with every enterprise policy. Desktop carries independent Python, Node.js and pnpm distributions. Python includes numpy, pandas, python-docx, python-pptx, openpyxl, Pillow, lxml and XlsxWriter with their complete dependencies. The `load_workspace_dependencies` tool installs this payload offline on first use under `$DSH_HOME/dsh-runtimes/dsh-primary-runtime` (normally `~/.dsh/dsh-runtimes/dsh-primary-runtime`) and returns absolute interpreter, pnpm script and library paths plus `pythonDistributions`, the bundled distribution names and versions. The version report excludes user-installed additions. Office tasks prefer these libraries unless user or workspace instructions select another environment. Execute the pnpm script with the returned Node executable. The returned Node library directory is reserved for bundled libraries, not pnpm's global installation directory. @@ -143,7 +145,7 @@ Finish CLI commands before updating or uninstalling Desktop; the installer does ## Installation ownership -Electron owns `$DSH_HOME/profiles/desktop`. Its `dependencies` contains packages installed by pnpm; `dsh.profile.bundles` contains the built-in bundles followed by enabled plugins. The Electron main process supplies the required workspace peers of its production dependencies, including the shared error base used by Typert. Its dependencies resolve from `app.asar/node_modules`, independently of the Harness runtime under `app.asar/dsh`. The standalone command-management worker inlines atomic-write and its error base so it does not require those packages at its execution location. The signed application supplies dsh, the private Desktop Host, and their production packages from `resources/app.asar/dsh`. Packaged applications select runtime profile resolution without creating package links; development profiles use filesystem links. Both host and plugins execute in the same Electron Node-mode process; Desktop does not enable `--preserve-symlinks`. The CLI cannot boot this profile. The Desktop-installed command can manage its plugins while the application is quit; npm-installed dsh cannot mutate it. +Electron owns `$DSH_HOME/profiles/desktop`. Its `dependencies` contains packages installed by pnpm; `dsh.profile.bundles` contains the built-in bundles followed by enabled plugins. The signed application supplies dsh, the private Desktop Host, and their production packages from `resources/app.asar/dsh`. Packaged applications select runtime profile resolution without creating package links; development profiles use filesystem links. Both host and plugins execute in the same Electron Node-mode process; Desktop does not enable `--preserve-symlinks`. The CLI cannot boot this profile. The Desktop-installed command can manage its plugins while the application is quit; npm-installed dsh cannot mutate it. The application preload exposes boot readiness, fatal startup reporting, native directory selection, the `__DSH_HOST_PATHS__` bridge for composer path references, and the lease-scoped Browser bridge only to `dsh-app://app` documents. The same preload forwards the main-process machine description from `dshDesktop.deviceInfo()` as `name=value` fields separated by `; `: `platform`, `os`, `app_arch` (the architecture the application binary runs as, which differs from the hardware architecture under emulation), `cpu`, and `memory_gib` (total physical memory in GiB with one decimal). A field is omitted when its source is unavailable. The description carries no hostname, user name, or serial number. Product documents use the shared authenticated HTTP APIs and receive the Desktop marker, update presentation, and an action that opens native confirmation; they cannot choose artifacts or authorize installation. Plugin management uses the Web application's authenticated HTTP APIs. Electron serves update-dialog documents and assets locally at `dsh-app://shell/`, independently of Host readiness. Electron exposes no plugin-management IPC or separate management document. No renderer receives filesystem access, raw Electron IPC, a shell, or arbitrary pnpm arguments. diff --git a/apps/desktop/README.zh.md b/apps/desktop/README.zh.md index 579b83b84d..bb874ce132 100644 --- a/apps/desktop/README.zh.md +++ b/apps/desktop/README.zh.md @@ -101,6 +101,8 @@ macOS PNG 使用带留白的圆角底板,供传统 ICNS 打包使用,包含 electron-builder 只把清单中的 `dependencies` 复制进 `app.asar/node_modules`,因此 Electron 主进程 bundle `lib/main.js` 内联其工作区 devDependencies,裸导入只剩 `electron`、Node 内置模块与这些 `dependencies`;沙箱 preload 只能留下 `electron`、`events`、`timers` 与 `url`,即其 `require` polyfill 能解析的模块。主进程 bundle 从被内联包的 `lib/` 产物解析它们,所以根 `build:lib:host` 在并发的工作区 tsdown 阶段之后才为 `apps/desktop` 打 bundle,并由 [`desktop-bundle-imports`](scripts/desktop-bundle-imports.mjs) 让任何静态、动态或 `require()` 导入无法在打包应用内解析的 Desktop bundle 直接失败。没有这项检查时,rolldown 无法解析的导入会作为外部说明符进入产物,并在启动时以 `ERR_MODULE_NOT_FOUND` 失败。[已归档的bundle 顺序决策](../../.agents/notes/archived/process/2026-09-22-desktop-main-bundle-after-workspace-tsdown.md)记录了备选方案。 +Electron 主进程将 `@deepseek-ai/dsh-error` 声明为生产依赖,满足 `@deepseek-ai/dsh-typert-protocol` 必需的对等依赖(peer dependency)。独立命令管理 worker 位于 `resources/runtime/cli/command-manager.js`,其相邻位置没有 `node_modules`,因此 bundle 内联 `@deepseek-ai/dsh-atomic-write` 和 `@deepseek-ai/dsh-error`。 + Windows 签名打包按 PE 文件内容扫描第一方运行时和应用生产依赖,包括没有常规扩展名的文件。最终扫描覆盖整个解包应用。目录链接、格式错误的 `MZ` 文件以及非 PE 的 `.exe`、`.dll` 或 `.pyd` 文件会使打包停止;以 `MZ` 开头的数据文件也会被拒绝,除非包含有效 PE 头。它保留有效的上游签名,并在记录运行时哈希或执行冒烟检查前为未签名代码补签。公钥验签每个进程处理最多 32 个文件,同时最多运行四个进程;硬件令牌签名仍串行执行,每个新签名必须匹配配置的证书且带时间戳。硬件签名或验签失败会停止本轮执行;独立的时间戳请求遵循[有界重试规则](windows-signing/README.zh.md#windows-ev-signing)。electron-builder 只有在验签和逐字节比对通过后,才保留复制后运行时可执行文件的签名。写入发布完成记录前,必须通过最终 PE 签名检查,以及使用全新缓存的 ASAR 载荷和 Host 冒烟检查。开发、仅准备和未签名构建不使用硬件令牌,可能被 Windows 代码完整性策略阻止;任何构建模式都不会关闭该策略。冒烟检查通过不代表兼容所有企业策略。 Desktop 携带独立的 Python、Node.js 和 pnpm 分发包。Python 包含 numpy、pandas、python-docx、python-pptx、openpyxl、Pillow、lxml、XlsxWriter 及其完整依赖。`load_workspace_dependencies` 工具首次使用时,将该产物离线安装到 `$DSH_HOME/dsh-runtimes/dsh-primary-runtime`(通常为 `~/.dsh/dsh-runtimes/dsh-primary-runtime`),并返回解释器、pnpm 脚本和库目录的绝对路径,以及记录内置分发包名称与版本的 `pythonDistributions`。版本报告不包含用户自行安装的包。Office 任务默认使用这些库,用户或工作区指令指定其他环境时遵循其要求。pnpm 脚本通过返回的 Node 可执行文件运行。返回的 Node 库目录为随包交付的库预留,不是 pnpm 的全局安装目录。 @@ -143,7 +145,7 @@ Welcome 加载共享 Toast 的配色和阴影变量,挂载在 body 下的通 ## 安装归属 -Electron 拥有 `$DSH_HOME/profiles/desktop`。其 `dependencies` 包含 pnpm 安装的包;`dsh.profile.bundles` 包含内置 bundle,后接已启用插件。Electron 主进程提供其生产依赖所需的工作区 peer,包括 Typert 使用的共享错误基类。主进程依赖从 `app.asar/node_modules` 解析,与 `app.asar/dsh` 下的 Harness 运行时相互独立。独立命令管理 worker 内联 atomic-write 及其错误基类,执行位置不需要另行提供这些包。签名应用从 `resources/app.asar/dsh` 提供 dsh、私有 Desktop Host 及其生产依赖。打包应用选择 runtime profile 解析,不创建包链接;开发 profile 使用文件系统链接。宿主与插件在同一个 Electron Node 模式进程中执行;Desktop 不启用 `--preserve-symlinks`。CLI 不能启动此 profile。Desktop 内置命令可在应用退出后管理其插件;npm 安装的 dsh 不能修改它。 +Electron 拥有 `$DSH_HOME/profiles/desktop`。其 `dependencies` 包含 pnpm 安装的包;`dsh.profile.bundles` 包含内置 bundle,后接已启用插件。签名应用从 `resources/app.asar/dsh` 提供 dsh、私有 Desktop Host 及其生产依赖。打包应用选择 runtime profile 解析,不创建包链接;开发 profile 使用文件系统链接。宿主与插件在同一个 Electron Node 模式进程中执行;Desktop 不启用 `--preserve-symlinks`。CLI 不能启动此 profile。Desktop 内置命令可在应用退出后管理其插件;npm 安装的 dsh 不能修改它。 应用 preload 只向 `dsh-app://app` 文档暴露启动就绪、致命启动失败上报、原生目录选择、用于 composer 路径引用的 `__DSH_HOST_PATHS__` 桥接和租约范围内的 Browser 桥接。同一个 preload 通过 `dshDesktop.deviceInfo()` 转发主进程采集的机器描述,按 `name=value` 字段以 `; ` 分隔:`platform`、`os`、`app_arch`(应用二进制实际运行的架构,模拟运行时与硬件架构不同)、`cpu` 和 `memory_gib`(物理内存总量,GiB,保留一位小数)。取值不可用时省略对应字段。该描述不包含主机名、用户名或序列号。产品页面还获得 Desktop 标记、更新展示数据和打开原生确认的操作,不能选择安装产物或授权安装。插件管理使用 Web 应用经过认证的 HTTP API;Electron 在 `dsh-app://shell/` 本地提供更新弹窗文档和资源,不依赖 Host 就绪。Electron 不提供插件管理 IPC 或独立管理页面。任何渲染进程都不会获得文件系统访问、原始 Electron IPC、shell 或任意 pnpm 参数。 diff --git a/apps/desktop/tests/desktop-bundle-imports.spec.ts b/apps/desktop/tests/desktop-bundle-imports.spec.ts index 339503d973..11c71c9662 100644 --- a/apps/desktop/tests/desktop-bundle-imports.spec.ts +++ b/apps/desktop/tests/desktop-bundle-imports.spec.ts @@ -1,6 +1,6 @@ -import { globSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' -import { join, resolve } from 'node:path' +import { join } from 'node:path' import { Rolldown } from 'tsdown' import { afterAll, describe, expect, it } from 'vitest' import { @@ -119,37 +119,3 @@ describe('packaged imports plugin', () => { expect(output.output.map(chunk => chunk.fileName)).toEqual(['require.js']) }) }) - -interface RuntimeManifest { - name: string - dependencies?: Record - peerDependencies?: Record - peerDependenciesMeta?: Record -} - -it('supplies required workspace peers of the Electron production dependency tree', () => { - const root = resolve(import.meta.dirname, '../../..') - const manifests = new Map(globSync(['apps/*/package.json', 'packages/*/*/package.json', 'vendor/*/package.json'], { cwd: root }) - .map((path) => { - const manifest = JSON.parse(readFileSync(join(root, path), 'utf8')) as RuntimeManifest - return [manifest.name, manifest] as const - })) - const desktop = JSON.parse(readFileSync(join(root, 'apps/desktop/package.json'), 'utf8')) as RuntimeManifest - const shipped = new Set() - const visit = (name: string): void => { - if (shipped.has(name)) return - shipped.add(name) - for (const dependency of Object.keys(manifests.get(name)?.dependencies ?? {})) visit(dependency) - } - for (const dependency of Object.keys(desktop.dependencies ?? {})) visit(dependency) - const missing: string[] = [] - for (const name of shipped) { - const manifest = manifests.get(name) - for (const peer of Object.keys(manifest?.peerDependencies ?? {})) { - if (manifests.has(peer) && !shipped.has(peer) && !manifest?.peerDependenciesMeta?.[peer]?.optional) { - missing.push(`${name} requires ${peer}`) - } - } - } - expect(missing).toEqual([]) -}) diff --git a/apps/desktop/tsdown.config.ts b/apps/desktop/tsdown.config.ts index 4683b56efb..ddf9c2d6db 100644 --- a/apps/desktop/tsdown.config.ts +++ b/apps/desktop/tsdown.config.ts @@ -50,6 +50,7 @@ export default defineConfig([ dts: false, clean: false, codeSplitting: false, + // The standalone worker has no node_modules; inline even production dependencies. deps: { alwaysBundle: ['@deepseek-ai/dsh-atomic-write', '@deepseek-ai/dsh-error'] }, }, { diff --git a/scripts/verify-runtime-closure.spec.ts b/scripts/verify-runtime-closure.spec.ts index 38a0c61cfd..930e0f07e4 100644 --- a/scripts/verify-runtime-closure.spec.ts +++ b/scripts/verify-runtime-closure.spec.ts @@ -1,6 +1,6 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' -import { dirname, join } from 'node:path' +import { dirname, join, resolve } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import { loadCordisYaml } from './cordis-yaml.ts' import { verifyRuntimeClosure } from './verify-runtime-closure.ts' @@ -39,6 +39,11 @@ afterEach(() => { }) describe('verifyRuntimeClosure', () => { + it('supplies required workspace peers of the Electron production dependency tree', async () => { + const root = resolve(import.meta.dirname, '..') + expect((await verifyRuntimeClosure(root, 'apps/desktop/package.json', false)).failures).toEqual([]) + }) + it('checks a private worker closure without requiring application presets', async () => { const manifestPath = 'packages/ssh/ssh-helper-runtime/package.json' const root = fixture({ [manifestPath]: { name: 'helper', dependencies: { '@scope/worker': 'workspace:^' } } })