🤯 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 openapi-remaining-services (#15913)
LobeHub Bot3d594e77f5ab
diff --git a/packages/openapi/src/services/agent.service.ts b/packages/openapi/src/services/agent.service.tsindex 6ccd3b35cf2..6e6c53b440a 100644--- a/packages/openapi/src/services/agent.service.ts+++ b/packages/openapi/src/services/agent.service.ts@@ -33,7 +33,7 @@ export class AgentService extends BaseService {* @returns The user's Agent list*/async queryAgents(request: GetAgentsRequest): ServiceResult<AgentListResponse> {- this.log('info', '获取 Agent 列表', { request });+ this.log('info', 'get agent list', { request });const { keyword } = request;@@ -58,14 +58,14 @@ export class AgentService extends BaseService {const [agentsList, totalResult] = await Promise.all([query, countQuery]);- this.log('info', `查询到 ${agentsList.length} 个 Agent`);+ this.log('info', `found ${agentsList.length} agents`);return {agents: agentsList,total: totalResult[0]?.count ?? 0,};} catch (error) {- this.handleServiceError(error, '获取 Agent 列表');+ this.handleServiceError(error, 'get agent list');}}@@ -75,7 +75,7 @@ export class AgentService extends BaseService {* @returns Created Agent info*/async createAgent(request: CreateAgentRequest): ServiceResult<AgentDetailResponse> {- this.log('info', '创建智能体', { title: request.title });+ this.log('info', 'create agent', { title: request.title });try {return await this.db.transaction(async (tx) => {@@ -99,12 +99,12 @@ export class AgentService extends BaseService {// Insert into databaseconst [createdAgent] = await tx.insert(agents).values(newAgentData).returning();- this.log('info', 'Agent 创建成功', { id: createdAgent.id, slug: createdAgent.slug });+ this.log('info', 'agent created successfully', { id: createdAgent.id, slug: createdAgent.slug });return createdAgent;});} catch (error) {- this.handleServiceError(error, '创建 Agent');+ this.handleServiceError(error, 'create agent');}}@@ -114,7 +114,7 @@ export class AgentService extends BaseService {* @returns Updated Agent info*/async updateAgent(request: UpdateAgentRequest): ServiceResult<AgentDetailResponse> {- this.log('info', '更新智能体', { id: request.id, title: request.title });+ this.log('info', 'update agent', { id: request.id, title: request.title });try {// Permission validation@@ -123,7 +123,7 @@ export class AgentService extends BaseService {});if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权更新此 Agent');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to update this agent');}return await this.db.transaction(async (tx) => {@@ -138,7 +138,7 @@ export class AgentService extends BaseService {});if (!existingAgent) {- throw this.createBusinessError(`Agent ID "${request.id}" 不存在`);+ throw this.createBusinessError(`Agent ID "${request.id}" not found`);}// Only update fields actually provided in the request to avoid overwriting existing values with undefined@@ -176,11 +176,11 @@ export class AgentService extends BaseService {.where(and(...whereConditions)).returning();- this.log('info', 'Agent 更新成功', { id: updatedAgent.id, slug: updatedAgent.slug });+ this.log('info', 'agent updated successfully', { id: updatedAgent.id, slug: updatedAgent.slug });return updatedAgent;});} catch (error) {- this.handleServiceError(error, '更新 Agent');+ this.handleServiceError(error, 'update agent');}}@@ -189,7 +189,7 @@ export class AgentService extends BaseService {* @param request Delete request parameters*/async deleteAgent(request: AgentDeleteRequest): ServiceResult<void> {- this.log('info', '删除智能体', {+ this.log('info', 'delete agent', {agentId: request.agentId,migrateSessionTo: request.migrateSessionTo,});@@ -201,7 +201,7 @@ export class AgentService extends BaseService {});if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权删除此 Agent');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to delete this agent');}// Check if the Agent to be deleted exists@@ -210,7 +210,7 @@ export class AgentService extends BaseService {});if (!targetAgent) {- throw this.createBusinessError(`Agent ID ${request.agentId} 不存在`);+ throw this.createBusinessError(`Agent ID ${request.agentId} not found`);}if (request.migrateSessionTo) {@@ -220,13 +220,13 @@ export class AgentService extends BaseService {});if (!migrateTarget) {- throw this.createBusinessError(`迁移目标 Agent ID ${request.migrateSessionTo} 不存在`);+ throw this.createBusinessError(`Migration target agent ID ${request.migrateSessionTo} not found`);}// Migrate session associations to the target Agentawait this.migrateAgentSessions(request.agentId, request.migrateSessionTo);- this.log('info', '会话迁移完成', {+ this.log('info', 'session migration completed', {from: request.agentId,to: request.migrateSessionTo,});@@ -241,9 +241,9 @@ export class AgentService extends BaseService {await agentModel.delete(request.agentId);}- this.log('info', 'Agent 删除成功', { agentId: request.agentId });+ this.log('info', 'agent deleted successfully', { agentId: request.agentId });} catch (error) {- this.handleServiceError(error, '删除 Agent');+ this.handleServiceError(error, 'delete agent');}}@@ -253,7 +253,7 @@ export class AgentService extends BaseService {* @returns Agent details*/async getAgentById(agentId: string): ServiceResult<AgentDetailResponse | null> {- this.log('info', '根据 ID 获取 Agent 详情', { agentId });+ this.log('info', 'get agent details by ID', { agentId });try {// Permission validation@@ -262,11 +262,11 @@ export class AgentService extends BaseService {});if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权访问此 Agent');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to access this agent');}if (!this.userId) {- throw this.createAuthError('未登录,无法获取 Agent 详情');+ throw this.createAuthError('Not logged in, cannot get agent details');}// Reuse AgentModel methods to get the full Agent configuration@@ -274,13 +274,13 @@ export class AgentService extends BaseService {const agent = await agentModel.getAgentConfigById(agentId);if (!agent || !agent.id) {- this.log('warn', 'Agent 不存在', { agentId });+ this.log('warn', 'agent not found', { agentId });return null;}return agent as AgentDetailResponse;} catch (error) {- this.handleServiceError(error, '获取 Agent 详情');+ this.handleServiceError(error, 'get agent details');}}@@ -291,7 +291,7 @@ export class AgentService extends BaseService {* @private*/private async migrateAgentSessions(fromAgentId: string, toAgentId: string): Promise<void> {- this.log('info', '开始迁移会话', { fromAgentId, toAgentId });+ this.log('info', 'start migrating sessions', { fromAgentId, toAgentId });try {await this.db.transaction(async (tx) => {@@ -345,12 +345,12 @@ export class AgentService extends BaseService {);}- this.log('info', '迁移会话完成', { count: newSessionIds.length });+ this.log('info', 'session migration completed', { count: newSessionIds.length });});- this.log('info', '会话迁移成功', { fromAgentId, toAgentId });+ this.log('info', 'session migration succeeded', { fromAgentId, toAgentId });} catch (error) {- this.handleServiceError(error, '会话迁移');+ this.handleServiceError(error, 'session migration');}}}diff --git a/packages/openapi/src/services/role.service.ts b/packages/openapi/src/services/role.service.tsindex 1a3774a9e95..86647437778 100644--- a/packages/openapi/src/services/role.service.ts+++ b/packages/openapi/src/services/role.service.ts@@ -44,7 +44,7 @@ export class RoleService extends BaseService {// Permission checkconst permissionResult = await this.resolveOperationPermission('RBAC_ROLE_READ');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权访问角色列表');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to access role list');}const conditions = [];@@ -87,7 +87,7 @@ export class RoleService extends BaseService {total: totalResult[0]?.count || 0,};} catch (error) {- this.handleServiceError(error, '获取角色列表');+ this.handleServiceError(error, 'get role list');}}@@ -99,7 +99,7 @@ export class RoleService extends BaseService {// Permission checkconst permissionResult = await this.resolveOperationPermission('RBAC_ROLE_READ');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权访问活跃角色列表');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to access active role list');}try {@@ -108,7 +108,7 @@ export class RoleService extends BaseService {where: and(eq(roles.isActive, true), this.getRoleScopeWhere()),});} catch (error) {- this.handleServiceError(error, '获取活跃角色列表');+ this.handleServiceError(error, 'get active role list');}}@@ -121,7 +121,7 @@ export class RoleService extends BaseService {// Permission checkconst permissionResult = await this.resolveOperationPermission('RBAC_ROLE_READ');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权访问此角色');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to access this role');}try {@@ -130,7 +130,7 @@ export class RoleService extends BaseService {});return role || null;} catch (error) {- this.handleServiceError(error, '获取角色详情');+ this.handleServiceError(error, 'get role details');}}@@ -143,7 +143,7 @@ export class RoleService extends BaseService {// Permission checkconst permissionResult = await this.resolveOperationPermission('RBAC_ROLE_READ');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权访问此角色');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to access this role');}try {@@ -152,7 +152,7 @@ export class RoleService extends BaseService {});return role || null;} catch (error) {- this.handleServiceError(error, '获取角色详情');+ this.handleServiceError(error, 'get role details');}}@@ -160,11 +160,11 @@ export class RoleService extends BaseService {* Create a new role*/async createRole(payload: CreateRoleRequest): ServiceResult<RoleItem> {- this.log('info', '创建角色', { payload });+ this.log('info', 'create role', { payload });const permissionResult = await this.resolveOperationPermission('RBAC_ROLE_CREATE');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权创建角色');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to create role');}try {@@ -174,7 +174,7 @@ export class RoleService extends BaseService {where: and(eq(roles.name, payload.name), this.getRoleScopeWhere()),});if (existingRole) {- throw this.createBusinessError(`角色名称 "${payload.name}" 已存在`);+ throw this.createBusinessError(`Role name "${payload.name}" already exists`);}const [createdRole] = await tx@@ -189,11 +189,11 @@ export class RoleService extends BaseService {}).returning();- this.log('info', '角色创建成功', { roleId: createdRole.id, roleName: createdRole.name });+ this.log('info', 'role created successfully', { roleId: createdRole.id, roleName: createdRole.name });return createdRole;});} catch (error) {- this.handleServiceError(error, '创建角色');+ this.handleServiceError(error, 'create role');}}@@ -209,7 +209,7 @@ export class RoleService extends BaseService {// Permission checkconst permissionResult = await this.resolveOperationPermission('RBAC_PERMISSION_READ');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权访问角色权限');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to access role permissions');}const conditions: SQL<unknown>[] = [eq(rolePermissions.roleId, request.roleId)];@@ -258,7 +258,7 @@ export class RoleService extends BaseService {total: totalResult[0]?.count || 0,};} catch (error) {- this.handleServiceError(error, '获取角色权限');+ this.handleServiceError(error, 'get role permissions');}}@@ -269,11 +269,11 @@ export class RoleService extends BaseService {roleId: string,payload: UpdateRolePermissionsRequest,): ServiceResult<{ granted: number; revoked: number; roleId: string }> {- this.log('info', '更新角色权限', { payload, roleId });+ this.log('info', 'update role permissions', { payload, roleId });const permissionResult = await this.resolveOperationPermission('RBAC_ROLE_UPDATE');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权更新角色权限');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to update role permissions');}const rawGrantIds = payload.grant ?? [];@@ -298,14 +298,14 @@ export class RoleService extends BaseService {const revokeIds = Array.from(revokeSet);if (!grantIds.length && !revokeIds.length) {- throw this.createBusinessError('未提供有效的 grant 或 revoke 权限 ID');+ throw this.createBusinessError('No valid grant or revoke permission IDs provided');}try {return await this.db.transaction(async (tx) => {const existingRole = await tx.query.roles.findFirst({ where: eq(roles.id, roleId) });if (!existingRole) {- throw this.createNotFoundError(`角色 ID "${roleId}" 不存在`);+ throw this.createNotFoundError(`Role ID "${roleId}" not found`);}let granted = 0;@@ -319,7 +319,7 @@ export class RoleService extends BaseService {const missingPermissionIds = grantIds.filter((id) => !validPermissionIds.includes(id));if (missingPermissionIds.length) {throw this.createNotFoundError(- `权限 ID [${missingPermissionIds.join(', ')}] 不存在,无法授权`,+ `Permission IDs [${missingPermissionIds.join(', ')}] not found, cannot grant`,);}@@ -367,7 +367,7 @@ export class RoleService extends BaseService {return { granted, revoked, roleId };});} catch (error) {- this.handleServiceError(error, '更新角色权限');+ this.handleServiceError(error, 'update role permissions');}}@@ -378,12 +378,12 @@ export class RoleService extends BaseService {* @returns Promise<RoleItem> - Updated role item*/async updateRole(id: string, updateData: UpdateRoleRequest): ServiceResult<RoleItem> {- this.log('info', '更新角色信息', { roleId: id, updateData });+ this.log('info', 'update role info', { roleId: id, updateData });// Permission checkconst permissionResult = await this.resolveOperationPermission('RBAC_ROLE_UPDATE');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权更新角色');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to update role');}try {@@ -394,12 +394,12 @@ export class RoleService extends BaseService {});if (!existingRole) {- throw this.createNotFoundError(`角色 ID "${id}" 不存在`);+ throw this.createNotFoundError(`Role ID "${id}" not found`);}// Check if it is a system role; system roles cannot have certain fields modifiedif (existingRole.isSystem && (updateData.name || updateData.isSystem === false)) {- throw this.createBusinessError('系统角色不允许修改名称或系统属性');+ throw this.createBusinessError('System roles cannot have their name or system attribute modified');}// If the role name is being modified, check whether the new name already exists@@ -409,7 +409,7 @@ export class RoleService extends BaseService {});if (duplicateRole) {- throw this.createBusinessError(`角色名称 "${updateData.name}" 已存在`);+ throw this.createBusinessError(`Role name "${updateData.name}" already exists`);}}@@ -430,11 +430,11 @@ export class RoleService extends BaseService {.where(and(eq(roles.id, id), this.getRoleScopeWhere())).returning();- this.log('info', '角色更新成功', { roleId: id, roleName: updatedRole.name });+ this.log('info', 'role updated successfully', { roleId: id, roleName: updatedRole.name });return updatedRole;});} catch (error) {- this.handleServiceError(error, '更新角色');+ this.handleServiceError(error, 'update role');}}@@ -442,12 +442,12 @@ export class RoleService extends BaseService {* Clear a role's permission mappings*/async clearRolePermissions(roleId: string): ServiceResult<{ removed: number; roleId: string }> {- this.log('info', '清空角色权限', { roleId });+ this.log('info', 'clear role permissions', { roleId });// Permission checkconst permissionResult = await this.resolveOperationPermission('RBAC_ROLE_UPDATE');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权清空角色权限');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to clear role permissions');}try {@@ -456,7 +456,7 @@ export class RoleService extends BaseService {where: and(eq(roles.id, roleId), this.getRoleScopeWhere()),});if (!existingRole) {- throw this.createNotFoundError(`角色 ID "${roleId}" 不存在`);+ throw this.createNotFoundError(`Role ID "${roleId}" not found`);}// Count and delete@@ -469,7 +469,7 @@ export class RoleService extends BaseService {return { removed: Number(before[0]?.count || 0), roleId };} catch (error) {- this.handleServiceError(error, '清空角色权限');+ this.handleServiceError(error, 'clear role permissions');}}@@ -477,11 +477,11 @@ export class RoleService extends BaseService {* Delete role by ID*/async deleteRole(id: string): ServiceResult<{ deleted: boolean; id: string }> {- this.log('info', '删除角色', { roleId: id });+ this.log('info', 'delete role', { roleId: id });const permissionResult = await this.resolveOperationPermission('RBAC_ROLE_DELETE');if (!permissionResult.isPermitted) {- throw this.createAuthorizationError(permissionResult.message || '无权删除角色');+ throw this.createAuthorizationError(permissionResult.message || 'No permission to delete role');}try {@@ -491,18 +491,18 @@ export class RoleService extends BaseService {});if (!existingRole) {- throw this.createNotFoundError(`角色 ID "${id}" 不存在`);+ throw this.createNotFoundError(`Role ID "${id}" not found`);}if (existingRole.isSystem) {- throw this.createBusinessError('系统角色不允许删除');+ throw this.createBusinessError('System roles cannot be deleted');}const linkedUser = await tx.query.userRoles.findFirst({where: and(eq(userRoles.roleId, id), this.getUserRoleScopeWhere()),});if (linkedUser) {- throw this.createBusinessError('角色仍然关联用户,无法删除');+ throw this.createBusinessError('Role is still associated with users and cannot be deleted');}const [deletedRole] = await tx@@ -511,14 +511,14 @@ export class RoleService extends BaseService {.returning({ id: roles.id });if (!deletedRole) {- throw this.createBusinessError('删除角色失败');+ throw this.createBusinessError('Failed to delete role');}- this.log('info', '角色删除成功', { roleId: id });+ this.log('info', 'role deleted successfully', { roleId: id });return { deleted: true, id: deletedRole.id };});} catch (error) {- this.handleServiceError(error, '删除角色');+ this.handleServiceError(error, 'delete role');}}}