# Editor Agent URL: /docs/web/components/editor-agent Editor Agent component. **Demo:** ```tsx 'use client'; import { useEffect, useMemo, useState } from 'react'; import { type EditorAgentClient, EditorAgent } from '@docyrus/ui/components/editor-agent'; import { Button } from '@docyrus/ui/primitives/ui/button'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { Bot } from 'lucide-react'; /* * EditorAgent is auth-aware — it needs an authenticated REST `client`, the * current `user`, an `apiBaseUrl`, and a `getAccessToken` callback. The docs * site has none of those, so this demo wires a no-op client that satisfies * the type contract and returns empty payloads. The drawer renders, threads * load empty, and `sendMessage` is a noop — perfect for visual exploration. * * For real wiring (auth + chat), see the docyrus-client integration in * `developer-tools-ai-assistant.tsx` (project repo) where `@docyrus/signin` * supplies `client`, `user`, and `getAccessToken`. */ const DEMO_API_BASE = 'https://api.docyrus.example/v1'; const DEMO_CHAT_URL = `${DEMO_API_BASE}/ai/agents/demo-agent-id/chat`; const DEMO_AGENT_ENVELOPE = { id: 'demo-agent-id', name: 'Docyrus AI', description: 'Your intelligent document assistant', avatar: { name: 'Docyrus AI', color: '#6366f1' } }; const DEMO_ASSISTANT_REPLY = 'This is a simulated response. In a real application, this would be powered by a language model via the Vercel AI SDK `useChat` hook.'; function buildMockChatStream(): Response { const encoder = new TextEncoder(); const id = 'demo-msg'; const events = [ { type: 'start' }, { type: 'start-step' }, { type: 'text-start', id }, { type: 'text-delta', id, delta: DEMO_ASSISTANT_REPLY }, { type: 'text-end', id }, { type: 'finish-step' }, { type: 'finish' } ]; const stream = new ReadableStream ); } function EditorAgentDemoInner() { const [open, setOpen] = useState(false); const client = useStubClient(); useMockChatFetch(); return (
Imagine a JSONata expression editor, a Handlebars template, or a Query Builder rendered here. The assistant slides in from the left and shares the same surface area.