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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import {
  CodeInterpreterTool,
  CodeInterpreterTool$Outbound,
  CodeInterpreterTool$outboundSchema,
} from "./codeinterpretertool.js";
import {
  CompletionArgs,
  CompletionArgs$Outbound,
  CompletionArgs$outboundSchema,
} from "./completionargs.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 type CreateAgentRequestTool =
  | CodeInterpreterTool
  | CustomConnector
  | DocumentLibraryTool
  | FunctionTool
  | ImageGenerationTool
  | WebSearchTool
  | WebSearchPremiumTool;

export type CreateAgentRequest = {
  /**
   * Instruction prompt the model will follow during the conversation.
   */
  instructions?: string | null | undefined;
  /**
   * List of tools which are available to the model during the conversation.
   */
  tools?:
    | Array<
      | CodeInterpreterTool
      | CustomConnector
      | DocumentLibraryTool
      | FunctionTool
      | ImageGenerationTool
      | WebSearchTool
      | WebSearchPremiumTool
    >
    | undefined;
  /**
   * White-listed arguments from the completion API
   */
  completionArgs?: CompletionArgs | undefined;
  guardrails?: Array<GuardrailConfig> | null | undefined;
  model: string;
  name: string;
  description?: string | null | undefined;
  handoffs?: Array<string> | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  versionMessage?: string | null | undefined;
};

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

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

export function createAgentRequestToolToJSON(
  createAgentRequestTool: CreateAgentRequestTool,
): string {
  return JSON.stringify(
    CreateAgentRequestTool$outboundSchema.parse(createAgentRequestTool),
  );
}

/** @internal */
export type CreateAgentRequest$Outbound = {
  instructions?: string | null | undefined;
  tools?:
    | Array<
      | CodeInterpreterTool$Outbound
      | CustomConnector$Outbound
      | DocumentLibraryTool$Outbound
      | FunctionTool$Outbound
      | ImageGenerationTool$Outbound
      | WebSearchTool$Outbound
      | WebSearchPremiumTool$Outbound
    >
    | undefined;
  completion_args?: CompletionArgs$Outbound | undefined;
  guardrails?: Array<GuardrailConfig$Outbound> | null | undefined;
  model: string;
  name: string;
  description?: string | null | undefined;
  handoffs?: Array<string> | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  version_message?: string | null | undefined;
};

/** @internal */
export const CreateAgentRequest$outboundSchema: z.ZodType<
  CreateAgentRequest$Outbound,
  CreateAgentRequest
> = z.object({
  instructions: z.nullable(z.string()).optional(),
  tools: z.array(
    z.union([
      CodeInterpreterTool$outboundSchema,
      CustomConnector$outboundSchema,
      DocumentLibraryTool$outboundSchema,
      FunctionTool$outboundSchema,
      ImageGenerationTool$outboundSchema,
      WebSearchTool$outboundSchema,
      WebSearchPremiumTool$outboundSchema,
    ]),
  ).optional(),
  completionArgs: CompletionArgs$outboundSchema.optional(),
  guardrails: z.nullable(z.array(GuardrailConfig$outboundSchema)).optional(),
  model: z.string(),
  name: z.string(),
  description: z.nullable(z.string()).optional(),
  handoffs: z.nullable(z.array(z.string())).optional(),
  metadata: z.nullable(z.record(z.string(), z.any())).optional(),
  versionMessage: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    completionArgs: "completion_args",
    versionMessage: "version_message",
  });
});

export function createAgentRequestToJSON(
  createAgentRequest: CreateAgentRequest,
): string {
  return JSON.stringify(
    CreateAgentRequest$outboundSchema.parse(createAgentRequest),
  );
}
