acp-sdk 0.0.4__py3-none-any.whl → 0.0.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.
@@ -566,9 +566,13 @@ class Server:
566
566
  case (
567
567
  RequestResponder(request=types.ClientRequest(root=req)) as responder
568
568
  ):
569
- with responder:
570
- await self._handle_request(
571
- message, req, session, raise_exceptions
569
+ async with responder:
570
+ responder.task_group.start_soon(
571
+ self._handle_request,
572
+ message,
573
+ req,
574
+ session,
575
+ raise_exceptions,
572
576
  )
573
577
  case types.ClientNotification(root=notify):
574
578
  await self._handle_notification(notify)
acp/server/session.py CHANGED
@@ -126,7 +126,7 @@ class ServerSession(
126
126
  case types.InitializeRequest(params=params):
127
127
  self._initialization_state = InitializationState.Initializing
128
128
  self._client_params = params
129
- with responder:
129
+ async with responder:
130
130
  await responder.respond(
131
131
  types.ServerResult(
132
132
  types.InitializeResult(
acp/shared/session.py CHANGED
@@ -71,27 +71,27 @@ class RequestResponder(Generic[ReceiveRequestT, SendResultT]):
71
71
  self.request = request
72
72
  self._session = session
73
73
  self._completed = False
74
- self._cancel_scope = anyio.CancelScope()
74
+ self.task_group = anyio.create_task_group()
75
75
  self._on_complete = on_complete
76
76
  self._entered = False # Track if we're in a context manager
77
77
 
78
- def __enter__(self) -> "RequestResponder[ReceiveRequestT, SendResultT]":
78
+ async def __aenter__(self) -> "RequestResponder[ReceiveRequestT, SendResultT]":
79
79
  """Enter the context manager, enabling request cancellation tracking."""
80
80
  self._entered = True
81
- self._cancel_scope = anyio.CancelScope()
82
- self._cancel_scope.__enter__()
81
+ self.task_group = anyio.create_task_group()
82
+ await self.task_group.__aenter__()
83
83
  return self
84
84
 
85
- def __exit__(self, exc_type, exc_val, exc_tb) -> None:
85
+ async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
86
86
  """Exit the context manager, performing cleanup and notifying completion."""
87
87
  try:
88
+ if not self.task_group:
89
+ raise RuntimeError("No active cancel scope")
90
+ await self.task_group.__aexit__(exc_type, exc_val, exc_tb)
88
91
  if self._completed:
89
92
  self._on_complete(self)
90
93
  finally:
91
94
  self._entered = False
92
- if not self._cancel_scope:
93
- raise RuntimeError("No active cancel scope")
94
- self._cancel_scope.__exit__(exc_type, exc_val, exc_tb)
95
95
 
96
96
  async def respond(self, response: SendResultT | ErrorData) -> None:
97
97
  """Send a response for this request.
@@ -116,10 +116,10 @@ class RequestResponder(Generic[ReceiveRequestT, SendResultT]):
116
116
  """Cancel this request and mark it as completed."""
117
117
  if not self._entered:
118
118
  raise RuntimeError("RequestResponder must be used as a context manager")
119
- if not self._cancel_scope:
119
+ if not self.task_group:
120
120
  raise RuntimeError("No active cancel scope")
121
121
 
122
- self._cancel_scope.cancel()
122
+ self.task_group.cancel_scope.cancel()
123
123
  self._completed = True # Mark as completed so it's removed from in_flight
124
124
  # Send an error response to indicate cancellation
125
125
  await self._session._send_response(
@@ -133,7 +133,9 @@ class RequestResponder(Generic[ReceiveRequestT, SendResultT]):
133
133
 
134
134
  @property
135
135
  def cancelled(self) -> bool:
136
- return self._cancel_scope is not None and self._cancel_scope.cancel_called
136
+ return (
137
+ self.task_group is not None and self.task_group.cancel_scope.cancel_called
138
+ )
137
139
 
138
140
 
139
141
  class BaseSession(
@@ -203,6 +205,7 @@ class BaseSession(
203
205
  self,
204
206
  request: SendRequestT,
205
207
  result_type: type[ReceiveResultT],
208
+ request_id: RequestId | None = None,
206
209
  ) -> ReceiveResultT:
207
210
  """
208
211
  Sends a request and wait for a response. Raises an McpError if the
@@ -212,8 +215,9 @@ class BaseSession(
212
215
  instead.
213
216
  """
214
217
 
215
- request_id = self._request_id
216
- self._request_id = request_id + 1
218
+ if request_id is None:
219
+ request_id = self._request_id
220
+ self._request_id = request_id + 1
217
221
 
218
222
  response_stream, response_stream_reader = anyio.create_memory_object_stream[
219
223
  JSONRPCResponse | JSONRPCError
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: acp-sdk
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Agent Communication Protocol SDK
5
5
  Project-URL: Homepage, https://github.com/i-am-bee/beeai
6
6
  Project-URL: Repository, https://github.com/i-am-bee/beeai
@@ -12,7 +12,7 @@ acp/client/stdio.py,sha256=f4Q8pmXCHr14tMfyjWuMQ5AoT2F6rvnY_gcqLaa4BvY,4686
12
12
  acp/server/__init__.py,sha256=Y0b-MWN_eAL9rOye8OxUt9UUZguWBix4yEdJScXbYNU,95
13
13
  acp/server/__main__.py,sha256=Rf4EUZuiP6AqgMbsw9CvyA4nUmJcKTq1h54GWLAndNY,1328
14
14
  acp/server/models.py,sha256=XqJzNfbleQJ_Wj-fglgZrkQEK93EZ0dMg8DeANeHygQ,341
15
- acp/server/session.py,sha256=xRrrtTnXcZjlL6C1JYpZGQebJVzw4kKKeHWvs3HADTE,11438
15
+ acp/server/session.py,sha256=W15GjzDsUMPKoKSR-vt2hRJm-WTef1OU_8aQhYiAoMU,11444
16
16
  acp/server/sse.py,sha256=hGdtFOkUlZJOoglI0UQYxz6KyZnaf2coHeBuHytCi7I,6716
17
17
  acp/server/stdio.py,sha256=QEscVVsH4h9G4e-NWsjl7_US0pCCPAzwR8-xfRbjads,2889
18
18
  acp/server/websocket.py,sha256=5sw6-64ES7rSLQ7UfY5aXSOnh16B3HWK2410kiDcxcU,2225
@@ -42,16 +42,16 @@ acp/server/highlevel/utilities/logging.py,sha256=07rXwvLf9Yd0EJCeu5bFlbXt-qr94Aq
42
42
  acp/server/highlevel/utilities/types.py,sha256=OR1JbgpRpGf19_-DOhwNr-OGPC-rCz1FLd8YBa4XqCc,1760
43
43
  acp/server/lowlevel/__init__.py,sha256=mS7slrVoWzHMYqDHDIJ7oRZxwPZG_I63UVQiJN311YY,93
44
44
  acp/server/lowlevel/helper_types.py,sha256=LmzGNx9FU258TKDyKjwfzH_KOnH4Mkk_k8i9EIFmN7Y,189
45
- acp/server/lowlevel/server.py,sha256=cRzDFKK_tw02eIvW6ie38NH7UXNaxZ2WPtoyX7iaoyI,22605
45
+ acp/server/lowlevel/server.py,sha256=4kHco_HLGvjC0Gy28FR8jnMs2b7cVsfJ_bo1C9jY7CY,22751
46
46
  acp/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  acp/shared/context.py,sha256=sc81CXNrn3OX_yX84nBfnGLvEHBUY9-rIpdb4S6mGus,350
48
48
  acp/shared/exceptions.py,sha256=gtaybYun_cRp7ZHoxV4iiorN8Dn_yUoj1-fpeMOnM2Y,316
49
49
  acp/shared/memory.py,sha256=RHEnuOVDkT8LrviEvUS5JGl0qs55DA0jcsiuOg82wa8,2802
50
50
  acp/shared/progress.py,sha256=enn_ZLnIPGS8107_rh7JgKvZXcXBUEv9STZdn84wIw0,1033
51
- acp/shared/session.py,sha256=IBVCFAUUfyx3TAzrhoCbLEsr7HCwPmfruVCmLHubcO8,15637
51
+ acp/shared/session.py,sha256=VI60P5ecaYQtdllMHpd6uZ3yggTxyGVYRaCKXfpIsm8,15784
52
52
  acp/shared/version.py,sha256=si_GMtVN2H0Y3Rn4QNf8u2V0kZRTzzlMHuCWqDDDK1s,106
53
- acp_sdk-0.0.4.dist-info/METADATA,sha256=gzwK7QSN26Odr4ZWgbGM8twXZc5I-g6gM3BJKONqgQE,1932
54
- acp_sdk-0.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
55
- acp_sdk-0.0.4.dist-info/entry_points.txt,sha256=zJgYH5TTBxQ1oBzEg-0RfEk09Te1W2LkqbyoLpFe9CA,42
56
- acp_sdk-0.0.4.dist-info/licenses/LICENSE,sha256=aLcXJ7ZsI7zZmq4n0iIQ6KYB3EJMtRJGLr7n514PE30,1100
57
- acp_sdk-0.0.4.dist-info/RECORD,,
53
+ acp_sdk-0.0.5.dist-info/METADATA,sha256=hW9vaZ2xe2134yAnjqt_UMm3u7oAGwFIIcTgYqzgcEw,1932
54
+ acp_sdk-0.0.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
55
+ acp_sdk-0.0.5.dist-info/entry_points.txt,sha256=zJgYH5TTBxQ1oBzEg-0RfEk09Te1W2LkqbyoLpFe9CA,42
56
+ acp_sdk-0.0.5.dist-info/licenses/LICENSE,sha256=aLcXJ7ZsI7zZmq4n0iIQ6KYB3EJMtRJGLr7n514PE30,1100
57
+ acp_sdk-0.0.5.dist-info/RECORD,,