Files
reverse-engineering-anything/src/server/registerApplicationTools/traceFeature.ts
T
gensokyo-dev a989c0e458 refactor(evidence): unify retained inputs across domains (#8299)
Declare logical Evidence sources once and resolve exact retained inputs through
shared application workflows across 20 composition tools. Preserve domain-owned
authentication, source closure, caller choices, coverage and resource admission.

Validation includes public CLI/MCP regressions, local Codex terra/high trials
and fresh-import real-artifact workflows. Measurements, failed attempts and
coverage limits are recorded in docs/verification/evidence-input-composition-2026-10-31.md.

Fixes #8293.
Fixes #8281.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
2026-10-31 14:45:21 +00:00

56 lines
2.0 KiB
TypeScript

import type { EvidenceMcpServer } from "../EvidenceMcpServer.js";
import { runAdmittedToolOperation } from "../admittedToolOperation.js";
import { recordEvidenceSources } from "../../application/investigation/recordEvidenceSources.js";
import { traceApplicationFeatureEvidence } from "../../application/javascript/JavaScriptApplicationWorkflowService.js";
import { toolContract } from "../../contracts/toolContracts.js";
import { logToolExecution } from "../toolLogging.js";
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
import { recordResult } from "./helpers.js";
import type { ApplicationToolRegistration } from "./types.js";
const traceContract = toolContract("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, context) =>
runAdmittedToolOperation(
server,
options.withAdmittedAnalysis,
traceContract.name,
context.mcpReq.signal,
async () => {
const result = await logToolExecution(
options.logger,
traceContract.name,
() =>
Promise.resolve(
traceApplicationFeatureEvidence(input, options.evidenceById, {
signal: context.mcpReq.signal,
}),
),
);
if (!result.ok)
return server.delivery.toCallToolResult(result, traceContract);
const recorded = recordEvidenceSources(
options.recordEvidence,
result.value.sources,
);
if (!recorded.ok)
return server.delivery.toCallToolResult(recorded, traceContract);
return recordResult(
{ ...options, delivery: server.delivery },
traceContract,
result.value.evidence,
);
},
),
);
};