rea-agents 1.7.0 → 2.1.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 +112 -59
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/ArtifactExtraction.js +1 -1
- package/dist/application/ArtifactInventory/classify.js +42 -0
- package/dist/application/ArtifactInventory/hash.js +43 -0
- package/dist/application/ArtifactInventory/reader.js +41 -0
- package/dist/application/ArtifactInventory/scanCanonical.js +155 -0
- package/dist/application/ArtifactInventory/scanReader.js +124 -0
- package/dist/application/ArtifactInventory/types.js +10 -0
- package/dist/application/ArtifactInventory.js +9 -351
- package/dist/application/AuthorizedArtifactInventory.js +2 -2
- package/dist/application/BinarySession.js +47 -270
- package/dist/application/BinarySessionExecution.js +28 -0
- package/dist/application/BinarySessionOpen.js +39 -0
- package/dist/application/BinarySessionRecords.js +149 -0
- package/dist/application/BinarySessionStatus.js +75 -0
- package/dist/application/CapabilityInventory.js +42 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +11 -29
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +165 -197
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +112 -0
- package/dist/application/ElectronBoundaryGraph.js +9 -0
- package/dist/application/ElectronBoundaryGraphContext.js +62 -0
- package/dist/application/ElectronBoundaryGraphIpc.js +242 -0
- package/dist/application/ElectronBoundaryGraphNative.js +86 -0
- package/dist/application/ElectronBoundaryGraphWindows.js +223 -0
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +58 -50
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationProviders.js +30 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptApplicationEvidence.js +26 -0
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +89 -0
- package/dist/application/JavaScriptApplicationService.js +74 -0
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +29 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +90 -0
- package/dist/application/JavaScriptArtifactAnalysis.js +52 -7
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +82 -17
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- package/dist/application/JavaScriptArtifactGraphEvidence.js +24 -14
- package/dist/application/JavaScriptArtifactGraphFindings.js +54 -8
- package/dist/application/JavaScriptArtifactGraphStructure.js +29 -101
- package/dist/application/JavaScriptArtifactPathResolution.js +269 -0
- package/dist/application/JavaScriptArtifactReconstruction.js +4 -1
- package/dist/application/JavaScriptArtifactReconstructionInput.js +2 -83
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayPlanning.js +201 -0
- package/dist/application/JavaScriptReplayService.js +292 -0
- package/dist/application/JavaScriptRuntimeReconciliationEvidence.js +25 -0
- package/dist/application/JavaScriptRuntimeReconciliationService.js +27 -0
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- package/dist/application/ManagedApplicationGraphService.js +55 -0
- package/dist/application/ManagedMemberComparisonService.js +122 -0
- package/dist/application/ManagedNativeVerificationService.js +39 -0
- package/dist/application/ManagedReconstructionService.js +58 -0
- package/dist/application/ManagedRuntimeCorrelationService.js +103 -0
- package/dist/application/NodeRuntimeCharacterizationService.js +196 -0
- package/dist/application/PermissionAuthority.js +106 -63
- package/dist/application/ProcessCaptureCapability.js +1 -1
- package/dist/application/ProcessCapturePermission.js +13 -0
- package/dist/application/ProcessCli.js +2 -12
- package/dist/application/ProcessHarness.js +1 -1
- package/dist/application/ProcessSampling.js +15 -11
- package/dist/application/ProjectPermissionStore.js +49 -9
- package/dist/application/RealHopperAssertions.js +76 -0
- package/dist/application/ReconstructionCoverageService.js +69 -0
- package/dist/application/ReconstructionCoverageWorkspaceStore.js +31 -0
- package/dist/application/RuntimeExecutableDiagnostics.js +172 -0
- package/dist/application/Setup.js +147 -259
- package/dist/application/SetupClientConfiguration.js +220 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +123 -12
- package/dist/application/SetupSkill.js +26 -12
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +6 -3
- package/dist/application/WindowsCapabilities.js +86 -0
- package/dist/application/runtime.js +2 -0
- package/dist/artifacts/AsarArtifactReader.js +11 -0
- package/dist/browser/BrowserProcessStartup.js +88 -0
- package/dist/browser/CdpCaptureDocuments.js +12 -8
- package/dist/browser/CdpCaptureEventBodyShapes.js +75 -0
- package/dist/browser/CdpCaptureEventHandlers.js +336 -0
- package/dist/browser/CdpCaptureEventHelpers.js +71 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +1 -0
- package/dist/browser/CdpCaptureEvents.js +46 -464
- package/dist/browser/CdpElectronInspection.js +106 -162
- package/dist/browser/CdpElectronProvider.js +5 -1
- package/dist/browser/CdpElectronScriptEvents.js +69 -0
- package/dist/browser/CdpElectronScripts.js +94 -0
- package/dist/browser/CdpElectronWorkers.js +56 -0
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -129
- package/dist/browser/CdpPageCaptureScripts.js +97 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpWebMcpDiscovery.js +38 -14
- package/dist/browser/PngVisualDiff.js +9 -2
- package/dist/catalogIdentity.js +8 -1
- package/dist/cli/artifactCommands.js +82 -0
- package/dist/cli/coreAnalysisCommands.js +232 -0
- package/dist/cli/managedCommands.js +397 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/options.js +9 -0
- package/dist/cli/setupCommands.js +108 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +122 -0
- package/dist/cli.js +13 -383
- package/dist/cliApplicationCommands.js +176 -0
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +17 -0
- package/dist/cliElectronCommands.js +100 -27
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- package/dist/cliJsonInput.js +54 -0
- package/dist/cliObservationOptions.js +137 -0
- package/dist/cliPolicyCommands.js +80 -46
- package/dist/cliSetup.js +289 -0
- package/dist/config/environment.js +107 -0
- package/dist/config/parseConfig.js +228 -0
- package/dist/config/parsers.js +68 -0
- package/dist/config/permissions.js +30 -0
- package/dist/config/types.js +1 -0
- package/dist/config.js +1 -292
- package/dist/contracts/applicationToolContracts.js +225 -0
- package/dist/contracts/artifactToolContracts.js +5 -9
- package/dist/contracts/browserToolContracts.js +14 -62
- package/dist/contracts/electronToolContracts.js +45 -19
- package/dist/contracts/errorSchemas.js +1 -0
- package/dist/contracts/investigationExamples.js +0 -6
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +46 -0
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +208 -0
- package/dist/contracts/managedToolContracts.js +153 -0
- package/dist/contracts/managedWorkflowExamples.js +346 -0
- package/dist/contracts/managedWorkflowToolContracts.js +203 -0
- package/dist/contracts/nativeToolContracts.js +2 -6
- package/dist/contracts/promptContracts.js +18 -2
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContractExamples.js +10 -25
- package/dist/contracts/toolContracts.js +49 -47
- package/dist/contracts/toolEffects.js +174 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -535
- package/dist/doctorRuntime.js +42 -1
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +37 -19
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -282
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/bundleComparison.js +4 -4
- package/dist/domain/electronObservation.js +13 -0
- package/dist/domain/electronStaticAnalysis.js +9 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +206 -0
- package/dist/domain/electronStaticAnalysisIpc.js +171 -0
- package/dist/domain/electronStaticAnalysisNative.js +164 -0
- package/dist/domain/electronStaticAnalysisTypes.js +1 -0
- package/dist/domain/electronStaticAnalysisValues.js +103 -0
- package/dist/domain/errors.js +32 -448
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/functionComparisonSchemas.js +3 -8
- package/dist/domain/inputIssueProjection.js +52 -0
- package/dist/domain/javascriptApplicationAnalysis.js +155 -0
- package/dist/domain/javascriptApplicationChangeGraph.js +231 -0
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +18 -0
- package/dist/domain/javascriptApplicationGraph.js +2 -1
- package/dist/domain/javascriptApplicationGraphSchemas.js +7 -0
- package/dist/domain/javascriptApplicationVersionComparison.js +116 -0
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +139 -0
- package/dist/domain/javascriptApplicationVersionItems.js +233 -0
- package/dist/domain/javascriptApplicationVersionKeys.js +170 -0
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureSeed.js +140 -0
- package/dist/domain/javascriptFeatureTrace.js +232 -0
- package/dist/domain/javascriptFeatureTraceSchemas.js +136 -0
- package/dist/domain/javascriptFeatureTraversal.js +100 -0
- package/dist/domain/javascriptNativeHandoff.js +85 -0
- package/dist/domain/javascriptReplay.js +361 -0
- package/dist/domain/javascriptRuntimeLoadState.js +106 -0
- package/dist/domain/javascriptRuntimeReconciliation.js +42 -0
- package/dist/domain/javascriptRuntimeReconciliationGraph.js +169 -0
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +247 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +160 -0
- package/dist/domain/javascriptRuntimeReconciliationResult.js +119 -0
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +316 -0
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +245 -0
- package/dist/domain/javascriptRuntimeStaticCandidates.js +193 -0
- package/dist/domain/javascriptSemanticAnalysis.js +386 -0
- package/dist/domain/javascriptSemanticIr.js +30 -0
- package/dist/domain/javascriptSemanticProjection.js +366 -0
- package/dist/domain/javascriptSemanticState.js +40 -0
- package/dist/domain/javascriptSemanticTraversal.js +22 -0
- package/dist/domain/javascriptSemanticValues.js +352 -0
- package/dist/domain/javascriptStaticAnalysis.js +26 -254
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisFindings.js +39 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +81 -2
- package/dist/domain/javascriptStaticAnalysisState.js +6 -0
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +206 -0
- package/dist/domain/managedApplicationGraphCoverage.js +170 -0
- package/dist/domain/managedApplicationGraphNodeCoverage.js +6 -0
- package/dist/domain/managedApplicationGraphNodes.js +336 -0
- package/dist/domain/managedArtifact.js +452 -0
- package/dist/domain/managedMemberComparison.js +211 -0
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +46 -0
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +196 -0
- package/dist/domain/managedRuntimeCorrelation.js +184 -0
- package/dist/domain/nodeRuntimeCharacterization.js +66 -0
- package/dist/domain/permissionPolicy.js +2 -0
- package/dist/domain/reconstructionCoverage.js +387 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +212 -0
- package/dist/domain/reconstructionVerificationSchemas.js +9 -3
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/webBundleAnalyzer.js +3 -409
- package/dist/domain/webBundleAnalyzerAst.js +77 -0
- package/dist/domain/webBundleAnalyzerInspection.js +307 -0
- package/dist/domain/webBundleAnalyzerResult.js +120 -0
- package/dist/dotnet/ManagedArtifactInspector.js +339 -0
- package/dist/dotnet/ManagedMemberInspector.js +153 -0
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataHeaps.js +131 -0
- package/dist/dotnet/ManagedMetadataInventory.js +104 -0
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +259 -0
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +143 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +311 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +143 -0
- package/dist/dotnet/ManagedPeReader.js +188 -0
- package/dist/dotnet/ManagedReaderFailure.js +10 -0
- package/dist/dotnet/ManagedStaticProvider.js +203 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraClient.js +76 -91
- package/dist/ghidra/GhidraClientStartup.js +29 -0
- package/dist/ghidra/GhidraClientWire.js +34 -0
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraDiagnostics.js +6 -1
- package/dist/ghidra/GhidraInstallation.js +20 -15
- package/dist/ghidra/GhidraLauncher.js +93 -29
- package/dist/ghidra/GhidraProvider.js +67 -161
- package/dist/ghidra/GhidraProviderCapabilities.js +173 -0
- package/dist/ghidra/GhidraSessionValues.js +2 -0
- package/dist/ghidra/GhidraSocketConnection.js +44 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +30 -0
- package/dist/ghidra/GhidraTransport.js +71 -0
- package/dist/identity.js +3 -2
- package/dist/main/messages.js +5 -0
- package/dist/main/reload.js +49 -0
- package/dist/main/shutdown.js +25 -0
- package/dist/main/startup.js +14 -0
- package/dist/main/state.js +26 -0
- package/dist/main/transport.js +61 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +35 -132
- package/dist/process/PrivateRuntimeRoot.js +3 -2
- package/dist/process/ProcessOwnership.js +35 -0
- package/dist/process/ProviderProcess.js +2 -0
- package/dist/replay/JavaScriptReplayWorker.js +300 -0
- package/dist/replay/LinuxJavaScriptReplayRunner.js +217 -0
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/LinuxRuntimeClosure.js +46 -0
- package/dist/replay/LinuxSeccompPolicy.js +40 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/replay/ReplayWorkerProtocol.js +55 -0
- package/dist/replay/SystemJavaScriptReplayHost.js +182 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +158 -41
- package/dist/server/registerApplicationTools/characterization.js +57 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/controlledReplay.js +38 -0
- package/dist/server/registerApplicationTools/coverage.js +84 -0
- package/dist/server/registerApplicationTools/helpers.js +42 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +13 -0
- package/dist/server/registerArtifactComparisonTool.js +16 -9
- package/dist/server/registerBrowserTools.js +61 -60
- package/dist/server/registerBundleComparisonTool.js +17 -20
- package/dist/server/registerElectronTools.js +39 -12
- package/dist/server/registerEnhancedTools.js +52 -15
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerEvidenceTools.js +5 -1
- package/dist/server/registerFunctionComparisonTool.js +14 -7
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +103 -132
- package/dist/server/registerManagedTools.js +6 -0
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +65 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +8 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +43 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +39 -0
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +39 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +52 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +75 -0
- package/dist/server/registerManagedWorkflowTools.js +13 -0
- package/dist/server/registerOfficialTools.js +81 -67
- package/dist/server/registerProcessComparisonTool.js +25 -47
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +9 -8
- package/dist/server/registerSessionTools.js +77 -216
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/sessionEvidence.js +14 -19
- package/dist/server/toolInputValidation.js +77 -0
- package/dist/server/toolRegistrationOptions.js +177 -2
- package/dist/server/toolResult.js +30 -17
- package/package.json +21 -14
- package/scripts/rea.mjs +1 -1
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +75 -6
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AnalysisInputError, } from "../domain/errors.js";
|
|
3
|
+
import { projectInputIssues } from "../domain/inputIssueProjection.js";
|
|
4
|
+
import { err, ok } from "../domain/result.js";
|
|
5
|
+
import { closeObjectSchemas } from "./toolRegistrationOptions.js";
|
|
6
|
+
/** Parse one MCP request exactly once and retain only schema-owned correction data. */
|
|
7
|
+
export const safeParseToolInput = (schema, input, operation) => {
|
|
8
|
+
const unknownIssues = unknownArgumentIssues(schema, input);
|
|
9
|
+
if (unknownIssues.length > 0)
|
|
10
|
+
return err(new AnalysisInputError(operation, undefined, unknownIssues));
|
|
11
|
+
const parsed = schema.safeParse(input);
|
|
12
|
+
return parsed.success
|
|
13
|
+
? ok(parsed.data)
|
|
14
|
+
: err(new AnalysisInputError(operation, undefined, projectInputIssues(parsed.error.issues, input)));
|
|
15
|
+
};
|
|
16
|
+
const schemaCache = new WeakMap();
|
|
17
|
+
const unknownArgumentIssues = (schema, input) => {
|
|
18
|
+
let jsonSchema = schemaCache.get(schema);
|
|
19
|
+
if (jsonSchema === undefined) {
|
|
20
|
+
const converter = schema["~standard"].jsonSchema?.input;
|
|
21
|
+
if (converter === undefined)
|
|
22
|
+
throw new TypeError("Tool input schema does not expose Standard JSON Schema");
|
|
23
|
+
jsonSchema = closeObjectSchemas(converter({ target: "draft-2020-12" }));
|
|
24
|
+
schemaCache.set(schema, jsonSchema);
|
|
25
|
+
}
|
|
26
|
+
return scanUnknownArguments(input, jsonSchema, jsonSchema, []);
|
|
27
|
+
};
|
|
28
|
+
const scanUnknownArguments = (value, schema, root, path) => {
|
|
29
|
+
const resolved = resolveSchema(schema, root);
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
const items = objectValue(resolved.items);
|
|
32
|
+
return items === undefined
|
|
33
|
+
? []
|
|
34
|
+
: value.flatMap((item, index) => scanUnknownArguments(item, items, root, [...path, index]));
|
|
35
|
+
}
|
|
36
|
+
if (!isObject(value))
|
|
37
|
+
return [];
|
|
38
|
+
const variants = schemaVariants(resolved, root);
|
|
39
|
+
const properties = Object.fromEntries(variants.flatMap((variant) => Object.entries(objectValue(variant.properties) ?? {})));
|
|
40
|
+
const closed = variants.length > 0 &&
|
|
41
|
+
variants.every((variant) => variant.additionalProperties !== true &&
|
|
42
|
+
!isObject(variant.additionalProperties));
|
|
43
|
+
const issues = [];
|
|
44
|
+
for (const [key, child] of Object.entries(value)) {
|
|
45
|
+
const propertySchema = objectValue(properties[key]);
|
|
46
|
+
if (propertySchema === undefined) {
|
|
47
|
+
if (closed)
|
|
48
|
+
issues.push({ path: [...path, key], reason: "unknown_argument" });
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
issues.push(...scanUnknownArguments(child, propertySchema, root, [...path, key]));
|
|
52
|
+
}
|
|
53
|
+
return issues;
|
|
54
|
+
};
|
|
55
|
+
const schemaVariants = (schema, root) => {
|
|
56
|
+
const resolved = resolveSchema(schema, root);
|
|
57
|
+
const variants = [resolved.oneOf, resolved.anyOf, resolved.allOf]
|
|
58
|
+
.flatMap((value) => (Array.isArray(value) ? value : []))
|
|
59
|
+
.flatMap((value) => {
|
|
60
|
+
const object = objectValue(value);
|
|
61
|
+
return object === undefined ? [] : schemaVariants(object, root);
|
|
62
|
+
});
|
|
63
|
+
if (variants.length > 0)
|
|
64
|
+
return variants;
|
|
65
|
+
return resolved.type === "object" || isObject(resolved.properties)
|
|
66
|
+
? [resolved]
|
|
67
|
+
: [];
|
|
68
|
+
};
|
|
69
|
+
const resolveSchema = (schema, root) => {
|
|
70
|
+
const reference = schema.$ref;
|
|
71
|
+
if (typeof reference !== "string" || !reference.startsWith("#/$defs/"))
|
|
72
|
+
return schema;
|
|
73
|
+
const definition = objectValue(objectValue(root.$defs)?.[reference.slice(8)]);
|
|
74
|
+
return definition === undefined ? schema : definition;
|
|
75
|
+
};
|
|
76
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
77
|
+
const objectValue = (value) => isObject(value) ? value : undefined;
|
|
@@ -1,7 +1,182 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
/** Project the public contract fields accepted by MCP tool registration. */
|
|
2
3
|
export const toolRegistrationOptions = (contract) => ({
|
|
4
|
+
title: contract.title,
|
|
3
5
|
description: contract.description,
|
|
4
|
-
inputSchema: contract.inputSchema,
|
|
5
|
-
outputSchema: contract.outputSchema,
|
|
6
|
+
inputSchema: advertisedInputSchema(contract.inputSchema),
|
|
7
|
+
outputSchema: advertisedOutputSchema(contract.outputSchema),
|
|
6
8
|
annotations: contract.annotations,
|
|
7
9
|
});
|
|
10
|
+
/**
|
|
11
|
+
* Advertise the exact Zod contract while leaving validation to REA's adapter.
|
|
12
|
+
* The SDK otherwise converts validation failures to text-only JSON-RPC errors
|
|
13
|
+
* before REA can return its stable structured error envelope.
|
|
14
|
+
*/
|
|
15
|
+
const advertisedInputSchema = (schema) => ({
|
|
16
|
+
"~standard": {
|
|
17
|
+
version: 1,
|
|
18
|
+
vendor: "rea",
|
|
19
|
+
validate: (input) => ({ value: input }),
|
|
20
|
+
jsonSchema: {
|
|
21
|
+
input: () => describeProperties(closeObjectSchemas(inputJsonSchema(schema))),
|
|
22
|
+
output: () => describeProperties(closeObjectSchemas(inputJsonSchema(schema))),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const advertisedOutputSchema = (schema) => {
|
|
27
|
+
const standard = schema["~standard"];
|
|
28
|
+
const converter = standard.jsonSchema?.output;
|
|
29
|
+
if (converter === undefined)
|
|
30
|
+
throw new TypeError("Tool output schema does not expose Standard JSON Schema");
|
|
31
|
+
return {
|
|
32
|
+
"~standard": {
|
|
33
|
+
...standard,
|
|
34
|
+
jsonSchema: {
|
|
35
|
+
input: () => describeRootProperties(closeObjectSchemas(converter({ target: "draft-2020-12" }))),
|
|
36
|
+
output: () => describeRootProperties(closeObjectSchemas(converter({ target: "draft-2020-12" }))),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const inputJsonSchema = (schema) => {
|
|
42
|
+
const converter = schema["~standard"].jsonSchema?.input;
|
|
43
|
+
if (converter === undefined)
|
|
44
|
+
throw new TypeError("Tool input schema does not expose Standard JSON Schema");
|
|
45
|
+
return converter({ target: "draft-2020-12" });
|
|
46
|
+
};
|
|
47
|
+
/** Close fixed-shape JSON Schema objects while preserving explicit maps. */
|
|
48
|
+
export const closeObjectSchemas = (value) => {
|
|
49
|
+
const closed = Object.fromEntries(Object.entries(value).map(([key, child]) => [key, closeSchemaValue(child)]));
|
|
50
|
+
return value.type === "object" &&
|
|
51
|
+
isObject(value.properties) &&
|
|
52
|
+
value.additionalProperties === undefined
|
|
53
|
+
? { ...closed, additionalProperties: false }
|
|
54
|
+
: closed;
|
|
55
|
+
};
|
|
56
|
+
const closeSchemaValue = (value) => {
|
|
57
|
+
if (Array.isArray(value))
|
|
58
|
+
return value.map(closeSchemaValue);
|
|
59
|
+
if (!isObject(value))
|
|
60
|
+
return value;
|
|
61
|
+
return closeObjectSchemas(value);
|
|
62
|
+
};
|
|
63
|
+
const describeProperties = (value) => Object.fromEntries(Object.entries(value).map(([key, child]) => {
|
|
64
|
+
if (key !== "properties" || typeof child !== "object" || child === null)
|
|
65
|
+
return [key, describeValue(child)];
|
|
66
|
+
return [
|
|
67
|
+
key,
|
|
68
|
+
Object.fromEntries(Object.entries(child).map(([property, schema]) => [
|
|
69
|
+
property,
|
|
70
|
+
isObject(schema) && typeof schema.description !== "string"
|
|
71
|
+
? {
|
|
72
|
+
...describeProperties(schema),
|
|
73
|
+
description: fallbackPropertyDescription(property),
|
|
74
|
+
}
|
|
75
|
+
: describeValue(schema),
|
|
76
|
+
])),
|
|
77
|
+
];
|
|
78
|
+
}));
|
|
79
|
+
const describeValue = (value) => {
|
|
80
|
+
if (Array.isArray(value))
|
|
81
|
+
return value.map(describeValue);
|
|
82
|
+
return isObject(value) ? describeProperties(value) : value;
|
|
83
|
+
};
|
|
84
|
+
const describeRootProperties = (value) => {
|
|
85
|
+
const properties = value.properties;
|
|
86
|
+
if (!isObject(properties))
|
|
87
|
+
return { ...value };
|
|
88
|
+
return {
|
|
89
|
+
...value,
|
|
90
|
+
properties: Object.fromEntries(Object.entries(properties).map(([property, schema]) => [
|
|
91
|
+
property,
|
|
92
|
+
isObject(schema) && typeof schema.description !== "string"
|
|
93
|
+
? {
|
|
94
|
+
...schema,
|
|
95
|
+
description: fallbackPropertyDescription(property),
|
|
96
|
+
}
|
|
97
|
+
: schema,
|
|
98
|
+
])),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const PROPERTY_DESCRIPTIONS = {
|
|
102
|
+
addresses: "Ordered provider-normalized procedure addresses to analyze.",
|
|
103
|
+
approved: "Explicit operator approval to perform this operation.",
|
|
104
|
+
after: "The later or right-hand observation to compare.",
|
|
105
|
+
before: "The earlier or left-hand observation to compare.",
|
|
106
|
+
boundary_id: "Exact reconstruction boundary identifier to evaluate.",
|
|
107
|
+
case_sensitive: "Whether text matching distinguishes uppercase and lowercase.",
|
|
108
|
+
cdp_endpoint: "Approved literal loopback Chrome DevTools Protocol endpoint.",
|
|
109
|
+
comment: "Exact analyst comment text to write.",
|
|
110
|
+
comparisons: "Validated comparison Evidence records to aggregate.",
|
|
111
|
+
coverage: "Exact reconstruction-coverage commitment to verify.",
|
|
112
|
+
detail: "Requested response detail level.",
|
|
113
|
+
direction: "Direction in which to traverse or compare relationships.",
|
|
114
|
+
document: "Exact provider document or program identity.",
|
|
115
|
+
error: "Structured, caller-actionable error when the operation fails.",
|
|
116
|
+
evidence: "Evidence v2 record produced by this operation.",
|
|
117
|
+
evidence_id: "Stable identifier of the recorded Evidence v2 observation.",
|
|
118
|
+
evidence_uri: "Session resource URI for the recorded Evidence v2 observation.",
|
|
119
|
+
executable: "Approved absolute path of the executable to run.",
|
|
120
|
+
format: "Declared input artifact format.",
|
|
121
|
+
name: "Exact name used by this operation.",
|
|
122
|
+
pattern: "Text or bounded pattern used to filter matching results.",
|
|
123
|
+
phase: "Current plan or execution phase of the operation.",
|
|
124
|
+
plan: "Content-bound execution plan and its approval commitment.",
|
|
125
|
+
query: "Non-empty feature or text query to investigate.",
|
|
126
|
+
question: "Concrete unresolved question to retain for later investigation.",
|
|
127
|
+
result: "Primary structured result returned by this operation.",
|
|
128
|
+
left: "Left-hand input used for comparison or differential execution.",
|
|
129
|
+
limit: "Maximum number of results to return in this page.",
|
|
130
|
+
limits: "Bounded resource-consumption and result-size limits for this operation.",
|
|
131
|
+
mode: "Operation mode that selects the requested behavior.",
|
|
132
|
+
offset: "Zero-based index of the first result to return.",
|
|
133
|
+
overwrite: "Whether an existing destination may be replaced.",
|
|
134
|
+
path: "Local filesystem path used by this operation.",
|
|
135
|
+
provider_id: "Exact deep-analysis provider ID, or automatic selection when omitted.",
|
|
136
|
+
right: "Right-hand input used for comparison or differential execution.",
|
|
137
|
+
schema_version: "Version of this structured result schema.",
|
|
138
|
+
source_evidence: "Evidence records supporting the prepared source transformation.",
|
|
139
|
+
status: "Current lifecycle or verification status.",
|
|
140
|
+
summary: "Concise evidence-backed summary of the result.",
|
|
141
|
+
symbols: "Ordered bounded Swift symbols to demangle.",
|
|
142
|
+
target_id: "Exact authorized CDP target identifier.",
|
|
143
|
+
unknown_id: "Exact residual-unknown identifier.",
|
|
144
|
+
unknown_registry_approved: "Explicit approval to record bounded residual uncertainty in the session registry.",
|
|
145
|
+
workspace_path: "Approved local path of the persistent investigation workspace.",
|
|
146
|
+
};
|
|
147
|
+
const fallbackPropertyDescription = (property) => {
|
|
148
|
+
const explicit = PROPERTY_DESCRIPTIONS[property];
|
|
149
|
+
if (explicit !== undefined)
|
|
150
|
+
return explicit;
|
|
151
|
+
const words = property.replaceAll("_", " ");
|
|
152
|
+
if (property.endsWith("_approved"))
|
|
153
|
+
return `Explicit operator approval for ${words.slice(0, -9)}.`;
|
|
154
|
+
if (property.endsWith("_offset"))
|
|
155
|
+
return `Zero-based index of the first ${words.slice(0, -7)} to return.`;
|
|
156
|
+
if (property.endsWith("_limit"))
|
|
157
|
+
return `Maximum number of ${words.slice(0, -6)} entries to return.`;
|
|
158
|
+
if (property.startsWith("max_"))
|
|
159
|
+
return `Maximum permitted ${words.slice(4)} for this operation.`;
|
|
160
|
+
if (property.startsWith("include_"))
|
|
161
|
+
return `Whether to include ${words.slice(8)} in the result.`;
|
|
162
|
+
if (property.startsWith("expected_"))
|
|
163
|
+
return `Expected ${words.slice(9)} used to reject stale or mismatched input.`;
|
|
164
|
+
if (property.endsWith("_sha256"))
|
|
165
|
+
return `Exact SHA-256 digest of ${words.slice(0, -7)}.`;
|
|
166
|
+
if (property.endsWith("_evidence_id"))
|
|
167
|
+
return `Exact Evidence v2 identifier for the ${words.slice(0, -12)} observation.`;
|
|
168
|
+
if (property.endsWith("_evidence_ids"))
|
|
169
|
+
return `Ordered Evidence v2 identifiers for the ${words.slice(0, -13)} observations.`;
|
|
170
|
+
if (property.endsWith("_path"))
|
|
171
|
+
return `Local filesystem path for ${words.slice(0, -5)}.`;
|
|
172
|
+
if (property.endsWith("_uri"))
|
|
173
|
+
return `Canonical URI for ${words.slice(0, -4)}.`;
|
|
174
|
+
if (property.endsWith("_bytes"))
|
|
175
|
+
return `Bounded byte count for ${words.slice(0, -6)}.`;
|
|
176
|
+
if (property.endsWith("_root") || property.endsWith("_roots"))
|
|
177
|
+
return `Approved canonical filesystem ${words}.`;
|
|
178
|
+
if (property.startsWith("is_") || property.startsWith("has_"))
|
|
179
|
+
return `Whether ${words}.`;
|
|
180
|
+
return `Value for ${words}.`;
|
|
181
|
+
};
|
|
182
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -9,43 +9,65 @@ export const toCallToolResult = (result, contract, options = {}) => result.ok
|
|
|
9
9
|
: errorResult(result.error);
|
|
10
10
|
const errorResult = (error) => {
|
|
11
11
|
const projected = projectAnalysisError(error);
|
|
12
|
+
const structuredContent = { error: projected };
|
|
12
13
|
return {
|
|
13
14
|
content: [
|
|
14
15
|
{
|
|
15
16
|
type: "text",
|
|
16
|
-
text:
|
|
17
|
+
text: JSON.stringify(structuredContent),
|
|
17
18
|
},
|
|
18
19
|
],
|
|
19
|
-
structuredContent
|
|
20
|
+
structuredContent,
|
|
20
21
|
isError: true,
|
|
21
22
|
};
|
|
22
23
|
};
|
|
23
24
|
const successResult = (value, contract, options) => {
|
|
24
|
-
const candidate =
|
|
25
|
+
const candidate = compactEvidence(value) ??
|
|
26
|
+
(contract.kind === "session" ? { result: value } : value);
|
|
25
27
|
const parsed = contract.outputSchema.safeParse(candidate);
|
|
26
28
|
if (!parsed.success) {
|
|
29
|
+
const structuredContent = {
|
|
30
|
+
error: projectAnalysisError(new AnalysisOutputError(contract.name, "output does not match the tool contract")),
|
|
31
|
+
};
|
|
27
32
|
return {
|
|
28
33
|
content: [
|
|
29
34
|
{
|
|
30
35
|
type: "text",
|
|
31
|
-
text:
|
|
36
|
+
text: JSON.stringify(structuredContent),
|
|
32
37
|
},
|
|
33
38
|
],
|
|
34
|
-
structuredContent
|
|
35
|
-
error: projectAnalysisError(new AnalysisOutputError(contract.name, "output does not match the tool contract")),
|
|
36
|
-
},
|
|
39
|
+
structuredContent,
|
|
37
40
|
isError: true,
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
return {
|
|
41
44
|
content: [
|
|
42
|
-
{ type: "text", text:
|
|
45
|
+
{ type: "text", text: JSON.stringify(parsed.data) },
|
|
43
46
|
...evidenceResourceLinks(value, contract.kind === "session" ||
|
|
44
47
|
options.evidenceResourcesAvailable === true),
|
|
48
|
+
...(options.resourceLinks ?? []).map((resource) => ({
|
|
49
|
+
type: "resource_link",
|
|
50
|
+
...resource,
|
|
51
|
+
mimeType: "application/json",
|
|
52
|
+
})),
|
|
45
53
|
],
|
|
46
54
|
structuredContent: candidate,
|
|
47
55
|
};
|
|
48
56
|
};
|
|
57
|
+
const compactEvidence = (value) => {
|
|
58
|
+
if (typeof value !== "object" ||
|
|
59
|
+
value === null ||
|
|
60
|
+
Array.isArray(value) ||
|
|
61
|
+
typeof value.evidence_id !== "string" ||
|
|
62
|
+
!/^ev_[a-f0-9]{64}$/u.test(value.evidence_id) ||
|
|
63
|
+
!("normalized_result" in value))
|
|
64
|
+
return undefined;
|
|
65
|
+
return {
|
|
66
|
+
result: value.normalized_result,
|
|
67
|
+
evidence_id: value.evidence_id,
|
|
68
|
+
evidence_uri: `rea://evidence/${value.evidence_id}`,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
49
71
|
const evidenceResourceLinks = (value, available) => {
|
|
50
72
|
if (!available ||
|
|
51
73
|
typeof value !== "object" ||
|
|
@@ -64,12 +86,3 @@ const evidenceResourceLinks = (value, available) => {
|
|
|
64
86
|
},
|
|
65
87
|
];
|
|
66
88
|
};
|
|
67
|
-
const formatValue = (value) => {
|
|
68
|
-
if (value === null)
|
|
69
|
-
return "OK";
|
|
70
|
-
if (typeof value === "string")
|
|
71
|
-
return value;
|
|
72
|
-
if (typeof value === "object")
|
|
73
|
-
return JSON.stringify(value, null, 2);
|
|
74
|
-
return String(value);
|
|
75
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rea-agents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Reverse engineer anything from your terminal or agent with one CLI and MCP server.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"type": "module",
|
|
32
32
|
"bin": {
|
|
33
|
-
"rea": "scripts/rea.mjs"
|
|
33
|
+
"rea": "scripts/rea.mjs",
|
|
34
|
+
"rea-agents": "scripts/rea.mjs"
|
|
34
35
|
},
|
|
35
36
|
"engines": {
|
|
36
37
|
"node": "^22.19.0 || >=24.11.0"
|
|
@@ -42,17 +43,17 @@
|
|
|
42
43
|
"bridge/hopper_bridge.py",
|
|
43
44
|
"bridge/ghidra/ReaGhidraBridge.java",
|
|
44
45
|
"scripts/rea.mjs",
|
|
45
|
-
"scripts/prepare-node-pty.mjs",
|
|
46
|
-
"scripts/rebuild-native.mjs",
|
|
47
46
|
"scripts/hopper-demo-x11.py",
|
|
48
47
|
"skills",
|
|
49
48
|
"README.md",
|
|
50
49
|
"LICENSE"
|
|
51
50
|
],
|
|
52
51
|
"scripts": {
|
|
53
|
-
"
|
|
52
|
+
"deps:check": "node scripts/check-dependency-install.mjs",
|
|
53
|
+
"prebuild": "npm run deps:check && node scripts/generate-package-metadata.mjs",
|
|
54
54
|
"build": "tsc -p tsconfig.build.json",
|
|
55
55
|
"postbuild": "node scripts/record-build-cache.mjs",
|
|
56
|
+
"precheck": "npm run deps:check",
|
|
56
57
|
"check": "npm run typecheck && npm run lint && npm run format:check && npm run docs:check && npm test",
|
|
57
58
|
"format": "prettier --write .",
|
|
58
59
|
"format:check": "prettier --check .",
|
|
@@ -64,7 +65,6 @@
|
|
|
64
65
|
"scan:todos": "node scripts/scan-todos.mjs",
|
|
65
66
|
"start": "node scripts/rea.mjs mcp",
|
|
66
67
|
"pretest": "npm run build",
|
|
67
|
-
"postinstall": "node scripts/prepare-node-pty.mjs",
|
|
68
68
|
"test": "vitest run",
|
|
69
69
|
"pretest:coverage": "npm run build",
|
|
70
70
|
"test:coverage": "vitest run --coverage.enabled --coverage.provider=v8",
|
|
@@ -73,19 +73,28 @@
|
|
|
73
73
|
"typecheck": "tsc --noEmit",
|
|
74
74
|
"verify:hopper": "npm run build && node scripts/verify-real-hopper.mjs",
|
|
75
75
|
"verify:ghidra": "npm run build && node scripts/verify-real-ghidra.mjs",
|
|
76
|
+
"verify:ghidra:windows": "npm run build && npm run build:ghidra-windows-fixture && node scripts/verify-real-ghidra-windows.mjs",
|
|
76
77
|
"verify:browser": "npm run build && node scripts/verify-real-browser.mjs",
|
|
78
|
+
"verify:javascript-runtime": "npm run build && node scripts/verify-local-javascript-runtime.mjs",
|
|
79
|
+
"verify:application-workflows": "npm run build && node scripts/verify-local-application-workflows.mjs",
|
|
80
|
+
"verify:managed": "npm run build && node scripts/verify-managed-conformance.mjs",
|
|
81
|
+
"verify:replay": "npm run build && node scripts/verify-real-javascript-replay.mjs",
|
|
77
82
|
"verify:hopper:linux": "npm run build && node scripts/verify-real-hopper-linux.mjs",
|
|
78
83
|
"verify:setup:linux": "npm run build && node scripts/verify-linux-setup-e2e.mjs",
|
|
79
84
|
"build:fixtures": "node scripts/build-conformance-fixtures.mjs",
|
|
85
|
+
"build:ghidra-windows-fixture": "node scripts/create-ghidra-windows-fixture.mjs",
|
|
80
86
|
"verify:fixtures": "npm run build:fixtures && node scripts/verify-conformance-fixtures.mjs",
|
|
81
87
|
"verify:package": "npm run build && node scripts/verify-package.mjs",
|
|
88
|
+
"verify:package:windows": "npm run build && node scripts/verify-windows-package.mjs",
|
|
89
|
+
"probe:windows-capabilities": "npm run build && node scripts/windows-capabilities.mjs",
|
|
82
90
|
"verify:published": "node scripts/verify-published-package.mjs",
|
|
83
91
|
"config:print": "node scripts/print-mcp-config.mjs",
|
|
84
|
-
"docs:generate": "npm run build && node scripts/generate-product-catalog.mjs && typedoc && node scripts/generate-error-schema.mjs",
|
|
85
|
-
"docs:check": "node scripts/generate-package-metadata.mjs --check && npm run build && node scripts/generate-product-catalog.mjs --check && node scripts/check-doc-facts.mjs && node scripts/check-typedoc.mjs && node scripts/generate-error-schema.mjs --check",
|
|
92
|
+
"docs:generate": "npm run build && node scripts/generate-skill-metadata.mjs && node scripts/generate-product-catalog.mjs && typedoc && node scripts/generate-error-schema.mjs",
|
|
93
|
+
"docs:check": "node scripts/generate-package-metadata.mjs --check && npm run build && node scripts/generate-skill-metadata.mjs --check && node scripts/generate-product-catalog.mjs --check && node scripts/check-doc-facts.mjs && node scripts/check-typedoc.mjs && node scripts/generate-error-schema.mjs --check",
|
|
86
94
|
"docs:error-schema": "npm run build && node scripts/generate-error-schema.mjs",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
95
|
+
"prepack": "npm run deps:check && node scripts/generate-skill-metadata.mjs --check",
|
|
96
|
+
"prepublishOnly": "npm run deps:check && node scripts/generate-skill-metadata.mjs --check",
|
|
97
|
+
"prepare": "npm run build && husky"
|
|
89
98
|
},
|
|
90
99
|
"lint-staged": {
|
|
91
100
|
"*.{ts,mjs,json,md,yml,yaml}": "prettier --write",
|
|
@@ -94,8 +103,10 @@
|
|
|
94
103
|
"dependencies": {
|
|
95
104
|
"@babel/parser": "8.0.4",
|
|
96
105
|
"@babel/types": "8.0.4",
|
|
106
|
+
"@clack/prompts": "1.7.0",
|
|
97
107
|
"@electron/asar": "4.2.0",
|
|
98
108
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
109
|
+
"@lydell/node-pty": "1.1.0",
|
|
99
110
|
"@modelcontextprotocol/server": "2.0.0-beta.4",
|
|
100
111
|
"@xterm/addon-serialize": "0.14.0",
|
|
101
112
|
"@xterm/headless": "6.0.0",
|
|
@@ -107,7 +118,6 @@
|
|
|
107
118
|
"ignore": "7.0.6",
|
|
108
119
|
"incur": "0.4.13",
|
|
109
120
|
"isomorphic-git": "1.38.7",
|
|
110
|
-
"node-pty": "1.1.0",
|
|
111
121
|
"pino": "9.14.0",
|
|
112
122
|
"plist": "5.0.0",
|
|
113
123
|
"semver": "7.8.5",
|
|
@@ -133,8 +143,5 @@
|
|
|
133
143
|
"typedoc": "0.28.20",
|
|
134
144
|
"typescript": "5.9.3",
|
|
135
145
|
"vitest": "4.1.10"
|
|
136
|
-
},
|
|
137
|
-
"allowScripts": {
|
|
138
|
-
"node-pty@1.1.0": true
|
|
139
146
|
}
|
|
140
147
|
}
|
package/scripts/rea.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { dirname, resolve } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
7
7
|
// Route production MCP before importing Incur. Incur owns registration helpers
|
|
8
|
-
// such as `mcp add`, while only dist/main.js may serve the
|
|
8
|
+
// such as `mcp add`, while only dist/main.js may serve the stdio tool catalog.
|
|
9
9
|
const args = process.argv.slice(2);
|
|
10
10
|
const { default: packageJson } = await import("../package.json", {
|
|
11
11
|
with: { type: "json" },
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
description: Reverse engineer
|
|
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.
|
|
4
4
|
metadata:
|
|
5
|
-
version: "
|
|
6
|
-
tool_count:
|
|
5
|
+
version: "22"
|
|
6
|
+
tool_count: 95
|
|
7
|
+
catalog_digest: "e0c341749f488a869b62ab9b48c9236c60c91317ac60c8427f12a830cb900ae0"
|
|
7
8
|
---
|
|
8
9
|
|
|
9
10
|
# REA
|
|
@@ -35,19 +36,87 @@ Electron `file://` pages use `list_electron_targets` and
|
|
|
35
36
|
filesystem-root authority. Never claim that Electron inspection invoked IPC,
|
|
36
37
|
evaluated renderer JavaScript, navigated, or escaped an approved root.
|
|
37
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
|
+
|
|
38
94
|
## Understand the request
|
|
39
95
|
|
|
40
96
|
Identify the app and what the user wants to understand or build. Do not ask for information they already provided.
|
|
41
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
|
+
|
|
42
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.
|
|
43
109
|
|
|
44
110
|
Notes is only a documentation example. Never select an app unless the user names it or confirms it.
|
|
45
111
|
|
|
46
112
|
## Ensure REA is ready
|
|
47
113
|
|
|
48
|
-
|
|
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`.
|
|
49
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.
|
|
50
|
-
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`.
|
|
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`.
|
|
51
120
|
4. If macOS or an installer requests human input, tell the user exactly what needs attention. After they finish, rerun setup and doctor.
|
|
52
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.
|
|
53
122
|
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { spawn } from "node:child_process";
|
|
4
|
-
|
|
5
|
-
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
6
|
-
const child = spawn(npm, ["rebuild", "node-pty"], {
|
|
7
|
-
stdio: "inherit",
|
|
8
|
-
env: { ...process.env, npm_config_build_from_source: "true" },
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
child.once("error", (error) => {
|
|
12
|
-
console.error(`Unable to rebuild node-pty: ${error.message}`);
|
|
13
|
-
process.exitCode = 1;
|
|
14
|
-
});
|
|
15
|
-
child.once("exit", (code, signal) => {
|
|
16
|
-
if (signal !== null) {
|
|
17
|
-
console.error(`node-pty rebuild terminated by ${signal}`);
|
|
18
|
-
process.exitCode = 1;
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
process.exitCode = code ?? 1;
|
|
22
|
-
});
|