rea-agents 6.3.0 → 6.5.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.
Files changed (1332) hide show
  1. package/DISCLAIMER.md +136 -0
  2. package/README.md +72 -18
  3. package/THIRD_PARTY_NOTICES.md +134 -0
  4. package/bridge/android/ReaJadxBridge.java +123 -11
  5. package/bridge/cutter/rea_bridge.py +816 -0
  6. package/bridge/ghidra/ReaGhidraAnalysisOptions.java +38 -0
  7. package/bridge/ghidra/ReaGhidraApplySeeds.java +151 -0
  8. package/bridge/ghidra/ReaGhidraBridge.java +1729 -283
  9. package/bridge/ghidra/ReaGhidraBundleActivator.java +14 -0
  10. package/bridge/ghidra/ReaGhidraMipsSoftFloat.java +176 -0
  11. package/bridge/ghidra/ReaGhidraNoReturnFix.java +123 -0
  12. package/bridge/ghidra/ReaGhidraPrepareRaw.java +49 -0
  13. package/bridge/hopper_bridge.py +103 -69
  14. package/bridge/mitmproxy/capture.py +189 -13
  15. package/bridge/native/rea_lldb_tracer.py +40 -6
  16. package/bridge/process/ProcessRunTokenReader.swift +76 -34
  17. package/bridge/pwntools/layout_impl.py +5 -0
  18. package/bridge/pwntools/recorded_crash_impl.py +31 -10
  19. package/dist/adb/AdbConfiguration.js +100 -0
  20. package/dist/adb/AdbDeviceOutput.js +208 -0
  21. package/dist/adb/AdbDirectoryListing.js +80 -0
  22. package/dist/adb/AdbHostFileName.js +34 -0
  23. package/dist/adb/AdbProvider.js +1433 -0
  24. package/dist/adb/AdbShellOutput.js +307 -0
  25. package/dist/android/AndroidTargetSnapshot.js +104 -22
  26. package/dist/android/JadxAnalysis.js +32 -7
  27. package/dist/android/JadxConfiguration.js +163 -53
  28. package/dist/android/JadxDoctor.js +115 -0
  29. package/dist/android/JadxMcpTransport.js +5 -3
  30. package/dist/android/JadxProtocol.js +14 -0
  31. package/dist/android/JadxProvider.js +63 -25
  32. package/dist/android/JadxRelease.js +12 -1
  33. package/dist/android/JadxWorkspaceRoot.js +157 -0
  34. package/dist/apktool/ApktoolConfiguration.js +227 -0
  35. package/dist/apktool/ApktoolDecodeOutput.js +142 -0
  36. package/dist/apktool/ApktoolProvider.js +543 -0
  37. package/dist/application/AnalysisContextQueries.js +5 -8
  38. package/dist/application/AnalysisProvider.js +24 -14
  39. package/dist/application/AppBundleExecutable.js +30 -25
  40. package/dist/application/BinaryTargetResolver.js +210 -33
  41. package/dist/application/BrowserEvidence.js +1 -1
  42. package/dist/application/BrowserObservationService.js +13 -2
  43. package/dist/application/BrowserScenarioCaptureService.js +0 -1
  44. package/dist/application/CallPathTracing.js +52 -13
  45. package/dist/application/CapabilityInventory.js +179 -29
  46. package/dist/application/ClaudeDesktopConfigLocation.js +152 -0
  47. package/dist/application/ClientConfigurationDocument.js +154 -7
  48. package/dist/application/ClientConfigurationFiles.js +128 -0
  49. package/dist/application/ClientRegistrationEnvironment.js +41 -0
  50. package/dist/application/ClientRegistrationIdentity.js +94 -29
  51. package/dist/application/ClientRegistrationStatus.js +223 -67
  52. package/dist/application/DirectAnalysis.js +86 -31
  53. package/dist/application/DirectAnalysisCleanup.js +1 -1
  54. package/dist/application/DirectAnalysisStatus.js +14 -2
  55. package/dist/application/Doctor.js +117 -34
  56. package/dist/application/DoctorDiagnostics.js +34 -12
  57. package/dist/application/DoctorProviderIds.js +2 -0
  58. package/dist/application/DoctorScope.js +11 -2
  59. package/dist/application/DshCordisPatch.js +355 -0
  60. package/dist/application/DshCordisYaml.js +155 -0
  61. package/dist/application/EnhancedLiteralTracing.js +30 -16
  62. package/dist/application/EnhancedToolTypes.js +0 -1
  63. package/dist/application/EnhancedTools.js +164 -54
  64. package/dist/application/EvidenceBundleCommands.js +36 -19
  65. package/dist/application/EvidenceBundleFiles.js +29 -7
  66. package/dist/application/FunctionAnalysisEvidence.js +3 -0
  67. package/dist/application/GeminiClientSettings.js +151 -0
  68. package/dist/application/HermesClientHome.js +115 -0
  69. package/dist/application/HermesConfigurationYaml.js +272 -0
  70. package/dist/application/HopperDownload.js +39 -0
  71. package/dist/application/InventoryProjectionEvidence.js +0 -1
  72. package/dist/application/InvestigationProviders.js +19 -3
  73. package/dist/application/JsonFiles.js +114 -23
  74. package/dist/application/JsonInputFile.js +410 -0
  75. package/dist/application/LinuxHopper.js +130 -60
  76. package/dist/application/MacHopper.js +177 -150
  77. package/dist/application/MacHopperPaths.js +40 -0
  78. package/dist/application/MipsElfMetadata.js +201 -0
  79. package/dist/application/MipsElfSharedLoad.js +164 -0
  80. package/dist/application/MipsGnuAttributes.js +90 -0
  81. package/dist/application/MsixPackageStorage.js +133 -0
  82. package/dist/application/ProgressReporter.js +1 -1
  83. package/dist/application/ProviderOperationExecution.js +39 -0
  84. package/dist/application/ReconstructionCoverageService.js +0 -1
  85. package/dist/application/ReconstructionObligationCandidates.js +12 -5
  86. package/dist/application/ReconstructionObligationLedgerDiagnostics.js +2 -2
  87. package/dist/application/ReconstructionObligationLedgerEvaluation.js +15 -33
  88. package/dist/application/ReconstructionObligationLedgerProjection.js +3 -72
  89. package/dist/application/ReconstructionObligationLedgerService.js +3 -1
  90. package/dist/application/ReconstructionObligationOriginalCases.js +2 -1
  91. package/dist/application/ReferenceSourceImport.js +94 -31
  92. package/dist/application/ReferenceSourceImportEntries.js +40 -30
  93. package/dist/application/ReferenceSourceImportPolicy.js +99 -23
  94. package/dist/application/ReferenceSourceImportTypes.js +30 -23
  95. package/dist/application/ReferenceSourceVcsAdapter.js +163 -31
  96. package/dist/application/RegularFileRead.js +121 -7
  97. package/dist/application/Setup.js +88 -14
  98. package/dist/application/SetupClientConfiguration.js +307 -38
  99. package/dist/application/SetupClients.js +12 -6
  100. package/dist/application/SetupHost.js +158 -38
  101. package/dist/application/SetupInstallFailure.js +42 -2
  102. package/dist/application/SetupPlan.js +83 -57
  103. package/dist/application/SetupRecoveryBackup.js +66 -0
  104. package/dist/application/SetupRegistrationEnvironment.js +2 -1
  105. package/dist/application/SetupSkill.js +354 -88
  106. package/dist/application/SupportedClients.js +429 -70
  107. package/dist/application/TypeScriptEmittedSourceCandidates.js +26 -0
  108. package/dist/application/Uninstall.js +412 -73
  109. package/dist/application/UninstallFailure.js +14 -0
  110. package/dist/application/Update.js +54 -25
  111. package/dist/application/UpdateFailure.js +17 -0
  112. package/dist/application/UpdateMaintenance.js +25 -47
  113. package/dist/application/UpdateRuntime.js +141 -27
  114. package/dist/application/Utf8JsonInput.js +7 -0
  115. package/dist/application/WebModuleTraceService.js +7 -0
  116. package/dist/application/WebNetworkCaptureService.js +16 -7
  117. package/dist/application/WebScriptExportService.js +131 -65
  118. package/dist/application/WebSourceLocationService.js +22 -3
  119. package/dist/application/WindowsCapabilities.js +18 -15
  120. package/dist/application/WorkflowEvidence.js +24 -1
  121. package/dist/application/adb/AdbDeviceAnalysisPort.js +1 -0
  122. package/dist/application/adb/AdbDeviceAnalysisService.js +13 -0
  123. package/dist/application/analysisView/AnalysisViewService.js +122 -6
  124. package/dist/application/android/AndroidPackageInspection.js +25 -0
  125. package/dist/application/android/AndroidSearchEvidenceSummary.js +100 -0
  126. package/dist/application/apktool/ApktoolResourceAnalysisPort.js +1 -0
  127. package/dist/application/apktool/ApktoolResourceAnalysisService.js +13 -0
  128. package/dist/application/binary/AnalysisClientCleanup.js +0 -24
  129. package/dist/application/binary/AnalysisProviderEvaluation.js +1 -1
  130. package/dist/application/binary/AnalysisProviderRegistry.js +36 -21
  131. package/dist/application/binary/AnalysisSnapshotCache.js +41 -20
  132. package/dist/application/binary/AnalysisSnapshotFiles.js +75 -9
  133. package/dist/application/binary/BinarySession.js +250 -97
  134. package/dist/application/binary/BinarySessionExecution.js +5 -4
  135. package/dist/application/binary/BinarySessionOpen.js +13 -6
  136. package/dist/application/binary/BinarySessionRecords.js +33 -7
  137. package/dist/application/binary/BinarySessionStatus.js +93 -23
  138. package/dist/application/binary/BinaryTargetSummary.js +9 -0
  139. package/dist/application/binary/CompositeProvider.js +71 -28
  140. package/dist/application/binary/LazyAnalysisProvider.js +3 -1
  141. package/dist/application/binary/SessionProviderRouter.js +5 -2
  142. package/dist/application/binaryDiagnostics/BinaryLayoutService.js +13 -2
  143. package/dist/application/binaryDiagnostics/PeResourcesPort.js +1 -0
  144. package/dist/application/binaryDiagnostics/PeResourcesService.js +114 -0
  145. package/dist/application/binaryDiagnostics/RecordedCrashService.js +16 -4
  146. package/dist/application/captures/PacketCaptureService.js +83 -0
  147. package/dist/application/closeOwnedWebResources.js +7 -0
  148. package/dist/application/electron/ElectronFusePort.js +1 -0
  149. package/dist/application/electron/ElectronFuseService.js +80 -0
  150. package/dist/application/evm/EvmInterfaceService.js +4 -0
  151. package/dist/application/firmware/FirmwareAnalysisService.js +3 -0
  152. package/dist/application/flutter/DartAotInspection.js +26 -0
  153. package/dist/application/flutter/FlutterBuildAnalysisPort.js +1 -0
  154. package/dist/application/flutter/FlutterBuildAnalysisService.js +13 -0
  155. package/dist/application/frida/FridaInstrumentationPort.js +8 -0
  156. package/dist/application/frida/FridaInstrumentationService.js +310 -0
  157. package/dist/application/frida/fridaInputErrors.js +17 -0
  158. package/dist/application/go/GoBinaryPort.js +1 -0
  159. package/dist/application/go/GoBinaryService.js +80 -0
  160. package/dist/application/harmony/HarmonyApplicationService.js +17 -0
  161. package/dist/application/investigation/EvidenceLedger.js +40 -14
  162. package/dist/application/investigation/InspectEvidenceBundle.js +18 -0
  163. package/dist/application/investigation/InvestigationRecords.js +12 -21
  164. package/dist/application/investigation/UnknownEvidence.js +22 -18
  165. package/dist/application/javascript/ElectronActiveObservationService.js +55 -25
  166. package/dist/application/javascript/ElectronBoundaryAnalysis.js +17 -3
  167. package/dist/application/javascript/ElectronBoundaryGraph.js +2 -0
  168. package/dist/application/javascript/ElectronBoundaryGraphCallPaths.js +144 -0
  169. package/dist/application/javascript/ElectronBoundaryGraphContext.js +3 -2
  170. package/dist/application/javascript/ElectronBoundaryGraphIpc.js +28 -9
  171. package/dist/application/javascript/ElectronBoundaryGraphNative.js +20 -7
  172. package/dist/application/javascript/ElectronBoundaryGraphWindows.js +50 -12
  173. package/dist/application/javascript/ElectronObservationService.js +0 -1
  174. package/dist/application/javascript/JavaScriptApplicationEvidence.js +15 -0
  175. package/dist/application/javascript/JavaScriptApplicationService.js +44 -18
  176. package/dist/application/javascript/JavaScriptApplicationWorkflowEvidence.js +5 -6
  177. package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +0 -1
  178. package/dist/application/javascript/JavaScriptArtifactAnalysis.js +253 -60
  179. package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +51 -23
  180. package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +93 -21
  181. package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +4 -3
  182. package/dist/application/javascript/JavaScriptArtifactGraphContext.js +35 -8
  183. package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +25 -14
  184. package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +163 -54
  185. package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +246 -15
  186. package/dist/application/javascript/JavaScriptArtifactPathResolution.js +1057 -323
  187. package/dist/application/javascript/JavaScriptArtifactReconstruction.js +134 -32
  188. package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +6 -1
  189. package/dist/application/javascript/JavaScriptModuleRelationships.js +39 -15
  190. package/dist/application/javascript/JavaScriptRecoveryService.js +32 -9
  191. package/dist/application/javascript/JavaScriptRuntimeObservationService.js +2 -1
  192. package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +0 -1
  193. package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +9 -3
  194. package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +228 -74
  195. package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +12 -19
  196. package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +4 -1
  197. package/dist/application/javascript/JavaScriptSemanticGraphElectronProjection.js +67 -0
  198. package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -3
  199. package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +5 -3
  200. package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +19 -8
  201. package/dist/application/javascript/JavaScriptSemanticTraceService.js +0 -1
  202. package/dist/application/jeb/JebAnalysisPort.js +1 -0
  203. package/dist/application/jeb/JebAnalysisService.js +13 -0
  204. package/dist/application/managed/ManagedApplicationGraphService.js +1 -2
  205. package/dist/application/managed/ManagedMemberComparisonService.js +72 -54
  206. package/dist/application/managed/ManagedNativeVerificationService.js +0 -1
  207. package/dist/application/managed/ManagedReconstructionService.js +0 -1
  208. package/dist/application/native/NativeCallRoutes.js +54 -34
  209. package/dist/application/native/NativeDispatchMetadataInspection.js +6 -2
  210. package/dist/application/native/NativeUiActionTrace.js +51 -30
  211. package/dist/application/native/NativeValueTrace.js +75 -24
  212. package/dist/application/pcap/PcapAnalysisPort.js +1 -0
  213. package/dist/application/pcap/PcapAnalysisService.js +24 -0
  214. package/dist/application/process/ProcessCli.js +57 -32
  215. package/dist/application/reverse/ReverseEngineeringCommandPort.js +1 -0
  216. package/dist/application/reverse/ReverseEngineeringService.js +688 -0
  217. package/dist/application/rust/RustBinaryPort.js +1 -0
  218. package/dist/application/rust/RustBinaryService.js +80 -0
  219. package/dist/application/signals/SignalRecordingService.js +83 -0
  220. package/dist/application/sqlite/SqliteDatabaseCapability.js +30 -0
  221. package/dist/application/sqlite/SqliteDatabasePort.js +1 -0
  222. package/dist/application/sqlite/SqliteDatabaseService.js +76 -0
  223. package/dist/application/wasm/WasmArtifactPort.js +1 -0
  224. package/dist/application/wasm/WasmArtifactService.js +77 -0
  225. package/dist/application/wasm/WasmInterfaceComparisonService.js +188 -0
  226. package/dist/artifacts/ArtifactHash.js +13 -2
  227. package/dist/artifacts/ArtifactPaths.js +133 -15
  228. package/dist/artifacts/ArtifactProvider.js +28 -19
  229. package/dist/artifacts/ArtifactReader.js +35 -0
  230. package/dist/artifacts/ArtifactResourceScope.js +109 -0
  231. package/dist/artifacts/AsarArtifactReader.js +295 -156
  232. package/dist/artifacts/AsarHeader.js +24 -0
  233. package/dist/artifacts/AsarListing.js +78 -0
  234. package/dist/artifacts/DirectoryArtifactReader.js +247 -74
  235. package/dist/artifacts/MachOSliceArtifactReader.js +198 -48
  236. package/dist/artifacts/NativeDmgArtifactReader.js +188 -78
  237. package/dist/artifacts/OrderedReads.js +57 -0
  238. package/dist/artifacts/SafeOutputTree.js +261 -71
  239. package/dist/artifacts/SafeOutputTreeCleanup.js +45 -0
  240. package/dist/artifacts/SafeOutputTreeCreationFailure.js +20 -0
  241. package/dist/artifacts/SafeOutputTreeIdentity.js +42 -0
  242. package/dist/artifacts/SafeOutputTreeReadback.js +33 -0
  243. package/dist/artifacts/ZipArtifactReader.js +186 -31
  244. package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +77 -68
  245. package/dist/artifacts/apple/DylibResolutionReader.js +11 -5
  246. package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +114 -38
  247. package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +125 -35
  248. package/dist/artifacts/apple/KeyedArchiveReader.js +35 -15
  249. package/dist/artifacts/apple/MachoLoadCommandReader.js +62 -61
  250. package/dist/artifacts/apple/NibArchive.js +11 -4
  251. package/dist/artifacts/apple/PlistNumberLiterals.js +2 -2
  252. package/dist/artifacts/extraction/ArtifactExtraction.js +115 -92
  253. package/dist/artifacts/hostExecutableMarking.js +16 -0
  254. package/dist/artifacts/inventory/ArtifactGraphConstruction.js +236 -69
  255. package/dist/artifacts/inventory/ArtifactInventory.js +7 -6
  256. package/dist/artifacts/inventory/classify.js +95 -35
  257. package/dist/artifacts/inventory/hashStableRootArtifact.js +48 -15
  258. package/dist/artifacts/inventory/reader.js +40 -17
  259. package/dist/artifacts/inventory/scanCanonical.js +84 -40
  260. package/dist/artifacts/inventory/scanReader.js +72 -19
  261. package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +177 -15
  262. package/dist/artifacts/javascript/JavaScriptSourceAnalysis.js +3 -0
  263. package/dist/artifacts/readStableArtifact.js +28 -4
  264. package/dist/browser/BrowserProcessStartup.js +20 -9
  265. package/dist/browser/BrowserScenarioPartialObservation.js +60 -38
  266. package/dist/browser/BrowserScenarioSecrets.js +193 -48
  267. package/dist/browser/CdpBrowserProvider.js +74 -98
  268. package/dist/browser/CdpCaptureDocuments.js +261 -65
  269. package/dist/browser/CdpCaptureDomSvg.js +243 -0
  270. package/dist/browser/CdpCaptureEventBodyShapes.js +12 -12
  271. package/dist/browser/CdpCaptureEventHandlers.js +49 -21
  272. package/dist/browser/CdpCaptureEvents.js +53 -19
  273. package/dist/browser/CdpCaptureStorage.js +22 -5
  274. package/dist/browser/CdpCaptureStorageFingerprints.js +54 -11
  275. package/dist/browser/CdpCaptureValues.js +0 -1
  276. package/dist/browser/CdpConnection.js +25 -9
  277. package/dist/browser/CdpElectronInspection.js +14 -4
  278. package/dist/browser/CdpElectronProvider.js +7 -2
  279. package/dist/browser/CdpElectronScripts.js +2 -1
  280. package/dist/browser/CdpElectronWorkers.js +7 -2
  281. package/dist/browser/CdpEndpoint.js +143 -17
  282. package/dist/browser/CdpObservationSession.js +24 -8
  283. package/dist/browser/CdpPageCapture.js +67 -17
  284. package/dist/browser/CdpPageCaptureScripts.js +4 -3
  285. package/dist/browser/CdpPageCaptureWorkers.js +5 -1
  286. package/dist/browser/CdpSafeMetadata.js +9 -5
  287. package/dist/browser/CdpScreenshot.js +5 -14
  288. package/dist/browser/CdpSnapshotStrings.js +21 -0
  289. package/dist/browser/CdpTargetSession.js +59 -36
  290. package/dist/browser/CdpWebMcpDiscovery.js +55 -16
  291. package/dist/browser/ElectronFileScope.js +99 -9
  292. package/dist/browser/PlaywrightBrowserScenarioProvider.js +64 -8
  293. package/dist/browser/PlaywrightElectronActiveActions.js +4 -4
  294. package/dist/browser/PlaywrightElectronActiveProjection.js +16 -4
  295. package/dist/browser/PlaywrightElectronActiveProvider.js +114 -36
  296. package/dist/browser/PlaywrightExecutionBoundary.js +2 -2
  297. package/dist/browser/PlaywrightScenarioArtifacts.js +5 -5
  298. package/dist/browser/PlaywrightScenarioBrowser.js +78 -13
  299. package/dist/browser/PlaywrightScenarioEvents.js +198 -36
  300. package/dist/browser/PlaywrightScenarioServiceWorkers.js +249 -0
  301. package/dist/browser/PlaywrightScenarioSession.js +180 -75
  302. package/dist/browser/PlaywrightScenarioStorage.js +507 -0
  303. package/dist/browser/PngVisualDiff.js +198 -29
  304. package/dist/browser/WebSourceMapFetcher.js +164 -81
  305. package/dist/browser/assets/LocalWebScriptArtifacts.js +27 -4
  306. package/dist/browser/assets/PublishWebScripts.js +88 -22
  307. package/dist/browser/assets/ScenarioScriptCapture.js +2 -1
  308. package/dist/browser/assets/WebArtifactReads.js +34 -4
  309. package/dist/browser/assets/WebSourceLocationArtifacts.js +39 -3
  310. package/dist/browser/execution/CdpExecutionCapture.js +3 -3
  311. package/dist/browser/execution/CdpPreciseCoverage.js +5 -8
  312. package/dist/browser/history/CaptureFailures.js +22 -8
  313. package/dist/browser/history/CaptureFormatError.js +2 -2
  314. package/dist/browser/history/{HarJson.js → CaptureJson.js} +14 -4
  315. package/dist/browser/history/CaptureRedaction.js +16 -3
  316. package/dist/browser/history/CaptureRelease.js +20 -2
  317. package/dist/browser/history/HarCapture.js +16 -9
  318. package/dist/browser/history/HarSchema.js +36 -36
  319. package/dist/browser/history/HistoricalCaptureDecoder.js +93 -25
  320. package/dist/browser/history/MitmproxyCaptureAdapter.js +3 -1
  321. package/dist/browser/history/NodeCaptureAdapter.js +48 -0
  322. package/dist/browser/history/{HarCaptureProcess.js → NodeCaptureProcess.js} +16 -15
  323. package/dist/browser/history/QlogCapture.js +385 -0
  324. package/dist/browser/history/SazCapture.js +130 -0
  325. package/dist/browser/history/SazHttp.js +61 -0
  326. package/dist/browser/history/SazMetadata.js +92 -0
  327. package/dist/browser/history/SazProjection.js +90 -0
  328. package/dist/browser/modules/NativeModuleResolver.js +177 -110
  329. package/dist/browser/modules/WebModuleArtifacts.js +41 -3
  330. package/dist/browser/network/PlaywrightNetworkContent.js +40 -5
  331. package/dist/browser/network/PlaywrightScenarioNetwork.js +125 -11
  332. package/dist/captures/TsharkCaptureProvider.js +370 -0
  333. package/dist/captures/parseFieldDiscovery.js +66 -0
  334. package/dist/captures/parsePacketOutput.js +21 -0
  335. package/dist/catalogIdentity.js +46 -35
  336. package/dist/cli/adbCommands.js +337 -0
  337. package/dist/cli/analysisViewCommands.js +39 -1
  338. package/dist/cli/androidCommands.js +11 -2
  339. package/dist/cli/apktoolCommands.js +52 -0
  340. package/dist/cli/applicationCommands.js +44 -17
  341. package/dist/cli/artifactCommands.js +9 -12
  342. package/dist/cli/binaryDiagnosticsCommands.js +27 -5
  343. package/dist/cli/browserAdvancedCommands.js +97 -55
  344. package/dist/cli/browserCommands.js +46 -29
  345. package/dist/cli/captureCommands.js +72 -0
  346. package/dist/cli/cliResultOutput.js +188 -0
  347. package/dist/cli/coreBinaryCommands.js +73 -32
  348. package/dist/cli/coreNativeCommands.js +54 -45
  349. package/dist/cli/cutterCommands.js +50 -0
  350. package/dist/cli/electronCommands.js +51 -4
  351. package/dist/cli/evmCommands.js +16 -8
  352. package/dist/cli/finishAnalysisCommand.js +44 -0
  353. package/dist/cli/firmwareCommands.js +21 -38
  354. package/dist/cli/flutterCommands.js +69 -0
  355. package/dist/cli/fridaCommands.js +211 -0
  356. package/dist/cli/goCommands.js +20 -0
  357. package/dist/cli/interactiveSetup.js +11 -1
  358. package/dist/cli/javascriptApplicationAnalysis.js +18 -2
  359. package/dist/cli/javascriptRecoveryCommands.js +29 -15
  360. package/dist/cli/jebCommands.js +99 -0
  361. package/dist/cli/jsonOutput.js +13 -6
  362. package/dist/cli/managedCommands.js +31 -3
  363. package/dist/cli/options.js +20 -2
  364. package/dist/cli/pcapCommands.js +47 -0
  365. package/dist/cli/processCommands.js +1 -1
  366. package/dist/cli/referenceSourceImportStatus.js +7 -0
  367. package/dist/cli/reverseEngineeringCommands.js +268 -0
  368. package/dist/cli/rustCommands.js +21 -0
  369. package/dist/cli/setupCommands.js +55 -15
  370. package/dist/cli/signalCommands.js +72 -0
  371. package/dist/cli/sqliteCommands.js +79 -0
  372. package/dist/cli/utilityCommands.js +179 -89
  373. package/dist/cli/wasmCommands.js +61 -0
  374. package/dist/cli/webModuleCommands.js +36 -32
  375. package/dist/cli/webNetworkCaptureCommands.js +8 -8
  376. package/dist/cli/webScriptCommands.js +20 -1
  377. package/dist/cli/webSourceLocationCommands.js +21 -9
  378. package/dist/cli-runtime/AbortablePromise-BVBemxbD.js +123 -0
  379. package/dist/cli-runtime/AnalysisProvider-D0Us2OTk.js +27 -0
  380. package/dist/cli-runtime/AnalysisSnapshotCache-BXS0wRd2.js +710 -0
  381. package/dist/cli-runtime/ArtifactReader-BXkffc1D.js +55 -0
  382. package/dist/cli-runtime/ArtifactResourceScope-DQWTcUwE.js +114 -0
  383. package/dist/cli-runtime/AsarHeader-CnzOzYEH.js +31 -0
  384. package/dist/cli-runtime/BinarySessionStatus-DnMxMk-r.js +211 -0
  385. package/dist/cli-runtime/BinaryTargetResolver-CVIJ_s1A.js +1308 -0
  386. package/dist/cli-runtime/BoundedFileBytes-BU30odTm.js +39 -0
  387. package/dist/cli-runtime/CdpTargetSession-DGX5pV9w.js +650 -0
  388. package/dist/cli-runtime/ClientConfigPath-c6jr6INc.js +36 -0
  389. package/dist/cli-runtime/ClientConfigurationDocument-ffQ9X0Se.js +1957 -0
  390. package/dist/cli-runtime/ClientRegistrationStatus-DszCyPEU.js +509 -0
  391. package/dist/cli-runtime/CurrentEntrypointPath-D5FRNdkq.js +14 -0
  392. package/dist/cli-runtime/DirectAnalysis-BgvAtpN3.js +528 -0
  393. package/dist/cli-runtime/Doctor-DIpf_I7N.js +588 -0
  394. package/dist/cli-runtime/ElectronFileScope-dpHm2nrS.js +1054 -0
  395. package/dist/cli-runtime/ExecFileOutput-BEQs-lDD.js +117 -0
  396. package/dist/cli-runtime/IdaConfiguration-CtGP7EKo.js +1094 -0
  397. package/dist/cli-runtime/InterfaceBuilderDecodeBudget-D4omRUe4.js +279 -0
  398. package/dist/cli-runtime/InventoryProjectionEvidence-DIsI4DJ6.js +49 -0
  399. package/dist/cli-runtime/InvestigationProviders-DoQRIHii.js +117 -0
  400. package/dist/cli-runtime/JavaScriptApplicationEvidenceGraph-D5aI_FSJ.js +160 -0
  401. package/dist/cli-runtime/JavaScriptApplicationWorkflowEvidence-Bz4-V0Ct.js +75 -0
  402. package/dist/cli-runtime/JavaScriptWorkerMemoryLimit-B1bwMM1a.js +86 -0
  403. package/dist/cli-runtime/JebMcpEndpoint-DUytrn5G.js +428 -0
  404. package/dist/cli-runtime/JsonFiles-DQa1PRKy.js +708 -0
  405. package/dist/cli-runtime/MacCodeSignature-MgYbRK_H.js +24 -0
  406. package/dist/cli-runtime/MacHopperPaths-CwL5lYPX.js +434 -0
  407. package/dist/cli-runtime/MachoLoadCommandReader-C7e074Ze.js +510 -0
  408. package/dist/cli-runtime/ManagedSnapshot-rqyBHcdL.js +4185 -0
  409. package/dist/cli-runtime/OwnedCommand-Cj9GhmPR.js +112 -0
  410. package/dist/cli-runtime/PrivateRuntimeRoot-DAy0PiBM.js +263 -0
  411. package/dist/cli-runtime/ProcessOwnership-DXC5-UWt.js +1378 -0
  412. package/dist/cli-runtime/ProviderDeadline-8m2pFRDc.js +122 -0
  413. package/dist/cli-runtime/RegularFile-B_6KPCNQ.js +139 -0
  414. package/dist/cli-runtime/RegularFileRead-DVlC5faM.js +125 -0
  415. package/dist/cli-runtime/SafeOutputTree-D6U15GXd.js +524 -0
  416. package/dist/cli-runtime/SetupHost-FkYWswsq.js +1098 -0
  417. package/dist/cli-runtime/SupportedClients-DaX6Lt2d.js +1049 -0
  418. package/dist/cli-runtime/UninstallFailure-1blyKXHE.js +22 -0
  419. package/dist/cli-runtime/Update-CbTC_eg1.js +143 -0
  420. package/dist/cli-runtime/UpdateFailure-BcFNxEZZ.js +24 -0
  421. package/dist/cli-runtime/ZipArtifactReader-B8ZgNe4D.js +248 -0
  422. package/dist/cli-runtime/analysisErrorCleanup-Do6YeeoD.js +32 -0
  423. package/dist/cli-runtime/analysisErrorPresentation-DGt7TdsH.js +497 -0
  424. package/dist/cli-runtime/appleArchiveFormat-tVoI2ykA.js +263 -0
  425. package/dist/cli-runtime/application__DirectAnalysisStatus-DpOejOf0.js +150 -0
  426. package/dist/cli-runtime/application__EnhancedTools-oFE2bOjs.js +1787 -0
  427. package/dist/cli-runtime/application__FunctionAnalysisEvidence-B6osuhvW.js +41 -0
  428. package/dist/cli-runtime/application__ReconstructionCoverageService-DN3wTFQj.js +32 -0
  429. package/dist/cli-runtime/application__ReconstructionObligationLedgerService-CKcTppX9.js +815 -0
  430. package/dist/cli-runtime/application__Setup-XpMaRNjy.js +514 -0
  431. package/dist/cli-runtime/application__Uninstall-_23pU2yB.js +427 -0
  432. package/dist/cli-runtime/application__UpdateRuntime-DPvY8ohd.js +345 -0
  433. package/dist/cli-runtime/application__android__AndroidApplicationService-CFgIFPM4.js +31 -0
  434. package/dist/cli-runtime/application__apple__AppleApplicationService-Db6QCsun.js +31 -0
  435. package/dist/cli-runtime/application__harmony__HarmonyApplicationService-CFjocHoK.js +31 -0
  436. package/dist/cli-runtime/application__javascript__ElectronActiveObservationService-CmVDUI_Z.js +118 -0
  437. package/dist/cli-runtime/application__javascript__ElectronObservationService-DEsR8KDN.js +63 -0
  438. package/dist/cli-runtime/application__javascript__JavaScriptApplicationService-CCkp8KBh.js +11450 -0
  439. package/dist/cli-runtime/application__javascript__JavaScriptApplicationWorkflowService-lPy0tzr3.js +2329 -0
  440. package/dist/cli-runtime/application__javascript__JavaScriptRuntimeReconciliationService-DWleA8K9.js +88 -0
  441. package/dist/cli-runtime/application__javascript__JavaScriptSemanticTraceService-DkALH4rL.js +299 -0
  442. package/dist/cli-runtime/artifactOperationError-B7n03FbD.js +27 -0
  443. package/dist/cli-runtime/artifacts__ArtifactProvider-zXI0QjSL.js +2187 -0
  444. package/dist/cli-runtime/binary-BVOr2mgE.js +14206 -0
  445. package/dist/cli-runtime/browserObservationError-Dx6xRTjb.js +40 -0
  446. package/dist/cli-runtime/catalogIdentity-DLoXgfIR.js +933 -0
  447. package/dist/cli-runtime/cli.js +41848 -0
  448. package/dist/cli-runtime/cliOutput-BC1BdAcB.js +122 -0
  449. package/dist/cli-runtime/cliOutput.js +5 -0
  450. package/dist/cli-runtime/cliResultOutput-DsRMI8CJ.js +780 -0
  451. package/dist/cli-runtime/cliResultOutput.js +5 -0
  452. package/dist/cli-runtime/composition__browserScenario-DHXC1a8n.js +2927 -0
  453. package/dist/cli-runtime/composition__electronObservation-GecK2EID.js +555 -0
  454. package/dist/cli-runtime/composition__electronScenario-CEZnVrAL.js +653 -0
  455. package/dist/cli-runtime/cutterToolContracts-TZH9EHr5.js +5134 -0
  456. package/dist/cli-runtime/doctorRuntime-BE5ZX8it.js +258 -0
  457. package/dist/cli-runtime/dotnet__ManagedStaticProvider-C8_yZCDc.js +5 -0
  458. package/dist/cli-runtime/errorSchemas-CTRmvMl3.js +601 -0
  459. package/dist/cli-runtime/javascriptApplicationAnalysis-HgMzVMQw.js +2068 -0
  460. package/dist/cli-runtime/javascriptExportReturnShapeProjection-Dg00g35t.js +78 -0
  461. package/dist/cli-runtime/javascriptExportShapeComparisonSchemas-BYnoIqIk.js +1242 -0
  462. package/dist/cli-runtime/javascriptRuntimeReconciliation-DNjDoL3S.js +1507 -0
  463. package/dist/cli-runtime/javascriptRuntimeReconciliationSchemas-BWpGWNcI.js +247 -0
  464. package/dist/cli-runtime/javascriptSemanticTraceSchemas-BTCNcvbc.js +126 -0
  465. package/dist/cli-runtime/lipo-DSWP6fv-.js +396 -0
  466. package/dist/cli-runtime/logger-CQQCI4a2.js +48 -0
  467. package/dist/cli-runtime/machoContainer-C8BIkkq3.js +172 -0
  468. package/dist/cli-runtime/managedApplicationGraph-B08jb3jq.js +1130 -0
  469. package/dist/cli-runtime/managedToolContracts-D60QmIYj.js +99 -0
  470. package/dist/cli-runtime/mcpDoctor.js +359 -0
  471. package/dist/cli-runtime/mcpStartupPolicy-CVVSOmRc.js +21 -0
  472. package/dist/cli-runtime/native__NativeMacOSProvider-YBTvUeJO.js +4875 -0
  473. package/dist/cli-runtime/officialToolContracts-CCFF0an9.js +1501 -0
  474. package/dist/cli-runtime/propertyListKeys-G8e74YWb.js +248 -0
  475. package/dist/cli-runtime/providerAdapterError-DAjhICdr.js +25 -0
  476. package/dist/cli-runtime/providerCleanupError-Ceq8f0wK.js +27 -0
  477. package/dist/cli-runtime/providerIdentities-Ao1XTvwx.js +31 -0
  478. package/dist/cli-runtime/providerStartupTimeout-B2tF2LtZ.js +17 -0
  479. package/dist/cli-runtime/readFileHandleChunks-dp60iZ6v.js +38 -0
  480. package/dist/cli-runtime/reconstructionObligationLedgerSchemas-Bao0xMr-.js +19478 -0
  481. package/dist/cli-runtime/rolldown-runtime-DXoylpqc.js +121 -0
  482. package/dist/cli-runtime/runtimeVersion-CMGd0bDu.js +23 -0
  483. package/dist/cli-runtime/safeJson-DKKACtdy.js +25 -0
  484. package/dist/cli-runtime/scanCanonical-KP4T9jSl.js +2724 -0
  485. package/dist/cli-runtime/snapshotEnvironment-D_tWyOub.js +813 -0
  486. package/dist/cli-runtime/toolContracts-D2FOG_Nb.js +3721 -0
  487. package/dist/cli-runtime/toolOutputSchemaGroups-DRiYs1je.js +12070 -0
  488. package/dist/cli-runtime/workflowInputError-n8Oo-bLA.js +26 -0
  489. package/dist/cli.js +44 -5
  490. package/dist/cliBrowserScenarioCommands.js +41 -5
  491. package/dist/cliCommandNames.js +80 -0
  492. package/dist/cliEvidenceCommands.js +0 -1
  493. package/dist/cliJavaScriptRuntimeCommands.js +16 -14
  494. package/dist/cliJsonInput.js +14 -6
  495. package/dist/cliLogging.js +50 -14
  496. package/dist/cliObservationOptions.js +9 -0
  497. package/dist/cliOutput.js +38 -5
  498. package/dist/composition/adb.js +3 -0
  499. package/dist/composition/apktool.js +3 -0
  500. package/dist/composition/binary.js +4 -0
  501. package/dist/composition/binaryDiagnostics.js +4 -0
  502. package/dist/composition/captures.js +3 -0
  503. package/dist/composition/directAnalysis.js +36 -11
  504. package/dist/composition/electronFuses.js +4 -0
  505. package/dist/composition/evm.js +12 -0
  506. package/dist/composition/flutter.js +3 -0
  507. package/dist/composition/go.js +4 -0
  508. package/dist/composition/javascriptAnalysisWorkerProcess.js +49 -0
  509. package/dist/composition/jeb.js +35 -0
  510. package/dist/composition/pcap.js +3 -0
  511. package/dist/composition/resolveWindowsProviderExecutable.js +61 -0
  512. package/dist/composition/reverseEngineering.js +29 -0
  513. package/dist/composition/rust.js +4 -0
  514. package/dist/composition/signals.js +3 -0
  515. package/dist/composition/sqlite.js +4 -0
  516. package/dist/composition/wasm.js +22 -0
  517. package/dist/composition/webNetworkCaptures.js +7 -2
  518. package/dist/config/environment.js +55 -4
  519. package/dist/config/ghidraDisabledAnalyzers.js +25 -0
  520. package/dist/config/ghidraLanguageOverride.js +9 -0
  521. package/dist/config/homeDirectory.js +9 -6
  522. package/dist/config/mcpInputSchemaProfile.js +31 -0
  523. package/dist/config/mcpOutputSchemaProfile.js +22 -0
  524. package/dist/config/parseConfig.js +36 -19
  525. package/dist/config/parsers.js +4 -3
  526. package/dist/config/{ghidraStartupTimeout.js → providerStartupTimeout.js} +7 -3
  527. package/dist/contracts/adb/adbToolContracts.js +353 -0
  528. package/dist/contracts/advertisedInputExamples.js +48 -0
  529. package/dist/contracts/analysisDetail.js +13 -0
  530. package/dist/contracts/analysisViewApiSurfaceExample.js +68 -0
  531. package/dist/contracts/analysisViewToolContracts.js +39 -3
  532. package/dist/contracts/android/androidToolContracts.js +17 -8
  533. package/dist/contracts/apktool/apktoolToolContracts.js +33 -0
  534. package/dist/contracts/applicationToolContracts.js +17 -2
  535. package/dist/contracts/artifactToolContracts.js +21 -6
  536. package/dist/contracts/browserToolContracts.js +2 -1
  537. package/dist/contracts/captures/captureToolContracts.js +42 -0
  538. package/dist/contracts/compactInputSchema.js +276 -0
  539. package/dist/contracts/cutterToolContracts.js +84 -0
  540. package/dist/contracts/enhancedToolContracts.js +2 -2
  541. package/dist/contracts/evm/evmToolContracts.js +30 -15
  542. package/dist/contracts/firmware/firmwareToolContracts.js +1 -1
  543. package/dist/contracts/flutter/flutterToolContracts.js +47 -0
  544. package/dist/contracts/fridaRemoteAddress.js +23 -0
  545. package/dist/contracts/fridaToolContracts.js +273 -0
  546. package/dist/contracts/functionComparisonExample.js +12 -1
  547. package/dist/contracts/functionWorkflowToolContracts.js +1 -1
  548. package/dist/contracts/gdbToolContracts.js +103 -0
  549. package/dist/contracts/go/goToolContracts.js +20 -0
  550. package/dist/contracts/hopperMemoryContracts.js +15 -0
  551. package/dist/contracts/inputSchemaPresentation.js +91 -24
  552. package/dist/contracts/investigationExamples.js +1 -0
  553. package/dist/contracts/javascript/electronToolContracts.js +40 -3
  554. package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +13 -1
  555. package/dist/contracts/jeb/jebToolContracts.js +64 -0
  556. package/dist/contracts/managed/managedToolContracts.js +43 -4
  557. package/dist/contracts/managed/managedWorkflowExamples.js +7 -1
  558. package/dist/contracts/managed/managedWorkflowToolContracts.js +4 -30
  559. package/dist/contracts/mobileApplicationGraphExamples.js +12 -0
  560. package/dist/contracts/native/binaryDiagnosticsToolContracts.js +27 -4
  561. package/dist/contracts/native/nativeToolContracts.js +10 -6
  562. package/dist/contracts/officialToolContracts.js +9 -9
  563. package/dist/contracts/pcap/pcapToolContracts.js +33 -0
  564. package/dist/contracts/providerSelection.js +1 -0
  565. package/dist/contracts/reconstructionReadinessExample.js +126 -119
  566. package/dist/contracts/reverseEngineeringToolContracts.js +52 -0
  567. package/dist/contracts/rizinDebugToolContracts.js +96 -0
  568. package/dist/contracts/rust/rustToolContracts.js +20 -0
  569. package/dist/contracts/sessionLifecycleInputs.js +34 -2
  570. package/dist/contracts/sessionToolContracts.js +4 -4
  571. package/dist/contracts/sessionToolSchemas.js +20 -2
  572. package/dist/contracts/signals/signalToolContracts.js +40 -0
  573. package/dist/contracts/sqlite/sqliteToolContracts.js +36 -0
  574. package/dist/contracts/toolContractExamples.js +35 -0
  575. package/dist/contracts/toolContractTypes.js +5 -0
  576. package/dist/contracts/toolContracts.js +32 -0
  577. package/dist/contracts/toolEffects.js +414 -8
  578. package/dist/contracts/toolOutputSchemaGroups.js +78 -33
  579. package/dist/contracts/toolOutputSchemaPrimitives.js +111 -10
  580. package/dist/contracts/toolSchemaMetadata.js +98 -9
  581. package/dist/contracts/unknownContractExamples.js +1 -1
  582. package/dist/contracts/wasm/wasmComparisonContracts.js +52 -0
  583. package/dist/contracts/wasm/wasmToolContracts.js +33 -0
  584. package/dist/contracts/webNetworkCaptureToolContracts.js +15 -4
  585. package/dist/cutter/CutterBridgeClient.js +621 -0
  586. package/dist/cutter/CutterBridgeService.js +139 -0
  587. package/dist/doctorRuntime.js +20 -8
  588. package/dist/domain/adb/adbDeviceAnalysis.js +605 -0
  589. package/dist/domain/analysisErrorBase.js +20 -0
  590. package/dist/domain/analysisErrorCleanup.js +29 -0
  591. package/dist/domain/analysisErrorCore.js +19 -0
  592. package/dist/domain/analysisErrorPresentation.js +75 -22
  593. package/dist/domain/analysisErrorProjection.js +35 -13
  594. package/dist/domain/analysisProfile.js +7 -3
  595. package/dist/domain/analysisSnapshot.js +313 -185
  596. package/dist/domain/analysisView/WebNetworkApiSurfaceAccumulator.js +414 -0
  597. package/dist/domain/analysisView/analysisView.js +417 -45
  598. package/dist/domain/analysisView/analysisViewCoverage.js +32 -0
  599. package/dist/domain/analysisView/analysisViewErrors.js +4 -0
  600. package/dist/domain/analysisView/analysisViewParent.js +12 -0
  601. package/dist/domain/analysisView/analysisViewText.js +29 -0
  602. package/dist/domain/analysisView/androidPackageView.js +102 -0
  603. package/dist/domain/analysisView/artifactInventoryView.js +140 -0
  604. package/dist/domain/analysisView/binaryLayoutView.js +13 -4
  605. package/dist/domain/analysisView/dartAotView.js +93 -0
  606. package/dist/domain/analysisView/evmInterfaceView.js +105 -0
  607. package/dist/domain/analysisView/interfaceBuilderView.js +182 -0
  608. package/dist/domain/analysisView/javascriptApplicationView.js +29 -26
  609. package/dist/domain/analysisView/machoView.js +186 -0
  610. package/dist/domain/analysisView/managedArtifactView.js +108 -0
  611. package/dist/domain/analysisView/managedMemberView.js +209 -0
  612. package/dist/domain/analysisView/nativeFunctionView.js +150 -0
  613. package/dist/domain/analysisView/pcapCaptureView.js +264 -0
  614. package/dist/domain/analysisView/qlogCaptureView.js +198 -0
  615. package/dist/domain/analysisView/wasmArtifactView.js +162 -0
  616. package/dist/domain/analysisView/webNetworkApiSurfaceView.js +123 -0
  617. package/dist/domain/analysisView/webNetworkCaptureView.js +388 -0
  618. package/dist/domain/android/androidAnalysis.js +36 -2
  619. package/dist/domain/android/androidApplication.js +57 -80
  620. package/dist/domain/apktool/apktoolResourceAnalysis.js +89 -0
  621. package/dist/domain/apple/appleApplication.js +71 -52
  622. package/dist/domain/apple/appleArchiveFormat.js +184 -0
  623. package/dist/domain/apple/appleAssetCatalog.js +15 -0
  624. package/dist/domain/apple/appleBundleAnatomy.js +96 -29
  625. package/dist/domain/apple/dyldPaths.js +18 -3
  626. package/dist/domain/apple/dylibResolution.js +21 -11
  627. package/dist/domain/apple/dylibResolutionFindings.js +8 -9
  628. package/dist/domain/apple/interfaceBuilderGraph.js +72 -45
  629. package/dist/domain/apple/interfaceBuilderKeyedArchive.js +38 -9
  630. package/dist/domain/apple/machoContainer.js +120 -8
  631. package/dist/domain/apple/machoCpuIdentity.js +4 -0
  632. package/dist/domain/apple/plistValue.js +6 -1
  633. package/dist/domain/artifactComparison.js +130 -25
  634. package/dist/domain/artifactDecompressionBudget.js +26 -0
  635. package/dist/domain/artifactGraph.js +28 -9
  636. package/dist/domain/artifactIdentity.js +33 -2
  637. package/dist/domain/artifactInspection.js +47 -45
  638. package/dist/domain/artifactIntegrityPolicy.js +10 -0
  639. package/dist/domain/artifactInventoryEvidence.js +148 -51
  640. package/dist/domain/artifactPathSyntax.js +1 -1
  641. package/dist/domain/binaryTarget.js +253 -80
  642. package/dist/domain/binaryTargetTypes.js +21 -1
  643. package/dist/domain/browserNetworkEvidence.js +4 -0
  644. package/dist/domain/browserObservation.js +88 -29
  645. package/dist/domain/browserObservationSchemas.js +12 -5
  646. package/dist/domain/browserScenarioCapture.js +2 -1
  647. package/dist/domain/browserScenarioCaptureValues.js +26 -2
  648. package/dist/domain/browserScenarioDiff.js +120 -11
  649. package/dist/domain/browserScenarioDiffEvidence.js +46 -13
  650. package/dist/domain/browserScenarioDiffValues.js +10 -3
  651. package/dist/domain/browserScenarioNetworkComparison.js +158 -0
  652. package/dist/domain/browserScenarioNormalization.js +10 -13
  653. package/dist/domain/browserScenarioValues.js +2 -12
  654. package/dist/domain/browserSession.js +2 -2
  655. package/dist/domain/bundleComparison.js +1 -5
  656. package/dist/domain/callPath.js +40 -3
  657. package/dist/domain/canonicalJsonDigestSteps.js +34 -12
  658. package/dist/domain/captures/packetCapture.js +138 -0
  659. package/dist/domain/captures/packetFields.js +81 -0
  660. package/dist/domain/changedBehavior.js +43 -41
  661. package/dist/domain/compactStringIdentity.js +9 -0
  662. package/dist/domain/comparisonSourceEvidence.js +6 -0
  663. package/dist/domain/dosCom.js +2 -2
  664. package/dist/domain/dosMz.js +52 -14
  665. package/dist/domain/electron/electronFuses.js +360 -0
  666. package/dist/domain/elfFixedHeader.js +42 -0
  667. package/dist/domain/evidence.js +104 -38
  668. package/dist/domain/evidenceBundle.js +58 -20
  669. package/dist/domain/evidenceErrors.js +5 -0
  670. package/dist/domain/evidenceRecordSummary.js +144 -0
  671. package/dist/domain/evm/evmInterface.js +18 -4
  672. package/dist/domain/evm/solidityMetadata.js +70 -0
  673. package/dist/domain/explicitSensitiveFailure.js +42 -24
  674. package/dist/domain/firmware/firmwareAnalysis.js +29 -0
  675. package/dist/domain/flutter/flutterBuildAnalysis.js +141 -0
  676. package/dist/domain/functionCallCoverage.js +60 -0
  677. package/dist/domain/functionComparisonDimensions.js +101 -10
  678. package/dist/domain/functionComparisonNormalization.js +66 -10
  679. package/dist/domain/functionComparisonResults.js +7 -6
  680. package/dist/domain/functionComparisonSchemas.js +14 -3
  681. package/dist/domain/functionDossierEvidence.js +3 -0
  682. package/dist/domain/go/goBinary.js +96 -0
  683. package/dist/domain/harmony/harmonyApplication.js +156 -0
  684. package/dist/domain/hopperErrors.js +15 -16
  685. package/dist/domain/hopperPublisher.js +12 -0
  686. package/dist/domain/hopperValues.js +112 -34
  687. package/dist/domain/inputIssueProjection.js +16 -1
  688. package/dist/domain/javascript/electronObservation.js +4 -1
  689. package/dist/domain/javascript/electronStaticAnalysisBrowser.js +24 -24
  690. package/dist/domain/javascript/electronStaticAnalysisIpc.js +13 -20
  691. package/dist/domain/javascript/electronStaticAnalysisNative.js +85 -41
  692. package/dist/domain/javascript/electronStaticAnalysisValues.js +30 -8
  693. package/dist/domain/javascript/electronWrappedCallPaths.js +498 -0
  694. package/dist/domain/javascript/htmlArtifactReferences.js +94 -4
  695. package/dist/domain/javascript/javascriptAnalysisResourceControls.js +65 -0
  696. package/dist/domain/javascript/javascriptApplicationAnalysis.js +7 -1
  697. package/dist/domain/javascript/javascriptApplicationChangeGraph.js +13 -8
  698. package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +1 -1
  699. package/dist/domain/javascript/javascriptApplicationGraph.js +96 -19
  700. package/dist/domain/javascript/javascriptApplicationGraphSchemas.js +1 -0
  701. package/dist/domain/javascript/javascriptApplicationProjectionResources.js +43 -0
  702. package/dist/domain/javascript/javascriptApplicationVersionItems.js +28 -12
  703. package/dist/domain/javascript/javascriptApplicationVersionKeys.js +40 -19
  704. package/dist/domain/javascript/javascriptArtifactFiles.js +2 -1
  705. package/dist/domain/javascript/javascriptAstFingerprint.js +100 -39
  706. package/dist/domain/javascript/javascriptAstValues.js +81 -0
  707. package/dist/domain/javascript/javascriptBootstrap.js +94 -0
  708. package/dist/domain/javascript/javascriptBootstrapIntegrity.js +372 -0
  709. package/dist/domain/javascript/javascriptBuiltinResourceMethods.js +8 -0
  710. package/dist/domain/javascript/javascriptBundledRequireOrigin.js +291 -0
  711. package/dist/domain/javascript/javascriptContextBridgeExposure.js +23 -0
  712. package/dist/domain/javascript/javascriptElectronMemberWrites.js +114 -0
  713. package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +6 -5
  714. package/dist/domain/javascript/javascriptExportShapeVariants.js +1 -1
  715. package/dist/domain/javascript/javascriptFeatureSeed.js +33 -16
  716. package/dist/domain/javascript/javascriptFeatureTrace.js +9 -3
  717. package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +42 -11
  718. package/dist/domain/javascript/javascriptIntrinsicInvocation.js +132 -0
  719. package/dist/domain/javascript/javascriptModuleDeclaration.js +28 -0
  720. package/dist/domain/javascript/javascriptModuleInterop.js +618 -0
  721. package/dist/domain/javascript/javascriptModuleResolutionMode.js +18 -0
  722. package/dist/domain/javascript/javascriptModuleSemanticIr.js +15 -0
  723. package/dist/domain/javascript/javascriptModuleSpecifier.js +5 -0
  724. package/dist/domain/javascript/javascriptNativeHandoff.js +6 -2
  725. package/dist/domain/javascript/javascriptPackageImportAliases.js +58 -0
  726. package/dist/domain/javascript/javascriptRecovery.js +12 -5
  727. package/dist/domain/javascript/javascriptRpcEndpoints.js +331 -0
  728. package/dist/domain/javascript/javascriptRuntimeLoadState.js +12 -3
  729. package/dist/domain/javascript/javascriptRuntimeObservation.js +4 -1
  730. package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +10 -4
  731. package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +7 -2
  732. package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +15 -2
  733. package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +0 -1
  734. package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +5 -4
  735. package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +121 -22
  736. package/dist/domain/javascript/javascriptSemanticAmbientWrites.js +251 -0
  737. package/dist/domain/javascript/javascriptSemanticAnalysis.js +493 -104
  738. package/dist/domain/javascript/javascriptSemanticAsyncEffects.js +17 -34
  739. package/dist/domain/javascript/javascriptSemanticCallResolution.js +4 -3
  740. package/dist/domain/javascript/javascriptSemanticCallableResults.js +42 -0
  741. package/dist/domain/javascript/javascriptSemanticCallableStack.js +52 -0
  742. package/dist/domain/javascript/javascriptSemanticCalls.js +14 -12
  743. package/dist/domain/javascript/javascriptSemanticChildProcesses.js +42 -55
  744. package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +428 -32
  745. package/dist/domain/javascript/javascriptSemanticDataEffects.js +14 -20
  746. package/dist/domain/javascript/javascriptSemanticDependencies.js +69 -0
  747. package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +15 -4
  748. package/dist/domain/javascript/javascriptSemanticFileProjection.js +1 -0
  749. package/dist/domain/javascript/javascriptSemanticFingerprints.js +51 -53
  750. package/dist/domain/javascript/javascriptSemanticGraph.js +74 -24
  751. package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +2 -11
  752. package/dist/domain/javascript/javascriptSemanticIterationSources.js +41 -8
  753. package/dist/domain/javascript/javascriptSemanticMemberMutations.js +538 -151
  754. package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +199 -3
  755. package/dist/domain/javascript/javascriptSemanticMutationValues.js +78 -35
  756. package/dist/domain/javascript/javascriptSemanticObjectReferences.js +671 -0
  757. package/dist/domain/javascript/javascriptSemanticObjects.js +27 -17
  758. package/dist/domain/javascript/javascriptSemanticProjection.js +202 -56
  759. package/dist/domain/javascript/javascriptSemanticPromises.js +6 -9
  760. package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +77 -0
  761. package/dist/domain/javascript/javascriptSemanticProvenance.js +5 -1
  762. package/dist/domain/javascript/javascriptSemanticQuery.js +34 -31
  763. package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +1 -3
  764. package/dist/domain/javascript/javascriptSemanticReferenceSources.js +25 -0
  765. package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +331 -8
  766. package/dist/domain/javascript/javascriptSemanticResources.js +6 -40
  767. package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +233 -0
  768. package/dist/domain/javascript/javascriptSemanticReturns.js +49 -52
  769. package/dist/domain/javascript/javascriptSemanticState.js +61 -4
  770. package/dist/domain/javascript/javascriptSemanticTraversal.js +25 -5
  771. package/dist/domain/javascript/javascriptSemanticValues.js +260 -35
  772. package/dist/domain/javascript/javascriptSourceAnalysis.js +1 -0
  773. package/dist/domain/javascript/javascriptSourceMapPaths.js +44 -17
  774. package/dist/domain/javascript/javascriptSourceParser.js +72 -3
  775. package/dist/domain/javascript/javascriptSourceSelection.js +11 -0
  776. package/dist/domain/javascript/javascriptStaticAnalysis.js +72 -26
  777. package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +100 -24
  778. package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +271 -47
  779. package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +8 -4
  780. package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +166 -56
  781. package/dist/domain/javascript/javascriptStaticAnalysisState.js +2 -0
  782. package/dist/domain/javascript/javascriptStaticAnalysisTypes.js +2 -1
  783. package/dist/domain/javascript/javascriptSymbolicBindings.js +836 -0
  784. package/dist/domain/javascript/javascriptSymbolicControlFlow.js +40 -0
  785. package/dist/domain/javascript/javascriptSymbolicValues.js +34 -0
  786. package/dist/domain/javascript/sourceToBundleComparison.js +3 -1
  787. package/dist/domain/javascript/sourceToBundleComparisonSchemas.js +2 -0
  788. package/dist/domain/javascript/sourceToBundleSignals.js +47 -13
  789. package/dist/domain/jeb/jebAnalysis.js +114 -0
  790. package/dist/domain/jsonShape.js +63 -52
  791. package/dist/domain/jsonValue.js +40 -12
  792. package/dist/domain/localPath.js +6 -3
  793. package/dist/domain/managed/managedApplicationGraph.js +42 -0
  794. package/dist/domain/managed/managedApplicationGraphCoverage.js +12 -2
  795. package/dist/domain/managed/managedApplicationGraphNodes.js +32 -23
  796. package/dist/domain/managed/managedArtifact.js +52 -1
  797. package/dist/domain/managed/managedInspectionEvidence.js +12 -0
  798. package/dist/domain/managed/managedMemberComparison.js +3 -0
  799. package/dist/domain/managed/managedMemberComparisonCoverage.js +23 -3
  800. package/dist/domain/managed/managedMemberComparisonItems.js +23 -19
  801. package/dist/domain/managed/managedMemberComparisonMatch.js +209 -18
  802. package/dist/domain/managed/managedNativeVerificationMatch.js +49 -26
  803. package/dist/domain/managed/managedNativeVerificationSchemas.js +13 -2
  804. package/dist/domain/managed/managedReconstruction.js +5 -8
  805. package/dist/domain/mobileApplicationGraphProjection.js +80 -0
  806. package/dist/domain/native/addressCoordinate.js +11 -0
  807. package/dist/domain/native/binaryLayout.js +2 -4
  808. package/dist/domain/native/bytePattern.js +100 -0
  809. package/dist/domain/native/nativeAotPe.js +1408 -0
  810. package/dist/domain/native/nativeInspection.js +38 -4
  811. package/dist/domain/native/nativeInstruction.js +38 -2
  812. package/dist/domain/native/nativeInvestigationGraph.js +9 -5
  813. package/dist/domain/native/nativeLoadImage.js +19 -1
  814. package/dist/domain/native/nativeMetadataRecovery.js +79 -6
  815. package/dist/domain/native/nativeUiObservation.js +5 -6
  816. package/dist/domain/native/objcSwiftMetadata.js +4 -1
  817. package/dist/domain/native/peResources.js +100 -0
  818. package/dist/domain/native/recordedCrash.js +79 -10
  819. package/dist/domain/nativeConvention.js +33 -0
  820. package/dist/domain/offsetDateTime.js +60 -0
  821. package/dist/domain/pcap/pcapAnalysis.js +91 -0
  822. package/dist/domain/pcap/pcapEvidence.js +15 -0
  823. package/dist/domain/peMachine.js +36 -0
  824. package/dist/domain/pngHeader.js +18 -0
  825. package/dist/domain/process/processCapture.js +91 -1
  826. package/dist/domain/process/processCaptureCoverage.js +26 -3
  827. package/dist/domain/process/processCaptureExample.js +26 -0
  828. package/dist/domain/process/processCaptureValidation.js +112 -8
  829. package/dist/domain/process/processComparison.js +41 -13
  830. package/dist/domain/process/processScenario.js +66 -7
  831. package/dist/domain/process/processTraceEvaluation.js +54 -50
  832. package/dist/domain/process/processTraceSpecification.js +243 -89
  833. package/dist/domain/propertyListKeys.js +214 -12
  834. package/dist/domain/propertyListXmlText.js +20 -4
  835. package/dist/domain/providerAdapterError.js +0 -5
  836. package/dist/domain/providerConfigurationRefusal.js +12 -0
  837. package/dist/domain/providerSelectionError.js +2 -1
  838. package/dist/domain/qlogCapture.js +62 -0
  839. package/dist/domain/rawBinary.js +96 -0
  840. package/dist/domain/reconstructionCoverage.js +5 -1
  841. package/dist/domain/reconstructionCoverageEvaluation.js +18 -15
  842. package/dist/domain/reconstructionCoverageVerifierResults.js +35 -0
  843. package/dist/domain/reconstructionObligationLedgerIntegrity.js +114 -0
  844. package/dist/domain/reconstructionObligationLedgerSchemas.js +104 -1
  845. package/dist/domain/reconstructionReadiness.js +4 -8
  846. package/dist/domain/reconstructionReadinessJourneyFindings.js +4 -1
  847. package/dist/domain/reconstructionUnknowns.js +9 -1
  848. package/dist/domain/reconstructionVerification.js +54 -25
  849. package/dist/domain/recordedTransportUrl.js +59 -0
  850. package/dist/domain/referenceSourceClassification.js +27 -23
  851. package/dist/domain/referenceSourceGraph.js +70 -23
  852. package/dist/domain/referenceSourceImportParsing.js +29 -16
  853. package/dist/domain/referenceSourcePathIdentity.js +32 -0
  854. package/dist/domain/referenceSourceRequireBindings.js +130 -0
  855. package/dist/domain/referenceSourceSummary.js +92 -0
  856. package/dist/domain/relationshipCoverage.js +44 -0
  857. package/dist/domain/residualUnknown.js +93 -26
  858. package/dist/domain/reverseEngineering.js +31 -0
  859. package/dist/domain/runtimeVersion.js +8 -0
  860. package/dist/domain/rust/rustBinary.js +200 -0
  861. package/dist/domain/signals/annotationTextWindow.js +31 -0
  862. package/dist/domain/signals/signalDecoders.js +69 -0
  863. package/dist/domain/signals/signalRecording.js +115 -0
  864. package/dist/domain/sourceMapContents.js +10 -3
  865. package/dist/domain/sourceMapEnvelope.js +17 -11
  866. package/dist/domain/sqlite/sqliteDatabase.js +188 -0
  867. package/dist/domain/staticRuntimeCorrelation.js +7 -9
  868. package/dist/domain/swiftSymbolClassification.js +17 -0
  869. package/dist/domain/symbolAnalysis.js +16 -4
  870. package/dist/domain/urlComponents.js +6 -0
  871. package/dist/domain/wasm/wasmArtifact.js +119 -0
  872. package/dist/domain/wasm/wasmInterface.js +89 -0
  873. package/dist/domain/webBundleAnalysis.js +14 -3
  874. package/dist/domain/webBundleAnalyzerAst.js +7 -2
  875. package/dist/domain/webBundleAnalyzerInspection.js +68 -40
  876. package/dist/domain/webBundleAnalyzerResult.js +18 -6
  877. package/dist/domain/webCaptureDiff.js +233 -34
  878. package/dist/domain/webCaptureFrameComparison.js +49 -0
  879. package/dist/domain/webMcpDiscovery.js +5 -2
  880. package/dist/domain/webModuleImports.js +22 -27
  881. package/dist/domain/webModuleTrace.js +3 -8
  882. package/dist/domain/webNetworkCapture.js +101 -39
  883. package/dist/domain/webNetworkCaptureCoordinates.js +21 -0
  884. package/dist/domain/webRuntime.js +0 -1
  885. package/dist/domain/webScreenshot.js +2 -2
  886. package/dist/domain/webScriptArtifacts.js +2 -4
  887. package/dist/domain/webScriptExport.js +6 -8
  888. package/dist/domain/webScriptExportError.js +10 -4
  889. package/dist/domain/webScriptExportPlan.js +9 -15
  890. package/dist/domain/webSourceLocation.js +20 -9
  891. package/dist/domain/zipPackageFormat.js +31 -2
  892. package/dist/domain/zodCollectionSteps.js +24 -0
  893. package/dist/dotnet/ManagedArtifactInspector.js +81 -54
  894. package/dist/dotnet/ManagedDecodeBudget.js +138 -0
  895. package/dist/dotnet/ManagedMemberInspector.js +113 -26
  896. package/dist/dotnet/ManagedMemberInspectorCore.js +356 -140
  897. package/dist/dotnet/ManagedMemberInstructionDecoder.js +112 -38
  898. package/dist/dotnet/ManagedMemberOwnership.js +65 -0
  899. package/dist/dotnet/ManagedMemberPointers.js +69 -0
  900. package/dist/dotnet/ManagedMemberRows.js +182 -44
  901. package/dist/dotnet/ManagedMetadataHeaps.js +123 -27
  902. package/dist/dotnet/ManagedMetadataInventory.js +5 -5
  903. package/dist/dotnet/ManagedMetadataInventoryRows.js +56 -63
  904. package/dist/dotnet/ManagedMetadataLayout.js +19 -5
  905. package/dist/dotnet/ManagedMetadataRowSizes.js +1 -1
  906. package/dist/dotnet/ManagedMethodBodyReader.js +34 -11
  907. package/dist/dotnet/ManagedMethodSpecs.js +78 -0
  908. package/dist/dotnet/ManagedNativeBoundaryHelpers.js +5 -4
  909. package/dist/dotnet/ManagedNativeBoundaryInspector.js +52 -44
  910. package/dist/dotnet/ManagedPeReader.js +96 -52
  911. package/dist/dotnet/ManagedReaderFailure.js +11 -1
  912. package/dist/dotnet/ManagedSnapshot.js +88 -0
  913. package/dist/dotnet/ManagedStaticProvider.js +57 -35
  914. package/dist/dotnet/ManagedTypeMemberLists.js +105 -0
  915. package/dist/dotnet/ManagedTypeNames.js +98 -0
  916. package/dist/dotnet/ManagedUserStrings.js +75 -0
  917. package/dist/electron/ElectronFusePath.js +247 -0
  918. package/dist/electron/ElectronFuseProvider.js +113 -0
  919. package/dist/electron/ElectronFuseReader.js +317 -0
  920. package/dist/evaluation/AgentEvaluationFixtures.js +194 -11
  921. package/dist/evaluation/AgentEvaluationReport.js +9 -5
  922. package/dist/evaluation/CodexAgentEval.js +58 -49
  923. package/dist/evaluation/KnownAnswerEvaluation.js +126 -57
  924. package/dist/evm/EvmoleFailures.js +19 -16
  925. package/dist/evm/EvmoleInterfaceAdapter.js +5 -1
  926. package/dist/evm/EvmoleInterfaceProvider.js +198 -23
  927. package/dist/evm/EvmoleInterfaceWorker.js +2 -0
  928. package/dist/evm/SolidityMetadata.js +139 -0
  929. package/dist/filesystem/OwnedDirectoryHandle.js +29 -0
  930. package/dist/filesystem/OwnedFileHandle.js +36 -0
  931. package/dist/filesystem/OwnedStagedOutput.js +138 -0
  932. package/dist/filesystem/RegularFile.js +81 -5
  933. package/dist/filesystem/StableFileHash.js +46 -0
  934. package/dist/filesystem/readFileHandleChunks.js +35 -0
  935. package/dist/firmware/FirmwareCommand.js +27 -5
  936. package/dist/firmware/FirmwareFiles.js +18 -7
  937. package/dist/firmware/FirmwareProvider.js +158 -32
  938. package/dist/firmware/FirmwarePublication.js +242 -4
  939. package/dist/firmware/FirmwareRelease.js +1 -0
  940. package/dist/firmware/FirmwareReports.js +202 -12
  941. package/dist/flutter/DartElf.js +418 -0
  942. package/dist/flutter/ElfBuildId.js +137 -0
  943. package/dist/flutter/ElfLoadMap.js +91 -0
  944. package/dist/flutter/FlutterBuildProvider.js +826 -0
  945. package/dist/flutter/FlutterPayloadScan.js +180 -0
  946. package/dist/frida/FridaInstrumentationManager.js +1104 -0
  947. package/dist/gdb/GdbSessionManager.js +1451 -0
  948. package/dist/generatedPackageMetadata.js +2 -2
  949. package/dist/ghidra/GhidraAnalysisProfile.js +175 -6
  950. package/dist/ghidra/GhidraAnalysisSeeds.js +211 -0
  951. package/dist/ghidra/GhidraClient.js +208 -29
  952. package/dist/ghidra/GhidraDiagnostics.js +18 -8
  953. package/dist/ghidra/GhidraDoctor.js +15 -12
  954. package/dist/ghidra/GhidraFunctionValues.js +73 -2
  955. package/dist/ghidra/GhidraInstallation.js +216 -20
  956. package/dist/ghidra/GhidraInstallationPolicy.js +79 -29
  957. package/dist/ghidra/GhidraInventoryValues.js +53 -1
  958. package/dist/ghidra/GhidraJavaLaunch.js +91 -10
  959. package/dist/ghidra/GhidraJavaProperties.js +117 -0
  960. package/dist/ghidra/GhidraLanguageCatalog.js +169 -0
  961. package/dist/ghidra/GhidraLauncher.js +306 -88
  962. package/dist/ghidra/GhidraLoadImageAttest.js +74 -7
  963. package/dist/ghidra/GhidraLoadImageValues.js +72 -0
  964. package/dist/ghidra/GhidraMipsProfile.js +315 -0
  965. package/dist/ghidra/GhidraPeProfile.js +21 -0
  966. package/dist/ghidra/GhidraPowerPcProfile.js +51 -0
  967. package/dist/ghidra/GhidraProvider.js +106 -20
  968. package/dist/ghidra/GhidraProviderCapabilities.js +30 -19
  969. package/dist/ghidra/GhidraProviderClient.js +520 -56
  970. package/dist/ghidra/GhidraPspExtension.js +140 -0
  971. package/dist/ghidra/GhidraPspProfile.js +59 -0
  972. package/dist/ghidra/GhidraRawBinaryLanguage.js +40 -0
  973. package/dist/ghidra/GhidraRiscvProfile.js +100 -0
  974. package/dist/ghidra/GhidraSessionError.js +155 -11
  975. package/dist/ghidra/GhidraSessionValues.js +75 -2
  976. package/dist/ghidra/GhidraTransport.js +2 -1
  977. package/dist/go/GoBinaryContainer.js +140 -0
  978. package/dist/go/GoBinaryImage.js +210 -0
  979. package/dist/go/GoBinaryProvider.js +151 -0
  980. package/dist/go/GoElfImage.js +211 -0
  981. package/dist/go/GoMachoImage.js +164 -0
  982. package/dist/go/GoModuleText.js +217 -0
  983. package/dist/go/GoPeImage.js +124 -0
  984. package/dist/hopper/BridgeLauncher.js +35 -2
  985. package/dist/hopper/HopperAnalysisProfile.js +21 -9
  986. package/dist/hopper/HopperCleanup.js +15 -3
  987. package/dist/hopper/HopperClient.js +203 -42
  988. package/dist/hopper/HopperMacPublisher.js +29 -0
  989. package/dist/hopper/HopperMachOImage.js +61 -27
  990. package/dist/hopper/HopperProcessDiagnostic.js +27 -0
  991. package/dist/hopper/HopperProvider.js +68 -26
  992. package/dist/hopper/HopperProviderCapabilities.js +7 -3
  993. package/dist/hopper/HopperRequestQueue.js +17 -5
  994. package/dist/hopper/HopperSessionValues.js +10 -1
  995. package/dist/hopper/HopperTargetLease.js +66 -19
  996. package/dist/ida/IdaBusyHealth.js +44 -0
  997. package/dist/ida/IdaCallGraph.js +134 -0
  998. package/dist/ida/IdaConfiguration.js +7 -2
  999. package/dist/ida/IdaDiagnosticRedactor.js +199 -0
  1000. package/dist/ida/IdaDiagnosticWriter.js +62 -0
  1001. package/dist/ida/IdaDoctor.js +7 -5
  1002. package/dist/ida/IdaJsonDiagnostic.js +138 -0
  1003. package/dist/ida/IdaMcpConnection.js +297 -27
  1004. package/dist/ida/IdaNativeProtocol.js +93 -0
  1005. package/dist/ida/IdaOperationRunner.js +249 -40
  1006. package/dist/ida/IdaProtocolValues.js +86 -4
  1007. package/dist/ida/IdaProvider.js +34 -8
  1008. package/dist/ida/IdaProviderCapabilities.js +37 -8
  1009. package/dist/ida/IdaSessionClient.js +332 -53
  1010. package/dist/ida/IdaWorkspace.js +57 -7
  1011. package/dist/inspector/V8InspectorCaptureProjection.js +7 -2
  1012. package/dist/inspector/V8InspectorEndpoint.js +15 -13
  1013. package/dist/inspector/V8InspectorProvider.js +41 -7
  1014. package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +337 -0
  1015. package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +594 -0
  1016. package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +65 -0
  1017. package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +590 -0
  1018. package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +126 -0
  1019. package/dist/javascript/recovery/RecoveryFiles.js +68 -12
  1020. package/dist/javascript/recovery/WakaruCommand.js +22 -9
  1021. package/dist/javascript/recovery/WakaruExecution.js +30 -18
  1022. package/dist/javascript/recovery/WakaruProvider.js +150 -24
  1023. package/dist/javascript/recovery/WakaruPublication.js +38 -14
  1024. package/dist/javascript/recovery/WakaruRelease.js +11 -4
  1025. package/dist/javascript/recovery/WakaruReport.js +15 -9
  1026. package/dist/javascript/recovery/WakaruVersion.js +24 -0
  1027. package/dist/javascript/sourceMaps/DecodedSourceMap.js +2 -16
  1028. package/dist/javascript/sourceMaps/SourceMapCommand.js +38 -7
  1029. package/dist/javascript/sourceMaps/SourceMapDecoder.js +84 -10
  1030. package/dist/javascript/sourceMaps/SourceMapFormat.js +26 -28
  1031. package/dist/javascript/sourceMaps/TraceSourceMap.js +34 -6
  1032. package/dist/jeb/JebMcpConnection.js +186 -0
  1033. package/dist/jeb/JebMcpEndpoint.js +45 -0
  1034. package/dist/jeb/JebProvider.js +297 -0
  1035. package/dist/logger.js +14 -1
  1036. package/dist/main/shutdown.js +3 -0
  1037. package/dist/main/transport.js +48 -4
  1038. package/dist/main.js +14 -3
  1039. package/dist/mcp/AnalysisSnapshotFiles-BAbiJQOc.js +1412 -0
  1040. package/dist/mcp/ArtifactProvider-DViCU_rn.js +2183 -0
  1041. package/dist/mcp/ArtifactProviderMetadata-b7pOK5_t.js +76 -0
  1042. package/dist/mcp/ArtifactReader-OyM03Gjn.js +55 -0
  1043. package/dist/mcp/ArtifactResourceScope-P3tq5z8Z.js +162 -0
  1044. package/dist/mcp/AsarHeader-WsPgoooH.js +31 -0
  1045. package/dist/mcp/BinarySessionStatus-B4P9gf-S.js +212 -0
  1046. package/dist/mcp/BinaryTargetResolver-BMaE_0H1.js +1427 -0
  1047. package/dist/mcp/BoundedFileBytes-DuczXiQZ.js +68 -0
  1048. package/dist/mcp/CdpCaptureDocuments-HDiF2O7k.js +746 -0
  1049. package/dist/mcp/CdpCaptureValues-M-j6CIh1.js +90 -0
  1050. package/dist/mcp/CdpConnection-BpDfz4MK.js +570 -0
  1051. package/dist/mcp/CdpOptionalCommand-BPjRD9Kz.js +120 -0
  1052. package/dist/mcp/CdpTargetSession-BsPoKhEU.js +86 -0
  1053. package/dist/mcp/DirectAnalysis-DrafbXke.js +409 -0
  1054. package/dist/mcp/DirectAnalysisStatus-CjjeDLzW.js +44 -0
  1055. package/dist/mcp/ElectronFileScope-BPG_YoyU.js +110 -0
  1056. package/dist/mcp/InterfaceBuilderDecodeBudget-5F2AkxJT.js +652 -0
  1057. package/dist/mcp/ManagedStaticProvider-BthZbKyZ.js +5028 -0
  1058. package/dist/mcp/NativeMacOSProvider-Bh79k8dI.js +4867 -0
  1059. package/dist/mcp/NativeMacOSProviderMetadata-N1lPOaY_.js +307 -0
  1060. package/dist/mcp/ProcedureAddressResolution-CQpuwm1h.js +19 -0
  1061. package/dist/mcp/ProcessOwnership-Bl_3ejLe.js +1502 -0
  1062. package/dist/mcp/ProviderDeadline-DskQ94YD.js +932 -0
  1063. package/dist/mcp/WorkflowEvidence-umWrB_wm.js +111 -0
  1064. package/dist/mcp/analysisErrorCore-DXRTvF_m.js +235 -0
  1065. package/dist/mcp/analysisErrorProjection-BN0EPM-3.js +892 -0
  1066. package/dist/mcp/artifactOperationError-CkHMMaf7.js +27 -0
  1067. package/dist/mcp/artifactToolContracts-Di4qZlEt.js +72 -0
  1068. package/dist/mcp/browserObservation-C0s4i8UI.js +4468 -0
  1069. package/dist/mcp/browserObservationError-CyLugqX4.js +40 -0
  1070. package/dist/mcp/browserObservationSchemas-tgqjH7aA.js +573 -0
  1071. package/dist/mcp/browserScenario-CAQ8Fns9.js +2929 -0
  1072. package/dist/mcp/browserScenarioCapture-CTNFN-FI.js +479 -0
  1073. package/dist/mcp/canonicalDigest-Bi_0_zGi.js +71 -0
  1074. package/dist/mcp/digests-BFoWUT_-.js +223 -0
  1075. package/dist/mcp/electronActiveObservation-lDvQTMR0.js +226 -0
  1076. package/dist/mcp/electronObservation-DFOFEood.js +112 -0
  1077. package/dist/mcp/electronObservation-i7LcILQ-.js +562 -0
  1078. package/dist/mcp/electronScenario-nCzE6IfJ.js +653 -0
  1079. package/dist/mcp/emptyArraySchema-tL6Qymyd.js +140 -0
  1080. package/dist/mcp/enhancedInputs-DgdEnzHy.js +56 -0
  1081. package/dist/mcp/javascriptRuntimeObservation-61NhCf7H.js +690 -0
  1082. package/dist/mcp/javascriptRuntimeObservation-PIUoLfX6.js +121 -0
  1083. package/dist/mcp/jsonSerialization-V-wWiFRE.js +152 -0
  1084. package/dist/mcp/lipo-Bnkoq_6W.js +502 -0
  1085. package/dist/mcp/localPath-AxvW9aPe.js +19 -0
  1086. package/dist/mcp/logger-BQY5ulYv.js +48 -0
  1087. package/dist/mcp/main-kBXHZ8S5.js +69390 -0
  1088. package/dist/mcp/main.js +6 -0
  1089. package/dist/mcp/managedToolContracts-CK--I_s7.js +101 -0
  1090. package/dist/mcp/nativeValueTrace-DR9UE62L.js +3439 -0
  1091. package/dist/mcp/officialToolContracts-B67NJ2tC.js +1413 -0
  1092. package/dist/mcp/pngHeader-DQ-ObyY2.js +147 -0
  1093. package/dist/mcp/propertyListKeys-DD25WsjI.js +553 -0
  1094. package/dist/mcp/providerAdapterError-sDxToNal.js +25 -0
  1095. package/dist/mcp/providerIdentities--ptAh481.js +31 -0
  1096. package/dist/mcp/providerIdentity-BCQ5n5tw.js +16 -0
  1097. package/dist/mcp/providerOperationHealth-CTYa3iLf.js +48 -0
  1098. package/dist/mcp/rolldown-runtime-BjeaiXFo.js +121 -0
  1099. package/dist/mcp/safeJson-NeGfpkrI.js +25 -0
  1100. package/dist/mcp/scanCanonical-CRXSpule.js +3982 -0
  1101. package/dist/mcp/serverIdentity-Cio4iFV3.js +1328 -0
  1102. package/dist/mcp/sourceMapEnvelope-C0uJlrOh.js +94 -0
  1103. package/dist/mcp/toolContracts-BW05wpcr.js +12200 -0
  1104. package/dist/mcp/toolOutputSchemaGroups-ColvNZ1r.js +17533 -0
  1105. package/dist/mcp/unicodeCodePointOrder-BezCbTpg.js +26 -0
  1106. package/dist/mcp/webContentArtifact-Dzjc1z-R.js +284 -0
  1107. package/dist/mcp/webRuntime-K__NYzXm.js +74 -0
  1108. package/dist/mcp/webSourceLocation-DbMAT2J9.js +11130 -0
  1109. package/dist/mcpDoctor.js +108 -76
  1110. package/dist/mcpStartupPolicy.js +3 -0
  1111. package/dist/native/AppleDispatchCoverage.js +81 -28
  1112. package/dist/native/AppleDispatchMetadata.js +20 -9
  1113. package/dist/native/AppleMachoFixups.js +253 -34
  1114. package/dist/native/AppleMachoSelection.js +44 -17
  1115. package/dist/native/AppleObjcCategories.js +1 -2
  1116. package/dist/native/AppleObjcDispatchFacets.js +76 -7
  1117. package/dist/native/CommandRunner.js +142 -32
  1118. package/dist/native/LldbCallTracer.js +5 -3
  1119. package/dist/native/MachoArchitectureSelection.js +50 -0
  1120. package/dist/native/NativeCallObservation.js +2 -1
  1121. package/dist/native/NativeMacOSProvider.js +173 -37
  1122. package/dist/native/NativeMachoInspection.js +142 -78
  1123. package/dist/native/NativeUiHelperRuntime.js +6 -1
  1124. package/dist/native/NativeUiObservation.js +6 -5
  1125. package/dist/native/SignatureTargetBinding.js +118 -55
  1126. package/dist/native/parsers/codesign.js +27 -10
  1127. package/dist/native/parsers/demangle.js +7 -1
  1128. package/dist/native/parsers/dyldInfo.js +73 -4
  1129. package/dist/native/parsers/lipo.js +53 -19
  1130. package/dist/native/parsers/machoUuid.js +150 -0
  1131. package/dist/native/parsers/otool.js +232 -29
  1132. package/dist/native/pe/PeResourceLayout.js +120 -0
  1133. package/dist/native/pe/PeResourceParser.js +286 -0
  1134. package/dist/native/pe/PeResourcesProvider.js +77 -0
  1135. package/dist/native/pwndbg/PwndbgCoreContext.js +20 -20
  1136. package/dist/native/pwntools/PwntoolsDecoder.js +264 -40
  1137. package/dist/native/pwntools/PwntoolsFailures.js +2 -1
  1138. package/dist/native/pwntools/PwntoolsInputLimit.js +27 -0
  1139. package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +27 -15
  1140. package/dist/native/pwntools/PwntoolsResourceLimits.js +3 -3
  1141. package/dist/native/pwntools/RecordedCrashSourceBindings.js +12 -8
  1142. package/dist/native/pwntools/RecordedCrashStructureBindings.js +3 -1
  1143. package/dist/objdump/ObjdumpCommand.js +21 -0
  1144. package/dist/pcap/PcapCommand.js +146 -0
  1145. package/dist/pcap/PcapConfiguration.js +93 -0
  1146. package/dist/pcap/PcapNativeBound.js +58 -0
  1147. package/dist/pcap/PcapOutput.js +240 -0
  1148. package/dist/pcap/PcapProvider.js +424 -0
  1149. package/dist/pcap/PcapSnapshot.js +171 -0
  1150. package/dist/process/ArtifactAnalysisResources.js +213 -0
  1151. package/dist/process/BoundedFileBytes.js +30 -7
  1152. package/dist/process/CurrentEntrypointPath.js +6 -0
  1153. package/dist/process/DarwinProcessRunTokenReader.js +125 -16
  1154. package/dist/process/ExecFileBoundedOutput.js +44 -0
  1155. package/dist/process/ExecFileOutput.js +30 -6
  1156. package/dist/process/JavaScriptWorkerMemoryLimit.js +25 -0
  1157. package/dist/process/LinuxResourceLimits.js +80 -0
  1158. package/dist/process/MacCodeSignature.js +3 -0
  1159. package/dist/process/OwnedCommand.js +40 -15
  1160. package/dist/process/PrivateRuntimeRoot.js +9 -19
  1161. package/dist/process/PrivateRuntimeRootUnavailableError.js +10 -0
  1162. package/dist/process/ProcessOwnership.js +173 -128
  1163. package/dist/process/ProcessOwnershipObservation.js +131 -43
  1164. package/dist/process/ProcessOwnershipProcessTree.js +4 -4
  1165. package/dist/process/ProcessRunTokenObservations.js +48 -0
  1166. package/dist/process/ProviderDeadline.js +58 -12
  1167. package/dist/process/ProviderDiagnosticRedaction.js +17 -0
  1168. package/dist/process/ProviderProcess.js +112 -14
  1169. package/dist/process/WindowsAuthority.js +48 -39
  1170. package/dist/process/WindowsBatchCommand.js +46 -0
  1171. package/dist/process/boundedUtf8Text.js +13 -0
  1172. package/dist/process/capture/FilesystemSnapshot.js +87 -12
  1173. package/dist/process/capture/ProcessCaptureClock.js +2 -0
  1174. package/dist/process/capture/ProcessCaptureError.js +22 -3
  1175. package/dist/process/capture/ProcessCaptureJournal.js +2 -1
  1176. package/dist/process/capture/ProcessCaptureLifecycle.js +433 -91
  1177. package/dist/process/capture/ProcessCaptureProgress.js +63 -0
  1178. package/dist/process/capture/ProcessHarness.js +209 -38
  1179. package/dist/process/capture/ProcessNormalization.js +278 -34
  1180. package/dist/process/capture/ProcessSampling.js +3 -2
  1181. package/dist/process/capture/ProcessScenarioRuntimeValidation.js +18 -15
  1182. package/dist/process/capture/TerminalRenderer.js +52 -14
  1183. package/dist/process/ownedDebuggerSession.js +203 -0
  1184. package/dist/reference/ReferenceSourceReader.js +22 -6
  1185. package/dist/reference/ReferenceSourceReaderEntries.js +182 -105
  1186. package/dist/reference/ReferenceSourceReaderErrors.js +17 -1
  1187. package/dist/reference/ReferenceSourceReaderFile.js +50 -11
  1188. package/dist/reference/ReferenceSourceReaderTypes.js +1 -2
  1189. package/dist/reference/ReferenceSourceReaderValidate.js +4 -5
  1190. package/dist/rizin/RizinCommand.js +14 -0
  1191. package/dist/rizin/RizinDebugSessionManager.js +1072 -0
  1192. package/dist/rust/RustAuditableReader.js +309 -0
  1193. package/dist/rust/RustBinaryImage.js +116 -0
  1194. package/dist/rust/RustBinaryProvider.js +162 -0
  1195. package/dist/server/EvidenceMcpServer.js +185 -27
  1196. package/dist/server/admittedToolOperation.js +14 -0
  1197. package/dist/server/contractToolHandler.js +28 -0
  1198. package/dist/server/createServer.js +238 -36
  1199. package/dist/server/externalMutationAdmission.js +50 -0
  1200. package/dist/server/mcpProgress.js +4 -2
  1201. package/dist/server/promptCompletion.js +19 -6
  1202. package/dist/server/providerEnvironment.js +3 -0
  1203. package/dist/server/registerAdbTools.js +36 -0
  1204. package/dist/server/registerAnalysisViewTool.js +9 -10
  1205. package/dist/server/registerAndroidTools.js +22 -13
  1206. package/dist/server/registerApktoolTools.js +14 -0
  1207. package/dist/server/registerApplicationTools/compareExportShapes.js +4 -6
  1208. package/dist/server/registerApplicationTools/compareSourceToBundle.js +4 -5
  1209. package/dist/server/registerApplicationTools/compareVersions.js +3 -2
  1210. package/dist/server/registerApplicationTools/coverage.js +3 -2
  1211. package/dist/server/registerApplicationTools/obligationLedger.js +3 -2
  1212. package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +11 -3
  1213. package/dist/server/registerApplicationTools/traceFeature.js +3 -2
  1214. package/dist/server/registerApplicationTools/traceSemantics.js +4 -5
  1215. package/dist/server/registerArtifactComparisonTool.js +5 -2
  1216. package/dist/server/registerArtifactTools.js +21 -1
  1217. package/dist/server/registerBinaryDiagnosticsTools.js +16 -4
  1218. package/dist/server/registerBrowserScenarioTool.js +10 -7
  1219. package/dist/server/registerBrowserTools.js +14 -13
  1220. package/dist/server/registerBundleComparisonTool.js +20 -6
  1221. package/dist/server/registerCaptureTools.js +12 -0
  1222. package/dist/server/registerCloseLifecycleTool.js +32 -3
  1223. package/dist/server/registerCutterTools.js +33 -0
  1224. package/dist/server/registerElectronTools.js +38 -17
  1225. package/dist/server/registerEnhancedTools.js +7 -6
  1226. package/dist/server/registerEvidenceTools.js +14 -10
  1227. package/dist/server/registerEvmTools.js +24 -11
  1228. package/dist/server/registerFirmwareTools.js +3 -11
  1229. package/dist/server/registerFlutterTools.js +17 -0
  1230. package/dist/server/registerFridaTools.js +205 -0
  1231. package/dist/server/registerFunctionComparisonTool.js +34 -11
  1232. package/dist/server/registerGdbTools.js +64 -0
  1233. package/dist/server/registerGoTools.js +9 -0
  1234. package/dist/server/registerInvestigationTools/helpers.js +2 -2
  1235. package/dist/server/registerInvestigationTools.js +12 -8
  1236. package/dist/server/registerJavaScriptRecoveryTool.js +4 -9
  1237. package/dist/server/registerJavaScriptRuntimeObservationTools.js +10 -11
  1238. package/dist/server/registerJebTools.js +16 -0
  1239. package/dist/server/registerManagedTools.js +11 -1
  1240. package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -6
  1241. package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -2
  1242. package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +3 -2
  1243. package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +3 -2
  1244. package/dist/server/registerNativeTools.js +14 -0
  1245. package/dist/server/registerOfficialTools.js +5 -0
  1246. package/dist/server/registerPcapTools.js +35 -0
  1247. package/dist/server/registerPeResourcesTool.js +9 -0
  1248. package/dist/server/registerProcessComparisonTool.js +14 -4
  1249. package/dist/server/registerRecordedCrashTools.js +4 -9
  1250. package/dist/server/registerReverseEngineeringTools.js +86 -0
  1251. package/dist/server/registerRizinDebugTools.js +53 -0
  1252. package/dist/server/registerRustTools.js +9 -0
  1253. package/dist/server/registerSessionRecordTools.js +21 -14
  1254. package/dist/server/registerSessionStatusTool.js +22 -4
  1255. package/dist/server/registerSessionTools.js +78 -34
  1256. package/dist/server/registerSignalTools.js +12 -0
  1257. package/dist/server/registerSqliteTools.js +9 -0
  1258. package/dist/server/registerWasmTools.js +46 -0
  1259. package/dist/server/registerWebModuleTool.js +4 -9
  1260. package/dist/server/registerWebNetworkCaptureTool.js +26 -17
  1261. package/dist/server/registerWebRuntimeTools.js +6 -5
  1262. package/dist/server/registerWebScriptTool.js +6 -3
  1263. package/dist/server/registerWebSourceLocationTool.js +4 -9
  1264. package/dist/server/retainedSummaryDelivery.js +28 -0
  1265. package/dist/server/sessionAvailabilityPolicy.js +3 -0
  1266. package/dist/server/toolRegistrationOptions.js +8 -0
  1267. package/dist/server/toolResult.js +68 -16
  1268. package/dist/server/toolResultEncoding.js +36 -3
  1269. package/dist/serverIdentity.js +17 -8
  1270. package/dist/signals/SigrokRecordingProvider.js +339 -0
  1271. package/dist/signals/parseDecoderDiscovery.js +65 -0
  1272. package/dist/sqlite/SqliteDatabaseFailures.js +134 -0
  1273. package/dist/sqlite/SqliteDatabaseInspection.js +421 -0
  1274. package/dist/sqlite/SqliteDatabaseLimits.js +16 -0
  1275. package/dist/sqlite/SqliteDatabaseProvider.js +295 -0
  1276. package/dist/sqlite/SqliteDatabaseSnapshot.js +156 -0
  1277. package/dist/sqlite/SqliteDatabaseWorker.js +46 -0
  1278. package/dist/sqlite/SqliteDatabaseWorkerExecution.js +112 -0
  1279. package/dist/wasm/WabtArtifactProvider.js +336 -0
  1280. package/dist/wasm/WabtFailures.js +101 -0
  1281. package/dist/wasm/WabtInterface.js +309 -0
  1282. package/dist/wasm/WabtOutput.js +60 -0
  1283. package/dist/wasm/WabtRelease.js +12 -0
  1284. package/dist/wasm/WabtString.js +48 -0
  1285. package/dist/wasm/WabtWat.js +147 -0
  1286. package/dist/wasm/WasmGlueAdapter.js +53 -0
  1287. package/dist/wasm/WasmInterfaceBudget.js +11 -0
  1288. package/dist/windows/WindowsNativeLoader.js +37 -7
  1289. package/dist/windows/WindowsOwnedProcess.js +150 -17
  1290. package/dist/windows/WindowsPrivateRuntime.js +34 -6
  1291. package/install.sh +157 -95
  1292. package/licenses/Apache-2.0.txt +202 -0
  1293. package/licenses/GCC-Runtime-Library-Exception-3.1.txt +73 -0
  1294. package/licenses/GPL-3.0.txt +674 -0
  1295. package/licenses/LGPL-2.0.txt +480 -0
  1296. package/licenses/MIT-template.txt +18 -0
  1297. package/licenses/MinGW-w64-runtime.txt +240 -0
  1298. package/licenses/Node-22.19.0-LICENSE.txt +2666 -0
  1299. package/licenses/README.md +68 -0
  1300. package/licenses/cfworker-MIT.txt +21 -0
  1301. package/licenses/dotnet-runtime-MIT.txt +23 -0
  1302. package/licenses/frida-17.23.2-COPYING.txt +50 -0
  1303. package/licenses/ghidra-12.1.4-DISCLAIMER.txt +13 -0
  1304. package/licenses/ghidra-12.1.4-LICENSE.txt +201 -0
  1305. package/licenses/ghidra-12.1.4-NOTICE.txt +49 -0
  1306. package/licenses/nativeaot-parser-MIT.txt +28 -0
  1307. package/licenses/npm-dependencies.txt +3612 -0
  1308. package/licenses/npm-runtime-notices.txt +8548 -0
  1309. package/licenses/upstream-sources.json +72 -0
  1310. package/licenses/xterm-MIT.txt +21 -0
  1311. package/native/windows/README.md +92 -11
  1312. package/native/windows/build/manifest.json +2 -2
  1313. package/native/windows/build/rea-windows-x64.node +0 -0
  1314. package/package.json +117 -22
  1315. package/scripts/electron-active-hook.cjs +4 -1
  1316. package/scripts/hopper-demo-x11.py +53 -3
  1317. package/scripts/prepack.mjs +5 -0
  1318. package/scripts/rea-android-workspace-guardian.mjs +46 -0
  1319. package/scripts/rea.mjs +44 -13
  1320. package/scripts/verify-windows-native-artifact.mjs +2 -2
  1321. package/skills/reverse-engineer-anything/SKILL.md +142 -20
  1322. package/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
  1323. package/skills/reverse-engineer-anything/references/evidence-workflows.md +31 -0
  1324. package/skills/reverse-engineer-anything/references/javascript-applications.md +118 -13
  1325. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +147 -16
  1326. package/skills/reverse-engineer-anything/references/runtime-observation.md +57 -7
  1327. package/third_party/README.md +1 -1
  1328. package/third_party/wabt/README.md +24 -0
  1329. package/dist/browser/history/HarCaptureAdapter.js +0 -20
  1330. package/dist/cli/streamedJsonOutput.js +0 -135
  1331. package/dist/cliJsonFile.js +0 -179
  1332. /package/dist/{application/binary → process}/AbortablePromise.js +0 -0
@@ -0,0 +1,4468 @@
1
+ import { t as __esmMin } from "./rolldown-runtime-BjeaiXFo.js";
2
+ import { _ as ok, d as AnalysisUnsupportedTargetError, f as init_analysisErrorCore, g as init_result, h as err, i as AnalysisCancelledError, l as AnalysisResourceConstraintError, m as init_analysisErrorBase, o as AnalysisInputError, p as AnalysisError } from "./analysisErrorCore-DXRTvF_m.js";
3
+ import { n as safeParseJson, t as init_safeJson } from "./safeJson-NeGfpkrI.js";
4
+ import { c as jsonValueSchema, o as init_jsonValue } from "./digests-BFoWUT_-.js";
5
+ import { n as compositeKey, r as init_unicodeCodePointOrder, t as compareUnicodeCodePoints } from "./unicodeCodePointOrder-BezCbTpg.js";
6
+ import { n as init_providerAdapterError, t as ProviderAdapterError } from "./providerAdapterError-sDxToNal.js";
7
+ import { n as init_browserObservationError, t as BrowserObservationError } from "./browserObservationError-CyLugqX4.js";
8
+ import { i as jsonParts, r as init_jsonSerialization } from "./jsonSerialization-V-wWiFRE.js";
9
+ import { n as init_canonicalDigest, t as digestCanonicalValue } from "./canonicalDigest-Bi_0_zGi.js";
10
+ import { n as readPngHeaderDimensions, o as resolveJavaScriptSourceMapUrl, r as init_javascriptSourceMapPaths, t as init_pngHeader } from "./pngHeader-DQ-ObyY2.js";
11
+ import { c as init_browserObservation$1, h as sanitizeEndpointCandidate, m as sanitizeBrowserUrl, n as init_webContentArtifact, t as createWebTextArtifact } from "./webContentArtifact-Dzjc1z-R.js";
12
+ import { a as inferJsonShape, i as webPageInspectionSchema, o as init_jsonShape, r as init_browserObservationSchemas, t as browserTargetListSchema } from "./browserObservationSchemas-tgqjH7aA.js";
13
+ import { a as createWebScreenshotArtifact, l as webScreenshotDiffSchema, o as decodeCanonicalBase64, s as init_webScreenshot, u as webScreenshotSchema } from "./emptyArraySchema-tL6Qymyd.js";
14
+ import { At as init_javascriptAstValues, C as init_javascriptSemanticAnalysis, D as parseJavaScriptSource, E as init_javascriptSourceParser, H as isTypeOnlyExportDeclaration, Ht as init_javascriptSemanticTraversal, It as semanticStaticPropertyName, Nt as readExactJavaScriptLiteral, T as init_javascriptRpcEndpoints, Ut as traverseJavaScriptAst, V as init_javascriptModuleDeclaration, Vt as completeSemanticSteps, W as isTypeOnlyImportDeclaration, Xt as compareBrowserCaptures, Yt as browserCaptureComparisonSchema, Zt as init_browserCaptureComparison, an as webObservationSessionSchema, b as classifyParsedJavaScriptRpcClientRootsSteps, cn as webBundleAnalysisSchema, ct as calleeName, dt as endpointArgument, g as analyzeParsedJavaScriptReferences, kt as stringValue, ln as webSourceMapsSchema, mt as init_javascriptStaticAnalysisHelpers, n as init_webSourceLocation, nn as webMcpDiscoverySchema, rn as init_browserSession, sn as init_webBundleAnalysis, t as WEB_SOURCE_MAP_LIMITS, tn as init_webMcpDiscovery, v as classifyParsedJavaScriptOpenReceivers, w as createJavaScriptRpcScan } from "./webSourceLocation-DbMAT2J9.js";
15
+ import { a as init_providerIdentities, t as CDP_BROWSER_PROVIDER_IDENTITY } from "./providerIdentities--ptAh481.js";
16
+ import { a as init_CdpTargetEvents, c as authorizeCdpTarget, i as cdpTargetEventMatches, l as init_CdpAuthorizedTarget, n as init_sourceMapEnvelope, o as authorizedMainFrame, r as sourceMapJsonText, s as init_CdpAuthorizedMainFrame } from "./sourceMapEnvelope-C0uJlrOh.js";
17
+ import { a as isHttpUrl, c as recordsValue, d as scriptMetadataValues, f as sourceExcluded, i as init_CdpCaptureValues, n as cdpStringValue, o as numberValue, p as sourceResult, r as delayWithCancellation, s as recordValue, t as allowedSanitizedUrl, u as requiredScriptSource } from "./CdpCaptureValues-M-j6CIh1.js";
18
+ import { _ as integerOrNull$1, a as init_CdpCaptureDocuments, b as isMainFrameNavigation, c as capturedSvgNodeKind, d as decodeBase64$1, f as exclusionReasonForUrl, g as initiatorLocation, h as init_CdpCaptureEventHelpers, i as captureResources, l as init_CdpCaptureDomSvg, m as firstCallFrame, n as captureDom, o as mainFrameUrl, p as executionContextKey, r as captureFrames, s as walkFrameTrees, t as captureAccessibility, u as consolePrimitive, v as isJsonContentType, y as isJsonMediaType } from "./CdpCaptureDocuments-HDiF2O7k.js";
19
+ import { c as hasCdpTargetWebSocket, i as init_CdpCommandRejection, l as init_CdpEndpoint, n as init_CdpConnection, r as CdpCommandRejection } from "./CdpConnection-BpDfz4MK.js";
20
+ import { a as openCdpTargetSession, i as openCdpEndpoint, n as closeCdpTargetSession, r as init_CdpTargetSession, t as attachCdpTargetSession } from "./CdpTargetSession-BsPoKhEU.js";
21
+ import { i as init_CdpCaptureCompleteness, n as optionalCdpCommand, r as CdpCaptureCompleteness, t as init_CdpOptionalCommand } from "./CdpOptionalCommand-BPjRD9Kz.js";
22
+ import { z } from "zod";
23
+ import { createHash } from "node:crypto";
24
+ import canonicalize from "canonicalize";
25
+ import { TraceMap, decodedMappings } from "@jridgewell/trace-mapping";
26
+ import * as t from "@babel/types";
27
+ import { constants, crc32, inflateSync } from "node:zlib";
28
+
29
+ //#region dist/domain/webBundleAnalyzerAst.js
30
+ var objectValue, objectString, isUrlLikeModuleSpecifier, resolveSpecifier, location, locationFields;
31
+ function init_webBundleAnalyzerAst() {
32
+ return (init_webBundleAnalyzerAst = __esmMin((() => {
33
+ init_browserObservation$1();
34
+ init_javascriptAstValues();
35
+ objectValue = (object, name) => {
36
+ let value;
37
+ for (const property of object.properties) {
38
+ if (t.isSpreadElement(property)) {
39
+ value = undefined;
40
+ continue;
41
+ }
42
+ const key = semanticStaticPropertyName(property.key, property.computed);
43
+ if (key === "" && !t.isStringLiteral(property.key)) value = undefined;
44
+ else if (key === name) value = t.isObjectProperty(property) ? property.value : undefined;
45
+ }
46
+ return value;
47
+ };
48
+ objectString = (object, name) => {
49
+ const value = objectValue(object, name);
50
+ if (value === undefined) return undefined;
51
+ const literal = readExactJavaScriptLiteral(value);
52
+ return literal.found && typeof literal.value === "string" ? literal.value : undefined;
53
+ };
54
+ isUrlLikeModuleSpecifier = (specifier) => specifier.startsWith("/") || specifier.startsWith("./") || specifier.startsWith("../") || /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(specifier);
55
+ resolveSpecifier = (specifier, base) => {
56
+ try {
57
+ const resolved = new URL(specifier, base);
58
+ if (resolved.protocol !== "http:" && resolved.protocol !== "https:") return null;
59
+ return sanitizeBrowserUrl(resolved.href).url;
60
+ } catch (cause) {
61
+ void cause;
62
+ return null;
63
+ }
64
+ };
65
+ location = (scriptKey, node) => ({
66
+ script_key: scriptKey,
67
+ ...locationFields(node)
68
+ });
69
+ locationFields = (node) => ({
70
+ line: node.loc?.start.line ?? null,
71
+ column: node.loc?.start.column ?? null
72
+ });
73
+ })))();
74
+ }
75
+
76
+ //#endregion
77
+ //#region dist/domain/webBundleAnalyzerInspection.js
78
+ var analyzeScript, inspectNode, inspectCall, inspectRouteProperty, addEdge, addEndpointCandidate, addFinding, addWebMcpDeclaration, detectVendorFingerprints, addRouteFrameworkInference, addUnique, basis, emptyAccumulator, isIncludedScript, routeCallNames, vendorDetectors;
79
+ function init_webBundleAnalyzerInspection() {
80
+ return (init_webBundleAnalyzerInspection = __esmMin((() => {
81
+ init_browserObservation$1();
82
+ init_unicodeCodePointOrder();
83
+ init_javascriptSemanticTraversal();
84
+ init_javascriptSemanticAnalysis();
85
+ init_javascriptAstValues();
86
+ init_javascriptStaticAnalysisHelpers();
87
+ init_webBundleAnalyzerAst();
88
+ init_javascriptRpcEndpoints();
89
+ init_javascriptSourceParser();
90
+ analyzeScript = (script, accumulator) => {
91
+ const file = parseJavaScriptSource(script.source.artifact.text);
92
+ if (file === null) {
93
+ accumulator.failedScripts.push(script.script_key);
94
+ return;
95
+ }
96
+ accumulator.parsedScripts += 1;
97
+ if ((file.errors?.length ?? 0) > 0) accumulator.recoveredScripts.push(script.script_key);
98
+ detectVendorFingerprints(script, accumulator);
99
+ const openReceiverFacts = classifyParsedJavaScriptOpenReceivers(file);
100
+ const rpc = createJavaScriptRpcScan(script.source.artifact.text, completeSemanticSteps(classifyParsedJavaScriptRpcClientRootsSteps(file)));
101
+ traverseJavaScriptAst(file, { enter: (node) => {
102
+ accumulator.visitedNodes += 1;
103
+ inspectNode(script, node, accumulator, openReceiverFacts);
104
+ const endpoint = rpc.inspect(node);
105
+ if (endpoint !== undefined) addFinding({
106
+ collection: accumulator.endpoints,
107
+ script,
108
+ rawValue: endpoint.value,
109
+ mechanism: endpoint.mechanism,
110
+ node,
111
+ accumulator
112
+ });
113
+ } });
114
+ };
115
+ inspectNode = (script, node, accumulator, openReceiverFacts) => {
116
+ if ((t.isImportDeclaration(node) || t.isExportAllDeclaration(node)) && node.source !== undefined) addEdge({
117
+ script,
118
+ specifier: node.source.value,
119
+ kind: "static_import",
120
+ node,
121
+ accumulator
122
+ });
123
+ else if (t.isExportNamedDeclaration(node) && node.source != null) addEdge({
124
+ script,
125
+ specifier: node.source.value,
126
+ kind: "static_import",
127
+ node,
128
+ accumulator
129
+ });
130
+ else if (t.isImportExpression(node)) {
131
+ const specifier = stringValue(node.source);
132
+ if (specifier !== undefined) addEdge({
133
+ script,
134
+ specifier,
135
+ kind: "dynamic_import",
136
+ node,
137
+ accumulator
138
+ });
139
+ }
140
+ if (t.isObjectProperty(node)) inspectRouteProperty(script, node, accumulator);
141
+ if (t.isCallExpression(node) || t.isOptionalCallExpression(node) || t.isNewExpression(node)) inspectCall(script, node, accumulator, openReceiverFacts);
142
+ };
143
+ inspectCall = (script, node, accumulator, openReceiverFacts) => {
144
+ const name = calleeName(node.callee);
145
+ const first = stringValue(node.arguments[0]);
146
+ if ((name === "require" || name.endsWith(".require")) && first !== undefined) addEdge({
147
+ script,
148
+ specifier: first,
149
+ kind: "require",
150
+ node,
151
+ accumulator
152
+ });
153
+ if (name === "importScripts" || name.endsWith(".importScripts")) for (const argument of node.arguments) {
154
+ const specifier = stringValue(argument);
155
+ if (specifier === undefined) continue;
156
+ addEdge({
157
+ script,
158
+ specifier,
159
+ kind: "worker_import",
160
+ node,
161
+ accumulator
162
+ });
163
+ }
164
+ if (routeCallNames.some((candidate) => name === candidate || name.endsWith(`.${candidate}`))) {
165
+ if (first !== undefined) addFinding({
166
+ collection: accumulator.routes,
167
+ script,
168
+ rawValue: first,
169
+ mechanism: `call:${name}`,
170
+ node,
171
+ accumulator
172
+ });
173
+ addRouteFrameworkInference({
174
+ script,
175
+ name,
176
+ node,
177
+ accumulator
178
+ });
179
+ }
180
+ const endpoint = endpointArgument(name, node.arguments, node.callee, openReceiverFacts.get(node.start ?? -1));
181
+ if (endpoint?.kind === "candidate") addEndpointCandidate(script, node, name, endpoint.value, accumulator);
182
+ else if (endpoint !== undefined) addFinding({
183
+ collection: accumulator.endpoints,
184
+ script,
185
+ rawValue: endpoint.value,
186
+ mechanism: `call:${name}`,
187
+ node,
188
+ accumulator
189
+ });
190
+ if (name.endsWith("modelContext.registerTool") || name === "modelContext.registerTool") addWebMcpDeclaration(script, node, accumulator);
191
+ };
192
+ inspectRouteProperty = (script, node, accumulator) => {
193
+ const key = semanticStaticPropertyName(node.key, node.computed);
194
+ const route = stringValue(node.value);
195
+ if ((key === "path" || key === "route") && route !== undefined) addFinding({
196
+ collection: accumulator.routes,
197
+ script,
198
+ rawValue: route,
199
+ mechanism: `property:${key}`,
200
+ node,
201
+ accumulator
202
+ });
203
+ };
204
+ addEdge = (context) => {
205
+ const key = `edge\0${context.script.script_key}\0${context.kind}\0${context.specifier}`;
206
+ addUnique(context.accumulator, key, () => context.accumulator.edges.push({
207
+ from_script_key: context.script.script_key,
208
+ kind: context.kind,
209
+ specifier: context.specifier,
210
+ resolved_url: context.kind === "worker_import" || isUrlLikeModuleSpecifier(context.specifier) ? resolveSpecifier(context.specifier, context.script.url) : null,
211
+ location: location(context.script.script_key, context.node)
212
+ }));
213
+ };
214
+ addEndpointCandidate = (script, node, name, rawValue, accumulator) => {
215
+ const value = sanitizeEndpointCandidate(rawValue);
216
+ const detector = `call:${name}:unverified-network-receiver`;
217
+ const key = compositeKey([
218
+ "endpoint-candidate",
219
+ script.script_key,
220
+ value,
221
+ detector
222
+ ]);
223
+ addUnique(accumulator, key, () => accumulator.inferences.push({
224
+ kind: "endpoint_candidate",
225
+ value,
226
+ confidence: "low",
227
+ basis: [{
228
+ ...basis(script, detector),
229
+ ...locationFields(node)
230
+ }]
231
+ }));
232
+ };
233
+ addFinding = (context) => {
234
+ const value = sanitizeEndpointCandidate(context.rawValue);
235
+ const key = `finding\0${context.mechanism}\0${context.script.script_key}\0${value}`;
236
+ addUnique(context.accumulator, key, () => context.collection.push({
237
+ value,
238
+ mechanism: context.mechanism,
239
+ location: location(context.script.script_key, context.node)
240
+ }));
241
+ };
242
+ addWebMcpDeclaration = (script, node, accumulator) => {
243
+ const declaration = node.arguments[0];
244
+ if (!t.isObjectExpression(declaration)) return;
245
+ const name = objectString(declaration, "name");
246
+ const description = objectString(declaration, "description");
247
+ const schema = objectValue(declaration, "inputSchema") ?? objectValue(declaration, "input_schema");
248
+ const declaredProperties = t.isObjectExpression(schema) ? objectValue(schema, "properties") : undefined;
249
+ const propertyObject = t.isObjectExpression(declaredProperties) ? declaredProperties : schema;
250
+ const schemaPropertyNames = t.isObjectExpression(propertyObject) ? propertyObject.properties.flatMap((property) => t.isObjectProperty(property) ? [semanticStaticPropertyName(property.key, property.computed)].filter(Boolean) : []) : [];
251
+ const metadata = {
252
+ name: name ?? null,
253
+ description: description ?? null,
254
+ schema_property_names: [...new Set(schemaPropertyNames)].sort()
255
+ };
256
+ const key = compositeKey([
257
+ "webmcp",
258
+ script.script_key,
259
+ metadata
260
+ ]);
261
+ addUnique(accumulator, key, () => accumulator.webMcp.push({
262
+ ...metadata,
263
+ trust: "page-declared-untrusted",
264
+ location: location(script.script_key, node)
265
+ }));
266
+ };
267
+ detectVendorFingerprints = (script, accumulator) => {
268
+ const text = script.source.artifact.text;
269
+ for (const detector of vendorDetectors) {
270
+ if (!detector.patterns.some((pattern) => text.includes(pattern))) continue;
271
+ const key = `vendor\0${script.script_key}\0${detector.value}`;
272
+ addUnique(accumulator, key, () => accumulator.inferences.push({
273
+ kind: detector.kind,
274
+ value: detector.value,
275
+ confidence: detector.confidence,
276
+ basis: [basis(script, detector.detector)]
277
+ }));
278
+ }
279
+ };
280
+ addRouteFrameworkInference = (context) => {
281
+ const value = context.name.endsWith("useRoutes") || context.name.endsWith("createBrowserRouter") ? "React Router-compatible route API" : "Generic route registration API";
282
+ const key = `route-framework\0${context.script.script_key}\0${value}`;
283
+ addUnique(context.accumulator, key, () => context.accumulator.inferences.push({
284
+ kind: "route_framework",
285
+ value,
286
+ confidence: "medium",
287
+ basis: [{
288
+ ...basis(context.script, `call:${context.name}`),
289
+ ...locationFields(context.node)
290
+ }]
291
+ }));
292
+ };
293
+ addUnique = (accumulator, key, add) => {
294
+ if (accumulator.seen.has(key)) return;
295
+ accumulator.seen.add(key);
296
+ add();
297
+ };
298
+ basis = (script, detector) => ({
299
+ script_key: script.script_key,
300
+ artifact_sha256: script.source.artifact.sha256,
301
+ line: null,
302
+ column: null,
303
+ detector
304
+ });
305
+ emptyAccumulator = () => ({
306
+ edges: [],
307
+ routes: [],
308
+ endpoints: [],
309
+ webMcp: [],
310
+ inferences: [],
311
+ seen: new Set(),
312
+ visitedNodes: 0,
313
+ parsedScripts: 0,
314
+ failedScripts: [],
315
+ recoveredScripts: []
316
+ });
317
+ isIncludedScript = (script) => script.source.included;
318
+ routeCallNames = [
319
+ "route",
320
+ "addRoute",
321
+ "useRoutes",
322
+ "createBrowserRouter",
323
+ "createHashRouter"
324
+ ];
325
+ vendorDetectors = [
326
+ {
327
+ value: "webpack",
328
+ detector: "webpack-runtime",
329
+ patterns: ["__webpack_require__"],
330
+ confidence: "high",
331
+ kind: "bundle_runtime"
332
+ },
333
+ {
334
+ value: "Vite",
335
+ detector: "vite-runtime",
336
+ patterns: ["__vite__", "import.meta.hot"],
337
+ confidence: "medium",
338
+ kind: "bundle_runtime"
339
+ },
340
+ {
341
+ value: "React",
342
+ detector: "react-runtime",
343
+ patterns: ["__REACT_DEVTOOLS_GLOBAL_HOOK__", "React.createElement"],
344
+ confidence: "medium",
345
+ kind: "vendor_fingerprint"
346
+ },
347
+ {
348
+ value: "Vue",
349
+ detector: "vue-runtime",
350
+ patterns: ["__VUE__", "createApp("],
351
+ confidence: "medium",
352
+ kind: "vendor_fingerprint"
353
+ },
354
+ {
355
+ value: "Next.js",
356
+ detector: "next-runtime",
357
+ patterns: ["__NEXT_DATA__", "/_next/"],
358
+ confidence: "high",
359
+ kind: "vendor_fingerprint"
360
+ },
361
+ {
362
+ value: "Angular",
363
+ detector: "angular-runtime",
364
+ patterns: ["ɵɵdefineComponent"],
365
+ confidence: "high",
366
+ kind: "vendor_fingerprint"
367
+ },
368
+ {
369
+ value: "Svelte",
370
+ detector: "svelte-runtime",
371
+ patterns: ["svelte/internal"],
372
+ confidence: "medium",
373
+ kind: "vendor_fingerprint"
374
+ }
375
+ ];
376
+ })))();
377
+ }
378
+
379
+ //#endregion
380
+ //#region dist/domain/webBundleAnalyzerResult.js
381
+ var buildWebBundleAnalysis, buildCaptureObservation, sourceArtifact, chunkNode, buildUnknowns, captureBudgetOmission, captureBudgetReason, buildCompleteness, bundleLimitations;
382
+ function init_webBundleAnalyzerResult() {
383
+ return (init_webBundleAnalyzerResult = __esmMin((() => {
384
+ init_webBundleAnalysis();
385
+ buildWebBundleAnalysis = (inspection, sourceScripts, sourceMaps, accumulator) => {
386
+ const unavailable = inspection.scripts.items.filter((script) => !script.source.included).map(({ script_key }) => script_key);
387
+ const omittedScripts = captureBudgetOmission(inspection, "scripts");
388
+ const omittedSourceMaps = sourceMaps.status === "not_requested" ? undefined : captureBudgetOmission(inspection, "source_maps");
389
+ const sourceMapIncomplete = sourceMaps.status === "partial" || sourceMaps.status === "unavailable";
390
+ const partial = accumulator.failedScripts.length > 0 || accumulator.recoveredScripts.length > 0 || unavailable.length > 0 || sourceMapIncomplete || omittedScripts !== undefined || omittedSourceMaps !== undefined;
391
+ return webBundleAnalysisSchema.parse({
392
+ capture: buildCaptureObservation(inspection, sourceScripts),
393
+ observations: {
394
+ chunks: {
395
+ nodes: sourceScripts.map(chunkNode),
396
+ edges: accumulator.edges
397
+ },
398
+ routes: accumulator.routes,
399
+ endpoints: accumulator.endpoints,
400
+ webmcp_declarations: accumulator.webMcp,
401
+ source_maps: sourceMaps
402
+ },
403
+ inferences: accumulator.inferences,
404
+ unknowns: buildUnknowns({
405
+ unavailable,
406
+ failedScripts: accumulator.failedScripts,
407
+ recoveredScripts: accumulator.recoveredScripts,
408
+ sourceMaps,
409
+ omittedScripts,
410
+ omittedSourceMaps
411
+ }),
412
+ completeness: buildCompleteness({
413
+ partial,
414
+ parsedScripts: accumulator.parsedScripts,
415
+ parseFailures: accumulator.failedScripts.length,
416
+ visitedNodes: accumulator.visitedNodes
417
+ }),
418
+ limitations: bundleLimitations()
419
+ });
420
+ };
421
+ buildCaptureObservation = (inspection, sourceScripts) => ({
422
+ target_url: inspection.target.url,
423
+ scripts_observed: inspection.scripts.total,
424
+ scripts_analyzed: sourceScripts.length,
425
+ source_artifacts: sourceScripts.map(sourceArtifact)
426
+ });
427
+ sourceArtifact = (script) => {
428
+ if (!script.source.included) throw new TypeError("Filtered source changed");
429
+ const { text: _text, ...artifact } = script.source.artifact;
430
+ return {
431
+ ...artifact,
432
+ text_available: true
433
+ };
434
+ };
435
+ chunkNode = (script) => {
436
+ if (!script.source.included) throw new TypeError("Filtered source changed");
437
+ return {
438
+ script_key: script.script_key,
439
+ url: script.url,
440
+ artifact_sha256: script.source.artifact.sha256,
441
+ bytes: script.source.artifact.bytes
442
+ };
443
+ };
444
+ buildUnknowns = (input) => [
445
+ ...input.omittedScripts === undefined ? [] : [{
446
+ dimension: "script_inventory",
447
+ reason: captureBudgetReason("script records", input.omittedScripts),
448
+ affected_script_keys: []
449
+ }],
450
+ ...input.unavailable.length === 0 ? [] : [{
451
+ dimension: "script_source",
452
+ reason: "Source artifact was not captured",
453
+ affected_script_keys: input.unavailable
454
+ }],
455
+ ...input.failedScripts.length === 0 ? [] : [{
456
+ dimension: "javascript_ast",
457
+ reason: "One or more source artifacts could not be parsed",
458
+ affected_script_keys: [...input.failedScripts]
459
+ }],
460
+ ...input.recoveredScripts.length === 0 ? [] : [{
461
+ dimension: "javascript_ast",
462
+ reason: "The parser recovered from errors in one or more source artifacts; findings may be incomplete",
463
+ affected_script_keys: [...input.recoveredScripts]
464
+ }],
465
+ ...input.omittedSourceMaps === undefined ? [] : [{
466
+ dimension: "source_maps",
467
+ reason: captureBudgetReason("source-map declarations", input.omittedSourceMaps),
468
+ affected_script_keys: []
469
+ }],
470
+ ...input.sourceMaps.status === "not_requested" || input.sourceMaps.status === "included" ? [] : [{
471
+ dimension: "source_maps",
472
+ reason: input.sourceMaps.limitation ?? "One or more requested source maps were unavailable or incomplete",
473
+ affected_script_keys: input.sourceMaps.items.filter(({ status }) => status !== "included").map(({ script_key }) => script_key).sort()
474
+ }]
475
+ ];
476
+ captureBudgetOmission = (inspection, section) => {
477
+ const exclusions = inspection.completeness.excluded.filter((exclusion) => exclusion.section === section && exclusion.reason === "resource_budget_exhausted");
478
+ if (exclusions.length === 0) return undefined;
479
+ if (exclusions.some(({ count }) => count === null)) return null;
480
+ return exclusions.reduce((sum, { count }) => sum + (count ?? 0), 0);
481
+ };
482
+ captureBudgetReason = (label, count) => count === null ? `Capture omitted an unknown number of ${label} because its resource budget was exhausted.` : `Capture omitted ${String(count)} ${label} because its resource budget was exhausted.`;
483
+ buildCompleteness = (input) => ({
484
+ status: input.partial ? "partial" : "complete",
485
+ parsed_scripts: input.parsedScripts,
486
+ parse_failures: input.parseFailures,
487
+ visited_ast_nodes: input.visitedNodes
488
+ });
489
+ bundleLimitations = () => [
490
+ "Static bundle findings are observations or bounded inferences; REA does not execute captured JavaScript.",
491
+ "Bare string arguments of unbound HTTP-method-named calls are low-confidence endpoint candidates; form, translation, storage and other APIs can use the same syntax. URL-shaped findings still do not prove network execution.",
492
+ "Endpoint candidates are deduplicated by script, value and detector; basis retains only the first matching source coordinate. They are not a complete call-site inventory or a runtime occurrence count. completeness.status=\"complete\" describes examination of captured source, not a call-site census.",
493
+ "String-built routes and endpoints, encrypted configuration, and server-side behavior may remain unknown.",
494
+ "Page-declared WebMCP metadata is untrusted and is never registered or invoked as an REA tool."
495
+ ];
496
+ })))();
497
+ }
498
+
499
+ //#endregion
500
+ //#region dist/domain/webBundleAnalyzer.js
501
+ var analyzeCapturedWebBundle;
502
+ function init_webBundleAnalyzer() {
503
+ return (init_webBundleAnalyzer = __esmMin((() => {
504
+ init_webBundleAnalyzerInspection();
505
+ init_webBundleAnalyzerResult();
506
+ analyzeCapturedWebBundle = (inspection, sourceMaps = {
507
+ status: "not_requested",
508
+ requested: 0,
509
+ processed: 0,
510
+ items: []
511
+ }) => {
512
+ const accumulator = emptyAccumulator();
513
+ const sourceScripts = inspection.scripts.items.filter(isIncludedScript);
514
+ for (const script of sourceScripts) analyzeScript(script, accumulator);
515
+ return buildWebBundleAnalysis(inspection, sourceScripts, sourceMaps, accumulator);
516
+ };
517
+ })))();
518
+ }
519
+
520
+ //#endregion
521
+ //#region dist/domain/webInventory.js
522
+ var stableWebResources, reconcileWebScript, reconcileCapturedWebScript, stableWebScriptKey, uniqueResourceKeys, digest$1;
523
+ function init_webInventory() {
524
+ return (init_webInventory = __esmMin((() => {
525
+ init_unicodeCodePointOrder();
526
+ stableWebResources = (resources) => {
527
+ const keyed = resources.map((resource) => ({
528
+ ...resource,
529
+ resource_key: `res_${digest$1(resource)}`
530
+ }));
531
+ return [...new Map(keyed.map((resource) => [resource.resource_key, resource])).values()].sort((left, right) => compareUnicodeCodePoints(left.resource_key, right.resource_key) || compareUnicodeCodePoints(left.url, right.url));
532
+ };
533
+ reconcileWebScript = (script, resources) => {
534
+ const candidates = resources.filter((resource) => resource.url === script.url);
535
+ if (candidates.length === 1) return {
536
+ status: "exact",
537
+ resource_key: candidates[0]?.resource_key ?? ""
538
+ };
539
+ if (candidates.length > 1) return {
540
+ status: "ambiguous",
541
+ candidate_resource_keys: uniqueResourceKeys(candidates)
542
+ };
543
+ return {
544
+ status: "unmatched",
545
+ reason: "no_exact_sanitized_url"
546
+ };
547
+ };
548
+ reconcileCapturedWebScript = (script, rawResources, resources) => {
549
+ const exact = rawResources.filter((resource) => resource.rawUrl === script.rawUrl);
550
+ if (exact.length === 1) {
551
+ const resource = exact[0];
552
+ if (resource !== undefined) {
553
+ const { rawUrl: _rawUrl, ...publicResource } = resource;
554
+ const stable = stableWebResources([publicResource])[0];
555
+ if (stable !== undefined) return {
556
+ status: "exact",
557
+ resource_key: stable.resource_key
558
+ };
559
+ }
560
+ }
561
+ const candidates = resources.filter((resource) => resource.url === script.url);
562
+ if (candidates.length > 0) return {
563
+ status: "ambiguous",
564
+ candidate_resource_keys: uniqueResourceKeys(candidates)
565
+ };
566
+ return {
567
+ status: "unmatched",
568
+ reason: "no_exact_sanitized_url"
569
+ };
570
+ };
571
+ stableWebScriptKey = (script) => `scr_${digest$1({
572
+ url: script.url,
573
+ cdp_hash: script.cdp_hash,
574
+ length: script.length,
575
+ is_module: script.is_module,
576
+ language: script.language,
577
+ source_map_url: script.source_map_url
578
+ })}`;
579
+ uniqueResourceKeys = (resources) => [...new Set(resources.map(({ resource_key }) => resource_key))].sort();
580
+ digest$1 = (value) => {
581
+ const encoded = canonicalize(value);
582
+ if (encoded === undefined) throw new TypeError("Web inventory value is not canonical JSON");
583
+ return createHash("sha256").update(encoded).digest("hex");
584
+ };
585
+ })))();
586
+ }
587
+
588
+ //#endregion
589
+ //#region dist/browser/CdpCaptureEventBodyShapes.js
590
+ var ingestResponseBodyShape, requestBodyShape, updateResponseBodyShape, invalidResponseBodyShape;
591
+ function init_CdpCaptureEventBodyShapes() {
592
+ return (init_CdpCaptureEventBodyShapes = __esmMin((() => {
593
+ init_jsonShape();
594
+ init_CdpCaptureValues();
595
+ init_CdpCaptureEventHelpers();
596
+ ingestResponseBodyShape = (state, requestId, value) => {
597
+ const result = recordValue(value);
598
+ const body = cdpStringValue(result?.body);
599
+ const base64Encoded = result?.base64Encoded;
600
+ if (body === undefined || typeof base64Encoded !== "boolean") {
601
+ invalidResponseBodyShape(state, requestId);
602
+ return;
603
+ }
604
+ const decoded = base64Encoded ? decodeBase64$1(body)?.toString("utf8") : body;
605
+ if (decoded === undefined) {
606
+ invalidResponseBodyShape(state, requestId);
607
+ return;
608
+ }
609
+ const shape = inferJsonShape(decoded);
610
+ if (shape === null) state.completeness.unavailable("json_body_shapes");
611
+ updateResponseBodyShape(state, requestId, shape);
612
+ };
613
+ requestBodyShape = (state, request) => {
614
+ if (!state.input.include_json_body_shapes) return {
615
+ status: "not_approved",
616
+ request: null,
617
+ response: null
618
+ };
619
+ const body = cdpStringValue(request.postData);
620
+ if (!isJsonContentType(recordValue(request.headers)) || body === undefined) return {
621
+ status: "unavailable",
622
+ request: null,
623
+ response: null
624
+ };
625
+ const shape = inferJsonShape(body);
626
+ if (shape === null) state.completeness.unavailable("json_body_shapes");
627
+ return {
628
+ status: shape === null ? "unavailable" : "included",
629
+ request: shape,
630
+ response: null
631
+ };
632
+ };
633
+ updateResponseBodyShape = (state, requestId, response) => {
634
+ const current = state.network.get(requestId);
635
+ if (current === undefined) return;
636
+ const request = current.body_shapes.request;
637
+ const status = response !== null ? "included" : request !== null ? "partial" : "unavailable";
638
+ state.network.set(requestId, {
639
+ ...current,
640
+ body_shapes: {
641
+ status,
642
+ request,
643
+ response
644
+ }
645
+ });
646
+ };
647
+ invalidResponseBodyShape = (state, requestId) => {
648
+ updateResponseBodyShape(state, requestId, null);
649
+ state.completeness.exclude("json_body_shapes", "invalid_protocol_value");
650
+ };
651
+ })))();
652
+ }
653
+
654
+ //#endregion
655
+ //#region dist/browser/CdpSafeMetadata.js
656
+ var safeResponseMetadata, normalizedHeaders, parseCsp, cspSource, cspHostSourceOrigin, schemeOf, parseLinks, splitLinkHeader, linkParameters, safeDestination, permissionFeatures, wellKnownHint, agentHint, isAgentRel, referrerPolicies, referrerPolicy, policyToken, contentLength, boundedHeader, unquote, agentHeaderNames, wellKnownAgentPaths;
657
+ function init_CdpSafeMetadata() {
658
+ return (init_CdpSafeMetadata = __esmMin((() => {
659
+ init_browserObservation$1();
660
+ init_CdpCaptureValues();
661
+ safeResponseMetadata = (requestId, url, response, allowedOrigins) => {
662
+ const headers = normalizedHeaders(response.headers);
663
+ const links = parseLinks(headers.get("link"), url, allowedOrigins);
664
+ const csp = parseCsp(headers.get("content-security-policy"), url, allowedOrigins);
665
+ const agentHints = [
666
+ ...links.flatMap((link) => link.rel.some(isAgentRel) ? [agentHint("link_rel", link.rel.join(" "), link.href)] : []),
667
+ ...agentHeaderNames.flatMap((name) => headers.has(name) ? [agentHint("response_header", name, null)] : []),
668
+ ...wellKnownHint(url)
669
+ ];
670
+ return {
671
+ response: {
672
+ request_id: requestId,
673
+ url,
674
+ mime_type: boundedHeader(cdpStringValue(response.mimeType)),
675
+ content_length: contentLength(headers.get("content-length")),
676
+ content_encoding: boundedHeader(headers.get("content-encoding")),
677
+ csp,
678
+ links,
679
+ policies: {
680
+ coop: policyToken(headers.get("cross-origin-opener-policy")),
681
+ coep: policyToken(headers.get("cross-origin-embedder-policy")),
682
+ corp: policyToken(headers.get("cross-origin-resource-policy")),
683
+ referrer_policy: referrerPolicy(headers.get("referrer-policy")),
684
+ x_content_type_options: policyToken(headers.get("x-content-type-options")),
685
+ permissions_policy_features: permissionFeatures(headers.get("permissions-policy"))
686
+ }
687
+ },
688
+ agentHints
689
+ };
690
+ };
691
+ normalizedHeaders = (value) => {
692
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return new Map();
693
+ const headers = new Map();
694
+ for (const [name, raw] of Object.entries(value)) {
695
+ const normalized = name.toLowerCase();
696
+ const header = typeof raw === "string" ? raw : typeof raw === "number" && Number.isFinite(raw) ? String(raw) : undefined;
697
+ if (header !== undefined) headers.set(normalized, header);
698
+ }
699
+ return headers;
700
+ };
701
+ parseCsp = (value, baseUrl, allowedOrigins) => {
702
+ const directives = [];
703
+ let nonceCount = 0;
704
+ let hashCount = 0;
705
+ for (const rawDirective of (value ?? "").split(";")) {
706
+ const [rawName, ...tokens] = rawDirective.trim().split(/\s+/u);
707
+ const name = (rawName ?? "").toLowerCase();
708
+ if (!/^[a-z][a-z0-9\x2d]*$/u.test(name)) continue;
709
+ const sources = [];
710
+ for (const token of tokens) {
711
+ const lower = token.toLowerCase();
712
+ if (lower.startsWith("'nonce-")) {
713
+ nonceCount += 1;
714
+ continue;
715
+ }
716
+ if (lower.startsWith("'sha256-") || lower.startsWith("'sha384-") || lower.startsWith("'sha512-")) {
717
+ hashCount += 1;
718
+ continue;
719
+ }
720
+ sources.push(cspSource(token, baseUrl, allowedOrigins));
721
+ }
722
+ directives.push({
723
+ name,
724
+ sources
725
+ });
726
+ }
727
+ return {
728
+ directives,
729
+ nonce_count: nonceCount,
730
+ hash_count: hashCount
731
+ };
732
+ };
733
+ cspSource = (token, baseUrl, allowedOrigins) => {
734
+ const lower = token.toLowerCase();
735
+ if (/^'[a-z0-9\x2d]+'$/u.test(lower)) return {
736
+ kind: "keyword",
737
+ value: lower
738
+ };
739
+ if (/^[a-z][a-z0-9+.\x2d]*:$/u.test(lower)) return {
740
+ kind: "scheme",
741
+ value: lower
742
+ };
743
+ const hostOrigin = cspHostSourceOrigin(token, baseUrl);
744
+ if (hostOrigin === undefined) return {
745
+ kind: "other",
746
+ value: null
747
+ };
748
+ return hostOrigin !== null && allowedOrigins.has(hostOrigin) ? {
749
+ kind: "approved_origin",
750
+ value: hostOrigin
751
+ } : {
752
+ kind: "external_origin",
753
+ value: null
754
+ };
755
+ };
756
+ cspHostSourceOrigin = (token, baseUrl) => {
757
+ const match = /^(?:([a-z][a-z0-9+.\x2d]*):\/\/)?([^\x2f?#]+)(?:\/[^?#]*)?$/iu.exec(token);
758
+ const authority = match?.[2];
759
+ if (authority === undefined || authority.length === 0) return undefined;
760
+ const scheme = (match?.[1] ?? schemeOf(baseUrl))?.toLowerCase();
761
+ if (scheme === undefined || !/^[a-z][a-z0-9+.\x2d]*$/u.test(scheme)) return undefined;
762
+ if (!/^(?:\*|(?:\*\.)?[a-z0-9\x2d]+(?:\.[a-z0-9\x2d]+)*\.?)(?::(?:\*|\d+))?$/iu.test(authority)) return undefined;
763
+ if (authority.includes("*")) return null;
764
+ try {
765
+ const parsed = new URL(`${scheme}://${authority}`);
766
+ return parsed.username === "" && parsed.password === "" && parsed.pathname === "/" && parsed.origin !== "null" ? parsed.origin : undefined;
767
+ } catch (cause) {
768
+ void cause;
769
+ return undefined;
770
+ }
771
+ };
772
+ schemeOf = (baseUrl) => {
773
+ try {
774
+ return new URL(baseUrl).protocol.replace(/:$/u, "");
775
+ } catch (cause) {
776
+ void cause;
777
+ return undefined;
778
+ }
779
+ };
780
+ parseLinks = (value, baseUrl, allowedOrigins) => {
781
+ const links = [];
782
+ for (const entry of splitLinkHeader(value ?? "")) {
783
+ const match = /^\s*<([^>]*)>(.*)$/u.exec(entry);
784
+ if (match === null) continue;
785
+ const parameters = linkParameters(match[2] ?? "");
786
+ const destination = safeDestination(match[1] ?? "", baseUrl, allowedOrigins);
787
+ links.push({
788
+ href: destination.url,
789
+ destination_scope: destination.scope,
790
+ rel: (parameters.get("rel") ?? "").toLowerCase().split(/\s+/u).filter(Boolean),
791
+ as: boundedHeader(parameters.get("as")),
792
+ type: boundedHeader(parameters.get("type")),
793
+ crossorigin: boundedHeader(parameters.get("crossorigin"))
794
+ });
795
+ }
796
+ return links;
797
+ };
798
+ splitLinkHeader = (value, delimiter = ",") => {
799
+ const entries = [];
800
+ let start = 0;
801
+ let quoted = false;
802
+ let escaped = false;
803
+ let target = false;
804
+ for (let index = 0; index < value.length; index += 1) {
805
+ const character = value[index];
806
+ if (quoted) {
807
+ if (escaped) escaped = false;
808
+ else if (character === "\\") escaped = true;
809
+ else if (character === "\"") quoted = false;
810
+ continue;
811
+ }
812
+ if (character === "\"" && !target) quoted = true;
813
+ else if (delimiter === "," && character === "<") target = true;
814
+ else if (delimiter === "," && character === ">") target = false;
815
+ else if (character === delimiter && !target) {
816
+ entries.push(value.slice(start, index));
817
+ start = index + 1;
818
+ }
819
+ }
820
+ entries.push(value.slice(start));
821
+ return entries;
822
+ };
823
+ linkParameters = (value) => {
824
+ const parameters = new Map();
825
+ for (const raw of splitLinkHeader(value, ";").slice(1)) {
826
+ const separator = raw.indexOf("=");
827
+ const name = (separator < 0 ? raw : raw.slice(0, separator)).trim().toLowerCase();
828
+ if (!/^[a-z][a-z0-9\x2d]*$/u.test(name)) continue;
829
+ const parameter = separator < 0 ? "" : raw.slice(separator + 1).trim();
830
+ parameters.set(name, unquote(parameter));
831
+ }
832
+ return parameters;
833
+ };
834
+ safeDestination = (value, baseUrl, allowedOrigins) => {
835
+ try {
836
+ const parsed = new URL(value, baseUrl);
837
+ const sanitized = sanitizeBrowserUrl(parsed.href).url;
838
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return {
839
+ url: sanitized,
840
+ scope: "unsupported"
841
+ };
842
+ if (!allowedOrigins.has(parsed.origin)) return {
843
+ url: sanitized,
844
+ scope: "outside_policy"
845
+ };
846
+ return {
847
+ url: sanitized,
848
+ scope: "approved"
849
+ };
850
+ } catch (cause) {
851
+ void cause;
852
+ return {
853
+ url: value,
854
+ scope: "unsupported"
855
+ };
856
+ }
857
+ };
858
+ permissionFeatures = (value) => [...new Set((value ?? "").split(",").map((entry) => entry.split("=", 1)[0]?.trim().toLowerCase() ?? "").filter((feature) => /^[a-z][a-z0-9\x2d]*$/u.test(feature)))].sort();
859
+ wellKnownHint = (url) => {
860
+ try {
861
+ const path = new URL(url).pathname.toLowerCase();
862
+ return wellKnownAgentPaths.has(path) ? [agentHint("well_known_resource", path, sanitizeBrowserUrl(url).url)] : [];
863
+ } catch (cause) {
864
+ void cause;
865
+ return [];
866
+ }
867
+ };
868
+ agentHint = (mechanism, declaration, url) => ({
869
+ mechanism,
870
+ declaration,
871
+ url,
872
+ trust: "page-declared-untrusted"
873
+ });
874
+ isAgentRel = (value) => [
875
+ "mcp",
876
+ "model-context",
877
+ "ai-plugin",
878
+ "service-desc"
879
+ ].includes(value);
880
+ referrerPolicies = new Set([
881
+ "no-referrer",
882
+ "no-referrer-when-downgrade",
883
+ "same-origin",
884
+ "origin",
885
+ "strict-origin",
886
+ "origin-when-cross-origin",
887
+ "strict-origin-when-cross-origin",
888
+ "unsafe-url"
889
+ ]);
890
+ referrerPolicy = (value) => {
891
+ let policy = null;
892
+ for (const raw of (value ?? "").split(",")) {
893
+ const token = raw.trim().toLowerCase();
894
+ if (token === "") continue;
895
+ if (!/^[a-z\x2d]+$/u.test(token)) return null;
896
+ if (referrerPolicies.has(token)) policy = token;
897
+ }
898
+ return policy;
899
+ };
900
+ policyToken = (value) => {
901
+ const token = (value ?? "").trim().toLowerCase();
902
+ return /^[a-z][a-z0-9_.\x2d]*$/u.test(token) ? token : null;
903
+ };
904
+ contentLength = (value) => {
905
+ const token = (value ?? "").trim();
906
+ if (!/^[0-9]+$/u.test(token)) return null;
907
+ const length = Number(token);
908
+ return Number.isSafeInteger(length) ? length : null;
909
+ };
910
+ boundedHeader = (value) => value === undefined ? null : value.trim().toLowerCase();
911
+ unquote = (value) => value.startsWith("\"") && value.endsWith("\"") ? value.slice(1, -1) : value;
912
+ agentHeaderNames = [
913
+ "x-model-context",
914
+ "x-webmcp",
915
+ "mcp-server"
916
+ ];
917
+ wellKnownAgentPaths = new Set([
918
+ "/.well-known/ai-plugin.json",
919
+ "/.well-known/mcp",
920
+ "/.well-known/model-context"
921
+ ]);
922
+ })))();
923
+ }
924
+
925
+ //#endregion
926
+ //#region dist/browser/CdpCaptureEventTypes.js
927
+ var CDP_CAPTURE_SCRIPT_METADATA_LIMITS;
928
+ function init_CdpCaptureEventTypes() {
929
+ return (init_CdpCaptureEventTypes = __esmMin((() => {
930
+ CDP_CAPTURE_SCRIPT_METADATA_LIMITS = {
931
+ retainedBytes: 8 * 1024 * 1024,
932
+ scripts: 5e4
933
+ };
934
+ })))();
935
+ }
936
+
937
+ //#endregion
938
+ //#region dist/browser/CdpCaptureEventHandlers.js
939
+ var handleExecutionContextCreated, handleExecutionContextDestroyed, handleScriptParsed, scriptMetadataStringBytes, stringByteLength, sourceMapForScript, handleRequestWillBeSent, preserveMalformedRedirectEvidence, redirectResponseUrlReason, handleResponseReceived, handleLoadingFinished, handleConsoleAPICalled, captureConsoleText, handleWebSocketFrame, captureWebSocketShape, handleWebSocketCreated, handleFrameNavigated;
940
+ function init_CdpCaptureEventHandlers() {
941
+ return (init_CdpCaptureEventHandlers = __esmMin((() => {
942
+ init_browserObservation$1();
943
+ init_jsonShape();
944
+ init_CdpSafeMetadata();
945
+ init_CdpCaptureValues();
946
+ init_CdpCaptureEventBodyShapes();
947
+ init_CdpCaptureEventHelpers();
948
+ init_CdpCaptureEventTypes();
949
+ handleExecutionContextCreated = (state, params) => {
950
+ const context = recordValue(params.context);
951
+ const identifier = numberValue(context?.id);
952
+ const frameId = cdpStringValue(recordValue(context?.auxData)?.frameId);
953
+ if (identifier === undefined || !Number.isSafeInteger(identifier) || frameId === undefined) return;
954
+ const key = String(identifier);
955
+ state.executionContextFrames.set(key, frameId);
956
+ };
957
+ handleExecutionContextDestroyed = (state, params) => {
958
+ const key = executionContextKey(params.executionContextId);
959
+ if (key !== null) state.executionContextFrames.delete(key);
960
+ };
961
+ handleScriptParsed = (state, params) => {
962
+ const scriptId = cdpStringValue(params.scriptId);
963
+ const rawUrl = cdpStringValue(params.url) ?? "";
964
+ const sanitized = allowedSanitizedUrl(rawUrl, state.allowedOrigins);
965
+ if (scriptId === undefined) {
966
+ state.completeness.exclude("scripts", "invalid_protocol_value");
967
+ return;
968
+ }
969
+ const replacedBytes = state.scriptMetadataBytesById.get(scriptId) ?? 0;
970
+ state.scriptMetadataBudgetOmissionsById.delete(scriptId);
971
+ if (replacedBytes > 0) {
972
+ state.scripts.delete(scriptId);
973
+ state.scriptMetadataBytesById.delete(scriptId);
974
+ state.retainedScriptMetadataBytes -= replacedBytes;
975
+ }
976
+ if (sanitized === undefined) {
977
+ state.completeness.exclude("scripts", exclusionReasonForUrl(rawUrl));
978
+ return;
979
+ }
980
+ const executionContext = executionContextKey(params.executionContextId);
981
+ const baseScript = {
982
+ scriptId,
983
+ rawUrl,
984
+ url: sanitized.url,
985
+ origin: sanitized.origin,
986
+ ...scriptMetadataValues(params),
987
+ language: cdpStringValue(params.scriptLanguage) ?? null,
988
+ executionContextKey: executionContext,
989
+ frameId: executionContext === null ? null : state.executionContextFrames.get(executionContext) ?? null
990
+ };
991
+ const baseBytes = scriptMetadataStringBytes(baseScript);
992
+ const sourceMapDeclared = typeof params.sourceMapURL === "string" && params.sourceMapURL.length > 0;
993
+ if (state.scripts.size >= CDP_CAPTURE_SCRIPT_METADATA_LIMITS.scripts || baseBytes > CDP_CAPTURE_SCRIPT_METADATA_LIMITS.retainedBytes - state.retainedScriptMetadataBytes) {
994
+ state.rejectedScriptMetadataBudgetCount += 1;
995
+ if (sourceMapDeclared) state.rejectedSourceMapMetadataBudgetCount += 1;
996
+ return;
997
+ }
998
+ const sourceMap = sourceMapForScript(params.sourceMapURL, rawUrl, state, CDP_CAPTURE_SCRIPT_METADATA_LIMITS.retainedBytes - state.retainedScriptMetadataBytes - baseBytes);
999
+ const { budgetExhausted, ...sourceMapFields } = sourceMap;
1000
+ const script = {
1001
+ ...baseScript,
1002
+ ...sourceMapFields
1003
+ };
1004
+ if (budgetExhausted) state.scriptMetadataBudgetOmissionsById.set(scriptId, true);
1005
+ const retainedBytes = baseBytes + stringByteLength(sourceMap.sourceMapUrl) + stringByteLength(sourceMap.sourceMapRawUrl);
1006
+ state.retainedScriptMetadataBytes += retainedBytes;
1007
+ state.scriptMetadataBytesById.set(scriptId, retainedBytes);
1008
+ state.scripts.set(scriptId, script);
1009
+ };
1010
+ scriptMetadataStringBytes = (script) => stringByteLength(script.scriptId) + stringByteLength(script.rawUrl) + stringByteLength(script.url) + stringByteLength(script.origin) + stringByteLength(script.hash) + stringByteLength(script.language) + stringByteLength(script.executionContextKey) + stringByteLength(script.frameId);
1011
+ stringByteLength = (value) => value === null ? 0 : Buffer.byteLength(value, "utf8");
1012
+ sourceMapForScript = (value, scriptUrl, state, remainingBytes) => {
1013
+ const declaredUrl = cdpStringValue(value);
1014
+ if (declaredUrl === undefined || declaredUrl === "") return {
1015
+ sourceMapUrl: null,
1016
+ sourceMapRawUrl: null,
1017
+ budgetExhausted: false
1018
+ };
1019
+ let rawUrl;
1020
+ try {
1021
+ rawUrl = new URL(declaredUrl, scriptUrl).href;
1022
+ } catch (cause) {
1023
+ void cause;
1024
+ state.completeness.exclude("source_maps", "unsupported_url");
1025
+ return {
1026
+ sourceMapUrl: null,
1027
+ sourceMapRawUrl: null,
1028
+ budgetExhausted: false
1029
+ };
1030
+ }
1031
+ const sanitized = allowedSanitizedUrl(rawUrl, state.allowedOrigins);
1032
+ if (sanitized !== undefined) {
1033
+ if (stringByteLength(rawUrl) + stringByteLength(sanitized.url) > remainingBytes) {
1034
+ return {
1035
+ sourceMapUrl: null,
1036
+ sourceMapRawUrl: null,
1037
+ budgetExhausted: true
1038
+ };
1039
+ }
1040
+ return {
1041
+ sourceMapUrl: sanitized.url,
1042
+ sourceMapRawUrl: rawUrl,
1043
+ budgetExhausted: false
1044
+ };
1045
+ }
1046
+ state.completeness.exclude("source_maps", exclusionReasonForUrl(rawUrl));
1047
+ return {
1048
+ sourceMapUrl: null,
1049
+ sourceMapRawUrl: null,
1050
+ budgetExhausted: false
1051
+ };
1052
+ };
1053
+ handleRequestWillBeSent = (state, params) => {
1054
+ const requestId = cdpStringValue(params.requestId);
1055
+ const request = recordValue(params.request);
1056
+ if (requestId === undefined) {
1057
+ state.completeness.exclude("network_requests", "invalid_protocol_value");
1058
+ return;
1059
+ }
1060
+ if (state.malformedRedirectRequestIds.has(requestId)) return;
1061
+ const previous = state.network.get(requestId);
1062
+ if (!Object.hasOwn(params, "redirectResponse") && previous !== undefined && preserveMalformedRedirectEvidence(state, requestId, previous)) return;
1063
+ const method = cdpStringValue(request?.method);
1064
+ const initiator = recordValue(params.initiator);
1065
+ const initiatorType = cdpStringValue(initiator?.type);
1066
+ if (request === undefined || method === undefined || method.length === 0 || initiatorType === undefined || initiatorType.length === 0) {
1067
+ preserveMalformedRedirectEvidence(state, requestId, previous);
1068
+ return;
1069
+ }
1070
+ const sanitized = allowedSanitizedUrl(request.url, state.allowedOrigins);
1071
+ if (sanitized === undefined) {
1072
+ state.completeness.exclude("network_requests", exclusionReasonForUrl(cdpStringValue(request.url)));
1073
+ state.network.delete(requestId);
1074
+ state.networkRequestTimestamps.delete(requestId);
1075
+ return;
1076
+ }
1077
+ const redirectResponse = recordValue(params.redirectResponse);
1078
+ if (Object.hasOwn(params, "redirectResponse") && redirectResponse === undefined && preserveMalformedRedirectEvidence(state, requestId, previous)) return;
1079
+ const redirects = [...previous?.redirects ?? []];
1080
+ if (redirectResponse !== undefined) {
1081
+ const rawResponseUrl = cdpStringValue(redirectResponse.url);
1082
+ const responseUrl = rawResponseUrl === undefined || rawResponseUrl === "" ? undefined : allowedSanitizedUrl(rawResponseUrl, state.allowedOrigins);
1083
+ const responseUrlReason = redirectResponseUrlReason(rawResponseUrl);
1084
+ if (previous === undefined) {
1085
+ if (responseUrl === undefined) state.completeness.exclude("network_requests", responseUrlReason);
1086
+ else state.completeness.attachLimited("network_requests");
1087
+ } else if (responseUrl === undefined) {
1088
+ state.completeness.exclude("network_requests", responseUrlReason);
1089
+ state.network.delete(requestId);
1090
+ state.networkRequestTimestamps.delete(requestId);
1091
+ return;
1092
+ } else {
1093
+ const encodedDataLength = numberValue(redirectResponse.encodedDataLength);
1094
+ if (encodedDataLength === undefined || encodedDataLength < 0) state.completeness.exclude("network_requests", "invalid_protocol_value");
1095
+ redirects.push({
1096
+ url: previous.url,
1097
+ response_url: responseUrl.url,
1098
+ method: previous.method,
1099
+ resource_type: previous.resource_type,
1100
+ status: numberValue(redirectResponse.status) ?? null,
1101
+ mime_type: cdpStringValue(redirectResponse.mimeType) ?? null,
1102
+ encoded_data_length: encodedDataLength === undefined || encodedDataLength < 0 ? null : encodedDataLength,
1103
+ request_timestamp: state.networkRequestTimestamps.get(requestId) ?? null,
1104
+ redirect_event_timestamp: numberValue(params.timestamp) ?? null
1105
+ });
1106
+ }
1107
+ }
1108
+ const initiatorFrame = initiatorLocation(initiator);
1109
+ const rawInitiatorUrl = cdpStringValue(initiatorFrame?.url);
1110
+ const initiatorUrl = allowedSanitizedUrl(rawInitiatorUrl, state.allowedOrigins);
1111
+ if (rawInitiatorUrl !== undefined && initiatorUrl === undefined) state.completeness.exclude("network_initiators", exclusionReasonForUrl(rawInitiatorUrl));
1112
+ state.network.set(requestId, {
1113
+ request_id: requestId,
1114
+ url: sanitized.url,
1115
+ origin: sanitized.origin ?? "",
1116
+ method,
1117
+ resource_type: cdpStringValue(params.type) ?? null,
1118
+ status: null,
1119
+ mime_type: null,
1120
+ encoded_data_length: null,
1121
+ redirects,
1122
+ initiator: {
1123
+ type: initiatorType,
1124
+ url: initiatorUrl?.url ?? null,
1125
+ line: integerOrNull$1(initiatorFrame?.lineNumber),
1126
+ column: integerOrNull$1(initiatorFrame?.columnNumber)
1127
+ },
1128
+ body_shapes: requestBodyShape(state, request)
1129
+ });
1130
+ const timestamp = numberValue(params.timestamp);
1131
+ if (timestamp === undefined) state.networkRequestTimestamps.delete(requestId);
1132
+ else state.networkRequestTimestamps.set(requestId, timestamp);
1133
+ };
1134
+ preserveMalformedRedirectEvidence = (state, requestId, previous) => {
1135
+ state.completeness.exclude("network_requests", "invalid_protocol_value");
1136
+ if (previous === undefined) return false;
1137
+ state.malformedRedirectRequestIds.add(requestId);
1138
+ if (state.input.include_json_body_shapes && isJsonMediaType(previous.mime_type) && previous.body_shapes.response === null) {
1139
+ updateResponseBodyShape(state, requestId, null);
1140
+ state.completeness.exclude("json_body_shapes", "invalid_protocol_value");
1141
+ }
1142
+ return true;
1143
+ };
1144
+ redirectResponseUrlReason = (value) => {
1145
+ if (value === undefined || value === "") return "invalid_protocol_value";
1146
+ try {
1147
+ new URL(value);
1148
+ } catch {
1149
+ return "invalid_protocol_value";
1150
+ }
1151
+ return exclusionReasonForUrl(value);
1152
+ };
1153
+ handleResponseReceived = (state, params) => {
1154
+ const requestId = cdpStringValue(params.requestId);
1155
+ if (requestId === undefined) {
1156
+ state.completeness.exclude("network_requests", "invalid_protocol_value");
1157
+ return;
1158
+ }
1159
+ if (state.malformedRedirectRequestIds.has(requestId)) return;
1160
+ const current = state.network.get(requestId);
1161
+ const response = recordValue(params.response);
1162
+ if (current === undefined) return;
1163
+ const sanitized = allowedSanitizedUrl(response?.url, state.allowedOrigins);
1164
+ if (response === undefined || sanitized === undefined) {
1165
+ state.completeness.exclude("network_requests", response === undefined ? "invalid_protocol_value" : exclusionReasonForUrl(cdpStringValue(response.url)));
1166
+ state.network.delete(requestId);
1167
+ state.networkRequestTimestamps.delete(requestId);
1168
+ return;
1169
+ }
1170
+ state.network.set(requestId, {
1171
+ ...current,
1172
+ status: numberValue(response.status) ?? null,
1173
+ mime_type: cdpStringValue(response.mimeType) ?? null
1174
+ });
1175
+ const metadata = safeResponseMetadata(requestId, sanitized.url, response, state.allowedOrigins);
1176
+ state.responseMetadata.push(metadata.response);
1177
+ state.agentHints.push(...metadata.agentHints);
1178
+ };
1179
+ handleLoadingFinished = (state, params) => {
1180
+ const requestId = cdpStringValue(params.requestId);
1181
+ if (requestId === undefined) return;
1182
+ if (state.malformedRedirectRequestIds.has(requestId)) return;
1183
+ const current = state.network.get(requestId);
1184
+ if (current === undefined) return;
1185
+ const encodedDataLength = numberValue(params.encodedDataLength);
1186
+ if (encodedDataLength === undefined || encodedDataLength < 0) {
1187
+ state.completeness.exclude("network_requests", "invalid_protocol_value");
1188
+ return;
1189
+ }
1190
+ state.network.set(requestId, {
1191
+ ...current,
1192
+ encoded_data_length: encodedDataLength
1193
+ });
1194
+ };
1195
+ handleConsoleAPICalled = (state, params) => {
1196
+ const frame = firstCallFrame(recordValue(params.stackTrace));
1197
+ if (frame === undefined) {
1198
+ state.completeness.exclude("console_events", "unattributed_origin");
1199
+ return;
1200
+ }
1201
+ const source = allowedSanitizedUrl(frame.url, state.allowedOrigins);
1202
+ if (source === undefined) {
1203
+ state.completeness.exclude("console_events", exclusionReasonForUrl(cdpStringValue(frame.url)));
1204
+ return;
1205
+ }
1206
+ const arguments_ = recordsValue(params.args);
1207
+ state.console.push({
1208
+ type: cdpStringValue(params.type) ?? "unknown",
1209
+ timestamp: numberValue(params.timestamp) ?? 0,
1210
+ argument_types: arguments_.map((argument) => cdpStringValue(argument.type) ?? "unknown"),
1211
+ url: source.url,
1212
+ line: integerOrNull$1(frame.lineNumber),
1213
+ column: integerOrNull$1(frame.columnNumber),
1214
+ text_capture: captureConsoleText(state, arguments_)
1215
+ });
1216
+ };
1217
+ captureConsoleText = (state, arguments_) => {
1218
+ if (!state.input.include_console_text) return {
1219
+ status: "not_approved",
1220
+ values: [],
1221
+ retained_bytes: 0
1222
+ };
1223
+ const values = [];
1224
+ let retainedBytes = 0;
1225
+ for (const [argumentIndex, argument] of arguments_.entries()) {
1226
+ const primitive = consolePrimitive(argument);
1227
+ if (primitive === undefined) continue;
1228
+ const text = primitive.text;
1229
+ values.push({
1230
+ argument_index: argumentIndex,
1231
+ type: primitive.type,
1232
+ text
1233
+ });
1234
+ retainedBytes += Buffer.byteLength(text);
1235
+ }
1236
+ return {
1237
+ status: "included",
1238
+ values,
1239
+ retained_bytes: retainedBytes
1240
+ };
1241
+ };
1242
+ handleWebSocketFrame = (state, params, direction) => {
1243
+ const requestId = cdpStringValue(params.requestId);
1244
+ if (requestId === undefined) return;
1245
+ const connection = state.webSocketConnectionsById.get(requestId);
1246
+ if (connection === undefined) return;
1247
+ const response = recordValue(params.response);
1248
+ const payload = cdpStringValue(response?.payloadData) ?? "";
1249
+ const opcode = Math.max(0, Math.trunc(numberValue(response?.opcode) ?? 0));
1250
+ const decoded = opcode === 1 ? undefined : decodeBase64$1(payload);
1251
+ if (opcode !== 1 && decoded === undefined) state.completeness.exclude("websocket_frames", "invalid_protocol_value");
1252
+ connection.events.push({
1253
+ direction,
1254
+ opcode,
1255
+ payload_bytes: opcode === 1 ? Buffer.byteLength(payload) : decoded?.byteLength ?? null,
1256
+ payload_shape: captureWebSocketShape(state, payload, opcode)
1257
+ });
1258
+ };
1259
+ captureWebSocketShape = (state, payload, opcode) => {
1260
+ if (!state.input.include_websocket_shapes) return null;
1261
+ if (opcode !== 1) return {
1262
+ format: "binary",
1263
+ json_shape: null
1264
+ };
1265
+ const shape = inferJsonShape(payload);
1266
+ return {
1267
+ format: shape === null ? "text" : "json",
1268
+ json_shape: shape
1269
+ };
1270
+ };
1271
+ handleWebSocketCreated = (state, params) => {
1272
+ const requestId = cdpStringValue(params.requestId);
1273
+ const rawUrl = cdpStringValue(params.url);
1274
+ if (requestId === undefined) {
1275
+ state.completeness.exclude("websocket_connections", "invalid_protocol_value");
1276
+ return;
1277
+ }
1278
+ if (rawUrl === undefined) {
1279
+ state.completeness.exclude("websocket_connections", "invalid_protocol_value");
1280
+ return;
1281
+ }
1282
+ const sourceUrl = sanitizeBrowserUrl(rawUrl).url;
1283
+ let parsed;
1284
+ try {
1285
+ parsed = new URL(sourceUrl);
1286
+ } catch (cause) {
1287
+ void cause;
1288
+ state.completeness.exclude("websocket_connections", "unsupported_url");
1289
+ return;
1290
+ }
1291
+ if (parsed.protocol === "ws:") parsed.protocol = "http:";
1292
+ else if (parsed.protocol === "wss:") parsed.protocol = "https:";
1293
+ else {
1294
+ state.completeness.exclude("websocket_connections", "unsupported_url");
1295
+ return;
1296
+ }
1297
+ if (!state.allowedOrigins.has(parsed.origin)) {
1298
+ state.completeness.exclude("websocket_connections", "disallowed_origin");
1299
+ return;
1300
+ }
1301
+ if (state.webSocketConnectionsById.has(requestId)) {
1302
+ state.completeness.exclude("websocket_connections", "invalid_protocol_value");
1303
+ return;
1304
+ }
1305
+ state.webSocketConnectionsById.set(requestId, {
1306
+ request_id: requestId,
1307
+ url: sourceUrl,
1308
+ events: []
1309
+ });
1310
+ };
1311
+ handleFrameNavigated = (state, params) => {
1312
+ const frame = recordValue(params.frame);
1313
+ if (state.mainFrameId === undefined) return;
1314
+ if (!isMainFrameNavigation({
1315
+ method: "Page.frameNavigated",
1316
+ params
1317
+ }, state.mainFrameId)) return;
1318
+ const rawUrl = cdpStringValue(frame?.url);
1319
+ const loaderId = cdpStringValue(frame?.loaderId);
1320
+ const document = `${String(loaderId ?? "")}\0${String(rawUrl ?? "")}`;
1321
+ if (state.committedDocument === document) return;
1322
+ state.committedDocument = document;
1323
+ state.navigationDuringCapture = true;
1324
+ if (isHttpUrl(rawUrl) && allowedSanitizedUrl(rawUrl, state.allowedOrigins) === undefined) state.originViolation = true;
1325
+ };
1326
+ })))();
1327
+ }
1328
+
1329
+ //#endregion
1330
+ //#region dist/browser/CdpCaptureEvents.js
1331
+ var CdpCaptureEvents;
1332
+ function init_CdpCaptureEvents() {
1333
+ return (init_CdpCaptureEvents = __esmMin((() => {
1334
+ init_CdpCaptureCompleteness();
1335
+ init_CdpCaptureEventBodyShapes();
1336
+ init_CdpCaptureEventHandlers();
1337
+ init_CdpCaptureEventHelpers();
1338
+ init_CdpCaptureValues();
1339
+ CdpCaptureEvents = class {
1340
+ #scriptMetadataBudgetExclusionsRecorded = false;
1341
+ #networkRequestOccurrences = new Map();
1342
+ #responseBodyExaminedOccurrences = new Map();
1343
+ scripts = new Map();
1344
+ scriptMetadataBudgetOmissionsById = new Map();
1345
+ rejectedScriptMetadataBudgetCount = 0;
1346
+ rejectedSourceMapMetadataBudgetCount = 0;
1347
+ scriptMetadataBytesById = new Map();
1348
+ retainedScriptMetadataBytes = 0;
1349
+ executionContextFrames = new Map();
1350
+ network = new Map();
1351
+ networkRequestTimestamps = new Map();
1352
+ malformedRedirectRequestIds = new Set();
1353
+ webSocketConnectionsById = new Map();
1354
+ console = [];
1355
+ responseMetadata = [];
1356
+ agentHints = [];
1357
+ completeness = new CdpCaptureCompleteness([
1358
+ "network_requests",
1359
+ "console_events",
1360
+ "websocket_connections",
1361
+ "websocket_frames",
1362
+ "metadata"
1363
+ ]);
1364
+ originViolation = false;
1365
+ navigationDuringCapture = false;
1366
+ mainFrameId = undefined;
1367
+ committedDocument = undefined;
1368
+ input;
1369
+ allowedOrigins;
1370
+ constructor(input, allowedOrigins) {
1371
+ this.input = input;
1372
+ this.allowedOrigins = allowedOrigins;
1373
+ }
1374
+ beginAuthorizedFrame(frameId) {
1375
+ this.mainFrameId = frameId;
1376
+ this.originViolation = false;
1377
+ this.navigationDuringCapture = false;
1378
+ this.committedDocument = undefined;
1379
+ this.scripts.clear();
1380
+ this.scriptMetadataBudgetOmissionsById.clear();
1381
+ this.rejectedScriptMetadataBudgetCount = 0;
1382
+ this.rejectedSourceMapMetadataBudgetCount = 0;
1383
+ this.scriptMetadataBytesById.clear();
1384
+ this.retainedScriptMetadataBytes = 0;
1385
+ this.#scriptMetadataBudgetExclusionsRecorded = false;
1386
+ this.executionContextFrames.clear();
1387
+ this.network.clear();
1388
+ this.networkRequestTimestamps.clear();
1389
+ this.#networkRequestOccurrences.clear();
1390
+ this.#responseBodyExaminedOccurrences.clear();
1391
+ this.malformedRedirectRequestIds.clear();
1392
+ this.webSocketConnectionsById.clear();
1393
+ this.console.length = 0;
1394
+ this.responseMetadata.length = 0;
1395
+ this.agentHints.length = 0;
1396
+ this.completeness.reset();
1397
+ if (!this.input.include_console_text) this.completeness.exclude("console_text", "not_approved", null);
1398
+ if (!this.input.include_json_body_shapes) this.completeness.exclude("json_body_shapes", "not_approved", null);
1399
+ if (!this.input.include_websocket_shapes) this.completeness.exclude("websocket_shapes", "not_approved", null);
1400
+ }
1401
+ beginFinalCapture(frameId) {
1402
+ this.mainFrameId = frameId;
1403
+ this.committedDocument = undefined;
1404
+ }
1405
+ /** Record final script metadata omissions after all scriptParsed replacements. */
1406
+ recordScriptMetadataBudgetExclusions() {
1407
+ if (this.#scriptMetadataBudgetExclusionsRecorded) return;
1408
+ this.#scriptMetadataBudgetExclusionsRecorded = true;
1409
+ const omittedScripts = this.rejectedScriptMetadataBudgetCount;
1410
+ const omittedSourceMaps = this.rejectedSourceMapMetadataBudgetCount + this.scriptMetadataBudgetOmissionsById.size;
1411
+ if (omittedScripts > 0) this.completeness.exclude("scripts", "resource_budget_exhausted", omittedScripts);
1412
+ if (omittedSourceMaps > 0) this.completeness.exclude("source_maps", "resource_budget_exhausted", omittedSourceMaps);
1413
+ }
1414
+ ingest(event) {
1415
+ const params = recordValue(event.params);
1416
+ if (params === undefined) return;
1417
+ switch (event.method) {
1418
+ case "Runtime.executionContextCreated":
1419
+ handleExecutionContextCreated(this, params);
1420
+ break;
1421
+ case "Runtime.executionContextDestroyed":
1422
+ handleExecutionContextDestroyed(this, params);
1423
+ break;
1424
+ case "Runtime.executionContextsCleared":
1425
+ this.executionContextFrames.clear();
1426
+ break;
1427
+ case "Debugger.scriptParsed":
1428
+ handleScriptParsed(this, params);
1429
+ break;
1430
+ case "Network.requestWillBeSent": {
1431
+ const requestId = cdpStringValue(params.requestId);
1432
+ const previous = requestId === undefined ? undefined : this.network.get(requestId);
1433
+ handleRequestWillBeSent(this, params);
1434
+ if (requestId !== undefined && this.network.get(requestId) !== previous) this.#networkRequestOccurrences.set(requestId, (this.#networkRequestOccurrences.get(requestId) ?? 0) + 1);
1435
+ break;
1436
+ }
1437
+ case "Network.responseReceived":
1438
+ handleResponseReceived(this, params);
1439
+ break;
1440
+ case "Network.loadingFinished":
1441
+ handleLoadingFinished(this, params);
1442
+ break;
1443
+ case "Runtime.consoleAPICalled":
1444
+ handleConsoleAPICalled(this, params);
1445
+ break;
1446
+ case "Page.frameNavigated":
1447
+ handleFrameNavigated(this, params);
1448
+ break;
1449
+ case "Network.webSocketCreated":
1450
+ handleWebSocketCreated(this, params);
1451
+ break;
1452
+ case "Network.webSocketFrameSent":
1453
+ handleWebSocketFrame(this, params, "sent");
1454
+ break;
1455
+ case "Network.webSocketFrameReceived":
1456
+ handleWebSocketFrame(this, params, "received");
1457
+ break;
1458
+ }
1459
+ }
1460
+ /** Resolve a transient execution context to one already authorized frame. */
1461
+ frameForScript(script, allowedFrameIds) {
1462
+ return script.frameId !== null && allowedFrameIds.has(script.frameId) ? script.frameId : null;
1463
+ }
1464
+ responseBodyRequests() {
1465
+ if (!this.input.include_json_body_shapes) return [];
1466
+ return [...this.network.values()].filter((request) => !this.malformedRedirectRequestIds.has(request.request_id)).filter((request) => isJsonMediaType(request.mime_type)).flatMap((request) => {
1467
+ const occurrence = this.#networkRequestOccurrences.get(request.request_id);
1468
+ return occurrence === undefined ? [] : [{
1469
+ requestId: request.request_id,
1470
+ occurrence
1471
+ }];
1472
+ });
1473
+ }
1474
+ currentResponseBodyRequest(candidate) {
1475
+ if (candidate.occurrence !== this.#networkRequestOccurrences.get(candidate.requestId)) return undefined;
1476
+ return this.network.get(candidate.requestId);
1477
+ }
1478
+ responseBodyUnavailable(candidate) {
1479
+ if (this.currentResponseBodyRequest(candidate) === undefined) return;
1480
+ this.#responseBodyExaminedOccurrences.set(candidate.requestId, candidate.occurrence);
1481
+ if (this.malformedRedirectRequestIds.has(candidate.requestId)) return;
1482
+ updateResponseBodyShape(this, candidate.requestId, null);
1483
+ this.completeness.unavailable("json_body_shapes");
1484
+ }
1485
+ /**
1486
+ * Mark eligible response bodies that arrived after the fetch pass was
1487
+ * enumerated.
1488
+ */
1489
+ settleUnexaminedResponseBodies() {
1490
+ for (const candidate of this.responseBodyRequests()) {
1491
+ const request = this.currentResponseBodyRequest(candidate);
1492
+ if (request?.body_shapes.response === null && this.#responseBodyExaminedOccurrences.get(candidate.requestId) !== candidate.occurrence) this.responseBodyUnavailable(candidate);
1493
+ }
1494
+ }
1495
+ ingestResponseBody(candidate, value) {
1496
+ if (this.currentResponseBodyRequest(candidate) === undefined) return;
1497
+ this.#responseBodyExaminedOccurrences.set(candidate.requestId, candidate.occurrence);
1498
+ if (this.malformedRedirectRequestIds.has(candidate.requestId)) return;
1499
+ ingestResponseBodyShape(this, candidate.requestId, value);
1500
+ }
1501
+ };
1502
+ })))();
1503
+ }
1504
+
1505
+ //#endregion
1506
+ //#region dist/browser/CdpCaptureStorageFingerprints.js
1507
+ var captureStorageFingerprints, addStorageItems, addCookies, addIndexedDb, indexedDbStoreSchema, indexedDbSchemaComplete, indexedDbKeyPathComplete, addIndexedDbRecords, addCaches, addCacheEntry, addFingerprint, STORAGE_ENTRY_PAGE_SIZE, digest, encodedValue, stableValue, stableValueComplete, remoteObjectComplete, decodeBase64;
1508
+ function init_CdpCaptureStorageFingerprints() {
1509
+ return (init_CdpCaptureStorageFingerprints = __esmMin((() => {
1510
+ init_unicodeCodePointOrder();
1511
+ init_CdpConnection();
1512
+ init_CdpOptionalCommand();
1513
+ init_CdpCaptureValues();
1514
+ captureStorageFingerprints = async ({ context, origin, cookieUrl, local, session, indexedDbNames, caches, limitations }) => {
1515
+ const state = {
1516
+ items: [],
1517
+ complete: local.complete && session.complete
1518
+ };
1519
+ const run = {
1520
+ context,
1521
+ limitations,
1522
+ state
1523
+ };
1524
+ addStorageItems(state, "local_storage", local.items);
1525
+ addStorageItems(state, "session_storage", session.items);
1526
+ await addCookies(run, cookieUrl);
1527
+ await addIndexedDb(run, origin, indexedDbNames);
1528
+ await addCaches(run, caches);
1529
+ state.items.sort((left, right) => compareUnicodeCodePoints(`${left.scope}:${left.identity_sha256}`, `${right.scope}:${right.identity_sha256}`));
1530
+ const complete = state.complete && state.items.every(({ complete }) => complete);
1531
+ return {
1532
+ items: state.items,
1533
+ complete
1534
+ };
1535
+ };
1536
+ addStorageItems = (state, scope, items) => {
1537
+ for (const item of items) addFingerprint(state, {
1538
+ scope,
1539
+ identity: item.key,
1540
+ value: item.value,
1541
+ complete: true
1542
+ });
1543
+ };
1544
+ addCookies = async (run, pageUrl) => {
1545
+ run.limitations.push("Cookie fingerprints cover cookies applicable to the current main-frame URL, not every path on its origin.");
1546
+ const raw = await optionalCdpCommand(run.context, "Network.getCookies", { urls: [pageUrl] }, run.limitations);
1547
+ if (raw === undefined) {
1548
+ run.state.complete = false;
1549
+ return;
1550
+ }
1551
+ const cookieValues = recordValue(raw)?.cookies;
1552
+ if (!Array.isArray(cookieValues)) {
1553
+ run.state.complete = false;
1554
+ return;
1555
+ }
1556
+ const cookies = recordsValue(cookieValues);
1557
+ if (cookies.length !== cookieValues.length) run.state.complete = false;
1558
+ for (const cookie of cookies) {
1559
+ const name = cdpStringValue(cookie.name);
1560
+ const value = cdpStringValue(cookie.value);
1561
+ const domain = cdpStringValue(cookie.domain);
1562
+ const path = cdpStringValue(cookie.path);
1563
+ if (name === undefined || value === undefined || domain === undefined || path === undefined) {
1564
+ run.state.complete = false;
1565
+ continue;
1566
+ }
1567
+ addFingerprint(run.state, {
1568
+ scope: "cookie",
1569
+ identity: {
1570
+ domain,
1571
+ path,
1572
+ name,
1573
+ partition_key: cookie.partitionKey ?? null
1574
+ },
1575
+ value,
1576
+ complete: true
1577
+ });
1578
+ }
1579
+ };
1580
+ addIndexedDb = async (run, origin, names) => {
1581
+ for (const databaseName of names) {
1582
+ const raw = await optionalCdpCommand(run.context, "IndexedDB.requestDatabase", {
1583
+ securityOrigin: origin,
1584
+ databaseName
1585
+ }, run.limitations);
1586
+ const database = recordValue(recordValue(raw)?.databaseWithObjectStores);
1587
+ if (raw === undefined || database === undefined) {
1588
+ run.state.complete = false;
1589
+ continue;
1590
+ }
1591
+ if (cdpStringValue(database.name) !== databaseName) {
1592
+ run.state.complete = false;
1593
+ continue;
1594
+ }
1595
+ if (!Array.isArray(database.objectStores)) {
1596
+ run.state.complete = false;
1597
+ continue;
1598
+ }
1599
+ const stores = recordsValue(database.objectStores);
1600
+ if (stores.length !== database.objectStores.length) run.state.complete = false;
1601
+ addFingerprint(run.state, {
1602
+ scope: "indexed_db_schema",
1603
+ identity: databaseName,
1604
+ value: stores.map(indexedDbStoreSchema),
1605
+ complete: stores.length === database.objectStores.length && indexedDbSchemaComplete(stores)
1606
+ });
1607
+ for (const store of stores) {
1608
+ const objectStoreName = cdpStringValue(store.name);
1609
+ if (objectStoreName === undefined) {
1610
+ run.state.complete = false;
1611
+ continue;
1612
+ }
1613
+ await addIndexedDbRecords(run, {
1614
+ origin,
1615
+ databaseName,
1616
+ objectStoreName
1617
+ });
1618
+ }
1619
+ }
1620
+ };
1621
+ indexedDbStoreSchema = (store) => ({
1622
+ name: cdpStringValue(store.name) ?? null,
1623
+ key_path: stableValue(store.keyPath),
1624
+ auto_increment: store.autoIncrement === true,
1625
+ indexes: recordsValue(store.indexes).map((index) => ({
1626
+ name: cdpStringValue(index.name) ?? null,
1627
+ key_path: stableValue(index.keyPath),
1628
+ unique: index.unique === true,
1629
+ multi_entry: index.multiEntry === true
1630
+ }))
1631
+ });
1632
+ indexedDbSchemaComplete = (stores) => stores.every((store) => cdpStringValue(store.name) !== undefined && indexedDbKeyPathComplete(store.keyPath) && typeof store.autoIncrement === "boolean" && Array.isArray(store.indexes) && recordsValue(store.indexes).length === store.indexes.length && recordsValue(store.indexes).every((index) => cdpStringValue(index.name) !== undefined && indexedDbKeyPathComplete(index.keyPath) && typeof index.unique === "boolean" && typeof index.multiEntry === "boolean"));
1633
+ indexedDbKeyPathComplete = (value) => {
1634
+ const keyPath = recordValue(value);
1635
+ if (keyPath === undefined) return false;
1636
+ switch (keyPath.type) {
1637
+ case "null": return true;
1638
+ case "string": return typeof keyPath.string === "string";
1639
+ case "array": return Array.isArray(keyPath.array) && keyPath.array.every((key) => typeof key === "string");
1640
+ default: return false;
1641
+ }
1642
+ };
1643
+ addIndexedDbRecords = async (run, input) => {
1644
+ let skipCount = 0;
1645
+ while (true) {
1646
+ const raw = await optionalCdpCommand(run.context, "IndexedDB.requestData", {
1647
+ securityOrigin: input.origin,
1648
+ databaseName: input.databaseName,
1649
+ objectStoreName: input.objectStoreName,
1650
+ skipCount,
1651
+ pageSize: STORAGE_ENTRY_PAGE_SIZE
1652
+ }, run.limitations);
1653
+ const result = recordValue(raw);
1654
+ if (raw === undefined || result === undefined) {
1655
+ run.state.complete = false;
1656
+ return;
1657
+ }
1658
+ if (!Array.isArray(result.objectStoreDataEntries) || typeof result.hasMore !== "boolean") {
1659
+ run.state.complete = false;
1660
+ return;
1661
+ }
1662
+ const entries = recordsValue(result.objectStoreDataEntries);
1663
+ if (entries.length !== result.objectStoreDataEntries.length) run.state.complete = false;
1664
+ for (const entry of entries) {
1665
+ const key = stableValue(entry.key);
1666
+ const primaryKey = stableValue(entry.primaryKey);
1667
+ const value = entry.value === undefined ? undefined : stableValue(entry.value);
1668
+ addFingerprint(run.state, {
1669
+ scope: "indexed_db_record",
1670
+ identity: {
1671
+ database: input.databaseName,
1672
+ store: input.objectStoreName,
1673
+ key,
1674
+ primaryKey
1675
+ },
1676
+ value,
1677
+ complete: remoteObjectComplete(entry.key) && remoteObjectComplete(entry.primaryKey) && remoteObjectComplete(entry.value)
1678
+ });
1679
+ }
1680
+ if (result.hasMore !== true) return;
1681
+ if (entries.length === 0 || skipCount > Number.MAX_SAFE_INTEGER - entries.length) {
1682
+ run.state.complete = false;
1683
+ return;
1684
+ }
1685
+ skipCount += entries.length;
1686
+ }
1687
+ };
1688
+ addCaches = async (run, caches) => {
1689
+ for (const cache of caches) {
1690
+ let skipCount = 0;
1691
+ let returnCount;
1692
+ while (returnCount === undefined || skipCount < returnCount) {
1693
+ const raw = await optionalCdpCommand(run.context, "CacheStorage.requestEntries", {
1694
+ cacheId: cache.id,
1695
+ skipCount,
1696
+ pageSize: STORAGE_ENTRY_PAGE_SIZE
1697
+ }, run.limitations);
1698
+ const result = recordValue(raw);
1699
+ if (raw === undefined || result === undefined) {
1700
+ run.state.complete = false;
1701
+ break;
1702
+ }
1703
+ if (!Array.isArray(result.cacheDataEntries) || typeof result.returnCount !== "number" || !Number.isSafeInteger(result.returnCount) || result.returnCount < 0) {
1704
+ run.state.complete = false;
1705
+ break;
1706
+ }
1707
+ const entries = recordsValue(result.cacheDataEntries);
1708
+ if (entries.length !== result.cacheDataEntries.length) run.state.complete = false;
1709
+ for (const entry of entries) await addCacheEntry(run, cache, entry);
1710
+ returnCount = result.returnCount;
1711
+ if (skipCount + entries.length >= returnCount) break;
1712
+ if (entries.length === 0 || skipCount > Number.MAX_SAFE_INTEGER - entries.length) {
1713
+ run.state.complete = false;
1714
+ break;
1715
+ }
1716
+ skipCount += entries.length;
1717
+ }
1718
+ }
1719
+ };
1720
+ addCacheEntry = async (run, cache, entry) => {
1721
+ const requestURL = cdpStringValue(entry.requestURL);
1722
+ const requestMethod = cdpStringValue(entry.requestMethod);
1723
+ if (requestURL === undefined || requestMethod === undefined) {
1724
+ run.state.complete = false;
1725
+ return;
1726
+ }
1727
+ if (!Array.isArray(entry.requestHeaders)) {
1728
+ run.state.complete = false;
1729
+ return;
1730
+ }
1731
+ const headerRecords = recordsValue(entry.requestHeaders);
1732
+ const requestHeaders = headerRecords.flatMap((header) => {
1733
+ const name = cdpStringValue(header.name);
1734
+ const value = cdpStringValue(header.value);
1735
+ return name === undefined || value === undefined ? [] : [{
1736
+ name,
1737
+ value
1738
+ }];
1739
+ });
1740
+ if (headerRecords.length !== entry.requestHeaders.length || requestHeaders.length !== headerRecords.length) {
1741
+ run.state.complete = false;
1742
+ return;
1743
+ }
1744
+ const raw = await optionalCdpCommand(run.context, "CacheStorage.requestCachedResponse", {
1745
+ cacheId: cache.id,
1746
+ requestURL,
1747
+ requestHeaders
1748
+ }, run.limitations);
1749
+ const body = cdpStringValue(recordValue(recordValue(raw)?.response)?.body);
1750
+ const decoded = body === undefined ? null : decodeBase64(body);
1751
+ const complete = decoded !== null;
1752
+ if (!complete) run.state.complete = false;
1753
+ addFingerprint(run.state, {
1754
+ scope: "cache_entry",
1755
+ identity: {
1756
+ cache: cache.name,
1757
+ requestURL,
1758
+ requestMethod,
1759
+ requestHeaders
1760
+ },
1761
+ value: decoded ?? undefined,
1762
+ complete
1763
+ });
1764
+ };
1765
+ addFingerprint = (state, input) => {
1766
+ state.items.push({
1767
+ scope: input.scope,
1768
+ identity_sha256: digest(input.identity),
1769
+ value_sha256: input.value === undefined ? null : digest(input.value),
1770
+ complete: input.complete && stableValueComplete(input.identity) && stableValueComplete(input.value)
1771
+ });
1772
+ };
1773
+ STORAGE_ENTRY_PAGE_SIZE = 1e3;
1774
+ digest = (value) => createHash("sha256").update(encodedValue(value)).digest("hex");
1775
+ encodedValue = (value) => {
1776
+ if (value instanceof Uint8Array) return value;
1777
+ const encoded = canonicalize(stableValue(value));
1778
+ if (encoded === undefined) throw new TypeError("Expected canonical JSON");
1779
+ return encoded;
1780
+ };
1781
+ stableValue = (value) => {
1782
+ if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
1783
+ if (Array.isArray(value)) return value.map((item) => stableValue(item));
1784
+ const record = recordValue(value);
1785
+ if (record === undefined) return String(value);
1786
+ return Object.fromEntries(Object.entries(record).filter(([key]) => key !== "objectId" && key !== "customPreview").sort(([left], [right]) => compareUnicodeCodePoints(left, right)).map(([key, item]) => [key, stableValue(item)]));
1787
+ };
1788
+ stableValueComplete = (value) => {
1789
+ if (value instanceof Uint8Array) return true;
1790
+ if (value === null || value === undefined || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return true;
1791
+ if (Array.isArray(value)) return value.every((item) => stableValueComplete(item));
1792
+ const record = recordValue(value);
1793
+ if (record === undefined) return false;
1794
+ const entries = Object.entries(record).filter(([key]) => key !== "objectId" && key !== "customPreview");
1795
+ return entries.every(([, item]) => stableValueComplete(item));
1796
+ };
1797
+ remoteObjectComplete = (value) => {
1798
+ const record = recordValue(value);
1799
+ if (record === undefined || record.objectId !== undefined || record.preview !== undefined || record.customPreview !== undefined || !stableValueComplete(record)) return false;
1800
+ switch (record.type) {
1801
+ case "undefined": return record.value === undefined && record.unserializableValue === undefined;
1802
+ case "string":
1803
+ case "boolean": return typeof record.value === record.type && record.unserializableValue === undefined;
1804
+ case "number": return record.unserializableValue === undefined ? typeof record.value === "number" && Number.isFinite(record.value) : record.value === undefined && typeof record.unserializableValue === "string" && [
1805
+ "-0",
1806
+ "NaN",
1807
+ "Infinity",
1808
+ "-Infinity"
1809
+ ].includes(record.unserializableValue);
1810
+ case "bigint": return record.value === undefined && typeof record.unserializableValue === "string" && /^-?\d+n$/u.test(record.unserializableValue);
1811
+ case "object": return record.unserializableValue === undefined && (record.subtype === "null" ? record.value === null : record.value !== null && typeof record.value === "object");
1812
+ default: return false;
1813
+ }
1814
+ };
1815
+ decodeBase64 = (value) => {
1816
+ if (value.length % 4 !== 0 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(value)) return null;
1817
+ return Buffer.from(value, "base64");
1818
+ };
1819
+ })))();
1820
+ }
1821
+
1822
+ //#endregion
1823
+ //#region dist/browser/CdpCaptureStorage.js
1824
+ var captureStorage, emptyStorageItems, capturedCaches, storageItems, stringArray;
1825
+ function init_CdpCaptureStorage() {
1826
+ return (init_CdpCaptureStorage = __esmMin((() => {
1827
+ init_CdpConnection();
1828
+ init_CdpOptionalCommand();
1829
+ init_CdpCaptureStorageFingerprints();
1830
+ init_CdpCaptureValues();
1831
+ captureStorage = async (context, pageUrl, limitations) => {
1832
+ const origin = new URL(pageUrl).origin;
1833
+ const quota = recordValue(await optionalCdpCommand(context, "Storage.getUsageAndQuota", { origin }, limitations));
1834
+ const local = context.input.include_storage_keys ? await storageItems(context, origin, true, limitations) : emptyStorageItems;
1835
+ const session = context.input.include_storage_keys ? await storageItems(context, origin, false, limitations) : emptyStorageItems;
1836
+ const indexedRaw = context.input.include_storage_keys ? await optionalCdpCommand(context, "IndexedDB.requestDatabaseNames", { securityOrigin: origin }, limitations) : undefined;
1837
+ const indexedValues = recordValue(indexedRaw)?.databaseNames;
1838
+ const indexed = stringArray(indexedValues);
1839
+ const cacheRaw = context.input.include_storage_keys ? await optionalCdpCommand(context, "CacheStorage.requestCacheNames", { securityOrigin: origin }, limitations) : undefined;
1840
+ const cacheField = recordValue(cacheRaw)?.caches;
1841
+ const caches = capturedCaches(recordsValue(cacheField));
1842
+ const fingerprints = context.input.include_storage_fingerprints ? await captureStorageFingerprints({
1843
+ context,
1844
+ origin,
1845
+ cookieUrl: pageUrl,
1846
+ local,
1847
+ session,
1848
+ indexedDbNames: indexed,
1849
+ caches,
1850
+ limitations
1851
+ }) : {
1852
+ items: [],
1853
+ complete: false
1854
+ };
1855
+ const structuredStorageComplete = indexedRaw !== undefined && Array.isArray(indexedValues) && indexed.length === indexedValues.length && Array.isArray(cacheField) && caches.length === cacheField.length;
1856
+ const keysExclusion = !context.input.include_storage_keys ? undefined : local.exclusion === "provider_unavailable" || session.exclusion === "provider_unavailable" || indexedRaw === undefined || cacheRaw === undefined ? "provider_unavailable" : !local.complete || !session.complete || !structuredStorageComplete ? "invalid_protocol_value" : undefined;
1857
+ return {
1858
+ keysExclusion,
1859
+ value: {
1860
+ origin,
1861
+ usage_bytes: numberValue(quota?.usage) ?? null,
1862
+ quota_bytes: numberValue(quota?.quota) ?? null,
1863
+ local_storage_keys: local.items.map(({ key }) => key),
1864
+ session_storage_keys: session.items.map(({ key }) => key),
1865
+ indexed_db_names: [...indexed],
1866
+ cache_names: caches.map(({ name }) => name),
1867
+ content_fingerprints: [...fingerprints.items],
1868
+ fingerprint_algorithm: "sha256",
1869
+ fingerprints_complete: fingerprints.complete && structuredStorageComplete,
1870
+ values_redacted: true
1871
+ }
1872
+ };
1873
+ };
1874
+ emptyStorageItems = {
1875
+ items: [],
1876
+ complete: false
1877
+ };
1878
+ capturedCaches = (values) => values.flatMap((cache) => {
1879
+ const name = cdpStringValue(cache.cacheName);
1880
+ const id = cdpStringValue(cache.cacheId);
1881
+ return name === undefined || id === undefined ? [] : [{
1882
+ name,
1883
+ id
1884
+ }];
1885
+ });
1886
+ storageItems = async (context, origin, isLocalStorage, limitations) => {
1887
+ const raw = await optionalCdpCommand(context, "DOMStorage.getDOMStorageItems", { storageId: {
1888
+ securityOrigin: origin,
1889
+ isLocalStorage
1890
+ } }, limitations);
1891
+ const entries = recordValue(raw)?.entries;
1892
+ if (raw === undefined || !Array.isArray(entries)) return {
1893
+ items: [],
1894
+ complete: false,
1895
+ exclusion: raw === undefined ? "provider_unavailable" : "invalid_protocol_value"
1896
+ };
1897
+ const items = entries.flatMap((entry) => {
1898
+ if (!Array.isArray(entry)) return [];
1899
+ const key = cdpStringValue(entry[0]);
1900
+ const value = cdpStringValue(entry[1]);
1901
+ return key === undefined || value === undefined ? [] : [{
1902
+ key,
1903
+ value
1904
+ }];
1905
+ });
1906
+ return {
1907
+ items,
1908
+ complete: items.length === entries.length
1909
+ };
1910
+ };
1911
+ stringArray = (value) => Array.isArray(value) ? value.flatMap((item) => {
1912
+ const text = cdpStringValue(item);
1913
+ return text === undefined ? [] : [text];
1914
+ }) : [];
1915
+ })))();
1916
+ }
1917
+
1918
+ //#endregion
1919
+ //#region dist/browser/CdpPageCaptureScripts.js
1920
+ var captureScripts, buildScriptDraft, captureScriptSource, keyAndBuildInventory, sourceDigest;
1921
+ function init_CdpPageCaptureScripts() {
1922
+ return (init_CdpPageCaptureScripts = __esmMin((() => {
1923
+ init_webInventory();
1924
+ init_CdpCaptureValues();
1925
+ init_unicodeCodePointOrder();
1926
+ captureScripts = async (options) => {
1927
+ const { context, events, rawResources, resources, frameIds } = options;
1928
+ const state = {
1929
+ context,
1930
+ events,
1931
+ frameIds,
1932
+ rawResources,
1933
+ resources
1934
+ };
1935
+ const drafts = [];
1936
+ for (const script of events.scripts.values()) drafts.push(await buildScriptDraft(script, state));
1937
+ if (!context.input.include_script_sources) events.completeness.exclude("script_sources", "not_approved", events.scripts.size);
1938
+ return keyAndBuildInventory(drafts, events.scripts.size);
1939
+ };
1940
+ buildScriptDraft = async (script, state) => {
1941
+ let source = state.context.input.include_script_sources ? await captureScriptSource(script, state) : sourceExcluded("source capture was not selected");
1942
+ const inventoryScript = {
1943
+ frame_id: state.events.frameForScript(script, state.frameIds),
1944
+ url: script.url,
1945
+ cdp_hash: script.hash,
1946
+ length: script.length,
1947
+ is_module: script.isModule,
1948
+ language: script.language,
1949
+ source_map_url: script.sourceMapUrl
1950
+ };
1951
+ return {
1952
+ item: {
1953
+ ...inventoryScript,
1954
+ origin: script.origin,
1955
+ resource_reconciliation: reconcileCapturedWebScript({
1956
+ ...inventoryScript,
1957
+ rawUrl: script.rawUrl
1958
+ }, state.rawResources, state.resources),
1959
+ source
1960
+ },
1961
+ sourceMapRawUrl: script.sourceMapRawUrl
1962
+ };
1963
+ };
1964
+ captureScriptSource = async (script, state) => {
1965
+ const { context } = state;
1966
+ const content = requiredScriptSource(await context.connection.send("Debugger.getScriptSource", { scriptId: script.scriptId }, context.sessionId, context.signal), context.operation);
1967
+ return sourceResult(content);
1968
+ };
1969
+ keyAndBuildInventory = (drafts, scriptCount) => {
1970
+ const keyed = drafts.map((draft) => ({
1971
+ ...draft,
1972
+ base: stableWebScriptKey(draft.item)
1973
+ }));
1974
+ keyed.sort((left, right) => compareUnicodeCodePoints(left.base, right.base) || compareUnicodeCodePoints(sourceDigest(left.item.source), sourceDigest(right.item.source)) || compareUnicodeCodePoints(left.item.frame_id ?? "", right.item.frame_id ?? ""));
1975
+ const totals = new Map();
1976
+ for (const { base } of keyed) totals.set(base, (totals.get(base) ?? 0) + 1);
1977
+ const seen = new Map();
1978
+ const sourceMapRequests = [];
1979
+ const items = keyed.map(({ base, item, sourceMapRawUrl }) => {
1980
+ const occurrence = (seen.get(base) ?? 0) + 1;
1981
+ seen.set(base, occurrence);
1982
+ const scriptKey = totals.get(base) === 1 ? base : `${base}_${String(occurrence)}`;
1983
+ if (item.source_map_url !== null && sourceMapRawUrl !== null) sourceMapRequests.push({
1984
+ scriptKey,
1985
+ declaredUrl: item.source_map_url,
1986
+ fetchUrl: sourceMapRawUrl
1987
+ });
1988
+ return {
1989
+ script_key: scriptKey,
1990
+ ...item
1991
+ };
1992
+ });
1993
+ return {
1994
+ inventory: {
1995
+ total: scriptCount,
1996
+ items
1997
+ },
1998
+ sourceMapRequests
1999
+ };
2000
+ };
2001
+ sourceDigest = (source) => source.included ? source.artifact.sha256 : source.reason;
2002
+ })))();
2003
+ }
2004
+
2005
+ //#endregion
2006
+ //#region dist/browser/CdpPageCaptureWorkers.js
2007
+ var captureWorkers;
2008
+ function init_CdpPageCaptureWorkers() {
2009
+ return (init_CdpPageCaptureWorkers = __esmMin((() => {
2010
+ init_CdpCaptureValues();
2011
+ init_CdpOptionalCommand();
2012
+ captureWorkers = async (input, frameIds) => {
2013
+ const { context, allowedOrigins, limitations, events } = input;
2014
+ const completeness = events.completeness;
2015
+ const result = await optionalCdpCommand({
2016
+ ...context,
2017
+ sessionId: undefined
2018
+ }, "Target.getTargets", {}, limitations);
2019
+ const items = [];
2020
+ if (result === undefined) completeness.unavailable("workers");
2021
+ for (const target of recordsValue(recordValue(result)?.targetInfos)) {
2022
+ const type = cdpStringValue(target.type) ?? "";
2023
+ const url = allowedSanitizedUrl(target.url, allowedOrigins);
2024
+ const relatedToPage = cdpStringValue(target.openerId) === context.target.id || cdpStringValue(target.parentFrameId) !== undefined && frameIds.has(cdpStringValue(target.parentFrameId) ?? "");
2025
+ if (!type.includes("worker")) continue;
2026
+ if (!relatedToPage) {
2027
+ completeness.exclude("workers", "out_of_target_scope");
2028
+ continue;
2029
+ }
2030
+ if (url === undefined) {
2031
+ const rawUrl = cdpStringValue(target.url);
2032
+ completeness.exclude("workers", rawUrl === undefined || rawUrl === "" ? "unattributed_origin" : isHttpUrl(rawUrl) ? "disallowed_origin" : "unsupported_url");
2033
+ continue;
2034
+ }
2035
+ if (typeof target.attached !== "boolean") {
2036
+ completeness.exclude("workers", "invalid_protocol_value");
2037
+ continue;
2038
+ }
2039
+ items.push({
2040
+ target_id: cdpStringValue(target.targetId) ?? "",
2041
+ type,
2042
+ url: url.url,
2043
+ origin: url.origin,
2044
+ attached: target.attached,
2045
+ opener_target_id: cdpStringValue(target.openerId) ?? null,
2046
+ parent_frame_id: cdpStringValue(target.parentFrameId) ?? null
2047
+ });
2048
+ }
2049
+ return items;
2050
+ };
2051
+ })))();
2052
+ }
2053
+
2054
+ //#endregion
2055
+ //#region dist/browser/CdpPageCapture.js
2056
+ var capturePage, captureAuthorizedPage, captureJsonResponseBodies, authorizeObservationWindow, capturePageDom, normalizedInspection, enableObservationDomains, accessibilityForFrames, publicResource, deduplicatedAgentHints, normalizedTarget, report;
2057
+ function init_CdpPageCapture() {
2058
+ return (init_CdpPageCapture = __esmMin((() => {
2059
+ init_browserObservationError();
2060
+ init_webInventory();
2061
+ init_CdpConnection();
2062
+ init_CdpCaptureEvents();
2063
+ init_CdpAuthorizedMainFrame();
2064
+ init_CdpCaptureStorage();
2065
+ init_CdpOptionalCommand();
2066
+ init_CdpCommandRejection();
2067
+ init_CdpCaptureDocuments();
2068
+ init_CdpCaptureDomSvg();
2069
+ init_CdpCaptureValues();
2070
+ init_CdpPageCaptureScripts();
2071
+ init_CdpPageCaptureWorkers();
2072
+ capturePage = async (context) => {
2073
+ const allowedOrigins = new Set(context.input.allowed_origins);
2074
+ const events = new CdpCaptureEvents(context.input, allowedOrigins);
2075
+ const removeListener = context.connection.onEvent((event) => {
2076
+ if (event.sessionId !== context.sessionId) return;
2077
+ events.ingest(event);
2078
+ });
2079
+ const state = {
2080
+ context,
2081
+ events,
2082
+ allowedOrigins,
2083
+ limitations: [
2084
+ "Observation starts when REA attaches; prior network and console activity is unavailable.",
2085
+ "Raw network headers, bodies, cookies, storage values, console objects, and WebSocket payloads are never retained; explicitly requested primitive console text is retained verbatim, while payload captures retain value-free shapes.",
2086
+ "Source maps are reported only as declarative URLs and are not fetched.",
2087
+ "URL-less scripts and console events without an allowed source URL are excluded because their origin cannot be proven.",
2088
+ ...context.target.attached === null ? ["CDP discovery omitted the target attachment state; attached is reported as unknown."] : []
2089
+ ],
2090
+ startedAt: new Date().toISOString()
2091
+ };
2092
+ try {
2093
+ return await captureAuthorizedPage(state);
2094
+ } finally {
2095
+ removeListener();
2096
+ }
2097
+ };
2098
+ captureAuthorizedPage = async (state) => {
2099
+ const { context, allowedOrigins, limitations } = state;
2100
+ const { connection, sessionId, input, signal } = context;
2101
+ await authorizeObservationWindow(state);
2102
+ await captureJsonResponseBodies(state);
2103
+ const frameResult = await authorizedMainFrame({
2104
+ connection: context.connection,
2105
+ sessionId: context.sessionId,
2106
+ signal: context.signal,
2107
+ allowedOrigins,
2108
+ operation: context.operation
2109
+ });
2110
+ const attachedUrl = mainFrameUrl(frameResult) ?? "";
2111
+ const frameCapture = captureFrames(frameResult, allowedOrigins, undefined, state.events.completeness);
2112
+ const frames = frameCapture.items;
2113
+ const captureFrame = frames[0];
2114
+ if (captureFrame === undefined) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
2115
+ state.events.beginFinalCapture(captureFrame.frame_id);
2116
+ const resourceCapture = captureResources(await connection.send("Page.getResourceTree", {}, sessionId, signal), allowedOrigins, state.events.completeness);
2117
+ const resources = stableWebResources(resourceCapture.items.map(publicResource));
2118
+ const dom = await capturePageDom(state);
2119
+ const accessibility = await accessibilityForFrames(state, frames);
2120
+ const scripts = await captureScripts({
2121
+ context,
2122
+ events: state.events,
2123
+ rawResources: resourceCapture.items,
2124
+ resources,
2125
+ frameIds: new Set(frames.map((frame) => frame.frame_id))
2126
+ });
2127
+ const workers = await captureWorkers({
2128
+ context,
2129
+ allowedOrigins,
2130
+ limitations,
2131
+ events: state.events
2132
+ }, new Set(frames.map((frame) => frame.frame_id)));
2133
+ const storageCapture = await captureStorage(context, attachedUrl, limitations);
2134
+ if (!input.include_storage_keys) state.events.completeness.exclude("storage_keys", "not_approved", null);
2135
+ else if (storageCapture.keysExclusion !== undefined) state.events.completeness.exclude("storage_keys", storageCapture.keysExclusion, null);
2136
+ await report(context.progress, 3, "Normalizing browser evidence");
2137
+ const completedFrameResult = await authorizedMainFrame({
2138
+ connection: context.connection,
2139
+ sessionId: context.sessionId,
2140
+ signal: context.signal,
2141
+ allowedOrigins,
2142
+ operation: context.operation
2143
+ });
2144
+ const completedUrl = mainFrameUrl(completedFrameResult) ?? "";
2145
+ if (state.events.originViolation) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
2146
+ if (state.events.navigationDuringCapture || completedUrl !== attachedUrl) throw new BrowserObservationError("inspect_web_page", "target_changed");
2147
+ state.events.settleUnexaminedResponseBodies();
2148
+ state.events.recordScriptMetadataBudgetExclusions();
2149
+ return {
2150
+ inspection: normalizedInspection(state, {
2151
+ attachedUrl,
2152
+ frames,
2153
+ dom,
2154
+ accessibility,
2155
+ scripts: scripts.inventory,
2156
+ resources,
2157
+ workers,
2158
+ storage: storageCapture.value
2159
+ }),
2160
+ sourceMapRequests: scripts.sourceMapRequests
2161
+ };
2162
+ };
2163
+ captureJsonResponseBodies = async (state) => {
2164
+ const requests = state.events.responseBodyRequests();
2165
+ for (let index = 0; index < requests.length; index += 1) {
2166
+ const candidate = requests[index];
2167
+ if (candidate === undefined) continue;
2168
+ const current = state.events.currentResponseBodyRequest(candidate);
2169
+ if (current === undefined) continue;
2170
+ if (current.encoded_data_length === null) {
2171
+ state.events.responseBodyUnavailable(candidate);
2172
+ continue;
2173
+ }
2174
+ let result;
2175
+ try {
2176
+ result = await optionalCdpCommand(state.context, "Network.getResponseBody", { requestId: candidate.requestId }, state.limitations);
2177
+ } catch (cause) {
2178
+ if (!(cause instanceof CdpCommandRejection) || cause.command !== "Network.getResponseBody" || cause.code !== -32e3 || cause.reportedMessage === null) throw cause;
2179
+ state.events.responseBodyUnavailable(candidate);
2180
+ state.limitations.push(`Response body unavailable for request ${candidate.requestId}: ${cause.userMessage}`);
2181
+ continue;
2182
+ }
2183
+ if (result !== undefined) {
2184
+ state.events.ingestResponseBody(candidate, result);
2185
+ continue;
2186
+ }
2187
+ for (const remaining of requests.slice(index)) state.events.responseBodyUnavailable(remaining);
2188
+ return;
2189
+ }
2190
+ };
2191
+ authorizeObservationWindow = async (state) => {
2192
+ const { context, allowedOrigins, events } = state;
2193
+ const { connection, sessionId, signal } = context;
2194
+ await report(context.progress, 1, "Enabling passive CDP domains");
2195
+ await connection.send("Page.enable", {}, sessionId, signal);
2196
+ const initialFrameResult = await authorizedMainFrame({
2197
+ connection: context.connection,
2198
+ sessionId: context.sessionId,
2199
+ signal: context.signal,
2200
+ allowedOrigins,
2201
+ operation: context.operation
2202
+ });
2203
+ const mainFrame = captureFrames(initialFrameResult, allowedOrigins).items[0];
2204
+ if (mainFrame === undefined) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
2205
+ events.beginAuthorizedFrame(mainFrame.frame_id);
2206
+ await enableObservationDomains(connection, sessionId, signal);
2207
+ await report(context.progress, 2, "Observing page events");
2208
+ await delayWithCancellation(context.input.observation_ms, context.operation, signal);
2209
+ if (events.originViolation) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
2210
+ };
2211
+ capturePageDom = async (state) => {
2212
+ const { context, allowedOrigins } = state;
2213
+ const result = await context.connection.send("DOMSnapshot.captureSnapshot", {
2214
+ computedStyles: [],
2215
+ includePaintOrder: false,
2216
+ includeDOMRects: false
2217
+ }, context.sessionId, context.signal);
2218
+ const capture = captureDom(result, allowedOrigins, context.input, state.events.completeness);
2219
+ let step = capture.next();
2220
+ let descriptionUnavailable = false;
2221
+ const pendingController = new AbortController();
2222
+ const signal = context.signal === undefined ? pendingController.signal : AbortSignal.any([context.signal, pendingController.signal]);
2223
+ while (!step.done) {
2224
+ const pending = step.value.map(async (query) => {
2225
+ if (descriptionUnavailable) return undefined;
2226
+ try {
2227
+ return capturedSvgNodeKind(query, await context.connection.send("DOM.describeNode", {
2228
+ backendNodeId: query.backendNodeId,
2229
+ depth: 0
2230
+ }, context.sessionId, signal));
2231
+ } catch (cause) {
2232
+ if (!(cause instanceof CdpCommandRejection)) throw cause;
2233
+ if (cause.code === -32601) descriptionUnavailable = true;
2234
+ else if (cause.code !== -32e3) throw cause;
2235
+ return undefined;
2236
+ }
2237
+ });
2238
+ try {
2239
+ step = capture.next(await Promise.all(pending));
2240
+ } catch (cause) {
2241
+ pendingController.abort();
2242
+ await Promise.allSettled(pending);
2243
+ throw cause;
2244
+ }
2245
+ }
2246
+ if (step.value.unresolvedSvgNodes > 0) state.limitations.push(`SVG identity was unavailable for ${String(step.value.unresolvedSvgNodes)} snapshotted XLink candidate nodes; their URL destinations remain unknown.`);
2247
+ return step.value;
2248
+ };
2249
+ normalizedInspection = (state, captured) => ({
2250
+ browser: state.context.discovery.version,
2251
+ target: normalizedTarget(state.context.target, captured.attachedUrl, state.allowedOrigins),
2252
+ capture_window: {
2253
+ started_at: state.startedAt,
2254
+ ended_at: new Date().toISOString(),
2255
+ observation_ms: state.context.input.observation_ms
2256
+ },
2257
+ completeness: state.events.completeness.snapshot(),
2258
+ frames: [...captured.frames],
2259
+ dom: {
2260
+ total_nodes: captured.dom.total,
2261
+ nodes: [...captured.dom.nodes]
2262
+ },
2263
+ accessibility: {
2264
+ total_nodes: captured.accessibility.total,
2265
+ text_capture: captured.accessibility.textCapture,
2266
+ nodes: [...captured.accessibility.nodes]
2267
+ },
2268
+ scripts: captured.scripts,
2269
+ resources: [...captured.resources],
2270
+ network: {
2271
+ requests: [...state.events.network.values()],
2272
+ websocket_connections: [...state.events.webSocketConnectionsById.values()],
2273
+ coverage_started_at: state.startedAt,
2274
+ prior_activity_available: false
2275
+ },
2276
+ console: {
2277
+ events: [...state.events.console],
2278
+ coverage_started_at: state.startedAt,
2279
+ prior_activity_available: false
2280
+ },
2281
+ workers: [...captured.workers],
2282
+ metadata: {
2283
+ responses: [...state.events.responseMetadata],
2284
+ dom_urls: [...captured.dom.urls],
2285
+ agent_hints: deduplicatedAgentHints([...state.events.agentHints, ...captured.dom.agentHints]),
2286
+ excluded_dom_urls: captured.dom.excludedUrls,
2287
+ headers_allowlisted: true
2288
+ },
2289
+ storage: captured.storage,
2290
+ limitations: state.limitations
2291
+ });
2292
+ enableObservationDomains = async (connection, sessionId, signal) => {
2293
+ await connection.send("Runtime.enable", {}, sessionId, signal);
2294
+ await connection.send("Debugger.enable", {}, sessionId, signal);
2295
+ await connection.send("Network.enable", {}, sessionId, signal);
2296
+ };
2297
+ accessibilityForFrames = async (state, frames) => {
2298
+ const { context, limitations, events } = state;
2299
+ const results = [];
2300
+ let unavailable = false;
2301
+ for (const frame of frames) {
2302
+ const result = await optionalCdpCommand(context, "Accessibility.getFullAXTree", { frameId: frame.frame_id }, limitations);
2303
+ if (result === undefined) unavailable = true;
2304
+ else results.push(result);
2305
+ }
2306
+ if (unavailable) events.completeness.unavailable("accessibility");
2307
+ const capture = captureAccessibility(results, {
2308
+ includeText: context.input.include_accessibility_text,
2309
+ ...results.length === 0 && unavailable ? { unavailable: true } : {}
2310
+ });
2311
+ if (!context.input.include_accessibility_text) events.completeness.exclude("accessibility", "not_approved", capture.textCapture.excluded_fields);
2312
+ if (capture.treeIncomplete) events.completeness.truncate("accessibility");
2313
+ return capture;
2314
+ };
2315
+ publicResource = ({ rawUrl: _rawUrl, ...resource }) => resource;
2316
+ deduplicatedAgentHints = (hints) => {
2317
+ const seen = new Set();
2318
+ return hints.filter((hint) => {
2319
+ const key = `${hint.mechanism}\0${hint.declaration}\0${hint.url ?? ""}`;
2320
+ if (seen.has(key)) return false;
2321
+ seen.add(key);
2322
+ return true;
2323
+ });
2324
+ };
2325
+ normalizedTarget = (target, currentUrl, allowedOrigins) => {
2326
+ const url = allowedSanitizedUrl(currentUrl, allowedOrigins);
2327
+ return {
2328
+ target_id: target.id,
2329
+ type: target.type,
2330
+ title: target.title,
2331
+ url: url?.url ?? "[unsupported-url]",
2332
+ origin: url?.origin ?? "",
2333
+ attached: target.attached
2334
+ };
2335
+ };
2336
+ report = async (progress, completed, message) => await progress?.report({
2337
+ phase: "browser_observation",
2338
+ completed,
2339
+ total: 3,
2340
+ message,
2341
+ ...completed === 3 ? { terminal: true } : {}
2342
+ });
2343
+ })))();
2344
+ }
2345
+
2346
+ //#endregion
2347
+ //#region dist/javascript/sourceMaps/SourceMapFormat.js
2348
+ var leafSchema, mapHeaderSchema, sectionSchema, indexedSchema, SourceMapFormatFailure, codecLeaf, compare, addOffset, consumeRecords, addSections, inspectMappingLayout, inspectLeaf, inspectSourceMap, inspectSourceMapValue;
2349
+ function init_SourceMapFormat() {
2350
+ return (init_SourceMapFormat = __esmMin((() => {
2351
+ init_webSourceLocation();
2352
+ init_sourceMapEnvelope();
2353
+ leafSchema = z.object({
2354
+ version: z.literal(3),
2355
+ file: z.string().nullable().optional(),
2356
+ sourceRoot: z.string().nullable().optional(),
2357
+ sources: z.array(z.string().nullable()),
2358
+ sourcesContent: z.array(z.string().nullable()).nullable().optional(),
2359
+ names: z.array(z.string()).default([]),
2360
+ mappings: z.string().regex(/^[A-Za-z0-9+/,;]*$/u),
2361
+ ignoreList: z.array(z.number().int().min(0)).optional(),
2362
+ x_google_ignoreList: z.array(z.number().int().min(0)).optional()
2363
+ });
2364
+ mapHeaderSchema = z.object({
2365
+ version: z.literal(3),
2366
+ file: z.string().nullable().optional(),
2367
+ sections: z.unknown().optional()
2368
+ });
2369
+ sectionSchema = z.object({
2370
+ offset: z.object({
2371
+ line: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
2372
+ column: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)
2373
+ }),
2374
+ map: z.unknown().optional(),
2375
+ url: z.string().optional()
2376
+ });
2377
+ indexedSchema = z.object({
2378
+ version: z.literal(3),
2379
+ sections: z.array(sectionSchema)
2380
+ });
2381
+ SourceMapFormatFailure = class extends Error {
2382
+ reason;
2383
+ constructor(reason, message) {
2384
+ super(message);
2385
+ this.reason = reason;
2386
+ }
2387
+ };
2388
+ codecLeaf = (map) => ({
2389
+ version: 3,
2390
+ ...map.file === undefined ? {} : { file: map.file },
2391
+ ...typeof map.sourceRoot === "string" ? { sourceRoot: map.sourceRoot } : {},
2392
+ sources: map.sources,
2393
+ ...map.sourcesContent == null ? {} : { sourcesContent: map.sourcesContent },
2394
+ names: map.names,
2395
+ mappings: map.mappings,
2396
+ ...map.ignoreList === undefined ? {} : { ignoreList: map.ignoreList },
2397
+ ...map.x_google_ignoreList === undefined ? {} : { x_google_ignoreList: map.x_google_ignoreList }
2398
+ });
2399
+ compare = (a, b) => a.line - b.line || a.column - b.column;
2400
+ addOffset = (base, offset) => {
2401
+ const result = {
2402
+ line: base.line + offset.line,
2403
+ column: offset.column + (offset.line === 0 ? base.column : 0)
2404
+ };
2405
+ if (!Number.isSafeInteger(result.line) || !Number.isSafeInteger(result.column) || result.line >= WEB_SOURCE_MAP_LIMITS.decodedRows) throw new SourceMapFormatFailure("limit", "Indexed offset exceeds the 262144 generated-row decoder budget.");
2406
+ return result;
2407
+ };
2408
+ consumeRecords = (budget, count) => {
2409
+ if (count > WEB_SOURCE_MAP_LIMITS.decodedRecords - budget.records) throw new SourceMapFormatFailure("limit", `Source-map structure exceeds the ${WEB_SOURCE_MAP_LIMITS.decodedRecords}-record decoder budget.`);
2410
+ budget.records += count;
2411
+ };
2412
+ addSections = (node, pending, budget, options) => {
2413
+ options.check?.();
2414
+ const header = mapHeaderSchema.parse(node.value);
2415
+ if (!Array.isArray(header.sections)) throw new SourceMapFormatFailure("format", "Indexed source-map sections must be an array.");
2416
+ consumeRecords(budget, header.sections.length);
2417
+ const sections = indexedSchema.parse(node.value).sections;
2418
+ for (const [index, section] of sections.entries()) {
2419
+ if ((index & 255) === 0) options.check?.();
2420
+ const previous = sections[index - 1];
2421
+ if (previous !== undefined && compare(section.offset, previous.offset) <= 0) throw new SourceMapFormatFailure("format", "Indexed section offsets must be strictly increasing.");
2422
+ if (section.url !== undefined) throw new SourceMapFormatFailure("unsupported", `External source-map section URL is not fetched: ${section.url}`);
2423
+ if (section.map === undefined) throw new SourceMapFormatFailure("format", "Indexed section requires an embedded map.");
2424
+ }
2425
+ for (let index = sections.length - 1; index >= 0; index -= 1) {
2426
+ const section = sections[index];
2427
+ if (section === undefined) continue;
2428
+ const next = sections[index + 1];
2429
+ const nextOffset = next === undefined ? null : addOffset(node.offset, next.offset);
2430
+ const stop = nextOffset === null ? node.stop : node.stop === null || compare(nextOffset, node.stop) < 0 ? nextOffset : node.stop;
2431
+ const offset = addOffset(node.offset, section.offset);
2432
+ if (node.stop !== null && compare(offset, node.stop) >= 0) throw new SourceMapFormatFailure("format", "Nested source-map section overlaps its enclosing boundary.");
2433
+ pending.push({
2434
+ value: section.map,
2435
+ path: [...node.path, index],
2436
+ offset,
2437
+ stop
2438
+ });
2439
+ }
2440
+ };
2441
+ inspectMappingLayout = (mappings, check) => {
2442
+ let lines = 1;
2443
+ let segments = 0;
2444
+ let components = 0;
2445
+ let inSegment = false;
2446
+ let continued = false;
2447
+ let digits = 0;
2448
+ const finish = () => {
2449
+ if (continued) throw new SourceMapFormatFailure("format", "Source-map VLQ ends with an unfinished continuation.");
2450
+ if (inSegment && ![
2451
+ 1,
2452
+ 4,
2453
+ 5
2454
+ ].includes(components)) throw new SourceMapFormatFailure("format", "Source-map segment requires one, four or five VLQ components.");
2455
+ };
2456
+ let index = 0;
2457
+ for (const character of mappings) {
2458
+ if ((index++ & 16383) === 0) check?.();
2459
+ if (character === "," || character === ";") {
2460
+ finish();
2461
+ inSegment = false;
2462
+ components = 0;
2463
+ if (character === ";") lines += 1;
2464
+ } else {
2465
+ digits += 1;
2466
+ if (digits === 7 && !/[A-Dg-j]/u.test(character) || digits > 7 && character !== "A" && character !== "g") throw new SourceMapFormatFailure("format", "Source-map VLQ exceeds the format's 32-bit quantity representation.");
2467
+ if (!inSegment) segments += 1;
2468
+ inSegment = true;
2469
+ continued = /[g-z0-9+/]/u.test(character);
2470
+ if (!continued) {
2471
+ components += 1;
2472
+ digits = 0;
2473
+ }
2474
+ }
2475
+ if (segments > WEB_SOURCE_MAP_LIMITS.decodedSegments || lines > WEB_SOURCE_MAP_LIMITS.decodedRows) throw new SourceMapFormatFailure("limit", "Source-map layout exceeds the 262144 segment/generated-row decoder budget.");
2476
+ }
2477
+ finish();
2478
+ return {
2479
+ lines,
2480
+ segments
2481
+ };
2482
+ };
2483
+ inspectLeaf = (node, budget, options) => {
2484
+ options.check?.();
2485
+ consumeRecords(budget, 1);
2486
+ if (typeof node.value !== "object" || node.value === null || Array.isArray(node.value)) return leafSchema.parse(node.value);
2487
+ const rawMap = node.value;
2488
+ const rawSources = rawMap.sources;
2489
+ const rawNames = rawMap.names;
2490
+ const rawContents = rawMap.sourcesContent;
2491
+ consumeRecords(budget, Array.isArray(rawSources) ? rawSources.length : 0);
2492
+ consumeRecords(budget, Array.isArray(rawNames) ? rawNames.length : 0);
2493
+ consumeRecords(budget, Array.isArray(rawContents) ? rawContents.length : 0);
2494
+ options.check?.();
2495
+ const leaf = leafSchema.parse(node.value);
2496
+ const layout = inspectMappingLayout(leaf.mappings, options.check);
2497
+ consumeRecords(budget, layout.segments + layout.lines);
2498
+ if (layout.segments > WEB_SOURCE_MAP_LIMITS.decodedSegments || node.offset.line + layout.lines > WEB_SOURCE_MAP_LIMITS.decodedRows) throw new SourceMapFormatFailure("limit", "Source-map layout exceeds the 262144 segment/generated-row decoder budget.");
2499
+ return leaf;
2500
+ };
2501
+ inspectSourceMap = (text) => {
2502
+ const jsonText = sourceMapJsonText(text);
2503
+ const value = JSON.parse(jsonText);
2504
+ return inspectSourceMapValue(value);
2505
+ };
2506
+ inspectSourceMapValue = (value, options = {}) => {
2507
+ options.check?.();
2508
+ const root = mapHeaderSchema.parse(value);
2509
+ const declarations = [];
2510
+ const leaves = [];
2511
+ const pending = [{
2512
+ value,
2513
+ path: [],
2514
+ offset: {
2515
+ line: 0,
2516
+ column: 0
2517
+ },
2518
+ stop: null
2519
+ }];
2520
+ const budget = options.budget ?? { records: 0 };
2521
+ while (pending.length > 0) {
2522
+ options.check?.();
2523
+ const node = pending.pop();
2524
+ if (node === undefined) break;
2525
+ if (node.path.length > WEB_SOURCE_MAP_LIMITS.sectionDepth) throw new SourceMapFormatFailure("limit", "Indexed source-map nesting exceeds the 64-level decoder stack budget.");
2526
+ if (mapHeaderSchema.parse(node.value).sections !== undefined) {
2527
+ addSections(node, pending, budget, options);
2528
+ continue;
2529
+ }
2530
+ const leaf = inspectLeaf(node, budget, options);
2531
+ leaves.push({
2532
+ map: leaf,
2533
+ codecMap: codecLeaf(leaf),
2534
+ offset: node.offset,
2535
+ stop: node.stop
2536
+ });
2537
+ if (options.profile !== "browser-collection") {
2538
+ const ignoredSources = new Set(leaf.ignoreList ?? leaf.x_google_ignoreList ?? []);
2539
+ for (const [sourceIndex, source] of leaf.sources.entries()) declarations.push({
2540
+ sectionPath: node.path,
2541
+ sourceIndex,
2542
+ source,
2543
+ root: leaf.sourceRoot ?? null,
2544
+ content: leaf.sourcesContent?.[sourceIndex] ?? null,
2545
+ ignored: ignoredSources.has(sourceIndex)
2546
+ });
2547
+ }
2548
+ }
2549
+ return {
2550
+ format: root.sections === undefined ? "regular" : "indexed",
2551
+ reportedFile: root.file ?? null,
2552
+ declarations,
2553
+ leaves
2554
+ };
2555
+ };
2556
+ })))();
2557
+ }
2558
+
2559
+ //#endregion
2560
+ //#region dist/javascript/sourceMaps/DecodedSourceMap.js
2561
+ var isBeforeSourceMapLeafStop, decodeValidatedSourceMapLeaves;
2562
+ function init_DecodedSourceMap() {
2563
+ return (init_DecodedSourceMap = __esmMin((() => {
2564
+ init_SourceMapFormat();
2565
+ isBeforeSourceMapLeafStop = (leaf, line, column) => {
2566
+ if (leaf.stop === null) return true;
2567
+ const generatedLine = leaf.offset.line + line;
2568
+ const generatedColumn = column + (line === 0 ? leaf.offset.column : 0);
2569
+ return generatedLine < leaf.stop.line || generatedLine === leaf.stop.line && generatedColumn < leaf.stop.column;
2570
+ };
2571
+ decodeValidatedSourceMapLeaves = (leaves, mapUrl, check) => leaves.map((leaf) => {
2572
+ check?.();
2573
+ const map = new TraceMap(leaf.codecMap, mapUrl);
2574
+ const rows = decodedMappings(map);
2575
+ for (const [line, row] of rows.entries()) {
2576
+ if ((line & 255) === 0) check?.();
2577
+ for (const segment of row) {
2578
+ const generatedLine = leaf.offset.line + line;
2579
+ const generatedColumn = segment[0] + (line === 0 ? leaf.offset.column : 0);
2580
+ if (!Number.isSafeInteger(generatedLine) || !Number.isSafeInteger(generatedColumn) || ![
2581
+ 1,
2582
+ 4,
2583
+ 5
2584
+ ].includes(segment.length) || segment.some((value) => !Number.isSafeInteger(value) || value < 0) || segment.length !== 1 && segment[1] >= leaf.map.sources.length || segment.length === 5 && segment[4] >= leaf.map.names.length) throw new SourceMapFormatFailure("format", "Decoded local or absolute position, source index or name index is invalid.");
2585
+ }
2586
+ }
2587
+ return {
2588
+ leaf,
2589
+ map,
2590
+ rows,
2591
+ resolvedSources: map.resolvedSources
2592
+ };
2593
+ });
2594
+ })))();
2595
+ }
2596
+
2597
+ //#endregion
2598
+ //#region dist/browser/WebSourceMapFetcher.js
2599
+ var SOURCE_MAP_FETCH_TIMEOUT_MS, SOURCE_MAP_RESPONSE_BYTES, SOURCE_MAP_OUTPUT_BYTES, SOURCE_MAP_FAILURE_LIMITATION_RESERVE, SOURCE_MAP_COLLECTION_ENVELOPE_RESERVE, fetchWebSourceMaps, sourceMapOutputLimitation, sourceMapsStatus, SourceMapDeadlineError, SourceMapSizeLimitError, SourceMapEncodingError, SourceMapRedirectLocationError, fetchOne, isFetchRedirectStatus, fetchFollowingApprovedRedirects, readBoundedText, readWithAbort, signalIsAborted, promiseWithAbort, normalizeSourceMap, originalModuleEdges, sourceParserPath, checkOperation, approvedUrl, sourceMapContext, emptySourceMapItem, sanitizeSource, preflightResolvedSourceBytes, consumeExpandedBytes, expandedOutputFailure, sourceMapOutputError, resolvedSourceLimitFailure, jsonBytes, artifactMetadataBytes, EMPTY_SOURCE_MAP_FAILURE, SOURCE_MAP_FAILURE_ENVELOPE_BYTES, SOURCE_MAP_SUCCESS_ENVELOPE_BYTES, sourceMapFailureReservation, sourceEntryOverheadBytes, cachedJsonBytes, cachedSanitized, mappingRowBytes, resolveOriginalSource, sourceMediaType, originalDependency;
2600
+ function init_WebSourceMapFetcher() {
2601
+ return (init_WebSourceMapFetcher = __esmMin((() => {
2602
+ init_DecodedSourceMap();
2603
+ init_browserObservation$1();
2604
+ init_analysisErrorCore();
2605
+ init_webBundleAnalyzerAst();
2606
+ init_javascriptSemanticAnalysis();
2607
+ init_javascriptSemanticTraversal();
2608
+ init_javascriptSourceParser();
2609
+ init_javascriptModuleDeclaration();
2610
+ init_javascriptStaticAnalysisHelpers();
2611
+ init_webBundleAnalysis();
2612
+ init_webContentArtifact();
2613
+ init_safeJson();
2614
+ init_sourceMapEnvelope();
2615
+ init_javascriptSourceMapPaths();
2616
+ init_jsonSerialization();
2617
+ init_SourceMapFormat();
2618
+ init_webSourceLocation();
2619
+ SOURCE_MAP_FETCH_TIMEOUT_MS = 3e4;
2620
+ SOURCE_MAP_RESPONSE_BYTES = 64 * 1024 * 1024;
2621
+ SOURCE_MAP_OUTPUT_BYTES = WEB_SOURCE_MAP_LIMITS.outputBytes;
2622
+ SOURCE_MAP_FAILURE_LIMITATION_RESERVE = 512;
2623
+ SOURCE_MAP_COLLECTION_ENVELOPE_RESERVE = 1024;
2624
+ fetchWebSourceMaps = async (requests, input, signal, host = { fetch: globalThis.fetch }) => {
2625
+ const items = [];
2626
+ const operationController = new AbortController();
2627
+ const timeout = setTimeout(() => operationController.abort(new SourceMapDeadlineError()), host.timeoutMs ?? SOURCE_MAP_FETCH_TIMEOUT_MS);
2628
+ const abortFromCaller = () => operationController.abort(signal?.reason);
2629
+ signal?.addEventListener("abort", abortFromCaller, { once: true });
2630
+ const operationSignal = operationController.signal;
2631
+ const deadlineAt = performance.now() + (host.timeoutMs ?? SOURCE_MAP_FETCH_TIMEOUT_MS);
2632
+ const budget = {
2633
+ retainedBytes: 0,
2634
+ deadlineAt,
2635
+ decodedRecords: {
2636
+ records: 0,
2637
+ expandedBytes: SOURCE_MAP_COLLECTION_ENVELOPE_RESERVE,
2638
+ resolvedSourceBytes: 0
2639
+ }
2640
+ };
2641
+ let limitation;
2642
+ try {
2643
+ for (const request of requests) {
2644
+ if (signal?.aborted === true) throw signal.reason;
2645
+ const reservation = sourceMapFailureReservation(request) + 1;
2646
+ if (reservation > SOURCE_MAP_OUTPUT_BYTES - budget.decodedRecords.expandedBytes) {
2647
+ limitation = sourceMapOutputLimitation(requests.length - items.length);
2648
+ break;
2649
+ }
2650
+ const expandedBytesBeforeItem = budget.decodedRecords.expandedBytes;
2651
+ budget.decodedRecords.expandedBytes += reservation;
2652
+ if (operationSignal.aborted || performance.now() >= deadlineAt) {
2653
+ items.push(emptySourceMapItem(request, "fetch_failed", "Source-map fetching exceeded its operation deadline."));
2654
+ continue;
2655
+ }
2656
+ const item = await fetchOne(request, input, operationSignal, host, budget);
2657
+ if (item.artifact === null) {
2658
+ const failureBytes = sourceMapFailureReservation(request, item.effective_url ?? null, item.limitation, item.status) + 1;
2659
+ if (failureBytes > SOURCE_MAP_OUTPUT_BYTES - expandedBytesBeforeItem) {
2660
+ limitation = sourceMapOutputLimitation(requests.length - items.length);
2661
+ break;
2662
+ }
2663
+ budget.decodedRecords.expandedBytes = expandedBytesBeforeItem + failureBytes;
2664
+ }
2665
+ items.push(item);
2666
+ }
2667
+ } catch (cause) {
2668
+ if (signal?.aborted === true) throw cause;
2669
+ if (cause instanceof SourceMapFormatFailure && cause.reason === "limit") limitation = sourceMapOutputLimitation(requests.length - items.length);
2670
+ else throw cause;
2671
+ } finally {
2672
+ clearTimeout(timeout);
2673
+ signal?.removeEventListener("abort", abortFromCaller);
2674
+ }
2675
+ if (signal?.aborted === true) throw signal.reason;
2676
+ return webSourceMapsSchema.parse({
2677
+ status: sourceMapsStatus(items, limitation !== undefined),
2678
+ requested: requests.length,
2679
+ processed: items.length,
2680
+ items,
2681
+ ...limitation === undefined ? {} : { limitation }
2682
+ });
2683
+ };
2684
+ sourceMapOutputLimitation = (unprocessed) => `source-map output budget could not retain results for ${String(unprocessed)} requested map${unprocessed === 1 ? "" : "s"}. their results are unknown.`;
2685
+ sourceMapsStatus = (items, omitted) => {
2686
+ const retained = items.filter(({ status }) => status === "included" || status === "partial").length;
2687
+ if (items.length === 0 || retained === 0) return "unavailable";
2688
+ if (omitted) return "partial";
2689
+ return retained === items.length && !items.some(({ status }) => status === "partial") ? "included" : "partial";
2690
+ };
2691
+ SourceMapDeadlineError = class extends Error {
2692
+ constructor() {
2693
+ super("Source-map fetching exceeded its operation deadline.");
2694
+ this.name = "SourceMapDeadlineError";
2695
+ }
2696
+ };
2697
+ SourceMapSizeLimitError = class extends Error {
2698
+ constructor() {
2699
+ super("Source-map response exceeded the retained-byte budget.");
2700
+ this.name = "SourceMapSizeLimitError";
2701
+ }
2702
+ };
2703
+ SourceMapEncodingError = class extends Error {
2704
+ constructor() {
2705
+ super("Source-map response is not valid UTF-8.");
2706
+ this.name = "SourceMapEncodingError";
2707
+ }
2708
+ };
2709
+ SourceMapRedirectLocationError = class extends Error {
2710
+ constructor(url, location) {
2711
+ super(`Source-map redirect from ${JSON.stringify(url)} supplied an invalid Location URL: ${JSON.stringify(location)}.`);
2712
+ this.name = "SourceMapRedirectLocationError";
2713
+ }
2714
+ };
2715
+ fetchOne = async (request, input, signal, host, budget) => {
2716
+ if (!approvedUrl(request.fetchUrl, input.allowed_origins)) return emptySourceMapItem(request, "policy_filtered", "Declared source-map URL is outside the approved exact origins.");
2717
+ let effectiveUrl = null;
2718
+ try {
2719
+ const fetched = await fetchFollowingApprovedRedirects(request.fetchUrl, input.allowed_origins, signal, host, (url) => {
2720
+ effectiveUrl = url;
2721
+ });
2722
+ if (fetched === undefined) return emptySourceMapItem(request, "policy_filtered", "A source-map redirect left the approved exact origins.", effectiveUrl);
2723
+ const { response, fetchedUrl } = fetched;
2724
+ try {
2725
+ consumeExpandedBytes(budget.decodedRecords, jsonBytes(fetchedUrl) - 4);
2726
+ } catch (cause) {
2727
+ try {
2728
+ await response.body?.cancel();
2729
+ } catch (cleanupCause) {
2730
+ if (cause instanceof SourceMapFormatFailure && cause.reason === "limit") throw sourceMapOutputError(cause, {
2731
+ cause: new AggregateError([cause, cleanupCause], "Source-map response cleanup failed after its output exceeded capacity."),
2732
+ cleanup: {
2733
+ reason: "Source-map response cancellation failed after its output exceeded capacity.",
2734
+ resources: ["source-map-response"]
2735
+ }
2736
+ });
2737
+ throw cause;
2738
+ }
2739
+ throw cause;
2740
+ }
2741
+ if (!response.ok) {
2742
+ await response.body?.cancel();
2743
+ return emptySourceMapItem(request, "fetch_failed", `Source-map server returned HTTP ${String(response.status)}.`, fetchedUrl);
2744
+ }
2745
+ checkOperation(undefined, signal, budget.deadlineAt);
2746
+ return normalizeSourceMap(request, await readBoundedText(response, budget, host.maxResponseBytes ?? SOURCE_MAP_RESPONSE_BYTES, signal), fetchedUrl, {
2747
+ signal,
2748
+ deadlineAt: budget.deadlineAt,
2749
+ budget: budget.decodedRecords
2750
+ });
2751
+ } catch (cause) {
2752
+ if (cause instanceof AnalysisResourceConstraintError) throw cause;
2753
+ if (cause instanceof SourceMapFormatFailure && cause.reason === "limit") throw cause;
2754
+ if (signal?.aborted === true && !(signal.reason instanceof SourceMapDeadlineError)) throw cause;
2755
+ if (cause instanceof SourceMapEncodingError) return emptySourceMapItem(request, "invalid", cause.message, effectiveUrl);
2756
+ return emptySourceMapItem(request, "fetch_failed", cause instanceof SourceMapRedirectLocationError || cause instanceof SourceMapSizeLimitError || cause instanceof SourceMapDeadlineError ? cause.message : "Source-map fetch or validation failed.", effectiveUrl);
2757
+ }
2758
+ };
2759
+ isFetchRedirectStatus = (status) => status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
2760
+ fetchFollowingApprovedRedirects = async (initialUrl, allowedOrigins, signal, host, observeResponse) => {
2761
+ let current = initialUrl;
2762
+ const visited = new Set();
2763
+ for (;;) {
2764
+ if (signal?.aborted === true) throw signal.reason;
2765
+ if (!approvedUrl(current, allowedOrigins)) return undefined;
2766
+ if (visited.has(current)) throw new Error("source_map_redirect_loop");
2767
+ visited.add(current);
2768
+ const response = await promiseWithAbort(host.fetch(current, {
2769
+ method: "GET",
2770
+ headers: { Accept: "application/json, application/source-map+json;q=0.9" },
2771
+ redirect: "manual",
2772
+ credentials: "omit",
2773
+ referrerPolicy: "no-referrer",
2774
+ ...signal === undefined ? {} : { signal }
2775
+ }), signal);
2776
+ observeResponse(current);
2777
+ if (signal !== undefined && signalIsAborted(signal)) {
2778
+ await response.body?.cancel(signal.reason).catch(() => undefined);
2779
+ throw signal.reason;
2780
+ }
2781
+ if (!isFetchRedirectStatus(response.status)) return {
2782
+ response,
2783
+ fetchedUrl: current
2784
+ };
2785
+ const location = response.headers.get("location");
2786
+ if (location === null) return {
2787
+ response,
2788
+ fetchedUrl: current
2789
+ };
2790
+ await response.body?.cancel();
2791
+ try {
2792
+ current = new URL(location, current).href;
2793
+ } catch {
2794
+ throw new SourceMapRedirectLocationError(current, location);
2795
+ }
2796
+ }
2797
+ };
2798
+ readBoundedText = async (response, budget, maxBytes, signal) => {
2799
+ if (response.body === null) return "";
2800
+ const reader = response.body.getReader();
2801
+ const chunks = [];
2802
+ let bytes = 0;
2803
+ try {
2804
+ for (;;) {
2805
+ if (signal?.aborted === true) throw signal.reason;
2806
+ const { done, value } = await readWithAbort(reader, signal);
2807
+ if (done) break;
2808
+ const nextBytes = value?.byteLength ?? 0;
2809
+ if (budget.retainedBytes + bytes + nextBytes > maxBytes) {
2810
+ await reader.cancel(new SourceMapSizeLimitError());
2811
+ throw new SourceMapSizeLimitError();
2812
+ }
2813
+ if (value !== undefined) chunks.push(value);
2814
+ bytes += nextBytes;
2815
+ }
2816
+ } finally {
2817
+ if (signal?.aborted !== true) reader.releaseLock();
2818
+ }
2819
+ budget.retainedBytes += bytes;
2820
+ const joined = new Uint8Array(bytes);
2821
+ let offset = 0;
2822
+ for (const chunk of chunks) {
2823
+ joined.set(chunk, offset);
2824
+ offset += chunk.byteLength;
2825
+ }
2826
+ try {
2827
+ return new TextDecoder("utf-8", {
2828
+ fatal: true,
2829
+ ignoreBOM: true
2830
+ }).decode(joined);
2831
+ } catch {
2832
+ throw new SourceMapEncodingError();
2833
+ }
2834
+ };
2835
+ readWithAbort = (reader, signal) => {
2836
+ if (signal === undefined) return reader.read();
2837
+ if (signal.aborted) return Promise.reject(signal.reason);
2838
+ return new Promise((resolve, reject) => {
2839
+ let settled = false;
2840
+ const cleanup = () => signal.removeEventListener("abort", abort);
2841
+ const abort = () => {
2842
+ if (settled) return;
2843
+ settled = true;
2844
+ cleanup();
2845
+ void reader.cancel(signal.reason).catch(() => undefined);
2846
+ reject(signal.reason);
2847
+ };
2848
+ signal.addEventListener("abort", abort, { once: true });
2849
+ void reader.read().then((value) => {
2850
+ if (settled) return;
2851
+ settled = true;
2852
+ cleanup();
2853
+ resolve(value);
2854
+ }, (cause) => {
2855
+ if (settled) return;
2856
+ settled = true;
2857
+ cleanup();
2858
+ void reader.cancel(cause).catch(() => undefined);
2859
+ reject(cause);
2860
+ });
2861
+ });
2862
+ };
2863
+ signalIsAborted = (signal) => signal?.aborted === true;
2864
+ promiseWithAbort = (promise, signal) => {
2865
+ if (signal === undefined) return promise;
2866
+ if (signal.aborted) return Promise.reject(signal.reason);
2867
+ return new Promise((resolve, reject) => {
2868
+ let settled = false;
2869
+ const cleanup = () => signal.removeEventListener("abort", abort);
2870
+ const abort = () => {
2871
+ if (settled) return;
2872
+ settled = true;
2873
+ cleanup();
2874
+ reject(signal.reason);
2875
+ };
2876
+ signal.addEventListener("abort", abort, { once: true });
2877
+ void promise.then((response) => {
2878
+ if (settled || signal.aborted) {
2879
+ void response.body?.cancel(signal.reason).catch(() => undefined);
2880
+ if (!settled) {
2881
+ settled = true;
2882
+ cleanup();
2883
+ reject(signal.reason);
2884
+ }
2885
+ return;
2886
+ }
2887
+ settled = true;
2888
+ cleanup();
2889
+ resolve(response);
2890
+ }, (cause) => {
2891
+ if (settled) return;
2892
+ settled = true;
2893
+ cleanup();
2894
+ reject(cause);
2895
+ });
2896
+ });
2897
+ };
2898
+ normalizeSourceMap = (request, text, fetchedUrl, context) => {
2899
+ const parsedJson = safeParseJson(sourceMapJsonText(text));
2900
+ if (!parsedJson.ok) return emptySourceMapItem(request, "invalid", "Source-map JSON is not a version 3 map.", fetchedUrl);
2901
+ const retainedBytesBeforeMap = context.budget.expandedBytes;
2902
+ try {
2903
+ const check = () => checkOperation(undefined, context.signal, context.deadlineAt);
2904
+ const inspected = inspectSourceMapValue(parsedJson.value, {
2905
+ profile: "browser-collection",
2906
+ budget: context.budget,
2907
+ check
2908
+ });
2909
+ context.budget.expandedBytes = retainedBytesBeforeMap - SOURCE_MAP_FAILURE_ENVELOPE_BYTES + SOURCE_MAP_SUCCESS_ENVELOPE_BYTES;
2910
+ consumeExpandedBytes(context.budget, jsonBytes(text) + artifactMetadataBytes("application/source-map+json", text) - 4);
2911
+ const sourcesByRaw = new Map();
2912
+ const resolvedByRoot = new Map();
2913
+ preflightResolvedSourceBytes(inspected.leaves, fetchedUrl, context.budget, resolvedByRoot, sourcesByRaw, check);
2914
+ check();
2915
+ const decoded = decodeValidatedSourceMapLeaves(inspected.leaves, fetchedUrl, check);
2916
+ const sourceJsonBytes = new Map();
2917
+ const nameJsonBytes = new Map();
2918
+ const originalSources = [];
2919
+ let declarationIndex = 0;
2920
+ for (const { leaf, resolvedSources } of decoded) {
2921
+ for (const [index, rawSource] of leaf.map.sources.entries()) {
2922
+ if ((index & 255) === 0) check();
2923
+ const resolved = rawSource === null ? null : resolvedSources[index] ?? null;
2924
+ const sanitized = resolved === null ? null : cachedSanitized(sourcesByRaw, resolved);
2925
+ const content = leaf.map.sourcesContent?.[index] ?? null;
2926
+ consumeExpandedBytes(context.budget, (sanitized === null ? 4 : cachedJsonBytes(sourceJsonBytes, sanitized)) + sourceEntryOverheadBytes(index, declarationIndex) + (originalSources.length === 0 ? 0 : 1) + (content === null ? 0 : jsonBytes(content) + artifactMetadataBytes(sourceMediaType(rawSource), content) - 4));
2927
+ originalSources.push({
2928
+ source_index: index,
2929
+ declaration_index: declarationIndex++,
2930
+ source: sanitized,
2931
+ artifact: content === null ? null : createWebTextArtifact(content, sourceMediaType(rawSource))
2932
+ });
2933
+ }
2934
+ }
2935
+ const mappings = [];
2936
+ declarationIndex = 0;
2937
+ for (const { leaf, rows, resolvedSources } of decoded) {
2938
+ const declarationBase = declarationIndex;
2939
+ declarationIndex += leaf.map.sources.length;
2940
+ for (const [line, row] of rows.entries()) {
2941
+ if ((line & 255) === 0) check();
2942
+ for (const segment of row) {
2943
+ if (!isBeforeSourceMapLeafStop(leaf, line, segment[0])) continue;
2944
+ if (segment.length === 1) continue;
2945
+ const rawSource = leaf.map.sources[segment[1]];
2946
+ if (rawSource === undefined) continue;
2947
+ const resolved = rawSource === null ? null : resolvedSources[segment[1]] ?? null;
2948
+ const source = resolved === null ? null : cachedSanitized(sourcesByRaw, resolved);
2949
+ const name = segment.length === 5 ? leaf.map.names[segment[4]] ?? null : null;
2950
+ const generatedLine = leaf.offset.line + line + 1;
2951
+ const generatedColumn = segment[0] + (line === 0 ? leaf.offset.column : 0);
2952
+ consumeExpandedBytes(context.budget, (source === null ? 4 : cachedJsonBytes(sourceJsonBytes, source)) + (name === null ? 4 : cachedJsonBytes(nameJsonBytes, name)) + mappingRowBytes(segment[1], declarationBase + segment[1], generatedLine, generatedColumn, segment[2] + 1, segment[3]) + (mappings.length === 0 ? 0 : 1));
2953
+ mappings.push({
2954
+ source_index: segment[1],
2955
+ declaration_index: declarationBase + segment[1],
2956
+ generated_line: generatedLine,
2957
+ generated_column: generatedColumn,
2958
+ source,
2959
+ original_line: segment[2] + 1,
2960
+ original_column: segment[3],
2961
+ name
2962
+ });
2963
+ }
2964
+ }
2965
+ }
2966
+ const modules = originalModuleEdges(originalSources, check, (edge) => consumeExpandedBytes(context.budget, Buffer.byteLength(JSON.stringify(edge)) + 1));
2967
+ check();
2968
+ if (modules.incomplete.length > 0) consumeExpandedBytes(context.budget, jsonBytes(`Module edges are incomplete: ${modules.incomplete.length} of ${originalSources.filter(({ artifact }) => artifact !== null).length} original sources could not be parsed in full (${modules.incomplete.join(", ")}).`) - 4);
2969
+ const parsed = {
2970
+ ...sourceMapContext(request, fetchedUrl),
2971
+ artifact: createWebTextArtifact(text, "application/source-map+json"),
2972
+ original_sources: originalSources,
2973
+ original_module_edges: modules.edges,
2974
+ mappings
2975
+ };
2976
+ check();
2977
+ return modules.incomplete.length === 0 ? {
2978
+ ...parsed,
2979
+ status: "included",
2980
+ limitation: null
2981
+ } : {
2982
+ ...parsed,
2983
+ status: "partial",
2984
+ limitation: `Module edges are incomplete: ${modules.incomplete.length} of ${originalSources.filter(({ artifact }) => artifact !== null).length} original sources could not be parsed in full (${modules.incomplete.join(", ")}).`
2985
+ };
2986
+ } catch (cause) {
2987
+ context.budget.expandedBytes = retainedBytesBeforeMap;
2988
+ if (cause instanceof SourceMapFormatFailure && cause.reason === "limit") return emptySourceMapItem(request, "fetch_failed", cause.message, fetchedUrl);
2989
+ if (context.signal?.aborted === true || cause instanceof SourceMapDeadlineError) throw cause;
2990
+ return emptySourceMapItem(request, "invalid", "Source-map JSON mappings could not be decoded safely.", fetchedUrl);
2991
+ }
2992
+ };
2993
+ originalModuleEdges = (sources, check, beforeEdge) => {
2994
+ const edges = [];
2995
+ const seen = new Set();
2996
+ const incomplete = [];
2997
+ for (const source of sources) {
2998
+ check();
2999
+ if (source.artifact === null) continue;
3000
+ const sourceName = source.source;
3001
+ if (sourceName === null) {
3002
+ incomplete.push(`unnamed source at declaration ${String(source.declaration_index)}`);
3003
+ continue;
3004
+ }
3005
+ const parsed = parseJavaScriptSource(source.artifact.text, sourceParserPath(sourceName));
3006
+ check();
3007
+ if (parsed === null) {
3008
+ incomplete.push(sourceName);
3009
+ continue;
3010
+ }
3011
+ if (parsed.errors.length > 0) incomplete.push(sourceName);
3012
+ let unboundRequires;
3013
+ traverseJavaScriptAst(parsed, { enter: (node) => {
3014
+ check();
3015
+ const dependency = originalDependency(node);
3016
+ if (dependency === null) return;
3017
+ const { kind, specifier, requireCallee } = dependency;
3018
+ if (requireCallee !== undefined) {
3019
+ unboundRequires ??= new Set(analyzeParsedJavaScriptReferences(parsed, "require").filter(({ role, resolution }) => role === "read" && resolution === "unbound").map(({ location }) => `${String(location.start.line)}:${String(location.start.column)}`));
3020
+ const location = requireCallee.loc?.start;
3021
+ if (location === undefined || !unboundRequires.has(`${String(location.line)}:${String(location.column)}`)) return;
3022
+ }
3023
+ const key = `${sourceName}\0${kind}\0${specifier}`;
3024
+ if (seen.has(key)) return;
3025
+ seen.add(key);
3026
+ const edge = {
3027
+ from_source: sourceName,
3028
+ kind,
3029
+ specifier,
3030
+ resolved_source: resolveOriginalSource(specifier, sourceName)
3031
+ };
3032
+ beforeEdge(edge);
3033
+ edges.push(edge);
3034
+ } });
3035
+ }
3036
+ return {
3037
+ edges,
3038
+ incomplete
3039
+ };
3040
+ };
3041
+ sourceParserPath = (source) => {
3042
+ try {
3043
+ return new URL(source).pathname;
3044
+ } catch (cause) {
3045
+ void cause;
3046
+ return source;
3047
+ }
3048
+ };
3049
+ checkOperation = (callerSignal, operationSignal, deadlineAt) => {
3050
+ if (callerSignal?.aborted === true) throw callerSignal.reason;
3051
+ if (operationSignal?.aborted === true) throw operationSignal.reason;
3052
+ if (performance.now() >= deadlineAt) throw new SourceMapDeadlineError();
3053
+ };
3054
+ approvedUrl = (value, allowedOrigins) => {
3055
+ try {
3056
+ const parsed = new URL(value);
3057
+ return (parsed.protocol === "http:" || parsed.protocol === "https:") && parsed.username === "" && parsed.password === "" && allowedOrigins.includes(parsed.origin);
3058
+ } catch (cause) {
3059
+ void cause;
3060
+ return false;
3061
+ }
3062
+ };
3063
+ sourceMapContext = (request, effectiveUrl = null) => ({
3064
+ script_key: request.scriptKey,
3065
+ declared_url: request.declaredUrl,
3066
+ effective_url: effectiveUrl
3067
+ });
3068
+ emptySourceMapItem = (request, status, limitation, effectiveUrl = null) => ({
3069
+ ...sourceMapContext(request, effectiveUrl),
3070
+ status,
3071
+ artifact: null,
3072
+ original_sources: [],
3073
+ original_module_edges: [],
3074
+ mappings: [],
3075
+ limitation
3076
+ });
3077
+ sanitizeSource = (value) => {
3078
+ try {
3079
+ return sanitizeBrowserUrl(new URL(value).href).url;
3080
+ } catch (cause) {
3081
+ void cause;
3082
+ return value;
3083
+ }
3084
+ };
3085
+ preflightResolvedSourceBytes = (leaves, mapUrl, budget, resolvedByRoot, sanitizedByResolved, check) => {
3086
+ let estimate = budget.expandedBytes;
3087
+ let resolvedBytes = budget.resolvedSourceBytes;
3088
+ for (const { map } of leaves) {
3089
+ let sourcesForRoot = resolvedByRoot.get(map.sourceRoot ?? null);
3090
+ if (sourcesForRoot === undefined) {
3091
+ sourcesForRoot = new Map();
3092
+ resolvedByRoot.set(map.sourceRoot ?? null, sourcesForRoot);
3093
+ }
3094
+ for (const source of map.sources) {
3095
+ check();
3096
+ if (source === null) continue;
3097
+ const sourceKey = source;
3098
+ let resolved = sourcesForRoot.get(sourceKey);
3099
+ if (resolved === undefined) resolved = resolveJavaScriptSourceMapUrl(source, map.sourceRoot, mapUrl);
3100
+ const bytes = Buffer.byteLength(resolved, "utf8");
3101
+ if (bytes > SOURCE_MAP_RESPONSE_BYTES - resolvedBytes) throw resolvedSourceLimitFailure();
3102
+ resolvedBytes += bytes;
3103
+ sourcesForRoot.set(sourceKey, resolved);
3104
+ const sanitized = cachedSanitized(sanitizedByResolved, resolved);
3105
+ estimate += jsonBytes(sanitized);
3106
+ if (estimate > WEB_SOURCE_MAP_LIMITS.outputBytes) throw expandedOutputFailure();
3107
+ }
3108
+ }
3109
+ budget.resolvedSourceBytes = resolvedBytes;
3110
+ };
3111
+ consumeExpandedBytes = (budget, bytes) => {
3112
+ if (bytes > WEB_SOURCE_MAP_LIMITS.outputBytes - budget.expandedBytes) throw expandedOutputFailure();
3113
+ budget.expandedBytes += bytes;
3114
+ };
3115
+ expandedOutputFailure = () => new SourceMapFormatFailure("limit", `Expanded source-map evidence exceeds the ${WEB_SOURCE_MAP_LIMITS.outputBytes / (1024 * 1024)} MiB public representation budget.`);
3116
+ sourceMapOutputError = (cause, options) => new AnalysisResourceConstraintError("analyze_web_bundle", "transport", cause.message, { maximum_source_map_output_bytes: SOURCE_MAP_OUTPUT_BYTES }, {
3117
+ cause,
3118
+ ...options
3119
+ });
3120
+ resolvedSourceLimitFailure = () => new SourceMapFormatFailure("limit", `Resolved source-map identities exceed the ${SOURCE_MAP_RESPONSE_BYTES / (1024 * 1024)} MiB decoder representation budget.`);
3121
+ jsonBytes = (value) => {
3122
+ let bytes = 0;
3123
+ for (const part of jsonParts(value)) bytes += Buffer.byteLength(part, "utf8");
3124
+ return bytes;
3125
+ };
3126
+ artifactMetadataBytes = (mediaType, text) => Buffer.byteLength(JSON.stringify({
3127
+ sha256: "0".repeat(64),
3128
+ bytes: Buffer.byteLength(text),
3129
+ media_type: mediaType,
3130
+ charset: "utf-8",
3131
+ text: ""
3132
+ })) - 2;
3133
+ EMPTY_SOURCE_MAP_FAILURE = emptySourceMapItem({
3134
+ scriptKey: "",
3135
+ declaredUrl: "",
3136
+ fetchUrl: ""
3137
+ }, "fetch_failed", "x".repeat(SOURCE_MAP_FAILURE_LIMITATION_RESERVE));
3138
+ SOURCE_MAP_FAILURE_ENVELOPE_BYTES = Buffer.byteLength(JSON.stringify(EMPTY_SOURCE_MAP_FAILURE)) - 4;
3139
+ SOURCE_MAP_SUCCESS_ENVELOPE_BYTES = Buffer.byteLength(JSON.stringify({
3140
+ ...EMPTY_SOURCE_MAP_FAILURE,
3141
+ status: "included",
3142
+ limitation: null
3143
+ })) - 4;
3144
+ sourceMapFailureReservation = (request, effectiveUrl = null, limitation, status = "fetch_failed") => SOURCE_MAP_FAILURE_ENVELOPE_BYTES + jsonBytes(request.declaredUrl) + jsonBytes(request.scriptKey) + (effectiveUrl === null ? 0 : jsonBytes(effectiveUrl) - 4) + Math.max(0, (limitation === undefined ? 0 : jsonBytes(limitation)) - SOURCE_MAP_FAILURE_LIMITATION_RESERVE - 2) + jsonBytes(status) - jsonBytes("fetch_failed");
3145
+ sourceEntryOverheadBytes = (sourceIndex, declarationIndex) => Buffer.byteLength(`{"source_index":${String(sourceIndex)},"declaration_index":${String(declarationIndex)},"source":,"artifact":null}`);
3146
+ cachedJsonBytes = (cache, value) => {
3147
+ const cached = cache.get(value);
3148
+ if (cached !== undefined) return cached;
3149
+ const bytes = jsonBytes(value);
3150
+ cache.set(value, bytes);
3151
+ return bytes;
3152
+ };
3153
+ cachedSanitized = (cache, value) => {
3154
+ const cached = cache.get(value);
3155
+ if (cached !== undefined) return cached;
3156
+ const sanitized = sanitizeSource(value);
3157
+ cache.set(value, sanitized);
3158
+ return sanitized;
3159
+ };
3160
+ mappingRowBytes = (sourceIndex, declarationIndex, generatedLine, generatedColumn, originalLine, originalColumn) => Buffer.byteLength(`{"source_index":${String(sourceIndex)},"declaration_index":${String(declarationIndex)},"generated_line":${String(generatedLine)},"generated_column":${String(generatedColumn)},"source":,"original_line":${String(originalLine)},"original_column":${String(originalColumn)},"name":}`);
3161
+ resolveOriginalSource = (specifier, base) => {
3162
+ if (!isUrlLikeModuleSpecifier(specifier)) return null;
3163
+ try {
3164
+ return sanitizeSource(new URL(specifier, base).href);
3165
+ } catch (cause) {
3166
+ void cause;
3167
+ return null;
3168
+ }
3169
+ };
3170
+ sourceMediaType = (source) => source?.endsWith(".ts") || source?.endsWith(".tsx") || source?.endsWith(".mts") || source?.endsWith(".cts") ? "text/typescript" : "text/javascript";
3171
+ originalDependency = (node) => {
3172
+ if (t.isImportDeclaration(node) || t.isExportAllDeclaration(node) || t.isExportNamedDeclaration(node)) return node.source === null || node.source === undefined || (t.isImportDeclaration(node) ? isTypeOnlyImportDeclaration(node) : isTypeOnlyExportDeclaration(node)) ? null : {
3173
+ kind: "static_import",
3174
+ specifier: node.source.value
3175
+ };
3176
+ if (t.isImportExpression(node)) {
3177
+ const specifier = stringValue(node.source);
3178
+ return specifier === undefined ? null : {
3179
+ kind: "dynamic_import",
3180
+ specifier
3181
+ };
3182
+ }
3183
+ if ((t.isCallExpression(node) || t.isOptionalCallExpression(node)) && t.isIdentifier(node.callee, { name: "require" })) {
3184
+ const specifier = stringValue(node.arguments[0]);
3185
+ return specifier === undefined ? null : {
3186
+ kind: "require",
3187
+ specifier,
3188
+ requireCallee: node.callee
3189
+ };
3190
+ }
3191
+ if (t.isTSImportEqualsDeclaration(node) && t.isTSExternalModuleReference(node.moduleReference)) return {
3192
+ kind: "require",
3193
+ specifier: node.moduleReference.expression.value
3194
+ };
3195
+ return null;
3196
+ };
3197
+ })))();
3198
+ }
3199
+
3200
+ //#endregion
3201
+ //#region dist/browser/CdpObservationSession.js
3202
+ var observeCdpSession, TimelineCapture, waitForWindow, captureFinalUrl, frameId, scopedUrl, boundedId, safeDetail, safeNetworkError;
3203
+ function init_CdpObservationSession() {
3204
+ return (init_CdpObservationSession = __esmMin((() => {
3205
+ init_analysisErrorCore();
3206
+ init_browserObservationError();
3207
+ init_CdpConnection();
3208
+ init_CdpCaptureCompleteness();
3209
+ init_CdpAuthorizedMainFrame();
3210
+ init_CdpCaptureValues();
3211
+ init_CdpCaptureDocuments();
3212
+ init_CdpCaptureEventHelpers();
3213
+ init_CdpTargetEvents();
3214
+ observeCdpSession = async (context) => {
3215
+ const allowedOrigins = new Set(context.input.allowed_origins);
3216
+ const initial = await authorizedMainFrame({
3217
+ connection: context.connection,
3218
+ sessionId: context.sessionId,
3219
+ signal: context.signal,
3220
+ allowedOrigins,
3221
+ operation: "observe_web_session"
3222
+ });
3223
+ const initialUrl = mainFrameUrl(initial) ?? "";
3224
+ const mainFrameId = frameId(initial);
3225
+ if (mainFrameId === undefined) throw new BrowserObservationError("inspect_web_page", "protocol_error");
3226
+ const capture = new TimelineCapture(allowedOrigins, mainFrameId, initialUrl);
3227
+ const removeListener = context.connection.onEvent((event) => {
3228
+ if (cdpTargetEventMatches(event, context.sessionId)) capture.ingest(event);
3229
+ });
3230
+ const removeDisconnectListener = context.connection.onDisconnect(() => capture.targetTerminated());
3231
+ try {
3232
+ await context.connection.send("Page.enable", {}, context.sessionId, context.signal);
3233
+ await context.connection.send("Network.enable", {}, context.sessionId, context.signal);
3234
+ await context.connection.send("Page.setLifecycleEventsEnabled", { enabled: true }, context.sessionId, context.signal);
3235
+ const armedAt = new Date().toISOString();
3236
+ await context.progress?.report({
3237
+ phase: "browser_observation",
3238
+ completed: 1,
3239
+ total: 2,
3240
+ message: "Browser observation armed; perform the requested user action now"
3241
+ });
3242
+ let endReason = await waitForWindow(context.input.observation_ms, capture, context.signal);
3243
+ if (endReason === "window_elapsed") endReason = await captureFinalUrl(context, capture, allowedOrigins);
3244
+ await context.progress?.report({
3245
+ phase: "browser_observation",
3246
+ completed: 2,
3247
+ total: 2,
3248
+ message: "Browser observation window ended",
3249
+ terminal: true
3250
+ });
3251
+ if (capture.scopeExcluded) endReason = "target_left_scope";
3252
+ return {
3253
+ browser: context.discovery.version,
3254
+ target: {
3255
+ target_id: context.target.id,
3256
+ initial_url: allowedSanitizedUrl(initialUrl, allowedOrigins)?.url ?? "",
3257
+ final_url: capture.finalUrl
3258
+ },
3259
+ window: {
3260
+ armed_at: armedAt,
3261
+ ended_at: new Date().toISOString(),
3262
+ requested_ms: context.input.observation_ms,
3263
+ end_reason: endReason
3264
+ },
3265
+ timeline: capture.timeline,
3266
+ completeness: capture.completeness.snapshot(),
3267
+ limitations: [
3268
+ "The timeline begins after REA attaches; earlier navigation and network activity is unavailable.",
3269
+ "Only navigation metadata is retained; headers, bodies, cookies, console values, and payloads are not captured by this tool.",
3270
+ "An out-of-policy destination ends collection immediately and is recorded without its URL."
3271
+ ]
3272
+ };
3273
+ } finally {
3274
+ removeListener();
3275
+ removeDisconnectListener();
3276
+ }
3277
+ };
3278
+ TimelineCapture = class {
3279
+ allowedOrigins;
3280
+ mainFrameId;
3281
+ timeline = [];
3282
+ completeness = new CdpCaptureCompleteness(["timeline"]);
3283
+ finalUrl;
3284
+ #sequence = 0;
3285
+ #pendingReload = false;
3286
+ #scopeExcluded = false;
3287
+ #endReason;
3288
+ #listeners = new Set();
3289
+ constructor(allowedOrigins, mainFrameId, initialUrl) {
3290
+ this.allowedOrigins = allowedOrigins;
3291
+ this.mainFrameId = mainFrameId;
3292
+ this.finalUrl = allowedSanitizedUrl(initialUrl, allowedOrigins)?.url ?? null;
3293
+ }
3294
+ ingest(event) {
3295
+ if (this.#endReason !== undefined || this.#scopeExcluded) return;
3296
+ const params = recordValue(event.params);
3297
+ if (params === undefined) return;
3298
+ switch (event.method) {
3299
+ case "Page.frameRequestedNavigation":
3300
+ this.#navigationRequested(event, params);
3301
+ break;
3302
+ case "Page.frameNavigated":
3303
+ this.#navigationCommitted(event, params);
3304
+ break;
3305
+ case "Page.navigatedWithinDocument":
3306
+ this.#sameDocument(event, params);
3307
+ break;
3308
+ case "Network.requestWillBeSent":
3309
+ this.#redirect(params);
3310
+ break;
3311
+ case "Network.loadingFailed":
3312
+ this.#loadingFailed(params);
3313
+ break;
3314
+ case "Page.lifecycleEvent":
3315
+ this.#lifecycle(params);
3316
+ break;
3317
+ case "Inspector.targetCrashed":
3318
+ case "Target.detachedFromTarget":
3319
+ this.targetTerminated();
3320
+ break;
3321
+ }
3322
+ }
3323
+ onEnd(listener) {
3324
+ if (this.#endReason !== undefined) listener(this.#endReason);
3325
+ else this.#listeners.add(listener);
3326
+ return () => this.#listeners.delete(listener);
3327
+ }
3328
+ end(reason) {
3329
+ if (this.#endReason !== undefined) return;
3330
+ this.#endReason = reason;
3331
+ for (const listener of this.#listeners) listener(reason);
3332
+ this.#listeners.clear();
3333
+ }
3334
+ targetTerminated() {
3335
+ if (this.#endReason !== undefined) return;
3336
+ this.#add({
3337
+ type: "target_terminated",
3338
+ params: {},
3339
+ rawUrl: null,
3340
+ requestId: null,
3341
+ detail: "target_terminated"
3342
+ });
3343
+ this.end("target_terminated");
3344
+ }
3345
+ setFinalUrl(rawUrl) {
3346
+ if (this.#scopeExcluded) return;
3347
+ const destination = scopedUrl(rawUrl, this.allowedOrigins);
3348
+ this.finalUrl = destination.scope === "approved" ? destination.url : null;
3349
+ }
3350
+ get scopeExcluded() {
3351
+ return this.#scopeExcluded;
3352
+ }
3353
+ excludeTargetScope(reason) {
3354
+ if (this.#scopeExcluded) return;
3355
+ this.#scopeExcluded = true;
3356
+ this.finalUrl = null;
3357
+ this.completeness.exclude("timeline", reason);
3358
+ }
3359
+ #navigationRequested(event, params) {
3360
+ if (!isMainFrameNavigation(event, this.mainFrameId)) return;
3361
+ const reason = safeDetail(params.reason);
3362
+ this.#pendingReload = reason === "reload";
3363
+ this.#add({
3364
+ type: "navigation_requested",
3365
+ params,
3366
+ rawUrl: cdpStringValue(params.url) ?? null,
3367
+ requestId: null,
3368
+ detail: reason
3369
+ });
3370
+ }
3371
+ #navigationCommitted(event, params) {
3372
+ const frame = recordValue(params.frame);
3373
+ if (!isMainFrameNavigation(event, this.mainFrameId)) return;
3374
+ const rawUrl = cdpStringValue(frame?.url);
3375
+ const destination = scopedUrl(rawUrl, this.allowedOrigins);
3376
+ this.#add({
3377
+ type: this.#pendingReload ? "same_origin_reload" : "navigation_committed",
3378
+ params: {
3379
+ ...params,
3380
+ frameId: frame?.id,
3381
+ loaderId: frame?.loaderId
3382
+ },
3383
+ rawUrl: rawUrl ?? null,
3384
+ requestId: null,
3385
+ detail: safeDetail(frame?.transitionType)
3386
+ });
3387
+ this.#pendingReload = false;
3388
+ if (destination.scope === "approved") this.finalUrl = destination.url;
3389
+ else {
3390
+ this.excludeTargetScope("out_of_target_scope");
3391
+ this.end("target_left_scope");
3392
+ }
3393
+ }
3394
+ #sameDocument(event, params) {
3395
+ if (!isMainFrameNavigation(event, this.mainFrameId)) return;
3396
+ const rawUrl = cdpStringValue(params.url);
3397
+ const destination = scopedUrl(rawUrl, this.allowedOrigins);
3398
+ this.#add({
3399
+ type: "same_document_navigation",
3400
+ params,
3401
+ rawUrl: rawUrl ?? null,
3402
+ requestId: null,
3403
+ detail: null
3404
+ });
3405
+ if (destination.scope === "approved") this.finalUrl = destination.url;
3406
+ else {
3407
+ this.excludeTargetScope("out_of_target_scope");
3408
+ this.end("target_left_scope");
3409
+ }
3410
+ }
3411
+ #redirect(params) {
3412
+ const resourceType = cdpStringValue(params.type);
3413
+ if (resourceType !== undefined && resourceType !== "Document") return;
3414
+ if (cdpStringValue(params.frameId) !== this.mainFrameId || recordValue(params.redirectResponse) === undefined) return;
3415
+ const request = recordValue(params.request);
3416
+ const rawUrl = cdpStringValue(request?.url);
3417
+ const destination = scopedUrl(rawUrl, this.allowedOrigins);
3418
+ this.#add({
3419
+ type: "redirect",
3420
+ params,
3421
+ rawUrl: rawUrl ?? null,
3422
+ requestId: cdpStringValue(params.requestId) ?? null,
3423
+ detail: null
3424
+ });
3425
+ if (destination.scope !== "approved") {
3426
+ this.excludeTargetScope("out_of_target_scope");
3427
+ this.end("target_left_scope");
3428
+ }
3429
+ }
3430
+ #loadingFailed(params) {
3431
+ const frame = cdpStringValue(params.frameId);
3432
+ if (frame !== undefined && frame !== this.mainFrameId) return;
3433
+ this.#add({
3434
+ type: "load_failed",
3435
+ params,
3436
+ rawUrl: null,
3437
+ requestId: cdpStringValue(params.requestId) ?? null,
3438
+ detail: safeNetworkError(params.errorText)
3439
+ });
3440
+ }
3441
+ #lifecycle(params) {
3442
+ if (cdpStringValue(params.frameId) !== this.mainFrameId) return;
3443
+ this.#add({
3444
+ type: "lifecycle",
3445
+ params,
3446
+ rawUrl: null,
3447
+ requestId: null,
3448
+ detail: safeDetail(params.name)
3449
+ });
3450
+ }
3451
+ #add(options) {
3452
+ const { type, params, rawUrl = null, requestId = null, detail = null } = options;
3453
+ const destination = rawUrl == null ? null : scopedUrl(rawUrl, this.allowedOrigins);
3454
+ this.#sequence += 1;
3455
+ this.timeline.push({
3456
+ sequence: this.#sequence,
3457
+ type,
3458
+ timestamp: Math.max(0, numberValue(params.timestamp) ?? 0),
3459
+ frame_id: boundedId(params.frameId),
3460
+ loader_id: boundedId(params.loaderId),
3461
+ request_id: requestId ?? null,
3462
+ url: destination?.scope === "approved" ? destination.url : null,
3463
+ destination_scope: destination?.scope ?? null,
3464
+ detail
3465
+ });
3466
+ }
3467
+ };
3468
+ waitForWindow = async (durationMs, capture, signal) => await new Promise((resolve, reject) => {
3469
+ let settled = false;
3470
+ let removeEnd = () => {};
3471
+ const finish = (reason) => {
3472
+ if (settled) return;
3473
+ settled = true;
3474
+ clearTimeout(timer);
3475
+ signal?.removeEventListener("abort", onAbort);
3476
+ removeEnd();
3477
+ resolve(reason);
3478
+ };
3479
+ const onAbort = () => {
3480
+ if (settled) return;
3481
+ settled = true;
3482
+ clearTimeout(timer);
3483
+ removeEnd();
3484
+ reject(new AnalysisCancelledError("observe_web_session"));
3485
+ };
3486
+ const timer = setTimeout(() => finish("window_elapsed"), durationMs);
3487
+ removeEnd = capture.onEnd(finish);
3488
+ signal?.addEventListener("abort", onAbort, { once: true });
3489
+ if (signal?.aborted === true) onAbort();
3490
+ });
3491
+ captureFinalUrl = async (context, capture, allowedOrigins) => {
3492
+ if (capture.scopeExcluded) return "target_left_scope";
3493
+ const result = await context.connection.send("Page.getFrameTree", {}, context.sessionId, context.signal);
3494
+ if (capture.scopeExcluded) return "target_left_scope";
3495
+ const url = mainFrameUrl(result);
3496
+ if (url !== undefined && allowedSanitizedUrl(url, allowedOrigins) !== undefined) {
3497
+ capture.setFinalUrl(url);
3498
+ return "window_elapsed";
3499
+ }
3500
+ capture.excludeTargetScope(url === undefined ? "invalid_protocol_value" : "out_of_target_scope");
3501
+ return "target_left_scope";
3502
+ };
3503
+ frameId = (result) => cdpStringValue(recordValue(recordValue(recordValue(result)?.frameTree)?.frame)?.id);
3504
+ scopedUrl = (value, allowedOrigins) => {
3505
+ const allowed = allowedSanitizedUrl(value, allowedOrigins);
3506
+ if (allowed !== undefined) return {
3507
+ url: allowed.url,
3508
+ scope: "approved"
3509
+ };
3510
+ return isHttpUrl(value) ? {
3511
+ url: null,
3512
+ scope: "outside_policy"
3513
+ } : {
3514
+ url: null,
3515
+ scope: "unsupported"
3516
+ };
3517
+ };
3518
+ boundedId = (value) => cdpStringValue(value) ?? null;
3519
+ safeDetail = (value) => {
3520
+ const detail = cdpStringValue(value)?.toLowerCase();
3521
+ return detail !== undefined && /^[a-z0-9_.:-]{1,100}$/u.test(detail) ? detail : null;
3522
+ };
3523
+ safeNetworkError = (value) => {
3524
+ const error = cdpStringValue(value);
3525
+ return error !== undefined && /^net::ERR_[A-Z0-9_]{1,100}$/u.test(error) ? error : null;
3526
+ };
3527
+ })))();
3528
+ }
3529
+
3530
+ //#endregion
3531
+ //#region dist/browser/CdpWebMcpDiscovery.js
3532
+ var discoverWebMcp, initialFrameScope, ingestFrameScopeEvent, handleFrameDetached, handleFrameUpdate, updateFrameScope, hasNewDocument, removeFrameTools, isTransientFrameUrl, removeFrame, assertStableAuthorizedFrame, ingestWebMcpEvent, webMcpEventTools, normalizeTool, registrationSource, buildWebMcpResult, toolKey, integerOrNull;
3533
+ function init_CdpWebMcpDiscovery() {
3534
+ return (init_CdpWebMcpDiscovery = __esmMin((() => {
3535
+ init_jsonValue();
3536
+ init_canonicalDigest();
3537
+ init_unicodeCodePointOrder();
3538
+ init_CdpCaptureCompleteness();
3539
+ init_browserObservationError();
3540
+ init_CdpCaptureValues();
3541
+ init_CdpCaptureDocuments();
3542
+ init_CdpOptionalCommand();
3543
+ discoverWebMcp = async (context) => {
3544
+ const origins = new Set(context.input.allowed_origins);
3545
+ const limitations = ["Page-declared tool metadata is untrusted and is never registered or invoked by REA.", "Discovery uses only WebMCP.enable and toolsAdded/toolsRemoved; WebMCP.invokeTool is never called."];
3546
+ const completeness = new CdpCaptureCompleteness();
3547
+ await context.connection.send("Page.enable", {}, context.sessionId, context.signal);
3548
+ const frameTree = await context.connection.send("Page.getFrameTree", {}, context.sessionId, context.signal);
3549
+ const initialUrl = mainFrameUrl(frameTree);
3550
+ if (allowedSanitizedUrl(initialUrl, origins) === undefined) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
3551
+ const frames = captureFrames(frameTree, origins, undefined, completeness).items;
3552
+ const frameUrls = initialFrameScope(frameTree, frames, completeness);
3553
+ const tools = new Map();
3554
+ const frameScope = {
3555
+ origins,
3556
+ frames: frameUrls,
3557
+ tools,
3558
+ completeness,
3559
+ transientFrames: new Set(),
3560
+ resolvedTransientFrames: new Set()
3561
+ };
3562
+ const removeListener = context.connection.onEvent((event) => {
3563
+ if (event.sessionId !== context.sessionId) return;
3564
+ if (ingestFrameScopeEvent(event, frameScope)) return;
3565
+ ingestWebMcpEvent({
3566
+ event,
3567
+ input: context.input,
3568
+ frames: frameUrls,
3569
+ tools,
3570
+ completeness,
3571
+ transientFrames: frameScope.transientFrames,
3572
+ resolvedTransientFrames: frameScope.resolvedTransientFrames
3573
+ });
3574
+ });
3575
+ await context.progress?.report({
3576
+ phase: "browser_observation",
3577
+ completed: 1,
3578
+ total: 2,
3579
+ message: "Enabling passive WebMCP discovery"
3580
+ });
3581
+ try {
3582
+ const enabled = await optionalCdpCommand(context, "WebMCP.enable", {}, limitations);
3583
+ const available = enabled !== undefined;
3584
+ if (!available) {
3585
+ completeness.unavailable("webmcp_tools");
3586
+ } else await delayWithCancellation(context.input.observation_ms, "discover_webmcp_tools", context.signal);
3587
+ await assertStableAuthorizedFrame(context, initialUrl, origins);
3588
+ if (frameScope.transientFrames.size > 0) completeness.attachLimited("webmcp_tools");
3589
+ return buildWebMcpResult({
3590
+ context,
3591
+ frameTree,
3592
+ tools,
3593
+ completeness,
3594
+ limitations,
3595
+ available
3596
+ });
3597
+ } finally {
3598
+ removeListener();
3599
+ await context.progress?.report({
3600
+ phase: "browser_observation",
3601
+ completed: 2,
3602
+ total: 2,
3603
+ message: "WebMCP discovery complete",
3604
+ terminal: true
3605
+ });
3606
+ }
3607
+ };
3608
+ initialFrameScope = (frameTree, frames, completeness) => {
3609
+ const scoped = new Map(frames.map((frame) => [frame.frame_id, {
3610
+ url: frame.url,
3611
+ origin: frame.origin,
3612
+ parentFrameId: frame.parent_frame_id
3613
+ }]));
3614
+ const root = recordValue(recordValue(frameTree)?.frameTree);
3615
+ if (root === undefined) return scoped;
3616
+ for (const tree of walkFrameTrees(root, () => completeness.exclude("webmcp_tools", "invalid_protocol_value"))) {
3617
+ const frame = recordValue(tree.frame);
3618
+ const frameId = cdpStringValue(frame?.id);
3619
+ const prior = frameId === undefined ? undefined : scoped.get(frameId);
3620
+ if (frameId !== undefined && prior !== undefined) scoped.set(frameId, {
3621
+ ...prior,
3622
+ loaderId: cdpStringValue(frame?.loaderId)
3623
+ });
3624
+ }
3625
+ return scoped;
3626
+ };
3627
+ ingestFrameScopeEvent = (event, state) => {
3628
+ const params = recordValue(event.params);
3629
+ if (params === undefined) return false;
3630
+ switch (event.method) {
3631
+ case "Page.frameDetached": return handleFrameDetached(params, state);
3632
+ case "Page.frameNavigated": return handleFrameUpdate(recordValue(params.frame), state, true);
3633
+ case "Page.navigatedWithinDocument": return handleFrameUpdate(params, state, false);
3634
+ default: return false;
3635
+ }
3636
+ };
3637
+ handleFrameDetached = (params, state) => {
3638
+ const frameId = cdpStringValue(params.frameId);
3639
+ if (frameId === undefined) {
3640
+ state.completeness.exclude("webmcp_tools", "invalid_protocol_value");
3641
+ return true;
3642
+ }
3643
+ removeFrame(frameId, state.frames, state.tools);
3644
+ state.transientFrames.delete(frameId);
3645
+ state.resolvedTransientFrames.delete(frameId);
3646
+ return true;
3647
+ };
3648
+ handleFrameUpdate = (frame, state, documentCommitted) => {
3649
+ if (frame === undefined) {
3650
+ state.completeness.exclude("webmcp_tools", "invalid_protocol_value");
3651
+ return true;
3652
+ }
3653
+ const frameId = cdpStringValue(frame?.id) ?? cdpStringValue(frame?.frameId);
3654
+ if (frameId === undefined) {
3655
+ state.completeness.exclude("webmcp_tools", "invalid_protocol_value");
3656
+ return true;
3657
+ }
3658
+ const rawUrl = cdpStringValue(frame?.url);
3659
+ if (isTransientFrameUrl(rawUrl)) {
3660
+ if (documentCommitted) {
3661
+ removeFrameTools(frameId, state.tools);
3662
+ state.transientFrames.add(frameId);
3663
+ state.resolvedTransientFrames.delete(frameId);
3664
+ }
3665
+ return true;
3666
+ }
3667
+ updateFrameScope(frame, frameId, state, documentCommitted);
3668
+ return true;
3669
+ };
3670
+ updateFrameScope = (frame, frameId, state, documentCommitted) => {
3671
+ const url = allowedSanitizedUrl(frame?.url, state.origins);
3672
+ if (url === undefined || url.origin === null) {
3673
+ removeFrameTools(frameId, state.tools);
3674
+ state.frames.delete(frameId);
3675
+ state.completeness.exclude("webmcp_tools", "out_of_target_scope");
3676
+ return;
3677
+ }
3678
+ const previous = state.frames.get(frameId);
3679
+ const loaderId = cdpStringValue(frame?.loaderId);
3680
+ if (hasNewDocument(documentCommitted, previous, url.url, loaderId)) removeFrameTools(frameId, state.tools);
3681
+ if (documentCommitted && state.transientFrames.has(frameId)) state.resolvedTransientFrames.add(frameId);
3682
+ state.frames.set(frameId, {
3683
+ url: url.url,
3684
+ origin: url.origin,
3685
+ ...loaderId === undefined ? {} : { loaderId },
3686
+ parentFrameId: (cdpStringValue(frame?.parentId) ?? state.frames.get(frameId)?.parentFrameId ?? "") || null
3687
+ });
3688
+ };
3689
+ hasNewDocument = (documentCommitted, previous, url, loaderId) => documentCommitted && previous !== undefined && (previous.url !== url || loaderId !== undefined && previous.loaderId !== undefined && previous.loaderId !== loaderId);
3690
+ removeFrameTools = (frameId, tools) => {
3691
+ for (const [key, tool] of tools) if (tool.frame_id === frameId) tools.delete(key);
3692
+ };
3693
+ isTransientFrameUrl = (url) => url === "" || url === "about:blank" || url === "about:srcdoc";
3694
+ removeFrame = (frameId, frames, tools) => {
3695
+ const pending = [frameId];
3696
+ const removed = new Set();
3697
+ while (pending.length > 0) {
3698
+ const current = pending.pop();
3699
+ if (current === undefined || removed.has(current)) continue;
3700
+ removed.add(current);
3701
+ for (const [candidate, frame] of frames) if (frame.parentFrameId === current) pending.push(candidate);
3702
+ frames.delete(current);
3703
+ }
3704
+ for (const [key, tool] of tools) if (removed.has(tool.frame_id)) tools.delete(key);
3705
+ };
3706
+ assertStableAuthorizedFrame = async (context, initialUrl, origins) => {
3707
+ const finalTree = await context.connection.send("Page.getFrameTree", {}, context.sessionId, context.signal);
3708
+ const finalUrl = mainFrameUrl(finalTree);
3709
+ if (allowedSanitizedUrl(finalUrl, origins) === undefined) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
3710
+ if (finalUrl !== initialUrl) throw new BrowserObservationError("inspect_web_page", "target_changed");
3711
+ };
3712
+ ingestWebMcpEvent = (options) => {
3713
+ const { event, input, frames, tools, completeness, transientFrames, resolvedTransientFrames } = options;
3714
+ if (event.method !== "WebMCP.toolsAdded" && event.method !== "WebMCP.toolsRemoved") return;
3715
+ const params = recordValue(event.params);
3716
+ if (params === undefined) {
3717
+ completeness.exclude("webmcp_tools", "invalid_protocol_value");
3718
+ return;
3719
+ }
3720
+ if (event.method === "WebMCP.toolsRemoved") {
3721
+ for (const removed of webMcpEventTools(params.tools, completeness)) {
3722
+ const name = cdpStringValue(removed.name);
3723
+ const frameId = cdpStringValue(removed.frameId);
3724
+ if (name === undefined || frameId === undefined) {
3725
+ completeness.exclude("webmcp_tools", "invalid_protocol_value");
3726
+ continue;
3727
+ }
3728
+ for (const [key, tool] of tools) if (tool.name === name && tool.frame_id === frameId) tools.delete(key);
3729
+ }
3730
+ return;
3731
+ }
3732
+ for (const declared of webMcpEventTools(params.tools, completeness)) {
3733
+ const frameId = cdpStringValue(declared.frameId);
3734
+ if (frameId !== undefined && transientFrames.has(frameId)) {
3735
+ if (!resolvedTransientFrames.has(frameId)) continue;
3736
+ transientFrames.delete(frameId);
3737
+ resolvedTransientFrames.delete(frameId);
3738
+ }
3739
+ const normalized = normalizeTool(declared, input, frames, completeness);
3740
+ if (normalized === undefined) continue;
3741
+ tools.set(normalized.tool_key, normalized);
3742
+ }
3743
+ };
3744
+ webMcpEventTools = (value, completeness) => {
3745
+ if (!Array.isArray(value)) {
3746
+ completeness.exclude("webmcp_tools", "invalid_protocol_value");
3747
+ return [];
3748
+ }
3749
+ const records = [];
3750
+ for (const item of value) {
3751
+ const record = recordValue(item);
3752
+ if (record === undefined) {
3753
+ completeness.exclude("webmcp_tools", "invalid_protocol_value");
3754
+ continue;
3755
+ }
3756
+ records.push(record);
3757
+ }
3758
+ return records;
3759
+ };
3760
+ normalizeTool = (value, input, frames, completeness) => {
3761
+ const frameId = cdpStringValue(value.frameId);
3762
+ const name = cdpStringValue(value.name);
3763
+ const frame = frameId === undefined ? undefined : frames.get(frameId);
3764
+ if (frameId === undefined || name === undefined) {
3765
+ completeness.exclude("webmcp_tools", "invalid_protocol_value");
3766
+ return undefined;
3767
+ }
3768
+ if (frame?.origin === null || frame === undefined) {
3769
+ completeness.exclude("webmcp_tools", "out_of_target_scope");
3770
+ return undefined;
3771
+ }
3772
+ const description = cdpStringValue(value.description) ?? "";
3773
+ const annotations = recordValue(value.annotations);
3774
+ const malformedAnnotations = Object.hasOwn(value, "annotations") && annotations === undefined;
3775
+ if (malformedAnnotations) completeness.exclude("webmcp_tools", "invalid_protocol_value");
3776
+ const annotation = (key) => {
3777
+ if (annotations === undefined || !Object.hasOwn(annotations, key)) return null;
3778
+ const hint = annotations[key];
3779
+ if (typeof hint === "boolean") return hint;
3780
+ completeness.exclude("webmcp_tools", "invalid_protocol_value");
3781
+ return null;
3782
+ };
3783
+ const consequential = annotation("consequential");
3784
+ const unknownConsequential = malformedAnnotations || annotations !== undefined && Object.hasOwn(annotations, "consequential") && typeof annotations.consequential !== "boolean";
3785
+ const declaration = jsonValueSchema.safeParse(value.inputSchema);
3786
+ if (!declaration.success) completeness.exclude("webmcp_tools", "invalid_protocol_value");
3787
+ const schema = declaration.success ? declaration.data : null;
3788
+ return {
3789
+ tool_key: toolKey(frame.url, frameId, name),
3790
+ name,
3791
+ description,
3792
+ frame_id: frameId,
3793
+ frame_url: frame.url,
3794
+ owner_origin: frame.origin,
3795
+ declaration_kind: numberValue(value.backendNodeId) === undefined ? "imperative" : "declarative",
3796
+ input_schema: schema,
3797
+ input_schema_sha256: declaration.success ? digestCanonicalValue(schema) : null,
3798
+ annotations: {
3799
+ read_only: annotation("readOnly"),
3800
+ untrusted_content: annotation("untrustedContent"),
3801
+ ...unknownConsequential ? {} : { consequential },
3802
+ autosubmit: annotation("autosubmit")
3803
+ },
3804
+ registration_source: registrationSource(recordValue(value.stackTrace), new Set(input.allowed_origins)),
3805
+ trust: "page-declared-untrusted"
3806
+ };
3807
+ };
3808
+ registrationSource = (stack, allowedOrigins) => {
3809
+ const frame = recordsValue(stack?.callFrames)[0];
3810
+ const url = allowedSanitizedUrl(frame?.url, allowedOrigins);
3811
+ return frame === undefined || url === undefined ? null : {
3812
+ url: url.url,
3813
+ line: integerOrNull(frame.lineNumber),
3814
+ column: integerOrNull(frame.columnNumber)
3815
+ };
3816
+ };
3817
+ buildWebMcpResult = (options) => {
3818
+ const { context, frameTree, tools, completeness, limitations, available } = options;
3819
+ const targetUrl = mainFrameUrl(frameTree) ?? context.target.url;
3820
+ const sanitized = allowedSanitizedUrl(targetUrl, new Set(context.input.allowed_origins));
3821
+ return {
3822
+ browser: context.discovery.version,
3823
+ target: {
3824
+ target_id: context.target.id,
3825
+ url: sanitized?.url ?? "[unsupported-url]",
3826
+ origin: sanitized?.origin ?? ""
3827
+ },
3828
+ status: available ? "available" : "unavailable",
3829
+ tools: {
3830
+ total: tools.size + completeness.droppedTotal,
3831
+ items: [...tools.values()].sort((left, right) => compareUnicodeCodePoints(left.tool_key, right.tool_key))
3832
+ },
3833
+ completeness: completeness.snapshot(),
3834
+ limitations
3835
+ };
3836
+ };
3837
+ toolKey = (frameUrl, frameId, name) => `webmcp_${createHash("sha256").update(compositeKey([
3838
+ frameUrl,
3839
+ frameId,
3840
+ name
3841
+ ])).digest("hex")}`;
3842
+ integerOrNull = (value) => {
3843
+ const number = numberValue(value);
3844
+ return number === undefined ? null : Math.max(0, Math.trunc(number));
3845
+ };
3846
+ })))();
3847
+ }
3848
+
3849
+ //#endregion
3850
+ //#region dist/browser/CdpScreenshot.js
3851
+ var captureCdpScreenshot, observeScreenshotNavigation;
3852
+ function init_CdpScreenshot() {
3853
+ return (init_CdpScreenshot = __esmMin((() => {
3854
+ init_webScreenshot();
3855
+ init_browserObservationError();
3856
+ init_CdpCaptureEventHelpers();
3857
+ init_CdpCaptureValues();
3858
+ init_CdpCaptureDocuments();
3859
+ init_CdpCaptureCompleteness();
3860
+ init_pngHeader();
3861
+ captureCdpScreenshot = async (context) => {
3862
+ const origins = new Set(context.input.allowed_origins);
3863
+ await context.progress?.report({
3864
+ phase: "browser_observation",
3865
+ completed: 1,
3866
+ total: 2,
3867
+ message: "Authorizing current screenshot frame"
3868
+ });
3869
+ await context.connection.send("Page.enable", {}, context.sessionId, context.signal);
3870
+ const before = await context.connection.send("Page.getFrameTree", {}, context.sessionId, context.signal);
3871
+ const beforeUrl = mainFrameUrl(before);
3872
+ const authorized = allowedSanitizedUrl(beforeUrl, origins);
3873
+ const mainFrame = captureFrames(before, origins, 1).items[0];
3874
+ if (authorized === undefined || mainFrame === undefined) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
3875
+ const initialFrame = recordValue(recordValue(recordValue(before)?.frameTree)?.frame);
3876
+ const navigation = {
3877
+ changed: false,
3878
+ leftScope: false,
3879
+ url: beforeUrl,
3880
+ loaderId: cdpStringValue(initialFrame?.loaderId)
3881
+ };
3882
+ const removeListener = context.connection.onEvent((event) => {
3883
+ if (event.sessionId !== context.sessionId) return;
3884
+ observeScreenshotNavigation(event, mainFrame.frame_id, origins, navigation);
3885
+ });
3886
+ let result;
3887
+ let after;
3888
+ try {
3889
+ result = recordValue(await context.connection.send("Page.captureScreenshot", {
3890
+ format: "png",
3891
+ fromSurface: true,
3892
+ captureBeyondViewport: false
3893
+ }, context.sessionId, context.signal));
3894
+ after = await context.connection.send("Page.getFrameTree", {}, context.sessionId, context.signal);
3895
+ } finally {
3896
+ removeListener();
3897
+ }
3898
+ const encoded = cdpStringValue(result?.data);
3899
+ const bytes = encoded === undefined ? undefined : decodeCanonicalBase64(encoded);
3900
+ if (bytes === undefined) throw new BrowserObservationError("inspect_web_page", "protocol_error");
3901
+ const dimensions = readPngHeaderDimensions(bytes);
3902
+ if (dimensions === undefined) throw new BrowserObservationError("inspect_web_page", "protocol_error");
3903
+ if (navigation.leftScope) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
3904
+ const afterUrl = mainFrameUrl(after);
3905
+ if (navigation.changed || afterUrl !== beforeUrl || allowedSanitizedUrl(afterUrl, origins) === undefined) throw new BrowserObservationError("inspect_web_page", "target_changed");
3906
+ await context.progress?.report({
3907
+ phase: "browser_observation",
3908
+ completed: 2,
3909
+ total: 2,
3910
+ message: "Screenshot capture complete",
3911
+ terminal: true
3912
+ });
3913
+ return {
3914
+ browser: context.discovery.version,
3915
+ target: {
3916
+ target_id: context.target.id,
3917
+ url: authorized.url,
3918
+ origin: authorized.origin ?? ""
3919
+ },
3920
+ captured_at: new Date().toISOString(),
3921
+ viewport: dimensions,
3922
+ artifact: createWebScreenshotArtifact(bytes),
3923
+ completeness: new CdpCaptureCompleteness().snapshot(),
3924
+ limitations: ["The screenshot contains the visible viewport, including on-screen content.", "REA does not scroll, evaluate JavaScript, or capture beyond the current viewport."]
3925
+ };
3926
+ };
3927
+ observeScreenshotNavigation = (event, mainFrameId, origins, state) => {
3928
+ if (!isMainFrameNavigation(event, mainFrameId)) return;
3929
+ const params = recordValue(event.params);
3930
+ if (params === undefined) return;
3931
+ const frame = event.method === "Page.frameNavigated" ? recordValue(params.frame) : params;
3932
+ if (event.method === "Page.frameNavigated" && state.loaderId !== undefined && state.loaderId !== "" && cdpStringValue(frame?.loaderId) === state.loaderId && cdpStringValue(frame?.url) === state.url) return;
3933
+ state.changed = true;
3934
+ if (allowedSanitizedUrl(frame?.url, origins) === undefined) state.leftScope = true;
3935
+ };
3936
+ })))();
3937
+ }
3938
+
3939
+ //#endregion
3940
+ //#region dist/browser/PngVisualDiff.js
3941
+ var PNG_COMPARISON_WORKING_MEMORY_BYTES, PNG_INFLATE_CHUNK_BYTES, comparePngScreenshots, parsePng, decodePng, admitEncodedInputPair, admitPngPair, inflateBufferAllowance, pngWorkingMemoryError, inflatePng, parseHeader, unfilter, expandRgba, applyFilter, paeth, dimensions, limitations, PNG_SIGNATURE;
3942
+ function init_PngVisualDiff() {
3943
+ return (init_PngVisualDiff = __esmMin((() => {
3944
+ init_analysisErrorCore();
3945
+ init_webScreenshot();
3946
+ PNG_COMPARISON_WORKING_MEMORY_BYTES = 256 * 1024 * 1024;
3947
+ PNG_INFLATE_CHUNK_BYTES = constants.Z_DEFAULT_CHUNK;
3948
+ comparePngScreenshots = (input) => {
3949
+ admitEncodedInputPair(input.before, input.after);
3950
+ const beforePlan = parsePng(input.before, "before");
3951
+ const afterPlan = parsePng(input.after, "after");
3952
+ admitPngPair(beforePlan, afterPlan);
3953
+ const before = decodePng(beforePlan);
3954
+ const after = decodePng(afterPlan);
3955
+ if (before.width !== after.width || before.height !== after.height) return {
3956
+ status: "dimension_mismatch",
3957
+ before: dimensions(before),
3958
+ after: dimensions(after),
3959
+ channel_threshold: input.channel_threshold,
3960
+ compared_pixels: 0,
3961
+ changed_pixels: null,
3962
+ changed_ratio: null,
3963
+ maximum_channel_delta: null,
3964
+ mean_absolute_channel_delta: null,
3965
+ limitations: limitations()
3966
+ };
3967
+ let changedPixels = 0;
3968
+ let maximumDelta = 0;
3969
+ let totalDelta = 0;
3970
+ for (let offset = 0; offset < before.rgba.length; offset += 4) {
3971
+ let changed = false;
3972
+ for (let channel = 0; channel < 4; channel += 1) {
3973
+ const delta = Math.abs((before.rgba[offset + channel] ?? 0) - (after.rgba[offset + channel] ?? 0));
3974
+ totalDelta += delta;
3975
+ maximumDelta = Math.max(maximumDelta, delta);
3976
+ if (delta > input.channel_threshold) changed = true;
3977
+ }
3978
+ if (changed) changedPixels += 1;
3979
+ }
3980
+ const pixels = before.width * before.height;
3981
+ const context = {
3982
+ before: dimensions(before),
3983
+ after: dimensions(after),
3984
+ channel_threshold: input.channel_threshold,
3985
+ compared_pixels: pixels,
3986
+ maximum_channel_delta: maximumDelta,
3987
+ mean_absolute_channel_delta: totalDelta / (pixels * 4),
3988
+ limitations: limitations()
3989
+ };
3990
+ if (changedPixels === 0) return {
3991
+ ...context,
3992
+ status: "identical",
3993
+ changed_pixels: 0,
3994
+ changed_ratio: 0
3995
+ };
3996
+ return {
3997
+ ...context,
3998
+ status: "different",
3999
+ changed_pixels: changedPixels,
4000
+ changed_ratio: changedPixels / pixels
4001
+ };
4002
+ };
4003
+ parsePng = (artifact, field) => {
4004
+ const bytes = decodeCanonicalBase64(artifact.data_base64);
4005
+ if (bytes === undefined || !bytes.subarray(0, 8).equals(PNG_SIGNATURE)) throw new TypeError("Invalid PNG signature");
4006
+ let offset = 8;
4007
+ let header;
4008
+ const compressed = [];
4009
+ let sawEnd = false;
4010
+ let sawPalette = false;
4011
+ let imageDataEnded = false;
4012
+ let paletteEntries = 0;
4013
+ let transparentColor;
4014
+ let sawTransparency = false;
4015
+ let unsupportedReason;
4016
+ while (offset < bytes.length) {
4017
+ if (offset + 12 > bytes.length) throw new TypeError("Truncated PNG chunk");
4018
+ const length = bytes.readUInt32BE(offset);
4019
+ if (length > 2147483647) throw new TypeError("Invalid PNG chunk length");
4020
+ const type = bytes.subarray(offset + 4, offset + 8).toString("latin1");
4021
+ const dataStart = offset + 8;
4022
+ const dataEnd = dataStart + length;
4023
+ if (dataEnd + 4 > bytes.length) throw new TypeError("Truncated PNG data");
4024
+ const data = bytes.subarray(dataStart, dataEnd);
4025
+ if (crc32(bytes.subarray(offset + 4, dataEnd)) !== bytes.readUInt32BE(dataEnd)) throw new TypeError("Invalid PNG chunk checksum");
4026
+ if (!/^[A-Za-z]{4}$/u.test(type) || type[2] !== type[2]?.toUpperCase()) throw new TypeError("Invalid PNG chunk type");
4027
+ if (type !== "IDAT" && compressed.length > 0) imageDataEnded = true;
4028
+ if (type === "IHDR") {
4029
+ if (offset !== 8 || header !== undefined) throw new TypeError("Invalid PNG header order");
4030
+ header = parseHeader(data);
4031
+ } else if (header === undefined) throw new TypeError("Invalid PNG header order");
4032
+ else if (type === "tRNS") {
4033
+ if (sawTransparency || compressed.length > 0) throw new TypeError("Invalid PNG transparency order");
4034
+ sawTransparency = true;
4035
+ if (header.colorType === 2 && data.length === 6) {
4036
+ transparentColor = [
4037
+ data.readUInt16BE(0),
4038
+ data.readUInt16BE(2),
4039
+ data.readUInt16BE(4)
4040
+ ];
4041
+ } else if (header.colorType === 0 && data.length === 2 || header.colorType === 3 && sawPalette && data.length > 0 && data.length <= paletteEntries) {
4042
+ unsupportedReason ??= "PNG transparency for this color type is not supported.";
4043
+ } else {
4044
+ throw new TypeError("Unsupported PNG transparency");
4045
+ }
4046
+ } else if (type === "PLTE") {
4047
+ if (sawPalette || sawTransparency || compressed.length > 0 || length === 0 || length > 768 || length % 3 !== 0 || header.colorType === 3 && length / 3 > 2 ** header.bitDepth || header.colorType !== 2 && header.colorType !== 3 && header.colorType !== 6) throw new TypeError("Invalid PNG palette");
4048
+ sawPalette = true;
4049
+ paletteEntries = length / 3;
4050
+ } else if (type === "IDAT") {
4051
+ if (imageDataEnded) throw new TypeError("Nonconsecutive PNG image data");
4052
+ compressed.push(data);
4053
+ } else if (type === "IEND") {
4054
+ if (length !== 0 || dataEnd + 4 !== bytes.length) throw new TypeError("Invalid PNG end chunk");
4055
+ sawEnd = true;
4056
+ break;
4057
+ } else if (/^[A-Z]/u.test(type)) {
4058
+ unsupportedReason ??= `Unsupported critical PNG chunk ${type}.`;
4059
+ }
4060
+ offset = dataEnd + 4;
4061
+ }
4062
+ if (header === undefined || !sawEnd || compressed.length === 0) throw new TypeError("Incomplete PNG");
4063
+ if (header.colorType === 3 && !sawPalette) throw new TypeError("Missing PNG palette");
4064
+ if (unsupportedReason !== undefined) throw new AnalysisUnsupportedTargetError("compare_web_screenshots", field, unsupportedReason);
4065
+ if (!header.supported) throw new AnalysisUnsupportedTargetError("compare_web_screenshots", field, "PNG encoding is not supported for pixel comparison.");
4066
+ const pixels = BigInt(header.width) * BigInt(header.height);
4067
+ const expectedRawBytes = (BigInt(header.width) * BigInt(header.channels) + 1n) * BigInt(header.height);
4068
+ return {
4069
+ bytes,
4070
+ width: header.width,
4071
+ height: header.height,
4072
+ channels: header.channels,
4073
+ compressed,
4074
+ transparentColor,
4075
+ expectedRawBytes,
4076
+ unfilteredBytes: pixels * BigInt(header.channels),
4077
+ rgbaBytes: pixels * 4n
4078
+ };
4079
+ };
4080
+ decodePng = (plan) => {
4081
+ const expected = Number(plan.expectedRawBytes);
4082
+ const raw = inflatePng(Buffer.concat(plan.compressed), expected + 1);
4083
+ if (raw.byteLength !== expected) throw new TypeError("Unexpected PNG size");
4084
+ return {
4085
+ width: plan.width,
4086
+ height: plan.height,
4087
+ rgba: expandRgba(unfilter(raw, plan.width, plan.height, plan.channels), plan.channels, plan.transparentColor)
4088
+ };
4089
+ };
4090
+ admitEncodedInputPair = (before, after) => {
4091
+ const sourceBytes = BigInt(before.bytes) + BigInt(after.bytes);
4092
+ if (sourceBytes > BigInt(PNG_COMPARISON_WORKING_MEMORY_BYTES)) throw pngWorkingMemoryError(sourceBytes, null, null);
4093
+ };
4094
+ admitPngPair = (before, after) => {
4095
+ const inputBytes = BigInt(before.bytes.byteLength + after.bytes.byteLength);
4096
+ const estimate = (current, retained) => {
4097
+ const compressedBytes = current.compressed.reduce((total, chunk) => total + BigInt(chunk.byteLength), 0n);
4098
+ const rgbaExpansion = current.channels === 3 ? current.rgbaBytes : 0n;
4099
+ return inputBytes + (retained?.rgbaBytes ?? 0n) + compressedBytes + inflateBufferAllowance(current.expectedRawBytes) + current.unfilteredBytes + rgbaExpansion;
4100
+ };
4101
+ const estimateBytes = [estimate(before, undefined), estimate(after, before)].reduce((maximum, value) => value > maximum ? value : maximum, 0n);
4102
+ if (estimateBytes > BigInt(PNG_COMPARISON_WORKING_MEMORY_BYTES)) throw pngWorkingMemoryError(estimateBytes, before, after);
4103
+ };
4104
+ inflateBufferAllowance = (expectedRawBytes) => {
4105
+ const chunkBytes = BigInt(PNG_INFLATE_CHUNK_BYTES);
4106
+ const maximumOutputBytes = expectedRawBytes + 1n;
4107
+ const roundUpToChunk = (bytes) => (bytes + chunkBytes - 1n) / chunkBytes * chunkBytes;
4108
+ const rejectedOutputChunks = roundUpToChunk(maximumOutputBytes + chunkBytes - 1n);
4109
+ const returnedOutputChunks = roundUpToChunk(maximumOutputBytes);
4110
+ const scratchChunk = expectedRawBytes % chunkBytes === 0n || maximumOutputBytes % chunkBytes === 0n ? chunkBytes : 0n;
4111
+ const concatenatedOutput = maximumOutputBytes > chunkBytes ? maximumOutputBytes : 0n;
4112
+ const returnedOutput = returnedOutputChunks + scratchChunk + concatenatedOutput;
4113
+ return rejectedOutputChunks > returnedOutput ? rejectedOutputChunks : returnedOutput;
4114
+ };
4115
+ pngWorkingMemoryError = (estimateBytes, before, after) => new AnalysisResourceConstraintError("compare_web_screenshots", "memory", "Screenshot comparison exceeds REA's 256 MiB estimated working-memory budget.", {
4116
+ boundary: "png-screenshot-comparison",
4117
+ estimated_working_memory_bytes: estimateBytes.toString(),
4118
+ maximum_working_memory_bytes: PNG_COMPARISON_WORKING_MEMORY_BYTES,
4119
+ before_dimensions: before === null ? null : {
4120
+ width: before.width,
4121
+ height: before.height
4122
+ },
4123
+ after_dimensions: after === null ? null : {
4124
+ width: after.width,
4125
+ height: after.height
4126
+ }
4127
+ }, { remediationAction: "Compare smaller screenshots or reduce their viewport dimensions before capture." });
4128
+ inflatePng = (compressed, maxOutputLength) => {
4129
+ try {
4130
+ return inflateSync(compressed, {
4131
+ maxOutputLength,
4132
+ chunkSize: PNG_INFLATE_CHUNK_BYTES
4133
+ });
4134
+ } catch (cause) {
4135
+ if (cause instanceof Error && "code" in cause && (cause.code === "Z_DATA_ERROR" || cause.code === "Z_BUF_ERROR" || cause.code === "ERR_BUFFER_TOO_LARGE")) throw new TypeError("Invalid PNG image data", { cause });
4136
+ throw cause;
4137
+ }
4138
+ };
4139
+ parseHeader = (data) => {
4140
+ if (data.byteLength !== 13) throw new TypeError("Invalid PNG header");
4141
+ const width = data.readUInt32BE(0);
4142
+ const height = data.readUInt32BE(4);
4143
+ const bitDepth = data[8] ?? 0;
4144
+ const colorType = data[9] ?? -1;
4145
+ const validDepth = colorType === 0 && [
4146
+ 1,
4147
+ 2,
4148
+ 4,
4149
+ 8,
4150
+ 16
4151
+ ].includes(bitDepth) || colorType === 2 && [8, 16].includes(bitDepth) || colorType === 3 && [
4152
+ 1,
4153
+ 2,
4154
+ 4,
4155
+ 8
4156
+ ].includes(bitDepth) || colorType === 4 && [8, 16].includes(bitDepth) || colorType === 6 && [8, 16].includes(bitDepth);
4157
+ if (width === 0 || height === 0 || width > 2147483647 || height > 2147483647 || !validDepth || data[10] !== 0 || data[11] !== 0 || data[12] !== 0 && data[12] !== 1) throw new TypeError("Invalid PNG header");
4158
+ return {
4159
+ width,
4160
+ height,
4161
+ colorType,
4162
+ bitDepth,
4163
+ interlace: data[12],
4164
+ channels: colorType === 6 ? 4 : 3,
4165
+ supported: bitDepth === 8 && (colorType === 2 || colorType === 6) && data[12] === 0
4166
+ };
4167
+ };
4168
+ unfilter = (raw, width, height, channels) => {
4169
+ const rowBytes = width * channels;
4170
+ const decoded = Buffer.alloc(rowBytes * height);
4171
+ for (let row = 0; row < height; row += 1) {
4172
+ const rawOffset = row * (rowBytes + 1);
4173
+ const outputOffset = row * rowBytes;
4174
+ const filter = raw[rawOffset];
4175
+ if (filter === undefined || filter > 4) throw new TypeError("Unsupported PNG filter");
4176
+ for (let column = 0; column < rowBytes; column += 1) {
4177
+ const source = raw[rawOffset + 1 + column] ?? 0;
4178
+ const left = column >= channels ? decoded[outputOffset + column - channels] ?? 0 : 0;
4179
+ const above = row > 0 ? decoded[outputOffset + column - rowBytes] ?? 0 : 0;
4180
+ const upperLeft = row > 0 && column >= channels ? decoded[outputOffset + column - rowBytes - channels] ?? 0 : 0;
4181
+ decoded[outputOffset + column] = applyFilter({
4182
+ filter,
4183
+ source,
4184
+ left,
4185
+ above,
4186
+ upperLeft
4187
+ });
4188
+ }
4189
+ }
4190
+ return decoded;
4191
+ };
4192
+ expandRgba = (decoded, channels, transparentColor) => {
4193
+ if (channels === 4) return decoded;
4194
+ const rgba = Buffer.alloc(decoded.length / channels * 4);
4195
+ for (let source = 0, target = 0; source < decoded.length; source += 3, target += 4) {
4196
+ rgba[target] = decoded[source] ?? 0;
4197
+ rgba[target + 1] = decoded[source + 1] ?? 0;
4198
+ rgba[target + 2] = decoded[source + 2] ?? 0;
4199
+ rgba[target + 3] = transparentColor !== undefined && transparentColor.every((value, channel) => decoded[source + channel] === value) ? 0 : 255;
4200
+ }
4201
+ return rgba;
4202
+ };
4203
+ applyFilter = (options) => {
4204
+ const { filter, source, left, above, upperLeft } = options;
4205
+ switch (filter) {
4206
+ case 0: return source;
4207
+ case 1: return source + left & 255;
4208
+ case 2: return source + above & 255;
4209
+ case 3: return source + Math.floor((left + above) / 2) & 255;
4210
+ case 4: return source + paeth(left, above, upperLeft) & 255;
4211
+ default: throw new TypeError("Unsupported PNG filter");
4212
+ }
4213
+ };
4214
+ paeth = (left, above, upperLeft) => {
4215
+ const prediction = left + above - upperLeft;
4216
+ const leftDistance = Math.abs(prediction - left);
4217
+ const aboveDistance = Math.abs(prediction - above);
4218
+ const upperLeftDistance = Math.abs(prediction - upperLeft);
4219
+ return leftDistance <= aboveDistance && leftDistance <= upperLeftDistance ? left : aboveDistance <= upperLeftDistance ? above : upperLeft;
4220
+ };
4221
+ dimensions = ({ width, height }) => ({
4222
+ width,
4223
+ height
4224
+ });
4225
+ limitations = () => [
4226
+ "Pixel comparison does not perform OCR, semantic layout analysis, or perceptual color correction.",
4227
+ "Only non-interlaced 8-bit RGB and RGBA PNG screenshots are accepted.",
4228
+ "PNG tRNS transparency is accepted only as a six-byte RGB color key; tRNS on RGBA or with another length is rejected."
4229
+ ];
4230
+ PNG_SIGNATURE = Buffer.from([
4231
+ 137,
4232
+ 80,
4233
+ 78,
4234
+ 71,
4235
+ 13,
4236
+ 10,
4237
+ 26,
4238
+ 10
4239
+ ]);
4240
+ })))();
4241
+ }
4242
+
4243
+ //#endregion
4244
+ //#region dist/browser/CdpBrowserProvider.js
4245
+ var CLEANUP_DOMAINS, CdpBrowserProvider, withTargetSession, selectTargets, authorizeTarget, scopeToTargetOrigin, providerError;
4246
+ function init_CdpBrowserProvider() {
4247
+ return (init_CdpBrowserProvider = __esmMin((() => {
4248
+ init_browserObservation$1();
4249
+ init_browserObservationSchemas();
4250
+ init_webBundleAnalyzer();
4251
+ init_webBundleAnalysis();
4252
+ init_browserSession();
4253
+ init_webMcpDiscovery();
4254
+ init_browserCaptureComparison();
4255
+ init_webScreenshot();
4256
+ init_analysisErrorBase();
4257
+ init_analysisErrorCore();
4258
+ init_browserObservationError();
4259
+ init_providerAdapterError();
4260
+ init_result();
4261
+ init_CdpEndpoint();
4262
+ init_CdpTargetSession();
4263
+ init_CdpPageCapture();
4264
+ init_WebSourceMapFetcher();
4265
+ init_CdpAuthorizedTarget();
4266
+ init_CdpObservationSession();
4267
+ init_CdpWebMcpDiscovery();
4268
+ init_CdpScreenshot();
4269
+ init_PngVisualDiff();
4270
+ init_providerIdentities();
4271
+ init_unicodeCodePointOrder();
4272
+ CLEANUP_DOMAINS = [
4273
+ "Network",
4274
+ "Debugger",
4275
+ "Runtime",
4276
+ "Page"
4277
+ ];
4278
+ CdpBrowserProvider = class {
4279
+ identity() {
4280
+ return CDP_BROWSER_PROVIDER_IDENTITY;
4281
+ }
4282
+ async listTargets(input, options = {}) {
4283
+ try {
4284
+ const endpoint = await openCdpEndpoint(input.cdp_endpoint, "list_browser_targets", options.signal);
4285
+ await endpoint.connection?.close();
4286
+ const { discovery } = endpoint;
4287
+ const selected = selectTargets(discovery, input.allowed_origins.length === 0 ? undefined : new Set(input.allowed_origins));
4288
+ return ok(browserTargetListSchema.parse({
4289
+ browser: discovery.version,
4290
+ targets: selected.allowed,
4291
+ excluded: selected.excluded,
4292
+ limitations: [
4293
+ input.allowed_origins.length === 0 ? "All page targets with supported HTTP(S) URLs are listed." : "Only page targets whose current URL matches an explicitly requested exact origin are listed.",
4294
+ ...selected.unconnectable === 0 ? [] : [`${String(selected.unconnectable)} otherwise allowed page target(s) lacked a validated direct CDP WebSocket and were excluded.`],
4295
+ ...selected.allowed.some((target) => target.attached === null) ? ["CDP discovery omitted attachment state for one or more targets; attached is reported as unknown."] : []
4296
+ ]
4297
+ }));
4298
+ } catch (cause) {
4299
+ return err(providerError(cause, "list_browser_targets", options.signal));
4300
+ }
4301
+ }
4302
+ async inspectPage(input, options = {}) {
4303
+ try {
4304
+ const captured = await this.#capture(input, options, "inspect_web_page");
4305
+ return ok(webPageInspectionSchema.parse(captured.inspection));
4306
+ } catch (cause) {
4307
+ return err(providerError(cause, "inspect_web_page", options.signal));
4308
+ }
4309
+ }
4310
+ async analyzeBundle(input, options = {}) {
4311
+ try {
4312
+ const captured = await this.#capture(input, options, "analyze_web_bundle");
4313
+ const sourceMaps = input.fetch_source_maps ? await fetchWebSourceMaps(captured.sourceMapRequests, {
4314
+ ...input,
4315
+ allowed_origins: input.allowed_origins.length > 0 ? input.allowed_origins : [captured.inspection.target.origin]
4316
+ }, options.signal) : undefined;
4317
+ return ok(webBundleAnalysisSchema.parse(analyzeCapturedWebBundle(captured.inspection, sourceMaps)));
4318
+ } catch (cause) {
4319
+ if (options.signal?.aborted === true && cause === options.signal.reason) {
4320
+ return err(new AnalysisCancelledError("analyze_web_bundle", { cause }));
4321
+ }
4322
+ return err(providerError(cause, "analyze_web_bundle", options.signal));
4323
+ }
4324
+ }
4325
+ async observeSession(input, options = {}) {
4326
+ try {
4327
+ return ok(webObservationSessionSchema.parse(await withTargetSession(input, "observe_web_session", options, observeCdpSession)));
4328
+ } catch (cause) {
4329
+ return err(providerError(cause, "observe_web_session", options.signal));
4330
+ }
4331
+ }
4332
+ async discoverWebMcpTools(input, options = {}) {
4333
+ try {
4334
+ return ok(webMcpDiscoverySchema.parse(await withTargetSession(input, "discover_webmcp_tools", options, discoverWebMcp)));
4335
+ } catch (cause) {
4336
+ return err(providerError(cause, "discover_webmcp_tools", options.signal));
4337
+ }
4338
+ }
4339
+ async compareCaptures(input) {
4340
+ try {
4341
+ return ok(browserCaptureComparisonSchema.parse(compareBrowserCaptures(input)));
4342
+ } catch (cause) {
4343
+ return err(providerError(cause, "compare_web_captures"));
4344
+ }
4345
+ }
4346
+ async captureScreenshot(input, options = {}) {
4347
+ try {
4348
+ return ok(webScreenshotSchema.parse(await withTargetSession(input, "capture_web_screenshot", options, captureCdpScreenshot)));
4349
+ } catch (cause) {
4350
+ return err(providerError(cause, "capture_web_screenshot", options.signal));
4351
+ }
4352
+ }
4353
+ async compareScreenshots(input) {
4354
+ try {
4355
+ return ok(webScreenshotDiffSchema.parse(comparePngScreenshots(input)));
4356
+ } catch (cause) {
4357
+ if (cause instanceof TypeError) return err(new AnalysisInputError("compare_web_screenshots", { cause }, [{
4358
+ path: [],
4359
+ reason: "invalid_format",
4360
+ message: cause.message
4361
+ }]));
4362
+ return err(providerError(cause, "compare_web_screenshots"));
4363
+ }
4364
+ }
4365
+ async #capture(input, options, operation) {
4366
+ return await withTargetSession(input, operation, options, async (session) => await capturePage({
4367
+ ...session,
4368
+ operation
4369
+ }));
4370
+ }
4371
+ };
4372
+ withTargetSession = async (input, operation, options, work) => {
4373
+ const endpoint = await openCdpEndpoint(input.cdp_endpoint, operation, options.signal);
4374
+ let targetSession;
4375
+ let output;
4376
+ try {
4377
+ const target = authorizeTarget(endpoint.discovery, input);
4378
+ const scopedInput = scopeToTargetOrigin(input, target);
4379
+ targetSession = endpoint.connection === undefined ? await openCdpTargetSession(endpoint.discovery, target, operation, options.signal) : await attachCdpTargetSession(endpoint.connection, target, operation, options.signal);
4380
+ output = await work({
4381
+ connection: targetSession.connection,
4382
+ sessionId: targetSession.sessionId,
4383
+ discovery: endpoint.discovery,
4384
+ target,
4385
+ input: scopedInput,
4386
+ ...options.signal === undefined ? {} : { signal: options.signal },
4387
+ ...options.progress === undefined ? {} : { progress: options.progress }
4388
+ });
4389
+ } finally {
4390
+ if (targetSession !== undefined) await closeCdpTargetSession(targetSession, CLEANUP_DOMAINS, options.signal);
4391
+ await endpoint.connection?.close();
4392
+ }
4393
+ if (options.signal?.aborted === true) throw new AnalysisCancelledError(operation, { cause: options.signal.reason });
4394
+ return output;
4395
+ };
4396
+ selectTargets = (discovery, allowedOrigins) => {
4397
+ const allowed = [];
4398
+ let disallowedOrigin = 0;
4399
+ let unsupportedUrl = 0;
4400
+ let nonPage = 0;
4401
+ let unconnectable = 0;
4402
+ for (const target of discovery.targets) {
4403
+ if (target.type !== "page") {
4404
+ nonPage += 1;
4405
+ continue;
4406
+ }
4407
+ const url = sanitizeBrowserUrl(target.url);
4408
+ if (url.origin === null) {
4409
+ unsupportedUrl += 1;
4410
+ continue;
4411
+ }
4412
+ if (allowedOrigins !== undefined && !allowedOrigins.has(url.origin)) {
4413
+ disallowedOrigin += 1;
4414
+ continue;
4415
+ }
4416
+ if (!hasCdpTargetWebSocket(discovery, target)) {
4417
+ unconnectable += 1;
4418
+ continue;
4419
+ }
4420
+ allowed.push({
4421
+ target_id: target.id,
4422
+ type: target.type,
4423
+ title: target.title,
4424
+ url: url.url,
4425
+ origin: url.origin,
4426
+ attached: target.attached
4427
+ });
4428
+ }
4429
+ allowed.sort((left, right) => compareUnicodeCodePoints(left.target_id, right.target_id));
4430
+ return {
4431
+ allowed,
4432
+ excluded: {
4433
+ disallowed_origin: disallowedOrigin,
4434
+ unsupported_url: unsupportedUrl,
4435
+ non_page: nonPage
4436
+ },
4437
+ unconnectable
4438
+ };
4439
+ };
4440
+ authorizeTarget = (discovery, input) => {
4441
+ return authorizeCdpTarget(discovery, input, "inspect_web_page").target;
4442
+ };
4443
+ scopeToTargetOrigin = (input, target) => {
4444
+ if (input.allowed_origins.length > 0) return input;
4445
+ const origin = sanitizeBrowserUrl(target.url).origin;
4446
+ if (origin === null) throw new BrowserObservationError("inspect_web_page", "target_not_allowed");
4447
+ return {
4448
+ ...input,
4449
+ allowed_origins: [origin]
4450
+ };
4451
+ };
4452
+ providerError = (cause, operation, signal) => cause instanceof BrowserObservationError && cause.operation !== operation ? new BrowserObservationError(operation, cause.reason, { cause }) : cause instanceof AnalysisError ? cause : signal?.aborted === true ? new AnalysisCancelledError(operation, { cause }) : new ProviderAdapterError(CDP_BROWSER_PROVIDER_IDENTITY.id, operation, { cause });
4453
+ })))();
4454
+ }
4455
+
4456
+ //#endregion
4457
+ //#region dist/composition/browserObservation.js
4458
+ var createBrowserObservationProvider;
4459
+ function init_browserObservation() {
4460
+ return (init_browserObservation = __esmMin((() => {
4461
+ init_CdpBrowserProvider();
4462
+ createBrowserObservationProvider = () => new CdpBrowserProvider();
4463
+ })))();
4464
+ }
4465
+
4466
+ //#endregion
4467
+ init_browserObservation();
4468
+ export { createBrowserObservationProvider };