Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: bump next to `16.1.5` to fix CVE-2026-23864 (#11886)

Arvin Xu7d9e6906469d
diff --git a/package.json b/package.json
index dfef5c3ad61..eb709483e6d 100644
--- a/package.json
+++ b/package.json
@@ -211,7 +211,7 @@
"@modelcontextprotocol/sdk": "^1.25.3",
"@napi-rs/canvas": "^0.1.88",
"@neondatabase/serverless": "^1.0.2",
- "@next/third-parties": "^16.1.4",
+ "@next/third-parties": "^16.1.5",
"@opentelemetry/exporter-jaeger": "^2.5.0",
"@opentelemetry/winston-transport": "^0.19.0",
"@react-pdf/renderer": "^4.3.2",
@@ -280,7 +280,7 @@
"model-bank": "workspace:*",
"motion": "^12.29.0",
"nanoid": "^5.1.6",
- "next": "^16.1.4",
+ "next": "^16.1.5",
"next-mdx-remote": "^5.0.0",
"next-themes": "^0.4.6",
"nextjs-toploader": "^3.9.17",
@@ -369,8 +369,8 @@
"@lobehub/lint": "^1.26.3",
"@lobehub/market-types": "^1.12.3",
"@lobehub/seo-cli": "^1.7.0",
- "@next/bundle-analyzer": "^16.1.4",
- "@next/eslint-plugin-next": "^16.1.4",
+ "@next/bundle-analyzer": "^16.1.5",
+ "@next/eslint-plugin-next": "^16.1.5",
"@peculiar/webcrypto": "^1.5.0",
"@playwright/test": "^1.58.0",
"@prettier/sync": "^0.6.1",
diff --git a/packages/types/src/agentGroup/index.ts b/packages/types/src/agentGroup/index.ts
index 0bfb889b414..f4ea5bb99d9 100644
--- a/packages/types/src/agentGroup/index.ts
+++ b/packages/types/src/agentGroup/index.ts
@@ -356,6 +356,11 @@ export interface TaskStatusResult {
currentActivity?: TaskCurrentActivity;
/** Error message if task failed */
error?: string;
+ /**
+ * Parsed UI messages from conversation-flow
+ * Used for displaying intermediate steps in server task
+ */
+ messages?: UIChatMessage[];
/** Task result content (last assistant message) */
result?: string;
/** Current task status */
diff --git a/src/server/routers/lambda/aiAgent.ts b/src/server/routers/lambda/aiAgent.ts
index e5b4542d26b..faf0a03b20c 100644
--- a/src/server/routers/lambda/aiAgent.ts
+++ b/src/server/routers/lambda/aiAgent.ts
@@ -1,4 +1,5 @@
import { type AgentRuntimeContext } from '@lobechat/agent-runtime';
+import { parse } from '@lobechat/conversation-flow';
import {
type TaskCurrentActivity,
type TaskStatusResult,
@@ -252,23 +253,26 @@ const aiAgentProcedure = authedProcedure.use(serverDatabase).use(async (opts) =>
export const aiAgentRouter = router({
/**
- * Create Thread for client-side task execution
+ * Create Thread for client-side task execution in Group mode
*
- * This endpoint is called by desktop client when runInClient=true.
- * It creates the Thread but does NOT execute the task - execution happens on client side.
+ * This endpoint is specifically designed for Group Chat scenarios where:
+ * - Messages in the thread may have different agentIds (supervisor, workers)
+ * - The subAgentId is the worker agent that executes the task
+ * - Thread messages query should not filter by agentId to include all parent messages
*/
- createClientTaskThread: aiAgentProcedure
- .input(CreateClientTaskThreadSchema)
+ createClientGroupAgentTaskThread: aiAgentProcedure
+ .input(CreateClientGroupAgentTaskThreadSchema)
.mutation(async ({ input, ctx }) => {
- const { agentId, groupId, instruction, parentMessageId, title, topicId } = input;
+ const { groupId, instruction, parentMessageId, subAgentId, title, topicId } = input;
- log('createClientTaskThread: agentId=%s, groupId=%s', agentId, groupId);
+ log('createClientGroupAgentTaskThread: subAgentId=%s, groupId=%s', subAgentId, groupId);
try {
// 1. Create Thread for isolated task execution
+ // Use subAgentId as the thread's agentId (the executing agent)
const startedAt = new Date().toISOString();
const thread = await ctx.threadModel.create({
- agentId,
+ agentId: subAgentId,
groupId,
metadata: { clientMode: true, startedAt },
sourceMessageId: parentMessageId,
@@ -285,11 +289,12 @@ export const aiAgentRouter = router({
});
}
- log('createClientTaskThread: created thread %s', thread.id);
+ log('createClientGroupAgentTaskThread: created thread %s', thread.id);
// 2. Create initial user message (persisted to database)
+ // Use subAgentId as the message's agentId
const userMessage = await ctx.messageModel.create({
- agentId,
+ agentId: subAgentId,
content: instruction,
groupId,
parentId: parentMessageId,
@@ -298,19 +303,21 @@ export const aiAgentRouter = router({
topicId,
});
- log('createClientTaskThread: created user message %s', userMessage.id);
+ log('createClientGroupAgentTaskThread: created user message %s', userMessage.id);
// 3. Query thread messages and main chat messages in parallel
const [threadMessages, messages] = await Promise.all([
// Thread messages (messages within this thread)
- ctx.messageModel.query({ agentId, threadId: thread.id, topicId }),
- // Main chat messages (messages without threadId, includes updated taskDetail)
- // Pass both agentId and groupId - query() prioritizes groupId when present
- ctx.messageModel.query({ agentId, groupId, topicId }),
+ // DON'T pass agentId - thread query fetches parent messages via sourceMessageId
+ // which may have different agentIds (supervisor vs worker in group chat)
+ ctx.messageModel.query({ threadId: thread.id, topicId }),
+ // Main chat messages (messages without threadId)
+ // Only filter by groupId + topicId (not agentId) to include all agents' messages
+ ctx.messageModel.query({ groupId, topicId }),
]);
log(
- 'createClientTaskThread: queried %d thread messages, %d main messages',
+ 'createClientGroupAgentTaskThread: queried %d thread messages, %d main messages',
threadMessages.length,
messages.length,
);
@@ -325,7 +332,7 @@ export const aiAgentRouter = router({
userMessageId: userMessage.id,
};
} catch (error: any) {
- log('createClientTaskThread failed: %O', error);
+ log('createClientGroupAgentTaskThread failed: %O', error);
if (error instanceof TRPCError) {
throw error;
@@ -334,32 +341,29 @@ export const aiAgentRouter = router({
throw new TRPCError({
cause: error,
code: 'INTERNAL_SERVER_ERROR',
- message: `Failed to create client task thread: ${error.message}`,
+ message: `Failed to create client group agent task thread: ${error.message}`,
});
}
}),
/**
- * Create Thread for client-side task execution in Group mode
+ * Create Thread for client-side task execution
*
- * This endpoint is specifically designed for Group Chat scenarios where:
- * - Messages in the thread may have different agentIds (supervisor, workers)
- * - The subAgentId is the worker agent that executes the task
- * - Thread messages query should not filter by agentId to include all parent messages
+ * This endpoint is called by desktop client when runInClient=true.
+ * It creates the Thread but does NOT execute the task - execution happens on client side.
*/
- createClientGroupAgentTaskThread: aiAgentProcedure
- .input(CreateClientGroupAgentTaskThreadSchema)
+ createClientTaskThread: aiAgentProcedure
+ .input(CreateClientTaskThreadSchema)
.mutation(async ({ input, ctx }) => {
- const { groupId, instruction, parentMessageId, subAgentId, title, topicId } = input;
+ const { agentId, groupId, instruction, parentMessageId, title, topicId } = input;
- log('createClientGroupAgentTaskThread: subAgentId=%s, groupId=%s', subAgentId, groupId);
+ log('createClientTaskThread: agentId=%s, groupId=%s', agentId, groupId);
try {
// 1. Create Thread for isolated task execution
- // Use subAgentId as the thread's agentId (the executing agent)
const startedAt = new Date().toISOString();
const thread = await ctx.threadModel.create({
- agentId: subAgentId,
+ agentId,
groupId,
metadata: { clientMode: true, startedAt },
sourceMessageId: parentMessageId,
@@ -376,12 +380,11 @@ export const aiAgentRouter = router({
});
}
- log('createClientGroupAgentTaskThread: created thread %s', thread.id);
+ log('createClientTaskThread: created thread %s', thread.id);
// 2. Create initial user message (persisted to database)
- // Use subAgentId as the message's agentId
const userMessage = await ctx.messageModel.create({
- agentId: subAgentId,
+ agentId,
content: instruction,
groupId,
parentId: parentMessageId,
@@ -390,21 +393,19 @@ export const aiAgentRouter = router({
topicId,
});
- log('createClientGroupAgentTaskThread: created user message %s', userMessage.id);
+ log('createClientTaskThread: created user message %s', userMessage.id);
// 3. Query thread messages and main chat messages in parallel
const [threadMessages, messages] = await Promise.all([
// Thread messages (messages within this thread)
- // DON'T pass agentId - thread query fetches parent messages via sourceMessageId
- // which may have different agentIds (supervisor vs worker in group chat)
- ctx.messageModel.query({ threadId: thread.id, topicId }),
- // Main chat messages (messages without threadId)
- // Only filter by groupId + topicId (not agentId) to include all agents' messages
- ctx.messageModel.query({ groupId, topicId }),
+ ctx.messageModel.query({ agentId, threadId: thread.id, topicId }),
+ // Main chat messages (messages without threadId, includes updated taskDetail)
+ // Pass both agentId and groupId - query() prioritizes groupId when present
+ ctx.messageModel.query({ agentId, groupId, topicId }),
]);
log(
- 'createClientGroupAgentTaskThread: queried %d thread messages, %d main messages',
+ 'createClientTaskThread: queried %d thread messages, %d main messages',
threadMessages.length,
messages.length,
);
@@ -419,7 +420,7 @@ export const aiAgentRouter = router({
userMessageId: userMessage.id,
};
} catch (error: any) {
- log('createClientGroupAgentTaskThread failed: %O', error);
+ log('createClientTaskThread failed: %O', error);
if (error instanceof TRPCError) {
throw error;
@@ -428,7 +429,7 @@ export const aiAgentRouter = router({
throw new TRPCError({
cause: error,
code: 'INTERNAL_SERVER_ERROR',
- message: `Failed to create client group agent task thread: ${error.message}`,
+ message: `Failed to create client task thread: ${error.message}`,
});
}
}),
@@ -907,6 +908,9 @@ export const aiAgentRouter = router({
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
);
+ // 6.1 Parse messages using conversation-flow for UI display
+ const { flatList: parsedMessages } = parse(threadMessages);
+
// 7. Get result content when task is completed or failed
let resultContent: string | undefined;
if (updatedTaskStatus === 'completed' || updatedTaskStatus === 'failed') {
@@ -974,6 +978,7 @@ export const aiAgentRouter = router({
(updatedMetadata?.totalCost ? { total: updatedMetadata.totalCost } : undefined),
currentActivity,
error: updatedMetadata?.error ?? realtimeStatus?.currentState?.error,
+ messages: parsedMessages,
result: resultContent,
status: updatedTaskStatus,
stepCount: realtimeStatus?.currentState?.stepCount,
diff --git a/src/server/services/changelog/index.test.ts b/src/server/services/changelog/index.test.ts
index f8f2fd455d8..42895d610c8 100644
--- a/src/server/services/changelog/index.test.ts
+++ b/src/server/services/changelog/index.test.ts
@@ -35,10 +35,6 @@ vi.mock('semver', async (importOriginal) => {
};
});
-vi.mock('url-join', () => ({
- default: vi.fn((...args) => args.join('/')),
-}));
-
// 模拟 process.env
const originalEnv = process.env;
@@ -282,33 +278,17 @@ describe('ChangelogService', () => {
});
describe('replaceCdnUrl', () => {
- it('should replace URL with CDN URL if available', async () => {
- // 设置环境变量
- process.env.DOC_S3_PUBLIC_DOMAIN = 'https://cdn.example.com';
-
- // 重新导入模块以确保环境变量生效
- const { ChangelogService } = await import('./index');
- const service = new ChangelogService();
-
- service.cdnUrls = { 'https://example.com/image.jpg': 'image-hash.jpg' };
-
+ it('should replace /blog URL with CDN URL', () => {
// @ts-ignore - accessing private method for testing
- const result = service.replaceCdnUrl('https://example.com/image.jpg');
+ const result = service.replaceCdnUrl('/blog/image.jpg');
- expect(result).toBe('https://cdn.example.com/image-hash.jpg');
+ expect(result).toBe('https://hub-apac-1.lobeobjects.space/blog/image.jpg');
});
- it('should return original URL if CDN URL is not available', () => {
- const originalDocCdnPrefix = process.env.DOC_S3_PUBLIC_DOMAIN;
- process.env.DOC_S3_PUBLIC_DOMAIN = 'https://cdn.example.com';
- service.cdnUrls = {};
-
+ it('should return original URL if not starting with /blog', () => {
// @ts-ignore - accessing private method for testing
const result = service.replaceCdnUrl('https://example.com/image.jpg');
expect(result).toBe('https://example.com/image.jpg');
-
- // Restore original value
- process.env.DOC_S3_PUBLIC_DOMAIN = originalDocCdnPrefix;
});
});
});