Computer use CLI for AI agents
Rust accessibilityaccessibility-apiai-agentsautomationclicomputer-usecomputer-use-agentcomputer-use-agentsdesktop-automationmacosmcprust
fix: make native installs independent of postinstall (#312)
Lahfir5a65c049a57d
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 302cd98c9..cc8e9fb90 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -198,7 +198,8 @@ jobs:- name: NPM package contentsrun: |- node --test tests/npm/*.test.js+ node --test tests/npm/*.test.js tests/release/*.test.js+ node scripts/check-npm-package.js- name: NPM wrapper smokerun: scripts/ci-npm-wrapper-smoke.shdiff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.ymlnew file mode 100644index 000000000..918aa4b54--- /dev/null+++ b/.github/workflows/homebrew.yml@@ -0,0 +1,35 @@+name: Homebrew++on:+ push:+ branches: [main]+ paths: ["Formula/**", ".github/workflows/homebrew.yml"]+ pull_request:+ paths: ["Formula/**", ".github/workflows/homebrew.yml"]+ workflow_dispatch:++permissions:+ contents: read++jobs:+ install:+ name: Fresh Homebrew install+ runs-on: macos-latest+ timeout-minutes: 15+ env:+ HOMEBREW_NO_AUTO_UPDATE: "1"+ HOMEBREW_NO_INSTALL_CLEANUP: "1"+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ - name: Install and test native formula+ run: |+ set -euo pipefail+ brew tap-new lahfir/agent-desktop-ci+ cp Formula/agent-desktop.rb "$(brew --repo lahfir/agent-desktop-ci)/Formula/agent-desktop.rb"+ brew install lahfir/agent-desktop-ci/agent-desktop+ brew test lahfir/agent-desktop-ci/agent-desktop+ formula_prefix=$(brew --prefix lahfir/agent-desktop-ci/agent-desktop)+ env -i PATH=/usr/bin:/bin "$formula_prefix/bin/agent-desktop" version+ test -x "$formula_prefix/bin/agent-desktop-macos-helper"diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 6f42f5e8c..a3c304d68 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -1,37 +1,10 @@name: Releaseon:- push:- branches: [main]workflow_dispatch:- inputs:- tag_name:- description: Release tag to build and publish, for example v0.2.0- required: true- type: string- version:- description: Semver version without the v prefix, for example 0.2.0- required: true- type: string- publish_npm:- description: Publish the npm package after GitHub assets are uploaded- required: true- default: true- type: boolean- publish_skills:- description: Publish skills after the release is built- required: true- default: true- type: boolean- allow_republish:- description: Replace the assets of a release that already carries them- required: false- default: false- type: boolean--# One release run per commit — never cancel, just queue.+concurrency:- group: release-${{ github.sha }}+ group: release# Deny all permissions at workflow level; each job declares only what it needs.permissions: {}@@ -40,99 +13,45 @@ env:CARGO_TERM_COLOR: alwaysjobs:- release-please:- name: Release Please+ check-release:+ name: Check for new versionruns-on: ubuntu-latesttimeout-minutes: 10permissions:contents: write- pull-requests: writeoutputs:- release_created: ${{ steps.release.outputs.release_created || steps.manual.outputs.release_created }}- tag_name: ${{ steps.release.outputs.tag_name || steps.manual.outputs.tag_name }}- version: ${{ steps.release.outputs.major && format('{0}.{1}.{2}', steps.release.outputs.major, steps.release.outputs.minor, steps.release.outputs.patch) || steps.manual.outputs.version }}- publish_npm: ${{ steps.manual.outputs.publish_npm || 'true' }}- publish_skills: ${{ steps.manual.outputs.publish_skills || steps.release.outputs.release_created }}- allow_republish: ${{ steps.manual.outputs.allow_republish || 'false' }}+ tag_name: ${{ steps.prepare.outputs.tag_name }}+ version: ${{ steps.prepare.outputs.version }}+ source_sha: ${{ steps.prepare.outputs.source_sha }}+ should_release: ${{ steps.prepare.outputs.should_release }}+ needs_github_release: ${{ steps.prepare.outputs.needs_github_release }}steps:- - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0- if: github.event_name != 'workflow_dispatch'- id: release- with:- config-file: release-please-config.json- manifest-file: .release-please-manifest.json-- - name: Use manual release inputs- if: github.event_name == 'workflow_dispatch'- id: manual+ - name: Require mainenv:- TAG_NAME: ${{ inputs.tag_name }}- VERSION: ${{ inputs.version }}- PUBLISH_NPM: ${{ inputs.publish_npm }}- PUBLISH_SKILLS: ${{ inputs.publish_skills }}- ALLOW_REPUBLISH: ${{ inputs.allow_republish }}- run: |- if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then- echo "Invalid version: ${VERSION}" >&2- exit 1- fi- if [[ "$TAG_NAME" != "v${VERSION}" ]]; then- echo "Tag ${TAG_NAME} must match version ${VERSION}" >&2+ RELEASE_REF: ${{ github.ref }}+ run: |+ if [ "$RELEASE_REF" != "refs/heads/main" ]; then+ echo "Release must run from main" >&2exit 1fi- {- echo "release_created=true"- echo "tag_name=${TAG_NAME}"- echo "version=${VERSION}"- echo "publish_npm=${PUBLISH_NPM}"- echo "publish_skills=${PUBLISH_SKILLS}"- echo "allow_republish=${ALLOW_REPUBLISH}"- } >> "$GITHUB_OUTPUT"-- - name: Sync Cargo.lock on release PR- if: github.event_name != 'workflow_dispatch' && steps.release.outputs.release_created != 'true'++ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ fetch-depth: 0+ ref: ${{ github.sha }}++ - name: Validate release metadata and create immutable tag+ id: prepareenv:GH_TOKEN: ${{ github.token }}GH_REPO: ${{ github.repository }}- run: |- set -euo pipefail- BRANCH="release-please--branches--main--components--agent-desktop"- OPEN_RELEASE_PRS=$(gh pr list \- --head "$BRANCH" \- --state open \- --json number \- --jq 'length')- if [ "$OPEN_RELEASE_PRS" = "0" ]; then- echo "No open release PR branch to sync"- exit 0- fi-- git init -b main release-pr- cd release-pr- git remote add origin "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git"- git fetch --depth=1 origin "$BRANCH"- git checkout -B "$BRANCH" FETCH_HEAD-- rustup show- VERSION=$(sed -n 's/.*version *= *"\([^"]*\)".*/\1/p' Cargo.toml | head -1)- cargo update -p agent-desktop --precise "$VERSION"- scripts/check-release-consistency.sh-- if git diff --quiet -- Cargo.lock; then- echo "Cargo.lock already matches release version ${VERSION}"- exit 0- fi-- git config user.name "github-actions[bot]"- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"- git add Cargo.lock- git commit -m "chore: sync cargo lock for release ${VERSION}"- git push origin "HEAD:${BRANCH}"+ run: bash scripts/prepare-release.shbuild:name: Build (${{ matrix.target }})- needs: release-please- if: needs.release-please.outputs.release_created == 'true'+ needs: check-release+ if: needs.check-release.outputs.should_release == 'true' || needs.check-release.outputs.needs_github_release == 'true'runs-on: ${{ matrix.runner }}container: ${{ matrix.container }}timeout-minutes: 30@@ -170,7 +89,15 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false- ref: ${{ needs.release-please.outputs.tag_name }}+ fetch-depth: 0+ ref: ${{ github.sha }}++ - name: Verify and select release source+ shell: bash+ env:+ RELEASE_SOURCE_SHA: ${{ needs.check-release.outputs.source_sha }}+ RELEASE_WORKFLOW_SHA: ${{ github.sha }}+ run: bash scripts/checkout-release-source.sh- name: Install rustup (container)if: runner.os == 'Linux'@@ -194,16 +121,6 @@ jobs:rustup showrustup target add ${{ matrix.target }}- - name: Cache cargo registry- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0- with:- path: |- ~/.cargo/registry/index/- ~/.cargo/registry/cache/- ~/.cargo/git/db/- key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock', 'Cargo.toml', 'crates/**/Cargo.toml', 'src/Cargo.toml') }}- restore-keys: ${{ runner.os }}-${{ matrix.target }}-cargo--- name: Build release binary (macOS)if: runner.os == 'macOS'run: |@@ -294,7 +211,7 @@ jobs:- name: Create tarball (macOS)if: runner.os == 'macOS'env:- VERSION: ${{ needs.release-please.outputs.version }}+ VERSION: ${{ needs.check-release.outputs.version }}run: |TARBALL="agent-desktop-v${VERSION}-${{ matrix.target }}.tar.gz"BINARY="target/${{ matrix.target }}/release/agent-desktop"@@ -319,7 +236,7 @@ jobs:if: runner.os == 'Linux'shell: bashenv:- VERSION: ${{ needs.release-please.outputs.version }}+ VERSION: ${{ needs.check-release.outputs.version }}run: |TARBALL="agent-desktop-v${VERSION}-${{ matrix.target }}.tar.gz"DIR="target/${{ matrix.target }}/release"@@ -338,7 +255,7 @@ jobs:if: runner.os == 'Windows'shell: pwshenv:- VERSION: ${{ needs.release-please.outputs.version }}+ VERSION: ${{ needs.check-release.outputs.version }}run: |$tarball = "agent-desktop-v${env:VERSION}-${{ matrix.target }}.tar.gz"& tar -czf $tarball -C "target/${{ matrix.target }}/release" agent-desktop.exe@@ -366,8 +283,8 @@ jobs:# Ships alongside CLI tarballs on the same release tag; npm stays CLI-only.build-ffi:name: Build FFI (${{ matrix.target }})- needs: release-please- if: needs.release-please.outputs.release_created == 'true'+ needs: check-release+ if: needs.check-release.outputs.should_release == 'true' || needs.check-release.outputs.needs_github_release == 'true'runs-on: ${{ matrix.runner }}container: ${{ matrix.container }}timeout-minutes: 30@@ -417,7 +334,15 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false- ref: ${{ needs.release-please.outputs.tag_name }}+ fetch-depth: 0+ ref: ${{ github.sha }}++ - name: Verify and select release source+ shell: bash+ env:+ RELEASE_SOURCE_SHA: ${{ needs.check-release.outputs.source_sha }}+ RELEASE_WORKFLOW_SHA: ${{ github.sha }}+ run: bash scripts/checkout-release-source.sh- name: Install rustup (container)if: runner.os == 'Linux'@@ -443,16 +368,6 @@ jobs:# NEVER add --features stub-adapter to the release FFI build — it ships a no-op dylib# where every adapter call returns PLATFORM_NOT_SUPPORTED. The guard step below enforces this.- - name: Cache cargo registry- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0- with:- path: |- ~/.cargo/registry/index/- ~/.cargo/registry/cache/- ~/.cargo/git/db/- key: ${{ runner.os }}-${{ matrix.target }}-ffi-cargo-${{ hashFiles('Cargo.lock', 'Cargo.toml', 'crates/**/Cargo.toml', 'src/Cargo.toml') }}- restore-keys: ${{ runner.os }}-${{ matrix.target }}-ffi-cargo--- name: Guard — release dylib must not be a stub buildshell: bashrun: |@@ -505,7 +420,7 @@ jobs:- name: Stage tarball contentsshell: bashenv:- VERSION: ${{ needs.release-please.outputs.version }}+ VERSION: ${{ needs.check-release.outputs.version }}run: |STAGE="agent-desktop-ffi-v${VERSION}-${{ matrix.target }}"mkdir -p "$STAGE/lib" "$STAGE/include"@@ -612,8 +527,8 @@ jobs:# macOS because cbindgen may omit macOS-gated symbols on Linux.ffi-release-gates:name: FFI Release Gates- needs: release-please- if: needs.release-please.outputs.release_created == 'true'+ needs: check-release+ if: needs.check-release.outputs.should_release == 'true' || needs.check-release.outputs.needs_github_release == 'true'runs-on: macos-latesttimeout-minutes: 30permissions:@@ -622,21 +537,19 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false- ref: ${{ needs.release-please.outputs.tag_name }}+ fetch-depth: 0+ ref: ${{ github.sha }}++ - name: Verify and select release source+ shell: bash+ env:+ RELEASE_SOURCE_SHA: ${{ needs.check-release.outputs.source_sha }}+ RELEASE_WORKFLOW_SHA: ${{ github.sha }}+ run: bash scripts/checkout-release-source.sh- name: Install Rust toolchainrun: rustup show- - name: Cache cargo registry- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0- with:- path: |- ~/.cargo/registry/index/- ~/.cargo/registry/cache/- ~/.cargo/git/db/- key: ${{ runner.os }}-ffi-gates-cargo-${{ hashFiles('Cargo.lock', 'Cargo.toml', 'crates/**/Cargo.toml', 'src/Cargo.toml') }}- restore-keys: ${{ runner.os }}-ffi-gates-cargo--- name: Install pinned cbindgen 0.29.4run: cargo install cbindgen --version 0.29.4 --locked@@ -653,8 +566,8 @@ jobs:--features stub-adapter --test c_abi_passthroughffi-release-panic-guard:- needs: release-please- if: needs.release-please.outputs.release_created == 'true'+ needs: check-release+ if: needs.check-release.outputs.should_release == 'true' || needs.check-release.outputs.needs_github_release == 'true'name: FFI Panic Guard (${{ matrix.target }})runs-on: ${{ matrix.runner }}container: ${{ matrix.container }}@@ -691,7 +604,15 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false- ref: ${{ needs.release-please.outputs.tag_name }}+ fetch-depth: 0+ ref: ${{ github.sha }}++ - name: Verify and select release source+ shell: bash+ env:+ RELEASE_SOURCE_SHA: ${{ needs.check-release.outputs.source_sha }}+ RELEASE_WORKFLOW_SHA: ${{ github.sha }}+ run: bash scripts/checkout-release-source.sh- name: Install rustup (container)if: runner.os == 'Linux'@@ -715,16 +636,6 @@ jobs:rustup showrustup target add ${{ matrix.target }}- - name: Cache cargo registry- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0- with:- path: |- ~/.cargo/registry/index/- ~/.cargo/registry/cache/- ~/.cargo/git/db/- key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock', 'Cargo.toml', 'crates/**/Cargo.toml', 'src/Cargo.toml') }}- restore-keys: ${{ runner.os }}-cargo--- name: Assert release-ffi profile keeps panic=unwindshell: bashrun: |@@ -743,8 +654,8 @@ jobs:# the CLI archive, the FFI archive and the npm package table.linux-archive-contents:name: Linux archive contents (${{ matrix.target }})- needs: [release-please, build, build-ffi]- if: needs.release-please.outputs.release_created == 'true'+ needs: [check-release, build, build-ffi]+ if: needs.check-release.outputs.should_release == 'true' || needs.check-release.outputs.needs_github_release == 'true'runs-on: ubuntu-latesttimeout-minutes: 10permissions:@@ -761,7 +672,15 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false- ref: ${{ needs.release-please.outputs.tag_name }}+ ref: ${{ github.sha }}+ fetch-depth: 0++ - name: Verify and select release source+ shell: bash+ env:+ RELEASE_SOURCE_SHA: ${{ needs.check-release.outputs.source_sha }}+ RELEASE_WORKFLOW_SHA: ${{ github.sha }}+ run: bash scripts/checkout-release-source.sh- name: Download this target's CLI and FFI archivesuses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1@@ -779,8 +698,16 @@ jobs:publish-github:name: Publish to GitHub Release- needs: [release-please, build, build-ffi, ffi-release-gates, ffi-release-panic-guard, linux-archive-contents]- if: needs.release-please.outputs.release_created == 'true'+ needs: [check-release, build, build-ffi, ffi-release-gates, ffi-release-panic-guard, linux-archive-contents, publish-npm]+ if: >-+ always() &&+ needs.check-release.result == 'success' &&+ needs.build.result == 'success' &&+ needs.build-ffi.result == 'success' &&+ needs.ffi-release-gates.result == 'success' &&+ needs.ffi-release-panic-guard.result == 'success' &&+ needs.linux-archive-contents.result == 'success' &&+ (needs.publish-npm.result == 'success' || needs.publish-npm.result == 'skipped')runs-on: ubuntu-latesttimeout-minutes: 10permissions:@@ -803,21 +730,13 @@ jobs:env:GH_TOKEN: ${{ github.token }}GH_REPO: ${{ github.repository }}- TAG_NAME: ${{ needs.release-please.outputs.tag_name }}- ALLOW_REPUBLISH: ${{ needs.release-please.outputs.allow_republish }}- run: |- if gh release view "$TAG_NAME" >/dev/null 2>&1; then- ATTACHED=$(gh release view "$TAG_NAME" --json assets --jq '.assets | length')- if [ "${ATTACHED}" -gt 0 ] && [ "${ALLOW_REPUBLISH}" != "true" ]; then- echo "FAIL: ${TAG_NAME} already carries ${ATTACHED} asset(s)."- echo "Re-uploading would replace shipped downloads. Cut a new version,"- echo "or dispatch with allow_republish=true if replacing them is intended."- exit 1- fi- else+ TAG_NAME: ${{ needs.check-release.outputs.tag_name }}+ run: |+ if ! gh release view "$TAG_NAME" >/dev/null 2>&1; thengh release create "$TAG_NAME" \+ --verify-tag \--title "$TAG_NAME" \- --notes "Release ${TAG_NAME}"+ --generate-notesfigh release upload "$TAG_NAME" \./*.tar.gz ./*.zip checksums.txt \@@ -827,7 +746,7 @@ jobs:env:GH_TOKEN: ${{ github.token }}GH_REPO: ${{ github.repository }}- TAG_NAME: ${{ needs.release-please.outputs.tag_name }}+ TAG_NAME: ${{ needs.check-release.outputs.tag_name }}EXPECTED_ASSETS: 13run: |ASSETS=$(gh release view "$TAG_NAME" --json assets --jq '.assets | length')@@ -850,8 +769,8 @@ jobs:publish-npm:name: Publish to npm- needs: [release-please, publish-github]- if: needs.release-please.outputs.release_created == 'true' && needs.release-please.outputs.publish_npm == 'true'+ needs: [check-release, build, build-ffi, ffi-release-gates, ffi-release-panic-guard, linux-archive-contents]+ if: needs.check-release.outputs.should_release == 'true'runs-on: ubuntu-latesttimeout-minutes: 15permissions:@@ -861,7 +780,15 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false- ref: ${{ needs.release-please.outputs.tag_name }}+ fetch-depth: 0+ ref: ${{ github.sha }}++ - name: Verify and select release source+ shell: bash+ env:+ RELEASE_SOURCE_SHA: ${{ needs.check-release.outputs.source_sha }}+ RELEASE_WORKFLOW_SHA: ${{ github.sha }}+ run: bash scripts/checkout-release-source.sh- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0with:@@ -871,7 +798,7 @@ jobs:- name: Prepare npm packageenv:- VERSION: ${{ needs.release-please.outputs.version }}+ VERSION: ${{ needs.check-release.outputs.version }}run: |cd npmnode -e "@@ -884,14 +811,27 @@ jobs:cp ../README.md README.mdcp ../CHANGELOG.md CHANGELOG.md 2>/dev/null || true+ - name: Download built release archives+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ pattern: "{binary,ffi}-*"+ merge-multiple: true+ path: ${{ runner.temp }}/npm-release++ - name: Bundle built CLI executables+ run: |+ cat "$RUNNER_TEMP/npm-release"/*.sha256 > "$RUNNER_TEMP/npm-release/checksums.txt"+ node scripts/prepare-npm-binaries.js "$RUNNER_TEMP/npm-release"+ node scripts/check-npm-package.js --bundled+- name: Publish to npmrun: npm publish --access publicworking-directory: npmpublish-skills:name: Publish Skills to ClawHub- needs: [release-please]- if: needs.release-please.outputs.release_created == 'true' && needs.release-please.outputs.publish_skills == 'true'+ needs: [check-release, publish-github]+ if: needs.check-release.outputs.should_release == 'true'runs-on: ubuntu-latesttimeout-minutes: 10permissions:@@ -900,7 +840,15 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false- ref: ${{ needs.release-please.outputs.tag_name }}+ fetch-depth: 0+ ref: ${{ github.sha }}++ - name: Verify and select release source+ shell: bash+ env:+ RELEASE_SOURCE_SHA: ${{ needs.check-release.outputs.source_sha }}+ RELEASE_WORKFLOW_SHA: ${{ github.sha }}+ run: bash scripts/checkout-release-source.sh- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0with:@@ -924,10 +872,10 @@ jobs:slug="$(basename "$skill_dir")"clawhub publish "$skill_dir" \--slug "$slug" \- --changelog "Release ${{ needs.release-please.outputs.tag_name }}" \+ --changelog "Release ${{ needs.check-release.outputs.tag_name }}" \--tags latest \--source-repo "${GITHUB_REPOSITORY}" \--source-commit "$SOURCE_COMMIT" \- --source-ref "${{ needs.release-please.outputs.tag_name }}" \+ --source-ref "${{ needs.check-release.outputs.tag_name }}" \--source-path "$skill_dir"donediff --git a/.gitleaks.toml b/.gitleaks.tomlindex 6d9c92f18..f89b018e3 100644--- a/.gitleaks.toml+++ b/.gitleaks.toml@@ -50,6 +50,7 @@ regexes = ['''(?i)^[A-Za-z0-9._%+-]+@users\.noreply\.github\.com$''','''(?i)^noreply@github\.com$''','''^secret@router\.example$''',+ '''^fixture@example\.invalid$''','''^org\.gnome\.Shell@(x11|wayland)\.service$''','''^user@[0-9]+\.service$''','''^ubuntu-appindicators@ubuntu\.com$''',diff --git a/.release-please-manifest.json b/.release-please-manifest.jsondeleted file mode 100644index 30b6d45ad..000000000--- a/.release-please-manifest.json+++ /dev/null@@ -1,3 +0,0 @@-{- ".": "0.10.1"-}diff --git a/Cargo.lock b/Cargo.lockindex fa17d12e4..85c67eff3 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -19,7 +19,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"[[package]]name = "agent-desktop"-version = "0.10.1"+version = "0.11.0"dependencies = ["agent-desktop-core","agent-desktop-linux",@@ -38,7 +38,7 @@ dependencies = [[[package]]name = "agent-desktop-core"-version = "0.10.1"+version = "0.11.0"dependencies = ["base64","libc",@@ -52,7 +52,7 @@ dependencies = [[[package]]name = "agent-desktop-ffi"-version = "0.10.1"+version = "0.11.0"dependencies = ["agent-desktop-core","agent-desktop-linux",@@ -68,7 +68,7 @@ dependencies = [[[package]]name = "agent-desktop-linux"-version = "0.10.1"+version = "0.11.0"dependencies = ["agent-desktop-core","async-io",@@ -85,7 +85,7 @@ dependencies = [[[package]]name = "agent-desktop-macos"-version = "0.10.1"+version = "0.11.0"dependencies = ["accessibility-sys","agent-desktop-core",@@ -104,7 +104,7 @@ dependencies = [[[package]]name = "agent-desktop-windows"-version = "0.10.1"+version = "0.11.0"dependencies = ["agent-desktop-core","serde_json",diff --git a/Cargo.toml b/Cargo.tomlindex 05bdd6de0..06612d968 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -7,7 +7,7 @@ resolver = "2"edition = "2024"rust-version = "1.89"license = "Apache-2.0"-version = "0.10.1" # x-release-please-version+version = "0.11.0"[workspace.dependencies]clap = { version = "4.6", features = ["derive"] }diff --git a/Formula/agent-desktop.rb b/Formula/agent-desktop.rbnew file mode 100644index 000000000..7ec18aa01--- /dev/null+++ b/Formula/agent-desktop.rb@@ -0,0 +1,31 @@+class AgentDesktop < Formula+ desc "Native accessibility-based desktop automation for agents"+ homepage "https://github.com/lahfir/agent-desktop"+ version "0.10.1"+ license "Apache-2.0"++ depends_on macos: :ventura++ on_arm do+ url "https://github.com/lahfir/agent-desktop/releases/download/v0.10.1/agent-desktop-v0.10.1-aarch64-apple-darwin.tar.gz"+ sha256 "3f1c9fbc5d31d96881bed0e741360cac5bbd2ae2c1add08643a05cfb3429244b"+ end++ on_intel do+ url "https://github.com/lahfir/agent-desktop/releases/download/v0.10.1/agent-desktop-v0.10.1-x86_64-apple-darwin.tar.gz"+ sha256 "55e82cfc22cc9f1e7313632a3cd1320f23614b4c7df310f989f5c053af5bcca3"+ end++ def install+ bin.install "agent-desktop", "agent-desktop-macos-helper"+ end++ test do+ require "json"+ response = JSON.parse(shell_output("#{bin}/agent-desktop version"))+ assert_equal true, response.fetch("ok")+ assert_equal version.to_s, response.fetch("data").fetch("version")+ assert_equal "macos", response.fetch("data").fetch("os")+ assert_path_exists bin/"agent-desktop-macos-helper"+ end+enddiff --git a/README.md b/README.mdindex 694e6755e..08d29ec0d 100644--- a/README.md+++ b/README.md@@ -28,7 +28,7 @@ The package works on macOS, Windows and Linux, on x64 and ARM64. Then check what- **Windows** needs no grant for apps at your terminal's integrity level. See [permissions](docs/install.md#permissions).- **Linux** needs the user's graphical session with `at-spi2-core`. See [permissions](docs/install.md#permissions).-If your package manager blocks install scripts, allow them (npm 11: `allowScripts`); see [docs/install.md](docs/install.md#blocked-install-scripts). To verify a release archive's origin, run `gh attestation verify`; see [docs/install.md](docs/install.md#release-archives). Building from source is covered in [docs/install.md](docs/install.md#from-source).+The npm package bundles the native binaries and helpers for all six platform and architecture combinations, so installation also works with scripts blocked. When postinstall runs, POSIX commands link directly to the native binary and owned Windows npm/Yarn commands call the executable directly; blocked scripts and some package managers retain a launcher. To verify a release archive's origin, run `gh attestation verify`; see [docs/install.md](docs/install.md#release-archives). Building from source is covered in [docs/install.md](docs/install.md#from-source).## Quick startdiff --git a/crates/linux/src/input/clipboard/owner/owner_locate.rs b/crates/linux/src/input/clipboard/owner/owner_locate.rsindex 886b32531..2fa5b92df 100644--- a/crates/linux/src/input/clipboard/owner/owner_locate.rs+++ b/crates/linux/src/input/clipboard/owner/owner_locate.rs@@ -103,10 +103,18 @@ pub(crate) fn locate_in(maps: &str, address: usize) -> Result<PathBuf, AdapterEr.ok_or_else(|| {refusal("The image that holds the clipboard code could not be found".to_owned())})?;- let helper = image+ let mut helper = image.parent().ok_or_else(|| refusal("The image that holds the clipboard code has no directory".into()))?.join(HELPER_NAME);+ if !helper.exists() {+ let arch = if cfg!(target_arch = "aarch64") {+ "arm64"+ } else {+ "x64"+ };+ helper.set_file_name(format!("{HELPER_NAME}-linux-{arch}"));+ }check_helper(&helper)?;Ok(helper)}diff --git a/crates/linux/src/input/clipboard/owner/owner_locate_tests.rs b/crates/linux/src/input/clipboard/owner/owner_locate_tests.rsindex 4156f305e..5c21d3b5a 100644--- a/crates/linux/src/input/clipboard/owner/owner_locate_tests.rs+++ b/crates/linux/src/input/clipboard/owner/owner_locate_tests.rs@@ -202,3 +202,30 @@ fn locating_refuses_group_write_on_the_helper_or_its_directory() {assert!(error.message.contains("group"), "{}", error.message);}}++#[test]+fn a_bundled_architecture_helper_is_validated_when_the_plain_helper_is_absent() {+ for mode in [0o755, 0o775] {+ let dir = scratch("bundled-helper");+ let image = image_in(&dir, "agent-desktop-linux");+ let helper = install(&dir, mode);+ let arch = if cfg!(target_arch = "aarch64") {+ "arm64"+ } else {+ "x64"+ };+ let bundled = dir.join(format!("{HELPER_NAME}-linux-{arch}"));+ fs::rename(helper, &bundled).expect("bundled helper");+ let result = locate_in(&maps_line(0x1000, 0x2000, &image), 0x1000);+ if mode == 0o755 {+ assert_eq!(result.expect("bundled helper"), bundled);+ } else {+ assert!(+ result+ .expect_err("group write is refused")+ .message+ .contains("group")+ );+ }+ }+}diff --git a/docs/install.md b/docs/install.mdindex 2e793a11b..28e75f5bc 100644--- a/docs/install.md+++ b/docs/install.md@@ -9,17 +9,9 @@ agent-desktop status # platform, permissions, supported surfaces## Blocked install scripts-The package's `postinstall` script downloads the binary from the GitHub release and checks its SHA-256. A package-manager that blocks install scripts leaves no binary, and the first run fails with binary-not-found. npm 11 runs the-script but warns that it is not covered by `allowScripts`. On Linux the script also needs `curl`, `tar` and `gzip`. To-allow it:--```bash-npm install -g --allow-scripts=agent-desktop agent-desktop-npm config set allow-scripts=agent-desktop --location=user-pnpm add -g --allow-build=agent-desktop agent-desktop-bun add -g --trust agent-desktop-```+The npm package includes the native binaries and helpers. With install scripts blocked, its launcher selects the+bundled binary. When postinstall runs, it links POSIX commands directly to the native binary and optimizes owned+Windows npm/Yarn commands to invoke the executable. Some package managers retain their own launcher.## Release archivesdiff --git a/npm/bin/agent-desktop b/npm/bin/agent-desktopindex f84147753..98157d88e 100755--- a/npm/bin/agent-desktop+++ b/npm/bin/agent-desktop@@ -31,16 +31,8 @@ function main() {console.error(`Error: Native binary not found for ${platform()}-${arch()}`);console.error(`Expected: ${binaryPath}`);console.error('');- console.error('This usually means the install ran with --ignore-scripts,');- console.error('the package manager blocked the postinstall script (npm: allow-scripts=agent-desktop),');- console.error('or its postinstall download step failed.');- console.error('Try reinstalling:');- console.error(' npm: npm install -g --allow-scripts=agent-desktop agent-desktop');- console.error(' pnpm: pnpm add -g --allow-build=agent-desktop agent-desktop');- console.error(' bun: bun add -g --trust agent-desktop');- console.error('');- console.error('Or download directly from:');- console.error(' https://github.com/lahfir/agent-desktop/releases');+ console.error('The installed package is incomplete. Reinstall agent-desktop.');+ console.error('Release binaries are also available at https://github.com/lahfir/agent-desktop/releases');process.exit(1);}@@ -59,13 +51,15 @@ function main() {}}+ let helperPath;if (platform() === 'darwin') {const override = process.env[MACOS_HELPER_PATH_ENV];if (override && !isAbsolute(override)) {console.error(`Error: ${MACOS_HELPER_PATH_ENV} must be an absolute path`);process.exit(1);}- const helperPath = override || join(binDir, MACOS_HELPER_NAME);+ const bundledHelper = join(binDir, `${MACOS_HELPER_NAME}-${platform()}-${arch()}`);+ helperPath = override || (existsSync(bundledHelper) ? bundledHelper : join(binDir, MACOS_HELPER_NAME));if (!existsSync(helperPath)) {console.error(`Error: macOS helper not found: ${helperPath}`);console.error('Reinstall agent-desktop so the CLI and helper come from the same release.');@@ -85,6 +79,7 @@ function main() {const child = spawn(binaryPath, process.argv.slice(2), {stdio: 'inherit',+ env: helperPath ? { ...process.env, [MACOS_HELPER_PATH_ENV]: helperPath } : process.env,windowsHide: false,});diff --git a/npm/lib/windows-bin.js b/npm/lib/windows-bin.jsnew file mode 100644index 000000000..0a3ed29b4--- /dev/null+++ b/npm/lib/windows-bin.js@@ -0,0 +1,39 @@+const { existsSync, realpathSync, readFileSync, writeFileSync } = require('fs');+const { dirname, join, relative, resolve } = require('path');++module.exports = function linkWindowsBin(directory, binaryName) {+ const binary = resolve(directory, binaryName);+ if (!existsSync(binary) || /[%!\r\n"]/.test(binary)) return false;+ const entry = join(directory, 'agent-desktop');+ let ancestor = directory;+ let linked = false;+ for (;;) {+ for (const destination of [ancestor, join(ancestor, '.bin')]) {+ const targets = [relative(destination, entry).replace(/\\/g, '/')];+ const alias = join(ancestor, 'agent-desktop', 'bin', 'agent-desktop');+ try {+ if (existsSync(alias) && realpathSync(alias) === realpathSync(entry)) {+ targets.push(relative(destination, alias).replace(/\\/g, '/'));+ }+ } catch {}+ const matches = (contents) => targets.some((target) =>+ contents.includes(`${target}"`) || contents.includes(`${target}'`));+ const command = join(destination, 'agent-desktop.cmd');+ try {+ const contents = readFileSync(command, 'utf8').replace(/\\/g, '/');+ if (!matches(contents)) continue;+ writeFileSync(command, `@echo off\r\n"${binary}" %*\r\nexit /b %errorlevel%\r\n`);+ const powershell = join(destination, 'agent-desktop.ps1');+ if (existsSync(powershell) && matches(readFileSync(powershell, 'utf8').replace(/\\/g, '/'))) {+ writeFileSync(powershell, `& '${binary.replace(/'/g, "''")}' @args\r\nexit $LASTEXITCODE\r\n`);+ }+ linked = true;+ } catch (error) {+ if (error.code !== 'ENOENT') process.stderr.write(`agent-desktop: Native command optimization skipped: ${error.message}\n`);+ }+ }+ const parent = dirname(ancestor);+ if (parent === ancestor) return linked;+ ancestor = parent;+ }+};diff --git a/npm/package.json b/npm/package.jsonindex 9c2deff31..e5711499d 100644--- a/npm/package.json+++ b/npm/package.json@@ -1,6 +1,6 @@{"name": "agent-desktop",- "version": "0.10.1",+ "version": "0.11.0","description": "Reliable computer use for AI agents — observe and operate desktop apps via native accessibility trees","license": "Apache-2.0","repository": {@@ -33,5 +33,14 @@"windows","linux","a11y"+ ],+ "os": [+ "darwin",+ "win32",+ "linux"+ ],+ "cpu": [+ "arm64",+ "x64"]}diff --git a/npm/scripts/postinstall.js b/npm/scripts/postinstall.jsindex ba5dba5c2..24141761f 100644--- a/npm/scripts/postinstall.js+++ b/npm/scripts/postinstall.js@@ -184,7 +184,8 @@ function isNodeWrapper(path) {}function linkBinEntry(directory, binaryName, osPlatform = platform()) {- if (osPlatform === 'win32' || !isInstalledPackage(directory)) return false;+ if (!isInstalledPackage(directory)) return false;+ if (osPlatform === 'win32') return require('../lib/windows-bin')(directory, binaryName);const entryPath = join(directory, BIN_ENTRY_NAME);const binaryPath = join(directory, binaryName);const temporary = `${entryPath}.link-${process.pid}`;@@ -300,6 +301,11 @@ function main() {return;}+ const bundledHelper = includesHelper ? join(binDir, `${helperName}-${platformKey}`) : undefined;+ if (includesHelper && existsSync(bundledHelper) && matchesRecordedDigest(bundledHelper)) {+ installExecutable(bundledHelper, helperPath);+ }+const alreadyInstalled =existsSync(binaryPath) &&matchesRecordedDigest(binaryPath) &&diff --git a/release-please-config.json b/release-please-config.jsondeleted file mode 100644index 7e0d74149..000000000--- a/release-please-config.json+++ /dev/null@@ -1,55 +0,0 @@-{- "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",- "release-type": "simple",- "bump-minor-pre-major": true,- "bump-patch-for-minor-pre-major": true,- "include-component-in-tag": false,- "packages": {- ".": {- "package-name": "agent-desktop",- "changelog-path": "CHANGELOG.md",- "extra-files": [- {- "type": "generic",- "path": "Cargo.toml"- },- {- "type": "json",- "path": "npm/package.json",- "jsonpath": "$.version"- },- {- "type": "generic",- "path": "skills/agent-desktop/SKILL.md"- },- {- "type": "generic",- "path": "skills/agent-desktop-ffi/SKILL.md"- },- {- "type": "generic",- "path": "skills/agent-desktop-linux/SKILL.md"- },- {- "type": "generic",- "path": "skills/agent-desktop-macos/SKILL.md"- },- {- "type": "generic",- "path": "skills/agent-desktop-windows/SKILL.md"- }- ]- }- },- "changelog-sections": [- { "type": "feat", "section": "Features" },- { "type": "fix", "section": "Bug Fixes" },- { "type": "perf", "section": "Performance" },- { "type": "refactor", "section": "Refactoring", "hidden": true },- { "type": "docs", "section": "Documentation", "hidden": true },- { "type": "style", "hidden": true },- { "type": "chore", "hidden": true },- { "type": "ci", "hidden": true },- { "type": "test", "hidden": true }- ]-}diff --git a/scripts/check-npm-package.js b/scripts/check-npm-package.jsindex 51414b411..e7cdfb2ae 100644--- a/scripts/check-npm-package.js+++ b/scripts/check-npm-package.js@@ -1,10 +1,8 @@#!/usr/bin/env node-const { execFileSync, execSync } = require('child_process');const { readFileSync } = require('fs');const { join } = require('path');const { tmpdir } = require('os');-const root = join(__dirname, '..');const npmDir = join(root, 'npm');const pkg = require(join(npmDir, 'package.json'));@@ -13,15 +11,14 @@ const { LINUX_HELPER_NAME, PLATFORMS, tarballName } = require(join(npmDir, 'lib'const expectedFiles = ['bin/agent-desktop','lib/platform.js',+ 'lib/windows-bin.js','package.json','scripts/postinstall.js',];-const NPM_PUBLISH_JOB = 'publish-npm';const BUILD_JOB = 'build';const BUILD_FFI_JOB = 'build-ffi';const PUBLISH_GITHUB_JOB = 'publish-github';-// Returns the YAML block for one job, so a requirement can be asserted about// the job that needs it rather than about the file that contains it.//@@ -44,7 +41,6 @@ function jobBlock(workflow, jobName) {const end = rest.findIndex((line) => /^ {2}\S/.test(line));return (end === -1 ? rest : rest.slice(0, end)).join('\n');}-function matrixIncludeTargets(jobText) {const lines = jobText.split('\n');const includeStart = lines.findIndex((line) => line.trim() === 'include:');@@ -68,7 +64,6 @@ function matrixIncludeTargets(jobText) {}return [...new Set(targets)];}-function normaliseTarballConstruction(line) {const match = line.match(/agent-desktop-v[^"']*?\.tar\.gz/);if (!match) return null;@@ -459,7 +454,8 @@ if (!pack || !Array.isArray(pack.files)) {);}const actualFiles = pack.files.map((file) => file.path).sort();-const expected = [...expectedFiles].sort();+const expected = [...expectedFiles, ...(process.argv.includes('--bundled')+ ? require('./npm-bundled-files')() : [])].sort();if (JSON.stringify(actualFiles) !== JSON.stringify(expected)) {throw new Error(`Unexpected npm package contents: ${actualFiles.join(', ')}`);@@ -469,7 +465,7 @@ if (pack.bundled && pack.bundled.length > 0) {throw new Error(`npm package unexpectedly bundles dependencies: ${pack.bundled.join(', ')}`);}-if (pack.unpackedSize > 25_000) {+if (pack.unpackedSize > (process.argv.includes('--bundled') ? 100_000_000 : 25_000)) {throw new Error(`npm package is unexpectedly large: ${pack.unpackedSize} bytes`);}diff --git a/scripts/check-release-consistency.sh b/scripts/check-release-consistency.shindex 3cce97bc1..2cdf94079 100755--- a/scripts/check-release-consistency.sh+++ b/scripts/check-release-consistency.sh@@ -18,10 +18,6 @@ read_json_version() {sed -n 's/.*"version" *: *"\([^"]*\)".*/\1/p' "$file" | head -1}-read_manifest_version() {- sed -n 's/.*"\." *: *"\([^"]*\)".*/\1/p' .release-please-manifest.json | head -1-}-lock_version_for() {local package="$1"awk -v target="$package" '@@ -55,18 +51,13 @@ lock_version_for() {workspace_version="$(read_toml_version)"npm_version="$(read_json_version npm/package.json)"-manifest_version="$(read_manifest_version)"[[ -n "$workspace_version" ]] || fail "could not read workspace version from Cargo.toml"[[ -n "$npm_version" ]] || fail "could not read npm package version"-[[ -n "$manifest_version" ]] || fail "could not read release-please manifest version"[[ "$npm_version" == "$workspace_version" ]] \|| fail "npm/package.json version ${npm_version} does not match Cargo.toml ${workspace_version}"-[[ "$manifest_version" == "$workspace_version" ]] \- || fail ".release-please-manifest.json version ${manifest_version} does not match Cargo.toml ${workspace_version}"-packages=(agent-desktopagent-desktop-corediff --git a/scripts/checkout-release-source.sh b/scripts/checkout-release-source.shnew file mode 100644index 000000000..ed45afe44--- /dev/null+++ b/scripts/checkout-release-source.sh@@ -0,0 +1,11 @@+#!/usr/bin/env bash+set -euo pipefail+if [[ ! "${RELEASE_SOURCE_SHA:-}" =~ ^[0-9a-f]{40}$ ]] || [[ ! "${RELEASE_WORKFLOW_SHA:-}" =~ ^[0-9a-f]{40}$ ]]; then+ echo "Release source and workflow must be full commit SHAs" >&2+ exit 1+fi+if ! git merge-base --is-ancestor "$RELEASE_SOURCE_SHA" "$RELEASE_WORKFLOW_SHA"; then+ echo "Release source must belong to the triggering main history" >&2+ exit 1+fi+git checkout --detach "$RELEASE_SOURCE_SHA"diff --git a/scripts/npm-bundled-files.js b/scripts/npm-bundled-files.jsnew file mode 100644index 000000000..b92635a77--- /dev/null+++ b/scripts/npm-bundled-files.js@@ -0,0 +1,10 @@+const { helperNames, PLATFORMS } = require('../npm/lib/platform');++module.exports = function bundledFiles() {+ return ['README.md', ...Object.entries(PLATFORMS).flatMap(([key, entry]) => {+ if (!entry.released) return [];+ const names = [entry.binaryName];+ names.push(...helperNames(entry).map((name) => `${name}-${key}`));+ return names.flatMap((name) => [`bin/${name}`, `bin/${name}.sha256`]);+ })];+};diff --git a/scripts/prepare-npm-binaries.js b/scripts/prepare-npm-binaries.jsnew file mode 100644index 000000000..8d7d1c1b2--- /dev/null+++ b/scripts/prepare-npm-binaries.js@@ -0,0 +1,41 @@+#!/usr/bin/env node++const { createHash } = require('node:crypto');+const { execFileSync } = require('node:child_process');+const { mkdirSync, readFileSync, writeFileSync } = require('node:fs');+const { join } = require('node:path');+const { PLATFORMS, tarballName } = require('../npm/lib/platform');+const { checksumFor } = require('../npm/scripts/postinstall');++const archiveDirectory = process.argv[2];+if (!archiveDirectory) throw new Error('Usage: node scripts/prepare-npm-binaries.js ARCHIVE_DIRECTORY');+const npmDirectory = join(__dirname, '..', 'npm');+const { version } = require('../npm/package.json');+const checksums = readFileSync(join(archiveDirectory, 'checksums.txt'), 'utf8');+const binDirectory = join(npmDirectory, 'bin');+mkdirSync(binDirectory, { recursive: true });++for (const [key, entry] of Object.entries(PLATFORMS)) {+ if (!entry.released) continue;+ const archiveName = tarballName(version, entry.target);+ const archivePath = join(archiveDirectory, archiveName);+ const digest = createHash('sha256').update(readFileSync(archivePath)).digest('hex');+ if (digest !== checksumFor(checksums, archiveName)) {+ throw new Error(`Checksum mismatch for ${archiveName}`);+ }+ const listing = execFileSync('tar', ['-tzf', archivePath], { encoding: 'utf8' })+ .trim().split(/\r?\n/).sort();+ if (JSON.stringify(listing) !== JSON.stringify([...entry.entries].sort())) {+ throw new Error(`Unexpected archive entries for ${archiveName}`);+ }+ for (const name of entry.entries) {+ const destinationName = name === entry.entries[0] ? entry.binaryName : `${name}-${key}`;+ const payload = execFileSync('tar', ['-xOzf', archivePath, name], {+ maxBuffer: 32 * 1024 * 1024,+ });+ if (payload.length === 0) throw new Error(`Empty executable: ${archiveName}/${name}`);+ writeFileSync(join(binDirectory, destinationName), payload, { mode: 0o755 });+ writeFileSync(join(binDirectory, `${destinationName}.sha256`),+ `${createHash('sha256').update(payload).digest('hex')}\n`);+ }+}diff --git a/scripts/prepare-release.sh b/scripts/prepare-release.shnew file mode 100644index 000000000..db9f76490--- /dev/null+++ b/scripts/prepare-release.sh@@ -0,0 +1,38 @@+#!/usr/bin/env bash+set -euo pipefail+bash scripts/check-release-consistency.sh+VERSION=$(node -p "require('./npm/package.json').version")+if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then+ echo "Invalid version: ${VERSION}" >&2+ exit 1+fi+TAG_NAME="v${VERSION}"+NPM_VERSION=$(npm view agent-desktop version 2>/dev/null || echo "0.0.0")+SHOULD_RELEASE=false+NEEDS_GITHUB_RELEASE=false+if [ "$VERSION" != "$NPM_VERSION" ]; then+ SHOULD_RELEASE=true+ NEEDS_GITHUB_RELEASE=true+elif ! gh release view "$TAG_NAME" >/dev/null 2>&1; then+ NEEDS_GITHUB_RELEASE=true+fi+SOURCE_SHA=$(git rev-parse HEAD)+if [ "$SHOULD_RELEASE" = true ] || [ "$NEEDS_GITHUB_RELEASE" = true ]; then+ if git rev-parse --verify "refs/tags/${TAG_NAME}" >/dev/null 2>&1; then+ SOURCE_SHA=$(git rev-parse "refs/tags/${TAG_NAME}^{commit}")+ TAG_VERSION=$(git show "${SOURCE_SHA}:npm/package.json" | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).version')+ if [ "$TAG_VERSION" != "$VERSION" ]; then+ echo "Existing tag ${TAG_NAME} has inconsistent version metadata" >&2+ exit 1+ fi+ else+ gh api "repos/${GH_REPO}/git/refs" -f "ref=refs/tags/${TAG_NAME}" -f "sha=${SOURCE_SHA}"+ fi+fi+{+ echo "tag_name=${TAG_NAME}"+ echo "version=${VERSION}"+ echo "source_sha=${SOURCE_SHA}"+ echo "should_release=${SHOULD_RELEASE}"+ echo "needs_github_release=${NEEDS_GITHUB_RELEASE}"+} >> "$GITHUB_OUTPUT"diff --git a/skills/agent-desktop-ffi/SKILL.md b/skills/agent-desktop-ffi/SKILL.mdindex da9866ab6..4fb0667b9 100644--- a/skills/agent-desktop-ffi/SKILL.md+++ b/skills/agent-desktop-ffi/SKILL.md@@ -1,6 +1,6 @@---name: agent-desktop-ffi-version: 0.10.1 # x-release-please-version+version: 0.11.0tags: ffi, c-bindings, cdylib, python, swift, node, go, rust-ffirequirements:- agent-desktop-ffidiff --git a/skills/agent-desktop-linux/SKILL.md b/skills/agent-desktop-linux/SKILL.mdindex 164312a52..27affd2a9 100644--- a/skills/agent-desktop-linux/SKILL.md+++ b/skills/agent-desktop-linux/SKILL.md@@ -1,6 +1,6 @@---name: agent-desktop-linux-version: 0.10.1 # x-release-please-version+version: 0.11.0tags: linux-automation, accessibility, at-spi, x11, wayland, ai-agent, gui-automation, clirequirements:- agent-desktopdiff --git a/skills/agent-desktop-macos/SKILL.md b/skills/agent-desktop-macos/SKILL.mdindex 72af84011..7de0935e6 100644--- a/skills/agent-desktop-macos/SKILL.md+++ b/skills/agent-desktop-macos/SKILL.md@@ -1,6 +1,6 @@---name: agent-desktop-macos-version: 0.10.1 # x-release-please-version+version: 0.11.0tags: macos-automation, accessibility, ax, tcc, ai-agent, gui-automation, clirequirements:- agent-desktopdiff --git a/skills/agent-desktop-windows/SKILL.md b/skills/agent-desktop-windows/SKILL.mdindex d57de52de..e0d4ec0ff 100644--- a/skills/agent-desktop-windows/SKILL.md+++ b/skills/agent-desktop-windows/SKILL.md@@ -1,6 +1,6 @@---name: agent-desktop-windows-version: 0.10.1 # x-release-please-version+version: 0.11.0tags: windows-automation, accessibility, uia, ai-agent, gui-automation, clirequirements:- agent-desktopdiff --git a/skills/agent-desktop/SKILL.md b/skills/agent-desktop/SKILL.mdindex 583d48d97..d201608c4 100644--- a/skills/agent-desktop/SKILL.md+++ b/skills/agent-desktop/SKILL.md@@ -1,6 +1,6 @@---name: agent-desktop-version: 0.10.1 # x-release-please-version+version: 0.11.0tags: computer-use, desktop-automation, accessibility, ai-agent, gui-automation, clirequirements:- agent-desktopdiff --git a/src/cli/contract_command_surface_tests.rs b/src/cli/contract_command_surface_tests.rsindex 083b06786..58de04883 100644--- a/src/cli/contract_command_surface_tests.rs+++ b/src/cli/contract_command_surface_tests.rs@@ -232,9 +232,6 @@ fn coverage_names() -> BTreeSet<&'static str> {#[path = "windows_capability_claims_tests.rs"]mod windows_capability_claims;-#[path = "install_doc_claims_tests.rs"]-mod install_doc_claims;-#[path = "doc_literal_drift_tests.rs"]mod doc_literal_drift;diff --git a/src/cli/install_doc_claims_tests.rs b/src/cli/install_doc_claims_tests.rsdeleted file mode 100644index f351ef4d7..000000000--- a/src/cli/install_doc_claims_tests.rs+++ /dev/null@@ -1,42 +0,0 @@-const README: &str = include_str!("../../README.md");--const INSTALL_HEADING: &str = "## Installation";-const NEXT_TOP_HEADING: &str = "## Language bindings";--/// The section is bounded by heading text alone, so the test does not depend-/// on the README's line terminators.-fn install_section() -> &'static str {- let start = README- .find(INSTALL_HEADING)- .expect("the README must carry an Installation section");- let end = README[start..]- .find(NEXT_TOP_HEADING)- .map_or(README.len(), |offset| start + offset);- &README[start..end]-}--/// The install path's two residual risks are closed as documentation rather-/// than as code, which only holds while the documentation says the two things-/// that close them. Same-origin checksums detect corruption but do not prove-/// provenance, so the reader needs the attestation command; and an npm that-/// blocks install scripts skips the postinstall that fetches the binary, so the-/// reader needs the allowlist entry before the wrapper's binary-not-found-/// failure is their first experience of the tool.-#[test]-fn the_install_section_closes_both_documented_npm_risks() {- let section = install_section();-- assert!(- section.contains("gh attestation verify"),- "the install section must show the attestation command: the published \- checksums share an origin with the artifact they describe, so they \- detect corruption and prove nothing about provenance"- );- assert!(- section.contains("allowScripts"),- "the install section must publish the allowScripts configuration: an \- npm that blocks install scripts skips the postinstall that fetches \- the native binary, and without the allowlist entry the reader meets \- a binary-not-found failure instead of a working install"- );-}diff --git a/tests/npm/bundled.test.js b/tests/npm/bundled.test.jsnew file mode 100644index 000000000..30a9c5855--- /dev/null+++ b/tests/npm/bundled.test.js@@ -0,0 +1,69 @@+const assert = require('node:assert/strict');+const { execFileSync } = require('node:child_process');+const { createHash } = require('node:crypto');+const { cpSync, mkdirSync, mkdtempSync, realpathSync, readFileSync, writeFileSync } = require('node:fs');+const { tmpdir } = require('node:os');+const { join, resolve } = require('node:path');+const { test } = require('node:test');+const { PLATFORMS, helperNames, tarballName } = require('../../npm/lib/platform');++function fixture() {+ const root = mkdtempSync(join(tmpdir(), 'agent-desktop-bundled-'));+ const source = resolve(__dirname, '../..');+ cpSync(join(source, 'npm'), join(root, 'npm'), { recursive: true });+ mkdirSync(join(root, 'scripts'));+ cpSync(join(source, 'scripts/prepare-npm-binaries.js'), join(root, 'scripts/prepare-npm-binaries.js'));+ const archives = join(root, 'archives');+ mkdirSync(archives);+ const { version } = require('../../npm/package.json');+ const hashes = [];+ for (const [key, entry] of Object.entries(PLATFORMS)) {+ if (!entry.released) continue;+ const stage = join(root, key);+ mkdirSync(stage);+ for (const name of entry.entries) {+ const contents = name === entry.entries[0]+ ? '#!/bin/sh\nprintf "%s" "$AGENT_DESKTOP_MACOS_HELPER_PATH"\n'+ : `#!/bin/sh\nprintf '%s' '${key}/${name}'\n`;+ writeFileSync(join(stage, name), contents, { mode: 0o755 });+ }+ const name = tarballName(version, entry.target);+ execFileSync('tar', ['-czf', join(archives, name), '-C', stage, ...entry.entries]);+ hashes.push(`${createHash('sha256').update(readFileSync(join(archives, name))).digest('hex')} ${name}`);+ }+ writeFileSync(join(archives, 'checksums.txt'), hashes.join('\n'));+ return { root, archives };+}++test('release packaging runs with scripts skipped and selects the matching macOS helper', {+ skip: process.platform === 'win32',+}, () => {+ const { root, archives } = fixture();+ execFileSync(process.execPath, [join(root, 'scripts/prepare-npm-binaries.js'), archives]);+ const stub = join(root, 'os-stub.js');+ writeFileSync(stub, "const os = require('os'); os.platform = () => 'darwin'; os.arch = () => 'arm64';");+ const output = execFileSync(process.execPath,+ ['-r', stub, join(root, 'npm/bin/agent-desktop'), 'version'], { encoding: 'utf8' });+ assert.equal(output, realpathSync(join(root, 'npm/bin/agent-desktop-macos-helper-darwin-arm64')));+ for (const [key, entry] of Object.entries(PLATFORMS)) {+ if (!entry.released) continue;+ for (const name of helperNames(entry)) {+ assert.equal(readFileSync(join(root, 'npm/bin', `${name}-${key}`), 'utf8'),+ readFileSync(join(root, key, name), 'utf8'));+ }+ }+ const binary = join(root, 'npm/bin/agent-desktop-darwin-arm64');+ assert.equal(readFileSync(`${binary}.sha256`, 'utf8').trim(),+ createHash('sha256').update(readFileSync(binary)).digest('hex'));+});++test('release packaging rejects a modified archive before installing its executable', {+ skip: process.platform === 'win32',+}, () => {+ const { root, archives } = fixture();+ const { version } = require('../../npm/package.json');+ writeFileSync(join(archives, tarballName(version, PLATFORMS['darwin-arm64'].target)), 'corrupt');+ assert.throws(() => execFileSync(process.execPath,+ [join(root, 'scripts/prepare-npm-binaries.js'), archives], { stdio: 'pipe' }),+ (error) => error.stderr.toString().includes('Checksum mismatch'));+});diff --git a/tests/npm/linux-install.test.js b/tests/npm/linux-install.test.jsindex 5a0d45115..eca9dd822 100644--- a/tests/npm/linux-install.test.js+++ b/tests/npm/linux-install.test.js@@ -218,7 +218,7 @@ for (const [name, options, expected] of [});}-test('the wrapper names the missing native binary when install scripts were disabled', { skip: POSIX_ONLY }, async () => {+test('the wrapper identifies an incomplete package when the bundled native binary is missing', { skip: POSIX_ONLY }, async () => {const dir = packageCopy();const { code, stderr } = await runScriptWithOsStub(join(dir, 'bin', 'agent-desktop'),@@ -228,7 +228,7 @@ test('the wrapper names the missing native binary when install scripts were disa);assert.equal(code, 1);assert.match(stderr, /Error: Native binary not found for linux-x64/);- assert.match(stderr, /--ignore-scripts/);+ assert.match(stderr, /installed package is incomplete/);assert.match(stderr, /Expected: .*agent-desktop-linux-x64/);});diff --git a/tests/npm/windows-bin.test.js b/tests/npm/windows-bin.test.jsnew file mode 100644index 000000000..5841dd4e3--- /dev/null+++ b/tests/npm/windows-bin.test.js@@ -0,0 +1,26 @@+const assert = require('node:assert/strict');+const { mkdirSync, mkdtempSync, readFileSync, writeFileSync } = require('node:fs');+const { tmpdir } = require('node:os');+const { join, relative } = require('node:path');+const { test } = require('node:test');+const optimize = require('../../npm/lib/windows-bin');++test('Windows optimization changes only command shims targeting this installation', () => {+ const root = mkdtempSync(join(tmpdir(), 'ad-windows-bin-'));+ const bin = join(root, 'node_modules/agent-desktop/bin');+ mkdirSync(bin, { recursive: true });+ const binary = join(bin, 'agent-desktop-win32-x64.exe');+ writeFileSync(binary, 'native');+ const command = join(root, 'agent-desktop.cmd');+ const otherCommand = join(root, 'node_modules/.bin/agent-desktop.cmd');+ mkdirSync(join(root, 'node_modules/.bin'), { recursive: true });+ const unrelated = '@echo off\nnode other-package/cli.js %*\n';+ writeFileSync(otherCommand, unrelated);+ const target = relative(root, join(bin, 'agent-desktop'));+ writeFileSync(command, `@echo off\nnode "${target}" %*\n`);+ assert.equal(optimize(bin, 'agent-desktop-win32-x64.exe'), true);+ const installed = readFileSync(command, 'utf8');+ assert.ok(installed.includes(`"${binary}" %*`));+ assert.doesNotMatch(installed, /node(?:\.exe)?[ "\t]/);+ assert.equal(readFileSync(otherCommand, 'utf8'), unrelated);+});diff --git a/tests/npm/wrapper.test.js b/tests/npm/wrapper.test.jsindex 34c58901b..bc4860516 100644--- a/tests/npm/wrapper.test.js+++ b/tests/npm/wrapper.test.js@@ -2,6 +2,8 @@ const assert = require('node:assert/strict');const {chmodSync,closeSync,+ cpSync,+ mkdirSync,openSync,readFileSync,rmSync,@@ -54,17 +56,23 @@ afterEach(() => {}});+function missingBinaryWrapper() {+ const root = temporaryDirectory();+ mkdirSync(join(root, 'bin'));+ cpSync(wrapperScriptPath, join(root, 'bin/agent-desktop'));+ cpSync(join(__dirname, '../../npm/lib'), join(root, 'lib'), { recursive: true });+ return join(root, 'bin/agent-desktop');+}+test('wrapper resolves the released win32-x64 mapping and names the missing-binary cause', async () => {- const { code, stderr } = await runScriptWithOsStub(wrapperScriptPath, 'win32', 'x64', ['version']);+ const { code, stderr } = await runScriptWithOsStub(missingBinaryWrapper(), 'win32', 'x64', ['version']);assert.equal(code, 1);assert.match(stderr, /Error: Native binary not found for win32-x64/);- assert.match(stderr, /--ignore-scripts/);- assert.match(stderr, /pnpm add -g --allow-build=agent-desktop agent-desktop/);- assert.match(stderr, /bun add -g --trust agent-desktop/);+ assert.match(stderr, /installed package is incomplete/);});test('wrapper resolves the released win32-arm64 mapping and exits non-zero when the binary is absent', async () => {- const { code, stderr } = await runScriptWithOsStub(wrapperScriptPath, 'win32', 'arm64', ['version']);+ const { code, stderr } = await runScriptWithOsStub(missingBinaryWrapper(), 'win32', 'arm64', ['version']);assert.equal(code, 1);assert.match(stderr, /Error: Native binary not found for win32-arm64/);assert.match(stderr, /Expected: .*agent-desktop-win32-arm64\.exe/);diff --git a/tests/release/prepare.test.js b/tests/release/prepare.test.jsnew file mode 100644index 000000000..45f626428--- /dev/null+++ b/tests/release/prepare.test.js@@ -0,0 +1,77 @@+const assert = require('node:assert/strict');+const { execFileSync, spawnSync } = require('node:child_process');+const { mkdirSync, mkdtempSync, readFileSync, writeFileSync } = require('node:fs');+const { tmpdir } = require('node:os');+const { join, resolve } = require('node:path');+const { test } = require('node:test');++function fixture() {+ const root = mkdtempSync(join(tmpdir(), 'ad-release-gate-'));+ for (const name of ['scripts', 'npm', 'tools']) mkdirSync(join(root, name));+ writeFileSync(join(root, 'npm/package.json'), '{"version":"0.10.2"}');+ writeFileSync(join(root, 'scripts/check-release-consistency.sh'), 'exit 0\n');+ writeFileSync(join(root, 'tools/npm'), '#!/bin/sh\nprintf "%s\\n" "$TEST_NPM_VERSION"\n', { mode: 0o755 });+ writeFileSync(join(root, 'tools/gh'), '#!/bin/sh\nif [ "$1" = release ]; then exit "$TEST_GITHUB_STATUS"; fi\nprintf "%s\\n" "$*" >> "$TEST_GH_LOG"\n', { mode: 0o755 });+ const git = (...args) => execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim();+ git('init', '-q');+ git('config', 'user.name', 'Lahfir');+ git('config', 'user.email', '[email protected]');+ git('add', '.');+ git('commit', '-qm', 'test: create release fixture');+ return { root, git };+}++for (const scenario of [+ { name: 'unchanged published version skips publication', npm: '0.10.2', github: '0', release: 'false', githubRelease: 'false' },+ { name: 'new version prepares publication', npm: '0.10.1', github: '1', release: 'true', githubRelease: 'true' },+ { name: 'missing GitHub release rebuilds the tagged source without republishing npm', npm: '0.10.2', github: '1', release: 'false', githubRelease: 'true', tagged: true },+]) {+ test(scenario.name, { skip: process.platform === 'win32' }, () => {+ const { root, git } = fixture();+ const source = git('rev-parse', 'HEAD');+ if (scenario.tagged) {+ git('tag', '--no-sign', '-m', 'test: release fixture', 'v0.10.2');+ writeFileSync(join(root, 'later.txt'), 'subsequent main commit');+ git('add', '.');+ git('commit', '-qm', 'test: advance main after tag');+ }+ const output = join(root, 'output');+ const log = join(root, 'gh.log');+ writeFileSync(log, '');+ execFileSync('bash', [resolve(__dirname, '../../scripts/prepare-release.sh')], {+ cwd: root,+ env: { ...process.env, PATH: `${join(root, 'tools')}:${process.env.PATH}`,+ GH_REPO: 'fixture/agent-desktop', GITHUB_OUTPUT: output,+ TEST_NPM_VERSION: scenario.npm, TEST_GITHUB_STATUS: scenario.github, TEST_GH_LOG: log },+ });+ const values = Object.fromEntries(readFileSync(output, 'utf8').trim().split('\n').map((line) => line.split('=')));+ assert.equal(values.should_release, scenario.release);+ assert.equal(values.needs_github_release, scenario.githubRelease);+ assert.equal(values.source_sha, source);+ assert.equal(values.tag_name, 'v0.10.2');+ const calls = readFileSync(log, 'utf8');+ if (scenario.release === 'true') assert.ok(calls.includes(`sha=${source}`));+ else assert.equal(calls, '');+ });+}++test('release checkout accepts only commits in the triggering history', { skip: process.platform === 'win32' }, () => {+ const { root, git } = fixture();+ const ancestor = git('rev-parse', 'HEAD');+ writeFileSync(join(root, 'later.txt'), 'trusted main change');+ git('add', '.');+ git('commit', '-qm', 'test: advance trusted main');+ const workflow = git('rev-parse', 'HEAD');+ git('checkout', '--orphan', 'unrelated');+ git('commit', '-qm', 'test: create unrelated history');+ const unrelated = git('rev-parse', 'HEAD');+ git('checkout', '--detach', workflow);+ for (const source of [unrelated, 'main; exit 0', ancestor]) {+ const result = spawnSync('bash', [resolve(__dirname, '../../scripts/checkout-release-source.sh')], {+ cwd: root, encoding: 'utf8',+ env: { ...process.env, RELEASE_SOURCE_SHA: source, RELEASE_WORKFLOW_SHA: workflow },+ });+ assert.equal(result.status, source === ancestor ? 0 : 1, result.stderr);+ assert.equal(git('rev-parse', 'HEAD'), source === ancestor ? ancestor : workflow);+ }+});