From c7b6fba276902e5853446b1b4886c0aa782646ab Mon Sep 17 00:00:00 2001 From: creatixchu Date: Tue, 20 Oct 2026 15:28:55 +0800 Subject: [PATCH 1/2] feat(plugins): enforce bundle Host platform support --- apps/web/tests/bundle-platform.e2e.ts | 60 +++++++++++++++++++ .../unsupported-platform.expected.md | 1 + .../official-unsupported-platform.expected.md | 53 ++++++++++++++++ ...e-enabled-unsupported-platform.expected.md | 54 +++++++++++++++++ .../manager-unsupported-platform.expected.md | 54 +++++++++++++++++ apps/web/tests/plugin-config.e2e.ts | 5 +- apps/web/tests/plugin-manager.e2e.ts | 6 +- apps/web/tests/preview-boot.e2e.ts | 17 ++---- apps/web/tsconfig.json | 1 + packages/boot/app-boot/README.i18n.yaml | 4 +- packages/boot/app-boot/README.md | 2 + packages/boot/app-boot/README.zh.md | 2 + packages/boot/app-boot/src/bundle-platform.ts | 28 +++++++++ packages/boot/app-boot/src/index.ts | 1 + packages/boot/app-boot/src/profile-plugins.ts | 6 +- packages/boot/app-boot/src/profile.ts | 5 +- .../app-boot/tests/bundle-platform.spec.ts | 18 ++++++ .../app-boot/tests/profile-plugins.spec.ts | 12 ++++ packages/boot/app-boot/tests/profile.spec.ts | 22 ++++++- packages/boot/plugin-manager/README.i18n.yaml | 4 +- packages/boot/plugin-manager/README.md | 2 + packages/boot/plugin-manager/README.zh.md | 2 + packages/boot/plugin-manager/src/index.ts | 9 ++- .../boot/plugin-manager/src/operations.ts | 3 +- packages/boot/plugin-manager/src/tools.ts | 1 + packages/boot/plugin-manager/src/types.ts | 2 +- .../boot/plugin-manager/tests/manager.spec.ts | 35 ++++++++++- .../plugin-manager/tests/operations.spec.ts | 11 ++++ .../boot/plugin-manager/tests/tools.spec.ts | 2 + .../client/ui-plugin-manager/README.i18n.yaml | 4 +- packages/client/ui-plugin-manager/README.md | 2 + .../client/ui-plugin-manager/README.zh.md | 2 + .../ui-plugin-manager/src/client/locales.ts | 2 + .../src/client/presentation.ts | 1 + .../tests/components.client.spec.tsx | 5 ++ .../experimental/cua-bundle/README.i18n.yaml | 4 +- packages/experimental/cua-bundle/README.md | 2 +- packages/experimental/cua-bundle/README.zh.md | 2 +- packages/experimental/cua-bundle/package.json | 5 +- .../extensions/tool-cordis/src/api-catalog.ts | 2 +- .../util/package-manifest/README.i18n.yaml | 4 +- packages/util/package-manifest/README.md | 1 + packages/util/package-manifest/README.zh.md | 1 + packages/util/package-manifest/src/types.ts | 2 + scripts/optional-bundles.spec.ts | 3 + tsconfig.host.json | 1 + 46 files changed, 428 insertions(+), 37 deletions(-) create mode 100644 apps/web/tests/bundle-platform.e2e.ts create mode 100644 apps/web/tests/expected/cua-permissions/unsupported-platform.expected.md create mode 100644 apps/web/tests/expected/plugin-config/official-unsupported-platform.expected.md create mode 100644 apps/web/tests/expected/plugin-manager/live-enabled-unsupported-platform.expected.md create mode 100644 apps/web/tests/expected/plugin-manager/manager-unsupported-platform.expected.md create mode 100644 packages/boot/app-boot/src/bundle-platform.ts create mode 100644 packages/boot/app-boot/tests/bundle-platform.spec.ts diff --git a/apps/web/tests/bundle-platform.e2e.ts b/apps/web/tests/bundle-platform.e2e.ts new file mode 100644 index 0000000000..1b23da431a --- /dev/null +++ b/apps/web/tests/bundle-platform.e2e.ts @@ -0,0 +1,60 @@ +/** Unsupported Host platforms leave the profile and running PTC configuration untouched. */ +import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' +import { chromium, type Browser } from 'playwright' +import type {} from '@deepseek-ai/dsh-ptc-runtime' +import { expect, it, onTestFinished } from 'vitest' +import { captureStableAria, compareOrRefreshGolden, launchWebScaffold, webSnapshotMode, type WebScaffold } from './scaffold.ts' +import { connectFreshWorkspaceZh, ZH_BROWSER_LOCALE } from './support.ts' + +it('disables unsupported bundles, shows the Host restriction, and refuses direct activation without changing PTC', async () => { + const root = await mkdtemp(join(tmpdir(), 'bundle-platform-web-')) + const owned: { scaffold?: WebScaffold; browser?: Browser } = {} + onTestFinished(async () => { + try { await owned.browser?.close() } finally { + try { await owned.scaffold?.close() } finally { await rm(root, { recursive: true, force: true }) } + } + }) + const name = 'host-platform-only' + await writeFile(join(root, 'package.json'), JSON.stringify({ name, version: '1.0.0', dsh: { bundle: { + patch: './cordis.patch.yml', platforms: [process.platform === 'darwin' ? 'win32' : 'darwin'], + } } })) + await writeFile(join(root, 'cordis.patch.yml'), '- id: ptc-runtime\n config:\n executionMode: persistent-in-memory\n') + const scaffold = owned.scaffold = await launchWebScaffold({ profile: { packages: [{ dir: root }] } }) + const browser = owned.browser = await chromium.launch() + const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: ZH_BROWSER_LOCALE }) + await page.goto(scaffold.authenticatedUrl) + await connectFreshWorkspaceZh(page, scaffold.workspaceCwd) + await page.getByRole('navigation', { name: '全局面板' }).getByRole('button', { name: '插件', exact: true }).click() + const reason = '此插件不支持运行 DSH 的主机操作系统' + const card = page.locator(`[data-plugin-package="${name}"]`) + await card.getByText(reason, { exact: true }).waitFor() + expect(await card.getByRole('switch').isEnabled()).toBe(false) + expect(await card.getByRole('switch').getAttribute('aria-checked')).toBe('false') + await compareOrRefreshGolden(fileURLToPath(new URL('./expected/cua-permissions/unsupported-platform.expected.md', import.meta.url)), + await captureStableAria(page, `[data-plugin-package="${name}"] p[role="status"]`, scaffold.workspaceCwd), webSnapshotMode()) + const manifest = join(scaffold.harnessHome, 'profiles/scaffold/package.json') + const before = await readFile(manifest, 'utf8') + const runtimeId = () => [...scaffold.ctx.loader.entries()].find(entry => entry.options.id === 'ptc-runtime')?.fiber?.uid + const beforeRuntime = runtimeId() + expect(beforeRuntime).toBeTypeOf('number') + expect(scaffold.ctx.ptcRuntime.programFormat).toBe('function-body') + const names = [name] + if (process.platform !== 'darwin') { + const cua = page.locator('[data-plugin-package="@deepseek-ai/dsh-cua-bundle"]') + await cua.getByText(reason, { exact: true }).waitFor() + expect(await cua.getByRole('switch').isEnabled()).toBe(false) + names.push('@deepseek-ai/dsh-cua-bundle') + } + for (const bundle of names) { + expect(await scaffold.ctx.pluginManager.setBundleEnabled(bundle, true)).toMatchObject({ + changed: false, application: 'failed', error: { code: 'unsupported-platform' }, + }) + } + expect(await readFile(manifest, 'utf8')).toBe(before) + expect(runtimeId()).toBe(beforeRuntime) + expect(scaffold.ctx.ptcRuntime.programFormat).toBe('function-body') + expect(scaffold.ctx.get('computerUse')).toBeUndefined() +}) diff --git a/apps/web/tests/expected/cua-permissions/unsupported-platform.expected.md b/apps/web/tests/expected/cua-permissions/unsupported-platform.expected.md new file mode 100644 index 0000000000..b6aa94aa05 --- /dev/null +++ b/apps/web/tests/expected/cua-permissions/unsupported-platform.expected.md @@ -0,0 +1 @@ +- status: 此插件不支持运行 DSH 的主机操作系统 diff --git a/apps/web/tests/expected/plugin-config/official-unsupported-platform.expected.md b/apps/web/tests/expected/plugin-config/official-unsupported-platform.expected.md new file mode 100644 index 0000000000..f3f49e709b --- /dev/null +++ b/apps/web/tests/expected/plugin-config/official-unsupported-platform.expected.md @@ -0,0 +1,53 @@ +- heading "插件" [level=1] +- text: 安装、启用和配置插件 +- button "插件说明" +- button "刷新" +- group "添加插件": + - button "添加插件" + - button "选择添加插件方式" +- heading "内置插件配置" [level=3] +- list: + - listitem: + - button "查看 子智能体": 子智能体 + - text: 设置子智能体的递归层级、数量和模型。 + - listitem: + - button "查看 网页搜索": 网页搜索 + - text: 设置 DeepSeek 的搜索提供方。 + - listitem: + - button "查看 Agent 循环": Agent 循环 + - text: 控制 Agent 派发工具调用的方式。 + - listitem: + - button "查看 终端": 终端 + - text: 限制每条命令最多能跑多久、最多输出多少内容。 +- heading "实验性插件" [level=3] +- button "更多" +- list: + - listitem: + - button "查看 智能体团队": 智能体团队 + - text: 实验性 启用团队协作、团队工具、成员列表和共享任务看板。 + - switch "启用 智能体团队" + - listitem: + - button "查看 语音输入": 语音输入 + - text: 实验性 在本机使用 SenseVoice 转写录音,首次使用需安装依赖。 + - switch "启用 语音输入" + - listitem: + - button "查看 自动授权审查": 自动授权审查 + - text: 实验性 提供自动审查权限模式,由模型在每次工具调用前判断是否授权。 + - switch "启用 自动授权审查" + - listitem: + - button "查看 开发者工具": 开发者工具 + - text: 实验性 查看调试会话原始数据、聊天消息分组数据,以及调试 NodeJS 后端 + - switch "启用 开发者工具" + - listitem: + - button "查看 Computer Use": Computer Use + - text: 实验性 异常 目前仅支持 macOS,Windows 支持正在开发中。为已有及新建 PTC 会话加载 Computer Use。请切换到 PTC 模式来使用,并授予辅助功能和屏幕录制权限。 + - switch "启用 Computer Use" [disabled] + - status: 此插件不支持运行 DSH 的主机操作系统 +- heading "已安装插件" [level=3] +- list: + - listitem: + - button "查看 @fixture/live-client": "@fixture/live-client" + - switch "启用 @fixture/live-client" + - listitem: + - button "查看 dsh-web-scaffold-defaults": dsh-web-scaffold-defaults + - switch "启用 dsh-web-scaffold-defaults" [checked] diff --git a/apps/web/tests/expected/plugin-manager/live-enabled-unsupported-platform.expected.md b/apps/web/tests/expected/plugin-manager/live-enabled-unsupported-platform.expected.md new file mode 100644 index 0000000000..d3f989f544 --- /dev/null +++ b/apps/web/tests/expected/plugin-manager/live-enabled-unsupported-platform.expected.md @@ -0,0 +1,54 @@ +- heading "插件" [level=1] +- text: 安装、启用和配置插件 +- button "插件说明" +- button "刷新" +- group "添加插件": + - button "添加插件" + - button "选择添加插件方式" +- heading "内置插件配置" [level=3] +- list: + - listitem: + - button "查看 子智能体": 子智能体 + - text: 设置子智能体的递归层级、数量和模型。 + - listitem: + - button "查看 网页搜索": 网页搜索 + - text: 设置 DeepSeek 的搜索提供方。 + - listitem: + - button "查看 Agent 循环": Agent 循环 + - text: 控制 Agent 派发工具调用的方式。 + - listitem: + - button "查看 终端": 终端 + - text: 限制每条命令最多能跑多久、最多输出多少内容。 +- heading "实验性插件" [level=3] +- button "更多" +- list: + - listitem: + - button "查看 智能体团队": 智能体团队 + - text: 实验性 启用团队协作、团队工具、成员列表和共享任务看板。 + - switch "启用 智能体团队" + - listitem: + - button "查看 语音输入": 语音输入 + - text: 实验性 在本机使用 SenseVoice 转写录音,首次使用需安装依赖。 + - switch "启用 语音输入" + - listitem: + - button "查看 自动授权审查": 自动授权审查 + - text: 实验性 提供自动审查权限模式,由模型在每次工具调用前判断是否授权。 + - switch "启用 自动授权审查" + - listitem: + - button "查看 开发者工具": 开发者工具 + - text: 实验性 查看调试会话原始数据、聊天消息分组数据,以及调试 NodeJS 后端 + - switch "启用 开发者工具" + - listitem: + - button "查看 Computer Use": Computer Use + - text: 实验性 异常 目前仅支持 macOS,Windows 支持正在开发中。为已有及新建 PTC 会话加载 Computer Use。请切换到 PTC 模式来使用,并授予辅助功能和屏幕录制权限。 + - switch "启用 Computer Use" [disabled] + - status: 此插件不支持运行 DSH 的主机操作系统 +- heading "已安装插件" [level=3] +- list: + - listitem: + - button "查看 @fixture/bundle": "@fixture/bundle" + - text: Registry description for the fixture bundle. + - switch "启用 @fixture/bundle" [checked] + - listitem: + - button "查看 dsh-web-scaffold-defaults": dsh-web-scaffold-defaults + - switch "启用 dsh-web-scaffold-defaults" [checked] diff --git a/apps/web/tests/expected/plugin-manager/manager-unsupported-platform.expected.md b/apps/web/tests/expected/plugin-manager/manager-unsupported-platform.expected.md new file mode 100644 index 0000000000..d2df587ad3 --- /dev/null +++ b/apps/web/tests/expected/plugin-manager/manager-unsupported-platform.expected.md @@ -0,0 +1,54 @@ +- heading "插件" [level=1] +- text: 安装、启用和配置插件 +- button "插件说明" +- button "刷新" +- group "添加插件": + - button "添加插件" + - button "选择添加插件方式" +- heading "内置插件配置" [level=3] +- list: + - listitem: + - button "查看 子智能体": 子智能体 + - text: 设置子智能体的递归层级、数量和模型。 + - listitem: + - button "查看 网页搜索": 网页搜索 + - text: 设置 DeepSeek 的搜索提供方。 + - listitem: + - button "查看 Agent 循环": Agent 循环 + - text: 控制 Agent 派发工具调用的方式。 + - listitem: + - button "查看 终端": 终端 + - text: 限制每条命令最多能跑多久、最多输出多少内容。 +- heading "实验性插件" [level=3] +- button "更多" +- list: + - listitem: + - button "查看 智能体团队": 智能体团队 + - text: 实验性 启用团队协作、团队工具、成员列表和共享任务看板。 + - switch "启用 智能体团队" + - listitem: + - button "查看 语音输入": 语音输入 + - text: 实验性 在本机使用 SenseVoice 转写录音,首次使用需安装依赖。 + - switch "启用 语音输入" + - listitem: + - button "查看 自动授权审查": 自动授权审查 + - text: 实验性 提供自动审查权限模式,由模型在每次工具调用前判断是否授权。 + - switch "启用 自动授权审查" + - listitem: + - button "查看 开发者工具": 开发者工具 + - text: 实验性 查看调试会话原始数据、聊天消息分组数据,以及调试 NodeJS 后端 + - switch "启用 开发者工具" + - listitem: + - button "查看 Computer Use": Computer Use + - text: 实验性 异常 目前仅支持 macOS,Windows 支持正在开发中。为已有及新建 PTC 会话加载 Computer Use。请切换到 PTC 模式来使用,并授予辅助功能和屏幕录制权限。 + - switch "启用 Computer Use" [disabled] + - status: 此插件不支持运行 DSH 的主机操作系统 +- heading "已安装插件" [level=3] +- list: + - listitem: + - button "查看 @fixture/bundle": "@fixture/bundle" + - text: Registry description for the fixture bundle. + - switch "启用 @fixture/bundle" + - listitem: + - button "查看 dsh-web-scaffold-defaults": dsh-web-scaffold-defaults + - switch "启用 dsh-web-scaffold-defaults" [checked] diff --git a/apps/web/tests/plugin-config.e2e.ts b/apps/web/tests/plugin-config.e2e.ts index fabf193a95..4040b0e072 100644 --- a/apps/web/tests/plugin-config.e2e.ts +++ b/apps/web/tests/plugin-config.e2e.ts @@ -19,7 +19,8 @@ import { import { ZH_BROWSER_LOCALE, saveFailureShot } from './support.ts' const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/plugin-config', import.meta.url)) -const OFFICIAL_EXPECTED = join(SNAPSHOT_DIR, 'official.expected.md') +const OFFICIAL_EXPECTED = join(SNAPSHOT_DIR, process.platform === 'darwin' + ? 'official.expected.md' : 'official-unsupported-platform.expected.md') const ROW_EXPECTED = join(SNAPSHOT_DIR, 'row.expected.md') const BUNDLE_EXPECTED = join(SNAPSHOT_DIR, 'bundle.expected.md') const FIXTURE_PLUGINS = fileURLToPath(new URL('./fixtures/plugins', import.meta.url)) @@ -440,7 +441,7 @@ describe('web e2e: plugin configuration pages', () => { it.skipIf(MODE === 'record')('keeps the fixture inventory closed', async () => { expect(tripwire.warnings).toEqual([]) - await assertFixtureInventory(SNAPSHOT_DIR, ['bundle.expected.md', 'official.expected.md', 'row.expected.md', 'subagent.expected.md', 'web-search.expected.md']) + await assertFixtureInventory(SNAPSHOT_DIR, ['bundle.expected.md', 'official.expected.md', 'official-unsupported-platform.expected.md', 'row.expected.md', 'subagent.expected.md', 'web-search.expected.md']) }) diff --git a/apps/web/tests/plugin-manager.e2e.ts b/apps/web/tests/plugin-manager.e2e.ts index d523b1328b..7f52301f69 100644 --- a/apps/web/tests/plugin-manager.e2e.ts +++ b/apps/web/tests/plugin-manager.e2e.ts @@ -21,8 +21,9 @@ import { } from './support.ts' const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/plugin-manager', import.meta.url)) -const MANAGER_EXPECTED = join(SNAPSHOT_DIR, 'manager.expected.md') -const LIVE_EXPECTED = join(SNAPSHOT_DIR, 'live-enabled.expected.md') +const PLATFORM_SUFFIX = process.platform === 'darwin' ? '' : '-unsupported-platform' +const MANAGER_EXPECTED = join(SNAPSHOT_DIR, `manager${PLATFORM_SUFFIX}.expected.md`) +const LIVE_EXPECTED = join(SNAPSHOT_DIR, `live-enabled${PLATFORM_SUFFIX}.expected.md`) const EXPORTS_EXPECTED = join(SNAPSHOT_DIR, 'exports.expected.md') const EXPORTS_EN_EXPECTED = join(SNAPSHOT_DIR, 'exports-en.expected.md') const FIXTURE_PLUGINS = fileURLToPath(new URL('./fixtures/plugins', import.meta.url)) @@ -1135,6 +1136,7 @@ describe('web e2e: plugin manager', () => { await assertFixtureInventory(SNAPSHOT_DIR, [ 'manager.expected.md', 'live-enabled.expected.md', 'missing-bundle.expected.md', 'exports.expected.md', 'exports-en.expected.md', 'icons.expected.md', 'loading.expected.md', 'refresh.expected.md', 'ime-enter.expected.md', 'header-responsive.expected.md', 'preview.expected.md', + 'manager-unsupported-platform.expected.md', 'live-enabled-unsupported-platform.expected.md', ]) }) }) diff --git a/apps/web/tests/preview-boot.e2e.ts b/apps/web/tests/preview-boot.e2e.ts index d4d502e388..1d2ad8a227 100644 --- a/apps/web/tests/preview-boot.e2e.ts +++ b/apps/web/tests/preview-boot.e2e.ts @@ -697,22 +697,17 @@ async function toggleOptionalBundles(page: Page): Promise { }) expect(result.optional.map(entry => entry.name).sort()).toEqual([...OPTIONAL_BUNDLES].sort()) expect(result.optional.filter(entry => entry.enabled || entry.availability !== 'installation')).toEqual([]) - expect(result.optional.filter(entry => entry.error !== null)).toEqual([]) + expect(result.optional.filter(entry => entry.error !== null)).toEqual([ + expect.objectContaining({ name: '@deepseek-ai/dsh-cua-bundle', error: { code: 'unsupported-platform' } }), + ]) // Metadata resolves through the Worker's Node internal modules: every optional bundle shows its title and icon. expect(result.optional.filter(entry => entry.metaError !== null || entry.title !== 'object' || entry.icon !== 'string')).toEqual([]) expect(result.inventoryErrors).toEqual([]) console.info(`preview boot: optional bundle toggles ${JSON.stringify(result.toggles.map(({ name, enable, disable, error }) => ({ name, enable, disable, error })))}`) - const cua = result.toggles.find(toggle => toggle.name === '@deepseek-ai/dsh-cua-bundle')! - expect(cua).toMatchObject({ - enable: 'applied', disable: 'applied', - error: null, - restored: true, + expect(result.toggles.find(toggle => toggle.name === '@deepseek-ai/dsh-cua-bundle')).toMatchObject({ + enable: 'failed', disable: 'applied', error: { code: 'unsupported-platform' }, + changed: 0, inactive: [], restored: true, }) - expect(cua.changed).toBeGreaterThan(0) - expect(cua.inactive).toEqual([]) - expect(cua.plugins).toContainEqual(expect.objectContaining({ - moduleName: '@deepseek-ai/dsh-experimental-cua-macos', enabled: false, fiberPhase: null, - })) const supported = result.toggles.filter(toggle => toggle.name !== '@deepseek-ai/dsh-cua-bundle') expect(supported.filter(toggle => toggle.enable !== 'applied' || toggle.disable !== 'applied') .map(({ name, enable, disable }) => ({ name, enable, disable }))).toEqual([]) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index db02a233ec..dcef16f6b7 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -84,6 +84,7 @@ "tests/input-plugin-extensions.e2e.ts", "tests/plugin-manager.e2e.ts", "tests/cua-optin.e2e.ts", + "tests/bundle-platform.e2e.ts", "tests/cua-permissions.e2e.ts", "tests/schedule-header.e2e.ts", "tests/worktree-opt-in.e2e.ts", diff --git a/packages/boot/app-boot/README.i18n.yaml b/packages/boot/app-boot/README.i18n.yaml index be702d4775..2cfa7ed0be 100644 --- a/packages/boot/app-boot/README.i18n.yaml +++ b/packages/boot/app-boot/README.i18n.yaml @@ -24,8 +24,8 @@ en: 4a424cd401556f20 zh: 0b34dd18e0db6cea /deepseek-ai-dsh-app-boot/use-this-package/profiles: - en: 0a1b5f4f40d835a7 - zh: d8f4b54160aa033b + en: 9209d1569f652dcf + zh: 8adffa229a0c6f41 /deepseek-ai-dsh-app-boot/use-this-package/previewing-the-effective-configuration: en: 646a0ccdd7881ad1 zh: e3696acb1573dd7b diff --git a/packages/boot/app-boot/README.md b/packages/boot/app-boot/README.md index 4b43180589..f79ea4f9d7 100644 --- a/packages/boot/app-boot/README.md +++ b/packages/boot/app-boot/README.md @@ -55,6 +55,8 @@ Admission happens only at composition boundaries DSH owns, and a denied row is d Exact-version exemptions live in the profile's own `compatibility.json`, not in its `package.json`, so an exemption write never touches the dependency manifest, the bundle list, or Cordis patch files. It maps exact `package-name@version` keys to lists of exact DSH runtime versions; neither a plugin upgrade nor a DSH upgrade inherits permission. A missing file means no exemptions. A malformed one never stops the profile from starting: records the reader accepts still apply, each rejected record is reported on stderr beside the plugin denials, and the file is then treated as read-only, so a grant or revocation refuses and asks the user to repair it by hand instead of overwriting their content. [Plugin Manager](../plugin-manager/README.md#version-compatibility-and-exemptions) owns the grant, revocation, and risk confirmation each change requires. +A bundle may declare `dsh.bundle.platforms` as a nonempty list of Node Host platform names, such as `["darwin"]`. The launcher validates this declaration before reading the bundle patch. An unsupported Host skips the entire layer, retains its saved selection, and reports the reason through `skippedBundles`; other layers remain effective. Omission permits every platform. Browser clients do not determine Host support. + Your machine-local preferences also live in the Harness home: - **`.env`** — your ordinary environment layers: the invoking directory's file outranks the Harness-home file, and both sit below the inherited environment. Variables that decide how the process starts (`PATH`, `DSH_*`, `XDG_*` and similar) are rejected from files: export them instead. The four proxy names (`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, `NO_PROXY`) are accepted from the Harness-home file only, never from the invoking directory's, which arrives with a clone. For a non-product bin that just wants one directory's `.env`, a missing file is fine and an unloadable one prints one labelled warning line. diff --git a/packages/boot/app-boot/README.zh.md b/packages/boot/app-boot/README.zh.md index eee5749ba6..7a90913d09 100644 --- a/packages/boot/app-boot/README.zh.md +++ b/packages/boot/app-boot/README.zh.md @@ -55,6 +55,8 @@ profile 导入插件前,DSH 会将其声明的 DSH 版本要求与 `getDshRunt 精确版本豁免保存在 profile 自己的 `compatibility.json` 中,而不是 `package.json`,因此写豁免不会触及依赖清单、组合包列表或 Cordis patch 文件。它把精确的 `package-name@version` 键映射到精确 DSH 运行时版本列表;插件升级和 DSH 升级都不继承授权。文件缺失表示没有豁免。文件损坏绝不会阻止 profile 启动:读取器接受的记录仍然生效,每条被拒绝的记录会与插件拒绝信息一起输出到 stderr,此后该文件被视为只读,因此授予或撤销会拒绝执行并要求用户手工修复,而不是覆盖用户的内容。[插件管理器](../plugin-manager/README.zh.md#version-compatibility-and-exemptions)负责每次变更所需的授权、撤销与风险确认。 +组合包可以用 `dsh.bundle.platforms` 声明非空的 Node Host 平台名称列表,例如 `["darwin"]`。启动器在读取组合包 patch 前验证此声明。Host 不受支持时会跳过整个配置层,保留已保存的选择,并通过 `skippedBundles` 报告原因;其他配置层继续生效。省略此字段时允许所有平台。浏览器所在机器的平台不决定 Host 是否受支持。 + 你的机器本地偏好同样位于 harness home 中: - **`.env`**——你的普通环境层:调用目录的文件优先于 harness home 的文件,两者都低于继承环境。在文件中设置的进程启动变量(如 `PATH`、`DSH_*`、`XDG_*`)会被拒绝:请改为导出这些变量。四个代理名(`HTTP_PROXY`、`HTTPS_PROXY`、`ALL_PROXY`、`NO_PROXY`)只从 harness home 的文件接受,绝不从调用目录的文件接受——后者随 clone 一起到来。对于只想加载某个目录 `.env` 的非产品 bin,文件缺失不影响启动,文件无法加载时输出一行带标签的警告。 diff --git a/packages/boot/app-boot/src/bundle-platform.ts b/packages/boot/app-boot/src/bundle-platform.ts new file mode 100644 index 0000000000..4d3f41e23e --- /dev/null +++ b/packages/boot/app-boot/src/bundle-platform.ts @@ -0,0 +1,28 @@ +/** Host operating-system admission for optional bundle layers. */ + +/** A valid bundle declaration excludes the operating system running DSH. */ +export class UnsupportedBundlePlatformError extends Error { + /** + * @param platforms Node platform names supported by the bundle. + * @param platform Operating system of the DSH Host. + */ + constructor(platforms: readonly string[], platform: string) { + super(`Bundle supports Host platforms ${platforms.join(', ')}; the DSH Host is running ${platform}`) + this.name = 'UnsupportedBundlePlatformError' + } +} + +/** + * Validate package metadata and reject an unsupported Host before selecting or composing a bundle. + * @param platforms The optional `dsh.bundle.platforms` field read from package.json. + * @param platform Operating system of the DSH Host, from Node's `process.platform`. + * @throws When the declaration is malformed or excludes the Host; omission allows every platform. + */ +export function assertBundlePlatform(platforms: unknown, platform: string): void { + if (platforms === undefined) return + if (!Array.isArray(platforms) || platforms.length === 0 + || !platforms.every((value): value is string => typeof value === 'string' && /^[a-z][a-z0-9]*$/.test(value))) { + throw new Error('dsh.bundle.platforms must be a nonempty list of Node platform names') + } + if (!platforms.includes(platform)) throw new UnsupportedBundlePlatformError(platforms, platform) +} diff --git a/packages/boot/app-boot/src/index.ts b/packages/boot/app-boot/src/index.ts index fded02c9c8..0dc2791df2 100644 --- a/packages/boot/app-boot/src/index.ts +++ b/packages/boot/app-boot/src/index.ts @@ -55,6 +55,7 @@ declare module '@deepseek-ai/cordis' { } } +export { assertBundlePlatform, UnsupportedBundlePlatformError } from './bundle-platform.ts' export { composeEntries, createRuntimeResolution, diff --git a/packages/boot/app-boot/src/profile-plugins.ts b/packages/boot/app-boot/src/profile-plugins.ts index 1cd55e9135..24d3ae5355 100644 --- a/packages/boot/app-boot/src/profile-plugins.ts +++ b/packages/boot/app-boot/src/profile-plugins.ts @@ -1,6 +1,7 @@ /** Installed profile dependencies and their bundle activation after package-manager operations. */ import { join } from 'node:path' +import { assertBundlePlatform } from './bundle-platform.ts' import { readProfileManifest, resolveBundleDir, writeProfileManifest, type ProfileManifest } from './profile.ts' /** Profile directory and installation used by the shared bundle resolver. */ @@ -112,7 +113,10 @@ export function reconcileProfilePlugins(options: ProfilePluginLocation & { const previous = after.manifest.dsh?.profile?.bundles ?? [] const bundles = previous.filter(name => !(beforeNames.has(name) || afterNames.has(name)) || bundleNames.has(name)) for (const dependency of after.dependencies) { - if (dependency.bundle && !disabled.has(dependency.name) && !bundles.includes(dependency.name)) bundles.push(dependency.name) + if (dependency.bundle && !disabled.has(dependency.name) && !bundles.includes(dependency.name)) { + assertBundlePlatform(bundleManifest(options, dependency.name)?.dsh?.bundle?.platforms, process.platform) + bundles.push(dependency.name) + } } const changed = bundles.length !== previous.length || bundles.some((name, index) => name !== previous[index]) const manifest = changed ? writeProfileBundles(options.profileDir, after.manifest, bundles) : after.manifest diff --git a/packages/boot/app-boot/src/profile.ts b/packages/boot/app-boot/src/profile.ts index db23fbf232..10fba4d4f7 100644 --- a/packages/boot/app-boot/src/profile.ts +++ b/packages/boot/app-boot/src/profile.ts @@ -28,6 +28,7 @@ import type { EntryOptions } from '@deepseek-ai/cordis-plugin-loader' import { applyEntryPatches, type PatchOptions } from '@deepseek-ai/cordis-plugin-include' import { resolveDshHome } from '@deepseek-ai/dsh-home-paths' import type { DshBundleManifest, DshPackageManifest } from '@deepseek-ai/dsh-package-manifest' +import { assertBundlePlatform } from './bundle-platform.ts' import { evaluatePluginCompatibility, pluginCompatibilityWarning } from './plugin-compatibility.ts' import { readProfileVersionExemptions } from './profile-compatibility.ts' import { loadOverlayPatches } from './index.ts' @@ -731,7 +732,8 @@ export function resolveBundleDir( * the shared Harness home. This is used by application-owned profiles whose * package project and lifecycle belong to that application. * Retired bundles are removed from the stored bundle list first, rewriting the - * manifest when it listed one. Unreadable bundles, and bundles whose own dsh requirements the profile does not exempt, are skipped + * manifest when it listed one. Unreadable bundles, unsupported Host platforms, and bundles whose own dsh requirements + * the profile does not exempt are skipped * without changing the manifest and listed in `skippedBundles`; nothing is printed. * @param binName - the diagnostic prefix on thrown errors. * @param dir - absolute profile package directory. @@ -758,6 +760,7 @@ export function loadProfileDirectory( if (bundle === undefined) { throw new Error(`${binName}: profile bundle ${JSON.stringify(packageName)} declares no dsh.bundle in its package.json`) } + assertBundlePlatform(bundle.platforms, process.platform) // A bundle is not a plugin row, so row admission never reads its own dsh requirements. const issue = evaluatePluginCompatibility(bundleManifest, exemptions) if (issue !== undefined && !issue.exempted) throw new Error(pluginCompatibilityWarning(issue)) diff --git a/packages/boot/app-boot/tests/bundle-platform.spec.ts b/packages/boot/app-boot/tests/bundle-platform.spec.ts new file mode 100644 index 0000000000..cdb7a75edf --- /dev/null +++ b/packages/boot/app-boot/tests/bundle-platform.spec.ts @@ -0,0 +1,18 @@ +/** Bundle declarations admit the Host operating system independently of browser clients. */ +import { expect, it } from 'vitest' +import { assertBundlePlatform, UnsupportedBundlePlatformError } from '../src/bundle-platform.ts' + +it.each(['darwin', 'win32', 'linux'])('allows undeclared platforms and an explicit %s Host', (platform) => { + expect(() => { assertBundlePlatform(undefined, platform) }).not.toThrow() + expect(() => { assertBundlePlatform([platform], platform) }).not.toThrow() + expect(() => { assertBundlePlatform(['darwin', 'win32', 'linux'], platform) }).not.toThrow() +}) + +it.each(['win32', 'linux'])('rejects macOS-only bundles on %s Hosts', (platform) => { + expect(() => { assertBundlePlatform(['darwin'], platform) }).toThrow(UnsupportedBundlePlatformError) + expect(() => { assertBundlePlatform(['darwin'], platform) }).toThrow(`the DSH Host is running ${platform}`) +}) + +it.each([null, true, 'darwin', [], [1], [''], ['Darwin'], [' darwin'], ['darwin', false]].map(platforms => ({ platforms })))('rejects malformed platform metadata $platforms', ({ platforms }) => { + expect(() => { assertBundlePlatform(platforms, 'darwin') }).toThrow('dsh.bundle.platforms must be a nonempty list') +}) diff --git a/packages/boot/app-boot/tests/profile-plugins.spec.ts b/packages/boot/app-boot/tests/profile-plugins.spec.ts index 04950b4812..223754fc71 100644 --- a/packages/boot/app-boot/tests/profile-plugins.spec.ts +++ b/packages/boot/app-boot/tests/profile-plugins.spec.ts @@ -31,6 +31,18 @@ function installed(location: ProfilePluginLocation, name: string, bundle = true) }) } +it('refuses automatic activation on an unsupported Host without changing the bundle selection', () => { + const location = fixture() + const before = readProfilePlugins(location) + writeManifest(location.profileDir, { dependencies: { restricted: '1.0.0' }, dsh: { profile: { bundles: [] } } }) + writeManifest(join(location.profileDir, 'node_modules/restricted'), { name: 'restricted', dsh: { bundle: { + patch: 'unused.yml', platforms: [process.platform === 'darwin' ? 'win32' : 'darwin'], + } } }) + const saved = readFileSync(join(location.profileDir, 'package.json'), 'utf8') + expect(() => reconcileProfilePlugins({ ...location, before, preserveDisabled: true })).toThrow('Host is running') + expect(readFileSync(join(location.profileDir, 'package.json'), 'utf8')).toBe(saved) +}) + describe('profile plugin inventory', () => { it('uses dependency alias keys, installed versions, and the loader installation precedence', () => { const location = fixture() diff --git a/packages/boot/app-boot/tests/profile.spec.ts b/packages/boot/app-boot/tests/profile.spec.ts index fbd47c20bf..0187836abc 100644 --- a/packages/boot/app-boot/tests/profile.spec.ts +++ b/packages/boot/app-boot/tests/profile.spec.ts @@ -47,7 +47,7 @@ const tmp = (): string => { /** Stage a fake installed app: package.json with deps and a node_modules holding bundles. */ function stageInstallation( - bundles: Record }>, + bundles: Record; platforms?: string[] }>, appName = 'dsh-app', ): string { const root = tmp() @@ -64,7 +64,7 @@ function stageInstallation( type: 'module', main: './index.js', dependencies: spec.deps ?? {}, - ...spec.patch === undefined ? {} : { dsh: { bundle: { patch: './cordis.patch.yml' } } }, + ...spec.patch === undefined ? {} : { dsh: { bundle: { patch: './cordis.patch.yml', ...spec.platforms === undefined ? {} : { platforms: spec.platforms } } } }, })) writeFileSync(join(dir, 'index.js'), `export const packageName = ${JSON.stringify(name)}\n`) if (spec.patch !== undefined) writeFileSync(join(dir, 'cordis.patch.yml'), spec.patch) @@ -76,6 +76,24 @@ function stageInstallation( return join(appDir, 'package.json') } +it('skips an unsupported saved bundle before composing any runtime overrides and retains the selection', () => { + const unsupported = process.platform === 'darwin' ? 'win32' : 'darwin' + const anchor = stageInstallation({ + base: { patch: '- insert:\n - id: ptc-runtime\n name: runtime\n config: { executionMode: isolated }\n' }, + restricted: { platforms: [unsupported], patch: '- id: ptc-runtime\n config: { executionMode: persistent-in-memory }\n' }, + }) + const dir = join(tmp(), 'profile') + initProfile(dir, ['base', 'restricted']) + const before = readFileSync(join(dir, 'package.json'), 'utf8') + const profile = loadProfileDirectory('test', dir, anchor) + expect(profile.layers.map(layer => layer.packageName)).toEqual(['base']) + expect(profile.skippedBundles).toHaveLength(1) + expect(profile.skippedBundles[0]?.packageName).toBe('restricted') + expect(profile.skippedBundles[0]?.reason).toContain(`Host is running ${process.platform}`) + expect(composeEntries(profile.layers.map(layer => layer.patches))).toMatchObject([{ id: 'ptc-runtime', config: { executionMode: 'isolated' } }]) + expect(readFileSync(join(dir, 'package.json'), 'utf8')).toBe(before) +}) + /** Represent one resolved external bundle as a loaded profile layer. */ function stageProfile(home: string, name: string, bundleAnchor: string): Profile { const dir = resolveProfileDir(name, home) diff --git a/packages/boot/plugin-manager/README.i18n.yaml b/packages/boot/plugin-manager/README.i18n.yaml index e16fd551f3..894882125e 100644 --- a/packages/boot/plugin-manager/README.i18n.yaml +++ b/packages/boot/plugin-manager/README.i18n.yaml @@ -15,8 +15,8 @@ en: 87679c51aa3693f5 zh: 11684a48a5806afb /deepseek-ai-dsh-plugin-manager/use-this-package: - en: 4a97c164c4eaf933 - zh: 8be4ac9f8b9e4d9c + en: 4319dce9376ca6d9 + zh: fe130b81e4f2dda2 /deepseek-ai-dsh-plugin-manager/use-this-package/version-compatibility-and-exemptions: en: 483285658e267dd5 zh: 846bec2daac59a96 diff --git a/packages/boot/plugin-manager/README.md b/packages/boot/plugin-manager/README.md index 0f1c691e9f..0d438eb845 100644 --- a/packages/boot/plugin-manager/README.md +++ b/packages/boot/plugin-manager/README.md @@ -39,6 +39,8 @@ For a deployment without agent presets, enable the tool in the profile patch. Pr A plugin toggle updates only `disabled` in the last matching override in the profile's `cordis.patch.yml`, or appends an override when none matches. Matching uses the entry id and any module-name assertion. An override holding only `id` and `disabled` is removed, and none is appended, when the bundle layers and the remaining profile patches already give the entry the requested state, so the profile patch records only departures from the bundles. Home and invocation patches are left out of that comparison; they apply after the profile patch and do not decide what it records. A bundle toggle changes `package.json`'s ordered `dsh.profile.bundles` list. Disabling retains the dependency; enabling appends the bundle at the end, which can change configuration precedence. Installation enables a new bundle by default. Home and invocation patches retain their higher priority. +Bundle platform declarations are checked before saving an enabled selection. Unsupported Hosts return `unsupported-platform`. The bundle remains visible with its display metadata and can still be deselected. Automatic activation after a package operation uses the same check. The agent-facing next step asks the user to run the bundle on a supported Host. + A selected bundle that cannot load remains in `listBundles` with an `error`; `enabled` records the saved selection, not successful loading. The plugin page shows the error and allows deselection. A broken bundle cannot be enabled. Management bundles remain protected if their files become unreadable. `listBundles` includes optional display `meta` for each bundle and its declared plugin rows, including disabled bundles. The Client selects a language from these values. The separate `description` field is the bundle's raw `package.json.description`; a metadata diagnostic does not block management. `source` gives a profile dependency as a spec `pnpm add` accepts: a git address or URL as recorded without the user information of an http(s) URL (a query string stays as recorded), a `file:` or `link:` path made absolute against the profile or the home directory for `~`, and a registry range, tag, or alias after the package name, as is any spec of a package installed under another name; a bundle the installation supplies has none, even when the profile also depends on it, because the installation's copy is the one that loads. The `plugin_manager` tool omits UI display metadata and update eligibility from list results. diff --git a/packages/boot/plugin-manager/README.zh.md b/packages/boot/plugin-manager/README.zh.md index 2f8a0cc3d0..c802285c57 100644 --- a/packages/boot/plugin-manager/README.zh.md +++ b/packages/boot/plugin-manager/README.zh.md @@ -39,6 +39,8 @@ kind: "package-reference" 插件开关只更新 profile 的 `cordis.patch.yml` 中最后一条匹配覆盖项的 `disabled`;没有匹配项时追加。匹配依据是条目 id,以及覆盖项声明的模块名称。如果组合包层和其余 profile patch 已使条目处于所请求的状态,仅含 `id` 与 `disabled` 的覆盖项会被移除,也不会追加覆盖项,因此 profile patch 只记录与组合包不同的设置。该比较不计入 home 和单次启动 patch;它们在 profile patch 之后应用,不决定 profile patch 记录什么。组合包开关修改 `package.json` 的有序 `dsh.profile.bundles` 列表。关闭保留依赖;开启追加到列表末尾,可能改变配置优先级。安装新组合包默认启用。home 和单次启动 patch 保留更高优先级。 +组合包的平台声明会在保存启用选择前检查。Host 不受支持时返回 `unsupported-platform`。组合包仍保留显示信息,并允许取消选择。包操作后的自动启用执行同一检查。给模型的下一步说明会提示用户在受支持的 Host 上运行该组合包。 + 已选择但无法加载的组合包仍会出现在 `listBundles` 中,并携带 `error`;`enabled` 表示保存的选择,不代表加载成功。插件页面显示错误并允许取消选择。损坏的组合包无法启用。管理组合包的文件变得不可读后仍受保护。 `listBundles` 为各组合包及其声明的插件行提供可选的展示 `meta`,包括已禁用的组合包。Client 从这些值中选择语言。单独的 `description` 字段是该组合包原始的 `package.json.description`;元信息诊断不会阻止管理操作。`source` 以 `pnpm add` 接受的 spec 给出 profile 依赖:git 地址或 URL 按记录给出,但去掉 http(s) URL 的 user information(查询字符串保持原样);`file:` 或 `link:` 路径按 profile 目录解析为绝对路径,`~` 展开为主目录;注册表版本范围、标签或别名接在包名的 `@` 之后,以别名安装的包的 spec 也是如此。安装提供的组合包没有该字段,即使 profile 也依赖它,因为实际加载的是安装中的副本。`plugin_manager` 工具的列表结果不包含 UI 展示元信息和更新资格。 diff --git a/packages/boot/plugin-manager/src/index.ts b/packages/boot/plugin-manager/src/index.ts index 16bc5ee932..fa1912babf 100644 --- a/packages/boot/plugin-manager/src/index.ts +++ b/packages/boot/plugin-manager/src/index.ts @@ -23,6 +23,7 @@ import { evaluatePluginCompatibility, readProfileCompatibility, readProfileVersionExemptions, setProfileVersionExemption, PROFILE_COMPATIBILITY_FILENAME, OFFICIAL_ON_DEMAND_CATALOG, getDshRuntimeVersion, ResolutionRestartRequired, + assertBundlePlatform, UnsupportedBundlePlatformError, } from '@deepseek-ai/dsh-app-boot' import type {} from '@deepseek-ai/dsh-hmr' import type { ProfileContext, ProfileManifest } from '@deepseek-ai/dsh-app-boot' @@ -114,6 +115,7 @@ function messageOf(error: unknown): string { return error instanceof Error ? err /** An expected refusal keeps its code; anything else becomes an operation error carrying its exact diagnostic. */ function managementError(error: unknown): ManagementError { + if (error instanceof UnsupportedBundlePlatformError) return { code: 'unsupported-platform' } if (!(error instanceof ManagementFailure)) return { code: 'operation-error', diagnostic: messageOf(error) } return { code: error.code, ...error.incompatible === undefined ? {} : { incompatible: error.incompatible } } } @@ -523,13 +525,17 @@ export class PluginManager extends TypertRemoteService { if (compatibility !== undefined && !compatibility.exempted) throw new ManagementFailure('incompatible-version', [incompatiblePlugin(compatibility)]) const dir = resolveBundleDir('dsh', name, this.profile.installAnchor, this.profile.dir) const meta = offered?.meta ?? readPluginMeta(info.name ?? name, pathToFileURL(join(dir, 'package.json')).href) + let platformError: ManagementError | undefined + try { assertBundlePlatform(info.dsh?.bundle?.platforms, process.platform) } + catch (error) { platformError = managementError(error) } + const error = targetError ?? platformError bundles.push({ name, official, availability, ...target, ...(version === undefined ? {} : { version }), ...(info.description === undefined || info.description === '' ? {} : { description: info.description }), ...meta === undefined ? {} : { meta }, ...sourceOf(info.name), enabled, installed, optional, removable: removable && readOnlyReason === undefined, ...(readOnlyReason === undefined ? {} : { readOnlyReason }), ...this.declaredRows(name, info), - ...targetError === undefined ? {} : { error: targetError } }) + ...error === undefined ? {} : { error } }) } catch (error) { if (enabled || installed || optional || offered !== undefined) { bundles.push({ name, official, availability, ...catalogMeta, ...target, ...(version === undefined ? {} : { version }), @@ -1115,6 +1121,7 @@ export class PluginManager extends TypertRemoteService { const metadata = bundleManifest(name, this.profile.dir, this.profile.installAnchor) if (metadata === undefined) throw new ManagementFailure('not-bundle') if (enabled) { + assertBundlePlatform(metadata.dsh?.bundle?.platforms, process.platform) const compatibility = evaluatePluginCompatibility(metadata, readProfileVersionExemptions(this.profile.dir)) if (compatibility !== undefined && !compatibility.exempted) throw new ManagementFailure('incompatible-version', [incompatiblePlugin(compatibility)]) this.bundleRows(name) diff --git a/packages/boot/plugin-manager/src/operations.ts b/packages/boot/plugin-manager/src/operations.ts index d3452139fe..7ab7c491ad 100644 --- a/packages/boot/plugin-manager/src/operations.ts +++ b/packages/boot/plugin-manager/src/operations.ts @@ -7,7 +7,7 @@ import { execa } from 'execa' import type { EntryOptions } from '@deepseek-ai/cordis-plugin-loader' import { withFileLock, writeFileAtomic } from '@deepseek-ai/dsh-atomic-write' import { - DEFAULT_PROFILE_BUNDLES, bundlePatchPaths, initProfile, PROFILE_TEMPLATES, readProfileManifest, + DEFAULT_PROFILE_BUNDLES, assertBundlePlatform, bundlePatchPaths, initProfile, PROFILE_TEMPLATES, readProfileManifest, resolveBundleDir, resolveProfileDir, loadOverlayPatches, composeEntries, readProfileVersionExemptions, evaluatePluginCompatibility, pluginCompatibilityWarning, type ProfileManifest, } from '@deepseek-ai/dsh-app-boot' @@ -102,6 +102,7 @@ async function reconcile(before: ProfileManifest, dir: string, anchor: string, o options.onOutput?.(`dsh: warning: ${name} declares no dsh.bundle — installed as a plain dependency, not a profile layer\n`, 'stderr') continue } + assertBundlePlatform(metadata.dsh.bundle.platforms, process.platform) for (const file of bundlePatchPaths(resolveBundleDir('dsh', name, anchor, dir), metadata.dsh.bundle)) loadOverlayPatches('dsh', file) if (!bundles.includes(name)) { bundles.push(name) diff --git a/packages/boot/plugin-manager/src/tools.ts b/packages/boot/plugin-manager/src/tools.ts index 2addbc05ba..e0d91126f2 100644 --- a/packages/boot/plugin-manager/src/tools.ts +++ b/packages/boot/plugin-manager/src/tools.ts @@ -23,6 +23,7 @@ const ERROR_STEPS: Record = { 'bundle-in-use': 'Call list_plugins, disable the entries from other layers that still use this bundle, then retry.', 'stale-approval': 'Call install_bundle again without approvedBuilds to read the current pendingBuilds.', 'incompatible-version': 'Install a version compatible with the running DSH. A version exemption needs the user\'s explicit acceptance of crash and data-loss risk.', + 'unsupported-platform': 'This bundle cannot run on the current Host platform; ask the user to use a supported Host.', 'operation-error': 'Report the diagnostic to the user; retry only after its cause is addressed.', } diff --git a/packages/boot/plugin-manager/src/types.ts b/packages/boot/plugin-manager/src/types.ts index e4909d5555..6f3c96176c 100644 --- a/packages/boot/plugin-manager/src/types.ts +++ b/packages/boot/plugin-manager/src/types.ts @@ -36,7 +36,7 @@ export interface IncompatiblePlugin { /** Localizable management failure and optional external diagnostic. */ export interface ManagementError { - code: ReadOnlyReason | 'unknown-plugin' | 'invalid-spec' | 'already-installed' | 'ambiguous-install' | 'not-bundle' | 'not-removable' | 'stop-profile' | 'bundle-in-use' | 'stale-approval' | 'incompatible-version' | 'operation-error' + code: ReadOnlyReason | 'unknown-plugin' | 'invalid-spec' | 'already-installed' | 'ambiguous-install' | 'not-bundle' | 'not-removable' | 'stop-profile' | 'bundle-in-use' | 'stale-approval' | 'incompatible-version' | 'unsupported-platform' | 'operation-error' diagnostic?: string /** Present with `incompatible-version`: the packages the running DSH version rejects. */ incompatible?: IncompatiblePlugin[] diff --git a/packages/boot/plugin-manager/tests/manager.spec.ts b/packages/boot/plugin-manager/tests/manager.spec.ts index b6cd4c21ad..b363e69ae1 100644 --- a/packages/boot/plugin-manager/tests/manager.spec.ts +++ b/packages/boot/plugin-manager/tests/manager.spec.ts @@ -89,6 +89,40 @@ async function fixture(reload: 'live' | 'startup' = 'live', overlay = false, pre return { ctx, dir, manager: ctx.pluginManager, bundle, profile, stopHmr, overlays, connection } } +it.each(['live', 'startup'] as const)('refuses an unsupported bundle before saving or applying it with %s reload', async (reload) => { + const { manager, dir, ctx } = await fixture(reload, false, undefined, {}, undefined, (dir) => { + const path = join(dir, 'node_modules/extra/package.json') + writeFileSync(path, JSON.stringify({ name: 'extra', version: '1.0.0', description: 'Platform-limited bundle', + dsh: { bundle: { patch: './cordis.patch.yml', platforms: [process.platform === 'darwin' ? 'win32' : 'darwin'] } } })) + const manifest = readProfileManifest('test', dir) + manifest.dsh = { profile: { bundles: ['core'] } } + writeFileSync(join(dir, 'package.json'), JSON.stringify(manifest)) + }) + const before = readFileSync(join(dir, 'package.json'), 'utf8') + const patchBefore = readFileSync(join(dir, 'cordis.patch.yml'), 'utf8') + expect((await manager.listBundles()).find(row => row.name === 'extra')).toMatchObject({ + enabled: false, description: 'Platform-limited bundle', error: { code: 'unsupported-platform' }, + }) + expect(await manager.setBundleEnabled('extra', true)).toMatchObject({ changed: false, application: 'failed', error: { code: 'unsupported-platform' } }) + expect(readFileSync(join(dir, 'package.json'), 'utf8')).toBe(before) + expect(ctx.get('managedProbe')).toBeUndefined() + expect(readFileSync(join(dir, 'cordis.patch.yml'), 'utf8')).toBe(patchBefore) + expect(await manager.setBundleEnabled('extra', false)).toMatchObject({ changed: false }) +}) + +it('allows supported bundle activation and permits deselecting an unsupported saved bundle', async () => { + const { manager, dir } = await fixture() + const path = join(dir, 'node_modules/extra/package.json') + const metadata = readProfileManifest('test', join(dir, 'node_modules/extra')) + metadata.dsh = { bundle: { patch: './cordis.patch.yml', platforms: [process.platform] } } + writeFileSync(path, JSON.stringify(metadata)) + expect(await manager.setBundleEnabled('extra', false)).toMatchObject({ changed: true, application: 'applied' }) + expect(await manager.setBundleEnabled('extra', true)).toMatchObject({ changed: true, application: 'applied' }) + metadata.dsh.bundle!.platforms = [process.platform === 'darwin' ? 'win32' : 'darwin'] + writeFileSync(path, JSON.stringify(metadata)) + expect(await manager.setBundleEnabled('extra', false)).toMatchObject({ changed: true, application: 'applied' }) +}) + it.each(['network', 'timeout'] as const)('stops a GitHub %s before pnpm and attributes it to the repository', async (kind) => { const { manager, dir, connection } = await fixture() const before = readFileSync(join(dir, 'package.json'), 'utf8') @@ -1515,7 +1549,6 @@ it.each([false, true])('rechecks installed bundle peers before accepting a disab expect(readProfileManifest('test', dir).dsh?.profile?.bundles).toEqual(['core', 'extra']) }) - it('lists absent Official entries offline without resolving their packages or consulting registries', async () => { const { manager } = await fixture() const resolve = vi.spyOn(operations, 'bundleManifest') diff --git a/packages/boot/plugin-manager/tests/operations.spec.ts b/packages/boot/plugin-manager/tests/operations.spec.ts index 87b6977df3..18fd74fdfd 100644 --- a/packages/boot/plugin-manager/tests/operations.spec.ts +++ b/packages/boot/plugin-manager/tests/operations.spec.ts @@ -172,6 +172,17 @@ function install(dir: string, name: string) { writeFileSync(join(dir, 'package.json'), JSON.stringify(manifest)) } +it('keeps a newly installed unsupported bundle out of the saved selection', async () => { + const { dir, context, pnpm } = fixture() + pnpm.mutate = (target) => { + install(target, 'restricted') + writeFileSync(join(target, 'node_modules/restricted/package.json'), JSON.stringify({ name: 'restricted', version: '1', + dsh: { bundle: { patch: './cordis.patch.yml', platforms: [process.platform === 'darwin' ? 'win32' : 'darwin'] } } })) + } + await expect(runProfilePnpm(context, ['add', 'restricted'], { execution: 'service', outputBytes: 8192 })).rejects.toThrow('Host is running') + expect(readProfileManifest('test', dir).dsh?.profile?.bundles).toEqual([]) +}) + function installGuarded(dir: string, dependency: string, name = dependency, version = '1.0.0', peer = '>=999.0.0') { install(dir, dependency) writeFileSync(join(dir, 'node_modules', dependency, 'package.json'), JSON.stringify({ diff --git a/packages/boot/plugin-manager/tests/tools.spec.ts b/packages/boot/plugin-manager/tests/tools.spec.ts index 07c0000a20..ddaa8edc26 100644 --- a/packages/boot/plugin-manager/tests/tools.spec.ts +++ b/packages/boot/plugin-manager/tests/tools.spec.ts @@ -303,4 +303,6 @@ it('tells the agent the next step for each change outcome it can act on', async expect(await outcome({ changed: false, application: 'failed', packageResult: { kind: 'unknown' }, error: { code: 'operation-error' } })) .toContain('Report the diagnostic') expect(await outcome({ changed: false, application: 'failed' })).toContain('Report the diagnostic') + expect(await outcome({ changed: false, application: 'failed', error: { code: 'unsupported-platform' } })) + .toBe('This bundle cannot run on the current Host platform; ask the user to use a supported Host.') }) diff --git a/packages/client/ui-plugin-manager/README.i18n.yaml b/packages/client/ui-plugin-manager/README.i18n.yaml index 2ad7cfa9a1..c70eadb208 100644 --- a/packages/client/ui-plugin-manager/README.i18n.yaml +++ b/packages/client/ui-plugin-manager/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-plugin-manager/use-this-package: - en: ddd9e45e21755108 - zh: 8af470315eecf8a4 + en: 23fbb489c4cb9568 + zh: 514273265546e144 /deepseek-ai-dsh-client-ui-plugin-manager/use-this-package/installing-a-bundle: en: fcb2e69c8b028c0a zh: d505a075679974eb diff --git a/packages/client/ui-plugin-manager/README.md b/packages/client/ui-plugin-manager/README.md index a28c62364a..eea7cb1143 100644 --- a/packages/client/ui-plugin-manager/README.md +++ b/packages/client/ui-plugin-manager/README.md @@ -39,6 +39,8 @@ On-demand Official cards are visible offline before installation. Turning one On The first list read shows a short group-heading placeholder and four skeleton cards, using the real cards' row, icon, and text-line spacing, with the action area left blank. They use the same opacity pulse as Session search and remain static with reduced motion. The accessible loading label and read timing are unchanged; refreshes retain the existing list, and installation and component-loading indicators keep their own states. +A bundle unavailable on the DSH Host operating system shows the reason on its card and details page. Its disabled switch prevents enabling it; an already selected bundle can still be switched off. [Plugin Manager](../../boot/plugin-manager/README.md#use-this-package) enforces the same restriction for direct requests. + The **Refresh** button shows its tooltip after 500 ms of hovering or keyboard focus. It reads the list again, then checks every updatable bundle for newer versions one after another; a failed read checks nothing. During a manual refresh, the button shows a spinner and stays disabled until all pending reads and those checks settle and at least 400 ms have elapsed, preventing a brief spinner flash; repeated refresh requests are ignored and the existing list remains visible. Success shows no toast. With a loaded list, a failed manual refresh keeps the cached content and shows a failure toast, including after leaving Plugins; select the button again to retry. Before any successful list read, failures show an in-place message with **Retry**. Background reads do not show the refresh spinner. ### Installing a bundle diff --git a/packages/client/ui-plugin-manager/README.zh.md b/packages/client/ui-plugin-manager/README.zh.md index 522cfe4dfc..541acb82d4 100644 --- a/packages/client/ui-plugin-manager/README.zh.md +++ b/packages/client/ui-plugin-manager/README.zh.md @@ -39,6 +39,8 @@ kind: "package-reference" 首次读取列表时,页面显示一条较短的分组标题占位和四行骨架卡片,沿用真实卡片的行、图标和文字间距,操作区域留白。骨架使用与 Session 搜索相同的透明度呼吸动效,在减少动态效果模式下保持静止。无障碍加载文案和读取时机不变;刷新时保留已有列表,安装及组件加载仍使用各自的状态提示。 +组合包不支持 DSH Host 的操作系统时,卡片和详情页会显示原因,关闭状态的开关不可启用;已选中的组合包仍可关闭。[插件管理器](../../boot/plugin-manager/README.zh.md#use-this-package)对直接请求执行同一限制。 + **刷新**按钮在悬停或键盘聚焦 500 毫秒后显示提示。它重新读取列表,再依次检查每个可更新组合包的新版本;读取失败时不做检查。手动刷新期间,按钮显示旋转加载指示并保持禁用,直到所有待处理读取和这些检查结束且至少经过 400 毫秒,避免加载指示一闪而过;重复刷新请求会被忽略,已有列表保持可见。成功不显示 toast。已有列表时,手动刷新失败保留缓存内容并显示失败 toast,即使已离开插件页也能看到;再次选择该按钮即可重试。在首次成功读取列表之前,失败仍原位显示提示与**重试**。后台读取不显示刷新按钮的加载指示。 ### 安装一个组合包 diff --git a/packages/client/ui-plugin-manager/src/client/locales.ts b/packages/client/ui-plugin-manager/src/client/locales.ts index 3f8a6b1dbd..dcde50582d 100644 --- a/packages/client/ui-plugin-manager/src/client/locales.ts +++ b/packages/client/ui-plugin-manager/src/client/locales.ts @@ -282,6 +282,7 @@ export const zh = { reasonStaleApproval: '待允许的安装脚本列表已变化,请重新安装以刷新', reasonIncompatibleVersion: '{plugin} 与 DSH {runtime} 不兼容(要求 {requirements}),运行它可能导致崩溃或数据丢失。', reasonIncompatibleVersionUnnamed: '这个插件与当前 DSH 版本不兼容,运行它可能导致崩溃或数据丢失。', + reasonUnsupportedPlatform: '此插件不支持运行 DSH 的主机操作系统', reasonIncompatibleInstall: '请安装与当前 DSH 兼容的插件版本。', reasonIncompatibleInstalled: '请卸载后重新安装与当前 DSH 兼容的版本。', reasonOperationError: 'Host 报告了一个错误', @@ -574,6 +575,7 @@ export const en = { reasonStaleApproval: 'The pending script approvals changed; install again to refresh them.', reasonIncompatibleVersion: '{plugin} is incompatible with DSH {runtime} (requires {requirements}); running it may cause crashes or data loss.', reasonIncompatibleVersionUnnamed: 'This plugin is incompatible with the running DSH version; running it may cause crashes or data loss.', + reasonUnsupportedPlatform: 'This plugin does not support the operating system running DSH.', reasonIncompatibleInstall: 'Install a plugin version compatible with this DSH.', reasonIncompatibleInstalled: 'Uninstall it and install a version compatible with this DSH.', reasonOperationError: 'The Host reported an error.', diff --git a/packages/client/ui-plugin-manager/src/client/presentation.ts b/packages/client/ui-plugin-manager/src/client/presentation.ts index b636c67e04..098e6cc6ec 100644 --- a/packages/client/ui-plugin-manager/src/client/presentation.ts +++ b/packages/client/ui-plugin-manager/src/client/presentation.ts @@ -58,6 +58,7 @@ const CODE_KEYS = { 'bundle-in-use': 'reasonBundleInUse', 'stale-approval': 'reasonStaleApproval', 'incompatible-version': 'reasonIncompatibleVersionUnnamed', + 'unsupported-platform': 'reasonUnsupportedPlatform', 'operation-error': 'reasonOperationError', } satisfies Record diff --git a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx index 287e99d887..d2fae04a44 100644 --- a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx +++ b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx @@ -1402,6 +1402,11 @@ describe('PluginManagerPage', () => { expect(within(detail).getByText(`${en.reasonLabel}: ${en.reasonIncompatibleVersionUnnamed} ${en.reasonIncompatibleInstalled}`)).toBeTruthy() fireEvent.click(within(detail).getByRole('button', { name: en.backToList })) expect(document.querySelector('[data-plugin-detail]')).toBeNull() + set({ packages: [pkg({ enabled: false, error: { code: 'unsupported-platform' } })] }) + expect(screen.getByText(en.reasonUnsupportedPlatform)).toBeTruthy() + expect(screen.getByRole('switch', { name: en.enableToggle.replace('{name}', 'dsh-better-sidebar') })).toHaveProperty('disabled', true) + set({ packages: [pkg({ enabled: true, error: { code: 'unsupported-platform' } })] }) + expect(screen.getByRole('switch', { name: en.enableToggle.replace('{name}', 'dsh-better-sidebar') })).toHaveProperty('disabled', false) // A bundle that leaves the list drops back to the cards. const { version: _version, ...unversioned } = pkg() set({ packages: [unversioned] }) diff --git a/packages/experimental/cua-bundle/README.i18n.yaml b/packages/experimental/cua-bundle/README.i18n.yaml index ff42d19472..d03f89bb5b 100644 --- a/packages/experimental/cua-bundle/README.i18n.yaml +++ b/packages/experimental/cua-bundle/README.i18n.yaml @@ -15,8 +15,8 @@ en: b563e4ec4727d0de zh: d0228da978238e05 /deepseek-ai-dsh-cua-bundle/use-this-package: - en: e19d1fd30ca77a8b - zh: b192eacfac12a5fe + en: beffb06c41af9dd4 + zh: 984332bbc27c681d /deepseek-ai-dsh-cua-bundle/understand-the-implementation: en: 057771fe13aaa337 zh: 4fdb2b98ff3e7a78 diff --git a/packages/experimental/cua-bundle/README.md b/packages/experimental/cua-bundle/README.md index d534cb07a6..795c396b22 100644 --- a/packages/experimental/cua-bundle/README.md +++ b/packages/experimental/cua-bundle/README.md @@ -37,7 +37,7 @@ The switch saves bundle selection in the profile’s `package.json`. Computer Us Disabling unloads the provider and withdraws CUA tools from its Agent scopes. Runtime configuration, the new-session default and saved grants remain. Session-only application decisions end with provider disposal. -Computer Use requires a macOS DSH Host. On other operating systems, installation omits the optional macOS provider and the bundle skips its Loader entry. Shared CUA logic and the permission-page entry remain available, but Computer Use operations require the provider. A browser on another operating system can connect to a supported Mac Host. +Computer Use is available only on a macOS DSH Host. The native provider is an optional dependency installed only on macOS; shared CUA and Client packages remain in the installation. Other Hosts refuse enablement before saving settings. An already selected bundle is skipped at startup with a diagnostic and remains available for deselection; saved user settings remain. A browser on another operating system can connect to a supported Mac Host. If preparation fails, the saved selection remains and CUA operations stay unavailable. Read the Host startup diagnostic, correct its cause, then restart DSH. diff --git a/packages/experimental/cua-bundle/README.zh.md b/packages/experimental/cua-bundle/README.zh.md index e47bd3ad43..2c38d4256b 100644 --- a/packages/experimental/cua-bundle/README.zh.md +++ b/packages/experimental/cua-bundle/README.zh.md @@ -37,7 +37,7 @@ pnpm dsh web 关闭会卸载提供方,并从其 Agent 作用域中撤回 CUA 工具。执行器配置、新会话默认值和已保存的授权保留。会话级应用授权随提供方卸载而失效。 -Computer Use 要求 DSH Host 运行在 macOS 上。其他系统安装时跳过可选的 macOS 提供方,组合包也不加载该提供方。共享 CUA 逻辑和权限页入口仍保留,Computer Use 操作需要提供方才能使用。其他操作系统上的浏览器可以连接受支持的 Mac Host。 +Computer Use 仅支持 macOS DSH Host。原生提供方是仅在 macOS 安装的可选依赖,共享 CUA 和 Client 包仍随安装提供。其他 Host 会在保存设置前拒绝启用。已选中的组合包会在启动时跳过并报告原因,仍可取消选择;已保存的用户设置保留。其他操作系统上的浏览器可以连接受支持的 Mac Host。 准备失败时,已保存的选择保留,CUA 操作不可用。查看 Host 的启动诊断,修复原因后重启 DSH。 diff --git a/packages/experimental/cua-bundle/package.json b/packages/experimental/cua-bundle/package.json index d4e4438b46..794c666300 100644 --- a/packages/experimental/cua-bundle/package.json +++ b/packages/experimental/cua-bundle/package.json @@ -34,7 +34,10 @@ "license": "MIT", "dsh": { "bundle": { - "patch": "./cordis.patch.yml" + "patch": "./cordis.patch.yml", + "platforms": [ + "darwin" + ] } }, "dependencies": { diff --git a/packages/extensions/tool-cordis/src/api-catalog.ts b/packages/extensions/tool-cordis/src/api-catalog.ts index dc434e6935..fdb860409e 100644 --- a/packages/extensions/tool-cordis/src/api-catalog.ts +++ b/packages/extensions/tool-cordis/src/api-catalog.ts @@ -6254,7 +6254,7 @@ export const TYPE_API: readonly TypeApiEntry[] = [ }, { name: 'ManagementError', - declaration: 'export interface ManagementError {\n code: ReadOnlyReason | \'unknown-plugin\' | \'invalid-spec\' | \'already-installed\' | \'ambiguous-install\' | \'not-bundle\' | \'not-removable\' | \'stop-profile\' | \'bundle-in-use\' | \'stale-approval\' | \'incompatible-version\' | \'operation-error\';\n diagnostic?: string;\n incompatible?: IncompatiblePlugin[];\n}', + declaration: 'export interface ManagementError {\n code: ReadOnlyReason | \'unknown-plugin\' | \'invalid-spec\' | \'already-installed\' | \'ambiguous-install\' | \'not-bundle\' | \'not-removable\' | \'stop-profile\' | \'bundle-in-use\' | \'stale-approval\' | \'incompatible-version\' | \'unsupported-platform\' | \'operation-error\';\n diagnostic?: string;\n incompatible?: IncompatiblePlugin[];\n}', }, { name: 'ManualCompactAgentContext', diff --git a/packages/util/package-manifest/README.i18n.yaml b/packages/util/package-manifest/README.i18n.yaml index bb73ae8f0f..4edf1572bf 100644 --- a/packages/util/package-manifest/README.i18n.yaml +++ b/packages/util/package-manifest/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 1db86285abf6c499 /deepseek-ai-dsh-package-manifest/use-this-package: - en: 0f5e861b0c0c5ee2 - zh: 766eaa36b794a22b + en: 2b4a2b115906bad1 + zh: df5642f9ed0741ff /deepseek-ai-dsh-package-manifest/understand-the-implementation: en: 41ec449dee927f04 zh: ec1b583bd9025d84 diff --git a/packages/util/package-manifest/README.md b/packages/util/package-manifest/README.md index a1d5e7f423..a6d23c311a 100644 --- a/packages/util/package-manifest/README.md +++ b/packages/util/package-manifest/README.md @@ -50,6 +50,7 @@ The following metadata fields are optional. Omitting them leaves the format vers | Field | Meaning | |---|---| | `dsh.manifestVersion` | Manifest format identifier; the declared format is `1`, independent of the npm package version and Session format version. | +| `dsh.bundle.platforms` | Optional nonempty list of Node Host platform names, such as `["darwin"]`; omission allows every operating system. The launcher and plugin manager enforce it before composing or selecting the bundle. | | `engines.dsh` | Author-declared compatible DSH versions as a SemVer range, including exact prerelease versions. This field sits beside `engines.node` and `engines.npm`; an engines object may omit `dsh`. | `LocalizedText` carries literal text or a language map with a required English fallback. `PluginLocalizedMeta` carries optional display title, description, an image data URL resolved from a package root's `package.json.icon` or an exported `/icon`, and metadata diagnostics for installed plugins. [App boot](../../boot/app-boot/README.md) reads these values; this package only supplies their types. diff --git a/packages/util/package-manifest/README.zh.md b/packages/util/package-manifest/README.zh.md index d676ff9bf7..9d7392e0ec 100644 --- a/packages/util/package-manifest/README.zh.md +++ b/packages/util/package-manifest/README.zh.md @@ -50,6 +50,7 @@ const manifest: DshPackageManifest = { | 字段 | 含义 | |---|---| | `dsh.manifestVersion` | manifest(元数据清单)格式标识;声明的格式为 `1`,独立于 npm 包版本和 Session 格式版本。 | +| `dsh.bundle.platforms` | 可选的非空 Node Host 平台名称列表,例如 `["darwin"]`;省略时允许所有操作系统。启动器和插件管理器在组合或选择该组合包前检查此字段。 | | `engines.dsh` | 作者声明的兼容 DSH 版本,使用 SemVer 范围,也可填写精确的预发布版本。此字段与 `engines.node`、`engines.npm` 并列;engines 对象可省略 `dsh`。 | `LocalizedText` 携带字面文本或带必需英文回退值的语言映射。`PluginLocalizedMeta` 携带已安装插件的可选展示标题、描述、从包根 `package.json.icon` 或导出的 `<标识>/icon` 解析的图片 data URL,以及元信息诊断。[App boot](../../boot/app-boot/README.zh.md) 读取这些值;本包只提供其类型。 diff --git a/packages/util/package-manifest/src/types.ts b/packages/util/package-manifest/src/types.ts index 27de17acfe..3a9915ab5d 100644 --- a/packages/util/package-manifest/src/types.ts +++ b/packages/util/package-manifest/src/types.ts @@ -69,6 +69,8 @@ export interface DshEnginesManifest { /** The configuration layer exported by a bundle package. */ export interface DshBundleManifest { + /** Supported Node Host platform names; omission allows every operating system. */ + platforms?: string[] /** One patch file path, or an ordered list applied in sequence, each relative to the declaring package root. */ patch: string | string[] } diff --git a/scripts/optional-bundles.spec.ts b/scripts/optional-bundles.spec.ts index 674919b570..40de24d3d8 100644 --- a/scripts/optional-bundles.spec.ts +++ b/scripts/optional-bundles.spec.ts @@ -91,6 +91,9 @@ describe.each(['web', 'desktop'] as const)('%s optional bundle overrides', (surf }) describe('optional bundles', () => { + it('admits Computer Use only on macOS Hosts', () => { + expect(bundles.get('@deepseek-ai/dsh-cua-bundle')?.manifest.dsh?.bundle?.platforms).toEqual(['darwin']) + }) const shipped = ['@deepseek-ai/dsh-base', '@deepseek-ai/dsh-web-app'].map(name => bundle(name).patches) it('ships at least one bundle switched off', () => { diff --git a/tsconfig.host.json b/tsconfig.host.json index 226923ef76..21e1964281 100644 --- a/tsconfig.host.json +++ b/tsconfig.host.json @@ -76,6 +76,7 @@ "apps/web/tests/input-plugin-extensions.e2e.ts", "apps/web/tests/plugin-manager.e2e.ts", "apps/web/tests/cua-optin.e2e.ts", + "apps/web/tests/bundle-platform.e2e.ts", "apps/web/tests/cua-permissions.e2e.ts", "apps/web/tests/schedule-header.e2e.ts", "apps/web/tests/worktree-opt-in.e2e.ts", From 8a1e9afae3f140138c2492a66598e6846ab2ecd6 Mon Sep 17 00:00:00 2001 From: creatixchu Date: Tue, 20 Oct 2026 15:29:31 +0800 Subject: [PATCH 2/2] test(cua): limit native opt-in flow to supported Hosts --- apps/web/tests/cua-optin.e2e.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/tests/cua-optin.e2e.ts b/apps/web/tests/cua-optin.e2e.ts index 287a073493..a550d88052 100644 --- a/apps/web/tests/cua-optin.e2e.ts +++ b/apps/web/tests/cua-optin.e2e.ts @@ -12,7 +12,8 @@ import { expect, it, vi } from 'vitest' import { captureStableAria, compareOrRefreshGolden, launchWebScaffold, webSnapshotMode, type WebScaffold } from './scaffold.ts' import { connectFreshWorkspaceZh, ZH_BROWSER_LOCALE } from './support.ts' -it.each([undefined, 'minimal'] as const)('adds CUA to PTC sessions while preserving default %s until the explicit persistent-runtime action', async (selectedDefault) => { +// The shipped bundle admits only macOS Hosts; unsupported Hosts are exercised in bundle-platform.e2e.ts. +it.skipIf(process.platform !== 'darwin').each([undefined, 'minimal'] as const)('adds CUA to PTC sessions while preserving default %s until the explicit persistent-runtime action', async (selectedDefault) => { const directory = await mkdtemp(join(tmpdir(), 'cua-optin-web-')) let ownedScaffold: WebScaffold | undefined let browser: Browser | undefined