package dto

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

// Bundle / aggregate DTOs returned by /api/internal/bundles/*.
// These responses compose existing per-resource responses so that the
// dashboard UI can render a full page with a single HTTP request.

type (
	// AgentsBundleResponse is returned by GET /bundles/agents and combines the
	// agent list needed by AgentsPage. Active sessions remain on /sessions.
	AgentsBundleResponse struct {
		Agents []agentview.Snapshot `json:"agents"`
	}

	// ServersBundleResponse is returned by GET /bundles/servers and combines
	// AgentTeam server configuration + agents + 12h/24h window summaries so the
	// dashboard can render server lists, agent-binding UI, and per-row in/out
	// message stats from one request.
	ServersBundleResponse struct {
		Servers          []ServerResponse     `json:"servers"`
		Agents           []agentview.Snapshot `json:"agents"`
		WindowSummary12h any                  `json:"windowSummary12h"`
		WindowSummary1d  any                  `json:"windowSummary1d"`
	}

	// RuntimesBundleResponse is returned by GET /bundles/runtimes and
	// combines runtime status, agents, and a fresh PATH detection pass.
	RuntimesBundleResponse struct {
		Summary  RuntimeBundleSummary    `json:"summary"`
		Runtimes []RuntimeBundleItem     `json:"runtimes"`
		Agents   []RuntimeAgentItem      `json:"agents"`
		Detected []DetectRuntimeResponse `json:"detected"`
	}

	// SettingsBundleResponse is returned by GET /bundles/settings and
	// combines config + system info in one response.
	SettingsBundleResponse struct {
		Settings   SettingsResponse `json:"settings"`
		SystemInfo any              `json:"systemInfo"`
	}

	// HomeBundleResponse is returned by GET /bundles/home and combines the
	// HomePage-critical data: overview + system info + aggregate counts +
	// server message/llm time-series for the current window.
	HomeBundleResponse struct {
		Overview                   OverviewResponse `json:"overview"`
		SystemInfo                 any              `json:"systemInfo"`
		Counts                     HomeCounts       `json:"counts"`
		LLMSummary                 any              `json:"llmSummary"`
		LLMTimeSeries              any              `json:"llmTimeseries"`
		LLMModelTimeSeries         any              `json:"llmModelTimeseries"`
		LLMInputTokenBar           any              `json:"llmInputTokenBar"`
		LLMCachedTokenBar          any              `json:"llmCachedTokenBar"`
		LLMOutputTokenBar          any              `json:"llmOutputTokenBar"`
		ServerMessageDirectional   any              `json:"serverMessageDirectional"`
		ServerMessageBar           any              `json:"serverMessageBar"`
		ServerMessageWindowSummary any              `json:"serverMessageWindowSummary"`
	}

	// AgentStatsBundleResponse is returned by GET /bundles/agents/:agentId/stats
	// and combines the read-only AgentDetailPage charts for one selected
	// agent/window into one request. Mutations and lazy workspace/activity
	// details intentionally stay on their dedicated endpoints.
	AgentStatsBundleResponse struct {
		MessageSummary any `json:"messageSummary"`
		MessageTrend   any `json:"messageTrend"`
		MessageBar     any `json:"messageBar"`
		TokenSummary   any `json:"tokenSummary"`
		TokenTrend     any `json:"tokenTrend"`
		InputTokenBar  any `json:"inputTokenBar"`
		CachedTokenBar any `json:"cachedTokenBar"`
		OutputTokenBar any `json:"outputTokenBar"`
	}

	// HomeCounts carries aggregate counts the HomePage previously obtained
	// by fetching full lists and reading .length on the client.
	HomeCounts struct {
		Skills int `json:"skills"`
	}
)
