@uipath/uipath-typescript 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3893,6 +3893,303 @@ function hasSecretConfig(config) {
3893
3893
  return Boolean(config.secret);
3894
3894
  }
3895
3895
 
3896
+ /**
3897
+ * Base error class for all UiPath SDK errors
3898
+ * Extends Error for standard error handling compatibility
3899
+ */
3900
+ class UiPathError extends Error {
3901
+ constructor(type, params) {
3902
+ super(params.message);
3903
+ this.name = type;
3904
+ this.type = type;
3905
+ this.statusCode = params.statusCode;
3906
+ this.requestId = params.requestId;
3907
+ this.timestamp = new Date();
3908
+ // Maintains proper stack trace for where our error was thrown
3909
+ if (Error.captureStackTrace) {
3910
+ Error.captureStackTrace(this, this.constructor);
3911
+ }
3912
+ }
3913
+ /**
3914
+ * Returns a clean JSON representation of the error
3915
+ */
3916
+ toJSON() {
3917
+ return {
3918
+ type: this.type,
3919
+ message: this.message,
3920
+ statusCode: this.statusCode,
3921
+ requestId: this.requestId,
3922
+ timestamp: this.timestamp
3923
+ };
3924
+ }
3925
+ /**
3926
+ * Returns detailed debug information including stack trace
3927
+ */
3928
+ getDebugInfo() {
3929
+ return {
3930
+ ...this.toJSON(),
3931
+ stack: this.stack
3932
+ };
3933
+ }
3934
+ }
3935
+
3936
+ /**
3937
+ * HTTP status code constants for error handling
3938
+ */
3939
+ const HttpStatus = {
3940
+ // Client errors (4xx)
3941
+ BAD_REQUEST: 400,
3942
+ UNAUTHORIZED: 401,
3943
+ FORBIDDEN: 403,
3944
+ NOT_FOUND: 404,
3945
+ TOO_MANY_REQUESTS: 429,
3946
+ // Server errors (5xx)
3947
+ INTERNAL_SERVER_ERROR: 500,
3948
+ NOT_IMPLEMENTED: 501,
3949
+ BAD_GATEWAY: 502,
3950
+ SERVICE_UNAVAILABLE: 503,
3951
+ GATEWAY_TIMEOUT: 504
3952
+ };
3953
+ /**
3954
+ * Error type constants for consistent error identification
3955
+ */
3956
+ const ErrorType = {
3957
+ AUTHENTICATION: 'AuthenticationError',
3958
+ AUTHORIZATION: 'AuthorizationError',
3959
+ VALIDATION: 'ValidationError',
3960
+ NOT_FOUND: 'NotFoundError',
3961
+ RATE_LIMIT: 'RateLimitError',
3962
+ SERVER: 'ServerError',
3963
+ NETWORK: 'NetworkError'
3964
+ };
3965
+ /**
3966
+ * HTTP header constants for error handling
3967
+ */
3968
+ const HttpHeaders = {
3969
+ X_REQUEST_ID: 'x-request-id'
3970
+ };
3971
+ /**
3972
+ * Standard error message constants
3973
+ */
3974
+ const ErrorMessages = {
3975
+ // Authentication errors
3976
+ AUTHENTICATION_FAILED: 'Authentication failed',
3977
+ // Authorization errors
3978
+ ACCESS_DENIED: 'Access denied',
3979
+ // Validation errors
3980
+ VALIDATION_FAILED: 'Validation failed',
3981
+ // Not found errors
3982
+ RESOURCE_NOT_FOUND: 'Resource not found',
3983
+ // Rate limit errors
3984
+ RATE_LIMIT_EXCEEDED: 'Rate limit exceeded',
3985
+ // Server errors
3986
+ INTERNAL_SERVER_ERROR: 'Internal Server error occurred',
3987
+ // Network errors
3988
+ NETWORK_ERROR: 'Network error occurred',
3989
+ REQUEST_TIMEOUT: 'Request timed out',
3990
+ REQUEST_ABORTED: 'Request was aborted',
3991
+ };
3992
+ /**
3993
+ * Error name constants for network error identification
3994
+ */
3995
+ const ErrorNames = {
3996
+ ABORT_ERROR: 'AbortError'};
3997
+
3998
+ /**
3999
+ * Error thrown when authentication fails (401 errors)
4000
+ * Common scenarios:
4001
+ * - Invalid credentials
4002
+ * - Expired token
4003
+ * - Missing authentication
4004
+ */
4005
+ class AuthenticationError extends UiPathError {
4006
+ constructor(params = {}) {
4007
+ super(ErrorType.AUTHENTICATION, {
4008
+ message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
4009
+ statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
4010
+ requestId: params.requestId
4011
+ });
4012
+ }
4013
+ }
4014
+
4015
+ /**
4016
+ * Error thrown when authorization fails (403 errors)
4017
+ * Common scenarios:
4018
+ * - Insufficient permissions
4019
+ * - Access denied to resource
4020
+ * - Invalid scope
4021
+ */
4022
+ class AuthorizationError extends UiPathError {
4023
+ constructor(params = {}) {
4024
+ super(ErrorType.AUTHORIZATION, {
4025
+ message: params.message || ErrorMessages.ACCESS_DENIED,
4026
+ statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
4027
+ requestId: params.requestId
4028
+ });
4029
+ }
4030
+ }
4031
+
4032
+ /**
4033
+ * Error thrown when validation fails (400 errors or client-side validation)
4034
+ * Common scenarios:
4035
+ * - Invalid input parameters
4036
+ * - Missing required fields
4037
+ * - Invalid data format
4038
+ */
4039
+ class ValidationError extends UiPathError {
4040
+ constructor(params = {}) {
4041
+ super(ErrorType.VALIDATION, {
4042
+ message: params.message || ErrorMessages.VALIDATION_FAILED,
4043
+ statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
4044
+ requestId: params.requestId
4045
+ });
4046
+ }
4047
+ }
4048
+
4049
+ /**
4050
+ * Error thrown when a resource is not found (404 errors)
4051
+ * Common scenarios:
4052
+ * - Resource doesn't exist
4053
+ * - Invalid ID provided
4054
+ * - Resource deleted
4055
+ */
4056
+ class NotFoundError extends UiPathError {
4057
+ constructor(params = {}) {
4058
+ super(ErrorType.NOT_FOUND, {
4059
+ message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
4060
+ statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
4061
+ requestId: params.requestId
4062
+ });
4063
+ }
4064
+ }
4065
+
4066
+ /**
4067
+ * Error thrown when rate limit is exceeded (429 errors)
4068
+ * Common scenarios:
4069
+ * - Too many requests in a time window
4070
+ * - API throttling
4071
+ */
4072
+ class RateLimitError extends UiPathError {
4073
+ constructor(params = {}) {
4074
+ super(ErrorType.RATE_LIMIT, {
4075
+ message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
4076
+ statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
4077
+ requestId: params.requestId
4078
+ });
4079
+ }
4080
+ }
4081
+
4082
+ /**
4083
+ * Error thrown when server encounters an error (5xx errors)
4084
+ * Common scenarios:
4085
+ * - Internal server error
4086
+ * - Service unavailable
4087
+ * - Gateway timeout
4088
+ */
4089
+ class ServerError extends UiPathError {
4090
+ constructor(params = {}) {
4091
+ super(ErrorType.SERVER, {
4092
+ message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
4093
+ statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
4094
+ requestId: params.requestId
4095
+ });
4096
+ }
4097
+ /**
4098
+ * Checks if this is a temporary error that might succeed on retry
4099
+ */
4100
+ get isRetryable() {
4101
+ return this.statusCode === HttpStatus.BAD_GATEWAY ||
4102
+ this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
4103
+ this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
4104
+ }
4105
+ }
4106
+
4107
+ /**
4108
+ * Error thrown when network/connection issues occur
4109
+ * Common scenarios:
4110
+ * - Connection timeout
4111
+ * - DNS resolution failure
4112
+ * - Network unreachable
4113
+ * - Request aborted
4114
+ */
4115
+ class NetworkError extends UiPathError {
4116
+ constructor(params = {}) {
4117
+ super(ErrorType.NETWORK, {
4118
+ message: params.message || ErrorMessages.NETWORK_ERROR,
4119
+ statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
4120
+ requestId: params.requestId
4121
+ });
4122
+ }
4123
+ }
4124
+
4125
+ /**
4126
+ * Type guard to check if an error is a UiPathError
4127
+ */
4128
+ function isUiPathError(error) {
4129
+ return error instanceof UiPathError;
4130
+ }
4131
+ /**
4132
+ * Type guard to check if an error is an AuthenticationError
4133
+ */
4134
+ function isAuthenticationError(error) {
4135
+ return error instanceof AuthenticationError;
4136
+ }
4137
+ /**
4138
+ * Type guard to check if an error is an AuthorizationError
4139
+ */
4140
+ function isAuthorizationError(error) {
4141
+ return error instanceof AuthorizationError;
4142
+ }
4143
+ /**
4144
+ * Type guard to check if an error is a ValidationError
4145
+ */
4146
+ function isValidationError(error) {
4147
+ return error instanceof ValidationError;
4148
+ }
4149
+ /**
4150
+ * Type guard to check if an error is a NotFoundError
4151
+ */
4152
+ function isNotFoundError(error) {
4153
+ return error instanceof NotFoundError;
4154
+ }
4155
+ /**
4156
+ * Type guard to check if an error is a RateLimitError
4157
+ */
4158
+ function isRateLimitError(error) {
4159
+ return error instanceof RateLimitError;
4160
+ }
4161
+ /**
4162
+ * Type guard to check if an error is a ServerError
4163
+ */
4164
+ function isServerError(error) {
4165
+ return error instanceof ServerError;
4166
+ }
4167
+ /**
4168
+ * Type guard to check if an error is a NetworkError
4169
+ */
4170
+ function isNetworkError(error) {
4171
+ return error instanceof NetworkError;
4172
+ }
4173
+ /**
4174
+ * Helper to get error details in a safe way
4175
+ */
4176
+ function getErrorDetails(error) {
4177
+ if (isUiPathError(error)) {
4178
+ return {
4179
+ message: error.message,
4180
+ statusCode: error.statusCode
4181
+ };
4182
+ }
4183
+ if (error instanceof Error) {
4184
+ return {
4185
+ message: error.message
4186
+ };
4187
+ }
4188
+ return {
4189
+ message: String(error)
4190
+ };
4191
+ }
4192
+
3896
4193
  /**
3897
4194
  * TokenManager is responsible for managing authentication tokens.
3898
4195
  * It provides token operations for a specific client ID.
@@ -3925,6 +4222,41 @@ class TokenManager {
3925
4222
  }
3926
4223
  return new Date() >= tokenInfo.expiresAt;
3927
4224
  }
4225
+ /**
4226
+ * Gets a valid authentication token, refreshing if necessary.
4227
+ * This is the single source of truth for token validation and refresh logic.
4228
+ *
4229
+ * @returns The valid token string
4230
+ * @throws AuthenticationError if no token available or refresh fails
4231
+ */
4232
+ async getValidToken() {
4233
+ const tokenInfo = this.executionContext.get('tokenInfo');
4234
+ if (!tokenInfo) {
4235
+ throw new AuthenticationError({
4236
+ message: 'No authentication token available. Make sure to initialize the SDK first.'
4237
+ });
4238
+ }
4239
+ // For secret-based tokens, they never expire
4240
+ if (tokenInfo.type === 'secret') {
4241
+ return tokenInfo.token;
4242
+ }
4243
+ // If token is not expired, return it
4244
+ if (!this.isTokenExpired(tokenInfo)) {
4245
+ return tokenInfo.token;
4246
+ }
4247
+ // Token is expired, refresh it
4248
+ try {
4249
+ const newToken = await this.refreshAccessToken();
4250
+ return newToken.access_token;
4251
+ }
4252
+ catch (error) {
4253
+ const message = error instanceof Error ? error.message : 'Unknown error';
4254
+ throw new AuthenticationError({
4255
+ message: `Token refresh failed: ${message}. Please re-authenticate.`,
4256
+ statusCode: HttpStatus.UNAUTHORIZED
4257
+ });
4258
+ }
4259
+ }
3928
4260
  /**
3929
4261
  * Gets the storage key for this TokenManager instance
3930
4262
  */
@@ -4139,10 +4471,6 @@ class TokenManager {
4139
4471
  }
4140
4472
  }
4141
4473
 
4142
- /**
4143
- * API Endpoint Constants
4144
- * Centralized location for all API endpoints used throughout the SDK
4145
- */
4146
4474
  /**
4147
4475
  * Base path constants for different services
4148
4476
  */
@@ -4150,6 +4478,66 @@ const ORCHESTRATOR_BASE = 'orchestrator_';
4150
4478
  const PIMS_BASE = 'pims_';
4151
4479
  const DATAFABRIC_BASE = 'datafabric_';
4152
4480
  const IDENTITY_BASE = 'identity_';
4481
+
4482
+ /**
4483
+ * Orchestrator Service Endpoints
4484
+ */
4485
+ /**
4486
+ * Task Service (Action Center) Endpoints
4487
+ */
4488
+ const TASK_ENDPOINTS = {
4489
+ CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
4490
+ GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
4491
+ GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
4492
+ GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
4493
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
4494
+ ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
4495
+ REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
4496
+ UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
4497
+ COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
4498
+ COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
4499
+ COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
4500
+ GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
4501
+ };
4502
+ /**
4503
+ * Orchestrator Bucket Endpoints
4504
+ */
4505
+ const BUCKET_ENDPOINTS = {
4506
+ GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
4507
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
4508
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
4509
+ GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
4510
+ GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
4511
+ GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
4512
+ };
4513
+ /**
4514
+ * Orchestrator Process Service Endpoints
4515
+ */
4516
+ const PROCESS_ENDPOINTS = {
4517
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
4518
+ START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
4519
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`,
4520
+ };
4521
+ /**
4522
+ * Orchestrator Queue Service Endpoints
4523
+ */
4524
+ const QUEUE_ENDPOINTS = {
4525
+ GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
4526
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
4527
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
4528
+ };
4529
+ /**
4530
+ * Orchestrator Asset Service Endpoints
4531
+ */
4532
+ const ASSET_ENDPOINTS = {
4533
+ GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetFiltered`,
4534
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetAssetsAcrossFolders`,
4535
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`,
4536
+ };
4537
+
4538
+ /**
4539
+ * Maestro Service Endpoints
4540
+ */
4153
4541
  /**
4154
4542
  * Maestro Process Service Endpoints
4155
4543
  */
@@ -4179,25 +4567,12 @@ const MAESTRO_ENDPOINTS = {
4179
4567
  REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
4180
4568
  },
4181
4569
  };
4570
+
4182
4571
  /**
4183
- * Task Service (Action Center) Endpoints
4572
+ * Data Fabric Service Endpoints
4184
4573
  */
4185
- const TASK_ENDPOINTS = {
4186
- CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
4187
- GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
4188
- GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
4189
- GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
4190
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
4191
- ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
4192
- REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
4193
- UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
4194
- COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
4195
- COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
4196
- COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
4197
- GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
4198
- };
4199
4574
  /**
4200
- * Data Fabric Service Endpoints
4575
+ * Data Fabric Entity Service Endpoints
4201
4576
  */
4202
4577
  const DATA_FABRIC_ENDPOINTS = {
4203
4578
  ENTITY: {
@@ -4216,48 +4591,17 @@ const DATA_FABRIC_ENDPOINTS = {
4216
4591
  GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
4217
4592
  },
4218
4593
  };
4219
- /**
4220
- * Orchestrator Bucket Endpoints
4221
- */
4222
- const BUCKET_ENDPOINTS = {
4223
- GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
4224
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
4225
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
4226
- GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
4227
- GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
4228
- GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
4229
- };
4594
+
4230
4595
  /**
4231
4596
  * Identity/Authentication Endpoints
4232
4597
  */
4598
+ /**
4599
+ * Identity Service Endpoints
4600
+ */
4233
4601
  const IDENTITY_ENDPOINTS = {
4234
4602
  TOKEN: `${IDENTITY_BASE}/connect/token`,
4235
4603
  AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
4236
4604
  };
4237
- /**
4238
- * Orchestrator Process Service Endpoints
4239
- */
4240
- const PROCESS_ENDPOINTS = {
4241
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
4242
- START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
4243
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`,
4244
- };
4245
- /**
4246
- * Orchestrator Queue Service Endpoints
4247
- */
4248
- const QUEUE_ENDPOINTS = {
4249
- GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
4250
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
4251
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
4252
- };
4253
- /**
4254
- * Orchestrator Asset Service Endpoints
4255
- */
4256
- const ASSET_ENDPOINTS = {
4257
- GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetFiltered`,
4258
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetAssetsAcrossFolders`,
4259
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`,
4260
- };
4261
4605
 
4262
4606
  class AuthService {
4263
4607
  constructor(config, executionContext) {
@@ -4617,7 +4961,7 @@ function normalizeBaseUrl(url) {
4617
4961
  // Connection string placeholder that will be replaced during build
4618
4962
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
4619
4963
  // SDK Version placeholder
4620
- const SDK_VERSION = "1.0.0";
4964
+ const SDK_VERSION = "1.1.0";
4621
4965
  const VERSION = "Version";
4622
4966
  const SERVICE = "Service";
4623
4967
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -4794,7 +5138,6 @@ class TelemetryClient {
4794
5138
  */
4795
5139
  getEnrichedAttributes(extraAttributes, eventName) {
4796
5140
  const attributes = {
4797
- ...extraAttributes,
4798
5141
  [APP_NAME]: SDK_SERVICE_NAME,
4799
5142
  [VERSION]: SDK_VERSION,
4800
5143
  [SERVICE]: eventName,
@@ -4803,6 +5146,7 @@ class TelemetryClient {
4803
5146
  [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN$1,
4804
5147
  [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN$1,
4805
5148
  [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN$1,
5149
+ ...extraAttributes,
4806
5150
  };
4807
5151
  return attributes;
4808
5152
  }
@@ -5071,333 +5415,39 @@ let UiPath$1 = class UiPath {
5071
5415
  return AuthService.isInOAuthCallback();
5072
5416
  }
5073
5417
  /**
5074
- * Complete OAuth authentication flow (only call if isInOAuthCallback() is true)
5075
- */
5076
- async completeOAuth() {
5077
- if (!AuthService.isInOAuthCallback()) {
5078
- throw new Error('Not in OAuth callback state. Call initialize() first to start OAuth flow.');
5079
- }
5080
- try {
5081
- const success = await __classPrivateFieldGet(this, _UiPath_authService, "f").authenticate(__classPrivateFieldGet(this, _UiPath_config, "f"));
5082
- if (success && this.isAuthenticated()) {
5083
- __classPrivateFieldSet(this, _UiPath_initialized, true, "f");
5084
- return true;
5085
- }
5086
- return false;
5087
- }
5088
- catch (error) {
5089
- const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
5090
- throw new Error(`Failed to complete OAuth: ${errorMessage}`);
5091
- }
5092
- }
5093
- /**
5094
- * Check if the user is authenticated (has valid token)
5095
- */
5096
- isAuthenticated() {
5097
- return __classPrivateFieldGet(this, _UiPath_authService, "f").hasValidToken();
5098
- }
5099
- /**
5100
- * Get the current authentication token
5101
- */
5102
- getToken() {
5103
- return __classPrivateFieldGet(this, _UiPath_authService, "f").getToken();
5104
- }
5105
- };
5106
- _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap();
5107
-
5108
- /**
5109
- * Base error class for all UiPath SDK errors
5110
- * Pure TypeScript class with clean interface
5111
- */
5112
- class UiPathError {
5113
- constructor(type, params) {
5114
- this.type = type;
5115
- this.message = params.message;
5116
- this.statusCode = params.statusCode;
5117
- this.requestId = params.requestId;
5118
- this.timestamp = new Date();
5119
- // Capture stack trace for debugging
5120
- this.stack = (new Error()).stack;
5121
- }
5122
- /**
5123
- * Returns a clean JSON representation of the error
5124
- */
5125
- toJSON() {
5126
- return {
5127
- type: this.type,
5128
- message: this.message,
5129
- statusCode: this.statusCode,
5130
- requestId: this.requestId,
5131
- timestamp: this.timestamp
5132
- };
5133
- }
5134
- /**
5135
- * Returns detailed debug information including stack trace
5136
- */
5137
- getDebugInfo() {
5138
- return {
5139
- ...this.toJSON(),
5140
- stack: this.stack
5141
- };
5142
- }
5143
- }
5144
-
5145
- /**
5146
- * HTTP status code constants for error handling
5147
- */
5148
- const HttpStatus = {
5149
- // Client errors (4xx)
5150
- BAD_REQUEST: 400,
5151
- UNAUTHORIZED: 401,
5152
- FORBIDDEN: 403,
5153
- NOT_FOUND: 404,
5154
- TOO_MANY_REQUESTS: 429,
5155
- // Server errors (5xx)
5156
- INTERNAL_SERVER_ERROR: 500,
5157
- NOT_IMPLEMENTED: 501,
5158
- BAD_GATEWAY: 502,
5159
- SERVICE_UNAVAILABLE: 503,
5160
- GATEWAY_TIMEOUT: 504
5161
- };
5162
- /**
5163
- * Error type constants for consistent error identification
5164
- */
5165
- const ErrorType = {
5166
- AUTHENTICATION: 'AuthenticationError',
5167
- AUTHORIZATION: 'AuthorizationError',
5168
- VALIDATION: 'ValidationError',
5169
- NOT_FOUND: 'NotFoundError',
5170
- RATE_LIMIT: 'RateLimitError',
5171
- SERVER: 'ServerError',
5172
- NETWORK: 'NetworkError'
5173
- };
5174
- /**
5175
- * HTTP header constants for error handling
5176
- */
5177
- const HttpHeaders = {
5178
- X_REQUEST_ID: 'x-request-id'
5179
- };
5180
- /**
5181
- * Standard error message constants
5182
- */
5183
- const ErrorMessages = {
5184
- // Authentication errors
5185
- AUTHENTICATION_FAILED: 'Authentication failed',
5186
- // Authorization errors
5187
- ACCESS_DENIED: 'Access denied',
5188
- // Validation errors
5189
- VALIDATION_FAILED: 'Validation failed',
5190
- // Not found errors
5191
- RESOURCE_NOT_FOUND: 'Resource not found',
5192
- // Rate limit errors
5193
- RATE_LIMIT_EXCEEDED: 'Rate limit exceeded',
5194
- // Server errors
5195
- INTERNAL_SERVER_ERROR: 'Internal Server error occurred',
5196
- // Network errors
5197
- NETWORK_ERROR: 'Network error occurred',
5198
- REQUEST_TIMEOUT: 'Request timed out',
5199
- REQUEST_ABORTED: 'Request was aborted',
5200
- };
5201
- /**
5202
- * Error name constants for network error identification
5203
- */
5204
- const ErrorNames = {
5205
- ABORT_ERROR: 'AbortError'};
5206
-
5207
- /**
5208
- * Error thrown when authentication fails (401 errors)
5209
- * Common scenarios:
5210
- * - Invalid credentials
5211
- * - Expired token
5212
- * - Missing authentication
5213
- */
5214
- class AuthenticationError extends UiPathError {
5215
- constructor(params = {}) {
5216
- super(ErrorType.AUTHENTICATION, {
5217
- message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
5218
- statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
5219
- requestId: params.requestId
5220
- });
5221
- }
5222
- }
5223
-
5224
- /**
5225
- * Error thrown when authorization fails (403 errors)
5226
- * Common scenarios:
5227
- * - Insufficient permissions
5228
- * - Access denied to resource
5229
- * - Invalid scope
5230
- */
5231
- class AuthorizationError extends UiPathError {
5232
- constructor(params = {}) {
5233
- super(ErrorType.AUTHORIZATION, {
5234
- message: params.message || ErrorMessages.ACCESS_DENIED,
5235
- statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
5236
- requestId: params.requestId
5237
- });
5238
- }
5239
- }
5240
-
5241
- /**
5242
- * Error thrown when validation fails (400 errors or client-side validation)
5243
- * Common scenarios:
5244
- * - Invalid input parameters
5245
- * - Missing required fields
5246
- * - Invalid data format
5247
- */
5248
- class ValidationError extends UiPathError {
5249
- constructor(params = {}) {
5250
- super(ErrorType.VALIDATION, {
5251
- message: params.message || ErrorMessages.VALIDATION_FAILED,
5252
- statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
5253
- requestId: params.requestId
5254
- });
5255
- }
5256
- }
5257
-
5258
- /**
5259
- * Error thrown when a resource is not found (404 errors)
5260
- * Common scenarios:
5261
- * - Resource doesn't exist
5262
- * - Invalid ID provided
5263
- * - Resource deleted
5264
- */
5265
- class NotFoundError extends UiPathError {
5266
- constructor(params = {}) {
5267
- super(ErrorType.NOT_FOUND, {
5268
- message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
5269
- statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
5270
- requestId: params.requestId
5271
- });
5272
- }
5273
- }
5274
-
5275
- /**
5276
- * Error thrown when rate limit is exceeded (429 errors)
5277
- * Common scenarios:
5278
- * - Too many requests in a time window
5279
- * - API throttling
5280
- */
5281
- class RateLimitError extends UiPathError {
5282
- constructor(params = {}) {
5283
- super(ErrorType.RATE_LIMIT, {
5284
- message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
5285
- statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
5286
- requestId: params.requestId
5287
- });
5288
- }
5289
- }
5290
-
5291
- /**
5292
- * Error thrown when server encounters an error (5xx errors)
5293
- * Common scenarios:
5294
- * - Internal server error
5295
- * - Service unavailable
5296
- * - Gateway timeout
5297
- */
5298
- class ServerError extends UiPathError {
5299
- constructor(params = {}) {
5300
- super(ErrorType.SERVER, {
5301
- message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
5302
- statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
5303
- requestId: params.requestId
5304
- });
5305
- }
5306
- /**
5307
- * Checks if this is a temporary error that might succeed on retry
5418
+ * Complete OAuth authentication flow (only call if isInOAuthCallback() is true)
5308
5419
  */
5309
- get isRetryable() {
5310
- return this.statusCode === HttpStatus.BAD_GATEWAY ||
5311
- this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
5312
- this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
5313
- }
5314
- }
5315
-
5316
- /**
5317
- * Error thrown when network/connection issues occur
5318
- * Common scenarios:
5319
- * - Connection timeout
5320
- * - DNS resolution failure
5321
- * - Network unreachable
5322
- * - Request aborted
5323
- */
5324
- class NetworkError extends UiPathError {
5325
- constructor(params = {}) {
5326
- super(ErrorType.NETWORK, {
5327
- message: params.message || ErrorMessages.NETWORK_ERROR,
5328
- statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
5329
- requestId: params.requestId
5330
- });
5420
+ async completeOAuth() {
5421
+ if (!AuthService.isInOAuthCallback()) {
5422
+ throw new Error('Not in OAuth callback state. Call initialize() first to start OAuth flow.');
5423
+ }
5424
+ try {
5425
+ const success = await __classPrivateFieldGet(this, _UiPath_authService, "f").authenticate(__classPrivateFieldGet(this, _UiPath_config, "f"));
5426
+ if (success && this.isAuthenticated()) {
5427
+ __classPrivateFieldSet(this, _UiPath_initialized, true, "f");
5428
+ return true;
5429
+ }
5430
+ return false;
5431
+ }
5432
+ catch (error) {
5433
+ const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
5434
+ throw new Error(`Failed to complete OAuth: ${errorMessage}`);
5435
+ }
5331
5436
  }
5332
- }
5333
-
5334
- /**
5335
- * Type guard to check if an error is a UiPathError
5336
- */
5337
- function isUiPathError(error) {
5338
- return error instanceof UiPathError;
5339
- }
5340
- /**
5341
- * Type guard to check if an error is an AuthenticationError
5342
- */
5343
- function isAuthenticationError(error) {
5344
- return error instanceof AuthenticationError;
5345
- }
5346
- /**
5347
- * Type guard to check if an error is an AuthorizationError
5348
- */
5349
- function isAuthorizationError(error) {
5350
- return error instanceof AuthorizationError;
5351
- }
5352
- /**
5353
- * Type guard to check if an error is a ValidationError
5354
- */
5355
- function isValidationError(error) {
5356
- return error instanceof ValidationError;
5357
- }
5358
- /**
5359
- * Type guard to check if an error is a NotFoundError
5360
- */
5361
- function isNotFoundError(error) {
5362
- return error instanceof NotFoundError;
5363
- }
5364
- /**
5365
- * Type guard to check if an error is a RateLimitError
5366
- */
5367
- function isRateLimitError(error) {
5368
- return error instanceof RateLimitError;
5369
- }
5370
- /**
5371
- * Type guard to check if an error is a ServerError
5372
- */
5373
- function isServerError(error) {
5374
- return error instanceof ServerError;
5375
- }
5376
- /**
5377
- * Type guard to check if an error is a NetworkError
5378
- */
5379
- function isNetworkError(error) {
5380
- return error instanceof NetworkError;
5381
- }
5382
- /**
5383
- * Helper to get error details in a safe way
5384
- */
5385
- function getErrorDetails(error) {
5386
- if (isUiPathError(error)) {
5387
- return {
5388
- message: error.message,
5389
- statusCode: error.statusCode
5390
- };
5437
+ /**
5438
+ * Check if the user is authenticated (has valid token)
5439
+ */
5440
+ isAuthenticated() {
5441
+ return __classPrivateFieldGet(this, _UiPath_authService, "f").hasValidToken();
5391
5442
  }
5392
- if (error instanceof Error) {
5393
- return {
5394
- message: error.message
5395
- };
5443
+ /**
5444
+ * Get the current authentication token
5445
+ */
5446
+ getToken() {
5447
+ return __classPrivateFieldGet(this, _UiPath_authService, "f").getToken();
5396
5448
  }
5397
- return {
5398
- message: String(error)
5399
- };
5400
- }
5449
+ };
5450
+ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap();
5401
5451
 
5402
5452
  /**
5403
5453
  * Type guards for error response types
@@ -5671,29 +5721,7 @@ class ApiClient {
5671
5721
  * @throws AuthenticationError if no token available or refresh fails
5672
5722
  */
5673
5723
  async getValidToken() {
5674
- // Try to get token info from context
5675
- const tokenInfo = this.executionContext.get('tokenInfo');
5676
- if (!tokenInfo) {
5677
- throw new AuthenticationError({ message: 'No authentication token available. Make sure to initialize the SDK first.' });
5678
- }
5679
- // For secret-based tokens, they never expire
5680
- if (tokenInfo.type === 'secret') {
5681
- return tokenInfo.token;
5682
- }
5683
- // If token is not expired, return it
5684
- if (!this.tokenManager.isTokenExpired(tokenInfo)) {
5685
- return tokenInfo.token;
5686
- }
5687
- try {
5688
- const newToken = await this.tokenManager.refreshAccessToken();
5689
- return newToken.access_token;
5690
- }
5691
- catch (error) {
5692
- throw new AuthenticationError({
5693
- message: `Token refresh failed: ${error.message}. Please re-authenticate.`,
5694
- statusCode: HttpStatus.UNAUTHORIZED
5695
- });
5696
- }
5724
+ return this.tokenManager.getValidToken();
5697
5725
  }
5698
5726
  async getDefaultHeaders() {
5699
5727
  // Get headers from execution context first
@@ -6378,6 +6406,51 @@ function reverseMap(map) {
6378
6406
  return acc;
6379
6407
  }, {});
6380
6408
  }
6409
+ /**
6410
+ * Transforms request data from SDK field names to API field names.
6411
+ *
6412
+ * This is the inverse of `transformData` - while `transformData` converts
6413
+ * API responses to SDK format (API → SDK), this function converts SDK
6414
+ * requests to API format (SDK → API).
6415
+ *
6416
+ * @param data The request data with SDK field names
6417
+ * @param responseMap The response mapping (API → SDK) - will be automatically reversed
6418
+ * @returns A new object with API field names
6419
+ *
6420
+ * @example
6421
+ * ```typescript
6422
+ * // Response map: API field → SDK field
6423
+ * const ProcessMap = { releaseKey: 'processKey', releaseName: 'processName' };
6424
+ *
6425
+ * // SDK request with SDK field names
6426
+ * const sdkRequest = { processKey: 'abc-123', processName: 'MyProcess' };
6427
+ *
6428
+ * // Transform to API format
6429
+ * const apiRequest = transformRequest(sdkRequest, ProcessMap);
6430
+ * // Result: { releaseKey: 'abc-123', releaseName: 'MyProcess' }
6431
+ * ```
6432
+ *
6433
+ * @example
6434
+ * ```typescript
6435
+ * // Conversation example
6436
+ * const ConversationMap = { agentReleaseId: 'agentId' };
6437
+ *
6438
+ * const sdkOptions = { agentId: 123, folderId: 456, label: 'My Chat' };
6439
+ * const apiPayload = transformRequest(sdkOptions, ConversationMap);
6440
+ * // Result: { agentReleaseId: 123, folderId: 456, label: 'My Chat' }
6441
+ * ```
6442
+ */
6443
+ function transformRequest(data, responseMap) {
6444
+ const result = { ...data };
6445
+ const requestMap = reverseMap(responseMap);
6446
+ for (const [sdkField, apiField] of Object.entries(requestMap)) {
6447
+ if (sdkField in result) {
6448
+ result[apiField] = result[sdkField];
6449
+ delete result[sdkField];
6450
+ }
6451
+ }
6452
+ return result;
6453
+ }
6381
6454
  /**
6382
6455
  * Transforms an array-based dictionary with separate keys and values arrays
6383
6456
  * into a standard JavaScript object/record
@@ -6635,10 +6708,7 @@ class PaginationHelpers {
6635
6708
  */
6636
6709
  static async getAll(config, options) {
6637
6710
  const optionsWithDefaults = options || {};
6638
- const { folderId, ...restOptions } = optionsWithDefaults;
6639
- const cursor = options?.cursor;
6640
- const pageSize = options?.pageSize;
6641
- const jumpToPage = options?.jumpToPage;
6711
+ const { folderId, pageSize, cursor, jumpToPage, ...restOptions } = optionsWithDefaults;
6642
6712
  // Determine if pagination is requested
6643
6713
  const isPaginationRequested = PaginationHelpers.hasPaginationParameters(options || {});
6644
6714
  // Process parameters (custom processing if provided, otherwise default)
@@ -10341,17 +10411,8 @@ class ProcessService extends BaseService {
10341
10411
  */
10342
10412
  async start(request, folderId, options = {}) {
10343
10413
  const headers = createHeaders({ [FOLDER_ID]: folderId });
10344
- // Transform processKey/processName to releaseKey/releaseName for API compatibility
10345
- const apiRequest = { ...request };
10346
- // Create a reverse mapping using ProcessMap
10347
- const reversedPropertiesMap = reverseMap(ProcessMap);
10348
- // Apply transformations for any client properties found in the request
10349
- Object.entries(reversedPropertiesMap).forEach(([clientKey, apiKey]) => {
10350
- if (clientKey in apiRequest) {
10351
- apiRequest[apiKey] = apiRequest[clientKey];
10352
- delete apiRequest[clientKey];
10353
- }
10354
- });
10414
+ // Transform SDK field names to API field names (e.g., processKey → releaseKey)
10415
+ const apiRequest = transformRequest(request, ProcessMap);
10355
10416
  // Create the request object according to API spec
10356
10417
  const requestBody = {
10357
10418
  startInfo: apiRequest
@@ -10759,4 +10820,262 @@ var JobState;
10759
10820
  JobState["Resumed"] = "Resumed";
10760
10821
  })(JobState || (JobState = {}));
10761
10822
 
10762
- export { APP_NAME, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CLOUD_CLIENT_ID, CLOUD_ORGANIZATION_NAME, CLOUD_REDIRECT_URI, CLOUD_ROLE_NAME, CLOUD_TENANT_NAME, CLOUD_URL, CONNECTION_STRING, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, FieldDisplayType, HttpStatus, JobPriority, JobState, JobType, JoinType, MAX_PAGE_SIZE, NetworkError, NotFoundError, PackageSourceType, PackageType, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, SDK_LOGGER_NAME, SDK_RUN_EVENT, SDK_SERVICE_NAME, SDK_VERSION, SERVICE, SLADurationUnit, ServerError, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, UNKNOWN$1 as UNKNOWN, UiPath, UiPathError, VERSION, ValidationError, createCaseInstanceWithMethods, createEntityWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, telemetryClient, track, trackEvent };
10823
+ /**
10824
+ * Common Constants for Conversational Agent
10825
+ */
10826
+ /**
10827
+ * Common field mappings shared across all conversational agent entities.
10828
+ * Maps API response fields to SDK-consistent naming conventions.
10829
+ */
10830
+ const CommonFieldMap = {
10831
+ createdAt: 'createdTime',
10832
+ updatedAt: 'updatedTime'
10833
+ };
10834
+
10835
+ /**
10836
+ * Constants for Conversational Agent
10837
+ */
10838
+ /**
10839
+ * Maps API response fields to SDK field names (API → SDK)
10840
+ * Used when transforming API responses for SDK consumers.
10841
+ * For request transformation (SDK → API), use `transformRequest(data, ConversationMap)`.
10842
+ */
10843
+ const ConversationMap = {
10844
+ ...CommonFieldMap,
10845
+ conversationId: 'id',
10846
+ lastActivityAt: 'lastActivityTime',
10847
+ agentReleaseId: 'agentId'
10848
+ };
10849
+ /**
10850
+ * Maps fields for Exchange entity to ensure consistent SDK naming
10851
+ */
10852
+ const ExchangeMap = {
10853
+ ...CommonFieldMap
10854
+ };
10855
+ /**
10856
+ * Maps fields for Message entity to ensure consistent SDK naming
10857
+ */
10858
+ const MessageMap = {
10859
+ ...CommonFieldMap
10860
+ };
10861
+
10862
+ /**
10863
+ * Common types for Conversational Agent
10864
+ * Contains IDs, primitives, and utility types used across conversation types.
10865
+ */
10866
+ /**
10867
+ * Identifies the origin of a message in the conversation.
10868
+ */
10869
+ var MessageRole;
10870
+ (function (MessageRole) {
10871
+ MessageRole["System"] = "system";
10872
+ MessageRole["User"] = "user";
10873
+ MessageRole["Assistant"] = "assistant";
10874
+ })(MessageRole || (MessageRole = {}));
10875
+ /**
10876
+ * Identifies the type of an interrupt.
10877
+ */
10878
+ var InterruptType;
10879
+ (function (InterruptType) {
10880
+ InterruptType["ToolCallConfirmation"] = "uipath_cas_tool_call_confirmation";
10881
+ })(InterruptType || (InterruptType = {}));
10882
+
10883
+ /**
10884
+ * Core data model types for Conversational Agent REST endpoints
10885
+ * Contains: Conversation, Exchange, Message, ContentPart, ToolCall, etc.
10886
+ */
10887
+ /**
10888
+ * Represents the order in which items should be sorted.
10889
+ */
10890
+ var SortOrder;
10891
+ (function (SortOrder) {
10892
+ SortOrder["Ascending"] = "ascending";
10893
+ SortOrder["Descending"] = "descending";
10894
+ })(SortOrder || (SortOrder = {}));
10895
+ /**
10896
+ * Feedback rating type.
10897
+ */
10898
+ var FeedbackRating;
10899
+ (function (FeedbackRating) {
10900
+ FeedbackRating["Positive"] = "positive";
10901
+ FeedbackRating["Negative"] = "negative";
10902
+ })(FeedbackRating || (FeedbackRating = {}));
10903
+
10904
+ /**
10905
+ * Event types for Conversational Agent WebSocket protocol
10906
+ */
10907
+ /**
10908
+ * Identifies how sensitive the LLM should be when detecting the start or end of speech.
10909
+ *
10910
+ * * UNSPECIFIED - the default is HIGH
10911
+ * * HIGH - Will detect the start/end of speech more often.
10912
+ * * LOW - Will detect the start/end of speech less often.
10913
+ */
10914
+ var InputStreamSpeechSensitivity;
10915
+ (function (InputStreamSpeechSensitivity) {
10916
+ InputStreamSpeechSensitivity["Unspecified"] = "UNSPECIFIED";
10917
+ InputStreamSpeechSensitivity["High"] = "HIGH";
10918
+ InputStreamSpeechSensitivity["Low"] = "LOW";
10919
+ })(InputStreamSpeechSensitivity || (InputStreamSpeechSensitivity = {}));
10920
+
10921
+ /**
10922
+ * Content Part Stream Types
10923
+ *
10924
+ * Defines the public API for interacting with streaming content parts
10925
+ * within a message. Content parts represent text, audio, images, etc.
10926
+ */
10927
+ /**
10928
+ * Types of citation processing errors
10929
+ */
10930
+ var CitationErrorType;
10931
+ (function (CitationErrorType) {
10932
+ CitationErrorType["CitationNotEnded"] = "CitationNotEnded";
10933
+ CitationErrorType["CitationNotStarted"] = "CitationNotStarted";
10934
+ })(CitationErrorType || (CitationErrorType = {}));
10935
+
10936
+ /**
10937
+ * Conversation Service Model
10938
+ *
10939
+ * This interface defines the HTTP CRUD operations for conversations
10940
+ * and real-time WebSocket session management.
10941
+ */
10942
+ /**
10943
+ * Creates methods for a conversation
10944
+ *
10945
+ * @param conversationData - The conversation data (response from API)
10946
+ * @param service - The conversation service instance
10947
+ * @param sessionMethods - Optional session methods for WebSocket session operations
10948
+ * @param exchangeService - Optional exchange service for scoped exchange methods
10949
+ * @returns Object containing conversation methods
10950
+ */
10951
+ function createConversationMethods(conversationData, service, sessionMethods, exchangeService) {
10952
+ return {
10953
+ exchanges: {
10954
+ getAll(options) {
10955
+ if (!conversationData.id)
10956
+ throw new Error('Conversation ID is undefined');
10957
+ if (!exchangeService)
10958
+ throw new Error('Exchange methods are not available.');
10959
+ return exchangeService.getAll(conversationData.id, options);
10960
+ },
10961
+ getById(exchangeId, options) {
10962
+ if (!conversationData.id)
10963
+ throw new Error('Conversation ID is undefined');
10964
+ if (!exchangeService)
10965
+ throw new Error('Exchange methods are not available.');
10966
+ return exchangeService.getById(conversationData.id, exchangeId, options);
10967
+ },
10968
+ createFeedback(exchangeId, options) {
10969
+ if (!conversationData.id)
10970
+ throw new Error('Conversation ID is undefined');
10971
+ if (!exchangeService)
10972
+ throw new Error('Exchange methods are not available.');
10973
+ return exchangeService.createFeedback(conversationData.id, exchangeId, options);
10974
+ }
10975
+ },
10976
+ async update(options) {
10977
+ if (!conversationData.id)
10978
+ throw new Error('Conversation ID is undefined');
10979
+ return service.updateById(conversationData.id, options);
10980
+ },
10981
+ async delete() {
10982
+ if (!conversationData.id)
10983
+ throw new Error('Conversation ID is undefined');
10984
+ return service.deleteById(conversationData.id);
10985
+ },
10986
+ startSession(options) {
10987
+ if (!conversationData.id)
10988
+ throw new Error('Conversation ID is undefined');
10989
+ if (!sessionMethods) {
10990
+ throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
10991
+ }
10992
+ return sessionMethods.startSession(conversationData.id, options);
10993
+ },
10994
+ getSession() {
10995
+ if (!conversationData.id)
10996
+ throw new Error('Conversation ID is undefined');
10997
+ if (!sessionMethods) {
10998
+ throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
10999
+ }
11000
+ return sessionMethods.getSession(conversationData.id);
11001
+ },
11002
+ endSession() {
11003
+ if (!conversationData.id)
11004
+ throw new Error('Conversation ID is undefined');
11005
+ if (!sessionMethods) {
11006
+ throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
11007
+ }
11008
+ sessionMethods.endSession(conversationData.id);
11009
+ },
11010
+ async uploadAttachment(file) {
11011
+ if (!conversationData.id)
11012
+ throw new Error('Conversation ID is undefined');
11013
+ return service.uploadAttachment(conversationData.id, file);
11014
+ }
11015
+ };
11016
+ }
11017
+ /**
11018
+ * Creates an actionable conversation by combining API conversation data with operational methods.
11019
+ *
11020
+ * @param conversationData - The conversation data from API
11021
+ * @param service - The conversation service instance
11022
+ * @param sessionMethods - Optional session methods for WebSocket session operations
11023
+ * @param exchangeService - Optional exchange service for scoped exchange methods
11024
+ * @returns A conversation object with added methods
11025
+ */
11026
+ function createConversationWithMethods(conversationData, service, sessionMethods, exchangeService) {
11027
+ const methods = createConversationMethods(conversationData, service, sessionMethods, exchangeService);
11028
+ return Object.assign({}, conversationData, methods);
11029
+ }
11030
+
11031
+ /**
11032
+ * Agent Service Models
11033
+ *
11034
+ * Provides fluent API for agent objects returned from getAll() and getById().
11035
+ */
11036
+ /**
11037
+ * Creates methods for an agent
11038
+ *
11039
+ * @param agentData - The agent data from API
11040
+ * @param conversationService - The conversation service instance for delegation
11041
+ * @returns Object containing agent methods
11042
+ */
11043
+ function createAgentMethods(agentData, conversationService) {
11044
+ const agentConversations = {
11045
+ async create(options = {}) {
11046
+ return conversationService.create(agentData.id, agentData.folderId, options);
11047
+ }
11048
+ };
11049
+ return {
11050
+ conversations: agentConversations,
11051
+ get connectionStatus() { return conversationService.connectionStatus; },
11052
+ get isConnected() { return conversationService.isConnected; },
11053
+ get connectionError() { return conversationService.connectionError; }
11054
+ };
11055
+ }
11056
+ function createAgentWithMethods(agentData, conversationService) {
11057
+ const methods = createAgentMethods(agentData, conversationService);
11058
+ return Object.defineProperties(Object.assign({}, agentData), Object.getOwnPropertyDescriptors(methods));
11059
+ }
11060
+
11061
+ /**
11062
+ * Constants for Agent Service
11063
+ */
11064
+ /**
11065
+ * Maps fields for Agent entities to ensure consistent SDK naming
11066
+ */
11067
+ const AgentMap = {
11068
+ ...CommonFieldMap
11069
+ };
11070
+
11071
+ /**
11072
+ * Constants for User Service
11073
+ */
11074
+ /**
11075
+ * Maps fields for User Settings entities to ensure consistent SDK naming
11076
+ */
11077
+ const UserSettingsMap = {
11078
+ ...CommonFieldMap
11079
+ };
11080
+
11081
+ export { APP_NAME, AgentMap, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CLOUD_CLIENT_ID, CLOUD_ORGANIZATION_NAME, CLOUD_REDIRECT_URI, CLOUD_ROLE_NAME, CLOUD_TENANT_NAME, CLOUD_URL, CONNECTION_STRING, CitationErrorType, ConversationMap, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, ExchangeMap, FeedbackRating, FieldDisplayType, HttpStatus, InputStreamSpeechSensitivity, InterruptType, JobPriority, JobState, JobType, JoinType, MAX_PAGE_SIZE, MessageMap, MessageRole, NetworkError, NotFoundError, PackageSourceType, PackageType, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, SDK_LOGGER_NAME, SDK_RUN_EVENT, SDK_SERVICE_NAME, SDK_VERSION, SERVICE, SLADurationUnit, ServerError, SortOrder, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, UNKNOWN$1 as UNKNOWN, UiPath, UiPathError, UserSettingsMap, VERSION, ValidationError, createAgentWithMethods, createCaseInstanceWithMethods, createConversationWithMethods, createEntityWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, telemetryClient, track, trackEvent };