Major WHOOSH system refactoring and feature enhancements
- Migrated from HIVE branding to WHOOSH across all components - Enhanced backend API with new services: AI models, BZZZ integration, templates, members - Added comprehensive testing suite with security, performance, and integration tests - Improved frontend with new components for project setup, AI models, and team management - Updated MCP server implementation with WHOOSH-specific tools and resources - Enhanced deployment configurations with production-ready Docker setups - Added comprehensive documentation and setup guides - Implemented age encryption service and UCXL integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
BIN
backend/app/core/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/app/core/__pycache__/auth_deps.cpython-310.pyc
Normal file
BIN
backend/app/core/__pycache__/auth_deps.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/app/core/__pycache__/auth_deps.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/auth_deps.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend/app/core/__pycache__/database.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/database.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/app/core/__pycache__/error_handlers.cpython-310.pyc
Normal file
BIN
backend/app/core/__pycache__/error_handlers.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/app/core/__pycache__/error_handlers.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/error_handlers.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/app/core/__pycache__/security.cpython-310.pyc
Normal file
BIN
backend/app/core/__pycache__/security.cpython-310.pyc
Normal file
Binary file not shown.
BIN
backend/app/core/__pycache__/security.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/security.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,4 +11,4 @@ async def get_current_user(token: Optional[str] = Depends(security)):
|
||||
return {"id": "anonymous", "username": "anonymous"}
|
||||
|
||||
# In production, validate the JWT token here
|
||||
return {"id": "user123", "username": "hive_user"}
|
||||
return {"id": "user123", "username": "whoosh_user"}
|
||||
@@ -8,7 +8,7 @@ import time
|
||||
import logging
|
||||
|
||||
# Enhanced database configuration with connection pooling
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:hive123@hive_postgres:5432/hive")
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:whoosh123@whoosh_postgres:5432/whoosh")
|
||||
|
||||
# Create engine with connection pooling and reliability features
|
||||
if "sqlite" in DATABASE_URL:
|
||||
|
||||
@@ -19,10 +19,10 @@ import hashlib
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Performance Metrics
|
||||
TASK_COUNTER = Counter('hive_tasks_total', 'Total tasks processed', ['task_type', 'agent'])
|
||||
TASK_DURATION = Histogram('hive_task_duration_seconds', 'Task execution time', ['task_type', 'agent'])
|
||||
ACTIVE_TASKS = Gauge('hive_active_tasks', 'Currently active tasks', ['agent'])
|
||||
AGENT_UTILIZATION = Gauge('hive_agent_utilization', 'Agent utilization percentage', ['agent'])
|
||||
TASK_COUNTER = Counter('whoosh_tasks_total', 'Total tasks processed', ['task_type', 'agent'])
|
||||
TASK_DURATION = Histogram('whoosh_task_duration_seconds', 'Task execution time', ['task_type', 'agent'])
|
||||
ACTIVE_TASKS = Gauge('whoosh_active_tasks', 'Currently active tasks', ['agent'])
|
||||
AGENT_UTILIZATION = Gauge('whoosh_agent_utilization', 'Agent utilization percentage', ['agent'])
|
||||
|
||||
class TaskType(Enum):
|
||||
"""Task types for specialized agent assignment"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Centralized Error Handling for Hive API
|
||||
Centralized Error Handling for WHOOSH API
|
||||
|
||||
This module provides standardized error handling, response formatting,
|
||||
and HTTP status code management across all API endpoints.
|
||||
@@ -26,9 +26,9 @@ from ..models.responses import ErrorResponse
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HiveAPIException(HTTPException):
|
||||
class WHOOSHAPIException(HTTPException):
|
||||
"""
|
||||
Custom exception class for Hive API with enhanced error details.
|
||||
Custom exception class for WHOOSH API with enhanced error details.
|
||||
|
||||
Extends FastAPI's HTTPException with additional context and
|
||||
standardized error formatting.
|
||||
@@ -49,7 +49,7 @@ class HiveAPIException(HTTPException):
|
||||
|
||||
# Standard error codes
|
||||
class ErrorCodes:
|
||||
"""Standard error codes used across the Hive API"""
|
||||
"""Standard error codes used across the WHOOSH API"""
|
||||
|
||||
# Authentication & Authorization
|
||||
INVALID_CREDENTIALS = "INVALID_CREDENTIALS"
|
||||
@@ -83,9 +83,9 @@ class ErrorCodes:
|
||||
|
||||
|
||||
# Common HTTP exceptions with proper error codes
|
||||
def agent_not_found_error(agent_id: str) -> HiveAPIException:
|
||||
def agent_not_found_error(agent_id: str) -> WHOOSHAPIException:
|
||||
"""Standard agent not found error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Agent with ID '{agent_id}' not found",
|
||||
error_code=ErrorCodes.AGENT_NOT_FOUND,
|
||||
@@ -93,9 +93,9 @@ def agent_not_found_error(agent_id: str) -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def agent_already_exists_error(agent_id: str) -> HiveAPIException:
|
||||
def agent_already_exists_error(agent_id: str) -> WHOOSHAPIException:
|
||||
"""Standard agent already exists error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail=f"Agent with ID '{agent_id}' already exists",
|
||||
error_code=ErrorCodes.AGENT_ALREADY_EXISTS,
|
||||
@@ -103,9 +103,9 @@ def agent_already_exists_error(agent_id: str) -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def task_not_found_error(task_id: str) -> HiveAPIException:
|
||||
def task_not_found_error(task_id: str) -> WHOOSHAPIException:
|
||||
"""Standard task not found error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Task with ID '{task_id}' not found",
|
||||
error_code=ErrorCodes.TASK_NOT_FOUND,
|
||||
@@ -113,9 +113,9 @@ def task_not_found_error(task_id: str) -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def coordinator_unavailable_error() -> HiveAPIException:
|
||||
def coordinator_unavailable_error() -> WHOOSHAPIException:
|
||||
"""Standard coordinator unavailable error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Coordinator service is currently unavailable",
|
||||
error_code=ErrorCodes.SERVICE_UNAVAILABLE,
|
||||
@@ -123,9 +123,9 @@ def coordinator_unavailable_error() -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def database_error(operation: str, details: Optional[str] = None) -> HiveAPIException:
|
||||
def database_error(operation: str, details: Optional[str] = None) -> WHOOSHAPIException:
|
||||
"""Standard database error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Database operation failed: {operation}",
|
||||
error_code=ErrorCodes.DATABASE_ERROR,
|
||||
@@ -133,9 +133,9 @@ def database_error(operation: str, details: Optional[str] = None) -> HiveAPIExce
|
||||
)
|
||||
|
||||
|
||||
def validation_error(field: str, message: str) -> HiveAPIException:
|
||||
def validation_error(field: str, message: str) -> WHOOSHAPIException:
|
||||
"""Standard validation error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Validation failed for field '{field}': {message}",
|
||||
error_code=ErrorCodes.VALIDATION_ERROR,
|
||||
@@ -144,15 +144,15 @@ def validation_error(field: str, message: str) -> HiveAPIException:
|
||||
|
||||
|
||||
# Global exception handlers
|
||||
async def hive_exception_handler(request: Request, exc: HiveAPIException) -> JSONResponse:
|
||||
async def whoosh_exception_handler(request: Request, exc: WHOOSHAPIException) -> JSONResponse:
|
||||
"""
|
||||
Global exception handler for HiveAPIException.
|
||||
Global exception handler for WHOOSHAPIException.
|
||||
|
||||
Converts HiveAPIException to properly formatted JSON response
|
||||
Converts WHOOSHAPIException to properly formatted JSON response
|
||||
with standardized error structure.
|
||||
"""
|
||||
logger.error(
|
||||
f"HiveAPIException: {exc.status_code} - {exc.detail}",
|
||||
f"WHOOSHAPIException: {exc.status_code} - {exc.detail}",
|
||||
extra={
|
||||
"error_code": exc.error_code,
|
||||
"details": exc.details,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Database initialization script for Hive platform.
|
||||
Database initialization script for WHOOSH platform.
|
||||
Creates all tables and sets up initial data.
|
||||
"""
|
||||
|
||||
@@ -41,8 +41,8 @@ def create_initial_user(db: Session):
|
||||
# Create initial admin user
|
||||
admin_user = User(
|
||||
username="admin",
|
||||
email="admin@hive.local",
|
||||
full_name="Hive Administrator",
|
||||
email="admin@whoosh.local",
|
||||
full_name="WHOOSH Administrator",
|
||||
hashed_password=User.hash_password("admin123"), # Change this!
|
||||
is_active=True,
|
||||
is_superuser=True,
|
||||
|
||||
@@ -109,14 +109,14 @@ class PerformanceMonitor:
|
||||
|
||||
# Task metrics
|
||||
self.task_duration = Histogram(
|
||||
'hive_task_duration_seconds',
|
||||
'whoosh_task_duration_seconds',
|
||||
'Task execution duration',
|
||||
['agent_id', 'task_type'],
|
||||
registry=self.registry
|
||||
)
|
||||
|
||||
self.task_counter = Counter(
|
||||
'hive_tasks_total',
|
||||
'whoosh_tasks_total',
|
||||
'Total tasks processed',
|
||||
['agent_id', 'task_type', 'status'],
|
||||
registry=self.registry
|
||||
@@ -124,21 +124,21 @@ class PerformanceMonitor:
|
||||
|
||||
# Agent metrics
|
||||
self.agent_response_time = Histogram(
|
||||
'hive_agent_response_time_seconds',
|
||||
'whoosh_agent_response_time_seconds',
|
||||
'Agent response time',
|
||||
['agent_id'],
|
||||
registry=self.registry
|
||||
)
|
||||
|
||||
self.agent_utilization = Gauge(
|
||||
'hive_agent_utilization_ratio',
|
||||
'whoosh_agent_utilization_ratio',
|
||||
'Agent utilization ratio',
|
||||
['agent_id'],
|
||||
registry=self.registry
|
||||
)
|
||||
|
||||
self.agent_queue_depth = Gauge(
|
||||
'hive_agent_queue_depth',
|
||||
'whoosh_agent_queue_depth',
|
||||
'Number of queued tasks per agent',
|
||||
['agent_id'],
|
||||
registry=self.registry
|
||||
@@ -146,27 +146,27 @@ class PerformanceMonitor:
|
||||
|
||||
# Workflow metrics
|
||||
self.workflow_duration = Histogram(
|
||||
'hive_workflow_duration_seconds',
|
||||
'whoosh_workflow_duration_seconds',
|
||||
'Workflow completion time',
|
||||
['workflow_type'],
|
||||
registry=self.registry
|
||||
)
|
||||
|
||||
self.workflow_success_rate = Gauge(
|
||||
'hive_workflow_success_rate',
|
||||
'whoosh_workflow_success_rate',
|
||||
'Workflow success rate',
|
||||
registry=self.registry
|
||||
)
|
||||
|
||||
# System metrics
|
||||
self.system_cpu_usage = Gauge(
|
||||
'hive_system_cpu_usage_percent',
|
||||
'whoosh_system_cpu_usage_percent',
|
||||
'System CPU usage percentage',
|
||||
registry=self.registry
|
||||
)
|
||||
|
||||
self.system_memory_usage = Gauge(
|
||||
'hive_system_memory_usage_percent',
|
||||
'whoosh_system_memory_usage_percent',
|
||||
'System memory usage percentage',
|
||||
registry=self.registry
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Unified Hive Coordinator
|
||||
Combines the functionality of HiveCoordinator and DistributedCoordinator into a single,
|
||||
cohesive orchestration system for the Hive platform.
|
||||
Unified WHOOSH Coordinator
|
||||
Combines the functionality of WHOOSHCoordinator and DistributedCoordinator into a single,
|
||||
cohesive orchestration system for the WHOOSH platform.
|
||||
|
||||
DEPRECATED: This module is being refactored. Use unified_coordinator_refactored.py for new implementations.
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Refactored Unified Hive Coordinator
|
||||
Refactored Unified WHOOSH Coordinator
|
||||
|
||||
This version integrates with the Bzzz P2P network by creating GitHub issues,
|
||||
which is the primary task consumption method for the Bzzz agents.
|
||||
@@ -23,7 +23,7 @@ logger = logging.getLogger(__name__)
|
||||
class UnifiedCoordinatorRefactored:
|
||||
"""
|
||||
The coordinator now delegates task execution to the Bzzz P2P network
|
||||
by creating a corresponding GitHub Issue for each Hive task.
|
||||
by creating a corresponding GitHub Issue for each WHOOSH task.
|
||||
"""
|
||||
|
||||
def __init__(self, redis_url: str = "redis://localhost:6379"):
|
||||
@@ -44,7 +44,7 @@ class UnifiedCoordinatorRefactored:
|
||||
if self.is_initialized:
|
||||
return
|
||||
|
||||
logger.info("🚀 Initializing Hive Coordinator with GitHub Bridge...")
|
||||
logger.info("🚀 Initializing WHOOSH Coordinator with GitHub Bridge...")
|
||||
|
||||
try:
|
||||
# Initialize GitHub service
|
||||
@@ -52,7 +52,7 @@ class UnifiedCoordinatorRefactored:
|
||||
self.github_service = GitHubService()
|
||||
logger.info("✅ GitHub Service initialized successfully.")
|
||||
except ValueError as e:
|
||||
logger.error(f"CRITICAL: GitHubService failed to initialize: {e}. The Hive-Bzzz bridge will be INACTIVE.")
|
||||
logger.error(f"CRITICAL: GitHubService failed to initialize: {e}. The WHOOSH-Bzzz bridge will be INACTIVE.")
|
||||
self.github_service = None
|
||||
|
||||
# Initialize other services
|
||||
@@ -65,7 +65,7 @@ class UnifiedCoordinatorRefactored:
|
||||
)
|
||||
|
||||
self.is_initialized = True
|
||||
logger.info("✅ Hive Coordinator initialized successfully")
|
||||
logger.info("✅ WHOOSH Coordinator initialized successfully")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Failed to initialize coordinator: {e}")
|
||||
@@ -76,13 +76,13 @@ class UnifiedCoordinatorRefactored:
|
||||
await self.initialize()
|
||||
self.running = True
|
||||
await self.background_service.start()
|
||||
logger.info("🚀 Hive Coordinator background processes started")
|
||||
logger.info("🚀 WHOOSH Coordinator background processes started")
|
||||
|
||||
async def shutdown(self):
|
||||
logger.info("🛑 Shutting down Hive Coordinator...")
|
||||
logger.info("🛑 Shutting down WHOOSH Coordinator...")
|
||||
self.running = False
|
||||
await self.background_service.shutdown()
|
||||
logger.info("✅ Hive Coordinator shutdown complete")
|
||||
logger.info("✅ WHOOSH Coordinator shutdown complete")
|
||||
|
||||
# =========================================================================
|
||||
# TASK COORDINATION (Delegates to Bzzz via GitHub Issues)
|
||||
@@ -102,16 +102,16 @@ class UnifiedCoordinatorRefactored:
|
||||
payload=context
|
||||
)
|
||||
|
||||
# 1. Persist task to the Hive database
|
||||
# 1. Persist task to the WHOOSH database
|
||||
try:
|
||||
task_dict = {
|
||||
'id': task.id, 'title': f"Task {task.type.value}", 'description': "Task created in Hive",
|
||||
'id': task.id, 'title': f"Task {task.type.value}", 'description': "Task created in WHOOSH",
|
||||
'priority': task.priority, 'status': task.status.value, 'assigned_agent': "BzzzP2PNetwork",
|
||||
'context': task.context, 'payload': task.payload, 'type': task.type.value,
|
||||
'created_at': task.created_at, 'completed_at': None
|
||||
}
|
||||
self.task_service.create_task(task_dict)
|
||||
logger.info(f"💾 Task {task_id} persisted to Hive database")
|
||||
logger.info(f"💾 Task {task_id} persisted to WHOOSH database")
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Failed to persist task {task_id} to database: {e}")
|
||||
|
||||
@@ -120,7 +120,7 @@ class UnifiedCoordinatorRefactored:
|
||||
|
||||
# 3. Create the GitHub issue for the Bzzz network
|
||||
if self.github_service:
|
||||
logger.info(f"🌉 Creating GitHub issue for Hive task {task_id}...")
|
||||
logger.info(f"🌉 Creating GitHub issue for WHOOSH task {task_id}...")
|
||||
# Fire and forget. In a production system, this would have retry logic.
|
||||
asyncio.create_task(
|
||||
self.github_service.create_bzzz_task_issue(task.dict())
|
||||
@@ -153,7 +153,7 @@ class UnifiedCoordinatorRefactored:
|
||||
"""Get coordinator health status."""
|
||||
return {
|
||||
"status": "operational" if self.is_initialized else "initializing",
|
||||
"bridge_mode": "Hive-Bzzz (GitHub Issues)",
|
||||
"bridge_mode": "WHOOSH-Bzzz (GitHub Issues)",
|
||||
"github_service_status": "active" if self.github_service else "inactive",
|
||||
"tracked_tasks": len(self.tasks),
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class Task:
|
||||
created_at: float = None
|
||||
completed_at: Optional[float] = None
|
||||
|
||||
class HiveCoordinator:
|
||||
class WHOOSHCoordinator:
|
||||
def __init__(self):
|
||||
self.tasks: Dict[str, Task] = {}
|
||||
self.task_queue: List[Task] = []
|
||||
@@ -379,7 +379,7 @@ Complete task → respond JSON format specified above."""
|
||||
async def initialize(self):
|
||||
"""Initialize the coordinator with proper error handling"""
|
||||
try:
|
||||
print("Initializing Hive Coordinator...")
|
||||
print("Initializing WHOOSH Coordinator...")
|
||||
|
||||
# Initialize HTTP client session with timeouts
|
||||
self.session = aiohttp.ClientSession(
|
||||
@@ -409,7 +409,7 @@ Complete task → respond JSON format specified above."""
|
||||
await self._test_initial_connectivity()
|
||||
|
||||
self.is_initialized = True
|
||||
print("✅ Hive Coordinator initialized")
|
||||
print("✅ WHOOSH Coordinator initialized")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Coordinator initialization failed: {e}")
|
||||
@@ -423,7 +423,7 @@ Complete task → respond JSON format specified above."""
|
||||
|
||||
async def shutdown(self):
|
||||
"""Enhanced shutdown with proper cleanup"""
|
||||
print("Shutting down Hive Coordinator...")
|
||||
print("Shutting down WHOOSH Coordinator...")
|
||||
|
||||
try:
|
||||
# Cancel any running tasks
|
||||
@@ -451,7 +451,7 @@ Complete task → respond JSON format specified above."""
|
||||
pass
|
||||
|
||||
self.is_initialized = False
|
||||
print("✅ Hive Coordinator shutdown")
|
||||
print("✅ WHOOSH Coordinator shutdown")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Shutdown error: {e}")
|
||||
@@ -533,22 +533,22 @@ Complete task → respond JSON format specified above."""
|
||||
available_agents = len([a for a in db_agents if a.current_tasks < a.max_concurrent])
|
||||
|
||||
# Agent metrics
|
||||
metrics.append(f"hive_agents_total {total_agents}")
|
||||
metrics.append(f"hive_agents_available {available_agents}")
|
||||
metrics.append(f"whoosh_agents_total {total_agents}")
|
||||
metrics.append(f"whoosh_agents_available {available_agents}")
|
||||
|
||||
# Task metrics
|
||||
metrics.append(f"hive_tasks_total {len(self.tasks)}")
|
||||
metrics.append(f"hive_tasks_pending {len([t for t in self.tasks.values() if t.status == TaskStatus.PENDING])}")
|
||||
metrics.append(f"hive_tasks_running {len([t for t in self.tasks.values() if t.status == TaskStatus.IN_PROGRESS])}")
|
||||
metrics.append(f"hive_tasks_completed {len([t for t in self.tasks.values() if t.status == TaskStatus.COMPLETED])}")
|
||||
metrics.append(f"hive_tasks_failed {len([t for t in self.tasks.values() if t.status == TaskStatus.FAILED])}")
|
||||
metrics.append(f"whoosh_tasks_total {len(self.tasks)}")
|
||||
metrics.append(f"whoosh_tasks_pending {len([t for t in self.tasks.values() if t.status == TaskStatus.PENDING])}")
|
||||
metrics.append(f"whoosh_tasks_running {len([t for t in self.tasks.values() if t.status == TaskStatus.IN_PROGRESS])}")
|
||||
metrics.append(f"whoosh_tasks_completed {len([t for t in self.tasks.values() if t.status == TaskStatus.COMPLETED])}")
|
||||
metrics.append(f"whoosh_tasks_failed {len([t for t in self.tasks.values() if t.status == TaskStatus.FAILED])}")
|
||||
|
||||
return "\n".join(metrics)
|
||||
|
||||
# Example usage and testing functions
|
||||
async def demo_coordination():
|
||||
"""Demonstrate the coordination system"""
|
||||
coordinator = HiveCoordinator()
|
||||
coordinator = WHOOSHCoordinator()
|
||||
|
||||
# Add example agents (you'll replace with your actual endpoints)
|
||||
coordinator.add_agent(Agent(
|
||||
Reference in New Issue
Block a user