feat(network): centralize proxy settings and add MCP routing (NAN-315) (#6372)
* feat(network): share proxy settings across features and MCP (NAN-315) * fix(network): address shared proxy review regressions * test(network): align rebased OAuth fixtures with runtime admission * fix(webui): configure shared proxy without leaving connection drafts * feat(webui): add optional shared proxy authentication editor * fix(webui): align proxy save tests and loading skeleton
This commit is contained in:
1 parent
872a83340d
commit
084b6bb394
181 files changed
+3740
-807
No files matched your search
@@ -25,6 +25,7 @@ import { ModelAPIControl } from "@/components/settings/models/ModelAPIControl";
|
||||
import { ProviderAPIControl } from "@/components/settings/models/ProviderAPIControl";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SettingsHint } from "@/components/settings/shared/SettingsHint";
|
||||
import { ProxySettingsControl } from "@/components/settings/shared/ProxySettingsControl";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -107,7 +108,7 @@ const CUSTOM_PROVIDER_ADVANCED_FIELDS: ProviderAdvancedField[] = [
|
||||
"extra_headers",
|
||||
"extra_body",
|
||||
"extra_query",
|
||||
"proxy",
|
||||
"use_proxy",
|
||||
"thinking_style",
|
||||
];
|
||||
|
||||
@@ -381,11 +382,13 @@ function ProviderRequestOptions({
|
||||
}
|
||||
|
||||
function ProviderAdvancedOptions({
|
||||
onConfigureProxy,
|
||||
fields,
|
||||
form,
|
||||
onChange,
|
||||
children,
|
||||
}: {
|
||||
onConfigureProxy?: () => void;
|
||||
fields: ProviderAdvancedField[];
|
||||
form: ProviderForm;
|
||||
onChange: (value: Partial<ProviderForm>) => void;
|
||||
@@ -466,22 +469,13 @@ function ProviderAdvancedOptions({
|
||||
</DropdownMenu>
|
||||
</label>
|
||||
) : null}
|
||||
{enabled.has("proxy") ? (
|
||||
<label className="block space-y-1.5 md:col-span-2">
|
||||
<span className="block px-3 text-[12px] font-medium text-muted-foreground">
|
||||
{tx("settings.providers.proxy", "Network proxy")}
|
||||
</span>
|
||||
<Input
|
||||
value={form.proxy}
|
||||
onChange={(event) => onChange({ proxy: event.target.value })}
|
||||
placeholder="http://127.0.0.1:7890"
|
||||
autoCapitalize="none"
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
spellCheck={false}
|
||||
className="h-9 rounded-full font-mono text-[12px]"
|
||||
/>
|
||||
</label>
|
||||
{enabled.has("use_proxy") ? (
|
||||
<ProxySettingsControl
|
||||
className="px-3 py-2 md:col-span-2"
|
||||
checked={form.useProxy}
|
||||
onChange={(useProxy) => onChange({ useProxy })}
|
||||
onConfigure={onConfigureProxy}
|
||||
/>
|
||||
) : null}
|
||||
{enabled.has("region") ? (
|
||||
<label className="block space-y-1.5">
|
||||
@@ -535,6 +529,7 @@ type ProviderSettingsView =
|
||||
| { kind: "provider"; name: string; adding: boolean };
|
||||
|
||||
export function ProvidersSettings({
|
||||
onConfigureProxy,
|
||||
entry,
|
||||
onClose,
|
||||
onCloseAutoFocus,
|
||||
@@ -560,6 +555,7 @@ export function ProvidersSettings({
|
||||
onProviderOAuthLogout,
|
||||
}: {
|
||||
entry: ProviderSettingsEntry;
|
||||
onConfigureProxy?: () => void;
|
||||
onClose: () => void;
|
||||
onCloseAutoFocus: (event: Event) => void;
|
||||
onProviderAdded?: (provider: string) => void;
|
||||
@@ -671,7 +667,7 @@ export function ProvidersSettings({
|
||||
const apiBase = form.apiBase.trim();
|
||||
const advancedFields = provider.advanced_fields ?? [];
|
||||
const oauthSettingsDirty = isOauthProvider && (
|
||||
form.proxy.trim() !== (provider.proxy ?? "").trim()
|
||||
form.useProxy !== (provider.use_proxy ?? false)
|
||||
|| form.extraBody.trim() !== providerJsonValue(provider.extra_body).trim()
|
||||
);
|
||||
const oauthSettingsSaving = saving && providerOperation?.action === "save";
|
||||
@@ -680,7 +676,7 @@ export function ProvidersSettings({
|
||||
const hasOptionalProviderSetting = Boolean(
|
||||
apiKey
|
||||
|| apiBase
|
||||
|| form.proxy.trim()
|
||||
|| form.useProxy
|
||||
|| form.extraHeaders.trim()
|
||||
|| form.extraBody.trim()
|
||||
|| form.extraQuery.trim()
|
||||
@@ -787,6 +783,7 @@ export function ProvidersSettings({
|
||||
/>
|
||||
{supportsOauthAdvancedSettings ? (
|
||||
<ProviderAdvancedOptions
|
||||
onConfigureProxy={onConfigureProxy}
|
||||
fields={advancedFields}
|
||||
form={form}
|
||||
onChange={(value) => onChangeProviderForm(provider.name, value)}
|
||||
@@ -902,6 +899,7 @@ export function ProvidersSettings({
|
||||
onChange={(value) => onChangeProviderForm(provider.name, value)}
|
||||
/>
|
||||
<ProviderAdvancedOptions
|
||||
onConfigureProxy={onConfigureProxy}
|
||||
fields={advancedFields}
|
||||
form={form}
|
||||
onChange={(value) => onChangeProviderForm(provider.name, value)}
|
||||
@@ -1039,6 +1037,7 @@ export function ProvidersSettings({
|
||||
</div>
|
||||
</label>
|
||||
<ProviderAdvancedOptions
|
||||
onConfigureProxy={onConfigureProxy}
|
||||
fields={CUSTOM_PROVIDER_ADVANCED_FIELDS}
|
||||
form={customProviderDraft}
|
||||
onChange={(value) =>
|
||||
|
||||
@@ -8,7 +8,7 @@ export type ProviderForm = {
|
||||
apiKey: string;
|
||||
apiBase: string;
|
||||
api: ModelAPIConfig | null;
|
||||
proxy: string;
|
||||
useProxy: boolean;
|
||||
extraHeaders: string;
|
||||
extraBody: string;
|
||||
extraQuery: string;
|
||||
@@ -43,7 +43,7 @@ export function providerFormFromRow(
|
||||
apiKey: "",
|
||||
apiBase: provider.api_base ?? provider.default_api_base ?? "",
|
||||
api: provider.api ?? null,
|
||||
proxy: provider.proxy ?? "",
|
||||
useProxy: provider.use_proxy ?? false,
|
||||
extraHeaders: providerJsonValue(provider.extra_headers),
|
||||
extraBody: providerJsonValue(provider.extra_body),
|
||||
extraQuery: providerJsonValue(provider.extra_query),
|
||||
@@ -60,7 +60,7 @@ export function emptyCustomProviderDraft(): CustomProviderDraft {
|
||||
apiKey: "",
|
||||
apiBase: "",
|
||||
api: { supported_apis: ["chat_completions"], preferred_api: "chat_completions" },
|
||||
proxy: "",
|
||||
useProxy: false,
|
||||
extraHeaders: "",
|
||||
extraBody: "",
|
||||
extraQuery: "",
|
||||
|
||||
@@ -456,7 +456,7 @@ export function useModelSettingsActions({
|
||||
if (provider.provider_api_configurable) update.api = providerForm.api;
|
||||
}
|
||||
for (const field of provider.advanced_fields ?? []) {
|
||||
if (field === "proxy") update.proxy = providerForm.proxy.trim();
|
||||
if (field === "use_proxy") update.use_proxy = providerForm.useProxy;
|
||||
if (field === "extra_headers") {
|
||||
update.extraHeaders = providerForm.extraHeaders.trim();
|
||||
}
|
||||
@@ -500,7 +500,7 @@ export function useModelSettingsActions({
|
||||
apiKey: draft.apiKey.trim() || undefined,
|
||||
apiBase: draft.apiBase.trim(),
|
||||
...(settings?.provider_api_configuration_supported ? { api: draft.api } : {}),
|
||||
proxy: draft.proxy.trim(),
|
||||
use_proxy: draft.useProxy,
|
||||
extraHeaders: draft.extraHeaders.trim(),
|
||||
extraBody: draft.extraBody.trim(),
|
||||
extraQuery: draft.extraQuery.trim(),
|
||||
|
||||
Reference in new issue
Block a user