@uipath/agent-sdk 1.205.0-preview.284 → 1.206.0-preview.282

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.
Files changed (2) hide show
  1. package/dist/index.js +170 -113
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,19 +1,15 @@
1
1
  import { createRequire } from "node:module";
2
- var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true,
12
- configurable: true,
13
- set: __exportSetter.bind(all, name)
14
- });
2
+ var __esm = (fn, res, err) => () => {
3
+ if (fn)
4
+ try {
5
+ res = fn(fn = 0);
6
+ } catch (e) {
7
+ err = [e];
8
+ }
9
+ if (err)
10
+ throw err[0];
11
+ return res;
15
12
  };
16
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
13
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
18
14
 
19
15
  // ../auth/src/catch-error.ts
@@ -400,12 +396,6 @@ var init_is_in_ssh = __esm(() => {
400
396
  });
401
397
 
402
398
  // ../../node_modules/open/index.js
403
- var exports_open = {};
404
- __export(exports_open, {
405
- apps: () => apps,
406
- default: () => open_default,
407
- openApp: () => openApp
408
- });
409
399
  import process8 from "node:process";
410
400
  import path from "node:path";
411
401
  import { fileURLToPath } from "node:url";
@@ -639,21 +629,6 @@ var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEach
639
629
  ...options,
640
630
  target
641
631
  });
642
- }, openApp = (name, options) => {
643
- if (typeof name !== "string" && !Array.isArray(name)) {
644
- throw new TypeError("Expected a valid `name`");
645
- }
646
- const { arguments: appArguments = [] } = options ?? {};
647
- if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
648
- throw new TypeError("Expected `appArguments` as Array type");
649
- }
650
- return baseOpen({
651
- ...options,
652
- app: {
653
- name,
654
- arguments: appArguments
655
- }
656
- });
657
632
  }, apps, open_default;
658
633
  var init_open = __esm(() => {
659
634
  init_wsl_utils();
@@ -710,7 +685,7 @@ var init_open = __esm(() => {
710
685
  });
711
686
 
712
687
  // ../filesystem/src/node.ts
713
- import { randomUUID } from "node:crypto";
688
+ import { createHash, randomUUID } from "node:crypto";
714
689
  import { existsSync } from "node:fs";
715
690
  import * as fs6 from "node:fs/promises";
716
691
  import * as os2 from "node:os";
@@ -733,16 +708,16 @@ class NodeFileSystem {
733
708
  };
734
709
  utils = {
735
710
  open: async (url) => {
736
- const { default: open2 } = await Promise.resolve().then(() => (init_open(), exports_open));
737
- await open2(url);
711
+ await Promise.resolve().then(() => init_open());
712
+ await open_default(url);
738
713
  }
739
714
  };
740
- async readFile(path3, options) {
715
+ async readFile(path, options) {
741
716
  try {
742
717
  if (options) {
743
- return await fs6.readFile(path3, "utf-8");
718
+ return await fs6.readFile(path, "utf-8");
744
719
  }
745
- return await fs6.readFile(path3);
720
+ return await fs6.readFile(path);
746
721
  } catch (error) {
747
722
  if (this.isEnoent(error))
748
723
  return null;
@@ -772,6 +747,15 @@ class NodeFileSystem {
772
747
  throw error;
773
748
  }
774
749
  }
750
+ async readdirEntries(dirPath) {
751
+ try {
752
+ return await fs6.readdir(dirPath, { withFileTypes: true });
753
+ } catch (error) {
754
+ if (this.isEnoent(error))
755
+ return [];
756
+ throw error;
757
+ }
758
+ }
775
759
  async stat(filePath) {
776
760
  try {
777
761
  const stats = await fs6.stat(filePath);
@@ -779,7 +763,8 @@ class NodeFileSystem {
779
763
  isFile: () => stats.isFile(),
780
764
  isDirectory: () => stats.isDirectory(),
781
765
  size: stats.size,
782
- mtimeMs: stats.mtimeMs
766
+ mtimeMs: stats.mtimeMs,
767
+ ctimeMs: stats.ctimeMs
783
768
  };
784
769
  } catch (error) {
785
770
  if (this.isEnoent(error))
@@ -893,6 +878,42 @@ class NodeFileSystem {
893
878
  throw error;
894
879
  }
895
880
  }
881
+ async hashFile(filePath) {
882
+ let handle;
883
+ try {
884
+ handle = await fs6.open(filePath, "r");
885
+ } catch (error) {
886
+ if (this.isEnoent(error))
887
+ return null;
888
+ throw error;
889
+ }
890
+ const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
891
+ try {
892
+ const opened = await handle.stat();
893
+ const stats = {
894
+ isFile: () => opened.isFile(),
895
+ isDirectory: () => opened.isDirectory(),
896
+ size: opened.size,
897
+ mtimeMs: opened.mtimeMs,
898
+ ctimeMs: opened.ctimeMs
899
+ };
900
+ const hash = createHash("sha256");
901
+ let size = 0;
902
+ for (;; ) {
903
+ const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
904
+ if (bytesRead === 0)
905
+ break;
906
+ hash.update(buffer.subarray(0, bytesRead));
907
+ size += bytesRead;
908
+ }
909
+ return { sha256: hash.digest("hex"), size, stats };
910
+ } finally {
911
+ if (hashBuffers.length < HASH_BUFFERS_KEPT) {
912
+ hashBuffers.push(buffer);
913
+ }
914
+ await handle.close();
915
+ }
916
+ }
896
917
  async realpath(filePath) {
897
918
  try {
898
919
  return await fs6.realpath(filePath);
@@ -938,8 +959,11 @@ class NodeFileSystem {
938
959
  return typeof error === "object" && error !== null && "code" in error && error.code === code;
939
960
  }
940
961
  }
941
- var LOCK_HEARTBEAT_MS = 5000, LOCK_STALE_MS = 15000, LOCK_MAX_WAIT_MS = 20000, LOCK_MAX_HOLD_MS = 60000, LOCK_RETRY_MIN_MS = 100, LOCK_RETRY_JITTER_MS = 200;
942
- var init_node = () => {};
962
+ var LOCK_HEARTBEAT_MS = 5000, LOCK_STALE_MS = 15000, LOCK_MAX_WAIT_MS = 20000, LOCK_MAX_HOLD_MS = 60000, LOCK_RETRY_MIN_MS = 100, LOCK_RETRY_JITTER_MS = 200, HASH_CHUNK_BYTES, hashBuffers, HASH_BUFFERS_KEPT = 64;
963
+ var init_node = __esm(() => {
964
+ HASH_CHUNK_BYTES = 256 * 1024;
965
+ hashBuffers = [];
966
+ });
943
967
  // ../filesystem/src/index.ts
944
968
  var fsInstance, getFileSystem = () => fsInstance;
945
969
  var init_src = __esm(() => {
@@ -1016,6 +1040,21 @@ var CommandDimensions = {
1016
1040
  ProductArea: "ProductArea",
1017
1041
  Mode: "Mode"
1018
1042
  };
1043
+ var ProjectDimensions = {
1044
+ ProjectKey: "ProjectKey",
1045
+ ProjectType: "ProjectType",
1046
+ ProjectIdentityStatus: "ProjectIdentityStatus",
1047
+ SolutionKey: "SolutionKey",
1048
+ SolutionProjectKey: "SolutionProjectKey",
1049
+ SolutionIdentityStatus: "SolutionIdentityStatus",
1050
+ PreviousSolutionKey: "PreviousSolutionKey"
1051
+ };
1052
+ var GUID_KEY_DIMENSIONS = new Set([
1053
+ ProjectDimensions.ProjectKey,
1054
+ ProjectDimensions.SolutionKey,
1055
+ ProjectDimensions.SolutionProjectKey,
1056
+ ProjectDimensions.PreviousSolutionKey
1057
+ ]);
1019
1058
  var ShipDimensions = {
1020
1059
  ShipKind: "ShipKind",
1021
1060
  Target: "Target",
@@ -1083,6 +1122,7 @@ var RESERVED_DIMENSION_NAMES = new Set([
1083
1122
  ...Object.values(BaseDimensions),
1084
1123
  ...Object.values(CommandDimensions),
1085
1124
  ...Object.values(ShipDimensions),
1125
+ ...Object.values(ProjectDimensions),
1086
1126
  ...Object.values(ErrorDimensions),
1087
1127
  ...Object.values(AuthDimensions),
1088
1128
  ...Object.values(SkillsDimensions),
@@ -1108,7 +1148,8 @@ var CURATED_DIMENSIONS = new Set([
1108
1148
  BaseDimensions.SessionIdSource,
1109
1149
  BaseDimensions.SessionId,
1110
1150
  ...Object.values(CommandDimensions),
1111
- ...Object.values(ShipDimensions)
1151
+ ...Object.values(ShipDimensions),
1152
+ ...Object.values(ProjectDimensions)
1112
1153
  ]);
1113
1154
 
1114
1155
  // ../common/src/sdk-user-agent.ts
@@ -1499,7 +1540,7 @@ var package_default = {
1499
1540
  name: "@uipath/agent-sdk",
1500
1541
  author: "UiPath",
1501
1542
  license: "SEE LICENSE IN LICENSE.txt",
1502
- version: "1.205.0-preview.284",
1543
+ version: "1.206.0-preview.282",
1503
1544
  description: "SDK for the UiPath Agent Runtime API — evaluation execution and debug sessions.",
1504
1545
  repository: {
1505
1546
  type: "git",
@@ -4643,8 +4684,8 @@ function resolveAuthProfileFilePath(profile) {
4643
4684
  if (normalized === undefined) {
4644
4685
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
4645
4686
  }
4646
- const fs7 = getFileSystem();
4647
- return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
4687
+ const fs = getFileSystem();
4688
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
4648
4689
  }
4649
4690
  function getActiveAuthProfileFilePath() {
4650
4691
  const profile = getActiveAuthProfile();
@@ -4816,6 +4857,8 @@ var ENV_AUTH_VARS = {
4816
4857
  };
4817
4858
 
4818
4859
  class EnvAuthConfigError extends Error {
4860
+ errorCode = "configuration_error";
4861
+ retry = "RetryWillNotFix";
4819
4862
  constructor(message) {
4820
4863
  super(message);
4821
4864
  this.name = "EnvAuthConfigError";
@@ -4854,11 +4897,11 @@ var readAuthFromEnv = () => {
4854
4897
  if (!rawUrl) {
4855
4898
  throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a JWT (treating it as an opaque token, ` + `e.g. a Personal Access Token). Set ${OPAQUE_TOKEN_BASE_URL_VAR} to the ` + `UiPath base URL if this is a PAT, or fix the token if it was meant to ` + `be a JWT (parse error: ${parseErrorMessage}).`);
4856
4899
  }
4857
- const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
4900
+ const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
4858
4901
  return {
4859
4902
  loginStatus: "Logged in",
4860
4903
  accessToken,
4861
- baseUrl: baseUrl2,
4904
+ baseUrl,
4862
4905
  organizationName,
4863
4906
  organizationId,
4864
4907
  tenantName,
@@ -4910,9 +4953,9 @@ function breakerPathFor(authPath) {
4910
4953
  return `${authPath}${BREAKER_SUFFIX}`;
4911
4954
  }
4912
4955
  async function loadRefreshBreaker(authPath) {
4913
- const fs7 = getFileSystem();
4956
+ const fs = getFileSystem();
4914
4957
  try {
4915
- const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
4958
+ const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
4916
4959
  if (!content)
4917
4960
  return {};
4918
4961
  const parsed = JSON.parse(content);
@@ -4923,20 +4966,20 @@ async function loadRefreshBreaker(authPath) {
4923
4966
  }
4924
4967
  async function saveRefreshBreaker(authPath, state) {
4925
4968
  try {
4926
- const fs7 = getFileSystem();
4927
- const path3 = breakerPathFor(authPath);
4928
- await fs7.mkdir(fs7.path.dirname(path3));
4929
- const tempPath = `${path3}.tmp`;
4930
- await fs7.writeFile(tempPath, JSON.stringify(state));
4931
- await fs7.rename(tempPath, path3);
4969
+ const fs = getFileSystem();
4970
+ const path = breakerPathFor(authPath);
4971
+ await fs.mkdir(fs.path.dirname(path));
4972
+ const tempPath = `${path}.tmp`;
4973
+ await fs.writeFile(tempPath, JSON.stringify(state));
4974
+ await fs.rename(tempPath, path);
4932
4975
  } catch {}
4933
4976
  }
4934
4977
  async function clearRefreshBreaker(authPath) {
4935
- const fs7 = getFileSystem();
4936
- const path3 = breakerPathFor(authPath);
4978
+ const fs = getFileSystem();
4979
+ const path = breakerPathFor(authPath);
4937
4980
  try {
4938
- if (await fs7.exists(path3)) {
4939
- await fs7.rm(path3);
4981
+ if (await fs.exists(path)) {
4982
+ await fs.rm(path);
4940
4983
  }
4941
4984
  } catch {}
4942
4985
  }
@@ -4958,13 +5001,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
4958
5001
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
4959
5002
  var PIPE_NAME_MAX_LENGTH = 103;
4960
5003
  var getRobotIpcPipeNames = async () => {
4961
- const fs7 = getFileSystem();
4962
- const username = fs7.env.getenv("USER") ?? fs7.env.getenv("USERNAME");
5004
+ const fs = getFileSystem();
5005
+ const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
4963
5006
  if (!username) {
4964
5007
  throw new Error("Unable to determine current username");
4965
5008
  }
4966
- const tempPath = fs7.env.getenv("TMPDIR") ?? "/tmp/";
4967
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs7.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
5009
+ const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
5010
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
4968
5011
  };
4969
5012
  var defaultIsRobotIpcAvailable = async () => {
4970
5013
  if (process.platform === "win32") {
@@ -4974,20 +5017,20 @@ var defaultIsRobotIpcAvailable = async () => {
4974
5017
  if (pipeNamesError || !pipeNames) {
4975
5018
  return false;
4976
5019
  }
4977
- const fs7 = getFileSystem();
5020
+ const fs = getFileSystem();
4978
5021
  for (const pipeName of pipeNames) {
4979
- const [existsError, exists2] = await catchError(fs7.exists(pipeName));
4980
- if (!existsError && exists2 === true) {
5022
+ const [existsError, exists] = await catchError(fs.exists(pipeName));
5023
+ if (!existsError && exists === true) {
4981
5024
  return true;
4982
5025
  }
4983
5026
  }
4984
5027
  return false;
4985
5028
  };
4986
- var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
5029
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
4987
5030
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
4988
5031
  promise.then((value) => {
4989
5032
  clearTimeout(timer);
4990
- resolve2(value);
5033
+ resolve(value);
4991
5034
  }, (error) => {
4992
5035
  clearTimeout(timer);
4993
5036
  reject(error);
@@ -5160,9 +5203,12 @@ var refreshAccessToken = async ({
5160
5203
  body: tokenParams
5161
5204
  });
5162
5205
  const tokenData = await tokenResponse.json();
5163
- if (!tokenResponse.ok) {
5206
+ if (tokenResponse.status === 400 || tokenResponse.status === 401) {
5164
5207
  throw new TokenRefreshOAuthError;
5165
5208
  }
5209
+ if (!tokenResponse.ok) {
5210
+ throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
5211
+ }
5166
5212
  const newAccessToken = tokenData.access_token;
5167
5213
  const newRefreshToken = tokenData.refresh_token;
5168
5214
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
@@ -5196,9 +5242,9 @@ var errorCode = (err) => {
5196
5242
  }
5197
5243
  return "EUNKNOWN";
5198
5244
  };
5199
- var probeAsync = async (fs7, candidate) => {
5245
+ var probeAsync = async (fs, candidate) => {
5200
5246
  try {
5201
- const stats = await fs7.stat(candidate);
5247
+ const stats = await fs.stat(candidate);
5202
5248
  if (stats === null) {
5203
5249
  return { exists: false };
5204
5250
  }
@@ -5225,36 +5271,36 @@ var probeAsync = async (fs7, candidate) => {
5225
5271
  }
5226
5272
  };
5227
5273
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
5228
- const fs7 = getFileSystem();
5229
- if (fs7.path.isAbsolute(envFilePath)) {
5230
- const probe2 = await probeAsync(fs7, envFilePath);
5231
- return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
5274
+ const fs = getFileSystem();
5275
+ if (fs.path.isAbsolute(envFilePath)) {
5276
+ const probe = await probeAsync(fs, envFilePath);
5277
+ return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
5232
5278
  exists: false,
5233
5279
  absolutePath: envFilePath,
5234
5280
  source: "absolute",
5235
- ...probe2.unusable ? { unusable: probe2.unusable } : {}
5281
+ ...probe.unusable ? { unusable: probe.unusable } : {}
5236
5282
  };
5237
5283
  }
5238
- const cwd = opts?.cwd ?? fs7.env.cwd();
5284
+ const cwd = opts?.cwd ?? fs.env.cwd();
5239
5285
  let searchDir = cwd;
5240
5286
  while (true) {
5241
- const candidate = fs7.path.join(searchDir, envFilePath);
5242
- const probe2 = await probeAsync(fs7, candidate);
5243
- if (probe2.exists) {
5287
+ const candidate = fs.path.join(searchDir, envFilePath);
5288
+ const probe = await probeAsync(fs, candidate);
5289
+ if (probe.exists) {
5244
5290
  return {
5245
5291
  exists: true,
5246
5292
  absolutePath: candidate,
5247
5293
  source: searchDir === cwd ? "cwd" : "ancestor"
5248
5294
  };
5249
5295
  }
5250
- const parentDir = fs7.path.dirname(searchDir);
5296
+ const parentDir = fs.path.dirname(searchDir);
5251
5297
  if (parentDir === searchDir) {
5252
5298
  break;
5253
5299
  }
5254
5300
  searchDir = parentDir;
5255
5301
  }
5256
- const homePath = fs7.path.join(fs7.env.homedir(), envFilePath);
5257
- const probe = await probeAsync(fs7, homePath);
5302
+ const homePath = fs.path.join(fs.env.homedir(), envFilePath);
5303
+ const probe = await probeAsync(fs, homePath);
5258
5304
  if (probe.exists) {
5259
5305
  return { exists: true, absolutePath: homePath, source: "home" };
5260
5306
  }
@@ -5297,12 +5343,12 @@ var parseEnvContent = (content) => {
5297
5343
  return env;
5298
5344
  };
5299
5345
  var loadEnvFileAsync = async ({ envPath }) => {
5300
- const fs7 = getFileSystem();
5301
- const absolutePath = fs7.path.isAbsolute(envPath) ? envPath : fs7.path.join(fs7.env.cwd(), envPath);
5302
- if (!await fs7.exists(absolutePath)) {
5346
+ const fs = getFileSystem();
5347
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
5348
+ if (!await fs.exists(absolutePath)) {
5303
5349
  throw new Error(`Environment file not found: ${envPath}`);
5304
5350
  }
5305
- const content = await fs7.readFile(absolutePath, "utf-8");
5351
+ const content = await fs.readFile(absolutePath, "utf-8");
5306
5352
  if (content === null) {
5307
5353
  throw new Error(`Environment file not found: ${envPath}`);
5308
5354
  }
@@ -5313,10 +5359,10 @@ var saveEnvFileAsync = async ({
5313
5359
  data,
5314
5360
  merge = true
5315
5361
  }) => {
5316
- const fs7 = getFileSystem();
5317
- const absolutePath = fs7.path.isAbsolute(envPath) ? envPath : fs7.path.join(fs7.env.homedir(), envPath);
5362
+ const fs = getFileSystem();
5363
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
5318
5364
  let existingData = {};
5319
- if (merge && await fs7.exists(absolutePath)) {
5365
+ if (merge && await fs.exists(absolutePath)) {
5320
5366
  try {
5321
5367
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
5322
5368
  } catch {}
@@ -5334,11 +5380,11 @@ var saveEnvFileAsync = async ({
5334
5380
  const content = `${lines.join(`
5335
5381
  `)}
5336
5382
  `;
5337
- const dir = fs7.path.dirname(absolutePath);
5338
- await fs7.mkdir(dir);
5383
+ const dir = fs.path.dirname(absolutePath);
5384
+ await fs.mkdir(dir);
5339
5385
  const tempPath = `${absolutePath}.tmp`;
5340
- await fs7.writeFile(tempPath, content);
5341
- await fs7.rename(tempPath, absolutePath);
5386
+ await fs.writeFile(tempPath, content);
5387
+ await fs.rename(tempPath, absolutePath);
5342
5388
  };
5343
5389
 
5344
5390
  // ../auth/src/loginStatus.ts
@@ -5462,11 +5508,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
5462
5508
  return { credentials };
5463
5509
  }
5464
5510
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
5465
- const fs7 = getFs();
5466
- const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
5511
+ const fs = getFs();
5512
+ const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
5467
5513
  if (absolutePath === globalPath)
5468
5514
  return;
5469
- if (!await fs7.exists(globalPath))
5515
+ if (!await fs.exists(globalPath))
5470
5516
  return;
5471
5517
  try {
5472
5518
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -5883,26 +5929,38 @@ function errorMessage(error) {
5883
5929
  }
5884
5930
 
5885
5931
  // ../auth/src/authContext.ts
5932
+ class AuthContextUnavailableError extends Error {
5933
+ instructionContext;
5934
+ sessionHint;
5935
+ errorCode = "authentication_required";
5936
+ retry = "RetryWillNotFix";
5937
+ constructor(message, instructionContext = "auth", sessionHint) {
5938
+ super(message);
5939
+ this.instructionContext = instructionContext;
5940
+ this.sessionHint = sessionHint;
5941
+ this.name = "AuthContextUnavailableError";
5942
+ }
5943
+ }
5886
5944
  var getAuthContext = async (options = {}) => {
5887
5945
  const status = await getLoginStatusAsync({
5888
5946
  ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
5889
5947
  envFilePath: options.envFilePath
5890
5948
  });
5891
5949
  if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
5892
- throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
5950
+ throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
5893
5951
  }
5894
- const tenantName = options.tenant ?? status.tenantName;
5952
+ const tenantName = options.tenant || status.tenantName;
5895
5953
  if (options.requireOrganizationId && !status.organizationId) {
5896
- throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
5954
+ throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
5897
5955
  }
5898
5956
  if (options.requireOrganizationName && !status.organizationName) {
5899
- throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
5957
+ throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
5900
5958
  }
5901
5959
  if (options.requireTenantId && !status.tenantId) {
5902
- throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
5960
+ throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
5903
5961
  }
5904
- if (options.requireTenantName && tenantName === undefined) {
5905
- throw new Error("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.");
5962
+ if (options.requireTenantName && !tenantName) {
5963
+ throw new AuthContextUnavailableError("Tenant not provided and UIPATH_TENANT_NAME not set. Run 'uip login' to select a tenant, or use 'uip login tenant set <tenant>' to switch tenants.", "identity");
5906
5964
  }
5907
5965
  return {
5908
5966
  baseUrl: status.baseUrl,
@@ -5939,9 +5997,8 @@ async function createAgentRuntimeConfig(options) {
5939
5997
  requireOrganizationId: true,
5940
5998
  requireTenantId: true
5941
5999
  });
5942
- const organizationId = ctx.organizationId;
5943
- const tenantId = ctx.tenantId;
5944
- const basePath = `${ctx.baseUrl}/${organizationId}/${tenantId}/agentsruntime_`;
6000
+ const { organizationId, tenantId } = ctx;
6001
+ const basePath = `${ctx.baseUrl}/${encodeURIComponent(organizationId)}/${encodeURIComponent(tenantId)}/agentsruntime_`;
5945
6002
  const headers = addSdkUserAgentHeader({
5946
6003
  Authorization: `Bearer ${ctx.accessToken}`,
5947
6004
  "X-UiPath-Internal-TenantId": tenantId
@@ -5985,8 +6042,8 @@ async function getAvailableModels(options) {
5985
6042
  return raw.map((item) => LlmModelFromJSON(item));
5986
6043
  }
5987
6044
  async function getAvailableModelNames(options) {
5988
- const models2 = await getAvailableModels(options);
5989
- return models2.map((m) => m.name).filter((n) => n != null);
6045
+ const models = await getAvailableModels(options);
6046
+ return models.map((m) => m.name).filter((n) => n != null);
5990
6047
  }
5991
6048
  async function getGuardrailDefinitions(options) {
5992
6049
  const config = await createAgentRuntimeConfig(options);
@@ -6463,4 +6520,4 @@ export {
6463
6520
  querystring
6464
6521
  };
6465
6522
 
6466
- //# debugId=940D246086F31FAA64756E2164756E21
6523
+ //# debugId=59F8B548003362A264756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/agent-sdk",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.205.0-preview.284",
5
+ "version": "1.206.0-preview.282",
6
6
  "description": "SDK for the UiPath Agent Runtime API — evaluation execution and debug sessions.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -30,5 +30,5 @@
30
30
  "files": [
31
31
  "dist"
32
32
  ],
33
- "gitHead": "a4c5d26ade993d3215fc16f6982179053a8a5f07"
33
+ "gitHead": "9f18b69f2307838e3ce650b91de76cf6c9a23c13"
34
34
  }