zyndai-agent 0.2.1__tar.gz → 0.2.2__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.2.1 → zyndai_agent-0.2.2}/PKG-INFO +292 -55
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/README.md +291 -54
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/pyproject.toml +1 -1
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/__init__.py +2 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/agent.py +54 -21
- zyndai_agent-0.2.2/zyndai_agent/config_manager.py +153 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/message.py +2 -1
- zyndai_agent-0.2.2/zyndai_agent/search.py +185 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/webhook_communication.py +15 -11
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent.egg-info/PKG-INFO +292 -55
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent.egg-info/SOURCES.txt +1 -0
- zyndai_agent-0.2.1/zyndai_agent/search.py +0 -64
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/setup.cfg +0 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/communication.py +0 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/identity.py +0 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/payment.py +0 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent/utils.py +0 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent.egg-info/dependency_links.txt +0 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent.egg-info/requires.txt +0 -0
- {zyndai_agent-0.2.1 → zyndai_agent-0.2.2}/zyndai_agent.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zyndai-agent
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
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
|
|
@@ -23,8 +23,13 @@ A powerful Python SDK that enables AI agents to communicate securely and discove
|
|
|
23
23
|
- 🔐 **Secure Identity Management**: Verify and manage agent identities using Polygon ID credentials
|
|
24
24
|
- 🔍 **Smart Agent Discovery**: Search and discover agents based on their capabilities with ML-powered semantic matching
|
|
25
25
|
- 💬 **Flexible Communication**: Choose between HTTP Webhooks or MQTT for encrypted real-time messaging between agents
|
|
26
|
+
- **Async/Sync Webhooks**: Support both fire-and-forget and request-response patterns
|
|
27
|
+
- **Built-in Endpoints**: `/webhook` (async) and `/webhook/sync` (sync with 30s timeout)
|
|
26
28
|
- 🤖 **LangChain Integration**: Seamlessly works with LangChain agents and any LLM
|
|
27
29
|
- 💰 **x402 Micropayments**: Built-in support for pay-per-use API endpoints with automatic payment handling
|
|
30
|
+
- **Webhook Protection**: Enable x402 payments on agent webhook endpoints
|
|
31
|
+
- **HTTP x402 Client**: Make payments to external x402-protected APIs
|
|
32
|
+
- **Automatic Challenge/Response**: Seamless payment flow with no manual intervention
|
|
28
33
|
- 🌐 **Decentralized Network**: Connect to the global ZyndAI agent network
|
|
29
34
|
- ⚡ **Easy Setup**: Get started in minutes with simple configuration
|
|
30
35
|
|
|
@@ -352,6 +357,8 @@ The SDK supports two communication modes: **HTTP Webhooks** (recommended) and **
|
|
|
352
357
|
|
|
353
358
|
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
359
|
|
|
360
|
+
##### Basic Webhook Configuration
|
|
361
|
+
|
|
355
362
|
```python
|
|
356
363
|
from zyndai_agent.agent import AgentConfig, ZyndAIAgent
|
|
357
364
|
import os
|
|
@@ -386,13 +393,177 @@ result = zyndai_agent.send_message(
|
|
|
386
393
|
messages = zyndai_agent.read_messages()
|
|
387
394
|
```
|
|
388
395
|
|
|
396
|
+
##### Webhook with x402 Micropayments
|
|
397
|
+
|
|
398
|
+
Enable x402 payment protection on your webhook endpoints to monetize agent services:
|
|
399
|
+
|
|
400
|
+
```python
|
|
401
|
+
from zyndai_agent.agent import AgentConfig, ZyndAIAgent
|
|
402
|
+
import os
|
|
403
|
+
|
|
404
|
+
# Configure with webhook mode and x402 payments
|
|
405
|
+
agent_config = AgentConfig(
|
|
406
|
+
webhook_host="0.0.0.0",
|
|
407
|
+
webhook_port=5001,
|
|
408
|
+
webhook_url=None, # Auto-generated http://localhost:5001/webhook
|
|
409
|
+
auto_reconnect=True,
|
|
410
|
+
message_history_limit=100,
|
|
411
|
+
registry_url="https://registry.zynd.ai",
|
|
412
|
+
identity_credential_path="./identity_credential.json",
|
|
413
|
+
secret_seed=os.environ["AGENT_SEED"],
|
|
414
|
+
agent_id=os.environ["AGENT_ID"],
|
|
415
|
+
price="$0.01", # Price per request
|
|
416
|
+
pay_to_address="0xYourEthereumAddress", # Your payment address
|
|
417
|
+
api_key=os.environ["API_KEY"]
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
# Agent automatically starts webhook server with x402 payment middleware
|
|
421
|
+
zyndai_agent = ZyndAIAgent(agent_config=agent_config)
|
|
422
|
+
print(f"Webhook URL: {zyndai_agent.webhook_url}")
|
|
423
|
+
print("x402 payments enabled - clients must pay to interact")
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
**x402 Configuration:**
|
|
427
|
+
- `price`: Payment amount per request (e.g., "$0.01", "$0.10")
|
|
428
|
+
- `pay_to_address`: Your Ethereum address to receive payments
|
|
429
|
+
- If both `price` and `pay_to_address` are provided, x402 is automatically enabled
|
|
430
|
+
- If either is `None`, x402 is disabled and endpoints are free to access
|
|
431
|
+
|
|
432
|
+
##### Asynchronous vs Synchronous Webhooks
|
|
433
|
+
|
|
434
|
+
The SDK supports two webhook communication modes:
|
|
435
|
+
|
|
436
|
+
**1. Asynchronous Mode (Default)** - Fire and forget:
|
|
437
|
+
```python
|
|
438
|
+
# Messages sent to /webhook endpoint
|
|
439
|
+
# Returns immediately without waiting for agent processing
|
|
440
|
+
result = zyndai_agent.send_message("Process this data")
|
|
441
|
+
|
|
442
|
+
# Handler processes asynchronously
|
|
443
|
+
def message_handler(message: AgentMessage, topic: str):
|
|
444
|
+
# Process message
|
|
445
|
+
response = process_message(message.content)
|
|
446
|
+
|
|
447
|
+
# Optionally send response via separate webhook call
|
|
448
|
+
if zyndai_agent.target_webhook_url:
|
|
449
|
+
zyndai_agent.send_message(response)
|
|
450
|
+
|
|
451
|
+
zyndai_agent.add_message_handler(message_handler)
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**2. Synchronous Mode** - Request/response pattern:
|
|
455
|
+
```python
|
|
456
|
+
# Messages sent to /webhook/sync endpoint
|
|
457
|
+
# Waits for agent to process and return response (30s timeout)
|
|
458
|
+
|
|
459
|
+
# Handler sets response using set_response()
|
|
460
|
+
def message_handler(message: AgentMessage, topic: str):
|
|
461
|
+
# Process message
|
|
462
|
+
response = agent_executor.invoke({"input": message.content})
|
|
463
|
+
|
|
464
|
+
# Set response for synchronous caller
|
|
465
|
+
zyndai_agent.set_response(message.message_id, response["output"])
|
|
466
|
+
|
|
467
|
+
zyndai_agent.add_message_handler(message_handler)
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
**Synchronous Response Flow:**
|
|
471
|
+
1. Client sends POST to `/webhook/sync`
|
|
472
|
+
2. Agent processes message via handler
|
|
473
|
+
3. Handler calls `set_response(message_id, response_content)`
|
|
474
|
+
4. Client receives immediate HTTP response with result
|
|
475
|
+
5. Timeout after 30 seconds if no response
|
|
476
|
+
|
|
477
|
+
**Use Cases:**
|
|
478
|
+
- **Async**: Long-running tasks, notifications, fire-and-forget operations
|
|
479
|
+
- **Sync**: Real-time queries, immediate responses needed, request-reply pattern
|
|
480
|
+
|
|
481
|
+
##### Complete Webhook Example with LangChain
|
|
482
|
+
|
|
483
|
+
```python
|
|
484
|
+
from zyndai_agent.agent import AgentConfig, ZyndAIAgent
|
|
485
|
+
from zyndai_agent.message import AgentMessage
|
|
486
|
+
from langchain_openai import ChatOpenAI
|
|
487
|
+
from langchain_classic.memory import ChatMessageHistory
|
|
488
|
+
from langchain_classic.agents import AgentExecutor, create_tool_calling_agent
|
|
489
|
+
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
490
|
+
from langchain_community.tools.tavily_search import TavilySearchResults
|
|
491
|
+
import os
|
|
492
|
+
|
|
493
|
+
# Configure agent with webhook and x402
|
|
494
|
+
agent_config = AgentConfig(
|
|
495
|
+
webhook_host="0.0.0.0",
|
|
496
|
+
webhook_port=5001,
|
|
497
|
+
webhook_url=None,
|
|
498
|
+
auto_reconnect=True,
|
|
499
|
+
message_history_limit=100,
|
|
500
|
+
registry_url="https://registry.zynd.ai",
|
|
501
|
+
identity_credential_path="./identity_credential.json",
|
|
502
|
+
secret_seed=os.environ["AGENT_SEED"],
|
|
503
|
+
agent_id=os.environ["AGENT_ID"],
|
|
504
|
+
price="$0.01", # Enable x402 payments
|
|
505
|
+
pay_to_address="0xYourAddress",
|
|
506
|
+
api_key=os.environ["API_KEY"]
|
|
507
|
+
)
|
|
508
|
+
|
|
509
|
+
# Initialize agent
|
|
510
|
+
zynd_agent = ZyndAIAgent(agent_config=agent_config)
|
|
511
|
+
|
|
512
|
+
# Create LangChain agent
|
|
513
|
+
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
|
|
514
|
+
search_tool = TavilySearchResults(max_results=3)
|
|
515
|
+
message_history = ChatMessageHistory()
|
|
516
|
+
|
|
517
|
+
prompt = ChatPromptTemplate.from_messages([
|
|
518
|
+
("system", "You are a helpful AI agent with web search capabilities."),
|
|
519
|
+
MessagesPlaceholder(variable_name="chat_history"),
|
|
520
|
+
("human", "{input}"),
|
|
521
|
+
MessagesPlaceholder(variable_name="agent_scratchpad")
|
|
522
|
+
])
|
|
523
|
+
|
|
524
|
+
agent = create_tool_calling_agent(llm, [search_tool], prompt)
|
|
525
|
+
agent_executor = AgentExecutor(agent=agent, tools=[search_tool], verbose=True)
|
|
526
|
+
zynd_agent.set_agent_executor(agent_executor)
|
|
527
|
+
|
|
528
|
+
# Message handler for both sync and async
|
|
529
|
+
def message_handler(message: AgentMessage, topic: str):
|
|
530
|
+
# Add to history
|
|
531
|
+
message_history.add_user_message(message.content)
|
|
532
|
+
|
|
533
|
+
# Process with LangChain agent
|
|
534
|
+
agent_response = zynd_agent.agent_executor.invoke({
|
|
535
|
+
"input": message.content,
|
|
536
|
+
"chat_history": message_history.messages
|
|
537
|
+
})
|
|
538
|
+
agent_output = agent_response["output"]
|
|
539
|
+
|
|
540
|
+
message_history.add_ai_message(agent_output)
|
|
541
|
+
|
|
542
|
+
# Set response for synchronous mode
|
|
543
|
+
zynd_agent.set_response(message.message_id, agent_output)
|
|
544
|
+
|
|
545
|
+
# Also send via webhook for agent-to-agent communication
|
|
546
|
+
if zynd_agent.target_webhook_url:
|
|
547
|
+
zynd_agent.send_message(agent_output)
|
|
548
|
+
|
|
549
|
+
zynd_agent.add_message_handler(message_handler)
|
|
550
|
+
|
|
551
|
+
print(f"\nWebhook Agent Running!")
|
|
552
|
+
print(f"Webhook URL: {zynd_agent.webhook_url}")
|
|
553
|
+
print(f"x402 Payments: Enabled at {agent_config.price}")
|
|
554
|
+
print("Supports both /webhook (async) and /webhook/sync (sync) endpoints")
|
|
555
|
+
```
|
|
556
|
+
|
|
389
557
|
**Webhook Mode Features:**
|
|
390
558
|
- ✅ No external broker required
|
|
391
559
|
- ✅ Standard HTTP/HTTPS communication
|
|
560
|
+
- ✅ Synchronous and asynchronous message patterns
|
|
561
|
+
- ✅ x402 micropayments integration
|
|
392
562
|
- ✅ Easy to deploy and debug
|
|
393
563
|
- ✅ Works behind firewalls with port forwarding
|
|
394
564
|
- ✅ Auto-retry on port conflicts (tries ports 5000-5010)
|
|
395
565
|
- ✅ Built-in health check endpoint (`/health`)
|
|
566
|
+
- ✅ Automatic payment challenge/response handling
|
|
396
567
|
|
|
397
568
|
#### MQTT Mode (Legacy)
|
|
398
569
|
|
|
@@ -424,6 +595,24 @@ result = zyndai_agent.send_message(
|
|
|
424
595
|
**Migration from MQTT to Webhooks:**
|
|
425
596
|
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
597
|
|
|
598
|
+
#### Webhook Endpoints Summary
|
|
599
|
+
|
|
600
|
+
When you start a webhook-enabled agent, the following HTTP endpoints become available:
|
|
601
|
+
|
|
602
|
+
| Endpoint | Method | Description | Response Time |
|
|
603
|
+
|----------|--------|-------------|---------------|
|
|
604
|
+
| `/webhook` | POST | Asynchronous message reception | Immediate (fire-and-forget) |
|
|
605
|
+
| `/webhook/sync` | POST | Synchronous message with response | Waits up to 30s for agent response |
|
|
606
|
+
| `/health` | GET | Health check and status | Immediate |
|
|
607
|
+
|
|
608
|
+
**Endpoint Behaviors:**
|
|
609
|
+
- **`/webhook`** (Async): Accepts message, returns 200 immediately, processes in background
|
|
610
|
+
- **`/webhook/sync`** (Sync): Accepts message, waits for handler to call `set_response()`, returns response or timeout
|
|
611
|
+
- **`/health`**: Returns agent status, useful for monitoring and discovery
|
|
612
|
+
|
|
613
|
+
**x402 Protection:**
|
|
614
|
+
When `price` and `pay_to_address` are configured, all webhook endpoints require x402 payment before processing requests.
|
|
615
|
+
|
|
427
616
|
### 🔐 Identity Verification
|
|
428
617
|
|
|
429
618
|
Verify other agents' identities before trusting them:
|
|
@@ -643,6 +832,9 @@ while True:
|
|
|
643
832
|
| `webhook_port` | `int` | `5000` | **Webhook mode**: Port number for webhook server |
|
|
644
833
|
| `webhook_url` | `str` | `None` | **Webhook mode**: Public URL (auto-generated if None) |
|
|
645
834
|
| `api_key` | `str` | `None` | **Webhook mode**: API key for webhook registration (required for webhook mode) |
|
|
835
|
+
| `price` | `str` | `None` | **x402 Webhook**: Price per request (e.g., "$0.01"). Enables x402 if set with `pay_to_address` |
|
|
836
|
+
| `pay_to_address` | `str` | `None` | **x402 Webhook**: Ethereum address for payments. Enables x402 if set with `price` |
|
|
837
|
+
| `agent_id` | `str` | `None` | **x402 Webhook**: Agent identifier (required when using x402 payments) |
|
|
646
838
|
| `mqtt_broker_url` | `str` | `None` | **MQTT mode**: MQTT broker connection URL |
|
|
647
839
|
| `default_outbox_topic` | `str` | `None` | **MQTT mode**: Default topic for outgoing messages |
|
|
648
840
|
| `auto_reconnect` | `bool` | `True` | Auto-reconnect/restart on disconnect |
|
|
@@ -651,9 +843,11 @@ while True:
|
|
|
651
843
|
| `identity_credential_path` | `str` | Required | Path to your DID credential file |
|
|
652
844
|
| `secret_seed` | `str` | Required | Your agent's secret seed |
|
|
653
845
|
|
|
654
|
-
**
|
|
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
|
|
846
|
+
**Notes**:
|
|
847
|
+
- Configure either `webhook_port` (recommended) OR `mqtt_broker_url`, not both
|
|
848
|
+
- When using webhook mode, `api_key` is required for registering your webhook URL with the registry
|
|
849
|
+
- x402 payments require both `price` and `pay_to_address` to be set. If either is `None`, x402 is disabled
|
|
850
|
+
- When using x402, `agent_id` should also be provided for proper identification
|
|
657
851
|
|
|
658
852
|
### Message Types
|
|
659
853
|
|
|
@@ -827,54 +1021,67 @@ except Exception as e:
|
|
|
827
1021
|
|
|
828
1022
|
## 📊 Architecture Overview
|
|
829
1023
|
```
|
|
830
|
-
|
|
831
|
-
│ ZyndAI Agent SDK
|
|
832
|
-
|
|
833
|
-
│
|
|
834
|
-
│ ┌──────────────────┐ ┌──────────────────┐
|
|
835
|
-
│ │ Identity Manager │ │ Search Manager │
|
|
836
|
-
│ │ │ │ │
|
|
837
|
-
│ │ - Verify DIDs │ │ - Capability │
|
|
838
|
-
│ │ - Load Creds │ │ Matching │
|
|
839
|
-
│ │ - Manage Keys │ │ - ML Scoring │
|
|
840
|
-
│ └──────────────────┘ └──────────────────┘
|
|
841
|
-
│
|
|
842
|
-
│
|
|
843
|
-
│ │ Communication Manager
|
|
844
|
-
│ │
|
|
845
|
-
│ │ -
|
|
846
|
-
│ │ -
|
|
847
|
-
│ │ -
|
|
848
|
-
│ │ -
|
|
849
|
-
│
|
|
850
|
-
│
|
|
851
|
-
│
|
|
852
|
-
│
|
|
853
|
-
│ │
|
|
854
|
-
│ │
|
|
855
|
-
│ │
|
|
856
|
-
│ │ -
|
|
857
|
-
│ │ -
|
|
858
|
-
│
|
|
859
|
-
│
|
|
860
|
-
│
|
|
861
|
-
│
|
|
862
|
-
│ │
|
|
863
|
-
│ │
|
|
864
|
-
│ │
|
|
865
|
-
│ │ -
|
|
866
|
-
│
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1024
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
1025
|
+
│ ZyndAI Agent SDK │
|
|
1026
|
+
├─────────────────────────────────────────────────────────────┤
|
|
1027
|
+
│ │
|
|
1028
|
+
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
1029
|
+
│ │ Identity Manager │ │ Search Manager │ │
|
|
1030
|
+
│ │ │ │ │ │
|
|
1031
|
+
│ │ - Verify DIDs │ │ - Capability │ │
|
|
1032
|
+
│ │ - Load Creds │ │ Matching │ │
|
|
1033
|
+
│ │ - Manage Keys │ │ - ML Scoring │ │
|
|
1034
|
+
│ └──────────────────┘ └──────────────────┘ │
|
|
1035
|
+
│ │
|
|
1036
|
+
│ ┌──────────────────────────────────────────────┐ │
|
|
1037
|
+
│ │ Webhook Communication Manager │ │
|
|
1038
|
+
│ │ │ │
|
|
1039
|
+
│ │ - Embedded Flask Server │ │
|
|
1040
|
+
│ │ - Async Endpoint (/webhook) │ │
|
|
1041
|
+
│ │ - Sync Endpoint (/webhook/sync) │ │
|
|
1042
|
+
│ │ - Health Check (/health) │ │
|
|
1043
|
+
│ │ - x402 Payment Middleware (optional) │ │
|
|
1044
|
+
│ │ - Message History Tracking │ │
|
|
1045
|
+
│ └──────────────────────────────────────────────┘ │
|
|
1046
|
+
│ │
|
|
1047
|
+
│ ┌──────────────────────────────────────────┐ │
|
|
1048
|
+
│ │ Communication Manager (MQTT - Legacy) │ │
|
|
1049
|
+
│ │ │ │
|
|
1050
|
+
│ │ - End-to-End Encryption (ECIES) │ │
|
|
1051
|
+
│ │ - Message Routing │ │
|
|
1052
|
+
│ │ - Topic Management │ │
|
|
1053
|
+
│ │ - History Tracking │ │
|
|
1054
|
+
│ └──────────────────────────────────────────┘ │
|
|
1055
|
+
│ │
|
|
1056
|
+
│ ┌──────────────────────────────────────────┐ │
|
|
1057
|
+
│ │ x402 Payment Processor │ │
|
|
1058
|
+
│ │ │ │
|
|
1059
|
+
│ │ - Payment Challenge Handling │ │
|
|
1060
|
+
│ │ - Signature Generation │ │
|
|
1061
|
+
│ │ - Automatic Retry Logic │ │
|
|
1062
|
+
│ │ - Multi-Method Support (GET/POST/etc) │ │
|
|
1063
|
+
│ │ - Webhook Protection (via middleware) │ │
|
|
1064
|
+
│ └──────────────────────────────────────────┘ │
|
|
1065
|
+
│ │
|
|
1066
|
+
│ ┌──────────────────────────────────────────┐ │
|
|
1067
|
+
│ │ LangChain Integration │ │
|
|
1068
|
+
│ │ │ │
|
|
1069
|
+
│ │ - Agent Executor Support │ │
|
|
1070
|
+
│ │ - Custom Tools │ │
|
|
1071
|
+
│ │ - Memory Management │ │
|
|
1072
|
+
│ └──────────────────────────────────────────┘ │
|
|
1073
|
+
└─────────────────────────────────────────────────────────────┘
|
|
1074
|
+
▼ ▼ ▼
|
|
1075
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
1076
|
+
│ Registry │ │ MQTT Broker │ │ Other Agent │
|
|
1077
|
+
│ Service │ │ (Legacy) │ │ Webhooks │
|
|
1078
|
+
└──────────────┘ └──────────────┘ └──────────────┘
|
|
1079
|
+
▼
|
|
1080
|
+
┌──────────────┐
|
|
1081
|
+
│ x402 Enabled │
|
|
1082
|
+
│ Services │
|
|
1083
|
+
│ (HTTP APIs) │
|
|
1084
|
+
└──────────────┘
|
|
878
1085
|
```
|
|
879
1086
|
|
|
880
1087
|
## 🤝 Contributing
|
|
@@ -975,6 +1182,35 @@ curl http://localhost:5000/health
|
|
|
975
1182
|
# {"status": "ok", "agent_id": "did:polygonid:...", "timestamp": 1234567890}
|
|
976
1183
|
```
|
|
977
1184
|
|
|
1185
|
+
**Testing Webhook Endpoints**
|
|
1186
|
+
```bash
|
|
1187
|
+
# Test async webhook (returns immediately)
|
|
1188
|
+
curl -X POST http://localhost:5000/webhook \
|
|
1189
|
+
-H "Content-Type: application/json" \
|
|
1190
|
+
-d '{"content": "Hello", "sender_id": "test", "message_type": "query"}'
|
|
1191
|
+
|
|
1192
|
+
# Response: {"status": "received", "message_id": "...", "timestamp": 1234567890}
|
|
1193
|
+
|
|
1194
|
+
# Test sync webhook (waits for agent response)
|
|
1195
|
+
curl -X POST http://localhost:5000/webhook/sync \
|
|
1196
|
+
-H "Content-Type: application/json" \
|
|
1197
|
+
-d '{"content": "Hello", "sender_id": "test", "message_type": "query"}'
|
|
1198
|
+
|
|
1199
|
+
# Response: {"status": "success", "message_id": "...", "response": "...", "timestamp": 1234567890}
|
|
1200
|
+
# Or timeout: {"status": "timeout", "message_id": "...", "error": "...", "timestamp": 1234567890}
|
|
1201
|
+
```
|
|
1202
|
+
|
|
1203
|
+
**x402 Payment Testing**
|
|
1204
|
+
```bash
|
|
1205
|
+
# First request triggers 402 Payment Required
|
|
1206
|
+
curl -X POST http://localhost:5000/webhook \
|
|
1207
|
+
-H "Content-Type: application/json" \
|
|
1208
|
+
-d '{"content": "Hello"}'
|
|
1209
|
+
|
|
1210
|
+
# Response: 402 with payment challenge
|
|
1211
|
+
# SDK automatically handles payment and retries
|
|
1212
|
+
```
|
|
1213
|
+
|
|
978
1214
|
### MQTT Mode Issues
|
|
979
1215
|
|
|
980
1216
|
**Connection Refused**
|
|
@@ -1030,8 +1266,9 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
1030
1266
|
- [x] Core agent communication and discovery
|
|
1031
1267
|
- [x] End-to-end encryption
|
|
1032
1268
|
- [x] LangChain integration
|
|
1033
|
-
- [x] x402 micropayment support
|
|
1034
|
-
- [x] HTTP Webhook communication mode
|
|
1269
|
+
- [x] x402 micropayment support for HTTP APIs
|
|
1270
|
+
- [x] HTTP Webhook communication mode (async/sync)
|
|
1271
|
+
- [x] x402 payment protection for webhook endpoints
|
|
1035
1272
|
- [ ] WebSocket support for real-time bidirectional communication
|
|
1036
1273
|
- [ ] Support for additional LLM providers (Anthropic, Cohere, etc.)
|
|
1037
1274
|
- [ ] Web dashboard for agent monitoring and payment tracking
|
|
@@ -1041,7 +1278,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
1041
1278
|
- [ ] Enhanced security features (rate limiting, access control)
|
|
1042
1279
|
- [ ] Performance optimizations for high-throughput scenarios
|
|
1043
1280
|
- [ ] x402 payment analytics and budgeting tools
|
|
1044
|
-
- [ ] Webhook authentication and rate limiting
|
|
1281
|
+
- [ ] Webhook authentication and advanced rate limiting
|
|
1045
1282
|
|
|
1046
1283
|
---
|
|
1047
1284
|
|