import { z } from "zod" /** * Base ChatMessage schema and ChatMessageSenderType enum * Used by message-related endpoints */ export const ForgeChatMessageSenderType = z.enum([ "User", "Agent", "Developer", "FunctionCallInput", "FunctionCallOutput", ]) export type ForgeChatMessageSenderType = z.infer< typeof ForgeChatMessageSenderType > export const ForgeChatMessageSender = z.discriminatedUnion("type", [ z.object({ type: z.literal(ForgeChatMessageSenderType.enum.User), userId: z.string(), }), z.object({ type: z.literal(ForgeChatMessageSenderType.enum.Agent), persona: z.literal("Amy"), }), z.object({ type: z.literal(ForgeChatMessageSenderType.enum.Developer) }), z.object({ type: z.literal(ForgeChatMessageSenderType.enum.FunctionCallInput), }), z.object({ type: z.literal(ForgeChatMessageSenderType.enum.FunctionCallOutput), }), ]) export const ForgeChatMessageUserScoreType = z.enum(["Positive", "Negative"]) export const ForgeChatMessageUserScore = z.object({ type: ForgeChatMessageUserScoreType, tags: z.string().array(), comment: z.string().optional(), }) export const ForgeChatMessage = z.object({ id: z.string(), threadId: z.string(), payload: z.string(), createdAt: z.coerce.date(), updatedAt: z.coerce.date(), opikTraceId: z.string().optional(), sender: ForgeChatMessageSender, userScore: ForgeChatMessageUserScore.optional(), }) export type ForgeChatMessageSender = z.infer export type ForgeChatMessageUserScoreType = z.infer< typeof ForgeChatMessageUserScoreType > export type ForgeChatMessageUserScore = z.infer< typeof ForgeChatMessageUserScore > export type ForgeChatMessage = z.infer