import { NextResponse } from "next/server";
import { getAuthFromRequest } from "@open-mercato/shared/lib/auth/server";
import { handleOpenCodeHealth } from "../../lib/opencode-handlers.js";
const openApi = {
  tag: "AI Assistant",
  summary: "AI assistant health check",
  methods: {
    GET: { summary: "Check OpenCode and MCP connection status" }
  }
};
const metadata = {
  GET: { requireAuth: true, requireFeatures: ["ai_assistant.view"] }
};
async function GET(req) {
  const auth = await getAuthFromRequest(req);
  if (!auth?.sub) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }
  try {
    const health = await handleOpenCodeHealth();
    return NextResponse.json(health);
  } catch (error) {
    console.error("[AI Health] Error:", error);
    return NextResponse.json(
      { error: "Failed to check health", message: error instanceof Error ? error.message : "Unknown error" },
      { status: 500 }
    );
  }
}
export {
  GET,
  metadata,
  openApi
};
//# sourceMappingURL=route.js.map
