Skip to content

๐ŸฅœPeanut Agent - PRO v0.1 Sistema de Agente Local con IA Avanzado - Haz que modelos pequeรฑos funcionen como los grandes

License

Notifications You must be signed in to change notification settings

smouj/peanut-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

37 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PeanutAgent Enterprise โ€” AI Gateway Platform
PeanutAgent Logo



PeanutAgent Icon

Version TypeScript Next.js Fastify Python

MCP Ollama Docker License

Tests pnpm Node SQLite


The perfect companion for KiloCode โ€” A production-ready AI Gateway with native MCP Server, Ollama local inference, Docker management, and enterprise-grade security. Zero API costs. Full privacy. Runs entirely on your machine.


๐Ÿš€ Quick Start ยท ๐Ÿ”Œ KiloCode Integration ยท ๐Ÿ“– Docs ยท ๐Ÿ—๏ธ Architecture ยท ๐Ÿ”’ Security


๐Ÿ‡ช๐Ÿ‡ธ Leer en Espaรฑol ยท ๐ŸŒ GitHub Pages


โœจ What is PeanutAgent?

PeanutAgent Enterprise is a full-stack AI Agent Management Platform that acts as a secure, intelligent gateway between your development tools and AI models. It bridges the gap between local LLMs and enterprise-grade tooling.

๐Ÿ”Œ MCP Server (v2.0.0)

KiloCode discovers and uses your local Ollama models as native tools via the Model Context Protocol. 7 tools, 4 resources, 2 prompts โ€” all spec-compliant.

๐Ÿค– Local AI Backend

Use PeanutAgent as a free, private AI backend for KiloCode. No API costs, no data leaving your machine. Supports qwen2.5, llama3.2, codellama, and any Ollama model.

๐Ÿณ Docker Management

Manage containers directly from KiloCode via MCP tools. List, start, stop, inspect, and stream logs โ€” all from your IDE.

๐Ÿ”’ Enterprise Security

JWT httpOnly cookies ยท TOTP 2FA (RFC 6238) ยท scrypt password hashing ยท AES-256-GCM encrypted secrets ยท Immutable SHA-256 audit chain.

๐Ÿ“Š Admin Dashboard

Next.js 15 dashboard with real-time metrics, agent management, Docker control, WebSocket terminal, and a dedicated KiloCode MCP integration page.

โš–๏ธ Smart Load Balancing

OpenClaw Orchestrator implements Smooth Weighted Round-Robin (Nginx algorithm) across agents with health-based routing and per-agent metrics.


๐Ÿ“ธ Dashboard Screenshots

New Enterprise Dashboard โ€” Redesigned with glassmorphism, neon effects, animated metrics, and a cyberpunk-inspired dark theme.

๐Ÿ–ฅ๏ธ Main Dashboard

PeanutAgent Enterprise Dashboard

๐Ÿ” Login Page

PeanutAgent Login

๐Ÿ“Š Dashboard Overview (1440px)

PeanutAgent Dashboard Overview

Dashboard Features:

  • ๐ŸŒ‘ Dark glassmorphism design with backdrop blur effects
  • โœจ Animated stat cards with sparkline charts and live counters
  • ๐ŸŸข Real-time status indicators with neon glow effects
  • ๐Ÿ“ˆ System metrics with animated progress bars
  • โšก Quick actions panel for instant navigation
  • ๐Ÿ”’ Platform overview with security status
  • ๐Ÿค– Agent list with health monitoring and latency display
  • ๐Ÿณ Docker containers panel with live status
  • ๐ŸŽจ Cyber grid background with ambient glow effects

๐Ÿ—๏ธ Architecture

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                    PeanutAgent Enterprise v2.0.0                         โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฆโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘   Next.js 15 Dashboard    โ•‘         Fastify API Gateway                  โ•‘
โ•‘   (Port 3000)             โ•‘         (Port 3001)                          โ•‘
โ•‘   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€   โ•‘   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€             โ•‘
โ•‘   โ€ข Auth (2FA TOTP)       โ•‘   โ€ข OpenClaw Orchestrator (SWRR)             โ•‘
โ•‘   โ€ข Agent Management      โ•‘   โ€ข JWT Auth (httpOnly cookies)              โ•‘
โ•‘   โ€ข Docker Management     โ•‘   โ€ข TOTP 2FA Verification                    โ•‘
โ•‘   โ€ข Audit Log Viewer      โ•‘   โ€ข Immutable Audit Chain (SHA-256)          โ•‘
โ•‘   โ€ข WebSocket Terminal    โ•‘   โ€ข Adaptive Rate Limiting                   โ•‘
โ•‘   โ€ข KiloCode MCP Page     โ•‘   โ€ข Docker Management API                    โ•‘
โ•‘   โ€ข Settings              โ•‘   โ€ข Kilo Code Bridge (AES-256-GCM)           โ•‘
โ•‘                           โ•‘   โ€ข MCP Server (7 tools, 4 resources)        โ•‘
โ•‘                           โ•‘   โ€ข Health Monitoring (30s intervals)        โ•‘
โ•‘                           โ•‘   โ€ข WebSocket Terminal                       โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฉโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                      Data & Infrastructure                                โ•‘
โ•‘   SQLite (WAL mode) โ”‚ Ollama LLM โ”‚ Docker Socket โ”‚ OpenTelemetry         โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
                              โ†• MCP Protocol (2024-11-05)
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                         KiloCode IDE                                      โ•‘
โ•‘   peanut_dispatch_agent ยท peanut_docker_* ยท peanut_list_agents           โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Domain-Driven Design

The gateway follows strict DDD principles with four layers:

Layer Path Responsibility
Domain src/domain/ Pure business entities (Agent, User, AuditEntry) with invariant enforcement
Application src/application/ Use cases & services (AuthService, OpenClawService, DockerService, CryptoService)
Infrastructure src/infrastructure/ SQLite repositories, Kilo client, MCP Server
Interface src/interfaces/ Fastify HTTP routes, WebSocket terminal handler

๐Ÿš€ Quick Start

Prerequisites

Requirement Version Notes
Node.js โ‰ฅ 20.0.0 LTS recommended
pnpm โ‰ฅ 9.0.0 npm i -g pnpm
Docker Any Optional, for container management
Python โ‰ฅ 3.10 Optional, for Python agent
Ollama Latest For local LLM inference

Development Setup

# 1. Clone the repository
git clone https://github.com/your-org/peanut-agent.git
cd peanut-agent

# 2. Install all dependencies (monorepo)
pnpm install

# 3. Build shared types package
pnpm --filter @peanut/shared-types build

# 4. Configure environment
cp services/gateway/.env.example services/gateway/.env

# Generate secrets (required)
echo "JWT_SECRET=$(openssl rand -hex 32)"
echo "KILO_ENCRYPTION_KEY=$(openssl rand -hex 32)"
# โ†’ Paste these values into services/gateway/.env

# 5. Start the API Gateway (port 3001)
pnpm --filter @peanut/gateway dev

# 6. Start the Dashboard (port 3000) โ€” in a new terminal
pnpm --filter @peanut/dashboard dev

Open http://localhost:3000 and login with:

  • Email: admin@peanut.local
  • Password: PeanutAdmin@2024!

Production (Docker Compose)

# 1. Configure secrets
cp .env.example .env
# Edit .env: set JWT_SECRET and KILO_ENCRYPTION_KEY

# 2. Launch all services
docker compose up -d

# Services:
#   Dashboard:  http://localhost:3000
#   Gateway:    http://localhost:3001
#   MCP Server: http://localhost:3001/mcp
#   Ollama:     http://localhost:11434

Install Ollama Models

ollama pull qwen2.5:7b       # Recommended for coding tasks
ollama pull llama3.2:3b      # Lightweight, fast responses
ollama pull codellama:7b     # Code-specialized model
ollama pull nomic-embed-text # For RAG memory embeddings

๐Ÿ”Œ KiloCode Integration

Connect KiloCode to PeanutAgent in under 30 seconds.

PeanutAgent v2.0.0 ships a full MCP (Model Context Protocol) Server that KiloCode discovers natively. This gives you free, private AI inference directly inside your IDE.

Step 1 โ€” Add MCP Server to KiloCode

Option A: Via KiloCode UI

  1. Open KiloCode in VS Code
  2. Click the MCP icon in the sidebar
  3. Add Server โ†’ Enter URL: http://localhost:3001/mcp

Option B: Edit config directly

Edit ~/.kilo/mcp_settings.json:

{
  "mcpServers": {
    "peanut-agent": {
      "url": "http://localhost:3001/mcp",
      "description": "PeanutAgent Enterprise โ€” Local AI Gateway"
    }
  }
}

Option C: Via Dashboard

Open http://localhost:3000/dashboard/kilocode โ†’ copy the pre-configured settings with one click.

Step 2 โ€” Use Local Models from KiloCode

// Discover available local models
peanut_list_agents({ onlineOnly: true })

// Run a coding task on local Ollama โ€” free, private, no API costs
peanut_dispatch_agent({
  message: "Refactor this function to use async/await",
  context: [{ role: "user", content: "Here is the code: ..." }]
})

// Manage Docker containers
peanut_docker_list({ all: false })
peanut_docker_control({ containerId: "my-api", action: "restart" })
peanut_docker_logs({ containerId: "my-api", tail: 50 })

Step 3 โ€” Create a Custom KiloCode Mode (Optional)

{
  "name": "PeanutLocal",
  "slug": "peanut-local",
  "roleDefinition": "You are a local AI assistant powered by PeanutAgent and Ollama. Use peanut_dispatch_agent for all AI tasks โ€” completely free and private.",
  "groups": ["read", "edit", "command"],
  "customInstructions": "Always prefer local Ollama models via peanut_dispatch_agent. Use peanut_list_agents to discover available models. Prefer qwen2.5:7b for coding tasks."
}

Available MCP Tools

Tool Description Auth Required
peanut_dispatch_agent Send tasks to local Ollama agents โ€” free, private inference โœ—
peanut_list_agents Discover available local AI agents with health status โœ—
peanut_docker_list List Docker containers with status and metrics โœ—
peanut_docker_control Start, stop, or restart Docker containers โœ—
peanut_docker_logs Retrieve container logs for debugging โœ—
peanut_gateway_status Check PeanutAgent gateway health and version โœ—
peanut_kilo_complete Proxy completions through PeanutAgent to Kilo Code API โœ—

MCP Resources

Resource URI Description
peanut://agents All registered AI agents with health and metrics
peanut://docker/containers Running Docker containers
peanut://gateway/health Gateway health and status
peanut://audit/recent Last 50 audit log entries

Why PeanutAgent + KiloCode?

Scenario Benefit
Local development Use Ollama models (qwen2.5, llama3.2) โ€” zero API costs
Privacy-sensitive code All inference stays on your machine โ€” no data leaks
Docker workflows Manage containers directly from KiloCode
Hybrid setup Route simple tasks to local, complex to cloud
Offline work Full AI coding assistance without internet

๐Ÿ“ Repository Structure

peanut-agent/
โ”œโ”€โ”€ apps/
โ”‚   โ””โ”€โ”€ dashboard/                  # Next.js 15 Admin Dashboard
โ”‚       โ”œโ”€โ”€ src/app/
โ”‚       โ”‚   โ”œโ”€โ”€ auth/login/         # Authentication page
โ”‚       โ”‚   โ””โ”€โ”€ dashboard/
โ”‚       โ”‚       โ”œโ”€โ”€ kilocode/       # ๐Ÿ†• KiloCode MCP integration page
โ”‚       โ”‚       โ”œโ”€โ”€ agents/         # Agent management
โ”‚       โ”‚       โ”œโ”€โ”€ docker/         # Docker management
โ”‚       โ”‚       โ”œโ”€โ”€ audit/          # Immutable audit log viewer
โ”‚       โ”‚       โ”œโ”€โ”€ terminal/       # WebSocket terminal
โ”‚       โ”‚       โ””โ”€โ”€ settings/       # Platform settings
โ”‚       โ”œโ”€โ”€ src/components/         # Reusable UI components (Radix UI)
โ”‚       โ””โ”€โ”€ src/lib/                # API client, auth utilities
โ”‚
โ”œโ”€โ”€ services/
โ”‚   โ””โ”€โ”€ gateway/                    # Fastify API Gateway (TypeScript, DDD)
โ”‚       โ”œโ”€โ”€ src/domain/             # Business entities (Agent, User, AuditEntry)
โ”‚       โ”œโ”€โ”€ src/application/        # Services (Auth, OpenClaw, Docker, Crypto)
โ”‚       โ”œโ”€โ”€ src/infrastructure/     # SQLite repos, Kilo client, MCP server
โ”‚       โ””โ”€โ”€ src/interfaces/         # HTTP routes, WebSocket handler
โ”‚
โ”œโ”€โ”€ packages/
โ”‚   โ””โ”€โ”€ shared-types/               # Shared TypeScript interfaces (incl. MCP types)
โ”‚
โ”œโ”€โ”€ docs/                           # Documentation
โ”‚   โ”œโ”€โ”€ ARCHITECTURE.md
โ”‚   โ”œโ”€โ”€ KILOCODE_INTEGRATION.md
โ”‚   โ”œโ”€โ”€ REFLECTION_MEMORY.md
โ”‚   โ”œโ”€โ”€ SECURITY.md
โ”‚   โ”œโ”€โ”€ TROUBLESHOOTING.md
โ”‚   โ””โ”€โ”€ WIZARD.md
โ”‚
โ”œโ”€โ”€ agent.py                        # Python AI agent core (local LLM)
โ”œโ”€โ”€ tools.py                        # Secure tool executor (allowlist-based)
โ”œโ”€โ”€ memory.py                       # RAG memory system (JSONL + embeddings)
โ”œโ”€โ”€ reflection.py                   # Reflection loop (auto-correction)
โ”œโ”€โ”€ gateway.py                      # Console gateway (multi-session)
โ”œโ”€โ”€ web_ui.py                       # Web gateway (FastAPI + WebSocket)
โ”œโ”€โ”€ docker-compose.yml              # Production deployment
โ””โ”€โ”€ .github/workflows/              # CI/CD pipelines

๐Ÿ”’ Security Architecture

Authentication Stack

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Login Flow                                          โ”‚
โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”‚
โ”‚  1. POST /auth/login โ†’ scrypt verify โ†’ JWT issue    โ”‚
โ”‚  2. POST /auth/totp/verify โ†’ TOTP check โ†’ session   โ”‚
โ”‚  3. httpOnly + Secure + SameSite=Strict cookie       โ”‚
โ”‚  4. 8-hour session expiry, revokable in SQLite       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Feature Implementation
JWT Sessions httpOnly, Secure, SameSite=Strict cookies ยท 8h expiry
TOTP 2FA RFC 6238 via otplib ยท 10 single-use backup codes
Password Hashing scrypt (N=2ยนโด, r=8, p=1) ยท 64-byte output ยท 32-byte random salt
Secret Encryption AES-256-GCM ยท keys stored in env, never in DB
Security Headers @fastify/helmet ยท HSTS, CSP, X-Frame-Options

Immutable Audit Chain

Every action is recorded in a cryptographic fingerprint chain:

Entry N:  SHA-256(previousFingerprint + content) โ†’ fingerprint
Entry N+1: SHA-256(fingerprint_N + content) โ†’ fingerprint

Any modification to any entry breaks the chain โ€” tamper detection is automatic.

Adaptive Rate Limiting

Scope Limit Backoff
Login (per IP) 10 req/min Exponential up to 5 min
TOTP (per user) 5 attempts/min Exponential up to 10 min
API Dispatch (per user) 60 req/min Standard

โš™๏ธ OpenClaw Orchestrator

The OpenClaw service implements Smooth Weighted Round-Robin (Nginx algorithm) for intelligent load balancing:

Agents: [{name: A, weight: 5}, {name: B, weight: 3}, {name: C, weight: 2}]

Each request:
  1. Increment currentWeight by agent.weight for all agents
  2. Select agent with highest currentWeight
  3. Subtract totalWeight from selected agent's currentWeight

Result: ~50% โ†’ A, ~30% โ†’ B, ~20% โ†’ C (proportional to weights)

Features:

  • Dynamic agent registration/deregistration at runtime
  • Health-based routing โ€” unhealthy agents automatically excluded
  • Per-agent metrics: latency, success rate, token usage
  • Background health checks every 30 seconds

๐Ÿ“ก API Reference

Authentication
POST /api/v1/auth/login              Login (email + password)
POST /api/v1/auth/totp/verify        Complete TOTP 2FA verification
POST /api/v1/auth/logout             Invalidate session
GET  /api/v1/auth/me                 Get current user profile
POST /api/v1/auth/totp/setup         Enable 2FA (returns QR code)
POST /api/v1/auth/password           Change password
Agent Management
GET    /api/v1/agents                List all agents with health status
POST   /api/v1/agents                Register new agent
PUT    /api/v1/agents/:id            Update agent configuration
DELETE /api/v1/agents/:id            Remove agent
GET    /api/v1/agents/:id/health     Force health check
POST   /api/v1/openclaw/dispatch     Send request (auto load-balanced)
Docker Management
GET    /api/v1/docker/containers              List containers
POST   /api/v1/docker/containers              Deploy new container
POST   /api/v1/docker/containers/:id/start   Start container
POST   /api/v1/docker/containers/:id/stop    Stop container
DELETE /api/v1/docker/containers/:id         Remove container
GET    /api/v1/docker/containers/:id/metrics Real-time metrics
GET    /api/v1/docker/containers/:id/logs    Container logs
GET    /api/v1/docker/images                 List local images
Kilo Code Bridge
GET  /api/v1/kilo/status     Connection status + usage stats
GET  /api/v1/kilo/config     Configuration (admin only)
PUT  /api/v1/kilo/config     Update config + API key (AES-256 encrypted)
POST /api/v1/kilo/complete   Proxy completion request to Kilo Code API
GET  /api/v1/kilo/usage      Token usage statistics
MCP Server (v2.0.0)
GET  /mcp                    MCP server discovery (capabilities, tools, resources)
POST /mcp                    JSON-RPC 2.0 endpoint (all MCP methods)
GET  /mcp/events             SSE endpoint for real-time updates

Supported JSON-RPC methods: initialize, tools/list, tools/call, resources/list, resources/read, prompts/list, prompts/get, ping

WebSocket Terminal
ws://localhost:3001/ws/terminal    Authenticated real-time terminal

๐Ÿงช Testing

# Run all tests (monorepo)
pnpm test

# Gateway unit tests
pnpm --filter @peanut/gateway test

# Gateway with coverage report
pnpm --filter @peanut/gateway test:coverage

# Run specific test file (e.g., MCP server)
cd services/gateway && pnpm vitest run tests/unit/mcp.server.test.ts

# Dashboard tests
pnpm --filter @peanut/dashboard test

# Python agent tests
pytest tests/ -v

# Python with coverage
pytest tests/ -v --cov=. --cov-report=html

Coverage requirements: 80% lines ยท functions ยท branches ยท statements


๐ŸŒ Environment Variables

Gateway (services/gateway/.env)

Variable Required Default Description
JWT_SECRET โœ… โ€” JWT signing secret (min 32 chars)
KILO_ENCRYPTION_KEY โœ… โ€” AES-256 key for secrets (64 hex chars)
PORT โœ— 3001 Gateway HTTP port
CORS_ORIGIN โœ— http://localhost:3000 Allowed CORS origins
DATA_DIR โœ— ./data SQLite database directory
LOG_LEVEL โœ— info Pino log level
DEFAULT_ADMIN_PASSWORD โœ— โ€” Override initial admin password

Dashboard (apps/dashboard/.env.local)

Variable Required Default Description
NEXT_PUBLIC_API_URL โœ— http://localhost:3001 Gateway HTTP URL
NEXT_PUBLIC_WS_URL โœ— ws://localhost:3001 Gateway WebSocket URL
GATEWAY_URL โœ— โ€” Internal gateway URL for Next.js rewrites

๐Ÿ Python Agent (Legacy)

The original Python agent runs independently and provides a lightweight local AI interface:

# Interactive setup wizard
python wizard.py

# Console gateway (multi-session, Rich UI)
python gateway.py

# Web gateway (FastAPI + WebSocket)
python web_ui.py
# Open: http://127.0.0.1:18889/

Python agent features:

  • ๐Ÿ”„ Reflection Loop โ€” Auto-correction with Pydantic schema validation (up to 3 retries)
  • ๐Ÿง  RAG Memory โ€” JSONL append-only store with Ollama embeddings + cosine similarity
  • ๐Ÿ›ก๏ธ Allowlist Security โ€” Shell commands restricted to safe read/diagnostic operations
  • ๐ŸŽฎ Gamification โ€” Peanut counter system (~/.peanut-agent/state.json)

๐Ÿ“ฆ Tech Stack

Layer Technology Version Purpose
Backend Fastify 4.x High-performance HTTP server
TypeScript 5.7 Type safety across the stack
better-sqlite3 11.x Embedded database (WAL mode)
@fastify/jwt 8.x JWT authentication
otplib 12.x TOTP 2FA (RFC 6238)
Zod 3.x Runtime schema validation
Frontend Next.js 15.1 React framework (App Router)
React 19.x UI library
Radix UI Latest Accessible component primitives
Tailwind CSS 3.x Utility-first styling
Recharts 2.x Real-time metrics charts
AI/ML Ollama Latest Local LLM inference
MCP Protocol 2024-11-05 KiloCode tool integration
OpenTelemetry 1.x Distributed tracing
Testing Vitest 3.x TypeScript unit/integration tests
pytest Latest Python agent tests
@testing-library/react 16.x Dashboard component tests

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md for:

  • Development workflow and branch strategy
  • Code style guidelines (ESLint + TypeScript strict mode)
  • Test requirements (80% coverage threshold)
  • PR review process

๐Ÿ“„ License

MIT โ€” see LICENSE for details.


Built with โค๏ธ for the KiloCode community

โญ Star on GitHub ยท ๐Ÿ› Report Bug ยท ๐Ÿ’ก Request Feature

PeanutAgent Enterprise v2.0.0 ยท MIT License ยท Local-First AI

About

๐ŸฅœPeanut Agent - PRO v0.1 Sistema de Agente Local con IA Avanzado - Haz que modelos pequeรฑos funcionen como los grandes

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors