rea-agents 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +157 -650
- package/bridge/mitmproxy/capture.py +210 -0
- package/bridge/native/rea_lldb_tracer.py +303 -0
- package/bridge/process/ProcessRunTokenReader.swift +263 -0
- package/bridge/process/ProcessRunTokenReaderMain.swift +35 -0
- package/bridge/pwndbg/core_context.py +101 -0
- package/bridge/pwndbg/launch.py +39 -0
- package/bridge/pwndbg/launch_impl.py +34 -0
- package/bridge/pwntools/decoder_runtime.py +59 -0
- package/bridge/pwntools/layout.py +39 -0
- package/bridge/pwntools/layout_impl.py +309 -0
- package/bridge/pwntools/recorded_crash.py +39 -0
- package/bridge/pwntools/recorded_crash_impl.py +143 -0
- package/dist/android/JadxProvider.js +1 -0
- package/dist/application/CapabilityInventory.js +21 -0
- package/dist/application/DirectAnalysis.js +97 -23
- package/dist/application/EvidenceBundleFiles.js +1 -1
- package/dist/application/ReconstructionObligationCandidates.js +5 -1
- package/dist/application/WebNetworkCapturePort.js +1 -0
- package/dist/application/WebNetworkCaptureService.js +132 -0
- package/dist/application/WindowsCapabilities.js +1 -1
- package/dist/application/binary/AnalysisSnapshotCache.js +49 -6
- package/dist/application/binary/BinarySession.js +38 -10
- package/dist/application/binary/BinarySessionOpen.js +16 -3
- package/dist/application/binary/BinarySessionRecords.js +20 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +57 -0
- package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +60 -0
- package/dist/application/evm/EvmInterfacePort.js +1 -0
- package/dist/application/evm/EvmInterfaceService.js +62 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +15 -2
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +42 -23
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +74 -24
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +23 -10
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +145 -70
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +14 -15
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +41 -1
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -9
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +118 -12
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +5 -5
- package/dist/application/{ProcessCli.js → process/ProcessCli.js} +10 -10
- package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +4 -4
- package/dist/artifacts/ArtifactProvider.js +30 -3
- package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
- package/dist/artifacts/ZipArtifactReader.js +3 -0
- package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
- package/dist/artifacts/apple/MachoLoadCommandReader.js +294 -0
- package/dist/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
- package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +3 -3
- package/dist/{application → artifacts/inventory}/ArtifactInventory.js +4 -4
- package/dist/{application/ArtifactInventory → artifacts/inventory}/classify.js +2 -2
- package/dist/{application/ArtifactInventory → artifacts/inventory}/reader.js +5 -5
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanCanonical.js +3 -3
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
- package/dist/artifacts/readStableArtifact.js +20 -4
- package/dist/browser/CdpCaptureEventHandlers.js +90 -2
- package/dist/browser/CdpCaptureEvents.js +9 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +12 -3
- package/dist/browser/history/CaptureFailures.js +101 -0
- package/dist/browser/history/CaptureFormatError.js +10 -0
- package/dist/browser/history/CaptureRedaction.js +65 -0
- package/dist/browser/history/CaptureRelease.js +12 -0
- package/dist/browser/history/HarCapture.js +165 -0
- package/dist/browser/history/HarCaptureAdapter.js +20 -0
- package/dist/browser/history/HarCaptureProcess.js +57 -0
- package/dist/browser/history/HarJson.js +91 -0
- package/dist/browser/history/HarSchema.js +72 -0
- package/dist/browser/history/HistoricalCaptureDecoder.js +186 -0
- package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
- package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
- package/dist/cli/artifactCommands.js +26 -1
- package/dist/cli/binaryDiagnosticsCommands.js +39 -0
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +8 -8
- package/dist/cli/electronCommands.js +16 -9
- package/dist/cli/evmCommands.js +24 -0
- package/dist/cli/firmwareCommands.js +6 -3
- package/dist/cli/javascriptApplicationAnalysis.js +16 -3
- package/dist/cli/jsonOutput.js +133 -0
- package/dist/cli/nativeCallCommands.js +35 -0
- package/dist/cli/processCommands.js +1 -1
- package/dist/cli/streamedJsonOutput.js +56 -0
- package/dist/cli/utilityCommands.js +2 -0
- package/dist/cli/webNetworkCaptureCommands.js +40 -0
- package/dist/cli.js +9 -3
- package/dist/cliBrowserScenarioCommands.js +2 -2
- package/dist/cliCommandNames.js +6 -0
- package/dist/cliJsonInput.js +30 -1
- package/dist/cliOutput.js +21 -6
- package/dist/composition/binaryDiagnostics.js +8 -0
- package/dist/composition/evm.js +4 -0
- package/dist/composition/webNetworkCaptures.js +6 -0
- package/dist/contracts/artifactToolContracts.js +6 -0
- package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
- package/dist/contracts/browserToolContracts.js +4 -3
- package/dist/contracts/errorSchemas.js +8 -1
- package/dist/contracts/evm/evmToolContracts.js +20 -0
- package/dist/contracts/investigationExamples.js +2 -2
- package/dist/contracts/managed/managedToolContracts.js +7 -3
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
- package/dist/contracts/native/nativeToolContracts.js +17 -1
- package/dist/contracts/officialToolContracts.js +12 -9
- package/dist/contracts/process/processCaptureExample.js +2 -0
- package/dist/contracts/sessionLifecycleInputs.js +22 -5
- package/dist/contracts/sessionStatusContract.js +10 -2
- package/dist/contracts/sessionToolContracts.js +8 -1
- package/dist/contracts/sessionToolSchemas.js +10 -3
- package/dist/contracts/toolContractExamples.js +1 -1
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +30 -0
- package/dist/contracts/toolOutputSchemaGroups.js +5 -1
- package/dist/contracts/toolOutputSchemaPrimitives.js +1 -1
- package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
- package/dist/domain/analysisErrorBase.js +15 -0
- package/dist/domain/analysisErrorCore.js +59 -5
- package/dist/domain/analysisErrorPresentation.js +29 -1
- package/dist/domain/analysisErrorProjection.js +52 -2
- package/dist/domain/analysisSnapshot.js +166 -2
- package/dist/domain/apple/dyldPaths.js +81 -0
- package/dist/domain/apple/dylibResolution.js +367 -0
- package/dist/domain/apple/dylibResolutionFindings.js +75 -0
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/browserObservation.js +1 -1
- package/dist/domain/browserObservationSchemas.js +13 -0
- package/dist/domain/browserScenarioValues.js +9 -2
- package/dist/domain/callPathSchemas.js +1 -1
- package/dist/domain/canonicalDigest.js +13 -1
- package/dist/domain/changedBehavior.js +3 -3
- package/dist/domain/comparisonStatus.js +2 -30
- package/dist/domain/conformanceTrustGate.js +0 -16
- package/dist/domain/evidence.js +17 -5
- package/dist/domain/evm/evmInterface.js +63 -0
- package/dist/domain/explicitSensitiveFailure.js +92 -0
- package/dist/domain/explicitSensitiveValues.js +10 -0
- package/dist/domain/firmware/firmwareAnalysis.js +8 -1
- package/dist/domain/javascript/electronActiveObservation.js +9 -4
- package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
- package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
- package/dist/domain/javascript/javascriptSemanticGraph.js +21 -5
- package/dist/domain/jsonValue.js +4 -0
- package/dist/domain/localPath.js +2 -0
- package/dist/domain/native/binaryLayout.js +357 -0
- package/dist/domain/native/nativeCallObservation.js +164 -0
- package/dist/domain/native/objcSwiftMetadata.js +0 -39
- package/dist/domain/native/recordedCrash.js +266 -0
- package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
- package/dist/domain/{processCapture.js → process/processCapture.js} +139 -2
- package/dist/domain/{processCaptureExample.js → process/processCaptureExample.js} +5 -0
- package/dist/domain/process/processCaptureParsing.js +54 -0
- package/dist/domain/{processCaptureValidation.js → process/processCaptureValidation.js} +18 -2
- package/dist/domain/{processComparison.js → process/processComparison.js} +1 -1
- package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
- package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
- package/dist/domain/providerSelectionError.js +4 -2
- package/dist/domain/reconstructionVerification.js +3 -3
- package/dist/domain/reconstructionVerificationSchemas.js +1 -1
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +3 -3
- package/dist/domain/webCaptureDiff.js +1 -0
- package/dist/domain/webNetworkCapture.js +118 -0
- package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
- package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
- package/dist/dotnet/ManagedMemberInspector.js +4 -2
- package/dist/dotnet/ManagedMemberInspectorCore.js +38 -32
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +23 -7
- package/dist/dotnet/ManagedMemberRows.js +14 -3
- package/dist/dotnet/ManagedMetadataHeaps.js +20 -2
- package/dist/dotnet/ManagedMetadataInventory.js +38 -28
- package/dist/dotnet/ManagedMetadataInventoryRows.js +24 -10
- package/dist/dotnet/ManagedMethodBodyReader.js +7 -1
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +15 -3
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +3 -1
- package/dist/dotnet/ManagedPeReader.js +11 -0
- package/dist/evm/EvmBytecodeCarrier.js +21 -0
- package/dist/evm/EvmWorkerLimits.js +40 -0
- package/dist/evm/EvmoleFailures.js +126 -0
- package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
- package/dist/evm/EvmoleInterfaceProvider.js +273 -0
- package/dist/evm/EvmoleInterfaceWorker.js +87 -0
- package/dist/evm/EvmoleRelease.js +16 -0
- package/dist/firmware/FirmwareCommand.js +1 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraLauncher.js +1 -0
- package/dist/ghidra/GhidraProvider.js +2 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +1 -1
- package/dist/hopper/BridgeLauncher.js +2 -0
- package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
- package/dist/javascript/recovery/WakaruCommand.js +3 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +1 -0
- package/dist/native/CommandRunner.js +2 -1
- package/dist/native/LldbCallTracer.js +278 -0
- package/dist/native/NativeCallObservation.js +135 -0
- package/dist/native/NativeMacOSProvider.js +19 -3
- package/dist/native/NativeMacOSProviderMetadata.js +8 -3
- package/dist/native/pwndbg/PwndbgCoreContext.js +160 -0
- package/dist/native/pwntools/PwntoolsDecoder.js +203 -0
- package/dist/native/pwntools/PwntoolsFailures.js +180 -0
- package/dist/native/pwntools/PwntoolsLayoutProvider.js +36 -0
- package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +75 -0
- package/dist/native/pwntools/PwntoolsRelease.js +19 -0
- package/dist/native/pwntools/PwntoolsResourceLimits.js +76 -0
- package/dist/native/pwntools/RecordedCrashSourceBindings.js +46 -0
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +101 -0
- package/dist/process/DarwinProcessRunTokenReader.js +294 -0
- package/dist/process/OwnedCommand.js +113 -0
- package/dist/process/ProcessOwnership.js +263 -33
- package/dist/process/ProcessOwnershipObservation.js +161 -24
- package/dist/process/ProviderProcess.js +30 -3
- package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
- package/dist/{application → process/capture}/ProcessCaptureError.js +17 -1
- package/dist/process/capture/ProcessCaptureLifecycle.js +615 -0
- package/dist/{application → process/capture}/ProcessHarness.js +195 -29
- package/dist/{application → process/capture}/ProcessSampling.js +2 -2
- package/dist/server/createServer.js +22 -0
- package/dist/server/promptCompletion.js +10 -3
- package/dist/server/registerBinaryDiagnosticsTools.js +17 -0
- package/dist/server/registerEvidenceTools.js +1 -1
- package/dist/server/registerEvmTools.js +17 -0
- package/dist/server/registerProcessComparisonTool.js +1 -1
- package/dist/server/registerRecordedCrashTools.js +17 -0
- package/dist/server/registerSessionTools.js +2 -2
- package/dist/server/registerWebNetworkCaptureTool.js +28 -0
- package/dist/server/sessionAvailabilityPolicy.js +3 -0
- package/dist/server/sessionToolPolicies.js +1 -1
- package/dist/server/toolResult.js +1 -1
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +37 -9
- package/scripts/rea.mjs +11 -3
- package/skills/reverse-engineer-anything/SKILL.md +23 -3
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +29 -0
- package/third_party/README.md +60 -0
- package/third_party/evmole/LICENSE +21 -0
- package/third_party/evmole/README.md +22 -0
- package/third_party/pwndbg/LICENSE.md +21 -0
- package/third_party/pwndbg/README.md +23 -0
- package/third_party/pwntools/README.md +40 -0
- package/dist/application/AuthorizedArtifactInventory.js +0 -7
- package/dist/application/ProcessCaptureLifecycle.js +0 -299
- package/dist/application/StoreFileLock.js +0 -124
- package/dist/contracts/processCaptureExample.js +0 -2
- package/dist/domain/bytecodeProvider.js +0 -178
- package/dist/domain/customProtocolCapture.js +0 -137
- package/dist/domain/eventProcessTree.js +0 -225
- package/dist/domain/mobileApplicationInvestigation.js +0 -159
- package/dist/domain/packageAnalysis.js +0 -123
- package/dist/domain/peInspection.js +0 -197
- package/dist/domain/processCaptureParsing.js +0 -21
- package/dist/domain/protocolCapture.js +0 -217
- package/dist/domain/runtimeIdentification.js +0 -212
- package/dist/generatedMcpToolCatalog.js +0 -37
- /package/dist/application/{ArtifactExtractionDestination.js → artifacts/ArtifactExtractionDestination.js} +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/policy.js +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/types.js +0 -0
- /package/dist/domain/{processEvidenceProvider.js → process/processEvidenceProvider.js} +0 -0
- /package/dist/domain/{processScenario.js → process/processScenario.js} +0 -0
- /package/dist/domain/{processTraceComparison.js → process/processTraceComparison.js} +0 -0
- /package/dist/domain/{processTraceDimensionProjection.js → process/processTraceDimensionProjection.js} +0 -0
- /package/dist/domain/{processTraceEvaluation.js → process/processTraceEvaluation.js} +0 -0
- /package/dist/{application → process/capture}/FilesystemSnapshot.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureEnvironment.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureJournal.js +0 -0
- /package/dist/{application → process/capture}/ProcessFilesystemEffects.js +0 -0
- /package/dist/{application → process/capture}/ProcessNormalization.js +0 -0
- /package/dist/{application → process/capture}/ProcessScenarioRuntimeValidation.js +0 -0
- /package/dist/{application → process/capture}/ProcessTimer.js +0 -0
- /package/dist/{application → process/capture}/TerminalRenderer.js +0 -0
|
@@ -1,32 +1,60 @@
|
|
|
1
|
-
import { parseProcessCapture } from "
|
|
2
|
-
import { err, ok } from "
|
|
3
|
-
import { AnalysisCapabilityUnavailableError } from "
|
|
4
|
-
import {} from "
|
|
5
|
-
import { ProcessCaptureError, processCaptureCancelled, } from "./ProcessCaptureError.js";
|
|
1
|
+
import { parseProcessCapture } from "../../domain/process/processCapture.js";
|
|
2
|
+
import { err, ok } from "../../domain/result.js";
|
|
3
|
+
import { AnalysisCapabilityUnavailableError } from "../../domain/analysisErrorCore.js";
|
|
4
|
+
import {} from "../../domain/analysisErrorBase.js";
|
|
5
|
+
import { describeProcessCaptureExecutionFailure, ProcessCaptureError, processCaptureCancelled, } from "./ProcessCaptureError.js";
|
|
6
6
|
export { ProcessCaptureError } from "./ProcessCaptureError.js";
|
|
7
7
|
import { startProcessSampler } from "./ProcessSampling.js";
|
|
8
8
|
import { snapshotRoots } from "./FilesystemSnapshot.js";
|
|
9
9
|
import { TerminalRenderer } from "./TerminalRenderer.js";
|
|
10
10
|
import { normalizeProcessText } from "./ProcessNormalization.js";
|
|
11
|
-
import { selectCapturedProcessGroupIds } from "../
|
|
12
|
-
import { awaitTerminalExit, buildCaptureResult, captureTerminalFrames, createRunManifest, observeSettlement, prepareProcessCapture, releaseProcessResources, resolveProcessResult, settleProcessCaptureJournal, } from "./ProcessCaptureLifecycle.js";
|
|
11
|
+
import { selectCapturedProcessGroupIds } from "../ProcessOwnershipProcessTree.js";
|
|
12
|
+
import { awaitTerminalExit, buildCaptureResult, cleanupReportFailure, captureTerminalFrames, createProcessCaptureObservationBuffer, createRunManifest, observeLaunchedExecutable, observeSelectedExecutable, observeSettlement, prepareProcessCapture, releaseProcessResources, resolveProcessResult, settleProcessCaptureJournal, } from "./ProcessCaptureLifecycle.js";
|
|
13
13
|
import { assertNotCancelled, resolveProcessScenarioRuntimePaths, } from "./ProcessScenarioRuntimeValidation.js";
|
|
14
14
|
import { createProcessCaptureJournal, scheduleScenarioInteractions, } from "./ProcessCaptureJournal.js";
|
|
15
15
|
import { makeProcessCaptureEnvironment } from "./ProcessCaptureEnvironment.js";
|
|
16
16
|
import { classifyFilesystemEffects } from "./ProcessFilesystemEffects.js";
|
|
17
17
|
import { processCaptureOwnershipUnavailableReason } from "./ProcessCaptureCapability.js";
|
|
18
|
+
import { DarwinProcessOwnershipInspectionError } from "../DarwinProcessRunTokenReader.js";
|
|
18
19
|
export { probeProcessCaptureCapability } from "./ProcessCaptureCapability.js";
|
|
19
20
|
const cleanupFailedStartup = async (options) => {
|
|
21
|
+
const sampledProcessGroupIds = options.terminal !== undefined &&
|
|
22
|
+
options.observations?.process_samples.state === "available"
|
|
23
|
+
? selectCapturedProcessGroupIds(options.terminal.pid, options.observations.process_samples.value).filter((groupId) => groupId !== options.terminal?.pid)
|
|
24
|
+
: undefined;
|
|
20
25
|
options.terminal?.kill("SIGKILL");
|
|
26
|
+
if (options.observations !== undefined && options.renderer !== undefined) {
|
|
27
|
+
try {
|
|
28
|
+
options.observations.rendered_frames = {
|
|
29
|
+
state: "available",
|
|
30
|
+
value: await options.renderer.frames(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (cause) {
|
|
34
|
+
options.observations.rendered_frames = {
|
|
35
|
+
state: "unavailable",
|
|
36
|
+
reason: `Rendered terminal frame collection failed: ${cause instanceof Error ? cause.message : "unknown failure"}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
21
40
|
const cleanupFailure = await releaseProcessResources({
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
timers: options.timers,
|
|
42
|
+
terminal: options.terminal,
|
|
43
|
+
renderer: options.renderer,
|
|
44
|
+
runId: options.runId,
|
|
45
|
+
captureBaseline: options.captureBaseline,
|
|
46
|
+
...(sampledProcessGroupIds === undefined ? {} : { sampledProcessGroupIds }),
|
|
47
|
+
temporaryRoot: options.temporaryRoot,
|
|
48
|
+
...(options.cleanupHost === undefined ? {} : { host: options.cleanupHost }),
|
|
24
49
|
});
|
|
25
|
-
if (cleanupFailure !== undefined)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
if (cleanupReportFailure(cleanupFailure) !== undefined) {
|
|
51
|
+
resolveProcessResult(undefined, options.cause, cleanupFailure, options.observations, {
|
|
52
|
+
scenario: options.scenario,
|
|
53
|
+
...(options.terminal === undefined
|
|
54
|
+
? {}
|
|
55
|
+
: { rootPid: options.terminal.pid }),
|
|
29
56
|
});
|
|
57
|
+
}
|
|
30
58
|
throw options.cause;
|
|
31
59
|
};
|
|
32
60
|
const createTerminalRenderer = (scenario, temporaryRoot, terminalPid, recordEvent) => new TerminalRenderer({
|
|
@@ -43,6 +71,7 @@ const startCaptureRuntime = async (options) => {
|
|
|
43
71
|
let terminal;
|
|
44
72
|
try {
|
|
45
73
|
const { spawn } = await import("@lydell/node-pty");
|
|
74
|
+
const selectedExecutable = await observeSelectedExecutable(scenario.executable, options.signal);
|
|
46
75
|
const startedAt = new Date();
|
|
47
76
|
const started = Date.now();
|
|
48
77
|
let lastOutput = started;
|
|
@@ -54,6 +83,12 @@ const startCaptureRuntime = async (options) => {
|
|
|
54
83
|
rows: scenario.terminal.rows,
|
|
55
84
|
name: "xterm-256color",
|
|
56
85
|
});
|
|
86
|
+
options.onSpawn(terminal.pid);
|
|
87
|
+
options.observationBuffer.target_pid = {
|
|
88
|
+
state: "available",
|
|
89
|
+
value: scenario.normalization.pids ? 1 : terminal.pid,
|
|
90
|
+
};
|
|
91
|
+
const executableIdentity = observeLaunchedExecutable(scenario.executable, selectedExecutable);
|
|
57
92
|
const framesTruncated = captureTerminalFrames({
|
|
58
93
|
...options,
|
|
59
94
|
terminal,
|
|
@@ -80,6 +115,7 @@ const startCaptureRuntime = async (options) => {
|
|
|
80
115
|
terminal,
|
|
81
116
|
started,
|
|
82
117
|
startedAt,
|
|
118
|
+
executableIdentity,
|
|
83
119
|
lastOutput: () => lastOutput,
|
|
84
120
|
framesTruncated,
|
|
85
121
|
stopSampler,
|
|
@@ -92,22 +128,32 @@ const startCaptureRuntime = async (options) => {
|
|
|
92
128
|
terminal,
|
|
93
129
|
renderer,
|
|
94
130
|
runId: options.runId,
|
|
131
|
+
captureBaseline: options.ownershipBaseline,
|
|
132
|
+
scenario,
|
|
133
|
+
...(options.cleanupHost === undefined
|
|
134
|
+
? {}
|
|
135
|
+
: { cleanupHost: options.cleanupHost }),
|
|
136
|
+
observations: options.observationBuffer,
|
|
95
137
|
temporaryRoot: options.temporaryRoot,
|
|
96
138
|
});
|
|
97
139
|
}
|
|
98
140
|
};
|
|
99
141
|
const finishProcessRun = async (options) => {
|
|
100
142
|
await options.stopSampler();
|
|
101
|
-
const
|
|
143
|
+
const sampledProcessGroupIds = options.runtime === undefined
|
|
144
|
+
? undefined
|
|
145
|
+
: selectCapturedProcessGroupIds(options.runtime.terminal.pid, options.samples).filter((groupId) => groupId !== options.runtime?.terminal.pid);
|
|
146
|
+
const cleanup = await releaseProcessResources({
|
|
102
147
|
timers: options.timers,
|
|
103
148
|
terminal: options.runtime?.terminal,
|
|
104
149
|
renderer: options.runtime?.renderer,
|
|
105
150
|
runId: options.runId,
|
|
151
|
+
captureBaseline: options.captureBaseline,
|
|
152
|
+
...(sampledProcessGroupIds === undefined ? {} : { sampledProcessGroupIds }),
|
|
106
153
|
temporaryRoot: options.temporaryRoot,
|
|
107
|
-
|
|
108
|
-
? []
|
|
109
|
-
: selectCapturedProcessGroupIds(options.runtime.terminal.pid, options.samples),
|
|
154
|
+
...(options.cleanupHost === undefined ? {} : { host: options.cleanupHost }),
|
|
110
155
|
});
|
|
156
|
+
const cleanupFailure = cleanupReportFailure(cleanup);
|
|
111
157
|
let { capture, executionFailure } = options;
|
|
112
158
|
let verifiedCapture;
|
|
113
159
|
if (capture !== undefined && cleanupFailure === undefined) {
|
|
@@ -129,11 +175,18 @@ const finishProcessRun = async (options) => {
|
|
|
129
175
|
executionFailure = new ProcessCaptureError(`process capture validation failed${cause instanceof Error ? `: ${cause.message}` : ""}`, { cause });
|
|
130
176
|
}
|
|
131
177
|
}
|
|
132
|
-
|
|
178
|
+
const rootPid = options.runtime?.terminal.pid ?? options.rootPid;
|
|
179
|
+
const partialContext = rootPid === undefined
|
|
180
|
+
? { scenario: options.scenario }
|
|
181
|
+
: { scenario: options.scenario, rootPid };
|
|
182
|
+
return resolveProcessResult(cleanupFailure === undefined ? verifiedCapture : capture, executionFailure, cleanup, options.observations, partialContext);
|
|
133
183
|
};
|
|
134
|
-
|
|
184
|
+
/** Preserve typed process-inspection preflight failures at the capture boundary. */
|
|
185
|
+
export const normalizeCaptureFailure = (cause, signal) => {
|
|
135
186
|
if (cause instanceof ProcessCaptureError)
|
|
136
187
|
return cause;
|
|
188
|
+
if (cause instanceof DarwinProcessOwnershipInspectionError)
|
|
189
|
+
return new ProcessCaptureError(cause.message, { cause });
|
|
137
190
|
if (signal?.aborted === true &&
|
|
138
191
|
(cause === signal.reason ||
|
|
139
192
|
(cause instanceof Error && cause.name === "AbortError")))
|
|
@@ -141,17 +194,66 @@ const normalizeCaptureFailure = (cause, signal) => {
|
|
|
141
194
|
return cause;
|
|
142
195
|
};
|
|
143
196
|
const completeCapture = async (options) => {
|
|
197
|
+
const unavailableReason = (stage, cause) => `${stage} failed: ${cause instanceof Error ? cause.message : "unknown failure"}`;
|
|
144
198
|
const { runtime, scenario } = options;
|
|
145
199
|
const { reason } = options.exit;
|
|
146
200
|
if (reason === "cancelled")
|
|
147
201
|
throw processCaptureCancelled();
|
|
148
|
-
|
|
202
|
+
let settlement;
|
|
203
|
+
try {
|
|
204
|
+
settlement = await observeSettlement(options.runId, selectCapturedProcessGroupIds(runtime.terminal.pid, options.samples), scenario.settle_ms, options.recordEvent, options.hostPlatform);
|
|
205
|
+
}
|
|
206
|
+
catch (cause) {
|
|
207
|
+
options.observationBuffer.settlement = {
|
|
208
|
+
state: "unavailable",
|
|
209
|
+
reason: unavailableReason("Process settlement observation", cause),
|
|
210
|
+
};
|
|
211
|
+
throw cause;
|
|
212
|
+
}
|
|
213
|
+
options.observationBuffer.settlement = {
|
|
214
|
+
state: "available",
|
|
215
|
+
value: settlement,
|
|
216
|
+
};
|
|
149
217
|
const samplingPartial = (await runtime.stopSampler()).partial;
|
|
150
218
|
await settleProcessCaptureJournal(options.eventJournal);
|
|
151
219
|
assertNotCancelled(options.signal);
|
|
152
|
-
|
|
220
|
+
let after;
|
|
221
|
+
try {
|
|
222
|
+
after = await options.captureSnapshot(scenario, options.signal);
|
|
223
|
+
}
|
|
224
|
+
catch (cause) {
|
|
225
|
+
options.observationBuffer.filesystem_snapshots = {
|
|
226
|
+
...options.observationBuffer.filesystem_snapshots,
|
|
227
|
+
after: {
|
|
228
|
+
state: "unavailable",
|
|
229
|
+
reason: unavailableReason("Final filesystem snapshot", cause),
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
throw cause;
|
|
233
|
+
}
|
|
234
|
+
options.observationBuffer.filesystem_snapshots = {
|
|
235
|
+
...options.observationBuffer.filesystem_snapshots,
|
|
236
|
+
after: {
|
|
237
|
+
state: "available",
|
|
238
|
+
value: { files: after.files, truncated: after.truncated },
|
|
239
|
+
},
|
|
240
|
+
};
|
|
153
241
|
options.recordEvent("filesystem_checkpoints", 1);
|
|
154
|
-
|
|
242
|
+
let renderedFrames;
|
|
243
|
+
try {
|
|
244
|
+
renderedFrames = await runtime.renderer.frames();
|
|
245
|
+
}
|
|
246
|
+
catch (cause) {
|
|
247
|
+
options.observationBuffer.rendered_frames = {
|
|
248
|
+
state: "unavailable",
|
|
249
|
+
reason: unavailableReason("Rendered terminal frame collection", cause),
|
|
250
|
+
};
|
|
251
|
+
throw cause;
|
|
252
|
+
}
|
|
253
|
+
options.observationBuffer.rendered_frames = {
|
|
254
|
+
state: "available",
|
|
255
|
+
value: renderedFrames,
|
|
256
|
+
};
|
|
155
257
|
const checkpoints = [
|
|
156
258
|
{
|
|
157
259
|
name: "before",
|
|
@@ -168,7 +270,18 @@ const completeCapture = async (options) => {
|
|
|
168
270
|
truncated: after.truncated,
|
|
169
271
|
},
|
|
170
272
|
];
|
|
171
|
-
|
|
273
|
+
let manifest;
|
|
274
|
+
try {
|
|
275
|
+
manifest = await createRunManifest(scenario, runtime.startedAt, new Date(), runtime.executableIdentity, { platform: options.hostPlatform, architecture: process.arch });
|
|
276
|
+
}
|
|
277
|
+
catch (cause) {
|
|
278
|
+
options.observationBuffer.manifest = {
|
|
279
|
+
state: "unavailable",
|
|
280
|
+
reason: unavailableReason("Capture manifest creation", cause),
|
|
281
|
+
};
|
|
282
|
+
throw cause;
|
|
283
|
+
}
|
|
284
|
+
options.observationBuffer.manifest = { state: "available", value: manifest };
|
|
172
285
|
const truncated = options.initiallyTruncated ||
|
|
173
286
|
after.truncated ||
|
|
174
287
|
runtime.framesTruncated() ||
|
|
@@ -194,19 +307,27 @@ const completeCapture = async (options) => {
|
|
|
194
307
|
});
|
|
195
308
|
};
|
|
196
309
|
/** Execute one caller-selected scenario and return bounded observations. */
|
|
197
|
-
const runProcessScenario = async (scenario, signal, hostEnvironment = process.env, hostPlatform = process.platform, captureSnapshot = snapshotRoots) => {
|
|
198
|
-
const { temporaryRoot, runId, before } = await prepareProcessCapture(scenario, signal, captureSnapshot);
|
|
310
|
+
const runProcessScenario = async (scenario, signal, hostEnvironment = process.env, hostPlatform = process.platform, captureSnapshot = snapshotRoots, cleanupHost) => {
|
|
311
|
+
const { temporaryRoot, runId, ownershipBaseline, before } = await prepareProcessCapture(scenario, signal, captureSnapshot);
|
|
199
312
|
const frames = [];
|
|
200
313
|
const samples = [];
|
|
314
|
+
const interactions = [];
|
|
201
315
|
const journal = createProcessCaptureJournal();
|
|
202
316
|
const { entries: eventJournal, recordEvent } = journal;
|
|
203
317
|
recordEvent("filesystem_checkpoints", 0);
|
|
318
|
+
const observations = createProcessCaptureObservationBuffer({
|
|
319
|
+
frames,
|
|
320
|
+
interactions,
|
|
321
|
+
samples,
|
|
322
|
+
eventJournal,
|
|
323
|
+
before,
|
|
324
|
+
});
|
|
204
325
|
let runtime;
|
|
326
|
+
let actualRootPid;
|
|
205
327
|
const timers = new Set();
|
|
206
328
|
let capture;
|
|
207
329
|
let executionFailure;
|
|
208
330
|
let stopSampler = async () => ({ partial: false });
|
|
209
|
-
const interactions = [];
|
|
210
331
|
const dispatchedEventIndexes = new Set();
|
|
211
332
|
try {
|
|
212
333
|
runtime = await startCaptureRuntime({
|
|
@@ -214,6 +335,12 @@ const runProcessScenario = async (scenario, signal, hostEnvironment = process.en
|
|
|
214
335
|
hostEnvironment,
|
|
215
336
|
temporaryRoot,
|
|
216
337
|
runId,
|
|
338
|
+
ownershipBaseline,
|
|
339
|
+
...(cleanupHost === undefined ? {} : { cleanupHost }),
|
|
340
|
+
observationBuffer: observations,
|
|
341
|
+
onSpawn: (pid) => {
|
|
342
|
+
actualRootPid = pid;
|
|
343
|
+
},
|
|
217
344
|
frames,
|
|
218
345
|
samples,
|
|
219
346
|
interactions,
|
|
@@ -234,6 +361,14 @@ const runProcessScenario = async (scenario, signal, hostEnvironment = process.en
|
|
|
234
361
|
dispatchedEventIndexes,
|
|
235
362
|
recordEvent,
|
|
236
363
|
});
|
|
364
|
+
observations.exit = {
|
|
365
|
+
state: "available",
|
|
366
|
+
value: {
|
|
367
|
+
code: exit.reason === "exited" && exit.exitCode >= 0 ? exit.exitCode : null,
|
|
368
|
+
signal: exit.signal ?? null,
|
|
369
|
+
reason: exit.reason,
|
|
370
|
+
},
|
|
371
|
+
};
|
|
237
372
|
capture = await completeCapture({
|
|
238
373
|
scenario,
|
|
239
374
|
hostPlatform,
|
|
@@ -247,6 +382,7 @@ const runProcessScenario = async (scenario, signal, hostEnvironment = process.en
|
|
|
247
382
|
exit,
|
|
248
383
|
initiallyTruncated: before.truncated,
|
|
249
384
|
eventJournal,
|
|
385
|
+
observationBuffer: observations,
|
|
250
386
|
recordEvent,
|
|
251
387
|
captureSnapshot,
|
|
252
388
|
...(signal === undefined ? {} : { signal }),
|
|
@@ -255,32 +391,62 @@ const runProcessScenario = async (scenario, signal, hostEnvironment = process.en
|
|
|
255
391
|
catch (cause) {
|
|
256
392
|
runtime?.terminal.kill("SIGKILL");
|
|
257
393
|
executionFailure = normalizeCaptureFailure(cause, signal);
|
|
394
|
+
if (runtime !== undefined &&
|
|
395
|
+
observations.rendered_frames.state === "unavailable" &&
|
|
396
|
+
observations.rendered_frames.reason.startsWith("Rendered terminal frames were not collected")) {
|
|
397
|
+
try {
|
|
398
|
+
observations.rendered_frames = {
|
|
399
|
+
state: "available",
|
|
400
|
+
value: await runtime.renderer.frames(),
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
catch (renderCause) {
|
|
404
|
+
const renderFailure = renderCause instanceof Error
|
|
405
|
+
? renderCause.message
|
|
406
|
+
: "unknown failure";
|
|
407
|
+
observations.rendered_frames = {
|
|
408
|
+
state: "unavailable",
|
|
409
|
+
reason: `Rendered terminal frame collection failed: ${renderFailure}`,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
}
|
|
258
413
|
}
|
|
259
414
|
return finishProcessRun({
|
|
260
415
|
runtime,
|
|
261
416
|
timers,
|
|
262
417
|
runId,
|
|
418
|
+
captureBaseline: ownershipBaseline,
|
|
419
|
+
...(cleanupHost === undefined ? {} : { cleanupHost }),
|
|
263
420
|
temporaryRoot,
|
|
421
|
+
scenario,
|
|
264
422
|
samples,
|
|
265
423
|
stopSampler,
|
|
266
424
|
capture,
|
|
267
425
|
executionFailure,
|
|
426
|
+
observations,
|
|
427
|
+
...(actualRootPid === undefined ? {} : { rootPid: actualRootPid }),
|
|
268
428
|
});
|
|
269
429
|
};
|
|
270
430
|
/** Execute one scenario through a typed expected-failure channel. */
|
|
271
|
-
export const captureProcessScenario = async (scenario, signal, platform = process.platform, environment = process.env, captureSnapshot = snapshotRoots) => {
|
|
431
|
+
export const captureProcessScenario = async (scenario, signal, platform = process.platform, environment = process.env, captureSnapshot = snapshotRoots, cleanupHost) => {
|
|
272
432
|
const ownershipReason = processCaptureOwnershipUnavailableReason(platform);
|
|
273
433
|
if (ownershipReason !== undefined)
|
|
274
434
|
return err(new AnalysisCapabilityUnavailableError("rea-process", "capture_process_scenario", ownershipReason, { userMessage: ownershipReason }));
|
|
275
435
|
try {
|
|
276
436
|
assertNotCancelled(signal);
|
|
277
437
|
const resolvedScenario = await resolveProcessScenarioRuntimePaths(scenario, environment);
|
|
278
|
-
return ok(await runProcessScenario(resolvedScenario, signal, environment, platform, captureSnapshot));
|
|
438
|
+
return ok(await runProcessScenario(resolvedScenario, signal, environment, platform, captureSnapshot, cleanupHost));
|
|
279
439
|
}
|
|
280
440
|
catch (cause) {
|
|
281
441
|
const failure = normalizeCaptureFailure(cause, signal);
|
|
442
|
+
const executionFailureReason = describeProcessCaptureExecutionFailure(cause);
|
|
282
443
|
return err(failure instanceof ProcessCaptureError
|
|
283
444
|
? failure
|
|
284
|
-
: new ProcessCaptureError("process capture failed", {
|
|
445
|
+
: new ProcessCaptureError("process capture failed", {
|
|
446
|
+
cause,
|
|
447
|
+
...(executionFailureReason === undefined
|
|
448
|
+
? {}
|
|
449
|
+
: { executionFailure: executionFailureReason }),
|
|
450
|
+
}));
|
|
285
451
|
}
|
|
286
452
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile, readdir } from "node:fs/promises";
|
|
2
|
-
import { execFileOutput } from "../
|
|
3
|
-
import { readProcessRunId } from "../
|
|
2
|
+
import { execFileOutput } from "../ExecFileOutput.js";
|
|
3
|
+
import { readProcessRunId } from "../ProcessOwnership.js";
|
|
4
4
|
const PROC_READ_CONCURRENCY = 64;
|
|
5
5
|
/** Prove that forkpty completed session setup and installed the run token. */
|
|
6
6
|
export const isInitializedPtyRoot = (options) => {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { createEvmInterfaceService } from "../composition/evm.js";
|
|
2
|
+
import { registerEvmTools } from "./registerEvmTools.js";
|
|
3
|
+
import { registerRecordedCrashTools } from "./registerRecordedCrashTools.js";
|
|
4
|
+
import { createRecordedCrashService } from "../composition/binaryDiagnostics.js";
|
|
5
|
+
import { registerBinaryDiagnosticsTools } from "./registerBinaryDiagnosticsTools.js";
|
|
6
|
+
import { createBinaryLayoutService } from "../composition/binaryDiagnostics.js";
|
|
1
7
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
2
8
|
import { isAbsolute } from "node:path";
|
|
3
9
|
import { PRODUCT_IDENTITY } from "../identity.js";
|
|
@@ -13,6 +19,8 @@ import { createWebSourceLocationService } from "../composition/webSourceLocation
|
|
|
13
19
|
import { registerWebSourceLocationTool } from "./registerWebSourceLocationTool.js";
|
|
14
20
|
import { createWebRuntimeService } from "../composition/webRuntime.js";
|
|
15
21
|
import { registerWebRuntimeTools } from "./registerWebRuntimeTools.js";
|
|
22
|
+
import { createWebNetworkCaptureService } from "../composition/webNetworkCaptures.js";
|
|
23
|
+
import { registerWebNetworkCaptureTool } from "./registerWebNetworkCaptureTool.js";
|
|
16
24
|
import { registerJavaScriptRecoveryTool } from "./registerJavaScriptRecoveryTool.js";
|
|
17
25
|
import { JavaScriptRecoveryService } from "../application/javascript/JavaScriptRecoveryService.js";
|
|
18
26
|
import { createJavaScriptRecoveryProvider } from "../composition/javascriptRecovery.js";
|
|
@@ -40,8 +48,18 @@ const installSessionToolAvailability = (server, session, options) => {
|
|
|
40
48
|
const policy = sessionAvailabilityPolicy(options.availabilityPolicy, {
|
|
41
49
|
optionalProviderLoadFailures: options.optionalProviderLoadFailures,
|
|
42
50
|
optionalFeatures: {
|
|
51
|
+
evmInterfaceEnabled: options.evmInterface !== undefined ||
|
|
52
|
+
(process.platform === "linux" && process.arch === "x64"),
|
|
43
53
|
webModuleResolutionEnabled: options.webModuleTrace !== undefined ||
|
|
44
54
|
isAbsolute(process.env.REA_BROWSER_EXECUTABLE ?? ""),
|
|
55
|
+
recordedCrashEnabled: options.recordedCrash !== undefined ||
|
|
56
|
+
(process.platform === "linux" &&
|
|
57
|
+
process.arch === "x64" &&
|
|
58
|
+
isAbsolute(process.env.REA_PWNTOOLS_PYTHON ?? "")),
|
|
59
|
+
binaryLayoutEnabled: options.binaryLayout !== undefined ||
|
|
60
|
+
(process.platform === "linux" &&
|
|
61
|
+
process.arch === "x64" &&
|
|
62
|
+
isAbsolute(process.env.REA_PWNTOOLS_PYTHON ?? "")),
|
|
45
63
|
firmwareInspectionEnabled: options.firmwareAnalysis !== undefined ||
|
|
46
64
|
(process.platform === "linux" &&
|
|
47
65
|
isAbsolute(process.env.REA_BINWALK_COMMAND ?? "")),
|
|
@@ -115,11 +133,15 @@ export const createServer = (analysis, session, options = {}) => {
|
|
|
115
133
|
throw result.reason;
|
|
116
134
|
};
|
|
117
135
|
registerAndroidTools(server, new AndroidAnalysisService(android), toolLogger, recordEvidence);
|
|
136
|
+
registerBinaryDiagnosticsTools(server, options.binaryLayout ?? createBinaryLayoutService(), toolLogger, recordEvidence);
|
|
137
|
+
registerEvmTools(server, options.evmInterface ?? createEvmInterfaceService(), toolLogger, recordEvidence);
|
|
138
|
+
registerRecordedCrashTools(server, options.recordedCrash ?? createRecordedCrashService(), toolLogger, recordEvidence);
|
|
118
139
|
registerFirmwareTools(server, new FirmwareAnalysisService(options.firmwareAnalysis ?? createFirmwareAnalysisProvider()), toolLogger, recordEvidence);
|
|
119
140
|
registerObservationTools(toolContext);
|
|
120
141
|
registerWebModuleTool(server, options.webModuleTrace ?? createWebModuleTraceService(), toolLogger, recordEvidence);
|
|
121
142
|
registerWebSourceLocationTool(server, options.webSourceLocation ?? createWebSourceLocationService(), toolLogger, recordEvidence);
|
|
122
143
|
registerWebRuntimeTools(server, options.webRuntime ?? createWebRuntimeService(), toolLogger, recordEvidence);
|
|
144
|
+
registerWebNetworkCaptureTool(server, options.webNetworkCapture ?? createWebNetworkCaptureService(), toolLogger, recordEvidence);
|
|
123
145
|
registerJavaScriptRecoveryTool(server, new JavaScriptRecoveryService(options.javascriptRecovery ?? createJavaScriptRecoveryProvider()), toolLogger, recordEvidence);
|
|
124
146
|
registerGuidedPrompts(server, analysis, session);
|
|
125
147
|
if (session !== undefined) {
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { uniqueSorted } from "../domain/canonicalOrdering.js";
|
|
3
3
|
import { artifactInventoryResultSchema } from "../domain/artifactGraph.js";
|
|
4
4
|
import { artifactInspectionResultSchema } from "../domain/artifactInspection.js";
|
|
5
|
-
import {
|
|
5
|
+
import { parseProcessCapture } from "../domain/process/processCapture.js";
|
|
6
6
|
const documentListSchema = z.array(z.string().min(1));
|
|
7
7
|
const providerStatusSchema = z.object({
|
|
8
8
|
providers: z.array(z.object({ id: z.string().min(1) })),
|
|
@@ -114,8 +114,15 @@ const evidenceValues = (kind, evidence) => {
|
|
|
114
114
|
const isProcessCaptureEvidence = (evidence) => {
|
|
115
115
|
if (evidence.operation !== "capture_process_scenario")
|
|
116
116
|
return false;
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
try {
|
|
118
|
+
parseProcessCapture(evidence.normalized_result);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
catch (cause) {
|
|
122
|
+
if (cause instanceof TypeError || cause instanceof z.ZodError)
|
|
123
|
+
return false;
|
|
124
|
+
throw cause;
|
|
125
|
+
}
|
|
119
126
|
};
|
|
120
127
|
const unknownCandidates = (session) => session === undefined
|
|
121
128
|
? []
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toolContract } from "../contracts/toolContracts.js";
|
|
2
|
+
import { logToolExecution } from "./toolLogging.js";
|
|
3
|
+
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
4
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
5
|
+
/** Bind offline layout inspection to its named contract and session Evidence owner. */
|
|
6
|
+
export const registerBinaryDiagnosticsTools = (server, service, logger, recordEvidence) => {
|
|
7
|
+
const contract = toolContract("inspect_binary_layout");
|
|
8
|
+
server.registerTool(contract.name, toolRegistrationOptions(contract), async (input, context) => {
|
|
9
|
+
const result = await logToolExecution(logger, contract.name, () => service.inspect(input, { signal: context.mcpReq.signal }));
|
|
10
|
+
if (!result.ok)
|
|
11
|
+
return toCallToolResult(result, contract);
|
|
12
|
+
const recorded = recordEvidence?.(result.value);
|
|
13
|
+
return recorded !== undefined && !recorded.ok
|
|
14
|
+
? toCallToolResult(recorded, contract)
|
|
15
|
+
: toCallToolResult(result, contract);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -4,7 +4,7 @@ import { mcpProgressReporter } from "./mcpProgress.js";
|
|
|
4
4
|
import { logToolExecution } from "./toolLogging.js";
|
|
5
5
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
6
6
|
import { toCallToolResult } from "./toolResult.js";
|
|
7
|
-
import { createArtifactExtractionDestination } from "../application/ArtifactExtractionDestination.js";
|
|
7
|
+
import { createArtifactExtractionDestination } from "../application/artifacts/ArtifactExtractionDestination.js";
|
|
8
8
|
/** Register provider-backed contracts that return atomic Evidence observations. */
|
|
9
9
|
export const registerEvidenceTools = (server, analysis, contracts, options) => {
|
|
10
10
|
for (const contract of contracts) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toolContract } from "../contracts/toolContracts.js";
|
|
2
|
+
import { logToolExecution } from "./toolLogging.js";
|
|
3
|
+
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
4
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
5
|
+
/** Bind the named EVM contract to shared validation and session Evidence recording. */
|
|
6
|
+
export const registerEvmTools = (server, service, logger, recordEvidence) => {
|
|
7
|
+
const contract = toolContract("inspect_evm_interface");
|
|
8
|
+
server.registerTool(contract.name, toolRegistrationOptions(contract), async (input, context) => {
|
|
9
|
+
const result = await logToolExecution(logger, contract.name, () => service.inspect(input, { signal: context.mcpReq.signal }));
|
|
10
|
+
if (!result.ok)
|
|
11
|
+
return toCallToolResult(result, contract);
|
|
12
|
+
const recorded = recordEvidence?.(result.value);
|
|
13
|
+
return recorded !== undefined && !recorded.ok
|
|
14
|
+
? toCallToolResult(recorded, contract)
|
|
15
|
+
: toCallToolResult(result, contract);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -2,7 +2,7 @@ import { toolContract } from "../contracts/toolContracts.js";
|
|
|
2
2
|
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
|
3
3
|
import { createEvidence, parseEvidence, } from "../domain/evidence.js";
|
|
4
4
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
5
|
-
import { compareProcessCaptures, parseProcessCapture, } from "../domain/processCapture.js";
|
|
5
|
+
import { compareProcessCaptures, parseProcessCapture, } from "../domain/process/processCapture.js";
|
|
6
6
|
import { err } from "../domain/result.js";
|
|
7
7
|
import { recordDerivedEvidence } from "./recordDerivedEvidence.js";
|
|
8
8
|
import { recordSessionEvidenceSources } from "./sessionEvidence.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toolContract } from "../contracts/toolContracts.js";
|
|
2
|
+
import { logToolExecution } from "./toolLogging.js";
|
|
3
|
+
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
4
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
5
|
+
/** Bind recorded crash inspection to its named contract and session Evidence owner. */
|
|
6
|
+
export const registerRecordedCrashTools = (server, service, logger, recordEvidence) => {
|
|
7
|
+
const contract = toolContract("inspect_recorded_crash");
|
|
8
|
+
server.registerTool(contract.name, toolRegistrationOptions(contract), async (input, context) => {
|
|
9
|
+
const result = await logToolExecution(logger, contract.name, () => service.inspect(input, { signal: context.mcpReq.signal }));
|
|
10
|
+
if (!result.ok)
|
|
11
|
+
return toCallToolResult(result, contract);
|
|
12
|
+
const recorded = recordEvidence?.(result.value);
|
|
13
|
+
return recorded !== undefined && !recorded.ok
|
|
14
|
+
? toCallToolResult(recorded, contract)
|
|
15
|
+
: toCallToolResult(result, contract);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { getNavigationContext, inspectAddressContext, } from "../application/AnalysisContextQueries.js";
|
|
3
3
|
import { readAnalysisSnapshot } from "../application/binary/AnalysisSnapshotFiles.js";
|
|
4
|
-
import { createProcessCaptureEvidence } from "../application/ProcessEvidence.js";
|
|
5
|
-
import { captureProcessScenario } from "../
|
|
4
|
+
import { createProcessCaptureEvidence } from "../application/process/ProcessEvidence.js";
|
|
5
|
+
import { captureProcessScenario } from "../process/capture/ProcessHarness.js";
|
|
6
6
|
import { toolContract } from "../contracts/toolContracts.js";
|
|
7
7
|
import { UnknownRegistryError } from "../domain/unknownRegistryError.js";
|
|
8
8
|
import {} from "../domain/analysisErrorBase.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { toolContract } from "../contracts/toolContracts.js";
|
|
2
|
+
import { logToolExecution } from "./toolLogging.js";
|
|
3
|
+
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
4
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
5
|
+
/** Bind historical inspection to its named contract and caller-owned Evidence writer. */
|
|
6
|
+
export const registerWebNetworkCaptureTool = (server, service, logger, recordEvidence) => {
|
|
7
|
+
const contract = toolContract("inspect_web_network_capture");
|
|
8
|
+
const registration = toolRegistrationOptions(contract);
|
|
9
|
+
// Keep the exact advertised contract; the shared service validates raw input
|
|
10
|
+
// before effects so caller-declared sensitivity also covers invalid arguments.
|
|
11
|
+
// SDK pre-validation otherwise emits unprojected issue paths as plain text.
|
|
12
|
+
const inputSchema = {
|
|
13
|
+
"~standard": {
|
|
14
|
+
...registration.inputSchema["~standard"],
|
|
15
|
+
vendor: "rea-application",
|
|
16
|
+
validate: (value) => ({ value }),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
server.registerTool(contract.name, { ...registration, inputSchema }, async (input, context) => {
|
|
20
|
+
const result = await logToolExecution(logger, contract.name, () => service.inspect(input, { signal: context.mcpReq.signal }));
|
|
21
|
+
if (!result.ok)
|
|
22
|
+
return toCallToolResult(result, contract);
|
|
23
|
+
const recorded = recordEvidence?.(result.value);
|
|
24
|
+
return recorded !== undefined && !recorded.ok
|
|
25
|
+
? toCallToolResult(recorded, contract)
|
|
26
|
+
: toCallToolResult(result, contract);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
@@ -3,7 +3,10 @@ import { platform } from "node:process";
|
|
|
3
3
|
export const sessionAvailabilityPolicy = (configured, defaults) => {
|
|
4
4
|
const policy = configured ??
|
|
5
5
|
(() => ({
|
|
6
|
+
evmInterfaceEnabled: defaults.optionalFeatures?.evmInterfaceEnabled ?? false,
|
|
6
7
|
processCaptureEnabled: platform !== "win32",
|
|
8
|
+
recordedCrashEnabled: defaults.optionalFeatures?.recordedCrashEnabled ?? false,
|
|
9
|
+
binaryLayoutEnabled: defaults.optionalFeatures?.binaryLayoutEnabled ?? false,
|
|
7
10
|
firmwareInspectionEnabled: defaults.optionalFeatures?.firmwareInspectionEnabled ?? false,
|
|
8
11
|
firmwareExtractionEnabled: defaults.optionalFeatures?.firmwareExtractionEnabled ?? false,
|
|
9
12
|
androidAnalysisEnabled: defaults.optionalFeatures?.androidAnalysisEnabled ?? false,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { PROCESS_PROVIDER } from "../application/ProcessEvidence.js";
|
|
1
|
+
export { PROCESS_PROVIDER } from "../application/process/ProcessEvidence.js";
|
|
2
2
|
export { ARTIFACT_COMPARISON_PROVIDER, BUNDLE_COMPARISON_PROVIDER, CALL_PATH_PROVIDER, CHANGED_BEHAVIOR_PROVIDER, FUNCTION_COMPARISON_PROVIDER, RECONSTRUCTION_PROVIDER, STATIC_RUNTIME_PROVIDER, } from "../application/InvestigationProviders.js";
|
|
@@ -3,7 +3,7 @@ import {} from "../domain/analysisErrorBase.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Serialize an application result as MCP text and structured content.
|
|
5
5
|
* Shared error projection preserves actionable local diagnostics while omitting
|
|
6
|
-
* raw
|
|
6
|
+
* raw cause objects; explicitly retained bounded command output stays visible.
|
|
7
7
|
*/
|
|
8
8
|
export const toCallToolResult = (result, contract) => result.ok ? successResult(result.value, contract) : errorResult(result.error);
|
|
9
9
|
const errorResult = (error) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"packageVersion": "
|
|
2
|
+
"packageVersion": "6.0.0",
|
|
3
3
|
"platform": "win32",
|
|
4
4
|
"architecture": "x64",
|
|
5
5
|
"abiVersion": 1,
|
|
6
6
|
"nodeApiVersion": 8,
|
|
7
7
|
"artifact": "rea-windows-x64.node",
|
|
8
|
-
"artifactSha256": "
|
|
8
|
+
"artifactSha256": "9914815706dcd4ef94d01543e31cb0b20035e98d5011d4b4e7f8e509823c8b1d"
|
|
9
9
|
}
|
|
Binary file
|