rea-agents 0.3.0 → 0.4.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 (122) hide show
  1. package/README.md +124 -20
  2. package/bridge/hopper_bridge.py +141 -13
  3. package/dist/application/AnalysisProvider.js +12 -1
  4. package/dist/application/ArtifactExtraction.js +166 -0
  5. package/dist/application/ArtifactGraphConstruction.js +257 -0
  6. package/dist/application/ArtifactInventory.js +253 -0
  7. package/dist/application/BinarySession.js +164 -14
  8. package/dist/application/CompositeProvider.js +73 -0
  9. package/dist/application/DirectAnalysis.js +27 -3
  10. package/dist/application/Doctor.js +35 -6
  11. package/dist/application/EnhancedTools.js +8 -7
  12. package/dist/application/EvidenceBundleCommands.js +29 -0
  13. package/dist/application/EvidenceBundleFiles.js +127 -0
  14. package/dist/application/EvidenceLedger.js +225 -18
  15. package/dist/application/FilesystemSnapshot.js +124 -0
  16. package/dist/application/LinuxHopper.js +186 -0
  17. package/dist/application/LoopbackReplay.js +195 -37
  18. package/dist/application/ProcessHarness.js +200 -191
  19. package/dist/application/ProcessNormalization.js +44 -0
  20. package/dist/application/ProcessOwnership.js +84 -0
  21. package/dist/application/ProcessSampling.js +284 -0
  22. package/dist/application/RealHopperAssertions.js +105 -0
  23. package/dist/application/ReferenceSourceImport.js +182 -0
  24. package/dist/application/ReferenceSourceImportEntries.js +122 -0
  25. package/dist/application/ReferenceSourceImportPolicy.js +73 -0
  26. package/dist/application/ReferenceSourceImportTypes.js +18 -0
  27. package/dist/application/ReferenceSourceVcsAdapter.js +34 -0
  28. package/dist/application/Setup.js +192 -41
  29. package/dist/application/Uninstall.js +130 -0
  30. package/dist/application/runtime.js +8 -1
  31. package/dist/artifacts/ArtifactPaths.js +51 -0
  32. package/dist/artifacts/ArtifactProvider.js +130 -0
  33. package/dist/artifacts/ArtifactReader.js +9 -0
  34. package/dist/artifacts/AsarArtifactReader.js +62 -0
  35. package/dist/artifacts/DirectoryArtifactReader.js +107 -0
  36. package/dist/artifacts/MachOSliceArtifactReader.js +66 -0
  37. package/dist/artifacts/SafeOutputTree.js +199 -0
  38. package/dist/artifacts/StreamBytes.js +10 -0
  39. package/dist/artifacts/ZipArtifactReader.js +109 -0
  40. package/dist/cli.js +149 -2
  41. package/dist/config.js +35 -1
  42. package/dist/contracts/artifactComparisonExample.js +95 -0
  43. package/dist/contracts/artifactToolContracts.js +84 -0
  44. package/dist/contracts/enhancedInputs.js +4 -0
  45. package/dist/contracts/functionComparisonExample.js +57 -0
  46. package/dist/contracts/investigationExamples.js +118 -0
  47. package/dist/contracts/nativeToolContracts.js +52 -0
  48. package/dist/contracts/processCaptureExample.js +25 -0
  49. package/dist/contracts/toolContractExamples.js +69 -0
  50. package/dist/contracts/toolContracts.js +99 -36
  51. package/dist/contracts/toolOutputSchemas.js +154 -82
  52. package/dist/contracts/unknownContractExamples.js +33 -0
  53. package/dist/domain/artifactComparison.js +273 -0
  54. package/dist/domain/artifactGraph.js +194 -0
  55. package/dist/domain/artifactInventoryEvidence.js +150 -0
  56. package/dist/domain/binaryTarget.js +55 -0
  57. package/dist/domain/bundleComparison.js +266 -0
  58. package/dist/domain/callPath.js +346 -0
  59. package/dist/domain/changedBehavior.js +294 -0
  60. package/dist/domain/errors.js +192 -4
  61. package/dist/domain/evidence.js +41 -10
  62. package/dist/domain/evidenceBundle.js +187 -6
  63. package/dist/domain/functionComparison.js +201 -0
  64. package/dist/domain/functionComparisonNormalization.js +112 -0
  65. package/dist/domain/functionComparisonResults.js +54 -0
  66. package/dist/domain/functionComparisonSchemas.js +82 -0
  67. package/dist/domain/functionDossierEvidence.js +171 -0
  68. package/dist/domain/hopperValues.js +14 -7
  69. package/dist/domain/nativeInspection.js +142 -0
  70. package/dist/domain/processCapture.js +152 -54
  71. package/dist/domain/processComparison.js +106 -0
  72. package/dist/domain/reconstructionUnknowns.js +90 -0
  73. package/dist/domain/reconstructionVerification.js +285 -0
  74. package/dist/domain/reconstructionVerificationSchemas.js +126 -0
  75. package/dist/domain/referenceSourceClassification.js +496 -0
  76. package/dist/domain/referenceSourceGraph.js +376 -0
  77. package/dist/domain/referenceSourceImportParsing.js +235 -0
  78. package/dist/domain/referenceSourcePolicy.js +1 -0
  79. package/dist/domain/residualUnknown.js +239 -0
  80. package/dist/domain/staticRuntimeCorrelation.js +375 -0
  81. package/dist/hopper/BridgeLauncher.js +40 -3
  82. package/dist/hopper/HopperClient.js +14 -5
  83. package/dist/hopper/HopperProvider.js +57 -22
  84. package/dist/identity.js +1 -0
  85. package/dist/main.js +5 -1
  86. package/dist/native/CommandRunner.js +156 -0
  87. package/dist/native/NativeMacOSProvider.js +306 -0
  88. package/dist/native/NativeMachoInspection.js +135 -0
  89. package/dist/native/parsers/codesign.js +55 -0
  90. package/dist/native/parsers/demangle.js +26 -0
  91. package/dist/native/parsers/dyldInfo.js +25 -0
  92. package/dist/native/parsers/lipo.js +67 -0
  93. package/dist/native/parsers/otool.js +193 -0
  94. package/dist/native/parsers/plist.js +23 -0
  95. package/dist/reference/ReferenceSourceReader.js +73 -0
  96. package/dist/reference/ReferenceSourceReaderEntries.js +206 -0
  97. package/dist/reference/ReferenceSourceReaderErrors.js +19 -0
  98. package/dist/reference/ReferenceSourceReaderFile.js +119 -0
  99. package/dist/reference/ReferenceSourceReaderPaths.js +23 -0
  100. package/dist/reference/ReferenceSourceReaderTypes.js +2 -0
  101. package/dist/reference/ReferenceSourceReaderValidate.js +71 -0
  102. package/dist/server/createServer.js +31 -5
  103. package/dist/server/recordDerivedEvidence.js +10 -0
  104. package/dist/server/registerArtifactComparisonTool.js +62 -0
  105. package/dist/server/registerArtifactTools.js +6 -0
  106. package/dist/server/registerBundleComparisonTool.js +47 -0
  107. package/dist/server/registerEnhancedTools.js +64 -12
  108. package/dist/server/registerEvidenceTools.js +36 -0
  109. package/dist/server/registerFunctionComparisonTool.js +68 -0
  110. package/dist/server/registerInvestigationTools.js +224 -0
  111. package/dist/server/registerNativeTools.js +6 -0
  112. package/dist/server/registerOfficialTools.js +47 -14
  113. package/dist/server/registerProcessComparisonTool.js +106 -0
  114. package/dist/server/registerSessionTools.js +179 -70
  115. package/dist/server/sessionEvidence.js +28 -0
  116. package/dist/server/sessionToolPolicies.js +64 -0
  117. package/dist/server/toolRegistrationOptions.js +7 -0
  118. package/dist/server/toolResult.js +8 -5
  119. package/install.sh +198 -0
  120. package/package.json +18 -1
  121. package/scripts/rea.mjs +5 -1
  122. package/skills/rea-analysis/SKILL.md +77 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rea-agents",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Reverse engineer anything from your terminal or coding agent with one CLI and MCP server.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,6 +39,7 @@
39
39
  "packageManager": "npm@11.16.0",
40
40
  "files": [
41
41
  "dist",
42
+ "install.sh",
42
43
  "bridge/hopper_bridge.py",
43
44
  "scripts/rea.mjs",
44
45
  "scripts/rebuild-native.mjs",
@@ -66,9 +67,11 @@
66
67
  "test:watch": "vitest",
67
68
  "typecheck": "tsc --noEmit",
68
69
  "verify:hopper": "npm run build && node scripts/verify-real-hopper.mjs",
70
+ "verify:hopper:linux": "npm run build && node scripts/verify-real-hopper-linux.mjs",
69
71
  "build:fixtures": "node scripts/build-conformance-fixtures.mjs",
70
72
  "verify:fixtures": "npm run build:fixtures && node scripts/verify-conformance-fixtures.mjs",
71
73
  "verify:package": "npm run build && node scripts/verify-package.mjs",
74
+ "verify:published": "node scripts/verify-published-package.mjs",
72
75
  "config:print": "node scripts/print-mcp-config.mjs",
73
76
  "docs:generate": "typedoc",
74
77
  "prepack": "npm run build",
@@ -80,17 +83,31 @@
80
83
  "*.ts": "oxlint --fix"
81
84
  },
82
85
  "dependencies": {
86
+ "@babel/parser": "8.0.4",
87
+ "@babel/types": "8.0.4",
88
+ "@electron/asar": "4.2.0",
83
89
  "@modelcontextprotocol/server": "2.0.0-beta.3",
90
+ "@zip.js/zip.js": "2.8.26",
84
91
  "canonicalize": "3.0.0",
92
+ "diff": "9.0.0",
93
+ "graphology": "0.26.0",
94
+ "graphology-shortest-path": "2.1.0",
95
+ "ignore": "7.0.6",
85
96
  "incur": "0.4.13",
97
+ "isomorphic-git": "1.38.7",
86
98
  "node-pty": "1.1.0",
87
99
  "pino": "9.14.0",
100
+ "plist": "5.0.0",
101
+ "smol-toml": "^1.7.0",
102
+ "write-file-atomic": "8.0.0",
88
103
  "ws": "8.21.0",
89
104
  "zod": "4.4.3"
90
105
  },
91
106
  "devDependencies": {
107
+ "@fast-check/vitest": "0.4.1",
92
108
  "@modelcontextprotocol/client": "2.0.0-beta.3",
93
109
  "@types/node": "24.10.1",
110
+ "@types/write-file-atomic": "4.0.3",
94
111
  "@types/ws": "8.18.1",
95
112
  "@vitest/coverage-v8": "4.1.10",
96
113
  "husky": "9.1.7",
package/scripts/rea.mjs CHANGED
@@ -1,8 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // Route production MCP before importing Incur. Incur owns registration helpers
4
- // such as `mcp add`, while only dist/main.js may serve the 50-tool stdio server.
4
+ // such as `mcp add`, while only dist/main.js may serve the 68-tool stdio server.
5
5
  const args = process.argv.slice(2);
6
+ const { default: packageJson } = await import("../package.json", {
7
+ with: { type: "json" },
8
+ });
9
+ process.env.REA_PACKAGE_VERSION = packageJson.version;
6
10
  const isMcpMode =
7
11
  args[0] === "--mcp" || (args.length === 1 && args[0] === "mcp");
8
12
 
@@ -1,6 +1,9 @@
1
1
  ---
2
2
  name: rea-analysis
3
3
  description: Reverse engineer apps with REA. Explore how features work, then build a version tailored to your project.
4
+ metadata:
5
+ version: "10"
6
+ tool_count: 68
4
7
  ---
5
8
 
6
9
  # REA
@@ -18,8 +21,8 @@ Notes is only a documentation example. Never select an app unless the user names
18
21
  ## Ensure REA is ready
19
22
 
20
23
  1. Run `npx -y rea-agents doctor`.
21
- 2. If setup is needed, explain that REA may install Homebrew and Hopper. Hopper is separate software and requires its own license.
22
- 3. Obtain approval before installing external software, then run `npx -y rea-agents setup --yes`.
24
+ 2. If setup is needed, tell the user REA needs to install its local binary-analysis tools. Do not lead with implementation details or assume the user knows reverse-engineering products.
25
+ 3. Before installing external software, obtain approval and identify what will be installed. If deeper analysis needs Hopper, describe it as REA's local analysis engine and note that it is a separate Mac app with its own license. Then run `npx -y rea-agents setup --yes`.
23
26
  4. If macOS or an installer requests human input, tell the user exactly what needs attention. After they finish, rerun setup and doctor.
24
27
  5. If setup registers a new MCP server, tell the user to restart their coding agent to load all REA tools. Direct CLI commands remain available before restart.
25
28
 
@@ -33,8 +36,80 @@ REA accepts a `.app` bundle directly. Do not expose its internal `Contents/MacOS
33
36
 
34
37
  Briefly tell the user what you will investigate. Open the app with `open_binary`, begin with `binary_overview`, and narrow the investigation around the requested feature. Use decompilation, strings, names, callers, callees, and cross-references as needed.
35
38
 
39
+ For applications, ZIP/APK/IPA packages, or Electron ASAR archives, call
40
+ `inventory_artifact` before extraction. Follow its deterministic occurrence
41
+ pages and cite graph manifest IDs. `extract_artifact` requires explicit user
42
+ approval, an absent absolute output root, and selected occurrence IDs; never
43
+ extract every entry implicitly. Symlinks and encrypted entries are inventory
44
+ facts, not extractable files. Nested containers require a separate deliberate
45
+ inventory step.
46
+
36
47
  Explain conclusions in plain language. Point to the relevant decompiled code, strings, names, and connections so the user can see how the explanation was reached. Do not claim to recover original source code or automatically clone an application.
37
48
 
49
+ Search uses bounded deterministic pages. Prefer literal mode; use regex mode only
50
+ when regex semantics are needed, and continue from `next_offset` while
51
+ `has_more` is true. Treat nullable permissions and explicit unavailable metadata
52
+ as unknown, never as `false`.
53
+
54
+ Every successful analysis result is Evidence v2. Cite evidence IDs and preserve
55
+ limitations and residual unknowns. Process capture is disabled by default,
56
+ requires per-call approval plus operator policy, and uses host networking only
57
+ when the operator explicitly permits it. It is behavioral evidence, not a
58
+ security sandbox.
59
+
60
+ Do not let unanswered questions disappear. Use `record_unknown` only with
61
+ explicit approval, attach supporting and contradicting evidence IDs, and record
62
+ the authority/environment still required. Use `update_unknown` with the current
63
+ `expected_revision`; stale updates must be re-read, not retried blindly. A
64
+ verified resolution needs qualifying observed evidence. Inference, withdrawn,
65
+ and out-of-scope dispositions are never substitutes for observed behavior.
66
+ Set `unknown_registry_approved: true` on `trace_feature` or
67
+ `capture_process_scenario` only when the user approves durable automatic
68
+ recording of their bounded residuals. The same flag on a direct operation
69
+ records typed provider unavailability, and on `compare_process_captures`
70
+ records an observed disagreement as a contradiction.
71
+
72
+ Use `compare_artifacts` with one record or bounded arrays of
73
+ `inventory_artifact` Evidence pages per side. Pages must share one manifest;
74
+ collect all node, occurrence, and edge pages for exhaustive comparison. It
75
+ compares stable occurrence paths, content, metadata, and graph relations,
76
+ cites both evidence sets on every delta, and paginates changes. Incomplete
77
+ inventories are truncated or unknown, never equivalent. Set
78
+ `unknown_registry_approved: true` only with approval to preserve the
79
+ disagreement or missing evidence as a residual unknown.
80
+
81
+ Use `compare_functions` with explicit `analyze_function` Evidence page sets;
82
+ it does not perform fuzzy whole-binary matching. Collect every pseudocode,
83
+ assembly, collection, and CFG page when exhaustive comparison matters.
84
+ Absolute addresses are volatile only in CFG topology; pseudocode constants are
85
+ never stripped. Omitted assembly, truncated scans, unavailable reference kinds,
86
+ and cross-provider text remain unknown rather than equal.
87
+
88
+ Use `compare_bundles` for canonical Evidence v2 bundle membership and
89
+ residual-unknown history changes. Pair cross-version observations explicitly;
90
+ the tool never guesses record identity. One-sided records prove only bundle
91
+ inclusion or omission, not behavioral absence. Use the returned canonical
92
+ bundle digests to anchor paginated reports.
93
+
94
+ Use `find_changed_behavior` to combine existing comparison Evidence. Runtime
95
+ process differences are observed changes; artifact and function differences
96
+ remain static candidates, not causal proof. Supply complete comparison pages.
97
+
98
+ Use `build_call_path` with explicit `analyze_function` Evidence groups from one
99
+ artifact and provider. Select endpoints by exact address. Missing dossiers,
100
+ incomplete callee pages, or a depth frontier make absence unknown; found paths
101
+ remain valid and cite each contributing dossier.
102
+
103
+ Use `correlate_static_and_runtime` only with explicit mappings between exact
104
+ static and runtime comparison findings. A matching pattern is a hypothesis,
105
+ never proof of causality. Declare side alignment; unmapped similarities are not
106
+ correlated.
107
+
108
+ Use `verify_reconstruction` with a finite typed specification and canonical
109
+ Evidence bundle. Pass means all declared claims passed with comparable
110
+ authority, not global implementation equivalence. Missing, limited, active-
111
+ unknown, or incompatible evidence stays unknown; observed differences fail.
112
+
38
113
  ## Build
39
114
 
40
115
  When requested, use normal coding tools to build a version suited to the user's project, stack, interface, and requirements. Keep the implementation tied to what the investigation established, and distinguish observed behavior from assumptions or design choices.