diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47a4a0f73..744c7803e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,8 +77,10 @@ jobs: GITHUB_TOKEN: ${{ env.RTK_INSTALL_GITHUB_TOKEN }} - name: Build Windows + shell: bash run: | pnpm run build + pnpm run plugin:bundle -- --name cua --platform win32 --arch ${{ matrix.arch }} pnpm run plugin:bundle -- --name feishu --platform win32 --arch ${{ matrix.arch }} pnpm exec electron-builder --win --${{ matrix.arch }} --publish=never env: @@ -90,6 +92,7 @@ jobs: - name: Verify bundled plugins shell: bash run: | + pnpm run plugin:verify -- --name cua --platform win32 --arch ${{ matrix.arch }} --plugin-root dist/${{ matrix.unpacked }}/resources/app.asar.unpacked/plugins pnpm run plugin:verify -- --name feishu --platform win32 --arch ${{ matrix.arch }} --plugin-root dist/${{ matrix.unpacked }}/resources/app.asar.unpacked/plugins - name: Upload artifacts @@ -142,6 +145,7 @@ jobs: - name: Build Linux run: | pnpm run build + pnpm run plugin:bundle -- --name cua --platform linux --arch ${{ matrix.arch }} pnpm run plugin:bundle -- --name feishu --platform linux --arch ${{ matrix.arch }} pnpm exec electron-builder --linux --${{ matrix.arch }} --publish=never env: @@ -153,6 +157,7 @@ jobs: - name: Verify bundled plugins shell: bash run: | + pnpm run plugin:verify -- --name cua --platform linux --arch ${{ matrix.arch }} --plugin-root dist/linux-unpacked/resources/app.asar.unpacked/plugins pnpm run plugin:verify -- --name feishu --platform linux --arch ${{ matrix.arch }} --plugin-root dist/linux-unpacked/resources/app.asar.unpacked/plugins - name: Upload artifacts @@ -213,7 +218,6 @@ jobs: - name: Build Mac run: | pnpm run build - pnpm run plugin:cua:build:mac:${{ matrix.arch }} pnpm run plugin:bundle -- --name cua --platform darwin --arch ${{ matrix.arch }} pnpm run plugin:bundle -- --name feishu --platform darwin --arch ${{ matrix.arch }} pnpm exec electron-builder --mac --${{ matrix.arch }} --publish=never diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70c17b089..d93ea4ec4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -173,6 +173,7 @@ jobs: - name: Build Windows run: | pnpm run build + pnpm run plugin:bundle -- --name cua --platform win32 --arch ${{ matrix.arch }} pnpm run plugin:bundle -- --name feishu --platform win32 --arch ${{ matrix.arch }} pnpm exec electron-builder --win --${{ matrix.arch }} --publish=never env: @@ -185,6 +186,7 @@ jobs: - name: Verify bundled plugins shell: bash run: | + pnpm run plugin:verify -- --name cua --platform win32 --arch ${{ matrix.arch }} --plugin-root dist/${{ matrix.unpacked }}/resources/app.asar.unpacked/plugins pnpm run plugin:verify -- --name feishu --platform win32 --arch ${{ matrix.arch }} --plugin-root dist/${{ matrix.unpacked }}/resources/app.asar.unpacked/plugins - name: Upload artifacts @@ -236,6 +238,7 @@ jobs: - name: Build Linux run: | pnpm run build + pnpm run plugin:bundle -- --name cua --platform linux --arch ${{ matrix.arch }} pnpm run plugin:bundle -- --name feishu --platform linux --arch ${{ matrix.arch }} pnpm exec electron-builder --linux --${{ matrix.arch }} --publish=never env: @@ -248,6 +251,7 @@ jobs: - name: Verify bundled plugins shell: bash run: | + pnpm run plugin:verify -- --name cua --platform linux --arch ${{ matrix.arch }} --plugin-root dist/linux-unpacked/resources/app.asar.unpacked/plugins pnpm run plugin:verify -- --name feishu --platform linux --arch ${{ matrix.arch }} --plugin-root dist/linux-unpacked/resources/app.asar.unpacked/plugins - name: Upload artifacts @@ -310,7 +314,6 @@ jobs: - name: Build Mac run: | pnpm run build - pnpm run plugin:cua:build:mac:${{ matrix.arch }} pnpm run plugin:bundle -- --name cua --platform darwin --arch ${{ matrix.arch }} pnpm run plugin:bundle -- --name feishu --platform darwin --arch ${{ matrix.arch }} pnpm exec electron-builder --mac --${{ matrix.arch }} --publish=never diff --git a/docs/features/cua-cross-platform-computer-use/plan.md b/docs/features/cua-cross-platform-computer-use/plan.md new file mode 100644 index 000000000..0604c1c49 --- /dev/null +++ b/docs/features/cua-cross-platform-computer-use/plan.md @@ -0,0 +1,182 @@ +# CUA Cross-Platform Computer Use Plan + +## Design Principles + +- Keep the DeepChat integration model unchanged: official plugin, skill, and DeepChat-owned tool + startup. +- Treat upstream CUA release artifacts as immutable inputs pinned by tag, commit, asset name, and + checksum. +- Fail closed when a target runtime is unavailable or an archive layout does not match expectations. +- Avoid runtime network activity. All downloads happen at build time. +- Keep packaging verification close to the produced `.dcplugin` files, not only source folders. + +## Current-State Changes Required + +### Plugin Manifest + +Update `plugins/cua/plugin.json`: + +- Change platform support from macOS-only to target-aware support for `darwin/arm64`, + `darwin/x64`, `win32/x64`, `win32/arm64`, and `linux/x64`. +- Add or enforce arch-aware visibility metadata so `linux/arm64` does not show CUA as an available + official plugin. +- Replace macOS-only runtime candidates with platform-specific candidates: + - `plugin:runtime/darwin/${arch}/CuaDriver.app/Contents/MacOS/cua-driver` + - `plugin:runtime/win32/${arch}/cua-driver.exe` + - `plugin:runtime/linux/${arch}/cua-driver` +- Keep plugin-local runtime candidates first. +- Update packaged download URL conventions to include target platform and arch. +- Update tool policies for upstream v0.5.5 tools. +- Keep the internal tool server declaration owned by the plugin host; do not add user-facing MCP + setup instructions. + +### Upstream Metadata + +Update `plugins/cua/vendor/cua-driver/upstream.json` from the old Swift fork metadata to the pinned +Rust driver release: + +- `source`: upstream `trycua/cua`. +- `tag`: `cua-driver-rs-v0.5.5`. +- `commit`: `d6dea4bc3c3a65ce821261752067cae8200fe5d6`. +- `version`: `0.5.5`. +- Include the expected asset map and checksums source. +- Record Windows arm64 as supported and Linux arm64 as unsupported for this pinned DeepChat + integration. + +### Runtime Staging + +Replace the macOS-only Swift build path in `scripts/build-cua-plugin-runtime.mjs` with a staging +pipeline: + +1. Resolve target platform and arch from CLI flags or host defaults. +2. Map supported DeepChat platform/arch targets to upstream asset names. +3. Download the upstream release archive and `checksums.txt` into a cache directory. +4. Verify the archive digest. +5. Extract into a temporary staging directory. +6. Validate the extracted layout. +7. Copy the normalized runtime files into `plugins/cua/runtime//`. +8. Set executable permissions for macOS and Linux. +9. Run host-executable smoke checks where the host platform and runtime loader can execute the + target binary. +10. Run macOS app bundle and signing checks for darwin targets. + +The script should reject Linux arm64 and any other unsupported target with a clear message before +any partial runtime is staged. + +### Plugin Packaging + +Update `scripts/package-plugin.mjs`: + +- Remove the darwin-only CUA guard. +- Keep only the selected `runtime//` subtree in the `.dcplugin` artifact. +- Narrow the packaged manifest's `engines.targets` to the selected `/` target so + target-specific artifacts cannot be discovered on the wrong architecture. +- Validate required files per target: + - macOS: helper app executable. + - Windows: `cua-driver.exe` and `cua-driver-uia.exe`. + - Linux: `cua-driver`. +- Preserve executable bits on POSIX archive entries. +- Keep source manifest hydration deterministic for platform and arch. + +### Build Scripts + +Update `package.json` scripts so CUA can be staged, bundled, and verified on supported platforms: + +- Add Windows x64 and arm64 CUA build scripts. +- Add Linux x64 CUA build script. +- Keep Linux arm64 unsupported unless it is explicitly validated for DeepChat. +- Avoid duplicate runtime staging when `plugin:bundle` already invokes a build script. Either make + the build script idempotent and cheap when the target runtime is current, or split staging from + bundling explicitly. +- Ensure supported Windows and Linux build scripts include the CUA bundle step without affecting + unsupported Linux arm64 builds. + +### CI and Release Workflows + +Update `.github/workflows/build.yml` and `.github/workflows/release.yml`: + +- Bundle and verify CUA on macOS arm64/x64. +- Bundle and verify CUA on Windows x64 and arm64. +- Bundle and verify CUA on Linux x64. +- Do not request Linux arm64 CUA artifacts until that target is explicitly supported. +- Keep CUA verification next to Feishu verification so missing official plugin artifacts fail the + build. + +### Skill Docs + +Adapt CUA skill docs from upstream v0.5.5 into DeepChat-specific docs: + +- Remove upstream manual install, PATH, and standalone MCP setup requirements. +- Describe the DeepChat tool surface and platform behavior. +- Add platform caveats for macOS permissions, Windows foreground/background dispatch, and Linux + pre-release limitations. +- Replace Swift-era tool names with v0.5.5 tool names. +- Keep plugin support metadata aligned with the supported platform/arch matrix. + +### Settings and Permission UX + +Update plugin settings/runtime status code where needed: + +- Keep macOS helper-app permission checks. +- Show platform-neutral runtime status for Windows and Linux. +- Avoid macOS-only permission copy on non-macOS platforms. +- Ensure missing Linux arm64 runtimes are reported as unsupported, not as broken installs. + +### Plugin Discovery Cleanup + +Update official plugin discovery so unsupported sibling artifacts for the same plugin id do not +disable an already installed supported artifact. Only remove persisted plugin state when no trusted +candidate for the current platform/arch exists in the discovery pass. + +### Tests + +Update and add focused tests for: + +- Official plugin target metadata, visibility, and runtime candidate resolution. +- CUA manifest hydration and visibility for supported platform/arch targets. +- Runtime packaging validation per platform and arch. +- Unsupported Linux arm64 behavior. +- Tool policy coverage for upstream v0.5.5 known tools. +- Skill docs no longer asserting macOS-only or user-managed MCP-only language. +- Build and release workflow assertions for CUA on Windows x64/arm64, macOS, and Linux x64. + +## Verification Plan + +Run these after implementation: + +```bash +pnpm run format +pnpm run i18n +pnpm run lint +pnpm run typecheck +pnpm test -- test/main/presenter/pluginPresenter.test.ts +pnpm test -- test/main/scripts +``` + +Run packaging checks on supported host/CI targets: + +```bash +pnpm run plugin:bundle -- --name cua --platform win32 --arch x64 +pnpm run plugin:verify -- --name cua --platform win32 --arch x64 +pnpm run plugin:bundle -- --name cua --platform win32 --arch arm64 +pnpm run plugin:verify -- --name cua --platform win32 --arch arm64 +pnpm run plugin:bundle -- --name cua --platform linux --arch x64 +pnpm run plugin:verify -- --name cua --platform linux --arch x64 +pnpm run plugin:bundle -- --name cua --platform darwin --arch arm64 +pnpm run plugin:verify -- --name cua --platform darwin --arch arm64 +pnpm run plugin:bundle -- --name cua --platform darwin --arch x64 +pnpm run plugin:verify -- --name cua --platform darwin --arch x64 +``` + +On Windows, also verify the built `.dcplugin` contains both `cua-driver.exe` and +`cua-driver-uia.exe`. On Linux, verify `cua-driver` is executable after extraction. On macOS, +verify the helper app executable path and signing state. + +## Rollout Notes + +- This change should land as one focused feature branch because manifest, packaging, docs, and CI + must stay in sync. +- If upstream publishes a newer driver before implementation starts, re-run the release asset audit + and update the pinned tag only after confirming asset names, tool names, and Linux availability. +- If macOS helper-app signing fails after staging the upstream bundle, keep the runtime update but + isolate the signing fix in the staging script instead of changing the plugin host. diff --git a/docs/features/cua-cross-platform-computer-use/spec.md b/docs/features/cua-cross-platform-computer-use/spec.md new file mode 100644 index 000000000..f43ed7d88 --- /dev/null +++ b/docs/features/cua-cross-platform-computer-use/spec.md @@ -0,0 +1,242 @@ +# CUA Cross-Platform Computer Use Spec + +## Status + +Draft for implementation planning. + +## Background + +DeepChat currently ships the CUA computer-use capability as an official plugin under +`plugins/cua`. The integration is DeepChat-managed: the plugin declares a skill and a bundled +tool server that DeepChat starts internally. Users do not configure an external MCP server, install +the CUA driver manually, or rely on PATH for the bundled experience. + +The current plugin is macOS-only: + +- `plugins/cua/plugin.json` limits `engines.platforms` to `darwin`. +- The runtime build script builds the older Swift driver from the vendored CUA fork. +- The package script special-cases only `runtime/darwin/`. +- Build and release workflows only include the CUA plugin in macOS artifacts. +- Skill docs, runtime permission wording, tests, and packaging docs assume macOS. + +Upstream `trycua/cua` now publishes the Rust CUA driver as cross-platform release artifacts. The +latest verified driver release for this plan is `cua-driver-rs-v0.5.5`, published on +2026-06-16. DeepChat support for this feature is limited to the targets that have upstream release +assets and have been validated for bundled plugin packaging: + +- macOS arm64 and x86_64, plus universal variants. +- Windows x86_64 and arm64. +- Linux x86_64. + +Linux arm64 remains unsupported for this DeepChat integration until upstream publishes and DeepChat +validates a matching release asset. Upstream documents Linux support as pre-release. DeepChat should +expose Linux support where the runtime asset exists, while keeping Linux limitations explicit in +docs and validation. + +## Goal + +Update the official DeepChat CUA plugin from the older macOS-only driver integration to the latest +cross-platform upstream CUA driver release, so packaged DeepChat builds can use computer-use tools +on macOS, Windows, and Linux without requiring user-managed MCP setup or manual CUA installation. + +## Non-Goals + +- Do not switch DeepChat to user-managed MCP configuration for CUA. +- Do not require PATH-installed `cua-driver` for the bundled plugin. +- Do not run upstream install or uninstall scripts at app runtime. +- Do not introduce auto-start services, scheduled tasks, or package-manager installation from + inside DeepChat. +- Do not claim Linux arm64 CUA support until that target is explicitly validated for DeepChat + packaging. +- Do not redesign the plugin host or the global tool permission model. + +## Platform Scope + +The implementation must support these packaged plugin targets: + +| DeepChat platform | DeepChat arch | Upstream asset status | Required behavior | +| --- | --- | --- | --- | +| `darwin` | `arm64` | Available | Bundle and verify CUA runtime | +| `darwin` | `x64` | Available | Bundle and verify CUA runtime | +| `win32` | `x64` | Available | Bundle and verify CUA runtime | +| `win32` | `arm64` | Available | Bundle and verify CUA runtime | +| `linux` | `x64` | Available | Bundle and verify CUA runtime | +| `linux` | `arm64` | Unsupported for DeepChat | Do not bundle or show CUA; fail clearly if requested directly | + +## Visibility Scope + +CUA support is target-based, not only platform-based. The plugin must be visible only for these +runtime targets: + +- `darwin/arm64` +- `darwin/x64` +- `win32/x64` +- `win32/arm64` +- `linux/x64` + +The plugin must not be visible as an official usable plugin on: + +- `linux/arm64` + +If the current plugin manifest can only express platform support, implementation must add an +arch-aware gate through manifest metadata, official-plugin discovery, or runtime support checks. +`engines.platforms` alone is not sufficient for CUA because Linux arm64 must stay hidden even though +the operating system is otherwise in scope. + +## Integration Contract + +DeepChat must continue to own the integration boundary: + +- The official plugin manifest or discovery layer declares the supported platform/arch targets and + bundled runtime candidates. +- The driver binary is started by DeepChat's plugin host through the existing plugin tool server + path. +- The user-facing capability remains "skill + built-in tool surface" inside DeepChat. +- The implementation may keep the internal stdio server transport, but it must not require users + to configure or install an external MCP server. +- Runtime detection must prefer plugin-local binaries and only use external fallback candidates for + diagnostics or development. + +## Upstream Runtime Contract + +Pin the CUA runtime to a specific upstream release: + +- Tag: `cua-driver-rs-v0.5.5`. +- Commit: `d6dea4bc3c3a65ce821261752067cae8200fe5d6`. +- Version: `0.5.5`. + +The build step must stage release artifacts instead of relying on local Swift-only source builds. +Every staged asset must be validated before packaging: + +- Download the expected release archive for the target platform and arch. +- Verify it against the upstream `checksums.txt` asset. +- Validate required files exist after extraction. +- Normalize executable permissions on POSIX targets. +- Validate the driver can be executed for a low-risk command such as `--version` when the host + platform and runtime loader can run the target binary. +- Keep macOS signing and helper-app validation in place where a `.app` bundle is staged. + +## Runtime Layout + +The packaged plugin should stage only the target runtime needed by the artifact being built: + +```text +plugins/cua/runtime/ + darwin/ + arm64/ + CuaDriver.app/Contents/MacOS/cua-driver + x64/ + CuaDriver.app/Contents/MacOS/cua-driver + win32/ + x64/ + cua-driver.exe + cua-driver-uia.exe + arm64/ + cua-driver.exe + cua-driver-uia.exe + linux/ + x64/ + cua-driver +``` + +If implementation inspection shows that DeepChat must keep the previous helper app display name, +the macOS app directory may remain `DeepChat Computer Use.app`, but the staged bundle must still +preserve a valid Info.plist, executable path, and code signature after any rename or re-sign step. + +## Tool Surface + +The plugin policy and skill docs must match upstream v0.5.5 tool names. + +Removed or renamed assumptions: + +- Do not expose `screenshot` as the primary capture tool. Upstream uses `get_window_state` with a + vision capture mode. +- Do not rely on `set_recording`. Recording is split into `start_recording`, + `stop_recording`, `get_recording_state`, `replay_trajectory`, and `install_ffmpeg`. + +Core tools expected across supported platforms include: + +- App and window discovery: `list_apps`, `list_windows`, `get_window_state`, + `get_accessibility_tree`. +- App and window actions: `launch_app`, `kill_app`, `bring_to_front`. +- Input actions: `click`, `double_click`, `right_click`, `drag`, `scroll`, `type_text`, + `press_key`, `hotkey`, `set_value`. +- Cursor tools: `get_screen_size`, `get_cursor_position`, `move_cursor`, + `set_agent_cursor_enabled`, `set_agent_cursor_motion`, `set_agent_cursor_style`, + `get_agent_cursor_state`. +- Configuration and permissions: `check_permissions`, `get_config`, `set_config`, + `check_for_update`. +- Session and recording lifecycle: `start_session`, `end_session`, `start_recording`, + `stop_recording`, `get_recording_state`, `replay_trajectory`, `install_ffmpeg`. + +Platform-specific tools may exist, such as Linux mouse-button primitives and Windows diagnostic +tools. Policies must classify these explicitly instead of leaving them to default approval rules. + +## Permission and Safety Requirements + +Tool policies must be exact and conservative: + +- Read-only discovery and status tools may be allowed automatically. +- User-visible input, app launch, app termination, window focus, recording, replay, config + mutation, and dependency installation must require user approval. +- Any newly detected upstream tool without a policy must be treated as a review failure in tests. + +Platform permission behavior must be explicit: + +- macOS keeps accessibility and screen-capture permission checks and helper-app permission UX. +- Windows must not show macOS TCC-specific instructions. +- Linux must communicate pre-release constraints and compositor/session limitations without + blocking supported tool startup when the driver reports usable status. + +## Packaging Requirements + +The packaged app must keep CUA usable after Electron packaging: + +- The `.dcplugin` artifact must contain the correct runtime subtree for its platform and arch. +- The packaged `.dcplugin` manifest must narrow `engines.targets` to the artifact's own + platform/arch target, even though the source manifest keeps the full supported target matrix. +- Runtime files must stay outside `app.asar`. +- Supported Windows archives must include `cua-driver-uia.exe` next to `cua-driver.exe`. +- Linux runtime files must retain executable permissions after package extraction. +- macOS helper bundles must pass bundle path, executable, and signing validation. +- `plugin:verify` must be able to verify CUA artifacts per supported platform and arch. +- CI and release workflows must bundle and verify CUA for supported Windows, macOS, and Linux + build targets. + +## Acceptance Criteria + +- Official CUA plugin metadata or discovery logic allows only the supported target matrix: + `darwin/arm64`, `darwin/x64`, `win32/x64`, `win32/arm64`, and `linux/x64`. +- Each target-specific CUA `.dcplugin` advertises only its own `engines.targets` entry, so + side-by-side artifacts cannot be selected on the wrong CPU architecture. +- Packaged macOS, Windows, and Linux x64 builds include a CUA `.dcplugin` artifact. +- Packaged Windows arm64 builds include a CUA `.dcplugin` artifact. +- Packaged Linux arm64 builds do not include a visible or usable CUA plugin. +- Direct CUA runtime packaging for Linux arm64 fails with a clear unsupported-target message. +- Official plugin visibility is gated by platform and arch, so the unsupported Linux arm target does + not show CUA as available. +- Unsupported sibling artifacts for the same plugin id are ignored during discovery without + disabling or uninstalling an installed artifact that supports the current target. +- The settings sidebar and settings routes expose the Plugins entry on supported CUA targets, not + only on macOS, while keeping unsupported CUA targets hidden. +- Runtime detection resolves the plugin-local binary on every supported target. +- The plugin starts through DeepChat's internal tool path without user-managed MCP setup. +- Optional MCP capabilities not implemented by the CUA driver, such as prompts and resources, are + treated as absent capabilities and must not produce error-level log spam. +- Skill docs describe DeepChat usage and platform caveats, not upstream manual installer workflows. +- Tool policies cover all upstream v0.5.5 tools known to this integration. +- Packaging docs and tests no longer describe CUA as macOS-only. +- Build, lint, i18n, and focused test suites pass after implementation. + +## Risks + +- Upstream release archive layouts may change. The staging script must validate layout and fail + closed. +- Cross-compiling the Rust driver locally is higher risk than consuming verified release assets. + The first implementation should prefer release assets. +- macOS helper-app rename or re-signing can break permissions. The implementation must verify the + staged bundle after any mutation. +- Linux support is upstream pre-release. DeepChat should support the available asset while keeping + limitations visible and testable. +- Tool names changed from the Swift-era integration. Missing policy updates could silently approve + or block the wrong tools. diff --git a/docs/features/cua-cross-platform-computer-use/tasks.md b/docs/features/cua-cross-platform-computer-use/tasks.md new file mode 100644 index 000000000..ce843c9dc --- /dev/null +++ b/docs/features/cua-cross-platform-computer-use/tasks.md @@ -0,0 +1,121 @@ +# CUA Cross-Platform Computer Use Tasks + +## Task List + +- [x] T01 - Update CUA upstream metadata + - Replace old Swift fork metadata with pinned `cua-driver-rs-v0.5.5` metadata. + - Record supported and unsupported platform/arch targets. + - Add expected upstream asset names and checksum source. + +- [x] T02 - Rewrite CUA runtime staging + - Replace macOS-only Swift build logic in `scripts/build-cua-plugin-runtime.mjs`. + - Add release asset download, checksum verification, extraction, layout validation, and runtime + copy. + - Add target mapping for darwin arm64/x64, win32 x64/arm64, and linux x64. + - Fail clearly for linux arm64. + +- [x] T03 - Validate staged runtime files + - Validate macOS helper app executable path and signing state. + - Validate Windows `cua-driver.exe` plus `cua-driver-uia.exe`. + - Validate Linux `cua-driver` and executable permissions. + - Add host-compatible `--version` smoke checks with a loader-version guard. + +- [x] T04 - Update CUA plugin manifest + - Expand support from macOS-only to the supported target matrix. + - Add or enforce arch-aware plugin visibility. + - Add platform-specific plugin-local runtime detect candidates. + - Keep CUA hidden on linux arm64. + - Update source URL pattern for platform and arch artifacts. + - Keep the DeepChat-owned internal tool server startup path. + +- [x] T05 - Update CUA tool policies + - Remove Swift-era `screenshot` and `set_recording` assumptions. + - Add policies for v0.5.5 read-only, action, recording, session, update, and platform-specific + tools. + - Add a test that fails when a known upstream tool lacks an explicit policy. + +- [x] T06 - Update plugin packaging + - Remove darwin-only CUA validation in `scripts/package-plugin.mjs`. + - Package only the selected `runtime//` subtree. + - Scope packaged target metadata to the selected `runtime//` subtree. + - Preserve POSIX executable permissions. + - Verify the `.dcplugin` artifact contains the expected files for each supported target. + +- [x] T07 - Update package scripts + - Add CUA build/bundle support for Windows x64/arm64 and Linux x64. + - Include CUA in supported Windows and Linux app build scripts. + - Keep Linux arm64 from bundling an unusable CUA plugin. + - Avoid unnecessary duplicate staging during bundle commands. + +- [x] T08 - Update CI and release workflows + - Bundle and verify CUA in macOS, Windows x64/arm64, and Linux x64 build jobs. + - Skip CUA for Linux arm64 jobs. + - Skip CUA only where the target is intentionally unsupported. + - Keep official plugin verification failing on missing expected artifacts. + +- [x] T09 - Update DeepChat skill docs + - Adapt upstream v0.5.5 skill guidance to DeepChat's bundled integration. + - Remove manual installer, PATH, and user-managed MCP setup language. + - Add macOS, Windows, and Linux platform caveats. + - Replace old tool names with v0.5.5 tool names. + +- [x] T10 - Update settings and permission status + - Keep macOS accessibility and screen-capture permission handling. + - Make Windows and Linux runtime status platform-aware. + - Show unsupported runtime status for linux arm64 rather than broken-install language. + - Avoid macOS-only instructions on non-macOS platforms. + +- [x] T11 - Update tests + - Update `test/main/presenter/pluginPresenter.test.ts` for cross-platform manifest behavior, + skill docs, metadata, and workflow expectations. + - Add or update package script tests for CUA target validation. + - Keep macOS signing tests focused on macOS helper behavior. + - Add negative tests for unsupported linux arm64 packaging and visibility. + +- [x] T12 - Update packaging documentation + - Update `docs/guides/plugin-packaging.md` so CUA is no longer described as macOS-only. + - Document platform/arch artifact expectations. + - Document the no-runtime-installer and plugin-local-runtime requirement. + +- [x] T13 - Run local verification + - Run formatting, i18n, lint, typecheck, and focused tests. + - Bundle and verify the Windows x64 CUA plugin on the current Windows host. + - Bundle and verify the Windows arm64 CUA plugin without running the non-host binary. + - Inspect the generated `.dcplugin` archive contents. + - On Linux hosts with an older glibc loader than the pinned upstream binary requires, verify that + staging still validates checksum, layout, file presence, and executable permissions. + +- [ ] T14 - Verify CI-only targets + - Use CI to validate macOS arm64/x64 packaging and signing. + - Use CI to validate Linux x64 packaging and executable permissions. + - Use CI to validate Windows x64/arm64 packaging. + - Confirm Linux arm64 jobs do not ship or show CUA. + +- [x] T15 - Prevent unsupported sibling cleanup + - Keep unsupported target artifacts from clearing installed state when a supported artifact for + the same plugin id exists. + - Add regression coverage for side-by-side CUA target artifacts with an active plugin-owned tool + server. + +- [x] T16 - Quiet unsupported optional MCP capabilities + - Treat `-32601 Unknown method` from prompts and resources list requests as unsupported optional + capabilities. + - Cache empty prompts/resources lists so CUA does not repeatedly emit error stack traces. + +## Implementation Order + +1. T01, T02, and T03 establish the runtime input and safety checks. +2. T04, T05, and T09 align the plugin contract with the new runtime. +3. T06 and T07 make local packaging produce correct artifacts. +4. T08 and T12 keep release infrastructure and documentation aligned. +5. T10 and T11 close platform UX and regression coverage. +6. T13 and T14 verify the final artifacts. + +## Done Definition + +- CUA `.dcplugin` artifacts are produced and verified for every supported target. +- Packaged DeepChat builds include CUA where the upstream runtime exists. +- DeepChat users can access computer-use capability through the built-in skill/tool path without + manual CUA setup. +- Unsupported targets fail clearly during packaging and do not ship broken plugins. +- Tests and docs reflect cross-platform support and current upstream tool names. diff --git a/docs/guides/plugin-packaging.md b/docs/guides/plugin-packaging.md index 6dfaf8a27..e37992626 100644 --- a/docs/guides/plugin-packaging.md +++ b/docs/guides/plugin-packaging.md @@ -80,31 +80,52 @@ step before packaging. The `bundle` action automatically detects and runs `scripts/build--plugin-runtime.mjs` when it exists. Standalone `package` expects the native runtime payload to be built already. -CUA native build commands (macOS-only, requires Swift toolchain): +CUA native runtime staging commands download pinned upstream release assets and verify their +checksums. They do not run upstream installers and do not require a PATH-installed `cua-driver`. ```bash -pnpm run plugin:cua:build # host architecture -pnpm run plugin:cua:build:mac:arm64 # explicit ARM64 -pnpm run plugin:cua:build:mac:x64 # explicit x64 +pnpm run plugin:cua:build # host platform and architecture +pnpm run plugin:cua:build:mac:arm64 # macOS arm64 +pnpm run plugin:cua:build:mac:x64 # macOS x64 +pnpm run plugin:cua:build:win:x64 # Windows x64 +pnpm run plugin:cua:build:win:arm64 # Windows arm64 +pnpm run plugin:cua:build:linux:x64 # Linux x64 ``` ## CUA Plugin Artifacts -The CUA plugin ships one macOS helper app per CPU architecture. The bundled package filename -includes both platform and architecture: +The CUA plugin is target-gated by platform and architecture. Supported bundled targets: + +- `darwin/arm64` +- `darwin/x64` +- `win32/x64` +- `win32/arm64` +- `linux/x64` + +Unsupported targets: + +- `linux/arm64` + +The bundled package filename includes both platform and architecture: ```text deepchat-plugin-cua--darwin-arm64.dcplugin deepchat-plugin-cua--darwin-x64.dcplugin +deepchat-plugin-cua--win32-x64.dcplugin +deepchat-plugin-cua--win32-arm64.dcplugin +deepchat-plugin-cua--linux-x64.dcplugin ``` Runtime detection inside the package uses architecture-specific paths: ```text -plugin:runtime/darwin//DeepChat Computer Use.app/Contents/MacOS/cua-driver +plugin:runtime/darwin//CuaDriver.app/Contents/MacOS/cua-driver +plugin:runtime/win32//cua-driver.exe +plugin:runtime/linux//cua-driver ``` -Each `.dcplugin` contains only the runtime directory for its target architecture. +Each `.dcplugin` contains only the runtime directory for its target platform and architecture. +Direct CUA packaging for unsupported targets fails before producing an artifact. ## Feishu Plugin Artifacts @@ -138,9 +159,10 @@ build/bundled-plugins/ The build matrix in `.github/workflows/build.yml` bundles plugins before running `electron-builder` on every platform: -- **macOS**: bundles both CUA (with native build) and feishu plugins. -- **Linux**: bundles feishu plugin only (CUA is macOS-only). -- **Windows**: bundles feishu plugin only. +- **macOS**: bundles both CUA and feishu plugins for arm64 and x64. +- **Linux x64**: bundles both CUA and feishu plugins. +- **Windows x64**: bundles both CUA and feishu plugins. +- **Windows arm64**: bundles both CUA and feishu plugins. Electron Builder embeds `.dcplugin` files from `build/bundled-plugins/` into: @@ -155,11 +177,14 @@ uploading artifacts. The release workflow (`.github/workflows/release.yml`) repeats the same steps. Final release uploads app artifacts only; `.dcplugin` files are not published as separate GitHub Release assets. -Expected embedded files (macOS example): +Expected embedded files across platform-specific app packages: ```text app.asar.unpacked/plugins/deepchat-plugin-cua--darwin-x64.dcplugin app.asar.unpacked/plugins/deepchat-plugin-cua--darwin-arm64.dcplugin +app.asar.unpacked/plugins/deepchat-plugin-cua--win32-x64.dcplugin +app.asar.unpacked/plugins/deepchat-plugin-cua--win32-arm64.dcplugin +app.asar.unpacked/plugins/deepchat-plugin-cua--linux-x64.dcplugin app.asar.unpacked/plugins/deepchat-plugin-feishu--darwin-x64.dcplugin app.asar.unpacked/plugins/deepchat-plugin-feishu--darwin-arm64.dcplugin ``` diff --git a/docs/issues/build-action-platform-failures/plan.md b/docs/issues/build-action-platform-failures/plan.md new file mode 100644 index 000000000..17cb7b629 --- /dev/null +++ b/docs/issues/build-action-platform-failures/plan.md @@ -0,0 +1,21 @@ +# Build Action Platform Failures Plan + +## Changes + +- Update the ACP registry fetcher to use Node's `https` module and sequential icon downloads so the + Windows arm64 build avoids the current built-in fetch crash path. +- Add a Linux glibc loader-mismatch branch to the CUA runtime smoke check. The staging script keeps + all file validation and skips only the host execution check when the runner cannot load the + target binary. +- Run the Windows build step under bash so each command exits immediately on failure. +- Add a local `vuedraggable` module declaration so `vue-tsgo` has a stable type source on macOS + arm64 runners. +- Add focused textual regression checks for the build scripts and workflow. + +## Verification + +- `pnpm run format` +- `pnpm run i18n` +- `pnpm run lint` +- `pnpm test -- test/main/presenter/pluginPresenter.test.ts` +- `pnpm run plugin:bundle -- --name cua --platform linux --arch x64` diff --git a/docs/issues/build-action-platform-failures/spec.md b/docs/issues/build-action-platform-failures/spec.md new file mode 100644 index 000000000..1b38c033a --- /dev/null +++ b/docs/issues/build-action-platform-failures/spec.md @@ -0,0 +1,42 @@ +# Build Action Platform Failures Spec + +## Status + +In progress. + +## Goal + +Restore the manual Build Application workflow for the current CUA cross-platform branch so the +Windows arm64 and Linux x64 jobs can produce packaged artifacts for maintainer verification. + +## Background + +GitHub Actions run `27634409921` failed on two jobs: + +- `build-windows(arm64)` crashed during `scripts/fetch-acp-registry.mjs` before `pnpm run build` + produced `out/main/index.js`; the PowerShell multi-line step then continued into packaging and + reported a secondary missing-entry asar error. +- `build-linux (x64)` staged the CUA runtime but failed the executable smoke check because the + upstream Linux binary requires `GLIBC_2.39`, while the Ubuntu 22.04 runner provides an older + loader. +- The follow-up run `27636722380` passed Windows x64, Windows arm64, and Linux x64, then failed + `build-mac (arm64)` during `vue-tsgo` because `vuedraggable` module typing was not resolved on + that runner. + +## Acceptance Criteria + +- Windows arm64 build steps stop at the first failing command and surface the real failure. +- `scripts/fetch-acp-registry.mjs` avoids the Windows arm64 registry-fetch crash path while still + refreshing the registry and cached icons. +- Linux x64 CUA runtime staging still validates checksum, archive layout, executable presence, and + permissions. +- Linux x64 CUA runtime smoke checks run when the host loader can execute the binary and skip only + for a detected glibc loader-version mismatch. +- macOS arm64 typecheck resolves `vuedraggable` for the existing draggable list components. +- The Build Application workflow can be pushed again for maintainer validation. + +## Non-Goals + +- Change the pinned CUA upstream release. +- Change the packaged Linux runner baseline. +- Redesign ACP registry runtime loading. diff --git a/docs/issues/build-action-platform-failures/tasks.md b/docs/issues/build-action-platform-failures/tasks.md new file mode 100644 index 000000000..e5c339902 --- /dev/null +++ b/docs/issues/build-action-platform-failures/tasks.md @@ -0,0 +1,10 @@ +# Build Action Platform Failures Tasks + +- [x] Inspect failed GitHub Actions logs. +- [x] Update ACP registry build-time fetch behavior. +- [x] Update CUA Linux smoke-check behavior. +- [x] Make Windows build workflow fail fast. +- [x] Add focused regression coverage. +- [x] Run local verification. +- [x] Add stable `vuedraggable` type resolution for macOS arm64 CI. +- [x] Push the branch to trigger a new Build Application workflow. diff --git a/docs/issues/cua-windows-launch-timeout-permissions/plan.md b/docs/issues/cua-windows-launch-timeout-permissions/plan.md new file mode 100644 index 000000000..0b1e02494 --- /dev/null +++ b/docs/issues/cua-windows-launch-timeout-permissions/plan.md @@ -0,0 +1,36 @@ +# Plan + +## Diagnosis + +Local packaged CUA `cua-driver.exe mcp` can list tools and run `launch_app` when the target is +resolvable. On Windows, `launch_app` waits for the MCP SDK default timeout when called with +unresolvable names or macOS-style bundle ids. The settings-page permission failure is a DeepChat +parsing and presentation issue: Windows `check_permissions` returns JSON with `post_message`, +`uia`, elevation, and integrity fields rather than macOS Accessibility and Screen Recording text. + +## Implementation + +- Add a CUA-specific launch guard in `ToolManager` for plugin-owned + `com.deepchat.plugins.cua` servers on Windows. +- Before dispatching `launch_app`, normalize Windows path-like `bundle_id` values to `path`. +- For `name` or plain `bundle_id` requests, call `list_apps` and match against known Windows app + identifiers before dispatch. If there is no match, return a tool error immediately. +- Extend CUA runtime permission results with `platform` and a diagnostics object. +- Parse JSON from non-macOS `check_permissions` output. +- Update the CUA settings page to render platform-specific rows: + - macOS: Accessibility, Screen Recording + - Windows: UI Automation, PostMessage, Integrity Level, Elevated + - Linux: permission check unavailable or runtime diagnostics + +## Test Strategy + +- Unit test the CUA launch guard in `ToolManager`. +- Unit test Windows JSON permission parsing in `PluginPresenter`. +- Run focused tests for touched presenters. +- Run project-required quality gates after implementation: format, i18n, lint. + +## Compatibility + +Existing macOS CUA permission probe and existing CUA tool names remain unchanged. The Windows guard +only intercepts unresolved or platform-mismatched `launch_app` inputs that previously hung. + diff --git a/docs/issues/cua-windows-launch-timeout-permissions/spec.md b/docs/issues/cua-windows-launch-timeout-permissions/spec.md new file mode 100644 index 000000000..544eee1c1 --- /dev/null +++ b/docs/issues/cua-windows-launch-timeout-permissions/spec.md @@ -0,0 +1,42 @@ +# CUA Windows Launch Timeout And Permission Diagnostics + +## Problem + +Packaged CUA on Windows can connect and expose tools, but `launch_app` may hang until the MCP SDK +request timeout when the model supplies an app identifier that the Windows driver cannot resolve. +The CUA plugin settings page also presents macOS permission labels on Windows and turns Windows +permission diagnostics into a generic failure message. + +## User Stories + +- As a Windows user, I want invalid or platform-mismatched `launch_app` arguments to fail quickly + with actionable guidance instead of waiting for `MCP error -32001: Request timed out`. +- As a Windows or Linux user, I want the CUA settings page to show platform-relevant diagnostics + instead of macOS Accessibility and Screen Recording checks. +- As a macOS user, I want the existing helper permission flow to keep working unchanged. + +## Acceptance Criteria + +- Windows CUA `launch_app` calls are preflighted before dispatching to the MCP driver when the + request uses a free-form `name` or non-AUMID `bundle_id`. +- Windows desktop app paths carried in `bundle_id` are normalized to the Windows `path` argument + before calling the driver. +- Windows unresolved app names or macOS-style bundle ids return an immediate tool error that tells + the agent to call `list_apps` and use `name`, `path`, `launch_path`, or `aumid`. +- CUA permission checks return platform-specific fields for Windows and Linux without marking a + successful Windows JSON check as a failure. +- The settings page renders platform-specific permission/diagnostic labels and messages. +- Tests cover Windows launch preflight and permission parsing behavior. + +## Non-Goals + +- Modify upstream `trycua/cua` binaries. +- Replace the plugin-owned MCP transport with a non-MCP tool host. +- Add new CUA-supported platforms beyond the current support matrix. + +## Constraints + +- Keep changes scoped to the CUA integration and generic MCP wrapper behavior needed by CUA. +- Do not expose plugin-owned CUA MCP servers in the normal MCP settings UI. +- Preserve macOS permission probe behavior. + diff --git a/docs/issues/cua-windows-launch-timeout-permissions/tasks.md b/docs/issues/cua-windows-launch-timeout-permissions/tasks.md new file mode 100644 index 000000000..1f1852901 --- /dev/null +++ b/docs/issues/cua-windows-launch-timeout-permissions/tasks.md @@ -0,0 +1,8 @@ +# Tasks + +- [x] T1 Document packaged CUA Windows launch timeout and platform diagnostics requirements. +- [x] T2 Add Windows CUA `launch_app` preflight and argument normalization. +- [x] T3 Parse and return platform-specific runtime permission diagnostics. +- [x] T4 Update CUA settings page rendering for macOS, Windows, and Linux. +- [x] T5 Add focused tests for launch guard and Windows permission parsing. +- [x] T6 Run verification commands and summarize residual risks. diff --git a/package.json b/package.json index afdc9fdbc..7651698f9 100644 --- a/package.json +++ b/package.json @@ -45,17 +45,20 @@ "plugin:verify": "node scripts/plugin.mjs verify", "plugin:bundle:clean": "node -e \"require('fs').rmSync('build/bundled-plugins',{recursive:true,force:true})\"", "plugin:cua:build": "node scripts/build-cua-plugin-runtime.mjs", - "plugin:cua:build:mac:arm64": "node scripts/build-cua-plugin-runtime.mjs --arch arm64", - "plugin:cua:build:mac:x64": "node scripts/build-cua-plugin-runtime.mjs --arch x64", + "plugin:cua:build:mac:arm64": "node scripts/build-cua-plugin-runtime.mjs --platform darwin --arch arm64", + "plugin:cua:build:mac:x64": "node scripts/build-cua-plugin-runtime.mjs --platform darwin --arch x64", + "plugin:cua:build:win:x64": "node scripts/build-cua-plugin-runtime.mjs --platform win32 --arch x64", + "plugin:cua:build:win:arm64": "node scripts/build-cua-plugin-runtime.mjs --platform win32 --arch arm64", + "plugin:cua:build:linux:x64": "node scripts/build-cua-plugin-runtime.mjs --platform linux --arch x64", "install:sharp": "node scripts/install-sharp-for-platform.js", - "build:mac": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:cua:build && pnpm run plugin:bundle -- --name cua --platform darwin && pnpm run plugin:bundle -- --name feishu --platform darwin && electron-builder --mac", - "build:mac:arm64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:cua:build:mac:arm64 && pnpm run plugin:bundle -- --name cua --platform darwin --arch arm64 && pnpm run plugin:bundle -- --name feishu --platform darwin --arch arm64 && electron-builder --mac --arm64", - "build:mac:x64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:cua:build:mac:x64 && pnpm run plugin:bundle -- --name cua --platform darwin --arch x64 && pnpm run plugin:bundle -- --name feishu --platform darwin --arch x64 && electron-builder --mac --x64", - "build:win": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name feishu --platform win32 && electron-builder --win", - "build:win:x64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name feishu --platform win32 --arch x64 && electron-builder --win --x64", - "build:win:arm64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name feishu --platform win32 --arch arm64 && electron-builder --win --arm64", - "build:linux": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name feishu --platform linux && electron-builder --linux", - "build:linux:x64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name feishu --platform linux --arch x64 && electron-builder --linux --x64", + "build:mac": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform darwin && pnpm run plugin:bundle -- --name feishu --platform darwin && electron-builder --mac", + "build:mac:arm64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform darwin --arch arm64 && pnpm run plugin:bundle -- --name feishu --platform darwin --arch arm64 && electron-builder --mac --arm64", + "build:mac:x64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform darwin --arch x64 && pnpm run plugin:bundle -- --name feishu --platform darwin --arch x64 && electron-builder --mac --x64", + "build:win": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform win32 && pnpm run plugin:bundle -- --name feishu --platform win32 && electron-builder --win", + "build:win:x64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform win32 --arch x64 && pnpm run plugin:bundle -- --name feishu --platform win32 --arch x64 && electron-builder --win --x64", + "build:win:arm64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform win32 --arch arm64 && pnpm run plugin:bundle -- --name feishu --platform win32 --arch arm64 && electron-builder --win --arm64", + "build:linux": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform linux && pnpm run plugin:bundle -- --name feishu --platform linux && electron-builder --linux", + "build:linux:x64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name cua --platform linux --arch x64 && pnpm run plugin:bundle -- --name feishu --platform linux --arch x64 && electron-builder --linux --x64", "build:linux:arm64": "pnpm run build && pnpm run plugin:bundle:clean && pnpm run plugin:bundle -- --name feishu --platform linux --arch arm64 && electron-builder --linux --arm64", "afterSign": "scripts/notarize.js", "installRuntime": "npx -y tiny-runtime-injector --type uv --dir ./runtime/uv --runtime-version 0.9.18 && npx -y tiny-runtime-injector --type node --dir ./runtime/node && npx -y tiny-runtime-injector --type rtk --dir ./runtime/rtk", diff --git a/plugins/cua/plugin.json b/plugins/cua/plugin.json index 1f63223fc..cd84fe753 100644 --- a/plugins/cua/plugin.json +++ b/plugins/cua/plugin.json @@ -5,7 +5,8 @@ "publisher": "DeepChat", "engines": { "deepchat": ">=${app.version}", - "platforms": ["darwin"] + "platforms": ["darwin", "win32", "linux"], + "targets": ["darwin/arm64", "darwin/x64", "win32/x64", "win32/arm64", "linux/x64"] }, "activationEvents": ["onEnable"], "capabilities": [ @@ -18,7 +19,7 @@ ], "source": { "type": "deepchat-official", - "url": "${github.release.download}/deepchat-plugin-cua-${app.version}-darwin-${arch}.dcplugin", + "url": "${github.release.download}/deepchat-plugin-cua-${app.version}-${target.platform}-${arch}.dcplugin", "publisher": "DeepChat" }, "runtime": { @@ -26,14 +27,16 @@ "type": "external-helper", "displayName": "Cua Driver", "detect": [ - "plugin:runtime/darwin/${arch}/DeepChat Computer Use.app/Contents/MacOS/cua-driver", + "plugin:runtime/darwin/${arch}/CuaDriver.app/Contents/MacOS/cua-driver", + "plugin:runtime/win32/${arch}/cua-driver.exe", + "plugin:runtime/linux/${arch}/cua-driver", "/Applications/CuaDriver.app/Contents/MacOS/cua-driver" ], "install": { "mode": "user-confirmed", "provider": "trycua", "strategy": "bundled-plugin-helper", - "minVersion": "0.1.0", + "minVersion": "0.5.5", "guideUrl": "https://cua.ai/docs/cua-driver/guide/getting-started/installation" } }, @@ -77,24 +80,37 @@ "list_windows": "allow", "get_screen_size": "allow", "get_window_state": "allow", + "get_accessibility_tree": "allow", "get_cursor_position": "allow", "get_config": "allow", "get_recording_state": "allow", "get_agent_cursor_state": "allow", - "screenshot": "allow", + "check_for_update": "allow", + "debug_window_info": "allow", + "start_session": "allow", + "end_session": "allow", "launch_app": "ask", + "kill_app": "ask", + "bring_to_front": "ask", "click": "ask", "right_click": "ask", "double_click": "ask", "drag": "ask", + "mouse_button_down": "ask", + "mouse_button_up": "ask", + "mouse_drag": "ask", + "parallel_mouse_drag": "ask", "scroll": "ask", "move_cursor": "ask", "type_text": "ask", + "type_text_chars": "ask", "press_key": "ask", "hotkey": "ask", "set_value": "ask", "set_config": "ask", - "set_recording": "ask", + "start_recording": "ask", + "stop_recording": "ask", + "install_ffmpeg": "ask", "set_agent_cursor_enabled": "ask", "set_agent_cursor_motion": "ask", "set_agent_cursor_style": "ask", diff --git a/plugins/cua/policies/tool-policy.json b/plugins/cua/policies/tool-policy.json index 54ab10168..167e1d685 100644 --- a/plugins/cua/policies/tool-policy.json +++ b/plugins/cua/policies/tool-policy.json @@ -6,24 +6,37 @@ "list_windows": "allow", "get_screen_size": "allow", "get_window_state": "allow", + "get_accessibility_tree": "allow", "get_cursor_position": "allow", "get_config": "allow", "get_recording_state": "allow", "get_agent_cursor_state": "allow", - "screenshot": "allow", + "check_for_update": "allow", + "debug_window_info": "allow", + "start_session": "allow", + "end_session": "allow", "launch_app": "ask", + "kill_app": "ask", + "bring_to_front": "ask", "click": "ask", "right_click": "ask", "double_click": "ask", "drag": "ask", + "mouse_button_down": "ask", + "mouse_button_up": "ask", + "mouse_drag": "ask", + "parallel_mouse_drag": "ask", "scroll": "ask", "move_cursor": "ask", "type_text": "ask", + "type_text_chars": "ask", "press_key": "ask", "hotkey": "ask", "set_value": "ask", "set_config": "ask", - "set_recording": "ask", + "start_recording": "ask", + "stop_recording": "ask", + "install_ffmpeg": "ask", "set_agent_cursor_enabled": "ask", "set_agent_cursor_motion": "ask", "set_agent_cursor_style": "ask", diff --git a/plugins/cua/settings/assets/index.css b/plugins/cua/settings/assets/index.css index d7cb089c5..04ab08004 100644 --- a/plugins/cua/settings/assets/index.css +++ b/plugins/cua/settings/assets/index.css @@ -97,6 +97,17 @@ h1 { border-top: 0; } +.section-title { + min-height: 36px; + padding: 10px 12px 8px; + border-bottom: 1px solid #e5e5df; + color: #52525b; + font-size: 12px; + font-weight: 800; + letter-spacing: 0; + text-transform: uppercase; +} + .row span { color: #52525b; font-size: 13px; @@ -199,6 +210,11 @@ button.danger:hover { border-color: #2f2f33; } + .section-title { + border-color: #2f2f33; + color: #a1a1aa; + } + .row span, .message, .eyebrow, diff --git a/plugins/cua/settings/assets/index.js b/plugins/cua/settings/assets/index.js index ddcb89ac4..403ce24a7 100644 --- a/plugins/cua/settings/assets/index.js +++ b/plugins/cua/settings/assets/index.js @@ -1,14 +1,18 @@ const stateNode = document.getElementById('plugin-state') const runtimeStateNode = document.getElementById('runtime-state') const runtimeVersionNode = document.getElementById('runtime-version') +const runtimePlatformNode = document.getElementById('runtime-platform') const runtimeCommandNode = document.getElementById('runtime-command') const runtimeHelperAppNode = document.getElementById('runtime-helper-app') const mcpStateNode = document.getElementById('mcp-state') -const accessibilityNode = document.getElementById('permission-accessibility') -const screenRecordingNode = document.getElementById('permission-screen-recording') +const diagnosticsTitleNode = document.getElementById('diagnostics-title') +const diagnosticsRowsNode = document.getElementById('diagnostics-rows') const messageNode = document.getElementById('message') const projectLinkNode = document.getElementById('project-link') +let currentPlatform = 'unknown' +let currentArch = 'unknown' + function setText(node, value) { if (node) { node.textContent = value || 'Unknown' @@ -29,45 +33,156 @@ function setState(enabled) { stateNode.className = enabled ? 'state state-ok' : 'state state-muted' } -function setPermissionStatus(node, value) { - if (!node) { - return +function getPluginApi() { + const api = window.deepchatPlugin + if (!api) { + throw new Error( + 'DeepChat plugin settings bridge is unavailable. Restart DeepChat and reopen this page.' + ) } + return api +} +function normalizeStatus(value) { const normalized = String(value || '').toLowerCase() if (normalized === 'granted') { - node.textContent = 'Granted' - node.className = 'permission-pill permission-ok' + return { text: 'Granted', className: 'permission-pill permission-ok' } + } + if (normalized === 'missing' || normalized === 'denied' || normalized === 'deny') { + return { text: 'Denied', className: 'permission-pill permission-denied' } + } + if (normalized === 'available' || normalized === 'ready' || normalized === 'ok') { + return { text: 'Ready', className: 'permission-pill permission-ok' } + } + if (normalized === 'unavailable' || normalized === 'failed') { + return { text: 'Unavailable', className: 'permission-pill permission-denied' } + } + return { text: value || 'Unknown', className: 'permission-pill permission-muted' } +} + +function createRow(label, value, statusValue) { + const row = document.createElement('div') + row.className = 'row' + + const labelNode = document.createElement('span') + labelNode.textContent = label + row.appendChild(labelNode) + + const valueNode = document.createElement('strong') + const status = normalizeStatus(statusValue || value) + valueNode.textContent = status.text + valueNode.className = status.className + row.appendChild(valueNode) + + return row +} + +function renderDiagnostics(title, rows) { + if (diagnosticsTitleNode) { + diagnosticsTitleNode.textContent = title + } + if (!diagnosticsRowsNode) { return } + diagnosticsRowsNode.textContent = '' + for (const row of rows) { + diagnosticsRowsNode.appendChild(createRow(row.label, row.value, row.status)) + } +} - if (normalized === 'missing' || normalized === 'denied' || normalized === 'deny') { - node.textContent = 'Denied' - node.className = 'permission-pill permission-denied' +function renderInitialDiagnostics(platform) { + if (platform === 'darwin') { + renderDiagnostics('macOS Permissions', [ + { label: 'Accessibility', value: 'Run Check' }, + { label: 'Screen Recording', value: 'Run Check' } + ]) return } + if (platform === 'win32') { + renderDiagnostics('Windows Diagnostics', [ + { label: 'UI Automation', value: 'Run Check' }, + { label: 'PostMessage', value: 'Run Check' }, + { label: 'Integrity Level', value: 'Run Check' }, + { label: 'Elevated', value: 'Run Check' } + ]) + return + } + if (platform === 'linux') { + renderDiagnostics('Linux Diagnostics', [{ label: 'Runtime Check', value: 'Run Check' }]) + return + } + renderDiagnostics('Diagnostics', [{ label: 'Runtime Check', value: 'Run Check' }]) +} - node.textContent = 'Unavailable' - node.className = 'permission-pill permission-muted' +function asRecord(value) { + return value && typeof value === 'object' && !Array.isArray(value) ? value : {} } -function getPluginApi() { - const api = window.deepchatPlugin - if (!api) { - throw new Error( - 'DeepChat plugin settings bridge is unavailable. Restart DeepChat and reopen this page.' - ) +function formatBoolean(value) { + if (typeof value !== 'boolean') { + return 'Unknown' } - return api + return value ? 'Yes' : 'No' +} + +function renderPermissionResult(data) { + const record = asRecord(data) + const platform = String(record.platform || currentPlatform) + const diagnostics = asRecord(record.diagnostics) + + if (platform === 'darwin') { + renderDiagnostics('macOS Permissions', [ + { label: 'Accessibility', value: record.accessibility }, + { label: 'Screen Recording', value: record.screenRecording } + ]) + return + } + + if (platform === 'win32') { + renderDiagnostics('Windows Diagnostics', [ + { label: 'UI Automation', value: record.uia }, + { label: 'PostMessage', value: record.postMessage }, + { + label: 'Integrity Level', + value: diagnostics.integrity_level || diagnostics.integrityLevel || 'Unknown' + }, + { label: 'Elevated', value: formatBoolean(diagnostics.elevated) } + ]) + return + } + + if (platform === 'linux') { + renderDiagnostics('Linux Diagnostics', [ + { + label: 'Runtime Check', + value: record.error ? 'Unavailable' : 'Ready', + status: record.error ? 'unavailable' : 'ready' + } + ]) + return + } + + renderDiagnostics('Diagnostics', [ + { + label: 'Runtime Check', + value: record.error ? 'Unavailable' : 'Ready', + status: record.error ? 'unavailable' : 'ready' + } + ]) } async function refreshStatus() { const status = await getPluginApi().getStatus() + currentPlatform = status.platform || 'unknown' + currentArch = status.arch || 'unknown' + setState(status.enabled) setText(runtimeStateNode, status.runtime?.state) setText(runtimeVersionNode, status.runtime?.version) + setText(runtimePlatformNode, `${currentPlatform}/${currentArch}`) setText(runtimeCommandNode, status.runtime?.command) - setText(runtimeHelperAppNode, status.runtime?.helperAppPath) + setText(runtimeHelperAppNode, status.runtime?.helperAppPath || 'Not required on this platform') + renderInitialDiagnostics(currentPlatform) const cuaMcp = status.mcpServers?.find((server) => server.serverId === 'cua-driver') if (!cuaMcp) { @@ -89,7 +204,7 @@ async function refreshStatus() { } async function checkPermissions() { - setMessage('Checking permissions...') + setMessage('Checking diagnostics...') const result = await getPluginApi().invokeAction('runtime.checkPermissions') if (!result.ok || !result.data) { console.error('[CUA Settings] Permission check failed:', result) @@ -97,8 +212,7 @@ async function checkPermissions() { return } - setPermissionStatus(accessibilityNode, result.data.accessibility) - setPermissionStatus(screenRecordingNode, result.data.screenRecording) + renderPermissionResult(result.data) if (result.data.error) { console.warn('[CUA Settings] Permission check returned diagnostics:', result.data) setMessage(result.data.error) diff --git a/plugins/cua/settings/index.html b/plugins/cua/settings/index.html index 068293d4f..22e897b7e 100644 --- a/plugins/cua/settings/index.html +++ b/plugins/cua/settings/index.html @@ -29,6 +29,10 @@

CUA Computer Use Runtime

Version Unknown +
+ Platform + Unknown +
Command Unknown @@ -44,14 +48,8 @@

CUA Computer Use Runtime

-
- Accessibility - Unknown -
-
- Screen Recording - Unknown -
+
Permissions
+