@@ -99,15 +99,15 @@ function resolveConfiguredModelRaw(cfg: OpenClawConfig): string {
9999function resolveConfiguredModelKeys ( cfg : OpenClawConfig ) : string [ ] {
100100 const models = cfg . agents ?. defaults ?. models ?? { } ;
101101 return Object . keys ( models )
102- . map ( ( key ) => String ( key ?? "" ) . trim ( ) )
102+ . map ( ( key ) => key . trim ( ) )
103103 . filter ( ( key ) => key . length > 0 ) ;
104104}
105105
106106function normalizeModelKeys ( values : string [ ] ) : string [ ] {
107107 const seen = new Set < string > ( ) ;
108108 const next : string [ ] = [ ] ;
109109 for ( const raw of values ) {
110- const value = String ( raw ?? "" ) . trim ( ) ;
110+ const value = raw . trim ( ) ;
111111 if ( ! value || seen . has ( value ) ) {
112112 continue ;
113113 }
@@ -226,7 +226,7 @@ async function promptManualModel(params: {
226226 ? undefined
227227 : ( value ) => ( normalizeOptionalString ( value ) ? undefined : "Required" ) ,
228228 } ) ;
229- const model = String ( modelInput ?? "" ) . trim ( ) ;
229+ const model = ( modelInput ?? "" ) . trim ( ) ;
230230 if ( ! model ) {
231231 return { } ;
232232 }
@@ -532,10 +532,11 @@ export async function promptDefaultModel(
532532 options,
533533 initialValue,
534534 } ) ;
535- if ( selection === KEEP_VALUE ) {
535+ const selectedValue = selection ?? "" ;
536+ if ( selectedValue === KEEP_VALUE ) {
536537 return { } ;
537538 }
538- if ( selection === MANUAL_VALUE ) {
539+ if ( selectedValue === MANUAL_VALUE ) {
539540 return promptManualModel ( {
540541 prompter : params . prompter ,
541542 allowBlank : false ,
@@ -544,7 +545,7 @@ export async function promptDefaultModel(
544545 }
545546
546547 const providerPluginResult = await maybeHandleProviderPluginSelection ( {
547- selection : String ( selection ) ,
548+ selection : selectedValue ,
548549 cfg,
549550 prompter : params . prompter ,
550551 agentDir : params . agentDir ,
@@ -556,7 +557,7 @@ export async function promptDefaultModel(
556557 return providerPluginResult ;
557558 }
558559
559- const model = String ( selection ) ;
560+ const model = selectedValue ;
560561 const { runProviderModelSelectedHook } = await loadResolvedModelPickerRuntime ( ) ;
561562 await runProviderModelSelectedHook ( {
562563 config : cfg ,
@@ -610,7 +611,7 @@ export async function promptModelAllowlist(params: {
610611 initialValue : existingKeys . join ( ", " ) ,
611612 placeholder : "provider/model, other-provider/model" ,
612613 } ) ;
613- const parsed = String ( raw ?? "" )
614+ const parsed = ( raw ?? "" )
614615 . split ( "," )
615616 . map ( ( value ) => value . trim ( ) )
616617 . filter ( ( value ) => value . length > 0 ) ;
@@ -668,7 +669,7 @@ export async function promptModelAllowlist(params: {
668669 initialValues : initialKeys . length > 0 ? initialKeys : undefined ,
669670 searchable : true ,
670671 } ) ;
671- const selected = normalizeModelKeys ( selection . map ( ( value ) => String ( value ) ) ) ;
672+ const selected = normalizeModelKeys ( selection ) ;
672673 if ( selected . length > 0 ) {
673674 return { models : selected } ;
674675 }
0 commit comments