Skip to content

🤯 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.

605 B
Raw Blame
import { type BuiltinAgentSlug } from '@lobechat/builtin-agents';

import { useAgentStore } from '@/store/agent';
import { useUserStore } from '@/store/user';
import { authSelectors } from '@/store/user/selectors';

/**
 * If a targetAgentId is provided, use it to fetch the agent config directly.
 * Otherwise, use the active session id to fetch the config.
 */
export const useInitBuiltinAgent = (slug: BuiltinAgentSlug) => {
  const useInitBuiltinAgent = useAgentStore((s) => s.useInitBuiltinAgent);

  const isLogin = useUserStore(authSelectors.isLogin);

  useInitBuiltinAgent(slug, { isLogin });
};