package dto

import "github.com/tidbcloud/AgentTeam/desktop/internal/metrics"

// DesktopCurrentMachineBindingRequest scopes local Machine setup to the
// Workspace currently rendered by the Desktop UI.
type DesktopCurrentMachineBindingRequest struct {
	WorkspaceID       string `json:"workspaceId" binding:"required"`
	ReplaceUnresolved bool   `json:"replaceUnresolved,omitempty"`
}

// DesktopRestoreMachineBindingRequest reconnects the current Desktop to an
// existing server-side Machine record.
type DesktopRestoreMachineBindingRequest struct {
	WorkspaceID string `json:"workspaceId" binding:"required"`
	MachineID   string `json:"machineId" binding:"required"`
}

// DesktopCurrentMachineBindingResponse reports only non-secret setup state.
type DesktopCurrentMachineBindingResponse struct {
	MachineID string `json:"machineId,omitempty"`
	Status    string `json:"status"`
}

// DesktopMachineDashboardResponse is the machine-scoped statistics contract
// consumed only by the Desktop Machine page. It contains no credentials.
type DesktopMachineDashboardResponse struct {
	MachineID      string                                             `json:"machineId"`
	WorkspaceID    string                                             `json:"workspaceId"`
	Window         string                                             `json:"window"`
	AgentCount     int                                                `json:"agentCount"`
	ActiveAgents   int                                                `json:"activeAgents"`
	MessageSummary metrics.AgentMessageSummary                        `json:"messageSummary"`
	MessageTrend   metrics.ServerMessageDirectionalTimeSeriesResponse `json:"messageTrend"`
	MessageBar     metrics.BarSeriesResponse                          `json:"messageBar"`
	TokenSummary   metrics.AgentTokenSummary                          `json:"tokenSummary"`
	TokenTrend     metrics.AgentTokenTimeSeriesResponse               `json:"tokenTrend"`
	InputTokenBar  metrics.BarSeriesResponse                          `json:"inputTokenBar"`
	CachedTokenBar metrics.BarSeriesResponse                          `json:"cachedTokenBar"`
	OutputTokenBar metrics.BarSeriesResponse                          `json:"outputTokenBar"`
	TokenSources   metrics.TokenSourceResult                          `json:"tokenSources"`
	Agents         []DesktopMachineDashboardAgent                     `json:"agents"`
}

type DesktopMachineDashboardAgent struct {
	AgentID  string `json:"agentId"`
	Name     string `json:"name"`
	Runtime  string `json:"runtime"`
	Active   bool   `json:"active"`
	Received uint64 `json:"received"`
	Sent     uint64 `json:"sent"`
	Input    uint64 `json:"input"`
	Cached   uint64 `json:"cached"`
	Output   uint64 `json:"output"`
	Total    uint64 `json:"total"`
}
