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,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) => {
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
2
|
-
import {
|
|
2
|
+
import { runReplayMachine } from "../domain/replayMachineRun.js";
|
|
3
3
|
import { ok } from "../domain/result.js";
|
|
4
|
-
import { safeParseToolInput } from "./toolInputValidation.js";
|
|
5
4
|
import { logToolExecution } from "./toolLogging.js";
|
|
6
|
-
import { toCallToolResult } from "./toolResult.js";
|
|
7
5
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
throw new TypeError("Missing run_replay_machine tool contract");
|
|
6
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
7
|
+
const contract = SESSION_TOOL_CONTRACTS[18];
|
|
11
8
|
/** Register direct execution-free finite replay-machine evaluation. */
|
|
12
9
|
export const registerReplayMachineTool = (server, logger) => {
|
|
13
10
|
server.registerTool(contract.name, toolRegistrationOptions(contract), async (input) => {
|
|
14
|
-
const
|
|
15
|
-
if (!parsed.ok)
|
|
16
|
-
return toCallToolResult(parsed, contract);
|
|
17
|
-
const result = await logToolExecution(logger, contract.name, () => Promise.resolve(ok(runReplayMachine(parsed.value))));
|
|
11
|
+
const result = await logToolExecution(logger, contract.name, () => Promise.resolve(ok(runReplayMachine(input))));
|
|
18
12
|
return toCallToolResult(result, contract);
|
|
19
13
|
});
|
|
20
14
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { readEvidenceBundle, writeEvidenceBundle, } from "../application/EvidenceBundleFiles.js";
|
|
2
|
-
import {
|
|
2
|
+
import { SESSION_TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
|
3
3
|
import { AnalysisProtocolError, PermissionRequiredError, } from "../domain/errors.js";
|
|
4
|
-
import { recordUnknownInputSchema, updateUnknownInputSchema, } from "../domain/residualUnknown.js";
|
|
5
4
|
import { err, ok } from "../domain/result.js";
|
|
6
|
-
import { safeParseToolInput } from "./toolInputValidation.js";
|
|
7
5
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
8
6
|
import { toCallToolResult } from "./toolResult.js";
|
|
9
7
|
/** Register evidence bundle import and export tools. */
|
|
@@ -11,24 +9,56 @@ export const registerEvidenceTools = (registration) => {
|
|
|
11
9
|
registerExportEvidenceTool(registration);
|
|
12
10
|
registerImportEvidenceTool(registration);
|
|
13
11
|
registerSnapshotEvidenceTool(registration);
|
|
12
|
+
registerReleaseEvidenceTool(registration);
|
|
13
|
+
};
|
|
14
|
+
const registerReleaseEvidenceTool = ({ server, session, releaseContract, permissionAuthority, }) => {
|
|
15
|
+
server.registerTool(releaseContract.name, toolRegistrationOptions(releaseContract), async (input) => {
|
|
16
|
+
const denied = await authorizeEvidenceWrite({
|
|
17
|
+
authority: permissionAuthority,
|
|
18
|
+
operationIdentity: `release_evidence:${input.bundle_digest}`,
|
|
19
|
+
});
|
|
20
|
+
if (denied !== undefined)
|
|
21
|
+
return toCallToolResult(denied, releaseContract);
|
|
22
|
+
const released = session.releaseEvidenceBundle(input.bundle_digest);
|
|
23
|
+
if (released)
|
|
24
|
+
void server.server
|
|
25
|
+
.sendResourceUpdated({
|
|
26
|
+
uri: `rea://evidence-bundle/${input.bundle_digest}`,
|
|
27
|
+
})
|
|
28
|
+
.catch(() => undefined);
|
|
29
|
+
return toCallToolResult(ok({
|
|
30
|
+
bundle_digest: input.bundle_digest,
|
|
31
|
+
released,
|
|
32
|
+
}), releaseContract);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const authorizeEvidenceWrite = async ({ authority, operationIdentity, }) => {
|
|
36
|
+
if (authority === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
const authorized = await authority.authorize({
|
|
39
|
+
capability: "evidence_write",
|
|
40
|
+
roots: [],
|
|
41
|
+
executables: [],
|
|
42
|
+
environment_names: [],
|
|
43
|
+
network: "none",
|
|
44
|
+
mount: false,
|
|
45
|
+
operation_identity: operationIdentity,
|
|
46
|
+
}, "write");
|
|
47
|
+
return authorized.ok ? undefined : permissionFailure(authorized);
|
|
14
48
|
};
|
|
15
49
|
const registerExportEvidenceTool = ({ server, session, exportContract, filePolicy, permissionAuthority, }) => {
|
|
16
50
|
server.registerTool(exportContract.name, toolRegistrationOptions(exportContract), async (input) => {
|
|
17
|
-
const parsedInput = safeParseToolInput(exportEvidenceBundleInputSchema, input, exportContract.name);
|
|
18
|
-
if (!parsedInput.ok)
|
|
19
|
-
return toCallToolResult(parsedInput, exportContract);
|
|
20
|
-
const parsed = parsedInput.value;
|
|
21
51
|
const bundle = session.exportEvidenceBundle();
|
|
22
52
|
const denied = await authorizeEvidencePath({
|
|
23
53
|
authority: permissionAuthority,
|
|
24
54
|
capability: "evidence_write",
|
|
25
|
-
path:
|
|
55
|
+
path: input.path,
|
|
26
56
|
access: "write",
|
|
27
|
-
operationIdentity: `export_evidence:${
|
|
57
|
+
operationIdentity: `export_evidence:${input.path}`,
|
|
28
58
|
});
|
|
29
59
|
if (denied !== undefined)
|
|
30
60
|
return toCallToolResult(denied, exportContract);
|
|
31
|
-
const written = await writeEvidenceBundle(bundle,
|
|
61
|
+
const written = await writeEvidenceBundle(bundle, input.path, input.overwrite, filePolicy);
|
|
32
62
|
return written.ok
|
|
33
63
|
? toCallToolResult(ok({
|
|
34
64
|
path: written.value.path,
|
|
@@ -40,10 +70,7 @@ const registerExportEvidenceTool = ({ server, session, exportContract, filePolic
|
|
|
40
70
|
});
|
|
41
71
|
};
|
|
42
72
|
const registerSnapshotEvidenceTool = ({ server, session, snapshotContract, }) => {
|
|
43
|
-
server.registerTool(snapshotContract.name, toolRegistrationOptions(snapshotContract), (
|
|
44
|
-
const parsed = safeParseToolInput(snapshotEvidenceBundleInputSchema, input, snapshotContract.name);
|
|
45
|
-
if (!parsed.ok)
|
|
46
|
-
return toCallToolResult(parsed, snapshotContract);
|
|
73
|
+
server.registerTool(snapshotContract.name, toolRegistrationOptions(snapshotContract), () => {
|
|
47
74
|
const snapshot = session.snapshotEvidenceBundle();
|
|
48
75
|
if (!snapshot.ok)
|
|
49
76
|
return toCallToolResult(snapshot, snapshotContract);
|
|
@@ -53,6 +80,8 @@ const registerSnapshotEvidenceTool = ({ server, session, snapshotContract, }) =>
|
|
|
53
80
|
bytes: snapshot.value.bytes,
|
|
54
81
|
records: snapshot.value.records,
|
|
55
82
|
unknowns: snapshot.value.unknowns,
|
|
83
|
+
scope: snapshot.value.scope,
|
|
84
|
+
survives_session: snapshot.value.survivesSession,
|
|
56
85
|
bundle_uri: snapshot.value.uri,
|
|
57
86
|
};
|
|
58
87
|
return toCallToolResult(ok(value), snapshotContract, {
|
|
@@ -68,10 +97,7 @@ const registerSnapshotEvidenceTool = ({ server, session, snapshotContract, }) =>
|
|
|
68
97
|
};
|
|
69
98
|
const registerImportEvidenceTool = ({ server, session, importContract, filePolicy, permissionAuthority, }) => {
|
|
70
99
|
server.registerTool(importContract.name, toolRegistrationOptions(importContract), async (input) => {
|
|
71
|
-
const
|
|
72
|
-
if (!parsedInput.ok)
|
|
73
|
-
return toCallToolResult(parsedInput, importContract);
|
|
74
|
-
const path = parsedInput.value.path;
|
|
100
|
+
const path = input.path;
|
|
75
101
|
const denied = await authorizeEvidencePath({
|
|
76
102
|
authority: permissionAuthority,
|
|
77
103
|
capability: "evidence_read",
|
|
@@ -84,15 +110,20 @@ const registerImportEvidenceTool = ({ server, session, importContract, filePolic
|
|
|
84
110
|
const loaded = await readEvidenceBundle(path, filePolicy);
|
|
85
111
|
if (!loaded.ok)
|
|
86
112
|
return toCallToolResult(loaded, importContract);
|
|
113
|
+
const retainedUnknownRevisions = new Set(session
|
|
114
|
+
.exportEvidenceBundle()
|
|
115
|
+
.unknowns.map((unknown) => unknownRevisionKey(unknown)));
|
|
87
116
|
const imported = session.importEvidenceBundle(loaded.value);
|
|
88
117
|
return imported.ok
|
|
89
118
|
? toCallToolResult(ok({
|
|
90
119
|
imported: imported.value,
|
|
120
|
+
unknowns_added: loaded.value.unknowns.filter((unknown) => !retainedUnknownRevisions.has(unknownRevisionKey(unknown))).length,
|
|
91
121
|
total: session.exportEvidenceBundle().records.length,
|
|
92
122
|
}), importContract)
|
|
93
123
|
: toCallToolResult(imported, importContract);
|
|
94
124
|
});
|
|
95
125
|
};
|
|
126
|
+
const unknownRevisionKey = (unknown) => `${unknown.unknown_id}:${String(unknown.revision)}`;
|
|
96
127
|
const authorizeEvidencePath = async (input) => {
|
|
97
128
|
if (input.authority === undefined)
|
|
98
129
|
return undefined;
|
|
@@ -108,16 +139,10 @@ const authorizeEvidencePath = async (input) => {
|
|
|
108
139
|
return authorized.ok ? undefined : permissionFailure(authorized);
|
|
109
140
|
};
|
|
110
141
|
/** Register residual-unknown query and mutation tools. */
|
|
111
|
-
|
|
142
|
+
const registerListUnknownsTool = ({ server, session, contracts, }) => {
|
|
112
143
|
const listContract = contracts[14];
|
|
113
|
-
const recordContract = contracts[15];
|
|
114
|
-
const updateContract = contracts[16];
|
|
115
|
-
const verifyContract = contracts[17];
|
|
116
144
|
server.registerTool(listContract.name, toolRegistrationOptions(listContract), (input) => {
|
|
117
|
-
const
|
|
118
|
-
if (!parsed.ok)
|
|
119
|
-
return toCallToolResult(parsed, listContract);
|
|
120
|
-
const filters = parsed.value;
|
|
145
|
+
const filters = input;
|
|
121
146
|
const all = session.listUnknowns({
|
|
122
147
|
...(filters.status === undefined ? {} : { status: filters.status }),
|
|
123
148
|
...(filters.severity === undefined
|
|
@@ -149,11 +174,11 @@ export const registerUnknownTools = ({ server, session, contracts, }) => {
|
|
|
149
174
|
})),
|
|
150
175
|
});
|
|
151
176
|
});
|
|
177
|
+
};
|
|
178
|
+
const registerRecordUnknownTool = ({ server, session, contracts, }) => {
|
|
179
|
+
const recordContract = contracts[15];
|
|
152
180
|
server.registerTool(recordContract.name, toolRegistrationOptions(recordContract), (input) => {
|
|
153
|
-
const
|
|
154
|
-
if (!parsed.ok)
|
|
155
|
-
return toCallToolResult(parsed, recordContract);
|
|
156
|
-
const result = session.recordUnknown(parsed.value);
|
|
181
|
+
const result = session.recordUnknown(input);
|
|
157
182
|
return result.ok
|
|
158
183
|
? toCallToolResult(result, recordContract, {
|
|
159
184
|
resourceLinks: [
|
|
@@ -166,11 +191,11 @@ export const registerUnknownTools = ({ server, session, contracts, }) => {
|
|
|
166
191
|
})
|
|
167
192
|
: toCallToolResult(result, recordContract);
|
|
168
193
|
});
|
|
194
|
+
};
|
|
195
|
+
const registerUpdateUnknownTool = ({ server, session, contracts, }) => {
|
|
196
|
+
const updateContract = contracts[16];
|
|
169
197
|
server.registerTool(updateContract.name, toolRegistrationOptions(updateContract), (input) => {
|
|
170
|
-
const
|
|
171
|
-
if (!parsed.ok)
|
|
172
|
-
return toCallToolResult(parsed, updateContract);
|
|
173
|
-
const result = session.updateUnknown(parsed.value);
|
|
198
|
+
const result = session.updateUnknown(input);
|
|
174
199
|
if (result.ok)
|
|
175
200
|
void server.server
|
|
176
201
|
.sendResourceUpdated({
|
|
@@ -189,12 +214,16 @@ export const registerUnknownTools = ({ server, session, contracts, }) => {
|
|
|
189
214
|
})
|
|
190
215
|
: toCallToolResult(result, updateContract);
|
|
191
216
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
217
|
+
};
|
|
218
|
+
const registerVerifyUnknownTool = ({ server, session, contracts, }) => {
|
|
219
|
+
const verifyContract = contracts[17];
|
|
220
|
+
server.registerTool(verifyContract.name, toolRegistrationOptions(verifyContract), (input) => toCallToolResult(session.verifyUnknownResolution(input.unknown_id), verifyContract));
|
|
221
|
+
};
|
|
222
|
+
export const registerUnknownTools = (registration) => {
|
|
223
|
+
registerListUnknownsTool(registration);
|
|
224
|
+
registerRecordUnknownTool(registration);
|
|
225
|
+
registerUpdateUnknownTool(registration);
|
|
226
|
+
registerVerifyUnknownTool(registration);
|
|
198
227
|
};
|
|
199
228
|
const permissionFailure = (failure) => {
|
|
200
229
|
if (failure.ok)
|
|
@@ -1,53 +1,38 @@
|
|
|
1
|
+
import { buildCapabilityInventory } from "../application/CapabilityInventory.js";
|
|
1
2
|
import { binarySessionInputSchema, SESSION_TOOL_CONTRACTS, } from "../contracts/toolContracts.js";
|
|
2
|
-
import { toCallToolResult } from "./toolResult.js";
|
|
3
3
|
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
|
4
4
|
import { createServerIdentity } from "../serverIdentity.js";
|
|
5
|
-
import {
|
|
5
|
+
import { mcpClientMetadata } from "./mcpClientMetadata.js";
|
|
6
6
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
7
|
-
import {
|
|
7
|
+
import { toCallToolResult } from "./toolResult.js";
|
|
8
8
|
/** Register the read-only provider and target status operation. */
|
|
9
9
|
export const registerSessionStatusTool = (options) => {
|
|
10
10
|
const { server, session, contract, startedAt, availabilityPolicy } = options;
|
|
11
|
-
server.registerTool(contract.name, toolRegistrationOptions(contract), (input) => {
|
|
12
|
-
const
|
|
13
|
-
if (!parsedInput.ok)
|
|
14
|
-
return toCallToolResult(parsedInput, contract);
|
|
15
|
-
const parsed = parsedInput.value;
|
|
16
|
-
const client = server.server.getClientVersion();
|
|
17
|
-
const clientCapabilities = server.server.getClientCapabilities();
|
|
18
|
-
const clientFeatures = {
|
|
19
|
-
elicitation_form: clientCapabilities?.elicitation?.form !== undefined,
|
|
20
|
-
elicitation_url: clientCapabilities?.elicitation?.url !== undefined,
|
|
21
|
-
roots: clientCapabilities?.roots !== undefined,
|
|
22
|
-
sampling: clientCapabilities?.sampling !== undefined,
|
|
23
|
-
};
|
|
11
|
+
server.registerTool(contract.name, toolRegistrationOptions(contract), (input, context) => {
|
|
12
|
+
const { client, clientFeatures, protocolVersion } = mcpClientMetadata(context);
|
|
24
13
|
const status = session.status();
|
|
25
14
|
const statusObject = jsonObjectSchema.parse(status);
|
|
26
15
|
const toolAvailability = buildCapabilityInventory(status, availabilityPolicy(), clientFeatures);
|
|
27
16
|
const serverIdentity = createServerIdentity({
|
|
28
17
|
startedAt,
|
|
29
18
|
expected: {
|
|
30
|
-
...(
|
|
19
|
+
...(input.expected_package_version === undefined
|
|
31
20
|
? {}
|
|
32
|
-
: { package_version:
|
|
33
|
-
...(
|
|
21
|
+
: { package_version: input.expected_package_version }),
|
|
22
|
+
...(input.expected_catalog_digest === undefined
|
|
34
23
|
? {}
|
|
35
|
-
: { catalog_digest:
|
|
36
|
-
...(
|
|
24
|
+
: { catalog_digest: input.expected_catalog_digest }),
|
|
25
|
+
...(input.expected_server_path === undefined
|
|
37
26
|
? {}
|
|
38
|
-
: { server_path:
|
|
27
|
+
: { server_path: input.expected_server_path }),
|
|
39
28
|
},
|
|
40
29
|
...(client === undefined ? {} : { client }),
|
|
41
|
-
...(
|
|
42
|
-
? {}
|
|
43
|
-
: {
|
|
44
|
-
protocolVersion: server.server.getNegotiatedProtocolVersion(),
|
|
45
|
-
}),
|
|
30
|
+
...(protocolVersion === undefined ? {} : { protocolVersion }),
|
|
46
31
|
});
|
|
47
32
|
return toCallToolResult({
|
|
48
33
|
ok: true,
|
|
49
34
|
value: projectSessionStatus({
|
|
50
|
-
input:
|
|
35
|
+
input: input,
|
|
51
36
|
status: statusObject,
|
|
52
37
|
toolAvailability,
|
|
53
38
|
serverIdentity,
|