rea-agents 6.2.0 → 6.4.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 +24 -23
- package/bridge/ghidra/ReaGhidraApplySeeds.java +151 -0
- package/bridge/ghidra/ReaGhidraBridge.java +597 -209
- package/bridge/ghidra/ReaGhidraNoReturnFix.java +123 -0
- package/bridge/hopper_bridge.py +2 -0
- package/dist/adb/AdbConfiguration.js +88 -0
- package/dist/adb/AdbDeviceOutput.js +186 -0
- package/dist/adb/AdbProvider.js +1190 -0
- package/dist/adb/AdbShellOutput.js +309 -0
- package/dist/android/AndroidTargetSnapshot.js +104 -22
- package/dist/android/JadxConfiguration.js +44 -24
- package/dist/android/JadxProvider.js +59 -21
- package/dist/android/JadxSession.js +51 -9
- package/dist/apktool/ApktoolConfiguration.js +84 -0
- package/dist/apktool/ApktoolDecodeOutput.js +59 -0
- package/dist/apktool/ApktoolProvider.js +506 -0
- package/dist/application/AnalysisProvider.js +8 -2
- package/dist/application/AppBundleExecutable.js +27 -22
- package/dist/application/BinaryTargetResolver.js +85 -19
- package/dist/application/BrowserScenarioEvidence.js +2 -2
- package/dist/application/CapabilityInventory.js +11 -1
- package/dist/application/ClientConfigurationDocument.js +98 -0
- package/dist/application/ClientConfigurationFiles.js +91 -0
- package/dist/application/ClientRegistrationEnvironment.js +35 -0
- package/dist/application/ClientRegistrationStatus.js +75 -27
- package/dist/application/DirectAnalysis.js +14 -8
- package/dist/application/DirectAnalysisCleanup.js +1 -2
- package/dist/application/DirectAnalysisStatus.js +3 -6
- package/dist/application/Doctor.js +27 -34
- package/dist/application/DoctorDiagnostics.js +1 -1
- package/dist/application/EvidenceBundleCommands.js +6 -12
- package/dist/application/EvidenceBundleFiles.js +1 -1
- package/dist/application/GeminiClientSettings.js +139 -0
- package/dist/application/HermesClientHome.js +115 -0
- package/dist/application/HopperDownload.js +39 -0
- package/dist/application/InvestigationProviders.js +10 -4
- package/dist/application/JsonFiles.js +16 -15
- package/dist/application/JsonInputFile.js +252 -0
- package/dist/application/LinuxHopper.js +6 -13
- package/dist/application/MacHopper.js +172 -149
- package/dist/application/MipsElfAbiFlags.js +140 -0
- package/dist/application/ProviderOperationExecution.js +31 -0
- package/dist/application/ReconstructionObligationCandidates.js +16 -3
- package/dist/application/ReconstructionObligationLedgerProjection.js +3 -1
- package/dist/application/ReferenceSourceImport.js +76 -29
- package/dist/application/ReferenceSourceImportEntries.js +18 -9
- package/dist/application/ReferenceSourceImportPolicy.js +99 -23
- package/dist/application/ReferenceSourceImportTypes.js +30 -22
- package/dist/application/ReferenceSourceVcsAdapter.js +145 -30
- package/dist/application/RegularFileRead.js +103 -0
- package/dist/application/Setup.js +69 -10
- package/dist/application/SetupClientConfiguration.js +134 -23
- package/dist/application/SetupHost.js +102 -22
- package/dist/application/SetupPlan.js +18 -17
- package/dist/application/SetupSkill.js +81 -13
- package/dist/application/SupportedClients.js +305 -37
- package/dist/application/Uninstall.js +172 -8
- package/dist/application/UpdateMaintenance.js +23 -23
- package/dist/application/Utf8JsonInput.js +71 -0
- package/dist/application/WebScriptExportService.js +130 -57
- package/dist/application/WebSourceLocationService.js +3 -0
- package/dist/application/adb/AdbDeviceAnalysisPort.js +1 -0
- package/dist/application/adb/AdbDeviceAnalysisService.js +13 -0
- package/dist/application/analysisView/AnalysisViewService.js +40 -2
- package/dist/application/android/AndroidAnalysisService.js +1 -1
- package/dist/application/apktool/ApktoolResourceAnalysisPort.js +1 -0
- package/dist/application/apktool/ApktoolResourceAnalysisService.js +13 -0
- package/dist/application/binary/AnalysisClientCleanup.js +0 -24
- package/dist/application/binary/AnalysisSnapshotCache.js +5 -4
- package/dist/application/binary/BinarySession.js +18 -1
- package/dist/application/binary/BinarySessionOpen.js +9 -1
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +2 -1
- package/dist/application/binaryDiagnostics/PeResourcesPort.js +1 -0
- package/dist/application/binaryDiagnostics/PeResourcesService.js +111 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +2 -1
- package/dist/application/evm/EvmInterfaceService.js +3 -0
- package/dist/application/firmware/FirmwareAnalysisService.js +3 -0
- package/dist/application/investigation/InspectEvidenceBundle.js +18 -0
- package/dist/application/javascript/ElectronActiveEvidence.js +2 -2
- package/dist/application/javascript/ElectronBoundaryAnalysis.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphContext.js +3 -2
- package/dist/application/javascript/ElectronBoundaryGraphIpc.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +20 -3
- package/dist/application/javascript/ElectronBoundaryGraphWindows.js +3 -3
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -0
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +107 -46
- package/dist/application/javascript/JavaScriptApplicationService.js +23 -11
- package/dist/application/javascript/JavaScriptApplicationWorkflowEvidence.js +5 -6
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +59 -45
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +171 -36
- package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +14 -16
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +74 -36
- package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +4 -3
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +11 -5
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +53 -42
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +92 -10
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +293 -238
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +120 -28
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +4 -0
- package/dist/application/javascript/JavaScriptJsonModules.js +2 -2
- package/dist/application/javascript/JavaScriptModuleRelationships.js +10 -20
- package/dist/application/javascript/JavaScriptRecoveryService.js +3 -0
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +11 -27
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +11 -5
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +206 -66
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +18 -23
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +5 -2
- package/dist/application/javascript/JavaScriptSemanticGraphEvidence.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphFingerprintProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +7 -5
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +6 -4
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +4 -4
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +29 -15
- package/dist/application/javascript/JavaScriptSemanticTraceService.js +15 -10
- package/dist/application/jeb/JebAnalysisPort.js +1 -0
- package/dist/application/jeb/JebAnalysisService.js +13 -0
- package/dist/application/managed/ManagedApplicationGraphService.js +1 -1
- package/dist/application/native/NativeCallRoutes.js +2 -4
- package/dist/application/native/NativeUiActionTrace.js +16 -8
- package/dist/application/native/NativeValueTrace.js +23 -6
- package/dist/application/process/ProcessCli.js +25 -20
- package/dist/artifacts/ArtifactPaths.js +129 -8
- package/dist/artifacts/ArtifactProvider.js +34 -31
- package/dist/artifacts/ArtifactProviderMetadata.js +1 -4
- package/dist/artifacts/ArtifactReader.js +23 -0
- package/dist/artifacts/ArtifactResourceScope.js +100 -0
- package/dist/artifacts/AsarArtifactReader.js +218 -80
- package/dist/artifacts/AsarHeader.js +24 -0
- package/dist/artifacts/DirectoryArtifactReader.js +168 -65
- package/dist/artifacts/MachOSliceArtifactReader.js +116 -39
- package/dist/artifacts/NativeDmgArtifactReader.js +179 -87
- package/dist/artifacts/NativeDmgOwnership.js +109 -0
- package/dist/artifacts/SafeOutputTree.js +245 -70
- package/dist/artifacts/SafeOutputTreeCleanup.js +45 -0
- package/dist/artifacts/SafeOutputTreeCreationFailure.js +20 -0
- package/dist/artifacts/SafeOutputTreeIdentity.js +42 -0
- package/dist/artifacts/SafeOutputTreeReadback.js +33 -0
- package/dist/artifacts/ZipArtifactReader.js +77 -27
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +58 -18
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +62 -24
- package/dist/artifacts/apple/KeyedArchiveReader.js +76 -49
- package/dist/artifacts/apple/MachoLoadCommandReader.js +36 -6
- package/dist/artifacts/extraction/ArtifactExtraction.js +134 -92
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +116 -50
- package/dist/artifacts/inventory/ArtifactInventory.js +5 -4
- package/dist/artifacts/inventory/classify.js +87 -25
- package/dist/artifacts/inventory/hashStableRootArtifact.js +70 -0
- package/dist/artifacts/inventory/reader.js +13 -5
- package/dist/artifacts/inventory/scanCanonical.js +73 -30
- package/dist/artifacts/inventory/scanReader.js +43 -20
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +72 -28
- package/dist/artifacts/javascript/JavaScriptSourceAnalysis.js +3 -0
- package/dist/browser/BrowserScenarioPartialObservation.js +8 -2
- package/dist/browser/BrowserScenarioSecrets.js +52 -37
- package/dist/browser/CdpBrowserProvider.js +9 -3
- package/dist/browser/CdpCaptureDocuments.js +40 -6
- package/dist/browser/CdpCaptureDomSvg.js +210 -0
- package/dist/browser/CdpCaptureEventBodyShapes.js +4 -8
- package/dist/browser/CdpCaptureEventHandlers.js +26 -9
- package/dist/browser/CdpCaptureEvents.js +4 -9
- package/dist/browser/CdpCaptureStorageFingerprints.js +3 -3
- package/dist/browser/CdpConnection.js +22 -5
- package/dist/browser/CdpElectronInspection.js +2 -2
- package/dist/browser/CdpElectronProvider.js +4 -3
- package/dist/browser/CdpElectronScripts.js +2 -2
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpTargetSession.js +30 -34
- package/dist/browser/CdpWebMcpDiscovery.js +48 -23
- package/dist/browser/ElectronFileScope.js +99 -9
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +63 -7
- package/dist/browser/PlaywrightElectronActiveProvider.js +11 -6
- package/dist/browser/PlaywrightScenarioArtifacts.js +5 -5
- package/dist/browser/PlaywrightScenarioBrowser.js +208 -43
- package/dist/browser/PlaywrightScenarioSession.js +130 -65
- package/dist/browser/PlaywrightScenarioStorage.js +507 -0
- package/dist/browser/PngVisualDiff.js +198 -29
- package/dist/browser/WebSourceMapFetcher.js +35 -9
- package/dist/browser/assets/LocalWebScriptArtifacts.js +3 -1
- package/dist/browser/assets/PublishWebScripts.js +75 -20
- package/dist/browser/assets/ScenarioScriptCapture.js +8 -12
- package/dist/browser/assets/WebArtifactReads.js +23 -1
- package/dist/browser/assets/WebSourceLocationArtifacts.js +1 -0
- package/dist/browser/execution/CdpExecutionCapture.js +3 -3
- package/dist/browser/execution/CdpPreciseCoverage.js +5 -8
- package/dist/browser/history/HarCapture.js +14 -0
- package/dist/browser/history/HarCaptureProcess.js +2 -10
- package/dist/browser/history/MitmproxyCaptureAdapter.js +3 -1
- package/dist/browser/modules/WebModuleArtifacts.js +1 -0
- package/dist/cli/adbCommands.js +337 -0
- package/dist/cli/analysisViewCommands.js +39 -1
- package/dist/cli/apktoolCommands.js +53 -0
- package/dist/cli/artifactCommands.js +8 -11
- package/dist/cli/binaryDiagnosticsCommands.js +19 -1
- package/dist/cli/browserAdvancedCommands.js +65 -36
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +12 -13
- package/dist/cli/coreNativeCommands.js +1 -14
- package/dist/cli/electronCommands.js +14 -10
- package/dist/cli/evmCommands.js +13 -4
- package/dist/cli/firmwareCommands.js +7 -2
- package/dist/cli/javascriptApplicationAnalysis.js +19 -13
- package/dist/cli/javascriptRecoveryCommands.js +22 -15
- package/dist/cli/jebCommands.js +99 -0
- package/dist/cli/jsonOutput.js +12 -4
- package/dist/cli/referenceSourceImportStatus.js +7 -0
- package/dist/cli/setupCommands.js +15 -3
- package/dist/cli/streamedJsonOutput.js +83 -4
- package/dist/cli/utilityCommands.js +68 -22
- package/dist/cli/webScriptCommands.js +20 -1
- package/dist/cli/webSourceLocationCommands.js +21 -9
- package/dist/cli.js +11 -2
- package/dist/cliBrowserScenarioCommands.js +2 -1
- package/dist/cliCommandNames.js +32 -0
- package/dist/cliJsonInput.js +47 -34
- package/dist/cliObservationOptions.js +7 -0
- package/dist/composition/adb.js +3 -0
- package/dist/composition/apktool.js +3 -0
- package/dist/composition/auxiliaryAnalysisProviders.js +5 -4
- package/dist/composition/binaryDiagnostics.js +4 -0
- package/dist/composition/browserScenario.js +2 -2
- package/dist/composition/directAnalysis.js +14 -7
- package/dist/composition/javascriptAnalysisWorkerProcess.js +48 -0
- package/dist/composition/jeb.js +6 -0
- package/dist/config/environment.js +10 -0
- package/dist/config/ghidraLanguageOverride.js +9 -0
- package/dist/config/mcpInputSchemaProfile.js +27 -0
- package/dist/config/parseConfig.js +28 -1
- package/dist/contracts/adb/adbToolContracts.js +353 -0
- package/dist/contracts/advertisedInputExamples.js +48 -0
- package/dist/contracts/analysisDetail.js +10 -0
- package/dist/contracts/analysisViewToolContracts.js +17 -2
- package/dist/contracts/apktool/apktoolToolContracts.js +33 -0
- package/dist/contracts/artifactComparisonExample.js +5 -5
- package/dist/contracts/artifactToolContracts.js +8 -5
- package/dist/contracts/browserToolContracts.js +1 -1
- package/dist/contracts/compactInputSchema.js +256 -0
- package/dist/contracts/errorSchemas.js +3 -1
- package/dist/contracts/functionComparisonExample.js +8 -0
- package/dist/contracts/functionWorkflowToolContracts.js +1 -1
- package/dist/contracts/inputSchemaPresentation.js +104 -13
- package/dist/contracts/javascript/electronToolContracts.js +16 -3
- package/dist/contracts/javascript/javascriptApplicationWorkflowExamples.js +3 -2
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +6 -3
- package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +1 -1
- package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +8 -7
- package/dist/contracts/jeb/jebToolContracts.js +64 -0
- package/dist/contracts/managed/managedToolContracts.js +3 -2
- package/dist/contracts/mobileApplicationGraphExamples.js +5 -5
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +25 -3
- package/dist/contracts/native/nativeToolContracts.js +1 -1
- package/dist/contracts/officialToolContracts.js +5 -5
- package/dist/contracts/sessionLifecycleInputs.js +4 -3
- package/dist/contracts/sessionStatusContract.js +3 -2
- package/dist/contracts/sessionToolContracts.js +5 -4
- package/dist/contracts/sessionToolSchemas.js +9 -4
- package/dist/contracts/toolContractExamples.js +6 -0
- package/dist/contracts/toolContractTypes.js +3 -0
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +167 -0
- package/dist/contracts/toolOutputSchemaGroups.js +7 -5
- package/dist/contracts/toolOutputSchemaPrimitives.js +2 -5
- package/dist/contracts/toolSchemaMetadata.js +82 -7
- package/dist/domain/adb/adbDeviceAnalysis.js +583 -0
- package/dist/domain/analysisErrorBase.js +5 -0
- package/dist/domain/analysisErrorCleanup.js +29 -0
- package/dist/domain/analysisErrorPresentation.js +18 -4
- package/dist/domain/analysisErrorProjection.js +4 -1
- package/dist/domain/analysisSnapshot.js +5 -2
- package/dist/domain/analysisView/analysisView.js +53 -5
- package/dist/domain/analysisView/binaryLayoutView.js +2 -0
- package/dist/domain/analysisView/javascriptApplicationView.js +2 -0
- package/dist/domain/analysisView/nativeFunctionView.js +155 -0
- package/dist/domain/android/androidApplication.js +25 -20
- package/dist/domain/android/androidPartialObservation.js +36 -0
- package/dist/domain/apktool/apktoolResourceAnalysis.js +77 -0
- package/dist/domain/apple/appleApplication.js +40 -23
- package/dist/domain/apple/appleBundleAnatomy.js +95 -28
- package/dist/domain/apple/dyldPaths.js +9 -1
- package/dist/domain/apple/dylibResolution.js +3 -3
- package/dist/domain/apple/interfaceBuilderGraph.js +22 -19
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +10 -1
- package/dist/domain/artifactComparison.js +39 -11
- package/dist/domain/artifactGraph.js +6 -4
- package/dist/domain/artifactIdentity.js +37 -9
- package/dist/domain/artifactInspection.js +10 -50
- package/dist/domain/artifactIntegrityPolicy.js +10 -0
- package/dist/domain/artifactInventoryEvidence.js +16 -17
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/binaryTarget.js +16 -0
- package/dist/domain/binaryTargetTypes.js +8 -1
- package/dist/domain/browserCompleteness.js +3 -2
- package/dist/domain/browserObservationSchemas.js +8 -4
- package/dist/domain/browserScenarioCaptureValues.js +2 -2
- package/dist/domain/browserScenarioNormalization.js +3 -3
- package/dist/domain/browserScenarioValues.js +3 -2
- package/dist/domain/callPath.js +8 -10
- package/dist/domain/canonicalDigest.js +7 -1
- package/dist/domain/canonicalJsonDigestSteps.js +34 -12
- package/dist/domain/canonicalOrdering.js +1 -13
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/compactStringIdentity.js +9 -0
- package/dist/domain/comparisonSemantics.js +0 -5
- package/dist/domain/digests.js +0 -3
- package/dist/domain/evidence.js +12 -6
- package/dist/domain/evidenceBundle.js +51 -33
- package/dist/domain/evidenceRecordSummary.js +144 -0
- package/dist/domain/firmware/firmwareAnalysis.js +4 -3
- package/dist/domain/functionComparison.js +2 -1
- package/dist/domain/functionComparisonNormalization.js +4 -3
- package/dist/domain/functionComparisonResults.js +2 -2
- package/dist/domain/functionDossierEvidence.js +2 -1
- package/dist/domain/hopperValues.js +11 -15
- package/dist/domain/inputIssueProjection.js +16 -1
- package/dist/domain/javascript/electronActiveObservation.js +4 -3
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +14 -15
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +20 -21
- package/dist/domain/javascript/electronStaticAnalysisNative.js +73 -41
- package/dist/domain/javascript/electronStaticAnalysisValues.js +24 -4
- package/dist/domain/javascript/javascriptAnalysisResourceControls.js +45 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +6 -1
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +18 -14
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +4 -0
- package/dist/domain/javascript/javascriptApplicationGraph.js +91 -28
- package/dist/domain/javascript/javascriptApplicationProjectionResources.js +35 -0
- package/dist/domain/javascript/javascriptApplicationVersionComparison.js +4 -4
- package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +37 -22
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +72 -45
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +16 -8
- package/dist/domain/javascript/javascriptAstFingerprint.js +60 -33
- package/dist/domain/javascript/javascriptAstValues.js +54 -0
- package/dist/domain/javascript/javascriptElectronMemberWrites.js +50 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +3 -2
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +31 -23
- package/dist/domain/javascript/javascriptExportShapeSelection.js +2 -2
- package/dist/domain/javascript/javascriptExportShapeVariants.js +3 -2
- package/dist/domain/javascript/javascriptFeatureSeed.js +5 -3
- package/dist/domain/javascript/javascriptFeatureTrace.js +7 -6
- package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +17 -9
- package/dist/domain/javascript/javascriptFeatureTraversal.js +4 -4
- package/dist/domain/javascript/javascriptModuleSemanticIr.js +15 -0
- package/dist/domain/javascript/javascriptNativeHandoff.js +12 -7
- package/dist/domain/javascript/javascriptRpcEndpoints.js +253 -0
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +1 -3
- package/dist/domain/javascript/javascriptRuntimeObservation.js +8 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliation.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationActive.js +9 -8
- package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +212 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationInputValidation.js +28 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +5 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliationParsing.js +12 -223
- package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +15 -17
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +379 -30
- package/dist/domain/javascript/javascriptSemanticCallResolution.js +9 -7
- package/dist/domain/javascript/javascriptSemanticCallableResults.js +42 -0
- package/dist/domain/javascript/javascriptSemanticCalls.js +8 -1
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +2 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +20 -0
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +7 -9
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +4 -11
- package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +15 -4
- package/dist/domain/javascript/javascriptSemanticFileProjection.js +1 -0
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +43 -42
- package/dist/domain/javascript/javascriptSemanticGraph.js +205 -52
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +21 -11
- package/dist/domain/javascript/javascriptSemanticIr.js +0 -4
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +139 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +774 -136
- package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +190 -0
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +98 -41
- package/dist/domain/javascript/javascriptSemanticObjectReferences.js +381 -0
- package/dist/domain/javascript/javascriptSemanticObjects.js +9 -7
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +7 -2
- package/dist/domain/javascript/javascriptSemanticProjection.js +72 -28
- package/dist/domain/javascript/javascriptSemanticPromises.js +15 -21
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +100 -0
- package/dist/domain/javascript/javascriptSemanticProvenance.js +3 -3
- package/dist/domain/javascript/javascriptSemanticQuery.js +33 -29
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +4 -5
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -9
- package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +16 -10
- package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +219 -0
- package/dist/domain/javascript/javascriptSemanticReturns.js +34 -48
- package/dist/domain/javascript/javascriptSemanticState.js +22 -2
- package/dist/domain/javascript/javascriptSemanticTraversal.js +25 -2
- package/dist/domain/javascript/javascriptSemanticValues.js +169 -30
- package/dist/domain/javascript/javascriptSourceAnalysis.js +1 -0
- package/dist/domain/javascript/javascriptSourceMapPaths.js +11 -1
- package/dist/domain/javascript/javascriptSourceParser.js +34 -9
- package/dist/domain/javascript/javascriptStaticAnalysis.js +29 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +13 -12
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +49 -5
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +8 -4
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +26 -15
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +1 -0
- package/dist/domain/javascript/sourceToBundleComparison.js +7 -5
- package/dist/domain/javascript/sourceToBundleSignals.js +7 -7
- package/dist/domain/jeb/jebAnalysis.js +114 -0
- package/dist/domain/jsonSerialization.js +109 -55
- package/dist/domain/jsonShape.js +69 -31
- package/dist/domain/jsonValue.js +3 -0
- package/dist/domain/localPath.js +10 -4
- package/dist/domain/managed/managedApplicationGraph.js +47 -6
- package/dist/domain/managed/managedApplicationGraphCoverage.js +8 -2
- package/dist/domain/managed/managedApplicationGraphNodes.js +94 -59
- package/dist/domain/managed/managedArtifact.js +1 -0
- package/dist/domain/managed/managedInspectionEvidence.js +13 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +6 -7
- package/dist/domain/native/nativeAotPe.js +1408 -0
- package/dist/domain/native/nativeCallObservation.js +2 -4
- package/dist/domain/native/nativeInstruction.js +21 -0
- package/dist/domain/native/nativeMetadataRecovery.js +79 -6
- package/dist/domain/native/nativeValueFlow.js +5 -11
- package/dist/domain/native/objcSwiftMetadata.js +15 -17
- package/dist/domain/native/peResources.js +94 -0
- package/dist/domain/nativeConvention.js +33 -0
- package/dist/domain/process/processCapture.js +102 -11
- package/dist/domain/process/processCaptureCoverage.js +8 -5
- package/dist/domain/process/processCaptureExample.js +67 -0
- package/dist/domain/process/processCaptureValidation.js +83 -3
- package/dist/domain/process/processComparison.js +0 -23
- package/dist/domain/process/processScenario.js +62 -10
- package/dist/domain/process/processTraceEvaluation.js +4 -4
- package/dist/domain/process/processTraceSpecification.js +1 -3
- package/dist/domain/propertyListKeys.js +3 -1
- package/dist/domain/providerCleanupError.js +6 -2
- package/dist/domain/reconstructionCoverage.js +2 -1
- package/dist/domain/reconstructionUnknowns.js +4 -3
- package/dist/domain/reconstructionVerification.js +3 -2
- package/dist/domain/referenceSourceGraph.js +32 -23
- package/dist/domain/referenceSourceImportParsing.js +40 -48
- package/dist/domain/referenceSourcePathIdentity.js +22 -0
- package/dist/domain/referenceSourceRequireBindings.js +137 -0
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +2 -1
- package/dist/domain/swiftSymbolClassification.js +6 -1
- package/dist/domain/symbolAnalysis.js +17 -2
- package/dist/domain/unicodeCodePointOrder.js +6 -0
- package/dist/domain/webBundleAnalyzerInspection.js +23 -3
- package/dist/domain/webCaptureDiff.js +170 -30
- package/dist/domain/webCaptureDiffSchemas.js +2 -8
- package/dist/domain/webInventory.js +3 -2
- package/dist/domain/webMcpDiscovery.js +4 -3
- package/dist/domain/webScriptExport.js +1 -1
- package/dist/domain/webScriptExportError.js +10 -4
- package/dist/domain/webScriptExportPlan.js +7 -13
- package/dist/domain/zipPackageFormat.js +4 -1
- package/dist/domain/zodCollectionSteps.js +24 -0
- package/dist/dotnet/ManagedArtifactInspector.js +55 -43
- package/dist/dotnet/ManagedDecodeBudget.js +80 -0
- package/dist/dotnet/ManagedMemberInspector.js +13 -6
- package/dist/dotnet/ManagedMemberInspectorCore.js +2 -2
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +5 -4
- package/dist/dotnet/ManagedMemberRows.js +9 -4
- package/dist/dotnet/ManagedMetadataHeaps.js +15 -5
- package/dist/dotnet/ManagedMetadataInventoryRows.js +20 -11
- package/dist/dotnet/ManagedMetadataLayout.js +10 -4
- package/dist/dotnet/ManagedMethodBodyReader.js +8 -3
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +3 -2
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +49 -34
- package/dist/dotnet/ManagedPeReader.js +41 -25
- package/dist/dotnet/ManagedReaderFailure.js +2 -1
- package/dist/dotnet/ManagedStaticProvider.js +65 -31
- package/dist/dotnet/ManagedStaticProviderMetadata.js +1 -4
- package/dist/evaluation/AgentEvaluationReport.js +9 -5
- package/dist/evaluation/CodexAgentEval.js +43 -13
- package/dist/evm/EvmoleFailures.js +0 -2
- package/dist/evm/EvmoleInterfaceProvider.js +67 -2
- package/dist/filesystem/OwnedDirectoryHandle.js +29 -0
- package/dist/filesystem/OwnedFileHandle.js +36 -0
- package/dist/filesystem/RegularFile.js +73 -0
- package/dist/filesystem/StableFileHash.js +46 -0
- package/dist/filesystem/readFileHandleChunks.js +26 -0
- package/dist/firmware/FirmwareCommand.js +25 -3
- package/dist/firmware/FirmwareFiles.js +23 -8
- package/dist/firmware/FirmwareProvider.js +156 -32
- package/dist/firmware/FirmwarePublication.js +24 -3
- package/dist/firmware/FirmwareRelease.js +1 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +55 -4
- package/dist/ghidra/GhidraAnalysisSeeds.js +211 -0
- package/dist/ghidra/GhidraClient.js +90 -8
- package/dist/ghidra/GhidraDiagnostics.js +11 -8
- package/dist/ghidra/GhidraFunctionValues.js +26 -2
- package/dist/ghidra/GhidraInstallation.js +111 -10
- package/dist/ghidra/GhidraInventoryValues.js +23 -1
- package/dist/ghidra/GhidraLanguageCatalog.js +99 -0
- package/dist/ghidra/GhidraLauncher.js +123 -58
- package/dist/ghidra/GhidraLoadImageAttest.js +49 -2
- package/dist/ghidra/GhidraMipsProfile.js +79 -0
- package/dist/ghidra/GhidraProvider.js +57 -9
- package/dist/ghidra/GhidraProviderCapabilities.js +18 -8
- package/dist/ghidra/GhidraProviderClient.js +282 -21
- package/dist/ghidra/GhidraSessionValues.js +9 -2
- package/dist/hopper/HopperAnalysisProfile.js +2 -0
- package/dist/hopper/HopperCleanup.js +1 -1
- package/dist/hopper/HopperClient.js +15 -6
- package/dist/hopper/HopperMachOImage.js +2 -0
- package/dist/hopper/HopperProvider.js +13 -2
- package/dist/ida/IdaOperationRunner.js +10 -2
- package/dist/ida/IdaProvider.js +7 -0
- package/dist/ida/IdaSessionClient.js +7 -3
- package/dist/ida/IdaWorkspace.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -5
- package/dist/inspector/V8InspectorCaptureProjection.js +46 -13
- package/dist/inspector/V8InspectorProvider.js +60 -8
- package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +326 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +520 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +63 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +521 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +116 -0
- package/dist/javascript/recovery/RecoveryFiles.js +18 -7
- package/dist/javascript/recovery/WakaruCommand.js +22 -9
- package/dist/javascript/recovery/WakaruExecution.js +11 -7
- package/dist/javascript/recovery/WakaruProvider.js +139 -16
- package/dist/javascript/recovery/WakaruPublication.js +14 -4
- package/dist/javascript/recovery/WakaruRelease.js +10 -3
- package/dist/javascript/recovery/WakaruReport.js +12 -7
- package/dist/javascript/recovery/WakaruVersion.js +24 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +16 -3
- package/dist/javascript/sourceMaps/SourceMapDecoder.js +63 -7
- package/dist/javascript/sourceMaps/SourceMapFormat.js +15 -4
- package/dist/jeb/JebMcpConnection.js +179 -0
- package/dist/jeb/JebMcpEndpoint.js +40 -0
- package/dist/jeb/JebProvider.js +299 -0
- package/dist/main/shutdown.js +76 -32
- package/dist/main/transport.js +1 -1
- package/dist/mcpDoctor.js +15 -6
- package/dist/native/AppleDispatchCoverage.js +25 -12
- package/dist/native/AppleDispatchMetadata.js +14 -7
- package/dist/native/AppleMachoFixups.js +71 -15
- package/dist/native/AppleMachoSelection.js +23 -3
- package/dist/native/AppleObjcDispatchFacets.js +3 -3
- package/dist/native/AppleObjcProperties.js +17 -7
- package/dist/native/LldbCallTracer.js +241 -75
- package/dist/native/NativeMacOSProvider.js +100 -20
- package/dist/native/NativeMacOSProviderMetadata.js +1 -2
- package/dist/native/NativeMachoInspection.js +11 -7
- package/dist/native/NativeUiHelperRuntime.js +6 -1
- package/dist/native/NativeUiObservation.js +4 -3
- package/dist/native/pe/PeResourceLayout.js +120 -0
- package/dist/native/pe/PeResourceParser.js +286 -0
- package/dist/native/pe/PeResourcesProvider.js +63 -0
- package/dist/process/BoundedFileBytes.js +30 -7
- package/dist/process/DarwinProcessRunTokenReader.js +8 -3
- package/dist/process/OwnedCommand.js +4 -3
- package/dist/process/ProcessOwnership.js +104 -112
- package/dist/process/ProcessOwnershipObservation.js +104 -51
- package/dist/process/ProcessOwnershipProcessTree.js +4 -4
- package/dist/process/ProcessRunTokenObservations.js +48 -0
- package/dist/process/ProviderDiagnosticRedaction.js +17 -0
- package/dist/process/ProviderProcess.js +4 -3
- package/dist/process/capture/FilesystemSnapshot.js +116 -22
- package/dist/process/capture/ProcessCaptureLifecycle.js +363 -86
- package/dist/process/capture/ProcessCaptureProgress.js +62 -0
- package/dist/process/capture/ProcessFilesystemEffects.js +19 -4
- package/dist/process/capture/ProcessHarness.js +202 -47
- package/dist/process/capture/ProcessNormalization.js +3 -1
- package/dist/process/capture/ProcessScenarioRuntimeValidation.js +5 -2
- package/dist/process/capture/TerminalRenderer.js +24 -7
- package/dist/reference/ReferenceSourceReader.js +22 -5
- package/dist/reference/ReferenceSourceReaderEntries.js +114 -51
- package/dist/reference/ReferenceSourceReaderErrors.js +12 -0
- package/dist/reference/ReferenceSourceReaderFile.js +50 -10
- package/dist/reference/ReferenceSourceReaderValidate.js +4 -4
- package/dist/server/EvidenceMcpServer.js +36 -1
- package/dist/server/admittedToolOperation.js +9 -0
- package/dist/server/analysisAdmission.js +8 -0
- package/dist/server/contractToolHandler.js +21 -0
- package/dist/server/createServer.js +118 -47
- package/dist/server/registerAdbTools.js +36 -0
- package/dist/server/registerAnalysisViewTool.js +4 -9
- package/dist/server/registerAndroidTools.js +3 -12
- package/dist/server/registerApktoolTools.js +14 -0
- package/dist/server/registerApplicationTools/compareExportShapes.js +6 -7
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +4 -5
- package/dist/server/registerApplicationTools/compareVersions.js +3 -2
- package/dist/server/registerApplicationTools/coverage.js +3 -2
- package/dist/server/registerApplicationTools/helpers.js +3 -2
- package/dist/server/registerApplicationTools/obligationLedger.js +3 -2
- package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +3 -2
- package/dist/server/registerApplicationTools/traceFeature.js +3 -2
- package/dist/server/registerApplicationTools/traceSemantics.js +4 -5
- package/dist/server/registerArtifactComparisonTool.js +5 -2
- package/dist/server/registerArtifactTools.js +2 -2
- package/dist/server/registerBinaryDiagnosticsTools.js +16 -4
- package/dist/server/registerBrowserScenarioTool.js +10 -7
- package/dist/server/registerBrowserTools.js +12 -9
- package/dist/server/registerBundleComparisonTool.js +16 -2
- package/dist/server/registerCloseLifecycleTool.js +36 -5
- package/dist/server/registerElectronTools.js +28 -10
- package/dist/server/registerEnhancedTools.js +78 -73
- package/dist/server/registerEvidenceTools.js +54 -46
- package/dist/server/registerEvmTools.js +4 -9
- package/dist/server/registerFirmwareTools.js +3 -11
- package/dist/server/registerFunctionComparisonTool.js +5 -2
- package/dist/server/registerJavaScriptRecoveryTool.js +4 -9
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +9 -6
- package/dist/server/registerJebTools.js +16 -0
- package/dist/server/registerManagedTools.js +7 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -6
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -2
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +3 -2
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +3 -2
- package/dist/server/registerOfficialTools.js +31 -25
- package/dist/server/registerPeResourcesTool.js +9 -0
- package/dist/server/registerProcessComparisonTool.js +5 -2
- package/dist/server/registerRecordedCrashTools.js +4 -9
- package/dist/server/registerSessionRecordTools.js +2 -1
- package/dist/server/registerSessionTools.js +58 -21
- package/dist/server/registerWebModuleTool.js +4 -9
- package/dist/server/registerWebNetworkCaptureTool.js +4 -9
- package/dist/server/registerWebRuntimeTools.js +6 -5
- package/dist/server/registerWebScriptTool.js +6 -3
- package/dist/server/registerWebSourceLocationTool.js +4 -9
- package/dist/server/toolResult.js +21 -2
- package/dist/windows/WindowsPrivateRuntime.js +12 -5
- package/install.sh +7 -4
- package/licenses/nativeaot-parser-MIT.txt +28 -0
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +38 -7
- package/scripts/rea.mjs +16 -1
- package/skills/reverse-engineer-anything/SKILL.md +52 -51
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +8 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +92 -13
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +31 -1
- package/dist/artifacts/inventory/policy.js +0 -2
- package/dist/domain/managed/managedApplicationGraphNodeCoverage.js +0 -6
- package/dist/server/registerNativeTools.js +0 -6
|
@@ -29,25 +29,51 @@ const architectureFor = (machine) => {
|
|
|
29
29
|
throw managedFailure("invalid-directory", "pe.machine", `Unsupported PE machine 0x${machine.toString(16).padStart(4, "0")}`);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
/** Resolve one section identity for both exact reads and available-byte queries. */
|
|
33
|
+
const resolveRva = (mapping) => {
|
|
33
34
|
const { bytes, sections, rva, size, scope } = mapping;
|
|
34
|
-
if (rva
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
if (!Number.isSafeInteger(rva) ||
|
|
36
|
+
!Number.isSafeInteger(size) ||
|
|
37
|
+
rva < 0 ||
|
|
38
|
+
size < 0 ||
|
|
39
|
+
rva > 0xffff_ffff ||
|
|
40
|
+
(size > 0 && size > 0x1_0000_0000 - rva))
|
|
41
|
+
throw managedFailure("invalid-directory", scope, `${scope} has an invalid RVA range`);
|
|
42
|
+
// VirtualSize owns RVA containment; raw size also includes alignment padding.
|
|
43
|
+
const selected = sections.find((section) => {
|
|
40
44
|
const within = rva - section.virtualAddress;
|
|
41
|
-
|
|
45
|
+
return (section.virtualSize > 0 &&
|
|
46
|
+
within >= 0 &&
|
|
47
|
+
within < section.virtualSize &&
|
|
48
|
+
size <= section.virtualSize - within);
|
|
49
|
+
});
|
|
50
|
+
if (selected === undefined)
|
|
51
|
+
throw managedFailure("invalid-directory", scope, `${scope} RVA is not covered by one PE section`);
|
|
52
|
+
for (const section of sections) {
|
|
53
|
+
if (section === selected || section.virtualSize === 0)
|
|
42
54
|
continue;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
const end = section.virtualAddress + section.virtualSize;
|
|
56
|
+
const intersects = size === 0
|
|
57
|
+
? rva >= section.virtualAddress && rva < end
|
|
58
|
+
: rva < end && rva + size > section.virtualAddress;
|
|
59
|
+
if (intersects)
|
|
60
|
+
throw managedFailure("invalid-directory", scope, `${scope} RVA range has ambiguous overlapping PE section mappings`);
|
|
48
61
|
}
|
|
49
|
-
|
|
62
|
+
const within = rva - selected.virtualAddress;
|
|
63
|
+
if (within > selected.rawSize || size > selected.rawSize - within)
|
|
64
|
+
throw managedFailure("invalid-directory", scope, `${scope} occupies virtual bytes without file-backed data`);
|
|
65
|
+
const offset = add(selected.rawOffset, within, scope);
|
|
66
|
+
requireRange(bytes, offset, size, scope);
|
|
67
|
+
let available = Math.min(selected.virtualSize - within, selected.rawSize - within, bytes.length - offset, 0x1_0000_0000 - rva);
|
|
68
|
+
// A future overlap ends the uniquely mapped extent even if the current byte is unique.
|
|
69
|
+
for (const section of sections)
|
|
70
|
+
if (section !== selected &&
|
|
71
|
+
section.virtualAddress > rva &&
|
|
72
|
+
section.virtualSize > 0)
|
|
73
|
+
available = Math.min(available, section.virtualAddress - rva);
|
|
74
|
+
return { offset, available };
|
|
50
75
|
};
|
|
76
|
+
const mapRva = (mapping) => mapping.rva === 0 && mapping.size === 0 ? 0 : resolveRva(mapping).offset;
|
|
51
77
|
const readDirectory = (bytes, offset) => {
|
|
52
78
|
requireRange(bytes, offset, 8, "pe.data-directory");
|
|
53
79
|
return {
|
|
@@ -186,16 +212,6 @@ export const readManagedPeLayout = (bytes) => {
|
|
|
186
212
|
cliDirectoryPresent,
|
|
187
213
|
cliIssue,
|
|
188
214
|
rvaToOffset: (rva, size, scope) => mapRva({ bytes, sections, rva, size, scope }),
|
|
189
|
-
rvaAvailableBytes: (rva, scope) => {
|
|
190
|
-
mapRva({ bytes, sections, rva, size: 1, scope });
|
|
191
|
-
for (const section of sections) {
|
|
192
|
-
if (rva < section.virtualAddress)
|
|
193
|
-
continue;
|
|
194
|
-
const within = rva - section.virtualAddress;
|
|
195
|
-
if (within < section.rawSize)
|
|
196
|
-
return Math.min(section.rawSize - within, bytes.length - section.rawOffset - within);
|
|
197
|
-
}
|
|
198
|
-
throw managedFailure("invalid-directory", scope, `${scope} RVA is not covered by file-backed PE section data`);
|
|
199
|
-
},
|
|
215
|
+
rvaAvailableBytes: (rva, scope) => resolveRva({ bytes, sections, rva, size: 1, scope }).available,
|
|
200
216
|
};
|
|
201
217
|
};
|
|
@@ -14,7 +14,8 @@ export const readManagedValue = (operation, issues) => {
|
|
|
14
14
|
return operation();
|
|
15
15
|
}
|
|
16
16
|
catch (cause) {
|
|
17
|
-
if (!(cause instanceof ManagedReaderFailure)
|
|
17
|
+
if (!(cause instanceof ManagedReaderFailure) ||
|
|
18
|
+
cause.issue.code === "resource-limit")
|
|
18
19
|
throw cause;
|
|
19
20
|
issues.push(cause.issue);
|
|
20
21
|
return undefined;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { createReadStream } from "node:fs";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
2
|
import { createAnalysisExecution, } from "../application/AnalysisProvider.js";
|
|
5
|
-
import {
|
|
3
|
+
import { managedStaticCapabilities } from "./ManagedStaticProviderMetadata.js";
|
|
4
|
+
import { MANAGED_STATIC_PROVIDER } from "../application/InvestigationProviders.js";
|
|
6
5
|
import { MANAGED_TOOL_CONTRACTS, managedTargetInputSchema, } from "../contracts/managed/managedToolContracts.js";
|
|
7
|
-
import {
|
|
6
|
+
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
|
7
|
+
import { AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisResourceConstraintError, } from "../domain/analysisErrorCore.js";
|
|
8
8
|
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
|
9
9
|
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
|
10
10
|
import { err, ok } from "../domain/result.js";
|
|
11
11
|
import { inspectManagedArtifactBytes } from "./ManagedArtifactInspector.js";
|
|
12
12
|
import { inspectManagedMembersBytes } from "./ManagedMemberInspector.js";
|
|
13
13
|
import { inspectManagedNativeBoundariesBytes } from "./ManagedNativeBoundaryInspector.js";
|
|
14
|
+
import { openRegularFile } from "../filesystem/RegularFile.js";
|
|
15
|
+
import { readBoundedFileBytes } from "../process/BoundedFileBytes.js";
|
|
16
|
+
// This provider eagerly retains the full PE snapshot. Keep its input resource
|
|
17
|
+
// policy separate from decoded metadata/output capacity; it is not a PE format limit.
|
|
18
|
+
const MAX_MANAGED_SNAPSHOT_BYTES = 128 * 1024 * 1024;
|
|
19
|
+
const snapshotCapacityError = (operation) => new AnalysisResourceConstraintError(operation, "memory", "Managed static inspection requires an eagerly retained PE snapshot within its input byte budget.", { max_snapshot_bytes: MAX_MANAGED_SNAPSHOT_BYTES });
|
|
14
20
|
/** Execution-free managed PE/CLI auxiliary provider. */
|
|
15
21
|
export class ManagedStaticProvider {
|
|
16
22
|
#capabilities = managedStaticCapabilities();
|
|
17
23
|
identity() {
|
|
18
|
-
return
|
|
24
|
+
return MANAGED_STATIC_PROVIDER;
|
|
19
25
|
}
|
|
20
26
|
capabilities() {
|
|
21
27
|
return this.#capabilities;
|
|
@@ -32,18 +38,18 @@ class ManagedStaticClient {
|
|
|
32
38
|
}
|
|
33
39
|
async execute(operation, parameters, options) {
|
|
34
40
|
if (operation === "health")
|
|
35
|
-
return ok(createAnalysisExecution(null,
|
|
41
|
+
return ok(createAnalysisExecution(null, MANAGED_STATIC_PROVIDER));
|
|
36
42
|
if (!isManagedOperation(operation))
|
|
37
|
-
return err(new AnalysisCapabilityUnavailableError(
|
|
43
|
+
return err(new AnalysisCapabilityUnavailableError(MANAGED_STATIC_PROVIDER.id, operation, "Operation is not implemented by the managed static provider."));
|
|
38
44
|
if (this.target.format !== "pe")
|
|
39
|
-
return err(new AnalysisCapabilityUnavailableError(
|
|
45
|
+
return err(new AnalysisCapabilityUnavailableError(MANAGED_STATIC_PROVIDER.id, operation, `Managed static triage requires a PE target; observed ${this.target.format}.`));
|
|
40
46
|
try {
|
|
41
47
|
if (options?.signal?.aborted === true)
|
|
42
48
|
return err(new AnalysisCancelledError(operation));
|
|
43
49
|
const snapshot = this.#snapshotBytes;
|
|
44
50
|
const observed = snapshot === undefined
|
|
45
|
-
? await readManagedSnapshot(this.target.path, options?.signal)
|
|
46
|
-
: await hashManagedSource(this.target.path, options?.signal);
|
|
51
|
+
? await readManagedSnapshot(this.target.path, operation, options?.signal)
|
|
52
|
+
: await hashManagedSource(this.target.path, operation, options?.signal);
|
|
47
53
|
if (observed.sha256 !== this.target.sha256)
|
|
48
54
|
return err(new EvidenceIntegrityError(`Managed artifact digest changed after open: expected ${this.target.sha256}, observed ${observed.sha256} at ${this.target.path}`));
|
|
49
55
|
const bytes = snapshot ?? observed.bytes;
|
|
@@ -51,7 +57,7 @@ class ManagedStaticClient {
|
|
|
51
57
|
throw new TypeError("Managed snapshot bytes are unavailable");
|
|
52
58
|
this.#snapshotBytes = bytes;
|
|
53
59
|
const result = inspectManagedOperation(operation, parameters, bytes, this.target);
|
|
54
|
-
return ok(createAnalysisExecution(result,
|
|
60
|
+
return ok(createAnalysisExecution(result, MANAGED_STATIC_PROVIDER, {
|
|
55
61
|
rawResult: null,
|
|
56
62
|
limitations: result.limitations,
|
|
57
63
|
subject: this.target,
|
|
@@ -61,7 +67,11 @@ class ManagedStaticClient {
|
|
|
61
67
|
catch (cause) {
|
|
62
68
|
if (options?.signal?.aborted === true)
|
|
63
69
|
return err(new AnalysisCancelledError(operation));
|
|
64
|
-
|
|
70
|
+
if (cause instanceof AnalysisError)
|
|
71
|
+
return err(cause);
|
|
72
|
+
return err(new ProviderAdapterError(MANAGED_STATIC_PROVIDER.id, operation, {
|
|
73
|
+
cause,
|
|
74
|
+
}));
|
|
65
75
|
}
|
|
66
76
|
}
|
|
67
77
|
close() {
|
|
@@ -69,27 +79,51 @@ class ManagedStaticClient {
|
|
|
69
79
|
return Promise.resolve(ok(null));
|
|
70
80
|
}
|
|
71
81
|
}
|
|
72
|
-
const readManagedSnapshot = async (path, signal) => {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
const readManagedSnapshot = async (path, operation, signal) => {
|
|
83
|
+
const handle = await openRegularFile(path, { symlinks: "follow", signal });
|
|
84
|
+
try {
|
|
85
|
+
const metadata = await handle.stat();
|
|
86
|
+
if (metadata.size > MAX_MANAGED_SNAPSHOT_BYTES)
|
|
87
|
+
throw snapshotCapacityError(operation);
|
|
88
|
+
const bytes = await readBoundedFileBytes(handle, MAX_MANAGED_SNAPSHOT_BYTES, signal);
|
|
89
|
+
if (bytes === undefined)
|
|
90
|
+
throw snapshotCapacityError(operation);
|
|
91
|
+
signal?.throwIfAborted();
|
|
92
|
+
return {
|
|
93
|
+
byteLength: bytes.length,
|
|
94
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
95
|
+
bytes,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
await handle.close();
|
|
100
|
+
}
|
|
79
101
|
};
|
|
80
|
-
const hashManagedSource = async (path, signal) => {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
102
|
+
const hashManagedSource = async (path, operation, signal) => {
|
|
103
|
+
const handle = await openRegularFile(path, { symlinks: "follow", signal });
|
|
104
|
+
try {
|
|
105
|
+
if ((await handle.stat()).size > MAX_MANAGED_SNAPSHOT_BYTES)
|
|
106
|
+
throw snapshotCapacityError(operation);
|
|
107
|
+
const digest = createHash("sha256");
|
|
108
|
+
let byteLength = 0;
|
|
109
|
+
const stream = handle.createReadStream({
|
|
110
|
+
autoClose: false,
|
|
111
|
+
...(signal === undefined ? {} : { signal }),
|
|
112
|
+
});
|
|
113
|
+
for await (const chunk of stream) {
|
|
114
|
+
signal?.throwIfAborted();
|
|
115
|
+
if (!Buffer.isBuffer(chunk))
|
|
116
|
+
throw new TypeError("Managed source stream returned non-buffer data");
|
|
117
|
+
if (chunk.length > MAX_MANAGED_SNAPSHOT_BYTES - byteLength)
|
|
118
|
+
throw snapshotCapacityError(operation);
|
|
119
|
+
byteLength += chunk.length;
|
|
120
|
+
digest.update(chunk);
|
|
121
|
+
}
|
|
122
|
+
return { byteLength, sha256: digest.digest("hex") };
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await handle.close();
|
|
91
126
|
}
|
|
92
|
-
return { byteLength, sha256: digest.digest("hex") };
|
|
93
127
|
};
|
|
94
128
|
const isManagedOperation = (operation) => MANAGED_TOOL_CONTRACTS.some(({ name }) => name === operation);
|
|
95
129
|
const inspectManagedOperation = (operation, parameters, bytes, target) => {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { MANAGED_STATIC_PROVIDER } from "../application/InvestigationProviders.js";
|
|
2
2
|
import { MANAGED_TOOL_CONTRACTS, } from "../contracts/managed/managedToolContracts.js";
|
|
3
|
-
/** Identity of execution-free managed metadata observations. */
|
|
4
|
-
export const MANAGED_STATIC_PROVIDER_IDENTITY = Object.freeze(MANAGED_STATIC_PROVIDER);
|
|
5
|
-
const IDENTITY = MANAGED_STATIC_PROVIDER_IDENTITY;
|
|
6
3
|
/** Declare managed metadata coverage without opening or loading an assembly. */
|
|
7
4
|
export const managedStaticCapabilities = () => Object.freeze(MANAGED_TOOL_CONTRACTS.map((contract) => Object.freeze({
|
|
8
|
-
provider:
|
|
5
|
+
provider: MANAGED_STATIC_PROVIDER,
|
|
9
6
|
operation: contract.name,
|
|
10
7
|
available: true,
|
|
11
8
|
reason: null,
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/** Require configured facts to pass while preserving workflow and execution gates. */
|
|
2
2
|
export const agentEvaluationPassed = (result) => result.exitCode === 0 &&
|
|
3
|
-
result.
|
|
3
|
+
(result.expectedFirstTool === null
|
|
4
|
+
? !result.naturalUse
|
|
5
|
+
: result.naturalUse) &&
|
|
4
6
|
result.correctFirstTool &&
|
|
5
7
|
result.repeatedCallCount === 0 &&
|
|
6
8
|
result.inputValidationFailureCount === 0 &&
|
|
7
9
|
result.requiredToolSubsequenceMet &&
|
|
8
10
|
result.inputTokens > 0 &&
|
|
9
|
-
(result.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
result.
|
|
11
|
+
(result.expectedFirstTool === null
|
|
12
|
+
? result.targetClarificationPassed === true
|
|
13
|
+
: result.factualCorrectness === "passed" ||
|
|
14
|
+
(result.factualCorrectness === "not_assessed" &&
|
|
15
|
+
result.answerHeuristicsMet &&
|
|
16
|
+
result.epistemicCuePresent));
|
|
13
17
|
/** Keep assessed fixture outcomes and scenarios without truth oracles distinct. */
|
|
14
18
|
export const summarizeFactualCorrectness = (results) => {
|
|
15
19
|
const passed = results.filter(({ factualCorrectness }) => factualCorrectness === "passed").length;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { evaluateKnownAnswers, } from "./KnownAnswerEvaluation.js";
|
|
2
2
|
import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js";
|
|
3
|
+
import { TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
3
4
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
5
|
const record = (value) => isRecord(value) ? value : undefined;
|
|
5
6
|
const textValue = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -20,19 +21,38 @@ const evidenceIdsFrom = (value) => {
|
|
|
20
21
|
return [];
|
|
21
22
|
return [...new Set(encoded.match(/ev_[a-f0-9]{64}/gu) ?? [])];
|
|
22
23
|
};
|
|
23
|
-
const
|
|
24
|
-
if (item.status === "failed" ||
|
|
25
|
-
(item.error !== undefined && item.error !== null))
|
|
26
|
-
return true;
|
|
24
|
+
const toolResultError = (item) => {
|
|
27
25
|
const result = record(item.result ?? item.output);
|
|
28
26
|
const structured = record(result?.structured_content ?? result?.structuredContent);
|
|
29
|
-
|
|
27
|
+
const direct = record(structured?.error ?? result?.error ?? item.error);
|
|
28
|
+
if (direct !== undefined || structured !== undefined)
|
|
29
|
+
return direct;
|
|
30
|
+
// Codex preserves some REA failures only as one complete JSON text block.
|
|
31
|
+
// A client-truncated preview or SDK prose is not a structured error record.
|
|
32
|
+
const content = result?.content;
|
|
33
|
+
if (!Array.isArray(content) || content.length !== 1)
|
|
34
|
+
return undefined;
|
|
35
|
+
const block = record(content[0]);
|
|
36
|
+
if (block?.type !== "text" || typeof block.text !== "string")
|
|
37
|
+
return undefined;
|
|
38
|
+
try {
|
|
39
|
+
return record(record(JSON.parse(block.text))?.error);
|
|
40
|
+
}
|
|
41
|
+
catch (cause) {
|
|
42
|
+
if (cause instanceof SyntaxError || cause instanceof RangeError)
|
|
43
|
+
return undefined;
|
|
44
|
+
throw cause;
|
|
45
|
+
}
|
|
30
46
|
};
|
|
31
|
-
const
|
|
47
|
+
const toolResultFailed = (item, error) => {
|
|
48
|
+
if (item.status === "failed" ||
|
|
49
|
+
(item.error !== undefined && item.error !== null))
|
|
50
|
+
return true;
|
|
32
51
|
const result = record(item.result ?? item.output);
|
|
33
52
|
const structured = record(result?.structured_content ?? result?.structuredContent);
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
return (result?.isError === true ||
|
|
54
|
+
structured?.error !== undefined ||
|
|
55
|
+
error !== undefined);
|
|
36
56
|
};
|
|
37
57
|
const callFromItem = (value) => {
|
|
38
58
|
const item = record(value);
|
|
@@ -41,14 +61,15 @@ const callFromItem = (value) => {
|
|
|
41
61
|
const tool = textValue(item.tool) ?? textValue(item.name);
|
|
42
62
|
if (tool === undefined)
|
|
43
63
|
return undefined;
|
|
64
|
+
const error = toolResultError(item);
|
|
44
65
|
return {
|
|
45
66
|
id: textValue(item.id) ?? null,
|
|
46
67
|
server: textValue(item.server) ?? textValue(item.server_name) ?? null,
|
|
47
68
|
tool,
|
|
48
69
|
arguments: item.arguments ?? item.input ?? {},
|
|
49
70
|
evidenceIds: evidenceIdsFrom(item.result ?? item.output),
|
|
50
|
-
error: toolResultFailed(item),
|
|
51
|
-
errorCode:
|
|
71
|
+
error: toolResultFailed(item, error),
|
|
72
|
+
errorCode: textValue(error?.code) ?? null,
|
|
52
73
|
};
|
|
53
74
|
};
|
|
54
75
|
const agentTextFromItem = (value) => {
|
|
@@ -106,12 +127,21 @@ export const evaluateCodexEvents = (events, expectedFirstTool, options = {}) =>
|
|
|
106
127
|
consumeEvent(state, event);
|
|
107
128
|
const reaCalls = state.calls.filter(({ server }) => server === null || server.toLowerCase() === "rea");
|
|
108
129
|
const signatures = new Map();
|
|
130
|
+
let targetRevision = 0;
|
|
109
131
|
for (const call of reaCalls) {
|
|
110
|
-
|
|
132
|
+
// A status read before and after a successful target lifecycle change is
|
|
133
|
+
// useful verification, not a duplicate analysis or unchanged failed retry.
|
|
134
|
+
const context = call.tool === "binary_session" ? `${String(targetRevision)}:` : "";
|
|
135
|
+
const signature = `${context}${call.tool}:${JSON.stringify(canonicalValue(call.arguments))}`;
|
|
111
136
|
signatures.set(signature, (signatures.get(signature) ?? 0) + 1);
|
|
137
|
+
if (!call.error &&
|
|
138
|
+
(call.tool === "open_binary" || call.tool === "close_binary"))
|
|
139
|
+
targetRevision += 1;
|
|
112
140
|
}
|
|
113
141
|
const repeatedCallCount = [...signatures.values()].reduce((total, count) => total + Math.max(0, count - 1), 0);
|
|
114
|
-
const inputValidationFailureCount = reaCalls.filter((
|
|
142
|
+
const inputValidationFailureCount = reaCalls.filter((call) => call.errorCode === "invalid_request" ||
|
|
143
|
+
(call.error &&
|
|
144
|
+
TOOL_CONTRACTS.find(({ name }) => name === call.tool)?.inputSchema.safeParse(call.arguments).success === false)).length;
|
|
115
145
|
const requiredToolSubsequenceMet = containsOrderedSubsequence(reaCalls.filter(({ error }) => !error).map(({ tool }) => tool), options.requiredToolSubsequence ?? []);
|
|
116
146
|
const finalMessage = state.finalMessages.at(-1) ?? "";
|
|
117
147
|
const evidenceIds = [
|
|
@@ -124,7 +154,7 @@ export const evaluateCodexEvents = (events, expectedFirstTool, options = {}) =>
|
|
|
124
154
|
const factualAssessment = evaluateKnownAnswers(events, finalMessage, options.fixtureClaims);
|
|
125
155
|
return {
|
|
126
156
|
naturalUse: reaCalls.length > 0,
|
|
127
|
-
correctFirstTool: reaCalls[0]?.tool === expectedFirstTool,
|
|
157
|
+
correctFirstTool: (reaCalls[0]?.tool ?? null) === expectedFirstTool,
|
|
128
158
|
firstTool: reaCalls[0]?.tool ?? null,
|
|
129
159
|
reaCalls,
|
|
130
160
|
repeatedCallCount,
|
|
@@ -24,8 +24,6 @@ export const evmInterfaceFailure = (cause, phase, path, workerLimits, limiter =
|
|
|
24
24
|
message: cause.message,
|
|
25
25
|
exit_code: cause.snapshot?.exitCode ?? null,
|
|
26
26
|
signal: cause.snapshot?.signal ?? null,
|
|
27
|
-
stdout: cause.snapshot?.stdout.text ?? null,
|
|
28
|
-
stderr: cause.snapshot?.stderr.text ?? null,
|
|
29
27
|
},
|
|
30
28
|
}, { operation: "inspect_evm_interface", cause });
|
|
31
29
|
if (cause.reason === "cancelled")
|
|
@@ -44,14 +44,29 @@ export class EvmoleInterfaceProvider {
|
|
|
44
44
|
environment;
|
|
45
45
|
launcher;
|
|
46
46
|
createRuntime;
|
|
47
|
+
#tail = Promise.resolve();
|
|
48
|
+
#closing = false;
|
|
49
|
+
#closePromise;
|
|
50
|
+
#pendingCleanup;
|
|
47
51
|
constructor(environment = process.env, launcher, createRuntime = () => PrivateRuntimeRoot.create({ prefix: "rea-evm-interface-" })) {
|
|
48
52
|
this.environment = environment;
|
|
49
53
|
this.launcher = launcher;
|
|
50
54
|
this.createRuntime = createRuntime;
|
|
51
55
|
}
|
|
52
56
|
/** Bind recovered interface candidates to both original carrier and decoded byte identity. */
|
|
53
|
-
|
|
57
|
+
inspect(input, options) {
|
|
58
|
+
if (this.#closing)
|
|
59
|
+
return Promise.resolve(err(this.#closedError()));
|
|
60
|
+
const operation = this.#tail.then(() => this.#closing ? err(this.#closedError()) : this.#inspect(input, options));
|
|
61
|
+
this.#tail = operation.then(() => undefined, () => undefined);
|
|
62
|
+
return operation;
|
|
63
|
+
}
|
|
64
|
+
async #inspect(input, options) {
|
|
65
|
+
const pending = await this.#retire();
|
|
66
|
+
if (pending !== undefined)
|
|
67
|
+
return err(pending);
|
|
54
68
|
let root;
|
|
69
|
+
let processOwner;
|
|
55
70
|
let retainedOutput;
|
|
56
71
|
let phase = "configuration";
|
|
57
72
|
let workerLimits;
|
|
@@ -221,6 +236,8 @@ export class EvmoleInterfaceProvider {
|
|
|
221
236
|
}));
|
|
222
237
|
}
|
|
223
238
|
catch (cause) {
|
|
239
|
+
if (cause instanceof OwnedCommandFailure)
|
|
240
|
+
processOwner = cause.cleanupOwner;
|
|
224
241
|
let fileFailure;
|
|
225
242
|
if (cause instanceof OwnedCommandFailure &&
|
|
226
243
|
cause.snapshot?.exitCode === EVM_FILE_SIZE_FAILURE_EXIT &&
|
|
@@ -249,12 +266,20 @@ export class EvmoleInterfaceProvider {
|
|
|
249
266
|
: { capturedOutput: retainedOutput })
|
|
250
267
|
: evmInterfaceFailure(cause, phase, input.path, workerLimits, limiter, fileFailure));
|
|
251
268
|
}
|
|
269
|
+
if (processOwner !== undefined) {
|
|
270
|
+
this.#pendingCleanup = { root, process: processOwner };
|
|
271
|
+
// The command failure already owns this cleanup diagnostic and its resources.
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
252
274
|
if (root !== undefined) {
|
|
253
275
|
try {
|
|
254
276
|
await root.close();
|
|
255
277
|
}
|
|
256
278
|
catch (cause) {
|
|
257
|
-
|
|
279
|
+
const retainedRoot = root;
|
|
280
|
+
this.#pendingCleanup = { root: retainedRoot, process: undefined };
|
|
281
|
+
root = undefined;
|
|
282
|
+
return err(new ProviderCleanupError(EVMOLE_PROVIDER_IDENTITY.id, [retainedRoot.path], {
|
|
258
283
|
reason: cause instanceof Error ? cause.message : String(cause),
|
|
259
284
|
previous_error: result.ok
|
|
260
285
|
? null
|
|
@@ -271,4 +296,44 @@ export class EvmoleInterfaceProvider {
|
|
|
271
296
|
: { capturedOutput: retainedOutput }))
|
|
272
297
|
: result;
|
|
273
298
|
}
|
|
299
|
+
async close() {
|
|
300
|
+
this.#closing = true;
|
|
301
|
+
this.#closePromise ??= this.#tail
|
|
302
|
+
.then(async () => {
|
|
303
|
+
const failure = await this.#retire();
|
|
304
|
+
if (failure !== undefined)
|
|
305
|
+
throw failure;
|
|
306
|
+
})
|
|
307
|
+
.catch((cause) => {
|
|
308
|
+
this.#closePromise = undefined;
|
|
309
|
+
throw cause;
|
|
310
|
+
});
|
|
311
|
+
return this.#closePromise;
|
|
312
|
+
}
|
|
313
|
+
#closedError() {
|
|
314
|
+
return new ProviderCleanupError(EVMOLE_PROVIDER_IDENTITY.id, [], { reason: "Provider is closing" }, { operation: OPERATION });
|
|
315
|
+
}
|
|
316
|
+
async #retire() {
|
|
317
|
+
const pending = this.#pendingCleanup;
|
|
318
|
+
if (pending === undefined)
|
|
319
|
+
return undefined;
|
|
320
|
+
if (pending.process !== undefined) {
|
|
321
|
+
const stopped = await pending.process.stop();
|
|
322
|
+
if (stopped.status === "incomplete")
|
|
323
|
+
return new ProviderCleanupError(EVMOLE_PROVIDER_IDENTITY.id, [pending.process.launch.ownership?.runId ?? "owned-worker"], { reason: stopped.reason }, { operation: OPERATION });
|
|
324
|
+
pending.process = undefined;
|
|
325
|
+
}
|
|
326
|
+
if (pending.root !== undefined) {
|
|
327
|
+
const root = pending.root;
|
|
328
|
+
try {
|
|
329
|
+
await root.close();
|
|
330
|
+
pending.root = undefined;
|
|
331
|
+
}
|
|
332
|
+
catch (cause) {
|
|
333
|
+
return new ProviderCleanupError(EVMOLE_PROVIDER_IDENTITY.id, [root.path], { reason: cause instanceof Error ? cause.message : String(cause) }, { operation: OPERATION, cause });
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
this.#pendingCleanup = undefined;
|
|
337
|
+
return undefined;
|
|
338
|
+
}
|
|
274
339
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Dir.close invalidates Node's private handle before its native close settles. */
|
|
2
|
+
export class OwnedDirectoryHandle {
|
|
3
|
+
handle;
|
|
4
|
+
#state = { kind: "open" };
|
|
5
|
+
constructor(handle) {
|
|
6
|
+
this.handle = handle;
|
|
7
|
+
}
|
|
8
|
+
close() {
|
|
9
|
+
if (this.#state.kind === "closed")
|
|
10
|
+
return Promise.resolve();
|
|
11
|
+
if (this.#state.kind === "closing")
|
|
12
|
+
return this.#state.attempt;
|
|
13
|
+
if (this.#state.kind === "failed")
|
|
14
|
+
return Promise.reject(this.#state.cause);
|
|
15
|
+
const attempt = Promise.resolve().then(async () => {
|
|
16
|
+
try {
|
|
17
|
+
await this.handle.close();
|
|
18
|
+
this.#state = { kind: "closed" };
|
|
19
|
+
}
|
|
20
|
+
catch (cause) {
|
|
21
|
+
// Dir has no public validity signal with which to authorize a retry.
|
|
22
|
+
this.#state = { kind: "failed", cause };
|
|
23
|
+
throw cause;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
this.#state = { kind: "closing", attempt };
|
|
27
|
+
return attempt;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** One file handle whose close result must remain truthful across retries. */
|
|
2
|
+
export class OwnedFileHandle {
|
|
3
|
+
handle;
|
|
4
|
+
#state = { kind: "open" };
|
|
5
|
+
constructor(handle) {
|
|
6
|
+
this.handle = handle;
|
|
7
|
+
}
|
|
8
|
+
/** Close the owned handle, retaining an unconfirmed close as a sticky failure. */
|
|
9
|
+
close() {
|
|
10
|
+
if (this.#state.kind === "closed")
|
|
11
|
+
return Promise.resolve();
|
|
12
|
+
if (this.#state.kind === "closing")
|
|
13
|
+
return this.#state.attempt;
|
|
14
|
+
if (this.#state.kind === "failed")
|
|
15
|
+
return Promise.reject(this.#state.cause);
|
|
16
|
+
if (this.handle.fd < 0) {
|
|
17
|
+
const cause = new Error("File handle was invalidated before this owner confirmed its close");
|
|
18
|
+
this.#state = { kind: "failed", cause };
|
|
19
|
+
return Promise.reject(cause);
|
|
20
|
+
}
|
|
21
|
+
const attempt = Promise.resolve().then(() => this.#attemptClose());
|
|
22
|
+
this.#state = { kind: "closing", attempt };
|
|
23
|
+
return attempt;
|
|
24
|
+
}
|
|
25
|
+
async #attemptClose() {
|
|
26
|
+
try {
|
|
27
|
+
await this.handle.close();
|
|
28
|
+
this.#state = { kind: "closed" };
|
|
29
|
+
}
|
|
30
|
+
catch (cause) {
|
|
31
|
+
this.#state =
|
|
32
|
+
this.handle.fd < 0 ? { kind: "failed", cause } : { kind: "open" };
|
|
33
|
+
throw cause;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { open } from "node:fs/promises";
|
|
3
|
+
import { OwnedFileHandle } from "./OwnedFileHandle.js";
|
|
4
|
+
/** Identifies a selected path that cannot be read as one regular file. */
|
|
5
|
+
export class NonRegularFileReadError extends Error {
|
|
6
|
+
path;
|
|
7
|
+
code;
|
|
8
|
+
constructor(path, directory) {
|
|
9
|
+
super(`Selected input must be a regular file: ${path}`);
|
|
10
|
+
this.path = path;
|
|
11
|
+
this.name = "NonRegularFileReadError";
|
|
12
|
+
this.code = directory ? "EISDIR" : "ENOTFILE";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Admission failed and the opened descriptor could not be confirmed closed. */
|
|
16
|
+
export class RegularFileAdmissionFailure extends Error {
|
|
17
|
+
path;
|
|
18
|
+
cleanupCause;
|
|
19
|
+
owner;
|
|
20
|
+
cause;
|
|
21
|
+
constructor(path, admissionCause, cleanupCause, owner) {
|
|
22
|
+
super(`Selected input failed admission and its descriptor close failed: ${path}`);
|
|
23
|
+
this.path = path;
|
|
24
|
+
this.cleanupCause = cleanupCause;
|
|
25
|
+
this.owner = owner;
|
|
26
|
+
this.name = "RegularFileAdmissionFailure";
|
|
27
|
+
this.cause = admissionCause;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** A regular input no longer matches the extent or identity admitted for reading. */
|
|
31
|
+
export class RegularFileChangedError extends Error {
|
|
32
|
+
path;
|
|
33
|
+
code = "ESTALE";
|
|
34
|
+
constructor(path) {
|
|
35
|
+
super(`Selected input changed while being read: ${path}`);
|
|
36
|
+
this.path = path;
|
|
37
|
+
this.name = "RegularFileChangedError";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Open and verify the selected file descriptor without blocking on pipes. */
|
|
41
|
+
export const openRegularFile = async (path, options) => {
|
|
42
|
+
options.signal?.throwIfAborted();
|
|
43
|
+
const handle = await open(path, constants.O_RDONLY |
|
|
44
|
+
(constants.O_NONBLOCK ?? 0) |
|
|
45
|
+
(constants.O_NOCTTY ?? 0) |
|
|
46
|
+
(options.symlinks === "reject" ? (constants.O_NOFOLLOW ?? 0) : 0));
|
|
47
|
+
const owner = new OwnedFileHandle(handle);
|
|
48
|
+
try {
|
|
49
|
+
options.signal?.throwIfAborted();
|
|
50
|
+
const metadata = await handle.stat();
|
|
51
|
+
options.signal?.throwIfAborted();
|
|
52
|
+
if (!metadata.isFile())
|
|
53
|
+
throw new NonRegularFileReadError(path, metadata.isDirectory());
|
|
54
|
+
return handle;
|
|
55
|
+
}
|
|
56
|
+
catch (cause) {
|
|
57
|
+
try {
|
|
58
|
+
await owner.close();
|
|
59
|
+
}
|
|
60
|
+
catch (cleanupCause) {
|
|
61
|
+
throw new RegularFileAdmissionFailure(path, cause, cleanupCause, owner);
|
|
62
|
+
}
|
|
63
|
+
throw cause;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/** Compare one regular file's identity and mutable metadata across a read. */
|
|
67
|
+
export const sameRegularFileState = (expected, observed) => observed.isFile() &&
|
|
68
|
+
expected.dev === observed.dev &&
|
|
69
|
+
expected.ino === observed.ino &&
|
|
70
|
+
expected.size === observed.size &&
|
|
71
|
+
expected.mode === observed.mode &&
|
|
72
|
+
expected.mtimeMs === observed.mtimeMs &&
|
|
73
|
+
expected.ctimeMs === observed.ctimeMs;
|