refactor(mcp): simplify evidence and workflows
This commit is contained in:
@@ -96,7 +96,7 @@ export const registerElectronTools = (
|
||||
[
|
||||
{
|
||||
operation: "list_electron_targets",
|
||||
predicate: "rea.electron-target-list/v1",
|
||||
predicate: "rea.electron-target-list",
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
@@ -17,7 +17,10 @@ import { mcpProgressReporter } from "./mcpProgress.js";
|
||||
import { logToolExecution } from "./toolLogging.js";
|
||||
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
||||
import { toCallToolResult } from "./toolResult.js";
|
||||
import { createArtifactExtractionDestination } from "../application/ArtifactExtractionDestination.js";
|
||||
import {
|
||||
artifactExtractionPermissionRequest,
|
||||
createArtifactExtractionDestination,
|
||||
} from "../application/ArtifactExtractionDestination.js";
|
||||
|
||||
interface EvidenceToolRegistration {
|
||||
readonly logger: Logger;
|
||||
@@ -127,15 +130,7 @@ const permissionRequest = (
|
||||
operation === "extract_artifact" &&
|
||||
typeof parameters.output_root === "string"
|
||||
)
|
||||
return {
|
||||
capability: "artifact_extract" as const,
|
||||
roots: [parameters.output_root],
|
||||
executables: [],
|
||||
environment_names: [],
|
||||
network: "none" as const,
|
||||
mount: false,
|
||||
operation_identity: `extract_artifact:${parameters.output_root}`,
|
||||
};
|
||||
return artifactExtractionPermissionRequest();
|
||||
if (
|
||||
operation === "inspect_artifact" &&
|
||||
parameters.native_mount_approved === true
|
||||
|
||||
@@ -63,7 +63,7 @@ const registerChangedBehavior = (
|
||||
if (!computed.ok) return toCallToolResult(computed, contract);
|
||||
const result = computed.value;
|
||||
const evidence = createEvidence(undefined, CHANGED_BEHAVIOR_PROVIDER, {
|
||||
predicateType: "rea.changed-behavior/v1",
|
||||
predicateType: "rea.changed-behavior",
|
||||
operation: contract.name,
|
||||
parameters: {
|
||||
comparison_evidence_ids: input.comparisons.map(
|
||||
@@ -121,7 +121,7 @@ const registerCallPath = (
|
||||
if (!computed.ok) return toCallToolResult(computed, contract);
|
||||
const result = computed.value;
|
||||
const evidence = createEvidence(undefined, CALL_PATH_PROVIDER, {
|
||||
predicateType: "rea.call-path/v1",
|
||||
predicateType: "rea.call-path",
|
||||
operation: contract.name,
|
||||
parameters: {
|
||||
start: input.start.address,
|
||||
@@ -181,7 +181,7 @@ const registerStaticRuntime = (
|
||||
if (!computed.ok) return toCallToolResult(computed, contract);
|
||||
const result = computed.value;
|
||||
const evidence = createEvidence(undefined, STATIC_RUNTIME_PROVIDER, {
|
||||
predicateType: "rea.static-runtime-correlation/v1",
|
||||
predicateType: "rea.static-runtime-correlation",
|
||||
operation: contract.name,
|
||||
parameters: {
|
||||
mapping_count: input.mappings.length,
|
||||
@@ -237,7 +237,7 @@ const registerReconstruction = (
|
||||
if (!closure.ok) return toCallToolResult(closure, contract);
|
||||
const links = closure.value;
|
||||
const evidence = createEvidence(undefined, RECONSTRUCTION_PROVIDER, {
|
||||
predicateType: "rea.reconstruction-verification/v1",
|
||||
predicateType: "rea.reconstruction-verification",
|
||||
operation: contract.name,
|
||||
parameters: {
|
||||
specification_sha256: result.specification_sha256,
|
||||
|
||||
@@ -82,12 +82,7 @@ const argumentSchema = (
|
||||
argument: PromptArgumentContract,
|
||||
completion: PromptCompletionSource,
|
||||
): z.ZodType => {
|
||||
const value = z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(4_096)
|
||||
.describe(argument.description);
|
||||
const value = z.string().trim().min(1).describe(argument.description);
|
||||
const kind = argument.completion;
|
||||
const completed =
|
||||
kind === undefined
|
||||
@@ -98,18 +93,24 @@ const argumentSchema = (
|
||||
return argument.required ? completed : completed.optional();
|
||||
};
|
||||
|
||||
const promptResult = (contract: PromptContract, arguments_: unknown) => ({
|
||||
description: contract.description,
|
||||
messages: [
|
||||
{
|
||||
role: "user" as const,
|
||||
content: {
|
||||
type: "text" as const,
|
||||
text: renderGuidedPrompt(
|
||||
contract,
|
||||
promptValuesSchema.parse(arguments_),
|
||||
),
|
||||
const promptResult = (contract: PromptContract, arguments_: unknown) => {
|
||||
const values = promptValuesSchema.parse(arguments_);
|
||||
for (const [name, argument] of Object.entries(contract.arguments))
|
||||
if (
|
||||
argument.required &&
|
||||
(values[name] === undefined || values[name]?.trim().length === 0)
|
||||
)
|
||||
throw new TypeError(`Invalid arguments: ${name} must not be empty`);
|
||||
return {
|
||||
description: contract.description,
|
||||
messages: [
|
||||
{
|
||||
role: "user" as const,
|
||||
content: {
|
||||
type: "text" as const,
|
||||
text: renderGuidedPrompt(contract, values),
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user