/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 18d2ae0c1a0c */ import * as z from "zod/v4"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { smartUnion } from "../../types/smartUnion.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ReferenceChunk, ReferenceChunk$inboundSchema, ReferenceChunk$Outbound, ReferenceChunk$outboundSchema, } from "./referencechunk.js"; import { TextChunk, TextChunk$inboundSchema, TextChunk$Outbound, TextChunk$outboundSchema, } from "./textchunk.js"; import { ToolReferenceChunk, ToolReferenceChunk$inboundSchema, ToolReferenceChunk$Outbound, ToolReferenceChunk$outboundSchema, } from "./toolreferencechunk.js"; export type Thinking = ToolReferenceChunk | TextChunk | ReferenceChunk; export type ThinkChunk = { type?: "thinking" | undefined; thinking: Array; /** * Signature to replay some reasoning blocks across turns. */ signature?: string | null | undefined; /** * Whether the thinking chunk is closed or not. Currently only used for prefixing. */ closed?: boolean | undefined; }; /** @internal */ export const Thinking$inboundSchema: z.ZodType = smartUnion([ ToolReferenceChunk$inboundSchema, TextChunk$inboundSchema, ReferenceChunk$inboundSchema, ]); /** @internal */ export type Thinking$Outbound = | ToolReferenceChunk$Outbound | TextChunk$Outbound | ReferenceChunk$Outbound; /** @internal */ export const Thinking$outboundSchema: z.ZodType = smartUnion([ ToolReferenceChunk$outboundSchema, TextChunk$outboundSchema, ReferenceChunk$outboundSchema, ]); export function thinkingToJSON(thinking: Thinking): string { return JSON.stringify(Thinking$outboundSchema.parse(thinking)); } export function thinkingFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Thinking$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Thinking' from JSON`, ); } /** @internal */ export const ThinkChunk$inboundSchema: z.ZodType = z .object({ type: z.literal("thinking").default("thinking"), thinking: z.array( smartUnion([ ToolReferenceChunk$inboundSchema, TextChunk$inboundSchema, ReferenceChunk$inboundSchema, ]), ), signature: z.nullable(z.string()).optional(), closed: z.boolean().optional(), }); /** @internal */ export type ThinkChunk$Outbound = { type: "thinking"; thinking: Array< ToolReferenceChunk$Outbound | TextChunk$Outbound | ReferenceChunk$Outbound >; signature?: string | null | undefined; closed?: boolean | undefined; }; /** @internal */ export const ThinkChunk$outboundSchema: z.ZodType< ThinkChunk$Outbound, ThinkChunk > = z.object({ type: z.literal("thinking").default("thinking" as const), thinking: z.array( smartUnion([ ToolReferenceChunk$outboundSchema, TextChunk$outboundSchema, ReferenceChunk$outboundSchema, ]), ), signature: z.nullable(z.string()).optional(), closed: z.boolean().optional(), }); export function thinkChunkToJSON(thinkChunk: ThinkChunk): string { return JSON.stringify(ThinkChunk$outboundSchema.parse(thinkChunk)); } export function thinkChunkFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ThinkChunk$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ThinkChunk' from JSON`, ); }