@lobehub/lobehub 2.0.0-next.295 → 2.0.0-next.297
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 +50 -0
- package/changelog/v1.json +18 -0
- package/locales/en-US/plugin.json +4 -0
- package/locales/zh-CN/plugin.json +4 -0
- package/package.json +2 -2
- package/packages/agent-runtime/src/core/__tests__/runtime.test.ts +5 -5
- package/packages/agent-runtime/src/utils/stepContextComputer.test.ts +5 -5
- package/packages/builtin-tool-gtd/src/client/Inspector/index.ts +0 -4
- package/packages/builtin-tool-gtd/src/client/Intervention/AddTodo.tsx +1 -1
- package/packages/builtin-tool-gtd/src/client/Render/TodoList/index.tsx +39 -10
- package/packages/builtin-tool-gtd/src/client/Render/index.ts +0 -2
- package/packages/builtin-tool-gtd/src/client/components/SortableTodoList/TodoItemRow.tsx +26 -12
- package/packages/builtin-tool-gtd/src/client/components/SortableTodoList/store/actions.ts +5 -5
- package/packages/builtin-tool-gtd/src/client/components/SortableTodoList/store/store.test.ts +14 -8
- package/packages/builtin-tool-gtd/src/executor/index.test.ts +48 -227
- package/packages/builtin-tool-gtd/src/executor/index.ts +15 -158
- package/packages/builtin-tool-gtd/src/manifest.ts +12 -42
- package/packages/builtin-tool-gtd/src/systemRole.ts +14 -8
- package/packages/builtin-tool-gtd/src/types.ts +47 -41
- package/packages/builtin-tool-memory/package.json +8 -0
- package/packages/builtin-tool-memory/src/client/Inspector/AddContextMemory/index.tsx +60 -0
- package/packages/builtin-tool-memory/src/client/Inspector/AddExperienceMemory/index.tsx +60 -0
- package/packages/builtin-tool-memory/src/client/Inspector/AddIdentityMemory/index.tsx +60 -0
- package/packages/builtin-tool-memory/src/client/Inspector/AddPreferenceMemory/index.tsx +60 -0
- package/packages/builtin-tool-memory/src/client/Inspector/RemoveIdentityMemory/index.tsx +60 -0
- package/packages/builtin-tool-memory/src/client/Inspector/SearchUserMemory/index.tsx +67 -0
- package/packages/builtin-tool-memory/src/client/Inspector/UpdateIdentityMemory/index.tsx +60 -0
- package/packages/builtin-tool-memory/src/client/Inspector/index.ts +35 -0
- package/packages/builtin-tool-memory/src/client/Intervention/AddExperienceMemory/index.tsx +17 -0
- package/packages/builtin-tool-memory/src/client/Intervention/index.ts +13 -0
- package/packages/builtin-tool-memory/src/client/Render/AddExperienceMemory/index.tsx +17 -0
- package/packages/builtin-tool-memory/src/client/Render/SearchUserMemory/index.tsx +217 -0
- package/packages/builtin-tool-memory/src/client/Render/index.ts +15 -0
- package/packages/builtin-tool-memory/src/client/Streaming/AddExperienceMemory/index.tsx +17 -0
- package/packages/builtin-tool-memory/src/client/Streaming/index.ts +18 -0
- package/packages/builtin-tool-memory/src/client/components/ExperienceMemoryCard.tsx +231 -0
- package/packages/builtin-tool-memory/src/client/components/index.ts +1 -0
- package/packages/builtin-tool-memory/src/client/index.ts +27 -0
- package/packages/builtin-tool-memory/src/executor/index.ts +9 -1
- package/packages/builtin-tool-memory/src/types.ts +61 -0
- package/packages/context-engine/src/providers/GTDTodoInjector.ts +15 -7
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/tools-with-branches.json +4 -0
- package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +1 -0
- package/packages/prompts/src/prompts/gtd/index.test.ts +32 -16
- package/packages/prompts/src/prompts/gtd/index.ts +9 -5
- package/packages/types/package.json +1 -1
- package/packages/types/src/discover/assistants.ts +4 -0
- package/packages/types/src/discover/groupAgents.ts +196 -0
- package/packages/types/src/discover/index.ts +5 -1
- package/packages/types/src/stepContext.ts +4 -1
- package/src/app/[variants]/(main)/community/(detail)/assistant/features/Details/Versions/index.tsx +2 -2
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/DetailProvider.tsx +19 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/Members/index.tsx +137 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/Nav.tsx +88 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/Overview/index.tsx +213 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/Related/index.tsx +85 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/SystemRole/TagList.tsx +20 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/SystemRole/index.tsx +71 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/Versions/index.tsx +119 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Details/index.tsx +51 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Header.tsx +253 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Sidebar/ActionButton/AddGroupAgent.tsx +222 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Sidebar/ActionButton/index.tsx +34 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Sidebar/Summary/index.tsx +42 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Sidebar/index.tsx +41 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/StatusPage/index.tsx +104 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/index.tsx +103 -0
- package/src/app/[variants]/(main)/community/(detail)/group_agent/loading.tsx +1 -0
- package/src/app/[variants]/(main)/community/(detail)/user/features/DetailProvider.tsx +7 -1
- package/src/app/[variants]/(main)/community/(detail)/user/features/UserContent.tsx +2 -0
- package/src/app/[variants]/(main)/community/(detail)/user/features/UserGroupCard.tsx +186 -0
- package/src/app/[variants]/(main)/community/(detail)/user/features/UserGroupList.tsx +59 -0
- package/src/app/[variants]/(main)/community/(detail)/user/index.tsx +3 -1
- package/src/app/[variants]/(main)/community/(list)/assistant/features/List/Item.tsx +26 -8
- package/src/app/[variants]/(main)/community/(list)/assistant/index.tsx +1 -0
- package/src/app/[variants]/(main)/community/features/Search.tsx +1 -1
- package/src/app/[variants]/(main)/group/profile/features/GroupProfile/index.tsx +2 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/AgentPublishButton/PublishResultModal.tsx +2 -1
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/GroupForkConfirmModal.tsx +60 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/GroupPublishResultModal.tsx +62 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/PublishButton.tsx +122 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/index.tsx +46 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/types.ts +12 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/useMarketGroupPublish.ts +211 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/utils.ts +22 -0
- package/src/app/[variants]/(main)/resource/features/DndContextWrapper.tsx +4 -2
- package/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx +30 -35
- package/src/app/[variants]/(main)/resource/library/_layout/Header/index.tsx +9 -11
- package/src/app/[variants]/router/desktopRouter.config.tsx +7 -0
- package/src/features/Conversation/Messages/AssistantGroup/Tool/Actions/index.tsx +11 -17
- package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/LoadingPlaceholder/index.tsx +13 -3
- package/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Render/CustomRender.tsx +43 -0
- package/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Render/FallbacktArgumentRender.tsx +59 -0
- package/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Render/index.tsx +46 -0
- package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/index.tsx +13 -19
- package/src/features/Conversation/Messages/AssistantGroup/Tool/index.tsx +17 -17
- package/src/features/Conversation/Messages/Tool/Tool/index.tsx +10 -9
- package/src/features/Conversation/TodoProgress/index.tsx +56 -23
- package/src/features/PluginsUI/Render/MCPType/index.tsx +1 -1
- package/src/features/ResourceManager/components/Explorer/Header/index.tsx +57 -4
- package/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx +6 -4
- package/src/features/ResourceManager/components/Explorer/ListView/index.tsx +16 -5
- package/src/features/ResourceManager/components/LibraryHierarchy/styles.ts +5 -4
- package/src/hooks/useActiveTabKey.ts +1 -2
- package/src/locales/default/plugin.ts +1 -0
- package/src/locales/default/setting.ts +12 -0
- package/src/server/routers/lambda/market/agentGroup.ts +296 -0
- package/src/server/routers/lambda/market/index.ts +134 -4
- package/src/server/services/discover/index.ts +123 -7
- package/src/services/discover.ts +55 -0
- package/src/store/chat/slices/message/selectors/dbMessage.test.ts +11 -11
- package/src/store/discover/slices/groupAgent/action.ts +80 -0
- package/src/store/discover/store.ts +3 -0
- package/src/store/file/slices/resource/action.ts +4 -2
- package/src/tools/inspectors.ts +2 -0
- package/src/tools/interventions.ts +2 -0
- package/src/tools/renders.ts +3 -1
- package/src/tools/streamings.ts +2 -0
- package/packages/builtin-tool-gtd/src/client/Inspector/CompleteTodos/index.tsx +0 -52
- package/packages/builtin-tool-gtd/src/client/Inspector/RemoveTodos/index.tsx +0 -52
- package/src/features/Conversation/Messages/AssistantGroup/Tool/Render/CustomRender.tsx +0 -113
- package/src/features/Conversation/Messages/Tool/Tool/Render.tsx +0 -47
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/AbortResponse.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Arguments/index.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/ErrorResponse.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/ApprovalActions.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/Fallback.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/KeyValueEditor.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/ModeSelector.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/index.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/PluginSettings.tsx +0 -0
- /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/RejectedResponse.tsx +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { BuiltinInspectorProps } from '@lobechat/types';
|
|
4
|
+
import { createStaticStyles, cssVar, cx } from 'antd-style';
|
|
5
|
+
import { Check } from 'lucide-react';
|
|
6
|
+
import { memo } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
import { highlightTextStyles, inspectorTextStyles, shinyTextStyles } from '@/styles';
|
|
10
|
+
|
|
11
|
+
import type { UpdateIdentityMemoryParams, UpdateIdentityMemoryState } from '../../../types';
|
|
12
|
+
|
|
13
|
+
const styles = createStaticStyles(({ css }) => ({
|
|
14
|
+
statusIcon: css`
|
|
15
|
+
margin-block-end: -2px;
|
|
16
|
+
margin-inline-start: 4px;
|
|
17
|
+
`,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
export const UpdateIdentityMemoryInspector = memo<
|
|
21
|
+
BuiltinInspectorProps<UpdateIdentityMemoryParams, UpdateIdentityMemoryState>
|
|
22
|
+
>(({ args, partialArgs, isArgumentsStreaming, isLoading, pluginState }) => {
|
|
23
|
+
const { t } = useTranslation('plugin');
|
|
24
|
+
|
|
25
|
+
const id = args?.id || partialArgs?.id;
|
|
26
|
+
|
|
27
|
+
// Initial streaming state
|
|
28
|
+
if (isArgumentsStreaming && !id) {
|
|
29
|
+
return (
|
|
30
|
+
<div className={cx(inspectorTextStyles.root, shinyTextStyles.shinyText)}>
|
|
31
|
+
<span>{t('builtins.lobe-user-memory.apiName.updateIdentityMemory')}</span>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const isSuccess = pluginState?.identityId;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className={cx(
|
|
41
|
+
inspectorTextStyles.root,
|
|
42
|
+
(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
|
|
43
|
+
)}
|
|
44
|
+
>
|
|
45
|
+
<span>{t('builtins.lobe-user-memory.apiName.updateIdentityMemory')}</span>
|
|
46
|
+
{id && (
|
|
47
|
+
<>
|
|
48
|
+
: <span className={highlightTextStyles.warning}>{id}</span>
|
|
49
|
+
</>
|
|
50
|
+
)}
|
|
51
|
+
{!isLoading && isSuccess && (
|
|
52
|
+
<Check className={styles.statusIcon} color={cssVar.colorSuccess} size={14} />
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
UpdateIdentityMemoryInspector.displayName = 'UpdateIdentityMemoryInspector';
|
|
59
|
+
|
|
60
|
+
export default UpdateIdentityMemoryInspector;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type BuiltinInspector } from '@lobechat/types';
|
|
2
|
+
|
|
3
|
+
import { MemoryApiName } from '../../types';
|
|
4
|
+
import { AddContextMemoryInspector } from './AddContextMemory';
|
|
5
|
+
import { AddExperienceMemoryInspector } from './AddExperienceMemory';
|
|
6
|
+
import { AddIdentityMemoryInspector } from './AddIdentityMemory';
|
|
7
|
+
import { AddPreferenceMemoryInspector } from './AddPreferenceMemory';
|
|
8
|
+
import { RemoveIdentityMemoryInspector } from './RemoveIdentityMemory';
|
|
9
|
+
import { SearchUserMemoryInspector } from './SearchUserMemory';
|
|
10
|
+
import { UpdateIdentityMemoryInspector } from './UpdateIdentityMemory';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Memory Inspector Components Registry
|
|
14
|
+
*
|
|
15
|
+
* Inspector components customize the title/header area
|
|
16
|
+
* of tool calls in the conversation UI.
|
|
17
|
+
*/
|
|
18
|
+
export const MemoryInspectors: Record<string, BuiltinInspector> = {
|
|
19
|
+
[MemoryApiName.addContextMemory]: AddContextMemoryInspector as BuiltinInspector,
|
|
20
|
+
[MemoryApiName.addExperienceMemory]: AddExperienceMemoryInspector as BuiltinInspector,
|
|
21
|
+
[MemoryApiName.addIdentityMemory]: AddIdentityMemoryInspector as BuiltinInspector,
|
|
22
|
+
[MemoryApiName.addPreferenceMemory]: AddPreferenceMemoryInspector as BuiltinInspector,
|
|
23
|
+
[MemoryApiName.removeIdentityMemory]: RemoveIdentityMemoryInspector as BuiltinInspector,
|
|
24
|
+
[MemoryApiName.searchUserMemory]: SearchUserMemoryInspector as BuiltinInspector,
|
|
25
|
+
[MemoryApiName.updateIdentityMemory]: UpdateIdentityMemoryInspector as BuiltinInspector,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Re-export individual inspectors
|
|
29
|
+
export { AddContextMemoryInspector } from './AddContextMemory';
|
|
30
|
+
export { AddExperienceMemoryInspector } from './AddExperienceMemory';
|
|
31
|
+
export { AddIdentityMemoryInspector } from './AddIdentityMemory';
|
|
32
|
+
export { AddPreferenceMemoryInspector } from './AddPreferenceMemory';
|
|
33
|
+
export { RemoveIdentityMemoryInspector } from './RemoveIdentityMemory';
|
|
34
|
+
export { SearchUserMemoryInspector } from './SearchUserMemory';
|
|
35
|
+
export { UpdateIdentityMemoryInspector } from './UpdateIdentityMemory';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { BuiltinInterventionProps } from '@lobechat/types';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
|
|
6
|
+
import type { AddExperienceMemoryParams } from '../../../types';
|
|
7
|
+
import { ExperienceMemoryCard } from '../../components';
|
|
8
|
+
|
|
9
|
+
const AddExperienceMemoryIntervention = memo<BuiltinInterventionProps<AddExperienceMemoryParams>>(
|
|
10
|
+
({ args }) => {
|
|
11
|
+
return <ExperienceMemoryCard data={args} />;
|
|
12
|
+
},
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
AddExperienceMemoryIntervention.displayName = 'AddExperienceMemoryIntervention';
|
|
16
|
+
|
|
17
|
+
export default AddExperienceMemoryIntervention;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuiltinIntervention } from '@lobechat/types';
|
|
2
|
+
|
|
3
|
+
import { MemoryApiName } from '../../types';
|
|
4
|
+
import AddExperienceMemoryIntervention from './AddExperienceMemory';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Memory Intervention Components Registry
|
|
8
|
+
*
|
|
9
|
+
* Intervention components display when human approval is required before tool execution.
|
|
10
|
+
*/
|
|
11
|
+
export const MemoryInterventions: Record<string, BuiltinIntervention> = {
|
|
12
|
+
[MemoryApiName.addExperienceMemory]: AddExperienceMemoryIntervention as BuiltinIntervention,
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { BuiltinRenderProps } from '@lobechat/types';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
|
|
6
|
+
import type { AddExperienceMemoryParams, AddExperienceMemoryState } from '../../../types';
|
|
7
|
+
import { ExperienceMemoryCard } from '../../components';
|
|
8
|
+
|
|
9
|
+
const AddExperienceMemoryRender = memo<
|
|
10
|
+
BuiltinRenderProps<AddExperienceMemoryParams, AddExperienceMemoryState>
|
|
11
|
+
>(({ args }) => {
|
|
12
|
+
return <ExperienceMemoryCard data={args} />;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
AddExperienceMemoryRender.displayName = 'AddExperienceMemoryRender';
|
|
16
|
+
|
|
17
|
+
export default AddExperienceMemoryRender;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { BuiltinRenderProps } from '@lobechat/types';
|
|
4
|
+
import { Accordion, AccordionItem, Flexbox, Tag, Text } from '@lobehub/ui';
|
|
5
|
+
import { createStaticStyles } from 'antd-style';
|
|
6
|
+
import { memo } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
import { highlightTextStyles } from '@/styles';
|
|
10
|
+
|
|
11
|
+
import type { SearchMemoryParams, SearchUserMemoryState } from '../../../types';
|
|
12
|
+
|
|
13
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
14
|
+
container: css`
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
|
|
17
|
+
width: 100%;
|
|
18
|
+
border: 1px solid ${cssVar.colorBorderSecondary};
|
|
19
|
+
border-radius: 12px;
|
|
20
|
+
|
|
21
|
+
background: ${cssVar.colorBgContainer};
|
|
22
|
+
`,
|
|
23
|
+
empty: css`
|
|
24
|
+
padding: 24px;
|
|
25
|
+
color: ${cssVar.colorTextTertiary};
|
|
26
|
+
text-align: center;
|
|
27
|
+
`,
|
|
28
|
+
item: css`
|
|
29
|
+
padding-block: 10px;
|
|
30
|
+
padding-inline: 12px;
|
|
31
|
+
border-block-end: 1px dashed ${cssVar.colorBorderSecondary};
|
|
32
|
+
|
|
33
|
+
&:last-child {
|
|
34
|
+
border-block-end: none;
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
itemContent: css`
|
|
38
|
+
font-size: 13px;
|
|
39
|
+
line-height: 1.5;
|
|
40
|
+
color: ${cssVar.colorTextSecondary};
|
|
41
|
+
`,
|
|
42
|
+
itemTitle: css`
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
color: ${cssVar.colorText};
|
|
46
|
+
`,
|
|
47
|
+
sectionHeader: css`
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
font-weight: 500;
|
|
50
|
+
`,
|
|
51
|
+
tags: css`
|
|
52
|
+
padding-block-start: 6px;
|
|
53
|
+
`,
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
interface MemoryItemProps {
|
|
57
|
+
content?: string | null;
|
|
58
|
+
subContent?: string | null;
|
|
59
|
+
tags?: string[] | null;
|
|
60
|
+
title?: string | null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const MemoryItem = memo<MemoryItemProps>(({ title, content, subContent, tags }) => {
|
|
64
|
+
return (
|
|
65
|
+
<Flexbox className={styles.item} gap={4}>
|
|
66
|
+
{title && <div className={styles.itemTitle}>{title}</div>}
|
|
67
|
+
{content && <div className={styles.itemContent}>{content}</div>}
|
|
68
|
+
{subContent && (
|
|
69
|
+
<Text className={styles.itemContent} style={{ fontStyle: 'italic' }} type={'secondary'}>
|
|
70
|
+
{subContent}
|
|
71
|
+
</Text>
|
|
72
|
+
)}
|
|
73
|
+
{tags && tags.length > 0 && (
|
|
74
|
+
<Flexbox className={styles.tags} gap={4} horizontal wrap={'wrap'}>
|
|
75
|
+
{tags.map((tag, index) => (
|
|
76
|
+
<Tag key={index} size={'small'}>
|
|
77
|
+
{tag}
|
|
78
|
+
</Tag>
|
|
79
|
+
))}
|
|
80
|
+
</Flexbox>
|
|
81
|
+
)}
|
|
82
|
+
</Flexbox>
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
MemoryItem.displayName = 'MemoryItem';
|
|
87
|
+
|
|
88
|
+
const SearchUserMemoryRender = memo<BuiltinRenderProps<SearchMemoryParams, SearchUserMemoryState>>(
|
|
89
|
+
({ pluginState }) => {
|
|
90
|
+
const { t } = useTranslation('plugin');
|
|
91
|
+
|
|
92
|
+
const contexts = pluginState?.contexts || [];
|
|
93
|
+
const experiences = pluginState?.experiences || [];
|
|
94
|
+
const preferences = pluginState?.preferences || [];
|
|
95
|
+
|
|
96
|
+
const totalCount = contexts.length + experiences.length + preferences.length;
|
|
97
|
+
|
|
98
|
+
if (totalCount === 0) {
|
|
99
|
+
return (
|
|
100
|
+
<div className={styles.container}>
|
|
101
|
+
<div className={styles.empty}>{t('builtins.lobe-user-memory.inspector.noResults')}</div>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const defaultActiveKeys = [
|
|
107
|
+
...(contexts.length > 0 ? ['contexts'] : []),
|
|
108
|
+
...(experiences.length > 0 ? ['experiences'] : []),
|
|
109
|
+
...(preferences.length > 0 ? ['preferences'] : []),
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Flexbox className={styles.container}>
|
|
114
|
+
<Accordion defaultExpandedKeys={defaultActiveKeys} gap={0}>
|
|
115
|
+
{/* Contexts */}
|
|
116
|
+
{contexts.length > 0 && (
|
|
117
|
+
<AccordionItem
|
|
118
|
+
itemKey="contexts"
|
|
119
|
+
paddingBlock={8}
|
|
120
|
+
paddingInline={12}
|
|
121
|
+
title={
|
|
122
|
+
<Text className={styles.sectionHeader}>
|
|
123
|
+
<span className={highlightTextStyles.info}>
|
|
124
|
+
{t('builtins.lobe-user-memory.render.contexts' as any)}
|
|
125
|
+
</span>
|
|
126
|
+
<Text as={'span'} type={'secondary'}>
|
|
127
|
+
{' '}
|
|
128
|
+
({contexts.length})
|
|
129
|
+
</Text>
|
|
130
|
+
</Text>
|
|
131
|
+
}
|
|
132
|
+
>
|
|
133
|
+
<Flexbox>
|
|
134
|
+
{contexts.map((item) => (
|
|
135
|
+
<MemoryItem
|
|
136
|
+
content={item.description}
|
|
137
|
+
key={item.id}
|
|
138
|
+
subContent={item.currentStatus}
|
|
139
|
+
tags={item.tags}
|
|
140
|
+
title={item.title}
|
|
141
|
+
/>
|
|
142
|
+
))}
|
|
143
|
+
</Flexbox>
|
|
144
|
+
</AccordionItem>
|
|
145
|
+
)}
|
|
146
|
+
|
|
147
|
+
{/* Experiences */}
|
|
148
|
+
{experiences.length > 0 && (
|
|
149
|
+
<AccordionItem
|
|
150
|
+
itemKey="experiences"
|
|
151
|
+
paddingBlock={8}
|
|
152
|
+
paddingInline={12}
|
|
153
|
+
title={
|
|
154
|
+
<Text className={styles.sectionHeader}>
|
|
155
|
+
<span className={highlightTextStyles.gold}>
|
|
156
|
+
{t('builtins.lobe-user-memory.render.experiences' as any)}
|
|
157
|
+
</span>
|
|
158
|
+
<Text as={'span'} type={'secondary'}>
|
|
159
|
+
{' '}
|
|
160
|
+
({experiences.length})
|
|
161
|
+
</Text>
|
|
162
|
+
</Text>
|
|
163
|
+
}
|
|
164
|
+
>
|
|
165
|
+
<Flexbox>
|
|
166
|
+
{experiences.map((item) => (
|
|
167
|
+
<MemoryItem
|
|
168
|
+
content={item.situation}
|
|
169
|
+
key={item.id}
|
|
170
|
+
subContent={item.keyLearning}
|
|
171
|
+
tags={item.tags}
|
|
172
|
+
title={item.action}
|
|
173
|
+
/>
|
|
174
|
+
))}
|
|
175
|
+
</Flexbox>
|
|
176
|
+
</AccordionItem>
|
|
177
|
+
)}
|
|
178
|
+
|
|
179
|
+
{/* Preferences */}
|
|
180
|
+
{preferences.length > 0 && (
|
|
181
|
+
<AccordionItem
|
|
182
|
+
itemKey="preferences"
|
|
183
|
+
paddingBlock={8}
|
|
184
|
+
paddingInline={12}
|
|
185
|
+
title={
|
|
186
|
+
<Text className={styles.sectionHeader}>
|
|
187
|
+
<span className={highlightTextStyles.warning}>
|
|
188
|
+
{t('builtins.lobe-user-memory.render.preferences' as any)}
|
|
189
|
+
</span>
|
|
190
|
+
<Text as={'span'} type={'secondary'}>
|
|
191
|
+
{' '}
|
|
192
|
+
({preferences.length})
|
|
193
|
+
</Text>
|
|
194
|
+
</Text>
|
|
195
|
+
}
|
|
196
|
+
>
|
|
197
|
+
<Flexbox>
|
|
198
|
+
{preferences.map((item) => (
|
|
199
|
+
<MemoryItem
|
|
200
|
+
content={item.conclusionDirectives}
|
|
201
|
+
key={item.id}
|
|
202
|
+
subContent={item.suggestions}
|
|
203
|
+
tags={item.tags}
|
|
204
|
+
/>
|
|
205
|
+
))}
|
|
206
|
+
</Flexbox>
|
|
207
|
+
</AccordionItem>
|
|
208
|
+
)}
|
|
209
|
+
</Accordion>
|
|
210
|
+
</Flexbox>
|
|
211
|
+
);
|
|
212
|
+
},
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
SearchUserMemoryRender.displayName = 'SearchUserMemoryRender';
|
|
216
|
+
|
|
217
|
+
export default SearchUserMemoryRender;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BuiltinRender } from '@lobechat/types';
|
|
2
|
+
|
|
3
|
+
import { MemoryApiName } from '../../types';
|
|
4
|
+
import AddExperienceMemoryRender from './AddExperienceMemory';
|
|
5
|
+
import SearchUserMemoryRender from './SearchUserMemory';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Memory Render Components Registry
|
|
9
|
+
*
|
|
10
|
+
* Render components display the final result of tool execution.
|
|
11
|
+
*/
|
|
12
|
+
export const MemoryRenders: Record<string, BuiltinRender> = {
|
|
13
|
+
[MemoryApiName.addExperienceMemory]: AddExperienceMemoryRender as BuiltinRender,
|
|
14
|
+
[MemoryApiName.searchUserMemory]: SearchUserMemoryRender as BuiltinRender,
|
|
15
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { BuiltinStreamingProps } from '@lobechat/types';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
|
|
6
|
+
import type { AddExperienceMemoryParams } from '../../../types';
|
|
7
|
+
import { ExperienceMemoryCard } from '../../components';
|
|
8
|
+
|
|
9
|
+
export const AddExperienceMemoryStreaming = memo<BuiltinStreamingProps<AddExperienceMemoryParams>>(
|
|
10
|
+
({ args }) => {
|
|
11
|
+
return <ExperienceMemoryCard data={args} loading />;
|
|
12
|
+
},
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
AddExperienceMemoryStreaming.displayName = 'AddExperienceMemoryStreaming';
|
|
16
|
+
|
|
17
|
+
export default AddExperienceMemoryStreaming;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BuiltinStreaming } from '@lobechat/types';
|
|
2
|
+
|
|
3
|
+
import { MemoryApiName } from '../../types';
|
|
4
|
+
import { AddExperienceMemoryStreaming } from './AddExperienceMemory';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Memory Streaming Components Registry
|
|
8
|
+
*
|
|
9
|
+
* Streaming components are used to render tool calls while arguments
|
|
10
|
+
* are still being generated, allowing real-time feedback to users.
|
|
11
|
+
*/
|
|
12
|
+
export const MemoryStreamings: Record<string, BuiltinStreaming> = {
|
|
13
|
+
[MemoryApiName.addExperienceMemory]: AddExperienceMemoryStreaming as BuiltinStreaming,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export {AddExperienceMemoryStreaming} from './AddExperienceMemory';
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Accordion, AccordionItem, Avatar, Flexbox, Tag, Text } from '@lobehub/ui';
|
|
4
|
+
import { Steps } from 'antd';
|
|
5
|
+
import { createStaticStyles, cssVar } from 'antd-style';
|
|
6
|
+
import { memo } from 'react';
|
|
7
|
+
|
|
8
|
+
import BubblesLoading from '@/components/BubblesLoading';
|
|
9
|
+
import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
|
|
10
|
+
import StreamingMarkdown from '@/components/StreamingMarkdown';
|
|
11
|
+
import { highlightTextStyles } from '@/styles';
|
|
12
|
+
|
|
13
|
+
import type { AddExperienceMemoryParams } from '../../types';
|
|
14
|
+
|
|
15
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
16
|
+
container: css`
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
|
|
19
|
+
width: 100%;
|
|
20
|
+
border: 1px solid ${cssVar.colorBorderSecondary};
|
|
21
|
+
border-radius: 16px;
|
|
22
|
+
|
|
23
|
+
background: ${cssVar.colorBgContainer};
|
|
24
|
+
`,
|
|
25
|
+
content: css`
|
|
26
|
+
padding-block: 12px;
|
|
27
|
+
padding-inline: 16px;
|
|
28
|
+
`,
|
|
29
|
+
detail: css`
|
|
30
|
+
font-size: 13px;
|
|
31
|
+
line-height: 1.6;
|
|
32
|
+
color: ${cssVar.colorTextSecondary};
|
|
33
|
+
`,
|
|
34
|
+
header: css`
|
|
35
|
+
padding-block: 10px;
|
|
36
|
+
padding-inline: 12px;
|
|
37
|
+
border-block-end: 1px solid ${cssVar.colorBorderSecondary};
|
|
38
|
+
`,
|
|
39
|
+
keyLearning: css`
|
|
40
|
+
font-size: 14px;
|
|
41
|
+
line-height: 1.6;
|
|
42
|
+
color: ${cssVar.colorText};
|
|
43
|
+
`,
|
|
44
|
+
section: css`
|
|
45
|
+
padding: 4px;
|
|
46
|
+
border-block-start: 1px solid ${cssVar.colorBorderSecondary};
|
|
47
|
+
`,
|
|
48
|
+
stepContent: css`
|
|
49
|
+
font-size: 13px;
|
|
50
|
+
line-height: 1.6;
|
|
51
|
+
color: ${cssVar.colorTextSecondary};
|
|
52
|
+
white-space: pre-wrap;
|
|
53
|
+
`,
|
|
54
|
+
stepsContainer: css`
|
|
55
|
+
.ant-steps-item-content {
|
|
56
|
+
min-height: auto;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ant-steps-item-description {
|
|
60
|
+
padding-block-end: 12px !important;
|
|
61
|
+
}
|
|
62
|
+
`,
|
|
63
|
+
summary: css`
|
|
64
|
+
font-size: 14px;
|
|
65
|
+
font-weight: 500;
|
|
66
|
+
color: ${cssVar.colorTextSecondary};
|
|
67
|
+
`,
|
|
68
|
+
tags: css`
|
|
69
|
+
padding-block-start: 8px;
|
|
70
|
+
border-block-start: 1px dashed ${cssVar.colorBorderSecondary};
|
|
71
|
+
`,
|
|
72
|
+
title: css`
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
display: -webkit-box;
|
|
75
|
+
-webkit-box-orient: vertical;
|
|
76
|
+
-webkit-line-clamp: 1;
|
|
77
|
+
|
|
78
|
+
font-weight: 500;
|
|
79
|
+
color: ${cssVar.colorText};
|
|
80
|
+
`,
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
export interface ExperienceMemoryCardProps {
|
|
84
|
+
data?: AddExperienceMemoryParams;
|
|
85
|
+
loading?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const ExperienceMemoryCard = memo<ExperienceMemoryCardProps>(({ data, loading }) => {
|
|
89
|
+
const { summary, details, tags, title, withExperience } = data || {};
|
|
90
|
+
const { situation, reasoning, action, possibleOutcome, keyLearning } = withExperience || {};
|
|
91
|
+
|
|
92
|
+
const hasStarContent = situation || reasoning || action || possibleOutcome;
|
|
93
|
+
|
|
94
|
+
if (!summary && !details && !tags?.length && !title && !hasStarContent && !keyLearning)
|
|
95
|
+
return null;
|
|
96
|
+
|
|
97
|
+
const starItems = [
|
|
98
|
+
{ avatar: 'S', content: situation, title: 'Situation' },
|
|
99
|
+
{ avatar: 'T', content: reasoning, title: 'Task' },
|
|
100
|
+
{ avatar: 'A', content: action, title: 'Action' },
|
|
101
|
+
{ avatar: 'R', content: possibleOutcome, title: 'Result' },
|
|
102
|
+
].filter((item) => item.content);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<Flexbox className={styles.container}>
|
|
106
|
+
{/* Header */}
|
|
107
|
+
<Flexbox align={'center'} className={styles.header} gap={8} horizontal>
|
|
108
|
+
<Flexbox flex={1}>
|
|
109
|
+
<div className={styles.title}>{title || 'Experience Memory'}</div>
|
|
110
|
+
</Flexbox>
|
|
111
|
+
{loading && <NeuralNetworkLoading size={20} />}
|
|
112
|
+
</Flexbox>
|
|
113
|
+
|
|
114
|
+
{/* When has STAR content: collapse summary */}
|
|
115
|
+
{hasStarContent ? (
|
|
116
|
+
<>
|
|
117
|
+
{/* Collapsed Summary */}
|
|
118
|
+
{(summary || tags?.length) && (
|
|
119
|
+
<Accordion gap={0}>
|
|
120
|
+
<AccordionItem
|
|
121
|
+
itemKey="summary"
|
|
122
|
+
paddingBlock={8}
|
|
123
|
+
paddingInline={8}
|
|
124
|
+
styles={{
|
|
125
|
+
base: { marginBlock: 4, marginInline: 4 },
|
|
126
|
+
}}
|
|
127
|
+
title={
|
|
128
|
+
<Text fontSize={12} type={'secondary'} weight={500}>
|
|
129
|
+
Summary
|
|
130
|
+
</Text>
|
|
131
|
+
}
|
|
132
|
+
>
|
|
133
|
+
<Flexbox gap={8} paddingBlock={'8px 12px'} paddingInline={8}>
|
|
134
|
+
{summary && <div className={styles.summary}>{summary}</div>}
|
|
135
|
+
{details && <div className={styles.detail}>{details}</div>}
|
|
136
|
+
{tags && tags.length > 0 && (
|
|
137
|
+
<Flexbox className={styles.tags} gap={8} horizontal wrap={'wrap'}>
|
|
138
|
+
{tags.map((tag, index) => (
|
|
139
|
+
<Tag key={index}>{tag}</Tag>
|
|
140
|
+
))}
|
|
141
|
+
</Flexbox>
|
|
142
|
+
)}
|
|
143
|
+
</Flexbox>
|
|
144
|
+
</AccordionItem>
|
|
145
|
+
</Accordion>
|
|
146
|
+
)}
|
|
147
|
+
|
|
148
|
+
{/* STAR Steps */}
|
|
149
|
+
<Accordion className={styles.section} defaultExpandedKeys={['star']} gap={0}>
|
|
150
|
+
<AccordionItem
|
|
151
|
+
itemKey="star"
|
|
152
|
+
paddingBlock={8}
|
|
153
|
+
paddingInline={8}
|
|
154
|
+
title={
|
|
155
|
+
<Text fontSize={12} type={'secondary'} weight={500}>
|
|
156
|
+
STAR
|
|
157
|
+
</Text>
|
|
158
|
+
}
|
|
159
|
+
>
|
|
160
|
+
<Flexbox paddingBlock={'8px 12px'} paddingInline={8}>
|
|
161
|
+
<Steps
|
|
162
|
+
className={styles.stepsContainer}
|
|
163
|
+
current={null as any}
|
|
164
|
+
direction="vertical"
|
|
165
|
+
items={starItems.map((item) => ({
|
|
166
|
+
description: <div className={styles.stepContent}>{item.content}</div>,
|
|
167
|
+
icon: (
|
|
168
|
+
<Avatar
|
|
169
|
+
avatar={item.avatar}
|
|
170
|
+
shadow
|
|
171
|
+
shape={'square'}
|
|
172
|
+
size={20}
|
|
173
|
+
style={{
|
|
174
|
+
border: `1px solid ${cssVar.colorBorderSecondary}`,
|
|
175
|
+
fontSize: 11,
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
),
|
|
179
|
+
title: (
|
|
180
|
+
<Text as={'span'} fontSize={12} type={'secondary'} weight={500}>
|
|
181
|
+
{item.title}
|
|
182
|
+
</Text>
|
|
183
|
+
),
|
|
184
|
+
}))}
|
|
185
|
+
size="small"
|
|
186
|
+
/>
|
|
187
|
+
</Flexbox>
|
|
188
|
+
</AccordionItem>
|
|
189
|
+
</Accordion>
|
|
190
|
+
|
|
191
|
+
{/* Key Learning */}
|
|
192
|
+
{keyLearning && (
|
|
193
|
+
<Flexbox
|
|
194
|
+
className={styles.section}
|
|
195
|
+
gap={8}
|
|
196
|
+
style={{ paddingBlock: 16, paddingInline: 12 }}
|
|
197
|
+
>
|
|
198
|
+
<Text fontSize={12} weight={500}>
|
|
199
|
+
<span className={highlightTextStyles.gold}>Key Learning</span>
|
|
200
|
+
</Text>
|
|
201
|
+
<div className={styles.keyLearning}>{keyLearning}</div>
|
|
202
|
+
</Flexbox>
|
|
203
|
+
)}
|
|
204
|
+
</>
|
|
205
|
+
) : (
|
|
206
|
+
/* When no STAR content: show summary and details */
|
|
207
|
+
<Flexbox className={styles.content} gap={8}>
|
|
208
|
+
{!summary && loading ? (
|
|
209
|
+
<BubblesLoading />
|
|
210
|
+
) : (
|
|
211
|
+
<>
|
|
212
|
+
{summary && <div className={styles.summary}>{summary}</div>}
|
|
213
|
+
{details && <StreamingMarkdown>{details}</StreamingMarkdown>}
|
|
214
|
+
{tags && tags.length > 0 && (
|
|
215
|
+
<Flexbox className={styles.tags} gap={8} horizontal wrap={'wrap'}>
|
|
216
|
+
{tags.map((tag, index) => (
|
|
217
|
+
<Tag key={index}>{tag}</Tag>
|
|
218
|
+
))}
|
|
219
|
+
</Flexbox>
|
|
220
|
+
)}
|
|
221
|
+
</>
|
|
222
|
+
)}
|
|
223
|
+
</Flexbox>
|
|
224
|
+
)}
|
|
225
|
+
</Flexbox>
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
ExperienceMemoryCard.displayName = 'ExperienceMemoryCard';
|
|
230
|
+
|
|
231
|
+
export default ExperienceMemoryCard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExperienceMemoryCard, type ExperienceMemoryCardProps } from './ExperienceMemoryCard';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Inspector components (customized tool call headers)
|
|
2
|
+
export { MemoryInspectors } from './Inspector';
|
|
3
|
+
export {
|
|
4
|
+
AddContextMemoryInspector,
|
|
5
|
+
AddExperienceMemoryInspector,
|
|
6
|
+
AddIdentityMemoryInspector,
|
|
7
|
+
AddPreferenceMemoryInspector,
|
|
8
|
+
RemoveIdentityMemoryInspector,
|
|
9
|
+
SearchUserMemoryInspector,
|
|
10
|
+
UpdateIdentityMemoryInspector,
|
|
11
|
+
} from './Inspector';
|
|
12
|
+
|
|
13
|
+
// Intervention components (human approval UI before tool execution)
|
|
14
|
+
export { MemoryInterventions } from './Intervention';
|
|
15
|
+
|
|
16
|
+
// Render components (final result display after tool execution)
|
|
17
|
+
export { MemoryRenders } from './Render';
|
|
18
|
+
|
|
19
|
+
// Streaming components (real-time feedback during tool execution)
|
|
20
|
+
export { AddExperienceMemoryStreaming, MemoryStreamings } from './Streaming';
|
|
21
|
+
|
|
22
|
+
// Shared components
|
|
23
|
+
export { ExperienceMemoryCard, type ExperienceMemoryCardProps } from './components';
|
|
24
|
+
|
|
25
|
+
// Re-export types and manifest for convenience
|
|
26
|
+
export { MemoryManifest } from '../manifest';
|
|
27
|
+
export * from '../types';
|