feat: scaffold BlackRoad OS Phase 2 infrastructure

Implements complete Phase 2 scaffold across 6 core modules:

## New Modules

### 1. Backend API Enhancements
- Add system router with /version, /config/public, /os/state endpoints
- Register system router in main.py
- Add comprehensive tests for system endpoints

### 2. Core OS Runtime (core_os/)
- Implement UserSession, Window, OSState models
- Add state management functions (open_window, close_window, etc.)
- Create Backend API adapter for communication
- Include full test suite for models and state

### 3. Operator Engine (operator_engine/)
- Build job registry with example jobs
- Implement simple scheduler with lifecycle management
- Optional HTTP server on port 8001
- Complete tests for jobs and scheduler

### 4. Web Client Enhancements
- Add CoreOSClient JavaScript class
- Integrate system API endpoints
- Event-driven architecture for state updates
- Zero dependencies, vanilla JavaScript

### 5. Prism Console (prism-console/)
- Modern dark-themed admin UI
- Multi-tab navigation (Overview, Jobs, Agents, Logs, System)
- Real-time metrics dashboard
- Backend API integration with auto-refresh

### 6. Documentation (codex-docs/)
- Complete MkDocs-based documentation
- Architecture guides and component docs
- Infrastructure setup guides
- API reference documentation

## CI/CD

- Add core-os-tests.yml workflow
- Add operator-tests.yml workflow
- Add docs-build.yml workflow

## Documentation

- Create BLACKROAD_OS_REPO_MAP.md cross-reference
- Add README for each module
- Comprehensive integration documentation

## Summary

- 37 new files created
- ~3,500 lines of new code
- 5 test suites with 15+ tests
- 3 new CI workflows
- 10+ documentation pages

All modules are minimal working skeletons ready for integration.
Designed to be extracted into separate repos if needed.

Phase 2 scaffold complete and ready for review.
This commit is contained in:
Claude
2025-11-18 03:47:13 +00:00
parent 9d90d3eb2e
commit e84407660d
38 changed files with 4443 additions and 1 deletions

129
core_os/models.py Normal file
View File

@@ -0,0 +1,129 @@
"""Core OS data models"""
from dataclasses import dataclass, field
from datetime import datetime
from typing import List, Optional, Dict, Any
from enum import Enum
import uuid
class WindowState(str, Enum):
"""Window state"""
NORMAL = "normal"
MINIMIZED = "minimized"
MAXIMIZED = "maximized"
CLOSED = "closed"
@dataclass
class UserSession:
"""
Represents a user session in BlackRoad OS
Attributes:
id: Unique session identifier
user_id: User ID (from auth system)
display_name: Display name for the session
created_at: Session creation timestamp
last_activity: Last activity timestamp
metadata: Additional session metadata
"""
id: str = field(default_factory=lambda: str(uuid.uuid4()))
user_id: Optional[str] = None
display_name: str = "Guest"
created_at: datetime = field(default_factory=datetime.utcnow)
last_activity: datetime = field(default_factory=datetime.utcnow)
metadata: Dict[str, Any] = field(default_factory=dict)
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary"""
return {
"id": self.id,
"user_id": self.user_id,
"display_name": self.display_name,
"created_at": self.created_at.isoformat(),
"last_activity": self.last_activity.isoformat(),
"metadata": self.metadata,
}
@dataclass
class Window:
"""
Represents a window in the OS
Attributes:
id: Unique window identifier
app_id: Application identifier
title: Window title
state: Window state (normal, minimized, maximized)
position: Window position (x, y)
size: Window size (width, height)
z_index: Z-index for layering
created_at: Window creation timestamp
metadata: Additional window metadata
"""
id: str = field(default_factory=lambda: str(uuid.uuid4()))
app_id: str = ""
title: str = "Untitled"
state: WindowState = WindowState.NORMAL
position: tuple[int, int] = (100, 100)
size: tuple[int, int] = (800, 600)
z_index: int = 0
created_at: datetime = field(default_factory=datetime.utcnow)
metadata: Dict[str, Any] = field(default_factory=dict)
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary"""
return {
"id": self.id,
"app_id": self.app_id,
"title": self.title,
"state": self.state.value,
"position": {"x": self.position[0], "y": self.position[1]},
"size": {"width": self.size[0], "height": self.size[1]},
"z_index": self.z_index,
"created_at": self.created_at.isoformat(),
"metadata": self.metadata,
}
@dataclass
class OSState:
"""
Represents the current state of the operating system
Attributes:
session: Current user session
windows: List of open windows
active_window_id: ID of the currently active window
desktop_items: Desktop icons/shortcuts
taskbar_items: Taskbar items
system_tray_items: System tray items
theme: Current theme name
metadata: Additional OS state metadata
"""
session: UserSession = field(default_factory=UserSession)
windows: List[Window] = field(default_factory=list)
active_window_id: Optional[str] = None
desktop_items: List[Dict[str, Any]] = field(default_factory=list)
taskbar_items: List[Dict[str, Any]] = field(default_factory=list)
system_tray_items: List[Dict[str, Any]] = field(default_factory=list)
theme: str = "classic"
metadata: Dict[str, Any] = field(default_factory=dict)
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary"""
return {
"session": self.session.to_dict(),
"windows": [w.to_dict() for w in self.windows],
"active_window_id": self.active_window_id,
"desktop_items": self.desktop_items,
"taskbar_items": self.taskbar_items,
"system_tray_items": self.system_tray_items,
"theme": self.theme,
"metadata": self.metadata,
}