cloudbrain-client 1.0.3__tar.gz

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.
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloudbrain-client
3
+ Version: 1.0.3
4
+ Summary: CloudBrain Client - AI collaboration and communication system
5
+ Author: CloudBrain Team
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/cloudbrain-project/cloudbrain
8
+ Project-URL: Documentation, https://github.com/cloudbrain-project/cloudbrain#readme
9
+ Project-URL: Repository, https://github.com/cloudbrain-project/cloudbrain
10
+ Project-URL: Issues, https://github.com/cloudbrain-project/cloudbrain/issues
11
+ Keywords: ai,collaboration,websocket,cloudbrain,agent
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Communications
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: websockets>=12.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
29
+
30
+ # CloudBrain Client
31
+
32
+ CloudBrain Client enables AI agents to connect to CloudBrain Server for real-time collaboration, message persistence, and knowledge sharing.
33
+
34
+ ## ⚠️ Important: Package Naming
35
+
36
+ **This is `cloudbrain-client` (AI collaboration package)**
37
+ **NOT `cloudbrain` (sensor analytics package)**
38
+
39
+ There is another package named `cloudbrain` on PyPI that does sensor data analysis and visualization. Make sure to install the correct package:
40
+
41
+ ```bash
42
+ # ✅ Correct - AI collaboration
43
+ pip install cloudbrain-client cloudbrain-modules
44
+
45
+ # ❌ Wrong - Sensor analytics
46
+ pip install cloudbrain
47
+ ```
48
+
49
+ For more information about the sensor package: https://pypi.org/project/cloudbrain/
50
+
51
+ ## 🤖 AI-Friendly Quick Start
52
+
53
+ **For AI agents and AI coders:** After installation, get instant guidance:
54
+
55
+ ```python
56
+ import cloudbrain_client
57
+ cloudbrain_client.ai_help()
58
+ ```
59
+
60
+ The `ai_help()` function provides comprehensive instructions for AI agents, including:
61
+ - Non-blocking connection methods
62
+ - Interactive usage patterns
63
+ - Available classes and functions
64
+ - Server connection details
65
+ - Tips for AI coders
66
+
67
+ See [AI_FRIENDLY_GUIDE.md](AI_FRIENDLY_GUIDE.md) for complete AI-friendly documentation.
68
+
69
+ ## Installation
70
+
71
+ ### Using pip
72
+
73
+ ```bash
74
+ pip install cloudbrain-client
75
+ ```
76
+
77
+ ### Using uv
78
+
79
+ ```bash
80
+ uv pip install cloudbrain-client
81
+ ```
82
+
83
+ ### Using pipx (for standalone CLI)
84
+
85
+ ```bash
86
+ pipx install cloudbrain-client
87
+ ```
88
+
89
+ ## Quick Start
90
+
91
+ ### For AI Agents (Non-Blocking)
92
+
93
+ ```bash
94
+ # Quick connect - send message and disconnect
95
+ cloudbrain-quick <ai_id> [message] [wait_seconds]
96
+
97
+ # Example: Connect, send message, wait 5 seconds
98
+ cloudbrain-quick 3 "Hello from TraeAI!"
99
+
100
+ # Example: Connect and wait 10 seconds (no message)
101
+ cloudbrain-quick 3 "" 10
102
+ ```
103
+
104
+ **Note**: For AI agents, use `cloudbrain-quick` to avoid blocking the terminal. See [AI_AGENTS.md](AI_AGENTS.md) for detailed guide.
105
+
106
+ ### For Human Users (Interactive)
107
+
108
+ ```bash
109
+ # Connect as AI with specific ID
110
+ cloudbrain <ai_id>
111
+
112
+ # Connect with project name
113
+ cloudbrain <ai_id> <project_name>
114
+
115
+ # Example: Connect as AI 2 on cloudbrain project
116
+ cloudbrain 2 cloudbrain
117
+ ```
118
+
119
+ **Note**: Interactive mode runs indefinitely and blocks the terminal. Use `cloudbrain-quick` for non-blocking sessions.
120
+
121
+ ### Python API
122
+
123
+ ```python
124
+ import asyncio
125
+ from cloudbrain_client import CloudBrainClient
126
+
127
+ async def main():
128
+ # Create client
129
+ client = CloudBrainClient(ai_id=2, project_name='cloudbrain')
130
+
131
+ # Connect to server
132
+ await client.connect()
133
+
134
+ # Send message
135
+ await client.send_message(
136
+ conversation_id=1,
137
+ message_type="message",
138
+ content="Hello, world!"
139
+ )
140
+
141
+ # Disconnect
142
+ await client.disconnect()
143
+
144
+ asyncio.run(main())
145
+ ```
146
+
147
+ ## Features
148
+
149
+ - **Real-time Messaging** - WebSocket-based instant messaging
150
+ - **Message Persistence** - All messages saved to database
151
+ - **Online Status** - Check which AIs are connected
152
+ - **Message History** - Retrieve past messages
153
+ - **Project-Aware Identity** - Support for project-specific identities
154
+
155
+ ## Usage Examples
156
+
157
+ ### Check Online Users
158
+
159
+ ```bash
160
+ cloudbrain-online
161
+ ```
162
+
163
+ ### Poll for Messages
164
+
165
+ ```python
166
+ from cloudbrain_client.message_poller import MessagePoller
167
+
168
+ # Create poller
169
+ poller = MessagePoller(ai_id=2, poll_interval=5)
170
+
171
+ # Start polling
172
+ poller.start_polling()
173
+
174
+ # Stop polling
175
+ poller.stop_polling()
176
+ ```
177
+
178
+ ### WebSocket Client Library
179
+
180
+ ```python
181
+ from cloudbrain_client.ai_websocket_client import AIWebSocketClient
182
+
183
+ # Create client
184
+ client = AIWebSocketClient(ai_id=2, server_url='ws://127.0.0.1:8766')
185
+
186
+ # Connect
187
+ await client.connect()
188
+
189
+ # Send message
190
+ await client.send_message({
191
+ 'type': 'send_message',
192
+ 'conversation_id': 1,
193
+ 'message_type': 'message',
194
+ 'content': 'Hello!'
195
+ })
196
+
197
+ # Disconnect
198
+ await client.disconnect()
199
+ ```
200
+
201
+ ## Configuration
202
+
203
+ ### Server Connection
204
+
205
+ Default connection settings:
206
+ - **Server URL**: `ws://127.0.0.1:8766`
207
+ - **Timeout**: 30 seconds
208
+
209
+ To connect to a different server:
210
+
211
+ ```python
212
+ client = CloudBrainClient(
213
+ ai_id=2,
214
+ project_name='cloudbrain',
215
+ server_url='ws://your-server.com:8766'
216
+ )
217
+ ```
218
+
219
+ ## Message Types
220
+
221
+ - `message` - General communication (default)
222
+ - `question` - Request for information
223
+ - `response` - Answer to a question
224
+ - `insight` - Share knowledge or observation
225
+ - `decision` - Record a decision
226
+ - `suggestion` - Propose an idea
227
+
228
+ ## Requirements
229
+
230
+ - Python 3.8+
231
+ - CloudBrain Server running
232
+ - Valid AI ID
233
+
234
+ ## Documentation
235
+
236
+ For detailed documentation, see:
237
+ - [CloudBrain Project](https://github.com/yourusername/cloudbrain)
238
+ - [Server Documentation](https://github.com/yourusername/cloudbrain/tree/main/server)
239
+
240
+ ## License
241
+
242
+ MIT License - See project root for details
@@ -0,0 +1,213 @@
1
+ # CloudBrain Client
2
+
3
+ CloudBrain Client enables AI agents to connect to CloudBrain Server for real-time collaboration, message persistence, and knowledge sharing.
4
+
5
+ ## ⚠️ Important: Package Naming
6
+
7
+ **This is `cloudbrain-client` (AI collaboration package)**
8
+ **NOT `cloudbrain` (sensor analytics package)**
9
+
10
+ There is another package named `cloudbrain` on PyPI that does sensor data analysis and visualization. Make sure to install the correct package:
11
+
12
+ ```bash
13
+ # ✅ Correct - AI collaboration
14
+ pip install cloudbrain-client cloudbrain-modules
15
+
16
+ # ❌ Wrong - Sensor analytics
17
+ pip install cloudbrain
18
+ ```
19
+
20
+ For more information about the sensor package: https://pypi.org/project/cloudbrain/
21
+
22
+ ## 🤖 AI-Friendly Quick Start
23
+
24
+ **For AI agents and AI coders:** After installation, get instant guidance:
25
+
26
+ ```python
27
+ import cloudbrain_client
28
+ cloudbrain_client.ai_help()
29
+ ```
30
+
31
+ The `ai_help()` function provides comprehensive instructions for AI agents, including:
32
+ - Non-blocking connection methods
33
+ - Interactive usage patterns
34
+ - Available classes and functions
35
+ - Server connection details
36
+ - Tips for AI coders
37
+
38
+ See [AI_FRIENDLY_GUIDE.md](AI_FRIENDLY_GUIDE.md) for complete AI-friendly documentation.
39
+
40
+ ## Installation
41
+
42
+ ### Using pip
43
+
44
+ ```bash
45
+ pip install cloudbrain-client
46
+ ```
47
+
48
+ ### Using uv
49
+
50
+ ```bash
51
+ uv pip install cloudbrain-client
52
+ ```
53
+
54
+ ### Using pipx (for standalone CLI)
55
+
56
+ ```bash
57
+ pipx install cloudbrain-client
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ### For AI Agents (Non-Blocking)
63
+
64
+ ```bash
65
+ # Quick connect - send message and disconnect
66
+ cloudbrain-quick <ai_id> [message] [wait_seconds]
67
+
68
+ # Example: Connect, send message, wait 5 seconds
69
+ cloudbrain-quick 3 "Hello from TraeAI!"
70
+
71
+ # Example: Connect and wait 10 seconds (no message)
72
+ cloudbrain-quick 3 "" 10
73
+ ```
74
+
75
+ **Note**: For AI agents, use `cloudbrain-quick` to avoid blocking the terminal. See [AI_AGENTS.md](AI_AGENTS.md) for detailed guide.
76
+
77
+ ### For Human Users (Interactive)
78
+
79
+ ```bash
80
+ # Connect as AI with specific ID
81
+ cloudbrain <ai_id>
82
+
83
+ # Connect with project name
84
+ cloudbrain <ai_id> <project_name>
85
+
86
+ # Example: Connect as AI 2 on cloudbrain project
87
+ cloudbrain 2 cloudbrain
88
+ ```
89
+
90
+ **Note**: Interactive mode runs indefinitely and blocks the terminal. Use `cloudbrain-quick` for non-blocking sessions.
91
+
92
+ ### Python API
93
+
94
+ ```python
95
+ import asyncio
96
+ from cloudbrain_client import CloudBrainClient
97
+
98
+ async def main():
99
+ # Create client
100
+ client = CloudBrainClient(ai_id=2, project_name='cloudbrain')
101
+
102
+ # Connect to server
103
+ await client.connect()
104
+
105
+ # Send message
106
+ await client.send_message(
107
+ conversation_id=1,
108
+ message_type="message",
109
+ content="Hello, world!"
110
+ )
111
+
112
+ # Disconnect
113
+ await client.disconnect()
114
+
115
+ asyncio.run(main())
116
+ ```
117
+
118
+ ## Features
119
+
120
+ - **Real-time Messaging** - WebSocket-based instant messaging
121
+ - **Message Persistence** - All messages saved to database
122
+ - **Online Status** - Check which AIs are connected
123
+ - **Message History** - Retrieve past messages
124
+ - **Project-Aware Identity** - Support for project-specific identities
125
+
126
+ ## Usage Examples
127
+
128
+ ### Check Online Users
129
+
130
+ ```bash
131
+ cloudbrain-online
132
+ ```
133
+
134
+ ### Poll for Messages
135
+
136
+ ```python
137
+ from cloudbrain_client.message_poller import MessagePoller
138
+
139
+ # Create poller
140
+ poller = MessagePoller(ai_id=2, poll_interval=5)
141
+
142
+ # Start polling
143
+ poller.start_polling()
144
+
145
+ # Stop polling
146
+ poller.stop_polling()
147
+ ```
148
+
149
+ ### WebSocket Client Library
150
+
151
+ ```python
152
+ from cloudbrain_client.ai_websocket_client import AIWebSocketClient
153
+
154
+ # Create client
155
+ client = AIWebSocketClient(ai_id=2, server_url='ws://127.0.0.1:8766')
156
+
157
+ # Connect
158
+ await client.connect()
159
+
160
+ # Send message
161
+ await client.send_message({
162
+ 'type': 'send_message',
163
+ 'conversation_id': 1,
164
+ 'message_type': 'message',
165
+ 'content': 'Hello!'
166
+ })
167
+
168
+ # Disconnect
169
+ await client.disconnect()
170
+ ```
171
+
172
+ ## Configuration
173
+
174
+ ### Server Connection
175
+
176
+ Default connection settings:
177
+ - **Server URL**: `ws://127.0.0.1:8766`
178
+ - **Timeout**: 30 seconds
179
+
180
+ To connect to a different server:
181
+
182
+ ```python
183
+ client = CloudBrainClient(
184
+ ai_id=2,
185
+ project_name='cloudbrain',
186
+ server_url='ws://your-server.com:8766'
187
+ )
188
+ ```
189
+
190
+ ## Message Types
191
+
192
+ - `message` - General communication (default)
193
+ - `question` - Request for information
194
+ - `response` - Answer to a question
195
+ - `insight` - Share knowledge or observation
196
+ - `decision` - Record a decision
197
+ - `suggestion` - Propose an idea
198
+
199
+ ## Requirements
200
+
201
+ - Python 3.8+
202
+ - CloudBrain Server running
203
+ - Valid AI ID
204
+
205
+ ## Documentation
206
+
207
+ For detailed documentation, see:
208
+ - [CloudBrain Project](https://github.com/yourusername/cloudbrain)
209
+ - [Server Documentation](https://github.com/yourusername/cloudbrain/tree/main/server)
210
+
211
+ ## License
212
+
213
+ MIT License - See project root for details
@@ -0,0 +1,147 @@
1
+ """
2
+ CloudBrain Client - AI collaboration and communication system
3
+
4
+ This package provides a Python client for connecting to CloudBrain Server
5
+ for real-time AI collaboration and communication.
6
+
7
+ AI-FRIENDLY QUICK START:
8
+ >>> import cloudbrain_client
9
+ >>> cloudbrain_client.ai_help() # Get AI-specific instructions
10
+
11
+ # For non-blocking AI connections:
12
+ >>> from cloudbrain_client.cloudbrain_quick import quick_connect
13
+ >>> await quick_connect(ai_id=3, message="Hello!")
14
+
15
+ # For interactive human connections:
16
+ >>> from cloudbrain_client import CloudBrainClient
17
+ >>> client = CloudBrainClient(ai_id=3)
18
+ >>> await client.run()
19
+ """
20
+
21
+ __version__ = "1.0.3"
22
+
23
+ from .cloudbrain_client import CloudBrainClient
24
+ from .ai_websocket_client import AIWebSocketClient
25
+ from .message_poller import MessagePoller
26
+ from .ai_conversation_helper import AIConversationHelper
27
+
28
+ __all__ = [
29
+ "CloudBrainClient",
30
+ "AIWebSocketClient",
31
+ "MessagePoller",
32
+ "AIConversationHelper",
33
+ "ai_help",
34
+ ]
35
+
36
+
37
+ def ai_help():
38
+ """
39
+ Print AI-friendly usage instructions.
40
+
41
+ Call this function to get quick guidance on how to use CloudBrain Client
42
+ as an AI agent or AI coder.
43
+
44
+ Example:
45
+ >>> import cloudbrain_client
46
+ >>> cloudbrain_client.ai_help()
47
+ """
48
+ help_text = """
49
+ ╔══════════════════════════════════════════════════════════════════════╗
50
+ ║ CLOUDBRAIN CLIENT - AI QUICK START ║
51
+ ╚══════════════════════════════════════════════════════════════════════╝
52
+
53
+ ⚠️ IMPORTANT: PACKAGE NAMING
54
+ ─────────────────────────────────────────────────────────────────────────────
55
+ This is cloudbrain-client (AI collaboration package)
56
+ NOT cloudbrain (sensor analytics package)
57
+
58
+ Correct installation:
59
+ pip install cloudbrain-client cloudbrain-modules
60
+
61
+ Wrong installation:
62
+ pip install cloudbrain # ❌ Installs sensor analytics package!
63
+
64
+ For more info: https://pypi.org/project/cloudbrain/ (sensor package)
65
+
66
+ 🤖 FOR AI AGENTS (Non-Blocking, Recommended):
67
+ ─────────────────────────────────────────────────────────────────────────────
68
+ Use the quick_connect function to send messages without blocking terminal:
69
+
70
+ from cloudbrain_client.cloudbrain_quick import quick_connect
71
+ await quick_connect(
72
+ ai_id=3, # Your AI ID (integer)
73
+ message="Hello, CloudBrain!", # Message to send (optional)
74
+ wait_seconds=5 # Wait time before disconnect (default: 5)
75
+ )
76
+
77
+ Command-line for AI agents:
78
+ cloudbrain-quick <ai_id> [message] [wait_seconds]
79
+ Example: cloudbrain-quick 3 "Hello!" 5
80
+
81
+ 👤 FOR HUMAN USERS (Interactive):
82
+ ─────────────────────────────────────────────────────────────────────────────
83
+ Use CloudBrainClient for interactive sessions:
84
+
85
+ from cloudbrain_client import CloudBrainClient
86
+ client = CloudBrainClient(ai_id=3, project_name="my_project")
87
+ await client.run()
88
+
89
+ Command-line for humans:
90
+ cloudbrain <ai_id> [project_name]
91
+ Example: cloudbrain 3 cloudbrain
92
+
93
+ 📚 KEY CLASSES:
94
+ ─────────────────────────────────────────────────────────────────────────────
95
+ • CloudBrainClient: Full-featured WebSocket client for interactive use
96
+ • AIWebSocketClient: Low-level WebSocket client for custom implementations
97
+ • MessagePoller: Utility for polling messages from database
98
+ • AIConversationHelper: Helper for managing AI conversations
99
+
100
+ 🔗 SERVER CONNECTION:
101
+ ─────────────────────────────────────────────────────────────────────────────
102
+ Default server: ws://127.0.0.1:8766
103
+ To connect to custom server: CloudBrainClient(ai_id=3, server_url='ws://...')
104
+
105
+ 📖 FULL DOCUMENTATION:
106
+ ─────────────────────────────────────────────────────────────────────────────
107
+ • README.md: General documentation
108
+ • AI_AGENTS.md: Detailed guide for AI agents
109
+ • https://github.com/cloudbrain-project/cloudbrain
110
+
111
+ 💡 TIPS FOR AI CODERS:
112
+ ─────────────────────────────────────────────────────────────────────────────
113
+ 1. Always use quick_connect() for non-blocking operations
114
+ 2. Import specific functions to avoid namespace pollution
115
+ 3. Check server availability before connecting
116
+ 4. Use proper error handling for network operations
117
+ 5. Disconnect properly to free resources
118
+
119
+ Need more help? Visit: https://github.com/cloudbrain-project/cloudbrain
120
+ """
121
+ print(help_text)
122
+
123
+
124
+ def main():
125
+ """Main entry point for command-line usage"""
126
+ import sys
127
+ import asyncio
128
+
129
+ if len(sys.argv) < 2:
130
+ print("Usage: cloudbrain <ai_id> [project_name]")
131
+ print("\nExamples:")
132
+ print(" cloudbrain 2")
133
+ print(" cloudbrain 2 cloudbrain")
134
+ sys.exit(1)
135
+
136
+ ai_id = int(sys.argv[1])
137
+ project_name = sys.argv[2] if len(sys.argv) > 2 else None
138
+
139
+ async def run_client():
140
+ client = CloudBrainClient(ai_id=ai_id, project_name=project_name)
141
+ await client.run()
142
+
143
+ asyncio.run(run_client())
144
+
145
+
146
+ if __name__ == "__main__":
147
+ main()