Bind typed service creation, observed availability and retryable cleanup in one composition owner. Reuse selected CLI/MCP factories and canonical contract groups without copying provider operation inventories. Closes #8429. Refs #740. Validated paired real application workflows, actual local Codex CLI Terra/high use, complete Evidence and Unknown checkpoint parity, compiler-backed import boundaries, SDK schemas and final real mixed routing. Automated review findings were fixed at their producing owners. Existing exact-base CodeQL alerts are documented on the PR under the owner-authorized unrelated-check exception; no global alerts or security rules were changed. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import type { ReverseEngineeringServiceRuntimeOptions } from "../application/reverse/ReverseEngineeringService.js";
|
|
import type { ReverseEngineeringCommandPort } from "../application/reverse/ReverseEngineeringCommandPort.js";
|
|
import { ReverseEngineeringService } from "../application/reverse/ReverseEngineeringService.js";
|
|
import { objdumpCommand } from "../objdump/ObjdumpCommand.js";
|
|
import { OBJDUMP_PROVIDER_IDENTITY } from "../objdump/ObjdumpProviderIdentity.js";
|
|
import { rizinCommand } from "../rizin/RizinCommand.js";
|
|
import { RIZIN_PROVIDER_IDENTITY } from "../rizin/RizinProviderIdentity.js";
|
|
import { resolveWindowsProviderExecutable } from "./resolveWindowsProviderExecutable.js";
|
|
|
|
export const createReverseEngineeringCommandPort = (
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
platform: NodeJS.Platform = process.platform,
|
|
): ReverseEngineeringCommandPort => ({
|
|
objdump: (input) => ({
|
|
executable: providerExecutable(
|
|
environment.REA_OBJDUMP_COMMAND ?? "objdump",
|
|
environment,
|
|
platform,
|
|
),
|
|
arguments: objdumpCommand(input),
|
|
identity: OBJDUMP_PROVIDER_IDENTITY,
|
|
environmentOverrides: { DEBUGINFOD_URLS: "" },
|
|
}),
|
|
rizin: (input) => ({
|
|
executable: providerExecutable(
|
|
environment.REA_RIZIN_COMMAND ?? "rizin",
|
|
environment,
|
|
platform,
|
|
),
|
|
arguments: rizinCommand(input),
|
|
identity: RIZIN_PROVIDER_IDENTITY,
|
|
}),
|
|
});
|
|
|
|
const providerExecutable = (
|
|
executable: string,
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
platform: NodeJS.Platform,
|
|
): string =>
|
|
platform === "win32"
|
|
? resolveWindowsProviderExecutable(executable, environment)
|
|
: executable;
|
|
|
|
/** Compose BYO reverse-engineering commands without acquiring tools at import time. */
|
|
export const createReverseEngineeringService = (
|
|
environment: Readonly<NodeJS.ProcessEnv> = process.env,
|
|
options: ReverseEngineeringServiceRuntimeOptions = {},
|
|
): ReverseEngineeringService => {
|
|
const environmentSnapshot = { ...environment };
|
|
return new ReverseEngineeringService({
|
|
...options,
|
|
environment: environmentSnapshot,
|
|
commands: createReverseEngineeringCommandPort(environmentSnapshot),
|
|
});
|
|
};
|