erosolar-cli 2.1.206 → 2.1.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -463,9 +463,68 @@ export class InteractiveShell {
463
463
  else {
464
464
  display.stream(`\n${lines}\n`);
465
465
  }
466
+ // Check if the current provider's API key is missing and show directions
467
+ await this.checkAndShowApiKeyWarning();
466
468
  // Keep UI pinned; no scrollback banners
467
469
  this.requestPromptRefresh(true);
468
470
  }
471
+ /**
472
+ * Check if the current provider's API key is configured.
473
+ * If not, show a warning with directions on how to get one.
474
+ */
475
+ async checkAndShowApiKeyWarning() {
476
+ const provider = this.sessionState.provider;
477
+ const apiKeyEnvVar = this.getApiKeyEnvVarForProvider(provider);
478
+ if (!apiKeyEnvVar) {
479
+ // Provider doesn't require an API key (e.g., Ollama)
480
+ return;
481
+ }
482
+ const hasKey = process.env[apiKeyEnvVar]?.trim();
483
+ if (hasKey) {
484
+ return;
485
+ }
486
+ const url = this.getApiKeyPortalLink(null, provider);
487
+ const providerLabel = this.providerLabel(provider);
488
+ const warning = [
489
+ '',
490
+ theme.warning(`⚠️ ${providerLabel} API key not configured`),
491
+ '',
492
+ ` To use ${this.sessionState.model}, you need a ${providerLabel} API key.`,
493
+ '',
494
+ ` 1. Get your API key at: ${theme.accent(url || 'the provider\'s website')}`,
495
+ ` 2. Run ${theme.info('/secrets')} to configure it`,
496
+ ` 3. Or set ${theme.bold(apiKeyEnvVar)} in your environment`,
497
+ '',
498
+ ].join('\n');
499
+ if (this.renderer) {
500
+ this.renderer.addEvent('banner', warning);
501
+ await this.renderer.flushEvents();
502
+ }
503
+ else {
504
+ display.stream(warning);
505
+ }
506
+ }
507
+ /**
508
+ * Get the environment variable name for a provider's API key.
509
+ */
510
+ getApiKeyEnvVarForProvider(provider) {
511
+ switch (provider) {
512
+ case 'openai':
513
+ return 'OPENAI_API_KEY';
514
+ case 'anthropic':
515
+ return 'ANTHROPIC_API_KEY';
516
+ case 'deepseek':
517
+ return 'DEEPSEEK_API_KEY';
518
+ case 'xai':
519
+ return 'XAI_API_KEY';
520
+ case 'google':
521
+ return 'GEMINI_API_KEY';
522
+ case 'ollama':
523
+ return null; // Ollama doesn't require an API key
524
+ default:
525
+ return null;
526
+ }
527
+ }
469
528
  describeSessionLabel() {
470
529
  if (this.sessionRestoreConfig.mode === 'autosave')
471
530
  return 'resume (autosave)';