Files
vf_react/src/views/AgentChat/constants/tools.ts
2025-12-16 12:31:31 +08:00

505 lines
16 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// src/views/AgentChat/constants/tools.ts
// MCP 工具配置
import * as React from 'react';
import {
Globe,
Newspaper,
Activity,
PieChart,
FileText,
BarChart3,
LineChart,
TrendingUp,
Calendar,
BookOpen,
Briefcase,
DollarSign,
Search,
Users,
// 量化工具图标
TrendingDown,
BarChart2,
Gauge,
Flame,
ArrowUpDown,
Waves,
Target,
CandlestickChart,
Sparkles,
ShieldAlert,
Calculator,
Zap,
Percent,
GitCompare,
Shuffle,
Brain,
Combine,
Scale,
} from 'lucide-react';
/**
* 工具类别枚举
*/
export enum ToolCategory {
NEWS = '新闻资讯',
CONCEPT = '概念板块',
LIMIT_UP = '涨停分析',
RESEARCH = '研报路演',
STOCK_DATA = '股票数据',
USER_DATA = '用户数据',
// 量化分析类别
QUANT_CLASSIC = '经典技术指标',
QUANT_VOLUME = '资金与情绪',
QUANT_PATTERN = '形态与突破',
QUANT_RISK = '风险与估值',
QUANT_MINUTE = '分钟级算子',
QUANT_TREND = '高级趋势',
QUANT_LIQUIDITY = '流动性统计',
QUANT_STRATEGY = '配对与策略',
}
/**
* MCP 工具配置接口
*/
export interface MCPTool {
/** 工具唯一标识 */
id: string;
/** 工具显示名称 */
name: string;
/** 工具图标React 元素)*/
icon: React.ReactNode;
/** 工具类别 */
category: ToolCategory;
/** 工具描述 */
description: string;
}
/**
* MCP 工具完整配置列表
* 包含所有可供 Agent 调用的工具
*/
export const MCP_TOOLS: MCPTool[] = [
// ==================== 新闻搜索类 ====================
{
id: 'search_news',
name: '全球新闻搜索',
icon: React.createElement(Globe, { className: 'w-4 h-4' }),
category: ToolCategory.NEWS,
description: '搜索全球新闻,支持关键词和日期过滤',
},
{
id: 'search_china_news',
name: '中国新闻搜索',
icon: React.createElement(Newspaper, { className: 'w-4 h-4' }),
category: ToolCategory.NEWS,
description: 'KNN语义搜索中国新闻',
},
{
id: 'search_medical_news',
name: '医疗健康新闻',
icon: React.createElement(Activity, { className: 'w-4 h-4' }),
category: ToolCategory.NEWS,
description: '医药、医疗设备、生物技术新闻',
},
// ==================== 概念板块类 ====================
{
id: 'search_concepts',
name: '概念板块搜索',
icon: React.createElement(PieChart, { className: 'w-4 h-4' }),
category: ToolCategory.CONCEPT,
description: '搜索股票概念板块及相关股票',
},
{
id: 'get_concept_details',
name: '概念详情',
icon: React.createElement(FileText, { className: 'w-4 h-4' }),
category: ToolCategory.CONCEPT,
description: '获取概念板块详细信息',
},
{
id: 'get_stock_concepts',
name: '股票概念',
icon: React.createElement(BarChart3, { className: 'w-4 h-4' }),
category: ToolCategory.CONCEPT,
description: '查询股票相关概念板块',
},
{
id: 'get_concept_statistics',
name: '概念统计',
icon: React.createElement(LineChart, { className: 'w-4 h-4' }),
category: ToolCategory.CONCEPT,
description: '涨幅榜、跌幅榜、活跃榜等',
},
// ==================== 涨停分析类 ====================
{
id: 'search_limit_up_stocks',
name: '涨停股票搜索',
icon: React.createElement(TrendingUp, { className: 'w-4 h-4' }),
category: ToolCategory.LIMIT_UP,
description: '搜索涨停股票,支持多条件筛选',
},
{
id: 'get_daily_stock_analysis',
name: '涨停日报',
icon: React.createElement(Calendar, { className: 'w-4 h-4' }),
category: ToolCategory.LIMIT_UP,
description: '每日涨停股票分析报告',
},
// ==================== 研报路演类 ====================
{
id: 'search_research_reports',
name: '研报搜索',
icon: React.createElement(BookOpen, { className: 'w-4 h-4' }),
category: ToolCategory.RESEARCH,
description: '搜索研究报告,支持语义搜索',
},
{
id: 'search_roadshows',
name: '路演活动',
icon: React.createElement(Briefcase, { className: 'w-4 h-4' }),
category: ToolCategory.RESEARCH,
description: '上市公司路演、投资者交流活动',
},
// ==================== 股票数据类 ====================
{
id: 'get_stock_basic_info',
name: '股票基本信息',
icon: React.createElement(FileText, { className: 'w-4 h-4' }),
category: ToolCategory.STOCK_DATA,
description: '公司名称、行业、主营业务等',
},
{
id: 'get_stock_financial_index',
name: '财务指标',
icon: React.createElement(DollarSign, { className: 'w-4 h-4' }),
category: ToolCategory.STOCK_DATA,
description: 'EPS、ROE、营收增长率等',
},
{
id: 'get_stock_trade_data',
name: '交易数据',
icon: React.createElement(BarChart3, { className: 'w-4 h-4' }),
category: ToolCategory.STOCK_DATA,
description: '价格、成交量、涨跌幅等',
},
{
id: 'get_stock_balance_sheet',
name: '资产负债表',
icon: React.createElement(PieChart, { className: 'w-4 h-4' }),
category: ToolCategory.STOCK_DATA,
description: '资产、负债、所有者权益',
},
{
id: 'get_stock_cashflow',
name: '现金流量表',
icon: React.createElement(LineChart, { className: 'w-4 h-4' }),
category: ToolCategory.STOCK_DATA,
description: '经营、投资、筹资现金流',
},
{
id: 'search_stocks_by_criteria',
name: '条件选股',
icon: React.createElement(Search, { className: 'w-4 h-4' }),
category: ToolCategory.STOCK_DATA,
description: '按行业、地区、市值筛选',
},
{
id: 'get_stock_comparison',
name: '股票对比',
icon: React.createElement(BarChart3, { className: 'w-4 h-4' }),
category: ToolCategory.STOCK_DATA,
description: '多只股票财务指标对比',
},
// ==================== 用户数据类 ====================
{
id: 'get_user_watchlist',
name: '自选股列表',
icon: React.createElement(Users, { className: 'w-4 h-4' }),
category: ToolCategory.USER_DATA,
description: '用户关注的股票及行情',
},
{
id: 'get_user_following_events',
name: '关注事件',
icon: React.createElement(Activity, { className: 'w-4 h-4' }),
category: ToolCategory.USER_DATA,
description: '用户关注的重大事件',
},
// ==================== 量化工具:经典技术指标 ====================
{
id: 'get_macd_signal',
name: 'MACD信号',
icon: React.createElement(TrendingUp, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_CLASSIC,
description: 'MACD金叉/死叉、动能分析、背离检测',
},
{
id: 'check_oscillator_status',
name: 'RSI/KDJ指标',
icon: React.createElement(Gauge, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_CLASSIC,
description: 'RSI + KDJ 超买超卖分析',
},
{
id: 'analyze_bollinger_bands',
name: '布林带分析',
icon: React.createElement(ArrowUpDown, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_CLASSIC,
description: '带宽、位置、收窄判断',
},
{
id: 'calc_stop_loss_atr',
name: 'ATR止损计算',
icon: React.createElement(ShieldAlert, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_CLASSIC,
description: '基于ATR的动态止损位计算',
},
// ==================== 量化工具:资金与情绪 ====================
{
id: 'analyze_market_heat',
name: '市场热度分析',
icon: React.createElement(Flame, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_VOLUME,
description: '换手率热度分级 + OBV趋势',
},
{
id: 'check_volume_price_divergence',
name: '量价背离检测',
icon: React.createElement(GitCompare, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_VOLUME,
description: '价量不匹配异常检测',
},
{
id: 'analyze_obv_trend',
name: 'OBV能量潮',
icon: React.createElement(Waves, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_VOLUME,
description: 'OBV独立分析+背离检测',
},
// ==================== 量化工具:形态与突破 ====================
{
id: 'check_new_high_breakout',
name: '新高突破检测',
icon: React.createElement(Target, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_PATTERN,
description: '20/60日唐奇安通道新高突破',
},
{
id: 'identify_candlestick_pattern',
name: 'K线形态识别',
icon: React.createElement(CandlestickChart, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_PATTERN,
description: '10+种经典K线组合形态',
},
{
id: 'find_price_gaps',
name: '跳空缺口分析',
icon: React.createElement(Sparkles, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_PATTERN,
description: '未回补缺口筛选与分析',
},
// ==================== 量化工具:风险与估值 ====================
{
id: 'calc_max_drawdown',
name: '最大回撤计算',
icon: React.createElement(TrendingDown, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_RISK,
description: '含夏普比率的回撤分析',
},
{
id: 'check_valuation_rank',
name: 'PE估值百分位',
icon: React.createElement(Percent, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_RISK,
description: 'PE历史百分位 + PEG修正',
},
{
id: 'calc_price_zscore',
name: 'Z-Score乖离率',
icon: React.createElement(Calculator, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_RISK,
description: '价格偏离均值程度+回归概率',
},
// ==================== 量化工具:分钟级高阶算子 ====================
{
id: 'calc_market_profile_vpoc',
name: 'VPOC筹码峰',
icon: React.createElement(BarChart2, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_MINUTE,
description: '成交量密集区分析',
},
{
id: 'calc_realized_volatility',
name: '已实现波动率',
icon: React.createElement(Activity, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_MINUTE,
description: '分钟级RV精确波动率',
},
{
id: 'analyze_buying_pressure',
name: '买卖压力分析',
icon: React.createElement(Scale, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_MINUTE,
description: '主力意图捕捉与压力失衡',
},
{
id: 'calc_parkinson_volatility',
name: '帕金森波动率',
icon: React.createElement(Zap, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_MINUTE,
description: '基于High/Low的精确波动率',
},
// ==================== 量化工具:高级趋势分析 ====================
{
id: 'calc_bollinger_squeeze',
name: '布林带挤压',
icon: React.createElement(Combine, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_TREND,
description: '带宽历史百分位,变盘预警',
},
{
id: 'calc_trend_slope',
name: '趋势斜率分析',
icon: React.createElement(LineChart, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_TREND,
description: 'R²拟合度+斜率方向判断',
},
{
id: 'calc_hurst_exponent',
name: 'Hurst指数',
icon: React.createElement(Brain, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_TREND,
description: '趋势/均值回归特征判断',
},
{
id: 'decompose_trend_simple',
name: '趋势分解',
icon: React.createElement(Shuffle, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_TREND,
description: '趋势+周期+残差分解',
},
// ==================== 量化工具:流动性与统计 ====================
{
id: 'calc_amihud_illiquidity',
name: 'Amihud流动性',
icon: React.createElement(DollarSign, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_LIQUIDITY,
description: '大单冲击成本评估',
},
{
id: 'calc_price_entropy',
name: '价格熵值',
icon: React.createElement(Activity, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_LIQUIDITY,
description: '市场混乱度/可预测性分析',
},
{
id: 'calc_rsi_divergence',
name: 'RSI背离检测',
icon: React.createElement(GitCompare, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_LIQUIDITY,
description: 'RSI顶底背离独立分析',
},
// ==================== 量化工具:配对与策略 ====================
{
id: 'test_cointegration',
name: '协整性测试',
icon: React.createElement(Combine, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_STRATEGY,
description: '配对交易信号与对冲比率',
},
{
id: 'calc_kelly_position',
name: '凯利仓位计算',
icon: React.createElement(Calculator, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_STRATEGY,
description: '基于胜率盈亏比的最优仓位',
},
{
id: 'search_similar_kline',
name: '相似K线检索',
icon: React.createElement(Search, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_STRATEGY,
description: '历史形态匹配预测',
},
{
id: 'get_comprehensive_analysis',
name: '综合技术分析',
icon: React.createElement(BarChart3, { className: 'w-4 h-4' }),
category: ToolCategory.QUANT_STRATEGY,
description: '多指标汇总分析报告',
},
];
/**
* 按类别分组的工具配置
* 用于在 UI 中按类别展示工具
*/
export const TOOL_CATEGORIES: Record<ToolCategory, MCPTool[]> = {
[ToolCategory.NEWS]: MCP_TOOLS.filter((t) => t.category === ToolCategory.NEWS),
[ToolCategory.CONCEPT]: MCP_TOOLS.filter((t) => t.category === ToolCategory.CONCEPT),
[ToolCategory.LIMIT_UP]: MCP_TOOLS.filter((t) => t.category === ToolCategory.LIMIT_UP),
[ToolCategory.RESEARCH]: MCP_TOOLS.filter((t) => t.category === ToolCategory.RESEARCH),
[ToolCategory.STOCK_DATA]: MCP_TOOLS.filter((t) => t.category === ToolCategory.STOCK_DATA),
[ToolCategory.USER_DATA]: MCP_TOOLS.filter((t) => t.category === ToolCategory.USER_DATA),
// 量化工具类别
[ToolCategory.QUANT_CLASSIC]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_CLASSIC),
[ToolCategory.QUANT_VOLUME]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_VOLUME),
[ToolCategory.QUANT_PATTERN]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_PATTERN),
[ToolCategory.QUANT_RISK]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_RISK),
[ToolCategory.QUANT_MINUTE]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_MINUTE),
[ToolCategory.QUANT_TREND]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_TREND),
[ToolCategory.QUANT_LIQUIDITY]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_LIQUIDITY),
[ToolCategory.QUANT_STRATEGY]: MCP_TOOLS.filter((t) => t.category === ToolCategory.QUANT_STRATEGY),
};
/**
* 量价相关工具 ID默认不选中
* 包括 QUANT_VOLUME 类别的工具
*/
const VOLUME_PRICE_TOOL_IDS = [
'analyze_market_heat', // 市场热度分析
'check_volume_price_divergence', // 量价背离检测
'analyze_obv_trend', // OBV能量潮
];
/**
* 默认选中的工具 ID 列表
* 排除量价相关工具(用户可手动选择启用)
*/
export const DEFAULT_SELECTED_TOOLS: string[] = MCP_TOOLS
.filter((tool) => !VOLUME_PRICE_TOOL_IDS.includes(tool.id))
.map((tool) => tool.id);
/**
* 根据 ID 查找工具配置
* @param toolId 工具 ID
* @returns 工具配置对象,未找到则返回 undefined
*/
export const findToolById = (toolId: string): MCPTool | undefined => {
return MCP_TOOLS.find((tool) => tool.id === toolId);
};
/**
* 根据类别获取工具列表
* @param category 工具类别
* @returns 该类别下的所有工具
*/
export const getToolsByCategory = (category: ToolCategory): MCPTool[] => {
return TOOL_CATEGORIES[category] || [];
};