rea-agents 2.0.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 +78 -32
- 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 +24 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +1 -23
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +156 -238
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +23 -7
- package/dist/application/ElectronBoundaryGraphWindows.js +32 -8
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +20 -37
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptArtifactAnalysis.js +45 -6
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +23 -1
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- 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 +1 -1
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayService.js +182 -156
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- 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/ProjectPermissionStore.js +48 -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/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 +29 -496
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -133
- 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 +4 -0
- 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 +10 -768
- package/dist/cliApplicationCommands.js +118 -4
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +4 -0
- package/dist/cliElectronCommands.js +33 -62
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- 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 -375
- package/dist/contracts/applicationToolContracts.js +134 -0
- package/dist/contracts/managedToolContracts.js +1 -1
- package/dist/contracts/managedWorkflowToolContracts.js +3 -3
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContracts.js +2 -2
- package/dist/contracts/toolEffects.js +14 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -550
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +34 -15
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -285
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +14 -2
- package/dist/domain/errors.js +4 -486
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/javascriptApplicationVersionItems.js +18 -6
- package/dist/domain/javascriptApplicationVersionKeys.js +8 -8
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureTraversal.js +19 -7
- package/dist/domain/javascriptRuntimeStaticCandidates.js +3 -1
- 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 +5 -221
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +71 -2
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +14 -364
- 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 +16 -8
- package/dist/domain/managedMemberComparison.js +37 -391
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +27 -389
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +82 -69
- package/dist/domain/managedRuntimeCorrelation.js +12 -3
- 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 +8 -0
- 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 +50 -29
- package/dist/dotnet/ManagedMemberInspector.js +51 -785
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataInventory.js +42 -306
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +48 -111
- 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 +102 -350
- package/dist/dotnet/ManagedPeReader.js +59 -28
- 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 +61 -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 -146
- 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 +64 -50
- package/dist/replay/LinuxJavaScriptReplayRunner.js +173 -390
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +119 -54
- 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 +10 -112
- package/dist/server/registerBrowserTools.js +59 -83
- package/dist/server/registerElectronTools.js +31 -46
- package/dist/server/registerEnhancedTools.js +34 -42
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +83 -116
- 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 +10 -274
- package/dist/server/registerOfficialTools.js +73 -59
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +2 -1
- package/dist/server/registerSessionTools.js +60 -164
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/toolRegistrationOptions.js +101 -3
- package/dist/server/toolResult.js +5 -0
- package/package.json +10 -11
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +20 -7
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { processCaptureComparisonSchema, processCaptureSchema, } from "../domain/processCapture.js";
|
|
3
|
+
import { evidenceBundleSchema } from "../domain/evidenceBundle.js";
|
|
4
|
+
import { residualUnknownSchema } from "../domain/residualUnknown.js";
|
|
5
|
+
import { referenceKindSchema } from "../domain/hopperValues.js";
|
|
6
|
+
import { demangleSwiftSchema, inspectMachoSchema, inspectPlistSchema, inspectSignatureSchema, listArchitecturesSchema, } from "../domain/nativeInspection.js";
|
|
7
|
+
import { artifactExtractionResultSchema, artifactInventoryResultSchema, } from "../domain/artifactGraph.js";
|
|
8
|
+
import { managedArtifactInspectionSchema, managedMemberInspectionSchema, managedNativeBoundaryInspectionSchema, } from "../domain/managedArtifact.js";
|
|
9
|
+
import { managedMemberComparisonResultSchema } from "../domain/managedMemberComparison.js";
|
|
10
|
+
import { managedNativeVerificationResultSchema } from "../domain/managedNativeVerification.js";
|
|
11
|
+
import { managedReconstructionImportResultSchema } from "../domain/managedReconstruction.js";
|
|
12
|
+
import { managedRuntimeCorrelationResultSchema } from "../domain/managedRuntimeCorrelation.js";
|
|
13
|
+
import { managedApplicationGraphResultSchema } from "../domain/managedApplicationGraph.js";
|
|
14
|
+
import { artifactComparisonResultSchema } from "../domain/artifactComparison.js";
|
|
15
|
+
import { functionComparisonResultSchema } from "../domain/functionComparison.js";
|
|
16
|
+
import { bundleComparisonResultSchema } from "../domain/bundleComparison.js";
|
|
17
|
+
import { changedBehaviorResultSchema } from "../domain/changedBehavior.js";
|
|
18
|
+
import { callPathResultSchema } from "../domain/callPath.js";
|
|
19
|
+
import { staticRuntimeCorrelationResultSchema } from "../domain/staticRuntimeCorrelation.js";
|
|
20
|
+
import { reconstructionVerificationResultSchema } from "../domain/reconstructionVerification.js";
|
|
21
|
+
import { analysisErrorProjectionSchema } from "./errorSchemas.js";
|
|
22
|
+
import { addressList, addressedEntry, bounded, containingProcedureResolution, functionDossierOutput, graphNode, lifecycleResultOf, nullableText, pageOutput, procedureIdentity, procedureInfoOutput, evidenceResultOf as resultOf, searchPageOutput, segmentOutput, sessionProvider, symbolDiscoveryOutput, targetFormatSchema, targetKindSchema, } from "./toolOutputSchemaPrimitives.js";
|
|
23
|
+
/** Exact structured-content schemas shared by direct analysis providers. */
|
|
24
|
+
export const officialOutputSchemas = {
|
|
25
|
+
address_name: resultOf(nullableText),
|
|
26
|
+
comment: resultOf(nullableText),
|
|
27
|
+
current_address: resultOf(z.string()),
|
|
28
|
+
current_procedure: resultOf(z.string()),
|
|
29
|
+
current_document: resultOf(z.string()),
|
|
30
|
+
goto_address: resultOf(z.string()),
|
|
31
|
+
inline_comment: resultOf(nullableText),
|
|
32
|
+
list_bookmarks: resultOf(z.array(addressedEntry)),
|
|
33
|
+
list_documents: resultOf(z.array(z.string())),
|
|
34
|
+
list_names: resultOf(pageOutput),
|
|
35
|
+
list_procedures: resultOf(pageOutput),
|
|
36
|
+
list_segments: segmentOutput,
|
|
37
|
+
list_strings: resultOf(pageOutput),
|
|
38
|
+
next_address: resultOf(z.string()),
|
|
39
|
+
prev_address: resultOf(z.string()),
|
|
40
|
+
procedure_address: resultOf(z.string()),
|
|
41
|
+
procedure_assembly: resultOf(z.string()),
|
|
42
|
+
procedure_callees: resultOf(addressList),
|
|
43
|
+
procedure_callers: resultOf(addressList),
|
|
44
|
+
procedure_info: procedureInfoOutput,
|
|
45
|
+
procedure_references: resultOf(z.object({
|
|
46
|
+
procedure: procedureIdentity,
|
|
47
|
+
direction: z.enum(["incoming", "outgoing"]),
|
|
48
|
+
references: bounded(z.object({
|
|
49
|
+
source_address: z.string(),
|
|
50
|
+
target_address: z.string(),
|
|
51
|
+
source_procedure: procedureIdentity.nullable(),
|
|
52
|
+
target_procedure: procedureIdentity.nullable(),
|
|
53
|
+
kind: referenceKindSchema,
|
|
54
|
+
})),
|
|
55
|
+
instructions_scanned: z.number().int().min(0),
|
|
56
|
+
instruction_scan_truncated: z.boolean(),
|
|
57
|
+
})),
|
|
58
|
+
procedure_pseudo_code: resultOf(nullableText),
|
|
59
|
+
resolve_containing_procedure: resultOf(containingProcedureResolution),
|
|
60
|
+
search_procedures: resultOf(searchPageOutput),
|
|
61
|
+
search_strings: resultOf(searchPageOutput),
|
|
62
|
+
set_address_name: resultOf(z.boolean()),
|
|
63
|
+
set_addresses_names: resultOf(z.record(z.string(), z.boolean())),
|
|
64
|
+
set_bookmark: resultOf(z.boolean()),
|
|
65
|
+
set_comment: resultOf(z.boolean()),
|
|
66
|
+
set_current_document: resultOf(z.string()),
|
|
67
|
+
set_inline_comment: resultOf(z.boolean()),
|
|
68
|
+
unset_bookmark: resultOf(z.boolean()),
|
|
69
|
+
xrefs: resultOf(addressList),
|
|
70
|
+
};
|
|
71
|
+
/** Exact structured-content schemas for composed analysis workflows. */
|
|
72
|
+
export const enhancedOutputSchemas = {
|
|
73
|
+
swift_classes: symbolDiscoveryOutput("classes"),
|
|
74
|
+
get_objc_classes: symbolDiscoveryOutput("classes"),
|
|
75
|
+
get_objc_protocols: symbolDiscoveryOutput("protocols"),
|
|
76
|
+
batch_decompile: resultOf(z.object({
|
|
77
|
+
items: z.array(z.discriminatedUnion("status", [
|
|
78
|
+
z.object({
|
|
79
|
+
address: z.string(),
|
|
80
|
+
status: z.literal("ok"),
|
|
81
|
+
pseudocode: z.string().min(1),
|
|
82
|
+
}),
|
|
83
|
+
z.object({
|
|
84
|
+
address: z.string(),
|
|
85
|
+
status: z.literal("error"),
|
|
86
|
+
error: analysisErrorProjectionSchema,
|
|
87
|
+
}),
|
|
88
|
+
])),
|
|
89
|
+
total: z.number().int().min(0),
|
|
90
|
+
succeeded: z.number().int().min(0),
|
|
91
|
+
failed: z.number().int().min(0),
|
|
92
|
+
})),
|
|
93
|
+
get_call_graph: resultOf(z.record(z.string(), z.array(graphNode))),
|
|
94
|
+
analyze_swift_types: resultOf(z.object({
|
|
95
|
+
total: z.number().int().min(0),
|
|
96
|
+
categories: z.record(z.string(), z.object({
|
|
97
|
+
count: z.number().int().min(0),
|
|
98
|
+
items: z.array(addressedEntry),
|
|
99
|
+
})),
|
|
100
|
+
})),
|
|
101
|
+
find_xrefs_to_name: resultOf(z.discriminatedUnion("status", [
|
|
102
|
+
z.object({
|
|
103
|
+
status: z.literal("resolved"),
|
|
104
|
+
name: z.string(),
|
|
105
|
+
address: z.string(),
|
|
106
|
+
xrefs: addressList,
|
|
107
|
+
}),
|
|
108
|
+
z.object({
|
|
109
|
+
status: z.literal("unresolved"),
|
|
110
|
+
name: z.string(),
|
|
111
|
+
reason: z.literal("name_not_found"),
|
|
112
|
+
}),
|
|
113
|
+
])),
|
|
114
|
+
binary_overview: resultOf(z.object({
|
|
115
|
+
document: z.string(),
|
|
116
|
+
detail: z.enum(["concise", "detailed"]),
|
|
117
|
+
segments: z.array(z.object({
|
|
118
|
+
name: z.string(),
|
|
119
|
+
start: z.string(),
|
|
120
|
+
end: z.string(),
|
|
121
|
+
length: z.number().min(0).optional(),
|
|
122
|
+
})),
|
|
123
|
+
segment_count: z.number().int().min(0),
|
|
124
|
+
procedure_count: z.number().int().min(0),
|
|
125
|
+
string_count: z.number().int().min(0),
|
|
126
|
+
})),
|
|
127
|
+
analyze_function: functionDossierOutput,
|
|
128
|
+
trace_feature: resultOf(z.object({
|
|
129
|
+
query: z.string(),
|
|
130
|
+
search_mode: z.literal("literal"),
|
|
131
|
+
operations_used: z.number().int().min(0),
|
|
132
|
+
operation_budget: z.number().int().min(1),
|
|
133
|
+
matches: z.array(z.object({
|
|
134
|
+
type: z.enum(["string", "procedure"]),
|
|
135
|
+
address: z.string(),
|
|
136
|
+
value: z.string(),
|
|
137
|
+
})),
|
|
138
|
+
references: z.array(z.object({
|
|
139
|
+
target_address: z.string(),
|
|
140
|
+
source_address: z.string(),
|
|
141
|
+
containing_procedure: containingProcedureResolution,
|
|
142
|
+
})),
|
|
143
|
+
truncated: z.boolean(),
|
|
144
|
+
residual_unknowns: z.array(z.string()),
|
|
145
|
+
})),
|
|
146
|
+
};
|
|
147
|
+
/** Exact Evidence v2 schemas for provider-neutral native inspection. */
|
|
148
|
+
export const nativeOutputSchemas = {
|
|
149
|
+
inspect_macho: resultOf(inspectMachoSchema),
|
|
150
|
+
inspect_signature: resultOf(inspectSignatureSchema),
|
|
151
|
+
inspect_plist: resultOf(inspectPlistSchema),
|
|
152
|
+
list_architectures: resultOf(listArchitecturesSchema),
|
|
153
|
+
demangle_swift: resultOf(demangleSwiftSchema),
|
|
154
|
+
};
|
|
155
|
+
/** Exact Evidence v2 schemas for provider-neutral artifact graph operations. */
|
|
156
|
+
export const artifactOutputSchemas = {
|
|
157
|
+
inventory_artifact: resultOf(artifactInventoryResultSchema),
|
|
158
|
+
extract_artifact: resultOf(artifactExtractionResultSchema),
|
|
159
|
+
};
|
|
160
|
+
/** Exact Evidence v2 schema for execution-free managed static analysis. */
|
|
161
|
+
export const managedOutputSchemas = {
|
|
162
|
+
inspect_managed_artifact: resultOf(managedArtifactInspectionSchema),
|
|
163
|
+
inspect_managed_members: resultOf(managedMemberInspectionSchema),
|
|
164
|
+
inspect_managed_native_boundaries: resultOf(managedNativeBoundaryInspectionSchema),
|
|
165
|
+
};
|
|
166
|
+
/** Exact Evidence v2 schema for provider-neutral managed workflows. */
|
|
167
|
+
export const managedWorkflowOutputSchemas = {
|
|
168
|
+
compare_managed_members: resultOf(managedMemberComparisonResultSchema),
|
|
169
|
+
verify_managed_native_boundaries: resultOf(managedNativeVerificationResultSchema),
|
|
170
|
+
import_managed_reconstruction: resultOf(managedReconstructionImportResultSchema),
|
|
171
|
+
plan_managed_runtime_correlation: resultOf(managedRuntimeCorrelationResultSchema),
|
|
172
|
+
project_managed_application_graph: resultOf(managedApplicationGraphResultSchema),
|
|
173
|
+
};
|
|
174
|
+
/** Exact structured-content schemas for target lifecycle operations. */
|
|
175
|
+
export const sessionOutputSchemas = {
|
|
176
|
+
open_binary: lifecycleResultOf(z.object({
|
|
177
|
+
path: z.string(),
|
|
178
|
+
format: targetFormatSchema,
|
|
179
|
+
kind: targetKindSchema,
|
|
180
|
+
loaderArgs: z.array(z.string()),
|
|
181
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
182
|
+
architecture: z.enum(["x86", "x86_64", "arm", "arm64"]).nullable(),
|
|
183
|
+
})),
|
|
184
|
+
close_binary: lifecycleResultOf(z.union([
|
|
185
|
+
z.null(),
|
|
186
|
+
z.object({
|
|
187
|
+
path: z.string(),
|
|
188
|
+
bytes: z.number().int().min(0),
|
|
189
|
+
entries: z.number().int().min(0),
|
|
190
|
+
}),
|
|
191
|
+
])),
|
|
192
|
+
binary_session: lifecycleResultOf(z.union([
|
|
193
|
+
sessionProvider.extend({ open: z.literal(false) }),
|
|
194
|
+
sessionProvider.extend({
|
|
195
|
+
open: z.literal(true),
|
|
196
|
+
path: z.string(),
|
|
197
|
+
format: targetFormatSchema,
|
|
198
|
+
kind: targetKindSchema,
|
|
199
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
200
|
+
architecture: z.enum(["x86", "x86_64", "arm", "arm64"]).nullable(),
|
|
201
|
+
}),
|
|
202
|
+
])),
|
|
203
|
+
export_evidence_bundle: lifecycleResultOf(z.union([
|
|
204
|
+
evidenceBundleSchema,
|
|
205
|
+
z.object({
|
|
206
|
+
path: z.string(),
|
|
207
|
+
bytes: z.number().int().min(0),
|
|
208
|
+
records: z.number().int().min(0),
|
|
209
|
+
}),
|
|
210
|
+
])),
|
|
211
|
+
import_evidence_bundle: lifecycleResultOf(z.object({
|
|
212
|
+
imported: z.number().int().min(0),
|
|
213
|
+
total: z.number().int().min(0),
|
|
214
|
+
})),
|
|
215
|
+
capture_process_scenario: resultOf(processCaptureSchema),
|
|
216
|
+
compare_process_captures: resultOf(processCaptureComparisonSchema),
|
|
217
|
+
compare_artifacts: resultOf(artifactComparisonResultSchema),
|
|
218
|
+
compare_functions: resultOf(functionComparisonResultSchema),
|
|
219
|
+
compare_bundles: resultOf(bundleComparisonResultSchema),
|
|
220
|
+
find_changed_behavior: resultOf(changedBehaviorResultSchema),
|
|
221
|
+
build_call_path: resultOf(callPathResultSchema),
|
|
222
|
+
correlate_static_and_runtime: resultOf(staticRuntimeCorrelationResultSchema),
|
|
223
|
+
verify_reconstruction: resultOf(reconstructionVerificationResultSchema),
|
|
224
|
+
list_unknowns: lifecycleResultOf(z.array(residualUnknownSchema)),
|
|
225
|
+
record_unknown: lifecycleResultOf(residualUnknownSchema),
|
|
226
|
+
update_unknown: lifecycleResultOf(residualUnknownSchema),
|
|
227
|
+
verify_unknown_resolution: lifecycleResultOf(z.object({
|
|
228
|
+
valid: z.boolean(),
|
|
229
|
+
truthVerified: z.boolean(),
|
|
230
|
+
unknown: residualUnknownSchema,
|
|
231
|
+
})),
|
|
232
|
+
};
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { procedureClassificationSchema, procedureIdentitySchema, localVariableSchema, functionDossierSchema, } from "../domain/hopperValues.js";
|
|
3
|
+
import { analysisProfileSchema } from "../domain/analysisProfile.js";
|
|
4
|
+
import { PROVIDER_REJECTION_CODES, } from "./providerSelection.js";
|
|
5
|
+
import { analysisErrorProjectionSchema } from "./errorSchemas.js";
|
|
6
|
+
/** Compact MCP result with an immutable link to complete session Evidence. */
|
|
7
|
+
export const evidenceResultOf = (schema) => z.strictObject({
|
|
8
|
+
result: schema,
|
|
9
|
+
evidence_id: z.string().regex(/^ev_[a-f0-9]{64}$/u),
|
|
10
|
+
evidence_uri: z.string().regex(/^rea:\/\/evidence\/ev_[a-f0-9]{64}$/u),
|
|
11
|
+
});
|
|
12
|
+
const resultOf = evidenceResultOf;
|
|
13
|
+
export const lifecycleResultOf = (schema) => z.object({ result: schema });
|
|
14
|
+
/** Resolve a required named output schema or reject contract drift. */
|
|
15
|
+
export const requireOutputSchema = (schemas, name) => {
|
|
16
|
+
const schema = schemas[name];
|
|
17
|
+
if (schema === undefined)
|
|
18
|
+
throw new Error(`Missing output schema for ${name}`);
|
|
19
|
+
return schema;
|
|
20
|
+
};
|
|
21
|
+
export const targetFormatSchema = z.enum([
|
|
22
|
+
"hopper",
|
|
23
|
+
"analysis-database",
|
|
24
|
+
"mach-o",
|
|
25
|
+
"elf",
|
|
26
|
+
"pe",
|
|
27
|
+
"zip",
|
|
28
|
+
"ipa",
|
|
29
|
+
"apk",
|
|
30
|
+
"asar",
|
|
31
|
+
"dmg",
|
|
32
|
+
"pkg",
|
|
33
|
+
"plist",
|
|
34
|
+
"javascript",
|
|
35
|
+
"source-map",
|
|
36
|
+
]);
|
|
37
|
+
export const targetKindSchema = z.enum([
|
|
38
|
+
"executable",
|
|
39
|
+
"database",
|
|
40
|
+
"archive",
|
|
41
|
+
"artifact",
|
|
42
|
+
]);
|
|
43
|
+
const providerCapability = z.object({
|
|
44
|
+
operation: z.string(),
|
|
45
|
+
available: z.boolean(),
|
|
46
|
+
reason: z.string().nullable(),
|
|
47
|
+
input_contract_version: z.number().int().min(1),
|
|
48
|
+
output_contract_version: z.number().int().min(1),
|
|
49
|
+
pagination: z.enum(["none", "offset", "cursor"]),
|
|
50
|
+
exhaustive: z.boolean(),
|
|
51
|
+
effects: z.object({
|
|
52
|
+
mutates_artifact: z.boolean(),
|
|
53
|
+
launches_process: z.boolean(),
|
|
54
|
+
may_show_ui: z.boolean(),
|
|
55
|
+
may_access_network: z.boolean(),
|
|
56
|
+
may_write_filesystem: z.boolean(),
|
|
57
|
+
changes_permissions: z.boolean(),
|
|
58
|
+
requires_root: z.boolean(),
|
|
59
|
+
}),
|
|
60
|
+
limits: z.object({
|
|
61
|
+
max_results: z.number().int().min(0).nullable(),
|
|
62
|
+
max_payload_bytes: z.number().int().min(0).nullable(),
|
|
63
|
+
timeout_ms: z.number().int().min(0).nullable(),
|
|
64
|
+
}),
|
|
65
|
+
limitations: z.array(z.string()),
|
|
66
|
+
});
|
|
67
|
+
const providerIdentity = z.object({
|
|
68
|
+
id: z.string(),
|
|
69
|
+
name: z.string(),
|
|
70
|
+
version: z.string().nullable(),
|
|
71
|
+
});
|
|
72
|
+
const providerRejectionCode = z.enum(PROVIDER_REJECTION_CODES);
|
|
73
|
+
const providerDiagnostics = z.record(z.string(), z.json());
|
|
74
|
+
const providerAvailability = z.discriminatedUnion("status", [
|
|
75
|
+
z.object({
|
|
76
|
+
status: z.literal("available"),
|
|
77
|
+
code: z.null(),
|
|
78
|
+
reason: z.null(),
|
|
79
|
+
diagnostics: providerDiagnostics,
|
|
80
|
+
}),
|
|
81
|
+
z.object({
|
|
82
|
+
status: z.literal("unavailable"),
|
|
83
|
+
code: providerRejectionCode,
|
|
84
|
+
reason: z.string().min(1),
|
|
85
|
+
diagnostics: providerDiagnostics,
|
|
86
|
+
}),
|
|
87
|
+
]);
|
|
88
|
+
const providerTargetSupport = z.discriminatedUnion("status", [
|
|
89
|
+
z.object({
|
|
90
|
+
status: z.literal("unknown"),
|
|
91
|
+
code: z.null(),
|
|
92
|
+
reason: z.string().min(1),
|
|
93
|
+
diagnostics: providerDiagnostics,
|
|
94
|
+
}),
|
|
95
|
+
z.object({
|
|
96
|
+
status: z.literal("supported"),
|
|
97
|
+
code: z.null(),
|
|
98
|
+
reason: z.null(),
|
|
99
|
+
diagnostics: providerDiagnostics,
|
|
100
|
+
}),
|
|
101
|
+
z.object({
|
|
102
|
+
status: z.literal("unsupported"),
|
|
103
|
+
code: z.enum([
|
|
104
|
+
"target_kind_unsupported",
|
|
105
|
+
"target_format_unsupported",
|
|
106
|
+
"architecture_unsupported",
|
|
107
|
+
"target_role_unsupported",
|
|
108
|
+
"managed_target_unsupported",
|
|
109
|
+
]),
|
|
110
|
+
reason: z.string().min(1),
|
|
111
|
+
diagnostics: providerDiagnostics,
|
|
112
|
+
}),
|
|
113
|
+
]);
|
|
114
|
+
export const sessionProvider = z.object({
|
|
115
|
+
provider: providerIdentity,
|
|
116
|
+
providers: z.array(providerIdentity),
|
|
117
|
+
capabilities: z.array(providerCapability),
|
|
118
|
+
analysis_provider_binding: z
|
|
119
|
+
.object({
|
|
120
|
+
provider: providerIdentity,
|
|
121
|
+
selection_source: z.enum([
|
|
122
|
+
"request",
|
|
123
|
+
"environment",
|
|
124
|
+
"auto-single-candidate",
|
|
125
|
+
]),
|
|
126
|
+
analysis_profile: analysisProfileSchema,
|
|
127
|
+
})
|
|
128
|
+
.nullable(),
|
|
129
|
+
analysis_provider_candidates: z.array(z.object({
|
|
130
|
+
provider: providerIdentity,
|
|
131
|
+
availability: providerAvailability,
|
|
132
|
+
target_support: providerTargetSupport,
|
|
133
|
+
selected: z.boolean(),
|
|
134
|
+
capabilities: z.array(providerCapability),
|
|
135
|
+
})),
|
|
136
|
+
tool_availability: z.array(z.object({
|
|
137
|
+
name: z.string(),
|
|
138
|
+
surface: z.string(),
|
|
139
|
+
available: z.boolean(),
|
|
140
|
+
reason: z.enum([
|
|
141
|
+
"available",
|
|
142
|
+
"target_required",
|
|
143
|
+
"provider_missing",
|
|
144
|
+
"provider_unavailable",
|
|
145
|
+
"target_unsupported",
|
|
146
|
+
"unsupported_host",
|
|
147
|
+
"policy_disabled",
|
|
148
|
+
]),
|
|
149
|
+
remediation: z.string().nullable(),
|
|
150
|
+
effects: z.strictObject({
|
|
151
|
+
mutatesTarget: z.boolean(),
|
|
152
|
+
mutatesSession: z.boolean(),
|
|
153
|
+
writesFilesystem: z.boolean(),
|
|
154
|
+
launchesProcess: z.boolean(),
|
|
155
|
+
accessesNetwork: z.boolean(),
|
|
156
|
+
changesUiState: z.boolean(),
|
|
157
|
+
mayDiscardData: z.boolean(),
|
|
158
|
+
idempotent: z.boolean(),
|
|
159
|
+
}),
|
|
160
|
+
annotations: z.object({
|
|
161
|
+
read_only: z.boolean(),
|
|
162
|
+
destructive: z.boolean(),
|
|
163
|
+
idempotent: z.boolean(),
|
|
164
|
+
open_world: z.boolean(),
|
|
165
|
+
}),
|
|
166
|
+
})),
|
|
167
|
+
client_features: z.object({
|
|
168
|
+
elicitation_form: z.boolean(),
|
|
169
|
+
elicitation_url: z.boolean(),
|
|
170
|
+
roots: z.boolean(),
|
|
171
|
+
sampling: z.boolean(),
|
|
172
|
+
}),
|
|
173
|
+
server_identity: z.object({
|
|
174
|
+
package: z.object({
|
|
175
|
+
name: z.string(),
|
|
176
|
+
version: z.string(),
|
|
177
|
+
root_path: z.string(),
|
|
178
|
+
build_commit: z.string().nullable(),
|
|
179
|
+
}),
|
|
180
|
+
server: z.object({
|
|
181
|
+
name: z.string(),
|
|
182
|
+
version: z.string(),
|
|
183
|
+
started_at: z.string(),
|
|
184
|
+
command_path: z.string(),
|
|
185
|
+
}),
|
|
186
|
+
sdk: z.object({
|
|
187
|
+
server: z.string(),
|
|
188
|
+
client_test: z.string(),
|
|
189
|
+
core: z.string(),
|
|
190
|
+
}),
|
|
191
|
+
negotiated_protocol_version: z.string().nullable(),
|
|
192
|
+
client: z.object({ name: z.string(), version: z.string() }).nullable(),
|
|
193
|
+
skill: z.object({ name: z.string(), expected_version: z.string() }),
|
|
194
|
+
catalog: z.record(z.string(), z.json()),
|
|
195
|
+
protocol_features: z.object({
|
|
196
|
+
progress: z.boolean(),
|
|
197
|
+
cancellation: z.boolean(),
|
|
198
|
+
evidence_resources: z.boolean(),
|
|
199
|
+
elicitation: z.boolean(),
|
|
200
|
+
}),
|
|
201
|
+
alignment: z.object({
|
|
202
|
+
state: z.enum(["aligned", "mcp_server_restart_required", "unknown"]),
|
|
203
|
+
reasons: z.array(z.string()),
|
|
204
|
+
remediation: z.string().nullable(),
|
|
205
|
+
}),
|
|
206
|
+
}),
|
|
207
|
+
});
|
|
208
|
+
export const nullableText = z.string().nullable();
|
|
209
|
+
export const addressList = z.array(z.string());
|
|
210
|
+
export const addressedEntry = z.object({
|
|
211
|
+
address: z.string(),
|
|
212
|
+
name: z.string(),
|
|
213
|
+
});
|
|
214
|
+
export const procedureIdentity = procedureIdentitySchema;
|
|
215
|
+
const localVariable = localVariableSchema;
|
|
216
|
+
export const containingProcedureResolution = z.discriminatedUnion("found", [
|
|
217
|
+
z.object({
|
|
218
|
+
query_address: z.string(),
|
|
219
|
+
found: z.literal(true),
|
|
220
|
+
procedure: procedureIdentity,
|
|
221
|
+
}),
|
|
222
|
+
z.object({
|
|
223
|
+
query_address: z.string(),
|
|
224
|
+
found: z.literal(false),
|
|
225
|
+
procedure: z.null(),
|
|
226
|
+
reason: z.enum(["outside_segments", "not_in_procedure"]),
|
|
227
|
+
}),
|
|
228
|
+
]);
|
|
229
|
+
const unavailable = z.object({
|
|
230
|
+
available: z.literal(false),
|
|
231
|
+
reason: z.string(),
|
|
232
|
+
});
|
|
233
|
+
const availableMemoryPermissions = z.object({
|
|
234
|
+
available: z.literal(true),
|
|
235
|
+
source: z.literal("ghidra-memory-block"),
|
|
236
|
+
});
|
|
237
|
+
export const bounded = (item) => z.object({
|
|
238
|
+
items: z.array(item),
|
|
239
|
+
total: z.number().int().min(0).nullable(),
|
|
240
|
+
returned: z.number().int().min(0),
|
|
241
|
+
truncated: z.boolean(),
|
|
242
|
+
next_offset: z.number().int().min(0).nullable(),
|
|
243
|
+
});
|
|
244
|
+
const addressedValue = z.object({
|
|
245
|
+
address: z.string(),
|
|
246
|
+
value: z.string(),
|
|
247
|
+
value_truncated: z.boolean().optional(),
|
|
248
|
+
symbol: z
|
|
249
|
+
.object({
|
|
250
|
+
primary: z.boolean(),
|
|
251
|
+
dynamic: z.boolean(),
|
|
252
|
+
external: z.boolean(),
|
|
253
|
+
type: z.string(),
|
|
254
|
+
source: z.enum(["default", "analysis", "ai", "imported", "user_defined"]),
|
|
255
|
+
})
|
|
256
|
+
.optional(),
|
|
257
|
+
procedure: z
|
|
258
|
+
.object({
|
|
259
|
+
external: z.boolean(),
|
|
260
|
+
thunk: z.boolean(),
|
|
261
|
+
thunk_target: z.string().nullable(),
|
|
262
|
+
})
|
|
263
|
+
.optional(),
|
|
264
|
+
string: z
|
|
265
|
+
.object({
|
|
266
|
+
encoding: z.string(),
|
|
267
|
+
termination: z.enum(["missing", "present_or_not_required"]),
|
|
268
|
+
byte_length: z.number().int().min(0),
|
|
269
|
+
})
|
|
270
|
+
.optional(),
|
|
271
|
+
});
|
|
272
|
+
export const pageOutput = z.object({
|
|
273
|
+
items: z.array(addressedValue),
|
|
274
|
+
offset: z.number().int().min(0),
|
|
275
|
+
limit: z.number().int().min(1),
|
|
276
|
+
total: z.number().int().min(0),
|
|
277
|
+
next_offset: z.number().int().min(0).nullable(),
|
|
278
|
+
has_more: z.boolean(),
|
|
279
|
+
});
|
|
280
|
+
export const searchPageOutput = pageOutput.extend({
|
|
281
|
+
items: z.array(z.object({
|
|
282
|
+
address: z.string(),
|
|
283
|
+
value: z.string(),
|
|
284
|
+
value_truncated: z.boolean(),
|
|
285
|
+
})),
|
|
286
|
+
});
|
|
287
|
+
const memoryRegionOutput = z.object({
|
|
288
|
+
name: z.string(),
|
|
289
|
+
start: z.string(),
|
|
290
|
+
end: z.string(),
|
|
291
|
+
readable: z.boolean().nullable(),
|
|
292
|
+
writable: z.boolean().nullable(),
|
|
293
|
+
executable: z.boolean().nullable(),
|
|
294
|
+
permissions: z.union([unavailable, availableMemoryPermissions]),
|
|
295
|
+
provenance: z.enum(["hopper-public-python-api", "ghidra-memory-block"]),
|
|
296
|
+
address_space: z.string().optional(),
|
|
297
|
+
image_base: z.string().optional(),
|
|
298
|
+
initialized: z.boolean().optional(),
|
|
299
|
+
overlay: z.boolean().optional(),
|
|
300
|
+
});
|
|
301
|
+
export const segmentOutput = resultOf(z.array(memoryRegionOutput.extend({ sections: z.array(memoryRegionOutput) })));
|
|
302
|
+
export const procedureInfoOutput = resultOf(z.object({
|
|
303
|
+
name: z.string(),
|
|
304
|
+
entrypoint: z.string(),
|
|
305
|
+
basicblock_count: z.number().int().min(0),
|
|
306
|
+
length: z.number().min(0),
|
|
307
|
+
signature: nullableText,
|
|
308
|
+
locals: z.array(localVariable),
|
|
309
|
+
classification: procedureClassificationSchema.nullable().default(null),
|
|
310
|
+
}));
|
|
311
|
+
export const symbolDiscoveryOutput = (property) => resultOf(z.object({
|
|
312
|
+
count: z.number().int().min(0),
|
|
313
|
+
[property]: z.array(addressedEntry),
|
|
314
|
+
}));
|
|
315
|
+
export const graphNode = z.discriminatedUnion("status", [
|
|
316
|
+
z.object({
|
|
317
|
+
address: z.string(),
|
|
318
|
+
status: z.literal("ok"),
|
|
319
|
+
calls: z.array(z.string()),
|
|
320
|
+
}),
|
|
321
|
+
z.object({
|
|
322
|
+
address: z.string(),
|
|
323
|
+
status: z.literal("error"),
|
|
324
|
+
error: analysisErrorProjectionSchema,
|
|
325
|
+
}),
|
|
326
|
+
]);
|
|
327
|
+
export const functionDossierOutput = resultOf(functionDossierSchema);
|