@uipath/conversational-tool 1.204.0 → 1.205.0-preview.258

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.
@@ -2101,7 +2101,7 @@ var package_default = {
2101
2101
  name: "@uipath/conversational-tool",
2102
2102
  author: "UiPath",
2103
2103
  license: "SEE LICENSE IN LICENSE.txt",
2104
- version: "1.204.0",
2104
+ version: "1.205.0-preview.258",
2105
2105
  description: "Handle conversations with deployed UiPath conversational processes.",
2106
2106
  publishConfig: {
2107
2107
  registry: "https://npm.pkg.github.com/"
@@ -2130,7 +2130,7 @@ var package_default = {
2130
2130
  "@uipath/common": "workspace:*",
2131
2131
  "@uipath/auth": "workspace:*",
2132
2132
  "@uipath/filesystem": "workspace:*",
2133
- "@uipath/uipath-typescript": "^1.7.1",
2133
+ "@uipath/uipath-typescript": "^1.8.0",
2134
2134
  "@types/node": "^25.5.2",
2135
2135
  typescript: "^7.0.2"
2136
2136
  }
@@ -2241,7 +2241,9 @@ var ErrorDimensions = {
2241
2241
  Result: "Result",
2242
2242
  ErrorCode: "ErrorCode",
2243
2243
  Retry: "Retry",
2244
- ErrorMessage: "ErrorMessage"
2244
+ ErrorMessage: "ErrorMessage",
2245
+ HttpStatus: "HttpStatus",
2246
+ UpstreamErrorCode: "UpstreamErrorCode"
2245
2247
  };
2246
2248
  var AuthDimensions = {
2247
2249
  AuthenticationMethod: "AuthenticationMethod",
@@ -2550,6 +2552,16 @@ class NodeFileSystem {
2550
2552
  async rename(oldPath, newPath) {
2551
2553
  await fs.rename(oldPath, newPath);
2552
2554
  }
2555
+ async isSymbolicLink(filePath) {
2556
+ try {
2557
+ return (await fs.lstat(filePath)).isSymbolicLink();
2558
+ } catch (error) {
2559
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
2560
+ return false;
2561
+ }
2562
+ throw error;
2563
+ }
2564
+ }
2553
2565
  async realpath(filePath) {
2554
2566
  try {
2555
2567
  return await fs.realpath(filePath);
@@ -3565,7 +3577,7 @@ function setGlobalLogFilePath(path2) {
3565
3577
  function getGlobalLogFilePath() {
3566
3578
  return logFilePathSlot.get("");
3567
3579
  }
3568
- var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
3580
+ var DEFAULT_LOG_LEVEL = 2 /* WARN */;
3569
3581
 
3570
3582
  class SimpleLogger {
3571
3583
  __brand = "SimpleLogger";
@@ -4667,7 +4679,9 @@ var CLI_ERROR_CODES = [
4667
4679
  "timeout",
4668
4680
  "server_error",
4669
4681
  "method_not_allowed",
4682
+ "not_supported",
4670
4683
  "configuration_error",
4684
+ "execution_failed",
4671
4685
  "unknown_error"
4672
4686
  ];
4673
4687
  var RETRY_HINTS = [
@@ -5624,7 +5638,9 @@ var OutputFormatter;
5624
5638
  [ErrorDimensions.Result]: data.Result,
5625
5639
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
5626
5640
  [ErrorDimensions.Retry]: data.Retry,
5627
- [ErrorDimensions.ErrorMessage]: data.Message
5641
+ [ErrorDimensions.ErrorMessage]: data.Message,
5642
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
5643
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
5628
5644
  });
5629
5645
  }
5630
5646
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -6737,22 +6753,12 @@ var resolveConfigAsync = async ({
6737
6753
  baseUrl = DEFAULT_BASE_URL;
6738
6754
  }
6739
6755
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
6740
- let clientId = customClientId;
6741
- if (!clientId && fileAuth.clientId) {
6742
- clientId = fileAuth.clientId;
6743
- }
6744
- if (!clientId) {
6745
- clientId = DEFAULT_CLIENT_ID;
6746
- }
6747
- let clientSecret = customClientSecret;
6748
- if (!clientSecret && fileAuth.clientSecret) {
6749
- clientSecret = fileAuth.clientSecret;
6750
- }
6751
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
6756
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
6757
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
6752
6758
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
6753
6759
  return {
6754
6760
  clientId,
6755
- clientSecret,
6761
+ clientSecret: customClientSecret,
6756
6762
  scopes,
6757
6763
  baseUrl,
6758
6764
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -6858,6 +6864,16 @@ var resolveIdentityType = (claims, authFlow, email) => {
6858
6864
  }
6859
6865
  return;
6860
6866
  };
6867
+ var resolveApplicationSubtype = (claims, authFlow) => {
6868
+ switch (asString(claims?.sub_type)) {
6869
+ case "service.external":
6870
+ return "External";
6871
+ case "service.internal":
6872
+ return "Internal";
6873
+ default:
6874
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
6875
+ }
6876
+ };
6861
6877
  var looksLikeEmail = (value) => value?.includes("@") ?? false;
6862
6878
  var pickEmail = (claims) => {
6863
6879
  for (const candidate of [claims?.email, claims?.preferred_username]) {
@@ -6899,6 +6915,12 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
6899
6915
  const clientId = asString(claims?.client_id);
6900
6916
  if (clientId)
6901
6917
  identity.clientId = clientId;
6918
+ const subType = asString(claims?.sub_type);
6919
+ if (subType)
6920
+ identity.subType = subType;
6921
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
6922
+ if (applicationSubtype)
6923
+ identity.applicationSubtype = applicationSubtype;
6902
6924
  return identity;
6903
6925
  };
6904
6926
  var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
@@ -7191,6 +7213,40 @@ var tryRobotClientFallback = async (options = {}) => {
7191
7213
  }
7192
7214
  };
7193
7215
 
7216
+ // ../auth/src/tenantSelection.ts
7217
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
7218
+ var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
7219
+ var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7220
+ var describeNonJsonResponse = (organizationId, response, parseError) => {
7221
+ if (response.redirected) {
7222
+ return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
7223
+ }
7224
+ const contentType = response.headers.get("content-type") ?? "unknown";
7225
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
7226
+ };
7227
+ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
7228
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
7229
+ const response = await fetch(url, {
7230
+ headers: {
7231
+ Authorization: `Bearer ${accessToken}`
7232
+ },
7233
+ ...signal ? { signal } : {}
7234
+ });
7235
+ if (!response.ok) {
7236
+ if (response.status === 401) {
7237
+ throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
7238
+ }
7239
+ const errorText = await response.text();
7240
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
7241
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
7242
+ }
7243
+ const [parseError, data] = await catchError2(response.json());
7244
+ if (parseError) {
7245
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
7246
+ }
7247
+ return data;
7248
+ };
7249
+
7194
7250
  // ../auth/src/tokenRefresh.ts
7195
7251
  var TOKEN_REFRESH_REAUTHENTICATE_MESSAGE = "Token refresh failed. Run 'uip login' to re-authenticate.";
7196
7252
 
@@ -7403,6 +7459,8 @@ var saveEnvFileAsync = async ({
7403
7459
  };
7404
7460
 
7405
7461
  // ../auth/src/loginStatus.ts
7462
+ var defaultRobotTenantIdCache = new Map;
7463
+ var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
7406
7464
  var getLoginStatusAsync = async (options = {}) => {
7407
7465
  return getLoginStatusWithDeps(options);
7408
7466
  };
@@ -7415,12 +7473,20 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7415
7473
  refreshToken: refreshTokenFn = refreshAccessToken,
7416
7474
  resolveConfig = resolveConfigAsync,
7417
7475
  robotFallback = tryRobotClientFallback,
7476
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
7477
+ robotTenantIdCache = defaultRobotTenantIdCache,
7478
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
7418
7479
  loadBreaker = loadRefreshBreaker,
7419
7480
  saveBreaker = saveRefreshBreaker,
7420
7481
  clearBreaker = clearRefreshBreaker
7421
7482
  } = deps;
7483
+ const robotDeps = {
7484
+ fetchTenantsAndOrgs,
7485
+ cache: robotTenantIdCache,
7486
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
7487
+ };
7422
7488
  if (isRobotAuthEnforced()) {
7423
- return resolveRobotEnforcedStatus(robotFallback);
7489
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
7424
7490
  }
7425
7491
  if (isEnvAuthEnabled()) {
7426
7492
  return readAuthFromEnv();
@@ -7438,7 +7504,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7438
7504
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
7439
7505
  };
7440
7506
  }
7441
- return resolveBorrowedRobotStatus(robotFallback);
7507
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
7442
7508
  }
7443
7509
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
7444
7510
  if ("status" in loaded) {
@@ -7480,7 +7546,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7480
7546
  }
7481
7547
  return buildFileStatus(tokens, credentials, globalHint);
7482
7548
  };
7483
- async function resolveRobotEnforcedStatus(robotFallback) {
7549
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
7484
7550
  if (isEnvAuthEnabled()) {
7485
7551
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
7486
7552
  }
@@ -7491,11 +7557,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
7491
7557
  hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
7492
7558
  };
7493
7559
  }
7494
- return buildRobotStatus(robotCreds);
7560
+ return buildRobotStatus(robotCreds, deps);
7495
7561
  }
7496
- async function resolveBorrowedRobotStatus(robotFallback) {
7562
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
7497
7563
  const robotCreds = await robotFallback();
7498
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
7564
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
7499
7565
  }
7500
7566
  async function loadFileCredentials(loadEnvFile, absolutePath) {
7501
7567
  let credentials;
@@ -7630,9 +7696,10 @@ function identityFields(accessToken, credentials) {
7630
7696
  ...scopes ? { scopes } : {}
7631
7697
  };
7632
7698
  }
7633
- function buildRobotStatus(robotCreds) {
7699
+ async function buildRobotStatus(robotCreds, deps) {
7634
7700
  const identity = resolveSessionIdentity(robotCreds.accessToken);
7635
7701
  const scopes = readTokenScopes(robotCreds.accessToken);
7702
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
7636
7703
  return {
7637
7704
  loginStatus: "Logged in",
7638
7705
  accessToken: robotCreds.accessToken,
@@ -7640,14 +7707,62 @@ function buildRobotStatus(robotCreds) {
7640
7707
  organizationName: robotCreds.organizationName,
7641
7708
  organizationId: robotCreds.organizationId,
7642
7709
  tenantName: robotCreds.tenantName,
7643
- tenantId: robotCreds.tenantId,
7710
+ tenantId: tenant.tenantId,
7644
7711
  issuer: robotCreds.issuer,
7645
7712
  expiration: getTokenExpiration(robotCreds.accessToken),
7646
7713
  source: "robot" /* Robot */,
7714
+ ...tenant.hint ? { hint: tenant.hint } : {},
7647
7715
  ...identity ? { identity } : {},
7648
7716
  ...scopes ? { scopes } : {}
7649
7717
  };
7650
7718
  }
7719
+ async function resolveRobotTenantId(robotCreds, deps) {
7720
+ const { baseUrl, accessToken, tenantName } = robotCreds;
7721
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
7722
+ if (!tenantName || !organization) {
7723
+ return {};
7724
+ }
7725
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
7726
+ let pending = deps.cache.get(key);
7727
+ if (!pending) {
7728
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
7729
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
7730
+ if (!settled.tenantId) {
7731
+ deps.cache.delete(key);
7732
+ }
7733
+ return settled;
7734
+ });
7735
+ deps.cache.set(key, pending);
7736
+ }
7737
+ return pending;
7738
+ }
7739
+ async function lookupRobotTenantId(target, deps) {
7740
+ const { baseUrl, accessToken, organization, tenantName } = target;
7741
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
7742
+ if (error) {
7743
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
7744
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
7745
+ }
7746
+ const rows = data?.tenants;
7747
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
7748
+ const wantedName = decodePathSegment(tenantName);
7749
+ const wanted = wantedName.toLowerCase();
7750
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
7751
+ if (!match) {
7752
+ const names = tenants.map((tenant) => tenant.name).join(", ");
7753
+ return {
7754
+ hint: `The Robot session targets tenant '${tenantName}', but ` + `organization '${organization}' lists no tenant of that name` + `${names ? ` (available: ${names})` : ""}. Commands that need ` + `the tenant id will fail until it can be resolved.`
7755
+ };
7756
+ }
7757
+ return { tenantId: match.id };
7758
+ }
7759
+ function tenantLookupFailureHint(tenantName, reason) {
7760
+ return `Could not resolve the id of tenant '${tenantName}' from the ` + `Robot session: ${reason} Commands that need the tenant id will ` + `fail until it can be resolved.`;
7761
+ }
7762
+ function decodePathSegment(segment) {
7763
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
7764
+ return error ? segment : decoded;
7765
+ }
7651
7766
  var isFileNotFoundError = (error) => {
7652
7767
  if (!(error instanceof Object))
7653
7768
  return false;
@@ -7883,9 +7998,6 @@ function normalizeTokenRefreshUnavailableFailure() {
7883
7998
  function errorMessage(error) {
7884
7999
  return error instanceof Error ? error.message : String(error);
7885
8000
  }
7886
- // ../auth/src/tenantSelection.ts
7887
- var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7888
-
7889
8001
  // ../auth/src/selectTenant.ts
7890
8002
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
7891
8003
  var INVALID_TENANT_CODE = "INVALID_TENANT";
@@ -7898,4 +8010,4 @@ var CLI_EXTERNAL_USER_ID = "app-user-cli-cas";
7898
8010
 
7899
8011
  export { package_default, getFileSystem, catchError, extractErrorDetails, extractErrorMessageSync, RESULTS, EXIT_CODES, OutputFormatter, InvalidArgumentError, Command, processContext, requireConfirmation, instructionsFor, canPrompt, parseBoundedInt, getSdkUserAgentToken, addSdkUserAgentHeader, getLoginStatusAsync, CLI_EXTERNAL_USER_ID };
7900
8012
 
7901
- //# debugId=78F4E5CD14A52E9164756E2164756E21
8013
+ //# debugId=FF27F74288A200B164756E2164756E21