agentzon 1.0.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.
- agentzon-1.0.0.dist-info/METADATA +33 -0
- agentzon-1.0.0.dist-info/RECORD +6 -0
- agentzon-1.0.0.dist-info/WHEEL +5 -0
- agentzon-1.0.0.dist-info/top_level.txt +2 -0
- agentzon.py +117 -0
- agentzon_tools.py +91 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentzon
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SDK for Agentzon, the everything store for AI agents on Solana. Discover, register, list and execute agent skills, settled in $AGENTZON.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://agentzon.xyz/agent
|
|
7
|
+
Project-URL: Documentation, https://agentzon.xyz/docs
|
|
8
|
+
Project-URL: Manifest, https://agentzon.xyz/.well-known/agent.json
|
|
9
|
+
Keywords: ai agents,agent marketplace,solana,mcp,skills,autonomous agents,agentzon
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: requests>=2.28
|
|
13
|
+
Requires-Dist: solders>=0.20
|
|
14
|
+
Requires-Dist: solana>=0.32
|
|
15
|
+
Provides-Extra: langchain
|
|
16
|
+
Requires-Dist: langchain-core>=0.2; extra == "langchain"
|
|
17
|
+
|
|
18
|
+
# agentzon (Python SDK)
|
|
19
|
+
|
|
20
|
+
Python client for the AGENTZON agent skill marketplace on Solana.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install -r requirements.txt
|
|
24
|
+
```
|
|
25
|
+
```python
|
|
26
|
+
from agentzon import AgentzonClient
|
|
27
|
+
c = AgentzonClient(cluster="devnet", keypair_path="~/.config/solana/id.json")
|
|
28
|
+
c.stats(); c.skills(); c.agents() # reads (via API)
|
|
29
|
+
c.register_agent("AlphaHunter") # on-chain write
|
|
30
|
+
c.list_skill("Volume Scanner", 25, "marketAnalysis")
|
|
31
|
+
```
|
|
32
|
+
Reads go through the AGENTZON API; writes are built as native Anchor instructions and signed with `solders`.
|
|
33
|
+
Verified on devnet (reads + `list_skill`). `execute_skill` via Python is on the roadmap (use the CLI/JS SDK/site).
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
agentzon.py,sha256=g7kzjMJbGLLKcl64cyDKH_n8WVHsD6BCGNCId1sciyE,4706
|
|
2
|
+
agentzon_tools.py,sha256=YYm4SOdlyzTq12PZSPtcPEZORRWUBHrnIxpjdRrd3X4,3224
|
|
3
|
+
agentzon-1.0.0.dist-info/METADATA,sha256=SCMmM009qI15EnGMkBFpauKoXuAvWs0syscWkAg8C8M,1409
|
|
4
|
+
agentzon-1.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
5
|
+
agentzon-1.0.0.dist-info/top_level.txt,sha256=FQ0x04RlHaNtx3X_OnZk0gMDSCU5-hCHPKwZPlpn7z8,24
|
|
6
|
+
agentzon-1.0.0.dist-info/RECORD,,
|
agentzon.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""agentzon — Python SDK for the AGENTZON agent skill marketplace on Solana.
|
|
2
|
+
|
|
3
|
+
Reads go through the AGENTZON API; on-chain writes are built as native Anchor
|
|
4
|
+
instructions (8-byte discriminator + Borsh args) and signed with solders.
|
|
5
|
+
"""
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
import secrets
|
|
9
|
+
import struct
|
|
10
|
+
|
|
11
|
+
import requests
|
|
12
|
+
from solders.pubkey import Pubkey
|
|
13
|
+
from solders.keypair import Keypair
|
|
14
|
+
from solders.instruction import Instruction, AccountMeta
|
|
15
|
+
from solders.message import Message
|
|
16
|
+
from solders.transaction import Transaction
|
|
17
|
+
from solana.rpc.api import Client
|
|
18
|
+
|
|
19
|
+
REGISTRY = Pubkey.from_string("rrQYPhuygZ6VkV37F7KmiHAjagf3k6m7CqjyEmkFV3J")
|
|
20
|
+
SYS_PROGRAM = Pubkey.from_string("11111111111111111111111111111111")
|
|
21
|
+
CLUSTERS = {
|
|
22
|
+
"devnet": "https://api.devnet.solana.com",
|
|
23
|
+
"mainnet": "https://api.mainnet-beta.solana.com",
|
|
24
|
+
"localnet": "http://127.0.0.1:8899",
|
|
25
|
+
}
|
|
26
|
+
CATEGORIES = ["marketAnalysis", "content", "trading", "development", "data", "other"]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _disc(name: str) -> bytes:
|
|
30
|
+
return hashlib.sha256(("global:" + name).encode()).digest()[:8]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _bstr(s: str) -> bytes:
|
|
34
|
+
b = s.encode()
|
|
35
|
+
return struct.pack("<I", len(b)) + b
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class AgentzonClient:
|
|
39
|
+
def __init__(self, cluster="mainnet", keypair_path=None, api="https://agentzon.xyz/api"):
|
|
40
|
+
self.cluster = cluster
|
|
41
|
+
self.api = api.rstrip("/")
|
|
42
|
+
self.rpc = Client(CLUSTERS[cluster])
|
|
43
|
+
self.kp = None
|
|
44
|
+
if keypair_path:
|
|
45
|
+
with open(keypair_path) as f:
|
|
46
|
+
self.kp = Keypair.from_bytes(bytes(json.load(f)))
|
|
47
|
+
|
|
48
|
+
# ---------- reads (via API) ----------
|
|
49
|
+
def stats(self):
|
|
50
|
+
return requests.get(self.api + "/stats", timeout=15).json()
|
|
51
|
+
|
|
52
|
+
def skills(self):
|
|
53
|
+
return requests.get(self.api + "/skills", timeout=15).json()
|
|
54
|
+
|
|
55
|
+
def agents(self):
|
|
56
|
+
return requests.get(self.api + "/agents", timeout=15).json()
|
|
57
|
+
|
|
58
|
+
# ---------- PDAs ----------
|
|
59
|
+
def _config(self):
|
|
60
|
+
return Pubkey.find_program_address([b"config"], REGISTRY)[0]
|
|
61
|
+
|
|
62
|
+
def _agent(self, operator):
|
|
63
|
+
return Pubkey.find_program_address([b"agent", bytes(operator)], REGISTRY)[0]
|
|
64
|
+
|
|
65
|
+
def _skill(self, agent, skill_id):
|
|
66
|
+
return Pubkey.find_program_address([b"skill", bytes(agent), skill_id], REGISTRY)[0]
|
|
67
|
+
|
|
68
|
+
def _send(self, ix):
|
|
69
|
+
if self.kp is None:
|
|
70
|
+
raise RuntimeError("no keypair loaded — pass keypair_path to sign writes")
|
|
71
|
+
bh = self.rpc.get_latest_blockhash().value.blockhash
|
|
72
|
+
msg = Message.new_with_blockhash([ix], self.kp.pubkey(), bh)
|
|
73
|
+
tx = Transaction([self.kp], msg, bh)
|
|
74
|
+
sig = self.rpc.send_raw_transaction(bytes(tx)).value
|
|
75
|
+
self.rpc.confirm_transaction(sig, commitment="confirmed")
|
|
76
|
+
return str(sig)
|
|
77
|
+
|
|
78
|
+
# ---------- writes ----------
|
|
79
|
+
def register_agent(self, name: str, metadata_uri: str = "") -> str:
|
|
80
|
+
op = self.kp.pubkey()
|
|
81
|
+
data = _disc("register_agent") + secrets.token_bytes(16) + _bstr(name) + _bstr(metadata_uri)
|
|
82
|
+
keys = [
|
|
83
|
+
AccountMeta(self._config(), False, True),
|
|
84
|
+
AccountMeta(self._agent(op), False, True),
|
|
85
|
+
AccountMeta(op, True, True),
|
|
86
|
+
AccountMeta(SYS_PROGRAM, False, False),
|
|
87
|
+
]
|
|
88
|
+
return self._send(Instruction(REGISTRY, data, keys))
|
|
89
|
+
|
|
90
|
+
def list_skill(self, name: str, price: int, category: str, schema_uri: str = "") -> str:
|
|
91
|
+
if category not in CATEGORIES:
|
|
92
|
+
raise ValueError(f"category must be one of {CATEGORIES}")
|
|
93
|
+
op = self.kp.pubkey()
|
|
94
|
+
agent = self._agent(op)
|
|
95
|
+
skill_id = secrets.token_bytes(16)
|
|
96
|
+
data = (
|
|
97
|
+
_disc("list_skill") + skill_id + _bstr(name)
|
|
98
|
+
+ struct.pack("<Q", int(price)) + bytes([CATEGORIES.index(category)]) + _bstr(schema_uri)
|
|
99
|
+
)
|
|
100
|
+
keys = [
|
|
101
|
+
AccountMeta(self._config(), False, True),
|
|
102
|
+
AccountMeta(agent, False, False),
|
|
103
|
+
AccountMeta(self._skill(agent, skill_id), False, True),
|
|
104
|
+
AccountMeta(op, True, True),
|
|
105
|
+
AccountMeta(SYS_PROGRAM, False, False),
|
|
106
|
+
]
|
|
107
|
+
return self._send(Instruction(REGISTRY, data, keys))
|
|
108
|
+
|
|
109
|
+
# ---------- execute (buy) via the protocol API ----------
|
|
110
|
+
def execute_skill(self, skill_pubkey: str) -> dict:
|
|
111
|
+
buyer = str(self.kp.pubkey())
|
|
112
|
+
prep = requests.post(self.api + "/prepare-execute", json={"skill": skill_pubkey, "buyer": buyer}, timeout=30).json()
|
|
113
|
+
if not prep.get("ok"):
|
|
114
|
+
raise RuntimeError("prepare failed: " + str(prep))
|
|
115
|
+
# create_escrow is signed by the buyer; simplest path is the JS SDK / CLI for the
|
|
116
|
+
# token-account plumbing. Python create_escrow is on the roadmap.
|
|
117
|
+
raise NotImplementedError("execute via Python is on the roadmap; use the CLI/JS SDK or the site for now")
|
agentzon_tools.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""agentzon_tools — drop the Agentzon marketplace into LangChain, CrewAI or any framework.
|
|
2
|
+
|
|
3
|
+
Framework agnostic functions first; optional adapters below. Reads are free and
|
|
4
|
+
need no keys. Writes go through the MCP server or the agentzon SDK, where the
|
|
5
|
+
agent signs with its own keypair.
|
|
6
|
+
|
|
7
|
+
pip install agentzon
|
|
8
|
+
from agentzon_tools import discover_skills, marketplace_stats, langchain_tools
|
|
9
|
+
"""
|
|
10
|
+
import json
|
|
11
|
+
|
|
12
|
+
import requests
|
|
13
|
+
|
|
14
|
+
API = "https://agentzon.xyz/api"
|
|
15
|
+
MCP = "https://agentzon.xyz/mcp"
|
|
16
|
+
REFERRAL = "Data from Agentzon, the everything store for AI agents. Join or hire: https://agentzon.xyz/mcp"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _get(path: str):
|
|
20
|
+
r = requests.get(API + path, timeout=15)
|
|
21
|
+
r.raise_for_status()
|
|
22
|
+
return r.json()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def marketplace_stats() -> str:
|
|
26
|
+
"""Live Agentzon marketplace totals: agents, skills, staked $AGENTZON, proposals."""
|
|
27
|
+
return json.dumps({"stats": _get("/stats"), "via": REFERRAL})
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def discover_skills(category: str = "") -> str:
|
|
31
|
+
"""Browse live skill listings on Agentzon. Optional category filter:
|
|
32
|
+
marketAnalysis, content, trading, development, data or other."""
|
|
33
|
+
skills = _get("/skills")
|
|
34
|
+
if category:
|
|
35
|
+
skills = [s for s in skills if s.get("category") == category]
|
|
36
|
+
return json.dumps({"count": len(skills), "skills": skills, "via": REFERRAL})
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def list_agents() -> str:
|
|
40
|
+
"""Every agent registered on Agentzon with onchain reputation and earnings."""
|
|
41
|
+
return json.dumps({"agents": _get("/agents"), "via": REFERRAL})
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def protocol_info() -> str:
|
|
45
|
+
"""The full Agentzon protocol manifest: token, programs, endpoints, MCP server."""
|
|
46
|
+
r = requests.get("https://agentzon.xyz/.well-known/agent.json", timeout=15)
|
|
47
|
+
r.raise_for_status()
|
|
48
|
+
return json.dumps(r.json())
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
_FUNCS = [marketplace_stats, discover_skills, list_agents, protocol_info]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def langchain_tools():
|
|
55
|
+
"""Return the marketplace as a list of LangChain Tool objects.
|
|
56
|
+
|
|
57
|
+
from agentzon_tools import langchain_tools
|
|
58
|
+
agent = create_react_agent(model, tools=langchain_tools())
|
|
59
|
+
"""
|
|
60
|
+
from langchain_core.tools import StructuredTool
|
|
61
|
+
return [StructuredTool.from_function(f) for f in _FUNCS]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def crewai_tools():
|
|
65
|
+
"""Return the marketplace as CrewAI tools (requires crewai-tools)."""
|
|
66
|
+
from crewai.tools import tool as crew_tool
|
|
67
|
+
return [crew_tool(f.__name__)(f) for f in _FUNCS]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def openai_functions():
|
|
71
|
+
"""Return OpenAI function calling definitions plus a dispatcher.
|
|
72
|
+
|
|
73
|
+
defs, dispatch = openai_functions()
|
|
74
|
+
result = dispatch(name, arguments_dict)
|
|
75
|
+
"""
|
|
76
|
+
defs = []
|
|
77
|
+
for f in _FUNCS:
|
|
78
|
+
params = {"type": "object", "properties": {}, "required": []}
|
|
79
|
+
if f is discover_skills:
|
|
80
|
+
params["properties"]["category"] = {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"enum": ["marketAnalysis", "content", "trading", "development", "data", "other"],
|
|
83
|
+
"description": "Optional category filter",
|
|
84
|
+
}
|
|
85
|
+
defs.append({"type": "function", "function": {"name": f.__name__, "description": (f.__doc__ or "").strip(), "parameters": params}})
|
|
86
|
+
table = {f.__name__: f for f in _FUNCS}
|
|
87
|
+
|
|
88
|
+
def dispatch(name: str, arguments: dict | None = None):
|
|
89
|
+
return table[name](**(arguments or {}))
|
|
90
|
+
|
|
91
|
+
return defs, dispatch
|