diff --git a/packages/aiCore/src/index.ts b/packages/aiCore/src/index.ts index 1cb02afb9..9b407021a 100644 --- a/packages/aiCore/src/index.ts +++ b/packages/aiCore/src/index.ts @@ -71,6 +71,7 @@ export type { ToolCallUnion, ToolModelMessage, ToolResultPart, + ToolResultUnion, ToolSet, UserModelMessage } from 'ai' diff --git a/src/renderer/src/aiCore/chunk/handleTooCallChunk.ts b/src/renderer/src/aiCore/chunk/handleTooCallChunk.ts index d550dc569..3aa1a7ac1 100644 --- a/src/renderer/src/aiCore/chunk/handleTooCallChunk.ts +++ b/src/renderer/src/aiCore/chunk/handleTooCallChunk.ts @@ -4,7 +4,7 @@ * 提供工具调用相关的处理API,每个交互使用一个新的实例 */ -import { ToolCallUnion, ToolSet } from '@cherrystudio/ai-core/index' +import { ToolCallUnion, ToolResultUnion, ToolSet } from '@cherrystudio/ai-core/index' import Logger from '@renderer/config/logger' import { MCPTool, MCPToolResponse } from '@renderer/types' import { Chunk, ChunkType } from '@renderer/types/chunk' @@ -84,9 +84,13 @@ export class ToolCallChunkHandler { /** * 处理工具调用结果事件 */ - public handleToolResult(chunk: any): void { + public handleToolResult( + chunk: { + type: 'tool-result' + } & ToolResultUnion + ): void { const toolCallId = chunk.toolCallId - const result = chunk.result + const result = chunk.output if (!toolCallId) { Logger.warn(`🔧 [ToolCallChunkHandler] Invalid tool result chunk: missing toolCallId`) diff --git a/src/renderer/src/aiCore/plugins/reasoningTimePlugin.ts b/src/renderer/src/aiCore/plugins/reasoningTimePlugin.ts index 26a019b19..e9bf9f321 100644 --- a/src/renderer/src/aiCore/plugins/reasoningTimePlugin.ts +++ b/src/renderer/src/aiCore/plugins/reasoningTimePlugin.ts @@ -49,7 +49,9 @@ export default definePlugin({ reasoningBlockId = '' controller.enqueue(chunk) } else { - controller.enqueue(chunk) + if (chunk.type !== 'reasoning-end') { + controller.enqueue(chunk) + } } }, diff --git a/src/renderer/src/services/ApiService.ts b/src/renderer/src/services/ApiService.ts index 283fe46c9..eda7bd19e 100644 --- a/src/renderer/src/services/ApiService.ts +++ b/src/renderer/src/services/ApiService.ts @@ -15,7 +15,7 @@ import { import { getStoreSetting } from '@renderer/hooks/useSettings' import i18n from '@renderer/i18n' import store from '@renderer/store' -import { Assistant, MCPTool, Model, Provider } from '@renderer/types' +import { Assistant, MCPServer, MCPTool, Model, Provider } from '@renderer/types' import { type Chunk, ChunkType } from '@renderer/types/chunk' import { Message } from '@renderer/types/newMessage' import { SdkModel } from '@renderer/types/sdk' @@ -263,7 +263,7 @@ export async function fetchMcpTools(assistant: Assistant) { if (enabledMCPs && enabledMCPs.length > 0) { try { - const toolPromises = enabledMCPs.map>(async (mcpServer) => { + const toolPromises = enabledMCPs.map>(async (mcpServer: MCPServer) => { try { const tools = await window.api.mcp.listTools(mcpServer) return tools.filter((tool: any) => !mcpServer.disabledTools?.includes(tool.name))