Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526/** * Message — a single user/assistant turn (PROTOCOL §11). * * `content` is an ordered list of ContentBlocks. `id` is the stable correlation key * referenced by streaming deltas (`message_delta`/`message_complete`) and by the * session JSONL. */import { Type, type Static } from '@sinclair/typebox';import { ContentBlockSchema } from '@/types/content';
export const MessageSchema = Type.Object({ id: Type.String(), role: Type.Union([Type.Literal('user'), Type.Literal('assistant')]), content: Type.Array(ContentBlockSchema), // Provenance: which model minted this assistant message. Used by the outbound transform // to compute `isSameModel` for reasoning-signature replay (mirrors pi-ai's triple on // AssistantMessage). Optional + assistant-only by convention — user messages leave // these undefined. Old sessions migrate to `undefined` provenance (cross-model-safe // downgrade) without a file rewrite. provider: Type.Optional(Type.String()), api: Type.Optional(Type.String()), model: Type.Optional(Type.String()),});
export type Message = Static<typeof MessageSchema>;