test(clients): check configured MCP catalogs in native harnesses (#15121)

* test(clients): check configured MCP catalogs in native harnesses

* test(opencode): resolve the native CLI in the isolated home

* ci(clients): identify native catalog discovery in the job log

* test(ci): isolate native clients and preserve registration failures
This commit is contained in:
morluto authored and GitHub committed 2026-11-29 18:03:55 +00:00
1 parent 7025845302
commit 8e18bdecef
11 files changed
+530 -43

No files matched your search

@@ -0,0 +1,78 @@
name: Native MCP registration
on:
workflow_dispatch:
schedule:
- cron: "31 8 * * 2"
pull_request:
paths:
- ".github/workflows/real-client-registration.yml"
- ".nvmrc"
- "package*.json"
- "scripts/rea.mjs"
- "scripts/verify-*-client.mjs"
- "scripts/verify/clients/**"
- "scripts/lib/**"
- "src/application/*Client*.ts"
- "src/application/Setup*.ts"
- "src/cli/**"
- "src/composition/**"
- "src/config/**"
- "src/contracts/**"
- "src/server/**"
- "!src/**/*.test.ts"
permissions:
contents: read
jobs:
scoped-catalog:
runs-on: ubuntu-latest
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
include:
- client: codex
package: "@openai/codex"
version: "0.172.0"
- client: claude
package: "@anthropic-ai/claude-code"
version: "2.1.332"
- client: gemini
package: "@google/gemini-cli"
version: "0.70.0"
- client: opencode
package: "opencode-ai"
version: "1.19.6"
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- name: Verify the catalog in an isolated native client
env:
CLIENT: ${{ matrix.client }}
CLIENT_PACKAGE: ${{ matrix.package }}
CLIENT_VERSION: ${{ github.event_name == 'schedule' && 'latest' || matrix.version }}
run: |
# Only tracked source and these three inputs enter the container.
git archive HEAD | docker run -i --name native-client --user node \
-e CLIENT -e CLIENT_PACKAGE -e CLIENT_VERSION \
-e REA_VERIFY_CODEX_FAILURE_PATH=/tmp/codex-registration-failure.json \
"node:$(cat .nvmrc)-bookworm" bash -eu -o pipefail -c '
cd "$(mktemp -d)"
tar -xf -
npm ci
npm install --prefix /tmp/native-client --no-package-lock --no-audit --no-fund "$CLIENT_PACKAGE@$CLIENT_VERSION"
PATH="/tmp/native-client/node_modules/.bin:$PATH" npm run "verify:${CLIENT}-client" -- scoped-chat
'
- name: Recover Codex failure report
if: failure() && matrix.client == 'codex'
id: diagnostics
run: |
report="$RUNNER_TEMP/codex-registration-failure.json"
if docker cp native-client:/tmp/codex-registration-failure.json "$report" && [[ -f "$report" && ! -L "$report" ]]; then
echo 'available=true' >> "$GITHUB_OUTPUT"
fi
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: failure() && steps.diagnostics.outputs.available == 'true'
with:
name: codex-registration-failure
path: ${{ runner.temp }}/codex-registration-failure.json
+79
View File
@@ -23,6 +23,85 @@ registration through the actual client, including a reduced `PATH` when checking
desktop or service startup. Record the client version and launch environment
separately from terminal doctor results. See [launcher troubleshooting](../getting-started/client-configuration.md#launchers-and-path).
### Check the catalog delivered by a native client
`npm run verify:codex-client` uses the installed Codex app-server and an isolated
`CODEX_HOME`. It reads the registered servers and their tool names after startup.
The production REA server must expose the selected families. Two probes must
receive the literal selector with both the short and structured `env_vars`
spellings, and a third must start with the selector absent. Use
`REA_VERIFY_CODEX_COMMAND` to select a specific executable, including a desktop
build's bundled CLI. On a registration failure, the verifier prints the path to
a JSON report with the status response and the last 64 KiB of client stderr.
The desktop Work window has its own registration path.
Run `npm run verify:claude-client -- scoped-chat`,
`npm run verify:gemini-client -- scoped-chat`, or
`npm run verify:opencode-client -- scoped-chat` with that client installed.
Each lane passes `--tool-families electron,javascript-runtime` only to REA setup.
The client launches with the setting absent from its environment. A loopback
model checks the exact registered tool names and returns a final answer.
Claude Code can advertise deferred names in its system reminder. OpenCode V2
can expose the namespace through its paginated Code Mode search. The receipt
reports how many schemas the client actually sent inline.
The **Native MCP registration** workflow runs pinned client versions on changes
to the covered paths and on manual dispatch. Its weekly run checks the current
npm releases. Each client installs and runs in a container with a copy of the
tracked source and no GitHub credentials or runner mounts. The Codex job uploads
its registration failure report when available.
### Check a desktop release
Use this manual check when verifying a new ChatGPT Work build or investigating
a desktop-specific report. Routine PR coverage runs the native CLI checks above
unattended. Work reads project registrations through a separate launch path.
In a disposable, trusted project, add these entries to `.codex/config.toml`.
Use the absolute path to Node, the probe in a checkout with `npm ci`, and two
unused receipt paths in an existing writable directory. Keep the selector out
of the parent environment so that only the literal registration supplies it.
```toml
[mcp_servers.probe_literal]
command = "/absolute/path/to/node"
args = [
"/checkout/scripts/verify/clients/environment-probe.mjs",
"/test-project/literal.json",
]
env_vars = ["LANG"]
[mcp_servers.probe_literal.env]
REA_MCP_TOOL_FAMILIES = "electron,javascript-runtime"
[mcp_servers.probe_control]
command = "/absolute/path/to/node"
args = [
"/checkout/scripts/verify/clients/environment-probe.mjs",
"/test-project/control.json",
]
env_vars = ["LANG"]
```
1. Open the test project in a fresh Work window and send an ordinary message,
such as “Reply OK without using tools.” The client starts its MCP servers as
part of the turn. A tool call or approval is unnecessary.
2. Read both JSON receipts after the turn. Each probe writes its receipt after
MCP initialization. The literal registration should report
`probe_environment_selected` and the control `probe_environment_absent`.
If neither file appears, check the project, executable, probe, and output
paths before interpreting the result.
3. To investigate structured environment references, change only the control's
`env_vars` to `[{name="LANG", source="local"}]`. Give both servers unused
receipt paths, open a fresh Work window, and repeat. Then move the structured
reference to the literal registration and restore the control to `["LANG"]`.
Repeat with fresh paths and a fresh window. A missing receipt that follows
the structured spelling distinguishes that failure from a server starting
with a missing selector.
Record the app build, bundled CLI version, and receipts for each registration.
Record a stream error separately from the handshake result. The same build can
complete a turn while a server is missing. [Worked example](https://github.com/morluto/rea/issues/15077#issuecomment-7259889703)
## Published Pi code-mode renderer limit
A separate probe of the published `@earendil-works/pi-codemode` 1.1.0 and 1.2.0
+3
View File
@@ -630,6 +630,9 @@ matching real-provider lane.
| Client configuration or schema conversion | [Native client lane](client-verification.md) | Distinguish loopback models from live services |
| Agent investigation quality | [Agent evaluation](#agent-evaluation-and-conformance-records) | Review transcript and scenario-specific evidence |
For a new ChatGPT Work build or a desktop-only report, use the
[manual desktop check](client-verification.md#check-a-desktop-release).
### Provider-backed workflow verification
For a new or changed provider-backed tool, select tests from the analyst's
+1
View File
@@ -286,6 +286,7 @@
"verify:package": "npm run build:cached && node scripts/verify-package.mjs",
"verify:advertised-schemas": "npm run build:cached && node scripts/verify-advertised-schemas.mjs",
"verify:package:windows": "npm run build:cached && node scripts/verify-windows-package.mjs",
"verify:codex-client": "npm run build:cached && node scripts/verify-codex-client.mjs",
"verify:qwen-client": "npm run build:cached && node scripts/verify-qwen-client.mjs",
"verify:gemini-client": "npm run build:cached && node scripts/verify-gemini-client.mjs",
"verify:opencode-client": "npm run build:cached && node scripts/verify-opencode-client.mjs",
+41 -13
View File
@@ -1,3 +1,4 @@
import { clientCatalogFixture } from "./verify/clients/catalog.mjs";
import assert from "node:assert/strict";
import { verifyClientSetupAndReadSkillBody } from "./verify/clients/setup.mjs";
import { createHash } from "node:crypto";
@@ -39,9 +40,10 @@ const runtimeRoot = process.env.REA_VERIFY_RUNTIME_ROOT ?? repo;
const command = process.env.REA_VERIFY_CLAUDE_COMMAND ?? "claude";
const mode = process.argv[2] ?? "call";
assert(
["chat", "call"].includes(mode),
"Usage: verify-claude-client.mjs [chat|call]",
["chat", "scoped-chat", "call"].includes(mode),
"Usage: verify-claude-client.mjs [chat|scoped-chat|call]",
);
const catalogFixture = clientCatalogFixture(mode);
const verifier = createVerifierRun();
const { path: lab } = await VerifierFixture.keepArtifacts({
prefix: "rea-claude-client-",
@@ -79,6 +81,7 @@ await withVerifierCleanup(async () => {
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
REA_PROCESS_RUN_ID: verifier.run_id,
};
delete environment.REA_MCP_TOOL_FAMILIES;
try {
clientVersion = await readClientVersion(commands, command, environment);
} catch (cause) {
@@ -122,6 +125,38 @@ await withVerifierCleanup(async () => {
const analysis = tools.find((t) =>
t.name.endsWith("analyze_javascript_application"),
);
if (
mode === "scoped-chat" &&
tools.some((tool) => tool.name === "ToolSearch")
) {
// Claude advertises deferred names in its own reminder before loading schemas.
const prefix = "mcp__rea__";
const names = new Set(
tools
.map(({ name }) => name)
.filter((name) => name.startsWith(prefix)),
);
const visibleCount = names.size;
for (const message of body.messages) {
if (message.role !== "user" || !Array.isArray(message.content))
continue;
for (const part of message.content) {
if (
part.type !== "text" ||
!part.text.startsWith("<system-reminder>")
)
continue;
for (const line of part.text.split("\n"))
if (line.startsWith(prefix)) names.add(line);
}
}
if (names.size > visibleCount) {
catalogFixture.assertNames(names, prefix);
catalogSize = names.size;
finalSeen = true;
return [{ type: "text", text: "REA_CLIENT_COMPATIBILITY_OK" }];
}
}
if (!analysis) {
// Native automatic discovery can begin the conversation while MCP is still connecting.
const wait = tools.find((t) => t.name === "WaitForMcpServers");
@@ -136,16 +171,8 @@ await withVerifierCleanup(async () => {
0,
-"analyze_javascript_application".length,
);
const expected = sortVerifierNames(
TOOL_CONTRACTS.map((t) => prefix + t.name),
);
const reaTools = tools.filter((t) => t.name.startsWith(prefix));
const reaTools = catalogFixture.check(tools, prefix);
catalogSize = reaTools.length;
assert.deepEqual(
sortVerifierNames(reaTools.map((t) => t.name)),
expected,
"Claude must forward the complete REA catalog after connection",
);
if (schemasChecked === 0) {
for (const tool of reaTools) {
assert(
@@ -234,7 +261,7 @@ await withVerifierCleanup(async () => {
await writeFile(join(lab, "claude-evidence.json"), bytes);
evidenceSeen = true;
}
if (mode === "chat" || (sessionStatusSeen && evidenceSeen)) {
if (mode !== "call" || (sessionStatusSeen && evidenceSeen)) {
finalSeen = true;
return [{ type: "text", text: "REA_CLIENT_COMPATIBILITY_OK" }];
}
@@ -258,6 +285,7 @@ await withVerifierCleanup(async () => {
);
await writeFile(configPath, original);
expectedSkillBody = await verifyClientSetupAndReadSkillBody({
setupArguments: catalogFixture.setupArguments,
client: "claude_code",
commands,
runtimeRoot,
@@ -299,7 +327,7 @@ await withVerifierCleanup(async () => {
],
},
}),
mode === "chat"
mode !== "call"
? "Say hello briefly."
: `Use the REA skill and tools to analyze the JavaScript directory ${target}. Report the result.`,
],
+198
View File
@@ -0,0 +1,198 @@
import assert from "node:assert/strict";
import { randomUUID } from "node:crypto";
import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { createInterface } from "node:readline";
import { fileURLToPath } from "node:url";
import { stringify } from "smol-toml";
import {
spawnOwnedProviderProcess,
ProviderProcessSupervisor,
} from "../dist/process/ProviderProcess.js";
import { cleanupOwnedProcessGroup } from "../dist/process/ProcessOwnership.js";
import { createVerifierCommands } from "./lib/verify-commands.mjs";
import {
VerifierFixture,
withVerifierFixture,
} from "./lib/verifier-fixture.mjs";
import { clientCatalogFixture } from "./verify/clients/catalog.mjs";
import { readClientVersion } from "./verify/clients/version.mjs";
const native = process.env.REA_VERIFY_CODEX_COMMAND ?? "codex";
assert.equal(
process.argv[2] ?? "scoped-chat",
"scoped-chat",
"Usage: verify-codex-client.mjs scoped-chat",
);
const fixture = clientCatalogFixture("scoped-chat");
const probe = fileURLToPath(
new URL("./verify/clients/environment-probe.mjs", import.meta.url),
);
const rea = fileURLToPath(new URL("../scripts/rea.mjs", import.meta.url));
await withVerifierFixture(
await VerifierFixture.open({ prefix: "rea-codex-client-" }),
async (lab) => {
const home = lab.path;
const config = join(home, ".codex");
await mkdir(config);
const environment = {
HOME: home,
USERPROFILE: home,
CODEX_HOME: config,
PATH: process.env.PATH,
LANG: "en_US.UTF-8",
};
const command = { command: process.execPath, args: [probe] };
const env = { REA_MCP_TOOL_FAMILIES: "electron,javascript-runtime" };
await writeFile(
join(config, "config.toml"),
stringify({
mcp_servers: {
plain: { ...command, env_vars: ["LANG"], env },
structured: {
...command,
env_vars: [{ name: "LANG", source: "local" }],
env,
},
control: command,
},
}),
);
const commands = await createVerifierCommands();
lab.releaseAfter(() => commands.close());
const version = await readClientVersion(commands, native, environment, {
cwd: home,
});
const setup = await commands.exec(
process.execPath,
[
rea,
"setup",
"--client",
"codex",
"--skill=false",
...fixture.setupArguments,
"--yes",
"--json",
],
{ cwd: home, env: environment, timeout: 60_000 },
);
assert.equal(JSON.parse(setup.stdout).status, "ready");
const owned = await spawnOwnedProviderProcess({
command: native,
arguments: ["app-server", "--listen", "stdio://"],
stdin: "pipe",
cwd: home,
hostEnvironment: environment,
runId: randomUUID(),
expectedCommand: null,
sweepTokenOwnedProcesses: true,
});
const supervisor = new ProviderProcessSupervisor(
{
...owned,
ownsProcessLifetime: true,
cleanup:
owned.cleanup ?? (() => cleanupOwnedProcessGroup(owned.ownership)),
},
{
captureStdout: false,
maxDiagnosticBytes: 64 * 1024,
diagnosticRetention: "tail",
},
);
lab.releaseAfter(async () => {
const cleanup = await supervisor.stop();
assert.notEqual(
cleanup.status,
"incomplete",
"Codex process cleanup must complete",
);
supervisor.dispose();
});
// Codex app-server uses its own newline-framed protocol on this pipe.
const lines = createInterface({
input: owned.process.stdout,
signal: AbortSignal.timeout(60_000),
});
const reader = lines[Symbol.asyncIterator]();
const send = (message) =>
owned.process.stdin.write(JSON.stringify(message) + "\n");
let statusResponse = null;
const request = async (id, method, params) => {
send({ id, method, params });
for (;;) {
const line = await reader.next();
assert(
!line.done,
`Codex closed the stream before replying to ${method}`,
);
const message = JSON.parse(line.value);
if (message.id !== id) continue;
if (method === "mcpServerStatus/list") statusResponse = message;
assert.equal(message.error, undefined, JSON.stringify(message.error));
return message.result;
}
};
try {
await request(1, "initialize", {
clientInfo: { name: "rea_registration_verifier", version: "1" },
capabilities: { experimentalApi: true },
});
send({ method: "initialized" });
const status = await request(2, "mcpServerStatus/list", { limit: 100 });
assert.equal(
status.nextCursor,
null,
"Expected all four test registrations on the status page",
);
const servers = new Map(
status.data.map((row) => [row.name, Object.keys(row.tools)]),
);
for (const name of ["plain", "structured"])
assert.deepEqual(
servers.get(name),
["probe_environment_selected"],
name,
);
assert.deepEqual(servers.get("control"), ["probe_environment_absent"]);
const tools = servers.get("rea");
assert(tools, "Codex must launch the REA registration");
fixture.assertNames(tools);
process.stdout.write(
JSON.stringify({
client: version,
catalogSize: tools.length,
checked: ["plain", "structured", "control", "rea"],
}) + "\n",
);
} catch (cause) {
// Run after the supervisor drains stderr and before the fixture is removed.
lab.releaseAfter(async () => {
const path =
process.env.REA_VERIFY_CODEX_FAILURE_PATH ??
join(
(
await VerifierFixture.keepArtifacts({
prefix: "rea-codex-failure-",
})
).path,
"codex-registration-failure.json",
);
const report = {
client: version,
error: cause instanceof Error ? cause.message : String(cause),
statusResponse,
stderr: supervisor.snapshot().stderr,
};
await writeFile(path, JSON.stringify(report, null, 2) + "\n");
process.stderr.write(`Codex registration failure report: ${path}\n`);
});
throw cause;
} finally {
lines.close();
owned.process.stdin.end();
}
},
);
+24 -18
View File
@@ -1,13 +1,11 @@
import { clientCatalogFixture } from "./verify/clients/catalog.mjs";
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import Ajv2020 from "ajv/dist/2020.js";
import {
TOOL_CONTRACTS,
toolContract,
} from "../dist/contracts/toolContracts.js";
import { toolContract } from "../dist/contracts/toolContracts.js";
import { isPathWithinRoot } from "../dist/domain/localPath.js";
import { createVerifierCommands } from "./lib/verify-commands.mjs";
import { saveVerifierCommandOutput } from "./lib/verifier-command-output.mjs";
@@ -49,9 +47,10 @@ const launch = (args) =>
? [command, args]
: [process.execPath, [entryPoint, ...args]];
assert(
["chat", "call"].includes(mode),
"Usage: verify-gemini-client.mjs [chat|call]",
["chat", "scoped-chat", "call"].includes(mode),
"Usage: verify-gemini-client.mjs [chat|scoped-chat|call]",
);
const catalogFixture = clientCatalogFixture(mode);
const verifier = createVerifierRun();
const { path: lab } = await VerifierFixture.keepArtifacts({
prefix: "rea-gemini-client-",
@@ -136,8 +135,20 @@ await withVerifierCleanup(async () => {
);
await writeFile(configPath, original);
for (const args of [
["setup", "--client", "gemini_cli", "--dry-run"],
["setup", "--client", "gemini_cli", "--yes"],
[
"setup",
"--client",
"gemini_cli",
...catalogFixture.setupArguments,
"--dry-run",
],
[
"setup",
"--client",
"gemini_cli",
...catalogFixture.setupArguments,
"--yes",
],
["doctor", "--client", "gemini_cli", "--skill"],
]) {
const result = await commands.exec(
@@ -194,6 +205,7 @@ await withVerifierCleanup(async () => {
"setup",
"--client",
"gemini_cli",
...catalogFixture.setupArguments,
"--yes",
"--json",
],
@@ -242,14 +254,8 @@ await withVerifierCleanup(async () => {
0,
-"analyze_javascript_application".length,
);
const expected = TOOL_CONTRACTS.map((t) => prefix + t.name).sort();
const reaTools = tools.filter((t) => expected.includes(t.name));
const reaTools = catalogFixture.check(tools, prefix);
catalogSize = reaTools.length;
assert.deepEqual(
reaTools.map((t) => t.name).sort(),
expected,
"Gemini must forward the complete REA tool catalog",
);
if (schemasChecked === 0) {
for (const tool of reaTools) {
assert(
@@ -303,7 +309,7 @@ await withVerifierCleanup(async () => {
await writeFile(join(lab, "gemini-evidence.json"), bytes);
evidenceSeen = true;
}
if (mode === "chat" || evidenceSeen) {
if (mode !== "call" || evidenceSeen) {
finalSeen = true;
return [{ text: "REA_CLIENT_COMPATIBILITY_OK" }];
}
@@ -341,13 +347,13 @@ await withVerifierCleanup(async () => {
"--model",
"gemini-2.5-flash",
"--approval-mode",
mode === "chat" ? "default" : "yolo",
mode !== "call" ? "default" : "yolo",
"--allowed-mcp-server-names",
"rea",
"--output-format",
"stream-json",
"-p",
mode === "chat"
mode !== "call"
? "Say hello briefly."
: `Use REA to analyze the JavaScript directory ${target}. Report the result.`,
]),
+43 -12
View File
@@ -1,3 +1,4 @@
import { clientCatalogFixture } from "./verify/clients/catalog.mjs";
import assert from "node:assert/strict";
import { verifyClientSetupAndReadSkillBody } from "./verify/clients/setup.mjs";
import { createHash } from "node:crypto";
@@ -5,7 +6,6 @@ import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import Ajv2020 from "ajv/dist/2020.js";
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
import { isPathWithinRoot } from "../dist/domain/localPath.js";
import { createVerifierCommands } from "./lib/verify-commands.mjs";
import { saveVerifierCommandOutput } from "./lib/verifier-command-output.mjs";
@@ -37,8 +37,8 @@ const command = process.env.REA_VERIFY_OPENCODE_COMMAND ?? "opencode";
const mode = process.argv[2] ?? "call";
const configFormat = process.env.REA_VERIFY_OPENCODE_CONFIG_FORMAT ?? "jsonc";
assert(
["chat", "call"].includes(mode),
"Usage: verify-opencode-client.mjs [chat|call]",
["chat", "scoped-chat", "call"].includes(mode),
"Usage: verify-opencode-client.mjs [chat|scoped-chat|call]",
);
const configFilename = new Map([
["json", "opencode.json"],
@@ -48,6 +48,7 @@ assert(
configFilename !== undefined,
"REA_VERIFY_OPENCODE_CONFIG_FORMAT must be json or jsonc",
);
const catalogFixture = clientCatalogFixture(mode);
const verifier = createVerifierRun();
const { path: lab } = await VerifierFixture.keepArtifacts({
prefix: "rea-opencode-client-",
@@ -82,6 +83,7 @@ let expectedSkillBody;
let evidenceSeen = false;
let finalSeen = false;
let catalogSize = null;
let catalogSearchRequested = false;
let schemasChecked = 0;
let artifactDigest;
const commands = await createVerifierCommands();
@@ -93,7 +95,9 @@ await withVerifierCleanup(async () => {
stdin: "pipe",
});
const environment = {
HOME: account,
USERPROFILE: account,
PATH: process.env.PATH ?? "",
OPENCODE_CONFIG_DIR: profile,
XDG_CONFIG_HOME: join(lab, "config"),
XDG_CACHE_HOME: join(lab, "cache"),
@@ -130,19 +134,45 @@ await withVerifierCleanup(async () => {
const analysis = tools.find((t) =>
t.name.endsWith("analyze_javascript_application"),
);
if (
!analysis &&
mode === "scoped-chat" &&
tools.some((tool) => tool.name === "execute")
) {
if (!catalogSearchRequested) {
catalogSearchRequested = true;
return toolCallMessage("call_rea_catalog", "execute", {
code: `const paths = []; let offset = 0;
do {
const page = await search({ namespace: "rea", offset });
paths.push(...page.items.map(item => item.path));
if (!page.next) break;
if (page.next.offset <= offset) throw Error("OpenCode catalog cursor did not advance");
offset = page.next.offset;
} while (true);
return { reaCatalogPaths: paths };`,
});
}
const result = findClientResult(
body.messages.filter((message) => message.role === "tool"),
(value) => Array.isArray(value.reaCatalogPaths),
);
assert(
result,
"OpenCode must return its native REA namespace search results",
);
catalogFixture.assertNames(result.reaCatalogPaths, "tools.rea.");
catalogSize = result.reaCatalogPaths.length;
finalSeen = true;
return { role: "assistant", content: "REA_CLIENT_COMPATIBILITY_OK" };
}
assert(analysis, "OpenCode must expose the REA analysis tool");
const prefix = analysis.name.slice(
0,
-"analyze_javascript_application".length,
);
const expected = TOOL_CONTRACTS.map((t) => prefix + t.name).sort();
const reaTools = tools.filter((t) => expected.includes(t.name));
const reaTools = catalogFixture.check(tools, prefix);
catalogSize = reaTools.length;
assert.deepEqual(
reaTools.map((t) => t.name).sort(),
expected,
"OpenCode must forward the complete REA catalog",
);
if (schemasChecked === 0) {
for (const tool of reaTools) {
assert(
@@ -175,7 +205,7 @@ await withVerifierCleanup(async () => {
await writeFile(join(lab, "opencode-evidence.json"), bytes);
evidenceSeen = true;
}
if (mode === "chat" || evidenceSeen) {
if (mode !== "call" || evidenceSeen) {
finalSeen = true;
return { role: "assistant", content: "REA_CLIENT_COMPATIBILITY_OK" };
}
@@ -235,6 +265,7 @@ await withVerifierCleanup(async () => {
);
await writeFile(configPath, original);
expectedSkillBody = await verifyClientSetupAndReadSkillBody({
setupArguments: catalogFixture.setupArguments,
client: "opencode",
commands,
runtimeRoot,
@@ -260,7 +291,7 @@ await withVerifierCleanup(async () => {
"json",
"--model",
"rea-fixture/rea-client-fixture",
mode === "chat"
mode !== "call"
? "Say hello briefly."
: `Use REA to analyze the JavaScript directory ${target}. Report the result.`,
],
+36
View File
@@ -0,0 +1,36 @@
import assert from "node:assert/strict";
import { contractsForToolFamilies } from "../../../dist/contracts/toolFamilies.js";
const scopedFamilies = ["electron", "javascript-runtime"];
/** Only setup receives the family selection. The native client must load it
* from its registration and forward exactly that catalog to the model. */
export function clientCatalogFixture(mode) {
const scoped = mode === "scoped-chat";
const all = contractsForToolFamilies(undefined);
const expected = scoped
? contractsForToolFamilies(new Set(scopedFamilies))
: all;
const assertNames = (names, prefix = "") => {
assert.deepEqual(
[...names].sort(),
expected.map(({ name }) => prefix + name).sort(),
"The native client must expose exactly the configured REA catalog",
);
};
return {
setupArguments: scoped ? ["--tool-families", scopedFamilies.join(",")] : [],
assertNames,
check(tools, prefix) {
const known = new Set(all.map(({ name }) => prefix + name));
const rea = tools.filter(({ name }) =>
prefix ? name.startsWith(prefix) : known.has(name),
);
assertNames(
rea.map(({ name }) => name),
prefix,
);
return rea;
},
};
}
@@ -0,0 +1,25 @@
import { writeFileSync } from "node:fs";
import { McpServer } from "@modelcontextprotocol/server";
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
// Used in a disposable native client project. Record only this known selector.
const selection = process.env.REA_MCP_TOOL_FAMILIES;
const state =
selection === undefined
? "absent"
: selection === "electron,javascript-runtime"
? "selected"
: "unexpected";
const tool = `probe_environment_${state}`;
const receipt = process.argv[2];
const server = new McpServer({ name: "rea-environment-probe", version: "1" });
server.registerTool(
tool,
{ description: "Read the configuration test result." },
() => ({ content: [{ type: "text", text: state }] }),
);
server.server.oninitialized = () => {
if (receipt)
writeFileSync(receipt, JSON.stringify({ initialized: true, tool }) + "\n");
};
await server.connect(new StdioServerTransport());
+2
View File
@@ -16,6 +16,7 @@ export async function verifyClientSetup({
skillDirectory,
requiredPlanTargets = [configPath, skillDirectory],
checkConfigured,
setupArguments = [],
}) {
const run = async (command, flag, output) => {
const result = await commands.exec(
@@ -25,6 +26,7 @@ export async function verifyClientSetup({
command,
"--client",
client,
...(command === "setup" ? setupArguments : []),
flag,
"--json",
],