mirror of
https://github.com/morluto/rea.git
synced 2026-10-31 03:45:39 +00:00
* fix(providers): name JEB, IDA, and one-shot command deadlines Wire JEB catalog discovery to REA_JEB_MCP_TIMEOUT_MS, name the IDA registration timeoutMs, and add command_timeout_ms for one-shot objdump and rizin. Debugger, Frida, and Cutter caps stay fixed and say so. Refs #5910 Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(providers): pass remaining deadlines and name the cap that fired Catalog discovery now sends the JEB budget still remaining to the SDK on connect and every tools/list page. Objdump and rizin preflight share one command_timeout_ms across stat and digest; the command still receives that budget again. Architecture Evidence keeps a selected timeout, and Frida and Rizin name the capture limit that actually stopped output. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(frida): preserve non-timeout device lookup failures getDeviceById is a lookup deadline only when Frida rejects with "Device not found" after the wait. A device-manager or backend failure stays a capability error. Align the assertions that still expected the previous capacity and capture sentences. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import type { JebAnalysisPort } from "../application/jeb/JebAnalysisPort.js";
|
|
import { parseJebMcpTimeoutMs } from "../config/environment.js";
|
|
import { ConfigurationError } from "../domain/configurationErrors.js";
|
|
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
import { err } from "../domain/result.js";
|
|
import type { JebMcpConnectionFactory } from "../jeb/JebMcpConnection.js";
|
|
import { JebProvider } from "../jeb/JebProvider.js";
|
|
|
|
/**
|
|
* Construct one JEB provider bound to the caller-selected MCP endpoint. An
|
|
* unusable endpoint makes only JEB unavailable; every other CLI command and
|
|
* MCP tool is composed alongside it.
|
|
*/
|
|
export const createJebAnalysisProvider = (
|
|
environment: Readonly<Record<string, string | undefined>> = process.env,
|
|
connectionFactory?: JebMcpConnectionFactory,
|
|
): JebAnalysisPort => {
|
|
const requestTimeout = parseJebMcpTimeoutMs(
|
|
environment.REA_JEB_MCP_TIMEOUT_MS,
|
|
);
|
|
if (!requestTimeout.ok) return unconfiguredJebProvider(requestTimeout.error);
|
|
try {
|
|
return new JebProvider({
|
|
environment,
|
|
...(requestTimeout.value === undefined
|
|
? {}
|
|
: {
|
|
requestTimeoutMs: requestTimeout.value,
|
|
discoveryTimeoutMs: requestTimeout.value,
|
|
}),
|
|
...(connectionFactory === undefined ? {} : { connectionFactory }),
|
|
});
|
|
} catch (cause: unknown) {
|
|
if (!(cause instanceof AnalysisInputError)) throw cause;
|
|
const constraint =
|
|
typeof cause.cause === "string" ? cause.cause : cause.message;
|
|
return unconfiguredJebProvider(
|
|
new ConfigurationError("Invalid REA environment configuration", {
|
|
cause,
|
|
settings: [{ setting: "REA_JEB_MCP_URL", constraint }],
|
|
}),
|
|
);
|
|
}
|
|
};
|
|
|
|
const unconfiguredJebProvider = (
|
|
error: ConfigurationError,
|
|
): JebAnalysisPort => {
|
|
const setting = error.settings[0]?.setting ?? "REA_JEB_MCP_URL";
|
|
return {
|
|
inspectAvailability: () =>
|
|
Promise.resolve({
|
|
status: "unavailable",
|
|
code: "not_configured",
|
|
reason: `${setting} is invalid: ${error.settings[0]?.constraint ?? error.message}`,
|
|
diagnostics: { setting },
|
|
}),
|
|
close: () => Promise.resolve(),
|
|
execute: () => Promise.resolve(err(error)),
|
|
};
|
|
};
|