mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
* test(mcp): check advertised schemas against a portable dialect in every profile * fix(mcp): re-emit advertised patterns in a portable regex grammar * fix(mcp): present discover_tools input through the selected profile The hot-cold catalog registered discover_tools directly with the SDK, so the default compact input profile still advertised its canonical schema, including page-size defaults clients apply on their own (#5322). Route every listed input schema, transport discovery included, through one server-owned presentation, and pass the selected presentation to the deferred server, which serves recorded tool schemas but not discovery. * fix(mcp): keep the Evidence union on described borrowed inputs borrowEvidenceInput installed its advertised projection on one schema instance. A call site's .describe() rebuilds the schema from its definition, so match_native_functions advertised left and right as unconstrained values in every input profile. Install the projection in the borrowed parser's constructor so derived schemas keep it, for both borrowed inputs and borrowed arrays. * fix(mcp): validate advertised dialect by selected profile * fix(mcp): preserve schema widening through references * feat(mcp): project compact input schemas into the portable advertised dialect One projection (advertisedDialectProjection.ts) owns the compact input advertisement: one type per node, items on every array, string literals as enums, oneOf widened to anyOf, allOf merged, tuples as element unions, exclusive bounds made inclusive, and every keyword outside the dialect dropped. Each rewrite is exact or widening; server validation is unchanged. The root description and sentences for dropped cross-field constraints move to the tool description, which Codex and Zed keep. The compact baseline falls to nullable values only (29), which the dialect cannot express without narrowing an input. The gateway shape repairs (typeArrayItemUnions, hasGatewayIncompatibleShape), the second dependentRequired-to-prose copy and the strict-gateway test denylist are removed; the dialect checker gates the inline presentation instead. * feat(mcp): omit output schemas from tools/list by default No surveyed model API reads an output schema, MCP client validators repeat REA's own result validation, and complete output schemas were about 92% of the default tools/list. REA_MCP_OUTPUT_SCHEMA_PROFILE now resolves to off through one owner (resolveMcpOutputSchemaProfile); compact and full remain selectable. structuredContent is still delivered, and the deferred server serves both off and full from the recorded catalog with the matching recorded identity. Tests and artifact verifiers that validate results against complete advertised output contracts select full explicitly. * docs: describe omitted output schemas as the default in README translations * fix(mcp): select schemas in verification workflows * fix(mcp): refuse zero-padded repeat bounds and record host-specific path patterns * fix(mcp): keep projected schemas permissive * fix(mcp): keep references valid when presentation widens their targets * fix(mcp): keep a single union branch's closure scoped to its properties * fix(mcp): select complete output schemas in the Electron verifier * fix(mcp): select complete output schemas in standalone verifier probes * fix(mcp): keep an allOf member's tuple tail with its own positions * fix(mcp): relax references into negations and conditionals presentation may remove * refactor(contracts): declare root discriminators as typed schema annotations * test(mcp): select the borrowed Evidence contract from its family * fix(mcp): keep astral literals and dynamic references widening in every mode * fix(mcp): omit astral literals and relax untracked references when presentation widens * fix(mcp): select complete output schemas in every verifier transport * fix(mcp): read reference pointers by schema position, not segment spelling * fix(mcp): protect references into collapsing boolean unions and keep referencing branches out of the collapse * fix(mcp): keep reduced schemas open when their root admits names by pattern * test(mcp): keep the reduced-schema pattern case outside the size-limited block * fix(mcp): omit patterns whose classes name astral characters * fix(mcp): decide union collapse and pointer protection from canonical branches * docs(mcp): document non-u astral matching and pin BMP agreement across V8 modes * fix(mcp): keep prototype-named properties as own properties in the dialect projection * test(mcp): select full output schemas in packet and signal schema checks * test(mcp): expect the advertised base64 schema to omit the unbounded pad-bit probe * fix(mcp): protect references into unevaluated keywords lost evaluation removes * fix(mcp): validate the doctor probe reply against the canonical output contract (#10655) * fix(mcp): validate the doctor probe reply against the canonical output contract * test(mcp): replay doctor probe validation under every output profile * test(mcp): accept typed-branch nullable unions in the advertised dialect (#10649) * test(mcp): select full output schemas in HTTP session workflows * fix(mcp): emit stack-safe classes with non-ASCII members and protect draft-07 reference siblings * fix(mcp): protect references into literal siblings of relaxed draft-07 references * feat(mcp): omit output schemas from tools/list by default (#10646) * feat(mcp): omit output schemas from tools/list by default No surveyed model API reads an output schema, MCP client validators repeat REA's own result validation, and complete output schemas were about 92% of the default tools/list. REA_MCP_OUTPUT_SCHEMA_PROFILE now resolves to off through one owner (resolveMcpOutputSchemaProfile); compact and full remain selectable. structuredContent is still delivered, and the deferred server serves both off and full from the recorded catalog with the matching recorded identity. Tests and artifact verifiers that validate results against complete advertised output contracts select full explicitly. * fix(mcp): select schemas in verification workflows * fix(mcp): select complete output schemas in the Electron verifier * fix(mcp): select complete output schemas in standalone verifier probes * fix(mcp): select complete output schemas in every verifier transport * test(mcp): select full output schemas in packet and signal schema checks * fix(mcp): validate the doctor probe reply against the canonical output contract (#10655) * fix(mcp): validate the doctor probe reply against the canonical output contract * test(mcp): replay doctor probe validation under every output profile * test(mcp): accept typed-branch nullable unions in the advertised dialect (#10649) * test(mcp): select full output schemas in HTTP session workflows * fix(mcp): keep the Evidence union on described borrowed inputs (#10597) * fix(mcp): keep the Evidence union on described borrowed inputs borrowEvidenceInput installed its advertised projection on one schema instance. A call site's .describe() rebuilds the schema from its definition, so match_native_functions advertised left and right as unconstrained values in every input profile. Install the projection in the borrowed parser's constructor so derived schemas keep it, for both borrowed inputs and borrowed arrays. * test(mcp): select the borrowed Evidence contract from its family * docs(mcp): admit baseline growth only for restored contract declarations * fix(mcp): state reduced multi-type properties as typed branches, not type lists The reduced fallback derived a property's types and emitted them as a type list, which Gemini, Moonshot and Ark reject. A property whose canonical schema is anyOf string and number therefore traded a typed union for a rejected construct when the inline projection fell back. Emit one type, or anyOf typed branches, so [T, null] becomes the dialect's nullable union. * feat(mcp)!: retire the full schema profiles and declare complete observations as a typed annotation (#10718) * refactor(mcp): declare complete observations as a typed annotation applied only on the wire * test(mcp): compare complete-observation declarations with their owning text * refactor(schema): couple Zod checks with their JSON Schema constraint keywords (#10725) * refactor(schema): couple Zod checks with their JSON Schema constraint keywords * refactor(schema): declare pattern approximations and object output roots as typed annotations (#10754) * refactor(schema): declare pattern approximations and object output roots as typed annotations * fix(schema): refuse pattern declarations JSON Schema cannot state * test(schema): select guided_workflows from its contract family * feat(mcp)!: retire the full input and output schema profiles (#10841) * feat(mcp)!: retire the full input and output schema profiles The compact input presentation is now the only advertised input schema, and output schemas are either omitted (`off`, the default) or bounded (`compact`). Catalog identity, the build-recorded digests and the recorded startup catalog collapse to those presentations: two digest profiles instead of six, one recorded catalog instead of two, and no input dialect baseline. Tests and verifiers that validated replies against listed full output schemas now validate against the canonical output contract, which REA already enforces server-side; tests that asserted canonical input restrictions read the canonical input schema instead of a full listing. BREAKING CHANGE: `REA_MCP_INPUT_SCHEMA_PROFILE=full` and `REA_MCP_OUTPUT_SCHEMA_PROFILE=full` are refused at startup and by `rea setup` with a configuration error naming the setting. Remove the setting from the client registration (or rerun setup with `REA_MCP_INPUT_SCHEMA_PROFILE=compact` / `REA_MCP_OUTPUT_SCHEMA_PROFILE=compact`). `REA_MCP_INPUT_SCHEMA_PROFILE` still accepts `compact`. Server-side validation is unchanged. * test(mcp): validate replies against canonical output contracts at every listed-schema reader tools/list omits output schemas by default, so fixtures, verifiers and the Android analysis runners that read a listed outputSchema now bind the canonical contract instead. connectLocalToolsMcp and advertisedMcpToolSchemas hand the SDK a definition carrying the canonical output schema, so the SDK client and caller-supplied validators check every successful reply. * test(mcp): resolve Android runners' output contracts from the selected repository The Android efficiency runners imported the canonical output-schema helper from the harness checkout while --repository selects the revision under test. Import it from the selected repository, as the runners already do for the SDK and Ajv. * test(mcp): let Android runners compare revisions before the canonical output helper A selected revision without scripts/lib/canonical-output-schema.mjs could not start the Android runners. Choose the output contracts in one harness helper: the selected revision's canonical contracts when it has them, otherwise its listed schemas under the full output profile it still supports. * fix(scripts): keep caller launch settings when the real Hopper verifier builds its server environment The verifier deleted REA_VERIFY_SERVER_COMMAND and REA_VERIFY_SERVER_ARGS_JSON from process.env itself before reading them, so a caller selecting an installed REA command silently ran the checkout's dist/main.js. Copy the environment, as main does, so only the child's environment changes. * test(mcp): validate whole replies against canonical output contracts wherever a listed definition is held tools/list omits output schemas by default and the full output profile is gone, so tests that handed the SDK a listed definition no longer checked complete replies. Attach the canonical output schema with withCanonicalOutputSchema at every held REA tool definition. Environment-served tools (not REA contracts), and the deferred-runtime and doctor tests that exercise per-profile listings, keep their listed definitions. * test(mcp): record the advertised catalog summary without the retired full profiles Retiring the full input and output profiles leaves only the compact input and compact output listings, so the summary drops the full-profile digests and every pattern only the full listings carried. Regenerated with npm run verify:advertised-schemas -- --update-summary.
452 lines
16 KiB
JavaScript
452 lines
16 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { createHash } from "node:crypto";
|
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
import { 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 { isPathWithinRoot } from "../dist/domain/localPath.js";
|
|
import { createVerifierCommands } from "./lib/verify-commands.mjs";
|
|
import { saveVerifierCommandOutput } from "./lib/verifier-command-output.mjs";
|
|
import { withVerifierCleanup } from "./lib/verifier-cleanup.mjs";
|
|
import {
|
|
CLIENT_JAVASCRIPT_FIXTURE_SOURCE,
|
|
assertClientJavaScriptFixtureEvidence,
|
|
} from "./verify/clients/javascript-fixture.mjs";
|
|
import {
|
|
findClientResult,
|
|
isClientJavaScriptEvidence,
|
|
} from "./verify/clients/result-discovery.mjs";
|
|
import { createVerifierRun, completeVerifierRun } from "./lib/verifier-run.mjs";
|
|
import { createGeminiModelFixture } from "./verify/clients/gemini-model-fixture.mjs";
|
|
import { importVerifierSource } from "./lib/verifier-source-loader.mjs";
|
|
import { VerifierFixture } from "./lib/verifier-fixture.mjs";
|
|
|
|
const { geminiUnsupportedLiteral } = await importVerifierSource(
|
|
new URL("./lib/gemini-schema-literals.mts", import.meta.url).href,
|
|
import.meta.url,
|
|
);
|
|
|
|
const repo = fileURLToPath(new URL("..", import.meta.url));
|
|
const runtimeRoot = process.env.REA_VERIFY_RUNTIME_ROOT ?? repo;
|
|
const command = process.env.REA_VERIFY_GEMINI_COMMAND ?? "gemini";
|
|
const mode = process.argv[2] ?? "call";
|
|
// npm installs of Gemini CLI provide a JavaScript entry point; on Windows only a gemini.cmd shim reaches
|
|
// PATH, which Node does not spawn without a shell, so a selected .js entry runs under this Node. It is
|
|
// resolved once, because the preflight runs from the caller's directory and the client from the workspace.
|
|
const entryPoint = /\.(c|m)?js$/iu.test(command) ? resolve(command) : undefined;
|
|
const launch = (args) =>
|
|
entryPoint === undefined
|
|
? [command, args]
|
|
: [process.execPath, [entryPoint, ...args]];
|
|
assert(
|
|
["chat", "call"].includes(mode),
|
|
"Usage: verify-gemini-client.mjs [chat|call]",
|
|
);
|
|
const verifier = createVerifierRun();
|
|
const { path: lab } = await VerifierFixture.keepArtifacts({
|
|
prefix: "rea-gemini-client-",
|
|
});
|
|
const account = join(lab, "account");
|
|
const profile = join(lab, "selected profile");
|
|
const workspace = join(lab, "workspace");
|
|
const configPath = join(profile, ".gemini", "settings.json");
|
|
const skillPath = join(
|
|
profile,
|
|
".agents",
|
|
"skills",
|
|
"reverse-engineer-anything",
|
|
"SKILL.md",
|
|
);
|
|
let clientVersion = null;
|
|
let fixture;
|
|
let passed = false;
|
|
let evidenceSeen = false;
|
|
let skillLoaded = false;
|
|
let expectedSkillBody;
|
|
let skillRequested = false;
|
|
let finalSeen = false;
|
|
let catalogSize = null;
|
|
let schemasChecked = 0;
|
|
let examplesChecked = 0;
|
|
let artifactDigest;
|
|
const commands = await createVerifierCommands();
|
|
await withVerifierCleanup(async () => {
|
|
await withVerifierCleanup(async () => {
|
|
await Promise.all([
|
|
mkdir(account),
|
|
mkdir(workspace),
|
|
mkdir(join(profile, ".gemini"), { recursive: true }),
|
|
]);
|
|
await commands.exec("git", ["init", "--quiet", workspace], {
|
|
timeout: 30_000,
|
|
stdin: "pipe",
|
|
});
|
|
await writeFile(join(lab, "system-settings.json"), "{}\n");
|
|
await writeFile(join(lab, "system-defaults.json"), "{}\n");
|
|
const environment = {
|
|
PATH: process.env.PATH ?? "",
|
|
USERPROFILE: account,
|
|
GEMINI_CLI_HOME: profile,
|
|
GEMINI_CLI_SYSTEM_SETTINGS_PATH: join(lab, "system-settings.json"),
|
|
GEMINI_CLI_SYSTEM_DEFAULTS_PATH: join(lab, "system-defaults.json"),
|
|
// Preserve the caller's bounded Node heap instead of the launcher's host-memory auto-sizing.
|
|
GEMINI_CLI_NO_RELAUNCH: "1",
|
|
GEMINI_CLI_TRUST_WORKSPACE: "true",
|
|
REA_PROCESS_RUN_ID: verifier.run_id,
|
|
};
|
|
try {
|
|
clientVersion = (
|
|
await commands.exec(...launch(["--version"]), {
|
|
env: environment,
|
|
timeout: 30_000,
|
|
stdin: "pipe",
|
|
})
|
|
).stdout.trim();
|
|
} catch (cause) {
|
|
const windowsHint =
|
|
process.platform === "win32"
|
|
? " On Windows, select the JavaScript entry point; npm installs provide it as node_modules/@google/gemini-cli/bundle/gemini.js."
|
|
: "";
|
|
throw new Error(
|
|
`Gemini preflight failed for ${command}; install Gemini CLI or set REA_VERIFY_GEMINI_COMMAND.${windowsHint} ${String(cause)}`,
|
|
{ cause },
|
|
);
|
|
}
|
|
const original = JSON.stringify(
|
|
{
|
|
security: {
|
|
auth: { selectedType: "gemini-api-key" },
|
|
folderTrust: { enabled: false },
|
|
},
|
|
telemetry: { enabled: false },
|
|
advanced: { autoConfigureMemory: false },
|
|
model: { name: "gemini-2.5-flash", maxSessionTurns: 8 },
|
|
mcpServers: { other: { command: "unrelated-server" } },
|
|
},
|
|
null,
|
|
2,
|
|
);
|
|
await writeFile(configPath, original);
|
|
for (const args of [
|
|
["setup", "--client", "gemini_cli", "--dry-run"],
|
|
["setup", "--client", "gemini_cli", "--yes"],
|
|
["doctor", "--client", "gemini_cli", "--skill"],
|
|
]) {
|
|
const result = await commands.exec(
|
|
process.execPath,
|
|
[join(runtimeRoot, "scripts/rea.mjs"), ...args, "--json"],
|
|
{ env: environment, cwd: workspace, timeout: 60_000, stdin: "pipe" },
|
|
);
|
|
const parsed = JSON.parse(result.stdout);
|
|
if (args[0] === "doctor") assert.equal(parsed.healthy, true);
|
|
else {
|
|
assert.equal(
|
|
parsed.status,
|
|
args.includes("--dry-run") ? "planned" : "ready",
|
|
);
|
|
if (args.includes("--dry-run")) {
|
|
assert(parsed.plannedActions.some((a) => a.target === configPath));
|
|
assert(
|
|
parsed.plannedActions.some((a) => {
|
|
const skills = join(profile, ".agents", "skills");
|
|
return (
|
|
isAbsolute(a.target) &&
|
|
relative(skills, a.target) !== "" &&
|
|
isPathWithinRoot(skills, a.target)
|
|
);
|
|
}),
|
|
);
|
|
assert(
|
|
parsed.plannedActions.every(
|
|
(a) =>
|
|
isAbsolute(a.target) &&
|
|
relative(profile, a.target) !== "" &&
|
|
isPathWithinRoot(profile, a.target),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
await writeFile(
|
|
join(
|
|
lab,
|
|
`${args[0]}${args.includes("--dry-run") ? "-plan" : ""}.json`,
|
|
),
|
|
result.stdout,
|
|
);
|
|
}
|
|
assert.equal(await readFile(`${configPath}.rea.backup`, "utf8"), original);
|
|
const configured = await readFile(configPath, "utf8");
|
|
assert.deepEqual(JSON.parse(configured).mcpServers.other, {
|
|
command: "unrelated-server",
|
|
});
|
|
const repeated = await commands.exec(
|
|
process.execPath,
|
|
[
|
|
join(runtimeRoot, "scripts/rea.mjs"),
|
|
"setup",
|
|
"--client",
|
|
"gemini_cli",
|
|
"--yes",
|
|
"--json",
|
|
],
|
|
{ env: environment, cwd: workspace, timeout: 60_000, stdin: "pipe" },
|
|
);
|
|
assert.deepEqual(JSON.parse(repeated.stdout).appliedActions, []);
|
|
assert.equal(await readFile(configPath, "utf8"), configured);
|
|
assert.equal(await readFile(`${configPath}.rea.backup`, "utf8"), original);
|
|
const installedSkill = await readFile(skillPath, "utf8");
|
|
assert(installedSkill.includes("name: reverse-engineer-anything"));
|
|
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?/u.exec(
|
|
installedSkill,
|
|
);
|
|
assert(frontmatter, "Installed skill must have authored frontmatter");
|
|
expectedSkillBody = (frontmatter[2] ?? "").trim();
|
|
assert(expectedSkillBody.length > 0);
|
|
|
|
const target = join(lab, "fixture α测试");
|
|
await mkdir(target);
|
|
await writeFile(join(target, "app.js"), CLIENT_JAVASCRIPT_FIXTURE_SOURCE);
|
|
const schemaValidator = new Ajv2020({
|
|
strict: false,
|
|
validateFormats: false,
|
|
});
|
|
const decodeGeminiResult = (text) => {
|
|
if (
|
|
text.startsWith("<untrusted_context>\n") &&
|
|
text.endsWith("\n</untrusted_context>")
|
|
)
|
|
return decodeGeminiResult(
|
|
text.slice(
|
|
"<untrusted_context>\n".length,
|
|
-"\n</untrusted_context>".length,
|
|
),
|
|
);
|
|
return JSON.parse(text);
|
|
};
|
|
fixture = await createGeminiModelFixture({
|
|
directory: lab,
|
|
onRequest: async ({ body, tools }) => {
|
|
const analysis = tools.find((t) =>
|
|
t.name.endsWith("analyze_javascript_application"),
|
|
);
|
|
assert(analysis, "Gemini 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));
|
|
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(
|
|
tool.parametersJsonSchema,
|
|
`${tool.name}: missing advertised JSON Schema`,
|
|
);
|
|
assert(
|
|
schemaValidator.validateSchema(tool.parametersJsonSchema),
|
|
`${tool.name}: invalid advertised JSON Schema: ${JSON.stringify(schemaValidator.errors)}`,
|
|
);
|
|
const unsupportedLiteral = geminiUnsupportedLiteral(
|
|
tool.parametersJsonSchema,
|
|
)?.path;
|
|
assert.equal(
|
|
unsupportedLiteral,
|
|
undefined,
|
|
`${tool.name}: Gemini SDK declaration retains a boolean or empty-string const/enum at ${unsupportedLiteral}`,
|
|
);
|
|
const name = tool.name.slice(prefix.length);
|
|
const contract = toolContract(name);
|
|
const validate = schemaValidator.compile(tool.parametersJsonSchema);
|
|
for (const example of contract.examples) {
|
|
assert(
|
|
validate(example.input),
|
|
`${tool.name}: Gemini SDK declaration rejects canonical example ${example.title}: ${JSON.stringify(schemaValidator.errors)}`,
|
|
);
|
|
examplesChecked++;
|
|
}
|
|
schemasChecked++;
|
|
}
|
|
}
|
|
const responses = body.contents
|
|
.flatMap((c) => c.parts ?? [])
|
|
.filter((p) => p.functionResponse)
|
|
.map((p) => p.functionResponse);
|
|
skillLoaded ||= responses.some((response) => {
|
|
const output = response.response?.output;
|
|
if (
|
|
response.name !== "activate_skill" ||
|
|
typeof output !== "string" ||
|
|
expectedSkillBody === undefined
|
|
)
|
|
return false;
|
|
const start = `<activated_skill name="reverse-engineer-anything">\n <instructions>\n ${expectedSkillBody}\n </instructions>\n\n <available_resources>\n `;
|
|
const at = output.indexOf(start);
|
|
if (at < 0) return false;
|
|
const resourcesStart = at + start.length;
|
|
const resourcesEnd = output.indexOf(
|
|
"\n </available_resources>\n</activated_skill>",
|
|
resourcesStart,
|
|
);
|
|
if (resourcesEnd < 0) return false;
|
|
const resources = output.slice(resourcesStart, resourcesEnd);
|
|
return (
|
|
!resources.includes("</activated_skill>") &&
|
|
!resources.includes("</available_resources>") &&
|
|
resources.includes(
|
|
join(profile, ".agents", "skills", "reverse-engineer-anything"),
|
|
)
|
|
);
|
|
});
|
|
const observed = findClientResult(
|
|
responses,
|
|
isClientJavaScriptEvidence,
|
|
decodeGeminiResult,
|
|
);
|
|
if (observed) {
|
|
const { evidence } = await assertClientJavaScriptFixtureEvidence(
|
|
observed,
|
|
target,
|
|
);
|
|
const bytes = JSON.stringify(evidence);
|
|
artifactDigest = createHash("sha256").update(bytes).digest("hex");
|
|
await writeFile(join(lab, "gemini-evidence.json"), bytes);
|
|
evidenceSeen = true;
|
|
}
|
|
if (mode === "chat" || evidenceSeen) {
|
|
finalSeen = true;
|
|
return [{ text: "REA_CLIENT_COMPATIBILITY_OK" }];
|
|
}
|
|
if (!skillRequested) {
|
|
const skill = tools.find((t) => t.name === "activate_skill");
|
|
assert(skill, "Gemini must expose its native skill activation tool");
|
|
skillRequested = true;
|
|
return [
|
|
{
|
|
functionCall: {
|
|
name: skill.name,
|
|
args: { name: "reverse-engineer-anything" },
|
|
},
|
|
},
|
|
];
|
|
}
|
|
assert(
|
|
skillLoaded,
|
|
"Gemini must load the installed personal REA skill",
|
|
);
|
|
return [
|
|
{
|
|
functionCall: {
|
|
name: analysis.name,
|
|
args: { input_path: target, format: "directory" },
|
|
},
|
|
},
|
|
];
|
|
},
|
|
});
|
|
const response = await saveVerifierCommandOutput(
|
|
() =>
|
|
commands.exec(
|
|
...launch([
|
|
"--model",
|
|
"gemini-2.5-flash",
|
|
"--approval-mode",
|
|
mode === "chat" ? "default" : "yolo",
|
|
"--allowed-mcp-server-names",
|
|
"rea",
|
|
"--output-format",
|
|
"stream-json",
|
|
"-p",
|
|
mode === "chat"
|
|
? "Say hello briefly."
|
|
: `Use REA to analyze the JavaScript directory ${target}. Report the result.`,
|
|
]),
|
|
{
|
|
env: {
|
|
...environment,
|
|
GEMINI_API_KEY: "local-fixture-key",
|
|
GOOGLE_GEMINI_BASE_URL: fixture.baseUrl,
|
|
},
|
|
cwd: workspace,
|
|
timeout: 120_000,
|
|
maxBuffer: 10 * 1024 * 1024,
|
|
stdin: "pipe",
|
|
},
|
|
),
|
|
{
|
|
stdout: join(lab, `${mode}.stdout`),
|
|
stderr: join(lab, `${mode}.stderr`),
|
|
},
|
|
);
|
|
const events = response.stdout
|
|
.split("\n")
|
|
.filter(Boolean)
|
|
.map((line) => JSON.parse(line));
|
|
assert.equal(
|
|
events.findLast((e) => e.type === "result")?.status,
|
|
"success",
|
|
);
|
|
assert.equal(fixture.failure, undefined);
|
|
assert(
|
|
finalSeen && response.stdout.includes("REA_CLIENT_COMPATIBILITY_OK"),
|
|
);
|
|
if (mode === "call") assert(evidenceSeen && skillLoaded);
|
|
}, [
|
|
() => commands.close(),
|
|
async () => {
|
|
await fixture?.close();
|
|
},
|
|
]);
|
|
passed = true;
|
|
}, [
|
|
async () => {
|
|
const lineage = await completeVerifierRun(verifier);
|
|
const receipt = {
|
|
client: "Gemini CLI",
|
|
clientVersion,
|
|
mode,
|
|
schemasChecked,
|
|
examplesChecked,
|
|
passed,
|
|
artifacts: lab,
|
|
runtimeRoot,
|
|
host: {
|
|
platform: process.platform,
|
|
architecture: process.arch,
|
|
node: process.versions.node,
|
|
},
|
|
modelFixture:
|
|
"loopback native Gemini API adapter; token counts synthetic; no live Google API claim",
|
|
skillDiscovery:
|
|
"native GEMINI_CLI_HOME personal shared directory; isolated Git project",
|
|
catalogSize,
|
|
evidenceSeen,
|
|
skillLoaded,
|
|
artifactDigest,
|
|
finalSeen,
|
|
requests: fixture?.requests,
|
|
probes: fixture?.probes,
|
|
fixtureFailure: fixture?.failure,
|
|
verifier: lineage,
|
|
};
|
|
await withVerifierCleanup(
|
|
() =>
|
|
writeFile(join(lab, "receipt.json"), JSON.stringify(receipt, null, 2)),
|
|
[
|
|
() => {
|
|
console.log(JSON.stringify(receipt));
|
|
},
|
|
],
|
|
);
|
|
},
|
|
]);
|