@lobehub/lobehub 2.0.0-next.190 → 2.0.0-next.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/packages/const/src/utils/merge.test.ts +679 -0
- package/packages/context-engine/src/processors/__tests__/AgentCouncilFlatten.test.ts +0 -20
- package/packages/context-engine/src/processors/__tests__/MessageContent.test.ts +5 -23
- package/packages/context-engine/src/providers/SystemRoleInjector.ts +0 -1
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentCouncil/simple.json +4 -19
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentCouncil/with-supervisor-reply.json +4 -23
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentGroup/speak-different-agent.json +3 -13
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistant-chain-with-followup.json +3 -8
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistantGroup/assistant-with-tools.json +21 -17
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistantGroup/tools-with-branches.json +15 -15
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/active-index-1.json +3 -13
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-branch.json +2 -9
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-group-branches.json +0 -11
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-user-branch.json +5 -15
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/conversation.json +4 -14
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/multi-assistant-group.json +0 -13
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/nested.json +2 -15
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/simple.json +4 -9
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/with-tools.json +8 -17
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/linear-conversation.json +3 -7
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/simple.json +1 -7
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/with-summary.json +10 -11
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/agentCouncil/simple.json +2 -32
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/agentCouncil/with-supervisor-reply.json +8 -46
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/agentGroup/speak-different-agent.json +5 -24
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistant-chain-with-followup.json +5 -13
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/assistant-with-tools.json +6 -16
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/tools-with-branches.json +6 -17
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/active-index-1.json +4 -18
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-branch.json +4 -16
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-group-branches.json +0 -19
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-user-branch.json +8 -24
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/conversation.json +7 -23
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/multi-assistant-group.json +0 -15
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/nested.json +4 -25
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/simple.json +2 -13
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/with-tools.json +4 -20
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/linear-conversation.json +4 -12
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/simple.json +2 -14
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/with-summary.json +20 -22
- package/packages/conversation-flow/src/__tests__/indexing.test.ts +0 -35
- package/packages/conversation-flow/src/__tests__/structuring.test.ts +0 -41
- package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +0 -4
- package/packages/conversation-flow/src/transformation/__tests__/BranchResolver.test.ts +0 -10
- package/packages/conversation-flow/src/transformation/__tests__/ContextTreeBuilder.test.ts +0 -19
- package/packages/conversation-flow/src/transformation/__tests__/FlatListBuilder.test.ts +0 -37
- package/packages/conversation-flow/src/transformation/__tests__/MessageCollector.test.ts +0 -12
- package/packages/conversation-flow/src/transformation/__tests__/MessageTransformer.test.ts +0 -2
- package/packages/database/src/models/message.ts +0 -1
- package/packages/prompts/src/prompts/chatMessages/index.test.ts +0 -1
- package/packages/prompts/src/prompts/groupChat/__snapshots__/index.test.ts.snap +0 -21
- package/packages/prompts/src/prompts/groupChat/index.test.ts +0 -3
- package/packages/types/src/message/ui/chat.ts +0 -2
- package/src/features/Conversation/store/slices/data/action.test.ts +0 -14
- package/src/features/Conversation/store/slices/data/reducer.test.ts +0 -21
- package/src/features/Conversation/store/slices/data/reducer.ts +1 -1
- package/src/features/Conversation/store/slices/message/action/crud.test.ts +0 -10
- package/src/server/modules/Mecha/ContextEngineering/__tests__/serverMessagesEngine.test.ts +3 -5
- package/src/server/routers/lambda/__tests__/message.test.ts +1 -2
- package/src/server/services/agentRuntime/AgentRuntimeService.ts +109 -109
- package/src/server/services/agentRuntime/types.ts +8 -8
- package/src/server/services/doc/index.tsx +2 -2
- package/src/server/services/generation/index.ts +2 -2
- package/src/server/services/message/index.ts +3 -3
- package/src/server/services/usage/index.ts +4 -4
- package/src/services/chat/chat.test.ts +0 -6
- package/src/services/chat/mecha/contextEngineering.test.ts +3 -29
- package/src/services/chat/mecha/modelParamsResolver.test.ts +803 -0
- package/src/store/chat/agents/GroupOrchestration/createGroupOrchestrationExecutors.ts +0 -2
- package/src/store/chat/agents/__tests__/createAgentExecutors/call-tool.test.ts +0 -6
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockMessages.ts +0 -3
- package/src/store/chat/agents/createAgentExecutors.ts +4 -4
- package/src/store/chat/slices/aiAgent/actions/__tests__/agentGroup.test.ts +0 -2
- package/src/store/chat/slices/aiAgent/actions/__tests__/runAgent.test.ts +0 -3
- package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +0 -1
- package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +0 -4
- package/src/store/chat/slices/message/reducer.test.ts +0 -5
- package/src/store/chat/slices/message/reducer.ts +1 -1
- package/src/store/chat/slices/message/selectors/displayMessage.test.ts +0 -13
- package/src/store/chat/slices/message/selectors/displayMessage.ts +3 -34
- package/src/store/chat/slices/portal/selectors.test.ts +0 -7
- package/src/store/chat/slices/thread/action.test.ts +0 -1
- package/src/store/chat/slices/translate/action.test.ts +0 -1
- package/src/store/tool/slices/oldStore/action.test.ts +0 -1
|
@@ -198,7 +198,6 @@ export const createGroupOrchestrationExecutors = (
|
|
|
198
198
|
content: agentInstruction,
|
|
199
199
|
createdAt: now,
|
|
200
200
|
id: `virtual_speak_instruction_${now}`,
|
|
201
|
-
meta: {},
|
|
202
201
|
role: 'user',
|
|
203
202
|
updatedAt: now,
|
|
204
203
|
},
|
|
@@ -275,7 +274,6 @@ export const createGroupOrchestrationExecutors = (
|
|
|
275
274
|
content: agentInstruction,
|
|
276
275
|
createdAt: now,
|
|
277
276
|
id: `virtual_broadcast_instruction_${now}`,
|
|
278
|
-
meta: {},
|
|
279
277
|
role: 'user',
|
|
280
278
|
updatedAt: now,
|
|
281
279
|
},
|
|
@@ -294,7 +294,6 @@ describe('call_tool executor', () => {
|
|
|
294
294
|
content: '',
|
|
295
295
|
pluginIntervention: { status: 'pending' },
|
|
296
296
|
createdAt: Date.now(),
|
|
297
|
-
meta: {},
|
|
298
297
|
updatedAt: Date.now(),
|
|
299
298
|
};
|
|
300
299
|
mockStore.dbMessagesMap[context.messageKey] = [assistantMessage, existingToolMessage as any];
|
|
@@ -342,7 +341,6 @@ describe('call_tool executor', () => {
|
|
|
342
341
|
role: 'tool',
|
|
343
342
|
content: '',
|
|
344
343
|
createdAt: Date.now(),
|
|
345
|
-
meta: {},
|
|
346
344
|
updatedAt: Date.now(),
|
|
347
345
|
};
|
|
348
346
|
mockStore.dbMessagesMap[context.messageKey] = [assistantMessage, existingToolMessage as any];
|
|
@@ -1297,7 +1295,6 @@ describe('call_tool executor', () => {
|
|
|
1297
1295
|
role: 'tool',
|
|
1298
1296
|
content: '',
|
|
1299
1297
|
createdAt: Date.now(),
|
|
1300
|
-
meta: {},
|
|
1301
1298
|
updatedAt: Date.now(),
|
|
1302
1299
|
} as any,
|
|
1303
1300
|
];
|
|
@@ -1757,7 +1754,6 @@ describe('call_tool executor', () => {
|
|
|
1757
1754
|
role: 'user',
|
|
1758
1755
|
content: 'Hello',
|
|
1759
1756
|
createdAt: Date.now(),
|
|
1760
|
-
meta: {},
|
|
1761
1757
|
updatedAt: Date.now(),
|
|
1762
1758
|
} as any,
|
|
1763
1759
|
{
|
|
@@ -1766,7 +1762,6 @@ describe('call_tool executor', () => {
|
|
|
1766
1762
|
content: 'Hi',
|
|
1767
1763
|
groupId: 'group_old',
|
|
1768
1764
|
createdAt: Date.now(),
|
|
1769
|
-
meta: {},
|
|
1770
1765
|
updatedAt: Date.now(),
|
|
1771
1766
|
} as any,
|
|
1772
1767
|
{
|
|
@@ -1774,7 +1769,6 @@ describe('call_tool executor', () => {
|
|
|
1774
1769
|
role: 'user',
|
|
1775
1770
|
content: 'Question',
|
|
1776
1771
|
createdAt: Date.now(),
|
|
1777
|
-
meta: {},
|
|
1778
1772
|
updatedAt: Date.now(),
|
|
1779
1773
|
} as any,
|
|
1780
1774
|
createAssistantMessage({ groupId: 'group_latest' }),
|
|
@@ -9,7 +9,6 @@ export const createAssistantMessage = (overrides: Partial<UIChatMessage> = {}):
|
|
|
9
9
|
content: 'I am an AI assistant.',
|
|
10
10
|
createdAt: Date.now(),
|
|
11
11
|
id: `msg_${nanoid()}`,
|
|
12
|
-
meta: {},
|
|
13
12
|
model: 'gpt-4',
|
|
14
13
|
provider: 'openai',
|
|
15
14
|
role: 'assistant',
|
|
@@ -26,7 +25,6 @@ export const createUserMessage = (overrides: Partial<UIChatMessage> = {}): UICha
|
|
|
26
25
|
content: 'Hello, AI!',
|
|
27
26
|
createdAt: Date.now(),
|
|
28
27
|
id: `msg_${nanoid()}`,
|
|
29
|
-
meta: {},
|
|
30
28
|
role: 'user',
|
|
31
29
|
updatedAt: Date.now(),
|
|
32
30
|
...overrides,
|
|
@@ -41,7 +39,6 @@ export const createToolMessage = (overrides: Partial<UIChatMessage> = {}): UICha
|
|
|
41
39
|
content: '',
|
|
42
40
|
createdAt: Date.now(),
|
|
43
41
|
id: `msg_${nanoid()}`,
|
|
44
|
-
meta: {},
|
|
45
42
|
plugin: {
|
|
46
43
|
apiName: 'search',
|
|
47
44
|
arguments: JSON.stringify({ query: 'test' }),
|
|
@@ -91,7 +91,7 @@ export const createAgentExecutors = (context: {
|
|
|
91
91
|
let assistantMessageId: string;
|
|
92
92
|
|
|
93
93
|
if (shouldSkipCreateMessage) {
|
|
94
|
-
//
|
|
94
|
+
// Skip first creation, subsequent calls will not skip
|
|
95
95
|
assistantMessageId = context.parentId;
|
|
96
96
|
shouldSkipCreateMessage = false;
|
|
97
97
|
} else {
|
|
@@ -100,9 +100,9 @@ export const createAgentExecutors = (context: {
|
|
|
100
100
|
// Get effective agentId (subAgentId for group orchestration, agentId otherwise)
|
|
101
101
|
const effectiveAgentId = getEffectiveAgentId();
|
|
102
102
|
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
// TODO:
|
|
103
|
+
// If this is the first regenerated creation of userMessage, llmPayload doesn't have parentMessageId
|
|
104
|
+
// So we assign it this way
|
|
105
|
+
// TODO: Maybe this should be implemented with an init method in the future
|
|
106
106
|
if (!llmPayload.parentMessageId) {
|
|
107
107
|
llmPayload.parentMessageId = context.parentId;
|
|
108
108
|
}
|
|
@@ -89,7 +89,6 @@ const createMockExecGroupAgentResponse = (overrides = {}) => ({
|
|
|
89
89
|
content: TEST_CONTENT.GROUP_MESSAGE,
|
|
90
90
|
createdAt: Date.now(),
|
|
91
91
|
updatedAt: Date.now(),
|
|
92
|
-
meta: {},
|
|
93
92
|
},
|
|
94
93
|
{
|
|
95
94
|
id: TEST_IDS.ASSISTANT_MESSAGE_ID,
|
|
@@ -97,7 +96,6 @@ const createMockExecGroupAgentResponse = (overrides = {}) => ({
|
|
|
97
96
|
content: '',
|
|
98
97
|
createdAt: Date.now(),
|
|
99
98
|
updatedAt: Date.now(),
|
|
100
|
-
meta: {},
|
|
101
99
|
},
|
|
102
100
|
],
|
|
103
101
|
topics: {
|
|
@@ -49,7 +49,6 @@ const createStreamStartEvent = (overrides = {}): StreamEvent => ({
|
|
|
49
49
|
content: '',
|
|
50
50
|
createdAt: Date.now(),
|
|
51
51
|
updatedAt: Date.now(),
|
|
52
|
-
meta: {},
|
|
53
52
|
},
|
|
54
53
|
},
|
|
55
54
|
...overrides,
|
|
@@ -170,7 +169,6 @@ describe('runAgent actions', () => {
|
|
|
170
169
|
content: '',
|
|
171
170
|
createdAt: Date.now(),
|
|
172
171
|
updatedAt: Date.now(),
|
|
173
|
-
meta: {},
|
|
174
172
|
},
|
|
175
173
|
},
|
|
176
174
|
});
|
|
@@ -203,7 +201,6 @@ describe('runAgent actions', () => {
|
|
|
203
201
|
content: '',
|
|
204
202
|
createdAt: Date.now(),
|
|
205
203
|
updatedAt: Date.now(),
|
|
206
|
-
meta: {},
|
|
207
204
|
},
|
|
208
205
|
},
|
|
209
206
|
});
|
|
@@ -62,7 +62,6 @@ describe('search actions', () => {
|
|
|
62
62
|
content: '',
|
|
63
63
|
createdAt: Date.now(),
|
|
64
64
|
updatedAt: Date.now(),
|
|
65
|
-
meta: {},
|
|
66
65
|
};
|
|
67
66
|
|
|
68
67
|
vi.spyOn(dbMessageSelectors, 'getDbMessageById').mockImplementation(
|
|
@@ -116,7 +115,6 @@ describe('search actions', () => {
|
|
|
116
115
|
content: '',
|
|
117
116
|
createdAt: Date.now(),
|
|
118
117
|
updatedAt: Date.now(),
|
|
119
|
-
meta: {},
|
|
120
118
|
};
|
|
121
119
|
|
|
122
120
|
vi.spyOn(dbMessageSelectors, 'getDbMessageById').mockImplementation(
|
|
@@ -195,7 +193,6 @@ describe('search actions', () => {
|
|
|
195
193
|
role: 'assistant',
|
|
196
194
|
createdAt: Date.now(),
|
|
197
195
|
updatedAt: Date.now(),
|
|
198
|
-
meta: {},
|
|
199
196
|
};
|
|
200
197
|
|
|
201
198
|
vi.spyOn(dbMessageSelectors, 'getDbMessageById').mockImplementation(
|
|
@@ -284,7 +281,6 @@ describe('search actions', () => {
|
|
|
284
281
|
role: 'tool',
|
|
285
282
|
createdAt: Date.now(),
|
|
286
283
|
updatedAt: Date.now(),
|
|
287
|
-
meta: {},
|
|
288
284
|
};
|
|
289
285
|
|
|
290
286
|
vi.spyOn(dbMessageSelectors, 'getDbMessageById').mockImplementation(
|
|
@@ -14,7 +14,6 @@ describe('messagesReducer', () => {
|
|
|
14
14
|
createdAt: 1629264000000,
|
|
15
15
|
updatedAt: 1629264000000,
|
|
16
16
|
role: 'user',
|
|
17
|
-
meta: {},
|
|
18
17
|
},
|
|
19
18
|
{
|
|
20
19
|
id: 'message2',
|
|
@@ -22,7 +21,6 @@ describe('messagesReducer', () => {
|
|
|
22
21
|
createdAt: 1629264000000,
|
|
23
22
|
updatedAt: 1629264000000,
|
|
24
23
|
role: 'assistant',
|
|
25
|
-
meta: {},
|
|
26
24
|
tools: [
|
|
27
25
|
{ identifier: 'tool1', apiName: 'calculator', id: 'abc', type: 'default', arguments: '' },
|
|
28
26
|
],
|
|
@@ -102,7 +100,6 @@ describe('messagesReducer', () => {
|
|
|
102
100
|
createdAt: 1629264000000,
|
|
103
101
|
updatedAt: 1629264000000,
|
|
104
102
|
role: 'user',
|
|
105
|
-
meta: {},
|
|
106
103
|
extra: { abc: '1' },
|
|
107
104
|
} as UIChatMessage,
|
|
108
105
|
...initialState,
|
|
@@ -232,7 +229,6 @@ describe('messagesReducer', () => {
|
|
|
232
229
|
content: 'Tool content',
|
|
233
230
|
createdAt: 1629264000000,
|
|
234
231
|
updatedAt: 1629264000000,
|
|
235
|
-
meta: {},
|
|
236
232
|
plugin: {
|
|
237
233
|
identifier: 'tool1',
|
|
238
234
|
apiName: 'calculator',
|
|
@@ -487,7 +483,6 @@ describe('messagesReducer', () => {
|
|
|
487
483
|
expect(newMessage?.role).toBe('user');
|
|
488
484
|
expect(newMessage?.createdAt).toBeDefined();
|
|
489
485
|
expect(newMessage?.updatedAt).toBeDefined();
|
|
490
|
-
expect(newMessage?.meta).toEqual({});
|
|
491
486
|
});
|
|
492
487
|
});
|
|
493
488
|
|
|
@@ -221,7 +221,7 @@ export const messagesReducer = (
|
|
|
221
221
|
return produce(state, (draftState) => {
|
|
222
222
|
const { value, id } = payload;
|
|
223
223
|
|
|
224
|
-
draftState.push({ ...value, createdAt: Date.now(), id,
|
|
224
|
+
draftState.push({ ...value, createdAt: Date.now(), id, updatedAt: Date.now() });
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -73,28 +73,16 @@ const mockedChats = [
|
|
|
73
73
|
id: 'msg1',
|
|
74
74
|
content: 'Hello World',
|
|
75
75
|
role: 'user',
|
|
76
|
-
meta: {
|
|
77
|
-
avatar: '😀',
|
|
78
|
-
},
|
|
79
76
|
},
|
|
80
77
|
{
|
|
81
78
|
id: 'msg2',
|
|
82
79
|
content: 'Goodbye World',
|
|
83
80
|
role: 'user',
|
|
84
|
-
meta: {
|
|
85
|
-
avatar: '😀',
|
|
86
|
-
},
|
|
87
81
|
},
|
|
88
82
|
{
|
|
89
83
|
id: 'msg3',
|
|
90
84
|
content: 'Function Message',
|
|
91
85
|
role: 'tool',
|
|
92
|
-
meta: {
|
|
93
|
-
avatar: DEFAULT_INBOX_AVATAR,
|
|
94
|
-
backgroundColor: 'rgba(0,0,0,0)',
|
|
95
|
-
description: 'inbox.desc',
|
|
96
|
-
title: 'inbox.title',
|
|
97
|
-
},
|
|
98
86
|
tools: [
|
|
99
87
|
{
|
|
100
88
|
arguments: ['arg1', 'arg2'],
|
|
@@ -359,7 +347,6 @@ describe('displayMessageSelectors', () => {
|
|
|
359
347
|
const chats = displayMessageSelectors.activeDisplayMessages(state);
|
|
360
348
|
expect(chats).toHaveLength(1);
|
|
361
349
|
expect(chats[0].id).toBe('msg1');
|
|
362
|
-
expect(chats[0].meta).toBeDefined();
|
|
363
350
|
});
|
|
364
351
|
});
|
|
365
352
|
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { type AssistantContentBlock, type UIChatMessage } from '@lobechat/types';
|
|
2
2
|
|
|
3
|
-
import { DEFAULT_USER_AVATAR } from '@/const/meta';
|
|
4
3
|
import { INBOX_SESSION_ID } from '@/const/session';
|
|
5
4
|
import { useAgentStore } from '@/store/agent';
|
|
6
|
-
import { agentChatConfigSelectors
|
|
7
|
-
import { useUserStore } from '@/store/user';
|
|
8
|
-
import { userProfileSelectors } from '@/store/user/selectors';
|
|
5
|
+
import { agentChatConfigSelectors } from '@/store/agent/selectors';
|
|
9
6
|
|
|
10
7
|
import { chatHelpers } from '../../../helpers';
|
|
11
8
|
import type { ChatStoreState } from '../../../initialState';
|
|
@@ -18,38 +15,11 @@ import { messageMapKey } from '../../../utils/messageMapKey';
|
|
|
18
15
|
* Use these selectors when you need to:
|
|
19
16
|
* - Render messages in UI components
|
|
20
17
|
* - Display assistantGroup messages with children
|
|
21
|
-
* - Show messages with proper meta information
|
|
22
18
|
* - Present message history with filters
|
|
23
19
|
*
|
|
24
20
|
* DO NOT use these for data mutations - use dbMessage.ts selectors instead.
|
|
25
21
|
*/
|
|
26
22
|
|
|
27
|
-
// ============= Meta Information ========== //
|
|
28
|
-
|
|
29
|
-
const getMeta = (message: UIChatMessage) => {
|
|
30
|
-
switch (message.role) {
|
|
31
|
-
case 'user': {
|
|
32
|
-
return {
|
|
33
|
-
avatar: userProfileSelectors.userAvatar(useUserStore.getState()) || DEFAULT_USER_AVATAR,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
case 'system': {
|
|
38
|
-
return message.meta;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
default: {
|
|
42
|
-
// For group chat, get meta from agent store by agentId
|
|
43
|
-
if (message.groupId && message.agentId) {
|
|
44
|
-
return agentSelectors.getAgentMetaById(message.agentId)(useAgentStore.getState());
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Otherwise, use the current agent's meta for single agent chat
|
|
48
|
-
return agentSelectors.currentAgentMeta(useAgentStore.getState());
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
23
|
// ============= Basic Display Message Access ========== //
|
|
54
24
|
|
|
55
25
|
/**
|
|
@@ -59,13 +29,12 @@ export const currentDisplayChatKey = (s: ChatStoreState) =>
|
|
|
59
29
|
messageMapKey({ agentId: s.activeAgentId, topicId: s.activeTopicId });
|
|
60
30
|
|
|
61
31
|
/**
|
|
62
|
-
* Get display messages by key
|
|
32
|
+
* Get display messages by key
|
|
63
33
|
*/
|
|
64
34
|
const getDisplayMessagesByKey =
|
|
65
35
|
(key: string) =>
|
|
66
36
|
(s: ChatStoreState): UIChatMessage[] => {
|
|
67
|
-
|
|
68
|
-
return messages.map((i) => ({ ...i, meta: getMeta(i) }));
|
|
37
|
+
return s.messagesMap[key] || [];
|
|
69
38
|
};
|
|
70
39
|
|
|
71
40
|
/**
|
|
@@ -117,7 +117,6 @@ describe('chatDockSelectors', () => {
|
|
|
117
117
|
createdAt: Date.now(),
|
|
118
118
|
updatedAt: Date.now(),
|
|
119
119
|
role: 'user',
|
|
120
|
-
meta: {},
|
|
121
120
|
sessionId: 'test-id',
|
|
122
121
|
} as UIChatMessage,
|
|
123
122
|
],
|
|
@@ -138,7 +137,6 @@ describe('chatDockSelectors', () => {
|
|
|
138
137
|
createdAt: Date.now(),
|
|
139
138
|
updatedAt: Date.now(),
|
|
140
139
|
role: 'user',
|
|
141
|
-
meta: {},
|
|
142
140
|
sessionId: 'test-id',
|
|
143
141
|
} as UIChatMessage,
|
|
144
142
|
],
|
|
@@ -158,7 +156,6 @@ describe('chatDockSelectors', () => {
|
|
|
158
156
|
createdAt: Date.now(),
|
|
159
157
|
updatedAt: Date.now(),
|
|
160
158
|
role: 'user',
|
|
161
|
-
meta: {},
|
|
162
159
|
sessionId: 'test-id',
|
|
163
160
|
} as UIChatMessage,
|
|
164
161
|
],
|
|
@@ -190,7 +187,6 @@ ${htmlContent}
|
|
|
190
187
|
createdAt: Date.now(),
|
|
191
188
|
updatedAt: Date.now(),
|
|
192
189
|
role: 'user',
|
|
193
|
-
meta: {},
|
|
194
190
|
sessionId: 'test-id',
|
|
195
191
|
} as UIChatMessage,
|
|
196
192
|
],
|
|
@@ -211,7 +207,6 @@ ${htmlContent}
|
|
|
211
207
|
createdAt: Date.now(),
|
|
212
208
|
updatedAt: Date.now(),
|
|
213
209
|
role: 'user',
|
|
214
|
-
meta: {},
|
|
215
210
|
sessionId: 'test-id',
|
|
216
211
|
} as UIChatMessage,
|
|
217
212
|
],
|
|
@@ -230,7 +225,6 @@ ${htmlContent}
|
|
|
230
225
|
createdAt: Date.now(),
|
|
231
226
|
updatedAt: Date.now(),
|
|
232
227
|
role: 'user',
|
|
233
|
-
meta: {},
|
|
234
228
|
sessionId: 'test-id',
|
|
235
229
|
} as UIChatMessage,
|
|
236
230
|
],
|
|
@@ -249,7 +243,6 @@ ${htmlContent}
|
|
|
249
243
|
createdAt: Date.now(),
|
|
250
244
|
updatedAt: Date.now(),
|
|
251
245
|
role: 'user',
|
|
252
|
-
meta: {},
|
|
253
246
|
sessionId: 'test-id',
|
|
254
247
|
} as UIChatMessage,
|
|
255
248
|
],
|