mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-25 21:22:01 +08:00
* feat: support Github Copilot * feat: finish i18n translate * fix: add safeStorage * clean code * chore: remove vision model * ✨ feat: add Model Context Protocol (MCP) support (#2809) * ✨ feat: add Model Context Protocol (MCP) server configuration (main) - Added `@modelcontextprotocol/sdk` dependency for MCP integration. - Introduced MCP server configuration UI in settings with add, edit, delete, and activation functionalities. - Created `useMCPServers` hook to manage MCP server state and actions. - Added i18n support for MCP settings with translation keys. - Integrated MCP settings into the application's settings navigation and routing. - Implemented Redux state management for MCP servers. - Updated `yarn.lock` with new dependencies and their resolutions. * 🌟 feat: implement mcp service and integrate with ipc handlers - Added `MCPService` class to manage Model Context Protocol servers. - Implemented various handlers in `ipc.ts` for managing MCP servers including listing, adding, updating, deleting, and activating/deactivating servers. - Integrated MCP related types into existing type declarations for consistency across the application. - Updated `preload` to expose new MCP related APIs to the renderer process. - Enhanced `MCPSettings` component to interact directly with the new MCP service for adding, updating, deleting servers and setting their active states. - Introduced selectors in the MCP Redux slice for fetching active and all servers from the store. - Moved MCP types to a centralized location in `@renderer/types` for reuse across different parts of the application. * feat: enhance MCPService initialization to prevent recursive calls and improve error handling * feat: enhance MCP integration by adding MCPTool type and updating related methods * feat: implement streaming support for tool calls in OpenAIProvider and enhance message processing * fix: finish_reason undefined * fix migrate * feat: add rate limit and warning * feat: add delete copilot token file feat: add login message feat: add default headers and change getCopilotToken algorithm * fix * feat: add rate limit * chore: change apihost * fix: remove duplicate apikey * fix: change api host * chore: add vertify first tooltip --------- Co-authored-by: 亢奋猫 <kangfenmao@qq.com> Co-authored-by: LiuVaayne <10231735+vaayne@users.noreply.github.com>
53 lines
1.1 KiB
TypeScript
53 lines
1.1 KiB
TypeScript
import { useDispatch, useSelector } from 'react-redux'
|
|
|
|
import type { RootState } from '../store'
|
|
import {
|
|
type CopilotState,
|
|
resetCopilotState,
|
|
setAvatar,
|
|
setDefaultHeaders,
|
|
setUsername,
|
|
updateCopilotState
|
|
} from '../store/copilot'
|
|
|
|
/**
|
|
* 用于访问和操作Copilot相关状态的钩子函数
|
|
* @returns Copilot状态和操作方法
|
|
*/
|
|
export function useCopilot() {
|
|
const dispatch = useDispatch()
|
|
const copilotState = useSelector((state: RootState) => state.copilot)
|
|
|
|
const updateUsername = (username: string) => {
|
|
dispatch(setUsername(username))
|
|
}
|
|
|
|
const updateAvatar = (avatar: string) => {
|
|
dispatch(setAvatar(avatar))
|
|
}
|
|
|
|
const updateDefaultHeaders = (headers: Record<string, string>) => {
|
|
dispatch(setDefaultHeaders(headers))
|
|
}
|
|
|
|
const updateState = (state: Partial<CopilotState>) => {
|
|
dispatch(updateCopilotState(state))
|
|
}
|
|
|
|
const resetState = () => {
|
|
dispatch(resetCopilotState())
|
|
}
|
|
|
|
return {
|
|
// 当前状态
|
|
...copilotState,
|
|
|
|
// 状态更新方法
|
|
updateUsername,
|
|
updateAvatar,
|
|
updateDefaultHeaders,
|
|
updateState,
|
|
resetState
|
|
}
|
|
}
|