Commit graph

3 commits

Author SHA1 Message Date
顾盼
bb1e71911c
feat(computer-use): configurable screenshot max dimension (setting + env) (#5122)
* feat(computer-use): configurable screenshot max dimension (setting + env)

Add a user-level knob for cua-driver's screenshot longest-edge cap. The
old open-computer-use backend exposed this via OPEN_COMPUTER_USE_IMAGE_*
env vars; the cua-driver migration dropped them, leaving only the
model-driven set_config tool. This restores deterministic user control.

- Setting tools.computerUse.maxImageDimension (number; default -1 = keep
  cua-driver's built-in default of 1568; 0 disables resizing / full
  resolution; a positive value caps the longest edge).
- Env override QWEN_COMPUTER_USE_MAX_IMAGE_DIMENSION (takes precedence
  over the setting; invalid/negative values fall through).
- Resolution lives in resolveMaxImageDimension(); applied via the
  cua-driver set_config tool once per (re)connect in
  ComputerUseClient.doStart — best-effort, never aborts startup, and
  re-applied after a daemon-restart reconnect.
- Docs: document tools.computerUse.{enabled,maxImageDimension} in
  settings.md (the block was previously undocumented). Refresh stale
  ocu/npx comments left in client.ts + install-state.ts by the migration.

Precedence: env var > setting > cua-driver default.

* chore(computer-use): finish ocu→cua-driver cleanup in schema-sync script

The cua-driver migration (#5051) left scripts/sync-computer-use-schemas.ts
pointing at the old open-computer-use backend: it npx'd
@qwen-code/open-computer-use, hard-coded the 9-tool ocu surface, and emitted an
"open-computer-use" header. Re-running it — which constants.ts' version-bump
procedure tells maintainers to do — would have clobbered the migrated 35-tool
cua-driver schemas.ts.

- Drive the locally-pinned `cua-driver mcp` binary (binaryPath /
  CUA_DRIVER_VERSION from constants.ts) instead of npx'ing ocu; expect 35
  tools and warn (don't fail) on drift.
- Emit the cua-driver-flavored schemas.ts header.
- Refresh install-state.test.ts fixtures from ocu package specs to the
  cua-driver-rs approval-key form the field actually stores now.

Verified the fixed script reproduces the committed 35-tool surface exactly
(modulo prettier formatting). No dead env-var handling remained — the module
reads only QWEN_COMPUTER_USE_{AUTO_APPROVE,DOWNLOAD_HOST,MAX_IMAGE_DIMENSION}.
2026-06-15 15:25:27 +08:00
顾盼
53d3d7f6ff
feat(computer-use): use @qwen-code/open-computer-use fork (signed + notarized) (#4726)
* feat(computer-use): point built-in MCP at @qwen-code/open-computer-use@0.2.2

Switch the deferred Computer Use MCP server from upstream
`open-computer-use` to the QwenLM fork `@qwen-code/open-computer-use`,
published to npm (signed + notarized, pinned at 0.2.2).

- constants.ts: add PINNED_OPEN_COMPUTER_USE_PACKAGE_NAME
  (@qwen-code/open-computer-use); pin 0.2.2;
  resolveComputerUsePackageSpec() composes name@version.
- sync-computer-use-schemas.ts: default to the scoped package + 0.2.2.
- schemas.ts: header refresh — tool surface is unchanged across
  0.2.0→0.2.2, so the hardcoded 9-tool schemas need no content change.
- Test/doc sample specs updated to the scoped name. permission-detector
  tests keep `open-computer-use doctor` — only the npm package is scoped;
  the installed CLI binary is still named `open-computer-use`.

* feat(computer-use): point built-in MCP at @qwen-code/open-computer-use@0.2.3

Switch the deferred Computer Use MCP server from upstream
`open-computer-use` to the QwenLM fork `@qwen-code/open-computer-use`,
published to npm (signed + notarized, pinned at 0.2.3).

0.2.3 includes the screenshot env-var controls (OPEN_COMPUTER_USE_IMAGE_*),
the window-free `permission-status` command, and the minScale-clamp fix
(small MAX_DIMENSION now downsamples to the minScale floor instead of
falling back to the full-size original).

- constants.ts: add PINNED_OPEN_COMPUTER_USE_PACKAGE_NAME
  (@qwen-code/open-computer-use); pin 0.2.3;
  resolveComputerUsePackageSpec() composes name@version.
- sync-computer-use-schemas.ts: default to the scoped package + 0.2.3.
- schemas.ts: header refresh — 0.2.0→0.2.3 changes don't alter the MCP
  tool surface, so the hardcoded 9-tool schemas are unchanged.
- Test/doc sample specs use the scoped name. permission-detector tests
  keep `open-computer-use doctor` — only the npm package is scoped; the
  installed CLI binary is still named `open-computer-use`.
2026-06-03 19:13:39 +08:00
顾盼
39cc9b3e6f
feat(computer-use): zero-config built-in via open-computer-use MCP (#4590)
* feat(computer-use): add tool name constants

* feat(computer-use): hardcode upstream tool schemas

* feat(computer-use): add enableComputerUse setting (default true)

* chore(vscode-ide-companion): sync settings schema for computerUse

* feat(computer-use): MCP stdio client for upstream binary

* feat(computer-use): ComputerUseTool wrapper + bootstrap stub

* feat(computer-use): register 9 deferred tools when enabled

* feat(computer-use): persist install approval state under ~/.qwen

* feat(computer-use): detect upstream permission errors

* feat(computer-use): bootstrap state machine (install + permissions)

* feat(computer-use): wire install approval to qwen-code confirm UX

* chore(computer-use): script to sync schemas from upstream

* fix(computer-use): consolidate package spec, surface download progress, correct version comment

* docs(computer-use): implementation plan

* fix(computer-use): forward image content parts to the model

* fix(computer-use): coerce string numbers to integers + clarify required fields

* fix(computer-use): detect missing Screen Recording + re-spawn doctor across permission transitions

* fix(computer-use): auto-reconnect on transport-closed errors

* fix(computer-use): sync schemas with upstream canonical contract

Regenerated schemas.ts from upstream open-computer-use@latest via
scripts/sync-computer-use-schemas.ts. Key contract fixes:

- element_index: type integer → string (upstream reads via optionalString)
- x/y/from_x/from_y/to_x/to_y: type integer → number (upstream uses optionalDouble)
- scroll: adds required direction enum + requires element_index (not pages)
- click: adds optional mouse_button string enum (left/right/middle)
- Descriptions updated to upstream verbatim text (no "REQUIRED:" prefix)

* fix(computer-use): bidirectional type coercion for string element_index

Rename coerceNumericStrings → coerceTypes and add Direction 2:
when schema declares type: "string" and model sends a number,
stringify it (e.g. element_index: 2 → "2"). This fixes the upstream
runtime error where optionalString returns nil for numeric element_index.

Direction 1 (string → number for integer/number fields) is preserved
unchanged for x/y coordinate fields.

Update tests: element_index coercion tests now reflect string schema
type; add new "coerces integer element_index to string" test cases.

* feat(prompts): strengthen deferred-tools guidance to prevent param guessing

* fix(computer-use): clearer wording for permission-transition onboarding message

* fix(computer-use): only probe permissions on fresh client start, not every tool call

* docs(computer-use): correct comment about permission-revocation recovery behavior

* fix(computer-use): pin upstream version exactly to prevent schema drift

* fix(computer-use): use pinned package spec in client singleton to prevent schema drift

* fix(computer-use): decouple install gate from per-action permission grant

* fix(computer-use): route registration through PermissionManager-aware registerLazy

* fix(computer-use): probe via upstream doctor instead of get_app_state on Finder

The previous probe called get_app_state on Finder, which has the side
effect of activating the target app via upstream's unhide / open -b /
AXRaise logic. Result: Finder popped to the foreground once per fresh
session even when the user's task had nothing to do with it.

The doctor CLI reads TCC + runtime preflight and prints a summary to
stdout, exiting silently when permissions are granted. When any
permission is missing, doctor launches the onboarding window via
LaunchServices (which dedups so repeated invocations focus the
existing window). We parse the stdout summary and rely on doctor's
own window-launching for the UX trigger — no separate spawnDoctor
call needed.

Side effect for steady-state sessions (permissions already granted):
ZERO Finder activation. The probe spawns npx -y doctor once per fresh
client start (~200-500ms), and that's it.

Also bumped pollIntervalMs default from 2s to 5s to amortize the
npx-spawn overhead during the rare permission-grant flow.
2026-05-29 10:39:51 +08:00