rea-agents 5.0.0 → 6.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 (275) hide show
  1. package/README.md +157 -650
  2. package/bridge/mitmproxy/capture.py +210 -0
  3. package/bridge/native/rea_lldb_tracer.py +303 -0
  4. package/bridge/process/ProcessRunTokenReader.swift +263 -0
  5. package/bridge/process/ProcessRunTokenReaderMain.swift +35 -0
  6. package/bridge/pwndbg/core_context.py +101 -0
  7. package/bridge/pwndbg/launch.py +39 -0
  8. package/bridge/pwndbg/launch_impl.py +34 -0
  9. package/bridge/pwntools/decoder_runtime.py +59 -0
  10. package/bridge/pwntools/layout.py +39 -0
  11. package/bridge/pwntools/layout_impl.py +309 -0
  12. package/bridge/pwntools/recorded_crash.py +39 -0
  13. package/bridge/pwntools/recorded_crash_impl.py +143 -0
  14. package/dist/android/JadxProvider.js +1 -0
  15. package/dist/application/CapabilityInventory.js +21 -0
  16. package/dist/application/DirectAnalysis.js +97 -23
  17. package/dist/application/EvidenceBundleFiles.js +1 -1
  18. package/dist/application/ReconstructionObligationCandidates.js +5 -1
  19. package/dist/application/WebNetworkCapturePort.js +1 -0
  20. package/dist/application/WebNetworkCaptureService.js +132 -0
  21. package/dist/application/WindowsCapabilities.js +1 -1
  22. package/dist/application/binary/AnalysisSnapshotCache.js +49 -6
  23. package/dist/application/binary/BinarySession.js +38 -10
  24. package/dist/application/binary/BinarySessionOpen.js +16 -3
  25. package/dist/application/binary/BinarySessionRecords.js +20 -0
  26. package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
  27. package/dist/application/binaryDiagnostics/BinaryLayoutService.js +57 -0
  28. package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
  29. package/dist/application/binaryDiagnostics/RecordedCrashService.js +60 -0
  30. package/dist/application/evm/EvmInterfacePort.js +1 -0
  31. package/dist/application/evm/EvmInterfaceService.js +62 -0
  32. package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -2
  33. package/dist/application/javascript/JavaScriptApplicationService.js +15 -2
  34. package/dist/application/javascript/JavaScriptArtifactAnalysis.js +42 -23
  35. package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
  36. package/dist/application/javascript/JavaScriptArtifactPathResolution.js +74 -24
  37. package/dist/application/javascript/JavaScriptArtifactReconstruction.js +23 -10
  38. package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
  39. package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +145 -70
  40. package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +14 -15
  41. package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +41 -1
  42. package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +7 -7
  43. package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -9
  44. package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +3 -3
  45. package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +118 -12
  46. package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +3 -3
  47. package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +5 -5
  48. package/dist/application/{ProcessCli.js → process/ProcessCli.js} +10 -10
  49. package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +4 -4
  50. package/dist/artifacts/ArtifactProvider.js +30 -3
  51. package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
  52. package/dist/artifacts/ZipArtifactReader.js +3 -0
  53. package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
  54. package/dist/artifacts/apple/MachoLoadCommandReader.js +294 -0
  55. package/dist/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
  56. package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +3 -3
  57. package/dist/{application → artifacts/inventory}/ArtifactInventory.js +4 -4
  58. package/dist/{application/ArtifactInventory → artifacts/inventory}/classify.js +2 -2
  59. package/dist/{application/ArtifactInventory → artifacts/inventory}/reader.js +5 -5
  60. package/dist/{application/ArtifactInventory → artifacts/inventory}/scanCanonical.js +3 -3
  61. package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
  62. package/dist/artifacts/readStableArtifact.js +20 -4
  63. package/dist/browser/CdpCaptureEventHandlers.js +90 -2
  64. package/dist/browser/CdpCaptureEvents.js +9 -0
  65. package/dist/browser/PlaywrightElectronActiveProvider.js +12 -3
  66. package/dist/browser/history/CaptureFailures.js +101 -0
  67. package/dist/browser/history/CaptureFormatError.js +10 -0
  68. package/dist/browser/history/CaptureRedaction.js +65 -0
  69. package/dist/browser/history/CaptureRelease.js +12 -0
  70. package/dist/browser/history/HarCapture.js +165 -0
  71. package/dist/browser/history/HarCaptureAdapter.js +20 -0
  72. package/dist/browser/history/HarCaptureProcess.js +57 -0
  73. package/dist/browser/history/HarJson.js +91 -0
  74. package/dist/browser/history/HarSchema.js +72 -0
  75. package/dist/browser/history/HistoricalCaptureDecoder.js +186 -0
  76. package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
  77. package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
  78. package/dist/cli/artifactCommands.js +26 -1
  79. package/dist/cli/binaryDiagnosticsCommands.js +39 -0
  80. package/dist/cli/coreAnalysisCommands.js +2 -2
  81. package/dist/cli/coreBinaryCommands.js +8 -8
  82. package/dist/cli/electronCommands.js +16 -9
  83. package/dist/cli/evmCommands.js +24 -0
  84. package/dist/cli/firmwareCommands.js +6 -3
  85. package/dist/cli/javascriptApplicationAnalysis.js +16 -3
  86. package/dist/cli/jsonOutput.js +133 -0
  87. package/dist/cli/nativeCallCommands.js +35 -0
  88. package/dist/cli/processCommands.js +1 -1
  89. package/dist/cli/streamedJsonOutput.js +56 -0
  90. package/dist/cli/utilityCommands.js +2 -0
  91. package/dist/cli/webNetworkCaptureCommands.js +40 -0
  92. package/dist/cli.js +9 -3
  93. package/dist/cliBrowserScenarioCommands.js +2 -2
  94. package/dist/cliCommandNames.js +6 -0
  95. package/dist/cliJsonInput.js +30 -1
  96. package/dist/cliOutput.js +21 -6
  97. package/dist/composition/binaryDiagnostics.js +8 -0
  98. package/dist/composition/evm.js +4 -0
  99. package/dist/composition/webNetworkCaptures.js +6 -0
  100. package/dist/contracts/artifactToolContracts.js +6 -0
  101. package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
  102. package/dist/contracts/browserToolContracts.js +4 -3
  103. package/dist/contracts/errorSchemas.js +8 -1
  104. package/dist/contracts/evm/evmToolContracts.js +20 -0
  105. package/dist/contracts/investigationExamples.js +2 -2
  106. package/dist/contracts/managed/managedToolContracts.js +7 -3
  107. package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
  108. package/dist/contracts/native/nativeToolContracts.js +17 -1
  109. package/dist/contracts/officialToolContracts.js +12 -9
  110. package/dist/contracts/process/processCaptureExample.js +2 -0
  111. package/dist/contracts/sessionLifecycleInputs.js +22 -5
  112. package/dist/contracts/sessionStatusContract.js +10 -2
  113. package/dist/contracts/sessionToolContracts.js +8 -1
  114. package/dist/contracts/sessionToolSchemas.js +10 -3
  115. package/dist/contracts/toolContractExamples.js +1 -1
  116. package/dist/contracts/toolContracts.js +6 -0
  117. package/dist/contracts/toolEffects.js +30 -0
  118. package/dist/contracts/toolOutputSchemaGroups.js +5 -1
  119. package/dist/contracts/toolOutputSchemaPrimitives.js +1 -1
  120. package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
  121. package/dist/domain/analysisErrorBase.js +15 -0
  122. package/dist/domain/analysisErrorCore.js +59 -5
  123. package/dist/domain/analysisErrorPresentation.js +29 -1
  124. package/dist/domain/analysisErrorProjection.js +52 -2
  125. package/dist/domain/analysisSnapshot.js +166 -2
  126. package/dist/domain/apple/dyldPaths.js +81 -0
  127. package/dist/domain/apple/dylibResolution.js +367 -0
  128. package/dist/domain/apple/dylibResolutionFindings.js +75 -0
  129. package/dist/domain/artifactPathSyntax.js +1 -1
  130. package/dist/domain/browserObservation.js +1 -1
  131. package/dist/domain/browserObservationSchemas.js +13 -0
  132. package/dist/domain/browserScenarioValues.js +9 -2
  133. package/dist/domain/callPathSchemas.js +1 -1
  134. package/dist/domain/canonicalDigest.js +13 -1
  135. package/dist/domain/changedBehavior.js +3 -3
  136. package/dist/domain/comparisonStatus.js +2 -30
  137. package/dist/domain/conformanceTrustGate.js +0 -16
  138. package/dist/domain/evidence.js +17 -5
  139. package/dist/domain/evm/evmInterface.js +63 -0
  140. package/dist/domain/explicitSensitiveFailure.js +92 -0
  141. package/dist/domain/explicitSensitiveValues.js +10 -0
  142. package/dist/domain/firmware/firmwareAnalysis.js +8 -1
  143. package/dist/domain/javascript/electronActiveObservation.js +9 -4
  144. package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
  145. package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
  146. package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
  147. package/dist/domain/javascript/javascriptSemanticGraph.js +21 -5
  148. package/dist/domain/jsonValue.js +4 -0
  149. package/dist/domain/localPath.js +2 -0
  150. package/dist/domain/native/binaryLayout.js +357 -0
  151. package/dist/domain/native/nativeCallObservation.js +164 -0
  152. package/dist/domain/native/objcSwiftMetadata.js +0 -39
  153. package/dist/domain/native/recordedCrash.js +266 -0
  154. package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
  155. package/dist/domain/{processCapture.js → process/processCapture.js} +139 -2
  156. package/dist/domain/{processCaptureExample.js → process/processCaptureExample.js} +5 -0
  157. package/dist/domain/process/processCaptureParsing.js +54 -0
  158. package/dist/domain/{processCaptureValidation.js → process/processCaptureValidation.js} +18 -2
  159. package/dist/domain/{processComparison.js → process/processComparison.js} +1 -1
  160. package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
  161. package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
  162. package/dist/domain/providerSelectionError.js +4 -2
  163. package/dist/domain/reconstructionVerification.js +3 -3
  164. package/dist/domain/reconstructionVerificationSchemas.js +1 -1
  165. package/dist/domain/residualUnknown.js +3 -2
  166. package/dist/domain/staticRuntimeCorrelation.js +3 -3
  167. package/dist/domain/webCaptureDiff.js +1 -0
  168. package/dist/domain/webNetworkCapture.js +118 -0
  169. package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
  170. package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
  171. package/dist/dotnet/ManagedMemberInspector.js +4 -2
  172. package/dist/dotnet/ManagedMemberInspectorCore.js +38 -32
  173. package/dist/dotnet/ManagedMemberInstructionDecoder.js +23 -7
  174. package/dist/dotnet/ManagedMemberRows.js +14 -3
  175. package/dist/dotnet/ManagedMetadataHeaps.js +20 -2
  176. package/dist/dotnet/ManagedMetadataInventory.js +38 -28
  177. package/dist/dotnet/ManagedMetadataInventoryRows.js +24 -10
  178. package/dist/dotnet/ManagedMethodBodyReader.js +7 -1
  179. package/dist/dotnet/ManagedNativeBoundaryHelpers.js +15 -3
  180. package/dist/dotnet/ManagedNativeBoundaryInspector.js +3 -1
  181. package/dist/dotnet/ManagedPeReader.js +11 -0
  182. package/dist/evm/EvmBytecodeCarrier.js +21 -0
  183. package/dist/evm/EvmWorkerLimits.js +40 -0
  184. package/dist/evm/EvmoleFailures.js +126 -0
  185. package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
  186. package/dist/evm/EvmoleInterfaceProvider.js +273 -0
  187. package/dist/evm/EvmoleInterfaceWorker.js +87 -0
  188. package/dist/evm/EvmoleRelease.js +16 -0
  189. package/dist/firmware/FirmwareCommand.js +1 -0
  190. package/dist/generatedPackageMetadata.js +2 -2
  191. package/dist/ghidra/GhidraLauncher.js +1 -0
  192. package/dist/ghidra/GhidraProvider.js +2 -2
  193. package/dist/ghidra/GhidraProviderCapabilities.js +1 -1
  194. package/dist/hopper/BridgeLauncher.js +2 -0
  195. package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
  196. package/dist/javascript/recovery/WakaruCommand.js +3 -0
  197. package/dist/javascript/sourceMaps/SourceMapCommand.js +1 -0
  198. package/dist/native/CommandRunner.js +2 -1
  199. package/dist/native/LldbCallTracer.js +278 -0
  200. package/dist/native/NativeCallObservation.js +135 -0
  201. package/dist/native/NativeMacOSProvider.js +19 -3
  202. package/dist/native/NativeMacOSProviderMetadata.js +8 -3
  203. package/dist/native/pwndbg/PwndbgCoreContext.js +160 -0
  204. package/dist/native/pwntools/PwntoolsDecoder.js +203 -0
  205. package/dist/native/pwntools/PwntoolsFailures.js +180 -0
  206. package/dist/native/pwntools/PwntoolsLayoutProvider.js +36 -0
  207. package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +75 -0
  208. package/dist/native/pwntools/PwntoolsRelease.js +19 -0
  209. package/dist/native/pwntools/PwntoolsResourceLimits.js +76 -0
  210. package/dist/native/pwntools/RecordedCrashSourceBindings.js +46 -0
  211. package/dist/native/pwntools/RecordedCrashStructureBindings.js +101 -0
  212. package/dist/process/DarwinProcessRunTokenReader.js +294 -0
  213. package/dist/process/OwnedCommand.js +113 -0
  214. package/dist/process/ProcessOwnership.js +263 -33
  215. package/dist/process/ProcessOwnershipObservation.js +161 -24
  216. package/dist/process/ProviderProcess.js +30 -3
  217. package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
  218. package/dist/{application → process/capture}/ProcessCaptureError.js +17 -1
  219. package/dist/process/capture/ProcessCaptureLifecycle.js +615 -0
  220. package/dist/{application → process/capture}/ProcessHarness.js +195 -29
  221. package/dist/{application → process/capture}/ProcessSampling.js +2 -2
  222. package/dist/server/createServer.js +22 -0
  223. package/dist/server/promptCompletion.js +10 -3
  224. package/dist/server/registerBinaryDiagnosticsTools.js +17 -0
  225. package/dist/server/registerEvidenceTools.js +1 -1
  226. package/dist/server/registerEvmTools.js +17 -0
  227. package/dist/server/registerProcessComparisonTool.js +1 -1
  228. package/dist/server/registerRecordedCrashTools.js +17 -0
  229. package/dist/server/registerSessionTools.js +2 -2
  230. package/dist/server/registerWebNetworkCaptureTool.js +28 -0
  231. package/dist/server/sessionAvailabilityPolicy.js +3 -0
  232. package/dist/server/sessionToolPolicies.js +1 -1
  233. package/dist/server/toolResult.js +1 -1
  234. package/native/windows/build/manifest.json +2 -2
  235. package/native/windows/build/rea-windows-x64.node +0 -0
  236. package/package.json +37 -9
  237. package/scripts/rea.mjs +11 -3
  238. package/skills/reverse-engineer-anything/SKILL.md +23 -3
  239. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +29 -0
  240. package/third_party/README.md +60 -0
  241. package/third_party/evmole/LICENSE +21 -0
  242. package/third_party/evmole/README.md +22 -0
  243. package/third_party/pwndbg/LICENSE.md +21 -0
  244. package/third_party/pwndbg/README.md +23 -0
  245. package/third_party/pwntools/README.md +40 -0
  246. package/dist/application/AuthorizedArtifactInventory.js +0 -7
  247. package/dist/application/ProcessCaptureLifecycle.js +0 -299
  248. package/dist/application/StoreFileLock.js +0 -124
  249. package/dist/contracts/processCaptureExample.js +0 -2
  250. package/dist/domain/bytecodeProvider.js +0 -178
  251. package/dist/domain/customProtocolCapture.js +0 -137
  252. package/dist/domain/eventProcessTree.js +0 -225
  253. package/dist/domain/mobileApplicationInvestigation.js +0 -159
  254. package/dist/domain/packageAnalysis.js +0 -123
  255. package/dist/domain/peInspection.js +0 -197
  256. package/dist/domain/processCaptureParsing.js +0 -21
  257. package/dist/domain/protocolCapture.js +0 -217
  258. package/dist/domain/runtimeIdentification.js +0 -212
  259. package/dist/generatedMcpToolCatalog.js +0 -37
  260. /package/dist/application/{ArtifactExtractionDestination.js → artifacts/ArtifactExtractionDestination.js} +0 -0
  261. /package/dist/{application/ArtifactInventory → artifacts/inventory}/policy.js +0 -0
  262. /package/dist/{application/ArtifactInventory → artifacts/inventory}/types.js +0 -0
  263. /package/dist/domain/{processEvidenceProvider.js → process/processEvidenceProvider.js} +0 -0
  264. /package/dist/domain/{processScenario.js → process/processScenario.js} +0 -0
  265. /package/dist/domain/{processTraceComparison.js → process/processTraceComparison.js} +0 -0
  266. /package/dist/domain/{processTraceDimensionProjection.js → process/processTraceDimensionProjection.js} +0 -0
  267. /package/dist/domain/{processTraceEvaluation.js → process/processTraceEvaluation.js} +0 -0
  268. /package/dist/{application → process/capture}/FilesystemSnapshot.js +0 -0
  269. /package/dist/{application → process/capture}/ProcessCaptureEnvironment.js +0 -0
  270. /package/dist/{application → process/capture}/ProcessCaptureJournal.js +0 -0
  271. /package/dist/{application → process/capture}/ProcessFilesystemEffects.js +0 -0
  272. /package/dist/{application → process/capture}/ProcessNormalization.js +0 -0
  273. /package/dist/{application → process/capture}/ProcessScenarioRuntimeValidation.js +0 -0
  274. /package/dist/{application → process/capture}/ProcessTimer.js +0 -0
  275. /package/dist/{application → process/capture}/TerminalRenderer.js +0 -0
@@ -0,0 +1,273 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { access, readFile, stat, writeFile } from "node:fs/promises";
3
+ import { constants } from "node:fs";
4
+ import { isAbsolute, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { z } from "zod";
7
+ import { createAnalysisExecution, } from "../application/AnalysisProvider.js";
8
+ import { readStableArtifact } from "../artifacts/readStableArtifact.js";
9
+ import { OwnedCommandFailure } from "../process/OwnedCommand.js";
10
+ import { AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisUnsupportedTargetError, AnalysisInputError, AnalysisOutputError, } from "../domain/analysisErrorCore.js";
11
+ import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
12
+ import { evmInterfaceSchema } from "../domain/evm/evmInterface.js";
13
+ import { ProviderAdapterError } from "../domain/providerAdapterError.js";
14
+ import { ProviderCleanupError } from "../domain/providerCleanupError.js";
15
+ import { err, ok } from "../domain/result.js";
16
+ import { runOwnedCommand } from "../process/OwnedCommand.js";
17
+ import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js";
18
+ import { evmInterfaceFailure, capturedEvmOutput, } from "./EvmoleFailures.js";
19
+ import { evmoleInterfaceReplySchema, projectEvmoleInterface, } from "./EvmoleInterfaceAdapter.js";
20
+ import { EVMOLE_PROVIDER_IDENTITY, EVM_INTERFACE_LIMITS, EVM_FILE_SIZE_FAILURE_EXIT, } from "./EvmoleRelease.js";
21
+ import { decodeEvmBytecodeCarrier } from "./EvmBytecodeCarrier.js";
22
+ import { selectEvmWorkerLimits, } from "./EvmWorkerLimits.js";
23
+ const OPERATION = "inspect_evm_interface";
24
+ const replySchema = z.discriminatedUnion("ok", [
25
+ z.strictObject({
26
+ ok: z.literal(true),
27
+ version: z.literal("0.9.3"),
28
+ bytecode: z.strictObject({
29
+ sha256: z.string().regex(/^[a-f0-9]{64}$/),
30
+ bytes: z.number().int().nonnegative(),
31
+ hex: z.string().regex(/^(?:[a-f0-9]{2})*$/),
32
+ }),
33
+ raw: evmoleInterfaceReplySchema,
34
+ }),
35
+ z.strictObject({
36
+ ok: z.literal(false),
37
+ reason: z.enum(["format", "decoder", "output-limit", "unsupported"]),
38
+ message: z.string(),
39
+ }),
40
+ ]);
41
+ /** Run unchanged EVMole/WASM in an owned worker; no target, chain or network execution. */
42
+ export class EvmoleInterfaceProvider {
43
+ environment;
44
+ launcher;
45
+ createRuntime;
46
+ constructor(environment = process.env, launcher, createRuntime = () => PrivateRuntimeRoot.create({ prefix: "rea-evm-interface-" })) {
47
+ this.environment = environment;
48
+ this.launcher = launcher;
49
+ this.createRuntime = createRuntime;
50
+ }
51
+ /** Bind recovered interface candidates to both original carrier and decoded byte identity. */
52
+ async inspect(input, options) {
53
+ let root;
54
+ let retainedOutput;
55
+ let phase = "configuration";
56
+ let workerLimits;
57
+ const limiter = this.environment.REA_EVM_PRLIMIT_COMMAND ?? "/usr/bin/prlimit";
58
+ let result;
59
+ try {
60
+ if (options?.signal?.aborted)
61
+ throw new AnalysisCancelledError(OPERATION);
62
+ if (process.platform !== "linux" || process.arch !== "x64")
63
+ throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, "Initial real-verified offline EVM interface profile supports Linux x64 only.");
64
+ try {
65
+ if (!isAbsolute(limiter))
66
+ throw new Error("REA_EVM_PRLIMIT_COMMAND must be an absolute executable path.");
67
+ await access(limiter, constants.X_OK);
68
+ if (!(await stat(limiter)).isFile())
69
+ throw new Error("Configured prlimit must be a regular executable file, not a directory.");
70
+ }
71
+ catch (cause) {
72
+ const reason = `Offline EVM interface inspection requires caller-supplied util-linux prlimit: ${limiter}; ${cause instanceof Error ? cause.message : String(cause)}`;
73
+ throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, reason, { cause, userMessage: reason });
74
+ }
75
+ let inheritedLimits;
76
+ try {
77
+ inheritedLimits = await readFile("/proc/self/limits", "utf8");
78
+ }
79
+ catch (cause) {
80
+ const reason = `Could not read inherited Linux resource limits at /proc/self/limits: ${cause instanceof Error ? cause.message : String(cause)}`;
81
+ throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, reason, { cause, userMessage: reason });
82
+ }
83
+ const limits = selectEvmWorkerLimits(inheritedLimits);
84
+ if (!limits.ok)
85
+ throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, limits.error, { userMessage: limits.error });
86
+ workerLimits = limits.value;
87
+ phase = "artifact-read";
88
+ const carrier = await readStableArtifact(input.path, EVM_INTERFACE_LIMITS.inputBytes, options?.signal);
89
+ phase = "worker";
90
+ root = await this.createRuntime();
91
+ const snapshotPath = join(root.path, "carrier.snapshot");
92
+ const requestPath = join(root.path, "request.json");
93
+ const replyPath = join(root.path, "reply.json");
94
+ await writeFile(snapshotPath, carrier.bytes, {
95
+ flag: "wx",
96
+ mode: 0o600,
97
+ ...(options?.signal === undefined ? {} : { signal: options.signal }),
98
+ });
99
+ await writeFile(requestPath, JSON.stringify({
100
+ snapshot_path: snapshotPath,
101
+ reply_path: replyPath,
102
+ failure_marker_path: join(root.path, "resource.failure"),
103
+ encoding: input.encoding,
104
+ }), { flag: "wx", mode: 0o600 });
105
+ const { NODE_OPTIONS: _ambientNodeOptions, ...environment } = this.environment;
106
+ const execution = await runOwnedCommand({
107
+ command: limiter,
108
+ arguments: [
109
+ `--as=${String(workerLimits.addressSpaceBytes)}:`,
110
+ `--fsize=${String(workerLimits.fileSizeBytes)}:`,
111
+ "--core=0:",
112
+ `--cpu=${String(workerLimits.cpuSeconds)}:`,
113
+ "--",
114
+ process.execPath,
115
+ "--max-old-space-size=256",
116
+ "--v8-pool-size=1",
117
+ "--disable-wasm-trap-handler",
118
+ fileURLToPath(new URL("./EvmoleInterfaceWorker.js", import.meta.url)),
119
+ requestPath,
120
+ ],
121
+ cwd: root.path,
122
+ expectedCommand: null,
123
+ runId: `rea-evm-interface-${randomUUID()}`,
124
+ hostEnvironment: environment,
125
+ }, {
126
+ timeoutMs: EVM_INTERFACE_LIMITS.timeoutMs,
127
+ diagnosticBytes: EVM_INTERFACE_LIMITS.diagnosticBytes,
128
+ }, {
129
+ ...(options?.signal === undefined ? {} : { signal: options.signal }),
130
+ ...(this.launcher === undefined ? {} : { launcher: this.launcher }),
131
+ });
132
+ const capturedOutput = capturedEvmOutput(execution);
133
+ retainedOutput = capturedOutput;
134
+ let reply;
135
+ try {
136
+ const file = await readStableArtifact(replyPath, EVM_INTERFACE_LIMITS.outputBytes, options?.signal);
137
+ reply = replySchema.parse(JSON.parse(file.bytes.toString("utf8")));
138
+ }
139
+ catch (cause) {
140
+ if (options?.signal?.aborted)
141
+ throw new AnalysisCancelledError(OPERATION, { capturedOutput });
142
+ throw new AnalysisOutputError(OPERATION, `Owned interface worker reply failed for ${input.path}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause, capturedOutput });
143
+ }
144
+ if (!reply.ok) {
145
+ if (reply.reason === "unsupported")
146
+ throw new AnalysisUnsupportedTargetError(OPERATION, input.path, reply.message, { capturedOutput });
147
+ if (reply.reason === "format")
148
+ throw new AnalysisInputError(OPERATION, { capturedOutput }, [
149
+ {
150
+ path: ["path"],
151
+ reason: "invalid_format",
152
+ message: reply.message,
153
+ },
154
+ ]);
155
+ if (reply.reason === "output-limit")
156
+ throw new AnalysisOutputError(OPERATION, reply.message, {
157
+ capturedOutput,
158
+ });
159
+ throw new ProviderAdapterError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, {
160
+ diagnostics: {
161
+ phase,
162
+ failure_kind: reply.reason,
163
+ reason: reply.message,
164
+ stdout: execution.stdout.text,
165
+ stderr: execution.stderr.text,
166
+ captured_output: { ...capturedOutput },
167
+ },
168
+ });
169
+ }
170
+ const selectedBytes = decodeEvmBytecodeCarrier(carrier.bytes, input.encoding);
171
+ const selectedHex = Buffer.from(selectedBytes).toString("hex");
172
+ const decodedHash = createHash("sha256")
173
+ .update(selectedBytes)
174
+ .digest("hex");
175
+ if (decodedHash !== reply.bytecode.sha256 ||
176
+ selectedHex !== reply.bytecode.hex ||
177
+ selectedBytes.length !== reply.bytecode.bytes)
178
+ throw new AnalysisOutputError(OPERATION, "Decoded bytecode representation does not match the selected carrier, encoding or reported SHA-256.", { capturedOutput });
179
+ const limitations = [
180
+ `Configured worker resource soft limits: address_space_bytes=${String(workerLimits.addressSpaceBytes)}, cpu_seconds=${String(workerLimits.cpuSeconds)}, file_size_bytes=${String(workerLimits.fileSizeBytes)}. Selected from inherited tighter limits; original hard limits are retained. Effective worker limits are not independently probed.`,
181
+ "Upstream may also report terminal metadata while recovering selectors. Its reported values are retained in raw_result, but integer precision and non-text-key coverage are unknown in the JS binding; complete original bytecode remains available.",
182
+ "Recovered selectors, argument strings and mutability are upstream inferences, not verified ABI signatures or names. Empty results do not prove the absence of callable dispatch.",
183
+ "Bytecode kind, hardfork and deployed-contract authenticity are unknown. This inspection performs no target runtime execution, chain/RPC lookup or network request.",
184
+ "Original carrier and decoded bytecode SHA-256 are distinct identities; SHA-256 is not the Ethereum Keccak code hash.",
185
+ "The owned worker has a 256 MiB JavaScript heap, 3 GiB virtual address-space limit and 30-second deadline. Virtual address space is distinct from resident memory; limits fail without partial success.",
186
+ ];
187
+ const validated = evmInterfaceSchema.safeParse({
188
+ artifact: {
189
+ path: input.path,
190
+ sha256: carrier.sha256,
191
+ bytes: carrier.bytes.length,
192
+ encoding: input.encoding,
193
+ },
194
+ bytecode: {
195
+ ...reply.bytecode,
196
+ digest_algorithm: "sha256",
197
+ kind: "unknown",
198
+ deployment_authenticity: "unknown",
199
+ hardfork: "unknown",
200
+ },
201
+ evidence_kind: "inferred",
202
+ functions: projectEvmoleInterface(reply.raw).functions,
203
+ discovery_completeness: "unknown",
204
+ runtime_execution: "not-performed",
205
+ diagnostics: {
206
+ stdout: execution.stdout.text,
207
+ stderr: execution.stderr.text,
208
+ truncated: capturedOutput.truncated,
209
+ },
210
+ limitations,
211
+ });
212
+ if (!validated.success)
213
+ throw new AnalysisOutputError(OPERATION, `Interface worker returned invalid bytecode-relative evidence: ${validated.error.issues[0]?.message ?? "schema mismatch"}`, { capturedOutput });
214
+ const report = validated.data;
215
+ result = ok(createAnalysisExecution(report, EVMOLE_PROVIDER_IDENTITY, {
216
+ rawResult: reply.raw,
217
+ subject: { path: input.path, format: "file", sha256: carrier.sha256 },
218
+ locations: [{ kind: "artifact-path", path: input.path }],
219
+ limitations,
220
+ }));
221
+ }
222
+ catch (cause) {
223
+ let fileFailure;
224
+ if (cause instanceof OwnedCommandFailure &&
225
+ cause.snapshot?.exitCode === EVM_FILE_SIZE_FAILURE_EXIT &&
226
+ cause.snapshot.signal === null &&
227
+ root !== undefined) {
228
+ try {
229
+ const marker = await readStableArtifact(join(root.path, "resource.failure"), 1);
230
+ if (!marker.bytes.equals(Buffer.from("F")))
231
+ throw new Error("Private worker failure marker does not match the observed exit status.");
232
+ fileFailure = { verified: true, failure: null };
233
+ }
234
+ catch (markerFailure) {
235
+ fileFailure = {
236
+ verified: false,
237
+ failure: markerFailure instanceof Error
238
+ ? markerFailure.message
239
+ : String(markerFailure),
240
+ };
241
+ }
242
+ }
243
+ result = err(options?.signal?.aborted &&
244
+ (cause === options.signal.reason ||
245
+ (cause instanceof Error && cause.name === "AbortError"))
246
+ ? new AnalysisCancelledError(OPERATION, retainedOutput === undefined
247
+ ? undefined
248
+ : { capturedOutput: retainedOutput })
249
+ : evmInterfaceFailure(cause, phase, input.path, workerLimits, limiter, fileFailure));
250
+ }
251
+ if (root !== undefined) {
252
+ try {
253
+ await root.close();
254
+ }
255
+ catch (cause) {
256
+ return err(new ProviderCleanupError(EVMOLE_PROVIDER_IDENTITY.id, [root.path], {
257
+ reason: cause instanceof Error ? cause.message : String(cause),
258
+ previous_error: result.ok
259
+ ? null
260
+ : projectAnalysisError(result.error),
261
+ ...(retainedOutput === undefined
262
+ ? {}
263
+ : { captured_output: { ...retainedOutput } }),
264
+ }, { operation: OPERATION }));
265
+ }
266
+ }
267
+ return result.ok && options?.signal?.aborted
268
+ ? err(new AnalysisCancelledError(OPERATION, retainedOutput === undefined
269
+ ? undefined
270
+ : { capturedOutput: retainedOutput }))
271
+ : result;
272
+ }
273
+ }
@@ -0,0 +1,87 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFile, writeFile } from "node:fs/promises";
3
+ import { z } from "zod";
4
+ import { decodeEvmBytecodeCarrier, EvmCarrierFailure, } from "./EvmBytecodeCarrier.js";
5
+ import { projectEvmoleInterface } from "./EvmoleInterfaceAdapter.js";
6
+ import { EVM_INTERFACE_LIMITS, EVM_FILE_SIZE_FAILURE_EXIT, } from "./EvmoleRelease.js";
7
+ const requestSchema = z.strictObject({
8
+ snapshot_path: z.string(),
9
+ reply_path: z.string(),
10
+ failure_marker_path: z.string(),
11
+ encoding: z.enum(["raw", "hex"]),
12
+ });
13
+ class UnsupportedContainer extends Error {
14
+ }
15
+ const main = async () => {
16
+ const requestPath = process.argv[2];
17
+ if (requestPath === undefined)
18
+ throw new Error("Owned worker request path missing.");
19
+ const request = requestSchema.parse(JSON.parse(await readFile(requestPath, "utf8")));
20
+ let reply;
21
+ try {
22
+ const bytes = decodeEvmBytecodeCarrier(await readFile(request.snapshot_path), request.encoding);
23
+ if (bytes[0] === 0xef && bytes[1] === 0x00)
24
+ throw new UnsupportedContainer("Container marker EF00 is outside the verified flat-bytecode interface profile.");
25
+ const modulePath = import.meta.resolve("evmole/no_tla");
26
+ const metadata = z
27
+ .object({ version: z.literal("0.9.3") })
28
+ .parse(JSON.parse(await readFile(new URL("../package.json", modulePath), "utf8")));
29
+ const engine = await import("evmole/no_tla");
30
+ engine.initSync({
31
+ module: await readFile(new URL(import.meta.resolve("evmole/evmole_bg.wasm"))),
32
+ });
33
+ const inferred = projectEvmoleInterface(engine.contractInfo(Buffer.from(bytes).toString("hex"), {
34
+ selectors: true,
35
+ arguments: true,
36
+ stateMutability: true,
37
+ }));
38
+ reply = {
39
+ ok: true,
40
+ version: metadata.version,
41
+ bytecode: {
42
+ sha256: createHash("sha256").update(bytes).digest("hex"),
43
+ bytes: bytes.length,
44
+ hex: Buffer.from(bytes).toString("hex"),
45
+ },
46
+ raw: inferred.raw,
47
+ };
48
+ }
49
+ catch (cause) {
50
+ reply = {
51
+ ok: false,
52
+ reason: cause instanceof EvmCarrierFailure
53
+ ? "format"
54
+ : cause instanceof UnsupportedContainer
55
+ ? "unsupported"
56
+ : "decoder",
57
+ message: cause instanceof Error ? cause.message : String(cause),
58
+ };
59
+ }
60
+ let encoded = JSON.stringify(reply);
61
+ if (Buffer.byteLength(encoded) > EVM_INTERFACE_LIMITS.outputBytes)
62
+ encoded = JSON.stringify({
63
+ ok: false,
64
+ reason: "output-limit",
65
+ message: "Complete interface evidence exceeds the 16 MiB reply budget.",
66
+ });
67
+ try {
68
+ await writeFile(request.reply_path, encoded, { flag: "wx", mode: 0o600 });
69
+ }
70
+ catch (cause) {
71
+ if (cause instanceof Error && "code" in cause && cause.code === "EFBIG") {
72
+ try {
73
+ await writeFile(request.failure_marker_path, "F", {
74
+ flag: "wx",
75
+ mode: 0o600,
76
+ });
77
+ }
78
+ catch (markerFailure) {
79
+ process.stderr.write(`File-size failure marker unavailable: ${markerFailure instanceof Error ? markerFailure.message : String(markerFailure)}\n`);
80
+ }
81
+ process.exitCode = EVM_FILE_SIZE_FAILURE_EXIT;
82
+ }
83
+ else
84
+ throw cause;
85
+ }
86
+ };
87
+ await main();
@@ -0,0 +1,16 @@
1
+ /** Unchanged locked npm/WASM profile; provenance is independent of chain deployment authenticity. */
2
+ export const EVMOLE_PROVIDER_IDENTITY = {
3
+ id: "evmole-interface",
4
+ name: "REA EVM interface adapter",
5
+ version: "evmole@0.9.3",
6
+ };
7
+ /** Worker-reserved status for an observed EFBIG write without a complete reply. */
8
+ export const EVM_FILE_SIZE_FAILURE_EXIT = 76;
9
+ /** Complete offline inspection budgets; worker JavaScript heap is bounded separately. */
10
+ export const EVM_INTERFACE_LIMITS = {
11
+ inputBytes: 4 * 1024 * 1024,
12
+ outputBytes: 16 * 1024 * 1024,
13
+ timeoutMs: 30_000,
14
+ diagnosticBytes: 1024 * 1024,
15
+ addressSpaceBytes: 3 * 1024 * 1024 * 1024,
16
+ };
@@ -63,6 +63,7 @@ export const runFirmwareCommand = async (context) => {
63
63
  runId,
64
64
  cwd: context.cwd,
65
65
  hostEnvironment: context.environment,
66
+ signal,
66
67
  env: {
67
68
  TMPDIR: context.cwd,
68
69
  OMP_NUM_THREADS: "1",
@@ -1,9 +1,9 @@
1
1
  /** Generated from package.json and package-lock.json; do not edit. */
2
2
  export const PACKAGE_METADATA = {
3
3
  name: "rea-agents",
4
- version: "5.0.0", // x-release-please-version
4
+ version: "6.0.0", // x-release-please-version
5
5
  serverSdkVersion: "2.3.1",
6
6
  clientSdkVersion: "2.3.1",
7
7
  coreSdkVersion: "2.3.1",
8
- skillVersion: "27",
8
+ skillVersion: "33",
9
9
  };
@@ -76,6 +76,7 @@ export class GhidraHeadlessLauncher {
76
76
  windowsVerbatimArguments: platform === "win32",
77
77
  platform,
78
78
  env: ghidraLaunchEnvironment(paths, this.options.javaHome, platform, command.command),
79
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
79
80
  });
80
81
  await writeGhidraRuntimeFile(paths.ownershipPath, `${JSON.stringify({
81
82
  run_id: session.runId,
@@ -163,11 +163,11 @@ const inspectWindowsP0TargetSupport = (target, diagnostics) => {
163
163
  reason: "Windows Ghidra P0 accepts PE targets only.",
164
164
  diagnostics,
165
165
  };
166
- if (target.architecture !== "x86_64")
166
+ if (target.architecture !== "x86" && target.architecture !== "x86_64")
167
167
  return {
168
168
  status: "unsupported",
169
169
  code: "architecture_unsupported",
170
- reason: "Windows Ghidra P0 accepts x86-64 PE targets only.",
170
+ reason: "Windows Ghidra P0 accepts x86 and x86-64 PE targets only.",
171
171
  diagnostics,
172
172
  };
173
173
  if (target.executableRole !== "application")
@@ -19,7 +19,7 @@ export const healthLimitations = Object.freeze([
19
19
  ]);
20
20
  /** Additional limitations applied to the experimental Windows x64 P0 boundary. */
21
21
  export const windowsP0Limitations = Object.freeze([
22
- "Windows Ghidra P0 accepts approved native x86-64 PE applications only; DLL, managed, hostile, sensitive, and mutable-path targets are unsupported.",
22
+ "Windows Ghidra P0 accepts approved native x86 and x86-64 PE applications only; DLL, managed, hostile, sensitive, and mutable-path targets are unsupported.",
23
23
  "The Windows bridge uses authenticated IPv4 loopback because Node path-based IPC does not expose Java AF_UNIX sockets; the endpoint file contains no bearer token.",
24
24
  "Windows sessions require the matching packaged Windows x64 native addon, local NTFS targets and runtimes, and Windows 10 or later. Native handles enforce path admission, private DACLs, and Job Object ownership automatically.",
25
25
  ]);
@@ -189,6 +189,7 @@ const launchHopperProcess = async (input) => {
189
189
  arguments: arguments_,
190
190
  runId: input.session.runId,
191
191
  expectedCommand: ownershipCommand,
192
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
192
193
  });
193
194
  if (input.linuxDemo !== undefined)
194
195
  return spawnOwnedProviderProcess({
@@ -196,6 +197,7 @@ const launchHopperProcess = async (input) => {
196
197
  arguments: input.linuxDemo.args,
197
198
  runId: input.session.runId,
198
199
  expectedCommand: ownershipCommand,
200
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
199
201
  });
200
202
  return spawn(input.argumentsForTarget);
201
203
  };
@@ -6,6 +6,7 @@ import { parseLinuxPrivateDisplayDiagnostic } from "./LinuxPrivateDisplayDiagnos
6
6
  const PYTHON_PATH = "/usr/bin/python3";
7
7
  const UNSHARE_PATH = "/usr/bin/unshare";
8
8
  const DEFAULT_PROBE_TIMEOUT_MS = 5_000;
9
+ const isAborted = (signal) => signal?.aborted === true;
9
10
  /** Probe the exact Xvfb boundary and select the least-privileged viable strategy. */
10
11
  export const selectLinuxPrivateDisplayStrategy = async (options) => {
11
12
  const timeoutMs = options.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
@@ -39,7 +40,7 @@ export const selectLinuxPrivateDisplayStrategy = async (options) => {
39
40
  };
40
41
  /** Run one helper probe in an owned process group and retain its full diagnostics. */
41
42
  export const runLinuxPrivateDisplayProbe = async (strategy, options) => {
42
- if (options.signal?.aborted === true)
43
+ if (isAborted(options.signal))
43
44
  return emptyProcessResult("cancelled");
44
45
  const command = privateDisplayProbeCommand(options.helperPath, strategy);
45
46
  let started;
@@ -49,12 +50,13 @@ export const runLinuxPrivateDisplayProbe = async (strategy, options) => {
49
50
  arguments: command.arguments,
50
51
  runId: randomUUID(),
51
52
  expectedCommand: null,
53
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
52
54
  });
53
55
  }
54
56
  catch (cause) {
55
57
  // best-effort cleanup: probe spawn failure is reported as launch-failed.
56
58
  void cause;
57
- return emptyProcessResult("launch-failed");
59
+ return emptyProcessResult(isAborted(options.signal) ? "cancelled" : "launch-failed");
58
60
  }
59
61
  const launch = {
60
62
  process: started.process,
@@ -51,8 +51,11 @@ export const runWakaruCommand = async (context) => {
51
51
  runId,
52
52
  cwd: context.cwd,
53
53
  hostEnvironment: context.environment,
54
+ ...(context.signal === undefined ? {} : { signal: context.signal }),
54
55
  env: { TMPDIR: context.cwd, RAYON_NUM_THREADS: "1", NO_COLOR: "1" },
55
56
  }).catch((cause) => {
57
+ if (context.signal?.aborted === true)
58
+ throw new AnalysisCancelledError(OPERATION);
56
59
  throw new ProviderAdapterError("wakaru", OPERATION, {
57
60
  cause,
58
61
  diagnostics: {
@@ -81,6 +81,7 @@ class OwnedCodec {
81
81
  runId: this.#runId,
82
82
  cwd: this.#runtime.path,
83
83
  hostEnvironment: environment,
84
+ signal: this.deadline.signal,
84
85
  });
85
86
  this.#supervisor = new ProviderProcessSupervisor({
86
87
  ...spawned,
@@ -64,7 +64,8 @@ const ALLOWED_TOOLS = new Set([
64
64
  "swift-demangle",
65
65
  "vtool",
66
66
  ]);
67
- const resolveXcrunTool = async (tool, signal) => {
67
+ /** Locate an Xcode tool through `xcrun --find` and pin its executable digest. */
68
+ export const resolveXcrunTool = async (tool, signal) => {
68
69
  const found = await captureProcess("/usr/bin/xcrun", ["--find", tool], "xcrun", signal === undefined ? {} : { signal });
69
70
  if (!found.ok) {
70
71
  if (found.error.reason === "cancelled")