@lobehub/lobehub 2.0.0-next.273 → 2.0.0-next.275

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 (237) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/changelog/v1.json +18 -0
  3. package/locales/ar/chat.json +7 -0
  4. package/locales/ar/models.json +2 -3
  5. package/locales/ar/plugin.json +22 -1
  6. package/locales/bg-BG/chat.json +7 -0
  7. package/locales/bg-BG/models.json +3 -3
  8. package/locales/bg-BG/plugin.json +22 -1
  9. package/locales/de-DE/chat.json +7 -0
  10. package/locales/de-DE/models.json +3 -4
  11. package/locales/de-DE/plugin.json +22 -1
  12. package/locales/en-US/chat.json +7 -0
  13. package/locales/en-US/models.json +5 -5
  14. package/locales/en-US/plugin.json +22 -1
  15. package/locales/es-ES/chat.json +7 -0
  16. package/locales/es-ES/models.json +3 -4
  17. package/locales/es-ES/plugin.json +22 -1
  18. package/locales/fa-IR/chat.json +7 -0
  19. package/locales/fa-IR/models.json +3 -4
  20. package/locales/fa-IR/plugin.json +22 -1
  21. package/locales/fr-FR/chat.json +7 -0
  22. package/locales/fr-FR/models.json +50 -3
  23. package/locales/fr-FR/plugin.json +22 -1
  24. package/locales/it-IT/chat.json +7 -0
  25. package/locales/it-IT/models.json +3 -3
  26. package/locales/it-IT/plugin.json +22 -1
  27. package/locales/ja-JP/chat.json +7 -0
  28. package/locales/ja-JP/models.json +43 -4
  29. package/locales/ja-JP/plugin.json +22 -1
  30. package/locales/ko-KR/chat.json +7 -0
  31. package/locales/ko-KR/models.json +3 -4
  32. package/locales/ko-KR/plugin.json +22 -1
  33. package/locales/nl-NL/chat.json +7 -0
  34. package/locales/nl-NL/models.json +51 -3
  35. package/locales/nl-NL/plugin.json +22 -1
  36. package/locales/pl-PL/chat.json +7 -0
  37. package/locales/pl-PL/models.json +3 -3
  38. package/locales/pl-PL/plugin.json +22 -1
  39. package/locales/pt-BR/chat.json +7 -0
  40. package/locales/pt-BR/models.json +3 -4
  41. package/locales/pt-BR/plugin.json +22 -1
  42. package/locales/ru-RU/chat.json +7 -0
  43. package/locales/ru-RU/models.json +3 -4
  44. package/locales/ru-RU/plugin.json +22 -1
  45. package/locales/tr-TR/chat.json +7 -0
  46. package/locales/tr-TR/models.json +3 -4
  47. package/locales/tr-TR/plugin.json +22 -1
  48. package/locales/vi-VN/chat.json +7 -0
  49. package/locales/vi-VN/models.json +3 -3
  50. package/locales/vi-VN/plugin.json +22 -1
  51. package/locales/zh-CN/chat.json +7 -0
  52. package/locales/zh-CN/models.json +54 -4
  53. package/locales/zh-CN/plugin.json +22 -1
  54. package/locales/zh-TW/chat.json +7 -0
  55. package/locales/zh-TW/models.json +43 -4
  56. package/locales/zh-TW/plugin.json +22 -1
  57. package/package.json +2 -2
  58. package/packages/builtin-tool-agent-builder/package.json +1 -0
  59. package/packages/builtin-tool-agent-builder/src/client/Inspector/GetAvailableModels/index.tsx +66 -0
  60. package/packages/builtin-tool-agent-builder/src/client/Inspector/InstallPlugin/index.tsx +63 -0
  61. package/packages/builtin-tool-agent-builder/src/client/Inspector/SearchMarketTools/index.tsx +64 -0
  62. package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdateConfig/index.tsx +94 -0
  63. package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdatePrompt/index.tsx +96 -0
  64. package/packages/builtin-tool-agent-builder/src/client/Inspector/index.ts +29 -0
  65. package/packages/builtin-tool-agent-builder/src/client/index.ts +13 -0
  66. package/packages/builtin-tool-agent-builder/src/executor.ts +132 -0
  67. package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/ExecuteCode/index.tsx +5 -14
  68. package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/RunCommand/index.tsx +5 -13
  69. package/packages/builtin-tool-group-agent-builder/package.json +7 -1
  70. package/packages/builtin-tool-group-agent-builder/src/ExecutionRuntime/index.ts +331 -87
  71. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/BatchCreateAgents/index.tsx +110 -0
  72. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/CreateAgent/index.tsx +72 -0
  73. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsx +57 -0
  74. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsx +57 -0
  75. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/SearchAgent/index.tsx +66 -0
  76. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsx +120 -0
  77. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroup/index.tsx +87 -0
  78. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroupPrompt/index.tsx +99 -0
  79. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/index.ts +52 -0
  80. package/packages/builtin-tool-group-agent-builder/src/client/Render/BatchCreateAgents.tsx +103 -0
  81. package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateAgentPrompt/index.tsx +36 -0
  82. package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateGroupPrompt/index.tsx +36 -0
  83. package/packages/builtin-tool-group-agent-builder/src/client/Render/index.ts +16 -0
  84. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/BatchCreateAgents/index.tsx +88 -0
  85. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateAgentPrompt/index.tsx +37 -0
  86. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateGroupPrompt/index.tsx +35 -0
  87. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/index.ts +22 -0
  88. package/packages/builtin-tool-group-agent-builder/src/client/index.ts +26 -0
  89. package/packages/builtin-tool-group-agent-builder/src/executor.ts +284 -0
  90. package/packages/builtin-tool-group-agent-builder/src/index.ts +1 -14
  91. package/packages/builtin-tool-group-agent-builder/src/manifest.ts +160 -15
  92. package/packages/builtin-tool-group-agent-builder/src/systemRole.ts +232 -46
  93. package/packages/builtin-tool-group-agent-builder/src/types.ts +191 -41
  94. package/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsx +2 -2
  95. package/packages/builtin-tool-group-management/src/manifest.ts +1 -1
  96. package/packages/builtin-tool-gtd/src/client/Inspector/ClearTodos/index.tsx +5 -11
  97. package/packages/builtin-tool-gtd/src/client/Inspector/CompleteTodos/index.tsx +3 -9
  98. package/packages/builtin-tool-gtd/src/client/Inspector/CreatePlan/index.tsx +6 -15
  99. package/packages/builtin-tool-gtd/src/client/Inspector/CreateTodos/index.tsx +3 -9
  100. package/packages/builtin-tool-gtd/src/client/Inspector/ExecTask/index.tsx +6 -17
  101. package/packages/builtin-tool-gtd/src/client/Inspector/RemoveTodos/index.tsx +3 -9
  102. package/packages/builtin-tool-gtd/src/client/Inspector/UpdatePlan/index.tsx +3 -9
  103. package/packages/builtin-tool-gtd/src/client/Inspector/UpdateTodos/index.tsx +3 -9
  104. package/packages/builtin-tool-knowledge-base/src/client/Inspector/ReadKnowledge/index.tsx +4 -16
  105. package/packages/builtin-tool-knowledge-base/src/client/Inspector/SearchKnowledgeBase/index.tsx +5 -16
  106. package/packages/builtin-tool-local-system/src/client/Inspector/EditLocalFile/index.tsx +4 -12
  107. package/packages/builtin-tool-local-system/src/client/Inspector/GlobLocalFiles/index.tsx +5 -13
  108. package/packages/builtin-tool-local-system/src/client/Inspector/GrepContent/index.tsx +5 -16
  109. package/packages/builtin-tool-local-system/src/client/Inspector/ListLocalFiles/index.tsx +5 -16
  110. package/packages/builtin-tool-local-system/src/client/Inspector/ReadLocalFile/index.tsx +5 -16
  111. package/packages/builtin-tool-local-system/src/client/Inspector/RenameLocalFile/index.tsx +5 -11
  112. package/packages/builtin-tool-local-system/src/client/Inspector/RunCommand/index.tsx +5 -13
  113. package/packages/builtin-tool-local-system/src/client/Inspector/SearchLocalFiles/index.tsx +5 -16
  114. package/packages/builtin-tool-local-system/src/client/Inspector/WriteLocalFile/index.tsx +6 -15
  115. package/packages/builtin-tool-notebook/src/client/Inspector/CreateDocument/index.tsx +7 -15
  116. package/packages/builtin-tool-page-agent/src/client/Inspector/EditTitle/index.tsx +5 -14
  117. package/packages/builtin-tool-page-agent/src/client/Inspector/GetPageContent/index.tsx +7 -8
  118. package/packages/builtin-tool-page-agent/src/client/Inspector/InitPage/index.tsx +4 -10
  119. package/packages/builtin-tool-page-agent/src/client/Inspector/ModifyNodes/index.tsx +3 -9
  120. package/packages/builtin-tool-page-agent/src/client/Inspector/ReplaceText/index.tsx +5 -11
  121. package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlMultiPages/index.tsx +6 -15
  122. package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlSinglePage/index.tsx +6 -15
  123. package/packages/builtin-tool-web-browsing/src/client/Inspector/Search/index.tsx +4 -15
  124. package/packages/database/src/models/chatGroup.ts +1 -1
  125. package/packages/model-bank/src/aiModels/aihubmix.ts +2 -1
  126. package/packages/model-bank/src/aiModels/google.ts +2 -1
  127. package/packages/model-bank/src/aiModels/infiniai.ts +9 -6
  128. package/packages/model-bank/src/aiModels/minimax.ts +9 -5
  129. package/packages/model-bank/src/aiModels/ollamacloud.ts +4 -2
  130. package/packages/model-bank/src/aiModels/vertexai.ts +2 -1
  131. package/packages/types/src/agentGroup/index.ts +8 -0
  132. package/patches/@upstash__qstash.patch +13 -1
  133. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Header/Nav.tsx +1 -1
  134. package/src/app/[variants]/(main)/agent/cron/[cronId]/index.tsx +4 -3
  135. package/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsx +1 -1
  136. package/src/app/[variants]/(main)/agent/profile/features/store/action.ts +18 -21
  137. package/src/app/[variants]/(main)/community/(detail)/features/MakedownRender.tsx +8 -6
  138. package/src/app/[variants]/(main)/group/_layout/GroupIdSync.tsx +6 -1
  139. package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/AgentProfilePopup.tsx +29 -21
  140. package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMember.tsx +1 -0
  141. package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMemberItem.tsx +35 -18
  142. package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/AddTopicButon.tsx +2 -10
  143. package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/Nav.tsx +10 -2
  144. package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/index.tsx +1 -2
  145. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/AgentBuilderProvider.tsx +1 -0
  146. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx +15 -9
  147. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/index.tsx +12 -6
  148. package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor/AgentHeader.tsx → GroupProfile/GroupHeader.tsx} +22 -29
  149. package/src/app/[variants]/(main)/group/profile/features/GroupProfile/index.tsx +96 -0
  150. package/src/app/[variants]/(main)/group/profile/features/Header/AgentBuilderToggle.tsx +3 -4
  151. package/src/app/[variants]/(main)/group/profile/features/Header/AutoSaveHint.tsx +11 -7
  152. package/src/app/[variants]/(main)/group/profile/features/Header/ChromeTabs/index.tsx +147 -0
  153. package/src/app/[variants]/(main)/group/profile/features/Header/index.tsx +104 -13
  154. package/src/app/[variants]/(main)/group/profile/features/MemberProfile/AgentHeader.tsx +222 -0
  155. package/src/app/[variants]/(main)/group/profile/features/MemberProfile/index.tsx +155 -0
  156. package/src/app/[variants]/(main)/group/profile/features/ProfileHydration.tsx +63 -5
  157. package/src/app/[variants]/(main)/group/profile/index.tsx +34 -37
  158. package/src/app/[variants]/(main)/settings/proxy/features/ProxyForm.tsx +156 -253
  159. package/src/app/[variants]/(main)/settings/proxy/index.tsx +1 -3
  160. package/src/app/[variants]/(mobile)/(home)/_layout/SessionHydration.tsx +1 -1
  161. package/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/index.tsx +1 -1
  162. package/src/features/AgentBuilder/index.tsx +16 -1
  163. package/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx +3 -2
  164. package/src/features/Conversation/Messages/User/useMarkdown.tsx +1 -0
  165. package/src/features/EditorCanvas/EditorCanvas.test.tsx +206 -0
  166. package/src/features/EditorCanvas/EditorDataMode.tsx +53 -19
  167. package/src/features/EditorModal/index.tsx +2 -2
  168. package/src/features/NavPanel/components/SessionHydration.tsx +1 -1
  169. package/src/features/PageEditor/EditorCanvas/useAskCopilotItem.tsx +10 -6
  170. package/src/features/PageEditor/Header/index.tsx +12 -10
  171. package/src/features/PageEditor/Header/useMenu.tsx +45 -48
  172. package/src/features/RightPanel/ToggleRightPanelButton.tsx +3 -1
  173. package/src/features/ShareModal/ShareImage/ChatList/index.tsx +1 -1
  174. package/src/features/ShareModal/SharePdf/index.tsx +1 -1
  175. package/src/hooks/useBidirectionalQuerySync.ts +112 -0
  176. package/src/locales/default/chat.ts +10 -0
  177. package/src/locales/default/plugin.ts +22 -1
  178. package/src/server/modules/AgentRuntime/RuntimeExecutors.ts +45 -45
  179. package/src/server/modules/KeyVaultsEncrypt/index.ts +6 -6
  180. package/src/server/modules/S3/index.ts +1 -1
  181. package/src/server/routers/lambda/agent.ts +24 -0
  182. package/src/server/routers/lambda/agentGroup.ts +39 -0
  183. package/src/services/agent.ts +22 -0
  184. package/src/services/chatGroup/index.ts +14 -0
  185. package/src/store/agent/selectors/selectors.ts +3 -0
  186. package/src/store/agentGroup/initialState.ts +6 -0
  187. package/src/store/agentGroup/selectors/byId.ts +3 -1
  188. package/src/store/agentGroup/selectors/current.ts +2 -2
  189. package/src/store/agentGroup/slices/lifecycle.ts +18 -0
  190. package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockStore.ts +1 -1
  191. package/src/store/chat/slices/aiAgent/actions/__tests__/agentGroup.test.ts +4 -1
  192. package/src/store/chat/slices/aiAgent/actions/agentGroup.ts +1 -1
  193. package/src/store/chat/slices/aiChat/actions/__tests__/conversationLifecycle.test.ts +65 -0
  194. package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +2 -1
  195. package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +1 -1
  196. package/src/store/chat/slices/builtinTool/actions/index.ts +1 -6
  197. package/src/store/chat/slices/message/action.test.ts +5 -5
  198. package/src/store/chat/slices/message/actions/publicApi.ts +5 -5
  199. package/src/store/chat/slices/message/initialState.ts +0 -5
  200. package/src/store/chat/slices/message/selectors/displayMessage.test.ts +4 -4
  201. package/src/store/chat/slices/plugin/action.test.ts +54 -19
  202. package/src/store/chat/slices/plugin/actions/pluginTypes.ts +15 -21
  203. package/src/store/chat/slices/topic/action.test.ts +74 -24
  204. package/src/store/chat/slices/topic/action.ts +21 -13
  205. package/src/store/chat/slices/topic/selectors.test.ts +1 -1
  206. package/src/store/global/initialState.ts +10 -0
  207. package/src/store/global/selectors/systemStatus.ts +5 -0
  208. package/src/store/groupProfile/action.ts +168 -0
  209. package/src/store/groupProfile/index.ts +16 -0
  210. package/src/{app/[variants]/(main)/group/profile/features/store → store/groupProfile}/initialState.ts +17 -0
  211. package/src/store/groupProfile/selectors.ts +13 -0
  212. package/src/store/tool/slices/builtin/executors/index.ts +4 -0
  213. package/src/styles/text.ts +16 -0
  214. package/src/tools/inspectors.ts +13 -0
  215. package/src/tools/renders.ts +3 -0
  216. package/src/tools/streamings.ts +8 -0
  217. package/tests/mocks/lru_map.ts +40 -0
  218. package/vitest.config.mts +9 -1
  219. package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/TypoBar.tsx +0 -129
  220. package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/index.tsx +0 -138
  221. package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/useSlashItems.tsx +0 -139
  222. package/src/app/[variants]/(main)/group/profile/features/ProfileEditor/index.tsx +0 -82
  223. package/src/app/[variants]/(main)/group/profile/features/ProfileProvider.tsx +0 -20
  224. package/src/app/[variants]/(main)/group/profile/features/StoreUpdater.tsx +0 -24
  225. package/src/app/[variants]/(main)/group/profile/features/store/action.ts +0 -163
  226. package/src/app/[variants]/(main)/group/profile/features/store/index.ts +0 -23
  227. package/src/app/[variants]/(main)/group/profile/features/store/selectors.ts +0 -7
  228. package/src/features/EditorModal/EditorCanvas.tsx +0 -84
  229. package/src/features/EditorModal/Typobar.tsx +0 -139
  230. package/src/store/chat/slices/builtinTool/actions/agentBuilder.ts +0 -192
  231. package/src/store/chat/slices/builtinTool/actions/groupAgentBuilder.ts +0 -242
  232. package/src/tools/executionRuntimes.ts +0 -14
  233. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/AgentTool.tsx +0 -0
  234. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/MentionDropdown.tsx +0 -0
  235. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/index.tsx +0 -0
  236. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/types.ts +0 -0
  237. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/useMentionItems.tsx +0 -0
@@ -1,163 +0,0 @@
1
- import { EDITOR_DEBOUNCE_TIME, EDITOR_MAX_WAIT } from '@lobechat/const';
2
- import { debounce } from 'es-toolkit/compat';
3
- import { type StateCreator } from 'zustand';
4
-
5
- import { type State, initialState } from './initialState';
6
-
7
- type SaveConfigPayload = {
8
- editorData: Record<string, any>;
9
- systemRole: string;
10
- };
11
-
12
- export interface Action {
13
- /**
14
- * Append content to streaming buffer (called during streaming)
15
- */
16
- appendStreamingContent: (chunk: string) => void;
17
- /**
18
- * Finalize streaming and save to config
19
- */
20
- finishStreaming: (updateConfig: (payload: SaveConfigPayload) => Promise<void>) => Promise<void>;
21
- flushSave: () => void;
22
- handleContentChange: (updateConfig: (payload: SaveConfigPayload) => Promise<void>) => void;
23
- setChatPanelExpanded: (expanded: boolean | ((prev: boolean) => boolean)) => void;
24
- /**
25
- * Start streaming mode - clears editor and prepares for streaming content
26
- */
27
- startStreaming: () => void;
28
- }
29
-
30
- export type Store = State & Action;
31
-
32
- // Create debounced save function outside of store for reuse
33
- const createDebouncedSave = (
34
- get: () => Store,
35
- updateConfig: (payload: SaveConfigPayload) => Promise<void>,
36
- ) =>
37
- debounce(
38
- async (payload: SaveConfigPayload) => {
39
- try {
40
- await updateConfig(payload);
41
- } catch (error) {
42
- console.error('[ProfileEditor] Failed to save:', error);
43
- }
44
- },
45
- EDITOR_DEBOUNCE_TIME,
46
- { leading: false, maxWait: EDITOR_MAX_WAIT, trailing: true },
47
- );
48
-
49
- export const store: (initState?: Partial<State>) => StateCreator<Store> =
50
- (initState) => (set, get) => {
51
- let debouncedSave: ReturnType<typeof createDebouncedSave> | null = null;
52
-
53
- return {
54
- ...initialState,
55
- ...initState,
56
-
57
- appendStreamingContent: (chunk) => {
58
- const currentContent = get().streamingContent || '';
59
- const newContent = currentContent + chunk;
60
- set({ streamingContent: newContent });
61
-
62
- // Update editor with streaming content
63
- const { editor } = get();
64
- if (editor) {
65
- try {
66
- editor.setDocument('markdown', newContent);
67
- } catch {
68
- // Ignore errors during streaming updates
69
- }
70
- }
71
- },
72
-
73
- finishStreaming: async (updateConfig) => {
74
- const { editor, streamingContent } = get();
75
- if (!streamingContent) {
76
- set({ streamingInProgress: false });
77
- return;
78
- }
79
-
80
- // Get the final content from editor
81
- let finalContent = streamingContent;
82
- let editorData = {};
83
-
84
- if (editor) {
85
- try {
86
- finalContent =
87
- (editor.getDocument('markdown') as unknown as string) || streamingContent;
88
- editorData = editor.getDocument('json') as unknown as Record<string, any>;
89
- } catch {
90
- // Use streaming content if editor read fails
91
- }
92
- }
93
-
94
- // Save to config
95
- try {
96
- await updateConfig({
97
- editorData: structuredClone(editorData || {}),
98
- systemRole: finalContent,
99
- });
100
- } catch (error) {
101
- console.error('[ProfileEditor] Failed to save streaming content:', error);
102
- }
103
-
104
- // Reset streaming state
105
- set({
106
- streamingContent: undefined,
107
- streamingInProgress: false,
108
- });
109
- },
110
-
111
- flushSave: () => {
112
- debouncedSave?.flush();
113
- },
114
-
115
- handleContentChange: (updateConfig) => {
116
- const { editor } = get();
117
- if (!editor) return;
118
-
119
- // Create debounced save on first use
120
- if (!debouncedSave) {
121
- debouncedSave = createDebouncedSave(get, updateConfig);
122
- }
123
-
124
- try {
125
- const markdownContent = (editor.getDocument('markdown') as unknown as string) || '';
126
- const jsonContent = editor.getDocument('json') as unknown as Record<string, any>;
127
-
128
- debouncedSave({
129
- editorData: structuredClone(jsonContent || {}),
130
- systemRole: markdownContent || '',
131
- });
132
- } catch (error) {
133
- console.error('[ProfileEditor] Failed to read editor content:', error);
134
- }
135
- },
136
-
137
- setChatPanelExpanded: (expanded) => {
138
- if (typeof expanded === 'function') {
139
- set((state) => ({ chatPanelExpanded: expanded(state.chatPanelExpanded) }));
140
- } else {
141
- set({ chatPanelExpanded: expanded });
142
- }
143
- },
144
-
145
- startStreaming: () => {
146
- const { editor } = get();
147
-
148
- // Clear editor content and prepare for streaming
149
- if (editor) {
150
- try {
151
- editor.setDocument('markdown', '');
152
- } catch {
153
- // Ignore errors
154
- }
155
- }
156
-
157
- set({
158
- streamingContent: '',
159
- streamingInProgress: true,
160
- });
161
- },
162
- };
163
- };
@@ -1,23 +0,0 @@
1
- 'use client';
2
-
3
- import { type StoreApiWithSelector } from '@lobechat/types';
4
- import { createContext } from 'zustand-utils';
5
- import { subscribeWithSelector } from 'zustand/middleware';
6
- import { shallow } from 'zustand/shallow';
7
- import { createWithEqualityFn } from 'zustand/traditional';
8
-
9
- import { type Store, store } from './action';
10
- import { type State } from './initialState';
11
-
12
- export type { PublicState, State } from './initialState';
13
-
14
- export const createStore = (initState?: Partial<State>) =>
15
- createWithEqualityFn(subscribeWithSelector(store(initState)), shallow);
16
-
17
- export const {
18
- useStore: useProfileStore,
19
- useStoreApi,
20
- Provider,
21
- } = createContext<StoreApiWithSelector<Store>>();
22
-
23
- export { selectors } from './selectors';
@@ -1,7 +0,0 @@
1
- import { type Store } from './action';
2
-
3
- export const selectors = {
4
- chatPanelExpanded: (s: Store) => s.chatPanelExpanded,
5
- editor: (s: Store) => s.editor,
6
- editorState: (s: Store) => s.editorState,
7
- };
@@ -1,84 +0,0 @@
1
- import {
2
- IEditor,
3
- ReactCodePlugin,
4
- ReactCodemirrorPlugin,
5
- ReactHRPlugin,
6
- ReactLinkPlugin,
7
- ReactListPlugin,
8
- ReactMathPlugin,
9
- ReactTablePlugin,
10
- } from '@lobehub/editor';
11
- import { Editor } from '@lobehub/editor/react';
12
- import { Flexbox } from '@lobehub/ui';
13
- import { FC, useMemo } from 'react';
14
-
15
- import { useUserStore } from '@/store/user';
16
- import { labPreferSelectors } from '@/store/user/selectors';
17
-
18
- import TypoBar from './Typobar';
19
-
20
- interface EditorCanvasProps {
21
- defaultValue?: string;
22
- editor?: IEditor;
23
- }
24
-
25
- const EditorCanvas: FC<EditorCanvasProps> = ({ defaultValue, editor }) => {
26
- const enableRichRender = useUserStore(labPreferSelectors.enableInputMarkdown);
27
-
28
- const richRenderProps = useMemo(
29
- () =>
30
- !enableRichRender
31
- ? {
32
- enablePasteMarkdown: false,
33
- markdownOption: false,
34
- }
35
- : {
36
- plugins: [
37
- ReactListPlugin,
38
- ReactCodePlugin,
39
- ReactCodemirrorPlugin,
40
- ReactHRPlugin,
41
- ReactLinkPlugin,
42
- ReactTablePlugin,
43
- ReactMathPlugin,
44
- ],
45
- },
46
- [enableRichRender],
47
- );
48
-
49
- return (
50
- <>
51
- {enableRichRender && <TypoBar editor={editor} />}
52
- <Flexbox
53
- padding={16}
54
- style={{ cursor: 'text', maxHeight: '80vh', minHeight: '50vh', overflowY: 'auto' }}
55
- >
56
- <Editor
57
- autoFocus
58
- content={''}
59
- editor={editor}
60
- onInit={(editor) => {
61
- if (!editor || !defaultValue) return;
62
- try {
63
- if (enableRichRender) {
64
- editor?.setDocument('markdown', defaultValue);
65
- } else {
66
- editor?.setDocument('text', defaultValue);
67
- }
68
- } catch (e) {
69
- console.error('setDocument error:', e);
70
- }
71
- }}
72
- style={{
73
- paddingBottom: 120,
74
- }}
75
- type={'text'}
76
- variant={'chat'}
77
- {...richRenderProps}
78
- />
79
- </Flexbox>
80
- </>
81
- );
82
- };
83
-
84
- export default EditorCanvas;
@@ -1,139 +0,0 @@
1
- import { HotkeyEnum, type IEditor, getHotkeyById } from '@lobehub/editor';
2
- import { useEditorState } from '@lobehub/editor/react';
3
- import {
4
- ChatInputActionBar,
5
- ChatInputActions,
6
- type ChatInputActionsProps,
7
- } from '@lobehub/editor/react';
8
- import { cssVar } from 'antd-style';
9
- import {
10
- BoldIcon,
11
- CodeXmlIcon,
12
- ItalicIcon,
13
- ListIcon,
14
- ListOrderedIcon,
15
- ListTodoIcon,
16
- MessageSquareQuote,
17
- SigmaIcon,
18
- SquareDashedBottomCodeIcon,
19
- StrikethroughIcon,
20
- UnderlineIcon,
21
- } from 'lucide-react';
22
- import { memo, useMemo } from 'react';
23
- import { useTranslation } from 'react-i18next';
24
-
25
- const TypoBar = memo<{ editor?: IEditor }>(({ editor }) => {
26
- const { t } = useTranslation('editor');
27
- const editorState = useEditorState(editor);
28
-
29
- const items: ChatInputActionsProps['items'] = useMemo(
30
- () =>
31
- [
32
- {
33
- active: editorState.isBold,
34
- icon: BoldIcon,
35
- key: 'bold',
36
- label: t('typobar.bold'),
37
- onClick: editorState.bold,
38
- tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Bold).keys },
39
- },
40
- {
41
- active: editorState.isItalic,
42
- icon: ItalicIcon,
43
- key: 'italic',
44
- label: t('typobar.italic'),
45
- onClick: editorState.italic,
46
- tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Italic).keys },
47
- },
48
- {
49
- active: editorState.isUnderline,
50
- icon: UnderlineIcon,
51
- key: 'underline',
52
- label: t('typobar.underline'),
53
- onClick: editorState.underline,
54
- tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Underline).keys },
55
- },
56
- {
57
- active: editorState.isStrikethrough,
58
- icon: StrikethroughIcon,
59
- key: 'strikethrough',
60
- label: t('typobar.strikethrough'),
61
- onClick: editorState.strikethrough,
62
- tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Strikethrough).keys },
63
- },
64
- {
65
- type: 'divider',
66
- },
67
-
68
- {
69
- icon: ListIcon,
70
- key: 'bulletList',
71
- label: t('typobar.bulletList'),
72
- onClick: editorState.bulletList,
73
- tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.BulletList).keys },
74
- },
75
- {
76
- icon: ListOrderedIcon,
77
- key: 'numberlist',
78
- label: t('typobar.numberList'),
79
- onClick: editorState.numberList,
80
- tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.NumberList).keys },
81
- },
82
- {
83
- icon: ListTodoIcon,
84
- key: 'tasklist',
85
- label: t('typobar.taskList'),
86
- onClick: editorState.checkList,
87
- },
88
- {
89
- type: 'divider',
90
- },
91
- {
92
- active: editorState.isBlockquote,
93
- icon: MessageSquareQuote,
94
- key: 'blockquote',
95
- label: t('typobar.blockquote'),
96
- onClick: editorState.blockquote,
97
- },
98
- {
99
- type: 'divider',
100
- },
101
- {
102
- icon: SigmaIcon,
103
- key: 'math',
104
- label: t('typobar.tex'),
105
- onClick: editorState.insertMath,
106
- },
107
- {
108
- active: editorState.isCode,
109
- icon: CodeXmlIcon,
110
- key: 'code',
111
- label: t('typobar.code'),
112
- onClick: editorState.code,
113
- tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.CodeInline).keys },
114
- },
115
- {
116
- icon: SquareDashedBottomCodeIcon,
117
- key: 'codeblock',
118
- label: t('typobar.codeblock'),
119
- onClick: editorState.codeblock,
120
- },
121
- ].filter(Boolean) as ChatInputActionsProps['items'],
122
- [editorState],
123
- );
124
-
125
- return (
126
- <ChatInputActionBar
127
- left={<ChatInputActions items={items} />}
128
- style={{
129
- background: cssVar.colorFillQuaternary,
130
- borderTopLeftRadius: 8,
131
- borderTopRightRadius: 8,
132
- }}
133
- />
134
- );
135
- });
136
-
137
- TypoBar.displayName = 'TypoBar';
138
-
139
- export default TypoBar;
@@ -1,192 +0,0 @@
1
- import type {
2
- GetAvailableModelsParams,
3
- InstallPluginParams,
4
- SearchMarketToolsParams,
5
- UpdateAgentConfigParams,
6
- UpdatePromptParams,
7
- } from '@lobechat/builtin-tool-agent-builder';
8
- import { AgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-agent-builder/executionRuntime';
9
- import debug from 'debug';
10
- import { type StateCreator } from 'zustand/vanilla';
11
-
12
- import { getAgentStoreState } from '@/store/agent';
13
- import { type ChatStore } from '@/store/chat/store';
14
-
15
- const log = debug('lobe-store:builtin-tool:agent-builder');
16
-
17
- export interface AgentBuilderAction {
18
- getAvailableModels: (id: string, params: GetAvailableModelsParams) => Promise<boolean>;
19
- installPlugin: (id: string, params: InstallPluginParams) => Promise<boolean>;
20
- internal_triggerAgentBuilderToolCalling: (
21
- id: string,
22
- apiName: string,
23
- params: any,
24
- ) => Promise<boolean>;
25
- searchMarketTools: (id: string, params: SearchMarketToolsParams) => Promise<boolean>;
26
- updateConfig: (id: string, params: UpdateAgentConfigParams) => Promise<boolean>;
27
- updatePrompt: (id: string, params: UpdatePromptParams) => Promise<boolean>;
28
- }
29
-
30
- const runtime = new AgentBuilderExecutionRuntime();
31
-
32
- export const agentBuilderSlice: StateCreator<
33
- ChatStore,
34
- [['zustand/devtools', never]],
35
- [],
36
- AgentBuilderAction
37
- > = (set, get) => ({
38
- // ==================== Read Operations ====================
39
-
40
- getAvailableModels: async (id, params) => {
41
- return get().internal_triggerAgentBuilderToolCalling(id, 'getAvailableModels', params);
42
- },
43
-
44
- installPlugin: async (id, params) => {
45
- return get().internal_triggerAgentBuilderToolCalling(id, 'installPlugin', params);
46
- },
47
-
48
- // ==================== Internal Helper ====================
49
- /**
50
- * Internal helper to execute agent builder tool calling operations
51
- * Handles operation tracking, error handling, and state updates
52
- */
53
- internal_triggerAgentBuilderToolCalling: async (id, apiName, params) => {
54
- // Get parent operationId from messageOperationMap (should be executeToolCall)
55
- const parentOperationId = get().messageOperationMap[id];
56
-
57
- // Create child operation for agent builder execution
58
- // Auto-associates message with this operation via messageId in context
59
- const { operationId, abortController } = get().startOperation({
60
- context: {
61
- messageId: id,
62
- },
63
- metadata: {
64
- apiName,
65
- params,
66
- startTime: Date.now(),
67
- },
68
- parentOperationId,
69
- type: 'builtinToolAgentBuilder',
70
- });
71
-
72
- log(
73
- '[%s] messageId=%s, parentOpId=%s, opId=%s, aborted=%s',
74
- apiName,
75
- id,
76
- parentOperationId,
77
- operationId,
78
- abortController.signal.aborted,
79
- );
80
-
81
- const context = { operationId };
82
-
83
- try {
84
- // Get target agent ID from AgentStore, not ChatStore
85
- // ChatStore's activeAgentId is for message scoping (might be AgentBuilder's own ID)
86
- // AgentStore's activeAgentId is the actual target agent being configured
87
- const agentId = getAgentStoreState().activeAgentId;
88
-
89
- if (!agentId) {
90
- throw new Error('No active agent found');
91
- }
92
-
93
- // Execute the runtime method
94
- let result;
95
- switch (apiName) {
96
- case 'updateAgentConfig':
97
- case 'updateConfig': {
98
- result = await runtime.updateAgentConfig(agentId, params as UpdateAgentConfigParams);
99
- break;
100
- }
101
- case 'getAvailableModels': {
102
- result = await runtime.getAvailableModels(params as GetAvailableModelsParams);
103
- break;
104
- }
105
- case 'searchMarketTools': {
106
- result = await runtime.searchMarketTools(params as SearchMarketToolsParams);
107
- break;
108
- }
109
- case 'installPlugin': {
110
- result = await runtime.installPlugin(agentId, params as InstallPluginParams);
111
- break;
112
- }
113
- case 'updatePrompt': {
114
- result = await runtime.updatePrompt(agentId, {
115
- streaming: true,
116
- ...params,
117
- } as UpdatePromptParams);
118
- break;
119
- }
120
- default: {
121
- throw new Error(`Unknown API name: ${apiName}`);
122
- }
123
- }
124
-
125
- const { content, success, error, state } = result;
126
-
127
- // Complete operation
128
- get().completeOperation(operationId);
129
-
130
- // Update message content
131
- await get().optimisticUpdateMessageContent(id, content, undefined, context);
132
-
133
- if (success) {
134
- // Update plugin state with the result
135
- await get().optimisticUpdatePluginState(id, state, context);
136
- } else {
137
- // Update plugin error
138
- await get().optimisticUpdatePluginError(id, error, context);
139
- }
140
-
141
- return true;
142
- } catch (error) {
143
- const err = error as Error;
144
-
145
- log('[%s] Error: messageId=%s, error=%s', apiName, id, err.message);
146
-
147
- // Check if it's an abort error
148
- if (err.message.includes('The user aborted a request.') || err.name === 'AbortError') {
149
- log('[%s] Request aborted: messageId=%s', apiName, id);
150
- // Fail operation for abort
151
- get().failOperation(operationId, {
152
- message: 'User cancelled the request',
153
- type: 'UserAborted',
154
- });
155
- // Don't update error message for user aborts
156
- return true;
157
- }
158
-
159
- // Fail operation for other errors
160
- get().failOperation(operationId, {
161
- message: err.message,
162
- type: 'PluginServerError',
163
- });
164
-
165
- // For other errors, update message
166
- await get().optimisticUpdateMessagePluginError(
167
- id,
168
- {
169
- body: error,
170
- message: err.message,
171
- type: 'PluginServerError',
172
- },
173
- context,
174
- );
175
-
176
- return true;
177
- }
178
- },
179
-
180
- searchMarketTools: async (id, params) => {
181
- return get().internal_triggerAgentBuilderToolCalling(id, 'searchMarketTools', params);
182
- },
183
-
184
- // ==================== Write Operations ====================
185
- updateConfig: async (id, params) => {
186
- return get().internal_triggerAgentBuilderToolCalling(id, 'updateConfig', params);
187
- },
188
-
189
- updatePrompt: async (id, params) => {
190
- return get().internal_triggerAgentBuilderToolCalling(id, 'updatePrompt', params);
191
- },
192
- });