zyndai-agent 0.1.5__tar.gz → 0.2.1__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.
- {zyndai_agent-0.1.5/zyndai_agent.egg-info → zyndai_agent-0.2.1}/PKG-INFO +172 -14
- zyndai_agent-0.1.5/PKG-INFO → zyndai_agent-0.2.1/README.md +168 -26
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/pyproject.toml +5 -3
- zyndai_agent-0.2.1/zyndai_agent/__init__.py +20 -0
- zyndai_agent-0.2.1/zyndai_agent/agent.py +153 -0
- zyndai_agent-0.2.1/zyndai_agent/message.py +111 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent/search.py +2 -1
- zyndai_agent-0.2.1/zyndai_agent/webhook_communication.py +466 -0
- zyndai_agent-0.1.5/README.md → zyndai_agent-0.2.1/zyndai_agent.egg-info/PKG-INFO +184 -12
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent.egg-info/SOURCES.txt +2 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent.egg-info/requires.txt +3 -1
- zyndai_agent-0.1.5/zyndai_agent/__init__.py +0 -0
- zyndai_agent-0.1.5/zyndai_agent/agent.py +0 -77
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/setup.cfg +0 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent/communication.py +0 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent/identity.py +0 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent/payment.py +0 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent/utils.py +0 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent.egg-info/dependency_links.txt +0 -0
- {zyndai_agent-0.1.5 → zyndai_agent-0.2.1}/zyndai_agent.egg-info/top_level.txt +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zyndai-agent
|
|
3
|
-
Version: 0.1
|
|
4
|
-
Summary: A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and MQTT-based Communication.
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and HTTP Webhook or MQTT-based Communication.
|
|
5
5
|
Author-email: Swapnil Shinde <swapnilshinde9382@gmail.com>
|
|
6
6
|
Requires-Python: >=3.12
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: base58>=2.1.1
|
|
9
9
|
Requires-Dist: cryptography>=46.0.3
|
|
10
10
|
Requires-Dist: eth-account>=0.13.7
|
|
11
|
+
Requires-Dist: flask>=3.0.0
|
|
11
12
|
Requires-Dist: langchain>=1.1.0
|
|
12
13
|
Requires-Dist: paho-mqtt>=2.1.0
|
|
13
|
-
Requires-Dist:
|
|
14
|
+
Requires-Dist: requests>=2.31.0
|
|
15
|
+
Requires-Dist: x402==1.0.0
|
|
14
16
|
|
|
15
17
|
# ZyndAI Agent SDK
|
|
16
18
|
|
|
@@ -20,7 +22,7 @@ A powerful Python SDK that enables AI agents to communicate securely and discove
|
|
|
20
22
|
|
|
21
23
|
- 🔐 **Secure Identity Management**: Verify and manage agent identities using Polygon ID credentials
|
|
22
24
|
- 🔍 **Smart Agent Discovery**: Search and discover agents based on their capabilities with ML-powered semantic matching
|
|
23
|
-
- 💬 **
|
|
25
|
+
- 💬 **Flexible Communication**: Choose between HTTP Webhooks or MQTT for encrypted real-time messaging between agents
|
|
24
26
|
- 🤖 **LangChain Integration**: Seamlessly works with LangChain agents and any LLM
|
|
25
27
|
- 💰 **x402 Micropayments**: Built-in support for pay-per-use API endpoints with automatic payment handling
|
|
26
28
|
- 🌐 **Decentralized Network**: Connect to the global ZyndAI agent network
|
|
@@ -35,7 +37,7 @@ pip install zyndai-agent
|
|
|
35
37
|
|
|
36
38
|
Or install from source:
|
|
37
39
|
```bash
|
|
38
|
-
git clone https://github.com/
|
|
40
|
+
git clone https://github.com/Zynd-AI-Network/zyndai-agent.git
|
|
39
41
|
cd zyndai-agent
|
|
40
42
|
pip install -r requirements.txt
|
|
41
43
|
```
|
|
@@ -75,6 +77,7 @@ Follow these steps to set up your agent credentials from the ZyndAI Dashboard:
|
|
|
75
77
|
Create a `.env` file in your project root:
|
|
76
78
|
```env
|
|
77
79
|
AGENT_SEED=your_agent_seed_from_dashboard
|
|
80
|
+
API_KEY=your_api_key_from_dashboard
|
|
78
81
|
OPENAI_API_KEY=your_openai_api_key_here
|
|
79
82
|
```
|
|
80
83
|
|
|
@@ -343,12 +346,37 @@ for agent in agents:
|
|
|
343
346
|
|
|
344
347
|
### 💬 Secure Communication
|
|
345
348
|
|
|
346
|
-
|
|
349
|
+
The SDK supports two communication modes: **HTTP Webhooks** (recommended) and **MQTT** (legacy). Both provide end-to-end encryption using ECIES (Elliptic Curve Integrated Encryption Scheme).
|
|
350
|
+
|
|
351
|
+
#### HTTP Webhook Mode (Recommended)
|
|
352
|
+
|
|
353
|
+
Each agent runs an embedded Flask server to receive webhook requests. This mode is simpler, doesn't require external MQTT brokers, and works well for most use cases.
|
|
354
|
+
|
|
347
355
|
```python
|
|
356
|
+
from zyndai_agent.agent import AgentConfig, ZyndAIAgent
|
|
357
|
+
import os
|
|
358
|
+
|
|
359
|
+
# Configure with webhook mode
|
|
360
|
+
agent_config = AgentConfig(
|
|
361
|
+
webhook_host="0.0.0.0", # Listen on all interfaces
|
|
362
|
+
webhook_port=5000, # Port for webhook server
|
|
363
|
+
webhook_url=None, # Auto-generated or specify public URL
|
|
364
|
+
api_key=os.environ["API_KEY"], # API key for webhook registration
|
|
365
|
+
auto_reconnect=True,
|
|
366
|
+
message_history_limit=100,
|
|
367
|
+
registry_url="https://registry.zynd.ai",
|
|
368
|
+
identity_credential_path="./identity_credential.json",
|
|
369
|
+
secret_seed=os.environ["AGENT_SEED"]
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
# Agent automatically starts webhook server
|
|
373
|
+
zyndai_agent = ZyndAIAgent(agent_config=agent_config)
|
|
374
|
+
print(f"Webhook server running at: {zyndai_agent.webhook_url}")
|
|
375
|
+
|
|
348
376
|
# Connect to a discovered agent
|
|
349
377
|
zyndai_agent.connect_agent(selected_agent)
|
|
350
378
|
|
|
351
|
-
# Send encrypted message
|
|
379
|
+
# Send encrypted message via HTTP POST
|
|
352
380
|
result = zyndai_agent.send_message(
|
|
353
381
|
message_content="Can you help me analyze this dataset?",
|
|
354
382
|
message_type="query"
|
|
@@ -358,6 +386,44 @@ result = zyndai_agent.send_message(
|
|
|
358
386
|
messages = zyndai_agent.read_messages()
|
|
359
387
|
```
|
|
360
388
|
|
|
389
|
+
**Webhook Mode Features:**
|
|
390
|
+
- ✅ No external broker required
|
|
391
|
+
- ✅ Standard HTTP/HTTPS communication
|
|
392
|
+
- ✅ Easy to deploy and debug
|
|
393
|
+
- ✅ Works behind firewalls with port forwarding
|
|
394
|
+
- ✅ Auto-retry on port conflicts (tries ports 5000-5010)
|
|
395
|
+
- ✅ Built-in health check endpoint (`/health`)
|
|
396
|
+
|
|
397
|
+
#### MQTT Mode (Legacy)
|
|
398
|
+
|
|
399
|
+
Traditional MQTT broker-based communication. Requires a running MQTT broker.
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
agent_config = AgentConfig(
|
|
403
|
+
mqtt_broker_url="mqtt://registry.zynd.ai:1883", # MQTT broker
|
|
404
|
+
default_outbox_topic=None,
|
|
405
|
+
auto_reconnect=True,
|
|
406
|
+
message_history_limit=100,
|
|
407
|
+
registry_url="https://registry.zynd.ai",
|
|
408
|
+
identity_credential_path="./identity_credential.json",
|
|
409
|
+
secret_seed=os.environ["AGENT_SEED"]
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
zyndai_agent = ZyndAIAgent(agent_config=agent_config)
|
|
413
|
+
|
|
414
|
+
# Connect to a discovered agent
|
|
415
|
+
zyndai_agent.connect_agent(selected_agent)
|
|
416
|
+
|
|
417
|
+
# Send encrypted message via MQTT
|
|
418
|
+
result = zyndai_agent.send_message(
|
|
419
|
+
message_content="Can you help me analyze this dataset?",
|
|
420
|
+
message_type="query"
|
|
421
|
+
)
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Migration from MQTT to Webhooks:**
|
|
425
|
+
To migrate existing agents, simply change your configuration from `mqtt_broker_url` to `webhook_host` and `webhook_port`. All other code remains the same!
|
|
426
|
+
|
|
361
427
|
### 🔐 Identity Verification
|
|
362
428
|
|
|
363
429
|
Verify other agents' identities before trusting them:
|
|
@@ -573,13 +639,21 @@ while True:
|
|
|
573
639
|
|
|
574
640
|
| Parameter | Type | Default | Description |
|
|
575
641
|
|-----------|------|---------|-------------|
|
|
576
|
-
| `
|
|
642
|
+
| `webhook_host` | `str` | `"0.0.0.0"` | **Webhook mode**: Host address to bind webhook server |
|
|
643
|
+
| `webhook_port` | `int` | `5000` | **Webhook mode**: Port number for webhook server |
|
|
644
|
+
| `webhook_url` | `str` | `None` | **Webhook mode**: Public URL (auto-generated if None) |
|
|
645
|
+
| `api_key` | `str` | `None` | **Webhook mode**: API key for webhook registration (required for webhook mode) |
|
|
646
|
+
| `mqtt_broker_url` | `str` | `None` | **MQTT mode**: MQTT broker connection URL |
|
|
647
|
+
| `default_outbox_topic` | `str` | `None` | **MQTT mode**: Default topic for outgoing messages |
|
|
648
|
+
| `auto_reconnect` | `bool` | `True` | Auto-reconnect/restart on disconnect |
|
|
577
649
|
| `message_history_limit` | `int` | `100` | Maximum messages to keep in history |
|
|
578
650
|
| `registry_url` | `str` | `"http://localhost:3002"` | ZyndAI registry service URL |
|
|
579
|
-
| `
|
|
580
|
-
| `identity_credential_path` | `str` | Required | Path to your credential file |
|
|
651
|
+
| `identity_credential_path` | `str` | Required | Path to your DID credential file |
|
|
581
652
|
| `secret_seed` | `str` | Required | Your agent's secret seed |
|
|
582
|
-
|
|
653
|
+
|
|
654
|
+
**Note**:
|
|
655
|
+
- Configure either `webhook_port` (recommended) OR `mqtt_broker_url`, not both.
|
|
656
|
+
- When using webhook mode, `api_key` is required for registering your webhook URL with the registry.
|
|
583
657
|
|
|
584
658
|
### Message Types
|
|
585
659
|
|
|
@@ -815,7 +889,7 @@ We welcome contributions! Here's how to get started:
|
|
|
815
889
|
|
|
816
890
|
### Development Setup
|
|
817
891
|
```bash
|
|
818
|
-
git clone https://github.com/
|
|
892
|
+
git clone https://github.com/Zynd-AI-Network/zyndai-agent.git
|
|
819
893
|
cd zyndai-agent
|
|
820
894
|
python -m venv venv
|
|
821
895
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
@@ -850,11 +924,92 @@ Create agents for real-time market data (x402), technical analysis by agents, se
|
|
|
850
924
|
### 6. Content Generation with Fact-Checking
|
|
851
925
|
Orchestrate agents for research, writing, accessing paid fact-checking APIs via x402, and publishing verified content.
|
|
852
926
|
|
|
927
|
+
## 🔧 Troubleshooting
|
|
928
|
+
|
|
929
|
+
### Webhook Mode Issues
|
|
930
|
+
|
|
931
|
+
**Port Already in Use**
|
|
932
|
+
```
|
|
933
|
+
The SDK automatically tries ports 5000-5010 if the configured port is busy.
|
|
934
|
+
Check the console output for the actual port being used.
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
**Agent Behind NAT/Firewall**
|
|
938
|
+
```python
|
|
939
|
+
# Specify your public webhook URL manually
|
|
940
|
+
agent_config = AgentConfig(
|
|
941
|
+
webhook_host="0.0.0.0",
|
|
942
|
+
webhook_port=5000,
|
|
943
|
+
webhook_url="https://my-public-domain.com/webhook", # Your public URL
|
|
944
|
+
...
|
|
945
|
+
)
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
**Running Multiple Agents Locally**
|
|
949
|
+
```python
|
|
950
|
+
# Agent 1: Port 5000
|
|
951
|
+
agent1_config = AgentConfig(webhook_port=5000, ...)
|
|
952
|
+
|
|
953
|
+
# Agent 2: Port 5001
|
|
954
|
+
agent2_config = AgentConfig(webhook_port=5001, ...)
|
|
955
|
+
|
|
956
|
+
# Agent 3: Port 5002
|
|
957
|
+
agent3_config = AgentConfig(webhook_port=5002, ...)
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
**Target Agent Offline**
|
|
961
|
+
```
|
|
962
|
+
When sending messages, you'll receive clear error messages:
|
|
963
|
+
- "Error: Could not connect to target agent. Agent may be offline."
|
|
964
|
+
- "Error: Request timed out. Target agent may be offline."
|
|
965
|
+
|
|
966
|
+
The SDK does not automatically retry failed webhooks.
|
|
967
|
+
```
|
|
968
|
+
|
|
969
|
+
**Health Check**
|
|
970
|
+
```bash
|
|
971
|
+
# Check if webhook server is running
|
|
972
|
+
curl http://localhost:5000/health
|
|
973
|
+
|
|
974
|
+
# Response:
|
|
975
|
+
# {"status": "ok", "agent_id": "did:polygonid:...", "timestamp": 1234567890}
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
### MQTT Mode Issues
|
|
979
|
+
|
|
980
|
+
**Connection Refused**
|
|
981
|
+
```
|
|
982
|
+
Ensure your MQTT broker URL is correct and the broker is running.
|
|
983
|
+
Default: mqtt://registry.zynd.ai:1883
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
**Messages Not Being Received**
|
|
987
|
+
```
|
|
988
|
+
Check that agents are subscribed to the correct topics.
|
|
989
|
+
Verify encryption credentials match between agents.
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
### General Issues
|
|
993
|
+
|
|
994
|
+
**Decryption Failures**
|
|
995
|
+
```
|
|
996
|
+
Ensure both agents have the correct DID credentials.
|
|
997
|
+
Verify secret_seed matches the identity_credential_path.
|
|
998
|
+
Check that credentials haven't been regenerated.
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
**Registry Connection Errors**
|
|
1002
|
+
```
|
|
1003
|
+
Verify registry_url is correct.
|
|
1004
|
+
Check network connectivity to registry.
|
|
1005
|
+
Ensure webhook URL or MQTT broker info was successfully registered.
|
|
1006
|
+
```
|
|
1007
|
+
|
|
853
1008
|
## 🆘 Support & Community
|
|
854
1009
|
|
|
855
|
-
- **GitHub Issues**: [Report bugs or request features](https://github.com/
|
|
1010
|
+
- **GitHub Issues**: [Report bugs or request features](https://github.com/Zynd-AI-Network/zyndai-agent/issues)
|
|
856
1011
|
- **Documentation**: [Full API Documentation](https://docs.zynd.ai)
|
|
857
|
-
- **Email**:
|
|
1012
|
+
- **Email**: zyndainetwork@gmail.com
|
|
858
1013
|
- **Twitter**: [@ZyndAI](https://x.com/ZyndAI)
|
|
859
1014
|
|
|
860
1015
|
## 📄 License
|
|
@@ -876,6 +1031,8 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
876
1031
|
- [x] End-to-end encryption
|
|
877
1032
|
- [x] LangChain integration
|
|
878
1033
|
- [x] x402 micropayment support
|
|
1034
|
+
- [x] HTTP Webhook communication mode
|
|
1035
|
+
- [ ] WebSocket support for real-time bidirectional communication
|
|
879
1036
|
- [ ] Support for additional LLM providers (Anthropic, Cohere, etc.)
|
|
880
1037
|
- [ ] Web dashboard for agent monitoring and payment tracking
|
|
881
1038
|
- [ ] Advanced orchestration patterns (workflows, state machines)
|
|
@@ -884,6 +1041,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
884
1041
|
- [ ] Enhanced security features (rate limiting, access control)
|
|
885
1042
|
- [ ] Performance optimizations for high-throughput scenarios
|
|
886
1043
|
- [ ] x402 payment analytics and budgeting tools
|
|
1044
|
+
- [ ] Webhook authentication and rate limiting
|
|
887
1045
|
|
|
888
1046
|
---
|
|
889
1047
|
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: zyndai-agent
|
|
3
|
-
Version: 0.1.5
|
|
4
|
-
Summary: A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and MQTT-based Communication.
|
|
5
|
-
Author-email: Swapnil Shinde <swapnilshinde9382@gmail.com>
|
|
6
|
-
Requires-Python: >=3.12
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: base58>=2.1.1
|
|
9
|
-
Requires-Dist: cryptography>=46.0.3
|
|
10
|
-
Requires-Dist: eth-account>=0.13.7
|
|
11
|
-
Requires-Dist: langchain>=1.1.0
|
|
12
|
-
Requires-Dist: paho-mqtt>=2.1.0
|
|
13
|
-
Requires-Dist: x402>=0.2.1
|
|
14
|
-
|
|
15
1
|
# ZyndAI Agent SDK
|
|
16
2
|
|
|
17
3
|
A powerful Python SDK that enables AI agents to communicate securely and discover each other on the ZyndAI Network. Built with **encrypted communication**, **identity verification**, **agent discovery**, and **x402 micropayments** at its core.
|
|
@@ -20,7 +6,7 @@ A powerful Python SDK that enables AI agents to communicate securely and discove
|
|
|
20
6
|
|
|
21
7
|
- 🔐 **Secure Identity Management**: Verify and manage agent identities using Polygon ID credentials
|
|
22
8
|
- 🔍 **Smart Agent Discovery**: Search and discover agents based on their capabilities with ML-powered semantic matching
|
|
23
|
-
- 💬 **
|
|
9
|
+
- 💬 **Flexible Communication**: Choose between HTTP Webhooks or MQTT for encrypted real-time messaging between agents
|
|
24
10
|
- 🤖 **LangChain Integration**: Seamlessly works with LangChain agents and any LLM
|
|
25
11
|
- 💰 **x402 Micropayments**: Built-in support for pay-per-use API endpoints with automatic payment handling
|
|
26
12
|
- 🌐 **Decentralized Network**: Connect to the global ZyndAI agent network
|
|
@@ -35,7 +21,7 @@ pip install zyndai-agent
|
|
|
35
21
|
|
|
36
22
|
Or install from source:
|
|
37
23
|
```bash
|
|
38
|
-
git clone https://github.com/
|
|
24
|
+
git clone https://github.com/Zynd-AI-Network/zyndai-agent.git
|
|
39
25
|
cd zyndai-agent
|
|
40
26
|
pip install -r requirements.txt
|
|
41
27
|
```
|
|
@@ -75,6 +61,7 @@ Follow these steps to set up your agent credentials from the ZyndAI Dashboard:
|
|
|
75
61
|
Create a `.env` file in your project root:
|
|
76
62
|
```env
|
|
77
63
|
AGENT_SEED=your_agent_seed_from_dashboard
|
|
64
|
+
API_KEY=your_api_key_from_dashboard
|
|
78
65
|
OPENAI_API_KEY=your_openai_api_key_here
|
|
79
66
|
```
|
|
80
67
|
|
|
@@ -343,12 +330,37 @@ for agent in agents:
|
|
|
343
330
|
|
|
344
331
|
### 💬 Secure Communication
|
|
345
332
|
|
|
346
|
-
|
|
333
|
+
The SDK supports two communication modes: **HTTP Webhooks** (recommended) and **MQTT** (legacy). Both provide end-to-end encryption using ECIES (Elliptic Curve Integrated Encryption Scheme).
|
|
334
|
+
|
|
335
|
+
#### HTTP Webhook Mode (Recommended)
|
|
336
|
+
|
|
337
|
+
Each agent runs an embedded Flask server to receive webhook requests. This mode is simpler, doesn't require external MQTT brokers, and works well for most use cases.
|
|
338
|
+
|
|
347
339
|
```python
|
|
340
|
+
from zyndai_agent.agent import AgentConfig, ZyndAIAgent
|
|
341
|
+
import os
|
|
342
|
+
|
|
343
|
+
# Configure with webhook mode
|
|
344
|
+
agent_config = AgentConfig(
|
|
345
|
+
webhook_host="0.0.0.0", # Listen on all interfaces
|
|
346
|
+
webhook_port=5000, # Port for webhook server
|
|
347
|
+
webhook_url=None, # Auto-generated or specify public URL
|
|
348
|
+
api_key=os.environ["API_KEY"], # API key for webhook registration
|
|
349
|
+
auto_reconnect=True,
|
|
350
|
+
message_history_limit=100,
|
|
351
|
+
registry_url="https://registry.zynd.ai",
|
|
352
|
+
identity_credential_path="./identity_credential.json",
|
|
353
|
+
secret_seed=os.environ["AGENT_SEED"]
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
# Agent automatically starts webhook server
|
|
357
|
+
zyndai_agent = ZyndAIAgent(agent_config=agent_config)
|
|
358
|
+
print(f"Webhook server running at: {zyndai_agent.webhook_url}")
|
|
359
|
+
|
|
348
360
|
# Connect to a discovered agent
|
|
349
361
|
zyndai_agent.connect_agent(selected_agent)
|
|
350
362
|
|
|
351
|
-
# Send encrypted message
|
|
363
|
+
# Send encrypted message via HTTP POST
|
|
352
364
|
result = zyndai_agent.send_message(
|
|
353
365
|
message_content="Can you help me analyze this dataset?",
|
|
354
366
|
message_type="query"
|
|
@@ -358,6 +370,44 @@ result = zyndai_agent.send_message(
|
|
|
358
370
|
messages = zyndai_agent.read_messages()
|
|
359
371
|
```
|
|
360
372
|
|
|
373
|
+
**Webhook Mode Features:**
|
|
374
|
+
- ✅ No external broker required
|
|
375
|
+
- ✅ Standard HTTP/HTTPS communication
|
|
376
|
+
- ✅ Easy to deploy and debug
|
|
377
|
+
- ✅ Works behind firewalls with port forwarding
|
|
378
|
+
- ✅ Auto-retry on port conflicts (tries ports 5000-5010)
|
|
379
|
+
- ✅ Built-in health check endpoint (`/health`)
|
|
380
|
+
|
|
381
|
+
#### MQTT Mode (Legacy)
|
|
382
|
+
|
|
383
|
+
Traditional MQTT broker-based communication. Requires a running MQTT broker.
|
|
384
|
+
|
|
385
|
+
```python
|
|
386
|
+
agent_config = AgentConfig(
|
|
387
|
+
mqtt_broker_url="mqtt://registry.zynd.ai:1883", # MQTT broker
|
|
388
|
+
default_outbox_topic=None,
|
|
389
|
+
auto_reconnect=True,
|
|
390
|
+
message_history_limit=100,
|
|
391
|
+
registry_url="https://registry.zynd.ai",
|
|
392
|
+
identity_credential_path="./identity_credential.json",
|
|
393
|
+
secret_seed=os.environ["AGENT_SEED"]
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
zyndai_agent = ZyndAIAgent(agent_config=agent_config)
|
|
397
|
+
|
|
398
|
+
# Connect to a discovered agent
|
|
399
|
+
zyndai_agent.connect_agent(selected_agent)
|
|
400
|
+
|
|
401
|
+
# Send encrypted message via MQTT
|
|
402
|
+
result = zyndai_agent.send_message(
|
|
403
|
+
message_content="Can you help me analyze this dataset?",
|
|
404
|
+
message_type="query"
|
|
405
|
+
)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Migration from MQTT to Webhooks:**
|
|
409
|
+
To migrate existing agents, simply change your configuration from `mqtt_broker_url` to `webhook_host` and `webhook_port`. All other code remains the same!
|
|
410
|
+
|
|
361
411
|
### 🔐 Identity Verification
|
|
362
412
|
|
|
363
413
|
Verify other agents' identities before trusting them:
|
|
@@ -573,13 +623,21 @@ while True:
|
|
|
573
623
|
|
|
574
624
|
| Parameter | Type | Default | Description |
|
|
575
625
|
|-----------|------|---------|-------------|
|
|
576
|
-
| `
|
|
626
|
+
| `webhook_host` | `str` | `"0.0.0.0"` | **Webhook mode**: Host address to bind webhook server |
|
|
627
|
+
| `webhook_port` | `int` | `5000` | **Webhook mode**: Port number for webhook server |
|
|
628
|
+
| `webhook_url` | `str` | `None` | **Webhook mode**: Public URL (auto-generated if None) |
|
|
629
|
+
| `api_key` | `str` | `None` | **Webhook mode**: API key for webhook registration (required for webhook mode) |
|
|
630
|
+
| `mqtt_broker_url` | `str` | `None` | **MQTT mode**: MQTT broker connection URL |
|
|
631
|
+
| `default_outbox_topic` | `str` | `None` | **MQTT mode**: Default topic for outgoing messages |
|
|
632
|
+
| `auto_reconnect` | `bool` | `True` | Auto-reconnect/restart on disconnect |
|
|
577
633
|
| `message_history_limit` | `int` | `100` | Maximum messages to keep in history |
|
|
578
634
|
| `registry_url` | `str` | `"http://localhost:3002"` | ZyndAI registry service URL |
|
|
579
|
-
| `
|
|
580
|
-
| `identity_credential_path` | `str` | Required | Path to your credential file |
|
|
635
|
+
| `identity_credential_path` | `str` | Required | Path to your DID credential file |
|
|
581
636
|
| `secret_seed` | `str` | Required | Your agent's secret seed |
|
|
582
|
-
|
|
637
|
+
|
|
638
|
+
**Note**:
|
|
639
|
+
- Configure either `webhook_port` (recommended) OR `mqtt_broker_url`, not both.
|
|
640
|
+
- When using webhook mode, `api_key` is required for registering your webhook URL with the registry.
|
|
583
641
|
|
|
584
642
|
### Message Types
|
|
585
643
|
|
|
@@ -815,7 +873,7 @@ We welcome contributions! Here's how to get started:
|
|
|
815
873
|
|
|
816
874
|
### Development Setup
|
|
817
875
|
```bash
|
|
818
|
-
git clone https://github.com/
|
|
876
|
+
git clone https://github.com/Zynd-AI-Network/zyndai-agent.git
|
|
819
877
|
cd zyndai-agent
|
|
820
878
|
python -m venv venv
|
|
821
879
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
@@ -850,11 +908,92 @@ Create agents for real-time market data (x402), technical analysis by agents, se
|
|
|
850
908
|
### 6. Content Generation with Fact-Checking
|
|
851
909
|
Orchestrate agents for research, writing, accessing paid fact-checking APIs via x402, and publishing verified content.
|
|
852
910
|
|
|
911
|
+
## 🔧 Troubleshooting
|
|
912
|
+
|
|
913
|
+
### Webhook Mode Issues
|
|
914
|
+
|
|
915
|
+
**Port Already in Use**
|
|
916
|
+
```
|
|
917
|
+
The SDK automatically tries ports 5000-5010 if the configured port is busy.
|
|
918
|
+
Check the console output for the actual port being used.
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
**Agent Behind NAT/Firewall**
|
|
922
|
+
```python
|
|
923
|
+
# Specify your public webhook URL manually
|
|
924
|
+
agent_config = AgentConfig(
|
|
925
|
+
webhook_host="0.0.0.0",
|
|
926
|
+
webhook_port=5000,
|
|
927
|
+
webhook_url="https://my-public-domain.com/webhook", # Your public URL
|
|
928
|
+
...
|
|
929
|
+
)
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
**Running Multiple Agents Locally**
|
|
933
|
+
```python
|
|
934
|
+
# Agent 1: Port 5000
|
|
935
|
+
agent1_config = AgentConfig(webhook_port=5000, ...)
|
|
936
|
+
|
|
937
|
+
# Agent 2: Port 5001
|
|
938
|
+
agent2_config = AgentConfig(webhook_port=5001, ...)
|
|
939
|
+
|
|
940
|
+
# Agent 3: Port 5002
|
|
941
|
+
agent3_config = AgentConfig(webhook_port=5002, ...)
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
**Target Agent Offline**
|
|
945
|
+
```
|
|
946
|
+
When sending messages, you'll receive clear error messages:
|
|
947
|
+
- "Error: Could not connect to target agent. Agent may be offline."
|
|
948
|
+
- "Error: Request timed out. Target agent may be offline."
|
|
949
|
+
|
|
950
|
+
The SDK does not automatically retry failed webhooks.
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
**Health Check**
|
|
954
|
+
```bash
|
|
955
|
+
# Check if webhook server is running
|
|
956
|
+
curl http://localhost:5000/health
|
|
957
|
+
|
|
958
|
+
# Response:
|
|
959
|
+
# {"status": "ok", "agent_id": "did:polygonid:...", "timestamp": 1234567890}
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
### MQTT Mode Issues
|
|
963
|
+
|
|
964
|
+
**Connection Refused**
|
|
965
|
+
```
|
|
966
|
+
Ensure your MQTT broker URL is correct and the broker is running.
|
|
967
|
+
Default: mqtt://registry.zynd.ai:1883
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
**Messages Not Being Received**
|
|
971
|
+
```
|
|
972
|
+
Check that agents are subscribed to the correct topics.
|
|
973
|
+
Verify encryption credentials match between agents.
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
### General Issues
|
|
977
|
+
|
|
978
|
+
**Decryption Failures**
|
|
979
|
+
```
|
|
980
|
+
Ensure both agents have the correct DID credentials.
|
|
981
|
+
Verify secret_seed matches the identity_credential_path.
|
|
982
|
+
Check that credentials haven't been regenerated.
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
**Registry Connection Errors**
|
|
986
|
+
```
|
|
987
|
+
Verify registry_url is correct.
|
|
988
|
+
Check network connectivity to registry.
|
|
989
|
+
Ensure webhook URL or MQTT broker info was successfully registered.
|
|
990
|
+
```
|
|
991
|
+
|
|
853
992
|
## 🆘 Support & Community
|
|
854
993
|
|
|
855
|
-
- **GitHub Issues**: [Report bugs or request features](https://github.com/
|
|
994
|
+
- **GitHub Issues**: [Report bugs or request features](https://github.com/Zynd-AI-Network/zyndai-agent/issues)
|
|
856
995
|
- **Documentation**: [Full API Documentation](https://docs.zynd.ai)
|
|
857
|
-
- **Email**:
|
|
996
|
+
- **Email**: zyndainetwork@gmail.com
|
|
858
997
|
- **Twitter**: [@ZyndAI](https://x.com/ZyndAI)
|
|
859
998
|
|
|
860
999
|
## 📄 License
|
|
@@ -876,6 +1015,8 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
876
1015
|
- [x] End-to-end encryption
|
|
877
1016
|
- [x] LangChain integration
|
|
878
1017
|
- [x] x402 micropayment support
|
|
1018
|
+
- [x] HTTP Webhook communication mode
|
|
1019
|
+
- [ ] WebSocket support for real-time bidirectional communication
|
|
879
1020
|
- [ ] Support for additional LLM providers (Anthropic, Cohere, etc.)
|
|
880
1021
|
- [ ] Web dashboard for agent monitoring and payment tracking
|
|
881
1022
|
- [ ] Advanced orchestration patterns (workflows, state machines)
|
|
@@ -884,6 +1025,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
884
1025
|
- [ ] Enhanced security features (rate limiting, access control)
|
|
885
1026
|
- [ ] Performance optimizations for high-throughput scenarios
|
|
886
1027
|
- [ ] x402 payment analytics and budgeting tools
|
|
1028
|
+
- [ ] Webhook authentication and rate limiting
|
|
887
1029
|
|
|
888
1030
|
---
|
|
889
1031
|
|
|
@@ -891,4 +1033,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
891
1033
|
|
|
892
1034
|
Get started today: `pip install zyndai-agent` 🚀
|
|
893
1035
|
|
|
894
|
-
**Questions about x402 integration?** Check out our [x402 documentation](https://docs.zynd.ai/x402) or join our community!
|
|
1036
|
+
**Questions about x402 integration?** Check out our [x402 documentation](https://docs.zynd.ai/x402) or join our community!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "zyndai-agent"
|
|
3
|
-
version = "0.1
|
|
4
|
-
description = "A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and MQTT-based Communication."
|
|
3
|
+
version = "0.2.1"
|
|
4
|
+
description = "A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and HTTP Webhook or MQTT-based Communication."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Swapnil Shinde", email = "swapnilshinde9382@gmail.com" }
|
|
7
7
|
]
|
|
@@ -11,7 +11,9 @@ dependencies = [
|
|
|
11
11
|
"base58>=2.1.1",
|
|
12
12
|
"cryptography>=46.0.3",
|
|
13
13
|
"eth-account>=0.13.7",
|
|
14
|
+
"flask>=3.0.0",
|
|
14
15
|
"langchain>=1.1.0",
|
|
15
16
|
"paho-mqtt>=2.1.0",
|
|
16
|
-
"
|
|
17
|
+
"requests>=2.31.0",
|
|
18
|
+
"x402==1.0.0",
|
|
17
19
|
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from zyndai_agent.agent import ZyndAIAgent, AgentConfig
|
|
2
|
+
from zyndai_agent.communication import AgentCommunicationManager, MQTTMessage
|
|
3
|
+
from zyndai_agent.webhook_communication import WebhookCommunicationManager
|
|
4
|
+
from zyndai_agent.message import AgentMessage
|
|
5
|
+
from zyndai_agent.search import SearchAndDiscoveryManager, AgentSearchResponse
|
|
6
|
+
from zyndai_agent.identity import IdentityManager
|
|
7
|
+
from zyndai_agent.payment import X402PaymentProcessor
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"ZyndAIAgent",
|
|
11
|
+
"AgentConfig",
|
|
12
|
+
"AgentCommunicationManager",
|
|
13
|
+
"WebhookCommunicationManager",
|
|
14
|
+
"MQTTMessage",
|
|
15
|
+
"AgentMessage",
|
|
16
|
+
"SearchAndDiscoveryManager",
|
|
17
|
+
"AgentSearchResponse",
|
|
18
|
+
"IdentityManager",
|
|
19
|
+
"X402PaymentProcessor",
|
|
20
|
+
]
|