/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CodeInterpreterOutput, CodeInterpreterOutput$inboundSchema, CodeInterpreterOutput$Outbound, CodeInterpreterOutput$outboundSchema, } from "./codeinterpreteroutput.js"; export const CodeInterpreterToolCallWithIdStatus = { InProgress: "in_progress", Completed: "completed", Incomplete: "incomplete", Interpreting: "interpreting", Failed: "failed", } as const; export type CodeInterpreterToolCallWithIdStatus = ClosedEnum< typeof CodeInterpreterToolCallWithIdStatus >; /** * Code interpreter call item: A tool-call record for code execution, including code, container, outputs, and status. */ export type CodeInterpreterToolCallWithId = { type: "code_interpreter_call"; /** * The unique ID of the message. */ id: string; code: string | null; containerId: string; outputs: Array | null; status: CodeInterpreterToolCallWithIdStatus; /** * 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; }; /** @internal */ export const CodeInterpreterToolCallWithIdStatus$inboundSchema: z.ZodNativeEnum< typeof CodeInterpreterToolCallWithIdStatus > = z.nativeEnum(CodeInterpreterToolCallWithIdStatus); /** @internal */ export const CodeInterpreterToolCallWithIdStatus$outboundSchema: z.ZodNativeEnum = CodeInterpreterToolCallWithIdStatus$inboundSchema; /** @internal */ export const CodeInterpreterToolCallWithId$inboundSchema: z.ZodType< CodeInterpreterToolCallWithId, z.ZodTypeDef, unknown > = z.object({ type: z.literal("code_interpreter_call"), id: z.string(), code: z.nullable(z.string()), container_id: z.string(), outputs: z.nullable(z.array(CodeInterpreterOutput$inboundSchema)), status: CodeInterpreterToolCallWithIdStatus$inboundSchema, response_id: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { "container_id": "containerId", "response_id": "responseId", }); }); /** @internal */ export type CodeInterpreterToolCallWithId$Outbound = { type: "code_interpreter_call"; id: string; code: string | null; container_id: string; outputs: Array | null; status: string; response_id?: string | null | undefined; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const CodeInterpreterToolCallWithId$outboundSchema: z.ZodType< CodeInterpreterToolCallWithId$Outbound, z.ZodTypeDef, CodeInterpreterToolCallWithId > = z.object({ type: z.literal("code_interpreter_call"), id: z.string(), code: z.nullable(z.string()), containerId: z.string(), outputs: z.nullable(z.array(CodeInterpreterOutput$outboundSchema)), status: CodeInterpreterToolCallWithIdStatus$outboundSchema, responseId: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { containerId: "container_id", responseId: "response_id", }); }); export function codeInterpreterToolCallWithIdToJSON( codeInterpreterToolCallWithId: CodeInterpreterToolCallWithId, ): string { return JSON.stringify( CodeInterpreterToolCallWithId$outboundSchema.parse( codeInterpreterToolCallWithId, ), ); } export function codeInterpreterToolCallWithIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CodeInterpreterToolCallWithId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CodeInterpreterToolCallWithId' from JSON`, ); }