From 92e65be447cefbbe8f24e099c1bb75edd1f85d52 Mon Sep 17 00:00:00 2001 From: yudshj Date: Thu, 26 Nov 2026 13:37:27 +0800 Subject: [PATCH] fix(office): upgrade LibreOffice Kit to 0.2.4 and select its glibc engines on Linux LibreOffice Kit 0.2.4 publishes its Linux engines as linux-x64-glibc and linux-arm64-glibc, but the sidecar and Desktop packaging looked for linux-, so a Linux target always fell back to WASM even when the kit declared a native engine. DSH's Linux distributions are glibc builds, so a Linux target now selects the glibc engine for its CPU. The third-party notices accept the two Linux engine packages under the same MPL-2.0 identity rule as the other engines. The web app and office-kit take Kit 0.2.4, the first release with those engines. Its release-age exclusions name the API and the six native engines; WASM is no longer an optional dependency of the kit and is no longer excluded. Because DSH no longer installs WASM, packaging now requires the target's declared native engine and rejects a target without one, naming its platform and CPU, instead of selecting a WASM package that cannot be present. The Python runtime smoke derives the same glibc package name and checks that the Office sidecar holds exactly that native engine. The Office provider, subsystem, package-surface and Desktop packaging documents describe Kit 0.2.4 and the native-only rule. --- THIRD_PARTY_NOTICES.md | 2 +- apps/desktop/packaging/README.i18n.yaml | 4 +- apps/desktop/packaging/README.md | 2 +- apps/desktop/packaging/README.zh.md | 2 +- .../package-surface.i18n.yaml | 4 +- docs/defensive-patterns/package-surface.md | 4 +- docs/defensive-patterns/package-surface.zh.md | 4 +- docs/subsystems/office-kit.i18n.yaml | 4 +- docs/subsystems/office-kit.md | 2 +- docs/subsystems/office-kit.zh.md | 2 +- packages/bundle/web-app/package.json | 2 +- packages/document/office-kit/README.i18n.yaml | 8 +-- packages/document/office-kit/README.md | 4 +- packages/document/office-kit/README.zh.md | 4 +- packages/document/office-kit/package.json | 2 +- pnpm-lock.yaml | 68 +++++++++++-------- pnpm-workspace.yaml | 13 ++-- .../build-exe-for-python-sdk-office.spec.ts | 51 ++++++++++---- scripts/gen-third-party-notices.spec.ts | 1 + scripts/gen-third-party-notices.ts | 2 + scripts/libreoffice-engine.spec.ts | 23 ++++--- scripts/libreoffice-packages.d.mts | 3 +- scripts/libreoffice-packages.mjs | 12 +++- scripts/smoke-python-runtime.py | 14 ++-- 24 files changed, 146 insertions(+), 91 deletions(-) diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index f6b9ad7b11..9e2fdf4e63 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -222,7 +222,7 @@ The installed SDK 0.3.263 declares the following optional platform packages. Eac ## LibreOffice conversion kit -`@deepseek-ai/libreoffice-kit`, `@deepseek-ai/libreoffice-kit-wasm`, `@deepseek-ai/libreoffice-kit-darwin-arm64`, `@deepseek-ai/libreoffice-kit-darwin-x64`, `@deepseek-ai/libreoffice-kit-win32-arm64`, `@deepseek-ai/libreoffice-kit-win32-x64` declare MPL-2.0, which remains outside the permissive-license allowlist; the notices check accepts only these package identities at those terms. The [distribution decision](.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.md) records the source obligations. +`@deepseek-ai/libreoffice-kit`, `@deepseek-ai/libreoffice-kit-wasm`, `@deepseek-ai/libreoffice-kit-darwin-arm64`, `@deepseek-ai/libreoffice-kit-darwin-x64`, `@deepseek-ai/libreoffice-kit-win32-arm64`, `@deepseek-ai/libreoffice-kit-win32-x64`, `@deepseek-ai/libreoffice-kit-linux-arm64-glibc`, `@deepseek-ai/libreoffice-kit-linux-x64-glibc` declare MPL-2.0, which remains outside the permissive-license allowlist; the notices check accepts only these package identities at those terms. The [distribution decision](.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.md) records the source obligations. The [kit repository](https://github.com/deepseek-ai/dsh-libreoffice-kit) supplies the corresponding LibreOffice source pin, modifications, build instructions, Node API, and artifact validation. Its engine packages retain their license and third-party notices; the Node API retains its MPL-2.0 declaration and NOTICE. Recipients must have access to those corresponding sources and notices. diff --git a/apps/desktop/packaging/README.i18n.yaml b/apps/desktop/packaging/README.i18n.yaml index e94fa6ad61..66df36c48b 100644 --- a/apps/desktop/packaging/README.i18n.yaml +++ b/apps/desktop/packaging/README.i18n.yaml @@ -45,8 +45,8 @@ en: b42f103358d0dfd7 zh: a534164ad9eb00da /desktop-packaging/runtime-file-selection-and-installation-checks: - en: 41cf2ae206d127d2 - zh: ad30381fdcb0d872 + en: 267624bd7a5c4568 + zh: 62908be9e4b9487a /desktop-packaging/desktop-runtime-preparation: en: 84be38ab3136fff7 zh: bb4ed12ee0e1dfa0 diff --git a/apps/desktop/packaging/README.md b/apps/desktop/packaging/README.md index 2cbf033f1a..744941bcca 100644 --- a/apps/desktop/packaging/README.md +++ b/apps/desktop/packaging/README.md @@ -252,7 +252,7 @@ Desktop packs workspace packages locally and installs external dependencies thro The [Electron shell file list](../scripts/electron-builder-config.mjs) excludes recognized JavaScript/CSS/TypeScript source maps and TypeScript build caches from the separate `resources/app.asar/node_modules` dependency collection. These exclusions preserve runtime code, native modules, WASM, data files (including ordinary `.map` assets), licenses, and notices; [shell archive tests](../tests/shell-file-selection.spec.ts) check retained bytes and exclusions. -The [Office conversion provider](../../../packages/document/office-kit/README.md) is a Host service mounted by web-app, so every application that loads web-app, including `dsh web` and Desktop, provides it together with the [Office tools](../../../packages/document/tool-document/README.md). The provider [resolves the Kit's engine itself](../../../packages/document/office-kit/README.md#understand-the-implementation), including the mapping of native engine manifests to unpacked physical directories. Desktop packaging only carries and unpacks the engine: it carries the target’s declared native engine, or WASM when the kit declares no matching native target, and preparation rejects a missing target engine before packaging. The complete Office dependencies, including the JavaScript libraries and the selected engine’s executables, data, licenses, and notices, are unpacked under `resources/app.asar.unpacked/dsh/node_modules/`. The Desktop shell passes the primary runtime location to the Host in [main.ts](../src/main.ts), and the Host sets it as `DSH_PRIMARY_RUNTIME`; neither passes a Kit location. Office skills are available in every application that loads web-app, and Desktop reads them from the skill package inside `resources/app.asar`; only Desktop mounts the bundled Python environment (`workspace-dependencies`). On macOS, the native helper receives the JIT entitlement required by [LibreOffice’s UNO bridge](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in). The Computer Use helper applications under `@deepseek-ai/dsh-cua-macos/native/bin` are also unpacked whole under `resources/app.asar.unpacked/dsh/node_modules/`, and the provider opens that copy. +The [Office conversion provider](../../../packages/document/office-kit/README.md) is a Host service mounted by web-app, so every application that loads web-app, including `dsh web` and Desktop, provides it together with the [Office tools](../../../packages/document/tool-document/README.md). The provider [resolves the Kit's engine itself](../../../packages/document/office-kit/README.md#understand-the-implementation), including the mapping of native engine manifests to unpacked physical directories. Desktop packaging only carries and unpacks the engine: it carries the target’s declared native engine, and preparation rejects an undeclared or missing target engine before packaging. The complete Office dependencies, including the JavaScript libraries and the selected engine’s executables, data, licenses, and notices, are unpacked under `resources/app.asar.unpacked/dsh/node_modules/`. The Desktop shell passes the primary runtime location to the Host in [main.ts](../src/main.ts), and the Host sets it as `DSH_PRIMARY_RUNTIME`; neither passes a Kit location. Office skills are available in every application that loads web-app, and Desktop reads them from the skill package inside `resources/app.asar`; only Desktop mounts the bundled Python environment (`workspace-dependencies`). On macOS, the native helper receives the JIT entitlement required by [LibreOffice’s UNO bridge](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in). The Computer Use helper applications under `@deepseek-ai/dsh-cua-macos/native/bin` are also unpacked whole under `resources/app.asar.unpacked/dsh/node_modules/`, and the provider opens that copy. The packaged application runs compiled JavaScript and pre-generated Typert metadata; it does not compile TypeScript plugins. Source-level debugger navigation and editor declarations remain available in development packages. [Copy-policy tests](../tests/runtime-file-policy.spec.ts) cover exclusions and retained assets; The [payload smoke](../tests/fixtures/runtime-payload-smoke.mjs) runs under Electron RunAsNode before the Host smoke and final inventory verification. The payload smoke resolves the search tool’s ripgrep executable and verifies text search and file enumeration. Signed Windows builds run these checks after dependency signing; other builds run them during `prepare:dsh`. The [Host smoke](../scripts/smoke-runtime.ts) creates DOCX, XLSX, and PPTX inputs with bundled Python and runs each through the real Office provider: PDF conversion, PNG rendering, conversion to the matching OpenDocument format, and, for XLSX, recalculation, checking each output's signature. Every assembled application, including directory and unsigned builds, repeats the payload and Host checks against ASAR. Archive integrity checks compare the complete archived descriptor with preparation, file bytes and membership in both archive and unpacked trees, recorded executable flags for archived files, and physical permissions for unpacked files. Conversion failures stop packaging before a release record is written; macOS DMG/ZIP builds run these checks before notarization. diff --git a/apps/desktop/packaging/README.zh.md b/apps/desktop/packaging/README.zh.md index 700589dd37..e52be505fb 100644 --- a/apps/desktop/packaging/README.zh.md +++ b/apps/desktop/packaging/README.zh.md @@ -252,7 +252,7 @@ Desktop 在本地打包工作区包,并通过目标捆绑的 Node 和 pnpm 安 [Electron 外壳文件清单](../scripts/electron-builder-config.mjs)从单独收集的 `resources/app.asar/node_modules` 依赖中排除已识别的 JavaScript/CSS/TypeScript source map 和 TypeScript 构建缓存。这些排除规则保留运行时代码、原生模块、WASM、数据文件(包括普通 `.map` 资源)、许可证和 notices;[外壳归档测试](../tests/shell-file-selection.spec.ts)检查保留文件的字节和排除项。 -[Office 转换提供方](../../../packages/document/office-kit/README.zh.md)是 web-app 挂载的 Host 服务,因此所有加载 web-app 的应用(包括 `dsh web` 和 Desktop)都提供它以及 [Office 工具](../../../packages/document/tool-document/README.zh.md)。该提供方[自行解析 Kit 的引擎](../../../packages/document/office-kit/README.zh.md#understand-the-implementation),包括把原生引擎清单映射到解包后的实体目录。Desktop 打包只负责携带和解包引擎:携带目标声明的原生引擎;kit 未声明匹配的原生目标时携带 WASM;目标引擎缺失时,准备阶段在打包前拒绝。完整的 Office 依赖(包括 JavaScript 库以及所选引擎的可执行文件、数据、许可证和声明)解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下。Desktop 壳在 [main.ts](../src/main.ts) 中把主运行时位置传给 Host,由 Host 设为 `DSH_PRIMARY_RUNTIME`;两者都不传 Kit 位置。所有加载 web-app 的应用都提供 Office 技能,Desktop 从 `resources/app.asar` 内的技能包读取它们;只有 Desktop 挂载内置 Python 环境(`workspace-dependencies`)。在 macOS 上,原生 helper 获得 [LibreOffice UNO 桥](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in)所需的 JIT 权限。`@deepseek-ai/dsh-cua-macos/native/bin` 下的 Computer Use helper 应用也整体解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下,提供方打开该副本。 +[Office 转换提供方](../../../packages/document/office-kit/README.zh.md)是 web-app 挂载的 Host 服务,因此所有加载 web-app 的应用(包括 `dsh web` 和 Desktop)都提供它以及 [Office 工具](../../../packages/document/tool-document/README.zh.md)。该提供方[自行解析 Kit 的引擎](../../../packages/document/office-kit/README.zh.md#understand-the-implementation),包括把原生引擎清单映射到解包后的实体目录。Desktop 打包只负责携带和解包引擎:携带目标声明的原生引擎;目标引擎未声明或缺失时,准备阶段在打包前拒绝。完整的 Office 依赖(包括 JavaScript 库以及所选引擎的可执行文件、数据、许可证和声明)解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下。Desktop 壳在 [main.ts](../src/main.ts) 中把主运行时位置传给 Host,由 Host 设为 `DSH_PRIMARY_RUNTIME`;两者都不传 Kit 位置。所有加载 web-app 的应用都提供 Office 技能,Desktop 从 `resources/app.asar` 内的技能包读取它们;只有 Desktop 挂载内置 Python 环境(`workspace-dependencies`)。在 macOS 上,原生 helper 获得 [LibreOffice UNO 桥](https://github.com/LibreOffice/core/blob/master/sysui/desktop/macosx/hardened_runtime.xcent.in)所需的 JIT 权限。`@deepseek-ai/dsh-cua-macos/native/bin` 下的 Computer Use helper 应用也整体解包到 `resources/app.asar.unpacked/dsh/node_modules/` 下,提供方打开该副本。 打包应用运行编译后的 JavaScript 和预生成的 Typert 元数据,不编译 TypeScript 插件。源码级调试导航和编辑器声明仍可从开发包中获取。[复制规则测试](../tests/runtime-file-policy.spec.ts)覆盖排除项和保留资源;[产物 smoke](../tests/fixtures/runtime-payload-smoke.mjs) 在 Host smoke 和最终清单验证之前,使用 Electron RunAsNode 执行。产物 smoke 解析搜索工具使用的 ripgrep 可执行文件,并验证文本搜索和文件枚举。Windows 签名构建在依赖签名后运行这些检查;其他构建在 `prepare:dsh` 中运行。[Host smoke](../scripts/smoke-runtime.ts) 使用捆绑的 Python 创建 DOCX、XLSX 和 PPTX 输入,并通过真实 Office 提供方逐一执行:PDF 转换、PNG 渲染、转换为对应的 OpenDocument 格式,以及针对 XLSX 的重算,检查每个输出的签名。每个组装后的应用(包括目录包和未签名构建)都会针对 ASAR 重复产物和 Host 检查。归档完整性检查将归档内完整描述符与准备结果比对,并核对归档和解包目录中的文件内容与清单、归档内文件记录的执行标志,以及解包文件的物理权限。转换失败会在写入发布记录前终止打包;macOS DMG/ZIP 构建在公证前执行这些检查。 diff --git a/docs/defensive-patterns/package-surface.i18n.yaml b/docs/defensive-patterns/package-surface.i18n.yaml index 0636877623..8168a60531 100644 --- a/docs/defensive-patterns/package-surface.i18n.yaml +++ b/docs/defensive-patterns/package-surface.i18n.yaml @@ -18,8 +18,8 @@ en: e68bfcde70f845b4 zh: 73e5c4fb067c4fa1 /package-surface-rules/internal-dependency-syntax-follows-the-package-family: - en: 0b3c0da2bfcea15c - zh: 133b381f64c42d1f + en: c160b78d6f649faa + zh: e65a5a3852e6c359 /package-surface-rules/a-new-resolve-hook-is-refused-outright: en: b420ae3e228432d5 zh: 0c49c4a9c3a5262c diff --git a/docs/defensive-patterns/package-surface.md b/docs/defensive-patterns/package-surface.md index cad0a891a5..bb06bb786c 100644 --- a/docs/defensive-patterns/package-surface.md +++ b/docs/defensive-patterns/package-surface.md @@ -154,7 +154,7 @@ Restating a required-devDependency package list or the field rules on this page Internal dependency syntax follows the package family: `@deepseek-ai/dsh` and `@deepseek-ai/dsh-*` use `workspace:*`, every other internal package uses `workspace:~`, and `workspace:^` has retired. The same dependency name is written the same way in every workspace, and a mismatch is a hard scan failure rather than a warning a reviewer can waive. The uniform syntax keeps one resolution path and prevents duplicate instances of a dependency and the resolution differences that follow them. - Judged by `workspaceRange()` in [verify-package-dependencies.ts](../../scripts/verify-package-dependencies.ts): the `@deepseek-ai/dsh` and `@deepseek-ai/dsh-*` families get `workspace:*`, every other internal package gets `workspace:~`; the scan walks the managed manifests and compares every declaration of the same dependency name. -- Boundary: a same-namespace package that is not a workspace member declares an ordinary third-party range and is outside the family rule — `@deepseek-ai/libreoffice-kit` is declared `0.2.3` in `packages/bundle/web-app/package.json` (devDependencies) and `packages/document/office-kit/package.json` (dependencies). +- Boundary: a same-namespace package that is not a workspace member declares an ordinary third-party range and is outside the family rule — `@deepseek-ai/libreoffice-kit` is declared `0.2.4` in `packages/bundle/web-app/package.json` (devDependencies) and `packages/document/office-kit/package.json` (dependencies). - Distribution is not restated here; the recompute command below prints the current counts of `workspace:*`, `workspace:~`, `workspace:^`, and any exact-range declaration outside the family rule. - Exception: the scan decides mechanically; a genuine exception means changing the scan and the policy file with the domain owner's confirmation and the reason on the change. - Recompute: @@ -170,7 +170,7 @@ Each family in its form, with the non-member exception left as an ordinary versi "dependencies": { "@deepseek-ai/dsh-base": "workspace:*", "@deepseek-ai/cordis": "workspace:~", - "@deepseek-ai/libreoffice-kit": "0.2.3" + "@deepseek-ai/libreoffice-kit": "0.2.4" }, "devDependencies": { "@deepseek-ai/dsh-typert-registry": "workspace:*" diff --git a/docs/defensive-patterns/package-surface.zh.md b/docs/defensive-patterns/package-surface.zh.md index d1a2132086..73c030381d 100644 --- a/docs/defensive-patterns/package-surface.zh.md +++ b/docs/defensive-patterns/package-surface.zh.md @@ -154,7 +154,7 @@ Restating a required-devDependency package list or the field rules on this page 内部依赖写法按包族决定:`@deepseek-ai/dsh` 与 `@deepseek-ai/dsh-*` 用 `workspace:*`,其余内部包用 `workspace:~`,`workspace:^` 已退出。同一个依赖名在所有 workspace 内写法一致,不一致是扫描硬失败,不是评审可以放行的警告。写法统一才能保持一条解析路径,避免同一个依赖出现重复实例以及随之而来的解析差异。 - 判定在 [verify-package-dependencies.ts](../../scripts/verify-package-dependencies.ts) 的 `workspaceRange()`:`@deepseek-ai/dsh` 与 `@deepseek-ai/dsh-*` 包族取 `workspace:*`,其余内部包取 `workspace:~`;扫描遍历受管清单,比对同一依赖名的每一处声明。 -- 边界:同命名空间但不是 workspace 成员的包按普通第三方版本范围声明,不受包族规则约束——`@deepseek-ai/libreoffice-kit` 在 `packages/bundle/web-app/package.json`(devDependencies)和 `packages/document/office-kit/package.json`(dependencies)中声明为 `0.2.3`。 +- 边界:同命名空间但不是 workspace 成员的包按普通第三方版本范围声明,不受包族规则约束——`@deepseek-ai/libreoffice-kit` 在 `packages/bundle/web-app/package.json`(devDependencies)和 `packages/document/office-kit/package.json`(dependencies)中声明为 `0.2.4`。 - 分布不在此复述;下面的复算命令会打印 `workspace:*`、`workspace:~`、`workspace:^` 的当前数量,以及族规则之外的精确版本声明。 - 例外:门禁机械判定;确需例外意味着修改扫描与策略文件,并须经对应领域专家确认、在改动上说明理由。 - 复算: @@ -170,7 +170,7 @@ python3 -c "import json,glob,collections; c=collections.Counter(); [c.update([r] "dependencies": { "@deepseek-ai/dsh-base": "workspace:*", "@deepseek-ai/cordis": "workspace:~", - "@deepseek-ai/libreoffice-kit": "0.2.3" + "@deepseek-ai/libreoffice-kit": "0.2.4" }, "devDependencies": { "@deepseek-ai/dsh-typert-registry": "workspace:*" diff --git a/docs/subsystems/office-kit.i18n.yaml b/docs/subsystems/office-kit.i18n.yaml index 657875b3cb..427770944e 100644 --- a/docs/subsystems/office-kit.i18n.yaml +++ b/docs/subsystems/office-kit.i18n.yaml @@ -15,5 +15,5 @@ en: 3a373dfc9dd945c3 zh: ff5f9a16d0e7b96f /office-kit/engine-selection-and-limits: - en: a26e451e9e481c52 - zh: da1f4a160a6c2094 + en: dac62dc258240d0a + zh: 026f1ac3119a843c diff --git a/docs/subsystems/office-kit.md b/docs/subsystems/office-kit.md index 1955482dd8..81e5b1d449 100644 --- a/docs/subsystems/office-kit.md +++ b/docs/subsystems/office-kit.md @@ -38,7 +38,7 @@ The `api/remotes` assembly mounts the conversion service's generated Remote desc ## Engine selection and limits -The external [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) Node API selects its precompiled engines. The kit has an independent version and release workflow, defined by the [release ownership decision](../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.md). Application builds install the published npm packages. Application packaging requires the target’s declared native engine, or Node WASM when the kit declares no native engine for that target. The [platform engine reference](../../packages/document/office-kit/README.md) defines installation and packaging. Invalid metadata, missing required assets, and conversion errors reject without switching engines. When the provider's Kit is absent or fails to import, the provider still registers and rejects conversions as `unavailable`. Conversion uses disk input and output paths on the Host, with no browser conversion engine or font RPC. +The external [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) Node API selects its precompiled engines. The kit has an independent version and release workflow, defined by the [release ownership decision](../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.md). Application builds install the published npm packages. Application packaging requires the target’s declared native engine (`linux--glibc` on Linux) and rejects targets without one instead of falling back to Node WASM. The [platform engine reference](../../packages/document/office-kit/README.md) defines installation and packaging. Invalid metadata, missing required assets, and conversion errors reject without switching engines. When the provider's Kit is absent or fails to import, the provider still registers and rejects conversions as `unavailable`. Conversion uses disk input and output paths on the Host, with no browser conversion engine or font RPC. The [Host provider configuration](../../packages/document/office-kit/README.md#use-this-package) owns concurrency, deadlines, input/output limits, archive limits, image resolution, and font access. Native/WASM implementation and asset distribution belong to the kit workspace. System LibreOffice discovery, runtime engine downloads, persistent output caching, workspace writes, and model-facing presentation are outside this provider. diff --git a/docs/subsystems/office-kit.zh.md b/docs/subsystems/office-kit.zh.md index 46521dcba5..f02ef14819 100644 --- a/docs/subsystems/office-kit.zh.md +++ b/docs/subsystems/office-kit.zh.md @@ -38,7 +38,7 @@ ## 引擎选择和限制 -外部 [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) Node API 选择其预编译引擎。kit 独立维护版本和发布流程,具体归属由[发布归属决策](../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.zh.md)定义。应用构建时安装已发布的 npm 包。应用打包要求目标已声明的原生引擎;kit 未为该目标声明原生引擎时使用 Node WASM。[平台引擎参考](../../packages/document/office-kit/README.zh.md)定义安装和打包规则。元数据无效、必需资源缺失和转换错误都会拒绝请求,不切换引擎。提供方的 Kit 缺失或导入失败时,提供方仍会注册,并以 `unavailable` 拒绝转换。转换在 Host 使用磁盘输入输出路径,不使用浏览器转换引擎或字体 RPC。 +外部 [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) Node API 选择其预编译引擎。kit 独立维护版本和发布流程,具体归属由[发布归属决策](../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.zh.md)定义。应用构建时安装已发布的 npm 包。应用打包要求目标已声明的原生引擎(Linux 上为 `linux--glibc`),未声明时拒绝打包,不回退到 Node WASM。[平台引擎参考](../../packages/document/office-kit/README.zh.md)定义安装和打包规则。元数据无效、必需资源缺失和转换错误都会拒绝请求,不切换引擎。提供方的 Kit 缺失或导入失败时,提供方仍会注册,并以 `unavailable` 拒绝转换。转换在 Host 使用磁盘输入输出路径,不使用浏览器转换引擎或字体 RPC。 [Host 提供方配置](../../packages/document/office-kit/README.zh.md#use-this-package)负责并发、期限、输入输出上限、归档上限、图像分辨率和字体访问。原生/WASM 实现和资产分发属于 kit 工作区。系统 LibreOffice 探测、运行时引擎下载、持久输出缓存、写入工作区和面向模型的展示不属于此提供方。 diff --git a/packages/bundle/web-app/package.json b/packages/bundle/web-app/package.json index f634ef7311..2bffcaa14f 100644 --- a/packages/bundle/web-app/package.json +++ b/packages/bundle/web-app/package.json @@ -244,7 +244,7 @@ "@deepseek-ai/dsh-tool-testkit": "workspace:*", "@deepseek-ai/dsh-tools": "workspace:*", "@deepseek-ai/dsh-typert-registry": "workspace:*", - "@deepseek-ai/libreoffice-kit": "0.2.3", + "@deepseek-ai/libreoffice-kit": "0.2.4", "@deepseek-ai/dsh-otel": "workspace:*" } } diff --git a/packages/document/office-kit/README.i18n.yaml b/packages/document/office-kit/README.i18n.yaml index a2433b87ed..a2d0683287 100644 --- a/packages/document/office-kit/README.i18n.yaml +++ b/packages/document/office-kit/README.i18n.yaml @@ -9,14 +9,14 @@ en: 37156fb2f1de123c zh: 44b77def8f181d4b /deepseek-ai-dsh-office-kit/summary: - en: b138dcadd0d59f99 - zh: 956e6d2cf58826e2 + en: 48ed53fb21d0e85c + zh: a23906e60ae09ae3 /deepseek-ai-dsh-office-kit/table-of-contents: en: d152484eb41ac6b4 zh: a134331a31395608 /deepseek-ai-dsh-office-kit/use-this-package: - en: 952dc31c7bf74384 - zh: c4c4b6fa355bd71d + en: 5afe42663bc14ffb + zh: 6fdea6a5ebbabe5b /deepseek-ai-dsh-office-kit/understand-the-implementation: en: ae535a0a276f6622 zh: 23e1bc19e9985df8 diff --git a/packages/document/office-kit/README.md b/packages/document/office-kit/README.md index ad1c53e4fd..b3fd30495a 100644 --- a/packages/document/office-kit/README.md +++ b/packages/document/office-kit/README.md @@ -9,7 +9,7 @@ English | [中文](README.zh.md) ## Summary -Render Office documents as PDFs or PNG images, convert them between formats, and recalculate workbooks on the Host computer. Targets with a declared native LibreOffice engine use it; other targets use Node WASM. Previews accept DOC, DOCX, XLS, XLSX, PPT, and PPTX; operations also accept the OpenDocument formats, and image rendering accepts PDF, which it renders with Poppler's `pdftoppm` when the subprocess provider finds it. OOXML operations return missing-font names; binary Office operations return an empty list. +Render Office documents as PDFs or PNG images, convert them between formats, and recalculate workbooks on the Host computer. Conversions use the native LibreOffice engine declared by the kit for the target (`linux--glibc` on Linux); targets without a declared engine install no engine package. Previews accept DOC, DOCX, XLS, XLSX, PPT, and PPTX; operations also accept the OpenDocument formats, and image rendering accepts PDF, which it renders with Poppler's `pdftoppm` when the subprocess provider finds it. OOXML operations return missing-font names; binary Office operations return an empty list. ## Table of Contents @@ -42,7 +42,7 @@ Callers submit authorized source identity, version, optional byte size, a deferr Poppler renders PDF pages without a LibreOffice converter slot and still shares queue admission, concurrency, and source-byte reservations. Each process reads the PDF from stdin, so no file passes between the provider and the process. One `pdfinfo` reports the page count, taken from its last `Pages:` line because document properties such as the title print earlier. The provider then applies the LibreOffice codes to the selection: more pages than `maxImages` is `output-too-large`, and a page outside the document is `invalid-request`. One `pdftoppm -cropbox` per run of consecutive pages renders at the requested DPI (default 144) and writes the PNG images to stdout one after another. The provider splits them at PNG chunk boundaries as they arrive, terminates `pdftoppm` with `output-too-large` once the bytes exceed the remaining `maxBytes`, and requires one image per page of the run. Page pixels and dimensions are checked only after rendering, against each PNG header: an image above `maxPixels` or `maxDimension` fails with `output-too-large`. The result has an empty `missingFonts` list. Exit code 1 maps to `invalid-document`, the `timeoutMs` deadline to `timeout`, and other failures to `failed`. -The provider depends on the independently published [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) npm API at kit version `0.2.3`. Application packaging selects the matching native package declared in the kit’s `optionalDependencies`, or WASM when no native package is declared for that target. A missing declared native engine rejects packaging without selecting WASM. The [release ownership decision](../../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.md) defines the independent kit and Harness responsibilities. +The provider depends on the independently published [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) npm API at kit version `0.2.4`. Application packaging selects the matching native package declared in the kit’s `optionalDependencies` (`linux--glibc` for Linux targets) and rejects packaging when the target engine is undeclared or missing, without falling back to WASM. Source installations on hosts without a declared native engine install no engine package. The [release ownership decision](../../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.md) defines the independent kit and Harness responsibilities. The provider registers even when its Kit is absent, such as a Python SDK executable launched without a downloaded Office sidecar. A conversion that needs a new converter then rejects with `OfficeKitError` code `unavailable`, and the provider logs each distinct failure once through `ctx.logger`. A Kit entry that fails to import behaves the same way. The provider retains only a successful import, so a later conversion locates and imports Kit again. The Office preview shows its localized `unavailable` message for the `document-render/failed` reason. diff --git a/packages/document/office-kit/README.zh.md b/packages/document/office-kit/README.zh.md index 555aeeb753..70646dedb7 100644 --- a/packages/document/office-kit/README.zh.md +++ b/packages/document/office-kit/README.zh.md @@ -9,7 +9,7 @@ kind: "package-reference" ## 概述 -在宿主计算机上将 Office 文档渲染为 PDF 或 PNG 图片、在格式之间转换,以及重算工作簿。声明了原生 LibreOffice 引擎的目标使用原生引擎,其余目标使用 Node WASM。预览支持 DOC、DOCX、XLS、XLSX、PPT 和 PPTX;操作还支持 OpenDocument 格式,图片渲染还支持 PDF,subprocess 提供方能找到 Poppler 的 `pdftoppm` 时用它渲染 PDF。OOXML 操作返回缺失字体名称;二进制 Office 操作返回空列表。 +在宿主计算机上将 Office 文档渲染为 PDF 或 PNG 图片、在格式之间转换,以及重算工作簿。转换使用 kit 为目标声明的原生 LibreOffice 引擎(Linux 上为 `linux--glibc`);未声明原生引擎的目标不安装引擎包。预览支持 DOC、DOCX、XLS、XLSX、PPT 和 PPTX;操作还支持 OpenDocument 格式,图片渲染还支持 PDF,subprocess 提供方能找到 Poppler 的 `pdftoppm` 时用它渲染 PDF。OOXML 操作返回缺失字体名称;二进制 Office 操作返回空列表。 ## 目录 @@ -42,7 +42,7 @@ kind: "package-reference" Poppler 渲染 PDF 页面时不占用 LibreOffice 转换器槽位,但仍共用队列准入、并发和源字节预留。每个进程从 stdin 读取 PDF,提供方与进程之间不传递任何文件。一个 `pdfinfo` 报告页数,取其最后一行 `Pages:`,因为标题等文档属性先输出。随后提供方按 LibreOffice 路径的错误码检查选择:页数超过 `maxImages` 为 `output-too-large`,页码超出文档为 `invalid-request`。每段连续页码由一个 `pdftoppm -cropbox` 按所请求的 DPI(默认 144)渲染,把 PNG 图片首尾相接写到 stdout。提供方在数据到达时按 PNG chunk 边界切分,字节数超过剩余的 `maxBytes` 时终止 `pdftoppm` 并报 `output-too-large`,并要求该段每页恰好一张图片。页面像素与尺寸上限只在渲染后按每张图片的 PNG 头校验:超过 `maxPixels` 或 `maxDimension` 的图片以 `output-too-large` 失败。结果的 `missingFonts` 为空列表。退出码 1 映射为 `invalid-document`,超过 `timeoutMs` 期限映射为 `timeout`,其他失败映射为 `failed`。 -此 provider 依赖独立发布的 [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) npm API,kit 版本为 `0.2.3`。应用打包选择 kit 的 `optionalDependencies` 中声明的匹配原生包;目标没有声明原生包时选择 WASM。已声明的原生引擎缺失时拒绝打包,不会选择 WASM。[发布归属决策](../../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.zh.md)定义独立 kit 与 Harness 各自的职责。 +此 provider 依赖独立发布的 [`@deepseek-ai/libreoffice-kit`](https://github.com/deepseek-ai/dsh-libreoffice-kit) npm API,kit 版本为 `0.2.4`。应用打包选择 kit 的 `optionalDependencies` 中为目标声明的匹配原生包(Linux 目标按架构选择 `linux--glibc`);目标引擎未声明或缺失时拒绝打包,不回退到 WASM。未声明原生引擎的宿主从源码安装时不安装引擎包。[发布归属决策](../../../.agents/notes/implemented/architecture/2026-09-14-independent-libreoffice-kit.zh.md)定义独立 kit 与 Harness 各自的职责。 Kit 缺失时提供方照常注册,例如未下载 Office sidecar 就启动的 Python SDK 可执行程序。此时需要新转换器的转换以代码为 `unavailable` 的 `OfficeKitError` 拒绝,提供方通过 `ctx.logger` 对每种不同的失败只报告一次。Kit 入口导入失败时行为相同。提供方只保留成功的导入,因此之后的转换会重新定位并导入 Kit。Office 预览对 `document-render/failed` 原因显示本地化的 `unavailable` 提示。 diff --git a/packages/document/office-kit/package.json b/packages/document/office-kit/package.json index 478f90b1d4..f586afb39e 100644 --- a/packages/document/office-kit/package.json +++ b/packages/document/office-kit/package.json @@ -62,7 +62,7 @@ "@deepseek-ai/dsh-subprocess-local": "workspace:*" }, "dependencies": { - "@deepseek-ai/libreoffice-kit": "0.2.3", + "@deepseek-ai/libreoffice-kit": "0.2.4", "@deepseek-ai/schemastery": "workspace:~", "@deepseek-ai/dsh-brand": "workspace:*", "@deepseek-ai/dsh-typert-protocol": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d35ce1e922..dd52f6328f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3748,8 +3748,8 @@ importers: specifier: workspace:* version: link:../../typert/registry '@deepseek-ai/libreoffice-kit': - specifier: 0.2.3 - version: 0.2.3 + specifier: 0.2.4 + version: 0.2.4 packages/client/config: devDependencies: @@ -9718,8 +9718,8 @@ importers: specifier: workspace:* version: link:../../typert/protocol '@deepseek-ai/libreoffice-kit': - specifier: 0.2.3 - version: 0.2.3 + specifier: 0.2.4 + version: 0.2.4 '@deepseek-ai/schemastery': specifier: link:../../../vendor/schemastery version: link:../../../vendor/schemastery @@ -22853,36 +22853,46 @@ packages: resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==} engines: {node: '>=20.19.0'} - '@deepseek-ai/libreoffice-kit-darwin-arm64@0.2.3': - resolution: {integrity: sha512-0dfiEQR6SqAQjh9hxyY8x77Sj3r+AGC+Xn2A/zF+bag9g40leYPL/c2UirSqYR6xUwE9a/5YgWFIHjw1eOh+3A==} + '@deepseek-ai/libreoffice-kit-darwin-arm64@0.2.4': + resolution: {integrity: sha512-j7ubpGbUrLvQailTkV4c4mwuMweStBsqW//BkIfD65ytW2rLrfRGhzHIO2wcg9Vq4kB+xv2VgQATc+mOVO0DjQ==} engines: {node: '>=22.19.0'} cpu: [arm64] os: [darwin] - '@deepseek-ai/libreoffice-kit-darwin-x64@0.2.3': - resolution: {integrity: sha512-vq0Fp7MTlZwV/yxLpmvQmx1uiiozLTjjODmgrOa9WC5WhrSQYZ+M1OiQKI0qbPAjpMZVBzcZvxlAGnDiTrG4jA==} + '@deepseek-ai/libreoffice-kit-darwin-x64@0.2.4': + resolution: {integrity: sha512-MR82Kj/1Pb8C98kDRM8CX+5aHvdo07ocupQV1rWlNA/b7UdO97nEy03wc267dCnLoH2G4lNmw5O6hRzphQ7kzw==} engines: {node: '>=22.19.0'} cpu: [x64] os: [darwin] - '@deepseek-ai/libreoffice-kit-wasm@0.2.3': - resolution: {integrity: sha512-g81zHATxolq/HKRglfrSO2gQgj4RZ//nJo98BcTIs9l8GPU4STNcWwplx5CE6Iy/20lZFbwT9jvGw1Key9xZmg==} + '@deepseek-ai/libreoffice-kit-linux-arm64-glibc@0.2.4': + resolution: {integrity: sha512-EWZOhsJxuM9HP25VGQrdeXBhJqL0o9Bxgimc0dtMxtiE2FeZZmNB0hsN8KYj7XFb2lt37GZpRlxtHCkfnoLmuQ==} engines: {node: '>=22.19.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] - '@deepseek-ai/libreoffice-kit-win32-arm64@0.2.3': - resolution: {integrity: sha512-cAQ0hRZ/8jt8Dudn7vYdpd5OeWpg0AOHzXqgn6UkkPXmQt1/+HCdc4MZbAM927I+c3lwJyLN1fyKIMW5iXCYpg==} + '@deepseek-ai/libreoffice-kit-linux-x64-glibc@0.2.4': + resolution: {integrity: sha512-2OYMgjmWevHh1YcMVAVRkJ2wYfhI0w3raBuUUTWZvNzFcdfTOTVUwzhsaGeUfKh+VRKzvTrsDeBm1yuL0vQGBA==} + engines: {node: '>=22.19.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@deepseek-ai/libreoffice-kit-win32-arm64@0.2.4': + resolution: {integrity: sha512-VfUkoflQSSHfEXPOYy1+6rYBITBoOXkR7E9wFvT7K1a0TknJhAaJfCmqRD+AeTN6Lz+AhzVZP2hfq7QCF9ZeCA==} engines: {node: '>=22.19.0'} cpu: [arm64] os: [win32] - '@deepseek-ai/libreoffice-kit-win32-x64@0.2.3': - resolution: {integrity: sha512-GMW+m/09Ts0m4gRUjIckeRN48OVYgJI7aLG1uoUHcG3LRPDsKnsyeRo+BSQn8rh4CmWtJg5c6qtl0uSW7b9zEg==} + '@deepseek-ai/libreoffice-kit-win32-x64@0.2.4': + resolution: {integrity: sha512-EbiIjU6pJGO+q2AlVved985IenoPCkIzcM8850nmxarq3BuY8TBAIVUaHlP1cypaQd+mJ3H8gTvANF6Wdptwpg==} engines: {node: '>=22.19.0'} cpu: [x64] os: [win32] - '@deepseek-ai/libreoffice-kit@0.2.3': - resolution: {integrity: sha512-MbpucYPrZpeec/smy7u8Z066JeQU6lMVK6A1oysUv1R/OATDvtlVmrsIlfcIz6bVbfJVpgregIK86dOdat9qdA==} + '@deepseek-ai/libreoffice-kit@0.2.4': + resolution: {integrity: sha512-M2K0fTAKcyM8rGW9iMnZsbuQoHeVtAEwKhrDN1TppOlAufBO9BJte8egddEKHEir4CjwN7Cakpy8p7zSov3dlQ==} engines: {node: '>=22.19.0'} hasBin: true @@ -30881,32 +30891,36 @@ snapshots: '@csstools/css-tokenizer@4.0.0': {} - '@deepseek-ai/libreoffice-kit-darwin-arm64@0.2.3': + '@deepseek-ai/libreoffice-kit-darwin-arm64@0.2.4': optional: true - '@deepseek-ai/libreoffice-kit-darwin-x64@0.2.3': + '@deepseek-ai/libreoffice-kit-darwin-x64@0.2.4': optional: true - '@deepseek-ai/libreoffice-kit-wasm@0.2.3': + '@deepseek-ai/libreoffice-kit-linux-arm64-glibc@0.2.4': optional: true - '@deepseek-ai/libreoffice-kit-win32-arm64@0.2.3': + '@deepseek-ai/libreoffice-kit-linux-x64-glibc@0.2.4': optional: true - '@deepseek-ai/libreoffice-kit-win32-x64@0.2.3': + '@deepseek-ai/libreoffice-kit-win32-arm64@0.2.4': optional: true - '@deepseek-ai/libreoffice-kit@0.2.3': + '@deepseek-ai/libreoffice-kit-win32-x64@0.2.4': + optional: true + + '@deepseek-ai/libreoffice-kit@0.2.4': dependencies: fflate: 0.8.2 fontkit: 2.0.4 saxes: 6.0.0 optionalDependencies: - '@deepseek-ai/libreoffice-kit-darwin-arm64': 0.2.3 - '@deepseek-ai/libreoffice-kit-darwin-x64': 0.2.3 - '@deepseek-ai/libreoffice-kit-wasm': 0.2.3 - '@deepseek-ai/libreoffice-kit-win32-arm64': 0.2.3 - '@deepseek-ai/libreoffice-kit-win32-x64': 0.2.3 + '@deepseek-ai/libreoffice-kit-darwin-arm64': 0.2.4 + '@deepseek-ai/libreoffice-kit-darwin-x64': 0.2.4 + '@deepseek-ai/libreoffice-kit-linux-arm64-glibc': 0.2.4 + '@deepseek-ai/libreoffice-kit-linux-x64-glibc': 0.2.4 + '@deepseek-ai/libreoffice-kit-win32-arm64': 0.2.4 + '@deepseek-ai/libreoffice-kit-win32-x64': 0.2.4 koffi: 3.1.1 '@docsearch/css@3.8.2': {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index bf56c53ddb..b2038b25c7 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -71,12 +71,13 @@ minimumReleaseAgeExclude: # Native Codex and Claude tests qualify this exact release with its local patches. - '@botiverse/oar@0.67.0' # Office engines and their API are qualified and released together by the kit repository. - - '@deepseek-ai/libreoffice-kit@0.2.3' - - '@deepseek-ai/libreoffice-kit-darwin-arm64@0.2.3' - - '@deepseek-ai/libreoffice-kit-darwin-x64@0.2.3' - - '@deepseek-ai/libreoffice-kit-win32-arm64@0.2.3' - - '@deepseek-ai/libreoffice-kit-win32-x64@0.2.3' - - '@deepseek-ai/libreoffice-kit-wasm@0.2.3' + - '@deepseek-ai/libreoffice-kit@0.2.4' + - '@deepseek-ai/libreoffice-kit-darwin-arm64@0.2.4' + - '@deepseek-ai/libreoffice-kit-darwin-x64@0.2.4' + - '@deepseek-ai/libreoffice-kit-linux-arm64-glibc@0.2.4' + - '@deepseek-ai/libreoffice-kit-linux-x64-glibc@0.2.4' + - '@deepseek-ai/libreoffice-kit-win32-arm64@0.2.4' + - '@deepseek-ai/libreoffice-kit-win32-x64@0.2.4' # Fresh pi-ai releases carry the model catalog updates that are the whole # point of bumping it; waiting out the release age would defeat that. - '@earendil-works/pi-ai@1.3.0' diff --git a/scripts/build-exe-for-python-sdk-office.spec.ts b/scripts/build-exe-for-python-sdk-office.spec.ts index 64c61687ee..da865b0ef1 100644 --- a/scripts/build-exe-for-python-sdk-office.spec.ts +++ b/scripts/build-exe-for-python-sdk-office.spec.ts @@ -31,9 +31,12 @@ async function fixture() { it('locates installed target optionals and leaves other platforms and absent optionals out', async () => { const { staging, packageAt } = await fixture() await packageAt('@deepseek-ai/libreoffice-kit', { - optionalDependencies: { native: '1', foreign: '1', absent: '1' }, + optionalDependencies: { + '@deepseek-ai/libreoffice-kit-linux-x64-glibc': '1', + native: '1', foreign: '1', absent: '1', + }, }) - await packageAt('@deepseek-ai/libreoffice-kit-wasm') + await packageAt('@deepseek-ai/libreoffice-kit-linux-x64-glibc') await packageAt('native', { os: ['linux'], cpu: ['x64'] }) await packageAt('foreign', { os: ['darwin'], cpu: ['arm64'] }) @@ -41,14 +44,17 @@ it('locates installed target optionals and leaves other platforms and absent opt expect(packages.map(path => path.slice(staging.length + 1).replaceAll('\\', '/'))).toEqual([ 'node_modules/@deepseek-ai/libreoffice-kit', - 'node_modules/@deepseek-ai/libreoffice-kit-wasm', + 'node_modules/@deepseek-ai/libreoffice-kit-linux-x64-glibc', 'node_modules/native', ]) }) it('rejects a missing required dependency in the deployed closure', async () => { const { staging, packageAt } = await fixture() - await packageAt('@deepseek-ai/libreoffice-kit', { dependencies: { 'dsh-missing-office-fixture': '1' } }) + await packageAt('@deepseek-ai/libreoffice-kit', { + dependencies: { 'dsh-missing-office-fixture': '1' }, + optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64-glibc': '1' }, + }) await expect(officePackageDirectories(staging, { platform: 'linux', arch: 'x64' })) .rejects.toThrow('dsh-missing-office-fixture required by @deepseek-ai/libreoffice-kit is missing') @@ -56,7 +62,9 @@ it('rejects a missing required dependency in the deployed closure', async () => it('rejects an incomplete installed optional instead of omitting it', async () => { const { staging, packageAt } = await fixture() - await packageAt('@deepseek-ai/libreoffice-kit', { optionalDependencies: { broken: '1' } }) + await packageAt('@deepseek-ai/libreoffice-kit', { + optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64-glibc': '1', broken: '1' }, + }) await mkdir(join(staging, 'node_modules/broken'), { recursive: true }) await expect(officePackageDirectories(staging, { platform: 'linux', arch: 'x64' })) @@ -65,28 +73,39 @@ it('rejects an incomplete installed optional instead of omitting it', async () = it('rejects an ancestor dependency outside the deployed closure', async () => { const { root, staging, packageAt } = await fixture() - await packageAt('@deepseek-ai/libreoffice-kit', { dependencies: { 'ancestor-office-fixture': '1' } }) + await packageAt('@deepseek-ai/libreoffice-kit', { + dependencies: { 'ancestor-office-fixture': '1' }, + optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64-glibc': '1' }, + }) await packageAt('ancestor-office-fixture', {}, root) await expect(officePackageDirectories(staging, { platform: 'linux', arch: 'x64' })) .rejects.toThrow('outside the deployed closure') }) -it.each([true, false])('requires a staged WASM engine when declared=%s even when an ancestor has one', async (declared) => { +it('requires a staged target engine even when an ancestor has one', async () => { const { root, staging, packageAt } = await fixture() - await packageAt('@deepseek-ai/libreoffice-kit', declared ? { optionalDependencies: { '@deepseek-ai/libreoffice-kit-wasm': '0.0.1' } } : {}) - await packageAt('@deepseek-ai/libreoffice-kit-wasm', {}, root) + await packageAt('@deepseek-ai/libreoffice-kit', { optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64-glibc': '0.0.1' } }) + await packageAt('@deepseek-ai/libreoffice-kit-linux-x64-glibc', {}, root) await expect(officePackageDirectories(staging, { platform: 'linux', arch: 'x64' })) - .rejects.toThrow('Office engine @deepseek-ai/libreoffice-kit-wasm required for linux/x64 is missing.') + .rejects.toThrow('Office engine @deepseek-ai/libreoffice-kit-linux-x64-glibc required for linux/x64 is missing.') +}) + +it('rejects a target without a declared native engine even when WASM is staged', async () => { + const { staging, packageAt } = await fixture() + await packageAt('@deepseek-ai/libreoffice-kit', { optionalDependencies: { '@deepseek-ai/libreoffice-kit-wasm': '0.0.1' } }) + await packageAt('@deepseek-ai/libreoffice-kit-wasm') + await expect(officePackageDirectories(staging, { platform: 'freebsd', arch: 'x64' })) + .rejects.toThrow('Office engine @deepseek-ai/libreoffice-kit-freebsd-x64 is not declared for freebsd/x64.') }) it.each([ ['darwin', 'arm64', 'darwin-arm64'], ['darwin', 'x64', 'darwin-x64'], ['win32', 'arm64', 'win32-arm64'], ['win32', 'x64', 'win32-x64'], - ['linux', 'x64', 'linux-x64'], ['linux', 'arm64', 'wasm'], ['freebsd', 'x64', 'wasm'], + ['linux', 'x64', 'linux-x64-glibc'], ['linux', 'arm64', 'linux-arm64-glibc'], ])('locates only the %s/%s engine even when other engines are staged', async (platform, arch, selected) => { const { staging, packageAt } = await fixture() - const targets = ['darwin-arm64', 'darwin-x64', 'win32-arm64', 'win32-x64', 'linux-x64', 'wasm'] + const targets = ['darwin-arm64', 'darwin-x64', 'win32-arm64', 'win32-x64', 'linux-x64-glibc', 'linux-arm64-glibc', 'wasm'] const names = targets.map(target => `@deepseek-ai/libreoffice-kit-${target}`) await packageAt('@deepseek-ai/libreoffice-kit', { optionalDependencies: Object.fromEntries(names.map(name => [name, '0.0.1'])) }) for (const name of names) await packageAt(name) @@ -97,14 +116,16 @@ it.each([ ]) }) -it.each(['darwin', 'win32', 'linux'])('%s requires its native package even when WASM is staged', async (platform) => { +it.each([ + ['darwin', 'darwin-arm64'], ['win32', 'win32-arm64'], ['linux', 'linux-arm64-glibc'], +])('%s requires its native package even when WASM is staged', async (platform, engine) => { const { staging, packageAt } = await fixture() await packageAt('@deepseek-ai/libreoffice-kit', { optionalDependencies: { - '@deepseek-ai/libreoffice-kit-wasm': '0.0.1', [`@deepseek-ai/libreoffice-kit-${platform}-arm64`]: '0.0.1', + '@deepseek-ai/libreoffice-kit-wasm': '0.0.1', [`@deepseek-ai/libreoffice-kit-${engine}`]: '0.0.1', } }) await packageAt('@deepseek-ai/libreoffice-kit-wasm') await expect(officePackageDirectories(staging, { platform, arch: 'arm64' })) - .rejects.toThrow(`Office engine @deepseek-ai/libreoffice-kit-${platform}-arm64 required for ${platform}/arm64 is missing.`) + .rejects.toThrow(`Office engine @deepseek-ai/libreoffice-kit-${engine} required for ${platform}/arm64 is missing.`) }) it('downloads pinned npm packages into the sidecar without resolving or executing package scripts', async () => { diff --git a/scripts/gen-third-party-notices.spec.ts b/scripts/gen-third-party-notices.spec.ts index 48029d3326..641937d0f9 100644 --- a/scripts/gen-third-party-notices.spec.ts +++ b/scripts/gen-third-party-notices.spec.ts @@ -99,6 +99,7 @@ describe('tierExternalDeps', () => { '@deepseek-ai/libreoffice-kit', '@deepseek-ai/libreoffice-kit-wasm', '@deepseek-ai/libreoffice-kit-darwin-arm64', '@deepseek-ai/libreoffice-kit-darwin-x64', '@deepseek-ai/libreoffice-kit-win32-arm64', '@deepseek-ai/libreoffice-kit-win32-x64', + '@deepseek-ai/libreoffice-kit-linux-arm64-glibc', '@deepseek-ai/libreoffice-kit-linux-x64-glibc', ]) { expect(() => { assertRuntimeLicenses([{ name, license: 'MPL-2.0' }]) }).not.toThrow() expect(() => { assertRuntimeLicenses([{ name, license: 'GPL-3.0-only' }]) }).toThrow(name) diff --git a/scripts/gen-third-party-notices.ts b/scripts/gen-third-party-notices.ts index 8b48e2a08e..67f13f588c 100644 --- a/scripts/gen-third-party-notices.ts +++ b/scripts/gen-third-party-notices.ts @@ -70,6 +70,8 @@ const LIBREOFFICE_PACKAGES = new Set([ '@deepseek-ai/libreoffice-kit-darwin-x64', '@deepseek-ai/libreoffice-kit-win32-arm64', '@deepseek-ai/libreoffice-kit-win32-x64', + '@deepseek-ai/libreoffice-kit-linux-arm64-glibc', + '@deepseek-ai/libreoffice-kit-linux-x64-glibc', ]) /** diff --git a/scripts/libreoffice-engine.spec.ts b/scripts/libreoffice-engine.spec.ts index 73d81b01d7..7eff9cbe64 100644 --- a/scripts/libreoffice-engine.spec.ts +++ b/scripts/libreoffice-engine.spec.ts @@ -4,21 +4,26 @@ import { selectOfficeEngine } from './libreoffice-packages.mjs' it.each([ ['darwin', 'arm64', 'darwin-arm64'], ['darwin', 'x64', 'darwin-x64'], ['win32', 'arm64', 'win32-arm64'], ['win32', 'x64', 'win32-x64'], - ['linux', 'x64', 'wasm'], ['linux', 'arm64', 'wasm'], - ['darwin', 'other', 'wasm'], ['freebsd', 'x64', 'wasm'], -])('selects the declared engine for %s/%s', (platform, arch, expected) => { + ['linux', 'x64', 'linux-x64-glibc'], ['linux', 'arm64', 'linux-arm64-glibc'], +])('selects the declared native engine for %s/%s', (platform, arch, expected) => { const optionalDependencies = Object.fromEntries( - ['darwin-arm64', 'darwin-x64', 'win32-arm64', 'win32-x64', 'wasm'] + ['darwin-arm64', 'darwin-x64', 'win32-arm64', 'win32-x64', 'linux-x64-glibc', 'linux-arm64-glibc'] .map(engine => [`@deepseek-ai/libreoffice-kit-${engine}`, '0.0.1']), ) expect(selectOfficeEngine({ optionalDependencies }, { platform, arch })).toBe(expected) }) -it('selects a declared Linux native target without an OS-specific policy change', () => { - expect(selectOfficeEngine({ optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64': '1' } }, - { platform: 'linux', arch: 'x64' })).toBe('linux-x64') +it('rejects a Linux target whose glibc engine the kit does not declare', () => { + expect(() => selectOfficeEngine({ optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64': '1' } }, + { platform: 'linux', arch: 'x64' })).toThrow('Office engine @deepseek-ai/libreoffice-kit-linux-x64-glibc is not declared for linux/x64.') + expect(() => selectOfficeEngine({ optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64-glibc': '1' } }, + { platform: 'linux', arch: 'arm64' })).toThrow('Office engine @deepseek-ai/libreoffice-kit-linux-arm64-glibc is not declared for linux/arm64.') }) -it('uses WASM when no native targets are declared', () => { - expect(selectOfficeEngine({}, { platform: 'darwin', arch: 'x64' })).toBe('wasm') +it('rejects targets without a declared native engine even when WASM is declared', () => { + const optionalDependencies = { '@deepseek-ai/libreoffice-kit-wasm': '0.0.1' } + expect(() => selectOfficeEngine({ optionalDependencies }, { platform: 'freebsd', arch: 'x64' })) + .toThrow('Office engine @deepseek-ai/libreoffice-kit-freebsd-x64 is not declared for freebsd/x64.') + expect(() => selectOfficeEngine({}, { platform: 'darwin', arch: 'x64' })) + .toThrow('Office engine @deepseek-ai/libreoffice-kit-darwin-x64 is not declared for darwin/x64.') }) diff --git a/scripts/libreoffice-packages.d.mts b/scripts/libreoffice-packages.d.mts index 3ec87bce5c..3acbaedc7a 100644 --- a/scripts/libreoffice-packages.d.mts +++ b/scripts/libreoffice-packages.d.mts @@ -1,10 +1,11 @@ /** Target engine and transitive installed packages for Office process sidecars. */ /** - * Select the declared native engine, or WASM when the target has no native package. + * Require the declared native engine for the target. Linux targets select the glibc engine for their CPU. * @param manifest - Installed kit manifest. * @param target - Distribution platform and CPU. * @returns Engine package suffix. + * @throws {Error} When the kit manifest does not declare a native engine for the target. */ export function selectOfficeEngine(manifest: { optionalDependencies?: Record }, target: { platform: string; arch: string }): string diff --git a/scripts/libreoffice-packages.mjs b/scripts/libreoffice-packages.mjs index 8dca95bfc7..46682136cd 100644 --- a/scripts/libreoffice-packages.mjs +++ b/scripts/libreoffice-packages.mjs @@ -5,14 +5,20 @@ import { createRequire } from 'node:module' import { isAbsolute, join, relative, sep } from 'node:path' /** - * Require the declared native engine, or use WASM on other targets. + * Require the declared native engine for the target. Linux distributions are glibc builds, so a Linux target selects + * the kit's glibc engine for its CPU. * @param {{ optionalDependencies?: Record }} manifest - Installed kit manifest. * @param {{ platform: string, arch: string }} target - Distribution platform and CPU. * @returns {string} Engine package suffix. + * @throws {Error} When the kit manifest does not declare a native engine for the target. */ export function selectOfficeEngine(manifest, target) { - const native = `${target.platform}-${target.arch}` - return Object.hasOwn(manifest.optionalDependencies ?? {}, `@deepseek-ai/libreoffice-kit-${native}`) ? native : 'wasm' + const native = target.platform === 'linux' ? `linux-${target.arch}-glibc` : `${target.platform}-${target.arch}` + const name = `@deepseek-ai/libreoffice-kit-${native}` + if (!Object.hasOwn(manifest.optionalDependencies ?? {}, name)) { + throw new Error(`Office engine ${name} is not declared for ${target.platform}/${target.arch}.`) + } + return native } /** diff --git a/scripts/smoke-python-runtime.py b/scripts/smoke-python-runtime.py index 0eea7048f8..704a099f44 100644 --- a/scripts/smoke-python-runtime.py +++ b/scripts/smoke-python-runtime.py @@ -1127,15 +1127,19 @@ def smoke_sdk_office(executable: Path) -> None: assert not (office.parent / "primary").exists(), "Office download unexpectedly prepared the authoring environment" adapter = office / "node_modules/@deepseek-ai/libreoffice-kit/package.json" native = stem.removeprefix("deepseek-harness-sdk-runtime-").replace("win-", "win32-").replace("macos-", "darwin-") + if native.startswith("linux-"): + native = f"{native}-glibc" declared = json.loads(adapter.read_text(encoding="utf-8")).get("optionalDependencies", {}) - selected = native if f"@deepseek-ai/libreoffice-kit-{native}" in declared else "wasm" - expected_backend = "wasm" if selected == "wasm" else "native" + expected_package = f"@deepseek-ai/libreoffice-kit-{native}" + if expected_package not in declared: + raise AssertionError(f"Kit manifest must declare native engine {expected_package}: {sorted(declared)}") + expected_backend = "native" engines = [ - json.loads(manifest.read_text())["engine"]["kind"] + (manifest.parent.name, json.loads(manifest.read_text())["engine"]["kind"]) for manifest in (office / "node_modules/@deepseek-ai").glob("libreoffice-kit-*/prebuilds.json") ] - if engines != [expected_backend]: - raise AssertionError(f"Office sidecar must contain only {expected_backend}: {engines}") + if engines != [(f"libreoffice-kit-{native}", expected_backend)]: + raise AssertionError(f"Office sidecar must contain only {expected_package} ({expected_backend}): {engines}") plugin = root / "office.mjs" shutil.copy2(Path(__file__).resolve().parent / "fixtures/python-sdk-office.mjs", plugin) documents = checks["copy_documents"](root)