@lobehub/chat 1.81.5 → 1.81.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/locales/ar/auth.json +1 -1
  4. package/locales/ar/hotkey.json +4 -0
  5. package/locales/bg-BG/auth.json +1 -1
  6. package/locales/bg-BG/hotkey.json +4 -0
  7. package/locales/de-DE/auth.json +1 -1
  8. package/locales/de-DE/hotkey.json +4 -0
  9. package/locales/en-US/auth.json +1 -1
  10. package/locales/en-US/hotkey.json +4 -0
  11. package/locales/es-ES/auth.json +1 -1
  12. package/locales/es-ES/hotkey.json +4 -0
  13. package/locales/fa-IR/auth.json +1 -1
  14. package/locales/fa-IR/hotkey.json +4 -0
  15. package/locales/fr-FR/auth.json +1 -1
  16. package/locales/fr-FR/hotkey.json +4 -0
  17. package/locales/it-IT/auth.json +1 -1
  18. package/locales/it-IT/hotkey.json +4 -0
  19. package/locales/ja-JP/auth.json +1 -1
  20. package/locales/ja-JP/hotkey.json +4 -0
  21. package/locales/ko-KR/auth.json +1 -1
  22. package/locales/ko-KR/hotkey.json +4 -0
  23. package/locales/nl-NL/auth.json +1 -1
  24. package/locales/nl-NL/hotkey.json +4 -0
  25. package/locales/pl-PL/auth.json +1 -1
  26. package/locales/pl-PL/hotkey.json +4 -0
  27. package/locales/pt-BR/auth.json +1 -1
  28. package/locales/pt-BR/hotkey.json +4 -0
  29. package/locales/ru-RU/auth.json +1 -1
  30. package/locales/ru-RU/hotkey.json +4 -0
  31. package/locales/tr-TR/auth.json +1 -1
  32. package/locales/tr-TR/hotkey.json +4 -0
  33. package/locales/vi-VN/auth.json +1 -1
  34. package/locales/vi-VN/hotkey.json +4 -0
  35. package/locales/zh-CN/auth.json +1 -1
  36. package/locales/zh-CN/changelog.json +1 -1
  37. package/locales/zh-CN/clerk.json +1 -1
  38. package/locales/zh-CN/discover.json +1 -1
  39. package/locales/zh-CN/file.json +1 -1
  40. package/locales/zh-CN/hotkey.json +4 -0
  41. package/locales/zh-CN/knowledgeBase.json +1 -1
  42. package/locales/zh-CN/metadata.json +1 -1
  43. package/locales/zh-CN/migration.json +1 -1
  44. package/locales/zh-CN/ragEval.json +1 -1
  45. package/locales/zh-CN/thread.json +1 -1
  46. package/locales/zh-CN/welcome.json +1 -1
  47. package/locales/zh-TW/auth.json +1 -1
  48. package/locales/zh-TW/hotkey.json +4 -0
  49. package/package.json +5 -3
  50. package/src/config/aiModels/github.ts +2 -4
  51. package/src/config/aiModels/google.ts +3 -4
  52. package/src/config/aiModels/sensenova.ts +4 -5
  53. package/src/const/hotkeys.ts +6 -0
  54. package/src/features/ChatInput/ActionBar/Clear.tsx +18 -8
  55. package/src/hooks/useHotkeys/chatScope.ts +7 -0
  56. package/src/libs/agent-runtime/google/index.ts +1 -1
  57. package/src/libs/agent-runtime/sensenova/index.ts +20 -27
  58. package/src/libs/agent-runtime/togetherai/index.ts +19 -23
  59. package/src/libs/agent-runtime/togetherai/type.ts +2 -2
  60. package/src/libs/agent-runtime/utils/sensenovaHelpers.test.ts +24 -33
  61. package/src/libs/agent-runtime/utils/sensenovaHelpers.ts +2 -3
  62. package/src/locales/default/hotkey.ts +4 -0
  63. package/src/server/modules/MCPClient/__tests__/__snapshots__/index.test.ts.snap +113 -0
  64. package/src/server/modules/MCPClient/__tests__/index.test.ts +81 -0
  65. package/src/server/modules/MCPClient/index.ts +80 -0
  66. package/src/types/hotkey.ts +1 -0
@@ -0,0 +1,80 @@
1
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
3
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4
+ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.d.ts';
5
+ import debug from 'debug';
6
+
7
+ const log = debug('lobe-mcp:client');
8
+
9
+ interface MCPConnectionBase {
10
+ id: string;
11
+ name: string;
12
+ type: 'http' | 'stdio';
13
+ }
14
+
15
+ interface HttpMCPConnection extends MCPConnectionBase {
16
+ type: 'http';
17
+ url: string;
18
+ }
19
+
20
+ interface StdioMCPConnection extends MCPConnectionBase {
21
+ args: string[];
22
+ command: string;
23
+ type: 'stdio';
24
+ }
25
+ type MCPConnection = HttpMCPConnection | StdioMCPConnection;
26
+
27
+ export class MCPClient {
28
+ private mcp: Client;
29
+ private transport: Transport;
30
+
31
+ constructor(connection: MCPConnection) {
32
+ log('Creating MCPClient with connection: %O', connection);
33
+ this.mcp = new Client({ name: 'lobehub-mcp-client', version: '1.0.0' });
34
+
35
+ switch (connection.type) {
36
+ case 'http': {
37
+ log('Using HTTP transport with url: %s', connection.url);
38
+ this.transport = new StreamableHTTPClientTransport(new URL(connection.url));
39
+ break;
40
+ }
41
+ case 'stdio': {
42
+ log(
43
+ 'Using Stdio transport with command: %s and args: %O',
44
+ connection.command,
45
+ connection.args,
46
+ );
47
+ this.transport = new StdioClientTransport({
48
+ args: connection.args,
49
+ command: connection.command,
50
+ });
51
+ break;
52
+ }
53
+ default: {
54
+ const err = new Error(`Unsupported MCP connection type: ${(connection as any).type}`);
55
+ log('Error creating client: %O', err);
56
+ throw err;
57
+ }
58
+ }
59
+ }
60
+
61
+ async initialize() {
62
+ log('Initializing MCP connection...');
63
+ await this.mcp.connect(this.transport);
64
+ log('MCP connection initialized.');
65
+ }
66
+
67
+ async listTools() {
68
+ log('Listing tools...');
69
+ const tools = await this.mcp.listTools();
70
+ log('Listed tools: %O', tools);
71
+ return tools;
72
+ }
73
+
74
+ async callTool(toolName: string, args: any) {
75
+ log('Calling tool: %s with args: %O', toolName, args);
76
+ const result = await this.mcp.callTool({ arguments: args, name: toolName });
77
+ log('Tool call result: %O', result);
78
+ return result;
79
+ }
80
+ }
@@ -58,6 +58,7 @@ export const KeyEnum = {
58
58
 
59
59
  export const HotkeyEnum = {
60
60
  AddUserMessage: 'addUserMessage',
61
+ ClearCurrentMessages: 'clearCurrentMessages',
61
62
  EditMessage: 'editMessage',
62
63
  OpenChatSettings: 'openChatSettings',
63
64
  OpenHotkeyHelper: 'openHotkeyHelper',