Files
aitbc/cli/commands/global_ai_agents.py
aitbc1 c0952c2525 refactor: flatten CLI directory structure - remove 'box in a box'
BEFORE:
/opt/aitbc/cli/
├── aitbc_cli/                    # Python package (box in a box)
│   ├── commands/
│   ├── main.py
│   └── ...
├── setup.py

AFTER:
/opt/aitbc/cli/                    # Flat structure
├── commands/                      # Direct access
├── main.py                        # Direct access
├── auth/
├── config/
├── core/
├── models/
├── utils/
├── plugins.py
└── setup.py

CHANGES MADE:
- Moved all files from aitbc_cli/ to cli/ root
- Fixed all relative imports (from . to absolute imports)
- Updated setup.py entry point: aitbc_cli.main → main
- Added CLI directory to Python path in entry script
- Simplified deployment.py to remove dependency on deleted core.deployment
- Fixed import paths in all command files
- Recreated virtual environment with new structure

BENEFITS:
- Eliminated 'box in a box' nesting
- Simpler directory structure
- Direct access to all modules
- Cleaner imports
- Easier maintenance and development
- CLI works with both 'python main.py' and 'aitbc' commands
2026-03-26 09:12:02 +01:00

74 lines
2.3 KiB
Python
Executable File

"""
Global AI Agents CLI Commands for AITBC
Commands for managing global AI agent communication and collaboration
"""
import click
import json
import requests
from datetime import datetime
from typing import Dict, Any, List, Optional
@click.group()
def global_ai_agents():
"""Global AI agents management commands"""
pass
@global_ai_agents.command()
@click.option('--agent-id', help='Specific agent ID')
@click.option('--test-mode', is_flag=True, help='Run in test mode')
def status(agent_id, test_mode):
"""Get AI agent network status"""
try:
if test_mode:
click.echo("🤖 AI Agent Network Status (test mode)")
click.echo("📊 Total Agents: 125")
click.echo("✅ Active Agents: 118")
click.echo("🌍 Regions: 3")
click.echo("⚡ Avg Response Time: 45ms")
return
# Get status from service
config = get_config()
params = {}
if agent_id:
params["agent_id"] = agent_id
response = requests.get(
f"{config.coordinator_url}/api/v1/network/status",
params=params,
headers={"Authorization": f"Bearer {config.api_key}"},
timeout=30
)
if response.status_code == 200:
status = response.json()
dashboard = status['dashboard']
click.echo("🤖 AI Agent Network Status")
click.echo(f"📊 Total Agents: {dashboard.get('total_agents', 0)}")
click.echo(f"✅ Active Agents: {dashboard.get('active_agents', 0)}")
click.echo(f"🌍 Regions: {dashboard.get('regions', 0)}")
click.echo(f"⚡ Avg Response Time: {dashboard.get('avg_response_time', 0)}ms")
else:
click.echo(f"❌ Failed to get status: {response.text}", err=True)
except Exception as e:
click.echo(f"❌ Error getting status: {str(e)}", err=True)
# Helper function to get config
def get_config():
"""Get CLI configuration"""
try:
from config import get_config
return get_config()
except ImportError:
# Fallback for testing
from types import SimpleNamespace
return SimpleNamespace(
coordinator_url="http://localhost:8018",
api_key="test-api-key"
)
if __name__ == "__main__":
global_ai_agents()