2026-10-07 11:45:17 +08:00
|
|
|
import type { BrowserObservationPort } from "./BrowserObservationPort.js";
|
|
|
|
|
import type { BrowserScenarioCapturePort } from "./BrowserScenarioCapturePort.js";
|
2026-10-07 16:03:37 +08:00
|
|
|
import type { ElectronObservationPort } from "./javascript/ElectronObservationPort.js";
|
|
|
|
|
import type { ElectronActiveObservationPort } from "./javascript/ElectronActiveObservationPort.js";
|
|
|
|
|
import type { JavaScriptRuntimeObservationPort } from "./javascript/JavaScriptRuntimeObservationPort.js";
|
2026-10-07 11:45:17 +08:00
|
|
|
import { AnalysisCapabilityUnavailableError } from "../domain/analysisErrorCore.js";
|
|
|
|
|
|
|
|
|
|
/** Existing observation ports loaded independently at MCP startup. */
|
|
|
|
|
export interface OptionalObservationProviders {
|
|
|
|
|
readonly browserObservation?: BrowserObservationPort;
|
|
|
|
|
readonly browserScenarioCapture?: BrowserScenarioCapturePort;
|
|
|
|
|
readonly electronObservation?: ElectronObservationPort;
|
|
|
|
|
readonly electronActiveObservation?: ElectronActiveObservationPort;
|
|
|
|
|
readonly javascriptRuntimeObservation?: JavaScriptRuntimeObservationPort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** A module failed before its port could be constructed; no engine was opened. */
|
|
|
|
|
export interface OptionalProviderLoadFailure {
|
|
|
|
|
readonly providerId: string;
|
|
|
|
|
readonly reason: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type OptionalProviderLoadFailures = Readonly<
|
|
|
|
|
Partial<
|
2026-10-12 11:01:58 -03:00
|
|
|
Record<
|
|
|
|
|
keyof OptionalObservationProviders | "fridaInstrumentation",
|
|
|
|
|
OptionalProviderLoadFailure
|
|
|
|
|
>
|
2026-10-07 11:45:17 +08:00
|
|
|
>
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
/** Successful ports and failed peers from one independent loading attempt. */
|
|
|
|
|
export interface OptionalProviderLoadResult extends OptionalObservationProviders {
|
|
|
|
|
readonly optionalProviderLoadFailures?: OptionalProviderLoadFailures;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Preserve the module's failure reason through the existing tool error algebra. */
|
|
|
|
|
export const optionalProviderUnavailable = (
|
|
|
|
|
failure: OptionalProviderLoadFailure,
|
|
|
|
|
operation: string,
|
|
|
|
|
): AnalysisCapabilityUnavailableError =>
|
|
|
|
|
new AnalysisCapabilityUnavailableError(
|
|
|
|
|
failure.providerId,
|
|
|
|
|
operation,
|
|
|
|
|
`Adapter could not load: ${failure.reason}`,
|
|
|
|
|
);
|