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
|
@@ -2,23 +2,23 @@ import * as t from "@babel/types";
|
|
|
2
2
|
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
3
3
|
import { clearSemanticPrimitiveBindingValues, evaluateSemanticBinding, evaluateSemanticExpression, } from "./javascriptSemanticValues.js";
|
|
4
4
|
import { semanticContainer, semanticSlotAtPath, } from "./javascriptSemanticSlots.js";
|
|
5
|
+
import { semanticClassCandidates, semanticClassPropertyReferences, semanticObjectPropertyReferences, } from "./javascriptSemanticObjectReferences.js";
|
|
5
6
|
import { semanticIterationSources } from "./javascriptSemanticIterationSources.js";
|
|
7
|
+
import { semanticCallableResultExpressions } from "./javascriptSemanticCallableResults.js";
|
|
8
|
+
import { createSemanticReturnedReferences } from "./javascriptSemanticReturnedReferences.js";
|
|
6
9
|
import { semanticMutationInitializers } from "./javascriptSemanticMutationInitializers.js";
|
|
7
|
-
import { semanticArrayIndex, semanticPropertyPathKeyMatches, } from "./javascriptSemanticPropertyPaths.js";
|
|
10
|
+
import { semanticArrayIndex, SemanticPropertyPathCoverage, semanticPropertyPathKeyMatches, } from "./javascriptSemanticPropertyPaths.js";
|
|
8
11
|
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
9
|
-
import {
|
|
10
|
-
import { semanticStaticPropertyKey, unwrapJavaScriptExpression, } from "./javascriptAstValues.js";
|
|
11
|
-
/** Preserve uncertainty from property writes and references exposed to calls. */
|
|
12
|
-
export
|
|
12
|
+
import { traverseJavaScriptAstSteps } from "./javascriptSemanticTraversal.js";
|
|
13
|
+
import { semanticStaticPropertyKey, semanticMemberWriteTargets, unwrapJavaScriptExpression, } from "./javascriptAstValues.js";
|
|
14
|
+
/** Preserve uncertainty from property writes and references exposed to calls, yielding during traversal and fixpoint iteration. */
|
|
15
|
+
export function* collectSemanticMemberMutationsSteps(program, state) {
|
|
13
16
|
const parents = state.parentsByNode;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (parent !== null)
|
|
17
|
-
parents.set(node, parent);
|
|
18
|
-
},
|
|
19
|
-
});
|
|
17
|
+
const normalizePath = observableMutationPaths(state);
|
|
18
|
+
const returnedReferences = createSemanticReturnedReferences(state);
|
|
20
19
|
const recordedEffects = new Set();
|
|
21
20
|
const selections = new Map();
|
|
21
|
+
const coveringPaths = new Map();
|
|
22
22
|
let arrayIterationUnknown = false;
|
|
23
23
|
const pendingReferences = [];
|
|
24
24
|
const iterableReferences = [];
|
|
@@ -55,8 +55,10 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
55
55
|
};
|
|
56
56
|
const markValue = (node, path, bindings, effect = "write", mutation, originAt = mutation) => {
|
|
57
57
|
const pending = [{ node, path, bindings, originAt }];
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
// Visit shallower alias traversals first so their exact prefixes suppress
|
|
59
|
+
// longer loop paths before those paths enumerate every assignment order.
|
|
60
|
+
for (let cursor = 0; cursor < pending.length; cursor++) {
|
|
61
|
+
const current = pending[cursor];
|
|
60
62
|
if (current === undefined)
|
|
61
63
|
break;
|
|
62
64
|
const expression = unwrapJavaScriptExpression(current.node).node;
|
|
@@ -72,18 +74,24 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
72
74
|
continue;
|
|
73
75
|
}
|
|
74
76
|
// An alias restored from a saved reference can revisit the same binding
|
|
75
|
-
// at an earlier capture
|
|
77
|
+
// at an earlier capture or a shorter getter-receiver path. Only a
|
|
78
|
+
// repeated capture and path closes a cycle.
|
|
76
79
|
const lifetime = JSON.stringify([
|
|
77
80
|
binding.bindingId,
|
|
78
81
|
current.originAt?.start,
|
|
79
82
|
current.originAt?.end,
|
|
83
|
+
current.path,
|
|
80
84
|
]);
|
|
81
85
|
if (current.bindings.has(lifetime))
|
|
82
86
|
continue;
|
|
83
87
|
// Union compatible copied-slot selections at each binding. Carrying every
|
|
84
88
|
// combination of exclusions through branch diamonds is exponential.
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
// Preserve paths that can change observed slots or Array prototype
|
|
90
|
+
// effects; canonicalize suffixes that cannot distinguish lattice facts.
|
|
91
|
+
let path = normalizePath(binding.bindingId, current.path, effect);
|
|
92
|
+
if (path === null)
|
|
93
|
+
continue;
|
|
94
|
+
const selectorIndex = path.findIndex((key) => key !== null && typeof key === "object");
|
|
87
95
|
const selector = path[selectorIndex];
|
|
88
96
|
if (selector !== null && typeof selector === "object") {
|
|
89
97
|
const selectionIdentity = JSON.stringify([
|
|
@@ -106,6 +114,26 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
106
114
|
selections.set(selectionIdentity, excludedKeys);
|
|
107
115
|
path = path.map((key, index) => index === selectorIndex ? { ...selector, excludedKeys } : key);
|
|
108
116
|
}
|
|
117
|
+
// Keep an antichain of exact paths. Widening distinct member keys would
|
|
118
|
+
// also invalidate unrelated siblings that never reach this effect.
|
|
119
|
+
const pathState = JSON.stringify([
|
|
120
|
+
binding.bindingId,
|
|
121
|
+
effect,
|
|
122
|
+
// Short writes stop at owned literal slots, whereas longer writes
|
|
123
|
+
// reach shared children. Only equal-depth writes cover one another.
|
|
124
|
+
effect === "write" ? path.length : null,
|
|
125
|
+
mutation?.start,
|
|
126
|
+
mutation?.end,
|
|
127
|
+
current.originAt?.start,
|
|
128
|
+
current.originAt?.end,
|
|
129
|
+
]);
|
|
130
|
+
let covering = coveringPaths.get(pathState);
|
|
131
|
+
if (covering === undefined) {
|
|
132
|
+
covering = new SemanticPropertyPathCoverage();
|
|
133
|
+
coveringPaths.set(pathState, covering);
|
|
134
|
+
}
|
|
135
|
+
if (!covering.retain(path))
|
|
136
|
+
continue;
|
|
109
137
|
const identity = JSON.stringify([
|
|
110
138
|
binding.bindingId,
|
|
111
139
|
effect,
|
|
@@ -117,7 +145,10 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
117
145
|
]);
|
|
118
146
|
if (recordedEffects.has(identity))
|
|
119
147
|
continue;
|
|
120
|
-
|
|
148
|
+
// A recorded write invalidates the binding to a non-primitive value, so
|
|
149
|
+
// only its first write can target a primitive. Re-evaluating it would
|
|
150
|
+
// replay every earlier write and make repeated writes superlinear.
|
|
151
|
+
const value = effect === "write" && binding.mutatedPaths.length === 0
|
|
121
152
|
? evaluateSemanticBinding(binding, state)
|
|
122
153
|
: undefined;
|
|
123
154
|
const primitiveWrite = value?.status === "literal" || value?.status === "union";
|
|
@@ -167,13 +198,9 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
167
198
|
});
|
|
168
199
|
}
|
|
169
200
|
else {
|
|
170
|
-
|
|
171
|
-
(
|
|
172
|
-
|
|
173
|
-
(current.path[0] === "constructor" &&
|
|
174
|
-
current.path[1] === "prototype")))
|
|
175
|
-
arrayIterationUnknown = true;
|
|
176
|
-
for (const value of referencedValues(expression, current.path, effect)) {
|
|
201
|
+
for (const value of effect === "escape"
|
|
202
|
+
? escapedReferenceLeaves(expression, current.path)
|
|
203
|
+
: expandedValues(expression, current.path, effect)) {
|
|
177
204
|
if (value.iterableFallbackPath !== undefined)
|
|
178
205
|
deferIterable({
|
|
179
206
|
node: value.node,
|
|
@@ -196,6 +223,71 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
196
223
|
}
|
|
197
224
|
};
|
|
198
225
|
const markEscaped = (node, mutation, path = []) => markValue(node, path, new Set(), "escape", mutation);
|
|
226
|
+
function expandedValues(expression, path, effect) {
|
|
227
|
+
if (t.isArrayExpression(expression) &&
|
|
228
|
+
((path[0] === "__proto__" && (effect === "escape" || path.length > 1)) ||
|
|
229
|
+
(path[0] === "constructor" && path[1] === "prototype")))
|
|
230
|
+
arrayIterationUnknown = true;
|
|
231
|
+
return referencedValues(expression, path, effect, state);
|
|
232
|
+
}
|
|
233
|
+
// Expanding a value below its references depends only on syntax, not on the
|
|
234
|
+
// escape site. Escaping an object reaches every method's results, so
|
|
235
|
+
// re-expanding it at each call through that object made N calls over N
|
|
236
|
+
// methods quadratic. Identifiers that resolve to the same binding and path
|
|
237
|
+
// are processed identically, so one stands for all of them.
|
|
238
|
+
const escapedLeaves = new WeakMap();
|
|
239
|
+
function escapedReferenceLeaves(root, rootPath) {
|
|
240
|
+
// Parser recovery can leave an argument hole, which expands to nothing.
|
|
241
|
+
if (!t.isNode(root))
|
|
242
|
+
return [];
|
|
243
|
+
const rootKey = JSON.stringify(rootPath);
|
|
244
|
+
const cached = escapedLeaves.get(root)?.get(rootKey);
|
|
245
|
+
if (cached !== undefined)
|
|
246
|
+
return cached;
|
|
247
|
+
const leaves = [];
|
|
248
|
+
const leafIdentities = new Set();
|
|
249
|
+
const expanded = new WeakMap();
|
|
250
|
+
const pending = [...expandedValues(root, rootPath, "escape")];
|
|
251
|
+
for (let cursor = 0; cursor < pending.length; cursor++) {
|
|
252
|
+
const value = pending[cursor];
|
|
253
|
+
if (value === undefined)
|
|
254
|
+
break;
|
|
255
|
+
const node = unwrapJavaScriptExpression(value.node).node;
|
|
256
|
+
if (!t.isNode(node))
|
|
257
|
+
continue;
|
|
258
|
+
const pathKey = JSON.stringify(value.path);
|
|
259
|
+
if (t.isIdentifier(node) && value.iterableFallbackPath === undefined) {
|
|
260
|
+
const binding = resolveSemanticBindingState(state, node, node.name);
|
|
261
|
+
const identity = JSON.stringify([
|
|
262
|
+
binding === undefined ? null : binding.bindingId,
|
|
263
|
+
binding === undefined ? node.name : null,
|
|
264
|
+
pathKey,
|
|
265
|
+
]);
|
|
266
|
+
if (leafIdentities.has(identity))
|
|
267
|
+
continue;
|
|
268
|
+
leafIdentities.add(identity);
|
|
269
|
+
leaves.push(value);
|
|
270
|
+
}
|
|
271
|
+
else if (value.iterableFallbackPath !== undefined ||
|
|
272
|
+
t.isIdentifier(node) ||
|
|
273
|
+
t.isMemberExpression(node) ||
|
|
274
|
+
t.isOptionalMemberExpression(node))
|
|
275
|
+
leaves.push(value);
|
|
276
|
+
else {
|
|
277
|
+
const paths = expanded.get(node) ?? new Set();
|
|
278
|
+
if (paths.has(pathKey))
|
|
279
|
+
continue;
|
|
280
|
+
paths.add(pathKey);
|
|
281
|
+
expanded.set(node, paths);
|
|
282
|
+
for (const reference of expandedValues(node, value.path, "escape"))
|
|
283
|
+
pending.push(reference);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const byPath = escapedLeaves.get(root) ?? new Map();
|
|
287
|
+
byPath.set(rootKey, leaves);
|
|
288
|
+
escapedLeaves.set(root, byPath);
|
|
289
|
+
return leaves;
|
|
290
|
+
}
|
|
199
291
|
const markReceiver = (callee, mutation) => {
|
|
200
292
|
const expression = unwrapJavaScriptExpression(callee).node;
|
|
201
293
|
if (t.isMemberExpression(expression) ||
|
|
@@ -203,23 +295,10 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
203
295
|
markEscaped(expression.object, mutation);
|
|
204
296
|
};
|
|
205
297
|
const markTarget = (node, mutation) => {
|
|
206
|
-
|
|
207
|
-
markValue(
|
|
208
|
-
else if (t.isRestElement(node))
|
|
209
|
-
markTarget(node.argument, mutation);
|
|
210
|
-
else if (t.isAssignmentPattern(node))
|
|
211
|
-
markTarget(node.left, mutation);
|
|
212
|
-
else if (t.isArrayPattern(node)) {
|
|
213
|
-
for (const element of node.elements)
|
|
214
|
-
if (element !== null)
|
|
215
|
-
markTarget(element, mutation);
|
|
216
|
-
}
|
|
217
|
-
else if (t.isObjectPattern(node)) {
|
|
218
|
-
for (const property of node.properties)
|
|
219
|
-
markTarget(t.isRestElement(property) ? property.argument : property.value, mutation);
|
|
220
|
-
}
|
|
298
|
+
for (const target of semanticMemberWriteTargets(node))
|
|
299
|
+
markValue(target.object, [semanticStaticPropertyKey(target.property, target.computed)], new Set(), "write", mutation);
|
|
221
300
|
};
|
|
222
|
-
|
|
301
|
+
yield* traverseJavaScriptAstSteps(program, {
|
|
223
302
|
enter: (node, parent) => {
|
|
224
303
|
for (const source of semanticIterationSources(node, parent))
|
|
225
304
|
deferIterable({
|
|
@@ -229,7 +308,7 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
229
308
|
bindings: new Set(),
|
|
230
309
|
effect: "escape",
|
|
231
310
|
originAt: source.mutation,
|
|
232
|
-
iterationOnly:
|
|
311
|
+
iterationOnly: source.kind === "iteration",
|
|
233
312
|
});
|
|
234
313
|
if (t.isAssignmentExpression(node))
|
|
235
314
|
markTarget(node.left, node);
|
|
@@ -242,6 +321,8 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
242
321
|
else if (t.isCallExpression(node) ||
|
|
243
322
|
t.isOptionalCallExpression(node) ||
|
|
244
323
|
t.isNewExpression(node)) {
|
|
324
|
+
for (const source of returnedReferences(node.callee))
|
|
325
|
+
markEscaped(source.node, node, source.projection);
|
|
245
326
|
for (const argument of node.arguments)
|
|
246
327
|
if (t.isSpreadElement(argument))
|
|
247
328
|
deferIterable({
|
|
@@ -273,10 +354,25 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
273
354
|
const effectsBefore = recordedEffects.size;
|
|
274
355
|
const iterablesBefore = iterableReferences.length;
|
|
275
356
|
const iterationBefore = arrayIterationUnknown;
|
|
276
|
-
for (const reference of pendingReferences.splice(0)) {
|
|
357
|
+
for (const [index, reference] of pendingReferences.splice(0).entries()) {
|
|
358
|
+
if (index % 64 === 0)
|
|
359
|
+
yield;
|
|
277
360
|
const { initializer } = reference;
|
|
278
361
|
if (referenceSourcesInactive(initializer, state))
|
|
279
362
|
pendingReferences.push(reference);
|
|
363
|
+
else if (t.isForOfStatement(initializer.node))
|
|
364
|
+
deferIterable({
|
|
365
|
+
node: initializer.node.right,
|
|
366
|
+
projection: [],
|
|
367
|
+
path: [null, ...reference.path],
|
|
368
|
+
fallbackPath: [],
|
|
369
|
+
bindings: reference.bindings,
|
|
370
|
+
effect: reference.effect,
|
|
371
|
+
originAt: initializer.node,
|
|
372
|
+
...(reference.mutation === undefined
|
|
373
|
+
? {}
|
|
374
|
+
: { mutation: reference.mutation }),
|
|
375
|
+
});
|
|
280
376
|
else if (initializer.copyKind === "array-rest" &&
|
|
281
377
|
initializer.copyProjectionOffset !== undefined) {
|
|
282
378
|
const offset = initializer.copyProjectionOffset;
|
|
@@ -297,7 +393,9 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
297
393
|
else
|
|
298
394
|
markValue(initializer.node, reference.path, reference.bindings, reference.effect, reference.mutation, reference.originAt);
|
|
299
395
|
}
|
|
300
|
-
for (const reference of [...iterableReferences]) {
|
|
396
|
+
for (const [index, reference] of [...iterableReferences].entries()) {
|
|
397
|
+
if (index % 64 === 0)
|
|
398
|
+
yield;
|
|
301
399
|
if (referenceSourcesInactive(reference, state))
|
|
302
400
|
continue;
|
|
303
401
|
if (reference.iterationOnly) {
|
|
@@ -326,7 +424,7 @@ export const collectSemanticMemberMutations = (program, state) => {
|
|
|
326
424
|
// Gathering effects can evaluate a primitive projection before its object
|
|
327
425
|
// escapes. Final values must use the completed mutation state.
|
|
328
426
|
clearSemanticPrimitiveBindingValues(state);
|
|
329
|
-
}
|
|
427
|
+
}
|
|
330
428
|
const referenceSourcesInactive = (reference, state) => reference.requiredSources?.some((source) => selectedReferenceSlot(source, state, source.node)?.presence === "absent") === true ||
|
|
331
429
|
reference.fallbackSources?.some((source) => {
|
|
332
430
|
// Selection precedes effects through the chosen reference. A later escape
|
|
@@ -381,15 +479,35 @@ const expandedIterationReferences = (reference, state) => {
|
|
|
381
479
|
};
|
|
382
480
|
});
|
|
383
481
|
};
|
|
384
|
-
const referencedValues = (node, path, effect) => {
|
|
482
|
+
const referencedValues = (node, path, effect, state) => {
|
|
483
|
+
if (effect === "escape" && t.isFunction(node))
|
|
484
|
+
return semanticCallableResultExpressions(node).flatMap(({ node, delegated }) => node === null ? [] : [{ node, path: delegated ? [null] : [] }]);
|
|
385
485
|
// An initializer owns its slots; only deeper writes can affect shared children.
|
|
386
486
|
if (t.isObjectExpression(node) || t.isArrayExpression(node)) {
|
|
387
487
|
if (effect === "write" && path.length < 2)
|
|
388
488
|
return [];
|
|
389
489
|
return t.isObjectExpression(node)
|
|
390
|
-
?
|
|
490
|
+
? semanticObjectPropertyReferences(node, path, state)
|
|
391
491
|
: arrayReferencedValues(node, path);
|
|
392
492
|
}
|
|
493
|
+
if (t.isClass(node)) {
|
|
494
|
+
const [key, ...remaining] = path;
|
|
495
|
+
if (key === undefined)
|
|
496
|
+
return [];
|
|
497
|
+
// Replacing or deleting the getter's property does not use the value it
|
|
498
|
+
// would return. Only a deeper path can mutate the returned object.
|
|
499
|
+
if (effect === "write" && remaining.length === 0)
|
|
500
|
+
return [];
|
|
501
|
+
return semanticClassPropertyReferences({ owner: node, kind: "static" }, [key, ...remaining], state);
|
|
502
|
+
}
|
|
503
|
+
if (t.isNewExpression(node)) {
|
|
504
|
+
const [key, ...remaining] = path;
|
|
505
|
+
if (key === undefined)
|
|
506
|
+
return [];
|
|
507
|
+
if (effect === "write" && remaining.length === 0)
|
|
508
|
+
return [];
|
|
509
|
+
return semanticClassCandidates(node.callee, state).flatMap((klass) => semanticClassPropertyReferences({ owner: klass, kind: "instance" }, [key, ...remaining], state));
|
|
510
|
+
}
|
|
393
511
|
if (t.isAssignmentExpression(node))
|
|
394
512
|
return node.operator === "||=" || node.operator === "??="
|
|
395
513
|
? [
|
|
@@ -415,50 +533,186 @@ const referencedValues = (node, path, effect) => {
|
|
|
415
533
|
];
|
|
416
534
|
return [];
|
|
417
535
|
};
|
|
418
|
-
const
|
|
419
|
-
const
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
536
|
+
const observableMutationPaths = (state) => {
|
|
537
|
+
const bindingNodes = new Map();
|
|
538
|
+
const expressions = new WeakMap();
|
|
539
|
+
const pendingExpressions = [];
|
|
540
|
+
const pending = [];
|
|
541
|
+
const queued = new Set();
|
|
542
|
+
const schedule = (node) => {
|
|
543
|
+
if (queued.has(node))
|
|
544
|
+
return;
|
|
545
|
+
queued.add(node);
|
|
546
|
+
pending.push(node);
|
|
547
|
+
};
|
|
548
|
+
const create = (read) =>
|
|
549
|
+
// Most bindings have no object origin or property projection. Materialize
|
|
550
|
+
// each collection only when it contains a fact or relationship.
|
|
551
|
+
read === undefined ? {} : { read };
|
|
552
|
+
const link = (source, target) => {
|
|
553
|
+
if (target.sources?.has(source) === true)
|
|
554
|
+
return;
|
|
555
|
+
(target.sources ??= new Set()).add(source);
|
|
556
|
+
(source.dependents ??= new Set()).add(target);
|
|
557
|
+
schedule(target);
|
|
558
|
+
};
|
|
559
|
+
const expressionNode = (node) => {
|
|
560
|
+
const expression = unwrapJavaScriptExpression(node).node;
|
|
561
|
+
const existing = expressions.get(expression);
|
|
562
|
+
if (existing !== undefined)
|
|
563
|
+
return existing;
|
|
564
|
+
const observer = create();
|
|
565
|
+
expressions.set(expression, observer);
|
|
566
|
+
pendingExpressions.push({ expression, observer });
|
|
567
|
+
return observer;
|
|
568
|
+
};
|
|
569
|
+
const project = (source, path) => {
|
|
570
|
+
let observer = source;
|
|
571
|
+
for (const key of path) {
|
|
572
|
+
const identity = JSON.stringify(key === null || typeof key === "object" ? key : String(key));
|
|
573
|
+
let selected = observer.projections?.get(identity);
|
|
574
|
+
if (selected === undefined) {
|
|
575
|
+
selected = create({ source: observer, key });
|
|
576
|
+
(observer.projections ??= new Map()).set(identity, selected);
|
|
577
|
+
(observer.dependents ??= new Set()).add(selected);
|
|
578
|
+
schedule(selected);
|
|
579
|
+
}
|
|
580
|
+
observer = selected;
|
|
445
581
|
}
|
|
446
|
-
|
|
447
|
-
|
|
582
|
+
return observer;
|
|
583
|
+
};
|
|
584
|
+
for (const binding of state.bindingsById.values())
|
|
585
|
+
bindingNodes.set(binding.bindingId, create());
|
|
586
|
+
for (const binding of state.bindingsById.values()) {
|
|
587
|
+
const observer = bindingNodes.get(binding.bindingId);
|
|
588
|
+
if (observer === undefined)
|
|
448
589
|
continue;
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
590
|
+
for (const initializer of binding.initializers) {
|
|
591
|
+
const expression = unwrapJavaScriptExpression(initializer.node).node;
|
|
592
|
+
// Preserve member paths through class values and local instances so
|
|
593
|
+
// getter-result aliases can be resolved at the accessor boundary.
|
|
594
|
+
if (t.isClass(expression) || t.isNewExpression(expression))
|
|
595
|
+
(observer.origins ??= new Set()).add("opaque");
|
|
596
|
+
link(project(expressionNode(initializer.node), initializer.projection), observer);
|
|
597
|
+
}
|
|
598
|
+
// Preserve exact paths where copies, defaults or iteration need their
|
|
599
|
+
// reference-specific projections; an opaque origin prevents pruning.
|
|
600
|
+
if (binding.referenceInitializers.length > 0)
|
|
601
|
+
(observer.origins ??= new Set()).add("opaque");
|
|
602
|
+
for (const initializer of binding.referenceInitializers) {
|
|
603
|
+
for (const source of [
|
|
604
|
+
initializer,
|
|
605
|
+
...(initializer.requiredSources ?? []),
|
|
606
|
+
...(initializer.fallbackSources ?? []),
|
|
607
|
+
])
|
|
608
|
+
link(expressionNode(source.node), observer);
|
|
609
|
+
}
|
|
460
610
|
}
|
|
461
|
-
|
|
611
|
+
const settle = () => {
|
|
612
|
+
while (pendingExpressions.length > 0 || pending.length > 0) {
|
|
613
|
+
while (pendingExpressions.length > 0) {
|
|
614
|
+
const selected = pendingExpressions.pop();
|
|
615
|
+
if (selected === undefined)
|
|
616
|
+
break;
|
|
617
|
+
const { expression, observer } = selected;
|
|
618
|
+
if (t.isObjectExpression(expression) || t.isArrayExpression(expression))
|
|
619
|
+
(observer.origins ??= new Set()).add(expression);
|
|
620
|
+
else if (t.isIdentifier(expression)) {
|
|
621
|
+
const binding = resolveSemanticBindingState(state, expression, expression.name);
|
|
622
|
+
if (binding !== undefined) {
|
|
623
|
+
const origin = bindingNodes.get(binding.bindingId);
|
|
624
|
+
if (origin !== undefined)
|
|
625
|
+
link(origin, observer);
|
|
626
|
+
}
|
|
627
|
+
else if (expression.name === "Array")
|
|
628
|
+
(observer.origins ??= new Set()).add("array");
|
|
629
|
+
else if (["globalThis", "global", "window", "self"].includes(expression.name))
|
|
630
|
+
(observer.origins ??= new Set()).add("ambient");
|
|
631
|
+
}
|
|
632
|
+
else if (t.isMemberExpression(expression) ||
|
|
633
|
+
t.isOptionalMemberExpression(expression))
|
|
634
|
+
link(project(expressionNode(expression.object), [
|
|
635
|
+
semanticStaticPropertyKey(expression.property, expression.computed),
|
|
636
|
+
]), observer);
|
|
637
|
+
else
|
|
638
|
+
for (const reference of referencedValues(expression, [], "escape", state))
|
|
639
|
+
link(project(expressionNode(reference.node), reference.path), observer);
|
|
640
|
+
schedule(observer);
|
|
641
|
+
}
|
|
642
|
+
const observer = pending.pop();
|
|
643
|
+
if (observer === undefined)
|
|
644
|
+
continue;
|
|
645
|
+
queued.delete(observer);
|
|
646
|
+
let changed = false;
|
|
647
|
+
const add = (origin) => {
|
|
648
|
+
if (observer.origins?.has(origin) === true)
|
|
649
|
+
return;
|
|
650
|
+
(observer.origins ??= new Set()).add(origin);
|
|
651
|
+
changed = true;
|
|
652
|
+
};
|
|
653
|
+
for (const source of observer.sources ?? [])
|
|
654
|
+
for (const origin of source.origins ?? [])
|
|
655
|
+
add(origin);
|
|
656
|
+
if (observer.read !== undefined) {
|
|
657
|
+
const { source, key } = observer.read;
|
|
658
|
+
if (key === null || typeof key === "object") {
|
|
659
|
+
// Dynamic keys and copied-slot masks retain their original paths.
|
|
660
|
+
// Enumerating their exclusion combinations would recreate the growth
|
|
661
|
+
// that the mutation collector's selection union already prevents.
|
|
662
|
+
if ((source.origins?.size ?? 0) > 0)
|
|
663
|
+
add("opaque");
|
|
664
|
+
}
|
|
665
|
+
else
|
|
666
|
+
for (const origin of source.origins ?? []) {
|
|
667
|
+
if (typeof origin === "string") {
|
|
668
|
+
if (origin === "array-prototype" || origin === "opaque")
|
|
669
|
+
add(origin);
|
|
670
|
+
else if (origin === "ambient" &&
|
|
671
|
+
semanticPropertyPathKeyMatches(key, "Array"))
|
|
672
|
+
add("array");
|
|
673
|
+
else if (origin === "array" &&
|
|
674
|
+
semanticPropertyPathKeyMatches(key, "prototype"))
|
|
675
|
+
add("array-prototype");
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
for (const reference of referencedValues(origin, [key], "escape", state)) {
|
|
679
|
+
link(project(expressionNode(reference.node), reference.path), observer);
|
|
680
|
+
if (reference.iterableFallbackPath !== undefined)
|
|
681
|
+
link(project(expressionNode(reference.node), reference.iterableFallbackPath), observer);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (changed)
|
|
687
|
+
for (const dependent of observer.dependents ?? [])
|
|
688
|
+
schedule(dependent);
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
settle();
|
|
692
|
+
return (bindingId, path, effect) => {
|
|
693
|
+
let observer = bindingNodes.get(bindingId);
|
|
694
|
+
if (observer === undefined)
|
|
695
|
+
return path;
|
|
696
|
+
if (path.some((key) => key !== null && typeof key === "object"))
|
|
697
|
+
return path;
|
|
698
|
+
if (effect === "escape") {
|
|
699
|
+
observer = project(observer, path);
|
|
700
|
+
settle();
|
|
701
|
+
return (observer.origins?.size ?? 0) === 0 ? null : path;
|
|
702
|
+
}
|
|
703
|
+
if ((observer.origins?.size ?? 0) === 0)
|
|
704
|
+
return path.length === 0 ? path : [null];
|
|
705
|
+
for (let offset = 0; offset < path.length; offset++) {
|
|
706
|
+
const key = path[offset];
|
|
707
|
+
if (key === undefined)
|
|
708
|
+
break;
|
|
709
|
+
observer = project(observer, [key]);
|
|
710
|
+
settle();
|
|
711
|
+
if ((observer.origins?.size ?? 0) === 0 && offset + 1 < path.length)
|
|
712
|
+
return [...path.slice(0, offset + 1), null];
|
|
713
|
+
}
|
|
714
|
+
return path;
|
|
715
|
+
};
|
|
462
716
|
};
|
|
463
717
|
const arrayReferencedValues = (node, path) => {
|
|
464
718
|
const [key, ...remaining] = path;
|