acp-sdk 0.0.3__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.
- acp/server/highlevel/server.py +2 -1
- acp/server/lowlevel/server.py +7 -3
- acp/server/session.py +1 -1
- acp/shared/session.py +17 -13
- {acp_sdk-0.0.3.dist-info → acp_sdk-0.0.5.dist-info}/METADATA +1 -1
- {acp_sdk-0.0.3.dist-info → acp_sdk-0.0.5.dist-info}/RECORD +9 -9
- {acp_sdk-0.0.3.dist-info → acp_sdk-0.0.5.dist-info}/WHEEL +0 -0
- {acp_sdk-0.0.3.dist-info → acp_sdk-0.0.5.dist-info}/entry_points.txt +0 -0
- {acp_sdk-0.0.3.dist-info → acp_sdk-0.0.5.dist-info}/licenses/LICENSE +0 -0
acp/server/highlevel/server.py
CHANGED
@@ -613,7 +613,7 @@ class Server:
|
|
613
613
|
self._mcp_server.create_initialization_options(),
|
614
614
|
)
|
615
615
|
|
616
|
-
async def run_sse_async(self) -> None:
|
616
|
+
async def run_sse_async(self, **uvicorn_kwargs) -> None:
|
617
617
|
"""Run the server using SSE transport."""
|
618
618
|
from starlette.applications import Starlette
|
619
619
|
from starlette.routing import Mount, Route
|
@@ -643,6 +643,7 @@ class Server:
|
|
643
643
|
host=self.settings.host,
|
644
644
|
port=self.settings.port,
|
645
645
|
log_level=self.settings.log_level.lower(),
|
646
|
+
**uvicorn_kwargs,
|
646
647
|
)
|
647
648
|
server = uvicorn.Server(config)
|
648
649
|
await server.serve()
|
acp/server/lowlevel/server.py
CHANGED
@@ -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
|
-
|
571
|
-
|
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.
|
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
|
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.
|
82
|
-
self.
|
81
|
+
self.task_group = anyio.create_task_group()
|
82
|
+
await self.task_group.__aenter__()
|
83
83
|
return self
|
84
84
|
|
85
|
-
def
|
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.
|
119
|
+
if not self.task_group:
|
120
120
|
raise RuntimeError("No active cancel scope")
|
121
121
|
|
122
|
-
self.
|
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
|
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
|
216
|
-
|
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
|
@@ -12,14 +12,14 @@ 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=
|
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
|
19
19
|
acp/server/highlevel/__init__.py,sha256=zpNfKzPtHeuOT74iaoT1938XpXurH82E_NJEg1n-p4E,247
|
20
20
|
acp/server/highlevel/context.py,sha256=1vEoiNhJQ4khbS1Ln5FAFj6rqPsXfiUB47-nDzYK0Is,5645
|
21
21
|
acp/server/highlevel/exceptions.py,sha256=FQhduu4gNAGIfpW9Twx4LsN8UR2KONdxmubZDbXNDKg,506
|
22
|
-
acp/server/highlevel/server.py,sha256=
|
22
|
+
acp/server/highlevel/server.py,sha256=t82jPgqCm7YZfcxIaeCkLDXVXxUgpPRJJ2e6MtA2baA,24239
|
23
23
|
acp/server/highlevel/agents/__init__.py,sha256=iahXO9_-1Fm0_6HcaFwcgiHTvY3v83GAVzWvVaTFOog,155
|
24
24
|
acp/server/highlevel/agents/agent_manager.py,sha256=FYRXE-RFWWlkbci8GfF1XS_n5CouGXSdvCw0jBbfcHo,3767
|
25
25
|
acp/server/highlevel/agents/base.py,sha256=Ets5AYbkB8gsRVMKaNjVRBonw6sOtAqmxIAti6emlNE,700
|
@@ -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=
|
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=
|
51
|
+
acp/shared/session.py,sha256=VI60P5ecaYQtdllMHpd6uZ3yggTxyGVYRaCKXfpIsm8,15784
|
52
52
|
acp/shared/version.py,sha256=si_GMtVN2H0Y3Rn4QNf8u2V0kZRTzzlMHuCWqDDDK1s,106
|
53
|
-
acp_sdk-0.0.
|
54
|
-
acp_sdk-0.0.
|
55
|
-
acp_sdk-0.0.
|
56
|
-
acp_sdk-0.0.
|
57
|
-
acp_sdk-0.0.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|