🤯 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
✨ feat(agent): split the agent profile into sidebar pages (#22854)
Lobehub Coderf81026c52c71
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 93ec410ca24..4b3b0a869ab 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -2375,14 +2375,23 @@"supervisor.todoList.allComplete": "All tasks completed","supervisor.todoList.title": "Tasks Completed","tab.backToChat": "Back to chat",+ "tab.context": "Context",+ "tab.engine": "Engine",+ "tab.environment": "Environment","tab.group.identity": "Identity",+ "tab.group.setup": "Configure",+ "tab.group.shape": "Shape","tab.groupProfile": "Group Profile",+ "tab.instruction": "Instruction","tab.integration": "IM Bots",+ "tab.knowledge": "Knowledge Base","tab.mail": "Mail","tab.profile": "Agent Profile","tab.profileBasic": "Profile","tab.search": "Search",+ "tab.skills": "Skills","tab.tasks": "Tasks",+ "tab.tools": "Tools & Connectors","task.activity.calling": "Calling Skill...","task.activity.clientExecuting": "Executing locally...","task.activity.generating": "Generating response...",diff --git a/locales/en-US/electron.json b/locales/en-US/electron.jsonindex d0a87d57969..3834ec017eb 100644--- a/locales/en-US/electron.json+++ b/locales/en-US/electron.json@@ -29,12 +29,16 @@"navigation.discoverModels": "Discover Models","navigation.discoverProviders": "Discover Providers","navigation.document": "Document",+ "navigation.engine": "Agent Engine",+ "navigation.environment": "Agent Environment","navigation.goals": "Goals","navigation.group": "Group","navigation.groupChat": "Group Chat","navigation.groupProfile": "Group Profile","navigation.home": "Home","navigation.image": "Image",+ "navigation.instruction": "Agent Instruction",+ "navigation.knowledge": "Agent Knowledge Base","navigation.knowledgeBase": "Knowledge Base","navigation.lobehub": "LobeHub","navigation.mail": "Mail",@@ -69,9 +73,11 @@"navigation.selfLearning": "Self-evolving","navigation.settings": "Settings","navigation.sharedAgent": "Shared Agent",+ "navigation.skills": "Agent Skills","navigation.stats": "Statistics","navigation.task": "Task","navigation.tasks": "Tasks",+ "navigation.tools": "Agent Tools","navigation.topics": "Topics","navigation.unpin": "Unpin","navigation.video": "Video",diff --git a/locales/en-US/setting.json b/locales/en-US/setting.jsonindex 4dc5690af2f..db222f13291 100644--- a/locales/en-US/setting.json+++ b/locales/en-US/setting.json@@ -1445,7 +1445,7 @@"settingAbout.remoteDebugging.restartToApply": "Restart LobeHub to apply this change.","settingAbout.remoteDebugging.title": "Remote Debugging","settingAgent.agentTools.add": "Add Tool",- "settingAgent.agentTools.agentEmpty": "No agent-exclusive tools yet",+ "settingAgent.agentTools.agentEmpty": "Nothing only for this agent yet","settingAgent.agentTools.authorizedBy": "Authorized by {{name}}","settingAgent.agentTools.badge.agentOnly": "Agent-only","settingAgent.agentTools.badge.copy": "Copy",@@ -1467,9 +1467,9 @@"settingAgent.agentTools.priorityTooltip": "When tools share a name, the agent-exclusive tool runs first at runtime; your user tools come next.","settingAgent.agentTools.priorityTooltipWorkspace": "When tools share a name, this agent-scoped tool runs first at runtime; the workspace user tools are the fallback.","settingAgent.agentTools.removeOwnedConfirm": "Delete this agent-exclusive connector? Its credentials will be removed.",- "settingAgent.agentTools.tabAgent": "Agent Tools",- "settingAgent.agentTools.tabUser": "User Tools",- "settingAgent.agentTools.tabWorkspace": "Workspace Tools",+ "settingAgent.agentTools.tabAgent": "Only for this agent",+ "settingAgent.agentTools.tabUser": "From my library",+ "settingAgent.agentTools.tabWorkspace": "From the workspace library","settingAgent.artwork.avatar.generating": "Creating an image that matches this Agent…","settingAgent.artwork.avatar.image": "AI avatar","settingAgent.artwork.background.empty": "Add a background to give this Agent a visual identity",@@ -1504,6 +1504,26 @@"settingAgent.devicePolicy.privateDevicePublicAgent": "Private devices are for private agents only — other members cannot reach them","settingAgent.devicePolicy.selectTarget": "Select environment","settingAgent.devicePolicy.title": "Execution environment",+ "settingAgent.driver.brings.harness": "LobeHub's own harness: you choose the model, tools and instruction.",+ "settingAgent.driver.brings.hetero": "Brings its own model, tools and instruction; you set where it runs.",+ "settingAgent.driver.groupCli": "Heterogeneous agent · local CLI",+ "settingAgent.driver.groupHarness": "Built by LobeHub",+ "settingAgent.driver.groupRemote": "Heterogeneous agent · remote platform",+ "settingAgent.driver.harness": "LobeHub",+ "settingAgent.driver.switchBackHarness": "The core instruction and tools take effect again.",+ "settingAgent.driver.switchFailed": "Could not switch. Try again.",+ "settingAgent.driver.switchKeepTopics": "Existing topics are kept; new messages are handled by {{name}}.",+ "settingAgent.driver.switchLosesPrompt": "The core instruction stops applying: {{name}} uses its own system prompt.",+ "settingAgent.driver.switchOk": "Switch driver",+ "settingAgent.driver.switchTitle": "Switch the driver to {{name}}?",+ "settingAgent.driver.switched": "Switched to {{name}}",+ "settingAgent.driver.title": "Driver",+ "settingAgent.engine.configTitle": "{{name}} settings",+ "settingAgent.engine.desc": "What runs this agent, and where it works.",+ "settingAgent.engine.heteroHint": "Where {{name}} runs and what it needs there is set under Environment.",+ "settingAgent.engine.title": "Engine",+ "settingAgent.environment.desc": "Where it runs, and what it needs there.",+ "settingAgent.environment.title": "Environment","settingAgent.export.dialogTitle": "Export Agent Profile","settingAgent.export.enabledPlugins": "Enabled Skills","settingAgent.export.error": "Failed to export the agent profile",@@ -1519,7 +1539,26 @@"settingAgent.identity.done": "Done","settingAgent.identity.edit": "Edit identity","settingAgent.identity.saveFailed": "Could not save the identity, please try again",+ "settingAgent.identity.saved": "Saved","settingAgent.identity.untitled": "Unnamed agent",+ "settingAgent.instruction.desc": "Who it is and how it should behave. It reads this before every reply.",+ "settingAgent.instruction.title": "Instruction",+ "settingAgent.knowledgePage.addFile": "Add file",+ "settingAgent.knowledgePage.addLibrary": "Add library",+ "settingAgent.knowledgePage.desc": "The libraries and files it can search when it answers.",+ "settingAgent.knowledgePage.files.countMore": "{{count}}+ files",+ "settingAgent.knowledgePage.files.count_one": "{{count}} file",+ "settingAgent.knowledgePage.files.count_other": "{{count}} files",+ "settingAgent.knowledgePage.files.desc": "Single files it can read without a library.",+ "settingAgent.knowledgePage.files.empty": "No file attached yet",+ "settingAgent.knowledgePage.files.title": "Files",+ "settingAgent.knowledgePage.libraries.desc": "Collections you manage in Resources. Switch one off to keep it without searching it.",+ "settingAgent.knowledgePage.libraries.empty": "No library attached yet",+ "settingAgent.knowledgePage.libraries.title": "Libraries",+ "settingAgent.knowledgePage.remove": "Remove from this agent",+ "settingAgent.knowledgePage.title": "Knowledge Base",+ "settingAgent.model.desc": "The model it answers with.",+ "settingAgent.model.title": "Model","settingAgent.modelPolicy.fixedTip": "The model is fixed in Agent Profile and cannot be switched while chatting.","settingAgent.modelPolicy.title": "Model","settingAgent.name.placeholder": "Enter agent name",@@ -1536,6 +1575,8 @@"settingAgent.prompt.mode.visual": "Visual editor","settingAgent.prompt.placeholder": "Enter agent instructions","settingAgent.prompt.title": "Core Instructions",+ "settingAgent.reasoning.desc": "Thinking longer is more accurate, but slower and costlier.",+ "settingAgent.reasoning.title": "Reasoning effort","settingAgent.role.label": "Role","settingAgent.role.placeholder": "What it is responsible for, e.g. Health Assistant","settingAgent.role.unset": "No role set yet",@@ -1545,6 +1586,13 @@"settingAgent.selectionPolicy.membersCanSwitchWhenShared": "Can switch when shared","settingAgent.selectionPolicy.membersCannotSwitch": "Locked","settingAgent.selectionPolicy.membersCannotSwitchWhenShared": "Locked when shared",+ "settingAgent.skills.source.builtin": "Built-in",+ "settingAgent.skills.source.community": "Community",+ "settingAgent.skills.source.custom": "Custom",+ "settingAgent.skillsPage.desc": "A skill is a set of steps it picks up only when a task needs them.",+ "settingAgent.skillsPage.group.desc": "Skills come from your library and are shared by all your agents.",+ "settingAgent.skillsPage.group.title": "Turned on for this agent",+ "settingAgent.skillsPage.title": "Skills","settingAgent.slug.autoPlaceholder": "Leave empty to generate one","settingAgent.slug.error.builtin": "A builtin agent’s identifier can’t be changed","settingAgent.slug.error.invalid": "Use lowercase letters, numbers and hyphens only",@@ -1559,7 +1607,32 @@"settingAgent.tag.placeholder": "Enter tag","settingAgent.tag.title": "Tag","settingAgent.title": "Agent info",+ "settingAgent.tools.close": "Close",+ "settingAgent.tools.countOfTotal": "{{count}} of {{total}} turned on",+ "settingAgent.tools.detail.tools_one": "{{count}} tool it gives the agent",+ "settingAgent.tools.detail.tools_other": "{{count}} tools it gives the agent",+ "settingAgent.tools.disable": "Turn off",+ "settingAgent.tools.enable": "Turn on",+ "settingAgent.tools.level.agentDesc": "Belong to this agent alone. When a name clashes, these run first.",+ "settingAgent.tools.level.libraryDesc": "Shared by all your agents. Connection and credentials are managed in your library.",+ "settingAgent.tools.level.libraryEmpty": "Nothing from the library is turned on for this agent yet",+ "settingAgent.tools.level.skillsEmpty": "No skills are turned on for this agent yet",+ "settingAgent.tools.level.workspaceDesc": "Shared across the workspace. Connection and credentials are managed in the workspace library.",+ "settingAgent.tools.manageLibrary": "Manage library",+ "settingAgent.tools.remove": "Remove from this agent",+ "settingAgent.tools.showAll": "Show all {{count}}",+ "settingAgent.tools.showLess": "Show less",+ "settingAgent.tools.toolCount_one": "{{count}} tool",+ "settingAgent.tools.toolCount_other": "{{count}} tools",+ "settingAgent.tools.type.builtin": "Built-in tool",+ "settingAgent.tools.type.composio": "Connected app",+ "settingAgent.tools.type.custom-connector": "Custom connector",+ "settingAgent.tools.type.lobehub-skill": "Connected app",+ "settingAgent.tools.type.plugin": "Plugin or skill",+ "settingAgent.tools.type.skill": "Skill","settingAgent.toolsConfig.title": "Tools",+ "settingAgent.toolsPage.desc": "Connect what it can act on: look things up, read files, call your services.",+ "settingAgent.toolsPage.title": "Tools and connectors","settingAgent.topicSharePolicy.membersCanShare": "Members can share","settingAgent.topicSharePolicy.membersCannotShare": "Creator and owners only","settingAgent.topicSharePolicy.title": "Topic sharing",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex d6853694809..67dc0ccca32 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -2375,14 +2375,23 @@"supervisor.todoList.allComplete": "所有任务已完成","supervisor.todoList.title": "任务完成","tab.backToChat": "返回对话",+ "tab.context": "上下文",+ "tab.engine": "引擎",+ "tab.environment": "执行环境","tab.group.identity": "身份",+ "tab.group.setup": "配置",+ "tab.group.shape": "塑造","tab.groupProfile": "群组档案",+ "tab.instruction": "指令","tab.integration": "IM 机器人",+ "tab.knowledge": "知识库","tab.mail": "邮箱","tab.profile": "助理档案","tab.profileBasic": "基础档案","tab.search": "搜索",+ "tab.skills": "技能","tab.tasks": "任务",+ "tab.tools": "工具与连接","task.activity.calling": "正在调用技能…","task.activity.clientExecuting": "本地执行中…","task.activity.generating": "正在生成回复…",diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.jsonindex 8ce525b860e..e097f4c4ade 100644--- a/locales/zh-CN/electron.json+++ b/locales/zh-CN/electron.json@@ -29,12 +29,16 @@"navigation.discoverModels": "发现模型","navigation.discoverProviders": "发现模型服务商","navigation.document": "文档",+ "navigation.engine": "助理引擎",+ "navigation.environment": "助理执行环境","navigation.goals": "目标","navigation.group": "群组","navigation.groupChat": "群组对话","navigation.groupProfile": "群组档案","navigation.home": "首页","navigation.image": "图像",+ "navigation.instruction": "助理指令",+ "navigation.knowledge": "助理知识库","navigation.knowledgeBase": "知识库","navigation.lobehub": "LobeHub","navigation.mail": "邮箱",@@ -69,9 +73,11 @@"navigation.selfLearning": "自进化","navigation.settings": "设置","navigation.sharedAgent": "分享助手",+ "navigation.skills": "助理技能","navigation.stats": "统计","navigation.task": "任务","navigation.tasks": "任务",+ "navigation.tools": "助理工具与连接","navigation.topics": "话题","navigation.unpin": "取消固定","navigation.video": "视频",diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.jsonindex 3026a90e4e5..35ea5293ef7 100644--- a/locales/zh-CN/setting.json+++ b/locales/zh-CN/setting.json@@ -1445,7 +1445,7 @@"settingAbout.remoteDebugging.restartToApply": "重启 LobeHub 后生效。","settingAbout.remoteDebugging.title": "远程调试","settingAgent.agentTools.add": "添加工具",- "settingAgent.agentTools.agentEmpty": "还没有 Agent 专属工具",+ "settingAgent.agentTools.agentEmpty": "还没有只给它用的工具","settingAgent.agentTools.authorizedBy": "由 {{name}} 授权","settingAgent.agentTools.badge.agentOnly": "Agent 专属","settingAgent.agentTools.badge.copy": "副本",@@ -1467,9 +1467,9 @@"settingAgent.agentTools.priorityTooltip": "工具同名时,运行时优先使用 Agent 专属工具,其次才使用你的用户工具。","settingAgent.agentTools.priorityTooltipWorkspace": "工具同名时,运行时优先使用该 Agent 维度的工具,其次兜底到当前工作空间下 user 维度的用户工具。","settingAgent.agentTools.removeOwnedConfirm": "删除这个 Agent 专属连接器?其凭据将被移除。",- "settingAgent.agentTools.tabAgent": "Agent 工具",- "settingAgent.agentTools.tabUser": "用户工具",- "settingAgent.agentTools.tabWorkspace": "Workspace 工具",+ "settingAgent.agentTools.tabAgent": "只给它用",+ "settingAgent.agentTools.tabUser": "来自我的库",+ "settingAgent.agentTools.tabWorkspace": "来自工作区的库","settingAgent.artwork.avatar.generating": "正在生成符合 Agent 设定的形象…","settingAgent.artwork.avatar.image": "AI 形象","settingAgent.artwork.background.empty": "添加背景,让助理拥有更鲜明的视觉形象",@@ -1504,6 +1504,26 @@"settingAgent.devicePolicy.privateDevicePublicAgent": "私人设备仅可用于私有助手,其他成员无法连接","settingAgent.devicePolicy.selectTarget": "选择环境","settingAgent.devicePolicy.title": "执行环境",+ "settingAgent.driver.brings.harness": "LobeHub 驾具:模型、工具和指令都由你来选。",+ "settingAgent.driver.brings.hetero": "自带模型、工具和指令,你只需要设置它在哪里运行。",+ "settingAgent.driver.groupCli": "异构 Agent · 本机 CLI",+ "settingAgent.driver.groupHarness": "LobeHub 自研",+ "settingAgent.driver.groupRemote": "异构 Agent · 远程平台",+ "settingAgent.driver.harness": "LobeHub",+ "settingAgent.driver.switchBackHarness": "核心指令和工具会重新生效。",+ "settingAgent.driver.switchFailed": "切换失败,再试一次。",+ "settingAgent.driver.switchKeepTopics": "已有话题会保留,之后的新消息由 {{name}} 处理。",+ "settingAgent.driver.switchLosesPrompt": "核心指令不会再生效:{{name}} 使用它自己的系统提示。",+ "settingAgent.driver.switchOk": "切换驱动",+ "settingAgent.driver.switchTitle": "把驱动换成 {{name}}?",+ "settingAgent.driver.switched": "已切换到 {{name}}",+ "settingAgent.driver.title": "驱动",+ "settingAgent.engine.configTitle": "{{name}} 设置",+ "settingAgent.engine.desc": "决定用什么驱动它、在哪里运行。",+ "settingAgent.engine.heteroHint": "{{name}} 在哪里运行、需要什么,在“执行环境”里设置。",+ "settingAgent.engine.title": "引擎",+ "settingAgent.environment.desc": "它在哪里运行,以及在那里需要什么。",+ "settingAgent.environment.title": "执行环境","settingAgent.export.dialogTitle": "导出助理档案","settingAgent.export.enabledPlugins": "已启用技能","settingAgent.export.error": "助理档案导出失败",@@ -1519,7 +1539,26 @@"settingAgent.identity.done": "完成","settingAgent.identity.edit": "编辑身份信息","settingAgent.identity.saveFailed": "身份信息保存失败,请重试",+ "settingAgent.identity.saved": "已保存","settingAgent.identity.untitled": "未命名助理",+ "settingAgent.instruction.desc": "它是谁、该怎么做事。每次回复前它都会先读这一段。",+ "settingAgent.instruction.title": "指令",+ "settingAgent.knowledgePage.addFile": "添加文件",+ "settingAgent.knowledgePage.addLibrary": "添加知识库",+ "settingAgent.knowledgePage.desc": "它回答时可以去查的知识库和文件。",+ "settingAgent.knowledgePage.files.countMore": "{{count}}+ 个文件",+ "settingAgent.knowledgePage.files.count_one": "{{count}} 个文件",+ "settingAgent.knowledgePage.files.count_other": "{{count}} 个文件",+ "settingAgent.knowledgePage.files.desc": "不放进知识库、单独给它读的文件。",+ "settingAgent.knowledgePage.files.empty": "还没有关联文件",+ "settingAgent.knowledgePage.files.title": "文件",+ "settingAgent.knowledgePage.libraries.desc": "你在“资源”里管理的知识库。关掉开关就不再查它,但会保留。",+ "settingAgent.knowledgePage.libraries.empty": "还没有关联知识库",+ "settingAgent.knowledgePage.libraries.title": "知识库",+ "settingAgent.knowledgePage.remove": "从这个助理移除",+ "settingAgent.knowledgePage.title": "知识库",+ "settingAgent.model.desc": "回答时用的模型。",+ "settingAgent.model.title": "模型","settingAgent.modelPolicy.fixedTip": "模型已在助理档案中固定,聊天时不可切换。","settingAgent.modelPolicy.title": "模型","settingAgent.name.placeholder": "请输入助理名称",@@ -1536,6 +1575,8 @@"settingAgent.prompt.mode.visual": "所见即所得","settingAgent.prompt.placeholder": "请输入助理指令","settingAgent.prompt.title": "核心指令",+ "settingAgent.reasoning.desc": "想得越久越准,但更慢也更贵。",+ "settingAgent.reasoning.title": "推理强度","settingAgent.role.label": "角色","settingAgent.role.placeholder": "负责领域,例如:健康助手","settingAgent.role.unset": "暂未设定角色",@@ -1545,6 +1586,13 @@"settingAgent.selectionPolicy.membersCanSwitchWhenShared": "公开后可切换","settingAgent.selectionPolicy.membersCannotSwitch": "锁定","settingAgent.selectionPolicy.membersCannotSwitchWhenShared": "公开后锁定",+ "settingAgent.skills.source.builtin": "内建",+ "settingAgent.skills.source.community": "社区",+ "settingAgent.skills.source.custom": "自己写的",+ "settingAgent.skillsPage.desc": "技能是一套做事的步骤,只有任务需要时它才会去读。",+ "settingAgent.skillsPage.group.desc": "技能来自你的库,所有助理共用。",+ "settingAgent.skillsPage.group.title": "给这个助理打开的",+ "settingAgent.skillsPage.title": "技能","settingAgent.slug.autoPlaceholder": "留空则自动生成","settingAgent.slug.error.builtin": "内置助理的标识不可修改","settingAgent.slug.error.invalid": "只能使用小写字母、数字和连字符",@@ -1559,7 +1607,32 @@"settingAgent.tag.placeholder": "请输入标签","settingAgent.tag.title": "标签","settingAgent.title": "助理信息",+ "settingAgent.tools.close": "关闭详情",+ "settingAgent.tools.countOfTotal": "已打开 {{count}} / 共 {{total}} 个",+ "settingAgent.tools.detail.tools_one": "给助理带来 {{count}} 个工具",+ "settingAgent.tools.detail.tools_other": "给助理带来 {{count}} 个工具",+ "settingAgent.tools.disable": "关闭",+ "settingAgent.tools.enable": "打开",+ "settingAgent.tools.level.agentDesc": "只属于这个助理。重名时,它们优先运行。",+ "settingAgent.tools.level.libraryDesc": "你所有助理共用。连接和凭证在“我的库”里统一管理。",+ "settingAgent.tools.level.libraryEmpty": "还没有从库里启用任何工具",+ "settingAgent.tools.level.skillsEmpty": "还没有给这个助理打开任何技能",+ "settingAgent.tools.level.workspaceDesc": "整个工作区共用。连接和凭证在工作区的库里统一管理。",+ "settingAgent.tools.manageLibrary": "管理库",+ "settingAgent.tools.remove": "从这个助理移除",+ "settingAgent.tools.showAll": "展开全部 {{count}} 个",+ "settingAgent.tools.showLess": "收起",+ "settingAgent.tools.toolCount_one": "{{count}} 个工具",+ "settingAgent.tools.toolCount_other": "{{count}} 个工具",+ "settingAgent.tools.type.builtin": "内置工具",+ "settingAgent.tools.type.composio": "已连接的应用",+ "settingAgent.tools.type.custom-connector": "自定义连接器",+ "settingAgent.tools.type.lobehub-skill": "已连接的应用",+ "settingAgent.tools.type.plugin": "插件或技能",+ "settingAgent.tools.type.skill": "技能","settingAgent.toolsConfig.title": "工具",+ "settingAgent.toolsPage.desc": "连上它能动手的东西:查资料、读文件、调用你的服务。",+ "settingAgent.toolsPage.title": "工具与连接","settingAgent.topicSharePolicy.membersCanShare": "成员可分享","settingAgent.topicSharePolicy.membersCannotShare": "仅创建者和所有者","settingAgent.topicSharePolicy.title": "话题分享",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 50b6246fe2f..8d95214089e 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1985,10 +1985,19 @@ export default {'tab.groupProfile': 'Group Profile','tab.backToChat': 'Back to chat','tab.group.identity': 'Identity',+ 'tab.group.shape': 'Shape',+ 'tab.group.setup': 'Configure',+ 'tab.context': 'Context',+ 'tab.engine': 'Engine',+ 'tab.environment': 'Environment',+ 'tab.instruction': 'Instruction',+ 'tab.knowledge': 'Knowledge Base',+ 'tab.tools': 'Tools & Connectors','tab.integration': 'IM Bots','tab.mail': 'Mail','tab.profile': 'Agent Profile','tab.profileBasic': 'Profile',+ 'tab.skills': 'Skills','tab.search': 'Search','tab.tasks': 'Tasks','task.activity.calling': 'Calling Skill...',diff --git a/packages/locales/src/default/electron.ts b/packages/locales/src/default/electron.tsindex 3cafa559850..248a2ede4d0 100644--- a/packages/locales/src/default/electron.ts+++ b/packages/locales/src/default/electron.ts@@ -29,6 +29,12 @@ export default {'navigation.image': 'Image','navigation.knowledgeBase': 'Knowledge Base','navigation.lobehub': 'LobeHub',+ 'navigation.engine': 'Agent Engine',+ 'navigation.environment': 'Agent Environment',+ 'navigation.instruction': 'Agent Instruction',+ 'navigation.knowledge': 'Agent Knowledge Base',+ 'navigation.tools': 'Agent Tools',+ 'navigation.skills': 'Agent Skills','navigation.mail': 'Mail','navigation.memory': 'Memory','navigation.memoryContexts': 'Memory - Contexts',diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.tsindex e644742ecd8..46ef39dfa76 100644--- a/packages/locales/src/default/setting.ts+++ b/packages/locales/src/default/setting.ts@@ -1278,6 +1278,7 @@ export default {'settingAgent.identity.createFailed': 'Could not create the agent, please try again','settingAgent.identity.done': 'Done','settingAgent.identity.edit': 'Edit identity',+ 'settingAgent.identity.saved': 'Saved','settingAgent.identity.saveFailed': 'Could not save the identity, please try again','settingAgent.identity.untitled': 'Unnamed agent','settingAgent.role.label': 'Role',@@ -1301,7 +1302,7 @@ export default {'settingAgent.prompt.placeholder': 'Enter agent instructions','settingAgent.prompt.title': 'Core Instructions','settingAgent.agentTools.add': 'Add Tool',- 'settingAgent.agentTools.agentEmpty': 'No agent-exclusive tools yet',+ 'settingAgent.agentTools.agentEmpty': 'Nothing only for this agent yet','settingAgent.agentTools.authorizedBy': 'Authorized by {{name}}','settingAgent.agentTools.badge.agentOnly': 'Agent-only','settingAgent.agentTools.badge.copy': 'Copy',@@ -1327,9 +1328,95 @@ export default {'When tools share a name, this agent-scoped tool runs first at runtime; the workspace user tools are the fallback.','settingAgent.agentTools.removeOwnedConfirm':'Delete this agent-exclusive connector? Its credentials will be removed.',- 'settingAgent.agentTools.tabAgent': 'Agent Tools',- 'settingAgent.agentTools.tabUser': 'User Tools',- 'settingAgent.agentTools.tabWorkspace': 'Workspace Tools',+ 'settingAgent.agentTools.tabAgent': 'Only for this agent',+ 'settingAgent.agentTools.tabUser': 'From my library',+ 'settingAgent.agentTools.tabWorkspace': 'From the workspace library',+ 'settingAgent.tools.level.agentDesc':+ 'Belong to this agent alone. When a name clashes, these run first.',+ 'settingAgent.tools.level.libraryDesc':+ 'Shared by all your agents. Connection and credentials are managed in your library.',+ 'settingAgent.tools.level.libraryEmpty':+ 'Nothing from the library is turned on for this agent yet',+ 'settingAgent.tools.level.skillsEmpty': 'No skills are turned on for this agent yet',+ 'settingAgent.tools.level.workspaceDesc':+ 'Shared across the workspace. Connection and credentials are managed in the workspace library.',+ 'settingAgent.tools.showAll': 'Show all {{count}}',+ 'settingAgent.tools.showLess': 'Show less',+ 'settingAgent.tools.toolCount_one': '{{count}} tool',+ 'settingAgent.tools.toolCount_other': '{{count}} tools',+ 'settingAgent.tools.countOfTotal': '{{count}} of {{total}} turned on',+ 'settingAgent.tools.enable': 'Turn on',+ 'settingAgent.tools.disable': 'Turn off',+ 'settingAgent.tools.close': 'Close',+ 'settingAgent.tools.detail.tools_one': '{{count}} tool it gives the agent',+ 'settingAgent.tools.detail.tools_other': '{{count}} tools it gives the agent',+ 'settingAgent.tools.manageLibrary': 'Manage library',+ 'settingAgent.tools.remove': 'Remove from this agent',+ 'settingAgent.tools.type.builtin': 'Built-in tool',+ 'settingAgent.tools.type.composio': 'Connected app',+ 'settingAgent.tools.type.custom-connector': 'Custom connector',+ 'settingAgent.tools.type.lobehub-skill': 'Connected app',+ 'settingAgent.tools.type.plugin': 'Plugin or skill',+ 'settingAgent.tools.type.skill': 'Skill',+ 'settingAgent.driver.groupCli': 'Heterogeneous agent · local CLI',+ 'settingAgent.driver.groupHarness': 'Built by LobeHub',+ 'settingAgent.driver.groupRemote': 'Heterogeneous agent · remote platform',+ 'settingAgent.driver.harness': 'LobeHub',+ 'settingAgent.driver.brings.harness':+ "LobeHub's own harness: you choose the model, tools and instruction.",+ 'settingAgent.driver.brings.hetero':+ 'Brings its own model, tools and instruction; you set where it runs.',+ 'settingAgent.driver.switchBackHarness': 'The core instruction and tools take effect again.',+ 'settingAgent.driver.switchFailed': 'Could not switch. Try again.',+ 'settingAgent.driver.switchKeepTopics':+ 'Existing topics are kept; new messages are handled by {{name}}.',+ 'settingAgent.driver.switchLosesPrompt':+ 'The core instruction stops applying: {{name}} uses its own system prompt.',+ 'settingAgent.driver.switchOk': 'Switch driver',+ 'settingAgent.driver.switchTitle': 'Switch the driver to {{name}}?',+ 'settingAgent.driver.switched': 'Switched to {{name}}',+ 'settingAgent.driver.title': 'Driver',+ 'settingAgent.engine.desc': 'What runs this agent, and where it works.',+ 'settingAgent.engine.heteroHint':+ 'Where {{name}} runs and what it needs there is set under Environment.',+ 'settingAgent.engine.configTitle': '{{name}} settings',+ 'settingAgent.engine.title': 'Engine',+ 'settingAgent.environment.title': 'Environment',+ 'settingAgent.environment.desc': 'Where it runs, and what it needs there.',+ 'settingAgent.instruction.title': 'Instruction',+ 'settingAgent.instruction.desc':+ 'Who it is and how it should behave. It reads this before every reply.',+ 'settingAgent.knowledgePage.title': 'Knowledge Base',+ 'settingAgent.knowledgePage.desc': 'The libraries and files it can search when it answers.',+ 'settingAgent.knowledgePage.libraries.title': 'Libraries',+ 'settingAgent.knowledgePage.libraries.desc':+ 'Collections you manage in Resources. Switch one off to keep it without searching it.',+ 'settingAgent.knowledgePage.libraries.empty': 'No library attached yet',+ 'settingAgent.knowledgePage.files.count_one': '{{count}} file',+ 'settingAgent.knowledgePage.files.count_other': '{{count}} files',+ 'settingAgent.knowledgePage.files.countMore': '{{count}}+ files',+ 'settingAgent.knowledgePage.files.title': 'Files',+ 'settingAgent.knowledgePage.files.desc': 'Single files it can read without a library.',+ 'settingAgent.knowledgePage.files.empty': 'No file attached yet',+ 'settingAgent.knowledgePage.addLibrary': 'Add library',+ 'settingAgent.knowledgePage.addFile': 'Add file',+ 'settingAgent.knowledgePage.remove': 'Remove from this agent',+ 'settingAgent.model.desc': 'The model it answers with.',+ 'settingAgent.model.title': 'Model',+ 'settingAgent.reasoning.desc': 'Thinking longer is more accurate, but slower and costlier.',+ 'settingAgent.reasoning.title': 'Reasoning effort',+ 'settingAgent.toolsPage.desc':+ 'Connect what it can act on: look things up, read files, call your services.',+ 'settingAgent.toolsPage.title': 'Tools and connectors',+ 'settingAgent.skillsPage.title': 'Skills',+ 'settingAgent.skillsPage.desc':+ 'A skill is a set of steps it picks up only when a task needs them.',+ 'settingAgent.skillsPage.group.title': 'Turned on for this agent',+ 'settingAgent.skillsPage.group.desc':+ 'Skills come from your library and are shared by all your agents.',+ 'settingAgent.skills.source.builtin': 'Built-in',+ 'settingAgent.skills.source.community': 'Community',+ 'settingAgent.skills.source.custom': 'Custom','settingAgent.devicePolicy.noPublicDevice': 'No public devices','settingAgent.devicePolicy.privateDeviceFixed':'A fixed environment can only use public workspace devices',diff --git a/scripts/stylexMigration/legacyFiles.json b/scripts/stylexMigration/legacyFiles.jsonindex f4cb2697100..3349775c29e 100644--- a/scripts/stylexMigration/legacyFiles.json+++ b/scripts/stylexMigration/legacyFiles.json@@ -733,7 +733,6 @@"src/routes/(main)/agent/profile/features/ProfileEditor/HeterogeneousAgentStatusCard.tsx","src/routes/(main)/agent/profile/features/ProfileEditor/RemoteAgentConfigCard.tsx","src/routes/(main)/agent/profile/features/ProfileEditor/WorkspaceAgentPolicyCard.tsx",- "src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx","src/routes/(main)/eval/_layout/style.ts","src/routes/(main)/eval/bench/[benchmarkId]/_layout/Sidebar/Header/BenchmarkHead.tsx","src/routes/(main)/eval/bench/[benchmarkId]/_layout/style.ts",diff --git a/src/features/AgentDriver/index.tsx b/src/features/AgentDriver/index.tsxnew file mode 100644index 00000000000..f1886909fd3--- /dev/null+++ b/src/features/AgentDriver/index.tsx@@ -0,0 +1,215 @@+'use client';++import { DEFAULT_PROVIDER } from '@lobechat/business-const';+import { DEFAULT_MODEL } from '@lobechat/const';+import { confirmModal, cssVar, Flexbox, Icon, Text, toast } from '@lobehub/ui';+import { SparklesIcon } from 'lucide-react';+import { memo, type ReactNode } from 'react';+import { useTranslation } from 'react-i18next';++import { CONNECTABLE_PROVIDERS, getConnectableProvider } from '@/features/ConnectAgent/providers';+import { useAgentStore } from '@/store/agent';+import { agentSelectors } from '@/store/agent/selectors';+import { useUserStore } from '@/store/user';+import { settingsSelectors } from '@/store/user/selectors';++import { type DriverTarget, planDriverRollback, planDriverSwitch } from './switchPlan';++const HARNESS = 'lobehub';++interface AgentDriverSelectProps {+ agentId: string;+ /** False when something else owns the choice, e.g. an agent bound to a device. */+ canEdit: boolean;+}++interface DriverTileProps {+ disabled: boolean;+ icon: ReactNode;+ label: string;+ onChoose: () => void;+ selected: boolean;+}++/** One driver as a tile; the chosen one is outlined, and one that cannot be picked is dimmed. */+const DriverTile = memo<DriverTileProps>(({ disabled, icon, label, onChoose, selected }) => (+ <Flexbox+ horizontal+ align={'center'}+ aria-checked={selected}+ gap={10}+ role={'radio'}+ tabIndex={disabled ? -1 : 0}+ style={{+ background: selected ? cssVar.colorFillTertiary : 'transparent',+ border: `1px solid ${selected ? cssVar.colorText : cssVar.colorBorderSecondary}`,+ borderRadius: 10,+ cursor: disabled ? 'not-allowed' : 'pointer',+ opacity: disabled ? 0.5 : 1,+ padding: '10px 12px',+ }}+ onClick={() => {+ if (!disabled) onChoose();+ }}+ onKeyDown={(event) => {+ if (event.key === 'Enter' && !disabled) onChoose();+ }}+ >+ {icon}+ <Text ellipsis style={{ fontWeight: selected ? 600 : 400 }}>+ {label}+ </Text>+ </Flexbox>+));++DriverTile.displayName = 'DriverTile';++/**+ * Which engine runs this agent: LobeHub Harness, where the model, tools and instruction are+ * all chosen on this agent, or a heterogeneous agent (Claude Code, Codex, …) that brings its+ * own runtime. It is one field whose value is the current driver — choosing another asks+ * first, because what can be configured below changes with it.+ *+ * Remote platform drivers (OpenClaw, Hermes) are listed but cannot be picked here: they only+ * exist bound to a device, and picking the device is part of creating them.+ */+const AgentDriverSelect = memo<AgentDriverSelectProps>(({ agentId, canEdit }) => {+ const { t } = useTranslation('setting');+ const heterogeneousProvider = useAgentStore(+ (s) => agentSelectors.getAgentConfigById(agentId)(s)?.agencyConfig?.heterogeneousProvider,+ );+ const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);+ const defaults = useUserStore(settingsSelectors.defaultAgentConfig);++ const harnessName = t('settingAgent.driver.harness');+ const current = heterogeneousProvider?.type ?? HARNESS;++ const switchTo = (target: DriverTarget, name: string) => {+ confirmModal({+ cancelText: t('cancel', { ns: 'common' }),+ okText: t('settingAgent.driver.switchOk'),+ title: t('settingAgent.driver.switchTitle', { name }),+ content: (+ <Flexbox gap={8}>+ <Text>{t('settingAgent.driver.switchKeepTopics', { name })}</Text>+ {!heterogeneousProvider && target.kind === 'hetero' && (+ <Text type={'warning'}>{t('settingAgent.driver.switchLosesPrompt', { name })}</Text>+ )}+ {target.kind === 'harness' && <Text>{t('settingAgent.driver.switchBackHarness')}</Text>}+ </Flexbox>+ ),+ onOk: async () => {+ const plan = planDriverSwitch({+ currentlyHeterogeneous: !!heterogeneousProvider,+ defaults: {+ model: defaults.model ?? DEFAULT_MODEL,+ provider: defaults.provider ?? DEFAULT_PROVIDER,+ },+ target,+ });++ // What the agent is now, kept so a half-finished switch can be undone.+ const before = agentSelectors.getAgentConfigById(agentId)(useAgentStore.getState());+ const previous = {+ heterogeneousProvider: before?.agencyConfig?.heterogeneousProvider,+ provider: before?.provider,+ };++ try {+ // Sequential on purpose: the second write must merge into the cleared block.+ for (const patch of plan) await updateAgentConfigById(agentId, patch);+ toast.success(t('settingAgent.driver.switched', { name }));+ } catch {+ // Switching between two external drivers is clear-then-write. If the write fails after+ // the clear, put the previous driver back rather than leave the agent on LobeHub with a+ // stale provider stamp.+ if (plan.length > 1 && previous.heterogeneousProvider) {+ try {+ await updateAgentConfigById(agentId, planDriverRollback(previous));+ } catch {+ // The failure toast below still tells the person the switch did not happen.+ }+ }+ toast.error(t('settingAgent.driver.switchFailed'));+ }+ },+ });+ };++ const choose = (value: string) => {+ if (value === current) return;++ if (value === HARNESS) return switchTo({ kind: 'harness' }, harnessName);++ const provider = getConnectableProvider(value as never);+ if (!provider || provider.kind === 'platform') return;+ switchTo({ command: provider.command, kind: 'hetero', type: provider.type }, provider.title);+ };++ const grid = (children: ReactNode) => (+ <div+ role={'radiogroup'}+ style={{+ display: 'grid',+ gap: 8,+ gridTemplateColumns: 'repeat(auto-fill, minmax(170px, 1fr))',+ }}+ >+ {children}+ </div>+ );++ const providerTile = (provider: (typeof CONNECTABLE_PROVIDERS)[number]) => (+ <DriverTile+ disabled={!canEdit || (provider.kind === 'platform' && provider.type !== current)}+ icon={<provider.brand.Avatar size={20} />}+ key={provider.type}+ label={provider.title}+ selected={provider.type === current}+ onChoose={() => choose(provider.type)}+ />+ );++ const group = (title: string, children: ReactNode) => (+ <Flexbox gap={8}>+ <Text fontSize={12} type={'secondary'}>+ {title}+ </Text>+ {children}+ </Flexbox>+ );++ // Every option is in view, so the choice is a look rather than a lookup.+ return (+ <Flexbox gap={16}>+ {group(+ t('settingAgent.driver.groupHarness'),+ grid(+ <DriverTile+ disabled={!canEdit}+ icon={<Icon icon={SparklesIcon} size={20} />}+ label={harnessName}+ selected={current === HARNESS}+ onChoose={() => choose(HARNESS)}+ />,+ ),+ )}+ {group(+ t('settingAgent.driver.groupCli'),+ grid(+ CONNECTABLE_PROVIDERS.filter((p) => p.kind !== 'platform').map((p) => providerTile(p)),+ ),+ )}+ {group(+ t('settingAgent.driver.groupRemote'),+ grid(+ CONNECTABLE_PROVIDERS.filter((p) => p.kind === 'platform').map((p) => providerTile(p)),+ ),+ )}+ </Flexbox>+ );+});++AgentDriverSelect.displayName = 'AgentDriverSelect';++export default AgentDriverSelect;diff --git a/src/features/AgentDriver/switchPlan.test.ts b/src/features/AgentDriver/switchPlan.test.tsnew file mode 100644index 00000000000..821f1138996--- /dev/null+++ b/src/features/AgentDriver/switchPlan.test.ts@@ -0,0 +1,59 @@+import { describe, expect, it } from 'vitest';++import { planDriverRollback, planDriverSwitch } from './switchPlan';++const defaults = { model: 'gpt-5.5', provider: 'openai' };++describe('planDriverSwitch', () => {+ it('moves a LobeHub agent onto a heterogeneous driver in one write', () => {+ const plan = planDriverSwitch({+ currentlyHeterogeneous: false,+ defaults,+ target: { command: 'claude', kind: 'hetero', type: 'claude-code' },+ });++ expect(plan).toEqual([+ {+ agencyConfig: { heterogeneousProvider: { command: 'claude', type: 'claude-code' } },+ provider: 'claude-code',+ },+ ]);+ });++ it('clears the old runtime before writing the new one so no credentials carry over', () => {+ const plan = planDriverSwitch({+ currentlyHeterogeneous: true,+ defaults,+ target: { command: 'codex', kind: 'hetero', type: 'codex' },+ });++ expect(plan).toHaveLength(2);+ expect(plan[0]).toEqual({ agencyConfig: { heterogeneousProvider: null } });+ expect(plan[1]).toMatchObject({ provider: 'codex' });+ });++ it('hands the provider and model back to the default chat model when leaving a runtime', () => {+ const plan = planDriverSwitch({+ currentlyHeterogeneous: true,+ defaults,+ target: { kind: 'harness' },+ });++ expect(plan).toEqual([+ { agencyConfig: { heterogeneousProvider: null }, model: 'gpt-5.5', provider: 'openai' },+ ]);+ });+});++describe('planDriverRollback', () => {+ it('writes the previous provider block and its stamp back', () => {+ const previous = { command: 'claude', env: { A: '1' }, type: 'claude-code' };++ expect(+ planDriverRollback({ heterogeneousProvider: previous, provider: 'claude-code' }),+ ).toEqual({+ agencyConfig: { heterogeneousProvider: previous },+ provider: 'claude-code',+ });+ });+});diff --git a/src/features/AgentDriver/switchPlan.ts b/src/features/AgentDriver/switchPlan.tsnew file mode 100644index 00000000000..6df49bdce21--- /dev/null+++ b/src/features/AgentDriver/switchPlan.ts@@ -0,0 +1,75 @@+import type { LobeAgentConfig } from '@lobechat/types';+import type { PartialDeep } from 'type-fest';++/**+ * What an agent runs on: LobeHub's own harness (the model and tools are chosen here),+ * or a heterogeneous agent that brings its own runtime (Claude Code, Codex, …).+ */+export type DriverTarget = { kind: 'harness' } | { command?: string; kind: 'hetero'; type: string };++interface DefaultChatModel {+ model: string;+ provider: string;+}++/**+ * The config writes that move an agent to another driver, in the order they must land.+ *+ * Why not one patch: `updateConfig` deep-merges, so writing the new provider over the old+ * one would keep the old driver's `env`, `authMode` and `apiConfig` — credentials and+ * routing that mean nothing (or something wrong) to the new runtime. Clearing the whole+ * block first and writing the new one second leaves nothing behind.+ *+ * A heterogeneous agent is stamped with its type as `provider` (run attribution, agent+ * list, message tags read it), so leaving a driver must hand `provider` back to a real+ * chat provider, or those readers would keep attributing runs to the old runtime.+ */+export const planDriverSwitch = ({+ currentlyHeterogeneous,+ defaults,+ target,+}: {+ currentlyHeterogeneous: boolean;+ defaults: DefaultChatModel;+ target: DriverTarget;+}): PartialDeep<LobeAgentConfig>[] => {+ const clear = { agencyConfig: { heterogeneousProvider: null } };++ if (target.kind === 'harness') {+ return [+ {+ ...clear,+ model: defaults.model,+ provider: defaults.provider,+ } as unknown as PartialDeep<LobeAgentConfig>,+ ];+ }++ const apply = {+ agencyConfig: { heterogeneousProvider: { command: target.command, type: target.type } },+ provider: target.type,+ } as unknown as PartialDeep<LobeAgentConfig>;++ return currentlyHeterogeneous+ ? [clear as unknown as PartialDeep<LobeAgentConfig>, apply]+ : [apply];+};++/**+ * The write that puts a heterogeneous agent back as it was, for when a switch between two+ * heterogeneous drivers fails after the first driver was cleared. Two requests cannot be one+ * transaction here, so the failure path restores instead: the old provider block and its+ * `provider` stamp are written back, which leaves the agent on its previous driver rather than+ * half way to the harness.+ */+export const planDriverRollback = ({+ heterogeneousProvider,+ provider,+}: {+ heterogeneousProvider: unknown;+ provider?: string;+}): PartialDeep<LobeAgentConfig> =>+ ({+ agencyConfig: { heterogeneousProvider },+ provider,+ }) as unknown as PartialDeep<LobeAgentConfig>;diff --git a/src/features/AgentIdentityModal/IdentityFields.tsx b/src/features/AgentIdentityModal/IdentityFields.tsxindex 73b1f9ea4ee..2500f524384 100644--- a/src/features/AgentIdentityModal/IdentityFields.tsx+++ b/src/features/AgentIdentityModal/IdentityFields.tsx@@ -42,6 +42,8 @@ export interface IdentityFieldsForm {interface IdentityFieldsProps {/** The agent being edited, so the dice never suggests its own current name back. */agentId?: string;+ /** Focus the name when the form appears; off where the form is part of a page. @default true */+ autoFocus?: boolean;form: IdentityFieldsForm;/** Overrides the slug placeholder, e.g. to say an empty slug is generated. */slugPlaceholder?: string;@@ -51,107 +53,109 @@ interface IdentityFieldsProps {const DESCRIPTION_MAX_LENGTH = 1000;/** Name / role / description / slug, shared by the edit and the create form. */-const IdentityFields = memo<IdentityFieldsProps>(({ agentId, form, slugPlaceholder }) => {- const { t } = useTranslation('setting');- const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);- const { setName } = form;+const IdentityFields = memo<IdentityFieldsProps>(+ ({ agentId, autoFocus = true, form, slugPlaceholder }) => {+ const { t } = useTranslation('setting');+ const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);+ const { setName } = form;- // Same draw as the header's "name it for me" button: the pool matches the- // user's language, and names already visible in the sidebar are excluded so- // the dice never suggests a second "佳宁". Read at click time — the list only- // matters at the moment of the roll.- const rollName = useCallback(() => {- const takenNames = homeAgentListSelectors- .allAgents(useHomeStore.getState())- .filter((agent) => agent.id !== agentId)- .map((agent) => agent.name)- .filter((name): name is string => !!name);+ // Same draw as the header's "name it for me" button: the pool matches the+ // user's language, and names already visible in the sidebar are excluded so+ // the dice never suggests a second "佳宁". Read at click time — the list only+ // matters at the moment of the roll.+ const rollName = useCallback(() => {+ const takenNames = homeAgentListSelectors+ .allAgents(useHomeStore.getState())+ .filter((agent) => agent.id !== agentId)+ .map((agent) => agent.name)+ .filter((name): name is string => !!name);- setName(randomAgentName(locale, takenNames));- }, [agentId, locale, setName]);+ setName(randomAgentName(locale, takenNames));+ }, [agentId, locale, setName]);- return (- <>- <Field label={t('settingAgent.personalName.label')}>- <Input- autoFocus- placeholder={t('settingAgent.personalName.placeholder')}- value={form.name}- suffix={- <ActionIcon- icon={DicesIcon}- size={'small'}- title={t('settingAgent.personalName.roll')}- onClick={rollName}- />- }- onChange={(e) => form.setName(e.target.value)}- />- </Field>- <Field label={t('settingAgent.role.label')}>- <Input- placeholder={t('settingAgent.role.placeholder')}- value={form.title}- onChange={(e) => form.setTitle(e.target.value)}- />- </Field>- {/* Other agents read this when they list agents to pick a teammate, so- the hint says who the text is for. */}- <Field- label={t('settingAgent.description.label')}- hint={- <Text style={{ fontSize: 12 }} type={'secondary'}>- {t('settingAgent.description.hint')}- </Text>- }- >- <TextArea- autoSize={{ maxRows: 6, minRows: 2 }}- maxLength={DESCRIPTION_MAX_LENGTH}- placeholder={t('settingAgent.description.inputPlaceholder')}- value={form.description}- onChange={(e) => form.setDescription(e.target.value)}- />- </Field>- {/* A builtin agent's identifier is not an editable field at all, so it is- not dressed as one: a disabled input still reads as "a control you- can't use right now" and needs a sentence explaining itself. Rendering- the bare marker states the fact and needs no caption. */}- {form.slugLocked ? (- <Field label={t('settingAgent.slug.label')}>- <Text code style={{ alignSelf: 'flex-start', color: cssVar.colorTextSecondary }}>- <span style={{ color: cssVar.colorTextTertiary }}>@</span>- {form.slug}- </Text>+ return (+ <>+ <Field label={t('settingAgent.personalName.label')}>+ <Input+ autoFocus={autoFocus}+ placeholder={t('settingAgent.personalName.placeholder')}+ value={form.name}+ suffix={+ <ActionIcon+ icon={DicesIcon}+ size={'small'}+ title={t('settingAgent.personalName.roll')}+ onClick={rollName}+ />+ }+ onChange={(e) => form.setName(e.target.value)}+ />+ </Field>+ <Field label={t('settingAgent.role.label')}>+ <Input+ placeholder={t('settingAgent.role.placeholder')}+ value={form.title}+ onChange={(e) => form.setTitle(e.target.value)}+ /></Field>- ) : (+ {/* Other agents read this when they list agents to pick a teammate, so+ the hint says who the text is for. */}<Field- label={t('settingAgent.slug.label')}+ label={t('settingAgent.description.label')}hint={- <Text style={{ fontSize: 12 }} type={form.error ? 'danger' : 'secondary'}>- {/* Show the url the current input actually produces — a literal- `<slug>` leaves the reader to do the substitution themselves,- and it updates as they type. Only an empty field falls back to- describing the field in the abstract. */}- {form.error ??- (form.slug.trim()- ? t('settingAgent.slug.openWith', { slug: form.slug.trim().toLowerCase() })- : t('settingAgent.slug.tooltip'))}+ <Text style={{ fontSize: 12 }} type={'secondary'}>+ {t('settingAgent.description.hint')}</Text>}>- <Input- aria-invalid={!!form.error}- data-invalid={form.error ? '' : undefined}- placeholder={slugPlaceholder ?? t('settingAgent.slug.placeholder')}- prefix={'@'}- value={form.slug}- onChange={(e) => form.setSlug(e.target.value)}+ <TextArea+ autoSize={{ maxRows: 6, minRows: 2 }}+ maxLength={DESCRIPTION_MAX_LENGTH}+ placeholder={t('settingAgent.description.inputPlaceholder')}+ value={form.description}+ onChange={(e) => form.setDescription(e.target.value)}/></Field>- )}- </>- );-});+ {/* A builtin agent's identifier is not an editable field at all, so it is+ not dressed as one: a disabled input still reads as "a control you+ can't use right now" and needs a sentence explaining itself. Rendering+ the bare marker states the fact and needs no caption. */}+ {form.slugLocked ? (+ <Field label={t('settingAgent.slug.label')}>+ <Text code style={{ alignSelf: 'flex-start', color: cssVar.colorTextSecondary }}>+ <span style={{ color: cssVar.colorTextTertiary }}>@</span>+ {form.slug}+ </Text>+ </Field>+ ) : (+ <Field+ label={t('settingAgent.slug.label')}+ hint={+ <Text style={{ fontSize: 12 }} type={form.error ? 'danger' : 'secondary'}>+ {/* Show the url the current input actually produces — a literal+ `<slug>` leaves the reader to do the substitution themselves,+ and it updates as they type. Only an empty field falls back to+ describing the field in the abstract. */}+ {form.error ??+ (form.slug.trim()+ ? t('settingAgent.slug.openWith', { slug: form.slug.trim().toLowerCase() })+ : t('settingAgent.slug.tooltip'))}+ </Text>+ }+ >+ <Input+ aria-invalid={!!form.error}+ data-invalid={form.error ? '' : undefined}+ placeholder={slugPlaceholder ?? t('settingAgent.slug.placeholder')}+ prefix={'@'}+ value={form.slug}+ onChange={(e) => form.setSlug(e.target.value)}+ />+ </Field>+ )}+ </>+ );+ },+);export default IdentityFields;diff --git a/src/features/AgentProfileTabs/index.tsx b/src/features/AgentProfileTabs/index.tsxindex dad8d3a9058..acc6cbb0348 100644--- a/src/features/AgentProfileTabs/index.tsx+++ b/src/features/AgentProfileTabs/index.tsx@@ -1,6 +1,6 @@'use client';-import { Segmented } from '@lobehub/ui';+import { Select } from '@lobehub/ui';import { type CSSProperties, memo } from 'react';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';@@ -46,15 +46,19 @@ const MobileAgentProfileTabs = memo<AgentProfileTabsProps>(({ active, agentId })// A lone segment is a label, not a switcher.if (options.length < 2) return null;+ // A strip of segments cannot hold this many pages in the 44px header, so the current page is a+ // compact menu that lists the rest.return (- <Segmented+ <Selectoptions={options}size={'small'}+ style={{ maxWidth: 180, minWidth: 120 }}value={active}- // `Segmented` only fires on a *change*, so the active segment is inert —- // notably on `/channel/:platform`, where Channels stays selected. Going- // back to the platform list is the breadcrumb's job, not this switcher's.- onChange={(value) => navigate(buildAgentProfileTabPath(agentId, value as AgentProfileTab))}+ // Picking the page already shown does nothing: on `/channel/:platform` Channels stays+ // selected, and going back to the platform list is the breadcrumb's job.+ onChange={(value) => {+ if (value !== active) navigate(buildAgentProfileTabPath(agentId, value as AgentProfileTab));+ }}/>);});@@ -62,8 +66,8 @@ const MobileAgentProfileTabs = memo<AgentProfileTabsProps>(({ active, agentId })MobileAgentProfileTabs.displayName = 'MobileAgentProfileTabs';/**- * Segmented switcher for the agent profile group — Profile / Channels /- * Statistics / Share — on mobile, which has no room for a sidebar. Desktop+ * Page switcher for the agent profile group — Profile, Instruction, Engine, Channels,+ * Statistics, … — on mobile, which has no room for a sidebar. Desktop* switches them from the sidebar (`AgentSidebar/ProfileNav`). The surfaces are* separate routes, so a segment writes the URL rather than holding local state:* deep links and back/forward keep working.diff --git a/src/features/AgentProfileTabs/tabOptions.test.ts b/src/features/AgentProfileTabs/tabOptions.test.tsindex 7f7a4a40d9b..d55e1c9c6c1 100644--- a/src/features/AgentProfileTabs/tabOptions.test.ts+++ b/src/features/AgentProfileTabs/tabOptions.test.ts@@ -10,11 +10,17 @@ import {const labels = {'channel': 'tab.integration',+ 'engine': 'tab.engine',+ 'environment': 'tab.environment',+ 'instruction': 'tab.instruction',+ 'knowledge': 'tab.knowledge','mail': 'tab.mail','profile': 'tab.profile','self-evolving': 'title','share': 'share',+ 'skills': 'tab.skills','statistics': 'usageStats.title',+ 'tools': 'tab.tools',};describe('buildAgentProfileTabPath', () => {@@ -61,10 +67,16 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: false,selfLearningSupported: false,shareSupported: true,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['profile',+ 'instruction',+ 'knowledge',+ 'engine',+ 'tools',+ 'skills','channel','statistics','share',@@ -79,9 +91,19 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: false,selfLearningSupported: false,shareSupported: false,+ heterogeneous: false,});- expect(options.map((option) => option.value)).toEqual(['profile', 'channel', 'statistics']);+ expect(options.map((option) => option.value)).toEqual([+ 'profile',+ 'instruction',+ 'knowledge',+ 'engine',+ 'tools',+ 'skills',+ 'channel',+ 'statistics',+ ]);});it('drops the config tabs for a member without edit access', () => {@@ -92,6 +114,7 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: false,selfLearningSupported: false,shareSupported: true,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['statistics']);@@ -105,6 +128,7 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: false,selfLearningSupported: false,shareSupported: false,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['channel', 'statistics']);@@ -118,6 +142,7 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: false,selfLearningSupported: false,shareSupported: false,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['statistics', 'share']);@@ -131,10 +156,16 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: true,selfLearningSupported: false,shareSupported: false,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['profile',+ 'instruction',+ 'knowledge',+ 'engine',+ 'tools',+ 'skills','mail','channel','statistics',@@ -149,6 +180,7 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: false,selfLearningSupported: true,shareSupported: false,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['self-evolving', 'statistics']);@@ -162,6 +194,7 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: false,selfLearningSupported: false,shareSupported: false,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['self-evolving', 'statistics']);@@ -175,25 +208,98 @@ describe('buildAgentProfileTabOptions', () => {mailSupported: true,selfLearningSupported: false,shareSupported: false,+ heterogeneous: false,});expect(options.map((option) => option.value)).toEqual(['statistics']);});});+describe('instruction, knowledge, engine, environment, tools and skills tabs', () => {+ const base = {+ active: 'profile' as const,+ canConfigure: true,+ labels,+ mailSupported: false,+ selfLearningSupported: false,+ shareSupported: false,+ };++ it('leaves instruction, knowledge, tools and skills out, and adds environment, for agents that bring their own', () => {+ const options = buildAgentProfileTabOptions({ ...base, heterogeneous: true });++ expect(options.map((option) => option.value)).toEqual([+ 'profile',+ 'engine',+ 'environment',+ 'channel',+ 'statistics',+ ]);+ });++ it('keeps tools when it owns the current page even if the agent has none', () => {+ const options = buildAgentProfileTabOptions({+ ...base,+ active: 'tools',+ heterogeneous: true,+ });++ expect(options.map((option) => option.value)).toContain('tools');+ });++ it('drops the configuration pages for a member without edit access', () => {+ const options = buildAgentProfileTabOptions({+ ...base,+ active: 'statistics',+ canConfigure: false,+ heterogeneous: false,+ });++ expect(options.map((option) => option.value)).toEqual(['statistics']);+ });++ it.each([+ ['/agent/agt_1/engine', 'engine'],+ ['/agent/agt_1/environment', 'environment'],+ ['/acme/agent/agt_1/tools', 'tools'],+ ['/agent/agt_1/instruction', 'instruction'],+ ['/agent/agt_1/skills', 'skills'],+ ['/agent/agt_1/knowledge', 'knowledge'],+ ])('maps %s to its tab', (pathname, tab) => {+ expect(getAgentProfileTab(pathname)).toBe(tab);+ });+});+describe('groupAgentProfileTabOptions', () => {const option = (value: AgentProfileTab) => ({label: value,value,});- it('keeps the profile on top and puts mail and IM bots under identity', () => {+ it('keeps who-it-is on top, then the setup pages, then mail and IM bots under identity', () => {const groups = groupAgentProfileTabOptions(- (['profile', 'mail', 'channel', 'self-evolving', 'statistics', 'share'] as const).map(option),+ (+ [+ 'profile',+ 'instruction',+ 'knowledge',+ 'engine',+ 'environment',+ 'tools',+ 'skills',+ 'mail',+ 'channel',+ 'self-evolving',+ 'statistics',+ 'share',+ ] as const+ ).map(option),);expect(groups.map((group) => [group.key, group.options.map((item) => item.value)])).toEqual([['profile', ['profile']],+ ['shape', ['instruction', 'knowledge']],+ ['setup', ['engine', 'environment', 'tools', 'skills']],['identity', ['mail', 'channel']],['general', ['self-evolving', 'statistics', 'share']],]);diff --git a/src/features/AgentProfileTabs/tabOptions.ts b/src/features/AgentProfileTabs/tabOptions.tsindex 7d8f919d900..b1a7a52badb 100644--- a/src/features/AgentProfileTabs/tabOptions.ts+++ b/src/features/AgentProfileTabs/tabOptions.ts@@ -1,14 +1,25 @@import urlJoin from 'url-join';export type AgentProfileTab =- 'channel' | 'mail' | 'profile' | 'self-evolving' | 'share' | 'statistics';+ | 'channel'+ | 'engine'+ | 'environment'+ | 'instruction'+ | 'knowledge'+ | 'mail'+ | 'profile'+ | 'self-evolving'+ | 'share'+ | 'skills'+ | 'statistics'+ | 'tools';export interface AgentProfileTabOption {label: string;value: AgentProfileTab;}-export type AgentProfileTabGroupKey = 'general' | 'identity' | 'profile';+export type AgentProfileTabGroupKey = 'general' | 'identity' | 'profile' | 'setup' | 'shape';export interface AgentProfileTabGroup {key: AgentProfileTabGroupKey;@@ -19,7 +30,7 @@ export const buildAgentProfileTabPath = (agentId: string, tab: AgentProfileTab)urlJoin('/agent', agentId, tab);const AGENT_PROFILE_ROUTE =- /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|mail(?:\/[^/]+)?|channel(?:\/[^/]+)?|self-evolving(?:\/[^/]+)*|statistics|share)\/?$/;+ /^(?:\/[^/]+)?\/agent\/[^/]+\/(profile|instruction|knowledge|engine|environment|tools|skills|mail(?:\/[^/]+)?|channel(?:\/[^/]+)?|self-evolving(?:\/[^/]+)*|statistics|share)\/?$/;/*** The profile-group tab a URL belongs to, if any. Anchored on Agent subroutes,@@ -53,6 +64,7 @@ export const buildAgentProfileTabOptions = ({mailSupported,selfLearningSupported,shareSupported,+ heterogeneous,}: {active: AgentProfileTab;canConfigure: boolean;@@ -60,8 +72,22 @@ export const buildAgentProfileTabOptions = ({mailSupported: boolean;selfLearningSupported: boolean;shareSupported: boolean;+ /**+ * Heterogeneous agents (Claude Code, Codex, …) bring their own system prompt, tools and skills,+ * so the instruction, tools and skills pages have nothing to configure for them.+ */+ heterogeneous: boolean;}): AgentProfileTabOption[] => {const showProfile = canConfigure || active === 'profile';+ // Engine, Instruction, Environment, Tools and Skills edit the same agent config as Profile, so+ // they follow its gate.+ const showEngine = canConfigure || active === 'engine';+ const showKnowledge = (canConfigure && !heterogeneous) || active === 'knowledge';+ const showInstruction = (canConfigure && !heterogeneous) || active === 'instruction';+ // Where a heterogeneous agent runs and what it needs there; a harness agent has no such page.+ const showEnvironment = (canConfigure && heterogeneous) || active === 'environment';+ const showTools = (canConfigure && !heterogeneous) || active === 'tools';+ const showSkills = (canConfigure && !heterogeneous) || active === 'skills';const showMail = (canConfigure && mailSupported) || active === 'mail';// Channels can dispatch to a bound device; cloud sandbox support is not required.const showChannel = canConfigure || active === 'channel';@@ -73,6 +99,12 @@ export const buildAgentProfileTabOptions = ({return [showProfile ? { label: labels.profile, value: 'profile' as const } : null,+ showInstruction ? { label: labels.instruction, value: 'instruction' as const } : null,+ showKnowledge ? { label: labels.knowledge, value: 'knowledge' as const } : null,+ showEngine ? { label: labels.engine, value: 'engine' as const } : null,+ showEnvironment ? { label: labels.environment, value: 'environment' as const } : null,+ showTools ? { label: labels.tools, value: 'tools' as const } : null,+ showSkills ? { label: labels.skills, value: 'skills' as const } : null,showMail ? { label: labels.mail, value: 'mail' as const } : null,showChannel ? { label: labels.channel, value: 'channel' as const } : null,showSelfLearning ? { label: labels['self-evolving'], value: 'self-evolving' as const } : null,@@ -83,6 +115,8 @@ export const buildAgentProfileTabOptions = ({const AGENT_PROFILE_TAB_GROUPS: { key: AgentProfileTabGroupKey; tabs: AgentProfileTab[] }[] = [{ key: 'profile', tabs: ['profile'] },+ { key: 'shape', tabs: ['instruction', 'knowledge'] },+ { key: 'setup', tabs: ['engine', 'environment', 'tools', 'skills'] },{ key: 'identity', tabs: ['mail', 'channel'] },{ key: 'general', tabs: ['self-evolving', 'statistics', 'share'] },];diff --git a/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts b/src/features/AgentProfileTabs/useAgentProfileTabOptions.tsindex b09434381fa..0e59dc916e3 100644--- a/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts+++ b/src/features/AgentProfileTabs/useAgentProfileTabOptions.ts@@ -6,6 +6,8 @@ import { useShowAgentIdentity } from '@/features/AgentMail/useShowAgentIdentity'import { useResourceAccess } from '@/features/ResourcePermission/useResourceAccess';import { useSelfLearningSurface } from '@/features/SelfLearning/SurfaceGate/useSelfLearningSurface';import { usePermission } from '@/hooks/usePermission';+import { useAgentStore } from '@/store/agent';+import { agentByIdSelectors } from '@/store/agent/selectors';import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';import { isMobileSurface } from '@/utils/mobileSurface';@@ -27,6 +29,7 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri!!isAgentEditable && isAccessResolved && canEditContent && canManageResource;const { visible: shareVisible } = useAgentShareSupported(agentId);const mailSupported = useShowAgentIdentity(agentId);+ const isHeterogeneous = useAgentStore(agentByIdSelectors.isAgentHeterogeneousById(agentId));const { enabled: enableSelfLearning } = useSelfLearningSurface();// The mobile Segmented has no room for another segment, so mobile keeps the// drawer entry in `AgentSidebar/Header/Nav`.@@ -39,6 +42,10 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stricanConfigure,labels: {'channel': t('tab.integration'),+ 'engine': t('tab.engine'),+ 'environment': t('tab.environment'),+ 'instruction': t('tab.instruction'),+ 'knowledge': t('tab.knowledge'),'mail': t('tab.mail'),// Inside the profile group the whole surface *is* the agent profile,// so the first entry is the "basic" tab, not "Agent Profile" again —@@ -46,12 +53,24 @@ export const useAgentProfileTabOptions = (active: AgentProfileTab, agentId: stri'profile': t('tab.profileBasic'),'self-evolving': t('title', { ns: 'selfLearning' }),'share': t('share', { ns: 'common' }),+ 'skills': t('tab.skills'),'statistics': t('usageStats.title', { ns: 'spend' }),+ 'tools': t('tab.tools'),},mailSupported,selfLearningSupported,shareSupported: shareVisible === true && canManageShare,+ heterogeneous: isHeterogeneous,}),- [active, canConfigure, canManageShare, mailSupported, selfLearningSupported, shareVisible, t],+ [+ active,+ canConfigure,+ canManageShare,+ isHeterogeneous,+ mailSupported,+ selfLearningSupported,+ shareVisible,+ t,+ ],);};diff --git a/src/features/AgentSidebar/ProfileNav.tsx b/src/features/AgentSidebar/ProfileNav.tsxindex b15abdb8776..fc434105ec7 100644--- a/src/features/AgentSidebar/ProfileNav.tsx+++ b/src/features/AgentSidebar/ProfileNav.tsx@@ -5,11 +5,17 @@ import type { LucideIcon } from 'lucide-react';import {ChartColumnBigIcon,ChevronLeftIcon,+ CpuIcon,DnaIcon,+ LibraryBigIcon,MailIcon,+ MonitorSmartphoneIcon,RadioTowerIcon,+ ScrollTextIcon,Share2Icon,+ SparklesIcon,UserRoundIcon,+ WrenchIcon,} from 'lucide-react';import { useTranslation } from 'react-i18next';import urlJoin from 'url-join';@@ -30,11 +36,17 @@ import Agent from './Header/Agent';const TAB_ICONS: Record<AgentProfileTab, LucideIcon> = {'channel': RadioTowerIcon,+ 'engine': CpuIcon,+ 'environment': MonitorSmartphoneIcon,+ 'instruction': ScrollTextIcon,+ 'knowledge': LibraryBigIcon,'mail': MailIcon,'profile': UserRoundIcon,'self-evolving': DnaIcon,'share': Share2Icon,+ 'skills': SparklesIcon,'statistics': ChartColumnBigIcon,+ 'tools': WrenchIcon,};interface ProfileNavProps {@@ -54,7 +66,7 @@ const ProfileNav = ({ active }: ProfileNavProps) => {<Flexbox gap={12} paddingInline={4}>{groupAgentProfileTabOptions(options).map((group) => (<Flexbox gap={1} key={group.key}>- {group.key === 'identity' && (+ {group.key !== 'general' && group.key !== 'profile' && (<TextellipsisfontSize={12}@@ -62,7 +74,7 @@ const ProfileNav = ({ active }: ProfileNavProps) => {type={'secondary'}weight={500}>- {t('tab.group.identity')}+ {t(`tab.group.${group.key}`)}</Text>)}{group.options.map(({ label, value }) => (diff --git a/src/features/ProfileEditor/AgentTool.tsx b/src/features/ProfileEditor/AgentTool.tsxindex 0a4a3203de7..93ec12ca859 100644--- a/src/features/ProfileEditor/AgentTool.tsx+++ b/src/features/ProfileEditor/AgentTool.tsx@@ -1,7 +1,7 @@'use client';import { getConnectorCatalog } from '@lobechat/const';-import { getActivePluginIds, upsertPluginMode } from '@lobechat/types';+import { getActivePluginIds, parsePluginEntry, upsertPluginMode } from '@lobechat/types';import type { ItemType } from '@lobehub/ui';import { Avatar, Button, cssVar, Flexbox, Icon } from '@lobehub/ui';import { McpIcon, SkillsIcon } from '@lobehub/ui/icons';@@ -40,10 +40,12 @@ import { agentSkillListResource } from '@/store/tool/slices/agentSkills/projectiimport type { LobeToolMetaWithAvailability } from '@/store/tool/slices/builtin/selectors';import { connectorSelectors } from '@/store/tool/slices/connector';+import { type ItemDetail } from './ItemDetailPanel';import PluginTag from './PluginTag';import PopoverContent from './PopoverContent';import { getVisibleProfileToolIds } from './profileToolVisibility';import { selectProfileToolCatalogsSynced, useStalePluginAutoResolve } from './staleProfilePlugins';+import ToolListGroup, { type ToolGroupMeta } from './ToolListGroup';export interface AgentToolProps {/**@@ -67,6 +69,17 @@ export interface AgentToolProps {* @default false*/filterAvailableInWeb?: boolean;+ /** The heading, description and action of the list; only the `list` variant shows them. */+ group?: ToolGroupMeta;+ /**+ * Which part of the library this list covers. Skills are agent skills (built-in, market and+ * your own); tools are everything else — built-in tools, connectors, plugins. `all` keeps the+ * single mixed list.+ * @default 'all'+ */+ kind?: 'all' | 'skills' | 'tools';+ /** Called with an item's details when its row is clicked; the page decides where to show them. */+ onOpenDetail?: (detail: ItemDetail) => void;/*** Show an "authorized by X" avatar on each connector chip. Set by the* two-section agent profile in a workspace so a teammate can see whose@@ -80,6 +93,12 @@ export interface AgentToolProps {* @default false*/useAllMetaList?: boolean;+ /**+ * `list` shows one row per tool with the add control below; `chip` keeps the compact+ * wrapping tags.+ * @default 'chip'+ */+ variant?: 'chip' | 'list';}const AgentTool = memo<AgentToolProps>(@@ -89,6 +108,10 @@ const AgentTool = memo<AgentToolProps>(useAllMetaList = false,excludeAgentConnectors = false,showAuthor = false,+ kind = 'all',+ group,+ onOpenDetail,+ variant = 'chip',}) => {const { t } = useTranslation('setting');const { allowed: canEdit } = usePermission('edit_own_content');@@ -218,7 +241,12 @@ const AgentTool = memo<AgentToolProps>(if (!effectiveAgentId) return;const hasPlugin = plugins.includes(pluginId);const shouldEnable = state !== undefined ? state : !hasPlugin;- if (shouldEnable === hasPlugin) return;+ // Taking an item out must also work on one that is switched off: it is not pinned, but+ // it still has an entry to remove.+ const hasEntry = (config?.plugins ?? []).some(+ (entry) => parsePluginEntry(entry).identifier === pluginId,+ );+ if (shouldEnable ? hasPlugin : !hasEntry) return;// upsertPluginMode operates on the raw (possibly mixed-shape) config// — not the pinned-only `plugins` above — so an existing disabled@@ -736,10 +764,12 @@ const AgentTool = memo<AgentToolProps>(icon={PlusIcon}loading={updating}size={'small'}- style={{ color: cssVar.colorTextSecondary }}+ style={variant === 'list' ? undefined : { color: cssVar.colorTextSecondary }}type={'text'}>- {t('tools.add', { defaultValue: 'Add' })}+ {kind === 'tools'+ ? t('settingAgent.agentTools.add')+ : t('tools.add', { defaultValue: 'Add' })}</Button>);@@ -813,76 +843,190 @@ const AgentTool = memo<AgentToolProps>(// managed entries remain untouched in config for compatibility with other// flows, but do not inflate this section's count or render misleading chips.const allEnabledTools = useMemo(() => {- return getVisibleProfileToolIds(plugins, {+ const visible = getVisibleProfileToolIds(plugins, {agentConnectorIdentifiers,nonConfigurableBuiltinToolIdentifiers: nonProfileConfigurableBuiltinToolIdentifiers,});- }, [plugins, agentConnectorIdentifiers, nonProfileConfigurableBuiltinToolIdentifiers]);+ if (kind === 'all') return visible;+ return visible.filter((id) => allSkillIdentifiers.has(id) === (kind === 'skills'));+ }, [+ plugins,+ agentConnectorIdentifiers,+ nonProfileConfigurableBuiltinToolIdentifiers,+ kind,+ allSkillIdentifiers,+ ]);++ // A list shows what is turned off as well, so it can be turned back on; the chips show only+ // what is on.+ const listedTools = useMemo(() => {+ const entries = (config?.plugins ?? [])+ .map((entry) => parsePluginEntry(entry))+ .filter((entry) => entry.mode !== 'auto');+ const visible = getVisibleProfileToolIds(+ entries.map((entry) => entry.identifier),+ {+ agentConnectorIdentifiers,+ nonConfigurableBuiltinToolIdentifiers: nonProfileConfigurableBuiltinToolIdentifiers,+ },+ );+ return kind === 'all'+ ? visible+ : visible.filter((id) => allSkillIdentifiers.has(id) === (kind === 'skills'));+ }, [+ config?.plugins,+ agentConnectorIdentifiers,+ nonProfileConfigurableBuiltinToolIdentifiers,+ kind,+ allSkillIdentifiers,+ ]);+ const disabledToolIds = useMemo(+ () =>+ new Set(+ (config?.plugins ?? [])+ .map((entry) => parsePluginEntry(entry))+ .filter((entry) => entry.mode === 'disabled')+ .map((entry) => entry.identifier),+ ),+ [config?.plugins],+ );+ const setPluginEnabled = (pluginId: string, enabled: boolean) => {+ if (!canEdit || !effectiveAgentId) return;+ return updateAgentConfigById(effectiveAgentId, {+ plugins: upsertPluginMode(config?.plugins, pluginId, enabled ? 'pinned' : 'disabled'),+ });+ };++ // Where a skill comes from, for the label on its row.+ const skillSource = useMemo(() => {+ const map = new Map<string, string>();+ for (const skill of installedBuiltinSkills)+ map.set(skill.identifier, t('settingAgent.skills.source.builtin'));+ for (const skill of marketAgentSkills)+ map.set(skill.identifier, t('settingAgent.skills.source.community'));+ for (const skill of userAgentSkills)+ map.set(skill.identifier, t('settingAgent.skills.source.custom'));+ return map;+ }, [installedBuiltinSkills, marketAgentSkills, userAgentSkills, t]);++ // The picker lists only what this page is about, so the Skills page never offers a tool.+ const pickerItems = useMemo(() => {+ if (kind === 'all') return allTabItems;+ return allTabItems.flatMap((item) => {+ if (!item || !('children' in item) || !item.children) return [item];+ const children = item.children.filter(+ (child) =>+ !!child &&+ 'key' in child &&+ allSkillIdentifiers.has(String(child.key)) === (kind === 'skills'),+ );+ return children.length > 0 ? [{ ...item, children }] : [];+ });+ }, [allTabItems, allSkillIdentifiers, kind]);++ const addControl = (+ <Suspense fallback={button}>+ {/* Plugin Selector Dropdown - Using Action component pattern */}+ <ActionDropdown+ maxWidth={400}+ minWidth={400}+ open={dropdownOpen}+ placement={'bottomLeft'}+ trigger={'click'}+ menu={{+ items: [],+ style: {+ // let only the custom scroller scroll+ maxHeight: 'unset',+ overflowY: 'visible',+ },+ }}+ popupProps={{+ style: {+ padding: 0,+ },+ }}+ popupRender={() => (+ <PopoverContent+ items={pickerItems}+ onClose={() => setDropdownOpen(false)}+ onOpenStore={() => {+ setDropdownOpen(false);+ createSkillStoreModal();+ }}+ />+ )}+ positionerProps={{+ collisionAvoidance: { align: 'flip', fallbackAxisSide: 'end', side: 'flip' },+ collisionBoundary:+ typeof document === 'undefined' ? undefined : document.documentElement,+ positionMethod: 'fixed',+ }}+ onOpenChange={(next) => {+ if (!canEdit) return;++ setDropdownOpen(next);+ }}+ >+ {button}+ </ActionDropdown>+ </Suspense>+ );++ if (variant === 'list' && group) {+ return (+ <ToolListGroup+ {...group}+ activeCount={listedTools.filter((id) => !disabledToolIds.has(id)).length}+ addControl={addControl}+ emptyText={t(+ kind === 'skills'+ ? 'settingAgent.tools.level.skillsEmpty'+ : 'settingAgent.tools.level.libraryEmpty',+ )}+ rows={listedTools.map((pluginId) => (+ <PluginTag+ disabled={!canEdit}+ enabled={!disabledToolIds.has(pluginId)}+ isSkill={kind === 'skills'}+ key={pluginId}+ pluginId={pluginId}+ showAuthor={showAuthor}+ showDesktopOnlyLabel={filterAvailableInWeb}+ tagLabel={kind === 'skills' ? skillSource.get(pluginId) : undefined}+ useAllMetaList={useAllMetaList}+ variant={'row'}+ onOpen={onOpenDetail}+ onRemove={handleRemovePlugin(pluginId)}+ onToggle={(next) => void setPluginEnabled(pluginId, next)}+ />+ ))}+ total={pickerItems.reduce(+ (sum, item) =>+ sum + (item && 'children' in item && item.children ? item.children.length : 0),+ 0,+ )}+ />+ );+ }return (<>{/* Plugin Selector and Tags */}- <Flexbox horizontal align="center" gap={8} wrap={'wrap'}>- <Suspense fallback={button}>- {/* Plugin Selector Dropdown - Using Action component pattern */}- <ActionDropdown- maxWidth={400}- minWidth={400}- open={dropdownOpen}- placement={'bottomLeft'}- trigger={'click'}- menu={{- items: [],- style: {- // let only the custom scroller scroll- maxHeight: 'unset',- overflowY: 'visible',- },- }}- popupProps={{- style: {- padding: 0,- },- }}- popupRender={() => (- <PopoverContent- items={allTabItems}- onClose={() => setDropdownOpen(false)}- onOpenStore={() => {- setDropdownOpen(false);- createSkillStoreModal();- }}- />- )}- positionerProps={{- collisionAvoidance: { align: 'flip', fallbackAxisSide: 'end', side: 'flip' },- collisionBoundary:- typeof document === 'undefined' ? undefined : document.documentElement,- positionMethod: 'fixed',- }}- onOpenChange={(next) => {- if (!canEdit) return;-- setDropdownOpen(next);- }}- >- {button}- </ActionDropdown>- </Suspense>+ <Flexbox horizontal align={'center'} gap={8} wrap={'wrap'}>+ {addControl}{/* Selected Plugins as Tags */}- {allEnabledTools.map((pluginId) => {- return (- <PluginTag- disabled={!canEdit}- key={pluginId}- pluginId={pluginId}- showAuthor={showAuthor}- showDesktopOnlyLabel={filterAvailableInWeb}- useAllMetaList={useAllMetaList}- onRemove={handleRemovePlugin(pluginId)}- />- );- })}+ {allEnabledTools.map((pluginId) => (+ <PluginTag+ disabled={!canEdit}+ key={pluginId}+ pluginId={pluginId}+ showAuthor={showAuthor}+ showDesktopOnlyLabel={filterAvailableInWeb}+ useAllMetaList={useAllMetaList}+ onRemove={handleRemovePlugin(pluginId)}+ />+ ))}</Flexbox></>);diff --git a/src/features/ProfileEditor/AgentUserTools/AgentToolsSection.tsx b/src/features/ProfileEditor/AgentUserTools/AgentToolsSection.tsxindex c4e21143cb3..b64e95adb32 100644--- a/src/features/ProfileEditor/AgentUserTools/AgentToolsSection.tsx+++ b/src/features/ProfileEditor/AgentUserTools/AgentToolsSection.tsx@@ -1,6 +1,6 @@'use client';-import { upsertPluginMode } from '@lobechat/types';+import { getPluginMode, upsertPluginMode } from '@lobechat/types';import { Button, confirmModal, DropdownMenu, Flexbox, Icon, Text } from '@lobehub/ui';import isEqual from 'fast-deep-equal';import { CopyIcon, PlugZapIcon, PlusIcon } from 'lucide-react';@@ -10,7 +10,9 @@ import { useTranslation } from 'react-i18next';import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';import { useIsWorkspaceOwner } from '@/business/client/hooks/useIsWorkspaceOwner';import { createAgentSkillStoreModal } from '@/features/AgentSkillStore';+import { type ItemDetail } from '@/features/ProfileEditor/ItemDetailPanel';import PluginTag from '@/features/ProfileEditor/PluginTag';+import ToolListGroup, { type ToolGroupMeta } from '@/features/ProfileEditor/ToolListGroup';import { usePermission } from '@/hooks/usePermission';import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';@@ -25,102 +27,136 @@ import { useUserStore } from '@/store/user';* an agent chip is a two-step op — unpin it from `agents.plugins` AND delete the* agent-owned `user_connectors` row (one more step than the user side).*/-const AgentToolsSection = memo<{ agentId: string; onStartCopy: () => void }>(- ({ agentId, onStartCopy }) => {- const { t } = useTranslation('setting');- const { allowed: canEdit } = usePermission('edit_own_content');+const AgentToolsSection = memo<{+ agentId: string;+ onStartCopy: () => void;+ /** The heading, description and action of the list; only the `list` variant shows them. */+ group?: ToolGroupMeta;+ /** Called with a connector's details when its row is clicked. */+ onOpenDetail?: (detail: ItemDetail) => void;+ /** `list` shows one row per tool as a settings group. */+ variant?: 'chip' | 'list';+}>(({ agentId, group, onOpenDetail, onStartCopy, variant = 'chip' }) => {+ const { t } = useTranslation('setting');+ const { allowed: canEdit } = usePermission('edit_own_content');- // Deleting an agent connector row is creator-or-owner only in a workspace- // (mirrors the server `assertWorkspaceRowManageable` gate). Used to hide the- // remove (×) on shared connectors the current member can't delete, so B- // never clicks into a FORBIDDEN error on A's connector.- const activeWorkspaceId = useActiveWorkspaceId();- const isWorkspaceOwner = useIsWorkspaceOwner();- const currentUserId = useUserStore((s) => s.user?.id);+ // Deleting an agent connector row is creator-or-owner only in a workspace+ // (mirrors the server `assertWorkspaceRowManageable` gate). Used to hide the+ // remove (×) on shared connectors the current member can't delete, so B+ // never clicks into a FORBIDDEN error on A's connector.+ const activeWorkspaceId = useActiveWorkspaceId();+ const isWorkspaceOwner = useIsWorkspaceOwner();+ const currentUserId = useUserStore((s) => s.user?.id);- const agentConnectors = useToolStore(connectorSelectors.agentConnectors(agentId), isEqual);- const detachConnectorFromAgent = useToolStore((s) => s.detachConnectorFromAgent);- const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);+ const agentConnectors = useToolStore(connectorSelectors.agentConnectors(agentId), isEqual);+ const detachConnectorFromAgent = useToolStore((s) => s.detachConnectorFromAgent);+ const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);- const handleRemove = async (connector: ConnectorWithTools) => {- const ok = await confirmModal({ content: t('settingAgent.agentTools.removeOwnedConfirm') });- if (!ok) return;- // 1) remove from agents.plugins, 2) delete the agent connector row.- const config = agentSelectors.getAgentConfigById(agentId)(useAgentStore.getState());- await updateAgentConfigById(agentId, {- plugins: upsertPluginMode(config?.plugins, connector.identifier, 'auto'),- });- await detachConnectorFromAgent(connector.id, agentId, 'delete');- };+ const handleRemove = async (connector: ConnectorWithTools) => {+ const ok = await confirmModal({ content: t('settingAgent.agentTools.removeOwnedConfirm') });+ if (!ok) return;+ // 1) remove from agents.plugins, 2) delete the agent connector row.+ const config = agentSelectors.getAgentConfigById(agentId)(useAgentStore.getState());+ await updateAgentConfigById(agentId, {+ plugins: upsertPluginMode(config?.plugins, connector.identifier, 'auto'),+ });+ await detachConnectorFromAgent(connector.id, agentId, 'delete');+ };- const addMenuItems = [- {- desc: t('settingAgent.agentTools.connectNew.desc'),- icon: PlugZapIcon,- key: 'connectNew',- label: t('settingAgent.agentTools.connectNew.title'),- onClick: () => createAgentSkillStoreModal(agentId),- },- {- desc: t('settingAgent.agentTools.copy.desc'),- icon: CopyIcon,- key: 'copy',- label: t('settingAgent.agentTools.copy.title'),- onClick: onStartCopy,- },- ];+ const addMenuItems = [+ {+ desc: t('settingAgent.agentTools.connectNew.desc'),+ icon: PlugZapIcon,+ key: 'connectNew',+ label: t('settingAgent.agentTools.connectNew.title'),+ onClick: () => createAgentSkillStoreModal(agentId),+ },+ {+ desc: t('settingAgent.agentTools.copy.desc'),+ icon: CopyIcon,+ key: 'copy',+ label: t('settingAgent.agentTools.copy.title'),+ onClick: onStartCopy,+ },+ ];+ const isList = variant === 'list';++ const addButton = (+ <DropdownMenu items={addMenuItems} placement={'bottomLeft'}>+ <Button disabled={!canEdit} icon={<Icon icon={PlusIcon} />} size={'small'} type={'text'}>+ {t('settingAgent.agentTools.add')}+ </Button>+ </DropdownMenu>+ );++ const agentPlugins = useAgentStore((s) => agentSelectors.getAgentConfigById(agentId)(s)?.plugins);+ const setEnabled = (identifier: string, enabled: boolean) =>+ updateAgentConfigById(agentId, {+ plugins: upsertPluginMode(agentPlugins, identifier, enabled ? 'pinned' : 'disabled'),+ });++ const tags = agentConnectors.map((connector) => {+ // Outside a workspace (personal), or when the row has no known+ // creator, fall back to the existing edit-permission gate. In a+ // workspace, only the creator or a workspace owner may delete.+ const canManageRow =+ !activeWorkspaceId ||+ !connector.userId ||+ connector.userId === currentUserId ||+ isWorkspaceOwner;return (- <Flexbox gap={8}>- <Text style={{ fontSize: 12, fontWeight: 500 }} type={'secondary'}>- {t('settingAgent.agentTools.tabAgent')} · {agentConnectors.length}- </Text>- <Flexbox horizontal align={'center'} gap={8} wrap={'wrap'}>- <DropdownMenu items={addMenuItems} placement={'bottomLeft'}>- <Button- disabled={!canEdit}- icon={<Icon icon={PlusIcon} />}- size={'small'}- type={'text'}- >- {t('settingAgent.agentTools.add')}- </Button>- </DropdownMenu>+ <PluginTag+ agentId={agentId}+ disabled={!canEdit}+ enabled={getPluginMode(agentPlugins, connector.identifier) !== 'disabled'}+ key={connector.id}+ pluginId={connector.identifier}+ removable={canManageRow}+ showAuthor={!!activeWorkspaceId}+ variant={isList ? 'row' : 'chip'}+ onOpen={isList ? onOpenDetail : undefined}+ onToggle={isList ? (next) => void setEnabled(connector.identifier, next) : undefined}+ onRemove={() => {+ handleRemove(connector);+ }}+ />+ );+ });- {agentConnectors.length === 0 && (- <Text style={{ fontSize: 12 }} type={'secondary'}>- {t('settingAgent.agentTools.agentEmpty')}- </Text>- )}+ if (isList && group) {+ return (+ <ToolListGroup+ {...group}+ addControl={addButton}+ emptyText={t('settingAgent.agentTools.agentEmpty')}+ rows={tags}+ activeCount={+ agentConnectors.filter(+ (connector) => getPluginMode(agentPlugins, connector.identifier) !== 'disabled',+ ).length+ }+ />+ );+ }- {agentConnectors.map((connector) => {- // Outside a workspace (personal), or when the row has no known- // creator, fall back to the existing edit-permission gate. In a- // workspace, only the creator or a workspace owner may delete.- const canManageRow =- !activeWorkspaceId ||- !connector.userId ||- connector.userId === currentUserId ||- isWorkspaceOwner;- return (- <PluginTag- agentId={agentId}- disabled={!canEdit}- key={connector.id}- pluginId={connector.identifier}- removable={canManageRow}- showAuthor={!!activeWorkspaceId}- onRemove={() => {- handleRemove(connector);- }}- />- );- })}- </Flexbox>+ return (+ <Flexbox gap={8}>+ <Text style={{ fontSize: 12, fontWeight: 500 }} type={'secondary'}>+ {t('settingAgent.agentTools.tabAgent')} · {agentConnectors.length}+ </Text>+ <Flexbox horizontal align={'center'} gap={8} wrap={'wrap'}>+ {addButton}+ {agentConnectors.length === 0 && (+ <Text style={{ fontSize: 12 }} type={'secondary'}>+ {t('settingAgent.agentTools.agentEmpty')}+ </Text>+ )}+ {tags}</Flexbox>- );- },-);+ </Flexbox>+ );+});AgentToolsSection.displayName = 'AgentToolsSection';diff --git a/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsx b/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsxindex 39978086a14..4e8e4b7d49b 100644--- a/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsx+++ b/src/features/ProfileEditor/AgentUserTools/UserToolsSection.tsx@@ -25,6 +25,8 @@ interface Props extends AgentToolProps {onConfirmCopy: () => void;selected: Set<string>;toggleSelected: (id: string) => void;+ /** `list` shows one row per tool under a heading supplied by the caller. */+ variant?: 'chip' | 'list';}/**@@ -41,6 +43,7 @@ const UserToolsSection = memo<Props>(onConfirmCopy,selected,toggleSelected,+ variant = 'chip',...toolProps}) => {const { t } = useTranslation('setting');@@ -126,14 +129,17 @@ const UserToolsSection = memo<Props>(return (<Flexbox gap={8}>- <Text style={{ fontSize: 12, fontWeight: 500 }} type={'secondary'}>- {baseToolsLabel} · {userToolCount}- </Text>+ {variant === 'chip' && (+ <Text style={{ fontSize: 12, fontWeight: 500 }} type={'secondary'}>+ {baseToolsLabel} · {userToolCount}+ </Text>+ )}<SharedAgentTool{...toolProps}excludeAgentConnectorsagentId={agentId}showAuthor={!!activeWorkspaceId}+ variant={variant}/></Flexbox>);diff --git a/src/features/ProfileEditor/AgentUserTools/index.tsx b/src/features/ProfileEditor/AgentUserTools/index.tsxindex 23801806bc0..e7a05d062fd 100644--- a/src/features/ProfileEditor/AgentUserTools/index.tsx+++ b/src/features/ProfileEditor/AgentUserTools/index.tsx@@ -1,17 +1,22 @@'use client';import { upsertPluginMode } from '@lobechat/types';-import { Flexbox } from '@lobehub/ui';+import { Button, Flexbox } from '@lobehub/ui';import isEqual from 'fast-deep-equal';import { memo, useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';+import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';import { type AgentToolProps } from '@/features/ProfileEditor/AgentTool';+import { type ToolGroupMeta } from '@/features/ProfileEditor/ToolListGroup';+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';import { useToolStore } from '@/store/tool';import { connectorSelectors } from '@/store/tool/slices/connector';import AgentToolsSection from './AgentToolsSection';+import RunPriorityHint from './RunPriorityHint';import UserToolsSection from './UserToolsSection';/**@@ -20,8 +25,11 @@ import UserToolsSection from './UserToolsSection';* (bottom, the user's pinned tools). Agent tools resolve with priority over* same-named user tools at runtime.*/-const AgentUserTools = memo<AgentToolProps>((props) => {- const { agentId } = props;+const AgentUserTools = memo<AgentToolProps & { variant?: 'chip' | 'list' }>((props) => {+ const { agentId, variant = 'chip', ...toolProps } = props;+ const { t } = useTranslation('setting');+ const navigate = useWorkspaceAwareNavigate();+ const activeWorkspaceId = useActiveWorkspaceId();const activeAgentId = useAgentStore((s) => s.activeAgentId);const effectiveAgentId = agentId || activeAgentId || '';@@ -78,17 +86,82 @@ const AgentUserTools = memo<AgentToolProps>((props) => {}};+ if (variant === 'list') {+ // Two levels, named for what they mean to the person: what belongs to this agent alone,+ // and what it borrows from the library every agent shares. Skills only ever come from the+ // library, so their page has the one list.+ const isSkills = toolProps.kind === 'skills';+ const agentGroup: ToolGroupMeta = {+ desc: t('settingAgent.tools.level.agentDesc'),+ extra: <RunPriorityHint agentId={effectiveAgentId} />,+ title: t('settingAgent.agentTools.tabAgent'),+ };+ const libraryGroup: ToolGroupMeta = {+ plain: isSkills,+ desc: isSkills+ ? t('settingAgent.skillsPage.group.desc')+ : t(+ activeWorkspaceId+ ? 'settingAgent.tools.level.workspaceDesc'+ : 'settingAgent.tools.level.libraryDesc',+ ),+ extra: (+ <Button size={'small'} type={'text'} onClick={() => navigate('/settings/skill')}>+ {t('settingAgent.tools.manageLibrary')}+ </Button>+ ),+ title: isSkills+ ? t('settingAgent.skillsPage.group.title')+ : t(+ activeWorkspaceId+ ? 'settingAgent.agentTools.tabWorkspace'+ : 'settingAgent.agentTools.tabUser',+ ),+ };++ return (+ <Flexbox gap={16} width={'100%'}>+ {!isSkills && (+ <AgentToolsSection+ agentId={effectiveAgentId}+ group={agentGroup}+ variant={'list'}+ onOpenDetail={toolProps.onOpenDetail}+ onStartCopy={() => setCopyMode(true)}+ />+ )}+ <UserToolsSection+ {...toolProps}+ agentId={effectiveAgentId}+ copyMode={copyMode}+ copying={copying}+ group={libraryGroup}+ selected={selected}+ toggleSelected={toggleSelected}+ variant={'list'}+ onCancelCopy={resetCopy}+ onConfirmCopy={handleConfirmCopy}+ />+ </Flexbox>+ );+ }+return (<Flexbox gap={16} width={'100%'}>- <AgentToolsSection agentId={effectiveAgentId} onStartCopy={() => setCopyMode(true)} />+ <AgentToolsSection+ agentId={effectiveAgentId}+ variant={variant}+ onStartCopy={() => setCopyMode(true)}+ /><UserToolsSection- {...props}+ {...toolProps}agentId={effectiveAgentId}copyMode={copyMode}copying={copying}selected={selected}toggleSelected={toggleSelected}+ variant={variant}onCancelCopy={resetCopy}onConfirmCopy={handleConfirmCopy}/>diff --git a/src/features/ProfileEditor/ItemDetailPanel.tsx b/src/features/ProfileEditor/ItemDetailPanel.tsxnew file mode 100644index 00000000000..e2ed3d10987--- /dev/null+++ b/src/features/ProfileEditor/ItemDetailPanel.tsx@@ -0,0 +1,110 @@+'use client';++import { ActionIcon, cssVar, DraggablePanel, Flexbox, Tag, Text } from '@lobehub/ui';+import { XIcon } from 'lucide-react';+import { memo, type ReactNode } from 'react';+import { useTranslation } from 'react-i18next';++import { useItemDetailStore } from './itemDetailStore';++/** What the side panel shows about one tool, connector or skill. */+export interface ItemDetail {+ description?: string;+ icon: ReactNode;+ identifier: string;+ /** Where it comes from or what kind it is, as a short label. */+ tag: string;+ title: string;+ /** The tools it brings; empty for a skill, which is a set of steps rather than tools. */+ tools: { description?: string | null; name: string }[];+}++/**+ * The right-hand panel of the profile pages: opens when a tool, connector or skill row is+ * clicked, docked at the page edge, and says what the item is, where it comes from, and which+ * tools it gives the agent. The list stays visible beside it.+ */+const ItemDetailDock = memo(() => {+ const { t } = useTranslation('setting');+ const detail = useItemDetailStore((s) => s.detail);+ const close = useItemDetailStore((s) => s.close);++ return (+ <DraggablePanel+ showHandleWideArea+ backgroundColor={cssVar.colorBgContainer}+ defaultSize={{ width: 380 }}+ expand={!!detail}+ expandable={false}+ maxWidth={560}+ minWidth={320}+ placement={'right'}+ size={{ height: '100%' }}+ style={{ borderInlineStart: `1px solid ${cssVar.colorBorderSecondary}` }}+ >+ {detail ? (+ <Flexbox gap={20} height={'100%'} padding={24} style={{ overflowY: 'auto' }}>+ <Flexbox horizontal align={'center'} gap={12}>+ <Flexbox+ align={'center'}+ flex={'none'}+ justify={'center'}+ style={{+ background: cssVar.colorFillTertiary,+ borderRadius: 10,+ height: 40,+ width: 40,+ }}+ >+ {detail.icon}+ </Flexbox>+ <Flexbox flex={1} gap={4} style={{ minWidth: 0 }}>+ <Text ellipsis style={{ fontSize: 16, fontWeight: 600 }}>+ {detail.title}+ </Text>+ <Flexbox horizontal>+ <Tag>{detail.tag}</Tag>+ </Flexbox>+ </Flexbox>+ <ActionIcon+ icon={XIcon}+ size={'small'}+ title={t('settingAgent.tools.close')}+ onClick={close}+ />+ </Flexbox>++ {detail.description ? <Text type={'secondary'}>{detail.description}</Text> : null}++ {detail.tools.length > 0 ? (+ <Flexbox gap={10}>+ <Text style={{ fontWeight: 500 }}>+ {t('settingAgent.tools.detail.tools', { count: detail.tools.length })}+ </Text>+ {detail.tools.map((tool) => (+ <Flexbox gap={2} key={tool.name}>+ <Text code ellipsis fontSize={12}>+ {tool.name}+ </Text>+ {tool.description ? (+ <Text ellipsis={{ rows: 2 }} fontSize={12} type={'secondary'}>+ {tool.description}+ </Text>+ ) : null}+ </Flexbox>+ ))}+ </Flexbox>+ ) : null}++ <Text code fontSize={12} type={'secondary'}>+ {detail.identifier}+ </Text>+ </Flexbox>+ ) : null}+ </DraggablePanel>+ );+});++ItemDetailDock.displayName = 'ItemDetailDock';++export default ItemDetailDock;diff --git a/src/features/ProfileEditor/ItemRow.tsx b/src/features/ProfileEditor/ItemRow.tsxnew file mode 100644index 00000000000..fbbc34fa487--- /dev/null+++ b/src/features/ProfileEditor/ItemRow.tsx@@ -0,0 +1,93 @@+'use client';++import { cssVar, Flexbox, Tag, Text } from '@lobehub/ui';+import { memo, type ReactNode } from 'react';++import { shouldActivateRow } from './rowKeys';++interface ItemRowProps {+ /** Controls at the end of the row: remove, switch, … */+ actions?: ReactNode;+ /** Shows the name as a problem, e.g. a tool that is no longer installed. */+ danger?: boolean;+ description?: string;+ /** The icon, shown on a small tile so every row lines up whatever the icon looks like. */+ icon: ReactNode;+ /** Something small between the name and the actions, such as who authorized it. */+ meta?: ReactNode;+ /** Opens the item's details when the row is clicked. */+ onClick?: () => void;+ /** What kind of thing this is, as a quiet label at the end. */+ tag?: string;+ title: string;+}++/**+ * One tool, skill, knowledge base or file as a row: an icon tile, the name with a line about+ * it, its kind, and the actions. The same row everywhere a list of these appears.+ */+const ItemRow = memo<ItemRowProps>(+ ({ actions, danger, description, icon, meta, onClick, tag, title }) => (+ <Flexbox+ horizontal+ align={'center'}+ gap={12}+ role={onClick ? 'button' : undefined}+ style={onClick ? { cursor: 'pointer' } : undefined}+ tabIndex={onClick ? 0 : undefined}+ onClick={onClick}+ onKeyDown={+ onClick+ ? (event) => {+ if (!shouldActivateRow(event)) return;+ event.preventDefault();+ onClick();+ }+ : undefined+ }+ >+ <Flexbox+ align={'center'}+ flex={'none'}+ justify={'center'}+ style={{+ background: cssVar.colorFillTertiary,+ borderRadius: 8,+ height: 32,+ width: 32,+ }}+ >+ {icon}+ </Flexbox>+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>+ <Text ellipsis style={{ fontWeight: 500 }} type={danger ? 'danger' : undefined}>+ {title}+ </Text>+ {description ? (+ <Text ellipsis fontSize={12} type={'secondary'}>+ {description}+ </Text>+ ) : null}+ </Flexbox>+ {meta}+ {tag ? <Tag style={{ flex: 'none', margin: 0 }}>{tag}</Tag> : null}+ {/* Controls act on the item; they must not also open its details. */}+ {actions ? (+ <Flexbox+ horizontal+ align={'center'}+ gap={8}+ onClick={(event) => {+ event.stopPropagation();+ }}+ >+ {actions}+ </Flexbox>+ ) : null}+ </Flexbox>+ ),+);++ItemRow.displayName = 'ItemRow';++export default ItemRow;diff --git a/src/features/ProfileEditor/PluginTag.test.tsx b/src/features/ProfileEditor/PluginTag.test.tsxindex 8cdfd6659cb..3b737bdce9b 100644--- a/src/features/ProfileEditor/PluginTag.test.tsx+++ b/src/features/ProfileEditor/PluginTag.test.tsx@@ -1,7 +1,7 @@/*** @vitest-environment happy-dom*/-import { render, screen } from '@testing-library/react';+import { fireEvent, render, screen } from '@testing-library/react';import type { ReactNode } from 'react';import { beforeEach, describe, expect, it, vi } from 'vitest';@@ -67,7 +67,7 @@ vi.mock('@/components/Plugins/PluginAvatar', () => ({ default: () => null }));// Run selectors against controlled state (the mocked selectors ignore state).vi.mock('@/store/tool', () => ({- useToolStore: (sel: (s: unknown) => unknown) => sel({}),+ useToolStore: (sel: (s: unknown) => unknown) => sel({ builtinTools: [] }),}));vi.mock('@/store/tool/slices/connector/selectors', () => ({connectorSelectors: {@@ -137,3 +137,88 @@ describe('PluginTag author attribution', () => {expect(screen.queryByTestId('author-avatar')).toBeNull();});});++describe('PluginTag row variant', () => {+ beforeEach(() => {+ mocks.agentConnectors = [];+ mocks.connectorList = [];+ });++ it('names the kind of tool and shows whose credentials it runs under', () => {+ mocks.agentConnectors = [+ { authorizedByAvatar: null, authorizedByName: '张三', identifier: 'gmail' },+ ];+ render(<PluginTag showAuthor agentId="agt-1" pluginId="gmail" variant="row" />);++ expect(screen.getByText('settingAgent.tools.type.custom-connector')).toBeTruthy();+ expect(screen.getByTestId('author-avatar')).toHaveTextContent('张三');+ });++ it('names the kind as a skill when the row sits in the skills list', () => {+ mocks.agentConnectors = [+ { authorizedByAvatar: null, authorizedByName: '张三', identifier: 'gmail' },+ ];+ render(<PluginTag isSkill pluginId="gmail" variant="row" />);++ expect(screen.getByText('settingAgent.tools.type.skill')).toBeTruthy();+ expect(screen.queryByText('settingAgent.tools.type.custom-connector')).toBeNull();+ });++ it('shows how many tools an item brings, and opens its details on click', () => {+ mocks.agentConnectors = [+ {+ authorizedByAvatar: null,+ authorizedByName: null,+ identifier: 'gmail',+ name: 'Gmail',+ tools: [+ { description: 'Send a mail', displayName: null, toolName: 'send' },+ { description: null, displayName: 'Read', toolName: 'read' },+ ],+ },+ ];+ const onOpen = vi.fn();+ render(<PluginTag agentId="agt-1" pluginId="gmail" variant="row" onOpen={onOpen} />);++ expect(screen.getByText('settingAgent.tools.toolCount')).toBeTruthy();+ fireEvent.click(screen.getByText('Gmail'));+ expect(onOpen).toHaveBeenCalledWith(+ expect.objectContaining({+ identifier: 'gmail',+ tools: [+ { description: 'Send a mail', name: 'send' },+ { description: null, name: 'Read' },+ ],+ }),+ );+ });++ it('switches an item on and off without opening its details', () => {+ const onToggle = vi.fn();+ const onOpen = vi.fn();+ render(+ <PluginTag enabled pluginId="gmail" variant="row" onOpen={onOpen} onToggle={onToggle} />,+ );++ fireEvent.click(screen.getByRole('switch'));+ expect(onToggle).toHaveBeenCalledWith(false);+ expect(onOpen).not.toHaveBeenCalled();+ });++ it('labels a row with the given source instead of the stored kind', () => {+ render(<PluginTag isSkill pluginId="gmail" tagLabel="Community" variant="row" />);++ expect(screen.getByText('Community')).toBeTruthy();+ });++ it('offers removal only when the row is removable and editable', () => {+ const { rerender } = render(<PluginTag pluginId="gmail" variant="row" />);+ expect(screen.queryByLabelText('settingAgent.tools.remove')).toBeTruthy();++ rerender(<PluginTag disabled pluginId="gmail" variant="row" />);+ expect(screen.queryByLabelText('settingAgent.tools.remove')).toBeNull();++ rerender(<PluginTag pluginId="gmail" removable={false} variant="row" />);+ expect(screen.queryByLabelText('settingAgent.tools.remove')).toBeNull();+ });+});diff --git a/src/features/ProfileEditor/PluginTag.tsx b/src/features/ProfileEditor/PluginTag.tsxindex aca879802a7..f254f29b18f 100644--- a/src/features/ProfileEditor/PluginTag.tsx+++ b/src/features/ProfileEditor/PluginTag.tsx@@ -2,7 +2,18 @@import type { ComposioAppType, LobehubSkillProviderType } from '@lobechat/const';import { resolveConnectorCatalogItem } from '@lobechat/const';-import { Avatar, createStaticStyles, cssVar, Flexbox, Icon, Tag, Tooltip } from '@lobehub/ui';+import {+ ActionIcon,+ Avatar,+ createStaticStyles,+ cssVar,+ Flexbox,+ Icon,+ Switch,+ Tag,+ Text,+ Tooltip,+} from '@lobehub/ui';import { McpIcon } from '@lobehub/ui/icons';import isEqual from 'fast-deep-equal';import { AlertCircle, Loader2, Square, SquareCheckBig, SquareMinus, X } from 'lucide-react';@@ -24,6 +35,9 @@ import {import { type LobeToolMetaWithAvailability } from '@/store/tool/slices/builtin/selectors';import { connectorSelectors } from '@/store/tool/slices/connector/selectors';+import { type ItemDetail } from './ItemDetailPanel';+import ItemRow from './ItemRow';+/*** Composio server icon component*/@@ -91,6 +105,10 @@ export interface PluginTagProps {*/agentId?: string;disabled?: boolean;+ /** In a row, an on/off switch for the item; `onToggle` makes it appear. */+ enabled?: boolean;+ /** Trailing controls of a `row` (e.g. a link to manage the tool); ignored by the chip. */+ extra?: React.ReactNode;/*** Renders the `selectable` checkbox in the "some but not all" state (a minus* box instead of a tick), the antd `indeterminate` / Gmail select-all@@ -99,9 +117,14 @@ export interface PluginTagProps {* tool granted for some of its APIs but not all.*/indeterminate?: boolean;+ /** In a row, name the kind as a skill rather than by how the item is stored. */+ isSkill?: boolean;+ /** In a row, opens the item's details. */+ onOpen?: (detail: ItemDetail) => void;onRemove?: (e: React.MouseEvent) => void;/** Fires when the checkbox/tag is toggled in `selectable` mode. */onSelect?: () => void;+ onToggle?: (next: boolean) => void;pluginId: string | { enabled: boolean; identifier: string; settings: Record<string, any> };/*** Whether the remove (×) button is shown. Default true. Set false to keep the@@ -131,11 +154,19 @@ export interface PluginTagProps {* @default false*/showDesktopOnlyLabel?: boolean;+ /** In a row, replaces the kind label, e.g. where a skill comes from. */+ tagLabel?: string;/*** Whether to use allMetaList (includes hidden tools) or metaList* @default false*/useAllMetaList?: boolean;+ /**+ * `chip` is the compact tag used inside menus and inline lists; `row` is one line of a+ * list — icon, name, what kind of tool it is, and the remove action.+ * @default 'chip'+ */+ variant?: 'chip' | 'row';}const PluginTag = memo<PluginTagProps>(@@ -152,6 +183,13 @@ const PluginTag = memo<PluginTagProps>(showAuthor = false,showDesktopOnlyLabel = false,useAllMetaList = false,+ variant = 'chip',+ extra,+ isSkill = false,+ enabled = true,+ onToggle,+ onOpen,+ tagLabel,}) => {const isDarkMode = useIsDark();const { t } = useTranslation('setting');@@ -267,6 +305,7 @@ const PluginTag = memo<PluginTagProps>(return {availableInWeb,avatar: builtinMeta.meta.avatar,+ description: builtinMeta.meta.description,isInstalled: true,title: builtinMeta.meta.title,type: 'builtin' as const,@@ -278,6 +317,7 @@ const PluginTag = memo<PluginTagProps>(return {availableInWeb: true,avatar: installedMeta.avatar,+ description: installedMeta.description,isInstalled: true,title: installedMeta.title,type: 'plugin' as const,@@ -289,6 +329,10 @@ const PluginTag = memo<PluginTagProps>(if (agentConn) {return {availableInWeb: true,+ description:+ typeof agentConn.metadata?.description === 'string'+ ? agentConn.metadata.description+ : undefined,icon: McpIcon,isInstalled: true,label: agentConn.name || identifier,@@ -390,6 +434,97 @@ const PluginTag = memo<PluginTagProps>(// Only show error state when not installed and not loadingconst showErrorState = !meta.isInstalled && !isLoading;+ // The tools an item brings, for its count and its details.+ const builtinApi = useToolStore(+ (s) => s.builtinTools.find((tool) => tool.identifier === identifier)?.manifest.api,+ isEqual,+ );+ const connectorTools = (+ agentConnectors.find((c) => c.identifier === identifier) ??+ customConnectors.find((c) => c.identifier === identifier)+ )?.tools;+ const toolList: ItemDetail['tools'] = connectorTools?.length+ ? connectorTools.map((tool) => ({+ description: tool.description,+ name: tool.displayName || tool.toolName,+ }))+ : (builtinApi ?? []).map((api) => ({ description: api.description, name: api.name }));++ if (variant === 'row') {+ const description =+ 'description' in meta && typeof meta.description === 'string'+ ? meta.description+ : undefined;++ const kindLabel = tagLabel ?? t(`settingAgent.tools.type.${isSkill ? 'skill' : meta.type}`);+ const title = getDisplayText() ?? identifier;++ return (+ <ItemRow+ danger={showErrorState}+ description={description}+ icon={renderIcon()}+ tag={kindLabel}+ title={title}+ actions={+ <>+ {extra}+ {onToggle ? (+ <Switch+ checked={enabled}+ disabled={disabled}+ size={'small'}+ title={t(enabled ? 'settingAgent.tools.disable' : 'settingAgent.tools.enable')}+ onChange={(next) => onToggle(next)}+ />+ ) : null}+ {removable && !disabled ? (+ <ActionIcon+ aria-label={t('settingAgent.tools.remove')}+ icon={X}+ size={'small'}+ title={t('settingAgent.tools.remove')}+ onClick={(e) => onRemove?.(e)}+ />+ ) : null}+ </>+ }+ meta={+ <>+ {toolList.length > 0 ? (+ <Text fontSize={12} style={{ flex: 'none' }} type={'secondary'}>+ {t('settingAgent.tools.toolCount', { count: toolList.length })}+ </Text>+ ) : null}+ {author ? (+ <Tooltip title={t('settingAgent.agentTools.authorizedBy', { name: author.name })}>+ <Avatar+ avatar={author.avatar}+ size={20}+ style={{ flexShrink: 0 }}+ title={author.name}+ />+ </Tooltip>+ ) : null}+ </>+ }+ onClick={+ onOpen+ ? () =>+ onOpen({+ description,+ icon: renderIcon(),+ identifier,+ tag: kindLabel,+ title,+ tools: toolList,+ })+ : undefined+ }+ />+ );+ }+return (<TagclassName={styles.tag}diff --git a/src/features/ProfileEditor/ToolListGroup.test.tsx b/src/features/ProfileEditor/ToolListGroup.test.tsxnew file mode 100644index 00000000000..46c376f8dfb--- /dev/null+++ b/src/features/ProfileEditor/ToolListGroup.test.tsx@@ -0,0 +1,46 @@+import { fireEvent, render, screen } from '@testing-library/react';+import { describe, expect, it } from 'vitest';++import ToolListGroup, { TOOL_ROWS_VISIBLE } from './ToolListGroup';++const rows = (n: number) => Array.from({ length: n }, (_, i) => <div key={i}>row-{i}</div>);++const renderGroup = (count: number) =>+ render(+ <ToolListGroup+ addControl={<button type="button">add</button>}+ emptyText="nothing yet"+ rows={rows(count)}+ title="Group"+ />,+ );++describe('ToolListGroup', () => {+ it('says so when the list is empty and still offers to add one', () => {+ renderGroup(0);++ expect(screen.getByText('nothing yet')).toBeTruthy();+ expect(screen.getByText('add')).toBeTruthy();+ });++ it('shows every row and the add control as the last row when the list is short', () => {+ renderGroup(3);++ expect(screen.getAllByText(/^row-/)).toHaveLength(3);+ expect(screen.getByText('add')).toBeTruthy();+ expect(screen.queryByText('settingAgent.tools.showAll')).toBeNull();+ });++ it('folds a long list after a few rows and opens the rest on request', () => {+ const total = TOOL_ROWS_VISIBLE + 5;+ renderGroup(total);++ expect(screen.getAllByText(/^row-/)).toHaveLength(TOOL_ROWS_VISIBLE);++ fireEvent.click(screen.getByText('settingAgent.tools.showAll'));+ expect(screen.getAllByText(/^row-/)).toHaveLength(total);++ fireEvent.click(screen.getByText('settingAgent.tools.showLess'));+ expect(screen.getAllByText(/^row-/)).toHaveLength(TOOL_ROWS_VISIBLE);+ });+});diff --git a/src/features/ProfileEditor/ToolListGroup.tsx b/src/features/ProfileEditor/ToolListGroup.tsxnew file mode 100644index 00000000000..56162814aab--- /dev/null+++ b/src/features/ProfileEditor/ToolListGroup.tsx@@ -0,0 +1,156 @@+'use client';++import { Button, cssVar, Flexbox, Text } from '@lobehub/ui';+import { Form, useForm } from '@lobehub/ui/form';+import { cssVar as sxVar } from '@lobehub/ui/stylex/cssVar.stylex';+import * as stylex from '@stylexjs/stylex';+import { memo, type ReactElement, type ReactNode, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { FORM_STYLE } from '@/const/layoutTokens';++const styles = stylex.create({+ divided: {+ borderBlockStartColor: sxVar.colorFillSecondary,+ borderBlockStartStyle: 'solid',+ borderBlockStartWidth: 1,+ },+ row: {+ backgroundColor: { 'default': 'transparent', ':hover': sxVar.colorFillQuaternary },+ transition: `background 150ms ${sxVar.motionEaseOut}`,+ },+});++/** How many rows show before the rest fold away. */+export const TOOL_ROWS_VISIBLE = 6;++/** What the caller says about a list: its heading, what it means, and any action beside it. */+export interface ToolGroupMeta {+ desc?: string;+ extra?: ReactNode;+ /** A bare list on the page — heading, rows, add — instead of a card of the settings form. */+ plain?: boolean;+ title: string;+}++interface ToolListGroupProps extends ToolGroupMeta {+ /** How many of the rows are switched on; every row when omitted. */+ activeCount?: number;+ /** The control that adds one more; it closes the list as a row of its own. */+ addControl: ReactNode;+ emptyText: string;+ /** One element per tool or skill, each with its own key. */+ rows: ReactElement[];+ /** How many exist to choose from; shows as "N of M turned on" instead of a bare count. */+ total?: number;+}++const Row = memo<{ children: ReactNode; divided: boolean }>(({ children, divided }) => (+ <Flexbox+ horizontal+ align={'center'}+ paddingBlock={12}+ paddingInline={16}+ {...stylex.props(styles.row, divided && styles.divided)}+ >+ <Flexbox flex={1} style={{ minWidth: 0 }}>+ {children}+ </Flexbox>+ </Flexbox>+));++Row.displayName = 'ToolListRow';++/**+ * One list of tools or skills as a settings group: how many there are beside the heading, one+ * row per item, and "add" as the last row. A long list folds after a few rows so the page stays+ * scannable, and one row opens the rest.+ */+const ToolListGroup = memo<ToolListGroupProps>(+ ({ activeCount, addControl, desc, emptyText, extra, plain, rows, title, total }) => {+ const { t } = useTranslation('setting');+ const form = useForm();+ const [expanded, setExpanded] = useState(false);+ const foldable = rows.length > TOOL_ROWS_VISIBLE;+ const visible = foldable && !expanded ? rows.slice(0, TOOL_ROWS_VISIBLE) : rows;++ const content = (+ <Flexbox>+ {rows.length === 0 ? (+ <Row divided={false}>+ <Text type={'secondary'}>{emptyText}</Text>+ </Row>+ ) : (+ visible.map((row, index) => (+ <Row divided={index > 0} key={row.key ?? index}>+ {row}+ </Row>+ ))+ )}+ {foldable && (+ <Row divided>+ <Flexbox horizontal>+ <Button size={'small'} type={'text'} onClick={() => setExpanded(!expanded)}>+ {expanded+ ? t('settingAgent.tools.showLess')+ : t('settingAgent.tools.showAll', { count: rows.length })}+ </Button>+ </Flexbox>+ </Row>+ )}+ <Row divided>+ <Flexbox horizontal>{addControl}</Flexbox>+ </Row>+ </Flexbox>+ );+ const heading = (+ <Flexbox horizontal align={'baseline'} gap={8}>+ {plain ? <Text style={{ fontWeight: 600 }}>{title}</Text> : title}+ <Text fontSize={12} type={'secondary'}>+ {total && total >= rows.length+ ? t('settingAgent.tools.countOfTotal', {+ count: activeCount ?? rows.length,+ total,+ })+ : (activeCount ?? rows.length)}+ </Text>+ </Flexbox>+ );++ if (plain) {+ return (+ <Flexbox gap={8}>+ <Flexbox horizontal align={'center'} justify={'space-between'}>+ {heading}+ {extra}+ </Flexbox>+ <Flexbox style={{ borderBlockStart: `1px solid ${cssVar.colorFillSecondary}` }}>+ {content}+ </Flexbox>+ </Flexbox>+ );+ }++ return (+ <Form+ collapsible={false}+ form={form}+ itemsType={'group'}+ variant={'filled'}+ items={[+ {+ children: content,+ desc,+ extra,+ title: heading,+ },+ ]}+ {...FORM_STYLE}+ />+ );+ },+);++ToolListGroup.displayName = 'ToolListGroup';++export default ToolListGroup;diff --git a/src/features/ProfileEditor/itemDetailStore.ts b/src/features/ProfileEditor/itemDetailStore.tsnew file mode 100644index 00000000000..d118b35682e--- /dev/null+++ b/src/features/ProfileEditor/itemDetailStore.ts@@ -0,0 +1,19 @@+import { create } from 'zustand';++import { type ItemDetail } from './ItemDetailPanel';++interface ItemDetailState {+ close: () => void;+ detail?: ItemDetail;+ open: (detail: ItemDetail) => void;+}++/**+ * The item whose details sit in the page's right-hand panel. A list opens one by clicking a row;+ * the page shell renders the panel, so it docks to the page edge like any other side panel.+ */+export const useItemDetailStore = create<ItemDetailState>((set) => ({+ close: () => set({ detail: undefined }),+ detail: undefined,+ open: (detail) => set({ detail }),+}));diff --git a/src/features/ProfileEditor/rowKeys.test.ts b/src/features/ProfileEditor/rowKeys.test.tsnew file mode 100644index 00000000000..e32ec0ce68a--- /dev/null+++ b/src/features/ProfileEditor/rowKeys.test.ts@@ -0,0 +1,19 @@+import { describe, expect, it } from 'vitest';++import { shouldActivateRow } from './rowKeys';++describe('shouldActivateRow', () => {+ const row = {};++ it.each(['Enter', ' '])('opens on %j when the row itself has focus', (key) => {+ expect(shouldActivateRow({ currentTarget: row, key, target: row })).toBe(true);+ });++ it('leaves other keys alone', () => {+ expect(shouldActivateRow({ currentTarget: row, key: 'a', target: row })).toBe(false);+ });++ it('leaves a key pressed on a control inside the row to that control', () => {+ expect(shouldActivateRow({ currentTarget: row, key: 'Enter', target: {} })).toBe(false);+ });+});diff --git a/src/features/ProfileEditor/rowKeys.ts b/src/features/ProfileEditor/rowKeys.tsnew file mode 100644index 00000000000..214032029a3--- /dev/null+++ b/src/features/ProfileEditor/rowKeys.ts@@ -0,0 +1,9 @@+/**+ * Whether a key press should open a clickable row: Enter or Space, and only when the row itself+ * has focus — a press on a switch or button inside the row belongs to that control.+ */+export const shouldActivateRow = (event: {+ currentTarget: unknown;+ key: string;+ target: unknown;+}): boolean => event.target === event.currentTarget && (event.key === 'Enter' || event.key === ' ');diff --git a/src/features/RouteMeta/AgentDynamicMeta.tsx b/src/features/RouteMeta/AgentDynamicMeta.tsxindex 80ad8dbb7c8..f4e7ad1026c 100644--- a/src/features/RouteMeta/AgentDynamicMeta.tsx+++ b/src/features/RouteMeta/AgentDynamicMeta.tsx@@ -99,6 +99,12 @@ const createAgentSectionDynamicMeta = (titleKey: string) => {export const TopicsDynamicMeta = createAgentSectionDynamicMeta('navigation.topics');export const ProfileDynamicMeta = createAgentSectionDynamicMeta('navigation.profile');+export const EngineDynamicMeta = createAgentSectionDynamicMeta('navigation.engine');+export const InstructionDynamicMeta = createAgentSectionDynamicMeta('navigation.instruction');+export const EnvironmentDynamicMeta = createAgentSectionDynamicMeta('navigation.environment');+export const ToolsDynamicMeta = createAgentSectionDynamicMeta('navigation.tools');+export const KnowledgeDynamicMeta = createAgentSectionDynamicMeta('navigation.knowledge');+export const SkillsDynamicMeta = createAgentSectionDynamicMeta('navigation.skills');export const ChannelDynamicMeta = createAgentSectionDynamicMeta('navigation.channels');export const StatisticsDynamicMeta = createAgentSectionDynamicMeta('navigation.stats');export const ShareDynamicMeta = createAgentSectionDynamicMeta('navigation.agentShare');diff --git a/src/routes/(main)/agent/engine/index.tsx b/src/routes/(main)/agent/engine/index.tsxnew file mode 100644index 00000000000..c49dc2ab874--- /dev/null+++ b/src/routes/(main)/agent/engine/index.tsx@@ -0,0 +1,8 @@+'use client';++import { AgentProfileView } from '../profile';++/** `/agent/:aid/engine` — what runs the agent: its driver, model and where it works. */+const AgentEnginePage = () => <AgentProfileView view="engine" />;++export default AgentEnginePage;diff --git a/src/routes/(main)/agent/environment/index.tsx b/src/routes/(main)/agent/environment/index.tsxnew file mode 100644index 00000000000..e8fcd46e586--- /dev/null+++ b/src/routes/(main)/agent/environment/index.tsx@@ -0,0 +1,8 @@+'use client';++import { AgentProfileView } from '../profile';++/** `/agent/:aid/environment` — where a heterogeneous agent runs and what it needs there. */+const AgentEnvironmentPage = () => <AgentProfileView view="environment" />;++export default AgentEnvironmentPage;diff --git a/src/routes/(main)/agent/features/routeMeta.ts b/src/routes/(main)/agent/features/routeMeta.tsindex 8d39dad5f0d..94ff9261ea6 100644--- a/src/routes/(main)/agent/features/routeMeta.ts+++ b/src/routes/(main)/agent/features/routeMeta.ts@@ -1,13 +1,19 @@import {ChartColumnBigIcon,+ CpuIcon,FileUserIcon,GraduationCapIcon,+ LibraryBigIcon,MailIcon,MessageSquare,MessagesSquareIcon,+ MonitorSmartphoneIcon,RadioTowerIcon,+ ScrollTextIcon,Share2Icon,+ SparklesIcon,UsersIcon,+ WrenchIcon,} from 'lucide-react';import { lazy } from 'react';@@ -30,6 +36,36 @@ const TopicsDynamicMeta = lazy(() =>default: module.TopicsDynamicMeta,})),);+const EngineDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.EngineDynamicMeta,+ })),+);+const InstructionDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.InstructionDynamicMeta,+ })),+);+const KnowledgeDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.KnowledgeDynamicMeta,+ })),+);+const SkillsDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.SkillsDynamicMeta,+ })),+);+const EnvironmentDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.EnvironmentDynamicMeta,+ })),+);+const ToolsDynamicMeta = lazy(() =>+ import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({+ default: module.ToolsDynamicMeta,+ })),+);const ProfileDynamicMeta = lazy(() =>import('@/features/RouteMeta/AgentDynamicMeta').then((module) => ({default: module.ProfileDynamicMeta,@@ -88,6 +124,48 @@ export const agentProfileRouteMeta = routeMeta({titleKey: 'navigation.profile',});+export const agentInstructionRouteMeta = routeMeta({+ DynamicMeta: InstructionDynamicMeta,+ icon: ScrollTextIcon,+ Skeleton: ProfileSkeleton,+ titleKey: 'navigation.instruction',+});++export const agentKnowledgeRouteMeta = routeMeta({+ DynamicMeta: KnowledgeDynamicMeta,+ icon: LibraryBigIcon,+ Skeleton: ProfileSkeleton,+ titleKey: 'navigation.knowledge',+});++export const agentSkillsRouteMeta = routeMeta({+ DynamicMeta: SkillsDynamicMeta,+ icon: SparklesIcon,+ Skeleton: ProfileSkeleton,+ titleKey: 'navigation.skills',+});++export const agentEngineRouteMeta = routeMeta({+ DynamicMeta: EngineDynamicMeta,+ icon: CpuIcon,+ Skeleton: ProfileSkeleton,+ titleKey: 'navigation.engine',+});++export const agentEnvironmentRouteMeta = routeMeta({+ DynamicMeta: EnvironmentDynamicMeta,+ icon: MonitorSmartphoneIcon,+ Skeleton: ProfileSkeleton,+ titleKey: 'navigation.environment',+});++export const agentToolsRouteMeta = routeMeta({+ DynamicMeta: ToolsDynamicMeta,+ icon: WrenchIcon,+ Skeleton: ProfileSkeleton,+ titleKey: 'navigation.tools',+});+export const agentMailRouteMeta = routeMeta({icon: MailIcon,Skeleton: createSurfaceSkeleton('list'),diff --git a/src/routes/(main)/agent/instruction/index.tsx b/src/routes/(main)/agent/instruction/index.tsxnew file mode 100644index 00000000000..687c5995a83--- /dev/null+++ b/src/routes/(main)/agent/instruction/index.tsx@@ -0,0 +1,8 @@+'use client';++import { AgentProfileView } from '../profile';++/** `/agent/:aid/instruction` — the agent's core instruction. */+const AgentInstructionPage = () => <AgentProfileView view="instruction" />;++export default AgentInstructionPage;diff --git a/src/routes/(main)/agent/knowledge/index.tsx b/src/routes/(main)/agent/knowledge/index.tsxnew file mode 100644index 00000000000..f80dbd2fda4--- /dev/null+++ b/src/routes/(main)/agent/knowledge/index.tsx@@ -0,0 +1,8 @@+'use client';++import { AgentProfileView } from '../profile';++/** `/agent/:aid/knowledge` — the knowledge bases and files the agent can search. */+const AgentKnowledgePage = () => <AgentProfileView view="knowledge" />;++export default AgentKnowledgePage;diff --git a/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx b/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsxindex 108393dc52a..1d50e9dc5ad 100644--- a/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx+++ b/src/routes/(main)/agent/profile/features/EditorCanvas/index.tsx@@ -31,11 +31,6 @@ const styles = createStaticStyles(({ css }) => ({editorShell: css`min-height: 300px;padding-block: 18px;- padding-inline: 18px;- border: 1px solid ${cssVar.colorBorderSecondary};- border-radius: ${cssVar.borderRadiusLG};-- background: ${cssVar.colorBgContainer};`,root: css`padding-block-end: 16px;diff --git a/src/routes/(main)/agent/profile/features/EngineEditor/index.tsx b/src/routes/(main)/agent/profile/features/EngineEditor/index.tsxnew file mode 100644index 00000000000..be62033749a--- /dev/null+++ b/src/routes/(main)/agent/profile/features/EngineEditor/index.tsx@@ -0,0 +1,202 @@+'use client';++import {+ HETEROGENEOUS_TYPE_LABELS,+ isRemoteHeterogeneousType,+} from '@lobechat/heterogeneous-agents';+import { Alert, Button, Flexbox, Text } from '@lobehub/ui';+import { Form, type FormGroupItem, useForm } from '@lobehub/ui/form';+import isEqual from 'fast-deep-equal';+import { ChevronDown } from 'lucide-react';+import React, { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { AGENT_SHARE_ALLOWED_PROVIDERS } from '@/business/agent-share';+import { useAgentShareSupported } from '@/business/client/useAgentShareSupported';+import { ModelIcon } from '@/components/LobeIcons';+import { FORM_STYLE } from '@/const/layoutTokens';+import AgentDriverSelect from '@/features/AgentDriver';+import { buildAgentProfileTabPath } from '@/features/AgentProfileTabs/tabOptions';+import ReasoningEffortSelect from '@/features/ModelSelect/ReasoningEffortSelect';+import ModelSwitchPanel from '@/features/ModelSwitchPanel';+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';+import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';+import { usePermission } from '@/hooks/usePermission';+import { useAgentStore } from '@/store/agent';+import { agentByIdSelectors, agentSelectors } from '@/store/agent/selectors';+import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';++import WorkspaceAgentDevicePolicy from '../ProfileEditor/WorkspaceAgentDevicePolicy';+import { WorkspaceAgentModelPolicy } from '../ProfileEditor/WorkspaceAgentModelPolicy';++const EngineEditor = memo(() => {+ const { t } = useTranslation(['setting', 'agent']);+ const form = useForm();+ const navigate = useWorkspaceAwareNavigate();+ const { allowed: canEdit } = usePermission('edit_own_content');+ const agentId = useAgentStore((s) => s.activeAgentId || '');+ const config = useAgentStore(agentSelectors.getAgentConfigById(agentId), isEqual);+ const { isShared } = useAgentShareSupported(agentId);+ const chatModels = useEnabledChatModels();+ const enabledList =+ isShared && AGENT_SHARE_ALLOWED_PROVIDERS+ ? chatModels.filter((provider) => AGENT_SHARE_ALLOWED_PROVIDERS?.includes(provider.id))+ : undefined;+ const selectedModel = useAiInfraStore(+ aiModelSelectors.getEnabledModelById(config?.model ?? '', config?.provider ?? ''),+ );+ const isWorkspaceAgent = useAgentStore(agentByIdSelectors.isWorkspaceAgentById(agentId));+ const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);+ const isHeterogeneous = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);+ const heterogeneousProvider = config?.agencyConfig?.heterogeneousProvider;+ const isRemoteHetero =+ isHeterogeneous &&+ !!heterogeneousProvider &&+ isRemoteHeterogeneousType(heterogeneousProvider.type);+ const driverName = heterogeneousProvider+ ? HETEROGENEOUS_TYPE_LABELS[heterogeneousProvider.type]+ : t('settingAgent.driver.harness');+ // What is configured below depends on the driver above, so the section is named after it.+ const configTitle = t('settingAgent.engine.configTitle', { name: driverName });++ // The driver is the one big choice on this page, so every option is laid out in view with what+ // the current one means for you above them.+ const driverForm = (+ <Flexbox gap={16}>+ <Flexbox gap={4}>+ <Text style={{ fontSize: 16, fontWeight: 600 }}>{t('settingAgent.driver.title')}</Text>+ <Text type={'secondary'}>+ {t(+ heterogeneousProvider+ ? 'settingAgent.driver.brings.hetero'+ : 'settingAgent.driver.brings.harness',+ )}+ </Text>+ </Flexbox>+ <AgentDriverSelect+ agentId={agentId}+ canEdit={canEdit && !isRemoteHetero && !isWorkspaceAgent}+ />+ </Flexbox>+ );++ const configHeading = (+ <Text fontSize={16} style={{ marginBlockStart: 8 }} weight={600}>+ {configTitle}+ </Text>+ );++ const modelForm = (+ <Form+ collapsible={false}+ form={form}+ itemsType={'group'}+ variant={'filled'}+ items={[+ {+ children: isHeterogeneous+ ? []+ : [+ {+ children: (+ <ModelSwitchPanel+ enabledList={enabledList}+ model={config?.model}+ open={canEdit ? undefined : false}+ openOnHover={false}+ placement={'bottomRight'}+ provider={config?.provider}+ notice={+ enabledList && (+ <Alert+ showIcon+ title={t('share.settings.modelRestriction.title', { ns: 'agent' })}+ type={'info'}+ description={t('share.settings.modelRestriction.description', {+ ns: 'agent',+ })}+ />+ )+ }+ onModelChange={async (value) => {+ if (canEdit) await updateAgentConfigById(agentId, value);+ }}+ >+ <Button disabled={!canEdit}>+ <ModelIcon model={config?.model} size={20} />+ {selectedModel?.displayName || config?.model}+ <ChevronDown size={14} />+ </Button>+ </ModelSwitchPanel>+ ),+ desc: t('settingAgent.model.desc'),+ label: t('settingAgent.model.title'),+ layout: 'horizontal' as const,+ minWidth: undefined,+ },+ ...(config?.model && config.provider+ ? [+ {+ children: (+ <ReasoningEffortSelect+ disabled={!canEdit}+ model={config.model}+ provider={config.provider}+ />+ ),+ desc: t('settingAgent.reasoning.desc'),+ label: t('settingAgent.reasoning.title'),+ layout: 'horizontal' as const,+ minWidth: undefined,+ },+ ]+ : []),+ ],+ title: configTitle,+ } satisfies FormGroupItem,+ ]}+ {...FORM_STYLE}+ />+ );++ return (+ <Flexbox gap={32} paddingBlock={'8px 48px'}>+ <Flexbox gap={4}>+ <Text fontSize={24} weight={600}>+ {t('settingAgent.engine.title')}+ </Text>+ <Text type={'secondary'}>{t('settingAgent.engine.desc')}</Text>+ </Flexbox>+ {!isWorkspaceAgent ? driverForm : null}+ {isHeterogeneous ? (+ // Where it runs lives on its own page, so say so rather than leave this one bare.+ <Flexbox horizontal align={'center'} gap={4}>+ <Text type={'secondary'}>+ {t('settingAgent.engine.heteroHint', { name: driverName })}+ </Text>+ <Button+ size={'small'}+ type={'text'}+ onClick={() => navigate(buildAgentProfileTabPath(agentId, 'environment'))}+ >+ {t('tab.environment', { ns: 'chat' })}+ </Button>+ </Flexbox>+ ) : isWorkspaceAgent ? (+ <>+ {configHeading}+ <Flexbox horizontal gap={8} wrap={'wrap'}>+ <WorkspaceAgentModelPolicy agentId={agentId} />+ <WorkspaceAgentDevicePolicy agentId={agentId} />+ </Flexbox>+ </>+ ) : (+ modelForm+ )}+ </Flexbox>+ );+});++EngineEditor.displayName = 'EngineEditor';++export default EngineEditor;diff --git a/src/routes/(main)/agent/profile/features/EnvironmentEditor/index.tsx b/src/routes/(main)/agent/profile/features/EnvironmentEditor/index.tsxnew file mode 100644index 00000000000..714a8569de2--- /dev/null+++ b/src/routes/(main)/agent/profile/features/EnvironmentEditor/index.tsx@@ -0,0 +1,285 @@+'use client';++import { isDesktop } from '@lobechat/const';+import {+ HETEROGENEOUS_TYPE_LABELS,+ isHeterogeneousProviderBindingSupported,+ isRemoteHeterogeneousType,+ isServerDefaultHeterogeneousAgentType,+} from '@lobechat/heterogeneous-agents';+import type { HeterogeneousApiConfig, HeterogeneousAuthMode } from '@lobechat/types';+import { Alert, Flexbox, Text } from '@lobehub/ui';+import isEqual from 'fast-deep-equal';+import { Fingerprint, MonitorSmartphone } from 'lucide-react';+import React, { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { ClaudeCodeEntrypointSetting } from '@/features/HeterogeneousAgent/ClaudeCodeEntrypointSetting';+import { ApiAuthLocalOnlyNotice } from '@/features/HeterogeneousAgent/ExecutionEnvironment/ApiAuthLocalOnlyNotice';+import { DeviceCliStatusCard } from '@/features/HeterogeneousAgent/ExecutionEnvironment/DeviceCliStatusCard';+import { HeteroExecutionTargetSelect } from '@/features/HeterogeneousAgent/ExecutionEnvironment/HeteroExecutionTargetSelect';+import { useProfileExecutionTarget } from '@/features/HeterogeneousAgent/ExecutionEnvironment/useProfileExecutionTarget';+import { resolveServerDefaultAgentModels } from '@/features/HeterogeneousAgent/modelPicker';+import { usePermission } from '@/hooks/usePermission';+import { useAgentStore } from '@/store/agent';+import { agentByIdSelectors, agentSelectors } from '@/store/agent/selectors';++import CloudHeterogeneousConfig from '../ProfileEditor/CloudHeterogeneousConfig';+import HeterogeneousAgentStatusCard from '../ProfileEditor/HeterogeneousAgentStatusCard';+import RemoteAgentConfigCard from '../ProfileEditor/RemoteAgentConfigCard';+import WorkspaceAgentDevicePolicy from '../ProfileEditor/WorkspaceAgentDevicePolicy';+import { WorkspaceAgentPolicyCard } from '../ProfileEditor/WorkspaceAgentPolicyCard';++const EnvironmentEditor = memo(() => {+ const { t } = useTranslation(['setting', 'agent']);+ const { allowed: canEdit } = usePermission('edit_own_content');+ const agentId = useAgentStore((s) => s.activeAgentId || '');+ const config = useAgentStore(agentSelectors.getAgentConfigById(agentId), isEqual);+ const isWorkspaceAgent = useAgentStore(agentByIdSelectors.isWorkspaceAgentById(agentId));+ const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);+ const isHeterogeneous = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);+ const heterogeneousProvider = config?.agencyConfig?.heterogeneousProvider;+ // Where this caller's new topics run. The environment picker and the panel+ // below both follow it, so the panel never describes this client by default.+ const executionTarget = useProfileExecutionTarget(agentId);++ const updateHeterogeneousCommand = async (command: string) => {+ if (!canEdit) return;+ if (!heterogeneousProvider) return;+ await updateAgentConfigById(agentId, {+ agencyConfig: {+ heterogeneousProvider: { ...heterogeneousProvider, command },+ },+ });+ };++ const updateHeterogeneousEnv = async (env: Record<string, string>) => {+ if (!canEdit) return;+ if (!heterogeneousProvider) return;+ await updateAgentConfigById(agentId, {+ agencyConfig: {+ heterogeneousProvider: { ...heterogeneousProvider, env },+ },+ });+ };++ const updateHeterogeneousAuthMode = async (+ authMode: HeterogeneousAuthMode,+ apiConfig?: HeterogeneousApiConfig,+ ) => {+ if (!canEdit || !heterogeneousProvider) return;+ await updateAgentConfigById(agentId, {+ agencyConfig: {+ heterogeneousProvider: { ...heterogeneousProvider, apiConfig, authMode },+ },+ });+ };++ const updateHeterogeneousApiConfig = async (apiConfig: HeterogeneousApiConfig | undefined) => {+ if (!canEdit || !heterogeneousProvider) return;+ await updateAgentConfigById(agentId, {+ agencyConfig: {+ heterogeneousProvider: { ...heterogeneousProvider, apiConfig },+ },+ });+ };++ const updateBoundDeviceId = async (boundDeviceId: string) => {+ await updateAgentConfigById(agentId, {+ agencyConfig: { ...config?.agencyConfig, boundDeviceId, executionTarget: 'device' },+ });+ };++ const isRemoteHetero =+ isHeterogeneous &&+ !!heterogeneousProvider &&+ isRemoteHeterogeneousType(heterogeneousProvider.type);+ const localDesktopAvailable =+ isDesktop && !!heterogeneousProvider && executionTarget.target === 'local';+ // Workspace agents are excluded even when the author could spawn them+ // locally: the binding UI would list workspace-scoped providers, but Desktop+ // main resolves the reference in the personal scope only (see+ // `selectRuntimeType`'s personal-scope guard). The deployment-default API+ // source is not a user-provider binding, so it stays available whenever+ // local Desktop execution is available.+ const apiModeAvailable =+ localDesktopAvailable &&+ !isWorkspaceAgent &&+ isHeterogeneousProviderBindingSupported(heterogeneousProvider.type);+ const useFetchServerDefaultCapability = useAgentStore(+ (s) => s.useFetchServerDefaultHeterogeneousCapability,+ );+ // The shared matrix owns which native drivers can reach the deployment relay;+ // model/runtime compatibility continues to come from the server capability below.+ const serverDefaultAgentType =+ heterogeneousProvider && isServerDefaultHeterogeneousAgentType(heterogeneousProvider.type)+ ? heterogeneousProvider.type+ : undefined;+ const serverCapabilityEnabled = localDesktopAvailable && !!serverDefaultAgentType;+ const serverCapabilitySync = useFetchServerDefaultCapability(serverCapabilityEnabled);+ // The last confirmed capability paints at once; the sync only confirms it, and+ // a failed background refresh keeps it instead of turning into an error.+ const serverCapability = useAgentStore(agentSelectors.heteroServerDefaultCapability);+ const serverCapabilityError = !serverCapability && serverCapabilitySync.error;+ const serverCapabilityLoading =+ serverCapabilityEnabled && !serverCapability && !serverCapabilitySync.error;+ const serverDefaultModels =+ serverCapability?.enabled === true && serverDefaultAgentType+ ? resolveServerDefaultAgentModels(serverCapability.models, serverDefaultAgentType)+ : [];+ const serverDefaultAvailable = serverCapabilityEnabled && serverDefaultModels.length > 0;+ const serverDefaultUnavailableReason = !localDesktopAvailable+ ? t('heterogeneousStatus.apiMode.localOnly')+ : serverCapabilityError+ ? t('heterogeneousStatus.apiMode.serverDefault.loadFailed')+ : serverCapability?.enabled === false+ ? t(+ serverCapability.reason === 'disabled'+ ? 'heterogeneousStatus.apiMode.serverDefault.disabled'+ : 'heterogeneousStatus.apiMode.serverDefault.invalidConfiguration',+ )+ : serverCapabilityEnabled && !serverCapabilityLoading && !serverDefaultAvailable+ ? t('heterogeneousStatus.apiMode.serverDefault.unsupported')+ : undefined;+ const renderHeterogeneousPanelBody = () => {+ if (!heterogeneousProvider) return null;++ const { panel } = executionTarget;++ switch (panel.kind) {+ case 'cloud': {+ return (+ <CloudHeterogeneousConfig+ provider={heterogeneousProvider}+ onEnvChange={updateHeterogeneousEnv}+ />+ );+ }+ case 'device': {+ return <DeviceCliStatusCard deviceId={panel.deviceId} provider={heterogeneousProvider} />;+ }+ case 'local':+ case 'runtime': {+ return (+ <HeterogeneousAgentStatusCard+ apiModeAvailable={apiModeAvailable}+ apiModeWorkspaceBlocked={isWorkspaceAgent}+ provider={heterogeneousProvider}+ serverDefaultAvailable={serverDefaultAvailable}+ serverDefaultLoading={serverCapabilityLoading}+ serverDefaultModels={serverDefaultModels}+ serverDefaultUnavailableReason={serverDefaultUnavailableReason}+ onApiConfigChange={updateHeterogeneousApiConfig}+ onAuthModeChange={updateHeterogeneousAuthMode}+ onCommandChange={updateHeterogeneousCommand}+ onServerDefaultRetry={() => {+ void serverCapabilitySync.revalidate();+ }}+ />+ );+ }+ case 'sandbox': {+ return (+ <Alert+ showIcon+ type={'info'}+ title={t('heterogeneousStatus.sandbox.desc', {+ name: HETEROGENEOUS_TYPE_LABELS[heterogeneousProvider.type],+ })}+ />+ );+ }+ case 'pending': {+ return null;+ }+ }+ };++ const renderHeterogeneousPanel = () => {+ // Until the member's own override loads, the target may still flip.+ if (!heterogeneousProvider || executionTarget.isPending) return null;++ return (+ <>+ {/* Dispatch rejects API auth off this desktop, and only the local card+ edits auth — so every other environment offers the way back. */}+ {executionTarget.isApiAuthBlocked && (+ <ApiAuthLocalOnlyNotice+ onUseSubscription={+ canEdit+ ? () =>+ void updateHeterogeneousAuthMode(+ 'subscription',+ heterogeneousProvider.apiConfig,+ )+ : undefined+ }+ />+ )}+ {renderHeterogeneousPanelBody()}+ </>+ );+ };++ return (+ <Flexbox gap={32} paddingBlock={'8px 48px'}>+ <Flexbox gap={4}>+ <Text fontSize={24} weight={600}>+ {t('settingAgent.environment.title')}+ </Text>+ <Text type={'secondary'}>{t('settingAgent.environment.desc')}</Text>+ </Flexbox>+ <Flexbox gap={8} style={{ containerType: 'inline-size' }}>+ {isRemoteHetero && heterogeneousProvider ? (+ // Remote platform agents (openclaw / hermes): show device config panel+ <>+ <RemoteAgentConfigCard+ provider={heterogeneousProvider}+ onBoundDeviceChange={updateBoundDeviceId}+ />+ <WorkspaceAgentDevicePolicy agentId={agentId} showDevicePicker={false} />+ </>+ ) : isHeterogeneous && heterogeneousProvider ? (+ // CLI agents: pick where new topics run, then configure that environment.+ <>+ <WorkspaceAgentPolicyCard+ fullWidth+ icon={MonitorSmartphone}+ title={t('settingAgent.devicePolicy.title')}+ >+ <HeteroExecutionTargetSelect+ agentId={agentId}+ deviceId={executionTarget.deviceId}+ isOverridden={executionTarget.isOverridden}+ isPending={executionTarget.isPending}+ isSelectable={executionTarget.isSelectable}+ providerType={heterogeneousProvider.type}+ target={executionTarget.target}+ />+ </WorkspaceAgentPolicyCard>+ {renderHeterogeneousPanel()}+ {/* Follows the engine and its sign-in, not where the run lands. */}+ {heterogeneousProvider.type === 'claude-code' &&+ (heterogeneousProvider.authMode ?? 'subscription') === 'subscription' && (+ <WorkspaceAgentPolicyCard+ fullWidth+ icon={Fingerprint}+ title={t('heterogeneousStatus.entrypoint.label')}+ >+ <ClaudeCodeEntrypointSetting+ disabled={!canEdit}+ env={heterogeneousProvider.env}+ onEnvChange={updateHeterogeneousEnv}+ />+ </WorkspaceAgentPolicyCard>+ )}+ </>+ ) : null}+ </Flexbox>+ </Flexbox>+ );+});++EnvironmentEditor.displayName = 'EnvironmentEditor';++export default EnvironmentEditor;diff --git a/src/routes/(main)/agent/profile/features/Header/index.tsx b/src/routes/(main)/agent/profile/features/Header/index.tsxindex 2b8929a7b74..3a48fccaccb 100644--- a/src/routes/(main)/agent/profile/features/Header/index.tsx+++ b/src/routes/(main)/agent/profile/features/Header/index.tsx@@ -36,6 +36,7 @@ import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';import AgentBreadcrumb from '@/features/AgentBreadcrumb';import { useAgentMarketSubmission } from '@/features/AgentMarketSubmission/useAgentMarketSubmission';import AgentProfileTabs, { AGENT_PROFILE_TABS_CENTER_STYLE } from '@/features/AgentProfileTabs';+import { type AgentProfileTab } from '@/features/AgentProfileTabs/tabOptions';import NavHeader from '@/features/NavHeader';import { formatPageEditorInfoTime } from '@/features/PageEditor/formatPageEditorInfoTime';import AccessLevelTag from '@/features/ResourcePermission/AccessLevelTag';@@ -111,7 +112,12 @@ const buildAgentProfileMarkdown = (params: {return `${sections.join('\n\n')}\n`;};-const Header = memo(() => {+interface HeaderProps {+ /** The profile page being shown, so the page switcher highlights it. */+ active?: AgentProfileTab;+}++const Header = memo<HeaderProps>(({ active = 'profile' }) => {const { i18n, t } = useTranslation(['setting', 'chat', 'file', 'common', 'agent']);const dateLocale = i18n?.resolvedLanguage || i18n?.language;const navigate = useWorkspaceAwareNavigate();@@ -464,7 +470,7 @@ const Header = memo(() => {},}}>- {activeAgentId && <AgentProfileTabs active={'profile'} agentId={activeAgentId} />}+ {activeAgentId && <AgentProfileTabs active={active} agentId={activeAgentId} />}</NavHeader>);});diff --git a/src/routes/(main)/agent/profile/features/InstructionEditor/index.tsx b/src/routes/(main)/agent/profile/features/InstructionEditor/index.tsxnew file mode 100644index 00000000000..6d20df19d8a--- /dev/null+++ b/src/routes/(main)/agent/profile/features/InstructionEditor/index.tsx@@ -0,0 +1,32 @@+'use client';++import { Flexbox, Text } from '@lobehub/ui';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import EditorCanvas from '../EditorCanvas';++/**+ * The Instruction page: the agent's core prompt, on a page of its own. Heterogeneous agents+ * (Claude Code, Codex, …) run an external CLI with its own system prompt, so the sidebar does+ * not offer this page for them rather than showing a control that looks effective but isn't.+ */+const InstructionEditor = memo(() => {+ const { t } = useTranslation('setting');++ return (+ <Flexbox gap={24} paddingBlock={'8px 48px'}>+ <Flexbox gap={4}>+ <Text fontSize={24} weight={600}>+ {t('settingAgent.instruction.title')}+ </Text>+ <Text type={'secondary'}>{t('settingAgent.instruction.desc')}</Text>+ </Flexbox>+ <EditorCanvas />+ </Flexbox>+ );+});++InstructionEditor.displayName = 'InstructionEditor';++export default InstructionEditor;diff --git a/src/routes/(main)/agent/profile/features/KnowledgeEditor/index.tsx b/src/routes/(main)/agent/profile/features/KnowledgeEditor/index.tsxnew file mode 100644index 00000000000..5f09754e603--- /dev/null+++ b/src/routes/(main)/agent/profile/features/KnowledgeEditor/index.tsx@@ -0,0 +1,154 @@+'use client';++import { ActionIcon, Button, Flexbox, Icon, Switch, Text } from '@lobehub/ui';+import isEqual from 'fast-deep-equal';+import { PlusIcon, XIcon } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import FileIcon from '@/components/FileIcon';+import RepoIcon from '@/components/LibIcon';+import { openAttachKnowledgeModal } from '@/features/LibraryModal';+import ItemRow from '@/features/ProfileEditor/ItemRow';+import ToolListGroup from '@/features/ProfileEditor/ToolListGroup';+import { usePermission } from '@/hooks/usePermission';+import { useClientDataSWR } from '@/libs/swr';+import { resourceService } from '@/services/resource';+import { useAgentStore } from '@/store/agent';+import { agentByIdSelectors } from '@/store/agent/selectors';++/** The most files counted for one library; past it the row says "N+". */+const COUNT_PAGE = 50;++/** How much is inside a library, so a row says what the agent can actually search. */+const LibraryCount = memo<{ id: string }>(({ id }) => {+ const { t } = useTranslation('setting');+ // One small, cached request per row, and not again on every focus: the count is a hint, so it+ // stops at a page rather than walking a large library.+ const { data } = useClientDataSWR(+ ['agent-library-count', id],+ () => resourceService.queryResources({ libraryId: id, limit: COUNT_PAGE }),+ { revalidateOnFocus: false },+ );+ if (!data) return null;++ // An older server may omit `items`; the count still falls back to zero rather than throwing.+ const items = data.items ?? [];+ const count = data.total ?? items.length;++ return (+ <Text fontSize={12} style={{ flex: 'none' }} type={'secondary'}>+ {data.hasMore && data.total === undefined+ ? t('settingAgent.knowledgePage.files.countMore', { count })+ : t('settingAgent.knowledgePage.files.count', { count })}+ </Text>+ );+});++LibraryCount.displayName = 'LibraryCount';++/**+ * The Knowledge Base page: the libraries and files this agent can search when it answers. Each+ * can be switched off without being removed, and adding opens the same picker as the chat input.+ */+const KnowledgeEditor = memo(() => {+ const { t } = useTranslation('setting');+ const { allowed: canEdit } = usePermission('edit_own_content');+ const agentId = useAgentStore((s) => s.activeAgentId || '');+ const libraries = useAgentStore(+ (s) => agentByIdSelectors.getAgentKnowledgeBasesById(agentId)(s),+ isEqual,+ );+ const files = useAgentStore((s) => agentByIdSelectors.getAgentFilesById(agentId)(s), isEqual);+ const [toggleKnowledgeBase, toggleFile, removeKnowledgeBase, removeFile] = useAgentStore((s) => [+ s.toggleKnowledgeBase,+ s.toggleFile,+ s.removeKnowledgeBaseFromAgent,+ s.removeFileFromAgent,+ ]);++ const addControl = (label: string) => (+ <Button+ disabled={!canEdit}+ icon={<Icon icon={PlusIcon} />}+ size={'small'}+ type={'text'}+ onClick={() => openAttachKnowledgeModal()}+ >+ {label}+ </Button>+ );++ const actions = (+ enabled: boolean | undefined,+ onToggle: (next: boolean) => void,+ onRemove: () => void,+ ) => (+ <>+ <Switch checked={!!enabled} disabled={!canEdit} size={'small'} onChange={onToggle} />+ <ActionIcon+ disabled={!canEdit}+ icon={XIcon}+ size={'small'}+ title={t('settingAgent.knowledgePage.remove')}+ onClick={onRemove}+ />+ </>+ );++ return (+ <Flexbox gap={32} paddingBlock={'8px 48px'}>+ <Flexbox gap={4}>+ <Text fontSize={24} weight={600}>+ {t('settingAgent.knowledgePage.title')}+ </Text>+ <Text type={'secondary'}>{t('settingAgent.knowledgePage.desc')}</Text>+ </Flexbox>++ <Flexbox gap={16}>+ <ToolListGroup+ addControl={addControl(t('settingAgent.knowledgePage.addLibrary'))}+ desc={t('settingAgent.knowledgePage.libraries.desc')}+ emptyText={t('settingAgent.knowledgePage.libraries.empty')}+ title={t('settingAgent.knowledgePage.libraries.title')}+ rows={libraries.map((item) => (+ <ItemRow+ description={item.description ?? undefined}+ icon={<RepoIcon />}+ key={item.id}+ meta={<LibraryCount id={item.id} />}+ title={item.name}+ actions={actions(+ item.enabled,+ (next) => void toggleKnowledgeBase(item.id, next),+ () => void removeKnowledgeBase(item.id),+ )}+ />+ ))}+ />+ <ToolListGroup+ addControl={addControl(t('settingAgent.knowledgePage.addFile'))}+ desc={t('settingAgent.knowledgePage.files.desc')}+ emptyText={t('settingAgent.knowledgePage.files.empty')}+ title={t('settingAgent.knowledgePage.files.title')}+ rows={files.map((item) => (+ <ItemRow+ icon={<FileIcon fileName={item.name} fileType={item.type} size={20} />}+ key={item.id}+ title={item.name}+ actions={actions(+ item.enabled,+ (next) => void toggleFile(item.id, next),+ () => void removeFile(item.id),+ )}+ />+ ))}+ />+ </Flexbox>+ </Flexbox>+ );+});++KnowledgeEditor.displayName = 'KnowledgeEditor';++export default KnowledgeEditor;diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.test.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.test.tsxdeleted file mode 100644index 7abec57e374..00000000000--- a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.test.tsx+++ /dev/null@@ -1,442 +0,0 @@-/**- * @vitest-environment happy-dom- */-import { act, render } from '@testing-library/react';-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';--import AgentHeader from './AgentHeader';--const mocks = vi.hoisted(() => {- return {- agentStoreState: {- activeAgentId: 'agent-a',- agentMap: {} as Record<- string,- {- agencyConfig?: { heterogeneousProvider?: { type: string } };- avatar?: string | null;- backgroundColor?: string;- name?: string;- slug?: string;- storedAvatar?: string | null;- title?: string;- }- >,- },- agentStoreListeners: new Set<() => void>(),- actionIconProps: { all: [] as Record<string, unknown>[] },- artworkProps: { last: undefined as Record<string, unknown> | undefined },- createAgentIdentityModal: vi.fn(),- refreshAgentConfig: vi.fn(),- emojiPickerProps: { last: undefined as Record<string, unknown> | undefined },- // In edit mode the header renders three inputs, in order: personal name,- // role, slug. `all` accumulates across renders, so read from the TAIL — the- // head holds a stale closure and a handler taken from it silently no-ops.- inputProps: {- all: [] as Record<string, unknown>[],- /** The headline input — the personal name. */- get name() {- return this.all.at(-3);- },- /** The second input — the role (`title`). */- get role() {- return this.all.at(-2);- },- /** The third input — the url slug. */- get slug() {- return this.all.at(-1);- },- },- permissionState: { allowed: false },- randomAgentName: vi.fn(() => 'Zoe'),- refreshAgentList: vi.fn(),- sidebarAgents: [] as { id: string; name?: string | null }[],- updateAgentMetaById: vi.fn(),- uploadWithProgress: vi.fn(),- };-});--vi.mock('@lobehub/ui', async (importOriginal) => ({- ...((await importOriginal()) as Record<string, unknown>),- ActionIcon: (props: Record<string, unknown>) => {- mocks.actionIconProps.all.push(props);- return (- <button type="button" onClick={props.onClick as () => void}>- {props.title as string}- </button>- );- },-}));--vi.mock('antd', async (importOriginal) => ({- ...(await importOriginal<object>()),- message: { error: vi.fn() },-}));--vi.mock('@/features/AgentProfileArtwork', () => ({- AgentProfileArtwork: (props: Record<string, unknown>) => {- mocks.artworkProps.last = props;- return <div>artwork</div>;- },-}));--vi.mock('@/hooks/usePermission', () => ({- usePermission: () => ({ allowed: mocks.permissionState.allowed, reason: 'requires member' }),-}));--vi.mock('@/store/agent', async () => {- const { useSyncExternalStore } = await import('react');-- return {- useAgentStore: (selector: (state: unknown) => unknown) =>- useSyncExternalStore(- (listener) => {- mocks.agentStoreListeners.add(listener);- return () => mocks.agentStoreListeners.delete(listener);- },- () =>- selector({- ...mocks.agentStoreState,- internal_refreshAgentConfig: mocks.refreshAgentConfig,- updateAgentMetaById: mocks.updateAgentMetaById,- }),- ),- };-});--vi.mock('@/store/agent/selectors', () => ({- agentSelectors: {- getAgentMetaById: (agentId: string) => (state: typeof mocks.agentStoreState) =>- state.agentMap[agentId] || {},- getAgentConfigById: (agentId: string) => (state: typeof mocks.agentStoreState) =>- state.agentMap[agentId] || {},- getAgentSlugById: (agentId: string) => (state: typeof mocks.agentStoreState) =>- state.agentMap[agentId]?.slug,- getAgentStoredAvatarById: (agentId: string) => (state: typeof mocks.agentStoreState) =>- state.agentMap[agentId]?.storedAvatar || undefined,- },-}));--vi.mock('@/features/AgentIdentityModal', () => ({- createAgentIdentityModal: (...args: unknown[]) => mocks.createAgentIdentityModal(...args),-}));--vi.mock('@lobechat/const', async (importOriginal) => ({- ...(await importOriginal<Record<string, unknown>>()),- randomAgentName: (...args: unknown[]) => mocks.randomAgentName(...(args as [])),-}));--vi.mock('@/store/home', () => {- const useHomeStore = (selector: (state: unknown) => unknown) =>- selector({ refreshAgentList: mocks.refreshAgentList });- useHomeStore.getState = () => ({ agents: mocks.sidebarAgents });- return { useHomeStore };-});--vi.mock('@/store/home/selectors', () => ({- homeAgentListSelectors: {- allAgents: (state: { agents: unknown[] }) => state.agents,- },-}));--vi.mock('@/store/file', () => ({- useFileStore: (selector: (state: unknown) => unknown) =>- selector({ uploadWithProgress: mocks.uploadWithProgress }),-}));--vi.mock('@/store/global', () => ({- useGlobalStore: (selector: (state: unknown) => unknown) => selector({ language: 'en-US' }),-}));--vi.mock('@/store/global/selectors', () => ({- globalGeneralSelectors: {- currentLanguage: (state: { language: string }) => state.language,- },-}));--describe('AgentHeader', () => {- beforeEach(() => {- vi.useFakeTimers();- vi.clearAllMocks();- mocks.agentStoreState.activeAgentId = 'agent-a';- mocks.agentStoreState.agentMap = {- 'agent-a': {- avatar: '🍷',- title: 'Readonly agent',- },- };- mocks.agentStoreListeners.clear();- mocks.emojiPickerProps.last = undefined;- mocks.inputProps.all = [];- mocks.actionIconProps.all = [];- mocks.artworkProps.last = undefined;- mocks.permissionState.allowed = false;- mocks.randomAgentName.mockReturnValue('Zoe');- mocks.sidebarAgents = [];- });-- afterEach(() => {- vi.useRealTimers();- });-- it('keeps the artwork editor read-only when edits are not allowed', () => {- render(<AgentHeader />);-- expect(mocks.artworkProps.last?.canEdit).toBe(false);- });-- it('keeps the display fallback out of the artwork character reference', () => {- mocks.agentStoreState.agentMap = {- 'agent-a': { avatar: '/avatars/agent-default.png', storedAvatar: null },- };-- render(<AgentHeader />);-- expect(mocks.artworkProps.last).toMatchObject({- avatar: '/avatars/agent-default.png',- storedAvatar: undefined,- });- });-- it('opens the identity form instead of editing inline', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { name: 'Alice', title: 'Health Assistant' } };- const view = render(<AgentHeader />);-- // The header is display-only: the three fields live in the modal.- expect(view.container.querySelectorAll('input')).toHaveLength(0);-- act(() => {- (mocks.actionIconProps.all.at(-1)?.onClick as () => void)?.();- });-- expect(mocks.createAgentIdentityModal).toHaveBeenCalledExactlyOnceWith('agent-a');- });-- it('shows the slug next to the role', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = {- 'agent-a': { name: 'Alice', slug: 'brave-otter-lamp', title: 'Health Assistant' },- };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('@brave-otter-lamp');- });-- it('shows the description other agents read', () => {- mocks.agentStoreState.agentMap = {- 'agent-a': {- description: 'Reviews pull requests and runs the test suite',- name: 'Alice',- title: 'Code Reviewer',- },- };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('Reviews pull requests and runs the test suite');- });-- // Regression: the headline used to fall back to the name field's PLACEHOLDER,- // so every unnamed agent read as though it were called "Give it a name, …".- it('never renders the input placeholder as a headline', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { slug: 'experiment-crop-then' } };- const view = render(<AgentHeader />);-- expect(view.container.textContent).not.toContain('settingAgent.personalName.placeholder');- });-- // The headline is the NAME slot. Borrowing the role printed it twice, since- // the role already has its own line right below.- it('does not borrow the role for the headline', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { slug: 'inbox', title: 'Lobe AI' } };- const view = render(<AgentHeader />);-- // Exactly once: on the role line, never as the headline.- expect(view.container.textContent?.match(/Lobe AI/g)).toHaveLength(1);- });-- it('shows an identical heterogeneous product name and role only once', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = {- 'agent-a': {- agencyConfig: { heterogeneousProvider: { type: 'grok-build' } },- name: 'Grok Build',- slug: 'why-hard-industry',- title: 'Grok Build',- },- };- const view = render(<AgentHeader />);-- expect(view.container.textContent?.match(/Grok Build/g)).toHaveLength(1);- expect(view.container.textContent).toContain('@why-hard-industry');- expect(view.container.textContent).not.toContain('settingAgent.personalName.unnamed');- expect(view.container.textContent).toContain('settingAgent.identity.edit');- });-- it('leaves an ordinary identical name and role in both slots', () => {- mocks.agentStoreState.agentMap = {- 'agent-a': { name: 'Grok Build', title: 'Grok Build' },- };- const view = render(<AgentHeader />);-- expect(view.container.textContent?.match(/Grok Build/g)).toHaveLength(2);- });-- it('suppresses the role included in an owner-qualified shared heterogeneous name', () => {- mocks.agentStoreState.agentMap = {- 'agent-a': {- agencyConfig: { heterogeneousProvider: { type: 'grok-build' } },- name: 'Max’s Grok Build',- slug: 'shared-builder',- title: 'Grok Build',- },- };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('Max’s Grok Build');- expect(view.container.textContent?.match(/Grok Build/g)).toHaveLength(1);- expect(view.container.textContent).toContain('@shared-builder');- expect(view.container.textContent).not.toContain('·');- });-- it('retains the role for a custom-named heterogeneous agent', () => {- mocks.agentStoreState.agentMap = {- 'agent-a': {- agencyConfig: { heterogeneousProvider: { type: 'grok-build' } },- name: 'Release Builder',- title: 'Grok Build',- },- };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('Release Builder');- expect(view.container.textContent).toContain('Grok Build');- });-- it('retains the unset role slot for a heterogeneous agent without a role', () => {- mocks.agentStoreState.agentMap = {- 'agent-a': {- agencyConfig: { heterogeneousProvider: { type: 'grok-build' } },- name: 'Release Builder',- slug: 'release-builder',- },- };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('settingAgent.role.unset');- expect(view.container.textContent).toContain('·');- expect(view.container.textContent).toContain('@release-builder');- });-- // With no name there is nothing to headline, so the slot carries the prompt- // that fixes it — not a placeholder dressed up as a name.- it('gives the headline slot to the naming prompt while unnamed', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { slug: 'inbox', title: 'Lobe AI' } };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('settingAgent.personalName.unnamed');- expect(view.container.textContent).not.toContain('settingAgent.identity.untitled');- // Naming it IS the next step; the identity form would split attention.- expect(view.container.textContent).not.toContain('settingAgent.identity.edit');- });-- // Read-only viewers get the plain label — an action they cannot take would be- // worse than a stated absence.- it('falls back to the unnamed label when edits are not allowed', () => {- mocks.agentStoreState.agentMap = { 'agent-a': { slug: 'inbox', title: 'Lobe AI' } };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('settingAgent.identity.untitled');- expect(view.container.textContent).not.toContain('settingAgent.personalName.pickForMe');- expect(view.container.textContent).not.toContain('settingAgent.identity.edit');- });-- it('restores the headline and the edit affordance once named', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { name: '思远', slug: 'inbox' } };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('思远');- expect(view.container.textContent).not.toContain('settingAgent.personalName.unnamed');- expect(view.container.textContent).toContain('settingAgent.identity.edit');- });-- it('states the role is unset instead of leaving a bare slug', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { name: '思远', slug: 'belong-pot-women' } };- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('settingAgent.role.unset');- expect(view.container.textContent).toContain('@belong-pot-women');- });-- it('offers one-click naming for an agent with no name', async () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { title: 'Health Assistant' } };- mocks.sidebarAgents = [- { id: 'agent-a', name: null },- { id: 'agent-b', name: 'Alice' },- { id: 'agent-c', name: 'Leo' },- { id: 'agent-d', name: null },- ];- const view = render(<AgentHeader />);-- expect(view.container.textContent).toContain('settingAgent.personalName.unnamed');- const button = [...view.container.querySelectorAll('button')].find((el) =>- el.textContent?.includes('settingAgent.personalName.pickForMe'),- );-- await act(async () => {- button?.click();- });-- // Names already on screen are excluded — a second "Alice" would defeat the- // point of having a name at all.- expect(mocks.randomAgentName).toHaveBeenCalledExactlyOnceWith('en-US', ['Alice', 'Leo']);- expect(mocks.updateAgentMetaById).toHaveBeenCalledExactlyOnceWith('agent-a', { name: 'Zoe' });- // Otherwise the sidebar keeps showing the unnamed label next to a now-named- // profile.- expect(mocks.refreshAgentList).toHaveBeenCalledOnce();- });-- it('does not offer naming for an agent that already has one', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = { 'agent-a': { name: 'Alice', title: 'Health Assistant' } };- const view = render(<AgentHeader />);-- expect(view.container.textContent).not.toContain('settingAgent.personalName.pickForMe');- });-- it('does not offer naming when edits are not allowed', () => {- mocks.agentStoreState.agentMap = { 'agent-a': { title: 'Health Assistant' } };- const view = render(<AgentHeader />);-- expect(view.container.textContent).not.toContain('settingAgent.personalName.pickForMe');- });-- it('keeps an artwork update bound to the agent that started it', () => {- mocks.permissionState.allowed = true;- mocks.agentStoreState.agentMap = {- 'agent-a': { title: 'Agent A' },- 'agent-b': { title: 'Agent B' },- };- render(<AgentHeader />);- const onAvatarChange = mocks.artworkProps.last?.onAvatarChange as (avatar: string) => void;-- act(() => {- mocks.agentStoreState.activeAgentId = 'agent-b';- mocks.agentStoreListeners.forEach((listener) => listener());- });-- act(() => {- onAvatarChange('https://example.com/agent-a.png');- });-- expect(mocks.updateAgentMetaById).toHaveBeenCalledExactlyOnceWith('agent-a', {- avatar: 'https://example.com/agent-a.png',- });- });-});diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.tsxdeleted file mode 100644index 656fe129346..00000000000--- a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.tsx+++ /dev/null@@ -1,162 +0,0 @@-'use client';--import { agentSecondaryDisplayName } from '@lobechat/types';-import { ActionIcon, Button, cssVar, Flexbox, Text, Tooltip } from '@lobehub/ui';-import isEqual from 'fast-deep-equal';-import { PencilIcon, SparklesIcon } from 'lucide-react';-import { memo } from 'react';-import { useTranslation } from 'react-i18next';--import { createAgentIdentityModal } from '@/features/AgentIdentityModal';-import { AgentProfileArtwork } from '@/features/AgentProfileArtwork';-import { usePermission } from '@/hooks/usePermission';-import { useAgentStore } from '@/store/agent';-import { agentSelectors } from '@/store/agent/selectors';-import { useGlobalStore } from '@/store/global';-import { globalGeneralSelectors } from '@/store/global/selectors';--import { useAutoName } from './useAutoName';--const AgentHeader = memo(() => {- const { t } = useTranslation(['setting', 'common']);- const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);- const { allowed: canEdit } = usePermission('edit_own_content');-- const agentId = useAgentStore((s) => s.activeAgentId || '');- const meta = useAgentStore(agentSelectors.getAgentMetaById(agentId), isEqual);- const config = useAgentStore(agentSelectors.getAgentConfigById(agentId), isEqual);- const slug = useAgentStore(agentSelectors.getAgentSlugById(agentId));- /** Keeps the render-only fallback avatar out of generation references. */- const storedAvatar = useAgentStore(agentSelectors.getAgentStoredAvatarById(agentId));- const updateMetaById = useAgentStore((s) => s.updateAgentMetaById);- const { autoName, naming } = useAutoName(agentId);- const personalName = meta.name?.trim();- const role = meta.title?.trim();- const description = meta.description?.trim();- const suppressDuplicateRole =- !!config?.agencyConfig?.heterogeneousProvider &&- !!personalName &&- !!role &&- agentSecondaryDisplayName({ name: personalName, title: role }) === undefined;- // Without edit rights there is nothing to prompt for, so a nameless agent- // falls back to the plain label rather than showing an action nobody can take.- const showNamePrompt = !personalName && canEdit;-- return (- <Flexbox- gap={16}- paddingBlock={'0 16px'}- style={{- cursor: 'default',- marginInline: -16,- width: 'calc(100% + 32px)',- }}- onClick={(e) => {- e.stopPropagation();- e.preventDefault();- }}- >- <AgentProfileArtwork- agentId={agentId}- avatar={meta.avatar}- background={meta.backgroundColor}- canEdit={canEdit}- description={meta.description}- locale={locale}- name={meta.name}- storedAvatar={storedAvatar}- systemRole={config?.systemRole}- title={meta.title}- onAvatarChange={(avatar) => {- if (canEdit) void updateMetaById(agentId, { avatar });- }}- onBackgroundChange={(backgroundColor) => {- if (canEdit) void updateMetaById(agentId, { backgroundColor });- }}- />- {/* Identity Section — display only. Editing the identity fields happens in a- form modal; inline inputs crowded the header and left no room for a- per-field label or error. */}- <Flexbox flex={1} gap={8} paddingInline={24} style={{ minWidth: 0 }}>- {/* The headline is the NAME slot. With no name there is nothing to- headline, so it carries the action that can fix this instead of a- placeholder pretending to be a name. The edit affordance stays hidden- until then: naming it IS the- next step, and offering the full identity form alongside would split- attention between two ways to do the same thing. */}- {showNamePrompt ? (- <Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>- <Text ellipsis style={{ color: cssVar.colorTextTertiary, fontSize: 20 }}>- {t('settingAgent.personalName.unnamed', { ns: 'setting' })}- </Text>- <Button- icon={SparklesIcon}- loading={naming}- size={'small'}- type={'text'}- onClick={() => {- void autoName();- }}- >- {t('settingAgent.personalName.pickForMe', { ns: 'setting' })}- </Button>- </Flexbox>- ) : (- <Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>- <Text ellipsis style={{ fontSize: 36, fontWeight: 600 }}>- {personalName || t('settingAgent.identity.untitled', { ns: 'setting' })}- </Text>- {canEdit ? (- <ActionIcon- icon={PencilIcon}- size={'small'}- title={t('settingAgent.identity.edit', { ns: 'setting' })}- onClick={() => createAgentIdentityModal(agentId)}- />- ) : null}- </Flexbox>- )}- <Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}>- {/* `Text type="secondary"` resolves to `colorTextDescription`, which antd- maps to the TERTIARY step — too faint for the line that carries the- agent's role. Set the secondary colour explicitly, and leave only- the decorative `@` and the separator at tertiary. */}- {/* A heterogeneous product name that already includes its role is- shown once. Genuinely custom names retain the role underneath. */}- {!suppressDuplicateRole ? (- <Text- ellipsis- style={{- color: role ? cssVar.colorTextSecondary : cssVar.colorTextTertiary,- }}- >- {role || t('settingAgent.role.unset', { ns: 'setting' })}- </Text>- ) : null}- {slug && !suppressDuplicateRole ? (- <Text style={{ color: cssVar.colorTextTertiary }}>·</Text>- ) : null}- {/* The tooltip only renders when a slug exists, so it can always name- the real url rather than a `<slug>` the reader has to substitute. */}- {slug ? (- <Tooltip title={t('settingAgent.slug.openWith', { ns: 'setting', slug })}>- <Text code style={{ color: cssVar.colorTextSecondary, flex: 'none' }}>- <span style={{ color: cssVar.colorTextTertiary }}>@</span>- {slug}- </Text>- </Tooltip>- ) : null}- </Flexbox>- {/* Edited in the identity form; shown here so the owner sees what other- agents read about this one. */}- {description ? (- <Text ellipsis={{ rows: 2 }} style={{ color: cssVar.colorTextSecondary }}>- {description}- </Text>- ) : null}- </Flexbox>- </Flexbox>- );-});--export default AgentHeader;diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsxindex af4ec05692f..0026633371d 100644--- a/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx+++ b/src/routes/(main)/agent/profile/features/ProfileEditor/index.tsx@@ -1,399 +1,106 @@'use client';-import { isDesktop } from '@lobechat/const';-import {- HETEROGENEOUS_TYPE_LABELS,- isHeterogeneousProviderBindingSupported,- isRemoteHeterogeneousType,- isServerDefaultHeterogeneousAgentType,-} from '@lobechat/heterogeneous-agents';-import type { HeterogeneousApiConfig, HeterogeneousAuthMode } from '@lobechat/types';-import { Alert, Button, createStaticStyles, cssVar, Flexbox } from '@lobehub/ui';+import { Button, Flexbox, toast } from '@lobehub/ui';import isEqual from 'fast-deep-equal';-import { ChevronDown, Fingerprint, MonitorSmartphone, Wrench } from 'lucide-react';-import React, { memo } from 'react';+import { memo } from 'react';import { useTranslation } from 'react-i18next';-import { AGENT_SHARE_ALLOWED_PROVIDERS } from '@/business/agent-share';-import { useAgentShareSupported } from '@/business/client/useAgentShareSupported';-import { ModelIcon } from '@/components/LobeIcons';-import { ClaudeCodeEntrypointSetting } from '@/features/HeterogeneousAgent/ClaudeCodeEntrypointSetting';-import { ApiAuthLocalOnlyNotice } from '@/features/HeterogeneousAgent/ExecutionEnvironment/ApiAuthLocalOnlyNotice';-import { DeviceCliStatusCard } from '@/features/HeterogeneousAgent/ExecutionEnvironment/DeviceCliStatusCard';-import { HeteroExecutionTargetSelect } from '@/features/HeterogeneousAgent/ExecutionEnvironment/HeteroExecutionTargetSelect';-import { useProfileExecutionTarget } from '@/features/HeterogeneousAgent/ExecutionEnvironment/useProfileExecutionTarget';-import { resolveServerDefaultAgentModels } from '@/features/HeterogeneousAgent/modelPicker';-import ReasoningEffortSelect from '@/features/ModelSelect/ReasoningEffortSelect';-import ModelSwitchPanel from '@/features/ModelSwitchPanel';-import RunPriorityHint from '@/features/ProfileEditor/AgentUserTools/RunPriorityHint';-import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';+import IdentityFields from '@/features/AgentIdentityModal/IdentityFields';+import { useAgentIdentityForm } from '@/features/AgentIdentityModal/useAgentIdentityForm';+import { AgentProfileArtwork } from '@/features/AgentProfileArtwork';import { usePermission } from '@/hooks/usePermission';import { useAgentStore } from '@/store/agent';-import { agentByIdSelectors, agentSelectors } from '@/store/agent/selectors';-import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';+import { agentSelectors } from '@/store/agent/selectors';+import { useGlobalStore } from '@/store/global';+import { globalGeneralSelectors } from '@/store/global/selectors';++/** The identity fields on the page, saved together with one button. */+const IdentityForm = memo<{ agentId: string }>(({ agentId }) => {+ const { t } = useTranslation(['common', 'setting']);+ const meta = useAgentStore(agentSelectors.getAgentMetaById(agentId), isEqual);+ const slug = useAgentStore(agentSelectors.getAgentSlugById(agentId));+ const form = useAgentIdentityForm({+ agentId,+ onSaved: () => toast.success(t('settingAgent.identity.saved', { ns: 'setting' })),+ });++ const dirty =+ form.name.trim() !== (meta.name ?? '').trim() ||+ form.title.trim() !== (meta.title ?? '').trim() ||+ form.description.trim() !== (meta.description ?? '').trim() ||+ (!form.slugLocked && form.slug.trim().toLowerCase() !== (slug ?? ''));-import EditorCanvas from '../EditorCanvas';-import AgentHeader from './AgentHeader';-import AgentTool from './AgentTool';-import CloudHeterogeneousConfig from './CloudHeterogeneousConfig';-import HeterogeneousAgentStatusCard from './HeterogeneousAgentStatusCard';-import RemoteAgentConfigCard from './RemoteAgentConfigCard';-import WorkspaceAgentDevicePolicy from './WorkspaceAgentDevicePolicy';-import { WorkspaceAgentModelPolicy } from './WorkspaceAgentModelPolicy';-import { WorkspaceAgentPolicyCard } from './WorkspaceAgentPolicyCard';+ return (+ <Flexbox gap={20}>+ <IdentityFields agentId={agentId} autoFocus={false} form={form} />+ <Flexbox horizontal gap={8}>+ <Button+ disabled={!dirty || form.saving}+ loading={form.saving}+ type={'primary'}+ onClick={() => {+ void form.save();+ }}+ >+ {t('save', { ns: 'common' })}+ </Button>+ </Flexbox>+ </Flexbox>+ );+});-const styles = createStaticStyles(({ css }) => ({- configLabel: css`- font-size: 12px;- line-height: 1;- color: ${cssVar.colorTextTertiary};- `,- configStack: css`- container-type: inline-size;- `,- configPanel: css`- padding: 24px;- border: 1px solid ${cssVar.colorBorderSecondary};- border-radius: ${cssVar.borderRadiusLG};- background: ${cssVar.colorFillQuaternary};- `,- topArea: css`- cursor: default;- margin-block-end: 28px;- `,-}));+IdentityForm.displayName = 'IdentityForm';+/**+ * The Profile page: the agent's face — avatar and cover — and who it is, as the identity form+ * right on the page. The instruction, what runs it and what it can use each have their own page.+ */const ProfileEditor = memo(() => {- const { t } = useTranslation(['setting', 'agent']);+ const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);const { allowed: canEdit } = usePermission('edit_own_content');const agentId = useAgentStore((s) => s.activeAgentId || '');+ const meta = useAgentStore(agentSelectors.getAgentMetaById(agentId), isEqual);const config = useAgentStore(agentSelectors.getAgentConfigById(agentId), isEqual);- const { isShared } = useAgentShareSupported(agentId);- const chatModels = useEnabledChatModels();- const enabledList =- isShared && AGENT_SHARE_ALLOWED_PROVIDERS- ? chatModels.filter((provider) => AGENT_SHARE_ALLOWED_PROVIDERS?.includes(provider.id))- : undefined;- const selectedModel = useAiInfraStore(- aiModelSelectors.getEnabledModelById(config?.model ?? '', config?.provider ?? ''),- );- const isWorkspaceAgent = useAgentStore(agentByIdSelectors.isWorkspaceAgentById(agentId));- const updateAgentConfigById = useAgentStore((s) => s.updateAgentConfigById);- const isHeterogeneous = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);- const heterogeneousProvider = config?.agencyConfig?.heterogeneousProvider;- // Where this caller's new topics run. The environment picker and the panel- // below both follow it, so the panel never describes this client by default.- const executionTarget = useProfileExecutionTarget(agentId);-- const updateHeterogeneousCommand = async (command: string) => {- if (!canEdit) return;- if (!heterogeneousProvider) return;- await updateAgentConfigById(agentId, {- agencyConfig: {- heterogeneousProvider: { ...heterogeneousProvider, command },- },- });- };-- const updateHeterogeneousEnv = async (env: Record<string, string>) => {- if (!canEdit) return;- if (!heterogeneousProvider) return;- await updateAgentConfigById(agentId, {- agencyConfig: {- heterogeneousProvider: { ...heterogeneousProvider, env },- },- });- };-- const updateHeterogeneousAuthMode = async (- authMode: HeterogeneousAuthMode,- apiConfig?: HeterogeneousApiConfig,- ) => {- if (!canEdit || !heterogeneousProvider) return;- await updateAgentConfigById(agentId, {- agencyConfig: {- heterogeneousProvider: { ...heterogeneousProvider, apiConfig, authMode },- },- });- };-- const updateHeterogeneousApiConfig = async (apiConfig: HeterogeneousApiConfig | undefined) => {- if (!canEdit || !heterogeneousProvider) return;- await updateAgentConfigById(agentId, {- agencyConfig: {- heterogeneousProvider: { ...heterogeneousProvider, apiConfig },- },- });- };-- const updateBoundDeviceId = async (boundDeviceId: string) => {- await updateAgentConfigById(agentId, {- agencyConfig: { ...config?.agencyConfig, boundDeviceId, executionTarget: 'device' },- });- };-- const isRemoteHetero =- isHeterogeneous &&- !!heterogeneousProvider &&- isRemoteHeterogeneousType(heterogeneousProvider.type);- const localDesktopAvailable =- isDesktop && !!heterogeneousProvider && executionTarget.target === 'local';- // Workspace agents are excluded even when the author could spawn them- // locally: the binding UI would list workspace-scoped providers, but Desktop- // main resolves the reference in the personal scope only (see- // `selectRuntimeType`'s personal-scope guard). The deployment-default API- // source is not a user-provider binding, so it stays available whenever- // local Desktop execution is available.- const apiModeAvailable =- localDesktopAvailable &&- !isWorkspaceAgent &&- isHeterogeneousProviderBindingSupported(heterogeneousProvider.type);- const useFetchServerDefaultCapability = useAgentStore(- (s) => s.useFetchServerDefaultHeterogeneousCapability,- );- // The shared matrix owns which native drivers can reach the deployment relay;- // model/runtime compatibility continues to come from the server capability below.- const serverDefaultAgentType =- heterogeneousProvider && isServerDefaultHeterogeneousAgentType(heterogeneousProvider.type)- ? heterogeneousProvider.type- : undefined;- const serverCapabilityEnabled = localDesktopAvailable && !!serverDefaultAgentType;- const serverCapabilitySync = useFetchServerDefaultCapability(serverCapabilityEnabled);- // The last confirmed capability paints at once; the sync only confirms it, and- // a failed background refresh keeps it instead of turning into an error.- const serverCapability = useAgentStore(agentSelectors.heteroServerDefaultCapability);- const serverCapabilityError = !serverCapability && serverCapabilitySync.error;- const serverCapabilityLoading =- serverCapabilityEnabled && !serverCapability && !serverCapabilitySync.error;- const serverDefaultModels =- serverCapability?.enabled === true && serverDefaultAgentType- ? resolveServerDefaultAgentModels(serverCapability.models, serverDefaultAgentType)- : [];- const serverDefaultAvailable = serverCapabilityEnabled && serverDefaultModels.length > 0;- const serverDefaultUnavailableReason = !localDesktopAvailable- ? t('heterogeneousStatus.apiMode.localOnly')- : serverCapabilityError- ? t('heterogeneousStatus.apiMode.serverDefault.loadFailed')- : serverCapability?.enabled === false- ? t(- serverCapability.reason === 'disabled'- ? 'heterogeneousStatus.apiMode.serverDefault.disabled'- : 'heterogeneousStatus.apiMode.serverDefault.invalidConfiguration',- )- : serverCapabilityEnabled && !serverCapabilityLoading && !serverDefaultAvailable- ? t('heterogeneousStatus.apiMode.serverDefault.unsupported')- : undefined;- const renderHeterogeneousPanelBody = () => {- if (!heterogeneousProvider) return null;-- const { panel } = executionTarget;-- switch (panel.kind) {- case 'cloud': {- return (- <CloudHeterogeneousConfig- provider={heterogeneousProvider}- onEnvChange={updateHeterogeneousEnv}- />- );- }- case 'device': {- return <DeviceCliStatusCard deviceId={panel.deviceId} provider={heterogeneousProvider} />;- }- case 'local':- case 'runtime': {- return (- <HeterogeneousAgentStatusCard- apiModeAvailable={apiModeAvailable}- apiModeWorkspaceBlocked={isWorkspaceAgent}- provider={heterogeneousProvider}- serverDefaultAvailable={serverDefaultAvailable}- serverDefaultLoading={serverCapabilityLoading}- serverDefaultModels={serverDefaultModels}- serverDefaultUnavailableReason={serverDefaultUnavailableReason}- onApiConfigChange={updateHeterogeneousApiConfig}- onAuthModeChange={updateHeterogeneousAuthMode}- onCommandChange={updateHeterogeneousCommand}- onServerDefaultRetry={() => {- void serverCapabilitySync.revalidate();- }}- />- );- }- case 'sandbox': {- return (- <Alert- showIcon- type={'info'}- title={t('heterogeneousStatus.sandbox.desc', {- name: HETEROGENEOUS_TYPE_LABELS[heterogeneousProvider.type],- })}- />- );- }- case 'pending': {- return null;- }- }- };-- const renderHeterogeneousPanel = () => {- // Until the member's own override loads, the target may still flip.- if (!heterogeneousProvider || executionTarget.isPending) return null;-- return (- <>- {/* Dispatch rejects API auth off this desktop, and only the local card- edits auth — so every other environment offers the way back. */}- {executionTarget.isApiAuthBlocked && (- <ApiAuthLocalOnlyNotice- onUseSubscription={- canEdit- ? () =>- void updateHeterogeneousAuthMode(- 'subscription',- heterogeneousProvider.apiConfig,- )- : undefined- }- />- )}- {renderHeterogeneousPanelBody()}- </>- );- };+ /** Keeps the render-only fallback avatar out of generation references. */+ const storedAvatar = useAgentStore(agentSelectors.getAgentStoredAvatarById(agentId));+ const updateMetaById = useAgentStore((s) => s.updateAgentMetaById);return (- <>- <Flexbox- className={styles.topArea}- onClick={(e) => {- e.stopPropagation();- }}- >- {/* Header: Avatar + Name + Description */}- <AgentHeader />- <Flexbox- className={styles.configStack}- gap={8}- paddingBlock={isRemoteHetero ? '8px 0' : undefined}- >- {isRemoteHetero && heterogeneousProvider ? (- // Remote platform agents (openclaw / hermes): show device config panel- <RemoteAgentConfigCard- provider={heterogeneousProvider}- onBoundDeviceChange={updateBoundDeviceId}- />- ) : isHeterogeneous && heterogeneousProvider ? (- // CLI agents: pick where new topics run, then configure that environment.- <>- <WorkspaceAgentPolicyCard- fullWidth- icon={MonitorSmartphone}- title={t('settingAgent.devicePolicy.title')}- >- <HeteroExecutionTargetSelect- agentId={agentId}- deviceId={executionTarget.deviceId}- isOverridden={executionTarget.isOverridden}- isPending={executionTarget.isPending}- isSelectable={executionTarget.isSelectable}- providerType={heterogeneousProvider.type}- target={executionTarget.target}- />- </WorkspaceAgentPolicyCard>- {renderHeterogeneousPanel()}- {/* Follows the engine and its sign-in, not where the run lands. */}- {heterogeneousProvider.type === 'claude-code' &&- (heterogeneousProvider.authMode ?? 'subscription') === 'subscription' && (- <WorkspaceAgentPolicyCard- fullWidth- icon={Fingerprint}- title={t('heterogeneousStatus.entrypoint.label')}- >- <ClaudeCodeEntrypointSetting- disabled={!canEdit}- env={heterogeneousProvider.env}- onEnvChange={updateHeterogeneousEnv}- />- </WorkspaceAgentPolicyCard>- )}- </>- ) : isWorkspaceAgent ? (- <>- <Flexbox horizontal gap={8} wrap={'wrap'}>- <WorkspaceAgentModelPolicy agentId={agentId} />- <WorkspaceAgentDevicePolicy agentId={agentId} />- </Flexbox>- <WorkspaceAgentPolicyCard- fullWidth- action={<RunPriorityHint agentId={agentId} />}- icon={Wrench}- title={t('settingAgent.toolsConfig.title')}- >- <AgentTool />- </WorkspaceAgentPolicyCard>- </>- ) : (- <Flexbox className={styles.configPanel} gap={10}>- <Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>- <div className={styles.configLabel}>{t('settingAgent.runtimeConfig.title')}</div>- <RunPriorityHint agentId={agentId} />- </Flexbox>- <Flexbox horizontal align={'center'} gap={12} justify={'flex-start'} wrap={'wrap'}>- <ModelSwitchPanel- enabledList={enabledList}- model={config?.model}- open={canEdit ? undefined : false}- openOnHover={false}- placement={'bottomLeft'}- provider={config?.provider}- notice={- enabledList && (- <Alert- showIcon- title={t('share.settings.modelRestriction.title', { ns: 'agent' })}- type={'info'}- description={t('share.settings.modelRestriction.description', {- ns: 'agent',- })}- />- )- }- onModelChange={async (value) => {- if (canEdit) await updateAgentConfigById(agentId, value);- }}- >- <Button disabled={!canEdit}>- <ModelIcon model={config?.model} size={20} />- {selectedModel?.displayName || config?.model}- <ChevronDown size={14} />- </Button>- </ModelSwitchPanel>- {config?.model && config.provider && (- <ReasoningEffortSelect- disabled={!canEdit}- model={config.model}- provider={config.provider}- />- )}- </Flexbox>- <AgentTool />- </Flexbox>- )}- {isRemoteHetero ? (- <WorkspaceAgentDevicePolicy agentId={agentId} showDevicePicker={false} />- ) : null}- </Flexbox>+ <Flexbox+ gap={32}+ paddingBlock={'0 48px'}+ // Clicking here must not pull focus into the prompt editor of the shared session.+ style={{ cursor: 'default' }}+ onClick={(e) => {+ e.stopPropagation();+ }}+ >+ <Flexbox style={{ marginInline: -16, width: 'calc(100% + 32px)' }}>+ <AgentProfileArtwork+ agentId={agentId}+ avatar={meta.avatar}+ background={meta.backgroundColor}+ canEdit={canEdit}+ description={meta.description}+ locale={locale}+ name={meta.name}+ storedAvatar={storedAvatar}+ systemRole={config?.systemRole}+ title={meta.title}+ onAvatarChange={(avatar) => {+ if (canEdit) void updateMetaById(agentId, { avatar });+ }}+ onBackgroundChange={(backgroundColor) => {+ if (canEdit) void updateMetaById(agentId, { backgroundColor });+ }}+ /></Flexbox>- {/* Main Content: Prompt Editor — built-in model runtime only. Hetero agents- (Claude Code / Codex + remote platforms) run an external CLI with its own- system prompt, so the agent's systemRole never reaches them. Hide the- editor here to avoid a control that looks effective but isn't (mirrors the- ModelSelect hiding above). */}- {!isHeterogeneous && <EditorCanvas />}- </>+ {/* Keyed by agent so switching agents starts the form from that agent's values. */}+ <IdentityForm agentId={agentId} key={agentId} />+ </Flexbox>);});+ProfileEditor.displayName = 'ProfileEditor';+export default ProfileEditor;diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/useAutoName.ts b/src/routes/(main)/agent/profile/features/ProfileEditor/useAutoName.tsdeleted file mode 100644index 981fb3233ae..00000000000--- a/src/routes/(main)/agent/profile/features/ProfileEditor/useAutoName.ts+++ /dev/null@@ -1,54 +0,0 @@-import { randomAgentName } from '@lobechat/const';-import { toast } from '@lobehub/ui';-import { useCallback, useState } from 'react';-import { useTranslation } from 'react-i18next';--import { useAgentStore } from '@/store/agent';-import { useGlobalStore } from '@/store/global';-import { globalGeneralSelectors } from '@/store/global/selectors';-import { useHomeStore } from '@/store/home';-import { homeAgentListSelectors } from '@/store/home/selectors';--/**- * One-click naming for an agent that never got a personal name — agents created- * before names existed, or through a path that doesn't seed one (REST, group- * members). Draws from the same pool a fresh agent is seeded from, in the user's- * language.- *- * Names already visible in the sidebar are excluded: the point of a name is to- * tell two agents apart, so handing out a second "Alice" would defeat it. The- * list is read at click time rather than subscribed to — it only matters at the- * moment of the draw, and subscribing would re-render the header on every- * sidebar change.- */-export const useAutoName = (agentId: string) => {- const { t } = useTranslation('setting');- const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);- const updateMetaById = useAgentStore((s) => s.updateAgentMetaById);- const refreshAgentList = useHomeStore((s) => s.refreshAgentList);- const [naming, setNaming] = useState(false);-- const autoName = useCallback(async () => {- setNaming(true);- try {- const takenNames = homeAgentListSelectors- .allAgents(useHomeStore.getState())- .filter((agent) => agent.id !== agentId)- .map((agent) => agent.name)- .filter((name): name is string => !!name);-- await updateMetaById(agentId, { name: randomAgentName(locale, takenNames) });- // The sidebar keeps its own copy of the label, so a rename that skips this- // leaves the new name on the profile and the old one in the list until- // something else revalidates. Refreshing here follows the same convention- // as the sidebar's own rename popover.- await refreshAgentList();- } catch {- toast.error(t('settingAgent.personalName.pickFailed'));- } finally {- setNaming(false);- }- }, [agentId, locale, refreshAgentList, t, updateMetaById]);-- return { autoName, naming };-};diff --git a/src/routes/(main)/agent/profile/features/SkillsEditor/index.tsx b/src/routes/(main)/agent/profile/features/SkillsEditor/index.tsxnew file mode 100644index 00000000000..8b61ee58a07--- /dev/null+++ b/src/routes/(main)/agent/profile/features/SkillsEditor/index.tsx@@ -0,0 +1,43 @@+'use client';++import { Flexbox, Text } from '@lobehub/ui';+import { memo, useEffect } from 'react';+import { useTranslation } from 'react-i18next';++import AgentUserTools from '@/features/ProfileEditor/AgentUserTools';+import { useItemDetailStore } from '@/features/ProfileEditor/itemDetailStore';++/**+ * The Skills page: the skills turned on for the agent, as one plain list. A row opens the+ * skill's details in the page's right-hand panel.+ */+const SkillsEditor = memo(() => {+ const { t } = useTranslation('setting');+ const open = useItemDetailStore((s) => s.open);++ // Leaving the page takes its panel with it.+ useEffect(() => useItemDetailStore.getState().close, []);++ return (+ <Flexbox gap={24} paddingBlock={'8px 48px'}>+ <Flexbox gap={4}>+ <Text fontSize={24} weight={600}>+ {t('settingAgent.skillsPage.title')}+ </Text>+ <Text type={'secondary'}>{t('settingAgent.skillsPage.desc')}</Text>+ </Flexbox>++ <AgentUserTools+ filterAvailableInWeb+ useAllMetaList+ kind={'skills'}+ variant={'list'}+ onOpenDetail={open}+ />+ </Flexbox>+ );+});++SkillsEditor.displayName = 'SkillsEditor';++export default SkillsEditor;diff --git a/src/routes/(main)/agent/profile/features/ToolsEditor/index.tsx b/src/routes/(main)/agent/profile/features/ToolsEditor/index.tsxnew file mode 100644index 00000000000..10abc93fb4d--- /dev/null+++ b/src/routes/(main)/agent/profile/features/ToolsEditor/index.tsx@@ -0,0 +1,44 @@+'use client';++import { Flexbox, Text } from '@lobehub/ui';+import { memo, useEffect } from 'react';+import { useTranslation } from 'react-i18next';++import AgentUserTools from '@/features/ProfileEditor/AgentUserTools';+import { useItemDetailStore } from '@/features/ProfileEditor/itemDetailStore';++/**+ * The Tools page: the tools and connectors the agent can act with, as two lists — the ones that+ * belong to this agent alone, and the ones it borrows from the library every agent shares. A row+ * opens its details in the page's right-hand panel.+ */+const ToolsEditor = memo(() => {+ const { t } = useTranslation('setting');+ const open = useItemDetailStore((s) => s.open);++ // Leaving the page takes its panel with it.+ useEffect(() => useItemDetailStore.getState().close, []);++ return (+ <Flexbox gap={32} paddingBlock={'8px 48px'}>+ <Flexbox gap={4}>+ <Text fontSize={24} weight={600}>+ {t('settingAgent.toolsPage.title')}+ </Text>+ <Text type={'secondary'}>{t('settingAgent.toolsPage.desc')}</Text>+ </Flexbox>++ <AgentUserTools+ filterAvailableInWeb+ useAllMetaList+ kind={'tools'}+ variant={'list'}+ onOpenDetail={open}+ />+ </Flexbox>+ );+});++ToolsEditor.displayName = 'ToolsEditor';++export default ToolsEditor;diff --git a/src/routes/(main)/agent/profile/index.tsx b/src/routes/(main)/agent/profile/index.tsxindex 52113427676..e1796094d8d 100644--- a/src/routes/(main)/agent/profile/index.tsx+++ b/src/routes/(main)/agent/profile/index.tsx@@ -1,14 +1,14 @@'use client';import { Flexbox } from '@lobehub/ui';-import { type FC } from 'react';-import { memo, Suspense } from 'react';+import { type FC, lazy, memo, Suspense } from 'react';import { useParams } from 'react-router';import AsyncBoundary from '@/components/AsyncBoundary';import { delayed } from '@/components/Skeleton/Delayed';import ProfileSkeleton from '@/components/Skeleton/Profile';import AgentBuilder from '@/features/AgentBuilder';+import ItemDetailDock from '@/features/ProfileEditor/ItemDetailPanel';import ResourceConfigAccessGate from '@/features/ResourcePermission/ResourceConfigAccessGate';import WideScreenContainer from '@/features/WideScreenContainer';import { usePermission } from '@/hooks/usePermission';@@ -18,7 +18,6 @@ import { StyleSheet } from '@/utils/styles';import EditLockDriver from './features/EditLockDriver';import Header from './features/Header';-import ProfileEditor from './features/ProfileEditor';import ProfileHydration from './features/ProfileHydration';import ProfileProvider from './features/ProfileProvider';import { selectors as profileSelectors, useProfileStore } from './features/store';@@ -43,7 +42,31 @@ const styles = StyleSheet.create({},});-const ProfileArea = memo(() => {+// One editor per route: the shell stays small and each page loads only its own editor.+const EngineEditor = lazy(() => import('./features/EngineEditor'));+const EnvironmentEditor = lazy(() => import('./features/EnvironmentEditor'));+const InstructionEditor = lazy(() => import('./features/InstructionEditor'));+const KnowledgeEditor = lazy(() => import('./features/KnowledgeEditor'));+const ProfileEditor = lazy(() => import('./features/ProfileEditor'));+const SkillsEditor = lazy(() => import('./features/SkillsEditor'));+const ToolsEditor = lazy(() => import('./features/ToolsEditor'));++/** Which page of the profile group the shell renders. They share one editing session. */+export type AgentProfileViewKey =+ 'engine' | 'environment' | 'instruction' | 'knowledge' | 'profile' | 'skills' | 'tools';++const VIEWS: Record<AgentProfileViewKey, FC> = {+ engine: EngineEditor,+ environment: EnvironmentEditor,+ instruction: InstructionEditor,+ knowledge: KnowledgeEditor,+ profile: ProfileEditor,+ skills: SkillsEditor,+ tools: ToolsEditor,+};++const ProfileArea = memo<{ view: AgentProfileViewKey }>(({ view }) => {+ const View = VIEWS[view];const editor = useProfileStore((s) => s.editor);const isAgentConfigLoading = useAgentStore(agentSelectors.isAgentConfigLoading);// `isAgentConfigLoading` is data-presence ("no config in the map yet"), so a@@ -73,7 +96,7 @@ const ProfileArea = memo(() => {loading={<ProfileSkeleton />}onRetry={() => retryAgentConfigFetch()}>- <Header />+ <Header active={view} /><Flexboxhorizontalheight={'100%'}@@ -82,7 +105,9 @@ const ProfileArea = memo(() => {onClick={handleContentClick}><WideScreenContainer>- <ProfileEditor />+ <Suspense fallback={<ProfileSkeleton />}>+ <View />+ </Suspense></WideScreenContainer></Flexbox></AsyncBoundary>@@ -107,7 +132,12 @@ const AgentBuilderSlot = memo(() => {return <AgentBuilder />;});-const AgentProfile: FC = () => {+/**+ * Profile, Instruction, Knowledge, Engine, Environment, Tools and Skills are separate routes but one editing session: the same+ * lock, hydration, store and Agent Builder serve all three, so a prompt edited on+ * Context is the prompt the Builder sees from Profile.+ */+export const AgentProfileView = ({ view }: { view: AgentProfileViewKey }) => {const { aid } = useParams<{ aid: string }>();return (@@ -120,7 +150,8 @@ const AgentProfile: FC = () => {><ProfileProvider><Flexbox horizontal height={'100%'} width={'100%'}>- <ProfileArea />+ <ProfileArea view={view} />+ <ItemDetailDock /><AgentBuilderSlot /></Flexbox></ProfileProvider>@@ -129,4 +160,6 @@ const AgentProfile: FC = () => {);};+const AgentProfile: FC = () => <AgentProfileView view="profile" />;+export default AgentProfile;diff --git a/src/routes/(main)/agent/skills/index.tsx b/src/routes/(main)/agent/skills/index.tsxnew file mode 100644index 00000000000..f8c5a2d9e4a--- /dev/null+++ b/src/routes/(main)/agent/skills/index.tsx@@ -0,0 +1,8 @@+'use client';++import { AgentProfileView } from '../profile';++/** `/agent/:aid/skills` — the skills the agent can load. */+const AgentSkillsPage = () => <AgentProfileView view="skills" />;++export default AgentSkillsPage;diff --git a/src/routes/(main)/agent/tools/index.tsx b/src/routes/(main)/agent/tools/index.tsxnew file mode 100644index 00000000000..facb88a45c9--- /dev/null+++ b/src/routes/(main)/agent/tools/index.tsx@@ -0,0 +1,8 @@+'use client';++import { AgentProfileView } from '../profile';++/** `/agent/:aid/tools` — the tools and connectors the agent can use. */+const AgentToolsPage = () => <AgentProfileView view="tools" />;++export default AgentToolsPage;diff --git a/src/spa/router/agentPageRoutes.tsx b/src/spa/router/agentPageRoutes.tsxindex 39cc71df81d..d5dcc59592b 100644--- a/src/spa/router/agentPageRoutes.tsx+++ b/src/spa/router/agentPageRoutes.tsx@@ -7,12 +7,18 @@ import { taskRouteMeta, tasksRouteMeta } from '@/features/AgentTasks/routeMeta';import {agentChannelDetailRouteMeta,agentChannelRouteMeta,+ agentEngineRouteMeta,+ agentEnvironmentRouteMeta,+ agentInstructionRouteMeta,+ agentKnowledgeRouteMeta,agentMailRouteMeta,agentPermissionRouteMeta,agentProfileRouteMeta,agentSelfLearningRouteMeta,agentShareRouteMeta,+ agentSkillsRouteMeta,agentStatisticsRouteMeta,+ agentToolsRouteMeta,topicsRouteMeta,} from '@/routes/(main)/agent/features/routeMeta';import { agentDocumentListLoader } from '@/spa/router/agentDocumentListLoader';@@ -25,7 +31,7 @@ import { dynamicElement, dynamicLayout, redirectElement } from '@/utils/router';/*** The full-page agent surfaces under `/agent/:aid` beside the chat: docs,- * goals, profile, channels, topics, statistics, share, self-evolving,+ * goals, profile, instruction, knowledge, engine, environment, tools, skills, channels, topics, statistics, share, self-evolving,* permission and tasks. Mounted by the desktop router under the agent layout* and reused by the mobile router (`mobileAgentRoutes.tsx`).*/@@ -84,6 +90,51 @@ export const agentPageChildren: RouteObject[] = [handle: { meta: agentProfileRouteMeta },path: 'profile',},+ {+ element: dynamicElement(+ () => import('@/routes/(main)/agent/instruction'),+ 'Desktop > Chat > Instruction',+ ),+ handle: { meta: agentInstructionRouteMeta },+ path: 'instruction',+ },+ {+ element: dynamicElement(+ () => import('@/routes/(main)/agent/knowledge'),+ 'Desktop > Chat > Knowledge',+ ),+ handle: { meta: agentKnowledgeRouteMeta },+ path: 'knowledge',+ },+ {+ element: dynamicElement(+ () => import('@/routes/(main)/agent/engine'),+ 'Desktop > Chat > Engine',+ ),+ handle: { meta: agentEngineRouteMeta },+ path: 'engine',+ },+ {+ element: dynamicElement(+ () => import('@/routes/(main)/agent/environment'),+ 'Desktop > Chat > Environment',+ ),+ handle: { meta: agentEnvironmentRouteMeta },+ path: 'environment',+ },+ {+ element: dynamicElement(() => import('@/routes/(main)/agent/tools'), 'Desktop > Chat > Tools'),+ handle: { meta: agentToolsRouteMeta },+ path: 'tools',+ },+ {+ element: dynamicElement(+ () => import('@/routes/(main)/agent/skills'),+ 'Desktop > Chat > Skills',+ ),+ handle: { meta: agentSkillsRouteMeta },+ path: 'skills',+ },{element: dynamicElement(() => import('@/routes/(main)/agent/mail'), 'Desktop > Chat > Mail'),handle: { meta: agentMailRouteMeta },