DSH / Atlas
2026-11-09implementedarchitecture

CUA programs outside the PTC preset

PTC preset 之外的 CUA 程序

Computer Use needs reusable application and window objects in Standard and other presets without changing their ordinary tool calls or requiring users to change the profile's PTC runtime. Experimental CUA packages cannot appear in shipped preset definitions. Program dispatch must retain the same permission checks, cancellation, nested logs, and screenshots as PTC.

English

Problem

Computer Use needs reusable application and window objects in Standard and other presets without changing their ordinary tool calls or requiring users to change the profile's PTC runtime. Experimental CUA packages cannot appear in shipped preset definitions. Program dispatch must retain the same permission checks, cancellation, nested logs, and screenshots as PTC.

Decision

CUA keeps agentPreset: ptc as the default selector for its raw cua tool. Every other composed preset receives cua_run_code. Agents without a composed preset receive it as well; CUA program tool for Agents without a preset supersedes their original exclusion. agentPreset: false retains global raw-tool registration. A base owner uses Agent scopes for registration and disposal, so enabling and disabling the provider affects existing and later Agents without editing presets. Raw registration depends only on base CUA services and preset selection. The private program producer publishes and withdraws its PTC registry by identity; private dependency loss or startup failure leaves raw tools and prompts available.

cua_run_code is the entry of a private PtcToolRegistry that each program-mode Agent's scope includes. The registry runs programs on one isolated Node persistent-in-memory runtime owned by the CUA provider; the PTC root and this tool share the PtcToolRegistry implementation (composable tool registries). Agent stateOwner identities select separate retained processes. Its only binding is the private tools.cua definition; the model calls ordinary session tools directly. Nested CUA operations retain tool policy, guards, dispatch events, and image admission. Programs select text and screenshots through inspect(...values), following the explicit output decision. The provider releases held keys when either program tool settles. Provider unload drains its own CUA programs before native teardown; releasing input held by other PTC programs does not wait for their unrelated work. State is in memory, separate from the profile's PTC state, and released with its Agent or provider.

CUA registers a source program through registerEnvironmentInitializer before its isolated runtime admits a run. Each new environment evaluates it once after installing current bindings, including temporary escalated environments. The child awaits Host acceptance before starting model code. Initialization shares the first run's time and output budgets; failure discards the environment and prevents model execution without rolling back external effects. Separate evaluation preserves model source locations. An initializer-owning scope depends only on the runtime, so program-tool dependency reloads retain the registration. PTC keeps its explicit bridge initialization.

This partially supersedes the exclusion of a CUA program entry in native CUA objects. That note still owns the object API's independence from an evaluator and the split between shared objects and native operations. The shared Node provider owns evaluation; CUA supplies its restricted bindings and initialization. The optional bundle decision still owns delivery and activation.

Alternatives considered

A CUA-specific evaluator duplicates execution lifecycle policy. Reusing the PTC registry and runtime keeps cancellation, limits, sandboxing, and result handling with their existing owners.

The profile's shared runtime couples CUA state to unrelated PTC and workflow settings. A per-call mode selected there cannot retain objects. A separate CUA runtime preserves the profile's chosen execution mode.

Global registration of both tool forms exposes a program runner inside PTC programs and exposes raw CUA calls to other presets. Selecting one form per Agent keeps each mode's intended tool list. Binding every session tool inside cua_run_code would duplicate ordinary direct calls and their declarations.

Prepending initialization to model code shifts source locations. Running initialization as a separate tool call fails for temporary escalated environments because the next call starts another process. A separate program within the first runtime execution supports both retained and temporary environments. Passing initialization with every program couples environment setup to tool requests and repeats work in existing environments; registration keeps setup and cleanup with the runtime owner.

Consequences

CUA adds no preset list or shipped preset dependency. Preset IDs select the tool form; custom PTC presets must match agentPreset. PTC and CUA share the public PtcToolRegistry; CUA owns a runtime initializer registration and drains its program tools before unregistering it. Older custom Node bootstraps require the matching protocol revision, as described in the upgrade guide.

The private binding limits callable Harness tools, not Node APIs. File and process access still follow the selected sandbox policy. Retained variables do not reserve applications or survive process loss; callers recreate objects and observe state before continuing. Composition and recorded-session tests cover tool selection, automatic initialization, retained state, nested output, and removal; native fixtures remain responsible for platform input behavior.

中文

问题

Computer Use 需要在标准及其他 preset 中复用应用和窗口对象,同时保留普通工具的调用方式,也不要求用户更改 profile 的 PTC 运行时。实验性 CUA 包不能出现在随产品提供的 preset 定义中。程序派发必须保留与 PTC 相同的权限检查、取消、嵌套日志和截图行为。

决策

CUA 保留 agentPreset: ptc,用默认选择器指定获得原始 cua 工具的 preset。其他已组合的 preset 获得 cua_run_code。未组合 preset 的 agent(智能体)也获得该工具;未组合 preset 的 Agent 使用 CUA 程序工具取代了原先不为它们注册工具的决定。agentPreset: false 保留全局原始工具注册。基础注册的所有者通过 Agent 作用域管理注册和销毁,因此启停提供方会影响已有和后续 Agent,无需修改 preset。原始工具的注册只依赖基础 CUA 服务和 preset 选择。私有程序工具的提供方按对象身份发布和撤回其 PTC 注册表;私有依赖缺失或启动失败时,原始工具和提示词仍然可用。

cua_run_code 是一个私有 PtcToolRegistry 的程序入口,每个程序模式 Agent 的作用域都引入该注册表。该注册表在 CUA 提供方持有的单个隔离 Node persistent-in-memory 运行时上运行程序;PTC 根注册表与该工具共用 PtcToolRegistry 实现(可组合的工具注册表)。Agent 的 stateOwner 身份选择各自独立的保留进程。它只绑定私有 tools.cua 定义;模型直接调用其他普通会话工具。嵌套 CUA 操作保留工具策略、guard、派发事件和图像接纳。程序通过 inspect(...values) 选择文字和截图,遵循显式输出决策。任一程序工具结束时,提供方都会释放该程序仍按住的键。提供方卸载时,先等待自己持有的 CUA 程序结束再清理原生资源;释放其他 PTC 程序持有的输入时,不等待这些程序中的其他工作。状态保存在内存中,独立于 profile 的 PTC 状态,随所属 Agent 或提供方释放。

CUA 在隔离运行时首次接纳运行前,通过 registerEnvironmentInitializer 注册一段源码。每个新环境安装本次绑定后执行该程序一次,包括临时提权环境。子进程等待 Host 确认后才开始执行模型代码。初始化与首次运行共享时间和输出预算;失败会丢弃环境并阻止模型代码执行,但不回滚外部效果。独立求值保留模型源码位置。初始化程序所属的作用域只依赖运行时,因此程序工具的依赖重载时仍保留这项注册。PTC 保留显式 bridge 初始化。

这部分取代原生 CUA 对象中不提供 CUA 程序入口的决定。原记录继续负责对象 API 独立于求值器,以及共享对象与原生操作之间的职责划分。共享 Node 提供方负责求值,CUA 提供受限的绑定和初始化。可选组合包决策继续负责分发和启用方式。

考虑过的替代方案

CUA 专用求值器会重复实现执行生命周期策略。复用 PTC 注册表和运行时,使取消、限制、沙箱和结果处理继续由现有实现负责。

profile 的共享运行时会使 CUA 状态依赖无关的 PTC 和工作流设置。在那里选择的逐次调用模式无法保留对象。独立的 CUA 运行时保留 profile 选定的执行模式。

全局注册两种工具形态会在 PTC 程序中暴露另一个程序执行器,并向其他 preset 暴露原始 CUA 调用。按 Agent 选择一种形态,可以保留各模式预期的工具列表。在 cua_run_code 内绑定所有会话工具,会重复普通的直接调用及其声明。

把初始化拼到模型代码前会偏移源码位置。通过单独的工具调用执行初始化无法适用于临时提权环境,因为下次调用会启动另一个进程。首次运行时执行中的独立程序同时支持保留环境和临时环境。每次提交程序都传入初始化,会使环境准备依赖工具请求,并在已有环境中重复执行;注册使准备和清理继续由运行时所有者负责。

后果

CUA 不增加 preset 列表,也不向内置 preset 添加依赖。工具形态按 preset ID 选择;自定义 PTC preset 必须与 agentPreset 匹配。PTC 与 CUA 共享公开的 PtcToolRegistry;CUA 拥有运行时初始化程序的注册,注销前会等待自己的程序工具执行结束。旧版自定义 Node bootstrap 需要匹配协议版本,详见升级指南。

私有绑定限制可调用的 Harness 工具,不限制 Node API。文件与进程访问仍遵循所选沙箱策略。保留变量不会独占应用,也不能跨进程丢失保留;调用方应重建对象并观察状态后再继续。组合测试和已记录会话测试覆盖工具选择、自动初始化、状态保留、嵌套输出及移除;平台输入行为仍由原生 fixture(测试前置数据)负责验证。