rea-agents 5.0.0 → 6.1.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 (507) hide show
  1. package/README.md +168 -655
  2. package/bridge/android/ReaJadxBridge.java +14 -5
  3. package/bridge/ghidra/ReaGhidraBridge.java +173 -47
  4. package/bridge/hopper_bridge.py +310 -128
  5. package/bridge/mitmproxy/capture.py +208 -0
  6. package/bridge/native/rea_lldb_tracer.py +839 -0
  7. package/bridge/process/ProcessRunTokenReader.swift +297 -0
  8. package/bridge/process/ProcessRunTokenReaderMain.swift +35 -0
  9. package/bridge/pwndbg/core_context.py +101 -0
  10. package/bridge/pwndbg/launch.py +39 -0
  11. package/bridge/pwndbg/launch_impl.py +34 -0
  12. package/bridge/pwntools/decoder_runtime.py +59 -0
  13. package/bridge/pwntools/layout.py +39 -0
  14. package/bridge/pwntools/layout_impl.py +309 -0
  15. package/bridge/pwntools/recorded_crash.py +39 -0
  16. package/bridge/pwntools/recorded_crash_impl.py +147 -0
  17. package/dist/android/JadxConfiguration.js +196 -33
  18. package/dist/android/JadxMcpTransport.js +4 -0
  19. package/dist/android/JadxProtocol.js +6 -0
  20. package/dist/android/JadxProvider.js +20 -2
  21. package/dist/android/JadxSession.js +23 -4
  22. package/dist/application/AnalysisContextQueries.js +8 -35
  23. package/dist/application/AnalysisDocument.js +32 -0
  24. package/dist/application/AppBundleExecutable.js +67 -21
  25. package/dist/application/CallPathTracing.js +19 -3
  26. package/dist/application/CapabilityInventory.js +27 -3
  27. package/dist/application/ClientConfigurationDocument.js +871 -6
  28. package/dist/application/ClientRegistrationIdentity.js +26 -5
  29. package/dist/application/ClientRegistrationStatus.js +29 -14
  30. package/dist/application/DirectAnalysis.js +97 -33
  31. package/dist/application/Doctor.js +4 -2
  32. package/dist/application/DoctorScope.js +25 -13
  33. package/dist/application/EnhancedLiteralTracing.js +22 -25
  34. package/dist/application/EnhancedTools.js +13 -11
  35. package/dist/application/EvidenceBundleFiles.js +24 -12
  36. package/dist/application/FunctionAnalysisEvidence.js +2 -3
  37. package/dist/application/InventoryProjectionEvidence.js +4 -3
  38. package/dist/application/InvestigationProviders.js +3 -2
  39. package/dist/application/JsonFiles.js +50 -28
  40. package/dist/application/ProcedureAddressResolution.js +11 -0
  41. package/dist/application/ReconstructionCoverageService.js +7 -4
  42. package/dist/application/ReconstructionObligationCandidates.js +5 -1
  43. package/dist/application/ReconstructionObligationLedgerService.js +4 -3
  44. package/dist/application/Setup.js +13 -1
  45. package/dist/application/SetupClientConfiguration.js +10 -15
  46. package/dist/application/SetupHost.js +5 -2
  47. package/dist/application/SetupPlan.js +5 -3
  48. package/dist/application/SupportedClients.js +34 -1
  49. package/dist/application/Uninstall.js +4 -3
  50. package/dist/application/Update.js +18 -3
  51. package/dist/application/UpdateRuntime.js +46 -25
  52. package/dist/application/WebModuleTraceService.js +4 -2
  53. package/dist/application/WebNetworkCapturePort.js +1 -0
  54. package/dist/application/WebNetworkCaptureService.js +134 -0
  55. package/dist/application/WebRuntimeService.js +5 -3
  56. package/dist/application/WebScriptExportService.js +2 -2
  57. package/dist/application/WebSourceLocationService.js +4 -2
  58. package/dist/application/WindowsCapabilities.js +1 -1
  59. package/dist/application/WorkflowEvidence.js +82 -0
  60. package/dist/application/binary/AnalysisProviderEvaluation.js +21 -5
  61. package/dist/application/binary/AnalysisProviderRegistry.js +2 -0
  62. package/dist/application/binary/AnalysisSnapshotCache.js +52 -12
  63. package/dist/application/binary/BinarySession.js +131 -76
  64. package/dist/application/binary/BinarySessionOpen.js +19 -6
  65. package/dist/application/binary/BinarySessionRecords.js +45 -3
  66. package/dist/application/binary/BinarySessionStatus.js +17 -1
  67. package/dist/application/binary/CompositeProvider.js +13 -0
  68. package/dist/application/binary/LazyAnalysisProvider.js +3 -0
  69. package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
  70. package/dist/application/binaryDiagnostics/BinaryLayoutService.js +59 -0
  71. package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
  72. package/dist/application/binaryDiagnostics/RecordedCrashService.js +62 -0
  73. package/dist/application/evm/EvmInterfacePort.js +1 -0
  74. package/dist/application/evm/EvmInterfaceService.js +64 -0
  75. package/dist/application/investigation/EvidenceLedger.js +21 -7
  76. package/dist/application/investigation/InvestigationRecords.js +8 -0
  77. package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
  78. package/dist/application/javascript/JavaScriptApplicationEvidence.js +25 -5
  79. package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +19 -2
  80. package/dist/application/javascript/JavaScriptApplicationService.js +34 -14
  81. package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +5 -5
  82. package/dist/application/javascript/JavaScriptArtifactAnalysis.js +47 -27
  83. package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +39 -7
  84. package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
  85. package/dist/application/javascript/JavaScriptArtifactPathResolution.js +80 -27
  86. package/dist/application/javascript/JavaScriptArtifactReconstruction.js +33 -12
  87. package/dist/application/javascript/JavaScriptModuleRelationships.js +37 -8
  88. package/dist/application/javascript/JavaScriptRecoveryService.js +4 -2
  89. package/dist/application/javascript/JavaScriptRuntimeObservationService.js +3 -1
  90. package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +3 -3
  91. package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
  92. package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +149 -72
  93. package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +14 -15
  94. package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +41 -1
  95. package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +7 -7
  96. package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -9
  97. package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +3 -3
  98. package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +118 -12
  99. package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +3 -3
  100. package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +27 -5
  101. package/dist/application/managed/ManagedApplicationGraphService.js +4 -3
  102. package/dist/application/managed/ManagedMemberComparisonService.js +7 -4
  103. package/dist/application/managed/ManagedNativeVerificationService.js +4 -3
  104. package/dist/application/managed/ManagedReconstructionService.js +4 -3
  105. package/dist/application/{ProcessCli.js → process/ProcessCli.js} +23 -15
  106. package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +8 -7
  107. package/dist/application/workflowInputError.js +18 -0
  108. package/dist/artifacts/ArtifactProvider.js +42 -5
  109. package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
  110. package/dist/artifacts/MachOSliceArtifactReader.js +98 -14
  111. package/dist/artifacts/NativeDmgArtifactReader.js +13 -6
  112. package/dist/artifacts/ZipArtifactReader.js +3 -0
  113. package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +22 -3
  114. package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
  115. package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +176 -56
  116. package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +195 -0
  117. package/dist/artifacts/apple/KeyedArchiveReader.js +36 -22
  118. package/dist/artifacts/apple/MachoLoadCommandReader.js +355 -0
  119. package/dist/artifacts/apple/NibArchive.js +81 -14
  120. package/dist/artifacts/apple/NibViewHierarchy.js +10 -3
  121. package/dist/artifacts/apple/PlistNumberLiterals.js +164 -0
  122. package/dist/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
  123. package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +16 -11
  124. package/dist/{application → artifacts/inventory}/ArtifactInventory.js +4 -4
  125. package/dist/{application/ArtifactInventory → artifacts/inventory}/classify.js +2 -2
  126. package/dist/{application/ArtifactInventory → artifacts/inventory}/reader.js +5 -5
  127. package/dist/{application/ArtifactInventory → artifacts/inventory}/scanCanonical.js +14 -17
  128. package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
  129. package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +6 -2
  130. package/dist/artifacts/readStableArtifact.js +20 -4
  131. package/dist/browser/CdpCaptureCompleteness.js +2 -0
  132. package/dist/browser/CdpCaptureEventHandlers.js +165 -12
  133. package/dist/browser/CdpCaptureEventTypes.js +5 -1
  134. package/dist/browser/CdpCaptureEvents.js +34 -0
  135. package/dist/browser/CdpConnection.js +30 -11
  136. package/dist/browser/CdpOptionalCommand.js +2 -3
  137. package/dist/browser/CdpPageCapture.js +23 -1
  138. package/dist/browser/PlaywrightElectronActiveActions.js +32 -23
  139. package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
  140. package/dist/browser/PlaywrightElectronActiveProvider.js +130 -122
  141. package/dist/browser/WebSourceMapFetcher.js +426 -72
  142. package/dist/browser/assets/LocalWebScriptArtifacts.js +2 -2
  143. package/dist/browser/history/CaptureFailures.js +137 -0
  144. package/dist/browser/history/CaptureFormatError.js +10 -0
  145. package/dist/browser/history/CaptureRedaction.js +65 -0
  146. package/dist/browser/history/CaptureRelease.js +17 -0
  147. package/dist/browser/history/HarCapture.js +165 -0
  148. package/dist/browser/history/HarCaptureAdapter.js +20 -0
  149. package/dist/browser/history/HarCaptureProcess.js +57 -0
  150. package/dist/browser/history/HarJson.js +92 -0
  151. package/dist/browser/history/HarSchema.js +72 -0
  152. package/dist/browser/history/HistoricalCaptureDecoder.js +188 -0
  153. package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
  154. package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
  155. package/dist/cli/analysisSelector.js +23 -0
  156. package/dist/cli/applicationCommands.js +2 -3
  157. package/dist/cli/artifactCommands.js +26 -1
  158. package/dist/cli/binaryDiagnosticsCommands.js +39 -0
  159. package/dist/cli/coreAnalysisCommands.js +2 -2
  160. package/dist/cli/coreBinaryCommands.js +78 -20
  161. package/dist/cli/electronCommands.js +21 -13
  162. package/dist/cli/evmCommands.js +24 -0
  163. package/dist/cli/firmwareCommands.js +6 -3
  164. package/dist/cli/javascriptApplicationAnalysis.js +20 -3
  165. package/dist/cli/jsonOutput.js +38 -0
  166. package/dist/cli/nativeCallCommands.js +34 -0
  167. package/dist/cli/processCommands.js +1 -1
  168. package/dist/cli/streamedJsonOutput.js +56 -0
  169. package/dist/cli/utilityCommands.js +2 -0
  170. package/dist/cli/webNetworkCaptureCommands.js +40 -0
  171. package/dist/cli/webRuntimeCommands.js +8 -8
  172. package/dist/cli.js +11 -4
  173. package/dist/cliBrowserScenarioCommands.js +2 -2
  174. package/dist/cliCommandNames.js +6 -1
  175. package/dist/cliJsonInput.js +35 -1
  176. package/dist/cliOutput.js +21 -6
  177. package/dist/composition/binaryDiagnostics.js +8 -0
  178. package/dist/composition/evm.js +4 -0
  179. package/dist/composition/webNetworkCaptures.js +6 -0
  180. package/dist/config/environment.js +4 -0
  181. package/dist/config/ghidraStartupTimeout.js +17 -0
  182. package/dist/config/mcpResponseBudget.js +22 -0
  183. package/dist/config/parseConfig.js +2 -1
  184. package/dist/contracts/artifactToolContracts.js +6 -0
  185. package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
  186. package/dist/contracts/browserToolContracts.js +4 -3
  187. package/dist/contracts/enhancedInputs.js +5 -3
  188. package/dist/contracts/enhancedToolContracts.js +3 -3
  189. package/dist/contracts/errorSchemas.js +8 -1
  190. package/dist/contracts/evm/evmToolContracts.js +20 -0
  191. package/dist/contracts/hopperMemoryContracts.js +2 -5
  192. package/dist/contracts/investigationExamples.js +2 -2
  193. package/dist/contracts/javascript/electronToolContracts.js +1 -1
  194. package/dist/contracts/managed/managedToolContracts.js +8 -6
  195. package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
  196. package/dist/contracts/native/nativeToolContracts.js +21 -3
  197. package/dist/contracts/officialToolContracts.js +26 -24
  198. package/dist/contracts/process/processCaptureExample.js +2 -0
  199. package/dist/contracts/promptContracts.js +3 -3
  200. package/dist/contracts/sessionLifecycleInputs.js +18 -5
  201. package/dist/contracts/sessionStatusContract.js +8 -2
  202. package/dist/contracts/sessionToolContracts.js +8 -3
  203. package/dist/contracts/sessionToolSchemas.js +8 -4
  204. package/dist/contracts/toolContractExamples.js +1 -2
  205. package/dist/contracts/toolContractHelpers.js +4 -1
  206. package/dist/contracts/toolContracts.js +6 -0
  207. package/dist/contracts/toolEffects.js +30 -1
  208. package/dist/contracts/toolOutputSchemaGroups.js +33 -28
  209. package/dist/contracts/toolOutputSchemaPrimitives.js +19 -1
  210. package/dist/contracts/toolSchemaMetadata.js +69 -10
  211. package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
  212. package/dist/domain/analysisErrorBase.js +22 -2
  213. package/dist/domain/analysisErrorCore.js +61 -5
  214. package/dist/domain/analysisErrorPresentation.js +95 -12
  215. package/dist/domain/analysisErrorProjection.js +148 -19
  216. package/dist/domain/analysisSnapshot.js +166 -2
  217. package/dist/domain/android/androidAnalysis.js +2 -4
  218. package/dist/domain/android/androidApplication.js +17 -9
  219. package/dist/domain/apple/appleApplication.js +41 -14
  220. package/dist/domain/apple/dyldEnvironment.js +73 -0
  221. package/dist/domain/apple/dyldPaths.js +81 -0
  222. package/dist/domain/apple/dylibResolution.js +478 -0
  223. package/dist/domain/apple/dylibResolutionFindings.js +77 -0
  224. package/dist/domain/apple/interfaceBuilderGraph.js +25 -13
  225. package/dist/domain/apple/interfaceBuilderKeyedArchive.js +13 -3
  226. package/dist/domain/apple/keyedArchive.js +9 -1
  227. package/dist/domain/apple/machoContainer.js +54 -0
  228. package/dist/domain/apple/plistNumbers.js +76 -0
  229. package/dist/domain/artifactIdentity.js +29 -0
  230. package/dist/domain/artifactInventoryEvidence.js +19 -24
  231. package/dist/domain/artifactPathSyntax.js +1 -1
  232. package/dist/domain/bridgeCandidateProjection.js +71 -0
  233. package/dist/domain/browserCompleteness.js +1 -0
  234. package/dist/domain/browserObservation.js +1 -1
  235. package/dist/domain/browserObservationError.js +24 -5
  236. package/dist/domain/browserObservationSchemas.js +13 -0
  237. package/dist/domain/browserScenarioValues.js +5 -2
  238. package/dist/domain/bundleComparison.js +3 -2
  239. package/dist/domain/callPathSchemas.js +1 -1
  240. package/dist/domain/canonicalDigest.js +13 -1
  241. package/dist/domain/canonicalJsonDigestSteps.js +133 -0
  242. package/dist/domain/canonicalOrdering.js +9 -5
  243. package/dist/domain/changedBehavior.js +9 -9
  244. package/dist/domain/comparisonSourceEvidence.js +40 -0
  245. package/dist/domain/comparisonStatus.js +2 -30
  246. package/dist/domain/configurationErrors.js +1 -1
  247. package/dist/domain/conformanceTrustGate.js +0 -16
  248. package/dist/domain/evidence.js +78 -11
  249. package/dist/domain/evidenceBundle.js +42 -1
  250. package/dist/domain/evidenceErrors.js +12 -1
  251. package/dist/domain/evm/evmInterface.js +63 -0
  252. package/dist/domain/explicitSensitiveFailure.js +108 -0
  253. package/dist/domain/explicitSensitiveValues.js +10 -0
  254. package/dist/domain/firmware/firmwareAnalysis.js +10 -4
  255. package/dist/domain/hopperErrors.js +23 -2
  256. package/dist/domain/hopperValues.js +51 -8
  257. package/dist/domain/immutableJson.js +114 -0
  258. package/dist/domain/inputIssueProjection.js +3 -0
  259. package/dist/domain/javascript/electronActiveObservation.js +37 -6
  260. package/dist/domain/javascript/electronStaticAnalysisValues.js +6 -12
  261. package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
  262. package/dist/domain/javascript/javascriptApplicationAnalysis.js +71 -23
  263. package/dist/domain/javascript/javascriptApplicationGraph.js +13 -0
  264. package/dist/domain/javascript/javascriptAstValues.js +20 -0
  265. package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
  266. package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
  267. package/dist/domain/javascript/javascriptRecovery.js +3 -8
  268. package/dist/domain/javascript/javascriptSemanticAnalysis.js +97 -2
  269. package/dist/domain/javascript/javascriptSemanticCoverage.js +6 -5
  270. package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +9 -17
  271. package/dist/domain/javascript/javascriptSemanticDataEffects.js +22 -5
  272. package/dist/domain/javascript/javascriptSemanticGraph.js +34 -5
  273. package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +1 -0
  274. package/dist/domain/javascript/javascriptSemanticPrimitives.js +25 -17
  275. package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -4
  276. package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
  277. package/dist/domain/javascript/javascriptSemanticValues.js +83 -11
  278. package/dist/domain/javascript/javascriptSourceParser.js +6 -2
  279. package/dist/domain/javascript/javascriptStaticAnalysis.js +22 -17
  280. package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -3
  281. package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +14 -4
  282. package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +66 -7
  283. package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +28 -16
  284. package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -2
  285. package/dist/domain/jsonSerialization.js +109 -0
  286. package/dist/domain/jsonValue.js +91 -3
  287. package/dist/domain/localPath.js +8 -0
  288. package/dist/domain/managed/managedApplicationGraph.js +10 -10
  289. package/dist/domain/managed/managedInspectionEvidence.js +16 -0
  290. package/dist/domain/managed/managedMemberComparisonMatch.js +5 -9
  291. package/dist/domain/managed/managedNativeVerification.js +3 -9
  292. package/dist/domain/native/binaryLayout.js +357 -0
  293. package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
  294. package/dist/domain/native/nativeCallObservation.js +186 -0
  295. package/dist/domain/native/nativeCallPartialObservation.js +33 -0
  296. package/dist/domain/native/objcSwiftMetadata.js +0 -39
  297. package/dist/domain/native/recordedCrash.js +266 -0
  298. package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
  299. package/dist/domain/{processCapture.js → process/processCapture.js} +143 -2
  300. package/dist/domain/{processCaptureExample.js → process/processCaptureExample.js} +5 -0
  301. package/dist/domain/process/processCaptureParsing.js +54 -0
  302. package/dist/domain/{processCaptureValidation.js → process/processCaptureValidation.js} +18 -2
  303. package/dist/domain/{processComparison.js → process/processComparison.js} +39 -5
  304. package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
  305. package/dist/domain/{processScenario.js → process/processScenario.js} +11 -10
  306. package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
  307. package/dist/domain/propertyListKeys.js +1 -1
  308. package/dist/domain/propertyListXmlText.js +19 -0
  309. package/dist/domain/providerAdapterError.js +1 -1
  310. package/dist/domain/providerOperationHealth.js +54 -0
  311. package/dist/domain/providerSelectionError.js +4 -2
  312. package/dist/domain/reconstructionVerification.js +9 -46
  313. package/dist/domain/reconstructionVerificationSchemas.js +3 -3
  314. package/dist/domain/residualUnknown.js +3 -2
  315. package/dist/domain/staticRuntimeCorrelation.js +9 -46
  316. package/dist/domain/webBundleAnalysis.js +20 -8
  317. package/dist/domain/webBundleAnalyzerInspection.js +13 -8
  318. package/dist/domain/webBundleAnalyzerResult.js +41 -2
  319. package/dist/domain/webCaptureDiff.js +1 -0
  320. package/dist/domain/webNetworkCapture.js +118 -0
  321. package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
  322. package/dist/domain/webRuntime.js +19 -5
  323. package/dist/domain/webSourceLocation.js +1 -0
  324. package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
  325. package/dist/dotnet/ManagedMemberInspector.js +4 -2
  326. package/dist/dotnet/ManagedMemberInspectorCore.js +38 -32
  327. package/dist/dotnet/ManagedMemberInstructionDecoder.js +23 -7
  328. package/dist/dotnet/ManagedMemberRows.js +14 -3
  329. package/dist/dotnet/ManagedMetadataHeaps.js +20 -2
  330. package/dist/dotnet/ManagedMetadataInventory.js +38 -28
  331. package/dist/dotnet/ManagedMetadataInventoryRows.js +24 -10
  332. package/dist/dotnet/ManagedMethodBodyReader.js +7 -1
  333. package/dist/dotnet/ManagedNativeBoundaryHelpers.js +15 -3
  334. package/dist/dotnet/ManagedNativeBoundaryInspector.js +3 -1
  335. package/dist/dotnet/ManagedPeReader.js +11 -0
  336. package/dist/evm/EvmBytecodeCarrier.js +21 -0
  337. package/dist/evm/EvmWorkerLimits.js +40 -0
  338. package/dist/evm/EvmoleFailures.js +126 -0
  339. package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
  340. package/dist/evm/EvmoleInterfaceProvider.js +273 -0
  341. package/dist/evm/EvmoleInterfaceWorker.js +87 -0
  342. package/dist/evm/EvmoleRelease.js +16 -0
  343. package/dist/firmware/FirmwareCommand.js +1 -0
  344. package/dist/firmware/FirmwareFiles.js +1 -1
  345. package/dist/generatedPackageMetadata.js +2 -2
  346. package/dist/ghidra/GhidraAnalysisProfile.js +5 -0
  347. package/dist/ghidra/GhidraClient.js +47 -14
  348. package/dist/ghidra/GhidraDiagnostics.js +7 -7
  349. package/dist/ghidra/GhidraFunctionValues.js +10 -7
  350. package/dist/ghidra/GhidraInstallation.js +18 -21
  351. package/dist/ghidra/GhidraInventoryValues.js +14 -4
  352. package/dist/ghidra/GhidraJavaLaunch.js +62 -0
  353. package/dist/ghidra/GhidraLauncher.js +34 -16
  354. package/dist/ghidra/GhidraProvider.js +2 -2
  355. package/dist/ghidra/GhidraProviderCapabilities.js +15 -3
  356. package/dist/ghidra/GhidraProviderClient.js +23 -12
  357. package/dist/ghidra/GhidraSessionError.js +11 -7
  358. package/dist/ghidra/GhidraTargetSnapshot.js +47 -12
  359. package/dist/ghidra/GhidraTransport.js +20 -0
  360. package/dist/hopper/BridgeLauncher.js +33 -11
  361. package/dist/hopper/HopperAnalysisProfile.js +62 -4
  362. package/dist/hopper/HopperCleanup.js +15 -3
  363. package/dist/hopper/HopperClient.js +222 -14
  364. package/dist/hopper/HopperFileOffset.js +237 -0
  365. package/dist/hopper/HopperMachOImage.js +196 -0
  366. package/dist/hopper/HopperOperationStage.js +6 -0
  367. package/dist/hopper/HopperProvider.js +63 -9
  368. package/dist/hopper/HopperProviderCapabilities.js +19 -1
  369. package/dist/hopper/HopperRegexSearch.js +137 -0
  370. package/dist/hopper/HopperRegexWorker.js +27 -0
  371. package/dist/hopper/HopperRequestQueue.js +68 -19
  372. package/dist/hopper/HopperTargetLease.js +3 -2
  373. package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
  374. package/dist/inspector/JavaScriptRuntimeScope.js +9 -1
  375. package/dist/inspector/V8InspectorCaptureProjection.js +8 -3
  376. package/dist/inspector/V8InspectorProvider.js +47 -11
  377. package/dist/javascript/recovery/WakaruCommand.js +3 -0
  378. package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
  379. package/dist/javascript/sourceMaps/SourceMapCommand.js +17 -0
  380. package/dist/javascript/sourceMaps/SourceMapFormat.js +79 -31
  381. package/dist/javascript/sourceMaps/TraceSourceMap.js +14 -28
  382. package/dist/mcpDoctor.js +62 -2
  383. package/dist/native/AppleDispatchCoverage.js +47 -6
  384. package/dist/native/AppleDispatchDecodeFacts.js +6 -0
  385. package/dist/native/AppleDispatchMetadata.js +6 -3
  386. package/dist/native/AppleMachoFixups.js +48 -24
  387. package/dist/native/AppleMachoSelection.js +32 -16
  388. package/dist/native/AppleObjcCategories.js +6 -2
  389. package/dist/native/AppleObjcDispatchFacets.js +5 -2
  390. package/dist/native/AppleObjcProperties.js +2 -1
  391. package/dist/native/AppleSwiftDispatchFacets.js +27 -21
  392. package/dist/native/AppleSwiftVtables.js +21 -15
  393. package/dist/native/CommandRunner.js +82 -84
  394. package/dist/native/LldbCallTracer.js +541 -0
  395. package/dist/native/LldbRetainedObservations.js +178 -0
  396. package/dist/native/NativeCallObservation.js +194 -0
  397. package/dist/native/NativeMacOSProvider.js +117 -20
  398. package/dist/native/NativeMacOSProviderMetadata.js +8 -3
  399. package/dist/native/SignatureTargetBinding.js +155 -0
  400. package/dist/native/parsers/lipo.js +71 -1
  401. package/dist/native/pwndbg/PwndbgCoreContext.js +180 -0
  402. package/dist/native/pwntools/PwntoolsDecoder.js +203 -0
  403. package/dist/native/pwntools/PwntoolsFailures.js +180 -0
  404. package/dist/native/pwntools/PwntoolsLayoutProvider.js +36 -0
  405. package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +75 -0
  406. package/dist/native/pwntools/PwntoolsRelease.js +19 -0
  407. package/dist/native/pwntools/PwntoolsResourceLimits.js +76 -0
  408. package/dist/native/pwntools/RecordedCrashSourceBindings.js +46 -0
  409. package/dist/native/pwntools/RecordedCrashStructureBindings.js +103 -0
  410. package/dist/process/DarwinProcessRunTokenReader.js +293 -0
  411. package/dist/process/ExecFileOutput.js +20 -0
  412. package/dist/process/OwnedCommand.js +118 -0
  413. package/dist/process/ProcessOwnership.js +431 -51
  414. package/dist/process/ProcessOwnershipObservation.js +209 -27
  415. package/dist/process/ProviderProcess.js +68 -10
  416. package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
  417. package/dist/{application → process/capture}/ProcessCaptureError.js +18 -2
  418. package/dist/process/capture/ProcessCaptureLifecycle.js +681 -0
  419. package/dist/{application → process/capture}/ProcessHarness.js +195 -29
  420. package/dist/{application → process/capture}/ProcessSampling.js +2 -2
  421. package/dist/server/EvidenceMcpServer.js +146 -0
  422. package/dist/server/createServer.js +37 -8
  423. package/dist/server/promptCompletion.js +10 -3
  424. package/dist/server/registerAndroidTools.js +2 -4
  425. package/dist/server/registerApplicationTools/helpers.js +2 -4
  426. package/dist/server/registerArtifactComparisonTool.js +11 -7
  427. package/dist/server/registerBinaryDiagnosticsTools.js +15 -0
  428. package/dist/server/registerBrowserScenarioTool.js +2 -4
  429. package/dist/server/registerBrowserTools.js +2 -4
  430. package/dist/server/registerBundleComparisonTool.js +2 -3
  431. package/dist/server/registerCloseLifecycleTool.js +8 -18
  432. package/dist/server/registerElectronTools.js +2 -4
  433. package/dist/server/registerEnhancedTools.js +18 -59
  434. package/dist/server/registerEvidenceTools.js +3 -5
  435. package/dist/server/registerEvmTools.js +15 -0
  436. package/dist/server/registerFirmwareTools.js +2 -4
  437. package/dist/server/registerFunctionComparisonTool.js +10 -6
  438. package/dist/server/registerInvestigationTools.js +7 -7
  439. package/dist/server/registerJavaScriptRecoveryTool.js +2 -4
  440. package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -4
  441. package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +2 -4
  442. package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +2 -4
  443. package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +2 -4
  444. package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +2 -4
  445. package/dist/server/registerOfficialTools.js +2 -4
  446. package/dist/server/registerProcessComparisonTool.js +72 -46
  447. package/dist/server/registerRecordedCrashTools.js +15 -0
  448. package/dist/server/registerSessionRecordTools.js +5 -6
  449. package/dist/server/registerSessionStatusTool.js +17 -3
  450. package/dist/server/registerSessionTools.js +13 -5
  451. package/dist/server/registerWebModuleTool.js +2 -4
  452. package/dist/server/registerWebNetworkCaptureTool.js +26 -0
  453. package/dist/server/registerWebRuntimeTools.js +3 -7
  454. package/dist/server/registerWebScriptTool.js +2 -4
  455. package/dist/server/registerWebSourceLocationTool.js +2 -4
  456. package/dist/server/runDerivedOperation.js +15 -3
  457. package/dist/server/sessionAvailabilityPolicy.js +3 -1
  458. package/dist/server/sessionToolPolicies.js +1 -1
  459. package/dist/server/toolRegistrationOptions.js +2 -2
  460. package/dist/server/toolResult.js +63 -11
  461. package/dist/server/toolResultEncoding.js +33 -0
  462. package/install.sh +1 -1
  463. package/native/windows/build/manifest.json +2 -2
  464. package/native/windows/build/rea-windows-x64.node +0 -0
  465. package/package.json +42 -9
  466. package/scripts/electron-active-hook-boundaries.cjs +18 -20
  467. package/scripts/electron-active-hook.cjs +241 -37
  468. package/scripts/rea.mjs +11 -3
  469. package/skills/reverse-engineer-anything/SKILL.md +32 -4
  470. package/skills/reverse-engineer-anything/references/javascript-applications.md +8 -1
  471. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +29 -0
  472. package/third_party/README.md +60 -0
  473. package/third_party/evmole/LICENSE +21 -0
  474. package/third_party/evmole/README.md +22 -0
  475. package/third_party/pwndbg/LICENSE.md +21 -0
  476. package/third_party/pwndbg/README.md +23 -0
  477. package/third_party/pwntools/README.md +40 -0
  478. package/dist/application/AuthorizedArtifactInventory.js +0 -7
  479. package/dist/application/ProcessCaptureLifecycle.js +0 -299
  480. package/dist/application/StoreFileLock.js +0 -124
  481. package/dist/contracts/processCaptureExample.js +0 -2
  482. package/dist/domain/bytecodeProvider.js +0 -178
  483. package/dist/domain/customProtocolCapture.js +0 -137
  484. package/dist/domain/eventProcessTree.js +0 -225
  485. package/dist/domain/mobileApplicationInvestigation.js +0 -159
  486. package/dist/domain/packageAnalysis.js +0 -123
  487. package/dist/domain/peInspection.js +0 -197
  488. package/dist/domain/processCaptureParsing.js +0 -21
  489. package/dist/domain/protocolCapture.js +0 -217
  490. package/dist/domain/runtimeIdentification.js +0 -212
  491. package/dist/generatedMcpToolCatalog.js +0 -37
  492. package/dist/ghidra/GhidraDefaults.js +0 -2
  493. /package/dist/application/{ArtifactExtractionDestination.js → artifacts/ArtifactExtractionDestination.js} +0 -0
  494. /package/dist/{application/ArtifactInventory → artifacts/inventory}/policy.js +0 -0
  495. /package/dist/{application/ArtifactInventory → artifacts/inventory}/types.js +0 -0
  496. /package/dist/domain/{processEvidenceProvider.js → process/processEvidenceProvider.js} +0 -0
  497. /package/dist/domain/{processTraceComparison.js → process/processTraceComparison.js} +0 -0
  498. /package/dist/domain/{processTraceDimensionProjection.js → process/processTraceDimensionProjection.js} +0 -0
  499. /package/dist/domain/{processTraceEvaluation.js → process/processTraceEvaluation.js} +0 -0
  500. /package/dist/{application → process/capture}/FilesystemSnapshot.js +0 -0
  501. /package/dist/{application → process/capture}/ProcessCaptureEnvironment.js +0 -0
  502. /package/dist/{application → process/capture}/ProcessCaptureJournal.js +0 -0
  503. /package/dist/{application → process/capture}/ProcessFilesystemEffects.js +0 -0
  504. /package/dist/{application → process/capture}/ProcessNormalization.js +0 -0
  505. /package/dist/{application → process/capture}/ProcessScenarioRuntimeValidation.js +0 -0
  506. /package/dist/{application → process/capture}/ProcessTimer.js +0 -0
  507. /package/dist/{application → process/capture}/TerminalRenderer.js +0 -0
@@ -82,6 +82,7 @@ export const parseInterfaceBuilderRecords = (value) => {
82
82
  objectCount: objectEntries.length,
83
83
  omittedObjects: Math.max(0, objectEntries.length - 20_000),
84
84
  omittedConnections,
85
+ omittedHierarchyReferences: 0,
85
86
  };
86
87
  };
87
88
  /**
@@ -164,6 +165,7 @@ const keyedArchiveTable = (objectTable) => {
164
165
  return output;
165
166
  };
166
167
  const hierarchy = (start) => {
168
+ let omittedReferences = 0;
167
169
  const visited = new Set();
168
170
  const root = [];
169
171
  const pending = [
@@ -190,10 +192,17 @@ const keyedArchiveTable = (objectTable) => {
190
192
  const { value, output } = entry;
191
193
  const uid = archiveUid(value);
192
194
  if (uid !== undefined) {
195
+ // UID0 is archived nil, not a missing hierarchy object.
196
+ if (uid === 0)
197
+ continue;
198
+ const target = objectTable[uid];
199
+ if (target === undefined) {
200
+ omittedReferences += 1;
201
+ continue;
202
+ }
193
203
  if (visited.has(uid))
194
204
  continue;
195
205
  visited.add(uid);
196
- const target = objectTable[uid];
197
206
  if (Array.isArray(target)) {
198
207
  for (let index = target.length - 1; index >= 0; index -= 1) {
199
208
  const child = target[index];
@@ -229,7 +238,7 @@ const keyedArchiveTable = (objectTable) => {
229
238
  appendNode(record(value), undefined, output);
230
239
  }
231
240
  }
232
- return root;
241
+ return { items: root, omittedReferences };
233
242
  };
234
243
  const archivedArrayClass = (classReference) => {
235
244
  const uid = archiveUid(classReference);
@@ -317,11 +326,12 @@ const parseKeyedArchive = (root) => {
317
326
  return {
318
327
  objects,
319
328
  connections,
320
- hierarchy,
329
+ hierarchy: hierarchy.items,
321
330
  classes,
322
331
  objectCount,
323
332
  omittedObjects: Math.max(0, objectCount - 20_000),
324
333
  omittedConnections,
334
+ omittedHierarchyReferences: hierarchy.omittedReferences,
325
335
  };
326
336
  };
327
337
  /** Coerce unknown values to a string-keyed record; non-objects become `{}`. */
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { AnalysisInputError } from "../analysisErrorCore.js";
2
3
  import { jsonValueSchema } from "../jsonValue.js";
3
4
  /** Select one archive within the active bundle and optionally one named root. */
4
5
  export const keyedArchiveInputSchema = z.strictObject({
@@ -72,7 +73,14 @@ export const projectKeyedArchive = (value, selection) => {
72
73
  if (top === undefined || Object.keys(top).length === 0)
73
74
  throw new TypeError("Keyed archive has no $top roots");
74
75
  if (selection.root !== undefined && !Object.hasOwn(top, selection.root))
75
- throw new TypeError(`Archive root does not exist: ${selection.root}`);
76
+ throw new AnalysisInputError("inspect_keyed_archive", undefined, [
77
+ {
78
+ path: ["root"],
79
+ reason: "invalid_value",
80
+ message: `Archive root does not exist: ${selection.root}. Select one of the archive's $top roots or omit root.`,
81
+ expected: Object.keys(top),
82
+ },
83
+ ]);
76
84
  const roots = selection.root === undefined
77
85
  ? top
78
86
  : { [selection.root]: top[selection.root] ?? null };
@@ -0,0 +1,54 @@
1
+ /** Decode FAT table entries once so artifact and native readers share identity facts. */
2
+ export const readFatSliceDeclarations = (tableBytes, options) => {
3
+ const { count, wide, littleEndian } = options;
4
+ const entrySize = wide ? 32 : 20;
5
+ if (tableBytes.byteLength < count * entrySize)
6
+ return { status: "malformed", reason: "FAT table is truncated" };
7
+ const view = new DataView(tableBytes.buffer, tableBytes.byteOffset, tableBytes.byteLength);
8
+ const slices = [];
9
+ for (let index = 0; index < count; index++) {
10
+ const base = index * entrySize;
11
+ const offset = wide
12
+ ? safeNumber(view.getBigUint64(base + 8, littleEndian))
13
+ : view.getUint32(base + 8, littleEndian);
14
+ const size = wide
15
+ ? safeNumber(view.getBigUint64(base + 16, littleEndian))
16
+ : view.getUint32(base + 12, littleEndian);
17
+ if (offset === null || size === null)
18
+ return {
19
+ status: "malformed",
20
+ reason: "FAT offset or size exceeds the safe range",
21
+ };
22
+ slices.push({
23
+ index,
24
+ offset,
25
+ size,
26
+ alignmentExponent: view.getUint32(base + (wide ? 24 : 16), littleEndian),
27
+ cpuType: view.getUint32(base, littleEndian),
28
+ cpuSubtype: view.getUint32(base + 4, littleEndian),
29
+ });
30
+ }
31
+ return { status: "parsed", slices };
32
+ };
33
+ /** Validate byte-range and table/header identity facts shared by Mach-O readers. */
34
+ export const validateFatSlice = (declaration, containerSize, tableEnd, embedded) => {
35
+ const { index, offset, size, alignmentExponent, cpuType, cpuSubtype } = declaration;
36
+ if (!Number.isSafeInteger(offset) ||
37
+ !Number.isSafeInteger(size) ||
38
+ size <= 0 ||
39
+ offset < tableEnd)
40
+ return `FAT architecture ${index} has an invalid slice range`;
41
+ if (offset > containerSize || size > containerSize - offset)
42
+ return `FAT architecture ${index} slice range extends beyond the file`;
43
+ if (!Number.isInteger(alignmentExponent) ||
44
+ alignmentExponent < 0 ||
45
+ alignmentExponent > 52)
46
+ return `FAT architecture ${index} alignment exponent ${alignmentExponent} is unsupported`;
47
+ if (offset % 2 ** alignmentExponent !== 0)
48
+ return `FAT architecture ${index} offset is not aligned to 2^${alignmentExponent}`;
49
+ if (embedded !== undefined &&
50
+ (embedded.cpuType !== cpuType || embedded.cpuSubtype !== cpuSubtype))
51
+ return `FAT architecture ${index} CPU type/subtype disagrees with its Mach-O header`;
52
+ return null;
53
+ };
54
+ const safeNumber = (value) => value > BigInt(Number.MAX_SAFE_INTEGER) ? null : Number(value);
@@ -0,0 +1,76 @@
1
+ /** Preserve unambiguous exact integers; disclose rounded or unclassified numbers. */
2
+ export const createPlistNumberProjection = (literals) => {
3
+ let exactIntegerCount = 0;
4
+ let ambiguousNumberCount = 0;
5
+ const mapNumber = (item) => {
6
+ if (Number.isSafeInteger(item) || !Number.isInteger(item))
7
+ return item;
8
+ if (literals.incomplete) {
9
+ ambiguousNumberCount += 1;
10
+ return item;
11
+ }
12
+ const decimals = literals.integers.get(item);
13
+ if (decimals === undefined) {
14
+ if (!literals.reals.has(item))
15
+ ambiguousNumberCount += 1;
16
+ return item;
17
+ }
18
+ const [decimal] = decimals;
19
+ if (decimals.size !== 1 ||
20
+ decimal === undefined ||
21
+ literals.reals.has(item)) {
22
+ ambiguousNumberCount += 1;
23
+ return item;
24
+ }
25
+ exactIntegerCount += 1;
26
+ return { $plist_type: "integer", decimal };
27
+ };
28
+ const map = (item) => {
29
+ if (typeof item === "number")
30
+ return mapNumber(item);
31
+ if (Array.isArray(item))
32
+ return item.map(map);
33
+ if (item !== null && typeof item === "object") {
34
+ const keys = Object.keys(item);
35
+ const marker = item[keys[0] ?? ""];
36
+ const reference = keys.length === 1 &&
37
+ (keys[0] === "UID" || keys[0] === "CF$UID") &&
38
+ typeof marker === "number";
39
+ if (reference) {
40
+ // Keep malformed numeric reference markers recognizable by the graph reader.
41
+ if (typeof marker === "number" &&
42
+ !Number.isSafeInteger(marker) &&
43
+ (literals.integers.has(marker) || !literals.reals.has(marker)))
44
+ ambiguousNumberCount += 1;
45
+ return item;
46
+ }
47
+ return Object.fromEntries(Object.entries(item).map(([key, child]) => [key, map(child)]));
48
+ }
49
+ return item;
50
+ };
51
+ return {
52
+ project: map,
53
+ limitations: () => [
54
+ ...(literals.incomplete
55
+ ? [
56
+ "Original archive number metadata could not be completely observed; decoded numbers may lose integer precision and exact integer/real association is unavailable.",
57
+ ]
58
+ : []),
59
+ ...(literals.unsafeIntegerLiterals === 0
60
+ ? []
61
+ : [
62
+ `${String(literals.unsafeIntegerLiterals)} observed integer literal(s) in the original archive exceed the exact range of a JSON number. Decoded numbers may lose integer precision unless represented as { "$plist_type": "integer", "decimal": "<exact digits>" }; the original archive bytes retain those literals.`,
63
+ ]),
64
+ ...(exactIntegerCount === 0
65
+ ? []
66
+ : [
67
+ `${String(exactIntegerCount)} unambiguous integer value(s) are reported with exact decimal text as { "$plist_type": "integer", "decimal": "<exact digits>" }.`,
68
+ ]),
69
+ ...(ambiguousNumberCount === 0
70
+ ? []
71
+ : [
72
+ `${String(ambiguousNumberCount)} number(s) beyond the exact integer range remain as decoded because their source integer/real type or reference marker cannot be associated unambiguously; integer precision loss remains possible.`,
73
+ ]),
74
+ ],
75
+ };
76
+ };
@@ -0,0 +1,29 @@
1
+ import { canonicalDigest } from "./comparisonSemantics.js";
2
+ /** Content-address an artifact independently of where it was observed. */
3
+ export const artifactIdForContent = (sha256) => `art_${canonicalDigest({ sha256 }, "Artifact")}`;
4
+ /** Identify an occurrence by its root and exact logical location. */
5
+ export const occurrenceIdForLocation = (input) => input.logicalPath === "."
6
+ ? `occ_${canonicalDigest({ root: input.rootArtifactId }, "Artifact")}`
7
+ : `occ_${canonicalDigest({
8
+ root_artifact_id: input.rootArtifactId,
9
+ logical_path: input.logicalPath,
10
+ entry_kind: input.entryKind,
11
+ }, "Artifact")}`;
12
+ /** Commit to graph members in the ordering established by the inventory owner. */
13
+ export const artifactGraphDigest = (input) => canonicalDigest({
14
+ nodes: input.nodes,
15
+ occurrences: input.occurrences,
16
+ edges: input.edges,
17
+ integrity_contradictions: input.contradictions,
18
+ }, "Artifact");
19
+ /** Bind a root artifact to its graph commitment. */
20
+ export const artifactManifestId = (rootArtifactId, graphSha256) => `agm_${canonicalDigest({ root_artifact_id: rootArtifactId, graph_sha256: graphSha256 }, "Artifact")}`;
21
+ /** Identify one integrity disagreement at its observed logical path. */
22
+ export const artifactContradictionId = (input) => `ic_${canonicalDigest({
23
+ root_artifact_id: input.rootArtifactId,
24
+ logical_path: input.logicalPath,
25
+ declared_sha256: input.declaredSha256,
26
+ observed_sha256: input.observedSha256,
27
+ }, "Artifact")}`;
28
+ /** Identify an edge by its semantic relationship and exact occurrence. */
29
+ export const artifactEdgeId = (semantic) => `edge_${canonicalDigest(semantic, "Artifact")}`;
@@ -1,5 +1,6 @@
1
1
  import { artifactInventoryResultSchema, } from "./artifactGraph.js";
2
- import { canonicalDigest, canonicalJson } from "./comparisonSemantics.js";
2
+ import { canonicalJson } from "./comparisonSemantics.js";
3
+ import { artifactContradictionId, artifactEdgeId, artifactGraphDigest, artifactIdForContent, artifactManifestId, occurrenceIdForLocation, } from "./artifactIdentity.js";
3
4
  import { parseEvidence } from "./evidence.js";
4
5
  import { artifactInspectionResultSchema } from "./artifactInspection.js";
5
6
  import { err, ok } from "./result.js";
@@ -29,8 +30,7 @@ const validateInventoryPage = (inventory) => {
29
30
  assertUnique(inventory.occurrences.map(({ logical_path: path }) => path), "logical path");
30
31
  assertUnique(inventory.edges.map(({ edge_id: id }) => id), "edge ID");
31
32
  for (const node of inventory.nodes)
32
- if (node.artifact_id !==
33
- `art_${canonicalDigest({ sha256: node.sha256 }, "Artifact inventory")}`)
33
+ if (node.artifact_id !== artifactIdForContent(node.sha256))
34
34
  throw new TypeError("Artifact node ID is not content-addressed");
35
35
  };
36
36
  /**
@@ -110,27 +110,24 @@ const validateCompleteInventory = (inventory) => {
110
110
  if (!nodeIds.has(contradiction.parent_artifact_id) ||
111
111
  !occurrenceIds.has(contradiction.occurrence_id))
112
112
  throw new TypeError("Integrity contradiction references a missing graph member");
113
- const expectedId = `ic_${canonicalDigest({
114
- root_artifact_id: inventory.manifest.root_artifact_id,
115
- logical_path: contradiction.logical_path,
116
- declared_sha256: contradiction.declared_sha256,
117
- observed_sha256: contradiction.observed_sha256,
118
- }, "Artifact inventory")}`;
113
+ const expectedId = artifactContradictionId({
114
+ rootArtifactId: inventory.manifest.root_artifact_id,
115
+ logicalPath: contradiction.logical_path,
116
+ declaredSha256: contradiction.declared_sha256,
117
+ observedSha256: contradiction.observed_sha256,
118
+ });
119
119
  if (contradiction.contradiction_id !== expectedId)
120
120
  throw new TypeError("Integrity contradiction ID does not match its identity");
121
121
  }
122
- const graphSha256 = canonicalDigest({
122
+ const graphSha256 = artifactGraphDigest({
123
123
  nodes: inventory.nodes,
124
124
  occurrences: inventory.occurrences,
125
125
  edges: inventory.edges,
126
- integrity_contradictions: inventory.integrityContradictions,
127
- }, "Artifact inventory");
126
+ contradictions: inventory.integrityContradictions,
127
+ });
128
128
  if (graphSha256 !== inventory.manifest.graph_sha256)
129
129
  throw new TypeError("Artifact graph commitment does not match its members");
130
- const manifestId = `agm_${canonicalDigest({
131
- root_artifact_id: inventory.manifest.root_artifact_id,
132
- graph_sha256: graphSha256,
133
- }, "Artifact inventory")}`;
130
+ const manifestId = artifactManifestId(inventory.manifest.root_artifact_id, graphSha256);
134
131
  if (manifestId !== inventory.manifest.manifest_id)
135
132
  throw new TypeError("Artifact manifest ID does not match its commitment");
136
133
  };
@@ -140,13 +137,11 @@ const validateOccurrence = (occurrence, inventory, nodeIds, occurrenceIds) => {
140
137
  if (occurrence.parent_occurrence_id !== null &&
141
138
  !occurrenceIds.has(occurrence.parent_occurrence_id))
142
139
  throw new TypeError("Artifact occurrence references a missing parent");
143
- const expectedId = occurrence.logical_path === "."
144
- ? `occ_${canonicalDigest({ root: inventory.manifest.root_artifact_id }, "Artifact inventory")}`
145
- : `occ_${canonicalDigest({
146
- root_artifact_id: inventory.manifest.root_artifact_id,
147
- logical_path: occurrence.logical_path,
148
- entry_kind: occurrence.entry_kind,
149
- }, "Artifact inventory")}`;
140
+ const expectedId = occurrenceIdForLocation({
141
+ rootArtifactId: inventory.manifest.root_artifact_id,
142
+ logicalPath: occurrence.logical_path,
143
+ entryKind: occurrence.entry_kind,
144
+ });
150
145
  if (occurrence.occurrence_id !== expectedId)
151
146
  throw new TypeError("Artifact occurrence ID does not match its identity");
152
147
  };
@@ -162,7 +157,7 @@ const validateEdge = (edge, nodeIds, occurrenceIds) => {
162
157
  occurrence_id: edge.occurrence_id,
163
158
  logical_path: edge.logical_path,
164
159
  };
165
- if (edge.edge_id !== `edge_${canonicalDigest(semantic, "Artifact inventory")}`)
160
+ if (edge.edge_id !== artifactEdgeId(semantic))
166
161
  throw new TypeError("Artifact edge ID does not match its identity");
167
162
  };
168
163
  const mergeExact = (output, key, value, label) => {
@@ -15,7 +15,7 @@
15
15
  * Unifying those outcome vocabularies is a separate, observable change.
16
16
  */
17
17
  /** Whether a reference carries a URI scheme (`https:`, `file:`, …). */
18
- export const hasScheme = (value) => /^[A-Za-z][A-Za-z+.-]*:/u.test(value);
18
+ export const hasScheme = (value) => /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(value);
19
19
  /** Whether a reference is scheme-qualified or protocol-relative. */
20
20
  export const looksExternal = (value) => hasScheme(value) || value.startsWith("//");
21
21
  /** Drop any query string and fragment from a declared reference. */
@@ -0,0 +1,71 @@
1
+ import { z } from "zod";
2
+ /** Coverage metadata for the bounded projection of candidate relationships. */
3
+ export const bridgeCandidateCoverageSchema = z.strictObject({
4
+ status: z.enum(["complete", "partial"]),
5
+ total_candidates: z.number().int().nonnegative(),
6
+ emitted_candidates: z.number().int().nonnegative(),
7
+ omitted_candidates: z.number().int().nonnegative(),
8
+ });
9
+ // The serialized candidate array is the retained representation; accounting
10
+ // its exact UTF-8 JSON size bounds both array objects and repeated path strings.
11
+ /** Maximum UTF-8 JSON size of a retained candidate array. */
12
+ export const MAX_BRIDGE_CANDIDATE_JSON_BYTES = 2 * 1024 * 1024;
13
+ const jsonText = (value) => {
14
+ const serialized = JSON.stringify(value);
15
+ if (serialized === undefined)
16
+ throw new TypeError("Bridge candidate is not JSON serializable");
17
+ return serialized;
18
+ };
19
+ /** Retain a deterministic prefix of grouped Cartesian candidates within a byte budget. */
20
+ export const projectCartesianCandidates = (input) => {
21
+ const total = input.groups.reduce((sum, group) => sum + group.left.length * group.right.length, 0);
22
+ const preparedGroups = input.groups.map((group) => ({
23
+ left: group.left.map((value) => ({
24
+ value,
25
+ pathBytes: Buffer.byteLength(jsonText(value.path)),
26
+ })),
27
+ right: group.right.map((value) => {
28
+ const emptyLeftCandidate = jsonText(input.createCandidate("", value));
29
+ return {
30
+ value,
31
+ rowOverhead: Buffer.byteLength(emptyLeftCandidate) - 2,
32
+ };
33
+ }),
34
+ }));
35
+ let estimatedFullBytes = 2 + Math.max(0, total - 1); // JSON array brackets and commas.
36
+ for (const group of preparedGroups) {
37
+ estimatedFullBytes +=
38
+ group.left.length *
39
+ group.right.reduce((sum, { rowOverhead }) => sum + rowOverhead, 0) +
40
+ group.right.length *
41
+ group.left.reduce((sum, { pathBytes }) => sum + pathBytes, 0);
42
+ }
43
+ const shouldEmitAll = estimatedFullBytes <= MAX_BRIDGE_CANDIDATE_JSON_BYTES;
44
+ const candidates = [];
45
+ let estimatedRetainedBytes = 2;
46
+ candidateLoop: for (const group of preparedGroups) {
47
+ for (const left of group.left) {
48
+ for (const right of group.right) {
49
+ const candidateBytes = right.rowOverhead + left.pathBytes;
50
+ const additionalBytes = candidateBytes + (candidates.length > 0 ? 1 : 0);
51
+ if (!shouldEmitAll &&
52
+ estimatedRetainedBytes + additionalBytes >
53
+ MAX_BRIDGE_CANDIDATE_JSON_BYTES)
54
+ break candidateLoop;
55
+ candidates.push(input.createCandidate(left.value.path, right.value));
56
+ estimatedRetainedBytes += additionalBytes;
57
+ }
58
+ }
59
+ }
60
+ return {
61
+ candidates,
62
+ coverage: {
63
+ status: candidates.length === total
64
+ ? "complete"
65
+ : "partial",
66
+ total_candidates: total,
67
+ emitted_candidates: candidates.length,
68
+ omitted_candidates: total - candidates.length,
69
+ },
70
+ };
71
+ };
@@ -33,6 +33,7 @@ const browserExclusionReasonSchema = z.enum([
33
33
  "out_of_target_scope",
34
34
  "provider_unavailable",
35
35
  "invalid_protocol_value",
36
+ "resource_budget_exhausted",
36
37
  ]);
37
38
  const browserExclusionSchema = z.object({
38
39
  section: browserSectionSchema,
@@ -77,7 +77,7 @@ const browserInput = {
77
77
  allowed_origins: browserAllowedOriginsSchema,
78
78
  };
79
79
  /** Public input for complete discovery, optionally filtered by exact origin. */
80
- export const listBrowserTargetsInputSchema = z.object({
80
+ export const listBrowserTargetsInputSchema = z.strictObject({
81
81
  ...browserInput,
82
82
  });
83
83
  const inspectWebPageInputFacts = {
@@ -1,4 +1,4 @@
1
- import { AnalysisError } from "./analysisErrorBase.js";
1
+ import { AnalysisError, } from "./analysisErrorBase.js";
2
2
  import { AnalysisCancelledError } from "./analysisErrorCore.js";
3
3
  /** A bounded passive browser observation failed at its CDP boundary. */
4
4
  export class BrowserObservationError extends AnalysisError {
@@ -13,13 +13,32 @@ export class BrowserObservationError extends AnalysisError {
13
13
  super(`Browser observation ${operation} failed: ${reason}`, options);
14
14
  this.operation = operation;
15
15
  this.reason = reason;
16
- this.userMessage = options?.detail;
17
- this.cleanupIncomplete = reason === "cleanup_failed";
16
+ this.userMessage =
17
+ options?.detail ?? observationFailureMessage(operation, reason);
18
+ this.cleanupIncomplete =
19
+ this.cleanup !== undefined || reason === "cleanup_failed";
18
20
  this.cleanupResources =
19
- reason === "cleanup_failed" ? ["browser_transport"] : [];
21
+ this.cleanup?.resources ??
22
+ (reason === "cleanup_failed" ? ["browser_transport"] : []);
20
23
  this.userCategory =
21
- reason === "cancelled" || options?.cause instanceof AnalysisCancelledError
24
+ reason === "cancelled" ||
25
+ options?.cause instanceof AnalysisCancelledError ||
26
+ (options?.cause instanceof AnalysisError &&
27
+ options.cause.userCategory === "cancelled")
22
28
  ? "cancelled"
23
29
  : undefined;
24
30
  }
25
31
  }
32
+ const observationFailureMessage = (operation, reason) => {
33
+ if (reason === "cancelled")
34
+ return `${operation} was cancelled. Collected observations and cleanup status are reported when available.`;
35
+ if (reason === "timeout")
36
+ return `${operation} exceeded its execution deadline. Review the target's responsiveness and retained observations before retrying.`;
37
+ if (reason === "endpoint_unreachable")
38
+ return `${operation} could not reach the selected loopback debugging endpoint. Verify that the target process is running with debugging enabled and that the endpoint's port matches it, then retry.`;
39
+ if (reason === "target_not_found")
40
+ return `${operation} could not find the selected target at the debugging endpoint. Refresh target discovery for that endpoint and retry with a returned target ID.`;
41
+ if (reason === "disconnected")
42
+ return `${operation} lost its debugging connection. Verify that the target process is still running, refresh target discovery, and retry the observation.`;
43
+ return undefined;
44
+ };
@@ -106,6 +106,19 @@ const browserNetworkRequestSchema = z.object({
106
106
  status: z.number().nullable(),
107
107
  mime_type: z.string().nullable(),
108
108
  encoded_data_length: z.number().min(0).nullable(),
109
+ redirects: z
110
+ .array(z.object({
111
+ url: z.string(),
112
+ response_url: z.string(),
113
+ method: z.string(),
114
+ resource_type: z.string().nullable(),
115
+ status: z.number().nullable(),
116
+ mime_type: z.string().nullable(),
117
+ encoded_data_length: z.number().min(0).nullable(),
118
+ request_timestamp: z.number().nullable(),
119
+ redirect_event_timestamp: z.number().nullable(),
120
+ }))
121
+ .optional(),
109
122
  initiator: z.object({
110
123
  type: z.string(),
111
124
  url: z.string().nullable(),
@@ -1,10 +1,13 @@
1
1
  import { z } from "zod";
2
+ import { isAbsoluteLocalPath, localPathStringSchema } from "./localPath.js";
2
3
  import { browserNetworkContentSelectionSchema } from "./browserNetworkEvidence.js";
3
4
  import { browserEndpointSchema, browserOriginSchema, } from "./browserObservation.js";
4
5
  export const scenarioIdentifierSchema = z
5
6
  .string()
6
7
  .regex(/^[A-Za-z][A-Za-z0-9._-]*$/u);
7
- const browserExecutablePathSchema = z.string().trim().min(1);
8
+ const browserExecutablePathSchema = localPathStringSchema.refine(isAbsoluteLocalPath, {
9
+ message: "executable_path must be an absolute local filesystem path (for example /opt/chromium/chrome or C:\\chromium\\chrome.exe)",
10
+ });
8
11
  const browserScenarioBaseUrlSchema = z
9
12
  .string()
10
13
  .min(1)
@@ -52,7 +55,7 @@ export const browserScenarioUrlSchema = z.strictObject({
52
55
  export const browserScenarioBrowserSchema = z.discriminatedUnion("mode", [
53
56
  z.strictObject({
54
57
  mode: z.literal("launch"),
55
- executable_path: browserExecutablePathSchema,
58
+ executable_path: browserExecutablePathSchema.describe("Absolute local filesystem path for the browser executable; relative paths are rejected."),
56
59
  headless: z
57
60
  .boolean()
58
61
  .default(true)
@@ -4,6 +4,7 @@ import { parseEvidenceBundle, serializeEvidenceBundle, } from "./evidenceBundle.
4
4
  import { digestSchema } from "./../domain/digests.js";
5
5
  import { prefixedDigestSchema } from "./../domain/digests.js";
6
6
  import { comparisonStatusSchema } from "./comparisonStatus.js";
7
+ import { localPathStringSchema } from "./localPath.js";
7
8
  const evidenceIdSchema = prefixedDigestSchema("ev");
8
9
  const classificationSchema = z.enum([
9
10
  "added",
@@ -15,8 +16,8 @@ const classificationSchema = z.enum([
15
16
  ]);
16
17
  /** Strict input for canonical Evidence bundle comparison. */
17
18
  export const bundleComparisonInputSchema = z.strictObject({
18
- left_bundle_path: z.string().min(1),
19
- right_bundle_path: z.string().min(1),
19
+ left_bundle_path: localPathStringSchema,
20
+ right_bundle_path: localPathStringSchema,
20
21
  record_pairs: z
21
22
  .array(z.object({
22
23
  left_evidence_id: evidenceIdSchema,
@@ -19,7 +19,7 @@ const evidenceIdSchema = prefixedDigestSchema("ev");
19
19
  /** Normalize a hexadecimal offset while preserving its optional address space. */
20
20
  export const parseCallPathAddress = (input) => inputAddressSchema.parse(input);
21
21
  /** Strict input for explicit call-path reconstruction from complete dossiers. */
22
- export const callPathInputSchema = z.object({
22
+ export const callPathInputSchema = z.strictObject({
23
23
  functions: z.array(evidenceSchema).min(1),
24
24
  start: z.object({ address: inputAddressSchema }).strict(),
25
25
  goal: z.object({ address: inputAddressSchema }).strict(),
@@ -2,9 +2,21 @@ import { createHash } from "node:crypto";
2
2
  /** Hash canonicalize-compatible JSON without assembling an aggregate string. */
3
3
  export const digestCanonicalValue = (value, context = "Comparison") => {
4
4
  const hash = createHash("sha256");
5
- const encoded = emitCanonical(value, (part) => hash.update(part), new Set());
5
+ // Batch small emitted parts to cut hash.update crossings.
6
+ // Flush cuts only at part boundaries, so the hashed byte stream is unchanged.
7
+ let buffered = "";
8
+ const emit = (part) => {
9
+ buffered += part;
10
+ if (buffered.length >= 8192) {
11
+ hash.update(buffered);
12
+ buffered = "";
13
+ }
14
+ };
15
+ const encoded = emitCanonical(value, emit, new Set());
6
16
  if (!encoded)
7
17
  throw new TypeError(`${context} could not canonicalize data`);
18
+ if (buffered)
19
+ hash.update(buffered);
8
20
  return hash.digest("hex");
9
21
  };
10
22
  const emitCanonical = (value, emit, ancestors) => {