/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Answer, Answer$inboundSchema, Answer$Outbound, Answer$outboundSchema, } from "./answer.js"; export type AnswerStep = { type?: "answer" | undefined; think: string; currentQuestion: string; errored?: boolean | undefined; /** * A list of question ids that are no longer relevant to the current answer referenced by their IDs. */ otherResolvedQuestionIds?: Array | undefined; answer: Answer; }; /** @internal */ export const AnswerStep$inboundSchema: z.ZodType< AnswerStep, z.ZodTypeDef, unknown > = z.object({ type: z.literal("answer").default("answer"), think: z.string(), current_question: z.string(), errored: z.boolean().default(false), other_resolved_question_ids: z.array(z.string()).optional(), answer: Answer$inboundSchema, }).transform((v) => { return remap$(v, { "current_question": "currentQuestion", "other_resolved_question_ids": "otherResolvedQuestionIds", }); }); /** @internal */ export type AnswerStep$Outbound = { type: "answer"; think: string; current_question: string; errored: boolean; other_resolved_question_ids?: Array | undefined; answer: Answer$Outbound; }; /** @internal */ export const AnswerStep$outboundSchema: z.ZodType< AnswerStep$Outbound, z.ZodTypeDef, AnswerStep > = z.object({ type: z.literal("answer").default("answer" as const), think: z.string(), currentQuestion: z.string(), errored: z.boolean().default(false), otherResolvedQuestionIds: z.array(z.string()).optional(), answer: Answer$outboundSchema, }).transform((v) => { return remap$(v, { currentQuestion: "current_question", otherResolvedQuestionIds: "other_resolved_question_ids", }); }); export function answerStepToJSON(answerStep: AnswerStep): string { return JSON.stringify(AnswerStep$outboundSchema.parse(answerStep)); } export function answerStepFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AnswerStep$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AnswerStep' from JSON`, ); }