rea-agents 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -10
- package/dist/application/ApplicationWorkflowEvidenceResolver.js +162 -0
- package/dist/application/ArtifactExtraction.js +5 -1
- package/dist/application/ArtifactGraphConstruction.js +3 -15
- package/dist/application/ArtifactInventory/classify.js +5 -1
- package/dist/application/ArtifactInventory/reader.js +2 -0
- package/dist/application/BinarySession.js +9 -2
- package/dist/application/BinarySessionStatus.js +40 -1
- package/dist/application/CapabilityInventory.js +26 -3
- package/dist/application/CommandShimReplay.js +6 -3
- package/dist/application/CompositeProvider.js +5 -2
- package/dist/application/DirectAnalysis.js +1 -20
- package/dist/application/DirectAnalysisStatus.js +83 -0
- package/dist/application/Doctor.js +34 -25
- package/dist/application/DoctorDiagnostics.js +1 -4
- package/dist/application/DoctorProjection.js +43 -0
- package/dist/application/DoctorScope.js +102 -0
- package/dist/application/EvidenceReferenceResolver.js +26 -0
- package/dist/application/JavaScriptApplicationEvidence.js +1 -1
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +10 -1
- package/dist/application/JavaScriptApplicationService.js +3 -2
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +26 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +49 -1
- package/dist/application/JavaScriptArtifactReconstruction.js +7 -0
- package/dist/application/JavaScriptModuleRelationships.js +25 -1
- package/dist/application/JavaScriptReturnShapeProjection.js +111 -0
- package/dist/application/JavaScriptSemanticGraphBuilder.js +294 -0
- package/dist/application/JavaScriptSemanticGraphConstruction.js +144 -0
- package/dist/application/JavaScriptSemanticGraphEvidence.js +86 -0
- package/dist/application/JavaScriptSemanticGraphFlowProjection.js +72 -0
- package/dist/application/JavaScriptSemanticGraphProjection.js +33 -0
- package/dist/application/JavaScriptSemanticTraceService.js +45 -0
- package/dist/application/LoopbackReplay.js +277 -133
- package/dist/application/LoopbackReplayRecorder.js +101 -0
- package/dist/application/PermissionAuthority.js +7 -3
- package/dist/application/ProcessCaptureEnvironment.js +26 -0
- package/dist/application/ProcessCaptureJournal.js +95 -0
- package/dist/application/ProcessCaptureLifecycle.js +25 -13
- package/dist/application/ProcessCheckpoints.js +35 -4
- package/dist/application/ProcessCli.js +26 -4
- package/dist/application/ProcessHarness.js +64 -83
- package/dist/application/ProcessNormalization.js +9 -2
- package/dist/application/ProcessReactiveCoordinator.js +225 -0
- package/dist/application/ProcessReactiveEffects.js +141 -0
- package/dist/application/ProcessReactiveHarness.js +85 -0
- package/dist/application/ProcessReactiveObservations.js +105 -0
- package/dist/application/ProcessSampling.js +2 -0
- package/dist/application/SessionProviderRouter.js +7 -6
- package/dist/application/Setup.js +11 -10
- package/dist/application/SetupPlan.js +1 -1
- package/dist/application/SetupRegistrationEnvironment.js +12 -0
- package/dist/application/TerminalRenderer.js +3 -1
- package/dist/browser/CdpEndpoint.js +37 -4
- package/dist/catalogIdentity.js +16 -7
- package/dist/cli/coreAnalysisCommands.js +34 -2
- package/dist/cli/javascriptApplicationAnalysis.js +19 -0
- package/dist/cli/setupCommands.js +81 -32
- package/dist/cli/utilityCommands.js +10 -2
- package/dist/cliApplicationCommands.js +79 -16
- package/dist/cliCommandNames.js +3 -0
- package/dist/cliElectronCommands.js +23 -33
- package/dist/cliObservationOptions.js +1 -1
- package/dist/cliOutput.js +56 -0
- package/dist/cliProcessCommands.js +32 -1
- package/dist/cliSetup.js +30 -21
- package/dist/contracts/applicationToolContracts.js +54 -7
- package/dist/contracts/applicationWorkflowInputContracts.js +119 -0
- package/dist/contracts/electronToolContracts.js +53 -32
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +32 -9
- package/dist/contracts/processCaptureExample.js +1 -0
- package/dist/contracts/replayMachineExample.js +37 -0
- package/dist/contracts/toolContractExamples.js +2 -0
- package/dist/contracts/toolContracts.js +5 -1
- package/dist/contracts/toolEffects.js +3 -0
- package/dist/contracts/toolOutputSchemaGroups.js +2 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +43 -0
- package/dist/doctorRuntime.js +41 -0
- package/dist/domain/analysisErrorPresentation.js +5 -3
- package/dist/domain/analysisErrorProjection.js +7 -1
- package/dist/domain/analysisSnapshot.js +2 -0
- package/dist/domain/artifactGraph.js +2 -0
- package/dist/domain/binaryTarget.js +3 -6
- package/dist/domain/changedBehavior.js +5 -4
- package/dist/domain/completionLedgerGeneration.js +190 -0
- package/dist/domain/errors.js +4 -2
- package/dist/domain/evidence.js +2 -0
- package/dist/domain/evidenceCompletionLedger.js +113 -0
- package/dist/domain/hopperStartupFailure.js +9 -0
- package/dist/domain/javascriptApplicationAnalysis.js +44 -2
- package/dist/domain/javascriptExportShapeComparison.js +145 -0
- package/dist/domain/javascriptExportShapeComparisonIdentity.js +11 -0
- package/dist/domain/javascriptExportShapeComparisonSchemas.js +277 -0
- package/dist/domain/javascriptExportShapeSelection.js +132 -0
- package/dist/domain/javascriptExportShapeVariants.js +272 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +2 -2
- package/dist/domain/javascriptSemanticAnalysis.js +17 -36
- package/dist/domain/javascriptSemanticCallResolution.js +129 -0
- package/dist/domain/javascriptSemanticCalls.js +269 -0
- package/dist/domain/javascriptSemanticGraph.js +356 -0
- package/dist/domain/javascriptSemanticGraphSchemas.js +329 -0
- package/dist/domain/javascriptSemanticGraphSerialization.js +23 -0
- package/dist/domain/javascriptSemanticIr.js +14 -1
- package/dist/domain/javascriptSemanticPrimitives.js +36 -0
- package/dist/domain/javascriptSemanticProjection.js +36 -4
- package/dist/domain/javascriptSemanticProvenance.js +29 -0
- package/dist/domain/javascriptSemanticQuery.js +294 -0
- package/dist/domain/javascriptSemanticQueryAssessment.js +74 -0
- package/dist/domain/javascriptSemanticQueryIdentity.js +86 -0
- package/dist/domain/javascriptSemanticQueryRelations.js +15 -0
- package/dist/domain/javascriptSemanticQuerySchemas.js +188 -0
- package/dist/domain/javascriptSemanticReturns.js +187 -0
- package/dist/domain/javascriptSemanticState.js +32 -0
- package/dist/domain/javascriptSemanticTraceSchemas.js +14 -0
- package/dist/domain/javascriptSemanticValues.js +54 -70
- package/dist/domain/processCapture.js +100 -0
- package/dist/domain/processCaptureReactiveValidation.js +175 -0
- package/dist/domain/processCaptureValidation.js +103 -12
- package/dist/domain/processComparison.js +78 -25
- package/dist/domain/processObservation.js +162 -0
- package/dist/domain/processReactiveCheckpointDataflow.js +32 -0
- package/dist/domain/processReactiveMatching.js +210 -0
- package/dist/domain/processReactiveRuntime.js +120 -0
- package/dist/domain/processReactiveScenario.js +361 -0
- package/dist/domain/processReactiveScenarioPreflight.js +120 -0
- package/dist/domain/processReactiveTransition.js +161 -0
- package/dist/domain/processScenario.js +33 -0
- package/dist/domain/processTraceComparison.js +43 -0
- package/dist/domain/processTraceDimensionProjection.js +50 -0
- package/dist/domain/processTraceEvaluation.js +312 -0
- package/dist/domain/processTraceSpecification.js +373 -0
- package/dist/domain/reconstructionVerification.js +5 -4
- package/dist/domain/replayMachine.js +18 -2
- package/dist/domain/replayMachineRun.js +216 -0
- package/dist/domain/replayMachineRuntime.js +88 -9
- package/dist/domain/staticRuntimeCorrelation.js +4 -2
- package/dist/domain/zipPackageFormat.js +20 -0
- package/dist/evaluation/CodexAgentEval.js +24 -0
- package/dist/generatedPackageMetadata.js +1 -1
- package/dist/ghidra/GhidraClient.js +13 -2
- package/dist/ghidra/GhidraDiagnostics.js +1 -0
- package/dist/ghidra/GhidraLauncher.js +7 -3
- package/dist/ghidra/GhidraProvider.js +8 -1
- package/dist/hopper/BridgeLauncher.js +56 -14
- package/dist/hopper/HopperClient.js +23 -10
- package/dist/hopper/HopperDiagnostics.js +14 -0
- package/dist/hopper/HopperProcessDiagnostic.js +14 -0
- package/dist/hopper/HopperProvider.js +8 -1
- package/dist/hopper/LinuxPrivateDisplayDiagnostic.js +72 -0
- package/dist/hopper/LinuxPrivateDisplayProbe.js +217 -0
- package/dist/main/transport.js +2 -0
- package/dist/mcpDoctor.js +310 -0
- package/dist/native/NativeMacOSProvider.js +1 -0
- package/dist/process/ProcessOwnership.js +200 -53
- package/dist/process/ProviderRunLineage.js +21 -0
- package/dist/server/createServer.js +4 -1
- package/dist/server/javascriptApplicationResult.js +22 -1
- package/dist/server/registerApplicationTools/characterization.js +3 -3
- package/dist/server/registerApplicationTools/compareExportShapes.js +37 -0
- package/dist/server/registerApplicationTools/compareVersions.js +12 -6
- package/dist/server/registerApplicationTools/controlledReplay.js +2 -2
- package/dist/server/registerApplicationTools/coverage.js +3 -3
- package/dist/server/registerApplicationTools/helpers.js +37 -25
- package/dist/server/registerApplicationTools/traceFeature.js +9 -5
- package/dist/server/registerApplicationTools/traceSemantics.js +30 -0
- package/dist/server/registerApplicationTools.js +4 -0
- package/dist/server/registerEvidenceResources.js +5 -1
- package/dist/server/registerProcessComparisonTool.js +17 -7
- package/dist/server/registerReplayMachineTool.js +20 -0
- package/dist/server/registerSessionTools.js +12 -7
- package/dist/server/sessionAvailabilityPolicy.js +2 -1
- package/dist/serverIdentity.js +19 -0
- package/package.json +62 -30
- package/scripts/hopper-demo-x11.py +459 -61
- package/scripts/prepack.mjs +55 -0
- package/scripts/prepare.mjs +28 -0
- package/scripts/rea.mjs +26 -5
- package/skills/reverse-engineer-anything/SKILL.md +4 -3
- package/skills/reverse-engineer-anything/references/javascript-applications.md +10 -0
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "incur";
|
|
2
|
-
import { runDoctor } from "../application/Doctor.js";
|
|
3
|
-
import { runSetup, systemSetupHost } from "../application/Setup.js";
|
|
2
|
+
import { DOCTOR_PROVIDER_IDS, runDoctor, } from "../application/Doctor.js";
|
|
3
|
+
import { runSetup, systemSetupHost, } from "../application/Setup.js";
|
|
4
4
|
import { runUninstall } from "../application/Uninstall.js";
|
|
5
5
|
import { runUpgrade, systemUpgradeHost } from "../application/Upgrade.js";
|
|
6
6
|
import { conciseSetupResult, confirmInteractiveSetup, renderInteractiveSetupResult, renderSetupProgress, } from "../cliSetup.js";
|
|
@@ -8,7 +8,19 @@ import { PRODUCT_IDENTITY } from "../identity.js";
|
|
|
8
8
|
import { logCliCommand } from "../cliLogging.js";
|
|
9
9
|
import { createSystemDoctorHost } from "../doctorRuntime.js";
|
|
10
10
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
11
|
+
import { SUPPORTED_CLIENT_DEFINITIONS } from "../application/SupportedClients.js";
|
|
12
|
+
import { projectDoctorReport } from "../application/DoctorProjection.js";
|
|
13
|
+
const supportedClientIds = SUPPORTED_CLIENT_DEFINITIONS.map(({ name }) => name);
|
|
14
|
+
const supportedClientSchema = z
|
|
15
|
+
.string()
|
|
16
|
+
.refine((candidate) => supportedClientIds.some((name) => name === candidate), "Unsupported agent integration");
|
|
17
|
+
/** Register setup, doctor, uninstall, and upgrade CLI commands. */
|
|
11
18
|
export const registerSetupCommands = (cli, logger) => {
|
|
19
|
+
registerSetupCommand(cli, logger);
|
|
20
|
+
registerDoctorCommand(cli, logger);
|
|
21
|
+
registerMaintenanceCommands(cli, logger);
|
|
22
|
+
};
|
|
23
|
+
const registerSetupCommand = (cli, logger) => {
|
|
12
24
|
cli.command(CLI_COMMANDS.setup, {
|
|
13
25
|
description: "Install requirements and configure agents",
|
|
14
26
|
outputPolicy: "agent-only",
|
|
@@ -22,14 +34,7 @@ export const registerSetupCommands = (cli, logger) => {
|
|
|
22
34
|
.default(false)
|
|
23
35
|
.describe("Also approve Hopper installation with --yes"),
|
|
24
36
|
client: z
|
|
25
|
-
.array(
|
|
26
|
-
"claude_code",
|
|
27
|
-
"claude_desktop",
|
|
28
|
-
"codex",
|
|
29
|
-
"cursor",
|
|
30
|
-
"gemini_cli",
|
|
31
|
-
"windsurf",
|
|
32
|
-
]))
|
|
37
|
+
.array(supportedClientSchema)
|
|
33
38
|
.default([])
|
|
34
39
|
.describe("Agent integration to configure; repeat for multiple agents"),
|
|
35
40
|
allDetected: z
|
|
@@ -48,17 +53,41 @@ export const registerSetupCommands = (cli, logger) => {
|
|
|
48
53
|
.boolean()
|
|
49
54
|
.default(false)
|
|
50
55
|
.describe("Use sequential accessible setup prompts"),
|
|
56
|
+
detail: z
|
|
57
|
+
.enum(["summary", "full"])
|
|
58
|
+
.default("summary")
|
|
59
|
+
.describe("Summary or complete setup and doctor diagnostics"),
|
|
51
60
|
}),
|
|
52
61
|
alias: { yes: "y" },
|
|
53
|
-
run: ({ options, formatExplicit
|
|
62
|
+
run: ({ options, formatExplicit }) => logCliCommand(logger, "setup", () => runSetupCommand({ options, formatExplicit })),
|
|
54
63
|
});
|
|
64
|
+
};
|
|
65
|
+
const registerDoctorCommand = (cli, logger) => {
|
|
55
66
|
cli.command(CLI_COMMANDS.doctor, {
|
|
56
67
|
description: "Check whether REA is ready",
|
|
57
68
|
options: z.object({
|
|
58
69
|
target: z.string().optional().describe("Optional app path to check"),
|
|
70
|
+
client: z
|
|
71
|
+
.array(supportedClientSchema)
|
|
72
|
+
.default([])
|
|
73
|
+
.describe("Agent registration whose readiness is required; repeatable"),
|
|
74
|
+
provider: z
|
|
75
|
+
.array(z.enum(DOCTOR_PROVIDER_IDS))
|
|
76
|
+
.default([])
|
|
77
|
+
.describe("Deep-analysis provider whose readiness is required"),
|
|
78
|
+
skill: z
|
|
79
|
+
.boolean()
|
|
80
|
+
.optional()
|
|
81
|
+
.describe("Require the installed REA skill identity to be aligned"),
|
|
82
|
+
detail: z
|
|
83
|
+
.enum(["summary", "full"])
|
|
84
|
+
.default("summary")
|
|
85
|
+
.describe("Summary or complete doctor diagnostics"),
|
|
59
86
|
}),
|
|
60
|
-
run: ({ options }) => logCliCommand(logger, "doctor", () => runDoctor(options.target, createSystemDoctorHost())),
|
|
87
|
+
run: ({ options }) => logCliCommand(logger, "doctor", () => runDoctor(options.target, createSystemDoctorHost(), doctorScope(options)).then((report) => projectDoctorReport(report, options.detail))),
|
|
61
88
|
});
|
|
89
|
+
};
|
|
90
|
+
const registerMaintenanceCommands = (cli, logger) => {
|
|
62
91
|
cli.command(CLI_COMMANDS.uninstall, {
|
|
63
92
|
description: "Remove REA-owned agent configuration and skill files",
|
|
64
93
|
options: z.object({
|
|
@@ -77,37 +106,57 @@ export const registerSetupCommands = (cli, logger) => {
|
|
|
77
106
|
};
|
|
78
107
|
const runSetupCommand = async (input) => {
|
|
79
108
|
const { options } = input;
|
|
80
|
-
const interactive =
|
|
81
|
-
!options.dryRun &&
|
|
82
|
-
!input.formatExplicit &&
|
|
83
|
-
process.stdin.isTTY === true &&
|
|
84
|
-
process.stderr.isTTY === true;
|
|
109
|
+
const interactive = setupIsInteractive(options, input.formatExplicit);
|
|
85
110
|
const hasExplicitScope = setupHasExplicitScope(options);
|
|
86
111
|
if (options.yes && !hasExplicitScope)
|
|
87
112
|
process.stderr.write("! Implicit `rea setup --yes` scope is deprecated; use `--all-detected` to retain it.\n");
|
|
113
|
+
const result = await runSetup(setupRunOptions(input, interactive, hasExplicitScope), systemSetupHost(createSystemDoctorHost()), interactive
|
|
114
|
+
? (actions) => confirmInteractiveSetup(actions, options.accessible)
|
|
115
|
+
: undefined);
|
|
116
|
+
if (interactive)
|
|
117
|
+
renderInteractiveSetupResult(result);
|
|
118
|
+
return options.detail === "full" ? result : conciseSetupResult(result);
|
|
119
|
+
};
|
|
120
|
+
const setupRunOptions = (input, interactive, hasExplicitScope) => {
|
|
121
|
+
const { options } = input;
|
|
88
122
|
const agentIntegrationSelected = options.allDetected || options.client.length > 0;
|
|
89
|
-
const
|
|
123
|
+
const hasSelectedClients = hasExplicitScope && !options.allDetected;
|
|
124
|
+
return {
|
|
90
125
|
approved: options.yes && !options.dryRun,
|
|
91
126
|
installHopper: options.installHopper,
|
|
92
127
|
structured: input.formatExplicit || options.dryRun,
|
|
93
128
|
proposeHopper: !hasExplicitScope || options.installHopper,
|
|
94
|
-
...(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
? {}
|
|
99
|
-
: {
|
|
100
|
-
installSkill: options.skill ?? agentIntegrationSelected,
|
|
101
|
-
}),
|
|
129
|
+
...(hasSelectedClients ? { clientIds: options.client } : {}),
|
|
130
|
+
...(hasExplicitScope
|
|
131
|
+
? { installSkill: options.skill ?? agentIntegrationSelected }
|
|
132
|
+
: {}),
|
|
102
133
|
...(interactive ? { onProgress: renderSetupProgress } : {}),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
134
|
+
...(hasSelectedClients
|
|
135
|
+
? {
|
|
136
|
+
readinessScope: {
|
|
137
|
+
clients: options.client,
|
|
138
|
+
providers: options.installHopper ? ["hopper"] : [],
|
|
139
|
+
skill: options.skill ?? agentIntegrationSelected,
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
: {}),
|
|
143
|
+
};
|
|
109
144
|
};
|
|
145
|
+
const setupIsInteractive = (options, formatExplicit) => !options.yes &&
|
|
146
|
+
!options.dryRun &&
|
|
147
|
+
!formatExplicit &&
|
|
148
|
+
process.stdin.isTTY === true &&
|
|
149
|
+
process.stderr.isTTY === true;
|
|
110
150
|
const setupHasExplicitScope = (options) => options.allDetected ||
|
|
111
151
|
options.client.length > 0 ||
|
|
112
152
|
options.skill !== undefined ||
|
|
113
153
|
options.installHopper;
|
|
154
|
+
const doctorScope = (options) => options.client.length === 0 &&
|
|
155
|
+
options.provider.length === 0 &&
|
|
156
|
+
options.skill === undefined
|
|
157
|
+
? undefined
|
|
158
|
+
: {
|
|
159
|
+
clients: options.client,
|
|
160
|
+
providers: options.provider,
|
|
161
|
+
skill: options.skill === true,
|
|
162
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "incur";
|
|
2
|
-
import { runProviderAnalysis,
|
|
2
|
+
import { runCapabilityStatus, runProviderAnalysis, runProviderStatus, } from "../application/DirectAnalysis.js";
|
|
3
3
|
import { importReferenceSource } from "../application/ReferenceSourceImport.js";
|
|
4
4
|
import { projectReferenceSourceImportError } from "../application/ReferenceSourceImportTypes.js";
|
|
5
5
|
import { loadConfiguredPermissionAuthority } from "../application/PermissionConfiguration.js";
|
|
@@ -22,7 +22,15 @@ const registerCapabilityCommands = (cli, logger) => {
|
|
|
22
22
|
description: command === "capabilities"
|
|
23
23
|
? "List provider capabilities and side effects"
|
|
24
24
|
: "List configured analysis providers",
|
|
25
|
-
|
|
25
|
+
options: z.object({
|
|
26
|
+
detail: z
|
|
27
|
+
.enum(["summary", "full"])
|
|
28
|
+
.default("summary")
|
|
29
|
+
.describe("Summary or complete provider descriptors"),
|
|
30
|
+
}),
|
|
31
|
+
run: ({ options }) => logCliCommand(logger, command, () => command === CLI_COMMANDS.providers
|
|
32
|
+
? runProviderStatus(logger, options.detail)
|
|
33
|
+
: runCapabilityStatus(logger, options.detail)),
|
|
26
34
|
});
|
|
27
35
|
}
|
|
28
36
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Cli, z } from "incur";
|
|
2
|
-
import {
|
|
2
|
+
import { compareApplicationVersionsEvidenceValidated, compareJavaScriptExportShapesEvidenceValidated, traceApplicationFeatureEvidenceValidated, } from "./application/JavaScriptApplicationWorkflowService.js";
|
|
3
|
+
import { traceJavaScriptSemanticsEvidenceValidated } from "./application/JavaScriptSemanticTraceService.js";
|
|
4
|
+
import { resolveCompareApplicationVersionsRequest, resolveCompareJavaScriptExportShapesRequest, resolveTraceApplicationFeatureRequest, resolveTraceJavaScriptSemanticsRequest, } from "./application/ApplicationWorkflowEvidenceResolver.js";
|
|
5
|
+
import { readEvidenceBundle } from "./application/EvidenceBundleFiles.js";
|
|
3
6
|
import { runControlledReplay } from "./application/JavaScriptReplayService.js";
|
|
4
7
|
import { executeNodeCharacterization, prepareNodeCharacterization, } from "./application/NodeRuntimeCharacterizationService.js";
|
|
5
8
|
import { commitReconstructionCoverage, queryReconstructionCoverage, reconstructionCoverageCommitInputSchema, reconstructionCoverageQueryInputSchema, } from "./application/ReconstructionCoverageService.js";
|
|
@@ -19,14 +22,32 @@ export const registerApplicationCommands = (cli, logger) => {
|
|
|
19
22
|
logger,
|
|
20
23
|
name: CLI_COMMANDS.traceApplicationFeature,
|
|
21
24
|
description: "Trace a typed seed through authenticated application Evidence JSON",
|
|
22
|
-
|
|
25
|
+
resolveInput: resolveTraceApplicationFeatureRequest,
|
|
26
|
+
workflow: traceApplicationFeatureEvidenceValidated,
|
|
27
|
+
});
|
|
28
|
+
registerJsonCommand({
|
|
29
|
+
cli,
|
|
30
|
+
logger,
|
|
31
|
+
name: CLI_COMMANDS.traceJavaScriptSemantics,
|
|
32
|
+
description: "Trace bounded static semantic relations through authenticated application Evidence",
|
|
33
|
+
resolveInput: resolveTraceJavaScriptSemanticsRequest,
|
|
34
|
+
workflow: traceJavaScriptSemanticsEvidenceValidated,
|
|
23
35
|
});
|
|
24
36
|
registerJsonCommand({
|
|
25
37
|
cli,
|
|
26
38
|
logger,
|
|
27
39
|
name: CLI_COMMANDS.compareApplicationVersions,
|
|
28
40
|
description: "Compare two authenticated JavaScript Application Graph versions",
|
|
29
|
-
|
|
41
|
+
resolveInput: resolveCompareApplicationVersionsRequest,
|
|
42
|
+
workflow: compareApplicationVersionsEvidenceValidated,
|
|
43
|
+
});
|
|
44
|
+
registerJsonCommand({
|
|
45
|
+
cli,
|
|
46
|
+
logger,
|
|
47
|
+
name: CLI_COMMANDS.compareJavaScriptExportShapes,
|
|
48
|
+
description: "Compare exact static JavaScript export return shapes without execution",
|
|
49
|
+
resolveInput: resolveCompareJavaScriptExportShapesRequest,
|
|
50
|
+
workflow: compareJavaScriptExportShapesEvidenceValidated,
|
|
30
51
|
});
|
|
31
52
|
cli.command(CLI_COMMANDS.runControlledReplay, {
|
|
32
53
|
description: "Plan or execute an approved extracted-module replay in the Linux sandbox",
|
|
@@ -138,13 +159,10 @@ const registerCoverageCommands = (cli, logger) => {
|
|
|
138
159
|
});
|
|
139
160
|
};
|
|
140
161
|
const configuredAuthority = async () => {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return authority.ok
|
|
146
|
-
? { ok: true, config: config.value, authority: authority.value }
|
|
147
|
-
: { ok: false, error: projectAnalysisError(authority.error) };
|
|
162
|
+
const configured = await loadConfiguredAuthority();
|
|
163
|
+
return configured.ok
|
|
164
|
+
? configured
|
|
165
|
+
: { ok: false, error: projectAnalysisError(configured.error) };
|
|
148
166
|
};
|
|
149
167
|
const replayDependencies = (config, authority) => ({
|
|
150
168
|
policy: config.javascriptReplayPolicy,
|
|
@@ -152,25 +170,70 @@ const replayDependencies = (config, authority) => ({
|
|
|
152
170
|
runner: new LinuxJavaScriptReplayRunner(),
|
|
153
171
|
authority,
|
|
154
172
|
});
|
|
155
|
-
const registerJsonCommand = ({ cli, logger, name, description, workflow, }) => {
|
|
173
|
+
const registerJsonCommand = ({ cli, logger, name, description, resolveInput, workflow, }) => {
|
|
156
174
|
cli.command(name, {
|
|
157
175
|
description,
|
|
158
176
|
args: z.object({
|
|
159
177
|
inputJson: z.string().describe("Inline workflow JSON or JSON file path"),
|
|
160
178
|
}),
|
|
161
|
-
|
|
179
|
+
options: z.object({
|
|
180
|
+
evidenceBundle: z
|
|
181
|
+
.string()
|
|
182
|
+
.optional()
|
|
183
|
+
.describe("Authorized Evidence bundle used to resolve Evidence IDs"),
|
|
184
|
+
}),
|
|
185
|
+
run: ({ args, options }) => logCliCommand(logger, name, async () => {
|
|
162
186
|
const input = await parseCliJsonInput(args.inputJson, name);
|
|
163
187
|
if (!input.ok)
|
|
164
188
|
return input.error;
|
|
165
|
-
const
|
|
189
|
+
const lookup = await loadEvidenceLookup(options.evidenceBundle, name);
|
|
190
|
+
if (!lookup.ok)
|
|
191
|
+
return {
|
|
192
|
+
error: "Application workflow failed",
|
|
193
|
+
...projectAnalysisError(lookup.error),
|
|
194
|
+
};
|
|
195
|
+
const resolved = resolveInput(input.value, lookup.value);
|
|
196
|
+
if (!resolved.ok)
|
|
197
|
+
return {
|
|
198
|
+
error: "Application workflow failed",
|
|
199
|
+
...projectAnalysisError(resolved.error),
|
|
200
|
+
};
|
|
201
|
+
const result = workflow(resolved.value);
|
|
166
202
|
return result.ok
|
|
167
203
|
? result.value
|
|
168
204
|
: {
|
|
169
205
|
error: "Application workflow failed",
|
|
170
|
-
...projectAnalysisError(result.error
|
|
171
|
-
? result.error
|
|
172
|
-
: new AnalysisInputError(name)),
|
|
206
|
+
...projectAnalysisError(result.error),
|
|
173
207
|
};
|
|
174
208
|
}),
|
|
175
209
|
});
|
|
176
210
|
};
|
|
211
|
+
const loadEvidenceLookup = async (bundlePath, operation) => {
|
|
212
|
+
if (bundlePath === undefined)
|
|
213
|
+
return { ok: true, value: undefined };
|
|
214
|
+
const configured = await loadConfiguredAuthority();
|
|
215
|
+
if (!configured.ok)
|
|
216
|
+
return configured;
|
|
217
|
+
const authorized = await authorizeRootPermission(configured.authority, {
|
|
218
|
+
capability: "evidence_read",
|
|
219
|
+
roots: [bundlePath],
|
|
220
|
+
access: "read",
|
|
221
|
+
operation,
|
|
222
|
+
});
|
|
223
|
+
if (!authorized.ok)
|
|
224
|
+
return authorized;
|
|
225
|
+
const loaded = await readEvidenceBundle(bundlePath, configured.config.evidenceFilePolicy);
|
|
226
|
+
if (!loaded.ok)
|
|
227
|
+
return loaded;
|
|
228
|
+
const records = new Map(loaded.value.records.map((record) => [record.evidence_id, record]));
|
|
229
|
+
return { ok: true, value: (evidenceId) => records.get(evidenceId) };
|
|
230
|
+
};
|
|
231
|
+
const loadConfiguredAuthority = async () => {
|
|
232
|
+
const config = parseConfig(process.env);
|
|
233
|
+
if (!config.ok)
|
|
234
|
+
return config;
|
|
235
|
+
const authority = await loadConfiguredPermissionAuthority(config.value);
|
|
236
|
+
return authority.ok
|
|
237
|
+
? { ok: true, config: config.value, authority: authority.value }
|
|
238
|
+
: authority;
|
|
239
|
+
};
|
package/dist/cliCommandNames.js
CHANGED
|
@@ -49,7 +49,10 @@ export const CLI_COMMANDS = Object.freeze({
|
|
|
49
49
|
analyzeJavaScriptApplication: "analyze-javascript-application",
|
|
50
50
|
reconcileJavaScriptRuntime: "reconcile-javascript-runtime",
|
|
51
51
|
traceApplicationFeature: "trace-application-feature",
|
|
52
|
+
traceJavaScriptSemantics: "trace-javascript-semantics",
|
|
52
53
|
compareApplicationVersions: "compare-application-versions",
|
|
54
|
+
compareJavaScriptExportShapes: "compare-javascript-export-shapes",
|
|
55
|
+
runReplayMachine: "run-replay-machine",
|
|
53
56
|
runControlledReplay: "run-controlled-replay",
|
|
54
57
|
prepareNodeCharacterization: "prepare-node-characterization",
|
|
55
58
|
executeNodeCharacterization: "execute-node-characterization",
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Cli, z } from "incur";
|
|
2
2
|
import { inspectElectronPage, listElectronTargets, } from "./application/ElectronObservationService.js";
|
|
3
|
-
import { analyzeJavaScriptApplication } from "./application/JavaScriptApplicationService.js";
|
|
4
3
|
import { reconcileJavaScriptRuntimeEvidence } from "./application/JavaScriptRuntimeReconciliationService.js";
|
|
5
4
|
import { loadConfiguredPermissionAuthority } from "./application/PermissionConfiguration.js";
|
|
6
5
|
import { CdpElectronProvider } from "./browser/CdpElectronProvider.js";
|
|
7
6
|
import { logCliCommand } from "./cliLogging.js";
|
|
8
7
|
import { parseConfig } from "./config.js";
|
|
9
8
|
import { inspectElectronPageInputSchema, listElectronTargetsInputSchema, } from "./domain/electronObservation.js";
|
|
10
|
-
import { analyzeJavaScriptApplicationInputSchema } from "./domain/javascriptApplicationAnalysis.js";
|
|
11
9
|
import { AnalysisInputError, projectAnalysisError } from "./domain/errors.js";
|
|
12
10
|
import { CLI_COMMANDS } from "./cliCommandNames.js";
|
|
13
11
|
import { parseCliJsonInput } from "./cliJsonInput.js";
|
|
14
12
|
import { electronPageInspectionOptions, javascriptApplicationOptions, } from "./cliObservationOptions.js";
|
|
13
|
+
import { runCliJavaScriptApplicationAnalysis } from "./cli/javascriptApplicationAnalysis.js";
|
|
15
14
|
const scopeOptions = {
|
|
16
15
|
allowedFileRoots: z
|
|
17
16
|
.array(z.string().min(1))
|
|
@@ -134,37 +133,28 @@ const registerJavaScriptApplicationCommand = (cli, logger) => {
|
|
|
134
133
|
path: z.string().describe("Absolute ASAR or extracted application path"),
|
|
135
134
|
}),
|
|
136
135
|
options: javascriptApplicationOptions,
|
|
137
|
-
run: ({ args, options }) => logCliCommand(logger, CLI_COMMANDS.analyzeJavaScriptApplication,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
max_source_map_sources: options.maxSourceMapSources,
|
|
160
|
-
max_parse_milliseconds: options.maxParseMilliseconds,
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
if (!parsed.success)
|
|
164
|
-
return inputError("analyze_javascript_application");
|
|
165
|
-
const result = await analyzeJavaScriptApplication(context.authority, parsed.data);
|
|
166
|
-
return result.ok ? result.value : cliError(result.error);
|
|
167
|
-
}),
|
|
136
|
+
run: ({ args, options }) => logCliCommand(logger, CLI_COMMANDS.analyzeJavaScriptApplication, () => runCliJavaScriptApplicationAnalysis({
|
|
137
|
+
input_path: args.path,
|
|
138
|
+
approved: options.approved,
|
|
139
|
+
format: options.artifactFormat,
|
|
140
|
+
source_map_read_approved: options.sourceMapReadApproved,
|
|
141
|
+
limits: {
|
|
142
|
+
max_entries: options.maxEntries,
|
|
143
|
+
max_total_artifact_bytes: options.maxTotalArtifactBytes,
|
|
144
|
+
max_artifact_entry_bytes: options.maxArtifactEntryBytes,
|
|
145
|
+
max_compression_ratio: options.maxCompressionRatio,
|
|
146
|
+
max_depth: options.maxDepth,
|
|
147
|
+
max_path_bytes: options.maxPathBytes,
|
|
148
|
+
max_text_files: options.maxTextFiles,
|
|
149
|
+
max_total_text_bytes: options.maxTotalTextBytes,
|
|
150
|
+
max_text_file_bytes: options.maxTextFileBytes,
|
|
151
|
+
max_ast_nodes: options.maxAstNodes,
|
|
152
|
+
max_findings: options.maxFindings,
|
|
153
|
+
max_modules: options.maxModules,
|
|
154
|
+
max_source_map_sources: options.maxSourceMapSources,
|
|
155
|
+
max_parse_milliseconds: options.maxParseMilliseconds,
|
|
156
|
+
},
|
|
157
|
+
})),
|
|
168
158
|
});
|
|
169
159
|
};
|
|
170
160
|
const electronContext = async () => {
|
|
@@ -108,7 +108,7 @@ export const javascriptApplicationOptions = z.object({
|
|
|
108
108
|
.boolean()
|
|
109
109
|
.default(false)
|
|
110
110
|
.describe("Approve reading the application artifact"),
|
|
111
|
-
|
|
111
|
+
artifactFormat: z
|
|
112
112
|
.enum(["auto", "asar", "directory"])
|
|
113
113
|
.default("auto")
|
|
114
114
|
.describe("Application artifact format"),
|
package/dist/cliOutput.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const SAFE_VALIDATION_MESSAGE = "REA could not read the command arguments. Run `rea --help`, correct the arguments, then try again.";
|
|
2
|
+
const UNSUPPORTED_OUTPUT_COMBINATION_MESSAGE = "Token windows cannot preserve structured output. Remove --token-limit/--token-offset and use --filter-output or command pagination.";
|
|
2
3
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
4
|
const validationError = (value) => {
|
|
4
5
|
if (!isRecord(value))
|
|
@@ -9,6 +10,61 @@ const validationError = (value) => {
|
|
|
9
10
|
return value.error.code === "VALIDATION_ERROR" ? value.error : undefined;
|
|
10
11
|
return undefined;
|
|
11
12
|
};
|
|
13
|
+
/** Reject text-window controls that would corrupt a structured document. */
|
|
14
|
+
export const validateCliOutputArguments = (arguments_) => {
|
|
15
|
+
let format = "toon";
|
|
16
|
+
let tokenWindow = false;
|
|
17
|
+
for (let index = 0; index < arguments_.length; index += 1) {
|
|
18
|
+
const argument = arguments_[index];
|
|
19
|
+
if (argument === "--")
|
|
20
|
+
break;
|
|
21
|
+
if (argument === "--json") {
|
|
22
|
+
format = "json";
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (argument === "--format") {
|
|
26
|
+
const value = arguments_[index + 1];
|
|
27
|
+
if (value !== undefined) {
|
|
28
|
+
format = value;
|
|
29
|
+
index += 1;
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (argument?.startsWith("--format=")) {
|
|
34
|
+
format = argument.slice("--format=".length);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (argument === "--token-limit" || argument === "--token-offset") {
|
|
38
|
+
if (arguments_[index + 1] !== undefined) {
|
|
39
|
+
tokenWindow = true;
|
|
40
|
+
index += 1;
|
|
41
|
+
}
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (argument?.startsWith("--token-limit=") ||
|
|
45
|
+
argument?.startsWith("--token-offset="))
|
|
46
|
+
tokenWindow = true;
|
|
47
|
+
}
|
|
48
|
+
if (tokenWindow &&
|
|
49
|
+
(format === "json" || format === "jsonl" || format === "yaml"))
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
format,
|
|
53
|
+
code: "UNSUPPORTED_OUTPUT_COMBINATION",
|
|
54
|
+
message: UNSUPPORTED_OUTPUT_COMBINATION_MESSAGE,
|
|
55
|
+
};
|
|
56
|
+
return { ok: true };
|
|
57
|
+
};
|
|
58
|
+
/** Render one complete structured error before command execution. */
|
|
59
|
+
export const renderCliOutputArgumentError = (error) => {
|
|
60
|
+
const value = {
|
|
61
|
+
ok: false,
|
|
62
|
+
error: { code: error.code, message: error.message },
|
|
63
|
+
};
|
|
64
|
+
if (error.format === "yaml")
|
|
65
|
+
return `ok: false\nerror:\n code: ${error.code}\n message: ${JSON.stringify(error.message)}\n`;
|
|
66
|
+
return `${JSON.stringify(value)}\n`;
|
|
67
|
+
};
|
|
12
68
|
/** Remove validator internals from Incur's caller-visible CLI output. */
|
|
13
69
|
export const sanitizeCliOutput = (output) => {
|
|
14
70
|
const trimmed = output.trimStart();
|
|
@@ -2,8 +2,13 @@ import { Cli, z } from "incur";
|
|
|
2
2
|
import { captureProcessScenarioFile, compareProcessEvidenceFiles, } from "./application/ProcessCli.js";
|
|
3
3
|
import { logCliCommand } from "./cliLogging.js";
|
|
4
4
|
import { CLI_COMMANDS } from "./cliCommandNames.js";
|
|
5
|
+
import { parseCliJsonInput } from "./cliJsonInput.js";
|
|
6
|
+
import { replayMachineRunInputSchema, runReplayMachine, } from "./domain/replayMachineRun.js";
|
|
7
|
+
import { AnalysisInputError, projectAnalysisError } from "./domain/errors.js";
|
|
8
|
+
import { projectInputIssues } from "./domain/inputIssueProjection.js";
|
|
5
9
|
/** Register Process Capture v4 one-shot commands through shared application services. */
|
|
6
10
|
export const registerProcessCommands = (cli, logger) => {
|
|
11
|
+
registerReplayMachineCommand(cli, logger);
|
|
7
12
|
cli.command(CLI_COMMANDS.captureProcess, {
|
|
8
13
|
description: "Capture one approved Process Capture v4 JSON scenario",
|
|
9
14
|
args: z.object({ scenario: z.string().describe("Scenario JSON path") }),
|
|
@@ -14,7 +19,33 @@ export const registerProcessCommands = (cli, logger) => {
|
|
|
14
19
|
args: z.object({
|
|
15
20
|
left: z.string().describe("Left capture Evidence JSON path"),
|
|
16
21
|
right: z.string().describe("Right capture Evidence JSON path"),
|
|
22
|
+
traceSpec: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Optional partial-order or finite-trace specification path"),
|
|
26
|
+
}),
|
|
27
|
+
run: ({ args }) => logCliCommand(logger, "compare-process-captures", () => compareProcessEvidenceFiles(args.left, args.right, args.traceSpec)),
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const registerReplayMachineCommand = (cli, logger) => {
|
|
31
|
+
cli.command(CLI_COMMANDS.runReplayMachine, {
|
|
32
|
+
description: "Run ordered protocol events directly through a finite replay machine",
|
|
33
|
+
args: z.object({
|
|
34
|
+
inputJson: z.string().describe("Inline replay JSON or JSON file path"),
|
|
35
|
+
}),
|
|
36
|
+
run: ({ args }) => logCliCommand(logger, CLI_COMMANDS.runReplayMachine, async () => {
|
|
37
|
+
const input = await parseCliJsonInput(args.inputJson, CLI_COMMANDS.runReplayMachine);
|
|
38
|
+
if (!input.ok)
|
|
39
|
+
return input.error;
|
|
40
|
+
const parsed = replayMachineRunInputSchema.safeParse(input.value);
|
|
41
|
+
return parsed.success
|
|
42
|
+
? runReplayMachine(parsed.data)
|
|
43
|
+
: {
|
|
44
|
+
error: "Process command failed",
|
|
45
|
+
...projectAnalysisError(new AnalysisInputError(CLI_COMMANDS.runReplayMachine, {
|
|
46
|
+
cause: parsed.error,
|
|
47
|
+
}, projectInputIssues(parsed.error.issues, input.value))),
|
|
48
|
+
};
|
|
17
49
|
}),
|
|
18
|
-
run: ({ args }) => logCliCommand(logger, "compare-process-captures", () => compareProcessEvidenceFiles(args.left, args.right)),
|
|
19
50
|
});
|
|
20
51
|
};
|