acp-sdk 0.0.1__py3-none-any.whl → 0.0.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.
- acp/server/highlevel/agents/base.py +1 -3
- acp/server/highlevel/agents/templates.py +1 -3
- acp/server/highlevel/context.py +3 -3
- acp/server/highlevel/server.py +6 -6
- acp/server/lowlevel/server.py +36 -25
- acp/shared/memory.py +3 -3
- {acp_sdk-0.0.1.dist-info → acp_sdk-0.0.3.dist-info}/METADATA +2 -2
- {acp_sdk-0.0.1.dist-info → acp_sdk-0.0.3.dist-info}/RECORD +11 -11
- {acp_sdk-0.0.1.dist-info → acp_sdk-0.0.3.dist-info}/WHEEL +0 -0
- {acp_sdk-0.0.1.dist-info → acp_sdk-0.0.3.dist-info}/entry_points.txt +0 -0
- {acp_sdk-0.0.1.dist-info → acp_sdk-0.0.3.dist-info}/licenses/LICENSE +0 -0
@@ -14,9 +14,7 @@ class Agent(BaseModel):
|
|
14
14
|
input: Type[BaseModel] = Field(description="Model for input")
|
15
15
|
output: Type[BaseModel] = Field(description="Model for output")
|
16
16
|
|
17
|
-
run_fn: Callable[[BaseModel, "Context"], Awaitable[BaseModel]] = Field(
|
18
|
-
exclude=True
|
19
|
-
)
|
17
|
+
run_fn: Callable[[BaseModel, "Context"], Awaitable[BaseModel]] = Field(exclude=True)
|
20
18
|
destroy_fn: Callable[["Context"], Awaitable[None]] | None = Field(exclude=True)
|
21
19
|
|
22
20
|
model_config = ConfigDict(extra="allow")
|
@@ -16,8 +16,6 @@ class AgentTemplate(BaseModel):
|
|
16
16
|
input: Type[BaseModel] = Field(description="Model for run input")
|
17
17
|
output: Type[BaseModel] = Field(description="Model for run output")
|
18
18
|
|
19
|
-
create_fn: Callable[[BaseModel, "Context"], Awaitable[Agent]] = Field(
|
20
|
-
exclude=True
|
21
|
-
)
|
19
|
+
create_fn: Callable[[BaseModel, "Context"], Awaitable[Agent]] = Field(exclude=True)
|
22
20
|
|
23
21
|
model_config = ConfigDict(extra="allow")
|
acp/server/highlevel/context.py
CHANGED
@@ -124,9 +124,9 @@ class Context(BaseModel):
|
|
124
124
|
Returns:
|
125
125
|
The resource content as either text or bytes
|
126
126
|
"""
|
127
|
-
assert (
|
128
|
-
|
129
|
-
)
|
127
|
+
assert self._fastmcp is not None, (
|
128
|
+
"Context is not available outside of a request"
|
129
|
+
)
|
130
130
|
return await self._fastmcp.read_resource(uri)
|
131
131
|
|
132
132
|
async def log(
|
acp/server/highlevel/server.py
CHANGED
@@ -467,7 +467,7 @@ class Server:
|
|
467
467
|
config: Type[BaseModel],
|
468
468
|
input: Type[BaseModel],
|
469
469
|
output: Type[BaseModel],
|
470
|
-
**kwargs
|
470
|
+
**kwargs,
|
471
471
|
) -> Callable:
|
472
472
|
"""Decorator to register an agent template.
|
473
473
|
|
@@ -494,7 +494,7 @@ class Server:
|
|
494
494
|
input=input,
|
495
495
|
output=output,
|
496
496
|
create_fn=func,
|
497
|
-
**kwargs
|
497
|
+
**kwargs,
|
498
498
|
)
|
499
499
|
self.add_agent_template(template)
|
500
500
|
return func
|
@@ -513,7 +513,7 @@ class Server:
|
|
513
513
|
configSchema=template.config.model_json_schema(),
|
514
514
|
inputSchema=template.input.model_json_schema(),
|
515
515
|
outputSchema=template.output.model_json_schema(),
|
516
|
-
**(template.model_extra if template.model_extra else {})
|
516
|
+
**(template.model_extra if template.model_extra else {}),
|
517
517
|
)
|
518
518
|
for template in templates
|
519
519
|
]
|
@@ -529,7 +529,7 @@ class Server:
|
|
529
529
|
description: str,
|
530
530
|
input: Type[BaseModel],
|
531
531
|
output: Type[BaseModel],
|
532
|
-
**kwargs
|
532
|
+
**kwargs,
|
533
533
|
) -> Callable:
|
534
534
|
"""Decorator to register an agent.
|
535
535
|
|
@@ -554,7 +554,7 @@ class Server:
|
|
554
554
|
output=output,
|
555
555
|
run_fn=func,
|
556
556
|
destroy_fn=None,
|
557
|
-
**kwargs
|
557
|
+
**kwargs,
|
558
558
|
)
|
559
559
|
self.add_agent(agent=agent)
|
560
560
|
return func
|
@@ -570,7 +570,7 @@ class Server:
|
|
570
570
|
description=agent.description,
|
571
571
|
inputSchema=agent.input.model_json_schema(),
|
572
572
|
outputSchema=agent.output.model_json_schema(),
|
573
|
-
**(agent.model_extra if agent.model_extra else {})
|
573
|
+
**(agent.model_extra if agent.model_extra else {}),
|
574
574
|
)
|
575
575
|
for agent in agents
|
576
576
|
]
|
acp/server/lowlevel/server.py
CHANGED
@@ -68,8 +68,10 @@ import contextvars
|
|
68
68
|
import logging
|
69
69
|
import warnings
|
70
70
|
from collections.abc import Awaitable, Callable
|
71
|
+
from contextlib import AsyncExitStack
|
71
72
|
from typing import Any, Sequence
|
72
73
|
|
74
|
+
import anyio
|
73
75
|
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
|
74
76
|
from pydantic import AnyUrl
|
75
77
|
|
@@ -182,7 +184,7 @@ class Server:
|
|
182
184
|
if types.ListAgentsRequest in self.request_handlers:
|
183
185
|
agents_capability = types.AgentsCapability(
|
184
186
|
templates=types.ListAgentTemplatesRequest in self.request_handlers,
|
185
|
-
listChanged=notification_options.agents_changed
|
187
|
+
listChanged=notification_options.agents_changed,
|
186
188
|
)
|
187
189
|
|
188
190
|
# Set logging capabilities if handler exists
|
@@ -538,30 +540,41 @@ class Server:
|
|
538
540
|
# in-process servers.
|
539
541
|
raise_exceptions: bool = False,
|
540
542
|
):
|
541
|
-
with
|
542
|
-
|
543
|
-
read_stream, write_stream, initialization_options
|
544
|
-
)
|
543
|
+
async with AsyncExitStack() as stack:
|
544
|
+
session = await stack.enter_async_context(
|
545
|
+
ServerSession(read_stream, write_stream, initialization_options)
|
546
|
+
)
|
547
|
+
|
548
|
+
async with anyio.create_task_group() as tg:
|
545
549
|
async for message in session.incoming_messages:
|
546
550
|
logger.debug(f"Received message: {message}")
|
547
551
|
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
552
|
+
tg.start_soon(
|
553
|
+
self._handle_message, message, session, raise_exceptions
|
554
|
+
)
|
555
|
+
|
556
|
+
async def _handle_message(
|
557
|
+
self,
|
558
|
+
message: RequestResponder[types.ClientRequest, types.ServerResult]
|
559
|
+
| types.ClientNotification
|
560
|
+
| Exception,
|
561
|
+
session: ServerSession,
|
562
|
+
raise_exceptions: bool = False,
|
563
|
+
):
|
564
|
+
with warnings.catch_warnings(record=True) as w:
|
565
|
+
match message:
|
566
|
+
case (
|
567
|
+
RequestResponder(request=types.ClientRequest(root=req)) as responder
|
568
|
+
):
|
569
|
+
with responder:
|
570
|
+
await self._handle_request(
|
571
|
+
message, req, session, raise_exceptions
|
564
572
|
)
|
573
|
+
case types.ClientNotification(root=notify):
|
574
|
+
await self._handle_notification(notify)
|
575
|
+
|
576
|
+
for warning in w:
|
577
|
+
logger.info(f"Warning: {warning.category.__name__}: {warning.message}")
|
565
578
|
|
566
579
|
async def _handle_request(
|
567
580
|
self,
|
@@ -614,14 +627,12 @@ class Server:
|
|
614
627
|
assert type(notify) in self.notification_handlers
|
615
628
|
|
616
629
|
handler = self.notification_handlers[type(notify)]
|
617
|
-
logger.debug(
|
618
|
-
f"Dispatching notification of type " f"{type(notify).__name__}"
|
619
|
-
)
|
630
|
+
logger.debug(f"Dispatching notification of type {type(notify).__name__}")
|
620
631
|
|
621
632
|
try:
|
622
633
|
await handler(notify)
|
623
634
|
except Exception as err:
|
624
|
-
logger.error(f"Uncaught exception in notification handler:
|
635
|
+
logger.error(f"Uncaught exception in notification handler: {err}")
|
625
636
|
|
626
637
|
|
627
638
|
async def _ping_handler(request: types.PingRequest) -> types.ServerResult:
|
acp/shared/memory.py
CHANGED
@@ -20,9 +20,9 @@ MessageStream = tuple[
|
|
20
20
|
|
21
21
|
|
22
22
|
@asynccontextmanager
|
23
|
-
async def create_client_server_memory_streams() ->
|
24
|
-
|
25
|
-
|
23
|
+
async def create_client_server_memory_streams() -> AsyncGenerator[
|
24
|
+
tuple[MessageStream, MessageStream], None
|
25
|
+
]:
|
26
26
|
"""
|
27
27
|
Creates a pair of bidirectional memory streams for client-server communication.
|
28
28
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: acp-sdk
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.3
|
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
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
20
|
-
Requires-Python:
|
20
|
+
Requires-Python: <4.0,>=3.10
|
21
21
|
Requires-Dist: anyio>=4.5
|
22
22
|
Requires-Dist: httpx-sse>=0.4
|
23
23
|
Requires-Dist: httpx>=0.27
|
@@ -17,13 +17,13 @@ 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
|
-
acp/server/highlevel/context.py,sha256=
|
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=25hb5pcu1okmiHEohmFZ9pt9XfaP1YlAmr8FGkyQAGQ,24191
|
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
|
-
acp/server/highlevel/agents/base.py,sha256=
|
26
|
-
acp/server/highlevel/agents/templates.py,sha256=
|
25
|
+
acp/server/highlevel/agents/base.py,sha256=Ets5AYbkB8gsRVMKaNjVRBonw6sOtAqmxIAti6emlNE,700
|
26
|
+
acp/server/highlevel/agents/templates.py,sha256=gDfWrsO6UjRLAGaJQYxv_KTp0or5a8SBQvXCYjb4oww,761
|
27
27
|
acp/server/highlevel/prompts/__init__.py,sha256=4BsMxoYolpoxg74xkkkzCFL8vvdkLVJ5cIPNs1ND1Jo,99
|
28
28
|
acp/server/highlevel/prompts/base.py,sha256=m5-CB-Jtu5V5fowml-7IQZDpqa7UmKRHc7Ex2tskmQk,5554
|
29
29
|
acp/server/highlevel/prompts/manager.py,sha256=UjGCo9w1RBcQ8Eo9aVEvLOrzSI9T1r7jEbXuvuklIuc,1489
|
@@ -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=cRzDFKK_tw02eIvW6ie38NH7UXNaxZ2WPtoyX7iaoyI,22605
|
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
|
-
acp/shared/memory.py,sha256=
|
49
|
+
acp/shared/memory.py,sha256=RHEnuOVDkT8LrviEvUS5JGl0qs55DA0jcsiuOg82wa8,2802
|
50
50
|
acp/shared/progress.py,sha256=enn_ZLnIPGS8107_rh7JgKvZXcXBUEv9STZdn84wIw0,1033
|
51
51
|
acp/shared/session.py,sha256=IBVCFAUUfyx3TAzrhoCbLEsr7HCwPmfruVCmLHubcO8,15637
|
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.3.dist-info/METADATA,sha256=xoREdAnkkQwzcyZDhKEvOZB-QTp9AXhheBBUyCqbaVY,1932
|
54
|
+
acp_sdk-0.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
55
|
+
acp_sdk-0.0.3.dist-info/entry_points.txt,sha256=zJgYH5TTBxQ1oBzEg-0RfEk09Te1W2LkqbyoLpFe9CA,42
|
56
|
+
acp_sdk-0.0.3.dist-info/licenses/LICENSE,sha256=aLcXJ7ZsI7zZmq4n0iIQ6KYB3EJMtRJGLr7n514PE30,1100
|
57
|
+
acp_sdk-0.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|