mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
* fix(mcp): name response-byte and startup ceilings in recovery Name REA_MCP_MAX_RESPONSE_BYTES, its effective value, the 10485760 byte floor, and process restart when the stdio response budget is hit, and state that the setting does not raise Node's string ceiling. Name fixed MCP startup phase budgets when those deadlines fire, and keep Codex's 30 second startup figure as client guidance. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(mcp): distinguish string ceilings and keep dossier recovery Name REA's reserved string limit separately from Node's ceiling, restore detail:summary discovery for an oversized complete evidence bundle, and apply the doctor deadline sentence when binary_session itself times out. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(mcp): keep retained SDK errors inside the text budget Quoted SDK validation diagnostics expand when recovery JSON is escaped into MCP text. Shorten only that preview so the retained-evidence reference still arrives as parseable error content. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(mcp): keep export advice when a summary exceeds the response budget An oversized get_evidence_bundle summary no longer repeats detail: summary. export_evidence_bundle still writes the retained bundle outside one MCP frame, including when a larger byte budget cannot raise the string ceiling. Co-authored-by: morluto <morluto@users.noreply.github.com> * style(mcp): format the SDK diagnostic preview return oxfmt rejected the fitted-preview ternary in EvidenceMcpServer.ts, which failed Static checks and the CI required gate. 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>
78 lines
2.9 KiB
TypeScript
78 lines
2.9 KiB
TypeScript
import type { AnalysisProviderSelector } from "./contracts/providerSelection.js";
|
|
|
|
/**
|
|
* Supported MCP startup deadlines and operation headroom.
|
|
*
|
|
* Client timeouts are caller-facing configuration. The smaller phase budgets
|
|
* preserve operational headroom, while the doctor deadline covers additional
|
|
* inventory requests after initialization.
|
|
*/
|
|
export const MCP_STARTUP_POLICY = {
|
|
codexStartupTimeoutSeconds: 30,
|
|
kimiStartupTimeoutMs: 30_000,
|
|
toolOperationHeadroomMs: 120_000,
|
|
initializeBudgetMs: 15_000,
|
|
toolsListBudgetMs: 5_000,
|
|
firstCatalogBudgetMs: 20_000,
|
|
doctorDeadlineMs: 30_000,
|
|
doctorStderrBytes: 64 * 1024,
|
|
} as const;
|
|
|
|
/**
|
|
* Recovery for a fixed MCP startup phase budget. Codex's startup figure is
|
|
* client guidance and is not named here; doctor text adds that distinction
|
|
* because its deadline uses the same 30 second magnitude.
|
|
*/
|
|
export const fixedMcpPhaseBudgetRecovery = (
|
|
phase: string,
|
|
value: number,
|
|
unit: "ms" | "bytes",
|
|
): string =>
|
|
`REA's fixed ${phase} is ${String(value)} ${unit} and this release has no runtime override.`;
|
|
|
|
/** Doctor startup recovery. The Codex figure is client guidance REA does not enforce. */
|
|
export const mcpDoctorDeadlineRecovery = (budgetMs: number): string =>
|
|
`${fixedMcpPhaseBudgetRecovery("MCP doctor startup deadline", budgetMs, "ms")} Codex startup_timeout_sec of ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)} seconds is client guidance; REA does not enforce that figure as this deadline.`;
|
|
|
|
/** Parsed startup and upstream request budgets affecting a client's tool deadline. */
|
|
export interface McpToolTimeoutInputs {
|
|
readonly analysisProvider: AnalysisProviderSelector;
|
|
readonly ghidraStartupTimeoutMs: number;
|
|
readonly hopperStartupTimeoutMs: number;
|
|
readonly jebMcpTimeoutMs?: number;
|
|
readonly providerRequestTimeoutMs?: number;
|
|
}
|
|
|
|
/** Allow for known startup phases and caller-selected upstream request budgets. */
|
|
export const mcpProviderDeadlineAllowanceMs = (
|
|
inputs: McpToolTimeoutInputs,
|
|
): number => {
|
|
const selectedProvider = inputs.analysisProvider;
|
|
const selectedTimeout =
|
|
selectedProvider === "ghidra"
|
|
? inputs.ghidraStartupTimeoutMs
|
|
: selectedProvider === "hopper"
|
|
? inputs.hopperStartupTimeoutMs
|
|
: Math.max(
|
|
inputs.ghidraStartupTimeoutMs,
|
|
inputs.hopperStartupTimeoutMs,
|
|
);
|
|
return Math.max(
|
|
selectedTimeout,
|
|
inputs.jebMcpTimeoutMs ?? 0,
|
|
inputs.providerRequestTimeoutMs ?? 0,
|
|
);
|
|
};
|
|
|
|
/** Add operation headroom to the parsed provider deadline allowance. */
|
|
export const recommendedMcpToolTimeoutMs = (
|
|
inputs: McpToolTimeoutInputs,
|
|
): number =>
|
|
mcpProviderDeadlineAllowanceMs(inputs) +
|
|
MCP_STARTUP_POLICY.toolOperationHeadroomMs;
|
|
|
|
/** Round up so Codex's whole-second deadline still covers the millisecond budget. */
|
|
export const recommendedMcpToolTimeoutSeconds = (
|
|
inputs: McpToolTimeoutInputs,
|
|
): number => Math.ceil(recommendedMcpToolTimeoutMs(inputs) / 1000);
|