@uipath/traces-tool 1.205.0-preview.281 → 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.
@@ -1,8 +1,9 @@
1
1
  import {
2
+ __toESM,
2
3
  __commonJS,
3
- __require,
4
- __toESM
5
- } from "./tool-1de529jm.js";
4
+ __exportCjs,
5
+ __require
6
+ } from "./tool-epsr41wx.js";
6
7
 
7
8
  // ../../node_modules/commander/lib/error.js
8
9
  var require_error = __commonJS(function(exports) {
@@ -124,7 +125,7 @@ var require_help = __commonJS(function(exports) {
124
125
  this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
125
126
  }
126
127
  visibleCommands(cmd) {
127
- const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
128
+ const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
128
129
  const helpCommand = cmd._getHelpCommand();
129
130
  if (helpCommand && !helpCommand._hidden) {
130
131
  visibleCommands.push(helpCommand);
@@ -604,8 +605,8 @@ var require_option = __commonJS(function(exports) {
604
605
  }
605
606
  }
606
607
  function camelcase(str) {
607
- return str.split("-").reduce((str2, word) => {
608
- return str2 + word[0].toUpperCase() + word.slice(1);
608
+ return str.split("-").reduce((str, word) => {
609
+ return str + word[0].toUpperCase() + word.slice(1);
609
610
  });
610
611
  }
611
612
  function splitOptionFlags(flags) {
@@ -726,8 +727,8 @@ var require_suggestSimilar = __commonJS(function(exports) {
726
727
  var require_command = __commonJS(function(exports) {
727
728
  var EventEmitter = __require("node:events").EventEmitter;
728
729
  var childProcess = __require("node:child_process");
729
- var path2 = __require("node:path");
730
- var fs2 = __require("node:fs");
730
+ var path = __require("node:path");
731
+ var fs = __require("node:fs");
731
732
  var process2 = __require("node:process");
732
733
  var { Argument, humanReadableArgName } = require_argument();
733
734
  var { CommanderError } = require_error();
@@ -1176,44 +1177,44 @@ Expecting one of '${allowedValues.join("', '")}'`);
1176
1177
  });
1177
1178
  return source;
1178
1179
  }
1179
- _prepareUserArgs(argv, parseOptions) {
1180
- if (argv !== undefined && !Array.isArray(argv)) {
1180
+ _prepareUserArgs(argv2, parseOptions) {
1181
+ if (argv2 !== undefined && !Array.isArray(argv2)) {
1181
1182
  throw new Error("first parameter to parse must be array or undefined");
1182
1183
  }
1183
1184
  parseOptions = parseOptions || {};
1184
- if (argv === undefined && parseOptions.from === undefined) {
1185
+ if (argv2 === undefined && parseOptions.from === undefined) {
1185
1186
  if (process2.versions?.electron) {
1186
1187
  parseOptions.from = "electron";
1187
1188
  }
1188
- const execArgv = process2.execArgv ?? [];
1189
- if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1189
+ const execArgv2 = process2.execArgv ?? [];
1190
+ if (execArgv2.includes("-e") || execArgv2.includes("--eval") || execArgv2.includes("-p") || execArgv2.includes("--print")) {
1190
1191
  parseOptions.from = "eval";
1191
1192
  }
1192
1193
  }
1193
- if (argv === undefined) {
1194
- argv = process2.argv;
1194
+ if (argv2 === undefined) {
1195
+ argv2 = process2.argv;
1195
1196
  }
1196
- this.rawArgs = argv.slice();
1197
+ this.rawArgs = argv2.slice();
1197
1198
  let userArgs;
1198
1199
  switch (parseOptions.from) {
1199
1200
  case undefined:
1200
1201
  case "node":
1201
- this._scriptPath = argv[1];
1202
- userArgs = argv.slice(2);
1202
+ this._scriptPath = argv2[1];
1203
+ userArgs = argv2.slice(2);
1203
1204
  break;
1204
1205
  case "electron":
1205
1206
  if (process2.defaultApp) {
1206
- this._scriptPath = argv[1];
1207
- userArgs = argv.slice(2);
1207
+ this._scriptPath = argv2[1];
1208
+ userArgs = argv2.slice(2);
1208
1209
  } else {
1209
- userArgs = argv.slice(1);
1210
+ userArgs = argv2.slice(1);
1210
1211
  }
1211
1212
  break;
1212
1213
  case "user":
1213
- userArgs = argv.slice(0);
1214
+ userArgs = argv2.slice(0);
1214
1215
  break;
1215
1216
  case "eval":
1216
- userArgs = argv.slice(1);
1217
+ userArgs = argv2.slice(1);
1217
1218
  break;
1218
1219
  default:
1219
1220
  throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
@@ -1262,7 +1263,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1262
1263
  this.processedArgs = [];
1263
1264
  }
1264
1265
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
1265
- if (fs2.existsSync(executableFile))
1266
+ if (fs.existsSync(executableFile))
1266
1267
  return;
1267
1268
  const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
1268
1269
  const executableMissing = `'${executableFile}' does not exist
@@ -1276,12 +1277,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
1276
1277
  let launchWithNode = false;
1277
1278
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1278
1279
  function findFile(baseDir, baseName) {
1279
- const localBin = path2.resolve(baseDir, baseName);
1280
- if (fs2.existsSync(localBin))
1280
+ const localBin = path.resolve(baseDir, baseName);
1281
+ if (fs.existsSync(localBin))
1281
1282
  return localBin;
1282
- if (sourceExt.includes(path2.extname(baseName)))
1283
+ if (sourceExt.includes(path.extname(baseName)))
1283
1284
  return;
1284
- const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
1285
+ const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
1285
1286
  if (foundExt)
1286
1287
  return `${localBin}${foundExt}`;
1287
1288
  return;
@@ -1293,23 +1294,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1293
1294
  if (this._scriptPath) {
1294
1295
  let resolvedScriptPath;
1295
1296
  try {
1296
- resolvedScriptPath = fs2.realpathSync(this._scriptPath);
1297
+ resolvedScriptPath = fs.realpathSync(this._scriptPath);
1297
1298
  } catch {
1298
1299
  resolvedScriptPath = this._scriptPath;
1299
1300
  }
1300
- executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
1301
+ executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
1301
1302
  }
1302
1303
  if (executableDir) {
1303
1304
  let localFile = findFile(executableDir, executableFile);
1304
1305
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1305
- const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
1306
+ const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
1306
1307
  if (legacyName !== this._name) {
1307
1308
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1308
1309
  }
1309
1310
  }
1310
1311
  executableFile = localFile || executableFile;
1311
1312
  }
1312
- launchWithNode = sourceExt.includes(path2.extname(executableFile));
1313
+ launchWithNode = sourceExt.includes(path.extname(executableFile));
1313
1314
  let proc;
1314
1315
  if (process2.platform !== "win32") {
1315
1316
  if (launchWithNode) {
@@ -1736,18 +1737,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
1736
1737
  this.error(message, { code: "commander.missingMandatoryOptionValue" });
1737
1738
  }
1738
1739
  _conflictingOption(option, conflictingOption) {
1739
- const findBestOptionFromValue = (option2) => {
1740
- const optionKey = option2.attributeName();
1740
+ const findBestOptionFromValue = (option) => {
1741
+ const optionKey = option.attributeName();
1741
1742
  const optionValue = this.getOptionValue(optionKey);
1742
1743
  const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
1743
1744
  const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
1744
1745
  if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
1745
1746
  return negativeOption;
1746
1747
  }
1747
- return positiveOption || option2;
1748
+ return positiveOption || option;
1748
1749
  };
1749
- const getErrorMessage = (option2) => {
1750
- const bestOption = findBestOptionFromValue(option2);
1750
+ const getErrorMessage = (option) => {
1751
+ const bestOption = findBestOptionFromValue(option);
1751
1752
  const optionKey = bestOption.attributeName();
1752
1753
  const source = this.getOptionValueSource(optionKey);
1753
1754
  if (source === "env") {
@@ -1898,13 +1899,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
1898
1899
  cmd.helpGroup(this._defaultCommandGroup);
1899
1900
  }
1900
1901
  nameFromFilename(filename) {
1901
- this._name = path2.basename(filename, path2.extname(filename));
1902
+ this._name = path.basename(filename, path.extname(filename));
1902
1903
  return this;
1903
1904
  }
1904
- executableDir(path3) {
1905
- if (path3 === undefined)
1905
+ executableDir(path) {
1906
+ if (path === undefined)
1906
1907
  return this._executableDir;
1907
- this._executableDir = path3;
1908
+ this._executableDir = path;
1908
1909
  return this;
1909
1910
  }
1910
1911
  helpInformation(contextOptions) {
@@ -2001,11 +2002,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2001
2002
  }
2002
2003
  help(contextOptions) {
2003
2004
  this.outputHelp(contextOptions);
2004
- let exitCode = Number(process2.exitCode ?? 0);
2005
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2006
- exitCode = 1;
2005
+ let exitCode2 = Number(process2.exitCode ?? 0);
2006
+ if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2007
+ exitCode2 = 1;
2007
2008
  }
2008
- this._exit(exitCode, "commander.help", "(outputHelp)");
2009
+ this._exit(exitCode2, "commander.help", "(outputHelp)");
2009
2010
  }
2010
2011
  addHelpText(position, text) {
2011
2012
  const allowedValues = ["beforeAll", "before", "after", "afterAll"];
@@ -2076,32 +2077,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2076
2077
  exports.Command = Command;
2077
2078
  exports.useColor = useColor;
2078
2079
  });
2079
-
2080
- // ../../node_modules/commander/index.js
2081
- var require_commander = __commonJS(function(exports) {
2082
- var { Argument } = require_argument();
2083
- var { Command } = require_command();
2084
- var { CommanderError, InvalidArgumentError } = require_error();
2085
- var { Help } = require_help();
2086
- var { Option } = require_option();
2087
- exports.program = new Command;
2088
- exports.createCommand = (name) => new Command(name);
2089
- exports.createOption = (flags, description) => new Option(flags, description);
2090
- exports.createArgument = (name, description) => new Argument(name, description);
2091
- exports.Command = Command;
2092
- exports.Option = Option;
2093
- exports.Argument = Argument;
2094
- exports.Help = Help;
2095
- exports.CommanderError = CommanderError;
2096
- exports.InvalidArgumentError = InvalidArgumentError;
2097
- exports.InvalidOptionArgumentError = InvalidArgumentError;
2098
- });
2099
2080
  // package.json
2100
2081
  var package_default = {
2101
2082
  name: "@uipath/traces-tool",
2102
2083
  author: "UiPath",
2103
2084
  license: "SEE LICENSE IN LICENSE.txt",
2104
- version: "1.205.0-preview.281",
2085
+ version: "1.206.0-preview.282",
2105
2086
  description: "Query execution traces for UiPath jobs",
2106
2087
  private: false,
2107
2088
  publishConfig: {
@@ -2123,6 +2104,7 @@ var package_default = {
2123
2104
  ],
2124
2105
  scripts: {
2125
2106
  build: "bun ../../tools/build-tool.ts",
2107
+ typecheck: "tsc --noEmit",
2126
2108
  package: "bun run build && bun pm pack",
2127
2109
  lint: "biome check .",
2128
2110
  "lint:fix": "biome check --write .",
@@ -2141,7 +2123,7 @@ var package_default = {
2141
2123
  };
2142
2124
 
2143
2125
  // ../filesystem/src/node.ts
2144
- import { randomUUID } from "node:crypto";
2126
+ import { createHash, randomUUID } from "node:crypto";
2145
2127
  import { existsSync } from "node:fs";
2146
2128
  import * as fs from "node:fs/promises";
2147
2129
  import * as os from "node:os";
@@ -2152,6 +2134,9 @@ var LOCK_MAX_WAIT_MS = 20000;
2152
2134
  var LOCK_MAX_HOLD_MS = 60000;
2153
2135
  var LOCK_RETRY_MIN_MS = 100;
2154
2136
  var LOCK_RETRY_JITTER_MS = 200;
2137
+ var HASH_CHUNK_BYTES = 256 * 1024;
2138
+ var hashBuffers = [];
2139
+ var HASH_BUFFERS_KEPT = 64;
2155
2140
 
2156
2141
  class NodeFileSystem {
2157
2142
  path = {
@@ -2170,7 +2155,7 @@ class NodeFileSystem {
2170
2155
  };
2171
2156
  utils = {
2172
2157
  open: async (url) => {
2173
- const { default: open } = await import("./index-sby22td6.js");
2158
+ const { default: open } = await import("./index-nzr4mx5p.js");
2174
2159
  await open(url);
2175
2160
  }
2176
2161
  };
@@ -2209,6 +2194,15 @@ class NodeFileSystem {
2209
2194
  throw error;
2210
2195
  }
2211
2196
  }
2197
+ async readdirEntries(dirPath) {
2198
+ try {
2199
+ return await fs.readdir(dirPath, { withFileTypes: true });
2200
+ } catch (error) {
2201
+ if (this.isEnoent(error))
2202
+ return [];
2203
+ throw error;
2204
+ }
2205
+ }
2212
2206
  async stat(filePath) {
2213
2207
  try {
2214
2208
  const stats = await fs.stat(filePath);
@@ -2216,7 +2210,8 @@ class NodeFileSystem {
2216
2210
  isFile: () => stats.isFile(),
2217
2211
  isDirectory: () => stats.isDirectory(),
2218
2212
  size: stats.size,
2219
- mtimeMs: stats.mtimeMs
2213
+ mtimeMs: stats.mtimeMs,
2214
+ ctimeMs: stats.ctimeMs
2220
2215
  };
2221
2216
  } catch (error) {
2222
2217
  if (this.isEnoent(error))
@@ -2330,6 +2325,42 @@ class NodeFileSystem {
2330
2325
  throw error;
2331
2326
  }
2332
2327
  }
2328
+ async hashFile(filePath) {
2329
+ let handle;
2330
+ try {
2331
+ handle = await fs.open(filePath, "r");
2332
+ } catch (error) {
2333
+ if (this.isEnoent(error))
2334
+ return null;
2335
+ throw error;
2336
+ }
2337
+ const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
2338
+ try {
2339
+ const opened = await handle.stat();
2340
+ const stats = {
2341
+ isFile: () => opened.isFile(),
2342
+ isDirectory: () => opened.isDirectory(),
2343
+ size: opened.size,
2344
+ mtimeMs: opened.mtimeMs,
2345
+ ctimeMs: opened.ctimeMs
2346
+ };
2347
+ const hash = createHash("sha256");
2348
+ let size = 0;
2349
+ for (;; ) {
2350
+ const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
2351
+ if (bytesRead === 0)
2352
+ break;
2353
+ hash.update(buffer.subarray(0, bytesRead));
2354
+ size += bytesRead;
2355
+ }
2356
+ return { sha256: hash.digest("hex"), size, stats };
2357
+ } finally {
2358
+ if (hashBuffers.length < HASH_BUFFERS_KEPT) {
2359
+ hashBuffers.push(buffer);
2360
+ }
2361
+ await handle.close();
2362
+ }
2363
+ }
2333
2364
  async realpath(filePath) {
2334
2365
  try {
2335
2366
  return await fs.realpath(filePath);
@@ -2380,6 +2411,208 @@ class NodeFileSystem {
2380
2411
  var fsInstance = new NodeFileSystem;
2381
2412
  var getFileSystem = () => fsInstance;
2382
2413
 
2414
+ // ../common/src/telemetry/telemetry-dimensions.ts
2415
+ var BaseDimensions = {
2416
+ ApplicationName: "ApplicationName",
2417
+ ProductVersion: "ProductVersion",
2418
+ InstallationId: "InstallationId",
2419
+ CloudUserId: "CloudUserId",
2420
+ CloudTenantId: "CloudTenantId",
2421
+ CloudOrganizationId: "CloudOrganizationId",
2422
+ IsInternalUser: "IsInternalUser",
2423
+ Environment: "Environment",
2424
+ BaseUrl: "BaseUrl",
2425
+ Region: "Region",
2426
+ Agent: "Agent",
2427
+ AgentVersion: "AgentVersion",
2428
+ AgentModel: "AgentModel",
2429
+ ToolName: "ToolName",
2430
+ ToolVersion: "ToolVersion",
2431
+ ExecutionContext: "ExecutionContext",
2432
+ CiProvider: "CiProvider",
2433
+ SessionIdSource: "SessionIdSource",
2434
+ SessionId: "SessionId"
2435
+ };
2436
+ var CommandDimensions = {
2437
+ IsCommand: "IsCommand",
2438
+ IsReexec: "IsReexec",
2439
+ CommandName: "CommandName",
2440
+ ExitCode: "ExitCode",
2441
+ TerminalOutcome: "TerminalOutcome",
2442
+ ErrorClass: "ErrorClass",
2443
+ TerminalSignal: "TerminalSignal",
2444
+ ErrorMessage: "ErrorMessage",
2445
+ SkillName: "SkillName",
2446
+ ProductArea: "ProductArea",
2447
+ Mode: "Mode"
2448
+ };
2449
+ var ProjectDimensions = {
2450
+ ProjectKey: "ProjectKey",
2451
+ ProjectType: "ProjectType",
2452
+ ProjectIdentityStatus: "ProjectIdentityStatus",
2453
+ SolutionKey: "SolutionKey",
2454
+ SolutionProjectKey: "SolutionProjectKey",
2455
+ SolutionIdentityStatus: "SolutionIdentityStatus",
2456
+ PreviousSolutionKey: "PreviousSolutionKey"
2457
+ };
2458
+ var GUID_KEY_DIMENSIONS = new Set([
2459
+ ProjectDimensions.ProjectKey,
2460
+ ProjectDimensions.SolutionKey,
2461
+ ProjectDimensions.SolutionProjectKey,
2462
+ ProjectDimensions.PreviousSolutionKey
2463
+ ]);
2464
+ var ShipDimensions = {
2465
+ ShipKind: "ShipKind",
2466
+ Target: "Target",
2467
+ ProjectType: "ProjectType",
2468
+ ProjectTypes: "ProjectTypes",
2469
+ ArtifactCorrelationKey: "ArtifactCorrelationKey",
2470
+ PackageName: "PackageName",
2471
+ PackageVersion: "PackageVersion",
2472
+ PackageVersionKey: "PackageVersionKey",
2473
+ DeploymentKey: "DeploymentKey",
2474
+ SolutionId: "SolutionId",
2475
+ FolderKey: "FolderKey",
2476
+ FeedId: "FeedId"
2477
+ };
2478
+ var ErrorDimensions = {
2479
+ Result: "Result",
2480
+ ErrorCode: "ErrorCode",
2481
+ Retry: "Retry",
2482
+ ErrorMessage: "ErrorMessage",
2483
+ HttpStatus: "HttpStatus",
2484
+ UpstreamErrorCode: "UpstreamErrorCode"
2485
+ };
2486
+ var AuthDimensions = {
2487
+ AuthenticationMethod: "AuthenticationMethod",
2488
+ Success: "Success",
2489
+ Reason: "Reason"
2490
+ };
2491
+ var SkillsDimensions = {
2492
+ SchemaVersion: "SchemaVersion",
2493
+ AgentType: "AgentType",
2494
+ SkillsVersion: "SkillsVersion",
2495
+ UipSubcommand: "UipSubcommand",
2496
+ FileExtension: "FileExtension",
2497
+ SubagentModel: "SubagentModel",
2498
+ SubagentType: "SubagentType",
2499
+ PermissionMode: "PermissionMode",
2500
+ EffortLevel: "EffortLevel",
2501
+ SessionSource: "SessionSource",
2502
+ Outcome: "Outcome",
2503
+ DurationMs: "DurationMs",
2504
+ Source: "Source"
2505
+ };
2506
+ var PackagerDimensions = {
2507
+ ProjectId: "ProjectId",
2508
+ ProjectType: "ProjectType",
2509
+ SolutionId: "SolutionId"
2510
+ };
2511
+ var ScopeDimensions = {
2512
+ FolderId: "FolderId"
2513
+ };
2514
+ var ID_DIMENSIONS = new Set([
2515
+ BaseDimensions.CloudUserId,
2516
+ BaseDimensions.CloudTenantId,
2517
+ BaseDimensions.CloudOrganizationId,
2518
+ BaseDimensions.InstallationId,
2519
+ ShipDimensions.ArtifactCorrelationKey,
2520
+ ShipDimensions.PackageVersionKey,
2521
+ ShipDimensions.DeploymentKey,
2522
+ ShipDimensions.SolutionId,
2523
+ ShipDimensions.FolderKey,
2524
+ ShipDimensions.FeedId,
2525
+ PackagerDimensions.ProjectId
2526
+ ]);
2527
+ var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
2528
+ var RESERVED_DIMENSION_NAMES = new Set([
2529
+ ...Object.values(BaseDimensions),
2530
+ ...Object.values(CommandDimensions),
2531
+ ...Object.values(ShipDimensions),
2532
+ ...Object.values(ProjectDimensions),
2533
+ ...Object.values(ErrorDimensions),
2534
+ ...Object.values(AuthDimensions),
2535
+ ...Object.values(SkillsDimensions),
2536
+ ...Object.values(PackagerDimensions),
2537
+ ...Object.values(ScopeDimensions)
2538
+ ]);
2539
+ var CURATED_DIMENSIONS = new Set([
2540
+ BaseDimensions.ApplicationName,
2541
+ BaseDimensions.ProductVersion,
2542
+ BaseDimensions.InstallationId,
2543
+ BaseDimensions.CloudUserId,
2544
+ BaseDimensions.CloudTenantId,
2545
+ BaseDimensions.CloudOrganizationId,
2546
+ BaseDimensions.IsInternalUser,
2547
+ BaseDimensions.Environment,
2548
+ BaseDimensions.BaseUrl,
2549
+ BaseDimensions.Region,
2550
+ BaseDimensions.Agent,
2551
+ BaseDimensions.AgentVersion,
2552
+ BaseDimensions.ToolVersion,
2553
+ BaseDimensions.ExecutionContext,
2554
+ BaseDimensions.CiProvider,
2555
+ BaseDimensions.SessionIdSource,
2556
+ BaseDimensions.SessionId,
2557
+ ...Object.values(CommandDimensions),
2558
+ ...Object.values(ShipDimensions),
2559
+ ...Object.values(ProjectDimensions)
2560
+ ]);
2561
+ function lowercaseIdDimensionValues(properties) {
2562
+ let changed = false;
2563
+ const result = {
2564
+ ...properties
2565
+ };
2566
+ for (const key of Object.keys(result)) {
2567
+ const value = result[key];
2568
+ if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
2569
+ continue;
2570
+ }
2571
+ const lowered = value.toLowerCase();
2572
+ if (lowered !== value) {
2573
+ result[key] = lowered;
2574
+ changed = true;
2575
+ }
2576
+ }
2577
+ return changed ? result : properties;
2578
+ }
2579
+
2580
+ // ../common/src/telemetry/project-identity.ts
2581
+ function projectKey(id) {
2582
+ if (typeof id !== "string")
2583
+ return;
2584
+ const key = id.trim().toLowerCase().replaceAll("-", "");
2585
+ return /^[0-9a-f]{32}$/.test(key) ? key : undefined;
2586
+ }
2587
+ function projectIdentityProperties(identity) {
2588
+ const key = identity.id ? projectKey(identity.id) : undefined;
2589
+ return {
2590
+ [ProjectDimensions.ProjectIdentityStatus]: identity.status === "resolved" && !key ? "invalid" : identity.status,
2591
+ [ProjectDimensions.ProjectType]: identity.projectType,
2592
+ ...identity.status === "resolved" && key ? {
2593
+ [ProjectDimensions.ProjectKey]: key
2594
+ } : {}
2595
+ };
2596
+ }
2597
+ var PROJECT_IDENTITY_LOOKUP_BUDGET_MS = 1000;
2598
+ async function withinProjectIdentityBudget(work, onTimeout) {
2599
+ work.catch(() => {
2600
+ return;
2601
+ });
2602
+ let timer;
2603
+ const expired = new Promise((resolve) => {
2604
+ timer = setTimeout(() => {
2605
+ onTimeout?.();
2606
+ resolve(undefined);
2607
+ }, PROJECT_IDENTITY_LOOKUP_BUDGET_MS);
2608
+ });
2609
+ try {
2610
+ return await Promise.race([work, expired]);
2611
+ } finally {
2612
+ clearTimeout(timer);
2613
+ }
2614
+ }
2615
+
2383
2616
  // ../common/src/telemetry/pseudonymize.ts
2384
2617
  var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2385
2618
  var PSEUDONYM_HEX_LENGTH = 32;
@@ -2748,8 +2981,8 @@ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2748
2981
  return `${redactUrl(core)}${trailing}`;
2749
2982
  });
2750
2983
  out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2751
- out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
2752
- const [core, trailing] = peelTrailingPunctuation(path2);
2984
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
2985
+ const [core, trailing] = peelTrailingPunctuation(path);
2753
2986
  return `${before}unc#${pseudonymize(core)}${trailing}`;
2754
2987
  });
2755
2988
  out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
@@ -2843,6 +3076,8 @@ function redactProperty(name, value) {
2843
3076
  if (isSensitiveName(name)) {
2844
3077
  return REDACTED;
2845
3078
  }
3079
+ if (GUID_KEY_DIMENSIONS.has(name))
3080
+ return projectKey(value);
2846
3081
  if (typeof value === "boolean" || typeof value === "number") {
2847
3082
  return value;
2848
3083
  }
@@ -2917,6 +3152,63 @@ function settlePromiseLike(thenable) {
2917
3152
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2918
3153
  }
2919
3154
 
3155
+ // ../common/src/error-codes.ts
3156
+ var CLI_ERROR_CODES = [
3157
+ "invalid_argument",
3158
+ "authentication_required",
3159
+ "permission_denied",
3160
+ "local_permission_denied",
3161
+ "not_found",
3162
+ "rate_limited",
3163
+ "network_error",
3164
+ "timeout",
3165
+ "server_error",
3166
+ "method_not_allowed",
3167
+ "not_supported",
3168
+ "configuration_error",
3169
+ "execution_failed",
3170
+ "unknown_error"
3171
+ ];
3172
+ var RETRY_HINTS = [
3173
+ "RetryWillNotFix",
3174
+ "RetryLater",
3175
+ "RetryAfter1Second",
3176
+ "RetryAfter10Seconds",
3177
+ "RetryAfter30Seconds",
3178
+ "RetryAfter60Seconds"
3179
+ ];
3180
+ var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
3181
+ var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
3182
+ function isCliErrorCode(value) {
3183
+ return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
3184
+ }
3185
+ function isRetryHint(value) {
3186
+ return typeof value === "string" && RETRY_HINT_VALUES.has(value);
3187
+ }
3188
+ function carriedErrorCode(error) {
3189
+ if (!error || typeof error !== "object")
3190
+ return;
3191
+ const code = error.errorCode;
3192
+ return isCliErrorCode(code) ? code : undefined;
3193
+ }
3194
+ function carriedRetry(error) {
3195
+ if (!error || typeof error !== "object")
3196
+ return;
3197
+ const retry = error.retry;
3198
+ return isRetryHint(retry) ? retry : undefined;
3199
+ }
3200
+ function defaultRetryForErrorCode(errorCode) {
3201
+ switch (errorCode) {
3202
+ case "network_error":
3203
+ case "rate_limited":
3204
+ case "server_error":
3205
+ case "timeout":
3206
+ return "RetryLater";
3207
+ default:
3208
+ return "RetryWillNotFix";
3209
+ }
3210
+ }
3211
+
2920
3212
  // ../common/src/error-graph.ts
2921
3213
  function* walkErrorGraph(error) {
2922
3214
  const queue = [error];
@@ -2961,18 +3253,54 @@ function findHttpStatusInGraph(error) {
2961
3253
  return;
2962
3254
  }
2963
3255
 
2964
- // ../common/src/local-permission-codes.ts
2965
- var LOCAL_PERMISSION_ERROR_CODES = new Set([
2966
- "EACCES",
2967
- "EPERM",
2968
- "EROFS"
2969
- ]);
2970
-
2971
- // ../common/src/error-handler.ts
2972
- var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
2973
- var DEFAULT_403 = "Forbidden (403). The account lacks permission for this operation, or the token carries no scope for this API. Run `uip login status --detailed` to see the token's scopes.";
2974
- var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
3256
+ // ../common/src/http-status.ts
3257
+ function classifyHttpStatus(status) {
3258
+ if (status === undefined)
3259
+ return;
3260
+ if (status === 400 || status === 409 || status === 413 || status === 422) {
3261
+ return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
3262
+ }
3263
+ if (status === 401) {
3264
+ return {
3265
+ errorCode: "authentication_required",
3266
+ retry: "RetryWillNotFix"
3267
+ };
3268
+ }
3269
+ if (status === 403) {
3270
+ return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
3271
+ }
3272
+ if (status === 404) {
3273
+ return { errorCode: "not_found", retry: "RetryWillNotFix" };
3274
+ }
3275
+ if (status === 405) {
3276
+ return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
3277
+ }
3278
+ if (status === 408) {
3279
+ return { errorCode: "timeout", retry: "RetryLater" };
3280
+ }
3281
+ if (status === 429) {
3282
+ return { errorCode: "rate_limited", retry: "RetryLater" };
3283
+ }
3284
+ if (status >= 500 && status < 600) {
3285
+ return { errorCode: "server_error", retry: "RetryLater" };
3286
+ }
3287
+ return;
3288
+ }
3289
+
3290
+ // ../common/src/local-permission-codes.ts
3291
+ var LOCAL_PERMISSION_ERROR_CODES = new Set([
3292
+ "EACCES",
3293
+ "EPERM",
3294
+ "EROFS"
3295
+ ]);
3296
+
3297
+ // ../common/src/error-handler.ts
3298
+ var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
3299
+ var DEFAULT_403 = "Forbidden (403). The account lacks permission for this operation, or the token carries no scope for this API. Run `uip login status --detailed` to see the token's scopes.";
3300
+ var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
2975
3301
  var DEFAULT_413 = "Payload too large (413). The upload exceeded the server or CDN size limit. Reduce the package size — for example, exclude unused dependencies or remove large files from the project — and try again.";
3302
+ var CLOUDFLARE_BLOCK_403 = "Forbidden (403) by Cloudflare, in front of the service: the answer is a Cloudflare HTML page, not the service's JSON, so the service did not see the request and did not check the account's roles or the token's scopes. Cloudflare blocks a request when its content matches a firewall rule (text that looks like SQL or script code, for example) or when it comes from a network the firewall does not allow.";
3303
+ var CLOUDFLARE_BLOCK_403_INSTRUCTIONS = "If the request carries text that looks like code, change that text and try again. Otherwise send the time of the request and the Cloudflare Ray ID, when the message gives one, to the owner of the service or UiPath support.";
2976
3304
  var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
2977
3305
  var NETWORK_ERROR_CODES = new Set([
2978
3306
  "ECONNREFUSED",
@@ -2998,8 +3326,8 @@ var TLS_ERROR_CODES = new Set([
2998
3326
  var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
2999
3327
  var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
3000
3328
  var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
3001
- function localPermissionInstructions(code, path2) {
3002
- const target = path2 !== undefined ? `'${path2}'` : "a local file or resource";
3329
+ function localPermissionInstructions(code, path) {
3330
+ const target = path !== undefined ? `'${path}'` : "a local file or resource";
3003
3331
  if (code === "EROFS") {
3004
3332
  return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
3005
3333
  }
@@ -3036,12 +3364,12 @@ function describePermissionError(error) {
3036
3364
  const code = matchLocalPermissionCode(cur.code, message);
3037
3365
  if (!code)
3038
3366
  continue;
3039
- const path2 = localPermissionPath(cur.path, message);
3367
+ const path = localPermissionPath(cur.path, message);
3040
3368
  return {
3041
3369
  code,
3042
3370
  message: message ?? code,
3043
- ...path2 !== undefined ? { path: path2 } : {},
3044
- instructions: localPermissionInstructions(code, path2)
3371
+ ...path !== undefined ? { path } : {},
3372
+ instructions: localPermissionInstructions(code, path)
3045
3373
  };
3046
3374
  }
3047
3375
  return;
@@ -3053,11 +3381,25 @@ function matchLocalPermissionCode(code, message) {
3053
3381
  const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
3054
3382
  return match ? match[1] : undefined;
3055
3383
  }
3056
- function localPermissionPath(path2, message) {
3057
- if (typeof path2 === "string")
3058
- return path2;
3384
+ function localPermissionPath(path, message) {
3385
+ if (typeof path === "string")
3386
+ return path;
3059
3387
  return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
3060
3388
  }
3389
+ function readHeader(response, name) {
3390
+ const headers = response?.headers;
3391
+ if (!headers || typeof headers !== "object")
3392
+ return;
3393
+ if (typeof headers.get === "function") {
3394
+ const value = headers.get(name);
3395
+ if (value)
3396
+ return value;
3397
+ }
3398
+ const plain = headers;
3399
+ const key = Object.keys(plain).find((k) => k.toLowerCase() === name.toLowerCase());
3400
+ const value = key === undefined ? undefined : plain[key];
3401
+ return typeof value === "string" && value !== "" ? value : undefined;
3402
+ }
3061
3403
  function isHtmlDocument(body) {
3062
3404
  return /^\s*(<!doctype html|<html\b)/i.test(body);
3063
3405
  }
@@ -3074,36 +3416,9 @@ function retryHintForRetryAfter(seconds) {
3074
3416
  return "RetryAfter60Seconds";
3075
3417
  }
3076
3418
  function classifyError(status, error) {
3077
- if (status === 400 || status === 409 || status === 422) {
3078
- return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
3079
- }
3080
- if (status === 401) {
3081
- return {
3082
- errorCode: "authentication_required",
3083
- retry: "RetryWillNotFix"
3084
- };
3085
- }
3086
- if (status === 403) {
3087
- return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
3088
- }
3089
- if (status === 404) {
3090
- return { errorCode: "not_found", retry: "RetryWillNotFix" };
3091
- }
3092
- if (status === 405) {
3093
- return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
3094
- }
3095
- if (status === 413) {
3096
- return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
3097
- }
3098
- if (status === 408) {
3099
- return { errorCode: "timeout", retry: "RetryLater" };
3100
- }
3101
- if (status === 429) {
3102
- return { errorCode: "rate_limited", retry: "RetryLater" };
3103
- }
3104
- if (status !== undefined && status >= 500 && status < 600) {
3105
- return { errorCode: "server_error", retry: "RetryLater" };
3106
- }
3419
+ const byStatus = classifyHttpStatus(status);
3420
+ if (byStatus)
3421
+ return byStatus;
3107
3422
  if (status === undefined && describePermissionError(error)) {
3108
3423
  return {
3109
3424
  errorCode: "local_permission_denied",
@@ -3119,6 +3434,17 @@ function classifyError(status, error) {
3119
3434
  }
3120
3435
  return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
3121
3436
  }
3437
+ function withCarriedClass(inferred, error) {
3438
+ const errorCode = carriedErrorCode(error);
3439
+ const retry = carriedRetry(error);
3440
+ if (errorCode === undefined || errorCode === inferred.errorCode) {
3441
+ return {
3442
+ errorCode: inferred.errorCode,
3443
+ retry: retry ?? inferred.retry
3444
+ };
3445
+ }
3446
+ return { errorCode, retry: retry ?? defaultRetryForErrorCode(errorCode) };
3447
+ }
3122
3448
  function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
3123
3449
  if (extractedMessage) {
3124
3450
  return `HTTP ${status}: ${extractedMessage}`;
@@ -3174,9 +3500,14 @@ async function extractErrorDetails(error, options) {
3174
3500
  const classificationStatus = status ?? findHttpStatusInGraph(error);
3175
3501
  const classification = classifyError(classificationStatus, error);
3176
3502
  let retry = classification.retry;
3503
+ const htmlForbidden = status === 403 && rawBody !== undefined && isHtmlDocument(rawBody);
3504
+ const rayId = htmlForbidden ? readHeader(response, "cf-ray") : undefined;
3505
+ const cloudflareBlock = htmlForbidden && (rayId !== undefined || /\bcloudflare\b/i.test(readHeader(response, "server") ?? ""));
3177
3506
  if (status === 401) {
3178
3507
  message = DEFAULT_401;
3179
3508
  result = "AuthenticationError";
3509
+ } else if (cloudflareBlock) {
3510
+ message = rayId ? `${CLOUDFLARE_BLOCK_403} Cloudflare Ray ID: ${rayId}.` : CLOUDFLARE_BLOCK_403;
3180
3511
  } else if (status === 403) {
3181
3512
  message = options?.forbiddenMessage ?? DEFAULT_403;
3182
3513
  result = "AuthenticationError";
@@ -3224,7 +3555,9 @@ async function extractErrorDetails(error, options) {
3224
3555
  }
3225
3556
  }
3226
3557
  let details = rawMessage;
3227
- if (rawBody) {
3558
+ if (htmlForbidden) {
3559
+ details = cloudflareBlock ? CLOUDFLARE_BLOCK_403_INSTRUCTIONS : HTML_RESPONSE_MESSAGE;
3560
+ } else if (rawBody) {
3228
3561
  if (parsedBody) {
3229
3562
  const extra = {};
3230
3563
  if (parsedBody.errorCode)
@@ -3258,6 +3591,8 @@ async function extractErrorDetails(error, options) {
3258
3591
  }
3259
3592
  if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
3260
3593
  context.requestId = parsedBody.requestId;
3594
+ } else if (cloudflareBlock && rayId) {
3595
+ context.requestId = rayId;
3261
3596
  }
3262
3597
  if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
3263
3598
  context.traceId = parsedBody.traceId;
@@ -3266,16 +3601,7 @@ async function extractErrorDetails(error, options) {
3266
3601
  context.path = permission.path;
3267
3602
  }
3268
3603
  if (status === 429) {
3269
- const resp = response;
3270
- const headersObj = resp?.headers;
3271
- let retryAfterValue;
3272
- if (headersObj && typeof headersObj === "object" && typeof headersObj.get === "function") {
3273
- retryAfterValue = headersObj.get("retry-after") ?? undefined;
3274
- }
3275
- if (!retryAfterValue && headersObj && typeof headersObj === "object") {
3276
- const headers = headersObj;
3277
- retryAfterValue = headers["retry-after"] ?? headers["Retry-After"];
3278
- }
3604
+ const retryAfterValue = readHeader(response, "retry-after");
3279
3605
  if (retryAfterValue) {
3280
3606
  const seconds = Number(retryAfterValue);
3281
3607
  if (!Number.isNaN(seconds)) {
@@ -3309,9 +3635,8 @@ async function extractErrorDetails(error, options) {
3309
3635
  }
3310
3636
  return {
3311
3637
  result,
3312
- errorCode: classification.errorCode,
3638
+ ...withCarriedClass({ errorCode: classification.errorCode, retry }, error),
3313
3639
  message,
3314
- retry,
3315
3640
  details,
3316
3641
  ...hasContext ? { context } : {},
3317
3642
  ...parsedErrors ? { parsedErrors } : {}
@@ -3321,10 +3646,169 @@ async function extractErrorMessage(error, options) {
3321
3646
  const { message } = await extractErrorDetails(error, options);
3322
3647
  return message;
3323
3648
  }
3324
- // ../common/src/exit-code.ts
3325
- function setExitCode(code) {
3326
- process.exitCode = code;
3649
+ // ../common/src/error-instructions.ts
3650
+ function extractHttpStatus(err) {
3651
+ if (!err || typeof err !== "object")
3652
+ return;
3653
+ const e = err;
3654
+ const structured = e.response?.status ?? e.status ?? e.statusCode;
3655
+ if (structured !== undefined)
3656
+ return structured;
3657
+ return typeof e.message === "string" ? parseHttpStatusFromMessage(e.message) : undefined;
3658
+ }
3659
+ var GENERIC = "Check authentication and parameters";
3660
+ function hasIdentityInstructionContext(err) {
3661
+ return err !== null && typeof err === "object" && "instructionContext" in err && err.instructionContext === "identity";
3662
+ }
3663
+ function instructionsFor(ctx, err) {
3664
+ if (ctx === "auth" && hasIdentityInstructionContext(err)) {
3665
+ return instructionsFor("identity");
3666
+ }
3667
+ switch (ctx) {
3668
+ case "auth":
3669
+ return "Run 'uip login' to authenticate. To inspect the current session, run 'uip whoami'.";
3670
+ case "auth-configuration":
3671
+ return "Fix the authentication settings named in Message, then retry.";
3672
+ case "identity":
3673
+ return "Select an active tenant with 'uip login tenant set <tenant>' and ensure your login includes an organization";
3674
+ case "input-parse":
3675
+ return "Ensure --inputs is valid JSON or pipe JSON via stdin";
3676
+ case "input-validate":
3677
+ return "Fix the flagged input fields to match the process's input schema";
3678
+ case "flag-format":
3679
+ return "Check the flag value format — see --help for the expected shape";
3680
+ case "permissions":
3681
+ return "Confirm your user has the required permissions in this folder/tenant, or re-authenticate with 'uip login' if your session has lapsed";
3682
+ case "backend": {
3683
+ const status = extractHttpStatus(err);
3684
+ if (status === 401) {
3685
+ return "Re-authenticate with 'uip login' — your session is invalid or expired";
3686
+ }
3687
+ if (status === 403) {
3688
+ return "Confirm your user has access to the resource, and the required permissions in this folder or tenant";
3689
+ }
3690
+ if (status === 404) {
3691
+ return "Verify the resource exists in the current folder/tenant";
3692
+ }
3693
+ if (status === 400 || status === 422) {
3694
+ return "Request was rejected — check flag values and inputs";
3695
+ }
3696
+ if (status === 405) {
3697
+ return "Check the command name and the base URL in use — the endpoint may not exist";
3698
+ }
3699
+ if (status === 408) {
3700
+ return "The request timed out — retry; if it persists, narrow the request (e.g. --limit on list commands)";
3701
+ }
3702
+ if (status === 409) {
3703
+ return "The resource already exists, or changed since it was read — list it to see the current state";
3704
+ }
3705
+ if (status === 413) {
3706
+ return "The upload is over the size limit — exclude unused dependencies or drop large files, then retry";
3707
+ }
3708
+ if (status === 429) {
3709
+ return "Rate limit reached — wait and retry; when the service suggests a delay, Retry and Context.retryAfter carry it";
3710
+ }
3711
+ if (status !== undefined && status >= 500 && status < 600) {
3712
+ return "The service returned a server error — retry; if it persists, check service status";
3713
+ }
3714
+ const permission = describePermissionError(err);
3715
+ if (permission) {
3716
+ return permission.instructions;
3717
+ }
3718
+ const connectivity = describeConnectivityError(err);
3719
+ if (connectivity) {
3720
+ return connectivity.instructions;
3721
+ }
3722
+ return GENERIC;
3723
+ }
3724
+ }
3725
+ }
3726
+
3727
+ // ../common/src/result-types.ts
3728
+ var RESULTS = {
3729
+ Success: "Success",
3730
+ Failure: "Failure",
3731
+ ConfigError: "ConfigError",
3732
+ AuthenticationError: "AuthenticationError",
3733
+ ValidationError: "ValidationError",
3734
+ TimeoutError: "TimeoutError"
3735
+ };
3736
+ // ../../node_modules/commander/index.js
3737
+ var exports_commander = {};
3738
+ __exportCjs(exports_commander, {
3739
+ program: () => $program,
3740
+ createCommand: () => $createCommand,
3741
+ createOption: () => $createOption,
3742
+ createArgument: () => $createArgument,
3743
+ Command: () => $Command,
3744
+ Option: () => $Option,
3745
+ Argument: () => $Argument,
3746
+ Help: () => $Help,
3747
+ CommanderError: () => $CommanderError,
3748
+ InvalidArgumentError: () => $InvalidArgumentError,
3749
+ InvalidOptionArgumentError: () => $InvalidOptionArgumentError
3750
+ }, {
3751
+ program: (value) => $program = value,
3752
+ createCommand: (value) => $createCommand = value,
3753
+ createOption: (value) => $createOption = value,
3754
+ createArgument: (value) => $createArgument = value,
3755
+ Command: (value) => $Command = value,
3756
+ Option: (value) => $Option = value,
3757
+ Argument: (value) => $Argument = value,
3758
+ Help: (value) => $Help = value,
3759
+ CommanderError: (value) => $CommanderError = value,
3760
+ InvalidArgumentError: (value) => $InvalidArgumentError = value,
3761
+ InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
3762
+ });
3763
+ var { Argument } = require_argument();
3764
+ var { Command: Command2 } = require_command();
3765
+ var { CommanderError, InvalidArgumentError } = require_error();
3766
+ var { Help } = require_help();
3767
+ var { Option } = require_option();
3768
+ var $program = new Command2;
3769
+ var $createCommand = (name) => new Command2(name);
3770
+ var $createOption = (flags, description) => new Option(flags, description);
3771
+ var $createArgument = (name, description) => new Argument(name, description);
3772
+ var $Command = Command2;
3773
+ var $Option = Option;
3774
+ var $Argument = Argument;
3775
+ var $Help = Help;
3776
+ var $CommanderError = CommanderError;
3777
+ var $InvalidArgumentError = InvalidArgumentError;
3778
+ var $InvalidOptionArgumentError = InvalidArgumentError;
3779
+
3780
+ // ../../node_modules/commander/esm.mjs
3781
+ var {
3782
+ program,
3783
+ createCommand,
3784
+ createArgument,
3785
+ createOption,
3786
+ CommanderError: CommanderError2,
3787
+ InvalidArgumentError: InvalidArgumentError2,
3788
+ InvalidOptionArgumentError,
3789
+ Command,
3790
+ Argument: Argument2,
3791
+ Option: Option2,
3792
+ Help: Help2
3793
+ } = exports_commander;
3794
+
3795
+ // ../common/src/command-examples.ts
3796
+ var examplesByCommand = new WeakMap;
3797
+ Command.prototype.examples = function(examples) {
3798
+ examplesByCommand.set(this, examples);
3799
+ return this;
3800
+ };
3801
+ // ../common/src/preview.ts
3802
+ var previewSlot = singleton("PreviewBuild");
3803
+ function isPreviewBuild() {
3804
+ return previewSlot.get(false) ?? false;
3327
3805
  }
3806
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
3807
+ if (isPreviewBuild()) {
3808
+ return this.command(nameAndArgs, opts);
3809
+ }
3810
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
3811
+ };
3328
3812
 
3329
3813
  // ../common/src/output-context.ts
3330
3814
  function createStorage() {
@@ -3359,8 +3843,8 @@ function getOutputSink() {
3359
3843
 
3360
3844
  // ../common/src/logger.ts
3361
3845
  var logFilePathSlot = singleton("logFilePath");
3362
- function setGlobalLogFilePath(path2) {
3363
- logFilePathSlot.set(path2);
3846
+ function setGlobalLogFilePath(path) {
3847
+ logFilePathSlot.set(path);
3364
3848
  }
3365
3849
  function getGlobalLogFilePath() {
3366
3850
  return logFilePathSlot.get("");
@@ -3428,14 +3912,14 @@ class SimpleLogger {
3428
3912
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
3429
3913
  }
3430
3914
  writeToFile(formatted) {
3431
- const path2 = this.logFilePath || getGlobalLogFilePath();
3432
- if (!path2)
3915
+ const path = this.logFilePath || getGlobalLogFilePath();
3916
+ if (!path)
3433
3917
  return;
3434
3918
  const timestamp = new Date().toISOString();
3435
3919
  this.pendingWrites = Promise.all([
3436
3920
  this.pendingWrites,
3437
3921
  this.pendingInit
3438
- ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
3922
+ ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
3439
3923
  }
3440
3924
  write(formatted) {
3441
3925
  if (this.isFileLoggingActive()) {
@@ -3485,17 +3969,17 @@ class SimpleLogger {
3485
3969
  setGlobalLogFilePath("");
3486
3970
  }
3487
3971
  }
3488
- setLogFile(path2) {
3489
- this.logFilePath = path2;
3490
- setGlobalLogFilePath(path2);
3491
- if (!path2)
3972
+ setLogFile(path) {
3973
+ this.logFilePath = path;
3974
+ setGlobalLogFilePath(path);
3975
+ if (!path)
3492
3976
  return;
3493
3977
  this.fileLoggingEnabled = true;
3494
- const fs2 = getFileSystem();
3978
+ const fs = getFileSystem();
3495
3979
  this.pendingInit = (async () => {
3496
3980
  const [error] = await catchError((async () => {
3497
- await fs2.mkdir(fs2.path.dirname(path2));
3498
- await fs2.writeFile(path2, "");
3981
+ await fs.mkdir(fs.path.dirname(path));
3982
+ await fs.writeFile(path, "");
3499
3983
  })());
3500
3984
  if (error)
3501
3985
  this.fileLoggingEnabled = false;
@@ -3543,189 +4027,133 @@ function getLogFilePath() {
3543
4027
  return logger.getLogFilePath();
3544
4028
  }
3545
4029
 
3546
- // ../common/src/output-codecs.ts
3547
- var yamlSlot = singleton("YamlCodec");
3548
- var jmespathSlot = singleton("JmespathCodec");
3549
- async function loadOutputCodecsAsync(needed) {
3550
- const loads = [];
3551
- if (needed.yaml && yamlSlot.get() === undefined) {
3552
- loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
3553
- yamlSlot.set(mod);
3554
- }));
4030
+ // ../common/src/timings.ts
4031
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
4032
+ function createStorage2() {
4033
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
4034
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
4035
+ return {
4036
+ getStore: () => {
4037
+ return;
4038
+ },
4039
+ run: (_store, fn) => fn()
4040
+ };
3555
4041
  }
3556
- if (needed.filter && jmespathSlot.get() === undefined) {
3557
- loads.push(import("./jmespath-231m3hyn.js").then((m)=>__toESM(m.default,1)).then((mod) => {
3558
- jmespathSlot.set(mod);
3559
- }));
4042
+ return new mod.AsyncLocalStorage;
4043
+ }
4044
+ var storageSlot = singleton("TimingStorage");
4045
+ var stateSlot = singleton("Timings");
4046
+ var rootStartedSlot = singleton("TimingsRootStarted");
4047
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
4048
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
4049
+ function newState(baseline) {
4050
+ return { baseline, httpMs: 0, httpCalls: 0 };
4051
+ }
4052
+ function getState() {
4053
+ const scoped = storage.getStore();
4054
+ if (scoped) {
4055
+ return scoped;
3560
4056
  }
3561
- await Promise.all(loads);
4057
+ const pinned = livePinnedState();
4058
+ if (pinned !== undefined) {
4059
+ return pinned;
4060
+ }
4061
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
3562
4062
  }
3563
- function getYamlCodec() {
3564
- return yamlSlot.get();
4063
+ function livePinnedState() {
4064
+ const pinned = stateSlot.get();
4065
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3565
4066
  }
3566
- function getJmespathCodec() {
3567
- return jmespathSlot.get();
4067
+ function processStartIsInvocationStart() {
4068
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
4069
+ }
4070
+ function timingsEnabled() {
4071
+ if (typeof process === "undefined") {
4072
+ return false;
4073
+ }
4074
+ const value = process.env?.[TIMINGS_ENV_VAR];
4075
+ if (value === undefined) {
4076
+ return false;
4077
+ }
4078
+ const normalized = value.trim().toLowerCase();
4079
+ return normalized === "1" || normalized === "true";
4080
+ }
4081
+ function recordExitCode(exitCode) {
4082
+ if (!timingsEnabled()) {
4083
+ return;
4084
+ }
4085
+ getState().exitCode = exitCode;
4086
+ }
4087
+ function invocationStartedAt() {
4088
+ return new Date(performance.timeOrigin + getState().baseline);
4089
+ }
4090
+ function invocationElapsedMs() {
4091
+ return performance.now() - getState().baseline;
4092
+ }
4093
+ function markCommandStart() {
4094
+ if (!timingsEnabled()) {
4095
+ return;
4096
+ }
4097
+ getState().commandStart = performance.now();
4098
+ }
4099
+ function recordCommandDuration(durationMs) {
4100
+ if (!timingsEnabled()) {
4101
+ return;
4102
+ }
4103
+ getState().commandMs = durationMs;
3568
4104
  }
3569
4105
 
3570
- // ../common/src/output-format-context.ts
3571
- var formatSlot = singleton("OutputFormat");
3572
- var formatExplicitSlot = singleton("OutputFormatExplicit");
3573
- var helpRequestedSlot = singleton("HelpRequested");
3574
- var filterSlot = singleton("OutputFilter");
3575
- function getOutputFormat() {
3576
- return formatSlot.get("json");
4106
+ // ../common/src/exit-code.ts
4107
+ function setExitCode(code) {
4108
+ process.exitCode = code;
4109
+ recordExitCode(code);
3577
4110
  }
3578
- function getOutputFilter() {
3579
- return filterSlot.get();
4111
+ var GENERIC_FAILURE_EXIT_CODE = 1;
4112
+ function recordCommandExit(code) {
4113
+ if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
4114
+ return;
4115
+ }
4116
+ setExitCode(code);
4117
+ }
4118
+ function getExitCode() {
4119
+ const code = process.exitCode;
4120
+ return typeof code === "number" ? code : 0;
3580
4121
  }
3581
4122
 
3582
- // ../common/src/telemetry/telemetry-dimensions.ts
3583
- var BaseDimensions = {
3584
- ApplicationName: "ApplicationName",
3585
- ProductVersion: "ProductVersion",
3586
- InstallationId: "InstallationId",
3587
- CloudUserId: "CloudUserId",
3588
- CloudTenantId: "CloudTenantId",
3589
- CloudOrganizationId: "CloudOrganizationId",
3590
- IsInternalUser: "IsInternalUser",
3591
- Environment: "Environment",
3592
- BaseUrl: "BaseUrl",
3593
- Region: "Region",
3594
- Agent: "Agent",
3595
- AgentVersion: "AgentVersion",
3596
- AgentModel: "AgentModel",
3597
- ToolName: "ToolName",
3598
- ToolVersion: "ToolVersion",
3599
- ExecutionContext: "ExecutionContext",
3600
- CiProvider: "CiProvider",
3601
- SessionIdSource: "SessionIdSource",
3602
- SessionId: "SessionId"
3603
- };
3604
- var CommandDimensions = {
3605
- IsCommand: "IsCommand",
3606
- IsReexec: "IsReexec",
3607
- CommandName: "CommandName",
3608
- ExitCode: "ExitCode",
3609
- TerminalOutcome: "TerminalOutcome",
3610
- ErrorClass: "ErrorClass",
3611
- TerminalSignal: "TerminalSignal",
3612
- ErrorMessage: "ErrorMessage",
3613
- SkillName: "SkillName",
3614
- ProductArea: "ProductArea",
3615
- Mode: "Mode"
3616
- };
3617
- var ShipDimensions = {
3618
- ShipKind: "ShipKind",
3619
- Target: "Target",
3620
- ProjectType: "ProjectType",
3621
- ProjectTypes: "ProjectTypes",
3622
- ArtifactCorrelationKey: "ArtifactCorrelationKey",
3623
- PackageName: "PackageName",
3624
- PackageVersion: "PackageVersion",
3625
- PackageVersionKey: "PackageVersionKey",
3626
- DeploymentKey: "DeploymentKey",
3627
- SolutionId: "SolutionId",
3628
- FolderKey: "FolderKey",
3629
- FeedId: "FeedId"
3630
- };
3631
- var ErrorDimensions = {
3632
- Result: "Result",
3633
- ErrorCode: "ErrorCode",
3634
- Retry: "Retry",
3635
- ErrorMessage: "ErrorMessage",
3636
- HttpStatus: "HttpStatus",
3637
- UpstreamErrorCode: "UpstreamErrorCode"
3638
- };
3639
- var AuthDimensions = {
3640
- AuthenticationMethod: "AuthenticationMethod",
3641
- Success: "Success",
3642
- Reason: "Reason"
3643
- };
3644
- var SkillsDimensions = {
3645
- SchemaVersion: "SchemaVersion",
3646
- AgentType: "AgentType",
3647
- SkillsVersion: "SkillsVersion",
3648
- UipSubcommand: "UipSubcommand",
3649
- FileExtension: "FileExtension",
3650
- SubagentModel: "SubagentModel",
3651
- SubagentType: "SubagentType",
3652
- PermissionMode: "PermissionMode",
3653
- EffortLevel: "EffortLevel",
3654
- SessionSource: "SessionSource",
3655
- Outcome: "Outcome",
3656
- DurationMs: "DurationMs",
3657
- Source: "Source"
3658
- };
3659
- var PackagerDimensions = {
3660
- ProjectId: "ProjectId",
3661
- ProjectType: "ProjectType",
3662
- SolutionId: "SolutionId"
3663
- };
3664
- var ScopeDimensions = {
3665
- FolderId: "FolderId"
3666
- };
3667
- var ID_DIMENSIONS = new Set([
3668
- BaseDimensions.CloudUserId,
3669
- BaseDimensions.CloudTenantId,
3670
- BaseDimensions.CloudOrganizationId,
3671
- BaseDimensions.InstallationId,
3672
- ShipDimensions.ArtifactCorrelationKey,
3673
- ShipDimensions.PackageVersionKey,
3674
- ShipDimensions.DeploymentKey,
3675
- ShipDimensions.SolutionId,
3676
- ShipDimensions.FolderKey,
3677
- ShipDimensions.FeedId,
3678
- PackagerDimensions.ProjectId
3679
- ]);
3680
- var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
3681
- var RESERVED_DIMENSION_NAMES = new Set([
3682
- ...Object.values(BaseDimensions),
3683
- ...Object.values(CommandDimensions),
3684
- ...Object.values(ShipDimensions),
3685
- ...Object.values(ErrorDimensions),
3686
- ...Object.values(AuthDimensions),
3687
- ...Object.values(SkillsDimensions),
3688
- ...Object.values(PackagerDimensions),
3689
- ...Object.values(ScopeDimensions)
3690
- ]);
3691
- var CURATED_DIMENSIONS = new Set([
3692
- BaseDimensions.ApplicationName,
3693
- BaseDimensions.ProductVersion,
3694
- BaseDimensions.InstallationId,
3695
- BaseDimensions.CloudUserId,
3696
- BaseDimensions.CloudTenantId,
3697
- BaseDimensions.CloudOrganizationId,
3698
- BaseDimensions.IsInternalUser,
3699
- BaseDimensions.Environment,
3700
- BaseDimensions.BaseUrl,
3701
- BaseDimensions.Region,
3702
- BaseDimensions.Agent,
3703
- BaseDimensions.AgentVersion,
3704
- BaseDimensions.ToolVersion,
3705
- BaseDimensions.ExecutionContext,
3706
- BaseDimensions.CiProvider,
3707
- BaseDimensions.SessionIdSource,
3708
- BaseDimensions.SessionId,
3709
- ...Object.values(CommandDimensions),
3710
- ...Object.values(ShipDimensions)
3711
- ]);
3712
- function lowercaseIdDimensionValues(properties) {
3713
- let changed = false;
3714
- const result = {
3715
- ...properties
3716
- };
3717
- for (const key of Object.keys(result)) {
3718
- const value = result[key];
3719
- if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
3720
- continue;
3721
- }
3722
- const lowered = value.toLowerCase();
3723
- if (lowered !== value) {
3724
- result[key] = lowered;
3725
- changed = true;
3726
- }
4123
+ // ../common/src/output-codecs.ts
4124
+ var yamlSlot = singleton("YamlCodec");
4125
+ var jmespathSlot = singleton("JmespathCodec");
4126
+ async function loadOutputCodecsAsync(needed) {
4127
+ const loads = [];
4128
+ if (needed.yaml && yamlSlot.get() === undefined) {
4129
+ loads.push(import("./js-yaml-a2bk27p6.js").then((mod) => {
4130
+ yamlSlot.set(mod);
4131
+ }));
3727
4132
  }
3728
- return changed ? result : properties;
4133
+ if (needed.filter && jmespathSlot.get() === undefined) {
4134
+ loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
4135
+ jmespathSlot.set(mod);
4136
+ }));
4137
+ }
4138
+ await Promise.all(loads);
4139
+ }
4140
+ function getYamlCodec() {
4141
+ return yamlSlot.get();
4142
+ }
4143
+ function getJmespathCodec() {
4144
+ return jmespathSlot.get();
4145
+ }
4146
+
4147
+ // ../common/src/output-format-context.ts
4148
+ var formatSlot = singleton("OutputFormat");
4149
+ var formatExplicitSlot = singleton("OutputFormatExplicit");
4150
+ var helpRequestedSlot = singleton("HelpRequested");
4151
+ var filterSlot = singleton("OutputFilter");
4152
+ function getOutputFormat() {
4153
+ return formatSlot.get("json");
4154
+ }
4155
+ function getOutputFilter() {
4156
+ return filterSlot.get();
3729
4157
  }
3730
4158
 
3731
4159
  // ../common/src/telemetry/command-terminal.ts
@@ -3846,17 +4274,8 @@ function terminalSignalFor(input, outcome) {
3846
4274
  }
3847
4275
  return outcome === "cancelled" ? "SIGINT" : undefined;
3848
4276
  }
3849
- function classifyHttpStatus(status) {
3850
- if (status === 401 || status === 403) {
3851
- return "auth";
3852
- }
3853
- if (status === 400 || status === 409 || status === 422) {
3854
- return "validation";
3855
- }
3856
- if (status === 408) {
3857
- return "timeout";
3858
- }
3859
- return "network_http";
4277
+ function classifyFailingHttpStatus(status) {
4278
+ return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
3860
4279
  }
3861
4280
  function classifyFromResult(result) {
3862
4281
  switch (result) {
@@ -3936,7 +4355,7 @@ function classifyError2(input) {
3936
4355
  }
3937
4356
  const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
3938
4357
  if (status !== undefined) {
3939
- return classifyHttpStatus(status);
4358
+ return classifyFailingHttpStatus(status);
3940
4359
  }
3941
4360
  return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
3942
4361
  }
@@ -3968,6 +4387,7 @@ function buildCommandTerminalTelemetryProperties(input) {
3968
4387
  var CommonTelemetryEvents = {
3969
4388
  Start: "Application.Start",
3970
4389
  Error: "Application.Error",
4390
+ ProjectActivity: "Cli.ProjectActivity",
3971
4391
  ShipSucceeded: "Cli.ShipSucceeded"
3972
4392
  };
3973
4393
 
@@ -4485,87 +4905,21 @@ class TelemetryService {
4485
4905
  return hex;
4486
4906
  }
4487
4907
  }
4488
- // ../common/src/timings.ts
4489
- var TIMINGS_ENV_VAR = "UIP_TIMINGS";
4490
- function createStorage2() {
4491
- const [error, mod] = catchError(() => __require("node:async_hooks"));
4492
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
4493
- return {
4494
- getStore: () => {
4495
- return;
4496
- },
4497
- run: (_store, fn) => fn()
4498
- };
4499
- }
4500
- return new mod.AsyncLocalStorage;
4501
- }
4502
- var storageSlot = singleton("TimingStorage");
4503
- var stateSlot = singleton("Timings");
4504
- var rootStartedSlot = singleton("TimingsRootStarted");
4505
- var longLivedHostSlot = singleton("TimingsLongLivedHost");
4506
- var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
4507
- function newState(baseline) {
4508
- return { baseline, httpMs: 0, httpCalls: 0 };
4509
- }
4510
- function getState() {
4511
- const scoped = storage.getStore();
4512
- if (scoped) {
4513
- return scoped;
4514
- }
4515
- const pinned = livePinnedState();
4516
- if (pinned !== undefined) {
4517
- return pinned;
4518
- }
4519
- return newState(processStartIsInvocationStart() ? 0 : performance.now());
4520
- }
4521
- function livePinnedState() {
4522
- const pinned = stateSlot.get();
4523
- return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
4524
- }
4525
- function processStartIsInvocationStart() {
4526
- return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
4527
- }
4528
- function timingsEnabled() {
4529
- if (typeof process === "undefined") {
4530
- return false;
4531
- }
4532
- const value = process.env?.[TIMINGS_ENV_VAR];
4533
- if (value === undefined) {
4534
- return false;
4535
- }
4536
- const normalized = value.trim().toLowerCase();
4537
- return normalized === "1" || normalized === "true";
4538
- }
4539
- function recordExitCode(exitCode) {
4540
- if (!timingsEnabled()) {
4541
- return;
4542
- }
4543
- getState().exitCode = exitCode;
4544
- }
4545
- function invocationStartedAt() {
4546
- return new Date(performance.timeOrigin + getState().baseline);
4547
- }
4548
- function invocationElapsedMs() {
4549
- return performance.now() - getState().baseline;
4550
- }
4551
- function markCommandStart() {
4552
- if (!timingsEnabled()) {
4553
- return;
4554
- }
4555
- getState().commandStart = performance.now();
4556
- }
4557
- function recordCommandDuration(durationMs) {
4558
- if (!timingsEnabled()) {
4559
- return;
4560
- }
4561
- getState().commandMs = durationMs;
4562
- }
4563
4908
  // ../common/src/telemetry/proxy-http-agent.ts
4564
4909
  var slot = singleton("ProxyAuthHttpsAgent");
4565
4910
 
4566
4911
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
4567
4912
  var providerSlot = singleton("TelemetryProvider");
4568
4913
 
4914
+ // ../common/src/telemetry/telemetry-config.ts
4915
+ function isTelemetryDisabled() {
4916
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
4917
+ return value === "1" || value === "true";
4918
+ }
4919
+ function isProjectTelemetryDisabled() {
4920
+ return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
4921
+ }
4922
+
4569
4923
  // ../common/src/telemetry/telemetry-spool.ts
4570
4924
  var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
4571
4925
  var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
@@ -4601,7 +4955,6 @@ var telemetry = new Proxy({}, {
4601
4955
  return typeof value === "function" ? value.bind(instance) : value;
4602
4956
  }
4603
4957
  });
4604
-
4605
4958
  // ../common/src/formatter.ts
4606
4959
  var ANSI_STYLES = {
4607
4960
  red: "\x1B[31m",
@@ -4611,46 +4964,6 @@ var ANSI_RESET = "\x1B[0m";
4611
4964
  function styleLine(line, style) {
4612
4965
  return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
4613
4966
  }
4614
- var CLI_ERROR_CODES = [
4615
- "invalid_argument",
4616
- "authentication_required",
4617
- "permission_denied",
4618
- "local_permission_denied",
4619
- "not_found",
4620
- "rate_limited",
4621
- "network_error",
4622
- "timeout",
4623
- "server_error",
4624
- "method_not_allowed",
4625
- "not_supported",
4626
- "configuration_error",
4627
- "execution_failed",
4628
- "unknown_error"
4629
- ];
4630
- var RETRY_HINTS = [
4631
- "RetryWillNotFix",
4632
- "RetryLater",
4633
- "RetryAfter1Second",
4634
- "RetryAfter10Seconds",
4635
- "RetryAfter30Seconds",
4636
- "RetryAfter60Seconds"
4637
- ];
4638
- var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
4639
- var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
4640
- function isCliErrorCode(value) {
4641
- return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
4642
- }
4643
- function isRetryHint(value) {
4644
- return typeof value === "string" && RETRY_HINT_VALUES.has(value);
4645
- }
4646
- var RESULTS = {
4647
- Success: "Success",
4648
- Failure: "Failure",
4649
- ConfigError: "ConfigError",
4650
- AuthenticationError: "AuthenticationError",
4651
- ValidationError: "ValidationError",
4652
- TimeoutError: "TimeoutError"
4653
- };
4654
4967
  var EXIT_CODES = {
4655
4968
  Success: 0,
4656
4969
  Failure: 1,
@@ -4659,6 +4972,9 @@ var EXIT_CODES = {
4659
4972
  ValidationError: 3,
4660
4973
  TimeoutError: 4
4661
4974
  };
4975
+ function exitCodeForResult(result) {
4976
+ return EXIT_CODES[result] ?? EXIT_CODES.Failure;
4977
+ }
4662
4978
  function escapeNonAscii(jsonText) {
4663
4979
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
4664
4980
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -5334,8 +5650,8 @@ function carriesOnlyNulls(value) {
5334
5650
  }
5335
5651
  return false;
5336
5652
  }
5337
- function nameList(names, cap2 = 12) {
5338
- const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
5653
+ function nameList(names, cap = 12) {
5654
+ const shown = names.slice(0, cap).map((n) => `\`${n}\``);
5339
5655
  const rest = names.length - shown.length;
5340
5656
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
5341
5657
  }
@@ -5472,40 +5788,11 @@ function defaultErrorCodeForResult(result) {
5472
5788
  return "unknown_error";
5473
5789
  }
5474
5790
  }
5475
- function parseHttpStatusFromMessage2(message) {
5476
- const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
5477
- if (!match)
5478
- return;
5479
- const status = Number(match[1]);
5480
- return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
5481
- }
5482
- function defaultErrorCodeForHttpStatus(status) {
5483
- if (status === undefined)
5484
- return;
5485
- if (status === 400 || status === 409 || status === 422) {
5486
- return "invalid_argument";
5487
- }
5488
- if (status === 401)
5489
- return "authentication_required";
5490
- if (status === 403)
5491
- return "permission_denied";
5492
- if (status === 404)
5493
- return "not_found";
5494
- if (status === 405)
5495
- return "method_not_allowed";
5496
- if (status === 408)
5497
- return "timeout";
5498
- if (status === 429)
5499
- return "rate_limited";
5500
- if (status >= 500 && status < 600)
5501
- return "server_error";
5502
- return;
5503
- }
5504
5791
  var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
5505
5792
  function defaultErrorCodeForFailure(data) {
5506
5793
  if (data.Result === RESULTS.Failure) {
5507
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
5508
- const errorCode = defaultErrorCodeForHttpStatus(status);
5794
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
5795
+ const errorCode = classifyHttpStatus(status)?.errorCode;
5509
5796
  if (errorCode)
5510
5797
  return errorCode;
5511
5798
  if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
@@ -5514,17 +5801,6 @@ function defaultErrorCodeForFailure(data) {
5514
5801
  }
5515
5802
  return defaultErrorCodeForResult(data.Result);
5516
5803
  }
5517
- function defaultRetryForErrorCode(errorCode) {
5518
- switch (errorCode) {
5519
- case "network_error":
5520
- case "rate_limited":
5521
- case "server_error":
5522
- case "timeout":
5523
- return "RetryLater";
5524
- default:
5525
- return "RetryWillNotFix";
5526
- }
5527
- }
5528
5804
  var OutputFormatter;
5529
5805
  ((OutputFormatter) => {
5530
5806
  function success(data, options) {
@@ -5556,7 +5832,7 @@ var OutputFormatter;
5556
5832
  data.Log ??= getLogFilePath() || undefined;
5557
5833
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
5558
5834
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
5559
- const exitCode = EXIT_CODES[data.Result] ?? 1;
5835
+ const exitCode = exitCodeForResult(data.Result);
5560
5836
  setExitCode(exitCode);
5561
5837
  recordCommandFailureTelemetry({
5562
5838
  result: data.Result,
@@ -5623,66 +5899,255 @@ var OutputFormatter;
5623
5899
  }
5624
5900
  }
5625
5901
  }
5626
- OutputFormatter.log = log;
5627
- function formatToString(data) {
5628
- const filter = getOutputFilter();
5629
- const envelope = data;
5630
- if ("Data" in data && data.Data != null) {
5631
- data.Data = normalizeDataKeys(data.Data);
5632
- if (filter) {
5633
- let note;
5634
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5635
- note = n;
5636
- }));
5637
- if (note) {
5638
- envelope.Warning = appendWarning(envelope.Warning, note);
5639
- }
5902
+ OutputFormatter.log = log;
5903
+ function formatToString(data) {
5904
+ const filter = getOutputFilter();
5905
+ const envelope = data;
5906
+ if ("Data" in data && data.Data != null) {
5907
+ data.Data = normalizeDataKeys(data.Data);
5908
+ if (filter) {
5909
+ let note;
5910
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5911
+ note = n;
5912
+ }));
5913
+ if (note) {
5914
+ envelope.Warning = appendWarning(envelope.Warning, note);
5915
+ }
5916
+ }
5917
+ }
5918
+ const output = normalizeOutputKeys(envelope);
5919
+ const lines = [];
5920
+ const sink = getOutputSink();
5921
+ printOutput(output, getOutputFormat(), (msg) => {
5922
+ lines.push(msg);
5923
+ }, needsAsciiSafeJson(sink));
5924
+ return lines.join(`
5925
+ `);
5926
+ }
5927
+ OutputFormatter.formatToString = formatToString;
5928
+ })(OutputFormatter ||= {});
5929
+
5930
+ // ../common/src/pass-through-tail.ts
5931
+ function maybeOption(arg) {
5932
+ return arg.length > 1 && arg[0] === "-";
5933
+ }
5934
+ function tokenizeTail(cmd, tail) {
5935
+ const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
5936
+ const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
5937
+ const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
5938
+ const tokens = [];
5939
+ let firstUnknown = -1;
5940
+ let sentinel = -1;
5941
+ let variadic;
5942
+ let group;
5943
+ let groupIndex = 0;
5944
+ let i = 0;
5945
+ while (i < tail.length || group !== undefined) {
5946
+ const index = group === undefined ? i : groupIndex;
5947
+ const arg = group ?? tail[i++];
5948
+ group = undefined;
5949
+ if (arg === "--") {
5950
+ sentinel = index;
5951
+ tokens.push({ kind: "sentinel", index });
5952
+ for (let j = i;j < tail.length; j++) {
5953
+ tokens.push({
5954
+ kind: "operand",
5955
+ index: j,
5956
+ text: tail[j],
5957
+ literal: true
5958
+ });
5959
+ }
5960
+ break;
5961
+ }
5962
+ if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
5963
+ tokens.push({
5964
+ kind: "option",
5965
+ index,
5966
+ text: arg,
5967
+ option: variadic,
5968
+ value: arg
5969
+ });
5970
+ continue;
5971
+ }
5972
+ variadic = undefined;
5973
+ if (maybeOption(arg)) {
5974
+ const option = find(arg);
5975
+ if (option) {
5976
+ let value;
5977
+ if (option.required) {
5978
+ value = tail[i];
5979
+ if (value !== undefined)
5980
+ i++;
5981
+ } else if (option.optional) {
5982
+ const next = tail[i];
5983
+ if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
5984
+ value = next;
5985
+ i++;
5986
+ }
5987
+ }
5988
+ tokens.push({
5989
+ kind: "option",
5990
+ index,
5991
+ text: arg,
5992
+ option,
5993
+ ...value === undefined ? {} : { value }
5994
+ });
5995
+ variadic = option.variadic ? option : undefined;
5996
+ continue;
5997
+ }
5998
+ }
5999
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
6000
+ const option = find(`-${arg[1]}`);
6001
+ if (option) {
6002
+ if (option.required || option.optional) {
6003
+ tokens.push({
6004
+ kind: "option",
6005
+ index,
6006
+ text: arg,
6007
+ option,
6008
+ value: arg.slice(2)
6009
+ });
6010
+ } else {
6011
+ tokens.push({ kind: "option", index, text: arg, option });
6012
+ group = `-${arg.slice(2)}`;
6013
+ groupIndex = index;
6014
+ }
6015
+ continue;
6016
+ }
6017
+ }
6018
+ if (/^--[^=]+=/.test(arg)) {
6019
+ const equals = arg.indexOf("=");
6020
+ const option = find(arg.slice(0, equals));
6021
+ if (option && (option.required || option.optional)) {
6022
+ tokens.push({
6023
+ kind: "option",
6024
+ index,
6025
+ text: arg,
6026
+ option,
6027
+ value: arg.slice(equals + 1)
6028
+ });
6029
+ continue;
6030
+ }
6031
+ }
6032
+ if (maybeOption(arg) && !negativeNumber(arg)) {
6033
+ const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
6034
+ if (firstUnknown === -1)
6035
+ firstUnknown = index;
6036
+ tokens.push({
6037
+ kind: "unknown",
6038
+ index,
6039
+ text: arg,
6040
+ flag: equals > 0 ? arg.slice(0, equals) : arg,
6041
+ ...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
6042
+ });
6043
+ continue;
6044
+ }
6045
+ tokens.push({ kind: "operand", index, text: arg, literal: false });
6046
+ }
6047
+ return { tokens, firstUnknown, sentinel };
6048
+ }
6049
+
6050
+ // ../common/src/project-telemetry.ts
6051
+ var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
6052
+ var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
6053
+ var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
6054
+ var RULES = Symbol.for("@uipath/common/projectTargetRules");
6055
+ function logSkipped(what, error) {
6056
+ logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
6057
+ }
6058
+ function bounded(work, what) {
6059
+ return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
6060
+ }
6061
+ async function identityWithContext(command, identity) {
6062
+ const props = projectIdentityProperties(identity);
6063
+ if (!identity.projectDirectory || isProjectTelemetryDisabled())
6064
+ return props;
6065
+ for (let node = command;node; node = node.parent ?? undefined) {
6066
+ const resolver = node[CONTEXT_RESOLVER];
6067
+ if (typeof resolver !== "function")
6068
+ continue;
6069
+ try {
6070
+ return {
6071
+ ...await resolver(identity.projectDirectory),
6072
+ ...props
6073
+ };
6074
+ } catch (error) {
6075
+ logSkipped("solution context lookup", error);
6076
+ return props;
6077
+ }
6078
+ }
6079
+ return props;
6080
+ }
6081
+ function getProjectTelemetryResolver(command) {
6082
+ for (let node = command;node; node = node.parent) {
6083
+ const resolver = node[RESOLVER];
6084
+ if (typeof resolver === "function")
6085
+ return resolver;
6086
+ }
6087
+ return;
6088
+ }
6089
+ function attachProjectTelemetryCapture(command, capture) {
6090
+ command[CAPTURE] = capture;
6091
+ }
6092
+ class ProjectTelemetrySession {
6093
+ resolver;
6094
+ command;
6095
+ target;
6096
+ props = {};
6097
+ explicit = false;
6098
+ input;
6099
+ constructor(resolver, command) {
6100
+ this.resolver = resolver;
6101
+ this.command = command;
6102
+ }
6103
+ async setTarget(path) {
6104
+ this.target = path;
6105
+ if (this.input) {
6106
+ await this.resolve({
6107
+ ...this.input,
6108
+ phase: "after",
6109
+ success: true
6110
+ });
6111
+ this.explicit = true;
6112
+ }
6113
+ }
6114
+ async setIdentity(identity) {
6115
+ try {
6116
+ const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
6117
+ if (props !== undefined)
6118
+ this.setProperties(props);
6119
+ } catch (error) {
6120
+ logSkipped("project identity capture", error);
6121
+ }
6122
+ }
6123
+ setProperties(properties) {
6124
+ try {
6125
+ this.props = { ...properties };
6126
+ this.explicit = true;
6127
+ } catch (error) {
6128
+ logSkipped("project identity properties", error);
6129
+ }
6130
+ }
6131
+ properties() {
6132
+ return { ...this.props };
6133
+ }
6134
+ async resolve(input) {
6135
+ this.input = input;
6136
+ if (this.explicit)
6137
+ return;
6138
+ try {
6139
+ const props = await bounded(this.resolver({
6140
+ ...input,
6141
+ target: this.target
6142
+ }), `project identity (${input.phase})`);
6143
+ if (props !== undefined) {
6144
+ this.props = props;
5640
6145
  }
6146
+ } catch (error) {
6147
+ logSkipped(`project identity (${input.phase})`, error);
5641
6148
  }
5642
- const output = normalizeOutputKeys(envelope);
5643
- const lines = [];
5644
- const sink = getOutputSink();
5645
- printOutput(output, getOutputFormat(), (msg) => {
5646
- lines.push(msg);
5647
- }, needsAsciiSafeJson(sink));
5648
- return lines.join(`
5649
- `);
5650
6149
  }
5651
- OutputFormatter.formatToString = formatToString;
5652
- })(OutputFormatter ||= {});
5653
- // ../../node_modules/commander/esm.mjs
5654
- var import__ = __toESM(require_commander(), 1);
5655
- var {
5656
- program,
5657
- createCommand,
5658
- createArgument,
5659
- createOption,
5660
- CommanderError,
5661
- InvalidArgumentError,
5662
- InvalidOptionArgumentError,
5663
- Command,
5664
- Argument,
5665
- Option,
5666
- Help
5667
- } = import__.default;
5668
-
5669
- // ../common/src/command-examples.ts
5670
- var examplesByCommand = new WeakMap;
5671
- Command.prototype.examples = function(examples) {
5672
- examplesByCommand.set(this, examples);
5673
- return this;
5674
- };
5675
- // ../common/src/preview.ts
5676
- var previewSlot = singleton("PreviewBuild");
5677
- function isPreviewBuild() {
5678
- return previewSlot.get(false) ?? false;
5679
6150
  }
5680
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
5681
- if (isPreviewBuild()) {
5682
- return this.command(nameAndArgs, opts);
5683
- }
5684
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
5685
- };
5686
6151
 
5687
6152
  // ../common/src/telemetry/command-attribution.ts
5688
6153
  var LEGACY_SKILL_NAMESPACE = "uipath:";
@@ -5928,8 +6393,7 @@ var pollSignalSlot = singleton("PollSignal");
5928
6393
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
5929
6394
  var processContext = {
5930
6395
  exit: (code) => {
5931
- recordExitCode(code);
5932
- setExitCode(code);
6396
+ recordCommandExit(code);
5933
6397
  },
5934
6398
  get pollSignal() {
5935
6399
  return pollSignalSlot.get();
@@ -5954,6 +6418,8 @@ function recordableArgValue(value, choices) {
5954
6418
  function extractCommandParams(cmd) {
5955
6419
  const params = {};
5956
6420
  forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
6421
+ if (name === undefined)
6422
+ return;
5957
6423
  const recordable = recordableArgValue(value, choices);
5958
6424
  params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5959
6425
  });
@@ -5969,7 +6435,8 @@ function isDefaultedPositional(cmd, index) {
5969
6435
  function forEachSuppliedArgument(cmd, visit) {
5970
6436
  const registered = cmd.registeredArguments ?? [];
5971
6437
  const processed = cmd.processedArgs ?? [];
5972
- for (let i = 0;i < registered.length; i++) {
6438
+ const bound = boundPositionalCount(cmd);
6439
+ for (let i = 0;i < bound; i++) {
5973
6440
  const name = registered[i].name();
5974
6441
  if (name && processed[i] !== undefined) {
5975
6442
  visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
@@ -5984,6 +6451,71 @@ function forEachSuppliedArgument(cmd, visit) {
5984
6451
  visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5985
6452
  }
5986
6453
  }
6454
+ forEachPassThroughToken(cmd, bound, (name, value) => {
6455
+ visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
6456
+ });
6457
+ }
6458
+ function boundPositionalCount(cmd) {
6459
+ const registered = cmd.registeredArguments ?? [];
6460
+ if (registered.some((argument) => argument.variadic)) {
6461
+ return registered.length;
6462
+ }
6463
+ if ((cmd.args ?? []).length <= registered.length) {
6464
+ return registered.length;
6465
+ }
6466
+ const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
6467
+ return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
6468
+ }
6469
+ function forEachPassThroughToken(cmd, bound, visit) {
6470
+ const registered = cmd.registeredArguments ?? [];
6471
+ const fillsPositionals = !registered.some((argument) => argument.variadic);
6472
+ const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
6473
+ const repeated = new Map;
6474
+ let nextPositional = bound;
6475
+ for (const token of tokens) {
6476
+ const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
6477
+ if (token.kind === "sentinel")
6478
+ continue;
6479
+ if (token.kind === "operand") {
6480
+ const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
6481
+ const name = claimable ? registered[nextPositional++].name() : undefined;
6482
+ visit(name || undefined, token.text);
6483
+ continue;
6484
+ }
6485
+ if (token.kind === "unknown") {
6486
+ const bare = token.flag.replace(/^-+/, "");
6487
+ const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
6488
+ const keyable = token.flag.startsWith("--") || token.flag.length === 2;
6489
+ if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
6490
+ visit(key, token.inlineValue ?? true);
6491
+ } else {
6492
+ visit(undefined, token.text);
6493
+ if (token.inlineValue !== undefined) {
6494
+ visit(undefined, token.inlineValue);
6495
+ } else if (!token.flag.startsWith("--") && token.flag.length > 2) {
6496
+ visit(undefined, token.flag.slice(2));
6497
+ }
6498
+ }
6499
+ continue;
6500
+ }
6501
+ if (pastUnknown) {
6502
+ visit(undefined, token.text);
6503
+ if (token.value !== undefined)
6504
+ visit(undefined, token.value);
6505
+ continue;
6506
+ }
6507
+ const option = token.option;
6508
+ const name = option.attributeName();
6509
+ const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
6510
+ const previous = repeated.get(name);
6511
+ if (previous) {
6512
+ previous.push(value);
6513
+ visit(name, previous);
6514
+ } else {
6515
+ repeated.set(name, [value]);
6516
+ visit(name, value);
6517
+ }
6518
+ }
5987
6519
  }
5988
6520
  function withheldArgumentValues(cmd) {
5989
6521
  const values = [];
@@ -6045,6 +6577,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
6045
6577
  const telemetryName = commandTelemetryName(commandParts);
6046
6578
  const commandPath = commandInvocationPath(commandParts);
6047
6579
  const props = typeof properties === "function" ? properties(...args) : properties;
6580
+ const projectResolver = getProjectTelemetryResolver(command);
6581
+ const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
6048
6582
  markCommandStart();
6049
6583
  const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
6050
6584
  try {
@@ -6057,6 +6591,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
6057
6591
  if (violation) {
6058
6592
  return Promise.reject(violation);
6059
6593
  }
6594
+ if (projectSession) {
6595
+ return projectSession.resolve({ command, args, phase: "before" }).then(() => {
6596
+ attachProjectTelemetryCapture(command, projectSession);
6597
+ return fn(...args);
6598
+ });
6599
+ }
6060
6600
  return fn(...args);
6061
6601
  }));
6062
6602
  if (error) {
@@ -6065,22 +6605,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
6065
6605
  const typed = error;
6066
6606
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
6067
6607
  const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
6068
- const finalResult = customResult ?? RESULTS.Failure;
6608
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6609
+ const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
6610
+ const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
6069
6611
  const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
6070
6612
  const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
6071
6613
  const typedRetry = typed.retry ?? typed.Retry;
6072
6614
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
6073
6615
  const typedContext = typed.context ?? typed.Context;
6074
6616
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
6075
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6076
6617
  fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
6618
+ const errorCode = customErrorCode ?? classified?.errorCode;
6619
+ const retry = customRetry ?? classified?.retry;
6620
+ const errorContext = customContext ?? classified?.context;
6077
6621
  OutputFormatter.error({
6078
6622
  Result: finalResult,
6079
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
6623
+ ...errorCode ? { ErrorCode: errorCode } : {},
6080
6624
  Message: errorMessage,
6081
6625
  Instructions: customInstructions ?? commandHelpHint(commandPath),
6082
- ...customRetry ? { Retry: customRetry } : {},
6083
- ...customContext ? { Context: customContext } : {}
6626
+ ...retry ? { Retry: retry } : {},
6627
+ ...errorContext ? { Context: errorContext } : {}
6084
6628
  });
6085
6629
  context.exit(fallbackExitCode);
6086
6630
  }
@@ -6089,6 +6633,14 @@ Command.prototype.trackedAction = function(context, fn, properties) {
6089
6633
  const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
6090
6634
  const recordedFailure = takeRecordedCommandFailureTelemetry();
6091
6635
  const success = !error && exitCode === 0;
6636
+ if (projectSession) {
6637
+ await projectSession.resolve({
6638
+ command,
6639
+ args,
6640
+ phase: "after",
6641
+ success
6642
+ });
6643
+ }
6092
6644
  const terminalTelemetry = buildCommandTerminalTelemetryProperties({
6093
6645
  error,
6094
6646
  exitCode,
@@ -6106,6 +6658,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
6106
6658
  }
6107
6659
  const baseProperties = redactProperties({
6108
6660
  ...commandParams,
6661
+ ...projectSession?.properties(),
6109
6662
  ...props,
6110
6663
  ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
6111
6664
  ...buildAgentSessionTelemetry(process.env),
@@ -6116,6 +6669,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
6116
6669
  });
6117
6670
  emitInvocationRequest(telemetryName, success, baseProperties);
6118
6671
  } finally {
6672
+ if (projectSession)
6673
+ attachProjectTelemetryCapture(command, undefined);
6119
6674
  releaseSuppliedArgumentValues(supplied);
6120
6675
  }
6121
6676
  });
@@ -6420,7 +6975,7 @@ function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
6420
6975
  }
6421
6976
  var TENANT_SWITCH_COMMAND = "uip login tenant set <tenant>";
6422
6977
  function createHiddenDeprecatedTenantOption(flags = "-t, --tenant <tenant-name>") {
6423
- return new Option(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
6978
+ return new Option2(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
6424
6979
  warnDeprecatedTenantOption(tenant);
6425
6980
  return tenant;
6426
6981
  });
@@ -6706,9 +7261,9 @@ function getProfileStorage() {
6706
7261
  if (isAuthProfileStorage(existing)) {
6707
7262
  return existing;
6708
7263
  }
6709
- const storage2 = createProfileStorage();
6710
- globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
6711
- return storage2;
7264
+ const storage = createProfileStorage();
7265
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
7266
+ return storage;
6712
7267
  }
6713
7268
  var profileStorage = getProfileStorage();
6714
7269
 
@@ -6739,8 +7294,8 @@ function resolveAuthProfileFilePath(profile) {
6739
7294
  if (normalized === undefined) {
6740
7295
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
6741
7296
  }
6742
- const fs2 = getFileSystem();
6743
- return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
7297
+ const fs = getFileSystem();
7298
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
6744
7299
  }
6745
7300
  function getActiveAuthProfileFilePath() {
6746
7301
  const profile = getActiveAuthProfile();
@@ -6913,6 +7468,8 @@ var ENV_AUTH_VARS = {
6913
7468
  };
6914
7469
 
6915
7470
  class EnvAuthConfigError extends Error {
7471
+ errorCode = "configuration_error";
7472
+ retry = "RetryWillNotFix";
6916
7473
  constructor(message) {
6917
7474
  super(message);
6918
7475
  this.name = "EnvAuthConfigError";
@@ -6951,11 +7508,11 @@ var readAuthFromEnv = () => {
6951
7508
  if (!rawUrl) {
6952
7509
  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}).`);
6953
7510
  }
6954
- const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
7511
+ const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
6955
7512
  return {
6956
7513
  loginStatus: "Logged in",
6957
7514
  accessToken,
6958
- baseUrl: baseUrl2,
7515
+ baseUrl,
6959
7516
  organizationName,
6960
7517
  organizationId,
6961
7518
  tenantName,
@@ -6996,8 +7553,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
6996
7553
  async function refreshTokenFingerprint(refreshToken) {
6997
7554
  const bytes = new TextEncoder().encode(refreshToken);
6998
7555
  if (globalThis.crypto?.subtle) {
6999
- const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
7000
- return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
7556
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
7557
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
7001
7558
  }
7002
7559
  const { createHash } = await import("node:crypto");
7003
7560
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -7006,9 +7563,9 @@ function breakerPathFor(authPath) {
7006
7563
  return `${authPath}${BREAKER_SUFFIX}`;
7007
7564
  }
7008
7565
  async function loadRefreshBreaker(authPath) {
7009
- const fs2 = getFileSystem();
7566
+ const fs = getFileSystem();
7010
7567
  try {
7011
- const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
7568
+ const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
7012
7569
  if (!content)
7013
7570
  return {};
7014
7571
  const parsed = JSON.parse(content);
@@ -7019,20 +7576,20 @@ async function loadRefreshBreaker(authPath) {
7019
7576
  }
7020
7577
  async function saveRefreshBreaker(authPath, state) {
7021
7578
  try {
7022
- const fs2 = getFileSystem();
7023
- const path2 = breakerPathFor(authPath);
7024
- await fs2.mkdir(fs2.path.dirname(path2));
7025
- const tempPath = `${path2}.tmp`;
7026
- await fs2.writeFile(tempPath, JSON.stringify(state));
7027
- await fs2.rename(tempPath, path2);
7579
+ const fs = getFileSystem();
7580
+ const path = breakerPathFor(authPath);
7581
+ await fs.mkdir(fs.path.dirname(path));
7582
+ const tempPath = `${path}.tmp`;
7583
+ await fs.writeFile(tempPath, JSON.stringify(state));
7584
+ await fs.rename(tempPath, path);
7028
7585
  } catch {}
7029
7586
  }
7030
7587
  async function clearRefreshBreaker(authPath) {
7031
- const fs2 = getFileSystem();
7032
- const path2 = breakerPathFor(authPath);
7588
+ const fs = getFileSystem();
7589
+ const path = breakerPathFor(authPath);
7033
7590
  try {
7034
- if (await fs2.exists(path2)) {
7035
- await fs2.rm(path2);
7591
+ if (await fs.exists(path)) {
7592
+ await fs.rm(path);
7036
7593
  }
7037
7594
  } catch {}
7038
7595
  }
@@ -7053,13 +7610,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
7053
7610
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
7054
7611
  var PIPE_NAME_MAX_LENGTH = 103;
7055
7612
  var getRobotIpcPipeNames = async () => {
7056
- const fs2 = getFileSystem();
7057
- const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
7613
+ const fs = getFileSystem();
7614
+ const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
7058
7615
  if (!username) {
7059
7616
  throw new Error("Unable to determine current username");
7060
7617
  }
7061
- const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
7062
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
7618
+ const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
7619
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
7063
7620
  };
7064
7621
  var defaultIsRobotIpcAvailable = async () => {
7065
7622
  if (process.platform === "win32") {
@@ -7069,20 +7626,20 @@ var defaultIsRobotIpcAvailable = async () => {
7069
7626
  if (pipeNamesError || !pipeNames) {
7070
7627
  return false;
7071
7628
  }
7072
- const fs2 = getFileSystem();
7629
+ const fs = getFileSystem();
7073
7630
  for (const pipeName of pipeNames) {
7074
- const [existsError, exists] = await catchError2(fs2.exists(pipeName));
7631
+ const [existsError, exists] = await catchError2(fs.exists(pipeName));
7075
7632
  if (!existsError && exists === true) {
7076
7633
  return true;
7077
7634
  }
7078
7635
  }
7079
7636
  return false;
7080
7637
  };
7081
- var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
7638
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
7082
7639
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
7083
7640
  promise.then((value) => {
7084
7641
  clearTimeout(timer);
7085
- resolve2(value);
7642
+ resolve(value);
7086
7643
  }, (error) => {
7087
7644
  clearTimeout(timer);
7088
7645
  reject(error);
@@ -7255,9 +7812,12 @@ var refreshAccessToken = async ({
7255
7812
  body: tokenParams
7256
7813
  });
7257
7814
  const tokenData = await tokenResponse.json();
7258
- if (!tokenResponse.ok) {
7815
+ if (tokenResponse.status === 400 || tokenResponse.status === 401) {
7259
7816
  throw new TokenRefreshOAuthError;
7260
7817
  }
7818
+ if (!tokenResponse.ok) {
7819
+ throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
7820
+ }
7261
7821
  const newAccessToken = tokenData.access_token;
7262
7822
  const newRefreshToken = tokenData.refresh_token;
7263
7823
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
@@ -7289,9 +7849,9 @@ var errorCode = (err) => {
7289
7849
  }
7290
7850
  return "EUNKNOWN";
7291
7851
  };
7292
- var probeAsync = async (fs2, candidate) => {
7852
+ var probeAsync = async (fs, candidate) => {
7293
7853
  try {
7294
- const stats = await fs2.stat(candidate);
7854
+ const stats = await fs.stat(candidate);
7295
7855
  if (stats === null) {
7296
7856
  return { exists: false };
7297
7857
  }
@@ -7318,36 +7878,36 @@ var probeAsync = async (fs2, candidate) => {
7318
7878
  }
7319
7879
  };
7320
7880
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
7321
- const fs2 = getFileSystem();
7322
- if (fs2.path.isAbsolute(envFilePath)) {
7323
- const probe2 = await probeAsync(fs2, envFilePath);
7324
- return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
7881
+ const fs = getFileSystem();
7882
+ if (fs.path.isAbsolute(envFilePath)) {
7883
+ const probe = await probeAsync(fs, envFilePath);
7884
+ return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
7325
7885
  exists: false,
7326
7886
  absolutePath: envFilePath,
7327
7887
  source: "absolute",
7328
- ...probe2.unusable ? { unusable: probe2.unusable } : {}
7888
+ ...probe.unusable ? { unusable: probe.unusable } : {}
7329
7889
  };
7330
7890
  }
7331
- const cwd = opts?.cwd ?? fs2.env.cwd();
7891
+ const cwd = opts?.cwd ?? fs.env.cwd();
7332
7892
  let searchDir = cwd;
7333
7893
  while (true) {
7334
- const candidate = fs2.path.join(searchDir, envFilePath);
7335
- const probe2 = await probeAsync(fs2, candidate);
7336
- if (probe2.exists) {
7894
+ const candidate = fs.path.join(searchDir, envFilePath);
7895
+ const probe = await probeAsync(fs, candidate);
7896
+ if (probe.exists) {
7337
7897
  return {
7338
7898
  exists: true,
7339
7899
  absolutePath: candidate,
7340
7900
  source: searchDir === cwd ? "cwd" : "ancestor"
7341
7901
  };
7342
7902
  }
7343
- const parentDir = fs2.path.dirname(searchDir);
7903
+ const parentDir = fs.path.dirname(searchDir);
7344
7904
  if (parentDir === searchDir) {
7345
7905
  break;
7346
7906
  }
7347
7907
  searchDir = parentDir;
7348
7908
  }
7349
- const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
7350
- const probe = await probeAsync(fs2, homePath);
7909
+ const homePath = fs.path.join(fs.env.homedir(), envFilePath);
7910
+ const probe = await probeAsync(fs, homePath);
7351
7911
  if (probe.exists) {
7352
7912
  return { exists: true, absolutePath: homePath, source: "home" };
7353
7913
  }
@@ -7390,12 +7950,12 @@ var parseEnvContent = (content) => {
7390
7950
  return env;
7391
7951
  };
7392
7952
  var loadEnvFileAsync = async ({ envPath }) => {
7393
- const fs2 = getFileSystem();
7394
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
7395
- if (!await fs2.exists(absolutePath)) {
7953
+ const fs = getFileSystem();
7954
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
7955
+ if (!await fs.exists(absolutePath)) {
7396
7956
  throw new Error(`Environment file not found: ${envPath}`);
7397
7957
  }
7398
- const content = await fs2.readFile(absolutePath, "utf-8");
7958
+ const content = await fs.readFile(absolutePath, "utf-8");
7399
7959
  if (content === null) {
7400
7960
  throw new Error(`Environment file not found: ${envPath}`);
7401
7961
  }
@@ -7406,10 +7966,10 @@ var saveEnvFileAsync = async ({
7406
7966
  data,
7407
7967
  merge = true
7408
7968
  }) => {
7409
- const fs2 = getFileSystem();
7410
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
7969
+ const fs = getFileSystem();
7970
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
7411
7971
  let existingData = {};
7412
- if (merge && await fs2.exists(absolutePath)) {
7972
+ if (merge && await fs.exists(absolutePath)) {
7413
7973
  try {
7414
7974
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
7415
7975
  } catch {}
@@ -7427,11 +7987,11 @@ var saveEnvFileAsync = async ({
7427
7987
  const content = `${lines.join(`
7428
7988
  `)}
7429
7989
  `;
7430
- const dir = fs2.path.dirname(absolutePath);
7431
- await fs2.mkdir(dir);
7990
+ const dir = fs.path.dirname(absolutePath);
7991
+ await fs.mkdir(dir);
7432
7992
  const tempPath = `${absolutePath}.tmp`;
7433
- await fs2.writeFile(tempPath, content);
7434
- await fs2.rename(tempPath, absolutePath);
7993
+ await fs.writeFile(tempPath, content);
7994
+ await fs.rename(tempPath, absolutePath);
7435
7995
  };
7436
7996
 
7437
7997
  // ../auth/src/loginStatus.ts
@@ -7555,11 +8115,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
7555
8115
  return { credentials };
7556
8116
  }
7557
8117
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
7558
- const fs2 = getFs();
7559
- const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
8118
+ const fs = getFs();
8119
+ const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
7560
8120
  if (absolutePath === globalPath)
7561
8121
  return;
7562
- if (!await fs2.exists(globalPath))
8122
+ if (!await fs.exists(globalPath))
7563
8123
  return;
7564
8124
  try {
7565
8125
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -7976,26 +8536,38 @@ function errorMessage(error) {
7976
8536
  }
7977
8537
 
7978
8538
  // ../auth/src/authContext.ts
8539
+ class AuthContextUnavailableError extends Error {
8540
+ instructionContext;
8541
+ sessionHint;
8542
+ errorCode = "authentication_required";
8543
+ retry = "RetryWillNotFix";
8544
+ constructor(message, instructionContext = "auth", sessionHint) {
8545
+ super(message);
8546
+ this.instructionContext = instructionContext;
8547
+ this.sessionHint = sessionHint;
8548
+ this.name = "AuthContextUnavailableError";
8549
+ }
8550
+ }
7979
8551
  var getAuthContext = async (options = {}) => {
7980
8552
  const status = await getLoginStatusAsync({
7981
8553
  ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
7982
8554
  envFilePath: options.envFilePath
7983
8555
  });
7984
8556
  if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
7985
- throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
8557
+ throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
7986
8558
  }
7987
- const tenantName = options.tenant ?? status.tenantName;
8559
+ const tenantName = options.tenant || status.tenantName;
7988
8560
  if (options.requireOrganizationId && !status.organizationId) {
7989
- throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
8561
+ throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
7990
8562
  }
7991
8563
  if (options.requireOrganizationName && !status.organizationName) {
7992
- throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
8564
+ throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
7993
8565
  }
7994
8566
  if (options.requireTenantId && !status.tenantId) {
7995
- throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
8567
+ throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
7996
8568
  }
7997
- if (options.requireTenantName && tenantName === undefined) {
7998
- 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.");
8569
+ if (options.requireTenantName && !tenantName) {
8570
+ 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");
7999
8571
  }
8000
8572
  return {
8001
8573
  baseUrl: status.baseUrl,
@@ -8017,27 +8589,44 @@ var TENANT_SELECTION_CODES = new Set([
8017
8589
  // src/services/feedback-service.ts
8018
8590
  var GUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8019
8591
  var ZERO_GUID = "00000000-0000-0000-0000-000000000000";
8020
- async function resolveAuth(tenant) {
8021
- const [loginError, loginStatus2] = await catchError(getLoginStatusAsync());
8022
- if (loginError) {
8023
- throw new Error(loginError.message);
8024
- }
8025
- if (loginStatus2.loginStatus !== "Logged in" || !loginStatus2.baseUrl) {
8026
- throw new Error("Not authenticated. Run 'uip auth login' first.");
8592
+
8593
+ class FeedbackApiError extends Error {
8594
+ errorCode;
8595
+ retry = "RetryWillNotFix";
8596
+ constructor(message, errorCode) {
8597
+ super(message);
8598
+ this.errorCode = errorCode;
8599
+ this.name = "FeedbackApiError";
8027
8600
  }
8028
- const tenantName = tenant ?? loginStatus2.tenantName;
8029
- if (!tenantName || !loginStatus2.organizationId) {
8030
- throw new Error("Missing tenant or organization info.");
8601
+ }
8602
+ var NOT_AUTHENTICATED = "Not authenticated. Run 'uip login' first.";
8603
+ async function resolveAuth(tenant) {
8604
+ const [authError, auth] = await catchError(getAuthContext({
8605
+ tenant,
8606
+ requireOrganizationId: true,
8607
+ requireTenantName: true
8608
+ }));
8609
+ if (authError) {
8610
+ if (carriedErrorCode(authError) === "authentication_required") {
8611
+ if (hasIdentityInstructionContext(authError)) {
8612
+ throw authError;
8613
+ }
8614
+ if (typeof authError === "object" && "sessionHint" in authError && typeof authError.sessionHint === "string") {
8615
+ throw authError;
8616
+ }
8617
+ throw new FeedbackApiError(NOT_AUTHENTICATED, "authentication_required");
8618
+ }
8619
+ throw authError;
8031
8620
  }
8032
8621
  return {
8033
- baseUrl: loginStatus2.baseUrl,
8034
- orgId: loginStatus2.organizationId,
8035
- tenantName,
8036
- token: loginStatus2.accessToken ?? ""
8622
+ baseUrl: auth.baseUrl,
8623
+ orgId: auth.organizationId,
8624
+ tenantName: auth.tenantName,
8625
+ token: auth.accessToken
8037
8626
  };
8038
8627
  }
8039
8628
  function feedbackBaseUrl(baseUrl, orgId, tenantName) {
8040
- return `${baseUrl}/${orgId}/${encodeURIComponent(tenantName)}/llmopstenant_/api/Feedback`;
8629
+ return `${baseUrl}/${encodeURIComponent(orgId)}/${encodeURIComponent(tenantName)}/llmopstenant_/api/Feedback`;
8041
8630
  }
8042
8631
  async function apiFetch(url, token, folderKey, method = "GET", body) {
8043
8632
  const headers = {
@@ -8056,13 +8645,13 @@ async function apiFetch(url, token, folderKey, method = "GET", body) {
8056
8645
  }
8057
8646
  async function handleErrorResponse(response, context) {
8058
8647
  if (response.status === 401) {
8059
- throw new Error("Not authenticated. Run 'uip auth login' first.");
8648
+ throw new FeedbackApiError(NOT_AUTHENTICATED, "authentication_required");
8060
8649
  }
8061
8650
  if (response.status === 403) {
8062
- throw new Error("Insufficient permissions. Ensure you have Logs.View / Logs.Create / Logs.Delete on this folder.");
8651
+ throw new FeedbackApiError("Insufficient permissions. Ensure you have Logs.View / Logs.Create / Logs.Delete on this folder.", "permission_denied");
8063
8652
  }
8064
8653
  if (response.status === 404) {
8065
- throw new Error(`${context} not found.`);
8654
+ throw new FeedbackApiError(`${context} not found.`, "not_found");
8066
8655
  }
8067
8656
  const text = await response.text();
8068
8657
  throw new Error(`Feedback API failed: ${response.status} ${response.statusText} - ${text}`);
@@ -8236,8 +8825,8 @@ async function readTextFile(filePath, label = "Comment") {
8236
8825
  }
8237
8826
  return Buffer.concat(chunks).toString("utf8");
8238
8827
  }
8239
- const fs2 = getFileSystem();
8240
- const content = await fs2.readFile(filePath, "utf-8");
8828
+ const fs = getFileSystem();
8829
+ const content = await fs.readFile(filePath, "utf-8");
8241
8830
  if (content === null) {
8242
8831
  throw new Error(`${label} file not found: ${filePath}`);
8243
8832
  }
@@ -8298,6 +8887,35 @@ async function resolveFeedbackText(code, sources) {
8298
8887
  }
8299
8888
  return values;
8300
8889
  }
8890
+ async function feedbackApiFailure(code, error, { permissions, fallback }) {
8891
+ const details = await extractErrorDetails(error);
8892
+ return {
8893
+ Result: RESULTS.Failure,
8894
+ Code: code,
8895
+ ErrorCode: details.errorCode,
8896
+ Message: details.message,
8897
+ Instructions: instructionsForFeedbackFailure(details.errorCode, error, {
8898
+ permissions,
8899
+ fallback
8900
+ }),
8901
+ Retry: details.retry,
8902
+ ...details.context ? { Context: details.context } : {}
8903
+ };
8904
+ }
8905
+ function instructionsForFeedbackFailure(errorCode, error, { permissions, fallback }) {
8906
+ switch (errorCode) {
8907
+ case "authentication_required":
8908
+ return instructionsFor("auth", error);
8909
+ case "permission_denied":
8910
+ return `Ask a tenant admin to grant ${permissions} on this folder.`;
8911
+ case "configuration_error":
8912
+ return instructionsFor("auth-configuration");
8913
+ case "local_permission_denied":
8914
+ return "Check access to the local file named in Message, then retry.";
8915
+ default:
8916
+ return fallback;
8917
+ }
8918
+ }
8301
8919
 
8302
8920
  // src/commands/feedback/create.ts
8303
8921
  var FEEDBACK_CREATE_EXAMPLES = [
@@ -8310,8 +8928,8 @@ var FEEDBACK_CREATE_EXAMPLES = [
8310
8928
  }
8311
8929
  }
8312
8930
  ];
8313
- function registerCreateCommand(program2) {
8314
- program2.command("create").description("Create feedback for a trace").examples(FEEDBACK_CREATE_EXAMPLES).option("--trace-id <id>", "Trace ID (32-char hex or GUID)").option("--positive", "Mark as positive feedback").option("--negative", "Mark as negative feedback").option("--span-id <id>", "Span ID (defaults to root span of trace)").option("--comment <text>", "Free-text annotation (max 1048576 chars)").option("--comment-file <file>", "Read comment from file; use '-' for stdin").option("--category <tag>", 'Category tag, repeatable. Built-in defaults: "Output", "Agent Error", "Agent Plan Execution"', collect, []).option("--agent-id <guid>", "Agent reference ID").option("--agent-version <str>", "Agent version (max 100 chars)").option("--folder-key <guid>", "Folder key (required for write ops)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (opts) => {
8931
+ function registerCreateCommand(program) {
8932
+ program.command("create").description("Create feedback for a trace").examples(FEEDBACK_CREATE_EXAMPLES).option("--trace-id <id>", "Trace ID (32-char hex or GUID)").option("--positive", "Mark as positive feedback").option("--negative", "Mark as negative feedback").option("--span-id <id>", "Span ID (defaults to root span of trace)").option("--comment <text>", "Free-text annotation (max 1048576 chars)").option("--comment-file <file>", "Read comment from file; use '-' for stdin").option("--category <tag>", 'Category tag, repeatable. Built-in defaults: "Output", "Agent Error", "Agent Plan Execution"', collect, []).option("--agent-id <guid>", "Agent reference ID").option("--agent-version <str>", "Agent version (max 100 chars)").option("--folder-key <guid>", "Folder key (required for write ops)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (opts) => {
8315
8933
  if (!opts.traceId) {
8316
8934
  OutputFormatter.error({
8317
8935
  Result: RESULTS.Failure,
@@ -8372,11 +8990,10 @@ function registerCreateCommand(program2) {
8372
8990
  }))
8373
8991
  }, { tenant: opts.tenant, folderKey: opts.folderKey }));
8374
8992
  if (error) {
8375
- OutputFormatter.error({
8376
- Result: RESULTS.Failure,
8377
- Code: "FeedbackCreate",
8378
- Message: error.message
8379
- });
8993
+ OutputFormatter.error(await feedbackApiFailure("FeedbackCreate", error, {
8994
+ permissions: "Logs.Create",
8995
+ fallback: "Verify --trace-id, --span-id and --folder-key, then retry."
8996
+ }));
8380
8997
  processContext.exit(1);
8381
8998
  return;
8382
8999
  }
@@ -8399,8 +9016,8 @@ var FEEDBACK_DELETE_EXAMPLES = [
8399
9016
  }
8400
9017
  }
8401
9018
  ];
8402
- function registerDeleteCommand(program2) {
8403
- program2.command("delete [id]").description("Delete feedback by ID").examples(FEEDBACK_DELETE_EXAMPLES).option("--folder-key <guid>", "Folder key (required)").option("-y, --yes", "Confirm this irreversible operation (required; the CLI never prompts)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (id, opts) => {
9019
+ function registerDeleteCommand(program) {
9020
+ program.command("delete [id]").description("Delete feedback by ID").examples(FEEDBACK_DELETE_EXAMPLES).option("--folder-key <guid>", "Folder key (required)").option("-y, --yes", "Confirm this irreversible operation (required; the CLI never prompts)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (id, opts) => {
8404
9021
  if (!id) {
8405
9022
  OutputFormatter.error({
8406
9023
  Result: RESULTS.Failure,
@@ -8429,11 +9046,10 @@ function registerDeleteCommand(program2) {
8429
9046
  folderKey: opts.folderKey
8430
9047
  }));
8431
9048
  if (error) {
8432
- OutputFormatter.error({
8433
- Result: RESULTS.Failure,
8434
- Code: "FeedbackDelete",
8435
- Message: error.message
8436
- });
9049
+ OutputFormatter.error(await feedbackApiFailure("FeedbackDelete", error, {
9050
+ permissions: "Logs.Delete",
9051
+ fallback: "Verify the feedback ID and --folder-key, then retry."
9052
+ }));
8437
9053
  processContext.exit(1);
8438
9054
  return;
8439
9055
  }
@@ -8459,8 +9075,8 @@ var FEEDBACK_GET_EXAMPLES = [
8459
9075
  }
8460
9076
  }
8461
9077
  ];
8462
- function registerGetCommand(program2) {
8463
- program2.command("get [id]").description("Get feedback by ID").examples(FEEDBACK_GET_EXAMPLES).option("--folder-key <guid>", "Folder key (required)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (id, opts) => {
9078
+ function registerGetCommand(program) {
9079
+ program.command("get [id]").description("Get feedback by ID").examples(FEEDBACK_GET_EXAMPLES).option("--folder-key <guid>", "Folder key (required)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (id, opts) => {
8464
9080
  if (!id) {
8465
9081
  OutputFormatter.error({
8466
9082
  Result: RESULTS.Failure,
@@ -8476,11 +9092,10 @@ function registerGetCommand(program2) {
8476
9092
  folderKey: opts.folderKey
8477
9093
  }));
8478
9094
  if (error) {
8479
- OutputFormatter.error({
8480
- Result: RESULTS.Failure,
8481
- Code: "FeedbackGet",
8482
- Message: error.message
8483
- });
9095
+ OutputFormatter.error(await feedbackApiFailure("FeedbackGet", error, {
9096
+ permissions: "Logs.View",
9097
+ fallback: "Verify the feedback ID and --folder-key, then retry."
9098
+ }));
8484
9099
  processContext.exit(1);
8485
9100
  return;
8486
9101
  }
@@ -8508,8 +9123,8 @@ var FEEDBACK_LIST_EXAMPLES = [
8508
9123
  }
8509
9124
  }
8510
9125
  ];
8511
- function registerListCommand(program2) {
8512
- program2.command("list").enablePositionalOptions().description("List feedback entries").examples(FEEDBACK_LIST_EXAMPLES).option("--agent-id <guid>", "Filter by agent ID").option("--agent-version <str>", "Filter by agent version").option("--trace-id <id>", "Filter by trace ID").option("--span-id <id>", "Filter by span ID").option("--status <value>", "Filter by status: Pending, Approved, Dismissed (repeatable)", collect, []).option("--positive", "Return positive feedback only").option("--negative", "Return negative feedback only").option("--limit <n>", "Max results (default: 20, max: 100)", parseInt).option("--offset <n>", "Results to skip (default: 0)", parseInt).addOption(new Option("--skip <n>").hideHelp().argParser(parseInt)).option("--folder-key <guid>", "Folder key").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (opts) => {
9126
+ function registerListCommand(program) {
9127
+ program.command("list").enablePositionalOptions().description("List feedback entries").examples(FEEDBACK_LIST_EXAMPLES).option("--agent-id <guid>", "Filter by agent ID").option("--agent-version <str>", "Filter by agent version").option("--trace-id <id>", "Filter by trace ID").option("--span-id <id>", "Filter by span ID").option("--status <value>", "Filter by status: Pending, Approved, Dismissed (repeatable)", collect, []).option("--positive", "Return positive feedback only").option("--negative", "Return negative feedback only").option("--limit <n>", "Max results (default: 20, max: 100)", parseInt).option("--offset <n>", "Results to skip (default: 0)", parseInt).addOption(new Option2("--skip <n>").hideHelp().argParser(parseInt)).option("--folder-key <guid>", "Folder key").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (opts) => {
8513
9128
  if (opts.positive && opts.negative) {
8514
9129
  OutputFormatter.error({
8515
9130
  Result: RESULTS.Failure,
@@ -8551,11 +9166,10 @@ function registerListCommand(program2) {
8551
9166
  skip: offset.value
8552
9167
  }, { tenant: opts.tenant, folderKey: opts.folderKey }));
8553
9168
  if (error) {
8554
- OutputFormatter.error({
8555
- Result: RESULTS.Failure,
8556
- Code: "FeedbackList",
8557
- Message: error.message
8558
- });
9169
+ OutputFormatter.error(await feedbackApiFailure("FeedbackList", error, {
9170
+ permissions: "Logs.View",
9171
+ fallback: "Verify --folder-key and the filters, then retry."
9172
+ }));
8559
9173
  processContext.exit(1);
8560
9174
  return;
8561
9175
  }
@@ -8582,13 +9196,13 @@ var FEEDBACK_LIST_DETAILED_EXAMPLES = [
8582
9196
  }
8583
9197
  }
8584
9198
  ];
8585
- function registerListDetailedCommand(program2) {
8586
- const listCmd = program2.commands.find((c) => c.name() === "list");
9199
+ function registerListDetailedCommand(program) {
9200
+ const listCmd = program.commands.find((c) => c.name() === "list");
8587
9201
  if (!listCmd) {
8588
9202
  throw new Error("registerListDetailedCommand must be called after registerListCommand");
8589
9203
  }
8590
9204
  listCmd.passThroughOptions();
8591
- listCmd.command("detailed").description("List feedback with span context and extended filters (max 200 items)").examples(FEEDBACK_LIST_DETAILED_EXAMPLES).option("--agent-id <guid>", "Filter by agent ID").option("--agent-version <str>", "Filter by agent version").option("--trace-id <id>", "Filter by trace ID").option("--span-id <id>", "Filter by span ID").option("--status <value>", "Filter by status: Pending, Approved, Dismissed (repeatable)", collect, []).option("--positive", "Return positive feedback only").option("--negative", "Return negative feedback only").option("--category-id <guid>", "Filter by category ID (repeatable)", collect, []).option("--after <iso>", "Created after this time (ISO 8601)").option("--before <iso>", "Created before this time (ISO 8601)").option("--since <duration>", "Relative lookback: 1h, 24h, 7d (shorthand for --after)").option("--sort-by <field>", "Sort field: createdAt, updatedAt (default: createdAt)").option("--sort-order <direction>", "Sort direction: asc, desc (default: desc)").option("--limit <n>", "Max results (default: 20, max: 200)", parseInt).option("--offset <n>", "Results to skip (default: 0)", parseInt).addOption(new Option("--skip <n>").hideHelp().argParser(parseInt)).option("--folder-key <guid>", "Folder key").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (opts) => {
9205
+ listCmd.command("detailed").description("List feedback with span context and extended filters (max 200 items)").examples(FEEDBACK_LIST_DETAILED_EXAMPLES).option("--agent-id <guid>", "Filter by agent ID").option("--agent-version <str>", "Filter by agent version").option("--trace-id <id>", "Filter by trace ID").option("--span-id <id>", "Filter by span ID").option("--status <value>", "Filter by status: Pending, Approved, Dismissed (repeatable)", collect, []).option("--positive", "Return positive feedback only").option("--negative", "Return negative feedback only").option("--category-id <guid>", "Filter by category ID (repeatable)", collect, []).option("--after <iso>", "Created after this time (ISO 8601)").option("--before <iso>", "Created before this time (ISO 8601)").option("--since <duration>", "Relative lookback: 1h, 24h, 7d (shorthand for --after)").option("--sort-by <field>", "Sort field: createdAt, updatedAt (default: createdAt)").option("--sort-order <direction>", "Sort direction: asc, desc (default: desc)").option("--limit <n>", "Max results (default: 20, max: 200)", parseInt).option("--offset <n>", "Results to skip (default: 0)", parseInt).addOption(new Option2("--skip <n>").hideHelp().argParser(parseInt)).option("--folder-key <guid>", "Folder key").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (opts) => {
8592
9206
  if (opts.positive && opts.negative) {
8593
9207
  OutputFormatter.error({
8594
9208
  Result: RESULTS.Failure,
@@ -8650,11 +9264,10 @@ function registerListDetailedCommand(program2) {
8650
9264
  skip: offset.value
8651
9265
  }, { tenant: opts.tenant, folderKey: opts.folderKey }));
8652
9266
  if (error) {
8653
- OutputFormatter.error({
8654
- Result: RESULTS.Failure,
8655
- Code: "FeedbackListDetailed",
8656
- Message: error.message
8657
- });
9267
+ OutputFormatter.error(await feedbackApiFailure("FeedbackListDetailed", error, {
9268
+ permissions: "Logs.View",
9269
+ fallback: "Verify --folder-key and the filters, then retry."
9270
+ }));
8658
9271
  processContext.exit(1);
8659
9272
  return;
8660
9273
  }
@@ -8701,17 +9314,8 @@ var FEEDBACK_UPDATE_EXAMPLES = [
8701
9314
  }
8702
9315
  }
8703
9316
  ];
8704
- function updateInstructions(message) {
8705
- if (message.startsWith("Not authenticated")) {
8706
- return "Run 'uip auth login', then run this command again.";
8707
- }
8708
- if (message.startsWith("Insufficient permissions")) {
8709
- return "Ask a tenant admin to grant Logs.View and Logs.Create on this folder.";
8710
- }
8711
- return "Verify the feedback ID and --folder-key, then retry.";
8712
- }
8713
- function registerUpdateCommand(program2) {
8714
- program2.command("update [id]").description("Update feedback (isPositive, comment, metadata, categories)").examples(FEEDBACK_UPDATE_EXAMPLES).option("--positive", "Change to positive feedback").option("--negative", "Change to negative feedback").option("--comment <text>", "Updated comment (max 1048576 chars)").option("--comment-file <file>", "Read updated comment from file; use '-' for stdin").option("--metadata <json>", "Updated metadata; must be valid JSON (max 1048576 chars)").option("--metadata-file <file>", "Read updated metadata from file; use '-' for stdin").option("--category <tag>", "Replacement category tags (repeatable)", collect, []).option("--folder-key <guid>", "Folder key (required)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (id, opts) => {
9317
+ function registerUpdateCommand(program) {
9318
+ program.command("update [id]").description("Update feedback (isPositive, comment, metadata, categories)").examples(FEEDBACK_UPDATE_EXAMPLES).option("--positive", "Change to positive feedback").option("--negative", "Change to negative feedback").option("--comment <text>", "Updated comment (max 1048576 chars)").option("--comment-file <file>", "Read updated comment from file; use '-' for stdin").option("--metadata <json>", "Updated metadata; must be valid JSON (max 1048576 chars)").option("--metadata-file <file>", "Read updated metadata from file; use '-' for stdin").option("--category <tag>", "Replacement category tags (repeatable)", collect, []).option("--folder-key <guid>", "Folder key (required)").addOption(createHiddenDeprecatedTenantOption("--tenant <name>")).trackedAction(processContext, async (id, opts) => {
8715
9319
  if (!id) {
8716
9320
  OutputFormatter.error({
8717
9321
  Result: RESULTS.Failure,
@@ -8770,12 +9374,10 @@ function registerUpdateCommand(program2) {
8770
9374
  })) : undefined
8771
9375
  }, { tenant: opts.tenant, folderKey: opts.folderKey }));
8772
9376
  if (error) {
8773
- OutputFormatter.error({
8774
- Result: RESULTS.Failure,
8775
- Code: "FeedbackUpdate",
8776
- Message: error.message,
8777
- Instructions: updateInstructions(error.message)
8778
- });
9377
+ OutputFormatter.error(await feedbackApiFailure("FeedbackUpdate", error, {
9378
+ permissions: "Logs.View and Logs.Create",
9379
+ fallback: "Verify the feedback ID and --folder-key, then retry."
9380
+ }));
8779
9381
  processContext.exit(1);
8780
9382
  return;
8781
9383
  }
@@ -8788,8 +9390,8 @@ function registerUpdateCommand(program2) {
8788
9390
  }
8789
9391
 
8790
9392
  // src/commands/feedback/index.ts
8791
- function registerFeedbackCommand(program2) {
8792
- const feedback = program2.command("feedback").enablePositionalOptions().description("Manage LLM Observability feedback for traces and spans");
9393
+ function registerFeedbackCommand(program) {
9394
+ const feedback = program.command("feedback").enablePositionalOptions().description("Manage LLM Observability feedback for traces and spans");
8793
9395
  registerCreateCommand(feedback);
8794
9396
  registerGetCommand(feedback);
8795
9397
  registerListCommand(feedback);
@@ -9052,7 +9654,7 @@ var package_default2 = {
9052
9654
  name: "@uipath/orchestrator-sdk",
9053
9655
  author: "UiPath",
9054
9656
  license: "SEE LICENSE IN LICENSE.txt",
9055
- version: "1.205.0",
9657
+ version: "1.206.0",
9056
9658
  repository: {
9057
9659
  type: "git",
9058
9660
  url: "https://github.com/UiPath/cli.git",
@@ -9079,6 +9681,10 @@ var package_default2 = {
9079
9681
  types: "./dist/src/index.d.ts",
9080
9682
  default: "./dist/index.js"
9081
9683
  }
9684
+ },
9685
+ "./folder-feed": {
9686
+ types: "./dist/src/folder-feed.d.ts",
9687
+ default: "./dist/folder-feed.js"
9082
9688
  }
9083
9689
  },
9084
9690
  files: [
@@ -9086,11 +9692,12 @@ var package_default2 = {
9086
9692
  ],
9087
9693
  private: true,
9088
9694
  scripts: {
9089
- build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && bun build ./src/index.browser.ts --outdir dist --format esm --target browser --external @uipath/auth --external @uipath/common --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
9695
+ build: "bun build ./src/index.ts ./src/folder-feed.ts --outdir dist --format esm --target node --sourcemap=linked && bun build ./src/index.browser.ts --outdir dist --format esm --target browser --external @uipath/auth --external @uipath/common --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
9090
9696
  generate: "bun run src/scripts/generate-sdk.ts",
9091
9697
  lint: "biome check .",
9092
9698
  test: "vitest run",
9093
- "test:coverage": "vitest run --coverage"
9699
+ "test:coverage": "vitest run --coverage",
9700
+ typecheck: "tsc --noEmit"
9094
9701
  },
9095
9702
  devDependencies: {
9096
9703
  "@uipath/auth": "workspace:*",
@@ -10220,6 +10827,39 @@ function ODataValueOfIEnumerableOfMachineFolderDtoFromJSONTyped(json, ignoreDisc
10220
10827
  value: json["value"] == null ? undefined : json["value"].map(MachineFolderDtoFromJSON)
10221
10828
  };
10222
10829
  }
10830
+ // ../orchestrator-sdk/generated/src/models/PersonalWorkspaceDto.ts
10831
+ function PersonalWorkspaceDtoFromJSON(json) {
10832
+ return PersonalWorkspaceDtoFromJSONTyped(json, false);
10833
+ }
10834
+ function PersonalWorkspaceDtoFromJSONTyped(json, ignoreDiscriminator) {
10835
+ if (json == null) {
10836
+ return json;
10837
+ }
10838
+ return {
10839
+ key: json["Key"] == null ? undefined : json["Key"],
10840
+ name: json["Name"] == null ? undefined : json["Name"],
10841
+ isActive: json["IsActive"] == null ? undefined : json["IsActive"],
10842
+ ownerId: json["OwnerId"] == null ? undefined : json["OwnerId"],
10843
+ ownerKey: json["OwnerKey"] == null ? undefined : json["OwnerKey"],
10844
+ ownerName: json["OwnerName"] == null ? undefined : json["OwnerName"],
10845
+ lastLogin: json["LastLogin"] == null ? undefined : new Date(json["LastLogin"]),
10846
+ exploringUserIds: json["ExploringUserIds"] == null ? undefined : json["ExploringUserIds"],
10847
+ id: json["Id"] == null ? undefined : json["Id"]
10848
+ };
10849
+ }
10850
+
10851
+ // ../orchestrator-sdk/generated/src/models/ODataValueOfIEnumerableOfPersonalWorkspaceDto.ts
10852
+ function ODataValueOfIEnumerableOfPersonalWorkspaceDtoFromJSON(json) {
10853
+ return ODataValueOfIEnumerableOfPersonalWorkspaceDtoFromJSONTyped(json, false);
10854
+ }
10855
+ function ODataValueOfIEnumerableOfPersonalWorkspaceDtoFromJSONTyped(json, ignoreDiscriminator) {
10856
+ if (json == null) {
10857
+ return json;
10858
+ }
10859
+ return {
10860
+ value: json["value"] == null ? undefined : json["value"].map(PersonalWorkspaceDtoFromJSON)
10861
+ };
10862
+ }
10223
10863
  // ../orchestrator-sdk/generated/src/models/SearchUserDto.ts
10224
10864
  function SearchUserDtoFromJSON(json) {
10225
10865
  return SearchUserDtoFromJSONTyped(json, false);
@@ -11317,6 +11957,74 @@ class JobsApi extends BaseAPI {
11317
11957
  return await response.value();
11318
11958
  }
11319
11959
  }
11960
+ // ../orchestrator-sdk/generated/src/apis/PersonalWorkspacesApi.ts
11961
+ class PersonalWorkspacesApi extends BaseAPI {
11962
+ async personalWorkspacesGetRaw(requestParameters, initOverrides) {
11963
+ const queryParameters = {};
11964
+ if (requestParameters["$select"] != null) {
11965
+ queryParameters["$select"] = requestParameters["$select"];
11966
+ }
11967
+ if (requestParameters["$expand"] != null) {
11968
+ queryParameters["$expand"] = requestParameters["$expand"];
11969
+ }
11970
+ if (requestParameters["$filter"] != null) {
11971
+ queryParameters["$filter"] = requestParameters["$filter"];
11972
+ }
11973
+ if (requestParameters["$orderby"] != null) {
11974
+ queryParameters["$orderby"] = requestParameters["$orderby"];
11975
+ }
11976
+ if (requestParameters["$top"] != null) {
11977
+ queryParameters["$top"] = requestParameters["$top"];
11978
+ }
11979
+ if (requestParameters["$skip"] != null) {
11980
+ queryParameters["$skip"] = requestParameters["$skip"];
11981
+ }
11982
+ if (requestParameters["$count"] != null) {
11983
+ queryParameters["$count"] = requestParameters["$count"];
11984
+ }
11985
+ const headerParameters = {};
11986
+ if (this.configuration && this.configuration.accessToken) {
11987
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []);
11988
+ }
11989
+ let urlPath = `/odata/PersonalWorkspaces`;
11990
+ const response = await this.request({
11991
+ path: urlPath,
11992
+ method: "GET",
11993
+ headers: headerParameters,
11994
+ query: queryParameters
11995
+ }, initOverrides);
11996
+ return new JSONApiResponse(response, (jsonValue) => ODataValueOfIEnumerableOfPersonalWorkspaceDtoFromJSON(jsonValue));
11997
+ }
11998
+ async personalWorkspacesGet(requestParameters = {}, initOverrides) {
11999
+ const response = await this.personalWorkspacesGetRaw(requestParameters, initOverrides);
12000
+ return await response.value();
12001
+ }
12002
+ async personalWorkspacesGetPersonalWorkspaceRaw(requestParameters, initOverrides) {
12003
+ const queryParameters = {};
12004
+ if (requestParameters["$select"] != null) {
12005
+ queryParameters["$select"] = requestParameters["$select"];
12006
+ }
12007
+ if (requestParameters["$expand"] != null) {
12008
+ queryParameters["$expand"] = requestParameters["$expand"];
12009
+ }
12010
+ const headerParameters = {};
12011
+ if (this.configuration && this.configuration.accessToken) {
12012
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []);
12013
+ }
12014
+ let urlPath = `/odata/PersonalWorkspaces/UiPath.Server.Configuration.OData.GetPersonalWorkspace`;
12015
+ const response = await this.request({
12016
+ path: urlPath,
12017
+ method: "GET",
12018
+ headers: headerParameters,
12019
+ query: queryParameters
12020
+ }, initOverrides);
12021
+ return new JSONApiResponse(response, (jsonValue) => PersonalWorkspaceDtoFromJSON(jsonValue));
12022
+ }
12023
+ async personalWorkspacesGetPersonalWorkspace(requestParameters = {}, initOverrides) {
12024
+ const response = await this.personalWorkspacesGetPersonalWorkspaceRaw(requestParameters, initOverrides);
12025
+ return await response.value();
12026
+ }
12027
+ }
11320
12028
  // ../common/src/session-kind.ts
11321
12029
  var SESSION_KIND_KEY = Symbol.for("@uipath/common/SessionKind");
11322
12030
  function attachSessionKind(carrier, kind) {
@@ -11396,7 +12104,7 @@ async function resolveFolder(input, options) {
11396
12104
  }
11397
12105
  return resolveByKey(foldersApi, input.folderKey);
11398
12106
  }
11399
- return resolveByPath(foldersApi, input.folderPath);
12107
+ return resolveByPath(config, foldersApi, input.folderPath);
11400
12108
  }
11401
12109
  async function resolveByKey(foldersApi, folderKey) {
11402
12110
  const folder = await foldersApi.foldersGetByKeyByIdentifier({
@@ -11413,12 +12121,12 @@ async function resolveByKey(foldersApi, folderKey) {
11413
12121
  feedType: folder.feedType
11414
12122
  };
11415
12123
  }
11416
- async function resolveByPath(foldersApi, folderPath) {
12124
+ async function resolveByPath(config, foldersApi, folderPath) {
11417
12125
  const response = await foldersApi.foldersGet({
11418
12126
  $filter: `FullyQualifiedName eq '${folderPath.replace(/'/g, "''")}'`,
11419
12127
  $top: 1
11420
12128
  });
11421
- const folder = response.value?.[0];
12129
+ const folder = response.value?.[0] ?? await resolveInPersonalWorkspace(config, foldersApi, folderPath);
11422
12130
  if (!folder?.id || !folder.key || !folder.fullyQualifiedName || !folder.displayName) {
11423
12131
  throw new Error(`Folder not found: '${folderPath}'.`);
11424
12132
  }
@@ -11430,6 +12138,66 @@ async function resolveByPath(foldersApi, folderPath) {
11430
12138
  feedType: folder.feedType
11431
12139
  };
11432
12140
  }
12141
+ var CURRENT_USER_FOLDER_PAGE_SIZE = 1000;
12142
+ var CURRENT_USER_FOLDER_PAGE_LIMIT = 50;
12143
+ async function resolveInPersonalWorkspace(config, foldersApi, folderPath) {
12144
+ const workspace = await lookupOrMiss("GetPersonalWorkspace", folderPath, () => new PersonalWorkspacesApi(config).personalWorkspacesGetPersonalWorkspace());
12145
+ if (!workspace?.key || !workspace.name) {
12146
+ return;
12147
+ }
12148
+ const wanted = folderPath.toLowerCase();
12149
+ const root = workspace.name.toLowerCase();
12150
+ let key;
12151
+ if (wanted === root) {
12152
+ key = workspace.key;
12153
+ } else if (wanted.startsWith(`${root}/`)) {
12154
+ key = await findKeyInCurrentUserFolders(foldersApi, folderPath);
12155
+ }
12156
+ if (!key) {
12157
+ return;
12158
+ }
12159
+ const folder = await foldersApi.foldersGetByKeyByIdentifier({
12160
+ identifier: key
12161
+ });
12162
+ return folder?.fullyQualifiedName?.toLowerCase() === wanted ? folder : undefined;
12163
+ }
12164
+ async function findKeyInCurrentUserFolders(foldersApi, folderPath) {
12165
+ const wanted = folderPath.toLowerCase();
12166
+ let skip = 0;
12167
+ for (let page = 0;page < CURRENT_USER_FOLDER_PAGE_LIMIT; page++) {
12168
+ const result = await lookupOrMiss("GetAllForCurrentUser", folderPath, () => foldersApi.foldersGetAllForCurrentUser({
12169
+ take: CURRENT_USER_FOLDER_PAGE_SIZE,
12170
+ skip
12171
+ }));
12172
+ const rows = result?.pageItems ?? [];
12173
+ const match = rows.find((row) => row.fullyQualifiedName?.toLowerCase() === wanted);
12174
+ if (match) {
12175
+ return match.key;
12176
+ }
12177
+ skip += rows.length;
12178
+ if (rows.length === 0 || typeof result?.count === "number" && skip >= result.count) {
12179
+ return;
12180
+ }
12181
+ }
12182
+ logger.debug(`GetAllForCurrentUser: stopped after ${CURRENT_USER_FOLDER_PAGE_LIMIT} pages without finding '${folderPath}'.`);
12183
+ return;
12184
+ }
12185
+ async function lookupOrMiss(endpoint, folderPath, call) {
12186
+ const [error, value] = await catchError(call());
12187
+ if (!error) {
12188
+ return value;
12189
+ }
12190
+ if (!isLookupMiss(error)) {
12191
+ throw error;
12192
+ }
12193
+ logger.debug(`${endpoint} lookup for '${folderPath}' failed: ${await extractErrorMessage(error)}`);
12194
+ return;
12195
+ }
12196
+ function isLookupMiss(error) {
12197
+ const failure = error;
12198
+ const status = failure?.response?.status ?? failure?.status;
12199
+ return typeof status === "number" && status >= 400 && status < 500 && status !== 408 && status !== 429;
12200
+ }
11433
12201
  // ../orchestrator-sdk/src/knowledge-bundles.ts
11434
12202
  var KB_INLINE_LIMITS = {
11435
12203
  maxObjectBytes: 16 * 1024 * 1024,
@@ -11467,26 +12235,21 @@ async function getTraceIdForJob(jobKey, options) {
11467
12235
  return jobTraceId ?? resolvedJobKey;
11468
12236
  }
11469
12237
  async function getSpansForTrace(traceId, options) {
11470
- const [loginError, loginStatus2] = await catchError(getLoginStatusAsync());
11471
- if (loginError) {
11472
- throw new Error(loginError.message);
11473
- }
11474
- if (loginStatus2.loginStatus !== "Logged in" || !loginStatus2.baseUrl) {
11475
- throw new Error("Not logged in. Run 'uip login' first.");
11476
- }
11477
- const tenantName = options.tenant || loginStatus2.tenantName;
11478
- if (!tenantName || !loginStatus2.organizationId) {
11479
- throw new Error("Missing tenant or organization info.");
11480
- }
12238
+ const auth = await getAuthContext({
12239
+ tenant: options.tenant,
12240
+ requireOrganizationId: true,
12241
+ requireTenantName: true
12242
+ });
12243
+ const { tenantName } = auth;
11481
12244
  if (!TRACE_ID_RE.test(traceId)) {
11482
12245
  throw new Error(`Invalid trace ID format: ${traceId}. Must be a 32-char hex string or GUID.`);
11483
12246
  }
11484
12247
  const traceIdNoHyphens = traceId.replaceAll("-", "");
11485
- const url = `${loginStatus2.baseUrl}/${encodeURIComponent(loginStatus2.organizationId)}/${encodeURIComponent(tenantName)}/llmopstenant_/api/Traces/v2/spans/otel?traceId=${encodeURIComponent(traceIdNoHyphens)}`;
12248
+ const url = `${auth.baseUrl}/${encodeURIComponent(auth.organizationId)}/${encodeURIComponent(tenantName)}/llmopstenant_/api/Traces/v2/spans/otel?traceId=${encodeURIComponent(traceIdNoHyphens)}`;
11486
12249
  const response = await fetch(url, {
11487
12250
  method: "GET",
11488
12251
  headers: {
11489
- Authorization: `Bearer ${loginStatus2.accessToken ?? ""}`,
12252
+ Authorization: `Bearer ${auth.accessToken}`,
11490
12253
  "Content-Type": "application/json",
11491
12254
  Accept: "application/json"
11492
12255
  }
@@ -11522,8 +12285,8 @@ var SPANS_GET_EXAMPLES = [
11522
12285
  }
11523
12286
  }
11524
12287
  ];
11525
- var registerSpansCommand = (program2) => {
11526
- const spans = program2.command("spans").description("Manage LLM Observability spans");
12288
+ var registerSpansCommand = (program) => {
12289
+ const spans = program.command("spans").description("Manage LLM Observability spans");
11527
12290
  spans.command("get").description("Get all spans by trace ID, or by job key as an alternative").argument("[trace-id]", "Trace ID (32-char hex or GUID format)").option("--job-key <guid>", "Orchestrator job key (GUID) — alternative to trace-id").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <name>")).option("--folder-path <path>", "Orchestrator folder path").option("--folder-key <guid>", "Orchestrator folder key (GUID)").examples(SPANS_GET_EXAMPLES).trackedAction(processContext, async (traceId, options) => {
11528
12291
  let resolvedTraceId;
11529
12292
  if (options.jobKey) {
@@ -11549,7 +12312,7 @@ var registerSpansCommand = (program2) => {
11549
12312
  processContext.exit(1);
11550
12313
  return;
11551
12314
  }
11552
- const [spansError, spans2] = await catchError(getSpansForTrace(resolvedTraceId, options));
12315
+ const [spansError, spans] = await catchError(getSpansForTrace(resolvedTraceId, options));
11553
12316
  if (spansError) {
11554
12317
  OutputFormatter.error({
11555
12318
  Result: RESULTS.Failure,
@@ -11562,23 +12325,23 @@ var registerSpansCommand = (program2) => {
11562
12325
  OutputFormatter.success({
11563
12326
  Result: RESULTS.Success,
11564
12327
  Code: "TraceSpans",
11565
- Data: spans2
12328
+ Data: spans
11566
12329
  });
11567
12330
  });
11568
12331
  };
11569
12332
 
11570
12333
  // src/tool.ts
11571
- var metadata = {
12334
+ var metadata2 = {
11572
12335
  name: "traces-tool",
11573
12336
  version: package_default.version,
11574
12337
  description: "Fetch LLM Observability traces for UiPath jobs",
11575
12338
  commandPrefix: "traces"
11576
12339
  };
11577
- var registerCommands = async (program2) => {
11578
- registerSpansCommand(program2);
11579
- registerFeedbackCommand(program2);
12340
+ var registerCommands2 = async (program) => {
12341
+ registerSpansCommand(program);
12342
+ registerFeedbackCommand(program);
11580
12343
  };
11581
12344
 
11582
- export { Command, metadata, registerCommands };
12345
+ export { Command, metadata2, registerCommands2 };
11583
12346
 
11584
- //# debugId=FE7CEA37F238615D64756E2164756E21
12347
+ //# debugId=30D8D71D6CD20D2164756E2164756E21