// Package decision implements the pure decision engine.
// Input: MessageContext. Output: []Action. Zero side effects.
package decision

import "github.com/enmanuel/agents/pkg/tools"

// MessageContext holds all the information about an incoming message.
type MessageContext struct {
	SenderID    string
	SenderName  string
	RoomID      string
	EventID     string   // Matrix event ID of the incoming message
	Content     string
	Command     string   // parsed command name, e.g. "deploy"
	Args        []string // parsed arguments
	PowerLevel  int
	IsDirectMsg bool
	IsMention   bool
	ThreadID    string
}

// ActionKind is the type of action to perform.
type ActionKind string

const (
	ActionKindReply   ActionKind = "reply"
	ActionKindSSH     ActionKind = "ssh"
	ActionKindHTTP    ActionKind = "http"
	ActionKindScript  ActionKind = "script"
	ActionKindFileOps ActionKind = "file_ops"
	ActionKindMCP     ActionKind = "mcp"
	ActionKindLLM     ActionKind = "llm"
	ActionKindDelegate ActionKind = "delegate"
)

// Action is a pure description of what the shell should do.
// It is a tagged union — only the field matching Kind is set.
type Action struct {
	Kind     ActionKind
	Reply    *ReplyAction
	SSH      *tools.SSHCommandSpec
	HTTP     *tools.HTTPCallSpec
	Script   *tools.ScriptSpec
	FileOps  *tools.FileOpsSpec
	MCP      *tools.MCPCallSpec
	LLM      *LLMAction
	Delegate *DelegateAction
}

type ReplyAction struct {
	Content    string
	ThreadID   string // empty = new thread
	InReplyTo  string // Matrix event ID to reply to (m.in_reply_to)
	Reaction   string // optional Matrix reaction
}

type LLMAction struct {
	ContextKey string // key to look up conversation history
	ExtraTools []string // additional tool names to make available
}

type DelegateAction struct {
	TargetAgentID string
	Task          string
	Context       map[string]string
}
