Files
deepseek-harness/docs/subsystems/computer-use.md
T
Yichen Jiang 7ed4b56940 feat(cua): serve Computer Use to MCP clients from the cua-mcp profile
Add @deepseek-ai/dsh-cua-mcp, an experimental optional bundle whose
profile frontend serves cua_run_code and cua_reset over MCP stdio to
Codex, Claude Code, and other harnesses. One connection owns one Agent;
programs run through ctx.tools.execute without a model step, the first
result carries the cua API reference, and screenshots are delivered as
the request version the program observed. DSH_CUA_CONSENT selects
unattended approval or client elicitation; --print-client-config renders
the client entry for the exact installation.

Supporting changes: dsh-cua gains a configured screenshotTarget and the
ctx.cuaPrograms reset/screenshot-target service, the PTC program-tool
factory exposes createRunCodeToolHandle with reset control, and dsh
plugin gains manifest-only enable/disable verbs for installed bundles.
2026-11-09 22:52:07 +08:00

10 KiB
Raw Blame History

Computer use

English | 中文

Computer use lets a model observe and operate the local desktop through a configured provider. The shared DSH capability is called computer use; Cua Driver names the upstream implementation.

Computer Use provides an optional experimental switch for macOS CUA permission setup.

The macOS CUA provider uses the shared CUA objects and executor, which enforce application consent through User Questions and profile configuration.

The CUA provider owns ctx.cuaAccess for system-permission status, explicit system requests, and application revocation. Its permission page projects these controls; app/window operations enforce the provider's consent policy before dispatch.

Permission type Meaning
CuaApplicationId, CuaApplicationGrant A platform-provided application identity and its displayed saved decision.
CuaSystemPermission Accessibility or Screen Recording, selected by the human.
CuaPermissionProcess, CuaSystemPermissionState Native access observations tagged darwin or win32, with helper process identity. macOS includes permission checks, parent identity and responsible-application metadata when available (falling back to the helper’s own bundle); Windows includes desktop lock, capture availability and elevation status.
CuaApplicationState Saved grants, refused applications, and whether persistence is available. Session-only grants remain internal to the provider. System observations and application icons are queried separately so the page can display each result as it arrives.

The shared object API uses connectCua to select an application, then app.getWindows() and app.getWindow(windowId) to select a window for screenshots and pointer input. Accessibility operations use element IDs from the latest tree for that application handle. Providers declare keyboard scopes and application-level accessibility in getCapabilities().

Serve Computer Use to another harness

Computer use MCP server is a shipped optional bundle for the cua-mcp profile. dsh --profile cua-mcp serves cua_run_code and cua_reset to one MCP client such as Codex or Claude Code; each connection owns one Agent whose programs retain application and window objects, and consent is granted unattended or forwarded to the client as an elicitation. dsh --profile cua-mcp --print-client-config codex|claude-code|json prints the client configuration. The profile runs no model turn and records no root tool calls in its Session.

Choose a provider

Mount dsh-computer-use and one provider in the same composition. Both Cua Driver providers are experimental public npm packages and require explicit activation.

Provider Runtime
Cua Driver MCP An already installed cua-driver executable connected through MCP
Cua Driver native The platform-native runtime installed with the npm dependency

Each provider supplies its upstream tool catalog. The shared service registers only a name and rejects any second provider, including another instance with the same name. It has no common desktop-operation methods or model-controlled selector.

Lifetime and desktop sharing

A provider retains its registration while it shuts down its tools and owned resources. Startup failure releases the attempted registration. The MCP provider keeps its registration during reconnects.

One registered provider does not reserve a desktop for a Session. Callers coordinate complete observe, act, and verify workflows across Sessions and separate DSH processes. A cancelled call cannot undo input that the desktop already received.

Results and platform requirements

Tools use the normal execution pipeline and Session log. Image-capable model routes with an attachment store receive durable screenshots; unsupported image routes receive the existing MCP image diagnostic. Provider READMEs own installation, permission, and platform limitations.

The decision record explains the registration-only service and the two Cua Driver integrations.

Cordis API

Generated from source by scripts/gen-cordis-catalog.ts (verified fresh by pnpm run verify-cordis-catalog in doc-sync; regenerate with pnpm run gen-cordis-catalog) — the language sides differ only in locale-specific paired document paths. Signature blocks use a ts cordis-catalog fence and keep the original source JSDoc; dispatch modes are defined in the primer, and the framework-inherited ctx API lives in cordis-api/inherited.md.

ctx.computerUse — ComputerUseRegistry

Owns one optional provider registration in the shared computer-use service.

/**
 * Reserve the sole provider slot until the contribution is disposed.
 * A second registration fails even when it repeats the current name. Providers
 * must stop their tools and await owned work before releasing this registration.
 * @param name - provider-owned name used in registration diagnostics.
 * @returns the effect disposer for this exact registration.
 */
register(name: ComputerUseProviderName): () => Promise<void>

Source: packages/computer-use/computer-use/src/index.ts

ctx.cuaAccess — CuaAccess

Browser controls for provider-owned native permission and application decisions.

/** Read PTC execution state separately from native permission checks.
 * @returns Whether the shared runtime retains memory and has an editable profile entry.
 */
@Remote ptcConfiguration(): { persistent: boolean; writable: boolean }

/** Persist in-memory PTC execution through the existing profile editor and Loader lifecycle.
 * @returns Completion after the shared runtime reload; already-persistent runtimes are left intact.
 */
@Remote async enablePersistentPtc(): Promise<void>

/**
 * Read fresh stored application decisions without issuing a native request.
 * @returns Saved grants, refused applications and durable-storage availability.
 */
@Remote applications(): Promise<CuaApplicationState>

/**
 * Inspect system privileges independently of application decisions and icons.
 * @returns Platform-tagged access observations and native process metadata.
 */
@Remote async systemStatus(): Promise<CuaSystemPermissionState>

/**
 * Load presentation icons separately from application decisions.
 * @returns Optional native PNG icons keyed by executable path; applications without paths are skipped.
 */
@Remote async applicationIcons(): Promise<Record<string, string>>

/**
 * Request the selected system privilege through the native provider.
 * @param permission macOS privilege to request.
 * @param locale Current Client language for provider-owned permission UI.
 * @returns Current permission observations; requesting does not establish consent.
 */
@Remote async requestPermission(permission: CuaSystemPermission, locale: string): Promise<CuaSystemPermissionState>

/**
 * Open the macOS privacy pane selected by the user.
 * @param permission Corresponding system privilege.
 * @param locale Current Client language for provider-owned recovery instructions.
 * @returns Completion after macOS accepted the open request.
 */
@Remote async openSettings(permission: CuaSystemPermission, locale: string): Promise<void>

/**
 * Remove saved and session access and join affected operations.
 * @param id Application identity displayed on the permission page.
 * @returns Completion after persistence and cancellation; dispatched input cannot be undone.
 */
@Remote revoke(id: CuaApplicationId): Promise<void>

/**
 * Clear this application's refusals across sessions so each session may ask for access again.
 * @param id Refused or revoked application displayed on the permission page.
 * @returns Completion after clearing refusals; no permission is granted and no action is replayed.
 */
@Remote async retryApproval(id: CuaApplicationId): Promise<void>

Source: packages/experimental/cua/src/access.ts

ctx.cuaPrograms — CuaPrograms

Host control over the dedicated cua_run_code environments; registered as ctx.cuaPrograms.

/**
 * Release one Agent's retained program environment. Active programs of that Agent are cancelled, new
 * programs wait for cleanup, and the next `cua_run_code` call starts a fresh process that re-creates the
 * `cua` global; application grants, native connections, and the desktop applications themselves are
 * unaffected. Resolves when no environment exists.
 * @param agent - Agent whose `cua_run_code` state owner is released.
 * @returns Completion after the process and its nested-call cleanup settle.
 * @throws CodeResetFailedError when cleanup fails; programs stay blocked until a later reset succeeds.
 */
reset(agent: Agent): Promise<void>

/**
 * Request-image target the provider delivered for a stored screenshot when `screenshotTarget` is configured.
 * A host that forwards screenshots outside a model request reads the same request version with it, so the
 * image a caller sees matches the coordinate space the provider mapped.
 * @param image - Durable screenshot attachment from a `cua` result.
 * @returns The fixed target, or undefined when the Agent's model route selects the delivered version.
 */
screenshotRequestTarget(image: ImageAttachmentRef): ImageRequestTarget | undefined

Types: Agent · ImageAttachmentRef · ImageRequestTarget

Source: packages/experimental/cua/src/tool-registration.ts