def on_execution_step(event):
payload = event.get("payload", {})
current_step = payload.get("current_step")
next_step = payload.get("next_step")
print(f"[SESSION: {handle.sessionId}] STEP: {current_step} -> {next_step} @ {event.get('timestamp')}")
def on_execution_start(event):
workflow_id = event.get("payload", {}).get("workflow_id")
print(f"[SESSION: {handle.sessionId}] START: {workflow_id} @ {event.get('timestamp')}")
handle = client.runs.start(
StartRunRequest(
workflow_id="workflow-123",
run_input_variables={"target": "https://example.com"},
)
)
handle.on("execution.step", on_execution_step)
handle.on("execution.start", on_execution_start)
handle.on("error", lambda err: print(f"[SESSION: {handle.sessionId}] ERROR: {err}"))
handle.on("end", lambda info: print(f"[SESSION: {handle.sessionId}] Workflow completed with status: {info.get('type')}"))