| 67 | ]; |
| 68 | |
| 69 | async function selectProvider(): Promise<string | symbol> { |
| 70 | const primaryOptions = PRIMARY_PROVIDERS.map((provider) => ({ |
| 71 | value: provider, |
| 72 | label: PROVIDER_DISPLAY_NAMES[provider] || provider |
| 73 | })); |
| 74 | |
| 75 | primaryOptions.push({ |
| 76 | value: 'other', |
| 77 | label: 'Other providers...' |
| 78 | }); |
| 79 | |
| 80 | const selection = await select({ |
| 81 | message: 'Select your AI provider:', |
| 82 | options: primaryOptions |
| 83 | }); |
| 84 | |
| 85 | if (isCancel(selection)) return selection; |
| 86 | |
| 87 | if (selection === 'other') { |
| 88 | const otherOptions = OTHER_PROVIDERS.map((provider) => ({ |
| 89 | value: provider, |
| 90 | label: PROVIDER_DISPLAY_NAMES[provider] || provider |
| 91 | })); |
| 92 | |
| 93 | return await select({ |
| 94 | message: 'Select provider:', |
| 95 | options: otherOptions |
| 96 | }); |
| 97 | } |
| 98 | |
| 99 | return selection; |
| 100 | } |
| 101 | |
| 102 | async function getApiKey(provider: string): Promise<string | symbol> { |
| 103 | const url = |