rea-agents 3.0.0 → 3.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 +14 -16
- package/dist/application/AnalysisContextQueries.js +21 -9
- package/dist/application/ApplicationWorkflowEvidenceResolver.js +19 -11
- package/dist/application/ArtifactInventory/policy.js +17 -0
- package/dist/application/ArtifactInventory/reader.js +1 -4
- package/dist/application/ArtifactInventory/scanCanonical.js +0 -3
- package/dist/application/ArtifactInventory/scanReader.js +7 -7
- package/dist/application/ArtifactInventory/types.js +1 -5
- package/dist/application/BinarySession.js +14 -16
- package/dist/application/BinarySessionRecords.js +31 -5
- package/dist/application/BinarySessionStatus.js +11 -5
- package/dist/application/BrowserEvidence.js +3 -5
- package/dist/application/CapabilityClientRequirements.js +26 -0
- package/dist/application/CapabilityInventory.js +134 -63
- package/dist/application/CrossVersionInventory.js +7 -6
- package/dist/application/ElectronActiveEvidence.js +55 -0
- package/dist/application/ElectronActiveObservationPort.js +1 -0
- package/dist/application/ElectronActiveObservationService.js +81 -0
- package/dist/application/EnhancedTools.js +22 -20
- package/dist/application/EvidenceBundleCommands.js +5 -1
- package/dist/application/EvidenceLedger.js +8 -1
- package/dist/application/JavaScriptReplayPermission.js +1 -1
- package/dist/application/JavaScriptReplayService.js +23 -15
- package/dist/application/ManagedRuntimeCorrelationService.js +9 -5
- package/dist/application/NodeRuntimeCharacterizationService.js +8 -9
- package/dist/application/ProcessCaptureLifecycle.js +5 -0
- package/dist/application/ProcessCli.js +2 -1
- package/dist/application/ProcessHarness.js +8 -3
- package/dist/application/ProcessNormalization.js +2 -1
- package/dist/application/ProjectPermissionStore.js +1 -0
- package/dist/application/ReferenceSourceImport.js +2 -2
- package/dist/application/SetupClientConfiguration.js +6 -1
- package/dist/application/WindowsCapabilities.js +5 -4
- package/dist/artifacts/ArtifactProvider.js +8 -10
- package/dist/artifacts/SafeOutputTree.js +7 -8
- package/dist/browser/CdpCaptureStorageFingerprints.js +10 -7
- package/dist/browser/CdpElectronInspection.js +3 -1
- package/dist/browser/JavaScriptRuntimeScope.js +5 -0
- package/dist/browser/PlaywrightElectronActiveActions.js +324 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +294 -0
- package/dist/browser/PlaywrightScenarioBrowser.js +4 -4
- package/dist/browser/PlaywrightScenarioSession.js +4 -4
- package/dist/browser/SensitiveTextCapture.js +1 -1
- package/dist/browser/V8InspectorCaptureProjection.js +1 -0
- package/dist/browser/V8InspectorProvider.js +3 -3
- package/dist/catalogIdentity.js +12 -6
- package/dist/cli/managedCommands.js +1 -1
- package/dist/cliApplicationCommands.js +2 -2
- package/dist/cliBrowserAdvancedCommands.js +11 -5
- package/dist/cliBrowserCommands.js +14 -7
- package/dist/cliCommandNames.js +1 -0
- package/dist/cliElectronCommands.js +46 -4
- package/dist/cliJavaScriptRuntimeCommands.js +14 -6
- package/dist/cliObservationOptions.js +4 -0
- package/dist/cliPolicyCommands.js +1 -0
- package/dist/config/browserScenario.js +77 -0
- package/dist/config/electronAutomation.js +35 -0
- package/dist/config/environment.js +6 -0
- package/dist/config/javascriptReplay.js +41 -0
- package/dist/config/managedRuntime.js +25 -0
- package/dist/config/parseConfig.js +56 -200
- package/dist/config/parsers.js +10 -1
- package/dist/config/passiveObservation.js +157 -0
- package/dist/config/processCapture.js +47 -0
- package/dist/contracts/applicationToolContracts.js +2 -5
- package/dist/contracts/applicationWorkflowInputContracts.js +86 -96
- package/dist/contracts/artifactToolContracts.js +27 -34
- package/dist/contracts/browserToolContracts.js +2 -2
- package/dist/contracts/electronToolContracts.js +30 -1
- package/dist/contracts/enhancedInputs.js +13 -29
- package/dist/contracts/functionWorkflowToolContracts.js +2 -3
- package/dist/contracts/managedToolContracts.js +4 -9
- package/dist/contracts/managedWorkflowExamples.js +12 -9
- package/dist/contracts/managedWorkflowToolContracts.js +30 -27
- package/dist/contracts/nativeToolContracts.js +2 -3
- package/dist/contracts/sessionToolSchemas.js +61 -0
- package/dist/contracts/toolContractExamples.js +1 -0
- package/dist/contracts/toolContractHelpers.js +23 -0
- package/dist/contracts/toolContracts.js +5 -77
- package/dist/contracts/toolEffects.js +15 -0
- package/dist/contracts/toolOutputSchemaGroups.js +17 -2
- package/dist/contracts/toolOutputSchemaPrimitives.js +76 -26
- package/dist/contracts/toolSchemaMetadata.js +128 -0
- package/dist/doctorRuntime.js +1 -1
- package/dist/domain/androidApplication.js +2 -0
- package/dist/domain/appleApplication.js +2 -0
- package/dist/domain/binaryTarget.js +7 -5
- package/dist/domain/binaryTargetTypes.js +1 -0
- package/dist/domain/browserCaptureComparison.js +21 -69
- package/dist/domain/browserObservation.js +22 -9
- package/dist/domain/bytecodeProvider.js +33 -35
- package/dist/domain/callPath.js +3 -2
- package/dist/domain/conformanceReplay.js +3 -3
- package/dist/domain/conformanceTrustGate.js +151 -16
- package/dist/domain/customProtocolCapture.js +3 -3
- package/dist/domain/electronActiveObservation.js +277 -0
- package/dist/domain/electronObservation.js +15 -11
- package/dist/domain/electronStaticAnalysisValues.js +4 -1
- package/dist/domain/eventProcessTree.js +82 -79
- package/dist/domain/functionComparisonNormalization.js +15 -8
- package/dist/domain/functionDossierEvidence.js +9 -4
- package/dist/domain/hopperValues.js +68 -71
- package/dist/domain/inputIssueProjection.js +4 -1
- package/dist/domain/investigationWorkspace.js +16 -15
- package/dist/domain/javascriptExportShapeComparisonSchemas.js +2 -2
- package/dist/domain/javascriptReplay.js +79 -63
- package/dist/domain/javascriptRuntimeObservation.js +1 -0
- package/dist/domain/javascriptRuntimeReconciliationActive.js +89 -0
- package/dist/domain/javascriptRuntimeReconciliationGraph.js +11 -10
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +57 -49
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +5 -1
- package/dist/domain/javascriptRuntimeReconciliationResult.js +21 -14
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +1 -1
- package/dist/domain/knownPageCoverage.js +15 -7
- package/dist/domain/nativeApiBoundary.js +15 -7
- package/dist/domain/nodeRuntimeCharacterization.js +14 -13
- package/dist/domain/processCaptureReactiveValidation.js +8 -3
- package/dist/domain/processCaptureValidation.js +7 -3
- package/dist/domain/processComparison.js +12 -7
- package/dist/domain/processObservation.js +5 -6
- package/dist/domain/processReactiveMatching.js +14 -7
- package/dist/domain/processReactiveTransition.js +9 -3
- package/dist/domain/processScenario.js +6 -3
- package/dist/domain/processTraceComparison.js +3 -2
- package/dist/domain/protocolCapture.js +8 -6
- package/dist/domain/reconstructionReadinessSchemas.js +30 -2
- package/dist/domain/referenceSourceImportParsing.js +2 -2
- package/dist/domain/replayMachineRuntime.js +5 -3
- package/dist/domain/sourceToBundleComparison.js +2 -2
- package/dist/domain/sourceToBundleComparisonSchemas.js +8 -8
- package/dist/domain/sourceToBundleSignals.js +7 -1
- package/dist/domain/staticRuntimeCorrelation.js +7 -5
- package/dist/domain/webBundleAnalysis.js +14 -14
- package/dist/domain/webCaptureDiff.js +15 -12
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +2 -3
- package/dist/generatedMcpToolCatalog.js +1 -1
- package/dist/generatedPackageMetadata.js +1 -1
- package/dist/ghidra/GhidraClient.js +1 -1
- package/dist/ghidra/GhidraClientStartup.js +1 -1
- package/dist/ghidra/GhidraFunctionValues.js +17 -15
- package/dist/ghidra/GhidraInventoryValues.js +57 -47
- package/dist/ghidra/GhidraProvider.js +18 -10
- package/dist/ghidra/GhidraProviderCapabilities.js +5 -1
- package/dist/ghidra/GhidraSocketConnection.js +1 -1
- package/dist/ghidra/protocol.js +19 -42
- package/dist/hopper/BridgeLauncher.js +3 -1
- package/dist/hopper/HopperAnalysisProfile.js +2 -4
- package/dist/hopper/HopperCleanup.js +5 -6
- package/dist/hopper/HopperClient.js +1 -1
- package/dist/hopper/HopperProvider.js +0 -14
- package/dist/hopper/LinuxPrivateDisplayProbe.js +16 -10
- package/dist/main/reload.js +1 -6
- package/dist/main/state.js +0 -14
- package/dist/main/transport.js +30 -37
- package/dist/main.js +17 -15
- package/dist/mcpDoctor.js +2 -24
- package/dist/process/PrivateRuntimeRoot.js +17 -0
- package/dist/process/ProcessOwnership.js +64 -128
- package/dist/process/ProcessOwnershipIdentity.js +13 -0
- package/dist/process/ProcessOwnershipObservation.js +88 -0
- package/dist/process/ProcessOwnershipProcessTree.js +22 -0
- package/dist/process/ProviderDeadline.js +8 -12
- package/dist/process/WindowsAuthority.js +32 -0
- package/dist/reference/ReferenceSourceReader.js +3 -3
- package/dist/reference/ReferenceSourceReaderEntries.js +2 -2
- package/dist/replay/JavaScriptReplayWorker.js +95 -11
- package/dist/replay/JavaScriptReplayWorkerTypes.js +1 -0
- package/dist/replay/LinuxJavaScriptReplayRunner.js +10 -15
- package/dist/replay/ReplayOutcome.js +26 -15
- package/dist/replay/ReplayWorkerProtocol.js +34 -29
- package/dist/server/createServer.js +158 -94
- package/dist/server/mcpClientMetadata.js +32 -0
- package/dist/server/registerApplicationTools/characterization.js +6 -13
- package/dist/server/registerApplicationTools/compareExportShapes.js +2 -7
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +2 -7
- package/dist/server/registerApplicationTools/compareVersions.js +3 -8
- package/dist/server/registerApplicationTools/controlledReplay.js +6 -11
- package/dist/server/registerApplicationTools/coverage.js +13 -19
- package/dist/server/registerApplicationTools/obligationLedger.js +1 -6
- package/dist/server/registerApplicationTools/readiness.js +1 -6
- package/dist/server/registerApplicationTools/traceFeature.js +3 -8
- package/dist/server/registerApplicationTools/traceSemantics.js +1 -6
- package/dist/server/registerArtifactComparisonTool.js +12 -16
- package/dist/server/registerBrowserScenarioTool.js +1 -6
- package/dist/server/registerBrowserTools.js +37 -79
- package/dist/server/registerBundleComparisonTool.js +10 -14
- package/dist/server/registerCloseLifecycleTool.js +6 -14
- package/dist/server/registerElectronTools.js +30 -47
- package/dist/server/registerEnhancedTools.js +114 -122
- package/dist/server/registerEvidenceTools.js +5 -9
- package/dist/server/registerFunctionComparisonTool.js +11 -15
- package/dist/server/registerInvestigationTools.js +41 -57
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +13 -27
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -9
- package/dist/server/registerManagedWorkflowTools/contract.js +2 -3
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -8
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +3 -8
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +8 -13
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +4 -9
- package/dist/server/registerOfficialTools.js +8 -9
- package/dist/server/registerProcessComparisonTool.js +19 -24
- package/dist/server/registerReplayMachineTool.js +4 -10
- package/dist/server/registerSessionRecordTools.js +69 -40
- package/dist/server/registerSessionStatusTool.js +13 -28
- package/dist/server/registerSessionTools.js +36 -52
- package/dist/server/sessionAvailabilityPolicy.js +2 -1
- package/dist/server/sessionToolPolicies.js +1 -5
- package/dist/server/toolRegistrationOptions.js +4 -192
- package/dist/server/toolResult.js +2 -18
- package/package.json +22 -14
- package/scripts/electron-active-hook-boundaries.cjs +394 -0
- package/scripts/electron-active-hook.cjs +501 -0
- package/scripts/rea.mjs +1 -11
- package/skills/reverse-engineer-anything/SKILL.md +2 -2
- package/dist/server/DynamicToolAvailability.js +0 -70
- package/dist/server/LazyToolCatalog.js +0 -134
- package/dist/server/hydrateServerTools.js +0 -191
- package/dist/server/toolInputValidation.js +0 -77
- package/scripts/package-runner-bootstrap.mjs +0 -72
|
@@ -1,138 +1,130 @@
|
|
|
1
1
|
import { EnhancedTools, } from "../application/EnhancedTools.js";
|
|
2
|
-
import {
|
|
2
|
+
import { REA_WORKFLOW_PROVIDER, workflowAnalysisProfile, } from "../application/InvestigationProviders.js";
|
|
3
3
|
import { ENHANCED_TOOL_CONTRACTS, } from "../contracts/toolContracts.js";
|
|
4
|
-
import {
|
|
5
|
-
import { logToolExecution } from "./toolLogging.js";
|
|
4
|
+
import { UnknownRegistryError } from "../domain/errors.js";
|
|
6
5
|
import { createEvidence } from "../domain/evidence.js";
|
|
7
|
-
import { AnalysisInputError, UnknownRegistryError } from "../domain/errors.js";
|
|
8
|
-
import { ok } from "../domain/result.js";
|
|
9
6
|
import { mcpProgressReporter } from "./mcpProgress.js";
|
|
10
|
-
import {
|
|
7
|
+
import { logToolExecution } from "./toolLogging.js";
|
|
11
8
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
12
|
-
import {
|
|
9
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
13
10
|
/** Register composed workflows against the same port as direct bridge tools. */
|
|
11
|
+
// oxlint-disable-next-line max-lines-per-function -- direct SDK calls retain each schema-handler type correlation.
|
|
14
12
|
export const registerEnhancedTools = (server, analysis, options) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
13
|
+
const [swiftClasses, objcClasses, objcProtocols, batchDecompile, callGraph, swiftTypes, xrefsToName, binaryOverview, analyzeFunction, inspectNativeApi, traceFeature, codeForString, traceCallPath,] = ENHANCED_TOOL_CONTRACTS;
|
|
14
|
+
server.registerTool(swiftClasses.name, toolRegistrationOptions(swiftClasses), (input, context) => executeEnhancedTool(analysis, options, swiftClasses, {
|
|
15
|
+
validatedCall: { name: "swift_classes", input },
|
|
16
|
+
context,
|
|
17
|
+
}));
|
|
18
|
+
server.registerTool(objcClasses.name, toolRegistrationOptions(objcClasses), (input, context) => executeEnhancedTool(analysis, options, objcClasses, {
|
|
19
|
+
validatedCall: { name: "get_objc_classes", input },
|
|
20
|
+
context,
|
|
21
|
+
}));
|
|
22
|
+
server.registerTool(objcProtocols.name, toolRegistrationOptions(objcProtocols), (input, context) => executeEnhancedTool(analysis, options, objcProtocols, {
|
|
23
|
+
validatedCall: { name: "get_objc_protocols", input },
|
|
24
|
+
context,
|
|
25
|
+
}));
|
|
26
|
+
server.registerTool(batchDecompile.name, toolRegistrationOptions(batchDecompile), (input, context) => executeEnhancedTool(analysis, options, batchDecompile, {
|
|
27
|
+
validatedCall: { name: "batch_decompile", input },
|
|
28
|
+
context,
|
|
29
|
+
}));
|
|
30
|
+
server.registerTool(callGraph.name, toolRegistrationOptions(callGraph), (input, context) => executeEnhancedTool(analysis, options, callGraph, {
|
|
31
|
+
validatedCall: { name: "get_call_graph", input },
|
|
32
|
+
context,
|
|
33
|
+
}));
|
|
34
|
+
server.registerTool(swiftTypes.name, toolRegistrationOptions(swiftTypes), (input, context) => executeEnhancedTool(analysis, options, swiftTypes, {
|
|
35
|
+
validatedCall: { name: "analyze_swift_types", input },
|
|
36
|
+
context,
|
|
37
|
+
}));
|
|
38
|
+
server.registerTool(xrefsToName.name, toolRegistrationOptions(xrefsToName), (input, context) => executeEnhancedTool(analysis, options, xrefsToName, {
|
|
39
|
+
validatedCall: { name: "find_xrefs_to_name", input },
|
|
40
|
+
context,
|
|
41
|
+
}));
|
|
42
|
+
server.registerTool(binaryOverview.name, toolRegistrationOptions(binaryOverview), (input, context) => executeEnhancedTool(analysis, options, binaryOverview, {
|
|
43
|
+
validatedCall: { name: "binary_overview", input },
|
|
44
|
+
context,
|
|
45
|
+
}));
|
|
46
|
+
server.registerTool(analyzeFunction.name, toolRegistrationOptions(analyzeFunction), (input, context) => executeEnhancedTool(analysis, options, analyzeFunction, {
|
|
47
|
+
validatedCall: { name: "analyze_function", input },
|
|
48
|
+
context,
|
|
49
|
+
}));
|
|
50
|
+
server.registerTool(inspectNativeApi.name, toolRegistrationOptions(inspectNativeApi), (input, context) => executeEnhancedTool(analysis, options, inspectNativeApi, {
|
|
51
|
+
validatedCall: { name: "inspect_native_api", input },
|
|
52
|
+
context,
|
|
53
|
+
}));
|
|
54
|
+
server.registerTool(traceFeature.name, toolRegistrationOptions(traceFeature), (input, context) => executeEnhancedTool(analysis, options, traceFeature, {
|
|
55
|
+
validatedCall: { name: "trace_feature", input },
|
|
56
|
+
context,
|
|
57
|
+
}));
|
|
58
|
+
server.registerTool(codeForString.name, toolRegistrationOptions(codeForString), (input, context) => executeEnhancedTool(analysis, options, codeForString, {
|
|
59
|
+
validatedCall: { name: "find_code_for_string", input },
|
|
60
|
+
context,
|
|
61
|
+
}));
|
|
62
|
+
server.registerTool(traceCallPath.name, toolRegistrationOptions(traceCallPath), (input, context) => executeEnhancedTool(analysis, options, traceCallPath, {
|
|
63
|
+
validatedCall: { name: "trace_call_path", input },
|
|
64
|
+
context,
|
|
65
|
+
}));
|
|
24
66
|
};
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
67
|
+
const executeEnhancedTool = async (analysis, registration, contract, request) => {
|
|
68
|
+
const { validatedCall, context } = request;
|
|
69
|
+
const name = validatedCall.name;
|
|
70
|
+
const progress = mcpProgressReporter(context);
|
|
71
|
+
await progress.report({
|
|
72
|
+
phase: name,
|
|
73
|
+
completed: 0,
|
|
74
|
+
total: 1,
|
|
75
|
+
message: "started",
|
|
76
|
+
});
|
|
77
|
+
const parsedInput = validatedCall.input;
|
|
78
|
+
const parameters = jsonParameters(parsedInput);
|
|
79
|
+
const services = new EnhancedTools({
|
|
80
|
+
execute: (operation, operationParameters, executionOptions) => analysis.execute(operation, operationParameters, {
|
|
81
|
+
...executionOptions,
|
|
82
|
+
progress,
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
const result = await logToolExecution(registration.logger, name, () => services.executeValidated(validatedCall, context.mcpReq.signal));
|
|
86
|
+
await progress.report({
|
|
87
|
+
phase: name,
|
|
88
|
+
completed: 1,
|
|
89
|
+
total: 1,
|
|
90
|
+
message: result.ok ? "completed" : "failed",
|
|
91
|
+
terminal: true,
|
|
92
|
+
});
|
|
93
|
+
if (result.ok) {
|
|
94
|
+
const upstreamProfile = registration.analysisProfile?.();
|
|
95
|
+
const evidence = createEvidence(registration.activeTarget?.(), REA_WORKFLOW_PROVIDER, {
|
|
96
|
+
operation: name,
|
|
97
|
+
parameters,
|
|
98
|
+
result: result.value,
|
|
99
|
+
...(upstreamProfile === undefined
|
|
100
|
+
? {}
|
|
101
|
+
: {
|
|
102
|
+
analysisProfile: workflowAnalysisProfile(upstreamProfile),
|
|
103
|
+
}),
|
|
104
|
+
confidence: "derived",
|
|
105
|
+
limitations: [
|
|
106
|
+
"Derived by an REA workflow from one or more provider observations.",
|
|
107
|
+
],
|
|
34
108
|
});
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
return toCallToolResult(
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}),
|
|
109
|
+
const recorded = registration.recordEvidence?.(evidence);
|
|
110
|
+
if (recorded !== undefined && !recorded.ok)
|
|
111
|
+
return toCallToolResult(recorded, contract);
|
|
112
|
+
const unknowns = recordWorkflowUnknowns({
|
|
113
|
+
name,
|
|
114
|
+
input: parameters,
|
|
115
|
+
result: result.value,
|
|
116
|
+
evidenceId: evidence.evidence_id,
|
|
117
|
+
recordUnknown: registration.recordUnknown,
|
|
45
118
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
total: 1,
|
|
51
|
-
message: result.ok ? "completed" : "failed",
|
|
52
|
-
terminal: true,
|
|
119
|
+
if (!unknowns.ok)
|
|
120
|
+
return toCallToolResult(unknowns, contract);
|
|
121
|
+
return toCallToolResult({ ok: true, value: evidence }, contract, {
|
|
122
|
+
evidenceResourcesAvailable: recorded !== undefined,
|
|
53
123
|
});
|
|
54
|
-
if (result.ok) {
|
|
55
|
-
const upstreamProfile = registration.analysisProfile?.();
|
|
56
|
-
const evidence = createEvidence(registration.activeTarget?.(), REA_WORKFLOW_PROVIDER, {
|
|
57
|
-
operation: name,
|
|
58
|
-
parameters,
|
|
59
|
-
result: result.value,
|
|
60
|
-
...(upstreamProfile === undefined
|
|
61
|
-
? {}
|
|
62
|
-
: {
|
|
63
|
-
analysisProfile: workflowAnalysisProfile(upstreamProfile),
|
|
64
|
-
}),
|
|
65
|
-
confidence: "derived",
|
|
66
|
-
limitations: [
|
|
67
|
-
"Derived by an REA workflow from one or more provider observations.",
|
|
68
|
-
],
|
|
69
|
-
});
|
|
70
|
-
const recorded = registration.recordEvidence?.(evidence);
|
|
71
|
-
if (recorded !== undefined && !recorded.ok)
|
|
72
|
-
return toCallToolResult(recorded, contract);
|
|
73
|
-
const unknowns = recordWorkflowUnknowns({
|
|
74
|
-
name,
|
|
75
|
-
input: parameters,
|
|
76
|
-
result: result.value,
|
|
77
|
-
evidenceId: evidence.evidence_id,
|
|
78
|
-
recordUnknown: registration.recordUnknown,
|
|
79
|
-
});
|
|
80
|
-
if (!unknowns.ok)
|
|
81
|
-
return toCallToolResult(unknowns, contract);
|
|
82
|
-
return toCallToolResult({ ok: true, value: evidence }, contract, {
|
|
83
|
-
evidenceResourcesAvailable: recorded !== undefined,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return toCallToolResult(result, contract);
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
const jsonParameters = (input) => Object.fromEntries(Object.entries(input).filter((entry) => entry[1] !== undefined));
|
|
90
|
-
const ENHANCED_INPUT_PARSERS = {
|
|
91
|
-
swift_classes: (input) => safeParseToolInput(enhancedInputSchemas.swift_classes, input, "swift_classes"),
|
|
92
|
-
get_objc_classes: (input) => safeParseToolInput(enhancedInputSchemas.get_objc_classes, input, "get_objc_classes"),
|
|
93
|
-
get_objc_protocols: (input) => safeParseToolInput(enhancedInputSchemas.get_objc_protocols, input, "get_objc_protocols"),
|
|
94
|
-
batch_decompile: (input) => safeParseToolInput(enhancedInputSchemas.batch_decompile, input, "batch_decompile"),
|
|
95
|
-
get_call_graph: (input) => safeParseToolInput(enhancedInputSchemas.get_call_graph, input, "get_call_graph"),
|
|
96
|
-
analyze_swift_types: (input) => safeParseToolInput(enhancedInputSchemas.analyze_swift_types, input, "analyze_swift_types"),
|
|
97
|
-
find_xrefs_to_name: (input) => safeParseToolInput(enhancedInputSchemas.find_xrefs_to_name, input, "find_xrefs_to_name"),
|
|
98
|
-
binary_overview: (input) => safeParseToolInput(enhancedInputSchemas.binary_overview, input, "binary_overview"),
|
|
99
|
-
analyze_function: (input) => safeParseToolInput(enhancedInputSchemas.analyze_function, input, "analyze_function"),
|
|
100
|
-
inspect_native_api: (input) => safeParseToolInput(enhancedInputSchemas.inspect_native_api, input, "inspect_native_api"),
|
|
101
|
-
trace_feature: (input) => safeParseToolInput(enhancedInputSchemas.trace_feature, input, "trace_feature"),
|
|
102
|
-
find_code_for_string: (input) => safeParseToolInput(enhancedInputSchemas.find_code_for_string, input, "find_code_for_string"),
|
|
103
|
-
trace_call_path: (input) => safeParseToolInput(enhancedInputSchemas.trace_call_path, input, "trace_call_path"),
|
|
104
|
-
};
|
|
105
|
-
const parseEnhancedCall = (name, input) => {
|
|
106
|
-
switch (name) {
|
|
107
|
-
case "swift_classes":
|
|
108
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.swift_classes(input), (value) => ({ name, input: value }));
|
|
109
|
-
case "get_objc_classes":
|
|
110
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.get_objc_classes(input), (value) => ({ name, input: value }));
|
|
111
|
-
case "get_objc_protocols":
|
|
112
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.get_objc_protocols(input), (value) => ({ name, input: value }));
|
|
113
|
-
case "batch_decompile":
|
|
114
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.batch_decompile(input), (value) => ({ name, input: value }));
|
|
115
|
-
case "get_call_graph":
|
|
116
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.get_call_graph(input), (value) => ({ name, input: value }));
|
|
117
|
-
case "analyze_swift_types":
|
|
118
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.analyze_swift_types(input), (value) => ({ name, input: value }));
|
|
119
|
-
case "find_xrefs_to_name":
|
|
120
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.find_xrefs_to_name(input), (value) => ({ name, input: value }));
|
|
121
|
-
case "binary_overview":
|
|
122
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.binary_overview(input), (value) => ({ name, input: value }));
|
|
123
|
-
case "analyze_function":
|
|
124
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.analyze_function(input), (value) => ({ name, input: value }));
|
|
125
|
-
case "inspect_native_api":
|
|
126
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.inspect_native_api(input), (value) => ({ name, input: value }));
|
|
127
|
-
case "trace_feature":
|
|
128
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.trace_feature(input), (value) => ({ name, input: value }));
|
|
129
|
-
case "find_code_for_string":
|
|
130
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.find_code_for_string(input), (value) => ({ name, input: value }));
|
|
131
|
-
case "trace_call_path":
|
|
132
|
-
return mapEnhancedCall(ENHANCED_INPUT_PARSERS.trace_call_path(input), (value) => ({ name, input: value }));
|
|
133
124
|
}
|
|
125
|
+
return toCallToolResult(result, contract);
|
|
134
126
|
};
|
|
135
|
-
const
|
|
127
|
+
const jsonParameters = (input) => Object.fromEntries(Object.entries(input).filter((entry) => entry[1] !== undefined));
|
|
136
128
|
const recordWorkflowUnknowns = ({ name, input, result, evidenceId, recordUnknown, }) => {
|
|
137
129
|
if (![
|
|
138
130
|
"trace_feature",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { AnalysisProtocolError, PermissionRequiredError, } from "../domain/errors.js";
|
|
1
2
|
import { createEvidence } from "../domain/evidence.js";
|
|
2
3
|
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
|
4
|
+
import { err } from "../domain/result.js";
|
|
5
|
+
import { mcpProgressReporter } from "./mcpProgress.js";
|
|
3
6
|
import { logToolExecution } from "./toolLogging.js";
|
|
4
|
-
import { toCallToolResult } from "./toolResult.js";
|
|
5
7
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
6
|
-
import {
|
|
7
|
-
import { safeParseToolInput } from "./toolInputValidation.js";
|
|
8
|
-
import { AnalysisProtocolError, PermissionRequiredError, } from "../domain/errors.js";
|
|
9
|
-
import { err } from "../domain/result.js";
|
|
8
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
10
9
|
/** Register provider-backed contracts that return atomic Evidence v2 observations. */
|
|
11
10
|
export const registerEvidenceTools = (server, analysis, contracts, options) => {
|
|
12
11
|
for (const contract of contracts) {
|
|
@@ -18,10 +17,7 @@ export const registerEvidenceTools = (server, analysis, contracts, options) => {
|
|
|
18
17
|
total: 1,
|
|
19
18
|
message: "started",
|
|
20
19
|
});
|
|
21
|
-
const
|
|
22
|
-
if (!parsedInput.ok)
|
|
23
|
-
return toCallToolResult(parsedInput, contract);
|
|
24
|
-
const parameters = jsonObjectSchema.parse(parsedInput.value);
|
|
20
|
+
const parameters = jsonObjectSchema.parse(input);
|
|
25
21
|
if (options.permissionAuthority !== undefined) {
|
|
26
22
|
const request = permissionRequest(contract.name, parameters);
|
|
27
23
|
if (request !== undefined) {
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
2
2
|
import { createEvidence } from "../domain/evidence.js";
|
|
3
|
+
import { compareFunctions } from "../domain/functionComparison.js";
|
|
3
4
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
4
|
-
import { FUNCTION_COMPARISON_PROVIDER } from "./sessionToolPolicies.js";
|
|
5
|
-
import { toCallToolResult } from "./toolResult.js";
|
|
6
5
|
import { recordDerivedEvidence } from "./recordDerivedEvidence.js";
|
|
6
|
+
import { runDerivedOperation } from "./runDerivedOperation.js";
|
|
7
7
|
import { resolveSessionEvidenceIds } from "./sessionEvidence.js";
|
|
8
|
+
import { FUNCTION_COMPARISON_PROVIDER } from "./sessionToolPolicies.js";
|
|
8
9
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
9
|
-
import {
|
|
10
|
-
import { safeParseToolInput } from "./toolInputValidation.js";
|
|
10
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
11
11
|
/** Register explicit Evidence-backed function comparison. */
|
|
12
12
|
export const registerFunctionComparisonTool = (server, session, contract) => {
|
|
13
13
|
server.registerTool(contract.name, toolRegistrationOptions(contract), async (input, context) => {
|
|
14
|
-
const parsedInput = safeParseToolInput(functionComparisonInputSchema, input, contract.name);
|
|
15
|
-
if (!parsedInput.ok)
|
|
16
|
-
return toCallToolResult(parsedInput, contract);
|
|
17
|
-
const parsed = parsedInput.value;
|
|
18
14
|
const expected = {
|
|
19
15
|
operation: "analyze_function",
|
|
20
16
|
predicate: "rea.analysis/v2",
|
|
21
17
|
};
|
|
22
|
-
const left = resolveSessionEvidenceIds(session,
|
|
18
|
+
const left = resolveSessionEvidenceIds(session, input.left_evidence_ids, expected);
|
|
23
19
|
if (!left.ok)
|
|
24
20
|
return toCallToolResult(left, contract);
|
|
25
|
-
const right = resolveSessionEvidenceIds(session,
|
|
21
|
+
const right = resolveSessionEvidenceIds(session, input.right_evidence_ids, expected);
|
|
26
22
|
if (!right.ok)
|
|
27
23
|
return toCallToolResult(right, contract);
|
|
28
24
|
const leftIds = left.value.map(({ evidence_id: id }) => id);
|
|
29
25
|
const rightIds = right.value.map(({ evidence_id: id }) => id);
|
|
30
|
-
const computed = await runDerivedOperation(context, contract.name, () => compareFunctions(left.value, right.value,
|
|
26
|
+
const computed = await runDerivedOperation(context, contract.name, () => compareFunctions(left.value, right.value, input.offset, input.limit));
|
|
31
27
|
if (!computed.ok)
|
|
32
28
|
return toCallToolResult(computed, contract);
|
|
33
29
|
const comparison = computed.value;
|
|
@@ -37,8 +33,8 @@ export const registerFunctionComparisonTool = (server, session, contract) => {
|
|
|
37
33
|
parameters: {
|
|
38
34
|
left_evidence_ids: leftIds,
|
|
39
35
|
right_evidence_ids: rightIds,
|
|
40
|
-
offset:
|
|
41
|
-
limit:
|
|
36
|
+
offset: input.offset,
|
|
37
|
+
limit: input.limit,
|
|
42
38
|
},
|
|
43
39
|
result: jsonValueSchema.parse(comparison),
|
|
44
40
|
confidence: "derived",
|
|
@@ -47,7 +43,7 @@ export const registerFunctionComparisonTool = (server, session, contract) => {
|
|
|
47
43
|
evidenceLinks: [...leftIds, ...rightIds],
|
|
48
44
|
});
|
|
49
45
|
const recorded = recordDerivedEvidence(session, evidence, functionUnknownInput({
|
|
50
|
-
approved:
|
|
46
|
+
approved: input.unknown_registry_approved,
|
|
51
47
|
status: comparison.status,
|
|
52
48
|
leftIds,
|
|
53
49
|
rightIds,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { runCrossVersionInvestigationValidated } from "../application/CrossVersionInvestigation.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { buildCallPath
|
|
5
|
-
import {
|
|
6
|
-
import { reconstructionVerificationInputSchema, verifyReconstruction, } from "../domain/reconstructionVerification.js";
|
|
7
|
-
import { changedBehaviorResultSchema, changedBehaviorInputSchema, findChangedBehavior, } from "../domain/changedBehavior.js";
|
|
8
|
-
import { createEvidence } from "../domain/evidence.js";
|
|
2
|
+
import { authorizeFileReadWithDeferredWrite, authorizeRootPermission, } from "../application/DeferredFileAuthorization.js";
|
|
3
|
+
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
4
|
+
import { buildCallPath } from "../domain/callPath.js";
|
|
5
|
+
import { changedBehaviorInputSchema, changedBehaviorResultSchema, findChangedBehavior, } from "../domain/changedBehavior.js";
|
|
9
6
|
import {} from "../domain/errors.js";
|
|
7
|
+
import { createEvidence } from "../domain/evidence.js";
|
|
10
8
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { verifyReconstruction } from "../domain/reconstructionVerification.js";
|
|
10
|
+
import { correlateStaticAndRuntime } from "../domain/staticRuntimeCorrelation.js";
|
|
13
11
|
import { mcpProgressReporter } from "./mcpProgress.js";
|
|
14
|
-
import { runDerivedOperation, } from "./runDerivedOperation.js";
|
|
15
|
-
import { authorizeFileReadWithDeferredWrite, authorizeRootPermission, } from "../application/DeferredFileAuthorization.js";
|
|
16
12
|
import { comparisonClosure, evidenceClosure, functionEvidenceIds, investigationContext, isIncomplete, recordWorkflowEvidence, verifyCoverageReadiness, } from "./registerInvestigationTools/helpers.js";
|
|
13
|
+
import { runDerivedOperation, } from "./runDerivedOperation.js";
|
|
14
|
+
import { CALL_PATH_PROVIDER, CHANGED_BEHAVIOR_PROVIDER, RECONSTRUCTION_PROVIDER, STATIC_RUNTIME_PROVIDER, } from "./sessionToolPolicies.js";
|
|
15
|
+
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
16
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
17
17
|
/** Register Evidence-composed differential investigation workflows. */
|
|
18
18
|
export const registerInvestigationTools = (server, session, contracts, policies) => {
|
|
19
19
|
registerChangedBehavior(server, session, contracts[0], policies);
|
|
@@ -23,11 +23,7 @@ export const registerInvestigationTools = (server, session, contracts, policies)
|
|
|
23
23
|
};
|
|
24
24
|
const registerChangedBehavior = (server, session, contract, policies) => {
|
|
25
25
|
server.registerTool(contract.name, contractOptions(contract), async (input, context) => {
|
|
26
|
-
const
|
|
27
|
-
if (!parsedInput.ok)
|
|
28
|
-
return toCallToolResult(parsedInput, contract);
|
|
29
|
-
const parsed = parsedInput.value;
|
|
30
|
-
const investigationRun = parsed.investigation_run;
|
|
26
|
+
const investigationRun = input.investigation_run;
|
|
31
27
|
if (investigationRun !== undefined)
|
|
32
28
|
return runAutomaticInvestigation({
|
|
33
29
|
server,
|
|
@@ -35,14 +31,14 @@ const registerChangedBehavior = (server, session, contract, policies) => {
|
|
|
35
31
|
contract,
|
|
36
32
|
policies,
|
|
37
33
|
investigationRun,
|
|
38
|
-
unknownRegistryApproved:
|
|
34
|
+
unknownRegistryApproved: input.unknown_registry_approved,
|
|
39
35
|
context,
|
|
40
36
|
});
|
|
41
|
-
const closure = evidenceClosure(session, comparisonClosure(
|
|
37
|
+
const closure = evidenceClosure(session, comparisonClosure(input.comparisons));
|
|
42
38
|
if (!closure.ok)
|
|
43
39
|
return toCallToolResult(closure, contract);
|
|
44
40
|
const links = closure.value;
|
|
45
|
-
const computed = await runDerivedOperation(context, contract.name, () => findChangedBehavior(
|
|
41
|
+
const computed = await runDerivedOperation(context, contract.name, () => findChangedBehavior(input.comparisons, input.offset, input.limit));
|
|
46
42
|
if (!computed.ok)
|
|
47
43
|
return toCallToolResult(computed, contract);
|
|
48
44
|
const result = computed.value;
|
|
@@ -50,9 +46,9 @@ const registerChangedBehavior = (server, session, contract, policies) => {
|
|
|
50
46
|
predicateType: "rea.changed-behavior/v1",
|
|
51
47
|
operation: contract.name,
|
|
52
48
|
parameters: {
|
|
53
|
-
comparison_evidence_ids:
|
|
54
|
-
offset:
|
|
55
|
-
limit:
|
|
49
|
+
comparison_evidence_ids: input.comparisons.map(({ evidence_id: id }) => id),
|
|
50
|
+
offset: input.offset,
|
|
51
|
+
limit: input.limit,
|
|
56
52
|
},
|
|
57
53
|
result: jsonValueSchema.parse(result),
|
|
58
54
|
confidence: "derived",
|
|
@@ -60,7 +56,7 @@ const registerChangedBehavior = (server, session, contract, policies) => {
|
|
|
60
56
|
limitations: result.limitations,
|
|
61
57
|
evidenceLinks: links,
|
|
62
58
|
});
|
|
63
|
-
const recorded = recordWorkflowEvidence(session, evidence,
|
|
59
|
+
const recorded = recordWorkflowEvidence(session, evidence, input.unknown_registry_approved, isIncomplete(result.behavior_status), {
|
|
64
60
|
question: "Did both versions behave the same under a complete controlled replay?",
|
|
65
61
|
domain: "changed-behavior",
|
|
66
62
|
requiredAuthority: "controlled-replay",
|
|
@@ -144,15 +140,11 @@ const runAutomaticInvestigation = async (input) => {
|
|
|
144
140
|
};
|
|
145
141
|
const registerCallPath = (server, session, contract) => {
|
|
146
142
|
server.registerTool(contract.name, contractOptions(contract), async (input, context) => {
|
|
147
|
-
const
|
|
148
|
-
if (!parsedInput.ok)
|
|
149
|
-
return toCallToolResult(parsedInput, contract);
|
|
150
|
-
const parsed = parsedInput.value;
|
|
151
|
-
const closure = evidenceClosure(session, functionEvidenceIds(parsed.functions));
|
|
143
|
+
const closure = evidenceClosure(session, functionEvidenceIds(input.functions));
|
|
152
144
|
if (!closure.ok)
|
|
153
145
|
return toCallToolResult(closure, contract);
|
|
154
146
|
const links = closure.value;
|
|
155
|
-
const computed = await runDerivedOperation(context, contract.name, () => buildCallPath(
|
|
147
|
+
const computed = await runDerivedOperation(context, contract.name, () => buildCallPath(input));
|
|
156
148
|
if (!computed.ok)
|
|
157
149
|
return toCallToolResult(computed, contract);
|
|
158
150
|
const result = computed.value;
|
|
@@ -160,12 +152,12 @@ const registerCallPath = (server, session, contract) => {
|
|
|
160
152
|
predicateType: "rea.call-path/v1",
|
|
161
153
|
operation: contract.name,
|
|
162
154
|
parameters: {
|
|
163
|
-
start:
|
|
164
|
-
goal:
|
|
165
|
-
max_depth:
|
|
166
|
-
max_paths:
|
|
167
|
-
offset:
|
|
168
|
-
limit:
|
|
155
|
+
start: input.start.address,
|
|
156
|
+
goal: input.goal.address,
|
|
157
|
+
max_depth: input.max_depth,
|
|
158
|
+
max_paths: input.max_paths,
|
|
159
|
+
offset: input.offset,
|
|
160
|
+
limit: input.limit,
|
|
169
161
|
},
|
|
170
162
|
result: jsonValueSchema.parse(result),
|
|
171
163
|
confidence: "derived",
|
|
@@ -173,7 +165,7 @@ const registerCallPath = (server, session, contract) => {
|
|
|
173
165
|
limitations: result.limitations,
|
|
174
166
|
evidenceLinks: links,
|
|
175
167
|
});
|
|
176
|
-
const recorded = recordWorkflowEvidence(session, evidence,
|
|
168
|
+
const recorded = recordWorkflowEvidence(session, evidence, input.unknown_registry_approved, result.status === "unknown" || result.status === "truncated", {
|
|
177
169
|
question: "Can the requested call path be established from complete analysis?",
|
|
178
170
|
domain: "call-path",
|
|
179
171
|
requiredAuthority: "shipped-artifact",
|
|
@@ -190,18 +182,14 @@ const registerCallPath = (server, session, contract) => {
|
|
|
190
182
|
};
|
|
191
183
|
const registerStaticRuntime = (server, session, contract) => {
|
|
192
184
|
server.registerTool(contract.name, contractOptions(contract), async (input, context) => {
|
|
193
|
-
const parsedInput = safeParseToolInput(staticRuntimeCorrelationInputSchema, input, contract.name);
|
|
194
|
-
if (!parsedInput.ok)
|
|
195
|
-
return toCallToolResult(parsedInput, contract);
|
|
196
|
-
const parsed = parsedInput.value;
|
|
197
185
|
const closure = evidenceClosure(session, comparisonClosure([
|
|
198
|
-
...
|
|
199
|
-
...
|
|
186
|
+
...input.static_comparisons,
|
|
187
|
+
...input.runtime_comparisons,
|
|
200
188
|
]));
|
|
201
189
|
if (!closure.ok)
|
|
202
190
|
return toCallToolResult(closure, contract);
|
|
203
191
|
const links = closure.value;
|
|
204
|
-
const computed = await runDerivedOperation(context, contract.name, () => correlateStaticAndRuntime(
|
|
192
|
+
const computed = await runDerivedOperation(context, contract.name, () => correlateStaticAndRuntime(input));
|
|
205
193
|
if (!computed.ok)
|
|
206
194
|
return toCallToolResult(computed, contract);
|
|
207
195
|
const result = computed.value;
|
|
@@ -209,9 +197,9 @@ const registerStaticRuntime = (server, session, contract) => {
|
|
|
209
197
|
predicateType: "rea.static-runtime-correlation/v1",
|
|
210
198
|
operation: contract.name,
|
|
211
199
|
parameters: {
|
|
212
|
-
mapping_count:
|
|
213
|
-
offset:
|
|
214
|
-
limit:
|
|
200
|
+
mapping_count: input.mappings.length,
|
|
201
|
+
offset: input.offset,
|
|
202
|
+
limit: input.limit,
|
|
215
203
|
},
|
|
216
204
|
result: jsonValueSchema.parse(result),
|
|
217
205
|
confidence: "inferred",
|
|
@@ -219,7 +207,7 @@ const registerStaticRuntime = (server, session, contract) => {
|
|
|
219
207
|
limitations: result.limitations,
|
|
220
208
|
evidenceLinks: links,
|
|
221
209
|
});
|
|
222
|
-
return toCallToolResult(recordWorkflowEvidence(session, evidence,
|
|
210
|
+
return toCallToolResult(recordWorkflowEvidence(session, evidence, input.unknown_registry_approved, result.status === "unknown" || result.status === "truncated", {
|
|
223
211
|
question: "Does runtime behavior match the available static analysis?",
|
|
224
212
|
domain: "static-runtime-correlation",
|
|
225
213
|
requiredAuthority: null,
|
|
@@ -235,15 +223,11 @@ const registerStaticRuntime = (server, session, contract) => {
|
|
|
235
223
|
};
|
|
236
224
|
const registerReconstruction = (server, session, contract) => {
|
|
237
225
|
server.registerTool(contract.name, contractOptions(contract), async (input, context) => {
|
|
238
|
-
const
|
|
239
|
-
if (!parsedInput.ok)
|
|
240
|
-
return toCallToolResult(parsedInput, contract);
|
|
241
|
-
const parsed = parsedInput.value;
|
|
242
|
-
const coverage = verifyCoverageReadiness(session, parsed.coverage);
|
|
226
|
+
const coverage = verifyCoverageReadiness(session, input.coverage);
|
|
243
227
|
if (!coverage.ok)
|
|
244
228
|
return toCallToolResult(coverage, contract);
|
|
245
229
|
const owned = session.exportEvidenceBundle();
|
|
246
|
-
const computed = await runDerivedOperation(context, contract.name, () => verifyReconstruction(
|
|
230
|
+
const computed = await runDerivedOperation(context, contract.name, () => verifyReconstruction(input.specification, owned, input.offset, input.limit));
|
|
247
231
|
if (!computed.ok)
|
|
248
232
|
return toCallToolResult(computed, contract);
|
|
249
233
|
const result = computed.value;
|
|
@@ -256,9 +240,9 @@ const registerReconstruction = (server, session, contract) => {
|
|
|
256
240
|
operation: contract.name,
|
|
257
241
|
parameters: {
|
|
258
242
|
specification_sha256: result.specification_sha256,
|
|
259
|
-
claim_ids:
|
|
260
|
-
offset:
|
|
261
|
-
limit:
|
|
243
|
+
claim_ids: input.specification.claims.map(({ claim_id: id }) => id),
|
|
244
|
+
offset: input.offset,
|
|
245
|
+
limit: input.limit,
|
|
262
246
|
},
|
|
263
247
|
result: jsonValueSchema.parse(result),
|
|
264
248
|
confidence: "derived",
|
|
@@ -266,7 +250,7 @@ const registerReconstruction = (server, session, contract) => {
|
|
|
266
250
|
limitations: result.limitations,
|
|
267
251
|
evidenceLinks: links,
|
|
268
252
|
});
|
|
269
|
-
return toCallToolResult(recordWorkflowEvidence(session, evidence,
|
|
253
|
+
return toCallToolResult(recordWorkflowEvidence(session, evidence, input.unknown_registry_approved, result.status === "unknown", {
|
|
270
254
|
question: "Does the reconstruction satisfy every declared claim?",
|
|
271
255
|
domain: "reconstruction-verification",
|
|
272
256
|
requiredAuthority: null,
|
|
@@ -1,37 +1,23 @@
|
|
|
1
1
|
import { listJavaScriptRuntimeTargets, observeJavaScriptRuntime, } from "../application/JavaScriptRuntimeObservationService.js";
|
|
2
2
|
import { JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS } from "../contracts/javascriptRuntimeObservationToolContracts.js";
|
|
3
|
-
import { listJavaScriptRuntimeTargetsInputSchema, observeJavaScriptRuntimeInputSchema, } from "../domain/javascriptRuntimeObservation.js";
|
|
4
3
|
import { logToolExecution } from "./toolLogging.js";
|
|
5
|
-
import { safeParseToolInput } from "./toolInputValidation.js";
|
|
6
4
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
7
5
|
import { toCallToolResult } from "./toolResult.js";
|
|
8
6
|
/** Register passive Inspector tools even when policy keeps them unavailable. */
|
|
9
7
|
export const registerJavaScriptRuntimeObservationTools = (server, options) => {
|
|
10
8
|
const [listContract, observeContract] = JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
schema: listJavaScriptRuntimeTargetsInputSchema,
|
|
14
|
-
execute: (parsed, signal) => listJavaScriptRuntimeTargets(options.runtime, options.permissionAuthority, parsed, { signal }),
|
|
15
|
-
});
|
|
16
|
-
registerRuntimeTool(server, options, {
|
|
17
|
-
contract: observeContract,
|
|
18
|
-
schema: observeJavaScriptRuntimeInputSchema,
|
|
19
|
-
execute: (parsed, signal) => observeJavaScriptRuntime(options.runtime, options.permissionAuthority, parsed, { signal }),
|
|
20
|
-
});
|
|
9
|
+
server.registerTool(listContract.name, toolRegistrationOptions(listContract), (input, context) => runRuntimeTool(options, listContract, { input, context }, (parsed, signal) => listJavaScriptRuntimeTargets(options.runtime, options.permissionAuthority, parsed, { signal })));
|
|
10
|
+
server.registerTool(observeContract.name, toolRegistrationOptions(observeContract), (input, context) => runRuntimeTool(options, observeContract, { input, context }, (parsed, signal) => observeJavaScriptRuntime(options.runtime, options.permissionAuthority, parsed, { signal })));
|
|
21
11
|
};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
: toCallToolResult({ ok: true, value: result.value }, spec.contract, {
|
|
34
|
-
evidenceResourcesAvailable: recorded !== undefined,
|
|
35
|
-
});
|
|
36
|
-
});
|
|
12
|
+
const runRuntimeTool = async (options, contract, request, execute) => {
|
|
13
|
+
const { input, context } = request;
|
|
14
|
+
const result = await logToolExecution(options.logger, contract.name, () => execute(input, context.mcpReq.signal));
|
|
15
|
+
if (!result.ok)
|
|
16
|
+
return toCallToolResult(result, contract);
|
|
17
|
+
const recorded = options.recordEvidence?.(result.value);
|
|
18
|
+
return recorded !== undefined && !recorded.ok
|
|
19
|
+
? toCallToolResult(recorded, contract)
|
|
20
|
+
: toCallToolResult({ ok: true, value: result.value }, contract, {
|
|
21
|
+
evidenceResourcesAvailable: recorded !== undefined,
|
|
22
|
+
});
|
|
37
23
|
};
|