acp-sdk 0.2.2__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.
- acp_sdk/client/client.py +4 -1
- acp_sdk/instrumentation.py +7 -0
- acp_sdk/server/bundle.py +11 -4
- acp_sdk/server/telemetry.py +0 -4
- {acp_sdk-0.2.2.dist-info → acp_sdk-0.2.4.dist-info}/METADATA +1 -1
- {acp_sdk-0.2.2.dist-info → acp_sdk-0.2.4.dist-info}/RECORD +7 -6
- {acp_sdk-0.2.2.dist-info → acp_sdk-0.2.4.dist-info}/WHEEL +0 -0
acp_sdk/client/client.py
CHANGED
@@ -9,6 +9,7 @@ from httpx_sse import EventSource, aconnect_sse
|
|
9
9
|
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
|
10
10
|
from pydantic import TypeAdapter
|
11
11
|
|
12
|
+
from acp_sdk.instrumentation import get_tracer
|
12
13
|
from acp_sdk.models import (
|
13
14
|
ACPError,
|
14
15
|
Agent,
|
@@ -62,7 +63,9 @@ class Client:
|
|
62
63
|
|
63
64
|
@asynccontextmanager
|
64
65
|
async def session(self, session_id: SessionId | None = None) -> AsyncGenerator[Self]:
|
65
|
-
|
66
|
+
session_id = session_id or uuid.uuid4()
|
67
|
+
with get_tracer().start_as_current_span("session", attributes={"acp.session": str(session_id)}):
|
68
|
+
yield Client(client=self._client, session_id=session_id, instrument=False)
|
66
69
|
|
67
70
|
async def agents(self) -> AsyncIterator[Agent]:
|
68
71
|
response = await self._client.get("/agents")
|
acp_sdk/server/bundle.py
CHANGED
@@ -5,15 +5,20 @@ from concurrent.futures import ThreadPoolExecutor
|
|
5
5
|
|
6
6
|
from pydantic import ValidationError
|
7
7
|
|
8
|
+
from acp_sdk.instrumentation import get_tracer
|
8
9
|
from acp_sdk.models import (
|
10
|
+
ACPError,
|
9
11
|
AnyModel,
|
10
12
|
AwaitRequest,
|
11
13
|
AwaitResume,
|
12
14
|
Error,
|
15
|
+
ErrorCode,
|
13
16
|
Event,
|
14
17
|
GenericEvent,
|
15
18
|
Message,
|
19
|
+
MessageCompletedEvent,
|
16
20
|
MessageCreatedEvent,
|
21
|
+
MessagePart,
|
17
22
|
MessagePartEvent,
|
18
23
|
Run,
|
19
24
|
RunAwaitingEvent,
|
@@ -24,11 +29,8 @@ from acp_sdk.models import (
|
|
24
29
|
RunInProgressEvent,
|
25
30
|
RunStatus,
|
26
31
|
)
|
27
|
-
from acp_sdk.models.errors import ErrorCode
|
28
|
-
from acp_sdk.models.models import MessageCompletedEvent, MessagePart
|
29
32
|
from acp_sdk.server.agent import Agent
|
30
33
|
from acp_sdk.server.logging import logger
|
31
|
-
from acp_sdk.server.telemetry import get_tracer
|
32
34
|
|
33
35
|
|
34
36
|
class RunBundle:
|
@@ -125,6 +127,8 @@ class RunBundle:
|
|
125
127
|
await_resume = await self.await_()
|
126
128
|
await self.emit(RunInProgressEvent(run=self.run))
|
127
129
|
run_logger.info("Run resumed")
|
130
|
+
elif isinstance(next, Error):
|
131
|
+
raise ACPError(error=next)
|
128
132
|
else:
|
129
133
|
try:
|
130
134
|
generic = AnyModel.model_validate(next)
|
@@ -142,7 +146,10 @@ class RunBundle:
|
|
142
146
|
await self.emit(RunCancelledEvent(run=self.run))
|
143
147
|
run_logger.info("Run cancelled")
|
144
148
|
except Exception as e:
|
145
|
-
|
149
|
+
if isinstance(e, ACPError):
|
150
|
+
self.run.error = e.error
|
151
|
+
else:
|
152
|
+
self.run.error = Error(code=ErrorCode.SERVER_ERROR, message=str(e))
|
146
153
|
self.run.status = RunStatus.FAILED
|
147
154
|
await self.emit(RunFailedEvent(run=self.run))
|
148
155
|
run_logger.exception("Run failed")
|
acp_sdk/server/telemetry.py
CHANGED
@@ -51,7 +51,3 @@ def configure_telemetry() -> None:
|
|
51
51
|
processor = BatchLogRecordProcessor(OTLPLogExporter())
|
52
52
|
logger_provider.add_log_record_processor(processor)
|
53
53
|
root_logger.addHandler(LoggingHandler(logger_provider=logger_provider))
|
54
|
-
|
55
|
-
|
56
|
-
def get_tracer() -> trace.Tracer:
|
57
|
-
return trace.get_tracer("acp-sdk", __version__)
|
@@ -1,8 +1,9 @@
|
|
1
1
|
acp_sdk/__init__.py,sha256=tXdAUM9zcmdSKCAkVrOCrGcXcuVS-yuvQUoQwTe9pek,98
|
2
|
+
acp_sdk/instrumentation.py,sha256=JqSyvILN3sGAfOZrmckQq4-M_4_5alyPn95DK0o5lfA,161
|
2
3
|
acp_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
4
|
acp_sdk/version.py,sha256=Niy83rgvigB4hL_rR-O4ySvI7dj6xnqkyOe_JTymi9s,73
|
4
5
|
acp_sdk/client/__init__.py,sha256=Bca1DORrswxzZsrR2aUFpATuNG2xNSmYvF1Z2WJaVbc,51
|
5
|
-
acp_sdk/client/client.py,sha256=
|
6
|
+
acp_sdk/client/client.py,sha256=5aA078pJxedVSGhhJ-NTTfjc19atSkdTyfR8LO6jgyM,6301
|
6
7
|
acp_sdk/models/__init__.py,sha256=numSDBDT1QHx7n_Y3Deb5VOvKWcUBxbOEaMwQBSRHxc,151
|
7
8
|
acp_sdk/models/errors.py,sha256=rEyaMVvQuBi7fwWe_d0PGGySYsD3FZTluQ-SkC0yhAs,444
|
8
9
|
acp_sdk/models/models.py,sha256=Z8qgURpz18uPXpYDYmlbMQ3Du9-hrJUE3GVPf7ufdUY,3994
|
@@ -10,15 +11,15 @@ acp_sdk/models/schemas.py,sha256=Kj7drJSR8d-N3KHzu_qTnLdagrMtAyhid5swluuhHTw,645
|
|
10
11
|
acp_sdk/server/__init__.py,sha256=mxBBBFaZuMEUENRMLwp1XZkuLeT9QghcFmNvjnqvAAU,377
|
11
12
|
acp_sdk/server/agent.py,sha256=fGky5MIuknw-Gy-THqhWLt9I9-gUyNIar8qEAvZb3uQ,6195
|
12
13
|
acp_sdk/server/app.py,sha256=qLeQ1STgX8_7cRtG-7Be6V5vS9ooBq6O89cQryqBdII,5903
|
13
|
-
acp_sdk/server/bundle.py,sha256=
|
14
|
+
acp_sdk/server/bundle.py,sha256=VchPUW8URH83-qJo9kRQsYCBcuLKbxGXHB3sw9CK0cc,6178
|
14
15
|
acp_sdk/server/context.py,sha256=MgnLV6qcDIhc_0BjW7r4Jj1tHts4ZuwpdTGIBnz2Mgo,1036
|
15
16
|
acp_sdk/server/errors.py,sha256=fWlgVsQ5hs_AXwzc-wvy6QgoDWEMRUBlSrfJfhHHMyE,2085
|
16
17
|
acp_sdk/server/logging.py,sha256=Oc8yZigCsuDnHHPsarRzu0RX3NKaLEgpELM2yovGKDI,411
|
17
18
|
acp_sdk/server/server.py,sha256=-eT3fmnEsBUN44Spi2EP2eV0l4RAlKa8bzqxnhz16SM,5399
|
18
19
|
acp_sdk/server/session.py,sha256=0cDr924HC5x2bBNbK9NSKVHAt5A_mi5dK8P4jP_ugq0,629
|
19
|
-
acp_sdk/server/telemetry.py,sha256=
|
20
|
+
acp_sdk/server/telemetry.py,sha256=1BUxNg-xL_Vqgs27PDWNc3HikrQW2lidAtT_FKlp_Qk,1833
|
20
21
|
acp_sdk/server/types.py,sha256=1bqMCjwZM3JzvJ1h4aBHWzjbldMQ45HqcezBD6hUoYo,175
|
21
22
|
acp_sdk/server/utils.py,sha256=EfrF9VCyVk3AM_ao-BIB9EzGbfTrh4V2Bz-VFr6f6Sg,351
|
22
|
-
acp_sdk-0.2.
|
23
|
-
acp_sdk-0.2.
|
24
|
-
acp_sdk-0.2.
|
23
|
+
acp_sdk-0.2.4.dist-info/METADATA,sha256=JCfcw8ZueUe0WzIBTrfQMcn4yRPIShxt0woTWN0M9sk,3463
|
24
|
+
acp_sdk-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
25
|
+
acp_sdk-0.2.4.dist-info/RECORD,,
|
File without changes
|