test(ptc): cover defaults and align CUA fixtures with launch modes

This commit is contained in:
_Kerman committed 2026-10-21 11:25:07 +08:00
1 parent a027637c51
commit b5131b4ae1
4 files changed
+15 -6

No files matched your search

@@ -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()
@@ -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[] = []
+6 -3
View File
@@ -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<string, (cwd: string) => Promise<void>> = {
// 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')
@@ -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') },