diff --git a/packages/cli/src/ui/components/ApiKeyInput.tsx b/packages/cli/src/ui/components/ApiKeyInput.tsx deleted file mode 100644 index c1d7d1ae4ae..00000000000 --- a/packages/cli/src/ui/components/ApiKeyInput.tsx +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @license - * Copyright 2025 Qwen Team - * SPDX-License-Identifier: Apache-2.0 - */ - -import type React from 'react'; -import { useState } from 'react'; -import { Box, Text } from 'ink'; -import { TextInput } from './shared/TextInput.js'; -import { theme } from '../semantic-colors.js'; -import { useKeypress } from '../hooks/useKeypress.js'; -import { t } from '../../i18n/index.js'; -import Link from 'ink-link'; - -export interface ApiKeyInputPlan { - apiKeyUrl: string; - helpText: string; - placeholder: string; - validate?: (apiKey: string) => string | null; -} - -interface ApiKeyInputProps { - onSubmit: (apiKey: string) => void; - onCancel: () => void; - plan: ApiKeyInputPlan; -} - -export const CODING_PLAN_API_KEY_URL = - 'https://bailian.console.aliyun.com/?tab=model#/efm/coding_plan'; - -export const CODING_PLAN_INTL_API_KEY_URL = - 'https://modelstudio.console.alibabacloud.com/?tab=dashboard#/efm/coding_plan'; - -export const TOKEN_PLAN_API_KEY_URL = - 'https://bailian.console.aliyun.com/cn-beijing?tab=doc#/doc/?type=model&url=3028856'; - -export function ApiKeyInput({ - onSubmit, - onCancel, - plan, -}: ApiKeyInputProps): React.JSX.Element { - const [apiKey, setApiKey] = useState(''); - const [error, setError] = useState(null); - - useKeypress( - (key) => { - if (key.name === 'escape') { - onCancel(); - } else if (key.name === 'return') { - const trimmedKey = apiKey.trim(); - if (!trimmedKey) { - setError(t('API key cannot be empty.')); - return; - } - const validationError = plan.validate?.(trimmedKey); - if (validationError) { - setError(validationError); - return; - } - onSubmit(trimmedKey); - } - }, - { isActive: true }, - ); - - return ( - - - {error && ( - - {error} - - )} - - {plan.helpText} - - - - - {plan.apiKeyUrl} - - - - - - {t('Enter to submit, Esc to go back')} - - - - ); -}