mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 23:15:58 +00:00
Listing the bridge tools closed the connection. The bridge copied each property from the pinned engine's schema, and that schema has no `overload_index` for `get_xrefs_to_method`, so the advertised map carried a null that kotlinx serialization cannot write. Only `tools/list` was affected: REA calls tools by name, which is why the real lanes never saw it, and the same defect reproduces against the 0.7.1 engine. The bridge now declares the properties and required fields it accepts, so an engine bump can neither advertise a null nor drop the overload selector REA relies on. The real Android lane lists the live catalog to keep the shape under test. One tool list serves both the consumed set and the reimplementation loop, unknown names fail fast instead of inheriting a method-shaped schema, and the identity moves to 12 because main's JNI split-qualification change already owns 11. Validation: build:cached, check:fast, docs:check, test:focused over the Android boundary files, and verify:android against the real 0.8.0 JAR and ApiDemos 6.0.18. The new catalog step passes; the lane still stops at the pre-existing `missing java` recovery expectation, which this change does not touch.
90 lines
3.1 KiB
JavaScript
90 lines
3.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { Client } from "@modelcontextprotocol/client";
|
|
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
import { jadxBridgeIdentity } from "../../../dist/android/JadxRelease.js";
|
|
|
|
/**
|
|
* Input schemas the bridge advertises for the tools it reimplements. REA owns
|
|
* these, so a caller can page, select over one overload and read manifest facts
|
|
* without depending on whichever schema the pinned engine happens to publish.
|
|
*/
|
|
const expectedInputs = {
|
|
list_classes: { properties: ["offset", "limit", "query"], required: [] },
|
|
get_class_summary: {
|
|
properties: ["class_name", "dex_static_values"],
|
|
required: ["class_name"],
|
|
},
|
|
get_method_body: {
|
|
properties: ["class_name", "method_name", "overload_index"],
|
|
required: ["class_name", "method_name"],
|
|
},
|
|
get_xrefs_to_class: { properties: ["class_name"], required: ["class_name"] },
|
|
get_xrefs_to_method: {
|
|
properties: ["class_name", "method_name", "overload_index"],
|
|
required: ["class_name", "method_name"],
|
|
},
|
|
rea_jvm_status: { properties: [], required: [] },
|
|
rea_native_declarations: { properties: ["path"], required: ["path"] },
|
|
get_app_info: { properties: [], required: [] },
|
|
get_android_manifest: { properties: [], required: [] },
|
|
};
|
|
|
|
/** Prove the real bridge advertises a serializable, REA-owned tool catalog. */
|
|
export const verifyAndroidBridgeCatalog = async ({
|
|
java,
|
|
jar,
|
|
bridge,
|
|
repository,
|
|
jvmArguments = [],
|
|
}) => {
|
|
const bridgeIdentity = jadxBridgeIdentity();
|
|
if (!bridgeIdentity.ok) throw new Error(bridgeIdentity.error);
|
|
const transport = new StdioClientTransport({
|
|
command: java,
|
|
args: [...jvmArguments, "-classpath", jar, bridge],
|
|
cwd: repository,
|
|
stderr: "pipe",
|
|
});
|
|
const client = new Client({ name: "rea-bridge-catalog", version: "1" });
|
|
try {
|
|
await client.connect(transport);
|
|
assert.deepEqual(
|
|
client.getServerVersion(),
|
|
{
|
|
name: bridgeIdentity.value.name,
|
|
version: bridgeIdentity.value.version,
|
|
},
|
|
"The bridge must report the identity REA expects",
|
|
);
|
|
const tools = new Map(
|
|
(await client.listTools()).tools.map((tool) => [tool.name, tool]),
|
|
);
|
|
assert.deepEqual(
|
|
[...tools.keys()].sort(),
|
|
[...Object.keys(expectedInputs), "load_apk"].sort(),
|
|
"The bridge must advertise only the tools REA consumes",
|
|
);
|
|
assert.ok(
|
|
tools.get("load_apk").inputSchema.properties?.path,
|
|
"load_apk must keep advertising the caller's target path",
|
|
);
|
|
for (const [name, expected] of Object.entries(expectedInputs)) {
|
|
const { inputSchema } = tools.get(name);
|
|
assert.deepEqual(
|
|
Object.keys(inputSchema.properties ?? {}).sort(),
|
|
[...expected.properties].sort(),
|
|
`${name} input properties`,
|
|
);
|
|
assert.deepEqual(
|
|
[...(inputSchema.required ?? [])].sort(),
|
|
[...expected.required].sort(),
|
|
`${name} required fields`,
|
|
);
|
|
}
|
|
console.log("PASS real bridge tool catalog and input schemas");
|
|
} finally {
|
|
await client.close();
|
|
await transport.close();
|
|
}
|
|
};
|