File size: 1,576 Bytes
b19d31a
 
 
e2bd30e
 
b19d31a
e2bd30e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ff709d
e2bd30e
 
 
 
 
 
 
 
 
 
 
b19d31a
e2bd30e
 
 
 
 
b19d31a
e2bd30e
b19d31a
 
e2bd30e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
import sys
import json
import os
import time

# Wait for OpenClaw to initialize
print("Waiting for OpenClaw to initialize...")
time.sleep(5)

# Load OpenClaw configuration
try:
    with open('/app/.openclaw/openclaw.json', 'r') as f:
        config = json.load(f)
    print("OpenClaw configuration loaded successfully")
except Exception as e:
    print(f"Error loading OpenClaw config: {e}")
    sys.exit(1)

# Check if A2A gateway is available
try:
    import a2ag
    a2a_available = True
    print("A2A Gateway extension is available")
except ImportError:
    a2a_available = False
    print("A2A Gateway extension not available")

# If A2A is available, initialize it with Cain's configuration
if a2a_available:
    try:
        # Extract configuration for A2A
        a2a_config = {
            "telegram": {
                "token": config.get("telegram_token", ""),
                "allowed_user_ids": config.get("telegram_allowed_ids", [])
            },
            "llm": {
                "provider": config.get("llm_provider", "openai"),
                "model": config.get("llm_model", "gpt-3.5-turbo"),
                "api_key": config.get("llm_api_key", ""),
                "temperature": config.get("llm_temperature", 0.7)
            }
        }
        
        # Initialize A2A gateway
        a2a = a2ag.A2A(a2a_config)
        print("A2A Gateway initialized successfully")
    except Exception as e:
        print(f"Error initializing A2A Gateway: {e}")
        sys.exit(1)

print("Sync script completed successfully")
sys.exit(0)