feat(23-00): DB migration and shared types for message_type

- Add message_type text column to chat_messages Drizzle schema
- Create SQL migration 0049_add_message_type.sql
- Update _journal.json with entries for idx 47, 48, 49
- Add messageType field to ChatMessage interface
- Add messageType to createMessageSchema (optional)
- Add handoffSchema and Handoff type to validators/chat.ts
- Re-export handoffSchema and Handoff from shared/src/index.ts
This commit is contained in:
Nexus Dev 2026-04-01 21:41:03 +00:00
parent a424e96dd7
commit 5671b24210
5 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1 @@
ALTER TABLE "chat_messages" ADD COLUMN "message_type" text;

View file

@ -10,6 +10,7 @@ export const chatMessages = pgTable(
role: text("role").notNull(),
content: text("content").notNull(),
agentId: uuid("agent_id"),
messageType: text("message_type"),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
},

View file

@ -592,9 +592,11 @@ export {
createConversationSchema,
updateConversationSchema,
createMessageSchema,
handoffSchema,
type CreateConversation,
type UpdateConversation,
type CreateMessage,
type Handoff,
} from "./validators/index.js";
export type {

View file

@ -27,6 +27,7 @@ export interface ChatMessage {
role: "user" | "assistant" | "system";
content: string;
agentId: string | null;
messageType: string | null;
createdAt: string;
updatedAt: string | null;
}

View file

@ -16,8 +16,20 @@ 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(),
});
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>;