/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const Mode = { Auto: "auto", Required: "required", } as const; export type Mode = ClosedEnum; export type AllowedToolsTools = { type: string; name?: string | undefined; serverLabel?: string | undefined; }; /** * Allowed tools tool choice: Restricts tool use to a provided list and sets whether tool use is optional (auto) or mandatory (required). */ export type AllowedTools = { type: "allowed_tools"; mode: Mode; tools: Array; }; /** @internal */ export const Mode$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Mode, ); /** @internal */ export const Mode$outboundSchema: z.ZodNativeEnum = Mode$inboundSchema; /** @internal */ export const AllowedToolsTools$inboundSchema: z.ZodType< AllowedToolsTools, z.ZodTypeDef, unknown > = z.object({ type: z.string(), name: z.string().optional(), server_label: z.string().optional(), }).transform((v) => { return remap$(v, { "server_label": "serverLabel", }); }); /** @internal */ export type AllowedToolsTools$Outbound = { type: string; name?: string | undefined; server_label?: string | undefined; }; /** @internal */ export const AllowedToolsTools$outboundSchema: z.ZodType< AllowedToolsTools$Outbound, z.ZodTypeDef, AllowedToolsTools > = z.object({ type: z.string(), name: z.string().optional(), serverLabel: z.string().optional(), }).transform((v) => { return remap$(v, { serverLabel: "server_label", }); }); export function allowedToolsToolsToJSON( allowedToolsTools: AllowedToolsTools, ): string { return JSON.stringify( AllowedToolsTools$outboundSchema.parse(allowedToolsTools), ); } export function allowedToolsToolsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AllowedToolsTools$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AllowedToolsTools' from JSON`, ); } /** @internal */ export const AllowedTools$inboundSchema: z.ZodType< AllowedTools, z.ZodTypeDef, unknown > = z.object({ type: z.literal("allowed_tools"), mode: Mode$inboundSchema, tools: z.array(z.lazy(() => AllowedToolsTools$inboundSchema)), }); /** @internal */ export type AllowedTools$Outbound = { type: "allowed_tools"; mode: string; tools: Array; }; /** @internal */ export const AllowedTools$outboundSchema: z.ZodType< AllowedTools$Outbound, z.ZodTypeDef, AllowedTools > = z.object({ type: z.literal("allowed_tools"), mode: Mode$outboundSchema, tools: z.array(z.lazy(() => AllowedToolsTools$outboundSchema)), }); export function allowedToolsToJSON(allowedTools: AllowedTools): string { return JSON.stringify(AllowedTools$outboundSchema.parse(allowedTools)); } export function allowedToolsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AllowedTools$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AllowedTools' from JSON`, ); }