-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathruntime.ts
More file actions
63 lines (62 loc) · 2.33 KB
/
Copy pathruntime.ts
File metadata and controls
63 lines (62 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { AppConfig } from "../config.js";
import type { BinarySession } from "./BinarySession.js";
import { HopperProvider } from "../hopper/HopperProvider.js";
import { GhidraProvider } from "../ghidra/GhidraProvider.js";
import { silentLogger, type Logger } from "../logger.js";
import { GENERATED_AUXILIARY_PROVIDERS } from "../generatedMcpToolCatalog.js";
import { AnalysisProviderRegistry } from "./AnalysisProviderRegistry.js";
import { composeBinarySession } from "./BinarySessionComposition.js";
import { LazyAnalysisProvider } from "./LazyAnalysisProvider.js";
/**
* Compose the target-switching runtime shared directly by CLI and MCP adapters.
* This is the sole production wiring point, so both adapters share identical
* provider selection, profile, lifecycle, and Evidence semantics.
*/
export const createBinarySession = (
config: AppConfig,
logger: Logger = silentLogger,
): BinarySession => {
const hopper = new HopperProvider(config, logger);
const ghidra = new GhidraProvider(config, logger);
const auxiliary = new Map(
GENERATED_AUXILIARY_PROVIDERS.map((provider) => [
provider.identity.id,
provider,
]),
);
const lazyProvider = (
id: string,
load: ConstructorParameters<typeof LazyAnalysisProvider>[0]["load"],
) => {
const generated = auxiliary.get(id);
if (generated === undefined)
throw new TypeError(`Missing generated provider metadata for ${id}`);
return new LazyAnalysisProvider({ ...generated, load });
};
return composeBinarySession(
new AnalysisProviderRegistry([hopper, ghidra], config.analysisProvider),
[
lazyProvider("rea-artifact-graph", async () => {
const { ArtifactProvider } = await import(
"../artifacts/ArtifactProvider.js"
);
return new ArtifactProvider(
config.artifactNativeMountEnabled,
config.artifactIntegrityContinueEnabled,
);
}),
lazyProvider("native-macos", async () => {
const { NativeMacOSProvider } = await import(
"../native/NativeMacOSProvider.js"
);
return new NativeMacOSProvider();
}),
lazyProvider("rea-dotnet-static", async () => {
const { ManagedStaticProvider } = await import(
"../dotnet/ManagedStaticProvider.js"
);
return new ManagedStaticProvider();
}),
],
);
};