diff --git a/README.md b/README.md index 73b130c..35e0032 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # UiPath Runtime -[![PyPI downloads](https://img.shields.io/pypi/dm/uipath-runtime.svg)](https://pypi.org/project/uipath-runtime/) [![PyPI - Version](https://img.shields.io/pypi/v/uipath-runtime)](https://pypi.org/project/uipath-runtime/) +[![PyPI downloads](https://img.shields.io/pypi/dm/uipath-runtime.svg)](https://pypi.org/project/uipath-runtime/) [![Python versions](https://img.shields.io/pypi/pyversions/uipath-runtime.svg)](https://pypi.org/project/uipath-runtime/) Runtime abstractions and contracts for the UiPath Python SDK. diff --git a/pyproject.toml b/pyproject.toml index 937ce53..eeb1c92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-runtime" -version = "0.2.4" +version = "0.2.5" description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/src/uipath/runtime/chat/runtime.py b/src/uipath/runtime/chat/runtime.py index 0436555..b9f658a 100644 --- a/src/uipath/runtime/chat/runtime.py +++ b/src/uipath/runtime/chat/runtime.py @@ -54,7 +54,7 @@ async def execute( return ( result if result - else UiPathRuntimeResult(status=UiPathRuntimeStatus.SUCCESSFUL) + else UiPathRuntimeResult(status=UiPathRuntimeStatus.SUSPENDED) ) async def stream( @@ -66,11 +66,21 @@ async def stream( await self.chat_bridge.connect() async for event in self.delegate.stream(input, options=options): - if isinstance(event, UiPathRuntimeMessageEvent): + if isinstance(event, UiPathRuntimeResult): + # In chat mode, convert successful completion to SUSPENDED + # Breakpoints and resumable triggers are already suspended + # Faulted jobs remain faulted + if event.status == UiPathRuntimeStatus.SUCCESSFUL: + yield UiPathRuntimeResult( + status=UiPathRuntimeStatus.SUSPENDED, + output=event.output, + ) + else: + yield event + elif isinstance(event, UiPathRuntimeMessageEvent): if event.payload: await self.chat_bridge.emit_message_event(event.payload) - - yield event + yield event async def get_schema(self) -> UiPathRuntimeSchema: """Get schema from the delegate runtime.""" diff --git a/src/uipath/runtime/errors/exception.py b/src/uipath/runtime/errors/exception.py index 1f6787d..770bd09 100644 --- a/src/uipath/runtime/errors/exception.py +++ b/src/uipath/runtime/errors/exception.py @@ -1,5 +1,7 @@ """Base exception class for UiPath runtime errors with structured error information.""" +from __future__ import annotations + import sys import traceback from typing import Any @@ -105,7 +107,7 @@ def __init__( @classmethod def from_resume_trigger_error( cls, exc: UiPathFaultedTriggerError - ) -> "UiPathRuntimeError": + ) -> UiPathRuntimeError: """Create UiPathRuntimeError from UiPathFaultedTriggerError.""" return cls( code=UiPathErrorCode.RESUME_TRIGGER_ERROR, diff --git a/tests/test_chat_runtime.py b/tests/test_chat.py similarity index 98% rename from tests/test_chat_runtime.py rename to tests/test_chat.py index 76cd290..0626751 100644 --- a/tests/test_chat_runtime.py +++ b/tests/test_chat.py @@ -114,7 +114,7 @@ async def test_chat_runtime_streams_and_emits_messages(): # Result propagation assert isinstance(result, UiPathRuntimeResult) - assert result.status == UiPathRuntimeStatus.SUCCESSFUL + assert result.status == UiPathRuntimeStatus.SUSPENDED assert result.output == {"messages": ["Hello", "How are you?", "Goodbye"]} # Bridge lifecycle @@ -158,6 +158,7 @@ async def test_chat_runtime_stream_yields_all_events(): assert isinstance(events[0], UiPathRuntimeMessageEvent) assert isinstance(events[1], UiPathRuntimeMessageEvent) assert isinstance(events[2], UiPathRuntimeResult) + assert events[2].status == UiPathRuntimeStatus.SUSPENDED # Bridge methods called cast(AsyncMock, bridge.connect).assert_awaited_once() diff --git a/uv.lock b/uv.lock index c8d6f0d..2bf658a 100644 --- a/uv.lock +++ b/uv.lock @@ -1005,7 +1005,7 @@ wheels = [ [[package]] name = "uipath-runtime" -version = "0.2.4" +version = "0.2.5" source = { editable = "." } dependencies = [ { name = "uipath-core" },