@@ -46,7 +46,6 @@ export const providerProfilesSchema = z.object({
4646 openAiHeadersMigrated : z . boolean ( ) . optional ( ) ,
4747 consecutiveMistakeLimitMigrated : z . boolean ( ) . optional ( ) ,
4848 todoListEnabledMigrated : z . boolean ( ) . optional ( ) ,
49- zaiApiLineCodingOnlyMigrated : z . boolean ( ) . optional ( ) ,
5049 } )
5150 . optional ( ) ,
5251} )
@@ -71,7 +70,6 @@ export class ProviderSettingsManager {
7170 openAiHeadersMigrated : true , // Mark as migrated on fresh installs
7271 consecutiveMistakeLimitMigrated : true , // Mark as migrated on fresh installs
7372 todoListEnabledMigrated : true , // Mark as migrated on fresh installs
74- zaiApiLineCodingOnlyMigrated : true , // Mark as migrated on fresh installs
7573 } ,
7674 }
7775
@@ -178,15 +176,6 @@ export class ProviderSettingsManager {
178176 isDirty = true
179177 }
180178
181- // Migrate Z AI api line to coding-only options
182- if ( ! providerProfiles . migrations . zaiApiLineCodingOnlyMigrated ) {
183- const changed = await this . migrateZaiApiLineCodingOnly ( providerProfiles )
184- if ( changed ) {
185- providerProfiles . migrations . zaiApiLineCodingOnlyMigrated = true
186- isDirty = true
187- }
188- }
189-
190179 if ( isDirty ) {
191180 await this . store ( providerProfiles )
192181 }
@@ -584,9 +573,7 @@ export class ProviderSettingsManager {
584573
585574 const apiConfigs = Object . entries ( providerProfiles . apiConfigs ) . reduce (
586575 ( acc , [ key , apiConfig ] ) => {
587- // Preprocess legacy settings before validation (e.g., Z AI api line)
588- const processed = this . preprocessLegacySettings ( apiConfig )
589- const result = providerSettingsWithIdSchema . safeParse ( processed )
576+ const result = providerSettingsWithIdSchema . safeParse ( apiConfig )
590577 return result . success ? { ...acc , [ key ] : result . data } : acc
591578 } ,
592579 { } as Record < string , ProviderSettingsWithId > ,
@@ -618,50 +605,6 @@ export class ProviderSettingsManager {
618605 }
619606 }
620607
621- /**
622- * Preprocess legacy settings objects before schema validation.
623- * For example, coerce deprecated Z AI api lines to coding-only variants.
624- */
625- private preprocessLegacySettings ( apiConfig : any ) : any {
626- try {
627- if ( apiConfig && apiConfig . apiProvider === "zai" ) {
628- const line = apiConfig . zaiApiLine
629- if ( line === "international" || line === "intl_standard" ) {
630- apiConfig . zaiApiLine = "international_coding"
631- } else if ( line === "china" || line === "china_standard" ) {
632- apiConfig . zaiApiLine = "china_coding"
633- }
634- }
635- } catch {
636- // no-op
637- }
638- return apiConfig
639- }
640-
641- /**
642- * Migrate Z AI api line values to coding-only options across all profiles.
643- */
644- private async migrateZaiApiLineCodingOnly ( providerProfiles : ProviderProfiles ) : Promise < boolean > {
645- let changed = false
646- try {
647- for ( const [ _name , apiConfig ] of Object . entries ( providerProfiles . apiConfigs ) ) {
648- if ( ( apiConfig as any ) ?. apiProvider === "zai" ) {
649- const cfg = apiConfig as any
650- if ( cfg . zaiApiLine === "international" || cfg . zaiApiLine === "intl_standard" ) {
651- cfg . zaiApiLine = "international_coding"
652- changed = true
653- } else if ( cfg . zaiApiLine === "china" || cfg . zaiApiLine === "china_standard" ) {
654- cfg . zaiApiLine = "china_coding"
655- changed = true
656- }
657- }
658- }
659- } catch ( error ) {
660- console . error ( `[MigrateZaiApiLine] Failed to migrate Z AI api line settings:` , error )
661- }
662- return changed
663- }
664-
665608 private findUniqueProfileName ( baseName : string , existingNames : Set < string > ) : string {
666609 if ( ! existingNames . has ( baseName ) ) {
667610 return baseName
0 commit comments