Replace Zod with TypeBox for schema validation
- Switch from Zod to TypeBox for tool parameter schemas - TypeBox schemas can be serialized/deserialized as JSON - Use AJV for runtime validation instead of Zod's parse - Add StringEnum helper for Google API compatibility (avoids anyOf/const patterns) - Export Type and Static from main package for convenience - Update all tests and documentation to reflect TypeBox usage
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import { type Static, Type } from "@sinclair/typebox";
|
||||
import type { AgentTool } from "../../agent";
|
||||
|
||||
export interface CalculateResult {
|
||||
@@ -15,10 +15,12 @@ export function calculate(expression: string): CalculateResult {
|
||||
}
|
||||
}
|
||||
|
||||
const calculateSchema = z.object({
|
||||
expression: z.string().describe("The mathematical expression to evaluate"),
|
||||
const calculateSchema = Type.Object({
|
||||
expression: Type.String({ description: "The mathematical expression to evaluate" }),
|
||||
});
|
||||
|
||||
type CalculateParams = Static<typeof calculateSchema>;
|
||||
|
||||
export const calculateTool: AgentTool<typeof calculateSchema, undefined> = {
|
||||
label: "Calculator",
|
||||
name: "calculate",
|
||||
|
||||
Reference in New Issue
Block a user