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; } /** * 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; } /** * Types for the Agent Memory metrics service. */ /** * Execution kind to filter Agent Memory queries by. Omit to include both * Debug and Runtime executions. */ declare enum AgentMemoryExecutionType { /** Executions produced during agent debugging sessions. */ Debug = "Debug", /** Executions produced during production runtime. */ Runtime = "Runtime" } /** * Common time-window and scope filters shared by Agent Memory queries. * * All fields are optional. When `startTime`/`endTime` are omitted, the query * defaults to the last 24 hours, with `endTime` defaulting to now. */ interface AgentMemoryFilterOptions { /** Inclusive lower bound for the query window. Defaults to 24 hours before `endTime` when omitted. */ startTime?: Date; /** Exclusive upper bound for the query window. Defaults to now when omitted. */ endTime?: Date; /** Filter to a single agent by ID. Obtain an `agentId` from the Agents service. */ agentId?: string; /** Filter to a specific agent version. */ agentVersion?: string; /** Folder keys to scope the query. Results are limited to folders you can access. */ folderKeys?: string[]; /** Filter to a specific execution kind. Omit to include both Debug and Runtime. */ executionType?: AgentMemoryExecutionType; } /** * Options for retrieving the agent-memory state timeline. */ interface AgentMemoryGetTimelineOptions extends AgentMemoryFilterOptions { } /** * Options for retrieving the memory-calls timeline. */ interface AgentMemoryGetCallsTimelineOptions extends AgentMemoryFilterOptions { } /** * Options for retrieving the top memory spaces. */ interface AgentMemoryGetTopSpacesOptions extends AgentMemoryFilterOptions { /** * Maximum number of memory spaces to return, ranked by memory count. * @default 5 */ limit?: number; } /** * One point on the agent-memory state timeline — memory-state counts for a * single time bucket. */ interface AgentMemoryGetTimelineResponse { /** Bucket timestamp. */ timeSlice: string; /** Count of memory entries that were in-memory in this bucket. */ inMemoryCount: number; /** Count of memory entries that were not in-memory in this bucket. */ notInMemoryCount: number; /** Total memory entries in this bucket. */ totalCount: number; /** Count of enabled memory entries in this bucket. */ enabledMemoryCount: number; /** Count of disabled memory entries in this bucket. */ disabledMemoryCount: number; } /** * One point on the memory-calls timeline — the count of memory calls for a * single time bucket. */ interface AgentMemoryGetCallsTimelineResponse { /** Bucket timestamp. */ timeSlice: string; /** Number of memory calls in this bucket. */ memoryCallsCount: number; } /** * A single memory space with its enabled/disabled memory-entry breakdown. */ interface AgentMemoryGetTopSpacesResponse { /** Memory space identifier. */ memorySpaceId: string; /** Memory space display name. */ memorySpaceName: string; /** Total memory entries in this space over the requested window. */ memoryCount: number; /** Count of enabled memory entries in this space. */ enabledMemoryCount: number; /** Count of disabled memory entries in this space. */ disabledMemoryCount: number; } /** * * @experimental * * /// warning * Preview: This service is experimental and may change or be removed in future releases. * /// * * Service for managing UiPath Agent Memory. * * Agent Memory is a persistent store of information an agent * retains across runs to improve runtime reliability. * * @example * ```typescript * import { UiPath } from '@uipath/uipath-typescript/core'; * import { AgentMemory } from '@uipath/uipath-typescript/agent-memory'; * * const sdk = new UiPath(config); * await sdk.initialize(); * * const memory = new AgentMemory(sdk); * const timeline = await memory.getTimeline(); * ``` */ interface AgentMemoryServiceModel { /** * Gets agent memory state over time, with optional filters. * * @experimental * * /// warning * Preview: This method is experimental and may change or be removed in future releases. * /// * * @param options - Optional time window and scope filters * @returns Promise resolving to an array of {@link AgentMemoryGetTimelineResponse}, one per time bucket. * @example * ```typescript * import { AgentMemory } from '@uipath/uipath-typescript/agent-memory'; * * const memory = new AgentMemory(sdk); * * // Last 24 hours (default window) * const timeline = await memory.getTimeline(); * console.log(timeline[0]?.inMemoryCount); * ``` * @example * ```typescript * import { AgentMemoryExecutionType } from '@uipath/uipath-typescript/agent-memory'; * * // Scoped to one agent in one folder, runtime executions only * const scoped = await memory.getTimeline({ * startTime: new Date('2026-05-01T00:00:00Z'), * endTime: new Date('2026-06-01T00:00:00Z'), * agentId: '', * folderKeys: [''], * executionType: AgentMemoryExecutionType.Runtime, * }); * ``` */ getTimeline(options?: AgentMemoryGetTimelineOptions): Promise; /** * Gets the number of agent memory calls (accesses to the memory store) over time, with optional filters. * * @experimental * * /// warning * Preview: This method is experimental and may change or be removed in future releases. * /// * * @param options - Optional time window and scope filters * @returns Promise resolving to an array of {@link AgentMemoryGetCallsTimelineResponse}, one per time bucket. * @example * ```typescript * import { AgentMemory } from '@uipath/uipath-typescript/agent-memory'; * * const memory = new AgentMemory(sdk); * * // Last 24 hours (default window) * const timeline = await memory.getCallsTimeline(); * console.log(timeline[0]?.memoryCallsCount); * ``` * @example * ```typescript * import { AgentMemoryExecutionType } from '@uipath/uipath-typescript/agent-memory'; * * // Scoped to one agent in one folder, runtime executions only * const scoped = await memory.getCallsTimeline({ * startTime: new Date('2026-05-01T00:00:00Z'), * endTime: new Date('2026-06-01T00:00:00Z'), * agentId: '', * folderKeys: [''], * executionType: AgentMemoryExecutionType.Runtime, * }); * ``` */ getCallsTimeline(options?: AgentMemoryGetCallsTimelineOptions): Promise; /** * Gets the top memory spaces by memory count, with optional filters * * @experimental * * /// warning * Preview: This method is experimental and may change or be removed in future releases. * /// * * @param options - Optional limit, time window, and scope filters * @returns Promise resolving to an array of {@link AgentMemoryGetTopSpacesResponse}, ranked by memory count. * @example * ```typescript * import { AgentMemory } from '@uipath/uipath-typescript/agent-memory'; * * const memory = new AgentMemory(sdk); * * // Top 5 memory spaces (default limit and window) * const top = await memory.getTopSpaces(); * console.log(top[0]?.memorySpaceName, top[0]?.memoryCount); * ``` * @example * ```typescript * import { AgentMemoryExecutionType } from '@uipath/uipath-typescript/agent-memory'; * * // Top 10 spaces for one folder over an explicit window, runtime executions only * const topScoped = await memory.getTopSpaces({ * startTime: new Date('2026-05-01T00:00:00Z'), * endTime: new Date('2026-06-01T00:00:00Z'), * folderKeys: [''], * executionType: AgentMemoryExecutionType.Runtime, * limit: 10, * }); * ``` */ getTopSpaces(options?: AgentMemoryGetTopSpacesOptions): Promise; } /** * Service for managing UiPath Agent Memory. */ declare class MemoryService extends BaseService implements AgentMemoryServiceModel { getTimeline(options?: AgentMemoryGetTimelineOptions): Promise; getCallsTimeline(options?: AgentMemoryGetCallsTimelineOptions): Promise; getTopSpaces(options?: AgentMemoryGetTopSpacesOptions): Promise; private buildMemoryFilterBody; } export { MemoryService as AgentMemory, AgentMemoryExecutionType }; export type { AgentMemoryFilterOptions, AgentMemoryGetCallsTimelineOptions, AgentMemoryGetCallsTimelineResponse, AgentMemoryGetTimelineOptions, AgentMemoryGetTimelineResponse, AgentMemoryGetTopSpacesOptions, AgentMemoryGetTopSpacesResponse, AgentMemoryServiceModel };