mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership. Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers. BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import type { EvidenceMcpServer } from "../EvidenceMcpServer.js";
|
|
import { resolveApplicationEvidenceRequest } from "../../application/EvidenceInputResolver.js";
|
|
import { recordSessionEvidenceSources } from "../sessionEvidence.js";
|
|
|
|
import { traceApplicationFeatureEvidenceValidated } from "../../application/javascript/JavaScriptApplicationWorkflowService.js";
|
|
import { applicationToolContract } from "../../contracts/applicationToolContracts.js";
|
|
import { logToolExecution } from "../toolLogging.js";
|
|
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
|
|
import { recordResult } from "./helpers.js";
|
|
import type { ApplicationToolRegistration } from "./types.js";
|
|
|
|
const traceContract = applicationToolContract("trace_application_feature");
|
|
|
|
/** Register the provider-neutral JavaScript feature trace tool. */
|
|
export const registerTraceFeatureTool = (
|
|
server: EvidenceMcpServer,
|
|
options: ApplicationToolRegistration,
|
|
): void => {
|
|
server.registerTool(
|
|
traceContract.name,
|
|
toolRegistrationOptions(traceContract),
|
|
async (input) => {
|
|
const resolved = resolveApplicationEvidenceRequest(
|
|
input,
|
|
options.evidenceById,
|
|
);
|
|
if (!resolved.ok)
|
|
return server.delivery.toCallToolResult(resolved, traceContract);
|
|
const parsed = resolved.value;
|
|
const result = await logToolExecution(
|
|
options.logger,
|
|
traceContract.name,
|
|
() => Promise.resolve(traceApplicationFeatureEvidenceValidated(parsed)),
|
|
);
|
|
if (!result.ok)
|
|
return server.delivery.toCallToolResult(result, traceContract);
|
|
const sources = [parsed.application, ...parsed.native_observations];
|
|
const recorded = recordSessionEvidenceSources(
|
|
options.recordEvidence,
|
|
sources,
|
|
);
|
|
if (!recorded.ok)
|
|
return server.delivery.toCallToolResult(recorded, traceContract);
|
|
return recordResult(
|
|
{ ...options, delivery: server.delivery },
|
|
traceContract,
|
|
result.value,
|
|
);
|
|
},
|
|
);
|
|
};
|