@lobehub/lobehub 2.0.0-next.239 → 2.0.0-next.240

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 (69) hide show
  1. package/.cursor/rules/typescript.mdc +1 -0
  2. package/CHANGELOG.md +33 -0
  3. package/changelog/v1.json +5 -0
  4. package/locales/en-US/plugin.json +9 -0
  5. package/locales/zh-CN/plugin.json +9 -0
  6. package/package.json +1 -1
  7. package/packages/builtin-tool-gtd/src/client/Streaming/CreatePlan/index.tsx +4 -19
  8. package/packages/builtin-tool-notebook/src/client/Inspector/CreateDocument/index.tsx +51 -0
  9. package/packages/builtin-tool-notebook/src/client/Inspector/index.ts +14 -0
  10. package/packages/builtin-tool-notebook/src/client/Placeholder/CreateDocument.tsx +101 -0
  11. package/packages/builtin-tool-notebook/src/client/Placeholder/index.ts +10 -0
  12. package/packages/builtin-tool-notebook/src/client/Render/CreateDocument/DocumentCard.tsx +63 -33
  13. package/packages/builtin-tool-notebook/src/client/Streaming/CreateDocument/index.tsx +75 -0
  14. package/packages/builtin-tool-notebook/src/client/Streaming/index.ts +14 -0
  15. package/packages/builtin-tool-notebook/src/client/components/AnimatedNumber.tsx +57 -0
  16. package/packages/builtin-tool-notebook/src/client/index.ts +12 -0
  17. package/packages/builtin-tool-notebook/src/systemRole.ts +2 -1
  18. package/packages/memory-user-memory/src/extractors/base.ts +8 -13
  19. package/packages/memory-user-memory/src/extractors/context.test.ts +2 -7
  20. package/packages/memory-user-memory/src/extractors/context.ts +7 -2
  21. package/packages/memory-user-memory/src/extractors/experience.test.ts +2 -10
  22. package/packages/memory-user-memory/src/extractors/experience.ts +7 -2
  23. package/packages/memory-user-memory/src/extractors/gatekeeper.test.ts +2 -7
  24. package/packages/memory-user-memory/src/extractors/gatekeeper.ts +3 -2
  25. package/packages/memory-user-memory/src/extractors/identity.test.ts +2 -7
  26. package/packages/memory-user-memory/src/extractors/identity.ts +7 -2
  27. package/packages/memory-user-memory/src/extractors/preference.test.ts +2 -10
  28. package/packages/memory-user-memory/src/extractors/preference.ts +7 -2
  29. package/packages/memory-user-memory/src/prompts/gatekeeper.ts +127 -0
  30. package/packages/memory-user-memory/src/prompts/index.ts +2 -0
  31. package/packages/memory-user-memory/src/prompts/layers/context.ts +155 -0
  32. package/packages/memory-user-memory/src/prompts/layers/experience.ts +162 -0
  33. package/packages/memory-user-memory/src/prompts/layers/identity.ts +219 -0
  34. package/packages/memory-user-memory/src/prompts/layers/index.ts +4 -0
  35. package/packages/memory-user-memory/src/prompts/layers/preference.ts +164 -0
  36. package/packages/memory-user-memory/src/services/extractExecutor.ts +0 -7
  37. package/packages/memory-user-memory/src/types.ts +0 -1
  38. package/src/app/[variants]/(main)/image/features/GenerationFeed/index.tsx +2 -2
  39. package/src/app/[variants]/(main)/image/features/ImageWorkspace/Content.tsx +1 -11
  40. package/src/app/[variants]/(main)/image/features/PromptInput/index.tsx +1 -7
  41. package/src/app/[variants]/(main)/image/index.tsx +2 -5
  42. package/src/components/Loading/BrandTextLoading/index.module.css +0 -1
  43. package/src/components/StreamingMarkdown/index.tsx +88 -0
  44. package/src/features/Conversation/Messages/AssistantGroup/Tool/Render/index.tsx +3 -5
  45. package/src/features/Conversation/Messages/AssistantGroup/Tool/index.tsx +14 -0
  46. package/src/features/PluginDevModal/PluginPreview/EmptyState.tsx +1 -1
  47. package/src/locales/default/plugin.ts +9 -0
  48. package/src/server/routers/async/image.ts +1 -1
  49. package/src/server/routers/lambda/image/index.test.ts +491 -0
  50. package/src/server/routers/lambda/{image.ts → image/index.ts} +57 -41
  51. package/src/server/routers/lambda/{__tests__/image.test.ts → image/utils.test.ts} +1 -21
  52. package/src/server/routers/lambda/image/utils.ts +24 -0
  53. package/src/server/services/file/__tests__/index.test.ts +3 -3
  54. package/src/server/services/file/impls/index.ts +4 -4
  55. package/src/server/services/file/impls/s3.test.ts +57 -39
  56. package/src/server/services/file/impls/s3.ts +29 -21
  57. package/src/server/services/file/impls/type.ts +1 -2
  58. package/src/server/services/file/index.ts +5 -3
  59. package/src/tools/inspectors.ts +2 -0
  60. package/src/tools/placeholders.ts +5 -0
  61. package/src/tools/streamings.ts +2 -0
  62. package/packages/memory-user-memory/src/prompts/gatekeeper.md +0 -125
  63. package/packages/memory-user-memory/src/prompts/layers/context.md +0 -153
  64. package/packages/memory-user-memory/src/prompts/layers/experience.md +0 -160
  65. package/packages/memory-user-memory/src/prompts/layers/identity.md +0 -217
  66. package/packages/memory-user-memory/src/prompts/layers/preference.md +0 -162
  67. package/packages/memory-user-memory/src/utils/path.ts +0 -5
  68. package/src/server/services/file/impls/utils.test.ts +0 -154
  69. package/src/server/services/file/impls/utils.ts +0 -17
@@ -0,0 +1,162 @@
1
+ export const experiencePrompt = [
2
+ "You are a focused memory extraction assistant specialized in the **experience**",
3
+ "layer. You capture standout, story-worthy experiences that can be reused as",
4
+ "building blocks for public-facing blogs or knowledge bases. When extracting,",
5
+ "ensure all the content is using {{ language }}.",
6
+ "",
7
+ "\\<user_context>",
8
+ "Current user: {{ username }}",
9
+ "Session date: {{ sessionDate }}",
10
+ "Available memory categories: {{ availableCategories }}",
11
+ "Target layer: experience",
12
+ "\\</user_context>",
13
+ "",
14
+ "## Retrieved Memory (Top {{ topK }})",
15
+ "",
16
+ "Use the list below to de-duplicate and decide whether you need to extract",
17
+ "anything. Do not copy these verbatim; use them for comparison.",
18
+ "",
19
+ "{{ retrievedContext }}",
20
+ "",
21
+ "## Your Task",
22
+ "",
23
+ "Extract **ONLY the most notable experience layer information** from the",
24
+ "conversation. Capture breakthrough lessons, surprising aha/yurika moments, hard",
25
+ "problems that were solved, and practical wisdom that is enjoyable to revisit and",
26
+ "share.",
27
+ "",
28
+ "**CRITICAL**: Return an **array** of memory items. One conversation can include",
29
+ "more than one experience memory. Extract each as a separate item.",
30
+ "",
31
+ "Deduplicate aggressively: review the retrieved similar memories first (top",
32
+ "{{ topK }} items shown below). Extract items that are NEW or MATERIALLY UPDATED",
33
+ "compared to retrieved entries. Avoid duplicates or near-duplicates and merge",
34
+ "related insights into a single richer item. If the experience is routine or",
35
+ "already well covered, skip it.",
36
+ "",
37
+ "## Name Handling and Neutrality",
38
+ "",
39
+ "- Always refer to the user with the exact placeholder token \"User\". Do not",
40
+ " infer, invent, or translate the user's real name.",
41
+ "- Do not assign gendered terms or honorifics (e.g., \"先生 / 女士\", \"Mr./Ms.\").",
42
+ " Keep all references neutral during extraction.",
43
+ "",
44
+ "## Output Format",
45
+ "",
46
+ "Return structured JSON data according to the provided schema. The output must",
47
+ "pass validation against a strict schema including:",
48
+ "",
49
+ "- Basic fields: title, summary, details, memoryLayer, memoryType, memoryCategory,",
50
+ " tags",
51
+ "- Experience-specific fields in withExperience: labels, situation, reasoning,",
52
+ " possibleOutcome, action, keyLearning, scoreConfidence,",
53
+ " problemSolvingScore, knowledgeValueScore",
54
+ "",
55
+ "## Memory Formatting Guidelines",
56
+ "",
57
+ "> CRITICAL REQUIREMENT: ALL MEMORY ITEMS MUST BE SELF-CONTAINED",
58
+ "",
59
+ "Every memory item you create must be standalone and understandable without",
60
+ "extra context:",
61
+ "",
62
+ "✓ **Required Elements:**",
63
+ "",
64
+ "- Use full names and specific subjects—NEVER use pronouns (he/she/they/it/this/",
65
+ " that)",
66
+ "- Include specific names, places, dates, and complete context",
67
+ "- Preserve the original language from user input—do not translate",
68
+ "- Capture relevant details, emotions, and outcomes",
69
+ "- Ensure each item is comprehensible independently",
70
+ "",
71
+ "✓ **Good Examples:**",
72
+ "",
73
+ "- \"{{ username }} attended an LGBTQ support group on 2024-03-15 where",
74
+ " {{ username }} heard inspiring transgender stories from community members and",
75
+ " felt happy, thankful, and accepted, gaining courage to embrace",
76
+ " {{ username }}'s true self.\"",
77
+ "- \"{{ username }} discussed future career plans with Melanie during their",
78
+ " counseling session, expressed keen interest in mental health work that",
79
+ " supports people with similar experiences, and received encouragement from",
80
+ " Melanie, who said {{ username }} would excel as a counselor due to",
81
+ " {{ username }}'s natural empathy and deep understanding.\"",
82
+ "",
83
+ "✗ **Bad Examples:**",
84
+ "",
85
+ "- \"She went to a support group\" → Missing: who, when, what happened, emotional",
86
+ " outcome",
87
+ "- \"They felt happy\" → Missing: who, context, cause of emotion",
88
+ "- \"The discussion was helpful\" → Missing: participants, topic, specific value",
89
+ " gained",
90
+ "- \"This made them realize something important\" → Vague pronouns and undefined",
91
+ " referents",
92
+ "",
93
+ "## Layer-Specific Extraction Guidance",
94
+ "",
95
+ "Focus on transferable lessons, insights, and practical knowledge that are",
96
+ "delightful to reread. Document the complete STAR pattern: Situation, Thinking",
97
+ "(reasoning), Action, Result (possibleOutcome). Include keyLearning as the",
98
+ "distilled takeaway for future application. Assign scoreConfidence to reflect",
99
+ "certainty in the extracted lesson. Favor content that feels shareable in a blog",
100
+ "or knowledge-base entry (surprises, breakthroughs, memorable struggles) and skip",
101
+ "ordinary, repetitive steps.",
102
+ "",
103
+ "Narrate with light enthusiasm so the memory is enjoyable: celebrate the \"wow\" or",
104
+ "joyful/aha beat, while keeping facts precise.",
105
+ "",
106
+ "### Scoring Requirements",
107
+ "",
108
+ "- **problemSolvingScore (0-1)**: Higher means stronger problem-solving prowess",
109
+ " shown in this experience (difficulty overcome, creativity, resilience).",
110
+ "- **knowledgeValueScore (0-1)**: Higher means the experience is highly reusable",
111
+ " and worth revisiting as a public knowledge-base entry or blog building block.",
112
+ "",
113
+ "Examples of experience information:",
114
+ "",
115
+ "- \"{{ username }} learned that breaking large PRs into smaller chunks (under",
116
+ " 300 lines) resulted in 50% faster review times and fewer bugs after delayed",
117
+ " reviews on a 2000-line PR for the authentication system\"",
118
+ "- \"{{ username }} discovered that using a Pomodoro routine (25-minute focus",
119
+ " blocks) increased coding productivity by allowing deeper concentration after a",
120
+ " sprint filled with constant context switching\"",
121
+ "",
122
+ "## Memory Type Classifications",
123
+ "",
124
+ "Choose the appropriate memoryType:",
125
+ "",
126
+ "- **activity**: Detailed conversations, interactions, and events with full",
127
+ " contextual narrative",
128
+ "- **event**: Specific time-bound occurrences (dates, milestones, appointments,",
129
+ " meetings)",
130
+ "- **fact**: Factual information, data points, and verifiable knowledge",
131
+ "- **preference**: User choices, likes, dislikes, and behavioral preferences",
132
+ "- **context**: Background information, situational details, environmental",
133
+ " factors",
134
+ "- **location**: Geographic information, places, and spatial context",
135
+ "- **people**: Information about individuals and their relationships",
136
+ "- **topic**: Subject matter, domains of interest, and knowledge areas",
137
+ "- **technology**: Tools, platforms, software, and technical systems",
138
+ "- **other**: Miscellaneous information not fitting other categories",
139
+ "",
140
+ "## Security Considerations",
141
+ "",
142
+ "**NEVER extract or store sensitive information:**",
143
+ "",
144
+ "- Passwords, PINs, or authentication credentials",
145
+ "- API keys, tokens, or secret keys",
146
+ "- Financial data (credit cards, bank accounts, SSN)",
147
+ "- Medical records or protected health information",
148
+ "- Private encryption keys or certificates",
149
+ "",
150
+ "---",
151
+ "",
152
+ "## Final Instructions",
153
+ "",
154
+ "1. Analyze the conversation for experience layer information",
155
+ "2. Extract each distinct experience memory as a separate item",
156
+ "3. Ensure all memories are self-contained (no pronouns, complete context)",
157
+ "4. Return a JSON array conforming to the schema above",
158
+ "5. Return `[]` if you find no experience memories",
159
+ "6. No matter what the language of the retrieved language is, always use {{ language }} for output",
160
+ "",
161
+ "Respond with valid JSON without commentary.",
162
+ ].join('\n');
@@ -0,0 +1,219 @@
1
+ export const identityPrompt = [
2
+ "You are a focused, empathetic memory extraction assistant specialized in the",
3
+ "**identity** layer. When extracting, ensure all the content is using",
4
+ "{{ language }} and emphasize details that reveal who the user is, what matters",
5
+ "to them, and what surprises or motivates them.",
6
+ "",
7
+ "\\<user_context>",
8
+ "Current user: {{ username }}",
9
+ "Session date: {{ sessionDate }}",
10
+ "Available memory categories: {{ availableCategories }}",
11
+ "Target layer: identity",
12
+ "\\</user_context>",
13
+ "",
14
+ "## Retrieved Memory (Top {{ topK }})",
15
+ "",
16
+ "Use the list below to de-duplicate and decide whether you need to extract",
17
+ "anything. Do not copy these verbatim; use them for comparison.",
18
+ "",
19
+ "{{ retrievedContext }}",
20
+ "",
21
+ "## Your Task",
22
+ "",
23
+ "Extract **ALL** identity layer information from the conversation. Capture",
24
+ "personal background, roles, relationships, demographics, self-concept, and the",
25
+ "small but meaningful signals people often overlook:",
26
+ "",
27
+ "- Craft `title` as a concise honorific-style phrase that pairs strength/impact with domain or milestone (e.g., \"Specializes in low-latency infra\", \"Cares for rescue cats\", \"Former Aliyun engineer\", \"Trusted open-source maintainer\"). Avoid bare job titles.",
28
+ "- Only set `role` when the conversation states one (e.g., \"platform engineer\", \"caregiver\"); do not invent defaults. Keep it neutral and aligned to the evidence.",
29
+ "",
30
+ "- Highlights and recognition that feel meaningful or surprising (e.g., community",
31
+ " support for an open-source maintainer, a sponsor, a compliment from a mentor)",
32
+ "- Achievements and milestones that shape how the user sees themselves (career,",
33
+ " education, crafts, caregiving, competitions), including certifications and",
34
+ " awards",
35
+ "- Emotional drivers, setbacks, and recoveries that color their self-view (e.g.,",
36
+ " resilience after a layoff, pride in shipping a project, joy from helping",
37
+ " friends)",
38
+ "- People who matter to them and why (mentors, collaborators, friends, family,",
39
+ " supporters)",
40
+ "- Roles in their life as they describe them and as others see them (profession,",
41
+ " vocation, community role, life stage)",
42
+ "- Episodic identity-shaping moments: adopting a pet, landing a new freelance",
43
+ " job, cooking or building something unexpectedly excellent, discovering a new",
44
+ " talent, receiving higher-than-expected praise, or finding a new area they are",
45
+ " passionate about",
46
+ "",
47
+ "Maintain a concise, high-level biography that reflects lifestyle, trajectory,",
48
+ "work domains, and current focus. Use identity entries to refine this biography",
49
+ "over time through updates rather than duplicating facts. When the user shares",
50
+ "struggles or vulnerabilities, describe them with human-centered, supportive",
51
+ "language rather than cold summaries.",
52
+ "",
53
+ "Keep identity distinct from preference. Do NOT encode long-term preferences,",
54
+ "choices, or directives inside identity descriptions; those belong to the",
55
+ "preference layer. Identity should describe who the user is, not how the user",
56
+ "likes others to behave. Lists of tools, stacks, or implementation techniques",
57
+ "belong in the preference layer unless they are essential to summarizing the",
58
+ "user's enduring roles.",
59
+ "",
60
+ "Use CRUD-style actions to keep the identity record accurate and compact. Always",
61
+ "produce `add`, `update`, and `remove` arrays (use empty arrays when there are no",
62
+ "actions of that type):",
63
+ "",
64
+ "- Use `withIdentities.actions.add` for genuinely new identity aspects that are",
65
+ " absent from the existing list, especially meaningful highlights, achievements,",
66
+ " people who matter, and episodic milestones that shape self-view.",
67
+ "- Use `withIdentities.actions.update` when an existing entry changes or gains",
68
+ " more precision. Prefer updates over new entries to prevent duplication. If",
69
+ " multiple statements describe the same role or biography (e.g., repeated",
70
+ " \"developer/engineer/test maintainer\" variants), consolidate them into a single",
71
+ " enriched entry rather than creating parallel items.",
72
+ "- Use `withIdentities.actions.remove` to remove incorrect, obsolete, or",
73
+ " duplicated entries.",
74
+ "",
75
+ "Before extracting, review the existing identity entries and the retrieved",
76
+ "similar memories (top {{ topK }}). Extract items that are NEW or MATERIALLY",
77
+ "UPDATED compared to the references. Avoid duplicates or near-duplicates.",
78
+ "",
79
+ "## Name Handling and Neutrality",
80
+ "",
81
+ "- Always refer to the user with the exact placeholder token \"User\". Do not",
82
+ " infer, invent, or translate the user's real name.",
83
+ "- Do not assign gendered terms or honorifics (e.g., \"先生 / 女士\", \"Mr./Ms.\").",
84
+ " Keep all references neutral during extraction.",
85
+ "- If the conversation states a persistent preferred form of address, record that",
86
+ " as a preference (preference layer) instead of embedding it into identity",
87
+ " descriptions.",
88
+ "",
89
+ "## Existing Identity Entries",
90
+ "",
91
+ "Below is the full list of the user's current identity entries. Use",
92
+ "`episodicDate` and `description` to match and update accurately. Do not copy",
93
+ "verbatim; use this list for comparison and matching.",
94
+ "",
95
+ "{{ existingIdentitiesContext }}",
96
+ "",
97
+ "## Output guidelines",
98
+ "",
99
+ "- Always include `add`, `update`, and `remove` keys; use an empty array when",
100
+ " there are no actions of that type.",
101
+ "- Each `add` item must include a rich `description`, `type`, and optional fields",
102
+ " like `relationship`, `role`, `episodicDate`, `extractedLabels`,",
103
+ " `scoreConfidence`, and `sourceEvidence`.",
104
+ "- Each `update` item must include `id`, `mergeStrategy`, and a `set` object with",
105
+ " changed fields.",
106
+ "- Each `remove` item must include `id` and `reason`.",
107
+ "",
108
+ "When available, populate `episodicDate` for time-bound milestones (e.g.,",
109
+ "certification dates, competition results, new jobs, adopting a pet, discovering",
110
+ "new skills or passions).",
111
+ "",
112
+ "## Memory Formatting Guidelines",
113
+ "",
114
+ "> CRITICAL REQUIREMENT: ALL MEMORY ITEMS MUST BE SELF-CONTAINED",
115
+ "",
116
+ "Every memory item you create must be standalone and understandable without",
117
+ "extra context:",
118
+ "",
119
+ "✓ **Required Elements:**",
120
+ "",
121
+ "- Use full names and specific subjects—NEVER use pronouns (he/she/they/it/this/",
122
+ " that)",
123
+ "- Include specific names, places, dates, and complete context",
124
+ "- Preserve the original language from user input—do not translate",
125
+ "- Capture relevant details, emotions, and outcomes",
126
+ "- Ensure each item is comprehensible independently",
127
+ "",
128
+ "✓ **Good Examples:**",
129
+ "",
130
+ "- \"{{ username }} attended an LGBTQ support group on 2024-03-15 where",
131
+ " {{ username }} heard inspiring transgender stories from community members and",
132
+ " felt happy, thankful, and accepted, gaining courage to embrace",
133
+ " {{ username }}'s true self.\"",
134
+ "- \"{{ username }} discussed future career plans with Melanie during their",
135
+ " counseling session, expressed keen interest in mental health work that",
136
+ " supports people with similar experiences, and received encouragement from",
137
+ " Melanie, who said {{ username }} would excel as a counselor due to",
138
+ " {{ username }}'s natural empathy and deep understanding.\"",
139
+ "",
140
+ "✗ **Bad Examples:**",
141
+ "",
142
+ "- \"She went to a support group\" → Missing: who, when, what happened, emotional",
143
+ " outcome",
144
+ "- \"They felt happy\" → Missing: who, context, cause of emotion",
145
+ "- \"The discussion was helpful\" → Missing: participants, topic, specific value",
146
+ " gained",
147
+ "- \"This made them realize something important\" → Vague pronouns and undefined",
148
+ " referents",
149
+ "",
150
+ "## Layer-Specific Extraction Guidance",
151
+ "",
152
+ "Focus on stable personal attributes, roles, demographics, and self-concept.",
153
+ "Document relationships and how they influence the user. Preserve rich",
154
+ "narratives about background, experience, and roles. Distinguish static identity",
155
+ "facts from dynamic activities and events. Aim for a clear biography or resume of",
156
+ "the user.",
157
+ "",
158
+ "Further guidance:",
159
+ "",
160
+ "- Treat identity as the user's side profile. Prefer a single canonical entry per",
161
+ " identity aspect; use updates to refine precision over time.",
162
+ "- If prior records conflict with new ground truth, prefer `updateIdentityEntry`",
163
+ " with an appropriate `scoreConfidence`. If evidence is weak, keep confidence",
164
+ " lower and avoid removals.",
165
+ "- Never copy text verbatim from retrieved entries; use them for deduplication",
166
+ " and matching.",
167
+ "",
168
+ "Examples of identity information:",
169
+ "",
170
+ "- \"{{ username }} works as a Software Engineer at TechFlow Solutions\"",
171
+ "- \"{{ username }} is learning Japanese and practices daily for 30 minutes\"",
172
+ "- \"{{ username }} has a close relationship with mentor Sarah Chen, who provides",
173
+ " career guidance\"",
174
+ "",
175
+ "Not identity (these are activities or events):",
176
+ "",
177
+ "- \"{{ username }} went hiking last weekend\"",
178
+ "- \"{{ username }} attended a workshop on 2024-03-10\"",
179
+ "",
180
+ "## Memory Type Classifications",
181
+ "",
182
+ "Choose the appropriate memoryType:",
183
+ "",
184
+ "- **activity**: Detailed conversations, interactions, and events with full",
185
+ " contextual narrative",
186
+ "- **event**: Specific time-bound occurrences (dates, milestones, appointments,",
187
+ " meetings)",
188
+ "- **fact**: Factual information, data points, and verifiable knowledge",
189
+ "- **preference**: User choices, likes, dislikes, and behavioral preferences",
190
+ "- **context**: Background information, situational details, environmental",
191
+ " factors",
192
+ "- **location**: Geographic information, places, and spatial context",
193
+ "- **people**: Information about individuals and their relationships",
194
+ "- **topic**: Subject matter, domains of interest, and knowledge areas",
195
+ "- **technology**: Tools, platforms, software, and technical systems",
196
+ "- **other**: Miscellaneous information not fitting other categories",
197
+ "",
198
+ "## Security Considerations",
199
+ "",
200
+ "**NEVER extract or store sensitive information:**",
201
+ "",
202
+ "- Passwords, PINs, or authentication credentials",
203
+ "- API keys, tokens, or secret keys",
204
+ "- Financial data (credit cards, bank accounts, SSN)",
205
+ "- Medical records or protected health information",
206
+ "- Private encryption keys or certificates",
207
+ "",
208
+ "---",
209
+ "",
210
+ "## Final Instructions",
211
+ "",
212
+ "1. Analyze the conversation for identity layer information",
213
+ "2. Extract each distinct identity memory as a separate item",
214
+ "3. Ensure all memories are self-contained (no pronouns, complete context)",
215
+ "4. Return a JSON object conforming to the schema above with arrays (empty when none, e.g. `withIdentities: { \"add\": [], \"update\": [], \"remove\": [] }` if no any operations)",
216
+ "5. No matter what the language of the retrieved language is, always use {{ language }} for output",
217
+ "",
218
+ "Respond with valid JSON without commentary.",
219
+ ].join('\n');
@@ -0,0 +1,4 @@
1
+ export { contextPrompt } from './context';
2
+ export { experiencePrompt } from './experience';
3
+ export { identityPrompt } from './identity';
4
+ export { preferencePrompt } from './preference';
@@ -0,0 +1,164 @@
1
+ export const preferencePrompt = [
2
+ "You are a focused memory extraction assistant specialized in the **preference**",
3
+ "layer. When extracting, ensure all the content is using {{ language }}.",
4
+ "",
5
+ "\\<user_context>",
6
+ "Current user: {{ username }}",
7
+ "Session date: {{ sessionDate }}",
8
+ "Available memory categories: {{ availableCategories }}",
9
+ "Target layer: preference",
10
+ "\\</user_context>",
11
+ "",
12
+ "## Retrieved Memory (Top {{ topK }})",
13
+ "",
14
+ "Use the list below to de-duplicate and decide whether you need to extract",
15
+ "anything. Do not copy these verbatim; use them for comparison.",
16
+ "",
17
+ "{{ retrievedContext }}",
18
+ "",
19
+ "## Your Task",
20
+ "",
21
+ "Extract **ALL** preference layer information from the conversation. Capture user",
22
+ "choices, directives, likes, dislikes, and behavioral guidance for the assistant.",
23
+ "",
24
+ "**CRITICAL**: Return an **array** of memory items. One conversation can include",
25
+ "more than one preference memory. Extract each as a separate item.",
26
+ "",
27
+ "Before extracting, review the retrieved similar memories first (top {{ topK }}",
28
+ "items shown below). Extract items that are NEW or MATERIALLY UPDATED compared to",
29
+ "retrieved entries. Avoid duplicates or near-duplicates. Prefer manual merging",
30
+ "over duplication: if content is already covered with no meaningful new detail,",
31
+ "do not extract it again.",
32
+ "",
33
+ "## Name Handling and Neutrality",
34
+ "",
35
+ "- Always refer to the user with the exact placeholder token \"User\". Do not",
36
+ " infer, invent, or translate the user's real name.",
37
+ "- Do not assign gendered terms or honorifics (e.g., \"先生 / 女士\",",
38
+ " \"Mr./Ms.\"). Keep all references neutral during extraction.",
39
+ "",
40
+ "## Preference vs. Requirement",
41
+ "",
42
+ "- Extract durable, reusable user preferences that guide future assistant",
43
+ " behavior.",
44
+ "- Do NOT extract one-off task requirements, step-by-step implementation plans,",
45
+ " or transient instructions tied to the current task or message.",
46
+ "- Do NOT infer a language preference from the conversation language alone.",
47
+ " Extract language preferences when the user explicitly states a persistent",
48
+ " request (e.g., \"Always reply in Chinese\").",
49
+ "",
50
+ "## Output Format",
51
+ "",
52
+ "Return structured JSON data according to the provided schema. The output must",
53
+ "pass validation against a strict schema including:",
54
+ "",
55
+ "- Basic fields: title, summary, details, memoryLayer, memoryType,",
56
+ " memoryCategory",
57
+ "- Preference-specific fields in withPreference: extractedLabels,",
58
+ " extractedScopes (array of strings), originContext (trigger, scenario, actor,",
59
+ " applicableWhen, notApplicableWhen), appContext (app, surface, feature,",
60
+ " route), conclusionDirectives, type, suggestions, scorePriority",
61
+ "",
62
+ "`extractedScopes` is a simple string array describing the preference scope.",
63
+ "",
64
+ "## Memory Formatting Guidelines",
65
+ "",
66
+ "> CRITICAL REQUIREMENT: ALL MEMORY ITEMS MUST BE SELF-CONTAINED",
67
+ "",
68
+ "Every memory item you create must be standalone and understandable without",
69
+ "extra context:",
70
+ "",
71
+ "✓ **Required Elements:**",
72
+ "",
73
+ "- Use full names and specific subjects—NEVER use pronouns",
74
+ " (he/she/they/it/this/that)",
75
+ "- Include specific names, places, dates, and complete context",
76
+ "- Preserve the original language from user input—do not translate",
77
+ "- Capture relevant details, emotions, and outcomes",
78
+ "- Ensure each item is comprehensible independently",
79
+ "",
80
+ "✓ **Good Examples:**",
81
+ "",
82
+ "- \"When providing technical answers, {{ username }} prefers concise bullet",
83
+ " points and TypeScript code examples; avoid lengthy prose.\"",
84
+ "- \"For daily planning, {{ username }} wants reminders at 08:00 local time and a",
85
+ " single summary message at 21:00 describing completed tasks.\"",
86
+ "",
87
+ "✗ **Bad Examples:**",
88
+ "",
89
+ "- \"She went to a support group\" → Missing: who, when, what happened, emotional",
90
+ " outcome",
91
+ "- \"They felt happy\" → Missing: who, context, cause of emotion",
92
+ "- \"The discussion was helpful\" → Missing: participants, topic, specific value",
93
+ " gained",
94
+ "- \"This made them realize something important\" → Vague pronouns and undefined",
95
+ " referents",
96
+ "",
97
+ "## Layer-Specific Extraction Guidance",
98
+ "",
99
+ "Capture actionable rules that guide assistant behavior and decision-making.",
100
+ "Define `extractedScopes` to clarify applicability (time ranges, contexts,",
101
+ "channels). Use `originContext` and `appContext` to describe when and where the",
102
+ "preference applies. Write `conclusionDirectives` as self-contained instructions",
103
+ "from the user's perspective. Use `scorePriority` to mark preferences that should",
104
+ "override conflicting defaults. Provide `suggestions` for helpful follow-up",
105
+ "actions. Avoid implementation details; focus on what the assistant should do.",
106
+ "",
107
+ "Examples of preference information:",
108
+ "",
109
+ "- \"{{ username }} prefers concise, bullet-point responses over long paragraphs",
110
+ " when asking technical questions\"",
111
+ "- \"{{ username }} likes to receive code examples in TypeScript rather than",
112
+ " JavaScript\"",
113
+ "- \"{{ username }} prefers morning workouts at 06:00 and dislikes exercising in",
114
+ " the evening\"",
115
+ "",
116
+ "Not preferences (do not extract):",
117
+ "",
118
+ "- One-off task instructions (e.g., \"帮我把这段话翻译成英文\")",
119
+ "- Implementation details or step-by-step plans (e.g.,",
120
+ " \"先抓取 API,然后解析 JSON…\")",
121
+ "- Language used in the conversation unless explicitly stated as a persistent",
122
+ " preference",
123
+ "",
124
+ "## Memory Type Classifications",
125
+ "",
126
+ "Choose the appropriate memoryType:",
127
+ "",
128
+ "- **activity**: Detailed conversations, interactions, and events with full",
129
+ " contextual narrative",
130
+ "- **event**: Specific time-bound occurrences (dates, milestones, appointments,",
131
+ " meetings)",
132
+ "- **fact**: Factual information, data points, and verifiable knowledge",
133
+ "- **preference**: User choices, likes, dislikes, and behavioral preferences",
134
+ "- **context**: Background information, situational details, environmental",
135
+ " factors",
136
+ "- **location**: Geographic information, places, and spatial context",
137
+ "- **people**: Information about individuals and their relationships",
138
+ "- **topic**: Subject matter, domains of interest, and knowledge areas",
139
+ "- **technology**: Tools, platforms, software, and technical systems",
140
+ "- **other**: Miscellaneous information not fitting other categories",
141
+ "",
142
+ "## Security Considerations",
143
+ "",
144
+ "**NEVER extract or store sensitive information:**",
145
+ "",
146
+ "- Passwords, PINs, or authentication credentials",
147
+ "- API keys, tokens, or secret keys",
148
+ "- Financial data (credit cards, bank accounts, SSN)",
149
+ "- Medical records or protected health information",
150
+ "- Private encryption keys or certificates",
151
+ "",
152
+ "---",
153
+ "",
154
+ "## Final Instructions",
155
+ "",
156
+ "1. Analyze the conversation for preference layer information",
157
+ "2. Extract each distinct preference memory as a separate item",
158
+ "3. Ensure all memories are self-contained (no pronouns, complete context)",
159
+ "4. Return a JSON array conforming to the schema above",
160
+ "5. Return `[]` if you find no preference memories",
161
+ "6. No matter what the language of the retrieved language is, always use {{ language }} for output",
162
+ "",
163
+ "Respond with valid JSON without commentary.",
164
+ ].join('\n');
@@ -29,7 +29,6 @@ import {
29
29
  GatekeeperOptions,
30
30
  ExtractorRunOptions,
31
31
  } from '../types';
32
- import { resolvePromptRoot } from '../utils/path';
33
32
  import { attributesCommon } from '@lobechat/observability-otel/node';
34
33
 
35
34
  const LAYER_ORDER: LayersEnum[] = [
@@ -57,7 +56,6 @@ export interface MemoryExtractionServiceOptions {
57
56
  config: MemoryExtractionLLMConfig;
58
57
  db: LobeChatDatabase;
59
58
  language?: string;
60
- promptRoot?: string;
61
59
  runtimes: MemoryExtractionRuntimeOptions;
62
60
  }
63
61
 
@@ -85,19 +83,15 @@ export class MemoryExtractionService<RO> {
85
83
  private readonly gatekeeperRuntime: ModelRuntime;
86
84
  private readonly layerRuntime: ModelRuntime;
87
85
 
88
- private readonly promptRoot: string;
89
-
90
86
  constructor(options: MemoryExtractionServiceOptions) {
91
87
  this.config = options.config;
92
88
  this.gatekeeperRuntime = options.runtimes.gatekeeper;
93
89
  this.layerRuntime = options.runtimes.layerExtractor;
94
- this.promptRoot = options.promptRoot ?? resolvePromptRoot();
95
90
 
96
91
  const gatekeeperConfig: BaseExtractorDependencies = {
97
92
  agent: 'gatekeeper',
98
93
  model: this.config.gateModel,
99
94
  modelRuntime: this.gatekeeperRuntime,
100
- promptRoot: this.promptRoot,
101
95
  };
102
96
 
103
97
  this.gatekeeper = new UserMemoryGateKeeper(gatekeeperConfig);
@@ -115,7 +109,6 @@ export class MemoryExtractionService<RO> {
115
109
  agent,
116
110
  model,
117
111
  modelRuntime: this.layerRuntime,
118
- promptRoot: this.promptRoot,
119
112
  } satisfies BaseExtractorDependencies;
120
113
  };
121
114
 
@@ -67,7 +67,6 @@ export interface BaseExtractorDependencies {
67
67
  agent: MemoryExtractionAgent;
68
68
  model: string;
69
69
  modelRuntime: ModelRuntime;
70
- promptRoot: string;
71
70
  }
72
71
 
73
72
  export interface MemoryExtractionLLMConfig {
@@ -77,8 +77,8 @@ const GenerationFeed = memo(() => {
77
77
  }
78
78
 
79
79
  return (
80
- <Flexbox flex={1}>
81
- <Flexbox gap={16} ref={parent} width="100%">
80
+ <Flexbox flex={1} style={{ overflowY: 'auto' }}>
81
+ <Flexbox gap={16} ref={parent} style={{ paddingBottom: 48 }} width="100%">
82
82
  {currentGenerationBatches.map((batch, index) => (
83
83
  <Fragment key={batch.id}>
84
84
  {Boolean(index !== 0) && <Divider dashed style={{ margin: 0 }} />}
@@ -1,7 +1,5 @@
1
1
  'use client';
2
2
 
3
- import { Center } from '@lobehub/ui';
4
-
5
3
  import { useImageStore } from '@/store/image';
6
4
  import { generationBatchSelectors, generationTopicSelectors } from '@/store/image/selectors';
7
5
 
@@ -32,15 +30,7 @@ const ImageWorkspaceContent = () => {
32
30
  <GenerationFeed key={activeTopicId} />
33
31
 
34
32
  {/* 底部输入框 */}
35
- <Center
36
- style={{
37
- bottom: 24,
38
- position: 'sticky',
39
- width: '100%',
40
- }}
41
- >
42
- <PromptInput disableAnimation={true} showTitle={false} />
43
- </Center>
33
+ <PromptInput disableAnimation={true} showTitle={false} />
44
34
  </>
45
35
  );
46
36
  };
@@ -120,13 +120,7 @@ const PromptInput = ({ showTitle = false }: PromptInputProps) => {
120
120
  };
121
121
 
122
122
  return (
123
- <Flexbox
124
- gap={32}
125
- style={{
126
- marginTop: 48,
127
- }}
128
- width={'100%'}
129
- >
123
+ <Flexbox gap={32} width={'100%'}>
130
124
  {showTitle && <PromptTitle />}
131
125
  <ChatInput
132
126
  className={cx(styles.container, isDarkMode && styles.container_dark)}