@uipath/gov-tool 1.206.0-preview.303 → 1.207.0-preview.305

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/tool.js +376 -152
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -96,7 +96,7 @@ function settlePromiseLike(thenable) {
96
96
  }
97
97
 
98
98
  // ../../auth/src/constants.ts
99
- var UIPATH_HOME_DIR = ".uipath", AUTH_FILENAME = ".auth", DEFAULT_BASE_URL = "https://cloud.uipath.com", DEFAULT_AUTH_TIMEOUT_MS;
99
+ var UIPATH_HOME_DIR = ".uipath", AUTH_FILENAME = ".auth", AUTH_FILE_MODE = 384, AUTH_DIR_MODE = 448, DEFAULT_BASE_URL = "https://cloud.uipath.com", DEFAULT_AUTH_TIMEOUT_MS;
100
100
  var init_constants = __esm(() => {
101
101
  DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
102
102
  });
@@ -779,12 +779,26 @@ class NodeFileSystem {
779
779
  throw error;
780
780
  }
781
781
  }
782
- async writeFile(filePath, data) {
782
+ async writeFile(filePath, data, options) {
783
783
  const dir = path2.dirname(filePath);
784
784
  if (dir) {
785
785
  await fs6.mkdir(dir, { recursive: true });
786
786
  }
787
- await fs6.writeFile(filePath, data);
787
+ if (options?.mode === undefined || process.platform === "win32") {
788
+ if (options?.exclusive) {
789
+ await fs6.writeFile(filePath, data, { flag: "wx" });
790
+ } else {
791
+ await fs6.writeFile(filePath, data);
792
+ }
793
+ return;
794
+ }
795
+ const handle = await fs6.open(filePath, options.exclusive ? "wx" : "w", options.mode);
796
+ try {
797
+ await handle.chmod(options.mode);
798
+ await handle.writeFile(data);
799
+ } finally {
800
+ await handle.close();
801
+ }
788
802
  }
789
803
  async appendFile(filePath, data) {
790
804
  const dir = path2.dirname(filePath);
@@ -819,7 +833,8 @@ class NodeFileSystem {
819
833
  isDirectory: () => stats.isDirectory(),
820
834
  size: stats.size,
821
835
  mtimeMs: stats.mtimeMs,
822
- ctimeMs: stats.ctimeMs
836
+ ctimeMs: stats.ctimeMs,
837
+ mode: stats.mode
823
838
  };
824
839
  } catch (error) {
825
840
  if (this.isEnoent(error))
@@ -830,8 +845,13 @@ class NodeFileSystem {
830
845
  async exists(filePath) {
831
846
  return existsSync(filePath);
832
847
  }
833
- async mkdir(dirPath) {
834
- await fs6.mkdir(dirPath, { recursive: true });
848
+ async mkdir(dirPath, options) {
849
+ await fs6.mkdir(dirPath, { recursive: true, mode: options?.mode });
850
+ }
851
+ async chmod(targetPath, mode) {
852
+ if (process.platform === "win32")
853
+ return;
854
+ await fs6.chmod(targetPath, mode);
835
855
  }
836
856
  async acquireLock(lockPath) {
837
857
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -981,7 +1001,7 @@ class NodeFileSystem {
981
1001
  async getTempDir() {
982
1002
  return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
983
1003
  }
984
- async copyDirectory(sourcePath, destPath) {
1004
+ async copyDirectory(sourcePath, destPath, options) {
985
1005
  const sourceStats = await this.stat(sourcePath);
986
1006
  if (!sourceStats) {
987
1007
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -998,7 +1018,9 @@ class NodeFileSystem {
998
1018
  if (!entryStats)
999
1019
  continue;
1000
1020
  if (entryStats.isDirectory()) {
1001
- await this.copyDirectory(srcEntry, destEntry);
1021
+ if (options?.skipDirectoryNames?.includes(entry))
1022
+ continue;
1023
+ await this.copyDirectory(srcEntry, destEntry, options);
1002
1024
  } else if (entryStats.isFile()) {
1003
1025
  const content = await this.readFile(srcEntry);
1004
1026
  if (content !== null) {
@@ -7691,7 +7713,7 @@ var package_default = {
7691
7713
  name: "@uipath/gov-tool",
7692
7714
  author: "UiPath",
7693
7715
  license: "SEE LICENSE IN LICENSE.txt",
7694
- version: "1.206.0-preview.303",
7716
+ version: "1.207.0-preview.305",
7695
7717
  description: "Manage UiPath governance — AOps policies, Access policies, and compliance packs.",
7696
7718
  private: false,
7697
7719
  repository: {
@@ -7822,13 +7844,15 @@ var ProjectDimensions = {
7822
7844
  SolutionKey: "SolutionKey",
7823
7845
  SolutionProjectKey: "SolutionProjectKey",
7824
7846
  SolutionIdentityStatus: "SolutionIdentityStatus",
7825
- PreviousSolutionKey: "PreviousSolutionKey"
7847
+ PreviousSolutionKey: "PreviousSolutionKey",
7848
+ PreviousProjectKey: "PreviousProjectKey"
7826
7849
  };
7827
7850
  var GUID_KEY_DIMENSIONS = new Set([
7828
7851
  ProjectDimensions.ProjectKey,
7829
7852
  ProjectDimensions.SolutionKey,
7830
7853
  ProjectDimensions.SolutionProjectKey,
7831
- ProjectDimensions.PreviousSolutionKey
7854
+ ProjectDimensions.PreviousSolutionKey,
7855
+ ProjectDimensions.PreviousProjectKey
7832
7856
  ]);
7833
7857
  var ShipDimensions = {
7834
7858
  ShipKind: "ShipKind",
@@ -8276,7 +8300,7 @@ var package_default2 = {
8276
8300
  name: "@uipath/authz-sdk",
8277
8301
  author: "UiPath",
8278
8302
  license: "SEE LICENSE IN LICENSE.txt",
8279
- version: "1.206.0",
8303
+ version: "1.207.0",
8280
8304
  description: "SDK for the UiPath Authorization Service API.",
8281
8305
  repository: {
8282
8306
  type: "git",
@@ -8763,6 +8787,9 @@ class PolicyManagementApi extends BaseAPI {
8763
8787
  if (requestParameters["policyId"] != null) {
8764
8788
  queryParameters["policyId"] = requestParameters["policyId"];
8765
8789
  }
8790
+ if (requestParameters["softDelete"] != null) {
8791
+ queryParameters["softDelete"] = requestParameters["softDelete"];
8792
+ }
8766
8793
  const headerParameters = {};
8767
8794
  if (requestParameters["xUipathInternalAccountid"] != null) {
8768
8795
  headerParameters["x-uipath-internal-accountid"] = String(requestParameters["xUipathInternalAccountid"]);
@@ -9737,6 +9764,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
9737
9764
  }
9738
9765
  return parseEnvContent(content);
9739
9766
  };
9767
+ var findAuthHomeDir = (fs, dir) => {
9768
+ let current = dir;
9769
+ for (;; ) {
9770
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
9771
+ return current;
9772
+ const parent = fs.path.dirname(current);
9773
+ if (parent === current)
9774
+ return;
9775
+ current = parent;
9776
+ }
9777
+ };
9778
+ var TEMP_FILE_ATTEMPTS = 5;
9779
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
9780
+ var writeTempFile = async (fs, targetPath, content) => {
9781
+ for (let attempt = 1;; attempt++) {
9782
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
9783
+ try {
9784
+ await fs.writeFile(tempPath, content, {
9785
+ mode: AUTH_FILE_MODE,
9786
+ exclusive: true
9787
+ });
9788
+ return tempPath;
9789
+ } catch (error) {
9790
+ if (!isFileExists(error)) {
9791
+ await fs.rm(tempPath).catch(() => {});
9792
+ throw error;
9793
+ }
9794
+ if (attempt === TEMP_FILE_ATTEMPTS)
9795
+ throw error;
9796
+ }
9797
+ }
9798
+ };
9740
9799
  var saveEnvFileAsync = async ({
9741
9800
  envPath,
9742
9801
  data,
@@ -9764,10 +9823,18 @@ var saveEnvFileAsync = async ({
9764
9823
  `)}
9765
9824
  `;
9766
9825
  const dir = fs.path.dirname(absolutePath);
9767
- await fs.mkdir(dir);
9768
- const tempPath = `${absolutePath}.tmp`;
9769
- await fs.writeFile(tempPath, content);
9770
- await fs.rename(tempPath, absolutePath);
9826
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
9827
+ const authHomeDir = findAuthHomeDir(fs, dir);
9828
+ if (authHomeDir !== undefined) {
9829
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
9830
+ }
9831
+ const tempPath = await writeTempFile(fs, absolutePath, content);
9832
+ try {
9833
+ await fs.rename(tempPath, absolutePath);
9834
+ } catch (error) {
9835
+ await fs.rm(tempPath).catch(() => {});
9836
+ throw error;
9837
+ }
9771
9838
  };
9772
9839
 
9773
9840
  // ../../auth/src/loginStatus.ts
@@ -10373,6 +10440,8 @@ var TENANT_SELECTION_CODES = new Set([
10373
10440
  ]);
10374
10441
  // ../../auth/src/logout.ts
10375
10442
  init_src();
10443
+ // ../../auth/src/utils/lockedEnvFile.ts
10444
+ init_src();
10376
10445
  // ../../admin/authz-sdk/src/client-factory.ts
10377
10446
  async function resolveConfig(plane, options) {
10378
10447
  const auth = await getAuthContext({
@@ -10446,9 +10515,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
10446
10515
  }
10447
10516
  }
10448
10517
 
10449
- // ../../common/src/telemetry/pseudonymize.ts
10450
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
10451
- var PSEUDONYM_HEX_LENGTH = 32;
10518
+ // ../../common/src/sha256.ts
10452
10519
  var SHA256_K = new Uint32Array([
10453
10520
  1116352408,
10454
10521
  1899447441,
@@ -10528,7 +10595,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
10528
10595
  function rotr(value, bits) {
10529
10596
  return (value >>> bits | value << 32 - bits) >>> 0;
10530
10597
  }
10531
- function sha256Hex(input) {
10598
+ function sha256Words(input) {
10532
10599
  const bytes = new TextEncoder().encode(input);
10533
10600
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
10534
10601
  const buffer = new Uint8Array(paddedLength);
@@ -10584,12 +10651,19 @@ function sha256Hex(input) {
10584
10651
  state[6] = state[6] + g >>> 0;
10585
10652
  state[7] = state[7] + h >>> 0;
10586
10653
  }
10654
+ return state;
10655
+ }
10656
+ function sha256Hex(input) {
10587
10657
  let hex = "";
10588
- for (const word of state) {
10658
+ for (const word of sha256Words(input)) {
10589
10659
  hex += word.toString(16).padStart(8, "0");
10590
10660
  }
10591
10661
  return hex;
10592
10662
  }
10663
+
10664
+ // ../../common/src/telemetry/pseudonymize.ts
10665
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
10666
+ var PSEUDONYM_HEX_LENGTH = 32;
10593
10667
  function resolveSha256Hex() {
10594
10668
  try {
10595
10669
  const nodeCrypto = __require("node:crypto");
@@ -10955,13 +11029,25 @@ function settlePromiseLike2(thenable) {
10955
11029
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
10956
11030
  }
10957
11031
 
11032
+ // ../../common/src/result-types.ts
11033
+ var RESULTS = {
11034
+ Success: "Success",
11035
+ Failure: "Failure",
11036
+ ConfigError: "ConfigError",
11037
+ AuthenticationError: "AuthenticationError",
11038
+ ValidationError: "ValidationError",
11039
+ TimeoutError: "TimeoutError"
11040
+ };
11041
+
10958
11042
  // ../../common/src/error-codes.ts
10959
11043
  var CLI_ERROR_CODES = [
10960
11044
  "invalid_argument",
11045
+ "confirmation_required",
10961
11046
  "authentication_required",
10962
11047
  "permission_denied",
10963
11048
  "local_permission_denied",
10964
11049
  "not_found",
11050
+ "not_enabled",
10965
11051
  "rate_limited",
10966
11052
  "network_error",
10967
11053
  "timeout",
@@ -11000,6 +11086,12 @@ function carriedRetry(error) {
11000
11086
  const retry = error.retry;
11001
11087
  return isRetryHint(retry) ? retry : undefined;
11002
11088
  }
11089
+ function carriedResult(error) {
11090
+ if (!error || typeof error !== "object")
11091
+ return;
11092
+ const result = error.result;
11093
+ return typeof result === "string" && result !== RESULTS.Success && Object.values(RESULTS).includes(result) ? result : undefined;
11094
+ }
11003
11095
  function defaultRetryForErrorCode(errorCode) {
11004
11096
  switch (errorCode) {
11005
11097
  case "network_error":
@@ -11389,6 +11481,8 @@ async function extractErrorDetails(error, options) {
11389
11481
  }
11390
11482
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
11391
11483
  context.errorCode = parsedBody.errorCode;
11484
+ } else if (typeof parsedBody?.errorCode === "number") {
11485
+ context.errorCode = String(parsedBody.errorCode);
11392
11486
  } else if (parsedBody?.code && typeof parsedBody.code === "string") {
11393
11487
  context.errorCode = parsedBody.code;
11394
11488
  }
@@ -11449,15 +11543,17 @@ async function extractErrorMessage(error, options) {
11449
11543
  const { message } = await extractErrorDetails(error, options);
11450
11544
  return message;
11451
11545
  }
11452
- // ../../common/src/result-types.ts
11453
- var RESULTS = {
11454
- Success: "Success",
11455
- Failure: "Failure",
11456
- ConfigError: "ConfigError",
11457
- AuthenticationError: "AuthenticationError",
11458
- ValidationError: "ValidationError",
11459
- TimeoutError: "TimeoutError"
11460
- };
11546
+ // ../../common/src/classified-failure.ts
11547
+ function notSupportedFailure(operation, instructions, context) {
11548
+ return {
11549
+ Result: RESULTS.Failure,
11550
+ ErrorCode: "not_supported",
11551
+ Message: `${operation} isn't supported on the connected environment.`,
11552
+ Instructions: instructions,
11553
+ Retry: "RetryWillNotFix",
11554
+ ...context ? { Context: context } : {}
11555
+ };
11556
+ }
11461
11557
  // ../../../node_modules/commander/index.js
11462
11558
  var exports_commander = {};
11463
11559
  __exportCjs(exports_commander, {
@@ -11896,7 +11992,10 @@ var AUTH_ERROR_CODES = new Set([
11896
11992
  var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
11897
11993
  "local_permission_denied"
11898
11994
  ]);
11899
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
11995
+ var VALIDATION_ERROR_CODES = new Set([
11996
+ "invalid_argument",
11997
+ "confirmation_required"
11998
+ ]);
11900
11999
  var NETWORK_HTTP_ERROR_CODES = new Set([
11901
12000
  "network_error",
11902
12001
  "rate_limited",
@@ -12125,6 +12224,103 @@ var CommonTelemetryEvents = {
12125
12224
  // ../../common/src/telemetry/telemetry-init.ts
12126
12225
  init_src();
12127
12226
 
12227
+ // ../../common/src/telemetry/trace-context.ts
12228
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
12229
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
12230
+ function getProcessEnv() {
12231
+ return globalThis.process?.env;
12232
+ }
12233
+ function parseInboundTraceparent(value) {
12234
+ if (!value) {
12235
+ return;
12236
+ }
12237
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
12238
+ if (!match) {
12239
+ return;
12240
+ }
12241
+ const [, traceId, parentSpanId] = match;
12242
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
12243
+ return;
12244
+ }
12245
+ return { traceId, parentSpanId };
12246
+ }
12247
+ function getInboundTraceContext() {
12248
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
12249
+ }
12250
+
12251
+ // ../../common/src/telemetry/session-id.ts
12252
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
12253
+ var SESSION_ID_MAX_LENGTH = 64;
12254
+ var RANDOM_SESSION_ID_LENGTH = 32;
12255
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
12256
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
12257
+ var INHERITED_SESSION_SOURCES = [
12258
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
12259
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
12260
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
12261
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
12262
+ { envVar: "WT_SESSION", source: "terminal" }
12263
+ ];
12264
+ var telemetrySessionSlot = singleton("TelemetrySession");
12265
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
12266
+ function getProcessEnv2() {
12267
+ return globalThis.process?.env;
12268
+ }
12269
+ function normalizeSessionId(value) {
12270
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
12271
+ return;
12272
+ }
12273
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
12274
+ return cleaned || undefined;
12275
+ }
12276
+ function getConfiguredTelemetrySessionId() {
12277
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
12278
+ }
12279
+ function getInheritedSession(env) {
12280
+ for (const candidate of INHERITED_SESSION_SOURCES) {
12281
+ const handle = normalizeSessionId(env[candidate.envVar]);
12282
+ if (handle) {
12283
+ return { id: handle, source: candidate.source };
12284
+ }
12285
+ }
12286
+ return;
12287
+ }
12288
+ function generateRandomSession() {
12289
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
12290
+ crypto.getRandomValues(bytes);
12291
+ let hex = "";
12292
+ for (const byte of bytes) {
12293
+ hex += byte.toString(16).padStart(2, "0");
12294
+ }
12295
+ return { id: hex, source: "random" };
12296
+ }
12297
+ function resolveTelemetrySession() {
12298
+ const existing = telemetrySessionSlot.get();
12299
+ if (existing) {
12300
+ return existing;
12301
+ }
12302
+ const declaredHandle = getConfiguredTelemetrySessionId();
12303
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
12304
+ telemetrySessionSlot.set(resolved);
12305
+ return resolved;
12306
+ }
12307
+ function getTelemetrySessionId() {
12308
+ return resolveTelemetrySession().id;
12309
+ }
12310
+ function getTelemetrySessionSource() {
12311
+ return resolveTelemetrySession().source;
12312
+ }
12313
+ function getTelemetryOperationId() {
12314
+ const existing = telemetryOperationIdSlot.get();
12315
+ if (existing) {
12316
+ return existing;
12317
+ }
12318
+ const inboundTraceId = getInboundTraceContext()?.traceId;
12319
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
12320
+ telemetryOperationIdSlot.set(generated);
12321
+ return generated;
12322
+ }
12323
+
12128
12324
  // ../../common/src/registry.ts
12129
12325
  import { execFileSync as execFileSync2 } from "node:child_process";
12130
12326
  function readRegistryValue(keyPath, valueName) {
@@ -12346,102 +12542,6 @@ class NodeContextStorage {
12346
12542
  return this.storage.getStore();
12347
12543
  }
12348
12544
  }
12349
- // ../../common/src/telemetry/trace-context.ts
12350
- var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
12351
- var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
12352
- function getProcessEnv() {
12353
- return globalThis.process?.env;
12354
- }
12355
- function parseInboundTraceparent(value) {
12356
- if (!value) {
12357
- return;
12358
- }
12359
- const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
12360
- if (!match) {
12361
- return;
12362
- }
12363
- const [, traceId, parentSpanId] = match;
12364
- if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
12365
- return;
12366
- }
12367
- return { traceId, parentSpanId };
12368
- }
12369
- function getInboundTraceContext() {
12370
- return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
12371
- }
12372
-
12373
- // ../../common/src/telemetry/session-id.ts
12374
- var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
12375
- var SESSION_ID_MAX_LENGTH = 64;
12376
- var RANDOM_SESSION_ID_LENGTH = 32;
12377
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
12378
- var CONTROL_CHARACTERS = /\p{Cc}/gu;
12379
- var INHERITED_SESSION_SOURCES = [
12380
- { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
12381
- { envVar: "CODEX_THREAD_ID", source: "codex" },
12382
- { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
12383
- { envVar: "TERM_SESSION_ID", source: "terminal" },
12384
- { envVar: "WT_SESSION", source: "terminal" }
12385
- ];
12386
- var telemetrySessionSlot = singleton("TelemetrySession");
12387
- var telemetryOperationIdSlot = singleton("TelemetryOperationId");
12388
- function getProcessEnv2() {
12389
- return globalThis.process?.env;
12390
- }
12391
- function normalizeSessionId(value) {
12392
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
12393
- return;
12394
- }
12395
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
12396
- return cleaned || undefined;
12397
- }
12398
- function getConfiguredTelemetrySessionId() {
12399
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
12400
- }
12401
- function getInheritedSession(env) {
12402
- for (const candidate of INHERITED_SESSION_SOURCES) {
12403
- const handle = normalizeSessionId(env[candidate.envVar]);
12404
- if (handle) {
12405
- return { id: handle, source: candidate.source };
12406
- }
12407
- }
12408
- return;
12409
- }
12410
- function generateRandomSession() {
12411
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
12412
- crypto.getRandomValues(bytes);
12413
- let hex = "";
12414
- for (const byte of bytes) {
12415
- hex += byte.toString(16).padStart(2, "0");
12416
- }
12417
- return { id: hex, source: "random" };
12418
- }
12419
- function resolveTelemetrySession() {
12420
- const existing = telemetrySessionSlot.get();
12421
- if (existing) {
12422
- return existing;
12423
- }
12424
- const declaredHandle = getConfiguredTelemetrySessionId();
12425
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
12426
- telemetrySessionSlot.set(resolved);
12427
- return resolved;
12428
- }
12429
- function getTelemetrySessionId() {
12430
- return resolveTelemetrySession().id;
12431
- }
12432
- function getTelemetrySessionSource() {
12433
- return resolveTelemetrySession().source;
12434
- }
12435
- function getTelemetryOperationId() {
12436
- const existing = telemetryOperationIdSlot.get();
12437
- if (existing) {
12438
- return existing;
12439
- }
12440
- const inboundTraceId = getInboundTraceContext()?.traceId;
12441
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
12442
- telemetryOperationIdSlot.set(generated);
12443
- return generated;
12444
- }
12445
12545
  // ../../common/src/telemetry/span-clock.ts
12446
12546
  function startSpanClock() {
12447
12547
  const started = performance.now();
@@ -12647,6 +12747,7 @@ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
12647
12747
  // ../../common/src/telemetry/telemetry-init.ts
12648
12748
  var telemetryInstanceSlot = singleton("TelemetryService");
12649
12749
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
12750
+ var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
12650
12751
  function getGlobalTelemetryInstance() {
12651
12752
  const existing = telemetryInstanceSlot.get();
12652
12753
  if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
@@ -12830,7 +12931,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
12830
12931
  const pagedRows = extractPagedRows(data.Data);
12831
12932
  const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
12832
12933
  items.forEach((item) => {
12833
- const values = Object.values(item).map((v) => v ?? "").join("\t");
12934
+ const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
12834
12935
  logFn(values);
12835
12936
  });
12836
12937
  } else {
@@ -12845,7 +12946,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
12845
12946
  default: {
12846
12947
  const hasData = "Data" in data && data.Data != null;
12847
12948
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
12848
- const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
12949
+ const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
12950
+ const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
12849
12951
  if (hasData && !(rows !== null && rows.length === 0)) {
12850
12952
  const logValue = data.Log;
12851
12953
  if (rows !== null) {
@@ -12902,6 +13004,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
12902
13004
  function isPlainObjectArray(value) {
12903
13005
  return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
12904
13006
  }
13007
+ function isPrimitiveArray(value) {
13008
+ return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
13009
+ }
12905
13010
  function isNonEmptyPlainObject(value) {
12906
13011
  return isPlainRecord(value) && Object.keys(value).length > 0;
12907
13012
  }
@@ -13248,12 +13353,12 @@ class FilterEvaluationError extends Error {
13248
13353
  instructions;
13249
13354
  retry = "RetryWillNotFix";
13250
13355
  result = RESULTS.ValidationError;
13251
- constructor(filter, cause) {
13356
+ constructor(filter, cause, hint) {
13252
13357
  const underlying = cause instanceof Error ? cause.message : String(cause);
13253
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
13358
+ super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
13254
13359
  this.name = "FilterEvaluationError";
13255
13360
  this.filter = filter;
13256
- this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
13361
+ this.instructions = (hint ? `${hint.instructions} ` : "") + `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
13257
13362
  }
13258
13363
  }
13259
13364
 
@@ -13375,6 +13480,93 @@ function nameList(names, cap = 12) {
13375
13480
  const rest = names.length - shown.length;
13376
13481
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
13377
13482
  }
13483
+ function notFieldsOn(names, scope) {
13484
+ return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
13485
+ }
13486
+ function failingFieldRead(ast, isList, fn, argIndex) {
13487
+ const [left, right, condition] = ast.children ?? [];
13488
+ let scopes = [];
13489
+ if (!isList) {
13490
+ scopes = [ast];
13491
+ } else if (ast.type === "FilterProjection" && left?.type === "Identity") {
13492
+ scopes = [condition, right];
13493
+ } else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
13494
+ scopes = [right];
13495
+ }
13496
+ const reads = new Set;
13497
+ let tracked = 0;
13498
+ const visit = (node) => {
13499
+ if (!node)
13500
+ return;
13501
+ switch (node.type) {
13502
+ case "Function": {
13503
+ const arg = node.children?.[argIndex - 1];
13504
+ if (node.name === fn && arg?.type === "Field" && arg.name) {
13505
+ reads.add(arg.name);
13506
+ tracked++;
13507
+ }
13508
+ node.children?.forEach(visit);
13509
+ return;
13510
+ }
13511
+ case "AndExpression":
13512
+ case "OrExpression":
13513
+ case "NotExpression":
13514
+ case "Comparator":
13515
+ case "MultiSelectList":
13516
+ case "MultiSelectHash":
13517
+ node.children?.forEach(visit);
13518
+ return;
13519
+ case "KeyValuePair":
13520
+ visit(node.value);
13521
+ return;
13522
+ }
13523
+ };
13524
+ scopes.forEach(visit);
13525
+ const calls = (node) => {
13526
+ if (node === null || typeof node !== "object")
13527
+ return 0;
13528
+ const own = node.type === "Function" && node.name === fn ? 1 : 0;
13529
+ const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
13530
+ return own + next.reduce((sum, child) => sum + calls(child), 0);
13531
+ };
13532
+ return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
13533
+ }
13534
+ function fieldExpression(name) {
13535
+ return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
13536
+ }
13537
+ function evaluationHint(codec, filter, data, cause) {
13538
+ const underlying = cause instanceof Error ? cause.message : String(cause);
13539
+ const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
13540
+ if (!failure)
13541
+ return;
13542
+ const [, fn, position, expected] = failure;
13543
+ const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
13544
+ if (name === undefined)
13545
+ return;
13546
+ const present = availableFields(data);
13547
+ if (present.length === 0)
13548
+ return;
13549
+ const scope = `${countRecords(data)} record(s)`;
13550
+ if (!present.includes(name)) {
13551
+ return {
13552
+ detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
13553
+ instructions: "Use a field the records have; names are case-sensitive."
13554
+ };
13555
+ }
13556
+ const records = Array.isArray(data) ? data : [data];
13557
+ const unset = records.filter((r) => r?.[name] == null).length;
13558
+ const field = fieldExpression(name);
13559
+ let fallback;
13560
+ if (expected.split(",").includes("string")) {
13561
+ fallback = "''";
13562
+ } else if (expected.split(",").includes("array")) {
13563
+ fallback = "`[]`";
13564
+ }
13565
+ return {
13566
+ detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
13567
+ instructions: fallback ? `Give it a default where ${fn}() reads it, e.g. \`${field} || ${fallback}\`.` : `Filter out the records where \`${name}\` is null before ${fn}() reads it.`
13568
+ };
13569
+ }
13378
13570
  function buildFilterWarning(filter, data, outcome) {
13379
13571
  const present = availableFields(data);
13380
13572
  const refs = referencedFields(filter);
@@ -13382,7 +13574,7 @@ function buildFilterWarning(filter, data, outcome) {
13382
13574
  const unchecked = refs.nested.filter((name) => !present.includes(name));
13383
13575
  const count = countRecords(data);
13384
13576
  const scope = `${count} record(s)`;
13385
- const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
13577
+ const isNotAField = (names) => notFieldsOn(names, scope);
13386
13578
  const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
13387
13579
  const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
13388
13580
  let detail;
@@ -13433,7 +13625,8 @@ function applyFilter(data, filter, onWarning) {
13433
13625
  try {
13434
13626
  result = codec.search(data, filter);
13435
13627
  } catch (err) {
13436
- throw new FilterEvaluationError(filter, err);
13628
+ const [, hint] = catchError2(() => evaluationHint(codec, filter, data, err));
13629
+ throw new FilterEvaluationError(filter, err, hint);
13437
13630
  }
13438
13631
  const inputCount = countRecords(data);
13439
13632
  const warn = (outcome) => {
@@ -14324,7 +14517,7 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
14324
14517
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
14325
14518
  const typed = error;
14326
14519
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
14327
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
14520
+ const customResult = carriedResult(error);
14328
14521
  const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
14329
14522
  const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
14330
14523
  const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
@@ -14703,6 +14896,8 @@ var FAILURE_STATUSES = new Set([
14703
14896
  "canceled",
14704
14897
  "stopped"
14705
14898
  ]);
14899
+ // ../../common/src/relayed-output.ts
14900
+ var RELAYED_OUTPUT_SYMBOL = Symbol.for("@uipath/common/relayed-output");
14706
14901
  // ../../common/src/screen-logger.ts
14707
14902
  var ScreenLogger;
14708
14903
  ((ScreenLogger) => {
@@ -15384,7 +15579,7 @@ var package_default3 = {
15384
15579
  name: "@uipath/aops-policy-sdk",
15385
15580
  author: "UiPath",
15386
15581
  license: "SEE LICENSE IN LICENSE.txt",
15387
- version: "1.206.0-preview.303",
15582
+ version: "1.207.0-preview.305",
15388
15583
  description: "SDK for the UiPath AOps Governance API — policy management and deployment.",
15389
15584
  repository: {
15390
15585
  type: "git",
@@ -23329,7 +23524,7 @@ var package_default4 = {
23329
23524
  name: "@uipath/compliance-packs-sdk",
23330
23525
  author: "UiPath",
23331
23526
  license: "SEE LICENSE IN LICENSE.txt",
23332
- version: "1.206.0",
23527
+ version: "1.207.0",
23333
23528
  description: "SDK for the UiPath Governance Server Compliance Packs API.",
23334
23529
  repository: {
23335
23530
  type: "git",
@@ -24077,8 +24272,38 @@ async function createApiClient3(ApiClass, options) {
24077
24272
  const config = await createCompliancePacksConfig(options);
24078
24273
  return new ApiClass(config);
24079
24274
  }
24275
+ // src/commands/compliance-pack/preview-gate.ts
24276
+ var PREVIEW_GATE_PATTERN = /Agentic Governance is a preview feature/i;
24277
+ var HTML_INSTEAD_OF_JSON_PATTERN = /Unexpected token '<', "<!DOCTYPE /i;
24278
+ var HTML_RESPONSE_MESSAGE2 = "The governance service path answered with an HTML page.";
24279
+ function rejectHtmlResponse(response) {
24280
+ if (/text\/html/i.test(response.headers.get("content-type") ?? "")) {
24281
+ throw new Error(HTML_RESPONSE_MESSAGE2);
24282
+ }
24283
+ }
24284
+ var PREVIEW_INSTRUCTIONS = "Agentic Governance is a preview feature and is not enabled for this organization. Contact your UiPath representative to request access.";
24285
+ var NOT_DEPLOYED_INSTRUCTIONS = "This environment does not serve the Agentic Governance service. It is available on Automation Cloud only.";
24286
+ function agenticGovernanceUnavailableFailure(details) {
24287
+ if (details.context?.httpStatus === 403 && PREVIEW_GATE_PATTERN.test(details.details)) {
24288
+ return notSupportedFailure("Agentic Governance", PREVIEW_INSTRUCTIONS, details.context);
24289
+ }
24290
+ if (HTML_INSTEAD_OF_JSON_PATTERN.test(details.details) || details.details === HTML_RESPONSE_MESSAGE2) {
24291
+ return notSupportedFailure("Agentic Governance", NOT_DEPLOYED_INSTRUCTIONS, details.context);
24292
+ }
24293
+ return;
24294
+ }
24295
+
24080
24296
  // src/commands/compliance-pack/catalog.ts
24081
24297
  var LOGIN_INSTRUCTIONS6 = "Ensure you are logged in with 'uip login' and have access to the compliance packs service.";
24298
+ async function reportFailure(error, instructions) {
24299
+ const details = await extractErrorDetails(error);
24300
+ OutputFormatter.error(agenticGovernanceUnavailableFailure(details) ?? {
24301
+ Result: RESULTS.Failure,
24302
+ Message: details.message,
24303
+ Instructions: instructions
24304
+ });
24305
+ processContext.exit(1);
24306
+ }
24082
24307
  var CATALOG_LIST_EXAMPLES = [
24083
24308
  {
24084
24309
  Description: "List all compliance packs available in the catalog",
@@ -24166,12 +24391,7 @@ var registerCatalogCommands = (compliancePacks) => {
24166
24391
  return await api.listCatalog();
24167
24392
  })());
24168
24393
  if (error) {
24169
- OutputFormatter.error({
24170
- Result: RESULTS.Failure,
24171
- Message: await extractErrorMessage(error),
24172
- Instructions: LOGIN_INSTRUCTIONS6
24173
- });
24174
- processContext.exit(1);
24394
+ await reportFailure(error, LOGIN_INSTRUCTIONS6);
24175
24395
  return;
24176
24396
  }
24177
24397
  OutputFormatter.success({
@@ -24193,12 +24413,7 @@ var registerCatalogCommands = (compliancePacks) => {
24193
24413
  return await api.getCatalogPack({ packId });
24194
24414
  })());
24195
24415
  if (error) {
24196
- OutputFormatter.error({
24197
- Result: RESULTS.Failure,
24198
- Message: await extractErrorMessage(error),
24199
- Instructions: "Check the pack identifier. Use 'uip gov compliance-packs catalog list' to see available pack IDs."
24200
- });
24201
- processContext.exit(1);
24416
+ await reportFailure(error, "Check the pack identifier. Use 'uip gov compliance-packs catalog list' to see available pack IDs.");
24202
24417
  return;
24203
24418
  }
24204
24419
  OutputFormatter.success({
@@ -24217,6 +24432,12 @@ async function runCommand(operation, successCode, errorInstructions, conflictIns
24217
24432
  const [error, result] = await catchError2(operation());
24218
24433
  if (error) {
24219
24434
  const details = await extractErrorDetails(error);
24435
+ const unavailable = agenticGovernanceUnavailableFailure(details);
24436
+ if (unavailable) {
24437
+ OutputFormatter.error(unavailable);
24438
+ processContext.exit(1);
24439
+ return;
24440
+ }
24220
24441
  const isConflict = details.context?.httpStatus === 409;
24221
24442
  OutputFormatter.error({
24222
24443
  Result: RESULTS.Failure,
@@ -24458,11 +24679,14 @@ var registerStateCommands = (compliancePacks) => {
24458
24679
  "organization"
24459
24680
  ])).argument("<target-id>", TARGET_ID_DESCRIPTION).argument("<pack-id>", PACK_ID_DESCRIPTION).option("--login-validity <minutes>", "Override the interactive-login token lifetime for this call. Rarely needed.", (v) => Number.parseInt(v, 10)).examples(STATE_DISABLE_EXAMPLES).trackedAction(processContext, async (scopeLevel, scopeTargetId, packId, options) => runCommand(() => createApiClient3(OrchestrationApi, {
24460
24681
  loginValidity: options.loginValidity
24461
- }).then((api) => api.disablePack({
24682
+ }).then((api) => api.disablePackRaw({
24462
24683
  scopeLevel,
24463
24684
  scopeTargetId,
24464
24685
  packId
24465
- })).then(() => ({ Status: "Disabled" })), "CompliancePacksStateDisable", "Check that a state row exists for this scope and pack. Use 'state list' to see recorded states."));
24686
+ })).then(({ raw }) => {
24687
+ rejectHtmlResponse(raw);
24688
+ return { Status: "Disabled" };
24689
+ }), "CompliancePacksStateDisable", "Check that a state row exists for this scope and pack. Use 'state list' to see recorded states."));
24466
24690
  state.command("restore").description([
24467
24691
  "Restore an active compliance pack to its suggested state at a given scope.",
24468
24692
  "Resets the pack's Aops policies to the bundle's suggested values: in-place config",
@@ -24537,4 +24761,4 @@ export {
24537
24761
  registerCommands
24538
24762
  };
24539
24763
 
24540
- //# debugId=588628E1FE96A8DD64756E2164756E21
24764
+ //# debugId=E17DD355E8E124F564756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/gov-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.303",
5
+ "version": "1.207.0-preview.305",
6
6
  "description": "Manage UiPath governance — AOps policies, Access policies, and compliance packs.",
7
7
  "private": false,
8
8
  "repository": {
@@ -24,5 +24,5 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
- "gitHead": "7d17b8a3c1a50892d42c9302087abc8307b04409"
27
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
28
28
  }