36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
import type { ToolContract } from "../src/contracts/toolContracts.js";
|
|
import { ok } from "../src/domain/result.js";
|
|
import { toCallToolResult } from "../src/server/toolResult.js";
|
|
|
|
const contract: ToolContract = {
|
|
name: "provider_neutral_fixture",
|
|
description: "Fixture contract for provider-neutral output validation.",
|
|
kind: "enhanced",
|
|
inputSchema: z.object({}),
|
|
outputSchema: z.object({ value: z.string() }),
|
|
annotations: {
|
|
readOnlyHint: true,
|
|
destructiveHint: false,
|
|
idempotentHint: true,
|
|
openWorldHint: false,
|
|
},
|
|
examples: [{ title: "Example fixture request", input: {} }],
|
|
};
|
|
|
|
describe("tool result projection", () => {
|
|
it("classifies output contract failures without naming a provider", () => {
|
|
expect(toCallToolResult(ok({ value: 42 }), contract)).toEqual({
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: "AnalysisOutputError: Analysis output does not match the tool contract",
|
|
},
|
|
],
|
|
isError: true,
|
|
});
|
|
});
|
|
});
|