@lobehub/chat 0.63.3 → 0.64.0
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.
- package/CHANGELOG.md +37 -0
- package/package.json +1 -1
- package/src/components/EmojiPicker/index.tsx +13 -5
- package/src/features/AgentSetting/AgentMeta/index.tsx +1 -1
- package/src/features/AgentSetting/AgentPlugin/LocalPluginItem.tsx +72 -0
- package/src/features/AgentSetting/AgentPlugin/MarketList.tsx +160 -0
- package/src/features/AgentSetting/AgentPlugin/PluginSettings.tsx +76 -0
- package/src/features/AgentSetting/AgentPlugin/index.tsx +8 -143
- package/src/features/PluginDevModal/ManifestForm.tsx +96 -0
- package/src/features/PluginDevModal/MetaForm.tsx +90 -0
- package/src/features/PluginDevModal/PluginPreview.tsx +36 -0
- package/src/features/PluginDevModal/index.tsx +153 -0
- package/src/locales/default/error.ts +2 -0
- package/src/locales/default/plugin.ts +79 -3
- package/src/locales/default/setting.ts +3 -0
- package/src/pages/chat/features/Conversation/ChatList/Error/index.tsx +2 -1
- package/src/pages/chat/features/Conversation/ChatList/Plugins/FunctionCall.tsx +7 -4
- package/src/pages/chat/features/Conversation/ChatList/Plugins/PluginMessage.tsx +27 -33
- package/src/services/plugin.ts +6 -3
- package/src/store/plugin/action.ts +23 -2
- package/src/store/plugin/initialState.ts +17 -1
- package/src/store/plugin/reducers/devPluginList.ts +56 -0
- package/src/store/plugin/selectors.ts +9 -2
- package/src/store/plugin/store.ts +5 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { produce } from 'immer';
|
|
2
|
+
|
|
3
|
+
import { DevPlugin } from '../initialState';
|
|
4
|
+
|
|
5
|
+
export type DevListState = DevPlugin[];
|
|
6
|
+
|
|
7
|
+
export type AddPluginAction = {
|
|
8
|
+
plugin: DevPlugin;
|
|
9
|
+
type: 'addItem';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type DeletePluginAction = {
|
|
13
|
+
id: string;
|
|
14
|
+
type: 'deleteItem';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type UpdatePluginAction = {
|
|
18
|
+
id: string;
|
|
19
|
+
plugin: DevPlugin;
|
|
20
|
+
type: 'updateItem';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type DevListDispatch = AddPluginAction | DeletePluginAction | UpdatePluginAction;
|
|
24
|
+
|
|
25
|
+
export const devPluginListReducer = (
|
|
26
|
+
state: DevListState,
|
|
27
|
+
payload: DevListDispatch,
|
|
28
|
+
): DevListState => {
|
|
29
|
+
switch (payload.type) {
|
|
30
|
+
case 'addItem': {
|
|
31
|
+
return [...state, payload.plugin];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
case 'deleteItem': {
|
|
35
|
+
return produce(state, (draftState) => {
|
|
36
|
+
const deleteIndex = state.findIndex((plugin) => plugin.identifier === payload.id);
|
|
37
|
+
if (deleteIndex !== -1) {
|
|
38
|
+
draftState.splice(deleteIndex, 1);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
case 'updateItem': {
|
|
44
|
+
return produce(state, (draftState) => {
|
|
45
|
+
const updateIndex = state.findIndex((plugin) => plugin.identifier === payload.id);
|
|
46
|
+
if (updateIndex !== -1) {
|
|
47
|
+
draftState[updateIndex] = payload.plugin;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
default: {
|
|
53
|
+
return state;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -23,8 +23,13 @@ const enabledSchema =
|
|
|
23
23
|
);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
const pluginList = (s: PluginStoreState) => [...s.pluginList, ...s.devPluginList];
|
|
27
|
+
|
|
26
28
|
const getPluginMetaById = (id: string) => (s: PluginStoreState) =>
|
|
27
|
-
pluginHelpers.getPluginFormList(s
|
|
29
|
+
pluginHelpers.getPluginFormList(pluginList(s), id);
|
|
30
|
+
|
|
31
|
+
const getDevPluginById = (id: string) => (s: PluginStoreState) =>
|
|
32
|
+
s.devPluginList.find((i) => i.identifier === id);
|
|
28
33
|
|
|
29
34
|
const getPluginManifestById = (id: string) => (s: PluginStoreState) => s.pluginManifestMap[id];
|
|
30
35
|
const getPluginSettingsById = (id: string) => (s: PluginStoreState) => s.pluginsSettings[id];
|
|
@@ -41,7 +46,7 @@ const getPluginManifestLoadingStatus = (id: string) => (s: PluginStoreState) =>
|
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
const displayPluginList = (s: PluginStoreState) =>
|
|
44
|
-
s.
|
|
49
|
+
pluginList(s).map((p) => ({
|
|
45
50
|
author: p.author,
|
|
46
51
|
avatar: p.meta?.avatar,
|
|
47
52
|
createAt: p.createAt,
|
|
@@ -54,8 +59,10 @@ const displayPluginList = (s: PluginStoreState) =>
|
|
|
54
59
|
export const pluginSelectors = {
|
|
55
60
|
displayPluginList,
|
|
56
61
|
enabledSchema,
|
|
62
|
+
getDevPluginById,
|
|
57
63
|
getPluginManifestById,
|
|
58
64
|
getPluginManifestLoadingStatus,
|
|
59
65
|
getPluginMetaById,
|
|
60
66
|
getPluginSettingsById,
|
|
67
|
+
pluginList,
|
|
61
68
|
};
|
|
@@ -19,7 +19,10 @@ const createStore: StateCreator<PluginStore, [['zustand/devtools', never]]> = (.
|
|
|
19
19
|
|
|
20
20
|
// =============== persist 本地缓存中间件配置 ============ //
|
|
21
21
|
|
|
22
|
-
type SessionPersist = Pick<
|
|
22
|
+
type SessionPersist = Pick<
|
|
23
|
+
PluginStore,
|
|
24
|
+
'pluginList' | 'pluginManifestMap' | 'pluginsSettings' | 'devPluginList'
|
|
25
|
+
>;
|
|
23
26
|
|
|
24
27
|
const storeName = 'LOBE_PLUGIN';
|
|
25
28
|
|
|
@@ -27,6 +30,7 @@ const persistOptions: PersistOptions<PluginStore, SessionPersist> = {
|
|
|
27
30
|
name: storeName,
|
|
28
31
|
|
|
29
32
|
partialize: (s) => ({
|
|
33
|
+
devPluginList: s.devPluginList,
|
|
30
34
|
pluginList: s.pluginList,
|
|
31
35
|
pluginManifestMap: s.pluginManifestMap,
|
|
32
36
|
pluginsSettings: s.pluginsSettings,
|