Skip to content

feat(ptc): support Python through a unified script runtime - #3635

Open
Raing5Days wants to merge 2 commits into
GCWing:mainfrom
Raing5Days:feat/ptc-python
Open

Raing5Days wants to merge 2 commits into
GCWing:mainfrom
Raing5Days:feat/ptc-python

Conversation

@Raing5Days

Copy link
Copy Markdown
Contributor

Summary

Closes #3625

  • 为 RunCode 增加可选 language: "python",未指定语言仍默认执行 TypeScript。
  • 将 Node 和 Python 后端统一到 ScriptPtcRuntime,共享工具 RPC、超时、输出限制及进程树取消;保留 NodePtcRuntime 兼容别名。
  • 增加 Python 异步工具绑定、并发调用、延迟工具 schema、UTF-8 日志和 JSON 返回值,并同步设置文案、能力目录和使用说明。

Type and Areas

Type: Feature / refactor / test / docs

Areas: Rust services、Core 工具管线、tool contracts、Desktop 文档、Web UI 国际化与能力目录。

Motivation / Impact

Python PTC 不再依赖 Node.js,可使用 CPython 3.8+ 编写异步函数体,通过 await tools.Name({...})、tools[name]({...}) 和 asyncio.gather 调用工具。TypeScript 仍要求 Node.js 22.6+,旧请求与配置无需迁移。

Verification

以下命令已在本地 Windows 执行通过:

  • cargo test --locked -p openbitfun-services-integrations --no-default-features --features ptc-runtime,remote-ssh-concrete --lib ptc_runtime::tests:: -- --nocapture — 15 passed,无解释器缺失跳过;覆盖 Python 并发、延迟工具、异常、UTF-8、输出限制、CPU-bound 超时、取消、权限拒绝、未完成嵌套调用清理、离线 SSH 不回退本机及 Node 回归。
  • cargo test --locked -p openbitfun-agent-tools --no-default-features --lib ptc::tests:: — 10 passed。
  • cargo test --locked -p openbitfun-core --no-default-features --features ptc-runtime --lib agentic::tools::product_runtime:: — 39 passed。
  • cargo test --locked -p openbitfun-core --no-default-features --features ptc-runtime --lib ptc_ — 10 passed,包含默认 TypeScript / Python 完整工具管线与旧请求兼容性。
  • pnpm run fmt:rs — passed。
  • node scripts/check-core-boundaries.mjs — passed。
  • node scripts/check-repo-hygiene.mjs — passed(未运行整个 repo-hygiene umbrella)。
  • pnpm run capabilities:generate / pnpm run capabilities:check — passed。
  • pnpm run i18n:audit — passed,0 warnings;通过 NODE_PATH 复用相邻工作区已安装的依赖,未修改依赖或锁文件。
  • git diff --cached --check — passed。

未执行 Desktop GUI、真实 SSH、Peer Device、Remote Control 或 Detached Dispatch 端到端验证。远程验证仅覆盖 SSH launcher 编译和离线目标不得回退本机的契约测试,不将本地测试视为远程行为证明。

Reviewer Notes

  • 运行时安装在实际执行主机,SSH 工作区仅在目标端探测和启动解释器;缺失解释器返回明确错误,不回退本机或切换语言。
  • 子工具调用继续走既有宿主权限管线;程序结束、超时或取消后清理未完成的嵌套调用。
  • 进程监督提供故障隔离,不是 OS 沙箱。Python 直接导入、文件系统和网络访问不经过工具权限,不应运行不可信脚本;没有新增 CPU/内存硬限额承诺。
  • 延迟工具响应保留 typescript_sdk,新增 input_schema / output_schema;未变更持久化配置形状。
  • 能力生成物仅包含相关文案及其 catalog digest 更新。

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Generated with OpenBitFun

@Raing5Days
Raing5Days marked this pull request as ready for review October 30, 2026 13:42
@GCWing
GCWing requested a review from wsp1911 October 31, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: PTC 程序调用工具缺少python

1 participant