@lobehub/lobehub 2.0.0-next.272 → 2.0.0-next.274

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 (296) 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/common.json +1 -1
  5. package/locales/ar/discover.json +2 -2
  6. package/locales/ar/models.json +40 -12
  7. package/locales/ar/onboarding.json +1 -1
  8. package/locales/ar/plugin.json +22 -1
  9. package/locales/ar/providers.json +0 -1
  10. package/locales/bg-BG/chat.json +7 -0
  11. package/locales/bg-BG/common.json +2 -0
  12. package/locales/bg-BG/discover.json +2 -2
  13. package/locales/bg-BG/models.json +48 -13
  14. package/locales/bg-BG/onboarding.json +1 -1
  15. package/locales/bg-BG/plugin.json +22 -1
  16. package/locales/bg-BG/providers.json +0 -1
  17. package/locales/de-DE/chat.json +7 -0
  18. package/locales/de-DE/common.json +2 -0
  19. package/locales/de-DE/discover.json +2 -2
  20. package/locales/de-DE/models.json +37 -13
  21. package/locales/de-DE/onboarding.json +3 -0
  22. package/locales/de-DE/plugin.json +22 -1
  23. package/locales/de-DE/providers.json +0 -1
  24. package/locales/en-US/chat.json +7 -0
  25. package/locales/en-US/discover.json +2 -2
  26. package/locales/en-US/models.json +15 -15
  27. package/locales/en-US/plugin.json +22 -1
  28. package/locales/en-US/providers.json +0 -1
  29. package/locales/es-ES/chat.json +7 -0
  30. package/locales/es-ES/common.json +2 -0
  31. package/locales/es-ES/discover.json +2 -2
  32. package/locales/es-ES/models.json +32 -14
  33. package/locales/es-ES/onboarding.json +3 -0
  34. package/locales/es-ES/plugin.json +22 -1
  35. package/locales/es-ES/providers.json +0 -1
  36. package/locales/fa-IR/chat.json +7 -0
  37. package/locales/fa-IR/common.json +2 -0
  38. package/locales/fa-IR/discover.json +2 -2
  39. package/locales/fa-IR/models.json +36 -14
  40. package/locales/fa-IR/onboarding.json +3 -0
  41. package/locales/fa-IR/plugin.json +22 -1
  42. package/locales/fa-IR/providers.json +0 -1
  43. package/locales/fr-FR/chat.json +7 -0
  44. package/locales/fr-FR/common.json +2 -0
  45. package/locales/fr-FR/discover.json +2 -2
  46. package/locales/fr-FR/models.json +95 -13
  47. package/locales/fr-FR/onboarding.json +3 -0
  48. package/locales/fr-FR/plugin.json +22 -1
  49. package/locales/fr-FR/providers.json +0 -1
  50. package/locales/it-IT/chat.json +7 -0
  51. package/locales/it-IT/common.json +2 -0
  52. package/locales/it-IT/discover.json +2 -2
  53. package/locales/it-IT/models.json +8 -13
  54. package/locales/it-IT/onboarding.json +3 -0
  55. package/locales/it-IT/plugin.json +22 -1
  56. package/locales/it-IT/providers.json +0 -1
  57. package/locales/ja-JP/chat.json +7 -0
  58. package/locales/ja-JP/common.json +2 -0
  59. package/locales/ja-JP/discover.json +2 -2
  60. package/locales/ja-JP/models.json +76 -8
  61. package/locales/ja-JP/onboarding.json +3 -0
  62. package/locales/ja-JP/plugin.json +22 -1
  63. package/locales/ja-JP/providers.json +0 -1
  64. package/locales/ko-KR/chat.json +7 -0
  65. package/locales/ko-KR/common.json +2 -0
  66. package/locales/ko-KR/discover.json +2 -2
  67. package/locales/ko-KR/models.json +8 -15
  68. package/locales/ko-KR/onboarding.json +3 -0
  69. package/locales/ko-KR/plugin.json +22 -1
  70. package/locales/ko-KR/providers.json +0 -1
  71. package/locales/nl-NL/chat.json +7 -0
  72. package/locales/nl-NL/common.json +2 -0
  73. package/locales/nl-NL/discover.json +2 -2
  74. package/locales/nl-NL/models.json +98 -9
  75. package/locales/nl-NL/onboarding.json +3 -0
  76. package/locales/nl-NL/plugin.json +22 -1
  77. package/locales/nl-NL/providers.json +0 -1
  78. package/locales/pl-PL/chat.json +7 -0
  79. package/locales/pl-PL/common.json +2 -0
  80. package/locales/pl-PL/discover.json +2 -2
  81. package/locales/pl-PL/models.json +38 -13
  82. package/locales/pl-PL/onboarding.json +3 -0
  83. package/locales/pl-PL/plugin.json +22 -1
  84. package/locales/pl-PL/providers.json +0 -1
  85. package/locales/pt-BR/chat.json +7 -0
  86. package/locales/pt-BR/common.json +2 -0
  87. package/locales/pt-BR/discover.json +2 -2
  88. package/locales/pt-BR/models.json +50 -13
  89. package/locales/pt-BR/onboarding.json +3 -0
  90. package/locales/pt-BR/plugin.json +22 -1
  91. package/locales/pt-BR/providers.json +0 -1
  92. package/locales/ru-RU/chat.json +7 -0
  93. package/locales/ru-RU/common.json +2 -0
  94. package/locales/ru-RU/discover.json +2 -2
  95. package/locales/ru-RU/models.json +54 -13
  96. package/locales/ru-RU/onboarding.json +3 -0
  97. package/locales/ru-RU/plugin.json +22 -1
  98. package/locales/ru-RU/providers.json +0 -1
  99. package/locales/tr-TR/chat.json +7 -0
  100. package/locales/tr-TR/common.json +2 -0
  101. package/locales/tr-TR/discover.json +2 -2
  102. package/locales/tr-TR/models.json +40 -13
  103. package/locales/tr-TR/onboarding.json +3 -0
  104. package/locales/tr-TR/plugin.json +22 -1
  105. package/locales/tr-TR/providers.json +0 -1
  106. package/locales/vi-VN/chat.json +7 -0
  107. package/locales/vi-VN/common.json +2 -0
  108. package/locales/vi-VN/discover.json +2 -2
  109. package/locales/vi-VN/models.json +8 -8
  110. package/locales/vi-VN/onboarding.json +3 -0
  111. package/locales/vi-VN/plugin.json +22 -1
  112. package/locales/vi-VN/providers.json +0 -1
  113. package/locales/zh-CN/chat.json +7 -0
  114. package/locales/zh-CN/discover.json +2 -2
  115. package/locales/zh-CN/models.json +95 -13
  116. package/locales/zh-CN/onboarding.json +3 -0
  117. package/locales/zh-CN/plugin.json +22 -1
  118. package/locales/zh-CN/providers.json +0 -1
  119. package/locales/zh-TW/chat.json +7 -0
  120. package/locales/zh-TW/common.json +2 -0
  121. package/locales/zh-TW/discover.json +2 -2
  122. package/locales/zh-TW/models.json +86 -13
  123. package/locales/zh-TW/onboarding.json +3 -0
  124. package/locales/zh-TW/plugin.json +22 -1
  125. package/locales/zh-TW/providers.json +0 -1
  126. package/package.json +1 -1
  127. package/packages/builtin-tool-agent-builder/package.json +1 -0
  128. package/packages/builtin-tool-agent-builder/src/client/Inspector/GetAvailableModels/index.tsx +66 -0
  129. package/packages/builtin-tool-agent-builder/src/client/Inspector/InstallPlugin/index.tsx +63 -0
  130. package/packages/builtin-tool-agent-builder/src/client/Inspector/SearchMarketTools/index.tsx +64 -0
  131. package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdateConfig/index.tsx +94 -0
  132. package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdatePrompt/index.tsx +96 -0
  133. package/packages/builtin-tool-agent-builder/src/client/Inspector/index.ts +29 -0
  134. package/packages/builtin-tool-agent-builder/src/client/index.ts +13 -0
  135. package/packages/builtin-tool-agent-builder/src/executor.ts +132 -0
  136. package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/ExecuteCode/index.tsx +5 -14
  137. package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/RunCommand/index.tsx +5 -13
  138. package/packages/builtin-tool-group-agent-builder/package.json +7 -1
  139. package/packages/builtin-tool-group-agent-builder/src/ExecutionRuntime/index.ts +331 -87
  140. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/BatchCreateAgents/index.tsx +110 -0
  141. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/CreateAgent/index.tsx +72 -0
  142. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsx +57 -0
  143. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsx +57 -0
  144. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/SearchAgent/index.tsx +66 -0
  145. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsx +120 -0
  146. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroup/index.tsx +87 -0
  147. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroupPrompt/index.tsx +99 -0
  148. package/packages/builtin-tool-group-agent-builder/src/client/Inspector/index.ts +52 -0
  149. package/packages/builtin-tool-group-agent-builder/src/client/Render/BatchCreateAgents.tsx +103 -0
  150. package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateAgentPrompt/index.tsx +36 -0
  151. package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateGroupPrompt/index.tsx +36 -0
  152. package/packages/builtin-tool-group-agent-builder/src/client/Render/index.ts +16 -0
  153. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/BatchCreateAgents/index.tsx +88 -0
  154. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateAgentPrompt/index.tsx +37 -0
  155. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateGroupPrompt/index.tsx +35 -0
  156. package/packages/builtin-tool-group-agent-builder/src/client/Streaming/index.ts +22 -0
  157. package/packages/builtin-tool-group-agent-builder/src/client/index.ts +26 -0
  158. package/packages/builtin-tool-group-agent-builder/src/executor.ts +284 -0
  159. package/packages/builtin-tool-group-agent-builder/src/index.ts +1 -14
  160. package/packages/builtin-tool-group-agent-builder/src/manifest.ts +160 -15
  161. package/packages/builtin-tool-group-agent-builder/src/systemRole.ts +232 -46
  162. package/packages/builtin-tool-group-agent-builder/src/types.ts +191 -41
  163. package/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsx +2 -2
  164. package/packages/builtin-tool-group-management/src/manifest.ts +1 -1
  165. package/packages/builtin-tool-gtd/src/client/Inspector/ClearTodos/index.tsx +5 -11
  166. package/packages/builtin-tool-gtd/src/client/Inspector/CompleteTodos/index.tsx +3 -9
  167. package/packages/builtin-tool-gtd/src/client/Inspector/CreatePlan/index.tsx +6 -15
  168. package/packages/builtin-tool-gtd/src/client/Inspector/CreateTodos/index.tsx +3 -9
  169. package/packages/builtin-tool-gtd/src/client/Inspector/ExecTask/index.tsx +6 -17
  170. package/packages/builtin-tool-gtd/src/client/Inspector/RemoveTodos/index.tsx +3 -9
  171. package/packages/builtin-tool-gtd/src/client/Inspector/UpdatePlan/index.tsx +3 -9
  172. package/packages/builtin-tool-gtd/src/client/Inspector/UpdateTodos/index.tsx +3 -9
  173. package/packages/builtin-tool-knowledge-base/src/client/Inspector/ReadKnowledge/index.tsx +4 -16
  174. package/packages/builtin-tool-knowledge-base/src/client/Inspector/SearchKnowledgeBase/index.tsx +5 -16
  175. package/packages/builtin-tool-local-system/src/client/Inspector/EditLocalFile/index.tsx +4 -12
  176. package/packages/builtin-tool-local-system/src/client/Inspector/GlobLocalFiles/index.tsx +5 -13
  177. package/packages/builtin-tool-local-system/src/client/Inspector/GrepContent/index.tsx +5 -16
  178. package/packages/builtin-tool-local-system/src/client/Inspector/ListLocalFiles/index.tsx +5 -16
  179. package/packages/builtin-tool-local-system/src/client/Inspector/ReadLocalFile/index.tsx +5 -16
  180. package/packages/builtin-tool-local-system/src/client/Inspector/RenameLocalFile/index.tsx +5 -11
  181. package/packages/builtin-tool-local-system/src/client/Inspector/RunCommand/index.tsx +5 -13
  182. package/packages/builtin-tool-local-system/src/client/Inspector/SearchLocalFiles/index.tsx +5 -16
  183. package/packages/builtin-tool-local-system/src/client/Inspector/WriteLocalFile/index.tsx +6 -15
  184. package/packages/builtin-tool-notebook/src/client/Inspector/CreateDocument/index.tsx +7 -15
  185. package/packages/builtin-tool-page-agent/src/client/Inspector/EditTitle/index.tsx +5 -14
  186. package/packages/builtin-tool-page-agent/src/client/Inspector/GetPageContent/index.tsx +7 -8
  187. package/packages/builtin-tool-page-agent/src/client/Inspector/InitPage/index.tsx +4 -10
  188. package/packages/builtin-tool-page-agent/src/client/Inspector/ModifyNodes/index.tsx +3 -9
  189. package/packages/builtin-tool-page-agent/src/client/Inspector/ReplaceText/index.tsx +5 -11
  190. package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlMultiPages/index.tsx +6 -15
  191. package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlSinglePage/index.tsx +6 -15
  192. package/packages/builtin-tool-web-browsing/src/client/Inspector/Search/index.tsx +4 -15
  193. package/packages/database/src/models/chatGroup.ts +1 -1
  194. package/packages/model-bank/src/aiModels/aihubmix.ts +2 -1
  195. package/packages/model-bank/src/aiModels/google.ts +2 -1
  196. package/packages/model-bank/src/aiModels/infiniai.ts +9 -6
  197. package/packages/model-bank/src/aiModels/minimax.ts +9 -5
  198. package/packages/model-bank/src/aiModels/ollamacloud.ts +4 -2
  199. package/packages/model-bank/src/aiModels/vertexai.ts +2 -1
  200. package/packages/types/src/agentGroup/index.ts +8 -0
  201. package/patches/@upstash__qstash.patch +13 -1
  202. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Header/Nav.tsx +1 -1
  203. package/src/app/[variants]/(main)/agent/cron/[cronId]/index.tsx +4 -3
  204. package/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsx +1 -1
  205. package/src/app/[variants]/(main)/agent/profile/features/store/action.ts +18 -21
  206. package/src/app/[variants]/(main)/group/_layout/GroupIdSync.tsx +6 -1
  207. package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/AgentProfilePopup.tsx +29 -21
  208. package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMember.tsx +1 -0
  209. package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMemberItem.tsx +35 -18
  210. package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/AddTopicButon.tsx +2 -10
  211. package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/Nav.tsx +10 -2
  212. package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/index.tsx +1 -2
  213. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/AgentBuilderProvider.tsx +1 -0
  214. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx +15 -9
  215. package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/index.tsx +12 -6
  216. package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor/AgentHeader.tsx → GroupProfile/GroupHeader.tsx} +22 -29
  217. package/src/app/[variants]/(main)/group/profile/features/GroupProfile/index.tsx +96 -0
  218. package/src/app/[variants]/(main)/group/profile/features/Header/AgentBuilderToggle.tsx +3 -4
  219. package/src/app/[variants]/(main)/group/profile/features/Header/AutoSaveHint.tsx +11 -7
  220. package/src/app/[variants]/(main)/group/profile/features/Header/ChromeTabs/index.tsx +147 -0
  221. package/src/app/[variants]/(main)/group/profile/features/Header/index.tsx +104 -13
  222. package/src/app/[variants]/(main)/group/profile/features/MemberProfile/AgentHeader.tsx +222 -0
  223. package/src/app/[variants]/(main)/group/profile/features/MemberProfile/index.tsx +155 -0
  224. package/src/app/[variants]/(main)/group/profile/features/ProfileHydration.tsx +63 -5
  225. package/src/app/[variants]/(main)/group/profile/index.tsx +34 -37
  226. package/src/app/[variants]/(mobile)/(home)/_layout/SessionHydration.tsx +1 -1
  227. package/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/index.tsx +1 -1
  228. package/src/features/AgentBuilder/index.tsx +16 -1
  229. package/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx +3 -2
  230. package/src/features/EditorCanvas/EditorCanvas.test.tsx +206 -0
  231. package/src/features/EditorCanvas/EditorDataMode.tsx +53 -19
  232. package/src/features/EditorModal/index.tsx +2 -2
  233. package/src/features/NavPanel/components/SessionHydration.tsx +1 -1
  234. package/src/features/ShareModal/ShareImage/ChatList/index.tsx +1 -1
  235. package/src/features/ShareModal/SharePdf/index.tsx +1 -1
  236. package/src/hooks/useBidirectionalQuerySync.ts +112 -0
  237. package/src/locales/default/chat.ts +10 -0
  238. package/src/locales/default/plugin.ts +22 -1
  239. package/src/server/modules/AgentRuntime/RuntimeExecutors.ts +45 -45
  240. package/src/server/modules/KeyVaultsEncrypt/index.ts +6 -6
  241. package/src/server/modules/S3/index.ts +1 -1
  242. package/src/server/routers/lambda/agent.ts +24 -0
  243. package/src/server/routers/lambda/agentGroup.ts +39 -0
  244. package/src/services/agent.ts +22 -0
  245. package/src/services/chatGroup/index.ts +14 -0
  246. package/src/store/agent/selectors/selectors.ts +3 -0
  247. package/src/store/agentGroup/initialState.ts +6 -0
  248. package/src/store/agentGroup/selectors/byId.ts +3 -1
  249. package/src/store/agentGroup/selectors/current.ts +2 -2
  250. package/src/store/agentGroup/slices/lifecycle.ts +18 -0
  251. package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockStore.ts +1 -1
  252. package/src/store/chat/slices/aiAgent/actions/__tests__/agentGroup.test.ts +4 -1
  253. package/src/store/chat/slices/aiAgent/actions/agentGroup.ts +1 -1
  254. package/src/store/chat/slices/aiChat/actions/__tests__/conversationLifecycle.test.ts +65 -0
  255. package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +2 -1
  256. package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +1 -1
  257. package/src/store/chat/slices/builtinTool/actions/index.ts +1 -6
  258. package/src/store/chat/slices/message/action.test.ts +5 -5
  259. package/src/store/chat/slices/message/actions/publicApi.ts +5 -5
  260. package/src/store/chat/slices/message/initialState.ts +0 -5
  261. package/src/store/chat/slices/message/selectors/displayMessage.test.ts +4 -4
  262. package/src/store/chat/slices/plugin/action.test.ts +54 -19
  263. package/src/store/chat/slices/plugin/actions/pluginTypes.ts +15 -21
  264. package/src/store/chat/slices/topic/action.test.ts +74 -24
  265. package/src/store/chat/slices/topic/action.ts +21 -13
  266. package/src/store/chat/slices/topic/selectors.test.ts +1 -1
  267. package/src/store/global/initialState.ts +10 -0
  268. package/src/store/global/selectors/systemStatus.ts +5 -0
  269. package/src/store/groupProfile/action.ts +168 -0
  270. package/src/store/groupProfile/index.ts +16 -0
  271. package/src/{app/[variants]/(main)/group/profile/features/store → store/groupProfile}/initialState.ts +17 -0
  272. package/src/store/groupProfile/selectors.ts +13 -0
  273. package/src/store/tool/slices/builtin/executors/index.ts +4 -0
  274. package/src/styles/text.ts +16 -0
  275. package/src/tools/inspectors.ts +13 -0
  276. package/src/tools/renders.ts +3 -0
  277. package/src/tools/streamings.ts +8 -0
  278. package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/TypoBar.tsx +0 -129
  279. package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/index.tsx +0 -138
  280. package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/useSlashItems.tsx +0 -139
  281. package/src/app/[variants]/(main)/group/profile/features/ProfileEditor/index.tsx +0 -82
  282. package/src/app/[variants]/(main)/group/profile/features/ProfileProvider.tsx +0 -20
  283. package/src/app/[variants]/(main)/group/profile/features/StoreUpdater.tsx +0 -24
  284. package/src/app/[variants]/(main)/group/profile/features/store/action.ts +0 -163
  285. package/src/app/[variants]/(main)/group/profile/features/store/index.ts +0 -23
  286. package/src/app/[variants]/(main)/group/profile/features/store/selectors.ts +0 -7
  287. package/src/features/EditorModal/EditorCanvas.tsx +0 -84
  288. package/src/features/EditorModal/Typobar.tsx +0 -139
  289. package/src/store/chat/slices/builtinTool/actions/agentBuilder.ts +0 -192
  290. package/src/store/chat/slices/builtinTool/actions/groupAgentBuilder.ts +0 -242
  291. package/src/tools/executionRuntimes.ts +0 -14
  292. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/AgentTool.tsx +0 -0
  293. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/MentionDropdown.tsx +0 -0
  294. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/index.tsx +0 -0
  295. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/types.ts +0 -0
  296. /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/useMentionItems.tsx +0 -0
@@ -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
- });
@@ -1,242 +0,0 @@
1
- import type {
2
- GetAvailableModelsParams,
3
- InstallPluginParams,
4
- SearchMarketToolsParams,
5
- UpdateAgentConfigParams,
6
- } from '@lobechat/builtin-tool-agent-builder';
7
- import { AgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-agent-builder/executionRuntime';
8
- import type {
9
- InviteAgentParams,
10
- RemoveAgentParams,
11
- UpdateGroupConfigParams,
12
- UpdateGroupPromptParams,
13
- } from '@lobechat/builtin-tool-group-agent-builder';
14
- import { GroupAgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-group-agent-builder/executionRuntime';
15
- import debug from 'debug';
16
- import { type StateCreator } from 'zustand/vanilla';
17
-
18
- import { getAgentStoreState } from '@/store/agent';
19
- import { getChatGroupStoreState } from '@/store/agentGroup';
20
- import { type ChatStore } from '@/store/chat/store';
21
-
22
- const log = debug('lobe-store:builtin-tool:group-agent-builder');
23
-
24
- export interface GroupAgentBuilderAction {
25
- // Inherited operations from AgentBuilder (operate on supervisor agent)
26
- groupAgentBuilder_getAvailableModels: (
27
- id: string,
28
- params: GetAvailableModelsParams,
29
- ) => Promise<boolean>;
30
- groupAgentBuilder_installPlugin: (id: string, params: InstallPluginParams) => Promise<boolean>;
31
- // Group-specific operations
32
- groupAgentBuilder_inviteAgent: (id: string, params: InviteAgentParams) => Promise<boolean>;
33
- groupAgentBuilder_removeAgent: (id: string, params: RemoveAgentParams) => Promise<boolean>;
34
- groupAgentBuilder_searchMarketTools: (
35
- id: string,
36
- params: SearchMarketToolsParams,
37
- ) => Promise<boolean>;
38
- groupAgentBuilder_updateConfig: (id: string, params: UpdateAgentConfigParams) => Promise<boolean>;
39
- groupAgentBuilder_updateGroupConfig: (
40
- id: string,
41
- params: UpdateGroupConfigParams,
42
- ) => Promise<boolean>;
43
- groupAgentBuilder_updatePrompt: (id: string, params: UpdateGroupPromptParams) => Promise<boolean>;
44
- internal_triggerGroupAgentBuilderToolCalling: (
45
- id: string,
46
- apiName: string,
47
- params: any,
48
- ) => Promise<boolean>;
49
- }
50
-
51
- const agentBuilderRuntime = new AgentBuilderExecutionRuntime();
52
- const groupAgentBuilderRuntime = new GroupAgentBuilderExecutionRuntime();
53
-
54
- export const groupAgentBuilderSlice: StateCreator<
55
- ChatStore,
56
- [['zustand/devtools', never]],
57
- [],
58
- GroupAgentBuilderAction
59
- > = (set, get) => ({
60
- // ==================== Inherited Operations (from AgentBuilder) ====================
61
- groupAgentBuilder_getAvailableModels: async (id, params) => {
62
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'getAvailableModels', params);
63
- },
64
-
65
- groupAgentBuilder_installPlugin: async (id, params) => {
66
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'installPlugin', params);
67
- },
68
-
69
- // ==================== Group-specific Operations ====================
70
- groupAgentBuilder_inviteAgent: async (id, params) => {
71
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'inviteAgent', params);
72
- },
73
-
74
- groupAgentBuilder_removeAgent: async (id, params) => {
75
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'removeAgent', params);
76
- },
77
-
78
- groupAgentBuilder_searchMarketTools: async (id, params) => {
79
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'searchMarketTools', params);
80
- },
81
-
82
- groupAgentBuilder_updateConfig: async (id, params) => {
83
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'updateConfig', params);
84
- },
85
-
86
- groupAgentBuilder_updateGroupConfig: async (id, params) => {
87
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'updateGroupConfig', params);
88
- },
89
-
90
- groupAgentBuilder_updatePrompt: async (id, params) => {
91
- return get().internal_triggerGroupAgentBuilderToolCalling(id, 'updatePrompt', params);
92
- },
93
-
94
- // ==================== Internal Helper ====================
95
-
96
- internal_triggerGroupAgentBuilderToolCalling: async (id, apiName, params) => {
97
- // Get parent operationId from messageOperationMap (should be executeToolCall)
98
- const parentOperationId = get().messageOperationMap[id];
99
-
100
- // Create child operation for group agent builder execution
101
- const { operationId, abortController } = get().startOperation({
102
- context: {
103
- messageId: id,
104
- },
105
- metadata: {
106
- apiName,
107
- params,
108
- startTime: Date.now(),
109
- },
110
- parentOperationId,
111
- type: 'builtinToolGroupAgentBuilder',
112
- });
113
-
114
- log(
115
- '[%s] messageId=%s, parentOpId=%s, opId=%s, aborted=%s',
116
- apiName,
117
- id,
118
- parentOperationId,
119
- operationId,
120
- abortController.signal.aborted,
121
- );
122
-
123
- const context = { operationId };
124
-
125
- try {
126
- // Get the active group ID
127
- const groupId = getChatGroupStoreState().activeGroupId;
128
- if (!groupId) {
129
- throw new Error('No active group found');
130
- }
131
-
132
- // Get supervisor agent ID for config/model operations
133
- const agentId = getAgentStoreState().activeAgentId;
134
-
135
- // Execute the runtime method
136
- let result;
137
- switch (apiName) {
138
- // Group-specific operations
139
- case 'inviteAgent': {
140
- result = await groupAgentBuilderRuntime.inviteAgent(groupId, params as InviteAgentParams);
141
- break;
142
- }
143
- case 'removeAgent': {
144
- result = await groupAgentBuilderRuntime.removeAgent(groupId, params as RemoveAgentParams);
145
- break;
146
- }
147
- case 'updatePrompt': {
148
- result = await groupAgentBuilderRuntime.updatePrompt({
149
- streaming: true,
150
- ...params,
151
- } as UpdateGroupPromptParams);
152
- break;
153
- }
154
- case 'updateGroupConfig': {
155
- result = await groupAgentBuilderRuntime.updateGroupConfig(
156
- params as UpdateGroupConfigParams,
157
- );
158
- break;
159
- }
160
- // Inherited operations (use AgentBuilder runtime for supervisor agent)
161
- case 'updateAgentConfig':
162
- case 'updateConfig': {
163
- if (!agentId) throw new Error('No supervisor agent found');
164
- result = await agentBuilderRuntime.updateAgentConfig(
165
- agentId,
166
- params as UpdateAgentConfigParams,
167
- );
168
- break;
169
- }
170
- case 'getAvailableModels': {
171
- result = await agentBuilderRuntime.getAvailableModels(params as GetAvailableModelsParams);
172
- break;
173
- }
174
- case 'searchMarketTools': {
175
- result = await agentBuilderRuntime.searchMarketTools(params as SearchMarketToolsParams);
176
- break;
177
- }
178
- case 'installPlugin': {
179
- if (!agentId) throw new Error('No supervisor agent found');
180
- result = await agentBuilderRuntime.installPlugin(agentId, params as InstallPluginParams);
181
- break;
182
- }
183
- default: {
184
- throw new Error(`Unknown API name: ${apiName}`);
185
- }
186
- }
187
-
188
- const { content, success, error, state } = result;
189
-
190
- // Complete operation
191
- get().completeOperation(operationId);
192
-
193
- // Update message content
194
- await get().optimisticUpdateMessageContent(id, content, undefined, context);
195
-
196
- if (success) {
197
- // Update plugin state with the result
198
- await get().optimisticUpdatePluginState(id, state, context);
199
- } else {
200
- // Update plugin error
201
- await get().optimisticUpdatePluginError(id, error, context);
202
- }
203
-
204
- return true;
205
- } catch (error) {
206
- const err = error as Error;
207
-
208
- log('[%s] Error: messageId=%s, error=%s', apiName, id, err.message);
209
-
210
- // Check if it's an abort error
211
- if (err.message.includes('The user aborted a request.') || err.name === 'AbortError') {
212
- log('[%s] Request aborted: messageId=%s', apiName, id);
213
- // Fail operation for abort
214
- get().failOperation(operationId, {
215
- message: 'User cancelled the request',
216
- type: 'UserAborted',
217
- });
218
- // Don't update error message for user aborts
219
- return true;
220
- }
221
-
222
- // Fail operation for other errors
223
- get().failOperation(operationId, {
224
- message: err.message,
225
- type: 'PluginServerError',
226
- });
227
-
228
- // For other errors, update message
229
- await get().optimisticUpdateMessagePluginError(
230
- id,
231
- {
232
- body: error,
233
- message: err.message,
234
- type: 'PluginServerError',
235
- },
236
- context,
237
- );
238
-
239
- return true;
240
- }
241
- },
242
- });