Skip to content

remove local user agent#1242

Closed
RhysSullivan wants to merge 2 commits into
mainfrom
surface-cli-desktop
Closed

remove local user agent#1242
RhysSullivan wants to merge 2 commits into
mainfrom
surface-cli-desktop

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

The headless apps/local server is always launched by the executor CLI (executor mcp / web / daemon run / the installed background service) unless the desktop app spawns it with EXECUTOR_CLIENT=desktop. Report it as cli instead of local, and narrow SurfaceClient to cli | desktop so the User-Agent surface is only ever one of the two.

  • apps/local client resolver falls back to cli (desktop still wins when EXECUTOR_CLIENT=desktop)
  • SurfaceClient type narrowed to "cli" | "desktop", compiler-enforced
  • registry UA formatting test updated off local

The headless apps/local server is always launched by the executor CLI (executor mcp / web / daemon run / installed service) unless the desktop app spawns it with EXECUTOR_CLIENT=desktop. Report it as cli instead of local and narrow SurfaceClient to cli | desktop so the surface is only ever one of the two.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 1c83945 Commit Preview URL

Branch Preview URL
Jul 01 2026, 08:19 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 1c83945 Jul 01 2026, 08:19 PM

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown

Greptile Summary

This PR removes the "local" surface client from the User-Agent by narrowing SurfaceClient to "cli" | "desktop" and ensuring EXECUTOR_CLIENT is always stamped to a valid value before apps/local initialises its User-Agent string.

  • A new client-env.ts side-effect module stamps EXECUTOR_CLIENT=cli (via ??=, preserving any pre-existing "desktop" value) and is imported at the very top of main.ts, before the @executor-js/local import graph loads.
  • installation.ts replaces the old desktop-or-local ternary with an allowlist check against SURFACE_CLIENTS, falling back to "cli" for unknown or missing values.
  • The SurfaceClient type is narrowed to "cli" | "desktop" with compiler enforcement, and one test case is updated accordingly.

Confidence Score: 5/5

Safe to merge — the change is a clean rename/narrowing with no behavioural risk in normal launch paths.

The env-var stamping uses ??= so it can never clobber a pre-existing "desktop" value set by the desktop launcher. The allowlist check in resolveClient() gracefully degrades unknown values to "cli", meaning legacy or misconfigured environments won't break. The import order in main.ts guarantees the stamp happens before any module that reads the env var at init time. No data, auth, or runtime logic is touched — this is purely a User-Agent surface label change.

No files require special attention.

Important Files Changed

Filename Overview
apps/cli/src/client-env.ts New side-effect module that stamps EXECUTOR_CLIENT=cli via ??= before the local server's import graph loads; preserves any pre-existing desktop value set by the desktop launcher.
apps/cli/src/main.ts Adds import "./client-env" as an early side-effect right after native-bindings, ensuring the env var is stamped before @executor-js/local initialises its User-Agent.
apps/local/src/installation.ts Replaces the old desktop-or-local ternary with a SURFACE_CLIENTS allowlist check and a "cli" fallback, correctly covering all launch paths and unknown values.
packages/core/integrations-registry/src/registry.ts Removes "local" from SurfaceClient, narrowing the union to `"cli"
packages/core/integrations-registry/src/registry.test.ts Updates the buildUserAgent test case from "local" to "desktop" to align with the narrowed type; no logic change.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Desktop as Desktop App
    participant CLI as executor CLI (main.ts)
    participant Env as process.env
    participant Local as apps/local (installation.ts)
    participant UA as User-Agent

    Note over CLI: import "./native-bindings"
    Note over CLI: import "./client-env"
    CLI->>Env: "EXECUTOR_CLIENT ??= "cli""

    alt Desktop launched CLI
        Desktop->>Env: "EXECUTOR_CLIENT = "desktop" (pre-set)"
        Note over Env: ??= preserves "desktop"
    end

    Note over Local: module init — resolveClient()
    Local->>Env: read EXECUTOR_CLIENT
    alt value in ["cli","desktop"]
        Env-->>Local: "cli" or "desktop"
    else missing / unknown value
        Env-->>Local: fallback → "cli"
    end
    Local->>UA: "buildUserAgent({ client: "cli" | "desktop" })"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Desktop as Desktop App
    participant CLI as executor CLI (main.ts)
    participant Env as process.env
    participant Local as apps/local (installation.ts)
    participant UA as User-Agent

    Note over CLI: import "./native-bindings"
    Note over CLI: import "./client-env"
    CLI->>Env: "EXECUTOR_CLIENT ??= "cli""

    alt Desktop launched CLI
        Desktop->>Env: "EXECUTOR_CLIENT = "desktop" (pre-set)"
        Note over Env: ??= preserves "desktop"
    end

    Note over Local: module init — resolveClient()
    Local->>Env: read EXECUTOR_CLIENT
    alt value in ["cli","desktop"]
        Env-->>Local: "cli" or "desktop"
    else missing / unknown value
        Env-->>Local: fallback → "cli"
    end
    Local->>UA: "buildUserAgent({ client: "cli" | "desktop" })"
Loading

Reviews (2): Last reviewed commit: "always set EXECUTOR_CLIENT so the surfac..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Jul 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1242

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1242

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1242

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1242

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1242

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1242

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1242

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1242

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1242

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1242

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1242

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1242

executor

npm i https://pkg.pr.new/executor@1242

commit: d9b251b

The CLI now stamps EXECUTOR_CLIENT=cli at startup (preserving desktop's own EXECUTOR_CLIENT=desktop), so the in-process apps/local server always sees an explicit surface. apps/local passes the value through, validated, instead of defaulting not-desktop to a guess.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant