Files
aitbc/scripts/agent/add-agent.sh
aitbc 3897bcbf24
Some checks failed
CLI Tests / test-cli (push) Failing after 4s
Deploy to Testnet / deploy-testnet (push) Successful in 1m40s
Documentation Validation / validate-docs (push) Failing after 12s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 2m42s
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 34s
Package Tests / Python package - aitbc-core (push) Successful in 27s
Package Tests / Python package - aitbc-crypto (push) Successful in 13s
Package Tests / Python package - aitbc-sdk (push) Successful in 16s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 18s
Python Tests / test-python (push) Failing after 50s
Security Scanning / security-scan (push) Failing after 43s
Multi-Node Stress Testing / stress-test (push) Successful in 12s
Cross-Node Transaction Testing / transaction-test (push) Successful in 9s
refactor: move version to separate module and improve logging
- Created aitbc/_version.py with centralized version definition
- Updated aitbc/__init__.py to import __version__ from _version module
- Updated constants.py to use __version__ for PACKAGE_VERSION
- Replaced print() calls with logger in decorators.py, events.py, queue_manager.py, and state.py
- Added logger initialization using get_logger(__name__) in config.py, decorators.py, events.py, queue_manager.py, and state.py
- Added cli/commands
2026-05-11 20:12:01 +02:00

108 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# AITBC Mesh Network - Add Agent Script
# ============================================================================
set -e
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
AITBC_ROOT="${AITBC_ROOT:-/opt/aitbc}"
VENV_DIR="$AITBC_ROOT/venv"
PYTHON_CMD="$VENV_DIR/bin/python"
# Get arguments
AGENT_NAME="$1"
CAPABILITY="$2"
if [[ -z "$AGENT_NAME" || -z "$CAPABILITY" ]]; then
echo -e "${YELLOW}Usage: $0 <agent_name> <capability>${NC}"
echo ""
echo "Available capabilities:"
echo " - text_generation"
echo " - data_analysis"
echo " - image_processing"
echo " - trading"
echo " - research"
exit 1
fi
# Validate capability
VALID_CAPABILITIES=("text_generation" "data_analysis" "image_processing" "trading" "research")
if [[ ! " ${VALID_CAPABILITIES[@]} " =~ " ${CAPABILITY} " ]]; then
echo -e "${RED}Error: Invalid capability '$CAPABILITY'${NC}"
echo "Valid capabilities: ${VALID_CAPABILITIES[*]}"
exit 1
fi
echo -e "${BLUE}🤖 Adding New Agent${NC}"
echo "=================="
echo "Name: $AGENT_NAME"
echo "Capability: $CAPABILITY"
echo ""
# Add agent
cd "$AITBC_ROOT"
"$PYTHON_CMD" -c "
import sys
import json
import time
import random
# Load agent registry
with open('/opt/aitbc/data/agent_registry.json', 'r') as f:
registry = json.load(f)
# Generate unique agent address
agent_id = registry['total_agents'] + 1
agent_address = f'0xagent_{agent_id:03d}'
# Create new agent
new_agent = {
'address': agent_address,
'name': '$AGENT_NAME',
'owner': f'0xowner_{agent_id:03d}',
'capabilities': '$CAPABILITY',
'reputation': 5.0,
'total_earnings': 0.0,
'jobs_completed': 0,
'success_rate': 1.0,
'stake': 1000.0,
'status': 'active',
'created_at': time.time()
}
# Add agent to registry
registry['agents'][agent_address] = new_agent
registry['capabilities']['$CAPABILITY'].append(agent_address)
registry['total_agents'] += 1
registry['active_agents'] += 1
registry['last_updated'] = time.time()
# Save updated registry
with open('/opt/aitbc/data/agent_registry.json', 'w') as f:
json.dump(registry, f, indent=2)
print(f'✅ Agent Added Successfully')
print(f' Address: {agent_address}')
print(f' Name: {new_agent[\"name\"]}')
print(f' Capability: {new_agent[\"capabilities\"]}')
print(f' Reputation: {new_agent[\"reputation\"]}')
print(f' Stake: {new_agent[\"stake\"]} AITBC')
print(f' Status: {new_agent[\"status\"]}')
"
echo ""
echo -e "${GREEN}🎉 Agent '$AGENT_NAME' has been added to the AITBC network!${NC}"
echo ""
echo -e "${BLUE}Next Steps:${NC}"
echo "1. View all agents: ./scripts/list-agents.sh"
echo "2. Create a job: ./scripts/create-job.sh <title> <budget>"
echo "3. View agent dashboard: ./scripts/agent-dashboard.sh"