fix(setup): drop stale Qwen tcp endpoints and name rewritten entry keys
Qwen prefers a tcp websocket endpoint over command, so a command entry that still has tcp stays remote. Setup now removes that key. The approval plan names startup_timeout_sec and Copilot tools when setup replaces them.
This commit is contained in:
committed by
xeropresence
parent
0cd9f47ff1
commit
53ba7e7b31
@@ -64,7 +64,7 @@ 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`, `headers`,
|
||||
and `oauth_resource` that contradict the local command, and an entry-level
|
||||
`oauth_resource`, and `tcp` 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`
|
||||
|
||||
@@ -1525,6 +1525,9 @@ const REGISTRATION_REMOTE_KEYS: Readonly<Record<string, 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,
|
||||
// Qwen treats `tcp` as a websocket endpoint and prefers it over `command`,
|
||||
// so a command entry that still has `tcp` stays remote.
|
||||
tcp: true,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { MCP_STARTUP_POLICY } from "../mcpStartupPolicy.js";
|
||||
import { runSetup } from "./Setup.js";
|
||||
import type { SetupProgressEvent } from "./SetupTypes.js";
|
||||
import { FakeSetupHost, options } from "./Setup.fixture.js";
|
||||
@@ -153,34 +154,15 @@ describe("setup workflow", () => {
|
||||
"configure_client:codex",
|
||||
]);
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
"Remote-server keys and switches that turn the server off are removed",
|
||||
`startup_timeout_sec, which setup sets to ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)}`,
|
||||
);
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
"remote-server keys and switches that turn the server off, which are removed",
|
||||
);
|
||||
expect(host.hopperInstalls).toBe(0);
|
||||
expect(host.configurations).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps Grok Build's entry disabled flag in the approval plan", async () => {
|
||||
const host = new FakeSetupHost();
|
||||
host.hopper = "/Applications/Hopper";
|
||||
host.skill = "unchanged";
|
||||
host.clients = [
|
||||
{
|
||||
name: "grok_build",
|
||||
displayName: "Grok Build",
|
||||
configPath: "/grok.toml",
|
||||
},
|
||||
];
|
||||
|
||||
const result = await runSetup(
|
||||
{ ...options(false), dryRun: true, clientIds: ["grok_build"] },
|
||||
host,
|
||||
);
|
||||
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
"the entry disabled flag is kept",
|
||||
);
|
||||
});
|
||||
|
||||
it("installs Hopper when unattended authorization is explicit", async () => {
|
||||
const host = new FakeSetupHost("linux");
|
||||
host.distribution = {
|
||||
@@ -210,6 +192,55 @@ describe("setup workflow", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("setup approval disclosure", () => {
|
||||
it("keeps Grok Build's entry disabled flag in the approval plan", async () => {
|
||||
const host = new FakeSetupHost();
|
||||
host.hopper = "/Applications/Hopper";
|
||||
host.skill = "unchanged";
|
||||
host.clients = [
|
||||
{
|
||||
name: "grok_build",
|
||||
displayName: "Grok Build",
|
||||
configPath: "/grok.toml",
|
||||
},
|
||||
];
|
||||
|
||||
const result = await runSetup(
|
||||
{ ...options(false), dryRun: true, clientIds: ["grok_build"] },
|
||||
host,
|
||||
);
|
||||
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
`startup_timeout_sec, which setup sets to ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)}`,
|
||||
);
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
"The entry disabled flag is kept.",
|
||||
);
|
||||
});
|
||||
|
||||
it("discloses that Copilot tool selection is replaced", async () => {
|
||||
const host = new FakeSetupHost();
|
||||
host.hopper = "/Applications/Hopper";
|
||||
host.skill = "unchanged";
|
||||
host.clients = [
|
||||
{
|
||||
name: "copilot_cli",
|
||||
displayName: "GitHub Copilot CLI",
|
||||
configPath: "/copilot.json",
|
||||
},
|
||||
];
|
||||
|
||||
const result = await runSetup(
|
||||
{ ...options(false), dryRun: true, clientIds: ["copilot_cli"] },
|
||||
host,
|
||||
);
|
||||
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
"tools, which setup sets to every tool",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setup workflow lifecycle and provider planning", () => {
|
||||
it("reports append-only lifecycle progress for each selected action", async () => {
|
||||
const host = new FakeSetupHost();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { join } from "node:path";
|
||||
|
||||
import { MCP_STARTUP_POLICY } from "../mcpStartupPolicy.js";
|
||||
import { isOwnedClientRegistrationCommand } from "./ClientRegistrationIdentity.js";
|
||||
import {
|
||||
linuxHopperInstallDisclosure,
|
||||
@@ -259,8 +260,10 @@ const setupPlan = (input: {
|
||||
label: client.displayName ?? client.name,
|
||||
target: client.configPath,
|
||||
detail: clientConfigurationDetail(
|
||||
client.name,
|
||||
client.displayName ?? client.name,
|
||||
{
|
||||
name: client.name,
|
||||
label: client.displayName ?? client.name,
|
||||
},
|
||||
input.command,
|
||||
input.providerEnvironment,
|
||||
input.installHopper,
|
||||
@@ -304,8 +307,7 @@ const majorVersion = (version: string): number =>
|
||||
Number.parseInt(version.split(".")[0] ?? "0", 10);
|
||||
|
||||
const clientConfigurationDetail = (
|
||||
clientName: string,
|
||||
client: string,
|
||||
client: { readonly name: string; readonly label: string },
|
||||
command: readonly string[],
|
||||
environment: SetupProviderEnvironment,
|
||||
installHopper: boolean,
|
||||
@@ -313,10 +315,7 @@ const clientConfigurationDetail = (
|
||||
const entries = Object.entries(environment)
|
||||
.sort(([left], [right]) => compareUnicodeCodePoints(left, right))
|
||||
.map(([name, value]) => `${name}=${value}`);
|
||||
const retainedFields =
|
||||
clientName === "grok_build"
|
||||
? "On an existing local command entry, other fields are retained. Remote-server keys and an enabled: false switch are removed; the entry disabled flag is kept. When that entry is remote, its other fields are replaced."
|
||||
: "On an existing local command entry, other fields are retained. Remote-server keys and switches that turn the server off are removed. When that entry is remote, its other fields are replaced.";
|
||||
const retainedFields = localEntryDisclosure(client.name);
|
||||
const environmentDetail =
|
||||
entries.length === 0
|
||||
? ` No additional provider environment variables. Existing server environment overrides are retained. ${retainedFields}`
|
||||
@@ -326,5 +325,21 @@ const clientConfigurationDetail = (
|
||||
? " If this plan installs Hopper, REA will add HOPPER_LAUNCHER_PATH using the launcher path reported by that installation."
|
||||
: " The HOPPER_LAUNCHER_PATH value shown above is the current fallback; if this plan installs Hopper, REA will replace it with the launcher path reported by that installation."
|
||||
: "";
|
||||
return `Add the REA MCP registration for ${client}; preserve unrelated configuration. Command: ${command.map((part) => JSON.stringify(part)).join(" ")}.${environmentDetail}${hopperDetail}`;
|
||||
return `Add the REA MCP registration for ${client.label}; preserve unrelated configuration. Command: ${command.map((part) => JSON.stringify(part)).join(" ")}.${environmentDetail}${hopperDetail}`;
|
||||
};
|
||||
|
||||
/** Say which entry fields setup rewrites, removes, or keeps before approval. */
|
||||
const localEntryDisclosure = (clientName: string): string => {
|
||||
const rewritten =
|
||||
clientName === "codex" || clientName === "grok_build"
|
||||
? `startup_timeout_sec, which setup sets to ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)}, `
|
||||
: clientName === "copilot_cli"
|
||||
? "tools, which setup sets to every tool, "
|
||||
: "";
|
||||
const removed =
|
||||
clientName === "grok_build"
|
||||
? "remote-server keys and an enabled: false switch, which are removed. The entry disabled flag is kept."
|
||||
: "remote-server keys and switches that turn the server off, which are removed.";
|
||||
const exceptions = rewritten === "" ? removed : `${rewritten}and ${removed}`;
|
||||
return `On an existing local command entry, user fields are kept except ${exceptions} When that entry is remote, its other fields are replaced.`;
|
||||
};
|
||||
|
||||
@@ -138,6 +138,35 @@ it("drops Codex oauth_resource from a local command entry", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("drops a Qwen tcp endpoint from a local command entry", async () => {
|
||||
const root = await createTestTempDirectory("rea-registration-tcp-");
|
||||
const configPath = join(root, "settings.json");
|
||||
const client: SetupClient = {
|
||||
name: "qwen_code",
|
||||
format: "json",
|
||||
configPath,
|
||||
};
|
||||
const existing = {
|
||||
...clientRegistrationEntry("json", ["rea-old", "mcp"], environment),
|
||||
timeout: 600000,
|
||||
tcp: "ws://stale.example/mcp",
|
||||
};
|
||||
await writeFile(
|
||||
configPath,
|
||||
serializeClientConfiguration(configurationWith("json", existing), "json"),
|
||||
);
|
||||
expect(await configureClientConfiguration(client, {}, command)).toMatchObject(
|
||||
{ status: "configured" },
|
||||
);
|
||||
expect(
|
||||
parseClientConfiguration(await readFile(configPath, "utf8"), "json").servers
|
||||
.rea,
|
||||
).toEqual({
|
||||
...clientRegistrationEntry("json", command, environment),
|
||||
timeout: 600000,
|
||||
});
|
||||
});
|
||||
|
||||
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