aigetwey 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dashboard/.next/BUILD_ID +1 -1
- package/dashboard/.next/build-manifest.json +3 -3
- package/dashboard/.next/diagnostics/route-bundle-stats.json +4 -4
- package/dashboard/.next/fallback-build-manifest.json +3 -3
- package/dashboard/.next/server/app/(console)/providers/[id]/page_client-reference-manifest.js +1 -1
- package/dashboard/.next/server/app/(console)/providers/page_client-reference-manifest.js +1 -1
- package/dashboard/.next/server/app/_global-error.html +1 -1
- package/dashboard/.next/server/app/_global-error.rsc +1 -1
- package/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/_not-found.html +1 -1
- package/dashboard/.next/server/app/_not-found.rsc +1 -1
- package/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/combos.html +1 -1
- package/dashboard/.next/server/app/combos.rsc +1 -1
- package/dashboard/.next/server/app/combos.segments/!KGNvbnNvbGUp/combos/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/combos.segments/!KGNvbnNvbGUp/combos.segment.rsc +1 -1
- package/dashboard/.next/server/app/combos.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/combos.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/combos.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/combos.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/combos.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/config.html +1 -1
- package/dashboard/.next/server/app/config.rsc +1 -1
- package/dashboard/.next/server/app/config.segments/!KGNvbnNvbGUp/config/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/config.segments/!KGNvbnNvbGUp/config.segment.rsc +1 -1
- package/dashboard/.next/server/app/config.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/config.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/config.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/config.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/config.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/console.html +1 -1
- package/dashboard/.next/server/app/console.rsc +1 -1
- package/dashboard/.next/server/app/console.segments/!KGNvbnNvbGUp/console/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/console.segments/!KGNvbnNvbGUp/console.segment.rsc +1 -1
- package/dashboard/.next/server/app/console.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/console.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/console.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/console.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/console.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.html +1 -1
- package/dashboard/.next/server/app/endpoint.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.segments/!KGNvbnNvbGUp/endpoint/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.segments/!KGNvbnNvbGUp/endpoint.segment.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/endpoint.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/index.html +1 -1
- package/dashboard/.next/server/app/index.rsc +1 -1
- package/dashboard/.next/server/app/index.segments/!KGNvbnNvbGUp/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/index.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/keys.html +1 -1
- package/dashboard/.next/server/app/keys.rsc +1 -1
- package/dashboard/.next/server/app/keys.segments/!KGNvbnNvbGUp/keys/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/keys.segments/!KGNvbnNvbGUp/keys.segment.rsc +1 -1
- package/dashboard/.next/server/app/keys.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/keys.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/keys.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/keys.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/keys.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/login.html +1 -1
- package/dashboard/.next/server/app/login.rsc +1 -1
- package/dashboard/.next/server/app/login.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/login.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/dashboard/.next/server/app/providers.html +1 -1
- package/dashboard/.next/server/app/providers.rsc +2 -2
- package/dashboard/.next/server/app/providers.segments/!KGNvbnNvbGUp/providers/__PAGE__.segment.rsc +2 -2
- package/dashboard/.next/server/app/providers.segments/!KGNvbnNvbGUp/providers.segment.rsc +1 -1
- package/dashboard/.next/server/app/providers.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/providers.segments/_full.segment.rsc +2 -2
- package/dashboard/.next/server/app/providers.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/providers.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/providers.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/quota.html +1 -1
- package/dashboard/.next/server/app/quota.rsc +1 -1
- package/dashboard/.next/server/app/quota.segments/!KGNvbnNvbGUp/quota/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/quota.segments/!KGNvbnNvbGUp/quota.segment.rsc +1 -1
- package/dashboard/.next/server/app/quota.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/quota.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/quota.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/quota.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/quota.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/app/tools.html +1 -1
- package/dashboard/.next/server/app/tools.rsc +1 -1
- package/dashboard/.next/server/app/tools.segments/!KGNvbnNvbGUp/tools/__PAGE__.segment.rsc +1 -1
- package/dashboard/.next/server/app/tools.segments/!KGNvbnNvbGUp/tools.segment.rsc +1 -1
- package/dashboard/.next/server/app/tools.segments/!KGNvbnNvbGUp.segment.rsc +1 -1
- package/dashboard/.next/server/app/tools.segments/_full.segment.rsc +1 -1
- package/dashboard/.next/server/app/tools.segments/_head.segment.rsc +1 -1
- package/dashboard/.next/server/app/tools.segments/_index.segment.rsc +1 -1
- package/dashboard/.next/server/app/tools.segments/_tree.segment.rsc +1 -1
- package/dashboard/.next/server/chunks/[root-of-the-server]__07euc03._.js.map +1 -1
- package/dashboard/.next/server/chunks/[root-of-the-server]__0uqpr_c._.js.map +1 -1
- package/dashboard/.next/server/chunks/ssr/_0p90gyy._.js.map +1 -1
- package/dashboard/.next/server/chunks/ssr/_1mumvwn._.js.map +1 -1
- package/dashboard/.next/server/chunks/ssr/src_components_ProviderDetail_tsx_06sxu0r._.js +1 -1
- package/dashboard/.next/server/chunks/ssr/src_components_ProviderDetail_tsx_06sxu0r._.js.map +1 -1
- package/dashboard/.next/server/chunks/ssr/src_components_ProviderManager_tsx_09d2dzw._.js +1 -1
- package/dashboard/.next/server/chunks/ssr/src_components_ProviderManager_tsx_09d2dzw._.js.map +1 -1
- package/dashboard/.next/server/middleware-build-manifest.js +3 -3
- package/dashboard/.next/server/pages/404.html +1 -1
- package/dashboard/.next/server/pages/500.html +1 -1
- package/dashboard/.next/static/chunks/{0pf-u__m67vld.js → 03xhjt1ta90pp.js} +1 -1
- package/dashboard/.next/static/chunks/{3y0b8yet0vgwr.js → 15d148buj9byd.js} +1 -1
- package/dashboard/.next/trace +1 -1
- package/dashboard/.next/trace-build +1 -1
- package/dashboard/src/components/ProviderDetail.tsx +10 -5
- package/dashboard/src/components/ProviderManager.tsx +7 -3
- package/dashboard/src/lib/client.ts +1 -0
- package/dashboard/src/lib/gateway.ts +2 -1
- package/dist/cli.js +10 -4
- package/dist/cli.js.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/headroom/process.js +22 -6
- package/dist/headroom/process.js.map +1 -1
- package/dist/routes/admin.js +1 -0
- package/dist/routes/admin.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +8 -4
- package/src/config.ts +2 -0
- package/src/headroom/process.ts +19 -5
- package/src/routes/admin.ts +2 -0
- /package/dashboard/.next/static/{WxqdtupTIrBh47rvaXxLB → jKcczqYA93-Kuqa9A9H9h}/_buildManifest.js +0 -0
- /package/dashboard/.next/static/{WxqdtupTIrBh47rvaXxLB → jKcczqYA93-Kuqa9A9H9h}/_clientMiddlewareManifest.js +0 -0
- /package/dashboard/.next/static/{WxqdtupTIrBh47rvaXxLB → jKcczqYA93-Kuqa9A9H9h}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/gateway.ts","../../../src/app/api/password/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import \"server-only\";\nimport { currentPassword } from \"./session\";\n\n/**\n * Server-side proxy to the gateway admin API. Runs only in Next.js server\n * context (route handlers / server components) — injects the admin password as\n * a Bearer token so it never reaches the browser.\n *\n * Scoped to the admin surface the gateway exposes today (usage, logs, providers,\n * budgets, whole-config CRUD). Granular provider/combo mutation helpers are added\n * alongside the pages that drive them in phase 11.\n */\nfunction gatewayUrl(): string {\n return (process.env.GATEWAY_URL ?? \"http://127.0.0.1:18080\").replace(/\\/$/, \"\");\n}\n\nexport interface GatewayResult<T> {\n ok: boolean;\n status: number;\n data: T | null;\n error?: string;\n}\n\nasync function call<T>(method: string, path: string, body?: unknown): Promise<GatewayResult<T>> {\n let res: Response;\n try {\n res = await fetch(gatewayUrl() + path, {\n method,\n headers: {\n authorization: `Bearer ${await currentPassword()}`,\n ...(body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n cache: \"no-store\",\n });\n } catch (e) {\n return { ok: false, status: 0, data: null, error: `gateway unreachable: ${(e as Error).message}` };\n }\n\n const text = await res.text();\n let data: T | null = null;\n try {\n data = text ? (JSON.parse(text) as T) : null;\n } catch {\n data = null;\n }\n if (!res.ok) {\n const err = (data as { error?: string } | null)?.error ?? `gateway returned ${res.status}`;\n return { ok: false, status: res.status, data, error: err };\n }\n return { ok: true, status: res.status, data };\n}\n\n/** Verify a specific admin password against the gateway (used at login, before a\n * session cookie exists). */\nexport async function checkGatewayAuth(password: string): Promise<boolean> {\n try {\n const res = await fetch(gatewayUrl() + \"/admin/providers\", {\n headers: { authorization: `Bearer ${password}` },\n cache: \"no-store\",\n });\n return res.ok;\n } catch {\n return false;\n }\n}\n\nexport const gateway = {\n providers: () => call<{ providers: ProviderSnapshot[] }>(\"GET\", \"/admin/providers\"),\n budgets: () => call<{ budgets: BudgetStatus[] }>(\"GET\", \"/admin/budgets\"),\n models: () => call<ModelsPayload>(\"GET\", \"/admin/models\"),\n logs: (limit = 100) => call<{ logs: UsageLog[] }>(\"GET\", `/admin/logs?limit=${limit}`),\n usage: (since = 0) => call<UsageSummary>(\"GET\", `/admin/usage?since=${since}`),\n usageSeries: (since: number, bucket: number) =>\n call<{ series: UsageSeriesPoint[] }>(\"GET\", `/admin/usage/series?since=${since}&bucket=${bucket}`),\n config: () => call<MaskedConfig>(\"GET\", \"/admin/config\"),\n putConfig: (text: string) => call<{ ok: boolean; config: MaskedConfig }>(\"PUT\", \"/admin/config\", { text }),\n changePassword: (current: string, next: string) =>\n call<{ ok: boolean }>(\"PUT\", \"/admin/password\", { current, next }),\n\n // ---- provider mutations (reply carries the fresh masked config) ----\n addProvider: (p: {\n id: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n free?: boolean;\n auto_models?: boolean;\n service_account?: string;\n }) => call<ConfigReply>(\"POST\", \"/admin/providers\", p),\n editProvider: (id: string, patch: { base_url?: string; format?: WireFormat }) =>\n call<ConfigReply>(\"PUT\", `/admin/providers/${encodeURIComponent(id)}`, patch),\n removeProvider: (id: string) => call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}`),\n addKey: (id: string, key: string) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/keys`, { key }),\n removeKey: (id: string, index: number) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/keys/${index}`),\n addProviderModel: (id: string, model: string, price?: { price_in?: number; price_out?: number }) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { model, ...price }),\n addProviderModels: (id: string, models: string[]) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { models }),\n removeProviderModel: (id: string, model: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models/${encodeURIComponent(model)}`),\n clearProviderModels: (id: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models`),\n testProvider: (id: string) => call<PingResult>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/test`),\n discoverModels: (id: string) =>\n call<{ ok: boolean; models: Array<{ id: string; added: boolean }> }>(\n \"POST\",\n `/admin/providers/${encodeURIComponent(id)}/connect`,\n ),\n\n // ---- combos: alias + ordered provider chain + strategy ----\n setRoute: (\n alias: string,\n body: { target: string[]; model?: string | string[]; strategy?: \"fallback\" | \"round-robin\"; price_in?: number; price_out?: number },\n ) => call<ConfigReply>(\"PUT\", `/admin/routes/${encodeURIComponent(alias)}`, body),\n removeRoute: (alias: string) => call<ConfigReply>(\"DELETE\", `/admin/routes/${encodeURIComponent(alias)}`),\n\n // ---- endpoint: toggles + gateway keys ----\n endpoint: () => call<EndpointPayload>(\"GET\", \"/admin/endpoint\"),\n setRtk: (enabled: boolean) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/rtk\", { enabled }),\n setCaveman: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/caveman\", { level }),\n setPonytail: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/ponytail\", { level }),\n addServerKey: (key: string) => call<ConfigReply>(\"POST\", \"/admin/endpoint/keys\", { key }),\n removeServerKey: (index: number) => call<ConfigReply>(\"DELETE\", `/admin/endpoint/keys/${index}`),\n};\n\n// ---- shapes mirrored from the gateway admin API ----\n\nexport type WireFormat = \"openai\" | \"anthropic\" | \"gemini\";\nexport type InjectLevel = \"off\" | \"lite\" | \"full\" | \"ultra\";\n\nexport interface ConfigReply {\n ok: boolean;\n config: MaskedConfig;\n}\n\nexport interface MaskedRoute {\n alias: string;\n target: string[];\n model?: string | string[];\n strategy: \"fallback\" | \"round-robin\";\n price_in?: number;\n price_out?: number;\n}\nexport interface MaskedProvider {\n id: string;\n name?: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n api_keys?: string[];\n /** optional friendly label per key, keyed by the MASKED key string. */\n key_names?: Record<string, string>;\n free: boolean;\n auto_models: boolean;\n service_account?: string;\n models: Array<{ id: string; price_in?: number; price_out?: number }>;\n cooldown_base_ms: number;\n max_retries: number;\n disabled_keys?: number[];\n disabled?: boolean;\n strategy?: \"fallback\" | \"round-robin\";\n sticky?: number;\n}\nexport interface MaskedConfig {\n server: { host: string; port: number; api_keys: string[] };\n endpoint: { rtk: boolean; caveman: InjectLevel; ponytail: InjectLevel };\n providers: MaskedProvider[];\n models: MaskedRoute[];\n}\n\nexport interface EndpointPayload {\n port: number;\n rtk: boolean;\n caveman: InjectLevel;\n ponytail: InjectLevel;\n headroom: { enabled: boolean; url: string; compress_user_messages: boolean };\n keys: Array<{ key: string; fingerprint: string; name?: string; models?: string[]; rpm?: number; expires?: number }>;\n}\n\nexport interface KeyUsageRow {\n fingerprint: string;\n name: string;\n masked: string;\n expires?: number;\n spent: number;\n tokens: number;\n budget: {\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n reset_in_ms: number;\n exhausted: boolean;\n alert: boolean;\n } | null;\n}\n\nexport interface HeadroomStatusReply {\n installed: boolean;\n path: string | null;\n running: boolean;\n python: string | null;\n localUrl: boolean;\n canStart: boolean;\n url: string;\n managedPid: number | null;\n enabled: boolean;\n compress_user_messages: boolean;\n}\n\nexport interface PingResult {\n reachable: boolean;\n status?: number;\n ok: boolean;\n error?: string;\n}\n\nexport interface PricingModel {\n id: string;\n price_in: number | null;\n price_out: number | null;\n default_in: number | null;\n default_out: number | null;\n}\nexport interface PricingPayload {\n providers: Array<{ id: string; models: PricingModel[] }>;\n}\n\nexport interface ModelsPayload {\n providers: Array<{\n id: string;\n format: WireFormat;\n models: Array<{ id: string; ref: string; price_in?: number; price_out?: number }>;\n }>;\n routes: MaskedRoute[];\n}\n\nexport interface KeySnapshot {\n key: string;\n healthy: boolean;\n cooldown_ms: number;\n fail_count: number;\n last_error: { message: string; status?: number; at: number } | null;\n}\nexport interface ProviderSnapshot {\n id: string;\n format: WireFormat;\n keys: KeySnapshot[];\n}\nexport type BudgetScope =\n | { type: \"global\" }\n | { type: \"provider\"; id: string }\n | { type: \"model\"; id: string }\n | { type: \"key\"; id: string };\n\nexport interface BudgetStatus {\n scope: BudgetScope;\n key: string;\n label: string;\n note?: string;\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n alert: boolean;\n alert_at: number;\n exhausted: boolean;\n est_converse: number | null;\n reset_in_ms: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n}\nexport interface UsageLog {\n ts: number;\n alias: string;\n provider: string;\n model: string;\n tokens_in: number;\n tokens_out: number;\n reasoning_tokens: number;\n cached_tokens: number;\n cost: number;\n status: number;\n latency_ms: number;\n stream: number;\n}\nexport interface UsageSummary {\n total: { requests: number; tokens_in: number; tokens_out: number; cost: number };\n by_provider: Array<{ provider: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n by_model: Array<{ alias: string; model: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n}\nexport interface UsageSeriesPoint {\n ts: number;\n requests: number;\n tokens_in: number;\n tokens_out: number;\n cost: number;\n}\n","import { NextResponse } from \"next/server\";\nimport { cookies } from \"next/headers\";\nimport { sealSession, SESSION_COOKIE } from \"@/lib/session\";\nimport { gateway } from \"@/lib/gateway\";\n\n/**\n * Change the admin password. The gateway verifies the current password and\n * persists the new hash; on success we re-issue the session cookie carrying the\n * new password so this browser stays logged in (other sessions must re-login).\n */\nexport async function POST(req: Request): Promise<NextResponse> {\n const { current, next } = (await req.json().catch(() => ({}))) as { current?: string; next?: string };\n if (!current || !next) {\n return NextResponse.json({ error: \"current and next are required\" }, { status: 400 });\n }\n if (next.length < 4) {\n return NextResponse.json({ error: \"new password must be at least 4 characters\" }, { status: 400 });\n }\n\n const r = await gateway.changePassword(current, next);\n if (!r.ok) {\n return NextResponse.json({ error: r.error ?? \"could not change password\" }, { status: r.status || 400 });\n }\n\n const jar = await cookies();\n jar.set(SESSION_COOKIE, sealSession(next), {\n httpOnly: true,\n sameSite: \"lax\",\n secure: process.env.NODE_ENV === \"production\",\n path: \"/\",\n maxAge: 60 * 60 * 12,\n });\n return NextResponse.json({ ok: true });\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/password/route\",\n pathname: \"/api/password\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/password/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"INNER_APP_ROUTE\")\n } : {}\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/password/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId,\n deploymentId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":["gatewayUrl","process","env","GATEWAY_URL","replace","call","method","path","body","res","fetch","headers","authorization","undefined","JSON","stringify","cache","e","ok","status","data","error","message","text","parse","err","checkGatewayAuth","password","gateway","providers","budgets","models","logs","limit","usage","since","usageSeries","bucket","config","putConfig","changePassword","current","next","addProvider","p","editProvider","id","patch","encodeURIComponent","removeProvider","addKey","key","removeKey","index","addProviderModel","model","price","addProviderModels","removeProviderModel","clearProviderModels","testProvider","discoverModels","setRoute","alias","removeRoute","endpoint","setRtk","enabled","setCaveman","level","setPonytail","addServerKey","removeServerKey","POST","req","json","catch","length","r","jar","set","httpOnly","sameSite","secure","maxAge"],"mappings":"4jCACA,IAAA,EAAA,EAAA,CAAA,CAAA,OAWA,SAASA,IACP,MAAO,CAACC,QAAQC,GAAG,CAACC,WAAW,EAAI,wBAAA,CAAwB,CAAEC,OAAO,CAAC,MAAO,GAC9E,CASA,eAAeC,EAAQC,CAAc,CAAEC,CAAY,CAAEC,CAAc,MAC7DC,EACJ,GAAI,CACFA,EAAM,MAAMC,MAAMV,IAAeO,EAAM,QACrCD,EACAK,QAAS,CACPC,cAAe,CAAC,OAAO,EAAE,MAAM,CAAA,EAAA,EAAA,eAAA,AAAe,IAAA,CAAI,CAClD,QAAaC,IAATL,EAAqB,CAAE,eAAgB,kBAAmB,EAAI,CAAC,CAAC,AACtE,EACAA,UAAeK,IAATL,EAAqBM,KAAKC,SAAS,CAACP,QAAQK,EAClDG,MAAO,UACT,EACF,CAAE,MAAOC,EAAG,CACV,MAAO,CAAEC,IAAI,EAAOC,OAAQ,EAAGC,KAAM,KAAMC,MAAO,CAAC,qBAAqB,EAAGJ,EAAYK,OAAO,CAAA,CAAE,AAAC,CACnG,CAEA,IAAMC,EAAO,MAAMd,EAAIc,IAAI,GACvBH,EAAiB,KACrB,GAAI,CACFA,EAAOG,EAAQT,KAAKU,KAAK,CAACD,GAAc,IAC1C,CAAE,KAAM,CACNH,EAAO,IACT,CACA,GAAI,CAACX,EAAIS,EAAE,CAAE,CACX,IAAMO,EAAOL,GAAoCC,OAAS,CAAC,iBAAiB,EAAEZ,EAAIU,MAAM,CAAA,CAAE,CAC1F,MAAO,CAAED,IAAI,EAAOC,O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,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,QAAiB,EAAW,CAAC,GAE5C,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,EATmB,CAShB,EAAY,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAY,AAAZ,EAAa,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,mCA5TA,SAAS,EACL,MAAO,CAAA,EAAA,EAAA,UAAA,AAAW,EAAC,kBACf,uBACA,CACJ,EACJ","ignoreList":[2]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/gateway.ts","../../../src/app/api/password/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import \"server-only\";\nimport { currentPassword } from \"./session\";\n\n/**\n * Server-side proxy to the gateway admin API. Runs only in Next.js server\n * context (route handlers / server components) — injects the admin password as\n * a Bearer token so it never reaches the browser.\n *\n * Scoped to the admin surface the gateway exposes today (usage, logs, providers,\n * budgets, whole-config CRUD). Granular provider/combo mutation helpers are added\n * alongside the pages that drive them in phase 11.\n */\nfunction gatewayUrl(): string {\n return (process.env.GATEWAY_URL ?? \"http://127.0.0.1:18080\").replace(/\\/$/, \"\");\n}\n\nexport interface GatewayResult<T> {\n ok: boolean;\n status: number;\n data: T | null;\n error?: string;\n}\n\nasync function call<T>(method: string, path: string, body?: unknown): Promise<GatewayResult<T>> {\n let res: Response;\n try {\n res = await fetch(gatewayUrl() + path, {\n method,\n headers: {\n authorization: `Bearer ${await currentPassword()}`,\n ...(body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n cache: \"no-store\",\n });\n } catch (e) {\n return { ok: false, status: 0, data: null, error: `gateway unreachable: ${(e as Error).message}` };\n }\n\n const text = await res.text();\n let data: T | null = null;\n try {\n data = text ? (JSON.parse(text) as T) : null;\n } catch {\n data = null;\n }\n if (!res.ok) {\n const err = (data as { error?: string } | null)?.error ?? `gateway returned ${res.status}`;\n return { ok: false, status: res.status, data, error: err };\n }\n return { ok: true, status: res.status, data };\n}\n\n/** Verify a specific admin password against the gateway (used at login, before a\n * session cookie exists). */\nexport async function checkGatewayAuth(password: string): Promise<boolean> {\n try {\n const res = await fetch(gatewayUrl() + \"/admin/providers\", {\n headers: { authorization: `Bearer ${password}` },\n cache: \"no-store\",\n });\n return res.ok;\n } catch {\n return false;\n }\n}\n\nexport const gateway = {\n providers: () => call<{ providers: ProviderSnapshot[] }>(\"GET\", \"/admin/providers\"),\n budgets: () => call<{ budgets: BudgetStatus[] }>(\"GET\", \"/admin/budgets\"),\n models: () => call<ModelsPayload>(\"GET\", \"/admin/models\"),\n logs: (limit = 100) => call<{ logs: UsageLog[] }>(\"GET\", `/admin/logs?limit=${limit}`),\n usage: (since = 0) => call<UsageSummary>(\"GET\", `/admin/usage?since=${since}`),\n usageSeries: (since: number, bucket: number) =>\n call<{ series: UsageSeriesPoint[] }>(\"GET\", `/admin/usage/series?since=${since}&bucket=${bucket}`),\n config: () => call<MaskedConfig>(\"GET\", \"/admin/config\"),\n putConfig: (text: string) => call<{ ok: boolean; config: MaskedConfig }>(\"PUT\", \"/admin/config\", { text }),\n changePassword: (current: string, next: string) =>\n call<{ ok: boolean }>(\"PUT\", \"/admin/password\", { current, next }),\n\n // ---- provider mutations (reply carries the fresh masked config) ----\n addProvider: (p: {\n id: string;\n name?: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n free?: boolean;\n auto_models?: boolean;\n service_account?: string;\n }) => call<ConfigReply>(\"POST\", \"/admin/providers\", p),\n editProvider: (id: string, patch: { base_url?: string; format?: WireFormat; name?: string }) =>\n call<ConfigReply>(\"PUT\", `/admin/providers/${encodeURIComponent(id)}`, patch),\n removeProvider: (id: string) => call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}`),\n addKey: (id: string, key: string) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/keys`, { key }),\n removeKey: (id: string, index: number) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/keys/${index}`),\n addProviderModel: (id: string, model: string, price?: { price_in?: number; price_out?: number }) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { model, ...price }),\n addProviderModels: (id: string, models: string[]) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { models }),\n removeProviderModel: (id: string, model: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models/${encodeURIComponent(model)}`),\n clearProviderModels: (id: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models`),\n testProvider: (id: string) => call<PingResult>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/test`),\n discoverModels: (id: string) =>\n call<{ ok: boolean; models: Array<{ id: string; added: boolean }> }>(\n \"POST\",\n `/admin/providers/${encodeURIComponent(id)}/connect`,\n ),\n\n // ---- combos: alias + ordered provider chain + strategy ----\n setRoute: (\n alias: string,\n body: { target: string[]; model?: string | string[]; strategy?: \"fallback\" | \"round-robin\"; price_in?: number; price_out?: number },\n ) => call<ConfigReply>(\"PUT\", `/admin/routes/${encodeURIComponent(alias)}`, body),\n removeRoute: (alias: string) => call<ConfigReply>(\"DELETE\", `/admin/routes/${encodeURIComponent(alias)}`),\n\n // ---- endpoint: toggles + gateway keys ----\n endpoint: () => call<EndpointPayload>(\"GET\", \"/admin/endpoint\"),\n setRtk: (enabled: boolean) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/rtk\", { enabled }),\n setCaveman: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/caveman\", { level }),\n setPonytail: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/ponytail\", { level }),\n addServerKey: (key: string) => call<ConfigReply>(\"POST\", \"/admin/endpoint/keys\", { key }),\n removeServerKey: (index: number) => call<ConfigReply>(\"DELETE\", `/admin/endpoint/keys/${index}`),\n};\n\n// ---- shapes mirrored from the gateway admin API ----\n\nexport type WireFormat = \"openai\" | \"anthropic\" | \"gemini\";\nexport type InjectLevel = \"off\" | \"lite\" | \"full\" | \"ultra\";\n\nexport interface ConfigReply {\n ok: boolean;\n config: MaskedConfig;\n}\n\nexport interface MaskedRoute {\n alias: string;\n target: string[];\n model?: string | string[];\n strategy: \"fallback\" | \"round-robin\";\n price_in?: number;\n price_out?: number;\n}\nexport interface MaskedProvider {\n id: string;\n name?: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n api_keys?: string[];\n /** optional friendly label per key, keyed by the MASKED key string. */\n key_names?: Record<string, string>;\n free: boolean;\n auto_models: boolean;\n service_account?: string;\n models: Array<{ id: string; price_in?: number; price_out?: number }>;\n cooldown_base_ms: number;\n max_retries: number;\n disabled_keys?: number[];\n disabled?: boolean;\n strategy?: \"fallback\" | \"round-robin\";\n sticky?: number;\n}\nexport interface MaskedConfig {\n server: { host: string; port: number; api_keys: string[] };\n endpoint: { rtk: boolean; caveman: InjectLevel; ponytail: InjectLevel };\n providers: MaskedProvider[];\n models: MaskedRoute[];\n}\n\nexport interface EndpointPayload {\n port: number;\n rtk: boolean;\n caveman: InjectLevel;\n ponytail: InjectLevel;\n headroom: { enabled: boolean; url: string; compress_user_messages: boolean };\n keys: Array<{ key: string; fingerprint: string; name?: string; models?: string[]; rpm?: number; expires?: number }>;\n}\n\nexport interface KeyUsageRow {\n fingerprint: string;\n name: string;\n masked: string;\n expires?: number;\n spent: number;\n tokens: number;\n budget: {\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n reset_in_ms: number;\n exhausted: boolean;\n alert: boolean;\n } | null;\n}\n\nexport interface HeadroomStatusReply {\n installed: boolean;\n path: string | null;\n running: boolean;\n python: string | null;\n localUrl: boolean;\n canStart: boolean;\n url: string;\n managedPid: number | null;\n enabled: boolean;\n compress_user_messages: boolean;\n}\n\nexport interface PingResult {\n reachable: boolean;\n status?: number;\n ok: boolean;\n error?: string;\n}\n\nexport interface PricingModel {\n id: string;\n price_in: number | null;\n price_out: number | null;\n default_in: number | null;\n default_out: number | null;\n}\nexport interface PricingPayload {\n providers: Array<{ id: string; models: PricingModel[] }>;\n}\n\nexport interface ModelsPayload {\n providers: Array<{\n id: string;\n format: WireFormat;\n models: Array<{ id: string; ref: string; price_in?: number; price_out?: number }>;\n }>;\n routes: MaskedRoute[];\n}\n\nexport interface KeySnapshot {\n key: string;\n healthy: boolean;\n cooldown_ms: number;\n fail_count: number;\n last_error: { message: string; status?: number; at: number } | null;\n}\nexport interface ProviderSnapshot {\n id: string;\n format: WireFormat;\n keys: KeySnapshot[];\n}\nexport type BudgetScope =\n | { type: \"global\" }\n | { type: \"provider\"; id: string }\n | { type: \"model\"; id: string }\n | { type: \"key\"; id: string };\n\nexport interface BudgetStatus {\n scope: BudgetScope;\n key: string;\n label: string;\n note?: string;\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n alert: boolean;\n alert_at: number;\n exhausted: boolean;\n est_converse: number | null;\n reset_in_ms: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n}\nexport interface UsageLog {\n ts: number;\n alias: string;\n provider: string;\n model: string;\n tokens_in: number;\n tokens_out: number;\n reasoning_tokens: number;\n cached_tokens: number;\n cost: number;\n status: number;\n latency_ms: number;\n stream: number;\n}\nexport interface UsageSummary {\n total: { requests: number; tokens_in: number; tokens_out: number; cost: number };\n by_provider: Array<{ provider: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n by_model: Array<{ alias: string; model: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n}\nexport interface UsageSeriesPoint {\n ts: number;\n requests: number;\n tokens_in: number;\n tokens_out: number;\n cost: number;\n}\n","import { NextResponse } from \"next/server\";\nimport { cookies } from \"next/headers\";\nimport { sealSession, SESSION_COOKIE } from \"@/lib/session\";\nimport { gateway } from \"@/lib/gateway\";\n\n/**\n * Change the admin password. The gateway verifies the current password and\n * persists the new hash; on success we re-issue the session cookie carrying the\n * new password so this browser stays logged in (other sessions must re-login).\n */\nexport async function POST(req: Request): Promise<NextResponse> {\n const { current, next } = (await req.json().catch(() => ({}))) as { current?: string; next?: string };\n if (!current || !next) {\n return NextResponse.json({ error: \"current and next are required\" }, { status: 400 });\n }\n if (next.length < 4) {\n return NextResponse.json({ error: \"new password must be at least 4 characters\" }, { status: 400 });\n }\n\n const r = await gateway.changePassword(current, next);\n if (!r.ok) {\n return NextResponse.json({ error: r.error ?? \"could not change password\" }, { status: r.status || 400 });\n }\n\n const jar = await cookies();\n jar.set(SESSION_COOKIE, sealSession(next), {\n httpOnly: true,\n sameSite: \"lax\",\n secure: process.env.NODE_ENV === \"production\",\n path: \"/\",\n maxAge: 60 * 60 * 12,\n });\n return NextResponse.json({ ok: true });\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/password/route\",\n pathname: \"/api/password\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/password/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"INNER_APP_ROUTE\")\n } : {}\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/password/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId,\n deploymentId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":["gatewayUrl","process","env","GATEWAY_URL","replace","call","method","path","body","res","fetch","headers","authorization","undefined","JSON","stringify","cache","e","ok","status","data","error","message","text","parse","err","checkGatewayAuth","password","gateway","providers","budgets","models","logs","limit","usage","since","usageSeries","bucket","config","putConfig","changePassword","current","next","addProvider","p","editProvider","id","patch","encodeURIComponent","removeProvider","addKey","key","removeKey","index","addProviderModel","model","price","addProviderModels","removeProviderModel","clearProviderModels","testProvider","discoverModels","setRoute","alias","removeRoute","endpoint","setRtk","enabled","setCaveman","level","setPonytail","addServerKey","removeServerKey","POST","req","json","catch","length","r","jar","set","httpOnly","sameSite","secure","maxAge"],"mappings":"4jCACA,IAAA,EAAA,EAAA,CAAA,CAAA,OAWA,SAASA,IACP,MAAO,CAACC,QAAQC,GAAG,CAACC,WAAW,EAAI,wBAAA,CAAwB,CAAEC,OAAO,CAAC,MAAO,GAC9E,CASA,eAAeC,EAAQC,CAAc,CAAEC,CAAY,CAAEC,CAAc,MAC7DC,EACJ,GAAI,CACFA,EAAM,MAAMC,MAAMV,IAAeO,EAAM,QACrCD,EACAK,QAAS,CACPC,cAAe,CAAC,OAAO,EAAE,MAAM,CAAA,EAAA,EAAA,eAAA,AAAe,IAAA,CAAI,CAClD,QAAaC,IAATL,EAAqB,CAAE,eAAgB,kBAAmB,EAAI,CAAC,CAAC,AACtE,EACAA,UAAeK,IAATL,EAAqBM,KAAKC,SAAS,CAACP,QAAQK,EAClDG,MAAO,UACT,EACF,CAAE,MAAOC,EAAG,CACV,MAAO,CAAEC,IAAI,EAAOC,OAAQ,EAA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AG,CAAC,gBAAiB,CAAA,EAAA,EAAA,qBAAA,AAAqB,EAAC,EAAW,YAAY,GAE9E,MAAM,CAAA,EAAA,EAAA,YAAY,AAAZ,EAAa,EAAa,EAChC,IAAI,SAAS,EAAW,KAAK,CAAC,IAAI,CAAE,SAChC,EACA,OAAQ,EAAW,KAAK,CAAC,MAAM,EAAI,GACvC,IACO,IACX,CAGI,IAAyB,EACzB,MAAM,EAAe,EADgB,EAGrC,EAAa,EAAO,kBAAkB,GACtC,MAAM,EAAO,qBAAqB,CAAC,EAAI,OAAO,CAAE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,QAAiB,EAAW,CAAC,GAE5C,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,EATmB,CAShB,EAAY,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAY,AAAZ,EAAa,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,mCA5TA,SAAS,EACL,MAAO,CAAA,EAAA,EAAA,UAAA,AAAW,EAAC,kBACf,uBACA,CACJ,EACJ","ignoreList":[2]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/gateway.ts","../../../src/app/api/login/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import \"server-only\";\nimport { currentPassword } from \"./session\";\n\n/**\n * Server-side proxy to the gateway admin API. Runs only in Next.js server\n * context (route handlers / server components) — injects the admin password as\n * a Bearer token so it never reaches the browser.\n *\n * Scoped to the admin surface the gateway exposes today (usage, logs, providers,\n * budgets, whole-config CRUD). Granular provider/combo mutation helpers are added\n * alongside the pages that drive them in phase 11.\n */\nfunction gatewayUrl(): string {\n return (process.env.GATEWAY_URL ?? \"http://127.0.0.1:18080\").replace(/\\/$/, \"\");\n}\n\nexport interface GatewayResult<T> {\n ok: boolean;\n status: number;\n data: T | null;\n error?: string;\n}\n\nasync function call<T>(method: string, path: string, body?: unknown): Promise<GatewayResult<T>> {\n let res: Response;\n try {\n res = await fetch(gatewayUrl() + path, {\n method,\n headers: {\n authorization: `Bearer ${await currentPassword()}`,\n ...(body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n cache: \"no-store\",\n });\n } catch (e) {\n return { ok: false, status: 0, data: null, error: `gateway unreachable: ${(e as Error).message}` };\n }\n\n const text = await res.text();\n let data: T | null = null;\n try {\n data = text ? (JSON.parse(text) as T) : null;\n } catch {\n data = null;\n }\n if (!res.ok) {\n const err = (data as { error?: string } | null)?.error ?? `gateway returned ${res.status}`;\n return { ok: false, status: res.status, data, error: err };\n }\n return { ok: true, status: res.status, data };\n}\n\n/** Verify a specific admin password against the gateway (used at login, before a\n * session cookie exists). */\nexport async function checkGatewayAuth(password: string): Promise<boolean> {\n try {\n const res = await fetch(gatewayUrl() + \"/admin/providers\", {\n headers: { authorization: `Bearer ${password}` },\n cache: \"no-store\",\n });\n return res.ok;\n } catch {\n return false;\n }\n}\n\nexport const gateway = {\n providers: () => call<{ providers: ProviderSnapshot[] }>(\"GET\", \"/admin/providers\"),\n budgets: () => call<{ budgets: BudgetStatus[] }>(\"GET\", \"/admin/budgets\"),\n models: () => call<ModelsPayload>(\"GET\", \"/admin/models\"),\n logs: (limit = 100) => call<{ logs: UsageLog[] }>(\"GET\", `/admin/logs?limit=${limit}`),\n usage: (since = 0) => call<UsageSummary>(\"GET\", `/admin/usage?since=${since}`),\n usageSeries: (since: number, bucket: number) =>\n call<{ series: UsageSeriesPoint[] }>(\"GET\", `/admin/usage/series?since=${since}&bucket=${bucket}`),\n config: () => call<MaskedConfig>(\"GET\", \"/admin/config\"),\n putConfig: (text: string) => call<{ ok: boolean; config: MaskedConfig }>(\"PUT\", \"/admin/config\", { text }),\n changePassword: (current: string, next: string) =>\n call<{ ok: boolean }>(\"PUT\", \"/admin/password\", { current, next }),\n\n // ---- provider mutations (reply carries the fresh masked config) ----\n addProvider: (p: {\n id: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n free?: boolean;\n auto_models?: boolean;\n service_account?: string;\n }) => call<ConfigReply>(\"POST\", \"/admin/providers\", p),\n editProvider: (id: string, patch: { base_url?: string; format?: WireFormat }) =>\n call<ConfigReply>(\"PUT\", `/admin/providers/${encodeURIComponent(id)}`, patch),\n removeProvider: (id: string) => call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}`),\n addKey: (id: string, key: string) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/keys`, { key }),\n removeKey: (id: string, index: number) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/keys/${index}`),\n addProviderModel: (id: string, model: string, price?: { price_in?: number; price_out?: number }) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { model, ...price }),\n addProviderModels: (id: string, models: string[]) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { models }),\n removeProviderModel: (id: string, model: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models/${encodeURIComponent(model)}`),\n clearProviderModels: (id: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models`),\n testProvider: (id: string) => call<PingResult>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/test`),\n discoverModels: (id: string) =>\n call<{ ok: boolean; models: Array<{ id: string; added: boolean }> }>(\n \"POST\",\n `/admin/providers/${encodeURIComponent(id)}/connect`,\n ),\n\n // ---- combos: alias + ordered provider chain + strategy ----\n setRoute: (\n alias: string,\n body: { target: string[]; model?: string | string[]; strategy?: \"fallback\" | \"round-robin\"; price_in?: number; price_out?: number },\n ) => call<ConfigReply>(\"PUT\", `/admin/routes/${encodeURIComponent(alias)}`, body),\n removeRoute: (alias: string) => call<ConfigReply>(\"DELETE\", `/admin/routes/${encodeURIComponent(alias)}`),\n\n // ---- endpoint: toggles + gateway keys ----\n endpoint: () => call<EndpointPayload>(\"GET\", \"/admin/endpoint\"),\n setRtk: (enabled: boolean) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/rtk\", { enabled }),\n setCaveman: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/caveman\", { level }),\n setPonytail: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/ponytail\", { level }),\n addServerKey: (key: string) => call<ConfigReply>(\"POST\", \"/admin/endpoint/keys\", { key }),\n removeServerKey: (index: number) => call<ConfigReply>(\"DELETE\", `/admin/endpoint/keys/${index}`),\n};\n\n// ---- shapes mirrored from the gateway admin API ----\n\nexport type WireFormat = \"openai\" | \"anthropic\" | \"gemini\";\nexport type InjectLevel = \"off\" | \"lite\" | \"full\" | \"ultra\";\n\nexport interface ConfigReply {\n ok: boolean;\n config: MaskedConfig;\n}\n\nexport interface MaskedRoute {\n alias: string;\n target: string[];\n model?: string | string[];\n strategy: \"fallback\" | \"round-robin\";\n price_in?: number;\n price_out?: number;\n}\nexport interface MaskedProvider {\n id: string;\n name?: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n api_keys?: string[];\n /** optional friendly label per key, keyed by the MASKED key string. */\n key_names?: Record<string, string>;\n free: boolean;\n auto_models: boolean;\n service_account?: string;\n models: Array<{ id: string; price_in?: number; price_out?: number }>;\n cooldown_base_ms: number;\n max_retries: number;\n disabled_keys?: number[];\n disabled?: boolean;\n strategy?: \"fallback\" | \"round-robin\";\n sticky?: number;\n}\nexport interface MaskedConfig {\n server: { host: string; port: number; api_keys: string[] };\n endpoint: { rtk: boolean; caveman: InjectLevel; ponytail: InjectLevel };\n providers: MaskedProvider[];\n models: MaskedRoute[];\n}\n\nexport interface EndpointPayload {\n port: number;\n rtk: boolean;\n caveman: InjectLevel;\n ponytail: InjectLevel;\n headroom: { enabled: boolean; url: string; compress_user_messages: boolean };\n keys: Array<{ key: string; fingerprint: string; name?: string; models?: string[]; rpm?: number; expires?: number }>;\n}\n\nexport interface KeyUsageRow {\n fingerprint: string;\n name: string;\n masked: string;\n expires?: number;\n spent: number;\n tokens: number;\n budget: {\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n reset_in_ms: number;\n exhausted: boolean;\n alert: boolean;\n } | null;\n}\n\nexport interface HeadroomStatusReply {\n installed: boolean;\n path: string | null;\n running: boolean;\n python: string | null;\n localUrl: boolean;\n canStart: boolean;\n url: string;\n managedPid: number | null;\n enabled: boolean;\n compress_user_messages: boolean;\n}\n\nexport interface PingResult {\n reachable: boolean;\n status?: number;\n ok: boolean;\n error?: string;\n}\n\nexport interface PricingModel {\n id: string;\n price_in: number | null;\n price_out: number | null;\n default_in: number | null;\n default_out: number | null;\n}\nexport interface PricingPayload {\n providers: Array<{ id: string; models: PricingModel[] }>;\n}\n\nexport interface ModelsPayload {\n providers: Array<{\n id: string;\n format: WireFormat;\n models: Array<{ id: string; ref: string; price_in?: number; price_out?: number }>;\n }>;\n routes: MaskedRoute[];\n}\n\nexport interface KeySnapshot {\n key: string;\n healthy: boolean;\n cooldown_ms: number;\n fail_count: number;\n last_error: { message: string; status?: number; at: number } | null;\n}\nexport interface ProviderSnapshot {\n id: string;\n format: WireFormat;\n keys: KeySnapshot[];\n}\nexport type BudgetScope =\n | { type: \"global\" }\n | { type: \"provider\"; id: string }\n | { type: \"model\"; id: string }\n | { type: \"key\"; id: string };\n\nexport interface BudgetStatus {\n scope: BudgetScope;\n key: string;\n label: string;\n note?: string;\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n alert: boolean;\n alert_at: number;\n exhausted: boolean;\n est_converse: number | null;\n reset_in_ms: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n}\nexport interface UsageLog {\n ts: number;\n alias: string;\n provider: string;\n model: string;\n tokens_in: number;\n tokens_out: number;\n reasoning_tokens: number;\n cached_tokens: number;\n cost: number;\n status: number;\n latency_ms: number;\n stream: number;\n}\nexport interface UsageSummary {\n total: { requests: number; tokens_in: number; tokens_out: number; cost: number };\n by_provider: Array<{ provider: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n by_model: Array<{ alias: string; model: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n}\nexport interface UsageSeriesPoint {\n ts: number;\n requests: number;\n tokens_in: number;\n tokens_out: number;\n cost: number;\n}\n","import { NextResponse } from \"next/server\";\nimport { cookies } from \"next/headers\";\nimport { sealSession, SESSION_COOKIE } from \"@/lib/session\";\nimport { checkGatewayAuth } from \"@/lib/gateway\";\n\n/**\n * Login: the gateway is the source of truth for the admin password (a hash\n * store, changeable at runtime). We verify the submitted password directly\n * against the gateway, then store it encrypted in the session cookie so later\n * proxied calls can present it as the Bearer.\n */\nexport async function POST(req: Request): Promise<NextResponse> {\n const { password } = (await req.json().catch(() => ({}))) as { password?: string };\n if (!password) {\n return NextResponse.json({ error: \"password required\" }, { status: 400 });\n }\n if (!(await checkGatewayAuth(password))) {\n return NextResponse.json({ error: \"wrong password (or gateway unreachable)\" }, { status: 401 });\n }\n\n const jar = await cookies();\n jar.set(SESSION_COOKIE, sealSession(password), {\n httpOnly: true,\n sameSite: \"lax\",\n secure: process.env.NODE_ENV === \"production\",\n path: \"/\",\n maxAge: 60 * 60 * 12, // 12h\n });\n return NextResponse.json({ ok: true });\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/login/route\",\n pathname: \"/api/login\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/login/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"INNER_APP_ROUTE\")\n } : {}\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/login/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId,\n deploymentId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":["gatewayUrl","process","env","GATEWAY_URL","replace","call","method","path","body","res","fetch","headers","authorization","undefined","JSON","stringify","cache","e","ok","status","data","error","message","text","parse","err","checkGatewayAuth","password","gateway","providers","budgets","models","logs","limit","usage","since","usageSeries","bucket","config","putConfig","changePassword","current","next","addProvider","p","editProvider","id","patch","encodeURIComponent","removeProvider","addKey","key","removeKey","index","addProviderModel","model","price","addProviderModels","removeProviderModel","clearProviderModels","testProvider","discoverModels","setRoute","alias","removeRoute","endpoint","setRtk","enabled","setCaveman","level","setPonytail","addServerKey","removeServerKey","POST","req","json","catch","jar","set","httpOnly","sameSite","secure","maxAge"],"mappings":"4jCACA,IAAA,EAAA,EAAA,CAAA,CAAA,OAWA,SAASA,IACP,MAAQC,AAAD,SAASC,GAAG,CAACC,WAAW,EAAI,wBAAA,CAAwB,CAAEC,OAAO,CAAC,MAAO,GAC9E,CASA,eAAeC,EAAQC,CAAc,CAAEC,CAAY,CAAEC,CAAc,MAC7DC,EACJ,GAAI,CACFA,EAAM,MAAMC,MA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,EAAK,EAAI,AAAL,SAAc,CAAC,kBAAqB,EAAD,AAAS,GAAG,CAAC,kBAAkB,AAC7F,EAAQ,GAAG,CAAC,gBAAiB,CAAA,EAAA,EAAA,qBAAA,AAAqB,EAAC,EAAW,YAAY,GAE9E,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAChC,IAAI,SAAS,EAAW,KAAK,CAAC,IAAI,CAAE,SAChC,EACA,OAAQ,EAAW,KAAK,CAAC,MAAM,EAAI,GACvC,IACO,IACX,EAGI,GAAyB,EACzB,MAAM,EAAe,EADgB,EAGrC,EAAa,EAAO,kBAAkB,GACtC,MAAM,EAAO,qBAAqB,CAAC,EAAI,OAAO,CAAE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,QAAiB,EAAW,CAAC,GAE5C,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GATmB,AAShB,EAAY,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,mCA5TA,SAAS,EACL,MAAO,CAAA,EAAA,EAAA,UAAA,AAAW,EAAC,kBACf,uBACA,CACJ,EACJ","ignoreList":[2]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/gateway.ts","../../../src/app/api/login/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import \"server-only\";\nimport { currentPassword } from \"./session\";\n\n/**\n * Server-side proxy to the gateway admin API. Runs only in Next.js server\n * context (route handlers / server components) — injects the admin password as\n * a Bearer token so it never reaches the browser.\n *\n * Scoped to the admin surface the gateway exposes today (usage, logs, providers,\n * budgets, whole-config CRUD). Granular provider/combo mutation helpers are added\n * alongside the pages that drive them in phase 11.\n */\nfunction gatewayUrl(): string {\n return (process.env.GATEWAY_URL ?? \"http://127.0.0.1:18080\").replace(/\\/$/, \"\");\n}\n\nexport interface GatewayResult<T> {\n ok: boolean;\n status: number;\n data: T | null;\n error?: string;\n}\n\nasync function call<T>(method: string, path: string, body?: unknown): Promise<GatewayResult<T>> {\n let res: Response;\n try {\n res = await fetch(gatewayUrl() + path, {\n method,\n headers: {\n authorization: `Bearer ${await currentPassword()}`,\n ...(body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n cache: \"no-store\",\n });\n } catch (e) {\n return { ok: false, status: 0, data: null, error: `gateway unreachable: ${(e as Error).message}` };\n }\n\n const text = await res.text();\n let data: T | null = null;\n try {\n data = text ? (JSON.parse(text) as T) : null;\n } catch {\n data = null;\n }\n if (!res.ok) {\n const err = (data as { error?: string } | null)?.error ?? `gateway returned ${res.status}`;\n return { ok: false, status: res.status, data, error: err };\n }\n return { ok: true, status: res.status, data };\n}\n\n/** Verify a specific admin password against the gateway (used at login, before a\n * session cookie exists). */\nexport async function checkGatewayAuth(password: string): Promise<boolean> {\n try {\n const res = await fetch(gatewayUrl() + \"/admin/providers\", {\n headers: { authorization: `Bearer ${password}` },\n cache: \"no-store\",\n });\n return res.ok;\n } catch {\n return false;\n }\n}\n\nexport const gateway = {\n providers: () => call<{ providers: ProviderSnapshot[] }>(\"GET\", \"/admin/providers\"),\n budgets: () => call<{ budgets: BudgetStatus[] }>(\"GET\", \"/admin/budgets\"),\n models: () => call<ModelsPayload>(\"GET\", \"/admin/models\"),\n logs: (limit = 100) => call<{ logs: UsageLog[] }>(\"GET\", `/admin/logs?limit=${limit}`),\n usage: (since = 0) => call<UsageSummary>(\"GET\", `/admin/usage?since=${since}`),\n usageSeries: (since: number, bucket: number) =>\n call<{ series: UsageSeriesPoint[] }>(\"GET\", `/admin/usage/series?since=${since}&bucket=${bucket}`),\n config: () => call<MaskedConfig>(\"GET\", \"/admin/config\"),\n putConfig: (text: string) => call<{ ok: boolean; config: MaskedConfig }>(\"PUT\", \"/admin/config\", { text }),\n changePassword: (current: string, next: string) =>\n call<{ ok: boolean }>(\"PUT\", \"/admin/password\", { current, next }),\n\n // ---- provider mutations (reply carries the fresh masked config) ----\n addProvider: (p: {\n id: string;\n name?: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n free?: boolean;\n auto_models?: boolean;\n service_account?: string;\n }) => call<ConfigReply>(\"POST\", \"/admin/providers\", p),\n editProvider: (id: string, patch: { base_url?: string; format?: WireFormat; name?: string }) =>\n call<ConfigReply>(\"PUT\", `/admin/providers/${encodeURIComponent(id)}`, patch),\n removeProvider: (id: string) => call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}`),\n addKey: (id: string, key: string) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/keys`, { key }),\n removeKey: (id: string, index: number) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/keys/${index}`),\n addProviderModel: (id: string, model: string, price?: { price_in?: number; price_out?: number }) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { model, ...price }),\n addProviderModels: (id: string, models: string[]) =>\n call<ConfigReply>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/models`, { models }),\n removeProviderModel: (id: string, model: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models/${encodeURIComponent(model)}`),\n clearProviderModels: (id: string) =>\n call<ConfigReply>(\"DELETE\", `/admin/providers/${encodeURIComponent(id)}/models`),\n testProvider: (id: string) => call<PingResult>(\"POST\", `/admin/providers/${encodeURIComponent(id)}/test`),\n discoverModels: (id: string) =>\n call<{ ok: boolean; models: Array<{ id: string; added: boolean }> }>(\n \"POST\",\n `/admin/providers/${encodeURIComponent(id)}/connect`,\n ),\n\n // ---- combos: alias + ordered provider chain + strategy ----\n setRoute: (\n alias: string,\n body: { target: string[]; model?: string | string[]; strategy?: \"fallback\" | \"round-robin\"; price_in?: number; price_out?: number },\n ) => call<ConfigReply>(\"PUT\", `/admin/routes/${encodeURIComponent(alias)}`, body),\n removeRoute: (alias: string) => call<ConfigReply>(\"DELETE\", `/admin/routes/${encodeURIComponent(alias)}`),\n\n // ---- endpoint: toggles + gateway keys ----\n endpoint: () => call<EndpointPayload>(\"GET\", \"/admin/endpoint\"),\n setRtk: (enabled: boolean) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/rtk\", { enabled }),\n setCaveman: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/caveman\", { level }),\n setPonytail: (level: InjectLevel) => call<ConfigReply>(\"PUT\", \"/admin/endpoint/ponytail\", { level }),\n addServerKey: (key: string) => call<ConfigReply>(\"POST\", \"/admin/endpoint/keys\", { key }),\n removeServerKey: (index: number) => call<ConfigReply>(\"DELETE\", `/admin/endpoint/keys/${index}`),\n};\n\n// ---- shapes mirrored from the gateway admin API ----\n\nexport type WireFormat = \"openai\" | \"anthropic\" | \"gemini\";\nexport type InjectLevel = \"off\" | \"lite\" | \"full\" | \"ultra\";\n\nexport interface ConfigReply {\n ok: boolean;\n config: MaskedConfig;\n}\n\nexport interface MaskedRoute {\n alias: string;\n target: string[];\n model?: string | string[];\n strategy: \"fallback\" | \"round-robin\";\n price_in?: number;\n price_out?: number;\n}\nexport interface MaskedProvider {\n id: string;\n name?: string;\n format: WireFormat;\n base_url: string;\n api_key?: string;\n api_keys?: string[];\n /** optional friendly label per key, keyed by the MASKED key string. */\n key_names?: Record<string, string>;\n free: boolean;\n auto_models: boolean;\n service_account?: string;\n models: Array<{ id: string; price_in?: number; price_out?: number }>;\n cooldown_base_ms: number;\n max_retries: number;\n disabled_keys?: number[];\n disabled?: boolean;\n strategy?: \"fallback\" | \"round-robin\";\n sticky?: number;\n}\nexport interface MaskedConfig {\n server: { host: string; port: number; api_keys: string[] };\n endpoint: { rtk: boolean; caveman: InjectLevel; ponytail: InjectLevel };\n providers: MaskedProvider[];\n models: MaskedRoute[];\n}\n\nexport interface EndpointPayload {\n port: number;\n rtk: boolean;\n caveman: InjectLevel;\n ponytail: InjectLevel;\n headroom: { enabled: boolean; url: string; compress_user_messages: boolean };\n keys: Array<{ key: string; fingerprint: string; name?: string; models?: string[]; rpm?: number; expires?: number }>;\n}\n\nexport interface KeyUsageRow {\n fingerprint: string;\n name: string;\n masked: string;\n expires?: number;\n spent: number;\n tokens: number;\n budget: {\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n reset_in_ms: number;\n exhausted: boolean;\n alert: boolean;\n } | null;\n}\n\nexport interface HeadroomStatusReply {\n installed: boolean;\n path: string | null;\n running: boolean;\n python: string | null;\n localUrl: boolean;\n canStart: boolean;\n url: string;\n managedPid: number | null;\n enabled: boolean;\n compress_user_messages: boolean;\n}\n\nexport interface PingResult {\n reachable: boolean;\n status?: number;\n ok: boolean;\n error?: string;\n}\n\nexport interface PricingModel {\n id: string;\n price_in: number | null;\n price_out: number | null;\n default_in: number | null;\n default_out: number | null;\n}\nexport interface PricingPayload {\n providers: Array<{ id: string; models: PricingModel[] }>;\n}\n\nexport interface ModelsPayload {\n providers: Array<{\n id: string;\n format: WireFormat;\n models: Array<{ id: string; ref: string; price_in?: number; price_out?: number }>;\n }>;\n routes: MaskedRoute[];\n}\n\nexport interface KeySnapshot {\n key: string;\n healthy: boolean;\n cooldown_ms: number;\n fail_count: number;\n last_error: { message: string; status?: number; at: number } | null;\n}\nexport interface ProviderSnapshot {\n id: string;\n format: WireFormat;\n keys: KeySnapshot[];\n}\nexport type BudgetScope =\n | { type: \"global\" }\n | { type: \"provider\"; id: string }\n | { type: \"model\"; id: string }\n | { type: \"key\"; id: string };\n\nexport interface BudgetStatus {\n scope: BudgetScope;\n key: string;\n label: string;\n note?: string;\n unit: \"usd\" | \"tokens\";\n limit: number;\n spent: number;\n pct: number;\n alert: boolean;\n alert_at: number;\n exhausted: boolean;\n est_converse: number | null;\n reset_in_ms: number;\n window: \"5h\" | \"24h\" | \"7day\" | \"30day\";\n}\nexport interface UsageLog {\n ts: number;\n alias: string;\n provider: string;\n model: string;\n tokens_in: number;\n tokens_out: number;\n reasoning_tokens: number;\n cached_tokens: number;\n cost: number;\n status: number;\n latency_ms: number;\n stream: number;\n}\nexport interface UsageSummary {\n total: { requests: number; tokens_in: number; tokens_out: number; cost: number };\n by_provider: Array<{ provider: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n by_model: Array<{ alias: string; model: string; requests: number; tokens_in: number; tokens_out: number; cost: number }>;\n}\nexport interface UsageSeriesPoint {\n ts: number;\n requests: number;\n tokens_in: number;\n tokens_out: number;\n cost: number;\n}\n","import { NextResponse } from \"next/server\";\nimport { cookies } from \"next/headers\";\nimport { sealSession, SESSION_COOKIE } from \"@/lib/session\";\nimport { checkGatewayAuth } from \"@/lib/gateway\";\n\n/**\n * Login: the gateway is the source of truth for the admin password (a hash\n * store, changeable at runtime). We verify the submitted password directly\n * against the gateway, then store it encrypted in the session cookie so later\n * proxied calls can present it as the Bearer.\n */\nexport async function POST(req: Request): Promise<NextResponse> {\n const { password } = (await req.json().catch(() => ({}))) as { password?: string };\n if (!password) {\n return NextResponse.json({ error: \"password required\" }, { status: 400 });\n }\n if (!(await checkGatewayAuth(password))) {\n return NextResponse.json({ error: \"wrong password (or gateway unreachable)\" }, { status: 401 });\n }\n\n const jar = await cookies();\n jar.set(SESSION_COOKIE, sealSession(password), {\n httpOnly: true,\n sameSite: \"lax\",\n secure: process.env.NODE_ENV === \"production\",\n path: \"/\",\n maxAge: 60 * 60 * 12, // 12h\n });\n return NextResponse.json({ ok: true });\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/login/route\",\n pathname: \"/api/login\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/login/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"INNER_APP_ROUTE\")\n } : {}\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/login/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId,\n deploymentId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":["gatewayUrl","process","env","GATEWAY_URL","replace","call","method","path","body","res","fetch","headers","authorization","undefined","JSON","stringify","cache","e","ok","status","data","error","message","text","parse","err","checkGatewayAuth","password","gateway","providers","budgets","models","logs","limit","usage","since","usageSeries","bucket","config","putConfig","changePassword","current","next","addProvider","p","editProvider","id","patch","encodeURIComponent","removeProvider","addKey","key","removeKey","index","addProviderModel","model","price","addProviderModels","removeProviderModel","clearProviderModels","testProvider","discoverModels","setRoute","alias","removeRoute","endpoint","setRtk","enabled","setCaveman","level","setPonytail","addServerKey","removeServerKey","POST","req","json","catch","jar","set","httpOnly","sameSite","secure","maxAge"],"mappings":"4jCACA,IAAA,EAAA,EAAA,CAAA,CAAA,OAWA,SAASA,IACP,MAAQC,AAAD,SAASC,GAAG,CAACC,WAAW,EAAI,wBAAA,CAAwB,CAAEC,OAAO,CAAC,MAAO,GAC9E,CASA,eAAeC,EA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