@lobehub/lobehub 2.0.10 → 2.0.12
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 +50 -0
- package/Dockerfile +44 -52
- package/changelog/v2.json +18 -0
- package/locales/ar/chat.json +4 -0
- package/locales/ar/models.json +65 -0
- package/locales/bg-BG/chat.json +4 -0
- package/locales/bg-BG/models.json +10 -0
- package/locales/de-DE/chat.json +4 -0
- package/locales/de-DE/models.json +41 -0
- package/locales/en-US/chat.json +4 -0
- package/locales/es-ES/chat.json +4 -0
- package/locales/es-ES/models.json +50 -0
- package/locales/fa-IR/chat.json +4 -0
- package/locales/fa-IR/models.json +39 -0
- package/locales/fr-FR/chat.json +4 -0
- package/locales/fr-FR/models.json +9 -0
- package/locales/it-IT/chat.json +4 -0
- package/locales/it-IT/models.json +62 -0
- package/locales/ja-JP/chat.json +4 -0
- package/locales/ja-JP/models.json +40 -0
- package/locales/ko-KR/chat.json +4 -0
- package/locales/ko-KR/models.json +31 -0
- package/locales/nl-NL/chat.json +4 -0
- package/locales/nl-NL/models.json +52 -0
- package/locales/pl-PL/chat.json +4 -0
- package/locales/pl-PL/models.json +43 -0
- package/locales/pt-BR/chat.json +4 -0
- package/locales/pt-BR/models.json +92 -0
- package/locales/ru-RU/chat.json +4 -0
- package/locales/ru-RU/models.json +34 -0
- package/locales/tr-TR/chat.json +4 -0
- package/locales/tr-TR/models.json +55 -0
- package/locales/vi-VN/chat.json +4 -0
- package/locales/vi-VN/models.json +31 -0
- package/locales/zh-CN/chat.json +4 -0
- package/locales/zh-TW/chat.json +4 -0
- package/package.json +1 -1
- package/packages/agent-runtime/src/groupOrchestration/GroupOrchestrationSupervisor.ts +18 -1
- package/packages/agent-runtime/src/groupOrchestration/__tests__/GroupOrchestrationSupervisor.test.ts +76 -5
- package/packages/agent-runtime/src/groupOrchestration/types.ts +3 -3
- package/packages/builtin-tool-group-management/src/client/Intervention/ExecuteTask.tsx +11 -11
- package/packages/builtin-tool-group-management/src/client/Intervention/ExecuteTasks.tsx +78 -79
- package/packages/builtin-tool-group-management/src/client/Render/ExecuteTask/index.tsx +3 -3
- package/packages/builtin-tool-group-management/src/client/Render/ExecuteTasks/index.tsx +61 -63
- package/packages/builtin-tool-group-management/src/client/Streaming/ExecuteTask/index.tsx +3 -3
- package/packages/builtin-tool-group-management/src/executor.test.ts +7 -9
- package/packages/builtin-tool-group-management/src/executor.ts +3 -3
- package/packages/builtin-tool-group-management/src/manifest.ts +49 -50
- package/packages/builtin-tool-group-management/src/systemRole.ts +153 -5
- package/packages/builtin-tool-group-management/src/types.ts +3 -2
- package/packages/builtin-tool-gtd/src/systemRole.ts +4 -4
- package/packages/context-engine/src/processors/TasksFlatten.ts +7 -5
- package/packages/context-engine/src/processors/__tests__/TasksFlatten.test.ts +164 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentGroup/index.ts +4 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentGroup/supervisor-after-multi-tasks.json +91 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/agentGroup/supervisor-content-only.json +74 -0
- package/packages/conversation-flow/src/__tests__/parse.test.ts +37 -0
- package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +70 -4
- package/packages/conversation-flow/src/transformation/__tests__/FlatListBuilder.test.ts +147 -0
- package/packages/database/src/repositories/agentGroup/index.ts +4 -0
- package/packages/types/src/message/ui/chat.ts +2 -0
- package/packages/types/src/tool/builtin.ts +5 -5
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Sidebar/ActionButton/ForkGroupAndChat.tsx +2 -1
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/index.tsx +2 -2
- package/src/app/[variants]/(main)/group/profile/features/Header/GroupPublishButton/useMarketGroupPublish.ts +11 -12
- package/src/features/Conversation/ChatItem/components/Title.tsx +1 -1
- package/src/features/Conversation/ChatList/index.tsx +0 -1
- package/src/features/Conversation/Messages/GroupTasks/TaskItem/ClientTaskItem.tsx +183 -0
- package/src/features/Conversation/Messages/GroupTasks/TaskItem/ServerTaskItem.tsx +94 -0
- package/src/features/Conversation/Messages/GroupTasks/TaskItem/TaskTitle.tsx +177 -0
- package/src/features/Conversation/Messages/GroupTasks/TaskItem/index.tsx +26 -0
- package/src/features/Conversation/Messages/GroupTasks/TaskItem/useClientTaskStats.ts +93 -0
- package/src/features/Conversation/Messages/GroupTasks/index.tsx +151 -0
- package/src/features/Conversation/Messages/Supervisor/index.tsx +7 -1
- package/src/features/Conversation/Messages/Task/ClientTaskDetail/index.tsx +72 -91
- package/src/features/Conversation/Messages/Task/TaskDetailPanel/StatusContent.tsx +46 -17
- package/src/features/Conversation/Messages/Tasks/TaskItem/ClientTaskItem.tsx +9 -24
- package/src/features/Conversation/Messages/Tasks/TaskItem/ServerTaskItem.tsx +18 -38
- package/src/features/Conversation/Messages/Tasks/shared/ErrorState.tsx +45 -2
- package/src/features/Conversation/Messages/Tasks/shared/InitializingState.tsx +16 -1
- package/src/features/Conversation/Messages/Tasks/shared/TaskContent.tsx +68 -0
- package/src/features/Conversation/Messages/Tasks/shared/TaskMessages.tsx +383 -0
- package/src/features/Conversation/Messages/Tasks/shared/index.ts +4 -0
- package/src/features/Conversation/Messages/Tasks/shared/useTaskPolling.ts +48 -0
- package/src/features/Conversation/Messages/index.tsx +5 -0
- package/src/locales/default/chat.ts +4 -0
- package/src/server/modules/AgentRuntime/RuntimeExecutors.ts +4 -0
- package/src/server/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts +106 -1
- package/src/server/routers/lambda/agentGroup.ts +2 -0
- package/src/server/routers/lambda/market/agent.ts +17 -45
- package/src/server/routers/lambda/market/agentGroup.ts +13 -25
- package/src/server/services/aiAgent/__tests__/execAgent.threadId.test.ts +2 -2
- package/src/server/utils/truncateToolResult.ts +1 -4
- package/src/store/chat/agents/GroupOrchestration/__tests__/batch-exec-async-tasks.test.ts +15 -15
- package/src/store/chat/agents/GroupOrchestration/createGroupOrchestrationExecutors.ts +22 -15
- package/src/store/chat/agents/__tests__/createAgentExecutors/exec-tasks.test.ts +21 -10
- package/src/store/chat/agents/createAgentExecutors.ts +2 -0
- package/src/store/chat/slices/aiAgent/actions/groupOrchestration.ts +10 -7
- package/src/features/Conversation/Messages/Task/ClientTaskDetail/CompletedState.tsx +0 -108
- package/src/features/Conversation/Messages/Task/ClientTaskDetail/InstructionAccordion.tsx +0 -63
- package/src/features/Conversation/Messages/Task/ClientTaskDetail/ProcessingState.tsx +0 -123
|
@@ -655,8 +655,10 @@ describe('RuntimeExecutors', () => {
|
|
|
655
655
|
|
|
656
656
|
const result = await executors.call_tools_batch!(instruction, state);
|
|
657
657
|
|
|
658
|
-
// Should query messages from database
|
|
658
|
+
// Should query messages from database with agentId, threadId, and topicId
|
|
659
659
|
expect(mockMessageModel.query).toHaveBeenCalledWith({
|
|
660
|
+
agentId: 'agent-123',
|
|
661
|
+
threadId: 'thread-123',
|
|
660
662
|
topicId: 'topic-123',
|
|
661
663
|
});
|
|
662
664
|
|
|
@@ -952,6 +954,109 @@ describe('RuntimeExecutors', () => {
|
|
|
952
954
|
}),
|
|
953
955
|
);
|
|
954
956
|
});
|
|
957
|
+
|
|
958
|
+
it('should query messages with correct metadata fields when state.metadata is defined', async () => {
|
|
959
|
+
const executors = createRuntimeExecutors(ctx);
|
|
960
|
+
const state = createMockState({
|
|
961
|
+
metadata: {
|
|
962
|
+
agentId: 'agent-abc',
|
|
963
|
+
threadId: 'thread-xyz',
|
|
964
|
+
topicId: 'topic-abc-123',
|
|
965
|
+
},
|
|
966
|
+
});
|
|
967
|
+
|
|
968
|
+
const instruction = {
|
|
969
|
+
payload: {
|
|
970
|
+
parentMessageId: 'assistant-msg-123',
|
|
971
|
+
toolsCalling: [
|
|
972
|
+
{
|
|
973
|
+
apiName: 'search',
|
|
974
|
+
arguments: '{}',
|
|
975
|
+
id: 'tool-call-1',
|
|
976
|
+
identifier: 'web-search',
|
|
977
|
+
type: 'default' as const,
|
|
978
|
+
},
|
|
979
|
+
],
|
|
980
|
+
},
|
|
981
|
+
type: 'call_tools_batch' as const,
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
await executors.call_tools_batch!(instruction, state);
|
|
985
|
+
|
|
986
|
+
// Should query messages with agentId, threadId, and topicId from state.metadata
|
|
987
|
+
expect(mockMessageModel.query).toHaveBeenCalledWith({
|
|
988
|
+
agentId: 'agent-abc',
|
|
989
|
+
threadId: 'thread-xyz',
|
|
990
|
+
topicId: 'topic-abc-123',
|
|
991
|
+
});
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
it('should preserve messages in newState even when state.metadata.topicId is undefined', async () => {
|
|
995
|
+
// Regression test: When state.metadata.topicId is undefined, previously the query
|
|
996
|
+
// only passed topicId, which caused isNull(topicId) condition and returned 0 messages.
|
|
997
|
+
// This led to "messages: at least one message is required" error in the next call_llm step.
|
|
998
|
+
//
|
|
999
|
+
// Fix: Now we also pass agentId and threadId, so even when topicId is undefined,
|
|
1000
|
+
// the query can still find messages by agentId scope.
|
|
1001
|
+
|
|
1002
|
+
// Mock: query returns messages when agentId is provided (regardless of topicId)
|
|
1003
|
+
mockMessageModel.query = vi
|
|
1004
|
+
.fn()
|
|
1005
|
+
.mockImplementation((params: { agentId?: string; topicId?: string }) => {
|
|
1006
|
+
// With the fix, agentId is always passed, so we can find messages
|
|
1007
|
+
if (params.agentId) {
|
|
1008
|
+
return Promise.resolve([
|
|
1009
|
+
{ id: 'msg-1', content: 'Hello', role: 'user' },
|
|
1010
|
+
{ id: 'msg-2', content: 'Response', role: 'assistant', tool_calls: [] },
|
|
1011
|
+
]);
|
|
1012
|
+
}
|
|
1013
|
+
// Without agentId (old buggy behavior), return empty
|
|
1014
|
+
return Promise.resolve([]);
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
const executors = createRuntimeExecutors(ctx);
|
|
1018
|
+
// State with undefined topicId but has agentId
|
|
1019
|
+
const state = createMockState({
|
|
1020
|
+
messages: [
|
|
1021
|
+
{ content: 'Hello', role: 'user' },
|
|
1022
|
+
{ content: 'Response', role: 'assistant', tool_calls: [] },
|
|
1023
|
+
],
|
|
1024
|
+
metadata: {
|
|
1025
|
+
agentId: 'agent-123',
|
|
1026
|
+
threadId: 'thread-123',
|
|
1027
|
+
topicId: undefined, // topicId is undefined
|
|
1028
|
+
},
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1031
|
+
const instruction = {
|
|
1032
|
+
payload: {
|
|
1033
|
+
parentMessageId: 'assistant-msg-123',
|
|
1034
|
+
toolsCalling: [
|
|
1035
|
+
{
|
|
1036
|
+
apiName: 'search',
|
|
1037
|
+
arguments: '{}',
|
|
1038
|
+
id: 'tool-call-1',
|
|
1039
|
+
identifier: 'web-search',
|
|
1040
|
+
type: 'default' as const,
|
|
1041
|
+
},
|
|
1042
|
+
],
|
|
1043
|
+
},
|
|
1044
|
+
type: 'call_tools_batch' as const,
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
const result = await executors.call_tools_batch!(instruction, state);
|
|
1048
|
+
|
|
1049
|
+
// Verify agentId is passed in the query
|
|
1050
|
+
expect(mockMessageModel.query).toHaveBeenCalledWith({
|
|
1051
|
+
agentId: 'agent-123',
|
|
1052
|
+
threadId: 'thread-123',
|
|
1053
|
+
topicId: undefined,
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
// Expected: newState.messages should NOT be empty
|
|
1057
|
+
// The next call_llm step needs messages to work properly
|
|
1058
|
+
expect(result.newState.messages.length).toBeGreaterThan(0);
|
|
1059
|
+
});
|
|
955
1060
|
});
|
|
956
1061
|
|
|
957
1062
|
describe('resolve_aborted_tools executor', () => {
|
|
@@ -133,9 +133,11 @@ export const agentGroupRouter = router({
|
|
|
133
133
|
.object({
|
|
134
134
|
avatar: z.string().nullish(),
|
|
135
135
|
backgroundColor: z.string().nullish(),
|
|
136
|
+
chatConfig: z.any().nullish(),
|
|
136
137
|
description: z.string().nullish(),
|
|
137
138
|
model: z.string().nullish(),
|
|
138
139
|
params: z.any().nullish(),
|
|
140
|
+
plugins: z.array(z.string()).nullish(),
|
|
139
141
|
provider: z.string().nullish(),
|
|
140
142
|
systemRole: z.string().nullish(),
|
|
141
143
|
tags: z.array(z.string()).nullish(),
|
|
@@ -177,8 +177,8 @@ const publishOrCreateSchema = z.object({
|
|
|
177
177
|
editorData: z.record(z.any()).optional(),
|
|
178
178
|
|
|
179
179
|
// Agent basic info
|
|
180
|
-
identifier: z.string().
|
|
181
|
-
// Optional - if not provided or not owned, will create new
|
|
180
|
+
identifier: z.string().nullish(),
|
|
181
|
+
// Optional - if not provided or not owned, will create new (allow null or undefined)
|
|
182
182
|
name: z.string(),
|
|
183
183
|
tags: z.array(z.string()).optional(),
|
|
184
184
|
tokenUsage: z.number().optional(),
|
|
@@ -312,12 +312,11 @@ export const agentRouter = router({
|
|
|
312
312
|
}
|
|
313
313
|
}),
|
|
314
314
|
|
|
315
|
-
|
|
316
315
|
/**
|
|
317
316
|
* Fork an agent
|
|
318
317
|
* POST /market/agent/:identifier/fork
|
|
319
318
|
*/
|
|
320
|
-
forkAgent: agentProcedure
|
|
319
|
+
forkAgent: agentProcedure
|
|
321
320
|
.input(
|
|
322
321
|
z.object({
|
|
323
322
|
identifier: z.string(),
|
|
@@ -385,13 +384,11 @@ forkAgent: agentProcedure
|
|
|
385
384
|
}
|
|
386
385
|
}),
|
|
387
386
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
/**
|
|
387
|
+
/**
|
|
391
388
|
* Get agent detail by identifier
|
|
392
389
|
* GET /market/agent/:identifier
|
|
393
390
|
*/
|
|
394
|
-
getAgentDetail: agentProcedure
|
|
391
|
+
getAgentDetail: agentProcedure
|
|
395
392
|
.input(z.object({ identifier: z.string() }))
|
|
396
393
|
.query(async ({ input, ctx }) => {
|
|
397
394
|
log('getAgentDetail input: %O', input);
|
|
@@ -409,14 +406,11 @@ getAgentDetail: agentProcedure
|
|
|
409
406
|
}
|
|
410
407
|
}),
|
|
411
408
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
/**
|
|
409
|
+
/**
|
|
416
410
|
* Get the fork source of an agent
|
|
417
411
|
* GET /market/agent/:identifier/fork-source
|
|
418
412
|
*/
|
|
419
|
-
getAgentForkSource: agentProcedure
|
|
413
|
+
getAgentForkSource: agentProcedure
|
|
420
414
|
.input(z.object({ identifier: z.string() }))
|
|
421
415
|
.query(async ({ input, ctx }) => {
|
|
422
416
|
log('getAgentForkSource input: %O', input);
|
|
@@ -470,16 +464,11 @@ getAgentForkSource: agentProcedure
|
|
|
470
464
|
}
|
|
471
465
|
}),
|
|
472
466
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
/**
|
|
467
|
+
/**
|
|
479
468
|
* Get all forks of an agent
|
|
480
469
|
* GET /market/agent/:identifier/forks
|
|
481
470
|
*/
|
|
482
|
-
getAgentForks: agentProcedure
|
|
471
|
+
getAgentForks: agentProcedure
|
|
483
472
|
.input(z.object({ identifier: z.string() }))
|
|
484
473
|
.query(async ({ input, ctx }) => {
|
|
485
474
|
log('getAgentForks input: %O', input);
|
|
@@ -533,17 +522,11 @@ getAgentForks: agentProcedure
|
|
|
533
522
|
}
|
|
534
523
|
}),
|
|
535
524
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
/**
|
|
525
|
+
/**
|
|
543
526
|
* Get own agents (requires authentication)
|
|
544
527
|
* GET /market/agent/own
|
|
545
528
|
*/
|
|
546
|
-
getOwnAgents: agentProcedure.input(paginationSchema.optional()).query(async ({ input, ctx }) => {
|
|
529
|
+
getOwnAgents: agentProcedure.input(paginationSchema.optional()).query(async ({ input, ctx }) => {
|
|
547
530
|
log('getOwnAgents input: %O', input);
|
|
548
531
|
|
|
549
532
|
try {
|
|
@@ -562,16 +545,11 @@ getOwnAgents: agentProcedure.input(paginationSchema.optional()).query(async ({ i
|
|
|
562
545
|
}
|
|
563
546
|
}),
|
|
564
547
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
/**
|
|
548
|
+
/**
|
|
571
549
|
* Publish an agent (make it visible in marketplace)
|
|
572
550
|
* POST /market/agent/:identifier/publish
|
|
573
551
|
*/
|
|
574
|
-
publishAgent: agentProcedure
|
|
552
|
+
publishAgent: agentProcedure
|
|
575
553
|
.input(z.object({ identifier: z.string() }))
|
|
576
554
|
.mutation(async ({ input, ctx }) => {
|
|
577
555
|
log('publishAgent input: %O', input);
|
|
@@ -589,11 +567,7 @@ publishAgent: agentProcedure
|
|
|
589
567
|
}
|
|
590
568
|
}),
|
|
591
569
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
/**
|
|
570
|
+
/**
|
|
597
571
|
* Unified publish or create agent flow
|
|
598
572
|
* This procedure handles the complete publish logic:
|
|
599
573
|
* 1. Check if identifier exists and if current user is owner
|
|
@@ -602,7 +576,7 @@ publishAgent: agentProcedure
|
|
|
602
576
|
*
|
|
603
577
|
* Returns: { identifier, isNewAgent, success }
|
|
604
578
|
*/
|
|
605
|
-
publishOrCreate: agentProcedure.input(publishOrCreateSchema).mutation(async ({ input, ctx }) => {
|
|
579
|
+
publishOrCreate: agentProcedure.input(publishOrCreateSchema).mutation(async ({ input, ctx }) => {
|
|
606
580
|
log('publishOrCreate input: %O', input);
|
|
607
581
|
|
|
608
582
|
const { identifier: inputIdentifier, name, ...versionData } = input;
|
|
@@ -684,13 +658,11 @@ publishOrCreate: agentProcedure.input(publishOrCreateSchema).mutation(async ({ i
|
|
|
684
658
|
}
|
|
685
659
|
}),
|
|
686
660
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
/**
|
|
661
|
+
/**
|
|
690
662
|
* Unpublish an agent (hide from marketplace, can be republished)
|
|
691
663
|
* POST /market/agent/:identifier/unpublish
|
|
692
664
|
*/
|
|
693
|
-
unpublishAgent: agentProcedure
|
|
665
|
+
unpublishAgent: agentProcedure
|
|
694
666
|
.input(z.object({ identifier: z.string() }))
|
|
695
667
|
.mutation(async ({ input, ctx }) => {
|
|
696
668
|
log('unpublishAgent input: %O', input);
|
|
@@ -134,7 +134,7 @@ const publishOrCreateGroupSchema = z.object({
|
|
|
134
134
|
})
|
|
135
135
|
.optional(),
|
|
136
136
|
description: z.string(),
|
|
137
|
-
identifier: z.string().
|
|
137
|
+
identifier: z.string().nullish(), // Allow null or undefined
|
|
138
138
|
memberAgents: z.array(memberAgentSchema),
|
|
139
139
|
name: z.string(),
|
|
140
140
|
visibility: z.enum(['public', 'private', 'internal']).optional(),
|
|
@@ -200,12 +200,11 @@ export const agentGroupRouter = router({
|
|
|
200
200
|
}
|
|
201
201
|
}),
|
|
202
202
|
|
|
203
|
-
|
|
204
203
|
/**
|
|
205
204
|
* Deprecate agent group
|
|
206
205
|
* POST /market/agent-group/:identifier/deprecate
|
|
207
206
|
*/
|
|
208
|
-
deprecateAgentGroup: agentGroupProcedure
|
|
207
|
+
deprecateAgentGroup: agentGroupProcedure
|
|
209
208
|
.input(z.object({ identifier: z.string() }))
|
|
210
209
|
.mutation(async ({ input, ctx }) => {
|
|
211
210
|
log('deprecateAgentGroup input: %O', input);
|
|
@@ -259,13 +258,11 @@ deprecateAgentGroup: agentGroupProcedure
|
|
|
259
258
|
}
|
|
260
259
|
}),
|
|
261
260
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
/**
|
|
261
|
+
/**
|
|
265
262
|
* Fork an agent group
|
|
266
263
|
* POST /market/agent-group/:identifier/fork
|
|
267
264
|
*/
|
|
268
|
-
forkAgentGroup: agentGroupProcedure
|
|
265
|
+
forkAgentGroup: agentGroupProcedure
|
|
269
266
|
.input(
|
|
270
267
|
z.object({
|
|
271
268
|
identifier: z.string(),
|
|
@@ -338,13 +335,11 @@ forkAgentGroup: agentGroupProcedure
|
|
|
338
335
|
}
|
|
339
336
|
}),
|
|
340
337
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
/**
|
|
338
|
+
/**
|
|
344
339
|
* Get the fork source of an agent group
|
|
345
340
|
* GET /market/agent-group/:identifier/fork-source
|
|
346
341
|
*/
|
|
347
|
-
getAgentGroupForkSource: agentGroupProcedure
|
|
342
|
+
getAgentGroupForkSource: agentGroupProcedure
|
|
348
343
|
.input(z.object({ identifier: z.string() }))
|
|
349
344
|
.query(async ({ input, ctx }) => {
|
|
350
345
|
log('getAgentGroupForkSource input: %O', input);
|
|
@@ -398,13 +393,11 @@ getAgentGroupForkSource: agentGroupProcedure
|
|
|
398
393
|
}
|
|
399
394
|
}),
|
|
400
395
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
/**
|
|
396
|
+
/**
|
|
404
397
|
* Get all forks of an agent group
|
|
405
398
|
* GET /market/agent-group/:identifier/forks
|
|
406
399
|
*/
|
|
407
|
-
getAgentGroupForks: agentGroupProcedure
|
|
400
|
+
getAgentGroupForks: agentGroupProcedure
|
|
408
401
|
.input(z.object({ identifier: z.string() }))
|
|
409
402
|
.query(async ({ input, ctx }) => {
|
|
410
403
|
log('getAgentGroupForks input: %O', input);
|
|
@@ -458,13 +451,11 @@ getAgentGroupForks: agentGroupProcedure
|
|
|
458
451
|
}
|
|
459
452
|
}),
|
|
460
453
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
/**
|
|
454
|
+
/**
|
|
464
455
|
* Publish agent group
|
|
465
456
|
* POST /market/agent-group/:identifier/publish
|
|
466
457
|
*/
|
|
467
|
-
publishAgentGroup: agentGroupProcedure
|
|
458
|
+
publishAgentGroup: agentGroupProcedure
|
|
468
459
|
.input(z.object({ identifier: z.string() }))
|
|
469
460
|
.mutation(async ({ input, ctx }) => {
|
|
470
461
|
log('publishAgentGroup input: %O', input);
|
|
@@ -518,15 +509,13 @@ publishAgentGroup: agentGroupProcedure
|
|
|
518
509
|
}
|
|
519
510
|
}),
|
|
520
511
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
/**
|
|
512
|
+
/**
|
|
524
513
|
* Unified publish or create agent group flow
|
|
525
514
|
* 1. Check if identifier exists and if current user is owner
|
|
526
515
|
* 2. If not owner or no identifier, create new group
|
|
527
516
|
* 3. Create new version for the group if updating
|
|
528
517
|
*/
|
|
529
|
-
publishOrCreate: agentGroupProcedure
|
|
518
|
+
publishOrCreate: agentGroupProcedure
|
|
530
519
|
.input(publishOrCreateGroupSchema)
|
|
531
520
|
.mutation(async ({ input, ctx }) => {
|
|
532
521
|
log('publishOrCreate input: %O', input);
|
|
@@ -614,12 +603,11 @@ publishOrCreate: agentGroupProcedure
|
|
|
614
603
|
}
|
|
615
604
|
}),
|
|
616
605
|
|
|
617
|
-
|
|
618
606
|
/**
|
|
619
607
|
* Unpublish agent group
|
|
620
608
|
* POST /market/agent-group/:identifier/unpublish
|
|
621
609
|
*/
|
|
622
|
-
unpublishAgentGroup: agentGroupProcedure
|
|
610
|
+
unpublishAgentGroup: agentGroupProcedure
|
|
623
611
|
.input(z.object({ identifier: z.string() }))
|
|
624
612
|
.mutation(async ({ input, ctx }) => {
|
|
625
613
|
log('unpublishAgentGroup input: %O', input);
|
|
@@ -205,7 +205,7 @@ describe('AiAgentService.execAgent - threadId handling', () => {
|
|
|
205
205
|
|
|
206
206
|
expect(assistantMessageCall).toBeDefined();
|
|
207
207
|
expect(assistantMessageCall![0].threadId).toBeUndefined();
|
|
208
|
-
});
|
|
208
|
+
}, 10_000);
|
|
209
209
|
});
|
|
210
210
|
|
|
211
211
|
describe('when appContext is undefined', () => {
|
|
@@ -247,6 +247,6 @@ describe('AiAgentService.execAgent - threadId handling', () => {
|
|
|
247
247
|
|
|
248
248
|
// Verify groupId is passed to AgentRuntimeService (checked in appContext)
|
|
249
249
|
// This is handled by the createOperation call
|
|
250
|
-
});
|
|
250
|
+
}, 10_000);
|
|
251
251
|
});
|
|
252
252
|
});
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Default maximum length for tool execution result content (in characters)
|
|
8
8
|
* This prevents context overflow when sending results back to LLM
|
|
9
|
-
* @default 6000 characters (~1,500 tokens for English, ~3,000 tokens for Chinese)
|
|
10
9
|
*/
|
|
11
|
-
export const DEFAULT_TOOL_RESULT_MAX_LENGTH =
|
|
10
|
+
export const DEFAULT_TOOL_RESULT_MAX_LENGTH = 25_000;
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Truncate tool result content if it exceeds the maximum length
|
|
@@ -21,8 +20,6 @@ export const DEFAULT_TOOL_RESULT_MAX_LENGTH = 6000;
|
|
|
21
20
|
export function truncateToolResult(content: string, maxLength?: number): string {
|
|
22
21
|
const limit = maxLength ?? DEFAULT_TOOL_RESULT_MAX_LENGTH;
|
|
23
22
|
|
|
24
|
-
console.log('content-limit', content, limit);
|
|
25
|
-
|
|
26
23
|
if (!content || content.length <= limit) {
|
|
27
24
|
return content;
|
|
28
25
|
}
|
|
@@ -139,8 +139,8 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
139
139
|
{
|
|
140
140
|
payload: {
|
|
141
141
|
tasks: [
|
|
142
|
-
{ agentId: TEST_IDS.AGENT_1_ID,
|
|
143
|
-
{ agentId: TEST_IDS.AGENT_2_ID,
|
|
142
|
+
{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' },
|
|
143
|
+
{ agentId: TEST_IDS.AGENT_2_ID, instruction: 'Task 2', title: 'Task 2 Title' },
|
|
144
144
|
],
|
|
145
145
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
146
146
|
},
|
|
@@ -187,8 +187,8 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
187
187
|
{
|
|
188
188
|
payload: {
|
|
189
189
|
tasks: [
|
|
190
|
-
{ agentId: TEST_IDS.AGENT_1_ID,
|
|
191
|
-
{ agentId: TEST_IDS.AGENT_2_ID,
|
|
190
|
+
{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' },
|
|
191
|
+
{ agentId: TEST_IDS.AGENT_2_ID, instruction: 'Task 2', title: 'Task 2 Title' },
|
|
192
192
|
],
|
|
193
193
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
194
194
|
},
|
|
@@ -263,8 +263,8 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
263
263
|
{
|
|
264
264
|
payload: {
|
|
265
265
|
tasks: [
|
|
266
|
-
{ agentId: TEST_IDS.AGENT_1_ID,
|
|
267
|
-
{ agentId: TEST_IDS.AGENT_2_ID,
|
|
266
|
+
{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' },
|
|
267
|
+
{ agentId: TEST_IDS.AGENT_2_ID, instruction: 'Task 2', title: 'Task 2 Title' },
|
|
268
268
|
],
|
|
269
269
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
270
270
|
},
|
|
@@ -327,8 +327,8 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
327
327
|
{
|
|
328
328
|
payload: {
|
|
329
329
|
tasks: [
|
|
330
|
-
{ agentId: TEST_IDS.AGENT_1_ID,
|
|
331
|
-
{ agentId: TEST_IDS.AGENT_2_ID,
|
|
330
|
+
{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' },
|
|
331
|
+
{ agentId: TEST_IDS.AGENT_2_ID, instruction: 'Task 2', title: 'Task 2 Title' },
|
|
332
332
|
],
|
|
333
333
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
334
334
|
},
|
|
@@ -386,8 +386,8 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
386
386
|
{
|
|
387
387
|
payload: {
|
|
388
388
|
tasks: [
|
|
389
|
-
{ agentId: TEST_IDS.AGENT_1_ID,
|
|
390
|
-
{ agentId: TEST_IDS.AGENT_2_ID,
|
|
389
|
+
{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' },
|
|
390
|
+
{ agentId: TEST_IDS.AGENT_2_ID, instruction: 'Task 2', title: 'Task 2 Title' },
|
|
391
391
|
],
|
|
392
392
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
393
393
|
},
|
|
@@ -445,8 +445,8 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
445
445
|
{
|
|
446
446
|
payload: {
|
|
447
447
|
tasks: [
|
|
448
|
-
{ agentId: TEST_IDS.AGENT_1_ID,
|
|
449
|
-
{ agentId: TEST_IDS.AGENT_2_ID,
|
|
448
|
+
{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' },
|
|
449
|
+
{ agentId: TEST_IDS.AGENT_2_ID, instruction: 'Task 2', title: 'Task 2 Title' },
|
|
450
450
|
],
|
|
451
451
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
452
452
|
},
|
|
@@ -498,7 +498,7 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
498
498
|
const result = await batchExecTasksExecutor(
|
|
499
499
|
{
|
|
500
500
|
payload: {
|
|
501
|
-
tasks: [{ agentId: TEST_IDS.AGENT_1_ID,
|
|
501
|
+
tasks: [{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' }],
|
|
502
502
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
503
503
|
},
|
|
504
504
|
type: 'batch_exec_async_tasks',
|
|
@@ -546,7 +546,7 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
546
546
|
const result = await batchExecTasksExecutor(
|
|
547
547
|
{
|
|
548
548
|
payload: {
|
|
549
|
-
tasks: [{ agentId: TEST_IDS.AGENT_1_ID,
|
|
549
|
+
tasks: [{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' }],
|
|
550
550
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
551
551
|
},
|
|
552
552
|
type: 'batch_exec_async_tasks',
|
|
@@ -604,7 +604,7 @@ describe('createGroupOrchestrationExecutors', () => {
|
|
|
604
604
|
await batchExecTasksExecutor(
|
|
605
605
|
{
|
|
606
606
|
payload: {
|
|
607
|
-
tasks: [{ agentId: TEST_IDS.AGENT_1_ID,
|
|
607
|
+
tasks: [{ agentId: TEST_IDS.AGENT_1_ID, instruction: 'Task 1', title: 'Task 1 Title' }],
|
|
608
608
|
toolMessageId: TEST_IDS.TOOL_MESSAGE_ID,
|
|
609
609
|
},
|
|
610
610
|
type: 'batch_exec_async_tasks',
|
|
@@ -369,14 +369,17 @@ export const createGroupOrchestrationExecutors = (
|
|
|
369
369
|
*
|
|
370
370
|
* Returns: task_completed result
|
|
371
371
|
*/
|
|
372
|
-
exec_async_task: async (
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
exec_async_task: async (
|
|
373
|
+
supervisorInstruction,
|
|
374
|
+
state,
|
|
375
|
+
): Promise<GroupOrchestrationExecutorOutput> => {
|
|
376
|
+
const { agentId, instruction, timeout, title, toolMessageId } = (
|
|
377
|
+
supervisorInstruction as SupervisorInstructionExecAsyncTask
|
|
375
378
|
).payload;
|
|
376
379
|
|
|
377
380
|
const sessionLogId = `${state.operationId}:exec_async_task`;
|
|
378
381
|
log(
|
|
379
|
-
`[${sessionLogId}] Executing async task for agent: ${agentId},
|
|
382
|
+
`[${sessionLogId}] Executing async task for agent: ${agentId}, instruction: ${instruction}, timeout: ${timeout}`,
|
|
380
383
|
);
|
|
381
384
|
|
|
382
385
|
const { groupId, topicId } = messageContext;
|
|
@@ -400,7 +403,7 @@ export const createGroupOrchestrationExecutors = (
|
|
|
400
403
|
agentId,
|
|
401
404
|
content: '',
|
|
402
405
|
groupId,
|
|
403
|
-
metadata: { instruction
|
|
406
|
+
metadata: { instruction, taskTitle: title },
|
|
404
407
|
parentId: toolMessageId,
|
|
405
408
|
role: 'task',
|
|
406
409
|
topicId,
|
|
@@ -427,7 +430,7 @@ export const createGroupOrchestrationExecutors = (
|
|
|
427
430
|
const createResult = await aiAgentService.execSubAgentTask({
|
|
428
431
|
agentId,
|
|
429
432
|
groupId,
|
|
430
|
-
instruction
|
|
433
|
+
instruction,
|
|
431
434
|
parentMessageId: taskMessageId,
|
|
432
435
|
title,
|
|
433
436
|
topicId,
|
|
@@ -600,9 +603,12 @@ export const createGroupOrchestrationExecutors = (
|
|
|
600
603
|
*
|
|
601
604
|
* Returns: task_completed result
|
|
602
605
|
*/
|
|
603
|
-
exec_client_async_task: async (
|
|
604
|
-
|
|
605
|
-
|
|
606
|
+
exec_client_async_task: async (
|
|
607
|
+
supervisorInstruction,
|
|
608
|
+
state,
|
|
609
|
+
): Promise<GroupOrchestrationExecutorOutput> => {
|
|
610
|
+
const { agentId, instruction, title, toolMessageId } = (
|
|
611
|
+
supervisorInstruction as SupervisorInstructionExecClientAsyncTask
|
|
606
612
|
).payload;
|
|
607
613
|
|
|
608
614
|
const sessionLogId = `${state.operationId}:exec_client_async_task`;
|
|
@@ -629,7 +635,7 @@ export const createGroupOrchestrationExecutors = (
|
|
|
629
635
|
agentId,
|
|
630
636
|
content: '',
|
|
631
637
|
groupId,
|
|
632
|
-
metadata: { instruction
|
|
638
|
+
metadata: { instruction, taskTitle: title },
|
|
633
639
|
parentId: toolMessageId,
|
|
634
640
|
role: 'task',
|
|
635
641
|
topicId,
|
|
@@ -656,7 +662,7 @@ export const createGroupOrchestrationExecutors = (
|
|
|
656
662
|
// Use Group-specific API that handles different agentIds in thread context
|
|
657
663
|
const threadResult = await aiAgentService.createClientGroupAgentTaskThread({
|
|
658
664
|
groupId: groupId!,
|
|
659
|
-
instruction
|
|
665
|
+
instruction,
|
|
660
666
|
parentMessageId: taskMessageId,
|
|
661
667
|
subAgentId: agentId,
|
|
662
668
|
title,
|
|
@@ -861,9 +867,9 @@ export const createGroupOrchestrationExecutors = (
|
|
|
861
867
|
interface TaskTracker {
|
|
862
868
|
agentId: string;
|
|
863
869
|
error?: string;
|
|
870
|
+
instruction: string;
|
|
864
871
|
result?: string;
|
|
865
872
|
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
866
|
-
task: string;
|
|
867
873
|
taskMessageId?: string;
|
|
868
874
|
threadId?: string;
|
|
869
875
|
timeout: number;
|
|
@@ -873,7 +879,7 @@ export const createGroupOrchestrationExecutors = (
|
|
|
873
879
|
const taskTrackers: TaskTracker[] = tasks.map((t) => ({
|
|
874
880
|
agentId: t.agentId,
|
|
875
881
|
status: 'pending',
|
|
876
|
-
|
|
882
|
+
instruction: t.instruction,
|
|
877
883
|
timeout: t.timeout || 1_800_000, // Default 30 minutes
|
|
878
884
|
title: t.title,
|
|
879
885
|
}));
|
|
@@ -887,8 +893,9 @@ export const createGroupOrchestrationExecutors = (
|
|
|
887
893
|
{
|
|
888
894
|
agentId: tracker.agentId,
|
|
889
895
|
content: '',
|
|
896
|
+
createdAt: Date.now() + index,
|
|
890
897
|
groupId,
|
|
891
|
-
metadata: { instruction: tracker.
|
|
898
|
+
metadata: { instruction: tracker.instruction, taskTitle: tracker.title },
|
|
892
899
|
parentId: toolMessageId,
|
|
893
900
|
role: 'task',
|
|
894
901
|
topicId,
|
|
@@ -922,7 +929,7 @@ export const createGroupOrchestrationExecutors = (
|
|
|
922
929
|
const createResult = await aiAgentService.execSubAgentTask({
|
|
923
930
|
agentId: tracker.agentId,
|
|
924
931
|
groupId,
|
|
925
|
-
instruction: tracker.
|
|
932
|
+
instruction: tracker.instruction,
|
|
926
933
|
parentMessageId: tracker.taskMessageId,
|
|
927
934
|
title: tracker.title,
|
|
928
935
|
topicId,
|