mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 09:34:20 +00:00
Use one named input-schema projection for clients and catalog identity, preserve dialect declarations, and bound compact schema depth. Keep canonical SDK output validation when output advertisements are disabled. Release request-owned state on cancellation and carry upstream limitations through composed workflows. Preserve doctor full-output envelopes and validate navigation facts at their owner. Reviewed fixes: #2088, #2108, #2513, #2684, #2693, #2695, #2836, #2864, #2868, #2877, #2933, #2998, #3002, #3015. Validation: focused schema, SDK output-validation, context, and workflow tests passed; no schema dialect or canonical output validation was relaxed.
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { ConfigurationError } from "../domain/configurationErrors.js";
|
|
import { err, ok, type Result } from "../domain/result.js";
|
|
|
|
/** Select whether tools/list carries the large output contracts. */
|
|
export const mcpOutputSchemaProfileSchema = z.enum(["full", "off"]);
|
|
|
|
export type McpOutputSchemaProfile = z.infer<
|
|
typeof mcpOutputSchemaProfileSchema
|
|
>;
|
|
|
|
const profileConstraint =
|
|
'REA_MCP_OUTPUT_SCHEMA_PROFILE must be "full" (default) or "off". The off profile omits output schemas from tools/list while REA validates every successful result against its canonical tool contract and returns complete structured content.';
|
|
|
|
/** Parse the output schema advertisement selection at server composition. */
|
|
export const parseMcpOutputSchemaProfile = (
|
|
value: string | undefined,
|
|
): Result<McpOutputSchemaProfile | undefined, ConfigurationError> => {
|
|
if (value === undefined) return ok(undefined);
|
|
const parsed = mcpOutputSchemaProfileSchema.safeParse(value);
|
|
return parsed.success
|
|
? ok(parsed.data)
|
|
: err(
|
|
new ConfigurationError(profileConstraint, {
|
|
settings: [
|
|
{
|
|
setting: "REA_MCP_OUTPUT_SCHEMA_PROFILE",
|
|
constraint: profileConstraint,
|
|
},
|
|
],
|
|
}),
|
|
);
|
|
};
|