/*
 * 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 {
  CodeInterpreterTool,
  CodeInterpreterTool$Outbound,
  CodeInterpreterTool$outboundSchema,
} from "./codeinterpretertool.js";
import {
  CompletionArgs,
  CompletionArgs$Outbound,
  CompletionArgs$outboundSchema,
} from "./completionargs.js";
import {
  DocumentLibraryTool,
  DocumentLibraryTool$Outbound,
  DocumentLibraryTool$outboundSchema,
} from "./documentlibrarytool.js";
import {
  FunctionTool,
  FunctionTool$Outbound,
  FunctionTool$outboundSchema,
} from "./functiontool.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 AgentUpdateRequestTools =
  | (CodeInterpreterTool & { type: "code_interpreter" })
  | (DocumentLibraryTool & { type: "document_library" })
  | (FunctionTool & { type: "function" })
  | (ImageGenerationTool & { type: "image_generation" })
  | (WebSearchTool & { type: "web_search" })
  | (WebSearchPremiumTool & { type: "web_search_premium" });

export type AgentUpdateRequest = {
  /**
   * 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 & { type: "code_interpreter" })
      | (DocumentLibraryTool & { type: "document_library" })
      | (FunctionTool & { type: "function" })
      | (ImageGenerationTool & { type: "image_generation" })
      | (WebSearchTool & { type: "web_search" })
      | (WebSearchPremiumTool & { type: "web_search_premium" })
    >
    | undefined;
  /**
   * White-listed arguments from the completion API
   */
  completionArgs?: CompletionArgs | undefined;
  model?: string | null | undefined;
  name?: string | null | undefined;
  description?: string | null | undefined;
  handoffs?: Array<string> | null | undefined;
  deploymentChat?: boolean | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  versionMessage?: string | null | undefined;
};

/** @internal */
export type AgentUpdateRequestTools$Outbound =
  | (CodeInterpreterTool$Outbound & { type: "code_interpreter" })
  | (DocumentLibraryTool$Outbound & { type: "document_library" })
  | (FunctionTool$Outbound & { type: "function" })
  | (ImageGenerationTool$Outbound & { type: "image_generation" })
  | (WebSearchTool$Outbound & { type: "web_search" })
  | (WebSearchPremiumTool$Outbound & { type: "web_search_premium" });

/** @internal */
export const AgentUpdateRequestTools$outboundSchema: z.ZodType<
  AgentUpdateRequestTools$Outbound,
  z.ZodTypeDef,
  AgentUpdateRequestTools
> = z.union([
  CodeInterpreterTool$outboundSchema.and(
    z.object({ type: z.literal("code_interpreter") }),
  ),
  DocumentLibraryTool$outboundSchema.and(
    z.object({ type: z.literal("document_library") }),
  ),
  FunctionTool$outboundSchema.and(z.object({ type: z.literal("function") })),
  ImageGenerationTool$outboundSchema.and(
    z.object({ type: z.literal("image_generation") }),
  ),
  WebSearchTool$outboundSchema.and(z.object({ type: z.literal("web_search") })),
  WebSearchPremiumTool$outboundSchema.and(
    z.object({ type: z.literal("web_search_premium") }),
  ),
]);

export function agentUpdateRequestToolsToJSON(
  agentUpdateRequestTools: AgentUpdateRequestTools,
): string {
  return JSON.stringify(
    AgentUpdateRequestTools$outboundSchema.parse(agentUpdateRequestTools),
  );
}

/** @internal */
export type AgentUpdateRequest$Outbound = {
  instructions?: string | null | undefined;
  tools?:
    | Array<
      | (CodeInterpreterTool$Outbound & { type: "code_interpreter" })
      | (DocumentLibraryTool$Outbound & { type: "document_library" })
      | (FunctionTool$Outbound & { type: "function" })
      | (ImageGenerationTool$Outbound & { type: "image_generation" })
      | (WebSearchTool$Outbound & { type: "web_search" })
      | (WebSearchPremiumTool$Outbound & { type: "web_search_premium" })
    >
    | undefined;
  completion_args?: CompletionArgs$Outbound | undefined;
  model?: string | null | undefined;
  name?: string | null | undefined;
  description?: string | null | undefined;
  handoffs?: Array<string> | null | undefined;
  deployment_chat?: boolean | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  version_message?: string | null | undefined;
};

/** @internal */
export const AgentUpdateRequest$outboundSchema: z.ZodType<
  AgentUpdateRequest$Outbound,
  z.ZodTypeDef,
  AgentUpdateRequest
> = z.object({
  instructions: z.nullable(z.string()).optional(),
  tools: z.array(
    z.union([
      CodeInterpreterTool$outboundSchema.and(
        z.object({ type: z.literal("code_interpreter") }),
      ),
      DocumentLibraryTool$outboundSchema.and(
        z.object({ type: z.literal("document_library") }),
      ),
      FunctionTool$outboundSchema.and(
        z.object({ type: z.literal("function") }),
      ),
      ImageGenerationTool$outboundSchema.and(
        z.object({ type: z.literal("image_generation") }),
      ),
      WebSearchTool$outboundSchema.and(
        z.object({ type: z.literal("web_search") }),
      ),
      WebSearchPremiumTool$outboundSchema.and(
        z.object({ type: z.literal("web_search_premium") }),
      ),
    ]),
  ).optional(),
  completionArgs: CompletionArgs$outboundSchema.optional(),
  model: z.nullable(z.string()).optional(),
  name: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  handoffs: z.nullable(z.array(z.string())).optional(),
  deploymentChat: z.nullable(z.boolean()).optional(),
  metadata: z.nullable(z.record(z.any())).optional(),
  versionMessage: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    completionArgs: "completion_args",
    deploymentChat: "deployment_chat",
    versionMessage: "version_message",
  });
});

export function agentUpdateRequestToJSON(
  agentUpdateRequest: AgentUpdateRequest,
): string {
  return JSON.stringify(
    AgentUpdateRequest$outboundSchema.parse(agentUpdateRequest),
  );
}
