🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🌐 chore: translate non-English comments to English in packages/openapi/src (#12873)
LobeHub Bot709c9749d0ba
diff --git a/packages/openapi/src/app.ts b/packages/openapi/src/app.tsindex 8e60e042b8e..15099f8fdcb 100644--- a/packages/openapi/src/app.ts+++ b/packages/openapi/src/app.ts@@ -3,27 +3,27 @@ import { cors } from 'hono/cors';import { logger } from 'hono/logger';import { prettyJSON } from 'hono/pretty-json';-// 导入用户认证中间件(支持OIDC和API Key两种认证方式)+// Import user authentication middleware (supports both OIDC and API Key authentication)import { userAuthMiddleware } from './middleware/auth';-// 导入路由+// Import routesimport routes from './routes';-// 创建Hono应用实例+// Create Hono app instanceconst app = new Hono().basePath('/api/v1');-// 全局中间件+// Global middlewareapp.use('*', cors());app.use('*', logger());app.use('*', prettyJSON());-app.use('*', userAuthMiddleware); // 用户认证中间件+app.use('*', userAuthMiddleware); // User authentication middleware-// 错误处理中间件+// Error handling middlewareapp.onError((error: Error, c) => {console.error('Hono Error:', error);return c.json({ error: error.message }, 500);});-// 健康检查端点+// Health check endpointapp.get('/health', (c) => {return c.json({service: 'lobe-chat-api',@@ -32,7 +32,7 @@ app.get('/health', (c) => {});});-// 注册路由+// Register routesObject.entries(routes).forEach(([key, value]) => app.route(`/${key}`, value));export { app as honoApp };diff --git a/packages/openapi/src/helpers/file.ts b/packages/openapi/src/helpers/file.tsindex 4c4e14374f5..aee06dcc43d 100644--- a/packages/openapi/src/helpers/file.ts+++ b/packages/openapi/src/helpers/file.ts@@ -7,19 +7,19 @@ import urlJoin from 'url-join';import { fileEnv } from '@/envs/file';/**- * 给文件添加URL前缀- * @param file 文件对象- * @returns 添加了URL前缀的文件对象+ * Add URL prefix to a file+ * @param file File object+ * @returns File object with URL prefix added*/export function addFileUrlPrefix<T extends { url?: string }>(file: T): T {- // 从 fileEnv 中获取公共域名前缀+ // Get the public domain prefix from fileEnvconst publicDomain = fileEnv.S3_PUBLIC_DOMAIN;if (!publicDomain) {return file;}- // 如果已经有完整的URL,直接返回+ // If the URL is already a full URL, return it directlyif (file.url && (file.url.startsWith('http://') || file.url.startsWith('https://'))) {return file;}@@ -31,17 +31,17 @@ export function addFileUrlPrefix<T extends { url?: string }>(file: T): T {}/**- * 批量给文件数组添加URL前缀- * @param files 文件数组- * @returns 添加了URL前缀的文件数组+ * Add URL prefix to an array of files+ * @param files Array of file objects+ * @returns Array of file objects with URL prefix added*/export function addFilesUrlPrefix<T extends { path?: string; url?: string }>(files: T[]): T[] {return files.map(addFileUrlPrefix);}/**- * 通用的 multipart/form-data 解析器- * 当原生 formData() 失败时的备用方案+ * Generic multipart/form-data parser+ * Fallback when the native formData() fails*/export async function parseFormData(c: Context): Promise<FormData> {const contentType = c.req.header('content-type') || '';@@ -49,7 +49,7 @@ export async function parseFormData(c: Context): Promise<FormData> {throw new Error('Content-Type 必须是 multipart/form-data');}- // 优先使用 formidable(流式、健壮),失败时回退到原生 formData()+ // Prefer formidable (streaming, robust); fall back to native formData() on failuretry {const webReq = c.req.raw as Request;const webBody = webReq.body;@@ -57,14 +57,14 @@ export async function parseFormData(c: Context): Promise<FormData> {throw new Error('解析失败:当前请求缺少可读的 body 流');}- // 将 Web ReadableStream 转为 Node Readable(Node 18+)+ // Convert Web ReadableStream to Node Readable (Node 18+)const nodeReadable =typeof Readable?.fromWeb === 'function' ? Readable.fromWeb(webBody as any) : null;if (!nodeReadable) {throw new Error('解析失败:运行时不支持 Readable.fromWeb,将不进行回退');}- // 构造最小化 Node-like IncomingMessage 供 formidable 使用+ // Construct a minimal Node-like IncomingMessage for formidableconst fakeReq: any = nodeReadable;fakeReq.headers = Object.fromEntries((webReq.headers as any) || []);fakeReq.method = webReq.method;@@ -76,7 +76,7 @@ export async function parseFormData(c: Context): Promise<FormData> {const chunks: Buffer[] = [];pass.on('data', (d: Buffer) => chunks.push(Buffer.isBuffer(d) ? d : Buffer.from(d)));pass.on('end', function (this: any) {- // 把合并后的 buffer 暂存,供 parse 回调读取+ // Store the merged buffer temporarily for the parse callback to readthis._buffer = Buffer.concat(chunks);});return pass;@@ -96,13 +96,13 @@ export async function parseFormData(c: Context): Promise<FormData> {const fd = new FormData();- // 追加普通字段(多值逐项 append)+ // Append regular fields (append each value individually for multi-value fields)for (const [name, value] of Object.entries(fields)) {if (Array.isArray(value)) value.forEach((v) => fd.append(name, String(v)));else fd.append(name, String(value));}- // 追加文件字段(兼容单值/多值)+ // Append file fields (compatible with single-value and multi-value)for (const [name, entry] of Object.entries(files)) {const list = Array.isArray(entry) ? entry : [entry];for (const f of list) {@@ -124,7 +124,7 @@ export async function parseFormData(c: Context): Promise<FormData> {return fd;} catch (e) {- // 保持失败即抛错,让上层按统一异常处理返回+ // Re-throw the error to let the caller handle it via unified exception handlingthrow e instanceof Error ? e : new Error('parseFormData 解析失败');}}diff --git a/packages/openapi/src/helpers/pagination.ts b/packages/openapi/src/helpers/pagination.tsindex c80a4f79396..9faa8d8772f 100644--- a/packages/openapi/src/helpers/pagination.ts+++ b/packages/openapi/src/helpers/pagination.ts@@ -3,9 +3,9 @@ import type { IPaginationQuery } from '../types';const DEFAULT_PAGE_SIZE = 20;/**- * 处理分页查询参数- * @param request 查询参数对象- * @returns 如果提供了分页参数,返回 { limit, offset };否则返回空对象+ * Process pagination query parameters+ * @param request Query parameter object+ * @returns { limit, offset } if pagination parameters are provided; otherwise an empty object*/export function processPaginationConditions(request: Record<string, any> & IPaginationQuery): {limit?: number;@@ -13,12 +13,12 @@ export function processPaginationConditions(request: Record<string, any> & IPagi} {const { page, pageSize } = request;- // 如果 page 和 pageSize 都未提供,则不进行分页(返回全部数据)+ // If neither page nor pageSize is provided, skip pagination (return all data)if (page === undefined && pageSize === undefined) {return {};}- // 只传了 page,则默认 pageSize 为 20+ // If only page is provided, default pageSize to 20if (page !== undefined && pageSize === undefined) {return {limit: DEFAULT_PAGE_SIZE,@@ -26,7 +26,7 @@ export function processPaginationConditions(request: Record<string, any> & IPagi};}- // 只传了 pageSize,则默认 page 为 1+ // If only pageSize is provided, default page to 1if (page === undefined && pageSize !== undefined) {return {limit: pageSize,diff --git a/packages/openapi/src/helpers/translate.ts b/packages/openapi/src/helpers/translate.tsindex af1cee63196..406fa9428fb 100644--- a/packages/openapi/src/helpers/translate.ts+++ b/packages/openapi/src/helpers/translate.ts@@ -1,15 +1,15 @@/**- * 从消息内容中移除系统上下文,只保留用户的原始消息+ * Remove system context from message content, keeping only the user's original message*/export function removeSystemContext(content: string): string {if (!content) return content;- // 匹配并移除系统上下文部分+ // Match and remove the system context sectionconst systemContextRegex = /<!-- 系统上下文[\S\s]*?<!-- 系统上下文结束 -->/g;const cleanContent = content.replaceAll(systemContextRegex, '').trim();- // 如果移除后内容为空,返回原内容(防止意外情况)+ // If the content is empty after removal, return the original (guard against unexpected cases)if (!cleanContent) {return content;}diff --git a/packages/openapi/src/routes/agent-groups.route.ts b/packages/openapi/src/routes/agent-groups.route.tsindex 80c20be706d..4ac5ecdc86a 100644--- a/packages/openapi/src/routes/agent-groups.route.ts+++ b/packages/openapi/src/routes/agent-groups.route.ts@@ -12,13 +12,13 @@ import {UpdateAgentGroupRequestSchema,} from '../types/agent-group.type';-// AgentGroup 相关路由(助理分类)+// AgentGroup-related routes (agent groups)const AgentGroupRoutes = new Hono();/**- * 获取助理分类列表+ * Get agent group list* GET /api/v1/agent-groups- * 需要助理读取权限+ * Requires agent read permission*/AgentGroupRoutes.get('/',@@ -31,9 +31,9 @@ AgentGroupRoutes.get();/**- * 创建助理分类+ * Create an agent group* POST /api/v1/agent-groups- * 需要助理创建权限+ * Requires agent create permission*/AgentGroupRoutes.post('/',@@ -47,9 +47,9 @@ AgentGroupRoutes.post();/**- * 根据 ID 获取助理分类详情+ * Get agent group details by ID* GET /api/v1/agent-groups/:id- * 需要助理读取权限+ * Requires agent read permission*/AgentGroupRoutes.get('/:id',@@ -63,9 +63,9 @@ AgentGroupRoutes.get();/**- * 更新助理分类+ * Update an agent group* PATCH /api/v1/agent-groups/:id- * 需要助理更新权限+ * Requires agent update permission*/AgentGroupRoutes.patch('/:id',@@ -80,13 +80,13 @@ AgentGroupRoutes.patch();/**- * 删除助理分类+ * Delete an agent group* DELETE /api/v1/agent-groups/:id- * 需要助理删除权限+ * Requires agent delete permission*- * 行为说明:- * - 删除指定的助理分类- * - 分类内助理不会被删除,会自动变为未分类状态(sessionGroupId 设为 null)+ * Behavior:+ * - Deletes the specified agent group+ * - Agents within the group are not deleted; they become uncategorized (sessionGroupId set to null)*/AgentGroupRoutes.delete('/:id',diff --git a/packages/openapi/src/routes/agents.route.ts b/packages/openapi/src/routes/agents.route.tsindex 9d7981326a5..a27f6758d84 100644--- a/packages/openapi/src/routes/agents.route.ts+++ b/packages/openapi/src/routes/agents.route.ts@@ -13,13 +13,13 @@ import {UpdateAgentRequestSchema,} from '../types/agent.type';-// Agent 相关路由+// Agent-related routesconst AgentRoutes = new Hono();/**- * 获取系统中的 Agent 列表+ * Get the list of Agents in the system* GET /api/v1/agents- * 需要 Agent 读取权限+ * Requires Agent read permission*/AgentRoutes.get('/',@@ -36,9 +36,9 @@ AgentRoutes.get();/**- * 创建智能体+ * Create an Agent* POST /api/v1/agents- * 需要 Agent 创建权限+ * Requires Agent create permission*/AgentRoutes.post('/',@@ -55,9 +55,9 @@ AgentRoutes.post();/**- * 根据 ID 获取 Agent 详情+ * Get Agent details by ID* GET /api/v1/agents/:id- * 需要 Agent 读取权限+ * Requires Agent read permission*/AgentRoutes.get('/:id',@@ -74,9 +74,9 @@ AgentRoutes.get();/**- * 更新智能体+ * Update an Agent* PUT /api/v1/agents/:id- * 需要 Agent 更新权限+ * Requires Agent update permission*/AgentRoutes.patch('/:id',@@ -94,9 +94,9 @@ AgentRoutes.patch();/**- * 删除智能体+ * Delete an Agent* DELETE /api/v1/agents/:id- * 需要 Agent 删除权限(仅管理员)+ * Requires Agent delete permission (admin only)*/AgentRoutes.delete('/:id',diff --git a/packages/openapi/src/routes/files.route.ts b/packages/openapi/src/routes/files.route.tsindex a06da94fca6..a3637892c26 100644--- a/packages/openapi/src/routes/files.route.ts+++ b/packages/openapi/src/routes/files.route.ts@@ -19,18 +19,18 @@ import {const app = new Hono();/**- * 获取文件列表+ * Get file list* GET /files** Query parameters:- * - page: number (optional) - 页码,默认1- * - pageSize: number (optional) - 每页数量,默认20,最大100- * - fileType: string (optional) - 文件类型过滤- * - keyword: string (optional) - 搜索关键词- * - userId: string (optional) - 用户ID,如果提供则获取指定用户文件- * - knowledgeBaseId: string (optional) - 知识库ID,筛选属于指定知识库的文件- * - updatedAtStart: string (optional) - 更新时间起始(ISO 8601格式,如:2024-01-01T00:00:00Z)- * - updatedAtEnd: string (optional) - 更新时间结束(ISO 8601格式,如:2024-12-31T23:59:59Z)+ * - page: number (optional) - Page number, default 1+ * - pageSize: number (optional) - Items per page, default 20, max 100+ * - fileType: string (optional) - File type filter+ * - keyword: string (optional) - Search keyword+ * - userId: string (optional) - User ID; if provided, returns files for the specified user+ * - knowledgeBaseId: string (optional) - Knowledge base ID, filter files belonging to the specified knowledge base+ * - updatedAtStart: string (optional) - Update time start (ISO 8601 format, e.g. 2024-01-01T00:00:00Z)+ * - updatedAtEnd: string (optional) - Update time end (ISO 8601 format, e.g. 2024-12-31T23:59:59Z)*/app.get('/',@@ -44,19 +44,19 @@ app.get();/**- * 文件上传并返回相应的文件- * 文件的 URL 根据 S3 类型自动生成,是否可以访问取决于 S3 的权限设置+ * Upload a file and return the corresponding file record+ * The file URL is auto-generated based on the S3 type; accessibility depends on S3 permission settings* POST /files* Content-Type: multipart/form-data** Form fields:- * - file: File (required) - 要上传的文件- * - knowledgeBaseId: string (optional) - 知识库ID- * - agentId: string (optional) - Agent ID,优先解析为 sessionId 并关联文件- * - sessionId: string (optional) - 会话ID,如果提供则创建文件和会话的关联关系- * - skipCheckFileType: boolean (optional) - 是否跳过文件类型检查- * - directory: string (optional) - 上传目录- * - skipExist: boolean (optional) - 是否跳过已存在的解析结果,默认false+ * - file: File (required) - The file to upload+ * - knowledgeBaseId: string (optional) - Knowledge base ID+ * - agentId: string (optional) - Agent ID; resolved to sessionId first for file association+ * - sessionId: string (optional) - Session ID; if provided, creates a file-session association+ * - skipCheckFileType: boolean (optional) - Whether to skip file type check+ * - directory: string (optional) - Upload directory+ * - skipExist: boolean (optional) - Whether to skip existing parse results, default false*/app.post('/',@@ -69,11 +69,11 @@ app.post();/**- * 获取文件详情+ * Get file details* GET /files/:id** Path parameters:- * - id: string (required) - 文件ID+ * - id: string (required) - File ID*/app.get('/:id',@@ -87,14 +87,14 @@ app.get();/**- * 获取文件访问URL+ * Get file access URL* GET /files/:id/url** Path parameters:- * - id: string (required) - 文件ID+ * - id: string (required) - File ID** Query parameters:- * - expiresIn: number (optional) - URL过期时间(秒),默认3600+ * - expiresIn: number (optional) - URL expiration time (seconds), default 3600*/app.get('/:id/url',@@ -109,15 +109,15 @@ app.get();/**- * 更新文件+ * Update a file* PATCH /files/:id** Path parameters:- * - id: string (required) - 文件ID+ * - id: string (required) - File ID** Request body (JSON):* {- * "knowledgeBaseId": "kb-id" | null (optional) - 知识库ID,传 null 表示取消关联+ * "knowledgeBaseId": "kb-id" | null (optional) - Knowledge base ID; pass null to remove association* }*/app.patch(@@ -133,11 +133,11 @@ app.patch();/**- * 删除文件+ * Delete a file* DELETE /files/:id** Path parameters:- * - id: string (required) - 文件ID+ * - id: string (required) - File ID*/app.delete('/:id',@@ -151,19 +151,19 @@ app.delete();/**- * 解析文件内容+ * Parse file content* POST /files/:id/parses** Path parameters:- * - id: string (required) - 文件ID+ * - id: string (required) - File ID** Query parameters:- * - skipExist: boolean (optional) - 是否跳过已存在的解析结果,默认false+ * - skipExist: boolean (optional) - Whether to skip existing parse results, default false*- * 功能:- * - 解析文档文件的文本内容(PDF、Word、Excel等)- * - 支持跳过已解析的文件,避免重复解析- * - 返回解析后的文本内容和元数据+ * Features:+ * - Parses the text content of document files (PDF, Word, Excel, etc.)+ * - Supports skipping already-parsed files to avoid duplicate parsing+ * - Returns the parsed text content and metadata*/app.post('/:id/parses',@@ -178,15 +178,15 @@ app.post();/**- * 触发文件分块任务(可选:自动触发嵌入)+ * Trigger file chunking task (optional: auto-trigger embedding)* POST /files/:id/chunks** Path parameters:- * - id: string (required) - 文件ID+ * - id: string (required) - File ID** Request body (JSON):- * - skipExist?: boolean - 是否跳过已存在的分块任务/结果- * - autoEmbedding?: boolean - 分块成功后是否自动触发嵌入+ * - skipExist?: boolean - Whether to skip existing chunking tasks/results+ * - autoEmbedding?: boolean - Whether to automatically trigger embedding after chunking succeeds*/app.post('/:id/chunks',@@ -201,16 +201,16 @@ app.post();/**- * 查询文件分块结果和状态+ * Query file chunking results and status* GET /files/:id/chunks** Path parameters:- * - id: string (required) - 文件ID+ * - id: string (required) - File ID*- * 功能:- * - 查询文件分块任务状态(进行中/成功/失败)- * - 返回当前分块数量- * - 同时返回嵌入任务状态等相关信息+ * Features:+ * - Query file chunking task status (in progress / succeeded / failed)+ * - Returns the current chunk count+ * - Also returns embedding task status and other related information*/app.get('/:id/chunks',@@ -224,18 +224,18 @@ app.get();/**- * 批量文件上传+ * Batch file upload* POST /files/batches* Content-Type: multipart/form-data** Form fields:- * - files: File[] (required) - 要上传的文件列表- * - knowledgeBaseId: string (optional) - 知识库ID- * - agentId: string (optional) - Agent ID,优先解析为 sessionId 并关联文件- * - sessionId: string (optional) - 会话ID,如果提供则创建文件和会话的关联关系- * - skipCheckFileType: boolean (optional) - 是否跳过文件类型检查- * - directory: string (optional) - 上传目录- * - skipExist: boolean (optional) - 是否跳过已存在的解析结果,默认false+ * - files: File[] (required) - List of files to upload+ * - knowledgeBaseId: string (optional) - Knowledge base ID+ * - agentId: string (optional) - Agent ID; resolved to sessionId first for file association+ * - sessionId: string (optional) - Session ID; if provided, creates a file-session association+ * - skipCheckFileType: boolean (optional) - Whether to skip file type check+ * - directory: string (optional) - Upload directory+ * - skipExist: boolean (optional) - Whether to skip existing parse results, default false*/app.post('/batches',@@ -248,7 +248,7 @@ app.post();/**- * 批量获取文件详情+ * Batch get file details* POST /files/queries* Content-Type: application/json*@@ -257,9 +257,9 @@ app.post(* "fileIds": ["file1", "file2", "file3"]* }*- * 功能:- * - 根据文件ID列表批量获取文件详情- * - 返回成功和失败的统计信息+ * Features:+ * - Batch retrieve file details by a list of file IDs+ * - Returns success and failure statistics*/app.post('/queries',diff --git a/packages/openapi/src/routes/knowledge-bases.route.ts b/packages/openapi/src/routes/knowledge-bases.route.tsindex 36e87a4da18..fb2a9014754 100644--- a/packages/openapi/src/routes/knowledge-bases.route.ts+++ b/packages/openapi/src/routes/knowledge-bases.route.ts@@ -19,13 +19,13 @@ import {const app = new Hono();/**- * 获取知识库列表+ * Get knowledge base list* GET /knowledge-bases** Query parameters:- * - page: number (optional) - 页码,默认1- * - pageSize: number (optional) - 每页数量,默认20,最大100- * - keyword: string (optional) - 搜索关键词(匹配名称或描述)+ * - page: number (optional) - Page number, default 1+ * - pageSize: number (optional) - Items per page, default 20, max 100+ * - keyword: string (optional) - Search keyword (matches name or description)*/app.get('/',@@ -39,15 +39,15 @@ app.get();/**- * 创建知识库+ * Create a knowledge base* POST /knowledge-bases* Content-Type: application/json** Request body:* {- * "name": "知识库名称",- * "description": "知识库描述(可选)",- * "avatar": "头像URL(可选)"+ * "name": "Knowledge base name",+ * "description": "Knowledge base description (optional)",+ * "avatar": "Avatar URL (optional)"* }*/app.post(@@ -62,11 +62,11 @@ app.post();/**- * 获取知识库详情+ * Get knowledge base details* GET /knowledge-bases/:id** Path parameters:- * - id: string (required) - 知识库ID+ * - id: string (required) - Knowledge base ID*/app.get('/:id',@@ -80,18 +80,18 @@ app.get();/**- * 更新知识库+ * Update a knowledge base* PATCH /knowledge-bases/:id* Content-Type: application/json** Path parameters:- * - id: string (required) - 知识库ID+ * - id: string (required) - Knowledge base ID** Request body:* {- * "name": "新名称(可选)",- * "description": "新描述(可选)",- * "avatar": "新头像URL(可选)"+ * "name": "New name (optional)",+ * "description": "New description (optional)",+ * "avatar": "New avatar URL (optional)"* }*/app.patch(@@ -107,11 +107,11 @@ app.patch();/**- * 删除知识库+ * Delete a knowledge base* DELETE /knowledge-bases/:id** Path parameters:- * - id: string (required) - 知识库ID+ * - id: string (required) - Knowledge base ID*/app.delete('/:id',@@ -125,20 +125,20 @@ app.delete();/**- * 获取指定知识库下的文件列表+ * Get the file list for a specific knowledge base* GET /knowledge-bases/:id/files** Path parameters:- * - id: string (required) - 知识库ID+ * - id: string (required) - Knowledge base ID** Query parameters:- * - page: number (optional) - 页码;仅传 page 时,默认 pageSize=20- * - pageSize: number (optional) - 每页数量,默认最大100;仅传 pageSize 时,默认 page=1- * - fileType: string (optional) - 文件类型过滤- * - keyword: string (optional) - 搜索关键词(匹配文件名)+ * - page: number (optional) - Page number; when only page is provided, defaults pageSize=20+ * - pageSize: number (optional) - Items per page, max 100; when only pageSize is provided, defaults page=1+ * - fileType: string (optional) - File type filter+ * - keyword: string (optional) - Search keyword (matches file name)*- * 说明:- * - 未提供 page 和 pageSize 时,不进行分页,返回全部数据+ * Notes:+ * - When neither page nor pageSize is provided, returns all data without pagination*/app.get('/:id/files',@@ -156,7 +156,7 @@ app.get();/**- * 批量为知识库添加文件关联+ * Batch add file associations to a knowledge base* POST /knowledge-bases/:id/files/batch*/app.post(@@ -172,7 +172,7 @@ app.post();/**- * 批量移除知识库与文件的关联+ * Batch remove file associations from a knowledge base* DELETE /knowledge-bases/:id/files/batch*/app.delete(@@ -188,7 +188,7 @@ app.delete();/**- * 批量将文件从当前知识库移动到目标知识库+ * Batch move files from the current knowledge base to a target knowledge base* POST /knowledge-bases/:id/files/move*/app.post(diff --git a/packages/openapi/src/routes/messages.route.ts b/packages/openapi/src/routes/messages.route.tsindex d125f3a5c4e..3838224632b 100644--- a/packages/openapi/src/routes/messages.route.ts+++ b/packages/openapi/src/routes/messages.route.ts@@ -15,10 +15,10 @@ import {MessagesListQuerySchema,} from '../types/message.type';-// Messages 相关路由+// Messages-related routesconst MessageRoutes = new Hono();-// GET /api/v1/messages/count - 统计消息数量 (支持各种过滤条件)+// GET /api/v1/messages/count - Get message count (supports various filter conditions)MessageRoutes.get('/count',requireAuth,@@ -33,7 +33,7 @@ MessageRoutes.get(},);-// GET /api/v1/messages - 获取消息列表 (支持各种过滤和搜索)+// GET /api/v1/messages - Get message list (supports various filters and search)MessageRoutes.get('/',requireAuth,@@ -48,7 +48,7 @@ MessageRoutes.get(},);-// GET /api/v1/messages/:id - 根据消息ID获取消息详情 (需要消息读取权限)+// GET /api/v1/messages/:id - Get message details by message ID (requires message read permission)MessageRoutes.get('/:id',requireAuth,@@ -63,7 +63,7 @@ MessageRoutes.get(},);-// POST /api/v1/messages - 创建新消息 (需要消息写入权限)+// POST /api/v1/messages - Create a new message (requires message write permission)MessageRoutes.post('/',requireAuth,@@ -79,7 +79,7 @@ MessageRoutes.post(},);-// POST /api/v1/messages/replies - 创建用户消息并生成 AI 回复 (需要消息写入权限)+// POST /api/v1/messages/replies - Create a user message and generate an AI reply (requires message write permission)MessageRoutes.post('/replies',requireAuth,@@ -94,7 +94,7 @@ MessageRoutes.post(},);-// DELETE /api/v1/messages/:id - 删除单个消息 (需要消息删除权限)+// DELETE /api/v1/messages/:id - Delete a single message (requires message delete permission)MessageRoutes.delete('/:id',requireAuth,@@ -109,7 +109,7 @@ MessageRoutes.delete(},);-// DELETE /api/v1/messages - 批量删除消息 (需要消息删除权限)+// DELETE /api/v1/messages - Batch delete messages (requires message delete permission)MessageRoutes.delete('/',requireAuth,diff --git a/packages/openapi/src/routes/models.route.ts b/packages/openapi/src/routes/models.route.tsindex 74e4d9a364a..bf4dea00969 100644--- a/packages/openapi/src/routes/models.route.ts+++ b/packages/openapi/src/routes/models.route.ts@@ -13,10 +13,10 @@ import {UpdateModelRequestSchema,} from '../types/model.type';-// Models 相关路由+// Models-related routesconst ModelRoutes = new Hono();-// GET /api/v1/models - 获取模型列表 (支持分页、过滤和分组)+// GET /api/v1/models - Get model list (supports pagination, filtering, and grouping)ModelRoutes.get('/',requireAuth,@@ -28,7 +28,7 @@ ModelRoutes.get(},);-// POST /api/v1/models - 创建模型+// POST /api/v1/models - Create a modelModelRoutes.post('/',requireAuth,@@ -40,7 +40,7 @@ ModelRoutes.post(},);-// GET /api/v1/models/:providerId/:modelId - 获取模型详情+// GET /api/v1/models/:providerId/:modelId - Get model detailsModelRoutes.get('/:providerId/:modelId',requireAuth,@@ -52,7 +52,7 @@ ModelRoutes.get(},);-// PATCH /api/v1/models/:providerId/:modelId - 更新模型+// PATCH /api/v1/models/:providerId/:modelId - Update a modelModelRoutes.patch('/:providerId/:modelId',requireAuth,diff --git a/packages/openapi/src/routes/topics.route.ts b/packages/openapi/src/routes/topics.route.tsindex ace0649f0c2..93241cee6ec 100644--- a/packages/openapi/src/routes/topics.route.ts+++ b/packages/openapi/src/routes/topics.route.ts@@ -15,10 +15,10 @@ import {TopicUpdateRequestSchema,} from '../types/topic.type';-// Topic 相关路由+// Topic-related routesconst TopicsRoutes = new Hono();-// GET /api/v1/topics - 获取话题列表(支持分页和 agent/group 过滤)+// GET /api/v1/topics - Get topic list (supports pagination and agent/group filtering)TopicsRoutes.get('/',requireAuth,@@ -33,7 +33,7 @@ TopicsRoutes.get(},);-// POST /api/v1/topics - 创建新的话题+// POST /api/v1/topics - Create a new topicTopicsRoutes.post('/',requireAuth,@@ -48,7 +48,7 @@ TopicsRoutes.post(},);-// GET /api/v1/topics/:id - 获取指定话题+// GET /api/v1/topics/:id - Get topic by IDTopicsRoutes.get('/:id',requireAuth,@@ -63,7 +63,7 @@ TopicsRoutes.get(},);-// PATCH /api/v1/topics/:id - 更新话题+// PATCH /api/v1/topics/:id - Update topicTopicsRoutes.patch('/:id',requireAuth,@@ -79,7 +79,7 @@ TopicsRoutes.patch(},);-// DELETE /api/v1/topics/:id - 删除话题+// DELETE /api/v1/topics/:id - Delete topicTopicsRoutes.delete('/:id',requireAuth,diff --git a/packages/openapi/src/routes/users.route.ts b/packages/openapi/src/routes/users.route.tsindex 92540e9b542..b4330426256 100644--- a/packages/openapi/src/routes/users.route.ts+++ b/packages/openapi/src/routes/users.route.ts@@ -17,9 +17,9 @@ import {const UserRoutes = new Hono();/**- * 获取当前登录用户信息+ * Get current logged-in user information* GET /api/v1/users/me- * 需要认证,但不需要特殊权限+ * Requires authentication but no special permission*/UserRoutes.get('/me', requireAuth, async (c) => {const userController = new UserController();@@ -27,9 +27,9 @@ UserRoutes.get('/me', requireAuth, async (c) => {});/**- * 获取系统中的用户列表 (支持搜索)+ * Get the list of users in the system (supports search)* GET /api/v1/users?keyword=xxx&page=1&pageSize=10- * 需要用户管理权限+ * Requires user management permission*/UserRoutes.get('/',@@ -43,9 +43,9 @@ UserRoutes.get();/**- * 创建新用户+ * Create a new user* POST /api/v1/users- * 需要用户创建权限+ * Requires user create permission*/UserRoutes.post('/',@@ -59,9 +59,9 @@ UserRoutes.post();/**- * 根据ID获取用户详情+ * Get user details by ID* GET /api/v1/users/:id- * 需要用户读取权限+ * Requires user read permission*/UserRoutes.get('/:id',@@ -75,9 +75,9 @@ UserRoutes.get();/**- * 更新用户信息 (RESTful 部分更新)+ * Update user information (RESTful partial update)* PATCH /api/v1/users/:id- * 需要用户更新权限+ * Requires user update permission*/UserRoutes.patch('/:id',@@ -92,9 +92,9 @@ UserRoutes.patch();/**- * 删除用户+ * Delete a user* DELETE /api/v1/users/:id- * 需要用户删除权限+ * Requires user delete permission*/UserRoutes.delete('/:id',@@ -108,9 +108,9 @@ UserRoutes.delete();/**- * 获取用户角色信息+ * Get user role information* GET /api/v1/users/:id/roles- * 需要用户角色查看权限+ * Requires user role read permission*/UserRoutes.get('/:id/roles',@@ -124,9 +124,9 @@ UserRoutes.get();/**- * 更新用户关联的角色+ * Update the roles associated with a user* PATCH /api/v1/users/:id/roles- * 需要用户角色分配权限+ * Requires user role assignment permission*/UserRoutes.patch('/:id/roles',@@ -141,9 +141,9 @@ UserRoutes.patch();/**- * 清空用户的角色列表+ * Clear all roles for a user* DELETE /api/v1/users/:id/roles- * 需要用户角色更新权限+ * Requires user role update permission*/UserRoutes.delete('/:id/roles',diff --git a/packages/openapi/src/types/agent-group.type.ts b/packages/openapi/src/types/agent-group.type.tsindex 14b1a3caa93..1a0f9d9cb62 100644--- a/packages/openapi/src/types/agent-group.type.ts+++ b/packages/openapi/src/types/agent-group.type.ts@@ -3,10 +3,10 @@ import { z } from 'zod';import type { SessionGroupItem } from '@/database/schemas';// ==================== Agent Group CRUD Types ====================-// 助理分类(使用 sessionGroups 表存储)相关类型定义+// Agent group (stored in sessionGroups table) related type definitions/**- * 创建助理分类请求参数+ * Create agent group request parameters*/export interface CreateAgentGroupRequest {name: string;@@ -19,7 +19,7 @@ export const CreateAgentGroupRequestSchema = z.object({});/**- * 更新助理分类请求参数+ * Update agent group request parameters*/export interface UpdateAgentGroupRequest {id: string;@@ -33,7 +33,7 @@ export const UpdateAgentGroupRequestSchema = z.object({});/**- * 删除助理分类请求参数+ * Delete agent group request parameters*/export interface DeleteAgentGroupRequest {id: string;@@ -42,7 +42,7 @@ export interface DeleteAgentGroupRequest {// ==================== Agent Group Response Types ====================/**- * 助理分类列表响应类型+ * Agent group list response type*/export type AgentGroupListResponse = SessionGroupItem[];diff --git a/packages/openapi/src/types/agent.type.ts b/packages/openapi/src/types/agent.type.tsindex d60703f2cc2..e58f9dcc75a 100644--- a/packages/openapi/src/types/agent.type.ts+++ b/packages/openapi/src/types/agent.type.ts@@ -8,7 +8,7 @@ import type { IPaginationQuery, PaginationQueryResponse } from './common.type';// ==================== Agent CRUD Types ====================/**- * 创建 Agent 请求参数+ * Create Agent request parameters*/export interface CreateAgentRequest {avatar?: string;@@ -53,7 +53,7 @@ export const CreateAgentRequestSchema = z.object({});/**- * 更新 Agent 请求参数+ * Update Agent request parameters*/export type UpdateAgentRequest = CreateAgentRequest & {id: string;@@ -62,7 +62,7 @@ export type UpdateAgentRequest = CreateAgentRequest & {export const UpdateAgentRequestSchema = CreateAgentRequestSchema.partial();/**- * 删除 Agent 请求参数+ * Delete Agent request parameters*/export interface AgentDeleteRequest {agentId: string;@@ -77,7 +77,7 @@ export const AgentDeleteRequestSchema = z.object({// ==================== Agent Batch Operations ====================/**- * 批量删除 Agent 请求参数+ * Batch delete Agents request parameters*/export interface BatchDeleteAgentsRequest {agentIds: string[];@@ -85,7 +85,7 @@ export interface BatchDeleteAgentsRequest {}/**- * 批量更新 Agent 请求参数+ * Batch update Agents request parameters*/export interface BatchUpdateAgentsRequest {agentIds: string[];@@ -99,7 +99,7 @@ export interface BatchUpdateAgentsRequest {}/**- * 批量操作结果类型+ * Batch operation result type*/export interface BatchOperationResult {errors?: Array<{@@ -114,21 +114,21 @@ export interface BatchOperationResult {// ==================== Agent Session Relations ====================/**- * Agent-Session 关联操作请求参数+ * Agent-Session link operation request parameters*/export interface AgentSessionLinkRequest {sessionId: string;}/**- * Agent-Session 批量关联操作请求参数+ * Agent-Session batch link operation request parameters*/export interface AgentSessionBatchLinkRequest {sessionIds: string[];}/**- * 为 Agent 创建 Session 请求参数+ * Create Session for Agent request parameters*/export interface CreateSessionForAgentRequest {agentId: string;@@ -139,7 +139,7 @@ export interface CreateSessionForAgentRequest {}/**- * Agent-Session 关联关系响应类型+ * Agent-Session relationship response type*/export interface AgentSessionRelation {agentId: string;@@ -156,14 +156,14 @@ export interface AgentSessionRelation {// ==================== Agent Response Types ====================/**- * Agent 列表响应类型+ * Agent list response type*/export type AgentListResponse = PaginationQueryResponse<{agents: AgentItem[];}>;/**- * Agent 详情响应类型,包含完整的配置信息+ * Agent detail response type, includes complete configuration information*/export interface AgentDetailResponse extends AgentItem {agentsFiles?: Array<{diff --git a/packages/openapi/src/types/chat.type.ts b/packages/openapi/src/types/chat.type.tsindex 10db8e272a9..54c09f1a89f 100644--- a/packages/openapi/src/types/chat.type.ts+++ b/packages/openapi/src/types/chat.type.ts@@ -4,7 +4,7 @@ import { z } from 'zod';// ==================== Chat Service Types ====================/**- * 聊天服务参数+ * Chat service parameters*/export interface ChatServiceParams {frequency_penalty?: number;@@ -38,7 +38,7 @@ export const ChatServiceParamsSchema = z.object({});/**- * 聊天响应+ * Chat response*/export interface ChatServiceResponse {content: string;@@ -54,7 +54,7 @@ export interface ChatServiceResponse {// ==================== Translation Service Types ====================/**- * 翻译服务参数+ * Translation service parameters*/export interface TranslateServiceParams {from?: string;@@ -76,7 +76,7 @@ export const TranslateServiceParamsSchema = z.object({// ==================== Message Generation Types ====================/**- * 消息生成参数+ * Message generation parameters*/export interface MessageGenerationParams {agentId?: string;@@ -128,12 +128,12 @@ export const MessageGenerationParamsSchema = z.object({// ==================== Configuration Types ====================/**- * 支持的AI提供商+ * Supported AI providers*/export type AIProvider = 'openai' | 'anthropic' | 'google' | 'groq' | 'vertexai';/**- * Chat Service配置+ * Chat Service configuration*/export interface ChatServiceConfig {defaultModel?: string;diff --git a/packages/openapi/src/types/common.type.ts b/packages/openapi/src/types/common.type.tsindex 13a4e06aac2..cd1afad6d53 100644--- a/packages/openapi/src/types/common.type.ts+++ b/packages/openapi/src/types/common.type.ts@@ -1,10 +1,10 @@-// 引入 zod 用于通用 schema+// Import zod for common schemasimport { z } from 'zod';-// ==================== 通用分页查询参数 ====================+// ==================== Common Pagination Query Parameters ====================/**- * 通用分页查询参数接口+ * Common pagination query parameter interface*/export interface IPaginationQuery {keyword?: string;@@ -13,14 +13,14 @@ export interface IPaginationQuery {}/**- * 通用分页查询参数 Schema+ * Common pagination query parameter Schema*/export const PaginationQuerySchema = z.object({keyword: z.string().optional().transform((val) => {- if (!val) return ''; // 允许为空,转换为空字符串+ if (!val) return ''; // Allow empty value, convert to empty stringreturn val.trim();}).refine((val) => val.length <= 100, '搜索关键词长度不能超过100个字符'),diff --git a/packages/openapi/src/types/index.ts b/packages/openapi/src/types/index.tsindex 7b98475f301..0e4a024b7ad 100644--- a/packages/openapi/src/types/index.ts+++ b/packages/openapi/src/types/index.ts@@ -1,8 +1,8 @@-// 引入 zod 用于通用 schema+// Import zod for common schemasimport type { LobeChatDatabase } from '@/database/type';/**- * 标准API响应格式+ * Standard API response format*/export interface ApiResponse<T = any> {data?: T;@@ -13,17 +13,17 @@ export interface ApiResponse<T = any> {}/**- * 服务接口基类+ * Service interface base class*/export interface IBaseService {/**- * 数据库实例+ * Database instance*/db?: LobeChatDatabase;}/**- * 服务方法返回类型+ * Service method return type*/export type ServiceResult<T = any> = Promise<T>;@@ -53,7 +53,7 @@ export interface TBatchTarget {targetUserIds?: string[];}-// ==================== 导出所有类型 ====================+// ==================== Export All Types ====================export * from './agent.type';export * from './agent-group.type';export * from './chat.type';diff --git a/packages/openapi/src/types/message-translations.type.ts b/packages/openapi/src/types/message-translations.type.tsindex e8198ae716d..85d5b5a4ac6 100644--- a/packages/openapi/src/types/message-translations.type.ts+++ b/packages/openapi/src/types/message-translations.type.ts@@ -3,7 +3,7 @@ import { z } from 'zod';// ==================== Message Translation Query Types ====================/**- * 翻译消息查询请求参数+ * Message translation query request parameters*/export interface MessageTranslateQueryRequest {messageId: string;@@ -14,14 +14,14 @@ export const MessageTranslateQueryRequestSchema = z.object({});/**- * 翻译消息 params 请求参数+ * Message translation params request parameters*/export type MessageTranslateParams = MessageTranslateQueryRequest;// ==================== Message Translation Trigger Types ====================/**- * 翻译消息 body 请求参数+ * Message translation body request parameters*/export interface MessageTranslateBody {from?: string;@@ -38,14 +38,14 @@ export const MessageTranslateTriggerRequestSchema = z.object({});/**- * 翻译消息完整请求参数+ * Full message translation trigger request parameters*/export type MessageTranslateTriggerRequest = MessageTranslateQueryRequest & MessageTranslateBody;// ==================== Message Translation Update Types ====================/**- * 更新翻译信息请求参数+ * Update translation info request parameters*/export type MessageTranslateInfoUpdate = MessageTranslateTriggerRequest & {content?: string;@@ -58,7 +58,7 @@ export const MessageTranslateInfoUpdateSchema = MessageTranslateTriggerRequestSc// ==================== Message Translation Response Types ====================/**- * 翻译消息响应参数+ * Message translation response parameters*/export interface MessageTranslateResponse {clientId: string | null;diff --git a/packages/openapi/src/types/model.type.ts b/packages/openapi/src/types/model.type.tsindex 3ae171a901d..6466ca95d7f 100644--- a/packages/openapi/src/types/model.type.ts+++ b/packages/openapi/src/types/model.type.ts@@ -19,7 +19,7 @@ const MODEL_TYPES = [] as const;/**- * 模型列表查询参数+ * Model list query parameters*/export interface ModelsListQuery extends IPaginationQuery {enabled?: boolean;diff --git a/packages/openapi/src/types/topic.type.ts b/packages/openapi/src/types/topic.type.tsindex a0c330885ac..cea65bd13e9 100644--- a/packages/openapi/src/types/topic.type.ts+++ b/packages/openapi/src/types/topic.type.ts@@ -73,7 +73,7 @@ export interface TopicResponse extends TopicItem {}/**- * Topic 列表响应类型+ * Topic list response type*/export type TopicListResponse = PaginationQueryResponse<{topics: TopicResponse[];