Docyrus

Docyrus Agent

AI-powered conversational agent component with chat, action panel, and trigger modes.

Client Only

Installation

pnpm dlx @docyrus/cli add @docyrus/ui-docyrus-agent
Required Packages(2 packages)
pnpm add ai zod
UI Primitives(9 components)
npx shadcn@latest add avatar badge button input label select switch textarea tooltip
AI Elements(6 components)
npx shadcn@latest add @ai-elements/conversation @ai-elements/message @ai-elements/prompt-input @ai-elements/reasoning @ai-elements/suggestion @ai-elements/tool

Usage

Chat Mode

The default chat interface with message history, streaming responses, reasoning steps, tool calls, and suggestions.

import { useChat } from 'ai/react';

import {
  DocyrusAgent
} from '@/components/docyrus/docyrus-agent';
import type {
  AgentProfile,
  AgentMessagePayload
} from '@/components/docyrus/docyrus-agent';

const agent: AgentProfile = {
  name: 'My Assistant',
  description: 'AI-powered helper',
  avatar: { color: '#6366f1', name: 'MA' }
};

function ChatExample() {
  const { messages, status, append, stop } = useChat({
    api: '/api/chat'
  });

  const handleSend = (payload: AgentMessagePayload) => {
    void append({ role: 'user', content: payload.text });
  };

  return (
    <DocyrusAgent
      mode="chat"
      agent={agent}
      messages={messages}
      chatStatus={status}
      onSendMessage={handleSend}
      onStopGeneration={stop}
      allowAttachments
      suggestions={['Summarize this document', 'Draft an email']}
    />
  );
}

Trigger Mode

Compact card with inline input that opens a dialog for the full chat experience.

import {
  DocyrusAgentTrigger
} from '@/components/docyrus/docyrus-agent';

<DocyrusAgentTrigger
  agent={agent}
  messages={messages}
  chatStatus={status}
  onSendMessage={handleSend}
  onStopGeneration={stop}
  dialogContainer="sheet"
  dialogSide="right"
  dialogSize="lg"
/>

Action Panel Mode

Pre-defined actions with parameter forms — useful for structured agent workflows (e.g. "Generate Report", "Send Email").

import type { AgentAction, AgentActionPayload } from '@/components/docyrus/docyrus-agent';

const actions: AgentAction[] = [
  {
    id: 'summarize',
    label: 'Summarize Document',
    description: 'Create a concise summary',
    params: [
      { name: 'length', label: 'Length', type: 'select', options: [
        { label: 'Short', value: 'short' },
        { label: 'Medium', value: 'medium' },
        { label: 'Detailed', value: 'detailed' }
      ]}
    ]
  },
  {
    id: 'translate',
    label: 'Translate',
    description: 'Translate text to another language',
    params: [
      { name: 'text', label: 'Text', type: 'textarea', required: true },
      { name: 'language', label: 'Target Language', type: 'text', placeholder: 'e.g. Turkish' }
    ]
  }
];

const handleExecute = (payload: AgentActionPayload) => {
  console.log('Action:', payload.actionId, 'Params:', payload.params);
};

<DocyrusAgent
  mode="action-panel"
  agent={agent}
  actions={actions}
  onExecuteAction={handleExecute}
/>

With Sources

Attach contextual data (documents, JSON schemas, files) to the agent conversation.

import type { AgentSource } from '@/components/docyrus/docyrus-agent';

const sources: AgentSource[] = [
  { type: 'json-schema', label: 'Contact Schema', value: JSON.stringify(schema) },
  { type: 'pdf', label: 'Q4 Report', value: 'https://...', mimeType: 'application/pdf' }
];

<DocyrusAgent
  mode="chat"
  agent={agent}
  sources={sources}
  messages={messages}
  chatStatus={status}
  onSendMessage={handleSend}
/>

API Reference

DocyrusAgent

PropTypeDefaultDescription
mode'chat' | 'action-panel' | 'trigger'—Required. Component display mode.
agentAgentProfile—Required. Agent identity — name, description, avatar, model.
messagesArray<UIMessage>[]Chat message history (from Vercel AI SDK useChat).
chatStatusChatStatus—Stream status: 'ready', 'streaming', 'submitted', 'error'.
actionsArray<AgentAction>[]Pre-defined actions shown in action panel mode.
sourcesArray<AgentSource>[]Contextual data attached to the conversation.
onSendMessage(payload: AgentMessagePayload) => void | Promise<void>—Called when user sends a message.
onStopGeneration() => void—Called when user stops generation.
onExecuteAction(payload: AgentActionPayload) => void | Promise<void>—Called when user executes an action.
allowAttachmentsbooleanfalseShow file attachment button in chat input.
acceptFileTypesstring—Accepted file MIME types (e.g. 'image/*,.pdf').
suggestionsArray<string>[]Quick-reply suggestions shown in empty state.
emptyStateReactNode—Custom empty state. Defaults to agent name + icon.
showMessageActionsbooleantrueShow copy button on assistant messages.
classNamestring—Additional CSS classes.

DocyrusAgentTrigger

Extends all DocyrusAgent props (except mode) with:

PropTypeDefaultDescription
openboolean—Controlled open state.
onOpenChange(open: boolean) => void—Called when dialog open state changes.
dialogContainer'modal' | 'sheet' | 'drawer''sheet'Dialog container type.
dialogSide'left' | 'right' | 'top' | 'bottom''right'Sheet/drawer side.
dialogSize'sm' | 'default' | 'lg' | 'xl' | 'full''lg'Dialog size.

Components

ComponentDescription
DocyrusAgentMain component — renders chat or action panel based on mode prop.
DocyrusAgentTriggerCompact card with inline input → opens dialog with full chat.
DocyrusAgentProviderContext provider — use to build custom layouts with agent sub-components.
DocyrusAgentChatFull chat layout (header + messages + input).
DocyrusAgentChatMessagesMessage list with reasoning, tool calls, and suggestions.
DocyrusAgentChatInputRich input with file attachments and submit/stop button.
DocyrusAgentHeaderAgent avatar + name + description header bar.
DocyrusAgentActionPanelAction list → parameter form → execution flow.
DocyrusAgentActionListSelectable action cards.
DocyrusAgentActionParamsDynamic parameter form for selected action.

Type Exports

TypeDescription
DocyrusAgentPropsProps for DocyrusAgent component.
DocyrusAgentTriggerPropsProps for DocyrusAgentTrigger component.
DocyrusAgentContextValueContext value — access via useDocyrusAgent() hook.
AgentProfileAgent identity (name, description, avatar, model).
AgentMode'chat' | 'action-panel' | 'trigger'
AgentActionAction definition with params.
AgentActionParamIndividual action parameter definition.
AgentActionPayloadPayload sent when executing an action.
AgentMessagePayloadPayload sent when sending a message.
AgentSourceContextual data source attached to conversation.
AgentSourceType'text' | 'json' | 'image' | 'pdf' | 'json-schema' | 'file' | 'custom'
ActionPanelView'action-list' | 'action-params' | 'executing'

Type Reference

AgentProfile

FieldTypeDescription
namestringAgent display name.
descriptionstringShort description shown below name.
avatar{ name?: string; color?: string; icon?: string; image?: string }Avatar configuration — color for background, image for custom avatar.
modelstringAI model identifier (informational).

AgentAction

FieldTypeDescription
idstringUnique action identifier.
labelstringDisplay label for the action card.
descriptionstringShort description shown below label.
iconReactNodeIcon displayed on the action card.
paramsArray<AgentActionParam>Parameters shown in the form when action is selected.
isDefaultbooleanIf true, auto-selects this action on mount.
opensChatbooleanIf true, switches to chat mode after execution.

AgentActionParam

FieldTypeDescription
namestringParameter key in the payload.
labelstringDisplay label for the form field.
type'text' | 'textarea' | 'number' | 'boolean' | 'select'Input type.
requiredbooleanWhether the field is required.
defaultValuestring | number | booleanInitial value.
placeholderstringPlaceholder text.
optionsArray<{ label: string; value: string }>Options for select type.
descriptionstringHelp text shown below the field.

AgentSource

FieldTypeDescription
typeAgentSourceTypeSource type — determines how the data is interpreted.
labelstringDisplay label for the source badge.
valuestringSource content or URL.
mimeTypestringMIME type for file-based sources.
metaRecord<string, unknown>Additional metadata.

AgentMessagePayload

FieldTypeDescription
textstringMessage text content.
filesArray<FileUIPart>Attached files (from Vercel AI SDK).
sourcesArray<AgentSource>Context sources included with the message.
actionIdstringAction ID if message originated from an action.
actionParamsRecord<string, string | number | boolean>Action parameters if from action execution.

AgentActionPayload

FieldTypeDescription
actionIdstringExecuted action ID.
paramsRecord<string, string | number | boolean>User-provided parameter values.
sourcesArray<AgentSource>Context sources included with the action.
customPromptstringAdditional user prompt text.

On this page