fix(model): route requests through Electron net

This commit is contained in:
mesalogo
2026-10-08 21:58:00 +08:00
parent 47917094ad
commit adb58d9200
3 changed files with 9 additions and 2 deletions
+5 -1
View File
@@ -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 ?? '',
+2
View File
@@ -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,
+2 -1
View File
@@ -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,