Skip to content

Repository files navigation

RASE1 🐸

Rene's Agentic System for Everything β€” A lightweight, extensible AI agent framework in pure Java.

RASE1 powers autonomous AI agents that can hold conversations, execute tools, manage memory, and interact with the real world β€” all from a single JAR. Built with minimal dependencies. Just Java 21 and reactive streams.

What is this?

RASE1 is the engine behind Slick β€” a personal AI agent that lives on a Raspberry Pi, manages calendars, shopping lists, train schedules, code reviews, and more. But the core is generic: plug in any LLM provider, define your tools, and you've got an agent.

Think of it as a headless AI agent runtime β€” a tight loop of LLM calls and tool executions, with streaming, memory, sessions, and security baked in.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Gateway                    β”‚
β”‚            (Discord, CLI, ...)              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Agent                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚             AgentLoop                  β”‚ β”‚
β”‚  β”‚  LLM Call β†’ Parse β†’ Tool Exec β†’ Loop  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Sessions β”‚ β”‚  Memory  β”‚ β”‚ Scheduling β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Tools                      β”‚
β”‚  Built-in: bash, grep, find, ls, edit, ... β”‚
β”‚  Script:   Any .sh/.py with a manifest     β”‚
β”‚  Custom:   Implement AgentTool<T>           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              LLM Providers                  β”‚
β”‚  Anthropic β”‚ OpenAI β”‚ Google (via Replicate)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Features

  • Agentic Loop β€” Multi-turn LLM ↔ tool execution loop with configurable depth limits
  • Streaming β€” Reactive (Project Reactor) streaming of LLM responses and agent events
  • Multi-Provider β€” Supports Anthropic (Claude), OpenAI (GPT), and Google (Gemini) API formats, routed through Replicate
  • Built-in Tools β€” bash, grep, find, ls, edit, write, codex (delegate to a coding sub-agent)
  • Script Tools β€” Drop a shell/Python script with a YAML manifest and it becomes a tool automatically
  • Command Security β€” Allowlist/blocklist-based shell command policy. The agent can only run what you permit
  • Semantic Memory β€” SQLite-backed long-term memory with embedding-based semantic search
  • Session Management β€” Persistent conversation sessions with transcript generation
  • Scheduling β€” Cron and one-shot scheduled prompts that fire autonomously
  • Discord Gateway β€” First-class Discord bot integration with streaming message updates, attachments, voice note transcription
  • Docker Hardened β€” Runs in a capability-dropped, no-port, no-privilege-escalation container

Tech Stack

Component Technology
Language Java 21
Reactive Streams Project Reactor
JSON Jackson
Database SQLite (via sqlite-jdbc)
Embeddings Replicate (multilingual-e5-large)
CLI JLine 3
Build Maven
Container Docker
Target Hardware Raspberry Pi 4 (but runs anywhere)

Project Structure

src/main/java/com/renemrhfr/rase1/
β”œβ”€β”€ agent/          # Core agent loop, state, events, config
β”‚   β”œβ”€β”€ events/     # AgentEvent types (start, text delta, tool exec, ...)
β”‚   β”œβ”€β”€ messages/   # Message types (user, assistant, tool result, reminder)
β”‚   └── tools/      # AgentTool interface and schema generation
β”œβ”€β”€ bootstrap/      # Application launcher
β”œβ”€β”€ discord/        # Discord gateway (bot integration)
β”œβ”€β”€ llm/            # LLM abstraction, model catalog, streaming events
β”‚   β”œβ”€β”€ providers/  # LlmProvider implementations (Replicate)
β”‚   β”œβ”€β”€ streaming/  # SSE event parsing and delta types
β”‚   └── context/    # Conversation context for API calls
β”œβ”€β”€ memory/         # Semantic memory (embeddings, SQLite, search)
β”œβ”€β”€ schedule/       # Cron and one-shot task scheduling
β”œβ”€β”€ session/        # Conversation persistence and transcripts
└── tools/          # Tool implementations
    β”œβ”€β”€ builtin/    # Bash, Grep, Find, Ls, Edit, Write, Codex
    β”œβ”€β”€ script/     # Script-based tool loader (auto-discovery)
    β”œβ”€β”€ shell/      # Process execution engine
    β”œβ”€β”€ security/   # Command allowlist/blocklist policy
    β”œβ”€β”€ replicate/  # Replicate API client for model calls
    β”œβ”€β”€ path/       # Path resolution utilities
    └── truncation/ # Output truncation for large tool results

Tool System

Built-in Tools

Tools that ship with the engine:

Tool Description
bash Execute shell commands (subject to allowlist policy)
write Write content to files
edit Match-and-replace text editing
grep Regex search across files
find Glob-based file discovery
ls Directory listing
manual Load full tool documentation
codex Delegate complex coding tasks to a sub-agent

Script Tools

Drop a script + manifest into your tools directory and it's automatically registered:

tools/
└── my-tool/
    β”œβ”€β”€ my-tool.sh       # or my-tool.py
    └── my-tool.md       # YAML front-matter manifest

The manifest defines the tool's name, description, parameters, and examples. The agent passes parameters as JSON on stdin, and reads stdout as the result.

Custom Tools with guardrails

Implement AgentTool<T> for full control:

public interface AgentTool<T> {
    String name();
    String description();
    List<String> examples();
    CompletableFuture<AgentToolResult> execute(T parameters, CancellationToken token);
}

Command Security

The agent's shell access is governed by policy files:

  • Allowlist β€” Only commands matching these rules can execute
  • Blocklist β€” Override allowlist for specific dangerous commands

Rule types:

command:git          # Allow/block by first token
prefix:cat /app/     # Allow/block by prefix match
exact:ls -la         # Allow/block exact command
tool:my-tool         # Allow/block a script tool by name

If no allowlist is configured, all commands are blocked by default.

Running

Prerequisites

  • Java 21+
  • Maven
  • Docker (for containerized deployment)
  • A Replicate API token (for LLM access)

Build

mvn clean package -DskipTests

Run with Docker

# Configure your .env file with required API tokens
docker compose up --build

Environment Variables

Variable Description
REPLICATE_API_TOKEN Replicate API token for LLM and embedding calls
DISCORD_TOKEN Discord bot token (for Discord gateway)
RASE1_TOOLS_DIR Directory to scan for script tools
RASE1_ALLOWED_COMMANDS_FILE Path to command allowlist
RASE1_BLOCKED_COMMANDS_FILE Path to command blocklist
TZ Timezone (e.g. Europe/Vienna)

Self-Rebuild Watcher

The agent can trigger its own rebuild by writing a file to a mounted volume. A host-side watcher picks it up, builds the jar, and restarts the container.

Agent writes REBUILD_REQUESTED β†’ host watcher detects it β†’ mvn package β†’ docker compose build β†’ up -d

If the new container fails to start, the watcher rolls back to the previous jar automatically.

Prerequisites on Host

  • Java 21 JDK: sudo apt install openjdk-21-jdk
  • Maven: sudo apt install maven
  • Docker + Docker Compose

Setup

  1. Copy the watcher script to your project root and make it executable:
cp watch-rebuild.sh ~/rase1-agent/
chmod +x ~/rase1-agent/watch-rebuild.sh
  1. Edit the CONFIG section at the top of watch-rebuild.sh to match your paths and jar name.

  2. Install the systemd service:

sudo cp rase-rebuild-watcher.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable rase-rebuild-watcher
sudo systemctl start rase-rebuild-watcher

Make sure User, WorkingDirectory, and ExecStart in the service file match your setup.

  1. Permissions β€” the watcher runs as your host user but the container writes as agentuser (UID 100, GID 101). Ensure the WATCHER directory is writable by both:
sudo groupadd -g 101 agentgroup  # skip if GID 101 already exists
sudo usermod -aG agentgroup $USER
sudo chgrp -R agentgroup ./data/workspace/rase1/
sudo chmod -R g+rwX ./data/workspace/rase1/

Test

echo "manual test" > ./data/workspace/rase1/WATCHER/REBUILD_REQUESTED
journalctl -u rase-rebuild-watcher -f

Agent-side usage (Java)

Files.writeString(Path.of("/app/data/workspace/rase1/WATCHER/REBUILD_REQUESTED"), "reason for rebuild");

Logs

  • Watcher journal: journalctl -u rase-rebuild-watcher -f
  • Build log: logs/rebuild.log
  • Rebuild result: data/workspace/rase1/WATCHER/REBUILD_STATUS

Design Principles

  • No frameworks. No Spring, no Quarkus, no magic. Just Java and libraries.
  • Reactive by default. The agent loop, LLM streaming, and event distribution all use Project Reactor.
  • Security first. Shell access is allowlisted. Containers are hardened. No ports exposed.
  • Extensible. Add tools via scripts or Java. Swap LLM providers. Plug in new gateways.
  • Runs on a Pi. Designed to be lightweight enough for a Raspberry Pi 4, powerful enough for real work.

Maintainers

License

TBD


Built with caffeine and curiosity. Maintained by a human and his frog. 🐸

About

Code for https://github.com/slickthefrog

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages