import { listAgentRuns } from '@/lib/delegation.js';

export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';

export async function GET(req) {
  const { searchParams } = new URL(req.url);
  return Response.json({
    runs: listAgentRuns({
      limit: Number(searchParams.get('limit') || 100),
      task_id: searchParams.get('task_id') || undefined,
      agent_id: searchParams.get('agent_id') || undefined,
      status: searchParams.get('status') || undefined,
    }),
  });
}
