/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CodeInterpreterContainerAuto, CodeInterpreterContainerAuto$inboundSchema, CodeInterpreterContainerAuto$Outbound, CodeInterpreterContainerAuto$outboundSchema, } from "./codeinterpretercontainerauto.js"; export type Container = CodeInterpreterContainerAuto | string; /** * Code interpreter tool definition: Enables code execution. Provide an explicit container ID or auto container configuration with optional file IDs and memory limit. */ export type CodeInterpreterToolDefinition = { type: "code_interpreter"; container: CodeInterpreterContainerAuto | string; }; /** @internal */ export const Container$inboundSchema: z.ZodType< Container, z.ZodTypeDef, unknown > = z.union([CodeInterpreterContainerAuto$inboundSchema, z.string()]); /** @internal */ export type Container$Outbound = CodeInterpreterContainerAuto$Outbound | string; /** @internal */ export const Container$outboundSchema: z.ZodType< Container$Outbound, z.ZodTypeDef, Container > = z.union([CodeInterpreterContainerAuto$outboundSchema, z.string()]); export function containerToJSON(container: Container): string { return JSON.stringify(Container$outboundSchema.parse(container)); } export function containerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Container$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Container' from JSON`, ); } /** @internal */ export const CodeInterpreterToolDefinition$inboundSchema: z.ZodType< CodeInterpreterToolDefinition, z.ZodTypeDef, unknown > = z.object({ type: z.literal("code_interpreter"), container: z.union([CodeInterpreterContainerAuto$inboundSchema, z.string()]), }); /** @internal */ export type CodeInterpreterToolDefinition$Outbound = { type: "code_interpreter"; container: CodeInterpreterContainerAuto$Outbound | string; }; /** @internal */ export const CodeInterpreterToolDefinition$outboundSchema: z.ZodType< CodeInterpreterToolDefinition$Outbound, z.ZodTypeDef, CodeInterpreterToolDefinition > = z.object({ type: z.literal("code_interpreter"), container: z.union([CodeInterpreterContainerAuto$outboundSchema, z.string()]), }); export function codeInterpreterToolDefinitionToJSON( codeInterpreterToolDefinition: CodeInterpreterToolDefinition, ): string { return JSON.stringify( CodeInterpreterToolDefinition$outboundSchema.parse( codeInterpreterToolDefinition, ), ); } export function codeInterpreterToolDefinitionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CodeInterpreterToolDefinition$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CodeInterpreterToolDefinition' from JSON`, ); }