mirror of
https://github.com/morluto/rea.git
synced 2026-11-07 15:26:25 +00:00
* feat(desktop): keep an agentenv computer up and drive it through REA's MCP tools - A Python helper keeps one agentenv computer up per build with run_bundle(keep=True) and reports its address, MCP URL, control token and sandbox id; it tears the computer down when stdin closes. - AgentEnvComputer owns the helper, waits for readiness, holds one MCP session to the computer's computer_* tools, records through the computer-recording routes, and removes the sandbox's containers by label when agentenv cannot confirm teardown. The token never leaves it. - start_build_computer starts a computer from a request (archive package, apt repository or .deb, opened on demand with REA in /opt/rea) or from a bundle folder; act_on_build_computer forwards screenshot, click, drag, scroll, type, key and wait and returns the driver's images unchanged; close_build_computer tears it down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): remove a build computer's container by name when agentenv cannot confirm teardown agentenv's local provider runs an ordinary computer as agent-<sandbox id> without the agentenv.sandbox label, so the label-only fallback found nothing and reported a running computer as removed. The fallback now lists containers by exact name and by label. The real test holds its recording open long enough for a first frame, checks the container by name, and runs rea inside the computer; the guide and tool descriptions say the app opens from the Applications menu and that a screenshot after opening a menu should come from a wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): own failed build-computer starts, keep ids past oversized screenshots, bound recordings - A start is owned from the helper's spawn. One that fails and whose teardown is unconfirmed stays held under a computer_id close can retry; closeAll refuses new starts, cancels and joins starts in progress, then closes every held computer. - When the first screenshot is too large, the error carries REA's result with the computer_id, and start_build_computer takes screenshot region, format and quality. - Recordings are refused before reading when the manifest's total exceeds the allowance, then fetched one segment at a time, each read bounded and checked against its size and sha256. - The helper keeps the tail of its output (a new tail retention mode in ProviderProcessSupervisor), so a build's own error is not crowded out. - A helper that reported no computer exits on its own before SIGTERM, so no phantom owner is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): bound a build computer's action log Every action kept its full arguments for the computer's whole life, so a long session grew REA's memory without limit. The log now keeps the latest 256 actions within 256 KiB, cuts each string to 1 KiB and each list to 64 items (naming what it cut), and keeps the total and the last applied index of each kind of action, so rules over the whole session hold after entries drop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
139 lines
4.5 KiB
TypeScript
139 lines
4.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { createCli } from "../../../src/cli.js";
|
|
import { createCliInventory } from "../../../scripts/lib/catalog-cli.mjs";
|
|
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
|
import { CLI_COMMAND_NAMES } from "../../../src/cliCommandNames.js";
|
|
|
|
/** Canonical MCP operations reached by CLI commands with different names. */
|
|
const CLI_COMMAND_TOOL_ALIASES = Object.freeze({
|
|
"environment-build": ["export_environment_bundle"],
|
|
guidance: ["search_guidance", "read_guidance_section"],
|
|
analyze: ["binary_overview"],
|
|
inspect: ["binary_overview"],
|
|
decompile: ["procedure_pseudo_code"],
|
|
function: ["analyze_function"],
|
|
instructions: ["read_function_instructions"],
|
|
trace: ["trace_feature"],
|
|
search: ["search_strings", "search_procedures"],
|
|
"capture-process": ["capture_process_scenario"],
|
|
compare: ["compare_bundles"],
|
|
"list-objdump-architectures": ["inspect_with_objdump"],
|
|
"debug-with-gdb": ["gdb_console"],
|
|
"debug-with-rizin": ["rizin_debug_command"],
|
|
});
|
|
|
|
/** MCP operations without a dedicated CLI command or direct command alias. */
|
|
const MCP_TOOLS_WITHOUT_DEDICATED_CLI = Object.freeze([
|
|
// Runtime settings belong to the long-lived MCP server; CLI calls use launch/per-call controls.
|
|
"inspect_analysis_settings",
|
|
"update_analysis_settings",
|
|
// MCP session control selects a resource root; CLI resource commands take paths directly.
|
|
"open_bundle_resources",
|
|
"address_name",
|
|
"comment",
|
|
"current_address",
|
|
"current_procedure",
|
|
"current_document",
|
|
"goto_address",
|
|
"inline_comment",
|
|
"list_bookmarks",
|
|
"list_documents",
|
|
"list_names",
|
|
"list_procedures",
|
|
"list_segments",
|
|
"list_strings",
|
|
"next_address",
|
|
"prev_address",
|
|
"procedure_address",
|
|
"procedure_assembly",
|
|
"procedure_callees",
|
|
"procedure_callers",
|
|
"procedure_info",
|
|
"procedure_references",
|
|
"resolve_containing_procedure",
|
|
"set_address_name",
|
|
"set_addresses_names",
|
|
"set_bookmark",
|
|
"set_comment",
|
|
"set_inline_comment",
|
|
"unset_bookmark",
|
|
"get_objc_classes",
|
|
"get_objc_protocols",
|
|
"batch_decompile",
|
|
"get_call_graph",
|
|
"analyze_swift_types",
|
|
"find_xrefs_to_name",
|
|
"trace_call_path",
|
|
"open_binary",
|
|
"close_binary",
|
|
// Investigation reset acts on the long-lived MCP server's retained history.
|
|
"reset_investigation",
|
|
"binary_session",
|
|
"export_evidence_bundle",
|
|
"import_evidence_bundle",
|
|
"compare_functions",
|
|
"find_changed_behavior",
|
|
"build_call_path",
|
|
"correlate_static_and_runtime",
|
|
"verify_reconstruction",
|
|
"list_unknowns",
|
|
"record_unknown",
|
|
"update_unknown",
|
|
"verify_unknown_resolution",
|
|
"get_evidence_bundle",
|
|
"get_navigation_context",
|
|
"inspect_address_context",
|
|
"start_gdb_session",
|
|
"gdb_session_status",
|
|
"close_gdb_session",
|
|
"start_rizin_debug_session",
|
|
"rizin_debug_session_status",
|
|
"close_rizin_debug_session",
|
|
"start_frida_session",
|
|
"load_frida_script",
|
|
"resume_frida_session",
|
|
"unload_frida_script",
|
|
"frida_session_status",
|
|
"close_frida_session",
|
|
// Build computers are held by the long-lived MCP server between actions.
|
|
"start_build_computer",
|
|
"act_on_build_computer",
|
|
"close_build_computer",
|
|
]);
|
|
|
|
describe("CLI canonical tool coverage", () => {
|
|
it("accounts for every MCP tool on the CLI or marks it intentionally MCP-only", () => {
|
|
const registeredCli = createCliInventory(createCli());
|
|
const registeredCommandNames = new Set([
|
|
...registeredCli.primary,
|
|
...registeredCli.aliases.map(({ name }) => name),
|
|
]);
|
|
const cliToolNames = new Set(
|
|
registeredCli.primary.map((command) => command.replaceAll("-", "_")),
|
|
);
|
|
for (const [command, names] of Object.entries(CLI_COMMAND_TOOL_ALIASES)) {
|
|
expect(registeredCommandNames.has(command)).toBe(true);
|
|
for (const name of names) cliToolNames.add(name);
|
|
}
|
|
for (const command of CLI_COMMAND_NAMES)
|
|
expect(registeredCommandNames.has(command)).toBe(true);
|
|
const intentionalMcpOnly = new Set<string>(MCP_TOOLS_WITHOUT_DEDICATED_CLI);
|
|
expect(
|
|
[...intentionalMcpOnly].filter((name) => cliToolNames.has(name)).sort(),
|
|
).toEqual([]);
|
|
const unaccounted = TOOL_CONTRACTS.map(({ name }) => name).filter(
|
|
(name) => !cliToolNames.has(name) && !intentionalMcpOnly.has(name),
|
|
);
|
|
expect(unaccounted).toEqual([]);
|
|
expect(new Set(MCP_TOOLS_WITHOUT_DEDICATED_CLI).size).toBe(
|
|
MCP_TOOLS_WITHOUT_DEDICATED_CLI.length,
|
|
);
|
|
expect(
|
|
MCP_TOOLS_WITHOUT_DEDICATED_CLI.every((name) =>
|
|
TOOL_CONTRACTS.some((contract) => contract.name === name),
|
|
),
|
|
).toBe(true);
|
|
});
|
|
});
|