Update the full-text instruction assertions, the run_code tool-schema and system-prompt sidecars of the session, SDK, and Web snapshots, the cua-mcp expected tools, the generated tool catalog with its Chinese pair, and the ptc-runtime-node README pair.
* feat(ptc): define scoped REPL top-level scopes and import base in guidance
The scoped REPL guidance now states the rules a program follows instead of
listing edge cases: each run_code call runs one program in its own top-level
scope, whose top-level declarations and received names are copied, not
referenced, into later programs; a program either uses a copied name or
declares it again; block-level var is discouraged because it changes which
value later programs copy; a failed program keeps earlier values. It names
the missing require and module and separates the import base, fixed at the
environment's first program, from process.cwd(), which follows each program.
Formats without top-level return say to await work before the program ends.
* test(ptc): pin the scoped REPL scope and import guidance
Update the verbatim scoped REPL guidance assertion and refresh, without a key,
the recorded run_code descriptions of the PTC and CUA scenarios whose guidance
changed: the scoped REPL rules and the "before the program ends" wording
shared by retained formats.
* test(cua-mcp): refresh the cua_run_code description for the scoped REPL guidance
The cua-mcp profile expectation landed on master after this branch's base; it lists cua_run_code with the scoped REPL execution instructions.
* fix(ptc): keep the shared scoped guidance free of a consumer tool name
The runtime execution instructions are shared by run_code and cua_run_code, so
the new sentence no longer names run_code. The Agent Note also gives the
missing top-level return as the reason for the retained-state wording, which
covers the persistent script format as well as the REPLs.
* test(ptc): pin the unchanged scoped guidance across consumers
The verbatim assertion, the three scoped tool schemas, and the cua-mcp profile
fixture follow the shared sentence, which no longer names run_code.
The child filters Node's ExperimentalWarning for vm.USE_MAIN_CONTEXT_DEFAULT_LOADER
and stripTypeScriptTypes, which the runtime itself triggers; an environment
initializer that imports a module under the scoped REPL otherwise prints it into
the first call's output. Warnings that programs emit still print. The host strips
types without printing the stripTypeScriptTypes warning.
Scoped REPL programs are named resolve(<creation cwd>, '.ptc-repl-<n>.js'), so on Windows their stacks show backslash paths. Compare locations against the resolved filename instead of a hardcoded '/' separator, keeping the submission ordinal, line, and column checks.
run_code now discards completion values for TypeScript runtimes, so the
scoped REPL guidance shares the inspect output sentence with the other
modes. Tests read the output field, cover environment initialization with
copied bindings, and the ptc-scoped-repl snapshot is re-recorded with
inspect output.
Each call's Script filename becomes <first working directory>/.ptc-repl-<n>.js.
No file exists at that path; the directory stays because Node's default loader
resolves relative import() specifiers from the filename.
A call that declares an earlier name again only with var now gets a var
copy of the earlier value, so a var declaration that does not run, after
a throw or in an untaken branch, keeps that value as a global var does in
Node's REPL. var count = count + 1 consequently adds to the earlier value.
A function of the same name in one call takes precedence over the var.
Update the model guidance, Agent Note, READMEs, and the ptc-scoped-repl
snapshot schema.
With replScoped: true, persistent-in-memory runs each call as a separate
VM Script in one retained context. Each call starts with copies of the
top-level bindings left by earlier calls, so a later call may declare any
earlier name again with any keyword while earlier functions and
still-running code keep their values. Results, top-level await, errors
and asynchronous failures follow the existing REPL evaluator; modules
load only through dynamic import(), resolved from the environment's first
working directory.
The control protocol moves to version 3; the upgrade guide covers
preinstalled bootstraps and the new PtcProgramFormat member. The Agent
Note records the decision and its comparison with node:repl and
vm-script, and the ptc-scoped-repl snapshot pins the model guidance.
run_code argument checks now throw ToolArgsError (INVALID_ARGS),
including timeoutMs or sandbox_permissions passed to a runtime whose
schema does not expose them; a missing runtime, workingDirectory, or
sandboxPolicy throws ToolContextUnavailableError. CodeRunFailedError
gains CODE_RUN_UNAVAILABLE after executor disposal, keeping
CODE_RUN_FAILED as the default. A runtime
rejection without its own code becomes CODE_RUN_FAILED with the
rejection as cause; caller cancellation keeps the signal's reason.
The PTC runtime Service Definition adds PtcRuntimeError for contract
misuse: PTC_RUNTIME_INVALID_ARGUMENT, PTC_RUNTIME_UNAVAILABLE, and
PTC_RUNTIME_CONFLICT. The Node runtime throws it for invalid specs and
bindings, use after disposal, incomplete retained cleanup, concurrent
runs for one owner, and a retained environment under another sandbox
policy. dsh-ptc-runtime now declares @deepseek-ai/dsh-error.
Refs #7869