@@ -42,7 +42,6 @@ import {
4242 catalogModelToAlias ,
4343 catalogProviderModels ,
4444 CatalogFetchError ,
45- DEFAULT_CATALOG_URL ,
4645 fetchCatalog ,
4746 inferWireType ,
4847 loadBuiltInCatalog ,
@@ -224,6 +223,7 @@ import {
224223import { formatBackgroundAgentTranscript } from './utils/background-agent-status' ;
225224import { formatBackgroundTaskTranscript } from './utils/background-task-status' ;
226225import { hasDispose , isExpandable , isPlanExpandable } from './utils/component-capabilities' ;
226+ import { resolveConnectCatalogRequest } from './utils/connect-catalog' ;
227227import {
228228 argsRecord ,
229229 formatErrorMessage ,
@@ -4344,6 +4344,7 @@ export class KimiTUI {
43444344 selectedValue,
43454345 currentThinking : this . state . appState . thinking ,
43464346 colors : this . state . theme . colors ,
4347+ searchable : true ,
43474348 onSelect : ( { alias, thinking } ) => {
43484349 this . restoreEditor ( ) ;
43494350 void this . performModelSwitch ( alias , thinking ) ;
@@ -5064,10 +5065,7 @@ export class KimiTUI {
50645065 // (context size, capabilities) comes from the catalog, so users do not
50655066 // hand-write it.
50665067 private async handleConnectCommand ( args : string ) : Promise < void > {
5067- const trimmed = args . trim ( ) ;
5068- const urlMatch = trimmed . match ( / - - u r l (?: = | \s + ) ( \S + ) / ) ;
5069- const url =
5070- urlMatch ?. [ 1 ] ?? ( / ^ h t t p s ? : \/ \/ \S + $ / . test ( trimmed ) ? trimmed : DEFAULT_CATALOG_URL ) ;
5068+ const { url, allowBuiltInFallback } = resolveConnectCatalogRequest ( args ) ;
50715069
50725070 const controller = new AbortController ( ) ;
50735071 const cancel = ( ) : void => {
@@ -5085,13 +5083,18 @@ export class KimiTUI {
50855083 spinner . stop ( { ok : false , label : 'Aborted.' } ) ;
50865084 } else {
50875085 const hint = error instanceof CatalogFetchError ? ` (HTTP ${ error . status } )` : '' ;
5088- const fallback = loadBuiltInCatalog ( BUILT_IN_CATALOG_JSON ) ;
5089- if ( fallback !== undefined ) {
5090- spinner . stop ( { ok : true , label : 'Using built-in catalog (offline mode).' } ) ;
5091- catalog = fallback ;
5092- } else {
5086+ if ( ! allowBuiltInFallback ) {
50935087 spinner . stop ( { ok : false , label : 'Failed to load catalog.' } ) ;
50945088 this . showError ( `Failed to fetch catalog${ hint } : ${ formatErrorMessage ( error ) } ` ) ;
5089+ } else {
5090+ const fallback = loadBuiltInCatalog ( BUILT_IN_CATALOG_JSON ) ;
5091+ if ( fallback !== undefined ) {
5092+ spinner . stop ( { ok : true , label : 'Using built-in catalog (offline mode).' } ) ;
5093+ catalog = fallback ;
5094+ } else {
5095+ spinner . stop ( { ok : false , label : 'Failed to load catalog.' } ) ;
5096+ this . showError ( `Failed to fetch catalog${ hint } : ${ formatErrorMessage ( error ) } ` ) ;
5097+ }
50955098 }
50965099 }
50975100 } finally {
@@ -5118,6 +5121,7 @@ export class KimiTUI {
51185121 if ( apiKey === undefined ) return ;
51195122
51205123 const wire = inferWireType ( entry ) ;
5124+ if ( wire === undefined ) return ;
51215125 const baseUrl = catalogBaseUrl ( entry , wire ) ;
51225126
51235127 // Remove stale provider config first so old model aliases are fully
@@ -5258,6 +5262,7 @@ export class KimiTUI {
52585262 private promptCatalogProviderSelection ( catalog : Catalog ) : Promise < string | undefined > {
52595263 return new Promise ( ( resolve ) => {
52605264 const options : ChoiceOption [ ] = Object . entries ( catalog )
5265+ . filter ( ( [ , entry ] ) => inferWireType ( entry ) !== undefined )
52615266 . map ( ( [ id , entry ] ) => ( {
52625267 value : id ,
52635268 label : entry . name ?? id ,
@@ -5349,6 +5354,7 @@ export class KimiTUI {
53495354 currentValue : firstAlias ,
53505355 currentThinking : initialThinking ,
53515356 colors : this . state . theme . colors ,
5357+ searchable : true ,
53525358 onSelect : ( { alias, thinking } ) => {
53535359 this . restoreEditor ( ) ;
53545360 resolve ( { alias, thinking } ) ;
0 commit comments