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
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Client, StreamableHTTPClientTransport, } from "@modelcontextprotocol/client";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
4
|
+
import { AnalysisCancelledError, AnalysisProtocolError, } from "../domain/analysisErrorCore.js";
|
|
5
|
+
const toolResultSchema = z.object({
|
|
6
|
+
isError: z.boolean().optional(),
|
|
7
|
+
structuredContent: z.record(z.string(), z.unknown()).optional(),
|
|
8
|
+
content: z
|
|
9
|
+
.array(z.object({ type: z.string(), text: z.string().optional() }).passthrough())
|
|
10
|
+
.default([]),
|
|
11
|
+
});
|
|
12
|
+
/** Decode a JEB MCP tool result without inventing an empty observation. */
|
|
13
|
+
export const decodeJebToolResult = (input) => {
|
|
14
|
+
const result = toolResultSchema.parse(input);
|
|
15
|
+
const blocks = result.content.flatMap((block) => block.type === "text" && block.text !== undefined ? [block.text] : []);
|
|
16
|
+
if (result.structuredContent !== undefined) {
|
|
17
|
+
// isError envelopes carry JEB's {success:false, message} refusal semantics;
|
|
18
|
+
// decode them so the provider can preserve the engine's own reason.
|
|
19
|
+
return jsonValueSchema.parse(result.structuredContent);
|
|
20
|
+
}
|
|
21
|
+
if (blocks.length !== 1)
|
|
22
|
+
throw new AnalysisProtocolError("JEB MCP omitted a single structured or text result; unsupported content cannot establish an empty observation.");
|
|
23
|
+
try {
|
|
24
|
+
return jsonValueSchema.parse(JSON.parse(blocks[0] ?? "null"));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
if (result.isError === true)
|
|
28
|
+
throw new AnalysisProtocolError(`JEB MCP tool failed: ${blocks[0] ?? "unexplained engine failure"}`);
|
|
29
|
+
return blocks[0] ?? null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
/** Serve JEB requests from a running engine client over streamable HTTP. */
|
|
33
|
+
export const createStreamableHttpJebMcpConnection = (endpoint) => {
|
|
34
|
+
let state;
|
|
35
|
+
let closing;
|
|
36
|
+
let closed = false;
|
|
37
|
+
const waitForCaller = (promise, signal) => {
|
|
38
|
+
if (signal?.aborted === true)
|
|
39
|
+
return Promise.reject(new AnalysisCancelledError("jeb_mcp"));
|
|
40
|
+
if (signal === undefined)
|
|
41
|
+
return promise;
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const abort = () => {
|
|
44
|
+
signal.removeEventListener("abort", abort);
|
|
45
|
+
reject(new AnalysisCancelledError("jeb_mcp"));
|
|
46
|
+
};
|
|
47
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
48
|
+
void promise.then((value) => {
|
|
49
|
+
signal.removeEventListener("abort", abort);
|
|
50
|
+
resolve(value);
|
|
51
|
+
}, (cause) => {
|
|
52
|
+
signal.removeEventListener("abort", abort);
|
|
53
|
+
reject(cause);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const dispose = async (owner) => {
|
|
58
|
+
if (owner.disposal !== undefined)
|
|
59
|
+
return owner.disposal;
|
|
60
|
+
const cleanup = (async () => {
|
|
61
|
+
const settled = await Promise.allSettled([
|
|
62
|
+
owner.client.close(),
|
|
63
|
+
owner.transport.close(),
|
|
64
|
+
]);
|
|
65
|
+
const failures = settled.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
66
|
+
if (failures.length > 0)
|
|
67
|
+
throw new AggregateError(failures, "JEB MCP connection cleanup failed");
|
|
68
|
+
if (state === owner)
|
|
69
|
+
state = undefined;
|
|
70
|
+
})();
|
|
71
|
+
owner.disposal = cleanup;
|
|
72
|
+
try {
|
|
73
|
+
await cleanup;
|
|
74
|
+
}
|
|
75
|
+
catch (cause) {
|
|
76
|
+
owner.disposal = undefined;
|
|
77
|
+
throw cause;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const connect = async (signal) => {
|
|
81
|
+
if (signal?.aborted === true)
|
|
82
|
+
throw new AnalysisCancelledError("jeb_mcp");
|
|
83
|
+
if (closing !== undefined)
|
|
84
|
+
await closing;
|
|
85
|
+
if (closed) {
|
|
86
|
+
if (state !== undefined)
|
|
87
|
+
await dispose(state);
|
|
88
|
+
throw new AnalysisProtocolError("JEB MCP connection is closed");
|
|
89
|
+
}
|
|
90
|
+
if (state?.tools !== undefined && state.disposal === undefined)
|
|
91
|
+
return state.tools;
|
|
92
|
+
if (state?.acquisition !== undefined)
|
|
93
|
+
return waitForCaller(state.acquisition, signal);
|
|
94
|
+
if (state !== undefined) {
|
|
95
|
+
await dispose(state);
|
|
96
|
+
if (state !== undefined || closing !== undefined)
|
|
97
|
+
return connect(signal);
|
|
98
|
+
}
|
|
99
|
+
const owner = {
|
|
100
|
+
client: new Client({
|
|
101
|
+
name: "rea-jeb",
|
|
102
|
+
version: "0.0.0",
|
|
103
|
+
}),
|
|
104
|
+
transport: new StreamableHTTPClientTransport(endpoint, {
|
|
105
|
+
requestInit: { redirect: "error" },
|
|
106
|
+
}),
|
|
107
|
+
signal: new AbortController(),
|
|
108
|
+
tools: undefined,
|
|
109
|
+
acquisition: undefined,
|
|
110
|
+
disposal: undefined,
|
|
111
|
+
};
|
|
112
|
+
state = owner;
|
|
113
|
+
const acquisition = (async () => {
|
|
114
|
+
try {
|
|
115
|
+
await owner.client.connect(owner.transport, {
|
|
116
|
+
signal: owner.signal.signal,
|
|
117
|
+
});
|
|
118
|
+
const listing = await owner.client.listTools({}, { signal: owner.signal.signal });
|
|
119
|
+
const tools = listing.tools.map((tool) => tool.name);
|
|
120
|
+
owner.tools = tools;
|
|
121
|
+
return tools;
|
|
122
|
+
}
|
|
123
|
+
catch (cause) {
|
|
124
|
+
owner.signal.abort(cause);
|
|
125
|
+
try {
|
|
126
|
+
await dispose(owner);
|
|
127
|
+
}
|
|
128
|
+
catch (cleanupCause) {
|
|
129
|
+
throw new AggregateError([cause, cleanupCause], "JEB MCP connection acquisition and cleanup failed", { cause });
|
|
130
|
+
}
|
|
131
|
+
throw cause;
|
|
132
|
+
}
|
|
133
|
+
})();
|
|
134
|
+
owner.acquisition = acquisition;
|
|
135
|
+
void acquisition.then(() => {
|
|
136
|
+
if (owner.acquisition === acquisition)
|
|
137
|
+
owner.acquisition = undefined;
|
|
138
|
+
}, () => {
|
|
139
|
+
if (owner.acquisition === acquisition)
|
|
140
|
+
owner.acquisition = undefined;
|
|
141
|
+
});
|
|
142
|
+
return waitForCaller(acquisition, signal);
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
connect,
|
|
146
|
+
async call(name, args, signal) {
|
|
147
|
+
await connect(signal);
|
|
148
|
+
const owner = state;
|
|
149
|
+
if (owner === undefined || owner.tools === undefined)
|
|
150
|
+
throw new AnalysisProtocolError("JEB MCP client failed to connect");
|
|
151
|
+
const result = await owner.client.callTool({ name, arguments: args }, signal === undefined ? {} : { signal });
|
|
152
|
+
return decodeJebToolResult(result);
|
|
153
|
+
},
|
|
154
|
+
async close() {
|
|
155
|
+
closed = true;
|
|
156
|
+
if (closing !== undefined)
|
|
157
|
+
return closing;
|
|
158
|
+
const operation = (async () => {
|
|
159
|
+
const owner = state;
|
|
160
|
+
if (owner === undefined)
|
|
161
|
+
return;
|
|
162
|
+
owner.tools = undefined;
|
|
163
|
+
owner.signal.abort();
|
|
164
|
+
if (owner.acquisition !== undefined)
|
|
165
|
+
await owner.acquisition.catch(() => undefined);
|
|
166
|
+
if (state === owner)
|
|
167
|
+
await dispose(owner);
|
|
168
|
+
})();
|
|
169
|
+
closing = operation;
|
|
170
|
+
try {
|
|
171
|
+
await operation;
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
if (closing === operation)
|
|
175
|
+
closing = undefined;
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
2
|
+
import { err, ok } from "../domain/result.js";
|
|
3
|
+
/** Default JEB MCP endpoint documented by the engine's headless client. */
|
|
4
|
+
export const DEFAULT_JEB_MCP_ENDPOINT = "http://127.0.0.1:8425/mcp";
|
|
5
|
+
/**
|
|
6
|
+
* Normalize the caller-selected JEB MCP endpoint.
|
|
7
|
+
*
|
|
8
|
+
* Only the scheme, host, and port select the engine; credentials, paths with
|
|
9
|
+
* segments beyond the MCP route, queries, and fragments are rejected rather
|
|
10
|
+
* than silently dropped.
|
|
11
|
+
*/
|
|
12
|
+
export const parseJebMcpEndpoint = (value) => {
|
|
13
|
+
const raw = value === undefined || value.length === 0 ? null : value;
|
|
14
|
+
let url;
|
|
15
|
+
try {
|
|
16
|
+
url = new URL(raw ?? DEFAULT_JEB_MCP_ENDPOINT);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return err(new AnalysisInputError("jeb_mcp_endpoint", {
|
|
20
|
+
cause: "Expected an absolute http(s) URL",
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
24
|
+
return err(new AnalysisInputError("jeb_mcp_endpoint", {
|
|
25
|
+
cause: "Only http and https JEB MCP endpoints are supported",
|
|
26
|
+
}));
|
|
27
|
+
if (url.hostname !== "127.0.0.1" && url.hostname !== "[::1]")
|
|
28
|
+
return err(new AnalysisInputError("jeb_mcp_endpoint", {
|
|
29
|
+
cause: "JEB MCP endpoint must use a literal loopback host (127.0.0.1 or ::1)",
|
|
30
|
+
}));
|
|
31
|
+
if (url.username !== "" || url.password !== "")
|
|
32
|
+
return err(new AnalysisInputError("jeb_mcp_endpoint", {
|
|
33
|
+
cause: "Embedding credentials in the JEB MCP endpoint is not supported; configure authentication with the engine",
|
|
34
|
+
}));
|
|
35
|
+
if (url.search !== "" || url.hash !== "")
|
|
36
|
+
return err(new AnalysisInputError("jeb_mcp_endpoint", {
|
|
37
|
+
cause: "JEB MCP endpoint query strings and fragments are not supported",
|
|
38
|
+
}));
|
|
39
|
+
return ok(url);
|
|
40
|
+
};
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createAnalysisExecution } from "../application/AnalysisProvider.js";
|
|
3
|
+
import { jebResultSchemas } from "../domain/jeb/jebAnalysis.js";
|
|
4
|
+
import { AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisProtocolError, AnalysisUnsupportedTargetError, } from "../domain/analysisErrorCore.js";
|
|
5
|
+
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
|
6
|
+
import { err, ok } from "../domain/result.js";
|
|
7
|
+
import { parseJebMcpEndpoint, DEFAULT_JEB_MCP_ENDPOINT, } from "./JebMcpEndpoint.js";
|
|
8
|
+
import { createStreamableHttpJebMcpConnection, } from "./JebMcpConnection.js";
|
|
9
|
+
export const JEB_PROVIDER_IDENTITY = {
|
|
10
|
+
id: "jeb",
|
|
11
|
+
name: "JEB",
|
|
12
|
+
version: null,
|
|
13
|
+
};
|
|
14
|
+
/** JEB's tool envelope: success with typed fields, or a message-only failure. */
|
|
15
|
+
const failure = z
|
|
16
|
+
.object({
|
|
17
|
+
success: z.literal(false),
|
|
18
|
+
message: z.string().optional(),
|
|
19
|
+
error: z
|
|
20
|
+
.object({
|
|
21
|
+
code: z.string().optional(),
|
|
22
|
+
message: z.string().optional(),
|
|
23
|
+
recovery_tool: z.string().optional(),
|
|
24
|
+
})
|
|
25
|
+
.optional(),
|
|
26
|
+
})
|
|
27
|
+
.passthrough();
|
|
28
|
+
const clientInformation = z
|
|
29
|
+
.object({
|
|
30
|
+
success: z.literal(true),
|
|
31
|
+
version: z.string().optional(),
|
|
32
|
+
gui_client: z.boolean().optional(),
|
|
33
|
+
startup_ts: z.number().int().nonnegative().optional(),
|
|
34
|
+
message: z.string().nullish(),
|
|
35
|
+
})
|
|
36
|
+
.passthrough();
|
|
37
|
+
const unitEntry = z.object({ unit_path: z.string(), unit_type: z.string() });
|
|
38
|
+
const openProject = z
|
|
39
|
+
.object({
|
|
40
|
+
success: z.literal(true),
|
|
41
|
+
name: z.string().nullish(),
|
|
42
|
+
creation_datetime: z.string().nullish(),
|
|
43
|
+
input_files: z
|
|
44
|
+
.array(z.object({
|
|
45
|
+
file_name: z.string(),
|
|
46
|
+
file_size: z.number().int().nonnegative(),
|
|
47
|
+
contents_sha256_hash: z.string(),
|
|
48
|
+
}))
|
|
49
|
+
.optional(),
|
|
50
|
+
units: z.array(unitEntry).optional(),
|
|
51
|
+
})
|
|
52
|
+
.passthrough();
|
|
53
|
+
const listUnits = z
|
|
54
|
+
.object({ success: z.literal(true), units: z.array(unitEntry) })
|
|
55
|
+
.passthrough();
|
|
56
|
+
const decompiledItem = z
|
|
57
|
+
.object({ success: z.literal(true), text: z.string() })
|
|
58
|
+
.passthrough();
|
|
59
|
+
const refusalReason = (payload, fallback) => {
|
|
60
|
+
const parsed = failure.safeParse(payload);
|
|
61
|
+
if (!parsed.success)
|
|
62
|
+
return fallback;
|
|
63
|
+
const envelope = parsed.data;
|
|
64
|
+
const reason = envelope.error?.message ?? envelope.message ?? envelope.error?.code;
|
|
65
|
+
if (reason !== undefined && reason.length > 0)
|
|
66
|
+
return reason;
|
|
67
|
+
return fallback;
|
|
68
|
+
};
|
|
69
|
+
/** Serve REA's JEB operations from a running engine client over MCP. */
|
|
70
|
+
export class JebProvider {
|
|
71
|
+
#connection;
|
|
72
|
+
#endpoint;
|
|
73
|
+
#identity = JEB_PROVIDER_IDENTITY;
|
|
74
|
+
#guiClient = null;
|
|
75
|
+
constructor(options = {}) {
|
|
76
|
+
const environment = options.environment ?? {};
|
|
77
|
+
const endpoint = parseJebMcpEndpoint(environment.REA_JEB_MCP_URL);
|
|
78
|
+
if (!endpoint.ok)
|
|
79
|
+
throw endpoint.error;
|
|
80
|
+
this.#endpoint = endpoint.value;
|
|
81
|
+
this.#connection = (options.connectionFactory ??
|
|
82
|
+
((url) => createStreamableHttpJebMcpConnection(url)))(this.#endpoint);
|
|
83
|
+
}
|
|
84
|
+
async inspectAvailability(signal) {
|
|
85
|
+
try {
|
|
86
|
+
await this.#refreshClientInformation(signal);
|
|
87
|
+
return {
|
|
88
|
+
status: "available",
|
|
89
|
+
code: null,
|
|
90
|
+
reason: null,
|
|
91
|
+
diagnostics: {
|
|
92
|
+
endpoint: this.#endpoint.toString(),
|
|
93
|
+
engine_version: this.#identity.version,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch (cause) {
|
|
98
|
+
if (signal?.aborted === true)
|
|
99
|
+
throw cause;
|
|
100
|
+
return {
|
|
101
|
+
status: "unavailable",
|
|
102
|
+
code: "not_configured",
|
|
103
|
+
reason: cause instanceof Error
|
|
104
|
+
? cause.message
|
|
105
|
+
: "The JEB MCP endpoint did not respond",
|
|
106
|
+
diagnostics: { endpoint: this.#endpoint.toString() },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async close() {
|
|
111
|
+
await this.#connection.close();
|
|
112
|
+
}
|
|
113
|
+
async execute(request, options) {
|
|
114
|
+
if (options?.signal?.aborted === true)
|
|
115
|
+
return err(new AnalysisCancelledError(request.operation));
|
|
116
|
+
try {
|
|
117
|
+
const execution = await this.#dispatch(request, options?.signal);
|
|
118
|
+
if (options?.signal?.aborted)
|
|
119
|
+
return err(new AnalysisCancelledError(request.operation));
|
|
120
|
+
if (execution.ok)
|
|
121
|
+
this.#identity = {
|
|
122
|
+
...this.#identity,
|
|
123
|
+
version: execution.value.provider.version,
|
|
124
|
+
};
|
|
125
|
+
return execution;
|
|
126
|
+
}
|
|
127
|
+
catch (cause) {
|
|
128
|
+
if (options?.signal?.aborted)
|
|
129
|
+
return err(new AnalysisCancelledError(request.operation, { cause }));
|
|
130
|
+
return err(this.#providerFailure(request.operation, cause));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async #dispatch(request, signal) {
|
|
134
|
+
const cancelled = (operation) => {
|
|
135
|
+
if (signal?.aborted === true)
|
|
136
|
+
throw new AnalysisCancelledError(operation);
|
|
137
|
+
};
|
|
138
|
+
switch (request.operation) {
|
|
139
|
+
case "inspect_jeb_client": {
|
|
140
|
+
cancelled(request.operation);
|
|
141
|
+
return this.#inspectClient(signal);
|
|
142
|
+
}
|
|
143
|
+
case "open_jeb_project": {
|
|
144
|
+
cancelled(request.operation);
|
|
145
|
+
return this.#openProject(request, signal);
|
|
146
|
+
}
|
|
147
|
+
case "list_jeb_units": {
|
|
148
|
+
cancelled(request.operation);
|
|
149
|
+
return this.#listUnits(request, signal);
|
|
150
|
+
}
|
|
151
|
+
case "decompile_jeb_item": {
|
|
152
|
+
cancelled(request.operation);
|
|
153
|
+
return this.#decompileItem(request, signal);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async #engine(signal) {
|
|
158
|
+
await this.#requireClientInformation(signal);
|
|
159
|
+
return {
|
|
160
|
+
name: "jeb",
|
|
161
|
+
version: this.#identity.version,
|
|
162
|
+
endpoint: this.#endpoint.toString(),
|
|
163
|
+
gui_client: this.#guiClient,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async #requireClientInformation(signal) {
|
|
167
|
+
if (this.#identity.version !== null)
|
|
168
|
+
return;
|
|
169
|
+
await this.#refreshClientInformation(signal);
|
|
170
|
+
}
|
|
171
|
+
async #refreshClientInformation(signal) {
|
|
172
|
+
if (signal?.aborted === true)
|
|
173
|
+
throw new AnalysisCancelledError("inspect_jeb_client");
|
|
174
|
+
const payload = await this.#connection.call("get_client_information", {}, signal);
|
|
175
|
+
const information = clientInformation.parse(this.#requireSuccess(payload, "inspect_jeb_client"));
|
|
176
|
+
this.#identity = {
|
|
177
|
+
...this.#identity,
|
|
178
|
+
version: information.version ?? null,
|
|
179
|
+
};
|
|
180
|
+
this.#guiClient = information.gui_client ?? null;
|
|
181
|
+
}
|
|
182
|
+
async #inspectClient(signal) {
|
|
183
|
+
const payload = await this.#connection.call("get_client_information", {}, signal);
|
|
184
|
+
const information = clientInformation.parse(this.#requireSuccess(payload, "inspect_jeb_client"));
|
|
185
|
+
this.#identity = {
|
|
186
|
+
...this.#identity,
|
|
187
|
+
version: information.version ?? null,
|
|
188
|
+
};
|
|
189
|
+
this.#guiClient = information.gui_client ?? null;
|
|
190
|
+
const result = jebResultSchemas.inspect_jeb_client.parse({
|
|
191
|
+
engine: {
|
|
192
|
+
name: "jeb",
|
|
193
|
+
version: information.version ?? null,
|
|
194
|
+
endpoint: this.#endpoint.toString(),
|
|
195
|
+
gui_client: information.gui_client ?? null,
|
|
196
|
+
},
|
|
197
|
+
startup_ts: information.startup_ts ?? null,
|
|
198
|
+
message: information.message ?? null,
|
|
199
|
+
});
|
|
200
|
+
return ok(createAnalysisExecution(result, this.#identity, {
|
|
201
|
+
rawResult: payload,
|
|
202
|
+
limitations: information.version === undefined
|
|
203
|
+
? ["The engine did not report its version."]
|
|
204
|
+
: [],
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
async #openProject(request, signal) {
|
|
208
|
+
const payload = await this.#connection.call("open_project", {
|
|
209
|
+
file_path: request.input.path,
|
|
210
|
+
}, signal);
|
|
211
|
+
const opened = openProject.parse(this.#requireSuccess(payload, request.operation));
|
|
212
|
+
const engine = await this.#engine(signal);
|
|
213
|
+
const result = jebResultSchemas.open_jeb_project.parse({
|
|
214
|
+
engine,
|
|
215
|
+
project_name: opened.name ?? null,
|
|
216
|
+
creation_datetime: opened.creation_datetime ?? null,
|
|
217
|
+
input_files: opened.input_files ?? [],
|
|
218
|
+
units: opened.units ?? [],
|
|
219
|
+
});
|
|
220
|
+
return ok(createAnalysisExecution(result, this.#identity, {
|
|
221
|
+
rawResult: payload,
|
|
222
|
+
limitations: [
|
|
223
|
+
"JEB resolves and analyzes the artifact on the engine host; REA did not open the target itself.",
|
|
224
|
+
],
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
async #listUnits(request, signal) {
|
|
228
|
+
const { count, index, filter, parent_unit_path } = request.input;
|
|
229
|
+
const payload = await this.#connection.call("list_units", {
|
|
230
|
+
count,
|
|
231
|
+
index,
|
|
232
|
+
...(filter === undefined ? {} : { filter }),
|
|
233
|
+
...(parent_unit_path === undefined ? {} : { parent_unit_path }),
|
|
234
|
+
}, signal);
|
|
235
|
+
const listed = listUnits.parse(this.#requireSuccess(payload, request.operation));
|
|
236
|
+
const units = listed.units;
|
|
237
|
+
const engine = await this.#engine(signal);
|
|
238
|
+
const result = jebResultSchemas.list_jeb_units.parse({
|
|
239
|
+
engine,
|
|
240
|
+
filter: filter ?? null,
|
|
241
|
+
parent_unit_path: parent_unit_path ?? null,
|
|
242
|
+
index,
|
|
243
|
+
count,
|
|
244
|
+
units,
|
|
245
|
+
coverage: units.length < count ? "complete" : "partial",
|
|
246
|
+
});
|
|
247
|
+
return ok(createAnalysisExecution(result, this.#identity, {
|
|
248
|
+
rawResult: payload,
|
|
249
|
+
limitations: [
|
|
250
|
+
"The engine caps unit pages at 100; a full page means more units may exist.",
|
|
251
|
+
],
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
async #decompileItem(request, signal) {
|
|
255
|
+
const { item_address, item_kind, unit_path } = request.input;
|
|
256
|
+
const payload = await this.#connection.call("decompile_code_item", {
|
|
257
|
+
item_address,
|
|
258
|
+
item_kind,
|
|
259
|
+
...(unit_path === undefined ? {} : { unit_path }),
|
|
260
|
+
}, signal);
|
|
261
|
+
const decompiled = decompiledItem.parse(this.#requireSuccess(payload, request.operation));
|
|
262
|
+
const engine = await this.#engine(signal);
|
|
263
|
+
const result = jebResultSchemas.decompile_jeb_item.parse({
|
|
264
|
+
engine,
|
|
265
|
+
unit_path: unit_path ?? null,
|
|
266
|
+
item_address,
|
|
267
|
+
item_kind,
|
|
268
|
+
text: decompiled.text,
|
|
269
|
+
});
|
|
270
|
+
return ok(createAnalysisExecution(result, this.#identity, {
|
|
271
|
+
rawResult: payload,
|
|
272
|
+
limitations: unit_path === undefined
|
|
273
|
+
? [
|
|
274
|
+
"The engine selected the project's first code unit implicitly; the effective unit identity is unknown.",
|
|
275
|
+
]
|
|
276
|
+
: [],
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
#requireSuccess(payload, operation) {
|
|
280
|
+
if (typeof payload !== "object" || payload === null)
|
|
281
|
+
throw new AnalysisProtocolError("JEB MCP returned a non-object envelope; no observation can be established");
|
|
282
|
+
const success = payload.success;
|
|
283
|
+
if (success === false)
|
|
284
|
+
throw new AnalysisUnsupportedTargetError(operation, this.#endpoint.toString(), refusalReason(payload, "The engine refused the request"));
|
|
285
|
+
if (success !== true)
|
|
286
|
+
throw new AnalysisProtocolError("JEB MCP omitted its success field; no observation can be established");
|
|
287
|
+
return payload;
|
|
288
|
+
}
|
|
289
|
+
#providerFailure(operation, cause) {
|
|
290
|
+
if (cause instanceof AnalysisError)
|
|
291
|
+
return cause;
|
|
292
|
+
if (cause instanceof z.ZodError)
|
|
293
|
+
return new AnalysisProtocolError("JEB omitted or malformed required observation fields", { cause });
|
|
294
|
+
return new AnalysisCapabilityUnavailableError("jeb", operation, cause instanceof Error ? cause.message : String(cause), {
|
|
295
|
+
cause: cause instanceof Error ? cause : undefined,
|
|
296
|
+
userMessage: `Start a JEB client serving MCP (default ${DEFAULT_JEB_MCP_ENDPOINT}) or set REA_JEB_MCP_URL to the running endpoint.`,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
package/dist/main/shutdown.js
CHANGED
|
@@ -3,24 +3,51 @@ import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
|
3
3
|
import { MCP_SHUTDOWN_FAILED } from "./messages.js";
|
|
4
4
|
export const createShutdown = (input) => {
|
|
5
5
|
const { handle, session, dependencies, serverLogger } = input;
|
|
6
|
-
let
|
|
6
|
+
let shutdownAttempt;
|
|
7
|
+
const cleanupOwners = [
|
|
8
|
+
{ close: () => handle.close(), closed: false },
|
|
9
|
+
...(input.closeAndroid === undefined
|
|
10
|
+
? []
|
|
11
|
+
: [{ close: input.closeAndroid, closed: false }]),
|
|
12
|
+
{
|
|
13
|
+
close: async () => {
|
|
14
|
+
const closed = await session.close({ retainProviderDocuments: true });
|
|
15
|
+
if (!closed.ok)
|
|
16
|
+
throw closed.error;
|
|
17
|
+
},
|
|
18
|
+
closed: false,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
let shutdownUnregistered = false;
|
|
7
22
|
let unregisterShutdown = () => undefined;
|
|
8
23
|
const shutdown = async () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]);
|
|
24
|
+
if (shutdownAttempt !== undefined)
|
|
25
|
+
return shutdownAttempt;
|
|
26
|
+
const pending = cleanupOwners.filter(({ closed }) => !closed);
|
|
27
|
+
const attempt = (async () => {
|
|
28
|
+
const results = await Promise.allSettled(pending.map(async (owner) => {
|
|
29
|
+
await owner.close();
|
|
30
|
+
owner.closed = true;
|
|
31
|
+
}));
|
|
32
|
+
const failures = [];
|
|
19
33
|
for (const result of results)
|
|
20
34
|
if (result.status === "rejected")
|
|
21
|
-
|
|
35
|
+
failures.push(result.reason);
|
|
36
|
+
if (failures.length === 1)
|
|
37
|
+
throw failures[0];
|
|
38
|
+
if (failures.length > 1)
|
|
39
|
+
throw new AggregateError(failures, "Multiple MCP cleanup operations failed");
|
|
40
|
+
if (!shutdownUnregistered) {
|
|
41
|
+
unregisterShutdown();
|
|
42
|
+
shutdownUnregistered = true;
|
|
43
|
+
}
|
|
22
44
|
})();
|
|
23
|
-
|
|
45
|
+
shutdownAttempt = attempt;
|
|
46
|
+
void attempt.catch(() => {
|
|
47
|
+
if (shutdownAttempt === attempt)
|
|
48
|
+
shutdownAttempt = undefined;
|
|
49
|
+
});
|
|
50
|
+
return attempt;
|
|
24
51
|
};
|
|
25
52
|
const requestShutdown = () => {
|
|
26
53
|
shutdown().catch((cause) => {
|
|
@@ -35,24 +62,41 @@ export const createShutdown = (input) => {
|
|
|
35
62
|
unregisterShutdown = dependencies.registerShutdown(requestShutdown);
|
|
36
63
|
return { shutdown, request: requestShutdown };
|
|
37
64
|
};
|
|
38
|
-
const describeShutdownFailure = (cause) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
const describeShutdownFailure = (cause) => describeShutdownFailureNode(cause, new WeakSet());
|
|
66
|
+
const describeShutdownFailureNode = (cause, active) => {
|
|
67
|
+
if (typeof cause === "object" && cause !== null) {
|
|
68
|
+
if (active.has(cause))
|
|
69
|
+
return { type: "cyclic_error" };
|
|
70
|
+
active.add(cause);
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
if (cause instanceof AnalysisError)
|
|
74
|
+
return { analysis_error: projectAnalysisError(cause) };
|
|
75
|
+
if (cause instanceof Error) {
|
|
76
|
+
const code = "code" in cause ? cause.code : undefined;
|
|
77
|
+
return {
|
|
78
|
+
name: cause.name,
|
|
79
|
+
message: cause.message,
|
|
80
|
+
...(typeof code === "string" ||
|
|
81
|
+
(typeof code === "number" && Number.isFinite(code))
|
|
82
|
+
? { code }
|
|
83
|
+
: {}),
|
|
84
|
+
...(cause instanceof AggregateError
|
|
85
|
+
? {
|
|
86
|
+
errors: cause.errors.map((error) => describeShutdownFailureNode(error, active)),
|
|
87
|
+
}
|
|
88
|
+
: {}),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (cause === null ||
|
|
92
|
+
typeof cause === "string" ||
|
|
93
|
+
typeof cause === "boolean" ||
|
|
94
|
+
(typeof cause === "number" && Number.isFinite(cause)))
|
|
95
|
+
return { type: cause === null ? "null" : typeof cause, value: cause };
|
|
96
|
+
return { type: typeof cause };
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (typeof cause === "object" && cause !== null)
|
|
100
|
+
active.delete(cause);
|
|
51
101
|
}
|
|
52
|
-
if (cause === null ||
|
|
53
|
-
typeof cause === "string" ||
|
|
54
|
-
typeof cause === "boolean" ||
|
|
55
|
-
(typeof cause === "number" && Number.isFinite(cause)))
|
|
56
|
-
return { type: cause === null ? "null" : typeof cause, value: cause };
|
|
57
|
-
return { type: typeof cause };
|
|
58
102
|
};
|
package/dist/main/transport.js
CHANGED
|
@@ -29,7 +29,7 @@ export const startMcpTransport = async (dependencies, session, serverContext) =>
|
|
|
29
29
|
// The SDK can discard a discovery probe and construct a replacement server.
|
|
30
30
|
const android = createAndroidAnalysisProvider(serverContext.environment);
|
|
31
31
|
androidProviders.push(android);
|
|
32
|
-
return (dependencies.createServer ?? createServer)(session, session, {
|
|
32
|
+
return (dependencies.createServer ?? createServer)({ kind: "session", session }, {
|
|
33
33
|
logger: serverContext.logger,
|
|
34
34
|
environment: serverContext.environment,
|
|
35
35
|
delivery: serverContext.delivery,
|