From 502e6652121df7668943d88aa96749a10665c32d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 12 Oct 2026 03:41:29 +0000 Subject: [PATCH] fix(setup): drop stale Codex oauth_resource and disclose remote replacement A command entry that still carries oauth_resource is rejected by Codex for stdio. Setup now treats that key as remote and removes it. The approval plan keeps other fields only for a local command entry and says a remote entry's other fields are replaced. --- docs/installation.md | 12 ++++---- .../ClientConfigurationDocument.ts | 3 ++ src/application/Setup.planning.test.ts | 3 ++ src/application/SetupPlan.ts | 6 ++-- .../clientRegistrationFields.test.ts | 28 +++++++++++++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index a10003ce3..b8f98663b 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -63,12 +63,12 @@ Detected provider settings replace only matching environment keys. Other fields you added to that entry, such as OMP's `timeout` or Codex's `tool_timeout_sec`, are kept. Setup rewrites only the launch keys (`command`, `args`, `type` or `transport`, and the environment map) and REA's -client-specific keys. It removes remote-server keys such as `url` and `headers` -that contradict the local command, and an entry-level `enabled: false` or -(outside Grok Build) `disabled: true`, so the registration is active. An -existing entry without a `command` is a remote server and is replaced whole. A -legacy OpenCode entry moved into the native `mcp.servers` table keeps only its -environment. +client-specific keys. It removes remote-server keys such as `url`, `headers`, +and `oauth_resource` that contradict the local command, and an entry-level +`enabled: false` or (outside Grok Build) `disabled: true`, so the registration +is active. An existing entry without a `command` is a remote server and is +replaced whole. A legacy OpenCode entry moved into the native `mcp.servers` +table keeps only its environment. Setup and doctor report a malformed REA environment map or invalid runtime setting before setup writes files. Repair the named setting in the client configuration; setup does not silently discard the rest of the map. diff --git a/src/application/ClientConfigurationDocument.ts b/src/application/ClientConfigurationDocument.ts index c5960cd26..ece1d7054 100644 --- a/src/application/ClientConfigurationDocument.ts +++ b/src/application/ClientConfigurationDocument.ts @@ -1522,6 +1522,9 @@ const REGISTRATION_REMOTE_KEYS: Readonly> = { env_http_headers: true, bearer_token_env_var: true, oauth: true, + // Codex serializes `--oauth-resource` as `oauth_resource` and rejects it on + // a command entry (`oauth_resource is not supported for stdio`). + oauth_resource: true, }; /** diff --git a/src/application/Setup.planning.test.ts b/src/application/Setup.planning.test.ts index d1ca6baea..3f4bd7069 100644 --- a/src/application/Setup.planning.test.ts +++ b/src/application/Setup.planning.test.ts @@ -152,6 +152,9 @@ describe("setup workflow", () => { expect(result.plannedActions.map(({ id }) => id)).toEqual([ "configure_client:codex", ]); + expect(result.plannedActions[0]?.detail).toContain( + "replaced when that entry is remote", + ); expect(host.hopperInstalls).toBe(0); expect(host.configurations).toBe(0); }); diff --git a/src/application/SetupPlan.ts b/src/application/SetupPlan.ts index aab48bd63..b333f908e 100644 --- a/src/application/SetupPlan.ts +++ b/src/application/SetupPlan.ts @@ -311,10 +311,12 @@ const clientConfigurationDetail = ( const entries = Object.entries(environment) .sort(([left], [right]) => compareUnicodeCodePoints(left, right)) .map(([name, value]) => `${name}=${value}`); + const retainedFields = + "Other fields are retained on an existing local command entry and replaced when that entry is remote."; const environmentDetail = entries.length === 0 - ? " No additional provider environment variables. Existing server environment overrides are retained, as are other fields on REA's existing entry." - : ` Detected provider environment: ${entries.join(", ")}. Existing server environment overrides are retained; detected values replace matching keys. Other fields on REA's existing entry are retained.`; + ? ` No additional provider environment variables. Existing server environment overrides are retained. ${retainedFields}` + : ` Detected provider environment: ${entries.join(", ")}. Existing server environment overrides are retained; detected values replace matching keys. ${retainedFields}`; const hopperDetail = installHopper ? environment.HOPPER_LAUNCHER_PATH === undefined ? " If this plan installs Hopper, REA will add HOPPER_LAUNCHER_PATH using the launcher path reported by that installation." diff --git a/tests/boundary/filesystem/clientRegistrationFields.test.ts b/tests/boundary/filesystem/clientRegistrationFields.test.ts index a70c7f700..abc286b47 100644 --- a/tests/boundary/filesystem/clientRegistrationFields.test.ts +++ b/tests/boundary/filesystem/clientRegistrationFields.test.ts @@ -110,6 +110,34 @@ it.each([ }, ); +it("drops Codex oauth_resource from a local command entry", async () => { + const root = await createTestTempDirectory( + "rea-registration-oauth-resource-", + ); + const configPath = join(root, "config.toml"); + const client: SetupClient = { name: "codex", format: "toml", configPath }; + const existing = { + ...clientRegistrationEntry("toml", ["rea-old", "mcp"], environment), + tool_timeout_sec: 900, + oauth_resource: "https://stale.example/resource", + }; + await writeFile( + configPath, + serializeClientConfiguration(configurationWith("toml", existing), "toml"), + ); + expect(await configureClientConfiguration(client, {}, command)).toMatchObject( + { status: "configured" }, + ); + expect( + parseClientConfiguration(await readFile(configPath, "utf8"), "toml").servers + .rea, + ).toEqual({ + ...clientRegistrationEntry("toml", command, environment), + startup_timeout_sec: MCP_STARTUP_POLICY.codexStartupTimeoutSeconds, + tool_timeout_sec: 900, + }); +}); + it("replaces a remote server entry instead of merging its fields", async () => { const root = await createTestTempDirectory("rea-registration-remote-"); const configPath = join(root, "mcp.json");