import { IUiPath } from '../core/index'; /** * Simplified universal pagination cursor * Used to fetch next/previous pages */ interface PaginationCursor { /** Opaque string containing all information needed to fetch next page */ value: string; } /** * Discriminated union for pagination methods - ensures cursor and jumpToPage are mutually exclusive */ type PaginationMethodUnion = { cursor?: PaginationCursor; jumpToPage?: never; } | { cursor?: never; jumpToPage?: number; } | { cursor?: never; jumpToPage?: never; }; /** * Pagination options. Users cannot specify both cursor and jumpToPage. */ type PaginationOptions = { /** Size of the page to fetch (items per page) */ pageSize?: number; } & PaginationMethodUnion; /** * Paginated response containing items and navigation information */ interface PaginatedResponse { /** The items in the current page */ items: T[]; /** Total count of items across all pages (if available) */ totalCount?: number; /** Whether more pages are available */ hasNextPage: boolean; /** Cursor to fetch the next page (if available) */ nextCursor?: PaginationCursor; /** Cursor to fetch the previous page (if available) */ previousCursor?: PaginationCursor; /** Current page number (1-based, if available) */ currentPage?: number; /** Total number of pages (if available) */ totalPages?: number; /** Whether this pagination type supports jumping to arbitrary pages */ supportsPageJump: boolean; } /** * Response for non-paginated calls that includes both data and total count */ interface NonPaginatedResponse { items: T[]; totalCount?: number; } /** * Helper type for defining paginated method overloads * Creates a union type of all ways pagination can be triggered */ type HasPaginationOptions = (T & { pageSize: number; }) | (T & { cursor: PaginationCursor; }) | (T & { jumpToPage: number; }); /** * Pagination types supported by the SDK */ declare enum PaginationType { OFFSET = "offset", TOKEN = "token" } /** * Interface for service access methods needed by pagination helpers */ interface PaginationServiceAccess { get(path: string, options?: any): Promise<{ data: T; }>; post(path: string, body?: any, options?: any): Promise<{ data: T; }>; requestWithPagination(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise>; } /** * Field names for extracting data from paginated responses. */ interface PaginationFieldNames { itemsField?: string; totalCountField?: string; continuationTokenField?: string; } /** * Options for the requestWithPagination method in BaseService. */ interface RequestWithPaginationOptions extends RequestSpec { pagination: PaginationFieldNames & { paginationType: PaginationType; paginationParams?: { pageSizeParam?: string; offsetParam?: string; tokenParam?: string; countParam?: string; convertToSkip?: boolean; zeroBased?: boolean; }; }; } /** * HTTP methods supported by the API client */ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'; /** * Supported response types for API requests */ type ResponseType = 'json' | 'text' | 'blob' | 'arraybuffer' | 'stream'; /** * Query parameters type with support for arrays and nested objects */ type QueryParams = Record | null | undefined>; /** * Standard HTTP headers type */ type Headers = Record; /** * Options for request retries */ interface RetryOptions { /** Maximum number of retry attempts */ maxRetries?: number; /** Base delay between retries in milliseconds */ retryDelay?: number; /** Whether to use exponential backoff */ useExponentialBackoff?: boolean; /** Status codes that should trigger a retry */ retryableStatusCodes?: number[]; } /** * Options for request timeouts */ interface TimeoutOptions { /** Request timeout in milliseconds */ timeout?: number; /** Whether to abort the request on timeout */ abortOnTimeout?: boolean; } /** * Options for request body transformation */ interface BodyOptions { /** Whether to stringify the body */ stringify?: boolean; /** Content type override */ contentType?: string; } /** * Pagination metadata for API requests */ interface PaginationMetadata { /** Type of pagination used by the API endpoint */ paginationType: PaginationType; /** Response field containing items array (defaults to 'value') */ itemsField?: string; /** Response field containing total count (defaults to '@odata.count') */ totalCountField?: string; /** Response field containing continuation token (defaults to 'continuationToken') */ continuationTokenField?: string; } /** * Base interface for all API requests */ interface RequestSpec { /** HTTP method for the request */ method?: HttpMethod; /** URL endpoint for the request */ url?: string; /** Query parameters to be appended to the URL */ params?: QueryParams; /** HTTP headers to include with the request */ headers?: Headers; /** Raw body content (takes precedence over data) */ body?: unknown; /** Expected response type */ responseType?: ResponseType; /** Request timeout options */ timeoutOptions?: TimeoutOptions; /** Retry behavior options */ retryOptions?: RetryOptions; /** Body transformation options */ bodyOptions?: BodyOptions; /** AbortSignal for cancelling the request */ signal?: AbortSignal; /** Pagination metadata for the request */ pagination?: PaginationMetadata; } interface ApiResponse { data: T; } /** * Base class for all UiPath SDK services. * * Provides common functionality for authentication, configuration, and API communication. * All service classes extend this base to inherit dependency injection and HTTP client access. * * This class implements the dependency injection pattern where services receive a configured * UiPath instance. The ApiClient is created internally and handles all HTTP operations * including authentication token management. * * @remarks * Service classes should extend this base and call `super(uiPath)` in their constructor. * Protected HTTP methods (get, post, put, patch, delete) are available to all subclasses. * */ declare class BaseService { #private; /** * SDK configuration (read-only). Available to subclasses so they can * fall back to init-time defaults like `folderKey`. */ protected readonly config: { folderKey?: string; }; /** * Creates a base service instance with dependency injection. * * Extracts configuration, execution context, and token manager from the UiPath instance * to initialize an authenticated API client. The ApiClient handles all HTTP operations * and token management internally. * * @param instance - UiPath SDK instance providing authentication and configuration. * Services receive this via dependency injection in the modular pattern. * @param headers - Optional default headers to include in every request (e.g. `x-uipath-external-user-id` for * CAS external-app auth) * * @example * ```typescript * // Services automatically call this via super() * export class EntityService extends BaseService { * constructor(instance: IUiPath) { * super(instance); // Initializes the internal ApiClient * } * } * * // Usage in modular pattern * import { UiPath } from '@uipath/uipath-typescript/core'; * import { Entities } from '@uipath/uipath-typescript/entities'; * * const sdk = new UiPath(config); * await sdk.initialize(); * const entities = new Entities(sdk); * ``` */ constructor(instance: IUiPath, headers?: Record); /** * Gets a valid authentication token, refreshing if necessary. * Use this when you need to manually add Authorization headers (e.g., direct uploads). * * @returns Promise resolving to a valid access token string * @throws AuthenticationError if no token is available or refresh fails */ protected getValidAuthToken(): Promise; /** * Creates a service accessor for pagination helpers * This allows pagination helpers to access protected methods without making them public */ protected createPaginationServiceAccess(): PaginationServiceAccess; protected request(method: string, path: string, options?: RequestSpec): Promise>; protected requestWithSpec(spec: RequestSpec): Promise>; protected get(path: string, options?: RequestSpec): Promise>; protected post(path: string, data?: unknown, options?: RequestSpec): Promise>; protected put(path: string, data?: unknown, options?: RequestSpec): Promise>; protected patch(path: string, data?: unknown, options?: RequestSpec): Promise>; protected delete(path: string, options?: RequestSpec): Promise>; /** * Execute a request with cursor-based pagination */ protected requestWithPagination(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise>; /** * Validates and prepares pagination parameters from options */ private validateAndPreparePaginationParams; /** * Prepares request parameters for pagination based on pagination type */ private preparePaginationRequestParams; /** * Creates a paginated response from API response */ private createPaginatedResponseFromResponse; /** * Determines if there are more pages based on pagination type and metadata */ private determineHasMorePages; } /** * Common enum for job state used across services */ declare enum JobState { Pending = "Pending", Running = "Running", Stopping = "Stopping", Terminating = "Terminating", Faulted = "Faulted", Successful = "Successful", Stopped = "Stopped", Suspended = "Suspended", Resumed = "Resumed", Cancelled = "Cancelled", /** Server-side fallback for an unrecognized or missing job state. */ Unknown = "Unknown" } /** * Filter fields shared by agent endpoints that accept a * folder/agent/project scope (`/Agents/agents`, `/Agents/errors`, etc.). */ interface AgentFilterOptions { /** Optional folder keys to scope the lookup. Intersected with the user's accessible folders. */ folderKeys?: string[]; /** Filter to specific agent names. */ agentNames?: string[]; /** Filter to specific project keys. */ projectKeys?: string[]; /** Filter to a single agent by ID. */ agentId?: string; /** Filter to a specific process version. */ processVersion?: string; } /** * Columns available for ordering results. */ declare enum AgentListSortColumn { AgentName = "AgentName", ParentProcess = "ParentProcess", LastRun = "LastRun", HealthScore = "HealthScore", LastIncident = "LastIncident", FolderName = "FolderName", /** Quantity of Agent Units consumed */ QuantityAGU = "QuantityAGU", /** Quantity of Platform Units consumed */ QuantityPLTU = "QuantityPLTU", FolderPath = "FolderPath" } /** * Ordering directive for the agents list. */ interface AgentListOrderBy { /** Column to sort by */ column: AgentListSortColumn; /** * Sort descending. * @default false */ desc?: boolean; } /** * One row in the agents list - agent identity plus consumption and health metadata aggregated over the * requested time window. */ interface AgentListItem { /** Agent ID */ agentId: string; /** Agent display name */ agentName: string; /** Parent process name. May be `null` or `""` for jobs not bound to a parent process. */ parentProcess: string | null; /** Folder key of the folder the agent runs in. May be `null` or `""`. */ folderKey: string | null; /** Folder display name. May be `null` or `""`. */ folderName: string | null; /** Fully qualified folder path. May be `null` or `""`. */ folderPath: string | null; /** Last run timestamp */ lastRun: string; /** Process key. May be `null` or `""` for ad-hoc jobs. */ processKey: string | null; /** Process version. May be `null` or `""`. */ processVersion: string | null; /** Health score (0-100) */ healthScore: number; /** Last incident type label. May be `null` or `""`. */ lastIncidentType: string | null; /** Total units consumed by this agent in the window */ unitsQuantity: number; /** Display name of the units (if any). May be `null` or `""`. */ unitsName: string | null; /** Quantity of Agent Units consumed by this agent */ quantityAGU: number; /** Quantity of Platform Units consumed by this agent */ quantityPLTU: number; } /** * Options for getting the list of agents. * * Composes filter, pagination, and sort options. */ type AgentGetAllOptions = AgentFilterOptions & PaginationOptions & { /** Sort order for the result set. */ orderBy?: AgentListOrderBy; }; /** * Summary information about a single job execution — included on every * error entry to anchor the window. */ interface AgentJobInfo { /** Job key */ jobKey: string; /** Folder key the job ran in */ folderKey: string; /** Display name of the folder */ folderName: string; /** Fully qualified folder path */ folderPath: string; /** Job start time */ startTime: string; /** Job end time. `null` while the job is still running. */ endTime: string | null; /** Process key the job was launched from. `null` for ad-hoc jobs. */ processKey: string | null; } /** * Columns available for ordering / grouping the agent errors list. */ declare enum AgentErrorSortColumn { AgentId = "AgentId", AgentName = "AgentName", ParentProcessName = "ParentProcessName", ErrorTitle = "ErrorTitle", FirstSeenStartTime = "FirstSeenStartTime", ExecutionCount = "ExecutionCount", Type = "Type", FirstSeenFolderName = "FirstSeenFolderName", FirstSeenFolderPath = "FirstSeenFolderPath", LastSeenStartTime = "LastSeenStartTime", LastSeenFolderName = "LastSeenFolderName", LastSeenFolderPath = "LastSeenFolderPath" } /** * Ordering directive for the agent errors list. */ interface AgentErrorOrderBy { /** Column to sort by */ column: AgentErrorSortColumn; /** * Sort descending. * @default false */ desc?: boolean; } /** * One error in the agent errors list — an error/error-class observed * for an agent over the requested window. */ interface AgentError { /** Error type */ type: string; /** Error description */ description: string; /** Agent ID */ agentId: string; /** Agent display name. `null` if the agent has no display name set. */ agentName: string | null; /** Job key where the error was first seen */ jobKey: string; /** Parent process name. `null` for jobs not bound to a parent process. */ parentProcess: string | null; /** First-seen timestamp */ firstSeen: string; /** Folder key where the error was first observed */ folderKey: string; /** Folder display name */ folderName: string; /** Fully qualified folder path */ folderPath: string; /** Number of error executions counted for this error */ count: number; /** First job in the window where this error was observed */ firstSeenJob: AgentJobInfo; /** Last job in the window where this error was observed */ lastSeenJob: AgentJobInfo; } /** * Options for the agent errors list. * * Composes filter, pagination, and sort/group options. */ type AgentGetErrorsOptions = AgentFilterOptions & PaginationOptions & { /** Sort order for the result set. */ orderBy?: AgentErrorOrderBy; /** Group results by one or more columns. */ groupBy?: AgentErrorSortColumn[]; }; /** * A single point on the agent errors timeline */ interface AgentGetErrorsTimelineResponse { /** Agent name */ name: string; /** Error count in this time bucket */ value: number; /** Bucket timestamp (ISO 8601, UTC) */ date: string; } /** * Options for getting the agent errors timeline. */ interface AgentGetErrorsTimelineOptions extends AgentFilterOptions { /** * Max number of agents to return. * @default 10 */ limit?: number; } /** * A single point on the agent consumption timeline */ interface AgentGetConsumptionTimelineResponse { /** Bucket timestamp (ISO 8601, UTC) */ timeSlice: string; /** Agent Units quantity consumed in this time bucket */ aguConsumption: number; } /** * Options for getting the agent consumption timeline. */ interface AgentGetConsumptionTimelineOptions extends AgentFilterOptions { } /** * A single point on the agent latency timeline */ interface AgentGetLatencyTimelineResponse { /** * Percentile label for this point — observed values: `"P50"`, `"P95"`. */ name: string; /** Latency value in milliseconds. */ value: number; /** Bucket timestamp (ISO 8601, UTC) */ date: string; } /** * Options for getting the agent latency timeline. */ interface AgentGetLatencyTimelineOptions extends AgentFilterOptions { } /** * A single agent's error count over the requested window, with the first and * last jobs where errors were observed. */ interface AgentTopErrorCount { /** Agent name */ name: string; /** Error count for this agent over the requested window */ count: number; /** Agent ID (GUID) */ agentId: string; /** First job in the window where this agent reported errors */ firstSeenJob: AgentJobInfo; /** Last job in the window where this agent reported errors */ lastSeenJob: AgentJobInfo; } /** * Response from getting the top agents by error count. */ interface AgentGetTopErrorCountResponse { /** Total error count across all agents in the window. */ totalErrors: number; /** Top-N agents ranked by error count. */ data: AgentTopErrorCount[]; } /** * Options for getting the top agents by error count. */ interface AgentGetTopErrorCountOptions extends AgentFilterOptions { /** * Max number of agents to return. Defaults to 10 server-side. * @default 10 */ limit?: number; } /** * Agent type, used to filter consumption results. * * Wire format is the string name, per the API's `StringEnumConverter` serialization. */ declare enum AgentType { Autonomous = "Autonomous", Conversational = "Conversational", Coded = "Coded" } /** * A single agent's unit consumption over the requested window, with the first * and last jobs where consumption was recorded. */ interface AgentConsumption { /** Agent ID (GUID) */ agentId: string; /** Agent display name */ agentName: string; /** Total quantity consumed by this agent. `null` if no consumption is recorded. */ consumedQuantity: number | null; /** Agent Units quantity consumed. `null` if no consumption is recorded. */ consumedAGUQuantity: number | null; /** Platform Units quantity consumed. `null` if no consumption is recorded. */ consumedPLTUQuantity: number | null; /** First job in the window where this agent recorded consumption */ firstSeenJob: AgentJobInfo; /** Last job in the window where this agent recorded consumption */ lastSeenJob: AgentJobInfo; } /** * Response from getting the top agents by consumption. */ interface AgentGetTopConsumptionResponse { /** Window start date. */ startDate: string; /** Window end date. */ endDate: string; /** Total quantity consumed across all matching agents in the window. */ totalConsumed: number; /** Total Agent Units quantity consumed. */ totalAGUConsumed: number; /** Total Platform Units quantity consumed. */ totalPLTUConsumed: number; /** Limit applied (echoed from the request). */ limit: number; /** Top-N agents ranked by consumption. Empty array when no agents matched. */ agents: AgentConsumption[]; } /** * Options for getting the top agents by consumption. */ interface AgentGetTopConsumptionOptions extends AgentFilterOptions { /** * Max number of agents to return. Defaults to 10 server-side. * @default 10 */ limit?: number; /** * Health-based filter. `true` returns only healthy agents, `false` only * unhealthy. Omit to include both. */ healthy?: boolean; /** * Health-score cutoff used when `healthy` is set. Defaults to 75.0 * server-side. * @default 75.0 */ healthThreshold?: number; /** * Filter to specific agent types. Multiple types are combined with `OR` and * sent to the API as a comma-separated string. */ agentTypes?: AgentType[]; } /** * Distribution of incidents across types over the requested window. */ interface AgentGetIncidentDistributionResponse { /** Number of error-type incidents in the window */ errorCount: number; /** Number of escalation-type incidents in the window */ escalationCount: number; /** Number of policy-type incidents in the window */ policyCount: number; } /** * Options for getting the incident distribution. * * Currently identical to {@link AgentFilterOptions}; named distinctly so that * future per-method filters can be added without a breaking change. */ interface AgentGetIncidentDistributionOptions extends AgentFilterOptions { } /** * Per-agent (process + folder) stats within an {@link AgentSummaryPeriod}. */ interface AgentSummaryEntry { /** Process key (GUID) */ processKey: string; /** Folder key (GUID) the agent ran in */ folderKey: string; /** Process version */ processVersion: string; /** Total job runs in the period */ totalJobs: number; /** Number of successful runs in the period */ successfulJobs: number; /** Success rate as a percentage (0-100) */ successRate: number; /** Average run duration in seconds */ averageDurationSeconds: number; /** First job completion timestamp (ISO 8601, UTC) */ firstJobFinished: string; /** Last job completion timestamp (ISO 8601, UTC) */ lastJobFinished: string; /** * Status of the most recent run, normalized to {@link JobState}. The API's * `Success` label maps to {@link JobState.Successful}; any unrecognized value * becomes {@link JobState.Unknown}. */ lastJobStatus: JobState; } /** * Aggregate stats for a single period within an {@link AgentGetSummaryResponse} * — covers the requested window for either the current period or an optional * lookback period. */ interface AgentSummaryPeriod { /** Total job runs across all agents in the period */ totalJobs: number; /** Number of successful runs across all agents in the period */ successfulJobs: number; /** Overall success rate as a percentage (0-100) */ successRate: number; /** Average run duration in seconds across all agents in the period */ averageDurationSeconds: number; /** Period start time (ISO 8601, UTC) */ startTime: string; /** Period end time (ISO 8601, UTC) */ endTime: string; /** Per-agent breakdown */ agents: AgentSummaryEntry[]; } /** * Response from getting the agent summary. */ interface AgentGetSummaryResponse { /** Aggregate stats for the requested window. Always present. */ currentPeriodSummary: AgentSummaryPeriod; /** Aggregate stats for the prior window of equal length. Only present when `lookbackPeriodAnalysis: true` was sent. */ lookbackPeriodSummary?: AgentSummaryPeriod; } /** * Job execution mode filter accepted by the summary endpoints. * * Wire format is the string name (`"Debug"` / `"Runtime"`), per the API's * `StringEnumConverter` serialization. */ declare enum AgentExecutionType { /** Test runs */ Debug = "Debug", /** Production runs */ Runtime = "Runtime" } /** * Options for getting the agent summary. */ interface AgentGetSummaryOptions extends AgentFilterOptions { /** * When `true`, it also computes a `lookbackPeriodSummary` for the * prior window of equal length. Defaults to `false` server-side. * @default false */ lookbackPeriodAnalysis?: boolean; /** Filter to a specific process by key (GUID). */ processKey?: string; /** * Filter to a specific folder by key (GUID). * * The summary endpoint accepts both — `folderKey` selects a * single folder, `folderKeys` filters the lookup to a list of folders. */ folderKey?: string; /** * Filter to a specific execution type — `Debug` (test runs) or * `Runtime` (production runs). */ executionType?: AgentExecutionType; } /** * Job-type breakdown of unit consumption — completed jobs vs jobs still in * progress at query time. */ interface AgentJobConsumptionSummary { /** Units consumed by jobs that have completed in the period */ completeJobs: number; /** Units consumed by jobs still in progress at query time */ incompleteJobs: number; } /** * Per-agent (process + folder) unit consumption entry within an * {@link AgentUnitConsumptionPeriod}. */ interface AgentUnitConsumptionEntry { /** Folder key (GUID) the agent ran in */ folderKey: string; /** Process key (GUID) */ processKey: string; /** Process version */ processVersion: string; /** First job completion timestamp (ISO 8601). `"0001-01-01T00:00:00"` if no completion in the period. */ firstJobFinished: string; /** Last job completion timestamp (ISO 8601). `"0001-01-01T00:00:00"` if no completion in the period. */ lastJobFinished: string; /** Agent Units consumption for this agent, split by job completion status */ agentUnitConsumption: AgentJobConsumptionSummary; /** Platform Units consumption for this agent, split by job completion status */ platformUnitConsumption: AgentJobConsumptionSummary; } /** * Aggregate Agent Units and Platform Units consumption for a single period within an * {@link AgentGetUnitConsumptionSummaryResponse} — covers the requested window * for either the current period or an optional lookback period. */ interface AgentUnitConsumptionPeriod { /** Total Agent Units consumed across all agents in the period, split by job completion */ totalAgentUnitConsumption: AgentJobConsumptionSummary; /** Total Platform Units consumed across all agents in the period, split by job completion */ totalPlatformUnitConsumption: AgentJobConsumptionSummary; /** Period start time (ISO 8601, UTC) */ startTime: string; /** Period end time (ISO 8601, UTC) */ endTime: string; /** Per-agent consumption breakdown */ agentConsumption: AgentUnitConsumptionEntry[]; } /** * Response from getting the agent unit consumption summary. */ interface AgentGetUnitConsumptionSummaryResponse { /** Aggregate consumption for the requested window. Always present. */ currentPeriodSummary: AgentUnitConsumptionPeriod; /** Aggregate consumption for the prior window of equal length. Only present when `lookbackPeriodAnalysis: true` was sent. */ lookbackPeriodSummary?: AgentUnitConsumptionPeriod; } /** * Options for getting the agent unit consumption summary. * * Currently identical to {@link AgentGetSummaryOptions} (the API uses the same * `AgentsSummaryRequest` schema for both endpoints); named distinctly so that * future per-method filters can be added without a breaking change. */ interface AgentGetUnitConsumptionSummaryOptions extends AgentGetSummaryOptions { } /** * Service for retrieving runtime data for UiPath Agents. * * UiPath Agents are AI-driven automations powered by large language models * and machine learning that plan, make decisions, and execute tasks in * dynamic environments. * * See [About Agents](https://docs.uipath.com/agents/automation-cloud/latest/user-guide/about-agents) * for an overview of UiPath Agents. * * ### Usage * * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) * * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * const list = await agents.getAll( * new Date('2025-01-01T00:00:00Z'), * new Date('2025-02-01T00:00:00Z'), * ); * ``` */ interface AgentServiceModel { /** * Retrieves the list of agents on the tenant with consumption and health * metadata over the requested window. * * Returns a {@link PaginatedResponse} when pagination options (`pageSize`, * `cursor`, or `jumpToPage`) are provided, otherwise a * {@link NonPaginatedResponse}. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional pagination, sort, and filters * @returns Promise resolving to a paginated or non-paginated list of {@link AgentListItem} * @example * ```typescript * import { Agents, AgentListSortColumn } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Non-paginated — returns the server default page * const result = await agents.getAll( * new Date('2025-05-01T00:00:00Z'), * new Date('2026-05-14T00:00:00Z'), * ); * result.items.forEach((agent) => { * console.log(`${agent.agentName} — ${agent.unitsQuantity} units, health=${agent.healthScore}`); * }); * * // Paginated — sorted by health score descending * const page = await agents.getAll( * new Date('2025-05-01T00:00:00Z'), * new Date('2026-05-14T00:00:00Z'), * { * pageSize: 25, * orderBy: { column: AgentListSortColumn.HealthScore, desc: true }, * folderKeys: [''], * }, * ); * * if (page.hasNextPage && page.nextCursor) { * const next = await agents.getAll( * new Date('2025-05-01T00:00:00Z'), * new Date('2026-05-14T00:00:00Z'), * { cursor: page.nextCursor }, * ); * } * ``` */ getAll(startTime: Date, endTime: Date, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Retrieves agent errors (error-classes observed for agents) over the * requested window. * * Returns a {@link PaginatedResponse} when pagination options (`pageSize`, * `cursor`, or `jumpToPage`) are provided, otherwise a * {@link NonPaginatedResponse}. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional pagination, sort/group, and filters * @returns Promise resolving to a paginated or non-paginated list of {@link AgentError} * @example * ```typescript * import { Agents, AgentErrorSortColumn } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Non-paginated — errors in the window * const result = await agents.getErrors( * new Date('2025-05-01T00:00:00Z'), * new Date('2026-05-14T00:00:00Z'), * ); * result.items.forEach((error) => { * console.log(`${error.type}: ${error.description} (count=${error.count})`); * }); * * // Paginated — sorted by execution count descending * const page = await agents.getErrors( * new Date('2025-05-01T00:00:00Z'), * new Date('2026-05-14T00:00:00Z'), * { * pageSize: 25, * orderBy: { column: AgentErrorSortColumn.ExecutionCount, desc: true }, * }, * ); * * if (page.hasNextPage && page.nextCursor) { * const next = await agents.getErrors( * new Date('2025-05-01T00:00:00Z'), * new Date('2026-05-14T00:00:00Z'), * { cursor: page.nextCursor }, * ); * } * ``` */ getErrors(startTime: Date, endTime: Date, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Retrieves a time-series of error counts grouped by agent over the requested window. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to an array of {@link AgentGetErrorsTimelineResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // All errors in May 2025 * const result = await agents.getErrorsTimeline( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * result.forEach((point) => { * console.log(`${point.date} ${point.name}: ${point.value} errors`); * }); * ``` * @example * ```typescript * // Scope to specific folders and top 5 agents * const result = await agents.getErrorsTimeline( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * folderKeys: [''], * agentNames: ['JokeAgent', 'StoryAgent'], * limit: 5, * }, * ); * ``` */ getErrorsTimeline(startTime: Date, endTime: Date, options?: AgentGetErrorsTimelineOptions): Promise; /** * Retrieves a time-series of Agent Units consumption over the requested window. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to an array of {@link AgentGetConsumptionTimelineResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Agent Units consumption timeline in May 2025 * const result = await agents.getConsumptionTimeline( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * result.forEach((point) => { * console.log(`${point.timeSlice}: ${point.aguConsumption} Agent Units`); * }); * ``` * @example * ```typescript * // Scope to specific folders and agents * const result = await agents.getConsumptionTimeline( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * folderKeys: [''], * agentNames: ['JokeAgent'], * }, * ); * ``` */ getConsumptionTimeline(startTime: Date, endTime: Date, options?: AgentGetConsumptionTimelineOptions): Promise; /** * Retrieves a time-series of agent latency (milliseconds) over the requested * window. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to an array of {@link AgentGetLatencyTimelineResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Latency timeline in May 2025 * const result = await agents.getLatencyTimeline( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * result.forEach((point) => { * console.log(`${point.date} ${point.name}: ${point.value} ms`); * }); * ``` * @example * ```typescript * // Scope to specific folders and a single agent * const result = await agents.getLatencyTimeline( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * folderKeys: [''], * agentId: '', * }, * ); * ``` */ getLatencyTimeline(startTime: Date, endTime: Date, options?: AgentGetLatencyTimelineOptions): Promise; /** * Retrieves the top-N agents ranked by error count over the requested window. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to {@link AgentGetTopErrorCountResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Top agents by error count in May 2025 * const result = await agents.getTopErrorCount( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * result.data.forEach((agent) => { * console.log(`${agent.name}: ${agent.count} errors`); * }); * ``` * @example * ```typescript * // Scope to specific folders and top 5 agents * const result = await agents.getTopErrorCount( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * folderKeys: [''], * limit: 5, * }, * ); * ``` */ getTopErrorCount(startTime: Date, endTime: Date, options?: AgentGetTopErrorCountOptions): Promise; /** * Retrieves the top-N agents ranked by unit consumption over the requested window. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to {@link AgentGetTopConsumptionResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Top agents by consumption in May 2025 * const result = await agents.getTopConsumption( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * console.log(`Total consumed: ${result.totalConsumed}`); * result.agents.forEach((agent) => { * console.log(`${agent.agentName}: ${agent.consumedQuantity}`); * }); * ``` * @example * ```typescript * import { Agents, AgentType } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Top 5 healthy autonomous agents by consumption * const result = await agents.getTopConsumption( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * limit: 5, * healthy: true, * agentTypes: [AgentType.Autonomous], * }, * ); * ``` */ getTopConsumption(startTime: Date, endTime: Date, options?: AgentGetTopConsumptionOptions): Promise; /** * Retrieves breakdown of agent incidents count — errors, escalations, * and policy violations over a requested window. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to {@link AgentGetIncidentDistributionResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Incident distribution in May 2025 * const result = await agents.getIncidentDistribution( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * console.log(`Errors: ${result.errorCount}, Escalations: ${result.escalationCount}, Policy: ${result.policyCount}`); * ``` * @example * ```typescript * // Scope to specific folders * const result = await agents.getIncidentDistribution( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * folderKeys: [''], * }, * ); * ``` */ getIncidentDistribution(startTime: Date, endTime: Date, options?: AgentGetIncidentDistributionOptions): Promise; /** * Retrieves a job-execution summary for the requested window: overall totals * (total jobs, successful jobs, success rate, average duration) alongside a * per-agent breakdown. When `lookbackPeriodAnalysis` is enabled, a comparable * summary for the preceding window of equal length is included too. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to {@link AgentGetSummaryResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Summary for May 2025 * const result = await agents.getSummary( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * console.log(`Success rate: ${result.currentPeriodSummary.successRate}%`); * ``` * @example * ```typescript * import { Agents, AgentExecutionType } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Runtime-only summary with lookback comparison * const result = await agents.getSummary( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * lookbackPeriodAnalysis: true, * executionType: AgentExecutionType.Runtime, * }, * ); * ``` */ getSummary(startTime: Date, endTime: Date, options?: AgentGetSummaryOptions): Promise; /** * Retrieves an aggregate Agent Units and Platform Units consumption summary per agent over the * requested window. * * @param startTime - Inclusive lower bound for the query window * @param endTime - Exclusive upper bound for the query window * @param options - Optional filters * @returns Promise resolving to {@link AgentGetUnitConsumptionSummaryResponse} * @example * ```typescript * import { Agents } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Unit consumption summary for May 2025 * const result = await agents.getUnitConsumptionSummary( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * ); * console.log(`Agent Units complete jobs: ${result.currentPeriodSummary.totalAgentUnitConsumption.completeJobs}`); * ``` * @example * ```typescript * import { Agents, AgentExecutionType } from '@uipath/uipath-typescript/agents'; * * const agents = new Agents(sdk); * * // Runtime-only summary with lookback comparison * const result = await agents.getUnitConsumptionSummary( * new Date('2025-05-01T00:00:00Z'), * new Date('2025-06-01T00:00:00Z'), * { * lookbackPeriodAnalysis: true, * executionType: AgentExecutionType.Runtime, * }, * ); * ``` */ getUnitConsumptionSummary(startTime: Date, endTime: Date, options?: AgentGetUnitConsumptionSummaryOptions): Promise; } /** * Service for interacting with the UiPath Agents API. */ declare class AgentService extends BaseService implements AgentServiceModel { getAll(startTime: Date, endTime: Date, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; getErrors(startTime: Date, endTime: Date, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; getErrorsTimeline(startTime: Date, endTime: Date, options?: AgentGetErrorsTimelineOptions): Promise; getConsumptionTimeline(startTime: Date, endTime: Date, options?: AgentGetConsumptionTimelineOptions): Promise; getLatencyTimeline(startTime: Date, endTime: Date, options?: AgentGetLatencyTimelineOptions): Promise; getTopErrorCount(startTime: Date, endTime: Date, options?: AgentGetTopErrorCountOptions): Promise; getTopConsumption(startTime: Date, endTime: Date, options?: AgentGetTopConsumptionOptions): Promise; getIncidentDistribution(startTime: Date, endTime: Date, options?: AgentGetIncidentDistributionOptions): Promise; getSummary(startTime: Date, endTime: Date, options?: AgentGetSummaryOptions): Promise; getUnitConsumptionSummary(startTime: Date, endTime: Date, options?: AgentGetUnitConsumptionSummaryOptions): Promise; /** * Builds the common POST request body shared by the agent filter endpoints — * the required time window plus any optional folder/agent/project/process * filters. Undefined options are omitted so the server applies its defaults. */ private buildAgentFilterBody; } export { AgentErrorSortColumn, AgentExecutionType, AgentListSortColumn, AgentType, AgentService as Agents }; export type { AgentConsumption, AgentError, AgentErrorOrderBy, AgentFilterOptions, AgentGetAllOptions, AgentGetConsumptionTimelineOptions, AgentGetConsumptionTimelineResponse, AgentGetErrorsOptions, AgentGetErrorsTimelineOptions, AgentGetErrorsTimelineResponse, AgentGetIncidentDistributionOptions, AgentGetIncidentDistributionResponse, AgentGetLatencyTimelineOptions, AgentGetLatencyTimelineResponse, AgentGetSummaryOptions, AgentGetSummaryResponse, AgentGetTopConsumptionOptions, AgentGetTopConsumptionResponse, AgentGetTopErrorCountOptions, AgentGetTopErrorCountResponse, AgentGetUnitConsumptionSummaryOptions, AgentGetUnitConsumptionSummaryResponse, AgentJobConsumptionSummary, AgentJobInfo, AgentListItem, AgentListOrderBy, AgentServiceModel, AgentSummaryEntry, AgentSummaryPeriod, AgentTopErrorCount, AgentUnitConsumptionEntry, AgentUnitConsumptionPeriod };