|
| 1 | +import { agnoStorage, createAgnoLLM } from "@openuidev/agno"; |
| 2 | +import { AgentInterface } from "@openuidev/react-ui"; |
| 3 | +import { ExternalLinkIcon } from "lucide-react"; |
| 4 | +import { library } from "./library"; |
| 5 | + |
| 6 | +declare const __AGNO_BACKEND_MODE__: "real" | "mock"; |
| 7 | + |
| 8 | +const isRealAgentOS = __AGNO_BACKEND_MODE__ === "real"; |
| 9 | +const DEMO_USER_ID = isRealAgentOS ? "openui-live-demo" : "openui-demo-user"; |
| 10 | +const AGENT_ID = "openui-assistant"; |
| 11 | +const AGENT_OS_URL = "https://os.agno.com"; |
| 12 | + |
| 13 | +const llm = createAgnoLLM({ |
| 14 | + url: "/agui", |
| 15 | + forwardedProps: { user_id: DEMO_USER_ID }, |
| 16 | +}); |
| 17 | + |
| 18 | +const storage = agnoStorage({ |
| 19 | + baseUrl: "", |
| 20 | + entityType: "agent", |
| 21 | + entityId: AGENT_ID, |
| 22 | + userId: DEMO_USER_ID, |
| 23 | +}); |
| 24 | + |
| 25 | +const starters = [ |
| 26 | + { |
| 27 | + displayText: "Use an Agno tool", |
| 28 | + prompt: "Use the stored quarterly revenue and show it as a chart with two useful follow-ups.", |
| 29 | + }, |
| 30 | + { |
| 31 | + displayText: "Collect structured input", |
| 32 | + prompt: "Create a validated project estimate form with project name, team size, and notes.", |
| 33 | + }, |
| 34 | +]; |
| 35 | + |
| 36 | +const agentOSSessionUrl = (sessionId: string) => { |
| 37 | + const url = new URL(`/sessions/${encodeURIComponent(sessionId)}`, AGENT_OS_URL); |
| 38 | + url.searchParams.set("sort_by", "updated_at_desc"); |
| 39 | + url.searchParams.set("type", "all"); |
| 40 | + url.searchParams.set("page", "1"); |
| 41 | + url.searchParams.set("limit", "25"); |
| 42 | + return url.toString(); |
| 43 | +}; |
| 44 | + |
| 45 | +export default function App() { |
| 46 | + return ( |
| 47 | + <AgentInterface |
| 48 | + llm={llm} |
| 49 | + storage={storage} |
| 50 | + componentLibrary={library} |
| 51 | + agentName="Agno × OpenUI" |
| 52 | + getThreadMenuActions={({ id, isRunning }) => |
| 53 | + !isRealAgentOS || isRunning |
| 54 | + ? [] |
| 55 | + : [ |
| 56 | + { |
| 57 | + id: "open-in-agentos", |
| 58 | + label: "Open in AgentOS", |
| 59 | + icon: <ExternalLinkIcon size="1em" />, |
| 60 | + href: agentOSSessionUrl(id), |
| 61 | + target: "_blank", |
| 62 | + rel: "noopener noreferrer", |
| 63 | + }, |
| 64 | + ] |
| 65 | + } |
| 66 | + starterVariant="short" |
| 67 | + starters={starters} |
| 68 | + > |
| 69 | + <AgentInterface.Welcome |
| 70 | + title="OpenUI handles the UI. AgentOS handles everything else." |
| 71 | + description={ |
| 72 | + isRealAgentOS |
| 73 | + ? "Connected to a live AgentOS and model. Try a backend Agno tool or ask for an interactive interface." |
| 74 | + : "Try a backend Agno tool or an interactive form. The local harness is deterministic and needs no model key." |
| 75 | + } |
| 76 | + /> |
| 77 | + </AgentInterface> |
| 78 | + ); |
| 79 | +} |
0 commit comments