Skip to content

Commit f477713

Browse files
committed
fix: debugger emit interrupt hit
1 parent 37393ee commit f477713

5 files changed

Lines changed: 30 additions & 21 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-runtime"
3-
version = "0.1.3"
3+
version = "0.2.0"
44
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/runtime/debug/bridge.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ async def emit_breakpoint_hit(
3737
"""Notify debugger that a breakpoint was hit."""
3838
...
3939

40+
async def emit_execution_suspended(self, result: UiPathRuntimeResult) -> None:
41+
"""Notify debugger that the execution has been suspended."""
42+
...
43+
44+
async def emit_execution_resumed(self, resume_data: Any) -> None:
45+
"""Notify debugger that the execution has resumed."""
46+
...
47+
4048
async def emit_execution_completed(
4149
self,
4250
runtime_result: UiPathRuntimeResult,

src/uipath/runtime/debug/runtime.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
)
2828
from uipath.runtime.resumable.protocols import UiPathResumeTriggerReaderProtocol
2929
from uipath.runtime.resumable.runtime import UiPathResumableRuntime
30-
from uipath.runtime.resumable.trigger import UiPathResumeTrigger
30+
from uipath.runtime.resumable.trigger import (
31+
UiPathResumeTrigger,
32+
UiPathResumeTriggerType,
33+
)
3134
from uipath.runtime.schema import UiPathRuntimeSchema
3235

3336
logger = logging.getLogger(__name__)
@@ -181,20 +184,22 @@ async def _stream_and_debug(
181184
and final_result.status == UiPathRuntimeStatus.SUSPENDED
182185
and final_result.trigger
183186
):
184-
state_event = UiPathRuntimeStateEvent(
185-
node_name="<suspended>",
186-
payload={
187-
"status": "suspended",
188-
"trigger": final_result.trigger.model_dump(),
189-
},
190-
)
191-
await self.debug_bridge.emit_state_update(state_event)
187+
await self.debug_bridge.emit_execution_suspended(event)
192188

193189
resume_data: dict[str, Any] | None = None
194190
try:
195-
resume_data = await self._poll_trigger(
196-
final_result.trigger, self.delegate.trigger_manager
197-
)
191+
if (
192+
final_result.trigger.trigger_type
193+
== UiPathResumeTriggerType.API
194+
):
195+
resume_data = (
196+
await self.debug_bridge.wait_for_resume()
197+
)
198+
else:
199+
resume_data = await self._poll_trigger(
200+
final_result.trigger,
201+
self.delegate.trigger_manager,
202+
)
198203
except UiPathDebugQuitError:
199204
final_result = UiPathRuntimeResult(
200205
status=UiPathRuntimeStatus.SUCCESSFUL,
@@ -203,14 +208,9 @@ async def _stream_and_debug(
203208
execution_completed = True
204209

205210
if resume_data is not None:
206-
resumed_event = UiPathRuntimeStateEvent(
207-
node_name="<resumed>",
208-
payload={
209-
"status": "resumed",
210-
"data": resume_data,
211-
},
211+
await self.debug_bridge.emit_execution_resumed(
212+
resume_data
212213
)
213-
await self.debug_bridge.emit_state_update(resumed_event)
214214

215215
# Continue with resumed execution
216216
current_input = resume_data

src/uipath/runtime/resumable/runtime.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ async def _handle_suspension(
146146

147147
suspended_result = UiPathRuntimeResult(
148148
status=UiPathRuntimeStatus.SUSPENDED,
149+
output=result.output,
149150
)
150151

151152
if result.output:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)