Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🧭 refactor: Move the Pure Subagent Modules Into @librechat/chat (#17582)
Marco Beretta267734911762
diff --git a/client/src/components/Chat/BackgroundTasks/Button.tsx b/client/src/components/Chat/BackgroundTasks/Button.tsxindex 9739557b90..69c2d760ff 100644--- a/client/src/components/Chat/BackgroundTasks/Button.tsx+++ b/client/src/components/Chat/BackgroundTasks/Button.tsx@@ -1,10 +1,10 @@import { memo, useEffect, useRef, useState } from 'react';import * as Ariakit from '@ariakit/react';+import { durableSubagentSelection } from '@librechat/chat/react';import { Button, IconButton, TooltipAnchor } from '@librechat/client';import { ListTodo, Maximize2, Minimize2, Square, X } from 'lucide-react';import type { TaskRow } from './rows';import { useParentSubagents } from '~/components/Chat/Subagents/ParentSubagentsProvider';-import { durableSubagentSelection } from '~/components/Chat/Subagents/eventSelection';import { useOpenSubagentPanel } from '~/components/Chat/Subagents/surface';import { RECENT_SUBAGENT_WINDOW_MS } from './rows';import useBackgroundTasks from './useTasks';diff --git a/client/src/components/Chat/Messages/Content/Parts/SubagentCall.tsx b/client/src/components/Chat/Messages/Content/Parts/SubagentCall.tsxindex 027f887979..1d91ac54e9 100644--- a/client/src/components/Chat/Messages/Content/Parts/SubagentCall.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/SubagentCall.tsx@@ -9,6 +9,9 @@ import {subagentProgressKey,useSubagentProgress,useToolCallIntent,+ resolveSubagentAgentId,+ subagentStatusLabelKey,+ getSubagentPrompt,} from '@librechat/chat/react';import type {PartMetadata,@@ -20,10 +23,7 @@ import type { SubagentContentPreview } from '@librechat/chat/react';import type { SubagentTickerLine } from '@librechat/chat';import { useParentSubagents } from '~/components/Chat/Subagents/ParentSubagentsProvider';import { isSelfSpawn as isSelfSpawnType } from '~/components/Chat/Subagents/author';-import { resolveSubagentAgentId } from '~/components/Chat/Subagents/identity';-import { subagentStatusLabelKey } from '~/components/Chat/Subagents/status';import { useOpenSubagentPanel } from '~/components/Chat/Subagents/surface';-import { getSubagentPrompt } from '~/components/Chat/Subagents/prompt';import { MessageContext } from '~/Providers/MessageContext';import { useShareContext } from '~/Providers/ShareContext';import MessageIcon from '~/components/Share/MessageIcon';diff --git a/client/src/components/Chat/Messages/Content/Wakeup.tsx b/client/src/components/Chat/Messages/Content/Wakeup.tsxindex eaaac3d087..c2220ea5f5 100644--- a/client/src/components/Chat/Messages/Content/Wakeup.tsx+++ b/client/src/components/Chat/Messages/Content/Wakeup.tsx@@ -1,5 +1,6 @@import { memo, useCallback, useMemo, useState } from 'react';import { Button } from '@librechat/client';+import { subagentStatusIcon, subagentStatusLabelKey } from '@librechat/chat/react';import {SystemEventHeader,SystemEventIcon,@@ -7,7 +8,6 @@ import {} from '@librechat/chat/components';import type { WakeupDisplay, WakeupTask } from '@librechat/chat';import type { TranslationKeys } from '~/hooks';-import { subagentStatusIcon, subagentStatusLabelKey } from '~/components/Chat/Subagents/status';import { useLocalize, useExpandCollapse, useLazyCollapseBody } from '~/hooks';import { useMessagePartsHost } from '~/Providers/MessagePartsHostContext';import { useSubagentTaskPanel } from '~/components/Chat/Subagents/task';diff --git a/client/src/components/Chat/Subagents/EventSubagentActivityGroup.test.tsx b/client/src/components/Chat/Subagents/EventSubagentActivityGroup.test.tsxindex 5e8bc18b0a..da894ec9ec 100644--- a/client/src/components/Chat/Subagents/EventSubagentActivityGroup.test.tsx+++ b/client/src/components/Chat/Subagents/EventSubagentActivityGroup.test.tsx@@ -1,12 +1,11 @@import React from 'react';import { useAtomValue, useSetAtom } from 'jotai';-import { activeSubagentPanel } from '@librechat/chat/react';import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';+import { activeSubagentPanel, durableSubagentSelection } from '@librechat/chat/react';import type { ParentSubagentSummary } from 'librechat-data-provider';import type { ActiveSubagentPanel } from '@librechat/chat/react';import EventSubagentActivityGroup from './EventSubagentActivityGroup';import { ChatSurfaceHarness, testChatSurface } from 'test/harness';-import { durableSubagentSelection } from './eventSelection';const mockRefresh = jest.fn().mockResolvedValue(undefined);const mockChild: ParentSubagentSummary = {diff --git a/client/src/components/Chat/Subagents/EventSubagentActivityGroup.tsx b/client/src/components/Chat/Subagents/EventSubagentActivityGroup.tsxindex 0a9fea1c3a..76d04e6d97 100644--- a/client/src/components/Chat/Subagents/EventSubagentActivityGroup.tsx+++ b/client/src/components/Chat/Subagents/EventSubagentActivityGroup.tsx@@ -2,13 +2,17 @@ import { useCallback, useId, useMemo, useState } from 'react';import { useSetAtom } from 'jotai';import { Button, cn } from '@librechat/client';import { Bot, ChevronDown } from 'lucide-react';-import { activeSubagentPanel } from '@librechat/chat/react';import { getMessageRowWidthClass } from '@librechat/chat/components';+import {+ activeSubagentPanel,+ isLiveSubagentStatus,+ subagentStatusDotClass,+ subagentStatusLabelKey,+ eventSubagentSelection,+} from '@librechat/chat/react';import type { ParentSubagentSummary } from 'librechat-data-provider';-import { isLiveSubagentStatus, subagentStatusDotClass, subagentStatusLabelKey } from './status';import { useChatSurface, useOpenSubagentPanel } from './surface';import { useParentSubagents } from './ParentSubagentsProvider';-import { eventSubagentSelection } from './eventSelection';import { useAgentsMapContext } from '~/Providers';import { renderAgentAvatar } from '~/utils';import { useLocalize } from '~/hooks';diff --git a/client/src/components/Chat/Subagents/SharedSubagentActivityDialog.tsx b/client/src/components/Chat/Subagents/SharedSubagentActivityDialog.tsxindex ecace48292..96b3697b7e 100644--- a/client/src/components/Chat/Subagents/SharedSubagentActivityDialog.tsx+++ b/client/src/components/Chat/Subagents/SharedSubagentActivityDialog.tsx@@ -1,7 +1,11 @@import { useCallback, useEffect, useMemo, useRef } from 'react';import { useAtom } from 'jotai';-import { activeSubagentPanel } from '@librechat/chat/react';import { OGDialog, OGDialogContent, OGDialogHeader, OGDialogTitle } from '@librechat/client';+import {+ activeSubagentPanel,+ adaptLivePersistedActivity,+ resolveSubagentAgentId,+} from '@librechat/chat/react';import type { TMessage } from 'librechat-data-provider';import {isSelfSpawn as isSelfSpawnType,@@ -13,8 +17,6 @@ import {import { MessageSurfaceContext } from '~/components/Chat/Messages/ui/surface';import { SubagentActivityScrollSurface } from './SubagentActivity';import SubagentConversation from './SubagentConversation';-import { adaptLivePersistedActivity } from './adapters';-import { resolveSubagentAgentId } from './identity';import { useAgentsMapContext } from '~/Providers';import { useLocalize } from '~/hooks';diff --git a/client/src/components/Chat/Subagents/SubagentActivity.test.tsx b/client/src/components/Chat/Subagents/SubagentActivity.test.tsxindex 15776510b3..05cdfb6034 100644--- a/client/src/components/Chat/Subagents/SubagentActivity.test.tsx+++ b/client/src/components/Chat/Subagents/SubagentActivity.test.tsx@@ -3,7 +3,7 @@ import { ContentTypes } from 'librechat-data-provider';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { act, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react';import type { TMessageContentParts, Agents } from 'librechat-data-provider';-import type { ChildActivity } from './adapters';+import type { ChildActivity } from '@librechat/chat/react';import SubagentActivity, { SubagentActivityScrollSurface } from './SubagentActivity';import { TaskContentScopeContext } from '~/data-provider/Subagents/content';import { ChatSurfaceHarness } from 'test/harness';diff --git a/client/src/components/Chat/Subagents/SubagentActivity.tsx b/client/src/components/Chat/Subagents/SubagentActivity.tsxindex c44e658de6..b3f5fdd315 100644--- a/client/src/components/Chat/Subagents/SubagentActivity.tsx+++ b/client/src/components/Chat/Subagents/SubagentActivity.tsx@@ -4,20 +4,19 @@ import { Alert, Button } from '@librechat/client';import { Maximize2, Minimize2 } from 'lucide-react';import { CSSTransition } from 'react-transition-group';import { MessageTimestamp } from '@librechat/chat/components';-import { ToolContentQueryContext } from '@librechat/chat/react';import { ContentTypes, QueryKeys, dataService } from 'librechat-data-provider';-import type { SearchResultData, TMessageContentParts } from 'librechat-data-provider';-import type { SteerReceiptState } from '@librechat/chat/components';-import type { ToolContentQuery } from '@librechat/chat/react';-import type { TaskContentScope } from '~/data-provider/Subagents/content';-import type { ChildActivity, ChildActivityItem } from './adapters';-import type { TranslationKeys } from '~/hooks';import {isAbnormalTerminalStatus,isLiveSubagentStatus,subagentStatusIcon,subagentStatusLabelKey,-} from './status';+ ToolContentQueryContext,+} from '@librechat/chat/react';+import type { ChildActivity, ChildActivityItem, ToolContentQuery } from '@librechat/chat/react';+import type { SearchResultData, TMessageContentParts } from 'librechat-data-provider';+import type { SteerReceiptState } from '@librechat/chat/components';+import type { TaskContentScope } from '~/data-provider/Subagents/content';+import type { TranslationKeys } from '~/hooks';import { TaskContentScopeContext } from '~/data-provider/Subagents/content';import MarkdownLite from '~/components/Chat/Messages/Content/MarkdownLite';import ContentParts from '~/components/Chat/Messages/Content/ContentParts';diff --git a/client/src/components/Chat/Subagents/SubagentConversation.test.tsx b/client/src/components/Chat/Subagents/SubagentConversation.test.tsxindex ee9ff02699..5df0773219 100644--- a/client/src/components/Chat/Subagents/SubagentConversation.test.tsx+++ b/client/src/components/Chat/Subagents/SubagentConversation.test.tsx@@ -1,5 +1,6 @@import React from 'react';import { ContentTypes } from 'librechat-data-provider';+import { mergeChildConversationTurns } from '@librechat/chat/react';import { fireEvent, render, screen, within } from '@testing-library/react';import type {FullToolCall,@@ -7,11 +8,10 @@ import type {TMessage,TMessageContentParts,} from 'librechat-data-provider';+import type { ChildConversationTurn } from '@librechat/chat/react';import type { ChatContract } from '~/hooks/Chat/contract';-import type { ChildConversationTurn } from './adapters';import type { TurnAuthor } from './author';import SubagentConversation from './SubagentConversation';-import { mergeChildConversationTurns } from './adapters';import { ChatContext } from '~/Providers/ChatContext';import { ChatSurfaceHarness } from 'test/harness';diff --git a/client/src/components/Chat/Subagents/SubagentConversation.tsx b/client/src/components/Chat/Subagents/SubagentConversation.tsxindex 219672975a..a8f98b50d4 100644--- a/client/src/components/Chat/Subagents/SubagentConversation.tsx+++ b/client/src/components/Chat/Subagents/SubagentConversation.tsx@@ -8,6 +8,12 @@ import {CollapsibleContent,CollapsibleTrigger,} from '@librechat/client';+import {+ isAbnormalTerminalStatus,+ isLiveSubagentStatus,+ hasTerminalOutcome,+ standardContent,+} from '@librechat/chat/react';import {SystemEventHeader,SystemEventIcon,@@ -16,12 +22,11 @@ import {ElapsedTimer,MessageRow,} from '@librechat/chat/components';+import type { ChildConversationTurn, ToolContentQuery } from '@librechat/chat/react';import type { TMessage, TMessageContentParts } from 'librechat-data-provider';-import type { ToolContentQuery } from '@librechat/chat/react';import type { ReactNode } from 'react';import type { TaskContentScope } from '~/data-provider/Subagents/content';import type { MessagePartsHost } from '~/hooks/Chat/contract';-import type { ChildConversationTurn } from './adapters';import type { TranslationKeys } from '~/hooks';import type { TurnAuthor } from './author';import {@@ -36,12 +41,9 @@ import { useSearchResultsByTurn } from '~/hooks/Messages/useSearchResultsByTurn'import { ErrorSourceProvider } from '~/components/Messages/Content/Error/source';import MinimalHoverButtons from '~/components/Chat/Messages/MinimalHoverButtons';import ContentParts from '~/components/Chat/Messages/Content/ContentParts';-import { isAbnormalTerminalStatus, isLiveSubagentStatus } from './status';import { AuthorContext } from '~/Providers/AuthorContext';import { ChatContext } from '~/Providers/ChatContext';import { isEmptyContentPart } from '~/utils/messages';-import { hasTerminalOutcome } from './outcome';-import { standardContent } from './adapters';import { useChatSurface } from './surface';import { useLocalize } from '~/hooks';import { cn } from '~/utils';diff --git a/client/src/components/Chat/Subagents/SubagentThreadPanel.tsx b/client/src/components/Chat/Subagents/SubagentThreadPanel.tsxindex 148b1e8a7d..d4faa30c5f 100644--- a/client/src/components/Chat/Subagents/SubagentThreadPanel.tsx+++ b/client/src/components/Chat/Subagents/SubagentThreadPanel.tsx@@ -21,6 +21,15 @@ import {subagentProgressKey,useSubagentProgress,useSubagentActivityStream,+ adaptDurableThreadActivity,+ adaptDurableThreadConversation,+ adaptLivePersistedActivity,+ mergeChildConversationTurns,+ retainBoundedMovingWindowTurns,+ eventSubagentSelection,+ resolveSubagentAgentId,+ isLiveSubagentStatus,+ getSubagentPrompt,} from '@librechat/chat/react';import type {ParentSubagentTaskSummary,@@ -41,13 +50,6 @@ import {useSubagentControlMutation,useSubagentThreadQuery,} from '~/data-provider';-import {- adaptDurableThreadActivity,- adaptDurableThreadConversation,- adaptLivePersistedActivity,- mergeChildConversationTurns,- retainBoundedMovingWindowTurns,-} from './adapters';import {agentAuthor,resolveSubagentAuthor,@@ -65,12 +67,8 @@ import { useConfiguredFooter } from '~/components/Chat/Footer';import { useParentSubagents } from './ParentSubagentsProvider';import useScaledMaxWidth from '~/hooks/useScaledMaxWidth';import SubagentConversation from './SubagentConversation';-import { eventSubagentSelection } from './eventSelection';-import { resolveSubagentAgentId } from './identity';import { useAgentsMapContext } from '~/Providers';-import { isLiveSubagentStatus } from './status';import { cn, renderAgentAvatar } from '~/utils';-import { getSubagentPrompt } from './prompt';import { useChatSurface } from './surface';const EVENT_TASK_PAGE_SIZE = 3;diff --git a/client/src/components/Chat/Subagents/task.ts b/client/src/components/Chat/Subagents/task.tsindex 94a6a851ed..45b3f5fd09 100644--- a/client/src/components/Chat/Subagents/task.ts+++ b/client/src/components/Chat/Subagents/task.ts@@ -1,7 +1,7 @@import { useCallback, useMemo } from 'react';+import { durableSubagentSelection } from '@librechat/chat/react';import type { ActiveSubagentPanel } from '@librechat/chat/react';import { useParentSubagents } from './ParentSubagentsProvider';-import { durableSubagentSelection } from './eventSelection';import { useShareContext } from '~/Providers/ShareContext';import { useOpenSubagentPanel } from './surface';import { useMessageContext } from '~/Providers';diff --git a/client/src/data-provider/Subagents/content.tsx b/client/src/data-provider/Subagents/content.tsxindex 961a24c0f9..0495f23f2e 100644--- a/client/src/data-provider/Subagents/content.tsx+++ b/client/src/data-provider/Subagents/content.tsx@@ -2,12 +2,10 @@ import { createContext, useContext } from 'react';import { atom, createStore } from 'jotai';import { useQuery, useQueryClient } from '@tanstack/react-query';import { QueryKeys, dataService, hasToolCallPreview } from 'librechat-data-provider';+import { recoverTaskContent, recoveredToolPart, isLiveSubagentStatus } from '@librechat/chat/react';import type { SubagentTaskContentSnapshot, ToolCallPartResponse } from 'librechat-data-provider';+import type { RecoveredContent, ToolContentQuery } from '@librechat/chat/react';import type { QueryClient, UseQueryOptions } from '@tanstack/react-query';-import type { ToolContentQuery } from '@librechat/chat/react';-import type { RecoveredContent } from '~/components/Chat/Subagents/recovery';-import { recoverTaskContent, recoveredToolPart } from '~/components/Chat/Subagents/recovery';-import { isLiveSubagentStatus } from '~/components/Chat/Subagents/status';import { ACTIVE_THREAD_REFRESH_MS } from './queries';export type TaskContentScope = {diff --git a/client/test/subagents.ts b/client/test/subagents.tsdeleted file mode 100644index 323535c080..0000000000--- a/client/test/subagents.ts+++ /dev/null@@ -1,27 +0,0 @@-import type { SubagentUpdateEvent } from 'librechat-data-provider';-import type { SubagentContentPart, SubagentTickerLine } from '@librechat/chat';-import {- foldSubagentEvent,- initSubagentTickerState,- foldSubagentEventIntoTicker,- initSubagentAggregatorState,-} from '@librechat/chat';--/** Folds a whole event stream through the incremental aggregator the live UI uses. */-export function aggregateSubagentContent(events: SubagentUpdateEvent[]): SubagentContentPart[] {- let parts: SubagentContentPart[] = [];- let state = initSubagentAggregatorState();- for (const event of events) {- ({ parts, state } = foldSubagentEvent(parts, state, event));- }- return parts;-}--/** Folds a whole event stream through the incremental ticker the live UI uses. */-export function buildSubagentTickerLines(events: SubagentUpdateEvent[]): SubagentTickerLine[] {- let state = initSubagentTickerState();- for (const event of events) {- state = foldSubagentEventIntoTicker(state, event);- }- return state.lines;-}diff --git a/client/src/components/Chat/Subagents/adapters.test.ts b/packages/chat/src/react/subagents/__tests__/adapters.spec.tssimilarity index 99%rename from client/src/components/Chat/Subagents/adapters.test.tsrename to packages/chat/src/react/subagents/__tests__/adapters.spec.tsindex db865bd18b..bd7eb5e758 100644--- a/client/src/components/Chat/Subagents/adapters.test.ts+++ b/packages/chat/src/react/subagents/__tests__/adapters.spec.ts@@ -1,12 +1,11 @@import { ContentTypes } from 'librechat-data-provider';-import { initSubagentAggregatorState, initSubagentTickerState } from '@librechat/chat';import type {SubagentThreadView,SubagentUpdateEvent,TMessageContentParts,FullToolCall,} from 'librechat-data-provider';-import type { ChildConversationTurn } from './adapters';+import type { ChildConversationTurn } from '../adapters';import {adaptDurableThreadActivity,adaptDurableThreadConversation,@@ -14,8 +13,9 @@ import {MAX_RETAINED_MOVING_WINDOW_TURNS,mergeChildConversationTurns,retainBoundedMovingWindowTurns,-} from './adapters';-import { aggregateSubagentContent } from 'test/subagents';+} from '../adapters';+import { initSubagentAggregatorState, initSubagentTickerState } from '../../../core';+import { aggregateSubagentContent } from '../../../core/__fixtures__/subagents';describe('child activity adapters', () => {it('passes child dispatch and completed durations to the generic tool card', () => {diff --git a/client/src/components/Chat/Subagents/identity.test.ts b/packages/chat/src/react/subagents/__tests__/identity.spec.tssimilarity index 94%rename from client/src/components/Chat/Subagents/identity.test.tsrename to packages/chat/src/react/subagents/__tests__/identity.spec.tsindex 0a93d64107..3beeb5e13b 100644--- a/client/src/components/Chat/Subagents/identity.test.ts+++ b/packages/chat/src/react/subagents/__tests__/identity.spec.ts@@ -1,4 +1,4 @@-import { resolveSubagentAgentId } from './identity';+import { resolveSubagentAgentId } from '../identity';describe('resolveSubagentAgentId', () => {const agent = { subagentKind: 'agent' as const, subagentAgentId: 'agent-1' };diff --git a/client/src/components/Chat/Subagents/outcome.test.ts b/packages/chat/src/react/subagents/__tests__/outcome.spec.tssimilarity index 99%rename from client/src/components/Chat/Subagents/outcome.test.tsrename to packages/chat/src/react/subagents/__tests__/outcome.spec.tsindex 572fef6837..7db3490529 100644--- a/client/src/components/Chat/Subagents/outcome.test.ts+++ b/packages/chat/src/react/subagents/__tests__/outcome.spec.ts@@ -2,7 +2,7 @@ import { File } from 'node:buffer';import { ContentTypes } from 'librechat-data-provider';import { ReadableStream, TransformStream, WritableStream } from 'node:stream/web';import type { SubagentThreadMessage, TMessageContentParts } from 'librechat-data-provider';-import { hasTerminalOutcome } from './outcome';+import { hasTerminalOutcome } from '../outcome';const outcome = (text: string, textTruncated = false): SubagentThreadMessage => ({messageId: 'task:assistant',diff --git a/client/src/components/Chat/Subagents/recovery.test.ts b/packages/chat/src/react/subagents/__tests__/recovery.spec.tssimilarity index 99%rename from client/src/components/Chat/Subagents/recovery.test.tsrename to packages/chat/src/react/subagents/__tests__/recovery.spec.tsindex 769bb435a7..39d84e81df 100644--- a/client/src/components/Chat/Subagents/recovery.test.ts+++ b/packages/chat/src/react/subagents/__tests__/recovery.spec.ts@@ -4,7 +4,7 @@ import type {SubagentTaskContentSuffix,SubagentContentEvent,} from 'librechat-data-provider';-import { reduceRecoveredContent, recoverTaskContent, recoveredToolPart } from './recovery';+import { reduceRecoveredContent, recoverTaskContent, recoveredToolPart } from '../recovery';const snapshot = (overrides: Partial<SubagentTaskContentSnapshot> = {},diff --git a/client/src/components/Chat/Subagents/adapters.ts b/packages/chat/src/react/subagents/adapters.tssimilarity index 99%rename from client/src/components/Chat/Subagents/adapters.tsrename to packages/chat/src/react/subagents/adapters.tsindex 887a9c257f..d73d95dfac 100644--- a/client/src/components/Chat/Subagents/adapters.ts+++ b/packages/chat/src/react/subagents/adapters.ts@@ -1,5 +1,4 @@import { ContentTypes } from 'librechat-data-provider';-import { REDACTED_REASONING_MARKER } from '@librechat/chat/react';import type {Agents,PartMetadata,@@ -13,7 +12,8 @@ import type {TAttachment,FullToolCall,} from 'librechat-data-provider';-import type { SubagentProgress } from '@librechat/chat/react';+import type { SubagentProgress } from './state';+import { REDACTED_REASONING_MARKER } from './state';export type ChildActivityItem =| Extract<SubagentActivityItem, { type: 'steer' }>@@ -253,7 +253,7 @@ const mergePersistedAndLiveActivity = (continue;}- const previous = merged.at(-1);+ const previous = merged[merged.length - 1];if (previous?.type !== item.type) {merged.push(item);continue;diff --git a/client/src/components/Chat/Subagents/eventSelection.ts b/packages/chat/src/react/subagents/eventSelection.tssimilarity index 96%rename from client/src/components/Chat/Subagents/eventSelection.tsrename to packages/chat/src/react/subagents/eventSelection.tsindex 70e694ef9a..35693b6849 100644--- a/client/src/components/Chat/Subagents/eventSelection.ts+++ b/packages/chat/src/react/subagents/eventSelection.ts@@ -1,7 +1,7 @@import type { ParentSubagentSummary } from 'librechat-data-provider';-import type { ActiveSubagentPanel } from '@librechat/chat/react';+import type { ActiveSubagentPanel } from './state';-export const eventTaskProgressKey = (threadId: string, taskId: string) =>+export const eventTaskProgressKey = (threadId: string, taskId: string): string =>`event-task:${threadId}:${taskId}`;export const eventSubagentSelection = (diff --git a/client/src/components/Chat/Subagents/identity.ts b/packages/chat/src/react/subagents/identity.tssimilarity index 100%rename from client/src/components/Chat/Subagents/identity.tsrename to packages/chat/src/react/subagents/identity.tsdiff --git a/packages/chat/src/react/subagents/index.ts b/packages/chat/src/react/subagents/index.tsindex 8011b2db35..b8359db813 100644--- a/packages/chat/src/react/subagents/index.ts+++ b/packages/chat/src/react/subagents/index.ts@@ -1,2 +1,9 @@export * from './state';export * from './stream';+export * from './status';+export * from './prompt';+export * from './outcome';+export * from './identity';+export * from './adapters';+export * from './recovery';+export * from './eventSelection';diff --git a/client/src/components/Chat/Subagents/outcome.ts b/packages/chat/src/react/subagents/outcome.tssimilarity index 100%rename from client/src/components/Chat/Subagents/outcome.tsrename to packages/chat/src/react/subagents/outcome.tsdiff --git a/client/src/components/Chat/Subagents/prompt.ts b/packages/chat/src/react/subagents/prompt.tssimilarity index 100%rename from client/src/components/Chat/Subagents/prompt.tsrename to packages/chat/src/react/subagents/prompt.tsdiff --git a/client/src/components/Chat/Subagents/recovery.ts b/packages/chat/src/react/subagents/recovery.tssimilarity index 98%rename from client/src/components/Chat/Subagents/recovery.tsrename to packages/chat/src/react/subagents/recovery.tsindex 6dad96238b..767f993e83 100644--- a/client/src/components/Chat/Subagents/recovery.ts+++ b/packages/chat/src/react/subagents/recovery.ts@@ -1,4 +1,3 @@-import { createStreamState, reduceStep, applySteerPart } from '@librechat/chat';import {ContentTypes,EModelEndpoint,@@ -14,7 +13,8 @@ import type {FullToolCall,PartMetadata,} from 'librechat-data-provider';-import type { StreamState, StepContext } from '@librechat/chat';+import type { StreamState, StepContext } from '../../core';+import { createStreamState, reduceStep, applySteerPart } from '../../core';import { isLiveSubagentStatus } from './status';export type RecoveredContent = {@@ -211,7 +211,7 @@ function applyRecoveredContent(export const recoveredToolPart = (snapshot: SubagentTaskContentSnapshot,params: { partIndex: number; toolCallId?: string; stepId?: string; agentId?: string },-) => {+): { partIndex: number; tool_call: FullToolCall } | null => {const matches = (index: number) => {const part = snapshot.content[index];if (part?.type !== ContentTypes.TOOL_CALL) return false;diff --git a/client/src/components/Chat/Subagents/status.ts b/packages/chat/src/react/subagents/status.tssimilarity index 72%rename from client/src/components/Chat/Subagents/status.tsrename to packages/chat/src/react/subagents/status.tsindex 5ef642f17d..97cda1ede4 100644--- a/client/src/components/Chat/Subagents/status.ts+++ b/packages/chat/src/react/subagents/status.ts@@ -1,29 +1,31 @@import { AlertCircle, CheckCircle2, Clock3, XCircle } from 'lucide-react';import type { SubagentThreadStatus } from 'librechat-data-provider';+import type { LucideIcon } from 'lucide-react';/** Only abnormal endings earn a status chip — main chat conveys an in-flight* run through its streaming content and cursor, never a "running" label. */export const isAbnormalTerminalStatus = (status: SubagentThreadStatus): boolean =>status === 'failed' || status === 'interrupted' || status === 'cancelled';-export const subagentStatusIcon = (status: SubagentThreadStatus) => {+export const subagentStatusIcon = (status: SubagentThreadStatus): LucideIcon => {if (status === 'completed') return CheckCircle2;if (status === 'failed' || status === 'interrupted') return AlertCircle;if (status === 'cancelled') return XCircle;return Clock3;};-export const subagentStatusLabelKey = (status: SubagentThreadStatus) =>- (- ({- dispatched: 'com_ui_subagent_thread_status_dispatched',- running: 'com_ui_subagent_thread_status_running',- completed: 'com_ui_subagent_thread_status_completed',- failed: 'com_ui_subagent_thread_status_failed',- interrupted: 'com_ui_subagent_thread_status_interrupted',- cancelled: 'com_ui_subagent_thread_status_cancelled',- }) as const- )[status];+const STATUS_LABEL_KEYS = {+ dispatched: 'com_ui_subagent_thread_status_dispatched',+ running: 'com_ui_subagent_thread_status_running',+ completed: 'com_ui_subagent_thread_status_completed',+ failed: 'com_ui_subagent_thread_status_failed',+ interrupted: 'com_ui_subagent_thread_status_interrupted',+ cancelled: 'com_ui_subagent_thread_status_cancelled',+} as const;++export const subagentStatusLabelKey = (+ status: SubagentThreadStatus,+): (typeof STATUS_LABEL_KEYS)[SubagentThreadStatus] => STATUS_LABEL_KEYS[status];/** Fixed-size status dot classes: a stable-width indicator that cannot make* rows shift as status text changes length. The dot only carries color — a