Files
deepseek-harness/docs/subsystems/computer-use.md
T
Yichen Jiang 94d7eb2045 Merge remote-tracking branch 'origin/master' into feat/cua-mcp
master renamed the macOS Computer Use provider to @deepseek-ai/dsh-cua-macos
(#8284) and moved identity construction to brandString (#8214).

Adapted to master:
- The cua-mcp profile mounts @deepseek-ai/dsh-cua-macos and declares it as the
  optional dependency; the bundle test follows the new name.
- The MCP adapter builds its Session and tool-call ids with brandString, so
  @deepseek-ai/dsh-brand becomes a runtime dependency of the package.

Conflicts:
- scripts/experimental-package-policy.ts and scripts/release/families.spec.ts:
  both sides added a row; the cua-macos, cua-mcp, and cua-windows rows coexist.
- scripts/package-dependency-policy.ts: took master's removal of the SessionId
  safe entry. longEdgeDimensions no longer sits in the safe-export list; it
  joins the existing peer-required @deepseek-ai/dsh-attachment entry, so this
  branch adds no safe-export exception.
- Generated catalogs, module graphs, and the dsh-doc package reference: took
  master and regenerated.
- Four translation pairing records: took master and re-recorded after
  reviewing both language diffs.
2026-11-11 16:31:58 +08:00

11 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 is an optional experimental bundle for macOS and Windows.

Both native providers use the shared CUA library to check configured and saved application grants. When a decision is needed, the library asks the user through User Questions.

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 windows, with the helper’s name and path when available. macOS includes permission checks, numeric helper and parent PIDs, and responsible-application metadata when available (falling back to the helper’s own bundle); Windows includes desktop lock, capture availability and elevation status, and omits the helper PID.
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 that composes the standalone cua-mcp profile; a profile manifest that selects it alone is the whole setup. dsh --profile cua-mcp serves cua_get_api_reference, 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. 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. The Computer Use bundle selects the native provider for the host platform. Custom compositions can also mount a provider directly.

Provider Runtime
macOS CUA Swift helper using macOS Accessibility
Windows CUA .NET helper using Windows UI Automation
Cua Driver MCP An already installed cua-driver executable connected through MCP
Cua Driver native The platform-native runtime installed with the npm dependency

The two Cua Driver providers are public experimental npm packages. Mount one explicitly to expose 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