Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(providers): preserve routes in runtime fill
Chris30ffb5c955ec
diff --git a/apps/desktop/src/renderer/lib/__tests__/customProviderRuntimeFill.test.ts b/apps/desktop/src/renderer/lib/__tests__/customProviderRuntimeFill.test.tsindex b959d0c997..0c63ecb9db 100644--- a/apps/desktop/src/renderer/lib/__tests__/customProviderRuntimeFill.test.ts+++ b/apps/desktop/src/renderer/lib/__tests__/customProviderRuntimeFill.test.ts@@ -598,6 +598,31 @@ describe('custom provider runtime fill', () => {]);});+ it('preserves model-level routes when runtime-fill copies models', () => {+ const source = draft({+ models: [+ {+ id: 'glm-5.3',+ name: 'GLM-5.3',+ route: {+ baseUrl: 'https://open.bigmodel.cn/api/v1',+ wireProtocol: 'openai-responses',+ requestPath: '/responses',+ },+ },+ ],+ });+ const result = applyRuntimeFillFields(+ draft({ models: [{ id: 'glm-5.3', name: 'Old GLM-5.3' }] }),+ source,+ ['models'],+ { sourceAgent: 'codex', targetAgent: 'codex' },+ );++ expect(result.models).toEqual(source.models);+ expect(result.models[0]?.route).not.toBe(source.models[0]?.route);+ });+it('ignores Pi-only capabilities when comparing or filling a non-Pi target', () => {const source = draft({models: [@@ -655,17 +680,29 @@ describe('custom provider runtime fill', () => {it('takes a deep snapshot for review and apply', () => {const source = draft({- models: [{ id: 'model-a', name: 'Model A', reasoningEfforts: ['low'] }],+ models: [+ {+ id: 'model-a',+ name: 'Model A',+ route: {+ baseUrl: 'https://api.example/v1',+ wireProtocol: 'openai-responses',+ },+ reasoningEfforts: ['low'],+ },+ ],headers: [{ name: 'X-Test', value: 'one' }],});const snapshot = cloneRuntimeFillDraft(source);source.models[0].name = 'Changed';+ source.models[0].route!.baseUrl = 'https://changed.example/v1';source.models[0].reasoningEfforts?.push('high');source.headers[0].value = 'two';expect(snapshot.models[0]).toMatchObject({name: 'Model A',+ route: { baseUrl: 'https://api.example/v1' },reasoningEfforts: ['low'],});expect(snapshot.headers[0]).toEqual({ name: 'X-Test', value: 'one' });diff --git a/apps/desktop/src/renderer/lib/customProviderRuntimeFill.ts b/apps/desktop/src/renderer/lib/customProviderRuntimeFill.tsindex eeae2ea167..05c237b23b 100644--- a/apps/desktop/src/renderer/lib/customProviderRuntimeFill.ts+++ b/apps/desktop/src/renderer/lib/customProviderRuntimeFill.ts@@ -268,6 +268,7 @@ export function cloneRuntimeFillDraft(draft: RuntimeFillDraft): RuntimeFillDraft...draft,models: draft.models.map((model) => ({...model,+ ...(model.route ? { route: { ...model.route } } : {}),...(model.reasoningEfforts ? { reasoningEfforts: [...model.reasoningEfforts] } : {}),})),headers: draft.headers.map((header) => ({ ...header })),diff --git a/apps/desktop/src/shared/piRuntimeInitialization.ts b/apps/desktop/src/shared/piRuntimeInitialization.tsindex dcdfaa0a78..0bec6eab82 100644--- a/apps/desktop/src/shared/piRuntimeInitialization.ts+++ b/apps/desktop/src/shared/piRuntimeInitialization.ts@@ -11,6 +11,7 @@ export function savedCustomProviderModelShape(id: model.id.trim(),name: model.name.trim(),...(includePiCapabilities && model.piApi ? { piApi: model.piApi } : {}),+ ...(model.route ? { route: { ...model.route } } : {}),...(model.contextWindow !== undefined ? { contextWindow: model.contextWindow } : {}),...(model.defaultEnabled === false ? { defaultEnabled: false } : {}),...(includePiCapabilities && model.supportsImageInput === true