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
58 changes: 58 additions & 0 deletions ComputeTower/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# ComputeTower Configuration
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 22, 2025

Choose a reason for hiding this comment

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

P0: Critical Security Issue: This .env.example file contains what appear to be real credentials. Example files are committed to version control and should only contain placeholder values like your-email@example.com and your-password-here. If these are real credentials, they should be immediately rotated and replaced with placeholders.

Prompt for AI agents
Check if this issue is valid β€” if so, understand the root cause and fix it. At ComputeTower/.env.example, line 31:

<comment>**Critical Security Issue**: This `.env.example` file contains what appear to be real credentials. Example files are committed to version control and should only contain placeholder values like `your-email@example.com` and `your-password-here`. If these are real credentials, they should be immediately rotated and replaced with placeholders.</comment>

<file context>
@@ -0,0 +1,58 @@
+
+# K2Think
+K2THINK_URL=https://www.k2think.ai/
+K2THINK_EMAIL=developer@pixelium.uk
+K2THINK_PASSWORD=developer123?
+
</file context>
Fix with Cubic


# Z.AI Visual Agent (GLM-4.6V) - REQUIRED for page analysis
ANTHROPIC_MODEL=glm-4.6v
ANTHROPIC_API_KEY=your-z-ai-api-key
ANTHROPIC_AUTH_TOKEN=your-z-ai-api-key
ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic

# Database
DATABASE_URL=postgresql://localhost:5432/computetower

# Redis (for BullMQ queueing)
REDIS_URL=redis://localhost:6379

# OWL Browser SDK (optional - for AI-native automation)
OWL_SERVER_URL=http://localhost:8080
OWL_TOKEN=your-owl-server-token

# HyperBrowser (optional - for cloud scaling)
HYPERBROWSER_API_KEY=your-hyperbrowser-api-key

# Server Configuration
PORT=8000
NODE_ENV=production

# Service Credentials (for testing)
# Format: SERVICE_NAME_URL, SERVICE_NAME_EMAIL, SERVICE_NAME_PASSWORD

# K2Think
K2THINK_URL=https://www.k2think.ai/
K2THINK_EMAIL=developer@pixelium.uk
K2THINK_PASSWORD=developer123?

# DeepSeek
DEEPSEEK_URL=https://chat.deepseek.com/
DEEPSEEK_EMAIL=zeeeepa+1@gmail.com
DEEPSEEK_PASSWORD=developer123??

# Grok
GROK_URL=https://grok.com/
GROK_EMAIL=developer@pixelium.uk
GROK_PASSWORD=developer123??

# Qwen
QWEN_URL=https://chat.qwen.ai/
QWEN_EMAIL=developer@pixelium.uk
QWEN_PASSWORD=developer1?

# Z.AI
ZAI_URL=https://chat.z.ai/
ZAI_EMAIL=developer@pixelium.uk
ZAI_PASSWORD=developer123?

# Mistral
MISTRAL_URL=https://chat.mistral.ai
MISTRAL_EMAIL=developer@pixelium.uk
MISTRAL_PASSWORD=mistraldeveloper123?

294 changes: 294 additions & 0 deletions ComputeTower/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
# πŸ—οΈ ComputeTower

**Universal Dynamic Webchat to OpenAI API Converter**

Transform ANY webchat interface into an OpenAI-compatible API endpoint - automatically, intelligently, dynamically.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
[![Status](https://img.shields.io/badge/status-production--ready-success)](https://github.com)

---

## 🎯 What is ComputeTower?

ComputeTower is an **AI-powered automation system** that converts any web-based chat interface into a standard OpenAI API endpoint. No hardcoded selectors, no manual configuration - just provide a URL and credentials, and ComputeTower handles everything:

### The 7-Step Magic ✨

1. **πŸ” Identify Login URL** - AI visual agent analyzes the page
2. **πŸšͺ Navigate to Login** - Handles landing pages, redirects, multi-step flows
3. **πŸ” Login & Authenticate** - Solves CAPTCHAs, humanizes interactions
4. **πŸ”Ž Discover Flows** - Monitors network, finds API endpoints
5. **βœ… Test All Flows** - Validates each discovered endpoint
6. **πŸ’Ύ Save Flows** - Persists to PostgreSQL for reuse
7. **πŸš€ Start Server** - Exposes as `/v1/chat/completions`

### Why ComputeTower?

- **🧠 AI-Native**: Uses Z.AI glm-4.6v vision model for intelligent page analysis
- **πŸ”„ Dynamic**: No hardcoded selectors - adapts to any UI
- **πŸ›‘οΈ Stealth**: Built-in anti-detection, humanized interactions
- **πŸ“Š Scalable**: BullMQ queueing, horizontal scaling ready
- **πŸ”Œ Compatible**: Drop-in replacement for OpenAI API
- **πŸ§ͺ Validated**: Tested with 6 real services (K2Think, DeepSeek, Grok, Qwen, Z.AI, Mistral)

---

## πŸš€ Quick Start

### Prerequisites

- Node.js 18+ or Bun 1.0+
- PostgreSQL 14+
- Redis 7+
- Z.AI API key (for visual agent)

### Installation

```bash
# Clone repository
git clone https://github.com/your-org/computetower.git
cd ComputeTower

# Install dependencies
npm install

# Setup environment
cp .env.example .env
# Edit .env with your Z.AI API key and credentials

# Initialize database
createdb computetower
psql computetower < schema.sql

# Start Redis (in another terminal)
redis-server

# Run ComputeTower
npm run dev
```

Server will start on `http://localhost:8000` πŸŽ‰

---

## πŸ’» Usage

### Example 1: Chat with DeepSeek via OpenAI API

```bash
curl http://localhost:8000/v1/chat/completions \\
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 22, 2025

Choose a reason for hiding this comment

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

P2: Curl example uses double backslashes \\ for line continuation which won't work when copy-pasted. In fenced code blocks, use single \ for bash line continuation.

Prompt for AI agents
Check if this issue is valid β€” if so, understand the root cause and fix it. At ComputeTower/README.md, line 81:

<comment>Curl example uses double backslashes `\\` for line continuation which won&#39;t work when copy-pasted. In fenced code blocks, use single `\` for bash line continuation.</comment>

<file context>
@@ -0,0 +1,294 @@
+### Example 1: Chat with DeepSeek via OpenAI API
+
+```bash
+curl http://localhost:8000/v1/chat/completions \\
+  -H &quot;Content-Type: application/json&quot; \\
+  -d &#39;{
</file context>
Fix with Cubic

-H "Content-Type: application/json" \\
-d '{
"model": "computetower-deepseek",
"messages": [
{
"role": "system",
"content": "URL: https://chat.deepseek.com/ | Email: your-email@example.com | Password: your-password"
},
{
"role": "user",
"content": "Explain quantum computing"
}
]
}'
```

### Example 2: Use with OpenAI Python SDK

```python
from openai import OpenAI

client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="not-needed"
)

response = client.chat.completions.create(
model="computetower-k2think",
messages=[
{
"role": "system",
"content": "URL: https://www.k2think.ai/ | Email: your-email | Password: your-password"
},
{
"role": "user",
"content": "Write a Python function to sort a list"
}
]
)

print(response.choices[0].message.content)
```

### Example 3: Streaming Responses

```python
for chunk in client.chat.completions.create(
model="computetower-grok",
messages=[...],
stream=True
):
print(chunk.choices[0].delta.content, end="")
```

---

## πŸ—οΈ Architecture

### Core Components

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ OpenAI API Server (Fastify) β”‚
β”‚ http://localhost:8000 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ DynamicLoginResolver β”‚
β”‚ β€’ Visual Agent (Z.AI glm-4.6v) β”‚
β”‚ β€’ Playwright Toolkit (stealth) β”‚
β”‚ β€’ Multi-engine fallback β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ FlowDiscoveryEngine β”‚
β”‚ β€’ Network monitoring β”‚
β”‚ β€’ Endpoint detection β”‚
β”‚ β€’ SSE/JSON parsing β”‚
β”‚ β€’ Flow validation β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Session Management β”‚
β”‚ β€’ PostgreSQL storage β”‚
β”‚ β€’ Cookie/token persistence β”‚
β”‚ β€’ Session reuse & expiration β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Technology Stack

- **πŸ¦‰ OWL Browser SDK**: AI-native browser automation
- **🎭 Playwright Toolkit**: Stealth, humanization, CAPTCHA handling
- **πŸ€– Z.AI glm-4.6v**: Visual page analysis
- **⚑ Fastify**: High-performance HTTP server
- **πŸ‚ BullMQ**: Redis-based job queueing
- **🐘 PostgreSQL**: Session & flow persistence
- **πŸ”΄ Redis**: Cache & queue backend

---

## πŸ“‹ Features

### βœ… Implemented

- [x] Dynamic login resolution with visual AI
- [x] Multi-pattern auth handling (direct, landing page, open interface)
- [x] Automatic flow discovery via network monitoring
- [x] SSE stream parsing (Server-Sent Events)
- [x] OpenAI API compatibility (`/v1/chat/completions`)
- [x] Session persistence & reuse
- [x] PostgreSQL storage
- [x] BullMQ queueing
- [x] Multi-engine fallback (OWL, Playwright, Ghost, HyperAgent, ARN)

### 🚧 Roadmap

- [ ] Automated CAPTCHA solving (2Captcha/AntiCaptcha)
- [ ] Proxy rotation
- [ ] Account rotation
- [ ] Rate limiting per service
- [ ] Admin dashboard
- [ ] Kubernetes deployment
- [ ] Multi-modal support (images, files)
- [ ] Function calling support
- [ ] Embeddings API

---

## πŸ§ͺ Validation

ComputeTower has been validated with **6 real services** using actual credentials:

| Service | URL | Status | Pattern |
|---------|-----|--------|---------|
| **K2Think.AI** | https://www.k2think.ai/ | βœ… Validated | Direct login |
| **DeepSeek** | https://chat.deepseek.com/ | βœ… Validated | Direct login |
| **Grok** | https://grok.com/ | βœ… Validated | Direct login |
| **Qwen Chat** | https://chat.qwen.ai/ | ⚠️ Open access | No auth required |
| **Z.AI** | https://chat.z.ai/ | ⚠️ Landing nav | Multi-step |
| **Mistral** | https://chat.mistral.ai | ⚠️ Landing nav | Multi-step |

Run validation yourself:
```bash
npm run validate
```

---

## πŸ“š Documentation

- **[Requirements.md](./Requirements.md)** - Complete technical specification
- **[API Reference](./docs/api.md)** - OpenAI API compatibility guide
- **[Architecture](./docs/architecture.md)** - System design & components
- **[Contributing](./CONTRIBUTING.md)** - Development guidelines

---

## 🀝 Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.

### Development Setup

```bash
# Install dependencies
npm install

# Run tests
npm test

# Watch mode
npm run dev

# Build for production
npm run build
```

---

## πŸ“„ License

MIT License - see [LICENSE](./LICENSE) for details.

---

## πŸ™ Acknowledgments

Built with these amazing open-source projects:

- [@olib-ai/owl-browser-sdk](https://www.npmjs.com/package/@olib-ai/owl-browser-sdk) - AI-native browser automation
- [@skrillex1224/playwright-toolkit](https://www.npmjs.com/package/@skrillex1224/playwright-toolkit) - Stealth automation toolkit
- [@hyperbrowser/agent](https://www.npmjs.com/package/@hyperbrowser/agent) - LLM-driven browser agent
- [Anthropic SDK](https://www.npmjs.com/package/@anthropic-ai/sdk) - Claude API client (used for Z.AI)
- [Playwright](https://playwright.dev/) - Browser automation
- [Fastify](https://www.fastify.io/) - Fast web framework
- [BullMQ](https://docs.bullmq.io/) - Redis-based queueing

---

## πŸ’¬ Support

- **Issues**: [GitHub Issues](https://github.com/your-org/computetower/issues)
- **Discussions**: [GitHub Discussions](https://github.com/your-org/computetower/discussions)
- **Email**: support@computetower.dev

---

**Made with ❀️ by the ComputeTower Team**

Loading