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; } /** Status of a span: whether it completed successfully, with an error, or was not set. */ declare enum SpanStatus { Unset = "Unset", Ok = "Ok", Error = "Error", /** Span is still in progress. */ Running = "Running", /** Span data is hidden from the caller due to tenant/folder permission rules. */ Restricted = "Restricted", /** Span was cancelled before completion. */ Cancelled = "Cancelled" } /** Platform source that produced the span. */ declare enum SpanSource { Testing = "Testing", Agents = "Agents", ProcessOrchestration = "ProcessOrchestration", ApiWorkflows = "ApiWorkflows", Robots = "Robots", ConversationalAgentsService = "ConversationalAgentsService", IntegrationServiceTrigger = "IntegrationServiceTrigger", Playground = "Playground", Governance = "Governance", /** Intelligent Experience Platform — unstructured and complex document processing source. */ IXPUnstructuredAndComplexDocuments = "IXPUnstructuredAndComplexDocuments", /** Agents authored in code (as opposed to visual/no-code designers). */ CodedAgents = "CodedAgents", /** Intelligent Experience Platform — communications mining source. */ IXPCommunicationsMining = "IXPCommunicationsMining", /** UiPath Context Grounding — span produced by the Enterprise Context Service for RAG/knowledge-base operations. */ EnterpriseContextService = "EnterpriseContextService", /** Model Context Protocol — span produced by an MCP server integration. */ MCP = "MCP", /** Agent-to-Agent — span produced by an A2A protocol call between agents. */ A2A = "A2A", /** Serverless — span produced by a serverless function execution. */ Serverless = "Serverless" } /** Minimum severity level of events captured in the span. */ declare enum SpanVerbosityLevel { Verbose = "Verbose", Trace = "Trace", Information = "Information", Warning = "Warning", Error = "Error", Critical = "Critical", Off = "Off" } /** Whether the span was produced during a debug or production runtime. */ declare enum SpanExecutionType { Debug = "Debug", Runtime = "Runtime" } /** Whether the caller has permission to read this span's data. */ declare enum SpanPermissionStatus { Allow = "Allow", /** Some span fields are redacted due to permission constraints (e.g. attributes visible but payload hidden). */ PartialBlock = "PartialBlock", Block = "Block" } /** Storage provider that created or manages the attachment. */ declare enum SpanAttachmentProvider { Orchestrator = "Orchestrator", /** Span attachment stored by the observability platform. */ LLMOps = "LLMOps" } /** Whether the attachment is an input, output, or neither. */ declare enum SpanAttachmentDirection { None = "None", In = "In", Out = "Out" } /** One level in the reference hierarchy that produced this span. */ interface SpanReferenceHierarchyEntry { serviceType: string; referenceId: string; version: string | null; } /** Contextual lineage attached to the span (reference hierarchy). */ interface SpanContext { referenceHierarchy: SpanReferenceHierarchyEntry[]; } /** File or payload attachment linked to the span. */ interface SpanAttachment { provider: SpanAttachmentProvider; id: string; fileName: string; mimeType: string; direction: SpanAttachmentDirection; } /** A single execution span returned by the Traces API. */ interface SpanGetResponse { /** Unique identifier of this span (GUID). */ id: string; /** Trace this span belongs to (GUID). */ traceId: string; /** Parent span ID, or null for root spans. */ parentId: string | null; /** Human-readable name of the operation, or null if the span has no name. */ name: string | null; /** ISO-8601 UTC timestamp when the span started. */ startTime: string; /** ISO-8601 UTC timestamp when the span ended, or null if still running. */ endTime: string | null; /** * Span attributes (user-defined schema — do not transform keys). * Values depend on the span type and the agent that produced them. */ attributes: Record; /** Completion status of the span. */ status: SpanStatus; /** Platform source that produced the span. */ source: SpanSource | null; /** Span type tag (e.g. `"agentRun"`, `"llmCall"`). */ spanType: string | null; /** Minimum verbosity level captured in this span. */ verbosityLevel: SpanVerbosityLevel | null; /** Whether this span was from a debug or runtime execution. */ executionType: SpanExecutionType | null; /** Folder key (GUID) scoping this span. */ folderKey: string | null; /** Identifier of the entity (agent, process, etc.) that produced the span. */ referenceId: string | null; /** Version of the entity that produced the span. */ referenceVersion: string | null; /** Version of the agent runtime. */ agentVersion: string | null; /** Organization (account) GUID. */ organizationId: string; /** Tenant GUID. */ tenantId: string | null; /** Key of the process associated with this span. */ processKey: string | null; /** Key of the job associated with this span. */ jobKey: string | null; /** ISO-8601 UTC timestamp of last update. */ updatedAt: string; /** Expiry timestamp, or null if the span does not expire. */ expiredTime: string | null; /** Reference hierarchy context for this span. */ context: SpanContext | null; /** File or payload attachments linked to this span. */ attachments: SpanAttachment[] | null; /** Whether the caller can read this span's data. */ permissionStatus: SpanPermissionStatus | null; } /** Options for retrieving all spans belonging to a trace. */ interface TracesGetByIdOptions { /** Maximum number of spans to return. */ pageSize?: number; /** Filter spans to those produced by a specific agent ID. */ agentId?: string; /** When true, include expired spans that are outside the default retention window. */ includeExpiredSpans?: boolean; } /** * Service for querying UiPath execution traces (spans). * * Traces are OpenTelemetry-compatible execution records generated by agents, robots, * Maestro processes, conversational agents, and other UiPath execution sources. * The `source` field on each {@link SpanGetResponse} identifies the originating platform. * * @example * ```typescript * import { UiPath } from '@uipath/uipath-typescript/core'; * import { Traces } from '@uipath/uipath-typescript/traces'; * * const sdk = new UiPath(config); * await sdk.initialize(); * * const traces = new Traces(sdk); * const spans = await traces.getById(''); * ``` */ interface TracesServiceModel { /** * Gets all spans for a specific trace ID. * * Returns up to `pageSize` spans (default 1000) in a single fetch. * Accepts both GUID format and OTEL 32-char hex format — the API normalizes both. * * @param traceId - Trace identifier * @param options - Optional filters {@link TracesGetByIdOptions} * @returns Promise resolving to an array of {@link SpanGetResponse}, each containing span identity, timing, status, source platform, attributes, verbosity, execution type, lineage context, and any file attachments. * @example * ```typescript * import { Traces } from '@uipath/uipath-typescript/traces'; * * const traces = new Traces(sdk); * const spans = await traces.getById(''); * console.log(spans.length, spans[0].spanType, spans[0].status); * ``` * @example * ```typescript * // Filter to a specific agent's spans * const agentSpans = await traces.getById('', { * agentId: '', * pageSize: 500, * }); * ``` */ getById(traceId: string, options?: TracesGetByIdOptions): Promise; /** * Gets specific spans by trace ID and span IDs. * * Accepts OTEL 16-char hex or GUID format for span IDs. * * @param traceId - Trace identifier * @param spanIds - List of span IDs to retrieve * @returns Promise resolving to an array of matching {@link SpanGetResponse}, each containing span identity, timing, status, source platform, attributes, verbosity, execution type, lineage context, and any file attachments. * @example * ```typescript * import { Traces } from '@uipath/uipath-typescript/traces'; * * const traces = new Traces(sdk); * * // First retrieve all spans to find the IDs you want * const allSpans = await traces.getById(''); * const spanIds = allSpans.slice(0, 3).map(s => s.id); * * const subset = await traces.getSpansByIds('', spanIds); * ``` */ getSpansByIds(traceId: string, spanIds: string[]): Promise; } declare class TracesService extends BaseService implements TracesServiceModel { private transformOtelSpan; getById(traceId: string, options?: TracesGetByIdOptions): Promise; getSpansByIds(traceId: string, spanIds: string[]): Promise; } /** * Filter fields shared by the trace-level agent endpoints */ interface AgentTraceFilterOptions { /** Inclusive lower bound for the query window. Omit to use the server default (1 year ago). */ startTime?: Date; /** Exclusive upper bound for the query window. Omit to use the server default (now). */ endTime?: Date; /** Folder keys to scope the query. Intersected with the user's accessible folders. */ folderKeys?: string[]; /** Filter to a single agent by ID. */ agentId?: string; /** Filter to a specific agent version. */ agentVersion?: string; /** Filter to a specific execution type. */ executionType?: SpanExecutionType; } /** * One point on the trace-level errors timeline — error count for a single * (error name, time bucket). */ interface AgentTraceGetErrorsTimelineResponse { /** Error name / category for this time-slice. */ name: string; /** Count of errors in this time bucket for this name. */ value: number; /** Bucket timestamp. */ date: string; } /** * Options for the trace-level errors timeline. */ interface AgentTraceGetErrorsTimelineOptions extends AgentTraceFilterOptions { } /** * One point on the trace-level latency timeline — a latency value for a single * (series, time bucket). */ interface AgentTraceGetLatencyTimelineResponse { /** Series/grouping name for this latency point. */ name: string; /** Latency value in decimal seconds for this series and time bucket. */ value: number; /** Bucket timestamp. */ date: string; } /** * Options for the trace-level latency timeline. */ interface AgentTraceGetLatencyTimelineOptions extends AgentTraceFilterOptions { } /** * Per-agent unit consumption totals over the requested window (trace-level) — * a flat per-(agent, version, folder) breakdown of Agent Units and Platform Units consumed. */ interface AgentTraceGetUnitConsumptionResponse { /** Agent ID these totals belong to. */ agentId: string; /** Folder key (GUID) the consumption was recorded in. */ folderKey: string; /** Agent version these totals belong to. */ agentVersion: string; /** Agent units consumed over the window. */ agentUnitsConsumed: number; /** Platform units consumed over the window. */ platformUnitsConsumed: number; } /** * Options for the trace-level per-agent unit consumption. */ interface AgentTraceGetUnitConsumptionOptions extends AgentTraceFilterOptions { } /** * A single span record from the trace store. */ interface AgentSpanGetResponse { /** Span ID. */ id: string; /** ID of the trace this span belongs to. */ traceId: string; /** Parent span ID. `null` for a root span. */ parentId: string | null; /** Span name. */ name: string; /** Span start time. */ startTime: string; /** Span end time. `null` while the span is in progress. */ endTime: string | null; /** Raw span attributes as a JSON string. */ attributes: string; /** Span status. */ status: string; /** Organization ID (GUID). */ organizationId: string; /** Tenant ID (GUID). */ tenantId: string | null; /** Span retention expiry time. */ expiredTime: string | null; /** Folder key (GUID) the span was recorded in. */ folderKey: string | null; /** Span source. */ source: string | null; /** Span type. */ spanType: string | null; /** Process key (GUID). */ processKey: string | null; /** Job key (GUID). */ jobKey: string | null; /** Reference ID (GUID). */ referenceId: string | null; /** Verbosity level. */ verbosityLevel: string | null; /** Record last-updated time. */ updatedAt: string; /** Whether the span payload is stored as a large payload. */ isLargePayload: boolean; /** Payload compression type. */ compressionType: string | null; /** Agent version that produced the span. */ agentVersion: string | null; /** Raw span context as a JSON string. */ context: string | null; } /** * Options for the spans-by-reference query. * * Composes the optional hierarchy/time filters with pagination options. */ type AgentTraceGetSpansByReferenceOptions = PaginationOptions & { /** Optional trace scope — narrows the scan to a single trace. */ traceId?: string; /** Restrict matches to hierarchy entries with this service type. */ serviceType?: string; /** Restrict matches to hierarchy entries with this version. */ version?: string; /** Inclusive lower bound on span start time. */ startTime?: Date; /** Exclusive upper bound on span end time. */ endTime?: Date; /** Execution type filter */ executionType?: SpanExecutionType; }; /** * Evaluation mode of a governance decision. */ declare enum AgentGovernanceMode { /** Policy evaluated and logged, but not enforced. */ Audit = "AUDIT", /** Policy evaluated and enforced. */ Enforce = "ENFORCE", /** Unrecognized or missing mode. */ Unknown = "Unknown" } /** * Verdict of a governance decision (`Deny` = violation). */ declare enum AgentGovernanceVerdict { /** Allowed — not a violation. */ Allow = "ALLOW", /** Denied — counts as a violation. */ Deny = "DENY", /** Unrecognized or missing verdict. */ Unknown = "Unknown" } /** * A single governance decision — one policy's allow/deny result for an agent run. */ interface AgentGovernanceDecisionGetResponse { /** Tenant ID (GUID). */ tenantId: string | null; /** Decision window start time — ISO 8601, UTC. */ startTime: string; /** Decision window end time — ISO 8601, UTC. */ endTime: string | null; /** Trace ID (GUID). */ traceId: string | null; /** Job key (GUID). */ jobKey: string | null; /** Folder key (GUID). */ folderKey: string | null; /** Runtime the evaluator ran in (context, not a filter). */ source: string | null; /** Policy ID. */ policyId: string | null; /** Policy display name. */ policyName: string | null; /** Governance pack name. */ packName: string | null; /** Governance hook (e.g. `BEFORE_MODEL`). */ hook: string | null; /** Evaluation mode, normalized to {@link AgentGovernanceMode} ({@link AgentGovernanceMode.Unknown} when missing/unrecognized). */ mode: AgentGovernanceMode; /** Enforcement action applied. `null` in audit mode (no action enforced). */ actionApplied: string | null; /** Verdict, normalized to {@link AgentGovernanceVerdict} (`Deny` = violation). */ evaluatorResult: AgentGovernanceVerdict; /** Human-readable reason. */ reason: string | null; /** Resolved agent ID (GUID). */ agentId: string | null; /** Agent display name. */ agentName: string | null; } /** * Options for the governance decisions query — optional filters plus pagination. */ type AgentGovernanceDecisionsOptions = PaginationOptions & { /** Inclusive upper bound for the query window. Defaults to now when omitted. */ endTime?: Date; /** Filter on the governance hook. */ hook?: string; /** Filter on the verdict. */ evaluatorResult?: AgentGovernanceVerdict; /** Filter on a single policy ID. */ policyId?: string; /** Filter on a single agent by its project key. */ agentId?: string; /** When `true`, restrict to violations (deny verdicts). */ violationsOnly?: boolean; }; /** * One breakdown entry in the governance summary — counts for a single key. */ interface AgentGovernanceCountItem { /** The value this row groups by — the distinct hook, agent id, policy id, or pack name for this breakdown. */ key: string | null; /** Display name (populated for the policy and agent breakdowns). */ name: string | null; /** Number of decisions for this key. */ count: number; /** Number of violations (deny verdicts) for this key. */ violationCount: number; } /** * Sections the governance summary can compute. `action` and `mode` are opt-in. */ declare enum AgentGovernanceSection { /** Scalar totals (`total`, `violations`). */ Totals = "totals", /** Breakdown by governance hook. */ Hook = "hook", /** Breakdown by agent. */ Agent = "agent", /** Breakdown by policy. */ Policy = "policy", /** Breakdown by governance pack. */ Pack = "pack", /** Breakdown by enforcement action (opt-in). */ Action = "action", /** Breakdown by evaluation mode (opt-in). */ Mode = "mode" } /** * Aggregated governance posture over the requested window. */ interface AgentGovernanceGetSummaryResponse { /** Total decisions in the window. */ total: number; /** Total violations (deny verdicts). */ violations: number; /** Breakdown by governance hook. */ byHook: AgentGovernanceCountItem[]; /** Breakdown by agent. */ byAgent: AgentGovernanceCountItem[]; /** Breakdown by policy. */ byPolicy: AgentGovernanceCountItem[]; /** Breakdown by governance pack. */ byPack: AgentGovernanceCountItem[]; /** Breakdown by enforcement action. Empty unless `action` is requested in `sections`. */ byAction: AgentGovernanceCountItem[]; /** Breakdown by evaluation mode. Empty unless `mode` is requested in `sections`. */ byMode: AgentGovernanceCountItem[]; } /** * Options for the governance summary. */ interface AgentGovernanceSummaryOptions { /** Inclusive upper bound for the query window. Defaults to now when omitted. */ endTime?: Date; /** Top-N size for each breakdown. */ topN?: number; /** Restrict totals and breakdowns to a single governance pack. */ packName?: string; /** * Which sections to compute. Omit for the default set * (`totals`, `hook`, `agent`, `policy`, `pack`); `action` and `mode` are opt-in. */ sections?: AgentGovernanceSection[]; } /** * Service for retrieving UiPath Agent trace metrics. */ interface AgentTracesServiceModel { /** * Retrieves a trace-level time-series of error counts grouped by error name. * * @param options - Optional window and filters * @returns Promise resolving to an array of {@link AgentTraceGetErrorsTimelineResponse} * @example * ```typescript * import { AgentTraces } from '@uipath/uipath-typescript/traces'; * * const trace = new AgentTraces(sdk); * * // Get the errors timeline * const result = await trace.getErrorsTimeline(); * result.forEach((point) => { * console.log(`${point.date} ${point.name}: ${point.value} errors`); * }); * ``` * @example * ```typescript * import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces'; * * // Get the errors timeline for an agent version within a time window * const filtered = await trace.getErrorsTimeline({ * startTime: new Date('2025-05-01T00:00:00Z'), * endTime: new Date('2025-06-01T00:00:00Z'), * agentId: '', * agentVersion: '1.0.0', * executionType: AgentTraceExecutionType.Runtime, * }); * ``` */ getErrorsTimeline(options?: AgentTraceGetErrorsTimelineOptions): Promise; /** * Retrieves a trace-level time-series of latency. * * @param options - Optional window and filters * @returns Promise resolving to an array of {@link AgentTraceGetLatencyTimelineResponse} * @example * ```typescript * import { AgentTraces } from '@uipath/uipath-typescript/traces'; * * const trace = new AgentTraces(sdk); * * // Get the latency timeline * const result = await trace.getLatencyTimeline(); * result.forEach((point) => { * console.log(`${point.date} ${point.name}: ${point.value}s`); * }); * ``` * @example * ```typescript * import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces'; * * // Get the latency timeline for an agent version within a time window * const filtered = await trace.getLatencyTimeline({ * startTime: new Date('2025-05-01T00:00:00Z'), * endTime: new Date('2025-06-01T00:00:00Z'), * agentId: '', * agentVersion: '1.0.0', * executionType: AgentTraceExecutionType.Runtime, * }); * ``` */ getLatencyTimeline(options?: AgentTraceGetLatencyTimelineOptions): Promise; /** * Retrieves trace-level per-agent unit consumption totals. * * @param options - Optional window and filters * @returns Promise resolving to an array of {@link AgentTraceGetUnitConsumptionResponse} * @example * ```typescript * import { AgentTraces } from '@uipath/uipath-typescript/traces'; * * const trace = new AgentTraces(sdk); * * // Get per-agent unit consumption * const result = await trace.getUnitConsumption(); * result.forEach((row) => { * console.log(`${row.agentId}: ${row.agentUnitsConsumed} Agent Units, ${row.platformUnitsConsumed} Platform Units`); * }); * ``` * @example * ```typescript * import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces'; * * // Get per-agent unit consumption for an agent version within a time window * const filtered = await trace.getUnitConsumption({ * startTime: new Date('2025-05-01T00:00:00Z'), * endTime: new Date('2025-06-01T00:00:00Z'), * agentId: '', * agentVersion: '1.0.0', * executionType: AgentTraceExecutionType.Runtime, * }); * ``` */ getUnitConsumption(options?: AgentTraceGetUnitConsumptionOptions): Promise; /** * Retrieves every span belonging to a single trace. * * @param traceId - Identifier of the trace whose spans should be returned * @returns Promise resolving to an array of {@link AgentSpanGetResponse} * @example * ```typescript * import { AgentTraces } from '@uipath/uipath-typescript/traces'; * * const trace = new AgentTraces(sdk); * * const spans = await trace.getSpansByTraceId(''); * spans.forEach((span) => { * console.log(`${span.name} (${span.startTime} → ${span.endTime ?? 'in progress'})`); * }); * ``` */ getSpansByTraceId(traceId: string): Promise; /** * Retrieves spans whose reference hierarchy contains the given reference id. * * @param referenceId - Reference id matched against each span's reference hierarchy * @param options - Optional pagination and hierarchy/time filters * @returns Promise resolving to a paginated or non-paginated list of {@link AgentSpanGetResponse} * @example * ```typescript * import { AgentTraces } from '@uipath/uipath-typescript/traces'; * * const trace = new AgentTraces(sdk); * * // Get spans by referenceId * const result = await trace.getSpansByReference(''); * result.items.forEach((span) => console.log(span.name)); * ``` * @example * ```typescript * import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces'; * * // Get spans by referenceId within a trace and time window * const page = await trace.getSpansByReference('', { * traceId: '', * executionType: AgentTraceExecutionType.Runtime, * startTime: new Date('2025-05-01T00:00:00Z'), * endTime: new Date('2025-06-01T00:00:00Z'), * pageSize: 25, * }); * * if (page.hasNextPage && page.nextCursor) { * const next = await trace.getSpansByReference('', { cursor: page.nextCursor }); * } * ``` */ getSpansByReference(referenceId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Lists individual governance decisions from agent execution traces — each * policy check's allow/deny outcome with its agent, policy, pack, hook, and * mode, plus the trace it belongs to — over the requested window. Filterable * and paginated. * * @remarks Requires the caller to be an organization admin. Non-admin callers get a `403` and the SDK throws an {@link AuthorizationError}. * * @param startTime - Inclusive lower bound for the query window * @param options - Optional window end, filters, and pagination * @returns Promise resolving to a paginated or non-paginated list of {@link AgentGovernanceDecisionGetResponse} * @example * ```typescript * import { AgentTraces } from '@uipath/uipath-typescript/traces'; * * const trace = new AgentTraces(sdk); * * // Decision rows since a start time * const result = await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z')); * result.items.forEach((row) => { * console.log(`${row.hook} ${row.policyId}: ${row.evaluatorResult}`); * }); * ``` * @example * ```typescript * // Violations only, for one agent, paginated * const page = await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z'), { * endTime: new Date('2025-06-01T00:00:00Z'), * violationsOnly: true, * agentId: '', * pageSize: 25, * }); * if (page.hasNextPage && page.nextCursor) { * const next = await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z'), { cursor: page.nextCursor }); * } * ``` * @example * ```typescript * import { isAuthorizationError } from '@uipath/uipath-typescript/core'; * * // Non-admin callers get a 403 * try { * await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z')); * } catch (error) { * if (isAuthorizationError(error)) { * console.error('Governance data requires an organization admin.'); * } * } * ``` */ getGovernanceDecisions(startTime: Date, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Summarizes governance decisions across agent execution traces — total * decisions and violations, plus top breakdowns by hook, agent, policy, and * pack — over the requested window. Filterable. * * @remarks Requires the caller to be an organization admin. Non-admin callers get a `403` and the SDK throws an {@link AuthorizationError}. * * @param startTime - Inclusive lower bound for the query window * @param options - Optional window end, top-N, pack scope, and sections * @returns Promise resolving to {@link AgentGovernanceGetSummaryResponse} * @example * ```typescript * import { AgentTraces } from '@uipath/uipath-typescript/traces'; * * const trace = new AgentTraces(sdk); * * // Default posture since a start time * const summary = await trace.getGovernanceSummary(new Date('2025-05-01T00:00:00Z')); * console.log(`${summary.violations} / ${summary.total} violations`); * summary.byPolicy.forEach((p) => console.log(`${p.key}: ${p.violationCount}`)); * ``` * @example * ```typescript * import { AgentGovernanceSection } from '@uipath/uipath-typescript/traces'; * * // Top 5 per breakdown, scoped to a pack, including the opt-in action/mode sections * const summary = await trace.getGovernanceSummary(new Date('2025-05-01T00:00:00Z'), { * topN: 5, * packName: 'ISO/IEC 42001:2023 Runtime', * sections: [AgentGovernanceSection.Action, AgentGovernanceSection.Mode], * }); * ``` * @example * ```typescript * import { isAuthorizationError } from '@uipath/uipath-typescript/core'; * * // Non-admin callers get a 403 * try { * await trace.getGovernanceSummary(new Date('2025-05-01T00:00:00Z')); * } catch (error) { * if (isAuthorizationError(error)) { * console.error('Governance data requires an organization admin.'); * } * } * ``` */ getGovernanceSummary(startTime: Date, options?: AgentGovernanceSummaryOptions): Promise; } /** * Service for retrieving UiPath Agent trace metrics. */ declare class AgentTracesService extends BaseService implements AgentTracesServiceModel { getErrorsTimeline(options?: AgentTraceGetErrorsTimelineOptions): Promise; getLatencyTimeline(options?: AgentTraceGetLatencyTimelineOptions): Promise; getUnitConsumption(options?: AgentTraceGetUnitConsumptionOptions): Promise; getSpansByTraceId(traceId: string): Promise; getSpansByReference(referenceId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; getGovernanceDecisions(startTime: Date, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; getGovernanceSummary(startTime: Date, options?: AgentGovernanceSummaryOptions): Promise; private buildTraceFilterBody; } export { AgentGovernanceMode, AgentGovernanceSection, AgentGovernanceVerdict, SpanExecutionType as AgentTraceExecutionType, AgentTracesService as AgentTraces, SpanAttachmentDirection, SpanAttachmentProvider, SpanExecutionType, SpanPermissionStatus, SpanSource, SpanStatus, SpanVerbosityLevel, TracesService as Traces }; export type { AgentGovernanceCountItem, AgentGovernanceDecisionGetResponse, AgentGovernanceDecisionsOptions, AgentGovernanceGetSummaryResponse, AgentGovernanceSummaryOptions, AgentSpanGetResponse, AgentTraceFilterOptions, AgentTraceGetErrorsTimelineOptions, AgentTraceGetErrorsTimelineResponse, AgentTraceGetLatencyTimelineOptions, AgentTraceGetLatencyTimelineResponse, AgentTraceGetSpansByReferenceOptions, AgentTraceGetUnitConsumptionOptions, AgentTraceGetUnitConsumptionResponse, AgentTracesServiceModel, SpanAttachment, SpanContext, SpanGetResponse, SpanReferenceHierarchyEntry, TracesGetByIdOptions, TracesServiceModel };