Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

934 B
Raw Blame
/**
 * GET /api/jobs/:id/runs
 *
 * Return run history for a single job (newest-first). LOCAL_ONLY.
 * Next 16 async params: `const { id } = await params`.
 */
import { NextResponse } from "next/server";

import { buildErrorBody } from "@omniroute/open-sse/utils/error.ts";
import { getJobRegistry } from "@/lib/jobRegistry";

export const dynamic = "force-dynamic";

export async function GET(_request: Request, { params }: { params: Promise<{ id: string }> }) {
  try {
    const { id } = await params;
    const registry = getJobRegistry();
    if (!registry.listJobs().some((j) => j.id === id)) {
      return NextResponse.json(buildErrorBody(404, "Job not found"), { status: 404 });
    }
    return NextResponse.json({ data: registry.getRuns(id) });
  } catch (err) {
    console.error("[API] GET /api/jobs/:id/runs error:", err);
    return NextResponse.json(buildErrorBody(500, "Failed to load runs"), { status: 500 });
  }
}