How chatsci/aeiva works
1. Repository shape
- This is a Python agent platform with a single core package (src/aeiva) and several interaction surfaces around it.
- The architecture is centered on a reusable agent runtime, not a single app: terminal chat, Gradio web UI, Slack, WhatsApp, realtime audio/text, browser automation, and a LifeRPG-style personal model all connect to the same core.
2. Primary runtime entrypoints
- The command layer under src/aeiva/command is the top-level orchestration boundary.
- Key entrypoints include aeiva_gateway, aeiva_server, aeiva_chat_terminal, aeiva_chat_gradio, aeiva_chat_slack, aeiva_chat_whatsapp, aeiva_chat_realtime, and aeiva_dialogue_replay.
- These commands select a channel, load config, wire services together, and hand off to the agent runtime.
3. Channel adapters and external interfaces
- src/aeiva/interface and parts of src/aeiva/command implement gateway adapters for terminal, Slack, and WhatsApp.
- The current product shape also includes a web dialogue UI and a separate LifeRPG UI, both exposed by the unified gateway.
- This makes the channel layer a thin boundary: it receives user input, normalizes it, and forwards it to the core agent; responses flow back through the same adapter.
4. Core agent / cognition pipeline
- The conceptual center is the agent, cognition, perception, action, and tool packages.
- perception ingests raw stimuli from sensors such as terminal input, audio streams, and video streams.
- cognition turns those stimuli into internal state: input interpretation, brain, emotion, goal, thought, reward, world model, memory, and mind manager.
- action represents what the system decides to do: plans, steps, procedures, tasks, skills, statuses, and actuators.
5. LLM abstraction and model backends
- src/aeiva/llm provides the model boundary: client logic, provider registry, API handlers, tool-loop support, fault tolerance, and usage metrics.
- Providers are pluggable, with at least a LiteLLM-based provider and a local MiniCPM provider.
- This layer isolates the rest of the system from model-specific APIs and enables both remote and local inference.
6. Tooling and execution boundary
- src/aeiva/tool is the execution substrate for external actions.
- It includes core tools such as calculator, web search, filesystem, and shell, plus a meta browser tool for more complex web interaction.
- The tool registry and decorator system imply a capability-based design: the agent can only invoke tools that are registered and approved.
7. Browser automation subsystem
- The browser stack under src/aeiva/tool/meta/browser_stack is a substantial subsystem on its own.
- It includes runtime launch, session management, snapshot/scroll/interaction scripts, element matching, target resolution, form filling, security, and service dispatch layers.
- Architecturally, this is the web-execution engine for tasks like navigation, extraction, and form automation, with strong separation between runtime state and higher-level service actions.
8. Memory and storage
- src/aeiva/cognition/memory handles agent memory behavior: raw memory, summary memory, memory organization/cleaning, storage, links, and service/config layers.
- src/aeiva/storage provides concrete persistence backends: SQLite, Chroma, and KuzuDB, all behind shared database abstractions.
- This creates a layered persistence model: cognition-level memory logic sits above storage engines, which can be swapped based on the workload.
9. Realtime multimodal path
- src/aeiva/realtime is the dedicated path for low-latency audio/text interaction.
- It contains provider abstractions for OpenAI and MiniCPM live models, plus WebRTC/FastRTC integration, response strategy, pause handling, and live UI builder/capabilities.
- This path is separate from the normal turn-based chat flow, which matters for diagrams because realtime interaction has its own transport and model orchestration.
10. Host, policy, and safety boundaries
- src/aeiva/host defines the host-side control plane: CLI, daemon, router, runner, protocol, approval policy, and command policy.
- src/aeiva/tool/meta/exec_approval.py and browser security modules suggest explicit approval gating for sensitive actions.
- In architecture terms, the host layer mediates between user-facing channels and privileged execution, enforcing command/approval rules.
11. LifeRPG and social modeling
- src/aeiva/liferpg, src/aeiva/society, and src/aeiva/ecs provide structured self-modeling and social/persona abstractions.
- The README describes LifeRPG as a separate UI for identity, roles, inventory, projects, and TODOs.
- These packages represent a domain model layered alongside conversation: the agent is not only answering text, but also maintaining a persistent life/identity graph.
12. Sandbox, plugins, and extension surfaces
- src/aeiva/sandbox is an isolated Docker-based execution environment for running tasks safely.
- src/aeiva/plugin includes plugin abilities and a VS Code daemon/adapter, showing that Aeiva can embed into editor workflows.
- This is important architecturally because execution is intentionally split into trusted core, sandboxed execution, and host/editor integrations.
13. Eventing, state, and lower-level runtime primitives
- src/aeiva/event, neuron, mas, environment, and embedding provide supporting runtime primitives rather than user-facing features.
- The event bus, scheduler, signal/state/validation layers, and environment abstractions suggest an internal asynchronous coordination model.
- These packages likely serve as glue between cognition, tools, and execution, especially where multi-step workflows need stateful coordination.
14. Quality, evaluation, and documentation
- The .reports directory and tests package indicate a strong emphasis on replayable evaluation and regression testing, especially for dialogue and browser-related behavior.
- src/aeiva/testing/dialogue_replay.py and the README’s replay command show that real conversation scenarios are treated as first-class test artifacts.
- Documentation lives under docs/ and is extensive enough to support architecture, design plans, and operational guidance.
15. Main data flow to capture in a diagram
- User input enters through a channel adapter or sensor.
- It is interpreted by cognition, which consults memory, world model, goals, and current state.
- The agent decides on an action or tool call, possibly invoking LLM providers and external tools.
- Results are persisted back into memory/storage and returned through the originating channel.
- For realtime or browser-heavy tasks, the flow detours through dedicated realtime or browser subsystems before returning to the core loop.
Main entry points: cognition Cognition · tool Tools · action Action · aeiva_gateway.py Gateway
Components 19
Core runtime
Agent cognition, action, and perception pipeline.
- Agent · Reusable agent runtime that ties the system together.
src/aeiva/agent - Perception · Sensors and stimulus normalization for input streams.
src/aeiva/perception - Cognition · Interpretation, brain, emotion, goal, thought, reward, world model, and mind management.
src/aeiva/cognition - Action · Plans, tasks, skills, procedures, steps, and statuses.
src/aeiva/action
Interfaces
User-facing channels and gateway entrypoints.
- Commands · Top-level orchestration and CLI entrypoints.
src/aeiva/command - Gateway · Unified channel selection and wiring boundary.
src/aeiva/command/aeiva_gateway.py - Adapters · Terminal, Slack, and WhatsApp gateway adapters.
src/aeiva/interface - Host ctrl · Host-side daemon, router, protocol, and approval policy.
src/aeiva/host
Model layer
LLM and realtime model orchestration.
- LLM gateway · Client, API handlers, provider registry, tool loop, and metrics.
src/aeiva/llm - Realtime · Low-latency audio/text path with live providers and WebRTC.
src/aeiva/realtime
Execution
Tooling, browser automation, sandboxing, and approval.
- Tools · Capability registry and approved tool execution surface.
src/aeiva/tool - Browser stack · Browser runtime, session, interaction, targeting, and service dispatch.
src/aeiva/tool/meta/browser_stack - Approval · Sensitive-action approval and execution gating.
src/aeiva/tool/meta/exec_approval.py - Sandbox · Docker-based isolated task execution environment.
src/aeiva/sandbox
State
Memory, storage, and domain models.
- Memory · Raw, summary, organization, cleaning, linking, and memory service layers.
src/aeiva/cognition/memory - Storage · SQLite, Chroma, and KuzuDB persistence behind shared database abstractions.
src/aeiva/storage - LifeRPG · Identity, roles, inventory, projects, and TODOs domain model.
src/aeiva/liferpg - Society · Persona and social-system abstractions.
src/aeiva/society - ECS · Entity-component-style structured state model.
src/aeiva/ecs
Connections 20
- Commands → Gateway: launches · Command entrypoints select a mode and wire services.
- Gateway → Adapters: routes · Gateway dispatches to the active channel adapter.
- Gateway → Host ctrl: coordinates · Host control plane mediates runtime and policy.
- Adapters → Perception: inputs · Channel adapters feed normalized user stimuli.
- Perception → Cognition: stimuli · Perception hands interpreted input to cognition.
- Cognition → Memory: reads/writes · Cognition consults and updates memory structures.
- Memory → Storage: persists · Memory logic stores data through backend databases.
- Cognition → LLM gateway: consults · Reasoning and interpretation can call the model boundary.
- Cognition → Action: decides · Cognition produces plans and executable intent.
- Action → Tools: invokes · Planned work uses registered tools and capabilities.
- Tools → Browser stack: delegates · Meta browser tool uses the browser automation engine.
- Tools → Sandbox: isolates · Some actions execute in the sandbox boundary.
- Tools → Approval: checks · Sensitive actions require approval before execution.
- LLM gateway → Realtime: live path · Realtime providers and response strategy handle live interaction.
- Realtime → Adapters: streams back · Live audio/text responses return through the originating surface.
- Action → Host ctrl: policy · Host rules constrain command and execution behavior.
- Browser stack → Approval: secure ops · Browser automation includes explicit security gating.
- Cognition → LifeRPG: self model · Identity and life-state feed higher-level cognition.
- Cognition → Society: persona · Social modeling informs response and behavior.
- Cognition → ECS: structured state · Entity-centric modeling supports internal state organization.