mirror of
https://github.com/kennethnym/freya
synced 2026-07-07 00:01:20 +01:00
feat: add conversation schemas (#155)
This commit is contained in:
@@ -159,3 +159,115 @@ export type ConversationEntryPayload =
|
||||
| AttachmentPayload
|
||||
| ContextSummaryPayload
|
||||
| GenericObjectPayload
|
||||
|
||||
export const Conversation = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
createdAt: "string.date.iso",
|
||||
updatedAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export type Conversation = typeof Conversation.infer
|
||||
|
||||
export const UserMessageConversationEntry = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
conversationId: "string.uuid",
|
||||
sequence: "number.integer >= 1",
|
||||
kind: "'user_message'",
|
||||
visibility: type.enumerated(...Object.values(ConversationEntryVisibility)),
|
||||
fileId: "null",
|
||||
payload: UserMessagePayload,
|
||||
metadata: ConversationEntryMetadata,
|
||||
createdAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export const AssistantMessageConversationEntry = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
conversationId: "string.uuid",
|
||||
sequence: "number.integer >= 1",
|
||||
kind: "'assistant_message'",
|
||||
visibility: type.enumerated(...Object.values(ConversationEntryVisibility)),
|
||||
fileId: "null",
|
||||
payload: AssistantMessagePayload,
|
||||
metadata: ConversationEntryMetadata,
|
||||
createdAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export const AttachmentConversationEntry = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
conversationId: "string.uuid",
|
||||
sequence: "number.integer >= 1",
|
||||
kind: "'attachment'",
|
||||
visibility: type.enumerated(...Object.values(ConversationEntryVisibility)),
|
||||
fileId: "string.uuid",
|
||||
payload: AttachmentPayload,
|
||||
metadata: ConversationEntryMetadata,
|
||||
createdAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export const ToolCallConversationEntry = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
conversationId: "string.uuid",
|
||||
sequence: "number.integer >= 1",
|
||||
kind: "'tool_call'",
|
||||
visibility: type.enumerated(...Object.values(ConversationEntryVisibility)),
|
||||
fileId: "null",
|
||||
payload: GenericObjectPayload,
|
||||
metadata: ConversationEntryMetadata,
|
||||
createdAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export const ToolResultConversationEntry = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
conversationId: "string.uuid",
|
||||
sequence: "number.integer >= 1",
|
||||
kind: "'tool_result'",
|
||||
visibility: type.enumerated(...Object.values(ConversationEntryVisibility)),
|
||||
fileId: "null",
|
||||
payload: GenericObjectPayload,
|
||||
metadata: ConversationEntryMetadata,
|
||||
createdAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export const ContextSummaryConversationEntry = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
conversationId: "string.uuid",
|
||||
sequence: "number.integer >= 1",
|
||||
kind: "'context_summary'",
|
||||
visibility: type.enumerated(...Object.values(ConversationEntryVisibility)),
|
||||
fileId: "null",
|
||||
payload: ContextSummaryPayload,
|
||||
metadata: ConversationEntryMetadata,
|
||||
createdAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export const SystemNoteConversationEntry = type({
|
||||
"+": "reject",
|
||||
id: "string.uuid",
|
||||
conversationId: "string.uuid",
|
||||
sequence: "number.integer >= 1",
|
||||
kind: "'system_note'",
|
||||
visibility: type.enumerated(...Object.values(ConversationEntryVisibility)),
|
||||
fileId: "null",
|
||||
payload: GenericObjectPayload,
|
||||
metadata: ConversationEntryMetadata,
|
||||
createdAt: "string.date.iso",
|
||||
})
|
||||
|
||||
export const ConversationEntry = type.or(
|
||||
UserMessageConversationEntry,
|
||||
AssistantMessageConversationEntry,
|
||||
AttachmentConversationEntry,
|
||||
ToolCallConversationEntry,
|
||||
ToolResultConversationEntry,
|
||||
ContextSummaryConversationEntry,
|
||||
SystemNoteConversationEntry,
|
||||
)
|
||||
|
||||
export type ConversationEntry = typeof ConversationEntry.infer
|
||||
|
||||
Reference in New Issue
Block a user