diff --git a/src/app/api/config/route.ts b/src/app/api/config/route.ts deleted file mode 100644 index 80e61b2..0000000 --- a/src/app/api/config/route.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { isAuthenticationEnabled } from "@/lib/auth"; -import { proxyEvoScientistAdminRequest } from "@/lib/server/evoscientistAdminProxy"; - -export const runtime = "nodejs"; - -async function proxy(request: NextRequest) { - if (!isAuthenticationEnabled()) { - return NextResponse.json( - { - error: - "Authentication required. Enable WebUI authentication to manage config.yaml.", - }, - { status: 403 } - ); - } - return proxyEvoScientistAdminRequest(request, { - upstreamPath: "/api/config", - requestLabel: "Built-in model configuration", - maxBodyBytes: 512_000, - }); -} - -export async function GET(request: NextRequest) { - return proxy(request); -} - -export async function PATCH(request: NextRequest) { - return proxy(request); -} - -export async function POST(request: NextRequest) { - return proxy(request); -} diff --git a/src/app/api/default-model/route.ts b/src/app/api/default-model/route.ts deleted file mode 100644 index e5b4356..0000000 --- a/src/app/api/default-model/route.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NextRequest } from "next/server"; -import { proxyEvoScientistAdminRequest } from "@/lib/server/evoscientistAdminProxy"; - -export const runtime = "nodejs"; - -export async function PUT(request: NextRequest) { - return proxyEvoScientistAdminRequest(request, { - upstreamPath: "/api/default-model", - requestLabel: "Default model configuration", - maxBodyBytes: 8_192, - }); -} diff --git a/src/app/api/provider-actions/route.ts b/src/app/api/provider-actions/route.ts deleted file mode 100644 index 2ff5221..0000000 --- a/src/app/api/provider-actions/route.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NextRequest } from "next/server"; -import { proxyEvoScientistAdminRequest } from "@/lib/server/evoscientistAdminProxy"; - -export const runtime = "nodejs"; - -export async function POST(request: NextRequest) { - return proxyEvoScientistAdminRequest(request, { - upstreamPath: "/api/provider-actions", - requestLabel: "Provider action", - maxBodyBytes: 32_768, - }); -} diff --git a/src/app/api/provider-profiles/route.ts b/src/app/api/provider-profiles/route.ts deleted file mode 100644 index 87e1619..0000000 --- a/src/app/api/provider-profiles/route.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { NextRequest } from "next/server"; -import { proxyEvoScientistAdminRequest } from "@/lib/server/evoscientistAdminProxy"; - -export const runtime = "nodejs"; - -async function proxy(request: NextRequest) { - return proxyEvoScientistAdminRequest(request, { - upstreamPath: "/api/provider-profiles", - requestLabel: "Provider configuration", - maxBodyBytes: 512_000, - }); -} - -export async function GET(request: NextRequest) { - return proxy(request); -} - -export async function PUT(request: NextRequest) { - return proxy(request); -} diff --git a/src/app/components/AccountDialog.tsx b/src/app/components/AccountDialog.tsx index 7013fa3..f4ec090 100644 --- a/src/app/components/AccountDialog.tsx +++ b/src/app/components/AccountDialog.tsx @@ -10,6 +10,7 @@ import { DialogTitle, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; +import { UserManagementSection } from "@/app/components/UserManagementSection"; interface AccountDialogProps { open: boolean; @@ -17,13 +18,16 @@ interface AccountDialogProps { } export function AccountDialog({ open, onOpenChange }: AccountDialogProps) { - const [username, setUsername] = useState(null); + const [account, setAccount] = useState<{ + username: string; + role: "admin" | "user"; + } | null>(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (!open) { - setUsername(null); + setAccount(null); setLoading(false); setError(null); return; @@ -36,6 +40,7 @@ export function AccountDialog({ open, onOpenChange }: AccountDialogProps) { .then(async (response) => { const body = (await response.json().catch(() => null)) as { username?: unknown; + role?: unknown; error?: unknown; } | null; if (!response.ok || typeof body?.username !== "string") { @@ -45,10 +50,13 @@ export function AccountDialog({ open, onOpenChange }: AccountDialogProps) { : "Account information is unavailable." ); } - return body.username; + return { + username: body.username, + role: body.role === "user" ? ("user" as const) : ("admin" as const), + }; }) .then((value) => { - if (!cancelled) setUsername(value); + if (!cancelled) setAccount(value); }) .catch((reason: unknown) => { if (!cancelled) { @@ -73,7 +81,7 @@ export function AccountDialog({ open, onOpenChange }: AccountDialogProps) { open={open} onOpenChange={onOpenChange} > - + User information @@ -85,7 +93,7 @@ export function AccountDialog({ open, onOpenChange }: AccountDialogProps) { className="rounded-md border border-border px-4 py-3" >

Username

- {loading || (!error && username === null) ? ( + {loading || (!error && account === null) ? (

Loading account...

@@ -96,12 +104,18 @@ export function AccountDialog({ open, onOpenChange }: AccountDialogProps) { > {error}

- ) : ( + ) : account ? (

- {username} + {account.username} + + {account.role} +

- )} + ) : null} + {account?.role === "admin" && ( + + )} - - ); - } - - const apiKeyField = selectedProvider.apiKeyField; - const apiKeyStatus = apiKeyField ? config.secrets[apiKeyField] : null; - const selectedEnvOverrides = providerFields(selectedProvider) - .map( - (field) => - config.env_overrides[field as keyof typeof config.env_overrides] - ) - .filter((name): name is string => Boolean(name)); - const providerConfigured = Boolean( - (apiKeyField && apiKeyStatus?.configured) || - (selectedProvider.baseUrlField && - values[selectedProvider.baseUrlField]) || - (selectedProvider.authModeField && - values[selectedProvider.authModeField] === "oauth") - ); - - return ( -
- {error && ( -
- {error} -
- )} - -
- - -
-
-
-
-

Default routing

-
-
-
- - -
-
- - - updateValue("model", event.target.value) - } - /> -
-
- - - updateValue("auxiliary_provider", event.target.value) - } - /> -
-
- - - updateValue("auxiliary_model", event.target.value) - } - /> -
-
- -