Skip to main content

Official CLI for deploying and managing services on OneXEOS Platform (Windows, macOS, Linux)

Project description

OneXEOS Platform CLI (onex)

Official CLI for deploying and managing services on the OneXEOS Platform

PyPI version Python 3.12+ License: MIT


๐Ÿ“‹ Table of Contents

๐Ÿ“– Detailed Guides:


Overview

The onex CLI provides a unified interface for:

  • ๐Ÿš€ One-command setup: VPN + login + .env generation (onex init)
  • ๐Ÿ” VPN management: Cross-platform WireGuard VPN setup (Mac, Linux, Windows)
  • ๐Ÿ“ฆ Service deployment: Deploy to local/dev/staging/prod environments
  • ๐Ÿ› Visual debugging: VS Code debugging with breakpoints (onex debug)
  • ๐Ÿ” Request tracing: End-to-end request debugging with trace_id
  • ๐Ÿ“Š Monitoring: View logs, status, and health checks
  • โšก Hot reload: Auto-reload on code changes during development
  • ๐Ÿ”ง Resource management: Provision MongoDB, Redis, Elasticsearch resources

Installation

For Service Developers (PyPI)

# Install from PyPI (recommended)
pip install onex-cli

# Or add to requirements.txt
onex-cli>=1.0.0

# Verify installation
onex --version

That's it! No platform repository access needed.

For Platform Developers

# Install from source (development)
cd onexeos-platform-NEW/onex-cli
pip install -e .

Quick Start

First-Time Setup (3 Steps)

# Step 1: Install CLI
pip install onex-cli

# Step 2: Initialize environment (VPN + login + .env)
onex init

# Step 3: Create your first service (NEW in v1.4.0!)
onex create

What onex init does:

  1. โœ… Sets up VPN from config file (if you have one)
  2. โœ… Auto-extracts credentials from VPN config (NEW in v1.1.0!)
  3. โœ… Logs into platform (no manual password entry!)
  4. โœ… Downloads credentials (MongoDB, Redis, JWT secrets)
  5. โœ… Auto-generates .env file
  6. โœ… Verifies connectivity
  7. โœ… Configures MCP for Claude Code (optional - NEW in v1.3.3!)

What onex create does (NEW in v1.4.0!):

  1. โœ… Interactive wizard to select template (REST API, Event-Driven, CRUD, Minimal)
  2. โœ… Generates complete service structure from template
  3. โœ… Validates service.yml automatically
  4. โœ… Shows next steps to deploy

You're ready to develop! ๐ŸŽ‰

NEW in v1.1.0: No more manual password entry! If your VPN config contains embedded credentials, onex init will automatically extract and use them for login.

NEW in v1.3.3: MCP (Model Context Protocol) integration allows Claude Code to debug your platform with natural language: "Is my platform healthy?", "Debug trace_id: abc123", "Show email-service logs"


Platform-Specific Setup Guides

Choose your operating system for detailed step-by-step instructions:

๐Ÿ“– Complete Setup Guide โ† Comprehensive guide for all platforms

Quick links by platform:

Key differences:

  • macOS/Linux: VPN managed via command-line (wg-quick, systemctl)
  • Windows: VPN managed via WireGuard GUI application

All other commands are identical across platforms.

Deploy Your First Service

cd services/demo
onex deploy

Debug Locally with VS Code

# Start service with debugger
onex debug --service demo

# Output:
# ๐Ÿ› VS Code debugging enabled on port 5678
#    Press F5 in VS Code to attach debugger
#
# ๐Ÿ“ฆ Loading service: demo
# โœ… Loaded demo: 7 routes
# ๐Ÿ“ก Access at: http://localhost:8001/docs

# Press F5 in VS Code โ†’ Set breakpoints โ†’ Make request

Commands

Core Commands

onex init                          # Setup VPN + login + .env (one command!)
onex create                        # Create new service from template (NEW v1.4.0!)
onex deploy                        # Deploy service to platform
onex debug --service <name>        # Debug service locally (VS Code ready)
onex trace <trace_id>              # Trace request through platform
onex logs <service> --follow       # Stream service logs
onex status <service>              # Check service health

All Commands

Command Description
Setup & Auth
onex init Initialize environment (VPN + login + .env)
onex login Login to platform and download credentials
onex logout Logout and remove stored credentials
Environment Switching (NEW v1.2.0)
onex switch <env> Switch environment (handles VPN + config)
VPN Management
onex vpn setup <file> Setup VPN from WireGuard config file
onex vpn status Show VPN connection status
onex vpn list List all configured VPNs
Environment Info
onex env Show active environment
onex env list List all configured environments
onex env show <env> Show environment details
onex env sync Regenerate .env file
Service Scaffolding (NEW v1.4.0)
onex create Create new service from template (interactive)
onex create -n <name> -t <template> Create service with specific template
Development
onex debug --service <name> Debug service locally (VS Code + hot reload)
onex dev Run service locally with hot-reload (deprecated, use debug)
Deployment
onex deploy Deploy service to active environment
onex validate Validate service.yml schema
onex provision Manually provision MongoDB resources
Monitoring
onex logs <service> View service logs
onex status <service> Check service status
onex trace <trace_id> Debug request flow end-to-end
Invocation
onex invoke <service>:<fn> Invoke function directly
Elasticsearch
onex es status [service] View es_sync trigger status and health
onex es mapping [service] Check ES mappings vs model definitions
onex es reindex <service> Reindex ES from MongoDB
onex es reindex <service> --recreate Recreate index with correct mappings + reindex
onex es test <service> Test es_sync end-to-end
Platform
onex platform check Check platform health

VPN Setup

NEW in v1.0.0: Built-in VPN management for dev/staging/prod access.

Automatic Setup (Recommended)

# One command does everything
onex init

# Prompts:
# - Do you have a VPN config file? [Y/n]: y
# - VPN config file path: ~/Downloads/alice-dev.conf
#
# Then automatically:
# โœ… Installs WireGuard (if needed)
# โœ… Imports config
# โœ… Connects to VPN
# โœ… Verifies connectivity
# โœ… Logs into platform
# โœ… Generates .env file

Manual VPN Management

# Setup VPN from config file
onex vpn setup ~/Downloads/alice-dev.conf

# Switch to dev environment (connects VPN + sets active)
onex switch dev

# Check VPN status
onex vpn status

# Switch to local (disconnects VPN)
onex switch local

Platform-Specific Instructions

macOS:

  • Uses Homebrew + wg-quick
  • Requires sudo for VPN operations

Linux:

  • Auto-installs WireGuard (Ubuntu/Debian/CentOS/RHEL)
  • Uses systemd for VPN management

Windows:

See service repository's docs/platform/VPN_SETUP_DEVELOPER.md for detailed guide.


Environment Management

Active Environment Concept

The active environment determines where commands deploy to:

# Show active environment
onex env
# โœ… Active environment: local

# Switch to dev (connects VPN + sets active)
onex switch dev
# โœ… Switched to: dev

# Now all commands use dev
onex deploy  # Deploys to dev
onex logs    # Shows dev logs

Available Environments

Environment Platform URL VPN Required Access
local http://localhost:8000 No Full (contact platform team for setup)
dev http://10.0.0.1:8000 Yes Deploy + Read
staging http://10.0.1.1:8000 Yes Read only
prod http://10.0.2.1:8000 Yes Read only

Note: IP addresses are examples and can be customized for your deployment.

Login to Environment

# Login to local (no VPN needed)
onex login --env local

# Switch to dev (connects VPN + logs in if credentials embedded)
onex switch dev
# โœ… Connects to VPN
# โœ… Sets dev as active environment

# Or use onex init for complete setup
onex init --config-file ~/Downloads/alice-dev.conf

Platform Architecture

Access Methods

The OneXEOS platform provides three access methods:

1. Public Access (via Domain + SSL)

  • Dev: https://dev.onexeos.com โ†’ Traefik โ†’ Gateway โ†’ Services
  • Staging: https://staging.onexeos.com โ†’ Traefik โ†’ Gateway โ†’ Services
  • Production: https://onexeos.com โ†’ Traefik โ†’ Multi-Replica Gateway โ†’ Services

2. VPN Access (Direct to Gateway)

  • Dev: http://10.0.0.1:8000 (via VPN)
  • Staging: http://10.0.1.1:8000 (via VPN)
  • Production: http://10.0.2.1:8000 (via VPN)

3. Initial Login (Public Auth Service)

  • All Environments: http://103.17.141.76:8100 (no VPN required)
  • Used during onex init for first-time authentication

Developer Workflow

# Step 1: Receive VPN config from DevOps
# Contains: Embedded credentials + Public auth URL + VPN config

# Step 2: Initialize environment
onex init --config-file alice-dev.conf
# โœ… Parses VPN config
# โœ… Authenticates via public auth (103.17.141.76:8100) - no VPN needed!
# โœ… Prompts to connect VPN
# โœ… Downloads credentials from gateway (10.0.0.1:8000) - requires VPN
# โœ… Saves environment config

# Step 3: Deploy your service
onex deploy
# Uses VPN gateway (10.0.0.1:8000) for deployment

# Step 4: Access via domain (public) OR VPN (direct)
# Public:  https://dev.onexeos.com/api/your-service/...
# Direct:  http://10.0.0.1:8000/api/your-service/...

URL Reference

Environment Public (SSL) VPN Gateway Auth (Public)
Dev https://dev.onexeos.com http://10.0.0.1:8000 http://103.17.141.76:8100
Staging https://staging.onexeos.com http://10.0.1.1:8000 http://103.17.141.76:8100
Production https://onexeos.com http://10.0.2.1:8000 http://103.17.141.76:8100

Configuration

Credential Storage

Credentials stored securely in ~/.onex/:

~/.onex/
โ”œโ”€โ”€ environments.json    # Environment credentials (MongoDB, Redis, JWT, etc.)
โ””โ”€โ”€ active-env          # Currently active environment

Security:

  • Never commit .env files
  • Never share ~/.onex/ directory
  • Files automatically created with restrictive permissions (600)

Auto-Generated .env File

When you run onex login or onex init, a .env file is automatically created in your service repository:

# MongoDB
MONGODB_URI=mongodb://user:pass@host:27017/db?authSource=admin
MONGODB_DATABASE=onexeos

# Redis
REDIS_URI=redis://:password@host:6379/0

# JWT
JWT_SECRET=<auto-downloaded-secret>
JWT_ALGORITHM=HS256

# Platform
PLATFORM_URL=http://10.0.0.1:8000

# Development
DEBUG=true
ENV=dev

Development

Debug Workflow

# Navigate to service directory
cd services/product

# Start debugging (VS Code ready!)
onex debug --service product

# Output:
# ๐Ÿ› VS Code debugging enabled on port 5678
#    Press F5 in VS Code to attach debugger
#
# ๐Ÿ“ฆ Loading service: product
#    โœ… POST   /products                โ†’ src.handlers.create_product
#    โœ… GET    /products/{id}           โ†’ src.handlers.get_product
#
# โœ… Loaded product: 5 routes
# ๐Ÿ“ก Access at: http://localhost:8001/docs

# In VS Code:
# 1. Set breakpoints (click left margin)
# 2. Press F5 โ†’ Select "Attach to Runtime"
# 3. Make request: curl http://localhost:8001/products/123
# 4. VS Code pauses at your breakpoints!

Features:

  • โœ… Hot reload on code changes
  • โœ… VS Code breakpoint debugging
  • โœ… Interactive API docs at /docs
  • โœ… Auto-registers routes with platform gateway

Request Tracing

Every request gets a unique trace_id:

# 1. Make request
curl -D /tmp/headers.txt http://localhost:8001/products/123

# 2. Extract trace_id from response header
grep x-trace-id /tmp/headers.txt
# x-trace-id: 550e8400-e29b-41d4-a716-446655440000

# 3. View complete request timeline
onex trace 550e8400-e29b-41d4-a716-446655440000

# Output shows Gateway โ†’ Runtime โ†’ Service flow:
# ๐Ÿ” Querying trace: 550e8400-e29b-41d4-a716-446655440000
#
# โœ… Found 12 log entries
# โฑ๏ธ  Total Duration: 456ms
#
# ๐Ÿ“ฆ GATEWAY
#   14:23:45.123 INFO    POST /products/123
#   14:23:45.145 INFO    Forwarding to product service
#
# ๐Ÿ“ฆ RUNTIME
#   14:23:45.156 INFO    Executing product:get_product
#
# ๐Ÿ“ฆ SERVICE
#   14:23:45.267 INFO    Product found: 123
#   14:23:45.456 INFO    POST /products/123 200 456ms

For Platform Developers

This CLI is maintained by the platform team.

Development Setup

cd onexeos-platform-NEW/onex-cli
pip install -e .

# Make changes to CLI
vim onex/commands/mycommand.py

# Test immediately (editable mode)
onex mycommand

Publishing to PyPI

See PUBLISHING.md for complete guide.

Quick reference:

# 1. Update version and changelog
vim setup.py CHANGELOG.md

# 2. Run verification script
./verify-package.sh

# 3. Build and test on TestPyPI
rm -rf dist/
python -m build
twine upload --repository testpypi dist/*

# 4. Test installation
pip install --index-url https://test.pypi.org/simple/ onex-cli

# 5. Publish to production PyPI
twine upload dist/*

# 6. Tag release
git tag -a v1.0.1 -m "Release 1.0.1"
git push origin v1.0.1

Adding New Commands

  1. Create command file in onex/commands/:
# onex/commands/mycommand.py
import click
from onex.utils import print_success, print_error

@click.command()
@click.option('--env', default='local', help='Environment')
def mycommand(env):
    """Description of new command"""
    print_success("Command completed!")
  1. Register in onex/__main__.py:
from onex.commands import mycommand
cli.add_command(mycommand.mycommand)
  1. Test:
onex mycommand --help

Directory Structure

onex-cli/
โ”œโ”€โ”€ setup.py                 # PyPI package configuration
โ”œโ”€โ”€ MANIFEST.in             # Package files to include
โ”œโ”€โ”€ LICENSE                 # MIT License
โ”œโ”€โ”€ CHANGELOG.md            # Version history
โ”œโ”€โ”€ PUBLISHING.md           # Publishing guide
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ onex/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ __main__.py         # CLI entry point
    โ”œโ”€โ”€ config.py           # Configuration management
    โ”œโ”€โ”€ utils.py            # Shared utilities
    โ”œโ”€โ”€ commands/           # Command implementations
    โ”‚   โ”œโ”€โ”€ debug.py       # Debug service locally
    โ”‚   โ”œโ”€โ”€ deploy.py      # Deploy to platform
    โ”‚   โ”œโ”€โ”€ dev.py         # Development mode (deprecated)
    โ”‚   โ”œโ”€โ”€ env.py         # Environment management
    โ”‚   โ”œโ”€โ”€ init.py        # VPN + login + .env setup
    โ”‚   โ”œโ”€โ”€ invoke.py      # Function invocation
    โ”‚   โ”œโ”€โ”€ login.py       # Platform authentication
    โ”‚   โ”œโ”€โ”€ logout.py      # Logout
    โ”‚   โ”œโ”€โ”€ logs.py        # View service logs
    โ”‚   โ”œโ”€โ”€ platform.py    # Platform management
    โ”‚   โ”œโ”€โ”€ provision.py   # Resource provisioning
    โ”‚   โ”œโ”€โ”€ status.py      # Service health
    โ”‚   โ”œโ”€โ”€ trace.py       # Request tracing
    โ”‚   โ”œโ”€โ”€ validate.py    # Schema validation
    โ”‚   โ””โ”€โ”€ vpn.py         # VPN management (NEW)
    โ”œโ”€โ”€ runtime/
    โ”‚   โ””โ”€โ”€ local_runtime.py  # Local service runtime
    โ”œโ”€โ”€ schema/
    โ”‚   โ””โ”€โ”€ service_descriptor.py  # Service schema
    โ””โ”€โ”€ vpn/               # VPN module (NEW)
        โ”œโ”€โ”€ __init__.py
        โ”œโ”€โ”€ platform_detector.py    # OS/environment detection
        โ”œโ”€โ”€ setup_vpn.py           # VPN orchestration
        โ””โ”€โ”€ wireguard_manager.py   # WireGuard operations

Windows Support

Full Windows compatibility! The OneX CLI works perfectly on Windows 10/11 with PowerShell and Command Prompt.

Quick Start on Windows

# Install CLI
pip install onex-cli

# Verify installation
onex --version

# Setup MCP for Claude Code (optional)
onex mcp setup

Key Differences on Windows

Feature Windows macOS/Linux
CLI Commands โœ… Identical โœ… Identical
MCP Setup โœ… onex mcp setup โœ… onex mcp setup
VPN Setup โš ๏ธ WireGuard GUI โœ… wg-quick CLI
Path Handling โœ… Automatic โœ… Automatic

VPN on Windows: Use the WireGuard GUI application instead of command-line tools. Import your .conf file and activate the tunnel manually.

For complete Windows guide: See WINDOWS_COMPATIBILITY.md


Troubleshooting

Command not found: onex

# Reinstall from PyPI
pip install --upgrade onex-cli

# Verify installation
which onex
onex --version

Platform connection failed

# Check VPN connection
onex vpn status

# Reconnect if needed
onex switch dev

# Verify platform health
onex platform check

VPN setup failed

macOS:

# Install WireGuard via Homebrew
brew install wireguard-tools

# Try setup again
onex vpn setup ~/Downloads/alice-dev.conf

Linux:

# Ubuntu/Debian
sudo apt update
sudo apt install wireguard wireguard-tools

# CentOS/RHEL
sudo yum install epel-release
sudo yum install wireguard-tools

# Try setup again
onex vpn setup ~/Downloads/alice-dev.conf

Windows: Download WireGuard GUI: https://www.wireguard.com/install/

"Module not found" errors

# Reinstall dependencies
pip install --upgrade onex-cli

# Or reinstall everything
pip install -r requirements.txt --upgrade

Deployment failed

# Validate service.yml first
onex validate

# Check platform health
onex platform check

# View detailed logs
onex logs deployment-controller --follow

Version History

See CHANGELOG.md for detailed version history.

Current Version: 1.0.1

  • โœ… VPN module (cross-platform support)
  • โœ… One-command setup (onex init)
  • โœ… VS Code debugging with debugpy
  • โœ… Auto-generated .env files
  • โœ… Published to PyPI
  • โœ… Comprehensive documentation

Support

For Service Developers

  • Installation: pip install onex-cli
  • Documentation: This README + service repo docs
  • Issues: Contact platform team

For Platform Developers

  • Development: Install from source (pip install -e .)
  • Publishing: See PUBLISHING.md
  • Issues: GitHub issues in platform repository

Related Documentation

Service Developers:

Platform Developers:


License

MIT License - See LICENSE file.


Links


Maintained by: OneXEOS Platform Team Used by: Service Developers (no platform repo access needed!) Version: 1.0.1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onex_cli-1.18.0.tar.gz (200.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onex_cli-1.18.0-py3-none-any.whl (208.3 kB view details)

Uploaded Python 3

File details

Details for the file onex_cli-1.18.0.tar.gz.

File metadata

  • Download URL: onex_cli-1.18.0.tar.gz
  • Upload date:
  • Size: 200.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for onex_cli-1.18.0.tar.gz
Algorithm Hash digest
SHA256 853f89eec13c6cefcf6110f7d9434c61dddcad3c1f086bbbbfaaf10ef22d1991
MD5 135bc620668fd3dd6a0623a5d088b4ee
BLAKE2b-256 51ba1807d22c58ca51c5e3ea3d7763f657416da10554cbccae10453868574582

See more details on using hashes here.

File details

Details for the file onex_cli-1.18.0-py3-none-any.whl.

File metadata

  • Download URL: onex_cli-1.18.0-py3-none-any.whl
  • Upload date:
  • Size: 208.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for onex_cli-1.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1219fb44707f5d35aee25df464465fe92d617624d3ceca7486bd62a181b0cb5
MD5 bbc8e49d5b1589c317ca56d913ca809d
BLAKE2b-256 f9e90e3ab34457c37bf9a924096b178d2f9bf5c244866eebac79228dee4ef1e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page