rea-agents 2.5.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 +20 -12
- package/bridge/ghidra/ReaGhidraBridge.java +477 -4
- package/bridge/hopper_bridge.py +54 -4
- package/dist/application/AnalysisContextQueries.js +142 -0
- package/dist/application/AnalysisSnapshotCache.js +4 -2
- 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 +19 -20
- package/dist/application/BinarySessionComposition.js +21 -0
- package/dist/application/BinarySessionRecords.js +106 -10
- 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 +140 -55
- package/dist/application/ClientRegistrationStatus.js +4 -1
- package/dist/application/CrossVersionInventory.js +7 -6
- package/dist/application/DirectAnalysis.js +6 -2
- 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 +49 -17
- package/dist/application/EvidenceBundleCommands.js +5 -1
- package/dist/application/EvidenceLedger.js +53 -17
- package/dist/application/JavaScriptArtifactAnalysis.js +13 -4
- package/dist/application/JavaScriptReplayPermission.js +1 -1
- package/dist/application/JavaScriptReplayService.js +23 -15
- package/dist/application/LazyAnalysisProvider.js +77 -0
- package/dist/application/LoopbackReplay.js +1 -1
- package/dist/application/ManagedRuntimeCorrelationService.js +9 -5
- package/dist/application/NativeApiInspection.js +80 -0
- 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/SessionProviderRouter.js +6 -6
- package/dist/application/SetupClientConfiguration.js +10 -3
- package/dist/application/WindowsCapabilities.js +5 -4
- package/dist/application/runtime.js +26 -9
- 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/PlaywrightBrowserScenarioProvider.js +8 -2
- 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 +15 -9
- package/dist/cli/artifactCommands.js +5 -3
- package/dist/cli/coreAnalysisCommands.js +41 -0
- 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 +2 -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 +35 -37
- package/dist/contracts/browserToolContracts.js +2 -2
- package/dist/contracts/electronToolContracts.js +30 -1
- package/dist/contracts/enhancedInputs.js +21 -27
- package/dist/contracts/functionWorkflowToolContracts.js +29 -0
- 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/promptContracts.js +14 -15
- package/dist/contracts/sessionToolSchemas.js +61 -0
- package/dist/contracts/toolContractExamples.js +4 -0
- package/dist/contracts/toolContractHelpers.js +23 -0
- package/dist/contracts/toolContracts.js +12 -67
- package/dist/contracts/toolEffects.js +19 -0
- package/dist/contracts/toolOutputSchemaGroups.js +66 -11
- package/dist/contracts/toolOutputSchemaPrimitives.js +76 -26
- package/dist/contracts/toolSchemaMetadata.js +128 -0
- package/dist/doctorRuntime.js +1 -1
- package/dist/domain/analysisErrorPresentation.js +8 -2
- package/dist/domain/analysisErrorProjection.js +1 -0
- 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 +177 -0
- package/dist/domain/callPath.js +3 -2
- package/dist/domain/conformancePackage.js +169 -0
- package/dist/domain/conformanceReplay.js +104 -0
- package/dist/domain/conformanceTrustGate.js +328 -0
- package/dist/domain/customProtocolCapture.js +137 -0
- 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 +217 -0
- package/dist/domain/evidenceBundle.js +47 -0
- package/dist/domain/functionComparisonNormalization.js +15 -8
- package/dist/domain/functionDossierEvidence.js +9 -4
- package/dist/domain/hopperStartupFailure.js +1 -1
- package/dist/domain/hopperValues.js +68 -68
- package/dist/domain/inputIssueProjection.js +11 -2
- 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/javascriptSemanticAnalysis.js +8 -12
- package/dist/domain/javascriptSourceParser.js +15 -0
- package/dist/domain/javascriptStaticAnalysis.js +8 -12
- package/dist/domain/knownPageCoverage.js +15 -7
- package/dist/domain/mobileApplicationInvestigation.js +159 -0
- package/dist/domain/nativeApiBoundary.js +138 -0
- package/dist/domain/nodeRuntimeCharacterization.js +14 -13
- package/dist/domain/objcSwiftMetadata.js +150 -0
- package/dist/domain/packageAnalysis.js +123 -0
- package/dist/domain/peInspection.js +196 -0
- 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 +245 -0
- 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/dotnet/ManagedStaticProvider.js +34 -5
- package/dist/generatedMcpToolCatalog.js +37 -0
- package/dist/generatedPackageMetadata.js +4 -4
- package/dist/ghidra/GhidraClient.js +1 -1
- package/dist/ghidra/GhidraClientStartup.js +1 -1
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraFunctionValues.js +44 -16
- package/dist/ghidra/GhidraInventoryValues.js +57 -47
- package/dist/ghidra/GhidraProvider.js +18 -10
- package/dist/ghidra/GhidraProviderCapabilities.js +45 -39
- 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 +27 -3
- package/dist/hopper/HopperProvider.js +42 -44
- package/dist/hopper/HopperRequestQueue.js +32 -4
- package/dist/hopper/HopperResponseStream.js +2 -2
- package/dist/hopper/LinuxPrivateDisplayProbe.js +16 -10
- package/dist/hopper/protocol.js +63 -21
- package/dist/main/reload.js +1 -6
- package/dist/main/state.js +0 -14
- package/dist/main/transport.js +31 -41
- package/dist/main.js +17 -13
- package/dist/mcpDoctor.js +4 -26
- package/dist/mcpStartupPolicy.js +14 -0
- 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 +101 -144
- 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 +124 -122
- package/dist/server/registerEvidenceResources.js +50 -101
- package/dist/server/registerEvidenceTools.js +5 -9
- package/dist/server/registerFunctionComparisonTool.js +11 -15
- package/dist/server/registerInvestigationTools.js +42 -59
- package/dist/server/registerJavaScriptApplicationGraphResource.js +0 -4
- 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/registerReconstructionObligationLedgerResource.js +0 -7
- package/dist/server/registerReconstructionReadinessResource.js +0 -7
- package/dist/server/registerReplayMachineTool.js +4 -10
- package/dist/server/registerSessionRecordTools.js +146 -47
- package/dist/server/registerSessionStatusTool.js +14 -29
- package/dist/server/registerSessionTools.js +45 -41
- package/dist/server/sessionAvailabilityPolicy.js +2 -1
- package/dist/server/sessionToolPolicies.js +1 -5
- package/dist/server/toolRegistrationOptions.js +4 -177
- package/dist/server/toolResult.js +14 -18
- package/package.json +35 -16
- package/scripts/electron-active-hook-boundaries.cjs +394 -0
- package/scripts/electron-active-hook.cjs +501 -0
- package/skills/reverse-engineer-anything/SKILL.md +10 -3
- package/dist/server/DynamicToolAvailability.js +0 -70
- package/dist/server/toolInputValidation.js +0 -77
|
@@ -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",
|
|
@@ -114,8 +110,7 @@ const runAutomaticInvestigation = async (input) => {
|
|
|
114
110
|
if (!investigated.ok)
|
|
115
111
|
return toCallToolResult(investigated, contract);
|
|
116
112
|
const workspace = investigated.value.workspace;
|
|
117
|
-
|
|
118
|
-
input.server.sendResourceListChanged();
|
|
113
|
+
session.retainInvestigationWorkspace(workspace);
|
|
119
114
|
const result = changedBehaviorResultSchema.parse(investigated.value.evidence.normalized_result);
|
|
120
115
|
const toolResult = toCallToolResult(recordWorkflowEvidence(session, investigated.value.evidence, input.unknownRegistryApproved, isIncomplete(result.behavior_status), {
|
|
121
116
|
question: `Automatic changed behavior run ${result.investigation_run?.run_id ?? "unknown"} remains ${result.behavior_status}`,
|
|
@@ -145,15 +140,11 @@ const runAutomaticInvestigation = async (input) => {
|
|
|
145
140
|
};
|
|
146
141
|
const registerCallPath = (server, session, contract) => {
|
|
147
142
|
server.registerTool(contract.name, contractOptions(contract), async (input, context) => {
|
|
148
|
-
const
|
|
149
|
-
if (!parsedInput.ok)
|
|
150
|
-
return toCallToolResult(parsedInput, contract);
|
|
151
|
-
const parsed = parsedInput.value;
|
|
152
|
-
const closure = evidenceClosure(session, functionEvidenceIds(parsed.functions));
|
|
143
|
+
const closure = evidenceClosure(session, functionEvidenceIds(input.functions));
|
|
153
144
|
if (!closure.ok)
|
|
154
145
|
return toCallToolResult(closure, contract);
|
|
155
146
|
const links = closure.value;
|
|
156
|
-
const computed = await runDerivedOperation(context, contract.name, () => buildCallPath(
|
|
147
|
+
const computed = await runDerivedOperation(context, contract.name, () => buildCallPath(input));
|
|
157
148
|
if (!computed.ok)
|
|
158
149
|
return toCallToolResult(computed, contract);
|
|
159
150
|
const result = computed.value;
|
|
@@ -161,12 +152,12 @@ const registerCallPath = (server, session, contract) => {
|
|
|
161
152
|
predicateType: "rea.call-path/v1",
|
|
162
153
|
operation: contract.name,
|
|
163
154
|
parameters: {
|
|
164
|
-
start:
|
|
165
|
-
goal:
|
|
166
|
-
max_depth:
|
|
167
|
-
max_paths:
|
|
168
|
-
offset:
|
|
169
|
-
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,
|
|
170
161
|
},
|
|
171
162
|
result: jsonValueSchema.parse(result),
|
|
172
163
|
confidence: "derived",
|
|
@@ -174,7 +165,7 @@ const registerCallPath = (server, session, contract) => {
|
|
|
174
165
|
limitations: result.limitations,
|
|
175
166
|
evidenceLinks: links,
|
|
176
167
|
});
|
|
177
|
-
const recorded = recordWorkflowEvidence(session, evidence,
|
|
168
|
+
const recorded = recordWorkflowEvidence(session, evidence, input.unknown_registry_approved, result.status === "unknown" || result.status === "truncated", {
|
|
178
169
|
question: "Can the requested call path be established from complete analysis?",
|
|
179
170
|
domain: "call-path",
|
|
180
171
|
requiredAuthority: "shipped-artifact",
|
|
@@ -191,18 +182,14 @@ const registerCallPath = (server, session, contract) => {
|
|
|
191
182
|
};
|
|
192
183
|
const registerStaticRuntime = (server, session, contract) => {
|
|
193
184
|
server.registerTool(contract.name, contractOptions(contract), async (input, context) => {
|
|
194
|
-
const parsedInput = safeParseToolInput(staticRuntimeCorrelationInputSchema, input, contract.name);
|
|
195
|
-
if (!parsedInput.ok)
|
|
196
|
-
return toCallToolResult(parsedInput, contract);
|
|
197
|
-
const parsed = parsedInput.value;
|
|
198
185
|
const closure = evidenceClosure(session, comparisonClosure([
|
|
199
|
-
...
|
|
200
|
-
...
|
|
186
|
+
...input.static_comparisons,
|
|
187
|
+
...input.runtime_comparisons,
|
|
201
188
|
]));
|
|
202
189
|
if (!closure.ok)
|
|
203
190
|
return toCallToolResult(closure, contract);
|
|
204
191
|
const links = closure.value;
|
|
205
|
-
const computed = await runDerivedOperation(context, contract.name, () => correlateStaticAndRuntime(
|
|
192
|
+
const computed = await runDerivedOperation(context, contract.name, () => correlateStaticAndRuntime(input));
|
|
206
193
|
if (!computed.ok)
|
|
207
194
|
return toCallToolResult(computed, contract);
|
|
208
195
|
const result = computed.value;
|
|
@@ -210,9 +197,9 @@ const registerStaticRuntime = (server, session, contract) => {
|
|
|
210
197
|
predicateType: "rea.static-runtime-correlation/v1",
|
|
211
198
|
operation: contract.name,
|
|
212
199
|
parameters: {
|
|
213
|
-
mapping_count:
|
|
214
|
-
offset:
|
|
215
|
-
limit:
|
|
200
|
+
mapping_count: input.mappings.length,
|
|
201
|
+
offset: input.offset,
|
|
202
|
+
limit: input.limit,
|
|
216
203
|
},
|
|
217
204
|
result: jsonValueSchema.parse(result),
|
|
218
205
|
confidence: "inferred",
|
|
@@ -220,7 +207,7 @@ const registerStaticRuntime = (server, session, contract) => {
|
|
|
220
207
|
limitations: result.limitations,
|
|
221
208
|
evidenceLinks: links,
|
|
222
209
|
});
|
|
223
|
-
return toCallToolResult(recordWorkflowEvidence(session, evidence,
|
|
210
|
+
return toCallToolResult(recordWorkflowEvidence(session, evidence, input.unknown_registry_approved, result.status === "unknown" || result.status === "truncated", {
|
|
224
211
|
question: "Does runtime behavior match the available static analysis?",
|
|
225
212
|
domain: "static-runtime-correlation",
|
|
226
213
|
requiredAuthority: null,
|
|
@@ -236,15 +223,11 @@ const registerStaticRuntime = (server, session, contract) => {
|
|
|
236
223
|
};
|
|
237
224
|
const registerReconstruction = (server, session, contract) => {
|
|
238
225
|
server.registerTool(contract.name, contractOptions(contract), async (input, context) => {
|
|
239
|
-
const
|
|
240
|
-
if (!parsedInput.ok)
|
|
241
|
-
return toCallToolResult(parsedInput, contract);
|
|
242
|
-
const parsed = parsedInput.value;
|
|
243
|
-
const coverage = verifyCoverageReadiness(session, parsed.coverage);
|
|
226
|
+
const coverage = verifyCoverageReadiness(session, input.coverage);
|
|
244
227
|
if (!coverage.ok)
|
|
245
228
|
return toCallToolResult(coverage, contract);
|
|
246
229
|
const owned = session.exportEvidenceBundle();
|
|
247
|
-
const computed = await runDerivedOperation(context, contract.name, () => verifyReconstruction(
|
|
230
|
+
const computed = await runDerivedOperation(context, contract.name, () => verifyReconstruction(input.specification, owned, input.offset, input.limit));
|
|
248
231
|
if (!computed.ok)
|
|
249
232
|
return toCallToolResult(computed, contract);
|
|
250
233
|
const result = computed.value;
|
|
@@ -257,9 +240,9 @@ const registerReconstruction = (server, session, contract) => {
|
|
|
257
240
|
operation: contract.name,
|
|
258
241
|
parameters: {
|
|
259
242
|
specification_sha256: result.specification_sha256,
|
|
260
|
-
claim_ids:
|
|
261
|
-
offset:
|
|
262
|
-
limit:
|
|
243
|
+
claim_ids: input.specification.claims.map(({ claim_id: id }) => id),
|
|
244
|
+
offset: input.offset,
|
|
245
|
+
limit: input.limit,
|
|
263
246
|
},
|
|
264
247
|
result: jsonValueSchema.parse(result),
|
|
265
248
|
confidence: "derived",
|
|
@@ -267,7 +250,7 @@ const registerReconstruction = (server, session, contract) => {
|
|
|
267
250
|
limitations: result.limitations,
|
|
268
251
|
evidenceLinks: links,
|
|
269
252
|
});
|
|
270
|
-
return toCallToolResult(recordWorkflowEvidence(session, evidence,
|
|
253
|
+
return toCallToolResult(recordWorkflowEvidence(session, evidence, input.unknown_registry_approved, result.status === "unknown", {
|
|
271
254
|
question: "Does the reconstruction satisfy every declared claim?",
|
|
272
255
|
domain: "reconstruction-verification",
|
|
273
256
|
requiredAuthority: null,
|
|
@@ -5,10 +5,6 @@ export const registerJavaScriptApplicationGraphResource = (server, session) => {
|
|
|
5
5
|
server.registerResource("javascript-application-graph-page", new ResourceTemplate("rea://evidence/{evidenceId}/application-graph/{collection}/offset/{offset}/limit/{limit}", {
|
|
6
6
|
list: undefined,
|
|
7
7
|
complete: {
|
|
8
|
-
evidenceId: (prefix) => session
|
|
9
|
-
.exportEvidenceBundle()
|
|
10
|
-
.records.map(({ evidence_id }) => evidence_id)
|
|
11
|
-
.filter((evidenceId) => evidenceId.startsWith(prefix)),
|
|
12
8
|
collection: (prefix) => ["nodes", "edges"].filter((name) => name.startsWith(prefix)),
|
|
13
9
|
},
|
|
14
10
|
}), {
|
|
@@ -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
|
};
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { compareManagedMembersEvidenceValidated } from "../../application/ManagedMemberComparisonService.js";
|
|
2
|
-
import { compareManagedMembersReferenceInputSchema } from "../../contracts/managedWorkflowToolContracts.js";
|
|
3
2
|
import { managedMemberComparisonResultSchema } from "../../domain/managedMemberComparison.js";
|
|
4
3
|
import { logToolExecution } from "../toolLogging.js";
|
|
5
|
-
import { toCallToolResult } from "../toolResult.js";
|
|
6
4
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
7
|
-
import {
|
|
5
|
+
import { toCallToolResult } from "../toolResult.js";
|
|
8
6
|
import { managedWorkflowContract } from "./contract.js";
|
|
9
7
|
import { recordManagedSources, resolveManagedEvidence } from "./evidence.js";
|
|
10
8
|
const compareContract = managedWorkflowContract("compare_managed_members");
|
|
11
9
|
/** Register the managed member comparison workflow tool. */
|
|
12
10
|
export const registerCompareManagedMembers = (server, options) => {
|
|
13
11
|
server.registerTool(compareContract.name, toolRegistrationOptions(compareContract), async (input) => {
|
|
14
|
-
const parsedInput = safeParseToolInput(compareManagedMembersReferenceInputSchema, input, compareContract.name);
|
|
15
|
-
if (!parsedInput.ok)
|
|
16
|
-
return toCallToolResult(parsedInput, compareContract);
|
|
17
12
|
const resolved = resolveManagedEvidence(options.session, [
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
input.left_evidence_id,
|
|
14
|
+
input.right_evidence_id,
|
|
20
15
|
]);
|
|
21
16
|
if (!resolved.ok)
|
|
22
17
|
return toCallToolResult(resolved, compareContract);
|
|
23
18
|
const [left, right] = resolved.value;
|
|
24
19
|
if (left === undefined || right === undefined)
|
|
25
20
|
throw new TypeError("Managed comparison Evidence resolution failed");
|
|
26
|
-
const { left_evidence_id: _leftEvidenceId, right_evidence_id: _rightEvidenceId, ...referencedInput } =
|
|
21
|
+
const { left_evidence_id: _leftEvidenceId, right_evidence_id: _rightEvidenceId, ...referencedInput } = input;
|
|
27
22
|
const parsed = { ...referencedInput, left, right };
|
|
28
23
|
const result = await logToolExecution(options.logger, compareContract.name, () => Promise.resolve(compareManagedMembersEvidenceValidated(parsed)));
|
|
29
24
|
if (!result.ok)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "../../contracts/managedWorkflowToolContracts.js";
|
|
2
|
-
|
|
3
|
-
export const managedWorkflowContract = (name) => {
|
|
2
|
+
export function managedWorkflowContract(name) {
|
|
4
3
|
const found = MANAGED_WORKFLOW_TOOL_CONTRACTS.find((candidate) => candidate.name === name);
|
|
5
4
|
if (found === undefined)
|
|
6
5
|
throw new Error(`Missing ${name} contract`);
|
|
7
6
|
return found;
|
|
8
|
-
}
|
|
7
|
+
}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { importManagedReconstructionEvidenceValidated } from "../../application/ManagedReconstructionService.js";
|
|
2
|
-
import { managedReconstructionReferenceInputSchema } from "../../contracts/managedWorkflowToolContracts.js";
|
|
3
2
|
import { logToolExecution } from "../toolLogging.js";
|
|
4
|
-
import { toCallToolResult } from "../toolResult.js";
|
|
5
3
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
6
|
-
import {
|
|
4
|
+
import { toCallToolResult } from "../toolResult.js";
|
|
7
5
|
import { managedWorkflowContract } from "./contract.js";
|
|
8
6
|
import { resolveManagedEvidence } from "./evidence.js";
|
|
9
7
|
const reconstructionContract = managedWorkflowContract("import_managed_reconstruction");
|
|
10
8
|
/** Register the managed reconstruction import workflow tool. */
|
|
11
9
|
export const registerImportManagedReconstruction = (server, options) => {
|
|
12
10
|
server.registerTool(reconstructionContract.name, toolRegistrationOptions(reconstructionContract), async (input) => {
|
|
13
|
-
const parsedInput = safeParseToolInput(managedReconstructionReferenceInputSchema, input, reconstructionContract.name);
|
|
14
|
-
if (!parsedInput.ok)
|
|
15
|
-
return toCallToolResult(parsedInput, reconstructionContract);
|
|
16
11
|
const resolved = resolveManagedEvidence(options.session, [
|
|
17
|
-
|
|
12
|
+
input.static_members_evidence_id,
|
|
18
13
|
]);
|
|
19
14
|
if (!resolved.ok)
|
|
20
15
|
return toCallToolResult(resolved, reconstructionContract);
|
|
21
16
|
const staticMembers = resolved.value[0];
|
|
22
17
|
if (staticMembers === undefined)
|
|
23
18
|
throw new TypeError("Managed reconstruction Evidence resolution failed");
|
|
24
|
-
const { static_members_evidence_id: _staticMembersEvidenceId, ...referencedInput } =
|
|
19
|
+
const { static_members_evidence_id: _staticMembersEvidenceId, ...referencedInput } = input;
|
|
25
20
|
const parsed = { ...referencedInput, static_members: staticMembers };
|
|
26
21
|
const result = await logToolExecution(options.logger, reconstructionContract.name, () => Promise.resolve(importManagedReconstructionEvidenceValidated(parsed)));
|
|
27
22
|
if (!result.ok)
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { planManagedRuntimeCorrelationEvidenceValidated } from "../../application/ManagedRuntimeCorrelationService.js";
|
|
2
|
-
import { managedRuntimeCorrelationReferenceInputSchema } from "../../contracts/managedWorkflowToolContracts.js";
|
|
3
2
|
import { logToolExecution } from "../toolLogging.js";
|
|
4
|
-
import { toCallToolResult } from "../toolResult.js";
|
|
5
3
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
6
|
-
import {
|
|
4
|
+
import { toCallToolResult } from "../toolResult.js";
|
|
7
5
|
import { managedWorkflowContract } from "./contract.js";
|
|
8
6
|
import { resolveManagedEvidence } from "./evidence.js";
|
|
9
7
|
const runtimeContract = managedWorkflowContract("plan_managed_runtime_correlation");
|
|
10
8
|
/** Register the managed runtime correlation planning workflow tool. */
|
|
11
9
|
export const registerPlanManagedRuntimeCorrelation = (server, options) => {
|
|
12
10
|
server.registerTool(runtimeContract.name, toolRegistrationOptions(runtimeContract), async (input) => {
|
|
13
|
-
const parsedInput = safeParseToolInput(managedRuntimeCorrelationReferenceInputSchema, input, runtimeContract.name);
|
|
14
|
-
if (!parsedInput.ok)
|
|
15
|
-
return toCallToolResult(parsedInput, runtimeContract);
|
|
16
11
|
const resolved = resolveManagedEvidence(options.session, [
|
|
17
|
-
|
|
12
|
+
input.static_members_evidence_id,
|
|
18
13
|
]);
|
|
19
14
|
if (!resolved.ok)
|
|
20
15
|
return toCallToolResult(resolved, runtimeContract);
|
|
21
16
|
const staticMembers = resolved.value[0];
|
|
22
17
|
if (staticMembers === undefined)
|
|
23
18
|
throw new TypeError("Managed runtime Evidence resolution failed");
|
|
24
|
-
const { static_members_evidence_id: _staticMembersEvidenceId, ...referencedInput } =
|
|
19
|
+
const { static_members_evidence_id: _staticMembersEvidenceId, ...referencedInput } = input;
|
|
25
20
|
const parsed = { ...referencedInput, static_members: staticMembers };
|
|
26
21
|
const result = await logToolExecution(options.logger, runtimeContract.name, () => Promise.resolve(planManagedRuntimeCorrelationEvidenceValidated(options.runtime, parsed)));
|
|
27
22
|
if (!result.ok)
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
import { projectManagedApplicationGraphEvidence } from "../../application/ManagedApplicationGraphService.js";
|
|
2
|
-
import { managedApplicationGraphReferenceInputSchema } from "../../contracts/managedWorkflowToolContracts.js";
|
|
3
2
|
import { logToolExecution } from "../toolLogging.js";
|
|
4
|
-
import { toCallToolResult } from "../toolResult.js";
|
|
5
3
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
6
|
-
import {
|
|
4
|
+
import { toCallToolResult } from "../toolResult.js";
|
|
7
5
|
import { managedWorkflowContract } from "./contract.js";
|
|
8
6
|
import { recordManagedSources, resolveManagedArtifactEvidence, resolveManagedBoundaryEvidence, resolveManagedEvidence, sourceEvidence, } from "./evidence.js";
|
|
9
7
|
const graphContract = managedWorkflowContract("project_managed_application_graph");
|
|
10
8
|
/** Register the managed application graph projection workflow tool. */
|
|
11
9
|
export const registerProjectManagedApplicationGraph = (server, options) => {
|
|
12
10
|
server.registerTool(graphContract.name, toolRegistrationOptions(graphContract), async (input) => {
|
|
13
|
-
const
|
|
14
|
-
if (!parsedInput.ok)
|
|
15
|
-
return toCallToolResult(parsedInput, graphContract);
|
|
16
|
-
const managedArtifact = parsedInput.value.managed_artifact_evidence_id === undefined
|
|
11
|
+
const managedArtifact = input.managed_artifact_evidence_id === undefined
|
|
17
12
|
? undefined
|
|
18
|
-
: resolveManagedArtifactEvidence(options.session,
|
|
13
|
+
: resolveManagedArtifactEvidence(options.session, input.managed_artifact_evidence_id);
|
|
19
14
|
if (managedArtifact !== undefined && !managedArtifact.ok)
|
|
20
15
|
return toCallToolResult(managedArtifact, graphContract);
|
|
21
|
-
const managedMembers =
|
|
16
|
+
const managedMembers = input.managed_members_evidence_id === undefined
|
|
22
17
|
? undefined
|
|
23
18
|
: resolveManagedEvidence(options.session, [
|
|
24
|
-
|
|
19
|
+
input.managed_members_evidence_id,
|
|
25
20
|
]);
|
|
26
21
|
if (managedMembers !== undefined && !managedMembers.ok)
|
|
27
22
|
return toCallToolResult(managedMembers, graphContract);
|
|
28
|
-
const managedBoundaries =
|
|
23
|
+
const managedBoundaries = input.managed_native_boundaries_evidence_id === undefined
|
|
29
24
|
? undefined
|
|
30
|
-
: resolveManagedBoundaryEvidence(options.session,
|
|
25
|
+
: resolveManagedBoundaryEvidence(options.session, input.managed_native_boundaries_evidence_id);
|
|
31
26
|
if (managedBoundaries !== undefined && !managedBoundaries.ok)
|
|
32
27
|
return toCallToolResult(managedBoundaries, graphContract);
|
|
33
28
|
const parsed = {
|
|
34
|
-
limits:
|
|
29
|
+
limits: input.limits,
|
|
35
30
|
managed_artifact: managedArtifact?.value[0],
|
|
36
31
|
managed_members: managedMembers?.value[0],
|
|
37
32
|
managed_native_boundaries: managedBoundaries?.value[0],
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { verifyManagedNativeBoundariesEvidence } from "../../application/ManagedNativeVerificationService.js";
|
|
2
|
-
import { managedNativeVerificationReferenceInputSchema } from "../../contracts/managedWorkflowToolContracts.js";
|
|
3
2
|
import { managedNativeVerificationResultSchema } from "../../domain/managedNativeVerification.js";
|
|
4
3
|
import { logToolExecution } from "../toolLogging.js";
|
|
5
|
-
import { toCallToolResult } from "../toolResult.js";
|
|
6
4
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
7
|
-
import {
|
|
5
|
+
import { toCallToolResult } from "../toolResult.js";
|
|
8
6
|
import { managedWorkflowContract } from "./contract.js";
|
|
9
7
|
import { recordManagedSources, resolveManagedBoundaryEvidence, resolveNativeEvidence, } from "./evidence.js";
|
|
10
8
|
const nativeVerificationContract = managedWorkflowContract("verify_managed_native_boundaries");
|
|
11
9
|
/** Register the managed/native boundary verification workflow tool. */
|
|
12
10
|
export const registerVerifyManagedNativeBoundaries = (server, options) => {
|
|
13
11
|
server.registerTool(nativeVerificationContract.name, toolRegistrationOptions(nativeVerificationContract), async (input) => {
|
|
14
|
-
const
|
|
15
|
-
if (!parsedInput.ok)
|
|
16
|
-
return toCallToolResult(parsedInput, nativeVerificationContract);
|
|
17
|
-
const managedBoundaries = resolveManagedBoundaryEvidence(options.session, parsedInput.value.managed_boundaries_evidence_id);
|
|
12
|
+
const managedBoundaries = resolveManagedBoundaryEvidence(options.session, input.managed_boundaries_evidence_id);
|
|
18
13
|
if (!managedBoundaries.ok)
|
|
19
14
|
return toCallToolResult(managedBoundaries, nativeVerificationContract);
|
|
20
|
-
const nativeObservations = resolveNativeEvidence(options.session,
|
|
15
|
+
const nativeObservations = resolveNativeEvidence(options.session, input.native_observation_evidence_ids);
|
|
21
16
|
if (!nativeObservations.ok)
|
|
22
17
|
return toCallToolResult(nativeObservations, nativeVerificationContract);
|
|
23
18
|
const managedBoundary = managedBoundaries.value[0];
|
|
24
19
|
if (managedBoundary === undefined)
|
|
25
20
|
throw new TypeError("Managed boundary Evidence resolution failed");
|
|
26
|
-
const { managed_boundaries_evidence_id: _managedBoundariesEvidenceId, native_observation_evidence_ids: _nativeObservationEvidenceIds, ...referencedInput } =
|
|
21
|
+
const { managed_boundaries_evidence_id: _managedBoundariesEvidenceId, native_observation_evidence_ids: _nativeObservationEvidenceIds, ...referencedInput } = input;
|
|
27
22
|
const parsed = {
|
|
28
23
|
...referencedInput,
|
|
29
24
|
managed_boundaries: managedBoundary,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { OFFICIAL_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
2
|
-
import { jsonObjectSchema, jsonValueSchema, } from "../domain/jsonValue.js";
|
|
3
|
-
import { toCallToolResult } from "./toolResult.js";
|
|
4
|
-
import { logToolExecution } from "./toolLogging.js";
|
|
5
|
-
import { createEvidence } from "../domain/evidence.js";
|
|
6
3
|
import { AnalysisCapabilityUnavailableError, UnknownRegistryError, } from "../domain/errors.js";
|
|
4
|
+
import { createEvidence } from "../domain/evidence.js";
|
|
5
|
+
import { jsonObjectSchema, jsonValueSchema, } from "../domain/jsonValue.js";
|
|
7
6
|
import { mcpProgressReporter } from "./mcpProgress.js";
|
|
7
|
+
import { logToolExecution } from "./toolLogging.js";
|
|
8
8
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
9
|
-
import {
|
|
9
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
10
10
|
/** Register direct bridge proxies, preserving MCP cancellation and typed errors. */
|
|
11
11
|
export const registerOfficialTools = (server, analysis, options) => {
|
|
12
12
|
for (const contract of OFFICIAL_TOOL_CONTRACTS) {
|
|
@@ -20,10 +20,7 @@ export const registerOfficialTools = (server, analysis, options) => {
|
|
|
20
20
|
};
|
|
21
21
|
const registerOfficialTool = (server, analysis, contract, registration) => {
|
|
22
22
|
server.registerTool(contract.name, toolRegistrationOptions(contract), async (input, context) => {
|
|
23
|
-
const
|
|
24
|
-
if (!parsedInput.ok)
|
|
25
|
-
return toCallToolResult(parsedInput, contract);
|
|
26
|
-
const arguments_ = projectOfficialArguments(contract, parsedInput.value);
|
|
23
|
+
const arguments_ = projectOfficialArguments(contract, input);
|
|
27
24
|
const progress = mcpProgressReporter(context);
|
|
28
25
|
const result = await runOfficialOperation(analysis, contract, arguments_, {
|
|
29
26
|
logger: registration.logger,
|
|
@@ -106,6 +103,8 @@ const recordOfficialUnknown = (input, error, contract, recordUnknown) => {
|
|
|
106
103
|
};
|
|
107
104
|
const projectOfficialArguments = (contract, input) => {
|
|
108
105
|
const parsed = jsonObjectSchema.parse(input);
|
|
106
|
+
if (!(contract.inputSchema instanceof z.ZodObject))
|
|
107
|
+
throw new TypeError("Official tool input contract must be an object schema");
|
|
109
108
|
const projected = {};
|
|
110
109
|
for (const key of Object.keys(contract.inputSchema.shape)) {
|
|
111
110
|
if (key === "unknown_registry_approved")
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createEvidence } from "../domain/evidence.js";
|
|
1
|
+
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
3
2
|
import { EvidenceIntegrityError } from "../domain/errors.js";
|
|
3
|
+
import { createEvidence } from "../domain/evidence.js";
|
|
4
4
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
5
5
|
import { compareProcessCaptures, parseProcessCapture, } from "../domain/processCapture.js";
|
|
6
|
-
import { recordDerivedEvidence } from "./recordDerivedEvidence.js";
|
|
7
6
|
import { err } from "../domain/result.js";
|
|
8
|
-
import {
|
|
9
|
-
import { toCallToolResult } from "./toolResult.js";
|
|
10
|
-
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
7
|
+
import { recordDerivedEvidence } from "./recordDerivedEvidence.js";
|
|
11
8
|
import { runDerivedOperation } from "./runDerivedOperation.js";
|
|
12
|
-
import { safeParseToolInput } from "./toolInputValidation.js";
|
|
13
9
|
import { resolveSessionEvidenceIds } from "./sessionEvidence.js";
|
|
10
|
+
import { PROCESS_PROVIDER } from "./sessionToolPolicies.js";
|
|
11
|
+
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
12
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
14
13
|
const PROCESS_CAPTURE_EVIDENCE = {
|
|
15
14
|
operation: "capture_process_scenario",
|
|
16
15
|
predicate: "rea.process-capture/v4",
|
|
@@ -19,14 +18,10 @@ const sourceLocations = (left, right) => [...(left ?? []), ...(right ?? [])];
|
|
|
19
18
|
/** Register deterministic process-capture comparison and contradiction tracking. */
|
|
20
19
|
export const registerProcessComparisonTool = (server, session, contract, now = Date.now) => {
|
|
21
20
|
server.registerTool(contract.name, toolRegistrationOptions(contract), async (input, context) => {
|
|
22
|
-
const
|
|
23
|
-
if (!parsedInput.ok)
|
|
24
|
-
return toCallToolResult(parsedInput, contract);
|
|
25
|
-
const parsed = parsedInput.value;
|
|
26
|
-
const leftRecord = resolveSessionEvidenceIds(session, [parsed.left_evidence_id], PROCESS_CAPTURE_EVIDENCE);
|
|
21
|
+
const leftRecord = resolveSessionEvidenceIds(session, [input.left_evidence_id], PROCESS_CAPTURE_EVIDENCE);
|
|
27
22
|
if (!leftRecord.ok)
|
|
28
23
|
return toCallToolResult(leftRecord, contract);
|
|
29
|
-
const rightRecord = resolveSessionEvidenceIds(session, [
|
|
24
|
+
const rightRecord = resolveSessionEvidenceIds(session, [input.right_evidence_id], PROCESS_CAPTURE_EVIDENCE);
|
|
30
25
|
if (!rightRecord.ok)
|
|
31
26
|
return toCallToolResult(rightRecord, contract);
|
|
32
27
|
let comparison;
|
|
@@ -36,12 +31,12 @@ export const registerProcessComparisonTool = (server, session, contract, now = D
|
|
|
36
31
|
leftCapture = parseProcessCapture(leftRecord.value[0]?.normalized_result);
|
|
37
32
|
rightCapture = parseProcessCapture(rightRecord.value[0]?.normalized_result);
|
|
38
33
|
const computed = await runDerivedOperation(context, contract.name, () => compareProcessCaptures(leftCapture, rightCapture, {
|
|
39
|
-
...(
|
|
34
|
+
...(input.max_capture_age_ms === undefined
|
|
40
35
|
? {}
|
|
41
|
-
: { maxCaptureAgeMs:
|
|
42
|
-
...(
|
|
36
|
+
: { maxCaptureAgeMs: input.max_capture_age_ms }),
|
|
37
|
+
...(input.trace_spec === undefined
|
|
43
38
|
? {}
|
|
44
|
-
: { traceSpecification:
|
|
39
|
+
: { traceSpecification: input.trace_spec }),
|
|
45
40
|
now,
|
|
46
41
|
}));
|
|
47
42
|
if (!computed.ok)
|
|
@@ -54,27 +49,27 @@ export const registerProcessComparisonTool = (server, session, contract, now = D
|
|
|
54
49
|
: "Invalid Process Capture v4")), contract);
|
|
55
50
|
}
|
|
56
51
|
const evidence = createEvidence(undefined, PROCESS_PROVIDER, {
|
|
57
|
-
predicateType:
|
|
52
|
+
predicateType: input.trace_spec === undefined
|
|
58
53
|
? "rea.process-comparison/v3"
|
|
59
54
|
: "rea.process-comparison/v4",
|
|
60
55
|
operation: contract.name,
|
|
61
56
|
parameters: {
|
|
62
|
-
left_evidence_id:
|
|
63
|
-
right_evidence_id:
|
|
57
|
+
left_evidence_id: input.left_evidence_id,
|
|
58
|
+
right_evidence_id: input.right_evidence_id,
|
|
64
59
|
left_normalization: leftCapture.normalization,
|
|
65
60
|
right_normalization: rightCapture.normalization,
|
|
66
|
-
...(
|
|
61
|
+
...(input.trace_spec === undefined
|
|
67
62
|
? {}
|
|
68
|
-
: { trace_spec: jsonValueSchema.parse(
|
|
63
|
+
: { trace_spec: jsonValueSchema.parse(input.trace_spec) }),
|
|
69
64
|
},
|
|
70
65
|
result: jsonValueSchema.parse(comparison),
|
|
71
66
|
confidence: "derived",
|
|
72
67
|
authority: "analyst-inference",
|
|
73
68
|
limitations: comparison.limitations,
|
|
74
69
|
locations: sourceLocations(leftRecord.value[0]?.locations, rightRecord.value[0]?.locations),
|
|
75
|
-
evidenceLinks: [
|
|
70
|
+
evidenceLinks: [input.left_evidence_id, input.right_evidence_id],
|
|
76
71
|
});
|
|
77
|
-
return toCallToolResult(recordDerivedEvidence(session, evidence, comparisonUnknownInput(
|
|
72
|
+
return toCallToolResult(recordDerivedEvidence(session, evidence, comparisonUnknownInput(input, comparison)), contract);
|
|
78
73
|
});
|
|
79
74
|
};
|
|
80
75
|
const comparisonUnknownInput = (parsed, comparison) => {
|