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