feat(jeb): add JEB engine provider over its MCP interface (#1536)
* feat(jeb): add JEB engine provider over its MCP interface
Add a bring-your-own JEB provider that serves project, unit, and
decompilation inspection from a caller-started JEB client speaking MCP
(streamable HTTP, selected with REA_JEB_MCP_URL). Expose four provider-neutral
operations through shared CLI/MCP workflows: inspect_jeb_client,
open_jeb_project, list_jeb_units, and decompile_jeb_item, each returning
Evidence with engine identity, endpoint, and preserved refusal reasons.
The adapter keeps JEB's envelope semantics: success fields are parsed
format-aware at the boundary, message-only refusals become unsupported-target
errors with the engine's own reason, transport failures become availability
failures with recovery guidance, and unit pagination derives coverage from the
engine's 100-item page cap. Explicit unknowns (implicitly selected unit,
omitted filters) are reported instead of guessed.
Verified against a real JEB 5.48.0 licensed build serving jeb-mcp-server 1.3.0
headless: client inspection, unit listing, and method decompilation were
exercised through the CLI, MCP boundary, and scripts/verify-jeb.mjs.
JEB 5.48.0 headless instances do not advertise open_project; the refusal is
preserved and documented.
* fix(jeb): verify against a real signed APK and fix CLI option surface
Verify the provider against a locally built, v1/v2/v3-signed probe APK
(binary manifest, classes.dex with a launcher activity) on JEB 5.48.0: the
full unit tree (apk, manifest, three certificate units, dex bytecode,
decompiler), wildcard-filtered and paginated unit listing with derived
coverage, parent-restricted listing, and launcher-activity method
decompilation through both CLI and MCP, including dexdec's inline
constant folding of the probe's obfuscated tag.
Move list-jeb-units filter/pagination and decompile-jeb-item unit selection
from positional arguments to options; the MCP schemas are unchanged.
* fix(jeb): preserve engine refusals through the real MCP boundary
Testing against the published Signal 8.30.3 universal APK exposed a boundary
bug the scripted provider tests missed: decodeJebToolResult raised a protocol
error for isError results before the provider could map JEB's
{success:false, message} envelope, so real engine refusals surfaced as
unreadable output instead of the engine's own reason. Decode refusal
envelopes like any structured result and let the provider preserve the
reason; cover the decoder directly, including contentless and unparseable
results.
Signal verification: full 109 MB R8/Kotlin/Compose APK with four signature
schemes and native arm64 ELF units parsed; MainActivity.onCreate and R8
synthetic lambdas decompiled through CLI and MCP; paginated, filtered, and
parent-restricted unit listing; refusal path confirmed on the live engine.
* docs(jeb): record Flutter Gallery verification on the real-engine lane
Verify the provider against the official Flutter Gallery 2.9.2 release APK
(112 MB): per-ABI libapp.so Dart AOT snapshot images analyzed as native code
with 75k methods on arm64, snapshot internals and wrapper methods decompiled
through both CLI and MCP with explicit unit selection, decoded manifest, and
filtered native-library unit discovery. Note that JEB 5.48.0 headless does
not expose the dedicated Dart snapshot processor or run_script; both remain
GUI-only engine surfaces.
* docs(jeb): translate the README JEB row for every supported language
The JEB row was inserted in English across all translated READMEs; each now
carries its own label, capability summary, requirements, and guide link
following that language's Android-row conventions.
* fix(jeb): enforce local endpoints and preserve cancellation
* fix(jeb): refuse redirects across the local MCP boundary
---------
Co-authored-by: REA Contributor <contributor@rea.tools>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
REA Contributor
morluto
parent
ded59689ce
commit
749e58772a
@@ -0,0 +1,46 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { JEB_TOOL_CONTRACTS } from "./jebToolContracts.js";
|
||||
import { TOOL_CONTRACTS } from "../toolContracts.js";
|
||||
|
||||
const registered = new Set(TOOL_CONTRACTS.map((contract) => contract.name));
|
||||
|
||||
it("registers every JEB contract in the canonical inventory with audited effects", () => {
|
||||
for (const contract of JEB_TOOL_CONTRACTS) {
|
||||
expect(registered.has(contract.name)).toBe(true);
|
||||
expect(contract.effects.accessesNetwork).toBe(true);
|
||||
expect(contract.effects.launchesProcess).toBe(false);
|
||||
expect(contract.effects.writesFilesystem).toBe(false);
|
||||
expect(contract.effects.mutatesTarget).toBe(false);
|
||||
}
|
||||
expect(contractByName("open_jeb_project").effects.idempotent).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps executable examples valid against their advertised input schemas", () => {
|
||||
for (const contract of JEB_TOOL_CONTRACTS) {
|
||||
for (const example of contract.examples) {
|
||||
expect(
|
||||
contract.inputSchema.safeParse(example.input).success,
|
||||
`${contract.name}: ${example.title ?? "example"}`,
|
||||
).toBe(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("describes engine authority truthfully", () => {
|
||||
for (const contract of JEB_TOOL_CONTRACTS) {
|
||||
expect(contract.kind).toBe("jeb-provider");
|
||||
expect(contract.description).toMatch(/JEB|[Ee]ngine/);
|
||||
}
|
||||
expect(contractByName("open_jeb_project").description).toContain(
|
||||
"REA does not",
|
||||
);
|
||||
});
|
||||
|
||||
const contractByName = (name: string) => {
|
||||
const contract = JEB_TOOL_CONTRACTS.find(
|
||||
(candidate) => candidate.name === name,
|
||||
);
|
||||
if (contract === undefined) throw new Error(`Missing JEB contract: ${name}`);
|
||||
return contract;
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
import {
|
||||
jebInputSchemas,
|
||||
jebResultSchemas,
|
||||
} from "../../domain/jeb/jebAnalysis.js";
|
||||
import type { ToolContract } from "../toolContractTypes.js";
|
||||
import { evidenceResultOf } from "../toolOutputSchemaPrimitives.js";
|
||||
import { toolContractMetadata } from "../toolEffects.js";
|
||||
|
||||
/** JEB-backed inspection served by a caller-supplied running engine client. */
|
||||
export const JEB_TOOL_CONTRACTS = [
|
||||
{
|
||||
name: "inspect_jeb_client",
|
||||
...toolContractMetadata("inspect_jeb_client"),
|
||||
description:
|
||||
"Inspect the running JEB client serving MCP: engine version, GUI or headless mode, and startup time. Does not open a target. Requires a caller-started JEB client reachable at REA_JEB_MCP_URL (default http://127.0.0.1:8425/mcp); REA never installs or launches JEB.",
|
||||
kind: "jeb-provider",
|
||||
inputSchema: jebInputSchemas.inspect_jeb_client,
|
||||
outputSchema: evidenceResultOf(jebResultSchemas.inspect_jeb_client),
|
||||
examples: [{ title: "Check the engine", input: {} }],
|
||||
},
|
||||
{
|
||||
name: "open_jeb_project",
|
||||
...toolContractMetadata("open_jeb_project"),
|
||||
description:
|
||||
"Open or create a JEB project from an artifact file or existing .jdb2 database on the engine host. Returns the project's input-file digests and top-level units. The engine analyzes the target itself; REA does not read the file or execute it. Fails when a project is already open.",
|
||||
kind: "jeb-provider",
|
||||
inputSchema: jebInputSchemas.open_jeb_project,
|
||||
outputSchema: evidenceResultOf(jebResultSchemas.open_jeb_project),
|
||||
examples: [
|
||||
{
|
||||
title: "Open a target for analysis",
|
||||
input: { path: "/tmp/Example.apk" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "list_jeb_units",
|
||||
...toolContractMetadata("list_jeb_units"),
|
||||
description:
|
||||
"List project units by stable unit path and type, with optional wildcard filter, parent restriction, and pagination. The engine caps pages at 100 units; a full page reports partial coverage because more units may exist. Read-only.",
|
||||
kind: "jeb-provider",
|
||||
inputSchema: jebInputSchemas.list_jeb_units,
|
||||
outputSchema: evidenceResultOf(jebResultSchemas.list_jeb_units),
|
||||
examples: [
|
||||
{
|
||||
title: "List units",
|
||||
input: {},
|
||||
},
|
||||
{
|
||||
title: "Find DEX units",
|
||||
input: { filter: "*.dex" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "decompile_jeb_item",
|
||||
...toolContractMetadata("decompile_jeb_item"),
|
||||
description:
|
||||
"Decompile one type or method to engine pseudo-code using its decompiler (Dalvik, Java, or native). item_address comes from the engine's code item listing; unit_path defaults to the engine's first code unit and stays unknown when omitted. Read-only with respect to the target file.",
|
||||
kind: "jeb-provider",
|
||||
inputSchema: jebInputSchemas.decompile_jeb_item,
|
||||
outputSchema: evidenceResultOf(jebResultSchemas.decompile_jeb_item),
|
||||
examples: [
|
||||
{
|
||||
title: "Decompile a method",
|
||||
input: {
|
||||
item_address: "Lcom/example/Main;->onCreate()V",
|
||||
item_kind: "method",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const satisfies readonly ToolContract[];
|
||||
@@ -25,6 +25,7 @@ export const TOOL_KINDS = [
|
||||
"artifact-provider",
|
||||
"managed-provider",
|
||||
"android-provider",
|
||||
"jeb-provider",
|
||||
"adb-provider",
|
||||
"firmware-provider",
|
||||
"browser-provider",
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
||||
import { MANAGED_TOOL_CONTRACTS } from "./managed/managedToolContracts.js";
|
||||
import { FIRMWARE_TOOL_CONTRACTS } from "./firmware/firmwareToolContracts.js";
|
||||
import { ANDROID_TOOL_CONTRACTS } from "./android/androidToolContracts.js";
|
||||
import { JEB_TOOL_CONTRACTS } from "./jeb/jebToolContracts.js";
|
||||
import { ADB_TOOL_CONTRACTS } from "./adb/adbToolContracts.js";
|
||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managed/managedWorkflowToolContracts.js";
|
||||
import { BROWSER_PROVIDER_TOOL_CONTRACTS } from "./browserProviderToolContracts.js";
|
||||
@@ -31,6 +32,7 @@ export const TOOL_CONTRACTS = [
|
||||
...EVM_TOOL_CONTRACTS,
|
||||
...MANAGED_TOOL_CONTRACTS,
|
||||
...ANDROID_TOOL_CONTRACTS,
|
||||
...JEB_TOOL_CONTRACTS,
|
||||
...ADB_TOOL_CONTRACTS,
|
||||
...FIRMWARE_TOOL_CONTRACTS,
|
||||
...MANAGED_WORKFLOW_TOOL_CONTRACTS,
|
||||
|
||||
@@ -98,6 +98,23 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
launchesProcess: true,
|
||||
writesFilesystem: true,
|
||||
}),
|
||||
inspect_jeb_client: effects({
|
||||
mutatesSession: true,
|
||||
accessesNetwork: true,
|
||||
}),
|
||||
open_jeb_project: effects({
|
||||
mutatesSession: true,
|
||||
accessesNetwork: true,
|
||||
idempotent: false,
|
||||
}),
|
||||
list_jeb_units: effects({
|
||||
mutatesSession: true,
|
||||
accessesNetwork: true,
|
||||
}),
|
||||
decompile_jeb_item: effects({
|
||||
mutatesSession: true,
|
||||
accessesNetwork: true,
|
||||
}),
|
||||
inspect_adb_client: effects({
|
||||
mutatesSession: true,
|
||||
launchesProcess: true,
|
||||
|
||||
Reference in New Issue
Block a user