test(linux): verify setup through CLI and MCP

This commit is contained in:
morluto
2026-07-13 21:20:51 +00:00
parent 75818d119e
commit 67504d2d51
20 changed files with 632 additions and 123 deletions
+14 -4
View File
@@ -1,4 +1,10 @@
import type { JsonValue } from "./jsonValue.js";
import {
hopperStartupFailure,
type HopperStartupFailureCode,
} from "./hopperStartupFailure.js";
export { hopperStartupFailure } from "./hopperStartupFailure.js";
export type { HopperStartupFailureCode } from "./hopperStartupFailure.js";
/** Stable tags exposed by safe analysis-error projections. */
const ANALYSIS_ERROR_TAGS = [
@@ -282,14 +288,14 @@ export class HopperRemoteError extends HopperError {
/** The owned Hopper bridge stopped before its client was closed. */
export class HopperProcessError extends HopperError {
readonly _tag = "HopperProcessError";
readonly failureCode: HopperStartupFailureCode | undefined;
override readonly userMessage: string | undefined;
constructor(readonly exitCode: number | null) {
super(`Hopper bridge stopped unexpectedly with code ${String(exitCode)}`);
this.userMessage =
exitCode === 78
? "This Hopper demo build or dialog is not supported for unattended Linux analysis. Update REA or use a supported Hopper build."
: undefined;
const failure = hopperStartupFailure(exitCode);
this.failureCode = failure?.code;
this.userMessage = failure?.message;
}
}
@@ -342,6 +348,7 @@ export interface AnalysisErrorProjection
| "unavailable"
| "execution_failure";
readonly message: string;
readonly code?: HopperStartupFailureCode;
}
/** Project expected failures into exhaustive, secret-safe caller fields. */
@@ -349,9 +356,12 @@ export const projectAnalysisError = (
error: AnalysisError,
): AnalysisErrorProjection => {
assertKnownTag(error._tag);
const code =
error instanceof HopperProcessError ? error.failureCode : undefined;
return {
category: errorCategory(error),
message: userMessage(error),
...(code === undefined ? {} : { code }),
};
};
+73
View File
@@ -0,0 +1,73 @@
export type HopperStartupFailureCode =
| "private_display_unavailable"
| "x11_authorization_failed"
| "unsupported_hopper_build"
| "invalid_launch_command"
| "process_ownership_mismatch"
| "hopper_exited_during_startup"
| "unsupported_demo_dialog"
| "unexpected_display_geometry"
| "x11_input_failed"
| "runtime_dependency_unavailable";
const failures = [
[
70,
"private_display_unavailable",
"REA could not start its private Linux display. Install Xvfb, then rerun rea doctor.",
],
[
71,
"x11_authorization_failed",
"REA could not authorize its private Linux display. Install xauth, then rerun rea doctor.",
],
[
72,
"unsupported_hopper_build",
"This Hopper build is not supported for unattended Linux analysis. Unset HOPPER_LAUNCHER_PATH and rerun rea setup --yes --install-hopper, or update REA.",
],
[
73,
"invalid_launch_command",
"REA refused an unexpected Hopper launch command. Check HOPPER_LAUNCHER_PATH and rerun rea doctor.",
],
[
74,
"process_ownership_mismatch",
"REA could not verify ownership of the launched Hopper process and stopped safely. Close other Hopper sessions and retry.",
],
[
75,
"hopper_exited_during_startup",
"Hopper exited before the REA bridge was ready. Run rea doctor and retry the analysis.",
],
[
76,
"unsupported_demo_dialog",
"This Hopper demo dialog is not supported for unattended Linux analysis. Update REA or use a supported Hopper build.",
],
[
77,
"unexpected_display_geometry",
"REA's private Linux display did not match the validated layout. Close custom display overrides and retry.",
],
[
78,
"x11_input_failed",
"REA could not activate Hopper's validated demo control. Install the XTEST runtime, then rerun rea doctor.",
],
[
79,
"runtime_dependency_unavailable",
"A Linux demo-session dependency is unavailable. Rerun rea setup --yes --install-hopper, then rea doctor.",
],
] as const;
const HOPPER_STARTUP_FAILURES = new Map<
number,
{ readonly code: HopperStartupFailureCode; readonly message: string }
>(failures.map(([exitCode, code, message]) => [exitCode, { code, message }]));
/** Return the stable public failure associated with a Linux demo adapter exit. */
export const hopperStartupFailure = (exitCode: number | null) =>
exitCode === null ? undefined : HOPPER_STARTUP_FAILURES.get(exitCode);