fix(ptc): allow local process declarations in function bodies

This commit is contained in:
_Kerman committed 2026-10-21 19:51:50 +08:00
1 parent 25ede01a8b
commit c905726461
5 files changed
+14 -6

No files matched your search

@@ -1,7 +1,7 @@
/** Node child evaluation over typed RPC; the host owns process lifetime. */
import type { PtcProgramFormat } from '@deepseek-ai/dsh-ptc-runtime'
import { AsyncLocalStorage } from 'node:async_hooks'
import type { Duplex } from 'node:stream'
import type { PtcProgramFormat } from '@deepseek-ai/dsh-ptc-runtime'
import { createProcessRpc } from './rpc.ts'
import { captureStreamWrites, LogBuffer, makeConsoleShim, makeBindingErrorClass, makeNamespaces, prepareCompletion, prepareException } from './bootstrap.ts'
import type { BindingErrorConstructor, PatchableStream } from './bootstrap.ts'
@@ -92,7 +92,8 @@ export async function runNodeMain(
if (active?.active && error) active.finish(prepareException(error, active.logs.remainingOutputBytes(), active.maxOutputBytes))
})
evaluator.globals.console = makeConsoleShim(logSink)
Object.defineProperty(evaluator.globals, 'process', { configurable: true, enumerable: true, writable: true, value: processState })
// Context access must not reserve a function-body parameter named process.
Object.defineProperty(evaluator.globals, 'process', { configurable: true, writable: true, value: processState })
}
for (const namespace of data.namespaces) {
const descriptor = namespace.errorClass