Skip to main content
Features

Chat System

Multi-interface chat architecture — public widget, admin chat, Argonaut agent, and user workbench with streaming, model selection, and conversation persistence

February 23, 2026

Chat System

Arcturus-Prime has four chat interfaces sharing common streaming and persistence patterns, each targeting different users and capabilities.

Chat Interfaces

ChatWidget (Public)

PropertyValue
Filesrc/components/chat/ChatWidget.astro
EndpointPOST /api/public/chat
Modelgoogle/gemini-2.0-flash-001 (free via OpenRouter)
PersistencesessionStorage — last 20 messages, cleared on tab close
Rate limit15 requests/hour per IP

Floating panel in the bottom-right corner on all public pages. Features a welcome state with starter chips, RAG-powered answers using the top 5 matching chunks (min score 0.3), and live infrastructure data injection. Max 8 messages of history sent per request, max 1024 tokens per response.

Admin Chat

PropertyValue
Filesrc/pages/admin/chat.astro
EndpointGET/POST /api/admin/chat
ModelsFull catalog — Ollama, Anthropic, OpenAI, Google, Groq, NVIDIA NIM, OpenRouter
PersistencelocalStorage — up to 50 conversations

Full-featured interface with sidebar conversation list, model selector with categories (pricing tier, route type, context window), custom system prompt editor, and conversation search. Auto-titles conversations from the first message.

Sensitivity routing: Messages containing private topics (health, PII, legal, relationships, credentials) are automatically routed to groq/llama-3.3-70b-versatile for privacy-safe processing.

Argonaut Chat

PropertyValue
Filesrc/pages/admin/argonaut/chat.astro
EndpointPOST /api/argonaut/chat
BackendsArgonaut (default) + OpenClaw (toggle)
PersistencelocalStorage — up to 50 conversations

Advanced admin interface with two switchable backends:

  • Argonaut: Full agent with RAG, tool calling, and user profiles. Three-tier fallback: daemon proxy → local agent → cloud-only.
  • OpenClaw: Orchestration agent for automation tasks.

Extras: RAG mode toggle (Full: 85K chunks unsanitized vs Safe: 46K chunks blog-only), voice conversation mode with Whisper STT + ElevenLabs TTS, agentic tool indicators, and sources panel.

Registered tools (when daemon is available): Brave/DuckDuckGo search, Perplexity, file read/write/list, allowlisted shell commands, Resend email, Twilio voice/SMS, Google Calendar.

User Workbench Chat

PropertyValue
Filesrc/pages/api/user/chat.ts
EndpointPOST /api/user/chat
ModelsFree models only
PersistenceNone (API-only)

Portal user access with role-based permissions (portal:workbench). Restricted to the free model list. Supports custom system prompts.

Provider Routing

The admin chat endpoint resolves providers by model prefix:

PrefixProviderRequirement
ollama/Ollama (local)Ollama running on network
anthropic/Anthropic DirectANTHROPIC_API_KEY set
openai/OpenAI DirectOPENAI_API_KEY set
google/Google Gemini DirectGOOGLE_API_KEY set
groq/GroqGROQ_API_KEY set
nvidia-nim/NVIDIA NIMNVIDIA_NIM_API_KEY set
Everything elseOpenRouterOPENROUTER_API_KEY set

Unified Chat Router

POST /api/admin/unified-chat classifies user intent with a two-tier system (regex patterns first, Groq LLM fallback) and routes to the appropriate backend:

IntentBackendUse Case
brainRAG + knowledge lookupQuestions about the site or infrastructure
forgeTmux session dispatchCoding tasks
terminalforge-shell sessionShell commands
openclawOrchestration agentAgentic tool use
contentContent-specific promptsBlog/journal writing
privateGroq (privacy-safe)Sensitive topics

The mode parameter can override intent detection: code→forge, terminal→terminal, agent→openclaw.

Streaming Format

All endpoints use Server-Sent Events (SSE):

data: {"content": "text chunk"}
data: {"content": "more text"}
data: {"sources": [...]}
data: {"suggestions": [...]}
data: [DONE]

Client-side pattern:

  1. Fetch with AbortController for cancellation
  2. response.body.getReader() + TextDecoder for streaming
  3. Buffer lines, parse JSON from data: prefix
  4. Handle special events: [DONE], error, content, sources
  5. Update DOM incrementally with marked for markdown rendering
  6. Sanitize HTML output (strip scripts, iframes, event handlers)

Conversation Persistence

InterfaceStorageKeyLimit
ChatWidgetsessionStorageArcturus-Prime-chat-history20 messages
Admin ChatlocalStorageArcturus-Prime-chat-conversations50 conversations
ArgonautlocalStorageargonaut-conversations50 conversations

Each stored conversation includes: ID, title (auto-generated from first message), messages array, selected model, optional system prompt, and timestamps.

Key Files

FilePurpose
src/components/chat/ChatWidget.astroPublic floating widget
src/pages/admin/chat.astroAdmin chat interface
src/pages/admin/argonaut/chat.astroArgonaut advanced interface
src/pages/api/public/chat.tsPublic endpoint (free model + RAG)
src/pages/api/admin/chat.tsAdmin endpoint (multi-provider)
src/pages/api/admin/personal-chat.tsPrivate vault endpoint (Groq-only)
src/pages/api/admin/unified-chat.tsIntent-routing endpoint
src/pages/api/argonaut/chat.tsArgonaut daemon proxy
src/pages/api/user/chat.tsPortal user endpoint
chataistreamingopenrouterargonautopenclawllm