rea-agents 1.1.0 → 1.2.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.
- package/README.md +21 -2
- package/dist/application/ArtifactInventory.js +80 -44
- package/dist/application/CommandShimReplay.js +136 -0
- package/dist/application/EvidenceBundleFiles.js +9 -1
- package/dist/application/ProcessCaptureAuthority.js +25 -0
- package/dist/application/ProcessCaptureCapability.js +23 -0
- package/dist/application/ProcessCaptureError.js +5 -0
- package/dist/application/ProcessCaptureLifecycle.js +269 -0
- package/dist/application/ProcessCheckpoints.js +129 -0
- package/dist/application/ProcessCli.js +61 -0
- package/dist/application/ProcessEvidence.js +38 -0
- package/dist/application/ProcessHarness.js +252 -272
- package/dist/application/ProcessNormalization.js +10 -1
- package/dist/application/ProcessOwnership.js +39 -1
- package/dist/application/ProcessSampling.js +39 -23
- package/dist/application/Setup.js +51 -76
- package/dist/application/SetupSkill.js +44 -0
- package/dist/application/TerminalRenderer.js +92 -0
- package/dist/application/runtime.js +1 -1
- package/dist/artifacts/ArtifactProvider.js +18 -6
- package/dist/artifacts/ArtifactReader.js +3 -1
- package/dist/artifacts/AsarArtifactReader.js +8 -1
- package/dist/artifacts/DirectoryArtifactReader.js +1 -0
- package/dist/artifacts/MachOSliceArtifactReader.js +1 -0
- package/dist/artifacts/NativeDmgArtifactReader.js +151 -0
- package/dist/artifacts/ZipArtifactReader.js +1 -0
- package/dist/cli.js +29 -24
- package/dist/cliProcessCommands.js +19 -0
- package/dist/config.js +2 -0
- package/dist/contracts/artifactToolContracts.js +1 -0
- package/dist/contracts/investigationExamples.js +3 -3
- package/dist/contracts/processCaptureExample.js +50 -7
- package/dist/contracts/toolContracts.js +3 -2
- package/dist/domain/changedBehavior.js +2 -2
- package/dist/domain/errors.js +11 -3
- package/dist/domain/processCapture.js +99 -293
- package/dist/domain/processCaptureValidation.js +124 -0
- package/dist/domain/processComparison.js +176 -32
- package/dist/domain/processScenario.js +370 -0
- package/dist/domain/reconstructionVerification.js +3 -3
- package/dist/domain/staticRuntimeCorrelation.js +3 -2
- package/dist/identity.js +1 -0
- package/dist/server/registerProcessComparisonTool.js +28 -8
- package/dist/server/registerSessionTools.js +3 -25
- package/dist/server/sessionToolPolicies.js +1 -6
- package/package.json +5 -1
- package/scripts/prepare-node-pty.mjs +35 -0
- package/skills/rea-analysis/SKILL.md +19 -4
|
@@ -4,14 +4,14 @@ import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
|
4
4
|
import { createEvidence } from "../domain/evidence.js";
|
|
5
5
|
import { EvidenceIntegrityError } from "../domain/errors.js";
|
|
6
6
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
7
|
-
import { compareProcessCaptures, processCaptureSchema, } from "../domain/processCapture.js";
|
|
7
|
+
import { compareProcessCaptures, processCaptureSchema, parseProcessCapture, } from "../domain/processCapture.js";
|
|
8
8
|
import { recordDerivedEvidence } from "./recordDerivedEvidence.js";
|
|
9
9
|
import { err } from "../domain/result.js";
|
|
10
10
|
import { PROCESS_PROVIDER } from "./sessionToolPolicies.js";
|
|
11
11
|
import { toCallToolResult } from "./toolResult.js";
|
|
12
12
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
13
13
|
/** Register deterministic process-capture comparison and contradiction tracking. */
|
|
14
|
-
export const registerProcessComparisonTool = (server, session, contract) => {
|
|
14
|
+
export const registerProcessComparisonTool = (server, session, contract, now = Date.now) => {
|
|
15
15
|
server.registerTool(contract.name, toolRegistrationOptions(contract), (input) => {
|
|
16
16
|
const parsed = z
|
|
17
17
|
.object({
|
|
@@ -19,15 +19,29 @@ export const registerProcessComparisonTool = (server, session, contract) => {
|
|
|
19
19
|
left: processCaptureSchema,
|
|
20
20
|
right_evidence_id: z.string(),
|
|
21
21
|
right: processCaptureSchema,
|
|
22
|
+
max_capture_age_ms: z.number().int().nonnegative().optional(),
|
|
22
23
|
unknown_registry_approved: z.literal(true).optional(),
|
|
23
24
|
})
|
|
24
25
|
.parse(input);
|
|
25
26
|
const validated = validateCaptureSources(session, parsed);
|
|
26
27
|
if (!validated.ok)
|
|
27
28
|
return toCallToolResult(validated, contract);
|
|
28
|
-
|
|
29
|
+
let comparison;
|
|
30
|
+
try {
|
|
31
|
+
comparison = compareProcessCaptures(parsed.left, parsed.right, {
|
|
32
|
+
...(parsed.max_capture_age_ms === undefined
|
|
33
|
+
? {}
|
|
34
|
+
: { maxCaptureAgeMs: parsed.max_capture_age_ms }),
|
|
35
|
+
now,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (cause) {
|
|
39
|
+
return toCallToolResult(err(new EvidenceIntegrityError(cause instanceof Error
|
|
40
|
+
? cause.message
|
|
41
|
+
: "Invalid Process Capture v4")), contract);
|
|
42
|
+
}
|
|
29
43
|
const evidence = createEvidence(undefined, PROCESS_PROVIDER, {
|
|
30
|
-
predicateType: "rea.process-comparison/
|
|
44
|
+
predicateType: "rea.process-comparison/v3",
|
|
31
45
|
operation: contract.name,
|
|
32
46
|
parameters: {
|
|
33
47
|
left_evidence_id: parsed.left_evidence_id,
|
|
@@ -50,17 +64,23 @@ const validateCaptureSources = (session, parsed) => {
|
|
|
50
64
|
[parsed.right_evidence_id, parsed.right],
|
|
51
65
|
]) {
|
|
52
66
|
const evidence = session.evidenceById(evidenceId);
|
|
53
|
-
|
|
67
|
+
let evidenceCapture;
|
|
68
|
+
try {
|
|
69
|
+
evidenceCapture = parseProcessCapture(evidence?.normalized_result);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
evidenceCapture = undefined;
|
|
73
|
+
}
|
|
54
74
|
if (evidence === undefined ||
|
|
55
75
|
evidence.operation !== "capture_process_scenario" ||
|
|
56
|
-
evidence.predicate_type !== "rea.process-capture/
|
|
76
|
+
evidence.predicate_type !== "rea.process-capture/v4" ||
|
|
57
77
|
evidence.provider.id !== PROCESS_PROVIDER.id ||
|
|
58
78
|
evidence.provider.name !== PROCESS_PROVIDER.name ||
|
|
59
79
|
evidence.provider.version !== PROCESS_PROVIDER.version ||
|
|
60
80
|
evidence.confidence !== "observed" ||
|
|
61
81
|
evidence.authority !== "controlled-replay" ||
|
|
62
|
-
|
|
63
|
-
canonicalJson(
|
|
82
|
+
evidenceCapture === undefined ||
|
|
83
|
+
canonicalJson(evidenceCapture) !== canonicalJson(capture))
|
|
64
84
|
return err(new EvidenceIntegrityError("Process comparison payload does not match its source Evidence"));
|
|
65
85
|
}
|
|
66
86
|
return { ok: true, value: null };
|
|
@@ -5,12 +5,11 @@ import { logToolExecution } from "./toolLogging.js";
|
|
|
5
5
|
import { ok } from "../domain/result.js";
|
|
6
6
|
import { processScenarioSchema } from "../domain/processCapture.js";
|
|
7
7
|
import { captureProcessScenario } from "../application/ProcessHarness.js";
|
|
8
|
-
import { createEvidence } from "../domain/evidence.js";
|
|
9
|
-
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
10
8
|
import { recordUnknownInputSchema, updateUnknownInputSchema, } from "../domain/residualUnknown.js";
|
|
11
9
|
import { readEvidenceBundle, writeEvidenceBundle, } from "../application/EvidenceBundleFiles.js";
|
|
12
10
|
import { UnknownRegistryError } from "../domain/errors.js";
|
|
13
|
-
import { DENY_EVIDENCE_FILE_POLICY, DENY_PROCESS_POLICY,
|
|
11
|
+
import { DENY_EVIDENCE_FILE_POLICY, DENY_PROCESS_POLICY, } from "./sessionToolPolicies.js";
|
|
12
|
+
import { createProcessCaptureEvidence } from "../application/ProcessEvidence.js";
|
|
14
13
|
import { registerProcessComparisonTool } from "./registerProcessComparisonTool.js";
|
|
15
14
|
import { registerArtifactComparisonTool } from "./registerArtifactComparisonTool.js";
|
|
16
15
|
import { registerFunctionComparisonTool } from "./registerFunctionComparisonTool.js";
|
|
@@ -45,13 +44,6 @@ const recordProcessResidualUnknowns = (session, scenario, evidence, residuals) =
|
|
|
45
44
|
}
|
|
46
45
|
return ok(null);
|
|
47
46
|
};
|
|
48
|
-
const processEvidenceParameters = (scenario) => ({
|
|
49
|
-
executable_name: scenario.executable.split("/").at(-1) ?? scenario.executable,
|
|
50
|
-
argument_count: scenario.arguments.length,
|
|
51
|
-
event_count: scenario.events.length,
|
|
52
|
-
filesystem_root_count: scenario.filesystem_roots.length,
|
|
53
|
-
normalization: scenario.normalization,
|
|
54
|
-
});
|
|
55
47
|
const registerProcessTools = ({ server, session, logger, processPolicy, captureContract, }) => {
|
|
56
48
|
server.registerTool(captureContract.name, {
|
|
57
49
|
description: captureContract.description,
|
|
@@ -63,21 +55,7 @@ const registerProcessTools = ({ server, session, logger, processPolicy, captureC
|
|
|
63
55
|
const captured = await logToolExecution(logger, captureContract.name, () => captureProcessScenario(scenario, processPolicy, context.mcpReq.signal));
|
|
64
56
|
if (!captured.ok)
|
|
65
57
|
return toCallToolResult(captured, captureContract);
|
|
66
|
-
const evidence =
|
|
67
|
-
predicateType: "rea.process-capture/v2",
|
|
68
|
-
operation: captureContract.name,
|
|
69
|
-
parameters: processEvidenceParameters(scenario),
|
|
70
|
-
result: jsonValueSchema.parse(captured.value),
|
|
71
|
-
confidence: "observed",
|
|
72
|
-
authority: "controlled-replay",
|
|
73
|
-
environment: {
|
|
74
|
-
id: `${process.platform}-${process.arch}`,
|
|
75
|
-
platform: process.platform,
|
|
76
|
-
architecture: process.arch,
|
|
77
|
-
isolation: "process",
|
|
78
|
-
},
|
|
79
|
-
limitations: captured.value.limitations,
|
|
80
|
-
});
|
|
58
|
+
const evidence = createProcessCaptureEvidence(scenario, captured.value);
|
|
81
59
|
const recorded = session.recordEvidence(evidence);
|
|
82
60
|
if (!recorded.ok)
|
|
83
61
|
return toCallToolResult(recorded, captureContract);
|
|
@@ -14,12 +14,7 @@ export const DENY_EVIDENCE_FILE_POLICY = {
|
|
|
14
14
|
maxStringLength: 1024 * 1024,
|
|
15
15
|
maxNodes: 1_000_000,
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
export const PROCESS_PROVIDER = {
|
|
19
|
-
id: "rea-process",
|
|
20
|
-
name: "REA deterministic process harness",
|
|
21
|
-
version: "1",
|
|
22
|
-
};
|
|
17
|
+
export { PROCESS_PROVIDER } from "../application/ProcessEvidence.js";
|
|
23
18
|
/** Provider identity for deterministic cross-artifact comparisons. */
|
|
24
19
|
export const ARTIFACT_COMPARISON_PROVIDER = {
|
|
25
20
|
id: "rea-artifact-comparison",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rea-agents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"install.sh",
|
|
42
42
|
"bridge/hopper_bridge.py",
|
|
43
43
|
"scripts/rea.mjs",
|
|
44
|
+
"scripts/prepare-node-pty.mjs",
|
|
44
45
|
"scripts/rebuild-native.mjs",
|
|
45
46
|
"skills",
|
|
46
47
|
"README.md",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"scan:todos": "node scripts/scan-todos.mjs",
|
|
60
61
|
"start": "node dist/main.js",
|
|
61
62
|
"pretest": "npm run build",
|
|
63
|
+
"postinstall": "node scripts/prepare-node-pty.mjs",
|
|
62
64
|
"test": "vitest run",
|
|
63
65
|
"pretest:coverage": "npm run build",
|
|
64
66
|
"test:coverage": "vitest run --coverage.enabled --coverage.provider=v8",
|
|
@@ -86,6 +88,8 @@
|
|
|
86
88
|
"@babel/types": "8.0.4",
|
|
87
89
|
"@electron/asar": "4.2.0",
|
|
88
90
|
"@modelcontextprotocol/server": "2.0.0-beta.3",
|
|
91
|
+
"@xterm/addon-serialize": "0.14.0",
|
|
92
|
+
"@xterm/headless": "6.0.0",
|
|
89
93
|
"@zip.js/zip.js": "2.8.26",
|
|
90
94
|
"canonicalize": "3.0.0",
|
|
91
95
|
"diff": "9.0.0",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { chmod, lstat } from "node:fs/promises";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
if (process.platform !== "win32") {
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const packageRoot = dirname(
|
|
11
|
+
require.resolve("node-pty/package.json", {
|
|
12
|
+
paths: [dirname(fileURLToPath(import.meta.url))],
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
const helperPath = join(
|
|
16
|
+
packageRoot,
|
|
17
|
+
"prebuilds",
|
|
18
|
+
`${process.platform}-${process.arch}`,
|
|
19
|
+
"spawn-helper",
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const helper = await lstat(helperPath);
|
|
24
|
+
if (!helper.isFile() || helper.isSymbolicLink()) {
|
|
25
|
+
throw new Error("node-pty spawn helper is not a regular file");
|
|
26
|
+
}
|
|
27
|
+
await chmod(helperPath, helper.mode | 0o111);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
30
|
+
// Source builds place their correctly-modeled helper under build/Release.
|
|
31
|
+
} else {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
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
4
|
metadata:
|
|
5
|
-
version: "
|
|
5
|
+
version: "11"
|
|
6
6
|
tool_count: 68
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -36,13 +36,19 @@ REA accepts a `.app` bundle directly. Do not expose its internal `Contents/MacOS
|
|
|
36
36
|
|
|
37
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.
|
|
38
38
|
|
|
39
|
-
For applications, ZIP/APK/IPA packages,
|
|
39
|
+
For applications, ZIP/APK/IPA packages, Electron ASAR archives, or DMGs, call
|
|
40
40
|
`inventory_artifact` before extraction. Follow its deterministic occurrence
|
|
41
41
|
pages and cite graph manifest IDs. `extract_artifact` requires explicit user
|
|
42
42
|
approval, an absent absolute output root, and selected occurrence IDs; never
|
|
43
43
|
extract every entry implicitly. Symlinks and encrypted entries are inventory
|
|
44
|
-
facts, not extractable files.
|
|
45
|
-
|
|
44
|
+
facts, not extractable files. Inventory traverses discovered ASARs within the
|
|
45
|
+
same graph and shared limits, including ASARs inside an approved mounted DMG.
|
|
46
|
+
|
|
47
|
+
Native DMG traversal is macOS-only, read-only, and disabled by default. Use it
|
|
48
|
+
only when the user approves that inventory call with
|
|
49
|
+
`native_mount_approved: true` and the operator has separately enabled
|
|
50
|
+
`REA_ARTIFACT_NATIVE_MOUNT_ENABLED=true`. Without both gates, retain the DMG
|
|
51
|
+
root-hash-only result. Never imply that approval changes extraction authority.
|
|
46
52
|
|
|
47
53
|
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.
|
|
48
54
|
|
|
@@ -57,6 +63,15 @@ requires per-call approval plus operator policy, and uses host networking only
|
|
|
57
63
|
when the operator explicitly permits it. It is behavioral evidence, not a
|
|
58
64
|
security sandbox.
|
|
59
65
|
|
|
66
|
+
`capture_process_scenario` produces Process Capture v4 only. If a boundary
|
|
67
|
+
reports Process Capture v3, tell the user or calling agent to rerun the original
|
|
68
|
+
scenario; v3 cannot be upgraded because it lacks required manifest and
|
|
69
|
+
settlement evidence. Treat the v4 manifest commitments as compatibility and
|
|
70
|
+
provenance evidence, and distinguish root exit from descendant settlement.
|
|
71
|
+
When comparing stored captures, set `max_capture_age_ms` when the task requires
|
|
72
|
+
fresh behavioral evidence. Different scenario and executable digests are
|
|
73
|
+
allowed, but schema and comparison-contract digests must be compatible.
|
|
74
|
+
|
|
60
75
|
Do not let unanswered questions disappear. Use `record_unknown` only with
|
|
61
76
|
explicit approval, attach supporting and contradicting evidence IDs, and record
|
|
62
77
|
the authority/environment still required. Use `update_unknown` with the current
|