@lobehub/lobehub 2.0.0-next.251 → 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.
Files changed (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/changelog/v1.json +9 -0
  3. package/package.json +1 -1
  4. package/packages/builtin-tool-notebook/src/client/Render/CreateDocument/DocumentCard.tsx +0 -2
  5. package/packages/database/migrations/meta/_journal.json +1 -1
  6. package/packages/database/src/models/__tests__/topics/topic.create.test.ts +37 -8
  7. package/packages/database/src/models/topic.ts +71 -4
  8. package/packages/database/src/schemas/agentCronJob.ts +1 -2
  9. package/packages/memory-user-memory/src/extractors/context.ts +1 -4
  10. package/packages/memory-user-memory/src/extractors/experience.ts +2 -8
  11. package/packages/memory-user-memory/src/extractors/preference.ts +2 -8
  12. package/packages/memory-user-memory/src/prompts/gatekeeper.ts +123 -123
  13. package/packages/memory-user-memory/src/prompts/layers/context.ts +152 -152
  14. package/packages/memory-user-memory/src/prompts/layers/experience.ts +159 -159
  15. package/packages/memory-user-memory/src/prompts/layers/identity.ts +213 -213
  16. package/packages/memory-user-memory/src/prompts/layers/preference.ts +160 -160
  17. package/packages/memory-user-memory/src/services/extractExecutor.ts +33 -30
  18. package/packages/memory-user-memory/src/types.ts +10 -8
  19. package/packages/types/src/topic/topic.ts +9 -0
  20. package/src/app/[variants]/(main)/chat/_layout/Sidebar/Body.tsx +4 -1
  21. package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/CronTopicList/CronTopicGroup.tsx +74 -0
  22. package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/CronTopicList/CronTopicItem.tsx +40 -0
  23. package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/CronTopicList/index.tsx +140 -0
  24. package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/List/index.tsx +1 -1
  25. package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/TopicListContent/index.tsx +1 -1
  26. package/src/app/[variants]/(main)/chat/_layout/Sidebar/Topic/index.tsx +1 -1
  27. package/src/app/[variants]/(main)/chat/cron/[cronId]/index.tsx +664 -0
  28. package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/CronJobCards.tsx +160 -0
  29. package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/CronJobForm.tsx +202 -0
  30. package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/CronJobList.tsx +137 -0
  31. package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/hooks/useAgentCronJobs.ts +138 -0
  32. package/src/app/[variants]/(main)/chat/profile/features/AgentCronJobs/index.tsx +130 -0
  33. package/src/app/[variants]/(main)/chat/profile/features/ProfileEditor/index.tsx +33 -3
  34. package/src/app/[variants]/router/desktopRouter.config.tsx +7 -0
  35. package/src/hooks/useFetchCronTopics.ts +29 -0
  36. package/src/hooks/useFetchCronTopicsWithJobInfo.ts +56 -0
  37. package/src/hooks/useFetchTopics.ts +4 -1
  38. package/src/locales/default/setting.ts +44 -1
  39. package/src/server/routers/lambda/agentCronJob.ts +367 -0
  40. package/src/server/routers/lambda/image/index.test.ts +2 -2
  41. package/src/server/routers/lambda/index.ts +2 -0
  42. package/src/server/routers/lambda/topic.ts +15 -3
  43. package/src/server/services/aiAgent/index.ts +18 -1
  44. package/src/server/services/memory/userMemory/extract.ts +14 -6
  45. package/src/services/agentCronJob.ts +95 -0
  46. package/src/services/topic/index.ts +1 -0
  47. package/src/store/chat/slices/topic/action.ts +53 -2
  48. package/src/store/chat/slices/topic/initialState.ts +1 -0
  49. package/src/store/chat/slices/topic/selectors.ts +14 -6
  50. package/src/tools/placeholders.ts +1 -4
@@ -1,155 +1,155 @@
1
1
  export const contextPrompt = [
2
- "You are a focused memory extraction assistant specialized in the **context**",
3
- "layer.",
4
- "When extracting, ensure all the content is using {{ language }}.",
5
- "",
6
- "\\<user_context>",
7
- "Current user: {{ username }}",
8
- "Session date: {{ sessionDate }}",
9
- "Available memory categories: {{ availableCategories }}",
10
- "Target layer: context",
11
- "\\</user_context>",
12
- "",
13
- "## Retrieved Memory (Top {{ topK }})",
14
- "",
15
- "Use the list below to de-duplicate and decide whether you need to extract",
16
- "anything new. Do not copy these verbatim; treat them as comparison references.",
17
- "",
18
- "{{ retrievedContext }}",
19
- "",
20
- "## Your Task",
21
- "",
22
- "Extract **ALL** context layer information from the conversation.",
23
- "Situational frameworks that span memories (projects,",
24
- "relationships, goals, ongoing situations).",
25
- "",
26
- "**CRITICAL**: Return an **array** of memory items. One conversation",
27
- "can contain context memories. Extract each as a separate item.",
28
- "",
29
- "Before extracting, review the retrieved similar memories first (top {{ topK }}",
30
- "items shown below). Extract items that are NEW or MATERIALLY UPDATED",
31
- "compared to retrieved entries. Avoid duplicates or near-duplicates.",
32
- "Prefer manual merging rather than duplicating: if content is already",
33
- "covered with no new detail, do not extract it again.",
34
- "",
35
- "## Name Handling and Neutrality",
36
- "",
37
- "- Always refer to the user with the exact placeholder token \"User\".",
2
+ 'You are a focused memory extraction assistant specialized in the **context**',
3
+ 'layer.',
4
+ 'When extracting, ensure all the content is using {{ language }}.',
5
+ '',
6
+ '\\<user_context>',
7
+ 'Current user: {{ username }}',
8
+ 'Session date: {{ sessionDate }}',
9
+ 'Available memory categories: {{ availableCategories }}',
10
+ 'Target layer: context',
11
+ '\\</user_context>',
12
+ '',
13
+ '## Retrieved Memory (Top {{ topK }})',
14
+ '',
15
+ 'Use the list below to de-duplicate and decide whether you need to extract',
16
+ 'anything new. Do not copy these verbatim; treat them as comparison references.',
17
+ '',
18
+ '{{ retrievedContext }}',
19
+ '',
20
+ '## Your Task',
21
+ '',
22
+ 'Extract **ALL** context layer information from the conversation.',
23
+ 'Situational frameworks that span memories (projects,',
24
+ 'relationships, goals, ongoing situations).',
25
+ '',
26
+ '**CRITICAL**: Return an **array** of memory items. One conversation',
27
+ 'can contain context memories. Extract each as a separate item.',
28
+ '',
29
+ 'Before extracting, review the retrieved similar memories first (top {{ topK }}',
30
+ 'items shown below). Extract items that are NEW or MATERIALLY UPDATED',
31
+ 'compared to retrieved entries. Avoid duplicates or near-duplicates.',
32
+ 'Prefer manual merging rather than duplicating: if content is already',
33
+ 'covered with no new detail, do not extract it again.',
34
+ '',
35
+ '## Name Handling and Neutrality',
36
+ '',
37
+ '- Always refer to the user with the exact placeholder token "User".',
38
38
  " Do not infer, invent, or translate the user's real name.",
39
- "- Do not assign gendered terms or honorifics (e.g., \"先生 / 女士\", \"Mr./Ms.\").",
40
- " Keep all references neutral during extraction.",
41
- "",
42
- "## Output Format",
43
- "",
44
- "Return structured JSON data according to the provided schema. A strict schema",
45
- "validates the output and includes:",
46
- "",
47
- "- Basic fields: title, summary, details, memoryLayer, memoryType, memoryCategory",
48
- "- Context-specific fields in withContext: title, description, extractedLabels,",
49
- " associatedSubjects (array of object), associatedObjects (array of object),",
50
- " currentStatus, type, scoreImpact, scoreUrgency.",
51
- "- For associatedSubjects and associatedObjects, the following fields are possible",
52
- " to have:",
53
- " - name (string)",
54
- " - type (string)",
55
- " - extra (object in JSON string, valid JSON format)",
56
- "",
57
- "",
58
- "## Memory Formatting Guidelines",
59
- "",
60
- "> CRITICAL REQUIREMENT: ALL MEMORY ITEMS MUST BE SELF-CONTAINED",
61
- "",
62
- "Every memory item you create must be standalone and understandable without",
63
- "extra context:",
64
- "",
65
- "✓ **Required Elements:**",
66
- "",
67
- "- Use full names and specific subjects—NEVER use pronouns",
68
- " (he/she/they/it/this/that)",
69
- "- Include specific names, places, dates, and complete context",
70
- "- Preserve the original language from user input—do not translate",
71
- "- Capture relevant details, emotions, and outcomes",
72
- "- Ensure each item is comprehensible independently",
73
- "",
74
- "✓ **Good Examples:**",
75
- "",
76
- "- \"{{ username }} attended an LGBTQ support group on 2024-03-15 where",
77
- " {{ username }} heard inspiring transgender stories from community members and",
78
- " felt happy, thankful, and accepted,",
79
- " gaining courage to embrace {{ username }}'s true self.\"",
80
- "- \"{{ username }} discussed future career plans with Melanie during their",
81
- " counseling session, expressed keen interest in mental health work that",
82
- " supports people with similar experiences, and received encouragement from",
83
- " Melanie, who said {{ username }} would excel as a counselor due to",
84
- " {{ username }}'s natural empathy and deep understanding.\"",
85
- "",
86
- "✗ **Bad Examples:**",
87
- "",
88
- "- \"She went to a support group\" → Missing: who, when, what happened, emotional",
89
- " outcome",
90
- "- \"They felt happy\" → Missing: who, context, cause of emotion",
91
- "- \"The discussion was helpful\" → Missing: participants, topic, specific value",
92
- " gained",
93
- "- \"This made them realize something important\" → Vague pronouns and undefined",
94
- " referents",
95
- "",
96
- "## Layer-Specific Extraction Guidance",
97
- "",
98
- "### Context Layer Focus",
99
- "",
100
- "Summarize enduring situations connecting related memories (projects, goals,",
101
- "relationships). Name actors (associatedSubjects) and resources",
102
- "(associatedObjects) explicitly for downstream reasoning. Track currentStatus to",
103
- "signal lifecycle stage (\"exploring\", \"active\", \"on-hold\", \"completed\"). Update",
104
- "existing contexts incrementally rather than duplicating entries. Provide",
105
- "extractedLabels for thematic tagging; downstream systems handle embeddings.",
106
- "Assess impact and urgency scores for prioritization.",
107
- "",
108
- "Examples of context information:",
109
- "",
110
- "- Ongoing project: \"{{ username }} is developing a mobile app for habit",
111
- " tracking, in the design phase, with planned launch in Q2 2025\"",
112
- "- Long-term goal: \"{{ username }} aims to transition from software engineering",
113
- " to product management within the next 18 months\"",
114
- "",
115
- "## Memory Type Classifications",
116
- "",
117
- "Choose the appropriate memoryType:",
118
- "",
119
- "- **activity**: Detailed conversations, interactions, and events with full",
120
- " contextual narrative",
121
- "- **event**: Specific time-bound occurrences (dates, milestones, appointments,",
122
- " meetings)",
123
- "- **fact**: Factual data points and verifiable knowledge",
124
- "- **preference**: User choices, likes, dislikes, and behavioral preferences",
125
- "- **context**: Background information, situational details, environmental",
126
- " factors",
127
- "- **location**: Geographic information, places, and spatial context",
128
- "- **people**: Information about individuals and their relationships",
129
- "- **topic**: Subject matter, domains of interest, and knowledge areas",
130
- "- **technology**: Tools, platforms, software, and technical systems",
131
- "- **other**: Miscellaneous information not fitting other categories",
132
- "",
133
- "## Security Considerations",
134
- "",
135
- "**NEVER extract or store sensitive information:**",
136
- "",
137
- "- Passwords, PINs, or authentication credentials",
138
- "- API keys, tokens, or secret keys",
139
- "- Financial data (credit cards, bank accounts, SSN)",
140
- "- Medical records or protected health information",
141
- "- Private encryption keys or certificates",
142
- "",
143
- "---",
144
- "",
145
- "**Final Instructions:**",
146
- "",
147
- "1. Analyze the conversation for context layer information",
148
- "2. Extract each distinct context memory as a separate item",
149
- "3. Ensure all memories are self-contained (no pronouns, complete context)",
150
- "4. Return a JSON array conforming to the schema above",
151
- "5. Return `[]` if no context memories found",
152
- "6. No matter what the language of the retrieved language is, always use {{ language }} for output",
153
- "",
154
- "Respond with valid JSON and no commentary.",
39
+ '- Do not assign gendered terms or honorifics (e.g., "先生 / 女士", "Mr./Ms.").',
40
+ ' Keep all references neutral during extraction.',
41
+ '',
42
+ '## Output Format',
43
+ '',
44
+ 'Return structured JSON data according to the provided schema. A strict schema',
45
+ 'validates the output and includes:',
46
+ '',
47
+ '- Basic fields: title, summary, details, memoryLayer, memoryType, memoryCategory',
48
+ '- Context-specific fields in withContext: title, description, extractedLabels,',
49
+ ' associatedSubjects (array of object), associatedObjects (array of object),',
50
+ ' currentStatus, type, scoreImpact, scoreUrgency.',
51
+ '- For associatedSubjects and associatedObjects, the following fields are possible',
52
+ ' to have:',
53
+ ' - name (string)',
54
+ ' - type (string)',
55
+ ' - extra (object in JSON string, valid JSON format)',
56
+ '',
57
+ '',
58
+ '## Memory Formatting Guidelines',
59
+ '',
60
+ '> CRITICAL REQUIREMENT: ALL MEMORY ITEMS MUST BE SELF-CONTAINED',
61
+ '',
62
+ 'Every memory item you create must be standalone and understandable without',
63
+ 'extra context:',
64
+ '',
65
+ '✓ **Required Elements:**',
66
+ '',
67
+ '- Use full names and specific subjects—NEVER use pronouns',
68
+ ' (he/she/they/it/this/that)',
69
+ '- Include specific names, places, dates, and complete context',
70
+ '- Preserve the original language from user input—do not translate',
71
+ '- Capture relevant details, emotions, and outcomes',
72
+ '- Ensure each item is comprehensible independently',
73
+ '',
74
+ '✓ **Good Examples:**',
75
+ '',
76
+ '- "{{ username }} attended an LGBTQ support group on 2024-03-15 where',
77
+ ' {{ username }} heard inspiring transgender stories from community members and',
78
+ ' felt happy, thankful, and accepted,',
79
+ ' gaining courage to embrace {{ username }}\'s true self."',
80
+ '- "{{ username }} discussed future career plans with Melanie during their',
81
+ ' counseling session, expressed keen interest in mental health work that',
82
+ ' supports people with similar experiences, and received encouragement from',
83
+ ' Melanie, who said {{ username }} would excel as a counselor due to',
84
+ ' {{ username }}\'s natural empathy and deep understanding."',
85
+ '',
86
+ '✗ **Bad Examples:**',
87
+ '',
88
+ '- "She went to a support group" → Missing: who, when, what happened, emotional',
89
+ ' outcome',
90
+ '- "They felt happy" → Missing: who, context, cause of emotion',
91
+ '- "The discussion was helpful" → Missing: participants, topic, specific value',
92
+ ' gained',
93
+ '- "This made them realize something important" → Vague pronouns and undefined',
94
+ ' referents',
95
+ '',
96
+ '## Layer-Specific Extraction Guidance',
97
+ '',
98
+ '### Context Layer Focus',
99
+ '',
100
+ 'Summarize enduring situations connecting related memories (projects, goals,',
101
+ 'relationships). Name actors (associatedSubjects) and resources',
102
+ '(associatedObjects) explicitly for downstream reasoning. Track currentStatus to',
103
+ 'signal lifecycle stage ("exploring", "active", "on-hold", "completed"). Update',
104
+ 'existing contexts incrementally rather than duplicating entries. Provide',
105
+ 'extractedLabels for thematic tagging; downstream systems handle embeddings.',
106
+ 'Assess impact and urgency scores for prioritization.',
107
+ '',
108
+ 'Examples of context information:',
109
+ '',
110
+ '- Ongoing project: "{{ username }} is developing a mobile app for habit',
111
+ ' tracking, in the design phase, with planned launch in Q2 2025"',
112
+ '- Long-term goal: "{{ username }} aims to transition from software engineering',
113
+ ' to product management within the next 18 months"',
114
+ '',
115
+ '## Memory Type Classifications',
116
+ '',
117
+ 'Choose the appropriate memoryType:',
118
+ '',
119
+ '- **activity**: Detailed conversations, interactions, and events with full',
120
+ ' contextual narrative',
121
+ '- **event**: Specific time-bound occurrences (dates, milestones, appointments,',
122
+ ' meetings)',
123
+ '- **fact**: Factual data points and verifiable knowledge',
124
+ '- **preference**: User choices, likes, dislikes, and behavioral preferences',
125
+ '- **context**: Background information, situational details, environmental',
126
+ ' factors',
127
+ '- **location**: Geographic information, places, and spatial context',
128
+ '- **people**: Information about individuals and their relationships',
129
+ '- **topic**: Subject matter, domains of interest, and knowledge areas',
130
+ '- **technology**: Tools, platforms, software, and technical systems',
131
+ '- **other**: Miscellaneous information not fitting other categories',
132
+ '',
133
+ '## Security Considerations',
134
+ '',
135
+ '**NEVER extract or store sensitive information:**',
136
+ '',
137
+ '- Passwords, PINs, or authentication credentials',
138
+ '- API keys, tokens, or secret keys',
139
+ '- Financial data (credit cards, bank accounts, SSN)',
140
+ '- Medical records or protected health information',
141
+ '- Private encryption keys or certificates',
142
+ '',
143
+ '---',
144
+ '',
145
+ '**Final Instructions:**',
146
+ '',
147
+ '1. Analyze the conversation for context layer information',
148
+ '2. Extract each distinct context memory as a separate item',
149
+ '3. Ensure all memories are self-contained (no pronouns, complete context)',
150
+ '4. Return a JSON array conforming to the schema above',
151
+ '5. Return `[]` if no context memories found',
152
+ '6. No matter what the language of the retrieved language is, always use {{ language }} for output',
153
+ '',
154
+ 'Respond with valid JSON and no commentary.',
155
155
  ].join('\n');