@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.
Files changed (87) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/changelog/v1.json +9 -0
  3. package/package.json +1 -1
  4. package/packages/const/src/utils/merge.test.ts +679 -0
  5. package/packages/context-engine/src/processors/__tests__/AgentCouncilFlatten.test.ts +0 -20
  6. package/packages/context-engine/src/processors/__tests__/MessageContent.test.ts +5 -23
  7. package/packages/context-engine/src/providers/SystemRoleInjector.ts +0 -1
  8. package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentCouncil/simple.json +4 -19
  9. package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentCouncil/with-supervisor-reply.json +4 -23
  10. package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentGroup/speak-different-agent.json +3 -13
  11. package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistant-chain-with-followup.json +3 -8
  12. package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistantGroup/assistant-with-tools.json +21 -17
  13. package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistantGroup/tools-with-branches.json +15 -15
  14. package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/active-index-1.json +3 -13
  15. package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-branch.json +2 -9
  16. package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-group-branches.json +0 -11
  17. package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-user-branch.json +5 -15
  18. package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/conversation.json +4 -14
  19. package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/multi-assistant-group.json +0 -13
  20. package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/nested.json +2 -15
  21. package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/simple.json +4 -9
  22. package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/with-tools.json +8 -17
  23. package/packages/conversation-flow/src/__tests__/fixtures/inputs/linear-conversation.json +3 -7
  24. package/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/simple.json +1 -7
  25. package/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/with-summary.json +10 -11
  26. package/packages/conversation-flow/src/__tests__/fixtures/outputs/agentCouncil/simple.json +2 -32
  27. package/packages/conversation-flow/src/__tests__/fixtures/outputs/agentCouncil/with-supervisor-reply.json +8 -46
  28. package/packages/conversation-flow/src/__tests__/fixtures/outputs/agentGroup/speak-different-agent.json +5 -24
  29. package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistant-chain-with-followup.json +5 -13
  30. package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/assistant-with-tools.json +6 -16
  31. package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/tools-with-branches.json +6 -17
  32. package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/active-index-1.json +4 -18
  33. package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-branch.json +4 -16
  34. package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-group-branches.json +0 -19
  35. package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-user-branch.json +8 -24
  36. package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/conversation.json +7 -23
  37. package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/multi-assistant-group.json +0 -15
  38. package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/nested.json +4 -25
  39. package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/simple.json +2 -13
  40. package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/with-tools.json +4 -20
  41. package/packages/conversation-flow/src/__tests__/fixtures/outputs/linear-conversation.json +4 -12
  42. package/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/simple.json +2 -14
  43. package/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/with-summary.json +20 -22
  44. package/packages/conversation-flow/src/__tests__/indexing.test.ts +0 -35
  45. package/packages/conversation-flow/src/__tests__/structuring.test.ts +0 -41
  46. package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +0 -4
  47. package/packages/conversation-flow/src/transformation/__tests__/BranchResolver.test.ts +0 -10
  48. package/packages/conversation-flow/src/transformation/__tests__/ContextTreeBuilder.test.ts +0 -19
  49. package/packages/conversation-flow/src/transformation/__tests__/FlatListBuilder.test.ts +0 -37
  50. package/packages/conversation-flow/src/transformation/__tests__/MessageCollector.test.ts +0 -12
  51. package/packages/conversation-flow/src/transformation/__tests__/MessageTransformer.test.ts +0 -2
  52. package/packages/database/src/models/message.ts +0 -1
  53. package/packages/prompts/src/prompts/chatMessages/index.test.ts +0 -1
  54. package/packages/prompts/src/prompts/groupChat/__snapshots__/index.test.ts.snap +0 -21
  55. package/packages/prompts/src/prompts/groupChat/index.test.ts +0 -3
  56. package/packages/types/src/message/ui/chat.ts +0 -2
  57. package/src/features/Conversation/store/slices/data/action.test.ts +0 -14
  58. package/src/features/Conversation/store/slices/data/reducer.test.ts +0 -21
  59. package/src/features/Conversation/store/slices/data/reducer.ts +1 -1
  60. package/src/features/Conversation/store/slices/message/action/crud.test.ts +0 -10
  61. package/src/server/modules/Mecha/ContextEngineering/__tests__/serverMessagesEngine.test.ts +3 -5
  62. package/src/server/routers/lambda/__tests__/message.test.ts +1 -2
  63. package/src/server/services/agentRuntime/AgentRuntimeService.ts +109 -109
  64. package/src/server/services/agentRuntime/types.ts +8 -8
  65. package/src/server/services/doc/index.tsx +2 -2
  66. package/src/server/services/generation/index.ts +2 -2
  67. package/src/server/services/message/index.ts +3 -3
  68. package/src/server/services/usage/index.ts +4 -4
  69. package/src/services/chat/chat.test.ts +0 -6
  70. package/src/services/chat/mecha/contextEngineering.test.ts +3 -29
  71. package/src/services/chat/mecha/modelParamsResolver.test.ts +803 -0
  72. package/src/store/chat/agents/GroupOrchestration/createGroupOrchestrationExecutors.ts +0 -2
  73. package/src/store/chat/agents/__tests__/createAgentExecutors/call-tool.test.ts +0 -6
  74. package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockMessages.ts +0 -3
  75. package/src/store/chat/agents/createAgentExecutors.ts +4 -4
  76. package/src/store/chat/slices/aiAgent/actions/__tests__/agentGroup.test.ts +0 -2
  77. package/src/store/chat/slices/aiAgent/actions/__tests__/runAgent.test.ts +0 -3
  78. package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +0 -1
  79. package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +0 -4
  80. package/src/store/chat/slices/message/reducer.test.ts +0 -5
  81. package/src/store/chat/slices/message/reducer.ts +1 -1
  82. package/src/store/chat/slices/message/selectors/displayMessage.test.ts +0 -13
  83. package/src/store/chat/slices/message/selectors/displayMessage.ts +3 -34
  84. package/src/store/chat/slices/portal/selectors.test.ts +0 -7
  85. package/src/store/chat/slices/thread/action.test.ts +0 -1
  86. package/src/store/chat/slices/translate/action.test.ts +0 -1
  87. package/src/store/tool/slices/oldStore/action.test.ts +0 -1
@@ -4,12 +4,12 @@ import { type LobeToolManifest } from '@lobechat/context-engine';
4
4
  // ==================== Step Lifecycle Callbacks ====================
5
5
 
6
6
  /**
7
- * Step 执行生命周期回调
8
- * 用于在 step 执行的不同阶段注入自定义逻辑
7
+ * Step execution lifecycle callbacks
8
+ * Used to inject custom logic at different stages of step execution
9
9
  */
10
10
  export interface StepLifecycleCallbacks {
11
11
  /**
12
- * step 执行后调用
12
+ * Called after step execution
13
13
  */
14
14
  onAfterStep?: (params: {
15
15
  operationId: string;
@@ -20,7 +20,7 @@ export interface StepLifecycleCallbacks {
20
20
  }) => Promise<void>;
21
21
 
22
22
  /**
23
- * step 执行前调用
23
+ * Called before step execution
24
24
  */
25
25
  onBeforeStep?: (params: {
26
26
  context?: AgentRuntimeContext;
@@ -30,7 +30,7 @@ export interface StepLifecycleCallbacks {
30
30
  }) => Promise<void>;
31
31
 
32
32
  /**
33
- * 在操作完成时调用(status 变为 done/error/interrupted
33
+ * Called when operation completes (status changes to done/error/interrupted)
34
34
  */
35
35
  onComplete?: (params: {
36
36
  finalState: AgentState;
@@ -40,7 +40,7 @@ export interface StepLifecycleCallbacks {
40
40
  }
41
41
 
42
42
  /**
43
- * Step 完成原因
43
+ * Step completion reason
44
44
  */
45
45
  export type StepCompletionReason =
46
46
  | 'done'
@@ -82,8 +82,8 @@ export interface OperationCreationParams {
82
82
  modelRuntimeConfig?: any;
83
83
  operationId: string;
84
84
  /**
85
- * Step 生命周期回调
86
- * 用于在 step 执行的不同阶段注入自定义逻辑
85
+ * Step lifecycle callbacks
86
+ * Used to inject custom logic at different stages of step execution
87
87
  */
88
88
  stepCallbacks?: StepLifecycleCallbacks;
89
89
  toolManifestMap: Record<string, LobeToolManifest>;
@@ -35,6 +35,6 @@ export class DocService {
35
35
  }
36
36
  }
37
37
 
38
- // 很奇怪,需要加一行这个 `readdirSync` 才能在 vercel 部署后读到 md 文件
39
- // 否则没法正常找到 mdx 文件
38
+ // Strangely, this `readdirSync` call is needed to read md files after Vercel deployment
39
+ // Otherwise, mdx files cannot be found properly
40
40
  readdirSync(join(process.cwd(), 'docs'));
@@ -67,8 +67,8 @@ interface ImageForGeneration {
67
67
  }
68
68
 
69
69
  /**
70
- * 图片生成服务
71
- * 负责处理AI生成图片的转换、上传和封面创建
70
+ * Image generation service
71
+ * Handles conversion, upload and cover creation for AI-generated images
72
72
  */
73
73
  export class GenerationService {
74
74
  private fileService: FileService;
@@ -52,7 +52,7 @@ export class MessageService {
52
52
 
53
53
  /**
54
54
  * Query messages and return response with success status (used after mutations)
55
- * 优先使用 agentId,如果没有则使用 sessionId(向后兼容)
55
+ * Prioritize agentId, fallback to sessionId if not provided (for backwards compatibility)
56
56
  */
57
57
  private async queryWithSuccess(
58
58
  options?: QueryOptions,
@@ -84,11 +84,11 @@ export class MessageService {
84
84
  * reducing the need for separate refresh calls and improving performance.
85
85
  */
86
86
  async createMessage(params: CreateMessageParams): Promise<CreateMessageResult> {
87
- // 1. Create the message (使用 agentId)
87
+ // 1. Create the message (using agentId)
88
88
  const item = await this.messageModel.create(params);
89
89
 
90
90
  // 2. Query all messages for this agent/topic
91
- // 使用 agentId 字段查询
91
+ // Use agentId field for query
92
92
  const messages = await this.messageModel.query(
93
93
  {
94
94
  agentId: params.agentId,
@@ -25,11 +25,11 @@ export class UsageRecordService {
25
25
  * @returns UsageRecordItem[]
26
26
  */
27
27
  findByMonth = async (mo?: string): Promise<UsageRecordItem[]> => {
28
- // 设置 startAt endAt
28
+ // Set startAt and endAt
29
29
  let startAt: string;
30
30
  let endAt: string;
31
31
  if (mo) {
32
- // mo 格式: "YYYY-MM"
32
+ // mo format: "YYYY-MM"
33
33
  startAt = dayjs(mo, 'YYYY-MM').startOf('month').format('YYYY-MM-DD');
34
34
  endAt = dayjs(mo, 'YYYY-MM').endOf('month').format('YYYY-MM-DD');
35
35
  } else {
@@ -86,11 +86,11 @@ export class UsageRecordService {
86
86
  };
87
87
 
88
88
  findAndGroupByDay = async (mo?: string): Promise<UsageLog[]> => {
89
- // 设置 startAt endAt
89
+ // Set startAt and endAt
90
90
  let startAt: string;
91
91
  let endAt: string;
92
92
  if (mo) {
93
- // mo 格式: "YYYY-MM"
93
+ // mo format: "YYYY-MM"
94
94
  startAt = dayjs(mo, 'YYYY-MM').startOf('month').format('YYYY-MM-DD');
95
95
  endAt = dayjs(mo, 'YYYY-MM').endOf('month').format('YYYY-MM-DD');
96
96
  } else {
@@ -425,7 +425,6 @@ describe('ChatService', () => {
425
425
  ],
426
426
  createdAt: Date.now(),
427
427
  id: 'test-id',
428
- meta: {},
429
428
  updatedAt: Date.now(),
430
429
  },
431
430
  ] as UIChatMessage[];
@@ -517,7 +516,6 @@ describe('ChatService', () => {
517
516
  ],
518
517
  createdAt: Date.now(),
519
518
  id: 'test-id-2',
520
- meta: {},
521
519
  updatedAt: Date.now(),
522
520
  },
523
521
  ] as UIChatMessage[];
@@ -624,7 +622,6 @@ describe('ChatService', () => {
624
622
  ],
625
623
  createdAt: Date.now(),
626
624
  id: 'test-id-3',
627
- meta: {},
628
625
  updatedAt: Date.now(),
629
626
  },
630
627
  ] as UIChatMessage[];
@@ -678,9 +675,6 @@ describe('ChatService', () => {
678
675
  id: 'vyQvEw6V',
679
676
  updatedAt: 1702723964330,
680
677
  extra: {},
681
- meta: {
682
- avatar: DEFAULT_USER_AVATAR,
683
- },
684
678
  },
685
679
  ] as UIChatMessage[];
686
680
 
@@ -262,7 +262,6 @@ describe('contextEngineering', () => {
262
262
  content: 'Continue our discussion',
263
263
  createdAt: Date.now(),
264
264
  id: 'test-history',
265
- meta: {},
266
265
  updatedAt: Date.now(),
267
266
  },
268
267
  ];
@@ -292,7 +291,6 @@ describe('contextEngineering', () => {
292
291
  imageList: [{ id: 'img1', url: 'http://example.com/image.png', alt: 'test.png' }],
293
292
  createdAt: Date.now(),
294
293
  id: 'test-id',
295
- meta: {},
296
294
  updatedAt: Date.now(),
297
295
  },
298
296
  ];
@@ -319,7 +317,6 @@ describe('contextEngineering', () => {
319
317
  imageList: [{ id: 'img1', url: 'http://example.com/image.png', alt: 'test.png' }],
320
318
  createdAt: Date.now(),
321
319
  id: 'test-id-2',
322
- meta: {},
323
320
  updatedAt: Date.now(),
324
321
  },
325
322
  ];
@@ -354,7 +351,6 @@ describe('contextEngineering', () => {
354
351
  ],
355
352
  createdAt: Date.now(),
356
353
  id: 'test-id-3',
357
- meta: {},
358
354
  updatedAt: Date.now(),
359
355
  },
360
356
  ];
@@ -377,7 +373,6 @@ describe('contextEngineering', () => {
377
373
  content: 'Hello {{username}}, today is {{date}} and the time is {{time}}',
378
374
  createdAt: Date.now(),
379
375
  id: 'test-placeholder-1',
380
- meta: {},
381
376
  updatedAt: Date.now(),
382
377
  },
383
378
  {
@@ -385,7 +380,6 @@ describe('contextEngineering', () => {
385
380
  content: 'Hi there! Your random number is {{random}}',
386
381
  createdAt: Date.now(),
387
382
  id: 'test-placeholder-2',
388
- meta: {},
389
383
  updatedAt: Date.now(),
390
384
  },
391
385
  ];
@@ -418,7 +412,6 @@ describe('contextEngineering', () => {
418
412
  ],
419
413
  createdAt: Date.now(),
420
414
  id: 'test-placeholder-array',
421
- meta: {},
422
415
  updatedAt: Date.now(),
423
416
  },
424
417
  ] as any;
@@ -443,7 +436,6 @@ describe('contextEngineering', () => {
443
436
  'Memory load: available={{memory_available}}, total contexts={{memory_contexts_count}}\n{{memory_summary}}',
444
437
  createdAt: Date.now(),
445
438
  id: 'memory-placeholder-test',
446
- meta: {},
447
439
  updatedAt: Date.now(),
448
440
  },
449
441
  {
@@ -451,7 +443,6 @@ describe('contextEngineering', () => {
451
443
  content: 'Hello',
452
444
  createdAt: Date.now(),
453
445
  id: 'memory-placeholder-user',
454
- meta: {},
455
446
  updatedAt: Date.now(),
456
447
  },
457
448
  ];
@@ -497,7 +488,9 @@ describe('contextEngineering', () => {
497
488
 
498
489
  // Memory context is injected as a consolidated user message before the first user message
499
490
  // Note: meta/id fields are removed by the engine cleanup step, so assert via content.
500
- const injection = result.find((m: any) => m.role === 'user' && String(m.content).includes('<user_memory>'));
491
+ const injection = result.find(
492
+ (m: any) => m.role === 'user' && String(m.content).includes('<user_memory>'),
493
+ );
501
494
  expect(injection).toBeDefined();
502
495
  expect(injection!.role).toBe('user');
503
496
  expect(injection!.content).toContain('<user_memory>');
@@ -512,7 +505,6 @@ describe('contextEngineering', () => {
512
505
  content: 'Hello {{username}}, missing: {{missing_var}}',
513
506
  createdAt: Date.now(),
514
507
  id: 'test-placeholder-missing',
515
- meta: {},
516
508
  updatedAt: Date.now(),
517
509
  },
518
510
  ];
@@ -533,7 +525,6 @@ describe('contextEngineering', () => {
533
525
  content: 'Hello there, no variables here',
534
526
  createdAt: Date.now(),
535
527
  id: 'test-no-placeholders',
536
- meta: {},
537
528
  updatedAt: Date.now(),
538
529
  },
539
530
  ];
@@ -564,7 +555,6 @@ describe('contextEngineering', () => {
564
555
  ],
565
556
  createdAt: Date.now(),
566
557
  id: 'test-combined',
567
- meta: {},
568
558
  updatedAt: Date.now(),
569
559
  },
570
560
  ];
@@ -600,7 +590,6 @@ describe('contextEngineering', () => {
600
590
  content: 'Message 1',
601
591
  createdAt: Date.now(),
602
592
  id: 'test-1',
603
- meta: {},
604
593
  updatedAt: Date.now(),
605
594
  },
606
595
  {
@@ -608,7 +597,6 @@ describe('contextEngineering', () => {
608
597
  content: 'Response 1',
609
598
  createdAt: Date.now(),
610
599
  id: 'test-2',
611
- meta: {},
612
600
  updatedAt: Date.now(),
613
601
  },
614
602
  {
@@ -616,7 +604,6 @@ describe('contextEngineering', () => {
616
604
  content: 'Message 2',
617
605
  createdAt: Date.now(),
618
606
  id: 'test-3',
619
- meta: {},
620
607
  updatedAt: Date.now(),
621
608
  },
622
609
  {
@@ -624,7 +611,6 @@ describe('contextEngineering', () => {
624
611
  content: 'Response 2',
625
612
  createdAt: Date.now(),
626
613
  id: 'test-4',
627
- meta: {},
628
614
  updatedAt: Date.now(),
629
615
  },
630
616
  {
@@ -632,7 +618,6 @@ describe('contextEngineering', () => {
632
618
  content: 'Latest message',
633
619
  createdAt: Date.now(),
634
620
  id: 'test-5',
635
- meta: {},
636
621
  updatedAt: Date.now(),
637
622
  },
638
623
  ];
@@ -662,7 +647,6 @@ describe('contextEngineering', () => {
662
647
  content: 'Original user input',
663
648
  createdAt: Date.now(),
664
649
  id: 'test-template',
665
- meta: {},
666
650
  updatedAt: Date.now(),
667
651
  },
668
652
  {
@@ -670,7 +654,6 @@ describe('contextEngineering', () => {
670
654
  content: 'Assistant response',
671
655
  createdAt: Date.now(),
672
656
  id: 'test-assistant',
673
- meta: {},
674
657
  updatedAt: Date.now(),
675
658
  },
676
659
  ];
@@ -703,7 +686,6 @@ describe('contextEngineering', () => {
703
686
  content: 'User message',
704
687
  createdAt: Date.now(),
705
688
  id: 'test-user',
706
- meta: {},
707
689
  updatedAt: Date.now(),
708
690
  },
709
691
  ];
@@ -729,7 +711,6 @@ describe('contextEngineering', () => {
729
711
  content: 'Old message 1',
730
712
  createdAt: Date.now(),
731
713
  id: 'test-old-1',
732
- meta: {},
733
714
  updatedAt: Date.now(),
734
715
  },
735
716
  {
@@ -737,7 +718,6 @@ describe('contextEngineering', () => {
737
718
  content: 'Old response',
738
719
  createdAt: Date.now(),
739
720
  id: 'test-old-2',
740
- meta: {},
741
721
  updatedAt: Date.now(),
742
722
  },
743
723
  {
@@ -745,7 +725,6 @@ describe('contextEngineering', () => {
745
725
  content: 'Recent input with {{username}}',
746
726
  createdAt: Date.now(),
747
727
  id: 'test-recent',
748
- meta: {},
749
728
  updatedAt: Date.now(),
750
729
  },
751
730
  ];
@@ -784,7 +763,6 @@ describe('contextEngineering', () => {
784
763
  content: 'Simple message',
785
764
  createdAt: Date.now(),
786
765
  id: 'test-simple',
787
- meta: {},
788
766
  updatedAt: Date.now(),
789
767
  },
790
768
  ];
@@ -811,7 +789,6 @@ describe('contextEngineering', () => {
811
789
  content: 'Message 1',
812
790
  createdAt: Date.now(),
813
791
  id: 'test-1',
814
- meta: {},
815
792
  updatedAt: Date.now(),
816
793
  },
817
794
  {
@@ -819,7 +796,6 @@ describe('contextEngineering', () => {
819
796
  content: 'Message 2',
820
797
  createdAt: Date.now(),
821
798
  id: 'test-2',
822
- meta: {},
823
799
  updatedAt: Date.now(),
824
800
  },
825
801
  {
@@ -827,7 +803,6 @@ describe('contextEngineering', () => {
827
803
  content: 'Message 3',
828
804
  createdAt: Date.now(),
829
805
  id: 'test-3',
830
- meta: {},
831
806
  updatedAt: Date.now(),
832
807
  },
833
808
  ];
@@ -861,7 +836,6 @@ describe('contextEngineering', () => {
861
836
  content: 'User message',
862
837
  createdAt: Date.now(),
863
838
  id: 'test-error',
864
- meta: {},
865
839
  updatedAt: Date.now(),
866
840
  },
867
841
  ];