Fix NodeJS compat

This commit is contained in:
Mario Zechner 2025-09-16 02:19:47 +02:00
parent e2d23a5abb
commit 197259c88a
19 changed files with 110 additions and 99 deletions

View file

@ -1,5 +1,10 @@
import Ajv from "ajv";
import addFormats from "ajv-formats";
import AjvModule from "ajv";
import addFormatsModule from "ajv-formats";
// Handle both default and named exports
const Ajv = (AjvModule as any).default || AjvModule;
const addFormats = (addFormatsModule as any).default || addFormatsModule;
import type { Tool, ToolCall } from "./types.js";
// Create a singleton AJV instance with formats
@ -25,7 +30,7 @@ export function validateToolArguments(tool: Tool, toolCall: ToolCall): any {
// Format validation errors nicely
const errors =
validate.errors
?.map((err) => {
?.map((err: any) => {
const path = err.instancePath ? err.instancePath.substring(1) : err.params.missingProperty || "root";
return ` - ${path}: ${err.message}`;
})