agent功能开发增加MCP后端
This commit is contained in:
@@ -114,7 +114,7 @@ const AgentChatV3 = () => {
|
||||
setIsLoadingSessions(true);
|
||||
try {
|
||||
const response = await axios.get('/mcp/agent/sessions', {
|
||||
params: { user_id: user.id, limit: 50 },
|
||||
params: { user_id: String(user.id), limit: 50 },
|
||||
});
|
||||
|
||||
if (response.data.success) {
|
||||
@@ -220,8 +220,16 @@ const AgentChatV3 = () => {
|
||||
const handleSendMessage = async () => {
|
||||
if (!inputValue.trim() || isProcessing) return;
|
||||
|
||||
// 权限检查
|
||||
if (user?.id !== 'max') {
|
||||
// 权限检查 - 检查 username 或 id
|
||||
const isMaxUser = user?.username === 'max' || user?.id === 'max' || user?.id === 1;
|
||||
|
||||
if (!isMaxUser) {
|
||||
logger.warn('AgentChat', '权限检查失败', {
|
||||
userId: user?.id,
|
||||
username: user?.username,
|
||||
userObject: user
|
||||
});
|
||||
|
||||
toast({
|
||||
title: '权限不足',
|
||||
description: '「价小前投研」功能目前仅对特定用户开放。如需使用,请联系管理员。',
|
||||
@@ -232,6 +240,8 @@ const AgentChatV3 = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info('AgentChat', '权限检查通过', { userId: user?.id, username: user?.username });
|
||||
|
||||
const userMessage = {
|
||||
type: MessageTypes.USER,
|
||||
content: inputValue,
|
||||
@@ -266,8 +276,8 @@ const AgentChatV3 = () => {
|
||||
isUser: m.type === MessageTypes.USER,
|
||||
content: m.content,
|
||||
})),
|
||||
user_id: user?.id || 'anonymous',
|
||||
user_nickname: user?.nickname || '匿名用户',
|
||||
user_id: user?.id ? String(user.id) : 'anonymous',
|
||||
user_nickname: user?.nickname || user?.username || '匿名用户',
|
||||
user_avatar: user?.avatar || '',
|
||||
session_id: currentSessionId,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user