rea-agents 6.4.0 → 6.7.0

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