smarta2a 0.2.1__py3-none-any.whl → 0.2.3__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.
Files changed (33) hide show
  1. smarta2a/__init__.py +4 -4
  2. smarta2a/agent/a2a_agent.py +38 -0
  3. smarta2a/agent/a2a_mcp_server.py +37 -0
  4. smarta2a/archive/mcp_client.py +86 -0
  5. smarta2a/client/__init__.py +0 -0
  6. smarta2a/client/a2a_client.py +267 -0
  7. smarta2a/client/smart_mcp_client.py +60 -0
  8. smarta2a/client/tools_manager.py +58 -0
  9. smarta2a/history_update_strategies/__init__.py +8 -0
  10. smarta2a/history_update_strategies/append_strategy.py +10 -0
  11. smarta2a/history_update_strategies/history_update_strategy.py +15 -0
  12. smarta2a/model_providers/__init__.py +5 -0
  13. smarta2a/model_providers/base_llm_provider.py +15 -0
  14. smarta2a/model_providers/openai_provider.py +281 -0
  15. smarta2a/server/__init__.py +3 -0
  16. smarta2a/server/handler_registry.py +23 -0
  17. smarta2a/{server.py → server/server.py} +224 -254
  18. smarta2a/server/state_manager.py +34 -0
  19. smarta2a/server/subscription_service.py +109 -0
  20. smarta2a/server/task_service.py +155 -0
  21. smarta2a/state_stores/__init__.py +8 -0
  22. smarta2a/state_stores/base_state_store.py +20 -0
  23. smarta2a/state_stores/inmemory_state_store.py +21 -0
  24. smarta2a/utils/__init__.py +32 -0
  25. smarta2a/utils/prompt_helpers.py +38 -0
  26. smarta2a/utils/task_builder.py +153 -0
  27. smarta2a/utils/task_request_builder.py +114 -0
  28. smarta2a/{types.py → utils/types.py} +62 -2
  29. {smarta2a-0.2.1.dist-info → smarta2a-0.2.3.dist-info}/METADATA +13 -7
  30. smarta2a-0.2.3.dist-info/RECORD +32 -0
  31. smarta2a-0.2.1.dist-info/RECORD +0 -7
  32. {smarta2a-0.2.1.dist-info → smarta2a-0.2.3.dist-info}/WHEEL +0 -0
  33. {smarta2a-0.2.1.dist-info → smarta2a-0.2.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
1
- from typing import Union, Any
1
+ from typing import Union, Any, Dict
2
2
  from pydantic import BaseModel, Field, TypeAdapter
3
3
  from typing import Literal, List, Annotated, Optional
4
4
  from datetime import datetime
@@ -57,7 +57,7 @@ Part = Annotated[Union[TextPart, FilePart, DataPart], Field(discriminator="type"
57
57
 
58
58
 
59
59
  class Message(BaseModel):
60
- role: Literal["user", "agent"]
60
+ role: Literal["user", "agent", "system"] # Added system role for system messages
61
61
  parts: List[Part]
62
62
  metadata: dict[str, Any] | None = None
63
63
 
@@ -357,6 +357,59 @@ class AgentCard(BaseModel):
357
357
  defaultOutputModes: List[str] = ["text"]
358
358
  skills: List[AgentSkill]
359
359
 
360
+ def pretty_print(self, include_separators: bool = False) -> str:
361
+ """Returns formatted string, optionally wrapped in separators"""
362
+ output = []
363
+ output.append(f"Name: {self.name}")
364
+
365
+ if self.description:
366
+ output.append(f"Description: {self.description}")
367
+
368
+ output.append(f"URL: {self.url}")
369
+
370
+ if self.provider:
371
+ output.append(f"Provider Organization: {self.provider.organization}")
372
+
373
+ # Capabilities handling
374
+ capabilities = []
375
+ if self.capabilities.streaming:
376
+ capabilities.append("Streaming")
377
+ if self.capabilities.pushNotifications:
378
+ capabilities.append("Push Notifications")
379
+ if self.capabilities.stateTransitionHistory:
380
+ capabilities.append("State Transition History")
381
+ output.append("Capabilities: " + ", ".join(capabilities))
382
+
383
+ # Skills handling
384
+ skills_output = ["Skills:"]
385
+ for skill in self.skills:
386
+ skills_output.append(f" {skill.name} [{skill.id}]")
387
+
388
+ if skill.description:
389
+ skills_output.append(f" Description: {skill.description}")
390
+
391
+ if skill.tags:
392
+ skills_output.append(f" Tags: {', '.join(skill.tags)}")
393
+
394
+ if skill.examples:
395
+ skills_output.append(" Examples:")
396
+ skills_output.extend([f" - {ex}" for ex in skill.examples])
397
+
398
+ if skill.inputModes:
399
+ skills_output.append(f" Input Modes: {', '.join(skill.inputModes)}")
400
+
401
+ if skill.outputModes:
402
+ skills_output.append(f" Output Modes: {', '.join(skill.outputModes)}")
403
+
404
+ skills_output.append("")
405
+
406
+ output.extend(skills_output)
407
+ result = "\n".join(output).strip()
408
+
409
+ if include_separators:
410
+ return f"---\n{result}\n---"
411
+ return result
412
+
360
413
 
361
414
  class A2AClientError(Exception):
362
415
  pass
@@ -388,6 +441,8 @@ They are used to help with the implementation of the server.
388
441
  class A2AResponse(BaseModel):
389
442
  status: Union[TaskStatus, str]
390
443
  content: Union[str, List[Any], Part, Artifact, List[Part], List[Artifact]]
444
+ sessionId: Optional[str] = None
445
+ metadata: Optional[dict[str, Any]] = None
391
446
 
392
447
  @model_validator(mode="after")
393
448
  def validate_state(self) -> 'A2AResponse':
@@ -422,3 +477,8 @@ class A2AStreamResponse(BaseModel):
422
477
  append: bool = False
423
478
  final: bool = False
424
479
  metadata: dict[str, Any] | None = None
480
+
481
+ class StateData(BaseModel):
482
+ sessionId: str
483
+ history: List[Message]
484
+ metadata: Dict[str, Any]
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smarta2a
3
- Version: 0.2.1
4
- Summary: A Python package for creating servers and clients following Google's Agent2Agent protocol
3
+ Version: 0.2.3
4
+ Summary: A simple Python framework (built on top of FastAPI) for creating Agents following Google's Agent2Agent protocol
5
5
  Project-URL: Homepage, https://github.com/siddharthsma/smarta2a
6
6
  Project-URL: Bug Tracker, https://github.com/siddharthsma/smarta2a/issues
7
7
  Author-email: Siddharth Ambegaonkar <siddharthsma@gmail.com>
@@ -10,10 +10,16 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.8
13
- Requires-Dist: fastapi
14
- Requires-Dist: pydantic
15
- Requires-Dist: sse-starlette
16
- Requires-Dist: uvicorn
13
+ Requires-Dist: anyio>=4.9.0
14
+ Requires-Dist: fastapi>=0.115.12
15
+ Requires-Dist: httpx>=0.28.1
16
+ Requires-Dist: mcp>=0.1.0
17
+ Requires-Dist: openai>=1.0.0
18
+ Requires-Dist: pydantic>=2.11.3
19
+ Requires-Dist: sse-starlette>=2.2.1
20
+ Requires-Dist: starlette>=0.46.2
21
+ Requires-Dist: typing-extensions>=4.13.2
22
+ Requires-Dist: uvicorn>=0.34.1
17
23
  Description-Content-Type: text/markdown
18
24
 
19
25
  # SmartA2A
@@ -45,7 +51,7 @@ pip install smarta2a
45
51
  ## Simple Echo Server Implementation
46
52
 
47
53
  ```python
48
- from smarta2a import SmartA2A
54
+ from smarta2a.server import SmartA2A
49
55
 
50
56
  app = SmartA2A("EchoServer")
51
57
 
@@ -0,0 +1,32 @@
1
+ smarta2a/__init__.py,sha256=T_EECYqWrxshix0FbgUv22zlKRX22HFU-HKXcYTOb3w,175
2
+ smarta2a/agent/a2a_agent.py,sha256=LrqWNgZra_dSHGmLZubhFMjZCgZ1BYdroXGuFFzv8Rk,1183
3
+ smarta2a/agent/a2a_mcp_server.py,sha256=X_mxkgYgCA_dSNtCvs0rSlOoWYc-8d3Qyxv0e-a7NKY,1015
4
+ smarta2a/archive/mcp_client.py,sha256=Fj64Kw5HFXZ0SHImWTsxTHIeP-3DgvP1nRiY_Jdgm0Q,3305
5
+ smarta2a/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ smarta2a/client/a2a_client.py,sha256=Tixof6e2EXrGbShSJls_S009i9VbO9QizyCDzbzSISE,9890
7
+ smarta2a/client/smart_mcp_client.py,sha256=-P_qwY3lnvL2uF-4e4ZdL3U0hyqMgVrD_u2cfhugQpc,2413
8
+ smarta2a/client/tools_manager.py,sha256=bTbVwxR3hYsbQ87ClaX1cnswJ34ZAEeZ0Xi8N5q47Q0,2247
9
+ smarta2a/history_update_strategies/__init__.py,sha256=x5WtiE9rG5ze8d8hA6E6wJOciBhWHa_ZgGgoIAZcXEQ,213
10
+ smarta2a/history_update_strategies/append_strategy.py,sha256=j7Qbhs69Wwr-HBLB8GJ3-mEPaBSHiBV2xz9ZZi86k2w,312
11
+ smarta2a/history_update_strategies/history_update_strategy.py,sha256=n2sfIGu8ztKI7gJTwRX26m4tZr28B8Xdhrk6RlBFlI8,373
12
+ smarta2a/model_providers/__init__.py,sha256=2FhblAUiwG9Xv27yEpuuz0VrnIZ-rlpgIuPwm-UIX5U,147
13
+ smarta2a/model_providers/base_llm_provider.py,sha256=6QjTUjYEnvHZji4_VWZz6CvLYKLyutxRUfIeH3seQg4,424
14
+ smarta2a/model_providers/openai_provider.py,sha256=bLNWlsrrSFTXxbKsTX_xXfJFuzfWmndKRKqCy0h6ZB8,10830
15
+ smarta2a/server/__init__.py,sha256=f2X454Ll4vJc02V4JLJHTN-h8u0TBm4d_FkiO4t686U,53
16
+ smarta2a/server/handler_registry.py,sha256=OVRG5dTvxB7qUNXgsqWxVNxIyRljUShSYxb1gtbi5XM,820
17
+ smarta2a/server/server.py,sha256=nqMsMeGJEvkj2kaF9U7yRnYAtj07vPCkQOdQALmaCws,31782
18
+ smarta2a/server/state_manager.py,sha256=Uc4BNr2kQvi7MAEh3CmHsKV2bP-Q8bYbGADQ35iHmZo,1350
19
+ smarta2a/server/subscription_service.py,sha256=fWqNNY0xmRksc_SZl4xt5fOPtZTQacfzou1-RMyaEd4,5188
20
+ smarta2a/server/task_service.py,sha256=TXVnFeS9ofAqH2z_7BOfk5uDmoZKv9irHHQSIuurI70,7650
21
+ smarta2a/state_stores/__init__.py,sha256=vafxAqpwvag_cYFH2XKGk3DPmJIWJr4Ioey30yLFkVQ,220
22
+ smarta2a/state_stores/base_state_store.py,sha256=LFI-LThPLf7M9z_CcXWCswajxMAtMx9tMFFVhZU0fM8,521
23
+ smarta2a/state_stores/inmemory_state_store.py,sha256=MgFGc7HxccrBxEqhVqKJ3bV-RnV1koU6iJd5m3rhhjA,682
24
+ smarta2a/utils/__init__.py,sha256=5db5VgDGgbMUGEF-xuyaC3qrgRQkUE9WAITkFSiNqSA,702
25
+ smarta2a/utils/prompt_helpers.py,sha256=jLETieoeBJLQXcGzwFeoKT5b2pS4tJ5770lPLImtKLo,1439
26
+ smarta2a/utils/task_builder.py,sha256=wqSyfVHNTaXuGESu09dhlaDi7D007gcN3-8tH-nPQ40,5159
27
+ smarta2a/utils/task_request_builder.py,sha256=6cOGOqj2Rg43xWM03GRJQzlIZHBptsMCJRp7oD-TDAQ,3362
28
+ smarta2a/utils/types.py,sha256=mtkn78SrXyzjnOw6OBcTHlnhGfHgxlhKxJsRAVlUaEQ,13078
29
+ smarta2a-0.2.3.dist-info/METADATA,sha256=XJBiT_AOoaltJAppDSd0D0y-bNKTwqxOuQiymgDj_Vs,2726
30
+ smarta2a-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ smarta2a-0.2.3.dist-info/licenses/LICENSE,sha256=ECMEVHuFkvpEmH-_A9HSxs_UnnsUqpCkiAYNHPCf2z0,1078
32
+ smarta2a-0.2.3.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- smarta2a/__init__.py,sha256=f_RqeaAHiBXO0O8n2kR8EBLGM3ezNwmR-CV-xHeOHLM,182
2
- smarta2a/server.py,sha256=lFUlAz4TEeEXCs2bgJmMTN7JpZTwYEKXyt4KWEQwS6U,30915
3
- smarta2a/types.py,sha256=_UuFtOsnHIIqfQ2m_FiIBBp141iYmhpPGgxE0jmHSHg,10807
4
- smarta2a-0.2.1.dist-info/METADATA,sha256=H4os9rBnBzByJI1FWr7vYW2w8Or8PInU7XtmwsHCIcY,2478
5
- smarta2a-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- smarta2a-0.2.1.dist-info/licenses/LICENSE,sha256=ECMEVHuFkvpEmH-_A9HSxs_UnnsUqpCkiAYNHPCf2z0,1078
7
- smarta2a-0.2.1.dist-info/RECORD,,