From 9bf38e166204d1c88daf6a81237ce58a6b3a58ee Mon Sep 17 00:00:00 2001 From: aitbc Date: Thu, 9 Apr 2026 10:15:59 +0200 Subject: [PATCH] feat: add handler functions for openclaw, workflow, resource, and simulate commands - Added handle_openclaw_action for agent file, wallet, environment, and market operations - Added handle_workflow_action for workflow name, template, config, and async execution - Added handle_resource_action for resource type, agent, CPU, memory, and duration management - Added handle_simulate_action for blockchain, wallets, price, network, and AI job simulations - Implemented kwargs extraction pattern for optional --- cli/unified_cli.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/cli/unified_cli.py b/cli/unified_cli.py index aa106f22..9055fb5f 100644 --- a/cli/unified_cli.py +++ b/cli/unified_cli.py @@ -463,6 +463,57 @@ def run_cli(argv, core): sys.exit(1) render_mapping(f"Agent {result['action']}:", result) + def handle_openclaw_action(args): + kwargs = {} + for name in ("agent_file", "wallet", "environment", "agent_id", "metrics", "price"): + value = getattr(args, name, None) + if value not in (None, "", False): + kwargs[name] = value + market_action = first(getattr(args, "market_action", None), getattr(args, "market_action_opt", None)) + if market_action: + kwargs["market_action"] = market_action + result = openclaw_operations(args.openclaw_action, **kwargs) + if not result: + sys.exit(1) + render_mapping(f"OpenClaw {result['action']}:", result) + + def handle_workflow_action(args): + kwargs = {} + for name in ("name", "template", "config_file", "params", "async_exec"): + value = getattr(args, name, None) + if value not in (None, "", False): + kwargs[name] = value + result = workflow_operations(args.workflow_action, **kwargs) + if not result: + sys.exit(1) + render_mapping(f"Workflow {result['action']}:", result) + + def handle_resource_action(args): + kwargs = {} + for name in ("type", "agent_id", "cpu", "memory", "duration"): + value = getattr(args, name, None) + if value not in (None, "", False): + kwargs[name] = value + result = resource_operations(args.resource_action, **kwargs) + if not result: + sys.exit(1) + render_mapping(f"Resource {result['action']}:", result) + + def handle_simulate_action(args): + if args.simulate_command == "blockchain": + simulate_blockchain(args.blocks, args.transactions, args.delay) + elif args.simulate_command == "wallets": + simulate_wallets(args.wallets, args.balance, args.transactions, args.amount_range) + elif args.simulate_command == "price": + simulate_price(args.price, args.volatility, args.timesteps, args.delay) + elif args.simulate_command == "network": + simulate_network(args.nodes, args.network_delay, args.failure_rate) + elif args.simulate_command == "ai-jobs": + simulate_ai_jobs(args.jobs, args.models, args.duration_range) + else: + print(f"Unknown simulate command: {args.simulate_command}") + sys.exit(1) + parser = argparse.ArgumentParser( description="AITBC CLI - Comprehensive Blockchain Management Tool", epilog="Examples: aitbc wallet create demo secret | aitbc wallet balance demo | aitbc ai submit --wallet demo --type text-generation --prompt 'hello' --payment 1",