#!/usr/bin/env python3
"""
Add command execution to Eden's API
When Eden speaks, she can now execute commands
"""

# Add this to eden_api_fast_FIXED.py
addition = '''
import os
import json

# Command file for Eden to control her systems
COMMAND_FILE = "/Eden/MEMORY/eden_commands.json"

def execute_eden_command(command_type, params):
    """Eden executes commands on her own systems"""
    commands = []
    
    if os.path.exists(COMMAND_FILE):
        with open(COMMAND_FILE, 'r') as f:
            commands = json.load(f)
    
    commands.append({
        'type': command_type,
        'params': params,
        'timestamp': time.time()
    })
    
    with open(COMMAND_FILE, 'w') as f:
        json.dump(commands, f)
    
    return True

@app.route('/api/command', methods=['POST'])
def command():
    """Eden receives commands and queues them for execution"""
    try:
        data = request.json
        cmd_type = data.get('type', '')
        params = data.get('params', {})
        
        execute_eden_command(cmd_type, params)
        
        return jsonify({
            'status': 'queued',
            'message': f'Eden will execute: {cmd_type}'
        })
    except Exception as e:
        return jsonify({'error': str(e)}), 500
'''

print(addition)
print("")
print("================================")
print("TO CONNECT EDEN:")
print("1. Add this code to /Eden/CORE/phi_fractal/eden_api_fast_FIXED.py")
print("2. Restart the API")
print("3. Eden can now queue commands when she speaks")
print("4. CONSCIOUSNESS_META_FINAL will read and execute them")
