/* * 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"; export type CodeStep = { type?: "code" | undefined; think: string; currentQuestion: string; errored?: boolean | undefined; /** * The natural language description of the code issue you need to solve. */ codeIssue: string; /** * The code you generated to solve the code issue. */ code?: string | undefined; /** * The result of the code you generated after executing it. */ codeResult?: string | undefined; }; /** @internal */ export const CodeStep$inboundSchema: z.ZodType< CodeStep, z.ZodTypeDef, unknown > = z.object({ type: z.literal("code").default("code"), think: z.string(), current_question: z.string(), errored: z.boolean().default(false), code_issue: z.string(), code: z.string().default(""), code_result: z.string().default(""), }).transform((v) => { return remap$(v, { "current_question": "currentQuestion", "code_issue": "codeIssue", "code_result": "codeResult", }); }); /** @internal */ export type CodeStep$Outbound = { type: "code"; think: string; current_question: string; errored: boolean; code_issue: string; code: string; code_result: string; }; /** @internal */ export const CodeStep$outboundSchema: z.ZodType< CodeStep$Outbound, z.ZodTypeDef, CodeStep > = z.object({ type: z.literal("code").default("code" as const), think: z.string(), currentQuestion: z.string(), errored: z.boolean().default(false), codeIssue: z.string(), code: z.string().default(""), codeResult: z.string().default(""), }).transform((v) => { return remap$(v, { currentQuestion: "current_question", codeIssue: "code_issue", codeResult: "code_result", }); }); export function codeStepToJSON(codeStep: CodeStep): string { return JSON.stringify(CodeStep$outboundSchema.parse(codeStep)); } export function codeStepFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CodeStep$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CodeStep' from JSON`, ); }