From b5131b4ae10b68fa57463d5ffbcadd90f78cd456 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Wed, 21 Oct 2026 11:25:07 +0800 Subject: [PATCH] test(ptc): cover defaults and align CUA fixtures with launch modes --- .../cua-macos/tests/persistent-bridge.built.e2e.ts | 2 +- packages/ptc-runtime/ptc-runtime/tests/service.spec.ts | 3 +++ snapshots/session/headless.snapshot.ts | 9 ++++++--- snapshots/session/ptc-script-retained/cua-guidance.mjs | 7 +++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/experimental/cua-macos/tests/persistent-bridge.built.e2e.ts b/packages/experimental/cua-macos/tests/persistent-bridge.built.e2e.ts index b9573c9eca..50b20e796c 100644 --- a/packages/experimental/cua-macos/tests/persistent-bridge.built.e2e.ts +++ b/packages/experimental/cua-macos/tests/persistent-bridge.built.e2e.ts @@ -71,7 +71,7 @@ it.skipIf(process.platform === 'win32' || !existsSync(bridge) || !existsSync(boo })) expect((await run('await import("@deepseek-ai/dsh-cua/bridge")', 'unresolved')).error?.message).toContain('Cannot find package') const section = (await ctx.systemPrompt.assemble()).sections.find(value => value.name === 'computer-use:dsh-cua') - const initialization = section?.text.split('Persistent PTC initialization:\n')[1] + const initialization = section?.text.match(/Persistent PTC initialization:\n\n```ts\n([\s\S]*?)\n```/u)?.[1] expect(initialization).toContain('/lib/bridge.js') const first = await run(`${initialization}\nvar app = await cua.getApp("test.fixture"); var win = await app.getWindow(7); await win.click(0); var shot = await win.getScreenshot(); ({ mimeType: shot.mimeType, pixelWidth: shot.pixelWidth, pixelHeight: shot.pixelHeight, windowId: shot.windowId, byteLength: shot.bytes.length });`, 'first') expect(first.error).toBeUndefined() diff --git a/packages/ptc-runtime/ptc-runtime/tests/service.spec.ts b/packages/ptc-runtime/ptc-runtime/tests/service.spec.ts index f423058186..57261a3caf 100644 --- a/packages/ptc-runtime/ptc-runtime/tests/service.spec.ts +++ b/packages/ptc-runtime/ptc-runtime/tests/service.spec.ts @@ -45,6 +45,9 @@ describe('PtcRuntime service seam', () => { expect(runtime.isolation).toBe('in-process-stub') expect(runtime.sandboxMode).toBeUndefined() expect(runtime.programFormat).toBe('function-body') + expect(runtime.retainsState).toBe(false) + expect(runtime.executionInstructions).toBe('') + expect(runtime.timeout).toBeUndefined() await expect(runtime.release({})).resolves.toBeUndefined() const calls: unknown[] = [] diff --git a/snapshots/session/headless.snapshot.ts b/snapshots/session/headless.snapshot.ts index 1c1c23106a..9049f5e9c0 100644 --- a/snapshots/session/headless.snapshot.ts +++ b/snapshots/session/headless.snapshot.ts @@ -50,7 +50,7 @@ import { type SnapshotManifest, type WorkspaceSnapshotEntry, } from '@deepseek-ai/dsh-session-snapshot' -import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke' +import { LOADER_SMOKE_TEST_TIMEOUT_MS, resolveExampleMode, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke' import { resolvePwshPath } from '@deepseek-ai/dsh-pwsh-local' import { parseSessionLog, prepareSessionSnapshotFixtureForComparison } from '@deepseek-ai/dsh-llm-replay' @@ -500,10 +500,13 @@ const workspaceSetups: Record Promise> = { // Keep the real prompt's bridge URL under the fixture workspace on every host. const source = join(repoRoot, 'packages/experimental/cua') const target = join(cwd, 'cua-runtime') - await cp(join(source, 'src'), join(target, 'src'), { recursive: true }) + const face = resolveExampleMode() === 'lib' ? 'lib' : 'src' + const extension = face === 'lib' ? 'js' : 'ts' + const guidanceDirectory = face === 'lib' ? 'lib/types' : 'src' + await cp(join(source, face), join(target, face), { recursive: true }) await copyFile(join(source, 'package.json'), join(target, 'package.json')) await symlink(join(source, 'node_modules'), join(target, 'node_modules'), 'dir') - await copyFile(join(repoRoot, 'packages/experimental/cua-macos/src/guidance.ts'), join(target, 'guidance.ts')) + await copyFile(join(repoRoot, `packages/experimental/cua-macos/${guidanceDirectory}/guidance.${extension}`), join(target, `guidance.${extension}`)) }, async 'windows-acl-skill'(cwd) { const target = join(cwd, '.dsh', 'skills', 'diagnose-windows-sandbox-acl', 'SKILL.md') diff --git a/snapshots/session/ptc-script-retained/cua-guidance.mjs b/snapshots/session/ptc-script-retained/cua-guidance.mjs index c12f500cd5..5776912817 100644 --- a/snapshots/session/ptc-script-retained/cua-guidance.mjs +++ b/snapshots/session/ptc-script-retained/cua-guidance.mjs @@ -9,8 +9,11 @@ export const Config = CuaConfig export async function apply(ctx, config) { const root = join(process.cwd(), 'cua-runtime') - const { installCua } = await import(pathToFileURL(join(root, 'src/index.ts')).href) - const { GUIDANCE } = await import(pathToFileURL(join(root, 'guidance.ts')).href) + // The snapshot launcher validates and propagates the selected program mode. + const face = process.env.DSH_EXAMPLE_MODE === 'lib' ? 'lib' : 'src' + const extension = face === 'lib' ? 'js' : 'ts' + const { installCua } = await import(pathToFileURL(join(root, face, `index.${extension}`)).href) + const { GUIDANCE } = await import(pathToFileURL(join(root, `guidance.${extension}`)).href) installCua(ctx, config, { helperPath: process.execPath, createChannel() { throw new Error('This prompt fixture does not perform native operations') },