/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 6a03acd8a711
 */

import * as z from "zod/v4";
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 {
  ToolConfiguration,
  ToolConfiguration$inboundSchema,
  ToolConfiguration$Outbound,
  ToolConfiguration$outboundSchema,
} from "./toolconfiguration.js";

export type CodeInterpreterTool = {
  toolConfiguration?: ToolConfiguration | null | undefined;
  type: "code_interpreter";
};

/** @internal */
export const CodeInterpreterTool$inboundSchema: z.ZodType<
  CodeInterpreterTool,
  unknown
> = z.object({
  tool_configuration: z.nullable(ToolConfiguration$inboundSchema).optional(),
  type: z.literal("code_interpreter"),
}).transform((v) => {
  return remap$(v, {
    "tool_configuration": "toolConfiguration",
  });
});
/** @internal */
export type CodeInterpreterTool$Outbound = {
  tool_configuration?: ToolConfiguration$Outbound | null | undefined;
  type: "code_interpreter";
};

/** @internal */
export const CodeInterpreterTool$outboundSchema: z.ZodType<
  CodeInterpreterTool$Outbound,
  CodeInterpreterTool
> = z.object({
  toolConfiguration: z.nullable(ToolConfiguration$outboundSchema).optional(),
  type: z.literal("code_interpreter"),
}).transform((v) => {
  return remap$(v, {
    toolConfiguration: "tool_configuration",
  });
});

export function codeInterpreterToolToJSON(
  codeInterpreterTool: CodeInterpreterTool,
): string {
  return JSON.stringify(
    CodeInterpreterTool$outboundSchema.parse(codeInterpreterTool),
  );
}
export function codeInterpreterToolFromJSON(
  jsonString: string,
): SafeParseResult<CodeInterpreterTool, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CodeInterpreterTool$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CodeInterpreterTool' from JSON`,
  );
}
