import { NextResponse } from "next/server";
import { syncModels } from "@/lib/adminrpc/client";

export const runtime = "nodejs";

/**
 * Trigger AI model sync via adminrpc gRPC.
 */
export async function POST() {
  try {
    const data = await syncModels();
    return NextResponse.json(data);
  } catch (e) {
    const msg = e instanceof Error ? e.message : String(e);
    console.error("AI sync error:", msg);
    return NextResponse.json({ error: `同步失败: ${msg}` }, { status: 500 });
  }
}
