π€― 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
π fix: can manual close the hidden builtin tools (#13631)
LiJian021fd07deb70
diff --git a/packages/builtin-tools/src/index.ts b/packages/builtin-tools/src/index.tsindex e8694b0a598..278a30624ec 100644--- a/packages/builtin-tools/src/index.ts+++ b/packages/builtin-tools/src/index.ts@@ -65,6 +65,30 @@ export const manualModeExcludeToolIds = [SkillStoreManifest.identifier,];+/**+ * Tool IDs whose enabled state is decided by runtime / system conditions+ * (e.g. cloud runtime, agent has documents attached, knowledge base configured,+ * desktop gateway available), NOT by the user's plugin selection.+ *+ * The chat-input Tools popover deliberately hides these β even in manual+ * skill-activate mode β so users don't see a toggle that they can't actually+ * affect (the rules in `AgentToolsEngine.createEnableChecker` would force them+ * back on regardless of UI state).+ *+ * If you change this list, keep it in sync with the `rules` map in+ * `src/server/modules/Mecha/AgentToolsEngine/index.ts` and the matching frontend+ * `src/helpers/toolEngineering/index.ts`.+ */+export const runtimeManagedToolIds = [+ CloudSandboxManifest.identifier,+ KnowledgeBaseManifest.identifier,+ LocalSystemManifest.identifier,+ MemoryManifest.identifier,+ RemoteDeviceManifest.identifier,+ AgentDocumentsManifest.identifier,+ WebBrowsingManifest.identifier,+];+export const builtinTools: LobeBuiltinTool[] = [{discoverable: false,diff --git a/src/features/ChatInput/ActionBar/Tools/useControls.tsx b/src/features/ChatInput/ActionBar/Tools/useControls.tsxindex 2fc6a4a35a6..b19af73203d 100644--- a/src/features/ChatInput/ActionBar/Tools/useControls.tsx+++ b/src/features/ChatInput/ActionBar/Tools/useControls.tsx@@ -14,7 +14,7 @@ import { useTranslation } from 'react-i18next';import { useCheckPluginsIsInstalled } from '@/hooks/useCheckPluginsIsInstalled';import { useFetchInstalledPlugins } from '@/hooks/useFetchInstalledPlugins';import { useAgentStore } from '@/store/agent';-import { agentByIdSelectors } from '@/store/agent/selectors';+import { agentByIdSelectors, chatConfigByIdSelectors } from '@/store/agent/selectors';import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';import { useToolStore } from '@/store/tool';import {@@ -42,7 +42,20 @@ export const useControls = ({ setUpdating }: { setUpdating: (updating: boolean)agentByIdSelectors.getAgentPluginsById(agentId)(s),s.togglePlugin,]);- const builtinList = useToolStore(builtinToolSelectors.metaList, isEqual);+ // In manual skill-activate mode, surface hidden builtin tools (web-browsing,+ // cloud-sandbox, knowledge-base, etc.) so users can explicitly enable/disable them.+ // In auto mode the activator handles those tools transparently, so they remain hidden.+ // NOTE: must read by `agentId` (not via the activeAgentId-based selector) so that+ // embedded / group-member chat inputs render the right agent's mode.+ const isManualSkillMode = useAgentStore(+ (s) => chatConfigByIdSelectors.getSkillActivateModeById(agentId)(s) === 'manual',+ );+ const builtinList = useToolStore(+ isManualSkillMode+ ? builtinToolSelectors.metaListIncludingHidden+ : builtinToolSelectors.metaList,+ isEqual,+ );const plugins = useAgentStore((s) => agentByIdSelectors.getAgentPluginsById(agentId)(s));// Klavis-related statediff --git a/src/store/tool/slices/builtin/selectors.ts b/src/store/tool/slices/builtin/selectors.tsindex 3efb5dc6b11..2fd1ec9e9a6 100644--- a/src/store/tool/slices/builtin/selectors.ts+++ b/src/store/tool/slices/builtin/selectors.ts@@ -1,3 +1,4 @@+import { runtimeManagedToolIds } from '@lobechat/builtin-tools';import { type BuiltinSkill, type LobeToolMeta } from '@lobechat/types';import {@@ -67,18 +68,40 @@ const getKlavisMetas = (s: ToolStoreState): LobeToolMeta[] =>const getKlavisMetasWithAvailability = (s: ToolStoreState): LobeToolMetaWithAvailability[] =>getKlavisMetas(s).map((meta) => ({ ...meta, availableInWeb: true }));+// Set form for O(1) lookup inside the filter loop.+const RUNTIME_MANAGED_TOOL_IDS = new Set(runtimeManagedToolIds);+/**- * Get visible builtin tools meta list (excludes hidden tools)- * Used for general tool display in chat input bar- * Only returns tools that are not in the uninstalledBuiltinTools list+ * Shared list builder for the chat-input Tools popover.+ * @param includeHidden When true, includes builtin tools whose `hidden` flag is set+ * (e.g. memory, agent-management). Used by the manual skill-activate mode so users+ * can explicitly toggle the otherwise auto-activated tools.+ *+ * Two categories of hidden tools are STILL excluded even when `includeHidden` is true:+ * 1. Tools with `discoverable: false` β the project-wide signal for "infrastructure /+ * internal, never user-facing" (the activator and `availableToolsForDiscovery`+ * selector both honor it).+ * 2. Tools listed in `runtimeManagedToolIds` β these have their enabled state forced+ * by `AgentToolsEngine` runtime rules (e.g. cloud-sandbox is on iff cloud runtime,+ * web-browsing is on iff search enabled, agent-documents is on iff agent has docs).+ * Showing a toggle the user can't actually affect would be a UI lie.*/-const metaList = (s: ToolStoreState): LobeToolMeta[] => {+const buildVisibleMetaList = (+ s: ToolStoreState,+ { includeHidden }: { includeHidden: boolean },+): LobeToolMeta[] => {const { uninstalledBuiltinTools } = s;const builtinMetas = s.builtinTools.filter((item) => {- // Filter hidden tools- if (item.hidden) return false;+ // Filter hidden tools (unless caller opts in)+ if (item.hidden && !includeHidden) return false;+ // Even when `includeHidden` is true, never expose pure infra tools.+ if (includeHidden && item.discoverable === false) return false;+ // Even when `includeHidden` is true, never expose runtime-rule-controlled tools+ // (their enabled state is forced by AgentToolsEngine rules; user toggles would+ // be a no-op and create UI/state mismatch).+ if (includeHidden && RUNTIME_MANAGED_TOOL_IDS.has(item.identifier)) return false;// Filter platform-specific tools (e.g., LocalSystem desktop-only)if (!isBuiltinToolAvailableInCurrentEnv(item.identifier)) return false;@@ -105,6 +128,26 @@ const metaList = (s: ToolStoreState): LobeToolMeta[] => {return [...skillMetas, ...agentSkillMetas, ...builtinMetas, ...getKlavisMetas(s)];};+/**+ * Get visible builtin tools meta list (excludes hidden tools)+ * Used for general tool display in chat input bar+ * Only returns tools that are not in the uninstalledBuiltinTools list+ */+const metaList = (s: ToolStoreState): LobeToolMeta[] =>+ buildVisibleMetaList(s, { includeHidden: false });++/**+ * Same as `metaList` but also surfaces builtin tools that are normally hidden+ * (e.g. web-browsing, cloud-sandbox). Used by the chat-input Tools popover when+ * the agent is in manual skill-activate mode so users can explicitly enable or+ * disable tools the activator would otherwise auto-activate.+ *+ * Pure infrastructure tools (the activator itself, agent-builder helpers, etc.)+ * are still excluded β they are never user-toggleable.+ */+const metaListIncludingHidden = (s: ToolStoreState): LobeToolMeta[] =>+ buildVisibleMetaList(s, { includeHidden: true });+// Tools that should never be exposed in agent profile configurationconst EXCLUDED_TOOLS = new Set(['lobe-agent-builder',@@ -183,5 +226,6 @@ export const builtinToolSelectors = {installedBuiltinSkills,isBuiltinToolInstalled,metaList,+ metaListIncludingHidden,uninstalledBuiltinTools,};