Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
docs(adr): scope computer use to an agent-driven MVP
vastsafba9dd4fee1b
diff --git a/docs/adr/0340-os-computer-use-capability.md b/docs/adr/0340-os-computer-use-capability.mdindex 8f163c6e0..c640e9922 100644--- a/docs/adr/0340-os-computer-use-capability.md+++ b/docs/adr/0340-os-computer-use-capability.md@@ -1,7 +1,8 @@# ADR 0340: Built-in computer use is a host-owned capability behind a user-picked scope grant-- Status: Proposed+- Status: Accepted- Date: 2026-11-04+- Decision: D681- Deciders: PI-Desktop core- Related: [ADR 0170](0170-work-panel-browser-as-bundled-plugin.md) ·[ADR 0211](0211-plan-safe-plugin-actions.md) ·@@ -33,7 +34,9 @@ what the *MVP* would not ship; the product is now released software at `0.21.0`with a plugin permission matrix, a durable permission broker, an audit log, anda floating call surface. The request is no longer "let the model take over thebrowser" but "give the agent a bounded, revocable, auditable way to operate the-machine, and let the user ask for it out loud".+machine" — on all three desktop platforms, driven by a model the user picks,+and without ever taking the mouse out of the user's hand. The spoken entry+point is specified here and built later; the agent is the first caller.Nothing in the repository supports it today. There is no screen capture, nosynthetic input, no window enumeration, and no accessibility client on any@@ -44,34 +47,38 @@ user: it can approve dialogs, including this application's own permission cards.## Decision-1. **Computer use is a host-core capability, not a plugin, a renderer feature,- or a Live Voice feature.** `crates/host-core` gains a `computer.*` RPC domain- and owns window enumeration, accessibility inspection, event synthesis,- screen capture, the grant broker, and the audit record. Electron main keeps- exactly two jobs: it renders the host-driven target picker and the grant- indicator, and it forwards `tools.execute`. The renderer never receives a- window handle, a native element reference, or an input primitive, and the- agent sidecar reaches the capability only through the existing `host.proxy`+1. **Native authority is host-core's; the decision loop is not.** `crates/host-core`+ gains a `computer.*` RPC domain and owns target enumeration, accessibility+ inspection, event synthesis, the grant broker, the per-action re-validation,+ and the audit record — it is the only component that can refuse. The+ perceive-decide-act loop and screen capture live above it, because the loop+ needs a model provider and capture needs Chromium, and host-core carries+ neither (`05-host-core-rust` §3). The renderer never receives a window+ handle, a native element reference, or an input primitive, and the agent+ sidecar reaches the capability only through the existing `host.proxy``tools.execute` allowlist entry — no new proxy method is introduced.-2. **One high-risk builtin tool, `Computer`.** It is a builtin like `Bash`, not- a bundled-plugin tool, because its blast radius must not be expressible as a- plugin permission a plugin author can request. `computer.*` is not a public- plugin host API and is not added to the plugin permissions matrix. The tool- exposes `inspect`, `screenshot`, `act`, `wait`, and `describe_scope`; it- exposes no "list windows", no "focus application", and no "switch target".--3. **Accessibility first, pixels as an explicit fallback.** `inspect` returns a- structured tree for the granted scope — role, name, value presence, enabled,- focused, bounds, and a per-grant opaque `uid` — and `act` addresses elements- by `uid`, dispatched through the platform accessibility action where one- exists (`AXUIElement` actions, UIA patterns, AT-SPI actions). Coordinate- input exists only as `act` with a `basis`: a token minted by a `screenshot`- of the same scope, carrying the scope revision and the measured window- geometry. The host re-validates the basis immediately before synthesis and- refuses a stale one. A model can therefore never dispatch a blind click, and- a window that moved between capture and action fails closed instead of- clicking whatever took its place.+2. **One high-risk tool, `Computer`, gated by the host and executed above it.**+ It follows the `GenerateImages` shape: host-core classifies it `high`,+ `tools.execute` performs the permission evaluation, and the handler runs in+ Electron main once the host authorises. It is not a plugin tool, so its+ blast radius cannot be expressed as a permission a plugin author may+ request; `computer.*` is not a public plugin host API and is not added to+ the plugin permissions matrix. The tool takes a natural-language instruction+ plus optional explicit steps; it exposes no "list windows", no "focus+ application", and no "switch target".++3. **Accessibility first, pixels as an explicit fallback.** `computer.inspect`+ returns a structured tree for the granted scope — role, name, value+ presence, enabled, focused, bounds, and a per-grant opaque `uid` — and every+ action addresses an element by `uid`, dispatched through the platform+ accessibility action where one exists (`AXUIElement` actions, UIA patterns,+ AT-SPI actions). Capture is scope-cropped and produces a `basis`: the grant+ revision plus the measured window geometry it was taken against. Coordinate+ input exists only with a `basis`, which the host re-validates by re-measuring+ immediately before synthesis and refuses when it no longer matches. A model+ can therefore never dispatch a blind click, and a window that moved between+ capture and action fails closed instead of clicking whatever took its place.4. **A scope grant is the unit of authority, and only the user can mint one.**A grant names exactly one target — one window, or one application's windows —@@ -109,27 +116,55 @@ user: it can approve dialogs, including this application's own permission cards.like `Write` and `Edit`. It is not plan-safe: it mutates state outside theworkspace that the host cannot snapshot, diff, or roll back.-8. **Voice reaches computer use only through the path that already exists.**- Live Voice stays a voice interface with no new authority: a spoken request- becomes `delegate_to_work_session`, the classifier routes it, and the Agent- turn calls `Computer` under the target session's policy. Grant creation and- every approval card remain desktop-UI decisions, consistent with ADR 0315; a- call may *request* a grant, which surfaces in the main window while the- floating call bar reports that the app needs attention. Progress and results- are spoken through the existing work-feedback channel. Voice-driven computer- use is therefore task-level delegation, not per-frame teleoperation, and the- spec says so rather than implying a latency it cannot deliver.--9. **Supported platforms are declared, and the unsupported ones fail closed.**- macOS uses ScreenCaptureKit and `AXUIElement` behind the Screen Recording- and Accessibility TCC grants. Windows uses UI Automation and `SendInput`, and- refuses a window owned by a higher-integrity process instead of silently- dropping events. Linux/X11 is best-effort over AT-SPI and XTEST. Wayland has- no portable synthetic input, so input is refused there with an explicit code- while capture stays available through the portal. Every one of these is a- distinct error code, never a hang and never a no-op reported as success.--10. **Every grant and every action is audited; content is not.** The existing+8. **The agent is the only caller in the first release; voice comes later.**+ The spoken path is specified and deliberately not built: Live Voice would+ reach `Computer` as an ordinary work request through the existing+ delegate/classifier/Agent-turn path and would gain no authority of its own,+ but nothing in the first release wires it, and the voice feature ships+ unchanged. Grant creation and every approval card remain desktop-UI+ decisions, consistent with ADR 0315, which is also why a call could never+ mint a grant on its own.++9. **The agent's own model does not have to drive the machine.** Computer use+ carries its own model binding — one `{ providerId, modelId }` the user picks+ in settings from the existing provider rows, following the+ `imageGeneration` precedent — and a bounded perceive-decide-act loop uses+ that model to turn one instruction into validated steps. The loop is a pure+ module in `packages/computer-use`: it receives an observation (the+ accessibility tree, and a capture when the grant allows pixels), asks the+ bound model for one action against a strict schema, and refuses anything+ that is not in that schema. The main agent sees a bounded summary, not a+ step-by-step transcript of the inner loop. With no binding configured the+ tool reports a configuration error instead of silently falling back to the+ conversation model, because the user chose which model may operate their+ computer.++10. **The agent's pointer is drawn, not stolen.** Every action is dispatched+ through an accessibility action or a window-targeted event, so the real+ system cursor never warps and the user keeps their mouse and keyboard+ while the agent works. A separate frameless, transparent, click-through+ always-on-top overlay window draws a virtual cursor that travels to the+ element the agent is about to act on and shows a press when it acts. The+ overlay is visualization only: it owns no part of the action, cannot+ receive input, and a failure to draw it never blocks or silently replaces+ an action. A platform path that could only act by warping the real pointer+ is refused rather than taken.++11. **Supported platforms are declared, and the unsupported ones fail closed.**+ macOS uses `AXUIElement` behind the Accessibility TCC grant, with+ `CGEventPostToPid` for key input into the granted application only. Windows+ uses UI Automation with window-targeted messages, and refuses a window+ owned by a higher-integrity process instead of silently dropping events.+ Linux/X11 is best-effort over AT-SPI. Wayland has no portable synthetic+ input, so input is refused there with an explicit code while capture stays+ available through the portal. Capture itself is Chromium's+ `desktopCapturer`, scope-cropped in main, which is the one part of the+ capability that is already cross-platform. Every unsupported path is a+ distinct error code, never a hang and never a no-op reported as success.+ A backend whose fidelity is partial says so in its own `inspect` result+ rather than returning an empty tree that reads like an empty window.++12. **Every grant and every action is audited; content is not.** The existing`audit.*` sink records the grant identity, target identity, action kind,element role and `uid`, and outcome. Typed text is recorded as a length, nota value, and pixels are never written to the audit log. Screenshots that@@ -138,13 +173,15 @@ user: it can approve dialogs, including this application's own permission cards.grant captures no pixels at all, and the grant card states which of the twothe user is approving before they approve it.-11. **Delivery is staged, and each stage is independently shippable.** Stage 1:- host capability, grant broker, indicator, audit, `inspect`/`act` on macOS.- Stage 2: `screenshot` and basis-bound coordinate input. Stage 3: Windows- UIA, then Linux/X11. Stage 4: the voice-facing refinements — spoken grant- requests, spoken progress, and the call-bar attention state. Non-goal item 9- is amended, not deleted: unattended full-desktop takeover and any- model-chosen target remain non-goals.+13. **Delivery is staged, and each stage is independently shippable.** Stage 1+ is the MVP: contracts, the grant broker and its refusals, the macOS+ backend, the bounded loop with its own model binding, the virtual-cursor+ overlay, the picker, the indicator, settings, and audit — agent-callable,+ no voice. Stage 2 adds the Windows and Linux backends behind the same+ contract and the same refusals, each with its own dependency review and+ per-platform device acceptance. Stage 3 adds the voice-facing refinements.+ Non-goal item 9 is amended, not deleted: unattended full-desktop takeover+ and any model-chosen target remain non-goals.## Consequences@@ -154,22 +191,32 @@ user: it can approve dialogs, including this application's own permission cards.instance, and an audit trail. The two refusals in decision 5 are the ones thatmust be covered by tests before any of this ships.- host-core gains its first platform-specific native surface beyond process- spawning, and with it three per-OS implementations and new native- dependencies, against a supply-chain rule that prefers few reviewed deps. The- capability must compile to a clean "unsupported on this platform" on any- target that is not implemented yet.+ spawning, and with it three per-OS implementations. The macOS backend is+ written as hand-declared framework FFI rather than new crates, so the+ supply-chain rule that prefers few reviewed dependencies survives the first+ stage; each later backend carries its own dependency review. The capability+ must compile to a clean "unsupported on this platform" on any target that is+ not implemented yet, and a backend with partial fidelity must say so.+- The inner loop spends tokens on a model the conversation did not choose, so+ the bound model, its step count, and its cost are the user's decision and+ have to be visible: the binding is explicit in settings, the loop is bounded+ by the grant's action budget, and the tool result names how many steps ran.+- A drawn cursor is not the system cursor, so it can disagree with reality — a+ window that moves mid-step leaves the overlay briefly wrong. The overlay is+ therefore never the source of truth for where an action landed; the host's+ re-measurement is, and the overlay follows it.- The product acquires OS permission prompts it never had. A doctor view has toreport Screen Recording and Accessibility state per platform, because a deniedTCC grant is indistinguishable from a broken feature from the user's side.- Screenshots of the user's desktop can now enter a session transcript andtherefore SQLite. That is a real privacy change; `a11y-only` grants exist so auser can take the capability without it.-- Live Voice gains no code-level authority, but it does gain a reachable- consequence: a sentence spoken into a call can move a mouse. The call surface- must make the active grant visible from the floating bar.-- Four UX surfaces are added: the target picker, the grant indicator with Stop,- the grant card with its policy and capture choice, and the settings doctor.- Their component-level wording lands with the implementing change, not here.+- Live Voice is untouched in this stage. When stage 3 wires it, a sentence+ spoken into a call becomes able to move a drawn cursor, and the call surface+ will have to make the active grant visible from the floating bar.+- Five UX surfaces are added: the target picker, the grant indicator with Stop,+ the grant card with its policy and capture choice, the settings page with the+ model binding and the permission doctor, and the cursor overlay.## Alternatives@@ -194,3 +241,17 @@ user: it can approve dialogs, including this application's own permission cards.- **Let the model pick the target window.** Removes the picker friction, andwith it the only guarantee that the agent operates on what the user meant.Rejected.+- **Drive the real system pointer with `SendInput`/XTEST/`CGWarpMouseCursorPosition`.**+ It is the shortest path to "it clicks things" and works against any toolkit,+ but it fights the user for their own mouse, cannot run while they work, and+ makes a runaway loop physically hard to stop. Rejected in favour of+ accessibility actions plus a drawn cursor (decision 10).+- **Reuse the conversation model for the loop.** One less setting, and no+ second provider call, but it forces a vision-capable chat model on everyone+ and spends the conversation's context on screenshots. Rejected in favour of+ an explicit binding (decision 9).+- **Run the loop inside host-core.** It would keep one owner for the whole+ capability, but host-core deliberately holds no provider SDK and no Chromium,+ so it can neither call the bound model nor capture a window. Rejected.+- **Put the loop in the renderer, next to the overlay it drives.** The renderer+ is the one process that must never hold this authority. Rejected.diff --git a/docs/spec/03-runtime/computer-use.md b/docs/spec/03-runtime/computer-use.mdindex 5faca4eed..ef15701df 100644--- a/docs/spec/03-runtime/computer-use.md+++ b/docs/spec/03-runtime/computer-use.md@@ -1,9 +1,9 @@# Computer Use v1-> Status: Design accepted, not implemented. This page is the authoritative-> contract for the capability described in-> [ADR 0340](../../adr/0340-os-computer-use-capability.md). No code in the-> repository implements it yet.+> Status: Stage 1 (MVP) in progress. This page is the authoritative contract+> for the capability described in+> [ADR 0340](../../adr/0340-os-computer-use-capability.md). The agent is the+> only caller; the spoken entry point is specified here and built in stage 3.## Scope@@ -12,37 +12,47 @@ explicitly handed to it. It is disabled by default, it is separate from theembedded `Browser` tool, and it never operates the whole desktop at once: everycall runs against one user-picked scope.-It is reachable by voice. Live Voice remains a voice interface with no new-authority — a spoken request becomes a work request on the bound session+The spoken entry point is deliberately not wired in stage 1. When it lands,+Live Voice gains no authority of its own — a spoken request becomes a work+request on the bound session([Live Voice Work Session Integration](live-work-session.md)), the existingAgent turn calls the tool, and the session's model, permission mode, and-approval cards apply unchanged. Voice-driven computer use is task delegation,-not per-frame teleoperation; a spoken instruction is answered by an agent turn-with observable progress, not by a continuous control loop.+approval cards apply unchanged. Voice-driven computer use will be task+delegation, not per-frame teleoperation.| Surface | Owner | Reach ||---|---|---|| `Browser` tool (`pi.browser`, ADR 0170) | Bundled plugin over allowlisted CDP | The embedded `WebContentsView` guest only |-| `Computer` tool (this page) | host-core builtin | One granted native window or application |+| `Computer` tool (this page) | Electron main, gated by host-core | One granted native window or application || Live Voice | Electron main and renderer | Audio, transcript, and work delegation; no input synthesis |## Ownership and process model```text-Renderer (picker UI, indicator)- → Preload IPC → Electron Main (thin: picker, indicator, tools.execute relay)- → Rust host-core `computer.*` (windows, accessibility, synthesis, capture,- grant broker, audit)+Renderer (picker, indicator, cursor overlay)+ → Preload IPC → Electron Main+ Computer tool handler, bounded loop, bound-model call,+ scope-cropped capture, overlay driver+ → Rust host-core `computer.*`+ targets, accessibility, synthesis, grant broker, re-validation, audit```-host-core owns window enumeration, accessibility inspection, event synthesis,-screen capture, the grant broker, the action budget, and the audit record. The-renderer never receives a native window handle, a native element reference, or-an input primitive; it receives only the picker's display list and the-indicator's grant view. The agent sidecar reaches the capability exclusively-through `tools.execute` on the existing `host.proxy` allowlist — no new proxy-method is added, and `computer.*` is not a plugin host API and does not appear-in the plugin permissions matrix.+host-core owns target enumeration, accessibility inspection, event synthesis,+the grant broker, the action budget, the per-action re-validation, and the audit+record. It is the only component that can refuse. The loop and the capture sit+in Electron main because the loop needs a model provider and the capture needs+Chromium, and host-core carries neither ([05-host-core-rust](05-host-core-rust.md) §3).++The renderer never receives a native window handle, a native element reference,+or an input primitive; it receives the picker's display list, the indicator's+grant view, and the overlay's draw commands. The agent sidecar reaches the tool+exclusively through `tools.execute` on the existing `host.proxy` allowlist — no+new proxy method is added, and `computer.*` is not a plugin host API and does+not appear in the plugin permissions matrix.++`Computer` follows the `GenerateImages` shape: host-core classifies it `high`+and performs the permission evaluation through `tools.execute`, and the handler+in main runs only after the host authorises the call.## Grant and scope@@ -102,18 +112,29 @@ hard-deny it before permission evaluation, exactly like `Write` and `Edit`: itmutates state outside the workspace that the host cannot snapshot, diff, or rollback.-| Action | Risk | Behavior |+The agent calls it with one natural-language `instruction` and an optional+`maxSteps`; `observeOnly` returns a description of the scope without acting. It+takes no `uid`, no coordinate, and no target: addressing is the inner loop's+job, and the target is the grant's. The result is a bounded summary naming what+changed, how many steps ran, and why the loop stopped — not a step-by-step+transcript.++Underneath, main drives these host operations. They are not agent-facing.++| Host operation | Risk | Behavior ||---|---|---|-| `describe_scope` | low | Returns the grant view: target label, revision, policy, capture mode, remaining budget |-| `inspect` | low | Structured accessibility tree of the scope: role, name, value presence, enabled, focused, bounds, per-grant opaque `uid` |-| `screenshot` | low | Scope-cropped, downscaled image plus a `basis` token; refused under an `a11y-only` grant |-| `act` | high | One bounded batch of input addressed by `uid`, or by coordinates against a `basis` |-| `wait` | low | Bounded wait for a scope condition (element present, enabled, text changed) with an explicit timeout |+| `computer.capabilities` | low | Backend identity, fidelity, per-platform OS permission state, session type |+| `computer.listTargets` | low | Pickable windows for the picker only; refused targets are listed with their reason, never silently dropped |+| `computer.grantCreate` / `grantRevoke` / `grantDescribe` | low | Mint, revoke, and read the single active grant; minting requires the user's picker choice |+| `computer.inspect` | low | Structured accessibility tree of the scope: role, name, value presence, enabled, focused, bounds, per-grant opaque `uid`, declared fidelity |+| `computer.act` | high | One validated action addressed by `uid`, or by coordinates against a `basis`, after re-measuring the scope |-`act` supports `click`, `double_click`, `right_click`, `set_value`,+`computer.act` supports `click`, `double_click`, `right_click`, `set_value`,`press_keys`, `scroll`, and `select`. Each is dispatched through the platform-accessibility action when one exists, and falls back to synthesis only when it-does not.+accessibility action when one exists, and falls back to a window-targeted event+only when it does not. Capture is performed in main over Chromium's+`desktopCapturer`, cropped to the geometry host-core measured, and is refused+under an `a11y-only` grant.Element identity is accessibility-first. A `uid` is opaque, minted per grant,and invalidated by a revision change. `inspect` returns no element values, only@@ -123,10 +144,10 @@ effect of enumeration.### Coordinates and freshness-Coordinate input exists only as `act` with a `basis`: a token minted by a-`screenshot` of the same scope, carrying the grant revision and the measured-window geometry. The host re-validates the basis immediately before synthesis-and refuses a stale one. Therefore:+Coordinate input exists only as `computer.act` with a `basis`: the grant+revision plus the window geometry a capture of the same scope was taken+against. The host re-measures and re-validates the basis immediately before+synthesis and refuses a stale one. Therefore:- A model can never dispatch a blind click. Without a capture there is no basis,and without a basis there are no coordinates.@@ -135,6 +156,48 @@ and refuses a stale one. Therefore:- Coordinates are scope-relative and clamped to the measured window bounds. Acoordinate outside them is an error, not a clamped click.+## The bound model and the loop++Computer Use carries its own model binding — one `{ providerId, modelId }` the+user picks in settings from the existing provider rows, following the+`imageGeneration` precedent. The conversation model is not used to drive the+machine, and there is no silent fallback to it: with no binding configured the+tool reports a configuration error. The user decides which model may operate+their computer, and what that costs.++The loop is a pure module in `packages/computer-use`, independent of Electron:++1. Observe: the accessibility tree for the scope, plus a scope-cropped capture+ when the grant allows pixels, plus the grant view.+2. Decide: one request to the bound model, which must answer with exactly one+ action against a strict schema, or `done`, or `ask`.+3. Validate: the schema, then the `uid` against the current tree, the+ coordinates against the measured geometry, the grant revision, and the+ remaining budget. Anything outside the schema is a refusal, not an attempt.+4. Act: one `computer.act`, then observe again.++The loop stops on `done`, on the step limit (the call's `maxSteps` clamped by+the grant's action budget), on revocation, on expiry, or on repeated failure of+the same step. Model prose never reaches a tool result unparsed: the summary is+assembled from what the loop actually did. Nothing in the model's answer can+widen the scope, change the target, raise the budget, or disable a refusal.++## The agent's cursor is drawn, not stolen++Actions are dispatched through accessibility actions or window-targeted events,+so the real system cursor never warps. The user keeps their mouse and keyboard+while the agent works, and a platform path that could only act by warping the+real pointer is refused rather than taken.++A separate frameless, transparent, click-through, always-on-top overlay window+draws the agent's own cursor: it travels to the element about to be acted on and+shows a press when the action is dispatched. The overlay is visualization only.+It owns no part of the action, never receives input (it is created with mouse+events ignored), and a failure to draw it neither blocks an action nor stands in+for one. It is also not the source of truth for where an action landed — the+host's re-measurement is, and the overlay follows it. The overlay closes with+the grant.+## Permission flowThe permission mode governs the grant, not each keystroke.@@ -142,9 +205,9 @@ The permission mode governs the grant, not each keystroke.| Stage | `ask` | `accept-edits` | `auto` ||---|---|---|---|| Create a grant | confirm (desktop UI) | confirm (desktop UI) | confirm (desktop UI) |-| `inspect`, `screenshot`, `describe_scope` in an active grant | allow | allow | allow |-| `act` under `confirm-each` | confirm per batch | confirm per batch | confirm per batch |-| `act` under `autonomous-in-scope` | unavailable | allow | allow |+| Inspect, capture, and describe the scope in an active grant | allow | allow | allow |+| An input action under `confirm-each` | confirm per step | confirm per step | confirm per step |+| An input action under `autonomous-in-scope` | unavailable | allow | allow || Plan / Goal | hard deny | hard deny | hard deny |`confirm-each` is the default and the only input policy available under `ask`.@@ -156,37 +219,48 @@ outlive the target it was approved for.## Platform support-| Platform | Inspection and input | Capture | Notes |-|---|---|---|---|-| macOS | `AXUIElement` behind the Accessibility TCC grant | ScreenCaptureKit behind the Screen Recording TCC grant | Secure input state refuses both |-| Windows | UI Automation plus `SendInput` | Desktop Duplication / window capture | A window owned by a higher-integrity process is refused, never silently dropped |-| Linux / X11 | AT-SPI plus XTEST, best effort | X11 capture | Requires an accessibility bus; absent toolkit support is reported, not guessed |-| Linux / Wayland | Input refused | Portal screen cast | No portable synthetic input exists; capture stays available |+All three desktop platforms are in scope. Capture is the same everywhere —+Chromium's `desktopCapturer`, cropped in main to the geometry host-core+measured — so only inspection and input are platform work.-Any platform or stage that is not implemented reports an explicit unsupported-code. A missing capability is never a hang and never a no-op reported as-success.+| Platform | Inspection and input | Stage | Notes |+|---|---|---|---|+| macOS | `AXUIElement` actions behind the Accessibility TCC grant; `CGEventPostToPid` for keys into the granted app | 1 | Hand-declared framework FFI, no new crates; secure input refuses both capture and input |+| Windows | UI Automation patterns, with window-targeted messages as the fallback | 2 | A window owned by a higher-integrity process is refused, never silently dropped |+| Linux / X11 | AT-SPI actions, best effort | 2 | Requires an accessibility bus; absent toolkit support is reported, not guessed |+| Linux / Wayland | Input refused | — | No portable synthetic input exists; capture stays available through the portal |++A platform whose backend is not built yet reports+`COMPUTER_PLATFORM_UNSUPPORTED` from every operation that would need it, and+`computer.capabilities` says so before the user tries. A backend whose fidelity+is partial declares that in its `inspect` result rather than returning an empty+tree that reads like an empty window. A missing capability is never a hang and+never a no-op reported as success.## Settings and UX surface- Computer Use is off by default. Enabling it does not create a grant, requestan OS permission, capture a frame, or enumerate a window.-- A doctor view reports per-platform OS permission state (Screen Recording,- Accessibility, accessibility bus, session type) and distinguishes "not- requested", "denied", and "unsupported on this platform". A denied TCC grant- must not be presented as a broken feature.+- The model binding is explicit. Settings offers the provider rows the user+ already configured; an enabled feature with no binding is a visible+ unconfigured state, not a silent fallback to the conversation model.+- A doctor view reports per-platform OS permission state (accessibility,+ capture, accessibility bus, session type) and distinguishes "not requested",+ "denied", and "unsupported on this platform". A denied TCC grant must not be+ presented as a broken feature.- The target picker is host-driven and shows the display list only while it isopen. It is the only way to choose a target.- The grant indicator is visible for the whole life of a grant, names thetarget, shows the remaining budget and the capture mode, and carries Stop. It- stays visible while the app is in the background, and the Live Voice call bar- reflects an active grant.+ stays visible while the app is in the background.- The grant card states, before approval, which capture mode is being approvedand that `a11y-and-pixels` means screenshots of the target may enter thesession transcript.+- The cursor overlay appears with the first action of a grant and closes with+ the grant.-Component-level wording for the picker, the indicator, the grant card, and the-doctor view lands with the implementing change.+Component-level wording for the picker, the indicator, the grant card, the+overlay, and the doctor view lands with the implementing change.## Audit and privacy@@ -207,17 +281,22 @@ grant, or permissions.Codes are registered in [08-error-codes](08-error-codes.md) §3.10 under the`COMPUTER_` prefix. The contract is that each distinct refusal is separately-attributable: feature disabled, no grant, scope violation, stale basis, stale-revision, budget exhausted, grant expired, self-target refused, secure input-refused, denylisted target, OS permission missing, elevated target, platform-unsupported, element not found or not actionable, and timeout.+attributable: feature disabled, no binding, no grant, scope violation, stale+basis, stale revision, budget exhausted, grant expired, self-target refused,+secure input refused, denylisted target, OS permission missing, elevated+target, platform unsupported, element not found or not actionable, a model+answer outside the action schema, and timeout.## Verification and limits- Automated coverage must include, before any of this ships: the self-targetrefusal, the secure-input refusal, stale-basis and stale-revision rejection,coordinate clamping, budget and expiry closure, single-grant exclusivity,- Plan/Goal denial, and the unsupported-platform path.+ Plan/Goal denial, the unsupported-platform path, the missing-binding path,+ and a model answer outside the action schema.+- The loop is covered without a provider: the model call is injected, so the+ schema, the validation, the step limits, and the stop conditions are unit+ tested against scripted answers including malformed and adversarial ones.- The accessibility tree, the synthesis path, and the capture path areplatform-specific and cannot be proven by fixtures. Real-device acceptanceper platform is a separate, explicitly authorized matrix, and a green fixturediff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex afbdbde5c..c70fe1ea2 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -8223,18 +8223,41 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.follows `confirm-each` (the only policy under `ask`) or an opt-in`autonomous-in-scope`. Plan and Goal hard-deny the tool, and no`allow-session` grant exists for it.-- Voice gains no authority: a spoken request reaches `Computer` only as a work- request on the bound session through the existing delegate/classifier path,- executed by the Agent turn. Voice-driven computer use is task delegation, not- per-frame teleoperation.-- macOS (`AXUIElement`, ScreenCaptureKit) and Windows (UIA, `SendInput`, with- higher-integrity targets refused) are the supported platforms; Linux/X11 is- best-effort over AT-SPI and XTEST; Wayland refuses input and keeps portal- capture. Every unsupported path has its own code, never a hang or a silent- no-op.+- Computer use carries **its own model binding** — one `{ providerId, modelId }`+ the user picks from the existing provider rows, following `imageGeneration`.+ A bounded perceive-decide-act loop in `packages/computer-use` turns one+ instruction into validated steps against a strict action schema; the+ conversation model never drives the machine and there is no silent fallback+ to it. The agent-facing tool therefore takes an instruction, not a `uid` or a+ coordinate, and returns a bounded summary rather than the inner transcript.+- The loop and the capture run in Electron main, not host-core: the loop needs+ a model provider and the capture needs Chromium, and host-core holds neither.+ host-core keeps everything that can refuse — targets, accessibility,+ synthesis, the grant broker, per-action re-validation, audit — and `Computer`+ follows the `GenerateImages` shape, where `tools.execute` performs the+ permission evaluation and main executes only after the host authorises.+- **The agent's cursor is drawn, not stolen.** Actions go through accessibility+ actions or window-targeted events, so the real pointer never warps and the+ user keeps their mouse while the agent works; a path that could only act by+ warping is refused. A frameless, transparent, click-through, always-on-top+ overlay draws the agent's own cursor, owns no part of the action, cannot+ receive input, and is never the source of truth for where an action landed.+- Voice is specified and deliberately unwired in the first release: the agent+ is the only caller. When stage 3 lands it, a spoken request will reach+ `Computer` only as a work request on the bound session through the existing+ delegate/classifier path, as task delegation rather than teleoperation.+- All three desktop platforms are in scope. Capture is `desktopCapturer`+ everywhere, so only inspection and input are platform work: macOS+ (`AXUIElement` actions, `CGEventPostToPid` keys, hand-declared framework FFI+ with no new crates) is stage 1; Windows (UIA, window-targeted messages,+ higher-integrity targets refused) and Linux/X11 (AT-SPI, best effort) are+ stage 2; Wayland refuses input and keeps portal capture. Every unsupported+ path has its own code, never a hang or a silent no-op, and a partial-fidelity+ backend declares it instead of returning an empty tree.- Non-goal 9 is amended rather than deleted: browser takeover, unattendedfull-desktop control, and any model-chosen target remain non-goals.-- Specified, not built: `03-runtime/computer-use.md`,- `08-error-codes.md` §3.10 (`COMPUTER_*`), `05-host-core-rust.md` §2/§5b/§6,+- Contract pages: `03-runtime/computer-use.md`, `08-error-codes.md` §3.10+ (`COMPUTER_*`), `05-host-core-rust.md` §2/§5b/§6,`05-security/01-security.md` §13, `03-tools-and-permissions.md` §0/§2/§6, and- the five `E2E-COMPUTER-USE-*` landing gates, all `NOT RUN`.+ the five `E2E-COMPUTER-USE-*` landing gates, all `NOT RUN` until stage 1+ lands.diff --git a/docs/zh-CN/spec/03-runtime/computer-use.md b/docs/zh-CN/spec/03-runtime/computer-use.mdindex 3d5bb6161..561f8c302 100644--- a/docs/zh-CN/spec/03-runtime/computer-use.md+++ b/docs/zh-CN/spec/03-runtime/computer-use.md@@ -2,30 +2,36 @@> **翻译说明:** 本页与[英文源规格](/spec/03-runtime/computer-use)一一对应。代码、协议字段和标识符保留原文;如翻译与英文源事实存在差异,以英文版本为准。-> 状态:设计已接受,尚未实现。本页是 [ADR 0340](../../../adr/0340-os-computer-use-capability.md) 所述能力的权威契约,仓库中目前没有任何代码实现它。+> 状态:阶段 1(MVP)进行中。本页是 [ADR 0340](../../../adr/0340-os-computer-use-capability.md) 所述能力的权威契约。当前唯一调用方是 Agent;语音入口在本页定义,但在阶段 3 才接通。## 范围电脑操作让 Agent 读取并操作用户明确交给它的某一个原生应用。该能力默认关闭,与内置 `Browser` 工具相互独立,且永不同时操作整个桌面:每次调用都只在一个由用户挑选的作用域内执行。-它可以通过语音触达。实时语音仍然只是语音接口,不获得任何新权限——一句口述请求会变成绑定会话上的工作请求(见[实时语音工作会话集成](/zh-CN/spec/03-runtime/live-work-session)),由现有 Agent 轮次调用工具,会话的模型、权限模式和审批卡片完全不变。语音驱动的电脑操作是任务委派,不是逐帧遥控:一句口述由一个带可见进度的 Agent 轮次来回答,而不是一条持续的控制回路。+语音入口在阶段 1 刻意不接通。接通后,实时语音也不获得任何自有权限——一句口述请求会变成绑定会话上的工作请求(见[实时语音工作会话集成](/zh-CN/spec/03-runtime/live-work-session)),由现有 Agent 轮次调用工具,会话的模型、权限模式和审批卡片完全不变。届时语音驱动的电脑操作是任务委派,不是逐帧遥控。| 界面 | 所有者 | 可达范围 ||---|---|---|| `Browser` 工具(`pi.browser`,ADR 0170) | 走白名单 CDP 的内置插件 | 仅限内嵌 `WebContentsView` 宿体 |-| `Computer` 工具(本页) | host-core 内置工具 | 一个被授权的原生窗口或应用 |+| `Computer` 工具(本页) | Electron Main 执行,由 host-core 把关 | 一个被授权的原生窗口或应用 || 实时语音 | Electron Main 与 Renderer | 音频、转录与工作委派;不做输入合成 |## 所有权与进程模型```text-Renderer(挑选器 UI、指示器)- → Preload IPC → Electron Main(薄层:挑选器、指示器、tools.execute 转发)- → Rust host-core `computer.*`(窗口、无障碍、合成、截取、- 授权中介、审计)+Renderer(挑选器、指示器、光标浮层)+ → Preload IPC → Electron Main+ Computer 工具处理器、有界回路、绑定模型调用、+ 作用域裁剪截取、浮层驱动+ → Rust host-core `computer.*`+ 目标枚举、无障碍、合成、授权中介、重校验、审计```-host-core 拥有窗口枚举、无障碍检查、事件合成、屏幕截取、授权中介、动作预算与审计记录。Renderer 永不拿到原生窗口句柄、原生元素引用或输入原语;它只拿到挑选器的展示列表和指示器的授权视图。Agent sidecar 只能通过现有 `host.proxy` 白名单中的 `tools.execute` 触达该能力——不新增代理方法;`computer.*` 不是插件宿主 API,也不出现在插件权限矩阵中。+host-core 拥有目标枚举、无障碍检查、事件合成、授权中介、动作预算、每动作重校验与审计记录。它是唯一能够拒绝的组件。回路与截取放在 Electron Main,因为回路需要模型 Provider、截取需要 Chromium,而 host-core 两者都不持有(见 [05-host-core-rust](/zh-CN/spec/03-runtime/05-host-core-rust) 第 3 节)。++Renderer 永不拿到原生窗口句柄、原生元素引用或输入原语;它只拿到挑选器的展示列表、指示器的授权视图和浮层的绘制指令。Agent sidecar 只能通过现有 `host.proxy` 白名单中的 `tools.execute` 触达该工具——不新增代理方法;`computer.*` 不是插件宿主 API,也不出现在插件权限矩阵中。++`Computer` 沿用 `GenerateImages` 的形状:host-core 把它归为 `high` 并通过 `tools.execute` 做权限评估,Main 中的处理器只有在宿主放行后才运行。## 授权与作用域@@ -62,26 +68,49 @@ host-core 拥有窗口枚举、无障碍检查、事件合成、屏幕截取、`Computer` 是内置高风险工具而非插件工具,因此它的影响面无法被表达成插件作者可以申请的权限。Plan 与 Goal 在权限评估之前就硬拒绝它,与 `Write`、`Edit` 相同:它改变的是工作区之外、宿主无法快照、比对或回滚的状态。-| 动作 | 风险 | 行为 |+Agent 以一条自然语言 `instruction` 加可选 `maxSteps` 调用它;`observeOnly` 只描述作用域而不动作。它不接受 `uid`、坐标或目标:寻址是内层回路的职责,目标是授权的职责。结果是一段有界摘要,说明改变了什么、跑了几步、为什么停下——不是内层回路的逐步记录。++其下由 Main 驱动以下宿主操作。它们不面向 Agent。++| 宿主操作 | 风险 | 行为 ||---|---|---|-| `describe_scope` | low | 返回授权视图:目标名称、revision、策略、截取模式、剩余预算 |-| `inspect` | low | 作用域的结构化无障碍树:role、name、是否有值、是否可用、是否聚焦、bounds、按授权生成的不透明 `uid` |-| `screenshot` | low | 裁剪到作用域并缩小的图像,附带 `basis` 令牌;`a11y-only` 授权下被拒绝 |-| `act` | high | 一批有界输入,按 `uid` 寻址,或按坐标配合 `basis` 寻址 |-| `wait` | low | 带显式超时地等待作用域条件(元素出现、变为可用、文本改变) |+| `computer.capabilities` | low | 后端身份、保真度、各平台操作系统权限状态、会话类型 |+| `computer.listTargets` | low | 仅供挑选器使用的可选窗口;被拒绝的目标连同原因一起列出,绝不静默丢弃 |+| `computer.grantCreate` / `grantRevoke` / `grantDescribe` | low | 签发、撤销与读取唯一的活动授权;签发必须基于用户在挑选器中的选择 |+| `computer.inspect` | low | 作用域的结构化无障碍树:role、name、是否有值、是否可用、是否聚焦、bounds、按授权生成的不透明 `uid`、声明的保真度 |+| `computer.act` | high | 重新测量作用域后,执行一个已校验的动作,按 `uid` 寻址或按坐标配合 `basis` 寻址 |-`act` 支持 `click`、`double_click`、`right_click`、`set_value`、`press_keys`、`scroll` 与 `select`。每一项都优先通过平台无障碍动作派发,只有在不存在对应动作时才回退到合成。+`computer.act` 支持 `click`、`double_click`、`right_click`、`set_value`、`press_keys`、`scroll` 与 `select`。每一项都优先通过平台无障碍动作派发,只有在不存在对应动作时才回退到面向窗口的事件。截取在 Main 中通过 Chromium 的 `desktopCapturer` 完成,按 host-core 测得的几何裁剪,并在 `a11y-only` 授权下被拒绝。元素身份以无障碍为先。`uid` 不透明、按授权生成,并在 revision 变化时失效。`inspect` 不返回元素取值,只返回是否有值,因此读取字段内容是一个用户能在转录中看到的显式 `inspect` 结果字段,而不是枚举的副作用。### 坐标与新鲜度-坐标输入只以 `act` 配合 `basis` 的形式存在:`basis` 由同一作用域的 `screenshot` 签发,携带授权 revision 与测得的窗口几何。宿主在合成前立即重新校验 `basis`,并拒绝过期值。因此:+坐标输入只以 `computer.act` 配合 `basis` 的形式存在:`basis` 是授权 revision 加上同一作用域的那次截取所依据的窗口几何。宿主在合成前立即重新测量并校验 `basis`,并拒绝过期值。因此:- 模型永远无法派发盲点击。没有截取就没有 `basis`,没有 `basis` 就没有坐标。- 目标在截取与动作之间移动、改变尺寸、revision 变化或失去焦点时失败关闭,而不是点击此刻占据那片像素的东西。- 坐标相对作用域,并被夹到测得的窗口边界内。越界坐标是错误,不是被夹紧后照样点击。+## 绑定模型与回路++电脑操作有自己的模型绑定——用户在设置里从已配置的 Provider 行中挑选的一组 `{ providerId, modelId }`,沿用 `imageGeneration` 的先例。对话模型不用来驱动机器,也没有静默回退:没有配置绑定时,工具报配置错误。哪个模型可以操作自己的电脑、为此花多少钱,由用户决定。++回路是 `packages/computer-use` 中与 Electron 无关的纯模块:++1. 观察:作用域的无障碍树,授权允许像素时再加一张作用域裁剪截图,以及授权视图。+2. 决策:向绑定模型发一次请求,它必须按严格 schema 回答恰好一个动作,或 `done`,或 `ask`。+3. 校验:先校验 schema,再校验 `uid` 是否在当前树中、坐标是否在测得几何内、授权 revision、以及剩余预算。任何超出 schema 的内容都是拒绝,而不是尝试。+4. 动作:执行一次 `computer.act`,然后重新观察。++回路在 `done`、步数上限(本次调用的 `maxSteps` 被授权动作预算夹紧)、被撤销、过期,或同一步反复失败时停止。模型散文绝不会未经解析进入工具结果:摘要由回路实际做过的事组装而成。模型回答中的任何内容都不能扩大作用域、改变目标、提高预算或关闭某条拒绝。++## Agent 的光标是画出来的,不是抢来的++动作通过无障碍动作或面向窗口的事件派发,因此真实系统光标永不被挪动。Agent 工作期间用户的鼠标和键盘仍归自己;只能靠挪动真实指针来动作的平台路径会被拒绝而不是被采用。++一个独立的无边框、透明、穿透点击、置顶浮层窗口画出 Agent 自己的光标:它移动到即将被操作的元素上,并在动作派发时显示一次按下。该浮层只是可视化。它不拥有动作的任何部分,永不接收输入(创建时即忽略鼠标事件),画不出来既不会阻塞动作也不会替代动作。它也不是动作落点的事实来源——宿主的重新测量才是,浮层跟随它。浮层随授权一起关闭。+## 权限流程权限模式治理的是授权,不是每一次按键。@@ -89,33 +118,37 @@ host-core 拥有窗口枚举、无障碍检查、事件合成、屏幕截取、| 阶段 | `ask` | `accept-edits` | `auto` ||---|---|---|---|| 创建授权 | 确认(桌面 UI) | 确认(桌面 UI) | 确认(桌面 UI) |-| 活动授权内的 `inspect`、`screenshot`、`describe_scope` | 允许 | 允许 | 允许 |-| `confirm-each` 下的 `act` | 每批确认 | 每批确认 | 每批确认 |-| `autonomous-in-scope` 下的 `act` | 不可用 | 允许 | 允许 |+| 活动授权内的检查、截取与作用域描述 | 允许 | 允许 | 允许 |+| `confirm-each` 下的一次输入动作 | 每步确认 | 每步确认 | 每步确认 |+| `autonomous-in-scope` 下的一次输入动作 | 不可用 | 允许 | 允许 || Plan / Goal | 硬拒绝 | 硬拒绝 | 硬拒绝 |`confirm-each` 是默认值,也是 `ask` 下唯一可用的输入策略。`autonomous-in-scope` 需要在授权时显式选择。两种策略都受动作预算、空闲过期、每动作作用域重校验以及终止开关约束。`Computer` 不存在 `allow-session` 授权:作用域授权本身就是会话级决定,而按工具名授权会活得比它被批准针对的那个目标更久。## 平台支持-| 平台 | 检查与输入 | 截取 | 说明 |+三个桌面平台都在范围内。截取各平台一致——Chromium 的 `desktopCapturer`,在 Main 中按 host-core 测得的几何裁剪——因此只有检查与输入是平台相关的工作。++| 平台 | 检查与输入 | 阶段 | 说明 ||---|---|---|---|-| macOS | `AXUIElement`,需 Accessibility TCC 授权 | ScreenCaptureKit,需屏幕录制 TCC 授权 | 安全输入状态会同时拒绝两者 |-| Windows | UI Automation 加 `SendInput` | 桌面复制 / 窗口截取 | 由更高完整性级别进程拥有的窗口被拒绝,绝不静默丢弃 |-| Linux / X11 | AT-SPI 加 XTEST,尽力而为 | X11 截取 | 需要无障碍总线;工具包不支持时如实上报,不做猜测 |-| Linux / Wayland | 拒绝输入 | 门户屏幕投送 | 不存在可移植的合成输入;截取仍可用 |+| macOS | `AXUIElement` 动作,需 Accessibility TCC 授权;按键用 `CGEventPostToPid` 投向被授权应用 | 1 | 手写 framework FFI,不引入新 crate;安全输入会同时拒绝截取与输入 |+| Windows | UI Automation 模式,回退到面向窗口的消息 | 2 | 由更高完整性级别进程拥有的窗口被拒绝,绝不静默丢弃 |+| Linux / X11 | AT-SPI 动作,尽力而为 | 2 | 需要无障碍总线;工具包不支持时如实上报,不做猜测 |+| Linux / Wayland | 拒绝输入 | — | 不存在可移植的合成输入;截取仍通过门户可用 |-任何尚未实现的平台或阶段都返回明确的不支持错误码。缺失的能力永不表现为挂起,也永不以成功回报空操作。+后端尚未落地的平台,在任何需要它的操作上都返回 `COMPUTER_PLATFORM_UNSUPPORTED`,并且 `computer.capabilities` 会在用户尝试之前就说明这一点。保真度只是部分的后端必须在自己的 `inspect` 结果里声明,而不是返回一棵读起来像空窗口的空树。缺失的能力永不表现为挂起,也永不以成功回报空操作。## 设置与 UX 界面- 电脑操作默认关闭。打开开关不会创建授权、申请操作系统权限、截取画面或枚举窗口。-- 体检视图按平台报告操作系统权限状态(屏幕录制、无障碍、无障碍总线、会话类型),并区分"未申请"、"已拒绝"与"本平台不支持"。被拒绝的 TCC 授权不得呈现为功能损坏。+- 模型绑定是显式的。设置里提供用户已配置的 Provider 行;功能已开启但没有绑定是一个可见的未配置状态,而不是静默回退到对话模型。+- 体检视图按平台报告操作系统权限状态(无障碍、截取、无障碍总线、会话类型),并区分"未申请"、"已拒绝"与"本平台不支持"。被拒绝的 TCC 授权不得呈现为功能损坏。- 目标挑选器由宿主驱动,仅在打开期间展示列表。它是选择目标的唯一方式。-- 授权指示器在授权存续期间始终可见,标明目标、剩余预算与截取模式,并带有"停止"。应用退到后台时它仍然可见,实时语音通话条也会反映活动授权。+- 授权指示器在授权存续期间始终可见,标明目标、剩余预算与截取模式,并带有"停止"。应用退到后台时它仍然可见。- 授权卡片在批准之前说明正在批准哪种截取模式,并说明 `a11y-and-pixels` 意味着目标的截图可能进入会话转录。+- 光标浮层在一次授权的首个动作时出现,并随授权一起关闭。-挑选器、指示器、授权卡片与体检视图的组件级措辞随实现变更落地,不在本页。+挑选器、指示器、授权卡片、浮层与体检视图的组件级措辞随实现变更落地,不在本页。## 审计与隐私@@ -125,10 +158,11 @@ host-core 拥有窗口枚举、无障碍检查、事件合成、屏幕截取、## 错误码-错误码登记在 [08-error-codes](/zh-CN/spec/03-runtime/08-error-codes) §3.10,统一使用 `COMPUTER_` 前缀。契约是每一种拒绝都可单独归因:功能关闭、无授权、作用域越界、`basis` 过期、revision 过期、预算耗尽、授权过期、拒绝自我目标、拒绝安全输入、目标在拒绝名单上、缺少操作系统权限、目标提权、平台不支持、元素未找到或不可操作,以及超时。+错误码登记在 [08-error-codes](/zh-CN/spec/03-runtime/08-error-codes) §3.10,统一使用 `COMPUTER_` 前缀。契约是每一种拒绝都可单独归因:功能关闭、未配置绑定、无授权、作用域越界、`basis` 过期、revision 过期、预算耗尽、授权过期、拒绝自我目标、拒绝安全输入、目标在拒绝名单上、缺少操作系统权限、目标提权、平台不支持、元素未找到或不可操作、模型回答超出动作 schema,以及超时。## 验证与限制-- 在任何部分交付之前,自动化覆盖必须包含:自我目标拒绝、安全输入拒绝、`basis` 与 revision 过期拒绝、坐标夹取、预算与过期关闭、单授权互斥、Plan/Goal 拒绝,以及不支持平台的路径。+- 在任何部分交付之前,自动化覆盖必须包含:自我目标拒绝、安全输入拒绝、`basis` 与 revision 过期拒绝、坐标夹取、预算与过期关闭、单授权互斥、Plan/Goal 拒绝、不支持平台的路径、缺少绑定的路径,以及模型回答超出动作 schema 的情形。+- 回路的覆盖不需要 Provider:模型调用是注入的,因此 schema、校验、步数上限与停止条件都用脚本化回答做单测,包含畸形与对抗性回答。- 无障碍树、合成路径与截取路径都与平台相关,无法用 fixture 证明。各平台的真机验收是单独且需显式授权的矩阵;fixture 全绿不等于真机通过。- E2E 场景列在 [04-e2e-test-plan](/zh-CN/spec/06-delivery/04-e2e-test-plan) 的 `E2E-COMPUTER-USE-` 前缀下。diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex 4bc7b830b..f222fd4eb 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -5743,15 +5743,32 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编`auto` 不签发任何授权,口述请求也不能。在授权内,检查类动作自动允许,输入遵循`confirm-each`(`ask` 下唯一策略)或需显式选择的 `autonomous-in-scope`。Plan 与 Goal 硬拒绝该工具,且它不存在 `allow-session` 授权。-- 语音不获得新权限:一句口述只能经由现有委派/分类器路径成为绑定会话上的工作- 请求,由 Agent 轮次执行。语音驱动的电脑操作是任务委派,不是逐帧遥控。-- 受支持平台为 macOS(`AXUIElement`、ScreenCaptureKit)与 Windows(UIA、- `SendInput`,提权目标被拒绝);Linux/X11 基于 AT-SPI 与 XTEST 尽力而为;- Wayland 拒绝输入并保留门户截取。每条不支持路径都有自己的错误码,绝不挂起,- 也绝不静默空操作。+- 电脑操作有**自己的模型绑定**——用户从已配置的 Provider 行中挑选的一组+ `{ providerId, modelId }`,沿用 `imageGeneration` 的先例。+ `packages/computer-use` 中一条有界的"观察—决策—动作"回路把一条指令按严格+ 动作 schema 变成一串已校验的步骤;对话模型绝不驱动机器,也没有静默回退。+ 因此面向 Agent 的工具接受的是一条指令,而不是 `uid` 或坐标,返回的是有界+ 摘要而不是内层记录。+- 回路与截取跑在 Electron Main 而不是 host-core:回路需要模型 Provider,截取+ 需要 Chromium,host-core 两者都不持有。host-core 保留一切能够拒绝的东西——+ 目标枚举、无障碍、合成、授权中介、每动作重校验、审计——而 `Computer` 沿用+ `GenerateImages` 的形状:`tools.execute` 做权限评估,Main 在宿主放行后才执行。+- **Agent 的光标是画出来的,不是抢来的。** 动作走无障碍动作或面向窗口的事件,+ 真实指针永不被挪动,Agent 工作期间用户的鼠标仍归自己;只能靠挪动真实指针来+ 动作的路径会被拒绝。一个无边框、透明、穿透点击、置顶的浮层画出 Agent 自己的+ 光标,它不拥有动作的任何部分,不能接收输入,也绝不是动作落点的事实来源。+- 语音在首个版本中只定规格、刻意不接通:唯一调用方是 Agent。阶段 3 接通后,+ 一句口述只能经由现有委派/分类器路径成为绑定会话上的工作请求,属于任务委派+ 而不是遥控。+- 三个桌面平台都在范围内。截取各平台统一用 `desktopCapturer`,因此只有检查与+ 输入是平台工作:macOS(`AXUIElement` 动作、`CGEventPostToPid` 按键、手写+ framework FFI 且不引入新 crate)属阶段 1;Windows(UIA、面向窗口的消息、+ 提权目标被拒绝)与 Linux/X11(AT-SPI,尽力而为)属阶段 2;Wayland 拒绝输入+ 并保留门户截取。每条不支持路径都有自己的错误码,绝不挂起,也绝不静默空操作,+ 保真度只是部分的后端必须自行声明,而不是返回一棵空树。- 非目标第 9 条是修订而非删除:浏览器接管、无人看管的全桌面控制,以及任何由模型自行选择目标,仍然是非目标。-- 只定规格未落实现:`03-runtime/computer-use.md`、`08-error-codes.md` §3.10+- 契约页面:`03-runtime/computer-use.md`、`08-error-codes.md` §3.10(`COMPUTER_*`)、`05-host-core-rust.md` §2/§5b/§6、`05-security/01-security.md` §13、`03-tools-and-permissions.md` §0/§2/§6,- 以及五条 `E2E-COMPUTER-USE-*` 落地闸门,全部为 `NOT RUN`。+ 以及五条 `E2E-COMPUTER-USE-*` 落地闸门,在阶段 1 落地前全部为 `NOT RUN`。