🤯 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
import { type LobeAgentChatConfig } from '@lobechat/types';
import { type AgentStoreState } from '@/store/agent/initialState';
import { chatConfigByIdSelectors } from './chatConfigByIdSelectors';
// ============ Current Agent Selectors (reuses chatConfigByIdSelectors) ============ //
const currentChatConfig = (s: AgentStoreState): LobeAgentChatConfig =>
chatConfigByIdSelectors.getChatConfigById(s.activeAgentId || '')(s);
const agentSearchMode = (s: AgentStoreState) =>
chatConfigByIdSelectors.getSearchModeById(s.activeAgentId || '')(s);
const isAgentEnableSearch = (s: AgentStoreState) =>
chatConfigByIdSelectors.isEnableSearchById(s.activeAgentId || '')(s);
const useModelBuiltinSearch = (s: AgentStoreState) =>
chatConfigByIdSelectors.getUseModelBuiltinSearchById(s.activeAgentId || '')(s);
const searchFCModel = (s: AgentStoreState) =>
chatConfigByIdSelectors.getSearchFCModelById(s.activeAgentId || '')(s);
// Read the stored history flag directly; model-level mode overrides should not affect history.
const enableHistoryCount = (s: AgentStoreState) =>
chatConfigByIdSelectors.getEnableHistoryCountById(s.activeAgentId || '')(s);
const historyCount = (s: AgentStoreState): number =>
chatConfigByIdSelectors.getHistoryCountById(s.activeAgentId || '')(s);
const isMemoryToolEnabled = (s: AgentStoreState) =>
chatConfigByIdSelectors.isMemoryToolEnabledById(s.activeAgentId || '')(s);
const isLocalSystemEnabled = (s: AgentStoreState) =>
chatConfigByIdSelectors.isLocalSystemEnabledById(s.activeAgentId || '')(s);
const isCloudSandboxEnabled = (s: AgentStoreState) =>
chatConfigByIdSelectors.getRuntimeModeById(s.activeAgentId || '')(s) === 'cloud';
const enableHistoryDivider =
(historyLength: number, currentIndex: number) => (s: AgentStoreState) => {
const config = currentChatConfig(s);
return (
enableHistoryCount(s) &&
historyLength > (config.historyCount ?? 0) &&
config.historyCount === historyLength - currentIndex
);
};
export const agentChatConfigSelectors = {
agentSearchMode,
currentChatConfig,
enableHistoryCount,
enableHistoryDivider,
historyCount,
isAgentEnableSearch,
isCloudSandboxEnabled,
isLocalSystemEnabled,
isMemoryToolEnabled,
searchFCModel,
useModelBuiltinSearch,
};