/*
 * 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 { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export const AgentConversationObject = {
  Conversation: "conversation",
} as const;
export type AgentConversationObject = ClosedEnum<
  typeof AgentConversationObject
>;

export type AgentConversationAgentVersion = string | number;

export type AgentConversation = {
  /**
   * Name given to the conversation.
   */
  name?: string | null | undefined;
  /**
   * Description of the what the conversation is about.
   */
  description?: string | null | undefined;
  /**
   * Custom metadata for the conversation.
   */
  metadata?: { [k: string]: any } | null | undefined;
  object: AgentConversationObject | undefined;
  id: string;
  createdAt: Date;
  updatedAt: Date;
  agentId: string;
  agentVersion?: string | number | null | undefined;
};

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

/** @internal */
export const AgentConversationAgentVersion$inboundSchema: z.ZodType<
  AgentConversationAgentVersion,
  z.ZodTypeDef,
  unknown
> = z.union([z.string(), z.number().int()]);

export function agentConversationAgentVersionFromJSON(
  jsonString: string,
): SafeParseResult<AgentConversationAgentVersion, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AgentConversationAgentVersion$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AgentConversationAgentVersion' from JSON`,
  );
}

/** @internal */
export const AgentConversation$inboundSchema: z.ZodType<
  AgentConversation,
  z.ZodTypeDef,
  unknown
> = z.object({
  name: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  metadata: z.nullable(z.record(z.any())).optional(),
  object: AgentConversationObject$inboundSchema.default("conversation"),
  id: z.string(),
  created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
  updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
  agent_id: z.string(),
  agent_version: z.nullable(z.union([z.string(), z.number().int()])).optional(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "updated_at": "updatedAt",
    "agent_id": "agentId",
    "agent_version": "agentVersion",
  });
});

export function agentConversationFromJSON(
  jsonString: string,
): SafeParseResult<AgentConversation, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AgentConversation$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AgentConversation' from JSON`,
  );
}
