Files
reverse-engineering-anything/src/application/OptionalObservationProviders.ts
T
Daniel Gonçalves AraujoandN0zoM1z0 4a4ae9b2b9 feat: add Frida instrumentation support (#1359)
* feat: add Frida instrumentation support

* fix: resolve Frida CI checks

* test: cover Frida contract validation branches

* docs: link Frida instrumentation guide

* fix(frida): handle cancellation cleanup safely

* fix(frida): address PR review findings

* fix(frida): preserve resume and message observations

* fix(ci): use canonical registry for rolldown

* fix(frida): declare foreign code effects

* fix(frida): retain failed startup resources for cleanup retries

Keep failed startup session and spawn handles owned until detach, resume,
and remote lease cleanup complete. Serialize retries and release each
remote reference once. Await CLI provider cleanup while preserving the
primary failure and any completed observations.

Add regressions for retained startup resources, concurrent cleanup,
shared remote leases, and CLI cleanup outcomes.

Validation: 41 focused tests pass on the PR head and its latest-main
integration; serial static and docs checks pass. Real Linux Frida 17.23.2
workflows and the native spawn/controlled-failure cleanup probe pass.

Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)

---------

Co-authored-by: N0zoM1z0 <1705004398@qq.com>
2026-10-12 22:01:58 +08:00

47 lines
1.9 KiB
TypeScript

import type { BrowserObservationPort } from "./BrowserObservationPort.js";
import type { BrowserScenarioCapturePort } from "./BrowserScenarioCapturePort.js";
import type { ElectronObservationPort } from "./javascript/ElectronObservationPort.js";
import type { ElectronActiveObservationPort } from "./javascript/ElectronActiveObservationPort.js";
import type { JavaScriptRuntimeObservationPort } from "./javascript/JavaScriptRuntimeObservationPort.js";
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<
Record<
keyof OptionalObservationProviders | "fridaInstrumentation",
OptionalProviderLoadFailure
>
>
>;
/** 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}`,
);