* fix(hopper): report unavailable procedure body coverage * refactor!: simplify runtime tools and remove replay engines Keep direct inspection, capture, and comparison tools. Bind handlers to named contracts and let agents compose experiments with commands and local fixture servers. BREAKING CHANGE: Remove controlled replay, Node characterization, finite replay-machine, managed runtime planning, and redundant string-tracing tools. Retire process replay, shims, reactive scenarios, custom checkpoints, and active browser replay and origin-scope inputs.
54 lines
2.3 KiB
TypeScript
54 lines
2.3 KiB
TypeScript
import type { McpServer } from "@modelcontextprotocol/server";
|
|
|
|
import type { BinarySessionPort } from "../application/BinarySession.js";
|
|
import { readEvidenceBundle } from "../application/EvidenceBundleFiles.js";
|
|
import { toolContract } from "../contracts/toolContracts.js";
|
|
import { compareBundles } from "../domain/bundleComparison.js";
|
|
import { createEvidence } from "../domain/evidence.js";
|
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
import { ok } from "../domain/result.js";
|
|
import { runDerivedOperation } from "./runDerivedOperation.js";
|
|
import { BUNDLE_COMPARISON_PROVIDER } from "./sessionToolPolicies.js";
|
|
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
|
import { toCallToolResult } from "./toolResult.js";
|
|
|
|
/** Register canonical Evidence bundle comparison. */
|
|
export const registerBundleComparisonTool = (
|
|
server: McpServer,
|
|
session: BinarySessionPort,
|
|
contract: ReturnType<typeof toolContract<"compare_bundles">>,
|
|
): void => {
|
|
server.registerTool(
|
|
contract.name,
|
|
toolRegistrationOptions(contract),
|
|
async (input, context) => {
|
|
const [left, right] = await Promise.all([
|
|
readEvidenceBundle(input.left_bundle_path),
|
|
readEvidenceBundle(input.right_bundle_path),
|
|
]);
|
|
if (!left.ok) return toCallToolResult(left, contract);
|
|
if (!right.ok) return toCallToolResult(right, contract);
|
|
const computed = await runDerivedOperation(context, contract.name, () =>
|
|
compareBundles(left.value, right.value, input.record_pairs),
|
|
);
|
|
if (!computed.ok) return toCallToolResult(computed, contract);
|
|
const comparison = computed.value;
|
|
const evidence = createEvidence(undefined, BUNDLE_COMPARISON_PROVIDER, {
|
|
predicateType: "rea.bundle-comparison",
|
|
operation: contract.name,
|
|
parameters: {
|
|
left_bundle_sha256: comparison.left_bundle_sha256,
|
|
right_bundle_sha256: comparison.right_bundle_sha256,
|
|
record_pairs: input.record_pairs,
|
|
},
|
|
result: jsonValueSchema.parse(comparison),
|
|
confidence: "derived",
|
|
authority: "analyst-inference",
|
|
limitations: comparison.limitations,
|
|
});
|
|
const recorded = session.recordEvidence(evidence);
|
|
return toCallToolResult(recorded.ok ? ok(evidence) : recorded, contract);
|
|
},
|
|
);
|
|
};
|