Files
blackroad-operating-system/operator_engine/server.py
Claude e84407660d 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.
2025-11-18 03:47:13 +00:00

61 lines
1.6 KiB
Python

"""Operator Engine HTTP Server (Optional)"""
from fastapi import FastAPI, HTTPException
from typing import List, Dict, Any
import uvicorn
from operator_engine.config import settings
from operator_engine.jobs import Job, job_registry
from operator_engine.scheduler import scheduler
app = FastAPI(
title=settings.APP_NAME,
version=settings.APP_VERSION,
description="BlackRoad Operator Engine - Job scheduling and workflow orchestration",
)
@app.get("/health")
async def health_check():
"""Health check endpoint"""
return {"status": "healthy", "version": settings.APP_VERSION}
@app.get("/jobs", response_model=List[Dict[str, Any]])
async def list_jobs():
"""List all jobs in the registry"""
jobs = job_registry.list_jobs()
return [job.to_dict() for job in jobs]
@app.get("/jobs/{job_id}")
async def get_job(job_id: str):
"""Get a specific job by ID"""
job = job_registry.get_job(job_id)
if not job:
raise HTTPException(status_code=404, detail="Job not found")
return job.to_dict()
@app.post("/jobs/{job_id}/execute")
async def execute_job(job_id: str):
"""Execute a job immediately"""
job = await scheduler.execute_job(job_id)
if not job:
raise HTTPException(status_code=404, detail="Job not found")
return job.to_dict()
@app.get("/scheduler/status")
async def get_scheduler_status():
"""Get scheduler status"""
return scheduler.get_status()
if __name__ == "__main__":
uvicorn.run(
"operator_engine.server:app",
host="0.0.0.0",
port=8001,
reload=True,
)