🤯 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 database models (#10225)
LobeHub Bot0d6cb06d59ae
diff --git a/packages/database/src/models/apiKey.ts b/packages/database/src/models/apiKey.tsindex 95d54e79988..2714c8f5c14 100644--- a/packages/database/src/models/apiKey.ts+++ b/packages/database/src/models/apiKey.ts@@ -51,12 +51,12 @@ export class ApiKeyModel {where: eq(apiKeys.userId, this.userId),});- // 如果没有提供解密器,直接返回原始结果+ // If no decryptor is provided, return the original results directlyif (!decryptor) {return results;}- // 对每个 API Key 的 key 字段进行解密+ // Decrypt the key field for each API Keyconst decryptedResults = await Promise.all(results.map(async (apiKey) => {const decryptedKey = await decryptor(apiKey.key);diff --git a/packages/database/src/models/chunk.ts b/packages/database/src/models/chunk.tsindex 9942681e62f..7324bd3197d 100644--- a/packages/database/src/models/chunk.ts+++ b/packages/database/src/models/chunk.ts@@ -209,7 +209,7 @@ export class ChunkModel {.leftJoin(files, eq(files.id, fileChunks.fileId)).where(inArray(fileChunks.fileId, fileIds)).orderBy((t) => desc(t.similarity))- // 先放宽到 15+ // Relaxed to 15 for now.limit(15);return result.map((item) => {diff --git a/packages/database/src/models/drizzleMigration.ts b/packages/database/src/models/drizzleMigration.tsindex c95b9479325..b932138a49c 100644--- a/packages/database/src/models/drizzleMigration.ts+++ b/packages/database/src/models/drizzleMigration.ts@@ -11,7 +11,7 @@ export class DrizzleMigrationModel {}getTableCounts = async () => {- // 这里使用 pg_tables 系统表查询用户表数量+ // Use pg_tables system table to query the number of user tablesconst result = await this.db.execute(sql`SELECT COUNT(*) as table_countdiff --git a/packages/database/src/models/oauthHandoff.ts b/packages/database/src/models/oauthHandoff.tsindex ad80f3e02cc..a68d6614298 100644--- a/packages/database/src/models/oauthHandoff.ts+++ b/packages/database/src/models/oauthHandoff.ts@@ -12,9 +12,9 @@ export class OAuthHandoffModel {}/**- * 创建新的认证凭证传递记录- * @param params 凭证数据- * @returns 创建的记录+ * Create a new OAuth handoff record+ * @param params Credential data+ * @returns Created record*/create = async (params: NewOAuthHandoff): Promise<OAuthHandoffItem> => {const [result] = await this.db@@ -27,21 +27,21 @@ export class OAuthHandoffModel {};/**- * 获取并消费认证凭证- * 该方法会先查询记录,如果找到则立即删除,确保凭证只能被使用一次- * @param id 凭证ID- * @param client 客户端类型- * @returns 凭证数据,如果不存在或已过期则返回null+ * Fetch and consume OAuth credentials+ * This method queries the record first, and if found, deletes it immediately to ensure credentials can only be used once+ * @param id Credential ID+ * @param client Client type+ * @returns Credential data, or null if it doesn't exist or has expired*/fetchAndConsume = async (id: string, client: string): Promise<OAuthHandoffItem | null> => {- // 先查找记录,同时检查是否过期 (5分钟TTL)+ // First find the record while checking if it's expired (5 minute TTL)const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000);const handoff = await this.db.query.oauthHandoffs.findFirst({where: and(eq(oauthHandoffs.id, id),eq(oauthHandoffs.client, client),- // 检查记录是否在5分钟内创建+ // Check if the record was created within the last 5 minutessql`${oauthHandoffs.createdAt} > ${fiveMinutesAgo}`,),});@@ -50,16 +50,16 @@ export class OAuthHandoffModel {return null;}- // 立即删除记录以确保一次性使用+ // Immediately delete the record to ensure one-time useawait this.db.delete(oauthHandoffs).where(eq(oauthHandoffs.id, id));return handoff;};/**- * 清理过期的认证凭证记录- * 这个方法应该被定期调用(比如通过 cron job)来清理过期的记录- * @returns 清理的记录数量+ * Clean up expired OAuth handoff records+ * This method should be called periodically (e.g., via a cron job) to clean up expired records+ * @returns Number of records cleaned up*/cleanupExpired = async (): Promise<number> => {const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000);@@ -72,11 +72,11 @@ export class OAuthHandoffModel {};/**- * 检查凭证是否存在(不消费)- * 主要用于测试和调试- * @param id 凭证ID- * @param client 客户端类型- * @returns 是否存在且未过期+ * Check if a credential exists (without consuming it)+ * Primarily used for testing and debugging+ * @param id Credential ID+ * @param client Client type+ * @returns Whether it exists and is not expired*/exists = async (id: string, client: string): Promise<boolean> => {const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000);diff --git a/packages/database/src/models/session.ts b/packages/database/src/models/session.tsindex f9313421b3c..37e4d5c1aec 100644--- a/packages/database/src/models/session.ts+++ b/packages/database/src/models/session.ts@@ -94,7 +94,7 @@ export class SessionModel {};queryWithGroups = async (): Promise<ChatSessionList> => {- // 查询所有会话+ // Query all sessionsconst result = await this.query();const groups = await this.db.query.sessionGroups.findMany({@@ -195,7 +195,7 @@ export class SessionModel {.limit(limit);};- // TODO: 未来将 Inbox id 入库后可以直接使用 _rank 方法+ // TODO: In the future, once Inbox ID is stored in the database, we can directly use the _rank methodrank = async (limit: number = 10): Promise<SessionRankItem[]> => {const inboxResult = await this.db.select({@@ -525,7 +525,7 @@ export class SessionModel {);}- // 先处理参数字段:undefined 表示删除,null 表示禁用标记+ // First process the params field: undefined means delete, null means disable flagconst existingParams = session.agent.params ?? {};const updatedParams: Record<string, any> = { ...existingParams };@@ -534,26 +534,26 @@ export class SessionModel {Object.keys(incomingParams).forEach((key) => {const incomingValue = incomingParams[key];- // undefined 代表显式删除该字段+ // undefined means explicitly delete this fieldif (incomingValue === undefined) {delete updatedParams[key];return;}- // 其余值(包括 null)都直接覆盖,null 表示在前端禁用该参数+ // All other values (including null) are directly overwritten, null means disable this param on the frontendupdatedParams[key] = incomingValue;});}- // 构建要合并的数据,排除 params(单独处理)+ // Build data to be merged, excluding params (processed separately)// eslint-disable-next-line @typescript-eslint/no-unused-varsconst { params: _params, ...restData } = data;const mergedValue = merge(session.agent, restData);- // 应用处理后的参数+ // Apply the processed parametersmergedValue.params = Object.keys(updatedParams).length > 0 ? updatedParams : undefined;- // 最终清理:确保没有 undefined 或 null 值进入数据库+ // Final cleanup: ensure no undefined or null values enter the databaseif (mergedValue.params) {const params = mergedValue.params as Record<string, any>;Object.keys(params).forEach((key) => {@@ -625,7 +625,7 @@ export class SessionModel {}// For agent sessions, include agent-specific fields- // TODO: 未来这里需要更好的实现方案,目前只取第一个+ // TODO: Need a better implementation in the future, currently only taking the first oneconst agent = agentsToSessions?.[0]?.agent;return {...res,@@ -670,7 +670,7 @@ export class SessionModel {with: { agentsToSessions: { columns: {}, with: { session: true } } },});- // 过滤和映射结果,确保有有效的 session 关联+ // Filter and map results, ensuring valid session associationsreturn (results.filter((item) => item.agentsToSessions && item.agentsToSessions.length > 0)diff --git a/packages/database/src/models/topic.ts b/packages/database/src/models/topic.tsindex de956f02636..c6d29ab80c4 100644--- a/packages/database/src/models/topic.ts+++ b/packages/database/src/models/topic.ts@@ -72,7 +72,7 @@ export class TopicModel {const keywordLowerCase = keyword.toLowerCase();- // 查询标题匹配的主题+ // Query topics matching by titleconst topicsByTitle = await this.db.query.topics.findMany({orderBy: [desc(topics.updatedAt)],where: and(@@ -82,7 +82,7 @@ export class TopicModel {),});- // 查询消息内容匹配的主题ID+ // Query topic IDs matching by message contentconst topicIdsByMessages = await this.db.select({ topicId: messages.topicId }).from(messages)@@ -96,19 +96,19 @@ export class TopicModel {),).groupBy(messages.topicId);- // 如果没有通过消息内容找到主题,直接返回标题匹配的主题+ // If no topics found by message content, return topics matching by titleif (topicIdsByMessages.length === 0) {return topicsByTitle;}- // 查询通过消息内容找到的主题+ // Query topics found by message contentconst topicIds = topicIdsByMessages.map((t) => t.topicId);const topicsByMessages = await this.db.query.topics.findMany({orderBy: [desc(topics.updatedAt)],where: and(eq(topics.userId, this.userId), inArray(topics.id, topicIds)),});- // 合并结果并去重+ // Merge results and deduplicateconst allTopics = [...topicsByTitle];const existingIds = new Set(topicsByTitle.map((t) => t.id));@@ -118,7 +118,7 @@ export class TopicModel {}}- // 按更新时间排序+ // Sort by update timereturn allTopics.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(),);@@ -199,9 +199,9 @@ export class TopicModel {};batchCreate = async (topicParams: (CreateTopicParams & { id?: string })[]) => {- // 开始一个事务+ // Start a transactionreturn this.db.transaction(async (tx) => {- // 在 topics 表中批量插入新的 topics+ // Batch insert new topics into the topics tableconst createdTopics = await tx.insert(topics).values(@@ -216,7 +216,7 @@ export class TopicModel {).returning();- // 对每个新创建的 topic,更新关联的 messages 的 topicId+ // For each newly created topic, update the topicId of associated messagesawait Promise.all(createdTopics.map(async (topic, index) => {const messageIds = topicParams[index].messages;@@ -255,7 +255,7 @@ export class TopicModel {}).returning();- // 查找与原始 topic 关联的 messages+ // Find messages associated with the original topicconst originalMessages = await tx.select().from(messages)