Recent context
Keeps the latest messages of the current session, serving quotes, follow-ups and continuous conversation first.
Internals
Platform adapters only send and normalise. The assistant runtime owns the decisions, models and tools run inside explicit permissions, and SQLite holds recoverable state.
Architecture
| Directory | Responsibility |
|---|---|
cmd/webui/ | Process entry point, environment assembly, SQLite and runtime dependency injection. |
model/assistant/ | Message events, channels, reply decisions, agent, media, memory and tasks. |
model/llm/ | Unified requests, provider adapters, model catalogue, token budget and retries. |
model/storage/ | Schema and persistence for configuration, messages, events, memory and tasks. |
webui/ | Gin API, authentication, configuration, events, updates and SSE. |
frontend-next/ | The Vue 3 admin console. |
Pipeline
The platform adapter turns text, mentions, quotes, images, files and sender details into a single MessageEvent.
Quotes, forwards and media references are resolved, and short-lived platform images are written into the local history media cache.
Checks whether the bot and group are enabled, the reply window, muted users, member level and bot-to-bot suppression.
Direct messages are handled directly; groups look for explicit mentions, quotes, trigger words and plugin commands. An explicit mention outranks a quote.
Ordinary group messages that were not directly triggered are judged immediately by the intent model, waiting at most 60 seconds so nothing queues forever.
Combines the system prompt, relationships, long-term memory, recent history, images and tool evidence, trimmed to the token budget.
Selects the chat or vision role; the agent runs the permitted tools and records every step.
The reply goes back to the source channel, and the detailed reason, send result, latency and tokens are all persisted.
Memory
Keeps the latest messages of the current session, serving quotes, follow-ups and continuous conversation first.
Once history passes a threshold, topics, conclusions and open items are distilled to cut repeated tokens.
Stable facts, preferences and relationships are extracted asynchronously with their source, confidence and update time.
Searchable by time, keyword, user, group and platform; cross-group and cross-channel access are gated by separate switches.
Retrieval narrows with structured filters first, then ranks by textual relevance and time decay, and finally passes the model only the matching evidence. Summaries are not recomputed when configuration reloads — they expire only when the input history changes or the summary version is bumped.
Multimodal
Storage
| Data | Default location | Backup requirement |
|---|---|---|
| Configuration, credentials, sessions, messages, memory, tasks | data/diana.db | Must be backed up, keeping the main database consistent with WAL/SHM. |
| Inbound media | data/media | Can be evicted by size; back it up when historical image recognition matters. |
| Runtime logs | logs/diana.log | Rotate regularly; never publish platform events or debug context. |
| Install and update backups | .installer/backups, .diana-updates | Keep the last known-good version and the evidence needed to restore it. |