Skip to content

🧠 Self-evolving cognitive agent framework β€” 5-cortex architecture, tri-store memory with metabolism, 4-layer reasoning, swarm intelligence, and zero-trust security. Python 3.12+

License

Notifications You must be signed in to change notification settings

NickPlaysCrypto/Neural-Claw-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python 3.12+ MIT License Phase 4 Architecture

🧠 NeuralClaw

The Self-Evolving Cognitive Agent Framework
Perceive Β· Remember Β· Reason Β· Evolve Β· Act

A next-generation autonomous agent that introduces cognitive memory architecture,
self-evolving intelligence, and security-first design.


πŸ“– Documentation

Comprehensive guides are available in the docs/ directory:

Guide Description
Getting Started Install, configure, first chat
Architecture Five Cortices, Neural Bus, pipeline
Channels Telegram, Discord, Slack, WhatsApp, Signal
Memory Episodic, Semantic, Procedural + Metabolism
Reasoning Fast-path β†’ Deliberative β†’ Reflective β†’ Meta
Swarm & Multi-Agent Delegation, Consensus, Agent Mesh
Federation Cross-network agents, trust scoring
Skills Builtins, Marketplace, Economy
Security Threat screening, sandbox, audit
Configuration TOML config, env vars, keychain
API Reference Python API quick reference
Troubleshooting Common issues, debugging

✨ What Makes NeuralClaw Different

Problem in existing agents NeuralClaw's answer
Flat markdown memory Cognitive Tri-Store β€” Episodic + Semantic + Procedural memory with metabolism (consolidation, decay, strengthening)
Dumb reactive loops 4-Layer Reasoning β€” Reflexive fast-path β†’ Deliberative β†’ Reflective self-critique β†’ Meta-cognitive evolution
No self-improvement Evolution Cortex β€” Behavioral calibration, experience distillation, automatic skill synthesis
Skill supply-chain attacks Cryptographic Marketplace β€” Ed25519 signing, static analysis, risk scoring
Single-channel bots 5 Channel Adapters β€” Telegram, Discord, Slack, WhatsApp, Signal
No security model Zero-Trust by Default β€” Pre-LLM threat screening, capability-based permissions, sandboxed execution

πŸ—οΈ Architecture: The Five Cortices

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚     Neural Bus       β”‚
                          β”‚  (async pub/sub)     β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β–Ό             β–Ό              β–Ό              β–Ό             β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚PERCEPTIONβ”‚  β”‚  MEMORY  β”‚  β”‚REASONING β”‚  β”‚  ACTION  β”‚  β”‚EVOLUTION β”‚
  β”‚         β”‚  β”‚          β”‚  β”‚          β”‚  β”‚          β”‚  β”‚          β”‚
  β”‚ Intake  β”‚  β”‚ Episodic β”‚  β”‚Fast Path β”‚  β”‚ Sandbox  β”‚  β”‚Calibratorβ”‚
  β”‚Classify β”‚  β”‚ Semantic β”‚  β”‚Deliberateβ”‚  β”‚Capabilityβ”‚  β”‚Distiller β”‚
  β”‚ Threat  β”‚  β”‚Proceduralβ”‚  β”‚Reflectiveβ”‚  β”‚  Audit   β”‚  β”‚Synthesizeβ”‚
  β”‚ Screen  β”‚  β”‚Metabolismβ”‚  β”‚          β”‚  β”‚          β”‚  β”‚          β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Every cortex communicates through the Neural Bus β€” an asynchronous event-driven backbone with full reasoning trace telemetry.


πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • At least one LLM provider (OpenAI, Anthropic, OpenRouter, or local Ollama)

Installation

# Install from PyPI
pip install neuralclaw

# Or install with all channel adapters
pip install neuralclaw[all-channels]

# Or install from source for development
git clone https://github.com/NickPlaysCrypto/Neural-Claw-.git
cd neuralclaw
pip install -e ".[dev]"

Setup

# Run the interactive setup wizard β€” configures LLM providers & stores keys securely
neuralclaw init

# Configure messaging channels (Telegram, Discord, Slack, WhatsApp, Signal)
neuralclaw channels setup

Usage

# Interactive terminal chat
neuralclaw chat

# Start the full gateway with all configured channels
neuralclaw gateway

# Check configuration and status
neuralclaw status

# View configured channels
neuralclaw channels list

πŸ”‘ LLM Provider Setup

NeuralClaw supports multiple LLM providers with automatic fallback routing:

Provider Model Setup
OpenAI GPT-4o, GPT-4o-mini API key from platform.openai.com
Anthropic Claude 3.5 Sonnet API key from console.anthropic.com
OpenRouter Multi-model access API key from openrouter.ai
Local (Ollama) Llama 3, Mistral, etc. No key needed β€” runs on localhost:11434

All API keys are stored in your OS keychain (Windows Credential Store / macOS Keychain / Linux Secret Service) β€” never in plaintext config files.


πŸ“‘ Channel Adapters

Channel Method Dependencies
Telegram Bot API via python-telegram-bot Token from @BotFather
Discord Bot via discord.py Token from Developer Portal
Slack Socket Mode via slack-bolt Bot + App tokens
WhatsApp whatsapp-web.js Node.js bridge Node.js 18+ required
Signal signal-cli JSON-RPC bridge signal-cli installed
# Interactive guided setup for all channels
neuralclaw channels setup

🧬 Intelligence Layer (Phase 2)

Memory Metabolism

Memories have a biological lifecycle β€” they aren't just appended:

Formation β†’ Consolidation β†’ Strengthening/Decay β†’ Retrieval β†’ Reconsolidation
  • Consolidation β€” Repeated episodic events merge into semantic knowledge
  • Strengthening β€” Frequently accessed memories gain importance
  • Decay β€” Stale, unused memories gradually lose relevance
  • Pruning β€” Very low-importance memories are archived

Reflective Reasoning

Complex queries trigger multi-step planning with self-critique:

Decompose β†’ Execute sub-tasks β†’ Self-critique β†’ Revise plan β†’ Synthesize answer

Evolution Cortex

Module Function
Calibrator Learns your style preferences (formality, verbosity, emoji) from corrections and interaction patterns
Distiller Extracts recurring patterns from episodes β†’ semantic facts + procedural workflows
Synthesizer Auto-generates new skills from repeated task failures via LLM code generation + sandbox testing

Skill Marketplace

from neuralclaw.skills.marketplace import SkillMarketplace

mp = SkillMarketplace()
pkg, findings = mp.publish("my_skill", "1.0", "author", "desc", code, private_key)
# Static analysis scans for: shell exec, network exfil, path traversal, obfuscation
# Risk score: 0.0 (safe) β†’ 1.0 (dangerous)

πŸ“ Project Structure

neuralclaw/
β”œβ”€β”€ bus/                    # Neural Bus (async event backbone)
β”‚   β”œβ”€β”€ neural_bus.py       #   Event types, pub/sub, correlation
β”‚   └── telemetry.py        #   Reasoning trace logging
β”œβ”€β”€ channels/               # Channel Adapters
β”‚   β”œβ”€β”€ protocol.py         #   Adapter interface
β”‚   β”œβ”€β”€ telegram.py         #   Telegram bot
β”‚   β”œβ”€β”€ discord_adapter.py  #   Discord bot
β”‚   β”œβ”€β”€ slack.py            #   Slack (Socket Mode)
β”‚   β”œβ”€β”€ whatsapp.py         #   WhatsApp (web.js bridge)
β”‚   └── signal_adapter.py   #   Signal (signal-cli bridge)
β”œβ”€β”€ cortex/                 # Cognitive Cortices
β”‚   β”œβ”€β”€ perception/         #   Intake, classifier, threat screen
β”‚   β”œβ”€β”€ memory/             #   Episodic, semantic, procedural, metabolism
β”‚   β”œβ”€β”€ reasoning/          #   Fast-path, deliberative, reflective
β”‚   β”œβ”€β”€ action/             #   Sandbox, capabilities, policy, network, audit
β”‚   └── evolution/          #   Calibrator, distiller, synthesizer
β”œβ”€β”€ providers/              # LLM Provider Abstraction
β”‚   β”œβ”€β”€ router.py           #   Multi-provider routing + fallback
β”‚   β”œβ”€β”€ openai.py           #   OpenAI connector
β”‚   β”œβ”€β”€ anthropic.py        #   Anthropic connector
β”‚   β”œβ”€β”€ openrouter.py       #   OpenRouter connector
β”‚   └── local.py            #   Ollama / local models
β”œβ”€β”€ skills/                 # Skill Framework
β”‚   β”œβ”€β”€ registry.py         #   Discovery and loading
β”‚   β”œβ”€β”€ manifest.py         #   Skill declarations
β”‚   β”œβ”€β”€ marketplace.py      #   Signed distribution + static analysis
β”‚   └── builtins/           #   Web search, file ops, code exec, calendar
β”œβ”€β”€ cli.py                  # Rich-powered CLI
β”œβ”€β”€ config.py               # TOML config + OS keychain secrets
└── gateway.py              # Orchestration engine (the brain)

πŸ›‘οΈ Security Model

NeuralClaw follows a zero-trust, security-first design:

  • Pre-LLM Threat Screening β€” Prompt injection and social engineering detection happens before the LLM sees the message
  • Capability-Based Permissions β€” Skills declare required capabilities; the verifier enforces them
  • Sandboxed Execution β€” Code execution runs in a restricted subprocess with resource limits
  • Cryptographic Skill Verification β€” Marketplace skills are HMAC-signed and statically analyzed
  • OS Keychain Integration β€” API keys stored in Windows Credential Store / macOS Keychain, never in files
  • Audit Logging β€” Every action is logged with full trace for accountability

🐝 Swarm Intelligence (Phase 3)

Delegation Chains

Agents can delegate sub-tasks to specialists with full context preservation and provenance tracking:

from neuralclaw.swarm.delegation import DelegationChain, DelegationContext

chain = DelegationChain()
ctx = DelegationContext(task_description="Research competitor pricing", max_steps=10)
delegation_id = await chain.create("researcher", ctx)
# ... sub-agent works ...
await chain.complete(delegation_id, result="Found 3 competitors", confidence=0.85)

Consensus Protocol

Multiple agents can vote on high-stakes decisions:

from neuralclaw.swarm.consensus import ConsensusProtocol, ConsensusMode

consensus = ConsensusProtocol(chain)
# Supports: MAJORITY, UNANIMOUS, WEIGHTED, QUORUM

Agent Mesh

A2A-compatible agent discovery and communication:

neuralclaw swarm status    # View registered agents
neuralclaw swarm agents    # List capabilities

Web Dashboard

Live monitoring dashboard with reasoning traces, memory stats, and swarm visualization:

neuralclaw dashboard       # Open at http://localhost:8099

🌐 Federation (Phase 4)

Agents can discover and communicate across network boundaries:

from neuralclaw.swarm.federation import FederationProtocol

fed = FederationProtocol(node_name="my-agent", port=8100)
await fed.start()                                 # Start federation server
await fed.join_federation("http://peer:8100")      # Connect to another agent
await fed.send_message(node_id, "Analyze this")    # Send cross-network task

Marketplace Economy

Credit-based economy with usage tracking, ratings, and leaderboards:

from neuralclaw.skills.economy import SkillEconomy

econ = SkillEconomy()
econ.register_author("nick", "Nick")
econ.register_skill("web_search", "nick")
econ.record_usage("web_search", user_id="u1", success=True)
econ.rate_skill("web_search", rater_id="u1", score=4.5, review="Great!")
print(econ.get_trending())

Benchmarks

# Run the full benchmark suite
neuralclaw benchmark

# Run a specific category
neuralclaw benchmark --category security

# Export results to JSON
neuralclaw benchmark --export

πŸ§ͺ Testing

# Install dev dependencies
pip install -e ".[dev]"

# Run full test suite
pytest tests/ -v

# Run Phase 2 functional tests
python test_phase2.py

# Run specific test modules
pytest tests/test_perception.py -v      # Perception + threat screening
pytest tests/test_memory.py -v          # Memory cortex
pytest tests/test_evolution_security_swarm.py -v  # Evolution, security, swarm
pytest tests/test_ssrf.py -v            # SSRF, URL validation, DNS rebinding
pytest tests/test_sandbox_policy.py -v  # Sandbox path validation, tool budgets

πŸ—ΊοΈ Roadmap

Phase Focus Status
Phase 1 Foundation β€” Cortices, Bus, CLI, Providers, Skills βœ… Complete
Phase 2 Intelligence β€” Memory metabolism, reflective reasoning, evolution cortex, marketplace βœ… Complete
Phase 3 Swarm β€” Multi-agent delegation, consensus protocols, agent mesh, web dashboard βœ… Complete
Phase 4 Domination β€” Federation, marketplace economy, benchmarks, PyPI publishing βœ… Complete

πŸ“„ License

MIT License β€” see LICENSE for details.


Built with 🧠 by Nick β€” Cardify / Claw Club

About

🧠 Self-evolving cognitive agent framework β€” 5-cortex architecture, tri-store memory with metabolism, 4-layer reasoning, swarm intelligence, and zero-trust security. Python 3.12+

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages