/* * 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 * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ConversationsItemsRetrieveRequest = { conversationId: string; itemId: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; /** * The role of the message sender (user, assistant, system, or developer). */ export const Role = { User: "user", Assistant: "assistant", System: "system", Developer: "developer", } as const; /** * The role of the message sender (user, assistant, system, or developer). */ export type Role = ClosedEnum; /** * The message content. Can be a simple text string or an array of multimodal content items (text, images, files, audio). */ export type Content = string | Array; /** * Input message item: A message with role and content. Use this for user, assistant, system, or developer turns in structured inputs. */ export type InputMessageItem = { /** * The item type identifier. Always 'message' for message items. */ type?: "message" | undefined; /** * The role of the message sender (user, assistant, system, or developer). */ role: Role; /** * The message content. Can be a simple text string or an array of multimodal content items (text, images, files, audio). */ content: string | Array; /** * The processing status of an individual item. 'in_progress' means currently processing, 'completed' means finished successfully, 'incomplete' means processing stopped before completion. */ status?: components.Status | undefined; /** * The unique ID of the message. */ id: string; /** * The ID of the response that created this item, if any. */ responseId?: string | null | undefined; /** * Metadata from the response that created this item, if any. */ metadata?: { [k: string]: string } | null | undefined; }; /** * OK */ export type ConversationsItemsRetrieveResponseBody = | components.ComputerToolCallWithId | components.CodeInterpreterToolCallWithId | components.OutputMessageWithId | components.OutputAudioItemWithId | components.FunctionToolCallWithId | components.LocalShellCallWithId | components.ShellCallWithId | components.MCPApprovalRequestWithId | components.MCPToolCallWithId | components.CustomToolCallWithId | components.FileSearchToolCallWithId | components.ComputerToolCallOutputWithId | components.WebSearchToolCallWithId | components.FunctionToolCallOutputWithId | components.ImageGenerationCallWithId | components.ShellCallOutputWithId | components.MCPListToolsWithId | components.MCPApprovalResponseWithId | components.CustomToolCallOutputWithId | InputMessageItem | components.ReasoningWithId | components.LocalShellCallOutputWithId | components.ResponseCompactionItemWithId | components.ItemReferenceWithId; /** @internal */ export const ConversationsItemsRetrieveRequest$inboundSchema: z.ZodType< ConversationsItemsRetrieveRequest, z.ZodTypeDef, unknown > = z.object({ conversation_id: z.string(), item_id: z.string(), "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "conversation_id": "conversationId", "item_id": "itemId", "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type ConversationsItemsRetrieveRequest$Outbound = { conversation_id: string; item_id: string; "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const ConversationsItemsRetrieveRequest$outboundSchema: z.ZodType< ConversationsItemsRetrieveRequest$Outbound, z.ZodTypeDef, ConversationsItemsRetrieveRequest > = z.object({ conversationId: z.string(), itemId: z.string(), xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { conversationId: "conversation_id", itemId: "item_id", xOnBehalfOf: "X-On-Behalf-Of", }); }); export function conversationsItemsRetrieveRequestToJSON( conversationsItemsRetrieveRequest: ConversationsItemsRetrieveRequest, ): string { return JSON.stringify( ConversationsItemsRetrieveRequest$outboundSchema.parse( conversationsItemsRetrieveRequest, ), ); } export function conversationsItemsRetrieveRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ConversationsItemsRetrieveRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConversationsItemsRetrieveRequest' from JSON`, ); } /** @internal */ export const Role$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Role, ); /** @internal */ export const Role$outboundSchema: z.ZodNativeEnum = Role$inboundSchema; /** @internal */ export const Content$inboundSchema: z.ZodType = z.union([z.string(), z.array(components.InputMessageContent$inboundSchema)]); /** @internal */ export type Content$Outbound = | string | Array; /** @internal */ export const Content$outboundSchema: z.ZodType< Content$Outbound, z.ZodTypeDef, Content > = z.union([ z.string(), z.array(components.InputMessageContent$outboundSchema), ]); export function contentToJSON(content: Content): string { return JSON.stringify(Content$outboundSchema.parse(content)); } export function contentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Content$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Content' from JSON`, ); } /** @internal */ export const InputMessageItem$inboundSchema: z.ZodType< InputMessageItem, z.ZodTypeDef, unknown > = z.object({ type: z.literal("message").optional(), role: Role$inboundSchema, content: z.union([ z.string(), z.array(components.InputMessageContent$inboundSchema), ]), status: components.Status$inboundSchema.optional(), id: z.string(), response_id: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { "response_id": "responseId", }); }); /** @internal */ export type InputMessageItem$Outbound = { type?: "message" | undefined; role: string; content: string | Array; status?: string | undefined; id: string; response_id?: string | null | undefined; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const InputMessageItem$outboundSchema: z.ZodType< InputMessageItem$Outbound, z.ZodTypeDef, InputMessageItem > = z.object({ type: z.literal("message").optional(), role: Role$outboundSchema, content: z.union([ z.string(), z.array(components.InputMessageContent$outboundSchema), ]), status: components.Status$outboundSchema.optional(), id: z.string(), responseId: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { responseId: "response_id", }); }); export function inputMessageItemToJSON( inputMessageItem: InputMessageItem, ): string { return JSON.stringify( InputMessageItem$outboundSchema.parse(inputMessageItem), ); } export function inputMessageItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InputMessageItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InputMessageItem' from JSON`, ); } /** @internal */ export const ConversationsItemsRetrieveResponseBody$inboundSchema: z.ZodType< ConversationsItemsRetrieveResponseBody, z.ZodTypeDef, unknown > = z.union([ components.ComputerToolCallWithId$inboundSchema, components.CodeInterpreterToolCallWithId$inboundSchema, components.OutputMessageWithId$inboundSchema, components.OutputAudioItemWithId$inboundSchema, components.FunctionToolCallWithId$inboundSchema, components.LocalShellCallWithId$inboundSchema, components.ShellCallWithId$inboundSchema, components.MCPApprovalRequestWithId$inboundSchema, components.MCPToolCallWithId$inboundSchema, components.CustomToolCallWithId$inboundSchema, components.FileSearchToolCallWithId$inboundSchema, components.ComputerToolCallOutputWithId$inboundSchema, components.WebSearchToolCallWithId$inboundSchema, components.FunctionToolCallOutputWithId$inboundSchema, components.ImageGenerationCallWithId$inboundSchema, components.ShellCallOutputWithId$inboundSchema, components.MCPListToolsWithId$inboundSchema, components.MCPApprovalResponseWithId$inboundSchema, components.CustomToolCallOutputWithId$inboundSchema, z.lazy(() => InputMessageItem$inboundSchema), components.ReasoningWithId$inboundSchema, components.LocalShellCallOutputWithId$inboundSchema, components.ResponseCompactionItemWithId$inboundSchema, components.ItemReferenceWithId$inboundSchema, ]); /** @internal */ export type ConversationsItemsRetrieveResponseBody$Outbound = | components.ComputerToolCallWithId$Outbound | components.CodeInterpreterToolCallWithId$Outbound | components.OutputMessageWithId$Outbound | components.OutputAudioItemWithId$Outbound | components.FunctionToolCallWithId$Outbound | components.LocalShellCallWithId$Outbound | components.ShellCallWithId$Outbound | components.MCPApprovalRequestWithId$Outbound | components.MCPToolCallWithId$Outbound | components.CustomToolCallWithId$Outbound | components.FileSearchToolCallWithId$Outbound | components.ComputerToolCallOutputWithId$Outbound | components.WebSearchToolCallWithId$Outbound | components.FunctionToolCallOutputWithId$Outbound | components.ImageGenerationCallWithId$Outbound | components.ShellCallOutputWithId$Outbound | components.MCPListToolsWithId$Outbound | components.MCPApprovalResponseWithId$Outbound | components.CustomToolCallOutputWithId$Outbound | InputMessageItem$Outbound | components.ReasoningWithId$Outbound | components.LocalShellCallOutputWithId$Outbound | components.ResponseCompactionItemWithId$Outbound | components.ItemReferenceWithId$Outbound; /** @internal */ export const ConversationsItemsRetrieveResponseBody$outboundSchema: z.ZodType< ConversationsItemsRetrieveResponseBody$Outbound, z.ZodTypeDef, ConversationsItemsRetrieveResponseBody > = z.union([ components.ComputerToolCallWithId$outboundSchema, components.CodeInterpreterToolCallWithId$outboundSchema, components.OutputMessageWithId$outboundSchema, components.OutputAudioItemWithId$outboundSchema, components.FunctionToolCallWithId$outboundSchema, components.LocalShellCallWithId$outboundSchema, components.ShellCallWithId$outboundSchema, components.MCPApprovalRequestWithId$outboundSchema, components.MCPToolCallWithId$outboundSchema, components.CustomToolCallWithId$outboundSchema, components.FileSearchToolCallWithId$outboundSchema, components.ComputerToolCallOutputWithId$outboundSchema, components.WebSearchToolCallWithId$outboundSchema, components.FunctionToolCallOutputWithId$outboundSchema, components.ImageGenerationCallWithId$outboundSchema, components.ShellCallOutputWithId$outboundSchema, components.MCPListToolsWithId$outboundSchema, components.MCPApprovalResponseWithId$outboundSchema, components.CustomToolCallOutputWithId$outboundSchema, z.lazy(() => InputMessageItem$outboundSchema), components.ReasoningWithId$outboundSchema, components.LocalShellCallOutputWithId$outboundSchema, components.ResponseCompactionItemWithId$outboundSchema, components.ItemReferenceWithId$outboundSchema, ]); export function conversationsItemsRetrieveResponseBodyToJSON( conversationsItemsRetrieveResponseBody: ConversationsItemsRetrieveResponseBody, ): string { return JSON.stringify( ConversationsItemsRetrieveResponseBody$outboundSchema.parse( conversationsItemsRetrieveResponseBody, ), ); } export function conversationsItemsRetrieveResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ConversationsItemsRetrieveResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConversationsItemsRetrieveResponseBody' from JSON`, ); }