Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "BlackRoad Agent Codespace",
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",

"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},

"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"github.copilot",
"github.copilot-chat",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker",
"eamodio.gitlens",
"Continue.continue"
],
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"files.autoSave": "onFocusChange",
"terminal.integrated.defaultProfile.linux": "bash"
}
}
},

"postCreateCommand": "bash .devcontainer/setup.sh",

"forwardPorts": [
8080,
3000,
5000,
11434,
8787
],

"portsAttributes": {
"8080": {
"label": "BlackRoad Operator",
"onAutoForward": "notify"
},
"3000": {
"label": "Web UI",
"onAutoForward": "openPreview"
},
"5000": {
"label": "Hailo Inference",
"onAutoForward": "silent"
},
"11434": {
"label": "Ollama API",
"onAutoForward": "silent"
},
"8787": {
"label": "Wrangler Dev",
"onAutoForward": "notify"
}
},

"remoteEnv": {
"PYTHONPATH": "${containerWorkspaceFolder}",
"BLACKROAD_ENV": "codespace",
"NODE_ENV": "development"
},

"mounts": [
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,readonly,type=bind,consistency=cached"
],

"postAttachCommand": "./quickstart.sh"
}
130 changes: 130 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash
set -e

echo "🔧 Setting up BlackRoad Agent Codespace..."

# Update package list
sudo apt-get update

# Install system dependencies
echo "📦 Installing system dependencies..."
sudo apt-get install -y \
build-essential \
curl \
wget \
git \
jq \
vim \
htop \
redis-tools \
postgresql-client

# Install Python dependencies
echo "🐍 Installing Python dependencies..."
pip install --upgrade pip
pip install black pylint pytest

# Install core prototypes dependencies
if [ -f "prototypes/operator/requirements.txt" ]; then
pip install -r prototypes/operator/requirements.txt
fi

if [ -f "prototypes/mcp-server/requirements.txt" ]; then
pip install -r prototypes/mcp-server/requirements.txt
fi

if [ -f "templates/ai-router/requirements.txt" ]; then
pip install -r templates/ai-router/requirements.txt
fi

# Install AI/ML libraries
echo "🤖 Installing AI/ML libraries..."
pip install \
openai \
anthropic \
ollama \
langchain \
langchain-community \
langchain-openai \
tiktoken \
transformers \
numpy \
fastapi \
uvicorn \
websockets

# Install PyTorch (CUDA-enabled if GPU is available, otherwise CPU-only)
echo "🧠 Installing PyTorch..."
if command -v nvidia-smi >/dev/null 2>&1; then
echo "Detected NVIDIA GPU. Attempting to install CUDA-enabled PyTorch..."
if ! pip install --index-url https://download.pytorch.org/whl/cu121 torch; then
echo "CUDA-enabled PyTorch installation failed; falling back to CPU-only build."
pip install torch
fi
else
echo "No NVIDIA GPU detected. Installing CPU-only PyTorch..."
pip install torch
fi
# Install Cloudflare Workers CLI (Wrangler)
echo "☁️ Installing Cloudflare Wrangler..."
npm install -g wrangler

# Install Ollama for local model hosting
echo "🦙 Installing Ollama..."
if curl -fsSL https://ollama.ai/install.sh | sh; then
echo "✅ Ollama installed successfully"
OLLAMA_INSTALLED=true
else
echo "⚠️ Ollama installation skipped (may require system permissions)"
OLLAMA_INSTALLED=false
fi

# Create necessary directories
echo "📁 Creating directories..."
mkdir -p /tmp/blackroad/{cache,logs,models}

# Initialize Ollama models (in background) only if Ollama was installed
if [ "$OLLAMA_INSTALLED" = true ] && command -v ollama >/dev/null 2>&1; then
echo "📥 Pulling open source AI models..."
(
LOG_FILE="/tmp/blackroad/logs/ollama_model_pull.log"

# Wait for Ollama to be ready
sleep 5

echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] Starting Ollama model pulls..." > "$LOG_FILE" 2>&1

# Pull popular open source models
ollama pull llama3.2:latest >> "$LOG_FILE" 2>&1 || echo "Skipped llama3.2"
ollama pull codellama:latest >> "$LOG_FILE" 2>&1 || echo "Skipped codellama"
ollama pull mistral:latest >> "$LOG_FILE" 2>&1 || echo "Skipped mistral"
ollama pull qwen2.5-coder:latest >> "$LOG_FILE" 2>&1 || echo "Skipped qwen2.5-coder"
ollama pull deepseek-coder:latest >> "$LOG_FILE" 2>&1 || echo "Skipped deepseek-coder"
ollama pull phi3:latest >> "$LOG_FILE" 2>&1 || echo "Skipped phi3"
ollama pull gemma2:latest >> "$LOG_FILE" 2>&1 || echo "Skipped gemma2"

echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] Model downloads complete" >> "$LOG_FILE" 2>&1
echo "✅ Model downloads initiated (check /tmp/blackroad/logs/ollama_model_pull.log for details)"
) &
else
echo "⚠️ Ollama is not installed; skipping model downloads."
fi

# Set up git config
echo "⚙️ Configuring git..."
git config --global --add safe.directory /workspaces/.github

# Make bridge executable
if [ -f "bridge" ]; then
chmod +x bridge
fi

echo ""
echo "✨ BlackRoad Agent Codespace setup complete!"
echo ""
echo "Available commands:"
echo " python -m operator.cli # Run the operator"
echo " ollama list # List available models"
echo " wrangler dev # Start Cloudflare Worker"
echo " ./bridge status # Check system status"
echo ""
62 changes: 62 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual environments
venv/
ENV/
env/
.venv

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Logs
*.log
/tmp/

# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Cloudflare
.wrangler/
wrangler.toml.backup

# Local development
.env
.env.local
*.local

# AI model downloads (too large)
*.gguf
*.bin
*.safetensors
Loading