package model

import (
	"encoding/json"
	"time"
)

// AgentBot represents an automated bot agent.
// Reference: Chatwoot AgentBot model + P2B M2 spec
type AgentBot struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	AccountID *uint          `gorm:"index" json:"account_id,omitempty"`
	Name      string         `gorm:"size:255;not null" json:"name"`
	AvatarURL string         `gorm:"size:512" json:"avatar_url"`
	BotType   string         `gorm:"size:50;default:'default'" json:"bot_type"` // default/custom
	Config    json.RawMessage `gorm:"type:jsonb" json:"config"`
	CreatedAt time.Time      `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime" json:"updated_at"`

	Inboxes []AgentBotInbox `gorm:"foreignKey:AgentBotID" json:"inboxes,omitempty"`
}

func (AgentBot) TableName() string { return "agent_bots" }