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:
parent
a424e96dd7
commit
5671b24210
5 changed files with 17 additions and 0 deletions
1
packages/db/src/migrations/0049_add_message_type.sql
Normal file
1
packages/db/src/migrations/0049_add_message_type.sql
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE "chat_messages" ADD COLUMN "message_type" text;
|
||||||
|
|
@ -10,6 +10,7 @@ export const chatMessages = pgTable(
|
||||||
role: text("role").notNull(),
|
role: text("role").notNull(),
|
||||||
content: text("content").notNull(),
|
content: text("content").notNull(),
|
||||||
agentId: uuid("agent_id"),
|
agentId: uuid("agent_id"),
|
||||||
|
messageType: text("message_type"),
|
||||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||||
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -592,9 +592,11 @@ export {
|
||||||
createConversationSchema,
|
createConversationSchema,
|
||||||
updateConversationSchema,
|
updateConversationSchema,
|
||||||
createMessageSchema,
|
createMessageSchema,
|
||||||
|
handoffSchema,
|
||||||
type CreateConversation,
|
type CreateConversation,
|
||||||
type UpdateConversation,
|
type UpdateConversation,
|
||||||
type CreateMessage,
|
type CreateMessage,
|
||||||
|
type Handoff,
|
||||||
} from "./validators/index.js";
|
} from "./validators/index.js";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export interface ChatMessage {
|
||||||
role: "user" | "assistant" | "system";
|
role: "user" | "assistant" | "system";
|
||||||
content: string;
|
content: string;
|
||||||
agentId: string | null;
|
agentId: string | null;
|
||||||
|
messageType: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string | null;
|
updatedAt: string | null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,20 @@ export const createMessageSchema = z.object({
|
||||||
role: z.enum(["user", "assistant", "system"]),
|
role: z.enum(["user", "assistant", "system"]),
|
||||||
content: z.string().min(1).max(100_000),
|
content: z.string().min(1).max(100_000),
|
||||||
agentId: z.string().uuid().optional(),
|
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 CreateConversation = z.infer<typeof createConversationSchema>;
|
||||||
export type UpdateConversation = z.infer<typeof updateConversationSchema>;
|
export type UpdateConversation = z.infer<typeof updateConversationSchema>;
|
||||||
export type CreateMessage = z.infer<typeof createMessageSchema>;
|
export type CreateMessage = z.infer<typeof createMessageSchema>;
|
||||||
|
export type Handoff = z.infer<typeof handoffSchema>;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue