@lobehub/lobehub 2.0.0-next.336 → 2.0.0-next.337

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 (24) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/changelog/v1.json +9 -0
  3. package/package.json +1 -1
  4. package/packages/builtin-tool-agent-builder/src/manifest.ts +0 -2
  5. package/packages/builtin-tool-memory/src/client/Render/AddPreferenceMemory/index.tsx +17 -0
  6. package/packages/builtin-tool-memory/src/client/Render/index.ts +2 -0
  7. package/packages/builtin-tool-memory/src/client/Streaming/AddPreferenceMemory/index.tsx +17 -0
  8. package/packages/builtin-tool-memory/src/client/Streaming/index.ts +4 -3
  9. package/packages/builtin-tool-memory/src/client/components/PreferenceMemoryCard.tsx +357 -0
  10. package/packages/builtin-tool-memory/src/client/components/index.ts +1 -0
  11. package/packages/builtin-tool-memory/src/executor/index.ts +3 -3
  12. package/packages/builtin-tool-memory/src/systemRole.ts +1 -0
  13. package/packages/database/src/models/userMemory/model.ts +1 -1
  14. package/packages/memory-user-memory/src/extractors/context.test.ts +0 -1
  15. package/packages/memory-user-memory/src/extractors/experience.test.ts +0 -1
  16. package/packages/memory-user-memory/src/extractors/identity.test.ts +0 -1
  17. package/packages/memory-user-memory/src/extractors/preference.test.ts +0 -1
  18. package/packages/memory-user-memory/src/schemas/context.ts +0 -2
  19. package/packages/memory-user-memory/src/schemas/experience.ts +0 -2
  20. package/packages/memory-user-memory/src/schemas/identity.ts +1 -2
  21. package/packages/memory-user-memory/src/schemas/preference.ts +0 -2
  22. package/src/server/routers/lambda/userMemories/tools.ts +5 -4
  23. package/src/server/routers/lambda/userMemories.ts +4 -4
  24. package/src/server/services/memory/userMemory/extract.ts +3 -3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.337](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.336...v2.0.0-next.337)
6
+
7
+ <sup>Released on **2026-01-22**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix memory schema, update the agentbuilder tools not always use humanIntervention.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix memory schema, closes [#11645](https://github.com/lobehub/lobe-chat/issues/11645) ([3baf780](https://github.com/lobehub/lobe-chat/commit/3baf780))
21
+ - **misc**: Update the agentbuilder tools not always use humanIntervention, closes [#11696](https://github.com/lobehub/lobe-chat/issues/11696) ([0d3017b](https://github.com/lobehub/lobe-chat/commit/0d3017b))
22
+
23
+ </details>
24
+
25
+ <div align="right">
26
+
27
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
28
+
29
+ </div>
30
+
5
31
  ## [Version 2.0.0-next.336](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.335...v2.0.0-next.336)
6
32
 
7
33
  <sup>Released on **2026-01-22**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Fix memory schema, update the agentbuilder tools not always use humanIntervention."
6
+ ]
7
+ },
8
+ "date": "2026-01-22",
9
+ "version": "2.0.0-next.337"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "features": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.336",
3
+ "version": "2.0.0-next.337",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -27,7 +27,6 @@ export const AgentBuilderManifest: BuiltinToolManifest = {
27
27
  {
28
28
  description:
29
29
  'Search for tools (MCP plugins) in the marketplace. Users can browse and install tools directly from the search results. Use this when users want to find new tools or capabilities.',
30
- humanIntervention: 'always',
31
30
  name: AgentBuilderApiName.searchMarketTools,
32
31
  parameters: {
33
32
  properties: {
@@ -57,7 +56,6 @@ export const AgentBuilderManifest: BuiltinToolManifest = {
57
56
  {
58
57
  description:
59
58
  'Install a plugin for the agent. This tool ALWAYS REQUIRES user approval before installation, even in auto-run mode. For MCP marketplace plugins, it will install and enable the plugin. For Klavis tools and LobehubSkill providers that need OAuth, it will initiate the connection flow and wait for user to complete authorization.',
60
- humanIntervention: 'always',
61
59
  name: AgentBuilderApiName.installPlugin,
62
60
  parameters: {
63
61
  properties: {
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+
3
+ import type { BuiltinRenderProps } from '@lobechat/types';
4
+ import { memo } from 'react';
5
+
6
+ import type { AddPreferenceMemoryParams, AddPreferenceMemoryState } from '../../../types';
7
+ import { PreferenceMemoryCard } from '../../components';
8
+
9
+ const AddPreferenceMemoryRender = memo<
10
+ BuiltinRenderProps<AddPreferenceMemoryParams, AddPreferenceMemoryState>
11
+ >(({ args }) => {
12
+ return <PreferenceMemoryCard data={args} />;
13
+ });
14
+
15
+ AddPreferenceMemoryRender.displayName = 'AddPreferenceMemoryRender';
16
+
17
+ export default AddPreferenceMemoryRender;
@@ -2,6 +2,7 @@ import type { BuiltinRender } from '@lobechat/types';
2
2
 
3
3
  import { MemoryApiName } from '../../types';
4
4
  import AddExperienceMemoryRender from './AddExperienceMemory';
5
+ import AddPreferenceMemoryRender from './AddPreferenceMemory';
5
6
  import SearchUserMemoryRender from './SearchUserMemory';
6
7
 
7
8
  /**
@@ -11,5 +12,6 @@ import SearchUserMemoryRender from './SearchUserMemory';
11
12
  */
12
13
  export const MemoryRenders: Record<string, BuiltinRender> = {
13
14
  [MemoryApiName.addExperienceMemory]: AddExperienceMemoryRender as BuiltinRender,
15
+ [MemoryApiName.addPreferenceMemory]: AddPreferenceMemoryRender as BuiltinRender,
14
16
  [MemoryApiName.searchUserMemory]: SearchUserMemoryRender as BuiltinRender,
15
17
  };
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+
3
+ import type { BuiltinStreamingProps } from '@lobechat/types';
4
+ import { memo } from 'react';
5
+
6
+ import type { AddPreferenceMemoryParams } from '../../../types';
7
+ import { PreferenceMemoryCard } from '../../components';
8
+
9
+ export const AddPreferenceMemoryStreaming = memo<BuiltinStreamingProps<AddPreferenceMemoryParams>>(
10
+ ({ args }) => {
11
+ return <PreferenceMemoryCard data={args} loading />;
12
+ },
13
+ );
14
+
15
+ AddPreferenceMemoryStreaming.displayName = 'AddPreferenceMemoryStreaming';
16
+
17
+ export default AddPreferenceMemoryStreaming;
@@ -2,6 +2,7 @@ import { type BuiltinStreaming } from '@lobechat/types';
2
2
 
3
3
  import { MemoryApiName } from '../../types';
4
4
  import { AddExperienceMemoryStreaming } from './AddExperienceMemory';
5
+ import { AddPreferenceMemoryStreaming } from './AddPreferenceMemory';
5
6
 
6
7
  /**
7
8
  * Memory Streaming Components Registry
@@ -11,8 +12,8 @@ import { AddExperienceMemoryStreaming } from './AddExperienceMemory';
11
12
  */
12
13
  export const MemoryStreamings: Record<string, BuiltinStreaming> = {
13
14
  [MemoryApiName.addExperienceMemory]: AddExperienceMemoryStreaming as BuiltinStreaming,
15
+ [MemoryApiName.addPreferenceMemory]: AddPreferenceMemoryStreaming as BuiltinStreaming,
14
16
  };
15
17
 
16
-
17
-
18
- export {AddExperienceMemoryStreaming} from './AddExperienceMemory';
18
+ export { AddExperienceMemoryStreaming } from './AddExperienceMemory';
19
+ export { AddPreferenceMemoryStreaming } from './AddPreferenceMemory';
@@ -0,0 +1,357 @@
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 { AddPreferenceMemoryParams } 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
+ directive: css`
35
+ font-size: 14px;
36
+ line-height: 1.6;
37
+ color: ${cssVar.colorText};
38
+ `,
39
+ header: css`
40
+ padding-block: 10px;
41
+ padding-inline: 12px;
42
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
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
+ suggestion: css`
64
+ padding-block: 8px;
65
+ padding-inline: 12px;
66
+ border-radius: 8px;
67
+
68
+ font-size: 13px;
69
+ line-height: 1.5;
70
+ color: ${cssVar.colorTextSecondary};
71
+
72
+ background: ${cssVar.colorFillQuaternary};
73
+ `,
74
+ summary: css`
75
+ font-size: 14px;
76
+ font-weight: 500;
77
+ color: ${cssVar.colorTextSecondary};
78
+ `,
79
+ tags: css`
80
+ padding-block-start: 8px;
81
+ border-block-start: 1px dashed ${cssVar.colorBorderSecondary};
82
+ `,
83
+ title: css`
84
+ overflow: hidden;
85
+ display: -webkit-box;
86
+ -webkit-box-orient: vertical;
87
+ -webkit-line-clamp: 1;
88
+
89
+ font-weight: 500;
90
+ color: ${cssVar.colorText};
91
+ `,
92
+ }));
93
+
94
+ export interface PreferenceMemoryCardProps {
95
+ data?: AddPreferenceMemoryParams;
96
+ loading?: boolean;
97
+ }
98
+
99
+ export const PreferenceMemoryCard = memo<PreferenceMemoryCardProps>(({ data, loading }) => {
100
+ const { summary, details, tags, title, withPreference } = data || {};
101
+ const { conclusionDirectives, originContext, appContext, suggestions, type } =
102
+ withPreference || {};
103
+
104
+ const hasContextContent =
105
+ originContext?.actor ||
106
+ originContext?.scenario ||
107
+ originContext?.trigger ||
108
+ originContext?.applicableWhen ||
109
+ originContext?.notApplicableWhen;
110
+
111
+ const hasAppContext = appContext?.app || appContext?.feature || appContext?.surface;
112
+
113
+ const hasSuggestions = suggestions && suggestions.length > 0;
114
+
115
+ if (
116
+ !summary &&
117
+ !details &&
118
+ !tags?.length &&
119
+ !title &&
120
+ !conclusionDirectives &&
121
+ !hasContextContent &&
122
+ !hasSuggestions
123
+ )
124
+ return null;
125
+
126
+ const contextItems = [
127
+ { avatar: '👤', content: originContext?.actor, title: 'Actor' },
128
+ { avatar: '🎯', content: originContext?.scenario, title: 'Scenario' },
129
+ { avatar: '⚡', content: originContext?.trigger, title: 'Trigger' },
130
+ { avatar: '✅', content: originContext?.applicableWhen, title: 'Applicable When' },
131
+ { avatar: '❌', content: originContext?.notApplicableWhen, title: 'Not Applicable When' },
132
+ ].filter((item) => item.content);
133
+
134
+ const appContextItems = [
135
+ { avatar: '📱', content: appContext?.app, title: 'App' },
136
+ { avatar: '🔧', content: appContext?.feature, title: 'Feature' },
137
+ { avatar: '📍', content: appContext?.surface, title: 'Surface' },
138
+ ].filter((item) => item.content);
139
+
140
+ return (
141
+ <Flexbox className={styles.container}>
142
+ {/* Header */}
143
+ <Flexbox align={'center'} className={styles.header} gap={8} horizontal>
144
+ <Flexbox flex={1}>
145
+ <div className={styles.title}>{title || 'Preference Memory'}</div>
146
+ </Flexbox>
147
+ {type && <Tag>{type}</Tag>}
148
+ {loading && <NeuralNetworkLoading size={20} />}
149
+ </Flexbox>
150
+
151
+ {/* When has context content: collapse summary */}
152
+ {hasContextContent || hasAppContext ? (
153
+ <>
154
+ {/* Collapsed Summary */}
155
+ {(summary || tags?.length) && (
156
+ <Accordion gap={0}>
157
+ <AccordionItem
158
+ itemKey="summary"
159
+ paddingBlock={8}
160
+ paddingInline={8}
161
+ styles={{
162
+ base: { marginBlock: 4, marginInline: 4 },
163
+ }}
164
+ title={
165
+ <Text fontSize={12} type={'secondary'} weight={500}>
166
+ Summary
167
+ </Text>
168
+ }
169
+ >
170
+ <Flexbox gap={8} paddingBlock={'8px 12px'} paddingInline={8}>
171
+ {summary && <div className={styles.summary}>{summary}</div>}
172
+ {details && <div className={styles.detail}>{details}</div>}
173
+ {tags && tags.length > 0 && (
174
+ <Flexbox className={styles.tags} gap={8} horizontal wrap={'wrap'}>
175
+ {tags.map((tag, index) => (
176
+ <Tag key={index}>{tag}</Tag>
177
+ ))}
178
+ </Flexbox>
179
+ )}
180
+ </Flexbox>
181
+ </AccordionItem>
182
+ </Accordion>
183
+ )}
184
+
185
+ {/* Origin Context Steps */}
186
+ {hasContextContent && (
187
+ <Accordion className={styles.section} defaultExpandedKeys={['context']} gap={0}>
188
+ <AccordionItem
189
+ itemKey="context"
190
+ paddingBlock={8}
191
+ paddingInline={8}
192
+ title={
193
+ <Text fontSize={12} type={'secondary'} weight={500}>
194
+ Origin Context
195
+ </Text>
196
+ }
197
+ >
198
+ <Flexbox paddingBlock={'8px 12px'} paddingInline={8}>
199
+ <Steps
200
+ className={styles.stepsContainer}
201
+ current={null as any}
202
+ direction="vertical"
203
+ items={contextItems.map((item) => ({
204
+ description: <div className={styles.stepContent}>{item.content}</div>,
205
+ icon: (
206
+ <Avatar
207
+ avatar={item.avatar}
208
+ shadow
209
+ shape={'square'}
210
+ size={20}
211
+ style={{
212
+ border: `1px solid ${cssVar.colorBorderSecondary}`,
213
+ fontSize: 11,
214
+ }}
215
+ />
216
+ ),
217
+ title: (
218
+ <Text as={'span'} fontSize={12} type={'secondary'} weight={500}>
219
+ {item.title}
220
+ </Text>
221
+ ),
222
+ }))}
223
+ size="small"
224
+ />
225
+ </Flexbox>
226
+ </AccordionItem>
227
+ </Accordion>
228
+ )}
229
+
230
+ {/* App Context */}
231
+ {hasAppContext && (
232
+ <Accordion className={styles.section} gap={0}>
233
+ <AccordionItem
234
+ itemKey="appContext"
235
+ paddingBlock={8}
236
+ paddingInline={8}
237
+ title={
238
+ <Text fontSize={12} type={'secondary'} weight={500}>
239
+ App Context
240
+ </Text>
241
+ }
242
+ >
243
+ <Flexbox paddingBlock={'8px 12px'} paddingInline={8}>
244
+ <Steps
245
+ className={styles.stepsContainer}
246
+ current={null as any}
247
+ direction="vertical"
248
+ items={appContextItems.map((item) => ({
249
+ description: <div className={styles.stepContent}>{item.content}</div>,
250
+ icon: (
251
+ <Avatar
252
+ avatar={item.avatar}
253
+ shadow
254
+ shape={'square'}
255
+ size={20}
256
+ style={{
257
+ border: `1px solid ${cssVar.colorBorderSecondary}`,
258
+ fontSize: 11,
259
+ }}
260
+ />
261
+ ),
262
+ title: (
263
+ <Text as={'span'} fontSize={12} type={'secondary'} weight={500}>
264
+ {item.title}
265
+ </Text>
266
+ ),
267
+ }))}
268
+ size="small"
269
+ />
270
+ </Flexbox>
271
+ </AccordionItem>
272
+ </Accordion>
273
+ )}
274
+
275
+ {/* Conclusion Directive */}
276
+ {conclusionDirectives && (
277
+ <Flexbox
278
+ className={styles.section}
279
+ gap={8}
280
+ style={{ paddingBlock: 16, paddingInline: 12 }}
281
+ >
282
+ <Text fontSize={12} weight={500}>
283
+ <span className={highlightTextStyles.primary}>Directive</span>
284
+ </Text>
285
+ <div className={styles.directive}>{conclusionDirectives}</div>
286
+ </Flexbox>
287
+ )}
288
+
289
+ {/* Suggestions */}
290
+ {hasSuggestions && (
291
+ <Flexbox
292
+ className={styles.section}
293
+ gap={8}
294
+ style={{ paddingBlock: 16, paddingInline: 12 }}
295
+ >
296
+ <Text fontSize={12} weight={500}>
297
+ <span className={highlightTextStyles.info}>Suggestions</span>
298
+ </Text>
299
+ <Flexbox gap={8}>
300
+ {suggestions.map((suggestion, index) => (
301
+ <div className={styles.suggestion} key={index}>
302
+ {suggestion}
303
+ </div>
304
+ ))}
305
+ </Flexbox>
306
+ </Flexbox>
307
+ )}
308
+ </>
309
+ ) : (
310
+ /* When no context content: show summary and details */
311
+ <Flexbox className={styles.content} gap={8}>
312
+ {!summary && loading ? (
313
+ <BubblesLoading />
314
+ ) : (
315
+ <>
316
+ {summary && <div className={styles.summary}>{summary}</div>}
317
+ {details && <StreamingMarkdown>{details}</StreamingMarkdown>}
318
+ {conclusionDirectives && (
319
+ <Flexbox gap={4} paddingBlock={8}>
320
+ <Text fontSize={12} weight={500}>
321
+ <span className={highlightTextStyles.primary}>Directive</span>
322
+ </Text>
323
+ <div className={styles.directive}>{conclusionDirectives}</div>
324
+ </Flexbox>
325
+ )}
326
+ {hasSuggestions && (
327
+ <Flexbox gap={8} paddingBlock={8}>
328
+ <Text fontSize={12} weight={500}>
329
+ <span className={highlightTextStyles.info}>Suggestions</span>
330
+ </Text>
331
+ <Flexbox gap={8}>
332
+ {suggestions.map((suggestion, index) => (
333
+ <div className={styles.suggestion} key={index}>
334
+ {suggestion}
335
+ </div>
336
+ ))}
337
+ </Flexbox>
338
+ </Flexbox>
339
+ )}
340
+ {tags && tags.length > 0 && (
341
+ <Flexbox className={styles.tags} gap={8} horizontal wrap={'wrap'}>
342
+ {tags.map((tag, index) => (
343
+ <Tag key={index}>{tag}</Tag>
344
+ ))}
345
+ </Flexbox>
346
+ )}
347
+ </>
348
+ )}
349
+ </Flexbox>
350
+ )}
351
+ </Flexbox>
352
+ );
353
+ });
354
+
355
+ PreferenceMemoryCard.displayName = 'PreferenceMemoryCard';
356
+
357
+ export default PreferenceMemoryCard;
@@ -1 +1,2 @@
1
1
  export { ExperienceMemoryCard, type ExperienceMemoryCardProps } from './ExperienceMemoryCard';
2
+ export { PreferenceMemoryCard, type PreferenceMemoryCardProps } from './PreferenceMemoryCard';
@@ -74,7 +74,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
74
74
  }
75
75
 
76
76
  return {
77
- content: `🧠 Context memory saved: "${params.title}"`,
77
+ content: `Context memory "${params.title}" saved with memoryId: "${result.memoryId}" and contextId: "${result.contextId}"`,
78
78
  state: { contextId: result.contextId, memoryId: result.memoryId },
79
79
  success: true,
80
80
  };
@@ -151,7 +151,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
151
151
  }
152
152
 
153
153
  return {
154
- content: `🧠 Identity memory saved: "${params.title}"`,
154
+ content: `Identity memory "${params.title}" saved with memoryId: "${result.memoryId}" and identityId: "${result.identityId}"`,
155
155
  state: { identityId: result.identityId, memoryId: result.memoryId },
156
156
  success: true,
157
157
  };
@@ -189,7 +189,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
189
189
  }
190
190
 
191
191
  return {
192
- content: `🧠 Preference memory saved: "${params.title}"`,
192
+ content: `Preference memory "${params.title}" saved with memoryId: "${result.memoryId}" and preferenceId: "${result.preferenceId}"`,
193
193
  state: { memoryId: result.memoryId, preferenceId: result.preferenceId },
194
194
  success: true,
195
195
  };
@@ -54,4 +54,5 @@ Conversation language: {{language}}
54
54
  - When memory activity is warranted, explain which layers are affected, cite any matching memories you found, and justify why extraction or updates are needed.
55
55
  - When nothing qualifies, explicitly state that no memory action is required after reviewing the context.
56
56
  - Keep your reasoning concise, structured, and aligned with the conversation language.
57
+ - **Never expose internal memory IDs** (e.g., mem_xxx, id: xxx) to users in your responses. Refer to memories by their descriptive titles or summaries instead.
57
58
  </response_expectations>`;
@@ -86,7 +86,7 @@ export interface BaseCreateUserMemoryParams {
86
86
  details: string;
87
87
  detailsEmbedding?: number[];
88
88
  memoryCategory: string;
89
- memoryLayer: LayersEnum;
89
+ memoryLayer?: LayersEnum;
90
90
  memoryType: TypesEnum;
91
91
  summary: string;
92
92
  summaryEmbedding?: number[];
@@ -39,7 +39,6 @@ describe('ContextExtractor', () => {
39
39
  const memoryItem = memories.items;
40
40
 
41
41
  expect(memories.type).toBe('array');
42
- expect(memoryItem.properties.memoryLayer.const).toBe('context');
43
42
  // memoryCategory is a plain string in schema, not an enum
44
43
  expect(memoryItem.properties.memoryCategory.type).toBe('string');
45
44
  expect(memoryItem.properties.memoryType.enum).toEqual(memoryTypeValues);
@@ -39,7 +39,6 @@ describe('ExperienceExtractor', () => {
39
39
  const memoryItem = memories.items;
40
40
 
41
41
  expect(memories.type).toBe('array');
42
- expect(memoryItem.properties.memoryLayer.const).toBe('experience');
43
42
  // memoryCategory is a plain string in schema, not an enum
44
43
  expect(memoryItem.properties.memoryCategory.type).toBe('string');
45
44
  expect(memoryItem.properties.memoryType.enum).toEqual(memoryTypeValues);
@@ -46,7 +46,6 @@ describe('IdentityExtractor', () => {
46
46
  {
47
47
  details: null,
48
48
  memoryCategory: 'personal',
49
- memoryLayer: 'identity',
50
49
  memoryType: 'fact',
51
50
  summary: 'New identity summary',
52
51
  tags: ['tag'],
@@ -39,7 +39,6 @@ describe('PreferenceExtractor', () => {
39
39
  const memoryItem = memories.items;
40
40
 
41
41
  expect(memories.type).toBe('array');
42
- expect(memoryItem.properties.memoryLayer.const).toBe('preference');
43
42
  // memoryCategory is a plain string in schema, not an enum
44
43
  expect(memoryItem.properties.memoryCategory.type).toBe('string');
45
44
  expect(memoryItem.properties.memoryType.enum).toEqual(memoryTypeValues);
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  ContextStatusEnum,
3
- LayersEnum,
4
3
  UserMemoryContextObjectType,
5
4
  UserMemoryContextSubjectType,
6
5
  } from '@lobechat/types';
@@ -79,7 +78,6 @@ export const WithContextSchema = z.object({
79
78
  export const ContextMemoryItemSchema = z.object({
80
79
  details: z.string().describe('Optional detailed information'),
81
80
  memoryCategory: z.string().describe('Memory category'),
82
- memoryLayer: z.literal(LayersEnum.Context).describe('Memory layer'),
83
81
  memoryType: MemoryTypeSchema.describe('Memory type'),
84
82
  summary: z.string().describe('Concise overview of this specific memory'),
85
83
  tags: z.array(z.string()).describe('User defined tags that summarize the context facets'),
@@ -1,4 +1,3 @@
1
- import { LayersEnum } from '@lobechat/types';
2
1
  import { z } from 'zod';
3
2
 
4
3
  import { MemoryTypeSchema } from './common';
@@ -37,7 +36,6 @@ export const WithExperienceSchema = z.object({
37
36
  export const ExperienceMemoryItemSchema = z.object({
38
37
  details: z.string().describe('Optional detailed information'),
39
38
  memoryCategory: z.string().describe('Memory category'),
40
- memoryLayer: z.literal(LayersEnum.Experience).describe('Memory layer'),
41
39
  memoryType: MemoryTypeSchema.describe('Memory type'),
42
40
  summary: z.string().describe('Concise overview of this specific memory'),
43
41
  tags: z.array(z.string()).describe('Model generated tags that summarize the experience facets'),
@@ -1,4 +1,4 @@
1
- import { LayersEnum, MergeStrategyEnum } from '@lobechat/types';
1
+ import { MergeStrategyEnum } from '@lobechat/types';
2
2
  import { z } from 'zod';
3
3
 
4
4
  import { MemoryTypeSchema } from './common';
@@ -43,7 +43,6 @@ export const AddIdentityActionSchema = z
43
43
  .object({
44
44
  details: z.union([z.string(), z.null()]).describe('Optional detailed information'),
45
45
  memoryCategory: z.string().describe('Memory category'),
46
- memoryLayer: z.literal(LayersEnum.Identity).describe('Memory layer'),
47
46
  memoryType: MemoryTypeSchema.describe('Memory type'),
48
47
  summary: z.string().describe('Concise overview of this specific memory'),
49
48
  tags: z.array(z.string()).describe('Model generated tags that summarize the identity facets'),
@@ -1,4 +1,3 @@
1
- import { LayersEnum } from '@lobechat/types';
2
1
  import { z } from 'zod';
3
2
 
4
3
  import { MemoryTypeSchema } from './common';
@@ -66,7 +65,6 @@ export const WithPreferenceSchema = z.object({
66
65
  export const PreferenceMemoryItemSchema = z.object({
67
66
  details: z.string().describe('Optional detailed information'),
68
67
  memoryCategory: z.string().describe('Memory category'),
69
- memoryLayer: z.literal(LayersEnum.Preference).describe('Memory layer'),
70
68
  memoryType: MemoryTypeSchema.describe('Memory type'),
71
69
  summary: z.string().describe('Concise overview of this specific memory'),
72
70
  tags: z.array(z.string()).describe('Model generated tags that summarize the preference facets'),
@@ -6,6 +6,7 @@ import {
6
6
  RemoveIdentityActionSchema,
7
7
  UpdateIdentityActionSchema,
8
8
  } from '@lobechat/memory-user-memory';
9
+ import { LayersEnum } from '@lobechat/types';
9
10
 
10
11
  import {
11
12
  type IdentityEntryBasePayload,
@@ -51,7 +52,7 @@ export const toolsRouter = router({
51
52
  details: input.details || '',
52
53
  detailsEmbedding,
53
54
  memoryCategory: input.memoryCategory,
54
- memoryLayer: input.memoryLayer,
55
+ memoryLayer: LayersEnum.Context,
55
56
  memoryType: input.memoryType,
56
57
  summary: input.summary,
57
58
  summaryEmbedding,
@@ -107,7 +108,7 @@ export const toolsRouter = router({
107
108
  type: input.memoryType,
108
109
  },
109
110
  memoryCategory: input.memoryCategory,
110
- memoryLayer: input.memoryLayer,
111
+ memoryLayer: LayersEnum.Experience,
111
112
  memoryType: input.memoryType,
112
113
  summary: input.summary,
113
114
  summaryEmbedding,
@@ -162,7 +163,7 @@ export const toolsRouter = router({
162
163
  details: input.details,
163
164
  detailsVector1024: detailsEmbedding ?? null,
164
165
  memoryCategory: input.memoryCategory,
165
- memoryLayer: input.memoryLayer,
166
+ memoryLayer: LayersEnum.Identity,
166
167
  memoryType: input.memoryType,
167
168
  metadata: Object.keys(identityMetadata).length > 0 ? identityMetadata : undefined,
168
169
  summary: input.summary,
@@ -226,7 +227,7 @@ export const toolsRouter = router({
226
227
  details: input.details || '',
227
228
  detailsEmbedding,
228
229
  memoryCategory: input.memoryCategory,
229
- memoryLayer: input.memoryLayer,
230
+ memoryLayer: LayersEnum.Preference,
230
231
  memoryType: input.memoryType,
231
232
  preference: {
232
233
  conclusionDirectives: input.withPreference.conclusionDirectives || '',
@@ -774,7 +774,7 @@ export const userMemoriesRouter = router({
774
774
  details: input.details || '',
775
775
  detailsEmbedding,
776
776
  memoryCategory: input.memoryCategory,
777
- memoryLayer: input.memoryLayer,
777
+ memoryLayer: LayersEnum.Context,
778
778
  memoryType: input.memoryType,
779
779
  summary: input.summary,
780
780
  summaryEmbedding,
@@ -830,7 +830,7 @@ export const userMemoriesRouter = router({
830
830
  type: input.memoryType,
831
831
  },
832
832
  memoryCategory: input.memoryCategory,
833
- memoryLayer: input.memoryLayer,
833
+ memoryLayer: LayersEnum.Experience,
834
834
  memoryType: input.memoryType,
835
835
  summary: input.summary,
836
836
  summaryEmbedding,
@@ -885,7 +885,7 @@ export const userMemoriesRouter = router({
885
885
  details: input.details,
886
886
  detailsVector1024: detailsEmbedding ?? null,
887
887
  memoryCategory: input.memoryCategory,
888
- memoryLayer: input.memoryLayer,
888
+ memoryLayer: LayersEnum.Identity,
889
889
  memoryType: input.memoryType,
890
890
  metadata: Object.keys(identityMetadata).length > 0 ? identityMetadata : undefined,
891
891
  summary: input.summary,
@@ -949,7 +949,7 @@ export const userMemoriesRouter = router({
949
949
  details: input.details || '',
950
950
  detailsEmbedding,
951
951
  memoryCategory: input.memoryCategory,
952
- memoryLayer: input.memoryLayer,
952
+ memoryLayer: LayersEnum.Preference,
953
953
  memoryType: input.memoryType,
954
954
  preference: {
955
955
  conclusionDirectives: input.withPreference.conclusionDirectives || '',
@@ -618,7 +618,7 @@ export class MemoryExtractionExecutor {
618
618
  details: item.details ?? '',
619
619
  detailsEmbedding: detailsVector ?? undefined,
620
620
  memoryCategory: item.memoryCategory ?? null,
621
- memoryLayer: (item.memoryLayer as LayersEnum) ?? LayersEnum.Context,
621
+ memoryLayer: LayersEnum.Context,
622
622
  memoryType: (item.memoryType as TypesEnum) ?? TypesEnum.Context,
623
623
  summary: item.summary ?? '',
624
624
  summaryEmbedding: summaryVector ?? undefined,
@@ -684,7 +684,7 @@ export class MemoryExtractionExecutor {
684
684
  type: item.withExperience?.type ?? null,
685
685
  },
686
686
  memoryCategory: item.memoryCategory ?? null,
687
- memoryLayer: (item.memoryLayer as LayersEnum) ?? LayersEnum.Experience,
687
+ memoryLayer: LayersEnum.Experience,
688
688
  memoryType: (item.memoryType as TypesEnum) ?? TypesEnum.Activity,
689
689
  summary: item.summary ?? '',
690
690
  summaryEmbedding: summaryVector ?? undefined,
@@ -728,7 +728,7 @@ export class MemoryExtractionExecutor {
728
728
  details: item.details ?? '',
729
729
  detailsEmbedding: detailsVector ?? undefined,
730
730
  memoryCategory: item.memoryCategory ?? null,
731
- memoryLayer: (item.memoryLayer as LayersEnum) ?? LayersEnum.Preference,
731
+ memoryLayer: LayersEnum.Preference,
732
732
  memoryType: (item.memoryType as TypesEnum) ?? TypesEnum.Preference,
733
733
  preference: {
734
734
  capturedAt: job.sourceUpdatedAt,