rea-agents 2.1.0 → 2.3.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 (193) hide show
  1. package/README.md +84 -18
  2. package/dist/application/AndroidApplicationService.js +17 -0
  3. package/dist/application/AppleApplicationService.js +17 -0
  4. package/dist/application/ApplicationWorkflowEvidenceResolver.js +162 -0
  5. package/dist/application/BinarySession.js +9 -2
  6. package/dist/application/BinarySessionStatus.js +39 -1
  7. package/dist/application/CapabilityInventory.js +15 -0
  8. package/dist/application/ClientRegistrationStatus.js +11 -4
  9. package/dist/application/CommandShimReplay.js +6 -3
  10. package/dist/application/CompositeProvider.js +5 -2
  11. package/dist/application/DirectAnalysis.js +1 -20
  12. package/dist/application/DirectAnalysisStatus.js +83 -0
  13. package/dist/application/Doctor.js +34 -25
  14. package/dist/application/DoctorDiagnostics.js +1 -4
  15. package/dist/application/DoctorProjection.js +43 -0
  16. package/dist/application/DoctorScope.js +102 -0
  17. package/dist/application/EvidenceReferenceResolver.js +26 -0
  18. package/dist/application/InventoryProjectionEvidence.js +41 -0
  19. package/dist/application/InvestigationProviders.js +12 -0
  20. package/dist/application/JavaScriptApplicationEvidence.js +1 -1
  21. package/dist/application/JavaScriptApplicationEvidenceGraph.js +10 -1
  22. package/dist/application/JavaScriptApplicationService.js +3 -2
  23. package/dist/application/JavaScriptApplicationWorkflowEvidence.js +26 -0
  24. package/dist/application/JavaScriptApplicationWorkflowService.js +49 -1
  25. package/dist/application/JavaScriptArtifactReconstruction.js +7 -0
  26. package/dist/application/JavaScriptModuleRelationships.js +25 -1
  27. package/dist/application/JavaScriptReturnShapeProjection.js +111 -0
  28. package/dist/application/JavaScriptSemanticGraphBuilder.js +294 -0
  29. package/dist/application/JavaScriptSemanticGraphConstruction.js +144 -0
  30. package/dist/application/JavaScriptSemanticGraphEvidence.js +86 -0
  31. package/dist/application/JavaScriptSemanticGraphFlowProjection.js +72 -0
  32. package/dist/application/JavaScriptSemanticGraphProjection.js +33 -0
  33. package/dist/application/JavaScriptSemanticTraceService.js +45 -0
  34. package/dist/application/LoopbackReplay.js +277 -133
  35. package/dist/application/LoopbackReplayRecorder.js +101 -0
  36. package/dist/application/PermissionAuthority.js +7 -3
  37. package/dist/application/ProcessCaptureJournal.js +95 -0
  38. package/dist/application/ProcessCaptureLifecycle.js +24 -13
  39. package/dist/application/ProcessCheckpoints.js +30 -4
  40. package/dist/application/ProcessCli.js +26 -4
  41. package/dist/application/ProcessHarness.js +20 -50
  42. package/dist/application/ProcessNormalization.js +3 -2
  43. package/dist/application/ProcessPairedExperiment.js +72 -0
  44. package/dist/application/ProcessReactiveCoordinator.js +218 -0
  45. package/dist/application/ProcessReactiveEffects.js +133 -0
  46. package/dist/application/ProcessReactiveObservations.js +20 -0
  47. package/dist/application/ProcessSampling.js +2 -0
  48. package/dist/application/SessionProviderRouter.js +7 -6
  49. package/dist/application/Setup.js +14 -13
  50. package/dist/application/SetupClientConfiguration.js +10 -6
  51. package/dist/application/SetupPlan.js +4 -3
  52. package/dist/application/SetupRegistrationEnvironment.js +12 -0
  53. package/dist/application/SetupSkill.js +44 -40
  54. package/dist/application/TerminalRenderer.js +3 -1
  55. package/dist/application/Uninstall.js +7 -1
  56. package/dist/application/Upgrade.js +16 -1
  57. package/dist/browser/CdpEndpoint.js +37 -4
  58. package/dist/catalogIdentity.js +16 -7
  59. package/dist/cli/coreAnalysisCommands.js +34 -2
  60. package/dist/cli/javascriptApplicationAnalysis.js +19 -0
  61. package/dist/cli/setupCommands.js +84 -30
  62. package/dist/cli/utilityCommands.js +10 -2
  63. package/dist/cliApplicationCommands.js +79 -16
  64. package/dist/cliCommandNames.js +3 -0
  65. package/dist/cliElectronCommands.js +23 -33
  66. package/dist/cliObservationOptions.js +1 -1
  67. package/dist/cliOutput.js +56 -0
  68. package/dist/cliProcessCommands.js +32 -1
  69. package/dist/cliSetup.js +55 -29
  70. package/dist/contracts/applicationToolContracts.js +54 -7
  71. package/dist/contracts/applicationWorkflowInputContracts.js +119 -0
  72. package/dist/contracts/electronToolContracts.js +73 -4
  73. package/dist/contracts/javascriptApplicationWorkflowExamples.js +32 -9
  74. package/dist/contracts/managedToolContracts.js +7 -2
  75. package/dist/contracts/processCaptureExample.js +1 -0
  76. package/dist/contracts/replayMachineExample.js +37 -0
  77. package/dist/contracts/sessionStatusContract.js +26 -0
  78. package/dist/contracts/toolContractExamples.js +2 -0
  79. package/dist/contracts/toolContractTypes.js +12 -1
  80. package/dist/contracts/toolContracts.js +8 -11
  81. package/dist/contracts/toolEffects.js +3 -0
  82. package/dist/contracts/toolOutputSchemaGroups.js +53 -9
  83. package/dist/contracts/toolOutputSchemaPrimitives.js +73 -32
  84. package/dist/doctorRuntime.js +41 -0
  85. package/dist/domain/analysisErrorPresentation.js +5 -3
  86. package/dist/domain/analysisErrorProjection.js +7 -1
  87. package/dist/domain/androidApplication.js +206 -0
  88. package/dist/domain/appleApplication.js +221 -0
  89. package/dist/domain/boundedCartesianProjection.js +15 -0
  90. package/dist/domain/changedBehavior.js +5 -4
  91. package/dist/domain/completionLedgerGeneration.js +190 -0
  92. package/dist/domain/errors.js +4 -2
  93. package/dist/domain/evidenceCompletionLedger.js +113 -0
  94. package/dist/domain/hopperStartupFailure.js +9 -0
  95. package/dist/domain/javascriptApplicationAnalysis.js +44 -2
  96. package/dist/domain/javascriptExportShapeComparison.js +145 -0
  97. package/dist/domain/javascriptExportShapeComparisonIdentity.js +11 -0
  98. package/dist/domain/javascriptExportShapeComparisonSchemas.js +277 -0
  99. package/dist/domain/javascriptExportShapeSelection.js +132 -0
  100. package/dist/domain/javascriptExportShapeVariants.js +272 -0
  101. package/dist/domain/javascriptRuntimeReconciliationParsing.js +2 -2
  102. package/dist/domain/javascriptSemanticAnalysis.js +17 -36
  103. package/dist/domain/javascriptSemanticCallResolution.js +129 -0
  104. package/dist/domain/javascriptSemanticCalls.js +269 -0
  105. package/dist/domain/javascriptSemanticGraph.js +356 -0
  106. package/dist/domain/javascriptSemanticGraphSchemas.js +329 -0
  107. package/dist/domain/javascriptSemanticGraphSerialization.js +23 -0
  108. package/dist/domain/javascriptSemanticIr.js +14 -1
  109. package/dist/domain/javascriptSemanticPrimitives.js +36 -0
  110. package/dist/domain/javascriptSemanticProjection.js +36 -4
  111. package/dist/domain/javascriptSemanticProvenance.js +29 -0
  112. package/dist/domain/javascriptSemanticQuery.js +294 -0
  113. package/dist/domain/javascriptSemanticQueryAssessment.js +74 -0
  114. package/dist/domain/javascriptSemanticQueryIdentity.js +86 -0
  115. package/dist/domain/javascriptSemanticQueryRelations.js +15 -0
  116. package/dist/domain/javascriptSemanticQuerySchemas.js +188 -0
  117. package/dist/domain/javascriptSemanticReturns.js +187 -0
  118. package/dist/domain/javascriptSemanticState.js +32 -0
  119. package/dist/domain/javascriptSemanticTraceSchemas.js +14 -0
  120. package/dist/domain/javascriptSemanticValues.js +54 -70
  121. package/dist/domain/processCapture.js +36 -0
  122. package/dist/domain/processCaptureValidation.js +101 -12
  123. package/dist/domain/processComparison.js +96 -24
  124. package/dist/domain/processObservation.js +153 -0
  125. package/dist/domain/processPairedExperiment.js +128 -0
  126. package/dist/domain/processReactiveCheckpointDataflow.js +32 -0
  127. package/dist/domain/processReactiveMatching.js +210 -0
  128. package/dist/domain/processReactiveRuntime.js +109 -0
  129. package/dist/domain/processReactiveScenario.js +361 -0
  130. package/dist/domain/processReactiveScenarioPreflight.js +120 -0
  131. package/dist/domain/processReactiveTransition.js +159 -0
  132. package/dist/domain/processScenario.js +12 -0
  133. package/dist/domain/processTraceComparison.js +43 -0
  134. package/dist/domain/processTraceDimensionProjection.js +50 -0
  135. package/dist/domain/processTraceEvaluation.js +312 -0
  136. package/dist/domain/processTraceSpecification.js +373 -0
  137. package/dist/domain/reconstructionVerification.js +5 -4
  138. package/dist/domain/replayMachine.js +332 -0
  139. package/dist/domain/replayMachineRun.js +216 -0
  140. package/dist/domain/replayMachineRuntime.js +294 -0
  141. package/dist/domain/runtimeIdentification.js +210 -0
  142. package/dist/domain/staticRuntimeCorrelation.js +4 -2
  143. package/dist/evaluation/CodexAgentEval.js +156 -0
  144. package/dist/generatedPackageMetadata.js +2 -2
  145. package/dist/ghidra/GhidraClient.js +13 -2
  146. package/dist/ghidra/GhidraDiagnostics.js +1 -0
  147. package/dist/ghidra/GhidraLauncher.js +7 -3
  148. package/dist/ghidra/GhidraProvider.js +8 -1
  149. package/dist/hopper/BridgeLauncher.js +56 -14
  150. package/dist/hopper/HopperClient.js +23 -10
  151. package/dist/hopper/HopperDiagnostics.js +14 -0
  152. package/dist/hopper/HopperProcessDiagnostic.js +14 -0
  153. package/dist/hopper/HopperProvider.js +8 -1
  154. package/dist/hopper/LinuxPrivateDisplayDiagnostic.js +72 -0
  155. package/dist/hopper/LinuxPrivateDisplayProbe.js +217 -0
  156. package/dist/identity.js +2 -1
  157. package/dist/main/transport.js +2 -0
  158. package/dist/mcpDoctor.js +310 -0
  159. package/dist/process/ProcessOwnership.js +200 -53
  160. package/dist/process/ProviderRunLineage.js +21 -0
  161. package/dist/server/createServer.js +8 -2
  162. package/dist/server/javascriptApplicationResult.js +106 -0
  163. package/dist/server/registerApplicationTools/characterization.js +3 -3
  164. package/dist/server/registerApplicationTools/compareExportShapes.js +37 -0
  165. package/dist/server/registerApplicationTools/compareVersions.js +12 -6
  166. package/dist/server/registerApplicationTools/controlledReplay.js +2 -2
  167. package/dist/server/registerApplicationTools/coverage.js +3 -3
  168. package/dist/server/registerApplicationTools/helpers.js +37 -25
  169. package/dist/server/registerApplicationTools/traceFeature.js +9 -5
  170. package/dist/server/registerApplicationTools/traceSemantics.js +30 -0
  171. package/dist/server/registerApplicationTools.js +4 -0
  172. package/dist/server/registerElectronTools.js +19 -5
  173. package/dist/server/registerEvidenceResources.js +7 -1
  174. package/dist/server/registerJavaScriptApplicationGraphResource.js +69 -0
  175. package/dist/server/registerManagedTools.js +18 -1
  176. package/dist/server/registerProcessComparisonTool.js +17 -7
  177. package/dist/server/registerReplayMachineTool.js +20 -0
  178. package/dist/server/registerSessionStatusTool.js +95 -25
  179. package/dist/server/registerSessionTools.js +12 -7
  180. package/dist/server/sessionAvailabilityPolicy.js +2 -1
  181. package/dist/server/toolResult.js +10 -4
  182. package/dist/serverIdentity.js +19 -0
  183. package/package.json +62 -29
  184. package/scripts/hopper-demo-x11.py +459 -61
  185. package/scripts/prepack.mjs +55 -0
  186. package/scripts/prepare.mjs +28 -0
  187. package/scripts/rea.mjs +26 -5
  188. package/skills/reverse-engineer-anything/SKILL.md +69 -228
  189. package/skills/reverse-engineer-anything/references/controlled-replay.md +12 -0
  190. package/skills/reverse-engineer-anything/references/evidence-workflows.md +33 -0
  191. package/skills/reverse-engineer-anything/references/javascript-applications.md +35 -0
  192. package/skills/reverse-engineer-anything/references/native-and-artifacts.md +36 -0
  193. package/skills/reverse-engineer-anything/references/runtime-observation.md +24 -0
@@ -0,0 +1,28 @@
1
+ import { access } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
6
+
7
+ const sourceHuskyIsAvailable = async () => {
8
+ try {
9
+ await access(join(root, "src"));
10
+ await access(join(root, "node_modules", "husky", "index.js"));
11
+ return true;
12
+ } catch (cause) {
13
+ if (
14
+ typeof cause === "object" &&
15
+ cause !== null &&
16
+ "code" in cause &&
17
+ cause.code === "ENOENT"
18
+ )
19
+ return false;
20
+ throw cause;
21
+ }
22
+ };
23
+
24
+ if (process.env.HUSKY !== "0" && (await sourceHuskyIsAvailable())) {
25
+ const { default: installHusky } = await import("husky");
26
+ const message = installHusky();
27
+ if (message.length > 0) process.stdout.write(`${message}\n`);
28
+ }
package/scripts/rea.mjs CHANGED
@@ -13,10 +13,13 @@ const { default: packageJson } = await import("../package.json", {
13
13
  process.env.REA_PACKAGE_VERSION = packageJson.version;
14
14
  const isMcpMode =
15
15
  args.length === 1 && (args[0] === "--mcp" || args[0] === "mcp");
16
+ const isMcpDoctorMode = args[0] === "mcp" && args[1] === "doctor";
16
17
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
17
18
  const runtimeFiles = isMcpMode
18
19
  ? ["dist/main.js"]
19
- : ["dist/cli.js", "dist/cliOutput.js"];
20
+ : isMcpDoctorMode
21
+ ? ["dist/main.js", "dist/mcpDoctor.js"]
22
+ : ["dist/cli.js", "dist/cliOutput.js"];
20
23
 
21
24
  if (!(await compiledRuntimeExists(runtimeFiles))) {
22
25
  process.stderr.write(
@@ -26,12 +29,30 @@ if (!(await compiledRuntimeExists(runtimeFiles))) {
26
29
  } else if (isMcpMode) {
27
30
  const { runEntrypoint } = await import("../dist/main.js");
28
31
  await runEntrypoint();
32
+ } else if (isMcpDoctorMode) {
33
+ const { runProductionMcpDoctorCli } = await import("../dist/mcpDoctor.js");
34
+ const result = await runProductionMcpDoctorCli(args.slice(2), {
35
+ dispatcherPath: fileURLToPath(import.meta.url),
36
+ packageRoot,
37
+ });
38
+ process.stdout.write(result.output);
39
+ process.exitCode = result.exitCode;
29
40
  } else {
30
41
  const { createCli } = await import("../dist/cli.js");
31
- const { sanitizeCliOutput } = await import("../dist/cliOutput.js");
32
- await createCli().serve(args, {
33
- stdout: (output) => process.stdout.write(sanitizeCliOutput(output)),
34
- });
42
+ const {
43
+ renderCliOutputArgumentError,
44
+ sanitizeCliOutput,
45
+ validateCliOutputArguments,
46
+ } = await import("../dist/cliOutput.js");
47
+ const outputArguments = validateCliOutputArguments(args);
48
+ if (!outputArguments.ok) {
49
+ process.stdout.write(renderCliOutputArgumentError(outputArguments));
50
+ process.exitCode = 1;
51
+ } else {
52
+ await createCli().serve(args, {
53
+ stdout: (output) => process.stdout.write(sanitizeCliOutput(output)),
54
+ });
55
+ }
35
56
  }
36
57
 
37
58
  async function compiledRuntimeExists(paths) {
@@ -1,235 +1,76 @@
1
1
  ---
2
2
  name: reverse-engineer-anything
3
- description: Reverse engineer native, Electron/JavaScript, and web application artifacts or runtimes with REA. Connect static artifacts to passive runtime evidence, explain how features work, and build a version tailored to the user's project. Skip REA setup for ordinary source-repository architecture analysis.
3
+ description: Reverse engineer native, managed, Electron/JavaScript, packaged, and browser applications with REA. Use shipped-artifact or approved runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.
4
4
  metadata:
5
- version: "22"
6
- tool_count: 95
7
- catalog_digest: "e0c341749f488a869b62ab9b48c9236c60c91317ac60c8427f12a830cb900ae0"
5
+ version: "23"
6
+ tool_count: 98
7
+ catalog_digest: "71de8a7174176823fd82c2666130233b5a1b4a1613583270d268774775b410bc"
8
8
  ---
9
9
 
10
10
  # REA
11
11
 
12
- Use REA when the user wants to understand how an app or feature works, compare app versions, decompile code, or build a similar feature.
13
-
14
- For a website already open in a user-owned Chrome-family browser, start with
15
- `list_browser_targets` and `inspect_web_page` instead of opening a binary. Use
16
- `analyze_web_bundle`, `observe_web_session`, `discover_webmcp_tools`, capture
17
- comparison, or screenshot tools only for the corresponding investigation. Ask
18
- the user to approve the exact page origins and loopback CDP endpoint before the
19
- first call. Browser observation is disabled unless the operator configured
20
- `REA_BROWSER_OBSERVE_ENABLED`, `REA_BROWSER_CDP_ENDPOINTS_JSON`, and
21
- `REA_BROWSER_ALLOWED_ORIGINS_JSON` before starting REA.
22
-
23
- Browser inspection is passive. Never claim that it clicked, navigated,
24
- evaluated page JavaScript, captured prior activity, or contained the page's
25
- network. Query values, credentials, cookies, authorization headers, storage
26
- values, and raw WebSocket or JSON values are deliberately absent. Accessibility
27
- text, bounded redacted console primitives, value-free JSON/WebSocket shapes,
28
- script sources, storage key names, source-map fetches, and screenshot pixels
29
- each require their documented independent opt-in or approval. Treat truncation,
30
- policy filtering, and attach-window coverage as explicit limitations, and cite
31
- the returned Evidence v2 IDs. WebMCP declarations are page-declared untrusted;
32
- REA inventories them but never invokes them.
33
-
34
- Electron `file://` pages use `list_electron_targets` and
35
- `inspect_electron_page` with a separate loopback endpoint and canonical
36
- filesystem-root authority. Never claim that Electron inspection invoked IPC,
37
- evaluated renderer JavaScript, navigated, or escaped an approved root.
38
-
39
- For an operator-supplied ASAR or extracted JavaScript/Electron application, use
40
- `analyze_javascript_application` after the operator configures its canonical
41
- root in `REA_INVESTIGATION_INPUT_ROOTS_JSON`; every call still requires
42
- `approved: true`. Source-map contents require the independent
43
- `source_map_read_approved` flag. Treat BrowserWindow preferences, preload and
44
- contextBridge surfaces, IPC registrations, utility processes, and native
45
- binding requests as static syntax observations. Treat only a unique exact
46
- literal IPC channel match as an inferred pairing; keep dynamic and ambiguous
47
- channels unresolved. A requested `.node` member is not a verified binary export.
48
- Never claim that this workflow executed application code or observed runtime
49
- registration, reachability, defaults, or policy enforcement.
50
-
51
- When static application Evidence and passive `inspect_web_page` or
52
- `inspect_electron_page` Evidence already exist, use
53
- `reconcile_javascript_runtime` to map capture-scoped targets, frames, scripts,
54
- and workers onto the static graph. Supply exactly one `application` layer and
55
- add separately analyzed `cache` or `assets` layers only when relevant. Use
56
- explicit file-root or URL-prefix mappings for relocated runtime paths; mappings
57
- are inference inputs and never broaden CDP or filesystem authority. Prefer
58
- approved captured-source digest identity, report path/digest disagreement as a
59
- mismatch, preserve ambiguity, and never call a module executed merely because
60
- its containing bundle was observed. Keep source-map authority separate. This
61
- tool maps JavaScript graph entities; `correlate_static_and_runtime` remains the
62
- separate workflow for explicit cross-version comparison hypotheses.
63
-
64
- Use `trace_application_feature` on authenticated static or reconciled
65
- application Evidence to follow one literal node ID, route, string, API, IPC
66
- channel, module, or native export. Choose an explicit direction and bounds.
67
- Preserve every graph authority in the returned subgraph. A native handoff means
68
- only that the exact artifact digest and requested export frontier are known;
69
- link Ghidra or Hopper Evidence only on exact subject digest, and never claim the
70
- workflow opened a provider or verified a requested export by itself.
71
-
72
- Use `compare_application_versions` after analyzing both versions independently.
73
- Accept only its unique digest, source-map, structural-fingerprint, or non-module
74
- semantic matches. Never use module ordinals or minified names as persistent
75
- identity, and never promote an ambiguous candidate to a match. Report added or
76
- removed only when opposite-side coverage is complete; otherwise report unknown.
77
- Use `unknown_registry_approved: true` only after approval to retain unresolved
78
- version matches. For local operator-provided artifacts, the packaged
79
- `verify:application-workflows` command reports digests and coverage without
80
- printing source text.
81
-
82
- Use `run_controlled_replay` only for operator-selected extracted JavaScript
83
- modules when the separate `javascript_replay` policy is enabled. First call
84
- `mode: plan`; review the exact module, stub, runtime, sandbox, case, limit, and
85
- policy commitments. Execute only with `approved: true` and that exact
86
- `plan_digest`. Prefer explicit cases plus the parser, sanitizer, or clipboard
87
- boundary generator. A right manifest produces a derived differential result.
88
- Treat return values, exceptions, denials, limits, and crashes as observations
89
- of the isolated experiment with `controlled-replay` authority—not facts about
90
- the real application. Never substitute passive browser/Electron permission,
91
- Process Capture, or an in-process `vm` run. Reproducer export requires its own
92
- literal approval and `evidence_write` authority after sandbox cleanup.
93
-
94
- ## Understand the request
95
-
96
- Identify the app and what the user wants to understand or build. Do not ask for information they already provided.
97
-
98
- First decide whether REA evidence is needed. When the complete source repository
99
- is available and the request is ordinary source-level architecture, code-flow,
100
- or implementation analysis, use normal repository tools and skip REA readiness,
101
- setup, and binary-provider commands. Use REA only when the request needs evidence
102
- from a binary, package, built artifact, decompilation, passive application
103
- runtime, controlled replay, or comparison against behavior not established by
104
- the available source. If the source is available but the requested claim still
105
- depends on built or runtime behavior, explain that distinction and continue with
106
- the relevant REA workflow.
107
-
108
- If the app is missing, ask which app they want to reverse engineer. If the app is known but the goal is unclear, ask what they want to understand or build, and offer to start with an overview. Never require the user to supply a program path, address, architecture, or reverse-engineering terminology.
109
-
110
- Notes is only a documentation example. Never select an app unless the user names it or confirms it.
111
-
112
- ## Ensure REA is ready
113
-
114
- Run this section only after the request-routing decision establishes that REA
115
- evidence is needed.
116
-
117
- 1. Run `npx -y rea-agents@latest doctor`.
118
- 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.
119
- 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@latest setup --yes`.
120
- 4. If macOS or an installer requests human input, tell the user exactly what needs attention. After they finish, rerun setup and doctor.
121
- 5. If setup registers a new MCP server, tell the user to restart their agent to load all REA tools. Direct CLI commands remain available before restart.
122
-
123
- ## Locate the app
124
-
125
- Accept a human-readable app name. Search macOS application locations and system metadata. If one clear match is found, continue without asking for a path. If several apps match, show their names and locations and ask which one the user means. If none match, ask where the app is installed.
126
-
127
- REA accepts a `.app` bundle directly. Do not expose its internal `Contents/MacOS` path unless it helps explain an error.
128
-
129
- ## Investigate
130
-
131
- 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.
132
-
133
- For applications, ZIP/APK/IPA packages, Electron ASAR archives, or DMGs, call
134
- `inventory_artifact` before extraction. Follow its deterministic occurrence
135
- pages and cite graph manifest IDs. `extract_artifact` requires explicit user
136
- approval, an absent absolute output root, and selected occurrence IDs; never
137
- extract every entry implicitly. Symlinks and encrypted entries are inventory
138
- facts, not extractable files. Inventory traverses discovered ASARs within the
139
- same graph and shared limits, including ASARs inside an approved mounted DMG.
140
-
141
- Native DMG traversal is macOS-only, read-only, and disabled by default. Use it
142
- only when the user approves that inventory call with
143
- `native_mount_approved: true` and the operator has separately enabled
144
- `REA_ARTIFACT_NATIVE_MOUNT_ENABLED=true`. Without both gates, retain the DMG
145
- root-hash-only result. Never imply that approval changes extraction authority.
146
-
147
- 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.
148
-
149
- Search uses bounded deterministic pages. Prefer literal mode; use regex mode only
150
- when regex semantics are needed, and continue from `next_offset` while
151
- `has_more` is true. Treat nullable permissions and explicit unavailable metadata
152
- as unknown, never as `false`.
153
-
154
- Every successful analysis result is Evidence v2. Cite evidence IDs and preserve
155
- limitations and residual unknowns. Process capture is disabled by default,
156
- requires per-call approval plus operator policy, and uses host networking only
157
- when the operator explicitly permits it. It is behavioral evidence, not a
158
- security sandbox.
159
-
160
- `capture_process_scenario` produces Process Capture v4 only. If a boundary
161
- reports Process Capture v3, tell the user or calling agent to rerun the original
162
- scenario; v3 cannot be upgraded because it lacks required manifest and
163
- settlement evidence. Treat the v4 manifest commitments as compatibility and
164
- provenance evidence, and distinguish root exit from descendant settlement.
165
- When comparing stored captures, set `max_capture_age_ms` when the task requires
166
- fresh behavioral evidence. Different scenario and executable digests are
167
- allowed, but schema and comparison-contract digests must be compatible.
168
-
169
- Do not let unanswered questions disappear. Use `record_unknown` only with
170
- explicit approval, attach supporting and contradicting evidence IDs, and record
171
- the authority/environment still required. Use `update_unknown` with the current
172
- `expected_revision`; stale updates must be re-read, not retried blindly. A
173
- verified resolution needs qualifying observed evidence. Inference, withdrawn,
174
- and out-of-scope dispositions are never substitutes for observed behavior.
175
- Set `unknown_registry_approved: true` on `trace_feature` or
176
- `capture_process_scenario` only when the user approves durable automatic
177
- recording of their bounded residuals. The same flag on a direct operation
178
- records typed provider unavailability, and on `compare_process_captures`
179
- records an observed disagreement as a contradiction.
180
-
181
- Use `compare_artifacts` with one record or bounded arrays of
182
- `inventory_artifact` Evidence pages per side. Pages must share one manifest;
183
- collect all node, occurrence, and edge pages for exhaustive comparison. It
184
- compares stable occurrence paths, content, metadata, and graph relations,
185
- cites both evidence sets on every delta, and paginates changes. Incomplete
186
- inventories are truncated or unknown, never equivalent. Set
187
- `unknown_registry_approved: true` only with approval to preserve the
188
- disagreement or missing evidence as a residual unknown.
189
-
190
- Use `compare_functions` with explicit `analyze_function` Evidence page sets;
191
- it does not perform fuzzy whole-binary matching. Collect every pseudocode,
192
- assembly, collection, and CFG page when exhaustive comparison matters.
193
- Absolute addresses are volatile only in CFG topology; pseudocode constants are
194
- never stripped. Omitted assembly, truncated scans, unavailable reference kinds,
195
- and cross-provider text remain unknown rather than equal.
196
-
197
- Use `compare_bundles` for canonical Evidence v2 bundle membership and
198
- residual-unknown history changes. Pair cross-version observations explicitly;
199
- the tool never guesses record identity. One-sided records prove only bundle
200
- inclusion or omission, not behavioral absence. Use the returned canonical
201
- bundle digests to anchor paginated reports.
202
-
203
- Use `find_changed_behavior` to combine existing comparison Evidence. Runtime
204
- process differences are observed changes; artifact and function differences
205
- remain static candidates, not causal proof. Supply complete comparison pages.
206
- For an automatic two-version artifact investigation, use its
207
- `investigation_run` mode with explicit write approval and a workspace beneath
208
- `REA_EVIDENCE_ROOTS_JSON`. It checkpoints inventory, comparison, and report
209
- Evidence in monotonic CAS-linked revisions. Repeating the same content and
210
- budgets resumes or reuses the run. This automatic mode does not execute either
211
- version or perform fuzzy function matching, so its behavior status remains
212
- unknown without separate controlled runtime Evidence.
213
-
214
- Use `build_call_path` with explicit `analyze_function` Evidence groups from one
215
- artifact and provider. Select endpoints by exact address. Missing dossiers,
216
- incomplete callee pages, or a depth frontier make absence unknown; found paths
217
- remain valid and cite each contributing dossier.
218
-
219
- Use `correlate_static_and_runtime` only with explicit mappings between exact
220
- static and runtime comparison findings. A matching pattern is a hypothesis,
221
- never proof of causality. Declare side alignment; unmapped similarities are not
222
- correlated.
223
-
224
- Use `verify_reconstruction` with a finite typed specification and canonical
225
- Evidence bundle. Pass means all declared claims passed with comparable
226
- authority, not global implementation equivalence. Missing, limited, active-
227
- unknown, or incompatible evidence stays unknown; observed differences fail.
228
-
229
- ## Build
230
-
231
- 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.
232
-
233
- ## Human input and cleanup
234
-
235
- Hopper or macOS may show a window that needs human input. Tell the user what appeared and ask them to handle it; do not guess or take over unrelated UI. Call `close_binary` when the investigation is complete.
12
+ Use REA when a claim depends on a shipped binary or package, decompilation,
13
+ passive application runtime evidence, controlled replay, or comparison with
14
+ behavior not established by available source. For ordinary analysis of a
15
+ complete source repository, use normal repository tools and do not run REA
16
+ readiness or provider commands.
17
+
18
+ ## Route the target first
19
+
20
+ Choose the first tool from the target the user supplied. Do not call
21
+ `open_binary` unless the target is native or an analysis database.
22
+
23
+ - ASAR or extracted JavaScript/Electron tree:
24
+ `analyze_javascript_application`.
25
+ - Archive, application package, ZIP/APK/IPA, or DMG: `inventory_artifact`.
26
+ - Managed PE/CLI assembly: `inspect_managed_artifact`.
27
+ - User-owned browser page already open: `list_browser_targets`.
28
+ - User-owned Electron runtime already open: `list_electron_targets`.
29
+ - Native executable, library, or analysis database: `open_binary`, then
30
+ `binary_overview`.
31
+
32
+ If the app is missing, ask which app to inspect. Resolve a human-readable app
33
+ name to one clear installed artifact when possible; ask only when matches are
34
+ ambiguous. Never choose an example app on the user's behalf.
35
+
36
+ ## Work summary-first
37
+
38
+ Start with the default summary projection. Do not repeat an identical tool call.
39
+ Do not fetch full Evidence or a full application graph unless a specific claim
40
+ requires detail absent from the summary. For JavaScript graphs, follow the
41
+ paged resource URIs returned by the summary and fetch only the relevant page.
42
+
43
+ Every conclusion must distinguish observations, inferences, and unknowns. Cite
44
+ Evidence IDs, preserve limitations and incomplete coverage, and never imply
45
+ that static analysis observed execution. Ask for approval only where a tool or
46
+ policy requires it; approval never broadens a different authority boundary.
47
+
48
+ ## Read only the relevant guide
49
+
50
+ - Native binaries, managed assemblies, archives, and extraction:
51
+ [references/native-and-artifacts.md](references/native-and-artifacts.md)
52
+ - ASARs, extracted JavaScript, feature tracing, and version comparison:
53
+ [references/javascript-applications.md](references/javascript-applications.md)
54
+ - Passive browser/Electron observation and static/runtime reconciliation:
55
+ [references/runtime-observation.md](references/runtime-observation.md)
56
+ - Evidence paging, comparisons, residual unknowns, and verification:
57
+ [references/evidence-workflows.md](references/evidence-workflows.md)
58
+ - Controlled JavaScript replay:
59
+ [references/controlled-replay.md](references/controlled-replay.md)
60
+
61
+ ## Readiness and setup
62
+
63
+ If REA tools are available, use them directly; do not run `doctor` on every
64
+ task. If the MCP server is unavailable or registration is reported stale, run
65
+ `npx -y rea-agents@latest doctor`. Propose
66
+ `npx -y rea-agents@latest setup` only when doctor identifies an alignment or
67
+ provider problem. Show the exact plan and obtain approval before setup writes
68
+ configuration or installs Hopper. Restart the agent after MCP registration
69
+ changes; direct CLI commands remain available immediately.
70
+
71
+ ## Finish the task
72
+
73
+ Explain findings in plain language and tie them to returned evidence. When the
74
+ user asks to build something, use normal coding tools and separate observed
75
+ behavior from design choices. Close an opened native session with
76
+ `close_binary` when the investigation is complete.
@@ -0,0 +1,12 @@
1
+ # Controlled JavaScript replay
2
+
3
+ Use `run_controlled_replay` only for operator-selected extracted modules when
4
+ the separate replay policy is enabled. Call `mode: plan` first. Review the exact
5
+ module, stub, runtime, sandbox, case, limits, and policy commitments. Execute
6
+ only with `approved: true` and that exact plan digest.
7
+
8
+ Treat return values, exceptions, denials, limits, and crashes as observations of
9
+ the isolated experiment with controlled-replay authority, not facts about the
10
+ real application. Never substitute browser/Electron permission, process
11
+ capture, or an in-process `vm` run. Reproducer export requires separate literal
12
+ approval and evidence-write authority after sandbox cleanup.
@@ -0,0 +1,33 @@
1
+ # Evidence, comparison, and verification workflows
2
+
3
+ REA results are Evidence v2. Cite evidence IDs and preserve authority,
4
+ limitations, coverage, and residual unknowns. Read the smallest deterministic
5
+ page that answers the question. Continue from a returned next offset while
6
+ `has_more` is true only when exhaustive coverage matters.
7
+
8
+ Use `record_unknown` only with explicit approval and name the authority or
9
+ environment still required. Supply supporting and contradicting evidence IDs.
10
+ Use `update_unknown` with the current revision; reread after a stale revision
11
+ instead of retrying blindly. Only qualifying observed evidence can verify a
12
+ resolution.
13
+
14
+ Use comparisons with complete, compatible page sets when claiming equivalence
15
+ or absence:
16
+
17
+ - `compare_artifacts` compares inventory pages by occurrence path, content,
18
+ metadata, and graph relations.
19
+ - `compare_functions` compares explicit function Evidence, not fuzzy
20
+ whole-binary matches.
21
+ - `compare_bundles` compares canonical bundle membership and unknown history.
22
+ - `find_changed_behavior` combines existing comparisons; static differences
23
+ remain candidates, not causal proof.
24
+ - `build_call_path` needs explicit function dossiers from one artifact/provider;
25
+ an incomplete frontier makes absence unknown.
26
+ - `correlate_static_and_runtime` uses explicit mappings; matching patterns are
27
+ hypotheses, not causality.
28
+ - `verify_reconstruction` evaluates a finite typed specification. A pass covers
29
+ only declared comparable claims, not global equivalence.
30
+
31
+ Process captures are opt-in behavioral evidence, not a security sandbox. V3
32
+ captures cannot be upgraded to V4; rerun the original scenario. Distinguish root
33
+ exit from descendant settlement and require freshness when the task needs it.
@@ -0,0 +1,35 @@
1
+ # JavaScript and Electron application artifacts
2
+
3
+ Use `analyze_javascript_application` for an operator-supplied ASAR or extracted
4
+ tree beneath an approved investigation root. Every call requires `approved:
5
+ true`; source-map contents require separate approval. Keep the default summary.
6
+ Use its counts, roots, node kinds, top findings, coverage, unknowns, and graph
7
+ page URIs before requesting more data.
8
+
9
+ BrowserWindow preferences, preload and contextBridge surfaces, IPC
10
+ registrations, utility processes, and native binding requests are static syntax
11
+ observations. Only a unique exact literal IPC channel match supports an inferred
12
+ pairing. Dynamic or ambiguous channels remain unresolved. A requested `.node`
13
+ member is not a verified native export. Never claim runtime reachability,
14
+ registration, defaults, or policy enforcement from static analysis.
15
+
16
+ Use `trace_application_feature` on existing application Evidence for one
17
+ literal node ID, route, string, API, IPC channel, module, or native export.
18
+ Choose a direction and finite bounds. Link Hopper or Ghidra Evidence only when
19
+ the exact artifact digest matches.
20
+
21
+ For version comparison, analyze each version once, then call
22
+ `compare_application_versions`. Accept only its digest, source-map, structural
23
+ fingerprint, or non-module semantic matches. Module ordinals and minified names
24
+ are not persistent identity. Report added or removed only with complete
25
+ opposite-side coverage; otherwise report unknown.
26
+
27
+ When the question asks how one exact exported callable's returned object shape
28
+ changed, analyze each version once and then call
29
+ `compare_javascript_export_shapes` with explicit module paths and export names.
30
+ Use the Evidence IDs returned by the two analysis calls. Accept variant pairing
31
+ only through the tool's unique exact literal discriminant. Cite the comparison
32
+ Evidence and report JSON Pointer changes; dynamic values, ambiguous variants,
33
+ and incomplete parent-property coverage stay unknown. This is static inference,
34
+ not runtime behavior. Use `run_controlled_replay` separately only when the user
35
+ needs approved runtime semantics.
@@ -0,0 +1,36 @@
1
+ # Native, managed, and packaged artifacts
2
+
3
+ ## Native targets
4
+
5
+ After `open_binary`, use `binary_overview` once and narrow around the requested
6
+ feature. Prefer literal search, names, decompilation, callers, callees, and
7
+ cross-references. Addresses and recovered pseudocode are analysis observations,
8
+ not original source. Provider unavailability and unsupported metadata remain
9
+ unknown rather than false.
10
+
11
+ Use `binary_session` with its default summary to check the open target, selected
12
+ provider, alignment, and recommended remediation. Request the capabilities view
13
+ with a family filter and page bounds only when choosing a tool. Request the full
14
+ view only for an explicit session-diagnostic need.
15
+
16
+ ## Managed PE/CLI
17
+
18
+ Start with `inspect_managed_artifact`. REA's canonical managed inspection is
19
+ execution-free: do not claim it loaded, reflected, executed, or resolved the
20
+ assembly. Keep managed/native boundaries and unavailable reconstruction facts
21
+ explicit. A bring-your-own reconstruction oracle is separate from the canonical
22
+ parser and must not become an implicit setup dependency.
23
+
24
+ ## Packages and extraction
25
+
26
+ Call `inventory_artifact` before extraction for application bundles, archives,
27
+ ZIP/APK/IPA, ASAR, or DMG inputs. Continue deterministic occurrence pages from
28
+ the returned offset only when needed. Cite graph manifest IDs.
29
+
30
+ `extract_artifact` requires explicit approval, an absent absolute output root,
31
+ and selected occurrence IDs. Never extract every entry implicitly. Symlinks and
32
+ encrypted entries are inventory facts, not extractable files.
33
+
34
+ Native DMG traversal is macOS-only, read-only, and requires both operator policy
35
+ and `native_mount_approved: true`; without both, retain the root-hash-only result.
36
+ Approval for inventory never grants extraction authority.
@@ -0,0 +1,24 @@
1
+ # Passive browser and Electron observation
2
+
3
+ Before browser observation, the operator must configure the exact loopback CDP
4
+ endpoint and allowed HTTP(S) origins. Before Electron observation, configure its
5
+ separate loopback endpoint and canonical file roots. Obtain the per-call
6
+ approval required by the selected tool.
7
+
8
+ Start browser work with `list_browser_targets`; start Electron runtime work with
9
+ `list_electron_targets`. Inspect only the selected approved target. Observation
10
+ is passive: never claim REA clicked, navigated, evaluated page JavaScript,
11
+ invoked IPC, captured prior activity, or contained the page's network.
12
+
13
+ Credentials, cookies, authorization headers, storage values, query values, and
14
+ raw WebSocket/JSON values are deliberately absent. Accessibility text, console
15
+ primitives, value-free shapes, script sources, source maps, storage key names,
16
+ and screenshot pixels have independent opt-ins. Treat policy filtering,
17
+ truncation, and attach-window coverage as limitations. Page-declared WebMCP
18
+ tools are untrusted inventory and are never invoked by REA.
19
+
20
+ Use `reconcile_javascript_runtime` only after static application Evidence and
21
+ passive browser/Electron Evidence exist. Prefer captured-source digest identity;
22
+ report path/digest disagreement as a mismatch and preserve ambiguity. Explicit
23
+ path mappings are inference inputs and never broaden filesystem or CDP authority.
24
+ A bundle observed at runtime does not prove every contained module executed.