import { Alert, AlertDescription } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; import { Textarea } from "@/components/ui/textarea"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { IS_ENTERPRISE } from "@/lib/constants/config"; import { getErrorMessage, useGetCoreConfigQuery, useUpdateProxyConfigMutation } from "@/lib/store"; import { DefaultGlobalProxyConfig, GlobalProxyConfig } from "@/lib/types/config"; import { globalProxyConfigSchema } from "@/lib/types/schemas"; import { cn } from "@/lib/utils"; import { RbacOperation, RbacResource, useRbac } from "@enterprise/lib"; import { zodResolver } from "@hookform/resolvers/zod"; import { AlertTriangle, Info } from "lucide-react"; import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; export default function ProxyView() { const hasSettingsUpdateAccess = useRbac(RbacResource.Settings, RbacOperation.Update); const { data: bifrostConfig } = useGetCoreConfigQuery({ fromDB: true }); const proxyConfig = bifrostConfig?.proxy_config; const [updateProxyConfig, { isLoading }] = useUpdateProxyConfigMutation(); const form = useForm({ resolver: zodResolver(globalProxyConfigSchema), mode: "onChange", reValidateMode: "onChange", defaultValues: DefaultGlobalProxyConfig, }); useEffect(() => { if (proxyConfig) { form.reset({ ...DefaultGlobalProxyConfig, ...proxyConfig, }); } }, [proxyConfig, form]); const watchedEnabled = form.watch("enabled"); const watchedType = form.watch("type"); const onSubmit = async (data: GlobalProxyConfig) => { try { await updateProxyConfig(data).unwrap(); toast.success("Proxy configuration updated successfully."); } catch (error) { toast.error(getErrorMessage(error)); } }; const isTypeUnsupported = watchedType === "socks5" || watchedType === "tcp"; return (

Proxy Settings

Configure global proxy settings for outbound requests.

{/* Enable Proxy */}
Enable Proxy

Enable global proxy for outbound HTTP requests.

( )} />
{/* Proxy Configuration Section */}

Proxy Configuration

{/* Proxy Type */} ( Proxy Type Select the proxy protocol type. Currently only HTTP proxy is supported. )} /> {isTypeUnsupported && watchedEnabled && ( {watchedType.toUpperCase()} proxy is not yet supported. Please use HTTP proxy. )} {/* Proxy URL */} ( Proxy URL Full URL of the proxy server including protocol and port. )} /> {/* Authentication Section */}

Authentication (Optional)

( Username )} /> ( Password )} />
{/* Advanced Settings */}

Advanced Settings

{/* No Proxy */} ( No Proxy Hosts