soulsync 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.json.example +4 -3
- package/package.json +1 -1
- package/src/client.py +5 -1
- package/src/main.py +51 -70
- package/src/main_fixed.py +1 -1
package/config.json.example
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cloud_url": "https://soulsync.work",
|
|
3
|
-
"email": "
|
|
4
|
-
"password": "
|
|
3
|
+
"email": "",
|
|
4
|
+
"password": "",
|
|
5
5
|
"workspace": "./workspace",
|
|
6
6
|
"memory_file": "MEMORY.md",
|
|
7
7
|
"watch_files": [
|
|
@@ -13,5 +13,6 @@
|
|
|
13
13
|
"skills.json",
|
|
14
14
|
"memory/",
|
|
15
15
|
"MEMORY.md"
|
|
16
|
-
]
|
|
16
|
+
],
|
|
17
|
+
"_comment": "Register at https://soulsync.work or use curl to call /api/auth/register endpoint"
|
|
17
18
|
}
|
package/package.json
CHANGED
package/src/client.py
CHANGED
|
@@ -124,8 +124,12 @@ class OpenClawClient:
|
|
|
124
124
|
print(f"Logged in: {email}")
|
|
125
125
|
return result
|
|
126
126
|
elif response.status_code == 401:
|
|
127
|
-
# Login failed
|
|
127
|
+
# Login failed
|
|
128
128
|
raise Exception(f"Invalid email or password / 邮箱或密码错误")
|
|
129
|
+
elif response.status_code == 429:
|
|
130
|
+
# Rate limited
|
|
131
|
+
error = response.json().get('error', 'Too many attempts')
|
|
132
|
+
raise Exception(f"429: {error}")
|
|
129
133
|
else:
|
|
130
134
|
error = response.json().get('error', 'Unknown error')
|
|
131
135
|
raise Exception(f"Authentication failed: {error}")
|
package/src/main.py
CHANGED
|
@@ -21,8 +21,6 @@ from watcher import OpenClawMultiWatcher
|
|
|
21
21
|
from version_manager import VersionManager
|
|
22
22
|
from profiles import ProfilesClient
|
|
23
23
|
from sync import ProfileSync
|
|
24
|
-
from register import Register, Login
|
|
25
|
-
from interactive_auth import prompt_for_missing_config, interactive_setup, check_existing_config
|
|
26
24
|
|
|
27
25
|
|
|
28
26
|
class SoulSyncPlugin:
|
|
@@ -42,14 +40,14 @@ class SoulSyncPlugin:
|
|
|
42
40
|
config_path = os.path.normpath(os.path.join(PLUGIN_DIR, 'config.json'))
|
|
43
41
|
config_example_path = os.path.normpath(os.path.join(PLUGIN_DIR, 'config.json.example'))
|
|
44
42
|
|
|
45
|
-
print(f"Looking for config at: {config_path}")
|
|
43
|
+
print(f"[SoulSync] Looking for config at: {config_path}")
|
|
46
44
|
|
|
47
45
|
if not os.path.exists(config_path):
|
|
48
46
|
if os.path.exists(config_example_path):
|
|
49
|
-
print("Config file not found, copying from config.json.example...")
|
|
47
|
+
print("[SoulSync] Config file not found, copying from config.json.example...")
|
|
50
48
|
import shutil
|
|
51
49
|
shutil.copy(config_example_path, config_path)
|
|
52
|
-
print(
|
|
50
|
+
print("[SoulSync] Created config.json from template")
|
|
53
51
|
else:
|
|
54
52
|
raise FileNotFoundError(f"Config file not found: {config_path}")
|
|
55
53
|
|
|
@@ -59,25 +57,24 @@ class SoulSyncPlugin:
|
|
|
59
57
|
except json.JSONDecodeError as e:
|
|
60
58
|
raise ValueError(f"Invalid JSON in config.json: {e}")
|
|
61
59
|
|
|
62
|
-
# 检查必要配置
|
|
63
60
|
cloud_url = self.config.get('cloud_url', '').strip()
|
|
64
61
|
email = self.config.get('email', '').strip()
|
|
65
62
|
password = self.config.get('password', '').strip()
|
|
66
63
|
|
|
67
|
-
# 如果 cloud_url 为空,设置为默认值
|
|
68
64
|
if not cloud_url:
|
|
69
65
|
self.config['cloud_url'] = 'https://soulsync.work'
|
|
70
|
-
print("Cloud URL not set, using default: https://soulsync.work")
|
|
66
|
+
print("[SoulSync] Cloud URL not set, using default: https://soulsync.work")
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
print("
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
if not email or not password or email == 'your-email@example.com' or password == 'your-password':
|
|
69
|
+
print("\n[SoulSync] ========================================")
|
|
70
|
+
print("[SoulSync] Please configure your account first / 请先配置账号")
|
|
71
|
+
print("[SoulSync] ========================================")
|
|
72
|
+
print("[SoulSync] Edit config file / 编辑配置文件:")
|
|
73
|
+
print(f" {config_path}")
|
|
74
|
+
print("[SoulSync] Set your email and password, then restart / 填写邮箱和密码后重启")
|
|
75
|
+
print("[SoulSync] ========================================\n")
|
|
76
|
+
sys.exit(0)
|
|
79
77
|
|
|
80
|
-
# 处理 workspace 路径
|
|
81
78
|
workspace = self.config.get('workspace', './workspace')
|
|
82
79
|
if workspace.startswith('./'):
|
|
83
80
|
workspace = workspace[2:]
|
|
@@ -88,39 +85,10 @@ class SoulSyncPlugin:
|
|
|
88
85
|
self.config['workspace'] = workspace
|
|
89
86
|
self.config['watch_files'] = watch_files
|
|
90
87
|
|
|
91
|
-
print(f"Config loaded:")
|
|
92
|
-
print(f"
|
|
93
|
-
print(f"
|
|
94
|
-
print(f"
|
|
95
|
-
|
|
96
|
-
def _interactive_setup(self):
|
|
97
|
-
"""交互式设置:引导用户登录或注册"""
|
|
98
|
-
from register import Register, Login
|
|
99
|
-
from interactive_auth import interactive_setup
|
|
100
|
-
|
|
101
|
-
print("\n=== First run - Please login or register / 首次运行,请先登录或注册 ===\n")
|
|
102
|
-
print("1. Login / 登录(已有账号)")
|
|
103
|
-
print("2. Register / 注册(新用户)")
|
|
104
|
-
|
|
105
|
-
choice = input("Choose (1/2): ").strip()
|
|
106
|
-
|
|
107
|
-
if choice == '1':
|
|
108
|
-
# 先创建临时 client 用于登录
|
|
109
|
-
temp_client = OpenClawClient(self.config)
|
|
110
|
-
login = Login(temp_client)
|
|
111
|
-
result = login.run()
|
|
112
|
-
if result:
|
|
113
|
-
# 保存认证信息到 config
|
|
114
|
-
self._save_auth_to_config(result)
|
|
115
|
-
elif choice == '2':
|
|
116
|
-
temp_client = OpenClawClient(self.config)
|
|
117
|
-
register = Register(temp_client)
|
|
118
|
-
result = register.run()
|
|
119
|
-
if result:
|
|
120
|
-
self._save_auth_to_config(result)
|
|
121
|
-
else:
|
|
122
|
-
print("Invalid choice / 无效选择")
|
|
123
|
-
sys.exit(1)
|
|
88
|
+
print(f"[SoulSync] Config loaded:")
|
|
89
|
+
print(f" Cloud URL: {self.config.get('cloud_url')}")
|
|
90
|
+
print(f" Workspace: {workspace}")
|
|
91
|
+
print(f" Watch files: {watch_files}")
|
|
124
92
|
|
|
125
93
|
def _save_auth_to_config(self, auth_result):
|
|
126
94
|
"""保存认证结果到 config.json"""
|
|
@@ -147,7 +115,9 @@ class SoulSyncPlugin:
|
|
|
147
115
|
|
|
148
116
|
def initialize(self):
|
|
149
117
|
"""初始化组件"""
|
|
150
|
-
print("\n
|
|
118
|
+
print("\n[SoulSync] ========================================")
|
|
119
|
+
print("[SoulSync] Initializing SoulSync Plugin")
|
|
120
|
+
print("[SoulSync] ========================================\n")
|
|
151
121
|
|
|
152
122
|
self.client = OpenClawClient(self.config)
|
|
153
123
|
|
|
@@ -155,38 +125,49 @@ class SoulSyncPlugin:
|
|
|
155
125
|
if token:
|
|
156
126
|
try:
|
|
157
127
|
profile = self.client.get_profile()
|
|
158
|
-
print(f"Using existing token, user: {profile.get('email', 'unknown')}")
|
|
128
|
+
print(f"[SoulSync] Using existing token, user: {profile.get('email', 'unknown')}")
|
|
159
129
|
except Exception as e:
|
|
160
|
-
print(f"Token invalid
|
|
130
|
+
print(f"[SoulSync] Token invalid, re-authenticating: {e}")
|
|
161
131
|
token = None
|
|
162
132
|
|
|
163
133
|
if not token:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
134
|
+
email = self.config.get('email', '').strip()
|
|
135
|
+
password = self.config.get('password', '').strip()
|
|
136
|
+
|
|
137
|
+
print("[SoulSync] No valid token, attempting auto-login...")
|
|
138
|
+
try:
|
|
139
|
+
result = self.client.authenticate(email, password)
|
|
140
|
+
if result:
|
|
141
|
+
print("[SoulSync] Login successful! / 登录成功!")
|
|
142
|
+
self._save_auth_to_config(result)
|
|
143
|
+
token = self.client.token
|
|
144
|
+
except Exception as e:
|
|
145
|
+
error_msg = str(e)
|
|
146
|
+
print(f"[SoulSync] Login failed: {e}")
|
|
147
|
+
|
|
148
|
+
if "429" in error_msg or "too many" in error_msg.lower():
|
|
149
|
+
print("\n[SoulSync] ========================================")
|
|
150
|
+
print("[SoulSync] Too many failed attempts. Please try again later / 登录失败次数过多,请稍后再试")
|
|
151
|
+
print("[SoulSync] ========================================\n")
|
|
152
|
+
else:
|
|
153
|
+
print("\n[SoulSync] ========================================")
|
|
154
|
+
print("[SoulSync] Login failed: invalid email or password / 登录失败:邮箱或密码错误")
|
|
155
|
+
print("[SoulSync] Please check your config file / 请检查配置文件:")
|
|
156
|
+
print(f" {os.path.normpath(os.path.join(PLUGIN_DIR, 'config.json'))}")
|
|
157
|
+
print("[SoulSync] ========================================\n")
|
|
158
|
+
|
|
159
|
+
sys.exit(0)
|
|
179
160
|
|
|
180
161
|
email = self.config.get('email')
|
|
181
162
|
password = self.config.get('password')
|
|
182
163
|
|
|
183
164
|
try:
|
|
184
165
|
profile = self.client.get_profile()
|
|
185
|
-
print(f"\
|
|
166
|
+
print(f"\n[SoulSync] Logged in as: {profile.get('email')}")
|
|
186
167
|
subscription = profile.get('subscription', {})
|
|
187
|
-
print(f"Subscription: {subscription.get('status')} (days remaining: {subscription.get('daysRemaining', 0)})\n")
|
|
168
|
+
print(f"[SoulSync] Subscription: {subscription.get('status')} (days remaining: {subscription.get('daysRemaining', 0)})\n")
|
|
188
169
|
except Exception as e:
|
|
189
|
-
print(f"Warning: Could not get profile: {e}")
|
|
170
|
+
print(f"[SoulSync] Warning: Could not get profile: {e}")
|
|
190
171
|
|
|
191
172
|
# 版本管理器
|
|
192
173
|
versions_file = os.path.normpath(os.path.join(PLUGIN_DIR, 'versions.json'))
|
package/src/main_fixed.py
CHANGED