|
| 1 | +"""Compatibility shims for legacy interrupt event types. |
| 2 | +
|
| 3 | +The interrupt-based tool-call confirmation flow was replaced by `confirmToolCall` |
| 4 | +on the tool call event itself (see PR #1558). The original `interrupt.py` was |
| 5 | +removed in `uipath-core` 0.5.13, but published `uipath-runtime` versions still |
| 6 | +import these names at module load time, breaking installs that pull the new |
| 7 | +`uipath-core` alongside an older runtime. |
| 8 | +
|
| 9 | +These shims keep those imports working. They are not used by current code paths |
| 10 | +and should be removed in the next minor bump of `uipath-core`. |
| 11 | +""" |
| 12 | + |
| 13 | +from enum import Enum |
| 14 | +from typing import Any, Literal, Union |
| 15 | + |
| 16 | +from pydantic import BaseModel, ConfigDict, Field |
| 17 | + |
| 18 | + |
| 19 | +class InterruptTypeEnum(str, Enum): |
| 20 | + """Enum of known interrupt types.""" |
| 21 | + |
| 22 | + TOOL_CALL_CONFIRMATION = "uipath_cas_tool_call_confirmation" |
| 23 | + |
| 24 | + |
| 25 | +class UiPathConversationToolCallConfirmationValue(BaseModel): |
| 26 | + """Schema for tool call confirmation interrupt value.""" |
| 27 | + |
| 28 | + tool_call_id: str = Field(..., alias="toolCallId") |
| 29 | + tool_name: str = Field(..., alias="toolName") |
| 30 | + input_schema: Any = Field(..., alias="inputSchema") |
| 31 | + input_value: Any | None = Field(None, alias="inputValue") |
| 32 | + |
| 33 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 34 | + |
| 35 | + |
| 36 | +class UiPathConversationToolCallConfirmationInterruptStartEvent(BaseModel): |
| 37 | + """Tool call confirmation interrupt start event with strong typing.""" |
| 38 | + |
| 39 | + type: Literal["uipath_cas_tool_call_confirmation"] |
| 40 | + value: UiPathConversationToolCallConfirmationValue |
| 41 | + |
| 42 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 43 | + |
| 44 | + |
| 45 | +class UiPathConversationGenericInterruptStartEvent(BaseModel): |
| 46 | + """Generic interrupt start event for custom interrupt types.""" |
| 47 | + |
| 48 | + type: str |
| 49 | + value: Any |
| 50 | + |
| 51 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 52 | + |
| 53 | + |
| 54 | +UiPathConversationInterruptStartEvent = Union[ |
| 55 | + UiPathConversationToolCallConfirmationInterruptStartEvent, |
| 56 | + UiPathConversationGenericInterruptStartEvent, |
| 57 | +] |
| 58 | + |
| 59 | + |
| 60 | +class UiPathConversationToolCallConfirmationEndValue(BaseModel): |
| 61 | + """Schema for tool call confirmation end value.""" |
| 62 | + |
| 63 | + approved: bool |
| 64 | + input: Any | None = None |
| 65 | + |
| 66 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 67 | + |
| 68 | + |
| 69 | +class UiPathConversationToolCallConfirmationInterruptEndEvent(BaseModel): |
| 70 | + """Tool call confirmation interrupt end event with strong typing.""" |
| 71 | + |
| 72 | + type: Literal["uipath_cas_tool_call_confirmation"] |
| 73 | + value: UiPathConversationToolCallConfirmationEndValue |
| 74 | + |
| 75 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 76 | + |
| 77 | + |
| 78 | +class UiPathConversationGenericInterruptEndEvent(BaseModel): |
| 79 | + """Generic interrupt end event for custom interrupt types.""" |
| 80 | + |
| 81 | + type: str |
| 82 | + value: Any |
| 83 | + |
| 84 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 85 | + |
| 86 | + |
| 87 | +UiPathConversationInterruptEndEvent = Union[ |
| 88 | + UiPathConversationToolCallConfirmationInterruptEndEvent, |
| 89 | + UiPathConversationGenericInterruptEndEvent, |
| 90 | +] |
| 91 | + |
| 92 | + |
| 93 | +class UiPathConversationInterruptEvent(BaseModel): |
| 94 | + """Encapsulates interrupt-related events within a message.""" |
| 95 | + |
| 96 | + interrupt_id: str = Field(..., alias="interruptId") |
| 97 | + start: UiPathConversationInterruptStartEvent | None = Field( |
| 98 | + None, alias="startInterrupt" |
| 99 | + ) |
| 100 | + end: UiPathConversationInterruptEndEvent | None = Field(None, alias="endInterrupt") |
| 101 | + |
| 102 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 103 | + |
| 104 | + |
| 105 | +class UiPathConversationInterruptData(BaseModel): |
| 106 | + """Core data of an interrupt within a message.""" |
| 107 | + |
| 108 | + type: str |
| 109 | + interrupt_value: Any = Field(..., alias="interruptValue") |
| 110 | + end_value: Any | None = Field(None, alias="endValue") |
| 111 | + |
| 112 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
| 113 | + |
| 114 | + |
| 115 | +class UiPathConversationInterrupt(UiPathConversationInterruptData): |
| 116 | + """An interrupt within a message — a pause point where the agent needs external input.""" |
| 117 | + |
| 118 | + interrupt_id: str = Field(..., alias="interruptId") |
| 119 | + created_at: str = Field(..., alias="createdAt") |
| 120 | + updated_at: str = Field(..., alias="updatedAt") |
| 121 | + |
| 122 | + model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) |
0 commit comments