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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { ClosedEnum } from "../../types/enums.js";
import { smartUnion } from "../../types/smartUnion.js";
import {
  CodeInterpreterTool,
  CodeInterpreterTool$Outbound,
  CodeInterpreterTool$outboundSchema,
} from "./codeinterpretertool.js";
import {
  CompletionArgs,
  CompletionArgs$Outbound,
  CompletionArgs$outboundSchema,
} from "./completionargs.js";
import {
  ConversationInputs,
  ConversationInputs$Outbound,
  ConversationInputs$outboundSchema,
} from "./conversationinputs.js";
import {
  CustomConnector,
  CustomConnector$Outbound,
  CustomConnector$outboundSchema,
} from "./customconnector.js";
import {
  DocumentLibraryTool,
  DocumentLibraryTool$Outbound,
  DocumentLibraryTool$outboundSchema,
} from "./documentlibrarytool.js";
import {
  FunctionTool,
  FunctionTool$Outbound,
  FunctionTool$outboundSchema,
} from "./functiontool.js";
import {
  GuardrailConfig,
  GuardrailConfig$Outbound,
  GuardrailConfig$outboundSchema,
} from "./guardrailconfig.js";
import {
  ImageGenerationTool,
  ImageGenerationTool$Outbound,
  ImageGenerationTool$outboundSchema,
} from "./imagegenerationtool.js";
import {
  WebSearchPremiumTool,
  WebSearchPremiumTool$Outbound,
  WebSearchPremiumTool$outboundSchema,
} from "./websearchpremiumtool.js";
import {
  WebSearchTool,
  WebSearchTool$Outbound,
  WebSearchTool$outboundSchema,
} from "./websearchtool.js";

export const ConversationRequestHandoffExecution = {
  Client: "client",
  Server: "server",
} as const;
export type ConversationRequestHandoffExecution = ClosedEnum<
  typeof ConversationRequestHandoffExecution
>;

export type ConversationRequestTool =
  | CodeInterpreterTool
  | CustomConnector
  | DocumentLibraryTool
  | FunctionTool
  | ImageGenerationTool
  | WebSearchTool
  | WebSearchPremiumTool;

export type ConversationRequestAgentVersion = string | number;

export type ConversationRequest = {
  inputs: ConversationInputs;
  stream?: false | undefined;
  store?: boolean | null | undefined;
  handoffExecution?: ConversationRequestHandoffExecution | null | undefined;
  instructions?: string | null | undefined;
  tools?:
    | Array<
      | CodeInterpreterTool
      | CustomConnector
      | DocumentLibraryTool
      | FunctionTool
      | ImageGenerationTool
      | WebSearchTool
      | WebSearchPremiumTool
    >
    | null
    | undefined;
  completionArgs?: CompletionArgs | null | undefined;
  guardrails?: Array<GuardrailConfig> | null | undefined;
  name?: string | null | undefined;
  description?: string | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  agentId?: string | null | undefined;
  agentVersion?: string | number | null | undefined;
  model?: string | null | undefined;
};

/** @internal */
export const ConversationRequestHandoffExecution$outboundSchema: z.ZodEnum<
  typeof ConversationRequestHandoffExecution
> = z.enum(ConversationRequestHandoffExecution);

/** @internal */
export type ConversationRequestTool$Outbound =
  | CodeInterpreterTool$Outbound
  | CustomConnector$Outbound
  | DocumentLibraryTool$Outbound
  | FunctionTool$Outbound
  | ImageGenerationTool$Outbound
  | WebSearchTool$Outbound
  | WebSearchPremiumTool$Outbound;

/** @internal */
export const ConversationRequestTool$outboundSchema: z.ZodType<
  ConversationRequestTool$Outbound,
  ConversationRequestTool
> = z.union([
  CodeInterpreterTool$outboundSchema,
  CustomConnector$outboundSchema,
  DocumentLibraryTool$outboundSchema,
  FunctionTool$outboundSchema,
  ImageGenerationTool$outboundSchema,
  WebSearchTool$outboundSchema,
  WebSearchPremiumTool$outboundSchema,
]);

export function conversationRequestToolToJSON(
  conversationRequestTool: ConversationRequestTool,
): string {
  return JSON.stringify(
    ConversationRequestTool$outboundSchema.parse(conversationRequestTool),
  );
}

/** @internal */
export type ConversationRequestAgentVersion$Outbound = string | number;

/** @internal */
export const ConversationRequestAgentVersion$outboundSchema: z.ZodType<
  ConversationRequestAgentVersion$Outbound,
  ConversationRequestAgentVersion
> = smartUnion([z.string(), z.int()]);

export function conversationRequestAgentVersionToJSON(
  conversationRequestAgentVersion: ConversationRequestAgentVersion,
): string {
  return JSON.stringify(
    ConversationRequestAgentVersion$outboundSchema.parse(
      conversationRequestAgentVersion,
    ),
  );
}

/** @internal */
export type ConversationRequest$Outbound = {
  inputs: ConversationInputs$Outbound;
  stream: false;
  store?: boolean | null | undefined;
  handoff_execution?: string | null | undefined;
  instructions?: string | null | undefined;
  tools?:
    | Array<
      | CodeInterpreterTool$Outbound
      | CustomConnector$Outbound
      | DocumentLibraryTool$Outbound
      | FunctionTool$Outbound
      | ImageGenerationTool$Outbound
      | WebSearchTool$Outbound
      | WebSearchPremiumTool$Outbound
    >
    | null
    | undefined;
  completion_args?: CompletionArgs$Outbound | null | undefined;
  guardrails?: Array<GuardrailConfig$Outbound> | null | undefined;
  name?: string | null | undefined;
  description?: string | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  agent_id?: string | null | undefined;
  agent_version?: string | number | null | undefined;
  model?: string | null | undefined;
};

/** @internal */
export const ConversationRequest$outboundSchema: z.ZodType<
  ConversationRequest$Outbound,
  ConversationRequest
> = z.object({
  inputs: ConversationInputs$outboundSchema,
  stream: z.literal(false).default(false as const),
  store: z.nullable(z.boolean()).optional(),
  handoffExecution: z.nullable(
    ConversationRequestHandoffExecution$outboundSchema,
  ).optional(),
  instructions: z.nullable(z.string()).optional(),
  tools: z.nullable(
    z.array(
      z.union([
        CodeInterpreterTool$outboundSchema,
        CustomConnector$outboundSchema,
        DocumentLibraryTool$outboundSchema,
        FunctionTool$outboundSchema,
        ImageGenerationTool$outboundSchema,
        WebSearchTool$outboundSchema,
        WebSearchPremiumTool$outboundSchema,
      ]),
    ),
  ).optional(),
  completionArgs: z.nullable(CompletionArgs$outboundSchema).optional(),
  guardrails: z.nullable(z.array(GuardrailConfig$outboundSchema)).optional(),
  name: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  metadata: z.nullable(z.record(z.string(), z.any())).optional(),
  agentId: z.nullable(z.string()).optional(),
  agentVersion: z.nullable(smartUnion([z.string(), z.int()])).optional(),
  model: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    handoffExecution: "handoff_execution",
    completionArgs: "completion_args",
    agentId: "agent_id",
    agentVersion: "agent_version",
  });
});

export function conversationRequestToJSON(
  conversationRequest: ConversationRequest,
): string {
  return JSON.stringify(
    ConversationRequest$outboundSchema.parse(conversationRequest),
  );
}
