rea-agents 5.0.0 → 6.1.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 +168 -655
- package/bridge/android/ReaJadxBridge.java +14 -5
- package/bridge/ghidra/ReaGhidraBridge.java +173 -47
- package/bridge/hopper_bridge.py +310 -128
- package/bridge/mitmproxy/capture.py +208 -0
- package/bridge/native/rea_lldb_tracer.py +839 -0
- package/bridge/process/ProcessRunTokenReader.swift +297 -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 +147 -0
- package/dist/android/JadxConfiguration.js +196 -33
- package/dist/android/JadxMcpTransport.js +4 -0
- package/dist/android/JadxProtocol.js +6 -0
- package/dist/android/JadxProvider.js +20 -2
- package/dist/android/JadxSession.js +23 -4
- package/dist/application/AnalysisContextQueries.js +8 -35
- package/dist/application/AnalysisDocument.js +32 -0
- package/dist/application/AppBundleExecutable.js +67 -21
- package/dist/application/CallPathTracing.js +19 -3
- package/dist/application/CapabilityInventory.js +27 -3
- package/dist/application/ClientConfigurationDocument.js +871 -6
- package/dist/application/ClientRegistrationIdentity.js +26 -5
- package/dist/application/ClientRegistrationStatus.js +29 -14
- package/dist/application/DirectAnalysis.js +97 -33
- package/dist/application/Doctor.js +4 -2
- package/dist/application/DoctorScope.js +25 -13
- package/dist/application/EnhancedLiteralTracing.js +22 -25
- package/dist/application/EnhancedTools.js +13 -11
- package/dist/application/EvidenceBundleFiles.js +24 -12
- package/dist/application/FunctionAnalysisEvidence.js +2 -3
- package/dist/application/InventoryProjectionEvidence.js +4 -3
- package/dist/application/InvestigationProviders.js +3 -2
- package/dist/application/JsonFiles.js +50 -28
- package/dist/application/ProcedureAddressResolution.js +11 -0
- package/dist/application/ReconstructionCoverageService.js +7 -4
- package/dist/application/ReconstructionObligationCandidates.js +5 -1
- package/dist/application/ReconstructionObligationLedgerService.js +4 -3
- package/dist/application/Setup.js +13 -1
- package/dist/application/SetupClientConfiguration.js +10 -15
- package/dist/application/SetupHost.js +5 -2
- package/dist/application/SetupPlan.js +5 -3
- package/dist/application/SupportedClients.js +34 -1
- package/dist/application/Uninstall.js +4 -3
- package/dist/application/Update.js +18 -3
- package/dist/application/UpdateRuntime.js +46 -25
- package/dist/application/WebModuleTraceService.js +4 -2
- package/dist/application/WebNetworkCapturePort.js +1 -0
- package/dist/application/WebNetworkCaptureService.js +134 -0
- package/dist/application/WebRuntimeService.js +5 -3
- package/dist/application/WebScriptExportService.js +2 -2
- package/dist/application/WebSourceLocationService.js +4 -2
- package/dist/application/WindowsCapabilities.js +1 -1
- package/dist/application/WorkflowEvidence.js +82 -0
- package/dist/application/binary/AnalysisProviderEvaluation.js +21 -5
- package/dist/application/binary/AnalysisProviderRegistry.js +2 -0
- package/dist/application/binary/AnalysisSnapshotCache.js +52 -12
- package/dist/application/binary/BinarySession.js +131 -76
- package/dist/application/binary/BinarySessionOpen.js +19 -6
- package/dist/application/binary/BinarySessionRecords.js +45 -3
- package/dist/application/binary/BinarySessionStatus.js +17 -1
- package/dist/application/binary/CompositeProvider.js +13 -0
- package/dist/application/binary/LazyAnalysisProvider.js +3 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +59 -0
- package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +62 -0
- package/dist/application/evm/EvmInterfacePort.js +1 -0
- package/dist/application/evm/EvmInterfaceService.js +64 -0
- package/dist/application/investigation/EvidenceLedger.js +21 -7
- package/dist/application/investigation/InvestigationRecords.js +8 -0
- package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +25 -5
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +19 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +34 -14
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +5 -5
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +47 -27
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +39 -7
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +80 -27
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +33 -12
- package/dist/application/javascript/JavaScriptModuleRelationships.js +37 -8
- package/dist/application/javascript/JavaScriptRecoveryService.js +4 -2
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +3 -1
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +149 -72
- 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 +27 -5
- package/dist/application/managed/ManagedApplicationGraphService.js +4 -3
- package/dist/application/managed/ManagedMemberComparisonService.js +7 -4
- package/dist/application/managed/ManagedNativeVerificationService.js +4 -3
- package/dist/application/managed/ManagedReconstructionService.js +4 -3
- package/dist/application/{ProcessCli.js → process/ProcessCli.js} +23 -15
- package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +8 -7
- package/dist/application/workflowInputError.js +18 -0
- package/dist/artifacts/ArtifactProvider.js +42 -5
- package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
- package/dist/artifacts/MachOSliceArtifactReader.js +98 -14
- package/dist/artifacts/NativeDmgArtifactReader.js +13 -6
- package/dist/artifacts/ZipArtifactReader.js +3 -0
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +22 -3
- package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +176 -56
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +195 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +36 -22
- package/dist/artifacts/apple/MachoLoadCommandReader.js +355 -0
- package/dist/artifacts/apple/NibArchive.js +81 -14
- package/dist/artifacts/apple/NibViewHierarchy.js +10 -3
- package/dist/artifacts/apple/PlistNumberLiterals.js +164 -0
- package/dist/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
- package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +16 -11
- 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 +14 -17
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +6 -2
- package/dist/artifacts/readStableArtifact.js +20 -4
- package/dist/browser/CdpCaptureCompleteness.js +2 -0
- package/dist/browser/CdpCaptureEventHandlers.js +165 -12
- package/dist/browser/CdpCaptureEventTypes.js +5 -1
- package/dist/browser/CdpCaptureEvents.js +34 -0
- package/dist/browser/CdpConnection.js +30 -11
- package/dist/browser/CdpOptionalCommand.js +2 -3
- package/dist/browser/CdpPageCapture.js +23 -1
- package/dist/browser/PlaywrightElectronActiveActions.js +32 -23
- package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +130 -122
- package/dist/browser/WebSourceMapFetcher.js +426 -72
- package/dist/browser/assets/LocalWebScriptArtifacts.js +2 -2
- package/dist/browser/history/CaptureFailures.js +137 -0
- package/dist/browser/history/CaptureFormatError.js +10 -0
- package/dist/browser/history/CaptureRedaction.js +65 -0
- package/dist/browser/history/CaptureRelease.js +17 -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 +92 -0
- package/dist/browser/history/HarSchema.js +72 -0
- package/dist/browser/history/HistoricalCaptureDecoder.js +188 -0
- package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
- package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
- package/dist/cli/analysisSelector.js +23 -0
- package/dist/cli/applicationCommands.js +2 -3
- 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 +78 -20
- package/dist/cli/electronCommands.js +21 -13
- package/dist/cli/evmCommands.js +24 -0
- package/dist/cli/firmwareCommands.js +6 -3
- package/dist/cli/javascriptApplicationAnalysis.js +20 -3
- package/dist/cli/jsonOutput.js +38 -0
- package/dist/cli/nativeCallCommands.js +34 -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/webRuntimeCommands.js +8 -8
- package/dist/cli.js +11 -4
- package/dist/cliBrowserScenarioCommands.js +2 -2
- package/dist/cliCommandNames.js +6 -1
- package/dist/cliJsonInput.js +35 -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/config/environment.js +4 -0
- package/dist/config/ghidraStartupTimeout.js +17 -0
- package/dist/config/mcpResponseBudget.js +22 -0
- package/dist/config/parseConfig.js +2 -1
- package/dist/contracts/artifactToolContracts.js +6 -0
- package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
- package/dist/contracts/browserToolContracts.js +4 -3
- package/dist/contracts/enhancedInputs.js +5 -3
- package/dist/contracts/enhancedToolContracts.js +3 -3
- package/dist/contracts/errorSchemas.js +8 -1
- package/dist/contracts/evm/evmToolContracts.js +20 -0
- package/dist/contracts/hopperMemoryContracts.js +2 -5
- package/dist/contracts/investigationExamples.js +2 -2
- package/dist/contracts/javascript/electronToolContracts.js +1 -1
- package/dist/contracts/managed/managedToolContracts.js +8 -6
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
- package/dist/contracts/native/nativeToolContracts.js +21 -3
- package/dist/contracts/officialToolContracts.js +26 -24
- package/dist/contracts/process/processCaptureExample.js +2 -0
- package/dist/contracts/promptContracts.js +3 -3
- package/dist/contracts/sessionLifecycleInputs.js +18 -5
- package/dist/contracts/sessionStatusContract.js +8 -2
- package/dist/contracts/sessionToolContracts.js +8 -3
- package/dist/contracts/sessionToolSchemas.js +8 -4
- package/dist/contracts/toolContractExamples.js +1 -2
- package/dist/contracts/toolContractHelpers.js +4 -1
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +30 -1
- package/dist/contracts/toolOutputSchemaGroups.js +33 -28
- package/dist/contracts/toolOutputSchemaPrimitives.js +19 -1
- package/dist/contracts/toolSchemaMetadata.js +69 -10
- package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
- package/dist/domain/analysisErrorBase.js +22 -2
- package/dist/domain/analysisErrorCore.js +61 -5
- package/dist/domain/analysisErrorPresentation.js +95 -12
- package/dist/domain/analysisErrorProjection.js +148 -19
- package/dist/domain/analysisSnapshot.js +166 -2
- package/dist/domain/android/androidAnalysis.js +2 -4
- package/dist/domain/android/androidApplication.js +17 -9
- package/dist/domain/apple/appleApplication.js +41 -14
- package/dist/domain/apple/dyldEnvironment.js +73 -0
- package/dist/domain/apple/dyldPaths.js +81 -0
- package/dist/domain/apple/dylibResolution.js +478 -0
- package/dist/domain/apple/dylibResolutionFindings.js +77 -0
- package/dist/domain/apple/interfaceBuilderGraph.js +25 -13
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +13 -3
- package/dist/domain/apple/keyedArchive.js +9 -1
- package/dist/domain/apple/machoContainer.js +54 -0
- package/dist/domain/apple/plistNumbers.js +76 -0
- package/dist/domain/artifactIdentity.js +29 -0
- package/dist/domain/artifactInventoryEvidence.js +19 -24
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/bridgeCandidateProjection.js +71 -0
- package/dist/domain/browserCompleteness.js +1 -0
- package/dist/domain/browserObservation.js +1 -1
- package/dist/domain/browserObservationError.js +24 -5
- package/dist/domain/browserObservationSchemas.js +13 -0
- package/dist/domain/browserScenarioValues.js +5 -2
- package/dist/domain/bundleComparison.js +3 -2
- package/dist/domain/callPathSchemas.js +1 -1
- package/dist/domain/canonicalDigest.js +13 -1
- package/dist/domain/canonicalJsonDigestSteps.js +133 -0
- package/dist/domain/canonicalOrdering.js +9 -5
- package/dist/domain/changedBehavior.js +9 -9
- package/dist/domain/comparisonSourceEvidence.js +40 -0
- package/dist/domain/comparisonStatus.js +2 -30
- package/dist/domain/configurationErrors.js +1 -1
- package/dist/domain/conformanceTrustGate.js +0 -16
- package/dist/domain/evidence.js +78 -11
- package/dist/domain/evidenceBundle.js +42 -1
- package/dist/domain/evidenceErrors.js +12 -1
- package/dist/domain/evm/evmInterface.js +63 -0
- package/dist/domain/explicitSensitiveFailure.js +108 -0
- package/dist/domain/explicitSensitiveValues.js +10 -0
- package/dist/domain/firmware/firmwareAnalysis.js +10 -4
- package/dist/domain/hopperErrors.js +23 -2
- package/dist/domain/hopperValues.js +51 -8
- package/dist/domain/immutableJson.js +114 -0
- package/dist/domain/inputIssueProjection.js +3 -0
- package/dist/domain/javascript/electronActiveObservation.js +37 -6
- package/dist/domain/javascript/electronStaticAnalysisValues.js +6 -12
- package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +71 -23
- package/dist/domain/javascript/javascriptApplicationGraph.js +13 -0
- package/dist/domain/javascript/javascriptAstValues.js +20 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
- package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
- package/dist/domain/javascript/javascriptRecovery.js +3 -8
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +97 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +6 -5
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +9 -17
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +22 -5
- package/dist/domain/javascript/javascriptSemanticGraph.js +34 -5
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +1 -0
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +25 -17
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -4
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
- package/dist/domain/javascript/javascriptSemanticValues.js +83 -11
- package/dist/domain/javascript/javascriptSourceParser.js +6 -2
- package/dist/domain/javascript/javascriptStaticAnalysis.js +22 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -3
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +14 -4
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +66 -7
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +28 -16
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -2
- package/dist/domain/jsonSerialization.js +109 -0
- package/dist/domain/jsonValue.js +91 -3
- package/dist/domain/localPath.js +8 -0
- package/dist/domain/managed/managedApplicationGraph.js +10 -10
- package/dist/domain/managed/managedInspectionEvidence.js +16 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +5 -9
- package/dist/domain/managed/managedNativeVerification.js +3 -9
- package/dist/domain/native/binaryLayout.js +357 -0
- package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
- package/dist/domain/native/nativeCallObservation.js +186 -0
- package/dist/domain/native/nativeCallPartialObservation.js +33 -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} +143 -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} +39 -5
- package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
- package/dist/domain/{processScenario.js → process/processScenario.js} +11 -10
- package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
- package/dist/domain/propertyListKeys.js +1 -1
- package/dist/domain/propertyListXmlText.js +19 -0
- package/dist/domain/providerAdapterError.js +1 -1
- package/dist/domain/providerOperationHealth.js +54 -0
- package/dist/domain/providerSelectionError.js +4 -2
- package/dist/domain/reconstructionVerification.js +9 -46
- package/dist/domain/reconstructionVerificationSchemas.js +3 -3
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +9 -46
- package/dist/domain/webBundleAnalysis.js +20 -8
- package/dist/domain/webBundleAnalyzerInspection.js +13 -8
- package/dist/domain/webBundleAnalyzerResult.js +41 -2
- package/dist/domain/webCaptureDiff.js +1 -0
- package/dist/domain/webNetworkCapture.js +118 -0
- package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
- package/dist/domain/webRuntime.js +19 -5
- package/dist/domain/webSourceLocation.js +1 -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/firmware/FirmwareFiles.js +1 -1
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +5 -0
- package/dist/ghidra/GhidraClient.js +47 -14
- package/dist/ghidra/GhidraDiagnostics.js +7 -7
- package/dist/ghidra/GhidraFunctionValues.js +10 -7
- package/dist/ghidra/GhidraInstallation.js +18 -21
- package/dist/ghidra/GhidraInventoryValues.js +14 -4
- package/dist/ghidra/GhidraJavaLaunch.js +62 -0
- package/dist/ghidra/GhidraLauncher.js +34 -16
- package/dist/ghidra/GhidraProvider.js +2 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +15 -3
- package/dist/ghidra/GhidraProviderClient.js +23 -12
- package/dist/ghidra/GhidraSessionError.js +11 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +47 -12
- package/dist/ghidra/GhidraTransport.js +20 -0
- package/dist/hopper/BridgeLauncher.js +33 -11
- package/dist/hopper/HopperAnalysisProfile.js +62 -4
- package/dist/hopper/HopperCleanup.js +15 -3
- package/dist/hopper/HopperClient.js +222 -14
- package/dist/hopper/HopperFileOffset.js +237 -0
- package/dist/hopper/HopperMachOImage.js +196 -0
- package/dist/hopper/HopperOperationStage.js +6 -0
- package/dist/hopper/HopperProvider.js +63 -9
- package/dist/hopper/HopperProviderCapabilities.js +19 -1
- package/dist/hopper/HopperRegexSearch.js +137 -0
- package/dist/hopper/HopperRegexWorker.js +27 -0
- package/dist/hopper/HopperRequestQueue.js +68 -19
- package/dist/hopper/HopperTargetLease.js +3 -2
- package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -1
- package/dist/inspector/V8InspectorCaptureProjection.js +8 -3
- package/dist/inspector/V8InspectorProvider.js +47 -11
- package/dist/javascript/recovery/WakaruCommand.js +3 -0
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +17 -0
- package/dist/javascript/sourceMaps/SourceMapFormat.js +79 -31
- package/dist/javascript/sourceMaps/TraceSourceMap.js +14 -28
- package/dist/mcpDoctor.js +62 -2
- package/dist/native/AppleDispatchCoverage.js +47 -6
- package/dist/native/AppleDispatchDecodeFacts.js +6 -0
- package/dist/native/AppleDispatchMetadata.js +6 -3
- package/dist/native/AppleMachoFixups.js +48 -24
- package/dist/native/AppleMachoSelection.js +32 -16
- package/dist/native/AppleObjcCategories.js +6 -2
- package/dist/native/AppleObjcDispatchFacets.js +5 -2
- package/dist/native/AppleObjcProperties.js +2 -1
- package/dist/native/AppleSwiftDispatchFacets.js +27 -21
- package/dist/native/AppleSwiftVtables.js +21 -15
- package/dist/native/CommandRunner.js +82 -84
- package/dist/native/LldbCallTracer.js +541 -0
- package/dist/native/LldbRetainedObservations.js +178 -0
- package/dist/native/NativeCallObservation.js +194 -0
- package/dist/native/NativeMacOSProvider.js +117 -20
- package/dist/native/NativeMacOSProviderMetadata.js +8 -3
- package/dist/native/SignatureTargetBinding.js +155 -0
- package/dist/native/parsers/lipo.js +71 -1
- package/dist/native/pwndbg/PwndbgCoreContext.js +180 -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 +103 -0
- package/dist/process/DarwinProcessRunTokenReader.js +293 -0
- package/dist/process/ExecFileOutput.js +20 -0
- package/dist/process/OwnedCommand.js +118 -0
- package/dist/process/ProcessOwnership.js +431 -51
- package/dist/process/ProcessOwnershipObservation.js +209 -27
- package/dist/process/ProviderProcess.js +68 -10
- package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
- package/dist/{application → process/capture}/ProcessCaptureError.js +18 -2
- package/dist/process/capture/ProcessCaptureLifecycle.js +681 -0
- package/dist/{application → process/capture}/ProcessHarness.js +195 -29
- package/dist/{application → process/capture}/ProcessSampling.js +2 -2
- package/dist/server/EvidenceMcpServer.js +146 -0
- package/dist/server/createServer.js +37 -8
- package/dist/server/promptCompletion.js +10 -3
- package/dist/server/registerAndroidTools.js +2 -4
- package/dist/server/registerApplicationTools/helpers.js +2 -4
- package/dist/server/registerArtifactComparisonTool.js +11 -7
- package/dist/server/registerBinaryDiagnosticsTools.js +15 -0
- package/dist/server/registerBrowserScenarioTool.js +2 -4
- package/dist/server/registerBrowserTools.js +2 -4
- package/dist/server/registerBundleComparisonTool.js +2 -3
- package/dist/server/registerCloseLifecycleTool.js +8 -18
- package/dist/server/registerElectronTools.js +2 -4
- package/dist/server/registerEnhancedTools.js +18 -59
- package/dist/server/registerEvidenceTools.js +3 -5
- package/dist/server/registerEvmTools.js +15 -0
- package/dist/server/registerFirmwareTools.js +2 -4
- package/dist/server/registerFunctionComparisonTool.js +10 -6
- package/dist/server/registerInvestigationTools.js +7 -7
- package/dist/server/registerJavaScriptRecoveryTool.js +2 -4
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +2 -4
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +2 -4
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +2 -4
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +2 -4
- package/dist/server/registerOfficialTools.js +2 -4
- package/dist/server/registerProcessComparisonTool.js +72 -46
- package/dist/server/registerRecordedCrashTools.js +15 -0
- package/dist/server/registerSessionRecordTools.js +5 -6
- package/dist/server/registerSessionStatusTool.js +17 -3
- package/dist/server/registerSessionTools.js +13 -5
- package/dist/server/registerWebModuleTool.js +2 -4
- package/dist/server/registerWebNetworkCaptureTool.js +26 -0
- package/dist/server/registerWebRuntimeTools.js +3 -7
- package/dist/server/registerWebScriptTool.js +2 -4
- package/dist/server/registerWebSourceLocationTool.js +2 -4
- package/dist/server/runDerivedOperation.js +15 -3
- package/dist/server/sessionAvailabilityPolicy.js +3 -1
- package/dist/server/sessionToolPolicies.js +1 -1
- package/dist/server/toolRegistrationOptions.js +2 -2
- package/dist/server/toolResult.js +63 -11
- package/dist/server/toolResultEncoding.js +33 -0
- package/install.sh +1 -1
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +42 -9
- package/scripts/electron-active-hook-boundaries.cjs +18 -20
- package/scripts/electron-active-hook.cjs +241 -37
- package/scripts/rea.mjs +11 -3
- package/skills/reverse-engineer-anything/SKILL.md +32 -4
- package/skills/reverse-engineer-anything/references/javascript-applications.md +8 -1
- 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/ghidra/GhidraDefaults.js +0 -2
- /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/{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,7 +1,9 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { AnalysisCapabilityUnavailableError } from "../domain/analysisErrorCore.js";
|
|
2
3
|
import { launcherIdentityFailure } from "./ProcessOwnershipIdentity.js";
|
|
3
4
|
import { descendantsOf, liveProcesses } from "./ProcessOwnershipProcessTree.js";
|
|
4
5
|
import { execFileOutput } from "./ExecFileOutput.js";
|
|
6
|
+
import { createDarwinProcessRunTokenReader } from "./DarwinProcessRunTokenReader.js";
|
|
5
7
|
/** Observe one group without signaling it, failing closed on identity doubt. */
|
|
6
8
|
export const observeOwnedProcessGroupWithHost = async (ownership, host) => {
|
|
7
9
|
let members;
|
|
@@ -105,46 +107,226 @@ export const parseProcessEnvironment = (value) => Object.fromEntries(value
|
|
|
105
107
|
const separator = entry.indexOf("=");
|
|
106
108
|
return [entry.slice(0, separator), entry.slice(separator + 1)];
|
|
107
109
|
}));
|
|
110
|
+
/** Read Linux stat field 22, tolerating spaces and closing parentheses in comm. */
|
|
111
|
+
export const parseLinuxProcessStartTime = (value) => {
|
|
112
|
+
const commandEnd = value.lastIndexOf(")");
|
|
113
|
+
if (commandEnd < 0)
|
|
114
|
+
return undefined;
|
|
115
|
+
const fields = value
|
|
116
|
+
.slice(commandEnd + 1)
|
|
117
|
+
.trim()
|
|
118
|
+
.split(/\s+/u);
|
|
119
|
+
const startTime = fields[19];
|
|
120
|
+
return startTime !== undefined && /^\d+$/u.test(startTime)
|
|
121
|
+
? startTime
|
|
122
|
+
: undefined;
|
|
123
|
+
};
|
|
124
|
+
const isExpectedAbort = (cause, signal) => signal?.aborted === true &&
|
|
125
|
+
(cause === signal.reason ||
|
|
126
|
+
(cause instanceof Error && cause.name === "AbortError"));
|
|
108
127
|
/** Create the operating-system process inspector for an explicit host context. */
|
|
109
|
-
export const createSystemProcessOwnershipHost = (platform = process.platform, hostEnvironment = process.env) =>
|
|
110
|
-
platform
|
|
111
|
-
|
|
128
|
+
export const createSystemProcessOwnershipHost = (platform = process.platform, hostEnvironment = process.env, options = {}) => {
|
|
129
|
+
const darwinTokens = platform === "darwin"
|
|
130
|
+
? createDarwinProcessRunTokenReader(options.darwinXcrun === undefined
|
|
131
|
+
? {}
|
|
132
|
+
: { xcrun: options.darwinXcrun })
|
|
133
|
+
: undefined;
|
|
134
|
+
const listProcesses = async (signal) => {
|
|
112
135
|
if (platform === "win32")
|
|
113
136
|
return [];
|
|
114
|
-
const { stdout } = await execFileOutput("ps", ["-axo", "pid=,ppid=,pgid=,stat=,command="], { env: hostEnvironment });
|
|
137
|
+
const { stdout } = await execFileOutput("ps", ["-axo", "pid=,ppid=,pgid=,uid=,stat=,command="], { env: hostEnvironment, ...(signal === undefined ? {} : { signal }) });
|
|
115
138
|
return stdout
|
|
116
139
|
.split("\n")
|
|
117
|
-
.map((line) => /\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(.*)/u.exec(line))
|
|
140
|
+
.map((line) => /\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(.*)/u.exec(line))
|
|
118
141
|
.filter((match) => match !== null)
|
|
119
142
|
.map((match) => ({
|
|
120
143
|
pid: Number(match[1]),
|
|
121
144
|
parentPid: Number(match[2]),
|
|
122
145
|
processGroupId: Number(match[3]),
|
|
123
|
-
|
|
124
|
-
|
|
146
|
+
uid: Number(match[4]),
|
|
147
|
+
state: match[5] ?? "",
|
|
148
|
+
command: match[6] ?? "",
|
|
125
149
|
}));
|
|
126
|
-
}
|
|
127
|
-
async
|
|
150
|
+
};
|
|
151
|
+
const processIdentities = async (processes, signal) => {
|
|
152
|
+
if (processes.length === 0)
|
|
153
|
+
return new Map();
|
|
128
154
|
if (platform === "linux")
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
155
|
+
return new Map(await Promise.all(processes.map(async ({ pid }) => {
|
|
156
|
+
try {
|
|
157
|
+
const stat = await readFile(`/proc/${String(pid)}/stat`, {
|
|
158
|
+
encoding: "utf8",
|
|
159
|
+
...(signal === undefined ? {} : { signal }),
|
|
160
|
+
});
|
|
161
|
+
const identity = parseLinuxProcessStartTime(stat);
|
|
162
|
+
return [
|
|
163
|
+
pid,
|
|
164
|
+
identity === undefined
|
|
165
|
+
? {
|
|
166
|
+
state: "unavailable",
|
|
167
|
+
reason: "malformed_proc_stat",
|
|
168
|
+
}
|
|
169
|
+
: {
|
|
170
|
+
state: "readable",
|
|
171
|
+
identity: `linux-starttime:${identity}`,
|
|
172
|
+
},
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
catch (cause) {
|
|
176
|
+
if (isExpectedAbort(cause, signal))
|
|
177
|
+
throw cause;
|
|
178
|
+
return [
|
|
179
|
+
pid,
|
|
180
|
+
{ state: "unavailable", reason: errorMessage(cause) },
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
})));
|
|
184
|
+
if (darwinTokens === undefined)
|
|
185
|
+
return new Map();
|
|
186
|
+
try {
|
|
187
|
+
return await darwinTokens.identities(processes, signal);
|
|
138
188
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
189
|
+
catch (cause) {
|
|
190
|
+
if (isExpectedAbort(cause, signal))
|
|
191
|
+
throw cause;
|
|
192
|
+
const reason = errorMessage(cause);
|
|
193
|
+
return new Map(processes.map(({ pid }) => [
|
|
194
|
+
pid,
|
|
195
|
+
{ state: "unavailable", reason },
|
|
196
|
+
]));
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const captureBaseline = async (signal) => {
|
|
200
|
+
if (platform !== "linux" && darwinTokens === undefined)
|
|
201
|
+
return [];
|
|
202
|
+
const processes = liveProcesses(await listProcesses(signal));
|
|
203
|
+
let identities = await processIdentities(processes, signal);
|
|
204
|
+
const unreadable = processes.filter(({ pid }) => identities.get(pid)?.state !== "readable");
|
|
205
|
+
if (unreadable.length > 0) {
|
|
206
|
+
const stillLive = liveProcesses(await listProcesses(signal)).filter(({ pid }) => unreadable.some((entry) => entry.pid === pid));
|
|
207
|
+
const retried = await processIdentities(stillLive, signal);
|
|
208
|
+
identities = new Map([...identities, ...retried]);
|
|
209
|
+
const unresolved = stillLive.filter(({ pid }) => identities.get(pid)?.state !== "readable");
|
|
210
|
+
const liveAfterRetry = liveProcesses(await listProcesses(signal));
|
|
211
|
+
const stillUnresolved = unresolved.filter(({ pid }) => liveAfterRetry.some((entry) => entry.pid === pid));
|
|
212
|
+
if (stillUnresolved.length > 0)
|
|
213
|
+
throw new Error(`process identity snapshot is unavailable for ${String(stillUnresolved.length)} live processes`);
|
|
214
|
+
}
|
|
215
|
+
return processes.map(({ pid }) => {
|
|
216
|
+
const observation = identities.get(pid);
|
|
217
|
+
return {
|
|
218
|
+
pid,
|
|
219
|
+
identity: observation?.state === "readable" ? observation.identity : null,
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
return {
|
|
224
|
+
platform,
|
|
225
|
+
prepare: async (signal) => {
|
|
226
|
+
await darwinTokens?.prepare(signal);
|
|
227
|
+
if (platform === "linux") {
|
|
228
|
+
try {
|
|
229
|
+
const processes = await listProcesses(signal);
|
|
230
|
+
if (!processes.some(({ pid }) => pid === process.pid))
|
|
231
|
+
throw new Error("ps did not report REA's current process");
|
|
232
|
+
}
|
|
233
|
+
catch (cause) {
|
|
234
|
+
if (isExpectedAbort(cause, signal))
|
|
235
|
+
throw cause;
|
|
236
|
+
const reason = `Linux process ownership inspection requires a procps-compatible ps on REA's PATH before launching a child: ${errorMessage(cause)}`;
|
|
237
|
+
throw new AnalysisCapabilityUnavailableError("process-ownership", "prepare_owned_process", reason, { cause, userMessage: reason });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
listProcesses,
|
|
242
|
+
async environment(pid) {
|
|
243
|
+
if (platform === "linux")
|
|
244
|
+
return parseProcessEnvironment(await readFile(`/proc/${pid}/environ`, "utf8"));
|
|
245
|
+
if (platform === "darwin") {
|
|
246
|
+
const process = (await listProcesses()).find((entry) => entry.pid === pid);
|
|
247
|
+
if (process === undefined)
|
|
248
|
+
throw new Error(`process ${String(pid)} is not live`);
|
|
249
|
+
const observation = (await darwinTokens?.read([process]))?.get(pid);
|
|
250
|
+
if (observation === undefined || observation.state === "unavailable")
|
|
251
|
+
throw new Error(observation?.reason ?? "process run token could not be read");
|
|
252
|
+
return observation.runId === undefined
|
|
253
|
+
? {}
|
|
254
|
+
: { REA_PROCESS_RUN_ID: observation.runId };
|
|
255
|
+
}
|
|
256
|
+
const { stdout } = await execFileOutput("ps", ["eww", "-p", String(pid)], {
|
|
257
|
+
env: hostEnvironment,
|
|
258
|
+
});
|
|
259
|
+
const observedEnvironment = {};
|
|
260
|
+
for (const match of stdout.matchAll(/(?:^|\s)([A-Za-z_][A-Za-z0-9_]*)=([^\s]*)/gu)) {
|
|
261
|
+
const name = match[1];
|
|
262
|
+
if (name !== undefined)
|
|
263
|
+
observedEnvironment[name] = match[2] ?? "";
|
|
264
|
+
}
|
|
265
|
+
return observedEnvironment;
|
|
266
|
+
},
|
|
267
|
+
async runTokens(processes) {
|
|
268
|
+
if (platform !== "darwin" || processes.length === 0)
|
|
269
|
+
return new Map();
|
|
270
|
+
try {
|
|
271
|
+
return (await darwinTokens?.read(processes)) ?? new Map();
|
|
272
|
+
}
|
|
273
|
+
catch (cause) {
|
|
274
|
+
void cause;
|
|
275
|
+
return new Map(processes.map(({ pid }) => [
|
|
276
|
+
pid,
|
|
277
|
+
{ state: "unavailable", reason: "reader_failure" },
|
|
278
|
+
]));
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
...(platform !== "linux" && darwinTokens === undefined
|
|
282
|
+
? {}
|
|
283
|
+
: {
|
|
284
|
+
processIdentities,
|
|
285
|
+
captureBaseline,
|
|
286
|
+
...(darwinTokens === undefined ? {} : { close: darwinTokens.close }),
|
|
287
|
+
}),
|
|
288
|
+
signalGroup(processGroupId, signal) {
|
|
289
|
+
process.kill(-processGroupId, signal);
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
export const systemProcessOwnershipHost = createSystemProcessOwnershipHost();
|
|
294
|
+
/** Observe the current OS start identity for one live PID, when supported. */
|
|
295
|
+
export const observeProcessStartIdentity = async (pid, host = systemProcessOwnershipHost) => {
|
|
296
|
+
const process = (await host.listProcesses()).find((entry) => entry.pid === pid);
|
|
297
|
+
if (process === undefined || liveProcesses([process]).length === 0)
|
|
298
|
+
return undefined;
|
|
299
|
+
if (host.processIdentities === undefined)
|
|
300
|
+
return { state: "unavailable", reason: "process identity is unsupported" };
|
|
301
|
+
return ((await host.processIdentities([process])).get(pid) ?? {
|
|
302
|
+
state: "unavailable",
|
|
303
|
+
reason: "process identity was not returned",
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/** Revalidate a launch-time start identity immediately before signaling a PID. */
|
|
307
|
+
export const signalProcessWithStartIdentity = async (pid, expectedIdentity, signal, options = {}) => {
|
|
308
|
+
const host = options.host ?? systemProcessOwnershipHost;
|
|
309
|
+
try {
|
|
310
|
+
const observed = await observeProcessStartIdentity(pid, host);
|
|
311
|
+
if (observed === undefined)
|
|
312
|
+
return "gone";
|
|
313
|
+
if (observed.state !== "readable")
|
|
314
|
+
return "unverified";
|
|
315
|
+
if (observed.identity !== expectedIdentity)
|
|
316
|
+
return "identity-changed";
|
|
317
|
+
(options.sendSignal ?? process.kill)(pid, signal);
|
|
318
|
+
return "signaled";
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
return "unverified";
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
/** Prepare native token inspection before REA launches a captured child. */
|
|
325
|
+
export const prepareProcessOwnershipInspection = async (signal) => {
|
|
326
|
+
await systemProcessOwnershipHost.prepare?.(signal);
|
|
327
|
+
};
|
|
146
328
|
/** Observe one group without signaling it, failing closed on identity doubt. */
|
|
147
|
-
export const observeOwnedProcessGroup = async (ownership, host =
|
|
329
|
+
export const observeOwnedProcessGroup = async (ownership, host = systemProcessOwnershipHost) => observeOwnedProcessGroupWithHost(ownership, host);
|
|
148
330
|
/**
|
|
149
331
|
* Record the live launcher and descendant lineage after run-token validation.
|
|
150
332
|
*
|
|
@@ -152,7 +334,7 @@ export const observeOwnedProcessGroup = async (ownership, host = systemHost) =>
|
|
|
152
334
|
* list means no descendants were live during this observation, not that the
|
|
153
335
|
* run never created a short-lived child.
|
|
154
336
|
*/
|
|
155
|
-
export const observeOwnedProcessLineage = async (ownership, host =
|
|
337
|
+
export const observeOwnedProcessLineage = async (ownership, host = systemProcessOwnershipHost) => observeOwnedProcessLineageWithHost(ownership, host);
|
|
156
338
|
const processIsGone = async (host, pid) => {
|
|
157
339
|
try {
|
|
158
340
|
return !liveProcesses(await host.listProcesses()).some((process) => process.pid === pid);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { WindowsOwnedProcess } from "../windows/WindowsOwnedProcess.js";
|
|
3
|
+
import { prepareProcessOwnershipInspection } from "./ProcessOwnershipObservation.js";
|
|
3
4
|
const DEFAULT_TERMINATION_GRACE_MS = 250;
|
|
4
5
|
const DEFAULT_KILL_GRACE_MS = 1_000;
|
|
5
6
|
/**
|
|
@@ -9,6 +10,9 @@ const DEFAULT_KILL_GRACE_MS = 1_000;
|
|
|
9
10
|
* selecting provider-specific command arguments or environment values.
|
|
10
11
|
*/
|
|
11
12
|
export const spawnOwnedProviderProcess = async (options) => {
|
|
13
|
+
options.signal?.throwIfAborted();
|
|
14
|
+
await prepareProcessOwnershipInspection(options.signal);
|
|
15
|
+
options.signal?.throwIfAborted();
|
|
12
16
|
const platform = options.platform ?? process.platform;
|
|
13
17
|
const hostEnvironment = options.hostEnvironment ?? process.env;
|
|
14
18
|
const environment = {
|
|
@@ -70,12 +74,21 @@ export class ProviderProcessSupervisor {
|
|
|
70
74
|
#exit = deferred();
|
|
71
75
|
#outputClose = deferred();
|
|
72
76
|
#outputClosed = false;
|
|
77
|
+
#stdoutObservedBytes = 0;
|
|
78
|
+
#stderrObservedBytes = 0;
|
|
79
|
+
#diagnosticTruncated = false;
|
|
73
80
|
#onStdout = (chunk) => {
|
|
74
81
|
this.#capture("stdout", this.#stdout, chunk);
|
|
75
82
|
};
|
|
76
83
|
#onStderr = (chunk) => {
|
|
77
84
|
this.#capture("stderr", this.#stderr, chunk);
|
|
78
85
|
};
|
|
86
|
+
#onStdoutError = (cause) => {
|
|
87
|
+
this.#recordStreamError("stdout", cause);
|
|
88
|
+
};
|
|
89
|
+
#onStderrError = (cause) => {
|
|
90
|
+
this.#recordStreamError("stderr", cause);
|
|
91
|
+
};
|
|
79
92
|
#onExit = (code, signal) => {
|
|
80
93
|
this.#recordExit(code, signal);
|
|
81
94
|
};
|
|
@@ -102,9 +115,10 @@ export class ProviderProcessSupervisor {
|
|
|
102
115
|
if (launch.process.exitCode !== null || launch.process.signalCode !== null)
|
|
103
116
|
this.#recordExit(launch.process.exitCode, launch.process.signalCode);
|
|
104
117
|
}
|
|
105
|
-
/** Latest
|
|
118
|
+
/** Latest retained output and exit observation, with explicit configured truncation. */
|
|
106
119
|
snapshot() {
|
|
107
120
|
return {
|
|
121
|
+
...(this.#diagnosticTruncated ? { diagnosticTruncated: true } : {}),
|
|
108
122
|
stdout: this.#stdout.snapshot(),
|
|
109
123
|
stderr: this.#stderr.snapshot(),
|
|
110
124
|
exitCode: this.#exitObservation?.code,
|
|
@@ -115,6 +129,9 @@ export class ProviderProcessSupervisor {
|
|
|
115
129
|
resetOutput() {
|
|
116
130
|
this.#stdout.reset();
|
|
117
131
|
this.#stderr.reset();
|
|
132
|
+
this.#stdoutObservedBytes = 0;
|
|
133
|
+
this.#stderrObservedBytes = 0;
|
|
134
|
+
this.#diagnosticTruncated = false;
|
|
118
135
|
}
|
|
119
136
|
/** Wait for process exit up to a caller-owned bounded interval. */
|
|
120
137
|
async waitForExit(timeoutMs) {
|
|
@@ -124,9 +141,13 @@ export class ProviderProcessSupervisor {
|
|
|
124
141
|
async waitForOutputClose(timeoutMs) {
|
|
125
142
|
return waitForProcessEvent(this.#outputClosed, this.#outputClose.promise, timeoutMs);
|
|
126
143
|
}
|
|
127
|
-
/**
|
|
144
|
+
/** Share each stop attempt; incomplete cleanup retains ownership and permits retry. */
|
|
128
145
|
stop(options = {}) {
|
|
129
|
-
this.#stopPromise ??= this.#stop(options)
|
|
146
|
+
this.#stopPromise ??= this.#stop(options).then((result) => {
|
|
147
|
+
if (result.status === "incomplete")
|
|
148
|
+
this.#stopPromise = undefined;
|
|
149
|
+
return result;
|
|
150
|
+
});
|
|
130
151
|
return this.#stopPromise;
|
|
131
152
|
}
|
|
132
153
|
/** Detach capture and process listeners after an adapter releases ownership. */
|
|
@@ -135,12 +156,26 @@ export class ProviderProcessSupervisor {
|
|
|
135
156
|
return;
|
|
136
157
|
this.#disposed = true;
|
|
137
158
|
this.launch.process.stdout?.off("data", this.#onStdout);
|
|
159
|
+
this.launch.process.stdout?.off("error", this.#onStdoutError);
|
|
138
160
|
this.launch.process.stderr?.off("data", this.#onStderr);
|
|
161
|
+
this.launch.process.stderr?.off("error", this.#onStderrError);
|
|
139
162
|
this.launch.process.off("exit", this.#onExit);
|
|
140
163
|
this.launch.process.off("close", this.#onClose);
|
|
141
164
|
this.launch.process.off("error", this.#onError);
|
|
142
165
|
}
|
|
143
166
|
async #stop(options) {
|
|
167
|
+
let completed = false;
|
|
168
|
+
try {
|
|
169
|
+
const result = await this.#stopWithin(options);
|
|
170
|
+
completed = result.status !== "incomplete";
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
if (completed)
|
|
175
|
+
this.dispose();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async #stopWithin(options) {
|
|
144
179
|
try {
|
|
145
180
|
if (!this.launch.ownsProcessLifetime)
|
|
146
181
|
return { status: "not-owned" };
|
|
@@ -182,9 +217,6 @@ export class ProviderProcessSupervisor {
|
|
|
182
217
|
: "owned provider process cleanup failed",
|
|
183
218
|
};
|
|
184
219
|
}
|
|
185
|
-
finally {
|
|
186
|
-
this.dispose();
|
|
187
|
-
}
|
|
188
220
|
}
|
|
189
221
|
#ownedCleanup(supplied) {
|
|
190
222
|
if (supplied !== undefined)
|
|
@@ -203,19 +235,45 @@ export class ProviderProcessSupervisor {
|
|
|
203
235
|
this.launch.process.kill(signal);
|
|
204
236
|
}
|
|
205
237
|
#attach(stream, name) {
|
|
206
|
-
if (name === "stdout")
|
|
238
|
+
if (name === "stdout") {
|
|
207
239
|
stream?.on("data", this.#onStdout);
|
|
208
|
-
|
|
240
|
+
stream?.on("error", this.#onStdoutError);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
209
243
|
stream?.on("data", this.#onStderr);
|
|
244
|
+
stream?.on("error", this.#onStderrError);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
#recordStreamError(stream, cause) {
|
|
248
|
+
this.#options.onDiagnostic?.({
|
|
249
|
+
type: "error",
|
|
250
|
+
message: `${stream} stream failed: ${cause.message}`,
|
|
251
|
+
});
|
|
210
252
|
}
|
|
211
253
|
#capture(stream, capture, chunk) {
|
|
212
254
|
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
213
|
-
|
|
255
|
+
if (stream === "stdout")
|
|
256
|
+
this.#stdoutObservedBytes += bytes.byteLength;
|
|
257
|
+
else
|
|
258
|
+
this.#stderrObservedBytes += bytes.byteLength;
|
|
259
|
+
const remaining = this.#options.maxDiagnosticBytes === undefined
|
|
260
|
+
? bytes.byteLength
|
|
261
|
+
: Math.max(0, this.#options.maxDiagnosticBytes -
|
|
262
|
+
this.#stdout.bytes -
|
|
263
|
+
this.#stderr.bytes);
|
|
264
|
+
const retained = Math.min(bytes.byteLength, remaining);
|
|
265
|
+
if (retained < bytes.byteLength)
|
|
266
|
+
this.#diagnosticTruncated = true;
|
|
267
|
+
if (retained > 0)
|
|
268
|
+
capture.append(bytes.subarray(0, retained));
|
|
214
269
|
this.#options.onDiagnostic?.({
|
|
215
270
|
type: "output",
|
|
216
271
|
stream,
|
|
217
272
|
bytes: bytes.byteLength,
|
|
218
|
-
totalBytes:
|
|
273
|
+
totalBytes: stream === "stdout"
|
|
274
|
+
? this.#stdoutObservedBytes
|
|
275
|
+
: this.#stderrObservedBytes,
|
|
276
|
+
...(retained < bytes.byteLength ? { truncated: true } : {}),
|
|
219
277
|
});
|
|
220
278
|
}
|
|
221
279
|
#recordExit(code, signal) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { tmpdir } from "node:os";
|
|
2
|
+
import { prepareProcessOwnershipInspection } from "../ProcessOwnershipObservation.js";
|
|
2
3
|
/** Explain why process capture cannot claim owned-process cleanup on a host. */
|
|
3
4
|
export const processCaptureOwnershipUnavailableReason = (platform) => platform === "win32"
|
|
4
5
|
? "Windows PTY process capture is unavailable because this adapter does not yet verify descendant cleanup. Use Linux (including WSL for Linux commands) or macOS. Reinstalling the PTY backend does not enable native Windows capture."
|
|
@@ -28,6 +29,20 @@ export const probeProcessCaptureCapability = async (options = {}) => {
|
|
|
28
29
|
backend: "node-pty",
|
|
29
30
|
reason: ownershipReason,
|
|
30
31
|
};
|
|
32
|
+
if (platform === "darwin") {
|
|
33
|
+
try {
|
|
34
|
+
await (options.prepareOwnershipInspector ?? prepareProcessOwnershipInspection)();
|
|
35
|
+
}
|
|
36
|
+
catch (cause) {
|
|
37
|
+
return {
|
|
38
|
+
available: false,
|
|
39
|
+
backend: "node-pty",
|
|
40
|
+
reason: cause instanceof Error
|
|
41
|
+
? cause.message
|
|
42
|
+
: "macOS process ownership inspection could not be prepared",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
31
46
|
try {
|
|
32
47
|
const { spawn } = await (options.loadPty ?? (() => import("@lydell/node-pty")))();
|
|
33
48
|
const terminal = spawn(platform === "win32" ? "cmd.exe" : "/bin/sh", platform === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalysisError } from "
|
|
1
|
+
import { AnalysisError } from "../../domain/analysisErrorBase.js";
|
|
2
2
|
/** Typed application failure produced by controlled process capture. */
|
|
3
3
|
export class ProcessCaptureError extends AnalysisError {
|
|
4
4
|
_tag = "ProcessCaptureError";
|
|
@@ -7,17 +7,33 @@ export class ProcessCaptureError extends AnalysisError {
|
|
|
7
7
|
reason;
|
|
8
8
|
cleanupIncomplete;
|
|
9
9
|
cleanupResources;
|
|
10
|
+
executionFailure;
|
|
11
|
+
partialObservation;
|
|
12
|
+
cleanupReport;
|
|
10
13
|
constructor(message, options) {
|
|
11
14
|
super(message, options);
|
|
12
|
-
this.userMessage = options?.userMessage;
|
|
15
|
+
this.userMessage = options?.userMessage ?? message;
|
|
13
16
|
this.userCategory = options?.userCategory;
|
|
14
17
|
this.reason =
|
|
15
18
|
options?.reason ??
|
|
16
19
|
(options?.userCategory === "cancelled" ? "cancelled" : "capture_failed");
|
|
17
20
|
this.cleanupIncomplete = this.reason === "cleanup_incomplete";
|
|
18
21
|
this.cleanupResources = options?.cleanupResources ?? [];
|
|
22
|
+
this.executionFailure = options?.executionFailure ?? message;
|
|
23
|
+
this.partialObservation = options?.partialObservation;
|
|
24
|
+
this.cleanupReport = options?.cleanupReport;
|
|
19
25
|
}
|
|
20
26
|
}
|
|
27
|
+
/** Return one non-recursive, domain-neutral summary of an execution failure. */
|
|
28
|
+
export const describeProcessCaptureExecutionFailure = (failure) => {
|
|
29
|
+
if (failure instanceof Error)
|
|
30
|
+
return failure.message || failure.name;
|
|
31
|
+
if (typeof failure === "string")
|
|
32
|
+
return failure;
|
|
33
|
+
if (failure === undefined)
|
|
34
|
+
return undefined;
|
|
35
|
+
return "Process capture failed with a non-error rejection.";
|
|
36
|
+
};
|
|
21
37
|
/** Caller-visible cancellation without exposing capture implementation state. */
|
|
22
38
|
export const processCaptureCancelled = () => new ProcessCaptureError("process capture was cancelled", {
|
|
23
39
|
userCategory: "cancelled",
|