Files
deepseek-harness/packages/workflow/workflow-ptc/tests/source-runtime.compat.spec.ts
T
Tianyi Cui a3cb678875 Merge master current-directory support into subagent activations
Integrate the observed master checkpoint 7ab215e23e5d977aae7eb5d4fb91782d39969dbb without rewriting the earlier published checkpoints. Master adds current-directory events, directory-aware consumers, and retained Git worktrees; its old subagent startup paths overlapped the unified activation implementation.

Resolve directory selection within managed startup after acquiring parent ownership. Preserve the original Session origin while setting each new local child directory, retain persisted directory state on cold resume, and pass a required absolute cwd to external providers. Keep unified local/external ownership, full completion notices, parked-input host completion, SDK wait/error/shutdown behavior, and ACP cancellation semantics. Retain removal of the old in-process driver and continuation managers.

Combine SDK wait with the new directory requests, preserve the new master directory/worktree fixtures, regenerate derived catalogs from the combined sources, and refresh only the four stale prompt/schema sidecars. Preserve every protected historical schema, archived note, catalog-v2 acknowledgement, and recorded predecessor input.

Validation: full build; 59 CI static gates; 855 subagent tests with 100% coverage on changed core/external sources; affected consumer suites including 119 repaired-fixture tests; SDK 11 and headless 16 recorded scenarios; two local headless expected cases; six built nested SDK/ACP cases; lint, strict cast inventory, workspace constraints, and whitespace checks. Native Windows worker diagnostics remain additive and require the next CI run to classify the original crash.
2026-10-06 10:52:35 +08:00

64 lines
2.7 KiB
TypeScript

import { provideWorkingDirectoryFixture } from '@deepseek-ai/dsh-agent-loop-testkit'
/** The Node compatibility matrix runs this complete source-entry smoke. */
import { readFile, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import { expect, it } from 'vitest'
import { Context } from '@deepseek-ai/cordis'
import SubagentRuntime from '@deepseek-ai/dsh-subagent'
import type { SandboxMode } from '@deepseek-ai/dsh-sandbox'
import PtcWorkflowEngine from '../src/index.ts'
import { fakeParent, mountPtcRuntime } from './setup.ts'
async function setup(mode: SandboxMode) {
const ctx = new Context()
const files = await mountPtcRuntime(ctx, mode)
provideWorkingDirectoryFixture(ctx)
await ctx.plugin(SubagentRuntime)
ctx.subagents.registerProvider({
name: 'spawn',
capabilities: { agentOptions: true, outputSchema: true, depthLimit: true, toolFilter: true, persona: true },
inheritsParentContext: false,
start: () => Promise.reject(new Error('source runtime smoke must not start a child')),
})
await ctx.plugin(PtcWorkflowEngine, {})
return { ctx, parent: await fakeParent(ctx), ...files }
}
it('runs the default workflow config through the source PTC runtime', async () => {
const { ctx, parent } = await setup('read-only')
const run = ctx.workflowEngine.start({
script: 'return args.left * args.right',
args: { left: 6, right: 7 },
meta: { name: 'source-runtime-compat', description: 'source workflow and PTC entry' },
parent,
})
try {
const result = await run.result
expect(result, result.error).toMatchObject({ value: 42, stopReason: 'completed', agentsStarted: 0 })
} finally { await run.dispose() }
})
it.each(['read-only', 'workspace-write'] as const)('enforces the Session file policy %s for direct Node writes', async (mode) => {
const { ctx, parent, root, cwd } = await setup(mode)
const outside = join(root, 'outside.txt')
const inside = join(cwd, 'inside.txt')
await writeFile(outside, 'unchanged')
const run = ctx.workflowEngine.start({
script: `const proc = globalThis.constructor.constructor('return process')()
const fs = proc.getBuiltinModule('node:fs')
try { fs.writeFileSync('inside.txt', 'inside') } catch {}
try { fs.writeFileSync(args.outside, 'changed') } catch {}
return 42`,
args: { outside },
meta: { name: 'source-confinement', description: 'direct Node file writes' },
parent,
})
try {
const result = await run.result
expect(result.stopReason, result.error).toBe('completed')
expect(await readFile(outside, 'utf8')).toBe('unchanged')
if (mode === 'workspace-write') expect(await readFile(inside, 'utf8')).toBe('inside')
else await expect(readFile(inside, 'utf8')).rejects.toMatchObject({ code: 'ENOENT' })
} finally { await run.dispose() }
})