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

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

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

export type ConversationAppendRequest = {
  inputs?: ConversationInputs | undefined;
  stream?: false | undefined;
  /**
   * Whether to store the results into our servers or not.
   */
  store?: boolean | undefined;
  handoffExecution?: ConversationAppendRequestHandoffExecution | undefined;
  /**
   * White-listed arguments from the completion API
   */
  completionArgs?: CompletionArgs | undefined;
  toolConfirmations?: Array<ToolCallConfirmation> | null | undefined;
};

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

/** @internal */
export type ConversationAppendRequest$Outbound = {
  inputs?: ConversationInputs$Outbound | undefined;
  stream: false;
  store: boolean;
  handoff_execution: string;
  completion_args?: CompletionArgs$Outbound | undefined;
  tool_confirmations?: Array<ToolCallConfirmation$Outbound> | null | undefined;
};

/** @internal */
export const ConversationAppendRequest$outboundSchema: z.ZodType<
  ConversationAppendRequest$Outbound,
  ConversationAppendRequest
> = z.object({
  inputs: ConversationInputs$outboundSchema.optional(),
  stream: z.literal(false).default(false as const),
  store: z.boolean().default(true),
  handoffExecution: ConversationAppendRequestHandoffExecution$outboundSchema
    .default("server"),
  completionArgs: CompletionArgs$outboundSchema.optional(),
  toolConfirmations: z.nullable(z.array(ToolCallConfirmation$outboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    handoffExecution: "handoff_execution",
    completionArgs: "completion_args",
    toolConfirmations: "tool_confirmations",
  });
});

export function conversationAppendRequestToJSON(
  conversationAppendRequest: ConversationAppendRequest,
): string {
  return JSON.stringify(
    ConversationAppendRequest$outboundSchema.parse(conversationAppendRequest),
  );
}
