package model

import (
	"encoding/json"
	"time"
)

// CopilotMessage represents a message within a copilot thread.
// Reference: P2B M10 spec
type CopilotMessage struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	ThreadID  uint           `gorm:"not null;index" json:"thread_id"`
	Role      string         `gorm:"size:50;not null" json:"role"` // user/assistant/system
	Content   string         `gorm:"type:text;not null" json:"content"`
	Metadata  json.RawMessage `gorm:"type:jsonb" json:"metadata"`
	CreatedAt time.Time      `gorm:"autoCreateTime" json:"created_at"`

	Thread CopilotThread `gorm:"foreignKey:ThreadID" json:"thread,omitempty"`
}

func (CopilotMessage) TableName() string { return "copilot_messages" }