Skip to content
@protocol-luna

Protocol LUNA

Luna Protocol

Protocol Luna

Autonomous, sentient-like AI bots powered by local LLM inference

Website Docs Model Discord Matrix

An open-source multi-platform AI assistant ecosystem with a modular architecture. The brain service (Emerald) connects to platform adapters (Discord, Matrix) and an LLM gateway (Sapphire) backed by llama.cpp (Krystal).

What is LUNA?

LUNA stands for Lifelike User-like Neural Agent -- an autonomous conversational AI designed to mimic human imperfections and social behavior.

Architecture

flowchart TD
    classDef platform fill:#2c3e50,color:#fff,stroke-width:2px
    classDef jade fill:#1abc9c,color:#fff,stroke-width:2px
    classDef pixie fill:#e84393,color:#fff,stroke-width:2px
    classDef brain fill:#27ae60,color:#fff,stroke-width:2px
    classDef service fill:#2980b9,color:#fff,stroke-width:2px
    classDef inference fill:#8e44ad,color:#fff,stroke-width:2px
    classDef alt fill:#c0392b,color:#fff,stroke-width:2px

    Discord["Discord"]:::platform
    Matrix["Matrix"]:::platform

    Jade["Jade (Discord)"]:::jade
    Pixieglow["Pixieglow (Matrix)"]:::pixie
    Discord ~~~ Matrix

    Emerald["Emerald (Brain)
    behavior · triggers · routing"]:::brain

    Sapphire["Sapphire (LLM Gateway)
    classify · emotion · sessions"]:::service

    KrystalS["Krystal (Small)
    Luna 1.5B · :3124
    FUTILE messages"]:::inference

    KrystalL["Krystal (Large)
    Discord-Hermes-8B · :3125
    INTERESSANT messages"]:::inference

    Ruby["Ruby (Markov Chain)
    order-4 · SQLite · 0 latency"]:::alt

    Discord --> Jade
    Matrix --> Pixieglow
    Jade -- ":3126 WS" --> Emerald
    Pixieglow -- ":3126 WS" --> Emerald
    Emerald -- ":3123 HTTP" --> Sapphire
    Sapphire -- ":3124" --> KrystalS
    Sapphire -- ":3125" --> KrystalL
    Emerald -.->|":3127"| Ruby
Loading

📐 Detailed architecture & state machine diagrams

Services

Service Role Port Language Logo
Emerald Brain & behavior engine 3126 TypeScript
Sapphire LLM gateway (sessions, classification, prompting) 3123 Python
Krystal LLM inference (llama.cpp) 3124 C++
Jade Discord adapter -- TypeScript
Pixieglow Matrix adapter -- TypeScript
Ruby Markov chain service 3127 TypeScript

Data Flow

  1. User sends a message on Discord or Matrix
  2. The adapter (Jade/Pixieglow) forwards it to Emerald via WebSocket
  3. Emerald evaluates behavior rules (burst, typo, sleep, mannerisms)
  4. Emerald decides: random/spontaneous triggers → Ruby (Markov chain), all others → Sapphire
  5. If Sapphire: classifies the message (emotion valence/arousal, category), manages conversation sessions, injects few-shot examples, and constructs the prompt
  6. Sapphire calls Krystal with emotion-aware sampling parameters
  7. Sapphire checks for degenerate responses and retries if needed
  8. Sapphire returns the response text (and optionally debug stats)
  9. Emerald applies typo/swap behavior and sends a RespondCommand back to the adapter
  10. The adapter posts the response to the platform

Behavior System

The bot doesn't just generate text -- it decides when, how, and whether to respond, simulating human imperfections:

Behavior Description
Sleep cycles Circadian rhythm -- ignores messages during rest hours, slows down when drowsy
Typo injection Keyboard-mistake realism with delayed self-correction
Hesitation Filler words injected post-generation ("uh...", "hmm...")
Burst mode Splits long responses into timed fragments
Topic fatigue Gets bored of repetitive topics -- longer delays, higher ignore chance
Forget chance Silently drops messages 3% of the time
Follow-up detection Chains up to 3 rapid replies in active conversations

Features

  • Multi-platform -- Discord (Jade) and Matrix (Pixieglow) with the same brain backend
  • Emotion-aware LLM -- Valence/arousal classification adjusts sampling parameters
  • Few-shot learning -- Category-matched example injection from YAML files
  • Session management -- Per-channel conversation history
  • Markov chain spontaneity -- Ruby generates context-free messages from real conversation data
  • Debug mode -- End-to-end token counting and timing across all layers
  • Single small model -- Luna Protocol 1.5B Q4_K_M fits in ~3 GB RAM

Repositories

Repository Description Language Status
emerald Brain & behavior engine TypeScript Active
sapphire LLM gateway Python Active
krystal LLM inference C++ Active
jade Discord adapter TypeScript Active
pixieglow Matrix adapter TypeScript Active
ruby Markov chain TypeScript Active
protocol-luna.github.io Website HTML/CSS Active

Deployment

  • All services run on a single VPS managed by PM2
  • WebSocket :3126 (Emerald ↔ bots)
  • HTTP :3123 (Emerald ↔ Sapphire)
  • HTTP :3124 (Sapphire ↔ Krystal)
  • HTTP :3127 (Emerald ↔ Ruby)
  • Cloudflared tunnel for Matrix federation
  • GitHub Pages serves protocol-luna.github.io

Get Started

# 1. LLM inference
git clone https://github.com/protocol-luna/krystal.git && cd krystal && ./start.sh

# 2. LLM gateway
git clone https://github.com/protocol-luna/sapphire.git && cd sapphire && pip install -r requirements.txt && python server.py

# 3. Brain service
git clone https://github.com/protocol-luna/emerald.git && cd emerald && npm install && npm start

# 4. Markov chain (optional)
git clone https://github.com/protocol-luna/ruby.git && cd ruby && npm install && npm start

# 5. Platform adapter (Discord or Matrix)
git clone https://github.com/protocol-luna/jade.git  # or pixieglow

Built with ❤️ and llama.cpp

Popular repositories Loading

  1. krystal krystal Public

    Shell 1

  2. protocol-luna.github.io protocol-luna.github.io Public

    HTML

  3. pixieglow pixieglow Public

    Matrix bot - LLM-powered, human-like behaviors, TTS

    TypeScript

  4. jade jade Public

    Discord bot client - connects to krystal LLM server

    JavaScript

  5. .github .github Public

    Protocol Luna organization profile & documentation

    Mermaid

  6. sapphire sapphire Public

    HTML

Repositories

Showing 8 of 8 repositories

Top languages

Loading…

Most used topics

Loading…