@@ -45,6 +45,7 @@ type ModelManifestPlugins = ModelManifestNormalizationContext["manifestPlugins"]
4545
4646export type ModelAliasIndex = {
4747 byAlias : Map < string , { alias : string ; ref : ModelRef } > ;
48+ byProviderAlias ?: Map < string , { alias : string ; ref : ModelRef } > ;
4849 byKey : Map < string , string [ ] > ;
4950} ;
5051
@@ -63,6 +64,10 @@ type ExactConfiguredProviderRefParts = {
6364 modelRaw : string ;
6465} ;
6566
67+ function providerAliasKey ( provider : string , alias : string ) : string {
68+ return `${ normalizeProviderId ( provider ) } /${ normalizeLowercaseStringOrEmpty ( alias ) } ` ;
69+ }
70+
6671function hasSlashFormModelRef ( raw : string ) : boolean {
6772 const trimmed = raw . trim ( ) ;
6873 const slash = trimmed . indexOf ( "/" ) ;
@@ -554,10 +559,11 @@ function buildModelAliasIndexWithManifestContext(
554559 } ,
555560) : ModelAliasIndex {
556561 const byAlias = new Map < string , { alias : string ; ref : ModelRef } > ( ) ;
562+ const byProviderAlias = new Map < string , { alias : string ; ref : ModelRef } > ( ) ;
557563 const byKey = new Map < string , string [ ] > ( ) ;
558564 const aliasCandidates = listModelAliasCandidates ( params . cfg ) ;
559565 if ( aliasCandidates . length === 0 ) {
560- return { byAlias, byKey } ;
566+ return { byAlias, byProviderAlias , byKey } ;
561567 }
562568 const manifestPlugins = params . manifestPluginContext . get ( ) ;
563569
@@ -576,14 +582,18 @@ function buildModelAliasIndexWithManifestContext(
576582 continue ;
577583 }
578584 const aliasKey = normalizeLowercaseStringOrEmpty ( alias ) ;
579- byAlias . set ( aliasKey , { alias, ref : parsed } ) ;
585+ const match = { alias, ref : parsed } ;
586+ byAlias . set ( aliasKey , match ) ;
587+ // Bare aliases retain their existing last-wins behavior. Provider-qualified
588+ // aliases stay scoped so duplicate display names cannot select another provider.
589+ byProviderAlias . set ( providerAliasKey ( parsed . provider , alias ) , match ) ;
580590 const key = modelKey ( parsed . provider , parsed . model ) ;
581591 const existing = byKey . get ( key ) ?? [ ] ;
582592 existing . push ( alias ) ;
583593 byKey . set ( key , existing ) ;
584594 }
585595
586- return { byAlias, byKey } ;
596+ return { byAlias, byProviderAlias , byKey } ;
587597}
588598
589599/** Build lookup maps from user-facing aliases to normalized model refs. */
@@ -728,6 +738,15 @@ export function resolveModelRefFromString(
728738 if ( aliasMatch ) {
729739 return { ref : aliasMatch . ref , alias : aliasMatch . alias } ;
730740 }
741+ const slash = model . indexOf ( "/" ) ;
742+ if ( slash > 0 ) {
743+ const providerAliasMatch = params . aliasIndex ?. byProviderAlias ?. get (
744+ providerAliasKey ( model . slice ( 0 , slash ) , model . slice ( slash + 1 ) ) ,
745+ ) ;
746+ if ( providerAliasMatch ) {
747+ return { ref : providerAliasMatch . ref , alias : providerAliasMatch . alias } ;
748+ }
749+ }
731750 const parsed = parseModelRefWithCompatAlias ( {
732751 cfg : params . cfg ,
733752 raw : model ,
0 commit comments