Merge pull request #454 from morluto/fix/mcp-routing-diagnostics

fix(mcp): clarify target routing and caller diagnostics
This commit is contained in:
morluto
2026-07-29 15:32:51 +08:00
committed by GitHub
25 changed files with 223 additions and 43 deletions
+4
View File
@@ -20,6 +20,10 @@ also requires the agent to keep observations, inferences, and unknowns
distinct. Requested prompt arguments and completion choices are rendered as
untrusted selection data, not instructions or authorization.
For target paths in `compare_application_versions`, the rendered workflow
opens each target before calling `inventory_artifact`; artifact inventory and
inspection operate on the active target and do not accept a path themselves.
Use standard MCP discovery and retrieval:
```json
+3 -3
View File
@@ -668,10 +668,10 @@
"mcp_resource_templates": 11
},
"digests": {
"tools_sha256": "5a88bf598a1e0fe705761db6af92f1ceabaf026cb6efa425e87b9633f1d7a3de",
"prompts_sha256": "f6da3ad38a1000c11364d1710f122ac4990551f04efd8c53ffb2e819b5cf5707",
"tools_sha256": "092dd59990f61b1011ac0cd4f5b8d6a3e4a2cf7ade49c86892963c87b71dc65b",
"prompts_sha256": "2dd61fd4e29657e7faf739ef67be7b1f637ddf446e7d73acc0d2fd1d9f06b43e",
"resources_sha256": "339a984ea8cd8be5f234adf24395bf0295258d990492005cf6fe1f293d12cd46",
"combined_sha256": "861cd8618e793342daa8b149bc2944360d84b077fd19cf22f6e0a57b6b249c73",
"combined_sha256": "461b4dbea03ef60d637f4b74debca4dbea0e1dd423d7d9c9a631e62204528c05",
"providers_sha256": "918ccd6b8ae442cd5844dcfde55086f458176241c8d166c1e9dd0f242ccd2bb0"
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ harm_rank,location,trigger,current_copy,user_risk,proposed_replacement,implement
11,src/domain/errors.ts:ArtifactOperationError,Artifact inventory or extraction fails,"Artifact {operation} failed: {reason} at {logicalPath} (declared_sha256=...)",Exposes paths hashes and internal reason,"Reason-specific plain message with safe recovery step.",implemented,focused assertions passed; full `npm run check` passed
12,src/domain/errors.ts:EvidenceFileError,Evidence file operation fails,"Evidence bundle {operation} failed: {reason}",Internal reason token gives weak recovery,"Reason-specific plain message with safe recovery step.",implemented,focused assertions passed; full `npm run check` passed
13,src/domain/errors.ts:EvidenceIntegrityError,Evidence validation fails,Raw constructor message,May expose validation internals and lacks recovery,"Evidence is invalid or has changed. Recreate or re-import it, then try again.",implemented,focused assertions passed; full `npm run check` passed
14,src/domain/errors.ts:UnknownRegistryError,Evidence-state mutation fails,"Residual unknown registry mutation failed: {reason}",Exposes internal subsystem and state token,"Evidence state changed before the update completed. Refresh the current state and try again.",implemented,focused assertions passed; full `npm run check` passed
14,src/domain/errors.ts:UnknownRegistryError,Evidence-state mutation fails,"Residual unknown registry mutation failed: {reason}",Exposes internal subsystem and state token,"Missing IDs identify the session and retry; concurrent revision conflicts refresh current state.",implemented,focused assertions passed; full `npm run check` passed
15,src/domain/errors.ts:ProcessCaptureError,Process capture fails,Raw constructor message,May expose process and cleanup internals,"Process capture could not complete. Check command access and limits, then try again.",implemented,focused assertions passed; full `npm run check` passed
16,src/domain/errors.ts:AnalysisTimeoutError,Analysis deadline expires,"Analysis operation timed out after {timeoutMs}ms: {operation}",Exposes internal deadline and operation; weak recovery,"Analysis took too long. Try a smaller request, then run `rea doctor` if it continues.",implemented,focused assertions passed; full `npm run check` passed
17,src/domain/errors.ts:HopperTimeoutError,Provider deadline expires,"Hopper did not respond within {timeoutMs}ms",Exposes provider and internal deadline,"Analysis took too long. Try a smaller request, then run `rea doctor` if it continues.",implemented,focused assertions passed; full `npm run check` passed
1 harm_rank location trigger current_copy user_risk proposed_replacement implementation_status verification_result
12 11 src/domain/errors.ts:ArtifactOperationError Artifact inventory or extraction fails Artifact {operation} failed: {reason} at {logicalPath} (declared_sha256=...) Exposes paths hashes and internal reason Reason-specific plain message with safe recovery step. implemented focused assertions passed; full `npm run check` passed
13 12 src/domain/errors.ts:EvidenceFileError Evidence file operation fails Evidence bundle {operation} failed: {reason} Internal reason token gives weak recovery Reason-specific plain message with safe recovery step. implemented focused assertions passed; full `npm run check` passed
14 13 src/domain/errors.ts:EvidenceIntegrityError Evidence validation fails Raw constructor message May expose validation internals and lacks recovery Evidence is invalid or has changed. Recreate or re-import it, then try again. implemented focused assertions passed; full `npm run check` passed
15 14 src/domain/errors.ts:UnknownRegistryError Evidence-state mutation fails Residual unknown registry mutation failed: {reason} Exposes internal subsystem and state token Evidence state changed before the update completed. Refresh the current state and try again. Missing IDs identify the session and retry; concurrent revision conflicts refresh current state. implemented focused assertions passed; full `npm run check` passed
16 15 src/domain/errors.ts:ProcessCaptureError Process capture fails Raw constructor message May expose process and cleanup internals Process capture could not complete. Check command access and limits, then try again. implemented focused assertions passed; full `npm run check` passed
17 16 src/domain/errors.ts:AnalysisTimeoutError Analysis deadline expires Analysis operation timed out after {timeoutMs}ms: {operation} Exposes internal deadline and operation; weak recovery Analysis took too long. Try a smaller request, then run `rea doctor` if it continues. implemented focused assertions passed; full `npm run check` passed
18 17 src/domain/errors.ts:HopperTimeoutError Provider deadline expires Hopper did not respond within {timeoutMs}ms Exposes provider and internal deadline Analysis took too long. Try a smaller request, then run `rea doctor` if it continues. implemented focused assertions passed; full `npm run check` passed
@@ -1,6 +1,6 @@
{
"schema_version": 1,
"manifest_id": "ecm_24026e05aeb579814a3d44d04eb8914b1d4ce301d916536bc68a745418c5d892",
"manifest_id": "ecm_8105537d48f95b240afd212bf3e3b975fb27f41d0e1ca313a76e61234619f2e8",
"verifier": {
"id": "rea-managed-conformance",
"version": "1"
@@ -14,7 +14,7 @@
"skill_digests": [
{
"skill_id": "reverse-engineer-anything",
"sha256": "9bb090837e251fc7ff1c1e621b77230f54c88650efb6520aff74d33877b023d8"
"sha256": "6365fa4341bc7309fd31cf6d1732f95b6fca82984e7f9fd0ab0b9223dc03c501"
}
],
"claims": [
+10 -2
View File
@@ -29,8 +29,16 @@ export const requireTruthfulMemoryRegions = (segments) => {
export function requireBridgeProgress(updates) {
const messages = updates.map(({ message }) => message);
if (
!messages.includes("Hopper bridge started request") ||
!messages.includes("Hopper bridge completed request")
!messages.some(
(message) =>
message === "Hopper bridge started request" ||
message.includes("started on Hopper's serial bridge"),
) ||
!messages.some(
(message) =>
message === "Hopper bridge completed request" ||
message.includes("Hopper bridge completed request"),
)
)
throw new Error(
`The MCP client did not observe correlated Hopper bridge progress: ${JSON.stringify(updates)}`,
+15 -10
View File
@@ -5,7 +5,6 @@ import { promisify } from "node:util";
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
import {
firstProcedureAddress,
requireAddressArray,
@@ -282,15 +281,6 @@ let summary;
try {
await client.connect(transport);
const listed = await client.listTools();
const expectedNames = TOOL_CONTRACTS.map(({ name }) => name).sort();
const actualNames = listed.tools.map(({ name }) => name).sort();
if (JSON.stringify(actualNames) !== JSON.stringify(expectedNames)) {
throw new Error(
"The real server tool inventory did not match its contracts",
);
}
const progressUpdates = [];
const options = {
timeout,
@@ -303,6 +293,21 @@ try {
);
const initialSession = await fullSessionStatus();
const initialStatus = requireMcpResult(initialSession, "binary_session");
const listed = await client.listTools();
const availableTools = initialStatus.tool_availability;
if (!Array.isArray(availableTools))
throw new Error("The real session omitted tool availability");
const expectedNames = availableTools
.filter(({ available }) => available === true)
.map(({ name }) => name)
.sort();
const actualNames = listed.tools.map(({ name }) => name).sort();
if (JSON.stringify(actualNames) !== JSON.stringify(expectedNames)) {
throw new Error(
"The real server tool inventory diverged from session availability",
);
}
if (initialStatus.open !== false)
throw new Error("The verifier did not start without a target");
requireHopperSelection(initialStatus, {
+9 -2
View File
@@ -4,7 +4,7 @@ description: Reverse engineer native, managed, Electron/JavaScript, packaged, an
metadata:
version: "23"
tool_count: 111
catalog_digest: "861cd8618e793342daa8b149bc2944360d84b077fd19cf22f6e0a57b6b249c73"
catalog_digest: "461b4dbea03ef60d637f4b74debca4dbea0e1dd423d7d9c9a631e62204528c05"
---
# REA
@@ -23,7 +23,8 @@ Choose the first tool from the target the user supplied. Do not call
- ASAR or extracted JavaScript/Electron tree:
`analyze_javascript_application`.
- Archive, application package, ZIP/APK/IPA/MSIX/AppX, or DMG:
`inventory_artifact`.
`open_binary` with the supplied local path, then `inspect_artifact` or
`inventory_artifact` (both operate on the active target and accept no path).
- Managed PE/CLI assembly: `inspect_managed_artifact`.
- User-owned browser page already open: `list_browser_targets`.
- User-owned Electron runtime already open: `list_electron_targets`.
@@ -34,6 +35,12 @@ If the app is missing, ask which app to inspect. Resolve a human-readable app
name to one clear installed artifact when possible; ask only when matches are
ambiguous. Never choose an example app on the user's behalf.
In a target-free session, use `open_binary` to bind any archive/package or
native target whose analysis tool operates on the active target. Do not call a
tool hidden from `tools/list`; inspect `binary_session` with
`detail: "capabilities"` for the exact remediation when a desired capability
is unavailable.
## Work summary-first
Start with the default summary projection. Do not repeat an identical tool call.
@@ -49,7 +49,7 @@ export const scanCanonicalArtifactInventory = async (
(!integrity.approved || !integrity.enabled)
)
throw new ArtifactReaderFailure(
"unavailable",
"policy",
"Integrity continuation requires explicit approval and operator policy",
);
const metadata = await lstat(path);
+1
View File
@@ -50,6 +50,7 @@ export class ArtifactReaderFailure extends Error {
| "integrity"
| "limit"
| "path"
| "policy"
| "unavailable",
message: string,
options?: ErrorOptions,
+8 -3
View File
@@ -1,3 +1,4 @@
import { isAbsolute } from "node:path";
import { z } from "zod";
import type { ToolContract } from "./toolContracts.js";
@@ -59,7 +60,11 @@ export const artifactInventoryInputSchema = z
/** Exact caller boundary for approved artifact extraction. */
export const artifactExtractionInputSchema = z.object({
approved: z.literal(true),
output_root: z.string().min(1).max(4_096),
output_root: z
.string()
.min(1)
.max(4_096)
.refine(isAbsolute, "Extraction output root must be absolute"),
occurrence_ids: z
.array(z.string().regex(/^occ_[a-f0-9]{64}$/u))
.min(1)
@@ -130,12 +135,12 @@ const artifact = <Name extends string>(
export const ARTIFACT_TOOL_CONTRACTS = [
artifact(
"inventory_artifact",
"Inventory the active application or package as a deterministic, content-addressed artifact graph. Returns bounded node and edge pages without extracting or mounting by default.",
"After open_binary binds a local archive, application package, or other artifact—or when one is already active—inventory it as a deterministic, content-addressed artifact graph. This tool accepts no path; in a target-free session open the target first. Returns bounded node and edge pages without extracting or mounting by default.",
artifactInventoryInputSchema,
),
artifact(
"inspect_artifact",
"Inspect the active artifact through one bounded, cancellable inventory substep. Returns the full substep Evidence and its ID, observations, derived relationships, hypotheses, contradictions, unexplored branches, limitations, and format-specific next probes. Any substep failure fails the whole call.",
"After open_binary binds a local archive, application package, or other artifact—or when one is already active—inspect it through one bounded, cancellable inventory substep. This tool accepts no path; in a target-free session open the target first. Returns the full substep Evidence and its ID, observations, derived relationships, hypotheses, contradictions, unexplored branches, limitations, and format-specific next probes. Any substep failure fails the whole call.",
artifactInspectionInputSchema,
),
artifact(
+2 -2
View File
@@ -184,9 +184,9 @@ export const PROMPT_CONTRACTS = [
},
steps: [
{
tools: ["inventory_artifact"],
tools: ["open_binary", "inventory_artifact"],
instruction:
"Inventory each target independently before extraction. Follow nodes, occurrences, and edges to completion and retain every Evidence page for each manifest.",
"For each supplied target path, open that target before inventory because inventory_artifact uses the active target and accepts no path. Follow nodes, occurrences, and edges to completion and retain every Evidence page for each manifest.",
},
{
tools: [
+8 -2
View File
@@ -24,6 +24,8 @@ export const analysisErrorRemediationAction = (
): string => {
if (error instanceof AnalysisInputError)
return "Correct the listed arguments and retry.";
if (error instanceof UnknownRegistryError && error.reason === "not-found")
return "Check that the unknown_id belongs to this session, then retry.";
if (error instanceof ReplayPlanStaleError)
return "Review the rebuilt replay plan and explicitly approve its new digest.";
if (error instanceof PermissionRequiredError)
@@ -99,7 +101,7 @@ const artifactErrorCategory = (
if (reason === "integrity") return "integrity_mismatch";
if (reason === "limit") return "truncated";
if (reason === "cancelled") return "cancelled";
if (reason === "unavailable") return "unavailable";
if (reason === "policy" || reason === "unavailable") return "unavailable";
return "execution_failure";
};
@@ -139,6 +141,8 @@ export const analysisErrorUserMessage = (error: AnalysisError): string => {
return evidenceFileMessage(error.reason);
if (error instanceof InvestigationWorkspaceError)
return investigationWorkspaceMessage(error.reason);
if (error instanceof UnknownRegistryError && error.reason === "not-found")
return "The requested residual unknown does not exist in this session. Check the unknown_id and try again.";
if (error instanceof UnknownRegistryError)
return "Evidence state changed before the update completed. Refresh the current state and try again.";
if (error instanceof ConfigurationError)
@@ -203,8 +207,10 @@ const artifactMessage = (reason: ArtifactOperationError["reason"]): string => {
return "Artifact is too large to process safely. Narrow the requested path or use a smaller artifact.";
if (reason === "path")
return "Artifact path is not allowed. Choose a path inside the artifact and try again.";
if (reason === "policy")
return "Artifact integrity continuation is disabled by policy. Configure REA_ARTIFACT_INTEGRITY_CONTINUE_ENABLED=true and retry only if continuing after mismatches is approved.";
if (reason === "unavailable")
return "Artifact format is not available on this system. Choose another artifact or supported environment.";
return "Artifact processing is unavailable for the current target or policy. Check artifact support and required approvals.";
if (reason === "format" || reason === "integrity")
return "Artifact is invalid or has changed. Get a fresh copy and try again.";
return "Artifact could not be read or written. Check file access and try again.";
+1
View File
@@ -220,6 +220,7 @@ const requestErrorDetails = (
issues: error.issues.map((issue) => ({
path: [...issue.path],
reason: issue.reason,
...(issue.message === undefined ? {} : { message: issue.message }),
...(issue.expected === undefined ? {} : { expected: issue.expected }),
...(issue.minimum === undefined ? {} : { minimum: issue.minimum }),
...(issue.maximum === undefined ? {} : { maximum: issue.maximum }),
+3
View File
@@ -97,6 +97,8 @@ export interface AnalysisInputIssue {
| "out_of_range"
| "invalid_value"
| "invalid_format";
/** Schema-authored correction guidance for cross-field or custom checks. */
readonly message?: string;
readonly expected?: JsonValue;
readonly minimum?: number;
readonly maximum?: number;
@@ -293,6 +295,7 @@ export class ArtifactOperationError extends AnalysisError {
| "integrity"
| "limit"
| "path"
| "policy"
| "unavailable"
| "io",
readonly artifactDetails?: Readonly<{
+7 -1
View File
@@ -46,7 +46,13 @@ const projectIssue = (
expected: issue.values.filter(isSafeExpected),
},
];
return [{ path, reason: "invalid_value" }];
return [
{
path,
reason: "invalid_value",
...(issue.message.length > 0 ? { message: issue.message } : {}),
},
];
};
const valueAtPath = (
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -29,7 +29,7 @@ import {
import { installDynamicToolAvailability } from "./DynamicToolAvailability.js";
const TARGET_FREE_INSTRUCTIONS =
"REA analyzes shipped artifacts. Route: ASAR/JavaScript -> analyze_javascript_application (configured root); archive/package -> inspect_artifact; managed PE/CLI -> inspect_managed_artifact; passive browser/Electron -> list_browser_targets/list_electron_targets; approved browser interaction -> capture_browser_scenario; Node/Electron Inspector -> list_javascript_runtime_targets; native binary/database -> open_binary, then binary_overview. Check binary_session policy. Start with summaries and cite Evidence IDs. Never repeat identical analysis or read full Evidence without need.";
"ASAR/JavaScript -> analyze_javascript_application; archive/package -> open_binary(path), then inspect_artifact/inventory_artifact (active target); managed PE/CLI -> inspect_managed_artifact; passive browser/Electron -> list_browser_targets/list_electron_targets; approved browser interaction -> capture_browser_scenario; Node/Electron Inspector -> list_javascript_runtime_targets; native binary/database -> open_binary, then binary_overview. Start with binary_session; call only tools in tools/list. Hidden routes: binary_session detail=capabilities. Use summaries, cite Evidence IDs. Never repeat identical analysis or read full Evidence.";
const ACTIVE_TARGET_INSTRUCTIONS =
"REA analyzes the active reverse-engineering target. Start native analysis with binary_overview, then narrow with analyze_function, literal search, callers, callees, and xrefs. Prefer summary views, never repeat an identical call, and read full Evidence only when the task requires it.";
+1 -1
View File
@@ -184,7 +184,7 @@ const recommendedActions = (
: []),
...(!open
? [
"Route the supplied target directly: ASAR/JavaScript to analyze_javascript_application, unfamiliar packages to inspect_artifact, managed PE/CLI to inspect_managed_artifact, browser/Electron runtimes to their list-target tools, and native binaries to open_binary.",
"For a supplied target, route by format: ASAR/JavaScript to analyze_javascript_application; archive/package to open_binary(path), then inspect_artifact or inventory_artifact on the active target; managed PE/CLI to inspect_managed_artifact; browser/Electron runtimes to their list-target tools; native binaries to open_binary.",
]
: [
"Continue from the active target with binary_overview or a bounded target-specific query.",
+11 -8
View File
@@ -15,7 +15,7 @@ const ADVERTISED_OUTPUT_SCHEMAS = new WeakMap<
export const toolRegistrationOptions = (contract: ToolContract) => ({
title: contract.title,
description: contract.description,
inputSchema: advertisedInputSchema(contract.inputSchema),
inputSchema: advertisedInputSchema(contract),
outputSchema: advertisedOutputSchema(contract.outputSchema),
annotations: contract.annotations,
});
@@ -25,14 +25,14 @@ export const toolRegistrationOptions = (contract: ToolContract) => ({
* The SDK otherwise converts validation failures to text-only JSON-RPC errors
* before REA can return its stable structured error envelope.
*/
const advertisedInputSchema = (schema: z.ZodObject) => ({
const advertisedInputSchema = (contract: ToolContract) => ({
"~standard": {
version: 1 as const,
vendor: "rea",
validate: (input: unknown) => ({ value: input }),
jsonSchema: {
input: () => advertisedInputJsonSchema(schema),
output: () => advertisedInputJsonSchema(schema),
input: () => advertisedInputJsonSchema(contract),
output: () => advertisedInputJsonSchema(contract),
},
},
});
@@ -56,11 +56,14 @@ const advertisedOutputSchema = (schema: z.ZodObject) => {
};
const advertisedInputJsonSchema = (
schema: z.ZodObject,
contract: ToolContract,
): Readonly<Record<string, unknown>> =>
cachedJsonSchema(ADVERTISED_INPUT_SCHEMAS, schema, () =>
describeProperties(closeObjectSchemas(inputJsonSchema(schema))),
);
cachedJsonSchema(ADVERTISED_INPUT_SCHEMAS, contract.inputSchema, () => ({
...describeProperties(
closeObjectSchemas(inputJsonSchema(contract.inputSchema)),
),
examples: contract.examples.map(({ input }) => input),
}));
const advertisedOutputJsonSchema = (
schema: z.ZodObject,
+22
View File
@@ -102,6 +102,28 @@ describe("tool contract surface", () => {
});
});
it("advertises the validated contract examples on the MCP input schema", () => {
for (const name of [
"record_unknown",
"run_replay_machine",
"build_reconstruction_obligation_ledger",
]) {
const contract = TOOL_CONTRACTS.find(
(candidate) => candidate.name === name,
);
expect(contract).toBeDefined();
if (contract === undefined) continue;
const schema =
toolRegistrationOptions(contract).inputSchema[
"~standard"
].jsonSchema.input();
expect(schema.examples).toEqual(
contract.examples.map(({ input }) => input),
);
}
});
it("advertises complete typed schemas and annotations for every public tool", () => {
const contracts = TOOL_CONTRACTS;
for (const contract of contracts) {
+57 -1
View File
@@ -242,6 +242,61 @@ describe("analysis error projection", () => {
).toEqual([]);
});
it("gives missing residual unknowns a lookup-specific remediation", () => {
expect(
projectAnalysisError(new UnknownRegistryError("not-found")),
).toMatchObject({
code: "execution_failure",
message:
"The requested residual unknown does not exist in this session. Check the unknown_id and try again.",
remediation: {
action:
"Check that the unknown_id belongs to this session, then retry.",
},
details: { reason: "not-found" },
});
});
it("retains custom input guidance in the projected error details", () => {
expect(
projectAnalysisError(
new AnalysisInputError("find_changed_behavior", undefined, [
{
path: [],
reason: "invalid_value",
message:
"Supply either existing comparisons or one investigation_run",
},
]),
),
).toMatchObject({
details: {
issues: [
{
path: [],
reason: "invalid_value",
message:
"Supply either existing comparisons or one investigation_run",
},
],
},
});
});
it("distinguishes disabled integrity continuation from format support", () => {
expect(
projectAnalysisError(
new ArtifactOperationError("inventory_artifact", "policy"),
),
).toMatchObject({
code: "artifact_operation_failed",
category: "unavailable",
message: expect.stringContaining(
"REA_ARTIFACT_INTEGRITY_CONTINUE_ENABLED=true",
),
});
});
it("validates every closed error-reason variant against the generated contract", () => {
const variants: AnalysisError[] = [
...(
@@ -251,6 +306,7 @@ describe("analysis error projection", () => {
"integrity",
"limit",
"path",
"policy",
"unavailable",
"io",
] as const
@@ -313,7 +369,7 @@ describe("analysis error projection", () => {
).map((diagnostic) => new HopperRemoteError(9, "safe", diagnostic)),
];
expect(variants).toHaveLength(38);
expect(variants).toHaveLength(39);
for (const variant of variants) {
const projected = projectAnalysisError(variant);
const parsed = analysisErrorProjectionSchema.safeParse(projected);
+40
View File
@@ -0,0 +1,40 @@
import { describe, expect, it } from "vitest";
import { z } from "zod";
import { artifactExtractionInputSchema } from "../src/contracts/artifactToolContracts.js";
import { projectInputIssues } from "../src/domain/inputIssueProjection.js";
describe("input issue projection", () => {
it("preserves schema-authored custom correction guidance", () => {
const schema = z
.object({ left: z.string().optional(), right: z.string().optional() })
.superRefine((value, context) => {
if (value.left === undefined && value.right === undefined)
context.addIssue({
code: "custom",
path: [],
message: "Supply either left or right",
});
});
const parsed = schema.safeParse({});
if (parsed.success) throw new Error("expected invalid input");
expect(projectInputIssues(parsed.error.issues, {})).toEqual([
{
path: [],
reason: "invalid_value",
message: "Supply either left or right",
},
]);
});
it("rejects relative extraction destinations at the caller boundary", () => {
expect(
artifactExtractionInputSchema.safeParse({
approved: true,
output_root: "relative/output",
occurrence_ids: [`occ_${"0".repeat(64)}`],
}).success,
).toBe(false);
});
});
@@ -129,6 +129,7 @@ const assertDescribedStrictObjects = (
path = "$",
): void => {
for (const [key, value] of objectEntries(schema)) {
if (key === "examples") continue;
if (key === "properties") {
const properties = objectEntries(value);
for (const [property, propertySchema] of properties) {
+3 -1
View File
@@ -284,7 +284,9 @@ describe("server and catalog identity", () => {
open: false,
target: null,
alignment: { state: "mcp_server_restart_required" },
recommended_actions: expect.any(Array),
recommended_actions: expect.arrayContaining([
"For a supplied target, route by format: ASAR/JavaScript to analyze_javascript_application; archive/package to open_binary(path), then inspect_artifact or inventory_artifact on the active target; managed PE/CLI to inspect_managed_artifact; browser/Electron runtimes to their list-target tools; native binaries to open_binary.",
]),
},
});
expect(JSON.stringify(summary.structuredContent)).not.toContain(
+11 -1
View File
@@ -145,7 +145,17 @@ describe("target-free MCP lifecycle", () => {
await server.connect(serverTransport);
await mcp.connect(clientTransport);
const beforeNames = (await mcp.listTools()).tools.map(({ name }) => name);
const beforeTools = (await mcp.listTools()).tools;
const beforeNames = beforeTools.map(({ name }) => name);
expect(mcp.getInstructions()).toContain(
"archive/package -> open_binary(path), then inspect_artifact/inventory_artifact (active target)",
);
expect(
beforeTools.find(({ name }) => name === "inventory_artifact")
?.description,
).toContain(
"This tool accepts no path; in a target-free session open the target first.",
);
expect(beforeNames).toContain("open_binary");
expect(beforeNames).toContain("binary_session");
expect(beforeNames).not.toContain("current_document");