diff --git a/client/src/Providers/AgentPanelContext.tsx b/client/src/Providers/AgentPanelContext.tsx index 891e1a91fc..3925492534 100644 --- a/client/src/Providers/AgentPanelContext.tsx +++ b/client/src/Providers/AgentPanelContext.tsx @@ -9,7 +9,7 @@ import { useMCPToolsQuery, } from '~/data-provider'; import { useLocalize, useGetAgentsConfig, useMCPConnectionStatus } from '~/hooks'; -import { Panel } from '~/common'; +import { Panel, isEphemeralAgent } from '~/common'; const AgentPanelContext = createContext(undefined); @@ -32,15 +32,15 @@ export function AgentPanelProvider({ children }: { children: React.ReactNode }) const { data: startupConfig } = useGetStartupConfig(); const { data: actions } = useGetActionsQuery(EModelEndpoint.agents, { - enabled: !!agent_id, + enabled: !isEphemeralAgent(agent_id), }); const { data: regularTools } = useAvailableToolsQuery(EModelEndpoint.agents, { - enabled: !!agent_id, + enabled: !isEphemeralAgent(agent_id), }); const { data: mcpData } = useMCPToolsQuery({ - enabled: !!agent_id && startupConfig?.mcpServers != null, + enabled: !isEphemeralAgent(agent_id) && startupConfig?.mcpServers != null, }); const { agentsConfig, endpointsConfig } = useGetAgentsConfig(); @@ -50,7 +50,7 @@ export function AgentPanelProvider({ children }: { children: React.ReactNode }) ); const { connectionStatus } = useMCPConnectionStatus({ - enabled: !!agent_id && mcpServerNames.length > 0, + enabled: !isEphemeralAgent(agent_id) && mcpServerNames.length > 0, }); const mcpServersMap = useMemo(() => { diff --git a/client/src/common/selector.ts b/client/src/common/selector.ts index 619d8e8f80..af69ca4af5 100644 --- a/client/src/common/selector.ts +++ b/client/src/common/selector.ts @@ -1,5 +1,5 @@ import React from 'react'; -import { TModelSpec, TStartupConfig } from 'librechat-data-provider'; +import { TStartupConfig } from 'librechat-data-provider'; export interface Endpoint { value: string; diff --git a/client/src/common/types.ts b/client/src/common/types.ts index 647950e546..8f865ce7a8 100644 --- a/client/src/common/types.ts +++ b/client/src/common/types.ts @@ -1,5 +1,5 @@ import { RefObject } from 'react'; -import { FileSources, EModelEndpoint } from 'librechat-data-provider'; +import { Constants, FileSources, EModelEndpoint } from 'librechat-data-provider'; import type { UseMutationResult } from '@tanstack/react-query'; import type * as InputNumberPrimitive from 'rc-input-number'; import type { SetterOrUpdater, RecoilState } from 'recoil'; @@ -8,6 +8,10 @@ import type * as t from 'librechat-data-provider'; import type { LucideIcon } from 'lucide-react'; import type { TranslationKeys } from '~/hooks'; +export function isEphemeralAgent(agentId: string | null | undefined): boolean { + return agentId == null || agentId === '' || agentId === Constants.EPHEMERAL_AGENT_ID; +} + export interface ConfigFieldDetail { title: string; description: string; diff --git a/client/src/components/SidePanel/Agents/ActionsPanel.tsx b/client/src/components/SidePanel/Agents/ActionsPanel.tsx index bbd9a2978c..f936d81357 100644 --- a/client/src/components/SidePanel/Agents/ActionsPanel.tsx +++ b/client/src/components/SidePanel/Agents/ActionsPanel.tsx @@ -1,27 +1,26 @@ import { useEffect } from 'react'; import { ChevronLeft } from 'lucide-react'; import { useForm, FormProvider } from 'react-hook-form'; - import { AuthTypeEnum, AuthorizationTypeEnum, TokenExchangeMethodEnum, } from 'librechat-data-provider'; import { - OGDialogTemplate, - TrashIcon, - OGDialog, - OGDialogTrigger, Label, + OGDialog, + TrashIcon, + OGDialogTrigger, useToastContext, + OGDialogTemplate, } from '@librechat/client'; +import type { ActionAuthForm } from '~/common'; import ActionsAuth from '~/components/SidePanel/Builder/ActionsAuth'; import { useAgentPanelContext } from '~/Providers/AgentPanelContext'; import { useDeleteAgentAction } from '~/data-provider'; -import type { ActionAuthForm } from '~/common'; +import { Panel, isEphemeralAgent } from '~/common'; import ActionsInput from './ActionsInput'; import { useLocalize } from '~/hooks'; -import { Panel } from '~/common'; export default function ActionsPanel() { const localize = useLocalize(); @@ -109,7 +108,7 @@ export default function ActionsPanel() {
diff --git a/client/src/components/SidePanel/Agents/FileSearch.tsx b/client/src/components/SidePanel/Agents/FileSearch.tsx index 5e73084e08..573742f8f1 100644 --- a/client/src/components/SidePanel/Agents/FileSearch.tsx +++ b/client/src/components/SidePanel/Agents/FileSearch.tsx @@ -18,6 +18,7 @@ import { SharePointPickerDialog } from '~/components/SharePoint'; import FileRow from '~/components/Chat/Input/Files/FileRow'; import FileSearchCheckbox from './FileSearchCheckbox'; import { useChatContext } from '~/Providers'; +import { isEphemeralAgent } from '~/common'; export default function FileSearch({ agent_id, @@ -69,7 +70,7 @@ export default function FileSearch({ const isUploadDisabled = endpointFileConfig.disabled ?? false; const sharePointEnabled = startupConfig?.sharePointFilePickerEnabled; - const disabledUploadButton = !agent_id || fileSearchChecked === false; + const disabledUploadButton = isEphemeralAgent(agent_id) || fileSearchChecked === false; const handleSharePointFilesSelected = async (sharePointFiles: any[]) => { try { diff --git a/client/src/components/SidePanel/Agents/MCPPanel.tsx b/client/src/components/SidePanel/Agents/MCPPanel.tsx index e207a15300..c20e4a9b1e 100644 --- a/client/src/components/SidePanel/Agents/MCPPanel.tsx +++ b/client/src/components/SidePanel/Agents/MCPPanel.tsx @@ -7,21 +7,19 @@ import { TokenExchangeMethodEnum, } from 'librechat-data-provider'; import { - OGDialog, - OGDialogTrigger, Label, - OGDialogTemplate, + OGDialog, TrashIcon, + OGDialogTrigger, useToastContext, + OGDialogTemplate, } from '@librechat/client'; +import type { MCPForm } from '~/common'; import { useAgentPanelContext } from '~/Providers/AgentPanelContext'; import { defaultMCPFormValues } from '~/common/mcp'; -import type { MCPForm } from '~/common'; +import { Panel, isEphemeralAgent } from '~/common'; import { useLocalize } from '~/hooks'; import MCPInput from './MCPInput'; -import { Panel } from '~/common'; -// TODO: Add MCP delete (for now mocked for ui) -// import { useDeleteAgentMCP } from '~/data-provider'; function useDeleteAgentMCP({ onSuccess, @@ -127,7 +125,7 @@ export default function MCPPanel() {