Skip to main content

CLI and API for 10xscale AgentFlow

Project description

AgentFlow CLI

A professional Python API framework for building agent-based applications with FastAPI, state graph orchestration, and comprehensive CLI tools.

๐Ÿ“š Documentation

Quick Start

Installation

pip install 10xscale-agentflow-cli

Initialize a New Project

# Create project structure
agentflow init

# Or with production config
agentflow init --prod

Start Development Server

agentflow api

Generate Docker Files

agentflow build --docker-compose

Key Features

  • โœ… CLI Tools - Professional command-line interface for scaffolding and deployment
  • โœ… State Graph Orchestration - Build complex agent workflows with LangGraph
  • โœ… FastAPI Backend - High-performance async web framework
  • โœ… Authentication - Built-in JWT auth and custom authentication support
  • โœ… ID Generation - Distributed Snowflake ID generation
  • โœ… Thread Management - Intelligent thread naming and conversation management
  • โœ… Docker Ready - Generate production-ready Docker files
  • โœ… Dependency Injection - InjectQ for clean dependency management
  • โœ… Development Tools - Hot-reload, pre-commit hooks, testing

CLI Commands

For detailed command documentation, see the CLI Guide.

agentflow init

Initialize a new project with configuration and sample graph.

# Basic initialization
agentflow init

# With production config (pyproject.toml, pre-commit hooks)
agentflow init --prod

# Custom directory
agentflow init --path ./my-project

# Force overwrite existing files
agentflow init --force

agentflow api

Start the development API server.

# Start with defaults (localhost:8000)
agentflow api

# Custom host and port
agentflow api --host 127.0.0.1 --port 9000

# Custom config file
agentflow api --config production.json

# Disable auto-reload
agentflow api --no-reload

# Verbose logging
agentflow api --verbose

agentflow build

Generate production Docker files.

# Generate Dockerfile
agentflow build

# Generate Dockerfile and docker-compose.yml
agentflow build --docker-compose

# Custom Python version and port
agentflow build --python-version 3.12 --port 9000

# Force overwrite
agentflow build --force

agentflow version

Display version information.

agentflow version

Configuration

The configuration file (agentflow.json) defines your agent, authentication, and infrastructure settings:

{
  "agent": "graph.react:app",
  "env": ".env",
  "auth": null,
  "checkpointer": null,
  "injectq": null,
  "store": null,
  "redis": null,
  "thread_name_generator": null
}

Configuration Options

Field Type Description
agent string Path to your compiled agent graph (required)
env string Path to environment variables file
auth null|"jwt"|object Authentication configuration
checkpointer string|null Path to custom checkpointer
injectq string|null Path to InjectQ container
store string|null Path to data store
redis string|null Redis connection URL
thread_name_generator string|null Path to custom thread name generator

See the Configuration Guide for complete details.

Authentication

AgentFlow supports multiple authentication strategies. See the Authentication Guide for complete details.

No Authentication

{
  "auth": null
}

JWT Authentication

agentflow.json:

{
  "auth": "jwt"
}

.env:

JWT_SECRET_KEY=your-super-secret-key
JWT_ALGORITHM=HS256

Custom Authentication

agentflow.json:

{
  "auth": {
    "method": "custom",
    "path": "auth.custom:MyAuthBackend"
  }
}

auth/custom.py:

from agentflow_cli import BaseAuth
from fastapi import Response, HTTPException
from fastapi.security import HTTPAuthorizationCredentials

class MyAuthBackend(BaseAuth):
    def authenticate(
        self,
        res: Response,
        credential: HTTPAuthorizationCredentials
    ) -> dict[str, any] | None:
        # Your authentication logic
        token = credential.credentials
        user = verify_token(token)

        if not user:
            raise HTTPException(401, "Invalid token")

        return {
            "user_id": user.id,
            "username": user.username,
            "email": user.email
        }

ID Generation

AgentFlow includes Snowflake ID generation for distributed, time-sortable unique IDs.

pip install "10xscale-agentflow-cli[snowflakekit]"

Usage:

from agentflow_cli import SnowFlakeIdGenerator

# Initialize
generator = SnowFlakeIdGenerator(
    snowflake_epoch=1704067200000,  # Jan 1, 2024
    snowflake_node_id=1,
    snowflake_worker_id=1
)

# Generate ID
id = await generator.generate()
print(f"Generated ID: {id}")

Environment Configuration:

SNOWFLAKE_EPOCH=1704067200000
SNOWFLAKE_NODE_ID=1
SNOWFLAKE_WORKER_ID=1
SNOWFLAKE_TIME_BITS=39
SNOWFLAKE_NODE_BITS=5
SNOWFLAKE_WORKER_BITS=8

See the ID Generation Guide for more details.

Thread Name Generation

Generate human-friendly names for conversation threads.

from agentflow_cli.src.app.utils.thread_name_generator import AIThreadNameGenerator

generator = AIThreadNameGenerator()
name = generator.generate_name()
# Output: "thoughtful-dialogue", "exploring-ideas", etc.

See the Thread Name Generator Guide for custom implementations.

Deployment

See the Deployment Guide for complete deployment instructions.

Docker Deployment

# Generate Docker files
agentflow build --docker-compose

# Build and run
docker compose up --build -d

# Check logs
docker compose logs -f

Kubernetes

See Deployment Guide - Kubernetes for complete manifests.

Cloud Platforms

Project Structure

agentflow-cli/
โ”œโ”€โ”€ agentflow_cli/          # Main package
โ”‚   โ”œโ”€โ”€ __init__.py        # Package exports
โ”‚   โ”œโ”€โ”€ cli/               # CLI commands
โ”‚   โ”‚   โ”œโ”€โ”€ main.py       # CLI entry point
โ”‚   โ”‚   โ””โ”€โ”€ commands/     # Command implementations
โ”‚   โ””โ”€โ”€ src/              # Application source
โ”‚       โ””โ”€โ”€ app/          # FastAPI application
โ”‚           โ”œโ”€โ”€ main.py   # App entry point
โ”‚           โ”œโ”€โ”€ core/     # Core functionality
โ”‚           โ”œโ”€โ”€ routers/  # API routes
โ”‚           โ””โ”€โ”€ utils/    # Utilities
โ”œโ”€โ”€ graph/                 # Agent graphs
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ react.py          # Sample React agent
โ”œโ”€โ”€ docs/                  # Documentation
โ”œโ”€โ”€ tests/                 # Test suite
โ”œโ”€โ”€ agentflow.json        # Configuration
โ”œโ”€โ”€ pyproject.toml        # Project metadata
โ””โ”€โ”€ README.md             # This file

Development

Setup

# Clone repository
git clone https://github.com/10xHub/agentflow-cli.git
cd agentflow-cli

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Testing

# Run all tests
pytest

# With coverage
pytest --cov=agentflow_cli --cov-report=html

# Run specific test file
pytest tests/test_cli.py -v

Code Quality

# Format code
ruff format .

# Lint code
ruff check .

# Fix auto-fixable issues
ruff check --fix .

Using the Makefile

# Show available commands
make help

# Install development dependencies
make dev-install

# Run tests
make test

# Format and lint
make format
make lint

# Build package
make build

# Clean build artifacts
make clean

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

MIT License - see LICENSE file for details.

Support

Credits

Developed by 10xScale and maintained by the community.


Made with โค๏ธ for the AI agent development community

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

10xscale_agentflow_cli-0.2.3.tar.gz (65.7 kB view details)

Uploaded Source

Built Distribution

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

10xscale_agentflow_cli-0.2.3-py3-none-any.whl (80.4 kB view details)

Uploaded Python 3

File details

Details for the file 10xscale_agentflow_cli-0.2.3.tar.gz.

File metadata

  • Download URL: 10xscale_agentflow_cli-0.2.3.tar.gz
  • Upload date:
  • Size: 65.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for 10xscale_agentflow_cli-0.2.3.tar.gz
Algorithm Hash digest
SHA256 1bf62f590b2eaaf7f3865cccba8dff4a1318f8836641331720cf77d4006b9d1c
MD5 d171fc5c45cad0f16d4dace746217498
BLAKE2b-256 441deab67679cab4d4a0466e821e5dda175e1b549541dee74d2fa5818342b6b0

See more details on using hashes here.

File details

Details for the file 10xscale_agentflow_cli-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for 10xscale_agentflow_cli-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 161b4cb53c5a852bc39a52aeb3537c30795d5cd0b45be2ba6a099ee47a3ec240
MD5 ae0b8e9d65a936ca889b0a32f089da0b
BLAKE2b-256 4f8bc41ffe957c1f1da0be4bce6288a8c1ea1b6bf7516317c20402e8fe17dc07

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