aid-resolver 0.1.0__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.
aid_resolver/__init__.py
ADDED
aid_resolver/client.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AIDResolver:
|
|
6
|
+
"""AID Resolver Python SDK
|
|
7
|
+
|
|
8
|
+
默认使用公共服务节点 https://www.aid-resolver.dev
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, endpoint: str = "https://www.aid-resolver.dev"):
|
|
12
|
+
self.endpoint = endpoint.rstrip("/")
|
|
13
|
+
|
|
14
|
+
def resolve(self, domain: str) -> dict:
|
|
15
|
+
"""同步解析指定域名的 Agent 服务信息"""
|
|
16
|
+
with httpx.Client(timeout=15.0) as client:
|
|
17
|
+
resp = client.get(f"{self.endpoint}/resolve/{domain}")
|
|
18
|
+
if resp.status_code == 404:
|
|
19
|
+
return {"error": f"未找到 {domain} 的 Agent 记录", "domain": domain}
|
|
20
|
+
resp.raise_for_status()
|
|
21
|
+
return resp.json()
|
|
22
|
+
|
|
23
|
+
def lookup(self, hashid: str) -> dict:
|
|
24
|
+
"""同步通过 HashID 反向查找 Agent"""
|
|
25
|
+
with httpx.Client(timeout=15.0) as client:
|
|
26
|
+
resp = client.get(f"{self.endpoint}/lookup", params={"hashid": hashid})
|
|
27
|
+
resp.raise_for_status()
|
|
28
|
+
return resp.json()
|
|
29
|
+
|
|
30
|
+
def health(self) -> dict:
|
|
31
|
+
"""同步健康检查"""
|
|
32
|
+
with httpx.Client(timeout=15.0) as client:
|
|
33
|
+
resp = client.get(f"{self.endpoint}/health")
|
|
34
|
+
return resp.json()
|
|
35
|
+
|
|
36
|
+
async def async_resolve(self, domain: str) -> dict:
|
|
37
|
+
"""异步解析 Agent 服务信息"""
|
|
38
|
+
async with httpx.AsyncClient(timeout=15.0) as client:
|
|
39
|
+
resp = await client.get(f"{self.endpoint}/resolve/{domain}")
|
|
40
|
+
if resp.status_code == 404:
|
|
41
|
+
return {"error": f"未找到 {domain} 的 Agent 记录", "domain": domain}
|
|
42
|
+
resp.raise_for_status()
|
|
43
|
+
return resp.json()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def discover(domain: str, endpoint: Optional[str] = None) -> dict:
|
|
47
|
+
"""同步快捷发现函数"""
|
|
48
|
+
resolver = AIDResolver(endpoint) if endpoint else AIDResolver()
|
|
49
|
+
return resolver.resolve(domain)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aid-resolver
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AID Resolver Python SDK - 去中心化 Agent 发现服务客户端
|
|
5
|
+
Home-page: https://www.aid-resolver.dev
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: you@example.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: httpx>=0.24.0
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: license
|
|
25
|
+
Dynamic: requires-dist
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
Dynamic: summary
|
|
28
|
+
|
|
29
|
+
# AID Resolver SDK
|
|
30
|
+
|
|
31
|
+
AID Resolver Python SDK - 去中心化 Agent 发现服务客户端。
|
|
32
|
+
|
|
33
|
+
基于 [AID 协议](https://github.com/agent-dns/aid-protocol),让你的 Agent 能像查电话簿一样发现其他 Agent。
|
|
34
|
+
|
|
35
|
+
## 安装
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install aid-resolver
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
aid_resolver/__init__.py,sha256=-iGutaK_vrc7I-VbvD-wjChYMrg9MCCiic4qq4oJhS0,103
|
|
2
|
+
aid_resolver/client.py,sha256=t2cj49kW_V02qiOIjGuYzxzePWgakNfTTeXaFEMrfl8,1852
|
|
3
|
+
aid_resolver-0.1.0.dist-info/METADATA,sha256=5fpQzxyXKZN64CaF-Cg-uYmwGsnq3ERoG0nWK-8KiYw,1101
|
|
4
|
+
aid_resolver-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
aid_resolver-0.1.0.dist-info/top_level.txt,sha256=axtIP9-Fcam67zqUw2yAyUTRjn9UY6YbfRmV7oSl9tk,13
|
|
6
|
+
aid_resolver-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aid_resolver
|