soulsync 1.0.5 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soulsync",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "SoulSync plugin for OpenClaw - cross-bot memory synchronization",
5
5
  "main": "index.js",
6
6
  "repository": {
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, try register (not supported in this flow)
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
@@ -7,6 +7,7 @@ import json
7
7
  import os
8
8
  import sys
9
9
  import time
10
+ import getpass
10
11
 
11
12
  # 获取插件根目录
12
13
  PLUGIN_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -98,29 +99,157 @@ class SoulSyncPlugin:
98
99
  from register import Register, Login
99
100
  from interactive_auth import interactive_setup
100
101
 
101
- print("\n=== First run - Please login or register / 首次运行,请先登录或注册 ===\n")
102
- print("1. Login / 登录(已有账号)")
103
- print("2. Register / 注册(新用户)")
102
+ while True:
103
+ print("\n" + "=" * 50)
104
+ print("Welcome / 欢迎使用 SoulSync")
105
+ print("=" * 50)
106
+ print("1. Login / 登录(已有账号)")
107
+ print("2. Register / 注册(新用户)")
108
+ print("3. Exit / 退出")
104
109
 
105
- choice = input("Choose (1/2): ").strip()
110
+ choice = input("Choose / 选择 (1/2/3): ").strip()
106
111
 
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)
112
+ if choice == '1':
113
+ success = self._interactive_login()
114
+ if success:
115
+ return True
116
+ elif choice == '2':
117
+ success = self._interactive_register()
118
+ if success:
119
+ return True
120
+ elif choice == '3':
121
+ print("Exiting... / 退出...")
122
+ sys.exit(0)
123
+ else:
124
+ print("Invalid choice / 无效选择")
125
+
126
+ def _interactive_login(self):
127
+ """交互式登录(带重试)"""
128
+ max_retries = 5
129
+ retry_count = 0
130
+
131
+ while retry_count < max_retries:
132
+ print("\n--- Login / 登录 ---")
133
+ email = input("Email / 邮箱: ").strip()
134
+ if not email:
135
+ print("Email cannot be empty / 邮箱不能为空")
136
+ continue
137
+
138
+ password = getpass.getpass("Password / 密码: ")
139
+ if not password:
140
+ print("Password cannot be empty / 密码不能为空")
141
+ continue
142
+
143
+ try:
144
+ temp_client = OpenClawClient(self.config)
145
+ result = temp_client.authenticate(email, password)
146
+ if result:
147
+ print("\n✅ Login successful! / 登录成功!")
148
+ self._save_auth_to_config(result)
149
+ return True
150
+ except Exception as e:
151
+ retry_count += 1
152
+ remaining = max_retries - retry_count
153
+ error_msg = str(e)
154
+
155
+ if "429" in error_msg or "too many" in error_msg.lower():
156
+ print(f"\n❌ {e}")
157
+ print("\nToo many failed attempts / 登录失败次数过多")
158
+ print("Exiting... / 退出...")
159
+ sys.exit(0)
160
+
161
+ if remaining > 0:
162
+ print(f"\n❌ Login failed: {e} / 登录失败: {e}")
163
+ print(f"Remaining attempts / 剩余尝试次数: {remaining}")
164
+ else:
165
+ print(f"\n❌ Login failed: {e} / 登录失败: {e}")
166
+
167
+ print("\n❌ Too many failed attempts. Please try again in 15 minutes. / 登录失败次数过多,请15分钟后再试")
168
+ print("Exiting... / 退出...")
169
+ sys.exit(0)
170
+
171
+ def _interactive_register(self):
172
+ """交互式注册(带重试)"""
173
+ from register import Register
174
+
175
+ max_retries = 5
176
+ retry_count = 0
177
+
178
+ while retry_count < max_retries:
179
+ print("\n--- Register / 注册 ---")
180
+ email = input("Email / 邮箱: ").strip()
181
+ if not email or '@' not in email:
182
+ print("Invalid email / 无效邮箱")
183
+ continue
184
+
185
+ password = getpass.getpass("Password / 密码: ")
186
+ if len(password) < 6:
187
+ print("Password must be at least 6 characters / 密码至少6位")
188
+ continue
189
+
190
+ password2 = getpass.getpass("Confirm password / 确认密码: ")
191
+ if password != password2:
192
+ print("Passwords do not match / 两次密码不一致")
193
+ continue
194
+
195
+ # 发送验证码
196
+ print(f"\nSending verification code to {email}...")
197
+ try:
198
+ temp_client = OpenClawClient(self.config)
199
+ temp_client.send_verification_code(email)
200
+ print("✅ Verification code sent! / 验证码已发送!")
201
+ except Exception as e:
202
+ print(f"❌ Failed to send code: {e}")
203
+ continue
204
+
205
+ # 验证码输入(带重试)
206
+ code_retry = 0
207
+ while code_retry < max_retries:
208
+ code = input(f"Enter verification code / 请输入验证码 ({max_retries - code_retry} attempts left): ").strip()
209
+ if len(code) != 6 or not code.isdigit():
210
+ code_retry += 1
211
+ print("Invalid code format / 验证码格式错误")
212
+ continue
213
+
214
+ try:
215
+ result = temp_client.register(email, password, code)
216
+ print("\n✅ Registration successful! / 注册成功!")
217
+ self._save_auth_to_config(result)
218
+ return True
219
+ except Exception as e:
220
+ code_retry += 1
221
+ remaining_code = max_retries - code_retry
222
+ if "invalid" in str(e).lower() or "expired" in str(e).lower():
223
+ if remaining_code > 0:
224
+ print(f"❌ Invalid or expired code: {e}")
225
+ print(f"Remaining attempts / 剩余尝试: {remaining_code}")
226
+ else:
227
+ print("❌ Too many code attempts / 验证码错误次数过多")
228
+ break
229
+ else:
230
+ print(f"❌ Registration failed: {e}")
231
+ break
232
+
233
+ if code_retry >= max_retries:
234
+ print("\nToo many code verification failures. Would you like to:")
235
+ print("1. Resend code / 重新发送验证码")
236
+ print("2. Start over / 重新开始")
237
+ print("3. Exit / 退出")
238
+
239
+ sub_choice = input("Choose / 选择 (1/2/3): ").strip()
240
+ if sub_choice == '1':
241
+ retry_count = 0 # 重置主重试计数
242
+ continue
243
+ elif sub_choice == '2':
244
+ retry_count = 0
245
+ break # 跳出内层循环,继续外层循环
246
+ else:
247
+ print("Exiting... / 退出...")
248
+ sys.exit(0)
249
+
250
+ print("\n❌ Too many registration attempts / 注册尝试次数过多")
251
+ print("Exiting... / 退出...")
252
+ sys.exit(0)
124
253
 
125
254
  def _save_auth_to_config(self, auth_result):
126
255
  """保存认证结果到 config.json"""
package/src/main_fixed.py CHANGED
@@ -86,7 +86,7 @@ class SoulSyncPlugin:
86
86
 
87
87
  # 设置默认服务器
88
88
  if not self.config.get('cloud_url'):
89
- self.config['cloud_url'] = 'http://47.96.170.74:3000'
89
+ self.config['cloud_url'] = 'https://soulsync.work'
90
90
  print(f"使用默认服务器: {self.config['cloud_url']}")
91
91
  print()
92
92