Skip to content

GetwaveS201/manus-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

62 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI Automation Assistant

A powerful dual-AI system with an intelligent routing engine and beautiful dark-themed interface

Live Demo Node.js License

A sophisticated AI assistant that intelligently routes requests between Google Gemini (fast Q&A) and OpenClaw (your own self-hosted AI automation agent) to provide the best possible response for every query.

✨ Features

🎯 Intelligent AI Routing

  • Smart Detection: Automatically routes to the best AI for each task
  • πŸ”΅ Gemini Integration: Handles Q&A, explanations, calculations, and general knowledge
  • 🟠 OpenClaw Integration: Your self-hosted AI agent for automation, emails, and complex workflows
  • Sidebar Mode Tabs: Manually switch between Gemini and OpenClaw with one click
  • Confidence Scoring: Score-based routing system (95%+ accuracy)
  • Graceful Fallbacks: If OpenClaw is unreachable, automatically falls back to Gemini

πŸ’¬ Modern Chat Interface

  • 🎨 Beautiful Dark Theme: Professional UI with purple accents
  • πŸ’Ύ Chat History: Persistent conversations with localStorage
  • πŸ“ Markdown Support: Full markdown rendering with syntax highlighting
  • πŸ“‹ One-Click Copy: Copy messages and code blocks instantly
  • πŸ—‘οΈ Chat Management: Delete conversations with confirmation
  • ⚑ Real-time Updates: Streaming responses from both AIs

β™Ώ Accessibility First

  • WCAG 2.1 AA Compliant: Semantic HTML5 and ARIA labels
  • ⌨️ Full Keyboard Navigation: Tab through all elements
  • πŸ“± Mobile Responsive: Optimized for all screen sizes
  • πŸ”Š Screen Reader Support: Comprehensive accessibility features
  • πŸ‘οΈ High Contrast: Easy-to-read color combinations

⌨️ Keyboard Shortcuts

  • Ctrl/Cmd + K - Start new chat
  • Escape - Clear input field
  • Ctrl/Cmd + / - Focus message input
  • Enter - Send message

🎨 UI/UX Features

  • Sidebar with searchable chat history
  • Message timestamps
  • AI badge indicators (Gemini πŸ”΅ / OpenClaw 🟠)
  • AI mode tabs in sidebar (switch between Gemini and OpenClaw)
  • OpenClaw connection status indicator (green/red dot)
  • OpenClaw settings panel (enter your VPS URL and token)
  • Loading states with animations
  • Example queries for quick start
  • Auto-scroll to latest messages
  • Code syntax highlighting (Atom One Dark theme)

Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/GetwaveS201/manus-proxy.git
cd manus-proxy

# Install dependencies
npm install

# Copy environment template
cp .env.example .env

# Edit .env and add your API keys
nano .env  # or use your preferred editor

Environment Variables

Copy .env.example to .env and fill in:

GEMINI_API_KEY=your_gemini_key
OPENCLAW_URL=http://your-vps-ip:18789    # Your OpenClaw server URL
OPENCLAW_TOKEN=your_openclaw_token       # Optional bearer token
PORT=3000

Note: OpenClaw URL and token can also be set directly in the app's sidebar βš™ Settings panel (saved in your browser).

Running Locally

npm start

Server runs at http://localhost:3000

πŸ“š API Documentation

POST /chat

Send a message to the AI assistant (public endpoint, no authentication required).

Request:

curl -X POST https://manus-proxy-1.onrender.com/chat \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "What is machine learning?",
    "ai": "gemini",
    "openclawUrl": "http://your-vps:18789",
    "openclawToken": "optional-token"
  }'

Success Response:

{
  "response": "Machine learning is a subset of artificial intelligence...",
  "ai": "gemini",
  "routing": {
    "ai": "gemini",
    "confidence": 95,
    "scores": {
      "gemini": 95,
      "openclaw": 5
    }
  }
}

POST /ping-openclaw

Check if your OpenClaw instance is reachable.

curl -X POST https://manus-proxy-1.onrender.com/ping-openclaw \
  -H "Content-Type: application/json" \
  -d '{"openclawUrl": "http://your-vps:18789", "openclawToken": ""}'

Response: {"reachable": true} or {"reachable": false, "reason": "Connection refused"}

GET /

Serves the frontend chat interface.

GET /health

Health check endpoint (requires API key header).

Deployment

Deploy to Render

  1. Push to GitHub
  2. Connect repository in Render Dashboard
  3. Add environment variables in Render settings
  4. Deploy!

Auto-deploy: Enabled on main branch

Live URL: https://manus-proxy-1.onrender.com

Architecture

User Request
    ↓
Smart Router (analyzes prompt)
    ↓
    β”œβ†’ Gemini API (fast, free)
    β”‚   - Q&A questions
    β”‚   - Explanations
    β”‚   - Simple greetings
    β”‚
    β””β†’ Manus API (powerful, paid)
        - Data processing
        - Research tasks
        - Content creation
        - Calculations

Routing Logic

Routes to Gemini:

  • Q&A: "What is...", "How does...", "Explain..."
  • Greetings: "hi", "hello", "thanks"
  • Short messages (≀3 words)

Routes to Manus:

  • Execution: "Calculate", "Find", "Create", "Build"
  • Research: "Compare", "Analyze", "Summarize"
  • Data tasks: CSV processing, calculations
  • Default: Any unclear requests

Security

Authentication

All API endpoints require X-API-Key header (except in development).

X-API-Key: your_app_api_key

Rate Limiting

  • 100 requests per 15 minutes per IP
  • Prevents credit drain attacks

Environment Variables

NEVER commit:

  • .env files
  • API keys
  • Secrets

Always use environment variables for sensitive data.

Error Handling

The system provides user-friendly error messages:

Gemini Quota Exceeded:

{
  "error": "⚠️ Gemini API quota exceeded...",
  "technical_error": "GEMINI_QUOTA_EXCEEDED"
}

Manus Credits Exhausted:

{
  "error": "⚠️ Manus AI credits exhausted...",
  "technical_error": "MANUS_CREDITS_EXCEEDED"
}

Development

Project Structure

manus-proxy/
β”œβ”€β”€ server.js              # Main application
β”œβ”€β”€ package.json           # Dependencies
β”œβ”€β”€ .env.example          # Environment template
β”œβ”€β”€ .gitignore            # Git ignore rules
β”œβ”€β”€ README.md             # This file
└── docs/
    β”œβ”€β”€ DEPLOYMENT_SUCCESS.md
    β”œβ”€β”€ PERFORMANCE_REPORT_RESPONSE.md
    └── COMPLETE_SESSION_SUMMARY.md

Adding Features

  1. Create feature branch
  2. Make changes
  3. Test locally
  4. Commit and push
  5. Auto-deploys to Render

Running Tests

npm test  # Coming soon

Cost Optimization

Current Performance:

  • ~90% queries use Gemini (free)
  • ~10% queries use OpenClaw (your own self-hosted VPS β€” no per-query cost!)
  • Massive savings vs paid AI APIs β€” OpenClaw runs on your own infrastructure

OpenClaw Cost:

  • One-time VPS cost (e.g. $5-20/month for a server)
  • No per-query API fees
  • Full control over your data and privacy

Gemini Pricing:

  • Free tier: sufficient for most Q&A usage
  • Paid tier: ~$0.075 per 1M tokens if you exceed the free tier

Troubleshooting

"Quota exceeded" errors

Gemini: Quotas reset daily at midnight PT. Upgrade to paid tier for higher limits.

Manus: Add credits at https://manus.ai/pricing

Server not responding

  1. Check Render logs in dashboard
  2. Verify environment variables are set
  3. Check API key validity

Routing to wrong AI

Adjust triggers in server.js chooseAI() function.

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

License

MIT

Support

Acknowledgments

Built with:


⚠️ Security Reminder: Never commit API keys. Always use environment variables.

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors