/* * 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 { CodeInterpreterToolCall, CodeInterpreterToolCall$inboundSchema, CodeInterpreterToolCall$Outbound, CodeInterpreterToolCall$outboundSchema, } from "./codeinterpretertoolcall.js"; import { ComputerToolCall, ComputerToolCall$inboundSchema, ComputerToolCall$Outbound, ComputerToolCall$outboundSchema, } from "./computertoolcall.js"; import { ComputerToolCallOutput, ComputerToolCallOutput$inboundSchema, ComputerToolCallOutput$Outbound, ComputerToolCallOutput$outboundSchema, } from "./computertoolcalloutput.js"; import { CustomToolCall, CustomToolCall$inboundSchema, CustomToolCall$Outbound, CustomToolCall$outboundSchema, } from "./customtoolcall.js"; import { CustomToolCallOutput, CustomToolCallOutput$inboundSchema, CustomToolCallOutput$Outbound, CustomToolCallOutput$outboundSchema, } from "./customtoolcalloutput.js"; import { FileSearchToolCall, FileSearchToolCall$inboundSchema, FileSearchToolCall$Outbound, FileSearchToolCall$outboundSchema, } from "./filesearchtoolcall.js"; import { FunctionToolCall, FunctionToolCall$inboundSchema, FunctionToolCall$Outbound, FunctionToolCall$outboundSchema, } from "./functiontoolcall.js"; import { FunctionToolCallOutput, FunctionToolCallOutput$inboundSchema, FunctionToolCallOutput$Outbound, FunctionToolCallOutput$outboundSchema, } from "./functiontoolcalloutput.js"; import { ImageGenerationCall, ImageGenerationCall$inboundSchema, ImageGenerationCall$Outbound, ImageGenerationCall$outboundSchema, } from "./imagegenerationcall.js"; import { InputMessage, InputMessage$inboundSchema, InputMessage$Outbound, InputMessage$outboundSchema, } from "./inputmessage.js"; import { ItemReference, ItemReference$inboundSchema, ItemReference$Outbound, ItemReference$outboundSchema, } from "./itemreference.js"; import { LocalShellCall, LocalShellCall$inboundSchema, LocalShellCall$Outbound, LocalShellCall$outboundSchema, } from "./localshellcall.js"; import { LocalShellCallOutput, LocalShellCallOutput$inboundSchema, LocalShellCallOutput$Outbound, LocalShellCallOutput$outboundSchema, } from "./localshellcalloutput.js"; import { MCPApprovalRequest, MCPApprovalRequest$inboundSchema, MCPApprovalRequest$Outbound, MCPApprovalRequest$outboundSchema, } from "./mcpapprovalrequest.js"; import { MCPApprovalResponse, MCPApprovalResponse$inboundSchema, MCPApprovalResponse$Outbound, MCPApprovalResponse$outboundSchema, } from "./mcpapprovalresponse.js"; import { MCPListTools, MCPListTools$inboundSchema, MCPListTools$Outbound, MCPListTools$outboundSchema, } from "./mcplisttools.js"; import { MCPToolCall, MCPToolCall$inboundSchema, MCPToolCall$Outbound, MCPToolCall$outboundSchema, } from "./mcptoolcall.js"; import { OutputAudioItem, OutputAudioItem$inboundSchema, OutputAudioItem$Outbound, OutputAudioItem$outboundSchema, } from "./outputaudioitem.js"; import { OutputMessage, OutputMessage$inboundSchema, OutputMessage$Outbound, OutputMessage$outboundSchema, } from "./outputmessage.js"; import { Reasoning, Reasoning$inboundSchema, Reasoning$Outbound, Reasoning$outboundSchema, } from "./reasoning.js"; import { ResponseCompactionItem, ResponseCompactionItem$inboundSchema, ResponseCompactionItem$Outbound, ResponseCompactionItem$outboundSchema, } from "./responsecompactionitem.js"; import { ShellCall, ShellCall$inboundSchema, ShellCall$Outbound, ShellCall$outboundSchema, } from "./shellcall.js"; import { ShellCallOutput, ShellCallOutput$inboundSchema, ShellCallOutput$Outbound, ShellCallOutput$outboundSchema, } from "./shellcalloutput.js"; import { WebSearchToolCall, WebSearchToolCall$inboundSchema, WebSearchToolCall$Outbound, WebSearchToolCall$outboundSchema, } from "./websearchtoolcall.js"; export type Item = | ComputerToolCall | CodeInterpreterToolCall | OutputMessage | OutputAudioItem | LocalShellCall | ShellCall | MCPApprovalRequest | MCPToolCall | FileSearchToolCall | WebSearchToolCall | FunctionToolCall | ImageGenerationCall | ShellCallOutput | MCPListTools | CustomToolCall | ComputerToolCallOutput | FunctionToolCallOutput | Reasoning | LocalShellCallOutput | MCPApprovalResponse | CustomToolCallOutput | ResponseCompactionItem | InputMessage | ItemReference; /** @internal */ export const Item$inboundSchema: z.ZodType = z .union([ ComputerToolCall$inboundSchema, CodeInterpreterToolCall$inboundSchema, OutputMessage$inboundSchema, OutputAudioItem$inboundSchema, LocalShellCall$inboundSchema, ShellCall$inboundSchema, MCPApprovalRequest$inboundSchema, MCPToolCall$inboundSchema, FileSearchToolCall$inboundSchema, WebSearchToolCall$inboundSchema, FunctionToolCall$inboundSchema, ImageGenerationCall$inboundSchema, ShellCallOutput$inboundSchema, MCPListTools$inboundSchema, CustomToolCall$inboundSchema, ComputerToolCallOutput$inboundSchema, FunctionToolCallOutput$inboundSchema, Reasoning$inboundSchema, LocalShellCallOutput$inboundSchema, MCPApprovalResponse$inboundSchema, CustomToolCallOutput$inboundSchema, ResponseCompactionItem$inboundSchema, InputMessage$inboundSchema, ItemReference$inboundSchema, ]); /** @internal */ export type Item$Outbound = | ComputerToolCall$Outbound | CodeInterpreterToolCall$Outbound | OutputMessage$Outbound | OutputAudioItem$Outbound | LocalShellCall$Outbound | ShellCall$Outbound | MCPApprovalRequest$Outbound | MCPToolCall$Outbound | FileSearchToolCall$Outbound | WebSearchToolCall$Outbound | FunctionToolCall$Outbound | ImageGenerationCall$Outbound | ShellCallOutput$Outbound | MCPListTools$Outbound | CustomToolCall$Outbound | ComputerToolCallOutput$Outbound | FunctionToolCallOutput$Outbound | Reasoning$Outbound | LocalShellCallOutput$Outbound | MCPApprovalResponse$Outbound | CustomToolCallOutput$Outbound | ResponseCompactionItem$Outbound | InputMessage$Outbound | ItemReference$Outbound; /** @internal */ export const Item$outboundSchema: z.ZodType = z.union([ ComputerToolCall$outboundSchema, CodeInterpreterToolCall$outboundSchema, OutputMessage$outboundSchema, OutputAudioItem$outboundSchema, LocalShellCall$outboundSchema, ShellCall$outboundSchema, MCPApprovalRequest$outboundSchema, MCPToolCall$outboundSchema, FileSearchToolCall$outboundSchema, WebSearchToolCall$outboundSchema, FunctionToolCall$outboundSchema, ImageGenerationCall$outboundSchema, ShellCallOutput$outboundSchema, MCPListTools$outboundSchema, CustomToolCall$outboundSchema, ComputerToolCallOutput$outboundSchema, FunctionToolCallOutput$outboundSchema, Reasoning$outboundSchema, LocalShellCallOutput$outboundSchema, MCPApprovalResponse$outboundSchema, CustomToolCallOutput$outboundSchema, ResponseCompactionItem$outboundSchema, InputMessage$outboundSchema, ItemReference$outboundSchema, ]); export function itemToJSON(item: Item): string { return JSON.stringify(Item$outboundSchema.parse(item)); } export function itemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Item$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Item' from JSON`, ); }