smarta2a 0.2.3__py3-none-any.whl → 0.2.4__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.
File without changes
File without changes
@@ -0,0 +1 @@
1
+ curl -X POST -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 1, "method": “tasks/send”, "params": {"id": "test-task-1","message": {"role": "user","parts": [{"type": "text", "text": "Test message"}]}} }' http://localhost:8000/
@@ -0,0 +1,37 @@
1
+ from smarta2a.server import SmartA2A
2
+ from smarta2a.utils.types import A2AResponse, TaskStatus, TaskState, TextPart, FileContent, FilePart
3
+
4
+ app = SmartA2A("EchoServer")
5
+
6
+ @app.on_send_task()
7
+ def handle_task(request):
8
+ """Echo the input text back as a completed task"""
9
+ input_text = request.content[0].text
10
+ #return f"Response to task: {input_text}"
11
+ return A2AResponse(
12
+ content=[TextPart(type="text", text="Response to task: " + input_text), FilePart(type="file", file=FileContent(name="test.txt", bytes="test"))],
13
+ status="working"
14
+ )
15
+
16
+ @app.on_send_subscribe_task()
17
+ async def handle_subscribe_task(request):
18
+ """Subscribe to the task"""
19
+ input_text = request.content[0].text
20
+ yield f"First response to the task: {input_text}"
21
+ yield f"Second response to the task: {input_text}"
22
+ yield f"Third response to the task: {input_text}"
23
+
24
+ @app.task_get()
25
+ def handle_get_task(request):
26
+ """Get the task"""
27
+ return f"Task: {request.id}"
28
+
29
+ @app.task_cancel()
30
+ def handle_cancel_task(request):
31
+ """Cancel the task"""
32
+ return f"Task cancelled: {request.id}"
33
+
34
+
35
+
36
+
37
+
smarta2a/server/server.py CHANGED
@@ -79,8 +79,11 @@ class SmartA2A:
79
79
  "reload": False
80
80
  }
81
81
  self.task_builder = TaskBuilder(default_status=TaskState.COMPLETED)
82
+
83
+ # Add this method to delegate ASGI calls
84
+ async def __call__(self, scope, receive, send):
85
+ return await self.app(scope, receive, send)
82
86
 
83
-
84
87
  def on_send_task(self):
85
88
  def decorator(func: Callable[[SendTaskRequest, Optional[StateData]], Any]) -> Callable:
86
89
  self.registry.register("tasks/send", func)
@@ -447,7 +450,7 @@ class SmartA2A:
447
450
  task = self.task_builder.build(
448
451
  content=raw_result,
449
452
  task_id=request.params.id,
450
- metadata=request.params.metadata or {}
453
+ metadata=getattr(raw_result, "metadata", {}) or {}
451
454
  )
452
455
 
453
456
  return self._finalize_task_response(request, task)
@@ -491,24 +494,26 @@ class SmartA2A:
491
494
  try:
492
495
  raw_result = handler(request)
493
496
 
497
+ cancel_task_builder = TaskBuilder(default_status=TaskState.CANCELED)
494
498
  # Handle direct CancelTaskResponse returns
495
499
  if isinstance(raw_result, CancelTaskResponse):
496
500
  return self._validate_response_id(raw_result, request)
497
501
 
498
502
  # Handle A2AStatus returns
499
503
  if isinstance(raw_result, A2AStatus):
500
- task = self.task_builder.normalize_from_status(
504
+ task = cancel_task_builder.normalize_from_status(
501
505
  status=raw_result.status,
502
506
  task_id=request.params.id,
503
- metadata=raw_result.metadata or {}
507
+ metadata=getattr(raw_result, "metadata", {}) or {}
504
508
  )
505
509
  else:
506
510
  # Existing processing for other return types
507
- task = self.task_builder.build(
511
+ task = cancel_task_builder.build(
508
512
  content=raw_result,
509
513
  task_id=request.params.id,
510
- metadata=raw_result.metadata or {}
514
+ metadata=getattr(raw_result, "metadata", {}) or {}
511
515
  )
516
+ print(task)
512
517
 
513
518
  # Final validation and packaging
514
519
  return self._finalize_cancel_response(request, task)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smarta2a
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
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
@@ -6,6 +6,10 @@ smarta2a/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  smarta2a/client/a2a_client.py,sha256=Tixof6e2EXrGbShSJls_S009i9VbO9QizyCDzbzSISE,9890
7
7
  smarta2a/client/smart_mcp_client.py,sha256=-P_qwY3lnvL2uF-4e4ZdL3U0hyqMgVrD_u2cfhugQpc,2413
8
8
  smarta2a/client/tools_manager.py,sha256=bTbVwxR3hYsbQ87ClaX1cnswJ34ZAEeZ0Xi8N5q47Q0,2247
9
+ smarta2a/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ smarta2a/examples/echo_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ smarta2a/examples/echo_server/curl.txt,sha256=MYBbAgrU3PeCsksrrBc0xgaTD5Dro7xiTsCUz8Ocvt8,247
12
+ smarta2a/examples/echo_server/main.py,sha256=PmS29F9PVL9qvtLSLuaXGHu2A5zyDoaPav5-udKGxJc,1107
9
13
  smarta2a/history_update_strategies/__init__.py,sha256=x5WtiE9rG5ze8d8hA6E6wJOciBhWHa_ZgGgoIAZcXEQ,213
10
14
  smarta2a/history_update_strategies/append_strategy.py,sha256=j7Qbhs69Wwr-HBLB8GJ3-mEPaBSHiBV2xz9ZZi86k2w,312
11
15
  smarta2a/history_update_strategies/history_update_strategy.py,sha256=n2sfIGu8ztKI7gJTwRX26m4tZr28B8Xdhrk6RlBFlI8,373
@@ -14,7 +18,7 @@ smarta2a/model_providers/base_llm_provider.py,sha256=6QjTUjYEnvHZji4_VWZz6CvLYKL
14
18
  smarta2a/model_providers/openai_provider.py,sha256=bLNWlsrrSFTXxbKsTX_xXfJFuzfWmndKRKqCy0h6ZB8,10830
15
19
  smarta2a/server/__init__.py,sha256=f2X454Ll4vJc02V4JLJHTN-h8u0TBm4d_FkiO4t686U,53
16
20
  smarta2a/server/handler_registry.py,sha256=OVRG5dTvxB7qUNXgsqWxVNxIyRljUShSYxb1gtbi5XM,820
17
- smarta2a/server/server.py,sha256=nqMsMeGJEvkj2kaF9U7yRnYAtj07vPCkQOdQALmaCws,31782
21
+ smarta2a/server/server.py,sha256=IOQCsGFSvI2sKoX2tcrJurxGFMCpUFgjOL9OmZEMSnk,32090
18
22
  smarta2a/server/state_manager.py,sha256=Uc4BNr2kQvi7MAEh3CmHsKV2bP-Q8bYbGADQ35iHmZo,1350
19
23
  smarta2a/server/subscription_service.py,sha256=fWqNNY0xmRksc_SZl4xt5fOPtZTQacfzou1-RMyaEd4,5188
20
24
  smarta2a/server/task_service.py,sha256=TXVnFeS9ofAqH2z_7BOfk5uDmoZKv9irHHQSIuurI70,7650
@@ -26,7 +30,7 @@ smarta2a/utils/prompt_helpers.py,sha256=jLETieoeBJLQXcGzwFeoKT5b2pS4tJ5770lPLImt
26
30
  smarta2a/utils/task_builder.py,sha256=wqSyfVHNTaXuGESu09dhlaDi7D007gcN3-8tH-nPQ40,5159
27
31
  smarta2a/utils/task_request_builder.py,sha256=6cOGOqj2Rg43xWM03GRJQzlIZHBptsMCJRp7oD-TDAQ,3362
28
32
  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,,
33
+ smarta2a-0.2.4.dist-info/METADATA,sha256=CJ_lycEMRsnb78GaiRerGm0vy1u07yfXoGPO89Ya5SA,2726
34
+ smarta2a-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
+ smarta2a-0.2.4.dist-info/licenses/LICENSE,sha256=ECMEVHuFkvpEmH-_A9HSxs_UnnsUqpCkiAYNHPCf2z0,1078
36
+ smarta2a-0.2.4.dist-info/RECORD,,