diff --git a/apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts b/apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts index 8108b6d671..8f7556ce2b 100644 --- a/apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts +++ b/apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts @@ -1,7 +1,8 @@ /** - * Static comparison of the agent-plane plugin rows of the shipped SDK profile and the Desktop standard agent preset, read from + * Static comparison of the plugin rows of the shipped SDK profile with the Desktop standard composition, read from * `dsh --dump-config` without booting. It covers rows whose model effect a default turn does not show, such as the - * plan mode section. Only rows the preset declares are compared; the remaining rows are the Desktop host plane. + * plan mode section. An SDK row compares with the standard agent preset row of the same id, or else with the Desktop + * host row of that id; an enabled SDK row with neither is SDK-only. Desktop host rows the SDK lacks are not compared. * Record differences in parity-exceptions.ts. */ import { mkdtemp, rm, writeFile } from 'node:fs/promises' @@ -20,11 +21,20 @@ const GROUP = 'cordis:group' interface Row { id?: string; name?: string; disabled?: unknown; config?: unknown } +/** Replace each unevaluated `!!js` node with `!!js `, so a differing expression reports at its own field. */ +function literal(value: unknown): unknown { + if (Array.isArray(value)) return value.map(literal) + if (value === null || typeof value !== 'object') return value + const entries = Object.entries(value) + if (entries.length === 1 && entries[0]![0] === '__jsExpr') return `!!js ${String(entries[0]![1])}` + return Object.fromEntries(entries.map(([key, item]) => [key, literal(item)])) +} + /** Leaf rows by id; group rows contribute their members, and an absent `disabled` reads as `false`. */ function leaves(rows: readonly Row[], into = new Map()): Map { for (const row of rows) { if (row.name === GROUP && Array.isArray(row.config)) leaves(row.config as Row[], into) - else if (row.id !== undefined) into.set(row.id, { name: row.name, disabled: row.disabled ?? false, config: row.config }) + else if (row.id !== undefined) into.set(row.id, literal({ name: row.name, disabled: row.disabled ?? false, config: row.config })) } return into } @@ -36,14 +46,37 @@ function presetRows(rows: readonly Row[]): Map { } /** - * The SDK rows with the ids a preset declares. A preset `persona` row and the SDK `system-prompt.personaPrefix` - * render the same persona section, so the SDK prefix compares as that row. + * The SDK rows by id. A preset `persona` row and the SDK `system-prompt.personaPrefix` render the same persona section, + * so the SDK prefix also compares as that row. */ -function sdkRows(rows: readonly Row[], ids: Iterable): Map { +function sdkRows(rows: readonly Row[]): Map { const all = leaves(rows) const prefix = (all.get('system-prompt') as { config?: { personaPrefix?: unknown } } | undefined)?.config?.personaPrefix if (prefix !== undefined) all.set('persona', { name: '@deepseek-ai/dsh-persona', disabled: false, config: { prefix } }) - return new Map([...ids].filter(id => all.has(id)).map(id => [id, all.get(id)])) + return all +} + +/** + * Pair each SDK row with the Desktop row it is compared against: the standard preset row of its id, else the Desktop + * host row of its id. A disabled SDK row with neither counterpart is absent on both sides. + * @param sdk - SDK rows by id. + * @param web - the Desktop (`web`) composition rows. + * @returns the SDK and Desktop sides of one entry table each. + */ +function pairRows(sdk: ReadonlyMap, web: readonly Row[]): [Map, Map] { + const preset = presetRows(web) + const host = leaves(web) + const desktop = new Map(preset) + const compared = new Map() + for (const id of preset.keys()) if (sdk.has(id)) compared.set(id, sdk.get(id)) + for (const [id, row] of sdk) { + if (preset.has(id)) continue + if (host.has(id)) { + compared.set(id, row) + desktop.set(id, host.get(id)) + } else if ((row as { disabled: unknown }).disabled !== true) compared.set(id, row) + } + return [compared, desktop] } async function fixture(test: TestContext) { @@ -62,13 +95,12 @@ async function fixture(test: TestContext) { return parseEntryYaml(result.stdout) as Row[] } return async (sdkPatches: object[] = []): Promise => { - const desktop = presetRows(await dump('web')) - const sdk = sdkRows(await dump('sdk', sdkPatches), desktop.keys()) + const [sdk, desktop] = pairRows(sdkRows(await dump('sdk', sdkPatches)), await dump('web')) return compareEntries('config', 'config', sdk, desktop) } } -it('compares the SDK agent rows with the Desktop standard preset', async (test) => { +it('compares the SDK rows with the Desktop standard composition', async (test) => { const differences = await fixture(test) assertParity(['config'], await differences()) }) @@ -78,3 +110,13 @@ it('detects a one-sided agent row change', async (test) => { const changed = await differences([{ id: 'tool-todo', config: { allowParallelInProgress: false } }]) expect(() => { assertParity(['config'], changed) }).toThrow('config tool-todo:/config/allowParallelInProgress (differs)') }) + +it('detects SDK rows outside the preset: a host row change and an SDK-only row', async (test) => { + const differences = await fixture(test) + const changed = await differences([ + { id: 'repeat-tool-reminder', config: { thresholds: [3, 5, 9], argumentsPreviewChars: 500 } }, + { insert: [{ id: 'parity-sdk-only', name: '@deepseek-ai/dsh-tool-present' }] }, + ]) + expect(() => { assertParity(['config'], changed) }).toThrow('config repeat-tool-reminder:/config/thresholds/2 (differs)') + expect(() => { assertParity(['config'], changed) }).toThrow('config parity-sdk-only (sdk only)') +}) diff --git a/apps/cli/tests/profiles/sdk/parity-exceptions.ts b/apps/cli/tests/profiles/sdk/parity-exceptions.ts index bfca69109d..0c2bd75499 100644 --- a/apps/cli/tests/profiles/sdk/parity-exceptions.ts +++ b/apps/cli/tests/profiles/sdk/parity-exceptions.ts @@ -7,6 +7,8 @@ import type { ParityException } from './parity.ts' const modelSelection = 'Desktop enables subagent model selection and discovery; SDK delegation inherits the caller model by default.' const webSurface = 'Desktop tells the model about the Web GUI that serves it; the SDK has no graphical surface.' const harnessSource = 'Desktop composes harness-dev-context to name the Harness checkout that serves its GUI; SDK embedders do not run the GUI.' +const primaryRuntime = 'Desktop always ships the primary runtime and selects it for the desktop profile; the SDK uses it only when the caller provides DSH_PRIMARY_RUNTIME or downloads it, and otherwise points the Office skills at the user Python.' +const sdkTransport = 'The SDK serves JSON-RPC over stdio instead of a Web server; the rows contribute no model context.' /** Every accepted difference; an entry that no longer matches an observed difference fails the comparison. */ export const parityExceptions: readonly ParityException[] = [ @@ -24,4 +26,15 @@ export const parityExceptions: readonly ParityException[] = [ reason: 'Desktop gates the tool on a profile-backed Host; the SDK always boots a profile, so both expose plugin_manager.' }, { kind: 'config', key: 'tool-plugin-market', side: 'desktop', reason: 'The Desktop preset declares the plugin market tools switched off; the SDK profile omits the row, so neither side exposes the tools.' }, + { kind: 'config', key: 'workspace-dependencies:/disabled', reason: primaryRuntime }, + { kind: 'config', key: 'workspace-dependencies:/config/source', reason: primaryRuntime }, + { kind: 'config', key: 'workspace-dependencies:/config/root', reason: primaryRuntime }, + { kind: 'config', key: 'skill-office:/config/pythonEnvironment', reason: primaryRuntime }, + { kind: 'config', key: 'hmr:/disabled', + reason: 'The SDK disables HMR so one stdio connection never observes its server or agent dependencies replaced; plugin_manager changes report restart-required instead of applied.' }, + { kind: 'config', key: 'session-title-llm:/disabled', + reason: 'The SDK has no title surface and skips the separate title request; the request is outside the agent context.' }, + { kind: 'config', key: 'sdk-app-startup', side: 'sdk', reason: sdkTransport }, + { kind: 'config', key: 'sdk-jsonrpc-server', side: 'sdk', reason: sdkTransport }, + { kind: 'config', key: 'connection:/config', reason: 'Desktop passes the trusted hosts of its Web server to the client connection; the SDK has no browser transport.' }, ] diff --git a/packages/bundle/sdk-app/README.i18n.yaml b/packages/bundle/sdk-app/README.i18n.yaml index 38f47a2b70..a0da9caa55 100644 --- a/packages/bundle/sdk-app/README.i18n.yaml +++ b/packages/bundle/sdk-app/README.i18n.yaml @@ -36,5 +36,5 @@ en: 9c42e75920483b74 zh: 0e9ff65a001a5919 /deepseek-ai-dsh-sdk-app/known-limitations-and-deferred-work/dev-note: - en: 8dc43118359abc13 - zh: 3d7133a25d3c2414 + en: 9c1bc0006484f978 + zh: 2acdf00c1c697b71 diff --git a/packages/bundle/sdk-app/README.md b/packages/bundle/sdk-app/README.md index 532c60fbd5..ad8cb2d498 100644 --- a/packages/bundle/sdk-app/README.md +++ b/packages/bundle/sdk-app/README.md @@ -80,6 +80,6 @@ Enabling `plugin_manager` changes the tool-schema prefix from earlier SDK versio
Working context for maintainers — click to expand -The [SDK/Desktop model context comparison](../../../apps/cli/tests/profiles/sdk/desktop-tools.expected.e2e.ts) and the [agent row comparison](../../../apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts) run without API credentials in `test:expected`, included in the required PR consumer job. Both compare this profile with native tool execution against the Desktop `standard` agent preset; PTC execution is not compared. The first compares the first model request of the top-level Agent, with Team off and on: tool names and schemas, system prompt sections, runtime context values, the session skill catalog and the other injected messages, after replacing test paths and clock readings and running both sides in UTC. The second compares the `--dump-config` rows the preset declares with the SDK rows of the same id, which covers sections a default turn does not show, such as plan mode. After building, run `CI=true pnpm run test:expected apps/cli/tests/profiles/sdk/`. Record each accepted difference in the adjacent `parity-exceptions.ts` with a reason; an inconsistency left unfixed also names its tracking issue in `debt`. A fix makes its exception stale, so the fixing change removes it. Existing SDK session snapshots and installed-runtime smokes independently check model output and packaging. +The [SDK/Desktop model context comparison](../../../apps/cli/tests/profiles/sdk/desktop-tools.expected.e2e.ts) and the [agent row comparison](../../../apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts) run without API credentials in `test:expected`, included in the required PR consumer job. Both compare this profile with native tool execution against the Desktop `standard` agent preset; PTC execution is not compared. The first compares the first model request of the top-level Agent, with Team off and on: tool names and schemas, system prompt sections, runtime context values, the session skill catalog and the other injected messages, after replacing test paths and clock readings and running both sides in UTC. The second compares each `--dump-config` row of this profile with the preset row of the same id, or else with the Desktop host row of that id, and reports an enabled row neither has; it covers rows whose effect a default turn does not show, such as the plan mode section. After building, run `CI=true pnpm run test:expected apps/cli/tests/profiles/sdk/`. Record each accepted difference in the adjacent `parity-exceptions.ts` with a reason; an inconsistency left unfixed also names its tracking issue in `debt`. A fix makes its exception stale, so the fixing change removes it. Existing SDK session snapshots and installed-runtime smokes independently check model output and packaging.
diff --git a/packages/bundle/sdk-app/README.zh.md b/packages/bundle/sdk-app/README.zh.md index 769aaaf0c9..9e4ac40017 100644 --- a/packages/bundle/sdk-app/README.zh.md +++ b/packages/bundle/sdk-app/README.zh.md @@ -80,6 +80,6 @@ profile 继承 base 系统提示词,包括 `You are an AI agent powered by Dee
维护者工作上下文——点击展开 -[SDK/Desktop 模型上下文比较](../../../apps/cli/tests/profiles/sdk/desktop-tools.expected.e2e.ts)与 [agent 配置项比较](../../../apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts) 在 `test:expected` 中无需 API 凭据运行,并纳入 PR 必需的 consumer 作业。两者都比较本 profile(原生工具执行)与 Desktop `standard` agent preset,不比较 PTC 执行。前者比较顶层 Agent 在关闭和开启 Team 时的首个模型请求:工具名和 schema、系统提示词段落、运行时上下文取值、会话 skill 目录和其余注入消息;比较前替换测试路径和时间读数,两侧都在 UTC 下运行。后者用 `--dump-config` 比较该 preset 声明的配置项与 SDK 中同 id 的配置项,覆盖默认回合看不到的段落,例如 plan mode。构建后运行 `CI=true pnpm run test:expected apps/cli/tests/profiles/sdk/`。每项接受的差异都在相邻的 `parity-exceptions.ts` 中带理由登记;暂不修复的不一致还要在 `debt` 中写明跟踪 issue。差异修复后对应例外变为 stale,修复改动需同时删除它。已有 SDK 会话快照和安装后运行时 smoke 分别检查模型输出和打包结果。 +[SDK/Desktop 模型上下文比较](../../../apps/cli/tests/profiles/sdk/desktop-tools.expected.e2e.ts)与 [agent 配置项比较](../../../apps/cli/tests/profiles/sdk/agent-config-parity.expected.e2e.ts) 在 `test:expected` 中无需 API 凭据运行,并纳入 PR 必需的 consumer 作业。两者都比较本 profile(原生工具执行)与 Desktop `standard` agent preset,不比较 PTC 执行。前者比较顶层 Agent 在关闭和开启 Team 时的首个模型请求:工具名和 schema、系统提示词段落、运行时上下文取值、会话 skill 目录和其余注入消息;比较前替换测试路径和时间读数,两侧都在 UTC 下运行。后者用 `--dump-config` 把本 profile 的每个配置项与 preset 中同 id 的配置项比较,preset 中没有时与 Desktop 宿主层同 id 的配置项比较,两处都没有的已启用配置项单独报出;它覆盖默认回合看不到的配置效果,例如 plan mode 段落。构建后运行 `CI=true pnpm run test:expected apps/cli/tests/profiles/sdk/`。每项接受的差异都在相邻的 `parity-exceptions.ts` 中带理由登记;暂不修复的不一致还要在 `debt` 中写明跟踪 issue。差异修复后对应例外变为 stale,修复改动需同时删除它。已有 SDK 会话快照和安装后运行时 smoke 分别检查模型输出和打包结果。