@lobehub/lobehub 2.0.0-next.360 → 2.0.0-next.362

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 (76) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/Dockerfile +2 -1
  3. package/changelog/v1.json +14 -0
  4. package/locales/en-US/chat.json +3 -1
  5. package/locales/zh-CN/chat.json +2 -0
  6. package/package.json +1 -1
  7. package/packages/const/src/userMemory.ts +1 -0
  8. package/packages/context-engine/src/base/BaseEveryUserContentProvider.ts +204 -0
  9. package/packages/context-engine/src/base/BaseLastUserContentProvider.ts +1 -8
  10. package/packages/context-engine/src/base/__tests__/BaseEveryUserContentProvider.test.ts +354 -0
  11. package/packages/context-engine/src/base/constants.ts +20 -0
  12. package/packages/context-engine/src/engine/messages/MessagesEngine.ts +27 -23
  13. package/packages/context-engine/src/engine/messages/__tests__/MessagesEngine.test.ts +364 -0
  14. package/packages/context-engine/src/providers/PageEditorContextInjector.ts +17 -13
  15. package/packages/context-engine/src/providers/PageSelectionsInjector.ts +65 -0
  16. package/packages/context-engine/src/providers/__tests__/PageSelectionsInjector.test.ts +333 -0
  17. package/packages/context-engine/src/providers/index.ts +3 -1
  18. package/packages/database/src/models/userMemory/model.ts +178 -3
  19. package/packages/database/src/models/userMemory/sources/benchmarkLoCoMo.ts +1 -1
  20. package/packages/memory-user-memory/package.json +2 -1
  21. package/packages/memory-user-memory/promptfoo/evals/activity/basic/buildMessages.ts +40 -0
  22. package/packages/memory-user-memory/promptfoo/evals/activity/basic/eval.yaml +13 -0
  23. package/packages/memory-user-memory/promptfoo/evals/activity/basic/prompt.ts +5 -0
  24. package/packages/memory-user-memory/promptfoo/evals/activity/basic/tests/cases.ts +106 -0
  25. package/packages/memory-user-memory/promptfoo/evals/activity/locomo/buildMessages.ts +104 -0
  26. package/packages/memory-user-memory/promptfoo/evals/activity/locomo/eval.yaml +13 -0
  27. package/packages/memory-user-memory/promptfoo/evals/activity/locomo/prompt.ts +5 -0
  28. package/packages/memory-user-memory/promptfoo/evals/activity/locomo/tests/benchmark-locomo-payload-conv-26.json +149 -0
  29. package/packages/memory-user-memory/promptfoo/evals/activity/locomo/tests/cases.ts +72 -0
  30. package/packages/memory-user-memory/promptfoo/response-formats/activity.json +370 -0
  31. package/packages/memory-user-memory/promptfoo/response-formats/experience.json +14 -0
  32. package/packages/memory-user-memory/promptfoo/response-formats/identity.json +281 -255
  33. package/packages/memory-user-memory/promptfooconfig.yaml +1 -0
  34. package/packages/memory-user-memory/scripts/generate-response-formats.ts +26 -2
  35. package/packages/memory-user-memory/src/extractors/activity.ts +44 -0
  36. package/packages/memory-user-memory/src/extractors/gatekeeper.test.ts +2 -1
  37. package/packages/memory-user-memory/src/extractors/gatekeeper.ts +2 -1
  38. package/packages/memory-user-memory/src/extractors/index.ts +1 -0
  39. package/packages/memory-user-memory/src/prompts/gatekeeper.ts +3 -3
  40. package/packages/memory-user-memory/src/prompts/index.ts +7 -1
  41. package/packages/memory-user-memory/src/prompts/layers/activity.ts +90 -0
  42. package/packages/memory-user-memory/src/prompts/layers/index.ts +1 -0
  43. package/packages/memory-user-memory/src/providers/existingUserMemory.test.ts +25 -1
  44. package/packages/memory-user-memory/src/providers/existingUserMemory.ts +113 -0
  45. package/packages/memory-user-memory/src/schemas/activity.ts +315 -0
  46. package/packages/memory-user-memory/src/schemas/experience.ts +5 -5
  47. package/packages/memory-user-memory/src/schemas/gatekeeper.ts +1 -0
  48. package/packages/memory-user-memory/src/schemas/index.ts +1 -0
  49. package/packages/memory-user-memory/src/services/extractExecutor.ts +29 -0
  50. package/packages/memory-user-memory/src/types.ts +7 -0
  51. package/packages/prompts/src/agents/index.ts +1 -0
  52. package/packages/prompts/src/agents/pageSelectionContext.ts +28 -0
  53. package/packages/types/src/aiChat.ts +4 -0
  54. package/packages/types/src/message/common/index.ts +1 -0
  55. package/packages/types/src/message/common/metadata.ts +8 -0
  56. package/packages/types/src/message/common/pageSelection.ts +36 -0
  57. package/packages/types/src/message/ui/params.ts +16 -0
  58. package/packages/types/src/serverConfig.ts +1 -1
  59. package/packages/types/src/userMemory/layers.ts +52 -0
  60. package/packages/types/src/userMemory/list.ts +20 -2
  61. package/packages/types/src/userMemory/shared.ts +22 -1
  62. package/packages/types/src/userMemory/trace.ts +1 -0
  63. package/packages/types/src/util.ts +9 -1
  64. package/scripts/prebuild.mts +1 -0
  65. package/src/features/ChatInput/Desktop/ContextContainer/ContextList.tsx +1 -1
  66. package/src/features/Conversation/ChatInput/index.tsx +9 -1
  67. package/src/features/Conversation/Messages/User/components/MessageContent.tsx +7 -1
  68. package/src/features/Conversation/Messages/User/components/PageSelections.tsx +62 -0
  69. package/src/features/PageEditor/EditorCanvas/useAskCopilotItem.tsx +5 -1
  70. package/src/libs/next/proxy/define-config.ts +1 -0
  71. package/src/locales/default/chat.ts +3 -2
  72. package/src/server/globalConfig/parseMemoryExtractionConfig.ts +7 -1
  73. package/src/server/routers/lambda/aiChat.ts +7 -0
  74. package/src/server/services/memory/userMemory/__tests__/extract.runtime.test.ts +2 -0
  75. package/src/server/services/memory/userMemory/extract.ts +108 -7
  76. package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +5 -19
@@ -0,0 +1,370 @@
1
+ {
2
+ "json_schema": {
3
+ "name": "activity_extraction",
4
+ "schema": {
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "memories": {
8
+ "description": "Array of extracted activity memories. Use an empty array when no activity should be captured.",
9
+ "items": {
10
+ "additionalProperties": false,
11
+ "description": "Self-contained activity memory describing what happened, when, where, with whom, and how it felt.",
12
+ "examples": [
13
+ {
14
+ "details": "Talked through renewal scope, confirmed timeline flexibility, and captured follow-ups.",
15
+ "memoryCategory": "work",
16
+ "memoryType": "activity",
17
+ "summary": "Client Q2 renewal meeting with Alice (ACME)",
18
+ "tags": [
19
+ "meeting",
20
+ "client",
21
+ "renewal"
22
+ ],
23
+ "title": "ACME Q2 renewal meeting",
24
+ "withActivity": {
25
+ "type": "meeting",
26
+ "associatedLocations": [
27
+ {
28
+ "address": "123 Main St, New York, NY",
29
+ "name": "ACME HQ"
30
+ }
31
+ ],
32
+ "associatedSubjects": [
33
+ {
34
+ "name": "Alice Smith",
35
+ "type": "person"
36
+ }
37
+ ],
38
+ "endsAt": "2024-05-03T15:00:00-04:00",
39
+ "feedback": "Positive momentum; Alice felt heard and open to renewal.",
40
+ "narrative": "Alice and User reviewed Q2 renewal scope, aligned on reduced deliverables, and agreed to share revised pricing next week.",
41
+ "notes": "Agenda: renewal scope, pricing, next steps.",
42
+ "startsAt": "2024-05-03T14:00:00-04:00",
43
+ "status": "completed",
44
+ "timezone": "America/New_York"
45
+ }
46
+ },
47
+ {
48
+ "details": "Routine check-up; discussed migraines and sleep habits.",
49
+ "memoryCategory": "health",
50
+ "memoryType": "activity",
51
+ "summary": "Doctor appointment with Dr. Kim about migraines",
52
+ "tags": [
53
+ "appointment",
54
+ "health"
55
+ ],
56
+ "title": "Neurology follow-up",
57
+ "withActivity": {
58
+ "type": "appointment",
59
+ "associatedLocations": [
60
+ {
61
+ "name": "City Neurology Clinic"
62
+ }
63
+ ],
64
+ "associatedSubjects": [
65
+ {
66
+ "name": "Dr. Kim",
67
+ "type": "person"
68
+ }
69
+ ],
70
+ "feedback": "Felt reassured; plan seems manageable.",
71
+ "narrative": "User saw Dr. Kim to review migraine frequency; decided to track sleep, hydration, and start a low-dose preventive.",
72
+ "notes": "Discussed triggers, hydration, and medication side effects.",
73
+ "status": "completed"
74
+ }
75
+ }
76
+ ],
77
+ "properties": {
78
+ "details": {
79
+ "description": "Optional detailed information or longer notes supporting the summary and narrative.",
80
+ "type": "string"
81
+ },
82
+ "memoryCategory": {
83
+ "description": "Memory category best matching the activity (e.g., work, health, travel, relationships).",
84
+ "type": "string"
85
+ },
86
+ "memoryType": {
87
+ "const": "activity",
88
+ "description": "Memory type; always activity.",
89
+ "type": "string"
90
+ },
91
+ "summary": {
92
+ "description": "Concise overview of this activity.",
93
+ "type": "string"
94
+ },
95
+ "tags": {
96
+ "description": "Model-generated tags summarizing key facets of the activity.",
97
+ "items": {
98
+ "type": "string"
99
+ },
100
+ "type": "array"
101
+ },
102
+ "title": {
103
+ "description": "Brief descriptive title for the activity, e.g., \"Dinner with friends at Marina\".",
104
+ "type": "string"
105
+ },
106
+ "withActivity": {
107
+ "additionalProperties": false,
108
+ "description": "Structured activity fields. Temporal and association values are optional—include only when the user mentioned them.",
109
+ "properties": {
110
+ "type": {
111
+ "description": "Activity type enum. Choose the closest match; fall back to \"other\" when unclear.",
112
+ "enum": [
113
+ "appointment",
114
+ "call",
115
+ "celebration",
116
+ "class",
117
+ "conference",
118
+ "errand",
119
+ "event",
120
+ "exercise",
121
+ "meal",
122
+ "meeting",
123
+ "other",
124
+ "project-session",
125
+ "social",
126
+ "task",
127
+ "trip",
128
+ "workshop"
129
+ ],
130
+ "type": "string"
131
+ },
132
+ "associatedLocations": {
133
+ "description": "Places linked to this activity. Capture any mentioned venue, address, or setting.",
134
+ "items": {
135
+ "additionalProperties": false,
136
+ "properties": {
137
+ "address": {
138
+ "description": "Free-form address or directions if provided.",
139
+ "type": [
140
+ "string",
141
+ "null"
142
+ ]
143
+ },
144
+ "extra": {
145
+ "description": "Optional key-value metadata related to the location.",
146
+ "type": [
147
+ "string",
148
+ "null"
149
+ ]
150
+ },
151
+ "name": {
152
+ "description": "Place name or venue label.",
153
+ "type": "string"
154
+ },
155
+ "tags": {
156
+ "description": "Place-related tags (e.g., indoor, outdoor, virtual).",
157
+ "items": {
158
+ "type": "string"
159
+ },
160
+ "type": [
161
+ "array",
162
+ "null"
163
+ ]
164
+ },
165
+ "type": {
166
+ "description": "Place type or category (office, clinic, restaurant, virtual).",
167
+ "type": "string"
168
+ }
169
+ },
170
+ "required": [
171
+ "type",
172
+ "name",
173
+ "address",
174
+ "tags",
175
+ "extra"
176
+ ],
177
+ "type": "object"
178
+ },
179
+ "type": "array"
180
+ },
181
+ "associatedObjects": {
182
+ "description": "Non-living entities or items tied to the activity (e.g., transportation for trips, devices, tools).",
183
+ "items": {
184
+ "additionalProperties": false,
185
+ "properties": {
186
+ "extra": {
187
+ "description": "Optional key-value metadata related to the object.",
188
+ "type": [
189
+ "string",
190
+ "null"
191
+ ]
192
+ },
193
+ "name": {
194
+ "description": "Name or label of the object (e.g., “MacBook”, “flight UA123”).",
195
+ "type": "string"
196
+ },
197
+ "type": {
198
+ "description": "Object category (e.g., transportation, device, document).",
199
+ "enum": [
200
+ "application",
201
+ "item",
202
+ "knowledge",
203
+ "other",
204
+ "person",
205
+ "place"
206
+ ],
207
+ "type": "string"
208
+ }
209
+ },
210
+ "required": [
211
+ "type",
212
+ "name",
213
+ "extra"
214
+ ],
215
+ "type": "object"
216
+ },
217
+ "type": "array"
218
+ },
219
+ "associatedSubjects": {
220
+ "description": "Living beings involved (people, pets, groups). Use when the subject lacks a known identity ID.",
221
+ "items": {
222
+ "additionalProperties": false,
223
+ "properties": {
224
+ "extra": {
225
+ "description": "Optional key-value metadata related to the subject.",
226
+ "type": [
227
+ "string",
228
+ "null"
229
+ ]
230
+ },
231
+ "name": {
232
+ "description": "Name or short label of the subject.",
233
+ "type": "string"
234
+ },
235
+ "type": {
236
+ "description": "Subject category (e.g., person, pet, group).",
237
+ "enum": [
238
+ "person",
239
+ "pet",
240
+ "group",
241
+ "other"
242
+ ],
243
+ "type": "string"
244
+ }
245
+ },
246
+ "required": [
247
+ "type",
248
+ "name",
249
+ "extra"
250
+ ],
251
+ "type": "object"
252
+ },
253
+ "type": "array"
254
+ },
255
+ "endsAt": {
256
+ "description": "ISO 8601 end time for the activity when specified. Omit if not explicitly provided.",
257
+ "format": "date-time",
258
+ "type": [
259
+ "string",
260
+ "null"
261
+ ]
262
+ },
263
+ "feedback": {
264
+ "description": "Subjective feelings or evaluation of how the activity went (mood, satisfaction, effort).",
265
+ "type": [
266
+ "string",
267
+ "null"
268
+ ]
269
+ },
270
+ "metadata": {
271
+ "additionalProperties": false,
272
+ "description": "Additional structured metadata to keep raw hints (JSON object). Use sparingly.",
273
+ "type": [
274
+ "object",
275
+ "null"
276
+ ]
277
+ },
278
+ "narrative": {
279
+ "description": "Factual story of what happened (chronology, participants, outcomes). Required for recall.",
280
+ "type": "string"
281
+ },
282
+ "notes": {
283
+ "description": "Short annotations such as agenda, preparation, or quick bullets distinct from narrative.",
284
+ "type": [
285
+ "string",
286
+ "null"
287
+ ]
288
+ },
289
+ "startsAt": {
290
+ "description": "ISO 8601 start time for the activity when specified. Omit if not explicitly provided.",
291
+ "format": "date-time",
292
+ "type": [
293
+ "string",
294
+ "null"
295
+ ]
296
+ },
297
+ "status": {
298
+ "description": "Lifecycle status when mentioned. Use planned/completed/cancelled/ongoing/on_hold/pending. Omit if unclear.",
299
+ "enum": [
300
+ "planned",
301
+ "completed",
302
+ "cancelled",
303
+ "ongoing",
304
+ "on_hold",
305
+ "pending"
306
+ ],
307
+ "type": [
308
+ "string",
309
+ "null"
310
+ ]
311
+ },
312
+ "tags": {
313
+ "description": "Optional activity-specific tags or facets.",
314
+ "items": {
315
+ "type": "string"
316
+ },
317
+ "type": [
318
+ "array",
319
+ "null"
320
+ ]
321
+ },
322
+ "timezone": {
323
+ "description": "IANA timezone string for the start/end times when provided (e.g., \"America/New_York\").",
324
+ "type": [
325
+ "string",
326
+ "null"
327
+ ]
328
+ }
329
+ },
330
+ "required": [
331
+ "type",
332
+ "narrative",
333
+ "feedback",
334
+ "notes",
335
+ "associatedLocations",
336
+ "associatedSubjects",
337
+ "associatedObjects",
338
+ "startsAt",
339
+ "endsAt",
340
+ "status",
341
+ "tags",
342
+ "timezone",
343
+ "metadata"
344
+ ],
345
+ "type": "object"
346
+ }
347
+ },
348
+ "required": [
349
+ "title",
350
+ "summary",
351
+ "details",
352
+ "memoryType",
353
+ "memoryCategory",
354
+ "tags",
355
+ "withActivity"
356
+ ],
357
+ "type": "object"
358
+ },
359
+ "type": "array"
360
+ }
361
+ },
362
+ "required": [
363
+ "memories"
364
+ ],
365
+ "type": "object"
366
+ },
367
+ "strict": true
368
+ },
369
+ "type": "json_schema"
370
+ }
@@ -62,6 +62,12 @@
62
62
  "type": "string",
63
63
  "description": "Narrative describing key insights or lessons learned"
64
64
  },
65
+ "knowledgeValueScore": {
66
+ "type": "number",
67
+ "minimum": 0,
68
+ "maximum": 1,
69
+ "description": "Numeric score (0-1) describing how reusable and shareable this experience is"
70
+ },
65
71
  "labels": {
66
72
  "type": "array",
67
73
  "items": {
@@ -73,6 +79,12 @@
73
79
  "type": "string",
74
80
  "description": "Narrative describing potential outcomes or learnings"
75
81
  },
82
+ "problemSolvingScore": {
83
+ "type": "number",
84
+ "minimum": 0,
85
+ "maximum": 1,
86
+ "description": "Numeric score (0-1) describing how effectively the problem was solved"
87
+ },
76
88
  "reasoning": {
77
89
  "type": "string",
78
90
  "description": "Narrative describing the thought process or motivations"
@@ -95,8 +107,10 @@
95
107
  "required": [
96
108
  "action",
97
109
  "keyLearning",
110
+ "knowledgeValueScore",
98
111
  "labels",
99
112
  "possibleOutcome",
113
+ "problemSolvingScore",
100
114
  "reasoning",
101
115
  "scoreConfidence",
102
116
  "situation",