|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with the `uipath-platform` package. |
| 4 | + |
| 5 | +## Package Purpose |
| 6 | + |
| 7 | +HTTP client layer for UiPath Platform APIs. Provides typed service classes for all orchestrator and platform resources. Depends on `uipath-core`, httpx, tenacity, and pydantic. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +cd packages/uipath-platform |
| 13 | + |
| 14 | +uv sync --all-extras # Install dependencies |
| 15 | +pytest # Run all tests |
| 16 | +pytest tests/services/test_assets_service.py # Single test file |
| 17 | +ruff check . # Lint |
| 18 | +ruff format --check . # Format check |
| 19 | +mypy src tests # Type check |
| 20 | +``` |
| 21 | + |
| 22 | +No justfile exists for this package — run commands directly. |
| 23 | + |
| 24 | +## Entry Point: `UiPath` Class |
| 25 | + |
| 26 | +`_uipath.py` defines the main `UiPath` class that exposes all services as properties: |
| 27 | + |
| 28 | +```python |
| 29 | +from uipath.platform import UiPath |
| 30 | +sdk = UiPath() |
| 31 | +sdk.assets # AssetsService |
| 32 | +sdk.attachments # AttachmentsService |
| 33 | +sdk.processes # ProcessesService |
| 34 | +sdk.buckets # BucketsService |
| 35 | +sdk.queues # QueuesService |
| 36 | +sdk.jobs # JobsService |
| 37 | +sdk.folders # FolderService |
| 38 | +sdk.tasks # TasksService (Action Center) |
| 39 | +sdk.connections # ConnectionsService |
| 40 | +sdk.context_grounding # ContextGroundingService |
| 41 | +sdk.documents # DocumentsService |
| 42 | +sdk.entities # EntitiesService |
| 43 | +sdk.llm # UiPathLlmChatService |
| 44 | +sdk.llm_openai # UiPathOpenAIService |
| 45 | +sdk.conversational # ConversationsService |
| 46 | +sdk.guardrails # GuardrailsService |
| 47 | +sdk.agenthub # AgentHubService |
| 48 | +sdk.mcp # McpService |
| 49 | +sdk.resource_catalog # ResourceCatalogService |
| 50 | +sdk.automation_tracker # AutomationTrackerService |
| 51 | +``` |
| 52 | + |
| 53 | +### Authentication |
| 54 | + |
| 55 | +Credentials can be provided via constructor parameters or environment variables (`UIPATH_URL`, `UIPATH_ACCESS_TOKEN`). Two auth modes are supported: |
| 56 | + |
| 57 | +- **User authentication** — provide `base_url` and `secret` (access token), or set them via env vars |
| 58 | +- **S2S (service-to-service)** — provide `client_id` and `client_secret` (both required together), optionally with `scope`; uses `ExternalApplicationService` internally to exchange for an access token |
| 59 | + |
| 60 | +Configuration is validated with Pydantic; missing `base_url` raises `BaseUrlMissingError`, missing `secret` raises `SecretMissingError`. |
| 61 | + |
| 62 | +## Service Architecture |
| 63 | + |
| 64 | +### Two-File Pattern (orchestrator/) |
| 65 | + |
| 66 | +Each orchestrator resource uses two files: |
| 67 | +- **`_<resource>_service.py`** — Internal service class extending `BaseService` and `FolderContext`. Contains HTTP logic (httpx calls, URL construction, retry, error handling). Methods decorated with `@traced` and `@resource_override`. |
| 68 | +- **`<resource>.py`** — Public Pydantic models for the resource. |
| 69 | + |
| 70 | +### BaseService (`common/_base_service.py`) |
| 71 | + |
| 72 | +All services inherit from `BaseService` which provides: |
| 73 | +- `request()` / `request_async()` — HTTP methods with tenacity-based retry (exponential backoff) |
| 74 | +- Automatic exception enrichment via `EnrichedException` |
| 75 | +- User-agent tracking and span utilities |
| 76 | + |
| 77 | +### FolderContext (`common/_folder_context.py`) |
| 78 | + |
| 79 | +Manages folder scoping (by `folder_key` or `folder_path`) for orchestrator operations. |
| 80 | + |
| 81 | +### Method Naming Convention |
| 82 | + |
| 83 | +- `retrieve` — get single resource by key |
| 84 | +- `retrieve_by_[field]` — get by alternate field |
| 85 | +- `list` — get multiple resources |
| 86 | + |
| 87 | +### Sync + Async |
| 88 | + |
| 89 | +Services provide both sync and async variants (e.g., `.invoke()` and `.invoke_async()`). |
| 90 | + |
| 91 | +## Modules Beyond Orchestrator |
| 92 | + |
| 93 | +| Module | Purpose | |
| 94 | +|--------|---------| |
| 95 | +| `action_center/` | Task management for human-in-the-loop workflows | |
| 96 | +| `agenthub/` | System agents and LLM model discovery | |
| 97 | +| `automation_tracker/` | Business Transaction Service (BTS) for Process Mining | |
| 98 | +| `chat/` | LLM gateway, conversations, throttling | |
| 99 | +| `connections/` | External connection management | |
| 100 | +| `context_grounding/` | RAG services (DeepRAG, batch RAG, ephemeral indexes) | |
| 101 | +| `documents/` | Document Understanding (IXP) | |
| 102 | +| `entities/` | Data Service entity management | |
| 103 | +| `guardrails/` | LLM output guardrails | |
| 104 | +| `resource_catalog/` | Resource discovery and metadata | |
| 105 | +| `resume_triggers/` | HITL trigger creation/reading protocols | |
| 106 | +| `common/` | Shared base classes, config, auth, retry, paging, validation | |
| 107 | +| `errors/` | Custom exceptions (`EnrichedException`, `FolderNotFoundException`, `BaseUrlMissingError`, etc.) | |
| 108 | + |
| 109 | +## Test Structure |
| 110 | + |
| 111 | +All tests are under `tests/services/` with one test file per service. Tests use `pytest-httpx` for HTTP mocking. |
| 112 | + |
| 113 | +### Key Test Fixtures (`tests/services/conftest.py`) |
| 114 | + |
| 115 | +- `base_url` — returns `"https://test.uipath.com"` |
| 116 | +- `config` — `UiPathApiConfig` instance |
| 117 | +- `execution_context` — `UiPathExecutionContext` with mocked `UIPATH_ROBOT_KEY` |
| 118 | +- `mock_env_vars` — standard mock env vars (URL, tokens, IDs) |
| 119 | +- Service-specific fixtures (e.g., `jobs_service`) built from config + execution_context |
0 commit comments