diff --git a/packages/api/src/router/assistant-tools/shared.ts b/packages/api/src/router/assistant-tools/shared.ts index dd2fbde..c819e7a 100644 --- a/packages/api/src/router/assistant-tools/shared.ts +++ b/packages/api/src/router/assistant-tools/shared.ts @@ -1,5 +1,6 @@ import type { prisma } from "@capakraken/db"; import type { PermissionKey, SystemRole } from "@capakraken/shared"; +import type { z } from "zod"; import type { TRPCContext } from "../../trpc.js"; export type ToolContext = { @@ -29,6 +30,8 @@ export interface ToolDef { parameters: Record; }; access?: ToolAccessRequirements; + /** EGAI 4.3.1.2 — optional Zod schema to validate tool results before returning to the AI */ + resultSchema?: z.ZodType; } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -40,8 +43,6 @@ export function withToolAccess( ): ToolDef[] { return tools.map((tool) => ({ ...tool, - ...(accessByName[tool.function.name] - ? { access: accessByName[tool.function.name] } - : {}), + ...(accessByName[tool.function.name] ? { access: accessByName[tool.function.name] } : {}), })); }