feat: 完成 Agent MCP 对接
- 增加 MCP 连接类型、环境检测接口和容器运行环境支持 - 将 Agent 编排改为绑定整体 MCP 并编译为 runtime McpSpec - 优化 MCP 工具展示、审批、草稿试运行和画布回显稳定性
This commit is contained in:
@@ -111,6 +111,49 @@ describe('agentTimelineAdapter', () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('uses tool display name when restoring aliased MCP tools from history', () => {
|
||||
const items = recordsToTimelineItems([
|
||||
{
|
||||
id: 'mcp-history',
|
||||
senderRole: 'assistant',
|
||||
contentText: '已完成',
|
||||
roundId: 'round-mcp',
|
||||
contentPayload: {
|
||||
chains: [
|
||||
{
|
||||
id: 'tool-mcp-1',
|
||||
name: 'mcp_123_search',
|
||||
toolDisplayName: 'Context MCP - search',
|
||||
status: 'TOOL_RESULT',
|
||||
result: 'ok',
|
||||
},
|
||||
],
|
||||
messageChain: [
|
||||
{
|
||||
role: 'assistant',
|
||||
toolCalls: [
|
||||
{
|
||||
id: 'tool-mcp-1',
|
||||
name: 'mcp_123_search',
|
||||
toolDisplayName: 'Context MCP - search',
|
||||
arguments: '{}',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
role: 'tool',
|
||||
toolCallId: 'tool-mcp-1',
|
||||
content: 'ok',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const tool = items.find((item) => item.type === 'tool');
|
||||
expect(tool?.toolName).toBe('Context MCP - search');
|
||||
});
|
||||
|
||||
it('hides knowledge retrieval cards when restoring agent chat history', () => {
|
||||
const items = recordsToTimelineItems([
|
||||
{
|
||||
|
||||
@@ -68,7 +68,9 @@ function shouldSkipToolProjection(value: unknown) {
|
||||
|
||||
function normalizeToolCallName(payload: Record<string, any>) {
|
||||
const fn = asRecord(payload.function);
|
||||
return normalizeToolName(payload.name ?? payload.toolName ?? fn.name);
|
||||
return normalizeToolName(
|
||||
payload.toolDisplayName ?? payload.name ?? payload.toolName ?? fn.name,
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeToolCallInput(payload: Record<string, any>) {
|
||||
@@ -211,7 +213,9 @@ function projectHistoryChain(
|
||||
hasAssistantThinking = true;
|
||||
continue;
|
||||
}
|
||||
const toolName = normalizeToolName(item.name ?? item.toolName);
|
||||
const toolName = normalizeToolName(
|
||||
item.toolDisplayName ?? item.name ?? item.toolName,
|
||||
);
|
||||
const toolCallId = normalizeToolCallId(item);
|
||||
if (toolCallId && toolName) {
|
||||
toolNameByCallId.set(toolCallId, toolName);
|
||||
|
||||
Reference in New Issue
Block a user