- Add VOICE_MODES constant and VoiceMode type to shared validators/chat.ts - Extend createMessageSchema with optional voiceMode enum field - Add voiceMode optional field to ChatMessage interface in types/chat.ts - Add 36-voice-schema.test.ts with 6 passing tests for voiceMode validation
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const createConversationSchema = z.object({
|
|
title: z.string().max(200).optional(),
|
|
agentId: z.string().uuid().optional(),
|
|
});
|
|
|
|
export const updateConversationSchema = z.object({
|
|
title: z.string().max(200).optional(),
|
|
agentId: z.string().uuid().nullable().optional(),
|
|
pinnedAt: z.string().datetime().nullable().optional(),
|
|
archivedAt: z.string().datetime().nullable().optional(),
|
|
});
|
|
|
|
export const VOICE_MODES = ["text", "voice_input", "full_voice"] as const;
|
|
export type VoiceMode = (typeof VOICE_MODES)[number];
|
|
|
|
export const createMessageSchema = z.object({
|
|
role: z.enum(["user", "assistant", "system"]),
|
|
content: z.string().min(1).max(100_000),
|
|
agentId: z.string().uuid().optional(),
|
|
messageType: z.string().optional(),
|
|
voiceMode: z.enum(VOICE_MODES).optional(),
|
|
});
|
|
|
|
export const handoffSchema = z.object({
|
|
spec: z.object({
|
|
what: z.string().min(1),
|
|
why: z.string().min(1),
|
|
constraints: z.string().optional().default(""),
|
|
success: z.string().optional().default(""),
|
|
}),
|
|
targetRole: z.enum(["pm", "engineer", "general"]),
|
|
});
|
|
|
|
export type CreateConversation = z.infer<typeof createConversationSchema>;
|
|
export type UpdateConversation = z.infer<typeof updateConversationSchema>;
|
|
export type CreateMessage = z.infer<typeof createMessageSchema>;
|
|
export type Handoff = z.infer<typeof handoffSchema>;
|
|
|
|
export const searchMessagesSchema = z.object({
|
|
q: z.string().min(2).max(200),
|
|
limit: z.coerce.number().int().min(1).max(50).optional(),
|
|
});
|
|
|
|
export const branchConversationSchema = z.object({
|
|
branchFromMessageId: z.string().uuid(),
|
|
});
|
|
|
|
export type SearchMessages = z.infer<typeof searchMessagesSchema>;
|
|
export type BranchConversation = z.infer<typeof branchConversationSchema>;
|
|
|
|
export const uploadChatFileSchema = z.object({
|
|
conversationId: z.string().uuid().optional(),
|
|
messageId: z.string().uuid().optional(),
|
|
source: z.enum(["user_upload", "agent_generated"]).default("user_upload"),
|
|
projectId: z.string().uuid().optional(),
|
|
});
|
|
|
|
export const createFileReferenceSchema = z.object({
|
|
fileId: z.string().uuid(),
|
|
messageId: z.string().uuid().optional(),
|
|
});
|
|
|
|
export type UploadChatFile = z.infer<typeof uploadChatFileSchema>;
|
|
export type CreateFileReference = z.infer<typeof createFileReferenceSchema>;
|