3
3
"""
4
4
5
5
from enum import Enum
6
- from typing import Annotated , Any , List , Literal , Optional , Union
6
+ from typing import Annotated , List , Literal , Optional , Union , Generic
7
7
8
8
from pydantic import Field
9
9
10
- from .types import ConfiguredBaseModel , Message , State
10
+ from .types import ConfiguredBaseModel , Message , AgentStateT , JSONValue
11
11
12
12
13
13
class EventType (str , Enum ):
@@ -46,7 +46,7 @@ class BaseEvent(ConfiguredBaseModel):
46
46
"""
47
47
type : EventType
48
48
timestamp : Optional [int ] = None
49
- raw_event : Optional [Any ] = None
49
+ raw_event : Optional [JSONValue ] = None
50
50
51
51
52
52
class TextMessageStartEvent (BaseEvent ):
@@ -161,20 +161,20 @@ class ThinkingEndEvent(BaseEvent):
161
161
"""
162
162
type : Literal [EventType .THINKING_END ] = EventType .THINKING_END # pyright: ignore[reportIncompatibleVariableOverride]
163
163
164
- class StateSnapshotEvent (BaseEvent ):
164
+ class StateSnapshotEvent (BaseEvent , Generic [ AgentStateT ] ):
165
165
"""
166
166
Event containing a snapshot of the state.
167
167
"""
168
168
type : Literal [EventType .STATE_SNAPSHOT ] = EventType .STATE_SNAPSHOT # pyright: ignore[reportIncompatibleVariableOverride]
169
- snapshot : State
169
+ snapshot : AgentStateT
170
170
171
171
172
172
class StateDeltaEvent (BaseEvent ):
173
173
"""
174
174
Event containing a delta of the state.
175
175
"""
176
176
type : Literal [EventType .STATE_DELTA ] = EventType .STATE_DELTA # pyright: ignore[reportIncompatibleVariableOverride]
177
- delta : List [ Any ] # JSON Patch (RFC 6902)
177
+ delta : JSONValue # JSON Patch (RFC 6902)
178
178
179
179
180
180
class MessagesSnapshotEvent (BaseEvent ):
@@ -190,7 +190,7 @@ class RawEvent(BaseEvent):
190
190
Event containing a raw event.
191
191
"""
192
192
type : Literal [EventType .RAW ] = EventType .RAW # pyright: ignore[reportIncompatibleVariableOverride]
193
- event : Any
193
+ event : JSONValue
194
194
source : Optional [str ] = None
195
195
196
196
@@ -200,7 +200,7 @@ class CustomEvent(BaseEvent):
200
200
"""
201
201
type : Literal [EventType .CUSTOM ] = EventType .CUSTOM # pyright: ignore[reportIncompatibleVariableOverride]
202
202
name : str
203
- value : Any
203
+ value : JSONValue
204
204
205
205
206
206
class RunStartedEvent (BaseEvent ):
@@ -219,7 +219,7 @@ class RunFinishedEvent(BaseEvent):
219
219
type : Literal [EventType .RUN_FINISHED ] = EventType .RUN_FINISHED # pyright: ignore[reportIncompatibleVariableOverride]
220
220
thread_id : str
221
221
run_id : str
222
- result : Optional [ Any ] = None
222
+ result : JSONValue = None
223
223
224
224
225
225
class RunErrorEvent (BaseEvent ):
0 commit comments