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.
This commit is contained in:
committed by
xeropresence
parent
b478a8b011
commit
502e665212
@@ -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.
|
||||
|
||||
@@ -1522,6 +1522,9 @@ const REGISTRATION_REMOTE_KEYS: Readonly<Record<string, true>> = {
|
||||
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,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user