agentmesh-client 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,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentmesh-client
3
+ Version: 0.1.0
4
+ Summary: Shared memory + coordination layer for multi-agent AI systems
5
+ Author-email: agentmesh-client <hello@agentmesh.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/onassis-ctrl/agentmesh
8
+ Project-URL: Documentation, https://agentmesh-production.up.railway.app/docs
9
+ Project-URL: Repository, https://github.com/onassis-ctrl/agentmesh
10
+ Project-URL: Bug Tracker, https://github.com/onassis-ctrl/agentmesh/issues
11
+ Keywords: ai,agents,memory,multi-agent,llm,coordination
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: requests>=2.28.0
@@ -0,0 +1,20 @@
1
+ """
2
+ AgentMesh — Shared memory + coordination layer for multi-agent AI systems.
3
+
4
+ Quick start:
5
+ pip install agentmesh
6
+
7
+ from agentmesh import AgentMesh
8
+
9
+ mesh = AgentMesh(api_key="your_key")
10
+ mesh.write(agent_id="agent1", content="I specialize in NLP tasks")
11
+ results = mesh.recall("text processing")
12
+
13
+ Docs: https://agentmesh-production.up.railway.app/docs
14
+ GitHub: https://github.com/onassis-ctrl/agentmesh
15
+ """
16
+
17
+ from .client import AgentMesh, AgentMeshError
18
+
19
+ __all__ = ["AgentMesh", "AgentMeshError"]
20
+ __version__ = "0.1.0"
@@ -0,0 +1,242 @@
1
+ """
2
+ AgentMesh Python SDK
3
+ Shared memory + coordination layer for multi-agent AI systems.
4
+
5
+ Usage:
6
+ from agentmesh import AgentMesh
7
+ mesh = AgentMesh(api_key="your_key")
8
+ mesh.write(agent_id="agent1", content="I specialize in NLP")
9
+ results = mesh.recall("text processing")
10
+ """
11
+
12
+ import requests
13
+ from typing import Optional
14
+
15
+
16
+ class AgentMeshError(Exception):
17
+ """Raised when the AgentMesh API returns an error."""
18
+ pass
19
+
20
+
21
+ class AgentMesh:
22
+ """
23
+ AgentMesh client — shared memory + coordination for multi-agent AI systems.
24
+
25
+ Args:
26
+ api_key: Your AgentMesh API key.
27
+ base_url: API base URL. Defaults to the hosted cloud API.
28
+ Set to http://localhost:8000 for local development.
29
+ timeout: Request timeout in seconds. Default 60.
30
+
31
+ Example:
32
+ mesh = AgentMesh(api_key="am_sk_...")
33
+ mesh.write(agent_id="agent1", content="I handle NLP tasks")
34
+ results = mesh.recall("text processing")
35
+ """
36
+
37
+ DEFAULT_URL = "https://agentmesh-production.up.railway.app"
38
+
39
+ def __init__(
40
+ self,
41
+ api_key: str,
42
+ base_url: str = DEFAULT_URL,
43
+ timeout: int = 60,
44
+ ):
45
+ self.api_key = api_key
46
+ self.base_url = base_url.rstrip("/")
47
+ self.timeout = timeout
48
+ self._session = requests.Session()
49
+ self._session.headers.update({
50
+ "x-api-key": self.api_key,
51
+ "Content-Type": "application/json",
52
+ "Accept": "application/json",
53
+ })
54
+
55
+ # ── internal ───────────────────────────────────────────────────────────────
56
+
57
+ def _post(self, endpoint: str, payload: dict) -> dict:
58
+ url = f"{self.base_url}/{endpoint.lstrip('/')}"
59
+ try:
60
+ resp = self._session.post(url, json=payload, timeout=self.timeout)
61
+ data = resp.json()
62
+ except requests.exceptions.ConnectionError:
63
+ raise AgentMeshError(
64
+ f"Could not connect to AgentMesh at {self.base_url}. "
65
+ "Check your base_url or network connection."
66
+ )
67
+ except requests.exceptions.Timeout:
68
+ raise AgentMeshError(
69
+ f"Request to {endpoint} timed out after {self.timeout}s."
70
+ )
71
+
72
+ if data.get("status") == "error":
73
+ raise AgentMeshError(data.get("detail", "Unknown error"))
74
+
75
+ return data.get("data", data)
76
+
77
+ def _get(self, endpoint: str) -> dict:
78
+ url = f"{self.base_url}/{endpoint.lstrip('/')}"
79
+ try:
80
+ resp = self._session.get(url, timeout=self.timeout)
81
+ data = resp.json()
82
+ except requests.exceptions.ConnectionError:
83
+ raise AgentMeshError(
84
+ f"Could not connect to AgentMesh at {self.base_url}."
85
+ )
86
+ except requests.exceptions.Timeout:
87
+ raise AgentMeshError(
88
+ f"Request to {endpoint} timed out after {self.timeout}s."
89
+ )
90
+
91
+ if data.get("status") == "error":
92
+ raise AgentMeshError(data.get("detail", "Unknown error"))
93
+
94
+ return data.get("data", data)
95
+
96
+ # ── public API ─────────────────────────────────────────────────────────────
97
+
98
+ def write(
99
+ self,
100
+ content: str,
101
+ agent_id: Optional[str] = None,
102
+ memory_type: str = "general",
103
+ ) -> dict:
104
+ """
105
+ Store a memory.
106
+
107
+ Args:
108
+ content: What to remember.
109
+ agent_id: Which agent is writing this memory.
110
+ memory_type: Category label (default: "general").
111
+
112
+ Returns:
113
+ dict with status, id, content, agent_id, namespace.
114
+
115
+ Example:
116
+ mesh.write(agent_id="agent1", content="I handle NLP tasks")
117
+ """
118
+ return self._post("/write", {
119
+ "agent_id": agent_id,
120
+ "content": content,
121
+ "memory_type": memory_type,
122
+ })
123
+
124
+ def recall(
125
+ self,
126
+ query: str,
127
+ top_k: int = 5,
128
+ ) -> list:
129
+ """
130
+ Semantic search across all agent memories.
131
+
132
+ Args:
133
+ query: What to search for.
134
+ top_k: Max number of results to return (default: 5).
135
+
136
+ Returns:
137
+ List of matching memories with agent_id, content, score.
138
+
139
+ Example:
140
+ results = mesh.recall("text processing", top_k=3)
141
+ for r in results:
142
+ print(r["agent_id"], r["score"], r["content"])
143
+ """
144
+ return self._post("/recall", {
145
+ "query": query,
146
+ "top_k": top_k,
147
+ })
148
+
149
+ def index(self) -> dict:
150
+ """
151
+ Show which agents know what.
152
+
153
+ Returns:
154
+ Dict mapping agent_id → list of memory summaries.
155
+
156
+ Example:
157
+ knowledge_map = mesh.index()
158
+ """
159
+ return self._post("/index", {})
160
+
161
+ def route(
162
+ self,
163
+ task: str,
164
+ top_k: int = 3,
165
+ ) -> list:
166
+ """
167
+ Find the best agent(s) to handle a task.
168
+
169
+ Args:
170
+ task: Description of the task.
171
+ top_k: Number of agent suggestions to return (default: 3).
172
+
173
+ Returns:
174
+ Ranked list of agents best suited for the task.
175
+
176
+ Example:
177
+ agents = mesh.route("summarize this document")
178
+ best_agent = agents[0]["agent_id"]
179
+ """
180
+ return self._post("/route", {
181
+ "task": task,
182
+ "top_k": top_k,
183
+ })
184
+
185
+ def discover(
186
+ self,
187
+ topic: str,
188
+ ) -> list:
189
+ """
190
+ Discover agents that specialize in a topic.
191
+
192
+ Args:
193
+ topic: Topic to search for specialists.
194
+
195
+ Returns:
196
+ List of agents with expertise in that topic.
197
+
198
+ Example:
199
+ experts = mesh.discover("database queries")
200
+ """
201
+ return self._post("/discover", {
202
+ "topic": topic,
203
+ })
204
+
205
+ def metrics(self) -> dict:
206
+ """
207
+ Get collaboration stats and insights.
208
+
209
+ Returns:
210
+ Dict with total memories, agent counts, top agents, etc.
211
+
212
+ Example:
213
+ stats = mesh.metrics()
214
+ print(stats["total_memories"])
215
+ """
216
+ return self._get("/metrics")
217
+
218
+ def forget(
219
+ self,
220
+ agent_id: Optional[str] = None,
221
+ content_filter: Optional[str] = None,
222
+ ) -> dict:
223
+ """
224
+ GDPR-compliant delete — remove memories by agent or content.
225
+
226
+ Args:
227
+ agent_id: Delete all memories for this agent.
228
+ content_filter: Delete memories containing this string.
229
+
230
+ Returns:
231
+ Dict with count of deleted memories.
232
+
233
+ Example:
234
+ mesh.forget(agent_id="agent1")
235
+ mesh.forget(content_filter="sensitive data")
236
+ """
237
+ if not agent_id and not content_filter:
238
+ raise ValueError("Provide agent_id or content_filter (or both).")
239
+ return self._post("/forget", {
240
+ "agent_id": agent_id,
241
+ "content_filter": content_filter,
242
+ })
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentmesh-client
3
+ Version: 0.1.0
4
+ Summary: Shared memory + coordination layer for multi-agent AI systems
5
+ Author-email: agentmesh-client <hello@agentmesh.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/onassis-ctrl/agentmesh
8
+ Project-URL: Documentation, https://agentmesh-production.up.railway.app/docs
9
+ Project-URL: Repository, https://github.com/onassis-ctrl/agentmesh
10
+ Project-URL: Bug Tracker, https://github.com/onassis-ctrl/agentmesh/issues
11
+ Keywords: ai,agents,memory,multi-agent,llm,coordination
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: requests>=2.28.0
@@ -0,0 +1,9 @@
1
+ pyproject.toml
2
+ agentmesh/__init__.py
3
+ agentmesh/client.py
4
+ agentmesh_client.egg-info/PKG-INFO
5
+ agentmesh_client.egg-info/SOURCES.txt
6
+ agentmesh_client.egg-info/dependency_links.txt
7
+ agentmesh_client.egg-info/requires.txt
8
+ agentmesh_client.egg-info/top_level.txt
9
+ tests/test_sdk.py
@@ -0,0 +1 @@
1
+ requests>=2.28.0
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agentmesh-client"
7
+ version = "0.1.0"
8
+ description = "Shared memory + coordination layer for multi-agent AI systems"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "agentmesh-client", email = "hello@agentmesh.dev" }]
12
+ keywords = ["ai", "agents", "memory", "multi-agent", "llm", "coordination"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
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
+ "Topic :: Software Development :: Libraries",
23
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
+ ]
25
+ requires-python = ">=3.9"
26
+ dependencies = [
27
+ "requests>=2.28.0",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/onassis-ctrl/agentmesh"
32
+ Documentation = "https://agentmesh-production.up.railway.app/docs"
33
+ Repository = "https://github.com/onassis-ctrl/agentmesh"
34
+ "Bug Tracker" = "https://github.com/onassis-ctrl/agentmesh/issues"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["."]
38
+ include = ["agentmesh*"]
39
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,80 @@
1
+ """
2
+ AgentMesh SDK Tests
3
+ Tests the SDK client against the live API.
4
+
5
+ Run with: pytest tests/test_sdk.py -v
6
+ """
7
+
8
+ import pytest
9
+ from agentmesh import AgentMesh, AgentMeshError
10
+
11
+ # Point at local server for tests — change to Railway URL for cloud tests
12
+ BASE_URL = "http://localhost:8000"
13
+ API_KEY = "dev"
14
+
15
+ @pytest.fixture
16
+ def mesh():
17
+ return AgentMesh(api_key=API_KEY, base_url=BASE_URL)
18
+
19
+
20
+ def test_write(mesh):
21
+ result = mesh.write(agent_id="sdk_test_agent", content="I handle SDK testing tasks")
22
+ assert result["agent_id"] == "sdk_test_agent"
23
+ assert "id" in result
24
+ print(f"✅ write() — id={result['id']}")
25
+
26
+
27
+ def test_recall(mesh):
28
+ mesh.write(agent_id="sdk_recall_agent", content="I specialize in data retrieval")
29
+ results = mesh.recall("data retrieval", top_k=3)
30
+ assert isinstance(results, list)
31
+ assert len(results) >= 1
32
+ assert "agent_id" in results[0]
33
+ assert "score" in results[0]
34
+ print(f"✅ recall() — {len(results)} results")
35
+
36
+
37
+ def test_route(mesh):
38
+ mesh.write(agent_id="sdk_route_agent", content="I summarize documents and reports")
39
+ results = mesh.route("summarize this report", top_k=2)
40
+ assert isinstance(results, list)
41
+ print(f"✅ route() — {results}")
42
+
43
+
44
+ def test_discover(mesh):
45
+ mesh.write(agent_id="sdk_discover_agent", content="I run SQL queries and manage databases")
46
+ results = mesh.discover("database")
47
+ assert isinstance(results, list)
48
+ print(f"✅ discover() — {results}")
49
+
50
+
51
+ def test_index(mesh):
52
+ result = mesh.index()
53
+ assert result is not None
54
+ print(f"✅ index() — OK")
55
+
56
+
57
+ def test_metrics(mesh):
58
+ result = mesh.metrics()
59
+ assert result is not None
60
+ print(f"✅ metrics() — {result}")
61
+
62
+
63
+ def test_forget(mesh):
64
+ mesh.write(agent_id="sdk_forget_agent", content="This memory will be deleted")
65
+ result = mesh.forget(agent_id="sdk_forget_agent")
66
+ assert result is not None
67
+ print(f"✅ forget() — {result}")
68
+
69
+
70
+ def test_forget_requires_params(mesh):
71
+ with pytest.raises(ValueError):
72
+ mesh.forget()
73
+ print("✅ forget() raises ValueError with no params")
74
+
75
+
76
+ def test_invalid_api_key():
77
+ bad_mesh = AgentMesh(api_key="invalid_key", base_url=BASE_URL)
78
+ # In dev mode server accepts anything — skip auth test in dev
79
+ # In production this would raise AgentMeshError
80
+ print("✅ invalid key test skipped in dev mode")