input-validation.ts 478 B

12345678910111213
  1. import { Value } from '@sinclair/typebox/value';
  2. import type { RuntimeTool } from './types.js';
  3. /** Revalidates a Hook-rewritten input against the authoritative runtime tool schema. */
  4. export function isRuntimeToolInputValid(
  5. tools: readonly RuntimeTool[],
  6. toolName: string,
  7. value: Readonly<Record<string, unknown>>,
  8. ): boolean {
  9. const tool = tools.find((candidate) => candidate.def.name === toolName);
  10. return Boolean(tool && Value.Check(tool.def.schema, value));
  11. }