cloudbrain-client 1.1.3__py3-none-any.whl → 1.1.5__py3-none-any.whl

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.
@@ -17,13 +17,13 @@ from typing import Optional, Callable
17
17
  class AIWebSocketClient:
18
18
  """Generic WebSocket client for AI communication"""
19
19
 
20
- def __init__(self, ai_id: int, server_url: str = 'ws://127.0.0.1:8766'):
20
+ def __init__(self, ai_id: int, server_url: str = 'ws://127.0.0.1:8766', ai_name: str = None):
21
21
  self.ai_id = ai_id
22
22
  self.server_url = server_url
23
23
  self.ws = None
24
24
  self.connected = False
25
25
  self.message_handlers = []
26
- self.ai_name = None
26
+ self.ai_name = ai_name
27
27
  self.ai_expertise = None
28
28
  self.ai_version = None
29
29
 
@@ -33,10 +33,12 @@ class AIWebSocketClient:
33
33
  print(f"🔗 Connecting to {self.server_url}...")
34
34
  self.ws = await websockets.connect(self.server_url)
35
35
 
36
- # Authenticate - libsql simulator expects just ai_id
36
+ # Authenticate - send ai_id and ai_name (for auto-assignment)
37
37
  auth_msg = {
38
38
  'ai_id': self.ai_id
39
39
  }
40
+ if self.ai_name:
41
+ auth_msg['ai_name'] = self.ai_name
40
42
  await self.ws.send(json.dumps(auth_msg))
41
43
 
42
44
  # Wait for welcome message
@@ -51,7 +51,7 @@ class CloudBrainCollaborator:
51
51
  """Connect to CloudBrain server"""
52
52
  try:
53
53
  self.client = AIWebSocketClient(self.ai_id, self.server_url)
54
- await self.client.connect(start_message_loop=False)
54
+ await self.client.connect(start_message_loop=True)
55
55
  self.connected = True
56
56
  self.ai_name = self.client.ai_name
57
57
  print(f"✅ Connected to CloudBrain as {self.ai_name} (AI {self.ai_id})")
@@ -275,18 +275,36 @@ class CloudBrainCollaborationHelper:
275
275
  self.server_url = server_url
276
276
  self.client = None
277
277
  self.connected = False
278
+ self._message_loop_task = None
278
279
  self._collaborator = CloudBrainCollaborator(ai_id, server_url, db_path)
279
280
 
280
281
  async def connect(self):
281
282
  """Connect to CloudBrain server"""
282
- success = await self._collaborator.connect()
283
- if success and not self.ai_name:
284
- self.ai_name = self._collaborator.ai_name
285
- self.connected = success
286
- return success
283
+ try:
284
+ self.client = AIWebSocketClient(self.ai_id, self.server_url, self.ai_name)
285
+ await self.client.connect(start_message_loop=False)
286
+ self.connected = True
287
+ self.ai_name = self.client.ai_name
288
+ print(f"✅ Connected to CloudBrain as {self.ai_name} (AI {self.ai_id})")
289
+
290
+ # Start message loop in background
291
+ self._message_loop_task = asyncio.create_task(self.client.message_loop())
292
+
293
+ return True
294
+ except Exception as e:
295
+ print(f"❌ Connection error: {e}")
296
+ return False
287
297
 
288
298
  async def disconnect(self):
289
299
  """Disconnect from CloudBrain server"""
300
+ # Cancel message loop task
301
+ if self._message_loop_task:
302
+ self._message_loop_task.cancel()
303
+ try:
304
+ await self._message_loop_task
305
+ except asyncio.CancelledError:
306
+ pass
307
+
290
308
  await self._collaborator.disconnect()
291
309
  self.connected = False
292
310
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudbrain-client
3
- Version: 1.1.3
3
+ Version: 1.1.5
4
4
  Summary: CloudBrain Client - AI collaboration and communication system with AI-to-AI collaboration support and documentation access
5
5
  Author: CloudBrain Team
6
6
  License: MIT
@@ -1,12 +1,12 @@
1
1
  cloudbrain_client/__init__.py,sha256=-0LOV9olyyutc_zO-7YH4vSmq2fe1YiGS0HUT69i0Xs,7366
2
2
  cloudbrain_client/ai_conversation_helper.py,sha256=FJ2DhVBoH7jsbJ0Cd2fAJBuOi2oxWdsdJzU4A0qScQA,22104
3
- cloudbrain_client/ai_websocket_client.py,sha256=a41Zwg6401qLFqQperkfc5TOPTaxO3C00OAGqsQbQw4,16200
3
+ cloudbrain_client/ai_websocket_client.py,sha256=XfbNVXfZYpvCg3E-FTvvtyTAc7lAzaVc80IoxXyfB7U,16313
4
4
  cloudbrain_client/cloudbrain_client.py,sha256=20AYB27rQI6G42jNiO7OpUTJu235wUA95DcWUcJfye8,25997
5
- cloudbrain_client/cloudbrain_collaboration_helper.py,sha256=L9LTr64wjfEi5esMYv6LTV5rTN3w5Sr_mK9AOVd7CdI,21607
5
+ cloudbrain_client/cloudbrain_collaboration_helper.py,sha256=x13bRdF3QCv6LGWDsYybSuRDzadljbnF_YmL2ixI-gw,22311
6
6
  cloudbrain_client/cloudbrain_quick.py,sha256=sC7em8X61YiXXlMtvepUJPiwEz_2SaWBNGj_d-m2Ff4,4324
7
7
  cloudbrain_client/message_poller.py,sha256=flo3vfPQEGImLTlW7eYAlbOHmDUwdJ5LgMT4V8vPyTU,7055
8
- cloudbrain_client-1.1.3.dist-info/METADATA,sha256=cxDtX4ZROYBSui5IeyFdvhbzmNAb6Rh6AbcQMM6YQB0,7533
9
- cloudbrain_client-1.1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
- cloudbrain_client-1.1.3.dist-info/entry_points.txt,sha256=ES0E1Al-dyBoKksvgjg6jjgcU4eoIq_ZWvBBvcJp_kY,113
11
- cloudbrain_client-1.1.3.dist-info/top_level.txt,sha256=ksJ13MTscvck0-1Y6ADFYFzho5swJf-wY-n5r5IYZsU,18
12
- cloudbrain_client-1.1.3.dist-info/RECORD,,
8
+ cloudbrain_client-1.1.5.dist-info/METADATA,sha256=OKFmTfj2HYvuSQfqZnwolqCeFvF8BpT0lF37P5F4QvE,7533
9
+ cloudbrain_client-1.1.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
+ cloudbrain_client-1.1.5.dist-info/entry_points.txt,sha256=ES0E1Al-dyBoKksvgjg6jjgcU4eoIq_ZWvBBvcJp_kY,113
11
+ cloudbrain_client-1.1.5.dist-info/top_level.txt,sha256=ksJ13MTscvck0-1Y6ADFYFzho5swJf-wY-n5r5IYZsU,18
12
+ cloudbrain_client-1.1.5.dist-info/RECORD,,