11"""Interrupt events for human-in-the-loop patterns."""
22
3- from typing import Any
3+ from enum import Enum
4+ from typing import Any , Literal , Union
45
56from pydantic import BaseModel , ConfigDict , Field
67
78
8- class UiPathConversationInterruptStartEvent (BaseModel ):
9- """Signals the start of an interrupt - a pause point where the agent needs external input."""
9+ class InterruptTypeEnum (str , Enum ):
10+ """Enum of known interrupt types."""
11+
12+ TOOL_CALL_CONFIRMATION = "uipath_cas_tool_call_confirmation"
13+
14+
15+ class UiPathConversationToolCallConfirmationValue (BaseModel ):
16+ """Schema for tool call confirmation interrupt value."""
17+
18+ tool_call_id : str = Field (..., alias = "toolCallId" )
19+ tool_name : str = Field (..., alias = "toolName" )
20+ input_schema : Any = Field (..., alias = "inputSchema" )
21+ input_value : Any | None = Field (None , alias = "inputValue" )
22+
23+ model_config = ConfigDict (validate_by_name = True , validate_by_alias = True )
24+
25+
26+ class UiPathConversationToolCallConfirmationInterruptStartEvent (BaseModel ):
27+ """Tool call confirmation interrupt start event with strong typing."""
28+
29+ type : Literal ["uipath_cas_tool_call_confirmation" ]
30+ value : UiPathConversationToolCallConfirmationValue
31+
32+ model_config = ConfigDict (validate_by_name = True , validate_by_alias = True )
33+
34+
35+ class UiPathConversationGenericInterruptStartEvent (BaseModel ):
36+ """Generic interrupt start event for custom interrupt types."""
1037
1138 type : str
1239 value : Any
1340
1441 model_config = ConfigDict (validate_by_name = True , validate_by_alias = True )
1542
1643
17- class UiPathConversationInterruptEndEvent (BaseModel ):
18- """Signals the interrupt end event with the provided value."""
44+ UiPathConversationInterruptStartEvent = Union [
45+ UiPathConversationToolCallConfirmationInterruptStartEvent ,
46+ UiPathConversationGenericInterruptStartEvent ,
47+ ]
1948
20- # Can be any type
21- model_config = ConfigDict (
22- validate_by_name = True , validate_by_alias = True , extra = "allow"
23- )
49+
50+ class UiPathConversationToolCallConfirmationEndValue (BaseModel ):
51+ """Schema for tool call confirmation end value."""
52+
53+ approved : bool
54+ input : Any | None = None
55+
56+ model_config = ConfigDict (validate_by_name = True , validate_by_alias = True )
57+
58+
59+ class UiPathConversationToolCallConfirmationInterruptEndEvent (BaseModel ):
60+ """Tool call confirmation interrupt end event with strong typing."""
61+
62+ type : Literal ["uipath_cas_tool_call_confirmation" ]
63+ value : UiPathConversationToolCallConfirmationEndValue
64+
65+ model_config = ConfigDict (validate_by_name = True , validate_by_alias = True )
66+
67+
68+ class UiPathConversationGenericInterruptEndEvent (BaseModel ):
69+ """Generic interrupt end event for custom interrupt types."""
70+
71+ type : str
72+ value : Any
73+
74+ model_config = ConfigDict (validate_by_name = True , validate_by_alias = True )
75+
76+
77+ UiPathConversationInterruptEndEvent = Union [
78+ UiPathConversationToolCallConfirmationInterruptEndEvent ,
79+ UiPathConversationGenericInterruptEndEvent ,
80+ ]
2481
2582
2683class UiPathConversationInterruptEvent (BaseModel ):
@@ -30,6 +87,6 @@ class UiPathConversationInterruptEvent(BaseModel):
3087 start : UiPathConversationInterruptStartEvent | None = Field (
3188 None , alias = "startInterrupt"
3289 )
33- end : Any | None = Field (None , alias = "endInterrupt" )
90+ end : UiPathConversationInterruptEndEvent | None = Field (None , alias = "endInterrupt" )
3491
3592 model_config = ConfigDict (validate_by_name = True , validate_by_alias = True )
0 commit comments