@uipath/eval-tool 1.204.0-preview.254 → 1.205.0-preview.256

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.
@@ -3164,7 +3164,9 @@ var ErrorDimensions = {
3164
3164
  Result: "Result",
3165
3165
  ErrorCode: "ErrorCode",
3166
3166
  Retry: "Retry",
3167
- ErrorMessage: "ErrorMessage"
3167
+ ErrorMessage: "ErrorMessage",
3168
+ HttpStatus: "HttpStatus",
3169
+ UpstreamErrorCode: "UpstreamErrorCode"
3168
3170
  };
3169
3171
  var AuthDimensions = {
3170
3172
  AuthenticationMethod: "AuthenticationMethod",
@@ -3514,6 +3516,16 @@ class NodeFileSystem {
3514
3516
  async rename(oldPath, newPath) {
3515
3517
  await fs.rename(oldPath, newPath);
3516
3518
  }
3519
+ async isSymbolicLink(filePath) {
3520
+ try {
3521
+ return (await fs.lstat(filePath)).isSymbolicLink();
3522
+ } catch (error) {
3523
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
3524
+ return false;
3525
+ }
3526
+ throw error;
3527
+ }
3528
+ }
3517
3529
  async realpath(filePath) {
3518
3530
  try {
3519
3531
  return await fs.realpath(filePath);
@@ -3607,7 +3619,7 @@ function setGlobalLogFilePath(path2) {
3607
3619
  function getGlobalLogFilePath() {
3608
3620
  return logFilePathSlot.get("");
3609
3621
  }
3610
- var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
3622
+ var DEFAULT_LOG_LEVEL = 2 /* WARN */;
3611
3623
 
3612
3624
  class SimpleLogger {
3613
3625
  __brand = "SimpleLogger";
@@ -4709,7 +4721,9 @@ var CLI_ERROR_CODES = [
4709
4721
  "timeout",
4710
4722
  "server_error",
4711
4723
  "method_not_allowed",
4724
+ "not_supported",
4712
4725
  "configuration_error",
4726
+ "execution_failed",
4713
4727
  "unknown_error"
4714
4728
  ];
4715
4729
  var RETRY_HINTS = [
@@ -5699,7 +5713,9 @@ var OutputFormatter;
5699
5713
  [ErrorDimensions.Result]: data.Result,
5700
5714
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
5701
5715
  [ErrorDimensions.Retry]: data.Retry,
5702
- [ErrorDimensions.ErrorMessage]: data.Message
5716
+ [ErrorDimensions.ErrorMessage]: data.Message,
5717
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
5718
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
5703
5719
  });
5704
5720
  }
5705
5721
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -6587,6 +6603,165 @@ function settlePromiseLike2(thenable) {
6587
6603
  ]);
6588
6604
  }
6589
6605
 
6606
+ // ../auth/src/utils/platform.ts
6607
+ function isBrowser() {
6608
+ return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
6609
+ }
6610
+
6611
+ // ../auth/src/utils/jwt.ts
6612
+ class InvalidIssuerError extends Error {
6613
+ expected;
6614
+ actual;
6615
+ constructor(expected, actual) {
6616
+ const actualText = actual ?? "<missing>";
6617
+ super(`Token issuer does not match the authority used to log in.
6618
+ ` + `Expected: ${expected}
6619
+ ` + `Actual: ${actualText}
6620
+
6621
+ ` + `The identity server that issued this token is not the one ` + `you pointed --authority at. Refusing to save credentials.`);
6622
+ this.expected = expected;
6623
+ this.actual = actual;
6624
+ this.name = "InvalidIssuerError";
6625
+ }
6626
+ }
6627
+ var parseJWT = (token) => {
6628
+ try {
6629
+ const parts = token.split(".");
6630
+ const base64Url = parts[1];
6631
+ if (!base64Url) {
6632
+ throw new Error("Invalid JWT token format - missing payload section");
6633
+ }
6634
+ const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
6635
+ let decodedString;
6636
+ if (isBrowser() && typeof atob !== "undefined") {
6637
+ decodedString = atob(base64);
6638
+ } else {
6639
+ decodedString = Buffer.from(base64, "base64").toString();
6640
+ }
6641
+ const jsonPayload = decodeURIComponent(decodedString.split("").map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));
6642
+ const parsed = JSON.parse(jsonPayload);
6643
+ return parsed;
6644
+ } catch (error) {
6645
+ throw new Error(`Failed to parse JWT: ${error instanceof Error ? error.message : "Unknown error"}`);
6646
+ }
6647
+ };
6648
+ var assertIssuerMatchesAuthority = (token, authority) => {
6649
+ let payload;
6650
+ try {
6651
+ payload = parseJWT(token);
6652
+ } catch (error) {
6653
+ throw new InvalidIssuerError(`${authority.replace(/\/+$/, "")}/identity_`, `<unparseable: ${error instanceof Error ? error.message : "unknown error"}>`);
6654
+ }
6655
+ const stripTrailingSlash = (s) => s.replace(/\/+$/, "");
6656
+ const expected = `${stripTrailingSlash(authority)}/identity_`;
6657
+ const actual = typeof payload.iss === "string" ? stripTrailingSlash(payload.iss) : undefined;
6658
+ if (actual !== expected) {
6659
+ throw new InvalidIssuerError(expected, payload.iss);
6660
+ }
6661
+ };
6662
+ var getTokenExpiration = (accessToken) => {
6663
+ try {
6664
+ const parts = accessToken.split(".");
6665
+ if (parts.length !== 3) {
6666
+ return;
6667
+ }
6668
+ const payload = parts[1];
6669
+ const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
6670
+ const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
6671
+ const decoded = atob(padded);
6672
+ const claims = JSON.parse(decoded);
6673
+ if (typeof claims.exp !== "number") {
6674
+ return;
6675
+ }
6676
+ return new Date(claims.exp * 1000);
6677
+ } catch {
6678
+ return;
6679
+ }
6680
+ };
6681
+
6682
+ // ../auth/src/sessionIdentity.ts
6683
+ var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
6684
+ var decodeClaims = (accessToken) => {
6685
+ const [error, claims] = catchError2(() => parseJWT(accessToken));
6686
+ return error ? undefined : claims;
6687
+ };
6688
+ var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
6689
+ var resolveIdentityType = (claims, authFlow, email) => {
6690
+ const subType = asString(claims?.sub_type);
6691
+ if (subType) {
6692
+ return subType.startsWith("service") ? "Application" : "User";
6693
+ }
6694
+ if (authFlow) {
6695
+ return authFlow === "authorization_code" ? "User" : "Application";
6696
+ }
6697
+ if (email)
6698
+ return "User";
6699
+ if (asString(claims?.client_id) && !asString(claims?.sub)) {
6700
+ return "Application";
6701
+ }
6702
+ return;
6703
+ };
6704
+ var resolveApplicationSubtype = (claims, authFlow) => {
6705
+ switch (asString(claims?.sub_type)) {
6706
+ case "service.external":
6707
+ return "External";
6708
+ case "service.internal":
6709
+ return "Internal";
6710
+ default:
6711
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
6712
+ }
6713
+ };
6714
+ var looksLikeEmail = (value) => value?.includes("@") ?? false;
6715
+ var pickEmail = (claims) => {
6716
+ for (const candidate of [claims?.email, claims?.preferred_username]) {
6717
+ const value = asString(candidate);
6718
+ if (looksLikeEmail(value))
6719
+ return value;
6720
+ }
6721
+ return;
6722
+ };
6723
+ var pickName = (claims) => {
6724
+ const username = asString(claims?.preferred_username);
6725
+ return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
6726
+ };
6727
+ var pickScopes = (claims) => {
6728
+ const raw = claims?.scope;
6729
+ const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
6730
+ return scopes.length > 0 ? scopes : undefined;
6731
+ };
6732
+ var resolveSessionIdentity = (accessToken, authFlow) => {
6733
+ const claims = accessToken ? decodeClaims(accessToken) : undefined;
6734
+ const email = pickEmail(claims);
6735
+ const type = resolveIdentityType(claims, authFlow, email);
6736
+ if (!type)
6737
+ return;
6738
+ const identity = { type };
6739
+ if (authFlow)
6740
+ identity.authFlow = authFlow;
6741
+ if (type === "User") {
6742
+ const userId = asString(claims?.sub);
6743
+ if (userId)
6744
+ identity.userId = userId;
6745
+ if (email)
6746
+ identity.userEmail = email;
6747
+ const name = pickName(claims);
6748
+ if (name)
6749
+ identity.userName = name;
6750
+ return identity;
6751
+ }
6752
+ const clientId = asString(claims?.client_id);
6753
+ if (clientId)
6754
+ identity.clientId = clientId;
6755
+ const subType = asString(claims?.sub_type);
6756
+ if (subType)
6757
+ identity.subType = subType;
6758
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
6759
+ if (applicationSubtype)
6760
+ identity.applicationSubtype = applicationSubtype;
6761
+ return identity;
6762
+ };
6763
+ var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
6764
+
6590
6765
  // ../auth/src/constants.ts
6591
6766
  var UIPATH_HOME_DIR = ".uipath";
6592
6767
  var AUTH_FILENAME = ".auth";
@@ -6736,22 +6911,12 @@ var resolveConfigAsync = async ({
6736
6911
  baseUrl = DEFAULT_BASE_URL;
6737
6912
  }
6738
6913
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
6739
- let clientId = customClientId;
6740
- if (!clientId && fileAuth.clientId) {
6741
- clientId = fileAuth.clientId;
6742
- }
6743
- if (!clientId) {
6744
- clientId = DEFAULT_CLIENT_ID;
6745
- }
6746
- let clientSecret = customClientSecret;
6747
- if (!clientSecret && fileAuth.clientSecret) {
6748
- clientSecret = fileAuth.clientSecret;
6749
- }
6750
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
6914
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
6915
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
6751
6916
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
6752
6917
  return {
6753
6918
  clientId,
6754
- clientSecret,
6919
+ clientSecret: customClientSecret,
6755
6920
  scopes,
6756
6921
  baseUrl,
6757
6922
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -6759,149 +6924,6 @@ var resolveConfigAsync = async ({
6759
6924
  };
6760
6925
  };
6761
6926
 
6762
- // ../auth/src/utils/platform.ts
6763
- function isBrowser() {
6764
- return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
6765
- }
6766
-
6767
- // ../auth/src/utils/jwt.ts
6768
- class InvalidIssuerError extends Error {
6769
- expected;
6770
- actual;
6771
- constructor(expected, actual) {
6772
- const actualText = actual ?? "<missing>";
6773
- super(`Token issuer does not match the authority used to log in.
6774
- ` + `Expected: ${expected}
6775
- ` + `Actual: ${actualText}
6776
-
6777
- ` + `The identity server that issued this token is not the one ` + `you pointed --authority at. Refusing to save credentials.`);
6778
- this.expected = expected;
6779
- this.actual = actual;
6780
- this.name = "InvalidIssuerError";
6781
- }
6782
- }
6783
- var parseJWT = (token) => {
6784
- try {
6785
- const parts = token.split(".");
6786
- const base64Url = parts[1];
6787
- if (!base64Url) {
6788
- throw new Error("Invalid JWT token format - missing payload section");
6789
- }
6790
- const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
6791
- let decodedString;
6792
- if (isBrowser() && typeof atob !== "undefined") {
6793
- decodedString = atob(base64);
6794
- } else {
6795
- decodedString = Buffer.from(base64, "base64").toString();
6796
- }
6797
- const jsonPayload = decodeURIComponent(decodedString.split("").map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));
6798
- const parsed = JSON.parse(jsonPayload);
6799
- return parsed;
6800
- } catch (error) {
6801
- throw new Error(`Failed to parse JWT: ${error instanceof Error ? error.message : "Unknown error"}`);
6802
- }
6803
- };
6804
- var assertIssuerMatchesAuthority = (token, authority) => {
6805
- let payload;
6806
- try {
6807
- payload = parseJWT(token);
6808
- } catch (error) {
6809
- throw new InvalidIssuerError(`${authority.replace(/\/+$/, "")}/identity_`, `<unparseable: ${error instanceof Error ? error.message : "unknown error"}>`);
6810
- }
6811
- const stripTrailingSlash = (s) => s.replace(/\/+$/, "");
6812
- const expected = `${stripTrailingSlash(authority)}/identity_`;
6813
- const actual = typeof payload.iss === "string" ? stripTrailingSlash(payload.iss) : undefined;
6814
- if (actual !== expected) {
6815
- throw new InvalidIssuerError(expected, payload.iss);
6816
- }
6817
- };
6818
- var getTokenExpiration = (accessToken) => {
6819
- try {
6820
- const parts = accessToken.split(".");
6821
- if (parts.length !== 3) {
6822
- return;
6823
- }
6824
- const payload = parts[1];
6825
- const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
6826
- const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
6827
- const decoded = atob(padded);
6828
- const claims = JSON.parse(decoded);
6829
- if (typeof claims.exp !== "number") {
6830
- return;
6831
- }
6832
- return new Date(claims.exp * 1000);
6833
- } catch {
6834
- return;
6835
- }
6836
- };
6837
-
6838
- // ../auth/src/sessionIdentity.ts
6839
- var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
6840
- var decodeClaims = (accessToken) => {
6841
- const [error, claims] = catchError2(() => parseJWT(accessToken));
6842
- return error ? undefined : claims;
6843
- };
6844
- var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
6845
- var resolveIdentityType = (claims, authFlow, email) => {
6846
- const subType = asString(claims?.sub_type);
6847
- if (subType) {
6848
- return subType.startsWith("service") ? "Application" : "User";
6849
- }
6850
- if (authFlow) {
6851
- return authFlow === "authorization_code" ? "User" : "Application";
6852
- }
6853
- if (email)
6854
- return "User";
6855
- if (asString(claims?.client_id) && !asString(claims?.sub)) {
6856
- return "Application";
6857
- }
6858
- return;
6859
- };
6860
- var looksLikeEmail = (value) => value?.includes("@") ?? false;
6861
- var pickEmail = (claims) => {
6862
- for (const candidate of [claims?.email, claims?.preferred_username]) {
6863
- const value = asString(candidate);
6864
- if (looksLikeEmail(value))
6865
- return value;
6866
- }
6867
- return;
6868
- };
6869
- var pickName = (claims) => {
6870
- const username = asString(claims?.preferred_username);
6871
- return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
6872
- };
6873
- var pickScopes = (claims) => {
6874
- const raw = claims?.scope;
6875
- const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
6876
- return scopes.length > 0 ? scopes : undefined;
6877
- };
6878
- var resolveSessionIdentity = (accessToken, authFlow) => {
6879
- const claims = accessToken ? decodeClaims(accessToken) : undefined;
6880
- const email = pickEmail(claims);
6881
- const type = resolveIdentityType(claims, authFlow, email);
6882
- if (!type)
6883
- return;
6884
- const identity = { type };
6885
- if (authFlow)
6886
- identity.authFlow = authFlow;
6887
- if (type === "User") {
6888
- const userId = asString(claims?.sub);
6889
- if (userId)
6890
- identity.userId = userId;
6891
- if (email)
6892
- identity.userEmail = email;
6893
- const name = pickName(claims);
6894
- if (name)
6895
- identity.userName = name;
6896
- return identity;
6897
- }
6898
- const clientId = asString(claims?.client_id);
6899
- if (clientId)
6900
- identity.clientId = clientId;
6901
- return identity;
6902
- };
6903
- var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
6904
-
6905
6927
  // ../auth/src/envAuth.ts
6906
6928
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
6907
6929
  var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
@@ -7190,6 +7212,40 @@ var tryRobotClientFallback = async (options = {}) => {
7190
7212
  }
7191
7213
  };
7192
7214
 
7215
+ // ../auth/src/tenantSelection.ts
7216
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
7217
+ var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
7218
+ var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7219
+ var describeNonJsonResponse = (organizationId, response, parseError) => {
7220
+ if (response.redirected) {
7221
+ 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}`;
7222
+ }
7223
+ const contentType = response.headers.get("content-type") ?? "unknown";
7224
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
7225
+ };
7226
+ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
7227
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
7228
+ const response = await fetch(url, {
7229
+ headers: {
7230
+ Authorization: `Bearer ${accessToken}`
7231
+ },
7232
+ ...signal ? { signal } : {}
7233
+ });
7234
+ if (!response.ok) {
7235
+ if (response.status === 401) {
7236
+ 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);
7237
+ }
7238
+ const errorText = await response.text();
7239
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
7240
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
7241
+ }
7242
+ const [parseError, data] = await catchError2(response.json());
7243
+ if (parseError) {
7244
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
7245
+ }
7246
+ return data;
7247
+ };
7248
+
7193
7249
  // ../auth/src/tokenRefresh.ts
7194
7250
  var TOKEN_REFRESH_REAUTHENTICATE_MESSAGE = "Token refresh failed. Run 'uip login' to re-authenticate.";
7195
7251
 
@@ -7402,6 +7458,8 @@ var saveEnvFileAsync = async ({
7402
7458
  };
7403
7459
 
7404
7460
  // ../auth/src/loginStatus.ts
7461
+ var defaultRobotTenantIdCache = new Map;
7462
+ var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
7405
7463
  var getLoginStatusAsync = async (options = {}) => {
7406
7464
  return getLoginStatusWithDeps(options);
7407
7465
  };
@@ -7414,12 +7472,20 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7414
7472
  refreshToken: refreshTokenFn = refreshAccessToken,
7415
7473
  resolveConfig = resolveConfigAsync,
7416
7474
  robotFallback = tryRobotClientFallback,
7475
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
7476
+ robotTenantIdCache = defaultRobotTenantIdCache,
7477
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
7417
7478
  loadBreaker = loadRefreshBreaker,
7418
7479
  saveBreaker = saveRefreshBreaker,
7419
7480
  clearBreaker = clearRefreshBreaker
7420
7481
  } = deps;
7482
+ const robotDeps = {
7483
+ fetchTenantsAndOrgs,
7484
+ cache: robotTenantIdCache,
7485
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
7486
+ };
7421
7487
  if (isRobotAuthEnforced()) {
7422
- return resolveRobotEnforcedStatus(robotFallback);
7488
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
7423
7489
  }
7424
7490
  if (isEnvAuthEnabled()) {
7425
7491
  return readAuthFromEnv();
@@ -7437,7 +7503,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7437
7503
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
7438
7504
  };
7439
7505
  }
7440
- return resolveBorrowedRobotStatus(robotFallback);
7506
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
7441
7507
  }
7442
7508
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
7443
7509
  if ("status" in loaded) {
@@ -7479,7 +7545,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7479
7545
  }
7480
7546
  return buildFileStatus(tokens, credentials, globalHint);
7481
7547
  };
7482
- async function resolveRobotEnforcedStatus(robotFallback) {
7548
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
7483
7549
  if (isEnvAuthEnabled()) {
7484
7550
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
7485
7551
  }
@@ -7490,11 +7556,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
7490
7556
  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.`
7491
7557
  };
7492
7558
  }
7493
- return buildRobotStatus(robotCreds);
7559
+ return buildRobotStatus(robotCreds, deps);
7494
7560
  }
7495
- async function resolveBorrowedRobotStatus(robotFallback) {
7561
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
7496
7562
  const robotCreds = await robotFallback();
7497
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
7563
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
7498
7564
  }
7499
7565
  async function loadFileCredentials(loadEnvFile, absolutePath) {
7500
7566
  let credentials;
@@ -7629,9 +7695,10 @@ function identityFields(accessToken, credentials) {
7629
7695
  ...scopes ? { scopes } : {}
7630
7696
  };
7631
7697
  }
7632
- function buildRobotStatus(robotCreds) {
7698
+ async function buildRobotStatus(robotCreds, deps) {
7633
7699
  const identity = resolveSessionIdentity(robotCreds.accessToken);
7634
7700
  const scopes = readTokenScopes(robotCreds.accessToken);
7701
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
7635
7702
  return {
7636
7703
  loginStatus: "Logged in",
7637
7704
  accessToken: robotCreds.accessToken,
@@ -7639,14 +7706,62 @@ function buildRobotStatus(robotCreds) {
7639
7706
  organizationName: robotCreds.organizationName,
7640
7707
  organizationId: robotCreds.organizationId,
7641
7708
  tenantName: robotCreds.tenantName,
7642
- tenantId: robotCreds.tenantId,
7709
+ tenantId: tenant.tenantId,
7643
7710
  issuer: robotCreds.issuer,
7644
7711
  expiration: getTokenExpiration(robotCreds.accessToken),
7645
7712
  source: "robot" /* Robot */,
7713
+ ...tenant.hint ? { hint: tenant.hint } : {},
7646
7714
  ...identity ? { identity } : {},
7647
7715
  ...scopes ? { scopes } : {}
7648
7716
  };
7649
7717
  }
7718
+ async function resolveRobotTenantId(robotCreds, deps) {
7719
+ const { baseUrl, accessToken, tenantName } = robotCreds;
7720
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
7721
+ if (!tenantName || !organization) {
7722
+ return {};
7723
+ }
7724
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
7725
+ let pending = deps.cache.get(key);
7726
+ if (!pending) {
7727
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
7728
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
7729
+ if (!settled.tenantId) {
7730
+ deps.cache.delete(key);
7731
+ }
7732
+ return settled;
7733
+ });
7734
+ deps.cache.set(key, pending);
7735
+ }
7736
+ return pending;
7737
+ }
7738
+ async function lookupRobotTenantId(target, deps) {
7739
+ const { baseUrl, accessToken, organization, tenantName } = target;
7740
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
7741
+ if (error) {
7742
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
7743
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
7744
+ }
7745
+ const rows = data?.tenants;
7746
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
7747
+ const wantedName = decodePathSegment(tenantName);
7748
+ const wanted = wantedName.toLowerCase();
7749
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
7750
+ if (!match) {
7751
+ const names = tenants.map((tenant) => tenant.name).join(", ");
7752
+ return {
7753
+ 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.`
7754
+ };
7755
+ }
7756
+ return { tenantId: match.id };
7757
+ }
7758
+ function tenantLookupFailureHint(tenantName, reason) {
7759
+ 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.`;
7760
+ }
7761
+ function decodePathSegment(segment) {
7762
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
7763
+ return error ? segment : decoded;
7764
+ }
7650
7765
  var isFileNotFoundError = (error) => {
7651
7766
  if (!(error instanceof Object))
7652
7767
  return false;
@@ -7915,9 +8030,6 @@ var getAuthContext = async (options = {}) => {
7915
8030
  identity: status.identity
7916
8031
  };
7917
8032
  };
7918
- // ../auth/src/tenantSelection.ts
7919
- var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7920
-
7921
8033
  // ../auth/src/selectTenant.ts
7922
8034
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
7923
8035
  var INVALID_TENANT_CODE = "INVALID_TENANT";
@@ -7925,6 +8037,6 @@ var TENANT_SELECTION_CODES = new Set([
7925
8037
  TENANT_SELECTION_REQUIRED_CODE,
7926
8038
  INVALID_TENANT_CODE
7927
8039
  ]);
7928
- export { catchError, carriedInstructions, extractErrorDetails, extractErrorMessage, RESULTS, Pagination, OutputFormatter, Command, processContext, instructionsFor, mimeTypeForFileName, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, getAuthContext };
8040
+ export { catchError, carriedInstructions, extractErrorDetails, extractErrorMessage, RESULTS, Pagination, OutputFormatter, Command, processContext, instructionsFor, mimeTypeForFileName, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, resolveSessionIdentity, getAuthContext };
7929
8041
 
7930
- //# debugId=928BF450BBD1FAB064756E2164756E21
8042
+ //# debugId=CA0AA111E72BB53D64756E2164756E21
package/dist/tool.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-w542x5bd.js";
5
- import"./tool-wqrb8d7k.js";
4
+ } from "./tool-6dab0khy.js";
5
+ import"./tool-ja7k1eac.js";
6
6
  import"./tool-1de529jm.js";
7
7
  export {
8
8
  metadata,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/eval-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.204.0-preview.254",
5
+ "version": "1.205.0-preview.256",
6
6
  "description": "Manage runtime evaluations, evaluators, eval sets, evaluations, and schedules.",
7
7
  "private": false,
8
8
  "repository": {
@@ -27,5 +27,5 @@
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
- "gitHead": "3ee79cdec05b36231a8da9e8de6bf0043585526a"
30
+ "gitHead": "63740c6cbb7ff282fa9118cc16a148eb030b245f"
31
31
  }