/** * @license * Copyright 2025 Qwen * SPDX-License-Identifier: Apache-2.0 */ import { Box, Text } from 'ink'; import { theme } from '../../../semantic-colors.js'; import { useKeypress } from '../../../hooks/useKeypress.js'; import { t } from '../../../../i18n/index.js'; import type { ToolDetailStepProps } from '../types.js'; export const ToolDetailStep: React.FC = ({ tool, onBack, }) => { useKeypress( (key) => { if (key.name === 'escape') { onBack(); } }, { isActive: true }, ); if (!tool) { return ( {t('No tool selected')} ); } // 格式化schema显示 const formatSchema = (schema: object | undefined): string => { if (!schema) return t('No schema available'); return JSON.stringify(schema, null, 2); }; return ( {/* 工具名称 */} {tool.name} {/* 工具描述 */} {tool.description && ( {tool.description} )} {/* 工具注解 */} {tool.annotations && ( {t('Annotations:')} {tool.annotations.title && ( • {t('Title')}: {tool.annotations.title} )} {tool.annotations.readOnlyHint !== undefined && ( • {t('Read Only')}:{' '} {tool.annotations.readOnlyHint ? t('Yes') : t('No')} )} {tool.annotations.destructiveHint !== undefined && ( • {t('Destructive')}:{' '} {tool.annotations.destructiveHint ? t('Yes') : t('No')} )} {tool.annotations.idempotentHint !== undefined && ( • {t('Idempotent')}:{' '} {tool.annotations.idempotentHint ? t('Yes') : t('No')} )} {tool.annotations.openWorldHint !== undefined && ( • {t('Open World')}:{' '} {tool.annotations.openWorldHint ? t('Yes') : t('No')} )} )} {/* Schema */} {t('Schema:')} {formatSchema(tool.schema)} {/* 所属服务器 */} {t('Server')}: {tool.serverName} ); };