rea-agents 6.5.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 (921) hide show
  1. package/README.md +12 -3
  2. package/THIRD_PARTY_NOTICES.md +1 -0
  3. package/bridge/android/ReaJadxBridge.java +167 -23
  4. package/bridge/cutter/rea_bridge.py +19 -10
  5. package/bridge/ghidra/ReaGhidraBridge.java +98 -66
  6. package/bridge/hopper_bridge.py +9 -1
  7. package/bridge/native/rea_lldb_tracer.py +48 -4
  8. package/bridge/pwndbg/core_context.py +15 -2
  9. package/dist/adb/AdbCommand.js +148 -0
  10. package/dist/adb/AdbConfiguration.js +26 -4
  11. package/dist/adb/AdbInputSnapshot.js +126 -0
  12. package/dist/adb/AdbProvider.js +765 -248
  13. package/dist/adb/AdbShellOutput.js +92 -21
  14. package/dist/android/AndroidTargetSnapshot.js +7 -7
  15. package/dist/android/JadxAnalysis.js +27 -32
  16. package/dist/android/JadxConfiguration.js +173 -125
  17. package/dist/android/JadxDoctor.js +11 -3
  18. package/dist/android/JadxFailure.js +154 -0
  19. package/dist/android/JadxInterruption.js +13 -0
  20. package/dist/android/JadxJavaProbe.js +246 -0
  21. package/dist/android/JadxMcpTransport.js +48 -15
  22. package/dist/android/JadxProtocol.js +29 -2
  23. package/dist/android/JadxProvider.js +171 -96
  24. package/dist/android/JadxRelease.js +5 -1
  25. package/dist/android/JadxSession.js +35 -14
  26. package/dist/apktool/ApktoolCommandCleanup.js +134 -0
  27. package/dist/apktool/ApktoolCommandOutput.js +22 -0
  28. package/dist/apktool/ApktoolConfiguration.js +162 -44
  29. package/dist/apktool/ApktoolDecodeOutput.js +29 -23
  30. package/dist/apktool/ApktoolDecodedInventory.js +52 -0
  31. package/dist/apktool/ApktoolProvider.js +254 -335
  32. package/dist/apktool/ApktoolStringTables.js +178 -0
  33. package/dist/apktool/ApktoolWorkspace.js +162 -0
  34. package/dist/application/AnalysisDocument.js +19 -4
  35. package/dist/application/AnalysisProvider.js +15 -1
  36. package/dist/application/AppBundleExecutable.js +11 -4
  37. package/dist/application/BinaryTargetResolver.js +9 -2
  38. package/dist/application/BrowserObservationService.js +54 -20
  39. package/dist/application/BrowserScenarioCaptureService.js +26 -6
  40. package/dist/application/CapabilityInventory.js +14 -8
  41. package/dist/application/ClaudeDesktopConfigLocation.js +5 -5
  42. package/dist/application/ClientConfigurationCleanup.js +73 -0
  43. package/dist/application/ClientConfigurationDocument.js +170 -128
  44. package/dist/application/ClientConfigurationPublication.js +167 -0
  45. package/dist/application/ClientRegistrationEnvironment.js +31 -1
  46. package/dist/application/ClientRegistrationIdentity.js +54 -39
  47. package/dist/application/ClientRegistrationStatus.js +123 -48
  48. package/dist/application/DirectAnalysis.js +15 -2
  49. package/dist/application/DirectAnalysisCleanup.js +5 -1
  50. package/dist/application/DirectAnalysisStatus.js +1 -1
  51. package/dist/application/Doctor.js +83 -9
  52. package/dist/application/DoctorDiagnostics.js +25 -4
  53. package/dist/application/DoctorProviderIds.js +7 -1
  54. package/dist/application/DshCordisPatch.js +1 -1
  55. package/dist/application/EnhancedTools.js +9 -21
  56. package/dist/application/HermesClientHome.js +20 -0
  57. package/dist/application/HermesConfigurationYaml.js +43 -3
  58. package/dist/application/HopperDownload.js +11 -3
  59. package/dist/application/HopperReleaseFeed.js +71 -0
  60. package/dist/application/InvestigationProviders.js +4 -3
  61. package/dist/application/JsonFiles.js +1 -1
  62. package/dist/application/LinuxHopper.js +96 -71
  63. package/dist/application/LinuxHopperPublisher.js +656 -0
  64. package/dist/application/MacHopper.js +182 -66
  65. package/dist/application/MipsElfMetadata.js +1 -1
  66. package/dist/application/MsixPackageStorage.js +13 -6
  67. package/dist/application/ProviderOperationExecution.js +13 -20
  68. package/dist/application/ReconstructionObligationCandidates.js +17 -2
  69. package/dist/application/ReconstructionObligationLedgerEvaluation.js +4 -0
  70. package/dist/application/ReconstructionObligationLedgerService.js +5 -3
  71. package/dist/application/ReconstructionObligationOriginalCases.js +8 -0
  72. package/dist/application/ReferenceSourceImportEntries.js +160 -18
  73. package/dist/application/ReferenceSourceImportPolicy.js +5 -3
  74. package/dist/application/ReferenceSourceVcsAdapter.js +3 -1
  75. package/dist/application/RegularFileRead.js +107 -88
  76. package/dist/application/Setup.js +23 -11
  77. package/dist/application/SetupClientConfiguration.js +155 -89
  78. package/dist/application/SetupClients.js +22 -13
  79. package/dist/application/SetupHost.js +90 -34
  80. package/dist/application/SetupInstallFailure.js +18 -3
  81. package/dist/application/SetupPlan.js +15 -5
  82. package/dist/application/SetupRecoveryBackup.js +40 -13
  83. package/dist/application/SetupRegistrationEnvironment.js +12 -0
  84. package/dist/application/SetupSkill.js +10 -30
  85. package/dist/application/SourceLimitations.js +35 -0
  86. package/dist/application/SupportedClients.js +4 -4
  87. package/dist/application/Uninstall.js +91 -36
  88. package/dist/application/UpdateCommandProgress.js +66 -0
  89. package/dist/application/UpdateMaintenance.js +7 -2
  90. package/dist/application/UpdateRuntime.js +60 -30
  91. package/dist/application/WebModuleTraceService.js +35 -22
  92. package/dist/application/WebNetworkCaptureService.js +8 -5
  93. package/dist/application/WebRuntimeService.js +41 -8
  94. package/dist/application/WebScriptExportService.js +6 -4
  95. package/dist/application/WebSourceLocationService.js +3 -4
  96. package/dist/application/WorkflowEvidence.js +11 -4
  97. package/dist/application/analysisView/AnalysisViewService.js +9 -52
  98. package/dist/application/android/AndroidAnalysisService.js +5 -4
  99. package/dist/application/android/AndroidSearchEvidenceSummary.js +6 -8
  100. package/dist/application/artifacts/ArtifactComparisonEvidence.js +32 -0
  101. package/dist/application/binary/AnalysisProviderEvaluation.js +14 -11
  102. package/dist/application/binary/AnalysisProviderRegistry.js +340 -50
  103. package/dist/application/binary/BinarySession.js +73 -34
  104. package/dist/application/binary/BinarySessionRecords.js +3 -0
  105. package/dist/application/binary/BinarySessionStatus.js +3 -4
  106. package/dist/application/binary/CompositeProvider.js +75 -30
  107. package/dist/application/binary/LazyAnalysisProvider.js +6 -68
  108. package/dist/application/binary/SessionProviderRouter.js +11 -2
  109. package/dist/application/binaryDiagnostics/BinaryLayoutService.js +3 -4
  110. package/dist/application/binaryDiagnostics/PeResourcesService.js +22 -5
  111. package/dist/application/binaryDiagnostics/RecordedCrashService.js +3 -4
  112. package/dist/application/captures/PacketCaptureService.js +3 -2
  113. package/dist/application/closeOwnedWebResources.js +32 -2
  114. package/dist/application/electron/ElectronFuseService.js +8 -43
  115. package/dist/application/evm/EvmInterfaceEvidence.js +11 -0
  116. package/dist/application/evm/EvmInterfaceService.js +4 -15
  117. package/dist/application/firmware/FirmwareAnalysisService.js +4 -3
  118. package/dist/application/go/GoBinaryService.js +4 -5
  119. package/dist/application/investigation/EvidenceLedger.js +3 -4
  120. package/dist/application/javascript/ElectronBoundaryGraphWindows.js +14 -2
  121. package/dist/application/javascript/ElectronEvidence.js +1 -2
  122. package/dist/application/javascript/ElectronObservationService.js +41 -7
  123. package/dist/application/javascript/JavaScriptApplicationEvidence.js +6 -0
  124. package/dist/application/javascript/JavaScriptArtifactAnalysis.js +35 -17
  125. package/dist/application/javascript/JavaScriptArtifactAnalysisTypes.js +30 -1
  126. package/dist/application/javascript/JavaScriptArtifactGraphContext.js +3 -2
  127. package/dist/application/javascript/JavaScriptArtifactGraphEvidence.js +3 -3
  128. package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +41 -11
  129. package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +18 -8
  130. package/dist/application/javascript/JavaScriptArtifactPathResolution.js +84 -24
  131. package/dist/application/javascript/JavaScriptArtifactReconstruction.js +15 -3
  132. package/dist/application/javascript/JavaScriptModuleRelationships.js +1 -1
  133. package/dist/application/javascript/JavaScriptRuntimeObservationEvidence.js +1 -2
  134. package/dist/application/javascript/JavaScriptRuntimeObservationService.js +33 -10
  135. package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +4 -5
  136. package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +103 -24
  137. package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +13 -4
  138. package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +23 -3
  139. package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +18 -5
  140. package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +4 -6
  141. package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +2 -3
  142. package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +2 -3
  143. package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +5 -8
  144. package/dist/application/native/NativeCallRoutes.js +40 -23
  145. package/dist/application/native/NativeUiActionTrace.js +8 -0
  146. package/dist/application/native/NativeValueTrace.js +8 -0
  147. package/dist/application/reverse/ReverseEngineeringService.js +2 -2
  148. package/dist/application/rust/RustBinaryService.js +6 -4
  149. package/dist/application/signals/SignalRecordingService.js +3 -2
  150. package/dist/application/wasm/WasmArtifactService.js +4 -5
  151. package/dist/artifacts/AnalysisCleanupLease.js +119 -0
  152. package/dist/artifacts/ArtifactFileOperation.js +150 -0
  153. package/dist/artifacts/ArtifactHash.js +2 -1
  154. package/dist/artifacts/ArtifactProvider.js +16 -5
  155. package/dist/artifacts/ArtifactReader.js +50 -4
  156. package/dist/artifacts/ArtifactResourceScope.js +80 -6
  157. package/dist/artifacts/AsarArtifactReader.js +12 -11
  158. package/dist/artifacts/AsarEntryStream.js +49 -17
  159. package/dist/artifacts/DirectoryArtifactReader.js +28 -7
  160. package/dist/artifacts/MachOSliceArtifactReader.js +70 -13
  161. package/dist/artifacts/NativeDmgArtifactReader.js +112 -13
  162. package/dist/artifacts/SafeOutputTree.js +5 -3
  163. package/dist/artifacts/SafeOutputTreeCreationFailure.js +1 -0
  164. package/dist/artifacts/SafeOutputTreeReadback.js +10 -16
  165. package/dist/artifacts/ZipArtifactReader.js +34 -14
  166. package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +3 -1
  167. package/dist/artifacts/apple/DylibFileAccess.js +106 -0
  168. package/dist/artifacts/apple/DylibResolutionReader.js +64 -155
  169. package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +52 -9
  170. package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +25 -24
  171. package/dist/artifacts/apple/KeyedArchiveReader.js +20 -11
  172. package/dist/artifacts/apple/MachoLoadCommandReader.js +17 -2
  173. package/dist/artifacts/apple/PlistNumberLiterals.js +104 -116
  174. package/dist/artifacts/extraction/ArtifactExtraction.js +15 -12
  175. package/dist/artifacts/inventory/ArtifactGraphConstruction.js +9 -11
  176. package/dist/artifacts/inventory/ArtifactInventory.js +2 -2
  177. package/dist/artifacts/inventory/classify.js +4 -2
  178. package/dist/artifacts/inventory/hashStableRootArtifact.js +14 -7
  179. package/dist/artifacts/inventory/scanCanonical.js +3 -4
  180. package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +3 -1
  181. package/dist/artifacts/readArtifactFileChunks.js +9 -0
  182. package/dist/artifacts/readStableArtifact.js +12 -34
  183. package/dist/browser/BrowserScenarioPartialObservation.js +14 -48
  184. package/dist/browser/CdpBrowserProvider.js +81 -30
  185. package/dist/browser/CdpCaptureDocuments.js +99 -131
  186. package/dist/browser/CdpCaptureDomSvg.js +31 -60
  187. package/dist/browser/CdpCaptureValues.js +12 -0
  188. package/dist/browser/CdpConnection.js +133 -27
  189. package/dist/browser/CdpElectronInspection.js +60 -60
  190. package/dist/browser/CdpElectronProvider.js +56 -4
  191. package/dist/browser/CdpElectronScriptEvents.js +4 -1
  192. package/dist/browser/CdpElectronScripts.js +2 -5
  193. package/dist/browser/CdpElectronWorkers.js +13 -2
  194. package/dist/browser/CdpPageCapture.js +2 -1
  195. package/dist/browser/CdpPageCaptureScripts.js +14 -10
  196. package/dist/browser/CdpPageCaptureWorkers.js +45 -14
  197. package/dist/browser/CdpSafeMetadata.js +23 -19
  198. package/dist/browser/CdpSnapshotNodes.js +103 -0
  199. package/dist/browser/CdpSnapshotStrings.js +0 -6
  200. package/dist/browser/CdpTargetSession.js +52 -10
  201. package/dist/browser/CdpTargetSessionOwner.js +198 -0
  202. package/dist/browser/ElectronCaptureCleanup.js +82 -0
  203. package/dist/browser/ElectronProcessCleanup.js +91 -0
  204. package/dist/browser/PlaywrightBrowserScenarioProvider.js +71 -16
  205. package/dist/browser/PlaywrightElectronActiveActions.js +53 -5
  206. package/dist/browser/PlaywrightElectronActiveFuses.js +86 -0
  207. package/dist/browser/PlaywrightElectronActiveProjection.js +5 -0
  208. package/dist/browser/PlaywrightElectronActiveProvider.js +140 -151
  209. package/dist/browser/PlaywrightExecutionBoundary.js +4 -2
  210. package/dist/browser/PlaywrightScenarioBrowser.js +236 -90
  211. package/dist/browser/PlaywrightScenarioEvents.js +135 -48
  212. package/dist/browser/PlaywrightScenarioServiceWorkers.js +121 -34
  213. package/dist/browser/PlaywrightScenarioSession.js +95 -22
  214. package/dist/browser/PlaywrightScenarioStorage.js +15 -7
  215. package/dist/browser/StructuredFieldToken.js +53 -0
  216. package/dist/browser/WebArtifactCleanup.js +53 -0
  217. package/dist/browser/WebSourceMapFetcher.js +19 -10
  218. package/dist/browser/assets/WebArtifactReads.js +6 -2
  219. package/dist/browser/assets/WebSourceLocationArtifacts.js +12 -3
  220. package/dist/browser/execution/CdpRuntimeSession.js +36 -7
  221. package/dist/browser/execution/CdpWebRuntimeProvider.js +22 -4
  222. package/dist/browser/history/CaptureFailures.js +7 -2
  223. package/dist/browser/history/HarCapture.js +42 -11
  224. package/dist/browser/history/SazMetadata.js +10 -47
  225. package/dist/browser/modules/NativeModuleResolver.js +108 -58
  226. package/dist/browser/modules/WebModuleArtifacts.js +12 -3
  227. package/dist/browser/network/PlaywrightNetworkContent.js +40 -17
  228. package/dist/browser/network/PlaywrightScenarioNetwork.js +182 -73
  229. package/dist/captures/TsharkCaptureProvider.js +13 -6
  230. package/dist/catalogIdentity.js +19 -14
  231. package/dist/cli/adbCommands.js +18 -19
  232. package/dist/cli/androidCommands.js +2 -14
  233. package/dist/cli/apktoolCommands.js +4 -14
  234. package/dist/cli/binaryDiagnosticsCommands.js +5 -5
  235. package/dist/cli/browserAdvancedCommands.js +11 -4
  236. package/dist/cli/browserCommands.js +21 -12
  237. package/dist/cli/captureCommands.js +4 -4
  238. package/dist/cli/cliResultOutput.js +175 -89
  239. package/dist/cli/coreBinaryCommands.js +4 -3
  240. package/dist/cli/cutterCommands.js +51 -13
  241. package/dist/cli/electronCommands.js +34 -13
  242. package/dist/cli/evmCommands.js +6 -15
  243. package/dist/cli/finishAnalysisCommand.js +10 -2
  244. package/dist/cli/firmwareCommands.js +6 -14
  245. package/dist/cli/flutterCommands.js +2 -18
  246. package/dist/cli/fridaCommands.js +8 -0
  247. package/dist/cli/goCommands.js +2 -2
  248. package/dist/cli/javascriptRecoveryCommands.js +14 -26
  249. package/dist/cli/jebCommands.js +2 -14
  250. package/dist/cli/options.js +6 -0
  251. package/dist/cli/pcapCommands.js +2 -20
  252. package/dist/cli/rustCommands.js +6 -7
  253. package/dist/cli/setupCommands.js +4 -3
  254. package/dist/cli/signalCommands.js +4 -4
  255. package/dist/cli/sqliteCommands.js +17 -44
  256. package/dist/cli/wasmCommands.js +7 -18
  257. package/dist/cli/webModuleCommands.js +19 -34
  258. package/dist/cli/webNetworkCaptureCommands.js +3 -2
  259. package/dist/cli/webRuntimeCommands.js +15 -6
  260. package/dist/cli/webSourceLocationCommands.js +14 -33
  261. package/dist/cli-runtime/AnalysisCleanupLease-CWfTGYKd.js +103 -0
  262. package/dist/cli-runtime/{AnalysisProvider-D0Us2OTk.js → AnalysisProvider-BGrYaMVo.js} +14 -3
  263. package/dist/cli-runtime/{AnalysisSnapshotCache-BXS0wRd2.js → AnalysisSnapshotCache-BjRlXeUS.js} +14 -13
  264. package/dist/cli-runtime/ArtifactFileOperation-Dg4BcoEM.js +122 -0
  265. package/dist/cli-runtime/{ArtifactReader-BXkffc1D.js → ArtifactReader-DMwm42bk.js} +29 -6
  266. package/dist/cli-runtime/ArtifactResourceScope-CokZGcII.js +175 -0
  267. package/dist/cli-runtime/{AsarHeader-CnzOzYEH.js → AsarHeader-BxwU17DJ.js} +1 -1
  268. package/dist/cli-runtime/{BinarySessionStatus-DnMxMk-r.js → BinarySessionStatus-DRhjr7Vb.js} +4 -3
  269. package/dist/cli-runtime/{BinaryTargetResolver-CVIJ_s1A.js → BinaryTargetResolver-tuCTjBlQ.js} +38 -108
  270. package/dist/cli-runtime/{BoundedFileBytes-BU30odTm.js → BoundedFileBytes-DRtiQNAQ.js} +7 -3
  271. package/dist/cli-runtime/{CdpTargetSession-DGX5pV9w.js → CdpTargetSession-CQ08KHbh.js} +318 -43
  272. package/dist/cli-runtime/ClientConfigPath-Dn-V_GUf.js +255 -0
  273. package/dist/cli-runtime/{ClientConfigurationDocument-ffQ9X0Se.js → ClientConfigurationDocument-C9T8MNGc.js} +206 -142
  274. package/dist/cli-runtime/{ClientRegistrationStatus-DszCyPEU.js → ClientRegistrationStatus-PnD29RTX.js} +112 -36
  275. package/dist/cli-runtime/{CurrentEntrypointPath-D5FRNdkq.js → CurrentEntrypointPath-m7QCIVN0.js} +1 -1
  276. package/dist/cli-runtime/{DirectAnalysis-BgvAtpN3.js → DirectAnalysis-C5NyUryV.js} +76 -23
  277. package/dist/cli-runtime/DirectoryArtifactReader-CokAJ8vo.js +448 -0
  278. package/dist/cli-runtime/{Doctor-DIpf_I7N.js → Doctor-DrkWsav4.js} +105 -25
  279. package/dist/cli-runtime/{ElectronFileScope-dpHm2nrS.js → ElectronFileScope-AP7VoVr7.js} +204 -149
  280. package/dist/cli-runtime/ElectronFuseFailures-DsjXR7Xp.js +609 -0
  281. package/dist/cli-runtime/{ExecFileOutput-BEQs-lDD.js → ExecFileOutput-D6KLYTve.js} +11 -9
  282. package/dist/cli-runtime/{InterfaceBuilderDecodeBudget-D4omRUe4.js → InterfaceBuilderDecodeBudget-CW1IO3dG.js} +40 -21
  283. package/dist/cli-runtime/{InventoryProjectionEvidence-DIsI4DJ6.js → InventoryProjectionEvidence-DTH5QAqL.js} +3 -3
  284. package/dist/cli-runtime/{InvestigationProviders-DoQRIHii.js → InvestigationProviders-CFh4a64d.js} +3 -2
  285. package/dist/cli-runtime/{JavaScriptApplicationEvidenceGraph-D5aI_FSJ.js → JavaScriptApplicationEvidenceGraph-gOmPB2L6.js} +6 -6
  286. package/dist/cli-runtime/{JavaScriptApplicationWorkflowEvidence-Bz4-V0Ct.js → JavaScriptApplicationWorkflowEvidence-WZgtK_Ok.js} +2 -2
  287. package/dist/cli-runtime/JebMcpEndpoint-BEalGZh9.js +710 -0
  288. package/dist/cli-runtime/{JsonFiles-DQa1PRKy.js → JsonFiles-uvd6ZyQi.js} +10 -118
  289. package/dist/cli-runtime/KunaInstallation-P0j3x851.js +1781 -0
  290. package/dist/cli-runtime/MacHopperPaths-bGzqjF1Z.js +34 -0
  291. package/dist/cli-runtime/{MachoLoadCommandReader-C7e074Ze.js → MachoLoadCommandReader-CZm6N5vF.js} +12 -192
  292. package/dist/cli-runtime/{ManagedSnapshot-rqyBHcdL.js → ManagedSnapshot-CPE9C3OD.js} +406 -110
  293. package/dist/cli-runtime/OwnedCommandCleanup-BN_V6Erc.js +187 -0
  294. package/dist/cli-runtime/OwnedRegularFile-D1f5nUCx.js +256 -0
  295. package/dist/cli-runtime/OwnedStagedOutput-D31dOozz.js +126 -0
  296. package/dist/cli-runtime/{PrivateRuntimeRoot-DAy0PiBM.js → PrivateRuntimeRoot-Cd23u6jd.js} +39 -6
  297. package/dist/cli-runtime/ProcessOwnership-CtrNr6ee.js +545 -0
  298. package/dist/cli-runtime/{ProcessOwnership-DXC5-UWt.js → ProcessOwnershipObservation-C006iCtZ.js} +149 -607
  299. package/dist/cli-runtime/{ProviderDeadline-8m2pFRDc.js → ProviderDeadline-rSuH4Pm8.js} +27 -1
  300. package/dist/cli-runtime/ProviderOperationExecution-CmU-XrQr.js +38 -0
  301. package/dist/cli-runtime/{snapshotEnvironment-D_tWyOub.js → ProviderProcess-D87A7ctp.js} +117 -160
  302. package/dist/cli-runtime/RegularFileRead-mbgGYtxe.js +125 -0
  303. package/dist/cli-runtime/{SafeOutputTree-D6U15GXd.js → SafeOutputTree-i904hd_2.js} +21 -20
  304. package/dist/cli-runtime/{SetupHost-FkYWswsq.js → SetupHost-CMPmPraB.js} +365 -195
  305. package/dist/cli-runtime/SharedStartupAttempt-BxKyf3Uv.js +1424 -0
  306. package/dist/cli-runtime/StableFileHash-Ame_h3lY.js +61 -0
  307. package/dist/cli-runtime/{SupportedClients-DaX6Lt2d.js → SupportedClients-DMafjitv.js} +89 -72
  308. package/dist/cli-runtime/{Update-CbTC_eg1.js → Update-DAsASWlE.js} +1 -1
  309. package/dist/cli-runtime/{AbortablePromise-BVBemxbD.js → WindowsBatchCommand-Cx9kaVNf.js} +2 -28
  310. package/dist/cli-runtime/WindowsNativeLoader-BqyZO0ZD.js +142 -0
  311. package/dist/cli-runtime/{ZipArtifactReader-B8ZgNe4D.js → ZipArtifactReader-Jed69LEL.js} +20 -16
  312. package/dist/cli-runtime/{analysisErrorCleanup-Do6YeeoD.js → analysisErrorCleanup-COdAmDsb.js} +4 -3
  313. package/dist/cli-runtime/{appleArchiveFormat-tVoI2ykA.js → appleArchiveFormat-Bb3G5CCI.js} +13 -7
  314. package/dist/cli-runtime/{application__DirectAnalysisStatus-DpOejOf0.js → application__DirectAnalysisStatus-F74bu9oy.js} +10 -10
  315. package/dist/cli-runtime/{application__EnhancedTools-oFE2bOjs.js → application__EnhancedTools-Bg51b0Yp.js} +84 -51
  316. package/dist/cli-runtime/{application__FunctionAnalysisEvidence-B6osuhvW.js → application__FunctionAnalysisEvidence-DBWIaYCh.js} +3 -3
  317. package/dist/cli-runtime/{application__ReconstructionCoverageService-DN3wTFQj.js → application__ReconstructionCoverageService-AEPNpZqJ.js} +3 -3
  318. package/dist/cli-runtime/{application__ReconstructionObligationLedgerService-CKcTppX9.js → application__ReconstructionObligationLedgerService-Cl9cPEZf.js} +22 -9
  319. package/dist/cli-runtime/{application__Setup-XpMaRNjy.js → application__Setup-DwQzEewK.js} +30 -18
  320. package/dist/cli-runtime/{application__Uninstall-_23pU2yB.js → application__Uninstall-BOf9oyvQ.js} +78 -37
  321. package/dist/cli-runtime/{application__UpdateRuntime-DPvY8ohd.js → application__UpdateRuntime-CzWkRJHa.js} +119 -29
  322. package/dist/cli-runtime/{application__android__AndroidApplicationService-CFgIFPM4.js → application__android__AndroidApplicationService-shW_aKlj.js} +3 -3
  323. package/dist/cli-runtime/{application__apple__AppleApplicationService-Db6QCsun.js → application__apple__AppleApplicationService-DIv6d3wB.js} +3 -3
  324. package/dist/cli-runtime/{application__harmony__HarmonyApplicationService-CFjocHoK.js → application__harmony__HarmonyApplicationService-OIUFVQFV.js} +3 -3
  325. package/dist/cli-runtime/{application__javascript__ElectronActiveObservationService-CmVDUI_Z.js → application__javascript__ElectronActiveObservationService-wvCh72hK.js} +3 -3
  326. package/dist/cli-runtime/application__javascript__ElectronObservationService-SydXPCwM.js +88 -0
  327. package/dist/cli-runtime/{application__javascript__JavaScriptApplicationService-CCkp8KBh.js → application__javascript__JavaScriptApplicationService-o0uEsjEc.js} +1120 -316
  328. package/dist/cli-runtime/{application__javascript__JavaScriptApplicationWorkflowService-lPy0tzr3.js → application__javascript__JavaScriptApplicationWorkflowService-BAheG_71.js} +51 -44
  329. package/dist/cli-runtime/{application__javascript__JavaScriptRuntimeReconciliationService-DWleA8K9.js → application__javascript__JavaScriptRuntimeReconciliationService-Cnn4GP8q.js} +5 -5
  330. package/dist/cli-runtime/{application__javascript__JavaScriptSemanticTraceService-DkALH4rL.js → application__javascript__JavaScriptSemanticTraceService-CmvLfV1A.js} +6 -6
  331. package/dist/cli-runtime/{artifacts__ArtifactProvider-zXI0QjSL.js → artifacts__ArtifactProvider-wx2K0F2I.js} +377 -359
  332. package/dist/cli-runtime/{binary-BVOr2mgE.js → binary-CWVNJhAC.js} +8561 -3159
  333. package/dist/cli-runtime/{catalogIdentity-DLoXgfIR.js → catalogIdentity-DAEEsOdX.js} +260 -81
  334. package/dist/cli-runtime/cli.js +6177 -3556
  335. package/dist/cli-runtime/{cliOutput-BC1BdAcB.js → cliOutput-CgSuw782.js} +47 -6
  336. package/dist/cli-runtime/cliOutput.js +2 -2
  337. package/dist/cli-runtime/cliResultOutput-10sd6xGx.js +1453 -0
  338. package/dist/cli-runtime/cliResultOutput.js +2 -1
  339. package/dist/cli-runtime/{composition__browserScenario-DHXC1a8n.js → composition__browserScenario-BtPb1c1y.js} +843 -356
  340. package/dist/cli-runtime/{composition__electronObservation-GecK2EID.js → composition__electronObservation-Bk8R6DJo.js} +128 -69
  341. package/dist/cli-runtime/{composition__electronScenario-CEZnVrAL.js → composition__electronScenario-BVF0qStH.js} +398 -135
  342. package/dist/cli-runtime/{cutterToolContracts-TZH9EHr5.js → cutterToolContracts-BQtG_Nzo.js} +195 -62
  343. package/dist/cli-runtime/{doctorRuntime-BE5ZX8it.js → doctorRuntime-B__SIpm-.js} +241 -21
  344. package/dist/cli-runtime/{dotnet__ManagedStaticProvider-C8_yZCDc.js → dotnet__ManagedStaticProvider-DO5Yzcp4.js} +1 -1
  345. package/dist/cli-runtime/{errorSchemas-CTRmvMl3.js → errorSchemas-Ixz_q7qt.js} +58 -4
  346. package/dist/cli-runtime/homeDirectory-DC_DeJIg.js +18 -0
  347. package/dist/cli-runtime/{javascriptApplicationAnalysis-HgMzVMQw.js → javascriptApplicationAnalysis-Dk6yBV8g.js} +688 -668
  348. package/dist/cli-runtime/{javascriptExportReturnShapeProjection-Dg00g35t.js → javascriptExportReturnShapeProjection-CObOIiQ6.js} +3 -3
  349. package/dist/cli-runtime/{javascriptExportShapeComparisonSchemas-BYnoIqIk.js → javascriptExportShapeComparisonSchemas-DpwuBenh.js} +5 -3
  350. package/dist/cli-runtime/{javascriptRuntimeReconciliation-DNjDoL3S.js → javascriptRuntimeReconciliation-C6ZgWMys.js} +61 -59
  351. package/dist/cli-runtime/{javascriptRuntimeReconciliationSchemas-BWpGWNcI.js → javascriptRuntimeReconciliationSchemas-D6tZKUQs.js} +2 -2
  352. package/dist/cli-runtime/{javascriptSemanticTraceSchemas-BTCNcvbc.js → javascriptSemanticTraceSchemas-C7m0b6_w.js} +3 -3
  353. package/dist/cli-runtime/{lipo-DSWP6fv-.js → lipo-DPQ6qurH.js} +9 -11
  354. package/dist/cli-runtime/{logger-CQQCI4a2.js → logger-BuDJ9xxO.js} +2 -2
  355. package/dist/cli-runtime/{machoContainer-C8BIkkq3.js → machoContainer-Cy98bkFm.js} +180 -0
  356. package/dist/cli-runtime/{managedApplicationGraph-B08jb3jq.js → managedApplicationGraph-BazVqpJv.js} +16 -10
  357. package/dist/cli-runtime/{managedToolContracts-D60QmIYj.js → managedToolContracts-BuFkMBH5.js} +2 -2
  358. package/dist/cli-runtime/mcpDoctor.js +8 -6
  359. package/dist/cli-runtime/mcpStartupPolicy-imCbM3qo.js +28 -0
  360. package/dist/cli-runtime/{native__NativeMacOSProvider-YBTvUeJO.js → native__NativeMacOSProvider-DTcRhuGA.js} +1384 -757
  361. package/dist/cli-runtime/{officialToolContracts-CCFF0an9.js → officialToolContracts-CzzVLx8I.js} +74 -53
  362. package/dist/cli-runtime/peMachine-B9ggfSJJ.js +95 -0
  363. package/dist/cli-runtime/propertyListKeys-D5dSASEy.js +355 -0
  364. package/dist/cli-runtime/{providerCleanupError-Ceq8f0wK.js → providerCleanupError-BhsJyAhk.js} +3 -5
  365. package/dist/cli-runtime/readArtifactFileChunks-BbTL_PtB.js +129 -0
  366. package/dist/cli-runtime/{reconstructionObligationLedgerSchemas-Bao0xMr-.js → reconstructionObligationLedgerSchemas-Bi6sect1.js} +6329 -3651
  367. package/dist/cli-runtime/{scanCanonical-KP4T9jSl.js → scanCanonical-CcDFUr-w.js} +233 -363
  368. package/dist/cli-runtime/snapshotEnvironment-Yvx5qwsl.js +196 -0
  369. package/dist/cli-runtime/{toolContracts-D2FOG_Nb.js → toolContracts-CJzEyZ38.js} +126 -52
  370. package/dist/cli-runtime/{toolOutputSchemaGroups-DRiYs1je.js → toolOutputSchemaGroups-BqdSzySu.js} +768 -589
  371. package/dist/cli-runtime/{workflowInputError-n8Oo-bLA.js → workflowInputError-BP8z9Wxl.js} +2 -2
  372. package/dist/cli.js +10 -0
  373. package/dist/cliBrowserScenarioCommands.js +2 -3
  374. package/dist/cliLogging.js +22 -7
  375. package/dist/cliObservationOptions.js +3 -0
  376. package/dist/cliOutput.js +68 -3
  377. package/dist/composition/binary.js +15 -2
  378. package/dist/composition/directAnalysis.js +8 -0
  379. package/dist/composition/javascriptAnalysisWorkerProcess.js +4 -5
  380. package/dist/composition/jeb.js +32 -21
  381. package/dist/config/environment.js +36 -2
  382. package/dist/config/mcpInputSchemaProfile.js +1 -1
  383. package/dist/config/parseConfig.js +7 -3
  384. package/dist/contracts/adb/adbToolContracts.js +2 -2
  385. package/dist/contracts/analysisViewApiSurfaceExample.js +4 -4
  386. package/dist/contracts/analysisViewToolContracts.js +42 -1
  387. package/dist/contracts/android/androidToolContracts.js +1 -1
  388. package/dist/contracts/apktool/apktoolToolContracts.js +5 -1
  389. package/dist/contracts/artifactComparisonExample.js +18 -14
  390. package/dist/contracts/artifactToolContracts.js +2 -1
  391. package/dist/contracts/browserScenarioToolContracts.js +1 -1
  392. package/dist/contracts/browserToolContracts.js +12 -1
  393. package/dist/contracts/compactInputSchema.js +13 -6
  394. package/dist/contracts/fridaToolContracts.js +5 -4
  395. package/dist/contracts/gdbToolContracts.js +2 -3
  396. package/dist/contracts/inputSchemaPresentation.js +173 -79
  397. package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +1 -0
  398. package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +1 -0
  399. package/dist/contracts/jsonSchemaKeywords.js +29 -0
  400. package/dist/contracts/managed/managedWorkflowExamples.js +3 -0
  401. package/dist/contracts/managed/managedWorkflowToolContracts.js +1 -1
  402. package/dist/contracts/mobileApplicationGraphExamples.js +15 -12
  403. package/dist/contracts/officialToolContracts.js +2 -2
  404. package/dist/contracts/rizinDebugToolContracts.js +3 -2
  405. package/dist/contracts/sessionToolContracts.js +3 -3
  406. package/dist/contracts/toolEffects.js +6 -2
  407. package/dist/contracts/toolOutputSchemaGroups.js +7 -4
  408. package/dist/contracts/toolOutputSchemaPrimitives.js +7 -0
  409. package/dist/contracts/toolSchemaMetadata.js +99 -27
  410. package/dist/cutter/CutterBridgeClient.js +206 -67
  411. package/dist/cutter/CutterBridgeService.js +52 -4
  412. package/dist/doctorRuntime.js +25 -4
  413. package/dist/domain/adb/adbDeviceAnalysis.js +19 -1
  414. package/dist/domain/analysisErrorBase.js +59 -2
  415. package/dist/domain/analysisErrorCleanup.js +3 -1
  416. package/dist/domain/analysisErrorCore.js +13 -0
  417. package/dist/domain/analysisErrorPresentation.js +23 -4
  418. package/dist/domain/analysisErrorProjection.js +44 -28
  419. package/dist/domain/analysisSearch.js +26 -0
  420. package/dist/domain/analysisSnapshot.js +11 -11
  421. package/dist/domain/analysisView/WebNetworkApiSurfaceAccumulator.js +4 -65
  422. package/dist/domain/analysisView/analysisView.js +25 -0
  423. package/dist/domain/analysisView/analysisViewDataAdmission.js +86 -0
  424. package/dist/domain/analysisView/artifactInventoryView.js +4 -18
  425. package/dist/domain/analysisView/javascriptApplicationCoverage.js +27 -0
  426. package/dist/domain/analysisView/javascriptApplicationView.js +100 -27
  427. package/dist/domain/analysisView/javascriptFactsView.js +92 -0
  428. package/dist/domain/analysisView/javascriptModuleReferences.js +37 -0
  429. package/dist/domain/analysisView/managedMemberView.js +6 -0
  430. package/dist/domain/android/androidApplication.js +8 -7
  431. package/dist/domain/apktool/apktoolResourceAnalysis.js +52 -2
  432. package/dist/domain/apple/appleApplication.js +41 -60
  433. package/dist/domain/apple/appleBundleAnatomy.js +56 -68
  434. package/dist/domain/apple/dylibResolution.js +5 -1
  435. package/dist/domain/apple/interfaceBuilderGraph.js +29 -8
  436. package/dist/domain/apple/interfaceBuilderKeyedArchive.js +11 -4
  437. package/dist/domain/apple/jvmClassFile.js +226 -0
  438. package/dist/domain/apple/keyedArchive.js +39 -17
  439. package/dist/domain/apple/machoContainer.js +3 -0
  440. package/dist/domain/apple/plistNumbers.js +67 -5
  441. package/dist/domain/apple/plistValue.js +89 -18
  442. package/dist/domain/artifactComparison.js +7 -5
  443. package/dist/domain/artifactGraph.js +4 -12
  444. package/dist/domain/artifactInspection.js +6 -17
  445. package/dist/domain/artifactInventoryEvidence.js +68 -60
  446. package/dist/domain/binaryTarget.js +11 -26
  447. package/dist/domain/binaryTargetTypes.js +10 -0
  448. package/dist/domain/browserNetworkEvidence.js +20 -3
  449. package/dist/domain/browserObservation.js +5 -28
  450. package/dist/domain/browserObservationError.js +4 -4
  451. package/dist/domain/browserScenarioCapture.js +11 -2
  452. package/dist/domain/browserScenarioCaptureLimits.js +34 -0
  453. package/dist/domain/browserScenarioCaptureValues.js +50 -0
  454. package/dist/domain/browserScenarioDiffEvidence.js +1 -3
  455. package/dist/domain/browserScenarioValues.js +5 -1
  456. package/dist/domain/captures/packetCapture.js +2 -1
  457. package/dist/domain/dosMz.js +14 -5
  458. package/dist/domain/electron/electronFuseEvidence.js +42 -0
  459. package/dist/domain/elfFixedHeader.js +24 -0
  460. package/dist/domain/evidence.js +7 -6
  461. package/dist/domain/evidenceBundle.js +9 -2
  462. package/dist/domain/explicitSensitiveFailure.js +3 -0
  463. package/dist/domain/fileSnapshotObservation.js +25 -0
  464. package/dist/domain/fixedTupleSchema.js +9 -0
  465. package/dist/domain/functionCallCoverage.js +6 -6
  466. package/dist/domain/functionComparisonDimensions.js +38 -11
  467. package/dist/domain/functionComparisonNormalization.js +17 -9
  468. package/dist/domain/functionDossierEvidence.js +4 -3
  469. package/dist/domain/harmony/harmonyApplication.js +8 -8
  470. package/dist/domain/hopperErrors.js +4 -2
  471. package/dist/domain/hopperValues.js +27 -4
  472. package/dist/domain/javascript/electronActiveObservation.js +1 -0
  473. package/dist/domain/javascript/electronStaticAnalysisBrowser.js +80 -20
  474. package/dist/domain/javascript/electronStaticAnalysisValues.js +0 -20
  475. package/dist/domain/javascript/electronStaticOptionObjects.js +45 -0
  476. package/dist/domain/javascript/electronWrappedCallPaths.js +70 -17
  477. package/dist/domain/javascript/javascriptAnalysisResourceControls.js +20 -4
  478. package/dist/domain/javascript/javascriptApplicationAnalysis.js +4 -0
  479. package/dist/domain/javascript/javascriptApplicationChangeGraph.js +3 -0
  480. package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +3 -1
  481. package/dist/domain/javascript/javascriptApplicationVersionItems.js +49 -21
  482. package/dist/domain/javascript/javascriptAstFingerprint.js +41 -10
  483. package/dist/domain/javascript/javascriptAstValues.js +83 -5
  484. package/dist/domain/javascript/javascriptBundledRequireOrigin.js +23 -36
  485. package/dist/domain/javascript/javascriptCommonJsExportReceivers.js +231 -0
  486. package/dist/domain/javascript/javascriptElectronMemberWrites.js +14 -4
  487. package/dist/domain/javascript/javascriptFeatureSeed.js +1 -1
  488. package/dist/domain/javascript/javascriptGraphqlOperations.js +382 -0
  489. package/dist/domain/javascript/javascriptModuleDeclaration.js +20 -0
  490. package/dist/domain/javascript/javascriptNativeHandoff.js +7 -11
  491. package/dist/domain/javascript/javascriptRpcEndpoints.js +7 -171
  492. package/dist/domain/javascript/javascriptRuntimeLoadState.js +9 -4
  493. package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +35 -12
  494. package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +50 -45
  495. package/dist/domain/javascript/javascriptSemanticAmbientWrites.js +284 -24
  496. package/dist/domain/javascript/javascriptSemanticAnalysis.js +452 -182
  497. package/dist/domain/javascript/javascriptSemanticAsyncEffects.js +37 -20
  498. package/dist/domain/javascript/javascriptSemanticCallResolution.js +55 -27
  499. package/dist/domain/javascript/javascriptSemanticCalls.js +4 -4
  500. package/dist/domain/javascript/javascriptSemanticChildProcesses.js +134 -50
  501. package/dist/domain/javascript/javascriptSemanticCoverage.js +5 -1
  502. package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +7 -13
  503. package/dist/domain/javascript/javascriptSemanticDataEffects.js +33 -10
  504. package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +1 -1
  505. package/dist/domain/javascript/javascriptSemanticEvaluationOrder.js +126 -0
  506. package/dist/domain/javascript/javascriptSemanticExpressionShapes.js +111 -0
  507. package/dist/domain/javascript/javascriptSemanticGetterQueries.js +147 -0
  508. package/dist/domain/javascript/javascriptSemanticGetterResults.js +264 -0
  509. package/dist/domain/javascript/javascriptSemanticGraph.js +18 -1
  510. package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +13 -0
  511. package/dist/domain/javascript/javascriptSemanticIterationSources.js +3 -2
  512. package/dist/domain/javascript/javascriptSemanticMapOperations.js +51 -0
  513. package/dist/domain/javascript/javascriptSemanticMemberMutations.js +215 -81
  514. package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +395 -118
  515. package/dist/domain/javascript/javascriptSemanticObjectReferences.js +241 -328
  516. package/dist/domain/javascript/javascriptSemanticObjects.js +33 -27
  517. package/dist/domain/javascript/javascriptSemanticOpaqueEffects.js +163 -0
  518. package/dist/domain/javascript/javascriptSemanticPrimitives.js +11 -1
  519. package/dist/domain/javascript/javascriptSemanticProjection.js +44 -67
  520. package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +2 -1
  521. package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +1 -1
  522. package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +45 -7
  523. package/dist/domain/javascript/javascriptSemanticResourceLimits.js +3 -19
  524. package/dist/domain/javascript/javascriptSemanticResources.js +27 -4
  525. package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +78 -37
  526. package/dist/domain/javascript/javascriptSemanticReturns.js +2 -2
  527. package/dist/domain/javascript/javascriptSemanticState.js +191 -42
  528. package/dist/domain/javascript/javascriptSemanticValues.js +167 -41
  529. package/dist/domain/javascript/javascriptSourceParser.js +54 -9
  530. package/dist/domain/javascript/javascriptStaticAnalysis.js +24 -13
  531. package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +276 -16
  532. package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +33 -25
  533. package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -0
  534. package/dist/domain/javascript/javascriptStaticAnalysisTypes.js +1 -1
  535. package/dist/domain/javascript/javascriptSymbolicBindings.js +424 -142
  536. package/dist/domain/javascript/javascriptSymbolicControlFlow.js +4 -0
  537. package/dist/domain/javascript/javascriptSymbolicValues.js +12 -1
  538. package/dist/domain/javascript/sourceToBundleSignals.js +3 -0
  539. package/dist/domain/managed/managedApplicationGraphNodes.js +14 -9
  540. package/dist/domain/managed/managedArtifact.js +26 -0
  541. package/dist/domain/managed/managedMemberComparison.js +3 -0
  542. package/dist/domain/managed/managedMemberComparisonCoverage.js +14 -1
  543. package/dist/domain/managed/managedMemberComparisonItems.js +124 -52
  544. package/dist/domain/managed/managedMemberComparisonMatch.js +76 -72
  545. package/dist/domain/managed/managedMemberSignatureIdentity.js +40 -0
  546. package/dist/domain/managed/managedNativeVerificationMatch.js +5 -5
  547. package/dist/domain/managed/managedNativeVerificationSchemas.js +2 -2
  548. package/dist/domain/mobileApplicationGraphProjection.js +33 -18
  549. package/dist/domain/native/bytePattern.js +21 -0
  550. package/dist/domain/native/nativeAotPe.js +29 -2
  551. package/dist/domain/native/nativeAotSnapshotObservation.js +18 -0
  552. package/dist/domain/native/nativeCallPartialObservation.js +14 -12
  553. package/dist/domain/native/nativeLoadImage.js +13 -0
  554. package/dist/domain/native/objcSwiftMetadata.js +15 -8
  555. package/dist/domain/native/peResources.js +6 -2
  556. package/dist/domain/peMachine.js +2 -0
  557. package/dist/domain/process/processComparison.js +3 -3
  558. package/dist/domain/process/processTraceDimensionProjection.js +1 -1
  559. package/dist/domain/process/processTraceEvaluation.js +65 -24
  560. package/dist/domain/propertyListKeys.js +84 -69
  561. package/dist/domain/propertyListXml.js +149 -0
  562. package/dist/domain/providerAdapterError.js +2 -0
  563. package/dist/domain/providerCleanupError.js +2 -4
  564. package/dist/domain/rawBinary.js +11 -2
  565. package/dist/domain/reconstructionCoverage.js +35 -23
  566. package/dist/domain/reconstructionCoverageEvaluation.js +36 -36
  567. package/dist/domain/reconstructionCoverageEvidence.js +26 -0
  568. package/dist/domain/reconstructionVerification.js +40 -26
  569. package/dist/domain/referenceSourceImportParsing.js +4 -0
  570. package/dist/domain/referenceSourcePathIdentity.js +2 -0
  571. package/dist/domain/referenceSourceRequireBindings.js +40 -101
  572. package/dist/domain/relationshipCoverage.js +4 -5
  573. package/dist/domain/sqlite/sqliteDatabase.js +2 -1
  574. package/dist/domain/symbolAnalysis.js +9 -8
  575. package/dist/domain/webBundleAnalyzerInspection.js +65 -25
  576. package/dist/domain/webCaptureDiff.js +124 -41
  577. package/dist/domain/webInventory.js +28 -14
  578. package/dist/domain/webModuleTrace.js +22 -0
  579. package/dist/domain/webScriptExportError.js +2 -3
  580. package/dist/domain/xmlDocument.js +41 -0
  581. package/dist/domain/zipPackageFormat.js +0 -4
  582. package/dist/dotnet/ManagedArtifactInspector.js +2 -4
  583. package/dist/dotnet/ManagedDecodeBudget.js +21 -1
  584. package/dist/dotnet/ManagedMemberInspector.js +31 -6
  585. package/dist/dotnet/ManagedMemberInspectorCore.js +63 -12
  586. package/dist/dotnet/ManagedMemberRows.js +8 -8
  587. package/dist/dotnet/ManagedMetadataHeaps.js +0 -1
  588. package/dist/dotnet/ManagedMetadataLayout.js +17 -15
  589. package/dist/dotnet/ManagedNativeBoundaryHelpers.js +20 -19
  590. package/dist/dotnet/ManagedNativeBoundaryInspector.js +7 -8
  591. package/dist/dotnet/ManagedPeReader.js +5 -0
  592. package/dist/dotnet/ManagedSnapshot.js +25 -20
  593. package/dist/dotnet/ManagedTypeNameDigests.js +177 -0
  594. package/dist/dotnet/ManagedTypeNames.js +6 -46
  595. package/dist/dotnet/ManagedTypeNesting.js +25 -0
  596. package/dist/dotnet/ManagedTypeReferences.js +94 -0
  597. package/dist/electron/ElectronFuseFailures.js +105 -0
  598. package/dist/electron/ElectronFusePath.js +4 -3
  599. package/dist/electron/ElectronFuseProvider.js +67 -92
  600. package/dist/electron/ElectronFuseReader.js +46 -30
  601. package/dist/evm/EvmoleFailures.js +1 -0
  602. package/dist/evm/EvmoleInterfaceProvider.js +13 -16
  603. package/dist/filesystem/OwnedRegularFile.js +116 -0
  604. package/dist/filesystem/OwnedStagedOutput.js +28 -11
  605. package/dist/filesystem/RegularFile.js +20 -8
  606. package/dist/filesystem/StableFileHash.js +56 -38
  607. package/dist/filesystem/callerPath.js +26 -0
  608. package/dist/filesystem/readFileHandleChunks.js +55 -5
  609. package/dist/filesystem/readStableFileBytes.js +85 -0
  610. package/dist/firmware/FirmwareCommand.js +13 -7
  611. package/dist/firmware/FirmwareFailures.js +56 -0
  612. package/dist/firmware/FirmwareFiles.js +128 -98
  613. package/dist/firmware/FirmwareProvider.js +120 -65
  614. package/dist/firmware/FirmwarePublication.js +26 -11
  615. package/dist/flutter/DartElf.js +27 -0
  616. package/dist/flutter/FlutterBuildProvider.js +44 -4
  617. package/dist/gdb/GdbSessionManager.js +202 -14
  618. package/dist/generatedPackageMetadata.js +1 -1
  619. package/dist/ghidra/GhidraAnalysisProfile.js +24 -10
  620. package/dist/ghidra/GhidraAnalysisSeeds.js +39 -55
  621. package/dist/ghidra/GhidraBridgeSources.js +12 -0
  622. package/dist/ghidra/GhidraClient.js +362 -148
  623. package/dist/ghidra/GhidraClientStartup.js +5 -3
  624. package/dist/ghidra/GhidraClientWire.js +5 -2
  625. package/dist/ghidra/GhidraDiagnostics.js +16 -5
  626. package/dist/ghidra/GhidraDoctor.js +45 -14
  627. package/dist/ghidra/GhidraDosSnapshot.js +83 -0
  628. package/dist/ghidra/GhidraExecutableHeader.js +54 -0
  629. package/dist/ghidra/GhidraFileArtifacts.js +93 -0
  630. package/dist/ghidra/GhidraFunctionValues.js +1 -0
  631. package/dist/ghidra/GhidraInstallation.js +143 -142
  632. package/dist/ghidra/GhidraInstallationPolicy.js +20 -79
  633. package/dist/ghidra/GhidraInstallationProperties.js +57 -0
  634. package/dist/ghidra/GhidraInventoryValues.js +22 -6
  635. package/dist/ghidra/GhidraJavaLaunch.js +11 -4
  636. package/dist/ghidra/GhidraJavaProbe.js +267 -0
  637. package/dist/ghidra/GhidraJavaProperties.js +9 -7
  638. package/dist/ghidra/GhidraLanguageCatalog.js +12 -7
  639. package/dist/ghidra/GhidraLauncher.js +128 -65
  640. package/dist/ghidra/GhidraLoadImageAttest.js +75 -78
  641. package/dist/ghidra/GhidraLoadImageValues.js +39 -29
  642. package/dist/ghidra/GhidraMipsProfile.js +13 -5
  643. package/dist/ghidra/GhidraNativeAotSnapshotOwner.js +221 -0
  644. package/dist/ghidra/GhidraPeProfile.js +88 -18
  645. package/dist/ghidra/GhidraProvider.js +219 -32
  646. package/dist/ghidra/GhidraProviderCapabilities.js +17 -4
  647. package/dist/ghidra/GhidraProviderClient.js +199 -239
  648. package/dist/ghidra/GhidraPspExtension.js +104 -34
  649. package/dist/ghidra/GhidraPspProfile.js +4 -1
  650. package/dist/ghidra/GhidraRawBinaryLanguage.js +13 -4
  651. package/dist/ghidra/GhidraReleasePolicy.js +93 -0
  652. package/dist/ghidra/GhidraRequestQueue.js +64 -40
  653. package/dist/ghidra/GhidraSessionError.js +152 -19
  654. package/dist/ghidra/GhidraSessionValues.js +13 -3
  655. package/dist/ghidra/GhidraSocketConnection.js +25 -11
  656. package/dist/ghidra/GhidraTargetSnapshot.js +67 -50
  657. package/dist/ghidra/GhidraTransport.js +86 -63
  658. package/dist/ghidra/extensions/GhidraExtensions.js +30 -45
  659. package/dist/go/GoBinaryProvider.js +89 -60
  660. package/dist/go/GoElfImage.js +3 -3
  661. package/dist/hopper/BridgeLauncher.js +43 -4
  662. package/dist/hopper/HopperAnalysisProfile.js +4 -2
  663. package/dist/hopper/HopperCleanup.js +14 -1
  664. package/dist/hopper/HopperClient.js +135 -63
  665. package/dist/hopper/HopperProvider.js +4 -7
  666. package/dist/hopper/HopperProviderCapabilities.js +2 -1
  667. package/dist/hopper/HopperRegexSearch.js +21 -60
  668. package/dist/ida/IdaBusyHealth.js +36 -2
  669. package/dist/ida/IdaMcpConnection.js +17 -11
  670. package/dist/ida/IdaNativeProtocol.js +1 -9
  671. package/dist/ida/IdaOperationRunner.js +8 -26
  672. package/dist/ida/IdaProtocolValues.js +2 -1
  673. package/dist/ida/IdaProvider.js +18 -2
  674. package/dist/ida/IdaSessionClient.js +54 -12
  675. package/dist/inspector/V8InspectorCaptureProjection.js +7 -0
  676. package/dist/inspector/V8InspectorProvider.js +2 -0
  677. package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +25 -4
  678. package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +4 -3
  679. package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +3 -2
  680. package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +7 -1
  681. package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +1 -1
  682. package/dist/javascript/recovery/RecoveryFiles.js +57 -8
  683. package/dist/jeb/JebMcpConnection.js +129 -70
  684. package/dist/jeb/JebMcpConnectionOwner.js +116 -0
  685. package/dist/jeb/JebMcpDeadline.js +46 -0
  686. package/dist/jeb/JebProvider.js +77 -51
  687. package/dist/kuna/KunaAddress.js +11 -0
  688. package/dist/kuna/KunaCommand.js +217 -0
  689. package/dist/kuna/KunaConfiguration.js +90 -0
  690. package/dist/kuna/KunaDoctor.js +198 -0
  691. package/dist/kuna/KunaInstallation.js +137 -0
  692. package/dist/kuna/KunaJson.js +23 -0
  693. package/dist/kuna/KunaJsonStream.js +433 -0
  694. package/dist/kuna/KunaLimits.js +5 -0
  695. package/dist/kuna/KunaProjectCache.js +804 -0
  696. package/dist/kuna/KunaProjectExport.js +202 -0
  697. package/dist/kuna/KunaProjectFiles.js +191 -0
  698. package/dist/kuna/KunaProjectReader.js +115 -0
  699. package/dist/kuna/KunaProvider.js +217 -0
  700. package/dist/kuna/KunaProviderCapabilities.js +102 -0
  701. package/dist/kuna/KunaQueryErrors.js +12 -0
  702. package/dist/kuna/KunaQueryWork.js +113 -0
  703. package/dist/kuna/KunaReferenceFiles.js +258 -0
  704. package/dist/kuna/KunaReferenceQueries.js +211 -0
  705. package/dist/kuna/KunaRelease.js +10 -0
  706. package/dist/kuna/KunaRunSlots.js +56 -0
  707. package/dist/kuna/KunaSessionClient.js +1162 -0
  708. package/dist/kuna/KunaStringInventory.js +145 -0
  709. package/dist/kuna/KunaStringQueries.js +133 -0
  710. package/dist/kuna/KunaTargetCommands.js +205 -0
  711. package/dist/kuna/KunaUnavailable.js +11 -0
  712. package/dist/main/processShutdown.js +17 -0
  713. package/dist/main/transport.js +21 -1
  714. package/dist/main.js +2 -12
  715. package/dist/mcp/AnalysisProvider-BABWbLoM.js +38 -0
  716. package/dist/mcp/{AnalysisSnapshotFiles-BAbiJQOc.js → AnalysisSnapshotFiles-BXz0c37-.js} +39 -28
  717. package/dist/mcp/{ProcessOwnership-Bl_3ejLe.js → ArtifactFileOperation-64cQKI7B.js} +274 -72
  718. package/dist/mcp/{ArtifactProvider-DViCU_rn.js → ArtifactProvider-Dx6pmil1.js} +371 -354
  719. package/dist/mcp/ArtifactProviderMetadata-UCJr2oZW.js +167 -0
  720. package/dist/mcp/{ArtifactReader-OyM03Gjn.js → ArtifactReader-BrnwNaKY.js} +29 -6
  721. package/dist/mcp/ArtifactResourceScope-zi3Dkqzy.js +175 -0
  722. package/dist/mcp/{AsarHeader-WsPgoooH.js → AsarHeader-B_IbppTz.js} +1 -1
  723. package/dist/mcp/{BinarySessionStatus-B4P9gf-S.js → BinarySessionStatus-CZ9nnXMt.js} +5 -4
  724. package/dist/mcp/{BinaryTargetResolver-BMaE_0H1.js → BinaryTargetResolver-BUncASDP.js} +146 -215
  725. package/dist/mcp/BoundedFileBytes-DYt5q9G2.js +43 -0
  726. package/dist/mcp/{CdpCaptureDocuments-HDiF2O7k.js → CdpCaptureDocuments-Y2uFcBpl.js} +194 -145
  727. package/dist/mcp/{CdpCaptureValues-M-j6CIh1.js → CdpCaptureValues-tNIg-gQK.js} +12 -5
  728. package/dist/mcp/{CdpConnection-BpDfz4MK.js → CdpEndpoint-BrhMhpSi.js} +352 -281
  729. package/dist/mcp/{CdpOptionalCommand-BPjRD9Kz.js → CdpOptionalCommand-PZZhlqxv.js} +2 -2
  730. package/dist/mcp/CdpTargetSession-BmmDC3XO.js +290 -0
  731. package/dist/mcp/{DirectAnalysis-DrafbXke.js → DirectAnalysis-B9KuCHTG.js} +29 -21
  732. package/dist/mcp/{DirectAnalysisStatus-CjjeDLzW.js → DirectAnalysisStatus-BgzopkIt.js} +7 -7
  733. package/dist/mcp/{ElectronFileScope-BPG_YoyU.js → ElectronFileScope-FXtK0d6I.js} +1 -1
  734. package/dist/mcp/ElectronFuseFailures-uZ_wOV6T.js +610 -0
  735. package/dist/mcp/MachoLoadCommandReader-C2VGgHA3.js +330 -0
  736. package/dist/mcp/{ManagedStaticProvider-BthZbKyZ.js → ManagedStaticProvider-CZuoPme2.js} +429 -131
  737. package/dist/mcp/{NativeMacOSProvider-Bh79k8dI.js → NativeMacOSProvider-CMguKrvN.js} +1376 -748
  738. package/dist/mcp/{NativeMacOSProviderMetadata-N1lPOaY_.js → NativeMacOSProviderMetadata-B_RH4KXF.js} +97 -7
  739. package/dist/mcp/{ProviderDeadline-DskQ94YD.js → OwnedCommand-BW1jBSt9.js} +436 -127
  740. package/dist/mcp/ProcedureAddressResolution-H6Qwpb_Y.js +59 -0
  741. package/dist/mcp/{WorkflowEvidence-umWrB_wm.js → WorkflowEvidence-CO4C7ALz.js} +16 -9
  742. package/dist/mcp/analysisErrorCleanup-Q344SnTO.js +34 -0
  743. package/dist/mcp/analysisErrorCore-BIEP7tvF.js +509 -0
  744. package/dist/mcp/{analysisErrorProjection-BN0EPM-3.js → analysisErrorProjection-B8teQwwD.js} +80 -30
  745. package/dist/mcp/{artifactToolContracts-Di4qZlEt.js → artifactToolContracts-C9dRDo-D.js} +6 -4
  746. package/dist/mcp/{browserObservation-C0s4i8UI.js → browserObservation-DUraZs62.js} +272 -107
  747. package/dist/mcp/{browserObservationError-CyLugqX4.js → browserObservationError-C5okJ5el.js} +27 -4
  748. package/dist/mcp/{browserObservationSchemas-tgqjH7aA.js → browserObservationSchemas-DwGGxBpu.js} +3 -3
  749. package/dist/mcp/{browserScenario-CAQ8Fns9.js → browserScenario-BRUz7yN0.js} +844 -358
  750. package/dist/mcp/{browserScenarioCapture-CTNFN-FI.js → browserScenarioCapture-CiMAsMx8.js} +127 -11
  751. package/dist/mcp/{InterfaceBuilderDecodeBudget-5F2AkxJT.js → callerPath-CpPnMZyN.js} +91 -65
  752. package/dist/mcp/{electronActiveObservation-lDvQTMR0.js → electronActiveObservation-DV0Ffy9X.js} +1 -0
  753. package/dist/mcp/electronFuses-D5SS7XXw.js +367 -0
  754. package/dist/mcp/{electronObservation-i7LcILQ-.js → electronObservation-DsN-NqY1.js} +134 -75
  755. package/dist/mcp/{electronObservation-DFOFEood.js → electronObservation-wOYWwqgF.js} +3 -3
  756. package/dist/mcp/{electronScenario-nCzE6IfJ.js → electronScenario-CYrt2zBK.js} +395 -135
  757. package/dist/mcp/{emptyArraySchema-tL6Qymyd.js → emptyArraySchema-C0o2Sxwp.js} +2 -2
  758. package/dist/mcp/{enhancedInputs-DgdEnzHy.js → enhancedInputs-6CCgB3VB.js} +1 -1
  759. package/dist/mcp/{javascriptRuntimeObservation-61NhCf7H.js → javascriptRuntimeObservation-BVbhkO2-.js} +12 -9
  760. package/dist/mcp/{javascriptRuntimeObservation-PIUoLfX6.js → javascriptRuntimeObservation-Cu0Yedqq.js} +2 -2
  761. package/dist/mcp/{lipo-Bnkoq_6W.js → lipo-DSTgUqL1.js} +11 -118
  762. package/dist/mcp/{logger-BQY5ulYv.js → logger-BGdGHadX.js} +2 -2
  763. package/dist/mcp/machoContainer-CMSxUBlK.js +605 -0
  764. package/dist/mcp/{main-kBXHZ8S5.js → main-Cx-Z7m_n.js} +16788 -5902
  765. package/dist/mcp/main.js +1 -1
  766. package/dist/mcp/{managedToolContracts-CK--I_s7.js → managedToolContracts-CSlbKJP-.js} +3 -3
  767. package/dist/mcp/{nativeValueTrace-DR9UE62L.js → nativeValueTrace-BEZbDieM.js} +2630 -2468
  768. package/dist/mcp/{officialToolContracts-B67NJ2tC.js → officialToolContracts-CauCcSsc.js} +74 -55
  769. package/dist/mcp/peMachine-aP1iYnHq.js +95 -0
  770. package/dist/mcp/propertyListKeys-BfCo0k4w.js +356 -0
  771. package/dist/mcp/providerCleanupError-DIRHxzWo.js +125 -0
  772. package/dist/mcp/{providerOperationHealth-CTYa3iLf.js → providerOperationHealth-9DRSGM8N.js} +24 -1
  773. package/dist/mcp/{scanCanonical-CRXSpule.js → scanCanonical-CF3ATd1V.js} +269 -463
  774. package/dist/mcp/{serverIdentity-Cio4iFV3.js → serverIdentity-BK0Ejd_Y.js} +262 -83
  775. package/dist/mcp/{sourceMapEnvelope-C0uJlrOh.js → sourceMapEnvelope-DAaRUIGj.js} +4 -4
  776. package/dist/mcp/{toolContracts-BW05wpcr.js → toolContracts-BPoHQdlC.js} +541 -327
  777. package/dist/mcp/{toolOutputSchemaGroups-ColvNZ1r.js → toolOutputSchemaGroups-MJ_f-PMK.js} +2551 -2354
  778. package/dist/mcp/{webContentArtifact-Dzjc1z-R.js → webContentArtifact-DfGkgDcI.js} +2 -17
  779. package/dist/mcp/{webRuntime-K__NYzXm.js → webRuntime-ccyhkRru.js} +2 -2
  780. package/dist/mcp/{webSourceLocation-DbMAT2J9.js → webSourceLocation-DKIum0vJ.js} +6451 -4414
  781. package/dist/mcpDoctor.js +4 -2
  782. package/dist/mcpStartupPolicy.js +18 -3
  783. package/dist/native/AppleDispatchMetadata.js +76 -27
  784. package/dist/native/AppleMachoFixups.js +20 -10
  785. package/dist/native/AppleObjcCategories.js +12 -1
  786. package/dist/native/AppleObjcDispatchFacets.js +21 -12
  787. package/dist/native/AppleObjcProperties.js +61 -17
  788. package/dist/native/AppleObjcProtocols.js +25 -7
  789. package/dist/native/AppleSwiftVtables.js +2 -0
  790. package/dist/native/CommandRunner.js +13 -9
  791. package/dist/native/LldbCallTracer.js +232 -178
  792. package/dist/native/LldbReadbackFiles.js +70 -0
  793. package/dist/native/LldbRetainedObservations.js +28 -56
  794. package/dist/native/NativeCallObservation.js +53 -52
  795. package/dist/native/NativeCallTarget.js +95 -0
  796. package/dist/native/NativeMacOSProvider.js +240 -171
  797. package/dist/native/NativeMachoInspection.js +21 -7
  798. package/dist/native/NativePlistSource.js +179 -0
  799. package/dist/native/NativeUiCleanupError.js +30 -0
  800. package/dist/native/NativeUiHelperRuntime.js +48 -35
  801. package/dist/native/NativeUiObservation.js +67 -45
  802. package/dist/native/SignatureTargetBinding.js +72 -53
  803. package/dist/native/parsers/demangle.js +16 -12
  804. package/dist/native/parsers/machoUuid.js +4 -4
  805. package/dist/native/parsers/otool.js +57 -17
  806. package/dist/native/parsers/plist.js +40 -25
  807. package/dist/native/pe/PeResourceLayout.js +22 -7
  808. package/dist/native/pe/PeResourceParser.js +10 -9
  809. package/dist/native/pe/PeResourcesProvider.js +63 -16
  810. package/dist/native/pwndbg/CoreFileMappingAuthority.js +51 -0
  811. package/dist/native/pwndbg/PwndbgCoreContext.js +26 -15
  812. package/dist/native/pwntools/PwntoolsDecoder.js +116 -53
  813. package/dist/native/pwntools/PwntoolsFailures.js +17 -3
  814. package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +11 -1
  815. package/dist/objdump/ObjdumpCommand.js +5 -2
  816. package/dist/pcap/PcapOutput.js +38 -2
  817. package/dist/pcap/PcapProvider.js +45 -15
  818. package/dist/pcap/PcapSnapshot.js +24 -4
  819. package/dist/process/ArtifactAnalysisResources.js +145 -52
  820. package/dist/process/BoundedFileBytes.js +8 -3
  821. package/dist/process/CurrentEntrypointPath.js +3 -1
  822. package/dist/process/DarwinProcessRunTokenReader.js +174 -63
  823. package/dist/process/DetachedPgpSignature.js +57 -0
  824. package/dist/process/ExecFileOutput.js +14 -11
  825. package/dist/{hopper/HopperTargetLease.js → process/HopperLease.js} +10 -0
  826. package/dist/process/LinuxResourceLimits.js +4 -24
  827. package/dist/process/OwnedCommand.js +109 -14
  828. package/dist/process/ProviderProcess.js +129 -10
  829. package/dist/process/RegexMatcher.js +96 -0
  830. package/dist/process/SharedStartupAttempt.js +59 -0
  831. package/dist/process/WindowsAuthority.js +1 -1
  832. package/dist/process/capture/FilesystemSnapshot.js +3 -2
  833. package/dist/process/capture/ProcessCaptureError.js +55 -17
  834. package/dist/process/capture/ProcessCaptureLifecycle.js +17 -20
  835. package/dist/process/capture/ProcessCaptureProgress.js +5 -3
  836. package/dist/process/capture/ProcessHarness.js +17 -3
  837. package/dist/process/snapshotEnvironment.js +8 -8
  838. package/dist/{application/binary → providers}/AnalysisClientCleanup.js +3 -3
  839. package/dist/providers/AnalysisClientCreation.js +193 -0
  840. package/dist/providers/AnalysisClientFailure.js +191 -0
  841. package/dist/providers/DeferredAnalysisClient.js +48 -0
  842. package/dist/providers/OwnedCommandCleanup.js +65 -0
  843. package/dist/providers/ProviderInspectionScope.js +10 -0
  844. package/dist/recordedCatalogDigests.js +2 -0
  845. package/dist/reference/ReferenceSourceReader.js +64 -0
  846. package/dist/reference/ReferenceSourceReaderEntries.js +12 -3
  847. package/dist/reference/ReferenceSourceReaderFile.js +2 -1
  848. package/dist/rizin/RizinCommand.js +2 -2
  849. package/dist/rizin/RizinDebugSessionManager.js +249 -210
  850. package/dist/rust/RustBinaryProvider.js +55 -23
  851. package/dist/server/EvidenceMcpServer.js +2 -2
  852. package/dist/server/contractToolHandler.js +17 -11
  853. package/dist/server/createServer.js +27 -8
  854. package/dist/server/promptCompletion.js +24 -22
  855. package/dist/server/registerArtifactComparisonTool.js +13 -2
  856. package/dist/server/registerBrowserScenarioTool.js +7 -5
  857. package/dist/server/registerBrowserTools.js +2 -4
  858. package/dist/server/registerCutterTools.js +2 -3
  859. package/dist/server/registerElectronTools.js +2 -13
  860. package/dist/server/registerFridaTools.js +8 -12
  861. package/dist/server/registerInvestigationTools.js +20 -20
  862. package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -4
  863. package/dist/server/registerManagedWorkflowTools/evidence.js +14 -7
  864. package/dist/server/registerProcessComparisonTool.js +3 -0
  865. package/dist/server/registerSessionStatusTool.js +13 -6
  866. package/dist/server/registerSessionTools.js +16 -29
  867. package/dist/server/runDerivedOperation.js +2 -0
  868. package/dist/signals/SigrokRecordingProvider.js +13 -6
  869. package/dist/sqlite/SqliteDatabaseFailures.js +25 -12
  870. package/dist/sqlite/SqliteDatabaseInspection.js +27 -12
  871. package/dist/sqlite/SqliteDatabaseSnapshot.js +58 -32
  872. package/dist/sqlite/SqliteDatabaseWorkerExecution.js +18 -3
  873. package/dist/wasm/WabtArtifactProvider.js +64 -42
  874. package/dist/wasm/WabtFailures.js +19 -1
  875. package/dist/wasm/WabtRuntime.js +58 -0
  876. package/dist/wasm/WasmGlueAdapter.js +20 -7
  877. package/dist/windows/WindowsNativeLoader.js +16 -2
  878. package/dist/windows/WindowsPrivateRuntime.js +44 -1
  879. package/licenses/npm-dependencies.txt +146 -1
  880. package/licenses/npm-runtime-notices.txt +175 -1
  881. package/native/windows/README.md +44 -7
  882. package/native/windows/build/manifest.json +2 -2
  883. package/native/windows/build/rea-windows-x64.node +0 -0
  884. package/package.json +11 -3
  885. package/scripts/electron-active-hook-boundaries.cjs +15 -2
  886. package/scripts/electron-active-hook.cjs +408 -46
  887. package/scripts/hopper-demo-x11.py +12 -10
  888. package/scripts/rea.mjs +62 -15
  889. package/skills/reverse-engineer-anything/SKILL.md +21 -7
  890. package/skills/reverse-engineer-anything/references/android-applications.md +3 -1
  891. package/skills/reverse-engineer-anything/references/javascript-applications.md +44 -1
  892. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +30 -10
  893. package/dist/cli-runtime/ArtifactResourceScope-DQWTcUwE.js +0 -114
  894. package/dist/cli-runtime/ClientConfigPath-c6jr6INc.js +0 -36
  895. package/dist/cli-runtime/IdaConfiguration-CtGP7EKo.js +0 -1094
  896. package/dist/cli-runtime/JebMcpEndpoint-DUytrn5G.js +0 -428
  897. package/dist/cli-runtime/MacHopperPaths-CwL5lYPX.js +0 -434
  898. package/dist/cli-runtime/OwnedCommand-Cj9GhmPR.js +0 -112
  899. package/dist/cli-runtime/RegularFile-B_6KPCNQ.js +0 -139
  900. package/dist/cli-runtime/RegularFileRead-DVlC5faM.js +0 -125
  901. package/dist/cli-runtime/analysisErrorPresentation-DGt7TdsH.js +0 -497
  902. package/dist/cli-runtime/application__javascript__ElectronObservationService-DEsR8KDN.js +0 -63
  903. package/dist/cli-runtime/artifactOperationError-B7n03FbD.js +0 -27
  904. package/dist/cli-runtime/browserObservationError-Dx6xRTjb.js +0 -40
  905. package/dist/cli-runtime/cliResultOutput-DsRMI8CJ.js +0 -780
  906. package/dist/cli-runtime/mcpStartupPolicy-CVVSOmRc.js +0 -21
  907. package/dist/cli-runtime/propertyListKeys-G8e74YWb.js +0 -248
  908. package/dist/cli-runtime/providerAdapterError-DAjhICdr.js +0 -25
  909. package/dist/cli-runtime/readFileHandleChunks-dp60iZ6v.js +0 -38
  910. package/dist/hopper/HopperRegexWorker.js +0 -27
  911. package/dist/mcp/ArtifactProviderMetadata-b7pOK5_t.js +0 -76
  912. package/dist/mcp/ArtifactResourceScope-P3tq5z8Z.js +0 -162
  913. package/dist/mcp/BoundedFileBytes-DuczXiQZ.js +0 -68
  914. package/dist/mcp/CdpTargetSession-BsPoKhEU.js +0 -86
  915. package/dist/mcp/ProcedureAddressResolution-CQpuwm1h.js +0 -19
  916. package/dist/mcp/analysisErrorCore-DXRTvF_m.js +0 -235
  917. package/dist/mcp/artifactOperationError-CkHMMaf7.js +0 -27
  918. package/dist/mcp/digests-BFoWUT_-.js +0 -223
  919. package/dist/mcp/propertyListKeys-DD25WsjI.js +0 -553
  920. package/dist/mcp/providerAdapterError-sDxToNal.js +0 -25
  921. package/dist/mcp/unicodeCodePointOrder-BezCbTpg.js +0 -26
@@ -1,37 +1,188 @@
1
1
  import { __esmMin } from "./rolldown-runtime-DXoylpqc.js";
2
- import { analysisInputErrorFromIssues, compareUnicodeCodePoints, err, init_binaryTargetTypes, init_inputIssueProjection, init_machoCpuIdentity, init_objcSwiftMetadata, init_result, init_swiftSymbolClassification, init_unicodeCodePointOrder, isMachOFormat, isSwiftMangledSymbolName, machoCpuSubtypeBase, nativeDispatchMetadataResultSchema, objcSwiftMetadataSchema, ok } from "./reconstructionObligationLedgerSchemas-Bao0xMr-.js";
3
- import { NATIVE_TOOL_CONTRACTS, init_nativeToolContracts } from "./cutterToolContracts-TZH9EHr5.js";
4
- import { AnalysisAccessDeniedError, AnalysisArtifactChangedError, AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisError, AnalysisInputError, AnalysisOutputError, AnalysisResourceConstraintError, AnalysisTimeoutError, BinaryTargetError, init_analysisErrorBase, init_analysisErrorCore, init_configurationErrors, init_jsonValue, jsonValueSchema } from "./errorSchemas-CTRmvMl3.js";
5
- import { ArtifactReaderFailure, init_ArtifactReader } from "./ArtifactReader-BXkffc1D.js";
6
- import { OwnedFileHandle, init_OwnedFileHandle, init_RegularFile, openRegularFile } from "./RegularFile-B_6KPCNQ.js";
7
- import { createAnalysisExecution, init_AnalysisProvider } from "./AnalysisProvider-D0Us2OTk.js";
8
- import { ArtifactResourceScope, init_ArtifactResourceScope } from "./ArtifactResourceScope-DQWTcUwE.js";
9
- import { ProviderAdapterError, init_providerAdapterError } from "./providerAdapterError-DAjhICdr.js";
10
- import { EvidenceIntegrityError, init_evidenceErrors } from "./analysisErrorPresentation-DGt7TdsH.js";
11
- import { init_analysisErrorProjection, projectAnalysisError } from "./cliResultOutput-DsRMI8CJ.js";
12
- import { analysisErrorWithCleanupFailure, init_analysisErrorCleanup } from "./analysisErrorCleanup-Do6YeeoD.js";
13
- import { ProviderCleanupError, init_providerCleanupError } from "./providerCleanupError-Ceq8f0wK.js";
14
- import { ProviderProcessSupervisor, init_ProviderProcess, init_snapshotEnvironment, snapshotEnvironment, spawnOwnedProviderProcess } from "./snapshotEnvironment-D_tWyOub.js";
15
- import { SWIFTC_INTERRUPT, cleanupOwnedProcessGroup, init_DarwinProcessRunTokenReader, init_ProcessOwnership, init_ProcessOwnershipObservation, observeProcessStartIdentity, signalProcessWithStartIdentity } from "./ProcessOwnership-DXC5-UWt.js";
16
- import { execFileOutput, init_ExecFileOutput } from "./ExecFileOutput-BEQs-lDD.js";
2
+ import { analysisInputErrorFromIssues, compareUnicodeCodePoints, createPlistNumberProjection, err, incompletePlistNumberLimitation, init_binaryTargetTypes, init_inputIssueProjection, init_machoCpuIdentity, init_objcSwiftMetadata, init_plistNumbers, init_result, init_swiftSymbolClassification, init_unicodeCodePointOrder, isAppleDispatchMetadataTarget, isMachOFormat, isSwiftMangledSymbolName, machoCpuSubtypeBase, nativeDispatchMetadataResultSchema, objcSwiftMetadataSchema, ok } from "./reconstructionObligationLedgerSchemas-Bi6sect1.js";
3
+ import { NATIVE_TOOL_CONTRACTS, init_nativeToolContracts } from "./cutterToolContracts-BQtG_Nzo.js";
4
+ import { AnalysisAccessDeniedError, AnalysisArtifactChangedError, AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisError, AnalysisInputError, AnalysisOutputError, AnalysisResourceConstraintError, AnalysisTimeoutError, BinaryTargetError, init_analysisErrorBase, init_analysisErrorCore, init_configurationErrors, init_jsonValue, jsonValueSchema, resolvedAnalysisError } from "./errorSchemas-Ixz_q7qt.js";
5
+ import { OwnedFileHandle, RegularFileCancelled, RegularFileChangedError, RegularFileCleanupFailure, RegularFileOperationCancelled, assertRegularFileActive, init_OwnedFileHandle, init_OwnedRegularFile, init_RegularFile, regularFileCancellation } from "./OwnedRegularFile-D1f5nUCx.js";
6
+ import { ArtifactReaderFailure, init_ArtifactReader } from "./ArtifactReader-DMwm42bk.js";
7
+ import { AnalysisCleanupLease, AnalysisCleanupLeaseGroup, init_AnalysisCleanupLease } from "./AnalysisCleanupLease-CWfTGYKd.js";
8
+ import { ArtifactFileCleanupFailure, artifactFileCancellationCause, artifactFilePrimaryFailure, bindArtifactFileCleanup, init_ArtifactFileOperation, withArtifactRegularFile } from "./ArtifactFileOperation-Dg4BcoEM.js";
9
+ import { createAnalysisExecution, init_AnalysisProvider } from "./AnalysisProvider-BGrYaMVo.js";
10
+ import { ArtifactResourceRetryFailure, ArtifactResourceScope, init_ArtifactResourceScope } from "./ArtifactResourceScope-CokZGcII.js";
11
+ import { EvidenceIntegrityError, ProviderAdapterError, init_analysisErrorProjection, init_evidenceErrors, init_providerAdapterError, projectAnalysisError } from "./cliResultOutput-10sd6xGx.js";
12
+ import { analysisErrorWithCleanupFailure, init_analysisErrorCleanup } from "./analysisErrorCleanup-COdAmDsb.js";
13
+ import { ProviderCleanupError, init_providerCleanupError } from "./providerCleanupError-BhsJyAhk.js";
14
+ import { SWIFTC_INTERRUPT, init_DarwinProcessRunTokenReader, init_ProcessOwnershipObservation, observeProcessStartIdentity, signalProcessWithStartIdentity } from "./ProcessOwnershipObservation-C006iCtZ.js";
15
+ import { ExecFileOutputCancelledError, execFileOutput, init_ExecFileOutput } from "./ExecFileOutput-D6KLYTve.js";
17
16
  import { init_safeJson, safeParseJson } from "./safeJson-DKKACtdy.js";
18
- import { ProviderStartupDeadline, init_ProviderDeadline, waitForAbortableDelay } from "./ProviderDeadline-8m2pFRDc.js";
19
- import { PrivateRuntimeRoot, init_PrivateRuntimeRoot } from "./PrivateRuntimeRoot-DAy0PiBM.js";
20
- import { demangleSwiftSchema, init_nativeCallObservation, init_nativeInspection, init_nativeUiObservation, inspectMachoSchema, inspectPlistSchema, inspectSignatureSchema, listArchitecturesSchema, nativeCallEventSchema, nativeCallObservationInputSchema, nativeCallObservationResultSchema, nativeCodeLocationSchema, nativeUiObservationInputSchema, nativeUiResultSchema, nativeUiScenarioInputSchema, nativeUiSnapshotSchema } from "./toolOutputSchemaGroups-DRiYs1je.js";
21
- import { init_BoundedFileBytes, readBoundedFileBytes } from "./BoundedFileBytes-BU30odTm.js";
22
- import { init_machoContainer, readFatSliceDeclarations, validateFatSlice } from "./machoContainer-C8BIkkq3.js";
23
- import { init_plistValue, init_propertyListKeys, omitPrototypeKeys, omittedPrototypeKeysLimitation, parseXmlPropertyList, projectPlistValue } from "./propertyListKeys-G8e74YWb.js";
24
- import { init_toolContracts, toolContract } from "./toolContracts-D2FOG_Nb.js";
25
- import { NATIVE_COMMAND_OUTPUT_BUDGET_BYTES, NATIVE_COMMAND_TIMEOUT_MS, NativeCommandFailure, XcrunCommandRunner, failureCapture, init_CommandRunner, init_lipo, parseLipoOutput, resolveXcrunTool } from "./lipo-DSWP6fv-.js";
26
- import { NATIVE_MACOS_PROVIDER_IDENTITY, init_NativeMacOSProviderMetadata, nativeMacOSCapabilities } from "./binary-BVOr2mgE.js";
17
+ import { ProviderProcessSupervisor, init_ProviderProcess, spawnOwnedProviderProcess } from "./ProviderProcess-D87A7ctp.js";
18
+ import { cleanupOwnedProcessGroup, init_ProcessOwnership } from "./ProcessOwnership-CtrNr6ee.js";
19
+ import { ProviderStartupDeadline, init_ProviderDeadline, waitForAbortableDelay } from "./ProviderDeadline-rSuH4Pm8.js";
20
+ import { init_snapshotEnvironment, snapshotEnvironment } from "./snapshotEnvironment-Yvx5qwsl.js";
21
+ import { PrivateRuntimeRoot, init_PrivateRuntimeRoot } from "./PrivateRuntimeRoot-Cd23u6jd.js";
22
+ import { demangleSwiftSchema, init_nativeCallObservation, init_nativeInspection, init_nativeUiObservation, init_plistValue, inspectMachoSchema, inspectPlistSchema, inspectSignatureSchema, listArchitecturesSchema, nativeCallEventSchema, nativeCallObservationInputSchema, nativeCallObservationResultSchema, nativeCapturedOutputSchema, nativeCodeLocationSchema, nativeUiObservationInputSchema, nativeUiResultSchema, nativeUiScenarioInputSchema, nativeUiSnapshotSchema, negativeZeroReal, negativeZeroRealLimitation, nonFiniteRealLimitation, projectPlistValue, unknownDateLimitation, unknownRealLimitation } from "./toolOutputSchemaGroups-BqdSzySu.js";
23
+ import { init_BoundedFileBytes, readBoundedFileBytes } from "./BoundedFileBytes-DRtiQNAQ.js";
24
+ import { hashStableFile, init_StableFileHash, stableFileHashCause } from "./StableFileHash-Ame_h3lY.js";
25
+ import { init_machoContainer, readFatSliceDeclarations, validateFatSlice } from "./machoContainer-Cy98bkFm.js";
26
+ import { init_propertyListKeys, omitPrototypeKeys, omittedPrototypeKeysLimitation, parseXmlPropertyList } from "./propertyListKeys-D5dSASEy.js";
27
+ import { init_toolContracts, toolContract } from "./toolContracts-CJzEyZ38.js";
28
+ import { NATIVE_COMMAND_OUTPUT_BUDGET_BYTES, NATIVE_COMMAND_TIMEOUT_MS, NativeCommandFailure, XcrunCommandRunner, failureCapture, init_CommandRunner, init_lipo, parseLipoOutput, resolveXcrunTool } from "./lipo-DPQ6qurH.js";
29
+ import { NATIVE_MACOS_PROVIDER_IDENTITY, init_NativeMacOSProviderMetadata, nativeMacOSCapabilities } from "./binary-CWVNJhAC.js";
27
30
  import { z } from "zod";
28
31
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
29
32
  import { createHash, randomUUID } from "node:crypto";
30
- import { lstat, mkdir, mkdtemp, open, readFile, realpath, rm, stat, symlink, writeFile } from "node:fs/promises";
31
33
  import { constants } from "node:fs";
32
- import { fileURLToPath } from "node:url";
33
34
  import { tmpdir } from "node:os";
35
+ import { lstat, mkdir, mkdtemp, open, realpath, rm, stat, symlink, writeFile } from "node:fs/promises";
36
+ import { fileURLToPath } from "node:url";
34
37
 
38
+ //#region dist/native/NativePlistSource.js
39
+ var resolveNativePlistSelection, macOSBundleRoot, unreadablePlist, nativePlistFailure, readPlistFile, requireRegularPlist, PLIST_MARKUP_PROBE_BYTES, plistSourceFormat;
40
+ function init_NativePlistSource() {
41
+ return (init_NativePlistSource = __esmMin((() => {
42
+ init_analysisErrorCore();
43
+ init_configurationErrors();
44
+ init_providerAdapterError();
45
+ init_providerCleanupError();
46
+ init_analysisErrorProjection();
47
+ init_result();
48
+ init_ArtifactReader();
49
+ init_ArtifactFileOperation();
50
+ init_NativeMacOSProviderMetadata();
51
+ resolveNativePlistSelection = async (target, requested) => {
52
+ try {
53
+ if (requested !== undefined && isAbsolute(requested)) return ok({
54
+ path: resolve(requested),
55
+ origin: "selected"
56
+ });
57
+ if (requested === undefined && target.kind === "artifact" && target.format === "plist") return ok({
58
+ path: target.path,
59
+ origin: "selected"
60
+ });
61
+ const source = target.sourcePath ?? target.path;
62
+ const sourceMetadata = await stat(source);
63
+ const root = sourceMetadata.isDirectory() ? source : macOSBundleRoot(target.path) ?? dirname(target.path);
64
+ if (requested !== undefined) return ok({
65
+ path: resolve(root, requested),
66
+ origin: "selected"
67
+ });
68
+ return ok({
69
+ path: target.bundleInfoPlist ?? resolve(root, "Contents/Info.plist"),
70
+ origin: "default"
71
+ });
72
+ } catch (cause) {
73
+ return err(new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", { cause }));
74
+ }
75
+ };
76
+ macOSBundleRoot = (path) => {
77
+ const programs = dirname(path);
78
+ const contents = dirname(programs);
79
+ return basename(programs) === "MacOS" && basename(contents) === "Contents" ? dirname(contents) : undefined;
80
+ };
81
+ unreadablePlist = (selection, reason, options) => {
82
+ const { path } = selection;
83
+ const sentence = reason.endsWith(".") ? reason : `${reason}.`;
84
+ const missingDefault = `The target has no readable default plist at ${path}: ${sentence} Select another plist in the target with the path input (CLI: --relative-path).`;
85
+ return selection.origin === "default" ? new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", missingDefault, {
86
+ ...options,
87
+ userMessage: missingDefault
88
+ }) : new AnalysisInputError("inspect_plist", options, [{
89
+ path: ["path"],
90
+ reason: "invalid_value",
91
+ message: `Cannot inspect ${path}: ${sentence}`
92
+ }]);
93
+ };
94
+ nativePlistFailure = (cause, selection, capturedOutput) => {
95
+ if (cause instanceof ArtifactReaderFailure && cause.cleanup !== undefined) {
96
+ const physical = cause instanceof ArtifactFileCleanupFailure ? cause.fileCleanupFailure : undefined;
97
+ const previous = physical?.outcome.kind === "failed" ? nativePlistFailure(artifactFilePrimaryFailure(cause), selection, capturedOutput) : physical?.completionCancellation === undefined ? undefined : new AnalysisCancelledError("inspect_plist", {
98
+ cause: physical.completionCancellation.reason,
99
+ capturedOutput
100
+ });
101
+ const previousProjection = previous === undefined ? null : projectAnalysisError(previous);
102
+ const previousDetails = previousProjection?.details;
103
+ const { captured_output: _capture, ...reasonDetails } = previousDetails ?? {};
104
+ const previousError = previousProjection === null ? null : {
105
+ ...previousProjection,
106
+ ...previousDetails === undefined ? {} : { details: reasonDetails }
107
+ };
108
+ const failure = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, cause.cleanup.resources, {
109
+ reason: cause.cleanup.reason,
110
+ previous_error: previousError
111
+ }, {
112
+ operation: "inspect_plist",
113
+ cause,
114
+ cleanupPrimary: previous,
115
+ capturedOutput
116
+ });
117
+ bindArtifactFileCleanup(cause, failure);
118
+ return failure;
119
+ }
120
+ if (cause instanceof ArtifactReaderFailure && cause.reason === "cancelled") return new AnalysisCancelledError("inspect_plist", {
121
+ cause: artifactFileCancellationCause(cause),
122
+ capturedOutput
123
+ });
124
+ if (cause instanceof ArtifactReaderFailure && cause.reason === "unavailable") return new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", cause.message, {
125
+ cause,
126
+ capturedOutput
127
+ });
128
+ if (selection === undefined) return new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", {
129
+ cause,
130
+ capturedOutput,
131
+ diagnostics: {
132
+ phase: "plist-scope",
133
+ reason: cause instanceof Error ? cause.message : String(cause)
134
+ }
135
+ });
136
+ const { path } = selection;
137
+ const code = cause instanceof Error && "code" in cause ? cause.code : undefined;
138
+ if (code === "ENOENT" || code === "ENOTDIR") return unreadablePlist(selection, "no file exists there", {
139
+ cause,
140
+ capturedOutput
141
+ });
142
+ if (code === "EISDIR" || code === "ENOTFILE") return unreadablePlist(selection, "it is not a regular file", {
143
+ cause,
144
+ capturedOutput
145
+ });
146
+ if (code === "EACCES" || code === "EPERM") return new BinaryTargetError(path, `permission denied while reading plist (${code})`, {
147
+ cause,
148
+ capturedOutput
149
+ });
150
+ return new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", {
151
+ cause,
152
+ capturedOutput,
153
+ diagnostics: {
154
+ path,
155
+ phase: "plist-file",
156
+ reason: cause instanceof Error ? cause.message : String(cause)
157
+ }
158
+ });
159
+ };
160
+ readPlistFile = async (input, read) => {
161
+ try {
162
+ return ok(await withArtifactRegularFile(input.selection.path, input.resources, input.signal, read, "follow"));
163
+ } catch (cause) {
164
+ return err(nativePlistFailure(cause, input.selection, input.capturedOutput));
165
+ }
166
+ };
167
+ requireRegularPlist = (input) => readPlistFile(input, async () => null);
168
+ PLIST_MARKUP_PROBE_BYTES = 4096;
169
+ plistSourceFormat = async (description, input) => {
170
+ if (/binary property list/iu.test(description)) return ok("binary");
171
+ if (/\bXML\b/iu.test(description)) return ok("xml");
172
+ if (/\bJSON\b/iu.test(description)) return ok("json");
173
+ if (!/\btext\b/iu.test(description)) return ok("unknown");
174
+ return readPlistFile(input, async (file) => {
175
+ const head = Buffer.alloc(PLIST_MARKUP_PROBE_BYTES);
176
+ const { bytesRead } = await file.read(head, 0, head.length, 0);
177
+ const encoding = head[0] === 255 && head[1] === 254 ? "utf-16le" : head[0] === 254 && head[1] === 255 ? "utf-16be" : "utf-8";
178
+ const text = new TextDecoder(encoding).decode(head.subarray(0, bytesRead)).trimStart();
179
+ return /^<(?:[!?]|(?:plist|dict|array|string|integer|real|data|date|true|false)[\s/>])/u.test(text) ? "xml" : "unknown";
180
+ });
181
+ };
182
+ })))();
183
+ }
184
+
185
+ //#endregion
35
186
  //#region dist/native/AppleDispatchCoverage.js
36
187
  var describeFixups, pushDispatchCoverage, formatIssue;
37
188
  function init_AppleDispatchCoverage() {
@@ -418,27 +569,30 @@ function init_AppleMachoFixups() {
418
569
  };
419
570
  uleb = (bytes, cursor, end) => {
420
571
  let value = 0n;
421
- let shift = 0n;
572
+ let shift = 0;
422
573
  for (;;) {
423
574
  if (cursor.at >= end) throw new RangeError("Truncated bind opcode operand");
424
575
  const byte = bytes[cursor.at++] ?? 0;
425
- value |= BigInt(byte & 127) << shift;
426
- shift += 7n;
576
+ const slice = byte & 127;
577
+ if (shift === 63 && slice > 1 || shift === 64 && slice !== 0) throw new RangeError("Oversized bind opcode operand");
578
+ if (shift < 64) value |= BigInt(slice) << BigInt(shift);
579
+ shift = Math.min(64, shift + 7);
427
580
  if ((byte & 128) === 0) return value;
428
- if (shift > 63n) throw new RangeError("Oversized bind opcode operand");
429
581
  }
430
582
  };
431
583
  sleb = (bytes, cursor, end) => {
432
584
  let value = 0n;
433
- let shift = 0n;
585
+ let shift = 0;
434
586
  let byte = 0;
435
587
  do {
436
588
  if (cursor.at >= end) throw new RangeError("Truncated bind opcode operand");
437
589
  byte = bytes[cursor.at++] ?? 0;
438
- value |= BigInt(byte & 127) << shift;
439
- shift += 7n;
440
- } while ((byte & 128) !== 0 && shift <= 63n);
441
- return (byte & 64) !== 0 ? value - (1n << shift) : value;
590
+ const slice = byte & 127;
591
+ if (shift === 63 && slice !== 0 && slice !== 127 || shift === 64 && slice !== (value < 0n ? 127 : 0)) throw new RangeError("Oversized bind opcode operand");
592
+ if (shift < 64) value = BigInt.asIntN(64, value | BigInt(slice) << BigInt(shift));
593
+ shift = Math.min(64, shift + 7);
594
+ } while ((byte & 128) !== 0);
595
+ return shift < 64 && (byte & 64) !== 0 ? value - (1n << BigInt(shift)) : value;
442
596
  };
443
597
  setBindRegister = (image, stream, state, byte) => {
444
598
  const { bytes } = image;
@@ -914,28 +1068,37 @@ function init_AppleMachoSelection() {
914
1068
 
915
1069
  //#endregion
916
1070
  //#region dist/native/AppleObjcProperties.js
917
- var parsePropertyAttributes, splitAttributes, readObjcPropertyList, readObjcPropertiesOf;
1071
+ var parsePropertyAttributes, decodePropertyAttributes, splitAttributes, readObjcPropertyList, readObjcPropertiesOf;
918
1072
  function init_AppleObjcProperties() {
919
1073
  return (init_AppleObjcProperties = __esmMin((() => {
920
1074
  init_AppleDispatchDecodeFacts();
921
- parsePropertyAttributes = (name, attributes) => {
922
- const tokens = attributes.length === 0 ? [] : splitAttributes(attributes);
1075
+ parsePropertyAttributes = (name, attributes) => decodePropertyAttributes(name, attributes).property;
1076
+ decodePropertyAttributes = (name, attributes) => {
1077
+ const { tokens, complete } = attributes.length === 0 ? {
1078
+ tokens: [],
1079
+ complete: true
1080
+ } : splitAttributes(attributes);
923
1081
  const typeAttributes = tokens.filter((token) => token[0] === "T");
924
1082
  const typeAttribute = typeAttributes.length === 1 ? typeAttributes[0] : undefined;
925
1083
  const typeEncoding = typeAttribute !== undefined && typeAttribute.length > 1 ? typeAttribute.slice(1) : null;
926
1084
  const value = (code) => tokens.find((token) => token[0] === code)?.slice(1) ?? null;
927
- return {
1085
+ const defaultsEstablished = typeEncoding !== null && complete;
1086
+ const property = {
928
1087
  name,
929
1088
  type_encoding: typeEncoding,
930
1089
  attributes: tokens.map((token) => ({
931
1090
  name: token.slice(0, 1),
932
1091
  value: token.slice(1)
933
1092
  })),
934
- atomicity: tokens.includes("N") ? "nonatomic" : typeEncoding === null ? null : "atomic",
935
- is_readonly: tokens.includes("R") ? true : typeEncoding === null ? null : false,
1093
+ atomicity: tokens.includes("N") ? "nonatomic" : defaultsEstablished ? "atomic" : null,
1094
+ is_readonly: tokens.includes("R") ? true : defaultsEstablished ? false : null,
936
1095
  getter: value("G"),
937
1096
  setter: value("S")
938
1097
  };
1098
+ return {
1099
+ property,
1100
+ complete
1101
+ };
939
1102
  };
940
1103
  splitAttributes = (attributes) => {
941
1104
  const tokens = [];
@@ -949,24 +1112,53 @@ function init_AppleObjcProperties() {
949
1112
  } else current += character;
950
1113
  }
951
1114
  tokens.push(current);
952
- return tokens.filter((token) => token.length > 0);
1115
+ return {
1116
+ tokens: tokens.filter((token) => token.length > 0),
1117
+ complete: !quoted
1118
+ };
953
1119
  };
954
1120
  readObjcPropertyList = (read, list, admit) => {
955
- if (list === 0n) return [];
1121
+ const properties = [];
1122
+ const issues = [];
1123
+ if (list === 0n) return {
1124
+ properties,
1125
+ issues
1126
+ };
956
1127
  const entrySize = read.u32(list) & ~3;
957
1128
  const count = read.u32(list + 4n);
958
1129
  if (entrySize !== 16) throw new TypeError(`Unsupported Objective-C property entry size ${entrySize}`);
959
- const properties = [];
960
1130
  for (let index = 0; index < count; index++) {
961
1131
  if (!admit()) break;
962
1132
  const entry = list + 8n + BigInt(index * entrySize);
963
- properties.push(parsePropertyAttributes(read.string(read.pointer(entry)), read.string(read.pointer(entry + 8n))));
1133
+ const location = `0x${entry.toString(16)}`;
1134
+ try {
1135
+ const name = read.string(read.pointer(entry));
1136
+ if (name.length === 0) throw new TypeError("the property name is empty");
1137
+ const decoded = decodePropertyAttributes(name, read.string(read.pointer(entry + 8n)));
1138
+ properties.push(decoded.property);
1139
+ if (!decoded.complete) issues.push({
1140
+ code: "property_attributes_incomplete",
1141
+ message: `property ${name} has an unterminated quoted class name in its type attribute, so atomicity and unestablished read-only state are unknown`,
1142
+ location
1143
+ });
1144
+ } catch (cause) {
1145
+ issues.push({
1146
+ code: "property_decode_failed",
1147
+ message: `property ${String(index)} could not be decoded: ${cause instanceof Error ? cause.message : String(cause)}`,
1148
+ location
1149
+ });
1150
+ }
964
1151
  }
965
- return properties;
1152
+ return {
1153
+ properties,
1154
+ issues
1155
+ };
966
1156
  };
967
1157
  readObjcPropertiesOf = (read, list, context) => {
968
1158
  try {
969
- return readObjcPropertyList(read, list, context.admit);
1159
+ const { properties, issues } = readObjcPropertyList(read, list, context.admit);
1160
+ for (const item of issues) context.issues.push(issue("objc_properties_categories", item.code, `${context.owner}: ${item.message}`, item.location));
1161
+ return properties;
970
1162
  } catch (cause) {
971
1163
  context.issues.push(issue("objc_properties_categories", "property_decode_failed", `${context.owner}: ${cause instanceof Error ? cause.message : String(cause)}`, context.location));
972
1164
  return [];
@@ -999,9 +1191,15 @@ function init_AppleObjcCategories() {
999
1191
  try {
1000
1192
  const category = read.pointer(field);
1001
1193
  const name = read.string(read.pointer(category));
1194
+ if (name.length === 0) throw new TypeError("Objective-C category has an empty name");
1002
1195
  const external = boundClassName(read, category + 8n);
1003
1196
  const local = read.pointer(category + 8n);
1004
- const className = external ?? (local === 0n ? null : input.localClassName(local));
1197
+ let className = external ?? null;
1198
+ if (external === undefined && local !== 0n) try {
1199
+ className = input.localClassName(local);
1200
+ } catch (cause) {
1201
+ input.issues.push(issue("objc_properties_categories", "category_class_unresolved", `Category ${name} class reference 0x${local.toString(16)}: ${cause instanceof Error ? cause.message : String(cause)}`, `0x${(category + 8n).toString(16)}`));
1202
+ }
1005
1203
  const owner = className ?? `(${name})`;
1006
1204
  result.objc_categories.push({
1007
1205
  name,
@@ -1059,7 +1257,7 @@ function init_AppleObjcProtocols() {
1059
1257
  }
1060
1258
  return names;
1061
1259
  };
1062
- const methods = (address, required, instance) => {
1260
+ const methods = (address, required, instance, emptySelectors) => {
1063
1261
  const output = [];
1064
1262
  if (address === 0n) return output;
1065
1263
  const flags = read.u32(address), count = read.u32(address + 4n);
@@ -1071,8 +1269,13 @@ function init_AppleObjcProtocols() {
1071
1269
  const entry = address + 8n + BigInt(index * stride);
1072
1270
  let selector = relative ? entry + BigInt(read.i32(entry)) : read.pointer(entry);
1073
1271
  if (relative && (flags & 1073741824) === 0) selector = read.pointer(selector);
1272
+ const selectorName = read.string(selector);
1273
+ if (selectorName.length === 0) {
1274
+ emptySelectors.push(`${required ? "required" : "optional"} ${instance ? "instance" : "class"} method ${String(index)} at 0x${entry.toString(16)} has an empty selector`);
1275
+ continue;
1276
+ }
1074
1277
  output.push({
1075
- selector: read.string(selector),
1278
+ selector: selectorName,
1076
1279
  method_type: instance ? "instance" : "class",
1077
1280
  address: null,
1078
1281
  is_required: required,
@@ -1088,8 +1291,11 @@ function init_AppleObjcProtocols() {
1088
1291
  if (read.u32(address + 64n) < 72) throw new RangeError("Truncated Objective-C protocol declaration");
1089
1292
  const protocolName = name(address);
1090
1293
  const adopted = list(read.pointer(address + 16n));
1091
- const required = [...methods(read.pointer(address + 24n), true, true), ...methods(read.pointer(address + 32n), true, false)];
1092
- const optional = [...methods(read.pointer(address + 40n), false, true), ...methods(read.pointer(address + 48n), false, false)];
1294
+ if (protocolName.length === 0) throw new TypeError("Objective-C protocol has an empty name");
1295
+ const skipped = [];
1296
+ const required = [...methods(read.pointer(address + 24n), true, true, skipped), ...methods(read.pointer(address + 32n), true, false, skipped)];
1297
+ const optional = [...methods(read.pointer(address + 40n), false, true, skipped), ...methods(read.pointer(address + 48n), false, false, skipped)];
1298
+ for (const message of skipped) failures.push(`Protocol 0x${address.toString(16)}: Objective-C protocol ${protocolName} ${message}`);
1093
1299
  result.objc_protocols.push({
1094
1300
  name: protocolName,
1095
1301
  methods: required,
@@ -1102,9 +1308,12 @@ function init_AppleObjcProtocols() {
1102
1308
  methods: required,
1103
1309
  optional_methods: optional,
1104
1310
  location: read.location(address),
1105
- decode: {
1311
+ decode: skipped.length === 0 ? {
1106
1312
  status: "decoded",
1107
1313
  reason: null
1314
+ } : {
1315
+ status: "partial",
1316
+ reason: "protocol_method_selector_empty"
1108
1317
  },
1109
1318
  evidence: read.evidence(address, "Objective-C protocol declaration and encoded method lists; IMP fields are not handler targets")
1110
1319
  });
@@ -1122,7 +1331,7 @@ function init_AppleObjcProtocols() {
1122
1331
 
1123
1332
  //#endregion
1124
1333
  //#region dist/native/AppleObjcDispatchFacets.js
1125
- var hex$1, decoded$1, localClassName, resolveSuperclass, decodeObjcDispatchFacets;
1334
+ var hex$1, decoded$1, readLocalClass, resolveSuperclass, decodeObjcDispatchFacets;
1126
1335
  function init_AppleObjcDispatchFacets() {
1127
1336
  return (init_AppleObjcDispatchFacets = __esmMin((() => {
1128
1337
  init_result();
@@ -1134,7 +1343,15 @@ function init_AppleObjcDispatchFacets() {
1134
1343
  status: "decoded",
1135
1344
  reason: null
1136
1345
  };
1137
- localClassName = (read, address) => read.string(read.pointer((read.pointer(address + 32n) & ~7n) + 24n));
1346
+ readLocalClass = (read, address) => {
1347
+ const ro = read.pointer(address + 32n) & ~7n;
1348
+ const name = read.string(read.pointer(ro + 24n));
1349
+ if (name.length === 0) throw new TypeError(`Objective-C class at ${hex$1(address)} has an empty name`);
1350
+ return {
1351
+ ro,
1352
+ name
1353
+ };
1354
+ };
1138
1355
  resolveSuperclass = (read, address, className, failures) => {
1139
1356
  const external = boundClassName(read, address + 8n);
1140
1357
  if (external !== undefined) return {
@@ -1148,12 +1365,11 @@ function init_AppleObjcDispatchFacets() {
1148
1365
  };
1149
1366
  try {
1150
1367
  return {
1151
- name: localClassName(read, superclass),
1368
+ name: readLocalClass(read, superclass).name,
1152
1369
  address: hex$1(superclass)
1153
1370
  };
1154
1371
  } catch (cause) {
1155
- void cause;
1156
- failures.push(`Superclass pointer ${hex$1(superclass)} of ${className} requires unsupported binding/fixup resolution`);
1372
+ failures.push(`Superclass pointer ${hex$1(superclass)} of ${className} could not be decoded: ${cause instanceof Error ? cause.message : String(cause)}`);
1157
1373
  return {
1158
1374
  name: null,
1159
1375
  address: hex$1(superclass)
@@ -1211,6 +1427,7 @@ function init_AppleObjcDispatchFacets() {
1211
1427
  void cause;
1212
1428
  }
1213
1429
  const selector = read.string(selectorAddress);
1430
+ if (selector.length === 0) throw new TypeError("Objective-C method has an empty selector");
1214
1431
  selectors.push(selector);
1215
1432
  result.objc_dispatch_implementations.push({
1216
1433
  class_name: className,
@@ -1287,9 +1504,7 @@ function init_AppleObjcDispatchFacets() {
1287
1504
  const readClass = (address, meta = false) => {
1288
1505
  if (address === 0n || visited.has(hex$1(address)) || !budget.admit()) return;
1289
1506
  visited.add(hex$1(address));
1290
- const ro = read.pointer(address + 32n) & ~7n;
1291
- const name = read.string(read.pointer(ro + 24n));
1292
- if (name.length === 0) throw new TypeError(`Objective-C class at ${hex$1(address)} has an empty name`);
1507
+ const { ro, name } = readLocalClass(read, address);
1293
1508
  const root = (read.u32(ro) & 2) !== 0;
1294
1509
  const superclass = resolveSuperclass(read, address, name, failures);
1295
1510
  if (superclass.name === null && superclass.address === null && !root) failures.push(`Superclass of ${name} requires external binding resolution`);
@@ -1310,10 +1525,12 @@ function init_AppleObjcDispatchFacets() {
1310
1525
  void cause;
1311
1526
  failures.push(`Unresolved ivar offset pointer ${hex$1(encodedOffset)}`);
1312
1527
  }
1528
+ const ivarName = read.string(read.pointer(entry + 8n));
1529
+ if (ivarName.length === 0) throw new TypeError("Objective-C ivar has an empty name");
1313
1530
  const alignment = read.u32(entry + 24n);
1314
1531
  result.objc_ivars.push({
1315
1532
  class_name: name,
1316
- name: read.string(read.pointer(entry + 8n)),
1533
+ name: ivarName,
1317
1534
  type_encoding: read.string(read.pointer(entry + 16n)),
1318
1535
  offset: value,
1319
1536
  size: read.u32(entry + 28n),
@@ -1398,7 +1615,7 @@ function init_AppleObjcDispatchFacets() {
1398
1615
  admit: () => budget.admit(),
1399
1616
  methods,
1400
1617
  protocols: (list) => protocolReader.list(list),
1401
- localClassName: (address) => localClassName(read, address)
1618
+ localClassName: (address) => readLocalClass(read, address).name
1402
1619
  });
1403
1620
  return {
1404
1621
  failures,
@@ -1597,6 +1814,7 @@ function init_AppleSwiftVtables() {
1597
1814
  const positiveWords = read.u32(descriptor + 28n);
1598
1815
  if (count > 2e4 || tableOffset + count > positiveWords) throw new RangeError("Swift vtable count or offset exceeds declared metadata bounds");
1599
1816
  const owner = read.string(read.relative(descriptor + 8n));
1817
+ if (owner.length === 0) throw new RangeError("Swift class vtable descriptor class name is empty");
1600
1818
  for (let index = 0; index < count; index++) {
1601
1819
  const entry = header + 8n + BigInt(index * 8);
1602
1820
  if (!read.admit()) {
@@ -1652,13 +1870,19 @@ function init_AppleSwiftVtables() {
1652
1870
 
1653
1871
  //#endregion
1654
1872
  //#region dist/native/AppleDispatchMetadata.js
1655
- var decodeAppleDispatchMetadata, inspectAppleDispatchMetadata;
1873
+ var decodeAppleDispatchMetadata, inspectAppleDispatchMetadata, OPERATION$3, appleDispatchMetadataFailure;
1656
1874
  function init_AppleDispatchMetadata() {
1657
1875
  return (init_AppleDispatchMetadata = __esmMin((() => {
1658
1876
  init_objcSwiftMetadata();
1659
1877
  init_binaryTargetTypes();
1660
1878
  init_analysisErrorCore();
1661
- init_RegularFile();
1879
+ init_ArtifactFileOperation();
1880
+ init_ArtifactReader();
1881
+ init_analysisErrorBase();
1882
+ init_analysisErrorProjection();
1883
+ init_providerAdapterError();
1884
+ init_providerCleanupError();
1885
+ init_NativeMacOSProviderMetadata();
1662
1886
  init_BoundedFileBytes();
1663
1887
  init_evidenceErrors();
1664
1888
  init_AppleDispatchCoverage();
@@ -1699,7 +1923,10 @@ function init_AppleDispatchMetadata() {
1699
1923
  while (end < bytes.length && end - start < 4096 && bytes[end] !== 0) end++;
1700
1924
  if (end === bytes.length || end - start >= 4096) throw new RangeError("Unterminated or oversized metadata string");
1701
1925
  offset(address, end - start + 1);
1702
- return new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(start, end));
1926
+ return new TextDecoder("utf-8", {
1927
+ fatal: true,
1928
+ ignoreBOM: true
1929
+ }).decode(bytes.subarray(start, end));
1703
1930
  };
1704
1931
  const result = objcSwiftMetadataSchema.parse({ db_save_result: null });
1705
1932
  let records = 0;
@@ -1786,37 +2013,99 @@ function init_AppleDispatchMetadata() {
1786
2013
  });
1787
2014
  return objcSwiftMetadataSchema.parse(result);
1788
2015
  };
1789
- inspectAppleDispatchMetadata = async (target, maxRecords, signal) => {
2016
+ inspectAppleDispatchMetadata = async (target, maxRecords, resources, signal) => {
1790
2017
  if (target.kind !== "executable" || !isMachOFormat(target.format)) throw new TypeError("Apple dispatch metadata requires a Mach-O target");
1791
2018
  const maximumBytes = 64 * 1024 * 1024;
1792
2019
  const capacityError = () => new AnalysisResourceConstraintError("inspect_native_dispatch_metadata", "memory", "Apple static metadata input exceeds its 64 MiB snapshot budget", { input_bytes: maximumBytes });
1793
- const handle = await openRegularFile(target.path, {
1794
- symlinks: "reject",
1795
- signal
1796
- });
1797
- try {
2020
+ const cancelled = () => new AnalysisCancelledError("inspect_native_dispatch_metadata", { cause: signal?.reason });
2021
+ const { bytes, digest } = await withArtifactRegularFile(target.path, resources, signal, async (handle) => {
1798
2022
  const before = await handle.stat();
1799
2023
  if (before.size > maximumBytes) throw capacityError();
1800
- if (signal?.aborted) throw new AnalysisCancelledError("inspect_native_dispatch_metadata");
1801
- const bytes = await readBoundedFileBytes(handle, maximumBytes, signal);
1802
- if (bytes === undefined) throw capacityError();
1803
- const digest = createHash("sha256").update(bytes).digest("hex");
1804
- if (digest !== target.sha256) throw new EvidenceIntegrityError("Apple metadata target digest changed after session binding");
1805
- return nativeDispatchMetadataResultSchema.parse({
1806
- target_sha256: target.sha256,
1807
- provider: {
1808
- id: "native-macos",
1809
- name: "macOS native inspection utilities",
1810
- version: "apple-metadata-reader-1"
1811
- },
1812
- analysis_profile_digest: null,
1813
- result: decodeAppleDispatchMetadata(bytes, maxRecords, {
1814
- path: target.path,
1815
- sha256: digest
1816
- }, target.architecture)
2024
+ if (signal?.aborted) throw cancelled();
2025
+ const read = await readBoundedFileBytes(handle, maximumBytes, signal).catch((cause) => {
2026
+ if (signal?.aborted === true && cause === signal.reason) throw cancelled();
2027
+ throw cause;
1817
2028
  });
1818
- } finally {
1819
- await handle.close();
2029
+ if (read === undefined) throw capacityError();
2030
+ const sha256 = createHash("sha256").update(read).digest("hex");
2031
+ if (sha256 !== target.sha256) throw new EvidenceIntegrityError("Apple metadata target digest changed after session binding");
2032
+ return {
2033
+ bytes: read,
2034
+ digest: sha256
2035
+ };
2036
+ }, "reject");
2037
+ return nativeDispatchMetadataResultSchema.parse({
2038
+ target_sha256: target.sha256,
2039
+ provider: {
2040
+ id: "native-macos",
2041
+ name: "macOS native inspection utilities",
2042
+ version: "apple-metadata-reader-1"
2043
+ },
2044
+ analysis_profile_digest: null,
2045
+ result: decodeAppleDispatchMetadata(bytes, maxRecords, {
2046
+ path: target.path,
2047
+ sha256: digest
2048
+ }, target.architecture)
2049
+ });
2050
+ };
2051
+ OPERATION$3 = "inspect_native_dispatch_metadata";
2052
+ appleDispatchMetadataFailure = (cause, path) => {
2053
+ if (cause instanceof ArtifactReaderFailure && cause.cleanup !== undefined) {
2054
+ const physical = cause instanceof ArtifactFileCleanupFailure ? cause.fileCleanupFailure : undefined;
2055
+ const previous = physical?.outcome.kind === "failed" ? appleDispatchMetadataFailure(artifactFilePrimaryFailure(cause), path) : physical?.completionCancellation === undefined ? undefined : new AnalysisCancelledError(OPERATION$3, { cause: physical.completionCancellation.reason });
2056
+ const failure = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, cause.cleanup.resources, {
2057
+ reason: cause.cleanup.reason,
2058
+ previous_error: previous === undefined ? null : projectAnalysisError(previous)
2059
+ }, {
2060
+ operation: OPERATION$3,
2061
+ cause,
2062
+ cleanupPrimary: previous
2063
+ });
2064
+ bindArtifactFileCleanup(cause, failure);
2065
+ return failure;
2066
+ }
2067
+ if (cause instanceof AnalysisError) return cause;
2068
+ if (cause instanceof ArtifactReaderFailure && cause.reason === "cancelled") return new AnalysisCancelledError(OPERATION$3, { cause: artifactFileCancellationCause(cause) });
2069
+ if (cause instanceof ArtifactReaderFailure && cause.reason === "unavailable") return new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, OPERATION$3, cause.message, { cause });
2070
+ return new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, OPERATION$3, {
2071
+ cause,
2072
+ diagnostics: {
2073
+ target_path: path,
2074
+ reason: cause instanceof Error ? cause.message : String(cause)
2075
+ }
2076
+ });
2077
+ };
2078
+ })))();
2079
+ }
2080
+
2081
+ //#endregion
2082
+ //#region dist/native/NativeUiCleanupError.js
2083
+ var NativeUiCleanupError;
2084
+ function init_NativeUiCleanupError() {
2085
+ return (init_NativeUiCleanupError = __esmMin((() => {
2086
+ init_AnalysisCleanupLease();
2087
+ init_providerCleanupError();
2088
+ NativeUiCleanupError = class extends ProviderCleanupError {
2089
+ runtimes;
2090
+ constructor(failures, operation, partialObservation) {
2091
+ const runtimes = failures.map(({ runtime }) => runtime);
2092
+ const resources = () => runtimes.filter((runtime) => !runtime.cleanupLease.released).flatMap((runtime) => runtime.resources());
2093
+ super("native-macos", resources(), {
2094
+ reason: "Native UI runtime cleanup remains incomplete",
2095
+ failures: failures.map(({ runtime, cause }) => ({
2096
+ resources: [...runtime.resources()],
2097
+ reason: cause instanceof Error ? cause.message : String(cause)
2098
+ }))
2099
+ }, {
2100
+ operation,
2101
+ cause: new AggregateError(failures.map(({ cause }) => cause), "Native UI runtime cleanup failed"),
2102
+ partialObservation
2103
+ });
2104
+ this.runtimes = runtimes;
2105
+ new AnalysisCleanupLeaseGroup(this, runtimes.map((runtime) => runtime.cleanupLease));
2106
+ this.bindCleanupResourceOwner({ get cleanupResources() {
2107
+ return resources();
2108
+ } });
1820
2109
  }
1821
2110
  };
1822
2111
  })))();
@@ -1843,6 +2132,8 @@ function init_NativeUiOutputBudget() {
1843
2132
  var createNativeUiHelperRuntime;
1844
2133
  function init_NativeUiHelperRuntime() {
1845
2134
  return (init_NativeUiHelperRuntime = __esmMin((() => {
2135
+ init_ArtifactResourceScope();
2136
+ init_AnalysisCleanupLease();
1846
2137
  init_snapshotEnvironment();
1847
2138
  init_DarwinProcessRunTokenReader();
1848
2139
  init_ExecFileOutput();
@@ -1850,59 +2141,68 @@ function init_NativeUiHelperRuntime() {
1850
2141
  init_NativeUiOutputBudget();
1851
2142
  createNativeUiHelperRuntime = (environment) => {
1852
2143
  const selectedEnvironment = snapshotEnvironment(environment);
2144
+ const deadlineSignal = AbortSignal.timeout(18e4);
2145
+ const operations = new ArtifactResourceScope();
1853
2146
  let root;
1854
- let executable;
1855
- const invoke = async (parameters, signal) => {
1856
- if (executable === undefined) {
1857
- root = await mkdtemp(join(tmpdir(), "rea-native-ui-"));
1858
- const output = join(root, "observer");
1859
- const main = join(root, "main.swift");
1860
- await symlink(fileURLToPath(new URL("../../bridge/native/ReaNativeUI.swift", new URL("../native/NativeUiHelperRuntime.js", import.meta.url).href)), main);
1861
- const compilerTemporary = join(root, "tmp");
1862
- await mkdir(compilerTemporary);
1863
- await execFileOutput("/usr/bin/xcrun", [
1864
- "swiftc",
1865
- "-module-cache-path",
1866
- join(root, "modules"),
1867
- fileURLToPath(new URL("../../bridge/native/NativeUIChildren.swift", new URL("../native/NativeUiHelperRuntime.js", import.meta.url).href)),
1868
- main,
1869
- "-o",
1870
- output
1871
- ], {
1872
- timeout: 6e4,
1873
- maxBuffer: 1024 * 1024,
1874
- stopSignal: SWIFTC_INTERRUPT,
1875
- env: {
1876
- ...selectedEnvironment,
1877
- TMPDIR: compilerTemporary
1878
- },
1879
- ...signal === undefined ? {} : { signal }
2147
+ let preparation;
2148
+ const cleanupLease = new AnalysisCleanupLease(async () => {
2149
+ await operations.close();
2150
+ if (root !== undefined) {
2151
+ await rm(root, {
2152
+ recursive: true,
2153
+ force: true
1880
2154
  });
1881
- executable = output;
2155
+ root = undefined;
2156
+ preparation = undefined;
1882
2157
  }
2158
+ });
2159
+ const prepare = async (signal) => {
2160
+ root = await mkdtemp(join(tmpdir(), "rea-native-ui-"));
2161
+ const output = join(root, "observer");
2162
+ const main = join(root, "main.swift");
2163
+ await symlink(fileURLToPath(new URL("../../bridge/native/ReaNativeUI.swift", new URL("../native/NativeUiHelperRuntime.js", import.meta.url).href)), main);
2164
+ const compilerTemporary = join(root, "tmp");
2165
+ await mkdir(compilerTemporary);
2166
+ await execFileOutput("/usr/bin/xcrun", [
2167
+ "swiftc",
2168
+ "-module-cache-path",
2169
+ join(root, "modules"),
2170
+ fileURLToPath(new URL("../../bridge/native/NativeUIChildren.swift", new URL("../native/NativeUiHelperRuntime.js", import.meta.url).href)),
2171
+ main,
2172
+ "-o",
2173
+ output
2174
+ ], {
2175
+ timeout: 6e4,
2176
+ maxBuffer: 1024 * 1024,
2177
+ stopSignal: SWIFTC_INTERRUPT,
2178
+ env: {
2179
+ ...selectedEnvironment,
2180
+ TMPDIR: compilerTemporary
2181
+ },
2182
+ signal
2183
+ });
2184
+ return output;
2185
+ };
2186
+ const invoke = (parameters, callerSignal) => operations.run(async () => {
2187
+ const signal = callerSignal === undefined ? deadlineSignal : AbortSignal.any([callerSignal, deadlineSignal]);
2188
+ preparation ??= prepare(signal);
2189
+ const executable = await preparation;
1883
2190
  const output = await execFileOutput(executable, [JSON.stringify(parameters)], {
1884
2191
  timeout: 3e4,
1885
2192
  maxBuffer: NATIVE_UI_HELPER_MAX_BUFFER,
1886
2193
  stopSignal: "SIGTERM",
1887
2194
  env: selectedEnvironment,
1888
- ...signal === undefined ? {} : { signal }
2195
+ signal
1889
2196
  });
1890
2197
  const parsed = safeParseJson(output.stdout);
1891
2198
  if (!parsed.ok) throw new Error(`Native helper returned invalid JSON: ${parsed.error}`, { cause: parsed.cause });
1892
2199
  return parsed.value;
1893
- };
2200
+ });
1894
2201
  return {
1895
2202
  invoke,
1896
- close: async () => {
1897
- if (root !== undefined) {
1898
- await rm(root, {
1899
- recursive: true,
1900
- force: true
1901
- });
1902
- root = undefined;
1903
- executable = undefined;
1904
- }
1905
- },
2203
+ cleanupLease,
2204
+ signal: deadlineSignal,
2205
+ close: () => cleanupLease.release(),
1906
2206
  resources: () => root === undefined ? [] : [root]
1907
2207
  };
1908
2208
  };
@@ -1911,17 +2211,26 @@ function init_NativeUiHelperRuntime() {
1911
2211
 
1912
2212
  //#endregion
1913
2213
  //#region dist/native/NativeUiObservation.js
1914
- var helper, responseSchema, observeNativeUi, observeWithHelper;
2214
+ var helper, passiveInputSchema, responseSchema, observeNativeUi, observeWithHelper, finishNativeUiObservation;
1915
2215
  function init_NativeUiObservation() {
1916
2216
  return (init_NativeUiObservation = __esmMin((() => {
2217
+ init_ProviderDeadline();
1917
2218
  init_binaryTargetTypes();
1918
2219
  init_nativeUiObservation();
1919
2220
  init_analysisErrorCore();
1920
2221
  init_providerAdapterError();
2222
+ init_analysisErrorBase();
2223
+ init_analysisErrorCleanup();
2224
+ init_ExecFileOutput();
2225
+ init_NativeUiCleanupError();
1921
2226
  init_result();
1922
2227
  init_NativeUiHelperRuntime();
1923
2228
  init_NativeUiOutputBudget();
1924
2229
  helper = fileURLToPath(new URL("../../bridge/native/ReaNativeUI.swift", new URL("../native/NativeUiObservation.js", import.meta.url).href));
2230
+ passiveInputSchema = nativeUiObservationInputSchema.transform((input) => ({
2231
+ ...input,
2232
+ steps: []
2233
+ }));
1925
2234
  responseSchema = z.discriminatedUnion("ok", [z.strictObject({
1926
2235
  ok: z.literal(true),
1927
2236
  result: nativeUiSnapshotSchema
@@ -1932,28 +2241,43 @@ function init_NativeUiObservation() {
1932
2241
  })]);
1933
2242
  observeNativeUi = async (target, operation, parameters, options) => {
1934
2243
  const runtime = options.runtime ?? createNativeUiHelperRuntime(options.environment);
2244
+ const signal = options.signal === undefined ? runtime.signal : AbortSignal.any([options.signal, runtime.signal]);
2245
+ let result;
1935
2246
  try {
1936
- return await observeWithHelper(target, operation, parameters, {
1937
- ...options,
2247
+ result = await observeWithHelper(target, operation, parameters, {
2248
+ signal,
1938
2249
  invoke: options.invoke ?? runtime.invoke
1939
2250
  });
1940
- } finally {
1941
- if (options.runtime === undefined) await runtime.close();
2251
+ } catch (cause) {
2252
+ result = err(cause instanceof AnalysisError ? cause : new ProviderAdapterError("native-macos", operation, { cause }));
1942
2253
  }
2254
+ if (options.runtime === undefined) {
2255
+ try {
2256
+ await runtime.close();
2257
+ } catch (cause) {
2258
+ result = finishNativeUiObservation(result, operation, signal);
2259
+ const cleanup = new NativeUiCleanupError([{
2260
+ runtime,
2261
+ cause
2262
+ }], operation, result.ok ? result.value : undefined);
2263
+ return result.ok ? err(cleanup) : err(analysisErrorWithCleanupFailure(result.error, cleanup, operation).bindCleanupDependencies([result.error, cleanup]));
2264
+ }
2265
+ }
2266
+ return finishNativeUiObservation(result, operation, signal);
1943
2267
  };
1944
2268
  observeWithHelper = async (target, operation, parameters, options) => {
1945
- const parsed = (operation === "observe_native_ui" ? nativeUiObservationInputSchema : nativeUiScenarioInputSchema).safeParse(parameters);
2269
+ const parsed = (operation === "observe_native_ui" ? passiveInputSchema : nativeUiScenarioInputSchema).safeParse(parameters);
1946
2270
  if (!parsed.success) return err(new AnalysisInputError(operation, { cause: parsed.error }));
1947
2271
  if (target.kind !== "executable" || !isMachOFormat(target.format)) return err(new AnalysisCapabilityUnavailableError("native-macos", operation, "Native UI observation requires an active Mach-O executable or app target"));
1948
2272
  const input = parsed.data;
1949
2273
  if (!input.screenshot && !input.accessibility) return err(new AnalysisInputError(operation, { cause: new Error("Enable screenshot or accessibility capture") }));
1950
- const steps = operation === "capture_native_ui_scenario" ? nativeUiScenarioInputSchema.parse(parameters).steps : [];
1951
- const signal = options.signal === undefined ? AbortSignal.timeout(18e4) : AbortSignal.any([options.signal, AbortSignal.timeout(18e4)]);
2274
+ const steps = input.steps;
2275
+ const signal = options.signal;
1952
2276
  const invoke = options.invoke;
1953
2277
  let launchTime;
1954
2278
  let outputBytes = 0;
1955
2279
  const take = async (action) => {
1956
- if (signal.aborted) return err(new AnalysisCancelledError(operation));
2280
+ if (signal.aborted) return err(new AnalysisCancelledError(operation, { cause: signal.reason }));
1957
2281
  try {
1958
2282
  const response = responseSchema.parse(await invoke({
1959
2283
  pid: input.pid,
@@ -1973,7 +2297,8 @@ function init_NativeUiObservation() {
1973
2297
  if (outputBytes > 67108864) return err(new AnalysisCapabilityUnavailableError("native-macos", operation, "Scenario captures exceeded the 64 MiB output budget"));
1974
2298
  return ok(response.result);
1975
2299
  } catch (cause) {
1976
- return err(signal.aborted ? new AnalysisCancelledError(operation) : new ProviderAdapterError("native-macos", operation, {
2300
+ if (cause instanceof AnalysisError) return err(cause);
2301
+ return err(cause instanceof ExecFileOutputCancelledError ? new AnalysisCancelledError(operation, { cause: cause.cause }) : new ProviderAdapterError("native-macos", operation, {
1977
2302
  cause,
1978
2303
  diagnostics: {
1979
2304
  helper_path: helper,
@@ -1987,8 +2312,10 @@ function init_NativeUiObservation() {
1987
2312
  if (!initial.ok) return initial;
1988
2313
  const results = [];
1989
2314
  let before = initial.value;
2315
+ let terminalFailure;
1990
2316
  for (const [index, step] of steps.entries()) {
1991
2317
  if (signal.aborted) {
2318
+ terminalFailure = new AnalysisCancelledError(operation, { cause: signal.reason });
1992
2319
  results.push({
1993
2320
  index,
1994
2321
  kind: step.kind,
@@ -1999,35 +2326,21 @@ function init_NativeUiObservation() {
1999
2326
  });
2000
2327
  break;
2001
2328
  }
2002
- if (step.kind === "wait") {
2003
- try {
2004
- await new Promise((resolve, reject) => {
2005
- const abort = () => {
2006
- clearTimeout(timer);
2007
- reject(new Error("cancelled"));
2008
- };
2009
- const timer = setTimeout(() => {
2010
- signal.removeEventListener("abort", abort);
2011
- resolve();
2012
- }, step.milliseconds);
2013
- signal.addEventListener("abort", abort, { once: true });
2014
- if (signal.aborted) abort();
2015
- });
2016
- } catch (cause) {
2017
- void cause;
2018
- results.push({
2019
- index,
2020
- kind: step.kind,
2021
- before,
2022
- after: null,
2023
- outcome: "cancelled",
2024
- reason: "Scenario cancelled during wait"
2025
- });
2026
- break;
2027
- }
2329
+ if (step.kind === "wait" && await waitForAbortableDelay(step.milliseconds, signal) === "aborted") {
2330
+ terminalFailure = new AnalysisCancelledError(operation, { cause: signal.reason });
2331
+ results.push({
2332
+ index,
2333
+ kind: step.kind,
2334
+ before,
2335
+ after: null,
2336
+ outcome: "cancelled",
2337
+ reason: "Scenario cancelled during wait"
2338
+ });
2339
+ break;
2028
2340
  }
2029
2341
  const after = await take(step.kind === "wait" ? undefined : step);
2030
2342
  if (!after.ok) {
2343
+ terminalFailure = after.error;
2031
2344
  results.push({
2032
2345
  index,
2033
2346
  kind: step.kind,
@@ -2048,7 +2361,7 @@ function init_NativeUiObservation() {
2048
2361
  });
2049
2362
  before = after.value;
2050
2363
  }
2051
- return ok(nativeUiResultSchema.parse({
2364
+ const report = nativeUiResultSchema.parse({
2052
2365
  target_sha256: target.sha256,
2053
2366
  initial: initial.value,
2054
2367
  steps: results,
@@ -2060,7 +2373,342 @@ function init_NativeUiObservation() {
2060
2373
  "Scenarios can change app data, cause app network activity and persist changes. The caller explicitly chooses leave-as-is; automatic restoration is unsupported.",
2061
2374
  "Window matching uses exact PID and window ID for screenshots and unique accessibility geometry. Accessibility paths can change as the UI changes; stale or ambiguous paths fail. Screenshots are scaled to at most 2048 pixels; scenario output is budgeted at 64 MiB and execution is cancelled after 180 seconds."
2062
2375
  ]
2063
- }));
2376
+ });
2377
+ return terminalFailure === undefined ? finishNativeUiObservation(ok(report), operation, signal) : err(terminalFailure.retainPartialObservation(report));
2378
+ };
2379
+ finishNativeUiObservation = (result, operation, signal) => result.ok && signal?.aborted ? err(new AnalysisCancelledError(operation, {
2380
+ cause: signal.reason,
2381
+ partialObservation: result.value
2382
+ })) : result;
2383
+ })))();
2384
+ }
2385
+
2386
+ //#endregion
2387
+ //#region dist/native/NativeCallTarget.js
2388
+ var OPERATION$2, nativeCallTargetFailure, verifyNativeCallTarget;
2389
+ function init_NativeCallTarget() {
2390
+ return (init_NativeCallTarget = __esmMin((() => {
2391
+ init_NativeMacOSProviderMetadata();
2392
+ init_analysisErrorCore();
2393
+ init_evidenceErrors();
2394
+ init_providerAdapterError();
2395
+ init_providerCleanupError();
2396
+ init_jsonValue();
2397
+ init_result();
2398
+ init_StableFileHash();
2399
+ init_RegularFile();
2400
+ init_OwnedRegularFile();
2401
+ init_AnalysisCleanupLease();
2402
+ init_ArtifactResourceScope();
2403
+ init_ArtifactFileOperation();
2404
+ OPERATION$2 = "observe_native_calls";
2405
+ nativeCallTargetFailure = (cause, path) => {
2406
+ if (cause instanceof ArtifactResourceRetryFailure && cause.cleanup !== undefined) {
2407
+ const failure = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, cause.cleanup.resources, {
2408
+ reason: cause.cleanup.reason,
2409
+ phase: "target-digest-retry"
2410
+ }, {
2411
+ operation: OPERATION$2,
2412
+ cause
2413
+ });
2414
+ bindArtifactFileCleanup(cause, failure);
2415
+ return failure;
2416
+ }
2417
+ if (cause instanceof RegularFileOperationCancelled || cause instanceof RegularFileCancelled) return new AnalysisCancelledError(OPERATION$2, {
2418
+ cause: cause.reason,
2419
+ ...cause instanceof RegularFileCancelled ? { diagnostics: { completed_hash: jsonValueSchema.parse(cause.outcome.value) } } : {}
2420
+ });
2421
+ const physical = stableFileHashCause(cause);
2422
+ if (physical instanceof RegularFileChangedError) return new EvidenceIntegrityError("Native call observation target changed during digest verification", { cause: physical });
2423
+ return new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, OPERATION$2, {
2424
+ cause: physical,
2425
+ diagnostics: {
2426
+ path,
2427
+ phase: "target-digest",
2428
+ reason: "Unable to verify the selected target digest",
2429
+ detail: physical instanceof Error ? physical.message : String(physical)
2430
+ }
2431
+ });
2432
+ };
2433
+ verifyNativeCallTarget = async (target, resources, signal) => {
2434
+ let cleanupLease;
2435
+ try {
2436
+ const digest = await hashStableFile(target.path, {
2437
+ ...signal === undefined ? {} : { signal },
2438
+ retainFailedClose: (owner) => {
2439
+ cleanupLease = new AnalysisCleanupLease(() => owner.close(), [target.path]);
2440
+ resources.retain({
2441
+ kind: "lease",
2442
+ resource: target.path,
2443
+ lease: cleanupLease
2444
+ });
2445
+ }
2446
+ });
2447
+ return digest.sha256 === target.sha256 ? ok(undefined) : err(new EvidenceIntegrityError("Native call observation target digest changed after session binding"));
2448
+ } catch (cause) {
2449
+ if (cause instanceof RegularFileCleanupFailure && cleanupLease !== undefined) {
2450
+ const cancellation = regularFileCancellation(cause);
2451
+ const completed = cause.outcome.kind === "completed" ? { completed_hash: jsonValueSchema.parse(cause.outcome.value) } : undefined;
2452
+ const primary = cause.outcome.kind === "failed" ? nativeCallTargetFailure(cause.outcome.cause, target.path) : cancellation === undefined ? undefined : new AnalysisCancelledError(OPERATION$2, {
2453
+ cause: cancellation.reason,
2454
+ diagnostics: completed
2455
+ });
2456
+ const framed = new ArtifactFileCleanupFailure(cause, cleanupLease);
2457
+ const failure = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, [target.path], {
2458
+ phase: "target-digest-close",
2459
+ reason: cause.cleanupCause instanceof Error ? cause.cleanupCause.message : String(cause.cleanupCause),
2460
+ ...completed
2461
+ }, {
2462
+ operation: OPERATION$2,
2463
+ cause: framed,
2464
+ cleanupPrimary: primary
2465
+ });
2466
+ bindArtifactFileCleanup(framed, failure);
2467
+ return err(failure);
2468
+ }
2469
+ return err(nativeCallTargetFailure(cause, target.path));
2470
+ }
2471
+ };
2472
+ })))();
2473
+ }
2474
+
2475
+ //#endregion
2476
+ //#region dist/domain/native/nativeCallPartialObservation.js
2477
+ var completed, nativeCallPartialObservationSchema;
2478
+ function init_nativeCallPartialObservation() {
2479
+ return (init_nativeCallPartialObservation = __esmMin((() => {
2480
+ init_nativeCallObservation();
2481
+ completed = nativeCallObservationResultSchema.shape;
2482
+ nativeCallPartialObservationSchema = z.strictObject({
2483
+ kind: z.literal("native-call-observation"),
2484
+ target: completed.target.omit({ launch_identity: true }).extend({ launch_identity: completed.target.shape.launch_identity.optional() }),
2485
+ process: completed.process.partial().extend({
2486
+ pid: z.number().int().positive().nullable(),
2487
+ stdout: nativeCapturedOutputSchema.nullable(),
2488
+ stderr: nativeCapturedOutputSchema.nullable(),
2489
+ other_stops: z.array(z.string())
2490
+ }),
2491
+ debugger: completed.debugger.partial().extend({ version: z.string().nullable() }),
2492
+ breakpoints: completed.breakpoints.optional(),
2493
+ events: z.array(nativeCallEventSchema),
2494
+ coverage: completed.coverage.omit({ status: true }).partial().extend({
2495
+ status: z.literal("partial"),
2496
+ reason: z.enum([
2497
+ "cancelled",
2498
+ "timeout",
2499
+ "tracer-failure",
2500
+ "capture-failure",
2501
+ "cleanup-failure"
2502
+ ])
2503
+ }),
2504
+ limitations: z.array(z.string())
2505
+ });
2506
+ })))();
2507
+ }
2508
+
2509
+ //#endregion
2510
+ //#region dist/native/NativeCallObservation.js
2511
+ var OPERATION$1, NATIVE_CALL_OBSERVATION_LIMITATIONS, observeNativeCalls, nativeCallFacts, projectNativeCalls, projectPartialNativeCalls;
2512
+ function init_NativeCallObservation() {
2513
+ return (init_NativeCallObservation = __esmMin((() => {
2514
+ init_analysisErrorCore();
2515
+ init_binaryTargetTypes();
2516
+ init_providerAdapterError();
2517
+ init_nativeCallObservation();
2518
+ init_NativeCallTarget();
2519
+ init_result();
2520
+ init_nativeCallPartialObservation();
2521
+ OPERATION$1 = "observe_native_calls";
2522
+ NATIVE_CALL_OBSERVATION_LIMITATIONS = [
2523
+ "Only entries are observed; return values, floating-point and stack-passed arguments are not captured.",
2524
+ "Registers are the raw integer argument registers at entry. For Objective-C methods the first two hold the receiver and the selector.",
2525
+ "Receiver classes come from LLDB's Objective-C runtime reader without running target code; they are null for class methods and for receivers LLDB cannot classify.",
2526
+ "Calls that never reach a symbol's entry, such as inlined code or objc_direct methods called directly, are not observed.",
2527
+ "The target is launched directly under LLDB, not through LaunchServices; LLDB disables ASLR for it, so load addresses can equal file addresses.",
2528
+ "The observation window is checked about once a second, and recording pauses the process at every entry, which slows it."
2529
+ ];
2530
+ observeNativeCalls = async (target, parameters, tracer, resources, signal) => {
2531
+ if (target.kind !== "executable" || !isMachOFormat(target.format)) return err(new AnalysisCapabilityUnavailableError("native-macos", OPERATION$1, "Native call observation launches a Mach-O executable; the active target is not one"));
2532
+ const parsed = nativeCallObservationInputSchema.safeParse(parameters);
2533
+ if (!parsed.success) return err(new AnalysisInputError(OPERATION$1, { cause: parsed.error }));
2534
+ try {
2535
+ return await resources.run(async () => {
2536
+ const selected = await verifyNativeCallTarget(target, resources, signal);
2537
+ if (!selected.ok) return selected;
2538
+ if (signal?.aborted) return err(new AnalysisCancelledError(OPERATION$1, { cause: signal.reason }));
2539
+ try {
2540
+ const traced = await tracer.trace({
2541
+ executable: target.path,
2542
+ architecture: target.architecture,
2543
+ expectedSha256: target.sha256,
2544
+ input: parsed.data
2545
+ }, signal);
2546
+ if (!traced.ok) return traced;
2547
+ return signal?.aborted ? err(new AnalysisCancelledError(OPERATION$1, {
2548
+ cause: signal.reason,
2549
+ partialObservation: projectPartialNativeCalls(target, parsed.data, traced.value, "cancelled")
2550
+ })) : ok(projectNativeCalls(target, parsed.data, traced.value));
2551
+ } catch (cause) {
2552
+ return err(new ProviderAdapterError("native-macos", OPERATION$1, {
2553
+ cause,
2554
+ diagnostics: { phase: "trace-result" }
2555
+ }));
2556
+ }
2557
+ });
2558
+ } catch (cause) {
2559
+ return err(nativeCallTargetFailure(cause, target.path));
2560
+ }
2561
+ };
2562
+ nativeCallFacts = (target, input, trace) => {
2563
+ const { run } = trace;
2564
+ const unresolved = run.breakpoints.filter(({ location_count: count }) => count === 0).map(({ index }) => index);
2565
+ const eventLimit = run.outcome === "event-limit";
2566
+ const resourceLimit = run.outcome === "resource-limit";
2567
+ const breakpointLocationLimit = run.breakpoint_locations_truncated === true;
2568
+ const partial = eventLimit || resourceLimit || breakpointLocationLimit || run.outcome === "duration-elapsed" || run.outcome === "stop-limit" || unresolved.length > 0;
2569
+ return {
2570
+ target: {
2571
+ path: target.path,
2572
+ sha256: target.sha256,
2573
+ architecture: target.architecture,
2574
+ arguments: input.arguments,
2575
+ environment: input.environment,
2576
+ working_directory: input.working_directory ?? null,
2577
+ launch_identity: {
2578
+ loaded_image_sha256: run.target_identity.loaded_image_sha256,
2579
+ file_device: run.target_identity.file_device,
2580
+ file_inode: run.target_identity.file_inode,
2581
+ selected_file_sha256: run.target_identity.selected_file_sha256,
2582
+ module_path: run.target_identity.module_path,
2583
+ module_uuid: run.target_identity.module_uuid,
2584
+ stable: run.target_identity.stable
2585
+ }
2586
+ },
2587
+ debugger: trace.debugger,
2588
+ process: {
2589
+ pid: run.pid,
2590
+ outcome: run.outcome,
2591
+ exit_status: run.exit_status,
2592
+ exit_description: run.exit_description,
2593
+ terminated: run.terminated && trace.terminated,
2594
+ elapsed_ms: run.elapsed_ms,
2595
+ stdout: trace.stdout,
2596
+ stderr: trace.stderr,
2597
+ other_stops: run.other_stops
2598
+ },
2599
+ breakpoints: input.breakpoints.map((request, index) => ({
2600
+ index,
2601
+ request: request.kind === "function" ? {
2602
+ ...request,
2603
+ module: request.module ?? null
2604
+ } : {
2605
+ ...request,
2606
+ class_name: request.class_name ?? null
2607
+ },
2608
+ location_count: run.breakpoints[index]?.location_count ?? 0,
2609
+ locations: run.breakpoints[index]?.locations ?? []
2610
+ })),
2611
+ events: run.events,
2612
+ coverage: {
2613
+ status: partial ? "partial" : "complete",
2614
+ event_limit_reached: eventLimit,
2615
+ resource_limit_reached: resourceLimit,
2616
+ ...breakpointLocationLimit ? { breakpoint_locations_truncated: true } : {},
2617
+ unresolved_breakpoints: unresolved
2618
+ },
2619
+ limitations: [
2620
+ ...NATIVE_CALL_OBSERVATION_LIMITATIONS,
2621
+ "The selected pathname digest and LLDB module identity are checked around launch. No immutable executable snapshot is used; concurrent in-place mutation or replacement and restoration cannot be ruled out, so the loaded-image digest remains unknown.",
2622
+ ...eventLimit ? [`Observation stopped at max_events (${input.max_events}); later calls were not recorded and the process was killed.`] : [],
2623
+ ...resourceLimit ? ["Observation stopped before retaining the next complete event because the estimated 8 MiB trace-payload or 65,536-frame aggregate budget was reached; the process was killed."] : [],
2624
+ ...run.outcome === "duration-elapsed" ? [`The process was still running after duration_ms (${input.duration_ms}) and was killed.`] : [],
2625
+ ...run.target_identity.stable ? [] : ["LLDB did not provide enough module identity evidence to confirm pathname and module continuity around launch."],
2626
+ ...run.outcome === "stop-limit" ? ["Observation stopped after repeated signal or exception stops; the process was killed."] : [],
2627
+ ...unresolved.length === 0 ? [] : [`Breakpoints ${unresolved.join(", ")} matched no code in any image loaded while observing; their calls could not be observed.`],
2628
+ ...run.breakpoints.some(({ location_count: count, locations }) => locations.length < count) ? ["Breakpoints with many matching locations list only the first 64; location_count gives the total."] : [],
2629
+ ...breakpointLocationLimit ? ["Resolved breakpoint locations exceeded the aggregate 8 MiB metadata budget; omitted locations are counted in location_count. This metadata limit does not change the process outcome."] : [],
2630
+ ...trace.stdout === null || trace.stderr === null ? ["One or more target output captures were unavailable."] : [],
2631
+ ...trace.stdout?.truncated === true || trace.stderr?.truncated === true ? ["Target output beyond 1 MiB per stream is counted but not kept."] : [],
2632
+ ...trace.stdout?.complete === false || trace.stderr?.complete === false ? ["Target output draining did not complete; reported byte counts are observed lower bounds, not stream totals."] : [],
2633
+ ...run.terminated && trace.terminated ? [] : [`REA could not confirm that process ${run.pid} exited; check for it before relying on host state.`]
2634
+ ]
2635
+ };
2636
+ };
2637
+ projectNativeCalls = (target, input, trace) => nativeCallObservationResultSchema.parse(nativeCallFacts(target, input, trace));
2638
+ projectPartialNativeCalls = (target, input, trace, reason) => {
2639
+ const facts = nativeCallFacts(target, input, trace);
2640
+ return nativeCallPartialObservationSchema.parse({
2641
+ ...facts,
2642
+ kind: "native-call-observation",
2643
+ coverage: {
2644
+ ...facts.coverage,
2645
+ status: "partial",
2646
+ reason
2647
+ }
2648
+ });
2649
+ };
2650
+ })))();
2651
+ }
2652
+
2653
+ //#endregion
2654
+ //#region dist/native/LldbReadbackFiles.js
2655
+ var LldbReadbackFiles;
2656
+ function init_LldbReadbackFiles() {
2657
+ return (init_LldbReadbackFiles = __esmMin((() => {
2658
+ init_result();
2659
+ init_ArtifactResourceScope();
2660
+ init_ArtifactFileOperation();
2661
+ LldbReadbackFiles = class {
2662
+ #resources = new ArtifactResourceScope();
2663
+ #targetPids = new Map();
2664
+ #failed = new Map();
2665
+ get hasPending() {
2666
+ return this.#resources.hasPending;
2667
+ }
2668
+ get cleanupResources() {
2669
+ return [...new Set([...this.#failed].filter(([lease]) => !lease.released).map(([, failure]) => failure.path))];
2670
+ }
2671
+ get cleanupCause() {
2672
+ const failures = [...this.#failed].filter(([lease]) => !lease.released).map(([, failure]) => failure.cause);
2673
+ return failures.length === 0 ? undefined : new AggregateError(failures, "LLDB readback descriptors remain open or unconfirmed");
2674
+ }
2675
+ /** Preserve a completed value even if final close transfers its owner here. */
2676
+ async read(path, read) {
2677
+ const blocked = [...this.#failed].find(([lease, failure]) => !lease.released && failure.path === path);
2678
+ if (blocked !== undefined) return err(blocked[1].cause);
2679
+ let completed;
2680
+ try {
2681
+ return ok(await withArtifactRegularFile(path, this.#resources, undefined, async (handle) => {
2682
+ const value = await read(handle);
2683
+ completed = { value };
2684
+ return value;
2685
+ }));
2686
+ } catch (cause) {
2687
+ if (cause instanceof ArtifactFileCleanupFailure) this.#failed.set(cause.cleanupLease, {
2688
+ path,
2689
+ cause
2690
+ });
2691
+ return completed === undefined ? err(cause) : ok(completed.value);
2692
+ }
2693
+ }
2694
+ /** The producer publishes one target PID per runtime; retain its parsed fact. */
2695
+ async readTargetPid(path) {
2696
+ const known = this.#targetPids.get(path);
2697
+ if (known !== undefined) return known;
2698
+ const contents = await this.read(path, async (file) => (await file.readFile("utf8")).trim());
2699
+ if (!contents.ok || !/^[1-9]\d*$/u.test(contents.value)) return undefined;
2700
+ const pid = Number(contents.value);
2701
+ if (!Number.isSafeInteger(pid)) return undefined;
2702
+ this.#targetPids.set(path, pid);
2703
+ return pid;
2704
+ }
2705
+ async retryCleanup() {
2706
+ try {
2707
+ await this.#resources.retryCleanup();
2708
+ } finally {
2709
+ for (const lease of this.#failed.keys()) if (lease.released) this.#failed.delete(lease);
2710
+ }
2711
+ }
2064
2712
  };
2065
2713
  })))();
2066
2714
  }
@@ -2166,60 +2814,35 @@ function init_LldbRetainedObservations() {
2166
2814
  };
2167
2815
  };
2168
2816
  readPrefix = (handle, requestedBytes) => readBoundedPrefix(requestedBytes, async (buffer, offset, length, position) => (await handle.read(buffer, offset, length, position)).bytesRead);
2169
- readLldbObservationJournal = async (path) => {
2170
- let handle;
2171
- try {
2172
- handle = await open(path, "r");
2173
- const { size } = await handle.stat();
2174
- const length = Math.min(size, LLDB_OBSERVATION_JOURNAL_MAX_BYTES);
2175
- const { buffer, bytesRead } = await readPrefix(handle, length);
2176
- const parsed = parseLldbObservationJournal(buffer.subarray(0, bytesRead));
2177
- const limitations = [...size > 8388608 ? ["The observation journal exceeded 8 MiB; only its bounded prefix was read."] : [], ...bytesRead < length ? ["The observation journal became shorter while being read; the available prefix was parsed."] : []];
2178
- return {
2179
- parsed,
2180
- limitations
2181
- };
2182
- } catch (cause) {
2183
- return {
2184
- parsed: {
2185
- events: [],
2186
- otherStops: [],
2187
- limitations: []
2188
- },
2189
- limitations: [`The observation journal could not be read: ${cause instanceof Error ? cause.message : String(cause)}`]
2190
- };
2191
- } finally {
2192
- await handle?.close().catch(() => undefined);
2193
- }
2194
- };
2195
- readPartialCapture = async (path) => {
2196
- let handle;
2197
- try {
2198
- handle = await open(path, "r");
2199
- const { size } = await handle.stat();
2200
- const length = Math.min(size, MAX_CAPTURE_BYTES);
2201
- const { buffer, bytesRead } = await readPrefix(handle, length);
2202
- return {
2203
- capture: {
2204
- text: buffer.subarray(0, bytesRead).toString("utf8"),
2205
- bytes: Math.max(size, bytesRead),
2206
- truncated: true,
2207
- complete: false
2208
- },
2209
- limitations: bytesRead < length ? ["A target output capture became shorter while being read; its retained prefix may be incomplete."] : []
2210
- };
2211
- } catch {
2212
- return null;
2213
- } finally {
2214
- await handle?.close().catch(() => undefined);
2215
- }
2216
- };
2817
+ readLldbObservationJournal = (path, files) => files.read(path, async (handle) => {
2818
+ const { size } = await handle.stat();
2819
+ const length = Math.min(size, LLDB_OBSERVATION_JOURNAL_MAX_BYTES);
2820
+ const { buffer, bytesRead } = await readPrefix(handle, length);
2821
+ return {
2822
+ parsed: parseLldbObservationJournal(buffer.subarray(0, bytesRead)),
2823
+ limitations: [...size > 8388608 ? ["The observation journal exceeded 8 MiB; only its bounded prefix was read."] : [], ...bytesRead < length ? ["The observation journal became shorter while being read; the available prefix was parsed."] : []]
2824
+ };
2825
+ });
2826
+ readPartialCapture = (path, files) => files.read(path, async (handle) => {
2827
+ const { size } = await handle.stat();
2828
+ const length = Math.min(size, MAX_CAPTURE_BYTES);
2829
+ const { buffer, bytesRead } = await readPrefix(handle, length);
2830
+ return {
2831
+ capture: {
2832
+ text: buffer.subarray(0, bytesRead).toString("utf8"),
2833
+ bytes: Math.max(size, bytesRead),
2834
+ truncated: true,
2835
+ complete: false
2836
+ },
2837
+ limitations: bytesRead < length ? ["A target output capture became shorter while being read; its retained prefix may be incomplete."] : []
2838
+ };
2839
+ });
2217
2840
  })))();
2218
2841
  }
2219
2842
 
2220
2843
  //#endregion
2221
2844
  //#region dist/native/LldbCallTracer.js
2222
- var OPERATION$1, PROVIDER, LLDB_REQUIREMENT, MAX_OUTPUT_BYTES, DEADLINE_GRACE_MS, DIAGNOSTIC_BYTES, BRIDGE, tracedSchema, tracerOutputSchema, ATTACH_REMEDIATION, LldbCallTracer, quote, tracerFailure, partialNativeObservation, partialObservationFromTrace, lldbRuntimePaths, readTracerOutput, capturedOutput, lldbCleanupResources, runLldb, readTargetPid, ensureTerminated, targetTerminationReason, alive;
2845
+ var OPERATION, PROVIDER, LLDB_REQUIREMENT, MAX_OUTPUT_BYTES, DEADLINE_GRACE_MS, DIAGNOSTIC_BYTES, BRIDGE, tracedSchema, tracerOutputSchema, ATTACH_REMEDIATION, LldbCallTracer, quote, tracerFailure, partialNativeObservation, partialObservationFromTrace, lldbRuntimePaths, readTracerOutput, capturedOutput, errorReason, releaseLldbRuntime, bindLldbCleanup, lldbCleanupFailure, lldbCleanupResources, runLldb, ensureTerminated, targetTerminationReason, alive;
2223
2846
  function init_LldbCallTracer() {
2224
2847
  return (init_LldbCallTracer = __esmMin((() => {
2225
2848
  init_snapshotEnvironment();
@@ -2237,8 +2860,13 @@ function init_LldbCallTracer() {
2237
2860
  init_ProviderDeadline();
2238
2861
  init_PrivateRuntimeRoot();
2239
2862
  init_CommandRunner();
2863
+ init_NativeCallObservation();
2864
+ init_LldbReadbackFiles();
2865
+ init_AnalysisCleanupLease();
2866
+ init_analysisErrorCleanup();
2867
+ init_analysisErrorBase();
2240
2868
  init_LldbRetainedObservations();
2241
- OPERATION$1 = "observe_native_calls";
2869
+ OPERATION = "observe_native_calls";
2242
2870
  PROVIDER = "native-macos";
2243
2871
  LLDB_REQUIREMENT = "LLDB from Xcode or the Command Line Tools is not available";
2244
2872
  MAX_OUTPUT_BYTES = 1024 * 1024;
@@ -2297,9 +2925,10 @@ function init_LldbCallTracer() {
2297
2925
  "tracer-error"
2298
2926
  ]),
2299
2927
  error: z.string().nullable(),
2300
- target_process_created: z.boolean().optional()
2928
+ target_process_created: z.boolean().optional(),
2929
+ target_process_exit_observed: z.boolean().optional()
2301
2930
  })]);
2302
- ATTACH_REMEDIATION = "Allow debugging for this user (Developer Tools access: `DevToolsSecurity -enable`, or membership in the _developer group). A hardened-runtime target is debuggable only with the com.apple.security.get-task-allow entitlement; see inspect_signature's debugger-attach facet.";
2931
+ ATTACH_REMEDIATION = "Allow debugging for this user (Developer Tools access: `DevToolsSecurity -enable`, or membership in the _developer group). A hardened-runtime target is debuggable only with the com.apple.security.get-task-allow entitlement; inspect_signature reports hardened_runtime and entitlements.";
2303
2932
  LldbCallTracer = class {
2304
2933
  launch;
2305
2934
  resolveTool;
@@ -2318,15 +2947,27 @@ function init_LldbCallTracer() {
2318
2947
  const pendingCleanup = await this.#retryPendingCleanup();
2319
2948
  if (pendingCleanup !== undefined) return err(pendingCleanup);
2320
2949
  const lldb = await this.resolveTool("lldb", signal);
2321
- if (!lldb.ok) return err(lldb.error.reason === "cancelled" ? new AnalysisCancelledError(OPERATION$1) : new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION$1, LLDB_REQUIREMENT, { userMessage: LLDB_REQUIREMENT }));
2950
+ if (!lldb.ok) return err(lldb.error.reason === "cancelled" ? new AnalysisCancelledError(OPERATION) : new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION, LLDB_REQUIREMENT, { userMessage: LLDB_REQUIREMENT }));
2322
2951
  const root = await PrivateRuntimeRoot.create({ prefix: "rea-lldb-" });
2323
2952
  const paths = lldbRuntimePaths(root.path);
2953
+ const owner = {
2954
+ root,
2955
+ rootLease: new AnalysisCleanupLease(() => root.close(), [root.path]),
2956
+ files: new LldbReadbackFiles(),
2957
+ supervisor: undefined,
2958
+ pidPath: paths.pid,
2959
+ targetIdentity: undefined,
2960
+ targetPid: undefined,
2961
+ processStopped: true,
2962
+ targetStopped: true
2963
+ };
2324
2964
  let result;
2325
2965
  try {
2326
- result = await this.#run(lldb.value, root, request, signal);
2966
+ result = await this.#run(lldb.value, owner, request, signal);
2327
2967
  } catch (cause) {
2328
2968
  const partialObservation = await partialNativeObservation({
2329
2969
  request,
2970
+ files: owner.files,
2330
2971
  pidPath: paths.pid,
2331
2972
  stdoutPath: paths.stdoutCapture,
2332
2973
  stderrPath: paths.stderrCapture,
@@ -2334,44 +2975,51 @@ function init_LldbCallTracer() {
2334
2975
  version: null,
2335
2976
  reason: "tracer-failure"
2336
2977
  });
2337
- const retained = this.#pendingCleanup;
2338
- const resources = retained === undefined ? [] : await lldbCleanupResources(retained);
2339
- result = err(new ProviderAdapterError(PROVIDER, OPERATION$1, {
2978
+ if (!owner.processStopped || !owner.targetStopped || owner.files.hasPending) this.#pendingCleanup = owner;
2979
+ result = err(new ProviderAdapterError(PROVIDER, OPERATION, {
2340
2980
  cause,
2341
- diagnostics: { reason: cause instanceof Error ? cause.message : String(cause) },
2981
+ diagnostics: { reason: errorReason(cause) },
2342
2982
  partialObservation,
2343
- ...retained === undefined ? {} : { cleanup: {
2983
+ ...this.#pendingCleanup === owner ? { cleanup: {
2344
2984
  reason: "LLDB trace failed while owned resources remain",
2345
- resources
2346
- } }
2985
+ resources: lldbCleanupResources(owner)
2986
+ } } : {}
2347
2987
  }));
2348
2988
  }
2349
- if (this.#pendingCleanup?.root === root) return result;
2989
+ if (result.ok && signal?.aborted) result = err(new AnalysisCancelledError(OPERATION, {
2990
+ cause: signal.reason,
2991
+ partialObservation: partialObservationFromTrace(request, result.value, "cancelled")
2992
+ }));
2993
+ if (owner.files.hasPending) this.#pendingCleanup = owner;
2994
+ if (this.#pendingCleanup === owner) {
2995
+ if (!result.ok && result.error.cleanupIncomplete) {
2996
+ if (owner.files.hasPending) {
2997
+ const files = lldbCleanupFailure(owner, "LLDB readback descriptor cleanup remains incomplete", owner.files.cleanupCause);
2998
+ result.error.retainSecondaryFailure(files, { readback_cleanup: projectAnalysisError(files) });
2999
+ }
3000
+ return err(bindLldbCleanup(result.error, owner));
3001
+ }
3002
+ const cleanup = lldbCleanupFailure(owner, "LLDB readback descriptor cleanup remains incomplete", owner.files.cleanupCause, result.ok ? partialObservationFromTrace(request, result.value) : undefined);
3003
+ return result.ok ? err(cleanup) : err(analysisErrorWithCleanupFailure(result.error, cleanup, OPERATION).bindCleanupDependencies([result.error, cleanup]));
3004
+ }
3005
+ let rootCleanup;
2350
3006
  try {
2351
- await root.close();
3007
+ await releaseLldbRuntime(owner);
3008
+ rootCleanup = ok(undefined);
2352
3009
  } catch (cause) {
2353
- this.#pendingCleanup = {
2354
- root,
2355
- supervisor: undefined,
2356
- pidPath: paths.pid,
2357
- targetIdentity: undefined,
2358
- processStopped: true,
2359
- targetStopped: true
2360
- };
2361
- const partialObservation = result.ok ? partialObservationFromTrace(request, result.value) : result.error.partialObservation;
2362
- return err(new ProviderCleanupError(PROVIDER, [root.path], {
2363
- reason: cause instanceof Error ? cause.message : String(cause),
2364
- ...result.ok ? {} : {
2365
- execution_failure: projectAnalysisError(result.error).code,
2366
- primary_failure: result.error.message
2367
- }
2368
- }, {
2369
- operation: OPERATION$1,
2370
- cause: result.ok ? cause : new AggregateError([result.error, cause], "LLDB trace and runtime cleanup both failed"),
2371
- ...partialObservation === undefined ? {} : { partialObservation }
2372
- }));
3010
+ rootCleanup = err(cause);
3011
+ this.#pendingCleanup = owner;
2373
3012
  }
2374
- return result;
3013
+ if (result.ok && signal?.aborted) result = err(new AnalysisCancelledError(OPERATION, {
3014
+ cause: signal.reason,
3015
+ partialObservation: partialObservationFromTrace(request, result.value, "cancelled")
3016
+ }));
3017
+ if (!rootCleanup.ok) {
3018
+ const cleanup = lldbCleanupFailure(owner, errorReason(rootCleanup.error), rootCleanup.error, result.ok ? partialObservationFromTrace(request, result.value) : undefined);
3019
+ if (!result.ok && result.error.cleanupIncomplete) bindLldbCleanup(result.error, owner);
3020
+ return result.ok ? err(cleanup) : err(analysisErrorWithCleanupFailure(result.error, cleanup, OPERATION).bindCleanupDependencies([result.error, cleanup]));
3021
+ }
3022
+ return result.ok ? result : err(resolvedAnalysisError(bindLldbCleanup(result.error, owner)));
2375
3023
  }
2376
3024
  /** Retry retained LLDB cleanup without abandoning its process or runtime owner. */
2377
3025
  async close() {
@@ -2389,37 +3037,50 @@ function init_LldbCallTracer() {
2389
3037
  async #retryPendingCleanup() {
2390
3038
  const owner = this.#pendingCleanup;
2391
3039
  if (owner === undefined) return undefined;
2392
- let firstFailure;
3040
+ const failures = [];
3041
+ try {
3042
+ await owner.files.retryCleanup();
3043
+ } catch (cause) {
3044
+ failures.push(cause);
3045
+ }
2393
3046
  if (!owner.processStopped) {
2394
- const stopped = await owner.supervisor?.stop();
2395
- if (stopped?.status === "incomplete") firstFailure = stopped.reason;
3047
+ if (owner.supervisor === undefined) failures.push(new Error("LLDB process cleanup ownership was unavailable"));
2396
3048
  else {
2397
- owner.supervisor?.dispose();
2398
- owner.processStopped = true;
3049
+ try {
3050
+ const stopped = await owner.supervisor.stop();
3051
+ if (stopped.status === "incomplete") failures.push(new Error(stopped.reason));
3052
+ else {
3053
+ owner.supervisor.dispose();
3054
+ owner.processStopped = true;
3055
+ }
3056
+ } catch (cause) {
3057
+ failures.push(cause);
3058
+ }
2399
3059
  }
2400
3060
  }
2401
- if (firstFailure === undefined && !owner.targetStopped) {
2402
- const targetTermination = await ensureTerminated(owner.pidPath, owner.targetIdentity, true);
2403
- if (targetTermination !== "terminated") firstFailure = targetTerminationReason(targetTermination);
2404
- else owner.targetStopped = true;
3061
+ if (owner.processStopped && !owner.targetStopped) {
3062
+ owner.targetPid = await owner.files.readTargetPid(owner.pidPath);
3063
+ try {
3064
+ const targetTermination = await ensureTerminated(owner.targetPid, owner.targetIdentity);
3065
+ if (targetTermination !== "terminated") failures.push(new Error(targetTerminationReason(targetTermination)));
3066
+ else owner.targetStopped = true;
3067
+ } catch (cause) {
3068
+ failures.push(cause);
3069
+ }
2405
3070
  }
2406
- if (firstFailure === undefined) {
3071
+ if (failures.length === 0) {
2407
3072
  try {
2408
- await owner.root.close();
3073
+ await releaseLldbRuntime(owner);
2409
3074
  this.#pendingCleanup = undefined;
2410
3075
  return undefined;
2411
3076
  } catch (cause) {
2412
- firstFailure = cause instanceof Error ? cause.message : String(cause);
3077
+ failures.push(cause);
2413
3078
  }
2414
3079
  }
2415
- const resources = await lldbCleanupResources(owner);
2416
- return new ProviderCleanupError(PROVIDER, resources, {
2417
- reason: firstFailure ?? "LLDB cleanup remains incomplete",
2418
- resources
2419
- }, { operation: OPERATION$1 });
3080
+ return lldbCleanupFailure(owner, failures.map(errorReason).join("; "), new AggregateError(failures, "LLDB cleanup remains incomplete"));
2420
3081
  }
2421
- async #run(lldb, root, request, signal) {
2422
- const directory = root.path;
3082
+ async #run(lldb, retained, request, signal) {
3083
+ const directory = retained.root.path;
2423
3084
  const paths = lldbRuntimePaths(directory);
2424
3085
  const { input } = request;
2425
3086
  await writeFile(paths.config, JSON.stringify({
@@ -2450,6 +3111,9 @@ function init_LldbCallTracer() {
2450
3111
  identity_ack_path: paths.identityAck,
2451
3112
  observation_path: paths.observations
2452
3113
  }), { mode: 384 });
3114
+ retained.processStopped = false;
3115
+ retained.targetStopped = false;
3116
+ this.#pendingCleanup = retained;
2453
3117
  const exited = await this.launch(lldb.path, [
2454
3118
  "--batch",
2455
3119
  "--no-lldbinit",
@@ -2463,31 +3127,30 @@ function init_LldbCallTracer() {
2463
3127
  pidPath: paths.pid,
2464
3128
  identityAckPath: paths.identityAck,
2465
3129
  environment: this.environment,
3130
+ files: retained.files,
2466
3131
  ...signal === undefined ? {} : { signal }
2467
3132
  });
2468
- const retained = {
2469
- root,
2470
- supervisor: exited.cleanupOwner,
2471
- pidPath: paths.pid,
2472
- targetIdentity: exited.targetIdentity,
2473
- processStopped: exited.cleanupOwner === undefined,
2474
- targetStopped: !exited.targetLaunched
2475
- };
2476
- this.#pendingCleanup = retained;
2477
- const output = exited.kind === "exited" ? await readTracerOutput(paths.result) : undefined;
2478
- let targetTermination = exited.targetLaunched ? await ensureTerminated(paths.pid, exited.targetIdentity, true) : "terminated";
2479
- if (output !== undefined && output.status !== "traced" && output.target_process_created === false && await readTargetPid(paths.pid) === undefined) targetTermination = "terminated";
3133
+ retained.supervisor = exited.cleanupOwner;
3134
+ retained.targetIdentity = exited.targetIdentity;
3135
+ retained.processStopped = exited.cleanupOwner === undefined && exited.cleanupFailure === undefined;
3136
+ retained.targetStopped = !exited.targetLaunched;
3137
+ const output = exited.kind === "exited" ? await readTracerOutput(paths.result, retained.files) : undefined;
3138
+ const bridgeObservedExit = output !== undefined && output.status !== "traced" && output.target_process_exit_observed === true;
3139
+ retained.targetPid = await retained.files.readTargetPid(paths.pid);
3140
+ let targetTermination = exited.targetLaunched && !bridgeObservedExit ? await ensureTerminated(retained.targetPid, exited.targetIdentity) : "terminated";
3141
+ if (output !== undefined && output.status !== "traced" && output.target_process_created === false && retained.targetPid === undefined) targetTermination = "terminated";
2480
3142
  retained.targetStopped = targetTermination === "terminated";
2481
- if (retained.processStopped && retained.targetStopped) this.#pendingCleanup = undefined;
3143
+ if (retained.processStopped && retained.targetStopped && !retained.files.hasPending) this.#pendingCleanup = undefined;
2482
3144
  const terminated = targetTermination === "terminated";
2483
3145
  const cleanupDetails = [exited.cleanupFailure, ...terminated ? [] : [targetTerminationReason(targetTermination)]].filter((detail) => detail !== undefined);
2484
3146
  const lifecycleCleanup = cleanupDetails.length === 0 ? undefined : {
2485
3147
  reason: cleanupDetails.join("; "),
2486
- resources: await lldbCleanupResources(retained)
3148
+ resources: lldbCleanupResources(retained)
2487
3149
  };
2488
3150
  const partialReason = exited.kind === "cancelled" ? "cancelled" : exited.kind === "timeout" ? "timeout" : exited.cleanupFailure !== undefined ? "cleanup-failure" : "tracer-failure";
2489
3151
  const getPartialObservation = (reason = partialReason) => partialNativeObservation({
2490
3152
  request,
3153
+ files: retained.files,
2491
3154
  pidPath: paths.pid,
2492
3155
  stdoutPath: paths.stdoutCapture,
2493
3156
  stderrPath: paths.stderrCapture,
@@ -2495,31 +3158,32 @@ function init_LldbCallTracer() {
2495
3158
  version: output?.status === "traced" ? output.version : null,
2496
3159
  reason
2497
3160
  });
2498
- if (exited.kind === "cancelled") return err(new AnalysisCancelledError(OPERATION$1, {
3161
+ if (exited.kind === "cancelled") return err(new AnalysisCancelledError(OPERATION, {
3162
+ cause: signal?.reason,
2499
3163
  ...lifecycleCleanup === undefined ? {} : { cleanup: lifecycleCleanup },
2500
3164
  partialObservation: await getPartialObservation()
2501
3165
  }));
2502
- if (exited.kind === "timeout") return err(new AnalysisTimeoutError(OPERATION$1, input.duration_ms + DEADLINE_GRACE_MS, {
3166
+ if (exited.kind === "timeout") return err(new AnalysisTimeoutError(OPERATION, input.duration_ms + DEADLINE_GRACE_MS, {
2503
3167
  ...lifecycleCleanup === undefined ? {} : { cleanup: lifecycleCleanup },
2504
3168
  partialObservation: await getPartialObservation()
2505
3169
  }));
2506
3170
  if (output !== undefined && output.status !== "traced") return err(tracerFailure(output, lifecycleCleanup, await getPartialObservation()));
2507
- if (exited.cleanupFailure !== undefined) return err(new ProviderCleanupError(PROVIDER, await lldbCleanupResources(retained), {
3171
+ if (exited.cleanupFailure !== undefined) return err(new ProviderCleanupError(PROVIDER, lldbCleanupResources(retained), {
2508
3172
  reason: "LLDB process-group cleanup could not be verified",
2509
3173
  cleanup_failure: exited.cleanupFailure,
2510
3174
  ...lifecycleCleanup === undefined ? {} : { target_cleanup: lifecycleCleanup }
2511
3175
  }, {
2512
- operation: OPERATION$1,
3176
+ operation: OPERATION,
2513
3177
  partialObservation: await getPartialObservation()
2514
3178
  }));
2515
- if (!terminated) return err(new ProviderCleanupError(PROVIDER, await lldbCleanupResources(retained), {
3179
+ if (!terminated) return err(new ProviderCleanupError(PROVIDER, lldbCleanupResources(retained), {
2516
3180
  reason: "LLDB target process termination could not be verified",
2517
3181
  ...lifecycleCleanup === undefined ? {} : { target_cleanup: lifecycleCleanup }
2518
3182
  }, {
2519
- operation: OPERATION$1,
3183
+ operation: OPERATION,
2520
3184
  partialObservation: await getPartialObservation()
2521
3185
  }));
2522
- if (output === undefined) return err(new ProviderAdapterError(PROVIDER, OPERATION$1, {
3186
+ if (output === undefined) return err(new ProviderAdapterError(PROVIDER, OPERATION, {
2523
3187
  diagnostics: {
2524
3188
  reason: "LLDB exited without a tracer result",
2525
3189
  exit_code: exited.exitCode,
@@ -2529,16 +3193,29 @@ function init_LldbCallTracer() {
2529
3193
  partialObservation: await getPartialObservation(),
2530
3194
  ...lifecycleCleanup === undefined ? {} : { cleanup: lifecycleCleanup }
2531
3195
  }));
2532
- const stdout = await capturedOutput(paths.stdoutCapture, output.target_output.stdout_bytes, output.target_output.stdout_truncated, output.target_output.stdout_complete);
2533
- const stderr = await capturedOutput(paths.stderrCapture, output.target_output.stderr_bytes, output.target_output.stderr_truncated, output.target_output.stderr_complete);
3196
+ const stdout = await capturedOutput(paths.stdoutCapture, output.target_output.stdout_bytes, output.target_output.stdout_truncated, output.target_output.stdout_complete, retained.files);
3197
+ const stderr = await capturedOutput(paths.stderrCapture, output.target_output.stderr_bytes, output.target_output.stderr_truncated, output.target_output.stderr_complete, retained.files);
2534
3198
  if (!stdout.ok || !stderr.ok) {
2535
- const partial = await getPartialObservation("capture-failure");
2536
- return err(new ProviderAdapterError(PROVIDER, OPERATION$1, {
2537
- partialObservation: partial,
3199
+ return err(new ProviderAdapterError(PROVIDER, OPERATION, {
3200
+ cause: new AggregateError([...stdout.ok ? [] : [stdout.error], ...stderr.ok ? [] : [stderr.error]], "LLDB capture readback failed"),
3201
+ partialObservation: projectPartialNativeCalls({
3202
+ path: request.executable,
3203
+ sha256: request.expectedSha256,
3204
+ architecture: request.architecture
3205
+ }, request.input, {
3206
+ debugger: {
3207
+ ...lldb,
3208
+ version: output.version
3209
+ },
3210
+ run: output,
3211
+ stdout: stdout.ok ? stdout.value : null,
3212
+ stderr: stderr.ok ? stderr.value : null,
3213
+ terminated
3214
+ }, "capture-failure"),
2538
3215
  diagnostics: {
2539
3216
  reason: "LLDB target output capture could not be read",
2540
- ...stdout.ok ? {} : { stdout_capture_error: stdout.error },
2541
- ...stderr.ok ? {} : { stderr_capture_error: stderr.error },
3217
+ ...stdout.ok ? {} : { stdout_capture_error: errorReason(stdout.error) },
3218
+ ...stderr.ok ? {} : { stderr_capture_error: errorReason(stderr.error) },
2542
3219
  ...lifecycleCleanup === undefined ? {} : { target_cleanup: lifecycleCleanup }
2543
3220
  },
2544
3221
  ...lifecycleCleanup === undefined ? {} : { cleanup: lifecycleCleanup }
@@ -2564,29 +3241,29 @@ function init_LldbCallTracer() {
2564
3241
  };
2565
3242
  const message = output.error ?? "no LLDB error text";
2566
3243
  if (output.status === "target-integrity-error") return new EvidenceIntegrityError(message || "The launched native target did not match its session digest", options);
2567
- if (output.status === "target-identity-unavailable") return new ProviderAdapterError(PROVIDER, OPERATION$1, {
3244
+ if (output.status === "target-identity-unavailable") return new ProviderAdapterError(PROVIDER, OPERATION, {
2568
3245
  ...options,
2569
3246
  diagnostics: {
2570
3247
  reason: message,
2571
3248
  constraint: "target process start identity could not be verified"
2572
3249
  }
2573
3250
  });
2574
- if (output.status === "tracer-error") return new ProviderAdapterError(PROVIDER, OPERATION$1, {
3251
+ if (output.status === "tracer-error") return new ProviderAdapterError(PROVIDER, OPERATION, {
2575
3252
  ...options,
2576
3253
  diagnostics: { reason: `LLDB bridge failed: ${message}` }
2577
3254
  });
2578
- if (output.status === "target-error") return new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION$1, `lldb-target-unloadable: ${message}`, options);
2579
- return /attach|not allowed|permission|denied|debugserver/iu.test(message) ? new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION$1, `debugger-attach-denied: ${message}`, {
3255
+ if (output.status === "target-error") return new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION, `lldb-target-unloadable: ${message}`, options);
3256
+ return /attach|not allowed|permission|denied|debugserver/iu.test(message) ? new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION, `debugger-attach-denied: ${message}`, {
2580
3257
  userMessage: ATTACH_REMEDIATION,
2581
3258
  ...options
2582
- }) : new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION$1, `launch-failed: ${message}`, options);
3259
+ }) : new AnalysisCapabilityUnavailableError(PROVIDER, OPERATION, `launch-failed: ${message}`, options);
2583
3260
  };
2584
3261
  partialNativeObservation = async (options) => {
2585
3262
  const [journal, pid, stdout, stderr] = await Promise.all([
2586
- readLldbObservationJournal(options.observationPath),
2587
- readTargetPid(options.pidPath),
2588
- readPartialCapture(options.stdoutPath),
2589
- readPartialCapture(options.stderrPath)
3263
+ readLldbObservationJournal(options.observationPath, options.files),
3264
+ options.files.readTargetPid(options.pidPath),
3265
+ readPartialCapture(options.stdoutPath, options.files),
3266
+ readPartialCapture(options.stderrPath, options.files)
2590
3267
  ]);
2591
3268
  return projectLldbPartialObservation({
2592
3269
  target: {
@@ -2598,35 +3275,26 @@ function init_LldbCallTracer() {
2598
3275
  working_directory: options.request.input.working_directory ?? null
2599
3276
  },
2600
3277
  pid,
2601
- stdout: stdout?.capture ?? null,
2602
- stderr: stderr?.capture ?? null,
3278
+ stdout: stdout.ok ? stdout.value.capture : null,
3279
+ stderr: stderr.ok ? stderr.value.capture : null,
2603
3280
  version: options.version,
2604
- journal: journal.parsed,
2605
- journalLimitations: journal.limitations,
2606
- limitations: [...stdout?.limitations ?? [], ...stderr?.limitations ?? []],
3281
+ journal: journal.ok ? journal.value.parsed : {
3282
+ events: [],
3283
+ otherStops: [],
3284
+ limitations: []
3285
+ },
3286
+ journalLimitations: journal.ok ? journal.value.limitations : [`The observation journal could not be read: ${errorReason(journal.error)}`],
3287
+ limitations: [...stdout.ok ? stdout.value.limitations : [`The target stdout capture could not be read: ${errorReason(stdout.error)}`], ...stderr.ok ? stderr.value.limitations : [`The target stderr capture could not be read: ${errorReason(stderr.error)}`]],
2607
3288
  reason: options.reason
2608
3289
  });
2609
3290
  };
2610
- partialObservationFromTrace = (request, trace) => projectLldbPartialObservation({
2611
- target: {
3291
+ partialObservationFromTrace = (request, trace, reason = "cleanup-failure") => {
3292
+ return projectPartialNativeCalls({
2612
3293
  path: request.executable,
2613
3294
  sha256: request.expectedSha256,
2614
- architecture: request.architecture,
2615
- arguments: request.input.arguments,
2616
- environment: request.input.environment,
2617
- working_directory: request.input.working_directory ?? null
2618
- },
2619
- pid: trace.run.pid,
2620
- stdout: trace.stdout,
2621
- stderr: trace.stderr,
2622
- version: trace.run.version,
2623
- journal: {
2624
- events: trace.run.events,
2625
- otherStops: trace.run.other_stops,
2626
- limitations: []
2627
- },
2628
- reason: "cleanup-failure"
2629
- });
3295
+ architecture: request.architecture
3296
+ }, request.input, trace, reason);
3297
+ };
2630
3298
  lldbRuntimePaths = (directory) => ({
2631
3299
  config: join(directory, "config.json"),
2632
3300
  result: join(directory, "result.json"),
@@ -2638,50 +3306,48 @@ function init_LldbCallTracer() {
2638
3306
  stderrCapture: join(directory, "stderr.capture"),
2639
3307
  observations: join(directory, "observations.jsonl")
2640
3308
  });
2641
- readTracerOutput = async (path) => {
2642
- let text;
2643
- try {
2644
- text = await readFile(path, "utf8");
2645
- } catch {
2646
- return undefined;
2647
- }
2648
- const parsed = safeParseJson(text);
3309
+ readTracerOutput = async (path, files) => {
3310
+ const text = await files.read(path, (file) => file.readFile("utf8"));
3311
+ if (!text.ok) return undefined;
3312
+ const parsed = safeParseJson(text.value);
2649
3313
  if (!parsed.ok) return undefined;
2650
3314
  const output = tracerOutputSchema.safeParse(parsed.value);
2651
3315
  return output.success ? output.data : undefined;
2652
3316
  };
2653
- capturedOutput = async (path, observedBytes, truncated, complete) => {
2654
- let handle;
2655
- try {
2656
- handle = await open(path, "r");
2657
- const { size } = await handle.stat();
2658
- const captureHandle = handle;
2659
- const { buffer, bytesRead } = await readBoundedPrefix(Math.min(size, MAX_OUTPUT_BYTES), async (target, offset, length, position) => (await captureHandle.read(target, offset, length, position)).bytesRead);
2660
- const captured = {
2661
- text: buffer.subarray(0, bytesRead).toString("utf8"),
2662
- bytes: observedBytes,
2663
- truncated: truncated || size > MAX_OUTPUT_BYTES,
2664
- complete: complete && bytesRead >= Math.min(observedBytes, MAX_OUTPUT_BYTES)
2665
- };
2666
- await handle.close();
2667
- handle = undefined;
2668
- return ok(captured);
2669
- } catch (cause) {
2670
- const failure = cause instanceof Error ? cause.message : String(cause);
2671
- if (handle !== undefined) {
2672
- try {
2673
- await handle.close();
2674
- } catch (closeCause) {
2675
- return err(`${failure}; closing capture file failed: ${closeCause instanceof Error ? closeCause.message : String(closeCause)}`);
2676
- }
2677
- }
2678
- return err(failure);
3317
+ capturedOutput = (path, observedBytes, truncated, complete, files) => files.read(path, async (handle) => {
3318
+ const { size } = await handle.stat();
3319
+ const { buffer, bytesRead } = await readBoundedPrefix(Math.min(size, MAX_OUTPUT_BYTES), async (target, offset, length, position) => (await handle.read(target, offset, length, position)).bytesRead);
3320
+ return {
3321
+ text: buffer.subarray(0, bytesRead).toString("utf8"),
3322
+ bytes: observedBytes,
3323
+ truncated: truncated || size > MAX_OUTPUT_BYTES,
3324
+ complete: complete && bytesRead >= Math.min(observedBytes, MAX_OUTPUT_BYTES)
3325
+ };
3326
+ });
3327
+ errorReason = (cause) => cause instanceof Error ? cause.message : String(cause);
3328
+ releaseLldbRuntime = async (owner) => {
3329
+ if (!owner.processStopped || !owner.targetStopped || owner.files.hasPending) throw new Error("LLDB runtime still owns unresolved child resources");
3330
+ await owner.rootLease.release();
3331
+ };
3332
+ bindLldbCleanup = (failure, owner) => {
3333
+ if (failure.cleanupIncomplete) {
3334
+ owner.rootLease.bindCleanupError(failure);
3335
+ failure.bindCleanupResourceOwner({ get cleanupResources() {
3336
+ return lldbCleanupResources(owner);
3337
+ } });
2679
3338
  }
3339
+ return failure;
2680
3340
  };
2681
- lldbCleanupResources = async (owner) => [
3341
+ lldbCleanupFailure = (owner, reason, cause, partialObservation) => bindLldbCleanup(new ProviderCleanupError(PROVIDER, lldbCleanupResources(owner), { reason }, {
3342
+ operation: OPERATION,
3343
+ cause,
3344
+ partialObservation
3345
+ }), owner);
3346
+ lldbCleanupResources = (owner) => [
2682
3347
  ...owner.processStopped ? [] : ["lldb-process-group"],
2683
- ...owner.targetStopped ? [] : [`native-target:${String(await readTargetPid(owner.pidPath) ?? "unknown")}`],
2684
- owner.root.path
3348
+ ...owner.targetStopped ? [] : [`native-target:${String(owner.targetPid ?? "unknown")}`],
3349
+ ...owner.files.cleanupResources,
3350
+ ...owner.rootLease.released ? [] : [owner.root.path]
2685
3351
  ];
2686
3352
  runLldb = async (executable, arguments_, options) => {
2687
3353
  if (options.signal?.aborted === true) return {
@@ -2721,7 +3387,7 @@ function init_LldbCallTracer() {
2721
3387
  }, { maxDiagnosticBytes: DIAGNOSTIC_BYTES });
2722
3388
  let identityAckWritten = false;
2723
3389
  while (!await supervisor.waitForOutputClose(20)) {
2724
- const pid = await readTargetPid(options.pidPath);
3390
+ const pid = await options.files.readTargetPid(options.pidPath);
2725
3391
  if (pid !== undefined && !identityAckWritten) {
2726
3392
  let observation;
2727
3393
  try {
@@ -2756,20 +3422,8 @@ function init_LldbCallTracer() {
2756
3422
  deadline.dispose();
2757
3423
  }
2758
3424
  };
2759
- readTargetPid = async (pidPath) => {
2760
- try {
2761
- const contents = (await readFile(pidPath, "utf8")).trim();
2762
- if (!/^[1-9]\d*$/u.test(contents)) return undefined;
2763
- const pid = Number(contents);
2764
- return Number.isSafeInteger(pid) ? pid : undefined;
2765
- } catch {
2766
- return undefined;
2767
- }
2768
- };
2769
- ensureTerminated = async (pidPath, identity, missingPidIsUnknown) => {
2770
- const pid = await readTargetPid(pidPath);
2771
- if (pid === undefined) return missingPidIsUnknown ? "identity-unavailable" : "terminated";
2772
- if (!Number.isSafeInteger(pid) || pid <= 0) return "identity-unavailable";
3425
+ ensureTerminated = async (pid, identity) => {
3426
+ if (pid === undefined) return "identity-unavailable";
2773
3427
  let signalDisposition;
2774
3428
  for (let attempt = 0; attempt < 20; attempt++) {
2775
3429
  if (!alive(pid)) return "terminated";
@@ -2806,150 +3460,12 @@ function init_LldbCallTracer() {
2806
3460
  })))();
2807
3461
  }
2808
3462
 
2809
- //#endregion
2810
- //#region dist/native/NativeCallObservation.js
2811
- var OPERATION, NATIVE_CALL_OBSERVATION_LIMITATIONS, observeNativeCalls, isAbortError, projectNativeCalls, fileSha256;
2812
- function init_NativeCallObservation() {
2813
- return (init_NativeCallObservation = __esmMin((() => {
2814
- init_analysisErrorCore();
2815
- init_binaryTargetTypes();
2816
- init_evidenceErrors();
2817
- init_providerAdapterError();
2818
- init_nativeCallObservation();
2819
- init_result();
2820
- OPERATION = "observe_native_calls";
2821
- NATIVE_CALL_OBSERVATION_LIMITATIONS = [
2822
- "Only entries are observed; return values, floating-point and stack-passed arguments are not captured.",
2823
- "Registers are the raw integer argument registers at entry. For Objective-C methods the first two hold the receiver and the selector.",
2824
- "Receiver classes come from LLDB's Objective-C runtime reader without running target code; they are null for class methods and for receivers LLDB cannot classify.",
2825
- "Calls that never reach a symbol's entry, such as inlined code or objc_direct methods called directly, are not observed.",
2826
- "The target is launched directly under LLDB, not through LaunchServices; LLDB disables ASLR for it, so load addresses can equal file addresses.",
2827
- "The observation window is checked about once a second, and recording pauses the process at every entry, which slows it."
2828
- ];
2829
- observeNativeCalls = async (target, parameters, tracer, signal, readTargetDigest = fileSha256) => {
2830
- if (target.kind !== "executable" || !isMachOFormat(target.format)) return err(new AnalysisCapabilityUnavailableError("native-macos", OPERATION, "Native call observation launches a Mach-O executable; the active target is not one"));
2831
- const parsed = nativeCallObservationInputSchema.safeParse(parameters);
2832
- if (!parsed.success) return err(new AnalysisInputError(OPERATION, { cause: parsed.error }));
2833
- let digest;
2834
- try {
2835
- digest = await readTargetDigest(target.path, signal);
2836
- } catch (cause) {
2837
- if (signal?.aborted === true || isAbortError(cause)) return err(new AnalysisCancelledError(OPERATION));
2838
- return err(new ProviderAdapterError("native-macos", OPERATION, { diagnostics: {
2839
- reason: "Unable to verify the selected target digest",
2840
- detail: cause instanceof Error ? cause.message : String(cause)
2841
- } }));
2842
- }
2843
- if (digest !== target.sha256) return err(new EvidenceIntegrityError("Native call observation target digest changed after session binding"));
2844
- if (signal?.aborted === true) return err(new AnalysisCancelledError(OPERATION));
2845
- const traced = await tracer.trace({
2846
- executable: target.path,
2847
- architecture: target.architecture,
2848
- expectedSha256: target.sha256,
2849
- input: parsed.data
2850
- }, signal);
2851
- if (!traced.ok) return traced;
2852
- return ok(projectNativeCalls(target, parsed.data, traced.value));
2853
- };
2854
- isAbortError = (cause) => cause instanceof Error && cause.name === "AbortError";
2855
- projectNativeCalls = (target, input, trace) => {
2856
- const { run } = trace;
2857
- const unresolved = run.breakpoints.filter(({ location_count: count }) => count === 0).map(({ index }) => index);
2858
- const eventLimit = run.outcome === "event-limit";
2859
- const resourceLimit = run.outcome === "resource-limit";
2860
- const breakpointLocationLimit = run.breakpoint_locations_truncated === true;
2861
- const partial = eventLimit || resourceLimit || breakpointLocationLimit || run.outcome === "duration-elapsed" || run.outcome === "stop-limit" || unresolved.length > 0;
2862
- return nativeCallObservationResultSchema.parse({
2863
- target: {
2864
- path: target.path,
2865
- sha256: target.sha256,
2866
- architecture: target.architecture,
2867
- arguments: input.arguments,
2868
- environment: input.environment,
2869
- working_directory: input.working_directory ?? null,
2870
- launch_identity: {
2871
- loaded_image_sha256: run.target_identity.loaded_image_sha256,
2872
- file_device: run.target_identity.file_device,
2873
- file_inode: run.target_identity.file_inode,
2874
- selected_file_sha256: run.target_identity.selected_file_sha256,
2875
- module_path: run.target_identity.module_path,
2876
- module_uuid: run.target_identity.module_uuid,
2877
- stable: run.target_identity.stable
2878
- }
2879
- },
2880
- debugger: trace.debugger,
2881
- process: {
2882
- pid: run.pid,
2883
- outcome: run.outcome,
2884
- exit_status: run.exit_status,
2885
- exit_description: run.exit_description,
2886
- terminated: run.terminated && trace.terminated,
2887
- elapsed_ms: run.elapsed_ms,
2888
- stdout: trace.stdout,
2889
- stderr: trace.stderr,
2890
- other_stops: run.other_stops
2891
- },
2892
- breakpoints: input.breakpoints.map((request, index) => ({
2893
- index,
2894
- request: request.kind === "function" ? {
2895
- ...request,
2896
- module: request.module ?? null
2897
- } : {
2898
- ...request,
2899
- class_name: request.class_name ?? null
2900
- },
2901
- location_count: run.breakpoints[index]?.location_count ?? 0,
2902
- locations: run.breakpoints[index]?.locations ?? []
2903
- })),
2904
- events: run.events,
2905
- coverage: {
2906
- status: partial ? "partial" : "complete",
2907
- event_limit_reached: eventLimit,
2908
- resource_limit_reached: resourceLimit,
2909
- ...breakpointLocationLimit ? { breakpoint_locations_truncated: true } : {},
2910
- unresolved_breakpoints: unresolved
2911
- },
2912
- limitations: [
2913
- ...NATIVE_CALL_OBSERVATION_LIMITATIONS,
2914
- "The selected pathname digest and LLDB module identity are checked around launch. No immutable executable snapshot is used; concurrent in-place mutation or replacement and restoration cannot be ruled out, so the loaded-image digest remains unknown.",
2915
- ...eventLimit ? [`Observation stopped at max_events (${input.max_events}); later calls were not recorded and the process was killed.`] : [],
2916
- ...resourceLimit ? ["Observation stopped before retaining the next complete event because the estimated 8 MiB trace-payload or 65,536-frame aggregate budget was reached; the process was killed."] : [],
2917
- ...run.outcome === "duration-elapsed" ? [`The process was still running after duration_ms (${input.duration_ms}) and was killed.`] : [],
2918
- ...run.target_identity.stable ? [] : ["LLDB did not provide enough module identity evidence to confirm pathname and module continuity around launch."],
2919
- ...run.outcome === "stop-limit" ? ["Observation stopped after repeated signal or exception stops; the process was killed."] : [],
2920
- ...unresolved.length === 0 ? [] : [`Breakpoints ${unresolved.join(", ")} matched no code in any image loaded while observing; their calls could not be observed.`],
2921
- ...run.breakpoints.some(({ location_count: count, locations }) => locations.length < count) ? ["Breakpoints with many matching locations list only the first 64; location_count gives the total."] : [],
2922
- ...breakpointLocationLimit ? ["Resolved breakpoint locations exceeded the aggregate 8 MiB metadata budget; omitted locations are counted in location_count. This metadata limit does not change the process outcome."] : [],
2923
- ...trace.stdout.truncated || trace.stderr.truncated ? ["Target output beyond 1 MiB per stream is counted but not kept."] : [],
2924
- ...!trace.stdout.complete || !trace.stderr.complete ? ["Target output draining did not complete; reported byte counts are observed lower bounds, not stream totals."] : [],
2925
- ...run.terminated && trace.terminated ? [] : [`REA could not confirm that process ${run.pid} exited; check for it before relying on host state.`]
2926
- ]
2927
- });
2928
- };
2929
- fileSha256 = async (path, signal) => {
2930
- const handle = await open(path, "r");
2931
- try {
2932
- const hash = createHash("sha256");
2933
- const buffer = new Uint8Array(1024 * 1024);
2934
- for (;;) {
2935
- signal?.throwIfAborted();
2936
- const { bytesRead } = await handle.read(buffer, 0, buffer.length, null);
2937
- if (bytesRead === 0) break;
2938
- hash.update(buffer.subarray(0, bytesRead));
2939
- }
2940
- return hash.digest("hex");
2941
- } finally {
2942
- await handle.close();
2943
- }
2944
- };
2945
- })))();
2946
- }
2947
-
2948
3463
  //#endregion
2949
3464
  //#region dist/native/SignatureTargetBinding.js
2950
- var identity, changedTarget, signatureReadFailure, withSignatureTarget, combineCleanupFailure, snapshotFailure, snapshotIO, copySignatureBytes, bindSignatureTarget, verifySignatureTarget;
3465
+ var identity, changedTarget, signatureReadFailure, withSignatureTarget, combineCleanupFailure, signatureCleanupFailure, snapshotFailure, snapshotIO, copySignatureBytes, bindSignatureTarget, verifySignatureTarget;
2951
3466
  function init_SignatureTargetBinding() {
2952
3467
  return (init_SignatureTargetBinding = __esmMin((() => {
3468
+ init_RegularFile();
2953
3469
  init_analysisErrorBase();
2954
3470
  init_analysisErrorCore();
2955
3471
  init_providerAdapterError();
@@ -2960,6 +3476,8 @@ function init_SignatureTargetBinding() {
2960
3476
  init_ArtifactResourceScope();
2961
3477
  init_PrivateRuntimeRoot();
2962
3478
  init_ArtifactReader();
3479
+ init_AnalysisCleanupLease();
3480
+ init_ArtifactFileOperation();
2963
3481
  init_NativeMacOSProviderMetadata();
2964
3482
  identity = (stat) => [
2965
3483
  stat.dev,
@@ -2970,6 +3488,7 @@ function init_SignatureTargetBinding() {
2970
3488
  ].join(":");
2971
3489
  changedTarget = (target, reason) => err(new AnalysisArtifactChangedError("inspect_signature", target.path, reason));
2972
3490
  signatureReadFailure = (target, cause) => {
3491
+ if (cause instanceof RegularFileOperationCancelled) return new AnalysisCancelledError("inspect_signature", { cause: cause.reason });
2973
3492
  if (cause instanceof AnalysisError) return cause;
2974
3493
  const code = cause instanceof Error && "code" in cause ? cause.code : undefined;
2975
3494
  if (code === "EACCES" || code === "EPERM") return new AnalysisAccessDeniedError("inspect_signature", target.path, code, { cause });
@@ -2989,14 +3508,14 @@ function init_SignatureTargetBinding() {
2989
3508
  return await resources.run(async () => {
2990
3509
  let root;
2991
3510
  try {
2992
- signal?.throwIfAborted();
3511
+ assertRegularFileActive(signal);
2993
3512
  root = await createRoot();
2994
3513
  } catch (cause) {
2995
- return err(signal?.aborted ? new AnalysisCancelledError("inspect_signature") : snapshotFailure(target, "create", cause));
3514
+ return err(cause instanceof RegularFileOperationCancelled ? signatureReadFailure(target, cause) : snapshotFailure(target, "create", cause));
2996
3515
  }
2997
3516
  const owner = {
2998
- kind: "private-runtime-root",
2999
- root,
3517
+ kind: "lease",
3518
+ lease: new AnalysisCleanupLease(() => root.close(), [root.path]),
3000
3519
  resource: root.path
3001
3520
  };
3002
3521
  let result;
@@ -3007,25 +3526,33 @@ function init_SignatureTargetBinding() {
3007
3526
  try {
3008
3527
  result = await inspect(binding.value);
3009
3528
  } catch (cause) {
3010
- result = err(cause instanceof AnalysisError ? cause : new AnalysisOutputError("inspect_signature", "Native output parsing failed", { cause }));
3529
+ result = err(new AnalysisOutputError("inspect_signature", "Native output parsing failed", { cause }));
3011
3530
  }
3012
3531
  }
3013
3532
  } catch (cause) {
3014
- result = err(cause instanceof AnalysisError ? cause : signatureReadFailure(target, cause));
3533
+ result = err(signatureReadFailure(target, cause));
3015
3534
  }
3016
3535
  const cleanup = await resources.release(owner);
3017
- if (cleanup.kind === "failed") return combineCleanupFailure(target, result, [root.path], cleanup.cause, "cleanup");
3536
+ if (result.ok && signal?.aborted) result = err(new AnalysisCancelledError("inspect_signature", {
3537
+ cause: signal.reason,
3538
+ partialObservation: result.value
3539
+ }));
3540
+ if (cleanup.kind === "failed") {
3541
+ const failure = signatureCleanupFailure(target, [root.path], cleanup.cause, "cleanup");
3542
+ new AnalysisCleanupLeaseGroup(failure, [owner.lease]);
3543
+ return combineCleanupFailure(result, failure);
3544
+ }
3018
3545
  return result;
3019
3546
  });
3020
3547
  } catch (cause) {
3021
- if (cause instanceof AnalysisError) return err(cause);
3022
3548
  const retained = cause instanceof ArtifactReaderFailure && cause.cleanup !== undefined ? cause.cleanup : undefined;
3023
- if (retained !== undefined) return combineCleanupFailure(target, err(signal?.aborted ? new AnalysisCancelledError("inspect_signature") : signatureReadFailure(target, cause)), retained.resources, cause, "retry");
3024
- return err(signal?.aborted ? new AnalysisCancelledError("inspect_signature") : signatureReadFailure(target, cause));
3549
+ if (retained !== undefined) return combineCleanupFailure(err(signatureReadFailure(target, cause)), signatureCleanupFailure(target, retained.resources, cause, "retry"));
3550
+ return err(signatureReadFailure(target, cause));
3025
3551
  }
3026
3552
  };
3027
- combineCleanupFailure = (target, primary, resources, cause, phase) => {
3028
- const cleanup = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, resources, {
3553
+ combineCleanupFailure = (primary, cleanup) => primary.ok ? err(cleanup) : err(analysisErrorWithCleanupFailure(primary.error, cleanup, "inspect_signature").bindCleanupDependencies([primary.error, cleanup]));
3554
+ signatureCleanupFailure = (target, resources, cause, phase) => {
3555
+ const failure = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, resources, {
3029
3556
  reason: cause instanceof Error ? cause.message : String(cause),
3030
3557
  phase: `signature-snapshot-${phase}`,
3031
3558
  path: target.path
@@ -3033,7 +3560,8 @@ function init_SignatureTargetBinding() {
3033
3560
  operation: "inspect_signature",
3034
3561
  cause
3035
3562
  });
3036
- return primary.ok ? err(cleanup) : err(analysisErrorWithCleanupFailure(primary.error, cleanup, "inspect_signature"));
3563
+ bindArtifactFileCleanup(cause, failure);
3564
+ return failure;
3037
3565
  };
3038
3566
  snapshotFailure = (target, phase, cause) => new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_signature", {
3039
3567
  cause,
@@ -3057,9 +3585,9 @@ function init_SignatureTargetBinding() {
3057
3585
  const chunk = Buffer.alloc(64 * 1024);
3058
3586
  let position = 0;
3059
3587
  while (position < size) {
3060
- signal?.throwIfAborted();
3588
+ assertRegularFileActive(signal);
3061
3589
  const { bytesRead } = await source.file.read(chunk, 0, Math.min(chunk.length, size - position), position);
3062
- signal?.throwIfAborted();
3590
+ assertRegularFileActive(signal);
3063
3591
  if (bytesRead === 0) throw new AnalysisArtifactChangedError("inspect_signature", target.path, `Signature target was truncated while hashing: ${target.path}`);
3064
3592
  const bytes = chunk.subarray(0, bytesRead);
3065
3593
  hash.update(bytes);
@@ -3073,17 +3601,27 @@ function init_SignatureTargetBinding() {
3073
3601
  let snapshotOwner;
3074
3602
  const perform = async () => {
3075
3603
  try {
3076
- signal?.throwIfAborted();
3604
+ assertRegularFileActive(signal);
3077
3605
  const before = await lstat(target.path, { bigint: true });
3078
- signal?.throwIfAborted();
3606
+ assertRegularFileActive(signal);
3079
3607
  if (!before.isFile() || before.isSymbolicLink()) return changedTarget(target, `Signature target is no longer a regular file: ${target.path}`);
3080
3608
  const file = await open(target.path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
3081
- sourceOwner = new OwnedFileHandle(file);
3609
+ const sourceHandle = new OwnedFileHandle(file);
3610
+ sourceOwner = {
3611
+ kind: "lease",
3612
+ resource: target.path,
3613
+ lease: new AnalysisCleanupLease(() => sourceHandle.close(), [target.path])
3614
+ };
3082
3615
  const opened = await file.stat({ bigint: true });
3083
- signal?.throwIfAborted();
3616
+ assertRegularFileActive(signal);
3084
3617
  if (identity(opened) !== identity(before)) return changedTarget(target, `Signature target changed before open: ${target.path}`);
3085
3618
  const snapshot = await snapshotIO(target, "create-file", () => open(snapshotPath, "wx", 384));
3086
- snapshotOwner = new OwnedFileHandle(snapshot);
3619
+ const snapshotHandle = new OwnedFileHandle(snapshot);
3620
+ snapshotOwner = {
3621
+ kind: "lease",
3622
+ resource: snapshotPath,
3623
+ lease: new AnalysisCleanupLease(() => snapshotHandle.close(), [snapshotPath])
3624
+ };
3087
3625
  const observed = await copySignatureBytes(target, {
3088
3626
  file,
3089
3627
  stat: opened
@@ -3091,7 +3629,7 @@ function init_SignatureTargetBinding() {
3091
3629
  if (observed !== target.sha256) return changedTarget(target, `Signature target digest changed: ${target.path}; expected ${target.sha256}, observed ${observed}`);
3092
3630
  const after = await file.stat({ bigint: true });
3093
3631
  const current = await lstat(target.path, { bigint: true });
3094
- signal?.throwIfAborted();
3632
+ assertRegularFileActive(signal);
3095
3633
  if (identity(after) !== identity(opened) || identity(current) !== identity(opened)) return changedTarget(target, `Signature target changed while establishing its version: ${target.path}`);
3096
3634
  await snapshotIO(target, "seal", () => snapshot.chmod(256));
3097
3635
  return ok({
@@ -3099,37 +3637,42 @@ function init_SignatureTargetBinding() {
3099
3637
  snapshotPath
3100
3638
  });
3101
3639
  } catch (cause) {
3102
- return err(signal?.aborted ? new AnalysisCancelledError("inspect_signature") : signatureReadFailure(target, cause));
3640
+ return err(signatureReadFailure(target, cause));
3103
3641
  }
3104
3642
  };
3105
3643
  let result = await perform();
3106
3644
  const cleanupFailures = [];
3107
- for (const [owner, path] of [[snapshotOwner, snapshotPath], [sourceOwner, target.path]]) {
3645
+ for (const owner of [snapshotOwner, sourceOwner]) {
3108
3646
  if (owner === undefined) continue;
3109
- const cleanup = await resources.release({
3110
- kind: "file-handle",
3111
- handle: owner,
3112
- resource: path
3113
- });
3647
+ const cleanup = await resources.release(owner);
3114
3648
  if (cleanup.kind === "failed") cleanupFailures.push({
3115
- path,
3649
+ owner,
3116
3650
  cause: cleanup.cause
3117
3651
  });
3118
3652
  }
3653
+ if (result.ok && signal?.aborted) result = err(new AnalysisCancelledError("inspect_signature", {
3654
+ cause: signal.reason,
3655
+ diagnostics: { snapshot_binding: {
3656
+ identity: result.value.identity,
3657
+ snapshot_path: result.value.snapshotPath
3658
+ } }
3659
+ }));
3119
3660
  if (cleanupFailures.length > 0) {
3120
3661
  const cause = new AggregateError(cleanupFailures.map(({ cause: failure }) => failure), "Signature snapshot file handles could not be closed");
3121
- result = combineCleanupFailure(target, result, cleanupFailures.map(({ path }) => path), cause, "close");
3662
+ const cleanup = signatureCleanupFailure(target, cleanupFailures.map(({ owner }) => owner.resource), cause, "close");
3663
+ new AnalysisCleanupLeaseGroup(cleanup, cleanupFailures.map(({ owner }) => owner.lease));
3664
+ result = combineCleanupFailure(result, cleanup);
3122
3665
  }
3123
3666
  return result;
3124
3667
  };
3125
3668
  verifySignatureTarget = async (target, binding, signal) => {
3126
3669
  try {
3127
- signal?.throwIfAborted();
3670
+ assertRegularFileActive(signal);
3128
3671
  const current = await lstat(target.path, { bigint: true });
3129
- signal?.throwIfAborted();
3672
+ assertRegularFileActive(signal);
3130
3673
  return current.isFile() && identity(current) === binding.identity ? ok(undefined) : changedTarget(target, `Signature target changed during inspection: ${target.path}`);
3131
3674
  } catch (cause) {
3132
- return err(signal?.aborted ? new AnalysisCancelledError("inspect_signature") : signatureReadFailure(target, cause));
3675
+ return err(signatureReadFailure(target, cause));
3133
3676
  }
3134
3677
  };
3135
3678
  })))();
@@ -3218,19 +3761,12 @@ function init_codesign() {
3218
3761
 
3219
3762
  //#endregion
3220
3763
  //#region dist/native/parsers/demangle.js
3221
- var resultSchema, parseDemangledSymbols;
3764
+ var linkageName, undecodedSpelling, parseDemangledSymbols;
3222
3765
  function init_demangle() {
3223
3766
  return (init_demangle = __esmMin((() => {
3224
3767
  init_swiftSymbolClassification();
3225
- resultSchema = z.object({
3226
- input: z.string(),
3227
- output: z.string(),
3228
- status: z.enum([
3229
- "demangled",
3230
- "unchanged",
3231
- "invalid"
3232
- ])
3233
- });
3768
+ linkageName = (input) => input.startsWith("__") ? input.slice(1) : input;
3769
+ undecodedSpelling = (input) => /^[Sse]/u.test(input) ? `$${input}` : linkageName(input);
3234
3770
  parseDemangledSymbols = (inputs, output) => {
3235
3771
  if (inputs.length === 0) {
3236
3772
  if (output === "" || output === "\n") return [];
@@ -3241,11 +3777,12 @@ function init_demangle() {
3241
3777
  return inputs.map((input, index) => {
3242
3778
  const value = lines[index];
3243
3779
  if (value === undefined) throw new TypeError("swift-demangle omitted an output line");
3244
- return resultSchema.parse({
3780
+ const decoded = value !== input && value !== undecodedSpelling(input);
3781
+ return {
3245
3782
  input,
3246
3783
  output: value,
3247
- status: value === input ? isSwiftMangledSymbolName(input) ? "invalid" : "unchanged" : "demangled"
3248
- });
3784
+ status: decoded ? "demangled" : isSwiftMangledSymbolName(linkageName(input)) ? "invalid" : "unchanged"
3785
+ };
3249
3786
  });
3250
3787
  };
3251
3788
  })))();
@@ -3253,18 +3790,20 @@ function init_demangle() {
3253
3790
 
3254
3791
  //#endregion
3255
3792
  //#region dist/native/parsers/plist.js
3256
- var plistObject, INTEGRAL_LITERAL, decodePlistJson, plistJsonNeedsNumberTypes, parsePlistJson, parsePlistXml, xmlNumberLiterals, prototypeKeyLimitations, numberLimitations, mapJsonNumbers, projectPlistBundle;
3793
+ var plistObject, INTEGRAL_LITERAL, decodePlistJson, plistJsonNeedsNumberTypes, parsePlistJson, parsePlistXml, prototypeKeyLimitations, negativeZeroLimitations, numberLimitations, mapJsonNumbers, projectPlistBundle;
3257
3794
  function init_plist() {
3258
3795
  return (init_plist = __esmMin((() => {
3259
3796
  init_analysisErrorCore();
3260
3797
  init_plistValue();
3261
3798
  init_propertyListKeys();
3262
3799
  init_result();
3800
+ init_plistNumbers();
3263
3801
  plistObject = z.record(z.string(), z.unknown());
3264
3802
  INTEGRAL_LITERAL = /^-?\d+$/u;
3265
- decodePlistJson = (output, unsafe) => {
3803
+ decodePlistJson = (output, unsafe, negativeZero = (item) => item) => {
3266
3804
  const text = output.replace(/^\uFEFF/u, "");
3267
3805
  return JSON.parse(text, (_key, item, context) => {
3806
+ if (typeof item === "number" && Object.is(item, -0)) return negativeZero(item);
3268
3807
  const source = context?.source;
3269
3808
  return typeof item !== "number" || Number.isSafeInteger(item) || source === undefined || !INTEGRAL_LITERAL.test(source) ? item : unsafe(item, source);
3270
3809
  });
@@ -3280,13 +3819,18 @@ function init_plist() {
3280
3819
  return found;
3281
3820
  };
3282
3821
  parsePlistJson = (output, xmlConversion) => {
3283
- const literals = xmlConversion === undefined ? undefined : xmlNumberLiterals(xmlConversion);
3822
+ let literals;
3284
3823
  let exactIntegerCount = 0;
3285
3824
  let ambiguousNumberCount = 0;
3825
+ let negativeZeroRealCount = 0;
3826
+ const signedZero = () => {
3827
+ negativeZeroRealCount += 1;
3828
+ return negativeZeroReal();
3829
+ };
3286
3830
  const classify = (item, digits) => {
3287
3831
  const exact = BigInt(digits).toString();
3288
- const integer = literals?.integers.get(item)?.has(exact) === true;
3289
- const real = literals?.reals.has(item) === true;
3832
+ const integer = literals?.incomplete === false && literals.integers.get(item)?.has(exact) === true;
3833
+ const real = literals?.incomplete === false && literals.reals.has(item);
3290
3834
  if (integer && !real) {
3291
3835
  exactIntegerCount += 1;
3292
3836
  return {
@@ -3300,7 +3844,8 @@ function init_plist() {
3300
3844
  };
3301
3845
  let decoded;
3302
3846
  try {
3303
- decoded = omitPrototypeKeys(decodePlistJson(output, classify));
3847
+ literals = xmlConversion === undefined ? undefined : parseXmlPropertyList(xmlConversion).numberLiterals;
3848
+ decoded = omitPrototypeKeys(decodePlistJson(output, classify, signedZero));
3304
3849
  } catch (cause) {
3305
3850
  return err(new AnalysisOutputError("inspect_plist", cause instanceof Error ? cause.message : String(cause), { cause }));
3306
3851
  }
@@ -3308,27 +3853,33 @@ function init_plist() {
3308
3853
  return ok({
3309
3854
  value,
3310
3855
  bundle: projectPlistBundle(value),
3311
- limitations: [...numberLimitations(exactIntegerCount, ambiguousNumberCount), ...prototypeKeyLimitations(decoded.omittedPrototypeKeys)]
3856
+ limitations: [
3857
+ ...negativeZeroLimitations(negativeZeroRealCount),
3858
+ ...literals?.incomplete === true ? [incompletePlistNumberLimitation] : [],
3859
+ ...numberLimitations(exactIntegerCount, ambiguousNumberCount),
3860
+ ...prototypeKeyLimitations(decoded.omittedPrototypeKeys)
3861
+ ]
3312
3862
  });
3313
3863
  };
3314
3864
  parsePlistXml = (output) => {
3315
3865
  let projected;
3316
3866
  let omittedPrototypeKeys;
3867
+ let literals;
3317
3868
  try {
3318
3869
  const decoded = parseXmlPropertyList(output);
3319
3870
  omittedPrototypeKeys = decoded.omittedPrototypeKeys;
3871
+ literals = decoded.numberLiterals;
3320
3872
  projected = projectPlistValue(decoded.value);
3321
3873
  } catch (cause) {
3322
3874
  return err(new AnalysisOutputError("inspect_plist", "plutil XML conversion was not a readable plist", { cause }));
3323
3875
  }
3324
- const literals = xmlNumberLiterals(output);
3325
3876
  let exactIntegerCount = 0;
3326
3877
  let ambiguousNumberCount = 0;
3327
3878
  const value = mapJsonNumbers(projected.value, (item) => {
3328
3879
  const decimals = literals.integers.get(item);
3329
3880
  if (decimals === undefined) return item;
3330
3881
  const [decimal] = decimals;
3331
- if (decimals.size !== 1 || decimal === undefined || literals.reals.has(item)) {
3882
+ if (literals.incomplete || decimals.size !== 1 || decimal === undefined || literals.reals.has(item)) {
3332
3883
  ambiguousNumberCount += 1;
3333
3884
  return item;
3334
3885
  }
@@ -3343,26 +3894,18 @@ function init_plist() {
3343
3894
  bundle: projectPlistBundle(value),
3344
3895
  limitations: [
3345
3896
  "plutil cannot express this plist as JSON, so it was decoded from plutil's XML conversion; data and date values are typed objects such as { \"$plist_type\": \"data\", \"base64\": ... }.",
3346
- ...projected.unknownRealCount === 0 ? [] : [`${String(projected.unknownRealCount)} non-finite real value(s) are reported as { "$plist_type": "real", "value": null } because the XML decoder does not distinguish NaN from infinity.`],
3897
+ ...projected.nonFiniteRealCount === 0 ? [] : [nonFiniteRealLimitation(projected.nonFiniteRealCount)],
3898
+ ...projected.unknownRealCount === 0 ? [] : [unknownRealLimitation(projected.unknownRealCount)],
3899
+ ...negativeZeroLimitations(projected.negativeZeroRealCount),
3900
+ ...projected.unknownDateCount === 0 ? [] : [unknownDateLimitation(projected.unknownDateCount)],
3901
+ ...literals.incomplete ? [incompletePlistNumberLimitation] : [],
3347
3902
  ...numberLimitations(exactIntegerCount, ambiguousNumberCount),
3348
3903
  ...prototypeKeyLimitations(omittedPrototypeKeys)
3349
3904
  ]
3350
3905
  });
3351
3906
  };
3352
- xmlNumberLiterals = (xml) => {
3353
- const integers = new Map();
3354
- for (const [, decimal = ""] of xml.matchAll(/<integer>\s*([+-]?\d+)\s*<\/integer>/gu)) {
3355
- const rounded = Number(decimal);
3356
- if (Number.isSafeInteger(rounded)) continue;
3357
- integers.set(rounded, (integers.get(rounded) ?? new Set()).add(BigInt(decimal).toString()));
3358
- }
3359
- const reals = new Set([...xml.matchAll(/<real>([^<]*)<\/real>/gu)].map(([, text = ""]) => Number.parseFloat(text)));
3360
- return {
3361
- integers,
3362
- reals
3363
- };
3364
- };
3365
3907
  prototypeKeyLimitations = (count) => count === 0 ? [] : [omittedPrototypeKeysLimitation(count)];
3908
+ negativeZeroLimitations = (count) => count === 0 ? [] : [negativeZeroRealLimitation(count)];
3366
3909
  numberLimitations = (exactIntegerCount, ambiguousNumberCount) => [...exactIntegerCount === 0 ? [] : [`${String(exactIntegerCount)} integer value(s) exceed the exact range of a JSON number and are reported as { "$plist_type": "integer", "decimal": "<exact digits>" }.`], ...ambiguousNumberCount === 0 ? [] : [`${String(ambiguousNumberCount)} number(s) beyond the exact range of a JSON number are reported as decoded because the XML literal they came from, a rounded <integer> or a <real>, cannot be identified.`]];
3367
3910
  mapJsonNumbers = (value, map) => {
3368
3911
  if (typeof value === "number") return map(value);
@@ -3507,7 +4050,7 @@ function init_echoedPath() {
3507
4050
 
3508
4051
  //#endregion
3509
4052
  //#region dist/native/parsers/otool.js
3510
- var DYLIB_COMMANDS, DYLIB_FIELDS, DYLIB_ENCODING_FIELDS, EMPTY_VALUE_FIELDS, BUILD_PLATFORM_NAMES, BUILD_TOOL_NAMES, buildCodeName, normalizeLineEndings, parseOtoolLoadCommands, WORD_SIZES, cpuEndian, parseHeader, headerValue, validateLoadCommandFraming, createLoadCommandState, parseLoadCommand, validateDylibCommandLines, scalarFields, collectUuid, collectEntrypoint, collectBuild, collectDependency, collectSegment, parseFields, parseField, requireUniqueField, parseSegment, parseSections, parseBuildTools, permissions, NUMERIC_PATTERN, numeric, nonEmptyName, stringField, numberField, hexField, stripOffsetSuffix, sectionAlignment;
4053
+ var DYLIB_COMMANDS, DYLIB_FIELDS, DYLIB_ENCODING_FIELDS, EMPTY_VALUE_FIELDS, BUILD_PLATFORM_NAMES, BUILD_TOOL_NAMES, buildCodeName, normalizeLineEndings, parseOtoolLoadCommands, WORD_SIZES, cpuEndian, parseHeader, headerValue, validateLoadCommandFraming, createLoadCommandState, parseLoadCommand, validateDylibCommandLines, validateLinkerOptionLines, scalarFields, collectUuid, collectEntrypoint, collectBuild, collectDependency, collectSegment, parseFields, TEXT_FIELDS, parseField, requireUniqueField, parseSegment, parseSections, parseBuildTools, permissions, NUMERIC_PATTERN, numeric, machoName, stringField, numberField, hexField, stripOffsetSuffix, sectionAlignment;
3511
4054
  function init_otool() {
3512
4055
  return (init_otool = __esmMin((() => {
3513
4056
  DYLIB_COMMANDS = new Set([
@@ -3669,6 +4212,7 @@ function init_otool() {
3669
4212
  if (kind === null) throw new TypeError("otool load command is missing cmd");
3670
4213
  for (const key of scalarFields(kind)) requireUniqueField(parsed, key);
3671
4214
  if (DYLIB_COMMANDS.has(kind)) validateDylibCommandLines(parsed);
4215
+ if (kind === "LC_LINKER_OPTION") validateLinkerOptionLines(parsed);
3672
4216
  state.commands.push({
3673
4217
  index,
3674
4218
  kind,
@@ -3681,7 +4225,7 @@ function init_otool() {
3681
4225
  collectSegment(kind, block, fields, state);
3682
4226
  };
3683
4227
  validateDylibCommandLines = (parsed) => {
3684
- const encodingFields = DYLIB_ENCODING_FIELDS.filter((key) => Object.hasOwn(parsed.values, key));
4228
+ const encodingFields = DYLIB_ENCODING_FIELDS.filter((key) => parsed.rows.some((field) => field?.[0] === key));
3685
4229
  if (encodingFields.length !== 1) throw new TypeError("otool dylib command must contain timestamp or options");
3686
4230
  for (const key of encodingFields) requireUniqueField(parsed, key);
3687
4231
  const allowed = new Set([...DYLIB_FIELDS, ...DYLIB_ENCODING_FIELDS]);
@@ -3690,9 +4234,15 @@ function init_otool() {
3690
4234
  if (key === undefined || !allowed.has(key)) throw new TypeError("otool dylib command contains ambiguous multiline text");
3691
4235
  }
3692
4236
  };
4237
+ validateLinkerOptionLines = (parsed) => {
4238
+ const count = numberField(parsed.values, "count");
4239
+ const labels = parsed.rows.map((field) => field?.[0]).filter((key) => key !== "cmd" && key !== "cmdsize" && key !== "count");
4240
+ if (count === null || labels.length !== count || labels.some((key, index) => key !== `string #${String(index + 1)}`)) throw new TypeError("otool linker-option strings do not match count");
4241
+ };
3693
4242
  scalarFields = (kind) => {
3694
4243
  const common = ["cmd", "cmdsize"];
3695
4244
  if (DYLIB_COMMANDS.has(kind)) return DYLIB_FIELDS;
4245
+ if (kind === "LC_LINKER_OPTION") return [...common, "count"];
3696
4246
  if (kind === "LC_LOAD_DYLINKER" || kind === "LC_ID_DYLINKER") return [...common, "name"];
3697
4247
  if (kind === "LC_UUID") return [...common, "uuid"];
3698
4248
  if (kind === "LC_MAIN") return [...common, "entryoff"];
@@ -3750,7 +4300,7 @@ function init_otool() {
3750
4300
  });
3751
4301
  };
3752
4302
  collectDependency = (kind, fields, state) => {
3753
- if (!DYLIB_COMMANDS.has(kind)) return;
4303
+ if (!DYLIB_COMMANDS.has(kind) || kind === "LC_ID_DYLIB") return;
3754
4304
  state.dependencies.push({
3755
4305
  path: stripOffsetSuffix(stringField(fields, "name")),
3756
4306
  kind,
@@ -3765,22 +4315,29 @@ function init_otool() {
3765
4315
  state.segments.push(segment);
3766
4316
  };
3767
4317
  parseFields = (block) => {
3768
- const fields = {};
3769
4318
  const rows = [];
3770
- for (const rawLine of block.split(/\r?\n/u).slice(1)) {
3771
- if (rawLine.trim().length === 0) continue;
3772
- const field = parseField(rawLine);
3773
- rows.push(field);
4319
+ for (const rawLine of block.split(/\r?\n/u).slice(1)) if (rawLine.trim().length > 0) rows.push(parseField(rawLine));
4320
+ const occurrences = new Map();
4321
+ for (const field of rows) if (field !== undefined) occurrences.set(field[0], (occurrences.get(field[0]) ?? 0) + 1);
4322
+ const fields = {};
4323
+ const ordinals = new Map();
4324
+ for (const field of rows) {
3774
4325
  if (field === undefined) continue;
3775
4326
  const [key, value] = field;
3776
- fields[key] = key === "segname" || key === "sectname" ? value : numeric(value) ?? value;
4327
+ const ordinal = (ordinals.get(key) ?? 0) + 1;
4328
+ ordinals.set(key, ordinal);
4329
+ const label = (occurrences.get(key) ?? 0) > 1 ? `${key} #${String(ordinal)}` : key;
4330
+ fields[label] = TEXT_FIELDS.test(key) ? value : numeric(value) ?? value;
3777
4331
  }
3778
4332
  return {
3779
4333
  values: fields,
3780
4334
  rows
3781
4335
  };
3782
4336
  };
4337
+ TEXT_FIELDS = /^(?:segname|sectname|string #\d+)$/u;
3783
4338
  parseField = (rawLine) => {
4339
+ const option = /^\s*(string #[1-9]\d*)(?: (.*))?$/u.exec(rawLine);
4340
+ if (option?.[1] !== undefined) return [option[1], option[2] ?? ""];
3784
4341
  const line = rawLine.trim();
3785
4342
  const match = /^((?:time stamp)|\S+(?:\s+version)?)(?:\s+(.+))?$/u.exec(line);
3786
4343
  return match?.[1] === undefined ? undefined : [match[1], match[2]?.trim() ?? ""];
@@ -3792,7 +4349,7 @@ function init_otool() {
3792
4349
  if (field[1] === "" && !EMPTY_VALUE_FIELDS.has(key)) throw new TypeError(`otool field ${key} has no value`);
3793
4350
  };
3794
4351
  parseSegment = (block, fields) => ({
3795
- name: nonEmptyName(stringField(fields, "segname")),
4352
+ name: machoName(fields, "segname"),
3796
4353
  vm_address: hexField(fields, "vmaddr"),
3797
4354
  vm_size: numberField(fields, "vmsize"),
3798
4355
  file_offset: numberField(fields, "fileoff"),
@@ -3814,8 +4371,8 @@ function init_otool() {
3814
4371
  "flags"
3815
4372
  ]) requireUniqueField(parsed, key);
3816
4373
  return {
3817
- segment: nonEmptyName(stringField(fields, "segname")),
3818
- name: nonEmptyName(stringField(fields, "sectname")),
4374
+ segment: machoName(fields, "segname"),
4375
+ name: machoName(fields, "sectname"),
3819
4376
  address: hexField(fields, "addr"),
3820
4377
  size: numberField(fields, "size"),
3821
4378
  file_offset: numberField(fields, "offset"),
@@ -3869,7 +4426,11 @@ function init_otool() {
3869
4426
  const parsed = Number.parseInt(value, value.startsWith("0x") ? 16 : 10);
3870
4427
  return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : null;
3871
4428
  };
3872
- nonEmptyName = (name) => name === null || name.length === 0 ? "unknown" : name;
4429
+ machoName = (fields, key) => {
4430
+ const name = stringField(fields, key);
4431
+ if (name === null) throw new TypeError(`otool field ${key} is missing`);
4432
+ return name;
4433
+ };
3873
4434
  stringField = (fields, name) => {
3874
4435
  const value = fields[name];
3875
4436
  return typeof value === "string" ? value : value === undefined || value === null ? null : String(value);
@@ -3952,16 +4513,16 @@ function init_machoUuid() {
3952
4513
  };
3953
4514
  selectDwarfdumpRow = (rows, selectedArchitecture) => {
3954
4515
  if (rows.length === 0) return { kind: "absent" };
3955
- const selectedRows = selectedArchitecture === null ? rows : rows.filter(({ architecture }) => architecture === selectedArchitecture);
4516
+ const selectedRows = selectedArchitecture === null ? rows : rows.filter(({ architecture }) => architecture === selectedArchitecture.dwarfdumpName);
3956
4517
  const validRows = selectedRows.filter(({ value }) => MACHO_UUID.test(value));
3957
4518
  const distinctValid = new Set(validRows.map(({ value }) => value.toLowerCase()));
3958
4519
  if (distinctValid.size > 1) return {
3959
4520
  kind: "conflict",
3960
- reason: `dwarfdump --uuid returned conflicting UUIDs for selected architecture ${selectedArchitecture ?? "unknown"}`
4521
+ reason: `dwarfdump --uuid returned conflicting UUIDs for selected architecture ${selectedArchitecture?.name ?? "unknown"}`
3961
4522
  };
3962
4523
  if (selectedRows.length !== 1) return {
3963
4524
  kind: "invalid",
3964
- reason: selectedRows.length > 1 ? `dwarfdump --uuid returned multiple rows for selected architecture ${selectedArchitecture}` : `dwarfdump --uuid returned no row for selected architecture ${selectedArchitecture}`
4525
+ reason: selectedRows.length > 1 ? `dwarfdump --uuid returned multiple rows for selected architecture ${selectedArchitecture?.name ?? "unknown"}` : `dwarfdump --uuid returned no row for selected architecture ${selectedArchitecture?.name ?? "unknown"}`
3965
4526
  };
3966
4527
  const [row] = selectedRows;
3967
4528
  if (row === undefined) return { kind: "absent" };
@@ -4031,7 +4592,7 @@ function init_machoUuid() {
4031
4592
 
4032
4593
  //#endregion
4033
4594
  //#region dist/native/NativeMachoInspection.js
4034
- var DISCOVERY_COMMANDS, SYMBOL_TABLE_EXPORTS, DYLD_INFO_EXPORTS, REQUIRED_SLICE_COMMANDS, OPTIONAL_VTOOL_COMMAND, VTOOL_UNAVAILABLE_LIMITATION, inspectNativeMacho, normalizeMacho, sliceOutput, captureLookup, namesEveryExport, parseNmExports, covered, uniqueSymbols, fileOffsetLocations, architectureLocations, selectedArchitectureArguments, selectArchitecture;
4595
+ var DISCOVERY_COMMANDS, SYMBOL_TABLE_EXPORTS, DYLD_INFO_EXPORTS, REQUIRED_SLICE_COMMANDS, OPTIONAL_VTOOL_COMMAND, VTOOL_UNAVAILABLE_LIMITATION, inspectNativeMacho, normalizeMacho, sliceOutput, captureLookup, namesEveryExport, parseNmExports, covered, uniqueSymbols, fileOffsetLocations, architectureLocations, toolArchitectureName, selectedArchitectureArguments, selectArchitecture;
4035
4596
  function init_NativeMachoInspection() {
4036
4597
  return (init_NativeMachoInspection = __esmMin((() => {
4037
4598
  init_analysisErrorCore();
@@ -4075,13 +4636,15 @@ function init_NativeMachoInspection() {
4075
4636
  ...selectedArchitectureArguments(tool, selectedArchitecture),
4076
4637
  context.target.path
4077
4638
  ], context.signal);
4078
- const [required, optional] = await Promise.all([Promise.all(REQUIRED_SLICE_COMMANDS.map(runSliceCommand)), runSliceCommand(OPTIONAL_VTOOL_COMMAND)]);
4639
+ const vtoolSelectsSlice = selectedArchitecture === null || !toolArchitectureName("vtool", selectedArchitecture).includes(".");
4640
+ const [required, optional] = await Promise.all([Promise.all(REQUIRED_SLICE_COMMANDS.map(runSliceCommand)), vtoolSelectsSlice ? runSliceCommand(OPTIONAL_VTOOL_COMMAND) : null]);
4079
4641
  for (const captured of required) {
4080
4642
  if (!captured.ok) return err(captured.error);
4081
4643
  captures.push(captured.value);
4082
4644
  }
4083
4645
  const limitations = [];
4084
- if (optional.ok) captures.push(optional.value);
4646
+ if (optional === null) limitations.push(`vtool cannot select the ${selectedArchitecture} slice; build metadata is normalized from otool only.`);
4647
+ else if (optional.ok) captures.push(optional.value);
4085
4648
  else if (optional.error._tag === "AnalysisCapabilityUnavailableError") limitations.push(VTOOL_UNAVAILABLE_LIMITATION);
4086
4649
  else return err(optional.error);
4087
4650
  const nmIndex = captures.findIndex(({ tool }) => tool === "nm");
@@ -4135,7 +4698,10 @@ function init_NativeMachoInspection() {
4135
4698
  const dyldExports = parseDyldSymbols(sliceOutput(byTool("dyld_info", 1)), "exports", imageBase, new Set(nmExports.map(({ name }) => name)));
4136
4699
  const exports = uniqueSymbols([...dyldExports, ...nmExports]);
4137
4700
  const dwarfdump = byTool("dwarfdump");
4138
- const uuid = reconcileMachoUuid(load.commands, dwarfdump.stdout, artifactPath, selectedArchitecture.name);
4701
+ const uuid = reconcileMachoUuid(load.commands, dwarfdump.stdout, artifactPath, selectedArchitecture.name === null ? null : {
4702
+ name: selectedArchitecture.name,
4703
+ dwarfdumpName: toolArchitectureName("dwarfdump", selectedArchitecture.name)
4704
+ });
4139
4705
  const provenance = captures.map(toInvocation);
4140
4706
  const threadEntrypoint = load.entrypoints.length === 0 && load.commands.some((command) => command.kind === "LC_UNIXTHREAD" || command.kind === "LC_THREAD");
4141
4707
  const threadEntrypointLimitation = "Thread-state entrypoints (LC_UNIXTHREAD/LC_THREAD) are retained as raw load commands; file offsets are not derived.";
@@ -4236,10 +4802,10 @@ function init_NativeMachoInspection() {
4236
4802
  }
4237
4803
  return locations;
4238
4804
  };
4805
+ toolArchitectureName = (tool, architecture) => tool === "dyld_info" ? architecture : architecture.replace(/\.v\d+$/u, "");
4239
4806
  selectedArchitectureArguments = (tool, architecture) => {
4240
4807
  if (architecture === null) return [];
4241
- const baseArchitecture = architecture.split(".")[0] ?? architecture;
4242
- const toolArchitecture = tool === "dyld_info" ? architecture : baseArchitecture;
4808
+ const toolArchitecture = toolArchitectureName(tool, architecture);
4243
4809
  return tool === "dwarfdump" ? [`--arch=${toolArchitecture}`] : ["-arch", toolArchitecture];
4244
4810
  };
4245
4811
  selectArchitecture = (target, available) => {
@@ -4261,26 +4827,31 @@ function init_NativeMachoInspection() {
4261
4827
 
4262
4828
  //#endregion
4263
4829
  //#region dist/native/NativeMacOSProvider.js
4264
- var NativeMacOSProvider, NativeMacOSClient, nativeCommandCleanupFailure, isNativeOperation, translateCommandFailure, translateCodeSignExitFailure, commandOutput, isNonzeroUnsignedObservation, canonicalPath, codeSignCaptureFailure, codeSignArchitectures, invocation, parseEntitlements, unreadablePlist, plutilDiagnostic, requireRegularPlist, resolvePlistPath;
4830
+ var NativeMacOSProvider, NativeMacOSClient, nativeCommandCleanupFailure, closeNativeFileScope, nativeOutputFailure, isNativeOperation, translateCommandFailure, translateCodeSignExitFailure, commandOutput, isNonzeroUnsignedObservation, canonicalPath, codeSignCaptureFailure, codeSignArchitectures, invocation, parseEntitlements, plutilDiagnostic;
4265
4831
  function init_NativeMacOSProvider() {
4266
4832
  return (init_NativeMacOSProvider = __esmMin((() => {
4833
+ init_NativePlistSource();
4834
+ init_ArtifactFileOperation();
4267
4835
  init_snapshotEnvironment();
4268
4836
  init_NativeMacOSProviderMetadata();
4269
4837
  init_AppleDispatchMetadata();
4270
4838
  init_NativeUiObservation();
4839
+ init_NativeUiCleanupError();
4271
4840
  init_LldbCallTracer();
4272
4841
  init_NativeCallObservation();
4273
4842
  init_AnalysisProvider();
4274
4843
  init_nativeToolContracts();
4275
4844
  init_binaryTargetTypes();
4845
+ init_objcSwiftMetadata();
4276
4846
  init_toolContracts();
4277
4847
  init_inputIssueProjection();
4278
4848
  init_analysisErrorCore();
4279
- init_configurationErrors();
4280
4849
  init_providerAdapterError();
4281
4850
  init_providerCleanupError();
4282
4851
  init_analysisErrorBase();
4283
4852
  init_jsonValue();
4853
+ init_plistValue();
4854
+ init_plistNumbers();
4284
4855
  init_propertyListKeys();
4285
4856
  init_nativeInspection();
4286
4857
  init_result();
@@ -4327,6 +4898,9 @@ function init_NativeMacOSProvider() {
4327
4898
  #pendingNativeUiRuntimes = new Set();
4328
4899
  #pendingCommands = new Set();
4329
4900
  #signatureResources = new ArtifactResourceScope();
4901
+ #plistResources = new ArtifactResourceScope();
4902
+ #callResources = new ArtifactResourceScope();
4903
+ #dispatchResources = new ArtifactResourceScope();
4330
4904
  #nativeUiTail = Promise.resolve();
4331
4905
  #closed = false;
4332
4906
  constructor(target, runner, tracer, environment, privateRuntimeRootFactory) {
@@ -4338,14 +4912,14 @@ function init_NativeMacOSProvider() {
4338
4912
  }
4339
4913
  async execute(operation, parameters, options) {
4340
4914
  if (this.#closed) return err(new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, operation, "Native provider client is closed"));
4341
- if (options?.signal?.aborted === true) return err(new AnalysisCancelledError(operation));
4915
+ if (options?.signal?.aborted === true) return err(new AnalysisCancelledError(operation, { cause: options.signal.reason }));
4342
4916
  if (operation === "health") return ok(createAnalysisExecution(null, NATIVE_MACOS_PROVIDER_IDENTITY));
4343
4917
  if (operation === "inspect_native_dispatch_metadata") {
4344
4918
  const input = toolContract(operation).inputSchema.safeParse(parameters);
4345
4919
  if (!input.success) return err(analysisInputErrorFromIssues(operation, input.error.issues, parameters, { cause: input.error }));
4346
- if (this.target.kind !== "executable" || !isMachOFormat(this.target.format)) return err(new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, operation, "Binary Apple metadata requires Mach-O; other providers can report symbol-only metadata"));
4920
+ if (!isAppleDispatchMetadataTarget(this.target)) return err(new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, operation, "Binary Apple metadata requires Mach-O; other providers can report symbol-only metadata"));
4347
4921
  try {
4348
- const result = await inspectAppleDispatchMetadata(this.target, input.data.max_records, options?.signal);
4922
+ const result = await this.#dispatchResources.run(() => inspectAppleDispatchMetadata(this.target, input.data.max_records, this.#dispatchResources, options?.signal));
4349
4923
  return ok(createAnalysisExecution(result, result.provider, {
4350
4924
  locations: [{
4351
4925
  kind: "artifact-path",
@@ -4354,19 +4928,12 @@ function init_NativeMacOSProvider() {
4354
4928
  limitations: result.result.coverage.flatMap(({ reason }) => reason === null ? [] : [reason])
4355
4929
  }));
4356
4930
  } catch (cause) {
4357
- if (cause instanceof AnalysisError) return err(cause);
4358
- return err(options?.signal?.aborted ? new AnalysisCancelledError(operation) : new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, operation, {
4359
- cause,
4360
- diagnostics: {
4361
- target_path: this.target.path,
4362
- reason: cause instanceof Error ? cause.message : String(cause)
4363
- }
4364
- }));
4931
+ return err(appleDispatchMetadataFailure(cause, this.target.path));
4365
4932
  }
4366
4933
  }
4367
4934
  if (!isNativeOperation(operation)) return err(new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, operation, "Operation is not implemented by native macOS tools."));
4368
4935
  if (operation === "observe_native_calls") {
4369
- const result = await observeNativeCalls(this.target, parameters, this.tracer, options?.signal);
4936
+ const result = await observeNativeCalls(this.target, parameters, this.tracer, this.#callResources, options?.signal);
4370
4937
  return result.ok ? ok(createAnalysisExecution(result.value, NATIVE_MACOS_PROVIDER_IDENTITY, {
4371
4938
  limitations: result.value.limitations,
4372
4939
  locations: [{
@@ -4383,33 +4950,30 @@ function init_NativeMacOSProvider() {
4383
4950
  return observation.ok ? ok(createAnalysisExecution(observation.value.result, NATIVE_MACOS_PROVIDER_IDENTITY, {
4384
4951
  limitations: observation.value.limitations,
4385
4952
  locations: observation.value.locations
4386
- })) : observation;
4953
+ })) : err(resolvedAnalysisError(observation.error));
4387
4954
  } catch (cause) {
4388
- return err(new AnalysisOutputError(operation, "Native output parsing failed", { cause }));
4955
+ return err(nativeOutputFailure(operation, cause));
4389
4956
  }
4390
4957
  }
4391
4958
  async close() {
4392
4959
  this.#closed = true;
4393
4960
  await Promise.allSettled(this.#pendingCommands);
4394
4961
  const uiCleanupFailures = await this.#serializeNativeUi(() => this.#retryNativeUiCleanup());
4395
- let signatureCleanup;
4396
- try {
4397
- await this.#signatureResources.close();
4398
- } catch (cause) {
4399
- const observation = ArtifactReaderFailure.cleanupObservation(cause, "signature-snapshot");
4400
- signatureCleanup = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, observation.resources, { reason: observation.reason }, {
4401
- operation: "close_binary",
4402
- cause
4403
- });
4404
- }
4962
+ const signatureCleanup = await closeNativeFileScope(this.#signatureResources, "signature-snapshot");
4963
+ const plistCleanup = await closeNativeFileScope(this.#plistResources, "plist-file");
4964
+ const callCleanup = await closeNativeFileScope(this.#callResources, "native-call-target");
4965
+ const dispatchCleanup = await closeNativeFileScope(this.#dispatchResources, "native-dispatch-metadata-target");
4405
4966
  const commandCleanup = await this.#retryNativeCommandCleanup();
4406
4967
  let result = await this.tracer.close();
4407
4968
  const cleanupErrors = [
4408
4969
  ...uiCleanupFailures.length === 0 ? [] : [this.#nativeUiCleanupFailure(uiCleanupFailures, "close_binary")],
4409
4970
  ...commandCleanup === undefined ? [] : [commandCleanup],
4410
- ...signatureCleanup === undefined ? [] : [signatureCleanup]
4971
+ ...signatureCleanup === undefined ? [] : [signatureCleanup],
4972
+ ...plistCleanup === undefined ? [] : [plistCleanup],
4973
+ ...callCleanup === undefined ? [] : [callCleanup],
4974
+ ...dispatchCleanup === undefined ? [] : [dispatchCleanup]
4411
4975
  ];
4412
- for (const cleanupError of cleanupErrors) result = result.ok ? err(cleanupError) : err(analysisErrorWithCleanupFailure(result.error, cleanupError));
4976
+ for (const cleanupError of cleanupErrors) result = result.ok ? err(cleanupError) : err(analysisErrorWithCleanupFailure(result.error, cleanupError).bindCleanupDependencies([result.error, cleanupError]));
4413
4977
  return result;
4414
4978
  }
4415
4979
  #observeNativeUi(operation, parameters, signal) {
@@ -4418,12 +4982,13 @@ function init_NativeMacOSProvider() {
4418
4982
  const earlierCleanupFailures = await this.#retryNativeUiCleanup();
4419
4983
  if (earlierCleanupFailures.length > 0) return err(this.#nativeUiCleanupFailure(earlierCleanupFailures, operation));
4420
4984
  const runtime = createNativeUiHelperRuntime(this.environment);
4985
+ const observationSignal = signal === undefined ? runtime.signal : AbortSignal.any([signal, runtime.signal]);
4421
4986
  this.#pendingNativeUiRuntimes.add(runtime);
4422
4987
  let result;
4423
4988
  try {
4424
4989
  result = await observeNativeUi(this.target, operation, parameters, {
4425
4990
  environment: this.environment,
4426
- signal,
4991
+ signal: observationSignal,
4427
4992
  runtime
4428
4993
  });
4429
4994
  } catch (cause) {
@@ -4433,12 +4998,14 @@ function init_NativeMacOSProvider() {
4433
4998
  await runtime.close();
4434
4999
  this.#pendingNativeUiRuntimes.delete(runtime);
4435
5000
  } catch (cause) {
5001
+ result = finishNativeUiObservation(result, operation, observationSignal);
4436
5002
  const cleanup = this.#nativeUiCleanupFailure([{
4437
5003
  runtime,
4438
5004
  cause
4439
5005
  }], operation, result.ok ? result.value : undefined);
4440
- return err(result.ok ? cleanup : analysisErrorWithCleanupFailure(result.error, cleanup, operation));
5006
+ return err(result.ok ? cleanup : analysisErrorWithCleanupFailure(result.error, cleanup, operation).bindCleanupDependencies([result.error, cleanup]));
4441
5007
  }
5008
+ result = finishNativeUiObservation(result, operation, observationSignal);
4442
5009
  return result.ok ? ok(createAnalysisExecution(result.value, NATIVE_MACOS_PROVIDER_IDENTITY, { limitations: result.value.limitations })) : result;
4443
5010
  });
4444
5011
  }
@@ -4472,18 +5039,7 @@ function init_NativeMacOSProvider() {
4472
5039
  }
4473
5040
  }
4474
5041
  #nativeUiCleanupFailure(failures, operation, partialObservation) {
4475
- const resources = failures.flatMap(({ runtime }) => runtime.resources());
4476
- return new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, resources.length === 0 ? ["native-ui-runtime"] : resources, {
4477
- reason: "Native UI runtime cleanup remains incomplete",
4478
- failures: failures.map(({ runtime, cause }) => ({
4479
- resources: [...runtime.resources()],
4480
- reason: cause instanceof Error ? cause.message : String(cause)
4481
- }))
4482
- }, {
4483
- operation,
4484
- cause: new AggregateError(failures.map(({ cause }) => cause), "Native UI runtime cleanup failed"),
4485
- ...partialObservation === undefined ? {} : { partialObservation }
4486
- });
5042
+ return new NativeUiCleanupError(failures, operation, partialObservation);
4487
5043
  }
4488
5044
  #dispatch(operation, parameters, signal) {
4489
5045
  switch (operation) {
@@ -4542,7 +5098,12 @@ function init_NativeMacOSProvider() {
4542
5098
  }
4543
5099
  async #inspectSignature(signal) {
4544
5100
  if (this.target.kind !== "executable" || !isMachOFormat(this.target.format)) return err(new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_signature", "Active artifact is not Mach-O; its container-level signature layer is not evaluated by codesign."));
4545
- return withSignatureTarget(this.target, this.#signatureResources, (binding) => this.#inspectBoundSignature(binding, signal), signal, this.privateRuntimeRootFactory);
5101
+ const inspected = await withSignatureTarget(this.target, this.#signatureResources, (binding) => this.#inspectBoundSignature(binding, signal), signal, this.privateRuntimeRootFactory);
5102
+ return inspected.ok ? ok({
5103
+ result: inspected.value,
5104
+ limitations: inspected.value.limitations,
5105
+ locations: []
5106
+ }) : inspected;
4546
5107
  }
4547
5108
  async #inspectBoundSignature(binding, signal) {
4548
5109
  const display = await this.#captureSignature(binding, ["-d", "--verbose=4"], signal);
@@ -4572,6 +5133,7 @@ function init_NativeMacOSProvider() {
4572
5133
  ];
4573
5134
  const limitations = [
4574
5135
  ...parsed.limitations,
5136
+ ...entitlementValue.limitations.map((note) => `Entitlements: ${note}`),
4575
5137
  "Inspected a digest-verified Mach-O byte snapshot; filesystem-bound signing context and trust validation are not examined.",
4576
5138
  ...entitlementValue.omittedPrototypeKeys === 0 ? [] : [`Entitlements: ${omittedPrototypeKeysLimitation(entitlementValue.omittedPrototypeKeys)}`]
4577
5139
  ];
@@ -4595,11 +5157,7 @@ function init_NativeMacOSProvider() {
4595
5157
  provenance,
4596
5158
  limitations
4597
5159
  });
4598
- return ok({
4599
- result: jsonValueSchema.parse(result),
4600
- limitations: result.limitations,
4601
- locations: []
4602
- });
5160
+ return ok(result);
4603
5161
  }
4604
5162
  async #inspectMixedSignatureSlices(binding, format, aggregateExits, signal) {
4605
5163
  const captures = [];
@@ -4652,61 +5210,101 @@ function init_NativeMacOSProvider() {
4652
5210
  async #inspectPlist(parameters, signal) {
4653
5211
  const requested = parameters.path;
4654
5212
  if (requested !== undefined && typeof requested !== "string") return err(new AnalysisOutputError("inspect_plist", "path was not a string"));
4655
- const plist = await resolvePlistPath(this.target, requested);
4656
- if (!plist.ok) return plist;
4657
- const selected = await requireRegularPlist(plist.value, requested);
4658
- if (!selected.ok) return selected;
4659
- const classified = await this.#run("inspect_plist", "file", ["-b", plist.value], { signal });
4660
- if (!classified.ok) return classified;
4661
- const json = await this.#run("inspect_plist", "plutil", [
4662
- "-convert",
4663
- "json",
4664
- "-o",
4665
- "-",
4666
- "--",
4667
- plist.value
4668
- ], {
4669
- signal,
4670
- acceptNonZero: true
4671
- });
4672
- if (!json.ok) return json;
4673
- const jsonDecoded = json.value.exitCode === 0;
4674
- const xml = jsonDecoded && !plistJsonNeedsNumberTypes(json.value.stdout) ? undefined : await this.#run("inspect_plist", "plutil", [
4675
- "-convert",
4676
- "xml1",
4677
- "-o",
4678
- "-",
4679
- "--",
4680
- plist.value
4681
- ], {
4682
- signal,
4683
- acceptNonZero: !jsonDecoded
4684
- });
4685
- if (xml !== undefined && !xml.ok) return xml;
4686
- if (xml !== undefined && xml.value.exitCode !== 0) return err(unreadablePlist(plist.value, requested, `plutil could not decode it as a property list (${plutilDiagnostic(xml.value.stderr, plist.value)})`));
4687
- const parsed = xml === undefined ? parsePlistJson(json.value.stdout) : jsonDecoded ? parsePlistJson(json.value.stdout, xml.value.stdout) : parsePlistXml(xml.value.stdout);
4688
- if (!parsed.ok) return parsed;
4689
- const provenance = [
4690
- classified.value,
4691
- json.value,
4692
- ...xml === undefined ? [] : [xml.value]
4693
- ].map((item) => invocation(item, plist.value, "$PLIST"));
4694
- const result = inspectPlistSchema.parse({
4695
- format: /binary property list/iu.test(classified.value.stdout) ? "binary" : /XML|text/iu.test(classified.value.stdout) ? "xml" : "unknown",
4696
- value: parsed.value.value,
4697
- bundle: parsed.value.bundle,
4698
- source_path: plist.value,
4699
- provenance,
4700
- limitations: parsed.value.limitations
4701
- });
4702
- return ok({
4703
- result: jsonValueSchema.parse(result),
4704
- limitations: parsed.value.limitations,
4705
- locations: [{
4706
- kind: "artifact-path",
4707
- path: plist.value
4708
- }]
4709
- });
5213
+ try {
5214
+ return await this.#plistResources.run(async () => {
5215
+ try {
5216
+ const plist = await resolveNativePlistSelection(this.target, requested);
5217
+ if (!plist.ok) return plist;
5218
+ const fileInput = {
5219
+ selection: plist.value,
5220
+ resources: this.#plistResources,
5221
+ signal
5222
+ };
5223
+ const selected = await requireRegularPlist(fileInput);
5224
+ if (!selected.ok) return selected;
5225
+ const classified = await this.#run("inspect_plist", "file", ["-b", plist.value.path], { signal });
5226
+ if (!classified.ok) return classified;
5227
+ const json = await this.#run("inspect_plist", "plutil", [
5228
+ "-convert",
5229
+ "json",
5230
+ "-o",
5231
+ "-",
5232
+ "--",
5233
+ plist.value.path
5234
+ ], {
5235
+ signal,
5236
+ acceptNonZero: true
5237
+ });
5238
+ if (!json.ok) return json;
5239
+ const jsonDecoded = json.value.exitCode === 0;
5240
+ const xml = jsonDecoded && !plistJsonNeedsNumberTypes(json.value.stdout) ? undefined : await this.#run("inspect_plist", "plutil", [
5241
+ "-convert",
5242
+ "xml1",
5243
+ "-o",
5244
+ "-",
5245
+ "--",
5246
+ plist.value.path
5247
+ ], {
5248
+ signal,
5249
+ acceptNonZero: !jsonDecoded
5250
+ });
5251
+ if (xml !== undefined && !xml.ok) return xml;
5252
+ if (xml !== undefined && xml.value.exitCode !== 0) {
5253
+ const capture = failureCapture(xml.value, false);
5254
+ return err(unreadablePlist(plist.value, `plutil could not decode it as a property list (${plutilDiagnostic(capture, plist.value.path)})`, { capturedOutput: {
5255
+ stdout: capture.stdout,
5256
+ stderr: capture.stderr,
5257
+ truncated: capture.truncated,
5258
+ stdout_bytes: capture.stdoutBytes,
5259
+ stderr_bytes: capture.stderrBytes,
5260
+ exit_code: capture.exitCode,
5261
+ signal: capture.signal
5262
+ } }));
5263
+ }
5264
+ const parsed = xml === undefined ? parsePlistJson(json.value.stdout) : jsonDecoded ? parsePlistJson(json.value.stdout, xml.value.stdout) : parsePlistXml(xml.value.stdout);
5265
+ if (!parsed.ok) return parsed;
5266
+ const provenance = [
5267
+ classified.value,
5268
+ json.value,
5269
+ ...xml === undefined ? [] : [xml.value]
5270
+ ].map((item) => invocation(item, plist.value.path, "$PLIST"));
5271
+ const converted = xml?.value ?? json.value;
5272
+ const format = await plistSourceFormat(classified.value.stdout, {
5273
+ ...fileInput,
5274
+ capturedOutput: {
5275
+ stdout: converted.stdout,
5276
+ stderr: converted.stderr,
5277
+ truncated: false,
5278
+ stdout_bytes: converted.stdoutBytes,
5279
+ stderr_bytes: converted.stderrBytes,
5280
+ exit_code: converted.exitCode,
5281
+ signal: converted.signal
5282
+ }
5283
+ });
5284
+ if (!format.ok) return format;
5285
+ const result = inspectPlistSchema.parse({
5286
+ format: format.value,
5287
+ value: parsed.value.value,
5288
+ bundle: parsed.value.bundle,
5289
+ source_path: plist.value.path,
5290
+ provenance,
5291
+ limitations: parsed.value.limitations
5292
+ });
5293
+ return ok({
5294
+ result: jsonValueSchema.parse(result),
5295
+ limitations: parsed.value.limitations,
5296
+ locations: [{
5297
+ kind: "artifact-path",
5298
+ path: plist.value.path
5299
+ }]
5300
+ });
5301
+ } catch (cause) {
5302
+ return err(nativeOutputFailure("inspect_plist", cause));
5303
+ }
5304
+ });
5305
+ } catch (cause) {
5306
+ return err(nativePlistFailure(cause, undefined));
5307
+ }
4710
5308
  }
4711
5309
  async #inspectMacho(signal) {
4712
5310
  if (!isMachOFormat(this.target.format)) return err(new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_macho", "Active artifact is not Mach-O."));
@@ -4741,8 +5339,56 @@ function init_NativeMacOSProvider() {
4741
5339
  resources: [...resources]
4742
5340
  }))
4743
5341
  });
5342
+ closeNativeFileScope = async (scope, resource) => {
5343
+ try {
5344
+ await scope.close();
5345
+ return undefined;
5346
+ } catch (cause) {
5347
+ const observation = ArtifactReaderFailure.cleanupObservation(cause, resource);
5348
+ const failure = new ProviderCleanupError(NATIVE_MACOS_PROVIDER_IDENTITY.id, observation.resources, { reason: observation.reason }, {
5349
+ operation: "close_binary",
5350
+ cause
5351
+ });
5352
+ bindArtifactFileCleanup(cause, failure);
5353
+ return failure;
5354
+ }
5355
+ };
5356
+ nativeOutputFailure = (operation, cause) => new AnalysisOutputError(operation, "Native output parsing failed", { cause });
4744
5357
  isNativeOperation = (operation) => NATIVE_TOOL_CONTRACTS.some(({ name }) => name === operation);
4745
5358
  translateCommandFailure = (operation, failure) => {
5359
+ const preparation = failure.preparationFailure;
5360
+ if (preparation !== undefined) {
5361
+ const marker = preparation.cleanupFailure;
5362
+ const compiler = preparation.compilerOutcome;
5363
+ const options = {
5364
+ cause: failure,
5365
+ ...preparation.capturedOutput === undefined ? {} : { capturedOutput: preparation.capturedOutput },
5366
+ ...marker === undefined ? {} : { cleanup: {
5367
+ reason: marker.message,
5368
+ resources: marker.cleanupResources
5369
+ } },
5370
+ diagnostics: {
5371
+ phase: "process-preparation",
5372
+ tool: failure.tool,
5373
+ reason: failure.reason,
5374
+ detail: preparation.message,
5375
+ ...compiler === undefined ? {} : { compiler_outcome: {
5376
+ outcome: compiler.outcome,
5377
+ code: compiler.code,
5378
+ signal: compiler.signal,
5379
+ ...compiler.timeoutMs === undefined ? {} : { timeout_ms: compiler.timeoutMs }
5380
+ } }
5381
+ }
5382
+ };
5383
+ const error = preparation.cancellation === undefined ? new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, operation, options) : failure.reason === "timeout" ? new AnalysisTimeoutError(operation, NATIVE_COMMAND_TIMEOUT_MS, {
5384
+ ...options,
5385
+ cause: preparation.cancellation.reason
5386
+ }) : new AnalysisCancelledError(operation, {
5387
+ ...options,
5388
+ cause: preparation.cancellation.reason
5389
+ });
5390
+ return marker === undefined ? error : error.bindCleanupDependencies([marker]);
5391
+ }
4746
5392
  const capturedOutput = failure.capture === null ? undefined : {
4747
5393
  stdout: failure.capture.stdout,
4748
5394
  stderr: failure.capture.stderr,
@@ -4822,50 +5468,31 @@ function init_NativeMacOSProvider() {
4822
5468
  const end = output.lastIndexOf("</plist>");
4823
5469
  if (start < 0 || end < start) return {
4824
5470
  value: null,
4825
- omittedPrototypeKeys: 0
5471
+ omittedPrototypeKeys: 0,
5472
+ limitations: []
4826
5473
  };
4827
- const { value, omittedPrototypeKeys } = parseXmlPropertyList(output.slice(start, end + "</plist>".length));
5474
+ const decoded = parseXmlPropertyList(output.slice(start, end + "</plist>".length));
5475
+ const projected = projectPlistValue(decoded.value);
5476
+ const numbers = createPlistNumberProjection(decoded.numberLiterals);
5477
+ const value = numbers.project(projected.value);
4828
5478
  return {
4829
- value: jsonValueSchema.parse(value),
4830
- omittedPrototypeKeys
5479
+ value,
5480
+ omittedPrototypeKeys: decoded.omittedPrototypeKeys,
5481
+ limitations: [
5482
+ ...numbers.limitations(),
5483
+ ...projected.nonFiniteRealCount === 0 ? [] : [nonFiniteRealLimitation(projected.nonFiniteRealCount)],
5484
+ ...projected.unknownRealCount === 0 ? [] : [unknownRealLimitation(projected.unknownRealCount)],
5485
+ ...projected.negativeZeroRealCount === 0 ? [] : [negativeZeroRealLimitation(projected.negativeZeroRealCount)],
5486
+ ...projected.unknownDateCount === 0 ? [] : [unknownDateLimitation(projected.unknownDateCount)]
5487
+ ]
4831
5488
  };
4832
5489
  };
4833
- unreadablePlist = (path, requested, reason) => {
4834
- const sentence = reason.endsWith(".") ? reason : `${reason}.`;
4835
- const missingDefault = `The target has no readable Contents/Info.plist at ${path}: ${sentence} Select another plist in the target with the path input (CLI: --relative-path).`;
4836
- return requested === undefined ? new AnalysisCapabilityUnavailableError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", missingDefault, { userMessage: missingDefault }) : new AnalysisInputError("inspect_plist", undefined, [{
4837
- path: ["path"],
4838
- reason: "invalid_value",
4839
- message: `Cannot inspect ${path}: ${sentence}`
4840
- }]);
4841
- };
4842
- plutilDiagnostic = (stderr, path) => {
4843
- const text = stderr.trim();
4844
- return text.startsWith(`${path}: `) ? text.slice(path.length + 2) : text;
4845
- };
4846
- requireRegularPlist = async (path, requested) => {
4847
- try {
4848
- if (!(await stat(path)).isFile()) return err(unreadablePlist(path, requested, "it is not a regular file"));
4849
- await (await open(path, "r")).close();
4850
- return ok(null);
4851
- } catch (cause) {
4852
- const code = cause instanceof Error && "code" in cause ? cause.code : undefined;
4853
- if (code === "ENOENT" || code === "ENOTDIR") return err(unreadablePlist(path, requested, "no file exists there"));
4854
- if (code === "EACCES" || code === "EPERM") return err(new BinaryTargetError(path, `permission denied while reading plist (${code})`, { cause }));
4855
- return err(new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", { cause }));
4856
- }
4857
- };
4858
- resolvePlistPath = async (target, requested) => {
4859
- try {
4860
- const source = target.sourcePath ?? target.path;
4861
- if (requested !== undefined && isAbsolute(requested)) return ok(resolve(requested));
4862
- const sourceMetadata = await stat(source);
4863
- const root = sourceMetadata.isDirectory() ? source : dirname(target.path);
4864
- if (requested !== undefined) return ok(resolve(root, requested));
4865
- return ok(target.bundleInfoPlist ?? resolve(root, "Contents/Info.plist"));
4866
- } catch (cause) {
4867
- return err(new ProviderAdapterError(NATIVE_MACOS_PROVIDER_IDENTITY.id, "inspect_plist", { cause }));
4868
- }
5490
+ plutilDiagnostic = (capture, path) => {
5491
+ const diagnostics = [capture.stderr, capture.stdout].map((stream) => {
5492
+ const text = stream.trim();
5493
+ return text.startsWith(`${path}: `) ? text.slice(path.length + 2) : text;
5494
+ }).filter((text) => text.length > 0);
5495
+ return diagnostics.length === 0 ? "plutil printed no diagnostic" : diagnostics.join("\n");
4869
5496
  };
4870
5497
  })))();
4871
5498
  }