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