/*
 * 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 { ClosedEnum } from "../../types/enums.js";
import {
  CompletionArgs,
  CompletionArgs$Outbound,
  CompletionArgs$outboundSchema,
} from "./completionargs.js";
import {
  ConversationInputs,
  ConversationInputs$Outbound,
  ConversationInputs$outboundSchema,
} from "./conversationinputs.js";

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

export type ConversationAppendStreamRequest = {
  inputs: ConversationInputs;
  stream?: boolean | undefined;
  /**
   * Whether to store the results into our servers or not.
   */
  store?: boolean | undefined;
  handoffExecution?:
    | ConversationAppendStreamRequestHandoffExecution
    | undefined;
  /**
   * White-listed arguments from the completion API
   */
  completionArgs?: CompletionArgs | undefined;
};

/** @internal */
export const ConversationAppendStreamRequestHandoffExecution$outboundSchema:
  z.ZodNativeEnum<typeof ConversationAppendStreamRequestHandoffExecution> = z
    .nativeEnum(ConversationAppendStreamRequestHandoffExecution);

/** @internal */
export type ConversationAppendStreamRequest$Outbound = {
  inputs: ConversationInputs$Outbound;
  stream: boolean;
  store: boolean;
  handoff_execution: string;
  completion_args?: CompletionArgs$Outbound | undefined;
};

/** @internal */
export const ConversationAppendStreamRequest$outboundSchema: z.ZodType<
  ConversationAppendStreamRequest$Outbound,
  z.ZodTypeDef,
  ConversationAppendStreamRequest
> = z.object({
  inputs: ConversationInputs$outboundSchema,
  stream: z.boolean().default(true),
  store: z.boolean().default(true),
  handoffExecution:
    ConversationAppendStreamRequestHandoffExecution$outboundSchema.default(
      "server",
    ),
  completionArgs: CompletionArgs$outboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    handoffExecution: "handoff_execution",
    completionArgs: "completion_args",
  });
});

export function conversationAppendStreamRequestToJSON(
  conversationAppendStreamRequest: ConversationAppendStreamRequest,
): string {
  return JSON.stringify(
    ConversationAppendStreamRequest$outboundSchema.parse(
      conversationAppendStreamRequest,
    ),
  );
}
