@lobehub/lobehub 2.0.0-next.250 → 2.0.0-next.252
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 +14 -0
- package/package.json +1 -1
- package/packages/builtin-tool-notebook/src/client/Render/CreateDocument/DocumentCard.tsx +0 -2
- package/packages/database/migrations/meta/_journal.json +1 -1
- package/packages/database/src/models/__tests__/topics/topic.create.test.ts +37 -8
- package/packages/database/src/models/topic.ts +71 -4
- package/packages/database/src/schemas/agentCronJob.ts +1 -2
- package/packages/memory-user-memory/src/extractors/context.ts +1 -4
- package/packages/memory-user-memory/src/extractors/experience.ts +2 -8
- package/packages/memory-user-memory/src/extractors/preference.ts +2 -8
- package/packages/memory-user-memory/src/prompts/gatekeeper.ts +123 -123
- package/packages/memory-user-memory/src/prompts/layers/context.ts +152 -152
- package/packages/memory-user-memory/src/prompts/layers/experience.ts +159 -159
- package/packages/memory-user-memory/src/prompts/layers/identity.ts +213 -213
- package/packages/memory-user-memory/src/prompts/layers/preference.ts +160 -160
- package/packages/memory-user-memory/src/services/extractExecutor.ts +33 -30
- package/packages/memory-user-memory/src/types.ts +10 -8
- package/packages/types/src/discover/mcp.ts +1 -1
- package/packages/types/src/topic/topic.ts +9 -0
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Body.tsx +4 -1
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/CronTopicList/CronTopicGroup.tsx +74 -0
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/CronTopicList/CronTopicItem.tsx +40 -0
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/CronTopicList/index.tsx +140 -0
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/List/index.tsx +1 -1
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/TopicListContent/index.tsx +1 -1
- package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/index.tsx +1 -1
- package/src/app/[variants]/(main)/chat/cron/[cronId]/index.tsx +664 -0
- package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/CronJobCards.tsx +160 -0
- package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/CronJobForm.tsx +202 -0
- package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/CronJobList.tsx +137 -0
- package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/hooks/useAgentCronJobs.ts +138 -0
- package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/index.tsx +130 -0
- package/src/app/[variants]/(main)/chat/profile/features/ProfileEditor/index.tsx +33 -3
- package/src/app/[variants]/(main)/community/(detail)/assistant/features/Sidebar/ActionButton/AddAgent.tsx +6 -0
- package/src/app/[variants]/(main)/community/(list)/assistant/features/List/Item.tsx +12 -3
- package/src/app/[variants]/(main)/community/(list)/mcp/features/List/Item.tsx +14 -4
- package/src/app/[variants]/router/desktopRouter.config.tsx +7 -0
- package/src/features/ResourceManager/components/Explorer/useCheckTaskStatus.ts +1 -1
- package/src/hooks/useFetchCronTopics.ts +29 -0
- package/src/hooks/useFetchCronTopicsWithJobInfo.ts +56 -0
- package/src/hooks/useFetchTopics.ts +4 -1
- package/src/locales/default/setting.ts +44 -1
- package/src/server/routers/lambda/agentCronJob.ts +367 -0
- package/src/server/routers/lambda/image/index.test.ts +2 -2
- package/src/server/routers/lambda/index.ts +2 -0
- package/src/server/routers/lambda/market/index.ts +45 -4
- package/src/server/routers/lambda/topic.ts +15 -3
- package/src/server/services/aiAgent/index.ts +18 -1
- package/src/server/services/discover/index.ts +29 -3
- package/src/server/services/memory/userMemory/extract.ts +14 -6
- package/src/services/agentCronJob.ts +95 -0
- package/src/services/discover.ts +38 -1
- package/src/services/topic/index.ts +1 -0
- package/src/store/chat/slices/topic/action.ts +53 -2
- package/src/store/chat/slices/topic/initialState.ts +1 -0
- package/src/store/chat/slices/topic/selectors.ts +14 -6
- package/src/store/tool/slices/mcpStore/action.test.ts +38 -0
- package/src/store/tool/slices/mcpStore/action.ts +18 -0
- package/src/tools/placeholders.ts +1 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
import { useChatStore } from '@/store/chat';
|
|
7
|
+
|
|
8
|
+
import TopicItem from '../List/Item';
|
|
9
|
+
|
|
10
|
+
interface CronTopicItemProps {
|
|
11
|
+
topic: {
|
|
12
|
+
createdAt: Date | string;
|
|
13
|
+
favorite?: boolean | null;
|
|
14
|
+
historySummary?: string | null;
|
|
15
|
+
id: string;
|
|
16
|
+
metadata?: any;
|
|
17
|
+
title?: string | null;
|
|
18
|
+
trigger?: string | null;
|
|
19
|
+
updatedAt: Date | string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CronTopicItem = memo<CronTopicItemProps>(({ topic }) => {
|
|
24
|
+
const { t } = useTranslation('topic');
|
|
25
|
+
const [activeTopicId, activeThreadId] = useChatStore((s) => [s.activeTopicId, s.activeThreadId]);
|
|
26
|
+
|
|
27
|
+
const displayTitle = topic.title || topic.historySummary || t('defaultTitle');
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<TopicItem
|
|
31
|
+
active={activeTopicId === topic.id}
|
|
32
|
+
fav={!!topic.favorite}
|
|
33
|
+
id={topic.id}
|
|
34
|
+
threadId={activeThreadId}
|
|
35
|
+
title={displayTitle}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export default CronTopicItem;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';
|
|
4
|
+
import { AccordionItem, ActionIcon, Flexbox, Icon, Text } from '@lobehub/ui';
|
|
5
|
+
import { message } from 'antd';
|
|
6
|
+
import { Calendar, Plus } from 'lucide-react';
|
|
7
|
+
import { memo, useCallback } from 'react';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
import urlJoin from 'url-join';
|
|
10
|
+
|
|
11
|
+
import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
|
|
12
|
+
import EmptyNavItem from '@/features/NavPanel/components/EmptyNavItem';
|
|
13
|
+
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
|
|
14
|
+
import { useFetchCronTopicsWithJobInfo } from '@/hooks/useFetchCronTopicsWithJobInfo';
|
|
15
|
+
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
|
16
|
+
import { agentCronJobService } from '@/services/agentCronJob';
|
|
17
|
+
import { useAgentStore } from '@/store/agent';
|
|
18
|
+
|
|
19
|
+
import CronTopicGroup from './CronTopicGroup';
|
|
20
|
+
|
|
21
|
+
interface CronTopicListProps {
|
|
22
|
+
itemKey: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const CronTopicList = memo<CronTopicListProps>(({ itemKey }) => {
|
|
26
|
+
const { t } = useTranslation('setting');
|
|
27
|
+
const router = useQueryRoute();
|
|
28
|
+
const agentId = useAgentStore((s) => s.activeAgentId);
|
|
29
|
+
const { cronTopicsGroupsWithJobInfo, isLoading, mutate } = useFetchCronTopicsWithJobInfo();
|
|
30
|
+
const totalTopics = cronTopicsGroupsWithJobInfo.reduce(
|
|
31
|
+
(acc, group) => acc + group.topics.length,
|
|
32
|
+
0,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const handleCreateCronJob = useCallback(async () => {
|
|
36
|
+
if (!agentId) return;
|
|
37
|
+
try {
|
|
38
|
+
const result = await agentCronJobService.create({
|
|
39
|
+
agentId,
|
|
40
|
+
content: t('agentCronJobs.form.content.placeholder') || 'This is a cron job',
|
|
41
|
+
cronPattern: '0 */30 * * *',
|
|
42
|
+
enabled: true,
|
|
43
|
+
name: t('agentCronJobs.addJob') || 'Cron Job Task',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (result.success) {
|
|
47
|
+
await mutate();
|
|
48
|
+
router.push(urlJoin('/agent', agentId, 'cron', result.data.id));
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Failed to create cron job:', error);
|
|
52
|
+
message.error('Failed to create scheduled task');
|
|
53
|
+
}
|
|
54
|
+
}, [agentId, mutate, router, t]);
|
|
55
|
+
|
|
56
|
+
if (!ENABLE_BUSINESS_FEATURES) return null;
|
|
57
|
+
|
|
58
|
+
const addAction = (
|
|
59
|
+
<ActionIcon
|
|
60
|
+
disabled={!agentId}
|
|
61
|
+
icon={Plus}
|
|
62
|
+
onClick={handleCreateCronJob}
|
|
63
|
+
size={'small'}
|
|
64
|
+
title={t('agentCronJobs.addJob')}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (isLoading) {
|
|
69
|
+
return (
|
|
70
|
+
<AccordionItem
|
|
71
|
+
action={addAction}
|
|
72
|
+
itemKey={itemKey}
|
|
73
|
+
paddingBlock={4}
|
|
74
|
+
paddingInline={'8px 4px'}
|
|
75
|
+
title={
|
|
76
|
+
<Flexbox align="center" gap={4} horizontal>
|
|
77
|
+
<Icon icon={Calendar} size={12} />
|
|
78
|
+
<Text ellipsis fontSize={12} type={'secondary'} weight={500}>
|
|
79
|
+
{t('agentCronJobs.title')}
|
|
80
|
+
</Text>
|
|
81
|
+
<NeuralNetworkLoading size={14} />
|
|
82
|
+
</Flexbox>
|
|
83
|
+
}
|
|
84
|
+
>
|
|
85
|
+
<SkeletonList />
|
|
86
|
+
</AccordionItem>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (cronTopicsGroupsWithJobInfo.length === 0) {
|
|
91
|
+
return (
|
|
92
|
+
<AccordionItem
|
|
93
|
+
action={addAction}
|
|
94
|
+
itemKey={itemKey}
|
|
95
|
+
paddingBlock={4}
|
|
96
|
+
paddingInline={'8px 4px'}
|
|
97
|
+
title={
|
|
98
|
+
<Flexbox align="center" gap={4} horizontal>
|
|
99
|
+
<Icon icon={Calendar} size={12} />
|
|
100
|
+
<Text ellipsis fontSize={12} type={'secondary'} weight={500}>
|
|
101
|
+
{t('agentCronJobs.title')}
|
|
102
|
+
</Text>
|
|
103
|
+
</Flexbox>
|
|
104
|
+
}
|
|
105
|
+
>
|
|
106
|
+
<EmptyNavItem onClick={handleCreateCronJob} title={t('agentCronJobs.addJob')} />
|
|
107
|
+
</AccordionItem>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<AccordionItem
|
|
113
|
+
action={addAction}
|
|
114
|
+
itemKey={itemKey}
|
|
115
|
+
paddingBlock={4}
|
|
116
|
+
paddingInline={'8px 4px'}
|
|
117
|
+
title={
|
|
118
|
+
<Flexbox align="center" gap={4} horizontal>
|
|
119
|
+
<Icon icon={Calendar} size={12} />
|
|
120
|
+
<Text ellipsis fontSize={12} type={'secondary'} weight={500}>
|
|
121
|
+
{`${t('agentCronJobs.title')} ${totalTopics > 0 ? totalTopics : ''}`}
|
|
122
|
+
</Text>
|
|
123
|
+
</Flexbox>
|
|
124
|
+
}
|
|
125
|
+
>
|
|
126
|
+
<Flexbox gap={2} paddingBlock={2}>
|
|
127
|
+
{cronTopicsGroupsWithJobInfo.map((group) => (
|
|
128
|
+
<CronTopicGroup
|
|
129
|
+
cronJob={group.cronJob}
|
|
130
|
+
cronJobId={group.cronJobId}
|
|
131
|
+
key={group.cronJobId}
|
|
132
|
+
topics={group.topics}
|
|
133
|
+
/>
|
|
134
|
+
))}
|
|
135
|
+
</Flexbox>
|
|
136
|
+
</AccordionItem>
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export default CronTopicList;
|
|
@@ -32,7 +32,7 @@ const TopicList = memo(() => {
|
|
|
32
32
|
|
|
33
33
|
const [topicDisplayMode] = useUserStore((s) => [preferenceSelectors.topicDisplayMode(s)]);
|
|
34
34
|
|
|
35
|
-
useFetchTopics();
|
|
35
|
+
useFetchTopics({ excludeTriggers: ['cron'] });
|
|
36
36
|
|
|
37
37
|
// Show skeleton when current session's topic data is not yet loaded
|
|
38
38
|
if (isUndefinedTopics) return <SkeletonList />;
|
|
@@ -30,7 +30,7 @@ const TopicListContent = memo(() => {
|
|
|
30
30
|
|
|
31
31
|
const [topicDisplayMode] = useUserStore((s) => [preferenceSelectors.topicDisplayMode(s)]);
|
|
32
32
|
|
|
33
|
-
useFetchTopics();
|
|
33
|
+
useFetchTopics({ excludeTriggers: ['cron'] });
|
|
34
34
|
|
|
35
35
|
if (isInSearchMode) return <SearchResult />;
|
|
36
36
|
|
|
@@ -22,7 +22,7 @@ const Topic = memo<TopicProps>(({ itemKey }) => {
|
|
|
22
22
|
const { t } = useTranslation(['topic', 'common']);
|
|
23
23
|
const [topicCount] = useChatStore((s) => [topicSelectors.currentTopicCount(s)]);
|
|
24
24
|
const dropdownMenu = useTopicActionsDropdownMenu();
|
|
25
|
-
const { isRevalidating } = useFetchTopics();
|
|
25
|
+
const { isRevalidating } = useFetchTopics({ excludeTriggers: ['cron'] });
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<AccordionItem
|