aid-resolver 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,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,10 @@
1
+ # AID Resolver SDK
2
+
3
+ AID Resolver Python SDK - 去中心化 Agent 发现服务客户端。
4
+
5
+ 基于 [AID 协议](https://github.com/agent-dns/aid-protocol),让你的 Agent 能像查电话簿一样发现其他 Agent。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ pip install aid-resolver
@@ -0,0 +1,4 @@
1
+ from .client import AIDResolver, discover
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["AIDResolver", "discover"]
@@ -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,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ aid_resolver/__init__.py
5
+ aid_resolver/client.py
6
+ aid_resolver.egg-info/PKG-INFO
7
+ aid_resolver.egg-info/SOURCES.txt
8
+ aid_resolver.egg-info/dependency_links.txt
9
+ aid_resolver.egg-info/requires.txt
10
+ aid_resolver.egg-info/top_level.txt
11
+ tests/test_client.py
@@ -0,0 +1 @@
1
+ httpx>=0.24.0
@@ -0,0 +1 @@
1
+ aid_resolver
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,24 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="aid-resolver",
5
+ version="0.1.0",
6
+ packages=find_packages(),
7
+ install_requires=["httpx>=0.24.0"],
8
+ python_requires=">=3.9",
9
+ description="AID Resolver Python SDK - 去中心化 Agent 发现服务客户端",
10
+ long_description=open("README.md", encoding="utf-8").read(),
11
+ long_description_content_type="text/markdown",
12
+ license="MIT",
13
+ author="Your Name",
14
+ author_email="you@example.com",
15
+ url="https://www.aid-resolver.dev",
16
+ classifiers=[
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Operating System :: OS Independent",
23
+ ],
24
+ )
@@ -0,0 +1,21 @@
1
+ import pytest
2
+ import httpx
3
+ from aid_resolver import AIDResolver
4
+
5
+ def test_health():
6
+ resolver = AIDResolver()
7
+ max_retries = 3
8
+ for attempt in range(max_retries):
9
+ try:
10
+ result = resolver.health()
11
+ assert result["status"] == "ok"
12
+ return
13
+ except httpx.ConnectError:
14
+ if attempt == max_retries - 1:
15
+ raise
16
+ continue
17
+
18
+ def test_resolve_not_found():
19
+ resolver = AIDResolver()
20
+ result = resolver.resolve("this-domain-definitely-does-not-exist-12345.com")
21
+ assert "error" in result