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
52 changes: 52 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: KhulnaSoft AI Compute Grid - Deploy

on:
push:
branches: [ main ]
paths:
- 'platform/**'
- 'runtime/**'
- 'infra/k8s/**'
pull_request:
branches: [ main ]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat .github/workflows/deploy.yml

Repository: CtxOS/ctxpod

Length of output: 1372


🌐 Web query:

actions/checkout v4 latest version 2024 2025

💡 Result:

The latest version of actions/checkout v4 is v4.3.1, released on 2025-11-17. This ports cleanup changes from v6 to the v4 branch. Prior versions include v4.3.0 (2025-08-11, documentation and dependency updates), v4.2.2 (2024-10), v4.2.0 (2024-09-25), and v4.0.0 (2023-10-17, updated to node20 runtime). Use uses: actions/checkout@v4 to pin to the v4 branch, which always points to the latest v4 release. Note that newer major versions like v6.0.2 (2026-01-09) exist with Node.js 24 support.

Citations:


🌐 Web query:

docker/setup-buildx-action latest version 2024 2025

💡 Result:

The latest version of the docker/setup-buildx-action GitHub Action is v4.0.0, released on 2026-03-05. This is a major release featuring Node 24 as the default runtime (requires Actions Runner v2.327.1+), removal of deprecated inputs/outputs, switch to ESM, and various dependency updates including @actions/core to 3.0.0 and @docker/actions-toolkit to 0.79.0. Previous recent versions: - v3.12.0 (2025-12-19): Deprecated install input, dependency bumps. - v3.11.1 and earlier in 2025. Usage example from official docs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 Repository last pushed on 2026-04-09 (as of search data), confirming v4.0.0 remains latest. Official Docker docs and GitHub Marketplace also reference v4.

Citations:


🌐 Web query:

docker/login-action latest version 2024 2025

💡 Result:

The latest version of the docker/login-action GitHub Action is v4.1.0, released on April 2, 2026. This is the current latest as of 2026-04-16. Recent releases in 2024-2026: - v4.1.0 (2026-04-02): Fix scoped Docker Hub cleanup path, dependency bumps including @aws-sdk/client-ecr to 3.1020.0 and @docker/actions-toolkit to 0.86.0. - v4.0.0 (2026-03-04): Node 24 as default runtime, switch to ESM, major dependency updates like @actions/core to 3.0.0. Usage example from official docs: - name: Login to Docker Hub uses: docker/login-action@v4.1.0 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} Official repository: https://github.com/docker/login-action

Citations:


🌐 Web query:

docker/build-push-action latest version 2024 2025

💡 Result:

The latest version of the docker/build-push-action GitHub Action is v7.1.0, released on 2026-04-10. This is confirmed by the GitHub releases page listing it as the top release dated 10 Apr (which aligns with 2026-04-10 given today's date of 2026-04-16), and the tags page showing v7.1.0 as the first tag. Previous versions include v7.0.0 (2026-03-05) and v6.19.x in early 2026. In 2024, versions were in the v6.x series (e.g., v6.4.0 in July 2024), and in 2025 leading up to v6.19.0 in February 2026. Official examples in the README and Marketplace use v7.

Citations:


Update GitHub Actions to current major versions.

These pinned action versions are significantly outdated. Update to the latest available versions:

  • actions/checkout@v3 → use v4 or latest v6
  • docker/setup-buildx-action@v2 → use v3 or latest v4
  • docker/login-action@v2 → use latest v3 or v4
  • docker/build-push-action@v4 → use latest v6 or v7

The major versions in the workflow file are no longer current and may face compatibility issues with modern GitHub runners.

🧰 Tools
🪛 actionlint (1.7.12)

[error] 17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/deploy.yml at line 17, Update the pinned GitHub Action
versions to current majors: replace uses: actions/checkout@v3 with a current
major (e.g., actions/checkout@v4 or `@v6`), update docker/setup-buildx-action@v2
to v3 or v4, docker/login-action@v2 to v3 or v4, and docker/build-push-action@v4
to v6 or v7; make these replacements where those action usages
(actions/checkout, docker/setup-buildx-action, docker/login-action,
docker/build-push-action) appear in the workflow so the workflow uses
maintained, compatible major versions.


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push AI Worker Image
uses: docker/build-push-action@v4
with:
context: .
file: runtime/images/worker.Dockerfile
push: true
tags: khulnasoft/ai-worker:latest

deploy-to-k8s:
needs: build-and-push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3

- name: Set up Kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config

- name: Deploy Infrastructure
run: |
kubectl apply -f infra/k8s/gpu/device-plugin.yaml
kubectl apply -f infra/k8s/ray/head.yaml
kubectl apply -f infra/k8s/ray/worker.yaml
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

102 changes: 46 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,71 @@
# CtxPod - AI-Powered IDE Platform
# 🚀 KhulnaSoft AI Compute Grid

A Gitpod-like development environment with autonomous AI agents that can plan, code, test, debug, and deploy automatically.
A production-grade deployment pack for a hybrid GPU cluster (local + cloud) tailored for AI-native platforms and distributed pentesting pipelines.

## 🚀 Quick Start
## 🌟 Features

### Prerequisites
- Docker and Docker Compose
- Node.js 16+
- OpenAI API key (for AI agents)
- **Hybrid GPU Scaling**: Routes jobs between local and cloud clusters based on availability and priority.
- **Ray-Based Compute**: Leverages [Ray](https://ray.io) for seamless distributed Python execution.
- **K8s & GPU Ready**: Includes manifests for NVIDIA Device Plugin and GPU-aware worker deployments.
- **Secure by Default**: Example security contexts and isolated runtime configurations.
- **Smart Control Plane**: FastAPI-based API with Redis job tracking and status monitoring.

### Installation
## 🏗️ Repository Structure

1. Clone and setup:
```bash
cp .env.example .env
# Edit .env with your OpenAI key
infra/
terraform/cloud/ # AWS/Cloud GPU provisioning
ansible/ # Node bootstrapping (Docker, NVIDIA drivers)
k8s/ # K8s manifests (GPU plugin, Ray cluster)
platform/
api/ # FastAPI job submission API
scheduler/ # Smart routing logic
runtime/
ray/ # AI task definitions
agents/ # Example client implementations
```

2. Build workspace image:
## 🚀 Quick Start

### 1. Provision Cloud Infrastructure
```bash
npm run build:docker
cd infra/terraform/cloud
terraform init
terraform apply
```

3. Start the platform:
### 2. Bootstrap Nodes (Local or Cloud)
```bash
npm run docker:run
cd infra/ansible
ansible-playbook -i inventory.ini gpu-node.yml
```

4. Create a workspace:
### 3. Deploy Kubernetes Cluster
```bash
curl -X POST http://localhost:3000/workspace
kubectl apply -f infra/k8s/gpu/device-plugin.yaml
kubectl apply -f infra/k8s/ray/head.yaml
kubectl apply -f infra/k8s/ray/worker.yaml
```

## 📋 Architecture

- **Control Server** (Node.js) - Manages workspaces and orchestrates agents
- **code-server** - Browser-based VS Code IDE
- **Docker** - Isolated workspace containers
- **Redis + BullMQ** - Queue-based agent system
- **AI Agents** - Autonomous coding agents

## 🛠️ Development

### 4. Run the Platform
```bash
# Start control server only
npm start
# Start API (Port 8000)
uvicorn platform.api.main:app --host 0.0.0.0

# Start with Docker Compose (includes Redis)
npm run docker:run

# Build Docker workspace image
npm run build:docker
# Start Scheduler
python platform/scheduler/scheduler.py
```

## 📚 API Endpoints

- `POST /workspace` - Create new workspace
- `GET /workspaces` - List all workspaces
- `GET /workspace/:id` - Get workspace details
- `DELETE /workspace/:id` - Stop workspace

## 🤖 AI Agents

Coming soon:
- **Planner Agent** - Breaks tasks into steps
- **Coder Agent** - Writes production code
- **Tester Agent** - Runs automated tests
- **Debugger Agent** - Fixes errors
- **Deployer Agent** - Ships to production
### 5. Submit a Job
```bash
python agents/example_agent.py
```

## 🔧 Configuration
## 🔐 Security & Observability

Edit `.env` for:
- OpenAI API key
- Redis connection
- Server settings
- **Sandboxing**: Pods are configured with restricted security contexts. Advanced isolation via gVisor is recommended for multi-tenant environments.
- **Monitoring**: Integration with Prometheus & Grafana is supported via Ray's native exporters.

## 📄 License
## 🤝 Contributing

MIT
This is a production blueprint. Please adapt configurations (AMIs, regions, instance types) to your specific requirements before final deployment.
48 changes: 48 additions & 0 deletions agents/example_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import requests
import time
import json
import logging

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("AIAgent")

API_URL = "http://localhost:8000"

def submit_and_wait(task_type, params):
payload = {
"task_type": task_type,
"params": params,
"priority": 1
}

try:
# Submit job
response = requests.post(f"{API_URL}/submit", json=payload)
response.raise_for_status()
job_id = response.json()["job_id"]
logger.info(f"Submitted {task_type} job. ID: {job_id}")

# Poll for status
while True:
status_resp = requests.get(f"{API_URL}/job/{job_id}")
status_resp.raise_for_status()
job_data = status_resp.json()

status = job_data.get("status")
logger.info(f"Job {job_id} status: {status}")

if "running" in status or "completed" in status:
return job_data

time.sleep(2)

except Exception as e:
logger.error(f"Error communicating with Grid API: {str(e)}")
return None

if __name__ == "__main__":
logger.info("Starting AI Agent example...")
result = submit_and_wait("CVE-Scanner", {"target": "khulnasoft.com", "depth": "advanced"})
if result:
print(f"Final Job State: {json.dumps(result, indent=2)}")
30 changes: 30 additions & 0 deletions agents/types/base_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import abc
import logging
from typing import Dict, Any

logger = logging.getLogger("GridAgent")

class Agent(abc.ABC):
"""
Formalized Base Agent for the multi-agent orchestration system.
Every agent must implement the 'run' method with input_data and context.
"""
def __init__(self, agent_id: str, role: str, config: Dict[str, Any] = None):
self.id = agent_id
self.role = role
self.config = config or {}
self.status = "idle"

@abc.abstractmethod
def run(self, input_data: Any, context: Dict[str, Any] = None) -> Dict[str, Any]:
"""
Main execution logic.
"""
pass

def log_decision(self, action: str, rationale: str, data: Any = None):
"""
Helper to record autonomous decisions for the audit trail.
"""
logger.info(f"[{self.role}] ACTION: {action} | RATIONALE: {rationale}")
# In production, this would call the platform/audit/logger.py
45 changes: 45 additions & 0 deletions agents/types/specialized.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from typing import Dict, Any, List
from agents.types.base_agent import Agent

class PlannerAgent(Agent):
"""
Agent specialized in decomposing complex goals into DSL workflows.
"""
def __init__(self, agent_id: str, config: Dict[str, Any] = None):
super().__init__(agent_id, "Planner", config)

def run(self, goal: Any, context: Dict[str, Any] = None) -> Dict[str, Any]:
self.log_decision("Generate Workflow", f"Decomposing goal: {goal}")
# Simplified mock logic - would call workflow_generator.py
return {
"type": "autonomous_scan",
"workflow": [
{"name": "Recon", "agent": "recon", "params": {"target": goal}}
]
}

class CriticAgent(Agent):
"""
Agent specialized in safety audit and efficiency review.
"""
def __init__(self, agent_id: str, config: Dict[str, Any] = None):
super().__init__(agent_id, "Critic", config)

def run(self, plan: Any, context: Dict[str, Any] = None) -> Dict[str, Any]:
self.log_decision("Audit Plan", "Reviewing proposed workflow for safety breaches.")
# Logic to check for blocked agents or dangerous commands
return {"approved": True, "score": 0.95}

class ObserverAgent(Agent):
"""
Agent specialized in real-time execution monitoring and anomaly detection.
"""
def __init__(self, agent_id: str, config: Dict[str, Any] = None):
super().__init__(agent_id, "Observer", config)

def run(self, job_telemetry: Any, context: Dict[str, Any] = None) -> Dict[str, Any]:
runtime = job_telemetry.get("runtime", 0)
if runtime > 600:
self.log_decision("Alert Anomaly", f"Job runtime ({runtime}s) exceeds threshold.")
return {"anomaly": True, "action": "Kill"}
return {"anomaly": False}
54 changes: 54 additions & 0 deletions infra/ansible/gpu-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
- name: Bootstrap KhulnaSoft AI GPU Node
hosts: gpu_nodes
become: yes
tasks:
- name: Update apt cache
apt:
update_cache: yes

- name: Install baseline dependencies
apt:
name:
- curl
- ca-certificates
- gnupg
- lsb-release
state: present

- name: Install Docker
apt:
name: docker.io
state: present

- name: Install NVIDIA drivers
apt:
name: nvidia-driver-535
state: present

- name: Install NVIDIA Container Toolkit
shell: |
curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | apt-key add -
curl -s -L https://nvidia.github.io/libnvidia-container/$(. /etc/os-release;echo $ID$VERSION_ID)/libnvidia-container.list | tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update && apt-get install -y nvidia-container-toolkit
args:
creates: /usr/bin/nvidia-container-toolkit

- name: Configure Docker to use NVIDIA runtime
copy:
content: |
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
dest: /etc/docker/daemon.json

- name: Restart Docker
service:
name: docker
state: restarted
Loading