acp-sdk 0.8.3__py3-none-any.whl → 0.8.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/models/models.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import asyncio
|
1
2
|
import uuid
|
2
3
|
from datetime import datetime, timezone
|
3
4
|
from enum import Enum
|
@@ -5,7 +6,7 @@ from typing import Any, Literal, Optional, Union
|
|
5
6
|
|
6
7
|
from pydantic import AnyUrl, BaseModel, ConfigDict, Field
|
7
8
|
|
8
|
-
from acp_sdk.models.errors import Error
|
9
|
+
from acp_sdk.models.errors import ACPError, Error
|
9
10
|
|
10
11
|
|
11
12
|
class AnyModel(BaseModel):
|
@@ -196,6 +197,15 @@ class Run(BaseModel):
|
|
196
197
|
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
197
198
|
finished_at: datetime | None = None
|
198
199
|
|
200
|
+
def raise_for_status(self) -> "Run":
|
201
|
+
match self.status:
|
202
|
+
case RunStatus.CANCELLED:
|
203
|
+
raise asyncio.CancelledError()
|
204
|
+
case RunStatus.FAILED:
|
205
|
+
raise ACPError(error=self.error)
|
206
|
+
case _:
|
207
|
+
return self
|
208
|
+
|
199
209
|
|
200
210
|
class MessageCreatedEvent(BaseModel):
|
201
211
|
type: Literal["message.created"] = "message.created"
|
acp_sdk/server/agent.py
CHANGED
@@ -58,13 +58,13 @@ class Agent(abc.ABC):
|
|
58
58
|
run = asyncio.get_running_loop().run_in_executor(executor, self._run_func, input, context)
|
59
59
|
|
60
60
|
try:
|
61
|
-
while
|
61
|
+
while not run.done() or yield_queue.async_q.qsize() > 0:
|
62
62
|
value = yield await yield_queue.async_q.get()
|
63
|
+
if isinstance(value, Exception):
|
64
|
+
raise value
|
63
65
|
await yield_resume_queue.async_q.put(value)
|
64
66
|
except janus.AsyncQueueShutDown:
|
65
67
|
pass
|
66
|
-
finally:
|
67
|
-
await run # Raise exceptions
|
68
68
|
|
69
69
|
async def _run_async_gen(self, input: list[Message], context: Context) -> None:
|
70
70
|
try:
|
@@ -74,12 +74,16 @@ class Agent(abc.ABC):
|
|
74
74
|
value = await context.yield_async(await gen.asend(value))
|
75
75
|
except StopAsyncIteration:
|
76
76
|
pass
|
77
|
+
except Exception as e:
|
78
|
+
await context.yield_async(e)
|
77
79
|
finally:
|
78
80
|
context.shutdown()
|
79
81
|
|
80
82
|
async def _run_coro(self, input: list[Message], context: Context) -> None:
|
81
83
|
try:
|
82
84
|
await context.yield_async(await self.run(input, context))
|
85
|
+
except Exception as e:
|
86
|
+
await context.yield_async(e)
|
83
87
|
finally:
|
84
88
|
context.shutdown()
|
85
89
|
|
@@ -91,12 +95,16 @@ class Agent(abc.ABC):
|
|
91
95
|
value = context.yield_sync(gen.send(value))
|
92
96
|
except StopIteration:
|
93
97
|
pass
|
98
|
+
except Exception as e:
|
99
|
+
context.yield_sync(e)
|
94
100
|
finally:
|
95
101
|
context.shutdown()
|
96
102
|
|
97
103
|
def _run_func(self, input: list[Message], context: Context) -> None:
|
98
104
|
try:
|
99
105
|
context.yield_sync(self.run(input, context))
|
106
|
+
except Exception as e:
|
107
|
+
context.yield_sync(e)
|
100
108
|
finally:
|
101
109
|
context.shutdown()
|
102
110
|
|
acp_sdk/server/types.py
CHANGED
@@ -5,5 +5,5 @@ from pydantic import BaseModel
|
|
5
5
|
from acp_sdk.models import AwaitRequest, AwaitResume, Message
|
6
6
|
from acp_sdk.models.models import MessagePart
|
7
7
|
|
8
|
-
RunYield = Message | MessagePart | str | AwaitRequest | BaseModel | dict[str | Any] | None
|
8
|
+
RunYield = Message | MessagePart | str | AwaitRequest | BaseModel | dict[str | Any] | None | Exception
|
9
9
|
RunYieldResume = AwaitResume | None
|
@@ -8,10 +8,10 @@ acp_sdk/client/types.py,sha256=_H6zYt-2OHOOYRtssRnbDIiwmgsl2-KIXc9lb-mJLFA,133
|
|
8
8
|
acp_sdk/client/utils.py,sha256=2jhJyrPJmVFRoDJh0q_JMqOMlC3IxCh-6HXed-PIZS8,924
|
9
9
|
acp_sdk/models/__init__.py,sha256=numSDBDT1QHx7n_Y3Deb5VOvKWcUBxbOEaMwQBSRHxc,151
|
10
10
|
acp_sdk/models/errors.py,sha256=rEyaMVvQuBi7fwWe_d0PGGySYsD3FZTluQ-SkC0yhAs,444
|
11
|
-
acp_sdk/models/models.py,sha256=
|
11
|
+
acp_sdk/models/models.py,sha256=PSv3Vq07ahCi6JpvEMzEdEjHdUU7NT9KTf21CF9B3-g,7629
|
12
12
|
acp_sdk/models/schemas.py,sha256=_ah7_zHsQJGxDXvnzsBvASdRsQHVphFQ7Sum6A04iRw,759
|
13
13
|
acp_sdk/server/__init__.py,sha256=mxBBBFaZuMEUENRMLwp1XZkuLeT9QghcFmNvjnqvAAU,377
|
14
|
-
acp_sdk/server/agent.py,sha256=
|
14
|
+
acp_sdk/server/agent.py,sha256=6VBKn_qVXqUl79G8T7grwhnuLMwr67d4UGagMGX1hMs,6586
|
15
15
|
acp_sdk/server/app.py,sha256=1S1mxECioL5NeGjGo5C8u94x7Ybvj79L_Aauu2352vA,7117
|
16
16
|
acp_sdk/server/bundle.py,sha256=5Rq6E4WgmuwPQ4u-sViaHeu5loCLEUgojWav9LAghX4,7036
|
17
17
|
acp_sdk/server/context.py,sha256=MgnLV6qcDIhc_0BjW7r4Jj1tHts4ZuwpdTGIBnz2Mgo,1036
|
@@ -20,8 +20,8 @@ acp_sdk/server/logging.py,sha256=Oc8yZigCsuDnHHPsarRzu0RX3NKaLEgpELM2yovGKDI,411
|
|
20
20
|
acp_sdk/server/server.py,sha256=JLQ2tyZpQaWvhZYw6-OWbKlSRNWezXLXhD5OFbKPysw,8014
|
21
21
|
acp_sdk/server/session.py,sha256=ekz1o6Sy1tQZlpaoS_VgbvFuUQh2qpiHG71mvBdvhgc,662
|
22
22
|
acp_sdk/server/telemetry.py,sha256=1BUxNg-xL_Vqgs27PDWNc3HikrQW2lidAtT_FKlp_Qk,1833
|
23
|
-
acp_sdk/server/types.py,sha256=
|
23
|
+
acp_sdk/server/types.py,sha256=gLb5wCkMYhmu2laj_ymK-TPfN9LSjRgKOP1H_893UzA,304
|
24
24
|
acp_sdk/server/utils.py,sha256=BhZKBNaLgczX6aYjxYva-6VI1bKmHtYQ5YDA5LrwF50,1831
|
25
|
-
acp_sdk-0.8.
|
26
|
-
acp_sdk-0.8.
|
27
|
-
acp_sdk-0.8.
|
25
|
+
acp_sdk-0.8.4.dist-info/METADATA,sha256=AZFhr-FKotfSVMuKUCdixS18rg6d-fjePoy2hWw3SnY,1651
|
26
|
+
acp_sdk-0.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
acp_sdk-0.8.4.dist-info/RECORD,,
|
File without changes
|