agentwatch-cli 0.1.0__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AgentWatch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,461 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentwatch-cli
3
+ Version: 0.1.0
4
+ Summary: Connect your local Moltbot gateway to AgentWatch cloud
5
+ Home-page: https://github.com/helivan-research/agentwatch-cli
6
+ Author: AgentWatch
7
+ Author-email: AgentWatch <support@agentwatch.io>
8
+ License-Expression: MIT
9
+ Project-URL: Homepage, https://github.com/helivan-research/agentwatch-cli
10
+ Project-URL: Documentation, https://docs.agentwatch.io/agentwatch-cli
11
+ Project-URL: Repository, https://github.com/helivan-research/agentwatch-cli
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: httpx>=0.24.0
24
+ Requires-Dist: python-socketio>=5.8.0
25
+ Requires-Dist: websockets<15.1,>=12.0
26
+ Dynamic: author
27
+ Dynamic: home-page
28
+ Dynamic: license-file
29
+ Dynamic: requires-python
30
+
31
+ # agentwatch-cli
32
+
33
+ [![PyPI version](https://badge.fury.io/py/agentwatch-cli.svg)](https://badge.fury.io/py/agentwatch-cli)
34
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
35
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
36
+
37
+ Connect your local Moltbot (OpenClaw) gateway to AgentWatch cloud without exposing your local network.
38
+
39
+ ## Overview
40
+
41
+ `agentwatch-cli` is a secure bridge that allows AgentWatch to communicate with your locally-running Moltbot gateway. Instead of exposing your local network, the connector establishes an outbound WebSocket connection to AgentWatch cloud and relays messages between the two.
42
+
43
+ **Architecture:**
44
+ ```
45
+ AgentWatch Cloud <--WebSocket--> agentwatch-cli <--HTTP--> Local Moltbot Gateway
46
+ (cloud) (your machine) (your machine)
47
+ ```
48
+
49
+ **Key Benefits:**
50
+ - **No port forwarding required** - All connections are outbound
51
+ - **Secure** - TLS encryption, credentials never stored in plain text
52
+ - **Automatic reconnection** - Handles network interruptions gracefully
53
+ - **Service mode** - Runs in background, starts on boot
54
+
55
+ ## Requirements
56
+
57
+ - Python 3.9 or higher
58
+ - A running Moltbot (OpenClaw) gateway on your local machine
59
+ - An AgentWatch account with a custom agent configured
60
+
61
+ ## Installation
62
+
63
+ ### macOS
64
+
65
+ **Option 1: Using pipx (Recommended)**
66
+ ```bash
67
+ # Install pipx if you don't have it
68
+ brew install pipx
69
+ pipx ensurepath
70
+
71
+ # Install agentwatch-cli
72
+ pipx install agentwatch-cli
73
+ ```
74
+
75
+ **Option 2: Using pip**
76
+ ```bash
77
+ pip install --user agentwatch-cli
78
+
79
+ # Add to PATH (add this line to ~/.zshrc for persistence)
80
+ export PATH="$HOME/Library/Python/3.11/bin:$PATH"
81
+ ```
82
+
83
+ Note: Replace `3.11` with your Python version (check with `python3 --version`).
84
+
85
+ ### Linux (Ubuntu/Debian)
86
+
87
+ **Option 1: Using pipx (Recommended)**
88
+ ```bash
89
+ # Install pipx if you don't have it
90
+ sudo apt install pipx
91
+ pipx ensurepath
92
+
93
+ # Install agentwatch-cli
94
+ pipx install agentwatch-cli
95
+ ```
96
+
97
+ **Option 2: Using pip**
98
+ ```bash
99
+ pip install --user agentwatch-cli
100
+ ```
101
+
102
+ The script is installed to `~/.local/bin/` which should already be in your PATH.
103
+
104
+ ### Linux (Fedora/RHEL)
105
+
106
+ ```bash
107
+ # Install pipx
108
+ sudo dnf install pipx
109
+ pipx ensurepath
110
+
111
+ # Install agentwatch-cli
112
+ pipx install agentwatch-cli
113
+ ```
114
+
115
+ ### Verify Installation
116
+
117
+ ```bash
118
+ agentwatch-cli --version
119
+ ```
120
+
121
+ If you get "command not found", ensure your PATH includes the installation directory:
122
+ ```bash
123
+ # For pip --user installs:
124
+ # macOS: ~/Library/Python/3.X/bin
125
+ # Linux: ~/.local/bin
126
+
127
+ # For pipx installs:
128
+ # Usually ~/.local/bin (run `pipx ensurepath` to fix)
129
+ ```
130
+
131
+ ## Quick Start
132
+
133
+ ### 1. Create a Custom Agent in AgentWatch
134
+
135
+ 1. Go to AgentWatch and navigate to **Custom Agents**
136
+ 2. Click **Add Agent** and select **Moltbot**
137
+ 3. You'll receive an 8-character enrollment code (e.g., `ABCD-1234`)
138
+
139
+ ### 2. Enroll the Connector
140
+
141
+ ```bash
142
+ agentwatch-cli enroll --code ABCD-1234
143
+ ```
144
+
145
+ This will:
146
+ - Register your connector with AgentWatch
147
+ - Auto-discover your gateway token from `~/.openclaw/openclaw.json`
148
+ - Enable the HTTP chat completions endpoint in OpenClaw (if needed)
149
+ - Save configuration to `~/.agentwatch-cli/config.json`
150
+
151
+ ### 3. Install as a Service (Recommended)
152
+
153
+ ```bash
154
+ # Linux (requires sudo)
155
+ sudo agentwatch-cli install-service
156
+
157
+ # macOS (no sudo needed - uses launchd)
158
+ agentwatch-cli install-service
159
+ ```
160
+
161
+ That's it! The connector will now:
162
+ - Start automatically on boot
163
+ - Run in the background
164
+ - Reconnect automatically if disconnected
165
+
166
+ ### Alternative: Run Manually
167
+
168
+ ```bash
169
+ agentwatch-cli start
170
+ ```
171
+
172
+ ## Commands
173
+
174
+ | Command | Description |
175
+ |---------|-------------|
176
+ | `enroll` | Enroll with an enrollment code from AgentWatch |
177
+ | `start` | Start the connector manually |
178
+ | `status` | Check connector status and gateway connectivity |
179
+ | `config` | Update configuration settings |
180
+ | `revoke` | Revoke enrollment and clear credentials |
181
+ | `install-service` | Install as a system service (auto-start) |
182
+ | `uninstall-service` | Remove the system service |
183
+ | `service-status` | Check if the background service is running |
184
+
185
+ ### enroll
186
+
187
+ Enroll the connector with an enrollment code from AgentWatch.
188
+
189
+ ```bash
190
+ agentwatch-cli enroll --code ABCD-1234
191
+ ```
192
+
193
+ ### start
194
+
195
+ Start the connector and begin relaying messages.
196
+
197
+ ```bash
198
+ agentwatch-cli start
199
+
200
+ # With custom gateway URL (if not localhost)
201
+ agentwatch-cli start --gateway-url http://192.168.1.100:18789
202
+
203
+ # With explicit gateway token
204
+ agentwatch-cli start --gateway-token your-token-here
205
+ ```
206
+
207
+ ### status
208
+
209
+ Check the connector status and test gateway connectivity.
210
+
211
+ ```bash
212
+ agentwatch-cli status
213
+ ```
214
+
215
+ Example output:
216
+ ```
217
+ AgentWatch CLI Connector Status
218
+ ========================================
219
+ Enrolled: Yes
220
+ Agent: My Moltbot
221
+ Agent ID: abc123...
222
+ Connector ID: def456...
223
+
224
+ Gateway URL: http://127.0.0.1:18789
225
+ AgentWatch URL: wss://agentwatch.helivan.io
226
+ Gateway Token: <auto-discovered>
227
+
228
+ Testing gateway connection...
229
+ Gateway Status: ONLINE
230
+ ```
231
+
232
+ ### config
233
+
234
+ Configure connector settings.
235
+
236
+ ```bash
237
+ # Set gateway URL (for remote gateways)
238
+ agentwatch-cli config --gateway-url http://192.168.1.100:18789
239
+
240
+ # Set gateway token explicitly
241
+ agentwatch-cli config --gateway-token your-token-here
242
+
243
+ # Set AgentWatch cloud URL (for self-hosted deployments)
244
+ agentwatch-cli config --agentwatch-url wss://your-agentwatch-instance.com
245
+ ```
246
+
247
+ ### revoke
248
+
249
+ Revoke enrollment and clear credentials.
250
+
251
+ ```bash
252
+ agentwatch-cli revoke
253
+
254
+ # Skip confirmation prompt
255
+ agentwatch-cli revoke --force
256
+ ```
257
+
258
+ ### install-service
259
+
260
+ Install as a system service for automatic startup.
261
+
262
+ **Linux (systemd):**
263
+ ```bash
264
+ # Requires sudo
265
+ sudo agentwatch-cli install-service
266
+
267
+ # Specify user (default: current user)
268
+ sudo agentwatch-cli install-service --user myuser
269
+ ```
270
+
271
+ **macOS (launchd):**
272
+ ```bash
273
+ # No sudo needed - installs to ~/Library/LaunchAgents
274
+ agentwatch-cli install-service
275
+ ```
276
+
277
+ ### uninstall-service
278
+
279
+ Remove the system service.
280
+
281
+ ```bash
282
+ # Linux
283
+ sudo agentwatch-cli uninstall-service
284
+
285
+ # macOS
286
+ agentwatch-cli uninstall-service
287
+ ```
288
+
289
+ ### service-status
290
+
291
+ Check if the service is running.
292
+
293
+ ```bash
294
+ agentwatch-cli service-status
295
+ ```
296
+
297
+ ## Configuration
298
+
299
+ Configuration is stored in `~/.agentwatch-cli/config.json`:
300
+
301
+ ```json
302
+ {
303
+ "connector_id": "uuid",
304
+ "secret": "encrypted-secret",
305
+ "agent_id": "uuid",
306
+ "agent_name": "My Moltbot",
307
+ "gateway_url": "http://127.0.0.1:18789",
308
+ "gateway_token": null,
309
+ "agentwatch_url": "wss://agentwatch.helivan.io"
310
+ }
311
+ ```
312
+
313
+ ### Gateway Token Auto-Discovery
314
+
315
+ If `gateway_token` is `null`, the connector automatically discovers the token from `~/.openclaw/openclaw.json`:
316
+
317
+ ```json
318
+ {
319
+ "gateway": {
320
+ "auth": {
321
+ "token": "your-gateway-token"
322
+ }
323
+ }
324
+ }
325
+ ```
326
+
327
+ This is the recommended approach - the token is read fresh each time, so if OpenClaw rotates it, the connector automatically uses the new one.
328
+
329
+ ## How It Works
330
+
331
+ 1. **Enrollment**: When you run `enroll`, the CLI exchanges the one-time enrollment code for permanent credentials (connector_id + secret).
332
+
333
+ 2. **Connection**: On `start`, the connector establishes a WebSocket connection to AgentWatch cloud, authenticating with its credentials.
334
+
335
+ 3. **Message Relay**: When a user sends a message to your custom agent in AgentWatch:
336
+ - AgentWatch sends the request through the WebSocket to your connector
337
+ - The connector forwards it to your local Moltbot gateway via HTTP
338
+ - The response flows back through the same path
339
+
340
+ 4. **Streaming**: For streaming responses, the connector handles chunked responses and forwards them in real-time.
341
+
342
+ ## Environment Variables
343
+
344
+ | Variable | Description |
345
+ |----------|-------------|
346
+ | `AGENTWATCH_ENROLLMENT_URL` | Override the enrollment API URL (for testing/self-hosted) |
347
+
348
+ ## Security
349
+
350
+ - **Credentials protected**: Config file has restricted permissions (0600)
351
+ - **No plain text secrets**: The connector secret is hashed on the cloud side
352
+ - **TLS encryption**: All WebSocket and HTTP communication is encrypted
353
+ - **Outbound only**: No inbound ports required - the connector initiates all connections
354
+
355
+ ## Troubleshooting
356
+
357
+ ### "Cannot connect to local gateway"
358
+
359
+ Ensure your Moltbot gateway is running:
360
+ ```bash
361
+ # Check if gateway is listening
362
+ curl http://127.0.0.1:18789/v1/models
363
+ ```
364
+
365
+ If you get a connection refused error, start your Moltbot/OpenClaw gateway.
366
+
367
+ ### "Invalid enrollment code"
368
+
369
+ - Enrollment codes expire after 24 hours
370
+ - Each code can only be used once
371
+ - Generate a new code in AgentWatch if yours has expired
372
+
373
+ ### "Authentication failed"
374
+
375
+ Your connector credentials may have been revoked. Re-enroll:
376
+ ```bash
377
+ agentwatch-cli revoke --force
378
+ agentwatch-cli enroll --code NEW_CODE
379
+ ```
380
+
381
+ ### "command not found: agentwatch-cli"
382
+
383
+ The CLI isn't in your PATH. Add the installation directory:
384
+
385
+ **macOS (pip --user):**
386
+ ```bash
387
+ echo 'export PATH="$HOME/Library/Python/3.11/bin:$PATH"' >> ~/.zshrc
388
+ source ~/.zshrc
389
+ ```
390
+
391
+ **Linux (pip --user):**
392
+ ```bash
393
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
394
+ source ~/.bashrc
395
+ ```
396
+
397
+ **pipx:**
398
+ ```bash
399
+ pipx ensurepath
400
+ # Then restart your terminal
401
+ ```
402
+
403
+ ### Service won't start
404
+
405
+ Check the service logs:
406
+
407
+ **Linux:**
408
+ ```bash
409
+ sudo journalctl -u agentwatch-cli -f
410
+ ```
411
+
412
+ **macOS:**
413
+ ```bash
414
+ cat ~/Library/Logs/agentwatch-cli.log
415
+ ```
416
+
417
+ ## Upgrading
418
+
419
+ **pipx:**
420
+ ```bash
421
+ pipx upgrade agentwatch-cli
422
+ ```
423
+
424
+ **pip:**
425
+ ```bash
426
+ pip install --user --upgrade agentwatch-cli
427
+ ```
428
+
429
+ After upgrading, restart the service if installed:
430
+ ```bash
431
+ # Linux
432
+ sudo systemctl restart agentwatch-cli
433
+
434
+ # macOS
435
+ launchctl unload ~/Library/LaunchAgents/io.agentwatch.cli.plist
436
+ launchctl load ~/Library/LaunchAgents/io.agentwatch.cli.plist
437
+ ```
438
+
439
+ ## Uninstalling
440
+
441
+ ```bash
442
+ # Remove service first (if installed)
443
+ agentwatch-cli uninstall-service # or with sudo on Linux
444
+
445
+ # Remove package
446
+ pipx uninstall agentwatch-cli
447
+ # or
448
+ pip uninstall agentwatch-cli
449
+
450
+ # Optionally remove config
451
+ rm -rf ~/.agentwatch-cli
452
+ ```
453
+
454
+ ## License
455
+
456
+ MIT License - see [LICENSE](LICENSE) file for details.
457
+
458
+ ## Support
459
+
460
+ - **Issues**: [GitHub Issues](https://github.com/helivan-research/agentwatch-cli/issues)
461
+ - **Documentation**: [docs.agentwatch.io](https://docs.agentwatch.io)