Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/desktop-commander-worker-promote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: desktop-commander worker promote

on:
workflow_dispatch:
inputs:
upload_run_id:
description: Successful desktop-commander publish run ID
required: true
type: string
upload_run_attempt:
description: Successful upload attempt number
required: true
type: string
confirm_promotion:
description: Promote the exact uploaded version to 100 percent
required: true
type: boolean
default: false

permissions:
actions: read
contents: read

concurrency:
group: desktop-commander-worker-lifecycle
cancel-in-progress: false

jobs:
promote-version:
if: github.ref == 'refs/heads/main' && inputs.confirm_promotion
name: Verify and promote desktop-commander Worker Version
runs-on: ubuntu-24.04
timeout-minutes: 20
environment: desktop-commander-production
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24.22.0
cache: npm
cache-dependency-path: pkgs/desktop-commander/worker/package-lock.json
- name: Install pinned cf CLI
working-directory: pkgs/desktop-commander/worker
run: npm ci --no-audit --no-fund
- name: Verify selected upload attempt
working-directory: pkgs/desktop-commander/worker
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
UPLOAD_RUN_ID: ${{ inputs.upload_run_id }}
UPLOAD_RUN_ATTEMPT: ${{ inputs.upload_run_attempt }}
VERIFIED_UPLOAD_RUN_FILE: ${{ runner.temp }}/desktop-commander-worker-verified-run.json
run: node verify-upload-run.mjs "$UPLOAD_RUN_ID" "$UPLOAD_RUN_ATTEMPT" "$VERIFIED_UPLOAD_RUN_FILE"
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: desktop-commander-worker-upload-${{ inputs.upload_run_id }}-${{ inputs.upload_run_attempt }}
path: ${{ runner.temp }}/desktop-commander-worker-provenance
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ inputs.upload_run_id }}
- name: Promote only the verified upload
working-directory: pkgs/desktop-commander/worker
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
DC_WORKER_CF_TOKEN: ${{ secrets.DESKTOP_COMMANDER_WORKER_CF_TOKEN }}
DC_WORKER_VERIFIED_RUN_FILE: ${{ runner.temp }}/desktop-commander-worker-verified-run.json
GITHUB_REPOSITORY: ${{ github.repository }}
run: node promote.mjs --manifest "${{ runner.temp }}/desktop-commander-worker-provenance/desktop-commander-worker-provenance.json" --promote
83 changes: 83 additions & 0 deletions .github/workflows/desktop-commander-worker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: desktop-commander worker publish

on:
workflow_dispatch:
inputs:
confirm_upload:
description: Confirm upload of a desktop-commander Worker version from main
required: true
type: boolean
default: false

permissions:
contents: read

concurrency:
group: desktop-commander-worker-lifecycle
cancel-in-progress: false

jobs:
publish-version:
if: github.ref == 'refs/heads/main' && inputs.confirm_upload
name: Upload desktop-commander Worker Version
runs-on: ubuntu-24.04
timeout-minutes: 15
environment: desktop-commander-production
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24.22.0
cache: npm
cache-dependency-path: pkgs/desktop-commander/worker/package-lock.json
- name: Install pinned cf CLI
working-directory: pkgs/desktop-commander/worker
run: npm ci --no-audit --no-fund
- name: Run Worker tests
working-directory: pkgs/desktop-commander/worker
run: npm test
- name: Validate Worker build without credentials
working-directory: pkgs/desktop-commander/worker
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
GITHUB_SHA: ${{ github.sha }}
run: node upload-version.mjs --dry-run
- name: Stage bridge-door secrets file
env:
BRIDGE_ACCESS_CLIENT_ID: ${{ secrets.BRIDGE_ACCESS_CLIENT_ID }}
BRIDGE_ACCESS_CLIENT_SECRET: ${{ secrets.BRIDGE_ACCESS_CLIENT_SECRET }}
run: |
umask 077
python3 - "$RUNNER_TEMP/desktop-commander-secrets.json" <<'PY'
import json, os, sys
data = {
"ACCESS_CLIENT_ID": os.environ["BRIDGE_ACCESS_CLIENT_ID"],
"ACCESS_CLIENT_SECRET": os.environ["BRIDGE_ACCESS_CLIENT_SECRET"],
}
if not all(data.values()):
raise SystemExit("bridge Access secrets are empty")
with open(sys.argv[1], "w") as f:
json.dump(data, f)
PY
- name: Upload Worker Version and capture provenance
working-directory: pkgs/desktop-commander/worker
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
DC_WORKER_CF_TOKEN: ${{ secrets.DESKTOP_COMMANDER_WORKER_CF_TOKEN }}
DC_WORKER_SECRETS_FILE: ${{ runner.temp }}/desktop-commander-secrets.json
DC_WORKER_PROVENANCE_FILE: ${{ runner.temp }}/desktop-commander-worker-provenance.json
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REF: ${{ github.ref }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
GITHUB_SHA: ${{ github.sha }}
run: node upload-version.mjs
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: desktop-commander-worker-upload-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/desktop-commander-worker-provenance.json
if-no-files-found: error
retention-days: 90
39 changes: 39 additions & 0 deletions .github/workflows/desktop-commander-worker-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: desktop-commander worker tests

on:
push:
branches: [main]
paths:
- "pkgs/desktop-commander/worker/**"
- ".github/workflows/desktop-commander-worker-tests.yml"
pull_request:
paths:
- "pkgs/desktop-commander/worker/**"
- ".github/workflows/desktop-commander-worker-tests.yml"

permissions:
contents: read

jobs:
test:
name: Worker tests and typecheck
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24.22.0
cache: npm
cache-dependency-path: pkgs/desktop-commander/worker/package-lock.json
- name: Install dependencies
working-directory: pkgs/desktop-commander/worker
run: npm ci --no-audit --no-fund
- name: Run Worker tests
working-directory: pkgs/desktop-commander/worker
run: npm test
- name: Typecheck
working-directory: pkgs/desktop-commander/worker
run: npm run typecheck
35 changes: 35 additions & 0 deletions home/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ let
# Commander" plugin. See pkgs/desktop-commander for the packaging; the
# desktop-commander-remote unit below keeps the device agent online.
desktop-commander = pkgs.callPackage ../../pkgs/desktop-commander { };
# supergateway: the stdio <-> streamable-HTTP bridge that fronts the
# packaged Desktop Commander for the self-hosted endpoint (#13404).
# See pkgs/supergateway; the desktop-commander-bridge unit below runs it.
supergateway = pkgs.callPackage ../../pkgs/supergateway { };
# Hidden-shell auth hook (1Password service account, Cloudflare).
# Same derivation nixos/agent-auth uses, so the BASH_ENV paths agree.
agent-shell-env = pkgs.callPackage ../../pkgs/agent-shell-env { };
Expand Down Expand Up @@ -1069,6 +1073,37 @@ in
Install.WantedBy = [ "default.target" ];
};

# Self-hosted Desktop Commander endpoint (#13404): the local half of
# commander.security.cab. supergateway wraps the packaged Desktop
# Commander (stdio) as a streamable-HTTP MCP server on
# 127.0.0.1:8931/mcp; the sandbox-link Cloudflare Tunnel carries it to
# the bridge door (commander-link.security.cab, Access service-token
# only), where the desktop-commander Worker picks it up. This unit
# replaces nothing: the vendor device agent above stays until the
# self-hosted endpoint is verified and is stood down separately.
#
# PATH matters for the same reason it does in
# desktop-commander-remote above: the wrapped server exists to run
# arbitrary user commands, so it needs the real user PATH.
systemd.user.services.desktop-commander-bridge = {
Unit = {
Description = "Desktop Commander local MCP bridge (stdio to streamable HTTP, 127.0.0.1:8931)";
After = [ "network-online.target" ];
Wants = [ "network-online.target" ];
};
Service = {
ExecStart = toString (
pkgs.writeShellScript "desktop-commander-bridge-start"
export PATH="/run/current-system/sw/bin:/run/wrappers/bin:/etc/profiles/per-user/$USER/bin:$HOME/.nix-profile/bin:$PATH"
exec ${supergateway}/bin/supergateway --stdio ${desktop-commander}/bin/desktop-commander --outputTransport streamableHttp --streamableHttpPath /mcp --port 8931 --host 127.0.0.1 --stateful --healthEndpoint /healthz --logFormat json

);
Restart = "on-failure";
RestartSec = 5;
};
Install.WantedBy = [ "default.target" ];
};

# ── Service cascade (2026-11-03) ─────────────────────────────────
# The three standing services are defined by the fleet's layered
# modules now, not by hand-rolled units in this file:
Expand Down
77 changes: 77 additions & 0 deletions pkgs/desktop-commander/worker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# desktop-commander Worker — self-hosted MCP endpoint (#13404)

The self-hosted replacement for the vendor's metered Remote Desktop
Commander relay. The vendor's hosted plan meters tool calls (free tier
10,000/month, Pro $20/month); this endpoint has no meter and keeps the
whole path inside the fleet's own Cloudflare account and hardware.

## Path of a request

```
AI client
-> POST https://commander.security.cab/mcp
Access app "desktop-commander": owner Google identity (the IdP
wired under #12412 with the client saved under #12417), or the
"desktop-commander" service token for machine clients.
-> this Worker (src/index.ts): refuses requests without an Access
JWT assertion, then proxies the streamable-HTTP MCP request,
swapping the caller's Access material for its own egress token.
-> https://commander-link.security.cab/mcp
Access app "desktop-commander link (bridge)": service-token-only
policy (the atlas-search pattern).
-> sandbox-link Cloudflare Tunnel -> http://localhost:8931 on amd
-> supergateway (systemd user unit desktop-commander-bridge,
pkgs/supergateway) in streamable-HTTP mode
-> the packaged Desktop Commander (pkgs/desktop-commander, stdio)
```

`workers_dev` is off; `commander.security.cab` (a Worker custom
domain) is the only public door.

## Secrets — by name only, never values

| Where | Name |
| --- | --- |
| fleet secrets (Bitwarden) | `cloudflare.access.desktop-commander-link-client-id` / `-client-secret` — bridge-door token the Worker presents |
| fleet secrets (Bitwarden) | `cloudflare.access.desktop-commander-client-id` / `-client-secret` — public-door token for machine MCP clients |
| fleet secrets (Bitwarden) | `cloudflare.api-token-desktop-commander-worker` — scoped deploy token |
| GitHub environment `desktop-commander-production` | `DESKTOP_COMMANDER_WORKER_CF_TOKEN` (same deploy token), `BRIDGE_ACCESS_CLIENT_ID`, `BRIDGE_ACCESS_CLIENT_SECRET` |
| Worker version secrets | `ACCESS_CLIENT_ID`, `ACCESS_CLIENT_SECRET` — uploaded per version by the publish workflow from the environment secrets |

## Deploys — cf version deployments via GitHub Actions

Modeled on the id-mail publisher/promoter pair:

1. **Publish** (`desktop-commander-worker-publish.yml`, manual dispatch
on main, `confirm_upload`): tests, a credential-free dry run, then
`upload-version.mjs` runs `cf workers versions create` with the
bridge secrets file. Uploading changes no traffic. The run emits a
provenance artifact naming the exact version, tag, and baseline.
2. **Promote** (`desktop-commander-worker-promote.yml`, manual dispatch
with the publish run id + attempt, `confirm_promotion`):
`verify-upload-run.mjs` vouches the run was a successful manual
publish on main, then `promote.mjs` checks the live deployment
still matches the manifest baseline and creates a deployment with
exactly that version at 100%.

Tests (`desktop-commander-worker-tests.yml`) run on pushes and PRs
touching this directory.

## Laptop side

- `desktop-commander-bridge.service` (user unit; defined in
`home/common/default.nix` next to `desktop-commander-remote`):
supergateway wrapping the packaged Desktop Commander on
`127.0.0.1:8931`, path `/mcp`, stateful sessions, `/healthz` for
gateway health.
- The vendor device agent (`desktop-commander-remote.service`) stays
running until this endpoint is verified end to end; standing it down
is a separate recorded step.

## Client setup

- Header-capable clients (Claude Code, Cursor, mcpx): send
`CF-Access-Client-Id` / `CF-Access-Client-Secret` with the
public-door token values.
- Browser clients: sign in with the owner's Google identity at the
Access prompt.
20 changes: 20 additions & 0 deletions pkgs/desktop-commander/worker/cloudflare.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { bindings, defineConfig } from "cf/config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };

// desktop-commander Worker — deployment source of truth for the cf
// versions flow (see README.md). Mirrors wrangler.toml, kept in step
// as the human-readable config record. The Worker's secrets
// (ACCESS_CLIENT_ID, ACCESS_CLIENT_SECRET) are never here: fleet
// secrets hold them by name, and a publish uploads them with the new
// version (cf workers versions create --secrets-file) so no version
// ever deploys without its bridge credentials.
export default defineConfig({
worker: {
name: "desktop-commander",
compatibilityDate: "2025-09-15",
entrypoint,
env: {
BRIDGE_BASE: bindings.text("https://commander-link.security.cab"),
},
},
});
1 change: 1 addition & 0 deletions pkgs/desktop-commander/worker/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"compatibilityDate":"2025-09-15","routes":["commander.security.cab"],"worker":"desktop-commander","workersDev":false}
Loading