rea-agents 6.4.0 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1420) hide show
  1. package/DISCLAIMER.md +136 -0
  2. package/README.md +76 -16
  3. package/THIRD_PARTY_NOTICES.md +135 -0
  4. package/bridge/android/ReaJadxBridge.java +281 -25
  5. package/bridge/cutter/rea_bridge.py +825 -0
  6. package/bridge/ghidra/ReaGhidraAnalysisOptions.java +38 -0
  7. package/bridge/ghidra/ReaGhidraBridge.java +1232 -142
  8. package/bridge/ghidra/ReaGhidraBundleActivator.java +14 -0
  9. package/bridge/ghidra/ReaGhidraMipsSoftFloat.java +176 -0
  10. package/bridge/ghidra/ReaGhidraPrepareRaw.java +49 -0
  11. package/bridge/hopper_bridge.py +111 -69
  12. package/bridge/mitmproxy/capture.py +189 -13
  13. package/bridge/native/rea_lldb_tracer.py +88 -10
  14. package/bridge/process/ProcessRunTokenReader.swift +76 -34
  15. package/bridge/pwndbg/core_context.py +15 -2
  16. package/bridge/pwntools/layout_impl.py +5 -0
  17. package/bridge/pwntools/recorded_crash_impl.py +31 -10
  18. package/dist/adb/AdbCommand.js +148 -0
  19. package/dist/adb/AdbConfiguration.js +41 -7
  20. package/dist/adb/AdbDeviceOutput.js +59 -37
  21. package/dist/adb/AdbDirectoryListing.js +80 -0
  22. package/dist/adb/AdbHostFileName.js +34 -0
  23. package/dist/adb/AdbInputSnapshot.js +126 -0
  24. package/dist/adb/AdbProvider.js +1106 -346
  25. package/dist/adb/AdbShellOutput.js +146 -77
  26. package/dist/android/AndroidTargetSnapshot.js +7 -7
  27. package/dist/android/JadxAnalysis.js +53 -33
  28. package/dist/android/JadxConfiguration.js +283 -145
  29. package/dist/android/JadxDoctor.js +123 -0
  30. package/dist/android/JadxFailure.js +154 -0
  31. package/dist/android/JadxInterruption.js +13 -0
  32. package/dist/android/JadxJavaProbe.js +246 -0
  33. package/dist/android/JadxMcpTransport.js +53 -18
  34. package/dist/android/JadxProtocol.js +43 -2
  35. package/dist/android/JadxProvider.js +183 -102
  36. package/dist/android/JadxRelease.js +17 -2
  37. package/dist/android/JadxSession.js +35 -14
  38. package/dist/android/JadxWorkspaceRoot.js +157 -0
  39. package/dist/apktool/ApktoolCommandCleanup.js +134 -0
  40. package/dist/apktool/ApktoolCommandOutput.js +22 -0
  41. package/dist/apktool/ApktoolConfiguration.js +306 -45
  42. package/dist/apktool/ApktoolDecodeOutput.js +131 -42
  43. package/dist/apktool/ApktoolDecodedInventory.js +52 -0
  44. package/dist/apktool/ApktoolProvider.js +296 -340
  45. package/dist/apktool/ApktoolStringTables.js +178 -0
  46. package/dist/apktool/ApktoolWorkspace.js +162 -0
  47. package/dist/application/AnalysisContextQueries.js +5 -8
  48. package/dist/application/AnalysisDocument.js +19 -4
  49. package/dist/application/AnalysisProvider.js +36 -18
  50. package/dist/application/AppBundleExecutable.js +16 -9
  51. package/dist/application/BinaryTargetResolver.js +204 -40
  52. package/dist/application/BrowserEvidence.js +1 -1
  53. package/dist/application/BrowserObservationService.js +54 -9
  54. package/dist/application/BrowserScenarioCaptureService.js +26 -7
  55. package/dist/application/CallPathTracing.js +52 -13
  56. package/dist/application/CapabilityInventory.js +182 -36
  57. package/dist/application/ClaudeDesktopConfigLocation.js +152 -0
  58. package/dist/application/ClientConfigurationCleanup.js +73 -0
  59. package/dist/application/ClientConfigurationDocument.js +270 -151
  60. package/dist/application/ClientConfigurationFiles.js +51 -14
  61. package/dist/application/ClientConfigurationPublication.js +167 -0
  62. package/dist/application/ClientRegistrationEnvironment.js +40 -4
  63. package/dist/application/ClientRegistrationIdentity.js +112 -32
  64. package/dist/application/ClientRegistrationStatus.js +280 -84
  65. package/dist/application/DirectAnalysis.js +98 -30
  66. package/dist/application/DirectAnalysisCleanup.js +5 -1
  67. package/dist/application/DirectAnalysisStatus.js +13 -1
  68. package/dist/application/Doctor.js +192 -37
  69. package/dist/application/DoctorDiagnostics.js +59 -16
  70. package/dist/application/DoctorProviderIds.js +8 -0
  71. package/dist/application/DoctorScope.js +11 -2
  72. package/dist/application/DshCordisPatch.js +355 -0
  73. package/dist/application/DshCordisYaml.js +155 -0
  74. package/dist/application/EnhancedLiteralTracing.js +30 -16
  75. package/dist/application/EnhancedToolTypes.js +0 -1
  76. package/dist/application/EnhancedTools.js +154 -56
  77. package/dist/application/EvidenceBundleCommands.js +30 -7
  78. package/dist/application/EvidenceBundleFiles.js +29 -7
  79. package/dist/application/FunctionAnalysisEvidence.js +3 -0
  80. package/dist/application/GeminiClientSettings.js +25 -13
  81. package/dist/application/HermesClientHome.js +20 -0
  82. package/dist/application/HermesConfigurationYaml.js +312 -0
  83. package/dist/application/HopperDownload.js +11 -3
  84. package/dist/application/HopperReleaseFeed.js +71 -0
  85. package/dist/application/InventoryProjectionEvidence.js +0 -1
  86. package/dist/application/InvestigationProviders.js +14 -3
  87. package/dist/application/JsonFiles.js +110 -20
  88. package/dist/application/JsonInputFile.js +220 -62
  89. package/dist/application/LinuxHopper.js +218 -115
  90. package/dist/application/LinuxHopperPublisher.js +656 -0
  91. package/dist/application/MacHopper.js +203 -83
  92. package/dist/application/MacHopperPaths.js +40 -0
  93. package/dist/application/{MipsElfAbiFlags.js → MipsElfMetadata.js} +71 -10
  94. package/dist/application/MipsElfSharedLoad.js +164 -0
  95. package/dist/application/MipsGnuAttributes.js +90 -0
  96. package/dist/application/MsixPackageStorage.js +140 -0
  97. package/dist/application/ProgressReporter.js +1 -1
  98. package/dist/application/ProviderOperationExecution.js +15 -14
  99. package/dist/application/ReconstructionCoverageService.js +0 -1
  100. package/dist/application/ReconstructionObligationCandidates.js +20 -4
  101. package/dist/application/ReconstructionObligationLedgerDiagnostics.js +2 -2
  102. package/dist/application/ReconstructionObligationLedgerEvaluation.js +19 -33
  103. package/dist/application/ReconstructionObligationLedgerProjection.js +3 -72
  104. package/dist/application/ReconstructionObligationLedgerService.js +6 -2
  105. package/dist/application/ReconstructionObligationOriginalCases.js +10 -1
  106. package/dist/application/ReferenceSourceImport.js +24 -8
  107. package/dist/application/ReferenceSourceImportEntries.js +180 -37
  108. package/dist/application/ReferenceSourceImportPolicy.js +5 -3
  109. package/dist/application/ReferenceSourceImportTypes.js +0 -1
  110. package/dist/application/ReferenceSourceVcsAdapter.js +36 -17
  111. package/dist/application/RegularFileRead.js +117 -70
  112. package/dist/application/Setup.js +59 -21
  113. package/dist/application/SetupClientConfiguration.js +301 -66
  114. package/dist/application/SetupClients.js +25 -10
  115. package/dist/application/SetupHost.js +149 -51
  116. package/dist/application/SetupInstallFailure.js +58 -3
  117. package/dist/application/SetupPlan.js +94 -55
  118. package/dist/application/SetupRecoveryBackup.js +93 -0
  119. package/dist/application/SetupRegistrationEnvironment.js +14 -1
  120. package/dist/application/SetupSkill.js +303 -76
  121. package/dist/application/SourceLimitations.js +35 -0
  122. package/dist/application/SupportedClients.js +166 -32
  123. package/dist/application/TypeScriptEmittedSourceCandidates.js +26 -0
  124. package/dist/application/Uninstall.js +356 -110
  125. package/dist/application/UninstallFailure.js +14 -0
  126. package/dist/application/Update.js +54 -25
  127. package/dist/application/UpdateCommandProgress.js +66 -0
  128. package/dist/application/UpdateFailure.js +17 -0
  129. package/dist/application/UpdateMaintenance.js +18 -31
  130. package/dist/application/UpdateRuntime.js +198 -54
  131. package/dist/application/WebModuleTraceService.js +42 -22
  132. package/dist/application/WebNetworkCaptureService.js +24 -12
  133. package/dist/application/WebRuntimeService.js +41 -8
  134. package/dist/application/WebScriptExportService.js +6 -4
  135. package/dist/application/WebSourceLocationService.js +23 -8
  136. package/dist/application/WindowsCapabilities.js +18 -15
  137. package/dist/application/WorkflowEvidence.js +31 -1
  138. package/dist/application/analysisView/AnalysisViewService.js +46 -11
  139. package/dist/application/android/AndroidAnalysisService.js +5 -4
  140. package/dist/application/android/AndroidPackageInspection.js +25 -0
  141. package/dist/application/android/AndroidSearchEvidenceSummary.js +98 -0
  142. package/dist/application/artifacts/ArtifactComparisonEvidence.js +32 -0
  143. package/dist/application/binary/AnalysisProviderEvaluation.js +14 -11
  144. package/dist/application/binary/AnalysisProviderRegistry.js +365 -60
  145. package/dist/application/binary/AnalysisSnapshotCache.js +41 -20
  146. package/dist/application/binary/AnalysisSnapshotFiles.js +75 -9
  147. package/dist/application/binary/BinarySession.js +308 -117
  148. package/dist/application/binary/BinarySessionExecution.js +5 -4
  149. package/dist/application/binary/BinarySessionOpen.js +13 -6
  150. package/dist/application/binary/BinarySessionRecords.js +36 -7
  151. package/dist/application/binary/BinarySessionStatus.js +96 -27
  152. package/dist/application/binary/BinaryTargetSummary.js +9 -0
  153. package/dist/application/binary/CompositeProvider.js +116 -28
  154. package/dist/application/binary/LazyAnalysisProvider.js +6 -66
  155. package/dist/application/binary/SessionProviderRouter.js +16 -4
  156. package/dist/application/binaryDiagnostics/BinaryLayoutService.js +14 -5
  157. package/dist/application/binaryDiagnostics/PeResourcesService.js +25 -5
  158. package/dist/application/binaryDiagnostics/RecordedCrashService.js +17 -7
  159. package/dist/application/captures/PacketCaptureService.js +84 -0
  160. package/dist/application/closeOwnedWebResources.js +37 -0
  161. package/dist/application/electron/ElectronFusePort.js +1 -0
  162. package/dist/application/electron/ElectronFuseService.js +45 -0
  163. package/dist/application/evm/EvmInterfaceEvidence.js +11 -0
  164. package/dist/application/evm/EvmInterfaceService.js +5 -15
  165. package/dist/application/firmware/FirmwareAnalysisService.js +4 -3
  166. package/dist/application/flutter/DartAotInspection.js +26 -0
  167. package/dist/application/flutter/FlutterBuildAnalysisPort.js +1 -0
  168. package/dist/application/flutter/FlutterBuildAnalysisService.js +13 -0
  169. package/dist/application/frida/FridaInstrumentationPort.js +8 -0
  170. package/dist/application/frida/FridaInstrumentationService.js +310 -0
  171. package/dist/application/frida/fridaInputErrors.js +17 -0
  172. package/dist/application/go/GoBinaryPort.js +1 -0
  173. package/dist/application/go/GoBinaryService.js +79 -0
  174. package/dist/application/harmony/HarmonyApplicationService.js +17 -0
  175. package/dist/application/investigation/EvidenceLedger.js +43 -18
  176. package/dist/application/investigation/InvestigationRecords.js +12 -21
  177. package/dist/application/investigation/UnknownEvidence.js +22 -18
  178. package/dist/application/javascript/ElectronActiveObservationService.js +55 -25
  179. package/dist/application/javascript/ElectronBoundaryAnalysis.js +17 -3
  180. package/dist/application/javascript/ElectronBoundaryGraph.js +2 -0
  181. package/dist/application/javascript/ElectronBoundaryGraphCallPaths.js +144 -0
  182. package/dist/application/javascript/ElectronBoundaryGraphIpc.js +26 -7
  183. package/dist/application/javascript/ElectronBoundaryGraphNative.js +1 -1
  184. package/dist/application/javascript/ElectronBoundaryGraphWindows.js +61 -11
  185. package/dist/application/javascript/ElectronEvidence.js +1 -2
  186. package/dist/application/javascript/ElectronObservationService.js +41 -8
  187. package/dist/application/javascript/JavaScriptApplicationEvidence.js +21 -0
  188. package/dist/application/javascript/JavaScriptApplicationService.js +29 -14
  189. package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +0 -1
  190. package/dist/application/javascript/JavaScriptArtifactAnalysis.js +119 -49
  191. package/dist/application/javascript/JavaScriptArtifactAnalysisTypes.js +30 -1
  192. package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +51 -21
  193. package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +31 -7
  194. package/dist/application/javascript/JavaScriptArtifactGraphContext.js +28 -6
  195. package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +25 -14
  196. package/dist/application/javascript/JavaScriptArtifactGraphEvidence.js +3 -3
  197. package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +186 -50
  198. package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +173 -14
  199. package/dist/application/javascript/JavaScriptArtifactPathResolution.js +959 -188
  200. package/dist/application/javascript/JavaScriptArtifactReconstruction.js +57 -32
  201. package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +2 -0
  202. package/dist/application/javascript/JavaScriptModuleRelationships.js +34 -12
  203. package/dist/application/javascript/JavaScriptRecoveryService.js +29 -9
  204. package/dist/application/javascript/JavaScriptRuntimeObservationEvidence.js +1 -2
  205. package/dist/application/javascript/JavaScriptRuntimeObservationService.js +33 -9
  206. package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +0 -1
  207. package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +4 -5
  208. package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +138 -43
  209. package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +13 -4
  210. package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +23 -3
  211. package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +18 -5
  212. package/dist/application/javascript/JavaScriptSemanticGraphElectronProjection.js +67 -0
  213. package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +4 -6
  214. package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +2 -3
  215. package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +2 -3
  216. package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +5 -8
  217. package/dist/application/javascript/JavaScriptSemanticTraceService.js +0 -1
  218. package/dist/application/managed/ManagedApplicationGraphService.js +0 -1
  219. package/dist/application/managed/ManagedMemberComparisonService.js +72 -54
  220. package/dist/application/managed/ManagedNativeVerificationService.js +0 -1
  221. package/dist/application/managed/ManagedReconstructionService.js +0 -1
  222. package/dist/application/native/NativeCallRoutes.js +78 -41
  223. package/dist/application/native/NativeDispatchMetadataInspection.js +6 -2
  224. package/dist/application/native/NativeUiActionTrace.js +43 -22
  225. package/dist/application/native/NativeValueTrace.js +65 -23
  226. package/dist/application/pcap/PcapAnalysisPort.js +1 -0
  227. package/dist/application/pcap/PcapAnalysisService.js +24 -0
  228. package/dist/application/process/ProcessCli.js +33 -13
  229. package/dist/application/reverse/ReverseEngineeringCommandPort.js +1 -0
  230. package/dist/application/reverse/ReverseEngineeringService.js +688 -0
  231. package/dist/application/rust/RustBinaryPort.js +1 -0
  232. package/dist/application/rust/RustBinaryService.js +82 -0
  233. package/dist/application/signals/SignalRecordingService.js +84 -0
  234. package/dist/application/sqlite/SqliteDatabaseCapability.js +30 -0
  235. package/dist/application/sqlite/SqliteDatabasePort.js +1 -0
  236. package/dist/application/sqlite/SqliteDatabaseService.js +76 -0
  237. package/dist/application/wasm/WasmArtifactPort.js +1 -0
  238. package/dist/application/wasm/WasmArtifactService.js +76 -0
  239. package/dist/application/wasm/WasmInterfaceComparisonService.js +188 -0
  240. package/dist/artifacts/AnalysisCleanupLease.js +119 -0
  241. package/dist/artifacts/ArtifactFileOperation.js +150 -0
  242. package/dist/artifacts/ArtifactHash.js +15 -3
  243. package/dist/artifacts/ArtifactPaths.js +4 -7
  244. package/dist/artifacts/ArtifactProvider.js +24 -9
  245. package/dist/artifacts/ArtifactReader.js +63 -5
  246. package/dist/artifacts/ArtifactResourceScope.js +92 -9
  247. package/dist/artifacts/AsarArtifactReader.js +186 -120
  248. package/dist/artifacts/AsarEntryStream.js +49 -17
  249. package/dist/artifacts/AsarListing.js +78 -0
  250. package/dist/artifacts/DirectoryArtifactReader.js +119 -28
  251. package/dist/artifacts/MachOSliceArtifactReader.js +153 -23
  252. package/dist/artifacts/NativeDmgArtifactReader.js +264 -62
  253. package/dist/artifacts/OrderedReads.js +57 -0
  254. package/dist/artifacts/SafeOutputTree.js +24 -7
  255. package/dist/artifacts/SafeOutputTreeCreationFailure.js +1 -0
  256. package/dist/artifacts/SafeOutputTreeReadback.js +10 -16
  257. package/dist/artifacts/ZipArtifactReader.js +150 -25
  258. package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +79 -68
  259. package/dist/artifacts/apple/DylibFileAccess.js +106 -0
  260. package/dist/artifacts/apple/DylibResolutionReader.js +72 -157
  261. package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +108 -29
  262. package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +81 -28
  263. package/dist/artifacts/apple/KeyedArchiveReader.js +23 -13
  264. package/dist/artifacts/apple/MachoLoadCommandReader.js +77 -61
  265. package/dist/artifacts/apple/NibArchive.js +11 -4
  266. package/dist/artifacts/apple/PlistNumberLiterals.js +106 -118
  267. package/dist/artifacts/extraction/ArtifactExtraction.js +21 -19
  268. package/dist/artifacts/hostExecutableMarking.js +16 -0
  269. package/dist/artifacts/inventory/ArtifactGraphConstruction.js +139 -41
  270. package/dist/artifacts/inventory/classify.js +36 -17
  271. package/dist/artifacts/inventory/hashStableRootArtifact.js +14 -7
  272. package/dist/artifacts/inventory/reader.js +36 -21
  273. package/dist/artifacts/inventory/scanCanonical.js +27 -21
  274. package/dist/artifacts/inventory/scanReader.js +36 -10
  275. package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +166 -8
  276. package/dist/artifacts/readArtifactFileChunks.js +9 -0
  277. package/dist/artifacts/readStableArtifact.js +13 -11
  278. package/dist/browser/BrowserProcessStartup.js +20 -9
  279. package/dist/browser/BrowserScenarioPartialObservation.js +74 -92
  280. package/dist/browser/BrowserScenarioSecrets.js +176 -46
  281. package/dist/browser/CdpBrowserProvider.js +124 -102
  282. package/dist/browser/CdpCaptureDocuments.js +232 -102
  283. package/dist/browser/CdpCaptureDomSvg.js +80 -76
  284. package/dist/browser/CdpCaptureEventBodyShapes.js +9 -5
  285. package/dist/browser/CdpCaptureEventHandlers.js +23 -12
  286. package/dist/browser/CdpCaptureEvents.js +49 -10
  287. package/dist/browser/CdpCaptureStorage.js +22 -5
  288. package/dist/browser/CdpCaptureStorageFingerprints.js +54 -11
  289. package/dist/browser/CdpCaptureValues.js +12 -1
  290. package/dist/browser/CdpConnection.js +135 -30
  291. package/dist/browser/CdpElectronInspection.js +74 -64
  292. package/dist/browser/CdpElectronProvider.js +63 -6
  293. package/dist/browser/CdpElectronScriptEvents.js +4 -1
  294. package/dist/browser/CdpElectronScripts.js +4 -6
  295. package/dist/browser/CdpElectronWorkers.js +20 -4
  296. package/dist/browser/CdpEndpoint.js +143 -17
  297. package/dist/browser/CdpObservationSession.js +24 -8
  298. package/dist/browser/CdpPageCapture.js +68 -17
  299. package/dist/browser/CdpPageCaptureScripts.js +18 -13
  300. package/dist/browser/CdpPageCaptureWorkers.js +46 -11
  301. package/dist/browser/CdpSafeMetadata.js +32 -24
  302. package/dist/browser/CdpScreenshot.js +5 -14
  303. package/dist/browser/CdpSnapshotNodes.js +103 -0
  304. package/dist/browser/CdpSnapshotStrings.js +15 -0
  305. package/dist/browser/CdpTargetSession.js +76 -7
  306. package/dist/browser/CdpTargetSessionOwner.js +198 -0
  307. package/dist/browser/CdpWebMcpDiscovery.js +23 -6
  308. package/dist/browser/ElectronCaptureCleanup.js +82 -0
  309. package/dist/browser/ElectronProcessCleanup.js +91 -0
  310. package/dist/browser/PlaywrightBrowserScenarioProvider.js +75 -20
  311. package/dist/browser/PlaywrightElectronActiveActions.js +57 -9
  312. package/dist/browser/PlaywrightElectronActiveFuses.js +86 -0
  313. package/dist/browser/PlaywrightElectronActiveProjection.js +21 -4
  314. package/dist/browser/PlaywrightElectronActiveProvider.js +237 -175
  315. package/dist/browser/PlaywrightExecutionBoundary.js +6 -4
  316. package/dist/browser/PlaywrightScenarioBrowser.js +240 -91
  317. package/dist/browser/PlaywrightScenarioEvents.js +287 -38
  318. package/dist/browser/PlaywrightScenarioServiceWorkers.js +336 -0
  319. package/dist/browser/PlaywrightScenarioSession.js +151 -46
  320. package/dist/browser/PlaywrightScenarioStorage.js +15 -7
  321. package/dist/browser/StructuredFieldToken.js +53 -0
  322. package/dist/browser/WebArtifactCleanup.js +53 -0
  323. package/dist/browser/WebSourceMapFetcher.js +181 -89
  324. package/dist/browser/assets/LocalWebScriptArtifacts.js +24 -3
  325. package/dist/browser/assets/PublishWebScripts.js +13 -2
  326. package/dist/browser/assets/ScenarioScriptCapture.js +2 -1
  327. package/dist/browser/assets/WebArtifactReads.js +15 -3
  328. package/dist/browser/assets/WebSourceLocationArtifacts.js +47 -3
  329. package/dist/browser/execution/CdpRuntimeSession.js +36 -7
  330. package/dist/browser/execution/CdpWebRuntimeProvider.js +22 -4
  331. package/dist/browser/history/CaptureFailures.js +29 -10
  332. package/dist/browser/history/CaptureFormatError.js +2 -2
  333. package/dist/browser/history/{HarJson.js → CaptureJson.js} +14 -4
  334. package/dist/browser/history/CaptureRedaction.js +16 -3
  335. package/dist/browser/history/CaptureRelease.js +20 -2
  336. package/dist/browser/history/HarCapture.js +54 -30
  337. package/dist/browser/history/HarSchema.js +36 -36
  338. package/dist/browser/history/HistoricalCaptureDecoder.js +93 -25
  339. package/dist/browser/history/NodeCaptureAdapter.js +48 -0
  340. package/dist/browser/history/{HarCaptureProcess.js → NodeCaptureProcess.js} +18 -9
  341. package/dist/browser/history/QlogCapture.js +385 -0
  342. package/dist/browser/history/SazCapture.js +130 -0
  343. package/dist/browser/history/SazHttp.js +61 -0
  344. package/dist/browser/history/SazMetadata.js +55 -0
  345. package/dist/browser/history/SazProjection.js +90 -0
  346. package/dist/browser/modules/NativeModuleResolver.js +248 -131
  347. package/dist/browser/modules/WebModuleArtifacts.js +49 -3
  348. package/dist/browser/network/PlaywrightNetworkContent.js +67 -9
  349. package/dist/browser/network/PlaywrightScenarioNetwork.js +249 -26
  350. package/dist/captures/TsharkCaptureProvider.js +377 -0
  351. package/dist/captures/parseFieldDiscovery.js +66 -0
  352. package/dist/captures/parsePacketOutput.js +21 -0
  353. package/dist/catalogIdentity.js +58 -42
  354. package/dist/cli/adbCommands.js +20 -21
  355. package/dist/cli/analysisViewCommands.js +1 -1
  356. package/dist/cli/androidCommands.js +13 -16
  357. package/dist/cli/apktoolCommands.js +14 -25
  358. package/dist/cli/applicationCommands.js +44 -17
  359. package/dist/cli/artifactCommands.js +1 -1
  360. package/dist/cli/binaryDiagnosticsCommands.js +17 -13
  361. package/dist/cli/browserAdvancedCommands.js +46 -26
  362. package/dist/cli/browserCommands.js +59 -33
  363. package/dist/cli/captureCommands.js +72 -0
  364. package/dist/cli/cliResultOutput.js +274 -0
  365. package/dist/cli/coreBinaryCommands.js +77 -30
  366. package/dist/cli/coreNativeCommands.js +53 -31
  367. package/dist/cli/cutterCommands.js +88 -0
  368. package/dist/cli/electronCommands.js +76 -13
  369. package/dist/cli/evmCommands.js +9 -19
  370. package/dist/cli/finishAnalysisCommand.js +52 -0
  371. package/dist/cli/firmwareCommands.js +20 -50
  372. package/dist/cli/flutterCommands.js +53 -0
  373. package/dist/cli/fridaCommands.js +219 -0
  374. package/dist/cli/goCommands.js +20 -0
  375. package/dist/cli/interactiveSetup.js +11 -1
  376. package/dist/cli/javascriptApplicationAnalysis.js +1 -1
  377. package/dist/cli/javascriptRecoveryCommands.js +18 -23
  378. package/dist/cli/jebCommands.js +2 -14
  379. package/dist/cli/jsonOutput.js +2 -2
  380. package/dist/cli/managedCommands.js +31 -3
  381. package/dist/cli/options.js +26 -2
  382. package/dist/cli/pcapCommands.js +29 -0
  383. package/dist/cli/processCommands.js +1 -1
  384. package/dist/cli/reverseEngineeringCommands.js +268 -0
  385. package/dist/cli/rustCommands.js +20 -0
  386. package/dist/cli/setupCommands.js +41 -12
  387. package/dist/cli/signalCommands.js +72 -0
  388. package/dist/cli/sqliteCommands.js +52 -0
  389. package/dist/cli/utilityCommands.js +116 -74
  390. package/dist/cli/wasmCommands.js +50 -0
  391. package/dist/cli/webModuleCommands.js +27 -38
  392. package/dist/cli/webNetworkCaptureCommands.js +10 -9
  393. package/dist/cli/webRuntimeCommands.js +15 -6
  394. package/dist/cli/webSourceLocationCommands.js +14 -33
  395. package/dist/cli-runtime/AnalysisCleanupLease-CWfTGYKd.js +103 -0
  396. package/dist/cli-runtime/AnalysisProvider-BGrYaMVo.js +38 -0
  397. package/dist/cli-runtime/AnalysisSnapshotCache-BjRlXeUS.js +711 -0
  398. package/dist/cli-runtime/ArtifactFileOperation-Dg4BcoEM.js +122 -0
  399. package/dist/cli-runtime/ArtifactReader-DMwm42bk.js +78 -0
  400. package/dist/cli-runtime/ArtifactResourceScope-CokZGcII.js +175 -0
  401. package/dist/cli-runtime/AsarHeader-BxwU17DJ.js +31 -0
  402. package/dist/cli-runtime/BinarySessionStatus-DRhjr7Vb.js +212 -0
  403. package/dist/cli-runtime/BinaryTargetResolver-tuCTjBlQ.js +1238 -0
  404. package/dist/cli-runtime/BoundedFileBytes-DRtiQNAQ.js +43 -0
  405. package/dist/cli-runtime/CdpTargetSession-CQ08KHbh.js +925 -0
  406. package/dist/cli-runtime/ClientConfigPath-Dn-V_GUf.js +255 -0
  407. package/dist/cli-runtime/ClientConfigurationDocument-C9T8MNGc.js +2021 -0
  408. package/dist/cli-runtime/ClientRegistrationStatus-PnD29RTX.js +585 -0
  409. package/dist/cli-runtime/CurrentEntrypointPath-m7QCIVN0.js +14 -0
  410. package/dist/cli-runtime/DirectAnalysis-C5NyUryV.js +581 -0
  411. package/dist/cli-runtime/DirectoryArtifactReader-CokAJ8vo.js +448 -0
  412. package/dist/cli-runtime/Doctor-DrkWsav4.js +668 -0
  413. package/dist/cli-runtime/ElectronFileScope-AP7VoVr7.js +1109 -0
  414. package/dist/cli-runtime/ElectronFuseFailures-DsjXR7Xp.js +609 -0
  415. package/dist/cli-runtime/ExecFileOutput-D6KLYTve.js +119 -0
  416. package/dist/cli-runtime/InterfaceBuilderDecodeBudget-CW1IO3dG.js +298 -0
  417. package/dist/cli-runtime/InventoryProjectionEvidence-DTH5QAqL.js +49 -0
  418. package/dist/cli-runtime/InvestigationProviders-CFh4a64d.js +118 -0
  419. package/dist/cli-runtime/JavaScriptApplicationEvidenceGraph-gOmPB2L6.js +160 -0
  420. package/dist/cli-runtime/JavaScriptApplicationWorkflowEvidence-WZgtK_Ok.js +75 -0
  421. package/dist/cli-runtime/JavaScriptWorkerMemoryLimit-B1bwMM1a.js +86 -0
  422. package/dist/cli-runtime/JebMcpEndpoint-BEalGZh9.js +710 -0
  423. package/dist/cli-runtime/JsonFiles-uvd6ZyQi.js +600 -0
  424. package/dist/cli-runtime/KunaInstallation-P0j3x851.js +1781 -0
  425. package/dist/cli-runtime/MacCodeSignature-MgYbRK_H.js +24 -0
  426. package/dist/cli-runtime/MacHopperPaths-bGzqjF1Z.js +34 -0
  427. package/dist/cli-runtime/MachoLoadCommandReader-CZm6N5vF.js +330 -0
  428. package/dist/cli-runtime/ManagedSnapshot-CPE9C3OD.js +4481 -0
  429. package/dist/cli-runtime/OwnedCommandCleanup-BN_V6Erc.js +187 -0
  430. package/dist/cli-runtime/OwnedRegularFile-D1f5nUCx.js +256 -0
  431. package/dist/cli-runtime/OwnedStagedOutput-D31dOozz.js +126 -0
  432. package/dist/cli-runtime/PrivateRuntimeRoot-Cd23u6jd.js +296 -0
  433. package/dist/cli-runtime/ProcessOwnership-CtrNr6ee.js +545 -0
  434. package/dist/cli-runtime/ProcessOwnershipObservation-C006iCtZ.js +920 -0
  435. package/dist/cli-runtime/ProviderDeadline-rSuH4Pm8.js +148 -0
  436. package/dist/cli-runtime/ProviderOperationExecution-CmU-XrQr.js +38 -0
  437. package/dist/cli-runtime/ProviderProcess-D87A7ctp.js +770 -0
  438. package/dist/cli-runtime/RegularFileRead-mbgGYtxe.js +125 -0
  439. package/dist/cli-runtime/SafeOutputTree-i904hd_2.js +525 -0
  440. package/dist/cli-runtime/SetupHost-CMPmPraB.js +1268 -0
  441. package/dist/cli-runtime/SharedStartupAttempt-BxKyf3Uv.js +1424 -0
  442. package/dist/cli-runtime/StableFileHash-Ame_h3lY.js +61 -0
  443. package/dist/cli-runtime/SupportedClients-DMafjitv.js +1066 -0
  444. package/dist/cli-runtime/UninstallFailure-1blyKXHE.js +22 -0
  445. package/dist/cli-runtime/Update-DAsASWlE.js +143 -0
  446. package/dist/cli-runtime/UpdateFailure-BcFNxEZZ.js +24 -0
  447. package/dist/cli-runtime/WindowsBatchCommand-Cx9kaVNf.js +97 -0
  448. package/dist/cli-runtime/WindowsNativeLoader-BqyZO0ZD.js +142 -0
  449. package/dist/cli-runtime/ZipArtifactReader-Jed69LEL.js +252 -0
  450. package/dist/cli-runtime/analysisErrorCleanup-COdAmDsb.js +33 -0
  451. package/dist/cli-runtime/appleArchiveFormat-Bb3G5CCI.js +269 -0
  452. package/dist/cli-runtime/application__DirectAnalysisStatus-F74bu9oy.js +150 -0
  453. package/dist/cli-runtime/application__EnhancedTools-Bg51b0Yp.js +1820 -0
  454. package/dist/cli-runtime/application__FunctionAnalysisEvidence-DBWIaYCh.js +41 -0
  455. package/dist/cli-runtime/application__ReconstructionCoverageService-AEPNpZqJ.js +32 -0
  456. package/dist/cli-runtime/application__ReconstructionObligationLedgerService-Cl9cPEZf.js +828 -0
  457. package/dist/cli-runtime/application__Setup-DwQzEewK.js +526 -0
  458. package/dist/cli-runtime/application__Uninstall-BOf9oyvQ.js +468 -0
  459. package/dist/cli-runtime/application__UpdateRuntime-CzWkRJHa.js +435 -0
  460. package/dist/cli-runtime/application__android__AndroidApplicationService-shW_aKlj.js +31 -0
  461. package/dist/cli-runtime/application__apple__AppleApplicationService-DIv6d3wB.js +31 -0
  462. package/dist/cli-runtime/application__harmony__HarmonyApplicationService-OIUFVQFV.js +31 -0
  463. package/dist/cli-runtime/application__javascript__ElectronActiveObservationService-wvCh72hK.js +118 -0
  464. package/dist/cli-runtime/application__javascript__ElectronObservationService-SydXPCwM.js +88 -0
  465. package/dist/cli-runtime/application__javascript__JavaScriptApplicationService-o0uEsjEc.js +12254 -0
  466. package/dist/cli-runtime/application__javascript__JavaScriptApplicationWorkflowService-BAheG_71.js +2336 -0
  467. package/dist/cli-runtime/application__javascript__JavaScriptRuntimeReconciliationService-Cnn4GP8q.js +88 -0
  468. package/dist/cli-runtime/application__javascript__JavaScriptSemanticTraceService-CmvLfV1A.js +299 -0
  469. package/dist/cli-runtime/artifacts__ArtifactProvider-wx2K0F2I.js +2205 -0
  470. package/dist/cli-runtime/binary-CWVNJhAC.js +19608 -0
  471. package/dist/cli-runtime/catalogIdentity-DAEEsOdX.js +1112 -0
  472. package/dist/cli-runtime/cli.js +44469 -0
  473. package/dist/cli-runtime/cliOutput-CgSuw782.js +163 -0
  474. package/dist/cli-runtime/cliOutput.js +5 -0
  475. package/dist/cli-runtime/cliResultOutput-10sd6xGx.js +1453 -0
  476. package/dist/cli-runtime/cliResultOutput.js +6 -0
  477. package/dist/cli-runtime/composition__browserScenario-BtPb1c1y.js +3414 -0
  478. package/dist/cli-runtime/composition__electronObservation-Bk8R6DJo.js +614 -0
  479. package/dist/cli-runtime/composition__electronScenario-BVF0qStH.js +916 -0
  480. package/dist/cli-runtime/cutterToolContracts-BQtG_Nzo.js +5267 -0
  481. package/dist/cli-runtime/doctorRuntime-B__SIpm-.js +478 -0
  482. package/dist/cli-runtime/dotnet__ManagedStaticProvider-DO5Yzcp4.js +5 -0
  483. package/dist/cli-runtime/errorSchemas-Ixz_q7qt.js +655 -0
  484. package/dist/cli-runtime/homeDirectory-DC_DeJIg.js +18 -0
  485. package/dist/cli-runtime/javascriptApplicationAnalysis-Dk6yBV8g.js +2088 -0
  486. package/dist/cli-runtime/javascriptExportReturnShapeProjection-CObOIiQ6.js +78 -0
  487. package/dist/cli-runtime/javascriptExportShapeComparisonSchemas-DpwuBenh.js +1244 -0
  488. package/dist/cli-runtime/javascriptRuntimeReconciliation-C6ZgWMys.js +1509 -0
  489. package/dist/cli-runtime/javascriptRuntimeReconciliationSchemas-D6tZKUQs.js +247 -0
  490. package/dist/cli-runtime/javascriptSemanticTraceSchemas-C7m0b6_w.js +126 -0
  491. package/dist/cli-runtime/lipo-DPQ6qurH.js +394 -0
  492. package/dist/cli-runtime/logger-BuDJ9xxO.js +48 -0
  493. package/dist/cli-runtime/machoContainer-Cy98bkFm.js +352 -0
  494. package/dist/cli-runtime/managedApplicationGraph-BazVqpJv.js +1136 -0
  495. package/dist/cli-runtime/managedToolContracts-BuFkMBH5.js +99 -0
  496. package/dist/cli-runtime/mcpDoctor.js +361 -0
  497. package/dist/cli-runtime/mcpStartupPolicy-imCbM3qo.js +28 -0
  498. package/dist/cli-runtime/native__NativeMacOSProvider-DTcRhuGA.js +5502 -0
  499. package/dist/cli-runtime/officialToolContracts-CzzVLx8I.js +1522 -0
  500. package/dist/cli-runtime/peMachine-B9ggfSJJ.js +95 -0
  501. package/dist/cli-runtime/propertyListKeys-D5dSASEy.js +355 -0
  502. package/dist/cli-runtime/providerCleanupError-BhsJyAhk.js +25 -0
  503. package/dist/cli-runtime/providerIdentities-Ao1XTvwx.js +31 -0
  504. package/dist/cli-runtime/providerStartupTimeout-B2tF2LtZ.js +17 -0
  505. package/dist/cli-runtime/readArtifactFileChunks-BbTL_PtB.js +129 -0
  506. package/dist/cli-runtime/reconstructionObligationLedgerSchemas-Bi6sect1.js +22156 -0
  507. package/dist/cli-runtime/rolldown-runtime-DXoylpqc.js +121 -0
  508. package/dist/cli-runtime/runtimeVersion-CMGd0bDu.js +23 -0
  509. package/dist/cli-runtime/safeJson-DKKACtdy.js +25 -0
  510. package/dist/cli-runtime/scanCanonical-CcDFUr-w.js +2594 -0
  511. package/dist/cli-runtime/snapshotEnvironment-Yvx5qwsl.js +196 -0
  512. package/dist/cli-runtime/toolContracts-CJzEyZ38.js +3795 -0
  513. package/dist/cli-runtime/toolOutputSchemaGroups-BqdSzySu.js +12249 -0
  514. package/dist/cli-runtime/workflowInputError-BP8z9Wxl.js +26 -0
  515. package/dist/cli.js +48 -5
  516. package/dist/cliBrowserScenarioCommands.js +41 -7
  517. package/dist/cliCommandNames.js +48 -0
  518. package/dist/cliEvidenceCommands.js +0 -1
  519. package/dist/cliJavaScriptRuntimeCommands.js +16 -14
  520. package/dist/cliJsonInput.js +12 -4
  521. package/dist/cliLogging.js +66 -15
  522. package/dist/cliObservationOptions.js +9 -0
  523. package/dist/cliOutput.js +105 -7
  524. package/dist/composition/binary.js +19 -2
  525. package/dist/composition/captures.js +3 -0
  526. package/dist/composition/directAnalysis.js +36 -11
  527. package/dist/composition/electronFuses.js +4 -0
  528. package/dist/composition/evm.js +12 -0
  529. package/dist/composition/flutter.js +3 -0
  530. package/dist/composition/go.js +4 -0
  531. package/dist/composition/javascriptAnalysisWorkerProcess.js +8 -8
  532. package/dist/composition/jeb.js +45 -5
  533. package/dist/composition/pcap.js +3 -0
  534. package/dist/composition/resolveWindowsProviderExecutable.js +61 -0
  535. package/dist/composition/reverseEngineering.js +29 -0
  536. package/dist/composition/rust.js +4 -0
  537. package/dist/composition/signals.js +3 -0
  538. package/dist/composition/sqlite.js +4 -0
  539. package/dist/composition/wasm.js +22 -0
  540. package/dist/composition/webNetworkCaptures.js +7 -2
  541. package/dist/config/environment.js +79 -4
  542. package/dist/config/ghidraDisabledAnalyzers.js +25 -0
  543. package/dist/config/homeDirectory.js +9 -6
  544. package/dist/config/mcpInputSchemaProfile.js +5 -1
  545. package/dist/config/mcpOutputSchemaProfile.js +22 -0
  546. package/dist/config/parseConfig.js +28 -34
  547. package/dist/config/parsers.js +4 -3
  548. package/dist/config/{ghidraStartupTimeout.js → providerStartupTimeout.js} +7 -3
  549. package/dist/contracts/adb/adbToolContracts.js +8 -8
  550. package/dist/contracts/analysisDetail.js +6 -3
  551. package/dist/contracts/analysisViewApiSurfaceExample.js +68 -0
  552. package/dist/contracts/analysisViewToolContracts.js +65 -3
  553. package/dist/contracts/android/androidToolContracts.js +17 -8
  554. package/dist/contracts/apktool/apktoolToolContracts.js +5 -1
  555. package/dist/contracts/applicationToolContracts.js +17 -2
  556. package/dist/contracts/artifactComparisonExample.js +18 -14
  557. package/dist/contracts/artifactToolContracts.js +16 -3
  558. package/dist/contracts/browserScenarioToolContracts.js +1 -1
  559. package/dist/contracts/browserToolContracts.js +13 -1
  560. package/dist/contracts/captures/captureToolContracts.js +42 -0
  561. package/dist/contracts/compactInputSchema.js +39 -12
  562. package/dist/contracts/cutterToolContracts.js +84 -0
  563. package/dist/contracts/enhancedToolContracts.js +2 -2
  564. package/dist/contracts/evm/evmToolContracts.js +30 -15
  565. package/dist/contracts/firmware/firmwareToolContracts.js +1 -1
  566. package/dist/contracts/flutter/flutterToolContracts.js +47 -0
  567. package/dist/contracts/fridaRemoteAddress.js +23 -0
  568. package/dist/contracts/fridaToolContracts.js +274 -0
  569. package/dist/contracts/functionComparisonExample.js +12 -1
  570. package/dist/contracts/gdbToolContracts.js +102 -0
  571. package/dist/contracts/go/goToolContracts.js +20 -0
  572. package/dist/contracts/hopperMemoryContracts.js +15 -0
  573. package/dist/contracts/inputSchemaPresentation.js +199 -38
  574. package/dist/contracts/investigationExamples.js +1 -0
  575. package/dist/contracts/javascript/electronToolContracts.js +27 -2
  576. package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +1 -0
  577. package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +13 -1
  578. package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +1 -0
  579. package/dist/contracts/jsonSchemaKeywords.js +29 -0
  580. package/dist/contracts/managed/managedToolContracts.js +43 -4
  581. package/dist/contracts/managed/managedWorkflowExamples.js +10 -1
  582. package/dist/contracts/managed/managedWorkflowToolContracts.js +4 -30
  583. package/dist/contracts/mobileApplicationGraphExamples.js +27 -12
  584. package/dist/contracts/native/binaryDiagnosticsToolContracts.js +3 -2
  585. package/dist/contracts/native/nativeToolContracts.js +10 -6
  586. package/dist/contracts/officialToolContracts.js +7 -7
  587. package/dist/contracts/pcap/pcapToolContracts.js +33 -0
  588. package/dist/contracts/providerSelection.js +1 -0
  589. package/dist/contracts/reconstructionReadinessExample.js +126 -119
  590. package/dist/contracts/reverseEngineeringToolContracts.js +52 -0
  591. package/dist/contracts/rizinDebugToolContracts.js +97 -0
  592. package/dist/contracts/rust/rustToolContracts.js +20 -0
  593. package/dist/contracts/sessionLifecycleInputs.js +34 -2
  594. package/dist/contracts/sessionToolContracts.js +4 -4
  595. package/dist/contracts/sessionToolSchemas.js +14 -0
  596. package/dist/contracts/signals/signalToolContracts.js +40 -0
  597. package/dist/contracts/sqlite/sqliteToolContracts.js +36 -0
  598. package/dist/contracts/toolContractExamples.js +29 -0
  599. package/dist/contracts/toolContractTypes.js +2 -0
  600. package/dist/contracts/toolContracts.js +26 -0
  601. package/dist/contracts/toolEffects.js +252 -9
  602. package/dist/contracts/toolOutputSchemaGroups.js +78 -32
  603. package/dist/contracts/toolOutputSchemaPrimitives.js +118 -10
  604. package/dist/contracts/toolSchemaMetadata.js +102 -16
  605. package/dist/contracts/unknownContractExamples.js +1 -1
  606. package/dist/contracts/wasm/wasmComparisonContracts.js +52 -0
  607. package/dist/contracts/wasm/wasmToolContracts.js +33 -0
  608. package/dist/contracts/webNetworkCaptureToolContracts.js +15 -4
  609. package/dist/cutter/CutterBridgeClient.js +760 -0
  610. package/dist/cutter/CutterBridgeService.js +187 -0
  611. package/dist/doctorRuntime.js +41 -8
  612. package/dist/domain/adb/adbDeviceAnalysis.js +45 -5
  613. package/dist/domain/analysisErrorBase.js +79 -2
  614. package/dist/domain/analysisErrorCleanup.js +4 -2
  615. package/dist/domain/analysisErrorCore.js +32 -0
  616. package/dist/domain/analysisErrorPresentation.js +80 -20
  617. package/dist/domain/analysisErrorProjection.js +72 -37
  618. package/dist/domain/analysisProfile.js +7 -3
  619. package/dist/domain/analysisSearch.js +26 -0
  620. package/dist/domain/analysisSnapshot.js +312 -185
  621. package/dist/domain/analysisView/WebNetworkApiSurfaceAccumulator.js +353 -0
  622. package/dist/domain/analysisView/analysisView.js +391 -44
  623. package/dist/domain/analysisView/analysisViewCoverage.js +32 -0
  624. package/dist/domain/analysisView/analysisViewDataAdmission.js +86 -0
  625. package/dist/domain/analysisView/analysisViewErrors.js +4 -0
  626. package/dist/domain/analysisView/analysisViewParent.js +12 -0
  627. package/dist/domain/analysisView/analysisViewText.js +29 -0
  628. package/dist/domain/analysisView/androidPackageView.js +102 -0
  629. package/dist/domain/analysisView/artifactInventoryView.js +126 -0
  630. package/dist/domain/analysisView/binaryLayoutView.js +11 -4
  631. package/dist/domain/analysisView/dartAotView.js +93 -0
  632. package/dist/domain/analysisView/evmInterfaceView.js +105 -0
  633. package/dist/domain/analysisView/interfaceBuilderView.js +182 -0
  634. package/dist/domain/analysisView/javascriptApplicationCoverage.js +27 -0
  635. package/dist/domain/analysisView/javascriptApplicationView.js +123 -49
  636. package/dist/domain/analysisView/javascriptFactsView.js +92 -0
  637. package/dist/domain/analysisView/javascriptModuleReferences.js +37 -0
  638. package/dist/domain/analysisView/machoView.js +186 -0
  639. package/dist/domain/analysisView/managedArtifactView.js +108 -0
  640. package/dist/domain/analysisView/managedMemberView.js +215 -0
  641. package/dist/domain/analysisView/nativeFunctionView.js +20 -25
  642. package/dist/domain/analysisView/pcapCaptureView.js +264 -0
  643. package/dist/domain/analysisView/qlogCaptureView.js +198 -0
  644. package/dist/domain/analysisView/wasmArtifactView.js +162 -0
  645. package/dist/domain/analysisView/webNetworkApiSurfaceView.js +123 -0
  646. package/dist/domain/analysisView/webNetworkCaptureView.js +388 -0
  647. package/dist/domain/android/androidAnalysis.js +36 -2
  648. package/dist/domain/android/androidApplication.js +37 -64
  649. package/dist/domain/apktool/apktoolResourceAnalysis.js +70 -8
  650. package/dist/domain/apple/appleApplication.js +70 -87
  651. package/dist/domain/apple/appleArchiveFormat.js +184 -0
  652. package/dist/domain/apple/appleAssetCatalog.js +15 -0
  653. package/dist/domain/apple/appleBundleAnatomy.js +57 -69
  654. package/dist/domain/apple/dyldPaths.js +9 -2
  655. package/dist/domain/apple/dylibResolution.js +24 -10
  656. package/dist/domain/apple/dylibResolutionFindings.js +8 -9
  657. package/dist/domain/apple/interfaceBuilderGraph.js +78 -33
  658. package/dist/domain/apple/interfaceBuilderKeyedArchive.js +39 -12
  659. package/dist/domain/apple/jvmClassFile.js +226 -0
  660. package/dist/domain/apple/keyedArchive.js +39 -17
  661. package/dist/domain/apple/machoContainer.js +123 -8
  662. package/dist/domain/apple/machoCpuIdentity.js +4 -0
  663. package/dist/domain/apple/plistNumbers.js +67 -5
  664. package/dist/domain/apple/plistValue.js +95 -19
  665. package/dist/domain/artifactComparison.js +116 -37
  666. package/dist/domain/artifactDecompressionBudget.js +26 -0
  667. package/dist/domain/artifactGraph.js +18 -9
  668. package/dist/domain/artifactIdentity.js +4 -1
  669. package/dist/domain/artifactInspection.js +34 -3
  670. package/dist/domain/artifactInventoryEvidence.js +146 -40
  671. package/dist/domain/binaryTarget.js +251 -109
  672. package/dist/domain/binaryTargetTypes.js +24 -1
  673. package/dist/domain/browserNetworkEvidence.js +24 -3
  674. package/dist/domain/browserObservation.js +92 -56
  675. package/dist/domain/browserObservationError.js +4 -4
  676. package/dist/domain/browserObservationSchemas.js +4 -1
  677. package/dist/domain/browserScenarioCapture.js +11 -1
  678. package/dist/domain/browserScenarioCaptureLimits.js +34 -0
  679. package/dist/domain/browserScenarioCaptureValues.js +76 -2
  680. package/dist/domain/browserScenarioDiff.js +120 -11
  681. package/dist/domain/browserScenarioDiffEvidence.js +44 -13
  682. package/dist/domain/browserScenarioDiffValues.js +10 -3
  683. package/dist/domain/browserScenarioNetworkComparison.js +158 -0
  684. package/dist/domain/browserScenarioNormalization.js +10 -13
  685. package/dist/domain/browserScenarioValues.js +7 -13
  686. package/dist/domain/browserSession.js +2 -2
  687. package/dist/domain/bundleComparison.js +1 -5
  688. package/dist/domain/callPath.js +40 -3
  689. package/dist/domain/captures/packetCapture.js +139 -0
  690. package/dist/domain/captures/packetFields.js +81 -0
  691. package/dist/domain/changedBehavior.js +43 -41
  692. package/dist/domain/comparisonSourceEvidence.js +6 -0
  693. package/dist/domain/dosCom.js +2 -2
  694. package/dist/domain/dosMz.js +66 -19
  695. package/dist/domain/electron/electronFuseEvidence.js +42 -0
  696. package/dist/domain/electron/electronFuses.js +360 -0
  697. package/dist/domain/elfFixedHeader.js +66 -0
  698. package/dist/domain/evidence.js +105 -39
  699. package/dist/domain/evidenceBundle.js +67 -22
  700. package/dist/domain/evidenceErrors.js +5 -0
  701. package/dist/domain/evm/evmInterface.js +18 -4
  702. package/dist/domain/evm/solidityMetadata.js +70 -0
  703. package/dist/domain/explicitSensitiveFailure.js +44 -23
  704. package/dist/domain/fileSnapshotObservation.js +25 -0
  705. package/dist/domain/firmware/firmwareAnalysis.js +29 -0
  706. package/dist/domain/fixedTupleSchema.js +9 -0
  707. package/dist/domain/flutter/flutterBuildAnalysis.js +141 -0
  708. package/dist/domain/functionCallCoverage.js +60 -0
  709. package/dist/domain/functionComparisonDimensions.js +136 -18
  710. package/dist/domain/functionComparisonNormalization.js +83 -19
  711. package/dist/domain/functionComparisonResults.js +7 -6
  712. package/dist/domain/functionComparisonSchemas.js +14 -3
  713. package/dist/domain/functionDossierEvidence.js +4 -0
  714. package/dist/domain/go/goBinary.js +96 -0
  715. package/dist/domain/harmony/harmonyApplication.js +156 -0
  716. package/dist/domain/hopperErrors.js +19 -18
  717. package/dist/domain/hopperPublisher.js +12 -0
  718. package/dist/domain/hopperValues.js +135 -34
  719. package/dist/domain/javascript/electronActiveObservation.js +1 -0
  720. package/dist/domain/javascript/electronObservation.js +4 -1
  721. package/dist/domain/javascript/electronStaticAnalysisBrowser.js +94 -33
  722. package/dist/domain/javascript/electronStaticAnalysisIpc.js +3 -1
  723. package/dist/domain/javascript/electronStaticAnalysisNative.js +19 -5
  724. package/dist/domain/javascript/electronStaticAnalysisValues.js +14 -28
  725. package/dist/domain/javascript/electronStaticOptionObjects.js +45 -0
  726. package/dist/domain/javascript/electronWrappedCallPaths.js +551 -0
  727. package/dist/domain/javascript/htmlArtifactReferences.js +94 -4
  728. package/dist/domain/javascript/javascriptAnalysisResourceControls.js +37 -1
  729. package/dist/domain/javascript/javascriptApplicationAnalysis.js +7 -0
  730. package/dist/domain/javascript/javascriptApplicationChangeGraph.js +10 -2
  731. package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +1 -1
  732. package/dist/domain/javascript/javascriptApplicationGraph.js +17 -1
  733. package/dist/domain/javascript/javascriptApplicationGraphSchemas.js +1 -0
  734. package/dist/domain/javascript/javascriptApplicationProjectionResources.js +8 -0
  735. package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +3 -1
  736. package/dist/domain/javascript/javascriptApplicationVersionItems.js +49 -21
  737. package/dist/domain/javascript/javascriptApplicationVersionKeys.js +31 -18
  738. package/dist/domain/javascript/javascriptArtifactFiles.js +2 -1
  739. package/dist/domain/javascript/javascriptAstFingerprint.js +89 -24
  740. package/dist/domain/javascript/javascriptAstValues.js +132 -5
  741. package/dist/domain/javascript/javascriptBootstrap.js +94 -0
  742. package/dist/domain/javascript/javascriptBootstrapIntegrity.js +372 -0
  743. package/dist/domain/javascript/javascriptBuiltinResourceMethods.js +8 -0
  744. package/dist/domain/javascript/javascriptBundledRequireOrigin.js +278 -0
  745. package/dist/domain/javascript/javascriptCommonJsExportReceivers.js +231 -0
  746. package/dist/domain/javascript/javascriptContextBridgeExposure.js +23 -0
  747. package/dist/domain/javascript/javascriptElectronMemberWrites.js +96 -22
  748. package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +6 -5
  749. package/dist/domain/javascript/javascriptExportShapeVariants.js +1 -1
  750. package/dist/domain/javascript/javascriptFeatureSeed.js +34 -17
  751. package/dist/domain/javascript/javascriptFeatureTrace.js +9 -3
  752. package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +42 -11
  753. package/dist/domain/javascript/javascriptGraphqlOperations.js +382 -0
  754. package/dist/domain/javascript/javascriptIntrinsicInvocation.js +132 -0
  755. package/dist/domain/javascript/javascriptModuleDeclaration.js +48 -0
  756. package/dist/domain/javascript/javascriptModuleInterop.js +618 -0
  757. package/dist/domain/javascript/javascriptModuleResolutionMode.js +18 -0
  758. package/dist/domain/javascript/javascriptModuleSpecifier.js +5 -0
  759. package/dist/domain/javascript/javascriptNativeHandoff.js +7 -12
  760. package/dist/domain/javascript/javascriptPackageImportAliases.js +58 -0
  761. package/dist/domain/javascript/javascriptRecovery.js +12 -5
  762. package/dist/domain/javascript/javascriptRpcEndpoints.js +7 -93
  763. package/dist/domain/javascript/javascriptRuntimeLoadState.js +16 -0
  764. package/dist/domain/javascript/javascriptRuntimeObservation.js +4 -1
  765. package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +45 -16
  766. package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +65 -47
  767. package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +0 -1
  768. package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +5 -4
  769. package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +113 -11
  770. package/dist/domain/javascript/javascriptSemanticAmbientWrites.js +511 -0
  771. package/dist/domain/javascript/javascriptSemanticAnalysis.js +706 -204
  772. package/dist/domain/javascript/javascriptSemanticAsyncEffects.js +54 -54
  773. package/dist/domain/javascript/javascriptSemanticCallResolution.js +59 -30
  774. package/dist/domain/javascript/javascriptSemanticCallableStack.js +52 -0
  775. package/dist/domain/javascript/javascriptSemanticCalls.js +10 -15
  776. package/dist/domain/javascript/javascriptSemanticChildProcesses.js +163 -92
  777. package/dist/domain/javascript/javascriptSemanticCoverage.js +5 -1
  778. package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +435 -45
  779. package/dist/domain/javascript/javascriptSemanticDataEffects.js +46 -29
  780. package/dist/domain/javascript/javascriptSemanticDependencies.js +69 -0
  781. package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +1 -1
  782. package/dist/domain/javascript/javascriptSemanticEvaluationOrder.js +126 -0
  783. package/dist/domain/javascript/javascriptSemanticExpressionShapes.js +111 -0
  784. package/dist/domain/javascript/javascriptSemanticFingerprints.js +11 -14
  785. package/dist/domain/javascript/javascriptSemanticGetterQueries.js +147 -0
  786. package/dist/domain/javascript/javascriptSemanticGetterResults.js +264 -0
  787. package/dist/domain/javascript/javascriptSemanticGraph.js +22 -1
  788. package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +13 -1
  789. package/dist/domain/javascript/javascriptSemanticIterationSources.js +5 -4
  790. package/dist/domain/javascript/javascriptSemanticMapOperations.js +51 -0
  791. package/dist/domain/javascript/javascriptSemanticMemberMutations.js +421 -154
  792. package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +500 -27
  793. package/dist/domain/javascript/javascriptSemanticObjectReferences.js +377 -174
  794. package/dist/domain/javascript/javascriptSemanticObjects.js +53 -43
  795. package/dist/domain/javascript/javascriptSemanticOpaqueEffects.js +163 -0
  796. package/dist/domain/javascript/javascriptSemanticPrimitives.js +11 -1
  797. package/dist/domain/javascript/javascriptSemanticProjection.js +180 -95
  798. package/dist/domain/javascript/javascriptSemanticPromises.js +6 -9
  799. package/dist/domain/javascript/javascriptSemanticProvenance.js +5 -1
  800. package/dist/domain/javascript/javascriptSemanticQuery.js +7 -2
  801. package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +2 -1
  802. package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +1 -1
  803. package/dist/domain/javascript/javascriptSemanticReferenceSources.js +25 -0
  804. package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +369 -8
  805. package/dist/domain/javascript/javascriptSemanticResourceLimits.js +3 -19
  806. package/dist/domain/javascript/javascriptSemanticResources.js +33 -44
  807. package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +81 -26
  808. package/dist/domain/javascript/javascriptSemanticReturns.js +37 -30
  809. package/dist/domain/javascript/javascriptSemanticState.js +225 -39
  810. package/dist/domain/javascript/javascriptSemanticTraversal.js +6 -4
  811. package/dist/domain/javascript/javascriptSemanticValues.js +379 -56
  812. package/dist/domain/javascript/javascriptSourceMapPaths.js +44 -17
  813. package/dist/domain/javascript/javascriptSourceParser.js +121 -7
  814. package/dist/domain/javascript/javascriptSourceSelection.js +11 -0
  815. package/dist/domain/javascript/javascriptStaticAnalysis.js +69 -24
  816. package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +97 -23
  817. package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +488 -48
  818. package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +196 -78
  819. package/dist/domain/javascript/javascriptStaticAnalysisState.js +4 -0
  820. package/dist/domain/javascript/javascriptStaticAnalysisTypes.js +2 -1
  821. package/dist/domain/javascript/javascriptSymbolicBindings.js +1118 -0
  822. package/dist/domain/javascript/javascriptSymbolicControlFlow.js +44 -0
  823. package/dist/domain/javascript/javascriptSymbolicValues.js +45 -0
  824. package/dist/domain/javascript/sourceToBundleComparison.js +3 -1
  825. package/dist/domain/javascript/sourceToBundleComparisonSchemas.js +2 -0
  826. package/dist/domain/javascript/sourceToBundleSignals.js +50 -13
  827. package/dist/domain/jsonValue.js +37 -12
  828. package/dist/domain/localPath.js +6 -3
  829. package/dist/domain/managed/managedApplicationGraph.js +5 -0
  830. package/dist/domain/managed/managedApplicationGraphCoverage.js +6 -2
  831. package/dist/domain/managed/managedApplicationGraphNodes.js +14 -10
  832. package/dist/domain/managed/managedArtifact.js +77 -1
  833. package/dist/domain/managed/managedInspectionEvidence.js +5 -6
  834. package/dist/domain/managed/managedMemberComparison.js +6 -0
  835. package/dist/domain/managed/managedMemberComparisonCoverage.js +36 -3
  836. package/dist/domain/managed/managedMemberComparisonItems.js +135 -59
  837. package/dist/domain/managed/managedMemberComparisonMatch.js +237 -42
  838. package/dist/domain/managed/managedMemberSignatureIdentity.js +40 -0
  839. package/dist/domain/managed/managedNativeVerificationMatch.js +54 -31
  840. package/dist/domain/managed/managedNativeVerificationSchemas.js +15 -4
  841. package/dist/domain/managed/managedReconstruction.js +5 -8
  842. package/dist/domain/mobileApplicationGraphProjection.js +95 -0
  843. package/dist/domain/native/addressCoordinate.js +11 -0
  844. package/dist/domain/native/binaryLayout.js +2 -4
  845. package/dist/domain/native/bytePattern.js +121 -0
  846. package/dist/domain/native/nativeAotPe.js +31 -4
  847. package/dist/domain/native/nativeAotSnapshotObservation.js +18 -0
  848. package/dist/domain/native/nativeCallPartialObservation.js +14 -12
  849. package/dist/domain/native/nativeInspection.js +38 -4
  850. package/dist/domain/native/nativeInstruction.js +17 -2
  851. package/dist/domain/native/nativeInvestigationGraph.js +9 -5
  852. package/dist/domain/native/nativeLoadImage.js +32 -1
  853. package/dist/domain/native/nativeUiObservation.js +5 -6
  854. package/dist/domain/native/objcSwiftMetadata.js +19 -9
  855. package/dist/domain/native/peResources.js +14 -4
  856. package/dist/domain/native/recordedCrash.js +79 -10
  857. package/dist/domain/offsetDateTime.js +60 -0
  858. package/dist/domain/pcap/pcapAnalysis.js +91 -0
  859. package/dist/domain/pcap/pcapEvidence.js +15 -0
  860. package/dist/domain/peMachine.js +38 -0
  861. package/dist/domain/pngHeader.js +18 -0
  862. package/dist/domain/process/processCaptureCoverage.js +26 -3
  863. package/dist/domain/process/processCaptureExample.js +2 -0
  864. package/dist/domain/process/processCaptureValidation.js +33 -8
  865. package/dist/domain/process/processComparison.js +41 -13
  866. package/dist/domain/process/processScenario.js +7 -0
  867. package/dist/domain/process/processTraceDimensionProjection.js +1 -1
  868. package/dist/domain/process/processTraceEvaluation.js +119 -74
  869. package/dist/domain/process/processTraceSpecification.js +243 -89
  870. package/dist/domain/propertyListKeys.js +238 -23
  871. package/dist/domain/propertyListXml.js +149 -0
  872. package/dist/domain/propertyListXmlText.js +20 -4
  873. package/dist/domain/providerAdapterError.js +2 -5
  874. package/dist/domain/providerCleanupError.js +2 -4
  875. package/dist/domain/providerConfigurationRefusal.js +12 -0
  876. package/dist/domain/providerSelectionError.js +2 -1
  877. package/dist/domain/qlogCapture.js +62 -0
  878. package/dist/domain/rawBinary.js +105 -0
  879. package/dist/domain/reconstructionCoverage.js +40 -24
  880. package/dist/domain/reconstructionCoverageEvaluation.js +50 -47
  881. package/dist/domain/reconstructionCoverageEvidence.js +26 -0
  882. package/dist/domain/reconstructionCoverageVerifierResults.js +35 -0
  883. package/dist/domain/reconstructionObligationLedgerIntegrity.js +114 -0
  884. package/dist/domain/reconstructionObligationLedgerSchemas.js +104 -1
  885. package/dist/domain/reconstructionReadiness.js +4 -8
  886. package/dist/domain/reconstructionReadinessJourneyFindings.js +4 -1
  887. package/dist/domain/reconstructionUnknowns.js +9 -1
  888. package/dist/domain/reconstructionVerification.js +86 -43
  889. package/dist/domain/recordedTransportUrl.js +59 -0
  890. package/dist/domain/referenceSourceClassification.js +27 -23
  891. package/dist/domain/referenceSourceGraph.js +51 -13
  892. package/dist/domain/referenceSourceImportParsing.js +27 -13
  893. package/dist/domain/referenceSourcePathIdentity.js +13 -1
  894. package/dist/domain/referenceSourceRequireBindings.js +40 -108
  895. package/dist/domain/referenceSourceSummary.js +92 -0
  896. package/dist/domain/relationshipCoverage.js +43 -0
  897. package/dist/domain/residualUnknown.js +93 -26
  898. package/dist/domain/reverseEngineering.js +31 -0
  899. package/dist/domain/runtimeVersion.js +8 -0
  900. package/dist/domain/rust/rustBinary.js +200 -0
  901. package/dist/domain/signals/annotationTextWindow.js +31 -0
  902. package/dist/domain/signals/signalDecoders.js +69 -0
  903. package/dist/domain/signals/signalRecording.js +115 -0
  904. package/dist/domain/sourceMapContents.js +10 -3
  905. package/dist/domain/sourceMapEnvelope.js +17 -11
  906. package/dist/domain/sqlite/sqliteDatabase.js +189 -0
  907. package/dist/domain/staticRuntimeCorrelation.js +7 -9
  908. package/dist/domain/swiftSymbolClassification.js +17 -0
  909. package/dist/domain/symbolAnalysis.js +20 -7
  910. package/dist/domain/urlComponents.js +6 -0
  911. package/dist/domain/wasm/wasmArtifact.js +119 -0
  912. package/dist/domain/wasm/wasmInterface.js +89 -0
  913. package/dist/domain/webBundleAnalysis.js +14 -3
  914. package/dist/domain/webBundleAnalyzerAst.js +7 -2
  915. package/dist/domain/webBundleAnalyzerInspection.js +113 -57
  916. package/dist/domain/webBundleAnalyzerResult.js +18 -6
  917. package/dist/domain/webCaptureDiff.js +235 -51
  918. package/dist/domain/webCaptureFrameComparison.js +49 -0
  919. package/dist/domain/webInventory.js +28 -14
  920. package/dist/domain/webMcpDiscovery.js +5 -2
  921. package/dist/domain/webModuleImports.js +22 -27
  922. package/dist/domain/webModuleTrace.js +25 -8
  923. package/dist/domain/webNetworkCapture.js +101 -39
  924. package/dist/domain/webNetworkCaptureCoordinates.js +21 -0
  925. package/dist/domain/webRuntime.js +0 -1
  926. package/dist/domain/webScreenshot.js +2 -2
  927. package/dist/domain/webScriptArtifacts.js +2 -4
  928. package/dist/domain/webScriptExport.js +6 -8
  929. package/dist/domain/webScriptExportError.js +2 -3
  930. package/dist/domain/webScriptExportPlan.js +2 -2
  931. package/dist/domain/webSourceLocation.js +20 -9
  932. package/dist/domain/xmlDocument.js +41 -0
  933. package/dist/domain/zipPackageFormat.js +25 -3
  934. package/dist/dotnet/ManagedArtifactInspector.js +25 -12
  935. package/dist/dotnet/ManagedDecodeBudget.js +87 -9
  936. package/dist/dotnet/ManagedMemberInspector.js +127 -22
  937. package/dist/dotnet/ManagedMemberInspectorCore.js +408 -141
  938. package/dist/dotnet/ManagedMemberInstructionDecoder.js +109 -37
  939. package/dist/dotnet/ManagedMemberOwnership.js +65 -0
  940. package/dist/dotnet/ManagedMemberPointers.js +69 -0
  941. package/dist/dotnet/ManagedMemberRows.js +181 -48
  942. package/dist/dotnet/ManagedMetadataHeaps.js +110 -25
  943. package/dist/dotnet/ManagedMetadataInventory.js +5 -5
  944. package/dist/dotnet/ManagedMetadataInventoryRows.js +36 -52
  945. package/dist/dotnet/ManagedMetadataLayout.js +26 -16
  946. package/dist/dotnet/ManagedMetadataRowSizes.js +1 -1
  947. package/dist/dotnet/ManagedMethodBodyReader.js +29 -11
  948. package/dist/dotnet/ManagedMethodSpecs.js +78 -0
  949. package/dist/dotnet/ManagedNativeBoundaryHelpers.js +20 -19
  950. package/dist/dotnet/ManagedNativeBoundaryInspector.js +13 -21
  951. package/dist/dotnet/ManagedPeReader.js +60 -27
  952. package/dist/dotnet/ManagedReaderFailure.js +9 -0
  953. package/dist/dotnet/ManagedSnapshot.js +93 -0
  954. package/dist/dotnet/ManagedStaticProvider.js +55 -64
  955. package/dist/dotnet/ManagedTypeMemberLists.js +105 -0
  956. package/dist/dotnet/ManagedTypeNameDigests.js +177 -0
  957. package/dist/dotnet/ManagedTypeNames.js +58 -0
  958. package/dist/dotnet/ManagedTypeNesting.js +25 -0
  959. package/dist/dotnet/ManagedTypeReferences.js +94 -0
  960. package/dist/dotnet/ManagedUserStrings.js +75 -0
  961. package/dist/electron/ElectronFuseFailures.js +105 -0
  962. package/dist/electron/ElectronFusePath.js +248 -0
  963. package/dist/electron/ElectronFuseProvider.js +88 -0
  964. package/dist/electron/ElectronFuseReader.js +333 -0
  965. package/dist/evaluation/AgentEvaluationFixtures.js +194 -11
  966. package/dist/evaluation/CodexAgentEval.js +19 -40
  967. package/dist/evaluation/KnownAnswerEvaluation.js +126 -57
  968. package/dist/evm/EvmoleFailures.js +20 -14
  969. package/dist/evm/EvmoleInterfaceAdapter.js +5 -1
  970. package/dist/evm/EvmoleInterfaceProvider.js +142 -35
  971. package/dist/evm/EvmoleInterfaceWorker.js +2 -0
  972. package/dist/evm/SolidityMetadata.js +139 -0
  973. package/dist/filesystem/OwnedRegularFile.js +116 -0
  974. package/dist/filesystem/OwnedStagedOutput.js +155 -0
  975. package/dist/filesystem/RegularFile.js +65 -9
  976. package/dist/filesystem/StableFileHash.js +56 -38
  977. package/dist/filesystem/callerPath.js +26 -0
  978. package/dist/filesystem/readFileHandleChunks.js +72 -13
  979. package/dist/filesystem/readStableFileBytes.js +85 -0
  980. package/dist/firmware/FirmwareCommand.js +15 -9
  981. package/dist/firmware/FirmwareFailures.js +56 -0
  982. package/dist/firmware/FirmwareFiles.js +136 -110
  983. package/dist/firmware/FirmwareProvider.js +122 -65
  984. package/dist/firmware/FirmwarePublication.js +244 -12
  985. package/dist/firmware/FirmwareReports.js +202 -12
  986. package/dist/flutter/DartElf.js +445 -0
  987. package/dist/flutter/ElfBuildId.js +137 -0
  988. package/dist/flutter/ElfLoadMap.js +91 -0
  989. package/dist/flutter/FlutterBuildProvider.js +866 -0
  990. package/dist/flutter/FlutterPayloadScan.js +180 -0
  991. package/dist/frida/FridaInstrumentationManager.js +1104 -0
  992. package/dist/gdb/GdbSessionManager.js +1639 -0
  993. package/dist/generatedPackageMetadata.js +2 -2
  994. package/dist/ghidra/GhidraAnalysisProfile.js +146 -14
  995. package/dist/ghidra/GhidraAnalysisSeeds.js +39 -55
  996. package/dist/ghidra/GhidraBridgeSources.js +12 -0
  997. package/dist/ghidra/GhidraClient.js +501 -180
  998. package/dist/ghidra/GhidraClientStartup.js +5 -3
  999. package/dist/ghidra/GhidraClientWire.js +5 -2
  1000. package/dist/ghidra/GhidraDiagnostics.js +23 -5
  1001. package/dist/ghidra/GhidraDoctor.js +60 -26
  1002. package/dist/ghidra/GhidraDosSnapshot.js +83 -0
  1003. package/dist/ghidra/GhidraExecutableHeader.js +54 -0
  1004. package/dist/ghidra/GhidraFileArtifacts.js +93 -0
  1005. package/dist/ghidra/GhidraFunctionValues.js +50 -2
  1006. package/dist/ghidra/GhidraInstallation.js +305 -108
  1007. package/dist/ghidra/GhidraInstallationPolicy.js +94 -103
  1008. package/dist/ghidra/GhidraInstallationProperties.js +57 -0
  1009. package/dist/ghidra/GhidraInventoryValues.js +52 -6
  1010. package/dist/ghidra/GhidraJavaLaunch.js +99 -11
  1011. package/dist/ghidra/GhidraJavaProbe.js +267 -0
  1012. package/dist/ghidra/GhidraJavaProperties.js +119 -0
  1013. package/dist/ghidra/GhidraLanguageCatalog.js +83 -8
  1014. package/dist/ghidra/GhidraLauncher.js +325 -85
  1015. package/dist/ghidra/GhidraLoadImageAttest.js +82 -65
  1016. package/dist/ghidra/GhidraLoadImageValues.js +109 -27
  1017. package/dist/ghidra/GhidraMipsProfile.js +258 -14
  1018. package/dist/ghidra/GhidraNativeAotSnapshotOwner.js +221 -0
  1019. package/dist/ghidra/GhidraPeProfile.js +91 -0
  1020. package/dist/ghidra/GhidraPowerPcProfile.js +51 -0
  1021. package/dist/ghidra/GhidraProvider.js +267 -42
  1022. package/dist/ghidra/GhidraProviderCapabilities.js +29 -15
  1023. package/dist/ghidra/GhidraProviderClient.js +439 -276
  1024. package/dist/ghidra/GhidraPspExtension.js +210 -0
  1025. package/dist/ghidra/GhidraPspProfile.js +62 -0
  1026. package/dist/ghidra/GhidraRawBinaryLanguage.js +49 -0
  1027. package/dist/ghidra/GhidraReleasePolicy.js +93 -0
  1028. package/dist/ghidra/GhidraRequestQueue.js +64 -40
  1029. package/dist/ghidra/GhidraRiscvProfile.js +100 -0
  1030. package/dist/ghidra/GhidraSessionError.js +301 -24
  1031. package/dist/ghidra/GhidraSessionValues.js +76 -0
  1032. package/dist/ghidra/GhidraSocketConnection.js +25 -11
  1033. package/dist/ghidra/GhidraTargetSnapshot.js +67 -50
  1034. package/dist/ghidra/GhidraTransport.js +86 -62
  1035. package/dist/ghidra/extensions/GhidraExtensions.js +30 -45
  1036. package/dist/go/GoBinaryContainer.js +140 -0
  1037. package/dist/go/GoBinaryImage.js +210 -0
  1038. package/dist/go/GoBinaryProvider.js +180 -0
  1039. package/dist/go/GoElfImage.js +211 -0
  1040. package/dist/go/GoMachoImage.js +164 -0
  1041. package/dist/go/GoModuleText.js +217 -0
  1042. package/dist/go/GoPeImage.js +124 -0
  1043. package/dist/hopper/BridgeLauncher.js +78 -6
  1044. package/dist/hopper/HopperAnalysisProfile.js +23 -11
  1045. package/dist/hopper/HopperCleanup.js +29 -4
  1046. package/dist/hopper/HopperClient.js +317 -93
  1047. package/dist/hopper/HopperMacPublisher.js +29 -0
  1048. package/dist/hopper/HopperMachOImage.js +61 -29
  1049. package/dist/hopper/HopperProcessDiagnostic.js +27 -0
  1050. package/dist/hopper/HopperProvider.js +57 -29
  1051. package/dist/hopper/HopperProviderCapabilities.js +9 -4
  1052. package/dist/hopper/HopperRegexSearch.js +21 -60
  1053. package/dist/hopper/HopperRequestQueue.js +17 -5
  1054. package/dist/hopper/HopperSessionValues.js +10 -1
  1055. package/dist/ida/IdaBusyHealth.js +78 -0
  1056. package/dist/ida/IdaCallGraph.js +134 -0
  1057. package/dist/ida/IdaConfiguration.js +7 -2
  1058. package/dist/ida/IdaDiagnosticRedactor.js +199 -0
  1059. package/dist/ida/IdaDiagnosticWriter.js +62 -0
  1060. package/dist/ida/IdaDoctor.js +7 -5
  1061. package/dist/ida/IdaJsonDiagnostic.js +138 -0
  1062. package/dist/ida/IdaMcpConnection.js +308 -32
  1063. package/dist/ida/IdaNativeProtocol.js +85 -0
  1064. package/dist/ida/IdaOperationRunner.js +246 -61
  1065. package/dist/ida/IdaProtocolValues.js +88 -5
  1066. package/dist/ida/IdaProvider.js +45 -10
  1067. package/dist/ida/IdaProviderCapabilities.js +37 -8
  1068. package/dist/ida/IdaSessionClient.js +379 -60
  1069. package/dist/ida/IdaWorkspace.js +54 -6
  1070. package/dist/inspector/V8InspectorCaptureProjection.js +14 -2
  1071. package/dist/inspector/V8InspectorEndpoint.js +15 -13
  1072. package/dist/inspector/V8InspectorProvider.js +43 -7
  1073. package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +44 -12
  1074. package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +107 -32
  1075. package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +7 -4
  1076. package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +85 -10
  1077. package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +16 -6
  1078. package/dist/javascript/recovery/RecoveryFiles.js +107 -13
  1079. package/dist/javascript/recovery/WakaruExecution.js +19 -11
  1080. package/dist/javascript/recovery/WakaruProvider.js +12 -9
  1081. package/dist/javascript/recovery/WakaruPublication.js +24 -10
  1082. package/dist/javascript/recovery/WakaruRelease.js +1 -1
  1083. package/dist/javascript/recovery/WakaruReport.js +3 -2
  1084. package/dist/javascript/sourceMaps/DecodedSourceMap.js +2 -16
  1085. package/dist/javascript/sourceMaps/SourceMapCommand.js +22 -4
  1086. package/dist/javascript/sourceMaps/SourceMapDecoder.js +22 -4
  1087. package/dist/javascript/sourceMaps/SourceMapFormat.js +25 -38
  1088. package/dist/javascript/sourceMaps/TraceSourceMap.js +34 -6
  1089. package/dist/jeb/JebMcpConnection.js +148 -82
  1090. package/dist/jeb/JebMcpConnectionOwner.js +116 -0
  1091. package/dist/jeb/JebMcpDeadline.js +46 -0
  1092. package/dist/jeb/JebMcpEndpoint.js +6 -1
  1093. package/dist/jeb/JebProvider.js +82 -58
  1094. package/dist/kuna/KunaAddress.js +11 -0
  1095. package/dist/kuna/KunaCommand.js +217 -0
  1096. package/dist/kuna/KunaConfiguration.js +90 -0
  1097. package/dist/kuna/KunaDoctor.js +198 -0
  1098. package/dist/kuna/KunaInstallation.js +137 -0
  1099. package/dist/kuna/KunaJson.js +23 -0
  1100. package/dist/kuna/KunaJsonStream.js +433 -0
  1101. package/dist/kuna/KunaLimits.js +5 -0
  1102. package/dist/kuna/KunaProjectCache.js +804 -0
  1103. package/dist/kuna/KunaProjectExport.js +202 -0
  1104. package/dist/kuna/KunaProjectFiles.js +191 -0
  1105. package/dist/kuna/KunaProjectReader.js +115 -0
  1106. package/dist/kuna/KunaProvider.js +217 -0
  1107. package/dist/kuna/KunaProviderCapabilities.js +102 -0
  1108. package/dist/kuna/KunaQueryErrors.js +12 -0
  1109. package/dist/kuna/KunaQueryWork.js +113 -0
  1110. package/dist/kuna/KunaReferenceFiles.js +258 -0
  1111. package/dist/kuna/KunaReferenceQueries.js +211 -0
  1112. package/dist/kuna/KunaRelease.js +10 -0
  1113. package/dist/kuna/KunaRunSlots.js +56 -0
  1114. package/dist/kuna/KunaSessionClient.js +1162 -0
  1115. package/dist/kuna/KunaStringInventory.js +145 -0
  1116. package/dist/kuna/KunaStringQueries.js +133 -0
  1117. package/dist/kuna/KunaTargetCommands.js +205 -0
  1118. package/dist/kuna/KunaUnavailable.js +11 -0
  1119. package/dist/logger.js +14 -1
  1120. package/dist/main/processShutdown.js +17 -0
  1121. package/dist/main/shutdown.js +3 -0
  1122. package/dist/main/transport.js +68 -4
  1123. package/dist/main.js +16 -15
  1124. package/dist/mcp/AnalysisProvider-BABWbLoM.js +38 -0
  1125. package/dist/mcp/AnalysisSnapshotFiles-BXz0c37-.js +1423 -0
  1126. package/dist/mcp/ArtifactFileOperation-64cQKI7B.js +1704 -0
  1127. package/dist/mcp/ArtifactProvider-Dx6pmil1.js +2200 -0
  1128. package/dist/mcp/ArtifactProviderMetadata-UCJr2oZW.js +167 -0
  1129. package/dist/mcp/ArtifactReader-BrnwNaKY.js +78 -0
  1130. package/dist/mcp/ArtifactResourceScope-zi3Dkqzy.js +175 -0
  1131. package/dist/mcp/AsarHeader-B_IbppTz.js +31 -0
  1132. package/dist/mcp/BinarySessionStatus-CZ9nnXMt.js +213 -0
  1133. package/dist/mcp/BinaryTargetResolver-BUncASDP.js +1358 -0
  1134. package/dist/mcp/BoundedFileBytes-DYt5q9G2.js +43 -0
  1135. package/dist/mcp/CdpCaptureDocuments-Y2uFcBpl.js +795 -0
  1136. package/dist/mcp/CdpCaptureValues-tNIg-gQK.js +97 -0
  1137. package/dist/mcp/CdpEndpoint-BrhMhpSi.js +641 -0
  1138. package/dist/mcp/CdpOptionalCommand-PZZhlqxv.js +120 -0
  1139. package/dist/mcp/CdpTargetSession-BmmDC3XO.js +290 -0
  1140. package/dist/mcp/DirectAnalysis-B9KuCHTG.js +417 -0
  1141. package/dist/mcp/DirectAnalysisStatus-BgzopkIt.js +44 -0
  1142. package/dist/mcp/ElectronFileScope-FXtK0d6I.js +110 -0
  1143. package/dist/mcp/ElectronFuseFailures-uZ_wOV6T.js +610 -0
  1144. package/dist/mcp/MachoLoadCommandReader-C2VGgHA3.js +330 -0
  1145. package/dist/mcp/ManagedStaticProvider-CZuoPme2.js +5326 -0
  1146. package/dist/mcp/NativeMacOSProvider-CMguKrvN.js +5495 -0
  1147. package/dist/mcp/NativeMacOSProviderMetadata-B_RH4KXF.js +397 -0
  1148. package/dist/mcp/OwnedCommand-BW1jBSt9.js +1241 -0
  1149. package/dist/mcp/ProcedureAddressResolution-H6Qwpb_Y.js +59 -0
  1150. package/dist/mcp/WorkflowEvidence-CO4C7ALz.js +118 -0
  1151. package/dist/mcp/analysisErrorCleanup-Q344SnTO.js +34 -0
  1152. package/dist/mcp/analysisErrorCore-BIEP7tvF.js +509 -0
  1153. package/dist/mcp/analysisErrorProjection-B8teQwwD.js +942 -0
  1154. package/dist/mcp/artifactToolContracts-C9dRDo-D.js +74 -0
  1155. package/dist/mcp/browserObservation-DUraZs62.js +4633 -0
  1156. package/dist/mcp/browserObservationError-C5okJ5el.js +63 -0
  1157. package/dist/mcp/browserObservationSchemas-DwGGxBpu.js +573 -0
  1158. package/dist/mcp/browserScenario-BRUz7yN0.js +3415 -0
  1159. package/dist/mcp/browserScenarioCapture-CiMAsMx8.js +595 -0
  1160. package/dist/mcp/callerPath-CpPnMZyN.js +678 -0
  1161. package/dist/mcp/canonicalDigest-Bi_0_zGi.js +71 -0
  1162. package/dist/mcp/electronActiveObservation-DV0Ffy9X.js +227 -0
  1163. package/dist/mcp/electronFuses-D5SS7XXw.js +367 -0
  1164. package/dist/mcp/electronObservation-DsN-NqY1.js +621 -0
  1165. package/dist/mcp/electronObservation-wOYWwqgF.js +112 -0
  1166. package/dist/mcp/electronScenario-CYrt2zBK.js +913 -0
  1167. package/dist/mcp/emptyArraySchema-C0o2Sxwp.js +140 -0
  1168. package/dist/mcp/enhancedInputs-6CCgB3VB.js +56 -0
  1169. package/dist/mcp/javascriptRuntimeObservation-BVbhkO2-.js +693 -0
  1170. package/dist/mcp/javascriptRuntimeObservation-Cu0Yedqq.js +121 -0
  1171. package/dist/mcp/jsonSerialization-V-wWiFRE.js +152 -0
  1172. package/dist/mcp/lipo-DSTgUqL1.js +395 -0
  1173. package/dist/mcp/localPath-AxvW9aPe.js +19 -0
  1174. package/dist/mcp/logger-BGdGHadX.js +48 -0
  1175. package/dist/mcp/machoContainer-CMSxUBlK.js +605 -0
  1176. package/dist/mcp/main-Cx-Z7m_n.js +80276 -0
  1177. package/dist/mcp/main.js +6 -0
  1178. package/dist/mcp/managedToolContracts-CSlbKJP-.js +101 -0
  1179. package/dist/mcp/nativeValueTrace-BEZbDieM.js +3601 -0
  1180. package/dist/mcp/officialToolContracts-CauCcSsc.js +1432 -0
  1181. package/dist/mcp/peMachine-aP1iYnHq.js +95 -0
  1182. package/dist/mcp/pngHeader-DQ-ObyY2.js +147 -0
  1183. package/dist/mcp/propertyListKeys-BfCo0k4w.js +356 -0
  1184. package/dist/mcp/providerCleanupError-DIRHxzWo.js +125 -0
  1185. package/dist/mcp/providerIdentities--ptAh481.js +31 -0
  1186. package/dist/mcp/providerIdentity-BCQ5n5tw.js +16 -0
  1187. package/dist/mcp/providerOperationHealth-9DRSGM8N.js +71 -0
  1188. package/dist/mcp/rolldown-runtime-BjeaiXFo.js +121 -0
  1189. package/dist/mcp/safeJson-NeGfpkrI.js +25 -0
  1190. package/dist/mcp/scanCanonical-CF3ATd1V.js +3788 -0
  1191. package/dist/mcp/serverIdentity-BK0Ejd_Y.js +1507 -0
  1192. package/dist/mcp/sourceMapEnvelope-DAaRUIGj.js +94 -0
  1193. package/dist/mcp/toolContracts-BPoHQdlC.js +12414 -0
  1194. package/dist/mcp/toolOutputSchemaGroups-MJ_f-PMK.js +17730 -0
  1195. package/dist/mcp/webContentArtifact-DfGkgDcI.js +269 -0
  1196. package/dist/mcp/webRuntime-ccyhkRru.js +74 -0
  1197. package/dist/mcp/webSourceLocation-DKIum0vJ.js +13167 -0
  1198. package/dist/mcpDoctor.js +95 -70
  1199. package/dist/mcpStartupPolicy.js +20 -2
  1200. package/dist/native/AppleDispatchCoverage.js +57 -17
  1201. package/dist/native/AppleDispatchMetadata.js +82 -29
  1202. package/dist/native/AppleMachoFixups.js +208 -35
  1203. package/dist/native/AppleMachoSelection.js +30 -23
  1204. package/dist/native/AppleObjcCategories.js +13 -3
  1205. package/dist/native/AppleObjcDispatchFacets.js +95 -17
  1206. package/dist/native/AppleObjcProperties.js +61 -17
  1207. package/dist/native/AppleObjcProtocols.js +25 -7
  1208. package/dist/native/AppleSwiftVtables.js +2 -0
  1209. package/dist/native/CommandRunner.js +146 -32
  1210. package/dist/native/LldbCallTracer.js +235 -179
  1211. package/dist/native/LldbReadbackFiles.js +70 -0
  1212. package/dist/native/LldbRetainedObservations.js +28 -56
  1213. package/dist/native/MachoArchitectureSelection.js +50 -0
  1214. package/dist/native/NativeCallObservation.js +55 -53
  1215. package/dist/native/NativeCallTarget.js +95 -0
  1216. package/dist/native/NativeMacOSProvider.js +318 -188
  1217. package/dist/native/NativeMachoInspection.js +155 -81
  1218. package/dist/native/NativePlistSource.js +179 -0
  1219. package/dist/native/NativeUiCleanupError.js +30 -0
  1220. package/dist/native/NativeUiHelperRuntime.js +48 -35
  1221. package/dist/native/NativeUiObservation.js +69 -47
  1222. package/dist/native/SignatureTargetBinding.js +147 -65
  1223. package/dist/native/parsers/codesign.js +27 -10
  1224. package/dist/native/parsers/demangle.js +22 -12
  1225. package/dist/native/parsers/dyldInfo.js +73 -4
  1226. package/dist/native/parsers/lipo.js +53 -19
  1227. package/dist/native/parsers/machoUuid.js +150 -0
  1228. package/dist/native/parsers/otool.js +275 -32
  1229. package/dist/native/parsers/plist.js +40 -25
  1230. package/dist/native/pe/PeResourceLayout.js +22 -7
  1231. package/dist/native/pe/PeResourceParser.js +10 -9
  1232. package/dist/native/pe/PeResourcesProvider.js +76 -15
  1233. package/dist/native/pwndbg/CoreFileMappingAuthority.js +51 -0
  1234. package/dist/native/pwndbg/PwndbgCoreContext.js +39 -28
  1235. package/dist/native/pwntools/PwntoolsDecoder.js +339 -52
  1236. package/dist/native/pwntools/PwntoolsFailures.js +19 -4
  1237. package/dist/native/pwntools/PwntoolsInputLimit.js +27 -0
  1238. package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +38 -16
  1239. package/dist/native/pwntools/PwntoolsResourceLimits.js +3 -3
  1240. package/dist/native/pwntools/RecordedCrashSourceBindings.js +12 -8
  1241. package/dist/native/pwntools/RecordedCrashStructureBindings.js +3 -1
  1242. package/dist/objdump/ObjdumpCommand.js +24 -0
  1243. package/dist/pcap/PcapCommand.js +146 -0
  1244. package/dist/pcap/PcapConfiguration.js +93 -0
  1245. package/dist/pcap/PcapNativeBound.js +58 -0
  1246. package/dist/pcap/PcapOutput.js +276 -0
  1247. package/dist/pcap/PcapProvider.js +454 -0
  1248. package/dist/pcap/PcapSnapshot.js +191 -0
  1249. package/dist/process/ArtifactAnalysisResources.js +306 -0
  1250. package/dist/process/BoundedFileBytes.js +8 -3
  1251. package/dist/process/CurrentEntrypointPath.js +8 -0
  1252. package/dist/process/DarwinProcessRunTokenReader.js +276 -61
  1253. package/dist/process/DetachedPgpSignature.js +57 -0
  1254. package/dist/process/ExecFileBoundedOutput.js +44 -0
  1255. package/dist/process/ExecFileOutput.js +44 -17
  1256. package/dist/{hopper/HopperTargetLease.js → process/HopperLease.js} +76 -19
  1257. package/dist/process/JavaScriptWorkerMemoryLimit.js +25 -0
  1258. package/dist/process/LinuxResourceLimits.js +60 -0
  1259. package/dist/process/MacCodeSignature.js +3 -0
  1260. package/dist/process/OwnedCommand.js +144 -25
  1261. package/dist/process/PrivateRuntimeRoot.js +9 -19
  1262. package/dist/process/PrivateRuntimeRootUnavailableError.js +10 -0
  1263. package/dist/process/ProcessOwnership.js +70 -17
  1264. package/dist/process/ProcessOwnershipObservation.js +35 -4
  1265. package/dist/process/ProviderDeadline.js +58 -12
  1266. package/dist/process/ProviderProcess.js +233 -17
  1267. package/dist/process/RegexMatcher.js +96 -0
  1268. package/dist/process/SharedStartupAttempt.js +59 -0
  1269. package/dist/process/WindowsAuthority.js +48 -39
  1270. package/dist/process/WindowsBatchCommand.js +46 -0
  1271. package/dist/process/boundedUtf8Text.js +13 -0
  1272. package/dist/process/capture/FilesystemSnapshot.js +63 -11
  1273. package/dist/process/capture/ProcessCaptureClock.js +2 -0
  1274. package/dist/process/capture/ProcessCaptureError.js +64 -7
  1275. package/dist/process/capture/ProcessCaptureJournal.js +2 -1
  1276. package/dist/process/capture/ProcessCaptureLifecycle.js +104 -56
  1277. package/dist/process/capture/ProcessCaptureProgress.js +7 -4
  1278. package/dist/process/capture/ProcessHarness.js +34 -17
  1279. package/dist/process/capture/ProcessNormalization.js +278 -36
  1280. package/dist/process/capture/ProcessSampling.js +3 -2
  1281. package/dist/process/capture/ProcessScenarioRuntimeValidation.js +13 -13
  1282. package/dist/process/capture/TerminalRenderer.js +31 -10
  1283. package/dist/process/ownedDebuggerSession.js +203 -0
  1284. package/dist/process/snapshotEnvironment.js +8 -8
  1285. package/dist/{application/binary → providers}/AnalysisClientCleanup.js +3 -3
  1286. package/dist/providers/AnalysisClientCreation.js +193 -0
  1287. package/dist/providers/AnalysisClientFailure.js +191 -0
  1288. package/dist/providers/DeferredAnalysisClient.js +48 -0
  1289. package/dist/providers/OwnedCommandCleanup.js +65 -0
  1290. package/dist/providers/ProviderInspectionScope.js +10 -0
  1291. package/dist/recordedCatalogDigests.js +2 -0
  1292. package/dist/reference/ReferenceSourceReader.js +64 -1
  1293. package/dist/reference/ReferenceSourceReaderEntries.js +79 -56
  1294. package/dist/reference/ReferenceSourceReaderErrors.js +5 -1
  1295. package/dist/reference/ReferenceSourceReaderFile.js +2 -2
  1296. package/dist/reference/ReferenceSourceReaderTypes.js +1 -2
  1297. package/dist/reference/ReferenceSourceReaderValidate.js +0 -1
  1298. package/dist/rizin/RizinCommand.js +14 -0
  1299. package/dist/rizin/RizinDebugSessionManager.js +1111 -0
  1300. package/dist/rust/RustAuditableReader.js +309 -0
  1301. package/dist/rust/RustBinaryImage.js +116 -0
  1302. package/dist/rust/RustBinaryProvider.js +194 -0
  1303. package/dist/server/EvidenceMcpServer.js +160 -37
  1304. package/dist/server/admittedToolOperation.js +7 -2
  1305. package/dist/server/contractToolHandler.js +17 -4
  1306. package/dist/server/createServer.js +179 -30
  1307. package/dist/server/externalMutationAdmission.js +50 -0
  1308. package/dist/server/mcpProgress.js +4 -2
  1309. package/dist/server/promptCompletion.js +43 -28
  1310. package/dist/server/providerEnvironment.js +3 -0
  1311. package/dist/server/registerAnalysisViewTool.js +6 -2
  1312. package/dist/server/registerAndroidTools.js +22 -4
  1313. package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +8 -1
  1314. package/dist/server/registerArtifactComparisonTool.js +13 -2
  1315. package/dist/server/registerArtifactTools.js +21 -1
  1316. package/dist/server/registerBrowserScenarioTool.js +7 -5
  1317. package/dist/server/registerBrowserTools.js +4 -8
  1318. package/dist/server/registerBundleComparisonTool.js +4 -4
  1319. package/dist/server/registerCaptureTools.js +12 -0
  1320. package/dist/server/registerCutterTools.js +32 -0
  1321. package/dist/server/registerElectronTools.js +13 -21
  1322. package/dist/server/registerEnhancedTools.js +7 -6
  1323. package/dist/server/registerEvidenceTools.js +14 -10
  1324. package/dist/server/registerEvmTools.js +22 -4
  1325. package/dist/server/registerFlutterTools.js +17 -0
  1326. package/dist/server/registerFridaTools.js +201 -0
  1327. package/dist/server/registerFunctionComparisonTool.js +29 -9
  1328. package/dist/server/registerGdbTools.js +64 -0
  1329. package/dist/server/registerGoTools.js +9 -0
  1330. package/dist/server/registerInvestigationTools/helpers.js +2 -2
  1331. package/dist/server/registerInvestigationTools.js +31 -27
  1332. package/dist/server/registerJavaScriptRuntimeObservationTools.js +3 -9
  1333. package/dist/server/registerManagedTools.js +11 -1
  1334. package/dist/server/registerManagedWorkflowTools/evidence.js +14 -7
  1335. package/dist/server/registerNativeTools.js +14 -0
  1336. package/dist/server/registerOfficialTools.js +5 -0
  1337. package/dist/server/registerPcapTools.js +35 -0
  1338. package/dist/server/registerProcessComparisonTool.js +12 -2
  1339. package/dist/server/registerReverseEngineeringTools.js +86 -0
  1340. package/dist/server/registerRizinDebugTools.js +53 -0
  1341. package/dist/server/registerRustTools.js +9 -0
  1342. package/dist/server/registerSessionRecordTools.js +19 -13
  1343. package/dist/server/registerSessionStatusTool.js +33 -8
  1344. package/dist/server/registerSessionTools.js +31 -31
  1345. package/dist/server/registerSignalTools.js +12 -0
  1346. package/dist/server/registerSqliteTools.js +9 -0
  1347. package/dist/server/registerWasmTools.js +46 -0
  1348. package/dist/server/registerWebNetworkCaptureTool.js +24 -10
  1349. package/dist/server/retainedSummaryDelivery.js +28 -0
  1350. package/dist/server/runDerivedOperation.js +2 -0
  1351. package/dist/server/sessionAvailabilityPolicy.js +3 -0
  1352. package/dist/server/toolRegistrationOptions.js +8 -0
  1353. package/dist/server/toolResult.js +52 -19
  1354. package/dist/server/toolResultEncoding.js +36 -3
  1355. package/dist/serverIdentity.js +17 -8
  1356. package/dist/signals/SigrokRecordingProvider.js +346 -0
  1357. package/dist/signals/parseDecoderDiscovery.js +65 -0
  1358. package/dist/sqlite/SqliteDatabaseFailures.js +147 -0
  1359. package/dist/sqlite/SqliteDatabaseInspection.js +436 -0
  1360. package/dist/sqlite/SqliteDatabaseLimits.js +16 -0
  1361. package/dist/sqlite/SqliteDatabaseProvider.js +295 -0
  1362. package/dist/sqlite/SqliteDatabaseSnapshot.js +182 -0
  1363. package/dist/sqlite/SqliteDatabaseWorker.js +46 -0
  1364. package/dist/sqlite/SqliteDatabaseWorkerExecution.js +127 -0
  1365. package/dist/wasm/WabtArtifactProvider.js +358 -0
  1366. package/dist/wasm/WabtFailures.js +119 -0
  1367. package/dist/wasm/WabtInterface.js +309 -0
  1368. package/dist/wasm/WabtOutput.js +60 -0
  1369. package/dist/wasm/WabtRelease.js +12 -0
  1370. package/dist/wasm/WabtRuntime.js +58 -0
  1371. package/dist/wasm/WabtString.js +48 -0
  1372. package/dist/wasm/WabtWat.js +147 -0
  1373. package/dist/wasm/WasmGlueAdapter.js +66 -0
  1374. package/dist/wasm/WasmInterfaceBudget.js +11 -0
  1375. package/dist/windows/WindowsNativeLoader.js +53 -9
  1376. package/dist/windows/WindowsOwnedProcess.js +150 -17
  1377. package/dist/windows/WindowsPrivateRuntime.js +66 -2
  1378. package/install.sh +157 -98
  1379. package/licenses/Apache-2.0.txt +202 -0
  1380. package/licenses/GCC-Runtime-Library-Exception-3.1.txt +73 -0
  1381. package/licenses/GPL-3.0.txt +674 -0
  1382. package/licenses/LGPL-2.0.txt +480 -0
  1383. package/licenses/MIT-template.txt +18 -0
  1384. package/licenses/MinGW-w64-runtime.txt +240 -0
  1385. package/licenses/Node-22.19.0-LICENSE.txt +2666 -0
  1386. package/licenses/README.md +68 -0
  1387. package/licenses/cfworker-MIT.txt +21 -0
  1388. package/licenses/dotnet-runtime-MIT.txt +23 -0
  1389. package/licenses/frida-17.23.2-COPYING.txt +50 -0
  1390. package/licenses/ghidra-12.1.4-DISCLAIMER.txt +13 -0
  1391. package/licenses/ghidra-12.1.4-LICENSE.txt +201 -0
  1392. package/licenses/ghidra-12.1.4-NOTICE.txt +49 -0
  1393. package/licenses/npm-dependencies.txt +3757 -0
  1394. package/licenses/npm-runtime-notices.txt +8722 -0
  1395. package/licenses/upstream-sources.json +72 -0
  1396. package/licenses/xterm-MIT.txt +21 -0
  1397. package/native/windows/README.md +130 -12
  1398. package/native/windows/build/manifest.json +2 -2
  1399. package/native/windows/build/rea-windows-x64.node +0 -0
  1400. package/package.json +97 -22
  1401. package/scripts/electron-active-hook-boundaries.cjs +15 -2
  1402. package/scripts/electron-active-hook.cjs +412 -47
  1403. package/scripts/hopper-demo-x11.py +65 -13
  1404. package/scripts/prepack.mjs +5 -0
  1405. package/scripts/rea-android-workspace-guardian.mjs +46 -0
  1406. package/scripts/rea.mjs +89 -26
  1407. package/scripts/verify-windows-native-artifact.mjs +2 -2
  1408. package/skills/reverse-engineer-anything/SKILL.md +146 -11
  1409. package/skills/reverse-engineer-anything/references/android-applications.md +3 -1
  1410. package/skills/reverse-engineer-anything/references/connection-and-recovery.md +10 -10
  1411. package/skills/reverse-engineer-anything/references/evidence-workflows.md +23 -0
  1412. package/skills/reverse-engineer-anything/references/javascript-applications.md +72 -3
  1413. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +149 -19
  1414. package/skills/reverse-engineer-anything/references/runtime-observation.md +57 -7
  1415. package/third_party/README.md +1 -1
  1416. package/third_party/wabt/README.md +24 -0
  1417. package/dist/browser/history/HarCaptureAdapter.js +0 -20
  1418. package/dist/cli/streamedJsonOutput.js +0 -135
  1419. package/dist/hopper/HopperRegexWorker.js +0 -27
  1420. /package/dist/{application/binary → process}/AbortablePromise.js +0 -0
@@ -0,0 +1,3788 @@
1
+ import { t as __esmMin } from "./rolldown-runtime-BjeaiXFo.js";
2
+ import { $ as isZipPackageFormat, Q as init_zipPackageFormat, X as ZIP_NON_ENTRY_LIMITATION, Z as hasZipSignature, et as zipPackageFormatForPath } from "./nativeValueTrace-BEZbDieM.js";
3
+ import { F as execFileOutputFailure, I as init_ExecFileOutput, P as execFileOutput, a as assertArtifactReadActive, s as init_ArtifactFileOperation } from "./ArtifactFileOperation-64cQKI7B.js";
4
+ import { a as sameArtifactEntry, i as init_ArtifactReader, o as sameArtifactSourceIdentity, r as copyArtifactEntry, t as ArtifactReaderFailure } from "./ArtifactReader-BrnwNaKY.js";
5
+ import { S as init_OwnedFileHandle, b as sameRegularFileState, l as init_OwnedRegularFile, m as RegularFileAdmissionFailure, n as init_machoContainer, p as NonRegularFileReadError, r as readFatContainerHeader, t as classifyFatContainerIdentity, u as regularFileCancellation, v as init_RegularFile, x as OwnedFileHandle, y as openRegularFile } from "./machoContainer-CMSxUBlK.js";
6
+ import { n as init_canonicalDigest, t as digestCanonicalValue } from "./canonicalDigest-Bi_0_zGi.js";
7
+ import { l as init_unicodeCodePointOrder, s as compareUnicodeCodePoints } from "./providerOperationHealth-9DRSGM8N.js";
8
+ import { c as init_machoCpuIdentity, l as machoCpuSubtypeBase } from "./electronFuses-D5SS7XXw.js";
9
+ import { B as observeMzWindowsHeader, V as parseDosMzHeader, c as MAX_XML_PLIST_PROBE_BYTES, f as hasXmlPlistSignature, l as createXmlPlistSignatureProbe, n as init_callerPath, p as init_appleArchiveFormat, t as absoluteCallerPath, u as hasBinaryPlistSignature, z as init_dosMz } from "./callerPath-CpPnMZyN.js";
10
+ import { a as OwnedDirectoryHandle, i as readArtifactFileChunks, o as init_OwnedDirectoryHandle, r as init_readArtifactFileChunks } from "./ArtifactProviderMetadata-UCJr2oZW.js";
11
+ import { Sr as occurrenceIdForLocation, _r as artifactManifestId, bi as init_artifactGraph, br as logicalPathNfc, gr as artifactIdForContent, hr as artifactGraphDigest, mr as artifactEdgeId, pr as artifactContradictionId, vr as init_artifactIdentity, yi as artifactInventoryResultSchema } from "./toolOutputSchemaGroups-MJ_f-PMK.js";
12
+ import { n as init_MachoLoadCommandReader, r as readMachoImage } from "./MachoLoadCommandReader-C2VGgHA3.js";
13
+ import { n as admitAsarHeader, r as init_AsarHeader } from "./AsarHeader-B_IbppTz.js";
14
+ import { c as init_CommandRunner, n as parseLipoOutput, o as XcrunCommandRunner, t as init_lipo } from "./lipo-DSTgUqL1.js";
15
+ import { basename, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
16
+ import { constants, createWriteStream } from "node:fs";
17
+ import { z } from "zod";
18
+ import { tmpdir } from "node:os";
19
+ import { lstat, mkdir, mkdtemp, open, opendir, readdir, realpath, rm, rmdir, unlink } from "node:fs/promises";
20
+ import { createHash } from "node:crypto";
21
+ import { setImmediate } from "node:timers/promises";
22
+ import { once } from "node:events";
23
+ import { PassThrough, Readable, Transform } from "node:stream";
24
+ import { pipeline } from "node:stream/promises";
25
+ import { parse } from "plist";
26
+ import { ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_ENTRY_DATA_OUT_OF_BOUNDS, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_SPLIT_ZIP_FILE, ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_UINT64, Reader, ZipReader } from "@zip.js/zip.js";
27
+ import { getRawHeader, uncache } from "@electron/asar";
28
+
29
+ //#region dist/domain/artifactDecompressionBudget.js
30
+ var ARTIFACT_DECOMPRESSION_RATIO, MINIMUM_ARTIFACT_DECOMPRESSION_BYTES, artifactDecompressionBudgetBytes;
31
+ function init_artifactDecompressionBudget() {
32
+ return (init_artifactDecompressionBudget = __esmMin((() => {
33
+ ARTIFACT_DECOMPRESSION_RATIO = 500;
34
+ MINIMUM_ARTIFACT_DECOMPRESSION_BYTES = 256 * 1024 * 1024;
35
+ artifactDecompressionBudgetBytes = (compressedBytes) => Math.max(MINIMUM_ARTIFACT_DECOMPRESSION_BYTES, Math.floor(compressedBytes) * 500);
36
+ })))();
37
+ }
38
+
39
+ //#endregion
40
+ //#region dist/artifacts/ZipArtifactReader.js
41
+ async function* typedZipFailures(source) {
42
+ try {
43
+ yield* source;
44
+ } catch (cause) {
45
+ throw typedZipFailure(cause);
46
+ }
47
+ }
48
+ var ZIP_UTF8_DECODER, NodeFileReader, ZipArtifactReader, projectZipEntry, decodeZipEntryText, CP437_HIGH_HALF, decodeCp437, zipEntryPath, decodeStrictZipUtf8, extractStream, ZIP_FAILURE_REASONS, typedZipFailure, isSymlink, toError;
49
+ function init_ZipArtifactReader() {
50
+ return (init_ZipArtifactReader = __esmMin((() => {
51
+ init_ArtifactFileOperation();
52
+ init_ArtifactReader();
53
+ init_artifactDecompressionBudget();
54
+ init_OwnedFileHandle();
55
+ init_RegularFile();
56
+ ZIP_UTF8_DECODER = new TextDecoder("utf-8", {
57
+ fatal: true,
58
+ ignoreBOM: true
59
+ });
60
+ NodeFileReader = class extends Reader {
61
+ path;
62
+ maximumReadBytes;
63
+ admitted;
64
+ #handle;
65
+ #owner;
66
+ #initPromise;
67
+ #ownsHandle;
68
+ constructor(path, maximumReadBytes, admitted) {
69
+ super(path);
70
+ this.path = path;
71
+ this.maximumReadBytes = maximumReadBytes;
72
+ this.admitted = admitted;
73
+ this.#ownsHandle = admitted === undefined;
74
+ }
75
+ init() {
76
+ this.#initPromise ??= this.#initialize();
77
+ return this.#initPromise;
78
+ }
79
+ async #initialize() {
80
+ try {
81
+ const handle = this.admitted?.handle ?? await openRegularFile(this.path, { symlinks: "reject" });
82
+ this.#handle = handle;
83
+ if (this.#ownsHandle) this.#owner = new OwnedFileHandle(handle);
84
+ } catch (cause) {
85
+ if (cause instanceof RegularFileAdmissionFailure) {
86
+ this.#owner = cause.owner;
87
+ const primary = cause.cause instanceof NonRegularFileReadError ? new ArtifactReaderFailure("format", `ZIP source is not a regular file: ${this.path}`, { cause: cause.cause }) : cause.cause;
88
+ throw ArtifactReaderFailure.withCleanup(primary, ArtifactReaderFailure.cleanupObservation(cause.cleanupCause, this.path));
89
+ }
90
+ if (cause instanceof NonRegularFileReadError) throw new ArtifactReaderFailure("format", `ZIP source is not a regular file: ${this.path}`, { cause });
91
+ throw cause;
92
+ }
93
+ const metadata = await this.#handle.stat();
94
+ if (!metadata.isFile() || this.admitted !== undefined && !sameRegularFileState(this.admitted.initial, metadata)) throw new ArtifactReaderFailure("integrity", `ZIP source identity changed before reading: ${this.path}`);
95
+ this.size = metadata.size;
96
+ }
97
+ async readUint8Array(index, length) {
98
+ const handle = this.#handle;
99
+ if (handle === undefined) throw new Error("ZIP reader is not initialized");
100
+ const readBytes = Math.min(length, this.size - index);
101
+ if (readBytes < 0) throw new ArtifactReaderFailure("format", `ZIP archive is malformed: read at ${index} extends beyond the ${this.size}-byte archive`);
102
+ if (this.maximumReadBytes !== undefined && readBytes > this.maximumReadBytes) throw new ArtifactReaderFailure("limit", `ZIP metadata read requires ${readBytes} bytes, exceeding the ${this.maximumReadBytes}-byte read budget`);
103
+ const bytes = Buffer.alloc(readBytes);
104
+ const read = await handle.read(bytes, 0, bytes.length, index);
105
+ return bytes.subarray(0, read.bytesRead);
106
+ }
107
+ async closeHandle() {
108
+ if (!this.#ownsHandle) return;
109
+ await this.#initPromise?.catch(() => undefined);
110
+ if (this.#owner === undefined) return;
111
+ await this.#owner.close();
112
+ this.#owner = undefined;
113
+ this.#handle = undefined;
114
+ }
115
+ };
116
+ ZipArtifactReader = class {
117
+ format;
118
+ #source;
119
+ #reader;
120
+ #entries = new Map();
121
+ /** Optionally bound each metadata read before allocating its backing buffer. */
122
+ constructor(path, format, maximumMetadataReadBytes, admitted) {
123
+ this.format = format;
124
+ this.#source = new NodeFileReader(path, maximumMetadataReadBytes, admitted);
125
+ this.#reader = new ZipReader(this.#source, {
126
+ checkSignature: true,
127
+ checkOverlappingEntry: true,
128
+ filenameEncoding: "cp437",
129
+ filenameValidation: "tolerant"
130
+ });
131
+ }
132
+ async *entries(signal) {
133
+ let index = 0;
134
+ let declaredFileBytes = 0;
135
+ for await (const entry of typedZipFailures(this.#reader.getEntriesGenerator({ decodeText: decodeZipEntryText }))) {
136
+ assertArtifactReadActive(signal);
137
+ const metadata = projectZipEntry(entry, index++);
138
+ if (metadata === undefined) continue;
139
+ if (metadata.kind === "file" && !metadata.encrypted && metadata.declaredSize !== null && Number.isSafeInteger(metadata.declaredSize) && metadata.declaredSize >= 0) {
140
+ declaredFileBytes += metadata.declaredSize;
141
+ const budget = artifactDecompressionBudgetBytes(this.#source.size);
142
+ if (declaredFileBytes > budget) throw new ArtifactReaderFailure("limit", `ZIP entries declare ${String(declaredFileBytes)} uncompressed bytes, exceeding this archive's ${String(budget)}-byte decompression budget (${String(MINIMUM_ARTIFACT_DECOMPRESSION_BYTES)}-byte minimum, ${String(500)}x archive size); a small archive cannot expand this far`);
143
+ }
144
+ const stored = this.#entries.get(metadata.adapterKey);
145
+ if (stored !== undefined && !sameArtifactEntry(metadata, stored.metadata)) throw new ArtifactReaderFailure("integrity", `ZIP member identity changed during enumeration: ${entry.filename}`);
146
+ if (stored === undefined) this.#entries.set(metadata.adapterKey, {
147
+ source: entry,
148
+ metadata: copyArtifactEntry(metadata)
149
+ });
150
+ yield metadata;
151
+ }
152
+ }
153
+ open(entry, signal) {
154
+ assertArtifactReadActive(signal);
155
+ const stored = this.#entries.get(entry.adapterKey);
156
+ if (stored === undefined || !sameArtifactEntry(entry, stored.metadata)) return Promise.reject(new ArtifactReaderFailure("integrity", "ZIP entry metadata does not match this reader's inventory"));
157
+ const source = stored.source;
158
+ if (source.directory || isSymlink(source)) return Promise.reject(new ArtifactReaderFailure("format", "ZIP entry is not a regular file"));
159
+ if (source.encrypted) return Promise.reject(new ArtifactReaderFailure("unavailable", "Encrypted ZIP entry is unsupported"));
160
+ return Promise.resolve(extractStream(source, signal));
161
+ }
162
+ async close() {
163
+ await this.#reader.close().catch(() => undefined);
164
+ await this.#source.closeHandle();
165
+ }
166
+ provenance() {
167
+ return [];
168
+ }
169
+ };
170
+ projectZipEntry = (entry, index) => {
171
+ const kind = isSymlink(entry) ? "symlink" : entry.directory ? "directory" : "file";
172
+ const sourcePath = zipEntryPath(entry);
173
+ const path = sourcePath.replace(/^(?:\.\/)+/u, "");
174
+ if (kind === "directory" && (path === "" || path === ".")) return undefined;
175
+ return {
176
+ path,
177
+ kind,
178
+ declaredSize: kind === "directory" ? null : entry.uncompressedSize,
179
+ compressedSize: kind === "directory" ? null : entry.compressedSize,
180
+ executable: entry.executable,
181
+ encrypted: entry.encrypted,
182
+ byteOffset: null,
183
+ declaredSha256: null,
184
+ unpacked: false,
185
+ limitations: [...kind === "symlink" ? ["Archive symlink target was not read."] : [], ...path === sourcePath ? [] : [`ZIP member name ${JSON.stringify(sourcePath)} has a leading current-directory prefix omitted from its logical path.`]],
186
+ adapterKey: `zip-entry:${index}`
187
+ };
188
+ };
189
+ decodeZipEntryText = (bytes, encoding, type) => {
190
+ if (type !== "filename") return undefined;
191
+ if (encoding === "utf-8") return decodeStrictZipUtf8(bytes, "ZIP filename is not valid UTF-8");
192
+ return encoding === "cp437" ? decodeCp437(bytes) : undefined;
193
+ };
194
+ CP437_HIGH_HALF = "ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0";
195
+ decodeCp437 = (bytes) => Array.from(bytes, (byte) => byte < 128 ? String.fromCharCode(byte) : CP437_HIGH_HALF.charAt(byte - 128)).join("");
196
+ zipEntryPath = (entry) => {
197
+ const field = entry.extraFieldUnicodePath;
198
+ if (field?.valid !== true) return entry.filename;
199
+ return decodeStrictZipUtf8(field.data.subarray(5), "ZIP Unicode Path extra field is not valid UTF-8");
200
+ };
201
+ decodeStrictZipUtf8 = (bytes, message) => {
202
+ try {
203
+ return ZIP_UTF8_DECODER.decode(bytes);
204
+ } catch (cause) {
205
+ throw new ArtifactReaderFailure("format", message, { cause });
206
+ }
207
+ };
208
+ extractStream = (entry, signal) => {
209
+ const output = new PassThrough();
210
+ const controller = new AbortController();
211
+ const onAbort = () => {
212
+ controller.abort(signal?.reason);
213
+ output.destroy(new ArtifactReaderFailure("cancelled", "ZIP operation cancelled"));
214
+ };
215
+ signal?.addEventListener("abort", onAbort, { once: true });
216
+ output.once("close", () => {
217
+ signal?.removeEventListener("abort", onAbort);
218
+ controller.abort();
219
+ });
220
+ const writable = new WritableStream({
221
+ write: async (chunk) => {
222
+ assertArtifactReadActive(signal);
223
+ if (!output.write(Buffer.from(chunk))) await once(output, "drain", { signal: controller.signal });
224
+ },
225
+ close: () => {
226
+ output.end();
227
+ },
228
+ abort: (reason) => {
229
+ output.destroy(toError(typedZipFailure(reason)));
230
+ }
231
+ });
232
+ void entry.getData(writable, {
233
+ signal: controller.signal,
234
+ checkSignature: true,
235
+ checkOverlappingEntry: true,
236
+ onprogress: () => assertArtifactReadActive(signal)
237
+ }).catch((cause) => output.destroy(toError(typedZipFailure(cause))));
238
+ return output;
239
+ };
240
+ ZIP_FAILURE_REASONS = new Map([...[
241
+ ERR_AMBIGUOUS_ARCHIVE,
242
+ ERR_BAD_FORMAT,
243
+ ERR_CENTRAL_DIRECTORY_NOT_FOUND,
244
+ ERR_ENTRY_DATA_OUT_OF_BOUNDS,
245
+ ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND,
246
+ ERR_EOCDR_NOT_FOUND,
247
+ ERR_EXTRAFIELD_ZIP64_NOT_FOUND,
248
+ ERR_INVALID_COMPRESSED_DATA,
249
+ ERR_INVALID_CRC32,
250
+ ERR_INVALID_UNCOMPRESSED_SIZE,
251
+ ERR_LOCAL_FILE_HEADER_NOT_FOUND,
252
+ ERR_OVERLAPPING_ENTRY,
253
+ ERR_UNSUPPORTED_UINT64
254
+ ].map((message) => [message, "format"]), ...[
255
+ ERR_ENCRYPTED_CENTRAL_DIRECTORY,
256
+ ERR_SPLIT_ZIP_FILE,
257
+ ERR_UNSUPPORTED_COMPRESSION,
258
+ ERR_UNSUPPORTED_ENCRYPTION
259
+ ].map((message) => [message, "unavailable"])]);
260
+ typedZipFailure = (cause) => {
261
+ if (!(cause instanceof Error) || cause instanceof ArtifactReaderFailure) return cause;
262
+ const reason = ZIP_FAILURE_REASONS.get(cause.message);
263
+ if (reason === undefined) return cause;
264
+ return new ArtifactReaderFailure(reason, reason === "format" ? `ZIP archive is malformed: ${cause.message}` : `ZIP archive uses an unsupported feature: ${cause.message}`, { cause });
265
+ };
266
+ isSymlink = (entry) => entry.unixMode !== undefined && (entry.unixMode & 61440) === 40960;
267
+ toError = (cause) => cause instanceof Error ? cause : new Error("ZIP extraction failed");
268
+ })))();
269
+ }
270
+
271
+ //#endregion
272
+ //#region dist/artifacts/ArtifactPaths.js
273
+ var DRIVE_PREFIX, ENGLISH_UNICODE_CASE_NOTE, ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION, DESTINATION_CASE_COLLISION_PREFIX, normalizeArtifactPath, ArtifactPathRegistry, emptyCaseNode, englishCaseFold, annotateEnglishUnicodeCaseCollisions, caseCollisionLimitation, destinationCaseCollisionMessage, englishUnicodeCaseCollisions, collisionsAlong;
274
+ function init_ArtifactPaths() {
275
+ return (init_ArtifactPaths = __esmMin((() => {
276
+ init_artifactIdentity();
277
+ init_unicodeCodePointOrder();
278
+ init_ArtifactReader();
279
+ DRIVE_PREFIX = /^[A-Za-z]:/u;
280
+ ENGLISH_UNICODE_CASE_NOTE = "This comparison is not a filesystem observation.";
281
+ ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION = `Logical archive names collide under English (en-US) Unicode case folding; a case-insensitive destination cannot store both spellings. ${ENGLISH_UNICODE_CASE_NOTE}`;
282
+ DESTINATION_CASE_COLLISION_PREFIX = "Destination filesystem cannot store both ";
283
+ normalizeArtifactPath = (input) => {
284
+ if (input.includes("\0") || input.startsWith("/") || DRIVE_PREFIX.test(input)) throw new ArtifactReaderFailure("path", `Artifact path is absolute or unsafe: ${JSON.stringify(input)}`);
285
+ const normalized = logicalPathNfc(input).replace(/\/+$/u, "");
286
+ const parts = normalized.split("/");
287
+ if (normalized.length === 0 || parts.some((part) => part === "" || part === "." || part === "..") || posix.normalize(normalized) !== normalized) throw new ArtifactReaderFailure("path", `Artifact path is not normalized: ${JSON.stringify(input)}`);
288
+ return normalized;
289
+ };
290
+ ArtifactPathRegistry = class {
291
+ #root = {
292
+ kind: undefined,
293
+ children: new Map()
294
+ };
295
+ add(path, kind) {
296
+ const parts = path.split("/");
297
+ let node = this.#root;
298
+ for (const [index, part] of parts.entries()) {
299
+ if (node.kind !== undefined && node.kind !== "directory") throw new ArtifactReaderFailure("path", `Artifact prefix conflict: ${path}`);
300
+ let child = node.children.get(part);
301
+ if (child === undefined) {
302
+ child = {
303
+ kind: undefined,
304
+ children: new Map()
305
+ };
306
+ node.children.set(part, child);
307
+ }
308
+ node = child;
309
+ if (index === parts.length - 1) {
310
+ if (node.kind !== undefined && node.kind !== kind) throw new ArtifactReaderFailure("path", `Artifact path collision: ${path}`);
311
+ if (kind !== "directory" && node.children.size > 0) throw new ArtifactReaderFailure("path", `Artifact prefix conflict: ${path}`);
312
+ }
313
+ }
314
+ node.kind = kind;
315
+ }
316
+ };
317
+ emptyCaseNode = () => ({
318
+ bySpelling: new Map(),
319
+ spellingsByFold: new Map(),
320
+ terminals: []
321
+ });
322
+ englishCaseFold = (part) => part.toLocaleLowerCase("en-US");
323
+ annotateEnglishUnicodeCaseCollisions = (occurrences) => {
324
+ const collisions = englishUnicodeCaseCollisions(occurrences.map(({ logical_path }) => logical_path));
325
+ if (collisions.size === 0) return undefined;
326
+ for (const occurrence of occurrences) for (const collision of collisions.get(occurrence.logical_path) ?? []) occurrence.limitations.push(caseCollisionLimitation(occurrence.logical_path, collision));
327
+ return ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION;
328
+ };
329
+ caseCollisionLimitation = (path, { prefix, other, additional }) => {
330
+ const others = additional === 0 ? other : `${other} and ${String(additional)} other spelling${additional === 1 ? "" : "s"}`;
331
+ const subject = prefix === path ? `Logical path ${path} collides` : `Logical path ${path} is under ${prefix}, which collides`;
332
+ return `${subject} under English (en-US) Unicode case folding with ${others}; a case-insensitive destination cannot store both. ${ENGLISH_UNICODE_CASE_NOTE}`;
333
+ };
334
+ destinationCaseCollisionMessage = (requestedPath, existingNames) => {
335
+ const slash = requestedPath.lastIndexOf("/");
336
+ const segment = slash < 0 ? requestedPath : requestedPath.slice(slash + 1);
337
+ if (existingNames.includes(segment)) return undefined;
338
+ const folded = englishCaseFold(segment);
339
+ const existing = existingNames.filter((name) => englishCaseFold(name) === folded).sort(compareUnicodeCodePoints)[0];
340
+ if (existing === undefined) return undefined;
341
+ const parent = slash < 0 ? "" : requestedPath.slice(0, slash + 1);
342
+ return `${DESTINATION_CASE_COLLISION_PREFIX}${requestedPath} and ${parent}${existing}; inventory retains both logical names.`;
343
+ };
344
+ englishUnicodeCaseCollisions = (paths) => {
345
+ const root = emptyCaseNode();
346
+ for (const path of paths) {
347
+ if (path.length === 0 || path === ".") continue;
348
+ let node = root;
349
+ for (const part of path.split("/")) {
350
+ let child = node.bySpelling.get(part);
351
+ if (child === undefined) {
352
+ const folded = englishCaseFold(part);
353
+ const spellings = node.spellingsByFold.get(folded);
354
+ if (spellings === undefined) node.spellingsByFold.set(folded, [part]);
355
+ else spellings.push(part);
356
+ child = emptyCaseNode();
357
+ node.bySpelling.set(part, child);
358
+ }
359
+ node = child;
360
+ }
361
+ node.terminals.push(path);
362
+ }
363
+ const collisions = new Map();
364
+ const pending = [{
365
+ node: root,
366
+ prefix: undefined,
367
+ chain: undefined
368
+ }];
369
+ for (let item = pending.pop(); item !== undefined; item = pending.pop()) {
370
+ const { node, prefix, chain } = item;
371
+ if (chain !== undefined) for (const path of node.terminals) collisions.set(path, collisionsAlong(chain));
372
+ for (const spellings of node.spellingsByFold.values()) spellings.sort(compareUnicodeCodePoints);
373
+ for (const [spelling, child] of node.bySpelling) {
374
+ const childPrefix = prefix === undefined ? spelling : `${prefix}/${spelling}`;
375
+ const spellings = node.spellingsByFold.get(englishCaseFold(spelling)) ?? [];
376
+ const other = spellings[0] === spelling ? spellings[1] : spellings[0];
377
+ pending.push({
378
+ node: child,
379
+ prefix: childPrefix,
380
+ chain: other === undefined ? chain : {
381
+ collision: {
382
+ prefix: childPrefix,
383
+ other: prefix === undefined ? other : `${prefix}/${other}`,
384
+ additional: spellings.length - 2
385
+ },
386
+ parent: chain
387
+ }
388
+ });
389
+ }
390
+ }
391
+ return collisions;
392
+ };
393
+ collisionsAlong = (chain) => {
394
+ const collisions = [];
395
+ let link = chain;
396
+ while (link !== undefined) {
397
+ collisions.push(link.collision);
398
+ link = link.parent;
399
+ }
400
+ return collisions.reverse();
401
+ };
402
+ })))();
403
+ }
404
+
405
+ //#endregion
406
+ //#region dist/artifacts/StreamBytes.js
407
+ var streamChunkToBuffer;
408
+ function init_StreamBytes() {
409
+ return (init_StreamBytes = __esmMin((() => {
410
+ streamChunkToBuffer = (value) => {
411
+ if (Buffer.isBuffer(value)) return value;
412
+ if (value instanceof Uint8Array) return Buffer.from(value);
413
+ if (typeof value === "string") return Buffer.from(value);
414
+ throw new TypeError("Readable stream emitted a non-byte chunk");
415
+ };
416
+ })))();
417
+ }
418
+
419
+ //#endregion
420
+ //#region dist/artifacts/SafeOutputTreeCreationFailure.js
421
+ var SafeOutputTreeCreationFailure, errorMessage;
422
+ function init_SafeOutputTreeCreationFailure() {
423
+ return (init_SafeOutputTreeCreationFailure = __esmMin((() => {
424
+ init_ArtifactReader();
425
+ SafeOutputTreeCreationFailure = class extends ArtifactReaderFailure {
426
+ tree;
427
+ constructor(cause, tree) {
428
+ const primary = cause instanceof ArtifactReaderFailure ? cause : new ArtifactReaderFailure("io", errorMessage(cause), { cause });
429
+ super(primary.reason, primary.message, {
430
+ cause: primary,
431
+ cancellation: primary.cancellation,
432
+ ...primary.cleanup === undefined ? {} : { cleanup: primary.cleanup },
433
+ ...primary.partialObservation === undefined ? {} : { partialObservation: primary.partialObservation }
434
+ }, primary.details);
435
+ this.name = "SafeOutputTreeCreationFailure";
436
+ this.tree = tree;
437
+ }
438
+ };
439
+ errorMessage = (cause) => cause instanceof Error ? cause.message : String(cause);
440
+ })))();
441
+ }
442
+
443
+ //#endregion
444
+ //#region dist/artifacts/SafeOutputTreeIdentity.js
445
+ var readDirectoryIdentity, assertPathIdentity, assertHandleIdentity, readFileIdentity, assertFilePathIdentity, isAbsent, replacedDirectory, isNotFound;
446
+ function init_SafeOutputTreeIdentity() {
447
+ return (init_SafeOutputTreeIdentity = __esmMin((() => {
448
+ init_ArtifactReader();
449
+ readDirectoryIdentity = async (path) => {
450
+ const metadata = await lstat(path, { bigint: true });
451
+ if (!metadata.isDirectory()) throw replacedDirectory(path);
452
+ return {
453
+ dev: metadata.dev,
454
+ ino: metadata.ino
455
+ };
456
+ };
457
+ assertPathIdentity = async (path, expected) => {
458
+ const metadata = await lstat(path, { bigint: true });
459
+ if (!metadata.isDirectory() || metadata.dev !== expected.dev || metadata.ino !== expected.ino) throw replacedDirectory(path);
460
+ };
461
+ assertHandleIdentity = async (handle, expected, path) => {
462
+ const metadata = await handle.stat({ bigint: true });
463
+ if (!metadata.isDirectory() || metadata.dev !== expected.dev || metadata.ino !== expected.ino) throw replacedDirectory(path);
464
+ };
465
+ readFileIdentity = async (handle, path) => {
466
+ const metadata = await handle.stat({ bigint: true });
467
+ if (!metadata.isFile()) throw new ArtifactReaderFailure("path", `Extraction file identity changed: ${path}`);
468
+ return {
469
+ dev: metadata.dev,
470
+ ino: metadata.ino
471
+ };
472
+ };
473
+ assertFilePathIdentity = async (path, expected) => {
474
+ const metadata = await lstat(path, { bigint: true });
475
+ if (!metadata.isFile() || metadata.dev !== expected.dev || metadata.ino !== expected.ino) throw new ArtifactReaderFailure("path", `Extraction file identity changed: ${path}`);
476
+ };
477
+ isAbsent = async (path) => lstat(path).then(() => false, (cause) => {
478
+ if (isNotFound(cause)) return true;
479
+ throw cause;
480
+ });
481
+ replacedDirectory = (path) => new ArtifactReaderFailure("path", `Extraction directory identity changed: ${path}`);
482
+ isNotFound = (cause) => cause instanceof Error && "code" in cause && cause.code === "ENOENT";
483
+ })))();
484
+ }
485
+
486
+ //#endregion
487
+ //#region dist/artifacts/SafeOutputTreeReadback.js
488
+ var hashOutputFile;
489
+ function init_SafeOutputTreeReadback() {
490
+ return (init_SafeOutputTreeReadback = __esmMin((() => {
491
+ init_readArtifactFileChunks();
492
+ init_ArtifactFileOperation();
493
+ init_StreamBytes();
494
+ init_ArtifactReader();
495
+ init_SafeOutputTreeIdentity();
496
+ hashOutputFile = async (owner, path, identity, options) => {
497
+ assertArtifactReadActive(options.signal);
498
+ const admittedIdentity = await readFileIdentity(owner.handle, path);
499
+ await assertFilePathIdentity(path, identity);
500
+ if (admittedIdentity.dev !== identity.dev || admittedIdentity.ino !== identity.ino) throw new ArtifactReaderFailure("path", `Extraction file identity changed: ${path}`);
501
+ const hash = createHash("sha256");
502
+ let bytes = 0;
503
+ for await (const raw of readArtifactFileChunks(owner.handle, options)) {
504
+ const chunk = streamChunkToBuffer(raw);
505
+ bytes += chunk.length;
506
+ if (bytes > options.maximum) throw new ArtifactReaderFailure("integrity", "Readback exceeded the bytes written");
507
+ hash.update(chunk);
508
+ }
509
+ await assertFilePathIdentity(path, identity);
510
+ assertArtifactReadActive(options.signal);
511
+ return {
512
+ sha256: hash.digest("hex"),
513
+ bytes
514
+ };
515
+ };
516
+ })))();
517
+ }
518
+
519
+ //#endregion
520
+ //#region dist/artifacts/SafeOutputTreeCleanup.js
521
+ var removeOwnedTree, removeFiles, requireEmpty;
522
+ function init_SafeOutputTreeCleanup() {
523
+ return (init_SafeOutputTreeCleanup = __esmMin((() => {
524
+ init_ArtifactReader();
525
+ init_SafeOutputTreeIdentity();
526
+ removeOwnedTree = async (input) => {
527
+ const { outputRoot, rootIdentity, directories, files } = input;
528
+ const filesByDirectory = new Map();
529
+ for (const entry of files) {
530
+ const directory = dirname(entry[0]);
531
+ const group = filesByDirectory.get(directory) ?? [];
532
+ group.push(entry);
533
+ filesByDirectory.set(directory, group);
534
+ }
535
+ const postorder = [...directories].sort(([left], [right]) => right.slice(outputRoot.length).split(sep).length - left.slice(outputRoot.length).split(sep).length);
536
+ for (const [path, identity] of postorder) {
537
+ await removeFiles(path, identity, filesByDirectory.get(path) ?? [], files);
538
+ const parentPath = dirname(path);
539
+ const parentIdentity = parentPath === outputRoot ? rootIdentity : directories.get(parentPath);
540
+ if (parentIdentity === undefined) throw replacedDirectory(parentPath);
541
+ await assertPathIdentity(parentPath, parentIdentity);
542
+ await assertPathIdentity(path, identity);
543
+ await requireEmpty(path);
544
+ await rmdir(path);
545
+ directories.delete(path);
546
+ }
547
+ await removeFiles(outputRoot, rootIdentity, filesByDirectory.get(outputRoot) ?? [], files);
548
+ await assertPathIdentity(outputRoot, rootIdentity);
549
+ await requireEmpty(outputRoot);
550
+ await rmdir(outputRoot);
551
+ };
552
+ removeFiles = async (directory, identity, filesInDirectory, retainedFiles) => {
553
+ for (const [path, fileIdentity] of filesInDirectory) {
554
+ await assertPathIdentity(directory, identity);
555
+ await assertFilePathIdentity(path, fileIdentity);
556
+ await unlink(path);
557
+ retainedFiles.delete(path);
558
+ }
559
+ };
560
+ requireEmpty = async (directory) => {
561
+ if ((await readdir(directory)).length > 0) throw new ArtifactReaderFailure("path", `Unowned entries remain in extraction directory: ${directory}`);
562
+ };
563
+ })))();
564
+ }
565
+
566
+ //#endregion
567
+ //#region dist/artifacts/SafeOutputTree.js
568
+ var SafeOutputTree, isDefined, isRejected, writeAll, normalizeDestinationPath, abortIfNeeded$4, isCancellationFailure, isAlreadyExists, throwIfDestinationCaseCollision;
569
+ function init_SafeOutputTree() {
570
+ return (init_SafeOutputTree = __esmMin((() => {
571
+ init_OwnedFileHandle();
572
+ init_StreamBytes();
573
+ init_ArtifactPaths();
574
+ init_callerPath();
575
+ init_ArtifactReader();
576
+ init_SafeOutputTreeCreationFailure();
577
+ init_SafeOutputTreeReadback();
578
+ init_SafeOutputTreeCleanup();
579
+ init_SafeOutputTreeIdentity();
580
+ SafeOutputTree = class SafeOutputTree {
581
+ platform;
582
+ #registry = new ArtifactPathRegistry();
583
+ #outputRoot;
584
+ #rootIdentity;
585
+ #nestedDirectories = new Map();
586
+ #unknownDirectories = new Set();
587
+ #ownedFiles = new Map();
588
+ #openFiles = new Map();
589
+ #openHandles = new Set();
590
+ #published = false;
591
+ #cleanup = { status: "not-required" };
592
+ constructor(outputRoot, platform) {
593
+ this.platform = platform;
594
+ this.#outputRoot = outputRoot;
595
+ }
596
+ /**
597
+ * Exclusively create the absent destination as this operation's owned tree.
598
+ *
599
+ * POSIX mode bits and directory `fchmod`/`fsync` have no Windows equivalent:
600
+ * `mkdir` already applies the requested mode, so the redundant handle
601
+ * `chmod` is skipped there to avoid an `EPERM` on the directory descriptor.
602
+ */
603
+ static async create(outputRoot, platform = process.platform) {
604
+ if (!isAbsolute(outputRoot)) throw new ArtifactReaderFailure("path", "Extraction output root must be absolute");
605
+ const requested = absoluteCallerPath(outputRoot);
606
+ const name = basename(requested);
607
+ if (name === "." || name === "..") throw new ArtifactReaderFailure("path", "Invalid extraction output root");
608
+ const parent = await realpath(dirname(requested)).catch((cause) => {
609
+ throw new ArtifactReaderFailure("unavailable", "Extraction output parent is unavailable", { cause });
610
+ });
611
+ const canonicalOutput = join(parent, name);
612
+ await mkdir(canonicalOutput, { mode: 448 }).catch((cause) => {
613
+ if (isAlreadyExists(cause)) throw new ArtifactReaderFailure("path", "Extraction output root already exists", { cause });
614
+ throw cause;
615
+ });
616
+ const tree = new SafeOutputTree(canonicalOutput, platform);
617
+ try {
618
+ const rootIdentity = await readDirectoryIdentity(canonicalOutput);
619
+ tree.#rootIdentity = rootIdentity;
620
+ if (platform !== "win32") {
621
+ const stagingHandle = tree.#trackHandle(await open(canonicalOutput, constants.O_RDONLY | constants.O_DIRECTORY));
622
+ let setup = { kind: "ready" };
623
+ try {
624
+ await assertHandleIdentity(stagingHandle.handle, rootIdentity, canonicalOutput);
625
+ await stagingHandle.handle.chmod(448);
626
+ } catch (cause) {
627
+ setup = {
628
+ kind: "failed",
629
+ cause
630
+ };
631
+ }
632
+ try {
633
+ await tree.#closeHandle(stagingHandle);
634
+ } catch (closeCause) {
635
+ if (setup.kind === "failed") throw ArtifactReaderFailure.withCleanup(setup.cause, ArtifactReaderFailure.cleanupObservation(closeCause, canonicalOutput));
636
+ throw closeCause;
637
+ }
638
+ if (setup.kind === "failed") throw setup.cause;
639
+ }
640
+ await assertPathIdentity(canonicalOutput, rootIdentity);
641
+ return tree;
642
+ } catch (cause) {
643
+ throw new SafeOutputTreeCreationFailure(cause, tree);
644
+ }
645
+ }
646
+ get outputRoot() {
647
+ return this.#outputRoot;
648
+ }
649
+ /** The output was durably committed, even if descriptor cleanup later failed. */
650
+ get published() {
651
+ return this.#published;
652
+ }
653
+ get cleanup() {
654
+ return structuredClone(this.#cleanup);
655
+ }
656
+ /** Stream one regular file with exact byte and digest verification. */
657
+ async write(relativePath, source, expected, signal) {
658
+ try {
659
+ this.#assertWritable();
660
+ if (!Number.isSafeInteger(expected.bytes) || expected.bytes < 0) throw new ArtifactReaderFailure("format", `Invalid expected extraction size for ${relativePath}`);
661
+ const path = normalizeDestinationPath(relativePath, this.platform);
662
+ this.#registry.add(path, "file");
663
+ const lineage = await this.#prepareParent(path);
664
+ const parent = lineage.at(-1);
665
+ if (parent === undefined) throw replacedDirectory(this.#outputRoot);
666
+ const fileName = path.slice(path.lastIndexOf("/") + 1);
667
+ const destination = join(parent.path, fileName);
668
+ const handle = await open(destination, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW, 384).catch(async (cause) => {
669
+ await throwIfDestinationCaseCollision(parent.path, path, cause);
670
+ throw new ArtifactReaderFailure("path", `Could not exclusively create extraction path: ${path}`, { cause });
671
+ });
672
+ const ownedHandle = this.#trackHandle(handle);
673
+ this.#openFiles.set(destination, ownedHandle);
674
+ const fileIdentity = await readFileIdentity(ownedHandle.handle, destination);
675
+ await assertFilePathIdentity(destination, fileIdentity);
676
+ this.#ownedFiles.set(destination, fileIdentity);
677
+ const hash = createHash("sha256");
678
+ let bytes = 0;
679
+ await this.#assertLineage(lineage);
680
+ for await (const raw of source) {
681
+ abortIfNeeded$4(signal);
682
+ const chunk = streamChunkToBuffer(raw);
683
+ if (chunk.length > expected.bytes - bytes) throw new ArtifactReaderFailure("integrity", `Extracted content exceeds the inventoried size: ${path}`);
684
+ bytes += chunk.length;
685
+ hash.update(chunk);
686
+ await writeAll(ownedHandle.handle, chunk);
687
+ }
688
+ if (bytes !== expected.bytes) throw new ArtifactReaderFailure("integrity", `Extracted content size disagrees with inventory: ${path}`);
689
+ const sha256 = hash.digest("hex");
690
+ if (sha256 !== expected.sha256) throw new ArtifactReaderFailure("integrity", `Extracted content disagrees with inventory: ${path}`);
691
+ await this.#assertLineage(lineage);
692
+ await assertFilePathIdentity(destination, fileIdentity);
693
+ await ownedHandle.handle.sync();
694
+ await this.#closeFileHandle(destination, ownedHandle);
695
+ const readbackHandle = this.#trackHandle(await open(destination, constants.O_RDONLY | constants.O_NOFOLLOW));
696
+ const readback = await hashOutputFile(readbackHandle, destination, fileIdentity, {
697
+ maximum: bytes,
698
+ signal
699
+ });
700
+ await this.#closeHandle(readbackHandle);
701
+ await this.#assertLineage(lineage);
702
+ await assertFilePathIdentity(destination, fileIdentity);
703
+ if (readback.sha256 !== sha256 || readback.bytes !== bytes) throw new ArtifactReaderFailure("integrity", `Durable readback verification failed: ${path}`);
704
+ return {
705
+ relativePath: path,
706
+ sha256,
707
+ bytesWritten: bytes
708
+ };
709
+ } catch (cause) {
710
+ try {
711
+ source.destroy();
712
+ } catch {}
713
+ throw cause;
714
+ }
715
+ }
716
+ /** Sync the owned output tree and prevent further writes through this instance. */
717
+ async commit(signal) {
718
+ this.#assertWritable();
719
+ abortIfNeeded$4(signal);
720
+ await this.#assertOwnedDirectories();
721
+ abortIfNeeded$4(signal);
722
+ if (this.platform === "win32") {
723
+ this.#published = true;
724
+ return;
725
+ }
726
+ const parent = this.#trackHandle(await open(dirname(this.#outputRoot), constants.O_RDONLY | constants.O_DIRECTORY));
727
+ let output;
728
+ let sync = { kind: "synced" };
729
+ try {
730
+ output = this.#trackHandle(await open(this.#outputRoot, constants.O_RDONLY | constants.O_DIRECTORY));
731
+ await assertHandleIdentity(output.handle, this.#requireRootIdentity(), this.#outputRoot);
732
+ await output.handle.sync();
733
+ await parent.handle.sync();
734
+ abortIfNeeded$4(signal);
735
+ this.#published = true;
736
+ } catch (cause) {
737
+ sync = {
738
+ kind: "failed",
739
+ cause
740
+ };
741
+ }
742
+ const closeResults = await Promise.allSettled([parent, output].filter(isDefined).map((handle) => this.#closeHandle(handle)));
743
+ const closeFailures = closeResults.filter(isRejected).map(({ reason }) => reason);
744
+ if (closeFailures.length > 0) {
745
+ const closeFailure = new AggregateError(closeFailures, "Extraction output directory handles could not be closed");
746
+ const cleanup = ArtifactReaderFailure.cleanupObservation(closeFailure, this.#outputRoot);
747
+ if (sync.kind === "failed") {
748
+ const primary = isCancellationFailure(sync.cause) ? sync.cause : new ArtifactReaderFailure("path", "Could not durably sync extraction output", { cause: sync.cause });
749
+ throw ArtifactReaderFailure.withCleanup(primary, cleanup);
750
+ }
751
+ throw ArtifactReaderFailure.withCleanup(closeFailure, cleanup);
752
+ }
753
+ if (sync.kind === "failed") {
754
+ if (isCancellationFailure(sync.cause)) throw sync.cause;
755
+ throw new ArtifactReaderFailure("path", "Could not durably sync extraction output", { cause: sync.cause });
756
+ }
757
+ }
758
+ /** Remove only this operation's unsealed tree and verify absence. */
759
+ async rollback() {
760
+ if (this.#published) {
761
+ await this.#closePendingHandles();
762
+ return structuredClone(this.#cleanup);
763
+ }
764
+ if (this.#cleanup.status === "complete") return structuredClone(this.#cleanup);
765
+ this.#cleanup = {
766
+ status: "incomplete",
767
+ residualPaths: [basename(this.#outputRoot)]
768
+ };
769
+ let removalFailure;
770
+ try {
771
+ await this.#admitPendingFiles();
772
+ await this.#closePendingHandles();
773
+ await this.#assertOwnedDirectories();
774
+ await removeOwnedTree({
775
+ outputRoot: this.#outputRoot,
776
+ rootIdentity: this.#requireRootIdentity(),
777
+ directories: this.#nestedDirectories,
778
+ files: this.#ownedFiles
779
+ });
780
+ } catch (cause) {
781
+ removalFailure = cause;
782
+ }
783
+ const absent = removalFailure === undefined && await isAbsent(this.#outputRoot);
784
+ this.#cleanup = absent ? {
785
+ status: "complete",
786
+ residualPaths: []
787
+ } : {
788
+ status: "incomplete",
789
+ residualPaths: [basename(this.#outputRoot)]
790
+ };
791
+ if (!absent) throw new ArtifactReaderFailure("integrity", `Extraction output cleanup could not be verified${removalFailure === undefined ? "" : `: ${removalFailure instanceof Error ? removalFailure.message : String(removalFailure)}`}`, {
792
+ cause: removalFailure,
793
+ cleanup: {
794
+ reason: removalFailure instanceof Error ? removalFailure.message : "Extraction output root remains after rollback",
795
+ resources: [this.#outputRoot]
796
+ }
797
+ });
798
+ return structuredClone(this.#cleanup);
799
+ }
800
+ async #prepareParent(relativePath) {
801
+ const parts = relativePath.split("/");
802
+ if (parts.pop() === undefined) throw new ArtifactReaderFailure("path", "Invalid extraction path");
803
+ let current = this.#outputRoot;
804
+ let logicalParent = "";
805
+ const lineage = [{
806
+ path: this.#outputRoot,
807
+ identity: this.#requireRootIdentity()
808
+ }];
809
+ if (parts.length === 0) await assertPathIdentity(this.#outputRoot, this.#requireRootIdentity());
810
+ for (const part of parts) {
811
+ const parent = lineage.at(-1);
812
+ if (parent === undefined) throw replacedDirectory(this.#outputRoot);
813
+ const logicalPath = logicalParent.length === 0 ? part : `${logicalParent}/${part}`;
814
+ current = join(current, part);
815
+ await assertPathIdentity(parent.path, parent.identity);
816
+ let created = true;
817
+ await mkdir(current, { mode: 448 }).catch((cause) => {
818
+ if (!isAlreadyExists(cause)) throw cause;
819
+ created = false;
820
+ });
821
+ if (!created) {
822
+ await throwIfDestinationCaseCollision(parent.path, logicalPath);
823
+ const identity = this.#nestedDirectories.get(current);
824
+ if (identity === undefined) throw replacedDirectory(current);
825
+ await assertPathIdentity(current, identity);
826
+ } else {
827
+ try {
828
+ const identity = await readDirectoryIdentity(current);
829
+ this.#nestedDirectories.set(current, identity);
830
+ } catch (cause) {
831
+ this.#unknownDirectories.add(current);
832
+ throw cause;
833
+ }
834
+ }
835
+ await assertPathIdentity(parent.path, parent.identity);
836
+ const identity = this.#nestedDirectories.get(current);
837
+ if (identity === undefined) throw replacedDirectory(current);
838
+ await assertPathIdentity(current, identity);
839
+ lineage.push({
840
+ path: current,
841
+ identity
842
+ });
843
+ logicalParent = logicalPath;
844
+ }
845
+ return lineage;
846
+ }
847
+ async #assertLineage(lineage) {
848
+ for (const { path, identity } of lineage) await assertPathIdentity(path, identity);
849
+ }
850
+ async #assertOwnedDirectories() {
851
+ const rootIdentity = this.#requireRootIdentity();
852
+ await assertPathIdentity(this.#outputRoot, rootIdentity);
853
+ for (const [path, identity] of this.#nestedDirectories) await assertPathIdentity(path, identity);
854
+ if (this.#unknownDirectories.size > 0) throw new ArtifactReaderFailure("path", `Extraction directory ownership is unknown: ${[...this.#unknownDirectories].join(", ")}`);
855
+ }
856
+ #requireRootIdentity() {
857
+ if (this.#rootIdentity === undefined) throw new ArtifactReaderFailure("path", `Extraction output root identity is unknown: ${this.#outputRoot}`);
858
+ return this.#rootIdentity;
859
+ }
860
+ #assertWritable() {
861
+ if (this.#published) throw new ArtifactReaderFailure("integrity", "Extraction tree is already committed");
862
+ if (this.#cleanup.status !== "not-required") throw new ArtifactReaderFailure("integrity", "Extraction tree cleanup has already started");
863
+ }
864
+ #trackHandle(handle) {
865
+ const owner = new OwnedFileHandle(handle);
866
+ this.#openHandles.add(owner);
867
+ return owner;
868
+ }
869
+ async #closeHandle(owner) {
870
+ await owner.close();
871
+ this.#openHandles.delete(owner);
872
+ }
873
+ async #closePendingHandles() {
874
+ const failures = [];
875
+ for (const owner of this.#openHandles) {
876
+ try {
877
+ await this.#closeHandle(owner);
878
+ } catch (cause) {
879
+ failures.push(cause);
880
+ }
881
+ }
882
+ if (failures.length > 0) throw new AggregateError(failures, "Output tree handles remain open");
883
+ }
884
+ async #closeFileHandle(path, owner) {
885
+ await this.#closeHandle(owner);
886
+ this.#openFiles.delete(path);
887
+ }
888
+ async #admitPendingFiles() {
889
+ for (const [path, owner] of this.#openFiles) {
890
+ let identity = this.#ownedFiles.get(path);
891
+ if (identity === undefined) {
892
+ identity = await readFileIdentity(owner.handle, path);
893
+ await assertFilePathIdentity(path, identity);
894
+ this.#ownedFiles.set(path, identity);
895
+ }
896
+ }
897
+ }
898
+ };
899
+ isDefined = (value) => value !== undefined;
900
+ isRejected = (result) => result.status === "rejected";
901
+ writeAll = async (handle, chunk) => {
902
+ let offset = 0;
903
+ while (offset < chunk.length) {
904
+ const { bytesWritten } = await handle.write(chunk, offset, chunk.length - offset);
905
+ if (bytesWritten === 0) throw new ArtifactReaderFailure("unavailable", "Extraction output stopped accepting bytes");
906
+ offset += bytesWritten;
907
+ }
908
+ };
909
+ normalizeDestinationPath = (relativePath, platform) => {
910
+ const path = normalizeArtifactPath(relativePath);
911
+ if (platform === "win32" && path.includes("\\")) throw new ArtifactReaderFailure("path", `Windows destination cannot materialize artifact path: ${JSON.stringify(path)}; backslashes denote path separators.`);
912
+ if (platform === "win32" && path.includes(":")) throw new ArtifactReaderFailure("path", `Windows destination cannot materialize artifact path as a regular file: ${path}; ':' denotes alternate data stream syntax.`);
913
+ if (platform === "win32" && /[\u0001-\u001f]/u.test(path)) throw new ArtifactReaderFailure("path", `Windows destination cannot materialize artifact path: ${JSON.stringify(path)}; Windows names cannot contain U+0001-U+001F.`);
914
+ return path;
915
+ };
916
+ abortIfNeeded$4 = (signal) => {
917
+ if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact extraction cancelled", { cause: signal.reason });
918
+ };
919
+ isCancellationFailure = (cause) => cause instanceof ArtifactReaderFailure && cause.reason === "cancelled";
920
+ isAlreadyExists = (cause) => cause instanceof Error && "code" in cause && cause.code === "EEXIST";
921
+ throwIfDestinationCaseCollision = async (parentDirectory, logicalPath, cause) => {
922
+ const names = await readdir(parentDirectory).catch(() => undefined);
923
+ if (names === undefined) return;
924
+ const message = destinationCaseCollisionMessage(logicalPath, names);
925
+ if (message === undefined) return;
926
+ throw new ArtifactReaderFailure("path", message, cause === undefined ? undefined : { cause });
927
+ };
928
+ })))();
929
+ }
930
+
931
+ //#endregion
932
+ //#region dist/artifacts/AsarEntryStream.js
933
+ var closeAsarHandle, readValidatedAsarEntry, abortIfNeeded$3, asarFailure$1, isFilesystemFailure$1;
934
+ function init_AsarEntryStream() {
935
+ return (init_AsarEntryStream = __esmMin((() => {
936
+ init_ArtifactReader();
937
+ closeAsarHandle = async (close, signal) => {
938
+ await close();
939
+ abortIfNeeded$3(signal);
940
+ };
941
+ readValidatedAsarEntry = (source, expectedBytes, entryPath, archivePath, signal) => {
942
+ const expectedExtent = expectedBytes === undefined ? undefined : BigInt(expectedBytes);
943
+ const completionFailure = () => {
944
+ const coverage = source.readCoverage();
945
+ if (coverage.kind !== "complete") return new ArtifactReaderFailure("integrity", `ASAR entry read coverage is incomplete: ${entryPath}`);
946
+ if (expectedExtent !== undefined && coverage.bytes !== expectedExtent) return new ArtifactReaderFailure("integrity", `ASAR entry size disagrees with its header: ${entryPath}`);
947
+ if (signal?.aborted) return new ArtifactReaderFailure("cancelled", "ASAR operation cancelled", { cause: signal.reason });
948
+ return undefined;
949
+ };
950
+ const output = Readable.from((async function* () {
951
+ const iterator = source[Symbol.asyncIterator]();
952
+ try {
953
+ while (true) {
954
+ const next = await iterator.next();
955
+ if (next.done) break;
956
+ const chunk = next.value;
957
+ if (!Buffer.isBuffer(chunk) && !(chunk instanceof Uint8Array)) throw new ArtifactReaderFailure("format", `ASAR entry did not return bytes: ${entryPath}`);
958
+ const coverage = source.readCoverage();
959
+ if (expectedExtent !== undefined && coverage.bytes > expectedExtent) throw new ArtifactReaderFailure("integrity", `ASAR entry exceeded its declared size: ${entryPath}`);
960
+ if (coverage.kind === "complete" && signal?.aborted) {
961
+ const failure = completionFailure();
962
+ if (failure !== undefined) throw failure;
963
+ }
964
+ yield chunk;
965
+ }
966
+ const failure = completionFailure();
967
+ if (failure !== undefined) throw failure;
968
+ } catch (cause) {
969
+ throw asarFailure$1(archivePath, `read ${entryPath}`, cause);
970
+ } finally {
971
+ try {
972
+ await iterator.return?.();
973
+ } catch {}
974
+ if (!source.destroyed) source.destroy();
975
+ }
976
+ })());
977
+ const onSourceError = (cause) => {
978
+ const completedCancellation = cause instanceof ArtifactReaderFailure && cause.reason === "cancelled" && source.readCoverage().kind === "complete" ? completionFailure() : undefined;
979
+ output.destroy(completedCancellation ?? asarFailure$1(archivePath, `read ${entryPath}`, cause));
980
+ };
981
+ source.on("error", onSourceError);
982
+ source.once("close", () => source.removeListener("error", onSourceError));
983
+ const onAbort = () => {
984
+ if (source.readCoverage().kind === "complete" && !output.destroyed && (source.errored === null || source.errored instanceof ArtifactReaderFailure && source.errored.reason === "cancelled")) {
985
+ const failure = completionFailure();
986
+ if (failure !== undefined) output.destroy(failure);
987
+ }
988
+ };
989
+ signal?.addEventListener("abort", onAbort, { once: true });
990
+ output.once("close", () => {
991
+ signal?.removeEventListener("abort", onAbort);
992
+ if (!source.destroyed) source.destroy();
993
+ });
994
+ if (signal?.aborted) onAbort();
995
+ return output;
996
+ };
997
+ abortIfNeeded$3 = (signal) => {
998
+ if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "ASAR operation cancelled", { cause: signal.reason });
999
+ };
1000
+ asarFailure$1 = (path, operation, cause) => {
1001
+ if (cause instanceof ArtifactReaderFailure) return cause;
1002
+ if (isFilesystemFailure$1(cause)) return new ArtifactReaderFailure("io", `Could not ${operation} ASAR at ${path}: ${cause.message}`, { cause });
1003
+ return new ArtifactReaderFailure("format", `Malformed ASAR during ${operation}: ${path}`, { cause });
1004
+ };
1005
+ isFilesystemFailure$1 = (cause) => cause instanceof Error && "errno" in cause && typeof cause.errno === "number" && "syscall" in cause && typeof cause.syscall === "string";
1006
+ })))();
1007
+ }
1008
+
1009
+ //#endregion
1010
+ //#region dist/artifacts/AsarListing.js
1011
+ function* ownChildren(files) {
1012
+ for (const name in files) if (Object.hasOwn(files, name)) yield [name, files[name]];
1013
+ }
1014
+ var MAX_LISTING_BYTES, nodeSchema, readAsarListing;
1015
+ function init_AsarListing() {
1016
+ return (init_AsarListing = __esmMin((() => {
1017
+ init_ArtifactReader();
1018
+ init_unicodeCodePointOrder();
1019
+ MAX_LISTING_BYTES = 64 * 1024 * 1024;
1020
+ nodeSchema = z.looseObject({
1021
+ files: z.custom((value) => value !== null && typeof value === "object" && !Array.isArray(value)).optional(),
1022
+ link: z.string().optional(),
1023
+ size: z.number().nonnegative().safe().optional(),
1024
+ offset: z.string().optional(),
1025
+ unpacked: z.boolean().optional(),
1026
+ executable: z.boolean().optional(),
1027
+ integrity: z.looseObject({
1028
+ algorithm: z.string(),
1029
+ hash: z.string()
1030
+ }).optional()
1031
+ });
1032
+ readAsarListing = async (header, signal) => {
1033
+ const root = nodeSchema.parse(header);
1034
+ if (root.files === undefined) throw new ArtifactReaderFailure("format", "ASAR root has no files table");
1035
+ const entries = [];
1036
+ const pending = [{
1037
+ parent: "",
1038
+ children: ownChildren(root.files)
1039
+ }];
1040
+ let retainedBytes = 0;
1041
+ let examined = 0;
1042
+ while (pending.length > 0) {
1043
+ if (examined++ % 128 === 0) {
1044
+ await setImmediate();
1045
+ if (signal?.aborted) throw new ArtifactReaderFailure("cancelled", "ASAR operation cancelled");
1046
+ }
1047
+ const frame = pending.at(-1);
1048
+ if (frame === undefined) break;
1049
+ const next = frame.children.next();
1050
+ if (next.done) {
1051
+ pending.pop();
1052
+ continue;
1053
+ }
1054
+ const [name, raw] = next.value;
1055
+ if (name.length === 0 || name === "." || name === ".." || name.includes("/") || name.includes("\0") || process.platform === "win32" && name.includes("\\")) throw new ArtifactReaderFailure("path", "ASAR header has an unsafe path component");
1056
+ const units = frame.parent.length + name.length + (frame.parent.length === 0 ? 0 : 1);
1057
+ retainedBytes += units * 2 + 256;
1058
+ if (retainedBytes > MAX_LISTING_BYTES) throw new ArtifactReaderFailure("limit", "ASAR expanded listing exceeds its 64 MiB representation budget");
1059
+ const path = frame.parent.length === 0 ? name : `${frame.parent}/${name}`;
1060
+ const metadata = nodeSchema.parse(raw);
1061
+ if (metadata.files === undefined && metadata.link === undefined && metadata.size === undefined) throw new ArtifactReaderFailure("format", "ASAR entry has no directory, link or file metadata");
1062
+ entries.push({
1063
+ path,
1064
+ metadata
1065
+ });
1066
+ if (metadata.files !== undefined) pending.push({
1067
+ parent: path,
1068
+ children: ownChildren(metadata.files)
1069
+ });
1070
+ }
1071
+ return entries.sort((left, right) => compareUnicodeCodePoints(left.path, right.path));
1072
+ };
1073
+ })))();
1074
+ }
1075
+
1076
+ //#endregion
1077
+ //#region dist/artifacts/AsarArtifactReader.js
1078
+ var AsarArtifactReader, defaultRemoveSnapshot, asarUnpackedEntryFailure, isAsarFileMetadata, parseArchiveOffset, abortIfNeeded$2, waitForOperation, asarFailure, isFilesystemFailure, isMissingFile;
1079
+ function init_AsarArtifactReader() {
1080
+ return (init_AsarArtifactReader = __esmMin((() => {
1081
+ init_ArtifactReader();
1082
+ init_AsarEntryStream();
1083
+ init_AsarHeader();
1084
+ init_OwnedFileHandle();
1085
+ init_readArtifactFileChunks();
1086
+ init_AsarListing();
1087
+ AsarArtifactReader = class {
1088
+ path;
1089
+ options;
1090
+ format = "asar";
1091
+ #archiveSize;
1092
+ #headerSize;
1093
+ #entries = new Map();
1094
+ #ownedHandles = new Map();
1095
+ #snapshot;
1096
+ #snapshotRoot;
1097
+ #snapshotOperation = Promise.resolve();
1098
+ constructor(path, options = {}) {
1099
+ this.path = path;
1100
+ this.options = options;
1101
+ }
1102
+ async *entries(signal) {
1103
+ let paths;
1104
+ try {
1105
+ await this.prepareContainer(undefined, signal);
1106
+ paths = await this.#withSnapshotOperation(async () => {
1107
+ const snapshotPath = this.#snapshotPath();
1108
+ this.#resetArchiveState();
1109
+ this.#entries.clear();
1110
+ const admitted = await this.#admitHeader(snapshotPath);
1111
+ this.#archiveSize = admitted.archiveBytes;
1112
+ this.#headerSize = admitted.headerBytes;
1113
+ abortIfNeeded$2(signal);
1114
+ const ordered = await readAsarListing(getRawHeader(snapshotPath).header, signal);
1115
+ const archiveMetadata = await lstat(snapshotPath);
1116
+ if (!archiveMetadata.isFile() || archiveMetadata.isSymbolicLink()) throw new ArtifactReaderFailure("format", "ASAR container is not a regular file");
1117
+ this.#archiveSize = archiveMetadata.size;
1118
+ return ordered;
1119
+ }, signal);
1120
+ } catch (cause) {
1121
+ throw asarFailure(this.path, "inventory", cause);
1122
+ }
1123
+ for (const { metadata, path } of paths) {
1124
+ abortIfNeeded$2(signal);
1125
+ const providerPath = path.split("/").join(sep);
1126
+ const kind = metadata.files !== undefined ? "directory" : metadata.link !== undefined ? "symlink" : "file";
1127
+ const entry = {
1128
+ path,
1129
+ kind,
1130
+ declaredSize: metadata.size ?? null,
1131
+ compressedSize: null,
1132
+ executable: metadata.executable === true,
1133
+ encrypted: false,
1134
+ byteOffset: null,
1135
+ declaredSha256: metadata.integrity !== undefined && metadata.integrity.algorithm === "SHA256" && /^[a-f0-9]{64}$/u.test(metadata.integrity.hash) ? metadata.integrity.hash : null,
1136
+ unpacked: "unpacked" in metadata && metadata.unpacked === true,
1137
+ limitations: kind === "symlink" ? ["ASAR symlink target was not followed or disclosed."] : [],
1138
+ adapterKey: providerPath
1139
+ };
1140
+ if (kind === "file" && isAsarFileMetadata(metadata)) this.#entries.set(providerPath, {
1141
+ metadata,
1142
+ entry: copyArtifactEntry(entry)
1143
+ });
1144
+ yield entry;
1145
+ }
1146
+ }
1147
+ async #admitHeader(snapshotPath) {
1148
+ const headerHandle = await this.#openOwned(snapshotPath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
1149
+ let admission;
1150
+ try {
1151
+ admission = {
1152
+ ok: true,
1153
+ value: await admitAsarHeader(headerHandle)
1154
+ };
1155
+ } catch (cause) {
1156
+ admission = {
1157
+ ok: false,
1158
+ cause
1159
+ };
1160
+ }
1161
+ try {
1162
+ await this.#closeOwnedHandle(headerHandle);
1163
+ } catch (cleanupCause) {
1164
+ if (!admission.ok) throw ArtifactReaderFailure.withCleanup(admission.cause, ArtifactReaderFailure.cleanupObservation(cleanupCause, snapshotPath));
1165
+ throw cleanupCause;
1166
+ }
1167
+ if (!admission.ok) throw admission.cause;
1168
+ return admission.value;
1169
+ }
1170
+ async open(entry, signal) {
1171
+ return this.#withSnapshotOperation(() => this.#openEntry(entry, signal), signal);
1172
+ }
1173
+ async #openEntry(entry, signal) {
1174
+ abortIfNeeded$2(signal);
1175
+ const state = this.#entries.get(entry.adapterKey);
1176
+ if (state === undefined && entry.kind !== "file") throw new ArtifactReaderFailure("format", "ASAR entry is not a regular file");
1177
+ if (state === undefined) throw new ArtifactReaderFailure("integrity", `ASAR entry was not produced by this reader: ${entry.path}`);
1178
+ if (!sameArtifactEntry(entry, state.entry)) throw new ArtifactReaderFailure("integrity", `ASAR entry metadata changed since inventory: ${state.entry.path}`);
1179
+ if (state.entry.unpacked) return this.#openUnpackedStream(state.entry, signal);
1180
+ return this.#openPackedStream(state, signal);
1181
+ }
1182
+ async #openPackedStream(state, signal) {
1183
+ const { metadata, entry: producedEntry } = state;
1184
+ const archiveSize = this.#archiveSize;
1185
+ const headerSize = this.#headerSize;
1186
+ const offset = metadata.offset === undefined ? undefined : parseArchiveOffset(metadata.offset);
1187
+ const start = offset === undefined || headerSize === undefined ? undefined : 8 + headerSize + offset;
1188
+ if (archiveSize === undefined || start === undefined || !Number.isSafeInteger(start) || metadata.size < 0 || !Number.isSafeInteger(metadata.size) || start > archiveSize || metadata.size > archiveSize - start) throw new ArtifactReaderFailure("format", `ASAR entry range is outside its container: ${producedEntry.path}`);
1189
+ const snapshotPath = this.#snapshotPath();
1190
+ let handle;
1191
+ try {
1192
+ const openedHandle = await this.#openOwned(snapshotPath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
1193
+ handle = openedHandle;
1194
+ const observed = await openedHandle.stat();
1195
+ abortIfNeeded$2(signal);
1196
+ if (!observed.isFile() || observed.size !== archiveSize) throw new ArtifactReaderFailure("integrity", `ASAR container changed before read: ${producedEntry.path}`);
1197
+ if (metadata.size === 0) {
1198
+ handle = undefined;
1199
+ await closeAsarHandle(() => this.#closeOwnedHandle(openedHandle), signal);
1200
+ return Readable.from([]);
1201
+ }
1202
+ const source = this.#ownedReadStream(openedHandle, {
1203
+ start,
1204
+ end: start + metadata.size - 1,
1205
+ signal
1206
+ });
1207
+ handle = undefined;
1208
+ const output = readValidatedAsarEntry(source, metadata.size, producedEntry.path, this.path, signal);
1209
+ this.#setOwnedOutput(openedHandle, output);
1210
+ return output;
1211
+ } catch (cause) {
1212
+ const failure = asarFailure(this.path, `read ${producedEntry.path}`, cause);
1213
+ if (handle !== undefined) {
1214
+ try {
1215
+ await this.#closeOwnedHandle(handle);
1216
+ } catch (cleanupCause) {
1217
+ throw ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, snapshotPath));
1218
+ }
1219
+ }
1220
+ throw failure;
1221
+ }
1222
+ }
1223
+ /** Capture once per reader lifetime; bind all interpretation to these exact bytes. */
1224
+ async prepareContainer(expectedSha256, signal) {
1225
+ await this.#withSnapshotOperation(async () => {
1226
+ abortIfNeeded$2(signal);
1227
+ if (this.#snapshot === undefined && this.#snapshotRoot !== undefined) await this.#closeSnapshot();
1228
+ if (this.#snapshot === undefined) await this.#captureSnapshot(signal);
1229
+ if (expectedSha256 !== undefined && this.#snapshot?.sha256 !== expectedSha256) throw new ArtifactReaderFailure("integrity", `ASAR container changed before interpretation: ${this.path}`);
1230
+ }, signal);
1231
+ }
1232
+ /** Read the same captured container that supplies headers and packed members. */
1233
+ async openContainer(signal) {
1234
+ await this.prepareContainer(undefined, signal);
1235
+ return this.#withSnapshotOperation(async () => {
1236
+ abortIfNeeded$2(signal);
1237
+ const snapshotPath = this.#snapshotPath();
1238
+ const handle = await this.#openOwned(snapshotPath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
1239
+ return this.#ownedReadStream(handle, { signal });
1240
+ }, signal);
1241
+ }
1242
+ async close() {
1243
+ await this.#withSnapshotOperation(() => this.#closeSnapshot());
1244
+ }
1245
+ async #captureSnapshot(signal) {
1246
+ let inputHandle;
1247
+ try {
1248
+ this.#snapshotRoot = await mkdtemp(join(tmpdir(), "rea-asar-snapshot-"));
1249
+ const snapshotPath = join(this.#snapshotRoot, "container.asar");
1250
+ const hash = createHash("sha256");
1251
+ inputHandle = await this.#openOwned(this.path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
1252
+ const source = this.#ownedReadStream(inputHandle, {
1253
+ signal,
1254
+ releaseOnClose: false
1255
+ });
1256
+ const digesting = new Transform({ transform(chunk, _encoding, callback) {
1257
+ hash.update(chunk);
1258
+ callback(null, chunk);
1259
+ } });
1260
+ await pipeline(source, digesting, createWriteStream(snapshotPath, {
1261
+ flags: "wx",
1262
+ mode: 384
1263
+ }));
1264
+ const completedInput = inputHandle;
1265
+ inputHandle = undefined;
1266
+ await this.#closeOwnedHandle(completedInput);
1267
+ abortIfNeeded$2(signal);
1268
+ this.#snapshot = {
1269
+ path: snapshotPath,
1270
+ sha256: hash.digest("hex")
1271
+ };
1272
+ } catch (cause) {
1273
+ let failure = asarFailure(this.path, "snapshot", cause);
1274
+ if (inputHandle !== undefined) {
1275
+ const failedInput = inputHandle;
1276
+ inputHandle = undefined;
1277
+ try {
1278
+ await this.#closeOwnedHandle(failedInput);
1279
+ } catch (cleanupCause) {
1280
+ failure = ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.path));
1281
+ }
1282
+ }
1283
+ try {
1284
+ if (this.#ownedHandles.size === 0) await this.#closeSnapshot();
1285
+ } catch (cleanupCause) {
1286
+ throw ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.#snapshotRoot ?? this.path));
1287
+ }
1288
+ throw failure;
1289
+ }
1290
+ }
1291
+ async #closeSnapshot() {
1292
+ await this.#closeOwnedHandles();
1293
+ const root = this.#snapshotRoot;
1294
+ if (root !== undefined) {
1295
+ try {
1296
+ await (this.options.removeSnapshot ?? defaultRemoveSnapshot)(root);
1297
+ if (this.#snapshotRoot === root) this.#snapshotRoot = undefined;
1298
+ } catch (cause) {
1299
+ throw ArtifactReaderFailure.withCleanup(cause, {
1300
+ reason: `Could not remove ASAR snapshot: ${root}`,
1301
+ resources: [root]
1302
+ });
1303
+ }
1304
+ }
1305
+ if (root === undefined || this.#snapshotRoot === undefined) {
1306
+ if (this.#snapshot !== undefined) uncache(this.#snapshot.path);
1307
+ this.#snapshot = undefined;
1308
+ this.#resetArchiveState();
1309
+ this.#entries.clear();
1310
+ }
1311
+ }
1312
+ async #withSnapshotOperation(operation, signal) {
1313
+ const previous = this.#snapshotOperation;
1314
+ let release;
1315
+ this.#snapshotOperation = new Promise((resolve) => {
1316
+ release = resolve;
1317
+ });
1318
+ try {
1319
+ await waitForOperation(previous, signal);
1320
+ } catch (cause) {
1321
+ void previous.then(release, release);
1322
+ throw cause;
1323
+ }
1324
+ try {
1325
+ abortIfNeeded$2(signal);
1326
+ return await operation();
1327
+ } finally {
1328
+ release();
1329
+ }
1330
+ }
1331
+ #snapshotPath() {
1332
+ if (this.#snapshot === undefined) throw new ArtifactReaderFailure("integrity", "ASAR snapshot is not available");
1333
+ return this.#snapshot.path;
1334
+ }
1335
+ provenance() {
1336
+ return [];
1337
+ }
1338
+ async #openUnpackedStream(entry, signal) {
1339
+ const unpackedRoot = `${this.path}.unpacked`;
1340
+ let handle;
1341
+ try {
1342
+ const rootMetadata = await lstat(unpackedRoot);
1343
+ if (!rootMetadata.isDirectory() || rootMetadata.isSymbolicLink()) throw new ArtifactReaderFailure("path", "ASAR unpacked companion is not a regular directory");
1344
+ const canonicalRoot = await realpath(unpackedRoot);
1345
+ const candidate = join(unpackedRoot, entry.adapterKey);
1346
+ const canonical = await realpath(candidate);
1347
+ const relativePath = relative(canonicalRoot, canonical);
1348
+ if (relativePath === ".." || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath)) throw new ArtifactReaderFailure("path", `ASAR unpacked entry escaped its companion directory: ${entry.path}`);
1349
+ const pathMetadata = await lstat(candidate);
1350
+ if (!pathMetadata.isFile() || pathMetadata.isSymbolicLink()) throw new ArtifactReaderFailure("path", `ASAR unpacked entry is not a regular file: ${entry.path}`);
1351
+ handle = await (this.options.openUnpackedFile ?? open)(canonical, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
1352
+ const openedHandle = handle;
1353
+ this.#adoptHandle(openedHandle, canonical);
1354
+ const openedMetadata = await openedHandle.stat();
1355
+ if (!openedMetadata.isFile() || openedMetadata.dev !== pathMetadata.dev || openedMetadata.ino !== pathMetadata.ino) {
1356
+ throw new ArtifactReaderFailure("integrity", `ASAR unpacked entry changed before read: ${entry.path}`, {}, {
1357
+ logicalPath: entry.path,
1358
+ declaredSha256: entry.declaredSha256,
1359
+ calculatedSha256: null,
1360
+ unpacked: true
1361
+ });
1362
+ }
1363
+ abortIfNeeded$2(signal);
1364
+ const source = this.#ownedReadStream(openedHandle, {
1365
+ start: 0,
1366
+ signal
1367
+ });
1368
+ handle = undefined;
1369
+ const output = readValidatedAsarEntry(source, undefined, entry.path, this.path, signal);
1370
+ this.#setOwnedOutput(openedHandle, output);
1371
+ return output;
1372
+ } catch (cause) {
1373
+ let failure = asarUnpackedEntryFailure(this.path, entry, cause);
1374
+ if (handle !== undefined && this.#ownedHandles.has(handle)) {
1375
+ try {
1376
+ await this.#closeOwnedHandle(handle);
1377
+ } catch (cleanupCause) {
1378
+ failure = ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.#ownedHandles.get(handle)?.path ?? entry.path));
1379
+ }
1380
+ }
1381
+ throw failure;
1382
+ }
1383
+ }
1384
+ async #closeOwnedHandle(handle) {
1385
+ const owned = this.#ownedHandles.get(handle);
1386
+ if (owned === undefined) return;
1387
+ owned.output?.destroy();
1388
+ owned.source?.destroy();
1389
+ try {
1390
+ await owned.owner.close();
1391
+ } catch (cause) {
1392
+ throw ArtifactReaderFailure.withCleanup(cause, ArtifactReaderFailure.cleanupObservation(cause, owned.path));
1393
+ }
1394
+ this.#ownedHandles.delete(handle);
1395
+ }
1396
+ async #closeOwnedHandles() {
1397
+ let failure;
1398
+ for (const [handle, owned] of this.#ownedHandles) {
1399
+ try {
1400
+ await this.#closeOwnedHandle(handle);
1401
+ } catch (cause) {
1402
+ failure = ArtifactReaderFailure.withCleanup(failure ?? cause, ArtifactReaderFailure.cleanupObservation(cause, owned.path));
1403
+ }
1404
+ }
1405
+ if (failure !== undefined) throw failure;
1406
+ }
1407
+ async #openOwned(path, flags) {
1408
+ const handle = await (this.options.openFile ?? open)(path, flags);
1409
+ this.#adoptHandle(handle, path);
1410
+ return handle;
1411
+ }
1412
+ #adoptHandle(handle, path) {
1413
+ this.#ownedHandles.set(handle, {
1414
+ path,
1415
+ owner: new OwnedFileHandle(handle)
1416
+ });
1417
+ }
1418
+ #ownedReadStream(handle, options) {
1419
+ const { releaseOnClose, ...readOptions } = options;
1420
+ const source = readArtifactFileChunks(handle, readOptions);
1421
+ const owned = this.#ownedHandles.get(handle);
1422
+ if (owned === undefined) throw new ArtifactReaderFailure("integrity", "ASAR handle has no owner");
1423
+ owned.source = source;
1424
+ owned.output = source;
1425
+ if (releaseOnClose !== false) source.once("close", () => {
1426
+ void this.#closeOwnedHandle(handle).catch(() => undefined);
1427
+ });
1428
+ return source;
1429
+ }
1430
+ #setOwnedOutput(handle, output) {
1431
+ const owned = this.#ownedHandles.get(handle);
1432
+ if (owned !== undefined) owned.output = output;
1433
+ }
1434
+ #resetArchiveState() {
1435
+ this.#archiveSize = undefined;
1436
+ this.#headerSize = undefined;
1437
+ }
1438
+ };
1439
+ defaultRemoveSnapshot = (path) => rm(path, {
1440
+ recursive: true,
1441
+ force: true
1442
+ });
1443
+ asarUnpackedEntryFailure = (archivePath, entry, cause) => {
1444
+ if (cause instanceof ArtifactReaderFailure) return cause;
1445
+ if (entry.unpacked && isMissingFile(cause)) return new ArtifactReaderFailure("unavailable", `ASAR unpacked entry bytes are unavailable: ${entry.path}`, { cause }, {
1446
+ logicalPath: entry.path,
1447
+ declaredSha256: entry.declaredSha256,
1448
+ calculatedSha256: null,
1449
+ unpacked: true
1450
+ });
1451
+ return asarFailure(archivePath, `read ${entry.path}`, cause);
1452
+ };
1453
+ isAsarFileMetadata = (metadata) => typeof metadata.size === "number" && metadata.files === undefined && metadata.link === undefined;
1454
+ parseArchiveOffset = (value) => {
1455
+ if (!/^(?:0|[1-9][0-9]*)$/u.test(value)) return undefined;
1456
+ const offset = Number(value);
1457
+ return Number.isSafeInteger(offset) ? offset : undefined;
1458
+ };
1459
+ abortIfNeeded$2 = (signal) => {
1460
+ if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "ASAR operation cancelled", { cause: signal.reason });
1461
+ };
1462
+ waitForOperation = async (operation, signal) => {
1463
+ if (signal === undefined) return operation;
1464
+ abortIfNeeded$2(signal);
1465
+ await new Promise((resolve, reject) => {
1466
+ const removeAbortListener = () => signal.removeEventListener("abort", onAbort);
1467
+ const onAbort = () => {
1468
+ removeAbortListener();
1469
+ reject(new ArtifactReaderFailure("cancelled", "ASAR operation cancelled", { cause: signal.reason }));
1470
+ };
1471
+ signal.addEventListener("abort", onAbort, { once: true });
1472
+ operation.then(() => {
1473
+ removeAbortListener();
1474
+ resolve();
1475
+ }, (cause) => {
1476
+ removeAbortListener();
1477
+ reject(cause);
1478
+ });
1479
+ });
1480
+ };
1481
+ asarFailure = (path, operation, cause) => {
1482
+ if (cause instanceof ArtifactReaderFailure) return cause;
1483
+ if (isFilesystemFailure(cause)) return new ArtifactReaderFailure("io", `Could not ${operation} ASAR at ${path}: ${cause.message}`, { cause });
1484
+ return new ArtifactReaderFailure("format", `Malformed ASAR during ${operation}: ${path}`, { cause });
1485
+ };
1486
+ isFilesystemFailure = (cause) => cause instanceof Error && "errno" in cause && typeof cause.errno === "number" && "syscall" in cause && typeof cause.syscall === "string";
1487
+ isMissingFile = (cause) => typeof cause === "object" && cause !== null && "code" in cause && cause.code === "ENOENT";
1488
+ })))();
1489
+ }
1490
+
1491
+ //#endregion
1492
+ //#region dist/artifacts/hostExecutableMarking.js
1493
+ var windowsLaunchableExtensions, hostExecutableMarking;
1494
+ function init_hostExecutableMarking() {
1495
+ return (init_hostExecutableMarking = __esmMin((() => {
1496
+ windowsLaunchableExtensions = new Set([
1497
+ ".bat",
1498
+ ".cmd",
1499
+ ".com",
1500
+ ".exe"
1501
+ ]);
1502
+ hostExecutableMarking = (path, metadata, platform = process.platform) => platform === "win32" ? metadata.isFile() && windowsLaunchableExtensions.has(extname(path).toLowerCase()) : typeof metadata.mode === "bigint" ? (metadata.mode & 73n) !== 0n : (metadata.mode & 73) !== 0;
1503
+ })))();
1504
+ }
1505
+
1506
+ //#endregion
1507
+ //#region dist/artifacts/DirectoryArtifactReader.js
1508
+ var DirectoryArtifactTraversalLimit, DirectoryArtifactReader, unsupportedEntryKind, artifactEntry, safeArtifactSize, directoryIoFailure, failureMessage$1, mapStableFileRead, withDirectoryIoContext, abortIfNeeded$1, assertContainedDirectory;
1509
+ function init_DirectoryArtifactReader() {
1510
+ return (init_DirectoryArtifactReader = __esmMin((() => {
1511
+ init_ArtifactReader();
1512
+ init_hostExecutableMarking();
1513
+ init_OwnedDirectoryHandle();
1514
+ init_OwnedFileHandle();
1515
+ init_readArtifactFileChunks();
1516
+ DirectoryArtifactTraversalLimit = class extends ArtifactReaderFailure {
1517
+ examinedEntries;
1518
+ maximumEntries;
1519
+ constructor(examinedEntries, maximumEntries) {
1520
+ super("limit", "Directory traversal reached its examined-entry budget", { boundary: "capacity" });
1521
+ this.examinedEntries = examinedEntries;
1522
+ this.maximumEntries = maximumEntries;
1523
+ }
1524
+ };
1525
+ DirectoryArtifactReader = class {
1526
+ format = "directory";
1527
+ #rootPromise;
1528
+ #rootIdentity;
1529
+ #rootPath;
1530
+ #directories = new Set();
1531
+ #files = new Map();
1532
+ constructor(root) {
1533
+ this.#rootPath = root;
1534
+ }
1535
+ /** Enumerate entries, optionally restricting descent while retaining directories. */
1536
+ async *entries(signal, selection) {
1537
+ const root = await this.#resolveRoot();
1538
+ const options = typeof selection === "function" ? { descendInto: selection } : selection;
1539
+ const maximum = options?.maximumEntries;
1540
+ if (maximum !== undefined && (!Number.isSafeInteger(maximum) || maximum < 0)) throw new RangeError("Directory traversal maximumEntries must be a nonnegative safe integer");
1541
+ let examined = 0;
1542
+ const examine = () => {
1543
+ if (maximum !== undefined && examined >= maximum) throw new DirectoryArtifactTraversalLimit(examined, maximum);
1544
+ examined += 1;
1545
+ };
1546
+ const pending = [root];
1547
+ while (pending.length > 0) {
1548
+ abortIfNeeded$1(signal);
1549
+ const directory = pending.pop();
1550
+ if (directory === undefined) break;
1551
+ await withDirectoryIoContext("inspect directory", directory, () => assertContainedDirectory(root, directory, this.#rootIdentity));
1552
+ for await (const entry of this.#readDirectory(directory, pending, signal, options, examine)) yield entry;
1553
+ await withDirectoryIoContext("inspect directory", directory, () => assertContainedDirectory(root, directory, this.#rootIdentity));
1554
+ }
1555
+ }
1556
+ async #resolveRoot() {
1557
+ return this.#rootPromise ??= (async () => {
1558
+ const root = await realpath(this.#rootPath);
1559
+ const metadata = await lstat(root, { bigint: true });
1560
+ if (metadata.isSymbolicLink() || !metadata.isDirectory()) throw new ArtifactReaderFailure("path", "Artifact root changed during traversal");
1561
+ this.#rootIdentity = {
1562
+ dev: metadata.dev,
1563
+ ino: metadata.ino
1564
+ };
1565
+ return root;
1566
+ })().catch((cause) => {
1567
+ if (cause instanceof ArtifactReaderFailure) throw cause;
1568
+ throw directoryIoFailure("resolve artifact root", this.#rootPath, cause);
1569
+ });
1570
+ }
1571
+ async *#readDirectory(directory, pending, signal, options, examine) {
1572
+ const root = await this.#resolveRoot();
1573
+ const handle = new OwnedDirectoryHandle(await opendir(directory).catch((cause) => {
1574
+ throw directoryIoFailure("open directory", directory, cause);
1575
+ }));
1576
+ this.#directories.add(handle);
1577
+ const childDirectories = [];
1578
+ let traversal = { kind: "complete" };
1579
+ try {
1580
+ for (;;) {
1581
+ await withDirectoryIoContext("inspect directory", directory, () => assertContainedDirectory(root, directory, this.#rootIdentity));
1582
+ const child = await handle.handle.read();
1583
+ if (child === null) break;
1584
+ examine();
1585
+ abortIfNeeded$1(signal);
1586
+ const absolute = join(directory, child.name);
1587
+ const metadata = await lstat(absolute, { bigint: true }).catch((cause) => {
1588
+ throw directoryIoFailure("inspect entry", absolute, cause);
1589
+ });
1590
+ const path = relative(root, absolute).split(sep).join("/");
1591
+ const entry = artifactEntry(path, absolute, metadata);
1592
+ if (entry === undefined) {
1593
+ options?.onOmission?.({
1594
+ path,
1595
+ kind: unsupportedEntryKind(metadata)
1596
+ });
1597
+ continue;
1598
+ }
1599
+ yield entry;
1600
+ if (entry.kind === "directory") {
1601
+ if (options?.descendInto?.(path) ?? true) childDirectories.push(absolute);
1602
+ else options?.onOmission?.({
1603
+ path,
1604
+ kind: "directory-descendants"
1605
+ });
1606
+ }
1607
+ }
1608
+ } catch (cause) {
1609
+ traversal = {
1610
+ kind: "failed",
1611
+ cause: cause instanceof ArtifactReaderFailure ? cause : directoryIoFailure("read directory", directory, cause)
1612
+ };
1613
+ } finally {
1614
+ await this.#finishDirectory(handle, directory, traversal);
1615
+ }
1616
+ if (traversal.kind === "failed") throw traversal.cause;
1617
+ childDirectories.reverse();
1618
+ pending.push(...childDirectories);
1619
+ }
1620
+ async #finishDirectory(handle, path, traversal) {
1621
+ try {
1622
+ await handle.close();
1623
+ this.#directories.delete(handle);
1624
+ } catch (cause) {
1625
+ const closeFailure = directoryIoFailure("close directory", path, cause);
1626
+ if (traversal.kind === "failed") throw ArtifactReaderFailure.withCleanup(traversal.cause, ArtifactReaderFailure.cleanupObservation(closeFailure, path));
1627
+ throw closeFailure;
1628
+ }
1629
+ }
1630
+ async open(entry, signal) {
1631
+ abortIfNeeded$1(signal);
1632
+ if (entry.kind !== "file") throw new ArtifactReaderFailure("format", "Only regular files can be opened");
1633
+ const fileHandle = await open(entry.adapterKey, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK).catch((cause) => {
1634
+ throw directoryIoFailure("open entry", entry.adapterKey, cause);
1635
+ });
1636
+ const owner = new OwnedFileHandle(fileHandle);
1637
+ this.#files.set(owner, entry.adapterKey);
1638
+ try {
1639
+ const observed = await owner.handle.stat({ bigint: true }).catch((cause) => {
1640
+ throw directoryIoFailure("inspect opened entry", entry.adapterKey, cause);
1641
+ });
1642
+ if (!observed.isFile() || !sameArtifactSourceIdentity(entry.sourceIdentity, observed)) {
1643
+ throw new ArtifactReaderFailure("integrity", `Directory entry changed before open: ${entry.path}`);
1644
+ }
1645
+ abortIfNeeded$1(signal);
1646
+ const source = Readable.from(mapStableFileRead(owner.handle, entry, signal), { objectMode: false });
1647
+ source.once("close", () => {
1648
+ void this.#closeFile(owner).catch(() => undefined);
1649
+ });
1650
+ return source;
1651
+ } catch (cause) {
1652
+ try {
1653
+ await this.#closeFile(owner);
1654
+ } catch (closeCause) {
1655
+ throw ArtifactReaderFailure.withCleanup(cause, ArtifactReaderFailure.cleanupObservation(directoryIoFailure("close opened entry", entry.adapterKey, closeCause), entry.adapterKey));
1656
+ }
1657
+ throw cause;
1658
+ }
1659
+ }
1660
+ async close() {
1661
+ const failures = [];
1662
+ for (const [owner, path] of this.#files) {
1663
+ try {
1664
+ await this.#closeFile(owner);
1665
+ } catch (cause) {
1666
+ failures.push(directoryIoFailure("close opened entry", path, cause));
1667
+ }
1668
+ }
1669
+ for (const owner of this.#directories) {
1670
+ try {
1671
+ await owner.close();
1672
+ this.#directories.delete(owner);
1673
+ } catch (cause) {
1674
+ failures.push(directoryIoFailure("close directory", owner.handle.path, cause));
1675
+ }
1676
+ }
1677
+ if (failures.length > 0) {
1678
+ const reason = failures.map(failureMessage$1).join("; ");
1679
+ throw new ArtifactReaderFailure("io", `Directory artifact cleanup failed: ${reason}`, {
1680
+ cause: new AggregateError(failures),
1681
+ cleanup: {
1682
+ reason,
1683
+ resources: [...this.#files.values(), ...[...this.#directories].map((owner) => owner.handle.path)]
1684
+ }
1685
+ });
1686
+ }
1687
+ }
1688
+ async #closeFile(owner) {
1689
+ await owner.close();
1690
+ this.#files.delete(owner);
1691
+ }
1692
+ provenance() {
1693
+ return [];
1694
+ }
1695
+ };
1696
+ unsupportedEntryKind = (metadata) => metadata.isFIFO() ? "fifo" : metadata.isSocket() ? "socket" : metadata.isBlockDevice() ? "block-device" : metadata.isCharacterDevice() ? "character-device" : "unsupported";
1697
+ artifactEntry = (path, absolute, metadata) => {
1698
+ const kind = metadata.isSymbolicLink() ? "symlink" : metadata.isDirectory() ? "directory" : metadata.isFile() ? "file" : undefined;
1699
+ if (kind === undefined) return undefined;
1700
+ return {
1701
+ path,
1702
+ kind,
1703
+ declaredSize: kind === "file" ? safeArtifactSize(metadata.size) : null,
1704
+ compressedSize: null,
1705
+ executable: hostExecutableMarking(absolute, metadata),
1706
+ encrypted: false,
1707
+ byteOffset: null,
1708
+ declaredSha256: null,
1709
+ unpacked: false,
1710
+ limitations: kind === "symlink" ? ["Symlink target was not followed or disclosed."] : [],
1711
+ adapterKey: absolute,
1712
+ ...kind === "file" ? { sourceIdentity: {
1713
+ device: metadata.dev,
1714
+ inode: metadata.ino,
1715
+ size: metadata.size,
1716
+ mode: metadata.mode,
1717
+ mtimeNs: metadata.mtimeNs,
1718
+ ctimeNs: metadata.ctimeNs
1719
+ } } : {}
1720
+ };
1721
+ };
1722
+ safeArtifactSize = (size) => {
1723
+ if (size < 0n || size > BigInt(Number.MAX_SAFE_INTEGER)) return null;
1724
+ return Number(size);
1725
+ };
1726
+ directoryIoFailure = (operation, path, cause) => {
1727
+ if (cause instanceof ArtifactReaderFailure) return cause;
1728
+ const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? ` (${cause.code})` : "";
1729
+ const detail = failureMessage$1(cause);
1730
+ return new ArtifactReaderFailure("io", `Could not ${operation} at ${path}${code}: ${detail}`, { cause });
1731
+ };
1732
+ failureMessage$1 = (cause) => cause instanceof Error ? cause.message : String(cause);
1733
+ mapStableFileRead = async function* (handle, entry, signal) {
1734
+ let bytes = 0n;
1735
+ try {
1736
+ const expectedBytes = entry.sourceIdentity?.size;
1737
+ if (expectedBytes === undefined) throw new ArtifactReaderFailure("integrity", `Directory entry has no captured file state: ${entry.path}`);
1738
+ for await (const chunk of readArtifactFileChunks(handle, {
1739
+ end: expectedBytes,
1740
+ signal
1741
+ })) {
1742
+ abortIfNeeded$1(signal);
1743
+ bytes += BigInt(chunk.length);
1744
+ yield chunk;
1745
+ }
1746
+ abortIfNeeded$1(signal);
1747
+ const [opened, current] = await Promise.all([handle.stat({ bigint: true }), lstat(entry.adapterKey, { bigint: true })]);
1748
+ abortIfNeeded$1(signal);
1749
+ if (!opened.isFile() || !current.isFile() || !sameArtifactSourceIdentity(entry.sourceIdentity, opened) || !sameArtifactSourceIdentity(entry.sourceIdentity, current) || bytes !== expectedBytes) throw new ArtifactReaderFailure("integrity", `Directory entry changed during read: ${entry.path}`);
1750
+ } catch (cause) {
1751
+ if (cause instanceof Error && "code" in cause && [
1752
+ "ENOENT",
1753
+ "ENOTDIR",
1754
+ "ELOOP"
1755
+ ].includes(String(cause.code))) throw new ArtifactReaderFailure("integrity", `Directory entry changed during read: ${entry.path}`, { cause });
1756
+ if (!(cause instanceof ArtifactReaderFailure)) throw directoryIoFailure("validate read entry", entry.adapterKey, cause);
1757
+ throw cause;
1758
+ }
1759
+ };
1760
+ withDirectoryIoContext = async (operation, path, action) => {
1761
+ try {
1762
+ return await action();
1763
+ } catch (cause) {
1764
+ throw directoryIoFailure(operation, path, cause);
1765
+ }
1766
+ };
1767
+ abortIfNeeded$1 = (signal) => {
1768
+ if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact traversal cancelled", { cause: signal.reason });
1769
+ };
1770
+ assertContainedDirectory = async (root, directory, rootIdentity) => {
1771
+ const canonical = await realpath(directory);
1772
+ const fromRoot = relative(root, canonical);
1773
+ const metadata = await lstat(directory);
1774
+ const currentRoot = await lstat(root, { bigint: true });
1775
+ if (rootIdentity === undefined || currentRoot.dev !== rootIdentity.dev || currentRoot.ino !== rootIdentity.ino || metadata.isSymbolicLink() || !metadata.isDirectory() || fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) throw new ArtifactReaderFailure("path", "Directory traversal escaped or changed its artifact root");
1776
+ };
1777
+ })))();
1778
+ }
1779
+
1780
+ //#endregion
1781
+ //#region dist/artifacts/ArtifactHash.js
1782
+ var ARTIFACT_CLASSIFICATION_PREFIX_BYTES, abortIfNeeded, hashReadable;
1783
+ function init_ArtifactHash() {
1784
+ return (init_ArtifactHash = __esmMin((() => {
1785
+ init_ArtifactReader();
1786
+ init_StreamBytes();
1787
+ init_appleArchiveFormat();
1788
+ ARTIFACT_CLASSIFICATION_PREFIX_BYTES = 8192;
1789
+ abortIfNeeded = (signal) => {
1790
+ if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact inventory cancelled", { cause: signal.reason });
1791
+ };
1792
+ hashReadable = async (stream, signal) => {
1793
+ const hash = createHash("sha256");
1794
+ const prefixes = [];
1795
+ let prefixBytes = 0;
1796
+ const xmlProbe = createXmlPlistSignatureProbe();
1797
+ let bytes = 0;
1798
+ for await (const raw of stream) {
1799
+ abortIfNeeded(signal);
1800
+ const chunk = streamChunkToBuffer(raw);
1801
+ bytes += chunk.length;
1802
+ hash.update(chunk);
1803
+ let chunkOffset = 0;
1804
+ while (chunkOffset < chunk.length && (prefixBytes < 8192 || xmlProbe.state === "pending" && prefixBytes < 1048576)) {
1805
+ const limit = prefixBytes < 8192 ? ARTIFACT_CLASSIFICATION_PREFIX_BYTES : MAX_XML_PLIST_PROBE_BYTES;
1806
+ const selected = chunk.subarray(chunkOffset, Math.min(chunkOffset + limit - prefixBytes, chunk.length));
1807
+ prefixes.push(selected);
1808
+ prefixBytes += selected.length;
1809
+ chunkOffset += selected.length;
1810
+ xmlProbe.write(selected);
1811
+ }
1812
+ }
1813
+ abortIfNeeded(signal);
1814
+ return {
1815
+ sha256: hash.digest("hex"),
1816
+ bytes,
1817
+ prefix: Buffer.concat(prefixes)
1818
+ };
1819
+ };
1820
+ })))();
1821
+ }
1822
+
1823
+ //#endregion
1824
+ //#region dist/domain/javascript/javascriptArtifactFiles.js
1825
+ var isJavaScriptSourcePath;
1826
+ function init_javascriptArtifactFiles() {
1827
+ return (init_javascriptArtifactFiles = __esmMin((() => {
1828
+ isJavaScriptSourcePath = (path) => /\.(?:cjs|cts|mjs|mts|js|jsx|ts|tsx)$/iu.test(path);
1829
+ })))();
1830
+ }
1831
+
1832
+ //#endregion
1833
+ //#region dist/artifacts/inventory/ArtifactGraphConstruction.js
1834
+ var indexOccurrencesByPath, createOccurrence, noteUnreadContainerSuffix, containerSuffixFamily, materializeDirectoryNodes, createRootNode, createArtifactNode, rootOccurrenceFor, rekeyOccurrences, createArtifactEdges, resolveOccurrenceParents, classifyArtifactPath, classifyArtifactContent, hasAsarHeader, artifactRoleForFormat, classifyArtifactBytes, classifyFatArtifact, relationFor, depth;
1835
+ function init_ArtifactGraphConstruction() {
1836
+ return (init_ArtifactGraphConstruction = __esmMin((() => {
1837
+ init_unicodeCodePointOrder();
1838
+ init_javascriptArtifactFiles();
1839
+ init_canonicalDigest();
1840
+ init_appleArchiveFormat();
1841
+ init_artifactIdentity();
1842
+ init_zipPackageFormat();
1843
+ init_dosMz();
1844
+ init_machoContainer();
1845
+ indexOccurrencesByPath = (occurrences) => {
1846
+ const byPath = new Map();
1847
+ for (const occurrence of occurrences) {
1848
+ const matches = byPath.get(occurrence.logical_path);
1849
+ if (matches === undefined) byPath.set(occurrence.logical_path, [occurrence]);
1850
+ else matches.push(occurrence);
1851
+ }
1852
+ return byPath;
1853
+ };
1854
+ createOccurrence = (entry, path, parent, duplicateOrdinal = 0) => {
1855
+ const role = entry.kind === "directory" ? {
1856
+ kind: path.toLowerCase().endsWith(".framework") ? "framework" : "container",
1857
+ format: "directory"
1858
+ } : containerSuffixFamily(path) === undefined ? classifyArtifactPath(path) : {
1859
+ kind: "unknown",
1860
+ format: "unknown"
1861
+ };
1862
+ return {
1863
+ occurrence_id: `occ_${digestCanonicalValue(duplicateOrdinal === 0 ? {
1864
+ path,
1865
+ kind: entry.kind
1866
+ } : {
1867
+ path,
1868
+ kind: entry.kind,
1869
+ duplicate_ordinal: duplicateOrdinal
1870
+ }, "Artifact")}`,
1871
+ artifact_id: null,
1872
+ parent_occurrence_id: parent,
1873
+ logical_path: path,
1874
+ entry_kind: entry.kind,
1875
+ artifact_kind: role.kind,
1876
+ artifact_format: role.format,
1877
+ declared_size: entry.declaredSize,
1878
+ compressed_size: entry.compressedSize,
1879
+ executable: entry.executable,
1880
+ encrypted: entry.encrypted,
1881
+ hash_status: entry.encrypted ? "unavailable" : "not-hashed",
1882
+ source_location: entry.byteOffset === null || entry.declaredSize === null ? null : {
1883
+ offset: entry.byteOffset,
1884
+ length: entry.declaredSize
1885
+ },
1886
+ limitations: [...entry.limitations]
1887
+ };
1888
+ };
1889
+ noteUnreadContainerSuffix = (occurrence) => {
1890
+ if (occurrence.entry_kind === "directory") return;
1891
+ const family = containerSuffixFamily(occurrence.logical_path);
1892
+ if (family === undefined) return;
1893
+ occurrence.limitations.push(`The path suffix suggests ${family.toUpperCase()}, but these bytes were not read, so the container family is unknown.`);
1894
+ };
1895
+ containerSuffixFamily = (path) => {
1896
+ const lower = path.toLowerCase();
1897
+ return lower.endsWith(".asar") ? "asar" : zipPackageFormatForPath(lower);
1898
+ };
1899
+ materializeDirectoryNodes = (occurrences, nodes) => {
1900
+ const directories = occurrences.filter(({ entry_kind: kind, hash_status }) => kind === "directory" && hash_status !== "unavailable").sort((left, right) => depth(right.logical_path) - depth(left.logical_path));
1901
+ const childrenByParent = new Map();
1902
+ for (const occurrence of occurrences) {
1903
+ if (occurrence.parent_occurrence_id === null) continue;
1904
+ const children = childrenByParent.get(occurrence.parent_occurrence_id);
1905
+ if (children === undefined) childrenByParent.set(occurrence.parent_occurrence_id, [occurrence]);
1906
+ else children.push(occurrence);
1907
+ }
1908
+ for (const directory of directories) {
1909
+ const children = (childrenByParent.get(directory.occurrence_id) ?? []).map(({ logical_path, artifact_id, entry_kind }) => ({
1910
+ name: logical_path.slice(directory.logical_path.length + 1),
1911
+ artifact_id,
1912
+ entry_kind
1913
+ })).sort((left, right) => compareUnicodeCodePoints(left.name, right.name));
1914
+ const node = createArtifactNode({
1915
+ sha256: digestCanonicalValue({
1916
+ kind: "directory",
1917
+ children
1918
+ }, "Artifact"),
1919
+ size: 0,
1920
+ format: "directory",
1921
+ contentState: "virtual"
1922
+ });
1923
+ nodes.set(node.artifact_id, node);
1924
+ directory.artifact_id = node.artifact_id;
1925
+ directory.hash_status = "verified";
1926
+ }
1927
+ };
1928
+ createRootNode = (input) => createArtifactNode({
1929
+ sha256: input.digest?.sha256 ?? digestCanonicalValue({
1930
+ kind: "directory-root",
1931
+ children: input.occurrences.map(({ logical_path, artifact_id }) => ({
1932
+ logical_path,
1933
+ artifact_id
1934
+ })).sort((left, right) => compareUnicodeCodePoints(left.logical_path, right.logical_path))
1935
+ }, "Artifact"),
1936
+ size: input.digest?.bytes ?? 0,
1937
+ format: input.digest === null ? "directory" : classifyArtifactBytes(input.digest.prefix, input.digest.bytes),
1938
+ contentState: "materialized"
1939
+ });
1940
+ createArtifactNode = (input) => ({
1941
+ artifact_id: artifactIdForContent(input.sha256),
1942
+ format: input.format,
1943
+ sha256: input.sha256,
1944
+ size: input.size,
1945
+ media_type: null,
1946
+ architecture: null,
1947
+ content_state: input.contentState,
1948
+ limitations: []
1949
+ });
1950
+ rootOccurrenceFor = (node, metadata) => ({
1951
+ occurrence_id: occurrenceIdForLocation({
1952
+ rootArtifactId: node.artifact_id,
1953
+ logicalPath: ".",
1954
+ entryKind: metadata.format === "directory" ? "directory" : "file"
1955
+ }),
1956
+ artifact_id: node.artifact_id,
1957
+ parent_occurrence_id: null,
1958
+ logical_path: ".",
1959
+ entry_kind: metadata.format === "directory" ? "directory" : "file",
1960
+ artifact_kind: metadata.format === "directory" || isZipPackageFormat(metadata.format) || [
1961
+ "asar",
1962
+ "dmg",
1963
+ "pkg"
1964
+ ].includes(metadata.format) ? "container" : artifactRoleForFormat(metadata.path, metadata.format).kind,
1965
+ artifact_format: metadata.format,
1966
+ declared_size: metadata.size,
1967
+ compressed_size: null,
1968
+ executable: metadata.executable,
1969
+ encrypted: false,
1970
+ hash_status: "verified",
1971
+ source_location: null,
1972
+ limitations: []
1973
+ });
1974
+ rekeyOccurrences = (rootArtifactId, occurrences) => {
1975
+ const replacements = new Map();
1976
+ const ordinalByPath = new Map();
1977
+ for (const occurrence of occurrences) {
1978
+ const ordinal = ordinalByPath.get(occurrence.logical_path) ?? 0;
1979
+ ordinalByPath.set(occurrence.logical_path, ordinal + 1);
1980
+ replacements.set(occurrence.occurrence_id, occurrenceIdForLocation({
1981
+ rootArtifactId,
1982
+ logicalPath: occurrence.logical_path,
1983
+ entryKind: occurrence.entry_kind,
1984
+ ...ordinal === 0 ? {} : { duplicateOrdinal: ordinal }
1985
+ }));
1986
+ }
1987
+ for (const occurrence of occurrences) {
1988
+ occurrence.occurrence_id = replacements.get(occurrence.occurrence_id) ?? occurrence.occurrence_id;
1989
+ if (occurrence.parent_occurrence_id !== null) occurrence.parent_occurrence_id = replacements.get(occurrence.parent_occurrence_id) ?? occurrence.parent_occurrence_id;
1990
+ }
1991
+ };
1992
+ createArtifactEdges = (rootArtifactId, occurrences, producer) => {
1993
+ const byId = new Map(occurrences.map((item) => [item.occurrence_id, item]));
1994
+ const byPath = indexOccurrencesByPath(occurrences);
1995
+ const edges = [];
1996
+ const limitations = [];
1997
+ for (const occurrence of occurrences) {
1998
+ const isSourceMap = occurrence.artifact_kind === "source-map";
1999
+ const sourcePath = isSourceMap ? occurrence.logical_path.slice(0, -".map".length) : undefined;
2000
+ const sourceCandidates = sourcePath === undefined ? [] : byPath.get(sourcePath) ?? [];
2001
+ const mappedSource = sourceCandidates.length === 1 && sourceCandidates[0]?.artifact_id !== null ? sourceCandidates[0] : undefined;
2002
+ if (sourcePath !== undefined) {
2003
+ const unknownMapping = sourceCandidates.length > 1 ? {
2004
+ occurrence: `Source-map target is unknown because multiple occurrences share ${JSON.stringify(sourcePath)}.`,
2005
+ coverage: `Source-map relationships are unknown because multiple occurrences share ${JSON.stringify(sourcePath)}.`
2006
+ } : sourceCandidates.length === 1 && mappedSource === undefined ? {
2007
+ occurrence: `Source-map target identity is unknown because the matching occurrence at ${JSON.stringify(sourcePath)} has no content identity.`,
2008
+ coverage: `Source-map relationships are unknown because the matching occurrence at ${JSON.stringify(sourcePath)} has no content identity.`
2009
+ } : undefined;
2010
+ if (unknownMapping !== undefined) {
2011
+ occurrence.limitations.push(unknownMapping.occurrence);
2012
+ limitations.push(unknownMapping.coverage);
2013
+ }
2014
+ }
2015
+ if (occurrence.parent_occurrence_id === null || occurrence.artifact_id === null) continue;
2016
+ const parentArtifactId = mappedSource?.artifact_id ?? byId.get(occurrence.parent_occurrence_id)?.artifact_id ?? rootArtifactId;
2017
+ const semantic = {
2018
+ parent_artifact_id: parentArtifactId,
2019
+ relation: occurrence.entry_kind === "slice" ? "slice-of" : isSourceMap ? mappedSource === undefined ? "contains" : "maps-source" : relationFor(occurrence.logical_path),
2020
+ occurrence_id: occurrence.occurrence_id
2021
+ };
2022
+ edges.push({
2023
+ edge_id: artifactEdgeId(semantic, occurrence),
2024
+ ...semantic,
2025
+ producer: occurrence.entry_kind === "slice" ? producer ?? null : null,
2026
+ ordinal: edges.length
2027
+ });
2028
+ }
2029
+ return {
2030
+ edges,
2031
+ limitations
2032
+ };
2033
+ };
2034
+ resolveOccurrenceParents = (occurrences, byPath, expandedContainerIds) => {
2035
+ const root = { children: new Map() };
2036
+ for (const matches of byPath.values()) {
2037
+ const parents = matches.filter((occurrence) => occurrence.entry_kind === "directory" || expandedContainerIds.has(occurrence.occurrence_id));
2038
+ if (parents.length === 0) continue;
2039
+ if (parents.length > 1) {
2040
+ for (const parent of parents) if (parent.entry_kind === "directory") {
2041
+ parent.artifact_id = null;
2042
+ parent.hash_status = "unavailable";
2043
+ parent.limitations.push("This directory occurrence cannot be materialized because multiple directory entries share its logical path.");
2044
+ }
2045
+ }
2046
+ const path = matches[0]?.logical_path;
2047
+ if (path === undefined) continue;
2048
+ let branch = root;
2049
+ for (const segment of path.split("/")) {
2050
+ let child = branch.children.get(segment);
2051
+ if (child === undefined) {
2052
+ child = { children: new Map() };
2053
+ branch.children.set(segment, child);
2054
+ }
2055
+ branch = child;
2056
+ }
2057
+ branch.occurrences = parents;
2058
+ }
2059
+ const limitations = new Set();
2060
+ const unknownParentOccurrences = new Set();
2061
+ for (const occurrence of occurrences) {
2062
+ const path = occurrence.logical_path;
2063
+ let branch = root;
2064
+ let parent;
2065
+ let ambiguousParentPath;
2066
+ let prefix = "";
2067
+ for (let start = 0;;) {
2068
+ const slash = path.indexOf("/", start);
2069
+ if (slash < 0) break;
2070
+ const segment = path.slice(start, slash);
2071
+ const child = branch.children.get(segment);
2072
+ if (child === undefined) break;
2073
+ branch = child;
2074
+ prefix = prefix.length === 0 ? segment : `${prefix}/${segment}`;
2075
+ const candidates = branch.occurrences ?? [];
2076
+ if (candidates.length === 1) {
2077
+ parent = candidates[0];
2078
+ ambiguousParentPath = undefined;
2079
+ } else if (candidates.length > 1) {
2080
+ parent = undefined;
2081
+ ambiguousParentPath = prefix;
2082
+ }
2083
+ start = slash + 1;
2084
+ }
2085
+ occurrence.parent_occurrence_id = parent?.occurrence_id ?? null;
2086
+ if (ambiguousParentPath !== undefined) {
2087
+ const limitation = `The parent occurrence for ${JSON.stringify(path)} is unknown because multiple observed directory or container occurrences share ${JSON.stringify(ambiguousParentPath)}.`;
2088
+ occurrence.limitations.push(limitation);
2089
+ limitations.add(limitation);
2090
+ unknownParentOccurrences.add(occurrence);
2091
+ }
2092
+ }
2093
+ return {
2094
+ limitations: [...limitations].sort(compareUnicodeCodePoints),
2095
+ unknownParentOccurrences
2096
+ };
2097
+ };
2098
+ classifyArtifactPath = (path) => {
2099
+ const lower = path.toLowerCase();
2100
+ if (lower.endsWith(".map")) return {
2101
+ kind: "source-map",
2102
+ format: "source-map"
2103
+ };
2104
+ if (isJavaScriptSourcePath(path)) return {
2105
+ kind: "javascript",
2106
+ format: "javascript-bundle"
2107
+ };
2108
+ if (/\.framework(?:\/|$)/u.test(lower)) return {
2109
+ kind: "framework",
2110
+ format: "file"
2111
+ };
2112
+ if (/\.(?:node|dylib|so)$/u.test(lower)) return {
2113
+ kind: lower.endsWith(".node") ? "native-addon" : "dynamic-library",
2114
+ format: "file"
2115
+ };
2116
+ if (lower.endsWith(".plist")) return {
2117
+ kind: "plist",
2118
+ format: "plist"
2119
+ };
2120
+ if (lower.endsWith(".entitlements")) return {
2121
+ kind: "entitlements",
2122
+ format: "entitlements"
2123
+ };
2124
+ return {
2125
+ kind: "resource",
2126
+ format: "file"
2127
+ };
2128
+ };
2129
+ classifyArtifactContent = (path, prefix, fileSize = prefix.length) => {
2130
+ const format = classifyArtifactBytes(prefix, fileSize);
2131
+ const byPath = classifyArtifactPath(path);
2132
+ if (format === "plist" && !hasBinaryPlistSignature(prefix) && ([
2133
+ "javascript",
2134
+ "source-map",
2135
+ "entitlements"
2136
+ ].includes(byPath.kind) || path.toLowerCase().endsWith(".asar"))) return byPath;
2137
+ if (format === "file" && path.toLowerCase().endsWith(".asar") && hasAsarHeader(prefix)) return {
2138
+ kind: "container",
2139
+ format: "asar"
2140
+ };
2141
+ return artifactRoleForFormat(path, format);
2142
+ };
2143
+ hasAsarHeader = (prefix) => {
2144
+ if (prefix.length < 17 || prefix.readUInt32LE(0) !== 4) return false;
2145
+ const headerSize = prefix.readUInt32LE(4);
2146
+ const payloadSize = prefix.readUInt32LE(8);
2147
+ if (headerSize < 16 || payloadSize !== headerSize - 4) return false;
2148
+ const stringLength = prefix.readUInt32LE(12);
2149
+ return stringLength >= 2 && stringLength <= payloadSize - 4 && prefix[16] === 123;
2150
+ };
2151
+ artifactRoleForFormat = (path, format) => {
2152
+ const byPath = classifyArtifactPath(path);
2153
+ if (format === "file" || format === byPath.format) return byPath;
2154
+ if (format === "unknown") return {
2155
+ kind: "unknown",
2156
+ format
2157
+ };
2158
+ if (format === "zip") return {
2159
+ kind: "container",
2160
+ format: zipPackageFormatForPath(path) ?? format
2161
+ };
2162
+ if (format === "plist") return {
2163
+ kind: "plist",
2164
+ format
2165
+ };
2166
+ return {
2167
+ kind: ["native-addon", "dynamic-library"].includes(byPath.kind) ? byPath.kind : "executable",
2168
+ format
2169
+ };
2170
+ };
2171
+ classifyArtifactBytes = (prefix, fileSize = prefix.length) => {
2172
+ if (hasZipSignature(prefix)) return "zip";
2173
+ if (hasBinaryPlistSignature(prefix)) return "plist";
2174
+ if (hasXmlPlistSignature(prefix)) return "plist";
2175
+ const fatFormat = classifyFatArtifact(prefix, fileSize);
2176
+ if (fatFormat !== null) return fatFormat;
2177
+ if (prefix.length >= 4) {
2178
+ const magic = prefix.readUInt32BE(0);
2179
+ if ([
2180
+ 4277009102,
2181
+ 4277009103,
2182
+ 3472551422,
2183
+ 3489328638
2184
+ ].includes(magic)) return "mach-o";
2185
+ if (prefix.subarray(0, 4).equals(Buffer.from([
2186
+ 127,
2187
+ 69,
2188
+ 76,
2189
+ 70
2190
+ ]))) return "elf";
2191
+ }
2192
+ if (prefix.length >= 2 && prefix[0] === 77 && prefix[1] === 90) {
2193
+ if (!Number.isSafeInteger(fileSize) || fileSize < prefix.length || prefix.length < Math.min(fileSize, 64)) return "unknown";
2194
+ const windowsHeader = observeMzWindowsHeader(prefix, fileSize);
2195
+ if (windowsHeader.state === "signature-needed") return "unknown";
2196
+ if (windowsHeader.state === "declared") {
2197
+ const windowsOffset = windowsHeader.offset;
2198
+ if (windowsHeader.signature === "PE" && windowsOffset >= 64 && windowsOffset <= prefix.length - 4) return "pe";
2199
+ return "unknown";
2200
+ }
2201
+ if (parseDosMzHeader(prefix, fileSize).ok) return "dos-mz";
2202
+ return "unknown";
2203
+ }
2204
+ return "file";
2205
+ };
2206
+ classifyFatArtifact = (prefix, fileSize) => {
2207
+ const fatHeader = readFatContainerHeader(prefix, fileSize);
2208
+ if (fatHeader.state === "needs-data" || fatHeader.state === "malformed") return "unknown";
2209
+ if (fatHeader.state === "not-fat") return null;
2210
+ const identity = classifyFatContainerIdentity(fatHeader, (offset) => {
2211
+ if (offset >= prefix.length) return undefined;
2212
+ if (offset + 4 > prefix.length) return null;
2213
+ return prefix.readUInt32BE(offset);
2214
+ });
2215
+ return identity.state === "mach-o" ? "mach-o-universal" : "unknown";
2216
+ };
2217
+ relationFor = (path) => path.toLowerCase().includes(".framework/") ? "embeds" : "contains";
2218
+ depth = (path) => path.split("/").length;
2219
+ })))();
2220
+ }
2221
+
2222
+ //#endregion
2223
+ //#region dist/artifacts/inventory/hashStableRootArtifact.js
2224
+ var openRootArtifact, hashStableRootArtifact, hashStableRootArtifactHandle;
2225
+ function init_hashStableRootArtifact() {
2226
+ return (init_hashStableRootArtifact = __esmMin((() => {
2227
+ init_OwnedRegularFile();
2228
+ init_readArtifactFileChunks();
2229
+ init_OwnedFileHandle();
2230
+ init_ArtifactReader();
2231
+ init_RegularFile();
2232
+ init_ArtifactHash();
2233
+ openRootArtifact = async (path, resourceScope, signal) => {
2234
+ try {
2235
+ return new OwnedFileHandle(await openRegularFile(path, {
2236
+ symlinks: "reject",
2237
+ signal
2238
+ }));
2239
+ } catch (cause) {
2240
+ const primary = cause instanceof RegularFileAdmissionFailure ? cause.cause : cause;
2241
+ const cancellation = regularFileCancellation(primary);
2242
+ const failure = cancellation !== undefined ? new ArtifactReaderFailure("cancelled", "Artifact admission cancelled", { cause: cancellation.reason }) : primary instanceof NonRegularFileReadError ? new ArtifactReaderFailure("format", `Artifact root is not a regular file: ${path}`, { cause: primary }) : primary;
2243
+ if (cause instanceof RegularFileAdmissionFailure) {
2244
+ const resource = `root artifact descriptor for ${path}`;
2245
+ const cleanup = await resourceScope.release({
2246
+ kind: "file-handle",
2247
+ resource,
2248
+ handle: cause.owner
2249
+ });
2250
+ if (cleanup.kind === "failed") throw resourceScope.cleanupFailure({
2251
+ kind: "failed",
2252
+ cause: failure
2253
+ }, [cleanup]);
2254
+ }
2255
+ throw failure;
2256
+ }
2257
+ };
2258
+ hashStableRootArtifact = async (path, resourceScope, signal) => {
2259
+ const owner = await openRootArtifact(path, resourceScope, signal);
2260
+ const handle = owner.handle;
2261
+ let outcome;
2262
+ try {
2263
+ const initial = await handle.stat();
2264
+ outcome = {
2265
+ kind: "completed",
2266
+ value: await hashStableRootArtifactHandle(path, handle, initial, signal)
2267
+ };
2268
+ } catch (cause) {
2269
+ outcome = {
2270
+ kind: "failed",
2271
+ cause
2272
+ };
2273
+ }
2274
+ const resource = `root artifact descriptor for ${path}`;
2275
+ const cleanup = await resourceScope.release({
2276
+ kind: "file-handle",
2277
+ resource,
2278
+ handle: owner
2279
+ });
2280
+ if (cleanup.kind === "failed") throw resourceScope.cleanupFailure(outcome, [cleanup]);
2281
+ if (outcome.kind === "failed") throw outcome.cause;
2282
+ return outcome.value;
2283
+ };
2284
+ hashStableRootArtifactHandle = async (path, handle, initial, signal) => {
2285
+ const digest = await hashReadable(readArtifactFileChunks(handle, {
2286
+ start: 0,
2287
+ end: initial.size,
2288
+ signal
2289
+ }), signal);
2290
+ abortIfNeeded(signal);
2291
+ const [opened, currentPath] = await Promise.all([handle.stat(), lstat(path)]);
2292
+ if (!sameRegularFileState(initial, opened) || !sameRegularFileState(initial, currentPath) || digest.bytes !== initial.size) throw new ArtifactReaderFailure("integrity", `Root artifact changed during inventory: ${path}`);
2293
+ abortIfNeeded(signal);
2294
+ return digest;
2295
+ };
2296
+ })))();
2297
+ }
2298
+
2299
+ //#endregion
2300
+ //#region dist/artifacts/inventory/classify.js
2301
+ var classifyAndHashRoot, classifyAndHashRootForInventory, classifyRootFormat, zipRootPackageFormat, hasKolyTrailer;
2302
+ function init_classify() {
2303
+ return (init_classify = __esmMin((() => {
2304
+ init_RegularFile();
2305
+ init_ArtifactGraphConstruction();
2306
+ init_ArtifactHash();
2307
+ init_appleArchiveFormat();
2308
+ init_zipPackageFormat();
2309
+ init_ArtifactReader();
2310
+ init_hashStableRootArtifact();
2311
+ classifyAndHashRoot = async (path, directory, expectedMetadata, options) => {
2312
+ return options.resourceScope.run(async () => {
2313
+ const result = await classifyAndHashRootForInventory(path, directory, expectedMetadata, options);
2314
+ const rootSource = result.rootSource;
2315
+ if (rootSource !== undefined) {
2316
+ const owner = {
2317
+ kind: "file-handle",
2318
+ handle: rootSource.owner,
2319
+ resource: `root artifact descriptor for ${path}`
2320
+ };
2321
+ const cleanupAttempt = await options.resourceScope.release(owner);
2322
+ if (cleanupAttempt.kind === "failed") throw options.resourceScope.cleanupFailure({ kind: "completed" }, [cleanupAttempt]);
2323
+ }
2324
+ return {
2325
+ format: result.format,
2326
+ digest: result.digest
2327
+ };
2328
+ });
2329
+ };
2330
+ classifyAndHashRootForInventory = async (path, directory, expectedMetadata, options) => {
2331
+ if (directory) return {
2332
+ format: "directory",
2333
+ digest: null,
2334
+ rootSource: undefined
2335
+ };
2336
+ const ownedHandle = await openRootArtifact(path, options.resourceScope, options.signal);
2337
+ const handle = ownedHandle.handle;
2338
+ const owner = {
2339
+ kind: "file-handle",
2340
+ handle: ownedHandle,
2341
+ resource: `root artifact descriptor for ${path}`
2342
+ };
2343
+ let outcome;
2344
+ try {
2345
+ const initial = await handle.stat();
2346
+ if (!sameRegularFileState(expectedMetadata, initial)) throw new ArtifactReaderFailure("integrity", `Root artifact changed before inventory: ${path}`);
2347
+ const format = await classifyRootFormat(path, handle, options.signal);
2348
+ const digest = await hashStableRootArtifactHandle(path, handle, initial, options.signal);
2349
+ const retainSource = isZipPackageFormat(format) || format === "mach-o-universal";
2350
+ outcome = {
2351
+ kind: "completed",
2352
+ value: {
2353
+ format,
2354
+ digest,
2355
+ rootSource: retainSource ? {
2356
+ handle,
2357
+ initial,
2358
+ owner: ownedHandle
2359
+ } : undefined
2360
+ }
2361
+ };
2362
+ } catch (cause) {
2363
+ outcome = {
2364
+ kind: "failed",
2365
+ cause
2366
+ };
2367
+ }
2368
+ if (outcome.kind === "failed" || outcome.value.rootSource === undefined) {
2369
+ const cleanupAttempt = await options.resourceScope.release(owner);
2370
+ if (cleanupAttempt.kind === "failed") throw options.resourceScope.cleanupFailure(outcome, [cleanupAttempt]);
2371
+ }
2372
+ if (outcome.kind === "failed") throw outcome.cause;
2373
+ return outcome.value;
2374
+ };
2375
+ classifyRootFormat = async (path, handle, signal) => {
2376
+ const magic = Buffer.alloc(ARTIFACT_CLASSIFICATION_PREFIX_BYTES);
2377
+ const observed = await handle.read(magic, 0, magic.length, 0);
2378
+ let prefix = magic.subarray(0, observed.bytesRead);
2379
+ const lower = path.toLowerCase();
2380
+ if (hasZipSignature(prefix)) return zipRootPackageFormat(lower);
2381
+ if (lower.endsWith(".pkg") && prefix.subarray(0, 4).equals(Buffer.from("xar!"))) return "pkg";
2382
+ if (lower.endsWith(".dmg") && await hasKolyTrailer(handle)) return "dmg";
2383
+ const xmlProbe = createXmlPlistSignatureProbe();
2384
+ xmlProbe.write(prefix);
2385
+ const chunks = [prefix];
2386
+ let prefixBytes = prefix.length;
2387
+ while (xmlProbe.state === "pending" && prefixBytes < 1048576) {
2388
+ abortIfNeeded(signal);
2389
+ const chunk = Buffer.alloc(Math.min(64 * 1024, MAX_XML_PLIST_PROBE_BYTES - prefixBytes));
2390
+ const read = await handle.read(chunk, 0, chunk.length, prefixBytes);
2391
+ abortIfNeeded(signal);
2392
+ if (read.bytesRead === 0) break;
2393
+ const selected = chunk.subarray(0, read.bytesRead);
2394
+ chunks.push(selected);
2395
+ prefixBytes += selected.length;
2396
+ xmlProbe.write(selected);
2397
+ }
2398
+ prefix = Buffer.concat(chunks);
2399
+ return classifyArtifactContent(path, prefix, (await handle.stat()).size).format;
2400
+ };
2401
+ zipRootPackageFormat = (lower) => lower.endsWith(".app") ? "app-pack" : zipPackageFormatForPath(lower) ?? "zip";
2402
+ hasKolyTrailer = async (handle) => {
2403
+ const size = (await handle.stat()).size;
2404
+ if (size < 512) return false;
2405
+ const trailer = Buffer.alloc(4);
2406
+ const read = await handle.read(trailer, 0, trailer.length, size - 512);
2407
+ return read.bytesRead === 4 && trailer.equals(Buffer.from("koly"));
2408
+ };
2409
+ })))();
2410
+ }
2411
+
2412
+ //#endregion
2413
+ //#region dist/artifacts/MachOSliceArtifactReader.js
2414
+ var MachOSliceArtifactReader, readStructuralSlices, lipoMatchesSlice, lipoSubtypeMatches, lipoNameMatches;
2415
+ function init_MachOSliceArtifactReader() {
2416
+ return (init_MachOSliceArtifactReader = __esmMin((() => {
2417
+ init_ArtifactFileOperation();
2418
+ init_CommandRunner();
2419
+ init_lipo();
2420
+ init_machoCpuIdentity();
2421
+ init_OwnedFileHandle();
2422
+ init_MachoLoadCommandReader();
2423
+ init_ArtifactReader();
2424
+ init_StreamBytes();
2425
+ init_RegularFile();
2426
+ init_readArtifactFileChunks();
2427
+ MachOSliceArtifactReader = class {
2428
+ path;
2429
+ runner;
2430
+ format = "file";
2431
+ #command;
2432
+ #source;
2433
+ #ownedSource;
2434
+ #pendingSource;
2435
+ #entries = new Map();
2436
+ #pendingCommands = new Set();
2437
+ #ownsSource;
2438
+ #closed = false;
2439
+ #closePromise;
2440
+ constructor(path, environment, runner = new XcrunCommandRunner(environment), source) {
2441
+ this.path = path;
2442
+ this.runner = runner;
2443
+ this.#source = source;
2444
+ this.#ownsSource = source === undefined;
2445
+ }
2446
+ async *entries(signal) {
2447
+ this.#entries.clear();
2448
+ const source = await this.#ensureSource();
2449
+ await this.#verifySource(source);
2450
+ if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader is closed");
2451
+ const command = this.runner.run("lipo", ["-detailed_info", this.path], signal === undefined ? {} : { signal });
2452
+ this.#pendingCommands.add(command);
2453
+ let captured;
2454
+ try {
2455
+ captured = await command;
2456
+ } finally {
2457
+ this.#pendingCommands.delete(command);
2458
+ }
2459
+ if (!captured.ok) throw new ArtifactReaderFailure(captured.error.reason === "cancelled" ? "cancelled" : "unavailable", captured.error.detail === null ? "lipo could not enumerate universal Mach-O slices" : `lipo could not enumerate universal Mach-O slices: ${captured.error.detail}`, {
2460
+ cause: captured.error,
2461
+ ...captured.error.cleanupFailure === null && captured.error.cleanupResources.length === 0 ? {} : { cleanup: {
2462
+ reason: captured.error.cleanupFailure ?? "Native command cleanup remains unverified",
2463
+ resources: [...captured.error.cleanupResources]
2464
+ } }
2465
+ });
2466
+ if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader closed during slice discovery");
2467
+ this.#command = {
2468
+ tool: captured.value.tool,
2469
+ arguments: ["-detailed_info", "$ARTIFACT"],
2470
+ tool_version: captured.value.toolVersion,
2471
+ executable_sha256: captured.value.executableSha256,
2472
+ exit_code: captured.value.exitCode,
2473
+ effects: ["read"]
2474
+ };
2475
+ await this.#verifySource(source);
2476
+ const fileSize = source.initial.size;
2477
+ const { architectures } = parseLipoOutput(captured.value.stdout, this.path);
2478
+ const structural = await readStructuralSlices(source.handle, fileSize);
2479
+ await this.#verifySource(source);
2480
+ if (structural.status === "malformed") throw new ArtifactReaderFailure("integrity", `Mach-O structural slice index is malformed: ${structural.reason}`);
2481
+ if (structural.status === "unsupported" && architectures.some(({ file_offset, size }) => file_offset === null || size === null)) throw new ArtifactReaderFailure("unavailable", `Mach-O structural slice index is unsupported: ${structural.reason}`);
2482
+ const slices = structural.status === "parsed" ? structural.slices : null;
2483
+ const matchingSlices = new Map();
2484
+ if (slices !== null) {
2485
+ if (slices.length !== architectures.length) throw new ArtifactReaderFailure("integrity", "lipo architecture count disagrees with the Mach-O FAT table");
2486
+ const unmatched = [...slices];
2487
+ for (const reported of architectures) {
2488
+ const match = unmatched.findIndex((observed) => lipoMatchesSlice(reported, observed, slices.length === 1));
2489
+ if (match < 0) throw new ArtifactReaderFailure("integrity", `lipo slice metadata disagrees with the Mach-O FAT table: ${reported.name} (cputype=${reported.cpu_type ?? "unknown"}, cpusubtype=${reported.cpu_subtype ?? "unknown"}, offset=${reported.file_offset ?? "unknown"}, size=${reported.size ?? "unknown"}, alignment=${reported.alignment ?? "unknown"})`);
2490
+ const [observed] = unmatched.splice(match, 1);
2491
+ if (observed !== undefined) matchingSlices.set(reported, observed);
2492
+ }
2493
+ }
2494
+ for (const architecture of architectures) {
2495
+ const structuralSlice = matchingSlices.get(architecture);
2496
+ const offset = architecture.file_offset ?? structuralSlice?.slice_offset;
2497
+ const sliceSize = architecture.size ?? structuralSlice?.slice_size;
2498
+ if (offset === undefined || sliceSize === undefined) throw new ArtifactReaderFailure("integrity", "lipo omitted a universal slice byte range");
2499
+ if (!Number.isSafeInteger(offset) || !Number.isSafeInteger(sliceSize) || offset < 0 || sliceSize <= 0 || !Number.isSafeInteger(offset + sliceSize) || offset + sliceSize > fileSize) throw new ArtifactReaderFailure("integrity", `lipo reported an out-of-bounds Mach-O slice: ${architecture.name}`);
2500
+ const entry = {
2501
+ path: `slices/${architecture.name}`,
2502
+ kind: "slice",
2503
+ declaredSize: sliceSize,
2504
+ compressedSize: null,
2505
+ executable: true,
2506
+ encrypted: false,
2507
+ byteOffset: offset,
2508
+ declaredSha256: null,
2509
+ unpacked: false,
2510
+ limitations: [
2511
+ ...structural.status === "not-mach-o" ? ["Structural Mach-O facts were unavailable; slice range is based on lipo output."] : structural.status === "unsupported" ? [`Structural Mach-O facts were unsupported (${structural.reason}); slice range is based on lipo output.`] : [],
2512
+ ...architecture.file_offset === null || architecture.size === null ? ["Slice range was derived from structural Mach-O facts because lipo omitted it."] : [],
2513
+ ...architecture.cpu_type !== null && architecture.cpu_type_code === null ? [`lipo CPU type is retained as unnormalized source text: ${architecture.cpu_type}`] : [],
2514
+ ...architecture.cpu_subtype !== null && architecture.cpu_subtype_code === null ? [`lipo CPU subtype is retained as unnormalized source text: ${architecture.cpu_subtype}${architecture.capabilities === null ? "" : `; capabilities ${architecture.capabilities}`}`] : []
2515
+ ],
2516
+ adapterKey: `${String(offset)}:${String(sliceSize)}`
2517
+ };
2518
+ this.#entries.set(entry.adapterKey, copyArtifactEntry(entry));
2519
+ yield entry;
2520
+ }
2521
+ }
2522
+ async open(entry, signal) {
2523
+ if (signal?.aborted === true) return Promise.reject(new ArtifactReaderFailure("cancelled", "Mach-O slice read cancelled", { cause: signal.reason }));
2524
+ const produced = this.#entries.get(entry.adapterKey);
2525
+ if (produced === undefined || !sameArtifactEntry(entry, produced)) throw new ArtifactReaderFailure("integrity", "Mach-O slice entry metadata does not match this reader's inventory");
2526
+ const offset = produced.byteOffset;
2527
+ const size = produced.declaredSize;
2528
+ if (offset === null || size === null || !Number.isSafeInteger(offset) || !Number.isSafeInteger(size) || offset < 0 || size <= 0) throw new ArtifactReaderFailure("integrity", "Invalid Mach-O slice byte range");
2529
+ const source = await this.#ensureSource();
2530
+ await this.#verifySource(source);
2531
+ if (!Number.isSafeInteger(offset + size) || offset + size > source.initial.size) throw new ArtifactReaderFailure("integrity", `Mach-O slice range is outside the artifact: ${entry.path}`);
2532
+ const sourceStream = readArtifactFileChunks(source.handle, {
2533
+ start: offset,
2534
+ end: offset + size - 1,
2535
+ ...signal === undefined ? {} : { signal }
2536
+ });
2537
+ const verifySource = () => this.#verifySource(source);
2538
+ let validatingSource = false;
2539
+ const completionFailure = () => {
2540
+ const coverage = sourceStream.readCoverage();
2541
+ if (coverage.kind !== "complete") return new ArtifactReaderFailure("integrity", `Mach-O slice read coverage is incomplete: ${entry.path}`);
2542
+ if (coverage.bytes !== BigInt(size)) return new ArtifactReaderFailure("integrity", `Mach-O slice size disagrees with lipo metadata: ${entry.path}`);
2543
+ if (signal?.aborted) return new ArtifactReaderFailure("cancelled", "Mach-O slice read cancelled", { cause: signal.reason });
2544
+ return undefined;
2545
+ };
2546
+ const output = Readable.from((async function* () {
2547
+ try {
2548
+ for await (const raw of sourceStream) {
2549
+ const chunk = streamChunkToBuffer(raw);
2550
+ if (sourceStream.readCoverage().kind === "complete" && signal?.aborted) {
2551
+ const failure = completionFailure();
2552
+ if (failure !== undefined) throw failure;
2553
+ }
2554
+ yield chunk;
2555
+ }
2556
+ } catch (cause) {
2557
+ if (cause instanceof ArtifactReaderFailure) throw cause;
2558
+ throw new ArtifactReaderFailure("integrity", `Could not read Mach-O slice range: ${entry.path}`, { cause });
2559
+ }
2560
+ validatingSource = true;
2561
+ const failure = completionFailure();
2562
+ if (failure !== undefined) throw failure;
2563
+ try {
2564
+ await verifySource();
2565
+ assertArtifactReadActive(signal);
2566
+ } finally {
2567
+ validatingSource = false;
2568
+ }
2569
+ })());
2570
+ const onSourceError = (cause) => {
2571
+ const completedCancellation = cause instanceof ArtifactReaderFailure && cause.reason === "cancelled" && sourceStream.readCoverage().kind === "complete" && !validatingSource ? completionFailure() : undefined;
2572
+ output.destroy(completedCancellation ?? (cause instanceof ArtifactReaderFailure ? cause : new ArtifactReaderFailure("integrity", `Could not read Mach-O slice range: ${entry.path}`, { cause })));
2573
+ };
2574
+ sourceStream.on("error", onSourceError);
2575
+ sourceStream.once("close", () => sourceStream.removeListener("error", onSourceError));
2576
+ const onAbort = () => {
2577
+ if (sourceStream.readCoverage().kind === "complete" && (sourceStream.errored === null || sourceStream.errored instanceof ArtifactReaderFailure && sourceStream.errored.reason === "cancelled") && !validatingSource && !output.destroyed) {
2578
+ const failure = completionFailure();
2579
+ if (failure !== undefined) output.destroy(failure);
2580
+ }
2581
+ };
2582
+ signal?.addEventListener("abort", onAbort, { once: true });
2583
+ output.once("close", () => {
2584
+ signal?.removeEventListener("abort", onAbort);
2585
+ if (!sourceStream.destroyed) sourceStream.destroy();
2586
+ });
2587
+ if (signal?.aborted) onAbort();
2588
+ return output;
2589
+ }
2590
+ provenance() {
2591
+ return this.#command === undefined ? [] : [structuredClone(this.#command)];
2592
+ }
2593
+ async close() {
2594
+ this.#closed = true;
2595
+ this.#closePromise ??= this.#releaseResources().catch((cause) => {
2596
+ this.#closePromise = undefined;
2597
+ throw cause;
2598
+ });
2599
+ return this.#closePromise;
2600
+ }
2601
+ async #releaseResources() {
2602
+ await Promise.allSettled(this.#pendingCommands);
2603
+ let cleanup;
2604
+ try {
2605
+ const failures = await this.runner.retryCleanup?.() ?? [];
2606
+ if (failures.length > 0) cleanup = {
2607
+ reason: failures.map(({ reason, resources }) => `${resources.join(", ")}: ${reason}`).join("; "),
2608
+ resources: [...new Set(failures.flatMap(({ resources }) => resources))]
2609
+ };
2610
+ } catch (cause) {
2611
+ cleanup = ArtifactReaderFailure.cleanupObservation(cause, "native-command-process-cleanup");
2612
+ }
2613
+ try {
2614
+ await this.#closeSource();
2615
+ } catch (cause) {
2616
+ if (cleanup === undefined) throw cause;
2617
+ throw ArtifactReaderFailure.withCleanup(cause, cleanup);
2618
+ }
2619
+ if (cleanup !== undefined) throw new ArtifactReaderFailure("unavailable", "Native command process cleanup remains incomplete", { cleanup });
2620
+ }
2621
+ async #ensureSource() {
2622
+ if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader is closed");
2623
+ if (this.#source !== undefined) return this.#source;
2624
+ this.#pendingSource ??= this.#acquireSource();
2625
+ const source = await this.#pendingSource;
2626
+ if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader closed during source acquisition");
2627
+ return source;
2628
+ }
2629
+ async #acquireSource() {
2630
+ let handle;
2631
+ try {
2632
+ handle = await openRegularFile(this.path, { symlinks: "reject" });
2633
+ } catch (cause) {
2634
+ if (!(cause instanceof RegularFileAdmissionFailure)) throw cause;
2635
+ this.#ownedSource = cause.owner;
2636
+ const primary = cause.cause instanceof NonRegularFileReadError ? new ArtifactReaderFailure("format", `Universal Mach-O source is not a regular file: ${this.path}`, { cause: cause.cause }) : cause.cause;
2637
+ throw ArtifactReaderFailure.withCleanup(primary, ArtifactReaderFailure.cleanupObservation(cause.cleanupCause, this.path));
2638
+ }
2639
+ const owner = new OwnedFileHandle(handle);
2640
+ this.#ownedSource = owner;
2641
+ try {
2642
+ const initial = await handle.stat();
2643
+ const source = {
2644
+ handle,
2645
+ initial
2646
+ };
2647
+ this.#source = source;
2648
+ return source;
2649
+ } catch (cause) {
2650
+ try {
2651
+ await owner.close();
2652
+ this.#ownedSource = undefined;
2653
+ } catch (cleanupCause) {
2654
+ throw ArtifactReaderFailure.withCleanup(cause, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.path));
2655
+ }
2656
+ throw cause;
2657
+ }
2658
+ }
2659
+ async #closeSource() {
2660
+ await this.#pendingSource?.catch(() => undefined);
2661
+ if (!this.#ownsSource || this.#ownedSource === undefined) return;
2662
+ await this.#ownedSource.close();
2663
+ this.#ownedSource = undefined;
2664
+ this.#source = undefined;
2665
+ }
2666
+ async #verifySource(source) {
2667
+ const [opened, currentPath] = await Promise.all([source.handle.stat(), lstat(this.path)]);
2668
+ if (!sameRegularFileState(source.initial, opened) || !sameRegularFileState(source.initial, currentPath)) throw new ArtifactReaderFailure("integrity", `Universal Mach-O source changed during inventory: ${this.path}`);
2669
+ }
2670
+ };
2671
+ readStructuralSlices = async (file, size) => {
2672
+ const readAt = async (offset, length) => {
2673
+ const bytes = Buffer.alloc(length);
2674
+ const { bytesRead } = await file.read(bytes, 0, length, offset);
2675
+ return bytes.subarray(0, bytesRead);
2676
+ };
2677
+ return readMachoImage(readAt, size);
2678
+ };
2679
+ lipoMatchesSlice = (reported, observed, structurallyUnique) => {
2680
+ const observedCpuType = observed.fat_cpu_type ?? observed.cpu_type;
2681
+ const observedCpuSubtype = observed.fat_cpu_subtype ?? observed.cpu_subtype;
2682
+ const hasPhysicalIdentity = reported.file_offset !== null || reported.size !== null || reported.cpu_type_code !== null || reported.cpu_subtype_code !== null;
2683
+ return (hasPhysicalIdentity || structurallyUnique) && lipoNameMatches(reported.name, observed.architecture) && (reported.file_offset === null || reported.file_offset === observed.slice_offset) && (reported.size === null || reported.size === observed.slice_size) && (reported.cpu_type_code === null || reported.cpu_type_code === observedCpuType) && lipoSubtypeMatches(reported, observedCpuSubtype) && (reported.alignment === null || observed.fat_alignment_exponent === null || reported.alignment === 2 ** observed.fat_alignment_exponent);
2684
+ };
2685
+ lipoSubtypeMatches = (reported, observedCpuSubtype) => {
2686
+ if (reported.cpu_subtype_code !== null) return reported.cpu_subtype_code === observedCpuSubtype;
2687
+ return reported.cpu_subtype_base === null || reported.cpu_subtype_base === machoCpuSubtypeBase(observedCpuSubtype);
2688
+ };
2689
+ lipoNameMatches = (reported, observed) => reported === observed || observed === "arm64e" && /^arm64e\.[A-Za-z0-9_]+$/u.test(reported);
2690
+ })))();
2691
+ }
2692
+
2693
+ //#endregion
2694
+ //#region dist/artifacts/NativeDmgOwnership.js
2695
+ var systemEntitySchema, attachOutputSchema, infoOutputSchema, parseNativeDmgInfo, parseNativeDmgAttachOutput, resolveNativeDmgOwnership, ownershipFromAttachOutput, topLevelDevices, isBelowRoot;
2696
+ function init_NativeDmgOwnership() {
2697
+ return (init_NativeDmgOwnership = __esmMin((() => {
2698
+ systemEntitySchema = z.object({
2699
+ "dev-entry": z.string().startsWith("/dev/"),
2700
+ "mount-point": z.string().optional()
2701
+ });
2702
+ attachOutputSchema = z.object({ "system-entities": z.array(systemEntitySchema) });
2703
+ infoOutputSchema = z.object({ images: z.array(z.object({ "system-entities": z.array(systemEntitySchema) })) });
2704
+ parseNativeDmgInfo = (stdout) => infoOutputSchema.parse(parse(stdout));
2705
+ parseNativeDmgAttachOutput = (stdout) => attachOutputSchema.parse(parse(stdout));
2706
+ resolveNativeDmgOwnership = (input) => {
2707
+ const rootedImages = input.info.images.filter((image) => image["system-entities"].some(({ "mount-point": mountPoint }) => mountPoint !== undefined && isBelowRoot(input.mountRoot, mountPoint)));
2708
+ if (rootedImages.length > 1) return {
2709
+ status: "unknown",
2710
+ reason: "multiple hdiutil image groups report mounts beneath the owned root"
2711
+ };
2712
+ const rootedImage = rootedImages[0];
2713
+ if (rootedImage !== undefined) {
2714
+ const hasOutsideMount = rootedImage["system-entities"].some(({ "mount-point": mountPoint }) => mountPoint !== undefined && !isBelowRoot(input.mountRoot, mountPoint));
2715
+ const groupDevices = rootedImage["system-entities"].map(({ "dev-entry": device }) => device);
2716
+ const devices = topLevelDevices(groupDevices);
2717
+ const overlapsBaseline = groupDevices.some((device) => input.baselineDevices.has(device));
2718
+ if (hasOutsideMount || overlapsBaseline || devices.length === 0) return {
2719
+ status: "unknown",
2720
+ reason: hasOutsideMount ? "the image group contains a mount outside the owned root" : overlapsBaseline ? "the image group includes a device present before attachment" : "the owned mount group contains no detachable device"
2721
+ };
2722
+ return {
2723
+ status: "owned",
2724
+ devices,
2725
+ source: "info"
2726
+ };
2727
+ }
2728
+ if (input.attachOutputReturned) {
2729
+ const attachOwnership = ownershipFromAttachOutput(input.attachOutput, input.mountRoot, input.baselineDevices);
2730
+ if (attachOwnership.status === "owned") {
2731
+ return attachOwnership;
2732
+ }
2733
+ if (attachOwnership.status === "unknown") return attachOwnership;
2734
+ }
2735
+ const newlyListedDevice = input.info.images.some((image) => image["system-entities"].some(({ "dev-entry": device }) => !input.baselineDevices.has(device)));
2736
+ if (newlyListedDevice) return {
2737
+ status: "unknown",
2738
+ reason: "hdiutil lists devices absent from the pre-attach baseline, but none is tied uniquely to the owned root; ownership is unknown"
2739
+ };
2740
+ return { status: "none" };
2741
+ };
2742
+ ownershipFromAttachOutput = (output, mountRoot, baselineDevices) => {
2743
+ if (output === undefined) return {
2744
+ status: "unknown",
2745
+ reason: "hdiutil attach succeeded but its ownership facts were malformed"
2746
+ };
2747
+ const entities = output["system-entities"];
2748
+ const hasRootMount = entities.some(({ "mount-point": mountPoint }) => mountPoint !== undefined && isBelowRoot(mountRoot, mountPoint));
2749
+ const hasOutsideMount = entities.some(({ "mount-point": mountPoint }) => mountPoint !== undefined && !isBelowRoot(mountRoot, mountPoint));
2750
+ const devices = entities.map(({ "dev-entry": device }) => device);
2751
+ const uniqueDevices = topLevelDevices(devices);
2752
+ const overlapsBaseline = devices.some((device) => baselineDevices.has(device));
2753
+ if (hasRootMount) {
2754
+ if (hasOutsideMount || overlapsBaseline || uniqueDevices.length === 0) return {
2755
+ status: "unknown",
2756
+ reason: hasOutsideMount ? "the attach result includes a mount outside the owned root" : overlapsBaseline ? "the attach result includes a device present before attachment" : "the attach result's owned mount has no detachable device"
2757
+ };
2758
+ return {
2759
+ status: "owned",
2760
+ devices: uniqueDevices,
2761
+ source: "attach"
2762
+ };
2763
+ }
2764
+ if (devices.length === 0) return {
2765
+ status: "unknown",
2766
+ reason: "hdiutil attach succeeded without reporting device ownership facts"
2767
+ };
2768
+ if (devices.some((device) => !baselineDevices.has(device))) return {
2769
+ status: "unknown",
2770
+ reason: "the attach result reports new devices without a mount beneath the owned root"
2771
+ };
2772
+ return { status: "none" };
2773
+ };
2774
+ topLevelDevices = (devices) => {
2775
+ const unique = [...new Set(devices)];
2776
+ return unique.filter((device) => !unique.some((parent) => /^\/dev\/disk\d+$/u.test(parent) && device.startsWith(`${parent}s`) && /^\d+$/u.test(device.slice(parent.length + 1))));
2777
+ };
2778
+ isBelowRoot = (root, path) => {
2779
+ const child = relative(root, resolve(path));
2780
+ return child !== "" && child !== "." && child !== ".." && !child.startsWith(`..${sep}`);
2781
+ };
2782
+ })))();
2783
+ }
2784
+
2785
+ //#endregion
2786
+ //#region dist/artifacts/NativeDmgArtifactReader.js
2787
+ var HDIUTIL_COMMAND_TIMEOUT_MS, VERIFY_SETTLE_DELAYS_MS, DETACH_SETTLE_DELAYS_MS, delay, NativeDmgCommandFailure, createSystemHost, NativeDmgArtifactReader, failureMessage, processNotStarted, runChecked, describeCommandFailure, processExitCode, processOutput, classifyCommandFailure, classifyVerifyFailure, verifyFailureReason, verifyFailureDiagnostic, INVALID_CHECKSUM_LINE, UNRECOGNIZED_IMAGE_LINE, untranslatedVerifyFailure, outputLines, command;
2788
+ function init_NativeDmgArtifactReader() {
2789
+ return (init_NativeDmgArtifactReader = __esmMin((() => {
2790
+ init_OwnedRegularFile();
2791
+ init_ArtifactReader();
2792
+ init_DirectoryArtifactReader();
2793
+ init_RegularFile();
2794
+ init_OwnedFileHandle();
2795
+ init_ExecFileOutput();
2796
+ init_NativeDmgOwnership();
2797
+ HDIUTIL_COMMAND_TIMEOUT_MS = 12e4;
2798
+ VERIFY_SETTLE_DELAYS_MS = [250, 500];
2799
+ DETACH_SETTLE_DELAYS_MS = [
2800
+ 250,
2801
+ 500,
2802
+ 1e3
2803
+ ];
2804
+ delay = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
2805
+ NativeDmgCommandFailure = class extends ArtifactReaderFailure {
2806
+ stdout;
2807
+ processNotStarted;
2808
+ verifyDiagnostic;
2809
+ unrecognizedImage;
2810
+ exitCode;
2811
+ constructor(failure, message, stdout, options) {
2812
+ super(failure.reason, message, options?.cause === undefined ? undefined : { cause: options.cause });
2813
+ this.stdout = stdout;
2814
+ this.processNotStarted = options?.processNotStarted ?? false;
2815
+ this.verifyDiagnostic = failure.verifyDiagnostic;
2816
+ this.unrecognizedImage = failure.unrecognizedImage ?? false;
2817
+ this.exitCode = options?.exitCode ?? null;
2818
+ }
2819
+ };
2820
+ createSystemHost = (environment) => ({
2821
+ delay,
2822
+ async run(arguments_, signal, options) {
2823
+ try {
2824
+ const { stdout, stderr } = await execFileOutput("/usr/bin/hdiutil", [...arguments_], {
2825
+ env: environment,
2826
+ stopSignal: "SIGTERM",
2827
+ ...options === undefined ? {} : { timeout: options.timeoutMs },
2828
+ ...signal === undefined ? {} : { signal }
2829
+ });
2830
+ return {
2831
+ stdout,
2832
+ stderr,
2833
+ exitCode: 0
2834
+ };
2835
+ } catch (cause) {
2836
+ const output = execFileOutputFailure(cause);
2837
+ if (cause instanceof Error && cause.name === "AbortError") throw new NativeDmgCommandFailure({ reason: "cancelled" }, "DMG operation cancelled", output?.stdout ?? "", { cause });
2838
+ const exitCode = typeof output?.code === "number" ? output.code : processExitCode(cause);
2839
+ if (exitCode !== undefined) return {
2840
+ stdout: output?.stdout ?? processOutput(cause, "stdout"),
2841
+ stderr: output?.stderr ?? processOutput(cause, "stderr"),
2842
+ exitCode,
2843
+ cause
2844
+ };
2845
+ throw new NativeDmgCommandFailure(classifyCommandFailure(cause, arguments_[0]), `hdiutil ${arguments_[0] ?? "operation"} failed: ${describeCommandFailure(cause, arguments_)}`, output?.stdout ?? "", {
2846
+ cause,
2847
+ processNotStarted: processNotStarted(cause)
2848
+ });
2849
+ }
2850
+ }
2851
+ });
2852
+ NativeDmgArtifactReader = class {
2853
+ path;
2854
+ format = "file";
2855
+ host;
2856
+ #provenance = [];
2857
+ #initialization;
2858
+ #directory;
2859
+ #devices = [];
2860
+ #inventoryConfirmedDevices = new Set();
2861
+ #mountRoot;
2862
+ #baselineDevices = new Set();
2863
+ #attachOutput;
2864
+ #attachOutputReturned = false;
2865
+ #attachMayHaveMounted = false;
2866
+ #ownershipUncertainty;
2867
+ #closed = false;
2868
+ #closePromise;
2869
+ #activeDirectoryOperations = new Set();
2870
+ #verificationProbeHandle;
2871
+ constructor(path, environment, host) {
2872
+ this.path = path;
2873
+ if (process.platform !== "darwin" && host === undefined) throw new ArtifactReaderFailure("unavailable", "Native DMG traversal is available only on macOS");
2874
+ this.host = host ?? createSystemHost(environment);
2875
+ }
2876
+ async *entries(signal, options) {
2877
+ await this.#ensureAttached(signal);
2878
+ const directory = this.#directory;
2879
+ if (directory === undefined) throw new ArtifactReaderFailure("unavailable", "DMG is not attached");
2880
+ const prefix = basename(this.path);
2881
+ const entries = directory.entries(signal, { onOmission: (omission) => options?.onOmission?.({
2882
+ ...omission,
2883
+ path: `${prefix}/${omission.path}`
2884
+ }) })[Symbol.asyncIterator]();
2885
+ try {
2886
+ for (;;) {
2887
+ if (this.#closed) return;
2888
+ const next = await this.#trackDirectoryOperation(() => entries.next());
2889
+ if (this.#closed) return;
2890
+ if (next.done) return;
2891
+ yield {
2892
+ ...next.value,
2893
+ path: `${prefix}/${next.value.path}`
2894
+ };
2895
+ }
2896
+ } finally {
2897
+ await entries.return?.();
2898
+ }
2899
+ }
2900
+ async open(entry, signal) {
2901
+ await this.#ensureAttached(signal);
2902
+ const directory = this.#directory;
2903
+ if (directory === undefined) throw new ArtifactReaderFailure("unavailable", "DMG is not attached");
2904
+ return this.#trackDirectoryOperation(() => directory.open(entry, signal));
2905
+ }
2906
+ provenance() {
2907
+ return structuredClone(this.#provenance);
2908
+ }
2909
+ close() {
2910
+ this.#closed = true;
2911
+ this.#closePromise ??= this.#closeOwnedResources().catch((cause) => {
2912
+ this.#closePromise = undefined;
2913
+ throw cause;
2914
+ });
2915
+ return this.#closePromise;
2916
+ }
2917
+ async #closeOwnedResources() {
2918
+ await this.#initialization?.catch(() => undefined);
2919
+ await Promise.allSettled(this.#activeDirectoryOperations);
2920
+ await this.#closeVerificationProbeHandle();
2921
+ await this.#closeMountedDirectory();
2922
+ let detachFailure = await this.#detachOwnedDevices();
2923
+ if (this.#devices.length === 0 && this.#mountRoot !== undefined && !this.#attachMayHaveMounted) await rm(this.#mountRoot, {
2924
+ recursive: true,
2925
+ force: true
2926
+ }).then(() => {
2927
+ this.#mountRoot = undefined;
2928
+ this.#directory = undefined;
2929
+ }, (cause) => {
2930
+ detachFailure ??= cause;
2931
+ });
2932
+ if (this.#attachMayHaveMounted) {
2933
+ detachFailure ??= new Error(this.#ownershipUncertainty ?? "hdiutil attachment ownership remains unknown");
2934
+ }
2935
+ if (detachFailure !== undefined) throw new ArtifactReaderFailure("unavailable", `DMG detach or mount-root cleanup failed for ${JSON.stringify(this.path)}: ${failureMessage(detachFailure)}`, {
2936
+ cause: detachFailure,
2937
+ cleanup: {
2938
+ reason: failureMessage(detachFailure),
2939
+ resources: [
2940
+ ...this.#devices.map((device) => `DMG device ${device}`),
2941
+ ...this.#attachMayHaveMounted ? [`DMG attachment ownership unknown at mount root ${this.#mountRoot ?? this.path}`] : [],
2942
+ ...this.#mountRoot === undefined ? [] : [`DMG mount root ${this.#mountRoot}`]
2943
+ ]
2944
+ }
2945
+ });
2946
+ }
2947
+ async #closeVerificationProbeHandle() {
2948
+ const owner = this.#verificationProbeHandle;
2949
+ if (owner === undefined) return;
2950
+ try {
2951
+ await owner.close();
2952
+ this.#verificationProbeHandle = undefined;
2953
+ } catch (cause) {
2954
+ throw ArtifactReaderFailure.withCleanup(cause, ArtifactReaderFailure.cleanupObservation(cause, `DMG verification target descriptor ${this.path}`));
2955
+ }
2956
+ }
2957
+ async #detachOwnedDevices() {
2958
+ let detachFailure = await this.#reconcileAttachState();
2959
+ let remainingDevices = [];
2960
+ for (const device of [...this.#devices].reverse()) {
2961
+ const failure = await this.#detach(device);
2962
+ if (failure !== undefined) {
2963
+ remainingDevices.push(device);
2964
+ detachFailure ??= failure;
2965
+ }
2966
+ }
2967
+ for (const delayMs of DETACH_SETTLE_DELAYS_MS) {
2968
+ if (remainingDevices.length === 0) break;
2969
+ await (this.host.delay ?? delay)(delayMs);
2970
+ const stillAttached = [];
2971
+ for (const device of remainingDevices) {
2972
+ if (!await this.#isAttached(device)) continue;
2973
+ const failure = await this.#detach(device);
2974
+ if (failure !== undefined) {
2975
+ stillAttached.push(device);
2976
+ detachFailure = failure;
2977
+ }
2978
+ }
2979
+ remainingDevices = stillAttached;
2980
+ }
2981
+ if (remainingDevices.length === 0) detachFailure = undefined;
2982
+ this.#devices = remainingDevices.reverse();
2983
+ return detachFailure;
2984
+ }
2985
+ async #closeMountedDirectory() {
2986
+ if (this.#directory !== undefined) {
2987
+ try {
2988
+ await this.#directory.close();
2989
+ this.#directory = undefined;
2990
+ } catch (cause) {
2991
+ const mountRoot = this.#mountRoot ?? this.path;
2992
+ throw ArtifactReaderFailure.withCleanup(cause, {
2993
+ reason: `DMG mounted directory remains owned: ${failureMessage(cause)}`,
2994
+ resources: [
2995
+ `DMG mounted directory at ${mountRoot}`,
2996
+ `DMG mount root ${mountRoot}`,
2997
+ ...this.#devices.map((device) => `DMG device ${device}`)
2998
+ ]
2999
+ });
3000
+ }
3001
+ }
3002
+ }
3003
+ /** Detach one device; return the failure only while it remains attached. */
3004
+ async #detach(device) {
3005
+ try {
3006
+ await runChecked(this.host, ["detach", device], undefined, { timeoutMs: HDIUTIL_COMMAND_TIMEOUT_MS });
3007
+ this.#provenance.push(command(["detach", device], ["mount"]));
3008
+ return undefined;
3009
+ } catch (cause) {
3010
+ return await this.#isAttached(device) ? cause : undefined;
3011
+ }
3012
+ }
3013
+ async #reconcileAttachState() {
3014
+ if (!this.#attachMayHaveMounted) return undefined;
3015
+ try {
3016
+ await this.#resolveAttachOwnership();
3017
+ return undefined;
3018
+ } catch (cause) {
3019
+ this.#ownershipUncertainty = failureMessage(cause);
3020
+ return cause;
3021
+ }
3022
+ }
3023
+ /** Treat unknown hdiutil state as attached during cleanup. */
3024
+ async #isAttached(device) {
3025
+ try {
3026
+ const parsed = await this.#readInfo();
3027
+ const isListed = parsed.images.some((image) => image["system-entities"].some((entity) => entity["dev-entry"] === device));
3028
+ if (isListed) {
3029
+ this.#inventoryConfirmedDevices.add(device);
3030
+ return true;
3031
+ }
3032
+ return !this.#inventoryConfirmedDevices.has(device);
3033
+ } catch {
3034
+ return true;
3035
+ }
3036
+ }
3037
+ async #ensureAttached(signal) {
3038
+ if (this.#closed) throw new ArtifactReaderFailure("unavailable", "DMG reader is closed");
3039
+ this.#initialization ??= this.#attach(signal);
3040
+ await this.#initialization;
3041
+ if (this.#closed) throw new ArtifactReaderFailure("unavailable", "DMG reader is closed");
3042
+ }
3043
+ async #trackDirectoryOperation(operation) {
3044
+ if (this.#closed) throw new ArtifactReaderFailure("unavailable", "DMG reader is closed");
3045
+ const running = Promise.resolve().then(operation);
3046
+ this.#activeDirectoryOperations.add(running);
3047
+ try {
3048
+ return await running;
3049
+ } finally {
3050
+ this.#activeDirectoryOperations.delete(running);
3051
+ }
3052
+ }
3053
+ async #attach(signal) {
3054
+ await this.#verify(signal);
3055
+ const baseline = await this.#readInfo();
3056
+ this.#baselineDevices = new Set(baseline.images.flatMap((image) => image["system-entities"].map(({ "dev-entry": device }) => device)));
3057
+ const mountRoot = await realpath(await mkdtemp(join(tmpdir(), "rea-dmg-")));
3058
+ this.#mountRoot = mountRoot;
3059
+ try {
3060
+ this.#attachMayHaveMounted = true;
3061
+ const attached = await runChecked(this.host, [
3062
+ "attach",
3063
+ "-readonly",
3064
+ "-nobrowse",
3065
+ "-plist",
3066
+ "-mountroot",
3067
+ mountRoot,
3068
+ this.path
3069
+ ], signal, { timeoutMs: HDIUTIL_COMMAND_TIMEOUT_MS });
3070
+ this.#attachOutputReturned = true;
3071
+ let parsed;
3072
+ try {
3073
+ parsed = parseNativeDmgAttachOutput(attached.stdout);
3074
+ } catch (cause) {
3075
+ throw new ArtifactReaderFailure("format", "hdiutil returned a malformed attachment plist", { cause });
3076
+ }
3077
+ if (parsed["system-entities"].length === 0) throw new ArtifactReaderFailure("format", "hdiutil returned no attached devices");
3078
+ this.#attachOutput = parsed;
3079
+ const ownership = await this.#resolveAttachOwnership();
3080
+ if (ownership !== "owned") throw new ArtifactReaderFailure(ownership === "unknown" ? "unavailable" : "path", ownership === "unknown" ? `DMG attachment ownership is uncertain: ${this.#ownershipUncertainty ?? "no unique mount under the owned root"}` : "hdiutil did not mount a new image beneath the owned root");
3081
+ this.#provenance.push(command([
3082
+ "attach",
3083
+ "-readonly",
3084
+ "-nobrowse",
3085
+ "-plist",
3086
+ "-mountroot",
3087
+ mountRoot,
3088
+ this.path
3089
+ ], ["read", "mount"]));
3090
+ this.#directory = new DirectoryArtifactReader(mountRoot);
3091
+ } catch (cause) {
3092
+ if (cause instanceof NativeDmgCommandFailure && cause.stdout !== "") {
3093
+ try {
3094
+ this.#attachOutput = parseNativeDmgAttachOutput(cause.stdout);
3095
+ this.#attachOutputReturned = true;
3096
+ } catch {}
3097
+ }
3098
+ if (cause instanceof NativeDmgCommandFailure && cause.processNotStarted) {
3099
+ this.#attachMayHaveMounted = false;
3100
+ this.#ownershipUncertainty = undefined;
3101
+ }
3102
+ throw cause;
3103
+ }
3104
+ }
3105
+ async #verify(signal) {
3106
+ const arguments_ = ["verify", this.path];
3107
+ const deadline = performance.now() + HDIUTIL_COMMAND_TIMEOUT_MS;
3108
+ for (let attempt = 0;; attempt += 1) {
3109
+ this.#throwIfVerificationCancelled(signal);
3110
+ try {
3111
+ await runChecked(this.host, arguments_, signal, { timeoutMs: Math.max(1, Math.ceil(deadline - performance.now())) });
3112
+ this.#provenance.push(command(arguments_, ["read"]));
3113
+ return;
3114
+ } catch (cause) {
3115
+ if (!(cause instanceof NativeDmgCommandFailure)) throw cause;
3116
+ this.#provenance.push(command(arguments_, ["read"], cause.exitCode));
3117
+ if (cause.unrecognizedImage) {
3118
+ const unreadable = await this.#isUnreadableTarget(signal, cause);
3119
+ this.#throwIfVerificationCancelled(signal);
3120
+ if (unreadable) throw new NativeDmgCommandFailure({ reason: "io" }, cause.message, cause.stdout, {
3121
+ cause: cause.cause,
3122
+ ...cause.exitCode === null ? {} : { exitCode: cause.exitCode }
3123
+ });
3124
+ }
3125
+ const delayMs = VERIFY_SETTLE_DELAYS_MS[attempt];
3126
+ if (cause.verifyDiagnostic !== "Resource temporarily unavailable" && !cause.unrecognizedImage || delayMs === undefined || deadline - performance.now() <= delayMs) throw cause;
3127
+ await (this.host.delay ?? delay)(delayMs);
3128
+ if (performance.now() >= deadline) throw cause;
3129
+ }
3130
+ }
3131
+ }
3132
+ async #readInfo() {
3133
+ const info = await runChecked(this.host, ["info", "-plist"], undefined, { timeoutMs: HDIUTIL_COMMAND_TIMEOUT_MS });
3134
+ return parseNativeDmgInfo(info.stdout);
3135
+ }
3136
+ async #resolveAttachOwnership() {
3137
+ const mountRoot = this.#mountRoot;
3138
+ if (mountRoot === undefined) throw new Error("DMG mount root is unavailable for ownership discovery");
3139
+ const ownership = resolveNativeDmgOwnership({
3140
+ info: await this.#readInfo(),
3141
+ ...this.#attachOutput === undefined ? {} : { attachOutput: this.#attachOutput },
3142
+ attachOutputReturned: this.#attachOutputReturned,
3143
+ mountRoot,
3144
+ baselineDevices: this.#baselineDevices
3145
+ });
3146
+ if (ownership.status === "owned") {
3147
+ this.#devices = [...ownership.devices];
3148
+ if (ownership.source === "info") for (const device of ownership.devices) this.#inventoryConfirmedDevices.add(device);
3149
+ this.#attachMayHaveMounted = false;
3150
+ this.#ownershipUncertainty = undefined;
3151
+ return "owned";
3152
+ }
3153
+ if (ownership.status === "unknown") {
3154
+ this.#ownershipUncertainty = ownership.reason;
3155
+ return "unknown";
3156
+ }
3157
+ this.#attachMayHaveMounted = false;
3158
+ this.#ownershipUncertainty = undefined;
3159
+ this.#devices = [];
3160
+ return "none";
3161
+ }
3162
+ #cancelledVerification(cause) {
3163
+ return new NativeDmgCommandFailure({ reason: "cancelled" }, "DMG operation cancelled", "", { cause });
3164
+ }
3165
+ #throwIfVerificationCancelled(signal) {
3166
+ if (signal?.aborted === true) throw this.#cancelledVerification(signal.reason);
3167
+ }
3168
+ async #isUnreadableTarget(signal, primaryFailure) {
3169
+ let handle;
3170
+ try {
3171
+ handle = await openRegularFile(this.path, {
3172
+ symlinks: "follow",
3173
+ ...signal === undefined ? {} : { signal }
3174
+ });
3175
+ } catch (cause) {
3176
+ if (cause instanceof RegularFileAdmissionFailure) {
3177
+ this.#verificationProbeHandle = cause.owner;
3178
+ const cancellation = regularFileCancellation(cause.cause);
3179
+ const failure = cancellation === undefined ? primaryFailure : this.#cancelledVerification(cancellation.reason);
3180
+ throw ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cause.cleanupCause, `DMG verification target descriptor ${this.path}`));
3181
+ }
3182
+ const cancellation = regularFileCancellation(cause);
3183
+ if (cancellation !== undefined) throw this.#cancelledVerification(cancellation.reason);
3184
+ if (cause instanceof NonRegularFileReadError) return false;
3185
+ return classifyCommandFailure(cause, undefined).reason === "io";
3186
+ }
3187
+ const owner = new OwnedFileHandle(handle);
3188
+ this.#verificationProbeHandle = owner;
3189
+ try {
3190
+ await owner.close();
3191
+ this.#verificationProbeHandle = undefined;
3192
+ } catch (cause) {
3193
+ throw ArtifactReaderFailure.withCleanup(signal?.aborted === true ? this.#cancelledVerification(signal.reason) : primaryFailure, ArtifactReaderFailure.cleanupObservation(cause, `DMG verification target descriptor ${this.path}`));
3194
+ }
3195
+ if (signal?.aborted === true) throw this.#cancelledVerification(signal.reason);
3196
+ return false;
3197
+ }
3198
+ };
3199
+ failureMessage = (cause) => cause instanceof Error ? cause.message : String(cause);
3200
+ processNotStarted = (cause) => {
3201
+ if (!(cause instanceof Error)) return false;
3202
+ const syscall = Reflect.get(cause, "syscall");
3203
+ const code = Reflect.get(cause, "code");
3204
+ const errno = Reflect.get(cause, "errno");
3205
+ return typeof syscall === "string" && syscall.startsWith("spawn ") && (typeof code === "string" || typeof code === "number" || typeof errno === "number");
3206
+ };
3207
+ runChecked = async (host, arguments_, signal, options) => {
3208
+ let result;
3209
+ try {
3210
+ result = await host.run(arguments_, signal, options);
3211
+ } catch (cause) {
3212
+ if (cause instanceof ArtifactReaderFailure) throw cause;
3213
+ if (cause instanceof Error && cause.name === "AbortError") throw new NativeDmgCommandFailure({ reason: "cancelled" }, "DMG operation cancelled", execFileOutputFailure(cause)?.stdout ?? "", { cause });
3214
+ const output = execFileOutputFailure(cause);
3215
+ throw new NativeDmgCommandFailure(classifyCommandFailure(cause, arguments_[0]), `hdiutil ${arguments_[0] ?? "operation"} failed: ${describeCommandFailure(cause, arguments_)}`, output?.stdout ?? "", {
3216
+ cause,
3217
+ processNotStarted: processNotStarted(cause)
3218
+ });
3219
+ }
3220
+ if (result.exitCode !== 0) {
3221
+ const failure = {
3222
+ command: "/usr/bin/hdiutil",
3223
+ exitCode: result.exitCode,
3224
+ ...result.cause === undefined ? {} : { code: processExitCode(result.cause) },
3225
+ stdout: result.stdout,
3226
+ ...result.stderr === undefined ? {} : { stderr: result.stderr }
3227
+ };
3228
+ const classification = classifyCommandFailure(failure, arguments_[0]);
3229
+ const details = describeCommandFailure(failure, arguments_);
3230
+ const unknownVerifyFailure = arguments_[0] === "verify" && classification.reason === "unavailable";
3231
+ throw new NativeDmgCommandFailure(classification, unknownVerifyFailure ? `hdiutil verify failed; captured diagnostics do not establish the failure cause: ${details}` : `hdiutil ${arguments_[0] ?? "operation"} failed: ${details}`, result.stdout, {
3232
+ cause: result.cause ?? failure,
3233
+ exitCode: result.exitCode
3234
+ });
3235
+ }
3236
+ return {
3237
+ stdout: result.stdout,
3238
+ exitCode: 0
3239
+ };
3240
+ };
3241
+ describeCommandFailure = (cause, arguments_) => {
3242
+ const fields = {
3243
+ command: "/usr/bin/hdiutil",
3244
+ arguments: [...arguments_]
3245
+ };
3246
+ if (typeof cause === "object" && cause !== null) {
3247
+ for (const key of [
3248
+ "code",
3249
+ "exitCode",
3250
+ "errno",
3251
+ "syscall",
3252
+ "signal",
3253
+ "stdout",
3254
+ "stderr"
3255
+ ]) {
3256
+ const value = Reflect.get(cause, key);
3257
+ if (typeof value === "string" || typeof value === "number") fields[key] = value;
3258
+ }
3259
+ const code = Reflect.get(cause, "code");
3260
+ if (typeof code === "number") fields.exitCode = code;
3261
+ }
3262
+ if (cause instanceof ArtifactReaderFailure) fields.message = cause.message;
3263
+ else if (cause instanceof Error) fields.message = cause.message;
3264
+ return JSON.stringify(fields);
3265
+ };
3266
+ processExitCode = (cause) => {
3267
+ if (typeof cause !== "object" || cause === null) return undefined;
3268
+ const exitCode = Reflect.get(cause, "exitCode");
3269
+ if (typeof exitCode === "number") return exitCode;
3270
+ const code = Reflect.get(cause, "code");
3271
+ return typeof code === "number" ? code : undefined;
3272
+ };
3273
+ processOutput = (cause, field) => {
3274
+ if (typeof cause !== "object" || cause === null) return "";
3275
+ const value = Reflect.get(cause, field);
3276
+ return typeof value === "string" ? value : "";
3277
+ };
3278
+ classifyCommandFailure = (cause, operation) => {
3279
+ if (typeof cause !== "object" || cause === null) return { reason: "unavailable" };
3280
+ const code = Reflect.get(cause, "code");
3281
+ const exitCode = Reflect.get(cause, "exitCode");
3282
+ if (typeof code === "number" || typeof exitCode === "number") {
3283
+ if (operation !== "verify") return { reason: "unavailable" };
3284
+ return classifyVerifyFailure(processOutput(cause, "stdout"), processOutput(cause, "stderr"));
3285
+ }
3286
+ if (code === "ENOENT") {
3287
+ const syscall = Reflect.get(cause, "syscall");
3288
+ return { reason: typeof syscall === "string" && syscall.startsWith("spawn") ? "unavailable" : "io" };
3289
+ }
3290
+ if (code === "EACCES" || code === "EPERM" || code === "EIO" || code === "ENOTDIR" || code === "EISDIR" || code === "ENODEV" || code === "EROFS" || code === "EMFILE" || code === "ENFILE") return { reason: "io" };
3291
+ return { reason: "unavailable" };
3292
+ };
3293
+ classifyVerifyFailure = (stdout, stderr) => {
3294
+ const diagnostic = verifyFailureDiagnostic(stdout, stderr);
3295
+ const reason = verifyFailureReason(diagnostic);
3296
+ const untranslated = reason === undefined ? untranslatedVerifyFailure(stdout, stderr) : undefined;
3297
+ return {
3298
+ ...untranslated,
3299
+ reason: reason ?? untranslated?.reason ?? "unavailable",
3300
+ ...diagnostic === undefined ? {} : { verifyDiagnostic: diagnostic }
3301
+ };
3302
+ };
3303
+ verifyFailureReason = (diagnostic) => {
3304
+ switch (diagnostic) {
3305
+ case "image not recognized":
3306
+ case "image not recognised": return "format";
3307
+ case "invalid checksum":
3308
+ case "image data corrupted": return "integrity";
3309
+ case "No such file or directory":
3310
+ case "Permission denied":
3311
+ case "Input/output error": return "io";
3312
+ case "Resource temporarily unavailable": return "unavailable";
3313
+ default: return undefined;
3314
+ }
3315
+ };
3316
+ verifyFailureDiagnostic = (stdout, stderr) => {
3317
+ const prefix = "hdiutil: verify failed - ";
3318
+ return outputLines(stdout, stderr).find((line) => line.startsWith(prefix))?.slice(prefix.length);
3319
+ };
3320
+ INVALID_CHECKSUM_LINE = /^hdiutil: verify: checksum of ".*" is INVALID$/u;
3321
+ UNRECOGNIZED_IMAGE_LINE = /^hdiutil: verify: unable to recognize ".*" as a disk image\./u;
3322
+ untranslatedVerifyFailure = (stdout, stderr) => {
3323
+ const lines = outputLines(stdout, stderr);
3324
+ if (lines.some((line) => INVALID_CHECKSUM_LINE.test(line))) return { reason: "integrity" };
3325
+ if (lines.some((line) => UNRECOGNIZED_IMAGE_LINE.test(line))) return {
3326
+ reason: "unavailable",
3327
+ unrecognizedImage: true
3328
+ };
3329
+ return undefined;
3330
+ };
3331
+ outputLines = (stdout, stderr) => `${stdout}\n${stderr}`.split(/\r?\n/u).map((line) => line.trim());
3332
+ command = (arguments_, effects, exitCode = 0) => ({
3333
+ tool: "/usr/bin/hdiutil",
3334
+ arguments: [...arguments_],
3335
+ tool_version: null,
3336
+ executable_sha256: null,
3337
+ exit_code: exitCode,
3338
+ effects
3339
+ });
3340
+ })))();
3341
+ }
3342
+
3343
+ //#endregion
3344
+ //#region dist/artifacts/inventory/reader.js
3345
+ var createReader, inventoryCoverage;
3346
+ function init_reader() {
3347
+ return (init_reader = __esmMin((() => {
3348
+ init_AsarArtifactReader();
3349
+ init_DirectoryArtifactReader();
3350
+ init_MachOSliceArtifactReader();
3351
+ init_NativeDmgArtifactReader();
3352
+ init_ZipArtifactReader();
3353
+ init_zipPackageFormat();
3354
+ createReader = (path, format, environment, rootSource) => {
3355
+ if (isZipPackageFormat(format)) return new ZipArtifactReader(path, format, undefined, rootSource);
3356
+ switch (format) {
3357
+ case "directory": return new DirectoryArtifactReader(path);
3358
+ case "asar": return new AsarArtifactReader(path);
3359
+ case "mach-o-universal": return process.platform === "darwin" ? new MachOSliceArtifactReader(path, environment, undefined, rootSource) : undefined;
3360
+ case "dmg":
3361
+ if (process.platform !== "darwin") return undefined;
3362
+ return new NativeDmgArtifactReader(path, environment);
3363
+ default: return undefined;
3364
+ }
3365
+ };
3366
+ inventoryCoverage = (format, reader, traversal) => {
3367
+ if (reader !== undefined) return {
3368
+ coverage: {
3369
+ scope: "container-entries",
3370
+ status: traversal.status
3371
+ },
3372
+ limitations: [...isZipPackageFormat(reader.format) ? [ZIP_NON_ENTRY_LIMITATION] : [], ...traversal.limitations]
3373
+ };
3374
+ if (format === "dmg" || format === "pkg") return {
3375
+ coverage: {
3376
+ scope: "container-entries",
3377
+ status: "unknown"
3378
+ },
3379
+ limitations: [`${format.toUpperCase()} root hash is observed; child inventory requires a native macOS adapter.`]
3380
+ };
3381
+ if (format === "mach-o-universal") return {
3382
+ coverage: {
3383
+ scope: "container-entries",
3384
+ status: "unknown"
3385
+ },
3386
+ limitations: ["Universal Mach-O slices require the native macOS lipo adapter."]
3387
+ };
3388
+ if (isZipPackageFormat(format) || format === "directory" || format === "asar") return {
3389
+ coverage: {
3390
+ scope: "container-entries",
3391
+ status: "unknown"
3392
+ },
3393
+ limitations: [`${format} child inventory reader is unavailable.`]
3394
+ };
3395
+ return {
3396
+ coverage: {
3397
+ scope: "root",
3398
+ status: "complete"
3399
+ },
3400
+ limitations: ["Artifact has no child container entries."]
3401
+ };
3402
+ };
3403
+ })))();
3404
+ }
3405
+
3406
+ //#endregion
3407
+ //#region dist/artifacts/inventory/types.js
3408
+ var STRICT_INTEGRITY_POLICY;
3409
+ function init_types() {
3410
+ return (init_types = __esmMin((() => {
3411
+ STRICT_INTEGRITY_POLICY = { mode: "fail" };
3412
+ })))();
3413
+ }
3414
+
3415
+ //#endregion
3416
+ //#region dist/artifacts/inventory/scanReader.js
3417
+ var UNAVAILABLE_UNPACKED_LIMITATION, emptyScan, scanReader, inventoryEntries, visitArtifactEntries, digestArtifactEntry, isExpandableAsar, isUnavailableUnpackedEntry;
3418
+ function init_scanReader() {
3419
+ return (init_scanReader = __esmMin((() => {
3420
+ init_ArtifactPaths();
3421
+ init_ArtifactReader();
3422
+ init_AsarArtifactReader();
3423
+ init_unicodeCodePointOrder();
3424
+ init_ArtifactGraphConstruction();
3425
+ init_types();
3426
+ init_ArtifactHash();
3427
+ UNAVAILABLE_UNPACKED_LIMITATION = "ASAR unpacked companion bytes were unavailable; no content hash or child artifact was produced.";
3428
+ emptyScan = () => ({
3429
+ nodes: new Map(),
3430
+ occurrences: [],
3431
+ pendingContradictions: []
3432
+ });
3433
+ scanReader = async (reader, ownedReaders, signal, integrity = STRICT_INTEGRITY_POLICY) => {
3434
+ const { nodes, occurrences, pendingContradictions } = emptyScan();
3435
+ if (reader === undefined) return {
3436
+ nodes,
3437
+ occurrences,
3438
+ pendingContradictions,
3439
+ caseCollisionLimitation: undefined,
3440
+ unknownParentOccurrences: new Set(),
3441
+ traversal: {
3442
+ status: "complete",
3443
+ limitations: []
3444
+ }
3445
+ };
3446
+ const context = {
3447
+ reader,
3448
+ signal,
3449
+ integrity,
3450
+ nodes,
3451
+ occurrences,
3452
+ pendingContradictions,
3453
+ occurrenceCountByPath: new Map(),
3454
+ registry: new ArtifactPathRegistry(),
3455
+ expandedContainerIds: new Set(),
3456
+ ownedReaders,
3457
+ omissions: []
3458
+ };
3459
+ await visitArtifactEntries(context, reader, "");
3460
+ const byPath = indexOccurrencesByPath(occurrences);
3461
+ const parentResolution = resolveOccurrenceParents(occurrences, byPath, context.expandedContainerIds);
3462
+ const structuralLimitations = [...parentResolution.limitations];
3463
+ return {
3464
+ nodes,
3465
+ occurrences,
3466
+ pendingContradictions,
3467
+ caseCollisionLimitation: annotateEnglishUnicodeCaseCollisions(occurrences),
3468
+ unknownParentOccurrences: parentResolution.unknownParentOccurrences,
3469
+ traversal: {
3470
+ status: context.omissions.length === 0 && structuralLimitations.length === 0 ? "complete" : "unknown",
3471
+ limitations: [...new Set([...context.omissions.map(({ path, kind }) => `Artifact traversal omitted ${kind} at ${JSON.stringify(path)}.`), ...structuralLimitations])].sort(compareUnicodeCodePoints)
3472
+ }
3473
+ };
3474
+ };
3475
+ inventoryEntries = (context, reader, prefix) => reader.entries(context.signal, { onOmission: (omission) => context.omissions.push({
3476
+ ...omission,
3477
+ path: normalizeArtifactPath(prefix.length === 0 ? omission.path : `${prefix}/${omission.path}`)
3478
+ }) })[Symbol.asyncIterator]();
3479
+ visitArtifactEntries = async (context, currentReader, prefix) => {
3480
+ const stack = [{
3481
+ reader: currentReader,
3482
+ prefix,
3483
+ iterator: inventoryEntries(context, currentReader, prefix)
3484
+ }];
3485
+ let failure;
3486
+ try {
3487
+ while (stack.length > 0) {
3488
+ const frame = stack.at(-1);
3489
+ if (frame === undefined) break;
3490
+ const next = await frame.iterator.next();
3491
+ if (next.done) {
3492
+ stack.pop();
3493
+ continue;
3494
+ }
3495
+ const entry = next.value;
3496
+ const logicalPath = normalizeArtifactPath(frame.prefix.length === 0 ? entry.path : `${frame.prefix}/${entry.path}`);
3497
+ const expandableAsar = isExpandableAsar(entry, logicalPath);
3498
+ context.registry.add(logicalPath, expandableAsar ? "directory" : entry.kind);
3499
+ const duplicateOrdinal = context.occurrenceCountByPath.get(logicalPath) ?? 0;
3500
+ context.occurrenceCountByPath.set(logicalPath, duplicateOrdinal + 1);
3501
+ const occurrence = createOccurrence(entry, logicalPath, null, duplicateOrdinal);
3502
+ let digested;
3503
+ try {
3504
+ digested = await digestArtifactEntry(context, frame.reader, entry, logicalPath, occurrence);
3505
+ } catch (cause) {
3506
+ if (!isUnavailableUnpackedEntry(cause, entry)) throw cause;
3507
+ occurrence.hash_status = "unavailable";
3508
+ occurrence.limitations.push(UNAVAILABLE_UNPACKED_LIMITATION);
3509
+ }
3510
+ if (digested === undefined) noteUnreadContainerSuffix(occurrence);
3511
+ else {
3512
+ context.nodes.set(digested.node.artifact_id, digested.node);
3513
+ occurrence.artifact_id = digested.node.artifact_id;
3514
+ occurrence.artifact_kind = digested.classification.kind;
3515
+ occurrence.artifact_format = digested.classification.format;
3516
+ occurrence.hash_status = digested.mismatched ? "mismatched" : "verified";
3517
+ if (digested.mismatched) occurrence.limitations.push("Declared integrity metadata contradicts observed bytes.");
3518
+ }
3519
+ context.occurrences.push(occurrence);
3520
+ if (expandableAsar && digested !== undefined && digested.classification.format === "asar" && !digested.mismatched) {
3521
+ const nested = new AsarArtifactReader(entry.adapterKey);
3522
+ context.ownedReaders.push(nested);
3523
+ await nested.prepareContainer(digested.node.sha256, context.signal);
3524
+ context.expandedContainerIds.add(occurrence.occurrence_id);
3525
+ stack.push({
3526
+ reader: nested,
3527
+ prefix: logicalPath,
3528
+ iterator: inventoryEntries(context, nested, logicalPath)
3529
+ });
3530
+ }
3531
+ }
3532
+ } catch (cause) {
3533
+ failure = { cause };
3534
+ } finally {
3535
+ for (const { iterator, prefix, reader } of stack.reverse()) {
3536
+ try {
3537
+ await iterator.return?.();
3538
+ } catch (cause) {
3539
+ failure = { cause: ArtifactReaderFailure.withCleanup(failure === undefined ? cause : failure.cause, ArtifactReaderFailure.cleanupObservation(cause, `artifact traversal for ${prefix || reader.format}`)) };
3540
+ }
3541
+ }
3542
+ }
3543
+ if (failure !== undefined) throw failure.cause;
3544
+ };
3545
+ digestArtifactEntry = async (context, currentReader, entry, logicalPath, occurrence) => {
3546
+ if (entry.kind !== "file" && entry.kind !== "slice" || entry.encrypted) return undefined;
3547
+ const digest = await hashReadable(await currentReader.open(entry, context.signal), context.signal);
3548
+ const mismatched = entry.declaredSha256 !== null && entry.declaredSha256 !== digest.sha256;
3549
+ if (mismatched && entry.declaredSha256 !== null) {
3550
+ if (context.integrity.mode === "fail") throw new ArtifactReaderFailure("integrity", `Artifact integrity metadata disagrees with content: ${logicalPath}`, undefined, {
3551
+ logicalPath,
3552
+ declaredSha256: entry.declaredSha256,
3553
+ calculatedSha256: digest.sha256,
3554
+ unpacked: entry.unpacked
3555
+ });
3556
+ context.pendingContradictions.push({
3557
+ occurrence,
3558
+ declaredSha256: entry.declaredSha256,
3559
+ observedSha256: digest.sha256,
3560
+ entryKind: entry.kind,
3561
+ unpacked: entry.unpacked
3562
+ });
3563
+ }
3564
+ const classified = entry.kind === "slice" ? {
3565
+ kind: "universal-slice",
3566
+ format: "mach-o"
3567
+ } : classifyArtifactContent(logicalPath, digest.prefix, digest.bytes);
3568
+ return {
3569
+ node: createArtifactNode({
3570
+ sha256: digest.sha256,
3571
+ size: digest.bytes,
3572
+ format: classifyArtifactBytes(digest.prefix, digest.bytes),
3573
+ contentState: "embedded"
3574
+ }),
3575
+ mismatched,
3576
+ classification: classified
3577
+ };
3578
+ };
3579
+ isExpandableAsar = (entry, logicalPath) => entry.kind === "file" && logicalPath.toLowerCase().endsWith(".asar") && isAbsolute(entry.adapterKey);
3580
+ isUnavailableUnpackedEntry = (cause, entry) => entry.unpacked && cause instanceof ArtifactReaderFailure && cause.reason === "unavailable";
3581
+ })))();
3582
+ }
3583
+
3584
+ //#endregion
3585
+ //#region dist/artifacts/inventory/scanCanonical.js
3586
+ var scanCanonicalArtifactInventory, scanCanonicalArtifactInventoryInScope, cleanupInventoryOwners, buildInventorySnapshot, buildIntegrityContradictions, verifyRootDigest, sortNodes, sortOccurrences, sortEdges, buildManifest, buildLimitations;
3587
+ function init_scanCanonical() {
3588
+ return (init_scanCanonical = __esmMin((() => {
3589
+ init_unicodeCodePointOrder();
3590
+ init_AsarArtifactReader();
3591
+ init_ArtifactReader();
3592
+ init_artifactGraph();
3593
+ init_ArtifactGraphConstruction();
3594
+ init_artifactIdentity();
3595
+ init_classify();
3596
+ init_hostExecutableMarking();
3597
+ init_hashStableRootArtifact();
3598
+ init_reader();
3599
+ init_scanReader();
3600
+ init_types();
3601
+ scanCanonicalArtifactInventory = async (path, options, readerFactory = createReader) => options.resourceScope.run(() => scanCanonicalArtifactInventoryInScope(path, options, readerFactory));
3602
+ scanCanonicalArtifactInventoryInScope = async (path, options, readerFactory = createReader) => {
3603
+ const integrity = options.integrity ?? STRICT_INTEGRITY_POLICY;
3604
+ const metadata = await lstat(path);
3605
+ const { format: rootFormat, digest: rootDigest, rootSource } = await classifyAndHashRootForInventory(path, metadata.isDirectory(), metadata, options);
3606
+ let reader;
3607
+ let readerCreationFailure;
3608
+ try {
3609
+ reader = readerFactory(path, rootFormat, options.environment ?? {}, rootSource);
3610
+ } catch (cause) {
3611
+ readerCreationFailure = { cause };
3612
+ }
3613
+ const ownedReaders = reader === undefined ? [] : [reader];
3614
+ let outcome;
3615
+ try {
3616
+ if (readerCreationFailure !== undefined) throw readerCreationFailure.cause;
3617
+ if (reader instanceof AsarArtifactReader) await reader.prepareContainer(rootDigest?.sha256, options.signal);
3618
+ const { nodes, occurrences, pendingContradictions, caseCollisionLimitation, unknownParentOccurrences, traversal } = await scanReader(reader, ownedReaders, options.signal, integrity);
3619
+ outcome = {
3620
+ kind: "completed",
3621
+ snapshot: await buildInventorySnapshot({
3622
+ path,
3623
+ metadata,
3624
+ rootFormat,
3625
+ rootDigest,
3626
+ rootSource,
3627
+ resourceScope: options.resourceScope,
3628
+ reader,
3629
+ signal: options.signal,
3630
+ nodes,
3631
+ occurrences,
3632
+ pendingContradictions,
3633
+ caseCollisionLimitation,
3634
+ unknownParentOccurrences,
3635
+ traversal
3636
+ })
3637
+ };
3638
+ } catch (cause) {
3639
+ outcome = {
3640
+ kind: "failed",
3641
+ cause
3642
+ };
3643
+ }
3644
+ const cleanupFailure = await cleanupInventoryOwners({
3645
+ path,
3646
+ options,
3647
+ rootSource,
3648
+ ownedReaders,
3649
+ outcome
3650
+ });
3651
+ if (cleanupFailure !== undefined) throw cleanupFailure;
3652
+ if (outcome.kind === "failed") throw outcome.cause;
3653
+ return outcome.snapshot;
3654
+ };
3655
+ cleanupInventoryOwners = async ({ path, options, rootSource, ownedReaders, outcome }) => {
3656
+ let cleanupFailure;
3657
+ const owners = [...ownedReaders].reverse().map((reader) => ({
3658
+ kind: "reader",
3659
+ reader,
3660
+ resource: `artifact reader for ${path}`
3661
+ }));
3662
+ if (rootSource !== undefined) owners.push({
3663
+ kind: "file-handle",
3664
+ handle: rootSource.owner,
3665
+ resource: `root artifact descriptor for ${path}`
3666
+ });
3667
+ for (const owner of owners) {
3668
+ const attempt = await options.resourceScope.release(owner);
3669
+ if (attempt.kind === "released") continue;
3670
+ cleanupFailure = options.resourceScope.cleanupFailure(cleanupFailure === undefined ? outcome : {
3671
+ kind: "failed",
3672
+ cause: cleanupFailure
3673
+ }, [attempt], outcome.kind === "completed" ? {
3674
+ kind: "artifact-inventory",
3675
+ inventory: outcome.snapshot
3676
+ } : undefined);
3677
+ }
3678
+ return cleanupFailure;
3679
+ };
3680
+ buildInventorySnapshot = async (input) => {
3681
+ const { path, metadata, rootFormat, rootDigest, rootSource, reader, signal } = input;
3682
+ materializeDirectoryNodes(input.occurrences, input.nodes);
3683
+ const rootNode = createRootNode({
3684
+ digest: rootDigest,
3685
+ occurrences: input.occurrences
3686
+ });
3687
+ input.nodes.set(rootNode.artifact_id, rootNode);
3688
+ rekeyOccurrences(rootNode.artifact_id, input.occurrences);
3689
+ const rootOccurrence = rootOccurrenceFor(rootNode, {
3690
+ size: metadata.size,
3691
+ executable: hostExecutableMarking(path, metadata),
3692
+ format: rootFormat,
3693
+ path
3694
+ });
3695
+ for (const occurrence of input.occurrences) if (occurrence.parent_occurrence_id === null && !input.unknownParentOccurrences.has(occurrence)) occurrence.parent_occurrence_id = rootOccurrence.occurrence_id;
3696
+ input.occurrences.unshift(rootOccurrence);
3697
+ const occurrenceById = new Map(input.occurrences.map((occurrence) => [occurrence.occurrence_id, occurrence]));
3698
+ const integrityContradictions = buildIntegrityContradictions(input.pendingContradictions, occurrenceById, rootNode);
3699
+ const edgeResult = createArtifactEdges(rootNode.artifact_id, input.occurrences, reader?.provenance()[0]);
3700
+ const { edges } = edgeResult;
3701
+ const orderedNodes = sortNodes([...input.nodes.values()]);
3702
+ const orderedOccurrences = sortOccurrences(input.occurrences);
3703
+ const orderedEdges = sortEdges(edges).map((edge, ordinal) => ({
3704
+ ...edge,
3705
+ ordinal
3706
+ }));
3707
+ await verifyRootDigest(path, rootDigest, rootSource, input.resourceScope, signal);
3708
+ const graphSha256 = artifactGraphDigest({
3709
+ nodes: orderedNodes,
3710
+ occurrences: orderedOccurrences,
3711
+ edges: orderedEdges,
3712
+ contradictions: integrityContradictions
3713
+ });
3714
+ const manifest = buildManifest({
3715
+ rootNode,
3716
+ rootFormat,
3717
+ graphSha256,
3718
+ orderedNodes,
3719
+ orderedOccurrences,
3720
+ orderedEdges
3721
+ });
3722
+ const traversal = inventoryCoverage(rootFormat, reader, input.traversal);
3723
+ const coverage = edgeResult.limitations.length === 0 ? traversal.coverage : {
3724
+ ...traversal.coverage,
3725
+ status: "unknown"
3726
+ };
3727
+ return {
3728
+ manifest,
3729
+ nodes: orderedNodes,
3730
+ occurrences: orderedOccurrences,
3731
+ edges: orderedEdges,
3732
+ provenance: reader?.provenance() ?? [],
3733
+ integrity_contradictions: integrityContradictions,
3734
+ coverage,
3735
+ limitations: buildLimitations([...traversal.limitations, ...edgeResult.limitations], integrityContradictions, input.caseCollisionLimitation)
3736
+ };
3737
+ };
3738
+ buildIntegrityContradictions = (pending, occurrenceById, rootNode) => pending.map((contradiction) => {
3739
+ const occurrence = contradiction.occurrence;
3740
+ const parent = occurrence.parent_occurrence_id === null ? undefined : occurrenceById.get(occurrence.parent_occurrence_id);
3741
+ const parentArtifactId = parent?.artifact_id ?? rootNode.artifact_id;
3742
+ return {
3743
+ contradiction_id: artifactContradictionId({
3744
+ rootArtifactId: rootNode.artifact_id,
3745
+ logicalPath: occurrence.logical_path,
3746
+ declaredSha256: contradiction.declaredSha256,
3747
+ observedSha256: contradiction.observedSha256
3748
+ }),
3749
+ occurrence_id: occurrence.occurrence_id,
3750
+ parent_artifact_id: parentArtifactId,
3751
+ logical_path: occurrence.logical_path,
3752
+ declared_sha256: contradiction.declaredSha256,
3753
+ observed_sha256: contradiction.observedSha256,
3754
+ entry_kind: contradiction.entryKind,
3755
+ unpacked: contradiction.unpacked,
3756
+ trust: "observed-untrusted",
3757
+ provenance: "container-integrity-metadata-versus-observed-bytes",
3758
+ limitations: ["Observed bytes contradict declared integrity metadata and cannot support equivalence."]
3759
+ };
3760
+ });
3761
+ verifyRootDigest = async (path, rootDigest, rootSource, resourceScope, signal) => {
3762
+ if (rootDigest === null) return;
3763
+ const verified = rootSource === undefined ? await hashStableRootArtifact(path, resourceScope, signal) : await hashStableRootArtifactHandle(path, rootSource.handle, rootSource.initial, signal);
3764
+ if (verified.sha256 !== rootDigest.sha256 || verified.bytes !== rootDigest.bytes) throw new ArtifactReaderFailure("integrity", "Root artifact changed during inventory");
3765
+ };
3766
+ sortNodes = (nodes) => nodes.sort((left, right) => compareUnicodeCodePoints(left.artifact_id, right.artifact_id));
3767
+ sortOccurrences = (occurrences) => occurrences.sort((left, right) => compareUnicodeCodePoints(left.logical_path, right.logical_path));
3768
+ sortEdges = (edges) => edges.sort((left, right) => compareUnicodeCodePoints(left.edge_id, right.edge_id));
3769
+ buildManifest = ({ rootNode, rootFormat, graphSha256, orderedNodes, orderedOccurrences, orderedEdges }) => artifactInventoryResultSchema.shape.manifest.parse({
3770
+ manifest_id: artifactManifestId(rootNode.artifact_id, graphSha256),
3771
+ root_artifact_id: rootNode.artifact_id,
3772
+ root_sha256: rootNode.sha256,
3773
+ root_format: rootFormat,
3774
+ graph_sha256: graphSha256,
3775
+ node_count: orderedNodes.length,
3776
+ occurrence_count: orderedOccurrences.length,
3777
+ edge_count: orderedEdges.length
3778
+ });
3779
+ buildLimitations = (scopeLimitations, integrityContradictions, caseCollisionLimitation) => [
3780
+ ...scopeLimitations,
3781
+ ...caseCollisionLimitation === undefined ? [] : [caseCollisionLimitation],
3782
+ ...integrityContradictions.length === 0 ? [] : [`${String(integrityContradictions.length)} integrity contradiction(s) were recorded; mismatched content is observed-untrusted.`]
3783
+ ];
3784
+ })))();
3785
+ }
3786
+
3787
+ //#endregion
3788
+ export { init_ArtifactPaths as C, init_ZipArtifactReader as E, DESTINATION_CASE_COLLISION_PREFIX as S, ZipArtifactReader as T, SafeOutputTreeCreationFailure as _, init_javascriptArtifactFiles as a, streamChunkToBuffer as b, hashReadable as c, DirectoryArtifactTraversalLimit as d, init_DirectoryArtifactReader as f, init_SafeOutputTree as g, SafeOutputTree as h, init_MachOSliceArtifactReader as i, init_ArtifactHash as l, init_AsarArtifactReader as m, scanCanonicalArtifactInventoryInScope as n, isJavaScriptSourcePath as o, AsarArtifactReader as p, MachOSliceArtifactReader as r, abortIfNeeded as s, init_scanCanonical as t, DirectoryArtifactReader as u, init_SafeOutputTreeCreationFailure as v, normalizeArtifactPath as w, ArtifactPathRegistry as x, init_StreamBytes as y };