Merge remote-tracking branch 'origin/main' into feat/dylib-resolution
# Conflicts: # docs/product-catalog.json # docs/verification/managed-conformance-manifest.json # skills/reverse-engineer-anything/SKILL.md # src/generatedMcpToolCatalog.ts
This commit is contained in:
@@ -189,6 +189,12 @@ export const buildCapabilityInventory = (
|
||||
};
|
||||
|
||||
const availabilityFor = (context: AvailabilityContext): Availability => {
|
||||
// These built-in workflows accept a caller-selected endpoint; they do not load the optional passive provider.
|
||||
if (
|
||||
context.name === "observe_web_execution" ||
|
||||
context.name === "inspect_web_event_listeners"
|
||||
)
|
||||
return { reason: "available", remediation: null };
|
||||
if (context.name === "get_navigation_context")
|
||||
return navigationContextAvailability(context.descriptors);
|
||||
const javascriptApplication = javascriptApplicationAvailability(context);
|
||||
|
||||
@@ -3,7 +3,8 @@ import { parseConfig } from "../config.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import { EnhancedTools } from "./EnhancedTools.js";
|
||||
import { executeFunctionAnalysisEvidence } from "./FunctionAnalysisEvidence.js";
|
||||
import { createBinarySession, createManagedBinarySession } from "./runtime.js";
|
||||
import type { DirectAnalysisDependencies } from "./DirectAnalysisDependencies.js";
|
||||
import type { BinarySession } from "./binary/BinarySession.js";
|
||||
import { silentLogger, type Logger } from "../logger.js";
|
||||
import { createEvidence } from "../domain/evidence.js";
|
||||
import type { Evidence } from "../domain/evidence.js";
|
||||
@@ -38,11 +39,6 @@ import {
|
||||
import type { AnalysisProviderSelector } from "../contracts/providerSelection.js";
|
||||
import { artifactInspectionResultSchema } from "../domain/artifactInspection.js";
|
||||
|
||||
export {
|
||||
runCapabilityStatus,
|
||||
runProviderStatus,
|
||||
} from "./DirectAnalysisStatus.js";
|
||||
|
||||
type DirectAnalysisTool =
|
||||
| "annotate_native_function"
|
||||
| "inspect_native_load_image"
|
||||
@@ -70,6 +66,7 @@ type DirectAnalysisTool =
|
||||
* retain a target or provider client for a subsequent command.
|
||||
*/
|
||||
export const runDirectAnalysis = async (
|
||||
dependencies: DirectAnalysisDependencies,
|
||||
path: string,
|
||||
tool: DirectAnalysisTool,
|
||||
arguments_: Readonly<Record<string, JsonValue>>,
|
||||
@@ -82,7 +79,7 @@ export const runDirectAnalysis = async (
|
||||
} = {},
|
||||
): Promise<JsonValue> =>
|
||||
withProcessCancellation(options.signal, (signal) =>
|
||||
runAnalysis(path, tool, arguments_, {
|
||||
runAnalysis(dependencies, path, tool, arguments_, {
|
||||
logger: options.logger ?? silentLogger,
|
||||
snapshotPath: options.snapshotPath,
|
||||
signal,
|
||||
@@ -97,6 +94,7 @@ export const runDirectAnalysis = async (
|
||||
|
||||
/** Execute one provider-native semantic operation with atomic provenance. */
|
||||
export const runProviderAnalysis = async (
|
||||
dependencies: DirectAnalysisDependencies,
|
||||
...[path, tool, arguments_, logger = silentLogger, signal]: readonly [
|
||||
path: string,
|
||||
tool: NativeToolName | ArtifactAnalysisOperation | ManagedToolName,
|
||||
@@ -106,9 +104,9 @@ export const runProviderAnalysis = async (
|
||||
]
|
||||
): Promise<JsonValue> =>
|
||||
isManagedToolName(tool)
|
||||
? runManagedProviderAnalysis(path, tool, signal)
|
||||
? runManagedProviderAnalysis(dependencies, path, tool, signal)
|
||||
: withProcessCancellation(signal, (operationSignal) =>
|
||||
runAnalysis(path, tool, arguments_, {
|
||||
runAnalysis(dependencies, path, tool, arguments_, {
|
||||
logger,
|
||||
snapshotPath: undefined,
|
||||
signal: operationSignal,
|
||||
@@ -117,12 +115,13 @@ export const runProviderAnalysis = async (
|
||||
|
||||
/** Execute managed metadata inspection in an isolated managed-only session. */
|
||||
export const runManagedProviderExecution = async (
|
||||
dependencies: DirectAnalysisDependencies,
|
||||
path: string,
|
||||
tool: ManagedToolName,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Result<AnalysisExecution, AnalysisError>> =>
|
||||
withProcessCancellation(signal, async (operationSignal) => {
|
||||
const session = createManagedBinarySession();
|
||||
const session = dependencies.createManagedBinarySession();
|
||||
try {
|
||||
const opened = await session.open(path, { signal: operationSignal });
|
||||
if (!opened.ok) return opened;
|
||||
@@ -133,11 +132,17 @@ export const runManagedProviderExecution = async (
|
||||
});
|
||||
|
||||
const runManagedProviderAnalysis = async (
|
||||
dependencies: DirectAnalysisDependencies,
|
||||
path: string,
|
||||
tool: ManagedToolName,
|
||||
signal?: AbortSignal,
|
||||
): Promise<JsonValue> => {
|
||||
const execution = await runManagedProviderExecution(path, tool, signal);
|
||||
const execution = await runManagedProviderExecution(
|
||||
dependencies,
|
||||
path,
|
||||
tool,
|
||||
signal,
|
||||
);
|
||||
if (!execution.ok) return cliError(execution.error);
|
||||
const value = execution.value;
|
||||
return createEvidence(value.subject ?? undefined, value.provider, {
|
||||
@@ -151,6 +156,7 @@ const runManagedProviderAnalysis = async (
|
||||
};
|
||||
|
||||
const runAnalysis = async (
|
||||
dependencies: DirectAnalysisDependencies,
|
||||
path: string,
|
||||
tool:
|
||||
| NativeToolName
|
||||
@@ -177,7 +183,7 @@ const runAnalysis = async (
|
||||
const { logger, signal, snapshotPath } = options;
|
||||
const config = parseConfig(options.environment ?? process.env);
|
||||
if (!config.ok) return cliError(config.error);
|
||||
const session = createBinarySession(config.value, logger);
|
||||
const session = dependencies.createBinarySession(config.value, logger);
|
||||
try {
|
||||
const prepared = await prepareSnapshot({
|
||||
path,
|
||||
@@ -247,13 +253,13 @@ const runAnalysis = async (
|
||||
};
|
||||
|
||||
const canReplayDirectTool = (
|
||||
session: ReturnType<typeof createBinarySession>,
|
||||
tool: Parameters<typeof runAnalysis>[1],
|
||||
session: BinarySession,
|
||||
tool: Parameters<typeof runAnalysis>[2],
|
||||
): boolean =>
|
||||
tool !== "trace_native_ui_action" && session.allowsSnapshotReplay(tool);
|
||||
|
||||
const executeAnalysisTool = async (input: {
|
||||
readonly session: ReturnType<typeof createBinarySession>;
|
||||
readonly session: BinarySession;
|
||||
readonly openedTarget: BinaryTarget;
|
||||
readonly tool:
|
||||
| NativeToolName
|
||||
@@ -372,7 +378,7 @@ const prepareSnapshot = async (options: {
|
||||
};
|
||||
|
||||
const replayProviderFor = (
|
||||
session: ReturnType<typeof createBinarySession>,
|
||||
session: BinarySession,
|
||||
tool:
|
||||
| NativeToolName
|
||||
| ArtifactAnalysisOperation
|
||||
@@ -384,7 +390,7 @@ const replayProviderFor = (
|
||||
: session.providerIdentity(tool);
|
||||
|
||||
const analysisProfileForEvidence = (
|
||||
session: ReturnType<typeof createBinarySession>,
|
||||
session: BinarySession,
|
||||
tool:
|
||||
| NativeToolName
|
||||
| ArtifactAnalysisOperation
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { AppConfig } from "../config.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import type { BinarySession } from "./binary/BinarySession.js";
|
||||
|
||||
/** Existing one-shot session factories supplied by the production boundary. */
|
||||
export interface DirectAnalysisDependencies {
|
||||
readonly createBinarySession: (
|
||||
config: AppConfig,
|
||||
logger: Logger,
|
||||
) => BinarySession;
|
||||
readonly createManagedBinarySession: () => BinarySession;
|
||||
}
|
||||
@@ -3,15 +3,16 @@ import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||
import { jsonObjectSchema, type JsonValue } from "../domain/jsonValue.js";
|
||||
import { createServerIdentity } from "../serverIdentity.js";
|
||||
import { silentLogger, type Logger } from "../logger.js";
|
||||
import { createBinarySession } from "./runtime.js";
|
||||
import type { DirectAnalysisDependencies } from "./DirectAnalysisDependencies.js";
|
||||
|
||||
const runSessionStatus = async (
|
||||
dependencies: Pick<DirectAnalysisDependencies, "createBinarySession">,
|
||||
logger: Logger = silentLogger,
|
||||
environment: Readonly<Record<string, string | undefined>> = process.env,
|
||||
): Promise<JsonValue> => {
|
||||
const config = parseConfig(environment);
|
||||
if (!config.ok) return { error: projectAnalysisError(config.error) };
|
||||
const session = createBinarySession(config.value, logger);
|
||||
const session = dependencies.createBinarySession(config.value, logger);
|
||||
try {
|
||||
return {
|
||||
...jsonObjectSchema.parse(session.status()),
|
||||
@@ -26,12 +27,14 @@ const runSessionStatus = async (
|
||||
|
||||
/** List binary-session provider candidates and auxiliary operation availability. */
|
||||
export const runProviderStatus = (
|
||||
dependencies: Pick<DirectAnalysisDependencies, "createBinarySession">,
|
||||
logger: Logger = silentLogger,
|
||||
environment: Readonly<Record<string, string | undefined>> = process.env,
|
||||
) => runSessionStatus(logger, environment);
|
||||
) => runSessionStatus(dependencies, logger, environment);
|
||||
|
||||
/** List binary-session operation descriptors; this is not the full MCP catalog. */
|
||||
export const runCapabilityStatus = (
|
||||
dependencies: Pick<DirectAnalysisDependencies, "createBinarySession">,
|
||||
logger: Logger = silentLogger,
|
||||
environment: Readonly<Record<string, string | undefined>> = process.env,
|
||||
) => runSessionStatus(logger, environment);
|
||||
) => runSessionStatus(dependencies, logger, environment);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { ExecutionOptions, ProviderIdentity } from "./AnalysisProvider.js";
|
||||
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import type { Result } from "../domain/result.js";
|
||||
import type {
|
||||
ObserveWebExecutionInput,
|
||||
WebExecution,
|
||||
} from "../domain/webExecution.js";
|
||||
import type {
|
||||
InspectWebEventListenersInput,
|
||||
WebEventListeners,
|
||||
} from "../domain/webEventListeners.js";
|
||||
|
||||
/** Provider-neutral live source attribution operations with distinct instrumentation authority. */
|
||||
export interface WebRuntimePort {
|
||||
identity(): ProviderIdentity;
|
||||
observeExecution(
|
||||
input: ObserveWebExecutionInput,
|
||||
options?: ExecutionOptions,
|
||||
): Promise<Result<WebExecution, AnalysisError>>;
|
||||
inspectEventListeners(
|
||||
input: InspectWebEventListenersInput,
|
||||
options?: ExecutionOptions,
|
||||
): Promise<Result<WebEventListeners, AnalysisError>>;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import type { WebRuntimePort } from "./WebRuntimePort.js";
|
||||
import { ok } from "../domain/result.js";
|
||||
import type { WebExecution } from "../domain/webExecution.js";
|
||||
import type { WebEventListeners } from "../domain/webEventListeners.js";
|
||||
|
||||
const browser = {
|
||||
product: "RecordingChrome/1",
|
||||
protocol_version: "1.3",
|
||||
revision: "fixture",
|
||||
user_agent: "fixture",
|
||||
js_version: "fixture",
|
||||
};
|
||||
const target = {
|
||||
target_id: "selected-page",
|
||||
initial_url: "http://127.0.0.1:9222/app",
|
||||
origin: "http://127.0.0.1:9222",
|
||||
frame_id: "main-frame",
|
||||
loader_id: "fixture-document",
|
||||
};
|
||||
const at = "2026-01-01T00:00:00.000Z";
|
||||
|
||||
/** Immutable application-port result; it makes no real browser or socket claim. */
|
||||
export const webExecutionFixture = (
|
||||
targetId = target.target_id,
|
||||
duration = 5,
|
||||
): WebExecution => ({
|
||||
browser,
|
||||
target: { ...target, target_id: targetId },
|
||||
window: {
|
||||
armed_at: at,
|
||||
ended_at: at,
|
||||
requested_ms: duration,
|
||||
end_reason: "window_elapsed",
|
||||
producer_started_seconds: 1,
|
||||
producer_sampled_seconds: 2,
|
||||
},
|
||||
coverage: {
|
||||
state: "captured",
|
||||
reason: null,
|
||||
offset_units: "utf16-code-units",
|
||||
end_offset: "exclusive",
|
||||
scripts: [],
|
||||
excluded_scripts: 0,
|
||||
},
|
||||
requests: [],
|
||||
excluded_requests: 0,
|
||||
sources: [],
|
||||
script_inventory: {
|
||||
main_document_scripts: 0,
|
||||
not_reported_script_ids: [],
|
||||
coverage_absence: "unknown",
|
||||
},
|
||||
instrumentation: {
|
||||
resets_execution_counters: true,
|
||||
disables_optimized_execution: true,
|
||||
takes_one_resetting_sample: true,
|
||||
executes_selected_code: false,
|
||||
cleanup: "confirmed",
|
||||
page_ownership: "external",
|
||||
},
|
||||
limitations: ["Recording port fixture, not real browser evidence."],
|
||||
});
|
||||
|
||||
/** Immutable listener port result for application and SDK schema boundaries. */
|
||||
export const webListenersFixture = (
|
||||
targetId = target.target_id,
|
||||
selector = "#selected",
|
||||
): WebEventListeners => ({
|
||||
browser,
|
||||
target: { ...target, target_id: targetId },
|
||||
inspected_at: at,
|
||||
selected_node: { selector, match: "found", backend_node_id: 22 },
|
||||
listeners: [],
|
||||
sources: [],
|
||||
cleanup: "confirmed",
|
||||
limitations: ["Recording port fixture, not real listener evidence."],
|
||||
});
|
||||
|
||||
/** Provider-neutral recording seam preserves the exact parsed caller target and window. */
|
||||
export const recordingWebRuntimePort = (): WebRuntimePort => ({
|
||||
identity: () => ({
|
||||
id: "runtime-recording",
|
||||
name: "Runtime recording fixture",
|
||||
version: "1",
|
||||
}),
|
||||
observeExecution: async (input) =>
|
||||
ok(webExecutionFixture(input.target_id, input.observation_ms)),
|
||||
inspectEventListeners: async (input) =>
|
||||
ok(webListenersFixture(input.target_id, input.selector)),
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { WebRuntimeService } from "./WebRuntimeService.js";
|
||||
import {
|
||||
recordingWebRuntimePort,
|
||||
webListenersFixture,
|
||||
} from "./WebRuntimeService.fixture.js";
|
||||
import { err, ok } from "../domain/result.js";
|
||||
import { AnalysisTimeoutError } from "../domain/analysisErrorCore.js";
|
||||
|
||||
it("rejects malformed input and prior cancellation without calling a provider", async () => {
|
||||
const provider = recordingWebRuntimePort();
|
||||
const service = new WebRuntimeService({
|
||||
identity: () => provider.identity(),
|
||||
observeExecution: () => {
|
||||
throw new Error("Provider must not be called");
|
||||
},
|
||||
inspectEventListeners: () => {
|
||||
throw new Error("Provider must not be called");
|
||||
},
|
||||
});
|
||||
const malformed = await service.observe({
|
||||
cdp_endpoint: "https://remote.example",
|
||||
target_id: "page",
|
||||
});
|
||||
if (malformed.ok)
|
||||
throw new Error("Invalid endpoint must fail before execution");
|
||||
expect(malformed.error._tag).toBe("AnalysisInputError");
|
||||
const cancelled = await service.inspect({}, { signal: AbortSignal.abort() });
|
||||
if (cancelled.ok)
|
||||
throw new Error("Prior cancellation must fail before inspection");
|
||||
expect(cancelled.error._tag).toBe("AnalysisCancelledError");
|
||||
});
|
||||
|
||||
it("preserves actual provider failures and rejects changed target/selector identities", async () => {
|
||||
const provider = recordingWebRuntimePort();
|
||||
const args = {
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
target_id: "selected-page",
|
||||
selector: "#selected",
|
||||
};
|
||||
const captured = webListenersFixture();
|
||||
const timeout = new AnalysisTimeoutError("observe_web_execution", 20_000);
|
||||
const service = new WebRuntimeService({
|
||||
identity: () => provider.identity(),
|
||||
observeExecution: async () => err(timeout),
|
||||
inspectEventListeners: async () =>
|
||||
ok({
|
||||
...captured,
|
||||
selected_node: { ...captured.selected_node, selector: "#different" },
|
||||
}),
|
||||
});
|
||||
const failed = await service.observe({
|
||||
cdp_endpoint: args.cdp_endpoint,
|
||||
target_id: args.target_id,
|
||||
observation_ms: 5,
|
||||
});
|
||||
expect(failed).toEqual(err(timeout));
|
||||
const changed = await service.inspect(args);
|
||||
if (changed.ok) throw new Error("Changed selection must be rejected");
|
||||
expect(changed.error._tag).toBe("AnalysisOutputError");
|
||||
});
|
||||
@@ -0,0 +1,146 @@
|
||||
import { z } from "zod";
|
||||
import type { ExecutionOptions } from "./AnalysisProvider.js";
|
||||
import type { WebRuntimePort } from "./WebRuntimePort.js";
|
||||
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import {
|
||||
AnalysisCancelledError,
|
||||
AnalysisInputError,
|
||||
AnalysisOutputError,
|
||||
} from "../domain/analysisErrorCore.js";
|
||||
import { createEvidence, type Evidence } from "../domain/evidence.js";
|
||||
import { jsonObjectSchema, jsonValueSchema } from "../domain/jsonValue.js";
|
||||
import { projectInputIssues } from "../domain/inputIssueProjection.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import {
|
||||
observeWebExecutionInputSchema,
|
||||
webExecutionSchema,
|
||||
} from "../domain/webExecution.js";
|
||||
import {
|
||||
inspectWebEventListenersInputSchema,
|
||||
webEventListenersSchema,
|
||||
} from "../domain/webEventListeners.js";
|
||||
|
||||
/** Shared public workflows keep instrumentation and listener inspection independently selectable. */
|
||||
export class WebRuntimeService {
|
||||
constructor(readonly provider: WebRuntimePort) {}
|
||||
|
||||
/** Observe externally triggered execution; selection authorizes the declared instrumentation. */
|
||||
async observe(
|
||||
rawInput: unknown,
|
||||
options?: ExecutionOptions,
|
||||
): Promise<Result<Evidence, AnalysisError>> {
|
||||
const operation = "observe_web_execution";
|
||||
const parsed = parseInput(
|
||||
observeWebExecutionInputSchema,
|
||||
rawInput,
|
||||
operation,
|
||||
options,
|
||||
);
|
||||
if (!parsed.ok) return parsed;
|
||||
const result = await this.provider.observeExecution(parsed.value, options);
|
||||
if (!result.ok) return result;
|
||||
const verified = webExecutionSchema.safeParse(result.value);
|
||||
if (!verified.success)
|
||||
return err(new AnalysisOutputError(operation, verified.error.message));
|
||||
if (
|
||||
verified.data.target.target_id !== parsed.value.target_id ||
|
||||
verified.data.window.requested_ms !== parsed.value.observation_ms
|
||||
)
|
||||
return err(
|
||||
new AnalysisOutputError(
|
||||
operation,
|
||||
"Provider changed the selected target or requested window.",
|
||||
),
|
||||
);
|
||||
return this.evidence(operation, parsed.value, verified.data, options);
|
||||
}
|
||||
|
||||
/** Inspect one selected node's listener declarations without dispatching an event. */
|
||||
async inspect(
|
||||
rawInput: unknown,
|
||||
options?: ExecutionOptions,
|
||||
): Promise<Result<Evidence, AnalysisError>> {
|
||||
const operation = "inspect_web_event_listeners";
|
||||
const parsed = parseInput(
|
||||
inspectWebEventListenersInputSchema,
|
||||
rawInput,
|
||||
operation,
|
||||
options,
|
||||
);
|
||||
if (!parsed.ok) return parsed;
|
||||
const result = await this.provider.inspectEventListeners(
|
||||
parsed.value,
|
||||
options,
|
||||
);
|
||||
if (!result.ok) return result;
|
||||
const verified = webEventListenersSchema.safeParse(result.value);
|
||||
if (!verified.success)
|
||||
return err(new AnalysisOutputError(operation, verified.error.message));
|
||||
if (
|
||||
verified.data.target.target_id !== parsed.value.target_id ||
|
||||
verified.data.selected_node.selector !== parsed.value.selector
|
||||
)
|
||||
return err(
|
||||
new AnalysisOutputError(
|
||||
operation,
|
||||
"Provider changed the selected target or node selector.",
|
||||
),
|
||||
);
|
||||
return this.evidence(operation, parsed.value, verified.data, options);
|
||||
}
|
||||
|
||||
private evidence(
|
||||
operation: string,
|
||||
input:
|
||||
| z.infer<typeof observeWebExecutionInputSchema>
|
||||
| z.infer<typeof inspectWebEventListenersInputSchema>,
|
||||
result:
|
||||
| z.infer<typeof webExecutionSchema>
|
||||
| z.infer<typeof webEventListenersSchema>,
|
||||
options?: ExecutionOptions,
|
||||
): Result<Evidence, AnalysisError> {
|
||||
if (options?.signal?.aborted)
|
||||
return err(new AnalysisCancelledError(operation));
|
||||
if (
|
||||
input.allowed_origins.length > 0 &&
|
||||
!input.allowed_origins.includes(result.target.origin)
|
||||
)
|
||||
return err(
|
||||
new AnalysisOutputError(
|
||||
operation,
|
||||
"Provider returned a document outside the selected origin scope.",
|
||||
),
|
||||
);
|
||||
return ok(
|
||||
createEvidence(undefined, this.provider.identity(), {
|
||||
predicateType: `rea.${operation.replaceAll("_", "-")}`,
|
||||
operation,
|
||||
parameters: jsonObjectSchema.parse(input),
|
||||
result: jsonValueSchema.parse(result),
|
||||
confidence: "observed",
|
||||
authority: "external-service",
|
||||
limitations: result.limitations,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const parseInput = <T>(
|
||||
schema: z.ZodType<T>,
|
||||
rawInput: unknown,
|
||||
operation: string,
|
||||
options: ExecutionOptions | undefined,
|
||||
): Result<T, AnalysisError> => {
|
||||
if (options?.signal?.aborted)
|
||||
return err(new AnalysisCancelledError(operation));
|
||||
const parsed = schema.safeParse(rawInput);
|
||||
return parsed.success
|
||||
? ok(parsed.data)
|
||||
: err(
|
||||
new AnalysisInputError(
|
||||
operation,
|
||||
{ cause: parsed.error },
|
||||
projectInputIssues(parsed.error.issues, rawInput),
|
||||
),
|
||||
);
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
import type { AppConfig } from "../config.js";
|
||||
import type { BinarySession } from "./binary/BinarySession.js";
|
||||
import { HopperProvider } from "../hopper/HopperProvider.js";
|
||||
import { GhidraProvider } from "../ghidra/GhidraProvider.js";
|
||||
import { IdaProvider } from "../ida/IdaProvider.js";
|
||||
import { silentLogger, type Logger } from "../logger.js";
|
||||
import { auxiliaryAnalysisProviderDeclarations } from "../composition/auxiliaryAnalysisProviders.js";
|
||||
import { AnalysisProviderRegistry } from "./binary/AnalysisProviderRegistry.js";
|
||||
import { composeBinarySession } from "./binary/BinarySessionComposition.js";
|
||||
import { LazyAnalysisProvider } from "./binary/LazyAnalysisProvider.js";
|
||||
import { ManagedStaticProvider } from "../dotnet/ManagedStaticProvider.js";
|
||||
import { SessionProviderRouter } from "./binary/SessionProviderRouter.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 ida = new IdaProvider(config);
|
||||
return composeBinarySession(
|
||||
new AnalysisProviderRegistry(
|
||||
[hopper, ghidra, ida],
|
||||
config.analysisProvider,
|
||||
),
|
||||
auxiliaryAnalysisProviderDeclarations().map(
|
||||
(declaration) => new LazyAnalysisProvider(declaration),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
/** Compose an execution-free managed session without native provider selection. */
|
||||
export const createManagedBinarySession = (): BinarySession =>
|
||||
composeBinarySession(
|
||||
SessionProviderRouter.selectable(new AnalysisProviderRegistry([]), [
|
||||
new ManagedStaticProvider(),
|
||||
]),
|
||||
);
|
||||
Reference in New Issue
Block a user