a2a-adapter 0.1.4__py3-none-any.whl → 0.1.5__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.
a2a_adapter/__init__.py CHANGED
@@ -26,7 +26,7 @@ Example:
26
26
  >>> asyncio.run(main())
27
27
  """
28
28
 
29
- __version__ = "0.1.4"
29
+ __version__ = "0.1.5"
30
30
 
31
31
  from .adapter import BaseAgentAdapter
32
32
  from .client import build_agent_app, serve_agent
a2a_adapter/client.py CHANGED
@@ -27,6 +27,7 @@ from a2a.types import (
27
27
  ListTaskPushNotificationConfigResponse,
28
28
  Message,
29
29
  MessageSendParams,
30
+ PushNotificationConfig,
30
31
  SetTaskPushNotificationConfigRequest,
31
32
  SetTaskPushNotificationConfigResponse,
32
33
  Task,
@@ -43,6 +44,11 @@ class AdapterRequestHandler(RequestHandler):
43
44
 
44
45
  This class bridges the gap between our adapter abstraction and the
45
46
  official A2A SDK's RequestHandler protocol.
47
+
48
+ Supports:
49
+ - Basic message send (sync and async)
50
+ - Task get/cancel for async adapters
51
+ - Push notification configuration for adapters that support it
46
52
  """
47
53
 
48
54
  def __init__(self, adapter: BaseAgentAdapter):
@@ -89,23 +95,37 @@ class AdapterRequestHandler(RequestHandler):
89
95
  async for event in self.adapter.handle_stream(params):
90
96
  yield event
91
97
 
92
- # Task-related methods (not supported by default)
98
+ # Task-related methods
93
99
 
94
100
  async def on_get_task(
95
101
  self,
96
102
  params: GetTaskRequest,
97
103
  context: ServerCallContext
98
104
  ) -> GetTaskResponse:
99
- """Get task status - not supported."""
100
- raise ServerError(error=UnsupportedOperationError())
105
+ """Get task status."""
106
+ if not self.adapter.supports_async_tasks():
107
+ raise ServerError(error=UnsupportedOperationError())
108
+
109
+ task = await self.adapter.get_task(params.id)
110
+ if task is None:
111
+ raise ServerError(error=UnsupportedOperationError(message=f"Task {params.id} not found"))
112
+
113
+ return GetTaskResponse(result=task)
101
114
 
102
115
  async def on_cancel_task(
103
116
  self,
104
117
  params: CancelTaskRequest,
105
118
  context: ServerCallContext
106
119
  ) -> CancelTaskResponse:
107
- """Cancel task - not supported."""
108
- raise ServerError(error=UnsupportedOperationError())
120
+ """Cancel task."""
121
+ if not self.adapter.supports_async_tasks():
122
+ raise ServerError(error=UnsupportedOperationError())
123
+
124
+ task = await self.adapter.cancel_task(params.id)
125
+ if task is None:
126
+ raise ServerError(error=UnsupportedOperationError(message=f"Task {params.id} not found"))
127
+
128
+ return CancelTaskResponse(result=task)
109
129
 
110
130
  async def on_resubscribe_to_task(
111
131
  self,
@@ -116,30 +136,47 @@ class AdapterRequestHandler(RequestHandler):
116
136
  raise ServerError(error=UnsupportedOperationError())
117
137
  yield # Make this an async generator
118
138
 
119
- # Push notification methods (not supported by default)
139
+ # Push notification methods
120
140
 
121
141
  async def on_set_task_push_notification_config(
122
142
  self,
123
143
  params: SetTaskPushNotificationConfigRequest,
124
144
  context: ServerCallContext
125
145
  ) -> SetTaskPushNotificationConfigResponse:
126
- """Set push notification config - not supported."""
127
- raise ServerError(error=UnsupportedOperationError())
146
+ """Set push notification config."""
147
+ if not hasattr(self.adapter, 'supports_push_notifications') or not self.adapter.supports_push_notifications():
148
+ raise ServerError(error=UnsupportedOperationError())
149
+
150
+ success = await self.adapter.set_push_notification_config(
151
+ params.taskId,
152
+ params.pushNotificationConfig
153
+ )
154
+ if not success:
155
+ raise ServerError(error=UnsupportedOperationError(message=f"Task {params.taskId} not found"))
156
+
157
+ return SetTaskPushNotificationConfigResponse(result=params.pushNotificationConfig)
128
158
 
129
159
  async def on_get_task_push_notification_config(
130
160
  self,
131
161
  params: GetTaskPushNotificationConfigParams,
132
162
  context: ServerCallContext
133
163
  ) -> GetTaskPushNotificationConfigResponse:
134
- """Get push notification config - not supported."""
135
- raise ServerError(error=UnsupportedOperationError())
164
+ """Get push notification config."""
165
+ if not hasattr(self.adapter, 'supports_push_notifications') or not self.adapter.supports_push_notifications():
166
+ raise ServerError(error=UnsupportedOperationError())
167
+
168
+ config = await self.adapter.get_push_notification_config(params.taskId)
169
+ if config is None:
170
+ raise ServerError(error=UnsupportedOperationError(message=f"No push config for task {params.taskId}"))
171
+
172
+ return GetTaskPushNotificationConfigResponse(result=config)
136
173
 
137
174
  async def on_list_task_push_notification_config(
138
175
  self,
139
176
  params: ListTaskPushNotificationConfigParams,
140
177
  context: ServerCallContext
141
178
  ) -> ListTaskPushNotificationConfigResponse:
142
- """List push notification configs - not supported."""
179
+ """List push notification configs - not supported (would need to track all configs)."""
143
180
  raise ServerError(error=UnsupportedOperationError())
144
181
 
145
182
  async def on_delete_task_push_notification_config(
@@ -147,8 +184,15 @@ class AdapterRequestHandler(RequestHandler):
147
184
  params: DeleteTaskPushNotificationConfigParams,
148
185
  context: ServerCallContext
149
186
  ) -> DeleteTaskPushNotificationConfigResponse:
150
- """Delete push notification config - not supported."""
151
- raise ServerError(error=UnsupportedOperationError())
187
+ """Delete push notification config."""
188
+ if not hasattr(self.adapter, 'supports_push_notifications') or not self.adapter.supports_push_notifications():
189
+ raise ServerError(error=UnsupportedOperationError())
190
+
191
+ success = await self.adapter.delete_push_notification_config(params.taskId)
192
+ if not success:
193
+ raise ServerError(error=UnsupportedOperationError(message=f"No push config for task {params.taskId}"))
194
+
195
+ return DeleteTaskPushNotificationConfigResponse(result={})
152
196
 
153
197
 
154
198
  def build_agent_app(
@@ -7,6 +7,7 @@ This package contains concrete adapter implementations for various agent framewo
7
7
  - LangChain: LLM application framework with LCEL support
8
8
  - LangGraph: Stateful workflow orchestration framework
9
9
  - Callable: Generic Python async function adapter
10
+ - OpenClaw: Personal AI super agent CLI wrapper
10
11
  """
11
12
 
12
13
  __all__ = [
@@ -15,6 +16,7 @@ __all__ = [
15
16
  "LangChainAgentAdapter",
16
17
  "LangGraphAgentAdapter",
17
18
  "CallableAgentAdapter",
19
+ "OpenClawAgentAdapter",
18
20
  ]
19
21
 
20
22
  # Lazy imports to avoid requiring all optional dependencies
@@ -34,4 +36,7 @@ def __getattr__(name: str):
34
36
  elif name == "CallableAgentAdapter":
35
37
  from .callable import CallableAgentAdapter
36
38
  return CallableAgentAdapter
39
+ elif name == "OpenClawAgentAdapter":
40
+ from .openclaw import OpenClawAgentAdapter
41
+ return OpenClawAgentAdapter
37
42
  raise AttributeError(f"module {__name__!r} has no attribute {name!r}")