Skip to content

Elisha630/devmesh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DevMesh β€” Multi-Agent Orchestration Framework

Tests Python License

🎯 Overview

DevMesh is a local multi-agent orchestration framework that lets you coordinate multiple AI CLI tools (Claude, Gemini, Codex, etc.) to work together autonomously on tasks.

Why DevMesh?

  • Leverage Multiple AI Tools β€” Use the best tool for each job (Claude for architecture, Codex for quick scripts, etc.)
  • Autonomous Coordination β€” Agents work together without human intervention
  • Safe Collaboration β€” Lock system prevents agents from stepping on each other's toes
  • Local & Fast β€” No cloud dependencies, everything runs locally with WebSocket coordination
  • Observable β€” Real-time dashboard shows what agents are doing, what they're accessing, and resource usage
  • Extensible β€” Works with any AI CLI tool that accepts a prompt argument

Core Concepts

Agents β€” AI CLI tools (Claude, Gemini, etc.) connected to DevMesh and ready to accept tasks

Tasks β€” Instructions broadcast to all agents; agents bid fairly to claim work

Locks β€” File access control system (READ/WRITE/INTENT/CO_WRITE) to prevent conflicts

Hardware Throttling β€” GPU/RAM limits enforced globally to prevent resource exhaustion

Rulebook β€” 10 design principles that ensure safe multi-agent collaboration

Key Features

  • WebSocket Coordinator β€” Single source of truth for all agent activity
  • Live Dashboard β€” Real-time visualization of tasks, agents, and locks
  • Lock Management β€” READ/WRITE/INTENT/CO_WRITE semantics for safe collaboration
  • Hardware Throttling β€” Resource limits (GPU/RAM) enforced per agent
  • Audit Logging β€” Event history persisted to SQLite and JSONL
  • Configuration Management β€” Environment-based settings with validation
  • Structured Logging β€” Color-coded console output with optional file logging

πŸ“ Project Structure

.
β”œβ”€β”€ server.py              # Main orchestration server (WebSocket + HTTP)
β”œβ”€β”€ agent_bridge.py        # CLI tool wrapper (registers agents with server)
β”œβ”€β”€ client_mock.py         # Test client for development/testing
β”œβ”€β”€ dashboard.html         # Web UI (static asset, served by server)
β”œβ”€β”€ config.py              # Configuration management & validation
β”œβ”€β”€ logger.py              # Structured logging with colored output
β”œβ”€β”€ errors.py              # Custom exception hierarchy
β”œβ”€β”€ storage.py             # SQLite storage + audit logging
β”œβ”€β”€ check_tools.py         # Utility to verify available CLI tools
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ tests/
β”‚   └── test_core.py       # Unit tests
└── .devmesh/
    β”œβ”€β”€ audit.jsonl        # Event audit log (JSONL mirror)
    └── devmesh.db         # SQLite persistence (tasks, agents, audit, projects)

πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • At least one AI CLI tool installed (Claude, Cursor Agent, Gemini, Codex, etc.)
  • Install dependencies: pip install -r requirements.txt

Start the Server

python server.py

The dashboard will automatically open at http://127.0.0.1:7701 and the server listens on ws://127.0.0.1:7700 for agent connections.

Supported AI Tools

DevMesh automatically detects and works with the following AI CLI tools (in order of precedence):

Tool Command Invoke Mode Best For
Claude (via agent CLI) claude arg Code generation, refactoring
Cursor Agent agent arg Agentic tasks with native trust
Google Gemini gemini arg Multi-modal tasks
OpenAI Codex codex arg Code completion, shell commands
Aider aider stdin Pair programming, collaborative editing
Continue continue arg IDE-integrated development
Sourcegraph Cody cody arg Code search & understanding
Ollama ollama arg Local LLM inference
ShellGPT sgpt arg Shell scripting assistance
GitHub Copilot gh arg GitHub-integrated suggestions

All tools run in non-interactive mode (YOLO/auto-approve) to enable fully autonomous operation.

βš™οΈ Configuration

All settings can be overridden via environment variables:

# Server
export DEVMESH_WS_HOST=127.0.0.1
export DEVMESH_WS_PORT=7700
export DEVMESH_HTTP_PORT=7701
export DEVMESH_DASHBOARD_PORT=7702

# Hardware
export DEVMESH_GPU_VRAM_GB=16
export DEVMESH_RAM_GB=32

# Timeouts
export DEVMESH_LOCK_TTL_SEC=15
export DEVMESH_HEARTBEAT_GRACE_SEC=5

# Logging
export DEVMESH_LOG_LEVEL=INFO
export DEVMESH_LOG_FILE=logs/devmesh.log

See config.py for all available settings.

πŸ“Š How It Works

Event Flow

  1. Server Startup β€” WebSocket listeners start; Dashboard opens in browser
  2. Agent Registration β€” Agent CLI connects, declares tool name and resource requirements
  3. Tool Detection β€” Server checks if agent command is available in PATH
  4. Task Broadcast β€” User sends task from dashboard; server broadcasts to all connected agents
  5. Lock Negotiation β€” Agents request locks (READ/WRITE/INTENT/CO_WRITE) before accessing files
  6. Execution β€” Agent runs CLI tool with task prompt; captures structured JSON output
  7. Results Collection β€” Agent reports completion, release locks; results stored in audit log
  8. Display β€” Dashboard updates in real time with results, logs, and hardware metrics

Lock Management System

The lock system prevents conflicts when multiple agents access the same files:

  • READ β€” Multiple agents can hold simultaneously; blocks WRITE/INTENT
  • WRITE β€” Exclusive access; only one agent at a time
  • INTENT β€” Signal that you'll write soon; blocks other INTENT locks
  • CO_WRITE β€” Pair programming mode; multiple agents can write collaboratively

Task Lifecycle

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ QUEUED  β”‚ Task created, waiting for agent to claim
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
     β”‚
     ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ CLAIMED β”‚ Agent has accepted the task
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
     β”‚
     ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ WORKING β”‚ Agent is executing the task
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
     β”‚
     +─────────────────────────┐
     ↓                         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚COMPLETED β”‚            β”‚  FAILED  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     ↑
     └─┬──────────────────────┐
       ↓                      ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ABANDONED   β”‚         β”‚  PAUSED *   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     
* PAUSED: Not fully implemented yet (reserved for future use)

Hardware Resource Tracking

Each agent declares its resource needs (VRAM, RAM). The server tracks allocation:

  • Allocation Request β€” Agent requests GPU/RAM; server checks available capacity
  • Grant or Deny β€” If capacity available, allocate. Otherwise reject with available resources
  • Release β€” When agent disconnects or task completes, resources freed automatically
  • Global Limits β€” All allocations checked against system-wide GPU/RAM limits (env-configurable)

πŸ”§ Implementation Details

Server (server.py)

  • WebSocket Server β€” Listens on ws://127.0.0.1:7700 for agent connections
  • HTTP Server β€” Serves dashboard and provides REST API endpoints on :7701
  • Dashboard WebSocket β€” Separate connection on :7702 for real-time UI updates
  • State Management β€” Maintains authoritative state for agents, tasks, locks, and hardware
  • Lock Arbitration β€” Implements lock request handling with conflict resolution
  • Heartbeat Monitor β€” Tracks agent activity; auto-releases locks on timeout

Agent Bridge (agent_bridge.py)

  • CLI Wrapper β€” Wraps any AI CLI tool for DevMesh integration
  • Resource Declaration β€” Reports tool name, capabilities, and resource requirements
  • Task Execution β€” Receives tasks via WebSocket, runs CLI tool with task prompt
  • Lock Requests β€” Negotiates file locks with server before accessing files
  • Structured Output β€” Parses tool output, captures stdout/stderr, reports results

Dashboard (dashboard.html)

  • Real-Time UI β€” Live task list, agent status, lock visualization
  • Task Command Center β€” Text input for broadcasting tasks to all agents
  • Hardware Monitor β€” Graphs GPU/RAM usage over time
  • Event Log β€” Raw stdout/stderr output and structured event stream
  • Knowledge Base β€” RAG discoveries shared across agents

Storage Layer (storage.py)

  • Task Persistence β€” SQLite tasks table with full task metadata
  • Agent Registry β€” Persistent record of connected agents, capabilities, resources
  • Audit Logging β€” Every event (lock request, task completion, etc.) logged to .devmesh/audit.jsonl
  • Thread-Safe Queue β€” Write queue prevents concurrent SQLite access issues
  • Backup & Recovery β€” Audit log mirrored to both SQLite and JSONL for durability

Configuration (config.py)

  • Centralized Settings β€” All environment variables and defaults in one place
  • Tool Profiles β€” Command templates and capability declarations for each AI CLI tool
  • Type Validation β€” Validates port ranges, file paths, resource limits on startup
  • Environment Override β€” Any setting overrideable via DEVMESH_* environment variables
  • Tool Detection β€” Lists all registered tools with their CLI commands and invoke modes

Logging (logger.py)

  • Structured Output β€” Timestamps, log levels, module names in every message
  • Color Coding β€” Different colors for DEBUG (blue), INFO (green), WARN (yellow), ERROR (red)
  • File Output β€” Optional file logging (set DEVMESH_LOG_FILE)
  • Readable Format β€” Easy to scan during development and debugging

Error Handling (errors.py)

  • Exception Hierarchy β€” Base DevMeshError with specific subclasses for different scenarios
  • JSON Serialization β€” All errors convertible to JSON for dashboard/API responses
  • Context Info β€” Each error includes relevant context for debugging
  • Error Codes β€” Structured codes (e.g., TOOL_NOT_FOUND, LOCK_TIMEOUT) for programmatic handling

πŸŽ“ Design Patterns

Rulebook (Rules 1-10)

DevMesh enforces a set of rules to ensure safe multi-agent collaboration:

# Rule Description
1 Framework Authority First agent becomes ARCHITECT
2 No Task Assignment Agents bid fairly; server arbitrates
3 Lock Hierarchy INTENT β†’ WRITE β†’ READ with clear semantics
4 Heartbeat Obligation Keep-alive signals or auto-release lock
5 Critic Requirement Code review by second agent if flagged
6 Hardware Throttle Respect GPU/RAM limits globally
7 Read Before Work Non-ARCHITECT agents read framework first
8 Diff-Based Writes Track file changes, prevent duplicates
9 Pub/Sub File Events Real-time change notifications
10 Single Source of Truth Server is authoritative state holder

πŸ“ˆ What's Implemented

Core Features βœ…

  • βœ… WebSocket Coordinator β€” Single source of truth for all agent activity, tasks, and locks
  • βœ… Live Dashboard β€” Real-time web UI with task tracking, agent monitoring, and lock visualization
  • βœ… Lock Management β€” READ/WRITE/INTENT/CO_WRITE semantics for safe collaboration between agents
  • βœ… Hardware Throttling β€” Global GPU/RAM limits enforced per each agent connection
  • βœ… Audit Logging β€” Complete event history persisted to SQLite and mirrored to JSONL
  • βœ… Configuration Management β€” Environment-based settings with validation and defaults
  • βœ… Structured Logging β€” Color-coded console output with optional file logging
  • βœ… Non-Interactive Mode β€” All tools run with auto-approval flags for autonomous operation
  • βœ… Multi-Tool Support β€” Works with 10+ different AI CLI tools via unified interface

Still TODO (Potential Future Work)

These features are out of scope for the current release:

  • PostgreSQL backend (SQLite is sufficient for most use cases)
  • Kubernetes operator support (local orchestration is the focus)
  • Slack/Discord bot notifications
  • Git-based file versioning (can be added as a storage layer)
  • Advanced performance profiling via Prometheus metrics

πŸ§ͺ Testing & Development

Run Tests

# Run all tests
pytest tests/ -v

# Run specific test file
pytest tests/test_core.py -v

# Run with coverage
pytest tests/ --cov=. --cov-report=term-missing

Development Setup

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install dev dependencies
pip install -r requirements.txt
pip install pytest pytest-cov

# Start server in debug mode
DEVMESH_LOG_LEVEL=DEBUG python server.py

Testing with Mock Agents

# Terminal 1: Start server
python server.py

# Terminal 2: Connect a mock agent
python client_mock.py --model architect

# Terminal 3: Connect another agent
python client_mock.py --model agent1

# Terminal 4: Send tasks via dashboard at http://127.0.0.1:7701

Checking Available Tools

python check_tools.py

Lists all AI CLI tools detected in your PATH and their versions.

πŸ“ License

MIT License β€” See LICENSE for details.

🀝 Contributing

Contributions are welcome! Here's how to get started:

Before You Code

  1. Open an issue β€” Describe the feature or bug you want to fix
  2. Get feedback β€” Wait for maintainer feedback before large changes
  3. Check the Rulebook β€” Understand the 10 design principles in the rulebook

Code Style

  • Python 3.12+ β€” Use modern Python features (type hints, dataclasses, etc.)
  • PEP 8 Compliance β€” Format code with black or autopep8
  • Type Hints β€” All functions must have complete type annotations
  • Docstrings β€” Document public functions and classes with docstrings
  • Immutability β€” Prefer immutable data structures where possible

Testing

  • Unit Tests β€” Write tests for all new functions in tests/
  • Integration Tests β€” Test interactions between components
  • Coverage β€” Aim for 80%+ code coverage
  • Run Before PR β€” Ensure all tests pass: pytest tests/ -v

Documentation

  • README Updates β€” Reflect changes to user-facing features
  • Inline Comments β€” Explain complex logic with comments
  • Commit Messages β€” Use descriptive messages (e.g., "fix: resolve lock timeout in agent bridge")
  • CHANGELOG β€” Update any breaking changes

PR Process

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit with clear messages
  4. Push to your fork
  5. Open a PR with description of changes
  6. Address review feedback
  7. Merge when approved

About

DevMesh is a local multi-agent orchestration system that coordinates multiple AI CLI tools (Claude, Gemini, Ollama, etc.) to work together on tasks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors