package model

import (
	"encoding/json"
	"time"
)

// CaptainCustomTool represents a custom tool function for Captain AI.
// Reference: P2B M10 spec
type CaptainCustomTool struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	AssistantID uint           `gorm:"not null;index" json:"assistant_id"`
	Name        string         `gorm:"size:255;not null" json:"name"`
	Description string         `gorm:"type:text" json:"description"`
	Endpoint    string         `gorm:"size:512" json:"endpoint"`
	Method      string         `gorm:"size:50;default:'POST'" json:"method"` // GET/POST/PUT/DELETE
	Headers     json.RawMessage `gorm:"type:jsonb" json:"headers"`
	Parameters  json.RawMessage `gorm:"type:jsonb" json:"parameters"`
	Active      bool           `gorm:"default:true" json:"active"`
	CreatedAt   time.Time      `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"autoUpdateTime" json:"updated_at"`

	Assistant CaptainAssistant `gorm:"foreignKey:AssistantID" json:"assistant,omitempty"`
}

func (CaptainCustomTool) TableName() string { return "captain_custom_tools" }