rea-agents 3.2.0 → 4.0.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 (434) hide show
  1. package/README.md +183 -332
  2. package/bridge/ghidra/ReaGhidraBridge.java +561 -74
  3. package/bridge/hopper_bridge.py +70 -27
  4. package/bridge/native/ReaNativeUI.swift +157 -0
  5. package/dist/application/AnalysisContextQueries.js +19 -5
  6. package/dist/application/AnalysisSnapshotCache.js +30 -11
  7. package/dist/application/AppleAssetCatalogAnalysis.js +171 -0
  8. package/dist/application/ArtifactExtractionDestination.js +0 -12
  9. package/dist/application/ArtifactGraphConstruction.js +44 -11
  10. package/dist/application/ArtifactInventory/classify.js +7 -15
  11. package/dist/application/ArtifactInventory/hash.js +4 -2
  12. package/dist/application/ArtifactInventory/policy.js +2 -17
  13. package/dist/application/ArtifactInventory/reader.js +3 -3
  14. package/dist/application/ArtifactInventory/scanCanonical.js +2 -2
  15. package/dist/application/ArtifactInventory/scanReader.js +12 -4
  16. package/dist/application/ArtifactInventory/types.js +0 -3
  17. package/dist/application/BinarySession.js +28 -43
  18. package/dist/application/BinarySessionExecution.js +37 -1
  19. package/dist/application/BinaryTargetResolver.js +50 -4
  20. package/dist/application/BrowserEvidence.js +36 -7
  21. package/dist/application/BrowserObservationService.js +17 -44
  22. package/dist/application/BrowserScenarioCaptureService.js +2 -35
  23. package/dist/application/BrowserScenarioEvidence.js +13 -9
  24. package/dist/application/CapabilityClientRequirements.js +2 -11
  25. package/dist/application/CapabilityInventory.js +21 -35
  26. package/dist/application/ClientConfigurationDocument.js +84 -7
  27. package/dist/application/ClientRegistrationIdentity.js +32 -0
  28. package/dist/application/ClientRegistrationStatus.js +59 -6
  29. package/dist/application/DirectAnalysis.js +37 -58
  30. package/dist/application/DirectAnalysisStatus.js +4 -4
  31. package/dist/application/Doctor.js +89 -80
  32. package/dist/application/DoctorDiagnostics.js +2 -26
  33. package/dist/application/DoctorScope.js +8 -14
  34. package/dist/application/ElectronActiveEvidence.js +10 -27
  35. package/dist/application/ElectronActiveObservationService.js +9 -36
  36. package/dist/application/ElectronBoundaryAnalysis.js +2 -0
  37. package/dist/application/ElectronBoundaryGraphNative.js +1 -1
  38. package/dist/application/ElectronEvidence.js +8 -3
  39. package/dist/application/ElectronObservationService.js +9 -25
  40. package/dist/application/EnhancedLiteralTracing.js +4 -8
  41. package/dist/application/EnhancedTools.js +15 -35
  42. package/dist/application/FilesystemSnapshot.js +7 -8
  43. package/dist/application/JavaScriptApplicationEvidenceGraph.js +2 -1
  44. package/dist/application/JavaScriptApplicationWorkflowService.js +31 -7
  45. package/dist/application/JavaScriptArtifactAnalysis.js +6 -4
  46. package/dist/application/JavaScriptArtifactFiles.js +5 -0
  47. package/dist/application/JavaScriptArtifactPathResolution.js +179 -47
  48. package/dist/application/JavaScriptRuntimeObservationEvidence.js +6 -3
  49. package/dist/application/JavaScriptRuntimeObservationService.js +9 -25
  50. package/dist/application/JavaScriptRuntimeReconciliationService.js +45 -4
  51. package/dist/application/JavaScriptSemanticGraphAsyncProjection.js +11 -0
  52. package/dist/application/JavaScriptSemanticGraphChildProcessProjection.js +11 -0
  53. package/dist/application/JavaScriptSemanticGraphDataProjection.js +11 -0
  54. package/dist/application/JavaScriptSemanticGraphFlowProjection.js +14 -5
  55. package/dist/application/JsonFiles.js +1 -1
  56. package/dist/application/LazyAnalysisProvider.js +27 -6
  57. package/dist/application/ManagedMemberComparisonService.js +19 -6
  58. package/dist/application/NativeApiInspection.js +2 -0
  59. package/dist/application/NativeCallRoutes.js +72 -0
  60. package/dist/application/NativeDispatchMetadataInspection.js +33 -0
  61. package/dist/application/NativeUiActionTrace.js +73 -49
  62. package/dist/application/NativeValueTrace.js +320 -0
  63. package/dist/application/ProcessCaptureCapability.js +32 -5
  64. package/dist/application/ProcessCaptureEnvironment.js +9 -26
  65. package/dist/application/ProcessCaptureError.js +1 -5
  66. package/dist/application/ProcessCaptureJournal.js +3 -40
  67. package/dist/application/ProcessCaptureLifecycle.js +102 -111
  68. package/dist/application/ProcessCli.js +18 -25
  69. package/dist/application/ProcessEvidence.js +5 -7
  70. package/dist/application/ProcessFilesystemEffects.js +36 -0
  71. package/dist/application/ProcessHarness.js +41 -120
  72. package/dist/application/ProcessNormalization.js +2 -17
  73. package/dist/application/ProcessScenarioRuntimeValidation.js +76 -0
  74. package/dist/application/ReferenceSourceImport.js +3 -4
  75. package/dist/application/Setup.js +236 -84
  76. package/dist/application/SetupClientConfiguration.js +14 -9
  77. package/dist/application/SetupPlan.js +138 -86
  78. package/dist/application/SetupSkill.js +0 -1
  79. package/dist/application/SupportedClients.js +102 -21
  80. package/dist/application/Uninstall.js +31 -20
  81. package/dist/application/Update.js +93 -0
  82. package/dist/application/UpdateMaintenance.js +108 -0
  83. package/dist/application/UpdateRuntime.js +126 -0
  84. package/dist/application/runtime.js +13 -2
  85. package/dist/artifacts/ArtifactPaths.js +6 -8
  86. package/dist/artifacts/ArtifactProvider.js +94 -41
  87. package/dist/artifacts/AsarArtifactReader.js +19 -4
  88. package/dist/artifacts/KeyedArchiveReader.js +110 -0
  89. package/dist/artifacts/MachOSliceArtifactReader.js +53 -5
  90. package/dist/artifacts/ZipArtifactReader.js +18 -1
  91. package/dist/browser/BrowserScenarioSecrets.js +28 -1
  92. package/dist/browser/CdpBrowserProvider.js +36 -15
  93. package/dist/browser/CdpCaptureDocuments.js +22 -8
  94. package/dist/browser/CdpCaptureEventHandlers.js +14 -5
  95. package/dist/browser/CdpCaptureEventHelpers.js +13 -0
  96. package/dist/browser/CdpCaptureEvents.js +10 -1
  97. package/dist/browser/CdpElectronInspection.js +5 -10
  98. package/dist/browser/CdpElectronProvider.js +1 -5
  99. package/dist/browser/CdpElectronScripts.js +1 -1
  100. package/dist/browser/CdpEndpoint.js +3 -2
  101. package/dist/browser/CdpObservationSession.js +14 -10
  102. package/dist/browser/CdpPageCapture.js +1 -1
  103. package/dist/browser/CdpPageCaptureScripts.js +1 -1
  104. package/dist/browser/CdpSafeMetadata.js +5 -4
  105. package/dist/browser/CdpScreenshot.js +16 -5
  106. package/dist/browser/CdpTargetSession.js +25 -4
  107. package/dist/browser/CdpWebMcpDiscovery.js +93 -20
  108. package/dist/browser/JavaScriptRuntimeScope.js +28 -2
  109. package/dist/browser/PlaywrightBrowserScenarioProvider.js +9 -8
  110. package/dist/browser/PlaywrightElectronActiveActions.js +3 -10
  111. package/dist/browser/PlaywrightElectronActiveProvider.js +5 -5
  112. package/dist/browser/PlaywrightScenarioActions.js +1 -1
  113. package/dist/browser/PlaywrightScenarioArtifacts.js +13 -25
  114. package/dist/browser/PlaywrightScenarioBrowser.js +28 -25
  115. package/dist/browser/PlaywrightScenarioEvents.js +82 -93
  116. package/dist/browser/PlaywrightScenarioSession.js +27 -123
  117. package/dist/browser/PngVisualDiff.js +22 -3
  118. package/dist/browser/V8InspectorCaptureProjection.js +7 -1
  119. package/dist/browser/V8InspectorProvider.js +60 -7
  120. package/dist/browser/WebSourceMapFetcher.js +99 -53
  121. package/dist/cli/artifactCommands.js +56 -12
  122. package/dist/cli/coreAnalysisCommands.js +110 -0
  123. package/dist/cli/managedCommands.js +1 -31
  124. package/dist/cli/setupCommands.js +16 -14
  125. package/dist/cli/utilityCommands.js +61 -4
  126. package/dist/cli.js +5 -7
  127. package/dist/cliApplicationCommands.js +0 -83
  128. package/dist/cliBrowserAdvancedCommands.js +7 -11
  129. package/dist/cliBrowserCommands.js +15 -23
  130. package/dist/cliBrowserContext.js +3 -24
  131. package/dist/cliBrowserScenarioCommands.js +2 -10
  132. package/dist/cliCommandNames.js +82 -7
  133. package/dist/cliElectronCommands.js +10 -36
  134. package/dist/cliJavaScriptRuntimeCommands.js +6 -30
  135. package/dist/cliJsonInput.js +4 -2
  136. package/dist/cliLogging.js +16 -7
  137. package/dist/cliObservationOptions.js +1 -1
  138. package/dist/cliOutput.js +2 -4
  139. package/dist/cliProcessCommands.js +6 -33
  140. package/dist/cliSetup.js +90 -160
  141. package/dist/config/environment.js +2 -78
  142. package/dist/config/parseConfig.js +18 -109
  143. package/dist/config/parsers.js +0 -23
  144. package/dist/contracts/applicationToolContracts.js +1 -118
  145. package/dist/contracts/artifactToolContracts.js +11 -19
  146. package/dist/contracts/browserScenarioToolContracts.js +1 -5
  147. package/dist/contracts/browserToolContracts.js +9 -16
  148. package/dist/contracts/electronToolContracts.js +5 -6
  149. package/dist/contracts/enhancedInputs.js +3 -2
  150. package/dist/contracts/errorSchemas.js +16 -40
  151. package/dist/contracts/functionWorkflowToolContracts.js +2 -2
  152. package/dist/contracts/javascriptApplicationWorkflowExamples.js +2 -2
  153. package/dist/contracts/javascriptRuntimeObservationToolContracts.js +4 -4
  154. package/dist/contracts/javascriptRuntimeReconciliationExample.js +1 -1
  155. package/dist/contracts/managedToolContracts.js +7 -4
  156. package/dist/contracts/managedWorkflowExamples.js +0 -22
  157. package/dist/contracts/managedWorkflowToolContracts.js +16 -31
  158. package/dist/contracts/nativeToolContracts.js +9 -0
  159. package/dist/contracts/promptContracts.js +6 -6
  160. package/dist/contracts/sessionToolSchemas.js +3 -3
  161. package/dist/contracts/toolContractExamples.js +4 -3
  162. package/dist/contracts/toolContracts.js +18 -7
  163. package/dist/contracts/toolEffects.js +34 -21
  164. package/dist/contracts/toolOutputSchemaGroups.js +18 -5
  165. package/dist/contracts/toolOutputSchemaPrimitives.js +9 -6
  166. package/dist/contracts/toolSchemaMetadata.js +5 -8
  167. package/dist/doctorRuntime.js +0 -41
  168. package/dist/domain/analysisErrorPresentation.js +4 -28
  169. package/dist/domain/analysisErrorProjection.js +33 -50
  170. package/dist/domain/analysisProfile.js +1 -1
  171. package/dist/domain/analysisSnapshot.js +77 -3
  172. package/dist/domain/androidApplication.js +5 -4
  173. package/dist/domain/appleApplication.js +5 -4
  174. package/dist/domain/appleAssetCatalog.js +127 -0
  175. package/dist/domain/artifactComparison.js +7 -11
  176. package/dist/domain/artifactGraph.js +8 -6
  177. package/dist/domain/artifactInspection.js +13 -12
  178. package/dist/domain/binaryTarget.js +23 -9
  179. package/dist/domain/browserObservation.js +43 -24
  180. package/dist/domain/browserObservationSchemas.js +2 -1
  181. package/dist/domain/browserScenario.js +7 -107
  182. package/dist/domain/browserScenarioCapture.js +0 -1
  183. package/dist/domain/browserScenarioCaptureValues.js +5 -4
  184. package/dist/domain/browserScenarioDiff.js +1 -3
  185. package/dist/domain/browserScenarioValues.js +16 -107
  186. package/dist/domain/bundleComparison.js +18 -17
  187. package/dist/domain/callPathSchemas.js +17 -7
  188. package/dist/domain/changedBehavior.js +2 -3
  189. package/dist/domain/comparisonSemantics.js +19 -0
  190. package/dist/domain/completionLedgerGeneration.js +3 -2
  191. package/dist/domain/conformancePackage.js +2 -1
  192. package/dist/domain/conformanceTrustGate.js +3 -5
  193. package/dist/domain/customProtocolCapture.js +2 -2
  194. package/dist/domain/digests.js +30 -0
  195. package/dist/domain/dosMz.js +83 -0
  196. package/dist/domain/electronActiveObservation.js +7 -5
  197. package/dist/domain/electronObservation.js +3 -2
  198. package/dist/domain/electronStaticAnalysisNative.js +15 -6
  199. package/dist/domain/emptyArraySchema.js +3 -0
  200. package/dist/domain/errors.js +10 -28
  201. package/dist/domain/evidence.js +5 -3
  202. package/dist/domain/evidenceCompletionLedger.js +3 -2
  203. package/dist/domain/functionComparisonNormalization.js +24 -18
  204. package/dist/domain/functionComparisonResults.js +3 -7
  205. package/dist/domain/functionComparisonSchemas.js +3 -2
  206. package/dist/domain/hopperValues.js +108 -8
  207. package/dist/domain/javascriptApplicationAnalysis.js +4 -7
  208. package/dist/domain/javascriptApplicationEvidenceSchemas.js +4 -3
  209. package/dist/domain/javascriptApplicationGraphSchemas.js +8 -7
  210. package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +9 -7
  211. package/dist/domain/javascriptApplicationVersionItems.js +12 -18
  212. package/dist/domain/javascriptAstValues.js +4 -0
  213. package/dist/domain/javascriptExportShapeComparison.js +1 -6
  214. package/dist/domain/javascriptExportShapeComparisonSchemas.js +6 -10
  215. package/dist/domain/javascriptExportShapeVariants.js +15 -2
  216. package/dist/domain/javascriptFeatureTraceSchemas.js +8 -7
  217. package/dist/domain/javascriptRuntimeObservation.js +14 -2
  218. package/dist/domain/javascriptRuntimeReconciliationMatching.js +8 -0
  219. package/dist/domain/javascriptRuntimeReconciliationParsing.js +4 -2
  220. package/dist/domain/javascriptRuntimeReconciliationResult.js +6 -4
  221. package/dist/domain/javascriptRuntimeReconciliationRuntime.js +15 -4
  222. package/dist/domain/javascriptRuntimeReconciliationSchemas.js +19 -18
  223. package/dist/domain/javascriptRuntimeStaticCandidates.js +18 -6
  224. package/dist/domain/javascriptSemanticAnalysis.js +57 -19
  225. package/dist/domain/javascriptSemanticAsyncEffects.js +39 -40
  226. package/dist/domain/javascriptSemanticCalls.js +46 -27
  227. package/dist/domain/javascriptSemanticChildProcesses.js +43 -50
  228. package/dist/domain/javascriptSemanticDataEffectHelpers.js +91 -18
  229. package/dist/domain/javascriptSemanticDataEffects.js +22 -10
  230. package/dist/domain/javascriptSemanticGraphSchemas.js +8 -6
  231. package/dist/domain/javascriptSemanticObjects.js +13 -3
  232. package/dist/domain/javascriptSemanticProjection.js +144 -38
  233. package/dist/domain/javascriptSemanticPromises.js +14 -27
  234. package/dist/domain/javascriptSemanticQuerySchemas.js +6 -9
  235. package/dist/domain/javascriptSemanticResources.js +2 -5
  236. package/dist/domain/javascriptSemanticState.js +4 -0
  237. package/dist/domain/javascriptSemanticTraceSchemas.js +2 -1
  238. package/dist/domain/javascriptSemanticTraversal.js +13 -5
  239. package/dist/domain/javascriptSemanticValues.js +10 -9
  240. package/dist/domain/javascriptSourceParser.js +5 -1
  241. package/dist/domain/javascriptStaticAnalysisCalls.js +8 -5
  242. package/dist/domain/javascriptStaticAnalysisHelpers.js +16 -7
  243. package/dist/domain/keyedArchive.js +181 -0
  244. package/dist/domain/managedApplicationGraph.js +4 -3
  245. package/dist/domain/managedArtifact.js +2 -1
  246. package/dist/domain/managedMemberComparison.js +18 -13
  247. package/dist/domain/managedMemberComparisonCoverage.js +2 -1
  248. package/dist/domain/managedMemberComparisonItems.js +27 -7
  249. package/dist/domain/managedMemberComparisonMatch.js +22 -6
  250. package/dist/domain/managedNativeVerificationMatch.js +2 -2
  251. package/dist/domain/managedNativeVerificationSchemas.js +7 -5
  252. package/dist/domain/managedReconstruction.js +6 -5
  253. package/dist/domain/nativeApiBoundary.js +7 -0
  254. package/dist/domain/nativeDataType.js +51 -0
  255. package/dist/domain/nativeInspection.js +0 -1
  256. package/dist/domain/nativeInstruction.js +82 -0
  257. package/dist/domain/nativeInvestigationGraph.js +9 -5
  258. package/dist/domain/nativeUiObservation.js +123 -0
  259. package/dist/domain/nativeValueFlow.js +17 -0
  260. package/dist/domain/nativeValueTrace.js +64 -0
  261. package/dist/domain/objcSwiftMetadata.js +39 -0
  262. package/dist/domain/peInspection.js +1 -0
  263. package/dist/domain/processCapture.js +5 -55
  264. package/dist/domain/processCaptureExample.js +0 -9
  265. package/dist/domain/processCaptureValidation.js +13 -144
  266. package/dist/domain/processComparison.js +3 -25
  267. package/dist/domain/processObservation.js +0 -29
  268. package/dist/domain/processScenario.js +28 -228
  269. package/dist/domain/processTraceDimensionProjection.js +0 -15
  270. package/dist/domain/processTraceEvaluation.js +0 -6
  271. package/dist/domain/protocolCapture.js +8 -36
  272. package/dist/domain/reconstructionCoverage.js +3 -2
  273. package/dist/domain/reconstructionObligationLedgerSchemas.js +4 -12
  274. package/dist/domain/reconstructionReadinessSchemas.js +4 -3
  275. package/dist/domain/reconstructionVerification.js +2 -1
  276. package/dist/domain/reconstructionVerificationSchemas.js +6 -13
  277. package/dist/domain/referenceSourceClassification.js +0 -110
  278. package/dist/domain/referenceSourceGraph.js +15 -5
  279. package/dist/domain/residualUnknown.js +3 -2
  280. package/dist/domain/runtimeIdentification.js +6 -5
  281. package/dist/domain/sourceMapContents.js +5 -0
  282. package/dist/domain/sourceToBundleComparison.js +3 -10
  283. package/dist/domain/sourceToBundleComparisonSchemas.js +7 -6
  284. package/dist/domain/sourceToBundleSignals.js +9 -3
  285. package/dist/domain/staticRuntimeCorrelation.js +5 -11
  286. package/dist/domain/webBundleAnalysis.js +17 -9
  287. package/dist/domain/webBundleAnalyzer.js +1 -1
  288. package/dist/domain/webCaptureDiff.js +5 -11
  289. package/dist/domain/webCaptureDiffSchemas.js +2 -1
  290. package/dist/domain/webMcpDiscovery.js +2 -1
  291. package/dist/dotnet/ManagedMemberInspectorCore.js +15 -7
  292. package/dist/dotnet/ManagedMemberInstructionDecoder.js +57 -40
  293. package/dist/dotnet/ManagedMemberRows.js +2 -0
  294. package/dist/dotnet/ManagedMethodBodyReader.js +15 -8
  295. package/dist/dotnet/ManagedPeReader.js +2 -0
  296. package/dist/generatedMcpToolCatalog.js +1 -1
  297. package/dist/generatedPackageMetadata.js +2 -2
  298. package/dist/ghidra/GhidraAnalysisProfile.js +15 -5
  299. package/dist/ghidra/GhidraClient.js +38 -8
  300. package/dist/ghidra/GhidraFunctionValues.js +56 -20
  301. package/dist/ghidra/GhidraInstallation.js +7 -4
  302. package/dist/ghidra/GhidraInventoryValues.js +44 -9
  303. package/dist/ghidra/GhidraLauncher.js +18 -3
  304. package/dist/ghidra/GhidraProvider.js +23 -2
  305. package/dist/ghidra/GhidraRequestQueue.js +45 -4
  306. package/dist/ghidra/GhidraSessionValues.js +5 -0
  307. package/dist/hopper/HopperAnalysisProfile.js +2 -0
  308. package/dist/hopper/HopperProvider.js +29 -6
  309. package/dist/hopper/HopperTargetLease.js +18 -4
  310. package/dist/logger.js +0 -13
  311. package/dist/main/messages.js +0 -1
  312. package/dist/main/reload.js +3 -32
  313. package/dist/main/shutdown.js +1 -2
  314. package/dist/main/transport.js +0 -17
  315. package/dist/main.js +0 -10
  316. package/dist/native/AppleDispatchMetadata.js +582 -0
  317. package/dist/native/AppleObjcProtocols.js +88 -0
  318. package/dist/native/AppleSwiftVtables.js +86 -0
  319. package/dist/native/CommandRunner.js +1 -1
  320. package/dist/native/NativeHostCapabilities.js +23 -0
  321. package/dist/native/NativeMacOSProvider.js +61 -9
  322. package/dist/native/NativeMachoInspection.js +39 -6
  323. package/dist/native/NativeUiHelperRuntime.js +42 -0
  324. package/dist/native/NativeUiObservation.js +174 -0
  325. package/dist/native/parsers/codesign.js +4 -1
  326. package/dist/native/parsers/dyldInfo.js +51 -25
  327. package/dist/native/parsers/lipo.js +13 -4
  328. package/dist/native/parsers/otool.js +84 -39
  329. package/dist/native/parsers/plist.js +2 -1
  330. package/dist/process/ExecFileOutput.js +5 -1
  331. package/dist/process/ProcessOwnership.js +69 -33
  332. package/dist/process/ProcessOwnershipObservation.js +31 -12
  333. package/dist/process/ProviderProcess.js +4 -2
  334. package/dist/reference/ReferenceSourceReaderEntries.js +48 -31
  335. package/dist/reference/ReferenceSourceReaderErrors.js +24 -0
  336. package/dist/reference/ReferenceSourceReaderFile.js +11 -5
  337. package/dist/reference/ReferenceSourceReaderValidate.js +22 -8
  338. package/dist/server/createServer.js +7 -62
  339. package/dist/server/registerApplicationTools/helpers.js +2 -9
  340. package/dist/server/registerApplicationTools.js +0 -4
  341. package/dist/server/registerArtifactComparisonTool.js +1 -1
  342. package/dist/server/registerBrowserScenarioTool.js +4 -2
  343. package/dist/server/registerBrowserTools.js +7 -7
  344. package/dist/server/registerBundleComparisonTool.js +1 -1
  345. package/dist/server/registerCloseLifecycleTool.js +1 -1
  346. package/dist/server/registerElectronTools.js +10 -4
  347. package/dist/server/registerEnhancedTools.js +20 -12
  348. package/dist/server/registerEvidenceTools.js +4 -28
  349. package/dist/server/registerFunctionComparisonTool.js +1 -1
  350. package/dist/server/registerInvestigationTools.js +6 -6
  351. package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -2
  352. package/dist/server/registerManagedTools.js +28 -14
  353. package/dist/server/registerManagedWorkflowTools.js +0 -2
  354. package/dist/server/registerProcessComparisonTool.js +1 -3
  355. package/dist/server/registerSessionRecordTools.js +9 -9
  356. package/dist/server/registerSessionStatusTool.js +1 -1
  357. package/dist/server/registerSessionTools.js +28 -57
  358. package/dist/server/sessionAvailabilityPolicy.js +2 -3
  359. package/dist/server/sessionToolPolicies.js +0 -4
  360. package/dist/server/toolResult.js +8 -10
  361. package/package.json +32 -22
  362. package/skills/reverse-engineer-anything/SKILL.md +15 -11
  363. package/skills/reverse-engineer-anything/references/evidence-workflows.md +3 -2
  364. package/skills/reverse-engineer-anything/references/javascript-applications.md +3 -2
  365. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +8 -6
  366. package/skills/reverse-engineer-anything/references/runtime-observation.md +15 -11
  367. package/dist/application/CommandShimReplay.js +0 -152
  368. package/dist/application/ConfiguredRoots.js +0 -19
  369. package/dist/application/InstrumentedJavaScriptReplayHost.js +0 -36
  370. package/dist/application/JavaScriptReplayPermission.js +0 -16
  371. package/dist/application/JavaScriptReplayPlanning.js +0 -207
  372. package/dist/application/JavaScriptReplayService.js +0 -274
  373. package/dist/application/LoopbackReplay.js +0 -389
  374. package/dist/application/LoopbackReplayRecorder.js +0 -129
  375. package/dist/application/ManagedRuntimeCorrelationService.js +0 -104
  376. package/dist/application/NodeRuntimeCharacterizationService.js +0 -191
  377. package/dist/application/PermissionAuthority.js +0 -268
  378. package/dist/application/PermissionConfiguration.js +0 -26
  379. package/dist/application/PermissionFailure.js +0 -5
  380. package/dist/application/ProcessCaptureAuthority.js +0 -24
  381. package/dist/application/ProcessCapturePermission.js +0 -13
  382. package/dist/application/ProcessCheckpoints.js +0 -178
  383. package/dist/application/ProcessReactiveCoordinator.js +0 -223
  384. package/dist/application/ProcessReactiveEffects.js +0 -153
  385. package/dist/application/ProcessReactiveHarness.js +0 -106
  386. package/dist/application/ProcessReactiveObservations.js +0 -105
  387. package/dist/application/ProjectPermissionStore.js +0 -199
  388. package/dist/application/RuntimeExecutableDiagnostics.js +0 -198
  389. package/dist/application/Upgrade.js +0 -134
  390. package/dist/browser/SensitiveTextCapture.js +0 -8
  391. package/dist/cliPolicyCommands.js +0 -185
  392. package/dist/config/browserScenario.js +0 -77
  393. package/dist/config/electronAutomation.js +0 -35
  394. package/dist/config/javascriptReplay.js +0 -41
  395. package/dist/config/managedRuntime.js +0 -25
  396. package/dist/config/passiveObservation.js +0 -87
  397. package/dist/config/permissions.js +0 -23
  398. package/dist/config/processCapture.js +0 -47
  399. package/dist/contracts/replayMachineExample.js +0 -37
  400. package/dist/domain/javascriptExportInstrumentation.js +0 -95
  401. package/dist/domain/javascriptReplay.js +0 -360
  402. package/dist/domain/managedRuntimeCorrelation.js +0 -181
  403. package/dist/domain/nodeRuntimeCharacterization.js +0 -63
  404. package/dist/domain/permissionPolicy.js +0 -176
  405. package/dist/domain/processCaptureReactiveSchema.js +0 -68
  406. package/dist/domain/processCaptureReactiveValidation.js +0 -180
  407. package/dist/domain/processReactiveCheckpointDataflow.js +0 -32
  408. package/dist/domain/processReactiveMatching.js +0 -196
  409. package/dist/domain/processReactiveRuntime.js +0 -116
  410. package/dist/domain/processReactiveScenario.js +0 -296
  411. package/dist/domain/processReactiveScenarioPreflight.js +0 -95
  412. package/dist/domain/processReactiveTransition.js +0 -187
  413. package/dist/domain/replayMachine.js +0 -320
  414. package/dist/domain/replayMachineRun.js +0 -168
  415. package/dist/domain/replayMachineRuntime.js +0 -296
  416. package/dist/domain/replayMachineValues.js +0 -84
  417. package/dist/domain/runtimeCharacterization.js +0 -84
  418. package/dist/replay/JavaScriptReplayWorker.js +0 -382
  419. package/dist/replay/JavaScriptReplayWorkerTypes.js +0 -1
  420. package/dist/replay/LinuxJavaScriptReplayRunner.js +0 -216
  421. package/dist/replay/LinuxJavaScriptReplaySandbox.js +0 -121
  422. package/dist/replay/LinuxRuntimeClosure.js +0 -44
  423. package/dist/replay/LinuxSeccompPolicy.js +0 -40
  424. package/dist/replay/ReplayOutcome.js +0 -104
  425. package/dist/replay/ReplayProcessLifecycle.js +0 -96
  426. package/dist/replay/ReplaySeccompFile.js +0 -29
  427. package/dist/replay/ReplayWorkerProtocol.js +0 -58
  428. package/dist/replay/SystemJavaScriptReplayHost.js +0 -153
  429. package/dist/server/ProcessCaptureElicitation.js +0 -153
  430. package/dist/server/registerApplicationTools/characterization.js +0 -46
  431. package/dist/server/registerApplicationTools/controlledReplay.js +0 -31
  432. package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +0 -29
  433. package/dist/server/registerReplayMachineTool.js +0 -14
  434. package/skills/reverse-engineer-anything/references/controlled-replay.md +0 -12
@@ -1,178 +0,0 @@
1
- import { snapshotRoots } from "./FilesystemSnapshot.js";
2
- import { scheduleProcessDelay } from "./ProcessTimer.js";
3
- /** Classify path-stable filesystem effects between two bounded states. */
4
- export const classifyFilesystemEffects = (before, after) => {
5
- const beforeByPath = new Map(before.map((file) => [file.path, file]));
6
- const afterByPath = new Map(after.map((file) => [file.path, file]));
7
- return [...new Set([...beforeByPath.keys(), ...afterByPath.keys()])]
8
- .sort()
9
- .map((path) => {
10
- const beforeFile = beforeByPath.get(path) ?? null;
11
- const afterFile = afterByPath.get(path) ?? null;
12
- if (beforeFile === null) {
13
- if (afterFile === null)
14
- throw new TypeError(`Filesystem effect ${path} has no file state`);
15
- return {
16
- path,
17
- status: "created",
18
- before: null,
19
- after: afterFile,
20
- };
21
- }
22
- if (afterFile === null)
23
- return {
24
- path,
25
- status: "deleted",
26
- before: beforeFile,
27
- after: null,
28
- };
29
- return {
30
- path,
31
- status: JSON.stringify(beforeFile) === JSON.stringify(afterFile)
32
- ? "unchanged"
33
- : "modified",
34
- before: beforeFile,
35
- after: afterFile,
36
- };
37
- });
38
- };
39
- /** Coordinates named lifecycle filesystem observations without overlapping scans. */
40
- export class ProcessCheckpoints {
41
- scenario;
42
- started;
43
- #captures = [];
44
- #captured = new Set();
45
- #terminalCounts = new Map();
46
- #terminalTails = new Map();
47
- #timers = new Set();
48
- #signal;
49
- #recordEvent;
50
- #pending = Promise.resolve();
51
- constructor(scenario, started, before, options = { signal: undefined }) {
52
- this.scenario = scenario;
53
- this.started = started;
54
- this.#signal = options.signal;
55
- this.#recordEvent = options.recordEvent ?? (() => undefined);
56
- this.#captures.push({
57
- name: "before",
58
- at_ms: 0,
59
- files: before.files,
60
- effects: [],
61
- truncated: before.truncated,
62
- });
63
- this.#recordEvent("filesystem_checkpoints", 0);
64
- this.#captured.add("before");
65
- for (const checkpoint of scenario.checkpoints) {
66
- if (checkpoint.trigger.type !== "time")
67
- continue;
68
- const timer = scheduleProcessDelay(checkpoint.trigger.at_ms, () => this.capture(checkpoint.name));
69
- this.#timers.add(timer);
70
- }
71
- }
72
- /** Observe normalized terminal text and fire matching literal checkpoints once. */
73
- observeTerminal(data) {
74
- for (const checkpoint of this.scenario.checkpoints) {
75
- const trigger = checkpoint.trigger;
76
- if (trigger.type !== "terminal_literal" ||
77
- this.#captured.has(checkpoint.name))
78
- continue;
79
- const combined = `${this.#terminalTails.get(checkpoint.name) ?? ""}${data}`;
80
- const count = (this.#terminalCounts.get(checkpoint.name) ?? 0) +
81
- countOccurrences(combined, trigger.value);
82
- this.#terminalCounts.set(checkpoint.name, count);
83
- this.#terminalTails.set(checkpoint.name, trigger.value.length === 1
84
- ? ""
85
- : combined.slice(-(trigger.value.length - 1)));
86
- if (count >= trigger.occurrence)
87
- this.capture(checkpoint.name);
88
- }
89
- }
90
- /** Capture every checkpoint assigned to the specified lifecycle trigger. */
91
- trigger(type) {
92
- for (const checkpoint of this.scenario.checkpoints)
93
- if (checkpoint.trigger.type === type)
94
- this.capture(checkpoint.name);
95
- }
96
- /** Queue one idempotent named snapshot. */
97
- capture(name) {
98
- this.#scheduleCapture(name, this.#signal);
99
- }
100
- /** Read one committed checkpoint for synchronous journal projection. */
101
- at(index) {
102
- const checkpoint = this.#captures[index];
103
- return checkpoint === undefined ? undefined : structuredClone(checkpoint);
104
- }
105
- #scheduleCapture(name, signal) {
106
- if (this.#captured.has(name))
107
- return;
108
- this.#captured.add(name);
109
- // Serialize scans even when time, terminal, and lifecycle triggers fire
110
- // together. Each effect set is intentionally relative to the immediately
111
- // preceding checkpoint, which preserves transient create/delete behavior.
112
- this.#pending = this.#pending.then(async () => {
113
- const snapshot = await snapshotRoots(this.scenario, signal);
114
- const previous = this.#captures.at(-1)?.files ?? [];
115
- const index = this.#captures.length;
116
- this.#captures.push({
117
- name,
118
- at_ms: Math.max(0, Date.now() - this.started),
119
- files: snapshot.files,
120
- effects: classifyFilesystemEffects(previous, snapshot.files),
121
- truncated: snapshot.truncated,
122
- });
123
- this.#recordEvent("filesystem_checkpoints", index);
124
- });
125
- }
126
- /** Queue one named snapshot and return its exact captured record. */
127
- async captureAndRead(name, signal) {
128
- const captureSignal = signal === undefined
129
- ? this.#signal
130
- : this.#signal === undefined
131
- ? signal
132
- : AbortSignal.any([this.#signal, signal]);
133
- this.#scheduleCapture(name, captureSignal);
134
- const scheduled = this.#pending;
135
- await scheduled;
136
- const index = this.#captures.findIndex(({ name: capturedName }) => capturedName === name);
137
- const checkpoint = this.#captures[index];
138
- if (index < 0 || checkpoint === undefined)
139
- throw new Error(`filesystem checkpoint was not captured: ${name}`);
140
- return { index, checkpoint: structuredClone(checkpoint) };
141
- }
142
- /** Finish pending snapshots and return them in observation order. */
143
- async finish(after) {
144
- for (const timer of this.#timers)
145
- timer.cancel();
146
- await this.#pending;
147
- const previous = this.#captures.at(-1)?.files ?? [];
148
- const index = this.#captures.length;
149
- this.#captures.push({
150
- name: "after_settlement",
151
- at_ms: Math.max(0, Date.now() - this.started),
152
- files: after.files,
153
- effects: classifyFilesystemEffects(previous, after.files),
154
- truncated: after.truncated,
155
- });
156
- this.#recordEvent("filesystem_checkpoints", index);
157
- return structuredClone(this.#captures);
158
- }
159
- /** Cancel scheduled captures and await any snapshot already in progress. */
160
- async dispose() {
161
- for (const timer of this.#timers)
162
- timer.cancel();
163
- this.#timers.clear();
164
- await this.#pending;
165
- }
166
- }
167
- const countOccurrences = (text, value) => {
168
- let count = 0;
169
- let offset = 0;
170
- while (offset <= text.length - value.length) {
171
- const found = text.indexOf(value, offset);
172
- if (found < 0)
173
- break;
174
- count += 1;
175
- offset = found + value.length;
176
- }
177
- return count;
178
- };
@@ -1,223 +0,0 @@
1
- import { commitProcessReactiveProposal, createProcessReactiveSnapshot, reduceProcessReactiveScenario, } from "../domain/processReactiveRuntime.js";
2
- import { scheduleProcessDelay } from "./ProcessTimer.js";
3
- const systemTimerHost = {
4
- schedule: (callback, delayMs) => scheduleProcessDelay(delayMs, callback),
5
- };
6
- /**
7
- * Serializes live observations, deadlines, and effect commits for one run.
8
- * Producer callbacks enqueue work without awaiting it, preventing reentrancy.
9
- */
10
- export class ProcessReactiveCoordinator {
11
- #scenario;
12
- #executor;
13
- #timerHost;
14
- #now;
15
- #scenarioDeadlineAt;
16
- #onDecision;
17
- #snapshot;
18
- #pendingInputs = [];
19
- #tail = Promise.resolve();
20
- #running = false;
21
- #failure;
22
- #stateTimer;
23
- #scenarioTimer;
24
- #stateDeadlineAt = 0;
25
- #effectAbort;
26
- #accepting = true;
27
- #closed = false;
28
- constructor(options) {
29
- this.#scenario = options.scenario;
30
- this.#executor = options.executor;
31
- this.#timerHost = options.timerHost ?? systemTimerHost;
32
- this.#now = options.now ?? Date.now;
33
- this.#scenarioDeadlineAt = this.#now() + options.scenario.deadline_ms;
34
- this.#onDecision = options.onDecision;
35
- this.#snapshot = createProcessReactiveSnapshot(options.scenario);
36
- this.#scheduleScenarioDeadline();
37
- this.#scheduleStateDeadline();
38
- }
39
- /** Current immutable reducer snapshot after all completed turns. */
40
- get snapshot() {
41
- return this.#snapshot;
42
- }
43
- /** Enqueue producer work without creating a floating promise. */
44
- enqueue(input) {
45
- if (!this.#accepting)
46
- return;
47
- if (this.#interruptsEffects(input))
48
- this.#effectAbort?.abort();
49
- this.#enqueueOwned(input);
50
- }
51
- /** Submit one input and wait until every turn queued before it completes. */
52
- async submit(input) {
53
- this.enqueue(input);
54
- await this.drain();
55
- return this.#snapshot;
56
- }
57
- /** Wait for currently queued reducer/effect work and surface host failures. */
58
- async drain() {
59
- for (;;) {
60
- const observedTail = this.#tail;
61
- await observedTail;
62
- if (observedTail === this.#tail)
63
- break;
64
- }
65
- if (this.#failure !== undefined)
66
- throw this.#failure;
67
- }
68
- /** Stop owned deadlines after queued work settles. */
69
- async close() {
70
- this.#accepting = false;
71
- this.#clearTimers();
72
- await this.drain();
73
- this.#closed = true;
74
- }
75
- #enqueueOwned(input) {
76
- if (this.#closed || this.#failure !== undefined)
77
- return;
78
- this.#pendingInputs.push(input);
79
- this.#startWorker();
80
- }
81
- #startWorker() {
82
- if (this.#running || this.#pendingInputs.length === 0)
83
- return;
84
- this.#running = true;
85
- this.#tail = this.#runQueue()
86
- .catch((cause) => this.#fail(cause))
87
- .finally(() => {
88
- this.#running = false;
89
- if (this.#pendingInputs.length > 0)
90
- this.#startWorker();
91
- });
92
- }
93
- async #runQueue() {
94
- for (;;) {
95
- const input = this.#nextInput();
96
- if (input === undefined)
97
- return;
98
- await this.#advance(input);
99
- }
100
- }
101
- #nextInput() {
102
- const terminalIndex = this.#pendingInputs.findIndex(({ kind }) => kind === "cancelled" || kind === "cleanup_failed");
103
- if (terminalIndex >= 0)
104
- return this.#pendingInputs.splice(terminalIndex, 1)[0];
105
- let observationIndex = -1;
106
- let captureOrder = Number.POSITIVE_INFINITY;
107
- for (const [index, input] of this.#pendingInputs.entries())
108
- if (input.kind === "observation" &&
109
- input.observation.capture_order < captureOrder) {
110
- observationIndex = index;
111
- captureOrder = input.observation.capture_order;
112
- }
113
- return observationIndex >= 0
114
- ? this.#pendingInputs.splice(observationIndex, 1)[0]
115
- : this.#pendingInputs.shift();
116
- }
117
- #fail(cause) {
118
- this.#failure ??= cause;
119
- this.#accepting = false;
120
- this.#closed = true;
121
- this.#effectAbort?.abort();
122
- this.#pendingInputs.length = 0;
123
- this.#clearTimers();
124
- }
125
- async #advance(input) {
126
- const before = this.#snapshot;
127
- let decision = reduceProcessReactiveScenario(this.#scenario, before, input);
128
- let effectResults = [];
129
- if (decision.kind === "proposal") {
130
- const effectAbort = new AbortController();
131
- this.#effectAbort = effectAbort;
132
- try {
133
- effectResults = await this.#executor.execute(decision.effects, effectAbort.signal);
134
- }
135
- catch (cause) {
136
- if (effectAbort.signal.aborted)
137
- return;
138
- throw cause;
139
- }
140
- finally {
141
- if (this.#effectAbort === effectAbort)
142
- this.#effectAbort = undefined;
143
- }
144
- if (effectAbort.signal.aborted)
145
- return;
146
- const expired = this.#expiredDeadlineInput();
147
- if (expired !== undefined) {
148
- this.#enqueueOwned(expired);
149
- return;
150
- }
151
- decision = commitProcessReactiveProposal(this.#scenario, decision, effectResults);
152
- }
153
- this.#snapshot = decision.snapshot;
154
- this.#onDecision?.(decision, input);
155
- if (this.#snapshot.status === "finished")
156
- this.#clearTimers();
157
- else if (this.#accepting &&
158
- (before.active_state !== this.#snapshot.active_state ||
159
- before.state_entry_capture_order !==
160
- this.#snapshot.state_entry_capture_order))
161
- this.#scheduleStateDeadline();
162
- for (const result of effectResults)
163
- if (result.status === "succeeded" &&
164
- !this.#hasObservation(result.observation.event_id))
165
- this.#enqueueOwned({
166
- kind: "observation",
167
- observation: result.observation,
168
- });
169
- }
170
- #hasObservation(eventId) {
171
- return (this.#snapshot.observations.some((observation) => observation.event_id === eventId) ||
172
- this.#pendingInputs.some((input) => input.kind === "observation" &&
173
- input.observation.event_id === eventId));
174
- }
175
- #interruptsEffects(input) {
176
- if (input.kind === "cancelled" ||
177
- input.kind === "cleanup_failed" ||
178
- input.kind === "scenario_deadline" ||
179
- input.kind === "target_lost")
180
- return true;
181
- return (input.kind === "state_deadline" &&
182
- input.state_id === this.#snapshot.active_state &&
183
- input.state_entry_capture_order ===
184
- this.#snapshot.state_entry_capture_order);
185
- }
186
- #expiredDeadlineInput() {
187
- const now = this.#now();
188
- if (now >= this.#scenarioDeadlineAt)
189
- return { kind: "scenario_deadline" };
190
- if (now < this.#stateDeadlineAt)
191
- return undefined;
192
- return {
193
- kind: "state_deadline",
194
- state_id: this.#snapshot.active_state,
195
- state_entry_capture_order: this.#snapshot.state_entry_capture_order,
196
- };
197
- }
198
- #scheduleScenarioDeadline() {
199
- if (!this.#accepting)
200
- return;
201
- this.#scenarioTimer = this.#timerHost.schedule(() => this.enqueue({ kind: "scenario_deadline" }), this.#scenario.deadline_ms);
202
- }
203
- #scheduleStateDeadline() {
204
- if (!this.#accepting)
205
- return;
206
- this.#stateTimer?.cancel();
207
- const state = this.#scenario.states.find(({ id }) => id === this.#snapshot.active_state);
208
- if (state === undefined)
209
- return;
210
- this.#stateDeadlineAt = this.#now() + state.deadline_ms;
211
- const identity = {
212
- state_id: state.id,
213
- state_entry_capture_order: this.#snapshot.state_entry_capture_order,
214
- };
215
- this.#stateTimer = this.#timerHost.schedule(() => this.enqueue({ kind: "state_deadline", ...identity }), state.deadline_ms);
216
- }
217
- #clearTimers() {
218
- this.#stateTimer?.cancel();
219
- this.#scenarioTimer?.cancel();
220
- this.#stateTimer = undefined;
221
- this.#scenarioTimer = undefined;
222
- }
223
- }
@@ -1,153 +0,0 @@
1
- import { createProcessObservation } from "../domain/processObservation.js";
2
- import { normalizeProcessElapsedTime } from "./ProcessNormalization.js";
3
- const elapsed = (host) => Math.max(0, host.now() - host.startedAtMs);
4
- const interactionData = (action) => {
5
- if (action.type === "send_input")
6
- return action.sensitive
7
- ? `<redacted-input:${String(Buffer.byteLength(action.data))}-bytes>`
8
- : action.data;
9
- if (action.type === "resize")
10
- return `${String(action.columns)}x${String(action.rows)}`;
11
- if (action.type === "close_stdin")
12
- return "";
13
- return action.signal;
14
- };
15
- const interactionType = (action) => {
16
- if (action.type === "send_input")
17
- return "input";
18
- if (action.type === "resize")
19
- return "resize";
20
- if (action.type === "close_stdin")
21
- return "stdin_close";
22
- return "signal";
23
- };
24
- const performTerminalAction = (host, terminal, action, atMs) => {
25
- if (action.type === "send_input")
26
- terminal.write(action.data);
27
- else if (action.type === "resize") {
28
- terminal.resize(action.columns, action.rows);
29
- // Rendered frames share the normalized clock used by captured terminal
30
- // frames and by the scheduled-event resize path. Passing the raw elapsed
31
- // time here stamped this frame on a different clock, so the next bucketed
32
- // frame could appear to move backwards and fail capture validation with
33
- // "rendered_frames: timestamps must be ordered".
34
- host.renderer.resize(action.columns, action.rows, normalizeProcessElapsedTime(atMs, host.timeBucketMs));
35
- }
36
- else if (action.type === "close_stdin")
37
- terminal.closeInput();
38
- else
39
- terminal.kill(action.signal);
40
- };
41
- const recordInteraction = (host, action, atMs, outcome) => {
42
- const index = host.interactions.length;
43
- const event = {
44
- sequence: index,
45
- scheduled_at_ms: atMs,
46
- dispatched_at_ms: atMs,
47
- type: interactionType(action),
48
- data: interactionData(action),
49
- outcome,
50
- };
51
- host.interactions.push(event);
52
- const location = host.journal.record("interaction_events", index);
53
- if (outcome !== "dispatched")
54
- return { status: "rejected" };
55
- return {
56
- status: "succeeded",
57
- observation: createProcessObservation({
58
- source: "interaction",
59
- source_sequence: index,
60
- captured_at_ms: atMs,
61
- subject_id: null,
62
- location,
63
- payload: event,
64
- }),
65
- };
66
- };
67
- const executeTerminalAction = (host, action) => {
68
- if (action.type === "send_signal" && action.target.kind !== "root")
69
- return { status: "rejected" };
70
- const terminal = host.terminal();
71
- if (terminal === undefined)
72
- return { status: "target_lost" };
73
- const atMs = elapsed(host);
74
- let outcome = "dispatched";
75
- try {
76
- performTerminalAction(host, terminal, action, atMs);
77
- }
78
- catch {
79
- outcome = "failed";
80
- }
81
- return recordInteraction(host, action, atMs, outcome);
82
- };
83
- const executeCheckpoint = async (host, action, signal) => {
84
- try {
85
- const { index, checkpoint } = await host.checkpoints.captureAndRead(action.name, signal);
86
- const location = host.journal.entries.findLast((entry) => entry.collection === "filesystem_checkpoints" && entry.index === index);
87
- if (location === undefined)
88
- return { status: "rejected" };
89
- return {
90
- status: "succeeded",
91
- observation: createProcessObservation({
92
- source: "filesystem",
93
- source_sequence: index,
94
- captured_at_ms: checkpoint.at_ms,
95
- subject_id: `checkpoint:${checkpoint.name}`,
96
- location,
97
- payload: checkpoint,
98
- }),
99
- };
100
- }
101
- catch {
102
- return { status: "rejected" };
103
- }
104
- };
105
- /** Execute proposed effects in order and stop after the first failure. */
106
- export const executeProcessReactiveEffects = async (host, actions, signal) => {
107
- const results = [];
108
- for (const action of actions) {
109
- if (signal.aborted)
110
- return results;
111
- const result = action.type === "checkpoint"
112
- ? await executeCheckpoint(host, action, signal)
113
- : executeTerminalAction(host, action);
114
- results.push(result);
115
- if (result.status !== "succeeded")
116
- break;
117
- }
118
- return results;
119
- };
120
- const triggerSources = (trigger) => {
121
- if (trigger.kind === "terminal_text")
122
- return [];
123
- if (trigger.kind === "event")
124
- return [
125
- "terminal_raw",
126
- "interaction",
127
- "process",
128
- "filesystem",
129
- "http",
130
- "websocket",
131
- "shim",
132
- ].includes(trigger.source)
133
- ? []
134
- : [trigger.source];
135
- return trigger.kind === "repeat"
136
- ? triggerSources(trigger.trigger)
137
- : trigger.triggers.flatMap(triggerSources);
138
- };
139
- /** Return unsupported sources, selectors, and checkpoint collisions pre-launch. */
140
- export const unsupportedProcessReactiveFeatures = (scenario, reservedCheckpointNames = new Set([
141
- "before",
142
- "after_settlement",
143
- ])) => [
144
- ...scenario.states.flatMap((state) => state.on.flatMap((transition) => triggerSources(transition.when).map((source) => `${transition.id}:source:${source}`))),
145
- ...scenario.states.flatMap((state) => state.on.flatMap((transition) => transition.actions.flatMap((action) => {
146
- if (action.type === "send_signal" && action.target.kind !== "root")
147
- return [`${transition.id}:target:${action.target.kind}`];
148
- if (action.type === "checkpoint" &&
149
- reservedCheckpointNames.has(action.name))
150
- return [`${transition.id}:checkpoint:${action.name}`];
151
- return [];
152
- }))),
153
- ];
@@ -1,106 +0,0 @@
1
- import { ProcessCaptureError } from "./ProcessCaptureError.js";
2
- import { ProcessReactiveCoordinator } from "./ProcessReactiveCoordinator.js";
3
- import { executeProcessReactiveEffects, unsupportedProcessReactiveFeatures, } from "./ProcessReactiveEffects.js";
4
- import { subscribeProcessReactiveObservations } from "./ProcessReactiveObservations.js";
5
- import { normalizeProcessSamples, normalizeProcessShimEvent, redactProtocolEvents, } from "./ProcessNormalization.js";
6
- const reactiveTerminalFor = (terminal) => {
7
- if (terminal === undefined)
8
- return undefined;
9
- return {
10
- write: (data) => terminal.write(data),
11
- resize: (columns, rows) => terminal.resize(columns, rows),
12
- closeInput: () => {
13
- const end = Reflect.get(terminal, "end");
14
- if (typeof end !== "function")
15
- throw new ProcessCaptureError("PTY backend does not expose an stdin-close operation");
16
- Reflect.apply(end, terminal, []);
17
- },
18
- kill: (signal) => terminal.kill(signal),
19
- };
20
- };
21
- const controlKind = (input) => input.kind === "observation" ? undefined : input.kind;
22
- /** Reject reactive declarations the current process adapter cannot execute. */
23
- export const assertSupportedReactiveScenario = (scenario) => {
24
- if (scenario.reactive === null)
25
- return;
26
- const unsupported = unsupportedProcessReactiveFeatures(scenario.reactive);
27
- if (unsupported.length === 0)
28
- return;
29
- throw new ProcessCaptureError(`reactive scenario requests unsupported features: ${unsupported.join(", ")}`);
30
- };
31
- /**
32
- * Attach the serialized reactive runtime once the target PID is available.
33
- *
34
- * Subscription replays journal entries admitted during launcher startup before
35
- * observing new records, so PID-dependent normalization cannot drop them.
36
- */
37
- export const startProcessReactiveHarness = (options) => {
38
- if (options.scenario.reactive === null)
39
- return undefined;
40
- const controls = [];
41
- const coordinator = new ProcessReactiveCoordinator({
42
- scenario: options.scenario.reactive,
43
- executor: {
44
- execute: (actions, signal) => executeProcessReactiveEffects({
45
- terminal: () => reactiveTerminalFor(options.terminal()),
46
- renderer: options.renderer,
47
- checkpoints: options.checkpoints,
48
- interactions: options.capture.interactions,
49
- journal: options.capture.journal,
50
- startedAtMs: options.started,
51
- now: Date.now,
52
- timeBucketMs: options.scenario.normalization.time_bucket_ms,
53
- }, actions, signal),
54
- },
55
- onDecision: (decision, input) => {
56
- const kind = controlKind(input);
57
- if (kind === undefined || decision.kind !== "finished")
58
- return;
59
- controls.push({
60
- sequence: controls.length,
61
- kind,
62
- after_capture_order: decision.snapshot.observations.at(-1)?.capture_order ?? -1,
63
- });
64
- },
65
- });
66
- return {
67
- coordinator,
68
- controls,
69
- unsubscribe: subscribeProcessReactiveObservations({
70
- journal: options.capture.journal,
71
- frames: options.capture.frames,
72
- interactions: options.capture.interactions,
73
- checkpointAt: (index) => options.checkpoints.at(index),
74
- processSampleAt: (index) => {
75
- const rootPid = options.terminal()?.pid;
76
- return rootPid === undefined
77
- ? undefined
78
- : normalizeProcessSamples(options.capture.processSamples, options.scenario, rootPid)[index];
79
- },
80
- protocolEventAt: (index) => redactProtocolEvents(options.capture.protocolEvents().slice(index, index + 1), options.scenario)[0],
81
- shimEventAt: (index) => {
82
- const event = options.shimReplay.events[index];
83
- const rootPid = options.terminal()?.pid;
84
- return event === undefined || rootPid === undefined
85
- ? undefined
86
- : normalizeProcessShimEvent(event, options.scenario, options.capture.temporaryRoot, rootPid);
87
- },
88
- sink: coordinator,
89
- }),
90
- };
91
- };
92
- /** Project internal reducer state into the stable Process Capture shape. */
93
- export const projectProcessReactiveRun = (harness) => {
94
- if (harness === undefined)
95
- return null;
96
- const snapshot = harness.coordinator.snapshot;
97
- const completion = snapshot.status === "running"
98
- ? { status: snapshot.status, outcome: null }
99
- : { status: snapshot.status, outcome: snapshot.outcome };
100
- return {
101
- ...completion,
102
- active_state: snapshot.active_state,
103
- transitions: snapshot.transitions,
104
- controls: harness.controls,
105
- };
106
- };