@@ -43,7 +43,7 @@ import {
4343} from './onboarding-ipc' ;
4444import { readPersisted as readPreferences , registerPreferencesIpc } from './preferences-ipc' ;
4545import { preparePromptContext } from './prompt-context' ;
46- import { resolveActiveModel } from './provider-settings' ;
46+ import { isKeylessProviderAllowed , resolveActiveModel } from './provider-settings' ;
4747import { safeInitSnapshotsDb } from './snapshots-db' ;
4848import { registerSnapshotsIpc , registerSnapshotsUnavailableIpc } from './snapshots-ipc' ;
4949
@@ -437,6 +437,7 @@ function registerIpcHandlers(): void {
437437 } catch {
438438 apiKey = '' ;
439439 }
440+ const allowKeyless = isKeylessProviderAllowed ( active . model . provider ) ;
440441 // Once we've snapped to the canonical active provider, the renderer-supplied
441442 // baseUrl can no longer be trusted — it may belong to a different (stale)
442443 // provider and would route the active provider's API key to the wrong host.
@@ -468,7 +469,7 @@ function registerIpcHandlers(): void {
468469 modelId : active . model . modelId ,
469470 } ;
470471 coreLogger . info ( '[generate] step=validate_provider' , stepCtx ) ;
471- if ( apiKey . length === 0 ) {
472+ if ( apiKey . length === 0 && ! allowKeyless ) {
472473 coreLogger . error ( '[generate] step=validate_provider.fail' , {
473474 provider : active . model . provider ,
474475 reason : 'missing_api_key' ,
@@ -518,6 +519,7 @@ function registerIpcHandlers(): void {
518519 ...( baseUrl !== undefined ? { baseUrl } : { } ) ,
519520 wire : active . wire ,
520521 ...( active . httpHeaders !== undefined ? { httpHeaders : active . httpHeaders } : { } ) ,
522+ ...( allowKeyless ? { allowKeyless : true } : { } ) ,
521523 signal : controller . signal ,
522524 logger : coreLogger ,
523525 } ,
@@ -575,6 +577,7 @@ function registerIpcHandlers(): void {
575577 } catch {
576578 apiKey = '' ;
577579 }
580+ const allowKeyless = isKeylessProviderAllowed ( active . model . provider ) ;
578581 // See codesign:v1:generate above — renderer baseUrl is ignored post-snap.
579582 const baseUrl = active . baseUrl ?? undefined ;
580583 if ( active . overridden ) {
@@ -617,6 +620,7 @@ function registerIpcHandlers(): void {
617620 ...( baseUrl !== undefined ? { baseUrl } : { } ) ,
618621 wire : active . wire ,
619622 ...( active . httpHeaders !== undefined ? { httpHeaders : active . httpHeaders } : { } ) ,
623+ ...( allowKeyless ? { allowKeyless : true } : { } ) ,
620624 signal : controller . signal ,
621625 } ,
622626 id ,
@@ -672,6 +676,7 @@ function registerIpcHandlers(): void {
672676 } catch {
673677 apiKey = '' ;
674678 }
679+ const allowKeyless = isKeylessProviderAllowed ( active . model . provider ) ;
675680 const baseUrl = active . baseUrl ?? undefined ;
676681 const promptContext = await preparePromptContext ( {
677682 attachments : payload . attachments ,
@@ -706,6 +711,7 @@ function registerIpcHandlers(): void {
706711 ...( baseUrl !== undefined ? { baseUrl } : { } ) ,
707712 wire : active . wire ,
708713 ...( active . httpHeaders !== undefined ? { httpHeaders : active . httpHeaders } : { } ) ,
714+ ...( allowKeyless ? { allowKeyless : true } : { } ) ,
709715 } ) ;
710716 logIpc . info ( 'applyComment.ok' , {
711717 ms : Date . now ( ) - t0 ,
@@ -740,7 +746,13 @@ function registerIpcHandlers(): void {
740746 provider : cfg . activeProvider ,
741747 modelId : cfg . activeModel ,
742748 } ) ;
743- const apiKey = getApiKeyForProvider ( active . model . provider ) ;
749+ let apiKey : string ;
750+ try {
751+ apiKey = getApiKeyForProvider ( active . model . provider ) ;
752+ } catch {
753+ apiKey = '' ;
754+ }
755+ const allowKeyless = isKeylessProviderAllowed ( active . model . provider ) ;
744756 const baseUrl = active . baseUrl ?? undefined ;
745757 return generateTitle ( {
746758 prompt,
@@ -749,6 +761,7 @@ function registerIpcHandlers(): void {
749761 ...( baseUrl !== undefined ? { baseUrl } : { } ) ,
750762 wire : active . wire ,
751763 ...( active . httpHeaders !== undefined ? { httpHeaders : active . httpHeaders } : { } ) ,
764+ ...( allowKeyless ? { allowKeyless : true } : { } ) ,
752765 } ) ;
753766 } ) ;
754767
0 commit comments