rea-agents 6.3.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 +7 -4
- package/bridge/ghidra/ReaGhidraApplySeeds.java +151 -0
- package/bridge/ghidra/ReaGhidraBridge.java +597 -209
- package/bridge/ghidra/ReaGhidraNoReturnFix.java +123 -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 +51 -19
- 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 +22 -2
- package/dist/application/CapabilityInventory.js +11 -1
- package/dist/application/ClientConfigurationDocument.js +70 -0
- package/dist/application/ClientConfigurationFiles.js +91 -0
- package/dist/application/ClientRegistrationEnvironment.js +35 -0
- package/dist/application/ClientRegistrationStatus.js +66 -31
- package/dist/application/DirectAnalysis.js +2 -2
- package/dist/application/DirectAnalysisCleanup.js +1 -1
- package/dist/application/DirectAnalysisStatus.js +1 -1
- package/dist/application/Doctor.js +5 -3
- package/dist/application/DoctorDiagnostics.js +1 -1
- package/dist/application/EvidenceBundleCommands.js +6 -12
- 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 +6 -0
- package/dist/application/JsonFiles.js +6 -5
- package/dist/{cliJsonFile.js → application/JsonInputFile.js} +108 -35
- package/dist/application/LinuxHopper.js +4 -12
- 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 +9 -3
- 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 +93 -7
- package/dist/application/Setup.js +54 -6
- package/dist/application/SetupClientConfiguration.js +116 -16
- package/dist/application/SetupHost.js +102 -24
- package/dist/application/SetupPlan.js +5 -8
- package/dist/application/SetupSkill.js +58 -39
- package/dist/application/SupportedClients.js +290 -65
- package/dist/application/Uninstall.js +158 -10
- package/dist/application/UpdateMaintenance.js +17 -21
- package/dist/application/Utf8JsonInput.js +7 -0
- package/dist/application/WebScriptExportService.js +131 -65
- 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/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/BinarySession.js +2 -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/ElectronBoundaryGraphContext.js +3 -2
- package/dist/application/javascript/ElectronBoundaryGraphIpc.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +19 -6
- package/dist/application/javascript/ElectronBoundaryGraphWindows.js +3 -3
- package/dist/application/javascript/JavaScriptApplicationService.js +22 -11
- package/dist/application/javascript/JavaScriptApplicationWorkflowEvidence.js +5 -6
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +171 -30
- package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +14 -16
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +67 -19
- package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +4 -3
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +11 -5
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +19 -16
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +92 -10
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +258 -235
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +115 -26
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +4 -1
- package/dist/application/javascript/JavaScriptModuleRelationships.js +6 -4
- package/dist/application/javascript/JavaScriptRecoveryService.js +3 -0
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +9 -3
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +199 -61
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +12 -19
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +4 -1
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -3
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +5 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +19 -8
- 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/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 +20 -15
- package/dist/artifacts/ArtifactReader.js +23 -0
- package/dist/artifacts/ArtifactResourceScope.js +100 -0
- package/dist/artifacts/AsarArtifactReader.js +176 -102
- 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 +29 -22
- 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 +32 -13
- package/dist/artifacts/extraction/ArtifactExtraction.js +110 -86
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +110 -43
- package/dist/artifacts/inventory/ArtifactInventory.js +5 -4
- package/dist/artifacts/inventory/classify.js +75 -32
- package/dist/artifacts/inventory/hashStableRootArtifact.js +48 -15
- package/dist/artifacts/inventory/reader.js +13 -5
- package/dist/artifacts/inventory/scanCanonical.js +62 -25
- package/dist/artifacts/inventory/scanReader.js +38 -11
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +15 -9
- 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 +5 -0
- 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/CdpConnection.js +22 -5
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpTargetSession.js +30 -34
- package/dist/browser/CdpWebMcpDiscovery.js +32 -10
- package/dist/browser/ElectronFileScope.js +99 -9
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +60 -4
- package/dist/browser/PlaywrightElectronActiveProvider.js +11 -6
- package/dist/browser/PlaywrightScenarioArtifacts.js +5 -5
- package/dist/browser/PlaywrightScenarioBrowser.js +69 -7
- package/dist/browser/PlaywrightScenarioSession.js +127 -54
- package/dist/browser/PlaywrightScenarioStorage.js +507 -0
- package/dist/browser/PngVisualDiff.js +198 -29
- package/dist/browser/WebSourceMapFetcher.js +3 -3
- package/dist/browser/assets/LocalWebScriptArtifacts.js +3 -1
- package/dist/browser/assets/PublishWebScripts.js +75 -20
- 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/coreBinaryCommands.js +0 -5
- package/dist/cli/coreNativeCommands.js +1 -14
- package/dist/cli/electronCommands.js +6 -1
- package/dist/cli/evmCommands.js +13 -4
- package/dist/cli/firmwareCommands.js +7 -2
- package/dist/cli/javascriptApplicationAnalysis.js +17 -1
- package/dist/cli/javascriptRecoveryCommands.js +22 -15
- package/dist/cli/jebCommands.js +99 -0
- package/dist/cli/jsonOutput.js +11 -4
- package/dist/cli/referenceSourceImportStatus.js +7 -0
- package/dist/cli/setupCommands.js +15 -3
- package/dist/cli/utilityCommands.js +66 -18
- package/dist/cli/webScriptCommands.js +20 -1
- package/dist/cli/webSourceLocationCommands.js +21 -9
- package/dist/cli.js +6 -0
- package/dist/cliBrowserScenarioCommands.js +2 -1
- package/dist/cliCommandNames.js +32 -0
- package/dist/cliJsonInput.js +2 -2
- package/dist/cliObservationOptions.js +3 -0
- package/dist/composition/adb.js +3 -0
- package/dist/composition/apktool.js +3 -0
- package/dist/composition/binaryDiagnostics.js +4 -0
- package/dist/composition/directAnalysis.js +12 -4
- 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/artifactToolContracts.js +8 -5
- package/dist/contracts/browserToolContracts.js +1 -1
- package/dist/contracts/compactInputSchema.js +256 -0
- package/dist/contracts/functionWorkflowToolContracts.js +1 -1
- package/dist/contracts/inputSchemaPresentation.js +10 -10
- package/dist/contracts/javascript/electronToolContracts.js +15 -3
- package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +1 -1
- package/dist/contracts/jeb/jebToolContracts.js +64 -0
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +25 -3
- package/dist/contracts/officialToolContracts.js +5 -5
- package/dist/contracts/sessionToolContracts.js +2 -2
- package/dist/contracts/sessionToolSchemas.js +6 -2
- 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 +5 -3
- package/dist/contracts/toolSchemaMetadata.js +82 -7
- package/dist/domain/adb/adbDeviceAnalysis.js +583 -0
- package/dist/domain/analysisErrorCleanup.js +29 -0
- package/dist/domain/analysisErrorPresentation.js +18 -6
- package/dist/domain/analysisErrorProjection.js +4 -1
- package/dist/domain/analysisSnapshot.js +2 -1
- package/dist/domain/analysisView/analysisView.js +52 -2
- 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/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 +2 -2
- package/dist/domain/apple/interfaceBuilderGraph.js +22 -19
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +10 -1
- package/dist/domain/artifactComparison.js +35 -7
- package/dist/domain/artifactGraph.js +5 -3
- package/dist/domain/artifactIdentity.js +30 -2
- package/dist/domain/artifactInspection.js +3 -43
- package/dist/domain/artifactIntegrityPolicy.js +10 -0
- package/dist/domain/artifactInventoryEvidence.js +11 -12
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/binaryTarget.js +16 -0
- package/dist/domain/binaryTargetTypes.js +8 -1
- package/dist/domain/browserObservationSchemas.js +8 -4
- package/dist/domain/canonicalJsonDigestSteps.js +34 -12
- package/dist/domain/compactStringIdentity.js +9 -0
- package/dist/domain/evidence.js +2 -1
- package/dist/domain/evidenceRecordSummary.js +144 -0
- package/dist/domain/inputIssueProjection.js +16 -1
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +12 -13
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +11 -20
- package/dist/domain/javascript/electronStaticAnalysisNative.js +70 -40
- package/dist/domain/javascript/electronStaticAnalysisValues.js +16 -0
- package/dist/domain/javascript/javascriptAnalysisResourceControls.js +45 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +4 -1
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +6 -6
- package/dist/domain/javascript/javascriptApplicationGraph.js +79 -18
- package/dist/domain/javascript/javascriptApplicationProjectionResources.js +35 -0
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +28 -12
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +9 -1
- package/dist/domain/javascript/javascriptAstFingerprint.js +58 -31
- package/dist/domain/javascript/javascriptAstValues.js +32 -0
- package/dist/domain/javascript/javascriptElectronMemberWrites.js +50 -0
- package/dist/domain/javascript/javascriptModuleSemanticIr.js +15 -0
- package/dist/domain/javascript/javascriptNativeHandoff.js +6 -1
- package/dist/domain/javascript/javascriptRpcEndpoints.js +253 -0
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +1 -3
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +7 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +8 -11
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +190 -33
- package/dist/domain/javascript/javascriptSemanticCallableResults.js +42 -0
- package/dist/domain/javascript/javascriptSemanticCalls.js +8 -1
- package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +15 -4
- package/dist/domain/javascript/javascriptSemanticFileProjection.js +1 -0
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +42 -41
- package/dist/domain/javascript/javascriptSemanticGraph.js +69 -23
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +2 -10
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +40 -7
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +341 -87
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +78 -35
- package/dist/domain/javascript/javascriptSemanticObjectReferences.js +381 -0
- package/dist/domain/javascript/javascriptSemanticObjects.js +7 -1
- package/dist/domain/javascript/javascriptSemanticProjection.js +52 -14
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +77 -0
- package/dist/domain/javascript/javascriptSemanticQuery.js +27 -29
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +1 -3
- package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +219 -0
- package/dist/domain/javascript/javascriptSemanticReturns.js +13 -23
- package/dist/domain/javascript/javascriptSemanticState.js +22 -2
- package/dist/domain/javascript/javascriptSemanticTraversal.js +19 -1
- package/dist/domain/javascript/javascriptSemanticValues.js +47 -19
- package/dist/domain/javascript/javascriptSourceAnalysis.js +1 -0
- package/dist/domain/javascript/javascriptStaticAnalysis.js +29 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +8 -6
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +49 -5
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +8 -4
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +1 -0
- package/dist/domain/jeb/jebAnalysis.js +114 -0
- package/dist/domain/jsonShape.js +63 -52
- package/dist/domain/jsonValue.js +3 -0
- package/dist/domain/managed/managedApplicationGraph.js +37 -0
- package/dist/domain/managed/managedApplicationGraphCoverage.js +8 -2
- package/dist/domain/managed/managedApplicationGraphNodes.js +32 -22
- package/dist/domain/managed/managedArtifact.js +1 -0
- package/dist/domain/managed/managedInspectionEvidence.js +13 -0
- package/dist/domain/native/nativeAotPe.js +1408 -0
- package/dist/domain/native/nativeInstruction.js +21 -0
- package/dist/domain/native/nativeMetadataRecovery.js +79 -6
- package/dist/domain/native/peResources.js +94 -0
- package/dist/domain/nativeConvention.js +33 -0
- package/dist/domain/process/processCapture.js +91 -1
- package/dist/domain/process/processCaptureExample.js +24 -0
- package/dist/domain/process/processCaptureValidation.js +79 -0
- package/dist/domain/process/processScenario.js +59 -7
- package/dist/domain/propertyListKeys.js +3 -1
- package/dist/domain/referenceSourceGraph.js +25 -16
- package/dist/domain/referenceSourceImportParsing.js +6 -3
- package/dist/domain/referenceSourcePathIdentity.js +22 -0
- package/dist/domain/referenceSourceRequireBindings.js +137 -0
- package/dist/domain/webBundleAnalyzerInspection.js +14 -2
- package/dist/domain/webCaptureDiff.js +102 -4
- 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 +4 -2
- 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 +55 -24
- 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 +33 -1
- 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 +76 -4
- package/dist/ghidra/GhidraDiagnostics.js +11 -8
- package/dist/ghidra/GhidraFunctionValues.js +26 -2
- package/dist/ghidra/GhidraInstallation.js +1 -1
- package/dist/ghidra/GhidraInventoryValues.js +23 -1
- package/dist/ghidra/GhidraLanguageCatalog.js +99 -0
- package/dist/ghidra/GhidraLauncher.js +80 -39
- 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/HopperClient.js +15 -6
- package/dist/hopper/HopperMachOImage.js +2 -0
- package/dist/hopper/HopperProvider.js +13 -2
- package/dist/ida/IdaOperationRunner.js +8 -2
- package/dist/ida/IdaProvider.js +7 -0
- package/dist/ida/IdaSessionClient.js +3 -1
- package/dist/ida/IdaWorkspace.js +4 -2
- 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/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/NativeMacOSProvider.js +91 -16
- 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 +96 -39
- 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 +28 -4
- package/dist/process/capture/ProcessCaptureLifecycle.js +350 -59
- package/dist/process/capture/ProcessCaptureProgress.js +62 -0
- package/dist/process/capture/ProcessHarness.js +194 -26
- 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/contractToolHandler.js +21 -0
- package/dist/server/createServer.js +97 -25
- 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 +4 -6
- 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/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/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 +32 -3
- package/dist/server/registerElectronTools.js +28 -10
- 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/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/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 +49 -18
- 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 +33 -5
- 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 +22 -1
|
@@ -5,13 +5,16 @@ import { readReferenceSource } from "../reference/ReferenceSourceReader.js";
|
|
|
5
5
|
import { parseReferenceSourceEntries } from "./ReferenceSourceImportEntries.js";
|
|
6
6
|
import { readReferenceSourceVcs } from "./ReferenceSourceVcsAdapter.js";
|
|
7
7
|
import {} from "./ReferenceSourceImportTypes.js";
|
|
8
|
-
import { prepareReferenceSourceImport } from "./ReferenceSourceImportPolicy.js";
|
|
8
|
+
import { prepareReferenceSourceImport, } from "./ReferenceSourceImportPolicy.js";
|
|
9
9
|
const failure = (code, message) => ({
|
|
10
10
|
tag: "reference-source-import",
|
|
11
11
|
code,
|
|
12
12
|
message,
|
|
13
13
|
});
|
|
14
|
-
const cancelled = () =>
|
|
14
|
+
const cancelled = (partial) => ({
|
|
15
|
+
...failure("cancelled", "Reference source import cancelled"),
|
|
16
|
+
...(partial === undefined ? {} : { partial }),
|
|
17
|
+
});
|
|
15
18
|
const isAborted = (signal) => signal?.aborted === true;
|
|
16
19
|
const relationshipKey = (relationship) => `${relationship.from_path}\u0000${relationship.to}\u0000${relationship.kind}\u0000${relationship.resolution}\u0000${relationship.parse_state}`;
|
|
17
20
|
const deduplicateRelationships = (relationships) => {
|
|
@@ -65,8 +68,37 @@ const sortExclusions = (exclusions) => [...exclusions].sort((left, right) => {
|
|
|
65
68
|
const byPath = compareUnicodeCodePoints(left.path, right.path);
|
|
66
69
|
if (byPath !== 0)
|
|
67
70
|
return byPath;
|
|
68
|
-
|
|
71
|
+
const byReason = compareUnicodeCodePoints(left.reason, right.reason);
|
|
72
|
+
if (byReason !== 0)
|
|
73
|
+
return byReason;
|
|
74
|
+
return compareUnicodeCodePoints("pattern" in left ? left.pattern : "", "pattern" in right ? right.pattern : "");
|
|
69
75
|
});
|
|
76
|
+
const createShouldExclude = (exclusions, secrets, ignored) => (path, kind) => {
|
|
77
|
+
const patternPath = kind === "directory" ? `${path}/` : path;
|
|
78
|
+
const secretMatch = secrets.test(patternPath);
|
|
79
|
+
if (secretMatch.ignored) {
|
|
80
|
+
if (!secretMatch.rule)
|
|
81
|
+
throw new Error(`Ignored secret path has no matching rule: ${path}`);
|
|
82
|
+
exclusions.push({
|
|
83
|
+
path,
|
|
84
|
+
reason: "configured-secret",
|
|
85
|
+
pattern: secretMatch.rule.pattern,
|
|
86
|
+
});
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const match = ignored.test(patternPath);
|
|
90
|
+
if (!match.ignored)
|
|
91
|
+
return false;
|
|
92
|
+
if (!match.rule)
|
|
93
|
+
throw new Error(`Ignored path has no matching rule: ${path}`);
|
|
94
|
+
const reason = match.rule.mark;
|
|
95
|
+
if (reason !== "project-ignored" &&
|
|
96
|
+
reason !== "default-ignored" &&
|
|
97
|
+
reason !== "caller-excluded")
|
|
98
|
+
throw new Error(`Ignored path has unknown rule origin: ${path}`);
|
|
99
|
+
exclusions.push({ path, reason, pattern: match.rule.pattern });
|
|
100
|
+
return true;
|
|
101
|
+
};
|
|
70
102
|
/**
|
|
71
103
|
* Import a reference source directory into a committed historical source graph.
|
|
72
104
|
*
|
|
@@ -74,51 +106,38 @@ const sortExclusions = (exclusions) => [...exclusions].sort((left, right) => {
|
|
|
74
106
|
* git subprocesses, or network requests. Paths explicitly excluded by the
|
|
75
107
|
* caller's reference-source policy are omitted from the graph.
|
|
76
108
|
*/
|
|
77
|
-
export const importReferenceSource = async (options) => {
|
|
109
|
+
export const importReferenceSource = async (options, resources) => {
|
|
78
110
|
if (isAborted(options.signal))
|
|
79
111
|
return err(cancelled());
|
|
80
|
-
const prepared = await prepareReferenceSourceImport(options);
|
|
112
|
+
const prepared = await prepareReferenceSourceImport(options, resources);
|
|
81
113
|
if (!prepared.ok)
|
|
82
114
|
return prepared;
|
|
83
115
|
const { ignored, root, secrets } = prepared.value;
|
|
84
116
|
if (isAborted(options.signal))
|
|
85
117
|
return err(cancelled());
|
|
86
118
|
const exclusions = [];
|
|
87
|
-
const shouldExclude = (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
if (ignored.ignores(path)) {
|
|
93
|
-
exclusions.push({ path, reason: "caller-excluded" });
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
};
|
|
98
|
-
const [readResult, vcs] = await Promise.all([
|
|
99
|
-
readReferenceSource(root, {
|
|
119
|
+
const shouldExclude = createShouldExclude(exclusions, secrets, ignored);
|
|
120
|
+
const [readResult, vcsResult] = await Promise.all([
|
|
121
|
+
readReferenceSource(root, resources, {
|
|
100
122
|
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
101
123
|
shouldExclude,
|
|
102
124
|
}),
|
|
103
|
-
readReferenceSourceVcs(root, options.signal),
|
|
125
|
+
readReferenceSourceVcs(root, resources, options.signal),
|
|
104
126
|
]);
|
|
105
|
-
if (!readResult.ok)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return err(failure("unsupported", error.message));
|
|
111
|
-
return err(failure("io", error.message));
|
|
112
|
-
}
|
|
127
|
+
if (!readResult.ok)
|
|
128
|
+
return err(combineReadFailures(readResult.error, vcsResult.ok ? undefined : vcsResult.error, readResult.error.partial));
|
|
129
|
+
if (!vcsResult.ok)
|
|
130
|
+
return err(combineReadFailures(vcsResult.error, undefined, readResult.value));
|
|
131
|
+
const vcs = vcsResult.value;
|
|
113
132
|
if (isAborted(options.signal))
|
|
114
|
-
return err(cancelled());
|
|
133
|
+
return err(cancelled(readResult.value));
|
|
115
134
|
const read = readResult.value;
|
|
116
135
|
const filePaths = new Set(read.entries
|
|
117
136
|
.filter((entry) => entry.status === "read" && entry.kind === "file")
|
|
118
137
|
.map((entry) => entry.path));
|
|
119
138
|
const { entries, relationships, parseFailures, limitations } = parseReferenceSourceEntries(read, filePaths, options.signal);
|
|
120
139
|
if (isAborted(options.signal))
|
|
121
|
-
return err(cancelled());
|
|
140
|
+
return err(cancelled(read));
|
|
122
141
|
const uniqueRelationships = deduplicateRelationships(relationships);
|
|
123
142
|
const uniqueFailures = normalizeHistoricalSourceParseFailures(parseFailures);
|
|
124
143
|
const sortedEntries = [...entries].sort((left, right) => compareUnicodeCodePoints(left.path, right.path));
|
|
@@ -152,3 +171,31 @@ export const importReferenceSource = async (options) => {
|
|
|
152
171
|
return err(failure("parse", cause instanceof Error ? cause.message : "Graph failed validation"));
|
|
153
172
|
}
|
|
154
173
|
};
|
|
174
|
+
const combineReadFailures = (primary, other, partial) => {
|
|
175
|
+
const code = primary.code === "cancelled" || other?.code === "cancelled"
|
|
176
|
+
? "cancelled"
|
|
177
|
+
: primary.code;
|
|
178
|
+
const cleanup = mergeCleanup(primary.cleanup, other?.cleanup);
|
|
179
|
+
const message = other === undefined
|
|
180
|
+
? primary.message
|
|
181
|
+
: `${primary.message}; additional reference metadata failure: ${other.message}`;
|
|
182
|
+
const cause = other === undefined
|
|
183
|
+
? primary.cause
|
|
184
|
+
: new AggregateError([primary, other], "Reference source inventory and metadata both failed", { cause: primary });
|
|
185
|
+
return {
|
|
186
|
+
...failure(code, message),
|
|
187
|
+
...(cleanup === undefined ? {} : { cleanup }),
|
|
188
|
+
...(partial === undefined ? {} : { partial }),
|
|
189
|
+
...(cause === undefined ? {} : { cause }),
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const mergeCleanup = (first, second) => {
|
|
193
|
+
if (first === undefined)
|
|
194
|
+
return second;
|
|
195
|
+
if (second === undefined)
|
|
196
|
+
return first;
|
|
197
|
+
return {
|
|
198
|
+
reason: `${first.reason}; ${second.reason}`,
|
|
199
|
+
resources: [...new Set([...first.resources, ...second.resources])],
|
|
200
|
+
};
|
|
201
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { posix } from "node:path";
|
|
3
|
+
import { logicalPathEscapesRoot } from "../domain/artifactIdentity.js";
|
|
4
|
+
import { createReferenceSourcePathLookup, isPortableAbsoluteReferenceTarget, } from "../domain/referenceSourcePathIdentity.js";
|
|
3
5
|
import { classifyReferenceSourcePath, detectReferenceSourceLanguage, } from "../domain/referenceSourceClassification.js";
|
|
4
6
|
import { parseReferenceSourceImports } from "../domain/referenceSourceImportParsing.js";
|
|
5
7
|
import { PARSEABLE_REFERENCE_SOURCE_LANGUAGES } from "./ReferenceSourceImportTypes.js";
|
|
@@ -48,11 +50,11 @@ const failedEntry = (entry) => {
|
|
|
48
50
|
limitations: [limitation],
|
|
49
51
|
};
|
|
50
52
|
};
|
|
51
|
-
const resolveInternalSpecifier = (fromPath, specifier,
|
|
53
|
+
const resolveInternalSpecifier = (fromPath, specifier, lookupPath) => {
|
|
52
54
|
if (posix.isAbsolute(specifier))
|
|
53
55
|
return { to: specifier, resolution: "unresolved" };
|
|
54
56
|
const normalized = posix.normalize(posix.join(posix.dirname(fromPath), specifier));
|
|
55
|
-
if (
|
|
57
|
+
if (logicalPathEscapesRoot(normalized))
|
|
56
58
|
return { to: normalized, resolution: "unresolved" };
|
|
57
59
|
const suffixes = ["", ".ts", ".js", ".mjs", ".cjs", ".tsx", ".jsx"];
|
|
58
60
|
const candidates = suffixes.flatMap((suffix) => [
|
|
@@ -75,12 +77,12 @@ const resolveInternalSpecifier = (fromPath, specifier, filePaths) => {
|
|
|
75
77
|
const stem = normalized.slice(0, -posix.extname(normalized).length);
|
|
76
78
|
candidates.push(...sourceSuffixes.map((suffix) => `${stem}${suffix}`));
|
|
77
79
|
}
|
|
78
|
-
const match =
|
|
80
|
+
const match = lookupPath.resolveCandidates(candidates);
|
|
79
81
|
return match === undefined
|
|
80
82
|
? { to: normalized, resolution: "unresolved" }
|
|
81
83
|
: { to: match, resolution: "internal" };
|
|
82
84
|
};
|
|
83
|
-
const appendFile = (entry,
|
|
85
|
+
const appendFile = (entry, lookupPath, output) => {
|
|
84
86
|
const language = detectReferenceSourceLanguage(entry.path);
|
|
85
87
|
output.entries.push({
|
|
86
88
|
path: entry.path,
|
|
@@ -100,7 +102,7 @@ const appendFile = (entry, filePaths, output) => {
|
|
|
100
102
|
output.relationships.push(relationship);
|
|
101
103
|
continue;
|
|
102
104
|
}
|
|
103
|
-
const resolved = resolveInternalSpecifier(relationship.from_path, relationship.to,
|
|
105
|
+
const resolved = resolveInternalSpecifier(relationship.from_path, relationship.to, lookupPath);
|
|
104
106
|
output.relationships.push({
|
|
105
107
|
...relationship,
|
|
106
108
|
to: resolved.to,
|
|
@@ -109,9 +111,9 @@ const appendFile = (entry, filePaths, output) => {
|
|
|
109
111
|
}
|
|
110
112
|
output.parseFailures.push(...parsed.parse_failures);
|
|
111
113
|
};
|
|
112
|
-
const appendReadEntry = (entry,
|
|
114
|
+
const appendReadEntry = (entry, lookupPath, output) => {
|
|
113
115
|
if (entry.kind === "file") {
|
|
114
|
-
appendFile(entry,
|
|
116
|
+
appendFile(entry, lookupPath, output);
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
117
119
|
const classifications = classifyReferenceSourcePath(entry.path);
|
|
@@ -128,7 +130,13 @@ const appendReadEntry = (entry, filePaths, output) => {
|
|
|
128
130
|
output.entries.push({
|
|
129
131
|
path: entry.path,
|
|
130
132
|
kind: "symlink",
|
|
131
|
-
|
|
133
|
+
// The reader resolves inventory identities from its root; the persisted
|
|
134
|
+
// graph represents relative symlink targets from the link's directory.
|
|
135
|
+
target: entry.targetState === "internal" ||
|
|
136
|
+
(entry.targetState === "missing" &&
|
|
137
|
+
!isPortableAbsoluteReferenceTarget(entry.target))
|
|
138
|
+
? posix.relative(posix.dirname(entry.path), entry.target) || "."
|
|
139
|
+
: entry.target,
|
|
132
140
|
target_state: entry.targetState,
|
|
133
141
|
classifications,
|
|
134
142
|
limitations: [],
|
|
@@ -142,13 +150,14 @@ export const parseReferenceSourceEntries = (read, filePaths, signal) => {
|
|
|
142
150
|
parseFailures: [],
|
|
143
151
|
limitations: [...read.limitations],
|
|
144
152
|
};
|
|
153
|
+
const lookupPath = createReferenceSourcePathLookup(filePaths);
|
|
145
154
|
for (const entry of read.entries) {
|
|
146
155
|
if (signal?.aborted === true)
|
|
147
156
|
break;
|
|
148
157
|
if (entry.status === "failed")
|
|
149
158
|
output.entries.push(failedEntry(entry));
|
|
150
159
|
else
|
|
151
|
-
appendReadEntry(entry,
|
|
160
|
+
appendReadEntry(entry, lookupPath, output);
|
|
152
161
|
}
|
|
153
162
|
return output;
|
|
154
163
|
};
|
|
@@ -1,49 +1,125 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lstat, realpath, stat } from "node:fs/promises";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import ignore from "ignore";
|
|
4
|
+
import { readRegularFileText, RegularFileCleanupFailure, retryRegularFileCleanup, } from "./RegularFileRead.js";
|
|
4
5
|
import { err, ok } from "../domain/result.js";
|
|
6
|
+
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
|
|
5
7
|
import { DEFAULT_REFERENCE_SOURCE_IGNORE_PATTERNS, } from "./ReferenceSourceImportTypes.js";
|
|
8
|
+
import { rootFilesystemFailure } from "../reference/ReferenceSourceReaderErrors.js";
|
|
6
9
|
const failure = (code, message) => ({
|
|
7
10
|
tag: "reference-source-import",
|
|
8
11
|
code,
|
|
9
12
|
message,
|
|
10
13
|
});
|
|
11
|
-
const
|
|
14
|
+
const isAborted = (signal) => signal?.aborted === true;
|
|
15
|
+
const addMarkedPatterns = (matcher, patterns, mark) => {
|
|
16
|
+
for (const pattern of patterns)
|
|
17
|
+
for (const line of pattern.split(/\r?\n/u))
|
|
18
|
+
matcher.add({ pattern: line, mark });
|
|
19
|
+
};
|
|
20
|
+
const resolveRoot = async (requestedRoot, signal) => {
|
|
21
|
+
if (isAborted(signal))
|
|
22
|
+
return err(failure("cancelled", "Reference source import cancelled"));
|
|
12
23
|
try {
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
const metadata = await stat(requestedRoot);
|
|
25
|
+
if (isAborted(signal))
|
|
26
|
+
return err(failure("cancelled", "Reference source import cancelled"));
|
|
27
|
+
if (!metadata.isDirectory())
|
|
28
|
+
return err(failure("invalid-root", `Reference source root is not a directory: ${requestedRoot}`));
|
|
15
29
|
const canonicalRoot = await realpath(resolve(requestedRoot));
|
|
30
|
+
if (isAborted(signal))
|
|
31
|
+
return err(failure("cancelled", "Reference source import cancelled"));
|
|
16
32
|
return ok(canonicalRoot);
|
|
17
33
|
}
|
|
18
34
|
catch (cause) {
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
if (isAborted(signal))
|
|
36
|
+
return err(failure("cancelled", "Reference source import cancelled"));
|
|
37
|
+
const rootFailure = rootFilesystemFailure(cause, "Reference source root could not be resolved");
|
|
38
|
+
if (rootFailure === undefined)
|
|
39
|
+
throw cause;
|
|
40
|
+
return err({ ...failure(rootFailure.code, rootFailure.message), cause });
|
|
21
41
|
}
|
|
22
42
|
};
|
|
23
|
-
const buildIgnored = async (root, excludePaths) => {
|
|
43
|
+
const buildIgnored = async (root, excludePaths, resources, signal) => {
|
|
24
44
|
const ignored = ignore();
|
|
45
|
+
const policyPath = join(root, ".gitignore");
|
|
46
|
+
let present = true;
|
|
25
47
|
try {
|
|
26
|
-
|
|
48
|
+
await lstat(policyPath);
|
|
27
49
|
}
|
|
28
50
|
catch (cause) {
|
|
29
|
-
|
|
30
|
-
|
|
51
|
+
if (!(typeof cause === "object" &&
|
|
52
|
+
cause !== null &&
|
|
53
|
+
"code" in cause &&
|
|
54
|
+
cause.code === "ENOENT"))
|
|
55
|
+
throw cause;
|
|
56
|
+
present = false;
|
|
57
|
+
}
|
|
58
|
+
signal?.throwIfAborted();
|
|
59
|
+
if (present) {
|
|
60
|
+
let text;
|
|
61
|
+
try {
|
|
62
|
+
text = await readRegularFileText(policyPath, { signal });
|
|
63
|
+
}
|
|
64
|
+
catch (cause) {
|
|
65
|
+
if (!(cause instanceof RegularFileCleanupFailure))
|
|
66
|
+
throw cause;
|
|
67
|
+
const retry = await retryRegularFileCleanup(cause, resources);
|
|
68
|
+
if (retry.cleanup !== undefined) {
|
|
69
|
+
const primary = cause.outcome.kind === "failed"
|
|
70
|
+
? cause.outcome.cause
|
|
71
|
+
: cause.cleanupCause;
|
|
72
|
+
return err({
|
|
73
|
+
...failure(signal?.aborted === true ? "cancelled" : "io", `Reference source ignore policy could not be read at ${policyPath}: ${errorMessage(primary)}`),
|
|
74
|
+
cleanup: retry.cleanup,
|
|
75
|
+
cause: primary,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (retry.outcome.kind === "failed")
|
|
79
|
+
throw retry.outcome.cause;
|
|
80
|
+
text = retry.outcome.value;
|
|
81
|
+
}
|
|
82
|
+
addMarkedPatterns(ignored, [text], "project-ignored");
|
|
31
83
|
}
|
|
32
|
-
ignored
|
|
84
|
+
addMarkedPatterns(ignored, DEFAULT_REFERENCE_SOURCE_IGNORE_PATTERNS, "default-ignored");
|
|
33
85
|
for (const path of excludePaths) {
|
|
34
|
-
ignored
|
|
35
|
-
ignored.add(`${path}/`);
|
|
86
|
+
addMarkedPatterns(ignored, [path, `${path}/`], "caller-excluded");
|
|
36
87
|
}
|
|
37
|
-
return ignored;
|
|
88
|
+
return ok(ignored);
|
|
38
89
|
};
|
|
39
90
|
/** Resolve the caller-selected directory and build path filters. */
|
|
40
|
-
export const prepareReferenceSourceImport = async (options) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
91
|
+
export const prepareReferenceSourceImport = async (options, resources) => {
|
|
92
|
+
try {
|
|
93
|
+
return await resources.run(async () => {
|
|
94
|
+
const root = await resolveRoot(options.root, options.signal);
|
|
95
|
+
if (!root.ok)
|
|
96
|
+
return root;
|
|
97
|
+
try {
|
|
98
|
+
const ignored = await buildIgnored(root.value, options.excludePaths ?? [], resources, options.signal);
|
|
99
|
+
if (!ignored.ok)
|
|
100
|
+
return ignored;
|
|
101
|
+
return ok({
|
|
102
|
+
root: root.value,
|
|
103
|
+
ignored: ignored.value,
|
|
104
|
+
secrets: ignore().add([...options.policy.secretPatterns]),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (cause) {
|
|
108
|
+
return err({
|
|
109
|
+
...failure(options.signal?.aborted === true ? "cancelled" : "io", `Reference source ignore policy could not be read at ${join(root.value, ".gitignore")}: ${errorMessage(cause)}`),
|
|
110
|
+
cause,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (cause) {
|
|
116
|
+
if (!(cause instanceof ArtifactReaderFailure))
|
|
117
|
+
throw cause;
|
|
118
|
+
return err({
|
|
119
|
+
...failure(cause.reason === "cancelled" ? "cancelled" : "io", cause.message),
|
|
120
|
+
...(cause.cleanup === undefined ? {} : { cleanup: cause.cleanup }),
|
|
121
|
+
cause,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
49
124
|
};
|
|
125
|
+
const errorMessage = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
@@ -1,28 +1,36 @@
|
|
|
1
|
+
const IMPORT_FAILURE_GUIDANCE = {
|
|
2
|
+
cancelled: {
|
|
3
|
+
category: "cancelled",
|
|
4
|
+
message: "Reference source import was cancelled. Start it again when ready.",
|
|
5
|
+
},
|
|
6
|
+
"invalid-root": {
|
|
7
|
+
category: "invalid_input",
|
|
8
|
+
message: "Reference source directory could not be opened. Check that the path exists, is readable, and points to a directory.",
|
|
9
|
+
},
|
|
10
|
+
unsupported: {
|
|
11
|
+
category: "unsupported_host",
|
|
12
|
+
message: "Safe no-follow file opens are unavailable on this host. Import the source tree with REA on Linux (including WSL) or macOS.",
|
|
13
|
+
},
|
|
14
|
+
io: {
|
|
15
|
+
category: "execution_failure",
|
|
16
|
+
message: "Reference source files could not be read. Check directory permissions and try again.",
|
|
17
|
+
},
|
|
18
|
+
parse: {
|
|
19
|
+
category: "execution_failure",
|
|
20
|
+
message: "Reference source could not be indexed. Check that the source tree is readable, then try again.",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
1
23
|
/** Safe CLI projection for a historical-source import failure. */
|
|
2
24
|
export const projectReferenceSourceImportError = (error) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
if (error.code === "invalid-root")
|
|
9
|
-
return {
|
|
10
|
-
category: "invalid_input",
|
|
11
|
-
message: "Reference source directory could not be opened. Check that the path exists, is readable, and points to a directory.",
|
|
12
|
-
};
|
|
13
|
-
if (error.code === "unsupported")
|
|
14
|
-
return {
|
|
15
|
-
category: "unsupported_host",
|
|
16
|
-
message: "Safe no-follow file opens are unavailable on this host. Import the source tree with REA on Linux (including WSL) or macOS.",
|
|
17
|
-
};
|
|
18
|
-
if (error.code === "io")
|
|
19
|
-
return {
|
|
20
|
-
category: "execution_failure",
|
|
21
|
-
message: "Reference source files could not be read. Check directory permissions and try again.",
|
|
22
|
-
};
|
|
25
|
+
const primary = IMPORT_FAILURE_GUIDANCE[error.code];
|
|
26
|
+
const cleanupMessage = error.cleanup === undefined
|
|
27
|
+
? ""
|
|
28
|
+
: ` Cleanup failed during import for ${error.cleanup.resources.join(", ")}: ${error.cleanup.reason}.`;
|
|
23
29
|
return {
|
|
24
|
-
category:
|
|
25
|
-
message:
|
|
30
|
+
category: primary.category,
|
|
31
|
+
message: `${error.message} ${primary.message}${cleanupMessage}`,
|
|
32
|
+
...(error.cleanup === undefined ? {} : { cleanup: error.cleanup }),
|
|
33
|
+
...(error.partial === undefined ? {} : { partial: error.partial }),
|
|
26
34
|
};
|
|
27
35
|
};
|
|
28
36
|
export const DEFAULT_REFERENCE_SOURCE_IGNORE_PATTERNS = [
|
|
@@ -1,60 +1,174 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { lstat
|
|
2
|
+
import { lstat } from "node:fs/promises";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { err, ok } from "../domain/result.js";
|
|
5
|
+
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
|
|
6
|
+
import { readRegularFile, RegularFileCleanupFailure, retryRegularFileCleanup, } from "./RegularFileRead.js";
|
|
5
7
|
/**
|
|
6
8
|
* Read Git metadata for a directory using isomorphic-git.
|
|
7
9
|
*
|
|
8
10
|
* No git subprocess or network is used; only the local `.git` object store is read.
|
|
9
11
|
*/
|
|
10
|
-
export const readReferenceSourceVcs = async (root, signal) => {
|
|
11
|
-
if (isAborted(signal))
|
|
12
|
-
return { kind: "unknown", head: null, dirty: null };
|
|
12
|
+
export const readReferenceSourceVcs = async (root, resources, signal) => {
|
|
13
13
|
try {
|
|
14
|
-
await
|
|
14
|
+
return await resources.run(async () => {
|
|
15
|
+
if (isAborted(signal))
|
|
16
|
+
return ok(unknownVcs());
|
|
17
|
+
try {
|
|
18
|
+
await lstat(join(root, ".git"));
|
|
19
|
+
}
|
|
20
|
+
catch (cause) {
|
|
21
|
+
return ok(errorCode(cause) === "ENOENT"
|
|
22
|
+
? { kind: "none", head: null, dirty: null }
|
|
23
|
+
: unknownVcs());
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const head = await resolveSourceHead(root, resources, signal);
|
|
27
|
+
if (isAborted(signal))
|
|
28
|
+
return ok(unknownVcs());
|
|
29
|
+
return ok({ kind: "git", head, dirty: null });
|
|
30
|
+
}
|
|
31
|
+
catch (cause) {
|
|
32
|
+
if (cause instanceof ArtifactReaderFailure)
|
|
33
|
+
throw cause;
|
|
34
|
+
return ok(unknownVcs());
|
|
35
|
+
}
|
|
36
|
+
});
|
|
15
37
|
}
|
|
16
38
|
catch (cause) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
catch (cause) {
|
|
28
|
-
// Unresolvable refs mean VCS state is unknown, not absent.
|
|
29
|
-
void cause;
|
|
30
|
-
return { kind: "unknown", head: null, dirty: null };
|
|
39
|
+
if (!(cause instanceof ArtifactReaderFailure))
|
|
40
|
+
throw cause;
|
|
41
|
+
return err({
|
|
42
|
+
tag: "reference-source-reader",
|
|
43
|
+
code: cause.reason === "cancelled" ? "cancelled" : "io",
|
|
44
|
+
message: cause.message,
|
|
45
|
+
...(cause.cleanup === undefined ? {} : { cleanup: cause.cleanup }),
|
|
46
|
+
cause,
|
|
47
|
+
});
|
|
31
48
|
}
|
|
32
49
|
};
|
|
33
|
-
const
|
|
50
|
+
const unknownVcs = () => ({
|
|
51
|
+
kind: "unknown",
|
|
52
|
+
head: null,
|
|
53
|
+
dirty: null,
|
|
54
|
+
});
|
|
55
|
+
const resolveSourceHead = async (root, resources, signal) => {
|
|
56
|
+
// isomorphic-git is loaded on first use so CLI and MCP startup skip it.
|
|
57
|
+
const { resolveRef } = await import("isomorphic-git");
|
|
58
|
+
let failedRead;
|
|
59
|
+
const cleanupFailures = [];
|
|
60
|
+
const readMetadataBytes = async (path) => {
|
|
61
|
+
try {
|
|
62
|
+
return await readRegularFile(path, { signal });
|
|
63
|
+
}
|
|
64
|
+
catch (cause) {
|
|
65
|
+
if (!(cause instanceof RegularFileCleanupFailure))
|
|
66
|
+
throw cause;
|
|
67
|
+
const retry = await retryRegularFileCleanup(cause, resources);
|
|
68
|
+
if (retry.outcome.kind === "failed" &&
|
|
69
|
+
errorCode(retry.outcome.cause) !== "ENOENT")
|
|
70
|
+
failedRead ??= { cause: retry.outcome.cause };
|
|
71
|
+
if (retry.cleanup === undefined &&
|
|
72
|
+
retry.outcome.kind === "failed" &&
|
|
73
|
+
!isAborted(signal))
|
|
74
|
+
throw retry.outcome.cause;
|
|
75
|
+
const primary = retry.outcome.kind === "failed"
|
|
76
|
+
? retry.outcome.cause
|
|
77
|
+
: cause.cleanupCause;
|
|
78
|
+
throw new ArtifactReaderFailure(isAborted(signal) ? "cancelled" : "io", `Git metadata could not be read safely: ${errorMessage(primary)}`, {
|
|
79
|
+
cause: primary,
|
|
80
|
+
...(retry.cleanup === undefined ? {} : { cleanup: retry.cleanup }),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const readMetadataText = async (path) => (await readMetadataBytes(path)).toString("utf8");
|
|
85
|
+
const throwCleanupFailures = (primary) => {
|
|
86
|
+
const observations = cleanupFailures.flatMap((failure) => failure.cleanup === undefined ? [] : [failure.cleanup]);
|
|
87
|
+
throw new ArtifactReaderFailure(isAborted(signal) ? "cancelled" : "io", `Git metadata could not be read safely: ${errorMessage(primary)}`, {
|
|
88
|
+
cause: new AggregateError([primary, ...cleanupFailures], "Git metadata reads and cleanup failed", { cause: primary }),
|
|
89
|
+
...(observations.length === 0
|
|
90
|
+
? {}
|
|
91
|
+
: {
|
|
92
|
+
cleanup: {
|
|
93
|
+
reason: observations.map(({ reason }) => reason).join("; "),
|
|
94
|
+
resources: [
|
|
95
|
+
...new Set(observations.flatMap(({ resources }) => resources)),
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const referenceFs = {
|
|
102
|
+
...fs,
|
|
103
|
+
promises: {
|
|
104
|
+
...fs.promises,
|
|
105
|
+
// Let isomorphic-git continue from a failed loose ref to packed-refs,
|
|
106
|
+
// then report the original read failure after resolution. This preserves
|
|
107
|
+
// both observations when packed metadata also fails cleanup.
|
|
108
|
+
readFile: async (path, options = null) => {
|
|
109
|
+
// The library probes readFile() without a path to detect promise APIs.
|
|
110
|
+
// Reject that invocation without attributing it to a source read.
|
|
111
|
+
if (path === undefined)
|
|
112
|
+
throw new TypeError("Git filesystem read requires a path");
|
|
113
|
+
try {
|
|
114
|
+
const bytes = await readMetadataBytes(path);
|
|
115
|
+
const encoding = typeof options === "string" ? options : options?.encoding;
|
|
116
|
+
return encoding === undefined || encoding === null
|
|
117
|
+
? bytes
|
|
118
|
+
: bytes.toString(encoding);
|
|
119
|
+
}
|
|
120
|
+
catch (cause) {
|
|
121
|
+
if (cause instanceof ArtifactReaderFailure) {
|
|
122
|
+
cleanupFailures.push(cause);
|
|
123
|
+
}
|
|
124
|
+
else if (errorCode(cause) !== "ENOENT")
|
|
125
|
+
failedRead ??= { cause };
|
|
126
|
+
throw cause;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
const readRef = async (options) => {
|
|
132
|
+
let head;
|
|
133
|
+
try {
|
|
134
|
+
head = await resolveRef({ fs: referenceFs, dir: root, ...options });
|
|
135
|
+
}
|
|
136
|
+
catch (cause) {
|
|
137
|
+
if (cleanupFailures.length > 0)
|
|
138
|
+
throwCleanupFailures(failedRead?.cause ?? cause);
|
|
139
|
+
if (failedRead !== undefined)
|
|
140
|
+
throw failedRead.cause;
|
|
141
|
+
throw cause;
|
|
142
|
+
}
|
|
143
|
+
if (cleanupFailures.length > 0)
|
|
144
|
+
throwCleanupFailures(failedRead?.cause ?? cleanupFailures[0]?.cause);
|
|
145
|
+
signal?.throwIfAborted();
|
|
146
|
+
if (failedRead !== undefined)
|
|
147
|
+
throw failedRead.cause;
|
|
148
|
+
return head;
|
|
149
|
+
};
|
|
34
150
|
const dotgit = join(root, ".git");
|
|
35
151
|
if (!(await lstat(dotgit)).isFile())
|
|
36
|
-
return
|
|
37
|
-
const pointer = (await
|
|
152
|
+
return readRef({ ref: "HEAD" });
|
|
153
|
+
const pointer = (await readMetadataText(dotgit)).replace(/\r?\n$/u, "");
|
|
38
154
|
if (!pointer.startsWith("gitdir: ") || pointer.length === 8)
|
|
39
155
|
throw new Error("Invalid Git directory pointer");
|
|
40
156
|
const gitdir = resolve(root, pointer.slice(8));
|
|
41
157
|
let commonDirectory;
|
|
42
158
|
try {
|
|
43
|
-
commonDirectory = resolve(gitdir, (await
|
|
159
|
+
commonDirectory = resolve(gitdir, (await readMetadataText(join(gitdir, "commondir"))).replace(/\r?\n$/u, ""));
|
|
44
160
|
}
|
|
45
161
|
catch (cause) {
|
|
46
162
|
if (errorCode(cause) !== "ENOENT")
|
|
47
163
|
throw cause;
|
|
48
|
-
return
|
|
164
|
+
return readRef({ gitdir, ref: "HEAD" });
|
|
49
165
|
}
|
|
50
|
-
const head = (await
|
|
166
|
+
const head = (await readMetadataText(join(gitdir, "HEAD"))).trim();
|
|
51
167
|
if (!head.startsWith("ref: "))
|
|
52
|
-
return
|
|
168
|
+
return readRef({ gitdir, ref: "HEAD" });
|
|
53
169
|
const ref = head.slice(5);
|
|
54
170
|
const privateRef = ["refs/bisect/", "refs/rewritten/", "refs/worktree/"].some((prefix) => ref.startsWith(prefix));
|
|
55
|
-
return
|
|
56
|
-
fs,
|
|
57
|
-
dir: root,
|
|
171
|
+
return readRef({
|
|
58
172
|
gitdir: privateRef ? gitdir : commonDirectory,
|
|
59
173
|
ref,
|
|
60
174
|
});
|
|
@@ -62,4 +176,5 @@ const resolveSourceHead = async (root) => {
|
|
|
62
176
|
const errorCode = (cause) => typeof cause === "object" && cause !== null && "code" in cause
|
|
63
177
|
? String(cause.code)
|
|
64
178
|
: undefined;
|
|
179
|
+
const errorMessage = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
65
180
|
const isAborted = (signal) => signal?.aborted === true;
|