/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 03d25d0a5e59 */ import * as z from "zod/v4"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FunctionT, FunctionT$inboundSchema, FunctionT$Outbound, FunctionT$outboundSchema, } from "./function.js"; import { ToolTypes, ToolTypes$inboundSchema, ToolTypes$outboundSchema, } from "./tooltypes.js"; export type Tool = { type?: ToolTypes | undefined; function: FunctionT; }; /** @internal */ export const Tool$inboundSchema: z.ZodType = z.object({ type: ToolTypes$inboundSchema.default("function"), function: FunctionT$inboundSchema, }); /** @internal */ export type Tool$Outbound = { type: string; function: FunctionT$Outbound; }; /** @internal */ export const Tool$outboundSchema: z.ZodType = z.object({ type: ToolTypes$outboundSchema.default("function"), function: FunctionT$outboundSchema, }); export function toolToJSON(tool: Tool): string { return JSON.stringify(Tool$outboundSchema.parse(tool)); } export function toolFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Tool$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Tool' from JSON`, ); }