Files
deepseek-harness/packages/ptc-runtime/ptc-runtime-node/src/configuration.ts
T
imccyu 37e0924f68 Merge pull request #8257 from deepseek-harness/ptc-scoped-repl-switch
feat(ptc): run the scoped REPL by default for persistent-in-memory execution
2026-11-10 22:34:59 +08:00

27 lines
1.6 KiB
TypeScript

/** Pure configuration changes for Node PTC profile editors. */
import type { PtcProgramFormat } from '@deepseek-ai/dsh-ptc-runtime'
import type { Config } from './config.ts'
import { assertNever } from '@deepseek-ai/dsh-util-values'
/** `replScoped` written for retained function bodies and REPL statements; the Node provider also uses it when `replScoped` is omitted. */
const SCOPED_REPL_BY_DEFAULT: boolean = true
/**
* Select retained Node execution while preserving Script and scoped REPL syntax.
* @param programFormat - Effective syntax; omission uses the Node provider's default function-body syntax.
* @returns All three settings to merge into the profile atomically, replacing stale values; function bodies and REPL statements
* switch to `persistent-in-memory` with `SCOPED_REPL_BY_DEFAULT`, which is also the default when `replScoped` is omitted.
*/
export function resolvePersistentExecution(
programFormat: PtcProgramFormat = 'function-body',
): Pick<Required<Config>, 'executionMode' | 'scriptPersistence' | 'replScoped'> {
switch (programFormat) {
case 'script': return { executionMode: 'vm-script', scriptPersistence: true, replScoped: false }
case 'function-body':
case 'repl': return { executionMode: 'persistent-in-memory', scriptPersistence: false, replScoped: SCOPED_REPL_BY_DEFAULT }
case 'scoped-repl': return { executionMode: 'persistent-in-memory', scriptPersistence: false, replScoped: true }
/* v8 ignore next -- The runtime supplies the closed, typed program-format union. */
default: return assertNever(programFormat)
}
}