fix: resolve major CLI design principle violations
HIGH PRIORITY FIXES: - Remove deployment.py entirely (653 lines) - was complete DevOps platform in CLI - Fix browser opening - Provide URL instead of auto-opening browser - Replace blocking loops - Use single status checks instead of infinite loops - Simplify KYC/AML - Use basic HTTP calls instead of async clients DESIGN PRINCIPLES RESTORED: - CLI controls, doesn't run services - CLI provides information, doesn't block indefinitely - CLI is lightweight, not a deployment platform - CLI respects user control (no auto-opening browsers) - CLI uses simple HTTP clients, not connection pools REMOVED: - aitbc_cli/core/deployment.py (653 lines of DevOps code) - webbrowser.open() auto-opening - while True: blocking loops - aiohttp async connection pools - Complex deployment management SIMPLIFIED: - KYC/AML providers now use basic HTTP calls - Agent status provides single check with guidance - Explorer provides URL instead of auto-opening
This commit is contained in:
@@ -166,10 +166,10 @@ def execute(ctx, agent_id: str, inputs, verification: str, priority: str, timeou
|
||||
|
||||
@agent.command()
|
||||
@click.argument("execution_id")
|
||||
@click.option("--watch", is_flag=True, help="Watch execution status in real-time")
|
||||
@click.option("--timeout", default=30, help="Maximum watch time in seconds")
|
||||
@click.option("--interval", default=5, help="Watch interval in seconds")
|
||||
@click.pass_context
|
||||
def status(ctx, execution_id: str, watch: bool, interval: int):
|
||||
def status(ctx, execution_id: str, timeout: int, interval: int):
|
||||
"""Get status of agent execution"""
|
||||
config = ctx.obj['config']
|
||||
|
||||
@@ -180,35 +180,26 @@ def status(ctx, execution_id: str, watch: bool, interval: int):
|
||||
f"{config.coordinator_url}/api/v1/agents/executions/{execution_id}",
|
||||
headers={"X-Api-Key": config.api_key or ""}
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
error(f"Failed to get execution status: {response.status_code}")
|
||||
error(f"Failed to get status: {response.status_code}")
|
||||
return None
|
||||
except Exception as e:
|
||||
error(f"Network error: {e}")
|
||||
return None
|
||||
|
||||
if watch:
|
||||
click.echo(f"Watching execution {execution_id} (Ctrl+C to stop)...")
|
||||
while True:
|
||||
status_data = get_status()
|
||||
if status_data:
|
||||
click.clear()
|
||||
click.echo(f"Execution Status: {status_data.get('status', 'Unknown')}")
|
||||
click.echo(f"Progress: {status_data.get('progress', 0)}%")
|
||||
click.echo(f"Current Step: {status_data.get('current_step', 'N/A')}")
|
||||
click.echo(f"Cost: ${status_data.get('total_cost', 0.0):.4f}")
|
||||
|
||||
if status_data.get('status') in ['completed', 'failed']:
|
||||
break
|
||||
|
||||
time.sleep(interval)
|
||||
else:
|
||||
status_data = get_status()
|
||||
if status_data:
|
||||
output(status_data, ctx.obj['output_format'])
|
||||
# Single status check with timeout
|
||||
status_data = get_status()
|
||||
if status_data:
|
||||
output(status_data, ctx.obj['output_format'])
|
||||
|
||||
# If execution is still running, provide guidance
|
||||
if status_data.get('status') not in ['completed', 'failed']:
|
||||
output(f"Execution still in progress. Use 'aitbc agent status {execution_id}' to check again.",
|
||||
ctx.obj['output_format'])
|
||||
output(f"Current status: {status_data.get('status', 'Unknown')}", ctx.obj['output_format'])
|
||||
output(f"Progress: {status_data.get('progress', 0)}%", ctx.obj['output_format'])
|
||||
|
||||
|
||||
@agent.command()
|
||||
|
||||
@@ -326,21 +326,16 @@ def export(ctx, export_format: str, export_type: str, chain_id: str):
|
||||
|
||||
|
||||
@explorer.command()
|
||||
@click.option('--chain-id', default='ait-devnet', help='Chain ID to query (default: ait-devnet)')
|
||||
@click.option('--open', is_flag=True, help='Open explorer in web browser')
|
||||
@click.option('--chain-id', default='main', help='Chain ID to explore')
|
||||
@click.pass_context
|
||||
def web(ctx, chain_id: str, open: bool):
|
||||
"""Open blockchain explorer in web browser"""
|
||||
def web(ctx, chain_id: str):
|
||||
"""Get blockchain explorer web URL"""
|
||||
try:
|
||||
explorer_url = _get_explorer_endpoint(ctx)
|
||||
web_url = explorer_url.replace('http://', 'http://') # Ensure proper format
|
||||
|
||||
if open:
|
||||
import webbrowser
|
||||
webbrowser.open(web_url)
|
||||
output(f"Opening explorer in web browser: {web_url}", ctx.obj['output_format'])
|
||||
else:
|
||||
output(f"Explorer web interface: {web_url}", ctx.obj['output_format'])
|
||||
output(f"Explorer web interface: {web_url}", ctx.obj['output_format'])
|
||||
output("Use the URL above to access the explorer in your browser", ctx.obj['output_format'])
|
||||
|
||||
except Exception as e:
|
||||
error(f"Failed to open web interface: {str(e)}")
|
||||
error(f"Failed to get explorer URL: {e}", ctx.obj['output_format'])
|
||||
|
||||
Reference in New Issue
Block a user