- Analytics: <Analytics /> in root layout loads umami when NEXT_PUBLIC_UMAMI_* env are set - Subscription: free/pro tiers in Postgres, daily quotas (10msg/5tool free, 1000/500 pro) - Chat route: checkAndConsume(chat_message) gate before streamText, 429 when exhausted - Tool metering: getWeather wrapped with withLimit decorator that deducts tool_call quota - Pricing page at /pricing with upgrade button - /api/billing/checkout posts to EGBE payment gateway, /api/billing/webhook verifies HMAC and upgrades user on checkout.session.completed - UsageBadge in chat header polls /api/usage every 15s - Dropped now-unused entitlements.ts
90 lines
2.4 KiB
TypeScript
90 lines
2.4 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { Geist, Geist_Mono } from "next/font/google";
|
|
import { Analytics } from "@/components/analytics";
|
|
import { ThemeProvider } from "@/components/theme-provider";
|
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
|
|
import "./globals.css";
|
|
import { SessionProvider } from "next-auth/react";
|
|
|
|
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL ?? "http://localhost:3000";
|
|
|
|
export const metadata: Metadata = {
|
|
metadataBase: new URL(baseUrl),
|
|
title: "EGBE Chatbot",
|
|
description: "Chatbot template wired to EGBE LiteLLM proxy.",
|
|
};
|
|
|
|
export const viewport = {
|
|
maximumScale: 1,
|
|
};
|
|
|
|
const geist = Geist({
|
|
subsets: ["latin"],
|
|
display: "swap",
|
|
variable: "--font-geist",
|
|
});
|
|
|
|
const geistMono = Geist_Mono({
|
|
subsets: ["latin"],
|
|
display: "swap",
|
|
variable: "--font-geist-mono",
|
|
});
|
|
|
|
const LIGHT_THEME_COLOR = "hsl(0 0% 100%)";
|
|
const DARK_THEME_COLOR = "hsl(240deg 10% 3.92%)";
|
|
const THEME_COLOR_SCRIPT = `\
|
|
(function() {
|
|
var html = document.documentElement;
|
|
var meta = document.querySelector('meta[name="theme-color"]');
|
|
if (!meta) {
|
|
meta = document.createElement('meta');
|
|
meta.setAttribute('name', 'theme-color');
|
|
document.head.appendChild(meta);
|
|
}
|
|
function updateThemeColor() {
|
|
var isDark = html.classList.contains('dark');
|
|
meta.setAttribute('content', isDark ? '${DARK_THEME_COLOR}' : '${LIGHT_THEME_COLOR}');
|
|
}
|
|
var observer = new MutationObserver(updateThemeColor);
|
|
observer.observe(html, { attributes: true, attributeFilter: ['class'] });
|
|
updateThemeColor();
|
|
})();`;
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: Readonly<{
|
|
children: React.ReactNode;
|
|
}>) {
|
|
return (
|
|
<html
|
|
className={`${geist.variable} ${geistMono.variable}`}
|
|
lang="en"
|
|
suppressHydrationWarning
|
|
>
|
|
<head>
|
|
<script
|
|
// biome-ignore lint/security/noDangerouslySetInnerHtml: "Required"
|
|
dangerouslySetInnerHTML={{
|
|
__html: THEME_COLOR_SCRIPT,
|
|
}}
|
|
/>
|
|
<Analytics />
|
|
</head>
|
|
<body className="antialiased">
|
|
<ThemeProvider
|
|
attribute="class"
|
|
defaultTheme="system"
|
|
disableTransitionOnChange
|
|
enableSystem
|
|
>
|
|
<SessionProvider
|
|
basePath={`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/auth`}
|
|
>
|
|
<TooltipProvider>{children}</TooltipProvider>
|
|
</SessionProvider>
|
|
</ThemeProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|