55import os
66from functools import cached_property
77from pathlib import Path
8- from typing import (
9- Any ,
10- TypeVar ,
11- )
8+ from typing import Any
129
1310from pydantic import BaseModel , ConfigDict
1411
2320
2421logger = logging .getLogger (__name__ )
2522
26- C = TypeVar ("C" , bound = "UiPathRuntimeContext" )
27-
2823
2924class UiPathRuntimeContext (BaseModel ):
3025 """Context information passed throughout the runtime execution."""
3126
3227 entrypoint : str | None = None
3328 input : str | None = None
3429 job_id : str | None = None
30+ tenant_id : str | None = None
31+ org_id : str | None = None
32+ folder_key : str | None = None
33+ process_key : str | None = None
3534 config_path : str = "uipath.json"
3635 runtime_dir : str | None = "__uipath"
3736 result_file : str = "output.json"
@@ -253,7 +252,9 @@ def state_file_path(self) -> str:
253252 return os .path .join ("__uipath" , "state.db" )
254253
255254 @classmethod
256- def with_defaults (cls : type [C ], config_path : str | None = None , ** kwargs ) -> C :
255+ def with_defaults (
256+ cls , config_path : str | None = None , ** kwargs
257+ ) -> "UiPathRuntimeContext" :
257258 """Construct a context with defaults, reading env vars and config file."""
258259 resolved_config_path = config_path or os .environ .get (
259260 "UIPATH_CONFIG_PATH" , "uipath.json"
@@ -270,6 +271,10 @@ def with_defaults(cls: type[C], config_path: str | None = None, **kwargs) -> C:
270271 # Apply defaults from env
271272 base .job_id = os .environ .get ("UIPATH_JOB_KEY" )
272273 base .logs_min_level = os .environ .get ("LOG_LEVEL" , "INFO" )
274+ base .org_id = os .environ .get ("UIPATH_ORGANIZATION_ID" )
275+ base .tenant_id = os .environ .get ("UIPATH_TENANT_ID" )
276+ base .process_key = os .environ .get ("UIPATH_PROCESS_UUID" )
277+ base .folder_key = os .environ .get ("UIPATH_FOLDER_KEY" )
273278
274279 # Override with kwargs
275280 for k , v in kwargs .items ():
@@ -278,7 +283,9 @@ def with_defaults(cls: type[C], config_path: str | None = None, **kwargs) -> C:
278283 return base
279284
280285 @classmethod
281- def from_config (cls : type [C ], config_path : str | None = None , ** kwargs ) -> C :
286+ def from_config (
287+ cls , config_path : str | None = None , ** kwargs
288+ ) -> "UiPathRuntimeContext" :
282289 """Load configuration from uipath.json file."""
283290 path = config_path or "uipath.json"
284291 config = {}
0 commit comments