Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(providers): 共用订阅参考价并清理不可用媒体目录
Dash01a7c0c10466
diff --git a/apps/desktop/src/main/usage/__tests__/accountReferencePrice.test.ts b/apps/desktop/src/main/usage/__tests__/accountReferencePrice.test.tsindex bf63f880b1..479bb0fa6a 100644--- a/apps/desktop/src/main/usage/__tests__/accountReferencePrice.test.ts+++ b/apps/desktop/src/main/usage/__tests__/accountReferencePrice.test.ts@@ -6,6 +6,13 @@ vi.mock('../../maker-host/active-catalog.js', () => ({getActiveCatalog: () => ({ ...BUNDLED_CATALOG, providers: [buildUserProvider({id: 'openai-account', name: 'Account', auth: { method: 'oauth', native: 'codex' },runtimes: { codex: { baseUrl: 'https://chatgpt.com/backend-api/codex', models: [{ id: 'gpt-5.6-luna', name: 'Luna' }] } },+ }), ...(['claude', 'xai'] as const).map(native => {+ const provider = buildUserProvider({+ id: `${native}-account`, name: 'Account', auth: { method: 'oauth', native }, runtimes: {},+ });+ // The active catalog fills Claude membership from account discovery.+ if (native === 'claude') provider.models.codex = [{ id: 'claude-sonnet-4-6', name: 'Sonnet', contextWindow: 200000, efforts: [], defaultEffort: null }];+ return provider;})] }),}));vi.mock('../modelPriceOverrideStore.js', () => ({@@ -17,7 +24,21 @@ vi.mock('../modelPriceOverrideStore.js', () => ({import { accountReferencePriceQuote } from '../accountReferencePrice.js';import { getReferenceModelPricing, getCodexProviderSubscriptionValuePrice } from '../referenceModelPricing.js';-describe('independent OpenAI account reference prices', () => {+describe('independent subscription account reference prices', () => {+ it.each([+ ['claude', 'anthropic', 'claude-sonnet-4-6'],+ ['xai', 'xai', 'xai/grok-4.6'],+ ])('shares %s public tariffs without changing account attribution', (native, publicId, modelId) => {+ const options = { agent: 'codex' as const, at: '2026-09-09' };+ const base = providerReferencePriceQuote(publicId, modelId, BUNDLED_CATALOG.modelRegistry, options);+ expect(base).toBeDefined();+ const actual = accountReferencePriceQuote(`${native}-account`, modelId, BUNDLED_CATALOG.modelRegistry, options);+ expect(actual).toEqual({ ...base, providerId: `${native}-account`, modelId });+ expect(getCodexProviderSubscriptionValuePrice(`${native}-account`, modelId, {}, options.at)).toEqual(actual);+ expect(getModelPriceQuote(getReferenceModelPricing(), `${native}-account`, modelId, 'codex')).toMatchObject({+ providerId: `${native}-account`, modelId, source: 'provider-reference',+ });+ });it('shares historical public tariffs without changing account attribution', () => {const options = { agent: 'codex' as const, at: '2026-09-09' };const base = providerReferencePriceQuote('openai', 'gpt-5.6-luna', BUNDLED_CATALOG.modelRegistry, options);diff --git a/apps/desktop/src/main/usage/accountReferencePrice.ts b/apps/desktop/src/main/usage/accountReferencePrice.tsindex 2cecc2b413..74eca56ab6 100644--- a/apps/desktop/src/main/usage/accountReferencePrice.ts+++ b/apps/desktop/src/main/usage/accountReferencePrice.ts@@ -1,15 +1,15 @@+import { providerCatalogId } from '@cindy/model-providers';import { providerReferencePriceQuote } from '../../shared/modelPriceQuote.js';import { getActiveCatalog } from '../maker-host/active-catalog.js';-/** Share public OpenAI tariffs while keeping each account's overrides and attribution separate. */+/** Share public tariffs while keeping each account's overrides and attribution separate. */export const accountReferencePriceQuote: typeof providerReferencePriceQuote = (providerId, modelId, registry, options,) => {- const independent = getActiveCatalog().providers.some(- provider => provider.id === providerId && provider.auth?.native === 'codex',- );+ const provider = getActiveCatalog().providers.find(provider => provider.id === providerId);+ const catalogId = provider ? providerCatalogId(provider) : providerId;const quote = providerReferencePriceQuote(- independent ? 'openai' : providerId, modelId, registry, options,+ catalogId, modelId, registry, options,);- return quote && independent ? { ...quote, providerId, modelId } : quote;+ return quote && catalogId !== providerId ? { ...quote, providerId, modelId } : quote;};diff --git a/apps/desktop/src/main/usage/referenceModelPricing.ts b/apps/desktop/src/main/usage/referenceModelPricing.tsindex 2266030e64..9bdfbddbf1 100644--- a/apps/desktop/src/main/usage/referenceModelPricing.ts+++ b/apps/desktop/src/main/usage/referenceModelPricing.ts@@ -34,7 +34,7 @@ export function getReferenceModelPricing(): ModelPricingCatalog {const registry = catalog.modelRegistry;const pricing = registryPricingCatalog(registry);for (const provider of catalog.providers) {- if (provider.auth?.native !== 'codex') continue;+ if (provider.auth?.method !== 'oauth' || !provider.auth.native) continue;for (const [agent, models] of Object.entries(provider.models)) {for (const model of models ?? []) {const quote = providerReferencePriceQuote(provider.id, model.id, registry, { agent: agent as AgentKind });diff --git a/packages/model-providers/src/__tests__/user-provider.test.ts b/packages/model-providers/src/__tests__/user-provider.test.tsindex 9c6ccdc24d..494d6d1e20 100644--- a/packages/model-providers/src/__tests__/user-provider.test.ts+++ b/packages/model-providers/src/__tests__/user-provider.test.ts@@ -39,6 +39,10 @@ describe('native subscription instances', () => {expect(a.models).toEqual(b.models);for (const agent of a.agents) expect(a.routing[agent]?.authStrategy).toBe('provider-oauth-header');expect(a.auth.native).toBe(native);+ expect(a.imageModels).toBeUndefined();+ expect(a.imageDefaults).toBeUndefined();+ expect(a.videoModels).toBeUndefined();+ expect(a.videoDefaults).toBeUndefined();});});diff --git a/packages/model-providers/src/user-provider.ts b/packages/model-providers/src/user-provider.tsindex 4c27a802a2..bf012fdeee 100644--- a/packages/model-providers/src/user-provider.ts+++ b/packages/model-providers/src/user-provider.ts@@ -509,6 +509,9 @@ export function buildUserProvider(])),// Media remains explicitly bound to the original provider until it supports account selection.imageModels: undefined,+ imageDefaults: undefined,+ videoModels: undefined,+ videoDefaults: undefined,};}if (nativeCodex) {