import { markAgentChatHomeHandoff, navigateWithAgentChatViewTransition, } from "@agent-native/core/client/agent-chat"; import { createAgentNativeAgentKitTransport } from "@agent-native/core/client/agentkit-chat/transport"; import { useT } from "@agent-native/core/client/i18n"; import { AgentKitComposer } from "@agent-native/toolkit/app/agentkit/react/components"; import { useAgentKitControl } from "@agent-native/toolkit/app/agentkit/react/context"; import { CoreComposerRuntimeProvider } from "@agent-native/toolkit/app/chat/agentkit-chat/composer"; import { CoreAgentKitRoot } from "@agent-native/toolkit/app/chat/agentkit-chat/index"; import { useRealtimeVoiceModeOptional } from "@agent-native/toolkit/app/chat/composer"; import { WaveBackground } from "@agent-native/toolkit/app/shared"; import { AgentNativeIcon } from "@agent-native/toolkit/app/shared/AgentNativeIcon"; import { IconBook, IconBrandDiscord, IconBrandGithub, IconUsers, } from "@tabler/icons-react"; import { useState, type ReactNode } from "react"; import { useNavigate } from "react-router"; import { Button } from "@/components/ui/button"; import { Item, ItemContent, ItemFooter, ItemMedia, ItemTitle, } from "@/components/ui/item"; import { Separator } from "@/components/ui/separator"; import { getChatHomeThreadId } from "@/lib/chat-home-thread"; import { chatHandoffComposerOptions, chatThreadPath, type ChatInitialComposerOptions, type ChatRouteState, } from "@/lib/chat-paths"; import { TAB_ID } from "@/lib/tab-id"; const DOCS_URL = "https://www.agent-native.com/docs"; const GITHUB_URL = "https://github.com/BuilderIO/agent-native"; const DISCORD_URL = "https://discord.gg/qm82StQ2NC"; /** * The same AgentKit composer the chat page uses, so Connect AI and the model * picker look the way they will in chat. Submitting hands the prompt to the * full chat page instead of running it here, and voice chat continues there. */ function HomeAgentComposer() { const navigate = useNavigate(); const realtimeVoice = useRealtimeVoiceModeOptional(); const [threadId] = useState(getChatHomeThreadId); const [transport] = useState(() => createAgentNativeAgentKitTransport({ browserTabId: TAB_ID, surface: "app", adapter: { textFormat: "markdown" }, }), ); function openChat( message: string, options: ChatInitialComposerOptions, onLocalSubmit?: () => void, ) { const state: ChatRouteState = { initialMessage: message, initialComposerOptions: options, }; markAgentChatHomeHandoff("chat"); navigateWithAgentChatViewTransition(navigate, chatThreadPath(threadId), { state, }); onLocalSubmit?.(); } function startVoiceChat() { // Home shows no transcript, so the session is bound to the thread it // opens rather than to whichever thread is on screen when it starts. void realtimeVoice?.start({ threadId }); markAgentChatHomeHandoff("chat"); navigateWithAgentChatViewTransition(navigate, chatThreadPath(threadId)); } return (
); } function HomeAgentComposerInput({ threadId, onSubmit, onVoiceChatStart, }: { threadId: string; onSubmit: ( text: string, options: ChatInitialComposerOptions, onLocalSubmit?: () => void, ) => void; onVoiceChatStart: () => void; }) { const t = useT(); const control = useAgentKitControl(threadId); return ( { const uploadedAttachments = files.length ? await control.uploadFiles( files.map((file) => ({ name: file.name, mediaType: file.type || "application/octet-stream", size: file.size, body: file, })), ) : []; onSubmit( text, chatHandoffComposerOptions(options, { references, ...(uploadedAttachments.length ? { uploadedAttachments } : {}), }), options.onLocalSubmit, ); }} /> ); } function ResourceLink({ href, icon, children, }: { href: string; icon?: ReactNode; children: ReactNode; }) { return ( ); } function ResourceColumn({ icon, title, children, }: { icon: ReactNode; title: string; children: ReactNode; }) { return (
{icon} {title} {children}
); } export default function HomePage() { const t = useT(); return (
} title={t("home.docsTitle")}> {t("home.docsGettingStarted")} {t("home.docsAddAction")} {t("home.docsAddPage")} {t("home.docsKeyConcepts")} } title={t("home.communityTitle")}> }> GitHub }> Discord
); }