docs(ptc): clarify remaining extension support and migration

This commit is contained in:
_Kerman committed 2026-11-11 15:37:46 +08:00
1 parent 5ea79d1fe7
commit f141464b59
17 files changed
+42 -51

No files matched your search

@@ -12,5 +12,5 @@
en: a4575a117b53ce7c
zh: 2ea9f832b2179537
/python-ptc-applies-the-shared-file-sandbox/migration:
en: 07db8fd9bdb92c10
zh: d2f74699578b8723
en: 2ef4feceb381d6eb
zh: 610648a7d2329d93
@@ -15,7 +15,7 @@ This affects custom compositions that select the Python runtime. Shipped profile
## Migration
1. In the `cordis.yml` or profile patch that selects the Python runtime, retain the existing shared sandbox services. If they are absent, mount `@deepseek-ai/dsh-sandbox-local` and `@deepseek-ai/dsh-sandbox-policy` with its required `@deepseek-ai/dsh-session-projection` service. See the [Python runtime requirements](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.1/packages/experimental/ptc-runtime-python/README.md#use-this-package).
1. In the `cordis.yml` or profile patch that selects the Python runtime, retain the existing shared sandbox services. If they are absent, mount `@deepseek-ai/dsh-sandbox-local` and `@deepseek-ai/dsh-sandbox-policy` with its required `@deepseek-ai/dsh-session-projection` service. See the Python runtime requirements ([English](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.2/packages/experimental/ptc-runtime-python/README.md#use-this-package), [中文](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.2/packages/experimental/ptc-runtime-python/README.zh.md#use-this-package)).
2. Set the shared `sandbox-policy` row's `mode` and `workspaceRoot` for agentless calls. Its default mode is `read-only`; `workspace-write` permits workspace writes. PTC tool calls use the Session's resolved policy and directory. Do not add a separate Python-only sandbox setting.
3. Direct service callers use `runtime.run(runtime.resolve(request))`; pass a trusted `sandboxPolicy` only when an explicit override is required. Model-facing `run_code` uses the existing approval flow for a one-call wider mode, without changing nested tools' permissions or replaying the program automatically.
4. Verify a program can write inside the intended workspace under `workspace-write`, fails to write outside it, and returns `result.sandbox.mode` and `result.sandbox.enforcement`. Under `read-only`, direct file writes fail. Inspect `sandbox-unavailable` separately from a denied file operation and repair the local sandbox installation before retrying.
@@ -15,7 +15,7 @@ description: "Python PTC 组合需要沙箱服务,且直接 Python 文件操
## 迁移
1. 在选择 Python 运行时的 `cordis.yml` 或 profile patch 中,保留已有共享沙箱服务。若尚未提供,挂载 `@deepseek-ai/dsh-sandbox-local` 和 `@deepseek-ai/dsh-sandbox-policy`,以及后者所需的 `@deepseek-ai/dsh-session-projection` 服务。参见 [Python 运行时要求](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.1/packages/experimental/ptc-runtime-python/README.md#use-this-package)。
1. 在选择 Python 运行时的 `cordis.yml` 或 profile patch 中,保留已有共享沙箱服务。若尚未提供,挂载 `@deepseek-ai/dsh-sandbox-local` 和 `@deepseek-ai/dsh-sandbox-policy`,以及后者所需的 `@deepseek-ai/dsh-session-projection` 服务。参见 Python 运行时要求([English](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.2/packages/experimental/ptc-runtime-python/README.md#use-this-package), [中文](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.2/packages/experimental/ptc-runtime-python/README.zh.md#use-this-package))。
2. 为无 Agent 调用设置共享 `sandbox-policy` 行的 `mode` 和 `workspaceRoot`。默认模式是 `read-only`;`workspace-write` 允许工作区写入。PTC 工具调用使用 Session 的已解析策略和目录。不要新增 Python 专用沙箱设置。
3. 直接服务调用方使用 `runtime.run(runtime.resolve(request))`;仅在需要显式覆盖时传入可信 `sandboxPolicy`。面向模型的 `run_code` 通过现有审批流程为一次调用扩大权限,不改变嵌套工具的权限,也不自动重放程序。
4. 验证程序在 `workspace-write` 下可以写入预期工作区、写入工作区外时失败,并返回 `result.sandbox.mode` 和 `result.sandbox.enforcement`。在 `read-only` 下,直接文件写入失败。将 `sandbox-unavailable` 与文件操作被拒绝区分处理,修复本地沙箱安装后再重试。
@@ -12,5 +12,5 @@
en: 09f1d48815a593eb
zh: 9fc1b25ae0736c64
/python-ptc-runtime-removal/migration:
en: 8732f177cc07862f
zh: 54a1bc7a425ed286
en: 0c178f15ce8392c3
zh: fdae160b37ca44e2
@@ -13,6 +13,7 @@ English | [中文](guide.zh.md)
## Migration
1. In the `cordis.yml` or profile patch that selects the Python provider, replace that row's `name` with `@deepseek-ai/dsh-ptc-runtime-node`. Remove its Python runtime `config`; configure Node limits separately when needed.
1. In the `cordis.yml` or profile patch that selects the Python provider, replace that row's `name` with `@deepseek-ai/dsh-ptc-runtime-node`. Remove its Python runtime `config`; configure Node limits separately when needed. Node also requires `fs` and `subprocess` alongside `sandbox` and `sandboxPolicy`. Reuse the existing providers; for a local composition missing them, mount `@deepseek-ai/dsh-fs-local` and `@deepseek-ai/dsh-subprocess-local` in the same execution world.
2. Rewrite Python `run_code` programs as TypeScript. For fresh execution per call, set `config.executionMode: per-call`; see the [Node runtime configuration](../../../../packages/ptc-runtime/ptc-runtime-node/README.md).
3. Run the affected profile with `--dump-config` and confirm its PTC runtime row selects `@deepseek-ai/dsh-ptc-runtime-node` with no Python provider row remaining. Run a PTC task and confirm that its TypeScript program completes.
3. Re-enable `workflow-ptc`, `tool-workflow`, and any previously enabled `tool-ralph` rows that were disabled solely for the Python provider, if those workflows are still wanted.
4. Run the affected profile with `--dump-config` and confirm its PTC runtime row selects `@deepseek-ai/dsh-ptc-runtime-node` with no Python provider row remaining. Run a PTC task and confirm that its TypeScript program completes.
@@ -13,6 +13,7 @@ description: "自定义 Python PTC 组合必须将已移除的运行时包替换
## 迁移
1. 在选择 Python 提供方的 `cordis.yml` 或 profile patch 中,将对应行的 `name` 替换为 `@deepseek-ai/dsh-ptc-runtime-node`。移除该行的 Python 运行时 `config`;如有需要,单独配置 Node 限制。
1. 在选择 Python 提供方的 `cordis.yml` 或 profile patch 中,将对应行的 `name` 替换为 `@deepseek-ai/dsh-ptc-runtime-node`。移除该行的 Python 运行时 `config`;如有需要,单独配置 Node 限制。除了 `sandbox` 和 `sandboxPolicy`,Node 还需要 `fs` 与 `subprocess`。复用已有提供方;本地组合若缺少它们,在同一执行环境中挂载 `@deepseek-ai/dsh-fs-local` 与 `@deepseek-ai/dsh-subprocess-local`。
2. 将 Python `run_code` 程序改写为 TypeScript。如需每次调用都使用全新执行环境,设置 `config.executionMode: per-call`;参见 [Node 运行时配置](../../../../packages/ptc-runtime/ptc-runtime-node/README.zh.md)。
3. 为受影响的 profile 添加 `--dump-config` 并运行,确认其 PTC 运行时行选择 `@deepseek-ai/dsh-ptc-runtime-node`,且不再保留 Python 提供方行。运行一个 PTC 任务并确认其 TypeScript 程序完成。
3. 如果仍需使用相关工作流,重新启用仅因 Python 提供方而禁用的 `workflow-ptc`、`tool-workflow`,以及此前启用过的 `tool-ralph` 行。
4. 为受影响的 profile 添加 `--dump-config` 并运行,确认其 PTC 运行时行选择 `@deepseek-ai/dsh-ptc-runtime-node`,且不再保留 Python 提供方行。运行一个 PTC 任务并确认其 TypeScript 程序完成。
@@ -15,8 +15,8 @@
en: d152484eb41ac6b4
zh: 09388d293f9be9cb
/deepseek-ai-dsh-tool-executor-ptc/use-this-package:
en: 90ceb23f80ce7b26
zh: 01ecb606d4e8fb6f
en: 8d3e288f223db19d
zh: 49da99d6201ae42f
/deepseek-ai-dsh-tool-executor-ptc/understand-the-implementation:
en: 78708b3779d999a9
zh: ad6173f9f01630de
@@ -38,6 +38,8 @@ Root `run_code` calls are exclusive and execute serially. `maxParallelSubCalls`
`maxSubCallsPerMinute` defaults to `1024` and must be a positive integer. Each `run_code` gets `floor(resolved timeoutMs / 60000 × maxSubCallsPerMinute)` tool-call attempts: the default Node timeout of two minutes allows 2048. Runtime defaults and timeout caps apply before this calculation; no deadline means no finite call allowance. This is a total allowance, not a rolling window, so calls may happen in a burst. All tool bindings share the count, including queued calls, invalid arguments, and failed tools. The next attempt terminates the entire program through the runtime abort path, cancels active subcalls, and abandons queued calls before returning `CODE_RUN_FAILED`. As with a timeout, catching a binding error cannot keep the program running; retained runtime state is discarded. Completed tool effects remain, and the next program starts a fresh count.
Custom `PtcRuntime` providers may report `language: 'typescript'` or `language: 'python'`. This executor generates the matching SDK and tool schema; the provider supplies execution. The Python renderer remains available for external providers independently of the repository's runtime packages.
This package declares `ctx.ptcRuntime` and `ctx.systemPrompt` as required injections; Agent-owned programs need `ctx.workingDirectory`. The executor activates only after its runtime is available and withdraws when that runtime unloads. An enabled PTC executor without a runtime stops application startup. A withdrawn PTC selection never falls back to native execution.
Shared dispatch events and the `ptc-mode` message-source declaration live in `@deepseek-ai/dsh-tool-executor-ptc/types`; Client code imports the same declarations through `@deepseek-ai/dsh-tool-executor-ptc/client`. Both entries exclude Host service declarations. Host policy extensions use `import type` from the package entry for `PtcDispatchLog` and `tools/ptc-dispatch-log` without mounting the executor.
@@ -38,6 +38,8 @@ kind: "package-reference"
`maxSubCallsPerMinute` 默认值为 `1024`,必须是正整数。每次 `run_code` 的工具调用额度为 `floor(最终 timeoutMs / 60000 × maxSubCallsPerMinute)`:Node 默认超时为两分钟,因此允许 2048 次。计算前先应用运行时默认值和超时上限;没有截止时间时,调用额度也没有有限上限。这是总额度,不是滑动窗口,因此可以集中调用。所有工具绑定共用计数,排队调用、无效参数和失败调用也计入。达到上限后,下一次尝试会通过运行时取消路径终止整个程序,取消进行中的子调用,并放弃排队调用,然后返回 `CODE_RUN_FAILED`。与超时一样,捕获绑定错误也不能让程序继续运行;运行时保留的状态会被丢弃。已完成的工具操作仍然生效,新的程序重新计数。
自定义 `PtcRuntime` 提供方可以报告 `language: 'typescript'` 或 `language: 'python'`。本执行器生成匹配的 SDK 与工具 schema;提供方负责执行。Python 渲染器继续供外部提供方使用,不依赖仓库提供哪些运行时包。
本包将 `ctx.ptcRuntime` 和 `ctx.systemPrompt` 声明为必需注入;带 Agent 的程序要求 `ctx.workingDirectory`。执行器在运行时可用后才激活,并在运行时卸载时撤回。启用 PTC 执行器但未提供运行时会阻止应用启动。已撤回的 PTC 选择不会回退到原生执行。
共享分派事件与 `ptc-mode` 消息来源声明位于 `@deepseek-ai/dsh-tool-executor-ptc/types`;Client 代码通过 `@deepseek-ai/dsh-tool-executor-ptc/client` 导入同一组声明。两个入口都不引入 Host 服务声明。Host 策略扩展通过包主入口的 `import type` 获取 `PtcDispatchLog` 与 `tools/ptc-dispatch-log`,无需挂载执行器。
+2 -2
View File
@@ -9,8 +9,8 @@
en: d487c8e1301e1d5a
zh: a03fbc7abe89f9f8
/ptc-runtime-ptc-execution-capability-family/summary:
en: a51c702e3930c51a
zh: 3f9a2b131a319b71
en: 5259e0b7e5f658d6
zh: fe878b0a364581a5
/ptc-runtime-ptc-execution-capability-family/table-of-contents:
en: 1eb35b015a6c423f
zh: a8a3dceee2c9e943
+1 -1
View File
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
## Summary
The `ptc-runtime/` group executes model programs against host-provided async functions. Node evaluates async function bodies, REPL statements or VM Scripts under the configured file policy. Async function bodies use fresh processes; REPL mode retains one process per explicit state owner; Script retention is optional through `scriptPersistence`. Memory ends with the process or owner. The experimental Python backend uses a fresh CPython process. Failures return as results for callers to diagnose or present to the model.
The `ptc-runtime/` group executes model programs against host-provided async functions. Node evaluates async function bodies, REPL statements or VM Scripts under the configured file policy. Async function bodies use fresh processes; REPL mode retains one process per explicit state owner; Script retention is optional through `scriptPersistence`. Memory ends with the process or owner. Failures return as results for callers to diagnose or present to the model.
## Table of Contents
+1 -1
View File
@@ -9,7 +9,7 @@ kind: "package-group"
## 概述
`ptc-runtime/` 分组执行调用宿主异步函数的模型程序。Node 按配置的文件策略求值异步函数体、REPL 语句或 VM Script。异步函数体使用新进程;REPL 模式为每个显式状态所有者保留一个进程;Script 通过 `scriptPersistence` 可选保留状态。进程或所有者结束时内存消失。实验性 Python 后端使用新的 CPython 进程。失败作为结果返回,供调用方诊断或交给模型处理。
`ptc-runtime/` 分组执行调用宿主异步函数的模型程序。Node 按配置的文件策略求值异步函数体、REPL 语句或 VM Script。异步函数体使用新进程;REPL 模式为每个显式状态所有者保留一个进程;Script 通过 `scriptPersistence` 可选保留状态。进程或所有者结束时内存消失。失败作为结果返回,供调用方诊断或交给模型处理。
## 目录
@@ -14,12 +14,8 @@ export function validateBindings(request: PtcRunRequest): Map<string, PtcBinding
if (!IDENTIFIER.test(namespace.global) || PORTABLE_RESERVED_WORDS.has(namespace.global)) {
throw new Error(`dsh-ptc-runtime-node: binding global ${JSON.stringify(namespace.global)} is not a usable identifier`)
}
// RESERVED_BINDING_GLOBALS is the seam's shared backend-owned set:
// `inspect` and `console` are this backend's output slots; the dunder entries exist
// for the Python side — its seeded/wrapped slots plus the `__debug__`
// compile-time constant — refused here too so the namespace list stays
// portable across backends. The seam declaration is the single home for
// why each entry is reserved.
// Shared exclusions keep binding declarations portable across the SDK's
// supported languages, including externally supplied Python runtimes.
if (RESERVED_BINDING_GLOBALS.has(namespace.global)) {
throw new Error(`dsh-ptc-runtime-node: reserved binding global ${JSON.stringify(namespace.global)}`)
}
@@ -57,8 +57,8 @@
en: 40294c1c31b74824
zh: 081cebc2e2650f03
/deepseek-ai-dsh-ptc-runtime/known-limitations-and-deferred-work:
en: 751969896e53743d
zh: b66d61ebd4870ad0
en: 11bf73cc8d315c8b
zh: cf31f6b353584241
/deepseek-ai-dsh-ptc-runtime/known-limitations-and-deferred-work/dev-note:
en: d56846da29ad869c
zh: 0397151a7e29b8ba
+1 -1
View File
@@ -134,7 +134,7 @@ These limits define what the seam cannot do; they are current package constraint
- **`run()` is one-shot** — `output` arrives only on the resolved `PtcRunResult`; the seam exposes no streaming-log or progress API for a live program's output.
- **Retained memory is disposable**: providers may keep state for an explicit owner; restart, release, and provider-specific failures discard it. Programs, binding calls and results remain logged by consumers; live objects are neither serialized nor replayed.
- **Providers have different confinement capabilities** — the shipped Node provider enforces a resolved file policy, while the private experimental Python provider rejects an explicit policy. No container provider is supplied.
- **No container provider is supplied** — the shipped Node provider enforces the resolved file policy through the composed sandbox backend.
- **No uniform binding byte cap applies across providers** — each provider owns its transport limits; a binding can still allocate memory before its result reaches those limits.
<a id="dev-note"></a>
@@ -134,7 +134,7 @@ binding-global 与 error-class 名称是语言可移植的:必须匹配标识
- **`run()` 是一次性的**——`output` 只有在 `PtcRunResult` resolve 后才能获得;seam 不提供正在运行的程序所产生输出的流式日志或进度接口。
- **保留内存可以丢失**:提供方可以为显式所有者保留状态;重启、释放以及提供方指定的失败会清除状态。程序、绑定调用和结果仍由消费者记录;运行中的对象不会被序列化或回放。
- **提供方的约束能力不同**——已发布 Node 提供方强制执行已解析文件策略,私有实验性 Python 提供方拒绝显式策略。不提供容器提供方。
- **不提供容器提供方**——已发布 Node 提供方通过组合的沙箱后端强制执行已解析文件策略。
- **提供方之间没有统一的绑定字节上限**——各提供方负责自己的传输限制;绑定仍可能在结果到达这些限制前分配内存。
<a id="dev-note"></a>
+14 -25
View File
@@ -25,24 +25,15 @@ export type {
} from './types.ts'
/**
* Binding globals EVERY backend refuses because SOME backend owns the slot in
* the program's namespace: `console` and `inspect` (Node's output bindings),
* `Image` (Node's program image class), and
* `__dsh_main__`/`__builtins__`/`__name__` (the Python backend's bootstrap
* wrapper and seeded module globals),
* and `__debug__`. One shared set — rather than each backend refusing only its
* own slots — keeps the portability promise real: a namespace list valid on
* one backend is valid on all, so a caller cannot pick a name that works on
* Node and collides on Python (or vice versa). `__name__` et al. ARE
* valid portable identifiers, so the identifier rule on
* `PtcBindingNamespace.global` never rejects them — hence this explicit set.
* (Error members differ: {@link DUNDER_MEMBER} refuses every dunder form
* wholesale; binding globals refuse only the names listed here.) `__debug__`
* is listed for a different reason than a collision: CPython compiles a bare
* `__debug__` reference to the constant `True` and rejects any assignment to
* the name at COMPILE time, so an injected global under that name is
* unreachable from the program — accepted by validation, unusable on the
* Python backend, which is exactly the split the shared set exists to prevent.
* Globals reserved by the language-portable binding contract, independently of
* the installed provider. Node uses `console`, `inspect`, and `Image` for output.
* Python presentation reserves `__dsh_main__` for a program wrapper and
* `__builtins__`/`__name__` for module globals; Python also rejects assignment to
* `__debug__` at compile time. The executor supports externally supplied Python
* runtimes, so every provider enforces the same exclusions. A namespace list
* valid for one provider remains valid when the runtime language changes.
* Binding globals reserve only these listed names; error members reject every
* dunder form through {@link DUNDER_MEMBER}.
*/
export const RESERVED_BINDING_GLOBALS: ReadonlySet<string> = new Set([
'console', 'inspect', 'Image',
@@ -71,13 +62,11 @@ export const RESERVED_ERROR_MEMBERS: ReadonlySet<string> = new Set([
export const DUNDER_MEMBER = /^__.+__$/
/**
* Reserved words of every portable target language (ECMAScript ∪ Python),
* refused as {@link PtcBindingNamespace.global} / error-class names by all
* backends. The portable-identifier contract
* promises a namespace list valid on one backend is valid on every backend; a
* per-language check would let `lambda` pass the TypeScript backend and fail
* the Python one. Extending the seam with a new language means widening this
* union (a breaking review of existing binding names, by design).
* ECMAScript and Python reserved words, rejected for binding globals and error
* class names by every provider. The executor presents both languages, including
* externally supplied Python runtimes. A shared set keeps namespace declarations
* portable: `lambda` is rejected even by a TypeScript provider. Adding another
* language requires reviewing this union against existing binding names.
*/
export const PORTABLE_RESERVED_WORDS: ReadonlySet<string> = new Set([
// ECMAScript reserved words and reserved-in-strict-mode names.