From adb58d9200da213ca8ca1618b9b66e80782e2649 Mon Sep 17 00:00:00 2001 From: mesalogo Date: Thu, 8 Oct 2026 21:58:00 +0800 Subject: [PATCH] fix(model): route requests through Electron net --- src/main/agent/create-runtime.ts | 6 +++++- src/main/index.ts | 2 ++ src/main/ipc.ts | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/agent/create-runtime.ts b/src/main/agent/create-runtime.ts index 95927011..52caa4b3 100644 --- a/src/main/agent/create-runtime.ts +++ b/src/main/agent/create-runtime.ts @@ -46,6 +46,7 @@ import { import type { LaunchEnvironmentProvider } from '../local-tool-environment/launch-environment-provider' import type { DesktopDiagnosticFailureObserver } from '../desktop-diagnostics' export type AgentCapabilityContext = { + modelFetcher?: ModelRuntimeOptions['fetcher'] outputStore?: ModelRuntimeOptions['outputStore'] outputAdopt?: ModelRuntimeOptions['outputAdopt'] observeFailure?: DesktopDiagnosticFailureObserver @@ -139,9 +140,11 @@ export function createDefaultModelRuntime( export function createModelProfileRuntime( defaultWorkspace: string, settings: ResolvedRuntimeSettings, - profile: ResolvedModelProfile + profile: ResolvedModelProfile, + fetcher?: ModelRuntimeOptions['fetcher'] ): ModelAgentRuntime { return new ModelAgentRuntime({ + fetcher, apiKey: profile.apiKey, baseUrl: profile.baseUrl, model: profile.modelName, @@ -359,6 +362,7 @@ export function createAgentRuntime( (modelAuthentication === 'none' || modelApiKey)) ) { return new ModelAgentRuntime({ + fetcher: capabilities.modelFetcher, outputStore: capabilities.outputStore, outputAdopt: capabilities.outputAdopt, apiKey: modelApiKey ?? '', diff --git a/src/main/index.ts b/src/main/index.ts index cbe04259..ac7b8371 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -8,6 +8,7 @@ import { dialog, globalShortcut, Menu, + net, safeStorage, session, shell, @@ -1115,6 +1116,7 @@ if (hasSingleInstanceLock) { : Promise.resolve([]) ]) return createAgentRuntime(defaultWorkspace, settings, { + modelFetcher: net.fetch, outputStore: { backingStore: storageFiles.backingStore }, outputAdopt: storageFiles.attachments.outputAdopt, observeFailure: observeDesktopFailure, diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 7ba58efe..ddc7d87d 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -11,6 +11,7 @@ import { BrowserWindow, dialog, ipcMain, + net, shell, type NotificationConstructorOptions, type IpcMainInvokeEvent @@ -6318,7 +6319,7 @@ export function registerIpcHandlers( if (profile.authentication === 'api-key' && !profile.apiKey) { throw new Error(`监督者模型连接“${profile.name}”未配置 API Key`) } - return createModelProfileRuntime(settings.workspacePath, settings, profile) + return createModelProfileRuntime(settings.workspacePath, settings, profile, net.fetch) } const supervisorService = createProductionSupervisorService(supervisionDatabase, async () => applicationSettingsStore?.get(), resolveSupervisorRuntime, supervisionModelPool,