/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 5d322ff91b16 */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { smartUnion } from "../../types/smartUnion.js"; import { ContentChunk, ContentChunk$Outbound, ContentChunk$outboundSchema, } from "./contentchunk.js"; export type ToolMessageContent = string | Array; export type ToolMessage = { role: "tool"; content: string | Array | null; toolCallId?: string | null | undefined; name?: string | null | undefined; }; /** @internal */ export type ToolMessageContent$Outbound = string | Array; /** @internal */ export const ToolMessageContent$outboundSchema: z.ZodType< ToolMessageContent$Outbound, ToolMessageContent > = smartUnion([z.string(), z.array(ContentChunk$outboundSchema)]); export function toolMessageContentToJSON( toolMessageContent: ToolMessageContent, ): string { return JSON.stringify( ToolMessageContent$outboundSchema.parse(toolMessageContent), ); } /** @internal */ export type ToolMessage$Outbound = { role: "tool"; content: string | Array | null; tool_call_id?: string | null | undefined; name?: string | null | undefined; }; /** @internal */ export const ToolMessage$outboundSchema: z.ZodType< ToolMessage$Outbound, ToolMessage > = z.object({ role: z.literal("tool"), content: z.nullable( smartUnion([z.string(), z.array(ContentChunk$outboundSchema)]), ), toolCallId: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { toolCallId: "tool_call_id", }); }); export function toolMessageToJSON(toolMessage: ToolMessage): string { return JSON.stringify(ToolMessage$outboundSchema.parse(toolMessage)); }