rea-agents 6.4.0 → 6.7.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/DISCLAIMER.md +136 -0
- package/README.md +76 -16
- package/THIRD_PARTY_NOTICES.md +135 -0
- package/bridge/android/ReaJadxBridge.java +281 -25
- package/bridge/cutter/rea_bridge.py +825 -0
- package/bridge/ghidra/ReaGhidraAnalysisOptions.java +38 -0
- package/bridge/ghidra/ReaGhidraBridge.java +1232 -142
- package/bridge/ghidra/ReaGhidraBundleActivator.java +14 -0
- package/bridge/ghidra/ReaGhidraMipsSoftFloat.java +176 -0
- package/bridge/ghidra/ReaGhidraPrepareRaw.java +49 -0
- package/bridge/hopper_bridge.py +111 -69
- package/bridge/mitmproxy/capture.py +189 -13
- package/bridge/native/rea_lldb_tracer.py +88 -10
- package/bridge/process/ProcessRunTokenReader.swift +76 -34
- package/bridge/pwndbg/core_context.py +15 -2
- package/bridge/pwntools/layout_impl.py +5 -0
- package/bridge/pwntools/recorded_crash_impl.py +31 -10
- package/dist/adb/AdbCommand.js +148 -0
- package/dist/adb/AdbConfiguration.js +41 -7
- package/dist/adb/AdbDeviceOutput.js +59 -37
- package/dist/adb/AdbDirectoryListing.js +80 -0
- package/dist/adb/AdbHostFileName.js +34 -0
- package/dist/adb/AdbInputSnapshot.js +126 -0
- package/dist/adb/AdbProvider.js +1106 -346
- package/dist/adb/AdbShellOutput.js +146 -77
- package/dist/android/AndroidTargetSnapshot.js +7 -7
- package/dist/android/JadxAnalysis.js +53 -33
- package/dist/android/JadxConfiguration.js +283 -145
- package/dist/android/JadxDoctor.js +123 -0
- package/dist/android/JadxFailure.js +154 -0
- package/dist/android/JadxInterruption.js +13 -0
- package/dist/android/JadxJavaProbe.js +246 -0
- package/dist/android/JadxMcpTransport.js +53 -18
- package/dist/android/JadxProtocol.js +43 -2
- package/dist/android/JadxProvider.js +183 -102
- package/dist/android/JadxRelease.js +17 -2
- package/dist/android/JadxSession.js +35 -14
- package/dist/android/JadxWorkspaceRoot.js +157 -0
- package/dist/apktool/ApktoolCommandCleanup.js +134 -0
- package/dist/apktool/ApktoolCommandOutput.js +22 -0
- package/dist/apktool/ApktoolConfiguration.js +306 -45
- package/dist/apktool/ApktoolDecodeOutput.js +131 -42
- package/dist/apktool/ApktoolDecodedInventory.js +52 -0
- package/dist/apktool/ApktoolProvider.js +296 -340
- package/dist/apktool/ApktoolStringTables.js +178 -0
- package/dist/apktool/ApktoolWorkspace.js +162 -0
- package/dist/application/AnalysisContextQueries.js +5 -8
- package/dist/application/AnalysisDocument.js +19 -4
- package/dist/application/AnalysisProvider.js +36 -18
- package/dist/application/AppBundleExecutable.js +16 -9
- package/dist/application/BinaryTargetResolver.js +204 -40
- package/dist/application/BrowserEvidence.js +1 -1
- package/dist/application/BrowserObservationService.js +54 -9
- package/dist/application/BrowserScenarioCaptureService.js +26 -7
- package/dist/application/CallPathTracing.js +52 -13
- package/dist/application/CapabilityInventory.js +182 -36
- package/dist/application/ClaudeDesktopConfigLocation.js +152 -0
- package/dist/application/ClientConfigurationCleanup.js +73 -0
- package/dist/application/ClientConfigurationDocument.js +270 -151
- package/dist/application/ClientConfigurationFiles.js +51 -14
- package/dist/application/ClientConfigurationPublication.js +167 -0
- package/dist/application/ClientRegistrationEnvironment.js +40 -4
- package/dist/application/ClientRegistrationIdentity.js +112 -32
- package/dist/application/ClientRegistrationStatus.js +280 -84
- package/dist/application/DirectAnalysis.js +98 -30
- package/dist/application/DirectAnalysisCleanup.js +5 -1
- package/dist/application/DirectAnalysisStatus.js +13 -1
- package/dist/application/Doctor.js +192 -37
- package/dist/application/DoctorDiagnostics.js +59 -16
- package/dist/application/DoctorProviderIds.js +8 -0
- package/dist/application/DoctorScope.js +11 -2
- package/dist/application/DshCordisPatch.js +355 -0
- package/dist/application/DshCordisYaml.js +155 -0
- package/dist/application/EnhancedLiteralTracing.js +30 -16
- package/dist/application/EnhancedToolTypes.js +0 -1
- package/dist/application/EnhancedTools.js +154 -56
- package/dist/application/EvidenceBundleCommands.js +30 -7
- package/dist/application/EvidenceBundleFiles.js +29 -7
- package/dist/application/FunctionAnalysisEvidence.js +3 -0
- package/dist/application/GeminiClientSettings.js +25 -13
- package/dist/application/HermesClientHome.js +20 -0
- package/dist/application/HermesConfigurationYaml.js +312 -0
- package/dist/application/HopperDownload.js +11 -3
- package/dist/application/HopperReleaseFeed.js +71 -0
- package/dist/application/InventoryProjectionEvidence.js +0 -1
- package/dist/application/InvestigationProviders.js +14 -3
- package/dist/application/JsonFiles.js +110 -20
- package/dist/application/JsonInputFile.js +220 -62
- package/dist/application/LinuxHopper.js +218 -115
- package/dist/application/LinuxHopperPublisher.js +656 -0
- package/dist/application/MacHopper.js +203 -83
- package/dist/application/MacHopperPaths.js +40 -0
- package/dist/application/{MipsElfAbiFlags.js → MipsElfMetadata.js} +71 -10
- package/dist/application/MipsElfSharedLoad.js +164 -0
- package/dist/application/MipsGnuAttributes.js +90 -0
- package/dist/application/MsixPackageStorage.js +140 -0
- package/dist/application/ProgressReporter.js +1 -1
- package/dist/application/ProviderOperationExecution.js +15 -14
- package/dist/application/ReconstructionCoverageService.js +0 -1
- package/dist/application/ReconstructionObligationCandidates.js +20 -4
- package/dist/application/ReconstructionObligationLedgerDiagnostics.js +2 -2
- package/dist/application/ReconstructionObligationLedgerEvaluation.js +19 -33
- package/dist/application/ReconstructionObligationLedgerProjection.js +3 -72
- package/dist/application/ReconstructionObligationLedgerService.js +6 -2
- package/dist/application/ReconstructionObligationOriginalCases.js +10 -1
- package/dist/application/ReferenceSourceImport.js +24 -8
- package/dist/application/ReferenceSourceImportEntries.js +180 -37
- package/dist/application/ReferenceSourceImportPolicy.js +5 -3
- package/dist/application/ReferenceSourceImportTypes.js +0 -1
- package/dist/application/ReferenceSourceVcsAdapter.js +36 -17
- package/dist/application/RegularFileRead.js +117 -70
- package/dist/application/Setup.js +59 -21
- package/dist/application/SetupClientConfiguration.js +301 -66
- package/dist/application/SetupClients.js +25 -10
- package/dist/application/SetupHost.js +149 -51
- package/dist/application/SetupInstallFailure.js +58 -3
- package/dist/application/SetupPlan.js +94 -55
- package/dist/application/SetupRecoveryBackup.js +93 -0
- package/dist/application/SetupRegistrationEnvironment.js +14 -1
- package/dist/application/SetupSkill.js +303 -76
- package/dist/application/SourceLimitations.js +35 -0
- package/dist/application/SupportedClients.js +166 -32
- package/dist/application/TypeScriptEmittedSourceCandidates.js +26 -0
- package/dist/application/Uninstall.js +356 -110
- package/dist/application/UninstallFailure.js +14 -0
- package/dist/application/Update.js +54 -25
- package/dist/application/UpdateCommandProgress.js +66 -0
- package/dist/application/UpdateFailure.js +17 -0
- package/dist/application/UpdateMaintenance.js +18 -31
- package/dist/application/UpdateRuntime.js +198 -54
- package/dist/application/WebModuleTraceService.js +42 -22
- package/dist/application/WebNetworkCaptureService.js +24 -12
- package/dist/application/WebRuntimeService.js +41 -8
- package/dist/application/WebScriptExportService.js +6 -4
- package/dist/application/WebSourceLocationService.js +23 -8
- package/dist/application/WindowsCapabilities.js +18 -15
- package/dist/application/WorkflowEvidence.js +31 -1
- package/dist/application/analysisView/AnalysisViewService.js +46 -11
- package/dist/application/android/AndroidAnalysisService.js +5 -4
- package/dist/application/android/AndroidPackageInspection.js +25 -0
- package/dist/application/android/AndroidSearchEvidenceSummary.js +98 -0
- package/dist/application/artifacts/ArtifactComparisonEvidence.js +32 -0
- package/dist/application/binary/AnalysisProviderEvaluation.js +14 -11
- package/dist/application/binary/AnalysisProviderRegistry.js +365 -60
- package/dist/application/binary/AnalysisSnapshotCache.js +41 -20
- package/dist/application/binary/AnalysisSnapshotFiles.js +75 -9
- package/dist/application/binary/BinarySession.js +308 -117
- package/dist/application/binary/BinarySessionExecution.js +5 -4
- package/dist/application/binary/BinarySessionOpen.js +13 -6
- package/dist/application/binary/BinarySessionRecords.js +36 -7
- package/dist/application/binary/BinarySessionStatus.js +96 -27
- package/dist/application/binary/BinaryTargetSummary.js +9 -0
- package/dist/application/binary/CompositeProvider.js +116 -28
- package/dist/application/binary/LazyAnalysisProvider.js +6 -66
- package/dist/application/binary/SessionProviderRouter.js +16 -4
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +14 -5
- package/dist/application/binaryDiagnostics/PeResourcesService.js +25 -5
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +17 -7
- package/dist/application/captures/PacketCaptureService.js +84 -0
- package/dist/application/closeOwnedWebResources.js +37 -0
- package/dist/application/electron/ElectronFusePort.js +1 -0
- package/dist/application/electron/ElectronFuseService.js +45 -0
- package/dist/application/evm/EvmInterfaceEvidence.js +11 -0
- package/dist/application/evm/EvmInterfaceService.js +5 -15
- package/dist/application/firmware/FirmwareAnalysisService.js +4 -3
- package/dist/application/flutter/DartAotInspection.js +26 -0
- package/dist/application/flutter/FlutterBuildAnalysisPort.js +1 -0
- package/dist/application/flutter/FlutterBuildAnalysisService.js +13 -0
- package/dist/application/frida/FridaInstrumentationPort.js +8 -0
- package/dist/application/frida/FridaInstrumentationService.js +310 -0
- package/dist/application/frida/fridaInputErrors.js +17 -0
- package/dist/application/go/GoBinaryPort.js +1 -0
- package/dist/application/go/GoBinaryService.js +79 -0
- package/dist/application/harmony/HarmonyApplicationService.js +17 -0
- package/dist/application/investigation/EvidenceLedger.js +43 -18
- package/dist/application/investigation/InvestigationRecords.js +12 -21
- package/dist/application/investigation/UnknownEvidence.js +22 -18
- package/dist/application/javascript/ElectronActiveObservationService.js +55 -25
- package/dist/application/javascript/ElectronBoundaryAnalysis.js +17 -3
- package/dist/application/javascript/ElectronBoundaryGraph.js +2 -0
- package/dist/application/javascript/ElectronBoundaryGraphCallPaths.js +144 -0
- package/dist/application/javascript/ElectronBoundaryGraphIpc.js +26 -7
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +1 -1
- package/dist/application/javascript/ElectronBoundaryGraphWindows.js +61 -11
- package/dist/application/javascript/ElectronEvidence.js +1 -2
- package/dist/application/javascript/ElectronObservationService.js +41 -8
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +21 -0
- package/dist/application/javascript/JavaScriptApplicationService.js +29 -14
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +0 -1
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +119 -49
- package/dist/application/javascript/JavaScriptArtifactAnalysisTypes.js +30 -1
- package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +51 -21
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +31 -7
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +28 -6
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +25 -14
- package/dist/application/javascript/JavaScriptArtifactGraphEvidence.js +3 -3
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +186 -50
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +173 -14
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +959 -188
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +57 -32
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +2 -0
- package/dist/application/javascript/JavaScriptModuleRelationships.js +34 -12
- package/dist/application/javascript/JavaScriptRecoveryService.js +29 -9
- package/dist/application/javascript/JavaScriptRuntimeObservationEvidence.js +1 -2
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +33 -9
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +0 -1
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +4 -5
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +138 -43
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +13 -4
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +23 -3
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +18 -5
- package/dist/application/javascript/JavaScriptSemanticGraphElectronProjection.js +67 -0
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +4 -6
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +2 -3
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +2 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +5 -8
- package/dist/application/javascript/JavaScriptSemanticTraceService.js +0 -1
- package/dist/application/managed/ManagedApplicationGraphService.js +0 -1
- package/dist/application/managed/ManagedMemberComparisonService.js +72 -54
- package/dist/application/managed/ManagedNativeVerificationService.js +0 -1
- package/dist/application/managed/ManagedReconstructionService.js +0 -1
- package/dist/application/native/NativeCallRoutes.js +78 -41
- package/dist/application/native/NativeDispatchMetadataInspection.js +6 -2
- package/dist/application/native/NativeUiActionTrace.js +43 -22
- package/dist/application/native/NativeValueTrace.js +65 -23
- package/dist/application/pcap/PcapAnalysisPort.js +1 -0
- package/dist/application/pcap/PcapAnalysisService.js +24 -0
- package/dist/application/process/ProcessCli.js +33 -13
- package/dist/application/reverse/ReverseEngineeringCommandPort.js +1 -0
- package/dist/application/reverse/ReverseEngineeringService.js +688 -0
- package/dist/application/rust/RustBinaryPort.js +1 -0
- package/dist/application/rust/RustBinaryService.js +82 -0
- package/dist/application/signals/SignalRecordingService.js +84 -0
- package/dist/application/sqlite/SqliteDatabaseCapability.js +30 -0
- package/dist/application/sqlite/SqliteDatabasePort.js +1 -0
- package/dist/application/sqlite/SqliteDatabaseService.js +76 -0
- package/dist/application/wasm/WasmArtifactPort.js +1 -0
- package/dist/application/wasm/WasmArtifactService.js +76 -0
- package/dist/application/wasm/WasmInterfaceComparisonService.js +188 -0
- package/dist/artifacts/AnalysisCleanupLease.js +119 -0
- package/dist/artifacts/ArtifactFileOperation.js +150 -0
- package/dist/artifacts/ArtifactHash.js +15 -3
- package/dist/artifacts/ArtifactPaths.js +4 -7
- package/dist/artifacts/ArtifactProvider.js +24 -9
- package/dist/artifacts/ArtifactReader.js +63 -5
- package/dist/artifacts/ArtifactResourceScope.js +92 -9
- package/dist/artifacts/AsarArtifactReader.js +186 -120
- package/dist/artifacts/AsarEntryStream.js +49 -17
- package/dist/artifacts/AsarListing.js +78 -0
- package/dist/artifacts/DirectoryArtifactReader.js +119 -28
- package/dist/artifacts/MachOSliceArtifactReader.js +153 -23
- package/dist/artifacts/NativeDmgArtifactReader.js +264 -62
- package/dist/artifacts/OrderedReads.js +57 -0
- package/dist/artifacts/SafeOutputTree.js +24 -7
- package/dist/artifacts/SafeOutputTreeCreationFailure.js +1 -0
- package/dist/artifacts/SafeOutputTreeReadback.js +10 -16
- package/dist/artifacts/ZipArtifactReader.js +150 -25
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +79 -68
- package/dist/artifacts/apple/DylibFileAccess.js +106 -0
- package/dist/artifacts/apple/DylibResolutionReader.js +72 -157
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +108 -29
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +81 -28
- package/dist/artifacts/apple/KeyedArchiveReader.js +23 -13
- package/dist/artifacts/apple/MachoLoadCommandReader.js +77 -61
- package/dist/artifacts/apple/NibArchive.js +11 -4
- package/dist/artifacts/apple/PlistNumberLiterals.js +106 -118
- package/dist/artifacts/extraction/ArtifactExtraction.js +21 -19
- package/dist/artifacts/hostExecutableMarking.js +16 -0
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +139 -41
- package/dist/artifacts/inventory/classify.js +36 -17
- package/dist/artifacts/inventory/hashStableRootArtifact.js +14 -7
- package/dist/artifacts/inventory/reader.js +36 -21
- package/dist/artifacts/inventory/scanCanonical.js +27 -21
- package/dist/artifacts/inventory/scanReader.js +36 -10
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +166 -8
- package/dist/artifacts/readArtifactFileChunks.js +9 -0
- package/dist/artifacts/readStableArtifact.js +13 -11
- package/dist/browser/BrowserProcessStartup.js +20 -9
- package/dist/browser/BrowserScenarioPartialObservation.js +74 -92
- package/dist/browser/BrowserScenarioSecrets.js +176 -46
- package/dist/browser/CdpBrowserProvider.js +124 -102
- package/dist/browser/CdpCaptureDocuments.js +232 -102
- package/dist/browser/CdpCaptureDomSvg.js +80 -76
- package/dist/browser/CdpCaptureEventBodyShapes.js +9 -5
- package/dist/browser/CdpCaptureEventHandlers.js +23 -12
- package/dist/browser/CdpCaptureEvents.js +49 -10
- package/dist/browser/CdpCaptureStorage.js +22 -5
- package/dist/browser/CdpCaptureStorageFingerprints.js +54 -11
- package/dist/browser/CdpCaptureValues.js +12 -1
- package/dist/browser/CdpConnection.js +135 -30
- package/dist/browser/CdpElectronInspection.js +74 -64
- package/dist/browser/CdpElectronProvider.js +63 -6
- package/dist/browser/CdpElectronScriptEvents.js +4 -1
- package/dist/browser/CdpElectronScripts.js +4 -6
- package/dist/browser/CdpElectronWorkers.js +20 -4
- package/dist/browser/CdpEndpoint.js +143 -17
- package/dist/browser/CdpObservationSession.js +24 -8
- package/dist/browser/CdpPageCapture.js +68 -17
- package/dist/browser/CdpPageCaptureScripts.js +18 -13
- package/dist/browser/CdpPageCaptureWorkers.js +46 -11
- package/dist/browser/CdpSafeMetadata.js +32 -24
- package/dist/browser/CdpScreenshot.js +5 -14
- package/dist/browser/CdpSnapshotNodes.js +103 -0
- package/dist/browser/CdpSnapshotStrings.js +15 -0
- package/dist/browser/CdpTargetSession.js +76 -7
- package/dist/browser/CdpTargetSessionOwner.js +198 -0
- package/dist/browser/CdpWebMcpDiscovery.js +23 -6
- package/dist/browser/ElectronCaptureCleanup.js +82 -0
- package/dist/browser/ElectronProcessCleanup.js +91 -0
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +75 -20
- package/dist/browser/PlaywrightElectronActiveActions.js +57 -9
- package/dist/browser/PlaywrightElectronActiveFuses.js +86 -0
- package/dist/browser/PlaywrightElectronActiveProjection.js +21 -4
- package/dist/browser/PlaywrightElectronActiveProvider.js +237 -175
- package/dist/browser/PlaywrightExecutionBoundary.js +6 -4
- package/dist/browser/PlaywrightScenarioBrowser.js +240 -91
- package/dist/browser/PlaywrightScenarioEvents.js +287 -38
- package/dist/browser/PlaywrightScenarioServiceWorkers.js +336 -0
- package/dist/browser/PlaywrightScenarioSession.js +151 -46
- package/dist/browser/PlaywrightScenarioStorage.js +15 -7
- package/dist/browser/StructuredFieldToken.js +53 -0
- package/dist/browser/WebArtifactCleanup.js +53 -0
- package/dist/browser/WebSourceMapFetcher.js +181 -89
- package/dist/browser/assets/LocalWebScriptArtifacts.js +24 -3
- package/dist/browser/assets/PublishWebScripts.js +13 -2
- package/dist/browser/assets/ScenarioScriptCapture.js +2 -1
- package/dist/browser/assets/WebArtifactReads.js +15 -3
- package/dist/browser/assets/WebSourceLocationArtifacts.js +47 -3
- package/dist/browser/execution/CdpRuntimeSession.js +36 -7
- package/dist/browser/execution/CdpWebRuntimeProvider.js +22 -4
- package/dist/browser/history/CaptureFailures.js +29 -10
- package/dist/browser/history/CaptureFormatError.js +2 -2
- package/dist/browser/history/{HarJson.js → CaptureJson.js} +14 -4
- package/dist/browser/history/CaptureRedaction.js +16 -3
- package/dist/browser/history/CaptureRelease.js +20 -2
- package/dist/browser/history/HarCapture.js +54 -30
- package/dist/browser/history/HarSchema.js +36 -36
- package/dist/browser/history/HistoricalCaptureDecoder.js +93 -25
- package/dist/browser/history/NodeCaptureAdapter.js +48 -0
- package/dist/browser/history/{HarCaptureProcess.js → NodeCaptureProcess.js} +18 -9
- package/dist/browser/history/QlogCapture.js +385 -0
- package/dist/browser/history/SazCapture.js +130 -0
- package/dist/browser/history/SazHttp.js +61 -0
- package/dist/browser/history/SazMetadata.js +55 -0
- package/dist/browser/history/SazProjection.js +90 -0
- package/dist/browser/modules/NativeModuleResolver.js +248 -131
- package/dist/browser/modules/WebModuleArtifacts.js +49 -3
- package/dist/browser/network/PlaywrightNetworkContent.js +67 -9
- package/dist/browser/network/PlaywrightScenarioNetwork.js +249 -26
- package/dist/captures/TsharkCaptureProvider.js +377 -0
- package/dist/captures/parseFieldDiscovery.js +66 -0
- package/dist/captures/parsePacketOutput.js +21 -0
- package/dist/catalogIdentity.js +58 -42
- package/dist/cli/adbCommands.js +20 -21
- package/dist/cli/analysisViewCommands.js +1 -1
- package/dist/cli/androidCommands.js +13 -16
- package/dist/cli/apktoolCommands.js +14 -25
- package/dist/cli/applicationCommands.js +44 -17
- package/dist/cli/artifactCommands.js +1 -1
- package/dist/cli/binaryDiagnosticsCommands.js +17 -13
- package/dist/cli/browserAdvancedCommands.js +46 -26
- package/dist/cli/browserCommands.js +59 -33
- package/dist/cli/captureCommands.js +72 -0
- package/dist/cli/cliResultOutput.js +274 -0
- package/dist/cli/coreBinaryCommands.js +77 -30
- package/dist/cli/coreNativeCommands.js +53 -31
- package/dist/cli/cutterCommands.js +88 -0
- package/dist/cli/electronCommands.js +76 -13
- package/dist/cli/evmCommands.js +9 -19
- package/dist/cli/finishAnalysisCommand.js +52 -0
- package/dist/cli/firmwareCommands.js +20 -50
- package/dist/cli/flutterCommands.js +53 -0
- package/dist/cli/fridaCommands.js +219 -0
- package/dist/cli/goCommands.js +20 -0
- package/dist/cli/interactiveSetup.js +11 -1
- package/dist/cli/javascriptApplicationAnalysis.js +1 -1
- package/dist/cli/javascriptRecoveryCommands.js +18 -23
- package/dist/cli/jebCommands.js +2 -14
- package/dist/cli/jsonOutput.js +2 -2
- package/dist/cli/managedCommands.js +31 -3
- package/dist/cli/options.js +26 -2
- package/dist/cli/pcapCommands.js +29 -0
- package/dist/cli/processCommands.js +1 -1
- package/dist/cli/reverseEngineeringCommands.js +268 -0
- package/dist/cli/rustCommands.js +20 -0
- package/dist/cli/setupCommands.js +41 -12
- package/dist/cli/signalCommands.js +72 -0
- package/dist/cli/sqliteCommands.js +52 -0
- package/dist/cli/utilityCommands.js +116 -74
- package/dist/cli/wasmCommands.js +50 -0
- package/dist/cli/webModuleCommands.js +27 -38
- package/dist/cli/webNetworkCaptureCommands.js +10 -9
- package/dist/cli/webRuntimeCommands.js +15 -6
- package/dist/cli/webSourceLocationCommands.js +14 -33
- package/dist/cli-runtime/AnalysisCleanupLease-CWfTGYKd.js +103 -0
- package/dist/cli-runtime/AnalysisProvider-BGrYaMVo.js +38 -0
- package/dist/cli-runtime/AnalysisSnapshotCache-BjRlXeUS.js +711 -0
- package/dist/cli-runtime/ArtifactFileOperation-Dg4BcoEM.js +122 -0
- package/dist/cli-runtime/ArtifactReader-DMwm42bk.js +78 -0
- package/dist/cli-runtime/ArtifactResourceScope-CokZGcII.js +175 -0
- package/dist/cli-runtime/AsarHeader-BxwU17DJ.js +31 -0
- package/dist/cli-runtime/BinarySessionStatus-DRhjr7Vb.js +212 -0
- package/dist/cli-runtime/BinaryTargetResolver-tuCTjBlQ.js +1238 -0
- package/dist/cli-runtime/BoundedFileBytes-DRtiQNAQ.js +43 -0
- package/dist/cli-runtime/CdpTargetSession-CQ08KHbh.js +925 -0
- package/dist/cli-runtime/ClientConfigPath-Dn-V_GUf.js +255 -0
- package/dist/cli-runtime/ClientConfigurationDocument-C9T8MNGc.js +2021 -0
- package/dist/cli-runtime/ClientRegistrationStatus-PnD29RTX.js +585 -0
- package/dist/cli-runtime/CurrentEntrypointPath-m7QCIVN0.js +14 -0
- package/dist/cli-runtime/DirectAnalysis-C5NyUryV.js +581 -0
- package/dist/cli-runtime/DirectoryArtifactReader-CokAJ8vo.js +448 -0
- package/dist/cli-runtime/Doctor-DrkWsav4.js +668 -0
- package/dist/cli-runtime/ElectronFileScope-AP7VoVr7.js +1109 -0
- package/dist/cli-runtime/ElectronFuseFailures-DsjXR7Xp.js +609 -0
- package/dist/cli-runtime/ExecFileOutput-D6KLYTve.js +119 -0
- package/dist/cli-runtime/InterfaceBuilderDecodeBudget-CW1IO3dG.js +298 -0
- package/dist/cli-runtime/InventoryProjectionEvidence-DTH5QAqL.js +49 -0
- package/dist/cli-runtime/InvestigationProviders-CFh4a64d.js +118 -0
- package/dist/cli-runtime/JavaScriptApplicationEvidenceGraph-gOmPB2L6.js +160 -0
- package/dist/cli-runtime/JavaScriptApplicationWorkflowEvidence-WZgtK_Ok.js +75 -0
- package/dist/cli-runtime/JavaScriptWorkerMemoryLimit-B1bwMM1a.js +86 -0
- package/dist/cli-runtime/JebMcpEndpoint-BEalGZh9.js +710 -0
- package/dist/cli-runtime/JsonFiles-uvd6ZyQi.js +600 -0
- package/dist/cli-runtime/KunaInstallation-P0j3x851.js +1781 -0
- package/dist/cli-runtime/MacCodeSignature-MgYbRK_H.js +24 -0
- package/dist/cli-runtime/MacHopperPaths-bGzqjF1Z.js +34 -0
- package/dist/cli-runtime/MachoLoadCommandReader-CZm6N5vF.js +330 -0
- package/dist/cli-runtime/ManagedSnapshot-CPE9C3OD.js +4481 -0
- package/dist/cli-runtime/OwnedCommandCleanup-BN_V6Erc.js +187 -0
- package/dist/cli-runtime/OwnedRegularFile-D1f5nUCx.js +256 -0
- package/dist/cli-runtime/OwnedStagedOutput-D31dOozz.js +126 -0
- package/dist/cli-runtime/PrivateRuntimeRoot-Cd23u6jd.js +296 -0
- package/dist/cli-runtime/ProcessOwnership-CtrNr6ee.js +545 -0
- package/dist/cli-runtime/ProcessOwnershipObservation-C006iCtZ.js +920 -0
- package/dist/cli-runtime/ProviderDeadline-rSuH4Pm8.js +148 -0
- package/dist/cli-runtime/ProviderOperationExecution-CmU-XrQr.js +38 -0
- package/dist/cli-runtime/ProviderProcess-D87A7ctp.js +770 -0
- package/dist/cli-runtime/RegularFileRead-mbgGYtxe.js +125 -0
- package/dist/cli-runtime/SafeOutputTree-i904hd_2.js +525 -0
- package/dist/cli-runtime/SetupHost-CMPmPraB.js +1268 -0
- package/dist/cli-runtime/SharedStartupAttempt-BxKyf3Uv.js +1424 -0
- package/dist/cli-runtime/StableFileHash-Ame_h3lY.js +61 -0
- package/dist/cli-runtime/SupportedClients-DMafjitv.js +1066 -0
- package/dist/cli-runtime/UninstallFailure-1blyKXHE.js +22 -0
- package/dist/cli-runtime/Update-DAsASWlE.js +143 -0
- package/dist/cli-runtime/UpdateFailure-BcFNxEZZ.js +24 -0
- package/dist/cli-runtime/WindowsBatchCommand-Cx9kaVNf.js +97 -0
- package/dist/cli-runtime/WindowsNativeLoader-BqyZO0ZD.js +142 -0
- package/dist/cli-runtime/ZipArtifactReader-Jed69LEL.js +252 -0
- package/dist/cli-runtime/analysisErrorCleanup-COdAmDsb.js +33 -0
- package/dist/cli-runtime/appleArchiveFormat-Bb3G5CCI.js +269 -0
- package/dist/cli-runtime/application__DirectAnalysisStatus-F74bu9oy.js +150 -0
- package/dist/cli-runtime/application__EnhancedTools-Bg51b0Yp.js +1820 -0
- package/dist/cli-runtime/application__FunctionAnalysisEvidence-DBWIaYCh.js +41 -0
- package/dist/cli-runtime/application__ReconstructionCoverageService-AEPNpZqJ.js +32 -0
- package/dist/cli-runtime/application__ReconstructionObligationLedgerService-Cl9cPEZf.js +828 -0
- package/dist/cli-runtime/application__Setup-DwQzEewK.js +526 -0
- package/dist/cli-runtime/application__Uninstall-BOf9oyvQ.js +468 -0
- package/dist/cli-runtime/application__UpdateRuntime-CzWkRJHa.js +435 -0
- package/dist/cli-runtime/application__android__AndroidApplicationService-shW_aKlj.js +31 -0
- package/dist/cli-runtime/application__apple__AppleApplicationService-DIv6d3wB.js +31 -0
- package/dist/cli-runtime/application__harmony__HarmonyApplicationService-OIUFVQFV.js +31 -0
- package/dist/cli-runtime/application__javascript__ElectronActiveObservationService-wvCh72hK.js +118 -0
- package/dist/cli-runtime/application__javascript__ElectronObservationService-SydXPCwM.js +88 -0
- package/dist/cli-runtime/application__javascript__JavaScriptApplicationService-o0uEsjEc.js +12254 -0
- package/dist/cli-runtime/application__javascript__JavaScriptApplicationWorkflowService-BAheG_71.js +2336 -0
- package/dist/cli-runtime/application__javascript__JavaScriptRuntimeReconciliationService-Cnn4GP8q.js +88 -0
- package/dist/cli-runtime/application__javascript__JavaScriptSemanticTraceService-CmvLfV1A.js +299 -0
- package/dist/cli-runtime/artifacts__ArtifactProvider-wx2K0F2I.js +2205 -0
- package/dist/cli-runtime/binary-CWVNJhAC.js +19608 -0
- package/dist/cli-runtime/catalogIdentity-DAEEsOdX.js +1112 -0
- package/dist/cli-runtime/cli.js +44469 -0
- package/dist/cli-runtime/cliOutput-CgSuw782.js +163 -0
- package/dist/cli-runtime/cliOutput.js +5 -0
- package/dist/cli-runtime/cliResultOutput-10sd6xGx.js +1453 -0
- package/dist/cli-runtime/cliResultOutput.js +6 -0
- package/dist/cli-runtime/composition__browserScenario-BtPb1c1y.js +3414 -0
- package/dist/cli-runtime/composition__electronObservation-Bk8R6DJo.js +614 -0
- package/dist/cli-runtime/composition__electronScenario-BVF0qStH.js +916 -0
- package/dist/cli-runtime/cutterToolContracts-BQtG_Nzo.js +5267 -0
- package/dist/cli-runtime/doctorRuntime-B__SIpm-.js +478 -0
- package/dist/cli-runtime/dotnet__ManagedStaticProvider-DO5Yzcp4.js +5 -0
- package/dist/cli-runtime/errorSchemas-Ixz_q7qt.js +655 -0
- package/dist/cli-runtime/homeDirectory-DC_DeJIg.js +18 -0
- package/dist/cli-runtime/javascriptApplicationAnalysis-Dk6yBV8g.js +2088 -0
- package/dist/cli-runtime/javascriptExportReturnShapeProjection-CObOIiQ6.js +78 -0
- package/dist/cli-runtime/javascriptExportShapeComparisonSchemas-DpwuBenh.js +1244 -0
- package/dist/cli-runtime/javascriptRuntimeReconciliation-C6ZgWMys.js +1509 -0
- package/dist/cli-runtime/javascriptRuntimeReconciliationSchemas-D6tZKUQs.js +247 -0
- package/dist/cli-runtime/javascriptSemanticTraceSchemas-C7m0b6_w.js +126 -0
- package/dist/cli-runtime/lipo-DPQ6qurH.js +394 -0
- package/dist/cli-runtime/logger-BuDJ9xxO.js +48 -0
- package/dist/cli-runtime/machoContainer-Cy98bkFm.js +352 -0
- package/dist/cli-runtime/managedApplicationGraph-BazVqpJv.js +1136 -0
- package/dist/cli-runtime/managedToolContracts-BuFkMBH5.js +99 -0
- package/dist/cli-runtime/mcpDoctor.js +361 -0
- package/dist/cli-runtime/mcpStartupPolicy-imCbM3qo.js +28 -0
- package/dist/cli-runtime/native__NativeMacOSProvider-DTcRhuGA.js +5502 -0
- package/dist/cli-runtime/officialToolContracts-CzzVLx8I.js +1522 -0
- package/dist/cli-runtime/peMachine-B9ggfSJJ.js +95 -0
- package/dist/cli-runtime/propertyListKeys-D5dSASEy.js +355 -0
- package/dist/cli-runtime/providerCleanupError-BhsJyAhk.js +25 -0
- package/dist/cli-runtime/providerIdentities-Ao1XTvwx.js +31 -0
- package/dist/cli-runtime/providerStartupTimeout-B2tF2LtZ.js +17 -0
- package/dist/cli-runtime/readArtifactFileChunks-BbTL_PtB.js +129 -0
- package/dist/cli-runtime/reconstructionObligationLedgerSchemas-Bi6sect1.js +22156 -0
- package/dist/cli-runtime/rolldown-runtime-DXoylpqc.js +121 -0
- package/dist/cli-runtime/runtimeVersion-CMGd0bDu.js +23 -0
- package/dist/cli-runtime/safeJson-DKKACtdy.js +25 -0
- package/dist/cli-runtime/scanCanonical-CcDFUr-w.js +2594 -0
- package/dist/cli-runtime/snapshotEnvironment-Yvx5qwsl.js +196 -0
- package/dist/cli-runtime/toolContracts-CJzEyZ38.js +3795 -0
- package/dist/cli-runtime/toolOutputSchemaGroups-BqdSzySu.js +12249 -0
- package/dist/cli-runtime/workflowInputError-BP8z9Wxl.js +26 -0
- package/dist/cli.js +48 -5
- package/dist/cliBrowserScenarioCommands.js +41 -7
- package/dist/cliCommandNames.js +48 -0
- package/dist/cliEvidenceCommands.js +0 -1
- package/dist/cliJavaScriptRuntimeCommands.js +16 -14
- package/dist/cliJsonInput.js +12 -4
- package/dist/cliLogging.js +66 -15
- package/dist/cliObservationOptions.js +9 -0
- package/dist/cliOutput.js +105 -7
- package/dist/composition/binary.js +19 -2
- package/dist/composition/captures.js +3 -0
- package/dist/composition/directAnalysis.js +36 -11
- package/dist/composition/electronFuses.js +4 -0
- package/dist/composition/evm.js +12 -0
- package/dist/composition/flutter.js +3 -0
- package/dist/composition/go.js +4 -0
- package/dist/composition/javascriptAnalysisWorkerProcess.js +8 -8
- package/dist/composition/jeb.js +45 -5
- package/dist/composition/pcap.js +3 -0
- package/dist/composition/resolveWindowsProviderExecutable.js +61 -0
- package/dist/composition/reverseEngineering.js +29 -0
- package/dist/composition/rust.js +4 -0
- package/dist/composition/signals.js +3 -0
- package/dist/composition/sqlite.js +4 -0
- package/dist/composition/wasm.js +22 -0
- package/dist/composition/webNetworkCaptures.js +7 -2
- package/dist/config/environment.js +79 -4
- package/dist/config/ghidraDisabledAnalyzers.js +25 -0
- package/dist/config/homeDirectory.js +9 -6
- package/dist/config/mcpInputSchemaProfile.js +5 -1
- package/dist/config/mcpOutputSchemaProfile.js +22 -0
- package/dist/config/parseConfig.js +28 -34
- package/dist/config/parsers.js +4 -3
- package/dist/config/{ghidraStartupTimeout.js → providerStartupTimeout.js} +7 -3
- package/dist/contracts/adb/adbToolContracts.js +8 -8
- package/dist/contracts/analysisDetail.js +6 -3
- package/dist/contracts/analysisViewApiSurfaceExample.js +68 -0
- package/dist/contracts/analysisViewToolContracts.js +65 -3
- package/dist/contracts/android/androidToolContracts.js +17 -8
- package/dist/contracts/apktool/apktoolToolContracts.js +5 -1
- package/dist/contracts/applicationToolContracts.js +17 -2
- package/dist/contracts/artifactComparisonExample.js +18 -14
- package/dist/contracts/artifactToolContracts.js +16 -3
- package/dist/contracts/browserScenarioToolContracts.js +1 -1
- package/dist/contracts/browserToolContracts.js +13 -1
- package/dist/contracts/captures/captureToolContracts.js +42 -0
- package/dist/contracts/compactInputSchema.js +39 -12
- package/dist/contracts/cutterToolContracts.js +84 -0
- package/dist/contracts/enhancedToolContracts.js +2 -2
- package/dist/contracts/evm/evmToolContracts.js +30 -15
- package/dist/contracts/firmware/firmwareToolContracts.js +1 -1
- package/dist/contracts/flutter/flutterToolContracts.js +47 -0
- package/dist/contracts/fridaRemoteAddress.js +23 -0
- package/dist/contracts/fridaToolContracts.js +274 -0
- package/dist/contracts/functionComparisonExample.js +12 -1
- package/dist/contracts/gdbToolContracts.js +102 -0
- package/dist/contracts/go/goToolContracts.js +20 -0
- package/dist/contracts/hopperMemoryContracts.js +15 -0
- package/dist/contracts/inputSchemaPresentation.js +199 -38
- package/dist/contracts/investigationExamples.js +1 -0
- package/dist/contracts/javascript/electronToolContracts.js +27 -2
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +1 -0
- package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +13 -1
- package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +1 -0
- package/dist/contracts/jsonSchemaKeywords.js +29 -0
- package/dist/contracts/managed/managedToolContracts.js +43 -4
- package/dist/contracts/managed/managedWorkflowExamples.js +10 -1
- package/dist/contracts/managed/managedWorkflowToolContracts.js +4 -30
- package/dist/contracts/mobileApplicationGraphExamples.js +27 -12
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +3 -2
- package/dist/contracts/native/nativeToolContracts.js +10 -6
- package/dist/contracts/officialToolContracts.js +7 -7
- package/dist/contracts/pcap/pcapToolContracts.js +33 -0
- package/dist/contracts/providerSelection.js +1 -0
- package/dist/contracts/reconstructionReadinessExample.js +126 -119
- package/dist/contracts/reverseEngineeringToolContracts.js +52 -0
- package/dist/contracts/rizinDebugToolContracts.js +97 -0
- package/dist/contracts/rust/rustToolContracts.js +20 -0
- package/dist/contracts/sessionLifecycleInputs.js +34 -2
- package/dist/contracts/sessionToolContracts.js +4 -4
- package/dist/contracts/sessionToolSchemas.js +14 -0
- package/dist/contracts/signals/signalToolContracts.js +40 -0
- package/dist/contracts/sqlite/sqliteToolContracts.js +36 -0
- package/dist/contracts/toolContractExamples.js +29 -0
- package/dist/contracts/toolContractTypes.js +2 -0
- package/dist/contracts/toolContracts.js +26 -0
- package/dist/contracts/toolEffects.js +252 -9
- package/dist/contracts/toolOutputSchemaGroups.js +78 -32
- package/dist/contracts/toolOutputSchemaPrimitives.js +118 -10
- package/dist/contracts/toolSchemaMetadata.js +102 -16
- package/dist/contracts/unknownContractExamples.js +1 -1
- package/dist/contracts/wasm/wasmComparisonContracts.js +52 -0
- package/dist/contracts/wasm/wasmToolContracts.js +33 -0
- package/dist/contracts/webNetworkCaptureToolContracts.js +15 -4
- package/dist/cutter/CutterBridgeClient.js +760 -0
- package/dist/cutter/CutterBridgeService.js +187 -0
- package/dist/doctorRuntime.js +41 -8
- package/dist/domain/adb/adbDeviceAnalysis.js +45 -5
- package/dist/domain/analysisErrorBase.js +79 -2
- package/dist/domain/analysisErrorCleanup.js +4 -2
- package/dist/domain/analysisErrorCore.js +32 -0
- package/dist/domain/analysisErrorPresentation.js +80 -20
- package/dist/domain/analysisErrorProjection.js +72 -37
- package/dist/domain/analysisProfile.js +7 -3
- package/dist/domain/analysisSearch.js +26 -0
- package/dist/domain/analysisSnapshot.js +312 -185
- package/dist/domain/analysisView/WebNetworkApiSurfaceAccumulator.js +353 -0
- package/dist/domain/analysisView/analysisView.js +391 -44
- package/dist/domain/analysisView/analysisViewCoverage.js +32 -0
- package/dist/domain/analysisView/analysisViewDataAdmission.js +86 -0
- package/dist/domain/analysisView/analysisViewErrors.js +4 -0
- package/dist/domain/analysisView/analysisViewParent.js +12 -0
- package/dist/domain/analysisView/analysisViewText.js +29 -0
- package/dist/domain/analysisView/androidPackageView.js +102 -0
- package/dist/domain/analysisView/artifactInventoryView.js +126 -0
- package/dist/domain/analysisView/binaryLayoutView.js +11 -4
- package/dist/domain/analysisView/dartAotView.js +93 -0
- package/dist/domain/analysisView/evmInterfaceView.js +105 -0
- package/dist/domain/analysisView/interfaceBuilderView.js +182 -0
- package/dist/domain/analysisView/javascriptApplicationCoverage.js +27 -0
- package/dist/domain/analysisView/javascriptApplicationView.js +123 -49
- package/dist/domain/analysisView/javascriptFactsView.js +92 -0
- package/dist/domain/analysisView/javascriptModuleReferences.js +37 -0
- package/dist/domain/analysisView/machoView.js +186 -0
- package/dist/domain/analysisView/managedArtifactView.js +108 -0
- package/dist/domain/analysisView/managedMemberView.js +215 -0
- package/dist/domain/analysisView/nativeFunctionView.js +20 -25
- package/dist/domain/analysisView/pcapCaptureView.js +264 -0
- package/dist/domain/analysisView/qlogCaptureView.js +198 -0
- package/dist/domain/analysisView/wasmArtifactView.js +162 -0
- package/dist/domain/analysisView/webNetworkApiSurfaceView.js +123 -0
- package/dist/domain/analysisView/webNetworkCaptureView.js +388 -0
- package/dist/domain/android/androidAnalysis.js +36 -2
- package/dist/domain/android/androidApplication.js +37 -64
- package/dist/domain/apktool/apktoolResourceAnalysis.js +70 -8
- package/dist/domain/apple/appleApplication.js +70 -87
- package/dist/domain/apple/appleArchiveFormat.js +184 -0
- package/dist/domain/apple/appleAssetCatalog.js +15 -0
- package/dist/domain/apple/appleBundleAnatomy.js +57 -69
- package/dist/domain/apple/dyldPaths.js +9 -2
- package/dist/domain/apple/dylibResolution.js +24 -10
- package/dist/domain/apple/dylibResolutionFindings.js +8 -9
- package/dist/domain/apple/interfaceBuilderGraph.js +78 -33
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +39 -12
- package/dist/domain/apple/jvmClassFile.js +226 -0
- package/dist/domain/apple/keyedArchive.js +39 -17
- package/dist/domain/apple/machoContainer.js +123 -8
- package/dist/domain/apple/machoCpuIdentity.js +4 -0
- package/dist/domain/apple/plistNumbers.js +67 -5
- package/dist/domain/apple/plistValue.js +95 -19
- package/dist/domain/artifactComparison.js +116 -37
- package/dist/domain/artifactDecompressionBudget.js +26 -0
- package/dist/domain/artifactGraph.js +18 -9
- package/dist/domain/artifactIdentity.js +4 -1
- package/dist/domain/artifactInspection.js +34 -3
- package/dist/domain/artifactInventoryEvidence.js +146 -40
- package/dist/domain/binaryTarget.js +251 -109
- package/dist/domain/binaryTargetTypes.js +24 -1
- package/dist/domain/browserNetworkEvidence.js +24 -3
- package/dist/domain/browserObservation.js +92 -56
- package/dist/domain/browserObservationError.js +4 -4
- package/dist/domain/browserObservationSchemas.js +4 -1
- package/dist/domain/browserScenarioCapture.js +11 -1
- package/dist/domain/browserScenarioCaptureLimits.js +34 -0
- package/dist/domain/browserScenarioCaptureValues.js +76 -2
- package/dist/domain/browserScenarioDiff.js +120 -11
- package/dist/domain/browserScenarioDiffEvidence.js +44 -13
- package/dist/domain/browserScenarioDiffValues.js +10 -3
- package/dist/domain/browserScenarioNetworkComparison.js +158 -0
- package/dist/domain/browserScenarioNormalization.js +10 -13
- package/dist/domain/browserScenarioValues.js +7 -13
- package/dist/domain/browserSession.js +2 -2
- package/dist/domain/bundleComparison.js +1 -5
- package/dist/domain/callPath.js +40 -3
- package/dist/domain/captures/packetCapture.js +139 -0
- package/dist/domain/captures/packetFields.js +81 -0
- package/dist/domain/changedBehavior.js +43 -41
- package/dist/domain/comparisonSourceEvidence.js +6 -0
- package/dist/domain/dosCom.js +2 -2
- package/dist/domain/dosMz.js +66 -19
- package/dist/domain/electron/electronFuseEvidence.js +42 -0
- package/dist/domain/electron/electronFuses.js +360 -0
- package/dist/domain/elfFixedHeader.js +66 -0
- package/dist/domain/evidence.js +105 -39
- package/dist/domain/evidenceBundle.js +67 -22
- package/dist/domain/evidenceErrors.js +5 -0
- package/dist/domain/evm/evmInterface.js +18 -4
- package/dist/domain/evm/solidityMetadata.js +70 -0
- package/dist/domain/explicitSensitiveFailure.js +44 -23
- package/dist/domain/fileSnapshotObservation.js +25 -0
- package/dist/domain/firmware/firmwareAnalysis.js +29 -0
- package/dist/domain/fixedTupleSchema.js +9 -0
- package/dist/domain/flutter/flutterBuildAnalysis.js +141 -0
- package/dist/domain/functionCallCoverage.js +60 -0
- package/dist/domain/functionComparisonDimensions.js +136 -18
- package/dist/domain/functionComparisonNormalization.js +83 -19
- package/dist/domain/functionComparisonResults.js +7 -6
- package/dist/domain/functionComparisonSchemas.js +14 -3
- package/dist/domain/functionDossierEvidence.js +4 -0
- package/dist/domain/go/goBinary.js +96 -0
- package/dist/domain/harmony/harmonyApplication.js +156 -0
- package/dist/domain/hopperErrors.js +19 -18
- package/dist/domain/hopperPublisher.js +12 -0
- package/dist/domain/hopperValues.js +135 -34
- package/dist/domain/javascript/electronActiveObservation.js +1 -0
- package/dist/domain/javascript/electronObservation.js +4 -1
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +94 -33
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +3 -1
- package/dist/domain/javascript/electronStaticAnalysisNative.js +19 -5
- package/dist/domain/javascript/electronStaticAnalysisValues.js +14 -28
- package/dist/domain/javascript/electronStaticOptionObjects.js +45 -0
- package/dist/domain/javascript/electronWrappedCallPaths.js +551 -0
- package/dist/domain/javascript/htmlArtifactReferences.js +94 -4
- package/dist/domain/javascript/javascriptAnalysisResourceControls.js +37 -1
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +7 -0
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +10 -2
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +1 -1
- package/dist/domain/javascript/javascriptApplicationGraph.js +17 -1
- package/dist/domain/javascript/javascriptApplicationGraphSchemas.js +1 -0
- package/dist/domain/javascript/javascriptApplicationProjectionResources.js +8 -0
- package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +3 -1
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +49 -21
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +31 -18
- package/dist/domain/javascript/javascriptArtifactFiles.js +2 -1
- package/dist/domain/javascript/javascriptAstFingerprint.js +89 -24
- package/dist/domain/javascript/javascriptAstValues.js +132 -5
- package/dist/domain/javascript/javascriptBootstrap.js +94 -0
- package/dist/domain/javascript/javascriptBootstrapIntegrity.js +372 -0
- package/dist/domain/javascript/javascriptBuiltinResourceMethods.js +8 -0
- package/dist/domain/javascript/javascriptBundledRequireOrigin.js +278 -0
- package/dist/domain/javascript/javascriptCommonJsExportReceivers.js +231 -0
- package/dist/domain/javascript/javascriptContextBridgeExposure.js +23 -0
- package/dist/domain/javascript/javascriptElectronMemberWrites.js +96 -22
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +6 -5
- package/dist/domain/javascript/javascriptExportShapeVariants.js +1 -1
- package/dist/domain/javascript/javascriptFeatureSeed.js +34 -17
- package/dist/domain/javascript/javascriptFeatureTrace.js +9 -3
- package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +42 -11
- package/dist/domain/javascript/javascriptGraphqlOperations.js +382 -0
- package/dist/domain/javascript/javascriptIntrinsicInvocation.js +132 -0
- package/dist/domain/javascript/javascriptModuleDeclaration.js +48 -0
- package/dist/domain/javascript/javascriptModuleInterop.js +618 -0
- package/dist/domain/javascript/javascriptModuleResolutionMode.js +18 -0
- package/dist/domain/javascript/javascriptModuleSpecifier.js +5 -0
- package/dist/domain/javascript/javascriptNativeHandoff.js +7 -12
- package/dist/domain/javascript/javascriptPackageImportAliases.js +58 -0
- package/dist/domain/javascript/javascriptRecovery.js +12 -5
- package/dist/domain/javascript/javascriptRpcEndpoints.js +7 -93
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +16 -0
- package/dist/domain/javascript/javascriptRuntimeObservation.js +4 -1
- package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +45 -16
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +65 -47
- package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +0 -1
- package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +5 -4
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +113 -11
- package/dist/domain/javascript/javascriptSemanticAmbientWrites.js +511 -0
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +706 -204
- package/dist/domain/javascript/javascriptSemanticAsyncEffects.js +54 -54
- package/dist/domain/javascript/javascriptSemanticCallResolution.js +59 -30
- package/dist/domain/javascript/javascriptSemanticCallableStack.js +52 -0
- package/dist/domain/javascript/javascriptSemanticCalls.js +10 -15
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +163 -92
- package/dist/domain/javascript/javascriptSemanticCoverage.js +5 -1
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +435 -45
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +46 -29
- package/dist/domain/javascript/javascriptSemanticDependencies.js +69 -0
- package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +1 -1
- package/dist/domain/javascript/javascriptSemanticEvaluationOrder.js +126 -0
- package/dist/domain/javascript/javascriptSemanticExpressionShapes.js +111 -0
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +11 -14
- package/dist/domain/javascript/javascriptSemanticGetterQueries.js +147 -0
- package/dist/domain/javascript/javascriptSemanticGetterResults.js +264 -0
- package/dist/domain/javascript/javascriptSemanticGraph.js +22 -1
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +13 -1
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +5 -4
- package/dist/domain/javascript/javascriptSemanticMapOperations.js +51 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +421 -154
- package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +500 -27
- package/dist/domain/javascript/javascriptSemanticObjectReferences.js +377 -174
- package/dist/domain/javascript/javascriptSemanticObjects.js +53 -43
- package/dist/domain/javascript/javascriptSemanticOpaqueEffects.js +163 -0
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +11 -1
- package/dist/domain/javascript/javascriptSemanticProjection.js +180 -95
- package/dist/domain/javascript/javascriptSemanticPromises.js +6 -9
- package/dist/domain/javascript/javascriptSemanticProvenance.js +5 -1
- package/dist/domain/javascript/javascriptSemanticQuery.js +7 -2
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +2 -1
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +1 -1
- package/dist/domain/javascript/javascriptSemanticReferenceSources.js +25 -0
- package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +369 -8
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +3 -19
- package/dist/domain/javascript/javascriptSemanticResources.js +33 -44
- package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +81 -26
- package/dist/domain/javascript/javascriptSemanticReturns.js +37 -30
- package/dist/domain/javascript/javascriptSemanticState.js +225 -39
- package/dist/domain/javascript/javascriptSemanticTraversal.js +6 -4
- package/dist/domain/javascript/javascriptSemanticValues.js +379 -56
- package/dist/domain/javascript/javascriptSourceMapPaths.js +44 -17
- package/dist/domain/javascript/javascriptSourceParser.js +121 -7
- package/dist/domain/javascript/javascriptSourceSelection.js +11 -0
- package/dist/domain/javascript/javascriptStaticAnalysis.js +69 -24
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +97 -23
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +488 -48
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +196 -78
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +4 -0
- package/dist/domain/javascript/javascriptStaticAnalysisTypes.js +2 -1
- package/dist/domain/javascript/javascriptSymbolicBindings.js +1118 -0
- package/dist/domain/javascript/javascriptSymbolicControlFlow.js +44 -0
- package/dist/domain/javascript/javascriptSymbolicValues.js +45 -0
- package/dist/domain/javascript/sourceToBundleComparison.js +3 -1
- package/dist/domain/javascript/sourceToBundleComparisonSchemas.js +2 -0
- package/dist/domain/javascript/sourceToBundleSignals.js +50 -13
- package/dist/domain/jsonValue.js +37 -12
- package/dist/domain/localPath.js +6 -3
- package/dist/domain/managed/managedApplicationGraph.js +5 -0
- package/dist/domain/managed/managedApplicationGraphCoverage.js +6 -2
- package/dist/domain/managed/managedApplicationGraphNodes.js +14 -10
- package/dist/domain/managed/managedArtifact.js +77 -1
- package/dist/domain/managed/managedInspectionEvidence.js +5 -6
- package/dist/domain/managed/managedMemberComparison.js +6 -0
- package/dist/domain/managed/managedMemberComparisonCoverage.js +36 -3
- package/dist/domain/managed/managedMemberComparisonItems.js +135 -59
- package/dist/domain/managed/managedMemberComparisonMatch.js +237 -42
- package/dist/domain/managed/managedMemberSignatureIdentity.js +40 -0
- package/dist/domain/managed/managedNativeVerificationMatch.js +54 -31
- package/dist/domain/managed/managedNativeVerificationSchemas.js +15 -4
- package/dist/domain/managed/managedReconstruction.js +5 -8
- package/dist/domain/mobileApplicationGraphProjection.js +95 -0
- package/dist/domain/native/addressCoordinate.js +11 -0
- package/dist/domain/native/binaryLayout.js +2 -4
- package/dist/domain/native/bytePattern.js +121 -0
- package/dist/domain/native/nativeAotPe.js +31 -4
- package/dist/domain/native/nativeAotSnapshotObservation.js +18 -0
- package/dist/domain/native/nativeCallPartialObservation.js +14 -12
- package/dist/domain/native/nativeInspection.js +38 -4
- package/dist/domain/native/nativeInstruction.js +17 -2
- package/dist/domain/native/nativeInvestigationGraph.js +9 -5
- package/dist/domain/native/nativeLoadImage.js +32 -1
- package/dist/domain/native/nativeUiObservation.js +5 -6
- package/dist/domain/native/objcSwiftMetadata.js +19 -9
- package/dist/domain/native/peResources.js +14 -4
- package/dist/domain/native/recordedCrash.js +79 -10
- package/dist/domain/offsetDateTime.js +60 -0
- package/dist/domain/pcap/pcapAnalysis.js +91 -0
- package/dist/domain/pcap/pcapEvidence.js +15 -0
- package/dist/domain/peMachine.js +38 -0
- package/dist/domain/pngHeader.js +18 -0
- package/dist/domain/process/processCaptureCoverage.js +26 -3
- package/dist/domain/process/processCaptureExample.js +2 -0
- package/dist/domain/process/processCaptureValidation.js +33 -8
- package/dist/domain/process/processComparison.js +41 -13
- package/dist/domain/process/processScenario.js +7 -0
- package/dist/domain/process/processTraceDimensionProjection.js +1 -1
- package/dist/domain/process/processTraceEvaluation.js +119 -74
- package/dist/domain/process/processTraceSpecification.js +243 -89
- package/dist/domain/propertyListKeys.js +238 -23
- package/dist/domain/propertyListXml.js +149 -0
- package/dist/domain/propertyListXmlText.js +20 -4
- package/dist/domain/providerAdapterError.js +2 -5
- package/dist/domain/providerCleanupError.js +2 -4
- package/dist/domain/providerConfigurationRefusal.js +12 -0
- package/dist/domain/providerSelectionError.js +2 -1
- package/dist/domain/qlogCapture.js +62 -0
- package/dist/domain/rawBinary.js +105 -0
- package/dist/domain/reconstructionCoverage.js +40 -24
- package/dist/domain/reconstructionCoverageEvaluation.js +50 -47
- package/dist/domain/reconstructionCoverageEvidence.js +26 -0
- package/dist/domain/reconstructionCoverageVerifierResults.js +35 -0
- package/dist/domain/reconstructionObligationLedgerIntegrity.js +114 -0
- package/dist/domain/reconstructionObligationLedgerSchemas.js +104 -1
- package/dist/domain/reconstructionReadiness.js +4 -8
- package/dist/domain/reconstructionReadinessJourneyFindings.js +4 -1
- package/dist/domain/reconstructionUnknowns.js +9 -1
- package/dist/domain/reconstructionVerification.js +86 -43
- package/dist/domain/recordedTransportUrl.js +59 -0
- package/dist/domain/referenceSourceClassification.js +27 -23
- package/dist/domain/referenceSourceGraph.js +51 -13
- package/dist/domain/referenceSourceImportParsing.js +27 -13
- package/dist/domain/referenceSourcePathIdentity.js +13 -1
- package/dist/domain/referenceSourceRequireBindings.js +40 -108
- package/dist/domain/referenceSourceSummary.js +92 -0
- package/dist/domain/relationshipCoverage.js +43 -0
- package/dist/domain/residualUnknown.js +93 -26
- package/dist/domain/reverseEngineering.js +31 -0
- package/dist/domain/runtimeVersion.js +8 -0
- package/dist/domain/rust/rustBinary.js +200 -0
- package/dist/domain/signals/annotationTextWindow.js +31 -0
- package/dist/domain/signals/signalDecoders.js +69 -0
- package/dist/domain/signals/signalRecording.js +115 -0
- package/dist/domain/sourceMapContents.js +10 -3
- package/dist/domain/sourceMapEnvelope.js +17 -11
- package/dist/domain/sqlite/sqliteDatabase.js +189 -0
- package/dist/domain/staticRuntimeCorrelation.js +7 -9
- package/dist/domain/swiftSymbolClassification.js +17 -0
- package/dist/domain/symbolAnalysis.js +20 -7
- package/dist/domain/urlComponents.js +6 -0
- package/dist/domain/wasm/wasmArtifact.js +119 -0
- package/dist/domain/wasm/wasmInterface.js +89 -0
- package/dist/domain/webBundleAnalysis.js +14 -3
- package/dist/domain/webBundleAnalyzerAst.js +7 -2
- package/dist/domain/webBundleAnalyzerInspection.js +113 -57
- package/dist/domain/webBundleAnalyzerResult.js +18 -6
- package/dist/domain/webCaptureDiff.js +235 -51
- package/dist/domain/webCaptureFrameComparison.js +49 -0
- package/dist/domain/webInventory.js +28 -14
- package/dist/domain/webMcpDiscovery.js +5 -2
- package/dist/domain/webModuleImports.js +22 -27
- package/dist/domain/webModuleTrace.js +25 -8
- package/dist/domain/webNetworkCapture.js +101 -39
- package/dist/domain/webNetworkCaptureCoordinates.js +21 -0
- package/dist/domain/webRuntime.js +0 -1
- package/dist/domain/webScreenshot.js +2 -2
- package/dist/domain/webScriptArtifacts.js +2 -4
- package/dist/domain/webScriptExport.js +6 -8
- package/dist/domain/webScriptExportError.js +2 -3
- package/dist/domain/webScriptExportPlan.js +2 -2
- package/dist/domain/webSourceLocation.js +20 -9
- package/dist/domain/xmlDocument.js +41 -0
- package/dist/domain/zipPackageFormat.js +25 -3
- package/dist/dotnet/ManagedArtifactInspector.js +25 -12
- package/dist/dotnet/ManagedDecodeBudget.js +87 -9
- package/dist/dotnet/ManagedMemberInspector.js +127 -22
- package/dist/dotnet/ManagedMemberInspectorCore.js +408 -141
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +109 -37
- package/dist/dotnet/ManagedMemberOwnership.js +65 -0
- package/dist/dotnet/ManagedMemberPointers.js +69 -0
- package/dist/dotnet/ManagedMemberRows.js +181 -48
- package/dist/dotnet/ManagedMetadataHeaps.js +110 -25
- package/dist/dotnet/ManagedMetadataInventory.js +5 -5
- package/dist/dotnet/ManagedMetadataInventoryRows.js +36 -52
- package/dist/dotnet/ManagedMetadataLayout.js +26 -16
- package/dist/dotnet/ManagedMetadataRowSizes.js +1 -1
- package/dist/dotnet/ManagedMethodBodyReader.js +29 -11
- package/dist/dotnet/ManagedMethodSpecs.js +78 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +20 -19
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +13 -21
- package/dist/dotnet/ManagedPeReader.js +60 -27
- package/dist/dotnet/ManagedReaderFailure.js +9 -0
- package/dist/dotnet/ManagedSnapshot.js +93 -0
- package/dist/dotnet/ManagedStaticProvider.js +55 -64
- package/dist/dotnet/ManagedTypeMemberLists.js +105 -0
- package/dist/dotnet/ManagedTypeNameDigests.js +177 -0
- package/dist/dotnet/ManagedTypeNames.js +58 -0
- package/dist/dotnet/ManagedTypeNesting.js +25 -0
- package/dist/dotnet/ManagedTypeReferences.js +94 -0
- package/dist/dotnet/ManagedUserStrings.js +75 -0
- package/dist/electron/ElectronFuseFailures.js +105 -0
- package/dist/electron/ElectronFusePath.js +248 -0
- package/dist/electron/ElectronFuseProvider.js +88 -0
- package/dist/electron/ElectronFuseReader.js +333 -0
- package/dist/evaluation/AgentEvaluationFixtures.js +194 -11
- package/dist/evaluation/CodexAgentEval.js +19 -40
- package/dist/evaluation/KnownAnswerEvaluation.js +126 -57
- package/dist/evm/EvmoleFailures.js +20 -14
- package/dist/evm/EvmoleInterfaceAdapter.js +5 -1
- package/dist/evm/EvmoleInterfaceProvider.js +142 -35
- package/dist/evm/EvmoleInterfaceWorker.js +2 -0
- package/dist/evm/SolidityMetadata.js +139 -0
- package/dist/filesystem/OwnedRegularFile.js +116 -0
- package/dist/filesystem/OwnedStagedOutput.js +155 -0
- package/dist/filesystem/RegularFile.js +65 -9
- package/dist/filesystem/StableFileHash.js +56 -38
- package/dist/filesystem/callerPath.js +26 -0
- package/dist/filesystem/readFileHandleChunks.js +72 -13
- package/dist/filesystem/readStableFileBytes.js +85 -0
- package/dist/firmware/FirmwareCommand.js +15 -9
- package/dist/firmware/FirmwareFailures.js +56 -0
- package/dist/firmware/FirmwareFiles.js +136 -110
- package/dist/firmware/FirmwareProvider.js +122 -65
- package/dist/firmware/FirmwarePublication.js +244 -12
- package/dist/firmware/FirmwareReports.js +202 -12
- package/dist/flutter/DartElf.js +445 -0
- package/dist/flutter/ElfBuildId.js +137 -0
- package/dist/flutter/ElfLoadMap.js +91 -0
- package/dist/flutter/FlutterBuildProvider.js +866 -0
- package/dist/flutter/FlutterPayloadScan.js +180 -0
- package/dist/frida/FridaInstrumentationManager.js +1104 -0
- package/dist/gdb/GdbSessionManager.js +1639 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +146 -14
- package/dist/ghidra/GhidraAnalysisSeeds.js +39 -55
- package/dist/ghidra/GhidraBridgeSources.js +12 -0
- package/dist/ghidra/GhidraClient.js +501 -180
- package/dist/ghidra/GhidraClientStartup.js +5 -3
- package/dist/ghidra/GhidraClientWire.js +5 -2
- package/dist/ghidra/GhidraDiagnostics.js +23 -5
- package/dist/ghidra/GhidraDoctor.js +60 -26
- package/dist/ghidra/GhidraDosSnapshot.js +83 -0
- package/dist/ghidra/GhidraExecutableHeader.js +54 -0
- package/dist/ghidra/GhidraFileArtifacts.js +93 -0
- package/dist/ghidra/GhidraFunctionValues.js +50 -2
- package/dist/ghidra/GhidraInstallation.js +305 -108
- package/dist/ghidra/GhidraInstallationPolicy.js +94 -103
- package/dist/ghidra/GhidraInstallationProperties.js +57 -0
- package/dist/ghidra/GhidraInventoryValues.js +52 -6
- package/dist/ghidra/GhidraJavaLaunch.js +99 -11
- package/dist/ghidra/GhidraJavaProbe.js +267 -0
- package/dist/ghidra/GhidraJavaProperties.js +119 -0
- package/dist/ghidra/GhidraLanguageCatalog.js +83 -8
- package/dist/ghidra/GhidraLauncher.js +325 -85
- package/dist/ghidra/GhidraLoadImageAttest.js +82 -65
- package/dist/ghidra/GhidraLoadImageValues.js +109 -27
- package/dist/ghidra/GhidraMipsProfile.js +258 -14
- package/dist/ghidra/GhidraNativeAotSnapshotOwner.js +221 -0
- package/dist/ghidra/GhidraPeProfile.js +91 -0
- package/dist/ghidra/GhidraPowerPcProfile.js +51 -0
- package/dist/ghidra/GhidraProvider.js +267 -42
- package/dist/ghidra/GhidraProviderCapabilities.js +29 -15
- package/dist/ghidra/GhidraProviderClient.js +439 -276
- package/dist/ghidra/GhidraPspExtension.js +210 -0
- package/dist/ghidra/GhidraPspProfile.js +62 -0
- package/dist/ghidra/GhidraRawBinaryLanguage.js +49 -0
- package/dist/ghidra/GhidraReleasePolicy.js +93 -0
- package/dist/ghidra/GhidraRequestQueue.js +64 -40
- package/dist/ghidra/GhidraRiscvProfile.js +100 -0
- package/dist/ghidra/GhidraSessionError.js +301 -24
- package/dist/ghidra/GhidraSessionValues.js +76 -0
- package/dist/ghidra/GhidraSocketConnection.js +25 -11
- package/dist/ghidra/GhidraTargetSnapshot.js +67 -50
- package/dist/ghidra/GhidraTransport.js +86 -62
- package/dist/ghidra/extensions/GhidraExtensions.js +30 -45
- package/dist/go/GoBinaryContainer.js +140 -0
- package/dist/go/GoBinaryImage.js +210 -0
- package/dist/go/GoBinaryProvider.js +180 -0
- package/dist/go/GoElfImage.js +211 -0
- package/dist/go/GoMachoImage.js +164 -0
- package/dist/go/GoModuleText.js +217 -0
- package/dist/go/GoPeImage.js +124 -0
- package/dist/hopper/BridgeLauncher.js +78 -6
- package/dist/hopper/HopperAnalysisProfile.js +23 -11
- package/dist/hopper/HopperCleanup.js +29 -4
- package/dist/hopper/HopperClient.js +317 -93
- package/dist/hopper/HopperMacPublisher.js +29 -0
- package/dist/hopper/HopperMachOImage.js +61 -29
- package/dist/hopper/HopperProcessDiagnostic.js +27 -0
- package/dist/hopper/HopperProvider.js +57 -29
- package/dist/hopper/HopperProviderCapabilities.js +9 -4
- package/dist/hopper/HopperRegexSearch.js +21 -60
- package/dist/hopper/HopperRequestQueue.js +17 -5
- package/dist/hopper/HopperSessionValues.js +10 -1
- package/dist/ida/IdaBusyHealth.js +78 -0
- package/dist/ida/IdaCallGraph.js +134 -0
- package/dist/ida/IdaConfiguration.js +7 -2
- package/dist/ida/IdaDiagnosticRedactor.js +199 -0
- package/dist/ida/IdaDiagnosticWriter.js +62 -0
- package/dist/ida/IdaDoctor.js +7 -5
- package/dist/ida/IdaJsonDiagnostic.js +138 -0
- package/dist/ida/IdaMcpConnection.js +308 -32
- package/dist/ida/IdaNativeProtocol.js +85 -0
- package/dist/ida/IdaOperationRunner.js +246 -61
- package/dist/ida/IdaProtocolValues.js +88 -5
- package/dist/ida/IdaProvider.js +45 -10
- package/dist/ida/IdaProviderCapabilities.js +37 -8
- package/dist/ida/IdaSessionClient.js +379 -60
- package/dist/ida/IdaWorkspace.js +54 -6
- package/dist/inspector/V8InspectorCaptureProjection.js +14 -2
- package/dist/inspector/V8InspectorEndpoint.js +15 -13
- package/dist/inspector/V8InspectorProvider.js +43 -7
- package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +44 -12
- package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +107 -32
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +7 -4
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +85 -10
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +16 -6
- package/dist/javascript/recovery/RecoveryFiles.js +107 -13
- package/dist/javascript/recovery/WakaruExecution.js +19 -11
- package/dist/javascript/recovery/WakaruProvider.js +12 -9
- package/dist/javascript/recovery/WakaruPublication.js +24 -10
- package/dist/javascript/recovery/WakaruRelease.js +1 -1
- package/dist/javascript/recovery/WakaruReport.js +3 -2
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +2 -16
- package/dist/javascript/sourceMaps/SourceMapCommand.js +22 -4
- package/dist/javascript/sourceMaps/SourceMapDecoder.js +22 -4
- package/dist/javascript/sourceMaps/SourceMapFormat.js +25 -38
- package/dist/javascript/sourceMaps/TraceSourceMap.js +34 -6
- package/dist/jeb/JebMcpConnection.js +148 -82
- package/dist/jeb/JebMcpConnectionOwner.js +116 -0
- package/dist/jeb/JebMcpDeadline.js +46 -0
- package/dist/jeb/JebMcpEndpoint.js +6 -1
- package/dist/jeb/JebProvider.js +82 -58
- package/dist/kuna/KunaAddress.js +11 -0
- package/dist/kuna/KunaCommand.js +217 -0
- package/dist/kuna/KunaConfiguration.js +90 -0
- package/dist/kuna/KunaDoctor.js +198 -0
- package/dist/kuna/KunaInstallation.js +137 -0
- package/dist/kuna/KunaJson.js +23 -0
- package/dist/kuna/KunaJsonStream.js +433 -0
- package/dist/kuna/KunaLimits.js +5 -0
- package/dist/kuna/KunaProjectCache.js +804 -0
- package/dist/kuna/KunaProjectExport.js +202 -0
- package/dist/kuna/KunaProjectFiles.js +191 -0
- package/dist/kuna/KunaProjectReader.js +115 -0
- package/dist/kuna/KunaProvider.js +217 -0
- package/dist/kuna/KunaProviderCapabilities.js +102 -0
- package/dist/kuna/KunaQueryErrors.js +12 -0
- package/dist/kuna/KunaQueryWork.js +113 -0
- package/dist/kuna/KunaReferenceFiles.js +258 -0
- package/dist/kuna/KunaReferenceQueries.js +211 -0
- package/dist/kuna/KunaRelease.js +10 -0
- package/dist/kuna/KunaRunSlots.js +56 -0
- package/dist/kuna/KunaSessionClient.js +1162 -0
- package/dist/kuna/KunaStringInventory.js +145 -0
- package/dist/kuna/KunaStringQueries.js +133 -0
- package/dist/kuna/KunaTargetCommands.js +205 -0
- package/dist/kuna/KunaUnavailable.js +11 -0
- package/dist/logger.js +14 -1
- package/dist/main/processShutdown.js +17 -0
- package/dist/main/shutdown.js +3 -0
- package/dist/main/transport.js +68 -4
- package/dist/main.js +16 -15
- package/dist/mcp/AnalysisProvider-BABWbLoM.js +38 -0
- package/dist/mcp/AnalysisSnapshotFiles-BXz0c37-.js +1423 -0
- package/dist/mcp/ArtifactFileOperation-64cQKI7B.js +1704 -0
- package/dist/mcp/ArtifactProvider-Dx6pmil1.js +2200 -0
- package/dist/mcp/ArtifactProviderMetadata-UCJr2oZW.js +167 -0
- package/dist/mcp/ArtifactReader-BrnwNaKY.js +78 -0
- package/dist/mcp/ArtifactResourceScope-zi3Dkqzy.js +175 -0
- package/dist/mcp/AsarHeader-B_IbppTz.js +31 -0
- package/dist/mcp/BinarySessionStatus-CZ9nnXMt.js +213 -0
- package/dist/mcp/BinaryTargetResolver-BUncASDP.js +1358 -0
- package/dist/mcp/BoundedFileBytes-DYt5q9G2.js +43 -0
- package/dist/mcp/CdpCaptureDocuments-Y2uFcBpl.js +795 -0
- package/dist/mcp/CdpCaptureValues-tNIg-gQK.js +97 -0
- package/dist/mcp/CdpEndpoint-BrhMhpSi.js +641 -0
- package/dist/mcp/CdpOptionalCommand-PZZhlqxv.js +120 -0
- package/dist/mcp/CdpTargetSession-BmmDC3XO.js +290 -0
- package/dist/mcp/DirectAnalysis-B9KuCHTG.js +417 -0
- package/dist/mcp/DirectAnalysisStatus-BgzopkIt.js +44 -0
- package/dist/mcp/ElectronFileScope-FXtK0d6I.js +110 -0
- package/dist/mcp/ElectronFuseFailures-uZ_wOV6T.js +610 -0
- package/dist/mcp/MachoLoadCommandReader-C2VGgHA3.js +330 -0
- package/dist/mcp/ManagedStaticProvider-CZuoPme2.js +5326 -0
- package/dist/mcp/NativeMacOSProvider-CMguKrvN.js +5495 -0
- package/dist/mcp/NativeMacOSProviderMetadata-B_RH4KXF.js +397 -0
- package/dist/mcp/OwnedCommand-BW1jBSt9.js +1241 -0
- package/dist/mcp/ProcedureAddressResolution-H6Qwpb_Y.js +59 -0
- package/dist/mcp/WorkflowEvidence-CO4C7ALz.js +118 -0
- package/dist/mcp/analysisErrorCleanup-Q344SnTO.js +34 -0
- package/dist/mcp/analysisErrorCore-BIEP7tvF.js +509 -0
- package/dist/mcp/analysisErrorProjection-B8teQwwD.js +942 -0
- package/dist/mcp/artifactToolContracts-C9dRDo-D.js +74 -0
- package/dist/mcp/browserObservation-DUraZs62.js +4633 -0
- package/dist/mcp/browserObservationError-C5okJ5el.js +63 -0
- package/dist/mcp/browserObservationSchemas-DwGGxBpu.js +573 -0
- package/dist/mcp/browserScenario-BRUz7yN0.js +3415 -0
- package/dist/mcp/browserScenarioCapture-CiMAsMx8.js +595 -0
- package/dist/mcp/callerPath-CpPnMZyN.js +678 -0
- package/dist/mcp/canonicalDigest-Bi_0_zGi.js +71 -0
- package/dist/mcp/electronActiveObservation-DV0Ffy9X.js +227 -0
- package/dist/mcp/electronFuses-D5SS7XXw.js +367 -0
- package/dist/mcp/electronObservation-DsN-NqY1.js +621 -0
- package/dist/mcp/electronObservation-wOYWwqgF.js +112 -0
- package/dist/mcp/electronScenario-CYrt2zBK.js +913 -0
- package/dist/mcp/emptyArraySchema-C0o2Sxwp.js +140 -0
- package/dist/mcp/enhancedInputs-6CCgB3VB.js +56 -0
- package/dist/mcp/javascriptRuntimeObservation-BVbhkO2-.js +693 -0
- package/dist/mcp/javascriptRuntimeObservation-Cu0Yedqq.js +121 -0
- package/dist/mcp/jsonSerialization-V-wWiFRE.js +152 -0
- package/dist/mcp/lipo-DSTgUqL1.js +395 -0
- package/dist/mcp/localPath-AxvW9aPe.js +19 -0
- package/dist/mcp/logger-BGdGHadX.js +48 -0
- package/dist/mcp/machoContainer-CMSxUBlK.js +605 -0
- package/dist/mcp/main-Cx-Z7m_n.js +80276 -0
- package/dist/mcp/main.js +6 -0
- package/dist/mcp/managedToolContracts-CSlbKJP-.js +101 -0
- package/dist/mcp/nativeValueTrace-BEZbDieM.js +3601 -0
- package/dist/mcp/officialToolContracts-CauCcSsc.js +1432 -0
- package/dist/mcp/peMachine-aP1iYnHq.js +95 -0
- package/dist/mcp/pngHeader-DQ-ObyY2.js +147 -0
- package/dist/mcp/propertyListKeys-BfCo0k4w.js +356 -0
- package/dist/mcp/providerCleanupError-DIRHxzWo.js +125 -0
- package/dist/mcp/providerIdentities--ptAh481.js +31 -0
- package/dist/mcp/providerIdentity-BCQ5n5tw.js +16 -0
- package/dist/mcp/providerOperationHealth-9DRSGM8N.js +71 -0
- package/dist/mcp/rolldown-runtime-BjeaiXFo.js +121 -0
- package/dist/mcp/safeJson-NeGfpkrI.js +25 -0
- package/dist/mcp/scanCanonical-CF3ATd1V.js +3788 -0
- package/dist/mcp/serverIdentity-BK0Ejd_Y.js +1507 -0
- package/dist/mcp/sourceMapEnvelope-DAaRUIGj.js +94 -0
- package/dist/mcp/toolContracts-BPoHQdlC.js +12414 -0
- package/dist/mcp/toolOutputSchemaGroups-MJ_f-PMK.js +17730 -0
- package/dist/mcp/webContentArtifact-DfGkgDcI.js +269 -0
- package/dist/mcp/webRuntime-ccyhkRru.js +74 -0
- package/dist/mcp/webSourceLocation-DKIum0vJ.js +13167 -0
- package/dist/mcpDoctor.js +95 -70
- package/dist/mcpStartupPolicy.js +20 -2
- package/dist/native/AppleDispatchCoverage.js +57 -17
- package/dist/native/AppleDispatchMetadata.js +82 -29
- package/dist/native/AppleMachoFixups.js +208 -35
- package/dist/native/AppleMachoSelection.js +30 -23
- package/dist/native/AppleObjcCategories.js +13 -3
- package/dist/native/AppleObjcDispatchFacets.js +95 -17
- package/dist/native/AppleObjcProperties.js +61 -17
- package/dist/native/AppleObjcProtocols.js +25 -7
- package/dist/native/AppleSwiftVtables.js +2 -0
- package/dist/native/CommandRunner.js +146 -32
- package/dist/native/LldbCallTracer.js +235 -179
- package/dist/native/LldbReadbackFiles.js +70 -0
- package/dist/native/LldbRetainedObservations.js +28 -56
- package/dist/native/MachoArchitectureSelection.js +50 -0
- package/dist/native/NativeCallObservation.js +55 -53
- package/dist/native/NativeCallTarget.js +95 -0
- package/dist/native/NativeMacOSProvider.js +318 -188
- package/dist/native/NativeMachoInspection.js +155 -81
- package/dist/native/NativePlistSource.js +179 -0
- package/dist/native/NativeUiCleanupError.js +30 -0
- package/dist/native/NativeUiHelperRuntime.js +48 -35
- package/dist/native/NativeUiObservation.js +69 -47
- package/dist/native/SignatureTargetBinding.js +147 -65
- package/dist/native/parsers/codesign.js +27 -10
- package/dist/native/parsers/demangle.js +22 -12
- package/dist/native/parsers/dyldInfo.js +73 -4
- package/dist/native/parsers/lipo.js +53 -19
- package/dist/native/parsers/machoUuid.js +150 -0
- package/dist/native/parsers/otool.js +275 -32
- package/dist/native/parsers/plist.js +40 -25
- package/dist/native/pe/PeResourceLayout.js +22 -7
- package/dist/native/pe/PeResourceParser.js +10 -9
- package/dist/native/pe/PeResourcesProvider.js +76 -15
- package/dist/native/pwndbg/CoreFileMappingAuthority.js +51 -0
- package/dist/native/pwndbg/PwndbgCoreContext.js +39 -28
- package/dist/native/pwntools/PwntoolsDecoder.js +339 -52
- package/dist/native/pwntools/PwntoolsFailures.js +19 -4
- package/dist/native/pwntools/PwntoolsInputLimit.js +27 -0
- package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +38 -16
- package/dist/native/pwntools/PwntoolsResourceLimits.js +3 -3
- package/dist/native/pwntools/RecordedCrashSourceBindings.js +12 -8
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +3 -1
- package/dist/objdump/ObjdumpCommand.js +24 -0
- package/dist/pcap/PcapCommand.js +146 -0
- package/dist/pcap/PcapConfiguration.js +93 -0
- package/dist/pcap/PcapNativeBound.js +58 -0
- package/dist/pcap/PcapOutput.js +276 -0
- package/dist/pcap/PcapProvider.js +454 -0
- package/dist/pcap/PcapSnapshot.js +191 -0
- package/dist/process/ArtifactAnalysisResources.js +306 -0
- package/dist/process/BoundedFileBytes.js +8 -3
- package/dist/process/CurrentEntrypointPath.js +8 -0
- package/dist/process/DarwinProcessRunTokenReader.js +276 -61
- package/dist/process/DetachedPgpSignature.js +57 -0
- package/dist/process/ExecFileBoundedOutput.js +44 -0
- package/dist/process/ExecFileOutput.js +44 -17
- package/dist/{hopper/HopperTargetLease.js → process/HopperLease.js} +76 -19
- package/dist/process/JavaScriptWorkerMemoryLimit.js +25 -0
- package/dist/process/LinuxResourceLimits.js +60 -0
- package/dist/process/MacCodeSignature.js +3 -0
- package/dist/process/OwnedCommand.js +144 -25
- package/dist/process/PrivateRuntimeRoot.js +9 -19
- package/dist/process/PrivateRuntimeRootUnavailableError.js +10 -0
- package/dist/process/ProcessOwnership.js +70 -17
- package/dist/process/ProcessOwnershipObservation.js +35 -4
- package/dist/process/ProviderDeadline.js +58 -12
- package/dist/process/ProviderProcess.js +233 -17
- package/dist/process/RegexMatcher.js +96 -0
- package/dist/process/SharedStartupAttempt.js +59 -0
- package/dist/process/WindowsAuthority.js +48 -39
- package/dist/process/WindowsBatchCommand.js +46 -0
- package/dist/process/boundedUtf8Text.js +13 -0
- package/dist/process/capture/FilesystemSnapshot.js +63 -11
- package/dist/process/capture/ProcessCaptureClock.js +2 -0
- package/dist/process/capture/ProcessCaptureError.js +64 -7
- package/dist/process/capture/ProcessCaptureJournal.js +2 -1
- package/dist/process/capture/ProcessCaptureLifecycle.js +104 -56
- package/dist/process/capture/ProcessCaptureProgress.js +7 -4
- package/dist/process/capture/ProcessHarness.js +34 -17
- package/dist/process/capture/ProcessNormalization.js +278 -36
- package/dist/process/capture/ProcessSampling.js +3 -2
- package/dist/process/capture/ProcessScenarioRuntimeValidation.js +13 -13
- package/dist/process/capture/TerminalRenderer.js +31 -10
- package/dist/process/ownedDebuggerSession.js +203 -0
- package/dist/process/snapshotEnvironment.js +8 -8
- package/dist/{application/binary → providers}/AnalysisClientCleanup.js +3 -3
- package/dist/providers/AnalysisClientCreation.js +193 -0
- package/dist/providers/AnalysisClientFailure.js +191 -0
- package/dist/providers/DeferredAnalysisClient.js +48 -0
- package/dist/providers/OwnedCommandCleanup.js +65 -0
- package/dist/providers/ProviderInspectionScope.js +10 -0
- package/dist/recordedCatalogDigests.js +2 -0
- package/dist/reference/ReferenceSourceReader.js +64 -1
- package/dist/reference/ReferenceSourceReaderEntries.js +79 -56
- package/dist/reference/ReferenceSourceReaderErrors.js +5 -1
- package/dist/reference/ReferenceSourceReaderFile.js +2 -2
- package/dist/reference/ReferenceSourceReaderTypes.js +1 -2
- package/dist/reference/ReferenceSourceReaderValidate.js +0 -1
- package/dist/rizin/RizinCommand.js +14 -0
- package/dist/rizin/RizinDebugSessionManager.js +1111 -0
- package/dist/rust/RustAuditableReader.js +309 -0
- package/dist/rust/RustBinaryImage.js +116 -0
- package/dist/rust/RustBinaryProvider.js +194 -0
- package/dist/server/EvidenceMcpServer.js +160 -37
- package/dist/server/admittedToolOperation.js +7 -2
- package/dist/server/contractToolHandler.js +17 -4
- package/dist/server/createServer.js +179 -30
- package/dist/server/externalMutationAdmission.js +50 -0
- package/dist/server/mcpProgress.js +4 -2
- package/dist/server/promptCompletion.js +43 -28
- package/dist/server/providerEnvironment.js +3 -0
- package/dist/server/registerAnalysisViewTool.js +6 -2
- package/dist/server/registerAndroidTools.js +22 -4
- package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +8 -1
- package/dist/server/registerArtifactComparisonTool.js +13 -2
- package/dist/server/registerArtifactTools.js +21 -1
- package/dist/server/registerBrowserScenarioTool.js +7 -5
- package/dist/server/registerBrowserTools.js +4 -8
- package/dist/server/registerBundleComparisonTool.js +4 -4
- package/dist/server/registerCaptureTools.js +12 -0
- package/dist/server/registerCutterTools.js +32 -0
- package/dist/server/registerElectronTools.js +13 -21
- package/dist/server/registerEnhancedTools.js +7 -6
- package/dist/server/registerEvidenceTools.js +14 -10
- package/dist/server/registerEvmTools.js +22 -4
- package/dist/server/registerFlutterTools.js +17 -0
- package/dist/server/registerFridaTools.js +201 -0
- package/dist/server/registerFunctionComparisonTool.js +29 -9
- package/dist/server/registerGdbTools.js +64 -0
- package/dist/server/registerGoTools.js +9 -0
- package/dist/server/registerInvestigationTools/helpers.js +2 -2
- package/dist/server/registerInvestigationTools.js +31 -27
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +3 -9
- package/dist/server/registerManagedTools.js +11 -1
- package/dist/server/registerManagedWorkflowTools/evidence.js +14 -7
- package/dist/server/registerNativeTools.js +14 -0
- package/dist/server/registerOfficialTools.js +5 -0
- package/dist/server/registerPcapTools.js +35 -0
- package/dist/server/registerProcessComparisonTool.js +12 -2
- package/dist/server/registerReverseEngineeringTools.js +86 -0
- package/dist/server/registerRizinDebugTools.js +53 -0
- package/dist/server/registerRustTools.js +9 -0
- package/dist/server/registerSessionRecordTools.js +19 -13
- package/dist/server/registerSessionStatusTool.js +33 -8
- package/dist/server/registerSessionTools.js +31 -31
- package/dist/server/registerSignalTools.js +12 -0
- package/dist/server/registerSqliteTools.js +9 -0
- package/dist/server/registerWasmTools.js +46 -0
- package/dist/server/registerWebNetworkCaptureTool.js +24 -10
- package/dist/server/retainedSummaryDelivery.js +28 -0
- package/dist/server/runDerivedOperation.js +2 -0
- package/dist/server/sessionAvailabilityPolicy.js +3 -0
- package/dist/server/toolRegistrationOptions.js +8 -0
- package/dist/server/toolResult.js +52 -19
- package/dist/server/toolResultEncoding.js +36 -3
- package/dist/serverIdentity.js +17 -8
- package/dist/signals/SigrokRecordingProvider.js +346 -0
- package/dist/signals/parseDecoderDiscovery.js +65 -0
- package/dist/sqlite/SqliteDatabaseFailures.js +147 -0
- package/dist/sqlite/SqliteDatabaseInspection.js +436 -0
- package/dist/sqlite/SqliteDatabaseLimits.js +16 -0
- package/dist/sqlite/SqliteDatabaseProvider.js +295 -0
- package/dist/sqlite/SqliteDatabaseSnapshot.js +182 -0
- package/dist/sqlite/SqliteDatabaseWorker.js +46 -0
- package/dist/sqlite/SqliteDatabaseWorkerExecution.js +127 -0
- package/dist/wasm/WabtArtifactProvider.js +358 -0
- package/dist/wasm/WabtFailures.js +119 -0
- package/dist/wasm/WabtInterface.js +309 -0
- package/dist/wasm/WabtOutput.js +60 -0
- package/dist/wasm/WabtRelease.js +12 -0
- package/dist/wasm/WabtRuntime.js +58 -0
- package/dist/wasm/WabtString.js +48 -0
- package/dist/wasm/WabtWat.js +147 -0
- package/dist/wasm/WasmGlueAdapter.js +66 -0
- package/dist/wasm/WasmInterfaceBudget.js +11 -0
- package/dist/windows/WindowsNativeLoader.js +53 -9
- package/dist/windows/WindowsOwnedProcess.js +150 -17
- package/dist/windows/WindowsPrivateRuntime.js +66 -2
- package/install.sh +157 -98
- package/licenses/Apache-2.0.txt +202 -0
- package/licenses/GCC-Runtime-Library-Exception-3.1.txt +73 -0
- package/licenses/GPL-3.0.txt +674 -0
- package/licenses/LGPL-2.0.txt +480 -0
- package/licenses/MIT-template.txt +18 -0
- package/licenses/MinGW-w64-runtime.txt +240 -0
- package/licenses/Node-22.19.0-LICENSE.txt +2666 -0
- package/licenses/README.md +68 -0
- package/licenses/cfworker-MIT.txt +21 -0
- package/licenses/dotnet-runtime-MIT.txt +23 -0
- package/licenses/frida-17.23.2-COPYING.txt +50 -0
- package/licenses/ghidra-12.1.4-DISCLAIMER.txt +13 -0
- package/licenses/ghidra-12.1.4-LICENSE.txt +201 -0
- package/licenses/ghidra-12.1.4-NOTICE.txt +49 -0
- package/licenses/npm-dependencies.txt +3757 -0
- package/licenses/npm-runtime-notices.txt +8722 -0
- package/licenses/upstream-sources.json +72 -0
- package/licenses/xterm-MIT.txt +21 -0
- package/native/windows/README.md +130 -12
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +97 -22
- package/scripts/electron-active-hook-boundaries.cjs +15 -2
- package/scripts/electron-active-hook.cjs +412 -47
- package/scripts/hopper-demo-x11.py +65 -13
- package/scripts/prepack.mjs +5 -0
- package/scripts/rea-android-workspace-guardian.mjs +46 -0
- package/scripts/rea.mjs +89 -26
- package/scripts/verify-windows-native-artifact.mjs +2 -2
- package/skills/reverse-engineer-anything/SKILL.md +146 -11
- package/skills/reverse-engineer-anything/references/android-applications.md +3 -1
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +10 -10
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +23 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +72 -3
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +149 -19
- package/skills/reverse-engineer-anything/references/runtime-observation.md +57 -7
- package/third_party/README.md +1 -1
- package/third_party/wabt/README.md +24 -0
- package/dist/browser/history/HarCaptureAdapter.js +0 -20
- package/dist/cli/streamedJsonOutput.js +0 -135
- package/dist/hopper/HopperRegexWorker.js +0 -27
- /package/dist/{application/binary → process}/AbortablePromise.js +0 -0
|
@@ -0,0 +1,3415 @@
|
|
|
1
|
+
import { t as __esmMin } from "./rolldown-runtime-BjeaiXFo.js";
|
|
2
|
+
import { A as err, D as AnalysisError, M as ok, O as init_analysisErrorBase, f as init_analysisErrorCore, i as AnalysisCancelledError, j as init_result, u as AnalysisTimeoutError } from "./analysisErrorCore-BIEP7tvF.js";
|
|
3
|
+
import { a as init_AnalysisCleanupLease, i as AnalysisCleanupLeaseGroup, n as init_providerCleanupError, r as AnalysisCleanupLease, t as ProviderCleanupError } from "./providerCleanupError-DIRHxzWo.js";
|
|
4
|
+
import { i as init_providerAdapterError, n as init_browserObservationError, r as ProviderAdapterError, t as BrowserObservationError } from "./browserObservationError-C5okJ5el.js";
|
|
5
|
+
import { n as init_analysisErrorCleanup, t as analysisErrorWithCleanupFailure } from "./analysisErrorCleanup-Q344SnTO.js";
|
|
6
|
+
import { c as init_browserObservation, d as isLiteralLoopbackHostname, m as sanitizeBrowserUrl, o as browserObservationEndpointSchema } from "./webContentArtifact-DfGkgDcI.js";
|
|
7
|
+
import { a as init_browserScenarioCaptureLimits, c as browserScenarioEventSchema, d as classifyBrowserScenarioCompleteness, f as init_browserScenarioCaptureValues, h as init_browserNetworkEvidence, l as browserScenarioStepSchema, n as init_browserScenarioCapture, p as PLAYWRIGHT_RESPONSE_BODY_PROVENANCE_LIMITATION, r as DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS, t as browserScenarioCaptureSchema, u as browserStepArtifactsSchema } from "./browserScenarioCapture-CiMAsMx8.js";
|
|
8
|
+
import { a as init_providerIdentities, r as PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY } from "./providerIdentities--ptAh481.js";
|
|
9
|
+
import { a as init_CdpEndpoint, c as withCdpDiscoveryDeadline, l as CdpConnection, u as init_CdpConnection } from "./CdpEndpoint-BrhMhpSi.js";
|
|
10
|
+
import { i as openCdpEndpoint, r as init_CdpTargetSession, t as attachCdpTargetSession } from "./CdpTargetSession-BmmDC3XO.js";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { chmod, mkdtemp, rm } from "node:fs/promises";
|
|
15
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
16
|
+
|
|
17
|
+
//#region dist/browser/PlaywrightExecutionBoundary.js
|
|
18
|
+
var OPERATION$5, PLAYWRIGHT_CLEANUP_CONFIRMATION_TIMEOUT_MS, withPlaywrightExecutionBoundary;
|
|
19
|
+
function init_PlaywrightExecutionBoundary() {
|
|
20
|
+
return (init_PlaywrightExecutionBoundary = __esmMin((() => {
|
|
21
|
+
init_analysisErrorCore();
|
|
22
|
+
OPERATION$5 = "capture_browser_scenario";
|
|
23
|
+
PLAYWRIGHT_CLEANUP_CONFIRMATION_TIMEOUT_MS = 3e4;
|
|
24
|
+
withPlaywrightExecutionBoundary = (work, timeoutMs, signal) => {
|
|
25
|
+
if (timeoutMs !== undefined && timeoutMs <= 0) return Promise.reject(new AnalysisTimeoutError(OPERATION$5, timeoutMs));
|
|
26
|
+
if (signal?.aborted === true) return Promise.reject(new AnalysisCancelledError(OPERATION$5, { cause: signal.reason }));
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
let settled = false;
|
|
29
|
+
let timer;
|
|
30
|
+
const deadline = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
|
|
31
|
+
const scheduleTimeout = () => {
|
|
32
|
+
if (deadline === undefined) return;
|
|
33
|
+
const remaining = deadline - performance.now();
|
|
34
|
+
if (remaining <= 0) {
|
|
35
|
+
fail(new AnalysisTimeoutError(OPERATION$5, timeoutMs ?? 0));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
timer = setTimeout(scheduleTimeout, Math.min(remaining, 2147483647));
|
|
39
|
+
timer.unref();
|
|
40
|
+
};
|
|
41
|
+
const cleanup = () => {
|
|
42
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
43
|
+
signal?.removeEventListener("abort", onAbort);
|
|
44
|
+
};
|
|
45
|
+
const succeed = (value) => {
|
|
46
|
+
if (settled) return;
|
|
47
|
+
settled = true;
|
|
48
|
+
cleanup();
|
|
49
|
+
resolve(value);
|
|
50
|
+
};
|
|
51
|
+
const fail = (error) => {
|
|
52
|
+
if (settled) return;
|
|
53
|
+
settled = true;
|
|
54
|
+
cleanup();
|
|
55
|
+
reject(error);
|
|
56
|
+
};
|
|
57
|
+
const onAbort = () => {
|
|
58
|
+
fail(new AnalysisCancelledError(OPERATION$5, { cause: signal?.reason }));
|
|
59
|
+
};
|
|
60
|
+
scheduleTimeout();
|
|
61
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
62
|
+
if (signal?.aborted === true) {
|
|
63
|
+
onAbort();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
void work().then(succeed, fail);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
})))();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region dist/browser/BrowserScenarioPartialObservation.js
|
|
74
|
+
var OPERATION$4, browserScenarioLimitations, browserScenarioCaptureData, browserScenarioCleanupObservation, browserScenarioOperationFailure;
|
|
75
|
+
function init_BrowserScenarioPartialObservation() {
|
|
76
|
+
return (init_BrowserScenarioPartialObservation = __esmMin((() => {
|
|
77
|
+
init_browserNetworkEvidence();
|
|
78
|
+
init_analysisErrorBase();
|
|
79
|
+
init_analysisErrorCleanup();
|
|
80
|
+
init_providerCleanupError();
|
|
81
|
+
init_providerAdapterError();
|
|
82
|
+
init_providerIdentities();
|
|
83
|
+
OPERATION$4 = "capture_browser_scenario";
|
|
84
|
+
browserScenarioLimitations = (session, scenario, events) => {
|
|
85
|
+
const capturedResponseBody = scenario.capture.network.response_body && events.some((event) => event.kind === "network-content" && event.phase === "response" && event.body.state === "captured" && (event.body.representation === "playwright-response-body-bytes" || event.body.representation === "browser-decoded-response-bytes"));
|
|
86
|
+
return [
|
|
87
|
+
"Event sequence records provider receipt order; simultaneous browser causality is not inferred.",
|
|
88
|
+
"Network content is retained only when selected; Playwright response-body bytes are API results and are not guaranteed to match wire bytes.",
|
|
89
|
+
"Request bytes are limited to what Playwright exposes; not_exposed does not establish body absence or multipart file coverage.",
|
|
90
|
+
"Network content reads settle within 5 seconds each and the observer does not request bodies from unfinished responses.",
|
|
91
|
+
...capturedResponseBody ? [PLAYWRIGHT_RESPONSE_BODY_PROVENANCE_LIMITATION] : [],
|
|
92
|
+
"Playwright scenario events do not expose request initiator stacks; receipt order does not prove causality.",
|
|
93
|
+
"Storage values are hashed only after declared-secret redaction.",
|
|
94
|
+
...scenario.storage.local_storage.length === 0 && scenario.storage.session_storage.length === 0 ? [] : ["Non-cookie storage seeds use CDP pre-script instrumentation; only pauses in the scenario's private seed script are resumed by this observer."],
|
|
95
|
+
...session.eventLimitations?.() ?? [],
|
|
96
|
+
...session.mode === "connect" ? [
|
|
97
|
+
"CDP attachment cannot recover pre-attach events or guarantee launch-time context options.",
|
|
98
|
+
`Attached locale ${scenario.environment.locale} applies to Intl formatting only; navigator.language(s) and Accept-Language remain caller-controlled. Use launch mode for matching page and request languages.`,
|
|
99
|
+
"Detaching a CDP page session may clear caller-owned navigator.platform emulation. REA cannot snapshot the caller's complete user-agent/client-hint state before attachment; use launch mode to avoid mutating that external browser."
|
|
100
|
+
] : []
|
|
101
|
+
];
|
|
102
|
+
};
|
|
103
|
+
browserScenarioCaptureData = (input) => {
|
|
104
|
+
const events = input.session.events();
|
|
105
|
+
return {
|
|
106
|
+
browser: {
|
|
107
|
+
mode: input.session.mode,
|
|
108
|
+
process_ownership: input.session.processOwnership,
|
|
109
|
+
cleanup: input.cleanup,
|
|
110
|
+
product: input.session.product,
|
|
111
|
+
version: input.session.version
|
|
112
|
+
},
|
|
113
|
+
scenario: {
|
|
114
|
+
start_origin: new URL(input.scenario.start_url.url).origin,
|
|
115
|
+
action_count: input.scenario.actions.length,
|
|
116
|
+
secret_references: input.scenario.secrets.map(({ secret_id: id }) => id).sort(),
|
|
117
|
+
network_content: input.scenario.capture.network,
|
|
118
|
+
event_families: [...new Set(input.scenario.capture.events)].sort(),
|
|
119
|
+
limits: input.scenario.capture.limits
|
|
120
|
+
},
|
|
121
|
+
duration_ms: Math.max(0, Math.round(performance.now() - input.startedAt)),
|
|
122
|
+
steps: [...input.steps],
|
|
123
|
+
events,
|
|
124
|
+
limitations: [...browserScenarioLimitations(input.session, input.scenario, events.items), ...input.limitations ?? []]
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
browserScenarioCleanupObservation = (cause) => cause instanceof AnalysisError && cause.cleanup !== undefined ? cause.cleanup : {
|
|
128
|
+
reason: cause instanceof Error ? cause.message : String(cause),
|
|
129
|
+
resources: cause instanceof AnalysisError && cause.cleanupResources.length > 0 ? cause.cleanupResources : ["browser_transport"]
|
|
130
|
+
};
|
|
131
|
+
browserScenarioOperationFailure = (cause, partialObservation, cleanupFailure) => {
|
|
132
|
+
const primary = cause instanceof AnalysisError ? cause : new ProviderAdapterError(PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id, OPERATION$4, { cause });
|
|
133
|
+
primary.retainPartialObservation(partialObservation);
|
|
134
|
+
if (cleanupFailure === undefined) return primary;
|
|
135
|
+
const observation = browserScenarioCleanupObservation(cleanupFailure.cause);
|
|
136
|
+
const cleanup = cleanupFailure.cause instanceof AnalysisError && cleanupFailure.cause.cleanupIncomplete ? cleanupFailure.cause : new ProviderCleanupError(PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id, observation.resources, { reason: observation.reason }, {
|
|
137
|
+
operation: "close_browser_scenario",
|
|
138
|
+
cause: cleanupFailure.cause
|
|
139
|
+
});
|
|
140
|
+
return analysisErrorWithCleanupFailure(primary, cleanup, OPERATION$4).bindCleanupDependencies([primary, cleanup]);
|
|
141
|
+
};
|
|
142
|
+
})))();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region dist/browser/PlaywrightBrowserScenarioProvider.js
|
|
147
|
+
var OPERATION$3, signalIsAborted, SNAPSHOT_KINDS, requestedForStep, unavailableArtifacts, stepCompleteness, createStep, initialStep, executeStep, globalCompleteness, runScenario, PlaywrightBrowserScenarioProvider;
|
|
148
|
+
function init_PlaywrightBrowserScenarioProvider() {
|
|
149
|
+
return (init_PlaywrightBrowserScenarioProvider = __esmMin((() => {
|
|
150
|
+
init_PlaywrightExecutionBoundary();
|
|
151
|
+
init_analysisErrorCleanup();
|
|
152
|
+
init_AnalysisCleanupLease();
|
|
153
|
+
init_providerCleanupError();
|
|
154
|
+
init_browserScenarioCapture();
|
|
155
|
+
init_browserScenarioCaptureValues();
|
|
156
|
+
init_analysisErrorBase();
|
|
157
|
+
init_analysisErrorCore();
|
|
158
|
+
init_browserObservationError();
|
|
159
|
+
init_providerAdapterError();
|
|
160
|
+
init_result();
|
|
161
|
+
init_BrowserScenarioPartialObservation();
|
|
162
|
+
init_providerIdentities();
|
|
163
|
+
OPERATION$3 = "capture_browser_scenario";
|
|
164
|
+
signalIsAborted = (signal) => signal?.aborted === true;
|
|
165
|
+
SNAPSHOT_KINDS = [
|
|
166
|
+
"screenshot",
|
|
167
|
+
"dom",
|
|
168
|
+
"accessibility",
|
|
169
|
+
"url",
|
|
170
|
+
"history",
|
|
171
|
+
"storage"
|
|
172
|
+
];
|
|
173
|
+
requestedForStep = (scenario, stepIndex) => new Set([...scenario.capture.after_each_step, ...stepIndex === scenario.actions.length ? scenario.capture.at_end : []]);
|
|
174
|
+
unavailableArtifacts = (requested, reason) => {
|
|
175
|
+
const state = (kind) => requested.has(kind) ? {
|
|
176
|
+
state: "missing",
|
|
177
|
+
reason
|
|
178
|
+
} : { state: "not_requested" };
|
|
179
|
+
return browserStepArtifactsSchema.parse({
|
|
180
|
+
screenshot: state("screenshot"),
|
|
181
|
+
dom: state("dom"),
|
|
182
|
+
accessibility: state("accessibility"),
|
|
183
|
+
url: state("url"),
|
|
184
|
+
history: state("history"),
|
|
185
|
+
storage: state("storage")
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
stepCompleteness = (artifacts, status) => {
|
|
189
|
+
const missing = SNAPSHOT_KINDS.filter((section) => artifacts[section].state === "missing");
|
|
190
|
+
const truncated = SNAPSHOT_KINDS.filter((section) => artifacts[section].state === "truncated");
|
|
191
|
+
if (status !== "completed") missing.push("action");
|
|
192
|
+
return classifyBrowserScenarioCompleteness(missing, truncated);
|
|
193
|
+
};
|
|
194
|
+
createStep = (input) => browserScenarioStepSchema.parse({
|
|
195
|
+
step_index: input.stepIndex,
|
|
196
|
+
step_id: input.stepId,
|
|
197
|
+
action: input.action,
|
|
198
|
+
status: input.status,
|
|
199
|
+
elapsed_ms: input.elapsedMs,
|
|
200
|
+
before_url: input.beforeUrl,
|
|
201
|
+
after_url: input.afterUrl,
|
|
202
|
+
error: input.error,
|
|
203
|
+
event_sequence_start: input.eventStart,
|
|
204
|
+
event_sequence_end: input.eventEnd,
|
|
205
|
+
artifacts: input.artifacts,
|
|
206
|
+
completeness: stepCompleteness(input.artifacts, input.status)
|
|
207
|
+
});
|
|
208
|
+
initialStep = async (input) => {
|
|
209
|
+
const { session, scenario, elapsedMs, signal } = input;
|
|
210
|
+
const artifacts = await session.capture(requestedForStep(scenario, 0), signal);
|
|
211
|
+
return createStep({
|
|
212
|
+
stepIndex: 0,
|
|
213
|
+
stepId: "scenario_start",
|
|
214
|
+
action: "goto_start",
|
|
215
|
+
status: "completed",
|
|
216
|
+
elapsedMs,
|
|
217
|
+
beforeUrl: session.sanitizeUrl(session.initialUrl),
|
|
218
|
+
afterUrl: session.sanitizeUrl(session.currentUrl()),
|
|
219
|
+
error: null,
|
|
220
|
+
eventStart: 1,
|
|
221
|
+
eventEnd: session.lastEventSequence(),
|
|
222
|
+
artifacts
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
executeStep = async (input) => {
|
|
226
|
+
const { session, scenario, action, stepIndex, priorFailure, signal } = input;
|
|
227
|
+
const beforeUrl = session.sanitizeUrl(session.currentUrl());
|
|
228
|
+
const eventStart = session.nextEventSequence();
|
|
229
|
+
const requested = requestedForStep(scenario, stepIndex);
|
|
230
|
+
if (priorFailure) return createStep({
|
|
231
|
+
stepIndex,
|
|
232
|
+
stepId: action.step_id,
|
|
233
|
+
action: action.action,
|
|
234
|
+
status: "cancelled",
|
|
235
|
+
elapsedMs: 0,
|
|
236
|
+
beforeUrl,
|
|
237
|
+
afterUrl: beforeUrl,
|
|
238
|
+
error: "not executed after an earlier action failure",
|
|
239
|
+
eventStart,
|
|
240
|
+
eventEnd: session.lastEventSequence(),
|
|
241
|
+
artifacts: unavailableArtifacts(requested, "action was not executed after an earlier failure")
|
|
242
|
+
});
|
|
243
|
+
const actionStartedAt = performance.now();
|
|
244
|
+
session.setStep(stepIndex);
|
|
245
|
+
const requestCancelled = () => signal?.aborted === true;
|
|
246
|
+
let outcome = {
|
|
247
|
+
status: "completed",
|
|
248
|
+
error: null
|
|
249
|
+
};
|
|
250
|
+
if (requestCancelled()) {
|
|
251
|
+
outcome = {
|
|
252
|
+
status: "cancelled",
|
|
253
|
+
error: "scenario request cancelled"
|
|
254
|
+
};
|
|
255
|
+
} else {
|
|
256
|
+
try {
|
|
257
|
+
await session.perform(action, signal);
|
|
258
|
+
} catch (cause) {
|
|
259
|
+
outcome = {
|
|
260
|
+
status: requestCancelled() ? "cancelled" : "failed",
|
|
261
|
+
error: session.redactError(cause)
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const artifacts = outcome.status === "cancelled" ? unavailableArtifacts(requested, "scenario request cancelled") : await session.capture(requested, signal);
|
|
266
|
+
return createStep({
|
|
267
|
+
stepIndex,
|
|
268
|
+
stepId: action.step_id,
|
|
269
|
+
action: action.action,
|
|
270
|
+
...outcome,
|
|
271
|
+
elapsedMs: Math.max(0, Math.round(performance.now() - actionStartedAt)),
|
|
272
|
+
beforeUrl,
|
|
273
|
+
afterUrl: session.sanitizeUrl(session.currentUrl()),
|
|
274
|
+
eventStart,
|
|
275
|
+
eventEnd: session.lastEventSequence(),
|
|
276
|
+
artifacts
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
globalCompleteness = (scenario, session, steps) => {
|
|
280
|
+
const missing = steps.flatMap(({ completeness }) => completeness.missing_sections);
|
|
281
|
+
const truncated = steps.flatMap(({ completeness }) => completeness.truncated_sections);
|
|
282
|
+
if (session.mode === "connect") missing.push("events");
|
|
283
|
+
if ((session.eventLimitations?.().length ?? 0) > 0) missing.push("events");
|
|
284
|
+
return classifyBrowserScenarioCompleteness(missing, truncated);
|
|
285
|
+
};
|
|
286
|
+
runScenario = async (openSession, scenario, options, retainCleanup) => {
|
|
287
|
+
if (options.signal?.aborted) throw new BrowserObservationError(OPERATION$3, "cancelled", { cause: options.signal.reason });
|
|
288
|
+
const startedAt = performance.now();
|
|
289
|
+
const session = await openSession(scenario, {
|
|
290
|
+
...options.signal === undefined ? {} : { signal: options.signal },
|
|
291
|
+
retainCleanup
|
|
292
|
+
});
|
|
293
|
+
const steps = [];
|
|
294
|
+
let operationOutcome = { ok: true };
|
|
295
|
+
try {
|
|
296
|
+
steps.push(await initialStep({
|
|
297
|
+
session,
|
|
298
|
+
scenario,
|
|
299
|
+
elapsedMs: Math.max(0, Math.round(performance.now() - startedAt)),
|
|
300
|
+
signal: options.signal
|
|
301
|
+
}));
|
|
302
|
+
let failed = false;
|
|
303
|
+
for (const [offset, action] of scenario.actions.entries()) {
|
|
304
|
+
const step = await executeStep({
|
|
305
|
+
session,
|
|
306
|
+
scenario,
|
|
307
|
+
action,
|
|
308
|
+
stepIndex: offset + 1,
|
|
309
|
+
priorFailure: failed,
|
|
310
|
+
signal: options.signal
|
|
311
|
+
});
|
|
312
|
+
steps.push(step);
|
|
313
|
+
failed ||= step.status !== "completed";
|
|
314
|
+
}
|
|
315
|
+
} catch (cause) {
|
|
316
|
+
operationOutcome = {
|
|
317
|
+
ok: false,
|
|
318
|
+
cause
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
let cleanupOutcome;
|
|
322
|
+
try {
|
|
323
|
+
cleanupOutcome = {
|
|
324
|
+
ok: true,
|
|
325
|
+
cleanup: await session.close()
|
|
326
|
+
};
|
|
327
|
+
} catch (cause) {
|
|
328
|
+
const cleanup = browserScenarioCleanupObservation(cause);
|
|
329
|
+
const failure = new BrowserObservationError(OPERATION$3, "cleanup_failed", {
|
|
330
|
+
cause,
|
|
331
|
+
cleanup
|
|
332
|
+
});
|
|
333
|
+
retainCleanup(session.cleanupLease);
|
|
334
|
+
new AnalysisCleanupLeaseGroup(failure, [session.cleanupLease]);
|
|
335
|
+
cleanupOutcome = {
|
|
336
|
+
ok: false,
|
|
337
|
+
cause: failure
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
if (!cleanupOutcome.ok) {
|
|
341
|
+
if (operationOutcome.ok && options.signal?.aborted) operationOutcome = {
|
|
342
|
+
ok: false,
|
|
343
|
+
cause: new AnalysisCancelledError(OPERATION$3, { cause: options.signal.reason })
|
|
344
|
+
};
|
|
345
|
+
const cleanup = browserScenarioCleanupObservation(cleanupOutcome.cause);
|
|
346
|
+
const partialObservation = {
|
|
347
|
+
kind: "browser-scenario-observation",
|
|
348
|
+
capture: browserScenarioCaptureData({
|
|
349
|
+
session,
|
|
350
|
+
scenario,
|
|
351
|
+
startedAt,
|
|
352
|
+
steps,
|
|
353
|
+
cleanup: "incomplete",
|
|
354
|
+
limitations: ["Scenario observations are partial because browser cleanup could not be confirmed."]
|
|
355
|
+
})
|
|
356
|
+
};
|
|
357
|
+
if (!operationOutcome.ok) throw browserScenarioOperationFailure(operationOutcome.cause, partialObservation, { cause: cleanupOutcome.cause });
|
|
358
|
+
const failure = new BrowserObservationError(OPERATION$3, "cleanup_failed", {
|
|
359
|
+
cause: cleanupOutcome.cause,
|
|
360
|
+
cleanup,
|
|
361
|
+
partialObservation,
|
|
362
|
+
detail: `Browser scenario cleanup could not be confirmed: ${cleanup.reason}. Collected steps and events are retained in partial_observation. Review the reported resources before retrying.`
|
|
363
|
+
});
|
|
364
|
+
if (cleanupOutcome.cause instanceof AnalysisError && cleanupOutcome.cause.cleanupIncomplete) failure.bindCleanupDependencies([cleanupOutcome.cause]);
|
|
365
|
+
throw failure;
|
|
366
|
+
}
|
|
367
|
+
if (!operationOutcome.ok) throw browserScenarioOperationFailure(operationOutcome.cause, {
|
|
368
|
+
kind: "browser-scenario-observation",
|
|
369
|
+
capture: browserScenarioCaptureData({
|
|
370
|
+
session,
|
|
371
|
+
scenario,
|
|
372
|
+
startedAt,
|
|
373
|
+
steps,
|
|
374
|
+
cleanup: cleanupOutcome.cleanup,
|
|
375
|
+
limitations: ["Scenario capture ended after an operation failed; uncollected steps are not represented."]
|
|
376
|
+
})
|
|
377
|
+
});
|
|
378
|
+
const completeness = globalCompleteness(scenario, session, steps);
|
|
379
|
+
const capture = browserScenarioCaptureSchema.parse({
|
|
380
|
+
...browserScenarioCaptureData({
|
|
381
|
+
session,
|
|
382
|
+
scenario,
|
|
383
|
+
startedAt,
|
|
384
|
+
steps,
|
|
385
|
+
cleanup: cleanupOutcome.cleanup
|
|
386
|
+
}),
|
|
387
|
+
completeness
|
|
388
|
+
});
|
|
389
|
+
if (signalIsAborted(options.signal)) throw new AnalysisCancelledError(OPERATION$3, {
|
|
390
|
+
cause: options.signal?.reason,
|
|
391
|
+
partialObservation: {
|
|
392
|
+
kind: "browser-scenario-observation",
|
|
393
|
+
capture: {
|
|
394
|
+
...capture,
|
|
395
|
+
limitations: [...capture.limitations, "Scenario capture was cancelled; collected steps, observations, and cleanup state are retained."]
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return capture;
|
|
400
|
+
};
|
|
401
|
+
PlaywrightBrowserScenarioProvider = class {
|
|
402
|
+
openSession;
|
|
403
|
+
#tail = Promise.resolve();
|
|
404
|
+
#closing = false;
|
|
405
|
+
#closePromise;
|
|
406
|
+
#pendingCleanup = new Set();
|
|
407
|
+
constructor(openSession) {
|
|
408
|
+
this.openSession = openSession;
|
|
409
|
+
}
|
|
410
|
+
identity() {
|
|
411
|
+
return PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY;
|
|
412
|
+
}
|
|
413
|
+
captureScenario(scenario, options = {}) {
|
|
414
|
+
if (this.#closing) return Promise.resolve(err(this.#closedError()));
|
|
415
|
+
const operation = this.#tail.then(() => this.#closing ? err(this.#closedError()) : this.#captureScenario(scenario, options));
|
|
416
|
+
this.#tail = operation.then(() => undefined, () => undefined);
|
|
417
|
+
return operation;
|
|
418
|
+
}
|
|
419
|
+
async #captureScenario(scenario, options) {
|
|
420
|
+
const pending = await this.#retryCleanup();
|
|
421
|
+
if (pending !== undefined) return err(pending);
|
|
422
|
+
const retained = [];
|
|
423
|
+
try {
|
|
424
|
+
return ok(await runScenario(this.openSession, scenario, options, (lease) => {
|
|
425
|
+
this.#pendingCleanup.add(lease);
|
|
426
|
+
retained.push(lease);
|
|
427
|
+
}));
|
|
428
|
+
} catch (cause) {
|
|
429
|
+
const primary = cause instanceof AnalysisError ? cause : new ProviderAdapterError(PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id, OPERATION$3, { cause });
|
|
430
|
+
if (retained.length === 0) return err(primary);
|
|
431
|
+
const cleanup = new ProviderCleanupError(PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id, retained.flatMap((lease) => lease.cleanupResources ?? []), { reason: "Browser scenario cleanup capabilities remain retained." }, {
|
|
432
|
+
operation: OPERATION$3,
|
|
433
|
+
cause
|
|
434
|
+
});
|
|
435
|
+
new AnalysisCleanupLeaseGroup(cleanup, retained);
|
|
436
|
+
return err(analysisErrorWithCleanupFailure(primary, cleanup, OPERATION$3).bindCleanupDependencies([primary, cleanup]));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
async close() {
|
|
440
|
+
this.#closing = true;
|
|
441
|
+
this.#closePromise ??= this.#tail.then(async () => {
|
|
442
|
+
const failure = await this.#retryCleanup();
|
|
443
|
+
if (failure !== undefined) throw failure;
|
|
444
|
+
}).catch((cause) => {
|
|
445
|
+
this.#closePromise = undefined;
|
|
446
|
+
throw cause;
|
|
447
|
+
});
|
|
448
|
+
return this.#closePromise;
|
|
449
|
+
}
|
|
450
|
+
#closedError() {
|
|
451
|
+
return new BrowserObservationError(OPERATION$3, "cleanup_failed", {
|
|
452
|
+
detail: "Browser scenario provider is closing.",
|
|
453
|
+
cleanup: {
|
|
454
|
+
reason: "Provider is closing",
|
|
455
|
+
resources: []
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
async #retryCleanup() {
|
|
460
|
+
const failures = [];
|
|
461
|
+
for (const pending of this.#pendingCleanup) {
|
|
462
|
+
try {
|
|
463
|
+
await withPlaywrightExecutionBoundary(() => pending.release(), PLAYWRIGHT_CLEANUP_CONFIRMATION_TIMEOUT_MS);
|
|
464
|
+
this.#pendingCleanup.delete(pending);
|
|
465
|
+
} catch (cause) {
|
|
466
|
+
const failure = new ProviderCleanupError(PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id, pending.cleanupResources ?? [], { reason: cause instanceof Error ? cause.message : String(cause) }, {
|
|
467
|
+
operation: OPERATION$3,
|
|
468
|
+
cause
|
|
469
|
+
});
|
|
470
|
+
new AnalysisCleanupLeaseGroup(failure, [pending]);
|
|
471
|
+
failures.push(failure);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (failures.length === 0) return undefined;
|
|
475
|
+
if (failures.length === 1) return failures[0];
|
|
476
|
+
return new ProviderCleanupError(PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id, failures.flatMap((failure) => failure.cleanupResources), { reason: "One or more browser scenario resources remain owned." }, {
|
|
477
|
+
operation: OPERATION$3,
|
|
478
|
+
cause: new AggregateError(failures, "Browser scenario cleanup failed")
|
|
479
|
+
}).bindCleanupDependencies(failures);
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
})))();
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region dist/browser/BrowserScenarioSecrets.js
|
|
487
|
+
var REDACTION_PREFIX, encodedSecretValues, normalizePercentEscapes, secretPatterns, declaredPatterns, secretReplacements, normalizePercentEscapesBytes, isHexByte, lowercaseHexByte, patternMatches, containsSecretPattern, containsSecretBytePattern, redactionMarker, replaceSecretLiterals, secretNeedles, BrowserScenarioSecrets;
|
|
488
|
+
function init_BrowserScenarioSecrets() {
|
|
489
|
+
return (init_BrowserScenarioSecrets = __esmMin((() => {
|
|
490
|
+
init_browserObservation();
|
|
491
|
+
REDACTION_PREFIX = "[REDACTED:";
|
|
492
|
+
encodedSecretValues = (secret) => new Set([encodeURIComponent(secret), new URLSearchParams([["value", secret]]).toString().slice("value=".length)]);
|
|
493
|
+
normalizePercentEscapes = (value) => {
|
|
494
|
+
if (!value.includes("%")) return value;
|
|
495
|
+
return value.replace(/%[0-9a-f]{2}/giu, (escape) => escape.toLowerCase());
|
|
496
|
+
};
|
|
497
|
+
secretPatterns = (secret, spellings) => {
|
|
498
|
+
if (secret === "") return [];
|
|
499
|
+
const patterns = [{
|
|
500
|
+
text: secret,
|
|
501
|
+
searchText: secret,
|
|
502
|
+
percentInsensitive: false
|
|
503
|
+
}, ...[...encodedSecretValues(secret)].map((text) => ({
|
|
504
|
+
text,
|
|
505
|
+
searchText: normalizePercentEscapes(text),
|
|
506
|
+
percentInsensitive: true
|
|
507
|
+
}))];
|
|
508
|
+
if (spellings === "text") patterns.push({
|
|
509
|
+
text: JSON.stringify(secret).slice(1, -1),
|
|
510
|
+
searchText: JSON.stringify(secret).slice(1, -1),
|
|
511
|
+
percentInsensitive: false
|
|
512
|
+
});
|
|
513
|
+
const seen = new Set();
|
|
514
|
+
return patterns.filter(({ text, percentInsensitive }) => {
|
|
515
|
+
if (text === "") return false;
|
|
516
|
+
const key = `${percentInsensitive ? "percent" : "literal"}:${text}`;
|
|
517
|
+
if (seen.has(key)) return false;
|
|
518
|
+
seen.add(key);
|
|
519
|
+
return true;
|
|
520
|
+
});
|
|
521
|
+
};
|
|
522
|
+
declaredPatterns = (values, spellings) => {
|
|
523
|
+
const seen = new Set();
|
|
524
|
+
return [...values.values()].flatMap((secret) => secretPatterns(secret, spellings)).filter(({ text, percentInsensitive }) => {
|
|
525
|
+
const key = `${percentInsensitive ? "percent" : "literal"}:${text}`;
|
|
526
|
+
if (seen.has(key)) return false;
|
|
527
|
+
seen.add(key);
|
|
528
|
+
return true;
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
secretReplacements = (values, spellings) => [...values].flatMap(([id, secret]) => secretPatterns(secret, spellings).map((pattern) => ({
|
|
532
|
+
id,
|
|
533
|
+
...pattern
|
|
534
|
+
}))).sort((left, right) => right.text.length - left.text.length || (left.id < right.id ? -1 : left.id > right.id ? 1 : 0));
|
|
535
|
+
normalizePercentEscapesBytes = (value) => {
|
|
536
|
+
if (value.indexOf(37) < 0) return value;
|
|
537
|
+
const normalized = Buffer.from(value);
|
|
538
|
+
for (let index = 0; index + 2 < normalized.length; index += 1) if (normalized[index] === 37 && isHexByte(normalized[index + 1]) && isHexByte(normalized[index + 2])) {
|
|
539
|
+
normalized[index + 1] = lowercaseHexByte(normalized[index + 1]);
|
|
540
|
+
normalized[index + 2] = lowercaseHexByte(normalized[index + 2]);
|
|
541
|
+
index += 2;
|
|
542
|
+
}
|
|
543
|
+
return normalized;
|
|
544
|
+
};
|
|
545
|
+
isHexByte = (value) => value !== undefined && (value >= 48 && value <= 57 || value >= 65 && value <= 70 || value >= 97 && value <= 102);
|
|
546
|
+
lowercaseHexByte = (value) => value >= 65 && value <= 70 ? value + 32 : value;
|
|
547
|
+
patternMatches = (value, normalizedValue, pattern) => (pattern.percentInsensitive ? normalizedValue : value).includes(pattern.searchText);
|
|
548
|
+
containsSecretPattern = (value, normalizedValue, patterns) => {
|
|
549
|
+
if (patterns.length === 0) return false;
|
|
550
|
+
return patterns.some((pattern) => patternMatches(value, normalizedValue, pattern));
|
|
551
|
+
};
|
|
552
|
+
containsSecretBytePattern = (value, normalizedValue, needles) => needles.some((needle) => (needle.percentInsensitive ? normalizedValue : value).includes(needle.needle));
|
|
553
|
+
redactionMarker = (id, patterns) => {
|
|
554
|
+
const candidates = [
|
|
555
|
+
`${REDACTION_PREFIX}${id}]`,
|
|
556
|
+
"[REDACTED]",
|
|
557
|
+
"…",
|
|
558
|
+
""
|
|
559
|
+
];
|
|
560
|
+
return candidates.find((candidate) => patterns.every((pattern) => !patternMatches(candidate, normalizePercentEscapes(candidate), pattern))) ?? "";
|
|
561
|
+
};
|
|
562
|
+
replaceSecretLiterals = (value, replacements, patterns) => {
|
|
563
|
+
const normalizedValue = replacements.some(({ percentInsensitive }) => percentInsensitive) ? normalizePercentEscapes(value) : value;
|
|
564
|
+
const parts = [];
|
|
565
|
+
let offset = 0;
|
|
566
|
+
while (offset < value.length) {
|
|
567
|
+
let next;
|
|
568
|
+
for (const replacement of replacements) {
|
|
569
|
+
const search = replacement.searchText;
|
|
570
|
+
const view = replacement.percentInsensitive ? normalizedValue : value;
|
|
571
|
+
const index = view.indexOf(search, offset);
|
|
572
|
+
if (index >= 0 && (next === undefined || index < next.index || index === next.index && replacement.text.length > next.text.length)) next = {
|
|
573
|
+
...replacement,
|
|
574
|
+
index
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (next === undefined) break;
|
|
578
|
+
const marker = redactionMarker(next.id, patterns);
|
|
579
|
+
parts.push(value.slice(offset, next.index), marker);
|
|
580
|
+
offset = next.index + next.text.length;
|
|
581
|
+
}
|
|
582
|
+
if (parts.length === 0) return value;
|
|
583
|
+
parts.push(value.slice(offset));
|
|
584
|
+
return parts.join("");
|
|
585
|
+
};
|
|
586
|
+
secretNeedles = (replacements, patterns) => replacements.map((pattern) => ({
|
|
587
|
+
id: pattern.id,
|
|
588
|
+
needle: Buffer.from(pattern.searchText),
|
|
589
|
+
percentInsensitive: pattern.percentInsensitive,
|
|
590
|
+
marker: Buffer.from(redactionMarker(pattern.id, patterns))
|
|
591
|
+
}));
|
|
592
|
+
BrowserScenarioSecrets = class BrowserScenarioSecrets {
|
|
593
|
+
values;
|
|
594
|
+
urlPatterns;
|
|
595
|
+
textPatterns;
|
|
596
|
+
urlReplacements;
|
|
597
|
+
textReplacements;
|
|
598
|
+
textNeedles;
|
|
599
|
+
redactionCostPerCharacter;
|
|
600
|
+
constructor(values) {
|
|
601
|
+
this.values = values;
|
|
602
|
+
this.urlPatterns = declaredPatterns(values, "url");
|
|
603
|
+
this.textPatterns = declaredPatterns(values, "text");
|
|
604
|
+
this.urlReplacements = secretReplacements(values, "url");
|
|
605
|
+
this.textReplacements = secretReplacements(values, "text");
|
|
606
|
+
this.textNeedles = secretNeedles(this.textReplacements, this.textPatterns);
|
|
607
|
+
this.redactionCostPerCharacter = 8;
|
|
608
|
+
for (const [replacements, patterns] of [[this.textReplacements, this.textPatterns], [this.urlReplacements, this.urlPatterns]]) for (const replacement of replacements) this.redactionCostPerCharacter = Math.max(this.redactionCostPerCharacter, 8 + (Buffer.byteLength(redactionMarker(replacement.id, patterns)) * 8 + 128) / replacement.text.length);
|
|
609
|
+
}
|
|
610
|
+
static resolve(scenario, environment) {
|
|
611
|
+
const values = new Map();
|
|
612
|
+
for (const declaration of scenario.secrets) {
|
|
613
|
+
const value = environment[declaration.environment_variable];
|
|
614
|
+
if (!Object.hasOwn(environment, declaration.environment_variable) || typeof value !== "string") return undefined;
|
|
615
|
+
values.set(declaration.secret_id, value);
|
|
616
|
+
}
|
|
617
|
+
return new BrowserScenarioSecrets(values);
|
|
618
|
+
}
|
|
619
|
+
value(source) {
|
|
620
|
+
if (source.source === "literal") return source.value;
|
|
621
|
+
const value = this.values.get(source.secret_id);
|
|
622
|
+
if (value === undefined) throw new Error("Validated browser secret was not resolved");
|
|
623
|
+
return value;
|
|
624
|
+
}
|
|
625
|
+
url(destination) {
|
|
626
|
+
const url = new URL(destination.url);
|
|
627
|
+
for (const { name, value } of destination.query) url.searchParams.append(name, this.value(value));
|
|
628
|
+
return url.href;
|
|
629
|
+
}
|
|
630
|
+
/** Conservative preflight for output expansion and per-match part arrays.
|
|
631
|
+
* Callers measuring untrusted observations must reserve this cost before
|
|
632
|
+
* invoking redaction. A one-byte secret can otherwise expand every byte.
|
|
633
|
+
*/
|
|
634
|
+
redactionAllocationCost(length) {
|
|
635
|
+
return Math.ceil(length * this.redactionCostPerCharacter);
|
|
636
|
+
}
|
|
637
|
+
redact(value) {
|
|
638
|
+
const patterns = this.textPatterns;
|
|
639
|
+
if (patterns.length === 0) return value;
|
|
640
|
+
const output = replaceSecretLiterals(value, this.textReplacements, patterns);
|
|
641
|
+
return containsSecretPattern(output, normalizePercentEscapes(output), patterns) ? "" : output;
|
|
642
|
+
}
|
|
643
|
+
/** Replace declared UTF-8, URI/form, and JSON-escaped secret spellings. */
|
|
644
|
+
redactBytes(value) {
|
|
645
|
+
const patterns = this.textPatterns;
|
|
646
|
+
if (patterns.length === 0) return value;
|
|
647
|
+
const candidates = this.textNeedles;
|
|
648
|
+
const hasPercentPatterns = candidates.some(({ percentInsensitive }) => percentInsensitive);
|
|
649
|
+
const normalizedValue = hasPercentPatterns && value.indexOf(37) >= 0 ? normalizePercentEscapesBytes(value) : value;
|
|
650
|
+
const sortedCandidates = candidates.map((candidate) => ({
|
|
651
|
+
...candidate,
|
|
652
|
+
index: (candidate.percentInsensitive ? normalizedValue : value).indexOf(candidate.needle)
|
|
653
|
+
})).sort((left, right) => right.needle.length - left.needle.length || (left.id < right.id ? -1 : left.id > right.id ? 1 : 0));
|
|
654
|
+
const parts = [];
|
|
655
|
+
let offset = 0;
|
|
656
|
+
while (true) {
|
|
657
|
+
let next;
|
|
658
|
+
for (const candidate of sortedCandidates) {
|
|
659
|
+
if (candidate.index >= 0 && candidate.index < offset) candidate.index = (candidate.percentInsensitive ? normalizedValue : value).indexOf(candidate.needle, offset);
|
|
660
|
+
if (candidate.index >= 0 && (next === undefined || candidate.index < next.index || candidate.index === next.index && candidate.needle.length > next.needle.length)) next = candidate;
|
|
661
|
+
}
|
|
662
|
+
if (next === undefined) break;
|
|
663
|
+
parts.push(value.subarray(offset, next.index), next.marker);
|
|
664
|
+
offset = next.index + next.needle.length;
|
|
665
|
+
}
|
|
666
|
+
if (parts.length === 0) return value;
|
|
667
|
+
parts.push(value.subarray(offset));
|
|
668
|
+
const redacted = Buffer.concat(parts);
|
|
669
|
+
const normalizedRedacted = hasPercentPatterns && redacted.indexOf(37) >= 0 ? normalizePercentEscapesBytes(redacted) : redacted;
|
|
670
|
+
return containsSecretBytePattern(redacted, normalizedRedacted, candidates) ? Buffer.alloc(0) : redacted;
|
|
671
|
+
}
|
|
672
|
+
/** Remove only declared secret values from one URL and report that action. */
|
|
673
|
+
sanitizeUrl(value) {
|
|
674
|
+
const patterns = this.urlPatterns;
|
|
675
|
+
if (patterns.length === 0) return sanitizeBrowserUrl(value);
|
|
676
|
+
const output = replaceSecretLiterals(value, this.urlReplacements, patterns);
|
|
677
|
+
if (containsSecretPattern(output, normalizePercentEscapes(output), patterns)) return {
|
|
678
|
+
url: "",
|
|
679
|
+
origin: null,
|
|
680
|
+
query_parameter_names: [],
|
|
681
|
+
redacted: true
|
|
682
|
+
};
|
|
683
|
+
const sanitized = sanitizeBrowserUrl(output);
|
|
684
|
+
return {
|
|
685
|
+
...sanitized,
|
|
686
|
+
redacted: sanitized.redacted || output !== value
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
fingerprint(value) {
|
|
690
|
+
const patterns = this.textPatterns;
|
|
691
|
+
if (patterns.length > 0 && containsSecretPattern(value, normalizePercentEscapes(value), patterns)) return {
|
|
692
|
+
value_state: "redacted-secret",
|
|
693
|
+
value_sha256: null
|
|
694
|
+
};
|
|
695
|
+
return {
|
|
696
|
+
value_state: "hashed",
|
|
697
|
+
value_sha256: createHash("sha256").update(value).digest("hex")
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
})))();
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region dist/browser/PlaywrightScenarioBrowser.js
|
|
706
|
+
var OPERATION$2, throwIfScenarioCancelled$1, PlaywrightScenarioBrowserCleanupOwner, attachedScenarioAdmissions, releaseAttachedScenario, createAttachedScenarioRelease, attachedScenarioLeaseKey, acquireAttachedScenario, allowedBrowserEnvironment, findConnectedPage, AttachedScenarioEnvironmentOwner, failBrowserScenarioOperation, openAttachedScenarioBrowser, openPlaywrightScenarioBrowser;
|
|
707
|
+
function init_PlaywrightScenarioBrowser() {
|
|
708
|
+
return (init_PlaywrightScenarioBrowser = __esmMin((() => {
|
|
709
|
+
init_providerIdentities();
|
|
710
|
+
init_analysisErrorCleanup();
|
|
711
|
+
init_providerAdapterError();
|
|
712
|
+
init_AnalysisCleanupLease();
|
|
713
|
+
init_analysisErrorBase();
|
|
714
|
+
init_browserObservation();
|
|
715
|
+
init_browserObservationError();
|
|
716
|
+
init_PlaywrightExecutionBoundary();
|
|
717
|
+
OPERATION$2 = "capture_browser_scenario";
|
|
718
|
+
throwIfScenarioCancelled$1 = (signal) => {
|
|
719
|
+
if (signal?.aborted === true) throw new BrowserObservationError(OPERATION$2, "cancelled", { cause: signal?.reason });
|
|
720
|
+
};
|
|
721
|
+
PlaywrightScenarioBrowserCleanupOwner = class {
|
|
722
|
+
resources;
|
|
723
|
+
#browserClosed = false;
|
|
724
|
+
#profileRemoved;
|
|
725
|
+
#eventFinalizationPromise;
|
|
726
|
+
#eventsFinalized = false;
|
|
727
|
+
cleanupLease;
|
|
728
|
+
/** Keep the narrow provider actions needed to release one opened browser. */
|
|
729
|
+
constructor(resources) {
|
|
730
|
+
this.resources = resources;
|
|
731
|
+
this.#profileRemoved = resources.removeProfile === undefined;
|
|
732
|
+
this.cleanupLease = new AnalysisCleanupLease(() => this.#closeResources().finally(() => this.resources.onSettled?.(this.#browserClosed)), this);
|
|
733
|
+
}
|
|
734
|
+
get browserClosed() {
|
|
735
|
+
return this.#browserClosed;
|
|
736
|
+
}
|
|
737
|
+
get cleanupResources() {
|
|
738
|
+
return [
|
|
739
|
+
...!this.#eventsFinalized ? ["browser_events"] : [],
|
|
740
|
+
...!this.#browserClosed ? ["browser_transport"] : [],
|
|
741
|
+
...!this.#profileRemoved ? ["browser_profile"] : []
|
|
742
|
+
];
|
|
743
|
+
}
|
|
744
|
+
/** Await actual resource release, including a late browser acknowledgement. */
|
|
745
|
+
release(finishEvents) {
|
|
746
|
+
this.#prepareEvents(finishEvents);
|
|
747
|
+
return this.cleanupLease.release();
|
|
748
|
+
}
|
|
749
|
+
close(finishEvents) {
|
|
750
|
+
return this.#awaitCleanup(this.release(finishEvents));
|
|
751
|
+
}
|
|
752
|
+
#prepareEvents(finishEvents) {
|
|
753
|
+
this.#eventFinalizationPromise ??= Promise.resolve().then(async () => {
|
|
754
|
+
await finishEvents?.();
|
|
755
|
+
this.#eventsFinalized = true;
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
async #awaitCleanup(cleanup) {
|
|
759
|
+
try {
|
|
760
|
+
await withPlaywrightExecutionBoundary(() => cleanup, PLAYWRIGHT_CLEANUP_CONFIRMATION_TIMEOUT_MS);
|
|
761
|
+
} catch (cause) {
|
|
762
|
+
const failure = new BrowserObservationError(OPERATION$2, "cleanup_failed", {
|
|
763
|
+
cause,
|
|
764
|
+
cleanup: {
|
|
765
|
+
reason: cause instanceof Error ? cause.message : String(cause),
|
|
766
|
+
resources: this.cleanupResources
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
new AnalysisCleanupLeaseGroup(failure, [this.cleanupLease]);
|
|
770
|
+
throw failure;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
async #closeResources() {
|
|
774
|
+
const failures = [];
|
|
775
|
+
this.#prepareEvents();
|
|
776
|
+
try {
|
|
777
|
+
await this.#eventFinalizationPromise;
|
|
778
|
+
} catch (cause) {
|
|
779
|
+
failures.push(cause);
|
|
780
|
+
}
|
|
781
|
+
if (!this.#browserClosed) {
|
|
782
|
+
try {
|
|
783
|
+
await this.resources.closeBrowser();
|
|
784
|
+
this.#browserClosed = true;
|
|
785
|
+
} catch (cause) {
|
|
786
|
+
failures.push(cause);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (this.#browserClosed && !this.#profileRemoved && this.resources.removeProfile !== undefined) {
|
|
790
|
+
try {
|
|
791
|
+
await this.resources.removeProfile();
|
|
792
|
+
this.#profileRemoved = true;
|
|
793
|
+
} catch (cause) {
|
|
794
|
+
failures.push(cause);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (failures.length === 1) throw failures[0];
|
|
798
|
+
if (failures.length > 1) throw new AggregateError(failures, "Browser session cleanup failed");
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
attachedScenarioAdmissions = new Map();
|
|
802
|
+
releaseAttachedScenario = (key, admission) => {
|
|
803
|
+
const waiter = admission.waiters.shift();
|
|
804
|
+
if (waiter === undefined) {
|
|
805
|
+
admission.active = false;
|
|
806
|
+
if (admission.cleanupOwner === undefined && attachedScenarioAdmissions.get(key) === admission) attachedScenarioAdmissions.delete(key);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
if (waiter.onAbort !== undefined) waiter.signal?.removeEventListener("abort", waiter.onAbort);
|
|
810
|
+
if (waiter.signal?.aborted === true) {
|
|
811
|
+
waiter.reject(new BrowserObservationError(OPERATION$2, "cancelled", { cause: waiter.signal.reason }));
|
|
812
|
+
releaseAttachedScenario(key, admission);
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
waiter.resolve(createAttachedScenarioRelease(key, admission));
|
|
816
|
+
};
|
|
817
|
+
createAttachedScenarioRelease = (key, admission) => {
|
|
818
|
+
let released = false;
|
|
819
|
+
return () => {
|
|
820
|
+
if (released) return;
|
|
821
|
+
released = true;
|
|
822
|
+
releaseAttachedScenario(key, admission);
|
|
823
|
+
};
|
|
824
|
+
};
|
|
825
|
+
attachedScenarioLeaseKey = (endpoint, targetId) => {
|
|
826
|
+
const discovery = new URL("/json/version", endpoint);
|
|
827
|
+
if (isLiteralLoopbackHostname(discovery.hostname)) discovery.hostname = "127.0.0.1";
|
|
828
|
+
return JSON.stringify([discovery.href, targetId]);
|
|
829
|
+
};
|
|
830
|
+
acquireAttachedScenario = (scenario, signal) => {
|
|
831
|
+
if (signal?.aborted === true) return Promise.reject(new BrowserObservationError(OPERATION$2, "cancelled", { cause: signal?.reason }));
|
|
832
|
+
const key = attachedScenarioLeaseKey(scenario.cdp_endpoint, scenario.target_id);
|
|
833
|
+
const admission = attachedScenarioAdmissions.get(key) ?? {
|
|
834
|
+
active: false,
|
|
835
|
+
waiters: [],
|
|
836
|
+
cleanupOwner: undefined
|
|
837
|
+
};
|
|
838
|
+
attachedScenarioAdmissions.set(key, admission);
|
|
839
|
+
return new Promise((resolve, reject) => {
|
|
840
|
+
const grant = (release) => resolve({
|
|
841
|
+
admission,
|
|
842
|
+
release
|
|
843
|
+
});
|
|
844
|
+
if (!admission.active) {
|
|
845
|
+
admission.active = true;
|
|
846
|
+
grant(createAttachedScenarioRelease(key, admission));
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
const waiter = {
|
|
850
|
+
signal,
|
|
851
|
+
resolve: (release) => grant(release),
|
|
852
|
+
reject,
|
|
853
|
+
onAbort: undefined
|
|
854
|
+
};
|
|
855
|
+
admission.waiters.push(waiter);
|
|
856
|
+
if (signal !== undefined) {
|
|
857
|
+
const onAbort = () => {
|
|
858
|
+
const index = admission.waiters.indexOf(waiter);
|
|
859
|
+
if (index < 0) return;
|
|
860
|
+
admission.waiters.splice(index, 1);
|
|
861
|
+
signal.removeEventListener("abort", onAbort);
|
|
862
|
+
reject(new BrowserObservationError(OPERATION$2, "cancelled", { cause: signal?.reason }));
|
|
863
|
+
if (!admission.active && admission.waiters.length === 0) releaseAttachedScenario(key, admission);
|
|
864
|
+
};
|
|
865
|
+
waiter.onAbort = onAbort;
|
|
866
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
867
|
+
if (signal.aborted) {
|
|
868
|
+
onAbort();
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
};
|
|
874
|
+
allowedBrowserEnvironment = (environment) => {
|
|
875
|
+
const allowed = [
|
|
876
|
+
"DBUS_SESSION_BUS_ADDRESS",
|
|
877
|
+
"DISPLAY",
|
|
878
|
+
"HOME",
|
|
879
|
+
"LANG",
|
|
880
|
+
"LD_LIBRARY_PATH",
|
|
881
|
+
"PATH",
|
|
882
|
+
"SystemRoot",
|
|
883
|
+
"TEMP",
|
|
884
|
+
"TMP",
|
|
885
|
+
"TMPDIR",
|
|
886
|
+
"WAYLAND_DISPLAY",
|
|
887
|
+
"XAUTHORITY",
|
|
888
|
+
"XDG_RUNTIME_DIR"
|
|
889
|
+
];
|
|
890
|
+
const selected = Object.fromEntries(allowed.map((name) => [name, environment[name]]).filter((entry) => entry[1] !== undefined));
|
|
891
|
+
if (process.platform !== "android") return selected;
|
|
892
|
+
const prefix = environment.PREFIX;
|
|
893
|
+
if (prefix === undefined) return selected;
|
|
894
|
+
return {
|
|
895
|
+
...selected,
|
|
896
|
+
LD_PRELOAD: `${prefix}/lib/libtermux-exec.so`,
|
|
897
|
+
TERMUX_EXEC__PROC_SELF_EXE: process.execPath
|
|
898
|
+
};
|
|
899
|
+
};
|
|
900
|
+
findConnectedPage = async (browser, targetId, signal) => {
|
|
901
|
+
for (const context of browser.contexts()) for (const page of context.pages()) {
|
|
902
|
+
const session = await context.newCDPSession(page);
|
|
903
|
+
try {
|
|
904
|
+
throwIfScenarioCancelled$1(signal);
|
|
905
|
+
const { targetInfo } = await session.send("Target.getTargetInfo");
|
|
906
|
+
throwIfScenarioCancelled$1(signal);
|
|
907
|
+
if (targetInfo.targetId !== targetId) continue;
|
|
908
|
+
return {
|
|
909
|
+
context,
|
|
910
|
+
page
|
|
911
|
+
};
|
|
912
|
+
} finally {
|
|
913
|
+
await session.detach();
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
throw new BrowserObservationError(OPERATION$2, "target_not_found");
|
|
917
|
+
};
|
|
918
|
+
AttachedScenarioEnvironmentOwner = class AttachedScenarioEnvironmentOwner {
|
|
919
|
+
page;
|
|
920
|
+
session;
|
|
921
|
+
#mediaOverride = false;
|
|
922
|
+
#deviceMetricsOverride = false;
|
|
923
|
+
#localeOverride = false;
|
|
924
|
+
#timezoneOverride = false;
|
|
925
|
+
#detached = false;
|
|
926
|
+
#application;
|
|
927
|
+
constructor(page, session) {
|
|
928
|
+
this.page = page;
|
|
929
|
+
this.session = session;
|
|
930
|
+
}
|
|
931
|
+
static async create(context, page) {
|
|
932
|
+
return new AttachedScenarioEnvironmentOwner(page, await context.newCDPSession(page));
|
|
933
|
+
}
|
|
934
|
+
get restored() {
|
|
935
|
+
return !this.#mediaOverride && !this.#deviceMetricsOverride && !this.#localeOverride && !this.#timezoneOverride;
|
|
936
|
+
}
|
|
937
|
+
get targetClosed() {
|
|
938
|
+
return this.page.isClosed();
|
|
939
|
+
}
|
|
940
|
+
apply(environment, signal) {
|
|
941
|
+
const application = this.#application ?? this.#applyEnvironment(environment, signal);
|
|
942
|
+
this.#application = application;
|
|
943
|
+
return application;
|
|
944
|
+
}
|
|
945
|
+
async #applyEnvironment(environment, signal) {
|
|
946
|
+
await this.page.emulateMedia({
|
|
947
|
+
colorScheme: environment.color_scheme,
|
|
948
|
+
reducedMotion: environment.reduced_motion
|
|
949
|
+
});
|
|
950
|
+
this.#mediaOverride = true;
|
|
951
|
+
throwIfScenarioCancelled$1(signal);
|
|
952
|
+
await this.session.send("Emulation.setDeviceMetricsOverride", {
|
|
953
|
+
width: environment.viewport.width,
|
|
954
|
+
height: environment.viewport.height,
|
|
955
|
+
deviceScaleFactor: environment.viewport.device_scale_factor,
|
|
956
|
+
mobile: false,
|
|
957
|
+
dontSetVisibleSize: true
|
|
958
|
+
});
|
|
959
|
+
this.#deviceMetricsOverride = true;
|
|
960
|
+
throwIfScenarioCancelled$1(signal);
|
|
961
|
+
await this.session.send("Emulation.setLocaleOverride", { locale: environment.locale });
|
|
962
|
+
this.#localeOverride = true;
|
|
963
|
+
throwIfScenarioCancelled$1(signal);
|
|
964
|
+
await this.session.send("Emulation.setTimezoneOverride", { timezoneId: environment.timezone });
|
|
965
|
+
this.#timezoneOverride = true;
|
|
966
|
+
throwIfScenarioCancelled$1(signal);
|
|
967
|
+
}
|
|
968
|
+
async close() {
|
|
969
|
+
if (this.#detached) return;
|
|
970
|
+
try {
|
|
971
|
+
await this.#application;
|
|
972
|
+
} catch {}
|
|
973
|
+
const failures = [];
|
|
974
|
+
if (this.#timezoneOverride) {
|
|
975
|
+
try {
|
|
976
|
+
await this.session.send("Emulation.setTimezoneOverride", { timezoneId: "" });
|
|
977
|
+
this.#timezoneOverride = false;
|
|
978
|
+
} catch (cause) {
|
|
979
|
+
failures.push(cause);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
if (this.#localeOverride) {
|
|
983
|
+
try {
|
|
984
|
+
await this.session.send("Emulation.setLocaleOverride", { locale: "" });
|
|
985
|
+
this.#localeOverride = false;
|
|
986
|
+
} catch (cause) {
|
|
987
|
+
failures.push(cause);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
if (this.#deviceMetricsOverride) {
|
|
991
|
+
try {
|
|
992
|
+
await this.session.send("Emulation.clearDeviceMetricsOverride");
|
|
993
|
+
this.#deviceMetricsOverride = false;
|
|
994
|
+
} catch (cause) {
|
|
995
|
+
failures.push(cause);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
if (this.#mediaOverride) {
|
|
999
|
+
try {
|
|
1000
|
+
await this.page.emulateMedia({
|
|
1001
|
+
colorScheme: null,
|
|
1002
|
+
reducedMotion: null
|
|
1003
|
+
});
|
|
1004
|
+
this.#mediaOverride = false;
|
|
1005
|
+
} catch (cause) {
|
|
1006
|
+
failures.push(cause);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
if (failures.length === 1) throw failures[0];
|
|
1010
|
+
if (failures.length > 1) throw new AggregateError(failures, "Attached browser environment restoration failed");
|
|
1011
|
+
await this.session.detach();
|
|
1012
|
+
this.#detached = true;
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
failBrowserScenarioOperation = async (cleanup, primaryFailure) => {
|
|
1016
|
+
try {
|
|
1017
|
+
await withPlaywrightExecutionBoundary(() => cleanup.release(), PLAYWRIGHT_CLEANUP_CONFIRMATION_TIMEOUT_MS);
|
|
1018
|
+
} catch (cause) {
|
|
1019
|
+
const primary = primaryFailure instanceof AnalysisError ? primaryFailure : new ProviderAdapterError(PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id, OPERATION$2, { cause: primaryFailure });
|
|
1020
|
+
const failure = new BrowserObservationError(OPERATION$2, "cleanup_failed", {
|
|
1021
|
+
cause,
|
|
1022
|
+
cleanup: {
|
|
1023
|
+
reason: cause instanceof Error ? cause.message : String(cause),
|
|
1024
|
+
resources: cleanup.cleanupResources ?? []
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
new AnalysisCleanupLeaseGroup(failure, [cleanup]);
|
|
1028
|
+
throw analysisErrorWithCleanupFailure(primary, failure, OPERATION$2).bindCleanupDependencies([primary, failure]);
|
|
1029
|
+
}
|
|
1030
|
+
throw primaryFailure;
|
|
1031
|
+
};
|
|
1032
|
+
openAttachedScenarioBrowser = async (browserRequest, environment, launcher, signal, retainCleanup) => {
|
|
1033
|
+
const lease = await acquireAttachedScenario(browserRequest, signal);
|
|
1034
|
+
let cleanupOwner;
|
|
1035
|
+
let environmentOwner;
|
|
1036
|
+
try {
|
|
1037
|
+
const priorOwner = lease.admission.cleanupOwner;
|
|
1038
|
+
if (priorOwner !== undefined) await priorOwner.close();
|
|
1039
|
+
throwIfScenarioCancelled$1(signal);
|
|
1040
|
+
const browser = await launcher.connectOverCDP(browserRequest.cdp_endpoint);
|
|
1041
|
+
const cleanup = new PlaywrightScenarioBrowserCleanupOwner({
|
|
1042
|
+
closeBrowser: async () => {
|
|
1043
|
+
let environmentFailure;
|
|
1044
|
+
const ownedEnvironment = environmentOwner;
|
|
1045
|
+
if (ownedEnvironment !== undefined) {
|
|
1046
|
+
try {
|
|
1047
|
+
await ownedEnvironment.close();
|
|
1048
|
+
environmentOwner = undefined;
|
|
1049
|
+
} catch (cause) {
|
|
1050
|
+
environmentFailure = cause;
|
|
1051
|
+
const browserConnected = browser.isConnected();
|
|
1052
|
+
if (ownedEnvironment.targetClosed || !browserConnected) {
|
|
1053
|
+
environmentOwner = undefined;
|
|
1054
|
+
if (!browserConnected) return;
|
|
1055
|
+
} else if (!ownedEnvironment.restored) {
|
|
1056
|
+
throw cause;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
try {
|
|
1061
|
+
await browser.close();
|
|
1062
|
+
environmentOwner = undefined;
|
|
1063
|
+
} catch (browserFailure) {
|
|
1064
|
+
if (environmentFailure !== undefined) throw new AggregateError([environmentFailure, browserFailure], "Attached browser environment cleanup failed");
|
|
1065
|
+
throw browserFailure;
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
onSettled: (browserClosed) => {
|
|
1069
|
+
if (browserClosed && lease.admission.cleanupOwner === cleanup) lease.admission.cleanupOwner = undefined;
|
|
1070
|
+
lease.release();
|
|
1071
|
+
},
|
|
1072
|
+
removeProfile: undefined
|
|
1073
|
+
});
|
|
1074
|
+
cleanupOwner = cleanup;
|
|
1075
|
+
lease.admission.cleanupOwner = cleanup;
|
|
1076
|
+
throwIfScenarioCancelled$1(signal);
|
|
1077
|
+
const target = await withPlaywrightExecutionBoundary(() => findConnectedPage(browser, browserRequest.target_id, signal), undefined, signal);
|
|
1078
|
+
throwIfScenarioCancelled$1(signal);
|
|
1079
|
+
const configuredEnvironment = await withPlaywrightExecutionBoundary(() => AttachedScenarioEnvironmentOwner.create(target.context, target.page), undefined, signal);
|
|
1080
|
+
environmentOwner = configuredEnvironment;
|
|
1081
|
+
await withPlaywrightExecutionBoundary(() => configuredEnvironment.apply(environment, signal), undefined, signal);
|
|
1082
|
+
return {
|
|
1083
|
+
...target,
|
|
1084
|
+
browser,
|
|
1085
|
+
profilePath: undefined,
|
|
1086
|
+
cleanup
|
|
1087
|
+
};
|
|
1088
|
+
} catch (cause) {
|
|
1089
|
+
if (cleanupOwner === undefined) {
|
|
1090
|
+
lease.release();
|
|
1091
|
+
throw cause;
|
|
1092
|
+
}
|
|
1093
|
+
const cleanup = cleanupOwner;
|
|
1094
|
+
const recovery = cleanup.cleanupLease;
|
|
1095
|
+
try {
|
|
1096
|
+
return await failBrowserScenarioOperation(recovery, cause);
|
|
1097
|
+
} catch (failure) {
|
|
1098
|
+
if (failure !== cause) retainCleanup?.(recovery);
|
|
1099
|
+
throw failure;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
openPlaywrightScenarioBrowser = async (scenario, environment, options = {}) => {
|
|
1104
|
+
const launcher = options.launcher ?? (await import("playwright-core")).chromium;
|
|
1105
|
+
if (scenario.browser.mode === "connect") return openAttachedScenarioBrowser(scenario.browser, scenario.environment, launcher, options.signal, options.retainCleanup);
|
|
1106
|
+
const profilePath = await mkdtemp(join(tmpdir(), "rea-browser-scenario-"));
|
|
1107
|
+
let context;
|
|
1108
|
+
try {
|
|
1109
|
+
await chmod(profilePath, 448);
|
|
1110
|
+
context = await launcher.launchPersistentContext(profilePath, {
|
|
1111
|
+
executablePath: resolve(scenario.browser.executable_path),
|
|
1112
|
+
headless: scenario.browser.headless,
|
|
1113
|
+
acceptDownloads: false,
|
|
1114
|
+
viewport: {
|
|
1115
|
+
width: scenario.environment.viewport.width,
|
|
1116
|
+
height: scenario.environment.viewport.height
|
|
1117
|
+
},
|
|
1118
|
+
deviceScaleFactor: scenario.environment.viewport.device_scale_factor,
|
|
1119
|
+
locale: scenario.environment.locale,
|
|
1120
|
+
timezoneId: scenario.environment.timezone,
|
|
1121
|
+
colorScheme: scenario.environment.color_scheme,
|
|
1122
|
+
reducedMotion: scenario.environment.reduced_motion,
|
|
1123
|
+
serviceWorkers: scenario.environment.service_workers,
|
|
1124
|
+
env: allowedBrowserEnvironment(environment),
|
|
1125
|
+
handleSIGHUP: false,
|
|
1126
|
+
handleSIGINT: false,
|
|
1127
|
+
handleSIGTERM: false,
|
|
1128
|
+
timeout: 0,
|
|
1129
|
+
args: process.platform === "android" ? ["--no-sandbox", "--single-process"] : []
|
|
1130
|
+
});
|
|
1131
|
+
} catch (cause) {
|
|
1132
|
+
const cleanup = new AnalysisCleanupLease(() => rm(profilePath, {
|
|
1133
|
+
recursive: true,
|
|
1134
|
+
force: true,
|
|
1135
|
+
maxRetries: 3
|
|
1136
|
+
}), ["browser_profile"]);
|
|
1137
|
+
try {
|
|
1138
|
+
return await failBrowserScenarioOperation(cleanup, cause);
|
|
1139
|
+
} catch (failure) {
|
|
1140
|
+
if (failure !== cause) options.retainCleanup?.(cleanup);
|
|
1141
|
+
throw failure;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
const cleanup = new PlaywrightScenarioBrowserCleanupOwner({
|
|
1145
|
+
closeBrowser: () => context.close(),
|
|
1146
|
+
removeProfile: () => rm(profilePath, {
|
|
1147
|
+
recursive: true,
|
|
1148
|
+
force: true,
|
|
1149
|
+
maxRetries: 3
|
|
1150
|
+
})
|
|
1151
|
+
});
|
|
1152
|
+
try {
|
|
1153
|
+
const browser = context.browser();
|
|
1154
|
+
if (browser === null) throw new BrowserObservationError(OPERATION$2, "protocol_error");
|
|
1155
|
+
const page = context.pages()[0] ?? await context.newPage();
|
|
1156
|
+
return {
|
|
1157
|
+
context,
|
|
1158
|
+
page,
|
|
1159
|
+
browser,
|
|
1160
|
+
profilePath,
|
|
1161
|
+
cleanup
|
|
1162
|
+
};
|
|
1163
|
+
} catch (cause) {
|
|
1164
|
+
const recovery = cleanup.cleanupLease;
|
|
1165
|
+
try {
|
|
1166
|
+
return await failBrowserScenarioOperation(recovery, cause);
|
|
1167
|
+
} catch (failure) {
|
|
1168
|
+
if (failure !== cause) options.retainCleanup?.(recovery);
|
|
1169
|
+
throw failure;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
})))();
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
//#endregion
|
|
1177
|
+
//#region dist/browser/PlaywrightScenarioActions.js
|
|
1178
|
+
var resolveLocator, resolveValue, performPlaywrightScenarioAction;
|
|
1179
|
+
function init_PlaywrightScenarioActions() {
|
|
1180
|
+
return (init_PlaywrightScenarioActions = __esmMin((() => {
|
|
1181
|
+
resolveLocator = (page, locator) => {
|
|
1182
|
+
switch (locator.kind) {
|
|
1183
|
+
case "test_id": return page.getByTestId(locator.value);
|
|
1184
|
+
case "role": return page.getByRole(locator.role, {
|
|
1185
|
+
name: locator.name,
|
|
1186
|
+
exact: true
|
|
1187
|
+
});
|
|
1188
|
+
case "css": return page.locator(locator.selector);
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
resolveValue = (value, secrets) => secrets.value(value);
|
|
1192
|
+
performPlaywrightScenarioAction = async (input) => {
|
|
1193
|
+
const { page, action, secrets } = input;
|
|
1194
|
+
const timeout = "timeout_ms" in action ? action.timeout_ms : undefined;
|
|
1195
|
+
const options = timeout === undefined ? {} : { timeout };
|
|
1196
|
+
switch (action.action) {
|
|
1197
|
+
case "goto":
|
|
1198
|
+
await page.goto(secrets.url(action.destination), {
|
|
1199
|
+
...options,
|
|
1200
|
+
waitUntil: action.wait_until
|
|
1201
|
+
});
|
|
1202
|
+
return;
|
|
1203
|
+
case "click":
|
|
1204
|
+
await resolveLocator(page, action.locator).click({
|
|
1205
|
+
...options,
|
|
1206
|
+
button: action.button,
|
|
1207
|
+
clickCount: action.click_count
|
|
1208
|
+
});
|
|
1209
|
+
return;
|
|
1210
|
+
case "fill":
|
|
1211
|
+
await resolveLocator(page, action.locator).fill(resolveValue(action.value, secrets), options);
|
|
1212
|
+
return;
|
|
1213
|
+
case "press":
|
|
1214
|
+
await resolveLocator(page, action.locator).press(action.key, options);
|
|
1215
|
+
return;
|
|
1216
|
+
case "select_option":
|
|
1217
|
+
await resolveLocator(page, action.locator).selectOption(resolveValue(action.value, secrets), options);
|
|
1218
|
+
return;
|
|
1219
|
+
case "check":
|
|
1220
|
+
await resolveLocator(page, action.locator).check(options);
|
|
1221
|
+
return;
|
|
1222
|
+
case "uncheck":
|
|
1223
|
+
await resolveLocator(page, action.locator).uncheck(options);
|
|
1224
|
+
return;
|
|
1225
|
+
case "wait_for":
|
|
1226
|
+
await resolveLocator(page, action.locator).waitFor({
|
|
1227
|
+
...options,
|
|
1228
|
+
state: action.state
|
|
1229
|
+
});
|
|
1230
|
+
return;
|
|
1231
|
+
case "wait_for_timeout": await page.waitForTimeout(action.duration_ms);
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
})))();
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
//#endregion
|
|
1238
|
+
//#region dist/browser/PlaywrightScenarioArtifacts.js
|
|
1239
|
+
var historyValueSchema, storageValueSchema, notRequested, missing, textArtifact, captureScreenshot, captureDom, captureAccessibility, navigationType, captureHistory, captureStorage, capturePlaywrightStepArtifacts;
|
|
1240
|
+
function init_PlaywrightScenarioArtifacts() {
|
|
1241
|
+
return (init_PlaywrightScenarioArtifacts = __esmMin((() => {
|
|
1242
|
+
init_browserScenarioCaptureValues();
|
|
1243
|
+
historyValueSchema = z.strictObject({
|
|
1244
|
+
length: z.number().int().min(0),
|
|
1245
|
+
navigation_entries: z.array(z.strictObject({
|
|
1246
|
+
type: z.string(),
|
|
1247
|
+
name: z.string()
|
|
1248
|
+
}))
|
|
1249
|
+
});
|
|
1250
|
+
storageValueSchema = z.strictObject({
|
|
1251
|
+
local_storage: z.array(z.tuple([z.string(), z.string()])),
|
|
1252
|
+
session_storage: z.array(z.tuple([z.string(), z.string()]))
|
|
1253
|
+
});
|
|
1254
|
+
notRequested = () => ({ state: "not_requested" });
|
|
1255
|
+
missing = (reason) => ({
|
|
1256
|
+
state: "missing",
|
|
1257
|
+
reason
|
|
1258
|
+
});
|
|
1259
|
+
textArtifact = (text) => {
|
|
1260
|
+
const bytes = Buffer.from(text);
|
|
1261
|
+
return {
|
|
1262
|
+
state: "captured",
|
|
1263
|
+
value: {
|
|
1264
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
1265
|
+
bytes: bytes.byteLength,
|
|
1266
|
+
text
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
};
|
|
1270
|
+
captureScreenshot = async (page) => {
|
|
1271
|
+
try {
|
|
1272
|
+
const bytes = await page.screenshot({
|
|
1273
|
+
type: "png",
|
|
1274
|
+
fullPage: false,
|
|
1275
|
+
animations: "disabled",
|
|
1276
|
+
caret: "hide"
|
|
1277
|
+
});
|
|
1278
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
1279
|
+
return {
|
|
1280
|
+
state: "captured",
|
|
1281
|
+
value: {
|
|
1282
|
+
sha256,
|
|
1283
|
+
bytes: bytes.byteLength,
|
|
1284
|
+
media_type: "image/png",
|
|
1285
|
+
data_base64: bytes.toString("base64")
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
} catch (cause) {
|
|
1289
|
+
void cause;
|
|
1290
|
+
return missing("screenshot capture failed");
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
captureDom = async (input) => {
|
|
1294
|
+
const { page, secrets } = input;
|
|
1295
|
+
try {
|
|
1296
|
+
return textArtifact(secrets.redact(await page.content()));
|
|
1297
|
+
} catch (cause) {
|
|
1298
|
+
void cause;
|
|
1299
|
+
return missing("DOM capture failed");
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
captureAccessibility = async (input) => {
|
|
1303
|
+
const { page, secrets } = input;
|
|
1304
|
+
try {
|
|
1305
|
+
const text = await page.locator("html").ariaSnapshot();
|
|
1306
|
+
return textArtifact(secrets.redact(text));
|
|
1307
|
+
} catch (cause) {
|
|
1308
|
+
void cause;
|
|
1309
|
+
return missing("accessibility capture failed");
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
navigationType = (value) => {
|
|
1313
|
+
switch (value) {
|
|
1314
|
+
case "navigate":
|
|
1315
|
+
case "reload":
|
|
1316
|
+
case "back_forward":
|
|
1317
|
+
case "prerender": return value;
|
|
1318
|
+
default: return "unknown";
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
captureHistory = async (page, secrets) => {
|
|
1322
|
+
try {
|
|
1323
|
+
const raw = historyValueSchema.parse(await page.evaluate(`(() => ({
|
|
1324
|
+
length: window.history.length,
|
|
1325
|
+
navigation_entries: performance.getEntriesByType("navigation").map(
|
|
1326
|
+
entry => ({
|
|
1327
|
+
type: typeof entry.type === "string" ? entry.type : "unknown",
|
|
1328
|
+
name: entry.name
|
|
1329
|
+
})
|
|
1330
|
+
)
|
|
1331
|
+
}))()`));
|
|
1332
|
+
const value = {
|
|
1333
|
+
length: raw.length,
|
|
1334
|
+
current_url: secrets.sanitizeUrl(page.url()),
|
|
1335
|
+
navigation_entries: raw.navigation_entries.map(({ type, name }) => ({
|
|
1336
|
+
type: navigationType(type),
|
|
1337
|
+
name: secrets.sanitizeUrl(name)
|
|
1338
|
+
}))
|
|
1339
|
+
};
|
|
1340
|
+
return {
|
|
1341
|
+
state: "captured",
|
|
1342
|
+
value
|
|
1343
|
+
};
|
|
1344
|
+
} catch (cause) {
|
|
1345
|
+
void cause;
|
|
1346
|
+
return missing("history capture failed");
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
captureStorage = async (input) => {
|
|
1350
|
+
const { context, page, secrets } = input;
|
|
1351
|
+
try {
|
|
1352
|
+
const pageUrl = new URL(page.url());
|
|
1353
|
+
const cookies = pageUrl.protocol === "http:" || pageUrl.protocol === "https:" ? await context.cookies(pageUrl.href) : [];
|
|
1354
|
+
const pageStorage = storageValueSchema.parse(await page.evaluate(`(() => ({
|
|
1355
|
+
local_storage: Object.entries(window.localStorage),
|
|
1356
|
+
session_storage: Object.entries(window.sessionStorage)
|
|
1357
|
+
}))()`));
|
|
1358
|
+
const value = {
|
|
1359
|
+
cookies: cookies.map((cookie) => ({
|
|
1360
|
+
name: secrets.redact(cookie.name),
|
|
1361
|
+
domain: secrets.redact(cookie.domain),
|
|
1362
|
+
path: secrets.redact(cookie.path),
|
|
1363
|
+
secure: cookie.secure,
|
|
1364
|
+
http_only: cookie.httpOnly,
|
|
1365
|
+
same_site: cookie.sameSite,
|
|
1366
|
+
...secrets.fingerprint(cookie.value)
|
|
1367
|
+
})),
|
|
1368
|
+
local_storage: pageStorage.local_storage.map(([name, value]) => ({
|
|
1369
|
+
name: secrets.redact(name),
|
|
1370
|
+
...secrets.fingerprint(value)
|
|
1371
|
+
})),
|
|
1372
|
+
session_storage: pageStorage.session_storage.map(([name, value]) => ({
|
|
1373
|
+
name: secrets.redact(name),
|
|
1374
|
+
...secrets.fingerprint(value)
|
|
1375
|
+
}))
|
|
1376
|
+
};
|
|
1377
|
+
return {
|
|
1378
|
+
state: "captured",
|
|
1379
|
+
value
|
|
1380
|
+
};
|
|
1381
|
+
} catch (cause) {
|
|
1382
|
+
void cause;
|
|
1383
|
+
return missing("storage capture failed");
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
capturePlaywrightStepArtifacts = async (input) => {
|
|
1387
|
+
const { context, page, secrets, requested } = input;
|
|
1388
|
+
const state = (kind, capture) => !requested.has(kind) ? Promise.resolve(notRequested()) : capture();
|
|
1389
|
+
return browserStepArtifactsSchema.parse({
|
|
1390
|
+
screenshot: await state("screenshot", () => captureScreenshot(page)),
|
|
1391
|
+
dom: await state("dom", () => captureDom({
|
|
1392
|
+
page,
|
|
1393
|
+
secrets
|
|
1394
|
+
})),
|
|
1395
|
+
accessibility: await state("accessibility", () => captureAccessibility({
|
|
1396
|
+
page,
|
|
1397
|
+
secrets
|
|
1398
|
+
})),
|
|
1399
|
+
url: await state("url", async () => ({
|
|
1400
|
+
state: "captured",
|
|
1401
|
+
value: secrets.sanitizeUrl(page.url())
|
|
1402
|
+
})),
|
|
1403
|
+
history: await state("history", () => captureHistory(page, secrets)),
|
|
1404
|
+
storage: await state("storage", () => captureStorage({
|
|
1405
|
+
context,
|
|
1406
|
+
page,
|
|
1407
|
+
secrets
|
|
1408
|
+
}))
|
|
1409
|
+
});
|
|
1410
|
+
};
|
|
1411
|
+
})))();
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
//#endregion
|
|
1415
|
+
//#region dist/browser/network/PlaywrightNetworkContent.js
|
|
1416
|
+
var credentialHeaders, errorMessage, captureNetworkHeaders, captureNetworkBody;
|
|
1417
|
+
function init_PlaywrightNetworkContent() {
|
|
1418
|
+
return (init_PlaywrightNetworkContent = __esmMin((() => {
|
|
1419
|
+
init_analysisErrorCore();
|
|
1420
|
+
init_PlaywrightExecutionBoundary();
|
|
1421
|
+
credentialHeaders = new Set([
|
|
1422
|
+
"authorization",
|
|
1423
|
+
"proxy-authorization",
|
|
1424
|
+
"cookie",
|
|
1425
|
+
"set-cookie"
|
|
1426
|
+
]);
|
|
1427
|
+
errorMessage = (cause, secrets, maxMetadataAllocationBytes) => {
|
|
1428
|
+
const message = cause instanceof Error && cause.message !== "" ? cause.message : "Network read failed";
|
|
1429
|
+
return secrets.redactionAllocationCost(message.length) <= maxMetadataAllocationBytes ? secrets.redact(message) : "Network read failed; diagnostic exceeds the allocation budget.";
|
|
1430
|
+
};
|
|
1431
|
+
captureNetworkHeaders = async (source, secrets, options) => {
|
|
1432
|
+
try {
|
|
1433
|
+
const headers = await withPlaywrightExecutionBoundary(() => source.headersArray(), options.timeoutMs, options.signal);
|
|
1434
|
+
let cost = 0;
|
|
1435
|
+
for (const { name, value } of headers) {
|
|
1436
|
+
cost += secrets.redactionAllocationCost(name.length + value.length) + 128;
|
|
1437
|
+
if (cost > options.maxHeaderAllocationBytes) return {
|
|
1438
|
+
state: "unavailable",
|
|
1439
|
+
message: `Headers exceed the ${String(options.maxHeaderAllocationBytes)}-byte allocation budget.`
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
return {
|
|
1443
|
+
state: "captured",
|
|
1444
|
+
items: headers.map(({ name, value }) => {
|
|
1445
|
+
const safeName = secrets.redact(name);
|
|
1446
|
+
const credential = credentialHeaders.has(name.toLowerCase());
|
|
1447
|
+
const safeValue = credential ? null : secrets.redactBytes(Buffer.from(value)).toString("utf8");
|
|
1448
|
+
return {
|
|
1449
|
+
name: safeName,
|
|
1450
|
+
value: safeValue,
|
|
1451
|
+
redacted: credential || safeName !== name || safeValue !== value
|
|
1452
|
+
};
|
|
1453
|
+
})
|
|
1454
|
+
};
|
|
1455
|
+
} catch (cause) {
|
|
1456
|
+
return {
|
|
1457
|
+
state: "unavailable",
|
|
1458
|
+
message: errorMessage(cause, secrets, options.maxMetadataAllocationBytes)
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
captureNetworkBody = async (read, phase, source, secrets, options, preflight) => {
|
|
1463
|
+
try {
|
|
1464
|
+
const observed = await withPlaywrightExecutionBoundary(read, options.timeoutMs, options.signal);
|
|
1465
|
+
if (observed === null) return { state: "not_exposed" };
|
|
1466
|
+
const maxBodyBytes = options.maxBodyBytes;
|
|
1467
|
+
if (observed.length > maxBodyBytes) return {
|
|
1468
|
+
state: "unavailable",
|
|
1469
|
+
reason: "body-size-limit",
|
|
1470
|
+
message: `Playwright materialized the body before its ${String(maxBodyBytes)}-byte retained-body budget was checked.`,
|
|
1471
|
+
limit_bytes: maxBodyBytes,
|
|
1472
|
+
observed_bytes: observed.length
|
|
1473
|
+
};
|
|
1474
|
+
const bodyAllocationCost = secrets.redactionAllocationCost(observed.length);
|
|
1475
|
+
const base64AllocationCost = Math.ceil(observed.length / 3) * 4 * 8 + 2;
|
|
1476
|
+
const maxBodyAllocationBytes = options.maxBodyAllocationBytes;
|
|
1477
|
+
const observedBodyAllocationBytes = Math.max(bodyAllocationCost, base64AllocationCost);
|
|
1478
|
+
if (observedBodyAllocationBytes > maxBodyAllocationBytes) return {
|
|
1479
|
+
state: "unavailable",
|
|
1480
|
+
reason: "body-allocation-limit",
|
|
1481
|
+
message: "Body redaction exceeds the selected network body allocation budget.",
|
|
1482
|
+
limit_allocation_bytes: maxBodyAllocationBytes,
|
|
1483
|
+
observed_allocation_bytes: observedBodyAllocationBytes
|
|
1484
|
+
};
|
|
1485
|
+
const contentType = source.headers()["content-type"];
|
|
1486
|
+
if (contentType !== undefined && secrets.redactionAllocationCost(contentType.length) > options.maxHeaderAllocationBytes) return {
|
|
1487
|
+
state: "unavailable",
|
|
1488
|
+
reason: "body-allocation-limit",
|
|
1489
|
+
message: "Content type exceeds the selected network header allocation budget.",
|
|
1490
|
+
limit_allocation_bytes: options.maxHeaderAllocationBytes,
|
|
1491
|
+
observed_allocation_bytes: secrets.redactionAllocationCost(contentType.length)
|
|
1492
|
+
};
|
|
1493
|
+
const admission = preflight?.({
|
|
1494
|
+
observedBytes: observed.length,
|
|
1495
|
+
allocationBytes: observedBodyAllocationBytes,
|
|
1496
|
+
mediaType: contentType
|
|
1497
|
+
});
|
|
1498
|
+
if (admission?.status === "omitted") return {
|
|
1499
|
+
state: "omitted",
|
|
1500
|
+
reason: admission.reason
|
|
1501
|
+
};
|
|
1502
|
+
const retained = secrets.redactBytes(observed);
|
|
1503
|
+
return {
|
|
1504
|
+
state: "captured",
|
|
1505
|
+
representation: phase === "request" ? "browser-exposed-request-bytes" : "playwright-response-body-bytes",
|
|
1506
|
+
encoding: "base64",
|
|
1507
|
+
content: retained.toString("base64"),
|
|
1508
|
+
bytes: retained.length,
|
|
1509
|
+
sha256: createHash("sha256").update(retained).digest("hex"),
|
|
1510
|
+
media_type: contentType === undefined ? null : secrets.redactBytes(Buffer.from(contentType)).toString("utf8"),
|
|
1511
|
+
redacted: !retained.equals(observed)
|
|
1512
|
+
};
|
|
1513
|
+
} catch (cause) {
|
|
1514
|
+
return {
|
|
1515
|
+
state: "unavailable",
|
|
1516
|
+
reason: cause instanceof AnalysisCancelledError ? "cancelled" : cause instanceof AnalysisTimeoutError ? "body-read-timeout" : "body-read-failed",
|
|
1517
|
+
message: errorMessage(cause, secrets, options.maxMetadataAllocationBytes)
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
})))();
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
//#endregion
|
|
1525
|
+
//#region dist/browser/network/PlaywrightScenarioNetwork.js
|
|
1526
|
+
var PlaywrightScenarioNetwork;
|
|
1527
|
+
function init_PlaywrightScenarioNetwork() {
|
|
1528
|
+
return (init_PlaywrightScenarioNetwork = __esmMin((() => {
|
|
1529
|
+
init_PlaywrightNetworkContent();
|
|
1530
|
+
PlaywrightScenarioNetwork = class {
|
|
1531
|
+
options;
|
|
1532
|
+
transactions = new Map();
|
|
1533
|
+
omittedRequests = new WeakSet();
|
|
1534
|
+
omittedPhases = new WeakMap();
|
|
1535
|
+
totalTransactions = 0;
|
|
1536
|
+
omittedTransactionCount = 0;
|
|
1537
|
+
firstOmittedTransaction = 0;
|
|
1538
|
+
lastOmittedTransaction = 0;
|
|
1539
|
+
/** One request and one response-content job at most per admitted transaction. */
|
|
1540
|
+
pending = [];
|
|
1541
|
+
queuedReads = [];
|
|
1542
|
+
gaps = new Set();
|
|
1543
|
+
accepting = true;
|
|
1544
|
+
activeReads = 0;
|
|
1545
|
+
readOptions;
|
|
1546
|
+
limits;
|
|
1547
|
+
constructor(options) {
|
|
1548
|
+
this.options = options;
|
|
1549
|
+
this.limits = options.limits;
|
|
1550
|
+
this.readOptions = {
|
|
1551
|
+
timeoutMs: options.readTimeoutMs ?? 5e3,
|
|
1552
|
+
maxBodyBytes: this.limits.max_network_body_bytes,
|
|
1553
|
+
maxBodyAllocationBytes: this.limits.max_network_body_allocation_bytes,
|
|
1554
|
+
maxHeaderAllocationBytes: this.limits.max_network_header_allocation_bytes,
|
|
1555
|
+
maxMetadataAllocationBytes: this.limits.max_network_metadata_allocation_bytes,
|
|
1556
|
+
...options.signal === undefined ? {} : { signal: options.signal }
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
/** Observe a request start, retaining the producer's redirect relationship when known. */
|
|
1560
|
+
request(request) {
|
|
1561
|
+
if (!this.accepting) return;
|
|
1562
|
+
const transaction = this.transaction(request);
|
|
1563
|
+
if (transaction === undefined) {
|
|
1564
|
+
this.omitOmittedTransactionPhase(request, "request");
|
|
1565
|
+
if (this.options.selection.request_body || this.options.selection.header_values) this.omitOmittedTransactionContent(request, "request");
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
if (transaction.requestObserved) return;
|
|
1569
|
+
if (!this.admitMetadata(transaction, "request", request)) return;
|
|
1570
|
+
transaction.requestObserved = true;
|
|
1571
|
+
const admission = this.options.emit({
|
|
1572
|
+
...this.metadata(request, transaction),
|
|
1573
|
+
kind: "request",
|
|
1574
|
+
status: null,
|
|
1575
|
+
failure: null
|
|
1576
|
+
});
|
|
1577
|
+
if (admission.status === "omitted") {
|
|
1578
|
+
this.options.omitNetwork(transaction.id, "request", admission.reason);
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
const sequence = admission.sequence;
|
|
1582
|
+
if (this.options.selection.request_body || this.options.selection.header_values) this.collect(transaction, sequence, "request", request, (headers) => this.options.selection.request_body ? captureNetworkBody(async () => request.postDataBuffer(), "request", request, this.options.secrets, this.readOptions, (body) => this.options.admitContentBody({
|
|
1583
|
+
transactionId: transaction.id,
|
|
1584
|
+
sourceEventSequence: sequence,
|
|
1585
|
+
phase: "request",
|
|
1586
|
+
headers,
|
|
1587
|
+
observedBytes: body.observedBytes,
|
|
1588
|
+
allocationBytes: body.allocationBytes,
|
|
1589
|
+
mediaType: body.mediaType
|
|
1590
|
+
})) : Promise.resolve({ state: "not_requested" }), this.options.selection.header_values);
|
|
1591
|
+
}
|
|
1592
|
+
/** Observe response metadata without starting a potentially unfinished body read. */
|
|
1593
|
+
response(response) {
|
|
1594
|
+
if (!this.accepting) return;
|
|
1595
|
+
const request = response.request();
|
|
1596
|
+
const transaction = this.transaction(request);
|
|
1597
|
+
if (transaction === undefined) {
|
|
1598
|
+
this.omitOmittedTransactionPhase(request, "response");
|
|
1599
|
+
this.observeOmittedTransactionPhase(request, "response");
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
if (!this.admitMetadata(transaction, "response", request, undefined, [], [{
|
|
1603
|
+
source: response,
|
|
1604
|
+
url: response.url()
|
|
1605
|
+
}])) return;
|
|
1606
|
+
const admission = this.options.emit({
|
|
1607
|
+
...this.metadata(request, transaction),
|
|
1608
|
+
kind: "response",
|
|
1609
|
+
url: this.options.secrets.sanitizeUrl(response.url()),
|
|
1610
|
+
status: response.status(),
|
|
1611
|
+
header_names: this.headerNames(response),
|
|
1612
|
+
failure: null
|
|
1613
|
+
});
|
|
1614
|
+
if (admission.status === "omitted") {
|
|
1615
|
+
this.options.omitNetwork(transaction.id, "response", admission.reason);
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
const sequence = admission.sequence;
|
|
1619
|
+
transaction.response = {
|
|
1620
|
+
source: response,
|
|
1621
|
+
sequence
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
/** Record completion and read selected content through the response API. */
|
|
1625
|
+
finished(request) {
|
|
1626
|
+
if (!this.accepting) return;
|
|
1627
|
+
const transaction = this.transaction(request);
|
|
1628
|
+
if (transaction === undefined) {
|
|
1629
|
+
this.omitOmittedTransactionPhase(request, "request-finished");
|
|
1630
|
+
const observed = this.omittedPhases.get(request);
|
|
1631
|
+
if (observed?.has("response") && (this.options.selection.response_body || this.options.selection.header_values)) this.omitOmittedTransactionContent(request, "response");
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1634
|
+
if (!this.admitMetadata(transaction, "request-finished", request)) return;
|
|
1635
|
+
transaction.terminal = "finished";
|
|
1636
|
+
const admission = this.options.emit({
|
|
1637
|
+
...this.metadata(request, transaction),
|
|
1638
|
+
kind: "request-finished",
|
|
1639
|
+
status: null,
|
|
1640
|
+
failure: null
|
|
1641
|
+
});
|
|
1642
|
+
if (admission.status === "omitted") {
|
|
1643
|
+
this.options.omitNetwork(transaction.id, "request-finished", admission.reason);
|
|
1644
|
+
transaction.responseScheduled = true;
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
this.responseContent(transaction);
|
|
1648
|
+
}
|
|
1649
|
+
/** Preserve request failure separately from missing or unreadable response content. */
|
|
1650
|
+
failed(request) {
|
|
1651
|
+
if (!this.accepting) return;
|
|
1652
|
+
const transaction = this.transaction(request);
|
|
1653
|
+
if (transaction === undefined) {
|
|
1654
|
+
this.omitOmittedTransactionPhase(request, "request-failed");
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
transaction.terminal = "failed";
|
|
1658
|
+
const failure = request.failure()?.errorText || "Unknown request failure";
|
|
1659
|
+
if (!this.admitMetadata(transaction, "request-failed", request, undefined, [failure])) return;
|
|
1660
|
+
const message = this.options.secrets.redact(failure);
|
|
1661
|
+
const admission = this.options.emit({
|
|
1662
|
+
...this.metadata(request, transaction),
|
|
1663
|
+
kind: "request-failed",
|
|
1664
|
+
status: null,
|
|
1665
|
+
failure: message
|
|
1666
|
+
});
|
|
1667
|
+
if (admission.status === "omitted") {
|
|
1668
|
+
this.options.omitNetwork(transaction.id, "request-failed", admission.reason);
|
|
1669
|
+
transaction.responseScheduled = true;
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
this.responseContent(transaction, {
|
|
1673
|
+
state: "unavailable",
|
|
1674
|
+
reason: "request-failed",
|
|
1675
|
+
message
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
/** Stop observing, mark unfinished transactions, and drain admitted content reads. */
|
|
1679
|
+
async finish() {
|
|
1680
|
+
if (!this.accepting) {
|
|
1681
|
+
await this.settlePendingReads();
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
this.accepting = false;
|
|
1685
|
+
for (const [request, transaction] of this.transactions) {
|
|
1686
|
+
if (transaction.terminal === undefined) {
|
|
1687
|
+
if (!this.admitMetadata(transaction, "request-unfinished", request)) continue;
|
|
1688
|
+
this.gaps.add("Some network requests had not completed when capture ended; later activity is unknown.");
|
|
1689
|
+
const admission = this.options.emit({
|
|
1690
|
+
...this.metadata(request, transaction),
|
|
1691
|
+
kind: "request-unfinished",
|
|
1692
|
+
status: null,
|
|
1693
|
+
failure: null,
|
|
1694
|
+
reason: this.options.signal?.aborted === true ? "cancelled" : "capture-ended"
|
|
1695
|
+
});
|
|
1696
|
+
if (admission.status === "omitted") {
|
|
1697
|
+
this.options.omitNetwork(transaction.id, "request-unfinished", admission.reason);
|
|
1698
|
+
transaction.responseScheduled = true;
|
|
1699
|
+
continue;
|
|
1700
|
+
}
|
|
1701
|
+
this.responseContent(transaction, {
|
|
1702
|
+
state: "unavailable",
|
|
1703
|
+
reason: this.options.signal?.aborted === true ? "cancelled" : "response-unfinished",
|
|
1704
|
+
message: "The response had not finished at the capture cutoff; no body read or refetch was attempted."
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
await this.settlePendingReads();
|
|
1709
|
+
}
|
|
1710
|
+
async settlePendingReads() {
|
|
1711
|
+
const results = await Promise.allSettled(this.pending);
|
|
1712
|
+
const failed = results.find((result) => result.status === "rejected");
|
|
1713
|
+
if (failed !== undefined) throw failed.reason;
|
|
1714
|
+
}
|
|
1715
|
+
/** Missing selected content contributes to aggregate completeness. */
|
|
1716
|
+
limitations() {
|
|
1717
|
+
return [...this.gaps];
|
|
1718
|
+
}
|
|
1719
|
+
omittedTransactionRange() {
|
|
1720
|
+
return this.omittedTransactionCount === 0 ? null : {
|
|
1721
|
+
first_transaction_id: `request-${String(this.firstOmittedTransaction)}`,
|
|
1722
|
+
last_transaction_id: `request-${String(this.lastOmittedTransaction)}`,
|
|
1723
|
+
count: this.omittedTransactionCount,
|
|
1724
|
+
reason: "max-network-transactions"
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
transaction(request) {
|
|
1728
|
+
const known = this.transactions.get(request);
|
|
1729
|
+
if (known !== undefined) return known;
|
|
1730
|
+
if (this.omittedRequests.has(request)) return undefined;
|
|
1731
|
+
this.totalTransactions += 1;
|
|
1732
|
+
const id = `request-${String(this.totalTransactions)}`;
|
|
1733
|
+
if (this.transactions.size >= this.limits.max_network_transactions) {
|
|
1734
|
+
this.omittedRequests.add(request);
|
|
1735
|
+
if (this.omittedTransactionCount === 0) this.firstOmittedTransaction = this.totalTransactions;
|
|
1736
|
+
this.lastOmittedTransaction = this.totalTransactions;
|
|
1737
|
+
this.omittedTransactionCount += 1;
|
|
1738
|
+
this.gaps.add(`Network collection reached its ${String(this.limits.max_network_transactions)}-transaction resource budget; omitted transaction IDs are listed in events.omissions.network_transaction_range.`);
|
|
1739
|
+
return undefined;
|
|
1740
|
+
}
|
|
1741
|
+
const predecessor = request.redirectedFrom();
|
|
1742
|
+
const predecessorTransaction = predecessor === null ? undefined : this.transactions.get(predecessor);
|
|
1743
|
+
const transaction = {
|
|
1744
|
+
id,
|
|
1745
|
+
redirectedFrom: predecessorTransaction?.id ?? null,
|
|
1746
|
+
redirectedFromState: predecessor === null ? "root" : predecessorTransaction === undefined ? "unknown" : undefined,
|
|
1747
|
+
responseScheduled: false,
|
|
1748
|
+
requestObserved: false
|
|
1749
|
+
};
|
|
1750
|
+
this.transactions.set(request, transaction);
|
|
1751
|
+
return transaction;
|
|
1752
|
+
}
|
|
1753
|
+
admitProducerStrings(transaction, kind, values) {
|
|
1754
|
+
const admission = this.options.admitText(kind, values);
|
|
1755
|
+
if (admission.status === "retained") return true;
|
|
1756
|
+
this.options.omitNetwork(transaction.id, kind, admission.reason);
|
|
1757
|
+
this.gaps.add(`Network ${kind} metadata was omitted for ${transaction.id} because ${admission.reason} was reached; network coverage is incomplete.`);
|
|
1758
|
+
return false;
|
|
1759
|
+
}
|
|
1760
|
+
omitOmittedTransactionPhase(request, kind) {
|
|
1761
|
+
if (!this.omittedRequests.has(request)) return;
|
|
1762
|
+
if (!this.observeOmittedTransactionPhase(request, kind)) return;
|
|
1763
|
+
this.options.omitEvent(kind, "max-network-transactions");
|
|
1764
|
+
}
|
|
1765
|
+
observeOmittedTransactionPhase(request, phase) {
|
|
1766
|
+
let observed = this.omittedPhases.get(request);
|
|
1767
|
+
if (observed === undefined) {
|
|
1768
|
+
observed = new Set();
|
|
1769
|
+
this.omittedPhases.set(request, observed);
|
|
1770
|
+
}
|
|
1771
|
+
if (observed.has(phase)) return false;
|
|
1772
|
+
observed.add(phase);
|
|
1773
|
+
return true;
|
|
1774
|
+
}
|
|
1775
|
+
omitOmittedTransactionContent(request, phase) {
|
|
1776
|
+
if (!this.omittedRequests.has(request)) return;
|
|
1777
|
+
if (!this.observeOmittedTransactionPhase(request, `network-content:${phase}`)) return;
|
|
1778
|
+
this.options.omitEvent("network-content", "max-network-transactions");
|
|
1779
|
+
}
|
|
1780
|
+
admitMetadata(transaction, kind, source, url, additionalStrings = [], additionalSources = []) {
|
|
1781
|
+
return this.admitProducerStrings(transaction, kind, this.metadataStrings(source, url, additionalStrings, additionalSources));
|
|
1782
|
+
}
|
|
1783
|
+
*metadataStrings(source, url, additionalStrings, additionalSources) {
|
|
1784
|
+
yield* this.retainedMetadataStrings(source, source.headers(), url);
|
|
1785
|
+
yield* additionalStrings;
|
|
1786
|
+
for (const extra of additionalSources) yield* this.retainedMetadataStrings(extra.source, extra.source.headers(), extra.url);
|
|
1787
|
+
}
|
|
1788
|
+
*retainedMetadataStrings(source, headers, url) {
|
|
1789
|
+
if (url !== undefined) yield url;
|
|
1790
|
+
for (const name in headers) {
|
|
1791
|
+
if (!Object.hasOwn(headers, name)) continue;
|
|
1792
|
+
yield name;
|
|
1793
|
+
if (this.options.selection.header_values) yield headers[name];
|
|
1794
|
+
}
|
|
1795
|
+
if ("method" in source) {
|
|
1796
|
+
const request = source;
|
|
1797
|
+
yield request.method();
|
|
1798
|
+
yield request.url();
|
|
1799
|
+
yield request.resourceType();
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
headerNames(source) {
|
|
1803
|
+
return Object.keys(source.headers()).map((name) => this.options.secrets.redact(name)).sort();
|
|
1804
|
+
}
|
|
1805
|
+
metadata(request, transaction) {
|
|
1806
|
+
return {
|
|
1807
|
+
transaction_id: transaction.id,
|
|
1808
|
+
redirected_from_transaction_id: transaction.redirectedFrom,
|
|
1809
|
+
...transaction.redirectedFromState === undefined ? {} : { redirected_from_transaction_state: transaction.redirectedFromState },
|
|
1810
|
+
method: this.options.secrets.redact(request.method()),
|
|
1811
|
+
url: this.options.secrets.sanitizeUrl(request.url()),
|
|
1812
|
+
resource_type: this.options.secrets.redact(request.resourceType()),
|
|
1813
|
+
header_names: this.headerNames(request)
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
responseContent(transaction, unavailable) {
|
|
1817
|
+
const response = transaction.response;
|
|
1818
|
+
if (response === undefined || transaction.responseScheduled || !this.options.selection.response_body && !this.options.selection.header_values) return;
|
|
1819
|
+
transaction.responseScheduled = true;
|
|
1820
|
+
this.collect(transaction, response.sequence, "response", response.source, (headers) => this.options.selection.response_body ? unavailable === undefined ? captureNetworkBody(() => response.source.body(), "response", response.source, this.options.secrets, this.readOptions, (body) => this.options.admitContentBody({
|
|
1821
|
+
transactionId: transaction.id,
|
|
1822
|
+
sourceEventSequence: response.sequence,
|
|
1823
|
+
phase: "response",
|
|
1824
|
+
headers,
|
|
1825
|
+
observedBytes: body.observedBytes,
|
|
1826
|
+
allocationBytes: body.allocationBytes,
|
|
1827
|
+
mediaType: body.mediaType
|
|
1828
|
+
})) : Promise.resolve(unavailable) : Promise.resolve({ state: "not_requested" }), this.options.selection.header_values);
|
|
1829
|
+
}
|
|
1830
|
+
collect(transaction, sequence, phase, source, body, includeHeaders) {
|
|
1831
|
+
const collect = async () => {
|
|
1832
|
+
const retainedHeaders = includeHeaders ? await captureNetworkHeaders(source, this.options.secrets, this.readOptions) : { state: "not_requested" };
|
|
1833
|
+
const retainedBody = await body(retainedHeaders);
|
|
1834
|
+
if (retainedBody.state === "omitted") {
|
|
1835
|
+
this.options.omitNetwork(transaction.id, "network-content", retainedBody.reason);
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
if (retainedHeaders.state === "unavailable" || retainedBody.state === "unavailable" || retainedBody.state === "not_exposed") this.gaps.add("Some selected network content was unavailable; per-transaction content states retain the reason.");
|
|
1839
|
+
const admission = this.options.emit({
|
|
1840
|
+
kind: "network-content",
|
|
1841
|
+
transaction_id: transaction.id,
|
|
1842
|
+
source_event_sequence: sequence,
|
|
1843
|
+
phase,
|
|
1844
|
+
headers: retainedHeaders,
|
|
1845
|
+
body: retainedBody
|
|
1846
|
+
});
|
|
1847
|
+
if (admission.status === "omitted") this.options.omitNetwork(transaction.id, "network-content", admission.reason);
|
|
1848
|
+
};
|
|
1849
|
+
this.pending.push(new Promise((resolve, reject) => {
|
|
1850
|
+
this.queuedReads.push({
|
|
1851
|
+
run: collect,
|
|
1852
|
+
resolve,
|
|
1853
|
+
reject
|
|
1854
|
+
});
|
|
1855
|
+
this.pumpContentReads();
|
|
1856
|
+
}));
|
|
1857
|
+
}
|
|
1858
|
+
pumpContentReads() {
|
|
1859
|
+
while (this.activeReads < 16 && this.queuedReads.length > 0) {
|
|
1860
|
+
const job = this.queuedReads.shift();
|
|
1861
|
+
if (job === undefined) return;
|
|
1862
|
+
this.activeReads += 1;
|
|
1863
|
+
void job.run().then(job.resolve, job.reject).finally(() => {
|
|
1864
|
+
this.activeReads -= 1;
|
|
1865
|
+
this.pumpContentReads();
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
})))();
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
//#endregion
|
|
1874
|
+
//#region dist/browser/PlaywrightScenarioEvents.js
|
|
1875
|
+
var MAX_LISTENER_OWNERS, allocationCost, PlaywrightScenarioEvents;
|
|
1876
|
+
function init_PlaywrightScenarioEvents() {
|
|
1877
|
+
return (init_PlaywrightScenarioEvents = __esmMin((() => {
|
|
1878
|
+
init_browserScenarioCaptureValues();
|
|
1879
|
+
init_browserScenarioCaptureLimits();
|
|
1880
|
+
init_PlaywrightScenarioNetwork();
|
|
1881
|
+
MAX_LISTENER_OWNERS = 2048;
|
|
1882
|
+
allocationCost = (value, remaining) => {
|
|
1883
|
+
if (typeof value === "string") return value.length * 8 + 2;
|
|
1884
|
+
if (value === null || typeof value !== "object") return 32;
|
|
1885
|
+
let cost = 2;
|
|
1886
|
+
for (const key in value) {
|
|
1887
|
+
if (!Object.hasOwn(value, key)) continue;
|
|
1888
|
+
const item = value[key];
|
|
1889
|
+
cost += key.length * 8 + 4 + allocationCost(item, remaining - cost);
|
|
1890
|
+
if (cost > remaining) break;
|
|
1891
|
+
}
|
|
1892
|
+
return cost;
|
|
1893
|
+
};
|
|
1894
|
+
PlaywrightScenarioEvents = class {
|
|
1895
|
+
items = [];
|
|
1896
|
+
retainedCost = 0;
|
|
1897
|
+
dropped = 0;
|
|
1898
|
+
omittedKinds = new Map();
|
|
1899
|
+
omittedNetwork = new Map();
|
|
1900
|
+
stepIndex = 0;
|
|
1901
|
+
sequence = 0;
|
|
1902
|
+
enabled;
|
|
1903
|
+
secrets;
|
|
1904
|
+
limits;
|
|
1905
|
+
ownsContext;
|
|
1906
|
+
pages = new WeakSet();
|
|
1907
|
+
incompleteFamilies = new Set();
|
|
1908
|
+
network;
|
|
1909
|
+
stopNetwork;
|
|
1910
|
+
stopListeners = new Map();
|
|
1911
|
+
sealed = false;
|
|
1912
|
+
constructor(options) {
|
|
1913
|
+
const network = options.network ?? {
|
|
1914
|
+
request_body: false,
|
|
1915
|
+
response_body: false,
|
|
1916
|
+
header_values: false
|
|
1917
|
+
};
|
|
1918
|
+
this.enabled = new Set(options.enabled);
|
|
1919
|
+
if (network.request_body || network.response_body || network.header_values) this.enabled = new Set([...this.enabled, "network"]);
|
|
1920
|
+
this.secrets = options.secrets;
|
|
1921
|
+
this.limits = options.limits ?? DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS;
|
|
1922
|
+
this.ownsContext = options.ownsContext === true;
|
|
1923
|
+
this.pages.add(options.page);
|
|
1924
|
+
if (this.ownsContext && this.enabled.size > 0) {
|
|
1925
|
+
const context = options.context ?? options.page.context();
|
|
1926
|
+
const onPage = (page) => this.popup(page);
|
|
1927
|
+
context.on("page", onPage);
|
|
1928
|
+
this.retainListener(context, () => context.off("page", onPage));
|
|
1929
|
+
}
|
|
1930
|
+
if (this.enabled.has("network")) {
|
|
1931
|
+
const context = options.context ?? options.page.context();
|
|
1932
|
+
const collector = new PlaywrightScenarioNetwork({
|
|
1933
|
+
selection: network,
|
|
1934
|
+
limits: this.limits,
|
|
1935
|
+
secrets: options.secrets,
|
|
1936
|
+
emit: (event) => this.push(event),
|
|
1937
|
+
admitText: (kind, values) => this.admitProducerText(kind, values, true),
|
|
1938
|
+
admitContentBody: (input) => this.admitContentBody(input),
|
|
1939
|
+
omitNetwork: (id, kind, reason) => this.omitNetwork(id, kind, reason),
|
|
1940
|
+
omitEvent: (kind, reason) => this.omitEvent(kind, reason),
|
|
1941
|
+
...options.signal === undefined ? {} : { signal: options.signal }
|
|
1942
|
+
});
|
|
1943
|
+
this.network = collector;
|
|
1944
|
+
const inScope = (request) => {
|
|
1945
|
+
if (this.ownsContext) return true;
|
|
1946
|
+
try {
|
|
1947
|
+
return this.pages.has(request.frame().page());
|
|
1948
|
+
} catch (cause) {
|
|
1949
|
+
void cause;
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
};
|
|
1953
|
+
const onRequest = (request) => {
|
|
1954
|
+
if (inScope(request)) collector.request(request);
|
|
1955
|
+
};
|
|
1956
|
+
const onResponse = (response) => {
|
|
1957
|
+
if (inScope(response.request())) collector.response(response);
|
|
1958
|
+
};
|
|
1959
|
+
const onFailed = (request) => {
|
|
1960
|
+
if (inScope(request)) collector.failed(request);
|
|
1961
|
+
};
|
|
1962
|
+
const onFinished = (request) => {
|
|
1963
|
+
if (inScope(request)) collector.finished(request);
|
|
1964
|
+
};
|
|
1965
|
+
context.on("request", onRequest);
|
|
1966
|
+
context.on("response", onResponse);
|
|
1967
|
+
context.on("requestfailed", onFailed);
|
|
1968
|
+
context.on("requestfinished", onFinished);
|
|
1969
|
+
this.stopNetwork = () => {
|
|
1970
|
+
context.off("request", onRequest);
|
|
1971
|
+
context.off("response", onResponse);
|
|
1972
|
+
context.off("requestfailed", onFailed);
|
|
1973
|
+
context.off("requestfinished", onFinished);
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
this.observePage(options.page);
|
|
1977
|
+
}
|
|
1978
|
+
setStep(index) {
|
|
1979
|
+
this.stepIndex = index;
|
|
1980
|
+
}
|
|
1981
|
+
nextSequence() {
|
|
1982
|
+
return this.sequence + 1;
|
|
1983
|
+
}
|
|
1984
|
+
lastSequence() {
|
|
1985
|
+
return this.sequence;
|
|
1986
|
+
}
|
|
1987
|
+
/** Drain selected network content and freeze the result before browser teardown. */
|
|
1988
|
+
async finish() {
|
|
1989
|
+
this.stopNetwork?.();
|
|
1990
|
+
this.stopNetwork = undefined;
|
|
1991
|
+
for (const owner of this.stopListeners.keys()) this.releaseListeners(owner);
|
|
1992
|
+
this.pages = new WeakSet();
|
|
1993
|
+
try {
|
|
1994
|
+
await this.network?.finish();
|
|
1995
|
+
} finally {
|
|
1996
|
+
this.sealed = true;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
/** Report selected popup event families with unrecoverable pre-discovery gaps. */
|
|
2000
|
+
limitations() {
|
|
2001
|
+
const popupGaps = [...this.incompleteFamilies].map((family) => `Popup ${family} events before Page discovery are unavailable; later events are retained.`);
|
|
2002
|
+
const gaps = [...popupGaps, ...this.network?.limitations() ?? []];
|
|
2003
|
+
if (this.dropped > 0) gaps.push("Browser event collection reached a selected resource budget; per-kind omissions and affected network transaction IDs are listed in events.omissions, and event coverage is incomplete.");
|
|
2004
|
+
return this.enabled.has("network") && !this.ownsContext ? ["Shared-context network capture excludes requests without a known root or descendant Page frame.", ...gaps] : gaps;
|
|
2005
|
+
}
|
|
2006
|
+
result() {
|
|
2007
|
+
const omittedKinds = new Map([...this.omittedKinds].map(([kind, omission]) => [kind, {
|
|
2008
|
+
count: omission.count,
|
|
2009
|
+
reasons: new Set(omission.reasons)
|
|
2010
|
+
}]));
|
|
2011
|
+
return {
|
|
2012
|
+
retained: this.items.length,
|
|
2013
|
+
dropped: this.dropped,
|
|
2014
|
+
items: this.items,
|
|
2015
|
+
omissions: {
|
|
2016
|
+
by_kind: [...omittedKinds].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([kind, omission]) => ({
|
|
2017
|
+
kind,
|
|
2018
|
+
count: omission.count,
|
|
2019
|
+
reasons: [...omission.reasons].sort()
|
|
2020
|
+
})),
|
|
2021
|
+
network_transactions: [...this.omittedNetwork].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([transaction_id, omission]) => ({
|
|
2022
|
+
transaction_id,
|
|
2023
|
+
omitted_kinds: [...omission.kinds].sort(),
|
|
2024
|
+
reasons: [...omission.reasons].sort()
|
|
2025
|
+
})),
|
|
2026
|
+
network_transaction_range: this.network?.omittedTransactionRange() ?? null
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
push(event) {
|
|
2031
|
+
this.sequence += 1;
|
|
2032
|
+
const cost = allocationCost(event, this.limits.max_event_allocation_bytes) + 128;
|
|
2033
|
+
const reason = this.admissionReason(cost);
|
|
2034
|
+
if (this.sealed || reason !== undefined) {
|
|
2035
|
+
const finalReason = reason ?? "max-events";
|
|
2036
|
+
this.omitEvent(event.kind, finalReason);
|
|
2037
|
+
return {
|
|
2038
|
+
status: "omitted",
|
|
2039
|
+
sequence: this.sequence,
|
|
2040
|
+
reason: finalReason
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
this.retainedCost += cost;
|
|
2044
|
+
const parsed = browserScenarioEventSchema.parse({
|
|
2045
|
+
...event,
|
|
2046
|
+
sequence: this.sequence,
|
|
2047
|
+
step_index: this.stepIndex
|
|
2048
|
+
});
|
|
2049
|
+
this.items.push(parsed);
|
|
2050
|
+
return {
|
|
2051
|
+
status: "retained",
|
|
2052
|
+
sequence: this.sequence
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
admitText(kind, ...values) {
|
|
2056
|
+
return this.admitProducerText(kind, values, false).status === "retained";
|
|
2057
|
+
}
|
|
2058
|
+
/** Admit conservative output cost before running redaction or cloning. */
|
|
2059
|
+
admitProducerText(kind, values, networkMetadata) {
|
|
2060
|
+
let cost = 4096;
|
|
2061
|
+
for (const value of values) {
|
|
2062
|
+
cost += this.secrets.redactionAllocationCost(value.length);
|
|
2063
|
+
}
|
|
2064
|
+
const reason = networkMetadata && cost > this.limits.max_network_metadata_allocation_bytes ? "max-network-metadata-allocation-bytes" : this.admissionReason(cost);
|
|
2065
|
+
if (reason !== undefined) {
|
|
2066
|
+
this.sequence += 1;
|
|
2067
|
+
this.omitEvent(kind, reason);
|
|
2068
|
+
return {
|
|
2069
|
+
status: "omitted",
|
|
2070
|
+
sequence: this.sequence,
|
|
2071
|
+
reason
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
return {
|
|
2075
|
+
status: "retained",
|
|
2076
|
+
sequence: this.sequence + 1
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
admissionReason(cost) {
|
|
2080
|
+
if (this.sealed || this.items.length >= this.limits.max_events) return "max-events";
|
|
2081
|
+
if (cost > this.limits.max_event_allocation_bytes) return "max-event-allocation-bytes";
|
|
2082
|
+
if (cost > this.limits.max_total_event_allocation_bytes - this.retainedCost) return "max-total-event-allocation-bytes";
|
|
2083
|
+
return undefined;
|
|
2084
|
+
}
|
|
2085
|
+
admitContentBody(input) {
|
|
2086
|
+
const kind = "network-content";
|
|
2087
|
+
const eventCost = allocationCost({
|
|
2088
|
+
kind,
|
|
2089
|
+
sequence: this.sequence + 1,
|
|
2090
|
+
step_index: this.stepIndex,
|
|
2091
|
+
transaction_id: input.transactionId,
|
|
2092
|
+
source_event_sequence: input.sourceEventSequence,
|
|
2093
|
+
phase: input.phase,
|
|
2094
|
+
headers: input.headers,
|
|
2095
|
+
body: {
|
|
2096
|
+
state: "captured",
|
|
2097
|
+
representation: input.phase === "request" ? "browser-exposed-request-bytes" : "playwright-response-body-bytes",
|
|
2098
|
+
encoding: "base64",
|
|
2099
|
+
content: null,
|
|
2100
|
+
bytes: input.observedBytes,
|
|
2101
|
+
sha256: "0".repeat(64),
|
|
2102
|
+
media_type: null,
|
|
2103
|
+
redacted: false
|
|
2104
|
+
}
|
|
2105
|
+
}, this.limits.max_event_allocation_bytes) - 64 + input.allocationBytes + (input.mediaType === undefined ? 0 : Math.max(input.mediaType.length * 8 + 2, this.secrets.redactionAllocationCost(input.mediaType.length))) + 128;
|
|
2106
|
+
const reason = this.admissionReason(eventCost);
|
|
2107
|
+
if (reason !== undefined) {
|
|
2108
|
+
this.sequence += 1;
|
|
2109
|
+
this.omitEvent(kind, reason);
|
|
2110
|
+
return {
|
|
2111
|
+
status: "omitted",
|
|
2112
|
+
sequence: this.sequence,
|
|
2113
|
+
reason
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
return {
|
|
2117
|
+
status: "retained",
|
|
2118
|
+
sequence: this.sequence + 1
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
omitEvent(kind, reason) {
|
|
2122
|
+
this.dropped += 1;
|
|
2123
|
+
let omission = this.omittedKinds.get(kind);
|
|
2124
|
+
if (omission === undefined) {
|
|
2125
|
+
omission = {
|
|
2126
|
+
count: 0,
|
|
2127
|
+
reasons: new Set()
|
|
2128
|
+
};
|
|
2129
|
+
this.omittedKinds.set(kind, omission);
|
|
2130
|
+
}
|
|
2131
|
+
omission.count += 1;
|
|
2132
|
+
omission.reasons.add(reason);
|
|
2133
|
+
}
|
|
2134
|
+
omitNetwork(transactionId, kind, reason) {
|
|
2135
|
+
let omission = this.omittedNetwork.get(transactionId);
|
|
2136
|
+
if (omission === undefined) {
|
|
2137
|
+
omission = {
|
|
2138
|
+
kinds: new Set(),
|
|
2139
|
+
reasons: new Set()
|
|
2140
|
+
};
|
|
2141
|
+
this.omittedNetwork.set(transactionId, omission);
|
|
2142
|
+
}
|
|
2143
|
+
omission.kinds.add(kind);
|
|
2144
|
+
omission.reasons.add(reason);
|
|
2145
|
+
}
|
|
2146
|
+
admitOwner(kind) {
|
|
2147
|
+
if (this.stopListeners.size < MAX_LISTENER_OWNERS) return true;
|
|
2148
|
+
this.sequence += 1;
|
|
2149
|
+
this.omitEvent(kind, "max-listener-owners");
|
|
2150
|
+
return false;
|
|
2151
|
+
}
|
|
2152
|
+
retainListener(owner, stop) {
|
|
2153
|
+
let stops = this.stopListeners.get(owner);
|
|
2154
|
+
if (stops === undefined) {
|
|
2155
|
+
stops = new Set();
|
|
2156
|
+
this.stopListeners.set(owner, stops);
|
|
2157
|
+
}
|
|
2158
|
+
stops.add(stop);
|
|
2159
|
+
}
|
|
2160
|
+
releaseListeners(owner) {
|
|
2161
|
+
const stops = this.stopListeners.get(owner);
|
|
2162
|
+
this.stopListeners.delete(owner);
|
|
2163
|
+
for (const stop of stops ?? []) stop();
|
|
2164
|
+
}
|
|
2165
|
+
observePage(page) {
|
|
2166
|
+
if (this.enabled.size > 0) {
|
|
2167
|
+
const onClose = () => {
|
|
2168
|
+
this.releaseListeners(page);
|
|
2169
|
+
};
|
|
2170
|
+
page.on("close", onClose);
|
|
2171
|
+
this.retainListener(page, () => page.off("close", onClose));
|
|
2172
|
+
}
|
|
2173
|
+
if (this.enabled.has("console")) {
|
|
2174
|
+
const onConsole = (message) => this.console(message);
|
|
2175
|
+
page.on("console", onConsole);
|
|
2176
|
+
this.retainListener(page, () => page.off("console", onConsole));
|
|
2177
|
+
}
|
|
2178
|
+
if (this.enabled.has("page-errors")) {
|
|
2179
|
+
const onError = (error) => {
|
|
2180
|
+
if (!this.admitText("page-error", error.message, error.stack ?? "")) return;
|
|
2181
|
+
this.push({
|
|
2182
|
+
kind: "page-error",
|
|
2183
|
+
message: this.secrets.redact(error.message),
|
|
2184
|
+
stack: error.stack === undefined ? null : this.secrets.redact(error.stack)
|
|
2185
|
+
});
|
|
2186
|
+
};
|
|
2187
|
+
page.on("pageerror", onError);
|
|
2188
|
+
this.retainListener(page, () => page.off("pageerror", onError));
|
|
2189
|
+
}
|
|
2190
|
+
if (this.enabled.has("websockets")) {
|
|
2191
|
+
const onWebSocket = (socket) => this.webSocket(socket);
|
|
2192
|
+
page.on("websocket", onWebSocket);
|
|
2193
|
+
this.retainListener(page, () => page.off("websocket", onWebSocket));
|
|
2194
|
+
}
|
|
2195
|
+
if (this.enabled.has("frames")) {
|
|
2196
|
+
const onAttached = (frame) => this.frame("frame-attached", frame);
|
|
2197
|
+
const onDetached = (frame) => this.frame("frame-detached", frame);
|
|
2198
|
+
const onNavigated = (frame) => this.frame("frame-navigated", frame);
|
|
2199
|
+
page.on("frameattached", onAttached);
|
|
2200
|
+
page.on("framedetached", onDetached);
|
|
2201
|
+
page.on("framenavigated", onNavigated);
|
|
2202
|
+
this.retainListener(page, () => page.off("frameattached", onAttached));
|
|
2203
|
+
this.retainListener(page, () => page.off("framedetached", onDetached));
|
|
2204
|
+
this.retainListener(page, () => page.off("framenavigated", onNavigated));
|
|
2205
|
+
}
|
|
2206
|
+
if (this.enabled.has("workers")) {
|
|
2207
|
+
const onWorker = (worker) => this.worker(worker);
|
|
2208
|
+
page.on("worker", onWorker);
|
|
2209
|
+
this.retainListener(page, () => page.off("worker", onWorker));
|
|
2210
|
+
}
|
|
2211
|
+
if (this.enabled.size > 0) {
|
|
2212
|
+
const onPopup = (popup) => this.popup(popup);
|
|
2213
|
+
page.on("popup", onPopup);
|
|
2214
|
+
this.retainListener(page, () => page.off("popup", onPopup));
|
|
2215
|
+
}
|
|
2216
|
+
if (this.enabled.has("downloads")) {
|
|
2217
|
+
const onDownload = (download) => this.download(download);
|
|
2218
|
+
page.on("download", onDownload);
|
|
2219
|
+
this.retainListener(page, () => page.off("download", onDownload));
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
safeUrl(value) {
|
|
2223
|
+
return this.secrets.sanitizeUrl(value);
|
|
2224
|
+
}
|
|
2225
|
+
console(message) {
|
|
2226
|
+
const rawText = message.text();
|
|
2227
|
+
const location = message.location();
|
|
2228
|
+
if (!this.admitText("console", rawText, location.url, message.type())) return;
|
|
2229
|
+
this.push({
|
|
2230
|
+
kind: "console",
|
|
2231
|
+
level: this.secrets.redact(message.type()),
|
|
2232
|
+
text: this.secrets.redact(rawText),
|
|
2233
|
+
url: location.url === "" ? null : this.safeUrl(location.url)
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
webSocket(socket) {
|
|
2237
|
+
if (!this.admitOwner("websocket-opened")) return;
|
|
2238
|
+
if (!this.admitText("websocket-opened", socket.url())) return;
|
|
2239
|
+
const url = this.safeUrl(socket.url());
|
|
2240
|
+
this.push({
|
|
2241
|
+
kind: "websocket-opened",
|
|
2242
|
+
url
|
|
2243
|
+
});
|
|
2244
|
+
const onSent = ({ payload }) => this.webSocketFrame("websocket-frame-sent", url, payload);
|
|
2245
|
+
const onReceived = ({ payload }) => this.webSocketFrame("websocket-frame-received", url, payload);
|
|
2246
|
+
const onClose = () => {
|
|
2247
|
+
this.push({
|
|
2248
|
+
kind: "websocket-closed",
|
|
2249
|
+
url
|
|
2250
|
+
});
|
|
2251
|
+
this.releaseListeners(socket);
|
|
2252
|
+
};
|
|
2253
|
+
socket.on("framesent", onSent);
|
|
2254
|
+
socket.on("framereceived", onReceived);
|
|
2255
|
+
socket.on("close", onClose);
|
|
2256
|
+
this.retainListener(socket, () => socket.off("framesent", onSent));
|
|
2257
|
+
this.retainListener(socket, () => socket.off("framereceived", onReceived));
|
|
2258
|
+
this.retainListener(socket, () => socket.off("close", onClose));
|
|
2259
|
+
}
|
|
2260
|
+
webSocketFrame(kind, url, payload) {
|
|
2261
|
+
const bytes = Buffer.byteLength(payload);
|
|
2262
|
+
const isText = typeof payload === "string";
|
|
2263
|
+
if (!isText) {
|
|
2264
|
+
this.push({
|
|
2265
|
+
kind,
|
|
2266
|
+
url,
|
|
2267
|
+
payload_type: "binary",
|
|
2268
|
+
payload_bytes: bytes,
|
|
2269
|
+
payload_text: null,
|
|
2270
|
+
truncated: false
|
|
2271
|
+
});
|
|
2272
|
+
return;
|
|
2273
|
+
}
|
|
2274
|
+
if (!this.admitText(kind, payload)) return;
|
|
2275
|
+
const text = this.secrets.redact(payload);
|
|
2276
|
+
this.push({
|
|
2277
|
+
kind,
|
|
2278
|
+
url,
|
|
2279
|
+
payload_type: "text",
|
|
2280
|
+
payload_bytes: bytes,
|
|
2281
|
+
payload_text: text,
|
|
2282
|
+
truncated: false
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
frame(kind, frame) {
|
|
2286
|
+
if (!this.admitText(kind, frame.url(), frame.name())) return;
|
|
2287
|
+
this.push({
|
|
2288
|
+
kind,
|
|
2289
|
+
url: frame.url() === "" ? null : this.safeUrl(frame.url()),
|
|
2290
|
+
name: frame.name() === "" ? null : this.secrets.redact(frame.name())
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
worker(worker) {
|
|
2294
|
+
if (!this.admitOwner("worker-created") || !this.admitText("worker-created", worker.url())) return;
|
|
2295
|
+
const details = {
|
|
2296
|
+
url: this.safeUrl(worker.url()),
|
|
2297
|
+
name: null
|
|
2298
|
+
};
|
|
2299
|
+
this.push({
|
|
2300
|
+
kind: "worker-created",
|
|
2301
|
+
...details
|
|
2302
|
+
});
|
|
2303
|
+
const onClose = () => {
|
|
2304
|
+
this.push({
|
|
2305
|
+
kind: "worker-closed",
|
|
2306
|
+
...details
|
|
2307
|
+
});
|
|
2308
|
+
this.releaseListeners(worker);
|
|
2309
|
+
};
|
|
2310
|
+
worker.on("close", onClose);
|
|
2311
|
+
this.retainListener(worker, () => worker.off("close", onClose));
|
|
2312
|
+
}
|
|
2313
|
+
popup(page) {
|
|
2314
|
+
if (this.pages.has(page)) return;
|
|
2315
|
+
if (!this.admitOwner("popup-opened") || !this.admitText("popup-opened", page.url())) return;
|
|
2316
|
+
this.pages.add(page);
|
|
2317
|
+
for (const family of [
|
|
2318
|
+
"frames",
|
|
2319
|
+
"workers",
|
|
2320
|
+
"websockets",
|
|
2321
|
+
"downloads"
|
|
2322
|
+
]) if (this.enabled.has(family)) this.incompleteFamilies.add(family);
|
|
2323
|
+
const opened = {
|
|
2324
|
+
url: page.url() === "" ? null : this.safeUrl(page.url()),
|
|
2325
|
+
name: null
|
|
2326
|
+
};
|
|
2327
|
+
if (this.enabled.has("popups")) {
|
|
2328
|
+
this.push({
|
|
2329
|
+
kind: "popup-opened",
|
|
2330
|
+
...opened
|
|
2331
|
+
});
|
|
2332
|
+
const onClose = () => {
|
|
2333
|
+
if (!this.admitText("popup-closed", page.url())) return;
|
|
2334
|
+
this.push({
|
|
2335
|
+
kind: "popup-closed",
|
|
2336
|
+
url: page.url() === "" ? null : this.safeUrl(page.url()),
|
|
2337
|
+
name: null
|
|
2338
|
+
});
|
|
2339
|
+
};
|
|
2340
|
+
page.on("close", onClose);
|
|
2341
|
+
this.retainListener(page, () => page.off("close", onClose));
|
|
2342
|
+
}
|
|
2343
|
+
this.observePage(page);
|
|
2344
|
+
}
|
|
2345
|
+
download(download) {
|
|
2346
|
+
if (this.admitText("download-cancelled", download.suggestedFilename(), download.url())) this.push({
|
|
2347
|
+
kind: "download-cancelled",
|
|
2348
|
+
suggested_filename: this.secrets.redact(download.suggestedFilename()),
|
|
2349
|
+
url: this.safeUrl(download.url())
|
|
2350
|
+
});
|
|
2351
|
+
void download.cancel().catch((cause) => {
|
|
2352
|
+
void cause;
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
};
|
|
2356
|
+
})))();
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
//#endregion
|
|
2360
|
+
//#region dist/browser/PlaywrightScenarioStorage.js
|
|
2361
|
+
var breakpointResponse, scriptIdentifierResponse, storageKeyResponse, targetInfoResponse, STORAGE_EVENT_METHODS, attachedTargetEvent, targetSessionEvent, nestedMessageEvent, nestedProtocolMessage, executionContextEvent, scriptParsedEvent, pausedEvent, evaluationResponse, STORAGE_CLEANUP_TIMEOUT_MS, PlaywrightScenarioStorage;
|
|
2362
|
+
function init_PlaywrightScenarioStorage() {
|
|
2363
|
+
return (init_PlaywrightScenarioStorage = __esmMin((() => {
|
|
2364
|
+
init_AnalysisCleanupLease();
|
|
2365
|
+
init_browserObservationError();
|
|
2366
|
+
init_PlaywrightExecutionBoundary();
|
|
2367
|
+
breakpointResponse = z.object({ breakpointId: z.string() });
|
|
2368
|
+
scriptIdentifierResponse = z.object({ identifier: z.string() });
|
|
2369
|
+
storageKeyResponse = z.object({ storageKey: z.string() });
|
|
2370
|
+
targetInfoResponse = z.object({ targetInfo: z.object({ targetId: z.string() }) });
|
|
2371
|
+
STORAGE_EVENT_METHODS = new Set([
|
|
2372
|
+
"Runtime.executionContextCreated",
|
|
2373
|
+
"Runtime.executionContextDestroyed",
|
|
2374
|
+
"Runtime.executionContextsCleared",
|
|
2375
|
+
"Debugger.scriptParsed",
|
|
2376
|
+
"Debugger.paused",
|
|
2377
|
+
"Target.attachedToTarget",
|
|
2378
|
+
"Target.detachedFromTarget",
|
|
2379
|
+
"Target.receivedMessageFromTarget"
|
|
2380
|
+
]);
|
|
2381
|
+
attachedTargetEvent = z.object({
|
|
2382
|
+
sessionId: z.string(),
|
|
2383
|
+
targetInfo: z.object({
|
|
2384
|
+
type: z.string(),
|
|
2385
|
+
targetId: z.string()
|
|
2386
|
+
})
|
|
2387
|
+
});
|
|
2388
|
+
targetSessionEvent = z.object({ sessionId: z.string() });
|
|
2389
|
+
nestedMessageEvent = z.object({
|
|
2390
|
+
sessionId: z.string(),
|
|
2391
|
+
message: z.string()
|
|
2392
|
+
});
|
|
2393
|
+
nestedProtocolMessage = z.object({
|
|
2394
|
+
id: z.number().optional(),
|
|
2395
|
+
method: z.string().optional(),
|
|
2396
|
+
params: z.unknown().optional(),
|
|
2397
|
+
result: z.unknown().optional(),
|
|
2398
|
+
error: z.object({ message: z.string() }).optional()
|
|
2399
|
+
});
|
|
2400
|
+
executionContextEvent = z.object({ context: z.object({
|
|
2401
|
+
id: z.number(),
|
|
2402
|
+
origin: z.string(),
|
|
2403
|
+
name: z.string(),
|
|
2404
|
+
auxData: z.object({ frameId: z.string().optional() }).optional()
|
|
2405
|
+
}) });
|
|
2406
|
+
scriptParsedEvent = z.object({
|
|
2407
|
+
scriptId: z.string(),
|
|
2408
|
+
executionContextId: z.number(),
|
|
2409
|
+
url: z.string()
|
|
2410
|
+
});
|
|
2411
|
+
pausedEvent = z.object({ callFrames: z.array(z.object({
|
|
2412
|
+
callFrameId: z.string(),
|
|
2413
|
+
location: z.object({ scriptId: z.string() })
|
|
2414
|
+
})) });
|
|
2415
|
+
evaluationResponse = z.object({ exceptionDetails: z.unknown().optional() });
|
|
2416
|
+
STORAGE_CLEANUP_TIMEOUT_MS = 1e3;
|
|
2417
|
+
PlaywrightScenarioStorage = class PlaywrightScenarioStorage {
|
|
2418
|
+
cdp;
|
|
2419
|
+
signal;
|
|
2420
|
+
#seeds = new Map();
|
|
2421
|
+
#initializedLocal = new Set();
|
|
2422
|
+
#initializedSession = new Set();
|
|
2423
|
+
#targets = new Map();
|
|
2424
|
+
#replies = new Map();
|
|
2425
|
+
#sourceUrl = `rea-storage-${randomUUID()}`;
|
|
2426
|
+
#listeners = [];
|
|
2427
|
+
#sequence = 0;
|
|
2428
|
+
#generation = 0;
|
|
2429
|
+
#closed = false;
|
|
2430
|
+
#cleanupCompleted = false;
|
|
2431
|
+
#loadingStopped = false;
|
|
2432
|
+
#failure;
|
|
2433
|
+
#closePromise;
|
|
2434
|
+
#detachPromise;
|
|
2435
|
+
#rootInitialization;
|
|
2436
|
+
#work = Promise.resolve();
|
|
2437
|
+
#removeListeners = () => undefined;
|
|
2438
|
+
constructor(cdp, signal) {
|
|
2439
|
+
this.cdp = cdp;
|
|
2440
|
+
this.signal = signal;
|
|
2441
|
+
}
|
|
2442
|
+
static async create(storagePage, scenario, secrets, options = {}) {
|
|
2443
|
+
const { signal, retainCleanup } = options;
|
|
2444
|
+
const { context, page } = storagePage;
|
|
2445
|
+
if (scenario.storage.local_storage.length === 0 && scenario.storage.session_storage.length === 0) return undefined;
|
|
2446
|
+
const connection = context.newCDPSession(page);
|
|
2447
|
+
let cdp;
|
|
2448
|
+
try {
|
|
2449
|
+
cdp = await withPlaywrightExecutionBoundary(() => connection, undefined, signal);
|
|
2450
|
+
} catch (cause) {
|
|
2451
|
+
if (signal?.aborted === true) {
|
|
2452
|
+
let detached = false;
|
|
2453
|
+
const lateCleanup = async () => {
|
|
2454
|
+
let session;
|
|
2455
|
+
try {
|
|
2456
|
+
session = await connection;
|
|
2457
|
+
} catch {
|
|
2458
|
+
return;
|
|
2459
|
+
}
|
|
2460
|
+
if (!detached) {
|
|
2461
|
+
await session.detach();
|
|
2462
|
+
detached = true;
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
2465
|
+
const cleanup = new AnalysisCleanupLease(lateCleanup, ["browser_storage_transport"]);
|
|
2466
|
+
retainCleanup?.(cleanup);
|
|
2467
|
+
void withPlaywrightExecutionBoundary(() => cleanup.release(), STORAGE_CLEANUP_TIMEOUT_MS).catch(() => undefined);
|
|
2468
|
+
}
|
|
2469
|
+
throw cause;
|
|
2470
|
+
}
|
|
2471
|
+
const owner = new PlaywrightScenarioStorage(cdp, signal);
|
|
2472
|
+
owner.addSeeds(scenario.storage.local_storage, "local", secrets);
|
|
2473
|
+
owner.addSeeds(scenario.storage.session_storage, "session", secrets);
|
|
2474
|
+
return owner;
|
|
2475
|
+
}
|
|
2476
|
+
async initialize(page, context) {
|
|
2477
|
+
const initialization = this.initializeRoot(page, context);
|
|
2478
|
+
this.#rootInitialization = initialization;
|
|
2479
|
+
await withPlaywrightExecutionBoundary(() => initialization, undefined, this.signal);
|
|
2480
|
+
}
|
|
2481
|
+
async initializeRoot(page, context) {
|
|
2482
|
+
const rootInfo = targetInfoResponse.parse(await this.cdp.send("Target.getTargetInfo"));
|
|
2483
|
+
if (this.#closed) return;
|
|
2484
|
+
const root = this.createTarget(undefined, rootInfo.targetInfo.targetId, (method, params) => this.cdp.send(method, params));
|
|
2485
|
+
this.#targets.set("", root);
|
|
2486
|
+
this.listen(page, context);
|
|
2487
|
+
const ready = this.initializeTarget(root);
|
|
2488
|
+
root.ready = ready;
|
|
2489
|
+
await ready;
|
|
2490
|
+
}
|
|
2491
|
+
addSeeds(blocks, kind, secrets) {
|
|
2492
|
+
for (const { origin, entries } of blocks) {
|
|
2493
|
+
const seed = this.#seeds.get(origin) ?? {
|
|
2494
|
+
local: [],
|
|
2495
|
+
session: []
|
|
2496
|
+
};
|
|
2497
|
+
seed[kind].push(...entries.map(({ name, value }) => [name, secrets.value(value)]));
|
|
2498
|
+
this.#seeds.set(origin, seed);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
listen(page, context) {
|
|
2502
|
+
const browser = context.browser();
|
|
2503
|
+
const detached = () => this.targetDetached("");
|
|
2504
|
+
page.on("close", detached);
|
|
2505
|
+
context.on("close", detached);
|
|
2506
|
+
browser?.on("disconnected", detached);
|
|
2507
|
+
this.#removeListeners = () => {
|
|
2508
|
+
page.off("close", detached);
|
|
2509
|
+
context.off("close", detached);
|
|
2510
|
+
browser?.off("disconnected", detached);
|
|
2511
|
+
};
|
|
2512
|
+
for (const method of [
|
|
2513
|
+
"Runtime.executionContextCreated",
|
|
2514
|
+
"Runtime.executionContextDestroyed",
|
|
2515
|
+
"Runtime.executionContextsCleared",
|
|
2516
|
+
"Debugger.scriptParsed",
|
|
2517
|
+
"Debugger.paused",
|
|
2518
|
+
"Target.attachedToTarget",
|
|
2519
|
+
"Target.detachedFromTarget",
|
|
2520
|
+
"Target.receivedMessageFromTarget"
|
|
2521
|
+
]) {
|
|
2522
|
+
const listener = (params) => this.event("", method, params);
|
|
2523
|
+
this.#listeners.push({
|
|
2524
|
+
method,
|
|
2525
|
+
listener
|
|
2526
|
+
});
|
|
2527
|
+
this.cdp.on(method, listener);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
createTarget(parentId, topLevelTargetId, send) {
|
|
2531
|
+
return {
|
|
2532
|
+
parentId,
|
|
2533
|
+
topLevelTargetId,
|
|
2534
|
+
send,
|
|
2535
|
+
contexts: new Map(),
|
|
2536
|
+
scripts: new Map(),
|
|
2537
|
+
ready: Promise.resolve(),
|
|
2538
|
+
waitingForDebugger: false
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
async initializeTarget(target) {
|
|
2542
|
+
if (this.#closed) return;
|
|
2543
|
+
await target.send("Page.enable");
|
|
2544
|
+
if (this.#closed) return;
|
|
2545
|
+
await target.send("Runtime.enable");
|
|
2546
|
+
if (this.#closed) return;
|
|
2547
|
+
await target.send("Debugger.enable");
|
|
2548
|
+
if (this.#closed) return;
|
|
2549
|
+
breakpointResponse.parse(await target.send("Debugger.setBreakpointByUrl", {
|
|
2550
|
+
url: this.#sourceUrl,
|
|
2551
|
+
lineNumber: 1
|
|
2552
|
+
}));
|
|
2553
|
+
if (this.#closed) return;
|
|
2554
|
+
scriptIdentifierResponse.parse(await target.send("Page.addScriptToEvaluateOnNewDocument", {
|
|
2555
|
+
worldName: this.#sourceUrl,
|
|
2556
|
+
source: `(() => {\n void 0;\n})()\n//# sourceURL=${this.#sourceUrl}`
|
|
2557
|
+
}));
|
|
2558
|
+
if (this.#closed) return;
|
|
2559
|
+
await target.send("Target.setAutoAttach", {
|
|
2560
|
+
autoAttach: true,
|
|
2561
|
+
waitForDebuggerOnStart: true,
|
|
2562
|
+
flatten: false
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
sendObserved(target, method, params) {
|
|
2566
|
+
return withPlaywrightExecutionBoundary(() => target.send(method, params), undefined, this.signal);
|
|
2567
|
+
}
|
|
2568
|
+
event(sessionId, method, params) {
|
|
2569
|
+
if (this.#closed) return;
|
|
2570
|
+
const target = this.#targets.get(sessionId);
|
|
2571
|
+
if (target === undefined) return;
|
|
2572
|
+
try {
|
|
2573
|
+
if (method === "Runtime.executionContextCreated") {
|
|
2574
|
+
const { context } = executionContextEvent.parse(params);
|
|
2575
|
+
if (context.name === this.#sourceUrl) target.contexts.set(context.id, context);
|
|
2576
|
+
} else if (method === "Runtime.executionContextDestroyed") {
|
|
2577
|
+
const { executionContextId } = z.object({ executionContextId: z.number() }).parse(params);
|
|
2578
|
+
target.contexts.delete(executionContextId);
|
|
2579
|
+
} else if (method === "Runtime.executionContextsCleared") {
|
|
2580
|
+
target.contexts.clear();
|
|
2581
|
+
target.scripts.clear();
|
|
2582
|
+
} else if (method === "Debugger.scriptParsed") {
|
|
2583
|
+
const script = scriptParsedEvent.parse(params);
|
|
2584
|
+
if (script.url === this.#sourceUrl) target.scripts.set(script.scriptId, script.executionContextId);
|
|
2585
|
+
} else if (method === "Debugger.paused") {
|
|
2586
|
+
const pause = pausedEvent.parse(params);
|
|
2587
|
+
const frame = pause.callFrames[0];
|
|
2588
|
+
if (frame === undefined || !target.scripts.has(frame.location.scriptId)) return;
|
|
2589
|
+
this.#generation += 1;
|
|
2590
|
+
this.#work = this.#work.then(() => this.seed(target, pause)).catch((cause) => {
|
|
2591
|
+
if (sessionId === "" || this.#targets.get(sessionId) === target) this.fail(cause);
|
|
2592
|
+
});
|
|
2593
|
+
} else if (method === "Target.attachedToTarget") {
|
|
2594
|
+
this.#generation += 1;
|
|
2595
|
+
this.attach(sessionId, attachedTargetEvent.parse(params));
|
|
2596
|
+
} else if (method === "Target.detachedFromTarget") {
|
|
2597
|
+
this.#generation += 1;
|
|
2598
|
+
this.targetDetached(targetSessionEvent.parse(params).sessionId);
|
|
2599
|
+
} else if (method === "Target.receivedMessageFromTarget") {
|
|
2600
|
+
this.nestedMessage(nestedMessageEvent.parse(params));
|
|
2601
|
+
}
|
|
2602
|
+
} catch (cause) {
|
|
2603
|
+
this.fail(cause);
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
nestedMessage(event) {
|
|
2607
|
+
const reply = nestedProtocolMessage.parse(JSON.parse(event.message));
|
|
2608
|
+
if (reply.id !== undefined) {
|
|
2609
|
+
const waiter = this.#replies.get(reply.id);
|
|
2610
|
+
if (waiter?.sessionId !== event.sessionId) return;
|
|
2611
|
+
this.#replies.delete(reply.id);
|
|
2612
|
+
if (reply.error !== undefined) waiter.reject(new Error(reply.error.message));
|
|
2613
|
+
else waiter.resolve(reply.result);
|
|
2614
|
+
return;
|
|
2615
|
+
}
|
|
2616
|
+
if (reply.method !== undefined && STORAGE_EVENT_METHODS.has(reply.method)) this.event(event.sessionId, reply.method, reply.params);
|
|
2617
|
+
}
|
|
2618
|
+
fail(cause) {
|
|
2619
|
+
this.#generation += 1;
|
|
2620
|
+
this.#failure ??= new BrowserObservationError("capture_browser_scenario", "protocol_error", { cause });
|
|
2621
|
+
}
|
|
2622
|
+
async seedPausedFrame(target, frame) {
|
|
2623
|
+
const contextId = target.scripts.get(frame.location.scriptId);
|
|
2624
|
+
const context = contextId === undefined ? undefined : target.contexts.get(contextId);
|
|
2625
|
+
const seed = context === undefined ? undefined : this.#seeds.get(context.origin);
|
|
2626
|
+
if (this.#closed || seed === undefined || context?.auxData?.frameId === undefined) return;
|
|
2627
|
+
const storageKey = storageKeyResponse.parse(await this.sendObserved(target, "Storage.getStorageKey", { frameId: context.auxData.frameId })).storageKey;
|
|
2628
|
+
const sessionKey = JSON.stringify([target.topLevelTargetId, storageKey]);
|
|
2629
|
+
const local = this.#initializedLocal.has(storageKey) || seed.local.length === 0 ? [] : seed.local;
|
|
2630
|
+
const session = this.#initializedSession.has(sessionKey) || seed.session.length === 0 ? [] : seed.session;
|
|
2631
|
+
if (local.length === 0 && session.length === 0) return;
|
|
2632
|
+
const payload = JSON.stringify({
|
|
2633
|
+
local,
|
|
2634
|
+
session
|
|
2635
|
+
}).replaceAll("<", "\\u003c");
|
|
2636
|
+
const response = evaluationResponse.parse(await this.sendObserved(target, "Debugger.evaluateOnCallFrame", {
|
|
2637
|
+
callFrameId: frame.callFrameId,
|
|
2638
|
+
expression: `(() => { const seed = ${payload}; for (const [name, value] of seed.local) localStorage.setItem(name, value); for (const [name, value] of seed.session) sessionStorage.setItem(name, value); })()`,
|
|
2639
|
+
returnByValue: true
|
|
2640
|
+
}));
|
|
2641
|
+
if (response.exceptionDetails !== undefined) throw new BrowserObservationError("capture_browser_scenario", "protocol_error", { detail: "The browser denied initial storage initialization." });
|
|
2642
|
+
if (local.length > 0) this.#initializedLocal.add(storageKey);
|
|
2643
|
+
if (session.length > 0) this.#initializedSession.add(sessionKey);
|
|
2644
|
+
}
|
|
2645
|
+
async seed(target, pause) {
|
|
2646
|
+
const frame = pause.callFrames[0];
|
|
2647
|
+
if (frame === undefined) return;
|
|
2648
|
+
let primaryFailure;
|
|
2649
|
+
let hasPrimaryFailure = false;
|
|
2650
|
+
try {
|
|
2651
|
+
await this.seedPausedFrame(target, frame);
|
|
2652
|
+
} catch (cause) {
|
|
2653
|
+
primaryFailure = cause;
|
|
2654
|
+
hasPrimaryFailure = true;
|
|
2655
|
+
}
|
|
2656
|
+
let resumeFailure;
|
|
2657
|
+
try {
|
|
2658
|
+
await withPlaywrightExecutionBoundary(() => target.send("Debugger.resume"), STORAGE_CLEANUP_TIMEOUT_MS);
|
|
2659
|
+
} catch (cause) {
|
|
2660
|
+
resumeFailure = cause;
|
|
2661
|
+
}
|
|
2662
|
+
if (hasPrimaryFailure && resumeFailure !== undefined) throw new AggregateError([primaryFailure, resumeFailure], "Storage initialization and debugger resume both failed", { cause: primaryFailure });
|
|
2663
|
+
if (this.signal?.aborted === true && resumeFailure === undefined) return;
|
|
2664
|
+
if (hasPrimaryFailure) throw primaryFailure;
|
|
2665
|
+
if (resumeFailure !== undefined) throw resumeFailure;
|
|
2666
|
+
}
|
|
2667
|
+
attach(parentId, event) {
|
|
2668
|
+
const parent = this.#targets.get(parentId);
|
|
2669
|
+
if (parent === undefined) return;
|
|
2670
|
+
const { sessionId, targetInfo } = event;
|
|
2671
|
+
const target = this.createTarget(parentId, event.targetInfo.type === "iframe" ? parent.topLevelTargetId : event.targetInfo.targetId, async (method, params = {}) => {
|
|
2672
|
+
const id = ++this.#sequence;
|
|
2673
|
+
const reply = new Promise((resolve, reject) => this.#replies.set(id, {
|
|
2674
|
+
sessionId,
|
|
2675
|
+
resolve,
|
|
2676
|
+
reject
|
|
2677
|
+
}));
|
|
2678
|
+
try {
|
|
2679
|
+
const sent = parent.send("Target.sendMessageToTarget", {
|
|
2680
|
+
sessionId,
|
|
2681
|
+
message: JSON.stringify({
|
|
2682
|
+
id,
|
|
2683
|
+
method,
|
|
2684
|
+
params
|
|
2685
|
+
})
|
|
2686
|
+
});
|
|
2687
|
+
const [, result] = await Promise.all([sent, reply]);
|
|
2688
|
+
return result;
|
|
2689
|
+
} finally {
|
|
2690
|
+
this.#replies.delete(id);
|
|
2691
|
+
}
|
|
2692
|
+
});
|
|
2693
|
+
target.waitingForDebugger = true;
|
|
2694
|
+
this.#targets.set(sessionId, target);
|
|
2695
|
+
target.ready = (async () => {
|
|
2696
|
+
try {
|
|
2697
|
+
if (!this.#closed && (targetInfo.type === "iframe" || targetInfo.type === "page")) await this.initializeTarget(target);
|
|
2698
|
+
} catch (cause) {
|
|
2699
|
+
if (this.signal?.aborted !== true && !this.#closed && this.#targets.get(sessionId) === target) this.fail(cause);
|
|
2700
|
+
}
|
|
2701
|
+
if (this.#targets.get(sessionId) !== target) return;
|
|
2702
|
+
try {
|
|
2703
|
+
await withPlaywrightExecutionBoundary(() => target.send("Runtime.runIfWaitingForDebugger"), STORAGE_CLEANUP_TIMEOUT_MS);
|
|
2704
|
+
target.waitingForDebugger = false;
|
|
2705
|
+
} catch (cause) {
|
|
2706
|
+
if (this.signal?.aborted !== true && !this.#closed && this.#targets.get(sessionId) === target) this.fail(cause);
|
|
2707
|
+
}
|
|
2708
|
+
})();
|
|
2709
|
+
}
|
|
2710
|
+
targetDetached(sessionId) {
|
|
2711
|
+
for (const [id, target] of this.#targets) if (target.parentId === sessionId) this.targetDetached(id);
|
|
2712
|
+
this.#targets.delete(sessionId);
|
|
2713
|
+
for (const [id, reply] of this.#replies) if (reply.sessionId === sessionId) {
|
|
2714
|
+
this.#replies.delete(id);
|
|
2715
|
+
reply.reject(new BrowserObservationError("capture_browser_scenario", "disconnected"));
|
|
2716
|
+
}
|
|
2717
|
+
this.#generation += 1;
|
|
2718
|
+
}
|
|
2719
|
+
async settle() {
|
|
2720
|
+
for (;;) {
|
|
2721
|
+
const generation = this.#generation;
|
|
2722
|
+
const work = this.#work;
|
|
2723
|
+
const targets = [...this.#targets.entries()];
|
|
2724
|
+
await withPlaywrightExecutionBoundary(() => Promise.all(targets.map(([, target]) => target.ready)), undefined, this.signal);
|
|
2725
|
+
await withPlaywrightExecutionBoundary(() => work, undefined, this.signal);
|
|
2726
|
+
await Promise.resolve();
|
|
2727
|
+
if (this.#failure !== undefined) throw this.#failure;
|
|
2728
|
+
if (generation === this.#generation && work === this.#work && targets.every(([id, target]) => this.#targets.get(id) === target)) return;
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
close(stopLoading = false) {
|
|
2732
|
+
if (this.#cleanupCompleted) return Promise.resolve({ loadingStopped: this.#loadingStopped });
|
|
2733
|
+
if (this.#closePromise !== undefined) return this.#closePromise;
|
|
2734
|
+
const closing = this.closeResources(stopLoading).catch((cause) => {
|
|
2735
|
+
throw new BrowserObservationError("capture_browser_scenario", "cleanup_failed", {
|
|
2736
|
+
cause,
|
|
2737
|
+
cleanup: {
|
|
2738
|
+
reason: cause instanceof Error ? cause.message : String(cause),
|
|
2739
|
+
resources: ["browser_transport", "browser_storage_bootstrap"]
|
|
2740
|
+
}
|
|
2741
|
+
});
|
|
2742
|
+
});
|
|
2743
|
+
this.#closePromise = closing;
|
|
2744
|
+
void closing.catch(() => {
|
|
2745
|
+
if (this.#closePromise === closing) this.#closePromise = undefined;
|
|
2746
|
+
});
|
|
2747
|
+
return closing;
|
|
2748
|
+
}
|
|
2749
|
+
async closeResources(stopLoading) {
|
|
2750
|
+
this.#closed = true;
|
|
2751
|
+
let stopLoadingFailure;
|
|
2752
|
+
if (stopLoading && !this.#loadingStopped) {
|
|
2753
|
+
try {
|
|
2754
|
+
const root = this.#targets.get("");
|
|
2755
|
+
if (root !== undefined) {
|
|
2756
|
+
await withPlaywrightExecutionBoundary(() => root.send("Page.stopLoading"), STORAGE_CLEANUP_TIMEOUT_MS);
|
|
2757
|
+
this.#loadingStopped = true;
|
|
2758
|
+
}
|
|
2759
|
+
} catch (cause) {
|
|
2760
|
+
stopLoadingFailure = { cause };
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
const work = this.#work;
|
|
2764
|
+
const rootInitialization = this.#rootInitialization;
|
|
2765
|
+
const targets = [...this.#targets.values()];
|
|
2766
|
+
try {
|
|
2767
|
+
await withPlaywrightExecutionBoundary(() => Promise.all([
|
|
2768
|
+
work.catch(() => undefined),
|
|
2769
|
+
...rootInitialization === undefined ? [] : [rootInitialization.catch(() => undefined)],
|
|
2770
|
+
...targets.map((target) => target.ready.catch(() => undefined))
|
|
2771
|
+
]), STORAGE_CLEANUP_TIMEOUT_MS);
|
|
2772
|
+
} catch {}
|
|
2773
|
+
let detach = this.#detachPromise;
|
|
2774
|
+
if (detach === undefined) {
|
|
2775
|
+
detach = Promise.resolve().then(() => this.cdp.detach());
|
|
2776
|
+
this.#detachPromise = detach;
|
|
2777
|
+
void detach.catch(() => {
|
|
2778
|
+
if (this.#detachPromise === detach) this.#detachPromise = undefined;
|
|
2779
|
+
});
|
|
2780
|
+
}
|
|
2781
|
+
await withPlaywrightExecutionBoundary(() => detach, STORAGE_CLEANUP_TIMEOUT_MS);
|
|
2782
|
+
for (const { method, listener } of this.#listeners) this.cdp.off(method, listener);
|
|
2783
|
+
this.#removeListeners();
|
|
2784
|
+
for (const reply of this.#replies.values()) reply.reject(new BrowserObservationError("capture_browser_scenario", "disconnected"));
|
|
2785
|
+
this.#targets.clear();
|
|
2786
|
+
this.#replies.clear();
|
|
2787
|
+
this.#cleanupCompleted = true;
|
|
2788
|
+
if (stopLoadingFailure !== undefined) throw stopLoadingFailure.cause;
|
|
2789
|
+
return { loadingStopped: this.#loadingStopped };
|
|
2790
|
+
}
|
|
2791
|
+
};
|
|
2792
|
+
})))();
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
//#endregion
|
|
2796
|
+
//#region dist/browser/PlaywrightScenarioServiceWorkers.js
|
|
2797
|
+
var OPERATION$1, POLICY_CLEANUP_CONFIRMATION_TIMEOUT_MS, scriptResponse, restorationResponse, attachedEvent, detachedEvent, PlaywrightScenarioServiceWorkers;
|
|
2798
|
+
function init_PlaywrightScenarioServiceWorkers() {
|
|
2799
|
+
return (init_PlaywrightScenarioServiceWorkers = __esmMin((() => {
|
|
2800
|
+
init_browserObservation();
|
|
2801
|
+
init_browserObservationError();
|
|
2802
|
+
init_CdpConnection();
|
|
2803
|
+
init_CdpEndpoint();
|
|
2804
|
+
init_CdpTargetSession();
|
|
2805
|
+
init_PlaywrightExecutionBoundary();
|
|
2806
|
+
OPERATION$1 = "capture_browser_scenario";
|
|
2807
|
+
POLICY_CLEANUP_CONFIRMATION_TIMEOUT_MS = 5e3;
|
|
2808
|
+
scriptResponse = z.object({ identifier: z.string() });
|
|
2809
|
+
restorationResponse = z.object({ result: z.object({ value: z.literal("policy_owned").nullable() }) });
|
|
2810
|
+
attachedEvent = z.object({
|
|
2811
|
+
sessionId: z.string(),
|
|
2812
|
+
targetInfo: z.object({ type: z.string() })
|
|
2813
|
+
});
|
|
2814
|
+
detachedEvent = z.object({ sessionId: z.string() });
|
|
2815
|
+
PlaywrightScenarioServiceWorkers = class {
|
|
2816
|
+
page;
|
|
2817
|
+
endpoint;
|
|
2818
|
+
targetId;
|
|
2819
|
+
marker = JSON.stringify(`rea-service-workers-${randomUUID()}`);
|
|
2820
|
+
restoreKey = JSON.stringify(`rea-restore-${randomUUID()}`);
|
|
2821
|
+
secret = JSON.stringify(randomUUID());
|
|
2822
|
+
#initialization;
|
|
2823
|
+
#restoration;
|
|
2824
|
+
#session;
|
|
2825
|
+
#targets = new Map();
|
|
2826
|
+
#closed = false;
|
|
2827
|
+
#released = false;
|
|
2828
|
+
#detached = false;
|
|
2829
|
+
#loadingStopped = false;
|
|
2830
|
+
#removeListener;
|
|
2831
|
+
#setup = new AbortController();
|
|
2832
|
+
constructor(page, endpoint, targetId) {
|
|
2833
|
+
this.page = page;
|
|
2834
|
+
this.endpoint = endpoint;
|
|
2835
|
+
this.targetId = targetId;
|
|
2836
|
+
}
|
|
2837
|
+
initialize() {
|
|
2838
|
+
return this.#initialization ??= this.install();
|
|
2839
|
+
}
|
|
2840
|
+
async install() {
|
|
2841
|
+
this.#session = await withCdpDiscoveryDeadline(OPERATION$1, this.#setup.signal, async (signal) => {
|
|
2842
|
+
await withPlaywrightExecutionBoundary(() => this.assertBlocked(), undefined, signal);
|
|
2843
|
+
const opened = await openCdpEndpoint(browserObservationEndpointSchema.parse(this.endpoint), OPERATION$1, signal);
|
|
2844
|
+
const target = opened.discovery.targets.find(({ id }) => id === this.targetId);
|
|
2845
|
+
if (target === undefined) {
|
|
2846
|
+
await opened.connection?.close();
|
|
2847
|
+
throw new BrowserObservationError(OPERATION$1, "target_not_found");
|
|
2848
|
+
}
|
|
2849
|
+
const connection = opened.connection ?? await CdpConnection.connect(opened.discovery.webSocket.url, OPERATION$1, signal);
|
|
2850
|
+
return await attachCdpTargetSession(connection, target, OPERATION$1, signal);
|
|
2851
|
+
});
|
|
2852
|
+
const connection = this.#session.connection;
|
|
2853
|
+
this.#removeListener = connection.onEvent((event) => {
|
|
2854
|
+
if (event.method === "Target.attachedToTarget" && this.#targets.has(event.sessionId ?? "")) {
|
|
2855
|
+
const { sessionId, targetInfo } = attachedEvent.parse(event.params);
|
|
2856
|
+
if (targetInfo.type === "iframe") this.addTarget(sessionId);
|
|
2857
|
+
} else if (event.method === "Target.detachedFromTarget") {
|
|
2858
|
+
const id = detachedEvent.parse(event.params).sessionId;
|
|
2859
|
+
this.#targets.get(id)?.markDetached();
|
|
2860
|
+
this.#targets.delete(id);
|
|
2861
|
+
if (id === this.#session?.sessionId) this.#detached = true;
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2864
|
+
const id = this.#session.sessionId;
|
|
2865
|
+
if (id === undefined) throw new BrowserObservationError(OPERATION$1, "protocol_error");
|
|
2866
|
+
this.addTarget(id);
|
|
2867
|
+
await this.settle();
|
|
2868
|
+
await withPlaywrightExecutionBoundary(() => this.assertBlocked(), undefined, this.#setup.signal);
|
|
2869
|
+
}
|
|
2870
|
+
addTarget(id) {
|
|
2871
|
+
this.#targets.get(id)?.markDetached();
|
|
2872
|
+
let markDetached = () => undefined;
|
|
2873
|
+
const detached = new Promise((resolve) => {
|
|
2874
|
+
markDetached = resolve;
|
|
2875
|
+
});
|
|
2876
|
+
const target = {
|
|
2877
|
+
id,
|
|
2878
|
+
detached,
|
|
2879
|
+
markDetached,
|
|
2880
|
+
ready: Promise.resolve()
|
|
2881
|
+
};
|
|
2882
|
+
this.#targets.set(id, target);
|
|
2883
|
+
const ready = this.initializeTarget(target);
|
|
2884
|
+
target.ready = ready;
|
|
2885
|
+
void ready.catch(() => undefined);
|
|
2886
|
+
}
|
|
2887
|
+
async initializeTarget(target) {
|
|
2888
|
+
try {
|
|
2889
|
+
if (this.#closed) return;
|
|
2890
|
+
await this.send(target.id, "Page.enable");
|
|
2891
|
+
if (this.#closed) return;
|
|
2892
|
+
const added = scriptResponse.parse(await this.send(target.id, "Page.addScriptToEvaluateOnNewDocument", {
|
|
2893
|
+
runImmediately: true,
|
|
2894
|
+
source: `(() => {
|
|
2895
|
+
if (!("serviceWorker" in navigator)) return;
|
|
2896
|
+
const prototype = ServiceWorkerContainer.prototype;
|
|
2897
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, "register");
|
|
2898
|
+
if (typeof descriptor?.value === "function" && Object.hasOwn(descriptor.value, Symbol.for(${this.marker}))) return;
|
|
2899
|
+
const register = () => Promise.reject(new Error("service workers are blocked by scenario policy"));
|
|
2900
|
+
Object.defineProperty(register, Symbol.for(${this.marker}), { value: true });
|
|
2901
|
+
const secret = ${this.secret};
|
|
2902
|
+
Object.defineProperty(globalThis, ${this.restoreKey}, { configurable: true, value: (provided) => {
|
|
2903
|
+
if (provided !== secret) return false;
|
|
2904
|
+
if (Object.getOwnPropertyDescriptor(prototype, "register")?.value === register) {
|
|
2905
|
+
if (descriptor === undefined) delete prototype.register;
|
|
2906
|
+
else Object.defineProperty(prototype, "register", descriptor);
|
|
2907
|
+
}
|
|
2908
|
+
delete globalThis[${this.restoreKey}];
|
|
2909
|
+
return true;
|
|
2910
|
+
}});
|
|
2911
|
+
Object.defineProperty(prototype, "register", { ...descriptor, configurable: true, value: register });
|
|
2912
|
+
})()`
|
|
2913
|
+
}));
|
|
2914
|
+
target.identifier = added.identifier;
|
|
2915
|
+
if (!this.#closed) await this.send(target.id, "Target.setAutoAttach", {
|
|
2916
|
+
autoAttach: true,
|
|
2917
|
+
waitForDebuggerOnStart: true,
|
|
2918
|
+
flatten: true,
|
|
2919
|
+
filter: [{
|
|
2920
|
+
type: "iframe",
|
|
2921
|
+
exclude: false
|
|
2922
|
+
}, { exclude: true }]
|
|
2923
|
+
});
|
|
2924
|
+
} finally {
|
|
2925
|
+
if (this.#targets.has(target.id) && target.id !== this.#session?.sessionId) await this.send(target.id, "Runtime.runIfWaitingForDebugger");
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
send(id, method, params = {}) {
|
|
2929
|
+
if (this.#session === undefined) throw new BrowserObservationError(OPERATION$1, "disconnected");
|
|
2930
|
+
return this.#session.connection.send(method, params, id);
|
|
2931
|
+
}
|
|
2932
|
+
async settle() {
|
|
2933
|
+
for (;;) {
|
|
2934
|
+
const targets = [...this.#targets.values()];
|
|
2935
|
+
await Promise.all(targets.map((target) => this.settleTarget(target)));
|
|
2936
|
+
if (targets.length === this.#targets.size && targets.every((target) => this.#targets.get(target.id) === target)) return;
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
async settleTarget(target) {
|
|
2940
|
+
try {
|
|
2941
|
+
await Promise.race([target.ready, target.detached]);
|
|
2942
|
+
} catch (cause) {
|
|
2943
|
+
if (this.#targets.get(target.id) === target) throw cause;
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
async settleTargetForRestore(target) {
|
|
2947
|
+
try {
|
|
2948
|
+
await Promise.race([target.ready, target.detached]);
|
|
2949
|
+
} catch {}
|
|
2950
|
+
}
|
|
2951
|
+
restorationScript() {
|
|
2952
|
+
return `(() => {
|
|
2953
|
+
const restore = globalThis[${this.restoreKey}];
|
|
2954
|
+
if (typeof restore === "function" && restore(${this.secret}) === true) return null;
|
|
2955
|
+
const register = globalThis.ServiceWorkerContainer?.prototype.register;
|
|
2956
|
+
return typeof register === "function" && Object.hasOwn(register, Symbol.for(${this.marker}))
|
|
2957
|
+
? "policy_owned"
|
|
2958
|
+
: null;
|
|
2959
|
+
})()`;
|
|
2960
|
+
}
|
|
2961
|
+
async restoreMainFrame(id) {
|
|
2962
|
+
const { result } = restorationResponse.parse(await this.send(id, "Runtime.evaluate", {
|
|
2963
|
+
expression: this.restorationScript(),
|
|
2964
|
+
returnByValue: true
|
|
2965
|
+
}));
|
|
2966
|
+
if (result.value === "policy_owned") throw new Error("service-worker policy restoration could not be confirmed");
|
|
2967
|
+
}
|
|
2968
|
+
async restorePlaywrightFrame(frame) {
|
|
2969
|
+
try {
|
|
2970
|
+
const failure = await frame.evaluate(this.restorationScript());
|
|
2971
|
+
if (failure === "policy_owned") throw new Error("service-worker policy restoration could not be confirmed");
|
|
2972
|
+
if (failure !== null) throw new BrowserObservationError(OPERATION$1, "protocol_error");
|
|
2973
|
+
} catch (cause) {
|
|
2974
|
+
if (!this.page.isClosed() && !frame.isDetached()) throw cause;
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
async stopMainFrame(frame) {
|
|
2978
|
+
try {
|
|
2979
|
+
await frame.evaluate("globalThis.stop()");
|
|
2980
|
+
this.#loadingStopped = true;
|
|
2981
|
+
} catch (cause) {
|
|
2982
|
+
if (!this.page.isClosed() && !frame.isDetached()) throw cause;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
async assertBlocked() {
|
|
2986
|
+
if (this.#session !== undefined) await this.settle();
|
|
2987
|
+
for (const frame of this.page.frames()) {
|
|
2988
|
+
let failure;
|
|
2989
|
+
try {
|
|
2990
|
+
failure = await frame.evaluate(`(async () => {
|
|
2991
|
+
if (!("serviceWorker" in navigator)) return null;
|
|
2992
|
+
const serviceWorker = navigator.serviceWorker;
|
|
2993
|
+
if (${this.#session !== undefined} &&
|
|
2994
|
+
(!Object.hasOwn(serviceWorker.register, Symbol.for(${this.marker})) ||
|
|
2995
|
+
typeof globalThis[${this.restoreKey}] !== "function")) return "policy_unprotected";
|
|
2996
|
+
if (serviceWorker.controller !== null) return "service_worker_blocked";
|
|
2997
|
+
return (await serviceWorker.getRegistrations()).length > 0
|
|
2998
|
+
? "service_worker_blocked"
|
|
2999
|
+
: null;
|
|
3000
|
+
})()`);
|
|
3001
|
+
} catch (cause) {
|
|
3002
|
+
if (frame.isDetached()) continue;
|
|
3003
|
+
throw cause;
|
|
3004
|
+
}
|
|
3005
|
+
if (failure === "policy_unprotected") throw new BrowserObservationError(OPERATION$1, "target_not_allowed");
|
|
3006
|
+
if (failure === "service_worker_blocked") throw new BrowserObservationError(OPERATION$1, "service_worker_blocked");
|
|
3007
|
+
if (failure !== null) throw new BrowserObservationError(OPERATION$1, "protocol_error");
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
close(stopLoading = false) {
|
|
3011
|
+
this.#closed = true;
|
|
3012
|
+
this.#setup.abort();
|
|
3013
|
+
const restoration = this.#restoration ??= this.restore(stopLoading);
|
|
3014
|
+
void restoration.then(() => {
|
|
3015
|
+
if (this.#restoration === restoration) this.#restoration = undefined;
|
|
3016
|
+
}, () => {
|
|
3017
|
+
if (this.#restoration === restoration) this.#restoration = undefined;
|
|
3018
|
+
});
|
|
3019
|
+
return withPlaywrightExecutionBoundary(() => restoration, POLICY_CLEANUP_CONFIRMATION_TIMEOUT_MS);
|
|
3020
|
+
}
|
|
3021
|
+
async restore(stopLoading) {
|
|
3022
|
+
await this.#initialization?.catch(() => undefined);
|
|
3023
|
+
if (this.#released) return;
|
|
3024
|
+
const session = this.#session;
|
|
3025
|
+
if (session === undefined) return;
|
|
3026
|
+
if (!this.page.isClosed()) {
|
|
3027
|
+
const mainFrame = this.page.mainFrame();
|
|
3028
|
+
if (stopLoading && !this.#loadingStopped) {
|
|
3029
|
+
if (!this.#detached && session.sessionId !== undefined) {
|
|
3030
|
+
await this.send(session.sessionId, "Page.stopLoading");
|
|
3031
|
+
this.#loadingStopped = true;
|
|
3032
|
+
} else {
|
|
3033
|
+
await this.stopMainFrame(mainFrame);
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
await Promise.all([...this.#targets.values()].map((target) => this.settleTargetForRestore(target)));
|
|
3037
|
+
for (const target of this.#targets.values()) {
|
|
3038
|
+
if (!this.#detached && target.identifier !== undefined) {
|
|
3039
|
+
try {
|
|
3040
|
+
await this.send(target.id, "Page.removeScriptToEvaluateOnNewDocument", { identifier: target.identifier });
|
|
3041
|
+
} catch (cause) {
|
|
3042
|
+
if (this.#targets.get(target.id) === target) throw cause;
|
|
3043
|
+
}
|
|
3044
|
+
delete target.identifier;
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
if (!this.#detached && session.sessionId !== undefined) {
|
|
3048
|
+
await this.restoreMainFrame(session.sessionId);
|
|
3049
|
+
} else {
|
|
3050
|
+
await this.restorePlaywrightFrame(mainFrame);
|
|
3051
|
+
}
|
|
3052
|
+
for (const frame of this.page.frames()) {
|
|
3053
|
+
if (frame === mainFrame) continue;
|
|
3054
|
+
if (frame.isDetached()) continue;
|
|
3055
|
+
if (frame.url().length === 0) continue;
|
|
3056
|
+
await this.restorePlaywrightFrame(frame);
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
if (!this.page.isClosed() && !this.#detached && session.sessionId !== undefined) {
|
|
3060
|
+
await session.connection.send("Target.detachFromTarget", { sessionId: session.sessionId });
|
|
3061
|
+
this.#detached = true;
|
|
3062
|
+
}
|
|
3063
|
+
this.#removeListener?.();
|
|
3064
|
+
await session.connection.close();
|
|
3065
|
+
this.#released = true;
|
|
3066
|
+
}
|
|
3067
|
+
};
|
|
3068
|
+
})))();
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
//#endregion
|
|
3072
|
+
//#region dist/browser/PlaywrightScenarioSession.js
|
|
3073
|
+
var OPERATION, throwIfScenarioCancelled, throwCleanupFailures, installCookies, initializePage, PlaywrightScenarioSession;
|
|
3074
|
+
function init_PlaywrightScenarioSession() {
|
|
3075
|
+
return (init_PlaywrightScenarioSession = __esmMin((() => {
|
|
3076
|
+
init_AnalysisCleanupLease();
|
|
3077
|
+
init_analysisErrorBase();
|
|
3078
|
+
init_browserObservationError();
|
|
3079
|
+
init_BrowserScenarioSecrets();
|
|
3080
|
+
init_PlaywrightScenarioBrowser();
|
|
3081
|
+
init_PlaywrightScenarioActions();
|
|
3082
|
+
init_PlaywrightScenarioArtifacts();
|
|
3083
|
+
init_PlaywrightScenarioEvents();
|
|
3084
|
+
init_PlaywrightScenarioStorage();
|
|
3085
|
+
init_PlaywrightScenarioServiceWorkers();
|
|
3086
|
+
init_PlaywrightExecutionBoundary();
|
|
3087
|
+
init_BrowserScenarioPartialObservation();
|
|
3088
|
+
OPERATION = "capture_browser_scenario";
|
|
3089
|
+
throwIfScenarioCancelled = (signal) => {
|
|
3090
|
+
if (signal?.aborted === true) throw new BrowserObservationError(OPERATION, "cancelled", { cause: signal?.reason });
|
|
3091
|
+
};
|
|
3092
|
+
throwCleanupFailures = (failures) => {
|
|
3093
|
+
if (failures.length === 1) throw failures[0];
|
|
3094
|
+
if (failures.length > 1) throw new AggregateError(failures, "Browser scenario cleanup failed");
|
|
3095
|
+
};
|
|
3096
|
+
installCookies = async (context, scenario, secrets) => {
|
|
3097
|
+
await context.addCookies(scenario.storage.cookies.map((cookie) => ({
|
|
3098
|
+
name: cookie.name,
|
|
3099
|
+
value: secrets.value(cookie.value),
|
|
3100
|
+
url: secrets.url(cookie.destination),
|
|
3101
|
+
httpOnly: cookie.http_only,
|
|
3102
|
+
secure: cookie.secure,
|
|
3103
|
+
sameSite: cookie.same_site
|
|
3104
|
+
})));
|
|
3105
|
+
};
|
|
3106
|
+
initializePage = async (context, scenario, secrets) => {
|
|
3107
|
+
context.setDefaultTimeout(0);
|
|
3108
|
+
context.setDefaultNavigationTimeout(0);
|
|
3109
|
+
await installCookies(context, scenario, secrets);
|
|
3110
|
+
};
|
|
3111
|
+
PlaywrightScenarioSession = class PlaywrightScenarioSession {
|
|
3112
|
+
opened;
|
|
3113
|
+
mode;
|
|
3114
|
+
processOwnership;
|
|
3115
|
+
product = "Chromium";
|
|
3116
|
+
version;
|
|
3117
|
+
initialUrl;
|
|
3118
|
+
secrets;
|
|
3119
|
+
eventCapture;
|
|
3120
|
+
storage;
|
|
3121
|
+
serviceWorkers;
|
|
3122
|
+
signal;
|
|
3123
|
+
#storageReleased = false;
|
|
3124
|
+
#stopLoading = false;
|
|
3125
|
+
cleanupLease;
|
|
3126
|
+
#policyStopsLoading = false;
|
|
3127
|
+
constructor(opened, options) {
|
|
3128
|
+
this.opened = opened;
|
|
3129
|
+
this.mode = options.mode;
|
|
3130
|
+
this.processOwnership = options.mode === "launch" ? "provider-owned" : "external";
|
|
3131
|
+
this.secrets = options.secrets;
|
|
3132
|
+
this.eventCapture = options.eventCapture;
|
|
3133
|
+
this.storage = options.storage;
|
|
3134
|
+
this.serviceWorkers = options.serviceWorkers;
|
|
3135
|
+
this.signal = options.signal;
|
|
3136
|
+
this.version = opened.browser.version();
|
|
3137
|
+
this.initialUrl = opened.page.url();
|
|
3138
|
+
this.cleanupLease = new AnalysisCleanupLease(async () => {
|
|
3139
|
+
await this.#closeResources();
|
|
3140
|
+
}, { get cleanupResources() {
|
|
3141
|
+
return opened.cleanup.cleanupResources;
|
|
3142
|
+
} });
|
|
3143
|
+
}
|
|
3144
|
+
static async open(scenario, environment, options) {
|
|
3145
|
+
throwIfScenarioCancelled(options.signal);
|
|
3146
|
+
const secrets = BrowserScenarioSecrets.resolve(scenario, environment);
|
|
3147
|
+
if (secrets === undefined) throw new BrowserObservationError(OPERATION, "secret_unavailable");
|
|
3148
|
+
const startedAt = performance.now();
|
|
3149
|
+
const openingCleanup = new Set();
|
|
3150
|
+
const opening = openPlaywrightScenarioBrowser(scenario, environment, {
|
|
3151
|
+
signal: options.signal,
|
|
3152
|
+
retainCleanup: (lease) => {
|
|
3153
|
+
openingCleanup.add(lease);
|
|
3154
|
+
options.retainCleanup?.(lease);
|
|
3155
|
+
}
|
|
3156
|
+
});
|
|
3157
|
+
let opened;
|
|
3158
|
+
try {
|
|
3159
|
+
opened = await withPlaywrightExecutionBoundary(() => opening, undefined, options.signal);
|
|
3160
|
+
} catch (cause) {
|
|
3161
|
+
let lateOpened;
|
|
3162
|
+
let openingFailure;
|
|
3163
|
+
const cleanup = new AnalysisCleanupLease(async () => {
|
|
3164
|
+
try {
|
|
3165
|
+
lateOpened = await opening;
|
|
3166
|
+
} catch (cause) {
|
|
3167
|
+
openingFailure = cause instanceof AnalysisError && !(options.signal?.aborted === true && cause === options.signal.reason) ? cause : undefined;
|
|
3168
|
+
const results = await Promise.allSettled([...openingCleanup].map((lease) => lease.release()));
|
|
3169
|
+
const failures = results.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
3170
|
+
throwCleanupFailures(failures);
|
|
3171
|
+
if (openingFailure?.cleanupIncomplete === true) throw openingFailure;
|
|
3172
|
+
return;
|
|
3173
|
+
}
|
|
3174
|
+
await lateOpened.cleanup.release();
|
|
3175
|
+
}, { get cleanupResources() {
|
|
3176
|
+
return lateOpened?.cleanup.cleanupResources ?? openingFailure?.cleanupResources;
|
|
3177
|
+
} });
|
|
3178
|
+
options.retainCleanup?.(cleanup);
|
|
3179
|
+
void withPlaywrightExecutionBoundary(() => cleanup.release(), 1e3).catch(() => undefined);
|
|
3180
|
+
throw cause;
|
|
3181
|
+
}
|
|
3182
|
+
const session = await this.initializeSession(opened, scenario, secrets, options);
|
|
3183
|
+
try {
|
|
3184
|
+
await withPlaywrightExecutionBoundary(() => opened.page.goto(secrets.url(scenario.start_url), {
|
|
3185
|
+
waitUntil: "load",
|
|
3186
|
+
timeout: 0
|
|
3187
|
+
}), undefined, options.signal);
|
|
3188
|
+
await withPlaywrightExecutionBoundary(() => session.serviceWorkers?.assertBlocked() ?? Promise.resolve(), undefined, options.signal);
|
|
3189
|
+
await withPlaywrightExecutionBoundary(() => session.storage?.settle() ?? Promise.resolve(), undefined, options.signal);
|
|
3190
|
+
return session;
|
|
3191
|
+
} catch (cause) {
|
|
3192
|
+
let cleanup;
|
|
3193
|
+
let cleanupFailure;
|
|
3194
|
+
try {
|
|
3195
|
+
cleanup = await session.close(true);
|
|
3196
|
+
} catch (failure) {
|
|
3197
|
+
cleanup = "incomplete";
|
|
3198
|
+
cleanupFailure = { cause: failure };
|
|
3199
|
+
options.retainCleanup?.(session.cleanupLease);
|
|
3200
|
+
}
|
|
3201
|
+
throw browserScenarioOperationFailure(cause, {
|
|
3202
|
+
kind: "browser-scenario-observation",
|
|
3203
|
+
capture: browserScenarioCaptureData({
|
|
3204
|
+
session,
|
|
3205
|
+
scenario,
|
|
3206
|
+
startedAt,
|
|
3207
|
+
steps: [],
|
|
3208
|
+
cleanup,
|
|
3209
|
+
limitations: ["Scenario navigation failed before the initial state was captured."]
|
|
3210
|
+
})
|
|
3211
|
+
}, cleanupFailure);
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
static async initializeSession(opened, scenario, secrets, options) {
|
|
3215
|
+
let events;
|
|
3216
|
+
let storage;
|
|
3217
|
+
const serviceWorkers = scenario.browser.mode === "connect" && scenario.environment.service_workers === "block" ? new PlaywrightScenarioServiceWorkers(opened.page, scenario.browser.cdp_endpoint, scenario.browser.target_id) : undefined;
|
|
3218
|
+
try {
|
|
3219
|
+
await withPlaywrightExecutionBoundary(async () => {
|
|
3220
|
+
await serviceWorkers?.initialize();
|
|
3221
|
+
await initializePage(opened.context, scenario, secrets);
|
|
3222
|
+
}, undefined, options.signal);
|
|
3223
|
+
storage = await PlaywrightScenarioStorage.create(opened, scenario, secrets, {
|
|
3224
|
+
...options.signal === undefined ? {} : { signal: options.signal },
|
|
3225
|
+
...options.retainCleanup === undefined ? {} : { retainCleanup: options.retainCleanup }
|
|
3226
|
+
});
|
|
3227
|
+
await storage?.initialize(opened.page, opened.context);
|
|
3228
|
+
throwIfScenarioCancelled(options.signal);
|
|
3229
|
+
events = new PlaywrightScenarioEvents({
|
|
3230
|
+
page: opened.page,
|
|
3231
|
+
context: opened.context,
|
|
3232
|
+
ownsContext: scenario.browser.mode === "launch",
|
|
3233
|
+
enabled: new Set(scenario.capture.events),
|
|
3234
|
+
secrets,
|
|
3235
|
+
network: scenario.capture.network,
|
|
3236
|
+
limits: scenario.capture.limits,
|
|
3237
|
+
...options.signal === undefined ? {} : { signal: options.signal }
|
|
3238
|
+
});
|
|
3239
|
+
return new PlaywrightScenarioSession(opened, {
|
|
3240
|
+
mode: scenario.browser.mode,
|
|
3241
|
+
secrets,
|
|
3242
|
+
eventCapture: events,
|
|
3243
|
+
storage,
|
|
3244
|
+
serviceWorkers,
|
|
3245
|
+
signal: options.signal
|
|
3246
|
+
});
|
|
3247
|
+
} catch (cause) {
|
|
3248
|
+
let storageReleased = false;
|
|
3249
|
+
const storageStopsLoading = storage !== undefined && options.signal?.aborted === true;
|
|
3250
|
+
let policyStopsLoading = !storageStopsLoading;
|
|
3251
|
+
const cleanup = async () => {
|
|
3252
|
+
let storageFailure;
|
|
3253
|
+
let policyFailure;
|
|
3254
|
+
let browserFailure;
|
|
3255
|
+
if (!storageReleased) {
|
|
3256
|
+
try {
|
|
3257
|
+
const result = await storage?.close(storageStopsLoading);
|
|
3258
|
+
if (storageStopsLoading && result?.loadingStopped !== true) policyStopsLoading = true;
|
|
3259
|
+
} catch (failure) {
|
|
3260
|
+
storageFailure = { cause: failure };
|
|
3261
|
+
policyStopsLoading = true;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
try {
|
|
3265
|
+
if (!opened.cleanup.browserClosed) await serviceWorkers?.close(policyStopsLoading);
|
|
3266
|
+
} catch (failure) {
|
|
3267
|
+
policyFailure = { cause: failure };
|
|
3268
|
+
}
|
|
3269
|
+
if (policyFailure === undefined) {
|
|
3270
|
+
try {
|
|
3271
|
+
await opened.cleanup.release(events === undefined ? undefined : () => events?.finish() ?? Promise.resolve());
|
|
3272
|
+
} catch (failure) {
|
|
3273
|
+
browserFailure = { cause: failure };
|
|
3274
|
+
}
|
|
3275
|
+
} else {
|
|
3276
|
+
try {
|
|
3277
|
+
await events?.finish();
|
|
3278
|
+
} catch (failure) {
|
|
3279
|
+
browserFailure = { cause: failure };
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
if (opened.cleanup.browserClosed) storageReleased = true;
|
|
3283
|
+
throwCleanupFailures([
|
|
3284
|
+
...policyFailure === undefined ? [] : [policyFailure.cause],
|
|
3285
|
+
...storageReleased || storageFailure === undefined ? [] : [storageFailure.cause],
|
|
3286
|
+
...browserFailure === undefined ? [] : [browserFailure.cause]
|
|
3287
|
+
]);
|
|
3288
|
+
};
|
|
3289
|
+
const recovery = new AnalysisCleanupLease(cleanup, opened.cleanup);
|
|
3290
|
+
try {
|
|
3291
|
+
return await failBrowserScenarioOperation(recovery, cause);
|
|
3292
|
+
} catch (failure) {
|
|
3293
|
+
if (failure !== cause) options.retainCleanup?.(recovery);
|
|
3294
|
+
throw failure;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
currentUrl() {
|
|
3299
|
+
return this.opened.page.url();
|
|
3300
|
+
}
|
|
3301
|
+
sanitizeUrl(value) {
|
|
3302
|
+
return this.secrets.sanitizeUrl(value);
|
|
3303
|
+
}
|
|
3304
|
+
setStep(index) {
|
|
3305
|
+
this.eventCapture.setStep(index);
|
|
3306
|
+
}
|
|
3307
|
+
nextEventSequence() {
|
|
3308
|
+
return this.eventCapture.nextSequence();
|
|
3309
|
+
}
|
|
3310
|
+
lastEventSequence() {
|
|
3311
|
+
return this.eventCapture.lastSequence();
|
|
3312
|
+
}
|
|
3313
|
+
events() {
|
|
3314
|
+
return this.eventCapture.result();
|
|
3315
|
+
}
|
|
3316
|
+
/** Preserve event coverage gaps for the aggregate capture's completeness. */
|
|
3317
|
+
eventLimitations() {
|
|
3318
|
+
return this.eventCapture.limitations();
|
|
3319
|
+
}
|
|
3320
|
+
async perform(action, signal) {
|
|
3321
|
+
await withPlaywrightExecutionBoundary(() => performPlaywrightScenarioAction({
|
|
3322
|
+
page: this.opened.page,
|
|
3323
|
+
action,
|
|
3324
|
+
secrets: this.secrets
|
|
3325
|
+
}), "timeout_ms" in action ? action.timeout_ms : undefined, signal);
|
|
3326
|
+
await withPlaywrightExecutionBoundary(() => this.storage?.settle() ?? Promise.resolve(), undefined, signal);
|
|
3327
|
+
}
|
|
3328
|
+
async capture(requested, signal) {
|
|
3329
|
+
await withPlaywrightExecutionBoundary(() => this.serviceWorkers?.assertBlocked() ?? Promise.resolve(), undefined, signal);
|
|
3330
|
+
await withPlaywrightExecutionBoundary(() => this.storage?.settle() ?? Promise.resolve(), undefined, signal);
|
|
3331
|
+
return withPlaywrightExecutionBoundary(() => capturePlaywrightStepArtifacts({
|
|
3332
|
+
context: this.opened.context,
|
|
3333
|
+
page: this.opened.page,
|
|
3334
|
+
secrets: this.secrets,
|
|
3335
|
+
requested
|
|
3336
|
+
}), undefined, signal);
|
|
3337
|
+
}
|
|
3338
|
+
async close(stopLoading = this.signal?.aborted === true) {
|
|
3339
|
+
this.#stopLoading ||= stopLoading;
|
|
3340
|
+
try {
|
|
3341
|
+
await withPlaywrightExecutionBoundary(() => this.cleanupLease.release(), PLAYWRIGHT_CLEANUP_CONFIRMATION_TIMEOUT_MS);
|
|
3342
|
+
} catch (cause) {
|
|
3343
|
+
const error = new BrowserObservationError(OPERATION, "cleanup_failed", {
|
|
3344
|
+
cause,
|
|
3345
|
+
cleanup: {
|
|
3346
|
+
reason: cause instanceof Error ? cause.message : String(cause),
|
|
3347
|
+
resources: this.cleanupLease.cleanupResources ?? []
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3350
|
+
new AnalysisCleanupLeaseGroup(error, [this.cleanupLease]);
|
|
3351
|
+
throw error;
|
|
3352
|
+
}
|
|
3353
|
+
return this.mode === "launch" ? "terminated-owned-process" : "disconnected-external";
|
|
3354
|
+
}
|
|
3355
|
+
async #closeResources() {
|
|
3356
|
+
const stopLoading = this.#stopLoading || this.signal?.aborted === true;
|
|
3357
|
+
let storageFailure;
|
|
3358
|
+
let policyFailure;
|
|
3359
|
+
let browserFailure;
|
|
3360
|
+
if (stopLoading && this.storage === undefined) this.#policyStopsLoading = true;
|
|
3361
|
+
if (!this.#storageReleased) {
|
|
3362
|
+
try {
|
|
3363
|
+
const result = await this.storage?.close(stopLoading);
|
|
3364
|
+
if (stopLoading && result?.loadingStopped !== true) this.#policyStopsLoading = true;
|
|
3365
|
+
} catch (failure) {
|
|
3366
|
+
storageFailure = { cause: failure };
|
|
3367
|
+
if (stopLoading) this.#policyStopsLoading = true;
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
try {
|
|
3371
|
+
if (!this.opened.cleanup.browserClosed) await this.serviceWorkers?.close(this.#policyStopsLoading);
|
|
3372
|
+
} catch (failure) {
|
|
3373
|
+
policyFailure = { cause: failure };
|
|
3374
|
+
}
|
|
3375
|
+
if (policyFailure === undefined) {
|
|
3376
|
+
try {
|
|
3377
|
+
await this.opened.cleanup.release(() => this.eventCapture.finish());
|
|
3378
|
+
} catch (failure) {
|
|
3379
|
+
browserFailure = { cause: failure };
|
|
3380
|
+
}
|
|
3381
|
+
} else {
|
|
3382
|
+
try {
|
|
3383
|
+
await this.eventCapture.finish();
|
|
3384
|
+
} catch (failure) {
|
|
3385
|
+
browserFailure = { cause: failure };
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
if (this.opened.cleanup.browserClosed) this.#storageReleased = true;
|
|
3389
|
+
throwCleanupFailures([
|
|
3390
|
+
...policyFailure === undefined ? [] : [policyFailure.cause],
|
|
3391
|
+
...this.#storageReleased || storageFailure === undefined ? [] : [storageFailure.cause],
|
|
3392
|
+
...browserFailure === undefined ? [] : [browserFailure.cause]
|
|
3393
|
+
]);
|
|
3394
|
+
}
|
|
3395
|
+
redactError(error) {
|
|
3396
|
+
return this.secrets.redact(error instanceof Error ? error.message : "browser action failed");
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
})))();
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
//#endregion
|
|
3403
|
+
//#region dist/composition/browserScenario.js
|
|
3404
|
+
var createBrowserScenarioProvider;
|
|
3405
|
+
function init_browserScenario() {
|
|
3406
|
+
return (init_browserScenario = __esmMin((() => {
|
|
3407
|
+
init_PlaywrightBrowserScenarioProvider();
|
|
3408
|
+
init_PlaywrightScenarioSession();
|
|
3409
|
+
createBrowserScenarioProvider = (environment) => new PlaywrightBrowserScenarioProvider((scenario, options) => PlaywrightScenarioSession.open(scenario, environment, options));
|
|
3410
|
+
})))();
|
|
3411
|
+
}
|
|
3412
|
+
|
|
3413
|
+
//#endregion
|
|
3414
|
+
init_browserScenario();
|
|
3415
|
+
export { createBrowserScenarioProvider };
|