Skip to main content

Brain matrix CLI: one integrated mind (emotional, logical, memory, inspiration, consciousness). SOUL, MEMORY, USER, TOOLS. Not a conventional agent framework.

Project description

Cerebrain!!!

PyPI version PyPI - Downloads Python License: MIT

GitHub: github.com/shuurai/cerebrain

Terminal-based brain matrix CLI: five parts (emotional, logical, memory, inspiration, consciousness) working as one. SOUL, MEMORY, USER, TOOLS. Init-before-use, simple terminal chat, self-awareness with live state, default self-skills (internal APIs), and HTTP/WebSocket API for integration (e.g. Nanobot, OpenClawd).

News

  • 0.3.x — Brain matrix identity and live state in system prompt; default self-skills (get_mood, get_memory_*, spark_inspiration, get_pulse, get_consciousness_state, get_thought_stream); simple terminal chat with boot messages and concise replies; tool-call handling for skills. Not a conventional agent framework.

Install

On PyPI the package is cerebrain (the name cerebrain is taken). The CLI command is cerebrain.

# PyPI
pip install cerebrain

# uv
uv tool install cerebrain

# From source
git clone https://github.com/shuurai/cerebrain.git && cd cerebrain
pip install -e .

Platforms: Linux, macOS. Python 3.11+.

Test locally without installing

cd cerebrain
pip install typer rich pyyaml requests httpx
PYTHONPATH=. python -m cerebrain --help
PYTHONPATH=. python -m cerebrain init --name dev --llm openrouter
PYTHONPATH=. python -m cerebrain chat

Or with a venv: python -m venv .venv, source .venv/bin/activate, then the same pip install and PYTHONPATH=. python -m cerebrain .... Editable install (pip install -e .) gives you the cerebrain command on your PATH.

Quick start

  1. Initialize (required before first use):

    cerebrain init
    

    You’ll be prompted for: brain name, LLM provider (openrouter, openai, anthropic, ollama, local), API key (when needed), model, max tokens, temperature, server port, and Soul (traits, values, communication style → SOUL.md). Config is written to ~/.cerebrain/config.yaml.

  2. Chat (simple terminal; boot messages then prompt/response):

    cerebrain chat
    cerebrain chat --brain my-brain --no-visual
    

    On start you see “Booting ….” and “Loading into Cerebra Matrix Terminal ….” then a normal chat loop. Replies are kept short (terminal / ship-computer style).

  3. API server (for Nanobot / OpenClawd). Port from config or 17971:

    cerebrain serve
    cerebrain serve --port 17971
    

    HTTP: POST /v1/chat with {"content": "..."}. WebSocket: ws://host:17971/v1/stream — send {"content": "..."}, receive {"reply": "..."}; one agent per connection. Requires FastAPI/uvicorn for full server features.

  4. Other commands:

    cerebrain status
    cerebrain list
    cerebrain diagnose --brain my-brain
    cerebrain export --brain my-brain --format json
    

Architecture

Cerebra is a brain matrix: one integrated mind made of five cooperating parts, not a single “agent” or a standard tool-calling pipeline.

Part Role
Emotional self Mood state; influences tone and presence.
Logical self LLM reasoning; handles language and inference.
Memory Short-term turns + optional long-term vector store (ChromaDB).
Inspiration Randomness/sparks; can perturb or enrich outputs.
Consciousness Integration layer; pulse/heartbeat and stream activity.

Four pillars define the mind’s content and tools:

  • SOUL — Identity, values, communication style (set at init; stable).
  • MEMORY — Short- and long-term context (grows with use).
  • USER — User context and preferences (adaptive).
  • TOOLS — Descriptions and use of tools (from workspace; adaptive).

Everything is init-before-use: config and SOUL live under ~/.cerebrain/; each brain has its own state.

Inner mechanism

  • System prompt is built from: SOUL, USER, TOOLS, relevant long-term memory, a brain matrix description (what Cerebra is), current state (live) (mood, memory counts, inspiration, pulse, stream activity), self-skills (internal APIs), and response style (short, terminal-like).
  • Live state is updated as you chat (mood, pulse, memory, inspiration) so Cerebra can refer to “right now” in answers.
  • Self-skills are internal APIs (e.g. get_mood, get_memory_recall, spark_inspiration, get_pulse). They are listed in the prompt and callable via agent.run_skill(...); when the model emits a tool call, the runner executes the skill and injects the result back into the flow.
  • Response style is kept to 1–3 short sentences, minimal preamble, like a terminal or ship computer.

So: one orchestrated “mind” with a fixed structure (five parts, four pillars), but with stateful, observable internals and self-awareness.

Experiment value (why and how)

  • Why: Most CLIs wrap a single LLM call or a standard agent loop. Cerebra is an explicit brain matrix: emotional, logical, memory, inspiration, and consciousness are first-class. That gives you a lab for personality (SOUL), context (MEMORY, USER), and variability (inspiration, pulse) without treating the backend as a generic agent.
  • How: Change SOUL at init to get different “persons”; use memory (short-term + optional ChromaDB) to test persistence and recall; trigger inspiration and watch pulse/consciousness to see how non-determinism and internal state affect replies. Use self-skills and the live state line to ask Cerebra about its own mood, memory, or stream activity. The terminal and HTTP/WebSocket APIs let you drive and observe the matrix from scripts or other tools (e.g. Nanobot, OpenClawd).

How it works

  • Brain matrix: One agent orchestrates five parts: Emotional self (mood), Logical self (LLM reasoning), Memory (short-term turns + optional ChromaDB long-term), Inspiration (randomness/sparks), Consciousness (integration; influenced by a pulse/heartbeat). The system prompt always includes a description of this and a live state line (mood, memory counts, inspiration, pulse, stream activity) so Cerebra can answer about itself and its current state.

  • System prompt: Built from SOUL (identity), USER (context), TOOLS (from workspace TOOLS.md), relevant long-term memory, brain matrix (what you are), current state (live), self skills (internal APIs), and a response style (1–3 short sentences, terse, terminal-style).

  • Self-skills (internal APIs): Cerebra has default skills that interact with its own state. They are listed in the prompt and callable via agent.run_skill(name, **kwargs) (e.g. from your code or future tool-calling). Default skills:

    • get_mood — Current emotional/mood state.
    • get_memory_summary — Short-term and long-term memory counts.
    • get_memory_recall — Query long-term memory (query, k).
    • spark_inspiration — Trigger inspiration engine once; returns a spark if any.
    • get_pulse — Current heartbeat/pulse (0..1).
    • get_consciousness_state — Activity levels of all streams.
    • get_thought_stream — Recent thought lines from a stream (stream, n).

    Skills are defined in cerebrain/core/self_skills.py; the agent can describe them and use results when tool-calling is enabled.

  • Response style: Replies are kept concise (1–3 sentences, minimal words, no preamble), like a terminal or ship computer.

Project layout

  • cerebrain/core/ — Brain agent (orchestration), emotional self, logical self (LLM), memory (short-term + optional ChromaDB long-term), inspiration engine, self_skills (default internal APIs), consciousness (stub).
  • cerebrain/cli/ — Typer CLI (init, chat, serve, status, list, diagnose, export).
  • cerebrain/ui/ — Terminal chat UI (simple loop); optional buffer/managers code parked for future fancy terminal.
  • cerebrain/api/ — HTTP server (POST /v1/chat, WebSocket /v1/stream).
  • cerebrain/scripts/ — Init wizard, diagnostics.
  • cerebrain/utils/ — Config, persistence, natural randomness (ANU/random.org fallback).

Optional: pip install cerebrain[chromadb] for long-term vector memory (self-contained ChromaDB).

Data and config: ~/.cerebrain/ (workspace, brain_states, config.yaml).

Configuration

Config: ~/.cerebrain/config.yaml. After cerebrain init it contains all supported keys. Example:

default_brain: default
server:
  port: 17971
llm_defaults:
  max_tokens: 8192
  temperature: 0.7
providers:
  openrouter:
    api_key: "sk-or-v1-..."
    api_base: "https://openrouter.ai/api/v1"
  openai:
    api_key: ""
    api_base: "https://api.openai.com/v1"
  # ... anthropic, ollama, local
  • server.port — Default for cerebrain serve.
  • llm_defaults — max_tokens and temperature (used as defaults for new brains).
  • providers..api_key — Set at init or edit the file; the LLM client reads from here.

Contribute & Roadmap

Contribute: Open issues and pull requests at github.com/shuurai/cerebrain. Ideas, docs, and code welcome.

Roadmap — where Cerebra could go:

  • Multi-brain — Several brains in one workspace; handoff, debate, or consensus between them.
  • Plugin system — Third-party skills, custom inspiration sources, and new “streams” in the consciousness layer.
  • Training / adaptation — SOUL or memory that evolves from interaction (e.g. light fine-tuning or preference learning), not just static init.
  • Web UI — Optional browser interface to the same matrix (chat, state, pulse) for those who want more than the terminal.
  • Embodied hooks — Integrations with sensors, time, or external events so mood and inspiration react to “real world” context.
  • Cross-brain sync — Share or merge memories, moods, or inspiration across brains (labs, teams, or personal variants).
  • Explainable state — Richer introspection: why a reply looked like this, which part (emotional / logical / inspiration) dominated, trace of self-skill calls.

The goal is to grow from a single-brain CLI into a platform for many minds: observable, composable, and still not “just another agent framework.”

License

MIT. See LICENSE in the repo.


Star History — see how this repo’s stars grow over time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cerebrain-0.3.4.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cerebrain-0.3.4-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

Details for the file cerebrain-0.3.4.tar.gz.

File metadata

  • Download URL: cerebrain-0.3.4.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cerebrain-0.3.4.tar.gz
Algorithm Hash digest
SHA256 e17039644f03d7d616e34ec6f6492d48da05cf30904d97e37058eb309fb74a47
MD5 aabf1c95a83aa9863b7f635460ea4041
BLAKE2b-256 ec8198888138aa313836891c046073b44601e6b81fc5d2de09f91d7861361d59

See more details on using hashes here.

File details

Details for the file cerebrain-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: cerebrain-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cerebrain-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0dad17c6852e21d4341f620f0f7d229428b1181a9b149d19d0c96bb776172416
MD5 ba54ef41d2bceaf139ef7c9357df2411
BLAKE2b-256 18c6916f5317562b45d7cfbfaaf6dae1742e9b31156c8ee948893515ec22c7d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page