2026-07-17 17:29:38 +08:00
|
|
|
import { createServer } from 'node:http'
|
2026-07-20 00:06:21 +08:00
|
|
|
import { mkdtemp, readFile, readdir, rm } from 'node:fs/promises'
|
2026-07-17 17:29:38 +08:00
|
|
|
import { tmpdir } from 'node:os'
|
|
|
|
|
import { join } from 'node:path'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
2026-07-20 00:06:21 +08:00
|
|
|
import { promisify } from 'node:util'
|
|
|
|
|
import { zstdDecompress } from 'node:zlib'
|
test: adopt execa for hand-rolled subprocess plumbing, parseArgs for llm-mock-server CLI, vi.waitFor for poll loops
Implements the execa Agent Note's four sub-changes:
- execa (root devDep + loader-smoke dep) replaces the hand-rolled
spawn-collect-timeout choreography in loader-smoke, apps/cli and
cli-demo/acp-demo built-bin e2e, lsp-local and code-runtime-worker
built-lib e2e, the tui pty-harness outer collector, the jsonrpc
keyless smoke, and crash-recovery's child spawn. Genuinely custom
parts stay custom: cli-demo's interrupt-on-marker, jsonrpc's
line-predicate protocol driving, crash-recovery's SIGKILL-at-failpoint.
The two loader-smoke /* v8 ignore */ OS-error branches are gone.
- llm-mock-server CLI tokenizes via node:util parseArgs; numeric
coercion/bounds/cross-option constraints stay manual; pinned
error-message tests updated to the parseArgs texts.
- both loadRootEnv copies in apps/web/tests are deleted: the owning
vitest configs (web unconditionally, snapshot in record mode)
already load the repo-root .env before these files run.
- the four poll loops (acp-snapshot harness waits + crash-recovery
waitForFile) ride vi.waitFor with explicit {interval, timeout}.
2026-07-26 22:29:41 +08:00
|
|
|
import { execa } from 'execa'
|
2026-07-17 17:29:38 +08:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
const binScript = fileURLToPath(new URL('../../../apps/cli/src/bin.ts', import.meta.url))
|
|
|
|
|
const patchPath = fileURLToPath(new URL('./keyless.patch.yml', import.meta.url))
|
2026-07-17 17:29:38 +08:00
|
|
|
const repoRoot = fileURLToPath(new URL('../../..', import.meta.url))
|
2026-07-20 00:06:21 +08:00
|
|
|
const decompress = promisify(zstdDecompress)
|
2026-07-17 17:29:38 +08:00
|
|
|
|
|
|
|
|
function waitForLine(
|
|
|
|
|
lines: string[],
|
|
|
|
|
predicate: (value: Record<string, unknown>) => boolean,
|
|
|
|
|
stderr: () => string,
|
|
|
|
|
): Promise<Record<string, unknown>> {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const deadline = Date.now() + 30_000
|
|
|
|
|
const poll = (): void => {
|
|
|
|
|
while (lines.length > 0) {
|
|
|
|
|
const line = lines.shift()!
|
|
|
|
|
if (!line.trim()) continue
|
|
|
|
|
try {
|
|
|
|
|
const value = JSON.parse(line) as Record<string, unknown>
|
|
|
|
|
if (predicate(value)) {
|
|
|
|
|
resolve(value)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
2026-07-19 22:19:42 +08:00
|
|
|
reject(new Error(`non-JSON stdout from JSON-RPC agent runtime: ${line}`))
|
2026-07-17 17:29:38 +08:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Date.now() >= deadline) {
|
|
|
|
|
reject(new Error(`timed out waiting for JSON-RPC response; stderr=${stderr()}`))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
setTimeout(poll, 10)
|
|
|
|
|
}
|
|
|
|
|
poll()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
describe('Python SDK dsh profile keyless smoke', () => {
|
2026-07-19 23:03:08 +08:00
|
|
|
it.each([
|
2026-07-30 18:11:20 +08:00
|
|
|
{ label: 'reports max-token turns with the default mapping config', envValue: undefined },
|
|
|
|
|
{ label: 'reports max-token turns with mapping enabled through env', envValue: 'true' },
|
|
|
|
|
{ label: 'reports max-token turns with mapping disabled through env', envValue: 'false' },
|
|
|
|
|
])('$label', async ({ envValue }) => {
|
2026-08-23 01:48:26 +08:00
|
|
|
const root = await mkdtemp(join(tmpdir(), 'dsh-python-sdk-runtime-smoke-'))
|
2026-07-17 17:29:38 +08:00
|
|
|
const modelRequests: Record<string, unknown>[] = []
|
|
|
|
|
const modelServer = createServer((request, response) => {
|
|
|
|
|
let body = ''
|
|
|
|
|
request.setEncoding('utf8')
|
|
|
|
|
request.on('data', (chunk: string) => { body += chunk })
|
|
|
|
|
request.on('end', () => {
|
|
|
|
|
modelRequests.push(JSON.parse(body) as Record<string, unknown>)
|
|
|
|
|
response.writeHead(200, { 'content-type': 'text/event-stream' })
|
|
|
|
|
response.write('data: {"choices":[{"delta":{"role":"assistant","content":null}}]}\n\n')
|
|
|
|
|
response.write('data: {"choices":[{"delta":{"content":"done"}}]}\n\n')
|
2026-07-19 23:03:08 +08:00
|
|
|
response.write('data: {"choices":[{"delta":{},"finish_reason":"length"}],"usage":{"prompt_tokens":3,"completion_tokens":1}}\n\n')
|
2026-07-17 17:29:38 +08:00
|
|
|
response.end('data: [DONE]\n\n')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
await new Promise<void>(resolve => modelServer.listen(0, '127.0.0.1', resolve))
|
|
|
|
|
const address = modelServer.address()
|
|
|
|
|
if (address === null || typeof address === 'string') throw new Error('model server did not bind a TCP port')
|
test: adopt execa for hand-rolled subprocess plumbing, parseArgs for llm-mock-server CLI, vi.waitFor for poll loops
Implements the execa Agent Note's four sub-changes:
- execa (root devDep + loader-smoke dep) replaces the hand-rolled
spawn-collect-timeout choreography in loader-smoke, apps/cli and
cli-demo/acp-demo built-bin e2e, lsp-local and code-runtime-worker
built-lib e2e, the tui pty-harness outer collector, the jsonrpc
keyless smoke, and crash-recovery's child spawn. Genuinely custom
parts stay custom: cli-demo's interrupt-on-marker, jsonrpc's
line-predicate protocol driving, crash-recovery's SIGKILL-at-failpoint.
The two loader-smoke /* v8 ignore */ OS-error branches are gone.
- llm-mock-server CLI tokenizes via node:util parseArgs; numeric
coercion/bounds/cross-option constraints stay manual; pinned
error-message tests updated to the parseArgs texts.
- both loadRootEnv copies in apps/web/tests are deleted: the owning
vitest configs (web unconditionally, snapshot in record mode)
already load the repo-root .env before these files run.
- the four poll loops (acp-snapshot harness waits + crash-recovery
waitForFile) ride vi.waitFor with explicit {interval, timeout}.
2026-07-26 22:29:41 +08:00
|
|
|
// The line-predicate protocol driving below is the genuinely custom part;
|
|
|
|
|
// execa owns spawn, the deadline, and exit settlement around it.
|
|
|
|
|
const child = execa(process.execPath, [
|
2026-07-17 17:29:38 +08:00
|
|
|
'--import',
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
'tsx/esm',
|
2026-07-17 17:29:38 +08:00
|
|
|
binScript,
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
'--profile',
|
|
|
|
|
'sdk',
|
|
|
|
|
'--patch',
|
|
|
|
|
patchPath,
|
2026-07-17 17:29:38 +08:00
|
|
|
], {
|
|
|
|
|
cwd: repoRoot,
|
|
|
|
|
env: {
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
DSH_HOME: join(root, '.dsh'),
|
|
|
|
|
DSH_PERMISSION_MODE: 'danger-full-access',
|
|
|
|
|
DSH_TELEMETRY_DISABLED: '1',
|
2026-07-17 17:29:38 +08:00
|
|
|
DEEPSEEK_API_KEY: 'keyless-smoke-no-call',
|
|
|
|
|
DEEPSEEK_BASE_URL: `http://127.0.0.1:${address.port}`,
|
2026-07-19 23:03:08 +08:00
|
|
|
...(envValue === undefined ? {} : { DSH_MAX_TOKENS_AS_SUCCESS: envValue }),
|
2026-07-17 17:29:38 +08:00
|
|
|
},
|
test: adopt execa for hand-rolled subprocess plumbing, parseArgs for llm-mock-server CLI, vi.waitFor for poll loops
Implements the execa Agent Note's four sub-changes:
- execa (root devDep + loader-smoke dep) replaces the hand-rolled
spawn-collect-timeout choreography in loader-smoke, apps/cli and
cli-demo/acp-demo built-bin e2e, lsp-local and code-runtime-worker
built-lib e2e, the tui pty-harness outer collector, the jsonrpc
keyless smoke, and crash-recovery's child spawn. Genuinely custom
parts stay custom: cli-demo's interrupt-on-marker, jsonrpc's
line-predicate protocol driving, crash-recovery's SIGKILL-at-failpoint.
The two loader-smoke /* v8 ignore */ OS-error branches are gone.
- llm-mock-server CLI tokenizes via node:util parseArgs; numeric
coercion/bounds/cross-option constraints stay manual; pinned
error-message tests updated to the parseArgs texts.
- both loadRootEnv copies in apps/web/tests are deleted: the owning
vitest configs (web unconditionally, snapshot in record mode)
already load the repo-root .env before these files run.
- the four poll loops (acp-snapshot harness waits + crash-recovery
waitForFile) ride vi.waitFor with explicit {interval, timeout}.
2026-07-26 22:29:41 +08:00
|
|
|
timeout: 35_000,
|
|
|
|
|
killSignal: 'SIGKILL',
|
|
|
|
|
reject: false,
|
2026-07-17 17:29:38 +08:00
|
|
|
})
|
|
|
|
|
const lines: string[] = []
|
|
|
|
|
let stdoutBuffer = ''
|
|
|
|
|
let stderr = ''
|
test: adopt execa for hand-rolled subprocess plumbing, parseArgs for llm-mock-server CLI, vi.waitFor for poll loops
Implements the execa Agent Note's four sub-changes:
- execa (root devDep + loader-smoke dep) replaces the hand-rolled
spawn-collect-timeout choreography in loader-smoke, apps/cli and
cli-demo/acp-demo built-bin e2e, lsp-local and code-runtime-worker
built-lib e2e, the tui pty-harness outer collector, the jsonrpc
keyless smoke, and crash-recovery's child spawn. Genuinely custom
parts stay custom: cli-demo's interrupt-on-marker, jsonrpc's
line-predicate protocol driving, crash-recovery's SIGKILL-at-failpoint.
The two loader-smoke /* v8 ignore */ OS-error branches are gone.
- llm-mock-server CLI tokenizes via node:util parseArgs; numeric
coercion/bounds/cross-option constraints stay manual; pinned
error-message tests updated to the parseArgs texts.
- both loadRootEnv copies in apps/web/tests are deleted: the owning
vitest configs (web unconditionally, snapshot in record mode)
already load the repo-root .env before these files run.
- the four poll loops (acp-snapshot harness waits + crash-recovery
waitForFile) ride vi.waitFor with explicit {interval, timeout}.
2026-07-26 22:29:41 +08:00
|
|
|
child.stdout.on('data', (chunk: Buffer) => {
|
|
|
|
|
stdoutBuffer += chunk.toString('utf8')
|
2026-07-17 17:29:38 +08:00
|
|
|
const parts = stdoutBuffer.split('\n')
|
|
|
|
|
stdoutBuffer = parts.pop() ?? ''
|
|
|
|
|
lines.push(...parts)
|
|
|
|
|
})
|
test: adopt execa for hand-rolled subprocess plumbing, parseArgs for llm-mock-server CLI, vi.waitFor for poll loops
Implements the execa Agent Note's four sub-changes:
- execa (root devDep + loader-smoke dep) replaces the hand-rolled
spawn-collect-timeout choreography in loader-smoke, apps/cli and
cli-demo/acp-demo built-bin e2e, lsp-local and code-runtime-worker
built-lib e2e, the tui pty-harness outer collector, the jsonrpc
keyless smoke, and crash-recovery's child spawn. Genuinely custom
parts stay custom: cli-demo's interrupt-on-marker, jsonrpc's
line-predicate protocol driving, crash-recovery's SIGKILL-at-failpoint.
The two loader-smoke /* v8 ignore */ OS-error branches are gone.
- llm-mock-server CLI tokenizes via node:util parseArgs; numeric
coercion/bounds/cross-option constraints stay manual; pinned
error-message tests updated to the parseArgs texts.
- both loadRootEnv copies in apps/web/tests are deleted: the owning
vitest configs (web unconditionally, snapshot in record mode)
already load the repo-root .env before these files run.
- the four poll loops (acp-snapshot harness waits + crash-recovery
waitForFile) ride vi.waitFor with explicit {interval, timeout}.
2026-07-26 22:29:41 +08:00
|
|
|
child.stderr.on('data', (chunk: Buffer) => { stderr += chunk.toString('utf8') })
|
2026-07-17 17:29:38 +08:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
child.stdin.write(`${JSON.stringify({
|
|
|
|
|
jsonrpc: '2.0',
|
|
|
|
|
id: 1,
|
|
|
|
|
method: 'initialize',
|
2026-07-29 16:36:07 +08:00
|
|
|
params: { cwd: root, provider: 'deepseek-official', model: 'deepseek-v4-pro', maxTokens: 1234 },
|
2026-07-17 17:29:38 +08:00
|
|
|
})}\n`)
|
|
|
|
|
const initialized = await waitForLine(lines, value => value.id === 1, () => stderr)
|
|
|
|
|
expect(initialized).toMatchObject({
|
|
|
|
|
jsonrpc: '2.0',
|
|
|
|
|
id: 1,
|
|
|
|
|
result: { serverInfo: { name: 'deepseek-harness-sdk-runtime' } },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
child.stdin.write(`${JSON.stringify({
|
|
|
|
|
jsonrpc: '2.0',
|
|
|
|
|
id: 2,
|
|
|
|
|
method: 'session/prompt',
|
|
|
|
|
params: { sessionId: 'main', contentBlocks: [{ type: 'text', text: 'inspect tools' }] },
|
|
|
|
|
})}\n`)
|
2026-07-30 18:11:20 +08:00
|
|
|
const prompt = await waitForLine(lines, value => value.id === 2, () => stderr)
|
|
|
|
|
expect(prompt).toMatchObject({
|
2026-07-19 23:03:08 +08:00
|
|
|
jsonrpc: '2.0',
|
2026-07-30 18:11:20 +08:00
|
|
|
id: 2,
|
|
|
|
|
result: { messageId: expect.any(String) as unknown },
|
|
|
|
|
})
|
|
|
|
|
const turnEnd = await waitForLine(lines, (value) => {
|
|
|
|
|
if (value.method !== 'session.event') return false
|
|
|
|
|
const params = value.params as Record<string, unknown> | undefined
|
|
|
|
|
const event = params?.event as Record<string, unknown> | undefined
|
|
|
|
|
return params?.sessionId === 'main' && event?.type === 'turn/end'
|
|
|
|
|
}, () => stderr)
|
|
|
|
|
expect(turnEnd).toMatchObject({
|
|
|
|
|
jsonrpc: '2.0',
|
|
|
|
|
method: 'session.event',
|
2026-07-19 23:03:08 +08:00
|
|
|
params: {
|
|
|
|
|
sessionId: 'main',
|
2026-07-30 18:11:20 +08:00
|
|
|
event: {
|
|
|
|
|
type: 'turn/end',
|
|
|
|
|
data: { reason: { kind: 'max-tokens' } },
|
|
|
|
|
},
|
2026-07-19 23:03:08 +08:00
|
|
|
},
|
|
|
|
|
})
|
2026-07-17 17:29:38 +08:00
|
|
|
const tools = modelRequests[0]?.tools as { function?: { name?: string } }[]
|
2026-07-28 17:36:44 +08:00
|
|
|
expect(modelRequests[0]?.max_tokens).toBe(1234)
|
2026-07-17 17:29:38 +08:00
|
|
|
expect(tools.map(tool => tool.function?.name).sort()).toEqual([
|
|
|
|
|
'bash',
|
|
|
|
|
'edit',
|
|
|
|
|
'read',
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
'read_image',
|
2026-07-17 17:29:38 +08:00
|
|
|
'subagent',
|
|
|
|
|
'todo_write',
|
|
|
|
|
'write',
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', id: 3, method: 'shutdown' })}\n`)
|
|
|
|
|
const shutdown = await waitForLine(lines, value => value.id === 3, () => stderr)
|
|
|
|
|
expect(shutdown).toMatchObject({ jsonrpc: '2.0', id: 3, result: {} })
|
test: adopt execa for hand-rolled subprocess plumbing, parseArgs for llm-mock-server CLI, vi.waitFor for poll loops
Implements the execa Agent Note's four sub-changes:
- execa (root devDep + loader-smoke dep) replaces the hand-rolled
spawn-collect-timeout choreography in loader-smoke, apps/cli and
cli-demo/acp-demo built-bin e2e, lsp-local and code-runtime-worker
built-lib e2e, the tui pty-harness outer collector, the jsonrpc
keyless smoke, and crash-recovery's child spawn. Genuinely custom
parts stay custom: cli-demo's interrupt-on-marker, jsonrpc's
line-predicate protocol driving, crash-recovery's SIGKILL-at-failpoint.
The two loader-smoke /* v8 ignore */ OS-error branches are gone.
- llm-mock-server CLI tokenizes via node:util parseArgs; numeric
coercion/bounds/cross-option constraints stay manual; pinned
error-message tests updated to the parseArgs texts.
- both loadRootEnv copies in apps/web/tests are deleted: the owning
vitest configs (web unconditionally, snapshot in record mode)
already load the repo-root .env before these files run.
- the four poll loops (acp-snapshot harness waits + crash-recovery
waitForFile) ride vi.waitFor with explicit {interval, timeout}.
2026-07-26 22:29:41 +08:00
|
|
|
const exit = await child
|
|
|
|
|
expect(exit.exitCode, `signal=${String(exit.signal)}; stderr=${stderr}`).toBe(0)
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
const sessionsRoot = join(root, '.dsh', 'sessions')
|
2026-07-20 00:06:21 +08:00
|
|
|
const files = await readdir(sessionsRoot, { recursive: true })
|
|
|
|
|
const log = files.find(file => file.endsWith('.jsonl.zstd'))
|
|
|
|
|
expect(log).toBeDefined()
|
|
|
|
|
const compressed = await readFile(join(sessionsRoot, log!))
|
|
|
|
|
expect(compressed.subarray(0, 4).toString('hex')).toBe('28b52ffd')
|
|
|
|
|
expect(JSON.parse((await decompress(compressed)).toString())).toMatchObject({ type: 'session', id: 'main' })
|
2026-07-17 17:29:38 +08:00
|
|
|
} finally {
|
test: adopt execa for hand-rolled subprocess plumbing, parseArgs for llm-mock-server CLI, vi.waitFor for poll loops
Implements the execa Agent Note's four sub-changes:
- execa (root devDep + loader-smoke dep) replaces the hand-rolled
spawn-collect-timeout choreography in loader-smoke, apps/cli and
cli-demo/acp-demo built-bin e2e, lsp-local and code-runtime-worker
built-lib e2e, the tui pty-harness outer collector, the jsonrpc
keyless smoke, and crash-recovery's child spawn. Genuinely custom
parts stay custom: cli-demo's interrupt-on-marker, jsonrpc's
line-predicate protocol driving, crash-recovery's SIGKILL-at-failpoint.
The two loader-smoke /* v8 ignore */ OS-error branches are gone.
- llm-mock-server CLI tokenizes via node:util parseArgs; numeric
coercion/bounds/cross-option constraints stay manual; pinned
error-message tests updated to the parseArgs texts.
- both loadRootEnv copies in apps/web/tests are deleted: the owning
vitest configs (web unconditionally, snapshot in record mode)
already load the repo-root .env before these files run.
- the four poll loops (acp-snapshot harness waits + crash-recovery
waitForFile) ride vi.waitFor with explicit {interval, timeout}.
2026-07-26 22:29:41 +08:00
|
|
|
// No-op after exit; reject: false settles on every outcome, so cleanup never races teardown.
|
|
|
|
|
child.kill('SIGKILL')
|
|
|
|
|
await child
|
2026-07-17 17:29:38 +08:00
|
|
|
await new Promise<void>(resolve => modelServer.close(() => { resolve() }))
|
|
|
|
|
await rm(root, { recursive: true, force: true })
|
|
|
|
|
}
|
|
|
|
|
}, 40_000)
|
2026-07-19 23:03:08 +08:00
|
|
|
|
|
|
|
|
it('rejects an invalid max-token success env value', async () => {
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
const root = await mkdtemp(join(tmpdir(), 'dsh-python-sdk-runtime-invalid-'))
|
|
|
|
|
try {
|
|
|
|
|
const { exitCode, stdout, stderr } = await execa(process.execPath, [
|
|
|
|
|
'--import',
|
|
|
|
|
'tsx/esm',
|
|
|
|
|
binScript,
|
|
|
|
|
'--profile',
|
|
|
|
|
'sdk',
|
|
|
|
|
'--patch',
|
|
|
|
|
patchPath,
|
|
|
|
|
], {
|
|
|
|
|
cwd: repoRoot,
|
|
|
|
|
env: {
|
|
|
|
|
DSH_HOME: join(root, '.dsh'),
|
|
|
|
|
DEEPSEEK_API_KEY: 'keyless-smoke-no-call',
|
|
|
|
|
DSH_MAX_TOKENS_AS_SUCCESS: 'sometimes',
|
|
|
|
|
},
|
|
|
|
|
stdin: 'ignore',
|
|
|
|
|
timeout: 25_000,
|
|
|
|
|
killSignal: 'SIGKILL',
|
|
|
|
|
reject: false,
|
|
|
|
|
})
|
2026-07-19 23:03:08 +08:00
|
|
|
|
test(python): prove installed dsh profile customization
Migrate the packaged-runtime smoke inventory from complete Cordis trees to the sdk profile plus ordered patches. Preserve the focused minimal and advanced behaviors, update the generated durable snapshots for explicit permission events and the smaller RunResult, and keep worker, MCP, ripgrep, PTY/editor, direct JSON-RPC, and real-provider coverage.
Add an installed-only external bundle scenario that invokes the wheel's dsh plugin command with a local file package, verifies profile manifest reconciliation, imports @deepseek-ai/cordis as a peer, asserts the packaged proxy returns the exact host Context instance, and proves its system-prompt contribution reaches the model. Migrate the repository source e2e and runnable minimal example to the same profile grammar.
2026-08-23 14:56:34 +08:00
|
|
|
expect(exitCode, stderr).toBe(1)
|
|
|
|
|
expect(stdout).toBe('')
|
|
|
|
|
expect(stderr).toContain('plugin tree failed to load')
|
|
|
|
|
expect(stderr).toContain('failed to apply loader entry sdk-jsonrpc-server (@deepseek-ai/dsh-sdk-jsonrpc-server)')
|
|
|
|
|
expect(stderr).toContain('sometimes')
|
|
|
|
|
} finally {
|
|
|
|
|
await rm(root, { recursive: true, force: true })
|
|
|
|
|
}
|
2026-07-26 23:10:38 +08:00
|
|
|
}, 30_000)
|
2026-07-17 17:29:38 +08:00
|
|
|
})
|