route.ts 574 B

123456789101112131415
  1. import { NextResponse } from "next/server";
  2. import { loadAgentFeed } from "@/lib/agent-monitor";
  3. import { AgentStatus } from "@/types/agent";
  4. function isAgentStatus(value: string | null): value is AgentStatus {
  5. return value === "working" || value === "idle" || value === "warning" || value === "offline";
  6. }
  7. export async function GET(request: Request) {
  8. const { searchParams } = new URL(request.url);
  9. const status = searchParams.get("status");
  10. const feed = await loadAgentFeed(status && isAgentStatus(status) ? status : "all");
  11. return NextResponse.json(feed);
  12. }