AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(platform): bot analytics admin page + read API (#13326)
Bentlyfebd477f0082
diff --git a/autogpt_platform/backend/backend/api/features/admin/bot_analytics_routes.py b/autogpt_platform/backend/backend/api/features/admin/bot_analytics_routes.pynew file mode 100644index 0000000000..5c3fd922ae--- /dev/null+++ b/autogpt_platform/backend/backend/api/features/admin/bot_analytics_routes.py@@ -0,0 +1,107 @@+"""Admin read API for bot usage analytics.++All endpoints are admin-gated (router-level ``requires_admin_user``) and+read-only. They surface aggregate counts, server presence and performance+metrics for every live bot — never message content or user identity (the+underlying schema stores neither).+"""++import logging++from autogpt_libs.auth import requires_admin_user+from fastapi import APIRouter, Query, Security++from backend.data.bot_analytics_reads import (+ BotAnalyticsSummary,+ BotCommandUsage,+ BotGuildInfo,+ BotServerActivity,+ BotServerCountPoint,+ BotTimeseriesPoint,+ get_bot_analytics_summary,+ get_bot_command_usage,+ get_bot_message_timeseries,+ get_bot_server_timeseries,+ get_bot_top_servers,+ list_bot_guilds,+)+from backend.platform_linking.models import Platform++logger = logging.getLogger(__name__)+++router = APIRouter(+ prefix="/bot-analytics",+ tags=["bot-analytics"],+ dependencies=[Security(requires_admin_user)],+)+++def _platform_value(platform: Platform | None) -> str | None:+ return platform.value if platform else None++[email protected]("/summary", response_model=BotAnalyticsSummary, summary="Bot Usage Summary")+async def bot_summary(+ platform: Platform | None = Query(None),+ days: int = Query(30, ge=1, le=365),+) -> BotAnalyticsSummary:+ return await get_bot_analytics_summary(_platform_value(platform), days)+++ "/timeseries",+ response_model=list[BotTimeseriesPoint],+ summary="Bot Message Timeseries",+)+async def bot_timeseries(+ platform: Platform | None = Query(None),+ days: int = Query(30, ge=1, le=365),+) -> list[BotTimeseriesPoint]:+ return await get_bot_message_timeseries(_platform_value(platform), days)+++ "/server-timeseries",+ response_model=list[BotServerCountPoint],+ summary="Bot Server-Count Timeseries (sharding curve)",+)+async def bot_server_timeseries(+ platform: Platform | None = Query(None),+ days: int = Query(30, ge=1, le=365),+) -> list[BotServerCountPoint]:+ return await get_bot_server_timeseries(_platform_value(platform), days)+++ "/top-servers",+ response_model=list[BotServerActivity],+ summary="Top Servers by Activity",+)+async def bot_top_servers(+ platform: Platform | None = Query(None),+ days: int = Query(30, ge=1, le=365),+ limit: int = Query(20, ge=1, le=100),+) -> list[BotServerActivity]:+ return await get_bot_top_servers(_platform_value(platform), days, limit)+++ "/command-usage",+ response_model=list[BotCommandUsage],+ summary="Command Usage Breakdown",+)+async def bot_command_usage(+ platform: Platform | None = Query(None),+ days: int = Query(30, ge=1, le=365),+) -> list[BotCommandUsage]:+ return await get_bot_command_usage(_platform_value(platform), days)++[email protected]("/guilds", response_model=list[BotGuildInfo], summary="Bot Server Roster")+async def bot_guilds(+ platform: Platform | None = Query(None),+ include_left: bool = Query(False),+ limit: int = Query(500, ge=1, le=2000),+) -> list[BotGuildInfo]:+ return await list_bot_guilds(_platform_value(platform), include_left, limit)diff --git a/autogpt_platform/backend/backend/api/features/admin/bot_analytics_routes_test.py b/autogpt_platform/backend/backend/api/features/admin/bot_analytics_routes_test.pynew file mode 100644index 0000000000..c1af6000bf--- /dev/null+++ b/autogpt_platform/backend/backend/api/features/admin/bot_analytics_routes_test.py@@ -0,0 +1,111 @@+from datetime import datetime, timezone+from unittest.mock import AsyncMock++import fastapi+import fastapi.testclient+import pytest++from backend.api.features.admin import bot_analytics_routes+from backend.data.bot_analytics_reads import (+ BotAnalyticsSummary,+ BotCommandUsage,+ BotGuildInfo,+ BotTimeseriesPoint,+)++app = fastapi.FastAPI()+app.include_router(bot_analytics_routes.router, prefix="/api/admin")+client = fastapi.testclient.TestClient(app)++[email protected](autouse=True)+def setup_app_auth(mock_jwt_admin):+ from autogpt_libs.auth.jwt_utils import get_jwt_payload++ app.dependency_overrides[get_jwt_payload] = mock_jwt_admin["get_jwt_payload"]+ yield+ app.dependency_overrides.clear()+++def test_summary_returns_metrics(mocker):+ mock_summary = AsyncMock(+ return_value=BotAnalyticsSummary(+ platform="DISCORD",+ window_days=30,+ live_servers=5,+ messages_received=100,+ replies_sent=90,+ commands_used=10,+ stream_errors=2,+ avg_reply_ms=1200.0,+ error_rate=0.02,+ )+ )+ mocker.patch.object(bot_analytics_routes, "get_bot_analytics_summary", mock_summary)+ resp = client.get("/api/admin/bot-analytics/summary?platform=DISCORD&days=30")+ assert resp.status_code == 200+ data = resp.json()+ assert data["live_servers"] == 5+ assert data["messages_received"] == 100+ assert data["error_rate"] == 0.02+ mock_summary.assert_awaited_once_with("DISCORD", 30)+++def test_timeseries_returns_list(mocker):+ mock_timeseries = AsyncMock(+ return_value=[+ BotTimeseriesPoint(+ date=datetime(2026, 6, 1, tzinfo=timezone.utc),+ messages=10,+ replies=9,+ errors=1,+ )+ ]+ )+ mocker.patch.object(+ bot_analytics_routes, "get_bot_message_timeseries", mock_timeseries+ )+ resp = client.get("/api/admin/bot-analytics/timeseries?days=7")+ assert resp.status_code == 200+ body = resp.json()+ assert len(body) == 1+ assert body[0]["messages"] == 10+ mock_timeseries.assert_awaited_once_with(None, 7)+++def test_command_usage_and_guilds(mocker):+ mock_commands = AsyncMock(return_value=[BotCommandUsage(command="setup", uses=3)])+ mock_guilds = AsyncMock(+ return_value=[+ BotGuildInfo(+ platform="DISCORD",+ server_id="9",+ name="Srv",+ joined_at=datetime(2026, 5, 1, tzinfo=timezone.utc),+ left_at=None,+ active=True,+ )+ ]+ )+ mocker.patch.object(bot_analytics_routes, "get_bot_command_usage", mock_commands)+ mocker.patch.object(bot_analytics_routes, "list_bot_guilds", mock_guilds)++ cmd = client.get("/api/admin/bot-analytics/command-usage")+ assert cmd.status_code == 200+ assert cmd.json()[0]["command"] == "setup"+ mock_commands.assert_awaited_once_with(None, 30)++ guilds = client.get("/api/admin/bot-analytics/guilds")+ assert guilds.status_code == 200+ assert guilds.json()[0]["active"] is True+ mock_guilds.assert_awaited_once_with(None, False, 500)+++def test_days_out_of_range_rejected():+ resp = client.get("/api/admin/bot-analytics/summary?days=9999")+ assert resp.status_code == 422+++def test_invalid_platform_rejected():+ resp = client.get("/api/admin/bot-analytics/summary?platform=MYSPACE")+ assert resp.status_code == 422diff --git a/autogpt_platform/backend/backend/api/rest_api.py b/autogpt_platform/backend/backend/api/rest_api.pyindex fe49047271..9afd323c33 100644--- a/autogpt_platform/backend/backend/api/rest_api.py+++ b/autogpt_platform/backend/backend/api/rest_api.py@@ -17,6 +17,7 @@ from fastapi.routing import APIRoutefrom prisma.errors import PrismaErrorimport backend.api.features.admin.block_cost_admin_routes+import backend.api.features.admin.bot_analytics_routesimport backend.api.features.admin.credit_admin_routesimport backend.api.features.admin.diagnostics_admin_routesimport backend.api.features.admin.execution_analytics_routes@@ -367,6 +368,11 @@ app.include_router(tags=["v2", "admin"],prefix="/api/admin",)+app.include_router(+ backend.api.features.admin.bot_analytics_routes.router,+ tags=["v2", "admin"],+ prefix="/api/admin",+)app.include_router(backend.api.features.admin.block_cost_admin_routes.router,tags=["v2", "admin"],diff --git a/autogpt_platform/backend/backend/data/bot_analytics_reads.py b/autogpt_platform/backend/backend/data/bot_analytics_reads.pynew file mode 100644index 0000000000..eb1d8307c4--- /dev/null+++ b/autogpt_platform/backend/backend/data/bot_analytics_reads.py@@ -0,0 +1,290 @@+"""Bot analytics read/aggregate queries for the admin dashboard.++Read-only counterpart to ``bot_analytics`` (writes). Runs in-process against+Prisma via ``query_raw_with_schema`` — the same direct-call pattern as+``platform_cost`` — so the admin REST routes call these without RPC.++Privacy: these queries only ever aggregate counts, durations and server-level+rows. There is no message content or user identity anywhere in the schema.+"""++import logging+from datetime import datetime, timedelta, timezone++from pydantic import BaseModel, Field++from backend.data.db import query_raw_with_schema++logger = logging.getLogger(__name__)+++class BotAnalyticsSummary(BaseModel):+ platform: str | None+ window_days: int+ live_servers: int = Field(+ description=(+ "Current count of servers the bot is in right now. "+ "Point-in-time gauge — intentionally ignores window_days. "+ "Use the server-count timeseries endpoint for the windowed growth curve."+ ),+ )+ messages_received: int+ replies_sent: int+ commands_used: int+ stream_errors: int+ avg_reply_ms: float | None+ error_rate: float+++class BotTimeseriesPoint(BaseModel):+ date: datetime+ messages: int+ replies: int+ errors: int+++class BotServerCountPoint(BaseModel):+ date: datetime+ server_count: int+++class BotServerActivity(BaseModel):+ server_id: str+ name: str | None+ messages: int+ commands: int+++class BotCommandUsage(BaseModel):+ command: str+ uses: int+++class BotGuildInfo(BaseModel):+ platform: str+ server_id: str+ name: str | None+ joined_at: datetime+ left_at: datetime | None+ active: bool+++def _since(days: int) -> datetime:+ return datetime.now(timezone.utc) - timedelta(days=days)+++def _platform_filter(platform: str | None, params: list, *, alias: str = "") -> str:+ """Append a platform value to ``params`` and return a SQL fragment."""+ if not platform:+ return ""+ params.append(platform)+ col = f'{alias}"platform"' if alias else '"platform"'+ return f"AND {col}::text = ${len(params)}"+++async def get_bot_analytics_summary(+ platform: str | None = None, days: int = 30+) -> BotAnalyticsSummary:+ event_params: list = [_since(days)]+ event_filter = _platform_filter(platform, event_params)+ event_rows = await query_raw_with_schema(+ f"""+ SELECT+ count(*) FILTER (WHERE "eventType" = 'message_received') AS messages,+ count(*) FILTER (WHERE "eventType" = 'reply_sent') AS replies,+ count(*) FILTER (WHERE "eventType" = 'command_used') AS commands,+ count(*) FILTER (WHERE "eventType" = 'stream_error') AS errors,+ avg("durationMs") FILTER (WHERE "eventType" = 'reply_sent') AS avg_reply_ms+ FROM {{schema_prefix}}"BotEvent"+ WHERE "createdAt" >= $1::timestamptz {event_filter}+ """,+ *event_params,+ )+ row = event_rows[0] if event_rows else {}++ guild_params: list = []+ guild_filter = _platform_filter(platform, guild_params)+ guild_rows = await query_raw_with_schema(+ f"""+ SELECT count(*) AS live+ FROM {{schema_prefix}}"BotGuild"+ WHERE "leftAt" IS NULL {guild_filter}+ """,+ *guild_params,+ )++ messages = int(row.get("messages") or 0)+ errors = int(row.get("errors") or 0)+ avg_reply_ms = row.get("avg_reply_ms")+ return BotAnalyticsSummary(+ platform=platform,+ window_days=days,+ live_servers=int(guild_rows[0]["live"]) if guild_rows else 0,+ messages_received=messages,+ replies_sent=int(row.get("replies") or 0),+ commands_used=int(row.get("commands") or 0),+ stream_errors=errors,+ avg_reply_ms=float(avg_reply_ms) if avg_reply_ms is not None else None,+ error_rate=(errors / messages) if messages else 0.0,+ )+++async def get_bot_message_timeseries(+ platform: str | None = None, days: int = 30+) -> list[BotTimeseriesPoint]:+ params: list = [_since(days)]+ platform_filter = _platform_filter(platform, params)+ # date_trunc on a timestamptz uses the session's time zone by default —+ # convert to UTC explicitly via AT TIME ZONE so days are bucketed by UTC+ # regardless of the connection's TZ (mirrors platform_cost's pattern).+ rows = await query_raw_with_schema(+ f"""+ SELECT+ date_trunc('day', "createdAt" AT TIME ZONE 'UTC') AT TIME ZONE 'UTC' AS day,+ count(*) FILTER (WHERE "eventType" = 'message_received') AS messages,+ count(*) FILTER (WHERE "eventType" = 'reply_sent') AS replies,+ count(*) FILTER (WHERE "eventType" = 'stream_error') AS errors+ FROM {{schema_prefix}}"BotEvent"+ WHERE "createdAt" >= $1::timestamptz {platform_filter}+ GROUP BY day+ ORDER BY day+ """,+ *params,+ )+ return [+ BotTimeseriesPoint(+ date=row["day"],+ messages=int(row["messages"]),+ replies=int(row["replies"]),+ errors=int(row["errors"]),+ )+ for row in rows+ ]+++async def get_bot_server_timeseries(+ platform: str | None = None, days: int = 30+) -> list[BotServerCountPoint]:+ """Cumulative live-server count at the end of each day — the curve to watch+ against the sharding threshold."""+ params: list = [days]+ joined_filter = _platform_filter(platform, params, alias="g.")+ left_filter = joined_filter # same param ($2) reused in both subqueries+ # The BotGuild.joinedAt / leftAt columns are `timestamp` (no tz) storing+ # naive UTC values (Prisma's default for DateTime). `now() AT TIME ZONE 'utc'`+ # also produces a naive UTC `timestamp`, so date_trunc here uses neither the+ # session TZ nor any implicit cast — comparisons stay naive-to-naive and the+ # daily buckets line up with UTC days regardless of session TZ.+ rows = await query_raw_with_schema(+ f"""+ SELECT+ d.day,+ (+ SELECT count(*) FROM {{schema_prefix}}"BotGuild" g+ WHERE g."joinedAt" < d.day + interval '1 day' {joined_filter}+ ) - (+ SELECT count(*) FROM {{schema_prefix}}"BotGuild" g+ WHERE g."leftAt" IS NOT NULL+ AND g."leftAt" < d.day + interval '1 day' {left_filter}+ ) AS server_count+ FROM generate_series(+ date_trunc('day', now() AT TIME ZONE 'utc') - ($1::int - 1) * interval '1 day',+ date_trunc('day', now() AT TIME ZONE 'utc'),+ interval '1 day'+ ) AS d(day)+ ORDER BY d.day+ """,+ *params,+ )+ return [+ BotServerCountPoint(+ date=row["day"], server_count=max(0, int(row["server_count"]))+ )+ for row in rows+ ]+++async def get_bot_top_servers(+ platform: str | None = None, days: int = 30, limit: int = 20+) -> list[BotServerActivity]:+ params: list = [_since(days)]+ platform_filter = _platform_filter(platform, params, alias="e.")+ params.append(limit)+ rows = await query_raw_with_schema(+ f"""+ SELECT+ e."serverId" AS server_id,+ g."name" AS name,+ count(*) FILTER (WHERE e."eventType" = 'message_received') AS messages,+ count(*) FILTER (WHERE e."eventType" = 'command_used') AS commands+ FROM {{schema_prefix}}"BotEvent" e+ LEFT JOIN {{schema_prefix}}"BotGuild" g+ ON g."serverId" = e."serverId" AND g."platform" = e."platform"+ WHERE e."createdAt" >= $1::timestamptz AND e."serverId" IS NOT NULL {platform_filter}+ GROUP BY e."serverId", g."name"+ ORDER BY messages DESC+ LIMIT ${len(params)}::int+ """,+ *params,+ )+ return [+ BotServerActivity(+ server_id=row["server_id"],+ name=row["name"],+ messages=int(row["messages"]),+ commands=int(row["commands"]),+ )+ for row in rows+ ]+++async def get_bot_command_usage(+ platform: str | None = None, days: int = 30+) -> list[BotCommandUsage]:+ params: list = [_since(days)]+ platform_filter = _platform_filter(platform, params)+ rows = await query_raw_with_schema(+ f"""+ SELECT "commandName" AS command, count(*) AS uses+ FROM {{schema_prefix}}"BotEvent"+ WHERE "eventType" = 'command_used'+ AND "commandName" IS NOT NULL+ AND "createdAt" >= $1::timestamptz {platform_filter}+ GROUP BY "commandName"+ ORDER BY uses DESC+ """,+ *params,+ )+ return [+ BotCommandUsage(command=row["command"], uses=int(row["uses"])) for row in rows+ ]+++async def list_bot_guilds(+ platform: str | None = None, include_left: bool = False, limit: int = 500+) -> list[BotGuildInfo]:+ params: list = []+ platform_filter = _platform_filter(platform, params)+ active_filter = "" if include_left else 'AND "leftAt" IS NULL'+ params.append(limit)+ rows = await query_raw_with_schema(+ f"""+ SELECT "platform", "serverId" AS server_id, "name", "joinedAt", "leftAt"+ FROM {{schema_prefix}}"BotGuild"+ WHERE 1 = 1 {platform_filter} {active_filter}+ ORDER BY ("leftAt" IS NULL) DESC, "joinedAt" DESC+ LIMIT ${len(params)}::int+ """,+ *params,+ )+ return [+ BotGuildInfo(+ platform=row["platform"],+ server_id=row["server_id"],+ name=row["name"],+ joined_at=row["joinedAt"],+ left_at=row["leftAt"],+ active=row["leftAt"] is None,+ )+ for row in rows+ ]diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/__tests__/main.test.tsxnew file mode 100644index 0000000000..4271249329--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/__tests__/main.test.tsx@@ -0,0 +1,77 @@+import { describe, expect, it } from "vitest";++import {+ getGetV2BotMessageTimeseriesMockHandler200,+ getGetV2BotServerCountTimeseriesShardingCurveMockHandler200,+ getGetV2BotServerRosterMockHandler200,+ getGetV2BotUsageSummaryMockHandler200,+ getGetV2CommandUsageBreakdownMockHandler200,+ getGetV2TopServersByActivityMockHandler200,+} from "@/app/api/__generated__/endpoints/admin/admin.msw";+import { server } from "@/mocks/mock-server";+import { render, screen } from "@/tests/integrations/test-utils";++import { BotsContent } from "../components/BotsContent";++function mockAllEndpoints() {+ server.use(+ getGetV2BotUsageSummaryMockHandler200({+ platform: "DISCORD",+ window_days: 30,+ live_servers: 42,+ messages_received: 1000,+ replies_sent: 950,+ commands_used: 30,+ stream_errors: 5,+ avg_reply_ms: 1500,+ error_rate: 0.005,+ }),+ getGetV2BotMessageTimeseriesMockHandler200([+ {+ date: new Date("2026-06-01T00:00:00Z"),+ messages: 10,+ replies: 9,+ errors: 1,+ },+ ]),+ getGetV2BotServerCountTimeseriesShardingCurveMockHandler200([+ { date: new Date("2026-06-01T00:00:00Z"), server_count: 42 },+ ]),+ getGetV2TopServersByActivityMockHandler200([+ { server_id: "1", name: "Cool Guild", messages: 500, commands: 10 },+ ]),+ getGetV2CommandUsageBreakdownMockHandler200([+ { command: "setup", uses: 12 },+ ]),+ getGetV2BotServerRosterMockHandler200([+ {+ platform: "DISCORD",+ server_id: "1",+ name: "Cool Guild",+ joined_at: new Date("2026-05-01T00:00:00Z"),+ left_at: null,+ active: true,+ },+ ]),+ );+}++describe("BotsContent", () => {+ it("renders the live server count and headline metrics", async () => {+ mockAllEndpoints();+ render(<BotsContent />);++ expect(await screen.findByText("Live servers")).toBeDefined();+ expect(await screen.findByText("42")).toBeDefined();+ expect(await screen.findByText("0.5%")).toBeDefined();+ });++ it("renders server activity, command usage and roster rows", async () => {+ mockAllEndpoints();+ render(<BotsContent />);++ expect(await screen.findAllByText("Cool Guild")).toHaveLength(2);+ expect(await screen.findByText("/setup")).toBeDefined();+ expect(await screen.findByText("Active")).toBeDefined();+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/BotsContent.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/BotsContent.tsxnew file mode 100644index 0000000000..569178eba7--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/BotsContent.tsx@@ -0,0 +1,147 @@+"use client";++import { Card } from "@/components/atoms/Card/Card";+import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";+import { Select } from "@/components/atoms/Select/Select";+import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";++import { MessageVolumeChart } from "./MessageVolumeChart";+import { ServerGrowthChart } from "./ServerGrowthChart";+import { SimpleTable } from "./SimpleTable";+import { SummaryCard } from "./SummaryCard";+import { useBotsContent } from "./useBotsContent";+import {+ DAYS_OPTIONS,+ formatDate,+ formatDuration,+ formatNumber,+ formatPercent,+ PLATFORM_OPTIONS,+} from "./helpers";++export function BotsContent() {+ const state = useBotsContent();+ const { summary } = state;++ const tiles = [+ { label: "Live servers", value: formatNumber(summary?.live_servers) },+ {+ label: "Messages received",+ value: formatNumber(summary?.messages_received),+ },+ { label: "Replies sent", value: formatNumber(summary?.replies_sent) },+ { label: "Commands used", value: formatNumber(summary?.commands_used) },+ {+ label: "Error rate",+ value: formatPercent(summary?.error_rate),+ subtitle: `${formatNumber(summary?.stream_errors)} stream errors`,+ },+ {+ label: "Avg reply time",+ value: formatDuration(summary?.avg_reply_ms),+ },+ ];++ return (+ <div className="flex flex-col gap-6">+ <div className="flex flex-wrap gap-3">+ <Select+ id="platform-filter"+ label="Platform"+ hideLabel+ value={state.platform}+ onValueChange={state.setPlatform}+ options={PLATFORM_OPTIONS}+ size="small"+ />+ <Select+ id="days-filter"+ label="Range"+ hideLabel+ value={String(state.days)}+ onValueChange={(value) => state.setDays(Number(value))}+ options={DAYS_OPTIONS}+ size="small"+ />+ </div>++ {state.isError ? (+ <ErrorCard+ httpError={{+ message:+ state.error instanceof Error+ ? state.error.message+ : "Failed to load bot analytics",+ }}+ context="bot analytics"+ hint="Make sure the backend is running the latest build and try again."+ />+ ) : state.isLoading ? (+ <div className="grid grid-cols-2 gap-4 md:grid-cols-3">+ {Array.from({ length: 6 }).map((_, index) => (+ <Skeleton key={index} className="h-24 rounded-lg" />+ ))}+ </div>+ ) : (+ <>+ <div className="grid grid-cols-2 gap-4 md:grid-cols-3">+ {tiles.map((tile) => (+ <SummaryCard key={tile.label} {...tile} />+ ))}+ </div>++ <Card>+ <h2 className="mb-4 text-xl font-semibold">+ Server growth & sharding outlook+ </h2>+ <ServerGrowthChart data={state.servers} />+ </Card>++ <Card>+ <h2 className="mb-4 text-xl font-semibold">Message volume</h2>+ <MessageVolumeChart data={state.messages} />+ </Card>++ <Card>+ <h2 className="mb-4 text-xl font-semibold">+ Top servers by activity+ </h2>+ <SimpleTable+ columns={["Server", "Messages", "Commands"]}+ rows={state.topServers.map((server) => [+ server.name || server.server_id,+ formatNumber(server.messages),+ formatNumber(server.commands),+ ])}+ />+ </Card>++ <div className="grid gap-6 lg:grid-cols-2">+ <Card>+ <h2 className="mb-4 text-xl font-semibold">Command usage</h2>+ <SimpleTable+ columns={["Command", "Uses"]}+ rows={state.commands.map((command) => [+ `/${command.command}`,+ formatNumber(command.uses),+ ])}+ />+ </Card>++ <Card>+ <h2 className="mb-4 text-xl font-semibold">Server roster</h2>+ <SimpleTable+ columns={["Server", "Status", "Joined"]}+ rows={state.roster.map((guild) => [+ guild.name || guild.server_id,+ guild.active ? "Active" : "Left",+ formatDate(guild.joined_at),+ ])}+ />+ </Card>+ </div>+ </>+ )}+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/MessageVolumeChart.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/MessageVolumeChart.tsxnew file mode 100644index 0000000000..3df1c3e830--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/MessageVolumeChart.tsx@@ -0,0 +1,63 @@+import {+ CartesianGrid,+ Legend,+ Line,+ LineChart,+ ResponsiveContainer,+ Tooltip,+ XAxis,+ YAxis,+} from "recharts";++import type { BotTimeseriesPoint } from "@/app/api/__generated__/models/botTimeseriesPoint";++import { formatDay } from "./helpers";++interface Props {+ data: BotTimeseriesPoint[];+}++export function MessageVolumeChart({ data }: Props) {+ const chartData = data.map((point) => ({+ date: formatDay(point.date),+ Messages: point.messages,+ Replies: point.replies,+ Errors: point.errors,+ }));++ return (+ <ResponsiveContainer width="100%" height={320}>+ <LineChart+ data={chartData}+ margin={{ top: 8, right: 24, left: 0, bottom: 0 }}+ >+ <CartesianGrid strokeDasharray="3 3" />+ <XAxis dataKey="date" fontSize={12} />+ <YAxis allowDecimals={false} fontSize={12} />+ <Tooltip />+ <Legend />+ <Line+ type="monotone"+ dataKey="Messages"+ stroke="#6366f1"+ strokeWidth={2}+ dot={false}+ />+ <Line+ type="monotone"+ dataKey="Replies"+ stroke="#10b981"+ strokeWidth={2}+ dot={false}+ />+ <Line+ type="monotone"+ dataKey="Errors"+ stroke="#ef4444"+ strokeWidth={2}+ dot={false}+ />+ </LineChart>+ </ResponsiveContainer>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/ServerGrowthChart.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/ServerGrowthChart.tsxnew file mode 100644index 0000000000..4fc1fc5a62--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/ServerGrowthChart.tsx@@ -0,0 +1,78 @@+import {+ Area,+ AreaChart,+ CartesianGrid,+ ReferenceLine,+ ResponsiveContainer,+ Tooltip,+ XAxis,+ YAxis,+} from "recharts";++import type { BotServerCountPoint } from "@/app/api/__generated__/models/botServerCountPoint";++import { formatDay, formatNumber, SHARDING_THRESHOLD } from "./helpers";++interface Props {+ data: BotServerCountPoint[];+}++export function ServerGrowthChart({ data }: Props) {+ const chartData = data.map((point) => ({+ date: formatDay(point.date),+ Servers: point.server_count,+ }));+ const peak = data.reduce(+ (max, point) => Math.max(max, point.server_count),+ 0,+ );+ // Only fold the (far-off) sharding threshold into the Y-axis once we're+ // actually approaching it — otherwise a handful of servers would render as a+ // flat line pinned to the bottom of a 0–2500 axis.+ const nearThreshold = peak > SHARDING_THRESHOLD * 0.4;++ return (+ <div>+ <ResponsiveContainer width="100%" height={320}>+ <AreaChart+ data={chartData}+ margin={{ top: 8, right: 24, left: 0, bottom: 0 }}+ >+ <defs>+ <linearGradient id="serverFill" x1="0" y1="0" x2="0" y2="1">+ <stop offset="5%" stopColor="#6366f1" stopOpacity={0.3} />+ <stop offset="95%" stopColor="#6366f1" stopOpacity={0} />+ </linearGradient>+ </defs>+ <CartesianGrid strokeDasharray="3 3" />+ <XAxis dataKey="date" fontSize={12} />+ <YAxis+ allowDecimals={false}+ fontSize={12}+ domain={nearThreshold ? [0, SHARDING_THRESHOLD] : undefined}+ />+ <Tooltip />+ {nearThreshold && (+ <ReferenceLine+ y={SHARDING_THRESHOLD}+ stroke="#ef4444"+ strokeDasharray="4 4"+ label="Sharding threshold"+ />+ )}+ <Area+ type="monotone"+ dataKey="Servers"+ stroke="#6366f1"+ strokeWidth={2}+ fill="url(#serverFill)"+ />+ </AreaChart>+ </ResponsiveContainer>+ <p className="mt-2 text-xs text-muted-foreground">+ Sharding threshold: {formatNumber(SHARDING_THRESHOLD)} servers · current+ peak in range: {formatNumber(peak)}+ </p>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/SimpleTable.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/SimpleTable.tsxnew file mode 100644index 0000000000..52a6820ee2--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/SimpleTable.tsx@@ -0,0 +1,48 @@+import type { ReactNode } from "react";++interface Props {+ columns: string[];+ rows: ReactNode[][];+ emptyLabel?: string;+}++export function SimpleTable({+ columns,+ rows,+ emptyLabel = "No data yet",+}: Props) {+ if (rows.length === 0) {+ return (+ <p className="py-6 text-center text-sm text-muted-foreground">+ {emptyLabel}+ </p>+ );+ }++ return (+ <div className="overflow-x-auto">+ <table className="w-full text-sm">+ <thead>+ <tr className="border-b text-left text-muted-foreground">+ {columns.map((column, columnIndex) => (+ <th key={columnIndex} className="px-3 py-2 font-medium">+ {column}+ </th>+ ))}+ </tr>+ </thead>+ <tbody>+ {rows.map((row, rowIndex) => (+ <tr key={rowIndex} className="border-b last:border-0">+ {row.map((cell, cellIndex) => (+ <td key={cellIndex} className="px-3 py-2">+ {cell}+ </td>+ ))}+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/SummaryCard.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/SummaryCard.tsxnew file mode 100644index 0000000000..f3d2e49649--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/SummaryCard.tsx@@ -0,0 +1,17 @@+interface Props {+ label: string;+ value: string;+ subtitle?: string;+}++export function SummaryCard({ label, value, subtitle }: Props) {+ return (+ <div className="rounded-lg border p-4">+ <div className="text-sm text-muted-foreground">{label}</div>+ <div className="text-2xl font-bold">{value}</div>+ {subtitle && (+ <div className="mt-1 text-xs text-muted-foreground">{subtitle}</div>+ )}+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/helpers.tsnew file mode 100644index 0000000000..993015cd0a--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/helpers.ts@@ -0,0 +1,44 @@+export const SHARDING_THRESHOLD = 2500;++export const DAYS_OPTIONS = [+ { value: "7", label: "Last 7 days" },+ { value: "30", label: "Last 30 days" },+ { value: "90", label: "Last 90 days" },+];++export const PLATFORM_OPTIONS = [+ { value: "all", label: "All platforms" },+ { value: "DISCORD", label: "Discord" },+];++export function formatNumber(value: number | null | undefined): string {+ if (value == null) return "—";+ return value.toLocaleString();+}++export function formatDuration(ms: number | null | undefined): string {+ if (ms == null) return "—";+ if (ms < 1000) return `${Math.round(ms)}ms`;+ return `${(ms / 1000).toFixed(1)}s`;+}++export function formatPercent(rate: number | null | undefined): string {+ if (rate == null) return "—";+ return `${(rate * 100).toFixed(1)}%`;+}++export function formatDay(value: string | Date): string {+ return new Date(value).toLocaleDateString(undefined, {+ month: "short",+ day: "numeric",+ });+}++export function formatDate(value: string | Date | null | undefined): string {+ if (!value) return "—";+ return new Date(value).toLocaleDateString(undefined, {+ year: "numeric",+ month: "short",+ day: "numeric",+ });+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/useBotsContent.ts b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/useBotsContent.tsnew file mode 100644index 0000000000..526c0a0c9c--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/components/useBotsContent.ts@@ -0,0 +1,81 @@+"use client";++import { useState } from "react";++import {+ useGetV2BotMessageTimeseries,+ useGetV2BotServerCountTimeseriesShardingCurve,+ useGetV2BotServerRoster,+ useGetV2BotUsageSummary,+ useGetV2CommandUsageBreakdown,+ useGetV2TopServersByActivity,+} from "@/app/api/__generated__/endpoints/admin/admin";+import type { Platform } from "@/app/api/__generated__/models/platform";+import { okData } from "@/app/api/helpers";++export function useBotsContent() {+ const [days, setDays] = useState(30);+ const [platform, setPlatform] = useState("all");++ const platformParam = platform === "all" ? undefined : (platform as Platform);+ const windowParams = {+ days,+ ...(platformParam && { platform: platformParam }),+ };++ // NOTE: the `select: okData` option must be inlined per call — hoisting it to+ // a shared const collapses okData's generic to `any` and loses response types.+ const summary = useGetV2BotUsageSummary(windowParams, {+ query: { select: okData },+ });+ const messages = useGetV2BotMessageTimeseries(windowParams, {+ query: { select: okData },+ });+ const servers = useGetV2BotServerCountTimeseriesShardingCurve(windowParams, {+ query: { select: okData },+ });+ const topServers = useGetV2TopServersByActivity(windowParams, {+ query: { select: okData },+ });+ const commands = useGetV2CommandUsageBreakdown(windowParams, {+ query: { select: okData },+ });+ const roster = useGetV2BotServerRoster(+ platformParam ? { platform: platformParam } : {},+ { query: { select: okData } },+ );++ return {+ days,+ setDays,+ platform,+ setPlatform,+ summary: summary.data,+ messages: messages.data ?? [],+ servers: servers.data ?? [],+ topServers: topServers.data ?? [],+ commands: commands.data ?? [],+ roster: roster.data ?? [],+ isLoading:+ summary.isLoading ||+ messages.isLoading ||+ servers.isLoading ||+ topServers.isLoading ||+ commands.isLoading ||+ roster.isLoading,+ isError:+ summary.isError ||+ messages.isError ||+ servers.isError ||+ topServers.isError ||+ commands.isError ||+ roster.isError,+ error:+ summary.error ||+ messages.error ||+ servers.error ||+ topServers.error ||+ commands.error ||+ roster.error,+ };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/bots/page.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/bots/page.tsxnew file mode 100644index 0000000000..3b20d284c9--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/admin/bots/page.tsx@@ -0,0 +1,28 @@+import { withRoleAccess } from "@/lib/withRoleAccess";++import { BotsContent } from "./components/BotsContent";++function BotsDashboard() {+ return (+ <div className="mx-auto p-6">+ <div className="flex flex-col gap-4">+ <div>+ <h1 className="text-3xl font-bold">Bot Analytics</h1>+ <p className="text-muted-foreground">+ Usage, reach and reliability across every live AutoPilot bot. No+ message content or user identity is collected — only aggregate+ counts and metrics.+ </p>+ </div>++ <BotsContent />+ </div>+ </div>+ );+}++export default async function BotsPage() {+ const withAdminAccess = await withRoleAccess(["admin"]);+ const ProtectedDashboard = await withAdminAccess(BotsDashboard);+ return <ProtectedDashboard />;+}diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/layout.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/layout.tsxindex a3afdd7568..4a458e0ef5 100644--- a/autogpt_platform/frontend/src/app/(platform)/admin/layout.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/admin/layout.tsx@@ -8,6 +8,7 @@ import {FileText,Heartbeat,CalculatorIcon,+ RobotIcon,} from "@phosphor-icons/react/dist/ssr";import { IconSliders } from "@/components/__legacy__/ui/icons";@@ -50,6 +51,11 @@ const sidebarLinkGroups = [href: "/admin/execution-analytics",icon: <FileText className="h-6 w-6" />,},+ {+ text: "Bot Analytics",+ href: "/admin/bots",+ icon: <RobotIcon className="h-6 w-6" />,+ },{text: "Block Cost Estimates",href: "/admin/block-cost-estimates",diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.jsonindex 317721536b..33ee854079 100644--- a/autogpt_platform/frontend/src/app/api/openapi.json+++ b/autogpt_platform/frontend/src/app/api/openapi.json@@ -82,6 +82,382 @@}}},+ "/api/admin/bot-analytics/command-usage": {+ "get": {+ "tags": ["v2", "admin", "bot-analytics"],+ "summary": "Command Usage Breakdown",+ "operationId": "getV2Command usage breakdown",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "platform",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/Platform" },+ { "type": "null" }+ ],+ "title": "Platform"+ }+ },+ {+ "name": "days",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 365,+ "minimum": 1,+ "default": 30,+ "title": "Days"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": { "$ref": "#/components/schemas/BotCommandUsage" },+ "title": "Response Getv2Command Usage Breakdown"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },+ "/api/admin/bot-analytics/guilds": {+ "get": {+ "tags": ["v2", "admin", "bot-analytics"],+ "summary": "Bot Server Roster",+ "operationId": "getV2Bot server roster",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "platform",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/Platform" },+ { "type": "null" }+ ],+ "title": "Platform"+ }+ },+ {+ "name": "include_left",+ "in": "query",+ "required": false,+ "schema": {+ "type": "boolean",+ "default": false,+ "title": "Include Left"+ }+ },+ {+ "name": "limit",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 2000,+ "minimum": 1,+ "default": 500,+ "title": "Limit"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": { "$ref": "#/components/schemas/BotGuildInfo" },+ "title": "Response Getv2Bot Server Roster"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },+ "/api/admin/bot-analytics/server-timeseries": {+ "get": {+ "tags": ["v2", "admin", "bot-analytics"],+ "summary": "Bot Server-Count Timeseries (sharding curve)",+ "operationId": "getV2Bot server-count timeseries (sharding curve)",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "platform",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/Platform" },+ { "type": "null" }+ ],+ "title": "Platform"+ }+ },+ {+ "name": "days",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 365,+ "minimum": 1,+ "default": 30,+ "title": "Days"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/BotServerCountPoint"+ },+ "title": "Response Getv2Bot Server-Count Timeseries (Sharding Curve)"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },+ "/api/admin/bot-analytics/summary": {+ "get": {+ "tags": ["v2", "admin", "bot-analytics"],+ "summary": "Bot Usage Summary",+ "operationId": "getV2Bot usage summary",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "platform",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/Platform" },+ { "type": "null" }+ ],+ "title": "Platform"+ }+ },+ {+ "name": "days",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 365,+ "minimum": 1,+ "default": 30,+ "title": "Days"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/BotAnalyticsSummary" }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },+ "/api/admin/bot-analytics/timeseries": {+ "get": {+ "tags": ["v2", "admin", "bot-analytics"],+ "summary": "Bot Message Timeseries",+ "operationId": "getV2Bot message timeseries",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "platform",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/Platform" },+ { "type": "null" }+ ],+ "title": "Platform"+ }+ },+ {+ "name": "days",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 365,+ "minimum": 1,+ "default": 30,+ "title": "Days"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/BotTimeseriesPoint"+ },+ "title": "Response Getv2Bot Message Timeseries"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },+ "/api/admin/bot-analytics/top-servers": {+ "get": {+ "tags": ["v2", "admin", "bot-analytics"],+ "summary": "Top Servers by Activity",+ "operationId": "getV2Top servers by activity",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "platform",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/Platform" },+ { "type": "null" }+ ],+ "title": "Platform"+ }+ },+ {+ "name": "days",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 365,+ "minimum": 1,+ "default": 30,+ "title": "Days"+ }+ },+ {+ "name": "limit",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 100,+ "minimum": 1,+ "default": 20,+ "title": "Limit"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": { "$ref": "#/components/schemas/BotServerActivity" },+ "title": "Response Getv2Top Servers By Activity"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },"/api/admin/diagnostics/agents": {"get": {"tags": ["v2", "admin", "diagnostics", "admin"],@@ -11518,6 +11894,87 @@"required": ["file"],"title": "Body_uploadWorkspaceFile"},+ "BotAnalyticsSummary": {+ "properties": {+ "platform": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Platform"+ },+ "window_days": { "type": "integer", "title": "Window Days" },+ "live_servers": {+ "type": "integer",+ "title": "Live Servers",+ "description": "Current count of servers the bot is in right now. Point-in-time gauge — intentionally ignores window_days. Use the server-count timeseries endpoint for the windowed growth curve."+ },+ "messages_received": {+ "type": "integer",+ "title": "Messages Received"+ },+ "replies_sent": { "type": "integer", "title": "Replies Sent" },+ "commands_used": { "type": "integer", "title": "Commands Used" },+ "stream_errors": { "type": "integer", "title": "Stream Errors" },+ "avg_reply_ms": {+ "anyOf": [{ "type": "number" }, { "type": "null" }],+ "title": "Avg Reply Ms"+ },+ "error_rate": { "type": "number", "title": "Error Rate" }+ },+ "type": "object",+ "required": [+ "platform",+ "window_days",+ "live_servers",+ "messages_received",+ "replies_sent",+ "commands_used",+ "stream_errors",+ "avg_reply_ms",+ "error_rate"+ ],+ "title": "BotAnalyticsSummary"+ },+ "BotCommandUsage": {+ "properties": {+ "command": { "type": "string", "title": "Command" },+ "uses": { "type": "integer", "title": "Uses" }+ },+ "type": "object",+ "required": ["command", "uses"],+ "title": "BotCommandUsage"+ },+ "BotGuildInfo": {+ "properties": {+ "platform": { "type": "string", "title": "Platform" },+ "server_id": { "type": "string", "title": "Server Id" },+ "name": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Name"+ },+ "joined_at": {+ "type": "string",+ "format": "date-time",+ "title": "Joined At"+ },+ "left_at": {+ "anyOf": [+ { "type": "string", "format": "date-time" },+ { "type": "null" }+ ],+ "title": "Left At"+ },+ "active": { "type": "boolean", "title": "Active" }+ },+ "type": "object",+ "required": [+ "platform",+ "server_id",+ "name",+ "joined_at",+ "left_at",+ "active"+ ],+ "title": "BotGuildInfo"+ },"BotPlatformInfo": {"properties": {"platform": { "type": "string", "title": "Platform" },@@ -11544,6 +12001,40 @@"title": "BotPlatformInfo","description": "A bot platform enabled on this deployment plus the caller's links to it.\n\nPlatforms whose adapter isn't configured (missing token/credentials) are\nomitted from the response entirely — the Bots settings page hides them."},+ "BotServerActivity": {+ "properties": {+ "server_id": { "type": "string", "title": "Server Id" },+ "name": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Name"+ },+ "messages": { "type": "integer", "title": "Messages" },+ "commands": { "type": "integer", "title": "Commands" }+ },+ "type": "object",+ "required": ["server_id", "name", "messages", "commands"],+ "title": "BotServerActivity"+ },+ "BotServerCountPoint": {+ "properties": {+ "date": { "type": "string", "format": "date-time", "title": "Date" },+ "server_count": { "type": "integer", "title": "Server Count" }+ },+ "type": "object",+ "required": ["date", "server_count"],+ "title": "BotServerCountPoint"+ },+ "BotTimeseriesPoint": {+ "properties": {+ "date": { "type": "string", "format": "date-time", "title": "Date" },+ "messages": { "type": "integer", "title": "Messages" },+ "replies": { "type": "integer", "title": "Replies" },+ "errors": { "type": "integer", "title": "Errors" }+ },+ "type": "object",+ "required": ["date", "messages", "replies", "errors"],+ "title": "BotTimeseriesPoint"+ },"BulkMoveAgentsRequest": {"properties": {"agent_ids": {@@ -15531,6 +16022,20 @@"title": "PickerTokenResponse","description": "Short-lived OAuth access token shipped to the browser for rendering a\nprovider-hosted picker UI (e.g. Google Drive Picker). Deliberately narrow:\nonly the fields the client needs to initialize the picker widget. Issued\nfrom the user's own stored credential so ownership and scope gating are\nenforced by the credential lookup."},+ "Platform": {+ "type": "string",+ "enum": [+ "DISCORD",+ "TELEGRAM",+ "SLACK",+ "TEAMS",+ "WHATSAPP",+ "GITHUB",+ "LINEAR"+ ],+ "title": "Platform",+ "description": "Mirror of the Prisma PlatformType enum."+ },"PlatformCostDashboard": {"properties": {"by_provider": {