feat: 完成 Agent MCP 对接
- 增加 MCP 连接类型、环境检测接口和容器运行环境支持 - 将 Agent 编排改为绑定整体 MCP 并编译为 runtime McpSpec - 优化 MCP 工具展示、审批、草稿试运行和画布回显稳定性
This commit is contained in:
@@ -51,9 +51,22 @@ public class ChatAssistantAccumulator {
|
||||
* @param arguments tool 参数
|
||||
*/
|
||||
public void appendToolCall(String id, String name, Object arguments) {
|
||||
appendToolCall(id, name, null, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录 tool call,同时保留面向前端展示的工具名称。
|
||||
*
|
||||
* @param id tool call id
|
||||
* @param name tool 名称
|
||||
* @param displayName tool 展示名称
|
||||
* @param arguments tool 参数
|
||||
*/
|
||||
public void appendToolCall(String id, String name, String displayName, Object arguments) {
|
||||
Map<String, Object> chain = findToolChain(id, name);
|
||||
chain.put("status", "TOOL_CALL");
|
||||
chain.put("arguments", arguments);
|
||||
putIfNotBlank(chain, "toolDisplayName", displayName);
|
||||
|
||||
Map<String, Object> assistantMessage = ensureToolCallAssistantMessage();
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -63,6 +76,7 @@ public class ChatAssistantAccumulator {
|
||||
toolCall.put("id", id);
|
||||
toolCall.put("name", name);
|
||||
toolCall.put("arguments", arguments == null ? null : String.valueOf(arguments));
|
||||
putIfNotBlank(toolCall, "toolDisplayName", displayName);
|
||||
toolCalls.add(toolCall);
|
||||
}
|
||||
|
||||
@@ -74,9 +88,22 @@ public class ChatAssistantAccumulator {
|
||||
* @param result tool 结果
|
||||
*/
|
||||
public void appendToolResult(String id, String name, Object result) {
|
||||
appendToolResult(id, name, null, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录 tool result,并保留面向前端展示的工具名称。
|
||||
*
|
||||
* @param id tool call id
|
||||
* @param name tool 名称
|
||||
* @param displayName tool 展示名称
|
||||
* @param result tool 结果
|
||||
*/
|
||||
public void appendToolResult(String id, String name, String displayName, Object result) {
|
||||
Map<String, Object> chain = findToolChain(id, name);
|
||||
chain.put("status", "TOOL_RESULT");
|
||||
chain.put("result", result);
|
||||
putIfNotBlank(chain, "toolDisplayName", displayName);
|
||||
Map<String, Object> toolMessage = ChatRuntimeHistoryPayloadHelper.toolMessage(
|
||||
id,
|
||||
result == null ? null : String.valueOf(result)
|
||||
@@ -191,4 +218,10 @@ public class ChatAssistantAccumulator {
|
||||
private String stringValue(Object value) {
|
||||
return value == null ? null : String.valueOf(value);
|
||||
}
|
||||
|
||||
private void putIfNotBlank(Map<String, Object> target, String key, String value) {
|
||||
if (value != null && !value.isBlank()) {
|
||||
target.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user