package operator

import (
	"github.com/tidbcloud/AgentTeam/desktop/internal/agentview"
	"github.com/tidbcloud/AgentTeam/desktop/internal/profile"
)

type fileAgentOperator struct{}

func (f *fileAgentOperator) Get(id string) (agentview.Snapshot, bool, error) {
	configured, ok := profile.Default().Agents().Get(id)
	if !ok {
		return agentview.Snapshot{}, false, nil
	}
	return agentview.Build(configured, agentview.BuildContext{}), true, nil
}

func (f *fileAgentOperator) All() ([]agentview.Snapshot, error) {
	configured := profile.Default().Agents().All()
	result := make([]agentview.Snapshot, 0, len(configured))
	for _, item := range configured {
		result = append(result, agentview.Build(item, agentview.BuildContext{}))
	}
	return result, nil
}
