fix: keep source Code Mode worker self-contained

A direct runtime import of the session package made the unbuilt worker depend on sibling lib output. Use a parity-tested local JSON snapshotter and pin the isolated source closure with a real-worker test.
This commit is contained in:
Tianyi Cui
2026-07-21 05:19:40 +08:00
parent aca8162ef2
commit 1709b8cfee
5 changed files with 193 additions and 3 deletions
@@ -6,8 +6,8 @@
*/
import { inspect } from 'node:util'
import { snapshotJsonValue } from '@deepseek-ai/dsh-session'
import type { DoneMessage, ReplyMessage, WorkerBootData, WorkerToHost } from './protocol.ts'
import { snapshotCodeJsonValue } from './worker-json.ts'
/** The port surface the bootstrap needs — satisfied by `parentPort` and by the tests' fake. */
export interface BootstrapPort {
@@ -157,7 +157,7 @@ export function prepareCompletion(value: unknown, maxOutputBytes: number): Omit<
if (value === undefined) return {}
let snapshot: unknown
try {
snapshot = snapshotJsonValue(value)
snapshot = snapshotCodeJsonValue(value)
} catch {
snapshot = undefined
}