refactor: rename direct tools to MCP tools across the codebase for consistency
This commit is contained in:
@@ -63,15 +63,15 @@ import { cn } from "@/lib/utils"
|
||||
|
||||
type RuntimeMode = "workflow" | "autonomous" | "hybrid"
|
||||
type SectionKey = "setup" | "persona" | "capability" | "service"
|
||||
type DirectToolItem = CreateAIAgentPayload["directTools"][number]
|
||||
type MCPToolItem = CreateAIAgentPayload["mcpTools"][number]
|
||||
|
||||
type DirectToolOption = {
|
||||
type MCPToolOption = {
|
||||
value: string
|
||||
label: string
|
||||
group: string
|
||||
subtitle: string
|
||||
description?: string
|
||||
meta: DirectToolItem
|
||||
meta: MCPToolItem
|
||||
}
|
||||
|
||||
const runtimeModes: {
|
||||
@@ -142,7 +142,7 @@ export function AIAgentConfigWorkbench({
|
||||
const [selectedTeamIds, setSelectedTeamIds] = useState<number[]>([])
|
||||
const [selectedSkillIds, setSelectedSkillIds] = useState<number[]>([])
|
||||
const [selectedKnowledgeBaseIds, setSelectedKnowledgeBaseIds] = useState<number[]>([])
|
||||
const [directTools, setDirectTools] = useState<DirectToolItem[]>([])
|
||||
const [mcpTools, setMCPTools] = useState<MCPToolItem[]>([])
|
||||
const [workflowBindings, setWorkflowBindings] = useState<AIAgentWorkflowBindingInput[]>([])
|
||||
|
||||
const [aiConfigs, setAIConfigs] = useState<AIConfig[]>([])
|
||||
@@ -197,7 +197,7 @@ export function AIAgentConfigWorkbench({
|
||||
setSelectedTeamIds([])
|
||||
setSelectedSkillIds([])
|
||||
setSelectedKnowledgeBaseIds([])
|
||||
setDirectTools([])
|
||||
setMCPTools([])
|
||||
setWorkflowBindings([])
|
||||
return
|
||||
}
|
||||
@@ -226,7 +226,7 @@ export function AIAgentConfigWorkbench({
|
||||
setSelectedTeamIds((detail.teams ?? []).map((team) => team.id))
|
||||
setSelectedSkillIds(detail.skillIds ?? [])
|
||||
setSelectedKnowledgeBaseIds(detail.knowledgeBaseIds ?? [])
|
||||
setDirectTools(detail.directTools ?? [])
|
||||
setMCPTools(detail.mcpTools ?? [])
|
||||
setWorkflowBindings(
|
||||
(detail.workflowBindings ?? []).map(
|
||||
({ workflowVersionId, toolName, triggerInstruction, priority, enabled }) => ({
|
||||
@@ -299,20 +299,14 @@ export function AIAgentConfigWorkbench({
|
||||
() => knowledgeBases.map((item) => ({ value: String(item.id), label: item.name })),
|
||||
[knowledgeBases],
|
||||
)
|
||||
const directToolOptions = useMemo<DirectToolOption[]>(
|
||||
const mcpToolOptions = useMemo<MCPToolOption[]>(
|
||||
() =>
|
||||
toolCatalog
|
||||
.filter(
|
||||
(tool) =>
|
||||
!tool.autoInjected &&
|
||||
(tool.sourceType === "mcp" ||
|
||||
tool.toolCode === "builtin/conversation_context" ||
|
||||
tool.toolCode === "graph/prepare_ticket_draft"),
|
||||
)
|
||||
.filter((tool) => !tool.autoInjected && tool.sourceType === "mcp")
|
||||
.map((tool) => ({
|
||||
value: tool.toolCode,
|
||||
label: tool.title || tool.toolName,
|
||||
group: tool.sourceType === "builtin" ? "内置工具" : tool.serverCode,
|
||||
group: tool.serverCode,
|
||||
subtitle: tool.toolCode,
|
||||
description: tool.description || undefined,
|
||||
meta: {
|
||||
@@ -348,10 +342,10 @@ export function AIAgentConfigWorkbench({
|
||||
setNext([...current, id])
|
||||
}
|
||||
|
||||
function setDirectToolSelection(values: string[]) {
|
||||
setDirectTools(
|
||||
function setMCPToolSelection(values: string[]) {
|
||||
setMCPTools(
|
||||
values.flatMap((value) => {
|
||||
const option = directToolOptions.find((item) => item.value === value)
|
||||
const option = mcpToolOptions.find((item) => item.value === value)
|
||||
return option ? [option.meta] : []
|
||||
}),
|
||||
)
|
||||
@@ -430,7 +424,7 @@ export function AIAgentConfigWorkbench({
|
||||
fallbackMessage: fallbackMessage.trim(),
|
||||
knowledgeBaseIds: uniqueNumbers(selectedKnowledgeBaseIds),
|
||||
skillIds: uniqueNumbers(selectedSkillIds),
|
||||
directTools,
|
||||
mcpTools,
|
||||
workflowBindings,
|
||||
}
|
||||
}
|
||||
@@ -775,16 +769,16 @@ export function AIAgentConfigWorkbench({
|
||||
</FormSection>
|
||||
|
||||
<FormSection
|
||||
title="Direct Tool"
|
||||
description="从工具分组中选择 Agent 可以直接调用的工具。"
|
||||
title="MCP Tool"
|
||||
description="选择允许 Agent 调用的 MCP Tool,选项与 MCP Tool 管理中的可用工具保持一致。"
|
||||
>
|
||||
<OptionCombobox
|
||||
multiple
|
||||
values={directTools.map((tool) => tool.toolCode)}
|
||||
options={directToolOptions}
|
||||
placeholder="选择 Direct Tool"
|
||||
emptyText="没有可用 Direct Tool"
|
||||
onValuesChange={setDirectToolSelection}
|
||||
values={mcpTools.map((tool) => tool.toolCode)}
|
||||
options={mcpToolOptions}
|
||||
placeholder="选择 MCP Tool"
|
||||
emptyText="没有可用 MCP Tool"
|
||||
onValuesChange={setMCPToolSelection}
|
||||
/>
|
||||
</FormSection>
|
||||
</div>
|
||||
|
||||
@@ -182,23 +182,23 @@ export default function DashboardAIAgentsPage() {
|
||||
label: t("aiAgent.columnCapabilities"),
|
||||
render: (item) => {
|
||||
const skills = item.skills ?? [];
|
||||
const directTools = item.directTools ?? [];
|
||||
const directToolServerCodes = Array.from(
|
||||
new Set(directTools.map((tool) => tool.serverCode).filter(Boolean)),
|
||||
const mcpTools = item.mcpTools ?? [];
|
||||
const mcpServerCodes = Array.from(
|
||||
new Set(mcpTools.map((tool) => tool.serverCode).filter(Boolean)),
|
||||
);
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="flex flex-wrap gap-1">
|
||||
<Badge variant="secondary">{skills.length} Skills</Badge>
|
||||
<Badge variant="secondary">{directTools.length} Tools</Badge>
|
||||
<Badge variant="secondary">{mcpTools.length} MCP Tools</Badge>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{directToolServerCodes.length === 0 ? (
|
||||
{mcpServerCodes.length === 0 ? (
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t("aiAgent.noMcpServer")}
|
||||
</span>
|
||||
) : (
|
||||
directToolServerCodes.map((serverCode) => (
|
||||
mcpServerCodes.map((serverCode) => (
|
||||
<Badge key={serverCode} variant="outline">
|
||||
{serverCode}
|
||||
</Badge>
|
||||
|
||||
@@ -241,7 +241,7 @@ export type AIAgent = {
|
||||
knowledgeBaseIds: number[]
|
||||
skillIds: number[]
|
||||
skills: { id: number; name: string }[]
|
||||
directTools: {
|
||||
mcpTools: {
|
||||
toolCode: string
|
||||
serverCode: string
|
||||
toolName: string
|
||||
@@ -282,7 +282,7 @@ export type CreateAIAgentPayload = {
|
||||
fallbackMessage: string
|
||||
knowledgeBaseIds: number[]
|
||||
skillIds: number[]
|
||||
directTools: {
|
||||
mcpTools: {
|
||||
toolCode: string
|
||||
serverCode: string
|
||||
toolName: string
|
||||
|
||||
@@ -1049,7 +1049,7 @@
|
||||
"loadTeamsFailed": "Could not load support teams.",
|
||||
"loadKnowledgeFailed": "Could not load knowledge bases.",
|
||||
"loadSkillsFailed": "Could not load skills.",
|
||||
"loadDirectToolsFailed": "Could not load Direct Tools.",
|
||||
"loadMCPToolsFailed": "Could not load MCP Tools.",
|
||||
"builtinTools": "Built-in tools",
|
||||
"ungrouped": "Ungrouped",
|
||||
"notSelected": "Not selected",
|
||||
@@ -1090,7 +1090,7 @@
|
||||
"sectionCapabilities": "Capabilities",
|
||||
"knowledgeTab": "Knowledge",
|
||||
"skillsTab": "Skills",
|
||||
"directToolsTab": "MCP tools",
|
||||
"mcpToolsTab": "MCP Tools",
|
||||
"knowledgeHint": "Select at least one knowledge base. You can adjust priority order.",
|
||||
"selectKnowledge": "Select and add knowledge base",
|
||||
"searchKnowledge": "Search knowledge bases",
|
||||
@@ -1109,15 +1109,15 @@
|
||||
"emptySkill": "No skills available",
|
||||
"noSkillsHint": "Without skills, routing only uses knowledge bases or human handoff.",
|
||||
"removeSkill": "Remove skill {name}",
|
||||
"directToolsHint": "Use only for low-risk atomic lookups through external MCP tools.",
|
||||
"mcpToolsHint": "Select the MCP Tools this Agent is allowed to call.",
|
||||
"selectToolGroup": "Select tool group",
|
||||
"searchToolGroup": "Search tool groups",
|
||||
"emptyToolGroup": "No tool groups available",
|
||||
"selectDirectTool": "Select Direct Tool",
|
||||
"searchDirectTool": "Search Direct Tools",
|
||||
"emptyDirectTool": "No Direct Tools available",
|
||||
"noDirectToolsHint": "Without Direct Tools, the agent will not call external or built-in tools directly. It will rely on knowledge bases, skills, and normal replies.",
|
||||
"removeDirectTool": "Remove Direct Tool {name}"
|
||||
"selectMCPTool": "Select MCP Tool",
|
||||
"searchMCPTool": "Search MCP Tools",
|
||||
"emptyMCPTool": "No MCP Tools available",
|
||||
"noMCPToolsHint": "Without MCP Tools, the Agent will not call external MCP Tools.",
|
||||
"removeMCPTool": "Remove MCP Tool {name}"
|
||||
},
|
||||
"aiConfig": {
|
||||
"allStatuses": "All statuses",
|
||||
|
||||
@@ -1049,7 +1049,7 @@
|
||||
"loadTeamsFailed": "加载客服组失败",
|
||||
"loadKnowledgeFailed": "加载知识库失败",
|
||||
"loadSkillsFailed": "加载 Skills 失败",
|
||||
"loadDirectToolsFailed": "加载 Direct Tools 失败",
|
||||
"loadMCPToolsFailed": "加载 MCP Tool 失败",
|
||||
"builtinTools": "内置工具",
|
||||
"ungrouped": "未分组",
|
||||
"notSelected": "未选择",
|
||||
@@ -1090,7 +1090,7 @@
|
||||
"sectionCapabilities": "能力配置",
|
||||
"knowledgeTab": "知识库",
|
||||
"skillsTab": "Skills",
|
||||
"directToolsTab": "MCP tools",
|
||||
"mcpToolsTab": "MCP Tool",
|
||||
"knowledgeHint": "至少选择一个知识库,可调整知识库优先级。",
|
||||
"selectKnowledge": "选择并添加知识库",
|
||||
"searchKnowledge": "搜索知识库",
|
||||
@@ -1109,15 +1109,15 @@
|
||||
"emptySkill": "没有可添加的 Skill",
|
||||
"noSkillsHint": "不绑定 Skill 时,自动路由只会走知识库或转人工。",
|
||||
"removeSkill": "移除 Skill {name}",
|
||||
"directToolsHint": "仅用于外部 MCP 工具的低风险、原子化查询。",
|
||||
"mcpToolsHint": "选择允许 Agent 调用的 MCP Tool。",
|
||||
"selectToolGroup": "选择工具分组",
|
||||
"searchToolGroup": "搜索工具分组",
|
||||
"emptyToolGroup": "没有可用的工具分组",
|
||||
"selectDirectTool": "选择 Direct Tool",
|
||||
"searchDirectTool": "搜索 Direct Tool",
|
||||
"emptyDirectTool": "没有可添加的 Direct Tool",
|
||||
"noDirectToolsHint": "不配置 Direct Tool 时,Agent 不会直接调用外部或内置工具,只会依赖知识库、Skill 和普通回复。",
|
||||
"removeDirectTool": "移除 Direct Tool {name}"
|
||||
"selectMCPTool": "选择 MCP Tool",
|
||||
"searchMCPTool": "搜索 MCP Tool",
|
||||
"emptyMCPTool": "没有可添加的 MCP Tool",
|
||||
"noMCPToolsHint": "不配置 MCP Tool 时,Agent 不会调用外部 MCP Tool。",
|
||||
"removeMCPTool": "移除 MCP Tool {name}"
|
||||
},
|
||||
"aiConfig": {
|
||||
"allStatuses": "全部状态",
|
||||
|
||||
Reference in New Issue
Block a user