Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI Tool

Command-line interface for all NeuAIs operations. Built with Python using the Calliope framework.

Installation

pip install neuais

Or from source:

git clone https://github.com/neuais/cli
cd cli
pip install -e .

Configuration

Config File

~/.neuais/config.toml:

[default]
endpoint = "https://api.neuais.com"
region = "us-west-2"
output = "json"

[profile.staging]
endpoint = "https://staging-api.neuais.com"
region = "us-west-2"

[profile.local]
endpoint = "http://localhost:8080"
region = "local"

Environment Variables

export NEUAIS_ENDPOINT="https://api.neuais.com"
export NEUAIS_TOKEN="your-token"
export NEUAIS_REGION="us-west-2"
export NEUAIS_OUTPUT="json"

Commands

Authentication

# Sign up
neuais auth signup

# Login
neuais auth login

# Logout
neuais auth logout

# Show current user
neuais auth whoami

# Refresh token
neuais auth refresh

Agent Management

# List agents
neuais agent list
neuais agent list --status running
neuais agent list --region us-west-2

# Deploy agent
neuais agent deploy my-agent \
  --config agent.toml \
  --binary ./target/release/my-agent

# Get agent details
neuais agent get my-agent
neuais agent get my-agent --output yaml

# Update agent
neuais agent update my-agent \
  --binary ./target/release/my-agent \
  --strategy rolling

# Delete agent
neuais agent delete my-agent
neuais agent delete my-agent --force

# Start/stop agent
neuais agent start my-agent
neuais agent stop my-agent
neuais agent restart my-agent

# Scale agent
neuais agent scale my-agent --replicas 5

# Get agent status
neuais agent status my-agent

Log Management

# Stream logs
neuais logs my-agent
neuais logs my-agent --follow
neuais logs my-agent --tail 100
neuais logs my-agent --since 1h
neuais logs my-agent --level error

# Download logs
neuais logs my-agent --download logs.txt
neuais logs my-agent --since 24h --download daily.log

Metrics

# Get agent metrics
neuais metrics my-agent
neuais metrics my-agent --period 1h
neuais metrics my-agent --metric cpu,memory

# Export metrics
neuais metrics my-agent --export metrics.json

Configuration

# Get config
neuais config get
neuais config get default.endpoint

# Set config
neuais config set default.endpoint https://api.neuais.com
neuais config set default.region us-east-1

# List profiles
neuais config profiles

# Use profile
neuais --profile staging agent list

Service Management

# List services
neuais service list

# Get service status
neuais service status auth
neuais service status --all

# Service logs
neuais service logs auth --tail 50

Observatory

# Open Observatory
neuais observatory

# Open for specific agent
neuais observatory --agent my-agent

# Open for region
neuais observatory --region us-west-2

Output Formats

JSON (default)

neuais agent list --output json
[
  {
    "id": "agt_1a2b3c",
    "name": "my-agent",
    "status": "running",
    "replicas": 3
  }
]

YAML

neuais agent list --output yaml
- id: agt_1a2b3c
  name: my-agent
  status: running
  replicas: 3

Table

neuais agent list --output table
ID          NAME       STATUS    REPLICAS
agt_1a2b3c  my-agent   running   3
agt_2b3c4d  worker-1   stopped   0

Advanced Usage

Scripting

#!/bin/bash

# Deploy multiple agents
for agent in agent-{1..10}; do
  neuais agent deploy $agent \
    --config configs/$agent.toml \
    --binary ./target/release/worker
done

# Wait for all to be running
for agent in agent-{1..10}; do
  while [ "$(neuais agent status $agent --output json | jq -r '.status')" != "running" ]; do
    sleep 1
  done
done

echo "All agents deployed"

Filtering

# Filter by status
neuais agent list --status running

# Filter by region
neuais agent list --region us-west-2

# Filter by tag
neuais agent list --tag env=production

# Combine filters
neuais agent list --status running --region us-west-2 --tag env=prod

Batch Operations

# Stop all agents in region
neuais agent list --region us-west-2 --output json | \
  jq -r '.[].id' | \
  xargs -I {} neuais agent stop {}

# Scale all agents
neuais agent list --output json | \
  jq -r '.[].id' | \
  xargs -I {} neuais agent scale {} --replicas 5

Plugins

Installing Plugins

neuais plugin install neuais-plugin-monitoring
neuais plugin install neuais-plugin-backup

Using Plugins

# Monitoring plugin
neuais monitoring dashboard
neuais monitoring alerts

# Backup plugin
neuais backup create my-agent
neuais backup restore my-agent backup-20240115

Shell Completion

Bash

neuais completion bash > /etc/bash_completion.d/neuais
source /etc/bash_completion.d/neuais

Zsh

neuais completion zsh > ~/.zsh/completion/_neuais

Fish

neuais completion fish > ~/.config/fish/completions/neuais.fish

Troubleshooting

Command not found

Add to PATH:

export PATH="$HOME/.local/bin:$PATH"

Authentication failed

Refresh token:

neuais auth logout
neuais auth login

Connection timeout

Check endpoint:

curl -v https://api.neuais.com/health

SSL errors

Update CA certificates:

pip install --upgrade certifi

Development

Source Structure

micro_ai/
├── cli.py              # Entry point
├── commands/
│   ├── agent.py
│   ├── auth.py
│   ├── logs.py
│   └── config.py
├── core/
│   ├── client.py
│   ├── config.py
│   └── output.py
└── calliope/
    └── cli.py          # Calliope framework

Building

python -m build

Testing

pytest tests/

Next Steps